my advent of code 2021 solutions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
757 B

import sys
inp = {}
solutions = []
def juzgfvzgv(poi, path, twice):
nex = inp[poi]
#print(nex)
for i in nex:
if i == 'end':
solutions.append(path + [i])
continue
elif i.islower() and i in path:
if twice and i != 'start':
juzgfvzgv(i, path + [i], False)
else:
continue
else:
juzgfvzgv(i, path + [i], twice)
with open(sys.argv[1], 'r') as f:
for i in f.readlines():
i = i.strip()
temp1, temp2 = i.split('-', 1)
inp.setdefault(temp1, list()).append(temp2)
inp.setdefault(temp2, list()).append(temp1)
juzgfvzgv('start', ['start'], True)
for i in solutions:
print(i)
print(len(solutions))