Given a positive integer n
, find the smallest number of squared integers which sum to n
(i.e. n = x2 + y2 should yield 2
).
- Any attempt to provide non-integer, non-positive input should return an error.
- Return only the count of squared integers that sum to
n
, not the list of integers. - Remember that 12 = 1.
SumOfSquares(13); // 2
SumOfSquares(27); // 3
- For
n
= 13: 32 + 22 = 9 + 4 = 13 - For
n
= 27:- 32 + 32 + 32 = 9 + 9 + 9 = 27
- 52 + 12 + 12 = 25 + 1 + 1 = 27
- The challenge will be live-coded in our weekly Tuesday meetup in the
solutions.go
file. - During the live-coding session, it will be tested by navigating to this directory and running
go test
. - The results of the live coding demo will be PR'ed as a mob solution. Any future submitters should reference this solutions guide in our wiki.
- Installed go