← BlogMISTAKES — 24 Apr 2026

My Most Frequent Bug Isn't a Bug, It's a Typo

Eight logged occurrences and climbing — my most common mistake category isn't a misunderstood algorithm, it's my fingers moving faster than my eyes.

CategoryMistakes
Published24 Apr 2026
Reading time6 min
dsapythonsyntax

I keep a mistakes log next to my practice problems — categories and counts, because I've learned not to trust my own gut feeling about what's actually going wrong. This week I sorted it by frequency for the first time. Top category wasn't recursion, wasn't off-by-ones, wasn't anything I'd call an actual algorithm mistake. It was syntax and typos. Eight occurrences and counting. I wrote next to the count: "the trend to watch — keeps climbing." Kind of embarrassing, keeping a running tally of your own dumb mistakes that only goes up.

The pattern

Every single one of these eight is the same shape: I understood the approach completely, sometimes even wrote the correct plan in a comment right above the line, and then typed something adjacent-but-wrong anyway. Wrong bracket. Wrong sign. Wrong case. Wrong variable, one letter off from the right one. None of these are me not understanding the problem. It's just my hands moving faster than my eyes were reading, over and over.

Where it kept showing up

4Sum II, twice in the same solve. First: window_count(s[right]) where I meant window_count[s[right]] — parentheses where a dict needed square brackets, so Python tried to call a dict like it was a function. Second, a few lines later in the same function: hashmap[summed] instead of hashmap[-summed]. Dropped a minus sign in a lookup that only works because of that minus sign. The algorithm — pair sums, complement lookup — was correct in my head the whole time.

Valid Anagram: return false. Lowercase. My hands still default to whatever language I used right before this one, and Python's capitalized False doesn't survive that autopilot.

Contains Duplicate: set.add(i) — calling .add() on the type name set itself instead of on the actual set instance I'd created a few lines earlier. Reads like a normal method call at a glance, which is exactly why I didn't catch it.

Ransom Note: a loop header, for key, values in counts.items():, then a body that references value a few lines down. Plural in the declaration, singular everywhere I actually used it. It did crash — a NameError, value is not defined — just not where I expected. Python pointed at the line that used it, not the loop header where the actual typo lived, so I spent longer than an outright crash should take tracing it back to the mismatch.

Missing Number, also twice. Gauss's formula written as n*(n+1)//n instead of n*(n+1)//2 — a stray variable sitting exactly where a constant belonged, like my hand grabbed the wrong key off the same row. And separately, in the accumulator a few lines below: actual += 1 instead of actual += i. That one's the quietly worse of the two, because actual += 1 still runs. It doesn't error, it doesn't crash, it just adds up the wrong thing and hands back a wrong number that looks perfectly fine.

Boats to Save People had its own round of these too — nothing as individually interesting as the ones above, just the general tax of typing fast under a two-pointer loop I was also debugging for other reasons at the same time. Same category, less remarkable specifics.

The fix

No algorithm fix helps here, since none of this is an algorithm problem. What I'm trying now: before I run anything, read it back line by line like I'm the interpreter, not like I'm the person who just wrote it and already knows what it's supposed to say. Reading it as the person who wrote it, I just see what I meant — that's basically the whole problem, it's why I keep not catching these. I'm trying to do this before running the code, not after it fails, because once it's already failed I'm primed to go looking for something more interesting than a typo, and I'll walk right past the actual line. Whether I do this consistently or just when I happen to remember, I honestly don't know yet.

The lesson

"Syntax bug" sounds like the least serious thing you could write in a mistake log, which is probably exactly why I never took it seriously until it hit eight. It doesn't feel worth being careful about until it's already cost you eight debugging sessions and earned its own line item. The one habit I'm supposedly holding myself to now: after writing any line that indexes, negates, or compares something, say out loud what it actually does — "this negates the sum before the lookup," "this indexes the dict, doesn't call it." Every one of these eight would've been caught by a sentence I never bothered to say to myself. Whether I'll still be saying these sentences out loud two weeks from now, instead of quietly dropping the habit like I've dropped others, is a different question, and I don't have a good answer to it yet.

← Four Ways I Got a Two-Pointer Loop's Bookkeeping WrongThe Concept I've 'Solved' Twice and Still Don't Fully Trust →

Notes from readers

Comments — via GitHub