Making any integer with four 2s
eli.thegreenplace.net
eli.thegreenplace.net
Ex, the gamma function is (n-1)! So now you're making 7 with four twos and a one. You've broken the spirit.
If I can hide numbers in a function call... It's trivially easy to always succeed.
Onetwothreefourfive()-2+2-2+2+, - (both binary and unary), ×, ÷ are functions, as is raising to a power. Why would you allow them?
As always in this kind of things, one can disagree about what constitutes an elementary function, but I don’t think taking square roots should be disqualified in this puzzle.
> Ex, the gamma function is (n-1)!
And 2 is just S(S(0)) (https://en.wikipedia.org/wiki/Peano_axioms)
> If I can hide numbers in a function call... It's trivially easy to always succeed.
I wouldn’t call the construction given by Paul Dirac trivial. Do you think it is, or do you know of a simpler one?
It's still a fun puzzle, it's just based more on our shared notational conventions as much as the underlying math.
Yes? It's doing exactly the thing that your parent comment complains about in the gamma function, introducing additional constants (in this case, mostly 2s) that, for no particular reason, don't count.
Why would you interpret squaring as consuming a 2, but square rooting as not consuming a 2?
This is a good example of why you need rules on which functions are allowed. Repeated application of the successor function makes the entire exercise trivial
Though I also think square root is cheating, it has an implicit 2 inside of it, where as raising to the power of 2 and log 2 are explicit.
You could also argue for only infix operators.
A good game must be somewhat challenging or else it is not really a game. Anything that makes the game trivial ought be omitted for it to be a game.
If I think of a competition, then I'd expect the rules to be determined ahead of time according to some pre-imagined criteria. If someone manages to find a clever hack within the rules that allows for trivial "breaks", then that's good for them and they just get to beat everyone else at it.
But if I think of a game, then it's much more natural for the rules to adapt over time as people realise that some types of "play" make the game less fun, or straight-up boring. They don't have to be self-consistent, or logical. They're essentially arbitrary, and just whatever they need to be to make the game "better".
So perhaps the implied rule is not about it being "reasonable, elemental", but rather about "common" functions and operands (yes, it's still a can of worms, and you'd need to be explicit about what that is).
Well, depends on how you define seldom. What if I told you that twitter would break without the use of Succ()? :-)
> it's still a can of worms
;-)
Where do you draw a line between "Functions available on a 4-function calculator" and "Functions I can make up specifically to generate a target integer"? I think you have to rigidly define this, or the game loses meaning.
Maybe the rule should be that the function has to be invented before the inventor has knowledge of this game. But now I'm just going through /usr/bin looking for binaries where the 2222th byte is 0x7.
But you're all missing the point. A winning "solution" to this game is whatever the reader accepts as a legal solution which at the same time is as creative as possible. That's necessarily subjective, but that's fine. Anybody is free to argue that it's a stupid game if these are the rules, and those folks just don't need to play and can let everybody else have some fun!
Granted there is creativity in this sort of game -- indeed, most "games" in life are like this -- but it's quite a different thing from winning a game with clearly defined rules like chess, or this game with the set of allowed operations specified up front.
(Mostly goes to show that it's really hard to be precise and allow some mathematical language and disallow some)
Logs would also need to state the base. No implicit use of e or 10, and lg wouldn't be allowed in place of log2.
I haven't said much other than logs and roots are binary operators with one of the operands usually implicit in the notation, so if we don't have special notation for powers and exponentiation, then we shouldn't allow the same for their inverse operations.
Why is it ok to use "22" = 2 * 10^1 + 2 (when it could be a number in base 3 — 2 * 3^1 + 2 = 8 decimal — or any other base)? This implies base 10, just like root implies base 2, or ln means e.
As I said, this is a game, and trying to imply certain artificial constraints will be really hard with how abstract maths is.
Again, mention of successor function is apt: everything else is built from 1, succ() and another axiom, definition or so. So everything else can be reduced to this.
Successor is essentially s(n) = n + 1, so that shouldn't be allowed either.
Successor simply "is" (it's a relation that satisfies a number of conditions), and summation is defined in terms of successor function.
My point is that you can really define everything in terms of these primitive definitions, which means that there won't be any single use of a non-2 digit for any function, or you'll be going with a set of arbitrary allowances.
But the whole point should be: what are those arbitrary constraints that make the game fun? And once you clear that bar, it's ok to open up the next one (this does not make them non-arbitrary though).
Basically, I am saying your take at those arbitrary decisions is not a very fun one ;-)
Letters are symbols used to write down words of a natural language.
If you are unfamiliar with a language, you are more likely to call them "symbols" instead of "letters".
That's not the whole story of course, you still need to agree on the set of allowed operations, but I think it makes a big difference even though it seems incidental at first.
I agree that you need to define and agree upon a finite set of allowed operations before playing the game. IMHO, square root, logarithm/exp, floor/round/ceiling, sin/cos/tan ought to be included in the list. But that's just like, my opinion, man.
They also say “mathematical tools” not arbitrary functions.
A + B = Succ(Succ(Succ(...Succ(A))))
So using your own argument, we could say that using '+' is simply a convention on how we can write down the above — if we insist on spelling "conventional" things out, we must be able to use the underlying elementary function[]. Or isn't a factorial n! really n(n-1)...21, so all those numbers spelled out?The mathematical root probably first appeared as a square root and was later extended to support other exponents.
But is there any fun in this? As noted elsewhere, the game is in finding the rules, and a solution within those rules.
[]Since all the natural numbers other than 1 are defined using a Succ() functions, there's a trivial solution. But if we only limit ourselves to this most elementary operation, we can't get a 1 because that's an axiom in itself ("There exists 1" or "There is a set of cardinality 1").
A + 0 = A (or A + 1 = Succ(A), if you insist 0∉ℕ)
A + Succ(B) = Succ(A) + B A + 0 = A
A + Succ(B) = Succ(A + B)
They would all be proven in the same manner, though some might be slightly stronger in relation to commutation, making some proofs easier off the bat.Yeah this feels like those "Implemented XYZ in 1 line"
import XYZWonder if someone could come up with general solution within these constraints.
This may be easier to see in a stack machine / RPN model. An expression is a list of operations, drawn from a finite set, each of is either “push the number 2” or something that decreases the stack size by at least 1. And you need exactly 4 pushes. So a valid expression has four pushes and at most 3 other operations, because otherwise the stack would underflow. This gives a finite number of possible expressions, but there are an infinite number of integers, so it can’t work.
Not with only four inputs you can't. You can only have three operations, because you have no way of getting another input parameter.
And yes I think your analysis that only allowing n-ary funcs with n>=2 would make general solution very much impossible since you can only have a limited number of inputs.
My reasoning is (I'm pretty sure it's the same as yours), why is the gamma function allowed, but not others? I could insert arbitrary functions to make the game arbitrarily solvable.
While this hit me at the Gamma introduction, I think it leads back to the beginning: It's a poorly defined problem from the rules at the start of the article. It should instead define the set of allowable functions (or operations) explicitly. I think you could modify this to retain the intent of showing how the problem scales with knowledge level.
BUT I did not use "44", which I did see in some solutions. That seemed out of bounds to me!
Maybe. But I doubt many people are aware of such functions, so it's still a fun challenge.
It's a little "brain teaser" game, to encourage kids to practice fairly basic math. Don't take it too far out of context.
2 + 2 + 2 + floor(sqrt(2))
Which feels at least more in the spirit of the challenge than gamma.
Okay, then this is easy, just use the successor function.
S(n) = n+1
6 = 2*2*2-2
7 = S(2*2*2-2)
8 = S(S(2*2*2-2))
Etc. fac(n) = n * fac(n-1) n>0
= 1 n=0https://en.wikipedia.org/wiki/Peano_axioms
It's probably something that only folks who study the foundations of mathematics would know.
You may have also heard about it if you learned about Gödel's incompleteness theorems, or read Gödel, Escher, Bach
A natural number is either zero or a successor of a natural number.
Addition is defined as a recursive application of successor functions.
m + 0 = m,
m + S(n) = S(m + n).
as an example -- 3 + 2:S(S(S(0))) + S(S(0)) = S( S(S(S(0))) + S(0) ) = S( S( S(S(S(0))) + 0 ) ) = S(S(S(S(S(0)))))
There's nothing really in the definition of the successor function that necessarily requires that it's interpreted as n+1, though. It's just an interpretation from the context in which it's used. It could represent any operation as long as it is isomorphic to adding one -- but there's nothing special about "adding one". You could have it represent multiplying by a constant, and interpret "zero" as the number one.
So a number in this interpretation is either 1; or 2 times a natural number.
1, 2, 4, 8, 16, 32 -- you're working only with powers of 2 now.
The above "addition" rule above still works, but now it represents "multiplication" instead of addition. I'll replace all the S's in the above example with x2
2x2x2x1 "+" 2x2x1 = 2x(2x2x2x1 + 2x1) = 2x(2x(2x2x2x1 + 1) = 2x2x2x2x2x1 = 32
So now, instead of addition, we've recursively defined multiplication where the successor function is interpreted as multiplying by 2. There's an infinite number of ways that you can interpret the successor function.
So basically, I do think it's cheating, and if you do want to define it as n+1, it would be even simpler to just define a function that takes any number to the desired output.
This may have been the fault of math education. In my college people learn real analysis (constructing the real numbers) before they learn to construct the natural numbers, which is backwards to me. I recommend learning it: constructing the natural numbers from just sets in the tradition of Zermelo–Fraenkel is mind blowing the first time you see it. Of course you could just use Peano axioms without touching set theory too.
The appendix (written for the book in 2011) points out an earlier (1962) 1.5-page paper π in Four 4's by J. H. Conway and M. J. T. Guy, written when they were students at Cambridge, that has a similar idea: https://archive.org/details/eureka-25/page/18/mode/1up?view=...
For example,
5 = ⌊√√√√√(4!)!⌋
because 24! lies between 5^{32} and 6^{32}.It could be the phenomenon of the author's cognitive bandwidth being consumed by everything in the article, including each argument, the overall argument, the writing, the formatting, etc. etc., and with time pressures. The critic can focus at their leisure on one point, with bandwidth to spare - and so it's obvious! :)
I wasn't criticizing him for this, but rather fascinated that this is the variant that was chosen.
12 = 2 * (2+2+2)
Is a hell or a lot simpler than using complex numbers. Might be a different example for that would have been better.
Or put differently: N = sqrt(N^2) or sqrt(N * N) for every positive N, but x = sqrt(x + x) or sqrt(x + 2) is only true for x = 2 for both or x = 0 for the first representation.
2^2 -> 2*2 -> 2+2
2^3 -> 2*2*2 -> (2+2)+(2+2)
N^2 == N*N != N+N
More generally "unwrap" is being used as inlining the recursive hyper operation once more: https://en.wikipedia.org/wiki/Hyperoperation
I made a stack machine with single character instructions and needed to solve a variation of this problem. I had just the digits 0 through 9. The characters '23' would be push 2 followed by push 3. To actually represent the number 23 you would use
45*3+
or something similar.
That left me with the problem of how to encode each integer in the fewest characters.Tools at hand.
The digits 0 through 9
'P': Pi
'*': (a * b),
'/': (a / b),
'-': (a - b),
'+': (a + b),
's': sin(a),
'c': cos(a),
'q': sqrt(a),
'l': log(a),
'~': abs(a),
'#': round(a),
'$': Math.floor(a),
'C': clamp(a),
'<': min(a, b),
'>': max(a, b),
'^': pow(a, b),
'a': atan2(a, b),
'%': positiveMod(a, b),
'!': (1 - a),
'?': (a <= 0 ? 0 : 1)
'o': a xor b scaled by c; ((a*c) xor (b*c))/c
'd': duplicate the top stack entry
':': swap the top two stack entries
';': swap the top and third stack entries
I have wondered about revisiting the stack machine with a complex number stack to see what I can come up with.(Next time I post something like this I am not going to use my phone)
Which gives you a finite problem. The VM cannot loop or define functions (yet, anyway) so it doesn't go all busy beaver on you.
In a similar vein I had wondered about a kernel function that read from a buffer with a 3x3 kernel on the stack.
Perhaps I should revisit the idea. Using a stack with multiple lanes of floats would potentially richer operations, colors, complex numbers, quaternions? 4 lanes could potentially Even storing the top value of the stack at the base for the next frame. Or, (new idea) a cyclic buffer stack of a fixed length. That wouldn't require any memory management at render time, and could persist multiple values just by popping them off.
I'm not sure how that would impact the speed. At the moment the stack expressions are converted into JavaScript expressions for the JIT to make fast. I'd have to go back to requiring an actual stack again.
It looks like OP's language is not Turing complete. It always terminates. You can just do a breadth first search on the program space. The first program you get that outputs the number you want is the shortest program.
If it were Turing complete, you can't do this, because eventually you'll find a program that just keeps running for like a really long time. Is it running because the program never halts? Or is will it halt eventually and output the number you want? You can't know for sure.
One small wrinkle, if you ignore the fact that the root notation conceals exponentiation by 1/2, by making that common value a default.
That's a lot of hidden 2's!
Given the prevalence of quadratic polynomials over higher-order ones, sqrt does feel somewhat more fundamental than arbitrary exponentiation.
Lots of people have pointed out the farcity of the game after allowing fancy functions, but IMHO, there is a lot of fun in just finding satisfying solutions, without the need for specific rule limitations.
So yes, the notation conceals something: its default value.
Et cetera ad infinitum...
So, if you want to say that sqrt(x) has a hidden parameter, you're just making an arbitrary claim unless you accept it is concealing an unbounded number of hidden parameters.
Or we can just do the obvious thing and say that sqrt(x) has one parameter.
[0]:https://googology.fandom.com/wiki/Fast-growing_hierarchy
So I used a SAT solver to find a combination of numbers, not using prohibited bytes, that add up to the number I really want.
https://docs.google.com/presentation/d/19K7SK1L49reoFgjEPKCF...
It was a lot of fun, you tend to develop strategies and the game has a simple, efficient UX. Fair warning, it is very time consuming.
[0] https://apps.apple.com/fr/app/tchisla-number-puzzle/id110062...
That's how I learned about false induction. I also liked the one about the men who were lined up and had something on their backs and they had to guess what it was.
The Definitive Four Fours Answer Key https://dwheeler.com/fourfours/
> Note that these are large files; both are over 1.6 Megabytes, so don’t load these if you have a slow Internet connection
Just shows how far internet speeds have come...
128 = √(2 / √√(√2 - (2 / √2)))
8192 = √√(2 / ((√2 * √2) - 2))
16384 = (2 / √√(√2 - (2 / √2)))
67108864 = √(2 / ((√2 * √2) - 2))
134217728 = (2 / √(√2 - (2 / √2)))
4503599627370496 = (2 / ((√2 * √2) - 2))
9007199254740992 = (2 / (√2 - (2 / √2)))
6369051672525773 = (√2 / (√2 - (2 / √2)))
I found these by accident a long time ago but kept them because they do "work". Try to input one expression in the lil box in https://www.wolframalpha.com/?source=nav and they will quickly evaluate to these values; the charade goes away after you press Enter and get the (mathematically) correct answer.My old solvers from what feels like a previous life: https://madflame991.blogspot.com/2013/02/four-fours.html https://madflame991.blogspot.com/2013/02/return-of-four-four...
That was fun
√2 - 2/√2 as a float64 is exactly equal to 2^{-52}
√2 * √2 as a float64 is exactly equal to 2 + 2^{-51}
and all other calculations after that are mathematically exact. For example: √(2 / √√(√2 - (2 / √2))) := √(2 / √√(2^{-52})) = √(2 / 2^{-13}) = 2^7 = 128
and √√(2 / ((√2 * √2) - 2)) := √√(2 / 2^{-51}) = √√(2^{52}) = 2^{13} = 8192
In your last one, 6369051672525773 = 2^{52} * 1.4142135623730951454746218587388284504413604736328125
(https://float.exposed/0x4336a09e667f3bcd) where the second value is the exact value of the floating-point representation of √2 (i.e. the closest representable-in-float64 value to √2)."The Strangest Man": https://en.wikipedia.org/wiki/The_Strangest_Man
Four Fours: https://en.wikipedia.org/wiki/Four_fours :
> Four fours is a mathematical puzzle, the goal of which is to find the simplest mathematical expression for every whole number from 0 to some maximum, using only common mathematical symbols and the digit four. No other digit is allowed. Most versions of the puzzle require that each expression have exactly four fours, but some variations require that each expression have some minimum number of fours.
> What about radix epi*i, or just e?"
At any rate they invented algebra so maybe there's something to it
Edit: It was the man who counted, definitely apocryphal, as it was written in the 20th century
but in this case there is a unsolved gap!
This is the Curse of Knowledge. OP stared too long into the abyss.
https://en.wikipedia.org/wiki/Superior_highly_composite_numb...
7 = (2+2)#+2/2
https://en.wikipedia.org/wiki/PrimorialI solved the puzzle for 1-10 before looking at the answers, and this was my solution for 7:
⌊√222⌋/2
or more readably:
floor(sqrt(222)) / 2
ceil(2.2)+2+2
All those are allowed, so what's the problem?
Getting to 7 is notoriously difficult
What am I missing?2 * 2 * 2 - 2/2
7 = 2/2 + 2 + 2 + 2
Then you just add it multiple times
And if 0 is an integer.
2/2-2/2