Last active
August 29, 2015 14:02
-
-
Save budnik/4cb21a83f76cdbc69501 to your computer and use it in GitHub Desktop.
Facebook Hacker Cup 2013 Hackathon – Beautiful Strings
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
#!/usr/bin/env ruby | |
# Solution to https://www.codeeval.com/open_challenges/83/ | |
# Worst code ever! One should never use an onliner and perlisms on commercial software. | |
ARGF.each_line do |l| | |
w=(1..26).to_a | |
puts l.downcase.gsub(/[^a-z]+/,'').each_char.group_by(&:to_sym).sort_by{|k,v|-v.size}.map{|f|f.last.size*w.pop}.reduce(:+) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment