Have You Tried Turning Your Brain off and Turning It Back on Again?
As someone who last attempted a math problem when I was around 16 years old, and began coding with no STEM (Science, Technology, Engineering and Mathematics) background at all, I have, until recently, always perceived computer science, along with every other science, as the binary opposite of creativity.
Scientists follow strict rules and understand complex formulas that leave no room for mistakes, while creatives draw outside the lines and generate new and fresh ideas. You either got science right or wrong, whereas the merit of creative output rested in its perception.
However, the more I code, the more I appreciate the practice as a vessel of creative expression. There is almost always more than one way to deliver the solution the problem presents. In fact, the more complex the problem is, the greater the number of possible solutions become available, and thus the greater the scope for creativity is afforded to the coder.
Though scope for creativity exists in abundance, capturing and channeling it proves to be a little more tricky. My own experience chimes with almost everyone that I talk with on the subject: The majority of time spent coding is spent not being creative.
Instead, it’s spent feeling at best perplexed, and at worst, torturously frustrated. Coding sessions are usually characterized by long periods of wheel-spinning and stagnation, until they’re suddenly punctured by a glorious breakthrough. And by god is it glorious.
You how you can tilt science in your favor, and—with very little effort—enjoy a few more of those triumphant victories that you spend hours working for.
When solutions do manifest, they very much manifest in bursts—in “eureka” moments (I’ve detailed more than a few of these on my own personal blog, Godsell Explains).
What feels like a stroke of genius, or even luck, may sway the coder to think that chance is a big factor in determining their progress.
Put the Hours in
As part of my coding practice, I use a website called Codewars. The site contains tiers of challenges that get incrementally harder as you progress. Before long, the complexity of the challenge means they are rarely completable in one sitting, with some taking me upwards of 9-10 hours.
As coding is not yet my full-time vocation, I am still holding down a nine to five, meaning all my coding is reserved for evenings and weekends. I reserve Saturday mornings in particular as a sacred time for my personal ritual of uninterrupted coding practice. On most days I code up until I go to sleep. Recognizing that I work to a particular schedule made me notice a slightly more subtle pattern.
I noticed that the times I would get most frustrated with solving a problem were typically evenings where I had been staring at the same problem for hours—whilst most likely at least a little fatigued from the day’s work.
Conversely, I noticed that I could revisit the same problem the following day or two and see it from angles that never seemed to occur to me during the last attempt.
A Good Night’s Sleep
This pattern urged me to read up on the impact of sleep on creativity. Already knowing a little about the (seemingly endless) benefits of good quality sleep from Chris Winter’s book The Sleep Solution and Matthew Walker’s book Why We Sleep (as well as one or two Simple Programmer blog posts), I hypothesized that there would be some causality.
My research brought me to a study undertaken by Denise J Cai. The aim of the study was to determine if sleep, in particular REM (Rapid Eye Movement) sleep—the deep sleep that invokes dreaming—could enhance your capacity for creative problem solving.
The study involved 77 participants. Each was required to take Remote Associates Tests (RATs). The tests involved the participant being presented with three different words, for example “cookie,” “sixteen,” and “heart,” and being asked to think of another word that linked all three together—for example “sweet”.
All participants began by taking their respective RATs once in the morning. After their morning session, one group slept for around 90 minutes, while the other listened to relaxing music whilst awake.
In their afternoon session, some participants were given the same tests i.e the exact same problems they were given in the morning. Some were “primed,” i.e. some of the answers to their morning tests were the same answers to different questions in their afternoon tests. Others were given completely unrelated tests.
If you’re exposed to a problem, you may begin piecing together a solution to it subconsciously whilst sleeping.
The sleeping group used brain activity monitoring equipment to determine the type of sleep the participant was experiencing. The results of the study showed that those who experienced REM sleep and were primed in the morning did better in the afternoon tests, whereas the non-REM sleep group and the rest group did not. When the morning and afternoon tests were unrelated, no group displayed improved results.
The results of this study suggest that if you’re exposed to a problem, you may begin piecing together a solution to it subconsciously whilst sleeping. As you’re asleep, you can’t be actively trying to work through it, but because your brain has already been exposed to the concept, it cannot help but try and muster up an answer.
Though the sample size is relatively small, and the findings are far from irrefutable, they certainly ring true with my anecdotal experiences.
Sleep Your Way to the Answer
I’m sure you’ve hit hurdles that seem insurmountable, and it can feel overwhelmingly tempting to scrap everything and return to the drawing board out of pure frustration.
Sleep on it. I’ve really surprised myself with the breakthroughs I’ve managed after getting back on my horse feeling refreshed by a solid night’s sleep. That’s not saying you should sink three years into a single function/challenge/solution, but at least give it one night’s worth of your subconscious’s attention.
Another phenomenon I began noticing was that sometimes, the new angle wouldn’t arrive in my mind at a time when I was sitting down trying to think of it, or even when I was thinking about coding at all.
Instead, it would pop into my mind when I was doing something mundane, mindless, and completely unrelated, for example whilst I was at the gym or in the shower.
This led me to another study; a 2018 article from the journal Sleep by Svenja Brodt, et al. The research studied sleep’s impact on creative problem solving with a slightly different approach than Cai’s.
Instead of using RATs, the study tasked 62 participants with solving three different types of problems—classical riddles, visual change detection, and anagrams. Like Cai’s, the study included a break period (of three hours), but this time it was only given to one group of the participants.
Some of this group used the break to sleep, whilst others stayed awake. The other group didn’t have a break period; they attempted to solve their set of problems once, and then tried them again immediately after.
Though there were no discernible differences between the two groups on the visual change detection or anagram solving tests, the results showed a positive impact on the ability of the participants who took a break to solve classical riddles. Interestingly, whether the participants who took a break used their time to sleep, or just to rest, seemed to be irrelevant—they both saw improvements.
The authors of the article conclude that the results support the notion of an “incubation” period being able to positively enhance your creative problem solving capacity. They posit that it is not sleep per se, but the presence of an incubation period that is the crucial variable.
According to the study, an incubation period allows for “unconscious processing that fosters spreading activation along associated networks” and “restructuring of problem representations.”
More simply, the mind can go some way to generate possible solutions by its own volition whether you’re awake or asleep, but the solutions take some time to gestate and develop.
Turn Your Brain “Off”
Considering both studies’ findings, it may not necessarily be sleep that enables your sharpest thinking, but instead anything that allows you to turn your brain “off” for a little while.
With this in mind, here are a few life hacks that should enable you to optimize your brain’s impressive and overlooked quirk.
First, and most obviously, is to make sure you get a good night’s sleep. Go to bed feeling tired, as that usually means you have woken up early that day. If you are a night owl, wake up super early one day, grind through the day feeling exhausted and I guarantee you’ll sleep like a baby that night. You’re now in a virtuous sleep cycle. Stick to it.
Another great tip here is to change the settings on your laptop and smartphone to filter out blue light from around sundown, as blue light can mess with your circadian rhythm.
Try not to drink caffeine any later than early afternoon, and limit your alcohol intake, as it’s known to be a huge detriment to your quality of sleep, even if you’ve been unconscious the whole night.
Regarding activities, something that works really well for me is going for a walk, usually through a park or green area. This is a great way to get away from your desk, breath fresh air, and do some light exercise. A change of scenery is a great way to induce a change in mindset and sense of “getting away from it all.”
If you’re game for something a little more challenging than walking (and you should be), physical exercise works wonders. Running, lifting weights, team sports—anything that requires you to fully exert yourself.
When you’re straining for that last squat in the set or almost crying with exhaustion during that final mile of your run, your brain cannot focus on anything but its immediate goal of getting there. It’s a great way to pull your brain’s focus off the coding challenge you’ve been grappling with.
Another favorite of mine is taking a bath. Just lying there and staring at the ceiling can bring about a meditative state and completely disengage your hard working brain. I find this particularly effective as the last thing I do before I go to bed.
The Most Productive Thing you do all day!
Coding often requires us to work for long hours, doggedly trying to find a solution to our problem. On such occasions, it may feel tempting to “push for the burn”—to grind out those long hours of mental perspiration.
But this may not be the optimal strategy.
As I’ve shown you in this post, your brain becomes less productive when you don’t get enough rest, when you don’t allow your mind to focus on anything else.
Instead of staying up late glued to your computer, don’t be afraid to go for that stroll, to run a bath or do some pull ups—it might very well be the most productive thing you do all day!