14
$\begingroup$

How to get 32 by using +1,+1,×3,×3,÷2,÷2,^2,^2?
(The last two operators are 'squaring'.)

$\endgroup$
7
  • 7
    $\begingroup$ would you please clarify what number to start from? I assume it is zero, as do the responders (so far), but the question as it stands does not contain that restriction - it doesn't even mention use of a calculator device, which commonly start from implicit zero $\endgroup$ Apr 23, 2020 at 20:04
  • 3
    $\begingroup$ Why not just +1+1... = 32? $\endgroup$
    – S.S. Anne
    Apr 23, 2020 at 20:40
  • 9
    $\begingroup$ @S.S.Anne I think we're supposed to use exactly two of each, otherwise the repetition in the listing would be rather redundant. $\endgroup$ Apr 23, 2020 at 20:41
  • 5
    $\begingroup$ I hope people make more of these puzzles so I can make more diagrams (wink wink). $\endgroup$
    – Galen
    Apr 24, 2020 at 0:00
  • 3
    $\begingroup$ @EricDuminil well, another thing dictated by the calculator setup - which the question apparently is meant to imply - are strictly left-associative parentheses, not arbitrary ones. $\endgroup$ Apr 25, 2020 at 23:54

8 Answers 8

42
$\begingroup$

I like Glorfindel's answer as it takes you through an example solution, and I recommend his answer. Just to show some underlying beauty and complexity of this puzzle, I created a diagram (directed multigraph) that shows all possible results (that yield integers) of permuting these operations. You'll have to open the image in another tab and magnify to follow it in detail. I hope you enjoy.

Note that the green nodes are those where at least one sequence of the operations terminates there.

Starting at zero:

enter image description here

Starting at one:

Since there might be some interest in this case, here's a similar map.

It is not actually possible to get from 1 to 32 using exactly these 8 operations. enter image description here

Bonus Information

I checked every graph that starts at 0 up through 32, and confirmed that none of the other graphs terminate at 32. What's more, the answer given by Glorfindel is the only solution. This puzzle makes me happy.

$\endgroup$
45
  • 3
    $\begingroup$ Nice! If I'm reading the graph correctly, it looks like the solution is unique. $\endgroup$
    – Glorfindel
    Apr 23, 2020 at 20:03
  • 3
    $\begingroup$ @Glorfindel That's my understanding as well, assuming we use each of the eight given operations exactly once. $\endgroup$
    – Galen
    Apr 23, 2020 at 20:04
  • 3
    $\begingroup$ @Galen: Nice diagrams. Graphviz can export to PNG directly, BTW. $\endgroup$ Apr 25, 2020 at 11:55
  • 4
    $\begingroup$ @Galen Graphs like these tend to make me drool uncontrollably, they are so ... soothing. I love these and tend to analyze them and follow the paths for no good reason whatsoever. Tremendous work! For some reason they reminded me of graphs representing the Collatz conjecture which I also liked. One thing that bothered me however is that the second graph (exported in JPG format) has visible artifacts, I wish it was a PNG image like the first one. $\endgroup$
    – Tomalla
    Apr 26, 2020 at 10:15
  • 3
    $\begingroup$ I really appreciate all the constructive feedback and critical thinking in the comments of this answer. It is really cool to see that I made something that gets people thinking, which is what puzzles are about after all :) $\endgroup$
    – Galen
    Apr 26, 2020 at 15:36
36
$\begingroup$

Assuming you start with 0 (like on a calculator), this should work:

$$0 \times 3 = 0$$ $$0 + 1 = 1$$ $$1 \times 3 = 3$$ $$3 + 1 = 4$$ $$4^2 = 16$$ $$16 \div 2 = 8$$ $$8^2 = 64$$ $$64 \div 2 = 32$$

$\endgroup$
4
  • 4
    $\begingroup$ Nice answer---I seem to have lost my ability to solve these things as I get older.....I get lost in the endlessly bifurcating trees. But what bothers me about some of these puzzles is that the zero (no matter how you arrive to it) can act as a way to "throw away" subsequent operations, no? For instance, you hucked out the x3 here. You could just as easily have thrown out any of the multiplications, divisions, and exponents. Nothing wrong with that at all, it's all part of the rules. But it seems less ....... interesting to me to allow it somehow. I wonder how a rule might limit that? $\endgroup$ Apr 24, 2020 at 1:13
  • 2
    $\begingroup$ A possible rule would be to start with $x$ and forbid 0 as an intermediate result? $\endgroup$
    – Glorfindel
    Apr 24, 2020 at 15:50
  • $\begingroup$ @Glorfindel Good one. Perhaps another could be that no two adjacent numbers in the calculation sequence can be equal, thus operations must always change the number. In some ways that is limiting, but it could apply to any collection of operations. $\endgroup$
    – Galen
    Apr 24, 2020 at 16:08
  • 2
    $\begingroup$ another (more restrictive) rule would be to require each intermediate result to be distinct. $\endgroup$
    – Jasen
    Apr 26, 2020 at 10:53
15
$\begingroup$

I don't know how I got to this question from Stack Overflow... But here is the solution and the Python code for checking every combination:

((((((((0*3)+1)*3)+1)**2)/2.0)**2)/2.0)

lis = ['+1', '+1', '*3', '*3', '/2.0', '/2.0', '**2', '**2']
result = set()
def sol(lis, current, res, result):

    if not lis and res == 32:
        result.add(current)
        return

    for i in range(len(lis)):
        c = f"({current}{lis[i]})"
        sol(lis[:i] + lis[i+1:], c, eval("res"+lis[i]), result)
sol(lis, 0, 0, result)
print(result)
```
$\endgroup$
4
  • 2
    $\begingroup$ Check out my answer to this question! You can see all the combinations that produce integers. $\endgroup$
    – Galen
    Apr 24, 2020 at 6:24
  • 5
    $\begingroup$ You got here via the Hot Network Questions list, like many. Welcome! $\endgroup$
    – Glorfindel
    Apr 24, 2020 at 7:05
  • $\begingroup$ @Galen the code style I mention ?? $\endgroup$
    – snr
    Apr 24, 2020 at 19:08
  • $\begingroup$ @Frank Nice recursive definition! I'm a fan of recursion. $\endgroup$
    – Galen
    Apr 26, 2020 at 3:19
12
$\begingroup$

I noticed that there was a lot of emphasis around powers of 2, and that gave me an idea:

I started from the solution and brute-forced my way backwards. This puzzle can be rephrased as something like: Starting at 32, use these operators sequentially to get to 0: $$-1, -1, \div 3, \div 3, \times 2, \times 2, \sqrt(n), \sqrt(n)$$

Notably:

This set of inverse operations has a smaller search space because dividing by 3 and taking the square root are much more restrictive in their use.

My work:

$$32 \times 2 = 64$$ $$\sqrt(64) = 8$$ $$8 \times 2 = 16$$ $$\sqrt(16)= 4$$ $$4-1 = 3$$ $$3 \div 3 = 1$$ $$1-1 = 0$$ $$0 \div 3 = 0$$ Then all you have to do is re-invert the operations (and reverse their order) to get the answer of $$\times 3, +1, \times 3, +1, (n)^2, \div 2, (n)^2, \div 2$$

$\endgroup$
1
  • 5
    $\begingroup$ Welcome to Puzzling! This is actually the method I used (at least to get to 4). $\endgroup$
    – Glorfindel
    Apr 24, 2020 at 15:49
5
$\begingroup$

This solution reduces the problem to a simpler one using each operation's effect on prime factorization.

We begin with $0+1=1=2^03^0$. Each step is represented by the form: $2^n3^m$.
We have the following operations:

$(*3)$ yields $2^n3^{m+1}$

$(/2)$ yields $2^{n-1}3^m$

$(\hat{}2)$ yields $2^{2n}3^{2m}$

and $(+1)$ "randomly" shuffles/introduces new exponents. Our desired number is $2^5=32$.
The only reasonable first step is to increase the exponents from zero, so we can apply: $$2^03^0*3=2^03^1$$ We then use our only chance to get rid of the $3$ factor entirely: $$2^03^1+1=2^23^0$$ We must get from $2^2\rightarrow2^5$, so let's reduce the problem to solving $2\rightarrow5$ using the remaining four operations (on the exponent): $(-1), (-1), (*2), (*2)$. Let's start backwards from $5$:

The last operation must have been $6-1=5$ (because $2.5*2$ is unreachable),

Next must have been $3*2=6$, (cannot be $7-1=6$, because $2*2*2\neq7$),

$3$ is odd, so we came from $4-1=3$, and finally $2*2=4$.

Converting everything back, we have performed the following:
$$(((0+1)*3+1)^2/2)^2/2=32$$

Pretty contrived but it kind of forces the solution without exhausting all the possibilities!

$\endgroup$
2
  • $\begingroup$ There are two copies of x3. You have only used one. $\endgroup$
    – Nij
    Apr 24, 2020 at 23:28
  • 1
    $\begingroup$ A mathematical explanation with useful, formal hints how this kind of problem can be approached. The other x3 is easy to include. $\endgroup$
    – mafu
    Apr 25, 2020 at 5:10
4
$\begingroup$

I had a lot of fun with this one! First, as others did, I worked out it could "only" be done starting from one particular number, then saw Glorfindel's answer and realised that if

4 is a waypoint, then so is -4, because -4^2 is also 16.

So I worked backwards from that and found

a new starting point of -8/9.

Then it occurred to me that

all the operations are reversible on the complex plane

so I modified the operations accordingly and wrote a solver, also as an exercise in the C++ STL, tuples, lambdas and all that fancy stuff, wrote the output to a file and fed it into gnuplot.

This is the resulting plot, showing

all 161,280 possible starting points
NB: there are duplicates I haven't removed;
there are more results than 8! (40,320) because a complex number has two square roots
gnuplot of the results

Edit: After posting I found a way to remove duplicates, which if I got the logic right means there are

4950 unique answers, using a difference of 0.0001 in both parts.

Edit: Can I post an example?

32 -1 /3 -sqrt -sqrt -1 *2 *2 /3 = -1.3333 - i2.3906

$\endgroup$
2
  • $\begingroup$ What a cool generalization! I love it! $\endgroup$
    – Galen
    Apr 26, 2020 at 19:04
  • $\begingroup$ could you post an example? :) $\endgroup$
    – Rainb
    Apr 27, 2020 at 1:55
1
$\begingroup$

In response to the assertion that it cannot be done starting with 1, here is a method that may work, depending on exactly how the rules are applied.

$$(1) \times 3 = 3$$ $$3 + 1 = 4$$ $${4 \div 2} = 2$$ $$2^2 = 4$$ $${4 \div 2} = 2$$ $$2^{2+1 \times 3} = 2^5$$ $$2^5 = 32$$

$\endgroup$
0
1
$\begingroup$

I am assuming that we are looking for an integer solution. With this assumption, here is a top down approach that nobody else has used. The first question that needs to be asked is is that If a solution exists then what will be the last operator that would be used .

The last operator cannot be ×3 or ^2 as no integer × 3 = 32 nor (any integer)^2 = 32 . Therefore, the last operator to be used has to be either +1 or ÷2 . Therefore the numbers that are possible right before the last operator was used was either 31 (since 31+1= 32) or 64 ( since 64/2= 32). The following picture shows that there are only 5 ways to get to 32 using a total of 2 operations. enter image description here

The image below shows a complete expansion of one of the 5 paths shown above. As has been mentioned in the previous answers, we can see in the image below that there is indeed a path starting from 0 such that using all the 8 operators exactly once, we can get to 32.

enter image description here

$\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.