Friday, April 12, 2013

Benchmarking faster than the Monk!

Another fun problem from RubyMonk.com solved.  This one is called Number Shuffle and much to my surprise the Monk's provided solution seemed fairly inefficient at first glance.  First I noticed the magic constants 3 ? 6 : 24
Ugly, and degeneralizing, but ok whatever.  But why would he use Array:shuffle and :uniq to find what is apparently a permutation? Isn't that like using a slot machine repeatedly until you get 24 jackpots?
Anyway, the proof is in the performance numbers:




Wednesday, April 10, 2013

Kaprekar's Number

Dude, nIce. I particularly enjoyed solving this problem, and then to add icing on the cake, my solution was shorter and more elegant than the provided solution!




PROVIDED SOLUTION
MY SOLUTION

Sunday, April 7, 2013

My first Ruby!

Here is my first Ruby, a simple prime visualization.  I want to record this moment so I can look back someday and say "Aww, how cute!"