New answers tagged

0

PowerShell, 126 120 bytes $x=$y=0 switch -r(,'-'+$args){U{$y++}D{$y--}R{$x++}L{$x--}.{$g="$g$_$x-$y"-replace"(?<=($x-$y)).*\1$"}} $g-replace'\d|-' Try it online! The script: injects $x-$y to input string like -0-0U0-1U0-2R1-2U1-3 removes substrings between same coordinates removes digits and minus chars Less golfed: $x=$y=0 switch -...


1

Matlab with DIPimage, 118 bytes - 30% = 82.6 function F(f,x,y),a=readim(f);m=a{1}>0;s=m|1;s(x,y)=0;h=gdt(s,[],m);n=~isinf(h);a(n)=lut(h(n),255*hsv(fix(max(h(n))))) DIPimage has a function to compute Euclidean geodesic distance transform (gdt). It uses the Fast Marching algorithm, which produces a very reasonable approximation to Euclidean distances. See ...


Top 50 recent answers are included