Making any integer with four 2s (2025)(eli.thegreenplace.net)
84 points by germanrabbit 6 hours ago | 23 comments
[–] adas0693 5 hours 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 3 hours ago
This feels very suspiciously like a finite field problem.
[–] genter 5 hours ago
Are you allowed to brute force it?
[–] argee 3 hours 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.
[–] gnabgib 6 hours ago
Popular last year (368 points, 165 comments) https://news.ycombinator.com/item?id=43145753
[–] Arnt 5 hours ago
Spoilsport.
And JFYI since December is near: https://rant.gulbrandsen.priv.no/hack/advent-calendar-for-ne...
[–] teo_zero 5 hours ago
Never understood why 7 is considered difficult...
7 = ⌈ 2.2² + 2 ⌉
[–] anthk 1 hour ago
(2 << 2) - ( 2 / 2)
[–] blueblock 4 hours ago
Rounding spoils the fun of the puzzle.
[–] nostrademons 3 hours ago
It seems very much in the spirit of allowing concatenation and square roots...
[–] AnimalMuppet 5 hours ago
It is difficult when the rules do not allow exponentiation.
[–] Jtsummers 4 hours ago
7 = ⌈ 2.2 + 2 + 2⌉
Would still work.
[–] hahajk 3 hours ago
[–] JumpCrisscross 2 hours ago
Squaring is to multiplication as is the latter to addition. If roots are invalid then so should be multiplications.
[–] SamBam 1 hour ago
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.
[–] penteract 1 hour ago
[–] danparsonson 2 hours ago
[–] drfloyd51 1 hour ago
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 1 hour ago
Multiplication is a scaling operation.
[–] spieglt 1 hour ago
[–] SideQuark 2 hours ago
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….