Skip to content

Instantly share code, notes, and snippets.

@gdiggs gdiggs/Assassins

Created Sep 2, 2010
What would you like to do?
# 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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.