Skip to content

Commit

Permalink
Create hashes Excersise 6
Browse files Browse the repository at this point in the history
  • Loading branch information
raspy8766 committed Sep 3, 2014
1 parent 4e9ba73 commit d09e008
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hashes Excersise 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
words = ['demo', 'none', 'tied', 'evil', 'dome', 'mode', 'live',
'fowl', 'veil', 'wolf', 'diet', 'vile', 'edit', 'tide',
'flow', 'neon']

result = {}

words.each do |word|
key = word.split('').sort.join
if result.has_key?(key)
result[key].push(word)
else
result[key] = [word]
end
end

result.each do |k, v|
puts "------"
p v
end

0 comments on commit d09e008

Please sign in to comment.