Skip to content

Instantly share code, notes, and snippets.

@x89
Created December 6, 2016 09:11
Show Gist options
  • Save x89/05a35156815ebf5ab6a72b018acdb09b to your computer and use it in GitHub Desktop.
Save x89/05a35156815ebf5ab6a72b018acdb09b to your computer and use it in GitHub Desktop.
Ruby
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