Skip to main content
saved 5 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 176171 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e=1,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLUj="RULD #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h^--j%2|v^~e=j^(v&2)-j%2~h:r[f(m,r[x]=x,y),x]=c))|e|n>o?o:o=n 

Try it online!Try it online! (only the fastest test cases)

JavaScript (ES6), 176 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e=1,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h^--j%2|v^~-j%2:r[f(m,r[x]=x,y),x]=c))|e|n>o?o:o=n 

Try it online! (only the fastest test cases)

JavaScript (ES6), 171 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e=1,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RULD #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=j^(v&2)-~h:r[f(m,r[x]=x,y),x]=c))|e|n>o?o:o=n 

Try it online! (only the fastest test cases)

saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 177176 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,ee=1,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h==e=h^--j%2&v==~j%2|v^~-j%2:r[f(m,r[x]=x,y),x]=c))|!e|n>o|e|n>o?o:o=n 

Try it online!Try it online! (only the fastest test cases)

JavaScript (ES6), 177 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h==--j%2&v==~-j%2:r[f(m,r[x]=x,y),x]=c))|!e|n>o?o:o=n 

Try it online! (only the fastest test cases)

JavaScript (ES6), 176 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e=1,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h^--j%2|v^~-j%2:r[f(m,r[x]=x,y),x]=c))|e|n>o?o:o=n 

Try it online! (only the fastest test cases)

saved 8 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 185177 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?h^-e=h==-j%2|v^~-j%2|(n=`${m}`.split` `.lengthj%2&v==~-1)>o?0:o=nj%2:r[f(m,r[x]=x,y),x]=c))|o|!e|n>o?o:o=n 

Try it online!Try it online! (only the fastest test cases)

JavaScript (ES6), 185 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?h^--j%2|v^~-j%2|(n=`${m}`.split` `.length-1)>o?0:o=n:r[f(m,r[x]=x,y),x]=c))|o 

Try it online!

JavaScript (ES6), 177 bytes

Expects a matrix of characters.

f=(m,X,Y=o=f,e,n=0)=>m.map((r,y)=>r.map((c,x)=>!~(j="RDLU #".search(c))|(n+=j==4,X+1?j>4|(h=x-X)*h+(v=y-Y)*v^1:j<5)?0:j<4?e=h==--j%2&v==~-j%2:r[f(m,r[x]=x,y),x]=c))|!e|n>o?o:o=n 

Try it online! (only the fastest test cases)

saved 2 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading