Created
January 2, 2023 18:47
-
-
Save Zerumi/b5433d694788730a722bee300c5d9a50 to your computer and use it in GitHub Desktop.
/ ! \ Made by Dmitriy Chebanenko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
list = [] | |
ans = [] | |
result = [] | |
d = {a : chr(a + ord('A')) for a in range(0, n)} | |
for i in range (2**n): | |
temp = "" | |
while(len(temp)!=n+1): | |
temp = input() | |
temp = temp.replace(' ', '') | |
a = [int(i) for i in temp] | |
ans.append(a[len(a)-1]) | |
list.append(a) | |
for i in range(2**n): | |
temp = [] | |
for j in range (len(ans)-1): | |
temp.append((ans[j]+ans[j+1])%2) | |
result.append(ans[0]) | |
ans = temp | |
print(result) | |
pp = "" | |
for i in range(2**n): | |
s = bin(i)[2:] | |
s = '0'*(n-len(s)) + s | |
if (s.count('1')==0 and result[i]==1): | |
pp+="1 + " | |
elif (result[i]==1): | |
for j in range (len(s)): | |
if (s[j]=='1'): | |
pp+=d[j] | |
pp+=" + " | |
pp = pp[:-2] | |
print(pp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment