BrainDen.com - Brain Teasers
• 1

# Arrange numbers and operators to the magic triangle

## Question

Note : A # B = A*10 + B

Arrange the numbers 1 to 9 to green triangles, and arrange operator (+,-,x,/,^, and #) to the white triangles, so the math operations below are equals.

• (((A op1 B) op2 D) op4 F) = constant
• (((F op4 G) op5 H) op6 I) = constant
• (((I op6 E) op3 C) op1 A) = constant
• A x F x I = constant

## Recommended Posts

• 1

Looks like

Spoiler

Now I can get my life back. Nice puzzle.

##### Share on other sites

• 2

It was surprising to find that there is only one solution. Here's how I found it.

It's computationally challenging - brute force is possible, but I took it as a challenge to solve it efficiently. Even so, aside from guessing, there is no way to avoid evaluating the expression ((AoB)@C)%D for all 9x8x7x6=3024 variable permutations and all 6x5x4=120 operator permutations, 362880 computations in all. But I only did each once. Next I noticed that not all the results were valid.

Spoiler

The result has constraints:

1. Integer. ((1+2)x3)/7 = 0.8571428571, and similar results were discarded
2. No larger than (9x8x7=504). ((1+2)x3^7 = 279936 and similar ones were discarded
3. No smaller than (1x2x3)=6. ((1+2)x3)/6 = 1 and similar ones were discarded
4. The corners have to be valid. ((1+2)x3)x10+6 = 66, and similar ones don't work because with 1 and 6 as two of the corners, corner 3 would have to be 11, and 11 is out of range.

Actually, constraint #4 encompasses all the the requirements for the evaluated expression.

It turns out there are only 3928 valid expressions - about 1.1% of the cases. But all 362880 have to be evaluated to determine that fact and find the valid ones. Each valid expression represents a candidate for a side of the triangle. I put the results into a table. No further calculations were necessary. The first 15 rows (candidate sides) look like this:

Spoiler

For the first record, (1 2 3 4) are the assigned values; (2 1 6) are the ops (-, +, 10A+B); and 24 is the result. Note that 24=1x4x6, where 1 and 4 are two of the corners (first and last value used) and 6 (an unused value) is available to assign to corner 3.

1 2 3 4 2 1 6 24 42=1x4x6
1 2 3 4 4 6 3 32 ...
1 2 3 4 6 2 3 36
1 2 3 4 6 3 2 32
1 2 3 5 4 1 6 40 40=1x5x8
1 2 3 5 4 3 6 20 ...
1 2 3 5 4 6 3 40
1 2 3 5 5 1 3 20
1 2 3 5 5 1 6 45
1 2 3 5 5 3 6 35
1 2 3 5 6 2 3 45
1 2 3 5 6 4 3 20
1 2 3 6 4 6 3 48 48=1x6x8
1 2 3 6 5 1 3 24 ...
1 2 3 6 6 2 3 54

A solution to the triangle is a set of three sides that

1. "Connect" at their end values (and ops)
2. Use all the values
3. Use all the ops
4. Share a common expression value (equal to the product of the three corners)

There were 60 valid results for the expressions:

Spoiler

6   8  10  12  14  15  16  18  20  21  24  27  28  30  32
35  36  40  42  45  48  54  56  60  63  64  70  72  80  84
90  96 105 108 112 120 126 135 140 144 160 162 168 180 189
192 210 216 224 240 252 270 280 288 315 336 360 378 432 504

And the full table did not have to be searched. Only segments of the full table had to be searched: those records with a common result. For example, the 2 sides that evaluated to 240.

Spoiler

6 2 4 8 6 3 2 240
8 2 3 6 6 3 2 240

Clearly 240 is not the right corner product; it takes more than two sides to make a triangle.

Or the 13 sides that evaluate to 252.

Spoiler

4 1 5 7 6 2 3 252 ?
4 1 5 9 2 5 1 252
4 1 6 7 2 6 3 252
4 2 6 7 6 2 3 252
4 2 8 9 2 6 3 252
4 2 8 9 4 6 3 252
4 6 3 9 3 6 1 252
4 6 5 7 3 6 1 252
7 1 3 4 2 6 3 252 X
7 1 8 4 6 2 3 252 X
7 5 8 9 2 6 3 252 ?
9 3 2 7 2 5 3 252 X
9 3 6 7 4 6 3 252 X

We inspect the first record (in red.) It begins with corner value of 4 and ends with corner value of 7. Looking down the table for sides beginning with 7, we see two of them that end with 4, which would be a triangle with only two corners, and a third side that ends with 9. And since 4x7x9=252 things look OK so we check for sides beginning with 9. There are two, but both of them go to a corner value of 7, not to 4. So there is no valid third side. But note also that our second side 7 5 8 9 is also invalid because it has an interior value of 5, a value already used by the first side (4 1 5 7). So actually there is no valid second side to go with the first record. So the first record is rejected.

With similar analysis, all the sides for the 252 corner product are rejected. So 252 is not the product of the corners.

Note that table lookup is lightning fast. All the computation time was used evaluating 362880 expressions and culling out 3928 valid sides.

Or the 79 sides that evalu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6 1 3 1 2 45
9 2 7 5 1 2 6 45
9 3 2 5 4 5 3 45
9 3 6 5 4 1 3 45
9 3 8 5 1 2 6 45
9 4 8 5 2 3 1 45
9 6 2 5 1 5 4 45
9 6 2 5 2 5 3 45
9 6 3 1 1 3 4 45
9 6 3 1 1 3 5 45
9 7 2 5 2 1 6 45
9 7 2 5 2 3 6 45
9 7 2 5 2 5 6 45
9 7 4 5 1 4 6 45
9 8 3 5 2 1 6 45
9 8 4 5 2 3 6 45

5 3 8 1 6 2 3 45 <-> 1 6 2 9 3 5 1 45 <-> 9 7 4 5 1 4 6 45

Here the solution is found. Side (1 6 2 9  3 5 1) connects to side (9 7 4 5  1 4 6) which connects to side (5 5 8 1  6 2 3). Note that both the end values and the end ops match. All of the values (1-9) and ops (1-6) are used, without repetition.

That is the only solution.

##### Share on other sites

• 0

Clarification?

Each variable {A B C D E F G H I} can be used only once.
I now assume, but it's not clear, that each operator {+ - x / ^ 10A+B]} can be used only once, making (9!)(6!) cases.

I started allowing any operator to be used in each white triangle.

##### Share on other sites

• 0
6 hours ago, bonanova said:

Clarification?

Each variable {A B C D E F G H I} can be used only once.
I now assume, but it's not clear, that each operator {+ - x / ^ 10A+B]} can be used only once, making (9!)(6!) cases.

I started allowing any operator to be used in each white triangle.

Yes you are right, each operator  only can be used once. making ((9!)(6!))/3 cases. (Because of the symmetry)

Edited by jasen
##### Share on other sites

• 0

When creating this puzzle (using computer), I started with 3 first constraints, then I got many solutions, so I have to add 1 more constraint. But I have to keep the symmetry of the puzzle. First I tried to sum the three corners, but I still got some solutions. Then  I tried to product the three corners, which yields 1 unique solution.

When creating this puzzle (using computer), I started with 3 first constraints, then I got many solutions, so I have to add 1 more constraint. But I have to keep the symmetry of the puzzle. First I tried to sum the three corners, but I still got some solutions. Then  I tried to product the three corners, which yields 1 unique solution.

##### Share on other sites

• 0

Must have been nice to have a unique solution appear like that.

I'm working on a truth-teller puzzle based on the recent US election.
Going through the same process.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.