day 15, factor both parts

This commit is contained in:
setop 2023-12-16 00:26:27 +01:00
parent 032f0c4caa
commit a4e02c42a7
2 changed files with 5 additions and 13 deletions

View File

@ -1,12 +0,0 @@
import sys
S=0
for l in sys.stdin.read().split(','):
c = 0
for w in l:
c += ord(w)
c *= 17
c = c % 256
print(l, c)
S += c
print(S)

View File

@ -8,9 +8,13 @@ def hash(l):
c = c % 256
return c
L = sys.stdin.read().split(',')
print(sum(hash(l) for l in L))
B = [ dict() for _ in range(256) ]
for l in sys.stdin.read().split(','):
for l in L:
e = l.find('=')
d = l.find('-')
i = max(e,d)