Finished 2023-12-08 p1

This commit is contained in:
FrederikBaerentsen 2023-12-08 10:55:02 +01:00
parent b6ae910775
commit ffe9616398

View File

@ -35,47 +35,48 @@ for i in maps:
nmaps.append([s,l,r]) nmaps.append([s,l,r])
pprint(d) #pprint(d)
pprint(maps) #pprint(maps)
pprint(nmaps) #pprint(nmaps)
count = 0 count = 0
way = nmaps[0][0] way = 'AAA'
first = True first = True
found = False found = False
index = 0 index = 0
print('Starting with ' + way) #print('Starting with ' + way)
cycle = 0
while found == False: while found == False:
for i in d: cycle += 1
print('Finding Index for ' + way,end=' at ') for idx, i in enumerate(d):
#print(way)
#print('Finding Index for ' + way,end=' at ')
c = way c = way
#if first == False: #if first == False:
index = [(i,table.index(c)) for i, table in enumerate(nmaps) if c in table] 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: for j in index:
if list(j)[1] == 0: if list(j)[1] == 0:
index = list(j)[0] index = list(j)[0]
#index = list(index[0])[1] #index = list(index[0])[1]
print(' (true index ',end='') #print(' (true index ',end='')
print(index,end=') ') #print(index,end=') ')
#else: #else:
# first = False # first = False
if i == 'R': if i == 'R':
way = nmaps[index][2] way = nmaps[index][2]
print('Going R to ' + way) #print('Going R to ' + way)
if i == 'L': if i == 'L':
way = nmaps[index][1] way = nmaps[index][1]
print('Going L to ' + way) #print('Going L to ' + way)
count += 1 count += 1
if way == 'ZZZ': if way == 'ZZZ':
found = True found = True
#print('COUND')
continue continue
#if nmaps[index][1] == 'ZZZ' or nmaps[index][2] == 'ZZZ': #if nmaps[index][1] == 'ZZZ' or nmaps[index][2] == 'ZZZ':
# print(nmaps[index][1],nmaps[index][2]) # print(nmaps[index][1],nmaps[index][2])
# print('Found at ' + str(index) + ' with count ' + str(count)) # print('Found at ' + str(index) + ' with count ' + str(count))
# found = True # found = True
# continue # continue
# input() print('Result: ' + str(count))
print(count)