tiny-tim said:
hi matiasmorant!
i don't get it … surely the number of possible ways is
infinite?
(i can just keep going back for my keys!

)
yes, sure, but only N times!
I can only walk N squares sides, if I keep on coming back for my keys, then I won't have enough permitted sides left to get to my destination :-D
To start with, you can take the case where N is the least number of sides in which I can reach both corners. For example, if I want to reach the corner with coordinates (1,Y) then there Y possible routes, if I want to reach the corner with coordinates (2,Y) then there are (Y^3 - Y)/6 possible routes (that's, with N being the least). what about (X,Y) ?
However, if N is not the least... let's say N=3 and I want to get to (1,1). Then, it can't be done, because, I could get there by walking 2 sides, 4 sides (coming back for my keys once), 6 sides (coming back for my keys twice), but not 3 sides.
That's it.
Some advice in the case where N is the least is also appreciated :-)