By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

how do you shuffle a deck of cards?

P: 6
Using integer and modulus division, determine how a deck of 52 cards can be represented by randomly generating 52 number. Each number should have a numeric value and a suit (ex: 4 of clubs)
Dec 3 '15 #1
Share this Question
Share on Google+
9 Replies


Rabbit
Expert Mod 10K+
P: 12,349
This isn't a code writing service, what have you tried so far?
Dec 3 '15 #2

P: 6
I've been on this project for weeks and I can't figure out anything. The only thing I can think of is assigning a string to every number and making the random number not repeat itself, but that doesn't include any division.
Dec 3 '15 #3

Rabbit
Expert Mod 10K+
P: 12,349
Here's a hint, if you integer divide a random number from 0-51 by 13 you get 0,1,2, or 3. 4 possible results for 4 possible suits. If you mod a random number from 0-51 by 4, you get a number from 0-12. 13 possible results for the 13 possible card ranks.
Dec 3 '15 #4

P: 6
How do I make the numbers not repeat the same outcome?
Dec 3 '15 #5

Rabbit
Expert Mod 10K+
P: 12,349
1) Generate a random number.
2) Check an array that stores the generated numbers to see if it's already in there.
3) If it's in there, go back to 1.
4) If it's not in there, put it in the array.
Dec 3 '15 #6

P: 6
I got the card numbers and suits to work, but I still don't know how to use an array to make the numbers stop repeating.
Dec 15 '15 #7

Rabbit
Expert Mod 10K+
P: 12,349
Each time you generated a card, you loop through the array to see if you already generated before hand.
Dec 15 '15 #8

P: 6
How do I use an array?
Dec 16 '15 #9

Rabbit
Expert Mod 10K+
P: 12,349
That's a very broad topic best suited for a class or tutorial. You can find any number of tutorials on google that will explain it greater detail than can be done in a forum. For example, this one: http://www.tutorialspoint.com/vb.net/vb.net_arrays.htm
Dec 16 '15 #10

Post your reply

Sign in to post your reply or Sign up for a free account.