Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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,
Flexx

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://197987]
help
Chatterbox?
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-07-21 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (449 votes). Check out past polls.

    Notices?