http://qs321.pair.com?node_id=401559


in reply to Hanoi Challenge

And to get things going, I'll post the bad solution that everyone should be able to beat. This ignores all but the first 3 pegs.
#! /usr/bin/perl -w use strict; my $disk_count = pop; solve('A'..'C', reverse 1..$disk_count); sub solve { my ($peg_from, $peg_to, $peg_hold, $first_disk, @rest) = @_; return unless $first_disk; solve($peg_from, $peg_hold, $peg_to, @rest); print "$first_disk: $peg_from -> $peg_to\n"; solve($peg_hold, $peg_to, $peg_from, @rest); }
Again, this makes no use of extra pegs, which you can use to beat it.