Skip to content

Instantly share code, notes, and snippets.

@igrabes
Created November 13, 2011 21:07
  • Select an option

Select an option

Revisions

  1. igrabes created this gist Nov 13, 2011.
    74 changes: 74 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@


    @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