master
E. Almqvist 4 years ago
parent 8ad018d09e
commit 1a062eb099
  1. 11
      2020/14.py

@ -92,9 +92,7 @@ curMask = None
mem = dict() mem = dict()
mem2 = dict() mem2 = dict()
for i in range( len(data) ): for line in data:
line = data[i]
address, val = parseLine(line) address, val = parseLine(line)
if( address != "mask" ): if( address != "mask" ):
val, oldval = applyMask(val, curMask) val, oldval = applyMask(val, curMask)
@ -114,12 +112,7 @@ for i in range( len(data) ):
curMask = val curMask = val
continue continue
memsum, memsum2 = 0, 0 memsum, memsum2 = sum(mem.values()), sum(mem2.values())
for addr, val in mem.items():
memsum += val
for addr, val in mem2.items():
memsum2 += val
print("Part1:", memsum) print("Part1:", memsum)
print("Part2:", memsum2) print("Part2:", memsum2)

Loading…
Cancel
Save