Programmers guide to weight loss

I lost 44 pounds in the last 6 months. I did it without a diet or going hungry. I used basic methods that are known to most programmers for optimizing my behavior.

Here is a short guide to optimizing yourself into losing weight.

Screen Shot 2015-10-12 at 6.25.32 PM

Will power == CPU cycles

This is one of ourunderlying assumptions: You want to spend as little will power as you possibly can, when making a decision about your eating choices. The more will power you spend, the less likely you are to succeed with losing weight.
Will power, like CPU cycles, is a limited resource, if every day you need to spend a lot of it in order to keep your weight, you will always fail at one point or onother. Not only that, will power is a shared resource – so if you spend it on going to the gym, you have less for other things.

ive-come-to-the-conclusion-that-the-shower-curtain-is-a-magical-doorway-to-the-land-of-willpower-ass-100541

The common diet algorithm
The commonly used diet algorithm looks something like this:

Map thingsICanNotEat = ...
Int willpower = ..
function boolean canIEatThis(sugar){
  if(thingsICanNotEat.contains(sugar) and willpower>0){
    willpower --
    return False 
  }
  return True
}

f_361de420df

This is described in Nir Eyal’s blog post about fitness apps. After having lunch with Nir, I came up with a new algorithm.

The optimized version that does not spend will power
Here is algorithm I used:

static final boolean _canEatSugar = False

function boolean canEatSugar(){
  return _canEatSugar
}

Wait… what happened to will power?

ytpj63

Well apparently, if you have static final variables (yes, contradiction in terms) you do not need to spend will power. This is the main hack of our minds – If you chose not to eat something because you hate it, or you are allergic to it, or it is against your religion, then you do not need to spend will power as you would with a dynamic type diet.

My hack definition

static final boolean canEatSugar = False
static final boolean canEatPasta = False
static final boolean canEatRice = False
static final boolean canEatWheat = False

I spent zero will power to maintain my eating habits, I chose things I can do without and took them away. I eat food I love (meat, fish, veggies, cheeses) and never go hungry. I do not second guess myself and never spend will power. My programming is in the static final identity level.

This way I never run into this:

willpower

And I work for Google :)

Final optimization – walking meetings

We all have 1:1 meetings, sync meeting and other “useful” meetings in our life – I turned most of my meetings into walking meeting. benefits include: no presentations, more effective outcomes, and usually shorter meetings.

Simply put:

funny-weight-loss-meme-image-quote-300x222

Conclusion

Moving our preferences to the identity level, declaring things as final, changes our will spend and makes our choices easier. You still need to have conviction, but you are not second guessing yourself all the time.

Share the love...Tweet about this on TwitterShare on LinkedInShare on Google+Share on Facebook

Amir Shevat

Amir Shevat is the global Startup Outreach lead in Google Developer Relations (g.co/launch). Previously, Amir Led Google Campus Tel Aviv and was the co founder of several startups.

You may also like...

4 Responses

  1. Oren says:

    Wow. You look different :)
    Great job ! I liked the post even that I’m not coding…
    Thanks for sharing

  2. Lior says:

    How does one address variables that are slightly more complex?
    Maybe wheat is actually an object and it’s type might vary the result?
    Inother words – how do you cover the edge cases for wholeWeat and wholeRice?

Leave a Reply to Amir Shevat Cancel reply

Your email address will not be published. Required fields are marked *