-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8tile.py
More file actions
51 lines (42 loc) · 1.03 KB
/
Copy path8tile.py
File metadata and controls
51 lines (42 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class tree(object):
def __init__(self):
self.a = None
print("Initail state : ")
a=[[1,2,3],[5,4,6],[7,-1,8]]
print(a)
print("Enter Final state : ")
b=[[1,2,3],[4,5,6],[7,8,-1]]
print(b)
def check(self,a,b):
if a==b:
print("Got the Output")
else:
combination=0
for x in range(0,3):
for y in range(0,3):
if(a[x][y]==-1):
if x==1 and y==1:
combination=4
print("4 Combination possible")
list1 = [[]]
temparray1 = a
temp = a[0][y]
a[0][y] = a[x][y]
a[x][y] = temp
temp1 = a
a = temparray1
if (x==0 and y==0) or (x==2 and y==2) or (x==0 and y==2) or (x==2 and y==0):
combination=2
print("2 Combination possible")
if (x==0 and y==1) or (x==1 and y==0) or (x==2 and y==1) or (x==1 and y==2):
combination=3
print("3 Combination possible")
print("Initail state : ")
a=[[1,2,3],[4,6,5],[7,-1,8]]
print(a)
print("Enter Final state : ")
b=[[1,2,3],[4,5,6],[7,8,-1]]
print(b)
root = tree()
root.check(a,b)
print(root)