King of the nerds – Quick and Dirty Programming Contest Winners
Winning a vendor sponsored timed programming contest at a three day technical conference (CodeMash**) which you voluntarially traveled to in Northern Ohio in the middle of January is a double edged sword.
One the one side you are the king of the nerds.
On the other side … you are the king of the nerds.
A few weeks ago Josh Schramm, Kevin Berridge, and I (all past Dayton Flyers and college roomates) took in a great CodeMash conference and decided to enter a StoutSystems sponsored programming SmackDown just for kicks.
We won. All hail the kings of the nerds.
Granted only ~15 teams entered (from 1 -3 people each) but none the less, we won and only one other team submitted even a failed attempt before our winning one.
Josh posted our solution in Ruby to GitHub and I have since cleaned it up a bit, added the original rules, a C# & Linq solution Kevin did while we were there and a new one of my own making in Ruby.
I am planning to write the solution in a few different languages and designs. If anyone else has an entry or can suggest a way to make the Ruby variant any cleaner or more idiomatic … please leave me a comment or fork my repo on GitHub.
Latest Ruby variation:
lines = []
File.open('../input.txt').each { |line| lines << line }
lines = lines[1..lines.size].
map { |line| line.split("\t") }.
each { |line| line[1] = line[1].gsub(/[^a-zA-Z]/, '').reverse }.
reject { |line| line[1].to_s.empty? }.
sort { |x, y| (x[1] <=> y[1]) == 0 ? (x[5].to_f <=> y[5].to_f) : (x[1] <=> y[1]) }.
collect { |line| line.join("\t") }.
insert(0, lines[0])
File.open("output.txt", 'w') { |f| f.write(lines) }
** CodeMash was an absolute blast. Great sessions, good people, nice venue, and rockin’ live music.
Long live esenihc lavivrus

3 comments