There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them.
Now, Gauss found out that every natural number may be expressed as a sum of three triangular numbers (these include
0), and it is fine to have one number more than once, e.g.
0 + 1 + 1 = 2.
Your task is to write a program or function, given a natural number (including
0), prints three triangular numbers that sum up to the argument. You may print the numbers separeted by spaces, as an array, or by another method you like. However, it is forbidden to use any builtin functions to directly get an array, a range or any other form of collection containing a list of triangular numbers (for instance a single atom that yields the range).
9 -> 6 + 3 + 0 or 3 + 3 + 3 12 -> 6 + 6 + 0 or 6 + 3 + 3 or 10 + 1 + 1 13 -> 6 + 6 + 1 1 -> 1 + 0 + 0 0 -> 0 + 0 + 0
Note: If there is more than one possible combination, you may print any or all, but you must print any combination only once, eliminating all combinations that are a result of rearranging other combinations. I'd really appreciate a try-it link and an explanation, I really love to see how you solve the problem ;)
This is code-golf, so standard loopholes apply. May the shortest answer in bytes win!