Not too challenging, and fun to solve over a cup of coffee, if you've not seen it before.

Question:

Arrange the digits 1-9 to make a nine digit number such that the first digit is divisible by one, the first two digits divisible by two, first three digits divisible by three …

Solution here: http://datagenetics.com/blog/march22018/index.html

## Nine digit puzzle

**Moderators:** jestingrabbit, Moderators General, Prelates

- DataGenetics
**Posts:**24**Joined:**Sat Jan 01, 2011 1:12 am UTC**Location:**Seattle

### Re: Nine digit puzzle

Almost too challenging for me but got it eventually. I used a bit of dumb trial and error.

**Spoiler:**

### Re: Nine digit puzzle

Solution:

EDIT: just realized I misread the puzzle. Didn't see the "arrange the digits 1 to 9" bit...

**Spoiler:**

EDIT: just realized I misread the puzzle. Didn't see the "arrange the digits 1 to 9" bit...

If it looks like a duck, and quacks like a duck, we have at least to consider the possibility that we have a small aquatic bird of the family Anatidae on our hands. –Douglas Adams

- Soupspoon
- You have done something you shouldn't. Or are about to.
**Posts:**2832**Joined:**Thu Jan 28, 2016 7:00 pm UTC**Location:**53-1

### Re: Nine digit puzzle

Place the 5 the only place it can go. The four even numbers have only four places, and these in turn tie down the 3, 6, and 7-place numbers (the 1-digit solution is always unconstrained, save by availability, as is the 9-digit one) with some digits already ruled out, through prior use, as you progressively fill in the gaps and check the multiples (when you add digit 3 you can validate 3ness, 4ness and 6ness; if so, adding digit 7 validates/otherwise 7ness and 8ness; 1/2/5/9ness is inherent).

There may be a quicker method, but with a phase-space significantly lower than 1x(4x3x2x1)x(4x3x2x1), as dead-ends reveal themselves and the (sole) solution pops out.

***long pause, before actually posting…***

I actually just tried semi-brute-forcing the answer in various ways, the "intelligent" solution has the program hit 34 dead ends on the way to the answer, while with the most basic method of trying (the current remainder of) digits 1..9 from position 1 to position 9, moving onto the next most recent alternative option at each failure, hits 413 failures along the way with trying the order-of-preference of digits 9..1 giving 2127 failures!

Obviously depends upon order of preference (present the digits in the order of the eventual answer, and it gets there with zero failures) and I'm tempted to meta-brute-force all permutations of 1..9 to see the total range of possibilities (from straight to the answer to the absolute worst 'misteps all the way' combination, which is not necessarily the exact reverse of the answer, as it should also pass muster in lower lengths to waste time) but that'd need another layer of multilayer iteration atop my dumb-and-dumber engines.

(Unintelligently) populating in any order other than left-to-right is already a bad idea, if you need to wait for the first digit to be permuted in before you can yay-or-nay any multiple (besides the 5 and the cut-down selection necessary on the even spots, but I'm not crediting that brute-forcer with any programmed-in sense to do that), so we can probably forget about meta-meta-bruteforcing a more generalised strategy, knowing that it's a total waste.

There may be a quicker method, but with a phase-space significantly lower than 1x(4x3x2x1)x(4x3x2x1), as dead-ends reveal themselves and the (sole) solution pops out.

***long pause, before actually posting…***

I actually just tried semi-brute-forcing the answer in various ways, the "intelligent" solution has the program hit 34 dead ends on the way to the answer, while with the most basic method of trying (the current remainder of) digits 1..9 from position 1 to position 9, moving onto the next most recent alternative option at each failure, hits 413 failures along the way with trying the order-of-preference of digits 9..1 giving 2127 failures!

Obviously depends upon order of preference (present the digits in the order of the eventual answer, and it gets there with zero failures) and I'm tempted to meta-brute-force all permutations of 1..9 to see the total range of possibilities (from straight to the answer to the absolute worst 'misteps all the way' combination, which is not necessarily the exact reverse of the answer, as it should also pass muster in lower lengths to waste time) but that'd need another layer of multilayer iteration atop my dumb-and-dumber engines.

(Unintelligently) populating in any order other than left-to-right is already a bad idea, if you need to wait for the first digit to be permuted in before you can yay-or-nay any multiple (besides the 5 and the cut-down selection necessary on the even spots, but I'm not crediting that brute-forcer with any programmed-in sense to do that), so we can probably forget about meta-meta-bruteforcing a more generalised strategy, knowing that it's a total waste.

### Who is online

Users browsing this forum: No registered users and 7 guests