1
0
www.mikescher.com/www/statics/euler/Euler_Problem-031_explanation.md

9 lines
540 B
Markdown
Raw Permalink Normal View History

2017-11-08 17:39:50 +01:00
The algorithm here enumerates through every possible combination using an approach similar to counting binary:
- Increment the last digit until our total sum is greater 200 (test for every combination if total sum == 200)
- Then set every field from back to front to zero until you find a non-zero field
- Set this field also to zero
- Increment the field before ... repeat
- Abort the loop when you have used every field
That is probably not the most efficient way, but I optimized this brute-force variant enough that it becomes viable.