On 6/28/07, Martin Barth <[EMAIL PROTECTED]> wrote:
snip
> #!/usr/bin/perl
You are missing two lines here.
use strict;
use warnings;
If you don't put those two lines you will be surprised by what Perl
does with your code.
>
> @startingdeck = ("A H","2 H","3 H","4 H","5 H","6 H","7 H","8 H",
I dont understand why you dont like your solution?
whats wrong at 3 H 4 H 5 H 6 H 7 H?
On Thu, 28 Jun 2007 12:59:21 +0300
"Amichai Teumim" <[EMAIL PROTECTED]> wrote:
> Yeah I don't mind cheating in this one ;)
>
> I just need the top five cards printed, even if the same each time.
>
> Any ide
Hi,
If you don't use rand() you will allways get the same result after
shuffeling. Is that OK for you?
( you're cheating in card games, right? *eg* )
On Thu, 28 Jun 2007 12:37:29 +0300
"Amichai Teumim" <[EMAIL PROTECTED]> wrote:
> Thanks for all the answers. I know there are other better ways of
Thanks for all the answers. I know there are other better ways of doing this
shuffle. I must however, use pop shift ans push.
#!/usr/bin/perl
@startingdeck = ("A H","2 H","3 H","4 H","5 H","6 H","7 H","8 H",
"9 H","10 H","J H","Q H","K H",
"A D","2 D","3 D","4 D",
Amichai Teumim <[EMAIL PROTECTED]> asked:
> I want to shuffle a deck of cards and then print out the top
> five cards.
Read the Perl faq entry on shuffling arrays (i.e. perldoc -q shuffle).
If you're using a fairly recent version of Perl, this'll get you started.
#!/usr/bin/perl -w
use strict
Amichai Teumim wrote:
I want to shuffle a deck of cards and then print out the top five cards.
I want to learn this, so please provide me with hints and tips as
opposed to plain solutions if possible please.
perldoc -q shuffle
John
--
Perl isn't a toolbox, but a small machine shop where you
Amichai Teumim 写道:
I want to shuffle a deck of cards and then print out the top five cards.
But what's "top five cards" since I saw all the cards are unique.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
I want to shuffle a deck of cards and then print out the top five cards.
#!/usr/bin/perl
@startingdeck = ("A H","2 H","3 H","4 H","5 H","6 H","7 H","8 H",
"9 H","10 H","J H","Q H","K H",
"A D","2 D","3 D","4 D","5 D","6 D","7 D","8 D",
"9 D","10 D"