Two-Tower Strategy Game
Problem statement
West and East each start with a near tower of height 5, a far tower of height 0, no dollies, and no bricks on dollies. Each unlocked turn uses one action:
BUY: acquire one permanent dolly.LOAD: add one brick to every dolly.MOVE_NEAR: move every dolly brick to the near tower and empty the dollies.MOVE_FAR: commit every dolly brick to the far tower and empty the dollies. The team is locked on the following day; those bricks arrive at the start of that locked turn.OBSERVE: consume the turn without changing state.
West acts first each day. East follows the supplied deterministic action schedule; an action listed on a locked East day is ignored. West wins after either turn when its near tower is taller than East's far tower and its far tower is taller than East's near tower.
Return a minimum-day winning West schedule of calendar-day actions within dayLimit, including WAIT on a forced locked day. Break equal-length ties lexicographically using BUY < LOAD < MOVE_FAR < MOVE_NEAR < OBSERVE < WAIT. Return an empty array when no win is possible.
Function
findWinningTowerStrategy(eastActions: String[], dayLimit: int) → String[]Examples
Example 1
eastActions = ["OBSERVE","OBSERVE","OBSERVE","OBSERVE","OBSERVE","OBSERVE","OBSERVE"]dayLimit = 7return = ["BUY","BUY","BUY","LOAD","LOAD","MOVE_FAR","WAIT"]West loads six bricks onto three dollies, commits them on day 5, and receives them on the forced wait day, making the far tower taller than East's near tower.
Example 2
eastActions = ["BUY","LOAD","MOVE_NEAR","BUY"]dayLimit = 4return = []Four days are insufficient for West to build a far tower above East's near tower.
Constraints
1 <= dayLimit <= 8.eastActions.length == dayLimit.- Every East action is one of
BUY,LOAD,MOVE_FAR,MOVE_NEAR, orOBSERVE.