Skip to content

Instantly share code, notes, and snippets.

@NeMO84
Created January 21, 2011 06:21
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 NeMO84/789320 to your computer and use it in GitHub Desktop.
Save NeMO84/789320 to your computer and use it in GitHub Desktop.
CONFIRMATIONS = ["y","yes","sure","yup","why not"]
def get_list_of_names
puts "Please enter a list of words (one,two,three...):"
input = gets.chomp.downcase
input.split(",")
end
def sanitize(names_array)
names_array = names_array.uniq
end
def output_list(list)
puts "--------Items--------"
list.each do |item|
puts item.first + item.last
end
puts "---------------------"
end
loop do
names1 = get_list_of_names
names1 = sanitize(names1)
puts "Do you want to enter a second list?"
if CONFIRMATIONS.include?(gets.chomp.downcase)
names2 = get_list_of_names
names2 = sanitize(names2)
names1 = names1.product(names2)
else
names1 = names1.repeated_combination(2).to_a
end
output_list(names1)
puts "Again?"
break unless CONFIRMATIONS.include?(gets.chomp.downcase)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment