Skip to content

Instantly share code, notes, and snippets.

@huynguyen
Created January 5, 2012 08:29
Show Gist options
  • Save huynguyen/1564257 to your computer and use it in GitHub Desktop.
Save huynguyen/1564257 to your computer and use it in GitHub Desktop.
Joe's Problem
#!/usr/bin/env ruby
require 'csv'
# Real men use ruby1.9 thus not needing rubygems require and FasterCSV was
# folded into std-lib csv. Plus I had all these lines to waste on snarky
# comments. :P
puts CSV.read("joe.csv").flatten!.inject(Hash.new(0)) {|h,x| h[x] += 1; h}
# hnguyen@taengoo:~ ಠ_ಠ >> ./huy.rb
# {"junk"=>1, "name"=>1, "100"=>110, "joe"=>69, "tony"=>70, "david"=>3, "200"=>32}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment