Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Hanoi Challenge

by tilly (Archbishop)
on Oct 22, 2004 at 16:34 UTC ( [id://401559]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://401559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found