Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input
[
[
1,
0,
0
],
[
1,
1,
0
],
[
0,
1,
1
]
]
Execution steps
Explore open cell
Computed output
[
"DRDR"
]
JavaScript reference implementation
const solve = (a,s)=>{
let o=[],seen=new Set,n=a.length;
function f(i,j,p){
if(!a[i]?.[j]||seen.has(i+","+j))return;
s("Explore open cell",{
Grid:a,Path:[...p],Current:[i,j]
});
if(i===n-1&&j===n-1){
o.push(p);
return
}
let key=i+","+j;
seen.add(key);
for(let [d,x,y] of [["D",1,0],["L",0,-1],["R",0,1],["U",-1,0]])f(i+x,j+y,p+d);
seen.delete(key)
}
f(0,0,"");
return o
};