The Sleep Algorithm: Building Better Rest, One Step at a Time
I can’t quite remember when my first “real” “adult” sleep issues began. It was probably about 10-12 years ago, though, as I was juggling consulting and growing Classroom Champions, give or take. All of a sudden it was taking me a long time, sometimes hours, to fall asleep. And then I was waking up to go to the bathroom once or twice a night. And once I was woken up, I couldn’t shut my brain off from thinking about, worrying about,anticipating what was happening at work and it would take me another hour to fall asleep, if I could at all.
I mentioned it to one of the partners at our consulting firm and to a few others. No one blinked an eye—it was just accepted that this was the territory of the job. It was almost a badge of honor in a way. So I just went with it.
After all, it was just sleep. It’s something I’ve been doing since I was born, billions do it every day. I shouldn’t have to put a ton of effort into it. I could just try a little harder and… it’ll work itself out, it has to.
But my sleep didn’t get better, and eventually, my mental health got worse (and worse.) Lack of sleep wasn’t the kingpin, but it wasn’t not a contributing factor.
Eventually, I had to face the fact: sleep is one of the most important activities in life. Nothing else this crucial goes without scrutiny; even the most basic work projects have plans, timelines, and goals. I needed to stop half-assing it and approach sleep the same way.
Fortunately, my training mindset eventually kicked and I started looking into sleep and how I could actively improve it. People like Matthrew Walker, David Spiegel, Andrew Huberman, and more do impressive work in these areas and strongly influenced my approaches and over time, my efforts paid off. I now my sleep onset latency (the time from laying down and trying to sleep, and actually falling asleep) is lower than ever, I wake up less than I have since my training days, when I do wake up—I generally can fall back to sleep relatively quickly, and my energy levels stay consistent throughout the day.
So, what’s the Problem?
Bad sleep destroys your edge. Six hours of sleep per night for two weeks makes your cognitive performance on par with a blood alcohol level of 0.10%—sleep-deprived is essentially drunk. Less than five hours triples your likelihood of anger or stress, making it harder to stay composed and in control. Run all the leadership development programs you want—if you have a sleep-deprived team, you’d be better off “investing” that money at the Bellagio in Vegas next weekend.
Conversely, good sleep sharpens everything. With seven to eight hours, you retain 40% more information, boosting learning and memory. It also cuts your risk of heart disease by nearly 50% and stroke by 15%. Sleep isn’t just rest—it’s the foundation for mental clarity, emotional balance, and long-term health.
At the Olympics, success wasn’t about focusing on one thing. It came from understanding every part of the process—training, recovery, mental preparation, technology, and teamwork—and how they all fit together. Solving one piece wasn’t enough; we had to focus on the whole algorithm. Algorithms, after all, are sets of instructions designed to process inputs and produce results. Just like Meta tweaks Instagram’s algorithm to boost engagement and revenue, tweaking the inputs in our own lives can lead to better, optimized outcomes.
Sleep works the same way. Tonight’s sleep isn’t just about what you do before bed; it’s built on how you woke up, what you did during the day, and the habits you’ve built over time. You won’t fix tonight with one quick change, but if you commit to building the foundation and tweaking it as you go, the results will come.
The Sleep Algorithm: A System for Lasting Change
The foundation of our sleep algorithm—our Source Code, if we go full Bill Gates—is the circadian rhythm. This built-in 24-hour clock governs not just our sleep but also mood, energy, and hormone production. When aligned, everything clicks: we fall asleep easily, wake up refreshed, and feel focused. But disrupt it—with inconsistent schedules, late-night light, or stress—and we face poor sleep, irritability, and fatigue.
Rooted in biology, the circadian rhythm evolved to help our ancestors survive by syncing behaviors with day and night. Controlled by the suprachiasmatic nucleus (SCN), a tiny brain region, it aligns processes like sleep, metabolism, and body temperature with sunlight. While we no longer rely on it to avoid predators, it still drives our performance, recovery, and well-being—and it’s the foundation of the Sleep Algorithm.
With that, here’s how to adjust your sleep algorithm. I like to think of these things as “chunks” of my day: a few things to do in the morning, a few in the afternoon, and a few in the evenings. The more you do, the more often, the better chances your sleep will improve. Aim for most (or some) of these most of the time. Do that over time and when you miss some, your body won’t skip a beat.
Remember: you can do hard things, and I’m not as bad of a person as you’re about to think I am right now! 😊
Morning Code: Start Strong, Start Intentionally
The first two hours after waking set the tone for the entire day—and night. Choices made during this window either support or disrupt our circadian rhythm. The goal is to optimize the body's algorithm: boost dopamine and cortisol (focus and wakefulness) while suppressing melatonin (the sleep hormone).
Be Consistent in Your Wake-Up Time: Your body thrives on routine, especially in the morning. Waking up at the same time every day reinforces your internal clock, making it easier to fall asleep at night and wake up refreshed.
Tweak to the code: Set a consistent wake-up time, even on weekends, to stabilize your energy and mood. While sleeping in feels great psychologically, it offers little physiological benefit unless you’re severely sleep-deprived. Stick with it—convince yourself the science is right, and you’ll be happier waking early, even on weekends, knowing your weekday sleep will benefit.
Get Outside Early: Sunlight is like a reset button for your body’s clock. Spending 5-10 minutes in natural light first thing in the morning stops melatonin production and boosts cortisol, your natural wake-up hormone. Even on cloudy days, natural light is far more effective than indoor lighting.
Tweaks: The more direct light you get early, the easier it is for your body to regulate sleep and energy. If you had a bad sleep or it’s cloudy, stay outside longer. And remember, windows block most benefits, so get outdoors. In Calgary’s dark, cold winters, I still make it a priority—even if it’s just a few minutes bundled up outside.
Add a Morning Workout: Training in the morning not only reinforces your circadian rhythm but also jumpstarts your day with energy and focus. Exercise boosts cortisol levels naturally, which is key for waking up and staying alert, and it helps align your body’s internal clock for better sleep later. Working out also gives you a good shot of dopamine, the "feel-good" neurotransmitter associated with motivation, focus, and reward. It increases energy and focus for hours after you’re done—helping you manage what I say next. :-)
Tweaks: Keep it simple—10-20 minutes of light cardio, stretching, or bodyweight exercises are enough to signal to your brain and body that it’s time to wake up. If time allows, a full workout is even better, but don’t stress if all you can fit in is something short. Pair this with your outdoor light exposure to double the benefit.
Delay Your Coffee: Caffeine blocks adenosine, the molecule that makes you feel sleepy as it builds throughout the day. Drinking coffee too early masks this natural process and leaves you with that “afternoon crash” feeling.
Tweaks: Wait 1.5–2 hours after waking up for your first cup of coffee. This delay not only clears adenosine naturally but also helps eliminate that dreaded afternoon crash. I get it—delaying coffee isn’t fun at first, but give it five days, and your body will adjust. Also—stop telling yourself you “need” it. You don’t, and you’ll thank yourself when your energy stabilizes throughout the day.
Combining these habits—consistent wake-ups, sunlight exposure, a quick morning workout, and delayed caffeine—will give you a powerful morning routine that sets your body up for energy, focus, and better sleep at night.
During the Day Code: Stay in Rhythm
Daytime habits are about aligning your actions with your body’s natural rhythms while preparing for a smoother evening. All of these are meant to be easily accomplished and will enhance mental and physical performance during the day, not distract from the now to help the later. The goal is to gently signal the algorithm to flip from going up to going down.
Light and Screens: Aim to get as much natural light as possible throughout the day, and minimize interference from screens as the day goes on.
Tweaks: Avoid sunglasses in the morning. After 12pm, use blue-light-blocking glasses or apps to reduce strain from screens and signal to your brain that evening is approaching. Wear your sunglasses all the way up until sunset. Your eyes/brain seeing a setting sun without sunglasses is a key signal that it is time to begin the shutdown process. I have a pair of glasses I use in the first half of the day that don’t have blue blocking, and a pair I use in the second half that do.
Cease Caffeine 8 Hours Before Sleep: A good rule of thumb that you’ll hear is to stop the intake of caffeine ten hours before you plan to go to sleep. I push this one a bit and usually recommend eight hours as it feels more realistic to me for people to have a coffee after lunch, since food in the belly can make us lethargic.
Tweaks: Tinker and track this over time. Make note of your last cup of coffee. There are plenty of apps out there that can do this. I used my Whoop journal to make notes and over time I can determine what does and doesn’t work for me.
Evening Code: Set the Stage for Recovery
Your evening decisions are all about tweaking the algorithm to create the optimal conditions for deep, restorative sleep. Your goal here is to keep your heart rate down and trigger melatonin as bedtime approaches.
A low heart rate at bedtime activates the parasympathetic nervous system, allowing your body to enter deep sleep more effectively. During deep sleep, your body focuses on repairing tissues, flushing toxins from the brain via the glymphatic system, and consolidating memories—key processes that require a calm, low-energy state to function optimally.
Finish Meals Early: Eating late keeps your body busy digesting, which elevates your heart rate and interferes with the first stage of deep sleep—the most restorative part of the night. Stop eating 2-3 hours before bed to let your body shift its focus to recovery instead of digestion.
Tweaks: Every body is different. I am always amazed to see in my Whoop data the “stress” caused in my body if I have solid (non-liquid) meal within an hour or two of bedtime. My recovery—from my HRV to my HR—is always 10-20% worse when I do that. Try different timing, evaluate it, and see what’s best for you. I didn’t believe it until I tried it.
Watch Alcohol and Cannabis Timing: I know plenty of busy people, myself included, who may prefer something to help them slow their brain down as sleep approaches. While these substances might help us relax or fall asleep faster, they disrupt the quality of our deep and REM sleep if they affect our heart rate too much as we lay down.
Tweaks: If you want to have that drink or Indica before bed, look to have the last consumption two hours before you plan to fall asleep. The difference between right before bed and a two hour window is likely the difference between your brain entering deep sleep and “cleaning up” after a long day, and not.
Wind Down with Purpose: Transitioning into sleep mode takes time. Activities like journaling, light stretching, or reading can help lower your heart rate and reduce stress.
Tweaks: Avoid screens and work in the last 1-2 hours before bed to give your mind and body time to settle. Remember,light turns off melatonin production, so keep the lights low
Cool Down: Your body’s core temperature naturally drops at night to support deep sleep. A cooler environment helps this process. This is also the reason we often give babies a warm bath before sleep to set their routine—warming the body slightly will trigger our core to cool, stimulating sleep.
Tweaks: Keep your bedroom between 16-20°C (60-68°F) or use cooling bedding to promote better sleep quality. We use an Eight Sleep for this and it’s what I recommend to anyone struggling with any temperature-related sleep issues. It turns on and warms the bed an hour before bedtime, senses you falling asleep, and automatically cools your bed, pushing your body and brain into deep sleep more efficiently.
The Takeaway
I’ll never again be caught in the trap of—”Oh, everyone has sleep issues, it’s just part of the deal.” Better to think of sleep sleep like an algorithm that you can tweak, adjust, and refine — just like you would a big project at work.
Each tweak you make, whether it’s delaying your coffee, getting more morning light, or adjusting your evening routine, changes the outcome. By understanding these levers and how they work, you can design a system that helps you sleep better, perform better, and feel better every day.
- Steve