http://www.perlmonks.org?node_id=11139715


in reply to Re: Advent of Code, Day 15, golfed!
in thread Advent of Code, Day 15, golfed!

Combining that with another stroke saved by replacing the stupid ++$g, $g-1 stuff
push@a,/./g}{print$s{-1+map{$u{$_}||=$a[$_]+$s{$g}for grep$a[$_]*!$s{$_},$g+$.,$g-($g%$.>0),$g-$.*($g>=$.),$g+($g%$. <$.-1);($g)=sort{$u{$a}-$u{$b}}keys%u;$s{$g}=delete$u{$g}}@a}