29

Use the minimum number of ones to make 29.

Here is the list of operations permitted:

  • "Standard" operations, such as: $x+y$, $x-y$, $x\times y$, $x\div y$
  • Negation: $-x$
  • Exponentiation of two numbers: $x^y$
  • The square root of a number: $\sqrt{x}$
  • The factorial: $x!$
  • Concatenation of the original digits: $x|x$, $x|x|x$, $x|x|x$, etc. This means that you cannot concatenate like this: $(1+1)|1 = 2|1 = 21$

You can only use ones, and the result must be exactly $29$, not "about" 29.

You may not use any other operations. That includes $\log{x}$, $\left \lfloor{x}\right \rfloor$, $\left \lceil{x}\right \rceil$ and any others. You must only use base 10, and you not use any decimal points (i.e. no .1, .11, etc.).

The record to beat is 7.

user46002
  • 2,564
  • 1
  • 19
  • 30
Allan Cao
  • 400
  • 3
  • 11

10 Answers10

26

Here's a 7-digit solution:

$(11-1)\times(1+1+1)-1$

Searching exhaustively is somewhat complicated. Let's say, broadly, impossible. One is able to take indefinite factorials and raise to ludicrous powers and take arbitrary numbers of square roots. These endeavors would almost certainly lead nowhere but computers don't necessarily know that.

Not only so, but a search that doesn't use symbolic algorithms to handle sqrts and fractions might find something that looks like a solution but is only 29.0000000.

Nonetheless, one can arbitrarily put "reasonable" restrictions on such things and say that we are not going to do, for example, $a^b$ unless $0<a<1000$ and $-20<b<20$.

Doing this, I find that there are 28,948 different numbers that can be reached with six 1s. None of them is 29. My code just tracked one solution for each number that it found and spat out the above solution which suggests to me that it's the only one with 7 digits. I haven't tried to do list them all, but if someone else wants to wade through my code it is below

def factorial(n):
    if n<=1: return 1
    return n*factorial(n-1)

sols={}
sols[1] = {}
sols[1][1] = "1"
vals = set([1])

digits=2
while digits<=7:
    sols[digits] = {}

    #concat
    concat = "1"*digits
    if eval(concat) not in vals:
        sols[digits][eval(concat)] = concat
        vals.add(eval(concat))

    #simple sum
    if digits not in vals:
        ssum = "1+"*digits
        sols[digits][digits] = ssum[:-1]
        vals.add(digits)

    #partitions
    for part1 in range(1,digits):
        part2 = digits-part1
        if part1>part2: break
        for val1 in sols[part1]:
            for val2 in sols[part2]:
                #multiply
                if val1*val2 not in vals:
                    sols[digits][val1*val2] = "("+sols[part1][val1]+")*("+sols[part2][val2]+")"
                    vals.add(val1*val2)
                #add
                if val1+val2 not in vals:
                    sols[digits][val1+val2] = "("+sols[part1][val1]+")+("+sols[part2][val2]+")"
                    vals.add(val1+val2)
                #divide
                if val2 !=0:
                    if val1/val2 not in vals:
                        sols[digits][val1/val2] = "("+sols[part1][val1]+")/("+sols[part2][val2]+")"
                        vals.add(val1/val2)
                if val1 !=0:
                    if val2/val1 not in vals:
                        sols[digits][val2/val1] = "("+sols[part2][val2]+")/("+sols[part1][val1]+")"
                        vals.add(val2/val1)
                #subtract
                if val1-val2 not in vals:
                    sols[digits][val1-val2] = "("+sols[part1][val1]+")-("+sols[part2][val2]+")"
                    vals.add(val1-val2)
                if val2-val1 not in vals:
                    sols[digits][val2-val1] = "("+sols[part2][val2]+")-("+sols[part1][val1]+")"
                    vals.add(val2-val1)
                #exponent
                if val1 > 0 and val1 < 1000 and abs(val2)<20:
                    if val1**val2 not in vals:
                        sols[digits][val1**val2] = "("+sols[part1][val1]+")^("+sols[part2][val2]+")"
                        vals.add(val1**val2)
                if val2 > 0 and val2 < 1000 and abs(val1)<20:
                    if val2**val1 not in vals:
                        sols[digits][val2**val1] = "("+sols[part2][val2]+")^("+sols[part1][val1]+")"
                        vals.add(val2**val1)

    #adjustments
    k = list(sols[digits].keys())[:]
    for val in k:
        #Sqrt
        if val>0:
            if val**0.5 not in vals:
                sols[digits][val**0.5] = "sqrt("+sols[digits][val]+")"
                vals.add(val**0.5)
            if val==int(val) and val<=20:
                if factorial(val) not in vals:
                    sols[digits][factorial(val)] = "("+sols[digits][val]+")!"
                    vals.add(factorial(val))

    if 29 in vals:
        break
    #next number
    print(digits,len(sols[digits]))
    digits+=1
Dr Xorile
  • 23,406
  • 3
  • 47
  • 125
14

I thought I had it with this:

$\sqrt{((1+1+1)!)!+11^{1+1}}$.

Until I remembered that

there's no function to square a number without using any digits, even though there is a function to take a square root without using any extra digits. For the past hour I've been trying to figure out how to square a number just using the square root.
Since square root is a number raised to the power of $\frac{1}{2}$, I'm wondering if I can just take a reciprocal of that for a total of six 1s. My guess is that this isn't allowed because there isn't a way to actually write this down!
$\sqrt{((1+1+1)!)!+11^{\frac{1}{1/2}}}$

Amorydai
  • 2,963
  • 10
  • 19
14

As stated by luchonacho, exhaustion will show that it's not possible in less than 7 digits with those operations.

Not showing negative values, as they are symmetric to positive ones, here are the easy attainable integer values:

1 digit:  1
2 digits: 0, 2, 11, 11!, ...
3 digits: 3, 6, 10, 12, 111, 720, 10!, ...
4 digits: 4, 5, 7, 9, 13, 22, 24, 110, 112, 120, 121, 719, 721, 1111, ...
5 digits: 8, 14, 17, 20, 21, 23, 25, 33, 36, 64, 66, 100, 109, 113, 119, 122, 132, 144, 222, 360, ...

And now we know we're stuck, because to achieve 29 (a prime number) in 6 digits, we would actually need any of those values in 5 digits: 28, 30, 784, 900, ... and we don't have them.

As such, any solution for 29 in 7 digits is optimal:

29 = (11−1)×(1+1+1)−1 (found by Dr Xorile)

Note that there may be room for a non-trivial sum of factorial numbers to reach a square power of 29 (or of 29±1), as found by Amorydai, but it's unlikely to beat 7 digits.


For illustration, while all values below 27 are attainable trivially with 6 digits or less, here are some solutions in 7 digits for numbers greater or equal to 28:

28 in 7 digits = (1+1+1)^(1+1+1)+1
28 in 7 digits = (1+1)×(11+1+1+1)
29 in 7 digits = (11−1)×(1+1+1)−1
30 in 6 digits = (11−1)×(1+1+1)
31 in 7 digits = (11−1)×(1+1)+11
31 in 7 digits = (11−1)×(1+1+1)+1
31 in 7 digits = (1+1+1)×11-1-1
32 in 6 digits = (1+1+1)×11-1
33 in 5 digits = (1+1+1)×11
34 in 6 digits = (1+1+1)×11+1
35 in 6 digits = (1+1+1)!^(1+1)-1
36 in 5 digits = (1+1+1)!^(1+1)
37 in 6 digits = (1+1+1)!^(1+1)+1
38 in 7 digits = (1+1+1)!^(1+1)+1+1
39 in 7 digits = (11+1+1)×(1+1+1)
40 in 7 digits = (11-1)×(1+1+1+1)
40 in 7 digits = (11-1)×(1+1)×(1+1)

15 is the lowest positive value requiring 6 digits with this reasoning.
28 is the lowest positive value requiring 7 digits with this reasoning.
41 is the lowest positive value requiring 8 digits with this reasoning.

Cœur
  • 265
  • 1
  • 8
  • Well argued! Can you somehow build a mathematical proof from this line of thinking? It would be great. – luchonacho Feb 28 '19 at 16:51
  • 4
    The claim that it's impossible to reach 29 by some iterated factorial, followed by a trivial addition/subtraction, followed by an iterated square root, might be very hard to prove (and necessary, because factorial and square root are free actions in this ruleset). – Brilliand Feb 28 '19 at 23:18
  • 1
    @Brilliand in x! ± 1, you never have a divisor lower than x, so subsequent square roots will always have a factor greater than x itself. – Cœur Mar 01 '19 at 01:52
  • 1
    @Cœur could you add two factorials then modify the result? I would hazard a guess that you could find something that roots to a factor smaller than x. Unlikely whether that would be doable in less than 6 though, more as a counterexample to that proof. –  Mar 01 '19 at 04:52
  • 1
    Note that you can get 27 = (1+1+1)^(1+1+1) for 6 digits. Just for your illustration! – CriminallyVulgar Mar 01 '19 at 09:15
  • @Cœur I mean, I meant "x! + x!" which I don't think is a multifactorial. –  Mar 01 '19 at 15:19
  • @Riker ah well, I clarified in my edit that "it's unlikely to beat 7 digits". Sorry, can't demonstrate it, and we don't have super-computers for that. – Cœur Mar 01 '19 at 16:16
  • 1
    @Riker I just realized adding/subtracting two different factorials won't work for this. The sum x!+y! (or x!-y!) will always be divisible by the smaller of x! or y!, hence divisible by 2 (provided neither x nor y is 1), and no iterated square of 29 is divisible by 2. That limits the possible "trivial addition/subtraction"s to a fairly small set. – Brilliand Mar 04 '19 at 20:41
10

I managed three 8's:

$(1+1+1+1)!+(1+1+1)!-1=24+6-1$
$(1+1+1)!\times((1+1+1)!-1)-1=6\times(6-1)-1$
$(11+1+1+1)\times(1+1)+1=14\times2-1$

and a very dodgy 6:

$11!!!!!!!!-(1+1+1+1)=11\times3-4$

and 4:

$(11-1)!!!!!!!-1=10\times3-1$

JMP
  • 35,612
  • 7
  • 78
  • 151
  • 13
    ... I don't think that's how factorial works. I'm very sure that is not how factorial works. – Allan Cao Feb 28 '19 at 08:43
  • 11
    @AllanCao I believe JonMark Perry is using extended factorial functions. For example, a double factorial is defined to be $n(n-2)(n-4)(n-6)...(3)(1)$ if $n$ is odd, and $n(n-2)(n-4)(n-6)...(4)(2)$ if $n$ is even. If we're calculating a triple-factorial, that evaluates to $n(n-3)(n-6)(n-9)...$. In the case of $(11 - 1)!!!!!!!$ (a seven-factorial), it simplifies like this: $(11 - 1)!!!!!!! = (10)!!!!!!! = (10)(10-7) = (10)(3) = 30$ – user46002 Feb 28 '19 at 08:50
  • 2
    I see. Since they aren't really factorial (and kind of cheating/cheap), the solution for 6 and 4 don't work. – Allan Cao Feb 28 '19 at 16:51
  • 1
    multi-factorial, but in most 24-type games they are considered to be a big cheat!!! mind you, so is (1+1).concat(11-1-1). @AllanCao – JMP Feb 28 '19 at 17:07
  • 2
    Which is why the concatenation is only for the original digit. – Allan Cao Feb 28 '19 at 17:18
8

According to my analysis, there is no solution using less than 7 digits. The proof would require an exhaustion of every possible operation from 29, reducing the dimensionality of the problem one digit at a time, like a tree. I haven't followed all the leaves of the tree, but it seems clear no one leads to a solution.

To see how my logic works, consider an example:

$29 + 1 = 30$

Here we have a sub problem, which is to find a way to get to 30 using 5 or less digits. You can then follow the leaves of the tree, reducing the dimensionality one at a time, until you see there is no solution. For example, 30 + 1 = 31, and finding 31 from 4 digits, etc. Or 30 + 11 = 41, and so on.

Importantly, many of the branches of the original problem are identical. For example, $29 + 1 = 30$ is the same as $29+1! = 30$; and the subbranch above $30 + 1 = 31$ is exactly the same as $29+(1+1) = 31$ and $29+(1+1)! = 31$.

Same logic applies to, for instance, $29-1=28$. You need to get to 28 using 5 digits. Following the branches seem to lead to nowhere.

Some routes are evidently discarded. For instance, 11! = 39916800, too high. Would need to be scaled with a relatively high number, like 111. But that uses 5 of 6 digits. No way to use the last one meaningfully. Same logic with 111! or other like (11-1)! Other routes, like (1+1+1)!=6, requires you to produce 23 (so 23+6=29) with only 3 digits. Impossible.

No idea why you would ever consider square root as a relevant operation. Temptation here is that somehow a squared root times a natural number ($\sqrt{a}b$) will give a natural number. However, this is only true if $ab^2$ is itself the square of a natural number. So you should start by searching for the latter. For example, take 36. It's the square of 6. Can you find natural numbers a and b such that $ab^2=36$? Yes, a=4 and b=3, or a=9 and b=2. But these use too many digits. Follow down the tree and you are done very quickly. What about a=11? It can be seen that it is not possible to find a natural number b such that $\sqrt{11b^2}$ is a natural number.

The above applies the same with division, e.g. $\frac{\sqrt{a}}{b}$ or $\frac{b}{\sqrt{a}}$ routes.

I haven't given you any proof of my claim and I might be totally wrong. But my methodology (reducing the dimensionality of the problem one at a time) led me to nowhere.

luchonacho
  • 323
  • 1
  • 2
  • 12
  • 3
    My solution for 7 digits uses a square root quite nicely. – Amorydai Feb 28 '19 at 15:15
  • @Amorydai True. I did overlook something like $\sqrt{a+b}$, focusing instead only on multiplicative forms, like $\sqrt{ab}$. I just had another go from derivations of yours, and it seems impossible to reduce it 1 digit. I could be wrong! As I said, I cannot offer proof, only failed trials. I do not want to go down every possible branch of the tree, even though it is possible. – luchonacho Feb 28 '19 at 16:49
  • The only cases where $\sqrt{a}b$ is a natural with both $a$ and $b$ natural are when $a$ is already a square, or when $b=0$. – user2357112 Feb 28 '19 at 18:25
  • 4
    Your "reducing the dimensionality one at a time" logic fails to account for the possibility of combining two expressions that both use more than one digit. For example, $(1+1+1)(1+1+1)$ cannot be decomposed into a 5-digit expression and a 1-digit expression. – user2357112 Feb 28 '19 at 18:26
  • @user2357112 True, but to the extent that these expressions have to be multiplied or added to other terms in order to reach 29, they are covered in my examples. For instance, your example gives a 9. That is precisely one of my examples, where $a=9$ and $b=2$. In case of addition/substraction, you still need to get to 20 (29-9) or 38 (29+9) using the remaining digits. – luchonacho Mar 01 '19 at 09:02
3

I can get an answer accurate to within 0.12% with six 1s:

$$\sqrt{\sqrt{\sqrt{11^{11}}}}+1+1 \approx 29.0343$$

jasonharper
  • 1,005
  • 8
  • 14
2

Lowest I managed so far is 9 digits:

  • (1 + 1 + 1 + 1)! + 1 + 1 + 1 + 1 + 1;

  • 11*(1 + 1 + 1) - (1 + 1 + 1 + 1)

Some other ways I came up with:

  • (1 + 1)^(1 + 1 + 1 + 1 + 1) - 1 - 1 - 1 (10 digits)

  • (1 + 1 + 1 + 1 + 1)!/(1 + 1 + 1 + 1) - 1 (10 digits)

  • (1 + 1 + 1 + 1 + 1)^(1 + 1) + 1 + 1 + 1 + 1 (11 digits)

  • 11*(1 + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1 (11 digits)

Harshith Rai
  • 1,064
  • 6
  • 12
simonzack
  • 475
  • 2
  • 13
2

This was posted before the question was edited to demand an integer, and requires that the rules accept rounding, but it does produce the digits 29. Six is achievable in this way:

$\sqrt{( ( 1 + 1 + 1 )! + 1 )} * 11 \approx 29.1033$

a sandwhich
  • 574
  • 3
  • 7
  • 2
    Interesting approach to the question but an exact answer is required. – Allan Cao Feb 28 '19 at 07:25
  • You could fix it with the floor: $\lfloor\sqrt{( ( 1 + 1 + 1 )! + 1 )} * 11\rfloor = 29$ – Dr Xorile Mar 01 '19 at 00:11
  • Floor can't be used. As well, I just assumed that people would take 29 as exactly 29 not around 29. – Allan Cao Mar 01 '19 at 05:57
  • Well, as the problem originally stated "make 29" without an explicit restriction to an exact integer result, asking on a puzzling site where people enjoy posting creative/stretch answers will bring one to accept such responses. Before the restriction was imposed, the multiple definitions of "make" might not rule out extra digits appearing. – a sandwhich Mar 02 '19 at 00:33
1

For the sake of completeness, here's an 8 digit solution:

(1+1+1)^(1+1+1) + 1 + 1

kwypston
  • 511
  • 2
  • 5
0

11+11+11-1-1-1-1=29 This is my best guess.

rhsquared
  • 9,220
  • 3
  • 31
  • 52