Viewing 40 posts - 1 through 40 (of 41 total)
  • Wednesday afternoon puzzle
  • RealMan
    Free Member

    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?

    PeterPoddy
    Free Member

    Are there aeroplanes on conveyors?

    rightplacerighttime
    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.

    DrRSwank
    Free Member

    76.2?

    TheSouthernYeti
    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?

    DrRSwank
    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?

    tthew
    Full Member

    42.

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

    j_me
    Free Member

    RealMan

    5318008

    TSY
    a) Beige
    b) Reduced washing

    organic355
    Free Member

    CharlieMungus
    Free Member

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

    organic355
    Free Member

    Hmm, but yet caredbored enough to post that. Now that is a real puzzle!

    fixed that for you.

    allthepies
    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

    beej
    Full Member

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

    EDIT – not sure 2nd is 2 now.

    RealMan
    Free Member

    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..

    Coyote
    Free Member

    71077345

    allthepies
    Free Member

    FAIL 🙂

    CharlieMungus
    Free Member

    189456327 —ooops

    GrahamS
    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:

    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

    Then you just… Erm…

    RealMan
    Free Member

    CM that’s not right…

    GrahamS 😀

    GrahamS
    Full Member

    189456327

    Erm 1894 is not divisible by 4. 🙂

    GrahamS
    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.


    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

    Then erm….

    CharlieMungus
    Free Member

    987654321 – then, i’m gonna start moving them around!!!

    freddyg
    Free Member

    Is it time for this yet?

    TheSouthernYeti
    Free Member

    147258369

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

    guattang
    Free Member

    381654729

    GrahamS
    Full Member

    147258369

    But 14725836 does not divide by 8

    CharlieMungus
    Free Member

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

    j_me
    Free Member

    indeed

    CharlieMungus
    Free Member

    was there a method?

    GrahamS
    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 🙂

    LsD
    Free Member

    Squadron Leader Brian Trubshaw.

    RealMan
    Free Member

    guattang, how did you get it?

    guattang
    Free Member

    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.

    RealMan
    Free Member

    So no mathematical genius, just code?

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

    guattang
    Free Member

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

    allthepies
    Free Member

    Lets see that code 🙂

    beej
    Full Member

    Would something like this help:

    http://math.about.com/library/bldivide.htm

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

    It’s a bit Sudoku ish.

    guattang
    Free Member

    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

    allthepies
    Free Member

    Wow! 😯

    brakes
    Free Member

    I’m not sure what’s duller, the question, the script, or the answer…

Viewing 40 posts - 1 through 40 (of 41 total)

The topic ‘Wednesday afternoon puzzle’ is closed to new replies.