# Golden Spheres

Another week, another riddler. This one is from Dean Ballard:

King Auric adored his most prized possession: a set of perfect spheres of solid gold. There was one of each size, with diameters of 1 centimeter, 2 centimeters, 3 centimeters, and so on. Their brilliant beauty brought joy to his heart. After many years, he felt the time had finally come to pass the golden spheres down to the next generation — his three children.

He decided it was best to give each child precisely one-third of the total gold by weight, but he had a difficult time determining just how to do that. After some trial and error, he managed to divide his spheres into three groups of equal weight. He was further amused when he realized that his collection contained the minimum number of spheres needed for this division. How many golden spheres did King Auric have?

To find this one I found by creating lists of cube numbers and seeing if there was a way to subdivide the subsets into groups that summed to a third of the sum. I was able to find the answer relatively easily without many optimizations (the only one I found was I only looked for subsets if the sum of the cube numbers was divisible by 3).

The division of the 23 spheres for 3 heirs is:

Heir 1: 3, 6, 10, 13, 18, 19, 21

Heir 2: 1, 4, 7, 8, 12, 16, 20, 22

Heir 3: 2, 5, 9, 11, 14, 15, 17, 23

I did an extension for the case where the king has a different number of heirs.

The division of the 24 spheres for 4 heirs is:

Heir 1: 7, 9, 21, 23

Heir 2: 8, 10, 11, 16, 17, 22

Heir 3: 1, 2, 3, 4, 14, 18, 24

Heir 4: 4, 6, 12, 13, 15, 19, 20

The division of the 24 spheres for the 5 heirs is:

Heir 1: 1, 18, 23

Heir 2: 8, 14, 16, 22

Heir 3: 2, 4, 9, 15, 24

Heir 4: 3, 5, 12, 19, 21

Heir 5: 6, 7, 10, 11, 13, 17, 20