USACO Bronze students often ask, "What algorithm is this?" A better first question is: "Are the constraints small enough to try every possibility, or does the story require step-by-step simulation?"
Simulation pattern
Simulation problems describe changes over time. The code should model the state and update it for each event. Examples include moving objects, changing scores, or processing a list of commands.
position = 0
for command in commands:
if command == "L":
position -= 1
else:
position += 1
Complete search pattern
Complete search tries every candidate answer when the search space is small. This is common when the input constraints make brute force acceptable.
best = 0
for a in range(n):
for b in range(a + 1, n):
score = evaluate(a, b)
best = max(best, score)
How to decide
- If the problem says events happen in order, think simulation.
- If it asks for the best choice among many small options, think complete search.
- If constraints are large, look for sorting, counting, or a stronger pattern.
Practice prompt
Create two tiny examples for a Bronze problem before coding: one where the answer is obvious, and one edge case. If the solution fails either tiny case, fix the reasoning before writing more code.
