Gamified challenge · BFS over states
Each row of level is a string: # is a wall, . is floor, P is the worker, C the crate and T the target mark (floor). The worker moves one cell U, D, L or R per move. Walking into the crate pushes it one cell the same way, which only works if the cell beyond it is floor (or the target). The worker can't walk through walls or pull the crate.
Write pushMoves(level) (Python: push_moves(level)) that returns the worker's moves as a string so that the crate ends on the target, using the fewest moves in total (walking steps and pushes each count 1). Any shortest answer passes. If the crate can never reach the target, return "impossible".
Example: ["######", "#T.CP#", "######"] → "LL": both moves push the crate left, and the second puts it on T.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google