Skip to content

Instantly share code, notes, and snippets.

@WA9ACE
Last active December 22, 2015 21:19
Show Gist options
  • Save WA9ACE/6532242 to your computer and use it in GitHub Desktop.
Save WA9ACE/6532242 to your computer and use it in GitHub Desktop.
13 cut card trick
cards = [*'2'..'10', 'J', 'Q', 'K', 'A']
suits = ['C', 'D', 'H', 'S']
deck = cards.product(suits).map(&:join)
13.times do
r = rand(1..52)
cut = deck.pop(r)
deck.unshift(cut).flatten!
end
# Output is each number of all suits together everytime
puts deck
=begin Sample Output
2C
2D
2H
2S
3C
3D
3H
3S
4C
4D
4H
4S
5C
5D
5H
5S
6C
6D
6H
6S
7C
7D
7H
7S
8C
8D
8H
8S
9C
9D
9H
9S
10C
10D
10H
10S
JC
JD
JH
JS
QC
QD
QH
QS
KC
KD
KH
KS
AC
AD
AH
AS
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment