Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re^3: Perl Card Trick by Flexx
in thread Perl Card Trick by Lysander

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found