A fun math problem

Here is a question from the Mathematical Association of America’s American Mathematics Competitions blog (which I found through this constraint programming blog):

Let x and y be two-digit integers such that y is obtained by reversing the digits of x. The integers x and y satisfy x^2 – y^2 = m^2 for some positive integer m. What is x + y + m?

This is easily solved using Solver Foundation’s constraint programming solver. The OML model is simple:

    Integers[0, 9], x1, x2, y1, y2
  Decisions[Integers[10, 100], x, y],
  Decisions[Integers[1, Infinity], m, theAnswer],

    x == 10 * x1 + x2,
    y == 10 * y1 + y2,
    y == 10 * x2 + x1,
    x * x - y * y == m * m,
    theAnswer == x + y + m

Update 10/4/2011: reader Bruno Repetto noted the following:

  • In the declaration  
    Decisions[Integers[0, 9], x1, x2, y1, y2],
    the range should be Integers[1, 9].  If 0 is included, this declaration alone could allow for one of the numbers x or y to be single-digit.
  • In the declaration  
    Decisions[Integers[10, 100], x, y],
    the range should be Integers[10, 99], as x and y are restricted to be two-digit integers.

Of course, given the constraints of the problem, the first and second declarations will work together to ensure that the x and y numbers are only two-digit integers, but it doesn’t hurt that the declarations be tighter.



Author: natebrix

Follow me on twitter at @natebrix.

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 )

Connecting to %s

%d bloggers like this: