The state of mind for solving technical problems
The hardest part of a technical problem is often not in the code. I checked the famous studies one by one: what holds up, what is a myth, and what chess has to say about debugging.
My about page says “Problem solver, occasionally problematic.” This post is about the second half. When I am stuck on a technical problem, the code is rarely the only thing in the way. Most of the time the obstacle sits behind my eyes.
Before writing this I went through the studies people quote on this topic: the original papers, the replication attempts, the meta-analyses. Some held up. Some are much weaker than the internet suggests. One or two did not survive at all. I say which is which as I go, because the last thing anyone needs is another productivity post built on myths.
The first idea is the enemy
The water jars
In 1942 Abraham Luchins gave people three jars (A, B, C) and asked them to measure an exact amount of water. The first few problems all had the same answer: B - A - 2C. With jars of 21, 127 and 3, you get 100 by filling B, then pouring off A once and C twice.
Then came problems that the long formula still solved, but that also had a much shorter answer, A + C or A - C. Jars of 15, 39 and 3, target 18: just 15 + 3. Most people who had done the earlier problems kept using the long formula. A control group that had not done the warm-up saw the short one.
Luchins called it the Einstellung effect, from the German for “setting” or “attitude”. Once the brain has a method that works, it stops looking for a better one.
Chess masters fall for it too
It would be comfortable to call this a beginner’s problem. Merim Bilalić, Peter McLeod and Fernand Gobet tested it on chess players: Candidate Masters, Masters and International Masters. The task was to find the shortest checkmate. The position had two. One was the smothered mate, a pattern every trained player knows, in five moves. The other was less familiar and took three.
Many of the players who found the familiar mate did not find the shorter one. By the authors’ estimate, the familiar solution dragged the experts down to the level of players about three standard deviations weaker. In chess terms that is a canyon. Grandmasters all found the short mate in that particular position, but showed the same effect in positions where the better solution was harder to see. The overall finding: more expertise means less Einstellung, not none.
The best part came from eye tracking. The players said they were looking for a better solution. Their eyes kept going back to the squares that belonged to the first idea. They sincerely believed they were searching. Their attention had already been captured.
The developer version: you have seen this kind of error come from the cache twenty times. The twenty-first time you open the cache logs, find something (logs always contain something), and spend the afternoon digging in the wrong place. Experience makes you fast, and it also points your eyes.
The box problem
In 1945 Karl Duncker described a related block, functional fixedness. People get a candle, a box full of thumbtacks and matches, and have to fix the candle to the wall so the wax does not drip. The answer is to empty the box, pin it to the wall and use it as a shelf. People who receive the box full of tacks see a container and struggle to see a shelf. People who receive the tacks and the empty box separately find the answer more easily. (Everyone calls it the candle problem. Duncker called it the box problem.)
In software it sounds like “Redis is the cache”, “logs are for debugging”, “that table is for reports”. Once a tool is stuck in one role, it is hard to see it in another, and the answer is often in the other role.
Stress switches off the part you need
Two in the morning, production is down, the client is calling. This is exactly when you need your prefrontal cortex: working memory, planning, holding attention where you put it. In a 2009 review in Nature Reviews Neuroscience, Amy Arnsten pulled together how stress signalling weakens that region. Her summary: even quite mild uncontrollable stress quickly impairs prefrontal function, in animals and in people. The same signals strengthen the emotional responses of the amygdala. The planner goes quiet and the panic department gets louder.
The key word is “uncontrollable”. So my first move in an incident is not technical. It is making the situation feel controlled: write down what I know and what I do not, note the time and the first symptom, test one hypothesis at a time. That does not end the chaos, but it tells the brain that someone is driving.
“A little stress is good for you”
Everyone backs this up with the Yerkes-Dodson law: an inverted U, moderate arousal is best. I read the 1908 paper. Robert Yerkes and John Dodson trained 40 dancing mice to choose between a white box and a black box, with an electric shock for the wrong choice. When the difference was easy to see, the strongest shock gave the fastest learning. As the discrimination got harder, the best results moved to weaker shocks. In their own words, a difficult habit may be acquired readily only under relatively weak stimulation.
So it is a finding about mice, shocks and habit formation. In 1994 Karl Halvor Teigen traced what happened to it afterwards and showed how later authors kept changing what the variables meant, then credited those changes to Yerkes and Dodson. His title says it all: “a law for all seasons”. My practical takeaway is simple. On a hard problem, manufacturing a panic deadline does not help. The 1908 mice would agree.
Flow is a set of conditions, not magic
Mihaly Csikszentmihalyi’s flow is the state where you are so absorbed that time disappears. In his description it has conditions: clear goals, immediate feedback, and a challenge that matches your skill. When I debug, I build those conditions on purpose:
- A clear goal. “Fix everything” is not a goal. “Make this test pass” is.
- Immediate feedback. A small test or script that reproduces the bug in seconds. When every check takes five minutes, you do not get flow, you get waiting.
- The right difficulty. If the problem is too big, I split it. If it is too easy, my attention drifts, and that is where the silly mistakes live.
Candidate moves, and Kotov’s syndrome
In Think Like a Grandmaster (English edition 1971), Alexander Kotov describes a way to calculate: list your candidate moves first, analyse each one once, then compare where they lead. It has critics. Some strong players say nobody really thinks that rigidly during a game. The core idea still holds, and it lines up with what Bilalić found: write down the alternatives before you fall in love with the first one.
Kotov’s name is also attached to a failure mode, Kotov syndrome: a player calculates for ages, cannot decide, runs short on time and finally plays a move they never checked at all. The developer version is three hours of analysis followed by an untested “fix” pushed to production at four in the morning. I know what four in the morning looks like, I have written about it on this blog. That is why I recognise the syndrome.
My debugging version:
- Before I test the first hypothesis, I write down at least three.
- For each one I write what would disprove it. If you only look for confirmation, your eyes do what the chess players’ eyes did.
- I start with the cheapest one to check, not the one I believe most.
Is your move safe?
Chess coach Dan Heisman asks a simple question in his book Is Your Move Safe?: a move is safe if your opponent has no forcing reply that wins material or gives mate. His blog version: can my opponent play a check, capture or threat that I cannot meet?
Before every deploy I ask the same thing. What does this change touch, who calls it, can I roll it back? Especially with database migrations. A move you cannot take back is the most expensive kind, on the board and in production.
When you are stuck: the duck, the break, the pillow
The rubber duck
In The Pragmatic Programmer (1999), Andrew Hunt and David Thomas tell the story of a programmer who, when stuck, explained the code line by line to a rubber duck. Explaining forces you to say your assumptions out loud, and halfway through a sentence like “and this variable is…” you often stop yourself. To be fair, this is practitioner wisdom, not a lab result. But it is free and it works. A colleague, a notebook or a half-written question can play the duck.
The break (incubation)
“Go for a walk and it will come to you.” The most serious source on this is a 2009 meta-analysis by Ut Na Sio and Thomas Ormerod covering 117 studies. The effect is real, but small to medium, and it depends on conditions:
- It works better after real effort. A longer preparation period gave a bigger effect. Looking at a problem for five minutes and then going for a walk is not incubation, it is escape.
- A demanding task during the break shrinks it. Switching to another hard bug is not a break.
- A light task (walking, washing the dishes) beat complete rest on verbal insight problems.
Sleep
Ullrich Wagner and colleagues’ 2004 Nature paper “Sleep inspires insight” gets quoted a lot, so I read the numbers. 66 people practised a digit task with a hidden shortcut. Then came 8 hours of either night sleep, night wakefulness or day wakefulness. In the sleep group 13 of 22 (59.1%) discovered the hidden rule. In each wake group it was 5 of 22 (22.7%). The detail people skip: without the initial practice, sleep did not help (25%).
It is not all good news. In 2018 Monika Schönauer and colleagues tested classic insight problems and magic tricks: 77 participants, 3 hours between sessions, sleep or wake. Sleep changed neither the number of solutions nor the number of “aha” moments.
So sleep can help when you have loaded the problem into your head first, and not for every kind of problem. “I will sleep on it and it will be solved” is not a guarantee. Pushing a fix to production at four in the morning on a tired brain, though, is Kotov syndrome in its purest form.
Mood
In 1987 Alice Isen, Kimberly Daubman and Gary Nowicki showed that a few minutes of a comedy film, or a small bag of candy, improved performance on Duncker’s box problem and other creative tasks. In 2009 Karuna Subramaniam, John Kounios and colleagues used fMRI and found that people in a better mood solved more problems, and solved more of them by insight. The anterior cingulate cortex responded both to mood and to insight.
None of this means “force yourself to be happy”. It does mean that debugging while angry, already drafting who to blame, is the worst option the research gives you.
Myth check: the willpower battery and unfinished tasks
“I am out of willpower.” For years, ego depletion theory said self-control works like a battery that drains with use. In 2016 a preregistered replication ran across 23 labs with 2,141 participants. The effect came out at d = 0.04, with a confidence interval that includes zero. Fatigue is real, nobody doubts that. The battery story is weak. “My willpower ran out” is a comfortable explanation for being stuck, but more often the real cause is a wrong hypothesis you have not let go of.
“Unfinished tasks stick in memory better.” That is the Zeigarnik effect, and it is everywhere. In 2025 Romain Ghibellini and Beat Meier published a meta-analysis. The memory advantage for unfinished tasks did not hold up. What did hold up is something else: people tend to go back to interrupted tasks (the Ovsiankina effect). So stopping mid-task does not make you remember it better, but it does pull you back. That is why I always leave one line where I stop: the next step.
Afterwards: look back
In How to Solve It (1945), George Pólya splits problem solving into four phases: understand the problem, make a plan, carry it out, look back. The last one is the one everybody skips. Tests pass, ticket closed, next.
That is where I learn the most. When I reread my old JavaScript and Python versions for the post on read-only data, both had holes. In the post on optimising duplicate elements across lists, I found three problems in my old code, one of which made it take 72 seconds on my server. Chess players call this post-game analysis. Going through a game you lost is not fun. It is the cheapest way to win the next one.
My routine
| Phase | What I do |
|---|---|
| Before | Write the problem in one sentence. Separate what I know from what I assume. Build the smallest test that reproduces it. |
| During | At least three hypotheses. For each: what would disprove it? One change at a time. Before deploying: is this move safe? |
| Under stress | Make it controlled: a timeline, the symptoms, one hypothesis. No panic deadlines. |
| Stuck | Explain it line by line to the duck (or a person). A light break after real effort. Sleep on a problem I have actually loaded. No debugging while angry. |
| Stopping | One line: what is the next step. |
| After | Look back: what did I wrongly assume, and how do I catch it faster next time? |
Problems find me, and I find them. I collected the technical problems I meet most often in businesses in a separate post. If you have one whose answer is not on the first page of search results, have a look at hire me or get in touch.
Sources
- Luchins, A. S. (1942). Mechanization in problem solving: The effect of Einstellung. Psychological Monographs, 54(6). doi:10.1037/h0093502
- Bilalić, M., McLeod, P., Gobet, F. (2008). Inflexibility of experts: Reality or myth? Quantifying the Einstellung effect in chess masters. Cognitive Psychology, 56(2), 73-102. PubMed
- Bilalić, M., McLeod, P., Gobet, F. (2008). Why good thoughts block better ones: The mechanism of the pernicious Einstellung (set) effect. Cognition, 108(3), 652-661. doi:10.1016/j.cognition.2008.05.005
- Duncker, K. (1945). On problem-solving. Psychological Monographs, 58(5). doi:10.1037/h0093599
- Arnsten, A. F. T. (2009). Stress signalling pathways that impair prefrontal cortex structure and function. Nature Reviews Neuroscience, 10(6), 410-422. doi:10.1038/nrn2648
- Yerkes, R. M., Dodson, J. D. (1908). The relation of strength of stimulus to rapidity of habit-formation. Journal of Comparative Neurology and Psychology, 18(5), 459-482. Full text
- Teigen, K. H. (1994). Yerkes-Dodson: A law for all seasons. Theory & Psychology, 4(4), 525-547. doi:10.1177/0959354394044004
- Csikszentmihalyi, M. (1990). Flow: The Psychology of Optimal Experience. Harper & Row.
- Kotov, A. (1971). Think Like a Grandmaster. Batsford.
- Heisman, D. Is Your Move Safe? and Avoiding the big mistake
- Hunt, A., Thomas, D. (1999). The Pragmatic Programmer. Addison-Wesley.
- Sio, U. N., Ormerod, T. C. (2009). Does incubation enhance problem solving? A meta-analytic review. Psychological Bulletin, 135(1), 94-120. doi:10.1037/a0014212
- Wagner, U., Gais, S., Haider, H., Verleger, R., Born, J. (2004). Sleep inspires insight. Nature, 427, 352-355. doi:10.1038/nature02223
- Schönauer, M., et al. (2018). Sleep does not promote solving classical insight problems and magic tricks. Frontiers in Human Neuroscience, 12, 72. doi:10.3389/fnhum.2018.00072
- Isen, A. M., Daubman, K. A., Nowicki, G. P. (1987). Positive affect facilitates creative problem solving. Journal of Personality and Social Psychology, 52(6), 1122-1131. doi:10.1037/0022-3514.52.6.1122
- Subramaniam, K., Kounios, J., Parrish, T. B., Jung-Beeman, M. (2009). A brain mechanism for facilitation of insight by positive affect. Journal of Cognitive Neuroscience, 21(3), 415-432. doi:10.1162/jocn.2009.21057
- Hagger, M. S., et al. (2016). A multilab preregistered replication of the ego-depletion effect. Perspectives on Psychological Science, 11(4), 546-573. doi:10.1177/1745691616652873
- Ghibellini, R., Meier, B. (2025). Interruption, recall and resumption: a meta-analysis of the Zeigarnik and Ovsiankina effects. Humanities and Social Sciences Communications, 12, 962. doi:10.1057/s41599-025-05000-w
- Pólya, G. (1945). How to Solve It. Princeton University Press.