Created
May 5, 2020 21:14
-
-
Save rugyoga/9ac7507f86589c7f187e4f85b848d61e to your computer and use it in GitHub Desktop.
Find the most frequently occurring alphanumeric in a very large data file
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
chars = Hash.new(0) | |
File.open("2019-annual/taxa.txt") do |f| | |
f.each_char.lazy.each do |char| | |
chars[char] += 1 if char.match(/^[[:alpha:]]$/) | |
end | |
end | |
puts chars.to_a.max{ |a, b| a[1] <=> b[1] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment