Day 5 (with weird logic)
This commit is contained in:
1 parent
bc158d12e1
commit
9a176b9d42
5 files changed
+498
-2
No files matched your search
+3
-2
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user