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:




No comments:

Post a Comment