And what 3 perfect squares add up to 15? Have you read the kata description?
sum_of_squares(15) = 4
15 = 9 + 4 + 1 + 1. There is no way to represent 15 as the sum of three perfect squares.
@Chrono79, in that case, test for n = 15 should not be 4, but 3
This comment is hidden because it contains spoiler information about the solution
C# translation added~
I was so close to giving up. Great Kata. Very satisfying. Thank you for your work; however, I really wondered how every number can be written as sum of perfect squares with maximum 4 number. Can someone explain that ?
In test case with number 19 the right answer should be 4, not 3. Because 19 = 16 + 1 + 1 + 1.
And in case with number 18 the right answer should be 3, because 18 = 16 + 1 + 1. Shouldn't it?
java translationplease review and approve.
it's not about DP, here. You need even more efficient.