๐ WAYPOINT LESSON
Elimination as arithmetic
โญโญโญ advancedโณ 10 min read๐ Lesson 174 of 256
Kill options in order: type-impossible, bounds-impossible, trace-impossible โ then pick the survivor needing no invisible code.
Elimination is arithmetic on your uncertainty. Kill options in this order:
- Type-impossible: an
intmethod returning aString; an option with a value the return type cannot hold (e.g. 3.5 for int). - Bounds-impossible: a value outside the achievable range (a sum of positives reported as negative; an index โฅ length).
- Trace-impossible: run two iterations of the loop mentally โ any option that disagrees with iteration 2 is dead regardless of the rest.
After elimination, if two options survive, ask what code would have
to say for each to be true. Usually one requires the loop to do
something the visible code does not (<= instead of <, remove
instead of skip). Pick the survivor that requires no invisible code.
Careless-mistake insurance: on questions with a "boundary" feel
(empty, single element, last index), check your answer against that
boundary before committing. Most lost points are not hard reasoning;
they are < answers on <= questions.