Charlie, you are a gifted and skilled programmer, one of the best I've encountered during my long professional life. Your programs are nicely structured, they are concise and mostly easily readable, even uncommented. They generally map the problem, trying to assume as little as possible, avoiding shortcuts and caring very little about the runtime .
This proves counterproductive facing a puzzle which performs a certain subroutine a zillion times – I do not intend to calculate what the word zillion represents here, but for every possible number within about 30k range you exhaust all possible compositions (6 times the number of partitions(!) , which is HUGE by itself).
In this case – time matters.
So I humbly suggest a minor modification which will reduce your total runtime by (ROM estimate) 80-90%: instead of multiplying a * 9876..and b *1234…use one addition instead of one long multiplication – just add 98765…to the previous sum in the loop, same for 1234…and see what happens.
I would appreciate it very much if you follow my advice – since you have an" a+b+c = 30,000" segment ready, you may apply the changes there and compare the runtimes in both versions. It really interests me, how significant those modifications are.
This is also an opportunity to thank you for your tremendous contribution to the site –
I admit that I have learned from you a lot.
Edited on June 10, 2013, 6:06 pm