~/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
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 isd = (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
setof 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
- Basics: robot on a walled grid (state + step loop) basics easy
- Rain barrel log py · c++ · java easy
- Game of Life: in place, then on an infinite board 2 levels Citadel medium
- Walking Robot Simulation py · c++ · java easy
- Spiral Matrix py · c++ · java easy
- 2048 moves and a 64-bit board encoding 2 levels Citadel medium
- OA: Connect-N on an unbounded board 2 levels Jane Street py · c++ · java medium
- Days between two dates (no datetime) Optiver py · c++ · java easy
- Multicore overheat prevention controller Optiver py · c++ · java hard
- Text box formatter Airbnb py · c++ · java medium
- Tetris block drop Databricks py · c++ · java medium
- Popping bubbles until the board settles eBayPinterest py · c++ · java medium
- Riding scooters down the street Pinterest py · c++ · java easy
- Word search in a straight line Uber py · c++ · java medium
- Data labeling task scheduler 3 levels OpenAI medium
- Wrap articles for a narrow screen Airbnb py · c++ · java medium
- Pick the elevator that answers a call Pinterest py · c++ · java easy
- Design Snake Game py · c++ · java easy