Why this is O(1)

Why O(1). in on a Python set is an amortised hash lookup — average case constant time, regardless of how many admins there are. Lookups on list (user_id in admin_list) would be O(n) and a common confusable.

Watch for. If admin_set is small enough to be authored as a literal {...}, it's still a set — Python doesn't switch to a list under the hood. The data structure choice in the *call site* is what determines complexity here.

How to recognize constant complexity in the wild

O(1) means the runtime doesn't grow with the input at all. Dictionary lookups, array indexing, single-line arithmetic — the input could be ten or ten million and the work is the same.

The eight rungs of the ladder

Big-O classifies the asymptotic growth of a function, not the wall-clock time. The ladder Bugdle uses has eight rungs ordered from cheapest to most ruinous: O(1), O(log n), O(n), O(n log n), O(n²), O(n³), O(2ⁿ), O(n!). The puzzle's answer sits at rung 1 of 8. The four-guess budget plus higher/lower hints means the puzzle is solvable in at most ⌈log₂(8)⌉ = 3 perfectly-read guesses; the fourth attempt absorbs misreads of the snippet.

Common confusables

Nested loops aren't automatically quadratic — the inner loop has to range over n, not a constant. A loop that always runs ten iterations is still O(1) work per outer iteration. Similarly, a recursive function isn't automatically exponential just because it calls itself twice — if the recursion has overlapping subproblems and you memoise, you collapse back to polynomial. Always ask: what does n really mean here, and how many distinct subproblems are there?

External reference: Big O notation — Wikipedia.