stevenviola @ stevenviola @programming.dev Posts 0Comments 2Joined 2 yr. ago
stevenviola @ stevenviola @programming.dev
Posts
0
Comments
2
Joined
2 yr. ago
Thanks! yup, I figured there would be a way. You're right, much faster, on my machine with your code, this is the speed:
$ time python3 day7.py 4555081946288 227921760109726 real 0m0.171s
I'll have to take a look to understand how that works to be better.
Python
Takes ~5.3s on my machine to get both outputs. Not sure how to optimize it any further other than running the math in threads? Took me longer than it should have to realize a lot of unnecessary math could be cut if the running total becomes greater than the target while doing the math. Also very happy to see that none of the inputs caused the recursive function to hit Python's max stack depth.