Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First - Breadth first search solution in Clear category for The 88th Puzzle by carel.anthonissen
def puzzle88(state):
GOAL = (1, 2, 1, 0, 2, 0, 0, 3, 0, 4, 3, 4)
ROT = ((3,5,2,0),(4,6,3,1),(8,10,7,5),(9,11,8,6))
rotate = lambda seq,rot: tuple([seq[rot[rot.index(i)-1]] if i in rot else c for i,c in enumerate(seq)])
gen = {rotate(state,r):str(i+1) for i,r in enumerate(ROT)}
while GOAL not in gen:
gen = {rotate(s,r):gen[s] + str(i+1) for s in gen.keys() for i,r in enumerate(ROT)}
return gen[GOAL]
May 13, 2017