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

Re^2: Lights out puzzle

by ambrus (Abbot)
on Dec 01, 2011 at 10:41 UTC ( #941039=note: print w/ replies, xml ) Need Help??


in reply to Re: Lights out puzzle
in thread Lights out puzzle

I changed the definition of the show and toggle methods like this:

sub show { my $board = shift; print "\e[H"; for my $row (@$board) { return unless defined $row; print map $_ ? '*' : defined $_ ? '.' : '', @$row; print "\e[K\n"; } print "\e[J"; use Time::HiRes "sleep"; sleep(6e-3); } # show sub toggle { my ($board, $x, $y) = @_; my $old = $board->[$y][$x]; return unless defined $old; $board->[$y][$x] = $old eq 1 ? 0 : 1; } # toggle
and now I can see the lights being chased down to the bottom of the board. Looks nice.


Comment on Re^2: Lights out puzzle
Download Code
Replies are listed 'Best First'.
Re^3: Lights out puzzle
by choroba (Canon) on Dec 01, 2011 at 11:00 UTC
    Yes, in fact, I did something similar for debugging :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (21)
As of 2015-07-31 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls