Tags
There are no tags for this page.
Attachments
Perl 6
Tower of Hanoi
Description
Invented by the French mathematician Édouard Lucas in 1883, this is a mathematical game/puzzle about moving a set of disks between a set of pegs, limited by the following rules :
- Only one disk may be moved at a time.
- Each move consists of taking the upper disk from one of the pegs and sliding it onto another peg, on top of the other disks that may already be present on that peg.
- No disk may be placed on top of a smaller disk.
Solutions
http://svn.pugscode.org/pugs/examples/algorithms/hanoi.pl
Status with current release of perl 6 / parrot
- Parrot 0.5.1 December 2007 : compiler errors - subs and argv not implemented
- Parrot SVN Revision 24336 20 December 2007 : works without // and argv syntax (http://nopaste.snit.ch:8001/11939)
- Parrot SVN Revision 24478 3 January 2008 : works as is
- Pugs SVN revision 18224 : works as is
Benchmarks
1000 iterations with 6 disks - skip output ( or comment on output to file, etc : http://sial.org/pbot/29516 thanks to Stephen Weeks / Tene on #perl6 )
- Pugs revision 18224 ( 1ghz, 640M ram )
- (100 iterations with 1 say per iteration) : real 0m22.611s, user 0m22.384s, sys 0m0.101s
- Parrot revision 24336 ( 1.6ghz, 2G ram )
- (1000 iterations no printing ) : real 0m3.577s, user 0m3.119s, 0m0.452s
- (100 iterations with 1 say per iteration) : real 0m0.841s, user 0m0.694s, sys 0m0.141s
Comparisons against Perl 5, etc
References
|