Post Reply 
Solving a simple addition / multiplication puzzle.
02-17-2024, 09:44 PM (This post was last modified: 02-18-2024 01:43 AM by matalog.)
Post: #1
Solving a simple addition / multiplication puzzle.
My dad forwarded me an email I had sent him in 2002:

"A customer at a 7-11 store selected four items to buy, and was told that the cost was $7.11. He was curious that the cost was the same as the store name, so he inquired as to how the figure was derived. The clerk said that he had simply multiplied the prices of the four individual items. The customer protested that the four prices should have been ADDED, not MULTIPLIED. The clerk said that that was OK with him, but, the restult was still the same: exactly $7.11. What were the four prices?"

So, obviously we have a+b+c+d =7.11= a*b*c*d.

I must have took the time to work it out on paper back then, but now I have my HP Prime.

To be honest, I usually use this calculator to do something different regarding connectivity or fast processing on a mobile computer, but I rarely use it for these type of real world problems and need some help.

Is there a way to input those 2 equations, and get a solve app or command on the HP Prime to return the answers?

I suppose that the answers will be 2dp each, and not more.

I tried this in CAS
Code:
solve( { a+b+c+d=7.11, a+b+c+d=7.11}, {a, b, c, d})
but it resulted in a far more complicated answer than I assume the writer of the puzzle had in mind :-).
Find all posts by this user
Quote this message in a reply
02-18-2024, 03:15 AM (This post was last modified: 02-20-2024 07:27 PM by Albert Chan.)
Post: #2
RE: Solving a simple addition / multiplication puzzle.
711 = 79 * 9 --> a = 0.79k, for positive integer k

b+c+d = 7.11 - 0.79k
k*b*c*d = 9.

9*10^6, divisors ≥ 100: 100,120,125,144,150,160,180,192,200,225,240,250,288,300, ...

k=1:
b+c+d = 6.32
b*c*d = 9

9 ≈ 3.00 * 1.732 * 1.732 --> sum of factors ≈ 6.46, too high
9 ≈ 2.88 * 1.768 * 1.768 --> sum of factors ≈ 6.42, again too high
9 ≈ 2.50 * 1.897 * 1.897 --> sum of factors ≈ 6.29, possible
9 = 2.50 * 2.00 * 1.80 --> sum of factors = 6.30
9 = 2.50 * 2.25 * 1.60 --> sum of factors = 6.35 --> 2.5 no good
9 ≈ 2.40 * 2.25 * 1.667 --> sum of factors ≈ 6.317
9 ≈ 2.40 * 2.40 * 1.563 --> sum of factors ≈ 6.363 --> 2.4 no good
9 ≈ 2.25 * 2.25 * 1.778 --> sum of factors < 6.317, can't get higher, k=1 no good

We still do sum of factors, even for fractional pennies, so that we know when to stop.

k=4 give the first solution:

3.16 + 1.50 + 1.25 + 1.20 = 7.11
3.16 * 1.50 * 1.25 * 1.20 = 7.11
Find all posts by this user
Quote this message in a reply
02-18-2024, 03:49 AM
Post: #3
RE: Solving a simple addition / multiplication puzzle.
Albert you are a very clever fellow!

On the face of it, there are four variables but only three pieces of information, being three pairs of quantities that are equal! Can you explain a little more about the insight that you have that allows us to get past that? What is the significance of your first line?
Find all posts by this user
Quote this message in a reply
02-18-2024, 04:36 AM
Post: #4
RE: Solving a simple addition / multiplication puzzle.
Before solving puzzle, I checked if AM ≥ GM

AM(a,b,c,d) = 7.11/4 ≈ 1.78
GM(a,b,c,d) = 4√(7.11) ≈ 1.63

AM ≥ GM --> solution is possible.

(02-18-2024 03:49 AM)Johnh Wrote:  What is the significance of your first line?

If we use units of pennies, we are really searching for integer solution.

A + B + C + D = 711
A * B * C * D = 711 * 10^6 = 79 * 9 * 10^6

79 is a prime number, must go in one of the variable, I just put it in A

B + C + D = 711 - 79k
k * B * C * D = (9 * 10^6)

(B, C, D) must be divisors of (9 * 10^6)
Find all posts by this user
Quote this message in a reply
02-18-2024, 09:07 AM (This post was last modified: 02-18-2024 10:11 AM by Thomas Klemm.)
Post: #5
RE: Solving a simple addition / multiplication puzzle.
This Python program is based on 2.1.5 Our Third Additive Solution of The 7-11 Problem:
Code:
N = 7_11_00_00_00
divs = [n for n in range(1, 711) if N % n == 0]

for a in divs:
    for b in [b for b in divs if a < b and a + b <= 709]:
        for c in [c for c in divs if b < c and a + b + c <= 710]:
            d = 711 - (a + b + c)
            if c < d and a * b * c * d == N:
                print(a, b, c, d)

Result

120 125 150 316

Using a single list-comprehensions makes it maybe easier to read:
Code:
[
    (a, b, c, d)
    for a in divs
    for b in divs
    for c in divs
    for d in [711 - (a + b + c)]
    if a < b < c < d and a + b + c < 711 and a * b * c * d == N
]

Result

[(120, 125, 150, 316)]

In this paper you can also find 2.2 Mathematical Approach:
Quote:We could also attempt to solve this without a computer program, and
exclude choices through mathematical trickery.

You can search for a+b+c+d=7.11=a*b*c*d and find plenty solutions.
Find all posts by this user
Quote this message in a reply
02-18-2024, 02:43 PM (This post was last modified: 02-23-2024 06:21 PM by Albert Chan.)
Post: #6
RE: Solving a simple addition / multiplication puzzle.
(02-18-2024 03:15 AM)Albert Chan Wrote:  711 = 79 * 9 --> a = 0.79k, for positive integer k

b+c+d = 7.11 - 0.79k
k*b*c*d = 9.

9*10^6, divisors ≥ 100: 100,120,125,144,150,160,180,192,200,225,240,250,288,300, ...

Instead of guessing, we may first find out where to look. (I skipped k=1..3)

k=4                   --> a = 0.79k = 3.16
b+c+d = 3.95    --> AM ≈ 1.3167
b*c*d = 2.25     --> GM ≈ 1.3104

AM > GM, and they are *very* close!
Let's assume (b,c,d) evenly distributed, b=c-x, d=c+x

c ≈ AM ≈ 1.3167
b*c*d = c*(c^2-x^2) = 2.25 --> x ≈ 0.1577

--> (b,c,d) ≈ [1.1590, 1.3167, 1.4744]
--> c must be within extremes, possibilities = 1.20, 1.25, 1.44

Lets try the more likely center first, c = 1.25

(b+d) = 3.95 - 1.25 = 2.7
(b*d) = 2.25 / 1.25 = 1.8

(b-d)² = (b+d)² - 4*(b*d) = 2.7² - 4*1.8 = 0.09 = 0.3²
(b, d) = ((b+d) ± (b-d))/2 = (2.7 ± 0.3)/2 = (1.20, 1.50)

--> (a, b, c, d) = 3.16, 1.20, 1.25, 1.50



Another way is assume (b,c,d) skewed extremely to one side, i.e. c = d

Cas> solve(b+d+d=3.95 and b*d*d=2.25, [b,d])

\(\left(\begin{array}{cc}
1.1390 & 1.4055 \\
1.5028 & 1.2236 \\
5.2583 & -0.6541
\end{array}\right)\)

max(b,d) = (1.4055, 1.5028), possibilities = 1.44, 1.50
min(b,d) = (1.1390, 1.2236), possibilities = 1.20

Solving cubic is harder, but we reduced to test only for b = 1.20
With only 2 possible d's left, we could try them all to get c.

2.25 / (1.20*1.44) = 1.30208... ✘
2.25 / (1.20*1.50) = 1.25

3.16 + 1.20 + 1.25 + 1.50 = 7.11 ✔
Find all posts by this user
Quote this message in a reply
02-18-2024, 03:34 PM
Post: #7
RE: Solving a simple addition / multiplication puzzle.
(02-18-2024 04:36 AM)Albert Chan Wrote:  Before solving puzzle, I checked if AM ≥ GM

AM(a,b,c,d) = 7.11/4 ≈ 1.78
GM(a,b,c,d) = 4√(7.11) ≈ 1.63

AM ≥ GM --> solution is possible.

(02-18-2024 03:49 AM)Johnh Wrote:  What is the significance of your first line?

If we use units of pennies, we are really searching for integer solution.

A + B + C + D = 711
A * B * C * D = 711 * 10^6 = 79 * 9 * 10^6

79 is a prime number, must go in one of the variable, I just put it in A

B + C + D = 711 - 79k
k * B * C * D = (9 * 10^6)

(B, C, D) must be divisors of (9 * 10^6)


Could you explain why 79 must be one of the values? I cannot find the answer.

Thank you

Patrick
Find all posts by this user
Quote this message in a reply
02-18-2024, 11:51 PM
Post: #8
RE: Solving a simple addition / multiplication puzzle.
(02-18-2024 03:34 PM)case2001 Wrote:  Could you explain why 79 must be one of the values? I cannot find the answer.

A * B * C * D = 711 * 10^6 = 79 * 9 * 10^6

If we divide both side by prime 79, RHS still is integer, so does LHS.

(A * B * C * D) / 79 = 9 * 10^6

This mean one of the variables must be divisible by 79, to make LHS match RHS

(02-17-2024 09:44 PM)matalog Wrote:  Is there a way to input those 2 equations, and get a solve app or command on the HP Prime to return the answers?

I don't know about HP Prime, but Python z3 solver can solve the puzzle in seconds.

>>> from z3 import *
>>> A, B, C, D = Int('A'), Int('B'), Int('C'), Int('D')
>>> solve(A+B+C+D == 711, A*B*C*D == 711*10**6, A>0, B>0, C>0, D>0)

[D = 120, C = 316, B = 125, A = 150]
Find all posts by this user
Quote this message in a reply
02-19-2024, 01:24 AM
Post: #9
RE: Solving a simple addition / multiplication puzzle.
Thank you
Find all posts by this user
Quote this message in a reply
02-19-2024, 04:53 PM (This post was last modified: 02-24-2024 02:47 AM by Albert Chan.)
Post: #10
RE: Solving a simple addition / multiplication puzzle.
(02-18-2024 04:36 AM)Albert Chan Wrote:  Before solving puzzle, I checked if AM ≥ GM

AM(a,b,c,d) = 7.11/4 ≈ 1.78
GM(a,b,c,d) = 4√(7.11) ≈ 1.63

AM ≥ GM --> solution is possible.

It is a good idea to maintain AM/GM inequality thorughtout, to reduce search space.
Example, if we assume b=c=d, and have AM = GM:

Cas> solve((7.11-a)/3 = (7.11/a)^(1/3), a)     → [0.744, 3.192]
Cas> solve((7.11-3*d) = 7.11/d^3, d)            → [1.306, 2.122]

Or, we solve both together

Cas> solve(a+d+d+d = 7.11 and a*d*d*d = 7.11, [a,d])

\(\left(\begin{array}{cc}
3.192 & 1.306 \\
0.744 & 2.122
\end{array}\right)\)

Add back AM/GM inequality, with (a,b,c,d) sorted, unit = pennies

a = 75 .. 130
d = 213 .. 319

Code:
N = 711 * 10**6
divs = [x for x in range(75,320) if N%x==0]
A = [x for x in divs if x <= 130]
D = [x for x in divs if x >= 213]

for a in A:
    for d in D:
        for b in divs:
            c = 711 - (a+b+d)
            if a<=b<=c<=d and a*b*c*d == N: print(a,b,c,d)

120 125 150 316

We could also loop a and d, and solve (b,c) with quadratic formula.
But trial and errors with all possible b's probably just as quick.

Comment:

Do this by hand, I would probably try A in reverse order.
Even if tested number is not a, it may have hit b or c.

>>> A[::-1]
[125, 120, 100, 96, 90, 80, 79, 75]
Find all posts by this user
Quote this message in a reply
02-20-2024, 06:47 PM (This post was last modified: 02-20-2024 08:05 PM by Albert Chan.)
Post: #11
RE: Solving a simple addition / multiplication puzzle.
(02-19-2024 04:53 PM)Albert Chan Wrote:  Do this by hand, I would probably try A in reverse order.
Even if tested number is not a, it may have hit b or c.

>>> A[::-1]
[125, 120, 100, 96, 90, 80, 79, 75]

Perhaps we should *not* check if the number hit b or c, to avoid double counting.
Try first number from A[::-1], apply AM/GM inequality for (b, d) valid ranges:

a = 125
b = 094 .. 133, possibilities = [125, 120, 100]
d = 247 .. 318, possibilities = [250, 288, 300, 316]

It is true that from possible (b,d)'s, we have solved the puzzle.
What if solution is not here? Then, we try the next one on the list.

a = 120
b = 098 .. 136, possibilities = [125, 120, 100]
d = 247 .. 318, possibilities = [250, 288, 300, 316]

Now, (a,b)=(120,125) is double counted. Same thing happens for case a=100
It is better to assume a is really the smallest. For a=125, only test for b=125

With a≤b restriction, no double counting.
Code:
a       b           b's     d           d's     (b's)×(d's)
125     125 .. 133  1       247 .. 318  4       4
120     120 .. 136  2       247 .. 318  4       8
100     117 .. 152  4       248 .. 306  3       12
 96     122 .. 156  3       247 .. 301  3       9
 90     133 .. 164  4       245 .. 292  2       8
 80     161 .. 183  1       236 .. 264  3       3
 79     166 .. 186  1       234 .. 259  3       3
 75     195 .. 203  1       221 .. 229  1       1
        TOTAL CASES 17                  23      48

Use quadratic formula for (c,d), cases to check = 17
But even tried all possible (c,d)'s, total cases is only 48

What if we know a is multiple of 79? (Again, (b,c,d) assume sorted)
Code:
a       b           b's     d           d's     (b's)×(d's)
79*1    166 .. 186  1       234 .. 259  2       2
79*2     81 .. 119  3       237 .. 313  4       12
79*3     76 .. 107  4       200 .. 258  4       16
79*4    114 .. 122  1       141 .. 150  2       2
        TOTAL CASES 9                  12       32

Note: we don't have to actually solve all the valid ranges.

Keeping same GM, if numbers are further apart, AM will grow bigger.
If it is impossible to make AM ≥ GM, there is no solution ... we skipped it.
This allowed "solving" AM/GM inequality by trial and errors. (see post #2)
Find all posts by this user
Quote this message in a reply
02-22-2024, 09:47 PM (This post was last modified: 02-22-2024 11:37 PM by deachp.)
Post: #12
RE: Solving a simple addition / multiplication puzzle.
Hello,
It's an underdetermined system of 4 variables and two equations, therefore it has infinitely many solutions. If the goal is to obtain positive values with two decimal points, one can combine a quadratic equation, divisor calculation, and filtering out negative numbers and rational numbers. Here, I've developed a program for the 50G calculator that could be ported to the HP Prime:

«
711 0 0 0 0 0 0 -> P a b c d ldivis ldivis2
«
4 P * 1000000 * DIVIS 'ldivis' STO
1 ldivis SIZE FOR i
ldivis i GET 'a' STO
4 P * a / DIVIS 'ldivis2' STO

1 ldivis2 SIZE FOR j
ldivis2 j GET 'b' STO

IF '((a+b)-P)^2' ->NUM '4*P*1000000/(a*b)' ->NUM >= THEN

IF '((P-(a+b))+SQRT(((a+b)-P)^2-4*P*1000000/(a*b)))/2' ->NUM DUP FP 0 == THEN

'c' STO
'P-c-a-b' EVAL 'd' STO

IF a 0 > b 0 > AND c 0 > AND d 0 > AND THEN

a I->R 100 / "a" ->TAG
b I->R 100 / "b" ->TAG
c I->R 100 / "c" ->TAG
d I->R 100 / "d" ->TAG

END
ELSE DROP
END
END
NEXT
NEXT
»
»

SQRT: Square root symbol
-> : Arrow

a:1.25
b:3.16
c:1.5
d:1.2

It takes 20 sec., to emulator in "Authentic Calculator Speed" mode, to found the answers. It can be optimized.

-Dante Aroní C.
Find all posts by this user
Quote this message in a reply
02-24-2024, 03:20 AM
Post: #13
RE: Solving a simple addition / multiplication puzzle.
a*b*c*d = 79 * 3^2 * 10^6

This implied one and only one variable is divisible by 79
Also, at least one variable only divisible by prime 2 or 5

We loop through these 2 variables to get the others.
From AM/GM inequality, variables within 75 .. 319 (see post #10)

Code:
A = [79,158,237,316]
B = [80,100,125,160,200,250]

for a in A:
    for b in B:
        s = 711 - (a+b)         # (c+d)
        p = 711e6/(a*b)         # (c*d)
        if (d:=(s*s-4*p)) < 0: continue
        d = (s+sqrt(d))/2
        if d == int(d): print(a,b,s-d,d)

316 125 120.0 150.0
Find all posts by this user
Quote this message in a reply
02-24-2024, 05:49 PM (This post was last modified: 02-25-2024 04:45 PM by Albert Chan.)
Post: #14
RE: Solving a simple addition / multiplication puzzle.
CMS Vol 32 #5, Sep06, page 12: M203 Mayhem solution
The solution skipped trial and errors, and started with a = 79*4 = 316

Here is another solution, using simple parity check.
To get sum of 711, even a, (b+c+d) is odd, we need an odd number.

Odd variable possibilities, b = [75, 125, 225]
Based on AM/GM inequality, variables within 114 .. 150 --> b = 125 (see post #11)

Assuming we don't know that, it is still simple to check them all

a = 316:
b =   75 --> (c+d)=320, (c*d)=30000 --> (c-d)² = -17600 < 0
b = 125 --> (c+d)=270, (c*d)=18000 --> (c-d)² = 900 = 30² --> (c,d)=(270±30)/2
b = 225 --> (c+d)=170, (c*d)=10000 --> (c-d)² = -11100 < 0

--> (a, b, c, d) = (316, 125, 150, 120)



Another way is to figure out how 5^6 factor get splitted among (b,c,d).
5^4 = 625 > 319, outside AM≥GM criteria, we are down to 2 choices.

5^6 = 5^(3+2+1)
5^6 = 5^(2+2+2)

(b+c+d) = 711 - 79k = 79*(9-k)

If k=4, RHS divisible by 5, but still not divisible by 25
--> a = 79*4 = 316, b = (125 or 250) are the only cases to check.

Again, assume we don't know (b,c,d) valid range = 114 .. 150 --> b = 125

If b = 250, AM(c,d) = (711-a-b)/2 = 72.5, GM(c,d) = √(711e6/a/b) = √9000 ≈ 94.9
AM < GM, impossible.

If b = 125, AM(c,d) = (711-a-b)/2 = 135, GM(c,d) = √(711e6/a/b) = √18000 ≈ 134.2
AM > GM: (c,d) = AM ± √(AM^2 - GM^2) = 135 ± √225 = 135 ± 15

--> (a, b, c, d) = (316, 125, 150, 120)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)