Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created January 29, 2010 12:14
Show Gist options
  • Save benfoxall/289684 to your computer and use it in GitHub Desktop.
Save benfoxall/289684 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
n = 52 # size of deck
s = 8 # number of shuffles
cards = []
n.times {|card| cards << card}
s.times do |shuffle|
a = cards[0...(n/2)]
b = cards[(n/2)..n ]
n.times do |c|
cards[c] = (c%2==0 ? a : b).shift
end
puts "#{shuffle+1}.\t #{cards.join ','}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment