Algorithm invariants
What should total be before processing the third item?
Examples
Worked example
Input
Total starts at zero. The first two items are 2 and 3.
Expected output
5
Hints and solution
Hint 1
Write down the starting state and walk through one example by hand.
Reveal worked answer
The invariant says total contains exactly what has already been processed, so it must be 2 + 3.