Dissipate
Diamond Member
Here is an interesting programming puzzle you might want to try:
You want to program a card game that uses a standard deck of 52 playing cards. In order to program such a game you have to simulate a deck of cards being dealt one by one off the top of a virtual deck. Hence, you must write a function that shuffles the deck of cards before the cards are dealt.
So an array of integers from 1 - 52 is passed into your function Shuffle(). Shuffle() then randomizes the location of all the numbers in the array to simulate the deck of cards being thoroughly shuffled. The only things you have to work with are the array itself and a random number generator, plus some integer variables to use as placeholders and of course standard loops.
Explain the algorithm of the Shuffle() function.
You want to program a card game that uses a standard deck of 52 playing cards. In order to program such a game you have to simulate a deck of cards being dealt one by one off the top of a virtual deck. Hence, you must write a function that shuffles the deck of cards before the cards are dealt.
So an array of integers from 1 - 52 is passed into your function Shuffle(). Shuffle() then randomizes the location of all the numbers in the array to simulate the deck of cards being thoroughly shuffled. The only things you have to work with are the array itself and a random number generator, plus some integer variables to use as placeholders and of course standard loops.
Explain the algorithm of the Shuffle() function.