Code RoomShuttle through rotating carousel
HardPrep Room Coding #4904

Shuttle through rotating carousel

CodingAlgorithms & data structuresMid–Staff~35 min

An automated warehouse runs a shuttle across a rectangular floor. Every cell carries a repeating schedule string, and all of the schedules have the same length L. Character t of a cell's schedule is '.' when that cell is clear during minute t and '#' when a rotating carousel fills it, and the schedule repeats forever, so minute t reads character t mod L. The shuttle stands on the top left cell at minute 0. Between one minute and the next it either waits where it is or steps to an orthogonally adjacent cell, and it must be standing on a clear cell at every minute, minute 0 included. Return the earliest minute at which it can be standing on the bottom right cell, or -1 when no sequence of waits and steps ever puts it there. The floor has at least one cell and L is at least 1.

Implement
shuttle_transit_time(floor: list[list[str]]) → int
Examples
in[[["..",".#"],[".#",".."]]]out3
in[[["...","..."],["...","..."]]]out2
in[[["#."],[".."]]]out-1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[[["..",".#"],[".#",".."]]]3not run yetsample
[[["...","..."],["...","..."]]]2not run yetsample
[[["#."],[".."]]]-1not run yetsample