Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aarongreenlee/791513 to your computer and use it in GitHub Desktop.
Save aarongreenlee/791513 to your computer and use it in GitHub Desktop.
Learning Ruby!
# Aaron Greenlee
# http://aarongreenlee.com/
# Activity 2.1: Warmup 3
puts "Give me three sets of words like 'apples and oranges' and 'are good to eat'"
puts "You'll then see every combination between the two groups."
word_groups = { :one => [],:two => [],:three => [] }
word_groups.each { |k,v|
puts "What words for group #{k}? : "
word_groups[k] = gets.chomp.strip.downcase.split(' ').uniq
}
puts '\nCool! Here are the combinations between groups...\n'
combos = []
word_groups.each { |outer_group,prefixes|
prefixes.each { |prefix|
word_groups.each { |inner_group,suffixes|
if outer_group != inner_group
suffixes.each { |suffix|
if prefix != suffix
combos << prefix + suffix
end
}
end
}
}
}
puts "\nAnd the combinations are....\n\n"
combos.each { |w| puts w }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment