Skip to content

Instantly share code, notes, and snippets.

@igrabes
Created November 13, 2011 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igrabes/1362714 to your computer and use it in GitHub Desktop.
Save igrabes/1362714 to your computer and use it in GitHub Desktop.
secret_santa (gideon)
@list = Array.new
puts "Please enter all of the people that will be participating in this years Secret Santa"
while true
input = gets.chomp
if input == ''
break
end
@list << input
list_count = @list.count
end
puts "Here is everyone:"
# Had to define list_count because the shift method only returns the first object
puts @list
# raise puts @list.inspect
puts "Is that everyone?"
total_question = gets.chomp
# raise puts @list.inspect
if total_question == "yes"
puts "Great Here is the output"
full_list = @list.shuffle!
puts full_list.inspect
prior=nil
full_list.each do |x|
if prior != nil
puts "#{x} #{prior}"
end
prior= x
# puts " #{full_list[x]} #{full_list[x# ]} "
end
else
puts "Please enter everyone else that you want to be involved:"
while true
second_input = gets.chomp
if second_input == ''
break
end
@list << second_input
end
puts "Here is everyone:"
puts @list
puts "Is that everyone?"
total_question = gets.chomp
if total_question == "yes"
puts "Great here are the matchups"
full_list = @list.shuffle!
puts full_list.inspect
prior=nil
full_list.each do |x|
if prior != nil
puts "#{x} #{prior}"
end
prior= x
end
else
puts "sorry but you need to come back when you get your shit together"
end
end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment