|Don't ask to ask, just ask|
Re^2: Puzzle Timeby Athanasius (Canon)
|on Dec 23, 2012 at 10:21 UTC||Need Help??|
++LanX for an excellent answer (way faster than my brute force approach).
Allow me one nit-pick:
9! = 362880 possible combinations are checked in a recursive function.
Throwing in a counter shows that sub append_digit is actually called 986,410 times. Took me a while to work out why...
9! is the number of combinations if every number has exactly 9 digits. But we also allow numbers with 1, 2, ..., 8 digits. So the total number of combinations is:
(That 1 extra sub call is the first one, when @number is empty.)
For anyone else trying to understand how this code works, here is my slightly-reworked version which outputs the results in the order found:
Hope that’s helpful!