Lessons 11–15 · About 60 min per lesson
Enumerating and comparing candidates
Try every feasible option and keep the best under the stated rule.
Lesson breakdown
- Lesson 11
List legal start states and check that enumeration is complete.
- Lesson 12
Reset state and score for each candidate.
- Lesson 13
Enumerate pairs with i < j to avoid duplicates and self-pairs.
- Lesson 14
Apply the tie-breaking rule when several candidates are optimal.
- Lesson 15
Estimate total work as candidates times simulation steps.
Worked example
Try starts 1, 2 and 3. Make only the swap (1,3), then guess shell 3. Which start earns 1 point?
How to solve it
The three end positions are 3, 2 and 1, so only start 1 scores. Repeat the same procedure for multiple rounds.
Assignment
Simulate Shell Game independently from each starting shell, swapping before checking each guess, and return the highest score.
Check your result
For rounds (1,3,3) and (1,2,3), start 1 earns 2, which is the maximum.