Uiua
Just a port of my Dart solution from earlier really, and it shows, as it takes about 30 seconds on the live data.
(edit: I just noticed the little alien in the code (β
β
β|β
β|β)
which is literally flipping the stack (β―Β°β‘Β°)β―οΈ΅ β»ββ»!)
Data β "2333133121414131402"
FS β ββΓ·2⧻.β½β‘β:ββββ(β‘|β―:Β―1)⧻.Data # Build up a map of the FS.
MoveB β β(β‘|β
)β(β
β
β|β
β|β) β‘Β―1.:β’ββΒ―1. # Find a space, move block into it.
MoveBs β β’(β’(βΒ―1|=Β―1β£)βΒ―1MoveB|>0⧻ββΒ―1)
TryMove β ⨬(β|β§ββββ)/Γ/>.
MoveFile β (
β(βββ―:Β―1⧻|β)βββ.β. # get posns from, start posn to.
⨬(ββ|TryMove β+ββΒ°β,β’)>0⧻. # check posn to is good, swap.
)
Check β /+/Γββ‘⧻.β₯0
&p Check MoveBs FS
&p Check β§MoveFileβ+1β‘/β₯.FS
(edit: improved. Part1 is instant, part2 is about 17sec, but the alien has left)
Data β "2333133121414131402"
FS β β½β‘β:β⧻:ββββ(β‘|β―:Β―1)⧻..Data # Build up a map of the FS.
Ixs β β(βΒ¬|ββ)β₯0 # Get indices of space, and of blocks reversed.
SwapBs β β½βΈβ‘/>βββ©ββ:β§β©β§»,, # Join them where space < block.
Files β ββ‘(β‘β)β=β‘+1/β₯.
Move β β§(βββ)ββ+β‘⧻,β’ # (tos, froms, fs)
MoveFile β (
βββ,β―:Β―1⧻. # List of possible starts
⨬(ββ|⨬(ββ|Move)>β©β’,,)>0⧻. # Only valid, leftwards starts
)
Check β /+/Γββ‘⧻.β₯0
&p Check β§βββSwapBsβΈIxs FS
&p Check β§βMoveFile Files .FS