If you're going to do this much work, you can do it entirely by hand.

Let's see. The fifth number has to be divisible by 5, so that digit is 0 or 5, but we don't have a 0 so that is 5. Digits in position 2, 4, 6, and 8 must be even, so that uses up 4 even digits - we only have 4 so all must be used there. Therefore the odd digits must be odd.

Oh, but we can go further still, so far we know that at position 4 we have (odd)(even)(odd)(even) and we need it divisible by 4, that will only happen if the 4'th digit is divisible by 2 but not 4. A similar thing happens at position 8. We only have 2 such digits, 2 and 6. Therefore 2 and 6 appear at positions 4 and 8. And 4 and 8 appear at positions 2 and 6.

We are now in a position to do exhaustive search. The pattern is that we want a permutation where the digits happen to fall into the sequence

  1. 1, 3, 7, 9
  2. 4, 8
  3. 1, 3, 7, 9
  4. 2, 6
  5. 5
  6. 4, 8
  7. 1, 3, 7, 9
  8. 2, 6
  9. 1, 3, 7, 9
With this pattern we need to check that the first 3 digits are divisible by 3. The second 3 digits are divisible by 3. The first 7 are divisible by 7. And the 7'th and 8'th are divisible by 8. Here is the exhaustive search:
143 x 14725836 x 1472589 x 147658 x 149 x 183254 x 1836547 x 1836549 x 187 x 189254 x 1896547 x 1896549 x 341 x 347 x 349 x 381254 x 381654729 <--- Yes! 3816549 x 387254 x 3876541 x 3876549 x 389 x 7412583 x 7412589 x 741658 x 743 x 749 x 781 x 783254 x 7836541 x 78365492 x 789254 x 7896541 x 7896543 x 941 x 943 x 947 x 981254 x 9816543 x 9816547 x 983 x 987254 x 9876541 x 9876543 x
And there you have it, only one answer.

Incidentally that there would be about one answer should not surprise. After all we have 9! permutations. But odds are that all of them get through the first check, half the second, a third the third, a quarter the fourth, etc. So we'd expect about 1/9! of the permutations to get through. Which (hmmm...) works out an estimate of 1 right answer...


In reply to Re^2: Golf the numbers! by tilly
in thread Golf the numbers! by si_lence

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.