Ah, a help request related to one of my favourite games - how could I resist? :-)
Here's my attempt:
The line is drawn on the grid, allows backtracking and is blocked by itself and gaps. I've not worked out how to manoeuvre the cursor into the end spot yet - I'll give it some more thought and get back to you.