Forum menu
Wednesday afternoon...
 

[Closed] Wednesday afternoon puzzle

Posts: 0
Free Member
Topic starter
 
[#2405726]

I am thinking of a nine-digit decimal natural number. It contains all 9 numerals 1, 2, 3, 4, 5, 6, 7, 8, 9.
For each n = 1, ..., 9 the first n digits read as an n-digit decimal natural number are divisible by n. What is my number?


 
Posted : 26/01/2011 4:48 pm
Posts: 19914
Free Member
 

Are there aeroplanes on conveyors?


 
Posted : 26/01/2011 4:50 pm
Posts: 0
Free Member
 

OK, so the first digit is one and the next digit is even, and the next digit odd, etc...

But now I've lost interest.

Feel free to stand on my shoulders.


 
Posted : 26/01/2011 4:55 pm
Posts: 0
Free Member
 

76.2?


 
Posted : 26/01/2011 5:00 pm
Posts: 0
Free Member
 

I have another cryptic puzzle for you lot...

What colour pants am I wearing?

For bonus points...

Why did I put them on inside out this morning?


 
Posted : 26/01/2011 5:07 pm
Posts: 0
Free Member
 

TSY - I left your lime green thong out for you so I assume you're wearing that?

You're wearing it inside out to even the stains out?


 
Posted : 26/01/2011 5:08 pm
Posts: 12332
Full Member
 

42.

That's the answer to both questions, and any other you could possibly ask.


 
Posted : 26/01/2011 5:08 pm
 j_me
Posts: 0
Free Member
 

RealMan

5318008

TSY
a) Beige
b) Reduced washing


 
Posted : 26/01/2011 5:09 pm
Posts: 0
Free Member
 

[img] [/img]


 
Posted : 26/01/2011 5:13 pm
Posts: 0
Free Member
 

Hmm, but yet cared enough to post that. Now that is a [i]real[/i] puzzle!


 
Posted : 26/01/2011 5:15 pm
Posts: 0
Free Member
 

Hmm, but yet [s]cared[/s]bored enough to post that. Now that is a real puzzle!

fixed that for you.


 
Posted : 26/01/2011 5:17 pm
Posts: 0
Free Member
 

OK, so the first digit is one

I thought that initially but I don't thing it has to be.

e.g. digit (n=) 1 with a value of 2 is divisible by (n=) 1


 
Posted : 26/01/2011 5:21 pm
 beej
Posts: 4215
Full Member
 

2nd digit is 2, 5th is 5.
4th, 6th, 8th are even.

EDIT - not sure 2nd is 2 now.


 
Posted : 26/01/2011 5:22 pm
Posts: 0
Free Member
Topic starter
 

I'd agree that the 5th is 5.

And that also any combination of the numbers will be divisible by 9, so you don't have to worry about that. (Not sure if that will help at all.)

That's about all I've really got at the moment..


 
Posted : 26/01/2011 5:31 pm
Posts: 7365
Free Member
 

71077345


 
Posted : 26/01/2011 5:58 pm
Posts: 0
Free Member
 

FAIL ๐Ÿ™‚


 
Posted : 26/01/2011 6:02 pm
Posts: 0
Free Member
 

189456327 ---ooops


 
Posted : 26/01/2011 6:17 pm
Posts: 31206
Full Member
 

I can see how I'd find a solution, but it is too painful to do by hand so I'd write code ๐Ÿ™‚

Seems to me you have to list the possible numbers for each position by looking at what the multiples of that position end with (e.g. for position 4: multiples of 4 end with 0,2,4,6,8 and the question says zero is not allowed)

Doing that gives:
[code]
1 2 3 4 5 6 7 8 9
----------------------
1 . 1 . . . 1 . 1
2 2 2 2 . 2 2 2 2
3 . 3 . . . 3 . 3
4 4 4 4 . 4 4 4 4
5 . 5 . 5 . 5 . 5
6 6 6 6 . 6 6 6 6
7 . 7 . . . 7 . 7
8 8 8 8 . 8 8 8 8
9 . 9 . . . 9 . 9
[/code]

Then you just... Erm...


 
Posted : 26/01/2011 6:18 pm
Posts: 0
Free Member
Topic starter
 

CM that's not right...

GrahamS ๐Ÿ˜€


 
Posted : 26/01/2011 6:23 pm
Posts: 31206
Full Member
 

189456327

Erm 1894 is not divisible by 4. ๐Ÿ™‚


 
Posted : 26/01/2011 6:24 pm
Posts: 31206
Full Member
 

Aah then we do some elimination. The only possible number at position 5 is 5 and the 4 even positions needs the 4 even numbers so they can't be under odd.

[code]
1 2 3 4 5 6 7 8 9
----------------------
1 . 1 . . . 1 . 1
. 2 . 2 . 2 . 2 .
3 . 3 . . . 3 . 3
. 4 . 4 . 4 . 4 .
. . . . 5 . . . .
. 6 . 6 . 6 . 6 .
7 . 7 . . . 7 . 7
. 8 . 8 . 8 . 8 .
9 . 9 . . . 9 . 9
[/code]

Then erm....


 
Posted : 26/01/2011 6:29 pm
Posts: 0
Free Member
 

987654321 - then, i'm gonna start moving them around!!!


 
Posted : 26/01/2011 6:29 pm
Posts: 5
Free Member
 

Is it time for this yet?

[img] [/img]


 
Posted : 26/01/2011 6:35 pm
Posts: 0
Free Member
 

147258369

My pants are black with a pink waistband.
I was just really tired when getting dressed this morning.


 
Posted : 26/01/2011 6:50 pm
Posts: 0
 

381654729


 
Posted : 26/01/2011 7:04 pm
Posts: 31206
Full Member
 

147258369

But 14725836 does not divide by 8


 
Posted : 26/01/2011 7:05 pm
Posts: 0
Free Member
 

By jove, i think he's got it (guattang, that is)


 
Posted : 26/01/2011 7:08 pm
 j_me
Posts: 0
Free Member
 

indeed


 
Posted : 26/01/2011 7:09 pm
Posts: 0
Free Member
 

was there a method?


 
Posted : 26/01/2011 7:10 pm
Posts: 31206
Full Member
 

381654729

Winner! But where is your working...? ๐Ÿ™‚

I got a far as reading off the remaining valid combinations of 3 digits from my grid and eliminating the ones not divisible by 3, leaving:

123, 129, 147, 183, 189, 321, 327, 381, 387
723, 729, 747, 783, 789, 921, 927, 981, 987

My next step would have been to try each of those with the possibles from the 4 column, but then I decided there must be an easier way ๐Ÿ™‚


 
Posted : 26/01/2011 7:10 pm
 LsD
Posts: 0
Free Member
 

Squadron Leader Brian Trubshaw.


 
Posted : 26/01/2011 7:26 pm
Posts: 0
Free Member
Topic starter
 

guattang, how did you get it?


 
Posted : 26/01/2011 7:26 pm
Posts: 0
 

I did it a in a simple loop (in a bash script if you're interested ...). I took the brute force approach, but runtime was only about 10 seconds.


 
Posted : 26/01/2011 8:06 pm
Posts: 0
Free Member
Topic starter
 

So no mathematical genius, just code?

TBH, I'm struggling to see how it would be done anyway else. Cheers though.


 
Posted : 26/01/2011 8:09 pm
Posts: 0
 

Afraid not. No genius here ... wether it be mathematical or otherwise ...


 
Posted : 26/01/2011 8:28 pm
Posts: 0
Free Member
 

Lets see that code ๐Ÿ™‚


 
Posted : 26/01/2011 8:32 pm
 beej
Posts: 4215
Full Member
 

Would something like this help:

[url= http://math.about.com/library/bldivide.htm ]http://math.about.com/library/bldivide.htm[/url]

EDIT - so looking at options from GrahamS's table, 4th digit can't be 4 or 8.

It's a bit Sudoku ish.


 
Posted : 26/01/2011 8:36 pm
Posts: 0
 

Hmmm ... not very elegant I'm afraid!!

#!/bin/bash

function test
{

num1=$1
num2=$2
((r=($num1/$num2)*$num2))
if [[ $r -eq $num1 ]]; then
echo 0
else
echo 1
fi
}

for n1 in printf "1\n2\n\n3\n4\n6\n7\n8\n9"
do
for n2 in printf "2\n4\n6\n8" | grep -v "$n1"
do
for n3 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2"
do
for n4 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3"
do
for n5 in printf "5"
do
for n6 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3|$n4|$n5"
do
for n7 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6"
do
for n8 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6|$n7"
do
for n9 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6|$n7|$n8"
do

if [[ test $n1 1 = "0" ]]; then
if [[ test ${n1}${n2} 2 = "0" ]]; then
if [[ test ${n1}${n2}${n3} 3 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4} 4 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5} 5 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6} 6 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7} 7 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8} 8 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8}${n9} 9 = "0" ]]; then
echo ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8}${n9}
fi
fi
fi
fi
fi
fi
fi
fi
fi

done
done
done
done
done
done
done
done
done


 
Posted : 26/01/2011 8:37 pm
Posts: 0
Free Member
 

Wow! ๐Ÿ˜ฏ


 
Posted : 26/01/2011 9:05 pm
Posts: 27
Free Member
 

I'm not sure what's duller, the question, the script, or the answer...


 
Posted : 26/01/2011 9:26 pm
Posts: 31206
Full Member
 

Bah, code is too easy, especially inelegant brute forcing it, and in bash as well... yuk. ๐Ÿ™‚

I'm pretty sure I was on the right lines for solving it by hand. It's easy enough to take those possible three digit numbers and see which are divisible by four when 2,4,6 or 8 is appended.

As beej points out, only 2 and 6 work since the last digit is odd. So...

1232 1236
1292 1296
1472 1476
1832 1836
1892 1896
3212 3216
3272 3276
3812 3816
3872 3876
7232 7236
7292 7296
7472 7476
7832 7836
7892 7896
9212 9216
9272 9276
9812 9816
9872 9876

Then eliminate the ones with repeated digits leaves:

[s]1232[/s] 1236
[s]1292[/s] 1296
1472 1476
1832 1836
1892 1896
[s]3212[/s] 3216
[s]3272[/s] 3276
3812 3816
3872 3876
[s]7232[/s] 7236
[s]7292[/s] 7296
[s]7472[/s] [s]7476[/s]
7832 7836
7892 7896
[s]9212[/s] 9216
[s]9272[/s] 9276
9812 9816
9872 9876

Then they can all have 5 appended and we're half way there..


 
Posted : 26/01/2011 10:11 pm