Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import product, combinations
- from functools import reduce
- from operator import xor, mul
- open("output.txt", "w").write("".join(str(i) for i in (lambda r, m, word: (lambda m, coefficients: [reduce(xor, [coefficients[index] * reduce(mul, [value[m - i - 1] for i in index], 1) for index in coefficients], 0) for value in product(*[[0, 1]] * m)])(m, ((lambda degree_coefficients: lambda r, m, word: (lambda f: (lambda x: f(lambda *args: x(x)(*args)))(lambda x: f(lambda *args: x(x)(*args))))(lambda f: lambda m, degree, word: degree_coefficients(m, degree, word) if degree == 0 else dict([coefficients.items() | f(m, degree - 1, [int(word[sum(j * 2 ** i for i, j in enumerate(value[::-1]))]) ^ reduce(xor, [coefficients[index] * reduce(mul, (value[m - i - 1] for i in index), 1) for index in coefficients], 0) for value in product(*[[0, 1]] * m)]).items() for coefficients in [degree_coefficients(m, degree, word)]][0]))(m, r, word))(lambda m, degree, word: dict((index, 1 if sum([2 * reduce(xor, [int(word[sum(j * 2 ** i for i, j in list(zip(index, index_values)) + list(zip([i for i in range(m) if i not in index], co_index_values)))]) for index_values in product(*[[0, 1]] * degree)], 0) - 1 for co_index_values in product(*[[0, 1]] * (m - degree))]) > 0 else 0) for index in combinations(range(m), degree))))(r, m, word)))(int(open("input.txt").readline().split()[0]), int(open("input.txt").readline().split()[1]), open("input.txt").readlines()[1].strip())))
Advertisement
Add Comment
Please, Sign In to add comment