Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Stack solution in Clear category for Disposable Teleports by flpo
GOAL = set("12345678")
def checkio(teleports_string):
teleports = set(map(frozenset, teleports_string.split(',')))
stack = [('1', teleports)]
while stack:
path, pairs = stack.pop()
last = path[-1]
if last == '1' and set(path) == GOAL:
return path
for n in '12345678'.replace(last, ''):
fs = frozenset((last, n))
if fs in pairs:
stack.append((path + n, pairs - {fs}))
March 21, 2018