~/problems

Problems

Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.

Simulation & OOP design

Simulation

Model the process exactly; watch simultaneous updates and direction arithmetic.

Notes

Recognise it when: the statement describes a process step by step (robots, games, queues, schedules) and n is small enough to just do it.

  • Directions: dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]. Turning right is d = (d + 1) % 4; left is (d + 3) % 4.
  • Simultaneous updates (Game of Life): compute everything from the old state, either into a copy or with encoded states (e.g. 2 means "was alive, now dead").
  • Obstacles as a set of tuples for O(1) checks.

Gotchas: off-by-one on boundaries, updating in place when you shouldn't, and the step count (does "after k steps" include step 0?). Write a tiny example out by hand first.

18 problems

Practical systems

Simulation & OOP design Model the rules precisely, keep it extensible.

Simulation

esc