Genetic Programming: Code smarter than you!


Here in sweden there are currently circulating some email with a challange about solving a math puzzle.
It’s nothing special really but the mail goes something like this (translated):
(Don’t blame me for the claims in the quote, it’s not my words)

It’s said that only people with an IQ over 120 can solve the following problem:

If we assume that:
2 + 3 = 10
7 + 2 = 63
6 + 5 = 66
8 + 4 = 96

How much is?
9 + 7 = ????

The mail contains an excel file with a password and can only be opened if you know the answer to the above.

Just for the hell of it I entered the problem into my old genetic expression evolver:
http://rogeralsing.com/2008/02/07/genetic-programming-math/

The application is based on genetic programming and does use genetic crossover and a real population (unlike my EvoLisa sample).

The problem was described like this:
problem.Cases.Add(new Case(2, 3, 10));
problem.Cases.Add(new Case(7, 2, 63));
problem.Cases.Add(new Case(6, 5, 66));
problem.Cases.Add(new Case(8, 4, 96));

The first and second arguments are variable values and the last argument is the expected output.

And here is the output of the application:

As you can see on the screenshot, the application have solved the equation in 250 generations (a few milliseconds).

That’s probably faster than you solved it ;-)

PS.
If it makes you feel better, I didn’t solve it at all, I go into fetus position on the floor when I see math problems ;-)

//Roger

9 thoughts on “Genetic Programming: Code smarter than you!”

  1. That was very interesting. Nature and computers never get bored or frustrated and can do factorial expansions without wondering whether they should doing something else that is more fun.
    When I looked at the link to genetic-programming-math, I discovered this link to the image is 404 for genmath41.gif.
    Gbrainy, which is a Google program of logic games, has some interesting problems.
    It is frustrating to play games against the computer, especially if they are solved games and thus the computer knows at each step of the tree, how to rate its opponent.

  2. I used a slightly different formula to come up with the same answer. I didn’t write a program, but just used some trial and error to come up with ways to manipulate the numbers alone and together to see if they would have the same result. It probably took me about 10 minutes. Definitely slower than the solver you used. My formula was:
    x^2 + x*y = answer
    so 2^2 + (2)*(3) = 4 + 6 = 10
    and 7^2 + (7)*(2) = 49 + 14 = 63
    etcetera
    therefore 9^2 + (9)*(7) = 81 + 63 = 144

  3. Hi Rusty,

    Actually I did’t write program too.

    My math solving was different:

    First I realize that result is divided exactly on x+y … and result is x … so formula is x(x+y) … because of simpler calculation this took me minute or two to solve it.

    But when I try gbrainy I found that I am not so smart :D
    (wow … sentence wit 3 time I … tc tc tc)

  4. hi,
    i’m newbie in c#, are you using any control parameters within this program (crossover, mutation probability, max generation, etc)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s