The video brilliantly maps abstract computational complexity onto a simple puzzle through a rigorous SAT reduction. It is a masterclass in revealing the profound mathematical depth hidden within seemingly trivial gameplay.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Fruit Box is NP-HardAdded:
Okay, yeah, welcome to my talk.
Thank you for coming. This is Fruit Box is NP-hard.
Um I will be switching between the slides and other stuff, but uh yeah.
So, what is Fruit Box?
Uh it's a web game, and I think you if you might want to play one game right now.
It's a very simple game. Uh I will send a link in into the the channel.
It's basically Oh, better turn that off.
It's this this game where you basically just select numbers that add up to 10.
This is uh this is the game.
So, you can start thinking what about this game might be complicated cuz I know when I started playing, I thought it was a really simple game. It's just like a find the correct combination game, and I thought it would be extremely simple to analyze, but it is actually pretty interesting.
So, yeah, that's >> [snorts] >> you you clear um a rectangular area, and the apples have to sum to 10, and that clears the apples off the board.
And if you're playing this game, also the you have a time limit, but we don't really care about that for this this talk.
Uh for this talk, in fact, we will considering infinite Fruit Box where we have infinite area, infinite time, and we don't care about points at all.
Cuz uh yeah.
So, let's start with a question like this.
Can we clear this apple?
Can I ask everyone here?
Can this apple be cleared?
>> a a no to me.
Oh, oh, you mean not immediately.
Yes, not immediately. Can it eventually be cleared with >> case, I'll have to think about it.
Okay, we got a yes.
Yeah, I think I see it.
Yeah, so you can uh here I can have the animations. You can uh clear it, but you can also get stuck if you uh clear these two, then these two, then the eight and the two, and then you can clear the seven and the three, but you can also get stuck by doing the nine and the one, and you're immediately out of moves.
>> [snorts] >> Well, I mean, you can do the seven, the one, and the two if you want, but does you no good for clearing the three.
So, this is why the game is interesting.
Cuz it turns out your strategy actually does matter, and you can block yourself off.
The animations are just OBS recordings.
Um Okay, so the this is actually Wait, actually let me go back. This is actually the decision problem that I will show as NP-hard that given a a board, is a given apple clearable? This is the question.
Yes or no, can this apple be cleared?
Uh no, not all the boards in the game are clearable. In fact, almost none of them are not clearable.
Uh but I I will talk about that in the second half of the talk. I also played around with building solvers for this game.
But let's I'll do that later. Okay.
So, um I don't know how much I have to explain about what NP-hard this is. I'm assuming most people here are pretty familiar, but I will give a quick explanation.
There's this class of decision problems that are uh in NP, which if you don't know what it means, one way to describe it is their solution is quickly checkable, but that's a very hand-wavy explanation. That's all you're going to get from me right now. And then what um there's also this class of problems that are NP-complete. And when I first learned of this, I thought it was pretty crazy.
It's basically problems that can be used to solve all the other NP problems.
Uh which is pretty crazy.
And one of these NP-complete problems is the Boolean Satisfiability Problem, which uh Also, I will for this talk, I will be assuming that P is not NP. I won't be uh going into that right now. Okay, so the SAT problem is uh basically you're given a Boolean formula, and you have to find variables that satisfy the satisfy it. Is it possible to find uh assignments to the variables, Boolean true or false assignments, that make the whole formula true? And in fact, it turns out it's enough to have that only for um formulas of this form that have uh the variables, the negated variables, then uh ORs, and those combined with ANDs.
This is the this is called the conjunctive normal form of the formula, and uh yeah, the question is can you find a solution to this? And that's actually an NP-complete problem.
Okay, is that clear enough?
I'm with you.
All right, good.
Okay, so uh what I will be doing now is going to do a reduction, which I'm going to show that every SAT problem can be turned into a Fruit Box problem like this.
So, if we had an oracle that could solve every Fruit Box problem, we could use that solution to get a solution for uh the Boolean Satisfiability Problem, which shows that it's at least as hard, so also uh NP-hard.
Nice.
Got a we got a 42 in the in the chat.
Um Yeah, I will I'll be talking more about uh the scores you can get and stuff later on.
Okay.
Um Yeah, that's what I'll be showing, and it's going to look something like this.
I'm going to construct Uh don't worry about this for now. This is just what it's going to look like in the end. I'm going to construct this step by step in a second. It's going to look what's going to look like in the end, a big board, and the question will be can you solve one of these?
And we're going to construct it from a given formula, and we're going to need a couple of like gadgets for this.
So, this is how we basically transfer uh a signal. It's like a like a wire.
So, as you can see, kind of if we can clear the seven, it kind of unlocks this path. We can use this two to clear the eight, and that allows us to clear this path, so we can use the three to clear the seven, and so on. We can have like this redirection. And the nines are just blockers. They're kind of inert cuz the only way to clear a nine is with a one, and I won't be using any other ones, so you can basically just see the nines as blockers.
And does that make sense?
Yep.
Good. I'll move on to how to build an OR gate. So, now we're basically just doing the classic video game building logic gates puzzle. This is if we can clear [clears throat] this eight or we can clear this eight, it allows us to use the three to clear the seven, and we can keep clearing from there on.
Um similar with the AND gate.
Can if you can clear both of these, you could clear a seven that's down here somewhere.
And then the [clears throat] what we actually can't do is build a NOT gate, but turns out we don't need to cuz we have this. This is basically the the most complicated part, which is basically at the start of the game, the player has a choice here. They can use this two to clear this eight or this eight, and I'm going to call one of the paths false, and one of the paths true.
So, the player has to make a kind of a variable assignment a choice to, and can only unlock stuff in one of these paths.
Uh and then the we can already move on to the total structure. This is basically what it looks like. This is the uh same formula I had shown as the example.
Uh yeah, you will you will wire them up separately. So, this is kind of like um circuit diagram here. So, these are the inputs the player basically has to choose.
Yes.
The player has to choose um a variable assignment for each of these, and then they can start clearing um down here. So, we use these for redirection, and then it feeds into ORs and ANDs, and then yeah, you can fully see the general structure, and that's basically the whole proof. I'm going to do I'm going to show I have this here.
Uh we can play. Does anyone want to choose a variable assignment? Wait, let me um Let me go back to the formula.
This is the same formula as the one shown as an example.
This one.
Yeah, this was This was written by uh AI.
I will show some code by me later. This is uh just uh This was entirely done by AI.
But yes. Okay, so does anyone want to choose a variable assignment?
Then we're considering left uh to mean false and right to mean true. And uh this is the formula.
Uh yeah, there is a reason that everyone has an extra bump. Uh the reason is See, we have two um sevens here, and we want to be able to This is like a branching.
We want to be able to clear both. Yeah, I'll do it I'll I'll choose a true for C.
We can clear this one.
And we can clear this one.
Okay, uh I'm just going to I I don't quite remember what the correct assignment is. I'm going to choose randomly, and we might get it or you might not.
So, I'm going to choose some assignments here, and uh Yeah, this already does nothing. So, can see that was a bad strategy if you wanted to clear it.
So, can get this this or can get this one cleared.
Uh yeah, we're stuck here.
Uh we definitely needed this one >> [snorts] >> uh true to get this one.
So, that was wrong.
Okay, let's Let me go back to the We'll do it what it looks like if we actually get success.
Um I need not A B and uh Help me out you guys.
It looks like you need C, and then D doesn't matter.
Yeah, okay. So, not A, B, and C.
Uh like this. Okay, let's try that.
And then it will be very satisfying, hopefully.
Uh I don't know if this is too small to read. I have not.
Can clear this or this one, this or and bam.
That's it. So, that's basically the proof complete. Um the only if you can if the player can find a variable assignment to these, they can clear it. So, it's basically like the set problem. Okay, yeah, that's the that's the main part of the talk uh done already. The guy The only interesting thing about this really is pretty standard. But the interesting is there's no not gate. And I think I'm I'm pretty sure a not gate is actually impossible.
Cuz How did I notice this? I don't know.
I was thinking about uh talks uh topics for a talk. I was going to do fruit box strategies, which I will also do now, but then I came up with maybe I can do something like this that's more uh that's maybe uh better for a a two swap type topic.
Okay, so there's no not gate. There is something called um the the circuit satisfiability problem, which is basically the same thing, but it's usually phrased with a not gate, which we don't have. And we kind of can't have because being able to clear something does never really makes it impossible to clear something else.
So, it's kind of weird.
So, yeah, that's the first part of the talk. And I don't really have uh slides for the second part of the talk.
But now I'm going to talk about strategies.
>> Wait a minute.
>> Any questions? You said Say Say that one more time. Clearing being able to clear something never makes you unable to clear something else. I'm thinking about a case where like you're adding like like 2 + 3 + 2 + 3 or something, and there's nothing else in that row.
You can clear that, but as soon as you clear one of those four, then you can't clear the rest, right?
Yeah.
I'm not sure how to make a not gate out of that or anything.
>> Yeah, I I I don't know how to prove it, but I feel like it's impossible to make a not gate. Or you can also think about not being able to clear something should make it possible to clear something else. That really seems really difficult to build.
>> Wasn't that what I Isn't that sort of what that is? If you have like a like a 2 3 2 3, like you can clear the whole row only if you don't clear any individual column.
If you have 2 3 2 3 in a row, then like if you clear any one of the columns, then you can't clear the whole row.
Yeah, yeah.
I I Yeah, I agree, but um yeah, I I I'm not saying I know how to make an a not gate necessarily out of this.
>> Yeah, I think it's impossible to make a not gate, but I I I don't quite know how to prove that.
Yeah.
You can make any not gate true. Yeah.
Okay.
So, now I'm going to talk This is actually This has nerd sniped many programmers over the years, actually.
And if you Google it, you will find a lot of people writing uh programs to solve this.
Um And I've also written some. It's actually quite difficult cuz a full uh game tree search is basically impossible. There's too many options.
Um I have uh a chart here with some of the strategies I made.
Um And also, uh when I started playing, I thought um I thought for sure it wasn't going to be that complicated. And basically, if I have a bot that just never misses anything, it would get most of the way there. It would already be a pretty good strategy. But turns out you actually need to have quite a smart bot to do well in this in this game.
So, the the first strategy here is just play randomly and do that a bunch of times.
Like play the game like do pick a random valid move uh repeatedly, make that move until you run out of moves, and then start over from the very start and keep track which your best uh run is. Which your best score is, and then that's the the the thing you'll go with.
Wait, so you can like reset the board?
Uh no, you can't reset the board, but since the you never get any information feedback, so you can just do it in your head pretty much.
>> Oh, okay. Sure, yeah.
So, you could if you I mean, as a human, it's very hard, but as a computer, you can just imagine what would happen, and um Yep, got you. And I actually I also wrote um I can actually get the the code to move my mouse.
This is kind of irrelevant, but it's kind of fun.
Um Wait a second.
If I it will um It will scan Oh, that's the wrong one.
Uh Oh, man.
I think I just started it, and it's going to It's about to move my mouse, which is not what I intended.
Okay, my stuff moving mouse in a second.
I'm going to ignore that for now. Okay, so this is the the first way I came up with to play the game, which is randomly. And turns out uh it's actually not very good.
Um Then the Then I spent a lot of time writing a depth first search, which does a lot better than random, uh but it basically gets stuck in a in a in one opening cuz there's Yeah.
The cuz of it being depth first, it basically chooses the first few moves, and then wastes all the time uh for the time down the line. So, basically reminiscent of the newest two swap video. At the start, you want to explore, and at the end, you can like calculate all the options.
Um The the way I simulated this is you play you basically combine the two strategies. You play some random moves at the start, and then you run depth first search from there, and then you repeat that whole thing a couple of times and then pick the best run you got.
Um Yeah.
Does that make sense?
Elliot asks, "What about Monte Carlo tree search?"
Yeah, well, randomly playing basically is Monte Carlo tree search, right?
That's what Monte Carlo tree search is, right?
Um so, it's kind of I don't I think it's different.
Yeah, how would how would you define it?
>> I'm not I'm not a I'm not an MCTS expert, but I think the idea is basically >> Neither am I. Neither am I, but >> branches that are already sort of doing well. There's like Yeah, yeah, so you sort of have an exploration feature that explores usually on nodes that are already looking promising.
Um Yeah. That's That's my understanding.
>> what I'm what I'm trying to do. I can also there's um Wait, let me find it real quick.
Um there's also here there's also this thread from 4 years ago where people were talking about the same thing. I only found this after I also spent several days writing solver for this, but um this guy did a competition on the code golf where he uh also let people play this and once people submitted their submissions and he scored them on 10 different boards and gave them points for that.
And uh the winner of this competition uh I got his code to run. Uh I'm going to I can quickly explain how it works in a second. And this is also on my my chart, which I slightly beat with uh with five move opening plus a huge depth first search plus 100 repetitions, but uh also mine also runs in under 2 minutes. This was the rules for this was the code has to run under 2 minutes, so just like the human you have 2 minutes to solve this. And you do actually run out of time a lot. Like you really wish you had more time.
Um The way this one works by dingle dooper uh is it's basically just a normal brute force search, but at every step of the game tree you limit yourself to four four options.
So, um if I uh let me you have like a a game the game tree and you have like 10 options you only pick uh the four uh promising He has a criterion, which is quite important. He chooses four of these and explores each of these four of these, so it's also a it's just a brute force uh search depth first search, but uh he limits the branching to four, so it doesn't quite get stuck too much in uh a deep uh deep lines.
So, yeah.
Uh so, that it doesn't explore too much, so you will get over to the other ones.
And that was the one that won this competition.
Um yeah. I have an idea for a heuristic that I have a feeling would be kind of good, although I'm >> Yeah. Yeah, I uh I'd be curious to try like um I'm imagining you look at the total set of legal moves immediately, like that are immediately playable, and pick the move that like that maximizes the amount of those greedily one one step in the future.
Uh maximizes the score greedily or >> No, maximizes the the amount of legal moves.
Oh, yeah, that's also the actually the first thing I tried to implement, but >> Oh, yeah.
Yeah, yeah, that was also my first idea.
It didn't I I don't my code was very messy. I kind of fixed it since then, but so I'm not sure if I maybe it was really bugged, but it didn't work as well as I hoped. Huh.
>> Uh and and you need some I it could be used as an addition to the other stuff, but you really need some way to throw like more compute at it, like some way to uh do a search or um Yeah, maybe just do that, but then like a depth three search with the same heuristic or something.
Yeah, you need something like that and uh I I never tried that, so it might be good. What this heuristic is is out of the legal moves you actually want the ones that clear the least apples cuz what you don't want to do is uh what you don't want to do is clear like Let me see if there's a terrible one.
Uh like this is bad cuz it wastes a lot of small numbers.
>> Oh, yeah.
What you want is um like the nines are the ones you really want to get rid of, so these are the nine one moves are good moves. I see. Um and basically any move that only clears two apples, that's a that's a good move. So, that's the heuristic I'm basically using and that also this user was using.
Um Yeah, you you really don't want to clear a bunch of small numbers. You really want these to be big numbers. And yeah, also someone asked earlier what how many like is it fully clearable? Typically, it's not fully clearable. I mean, it's already not fully clearable if there's more nines than ones, right? Then it's already impossible.
Uh and that's like half the time, so in I don't know how many are actually solvable cuz I think my solution could still be a lot better, but it feels like only one or two percent or something are solvable.
Uh like fully clearable.
There is a YouTube video of someone supposedly fully clearing it as a human, but since it was so difficult for me with the computer, I think it might be it might be fake, but I don't know. Are you guaranteed that all the numbers add up to a multiple of 10?
I think so. Someone said so.
Um So, I think they did uh write it so that the the sum is divisible by 10, yeah.
Yeah, full clears are also would also be NP-hard. And I think there's other questions you could ask.
Like is a set of moves optimal? That might actually be um more than NP. That might be like PSPACE-hard.
Uh but I haven't Wait, so do do we have a proof for that that the full clears are also NP-hard or just the individual >> Um I mean, yeah, yeah, yeah. I can I can extend this construction to uh like at the end I can instead of just whoops unlocking the seven, I can build a contraption where this allows you to get a full clear.
Oh, only if you're able to eliminate the the seven at the bottom.
>> the seven, [laughter] you can like unlock an ocean of ones that will uh let you clear everything else, so you can full clear if and only if there is a solution for this.
So, full clears in general are also NP-hard, yeah.
Um Yeah, what was I talking about anything else before that?
Pick the move with the most remaining.
Yeah, I think those might be good.
But I can't really get it to work that well.
I that that was my first thought, but I couldn't quite get it to work.
Um Yeah, I can Let me try to get uh one of my uh um one of my uh programs to run on the board cuz it's kind of fun to watch.
But yeah, that's that's Elliot, let us know if you end up implementing it. I'm curious to see how that heuristic does at various depths.
Yeah, I can share my code if um I mean, my code is kind of messy, but um if you want to try to interface with Okay.
This Okay, let me This kind of bugged out cuz it didn't clear some of them.
Let me Let's wait for it to be done.
It plays like this.
Okay, let me reset.
We can watch it get a really high score.
Bam. That's pretty good. Wow. Wait, I'm curious. Before you hit reset, I want to count the number of nines and ones. It looks like Yeah, it looks like there's only one one left and like a lot of nines.
Uh yeah, although that might not be the total balance cuz sometimes it does use ones like over nines. Like when it does eight one one if at the end you don't really have any other good moves.
>> Got you.
Yeah.
Um Yeah, I can It's fun to watch, so we'll do another one.
>> Like as a human I got like 127 or something as my personal best. I waste a lot of time playing this game.
It's quite addictive.
Quite addictive game.
Okay, I'm going to have to try it.
>> [laughter] >> We'll see who can get the highest score in the Okay. in the thread made after this video.
Yeah, I guess we can end the recording.
I don't really have anything else to add to the Cool.
Yeah, I appreciate it. Thank you. Okay.
Yeah.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 viewsโข2026-05-28
How agent o11y differs from traditional o11y โ Phil Hetzel, Braintrust
aiDotEngineer
450 viewsโข2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation๐ฏโ
LearnwithSahera
1K viewsโข2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 viewsโข2026-05-29
Search Algorithms Explained in 60 Seconds! ๐ค๐จ
samarthtuliofficial
218 viewsโข2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 viewsโข2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 viewsโข2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 viewsโข2026-06-01











