Project Euler #59: XOR decryption

  • + 0 comments

    Imo this is compact and runs quick!

    from itertools import product
    from string import ascii_lowercase, printable
    
    m=int(input())
    d=input().split()
    
    for k in product(ascii_lowercase,repeat=3):
        for i in range(m):
            if chr(int(d[i])^ord(k[i%len(k)]))not in" ();:,.'?-"+printable[:63]:
                break
        else:
            print("".join(k))
            break