Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: Perl Card Trick

by Flexx (Pilgrim)
on Sep 15, 2002 at 03:24 UTC ( #197987=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Perl Card Trick
in thread Perl Card Trick

I'm sorry to tell you, but that still won't work... (try choosing 1/1 -- two of diamonds). You just shifted (mirrored) the problem...

Now it still works for anything on 1/1 .. 4/4 in the original table...

click Read more below for the solution...

use @cards = reverse @cards;, since that's what you're doing when you collect the cards,(stacking them left to right, top to botton) and then put them up on the table again...

Original numbering was fine, you have to twist your solution lookup, however.

Updated : Here's a diff to your (semi-original) solution:

5c5 < my ($column, $row, @cards2); --- > my ($column, $row); 33,39c33 < for (my $i = 0; $i <= $#cards; $i++) { < for (my $j = 0; $j <= $#cards; $j++) { < $cards2[$i][$j] = $cards[$j][$i]; < $cards2[$j][$i] = $cards[$i][$j]; < } < } < @cards = @cards2; --- > @cards = reverse @cards; 51c45 < print "\n\nYour card is: $cards[$column-1][$row-1][0]$cards[$column- +1][$row-1][1]\n\n"; --- > print "\n\nYour card is: $cards[$row-1][$column-1][0]$cards[$row-1][ +$column-1][1]\n\n"; 56c50 < $i = 4; --- > $i = 1; 66c60 < $i -= 1; --- > $i++;

So long,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://197987]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-03-23 08:54 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (289 votes). Check out past polls.