SeedV / SeedLang

An embeddable and visualizable scripting engine for .Net and Unity.
https://seedv.github.io/SeedLang/
Apache License 2.0
9 stars 1 forks source link

Correct the tower order of the Hanoi program #241

Closed wixette closed 1 year ago

wixette commented 1 year ago

"C" should be the target tower, and "B" should be the auxiliary tower.

After this fix, the output of the Hanoi script:

dotnet run --project csharp/src/SeedLang.Shell -- -f example_scripts/seedpython/hanoi.py 
SeedLang.Shell 0.3.0-preview20220923142436
Copyright 2021-2022 The SeedV Lab.

Enabled Visualizers: 

---------- Source ----------
1     # Tower of Hanoi problem.
2     def move(n, source, target, auxiliary):
3         if n <= 0:
4             return
5         move(n - 1, source, auxiliary, target)
6         print('Tower ' + source + ' -> Tower ' + target)
7         move(n - 1, auxiliary, target, source)
8     
9     
10    num = 3
11    move(num, 'A', 'C', 'B')

---------- Run ----------
Tower A -> Tower C
Tower A -> Tower B
Tower C -> Tower B
Tower A -> Tower C
Tower B -> Tower A
Tower B -> Tower C
Tower A -> Tower C