Starvation games: A (fox’s) guide to fasting metabolism

Thing practiced: storytime with canids

Tools used: D3.js, pen + paper, PubMed (references)

You’re much too beautiful! Do you want us all to feel depressed?

For 382 days, a twenty-seven-year-old man chose to consume nothing but fluids, salt, vitamins, and yeast. He survived, dropping from 456 to 180 pounds—and weighed in at 196 five years later.

Fasting is in vogue now, and not just among self-flagellants. Fans of intermittent fasting say hunger hones our bodies’ recovery mechanisms and preserves lean tissue while eliminating fat. Paleo Diet adherents—who argue that obesity, diabetes, and heart disease stem from the mismatch between our evolutionary history and the modern environment—remind us that humans evolved to thrive when meals were rare. So (how) do our bodies survive when we’re not eating?

All our energy derives from breaking carbon-carbon bonds, and we have various carbon backbones available to burn. Glycogen, a branched carbohydrate, is our fast fuel: all our cells maintain a stash, and all can quickly mobilize it as sugar when needed. Stockpiling glycogen is inefficient, though, because we package it with water. (We think of carbohydrates as yielding 4 calories per gram, but we reap only 1-2 calories per gram of hydrated glycogen.)

A larger store of potential energy is in body proteins, which are linear polymers of amino acids. Proteins serve critical functions (skin, ligaments, muscle, enzymes, hormones), so we preserve them as much as possible. Though proteins can and do get broken down for energy, catabolizing more than about half will kill us.

Our main fuel store is fat, which is both efficient to store (because it’s not hydrated) and otherwise useless (meaning it’s easily expendable). Theoretically, a man with 20% body fat could survive off his fat layer for weeks.

Stored energy reserves in a 170-pound, 20% body fat man; one day’s resting energy usage is shown for reference.

In practice, though, calories from different sources aren’t interchangeable. Our bodies don’t literally burn fuel, but instead send it through energy-harvesting pathways that accept specific inputs. Some cell types lack the machinery needed to process certain molecules; for example, red blood cells don’t have mitochondria, so they can use only glucose (sugar) for energy. Other tissues can’t use certain fuels because they’re not physically accessible; for instance, the brain can’t burn fat because fatty acids can’t permeate the blood-brain barrier. And our bodies can interconvert our energy stores in only limited ways: we can convert glucose to fat, and protein to glucose or fat, but we can’t convert fatty acids to either glucose or protein.

When we’re starving, our bodies prioritize two things: maintaining an uninterrupted flow of energy to the brain and spinal cord, and preserving as much body protein as possible. Normally, our brains run solely on glucose. During starvation, though, glucose is precious: we can create it only by destroying body protein. To conserve protein, the brain reduces its glucose usage by burning the ketone bodies β-hydroxybutyrate and acetoacetate as fuel. Likewise, muscle tissue and major organs like the heart and liver usually burn a mixture of glucose and fatty acids, but switch to a ketones-added, lower-glucose, higher-fat mixture.

How brain and muscle adjust their energy usage as starvation progresses: the brain switches to use ketone bodies (β-OHB and AcAc) as its primary fuel, while muscle replaces most of its glucose usage with fatty acids (FFA). (Percentages shown are oxygen equivalents).

During the first phase of fasting, as we run down our short-term glycogen stores, the liver ramps up its ketone production to allow us to make these fuel usage transitions.

As starvation progresses, blood concentrations of ketone bodies β-hydroxybutyrate (β-OHB) and acetoacetate (AcAc) rise by orders of magnitude; free fatty acid (FFA) concentration doubles.

These metabolic transitions spare vital organ and muscle proteins, but we do still burn some protein—both to produce the minimal glucose some tissues still need and to provide the four-carbon intermediates required to catabolize ketones and fat. Throughout this “steady” state of fasting, which can last weeks to months, our bodies gradually cannibalize our protein stores. Eventually, enough protein is consumed that our organ systems lose function and we die, usually when our respiratory muscles fail. (We die of starvation even if we’ve retained large stores of fat.)

So, what does any of this have to do with a plan to lose weight? Not much, I hope. It’s tempting to think that 20 or 30 days of buckling down and getting hardcore will turn us into perfect, beautiful people. If only.

we’re all fucked up skinny bitch


Things practiced: calming down, making food, hanging out

Insomniac cooking

Thing practiced: cooking

Tool used: phone

I couldn’t sleep so instead I made a bunch of food.

Food: Provençal

Thing practiced: making food

Trying gradually to expand my cooking style from nonexistent to unsophisticated.

Provençal beef stew (Daube de bouef)
Eggplant custard (Aubergines à la Provençale)

Onion panade (Panade à l’oignon au gratin)
Zucchini fans (Courgettes en éventail)

Garlic chicken (Poulet aux 40 gousses d’ail)
Pork chops with Dijon & apples (Côtes de porc à la moutarde & pommes)

Photos: San Francisco

Thing practiced: walking around

Photos: Around LA

Thing practiced: photography

Tools used: Canon Rebel T3i, Canon 40mm f/2.8 lens

El Matador SB (Malibu) – f/3.5, 1/1600 s, ISO 100
El Matador SB (Malibu) – f/4, 1/250 s, ISO 100

Angeles Crest Highway (Mount Wilson) – f/4, 1/3200 s, ISO 100

Mount WilsonGetty
Angeles Crest Highway (Mount Wilson) – f/4, 1/2000 s, ISO 100
Getty Center (Brentwood) – f/2.8, 1/40 s, ISO 3200

Getty Center (Brentwood) – f/2.8, 1/1000 s, ISO 100

Lake ShrineLake Shrine
Lake Shrine (Pacific Palisades) – f/4.5, 1/120 s, ISO 400
Lake Shrine (Pacific Palisades) – f/4.5, 1/160 s, ISO 250

Lake Shrine (Pacific Palisades) – f/11, 1/120 s, ISO 160

Piano: Beethoven sonata no. 14 in C# minor (Moonlight), mvt. 3: Presto agitato

Thing practiced: piano

Tool used: a piano

I used to play the piano (somewhat haphazardly) as a kid, but I abandoned all music-related activities after damaging my third-favorite finger five years ago. Recently, though, I’ve been scrabbling to grasp whatever wispy skills I can muster, so I try to play whenever I’m near a piano. Which is rarely.

Turns out, I kinda suck. But that’s what practice is for, right?


Thing practiced:drawing

Tools used: index cards, pens, Sharpie, , , solvent

Chores: Mazda MX-5 maintenance

Thing practiced: doing chores

Tools and supplies used: (pictured ↓)

Project Euler: #137, Fibonacci golden nuggets

Thing practiced: math

Tools used: A Friendly Introduction to Number Theory, Python

“m tired of girls, I want to see more math.”
—no one ever


Consider the infinite polynomial series

$$ {A_F}(x) = x{F_1} + {x^2}{F_2} + {x^3}{F_3} + \ldots \tag{1} $$

where Fk is the kth term in the Fibonacci sequence (1, 1, 2, 3, 5, 8, ...).

For every case where x is rational and AF(x) is a positive integer, we call AF(x) a golden nugget, because these are increasingly rare – for example, the 10th golden nugget is 74,049,690.

What is the 15th golden nugget?


Infinite series are unwieldy, so first we replace (1) with a closed-form version (derived here):

$$ {A_F}(x) = \frac{x}{1 - x - {x^2}} \tag{2} $$

We need AF(x) to be a positive integer, which we’ll call n. So, rearranging (2), we get:

$$ {A_F}(x) = n = \frac{x}{1 - x - {x^2}} $$ $$ n{x^2} + (n + 1)x - n = 0 \tag{3} $$

This is a standard quadratic equation with solutions

$$ x = \frac{-(n + 1) \pm \sqrt{(n + 1)^2 + 4n^2}}{2n} \tag{4} $$

As long as the square root portion of (4) is an integer, x will be rational. We can solve for this case by calling this portion m (making the discriminant m2):

$$ m^2 = (n + 1)^2 + 4{n^2} = 5{n^2} + 2n + 1 $$

and doing some algebra we get:

$$ 5m^2 = 25n^2 + 10n + 1 + 4 = (5n + 1)^2 + 4 $$ $$ (5n + 1)^2 - 5m^2 = -4 \tag{5} $$

Now, if we substitute p = 5n + 1, then (5) becomes a Pell-like equation:

$$ p^2 - 5m^2 = -4 \tag{6} $$

This means that we can find solutions to (6) by finding solutions to the corresponding unit-form Pell equation x2 - 5y2 = 1 and transforming them.

To compute the solutions, we use the technique described here. We first identify the fundamental solutions to (6). Then, we transform these into solutions of the unit-form equation by the identity (pi2 - 5mi2)(xi2 - 5yi2) = -4. From these, we can generate subsequent solutions, then transform them back into solutions to (6) by the same identity. Finally, we re-substitute our original n = AF(x) back in to find the golden nuggets.

This gives us the answer: 1,120,149,658,760.

Early morning doodles

Thing practiced: drawing

Tools used: index cards, pen, colored pencil, phone

Waiting-around doodles

Thing practiced: handheld drawing

Tools used: free minutes, index cards, Sharpie®s

Idle doodles

Thing practiced: drawing

Tools used: colored pencils, paper

I like seeing the doodles people make when talking on the phone at a desk. Some people sketch the things around them (their hand, the Shift key, a plant), some people draw geometric patterns, some people just write down individual words and put boxes around them. When I was a kid we used to spend class passing notes with terrible stick-figure illustrations of pretty much nothing, but it was fun, and idle phone doodling evokes the same feeling. Which is irrelevant, except that I spent tonight’s on-hold time with Comcast doodling:


Institutional politics

Thing practiced: data visualization, sort of

Tools used: D3.js, GDAL

Gay marriage around the world
Mar 2013
(drag to rotate)
(Bigger version here.)

The Supreme Court is considering two big same-sex marriage cases next week—Tuesday’s case (3/26) decides the constitutionality of Proposition 8, which bans gay marriage in California, and Wednesday’s case (3/27) covers the federal Defense of Marriage Act, which defines marriage in the U.S. as exclusively between a man and a women. ☠️


Thing practiced: drawing

Tools used: sketch paper, colored pencils, pencil, eraser


Project Euler: #112-113, Bouncy numbers

Thing practiced: math

Tool used: Sublime Text 2

Problem 112:

If no digit in a number is exceeded by the digit to its left it’s called an increasing number – e.g. 134,468. Similarly if no digit is exceeded by the digit to its right it’s called a decreasing number – e.g. 66,420. We’ll call a positive integer that is neither increasing nor decreasing a “bouncy” number – e.g. 155,349.

Clearly there cannot be any bouncy numbers below 100. In fact, the least number for which the proportion of bouncy numbers reaches 50% is 538. By the time we reach 21,780 the proportion of bouncy numbers is 90%.

Find the least number for which the proportion of bouncy numbers is exactly 99%.

Solution to 112:

This seems easy enough to brute-force, so I tried that in Python:

# Parse the number right-to-left to find if it's bouncy.
def is_bouncy(num):
    has_incr_seq, has_decr_seq = False, False
    right_digit = num % 10
    num = num // 10

    while num > 0:
        left_digit = num % 10
        if left_digit < right_digit:
            has_incr_seq = True
        elif left_digit > right_digit:
            has_decr_seq = True
        right_digit = left_digit
        num = num // 10
        if has_incr_seq and has_decr_seq:
            return True
    return False

# Iterate through numbers until the bouncy count is 99%
# of the total count.
count = 0
i = 99
while count < 0.99 * i:
    i = i + 1
    if is_bouncy(i):
        count = count + 1

This gives us the answer: 1,587,000. (Python took 2.8 s to run this on a MacBook Air; out of curiosity I tried it in C — 42 ms.)

Next, problem 113:

As n increases, the proportion of bouncy numbers below n increases such that there are only 12,951 numbers below 1,000,000 that are not bouncy and only 277,032 non-bouncy numbers below 1010.

How many numbers below a googol (10100) are not bouncy?

Solution to 113:

Let’s start with a simple question and expand from there – how many increasing numbers are there below 1000?

Well, there are 3 digits in any number below 1000 (if we consider e.g. 012 to be 12), and for a number to be increasing each digit must be no lower than the digit to its left. Let’s label the digits in a 3-digit number A, B, and C. The leftmost digit A can be any of the digits 0-9; the middle digit B can be any of the digits from A-9; and the rightmost digit C can be any of the digits from B-9. That means that there are 12 potential digits to choose the 3 digits of our number from – the 10 digits 0-9, plus 2 potential duplicates if A = B or B = C.

The number of increasing numbers below 1000, then, is just (12 choose 3) = 220, minus 1 because we don’t want to count 000. Likewise, the number of increasing numbers below a googol is

$$ {109 \choose 100} - 1 \tag{increasing} $$

Decreasing numbers are similar, except that we can’t just ignore leading zeroes as we’d done with increasing numbers – for example, 072 is in fact a decreasing number, but wouldn’t be caught by the (12 choose 3) we used earlier. So, how many decreasing numbers are there below 1000?

If we label the digits in a 3-digit decreasing number D, E, and F, then the leftmost digit D can be any of the digits 0-9; the middle digit E can be any of the digits 0-D, or, if D = 0, any of the digits 0-9; and the rightmost digit F can be any of the digits 0-E, or, if D = E = 0, any of the digits 0-9. That means that there are 13 potential digits to choose the 3 digits of our number from – the 10 digits 0-9, plus 2 potential duplicates if D = E or E = F, plus 1 for potential leading zero(es).

The number of decreasing numbers below 1000, then, is (13 choose 3) = 286, minus 4 because 000 will occur 4 times (one time as before, plus once for each digit). Analogously, the number of decreasing numbers below a googol is

$$ {110 \choose 100} - 101 \tag{decreasing} $$

Almost there! In order to find all the non-bouncy numbers, we just need to add the increasing numbers to the decreasing numbers. However, some numbers are increasing and decreasing – e.g. 888. How many of these monotonic numbers are there? Well, for each power of 10 there are 9 potential monotonic numbers – e.g. we have 1, 2, ..., 9, 11, 22, ..., 99, 111, 222, ..., 999, etc. Since we have 100 digits, we have:

$$ 9 \times 100 \tag{duplicates} $$

Thus, the total number of non-bouncy numbers below a googol should be:

$$ \left({109 \choose 100} - 1\right) + \left({110 \choose 100} - 101\right) - (9 \times 100) \tag{total} $$

This gives us a final solution of 51,161,058,134,250.

Sketch: Peonies

Thing practiced: drawing

Tools used: Prismacolor pencils, solvent, drawing paper

(Haven’t posted for a while – it’s been busy, and spending a whole free hour any given day on random bullshit seems indulgent. I finally bought some colored pencils that aren’t meant for preschoolers, though, so I had to try them out.)



Thing practiced: drawing

Tools used: index cards, 4B pencil, eraser, pen


3D model: Inline-four engine

Thing practiced: 3D modeling

Tool used: SolidWorks 2013 trial

I’ve always had an iffy understanding of how car engines work – I learned pretty much everything I know (about everything) from this book when I was small. To understand better, I started modeling one in Solidworks:

Intake and exhaust camshafts:

Pistons and connecting rods:
Pistons and rods


Classic AI: Mancala

Thing practiced: logic programming

Tools used: Sublime Text 3 beta, SWI-Prolog, J.R. Fisher’s Prolog tutorial

Mancala is a traditional African two-player board game with many different variations. One variant of mancala, called Kalah, has a long history in AI research – see e.g. Silver 1961 (pdf), Bell 1968, Slagle and Dixon 1969 (pdf), and Irving et al 2000 (pdf).

Prolog is a logic programming language devised by Alain Colmerauer and his colleagues in the early 1970s. The idea behind the language is that you feed the computer a set of facts and rules, then ask the computer to use those constraints to answer questions about things you want to know.

For today’s practice, I tried to implement a program to play mancala in Prolog – specifically the version of mancala I learned in elementary school day care, which has three seeds per hole (game rules are here). To solve the game, we can generate a tree of possible moves for each state and use minimax with alpha-beta pruning to find the optimal one. The code is here.