import os
import time
N = 9
T = [1,2,3,4,5,6,7,8,0]#the original state
obj = [2,4,3,1,6,0,7,5,8]#the final state
factory = [1, 1, 2, 6, 24, 120,720, 5040,40320]
defformed_print(L):
n = 0;
for i in range(0,7,3):
t = L[i:i+3]
print(t[0],t[1],t[2])
print('\n')
defget_state(node):
used,sum = [0]*9,0for pos,i in enumerate(node):
num = 0
used[i] = 1for k in range(0,i):
if(used[k]==0):num += 1
sum += num*factory[8-pos]
return sum
deffind_next_nodes(curr_node):defswap(L,i,j):#return a list with swapped items
temp = L[::]
temp[i],temp[j] = temp[j],temp[i]
return temp
pos = curr_node.index(0)#find the position of 0
i,j = pos//3,pos%3
import os import time N = 9 T = [1,2,3,4,5,6,7,8,0]#the original state obj = [2,4,3,1,6,0,7,5,8]#the final state factory = [1, 1, 2, 6, 24, 120,720, 5040,40320] def formed_print(L): n = 0;