2
$\begingroup$

How can you make the number 12 with just the numbers 1,5,19,10? You can only use each number once, and can only use subtraction addition multiplication and division.

$\endgroup$
  • 1
    $\begingroup$ Do we need to use each of 1,5,19,10 exactly once? $\endgroup$ – Rand al'Thor Apr 7 '17 at 19:32
  • $\begingroup$ Has a correct answer been given? If so, please don't forget to $\color{green}{\checkmark \small\text{Accept}}$ it. If not, some responses to the answerers to help steer them in the right direction would be helpful. $\endgroup$ – Rubio Apr 18 '17 at 6:36
7
$\begingroup$

It's certainly possible if

the division operation is what is sometimes termed "integer division" (that is, ignoring remainders)

Since

$19 \text{ div } 5 = 3$

So

$10 + 19 \text{ div } 5 - 1 = 10 + 3 - 1 = 12$


A brute force of non-lateral-thinking evaluations...

If for each of the $4!=24$ permutations of the numbers [A, B, C, D] we take each of the $4^3=64$ three-wise Cartesian product of the four operations (+, -, *, /) [p, q, r] and arrange them in the sixteen (I think) ways:

A
A p B
A p B q C
(A p B) q C
A p (B q C)
A p B q C r D
(A p B) q C r D
A p (B q C) r D
A p B q (C r D)
(A p B) q (C r D)
(A p B q C) r D
A p (B q C r D)
((A p B) q C) r D
A p ((B q C) r D)
(A p (B q C)) r D
A p (B q (C r D))

Then (while we will have equivalents) we will cover all the possible ways to calculate a result without resorting to any lateral thinking approach. (Note that we do not need B or C q D and the like since the permutations and Cartesian product will rearrange to equivalents in terms of A or A p B and so on.

Note: Please do comment if there are any I have missed! (I have not put the formula in terms of Catalan numbers, as I am not 100% on it myself)

This gives only $4^3\times 4!\times 16 = 24,576$ evaluations to make, which makes it pretty easy for a computer to print any that are as close or closer to $12$ as any so far evaluated - as this Python 3 code does (I added an epsilon just to catch any floating point deviations):

from itertools import permutations, product
distance = 12
epsilon = 0.001
for A,B,C,D in permutations((1,5,10,19)):
    for p,q,r in product('+-*/', repeat=3):
            for s in ("{0}", "{0}{4}{1}", "{0}{4}{1}{5}{2}", "({0}{4}{1}){5}{2}", "{0}{4}({1}{5}{2})", "{0}{4}{1}{5}{2}{6}{3}","({0}{4}{1}){5}{2}{6}{3}","{0}{4}({1}{5}{2}){6}{3}","{0}{4}{1}{5}({2}{6}{3})","({0}{4}{1}){5}({2}{6}{3})","({0}{4}{1}{5}{2}){6}{3}","{0}{4}({1}{5}{2}{6}{3})","(({0}{4}{1}){5}{2}){6}{3}","{0}{4}(({1}{5}{2}){6}{3})","({0}{4}({1}{5}{2})){6}{3}","{0}{4}({1}{5}({2}{6}{3}))"):
                    e = s.format(A,B,C,D,p,q,r)
                    v = eval(e)
                    curDistance = abs(12 - v)
                    if curDistance - epsilon <= distance:
                            distance = curDistance
                            print(e, '=', v)

Which prints:

1 = 1
1+5 = 6
1+5+10 = 16
(1+5)+10 = 16
1+(5+10) = 16
1+5+10 = 16
(1+5)+10 = 16
1+(5+10) = 16
1+5+10 = 16
(1+5)+10 = 16
1+(5+10) = 16
1+5+10 = 16
(1+5)+10 = 16
1+(5+10) = 16
1+5-10+19 = 15
(1+5)-10+19 = 15
1+(5-10)+19 = 15
(1+5-10)+19 = 15
1+(5-10+19) = 15
((1+5)-10)+19 = 15
1+((5-10)+19) = 15
(1+(5-10))+19 = 15
1+5-(10-19) = 15
(1+5)-(10-19) = 15
1+(5-(10-19)) = 15
1+5/10*19 = 10.5
(1+5)/10*19 = 11.4
((1+5)/10)*19 = 11.4
(1+5)/(10/19) = 11.4
(1+5)*19/10 = 11.4
(1+5)*(19/10) = 11.399999999999999
((1+5)*19)/10 = 11.4
(5+1)/10*19 = 11.4
((5+1)/10)*19 = 11.4
(5+1)/(10/19) = 11.4
(5+1)*19/10 = 11.4
(5+1)*(19/10) = 11.399999999999999
((5+1)*19)/10 = 11.4
19*(1+5)/10 = 11.4
19*((1+5)/10) = 11.4
(19*(1+5))/10 = 11.4
19*(5+1)/10 = 11.4
19*((5+1)/10) = 11.4
(19*(5+1))/10 = 11.4
19/10*(1+5) = 11.399999999999999
(19/10)*(1+5) = 11.399999999999999
19/(10/(1+5)) = 11.4
19/10*(5+1) = 11.399999999999999
(19/10)*(5+1) = 11.399999999999999
19/(10/(5+1)) = 11.4

and shows that the closest we can get is $11.4$ (subject to me being correct about the enumeration!)

Note to run this in Python 2, change for A,B,C,D in permutations((1,5,10,19)): to for A,B,C,D in permutations((1.,5.,10.,19.)): in order to correctly evaluate the floating point arithmetic

$\endgroup$
  • 1
    $\begingroup$ Excellent tour de brute force (and exhibition of interesting Python utilities)! I don't see anything missing but do suspect some duplication, as A p B q C, for instance, seems to be covered by (A p B) q C and A p (B q C). $\endgroup$ – humn Apr 8 '17 at 16:58
  • $\begingroup$ Yes plenty of duplication - note that in your "for instance" not all (p, q) choices have all three the same, some do, while others have two equal and a third different and some are one pair, while others are another - the duplication just avoids bothering to write complicated code at the expense of more evaluations. (Think A - B / C and A / B - C and their parenthesised counterparts. EDIT: Maybe the reordering actually takes care of these, um...) $\endgroup$ – Jonathan Allan Apr 8 '17 at 17:05
5
$\begingroup$

Turn the 19 upside-down to get 61, subtract 1 to get 60, divide by 10 - 5 to get 12. voilà.

$\endgroup$
  • $\begingroup$ What about the 10? (Also, I don't think your operation counts under the "subtraction addition multiplication and division" specified in the question.) $\endgroup$ – Rand al'Thor Apr 7 '17 at 21:15
  • $\begingroup$ turn that upside-down too, and multiply. he doesn't say we have to use all the numbers - implicitly i guess we should $\endgroup$ – JonMark Perry Apr 7 '17 at 21:17
  • 3
    $\begingroup$ @boboquack Not every short answer is necessarily a bad one. $\endgroup$ – Rand al'Thor Apr 7 '17 at 22:18
  • $\begingroup$ If you're going to count an upside down 10 as 1, why not just flip that and subtract 7 from 19? $\endgroup$ – Ian MacDonald Apr 8 '17 at 16:57
3
$\begingroup$

Do you really mean 19? The order of those numbers looks weird, so I'm wondering if you made a typo and actually mean 1, 5, 9, 10. If so, the answer is easier:

$\frac{10}{5}+9+1=12$.

If you really do mean 19 and not 9, then it's harder to get to 12. I've come up with a few possibilities that almost work:

  • $\frac{(19+5)\times5}{10}=12$ (uses 5 twice, doesn't use 1)

  • $10+\sqrt{\frac{19+1}{5}}=12$ (uses square root)

  • $10+\frac{19+1}{10}=12$ (uses 10 twice, doesn't use 5)

... and so on, but nothing that quite makes it perfectly.

$\endgroup$
3
$\begingroup$

I'll add another push-the-envelope answer.

I haven't found any solution in base 10, but there are solutions when the numbers are in other bases, for example:

   12₁₁ = 19₁₁ + 5₁₁ − 1₁₁ − 10₁₁ = 20 + 5 − 1 − 11 = 13
   12₁₂ = 1₁₂ × 5₁₂ + 19₁₂ − 10₁₂ = 1 × 5 + 21 − 12 = 14
   12₁₃ = 1₁₃ + 5₁₃ + 19₁₃ − 10₁₃ = 1 + 5 +22 − 13 = 15
   12₂₈ = 19₂₈ − 10₂₈ / (5₂₈ − 1₂₈) = 37 − 28 / (5 − 1) = 30
   12₃₆ = 19₃₆ − (10₃₆ − 1₃₆) / 5₃₆ = 45 − (36 − 1) / 5 = 38

(Yes, I know that unmarked numbers are in base 10, but it looks as if this question isn't solvable with a bit of lateral thinking.)

$\endgroup$
  • $\begingroup$ I concur. It is not solvable in base-10. But since base is not specified... $\endgroup$ – Overmind Apr 12 '17 at 11:47
0
$\begingroup$

Are you sure, the numbers are 1,5,19,10? I guessing answer was (19/5)+10-1 = 12.8 (or) (5/19)+1*10 = 12.6 by following under conditions (But it's not equal to 12).

we can do like $(5+1+10) - \sqrt{(19+1)/5} = 16-4.36 = 11.64$ (not equal to 12).

I believe $10 + \sqrt{(19+1)/5} = 12$ (need to use Square root)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.