Print Story Puzzle Time
Logic & Maths
By codemonkey uk (Wed Jun 04, 2008 at 10:15:12 AM EST) (all tags)
**NINE** x2 = EIGHTEEN
Given that each letter represents a number (0-9), and the star (*) symbol is wild, what integer values do the numbers "**NINE**" and "EIGHTEEN" need to be to make the above statement true?

This puzzle appears in this weeks New Scientist magazine.



Took me about 2 hours to solve, there are, according to my workings, 6 solutions in total. One of them is:
45818999*2=91637998
Using the key:
I=1, H=3, G=6, T=7, N=8, E=9
Can you find one of the other 5 solutions?
< Let the whining begin! | Attention Web Surfing Infidels! >
Puzzle Time | 17 comments (17 topical, 0 hidden) | Trackback
Ewww maths by nebbish (2.00 / 0) #1 Wed Jun 04, 2008 at 10:22:15 AM EST

--------
It's political correctness gone mad!


you are what is wrong with society (says the bbc) by codemonkey uk (4.00 / 1) #2 Wed Jun 04, 2008 at 10:31:51 AM EST
"The British are uniquely happy to admit being bad at maths, says a report. Why is that and how can attitudes change?" - http://news.bbc.co.uk/1/hi/magazine/7435023.stm

--- Thad ---
developer of ... ?
[ Parent ]

Yeah well by nebbish (2.00 / 0) #3 Wed Jun 04, 2008 at 11:15:37 AM EST
Maths is boooooooring

--------
It's political correctness gone mad!
[ Parent ]

Karma Police, arrest this man ... by Herring (2.00 / 0) #6 Wed Jun 04, 2008 at 12:03:52 PM EST


You can't outlaw rabbits! They'll just go underground - Milton Jones
[ Parent ]

Solves by ucblockhead (2.00 / 0) #4 Wed Jun 04, 2008 at 11:37:30 AM EST
Does it count if I write a program that solves it?
----
ウセーバラケダ


Why wouldn't it? by codemonkey uk (2.00 / 0) #5 Wed Jun 04, 2008 at 11:41:59 AM EST
How do you think I did it? :P

--- Thad ---
developer of ... ?
[ Parent ]

Bah! by ambrosen (2.00 / 0) #7 Wed Jun 04, 2008 at 12:06:04 PM EST
I have no prolog interpreter available.



Man, that's easy. by Driusan (4.00 / 1) #8 Wed Jun 04, 2008 at 07:40:04 PM EST
* = 0
*2 = 0
*3 = 0
*4 = 0
N = 0
I = 0
E = 0
G = 0
H = 0
T = 0



Maybe I missed something... by george (2.00 / 0) #9 Thu Jun 05, 2008 at 12:13:19 PM EST
Hrm, I found 25 solutions, assuming leading zeros aren't permitted. Is there an additional constraint that no two variables have the same value?

45000995*2 = 90001990
45202996*2 = 90405992
45404997*2 = 90809994
45616998*2 = 91233996
45818999*2 = 91637998
46020995*2 = 92041990
46222996*2 = 92445992
46424997*2 = 92849994
46636998*2 = 93273996
46838999*2 = 93677998
47040995*2 = 94081990
47242996*2 = 94485992
47444997*2 = 94889994
47656998*2 = 95313996
47858999*2 = 95717998
48060995*2 = 96121990
48262996*2 = 96525992
48464997*2 = 96929994
48676998*2 = 97353996
48878999*2 = 97757998
49080995*2 = 98161990
49282996*2 = 98565992
49484997*2 = 98969994
49696998*2 = 99393996
49898999*2 = 99797998




assumptions by codemonkey uk (2.00 / 0) #10 Thu Jun 05, 2008 at 01:27:43 PM EST
Ah, that's interesting, I assumed unique one-to-one mapping between letters and the number the represent, so you can't have both E=1 and I=1.  But I did also assume that leading zeros were permitted.  If I narrow my search to disallow leading zeros I get exactly 1 solution, which is probably what the puzzle author intended.

By the by, of the three places I posted this puzzle, you are the only person (other than me) to find a solution.  :)

--- Thad ---
developer of ... ?
[ Parent ]

well I only just saw it by fluffy (2.00 / 0) #11 Fri Jun 06, 2008 at 05:38:40 PM EST
and I'm working on it. gprolog was taking forever but I didn't put in a uniqueness constraint, either. Silly me for ass-u-ming.
busy bees buzz | sockpuppet revolution
[ Parent ]

What are you talking about? by Driusan (2.00 / 0) #15 Sat Jun 07, 2008 at 04:37:39 PM EST
I posted a solution before george and it only took about a minute, without the help of any computer.

Just because you didn't ask the question you thought you asked doesn't mean solutions to the question you did ask aren't solutions.

[ Parent ]

What? by codemonkey uk (4.00 / 1) #16 Sun Jun 08, 2008 at 04:53:01 PM EST
I never said your solution doesn't count, i thought it was quite clever.  It's not like i'm giving out prizes here, just commenting on what i find interesting.  Jeez.

--- Thad ---
developer of ... ?
[ Parent ]

Code fragments by fluffy (2.00 / 0) #12 Fri Jun 06, 2008 at 06:07:58 PM EST
I originally was writing it in prolog but that became obvious that it was stupid since there was a much more straightforward approach in C.

Non-unique, no leading 0s:

int main(void)
{
    int i = 0;
    char buf[20];

    for (i = 10000000; i < 50000000; i++)
    {
        sprintf(buf, "%08d%08d", i, i*2);
        if (buf[2] = buf[4]
            && buf[2] =
buf[15]
            && buf[3] = buf[9]
            && buf[5] =
buf[8]
            && buf[5] = buf[13]
            && buf[5] =
buf[14])
            printf("%d*2 = %dn", i, i*2);
    }

    return 0;
}

finds a whole bunch of answers.  If I add a uniqueness constraint, that becomes:

int nonrepeating(const char *str)
{
    const char *cmpp;   

    if (!*str)
        return 1;
    for (cmpp = str + 1; *cmpp; cmpp++)
    {
        if (*str = *cmpp)
            return 0;
    }
    return nonrepeating(str + 1);
}

int main(void)
{
    int i = 0;
    char buf[20];

    for (i = 45000000; i < 50000000; i++)
    {
        sprintf(buf, "%08d%08d", i, i*2);
        if (buf[2] =
buf[4]
            && buf[2] = buf[15]
            && buf[3] =
buf[9]
            && buf[5] = buf[8]
            && buf[5] =
buf[13]
            && buf[5] == buf[14])
        {
            char foo[10];
            sprintf(foo, "%c%c%c%c%c%c", buf[2], buf[3], buf[5],
                buf[10], buf[11], buf[12]);
            if (nonrepeating(foo))
                printf("%d*2 = %dn", i, i*2);
        }
    }

    return 0;
}

and the only solution it gives is 45818999*2 = 91637998.  (Note that this also requires that the xs do not have the same uniqueness constraint as the stated digits.)
busy bees buzz | sockpuppet revolution


Damnit scoop by fluffy (2.00 / 0) #13 Fri Jun 06, 2008 at 06:08:51 PM EST
It changed all my equalities to some sort of weird-ass autoformat thing.  Obviously every single = sign needs to be a double-equal.
busy bees buzz | sockpuppet revolution
[ Parent ]

i understood the intent :) by codemonkey uk (2.00 / 0) #14 Sat Jun 07, 2008 at 07:38:03 AM EST
That's a pretty neat solution.  I'll post mine on Monday.

--- Thad ---
developer of ... ?
[ Parent ]

Wrap code in <ecode></ecode> by gazbo (2.00 / 0) #17 Tue Jun 10, 2008 at 10:06:19 AM EST
It's the format-escaping technique of the gods!

"Engarde!" cried the larvae, huskily. - Scrymarch

[ Parent ]

Puzzle Time | 17 comments (17 topical, 0 hidden) | Trackback