Skip to content

Instantly share code, notes, and snippets.

@hyperneutrino
Created December 14, 2020 06:28
Show Gist options
  • Save hyperneutrino/ff8d5d47c7decde8c1c00a4699999cf2 to your computer and use it in GitHub Desktop.
Save hyperneutrino/ff8d5d47c7decde8c1c00a4699999cf2 to your computer and use it in GitHub Desktop.
mask = ""
m = {}
while True:
try: line = input()
except: break
if line[1] == "a":
mask = line[7:]
else:
a, b = map(int, line[4:].split("] = "))
b = bin(b)[2:].zfill(36)
k = ""
for i, j in zip(mask, b):
if i == "X": k += j
else: k += i
m[a] = int(k, 2)
print(sum(m.values()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment