Parity Control

Back to Problem Solutions forum

dlardashev     2017-01-08 09:59:56

Please help me. My solution:

def isWrong(s):
    s = str(s)

    if s.count('1') % 2 == 1:
        return 'Wrong'
    elif len(s) == 10 and s[2] == 1:
        return int(s[:2] + s[3:], 2)
        return int(s, 2)        

mes = [bin(int(x)) for x in input().split(' ')]

mes = list(map(isWrong, mes))

mes = [chr(x) for x in mes if x != 'Wrong']

print (''.join(mes))

This task is solved, but chars is wrong, despite digits is correct. What is wrong with chr()?

Quandray     2017-01-08 10:19:19
User avatar


I think chr() is doing what it should do. The problem description says ...

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

I can't see where you are "clearing the highest bit"

dlardashev     2017-01-08 10:39:18

Thanks, man. It is really this problem :)

I cleared the highest bit, but I did forget ' ' and it would stay.

P.S. Sorry for my English

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