Part two · The lazy answer
Minimum effort
Everything above assumed you would do as you were told. Let's drop that assumption.
If you're like me — lazy — you don't have the mental fortitude to stop your cheat meal and to be diligent towards your session. Two problems, then: exercise is boring, possibly painful, and eating good junk food feels great — arguably necessary.
So in an ideal world, I'd want to hit my goal in the most fun way possible: either cut down the boredom and pain, or ramp up the pleasure, or both. And that's where the principle that makes this possible — or tells us it's impossible — comes in: linear optimization.
It's one of those techniques that quietly holds up modern society, alongside the Fourier transform, matrix factorization, and graph theory. Concretely: it maximizes or minimizes a linear function — profit, cost, whatever — subject to linear equality and inequality constraints. Or, roughly: it finds the best possible outcome inside a mathematical model.
A YouTuber and their editor
Let's take a random example. A YouTuber wants to maximize total watch hours this month. There are two video formats: shorts (quantity x) and long-form videos (quantity y). On average, a long-form video pulls 15k hours of watch time in a month; a short pulls 2k.
The YouTuber has 80 hours max to spend on this per month. A short takes 2h of work, a long-form video takes 9h:
Their editor's contract caps them at 68 hours per month. A short takes 1h to edit, a long-form video takes 8h:
On top of that, x ≥ 0 and y ≥ 0, because negative videos don't exist. We can plot all of this as lines on a plane.
The coloured region — the quadrilateral — holds every possible combination of x and y. Now trace the line 2x + 15y = 0: it cuts through the origin, and our whole region sits on its positive side, which confirms P is always positive here — except at the origin, where you've made nothing at all.
Slide that same line outward, keeping it parallel to itself. Each position is a line of equal profit — an iso-profit line — and the moment it's about to leave the coloured region entirely, wherever it last touches is your answer.
That point is always one of the corners of the quadrilateral. But only whole numbers of videos exist, and a corner that lands between two integers is no use as it stands. The fix is the same gesture you just made: keep sliding the profit line inwards until it touches the first point with whole coordinates. That one is your answer — every step inwards costs you views, so the first integer point you meet is the best one you can actually afford.
Here the winning corner is 4 shorts, 8 long, so the YouTuber can hope for at most 128k hours of views this month. Two dimensions make this easy to see. Twenty won't — we'll come back to that.
Now do it for your diet
To start, we need to define our objective — and that earlier line, about hitting the goal in the most fun way possible, already hands it to us. Call Pain the perceived boredom or discomfort, and Pleasure the perceived enjoyment. That sentence translates to:
We could stop there, but it's always cleaner to work with a single objective. Here's the neat part: pleasure is just a positive experience, and pain is a negative one. So we can collapse both into one variable, Pe — perceived experience:
Now let's go back to the calorie-burn table from part one and put a calorie-gain-per-meal table next to it. From each, pick at most 10 activities and 10 meals of your choice, and score each one's Pe from −10 to 10 — 10 for pure pleasure, −10 for the worst pain you can imagine.
Let ai be activity i and fi meal i. Call Nai and Nfi how many times each happens, Pai and Pfi their Pe score, and Cai, Cfi the calories they burn or provide. The objective is:
But this objective comes with constraints.
Three things standing in your way
First, your day has limited hours — you have to sleep, go to work, and so on. Give your diet T minutes a day and everything has to fit inside it.
Second, you need to eat at least your BMR in a day. This one isn't negotiable — go under it and you're not depriving your body of fat, you're depriving it of what it needs just to function. That's why it's a hard floor in the program, not a suggestion:
Finally, there's your weight-loss target, which we can pull straight from part one.
So to actually hit your goal, what you need is:
Σ Nai·Cai = EEE
Σ Nfi·Cfi = Ci which folds down to Σ Nai·Cai − Σ Nfi·Cfi ≥ L × 770/3 − BMR − NEAT = −2,549 kcal/day
Negative, and that's the point: resting and working already burn enough that you may eat up to 2,549 kcal more than you exercise off.
Twenty dimensions
This time there are 10 exercises and 10 meals — 20 dimensions. Same principle, except now we're looking at the 20-dimensional equivalent of that same quadrilateral. Impossible to draw, but the rule doesn't change: the solution still sits in a corner, and one more step lands us on the best all-integer version of it. What we can draw is two dimensions at a time.
Your ideal day is therefore —. Not the day you imagined when you started reading, probably. Depending on what you picked, you may have just been told to eat four cheeseburgers. That sounds unhealthy, and it is — but the model did exactly what you asked. You told it to optimise calories and pleasure. You never mentioned nutrition, and you never mentioned that you'd like to eat different things.
You can fix it with a little hack: just cap how many times the same meal can show up in a day. That's a new kind of constraint — not a sum across everything, but a ceiling on one variable at a time, Nfi ≤ k for every meal. Set it below, then scroll back up and watch the programme rearrange itself.
And that's it — you have everything you need to launch your own diet app and become a multi-millionaire. Hope you enjoyed the reading, and if you're lazy to the point of never using any of this, at least reading this article burned ___ kcal.