From ffe9616398da31a66d22344cf499d2f5e63007ad Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Fri, 8 Dec 2023 10:55:02 +0100 Subject: [PATCH] Finished 2023-12-08 p1 --- 2023/day8/part1.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/2023/day8/part1.py b/2023/day8/part1.py index 25591ba..66413f0 100644 --- a/2023/day8/part1.py +++ b/2023/day8/part1.py @@ -35,47 +35,48 @@ for i in maps: nmaps.append([s,l,r]) -pprint(d) -pprint(maps) -pprint(nmaps) +#pprint(d) +#pprint(maps) +#pprint(nmaps) count = 0 -way = nmaps[0][0] +way = 'AAA' first = True found = False index = 0 -print('Starting with ' + way) +#print('Starting with ' + way) +cycle = 0 while found == False: - for i in d: - print('Finding Index for ' + way,end=' at ') + cycle += 1 + for idx, i in enumerate(d): + #print(way) + #print('Finding Index for ' + way,end=' at ') c = way #if first == False: index = [(i,table.index(c)) for i, table in enumerate(nmaps) if c in table] - print(index,end='') + #print(index,end='') for j in index: if list(j)[1] == 0: index = list(j)[0] #index = list(index[0])[1] - print(' (true index ',end='') - print(index,end=') ') + #print(' (true index ',end='') + #print(index,end=') ') #else: # first = False if i == 'R': way = nmaps[index][2] - print('Going R to ' + way) + #print('Going R to ' + way) if i == 'L': way = nmaps[index][1] - print('Going L to ' + way) + #print('Going L to ' + way) count += 1 if way == 'ZZZ': found = True + #print('COUND') continue #if nmaps[index][1] == 'ZZZ' or nmaps[index][2] == 'ZZZ': # print(nmaps[index][1],nmaps[index][2]) # print('Found at ' + str(index) + ' with count ' + str(count)) # found = True # continue - # input() - print(count) - - +print('Result: ' + str(count))