4 ms·
Apologies, I'm posting this few times, but are you calculating the total number of solutions, or just finding a solution? The latter has a closed form solution:
by IanCal 13y ago
Apologies, I'm posting this few times, but are you calculating the total number of solutions, or just finding a solution? The latter has a closed form solution: https://gist.github.com/IanCal/1858601 https://gist.github.com/IanCal/1858601
That'll do ~N=1e6 in a second (I'm sure there are lots of optimisations that could be done in it though), or solutions for N=4 to N=1000 in less than 10.
The more complex problem is finding out how many solutions there are in total.
- shoo 13y agoYou're correct, i'm merely finding a single feasible solution. Cheers for the link