Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
receive, review, rewrite, reveal, relish solution in Clear category for Anagrams By Stacks by veky
def checkio(data):
import collections
start, end = data.split('-')
stacks, moves = slice(3), slice(3, None)
visited, queue = set(), collections.deque([('', start, '')])
while queue:
S = queue.popleft()
visited.add(S[stacks])
if S[2] == end: return ','.join(S[moves])
for s,e in (0,1), (0,2), (1,0), (1,2), (2,0), (2,1):
if S[s] and (e or not S[e]):
T = tuple(map(list, S))
T[e].append(T[s].pop())
T = tuple(map(''.join, T))
if T[stacks] not in visited: queue.append((*T, f"{s}{e}"))
Sept. 11, 2016
Comments: