Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Disposable Teleports by natsuki
def checkio(teleports_string):
teleports = [set(t) for t in teleports_string.split(',')]
stack = [('1', '1', [])] # (station, route, visited)
while stack:
station, route, visited = stack.pop()
if len(set(route)) == 8 and route[-1] == '1':
return route
else:
for teleport in [t for t in teleports if station in t and t not in visited]:
dest = (teleport - {station}).pop()
stack.append((dest, route + dest, visited + [{station, dest}]))
return ''
April 2, 2014
Comments: