Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
one line solution in Uncategorized category for Disposable Teleports by Apua
def checkio(teleports_string):
#return any route from 1 to 1 over all points
#Don't remove checkio function
return checkio.__setattr__('f', lambda E={(int(a),int(b)) for a,b in teleports_string.split(',')},k=1,path=[]: checkio.f.__setattr__('ans',''.join(map(str,[1]+path))) or True if len(set(path))==8 and path[-1]==1 else any(checkio.f({e for e in E if e!=(k,n) and e!=(n,k)},n,path+[n]) for n in {e[0] if e[1]==k else e[1] for e in E if k in e})) or checkio.f() and checkio.f.ans
if __name__ == "__main__":
print(checkio("12,23,34,45,56,67,78,81")) #"123456781"
print(checkio("12,28,87,71,13,14,34,35,45,46,63,65")) #"1365417821"
print(checkio("12,15,16,23,24,28,83,85,86,87,71,74,56")) #"12382478561"
print(checkio("13,14,23,25,34,35,47,56,58,76,68")) #"132586741"
Aug. 10, 2013
Comments: