OneBug
Bug of the week #46 new bug every Thursday write-ups

A weekly bug-spotting puzzle for developers.

One hidden bug. Click the line you suspect. See your time and where the community guessed. Every bug comes with a full write-up: the rule it breaks and the fix.

Spot the bug Python
1
# Build the leaderboard: each team's average score, in whole points.
2
scores = {"red": [2, 3], "blue": [3, 4], "green": [4, 5]}
3
board = {}
4
for team, pts in scores.items():
5
    avg = sum(pts) / len(pts)
6
    board[team] = round(avg)
7
ranked = dict(sorted(board.items(), key=lambda kv: -kv[1]))
8
print(ranked)
9
# expected: {'green': 5, 'blue': 4, 'red': 3}
10
# actual:   {'blue': 4, 'green': 4, 'red': 2}  (!)

Read the full write-up for this bug (spoilers)

One email a week. The bug, the median, nothing else.

Why these bugs bite

write-ups

Every bug on this site gets a full article: the exact language semantics, why it bites in real code, and the fix.

All write-ups ->

Put your own bug in your blog

Paste your own code, mark the bug, and get one script tag that drops the puzzle into your post or docs. Readers solve it inline; the share card brings them back.

create your own puzzle
  1. Get an embed key.
  2. Paste your code and mark the bug in the editor.
  3. Drop the <script> tag into your post.

No spam. One key per blog. The full editor (paste your code, mark the bug) opens once your key is active.

what you'll paste
<script src="https://onebug.dev/embed.js" data-puzzle-id="your-id" data-theme="auto" async></script>

Carries "Powered by OneBug" and links readers back to your puzzle.

Why I built this

I read code review like other people read crosswords. So I built one bug, one shot, and shipped it in public - no funding, no roadmap deck, just a puzzle a week and the numbers behind it.

- Robert · @rsz_me · building OneBug in public.

Past bugs

free · playable
#44 The config that loads and never applies (Go) 0 solved #43 The failed-payment report that includes a success (SQL) 0 solved #42 Three timers, one announcement (JavaScript) 0 solved #41 The template that changes when its copy does (Python) 0 solved #40 The name that measures one character too long (Go) 0 solved #39 The pass rate that rounds everyone to zero (SQL) 0 solved #38 The stock total that comes back zero (JavaScript) 0 solved #37 The handlers that all report the last error (Python) 0 solved #36 The tally that crashes when the workers pile on (Go) 0 solved #35 The average discount that reads too high (SQL) 0 solved #34 The waiting count that loses whole customers (SQL) 0 solved #33 The word count that dies on the first word (Go) 0 solved #32 Regulars that look like one-time buyers (SQL) 0 solved #31 The invoice that never settles (JavaScript) 0 solved #30 The pending items that won't all clear (Python) 0 solved #29 Quantities that turn into NaN (JavaScript) 0 solved #28 The products that vanish from the report (SQL) 0 solved #27 Five hundred workers, fewer results (Go) 0 solved #26 Greeters that all greet the last guest (Go) 0 solved #25 The parser that always reports an error (Go) 0 solved #24 The override that rewrites the defaults (Python) 0 solved #23 The port check that passes only sometimes (Python) 0 solved #22 One survey answers for another (Python) 0 solved #20 The copy that usually works (C) median 9.7s #19 The duplicate that slips through at 700 (Java) median 9.8s #18 The servers that never get healthy (Go) median 20s #17 The query that finds nobody (SQL) median 2.6s #16 Filenames that lose more than .txt (Python) median 3.1s #15 The cheapest deals, sorted wrong (TypeScript) median 0.7s #6 The search that crashes on big arrays (Java) median 6.2s #5 The bounds check that waves it through (C) median 16s #4 The filter that eats its input (Go) 0 solved #3 Revenue that looks too good (SQL) median 27s #2 The discount counter that keeps counting (Python) median 21s #1 The round-robin split that never splits (TypeScript) median 32s