Shuttle through rotating carousel

Write codeHard35 minAmazon style

Your task

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.

Examples

shuttle_transit_time(floor: list[list[str]]) -> int
Example 1
Inputshuttle_transit_time([["..", ".#"], [".#", ".."]])
Output3
Example 2
Inputshuttle_transit_time([["...", "..."], ["...", "..."]])
Output2
Example 3
Inputshuttle_transit_time([["#."], [".."]])
Output-1