-Pad←{ ⟨h,w⟩←≢𝕩 ⋄ »˘»(2+w)↑˘(2+h)↑𝕩 }
-PrepMap←{ Pad >(⌈´≠¨𝕩)⊸↑¨𝕩 }
+PrepMap←{ >(⌈´≠¨𝕩)⊸↑¨𝕩 }
PrepStep←{ 𝕊"L": 'L'; 𝕊"R": 'R'; •ParseFloat 𝕩 }
PrepPath←{ PrepStep¨(+`⟨0⟩∾≠˝⍉2↕𝕩∊"LR")⊔𝕩 }
Prep←{ ⟨ PrepMap ¯2↓𝕩, PrepPath ¯1⊑𝕩 ⟩ }
TR←{⟨1,¯1⟩×⌽𝕩}
Main←{𝕊⟨map,path⟩:
+ sidelen←√(+´⥊' '≠map)÷6
+ Pad←{ ⟨h,w⟩←≢𝕩 ⋄ »⍟sidelen˘»⍟sidelen(w+2×sidelen)↑˘(h+2×sidelen)↑𝕩 }
+ map ↩ Pad map
Move←{
'L' 𝕊 ⟨pos,dir⟩: ⟨pos,TL dir⟩;
'R' 𝕊 ⟨pos,dir⟩: ⟨pos,TR dir⟩;
dest↩{ (≢map)|𝕩+dir } •_while_ { ' '=𝕩⊑map } dest
⟨('.'=dest⊑map)⊑⟨pos,dest⟩,dir⟩
}
- pos←⟨1,⊑(1⊏map)⊐'.'⟩
+ pos←⟨sidelen,⊑(sidelen⊏map)⊐'.'⟩
dir←⟨0,1⟩
⟨⟨r,c⟩,d⟩ ← ⟨pos,dir⟩ Move´ ⌽path
- (1000×r) + (4×c) + (|1-˜+´⟨2,1⟩×d)
+ (1000×r+1-sidelen) + (4×c+1-sidelen) + (|1-˜+´⟨2,1⟩×d)
}
•Show Main Prep •file.Lines ⊑•args