Towers of Hanoi: Difference between revisions

added Inform 7 solution
m (Use Template:Task instead of Template:Puzzle. The Puzzle template's meaning is rather vague, and there is probably a better way to handle that information.)
(added Inform 7 solution)
Line 463:
==={{header|Unicon}}===
This Icon solution works in Unicon.
 
=={{header|Inform 7}}==
<lang inform7>Hanoi is a room.
 
A disk is a kind of supporter.
 
A post is a kind of supporter. A post is always fixed in place.
 
The left post, the middle post, and the right post are posts in Hanoi.
 
A disk is a kind of supporter.
The red disk is a disk on the left post.
The orange disk is a disk on the red disk.
The yellow disk is a disk on the orange disk.
The green disk is a disk on the yellow disk.
 
Definition: a disk is topmost if nothing is on it.
 
When play begins:
move 4 disks from the left post to the right post via the middle post.
 
To move (N - number) disk/disks from (FP - post) to (TP - post) via (VP - post):
if N > 0:
move N - 1 disks from FP to VP via TP;
say "Moving a disk from [FP] to [TP]...";
let D be a random topmost disk enclosed by FP;
if a topmost disk (called TD) is enclosed by TP, now D is on TD;
otherwise now D is on TP;
move N - 1 disks from VP to TP via FP.</lang>
 
=={{header|Io}}==
Anonymous user