Card shuffles: Difference between revisions

m
added whitespace to the task's preamble, added a ;Task and ;Bonus section headers, added a Games category.
(Added Perl example)
m (added whitespace to the task's preamble, added a ;Task and ;Bonus section headers, added a Games category.)
Line 1:
[[Category:Games]]
 
{{draft task|Games}}
 
There are many techniques that people use to shuffle [[Playing cards|cards]] for card games. Some are more effective than others.
 
 
The task here is to implement the (seemingly) more common techniques of the riffle shuffle and overhand shuffle for ''n'' iterations. Implementing playing cards is not necessary if it would be easier to implement these shuffling methods for generic collections. Where possible, compare this to a standard/built-in shuffling procedure.
;Task
Implement the (seemingly) more common techniques of the riffle shuffle and overhand shuffle for   ''n''   iterations.
 
 
Implementing playing cards is not necessary if it would be easier to implement these shuffling methods for generic collections.
 
Where possible, compare this to a standard/built-in shuffling procedure.
 
One iteration of the riffle shuffle is defined as:
# Split the deck into two piles
# Merge the two piles by alternating taking one card from the top or bottom (the same throughout the whole merge) of each pile
# The merged deck is now the new "shuffled" deck
 
 
One iteration of the overhand shuffle is defined as:
# Take a group of consecutive cards from the top of the deck. For our purposes up to 20% of the deck seems like a good amount.
# Place that group on top of a second pile
# Repeat these steps until there are no cards remaining in the original deck
# The second pile is now the new "shuffled" deck
 
 
;Bonus
Implement other methods described in the Wikipedia article:   [https://wikipedia.org/wiki/Shuffling#Shuffling_techniques|shuffling techniques].
 
'''Bonus:''' Implement other methods described [[wp:Shuffling#Shuffling_techniques|here]]. Allow for "human errors" of imperfect cutting and interleaving.
<br><br>
 
=={{header|C++}}==