Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short solution in Uncategorized category for Disposable Teleports by altarfinch
def explore(n,t,s):
return [n] if not s and n == '1' else [n + c for l in [l for l in t if l[0] == n] for c in explore(l[1],list(set(t) - set([l]) - set([l[::-1]])),s.replace(n,''))]
def checkio(str):
return explore('1',str.split(',') + str[::-1].split(','),'2345678')[0]
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"
June 21, 2013
Comments: