Created
January 21, 2011 06:21
-
-
Save NeMO84/789320 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
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