Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fillA(n, a):
- while n > 0:
- a.append(n)
- n = n - 1
- return (a)
- def smove(a, b):
- global i
- if len(a) > 0:
- b.append(a.pop())
- print(source, C, target)
- i = i + 1
- def move(n, start, end, auxiliary):
- if n == 1:
- smove(start, end)
- if n > 1:
- move(n - 1, start, auxiliary, end)
- smove(start, end)
- move(n - 1, auxiliary, end, start)
- if __name__ == '__main__':
- x = int(input("Nombre de palet :"), 10)
- i = 0
- source = list()
- target = list()
- C = list()
- source = fillA(x, source)
- print("Positions de départ : ", source, C, target)
- move(x, source, target, C)
- print("Etapes : ", i)
Add Comment
Please, Sign In to add comment