(In reply to
Choice of two algorithms by Charlie)
We can improve on this using the fact that 12^6 = 1 mod 7. As a result, we can swap the nth and n+6th digits of any solution to arrive at another solution. That's because A*12^(n+6) + B*12^n = 12^n(A*12^6 + B) = 12^n(A+B) mod 7 which is symmetric in A and B.
So we can use Charlie's approach of enumerating the pandigitals, but we can immediately skip any where the ith digit is bigger than the i+6th digit, greatly reducing how many numbers we have to compute divisibility for.
For each of these solutions, there will be a set of 2^6 = 64 total solutions, where in each case you can pick whether the ith and i+6th digits should be in ascending or descending order.

Posted by Paul
on 20160913 19:01:57 