MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / hanoi

Function hanoi

Tower-of_Hanoi/hanoi.py:36–356  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34print("Goal: move the full stack to another column.")
35
36def hanoi():
37 global a1
38 global a2
39 global a3
40 global b1
41 global b2
42 global b3
43 global c1
44 global c2
45 global c3
46 global charon
47
48 col = input("Column? ")
49 if col.isdigit():
50
51
52 if int(col) == 1:
53 if a3 == " ":
54 if a2 == " ":
55 if a1 == " ":
56 print("empty.")
57 hanoi()
58 else:
59 charon = a1
60 a1 = " "
61 else:
62 charon = a2
63 a2 = " "
64 else:
65 charon = a3
66 a3 = " "
67
68 move = int(input("Move to? "))
69
70 if move == 1:
71 if a1 == " ":
72 a1 = charon
73 else:
74 if a2 == " ":
75 a2 = charon
76 else:
77 a3 = charon
78
79 elif int(move) == 2:
80 if b1 == " ":
81 b1 = charon
82
83 elif b1 < charon:
84 #print("broken")
85 if a1 == " ":
86 a1 = charon
87 else:
88 if a2 == " ":
89 a2 = charon
90 else:
91 a3 = charon
92
93 else:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected