Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def path(connected,visited = ['start']): return 1 if visited[-1] == 'end' else sum([path(connected,visited+[p]) for p in [route for route in [i[0] for i in connected if i[1] == visited[-1]]+[i[1] for i in connected if i[0] == visited[-1]] if not route == "start" and ((not route in visited) or (not len(set([a for a in visited if a == a.lower()])) < len([a for a in visited if a == a.lower()])) or (route == route.upper()))]])
- print(path([a.split("-") for a in open('input12.txt').read().split("\n")]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement