-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Three-disk Tower of Hanoi puzzle. | ||
# | ||
# Moves are printed in order, one on each line, where a move `src dst` indicates | ||
# that the top disk from rod `src` should be moved to rod `dst`. | ||
|
||
@hanoi (disk: int, src: int, dst: int, spare: int) { | ||
zero: int = const 0; | ||
nonneg: bool = ge disk zero; | ||
br nonneg .then .else; | ||
.then: | ||
one: int = const 1; | ||
above: int = sub disk one; | ||
call @hanoi above src spare dst; | ||
print src dst; | ||
call @hanoi above spare dst src; | ||
.else: | ||
ret; | ||
} | ||
|
||
@main { | ||
disk: int = const 2; | ||
src: int = const 0; | ||
dst: int = const 2; | ||
spare: int = const 1; | ||
call @hanoi disk src dst spare; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
0 2 | ||
0 1 | ||
2 1 | ||
0 2 | ||
1 0 | ||
1 2 | ||
0 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
total_dyn_inst: 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters