-
-
Save x89/05a35156815ebf5ab6a72b018acdb09b to your computer and use it in GitHub Desktop.
Ruby
This file contains hidden or 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
frequency_array = Array.new(8) | |
frequency_array.fill(Hash.new) | |
lines.each do |line| | |
puts line.chars.join(' ') | |
line.chars.each_with_index do |c,idx| | |
hash = frequency_array[idx] | |
if hash.include? c then | |
hash[c] += 1 | |
else | |
hash[c] = 1 | |
end | |
puts "Added char #{c} to hash id #{idx} to make #{hash[c]} #{frequency_array}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment