Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
11-liner: clean as a whistle solution in Clear category for Disposable Teleports by przemyslaw.daniel
def checkio(teleports_string):
stack = [("1", teleports_string.split(','))]
while stack:
path, teleport_list = stack.pop()
if len(set(path)) == 8 and path[0] == path[-1]:
return path
for teleport in teleport_list:
if teleport.find(path[-1]) > -1:
new_node = teleport.replace(path[-1], '')
new_list = filter(lambda x: x != teleport, teleport_list)
stack += [(path+new_node, list(new_list))]
June 2, 2017