day 15, factor both parts
This commit is contained in:
parent
032f0c4caa
commit
a4e02c42a7
12
d15/part1.py
12
d15/part1.py
|
@ -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)
|
|
|
@ -8,9 +8,13 @@ def hash(l):
|
||||||
c = c % 256
|
c = c % 256
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
L = sys.stdin.read().split(',')
|
||||||
|
|
||||||
|
print(sum(hash(l) for l in L))
|
||||||
|
|
||||||
B = [ dict() for _ in range(256) ]
|
B = [ dict() for _ in range(256) ]
|
||||||
|
|
||||||
for l in sys.stdin.read().split(','):
|
for l in L:
|
||||||
e = l.find('=')
|
e = l.find('=')
|
||||||
d = l.find('-')
|
d = l.find('-')
|
||||||
i = max(e,d)
|
i = max(e,d)
|
Loading…
Reference in New Issue