Problem 33 - Parity Control

Back to Problem Solutions forum

Eddie_Hitler     2022-01-19 13:31:56
User avatar

Hey All,

I'm working on Parity control but I keep getting the answer wrong. There's a part of the problem that reads:

Answer should contain message with corrupted bytes removed, highest bits cleared - and represented as characters rather than numbers.

What does "highest bits cleared" actually mean? It's not so much a coding problem I'm having, rather I don't understand the question.

This is causing my answer to contain extra characters as below:

Expected Answer: meMSZkFnXr FoWvmuLRdixa8NmTnlfnp 5CZiH2FV0ZQj R66 n58mgt c8Qa JT L.

My Answer: JmQeM5SZkFnXrb 1FvoWvmuhLRdixa8NmTIDpUnlfnp 5CZimH2FV0ZQjb RE66 B n5R8mgJltv c8Qa JtT uL.

I thought maybe it meant to just remove the highest number, but the example answer given is:

input data: 65 238 236 225 46

answer: Ana.

So, this means that 65 = A, 238 = n, 236 = l, 255 = a and 46 = .

How do I know how to identify the extra character? The example answer means it's l, which is 236 and not the highest number.

Thanks :D

(this is driving me absolutely nuts.)

Eddie_Hitler     2022-01-19 13:48:11
User avatar

If it helps here is my code:

import re
x = input("Input: ")
x = re.findall(r"[0-9]+",x)
x = [int(x) for x in x]
end = []
for _ in range(len(x)):
    a = x.pop(0)    
    if a > 122: 
        a -= 128
    if (a >= 48 and a <= 57) or (a >= 64 and a <= 90) or (a >= 97 and a <= 122) or (a == 46) or (a == 32):
        num = bin(a).replace("b","")
        letter = "".join([chr(int(binary, 2)) for binary in num.split(" ")])
        end.append(letter)
print("".join(end))
gardengnome     2022-01-19 14:00:01
User avatar

"corrupted bytes removed, highest bits cleared" byte corrupted: ignore it (it should not feature in output) highest bit cleared: the byte representation should not start with 1

Eddie_Hitler     2022-01-19 14:04:57
User avatar

Thanks man, think I'm going to give up on this one for now then. I went with just removing 128 from any interger more than 122 as that would count for that extra byte, it'll need a whole re-work.

Thanks again for the help.

gardengnome     2022-01-19 14:08:37
User avatar

The first part - ignore corrupted bytes - is a one-line check. Think about how you identify that a byte is corrupted. Hint: python has a lovely count() function that allows you to count how often a chracter appears in a string.

Eddie_Hitler     2022-01-19 14:46:48
User avatar

i must be losing my mind.

Input: 65 238 236 225 46
0b1000001
0b11101110
0b11101100
0b11100001
0b101110
Anla.

How can you tell which one is corrupted from the above?

Thanks for your help.

Eddie_Hitler     2022-01-19 14:52:20
User avatar

I got it :D thanks again!!! All good. There's 3 hours i'll never get back!!

Please login and solve 5 problems to be able to post at forum