diff --git a/d15/part1.py b/d15/part1.py deleted file mode 100644 index f07eaba..0000000 --- a/d15/part1.py +++ /dev/null @@ -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) diff --git a/d15/part2.py b/d15/run.py similarity index 86% rename from d15/part2.py rename to d15/run.py index d1ef39c..a9c5765 100644 --- a/d15/part2.py +++ b/d15/run.py @@ -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)