Skip to content

Splitting the Loot with Ruby

A lot of this problem is to do with implementing the algorithm that shares the gem. The only easy aspect is that the total value of the gems must be a divisible by the number of shares.

Danilo had used this problem while in South America so he already had a dojo solution that used recursion to effective check every possible combination. While that was clever there was also some discussion as to what causes the “greedy” method to fail. The method seems to work in such a large number of cases that the exact split has to be pathalogical.