## For All You Math Geniuses Out There...

**Moderators:** Forum Moderators, Developers

- artisticdude
- Moderator Emeritus
**Posts:**2424**Joined:**December 15th, 2009, 12:37 pm**Location:**Somewhere in the middle of everything

### For All You Math Geniuses Out There...

I'm preparing to take the SAT test (a standardized test that is required to get into most colleges/universities here in the United States) by taking several practice tests in my spare time. One of the practice tests had the following problem, which I was unable to solve mathematically. After the test I looked at the solution (which I give in the spoiler below the problem), and if you plug the solution into the problem it comes out just fine, but there was no explanation offered with the solution and I'm unable to determine how the solution was reached. I'd be interested if anyone could offer a possible way to solve this.

I have no idea how they arrived at that solution, but here's my thought process:
Since there is a time limit on the SAT, I ended up wasting a lot of time on this problem, and I never even figured out an answer (right or wrong) anyway. I've looked for alternate routes to solve this problem mathematically, but either I'm missing something obvious or there is no mathematical method to solve it.

A four-digit integer, WXYZ, in which W, X, Y, and Z each represent a different digit, is formed according to the following rules.

1. X = W + Y + Z

2. W = Y + 1

3. Z = W - 5

What is the four-digit integer?

**Solution:**

**My Methodology:**

"I'm never wrong. One time I thought I was wrong, but I was mistaken."

### Re: For All You Math Geniuses Out There...

I have absolutely no math qualifications whatsoever, but I could find the solution easily, by myself. I think you overthought this and took it as algebra while it is in fact logic. Here is my methodology:

A single digit cannot but higher than 9, hence:

X = Z+W+Y <= 9

A single digit cannot be lower than 0 either, hence:

W has to be between 5 and 9 (because Z=W-5 or W=Z+5);

Z has to be between 0 and 4;

Y has to be between 4 and 8;

If W+Z+Y must be <= 9, I took the minimum values, which are in fact the solution:

W = 5,

Y = W-1 = 4

Z = W-5 = 0

X = W+Y+Z = 9

Edit: Well, your methodology ain't so bad: your 3Y - 3 thing is cool, but it ultimately leads to a dead end if you don't try to substitute Y... I'll rethink this over, to see if there's a mathematical solution.

A single digit cannot but higher than 9, hence:

X = Z+W+Y <= 9

A single digit cannot be lower than 0 either, hence:

W has to be between 5 and 9 (because Z=W-5 or W=Z+5);

Z has to be between 0 and 4;

Y has to be between 4 and 8;

If W+Z+Y must be <= 9, I took the minimum values, which are in fact the solution:

W = 5,

Y = W-1 = 4

Z = W-5 = 0

X = W+Y+Z = 9

Edit: Well, your methodology ain't so bad: your 3Y - 3 thing is cool, but it ultimately leads to a dead end if you don't try to substitute Y... I'll rethink this over, to see if there's a mathematical solution.

*Jazz is not dead, it just smells funny*- Frank Zappa

**Current projects:**Internet meme Era, The Settlers of Wesnoth

- Alarantalara
- Art Contributor
**Posts:**782**Joined:**April 23rd, 2010, 8:17 pm**Location:**Canada

### Re: For All You Math Geniuses Out There...

Using just the equations given, the problem is underspecified with an infinite number of solutions as you discovered.

You could rewrite it as a linear programming problem:

Maximize 1000w + 100x + 10y + z

Subject to:

1 <= W <= 9

0 <= X <= 9

0 <= Y <= 9

0 <= Z <= 9

W+Y+Z=X

W=Y+1

Z=W-5

And then solve it. (Note that this does not include the unique digit constraint, so is incomplete. In this case it doesn't matter, since there is only one result that satisfies the constraints)

Practically, the only important part is recognizing the extra constraints and adding them to the equations to solve the problem as Dixie did. It's likely much faster to do it that way than to set up the problem above and solve it manually.

You could rewrite it as a linear programming problem:

Maximize 1000w + 100x + 10y + z

Subject to:

1 <= W <= 9

0 <= X <= 9

0 <= Y <= 9

0 <= Z <= 9

W+Y+Z=X

W=Y+1

Z=W-5

And then solve it. (Note that this does not include the unique digit constraint, so is incomplete. In this case it doesn't matter, since there is only one result that satisfies the constraints)

Practically, the only important part is recognizing the extra constraints and adding them to the equations to solve the problem as Dixie did. It's likely much faster to do it that way than to set up the problem above and solve it manually.

- artisticdude
- Moderator Emeritus
**Posts:**2424**Joined:**December 15th, 2009, 12:37 pm**Location:**Somewhere in the middle of everything

### Re: For All You Math Geniuses Out There...

So I did. So there was no strictly mathematical route to solve it after all. Which, I suppose, is why the equations were called 'rules' and not 'equations'.Dixie wrote:I think you overthought this and took it as algebra while it is in fact logic.

Thanks guys, that makes a lot more sense.

"I'm never wrong. One time I thought I was wrong, but I was mistaken."

### Re: For All You Math Geniuses Out There...

I'd even have solved that by getting everything to one variable. I selected Y (whyever).

So, we have given:

X = W + Y + Z

W = Y + 1

Z = W - 5 => Z = Y + 1 - 5 = Y - 4

=> X = (Y + 1) + Y + (Y - 4) = 3 * Y - 3

Now we have the following four digits:

Y + 1; 3 * Y - 3; Y; Y - 4

As all digits must be in the range 0..9, we can see three conditions here:

I. 0 < Y + 1 < 10 => -1 < Y < 9

II. 0 < 3 * Y - 3 < 10 => 0 < Y < 5

III. 0 < Y - 4 < 10 => 14 > Y > 3

And now the solution is obvious: Y = 4 (as that is the only value for Y which fulfills conditions II and III).

Let's see the result:

W = Y + 1 = 5

X = 3 * Y - 3 = 9

Y = 4

Z = Y - 4 = 0

=> 5940

So, we have given:

X = W + Y + Z

W = Y + 1

Z = W - 5 => Z = Y + 1 - 5 = Y - 4

=> X = (Y + 1) + Y + (Y - 4) = 3 * Y - 3

Now we have the following four digits:

Y + 1; 3 * Y - 3; Y; Y - 4

As all digits must be in the range 0..9, we can see three conditions here:

I. 0 < Y + 1 < 10 => -1 < Y < 9

II. 0 < 3 * Y - 3 < 10 => 0 < Y < 5

III. 0 < Y - 4 < 10 => 14 > Y > 3

And now the solution is obvious: Y = 4 (as that is the only value for Y which fulfills conditions II and III).

Let's see the result:

W = Y + 1 = 5

X = 3 * Y - 3 = 9

Y = 4

Z = Y - 4 = 0

=> 5940

UMC Story Images — Story images for

*your*campaign!### Re: For All You Math Geniuses Out There...

WXYZ=5940

X = W + Y + Z(=) 9=5+4+0

W = Y + 1(=) 5= 5+1

Z = W - 5 (=) 0=5-5

P.S.My three cents.

X = W + Y + Z(=) 9=5+4+0

W = Y + 1(=) 5= 5+1

Z = W - 5 (=) 0=5-5

P.S.My three cents.

My new account is: Power_Pixel_Wannabe. Yea. Yea.... Why are you still reading this? What the heck m8? You have some kind of problem? Yea. I draw. NO I'M NOT 5 ANYMORE!!! Little brats.

The heck m8? I thought you left... No seriously... go... serious...

ok bye m8. I'm serious.

The heck m8? I thought you left... No seriously... go... serious...

ok bye m8. I'm serious.

### Re: For All You Math Geniuses Out There...

Eh. You have inflation, right? [/bad joke]

You are not supposed to explain the solution, but the way to get it.

You are not supposed to explain the solution, but the way to get it.

UMC Story Images — Story images for

*your*campaign!### Re: For All You Math Geniuses Out There...

The first thing I did was line up all the variables like so:

Now we could probably save some time by noting that X as the sum of all these is going to be towards the large side, and we could guess X=9, then failing that guess X=8, and so on. When the problem domain is small enough, plugging in numbers can be a great time saver on these standardized tests. But, let's try without any guessing:

If you did all these steps then you probably wasted too much time, though.

Code: Select all

```
0 <= Z < Y < W < X <= 9
```

Code: Select all

```
Z = W - 5 (rule #3)
W = Z+5
W = Y+1 (rule #2)
Z+5 = Y+1
Y = Z+4
X = W+Y+Z (rule #1)
X = Z+5 + Z+4 + Z
X = 3Z+9
X <= 9
3Z+9 <= 9
3Z <= 0
Z <= 0
0 <= Z <= 0
Z = 0
Y = 4
W = 5
X = 9
```

http://www.wesnoth.org/wiki/User:Sapient

*... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."*### Re: For All You Math Geniuses Out There...

Just for the record, here is a Prolog solution!

First some predicates. 'Dig' defines what is a legal digit, while 'add' and 'sub' operates on them.
Now we just need to set up the constraints from the problem description (molded with the notation we just invented). This is like asking "hey Prolog, can you see if you can find a set of digits so that X is W, Y and Z added, and Y plus 1 is W, and W minus 5 is Z?"
And out comes the answer!

First some predicates. 'Dig' defines what is a legal digit, while 'add' and 'sub' operates on them.

Code: Select all

```
dig(X) :- dig_(X, 9).
dig_(0, _).
dig_(s(X), N) :- N > 0, dig_(X, N - 1).
add(R, 0, R).
add(X, s(Y), s(R)) :- dig(R), add(X, Y, R).
sub(X, Y, Z) :- add(Z, Y, X).
```

Code: Select all

```
add(W, Y, _WY), add(_WY, Z, X),
add(Y, s(0), W),
sub(W, s(s(s(s(s(0))))), Z).
```

Code: Select all

```
W = s(s(s(s(s(0)))))
X = s(s(s(s(s(s(s(s(s(0)))))))))
Y = s(s(s(s(0))))
Z = 0
```

### Re: For All You Math Geniuses Out There...

There are several different ways to solve this. As dixie said it is an exercise in logic. Crendgrim gave a good solution for you and atlaranta is right about a general technique (I wrote a linear optimization on my calculator myself in University/College )

Here's another methodology you might find useful to compare against:

Always turn these problems into a semi-matrix form with coefficients on one side and results on the other, leaving gaps so that the x,y,z line up:

x-w-y-z=0 ....(1)

-w+y =-1 ....(2)

-w +z=-5 ....(3)

Now, (1)+(2)+(3) gives:

x=3(w-2)

Meaning that x is a multiple of 3

from (3) we know that (w-2) = z+3, giving x = 3(z+3)

because z must be at least 0, x must be 3*(0+3)=9

The rest just falls into place from there.

Here's another methodology you might find useful to compare against:

Always turn these problems into a semi-matrix form with coefficients on one side and results on the other, leaving gaps so that the x,y,z line up:

x-w-y-z=0 ....(1)

-w+y =-1 ....(2)

-w +z=-5 ....(3)

Now, (1)+(2)+(3) gives:

x=3(w-2)

Meaning that x is a multiple of 3

from (3) we know that (w-2) = z+3, giving x = 3(z+3)

because z must be at least 0, x must be 3*(0+3)=9

The rest just falls into place from there.

### Re: For All You Math Geniuses Out There...

W + Y + Z <= 9

Since Z = W - 5 and W = Y + 1, we can substitute W and Y in the above --

(Z + 5) + (Z + 4) + Z <= 9

So

3Z + 9 <= 9 (i.e., Z <= 0 so Z = 0, and the rest follows.)

QED, in about 10 seconds.

Since Z = W - 5 and W = Y + 1, we can substitute W and Y in the above --

(Z + 5) + (Z + 4) + Z <= 9

So

3Z + 9 <= 9 (i.e., Z <= 0 so Z = 0, and the rest follows.)

QED, in about 10 seconds.