Created
September 2, 2010 00:04
-
-
Save gdiggs/561608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Assassin - Random and fair pairing for a game of assassin of any size (defaults to 10) | |
# Takes number of players from args | |
num_players = ARGV[0].to_i == 0 ? 10 : ARGV[0].to_i | |
killers = (0..num_players-1).to_a | |
targets = killers.shuffle | |
puts "killers: #{killers.inspect}" | |
puts "targets: #{targets.inspect}" | |
killers.each do |killer| | |
target = targets[killer] | |
if killer == targets[killer] | |
puts "#{killer} has him/herself" | |
elsif targets.index(killer) == target | |
puts "#{killer} has #{target} and #{target} has #{killer}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment