Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Hanoi Challenge

by tilly (Archbishop)
on Oct 22, 2004 at 16:34 UTC ( #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? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-01-26 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?