Rendered at 11:06:46 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
hahajk 16 days ago [-]
i know everyone plays with their own rules, but from my perspective, a square root spends a 2 - it's not an operator like + or ! . there's an implicit "2" since you could also take the cube root or fourth root
jjmarr 16 days ago [-]
You can use `sin(arctan())` as the repeatable operator instead of sqrt(). Then "unwrap" by applying ^-2 - (2^-2)
Though it really depends which definitions you find more fundamental.
Still, exp and log seem like good choices.
JadeNB 15 days ago [-]
> There's a 2 in the definition of sin :-)
How?
shiandow 15 days ago [-]
sin(x) = (e^ix - e^-ix) / 2i
Personability 15 days ago [-]
That's more an identity than a definition.
shiandow 15 days ago [-]
Depends on your perspective I suppose. It's one of the simpler ways to define it for complex numbers.
JadeNB 14 days ago [-]
I think the series \sum_{n = 0}^\infty 1/((2n + 1)!)x^{2n + 1}, to which the definition in terms of exponentials reduces, is about equivalently simple, but, sure, it has a 2 in it (several 2's in it!) too.
anthk 16 days ago [-]
Keep it simple.
2^2 - (2 / 2).
olmo23 15 days ago [-]
2 + 2 - (2/2).
schiffern 16 days ago [-]
Perfect answer, I hate it :)
JumpCrisscross 16 days ago [-]
> it's not an operator like + or !
Squaring is to multiplication as is the latter to addition. If roots are invalid then so should be multiplications.
penteract 16 days ago [-]
Exponentiation is to multiplication as multiplication is to addition. Squaring is to multiplication as doubling is to addition.
jolmg 16 days ago [-]
> Squaring is to multiplication as doubling is to addition.
as halving is to addition.
penteract 16 days ago [-]
Square rooting is to multiplication as halving is to addition.
13 days ago [-]
SamBam 16 days ago [-]
GP didn't say roots are invalid, just that they burn a two.
If we agree that 2^2 uses two twos (and, indeed, that 2^3 isn't valid, because it uses a 3), then what's the equivalent of a square root?
Of course to my simple math brain, a square root is ^1/2, which includes the digit 1. But I agree there is someone 2-ish about the square root.
direwolf20 16 days ago [-]
It can be written as ²√2 and there's also ³√2 and so on
schiffern 16 days ago [-]
Yep.
It would be like if we had a stylistic convention that you can drop the second number in an addition and it becomes 1. So "6 +" means "6 + 1."
Now I can trivially make any number, but I'm just 'exploiting' a convenience feature in the notation:
0 = 2 + 2 - 2 - 2
1 = 2 + 2 - 2 - 2 +
2 = 2 + 2 - 2 - 2 + +
Etc
16 days ago [-]
danparsonson 16 days ago [-]
Would you elaborate on that? That doesn't make any sense to me
drfloyd51 16 days ago [-]
Multiplication is repeated addition.
2x3= 2+2+2
AxB= A+A B times.
Raising to a power is repeated multiplication.
2^3= 2x2x2
A^B = AxA B times
Roots are the inverse of powers
Division is the inverse of multiplications.
Given this… the OC’s comment about giving exceptions to powers in the rules is nonsense because they are still operations.
mojomark 16 days ago [-]
Multiplication is not the same as repeated addition, which you can observe as soon as you try the two different operations on fractions or negative numbers. For example, you can't add a number to itself 1/3 times, but you can certainly scale a number by 1/3.
Multiplication is a scaling operation.
reichstein 16 days ago [-]
Multiplication is the generalization of repeated addition. Repeated addition can be generalized to fractional values.
In the integers, it is the same thing, with a rule for negative times.
In the rational numbers, you can generalize to adding a number to itself a rational number of times. Adding a/b to itself p/q times is defined as adding a to itself p times, with a divisor that is adding b to itself q times.
So adding the rational 5 (5/1) with itself 2_and-1/3 (4/3) times just means (5+5+5+5) / (1 + 1 + 1) = 20/3, a rational that we can also write as 6
-and-2/3. Only addition of integers is used.
Which is the same as rational multiplication (a/b)(p/q) = (ap)/(b*q).
But it's true that you can't say that rational multiplication is the same as _integer_ repeated addition.
goodmythical 16 days ago [-]
Can you not? 9+(9(1/3)) [adding nine to itself a third of a time] is nine plus one third of nine {or nine divided by three} which is one of the three in three times three that equals nine which is three therefore 9+(9(1/3))=11 because 9+3=11
mojomark 16 days ago [-]
By dividing by 3 you are introducing a scaler into the operation.
Multiplication also flips signs (direction). That's why a negative * negative = positive, whereas a negative + negative = negative. The addition operator does not flip direction.
Multiplication is not generally the same as multiple addition operations. However, it has the same result for positive whole numbers.
I am not writing this to flippant. I'm a 40-something year old engineer and I litterally thought the same thing until a year ago-ish. I was trying to build a function (I can't recall what exactly) for a project and I said, well instead of multiplying these terms (which wasn't efficient for what I was doing or something), I'll just cycle through and add the terms X-number of times. ChatGPT said "uh, no, that's not the same thing," to which I said NFW and proceeded down a deep rabbit hole on the difference. I'm glad I did because I also now have a much better intuition for imaginary numbers, which I was severely lacking before.
red369 16 days ago [-]
:)
I like it when people who are clearly smart do things like this! Makes me feel better.
Because it's just wrong. hahajk said that taking the 2nd root spends a 2, not that "roots are invalid". (FWIW, I'm not necessarily endorsing the view that the square root symbol implicitly spends a 2, I'm just saying that the counterarguments given are logically wrong ... actually more like semantically wrong.)
The comment below by drfloyd51 is similarly wrong ... hahajk didn't say anything about "giving exceptions to powers in the rules".
And the comment by speglt is also wrong:
> If taking a square root is an inherent use of a two, then dividing a number by another number should also be a use of a two, because there are two operands.
The number of operands isn't relevant; the degree of the root is.
And from SideQuark we get
> One could even claim division is raising to the -1 power, thereby disqualifying it in exactly the same manner you disqualify sqrt.
But hahajk said nothing about anything being disqualified. (Not to mention that division is not raising to the -1 power ... raising what? n/d = n * d^-1, but this is completely irrelevant to hahajk's argument.)
spieglt 16 days ago [-]
Multiplication is adding numbers to themselves. Exponentiation is multiplying numbers by themselves. Ditto division/taking roots. Squaring a number is just the instance of exponentiation that happens to have two operands. If taking a square root is an inherent use of a two, then dividing a number by another number should also be a use of a two, because there are two operands.
Biganon 16 days ago [-]
Yes, taking the nth root is an operator. Taking the SQUARE root is this operator with the operand 2, which is usually graphically omited. I totally agree with the top comment: it's burning one of the 2's.
jibalt 15 days ago [-]
The obvious counterargument is that the problem statement is
> Given exactly four instances of the digit 2 and some target natural number, use any mathematical operations to generate the target number with these 2s, using no other digits.
and the square root symbol is a mathematical operation and is not a digit. That it is equivalent to taking the 2nd root isn't relevant ... the whole puzzle is about finding and using equivalents.
ta2345fa59be 16 days ago [-]
Or use the successor operator.
SideQuark 16 days ago [-]
Alternatively, one can claim sqrt is a single symbol, and there are extensions requiring a digit. Log, ln, also have hidden bases, but they’re also valid symbols. Cos/sin may be in radians or degrees, both in common use, and no real place to denote it.
One could even claim division is raising to the -1 power, thereby disqualifying it in exactly the same manner you disqualify sqrt. I’ve never seen sqrt with a 2 index; power -1 is seen quite often for division.
Go figure….
Someone 16 days ago [-]
It’s true cheating, but if you assume the Peano axioms, you can write any integer with one zero without having to resort to complex functions such as √. For example (if I didn’t miscount the S-es or parentheses),
S(S(S(S(S(S(S(0)))))))) = 7
rav 16 days ago [-]
You don't even need zero in that case, you can use the fact that 2 - 2 = 0 to use the four 2s:
S(S(S(S(S(S(S(2+2-2+2)))))))) = 7
...which is essentially the same as Dirac's general solution (which also derives a "successor operator" akin to S that doesn't spend any numeric literals).
EDIT: I realize that this was already posted in a comment by
shoo several hours ago.
vessenes 16 days ago [-]
You’ve got S(4) in the center there
jasomill 16 days ago [-]
From the text, the inner term was clearly intended to be "2-2+2-2".
vessenes 15 days ago [-]
I agree!
16 days ago [-]
adas0693 16 days ago [-]
there is a related problem (inspired by an interview questions from ITA software, a part of Google now) that asks to find the smallest positive integer that cannot be expressed using a digit K (in [2,9]) N times in an expression that involves the four basic arithmetic operations and the parentheses: +, -, *, /, (, and ).
to make the problem more interesting, the list of operations can be extended to include exponentiation and concatenation.
for example, using the four basic operations for N=4, and K in [2,9], we get:
7 cannot be computed in 4 2s;
11 cannot be computed in 4 3s;
10 cannot be computed in 4 4s;
8 cannot be computed in 4 5s;
9 cannot be computed in 4 6s;
4 cannot be computed in 4 7s;
5 cannot be computed in 4 8s;
4 cannot be computed in 4 9s;
catlifeonmars 16 days ago [-]
This feels very suspiciously like a finite field problem.
genter 16 days ago [-]
Are you allowed to brute force it?
argee 16 days ago [-]
That's how you do it right? It's a BFS with 4 being the max depth, and you print whatever numbers in the problem set which you didn't find.
twoodfin 16 days ago [-]
Given the problems ITA solved, thinking about the question that way makes perfect sense.
dooglius 16 days ago [-]
Figuring that out is presumably part of the interview (and would depend on N)
A recent IOCCC entry solves a related game of making integers out of variable number of constants (e.g. make expression using only "2" and basic operations, but any number of "2" can be used as opposed to always four):
I had a teacher in middle school who would assign a version of this over winter break with the digits of the new year. I had a lot of fun with it in 1996. Sad to think she must've stopped in 2000...
bajard 16 days ago [-]
22 is cheating because 22 = 2*10+2 is arbitrary in base 10. If you write 22 in some base, you have to write the base, and that's an extra number.
teo_zero 16 days ago [-]
Never understood why 7 is considered difficult...
7 = ⌈ 2.2² + 2 ⌉
anthk 16 days ago [-]
(2 << 2) - ( 2 / 2)
blueblock 16 days ago [-]
Rounding spoils the fun of the puzzle.
nostrademons 16 days ago [-]
It seems very much in the spirit of allowing concatenation and square roots...
jtari3333 16 days ago [-]
Rounding is a completely valid mathematical operation.
16 days ago [-]
AnimalMuppet 16 days ago [-]
It is difficult when the rules do not allow exponentiation.
There's a direct trivial solution for any natural number using the successor function S(a) = a + 1 from Peano arithmetic.
Encode 0 as 2 + 2 - 2 - 2 then apply S a times to that 0.
Only depends upon natural numbers & Peano stuff, no need for construction of rationals, irrationals, logarithms, etc.
edflsafoiewq 16 days ago [-]
This and Dirac's trick are both writing the number in unary. Is there a way to write it with o(n) symbols?
shoo 16 days ago [-]
That's a fun question.
If we're allowed to introduce our own operators, we could concoct something like decimal notation
a . b := 10a + b
So we could write 90210 as 9 . 0 . 2 . 1 . 0 = S(S(S(S(S(S(S(S(S(0))))))))) . 0 . S(S(0)) . S(0) . 0
That doesn't quite work as it still depends upon a bunch of literal zeros. We could replace 0 with an operator Z() := 0, but that seems to be very much against the spirit of the challenge.
We could rewrite our ersatz decimal expression to only require a single zero & then evaluate a vector of functions f : N -> N across that zero, resulting in a vector of natural numbers, then reduce that vector to a single number with our `.` decimal notation operator.
Let M(fs, x) := (fs_1(x), ..., fs_n(x))
Let R(x) := x_1 . x_2 . ... . x_n
90210 = R(M((SSSSSSSSS, Id, SS, S, Id), 0))
the number of symbols to write a d-digit number this way is bounded by 10 + 10d = 10 + 10log_10(n)
Is this cheating / against the spirit of the challenge? Perhaps!
3=(sin(arctan(sin(arctan(sin(arctan(2))))))^−2 − (2)^−2
Though it really depends which definitions you find more fundamental.
Still, exp and log seem like good choices.
How?
2^2 - (2 / 2).
Squaring is to multiplication as is the latter to addition. If roots are invalid then so should be multiplications.
as halving is to addition.
If we agree that 2^2 uses two twos (and, indeed, that 2^3 isn't valid, because it uses a 3), then what's the equivalent of a square root?
Of course to my simple math brain, a square root is ^1/2, which includes the digit 1. But I agree there is someone 2-ish about the square root.
It would be like if we had a stylistic convention that you can drop the second number in an addition and it becomes 1. So "6 +" means "6 + 1."
Now I can trivially make any number, but I'm just 'exploiting' a convenience feature in the notation:
0 = 2 + 2 - 2 - 2
1 = 2 + 2 - 2 - 2 +
2 = 2 + 2 - 2 - 2 + +
Etc
2x3= 2+2+2 AxB= A+A B times.
Raising to a power is repeated multiplication.
2^3= 2x2x2 A^B = AxA B times
Roots are the inverse of powers
Division is the inverse of multiplications.
Given this… the OC’s comment about giving exceptions to powers in the rules is nonsense because they are still operations.
Multiplication is a scaling operation.
In the integers, it is the same thing, with a rule for negative times.
In the rational numbers, you can generalize to adding a number to itself a rational number of times. Adding a/b to itself p/q times is defined as adding a to itself p times, with a divisor that is adding b to itself q times.
So adding the rational 5 (5/1) with itself 2_and-1/3 (4/3) times just means (5+5+5+5) / (1 + 1 + 1) = 20/3, a rational that we can also write as 6 -and-2/3. Only addition of integers is used.
Which is the same as rational multiplication (a/b)(p/q) = (ap)/(b*q).
But it's true that you can't say that rational multiplication is the same as _integer_ repeated addition.
Multiplication also flips signs (direction). That's why a negative * negative = positive, whereas a negative + negative = negative. The addition operator does not flip direction.
Multiplication is not generally the same as multiple addition operations. However, it has the same result for positive whole numbers.
I am not writing this to flippant. I'm a 40-something year old engineer and I litterally thought the same thing until a year ago-ish. I was trying to build a function (I can't recall what exactly) for a project and I said, well instead of multiplying these terms (which wasn't efficient for what I was doing or something), I'll just cycle through and add the terms X-number of times. ChatGPT said "uh, no, that's not the same thing," to which I said NFW and proceeded down a deep rabbit hole on the difference. I'm glad I did because I also now have a much better intuition for imaginary numbers, which I was severely lacking before.
I like it when people who are clearly smart do things like this! Makes me feel better.
Reminds me of this story: https://news.ycombinator.com/item?id=5663709
Learn logarithms.
The comment below by drfloyd51 is similarly wrong ... hahajk didn't say anything about "giving exceptions to powers in the rules".
And the comment by speglt is also wrong:
> If taking a square root is an inherent use of a two, then dividing a number by another number should also be a use of a two, because there are two operands.
The number of operands isn't relevant; the degree of the root is.
And from SideQuark we get
> One could even claim division is raising to the -1 power, thereby disqualifying it in exactly the same manner you disqualify sqrt.
But hahajk said nothing about anything being disqualified. (Not to mention that division is not raising to the -1 power ... raising what? n/d = n * d^-1, but this is completely irrelevant to hahajk's argument.)
> Given exactly four instances of the digit 2 and some target natural number, use any mathematical operations to generate the target number with these 2s, using no other digits.
and the square root symbol is a mathematical operation and is not a digit. That it is equivalent to taking the 2nd root isn't relevant ... the whole puzzle is about finding and using equivalents.
One could even claim division is raising to the -1 power, thereby disqualifying it in exactly the same manner you disqualify sqrt. I’ve never seen sqrt with a 2 index; power -1 is seen quite often for division.
Go figure….
EDIT: I realize that this was already posted in a comment by shoo several hours ago.
to make the problem more interesting, the list of operations can be extended to include exponentiation and concatenation.
for example, using the four basic operations for N=4, and K in [2,9], we get:
7 cannot be computed in 4 2s; 11 cannot be computed in 4 3s; 10 cannot be computed in 4 4s; 8 cannot be computed in 4 5s; 9 cannot be computed in 4 6s; 4 cannot be computed in 4 7s; 5 cannot be computed in 4 8s; 4 cannot be computed in 4 9s;
https://www.ioccc.org/2025/kurdyukov/index.html
7 = ⌈ 2.2² + 2 ⌉
And JFYI since December is near: https://rant.gulbrandsen.priv.no/hack/advent-calendar-for-ne...
Encode 0 as 2 + 2 - 2 - 2 then apply S a times to that 0.
Only depends upon natural numbers & Peano stuff, no need for construction of rationals, irrationals, logarithms, etc.
If we're allowed to introduce our own operators, we could concoct something like decimal notation
a . b := 10a + b
So we could write 90210 as 9 . 0 . 2 . 1 . 0 = S(S(S(S(S(S(S(S(S(0))))))))) . 0 . S(S(0)) . S(0) . 0
That doesn't quite work as it still depends upon a bunch of literal zeros. We could replace 0 with an operator Z() := 0, but that seems to be very much against the spirit of the challenge.
We could rewrite our ersatz decimal expression to only require a single zero & then evaluate a vector of functions f : N -> N across that zero, resulting in a vector of natural numbers, then reduce that vector to a single number with our `.` decimal notation operator.
Let M(fs, x) := (fs_1(x), ..., fs_n(x))
Let R(x) := x_1 . x_2 . ... . x_n
90210 = R(M((SSSSSSSSS, Id, SS, S, Id), 0))
the number of symbols to write a d-digit number this way is bounded by 10 + 10d = 10 + 10log_10(n)
Is this cheating / against the spirit of the challenge? Perhaps!