Day 5 (with weird logic)

This commit is contained in:
Maya Herrscher committed 2023-12-05 13:58:46 +01:00
1 parent bc158d12e1
commit 9a176b9d42
5 files changed
+498 -2

No files matched your search

+3 -2
View File
@@ -4,7 +4,6 @@ import sys
NUMS = ['0','1','2','3','4','5','6','7','8','9']
def get_number(schema, x, y):
start = x
while start > 0:
@@ -47,8 +46,9 @@ if __name__ == '__main__':
for x, sym in enumerate(line):
if x < next_x: continue
if sym in NUMS:
n, next_x = part_number(schema, x, y)
n, next_x = get_number(schema, x, y)
res1 += n
else: continue
res1 = str(res1)
print(f"challenge 1:\n{res1}\n")
@@ -58,6 +58,7 @@ if __name__ == '__main__':
for y, line in enumerate(schema):
for x, sym in enumerate(line):
if sym == '*': res2 += gear_ratio(schema, x, y)
else: continue
res2 = str(res2)
print(f"challenge 2:\n{res2}\n")