This is a collection of code golf, written in Ruby. Certainly not the shortest, but it works.