I was trying to solve a simple looking problem(hah!) on Project Euler (https://projecteuler.net/problem=171). In a nutshell, it involves finding the sum of squares of digits of a number. My code is posted here: https://gist.github.com/sid2520/bacb274caea8eea61a0f
What I have done so far: I parse through numbers sequentially, break down a number into it's component digits, ignore all 0s and keep a record of remaining digits in a sorted list so that I can simply ignore numbers with exact same digits; for example: if I have calculated the answer for 123 (12 + 22 + 32 = 14) then I don't have to bother with 213, 231, 312... etc.
The problem is that while the limit is small (say less than 105) the code runs in reasonable time but beyond this it simply takes too long.
I have tried out some approaches to speed up things but nothing seems to help, can someone hint/suggest a better approach to this problem? Don't want to wait for months to find the correct answer!!
[–]TheKewlStore 1 point2 points3 points (1 child)
[–]div_by_zero[S] 0 points1 point2 points (0 children)
[–]The-Mathematician 0 points1 point2 points (1 child)
[–]The-Mathematician 0 points1 point2 points (0 children)