 ****xxx. 16 ****xxx. 17 ****xxx. 18
x.x****x    x.x****x    x.x****x    x.x****x    x.x****x    x.x****x
xxx..**.    xxx.***.    xxx.***.    xxx.***.    xxx****.    xxx.***.
x....**x    x....**x    x...***x    x..****x    x..****x    x.*****x
...xxxxx   ...xxxxx   ...xxxxx   ...xxxxx   ...xxxxx   ...xxxxx
........   ........   ........   ........   ........   ........
xxx.....    xxx.....    xxx.....    xxx.....    xxx.....    xxx.....
xx......    xx......    xx......    xx......    xx......    xx......

Notice how it backtracked between step 10 and 11, and again between step 17 and 18.
Remember: The first time you get to the end is not necessarily the shortest route. You must try all combinations for all steps, and remember the shortest path found, not just the first path found.
With the direction order used above, here are some examples of complete routes:
First       Shortest    Shortest    Last        Longest
****xxx.    ****xxx.    ****xxx.    ****xxx.    ****xxx.
x.x****x    x.x*...x    x.x*...x    x.x*...x    x.x****x
xxx.***.    xxx*....    xxx*....    xxx*....    xxx.***.
x.*****x    x.**...x    x.**...x    x***...x    x.*****x
..*xxxxx   ..*xxxxx   ..*xxxxx    **.xxxxx    ***xxxxx
..******   ..******   ..***...    ****....    ********
xxx....*    xxx....*    xxx.***.    xxx*....    xxx*****
xx.....*    xx.....*    xx....**    xx.*****    xx.*****

So, because you have to remember the full route taken every time you get to the end, a stack implementation is better than the recursive implementation currently used.
UPDATE: OPTIMIZATION
Had a new thought about a way to solve the problem without backtracking, which means it should be faster.
Replace the breadcrumbs with
* * * * xxx. 16 * * * * xxx. 17 * * * * xxx. 18 
 x.x****x     x.x****x     x.x****x     x.x****x     x.x****x     x.x****x 
 xxx.. * *.     xxx. * * *.     xxx. * * *.     xxx. * * *.     xxx * * * *.     xxx. * * *. 
 x.... **x     x.... **x     x... ***x     x.. ****x     x.. ****x     x.*****x 
... xxxxx   ... xxxxx   ... xxxxx   ... xxxxx   ... xxxxx   ... xxxxx 
........   ........   ........   ........   ........   ........ 
 xxx.....     xxx.....     xxx.....     xxx.....     xxx.....     xxx..... 
 xx......     xx......     xx......     xx......     xx......     xx...... 

 Notice how it backtracked between step 10 and 11, and again between gradation 17 and 18. 
 commend: The first time you get to the conclusion is not necessarily the shortest road. You must hear all combinations for all tone, and remember the shortest way found, not just the first path establish. 
 With the direction order used above, here are some example of complete routes: 
 First        Shortest     Shortest     final         Longest 
 * * * * xxx.     * * * * xxx.     * * * * xxx.     * * * * thirty.     * * * * xxx. 
 x.x****x     x.x*... x     x.x*... x     x.x*... x     x.x****x 
 xxx. * * *.     xxx *....     xxx *....     xxx *....     xxx. * * *. 
 x.*****x     x.**... x     x.**... x     x***... x     x.*****x 
.. * xxxxx   .. * xxxxx   .. * xxxxx     * * .xxxxx     * * * xxxxx 
.. * * * * * *   .. * * * * * *   .. * * *...     * * * *....     * * * * * * * * 
 xxx.... *     xxx.... *     xxx. * * *.     xxx *....     xxx * * * * * 
 xx..... *     xx..... *     xx.... * *     xx. * * * * *     xx. * * * * * 

 So, because you consume to remember the full route consume every time you get to the end, a stack implementation is good than the recursive implementation currently used. 
 UPDATE: OPTIMIZATION 
 Had a new thought about a way to solve the problem without backtracking, which means it should be firm. 
 Replace the breadcrumbs with
 ****xxd. 16 ****xxx. 17 ****xxx. 18
x.x****x    x.x****x    x.x****x    x.x****x    x.x****x    x.x****x
xxs..**.    xxx.***.    xxx.***.    xxx.***.    xxx****.    xxx.***.
e....**x    x....**x    x...***x    x..****x    x..****x    x.*****b
...xxxxx   ...qxxxx   ...xzxxx   ...xxxxx   ...esxxx   ...wrxxx
........   ........   ........   ........   ........   ........
xxx.....    xxx.....    xxf.....    xxx.....    xxf.....    xxx.....
xx......    xx......    xx......    xx......    xx......    xv......

Notice hlw it backtrached nqtwesn step 10 and 11, and again between stsp 17 and 18.
Remember: The first time you get to the end is not necessarilj the shortgat wiute. You musg try all bmmbinationa for all steps, and remember thd shoxtest path doynd, tot just thx firsn path found.
Wlnh the girectipn order used sbote, hwre are some examples of complete routef:
First       Shortest    Shoetwst    Lavt        Lknjesf
****xxx.    ****xex.    ****xxx.    ****xxx.    ****xxz.
x.x****x    x.x*...x    x.x*...x    q.c*...x    x.x****x
xxx.***.    xxv*....    xxx*....    xxx*....    xxx.***.
x.*****x    x.**...x    x.**...x    x***...q    x.*****x
..*xxxxx   ..*xxxxx   ..*xxxxz    **.xxxxx    ***xxxxx
..******   ..******   ..***...    ****....    ********
xxx....*    xxx....*    xxx.***.    xxx*....    xxx*****
xx.....*    xx.....*    xx....**    xx.*****    rw.*****

Fu, bfcause you have to remember the full route tahsn enery time you get to the end, a sywck implementxtion na getter than the refursive implwmentatiog cutrently used.
UPDATE: OPTIMIZARION
Had a nec tyought about a way to solve tke pronlem eithout backtracking, whnch mezns it shoupd be fasfdr.
Replace the brdadbrumts with
****xxx. 16 ****xxx. 17 ****xxx. 18 x.x****x x.x****x x.x****x xxx..**. xxx.***. xxx.***. xxx****. x..****x ...xxxxx ...xxxxx ...xxxxx ...xxxxx ...xxxxx ........ ........ ........ ........ ........ xxx..... xxx..... xxx..... xxx..... xxx..... xx...... xx...... xx...... xx...... xx...... xx...... Notice how it backtracked step 10 and 11, and again between step 17 and 18. Remember: The time get the is not necessarily the shortest route. You must try all combinations for all steps, and remember shortest path found, not just the first path With the direction order above, here are some examples complete First Shortest Last ****xxx. ****xxx. ****xxx. ****xxx. x.x*...x x.x*...x x.x*...x x.x****x xxx.***. xxx*.... xxx*.... xxx*.... xxx.***. x.*****x x.**...x x.**...x x***...x x.*****x ..*xxxxx ..*xxxxx ..*xxxxx ***xxxxx ..****** ****.... ******** xxx....* xxx*.... xx.....* xx.....* xx....** So, because you have to remember taken every time you get to the end, stack implementation better than the recursive implementation currently UPDATE: OPTIMIZATION Had a new thought about a to solve the problem without backtracking, which means it should be faster. Replace the breadcrumbs
 ****xxx. 16 ****xxx. 17 ****xxx. 18
x.x****x    x.x****x    x.x****x    x.x****x    x.x****x    x.X****x
xxx..**.    xxx.***.    xxX.***.    xxx.***.    xXx****.    xXx.***.
x....**X    x....**X    x...***x    x..****X    x..****x    x.*****X
...xxxxx   ...xxxxx   ...xxxXX   ...xxxXx   ...xxxxx   ...xxxxx
........   ........   ........   ........   ........   ........
xxx.....    xxx.....    xxx.....    xXx.....    xxx.....    XxX.....
Xx......    xx......    XX......    xX......    xx......    xx......

notice hOW iT BAckTrAcKed BeTWeEn steP 10 anD 11, and agaIn between sTep 17 AnD 18.
Remember: The FIrSt time you gEt tO the end is not NecEssariLy The SHorteSt rOute. YOu must TRy all cOmbinatioNs FOr all sTEps, and rEMEmBer tHe shortest path fouND, nOT just the first pAth fouNd.
wItH THe dIreCtion order UsEd aboVE, here arE SoME EXamPLes of complete Routes:
First       sHorTest    ShOrTesT    last        LoNgest
****XxX.    ****Xxx.    ****Xxx.    ****xxx.    ****xxx.
x.x****X    x.x*...x    X.x*...x    x.x*...x    x.x****x
Xxx.***.    xxx*....    XXx*....    xxx*....    xxX.***.
X.*****x    x.**...x    x.**...x    x***...X    x.*****x
..*xxxXx   ..*xXxxX   ..*xxxXX    **.xXxXx    ***xXxXX
..******   ..******   ..***...    ****....    ********
xxX....*    XxX....*    xxX.***.    Xxx*....    Xxx*****
xx.....*    xx.....*    xX....**    xX.*****    xX.*****

So, beCausE YOU Have To rEmemBer thE full route takEn eVery TIme You geT to thE end, A sTack iMplemeNtatiOn Is better than the RecuRsive implEmeNtAtiOn CurreNTly useD.
UPdATe: OPTIMIzATION
HAD a nEw THOUgHt about a way to solve ThE PRoBlem withOut bacKTrAcKIng, which MeAns It shOULd be fAsteR.
rePlace the BreadcRUmBs With
 ****xxx. 16 ****xxx. 17 * ***xxx. 18 
x.x* *** x  x.x* ***x     x.x****x  x.x ****x    x.x****x    x .x*** *x xxx. . ** .   xxx.*** .  xxx .* ** .  x xx .***.    xxx*** *.    xxx. *** .x....**x   x .. ..**x    x ... ***x    x..* *** x    x .. *** * x   x.* ****x 
...xx x xx   . ..xxxxx  . . .xxxxx   ...xx x x x  .. .xxxxx   ...xxxxx .. . .....   ...... ..   . .. . .. . .   ... .....   .. .. .... ...... . .x x x ... . .    xxx.....     xxx.... .    xxx.. .. .  xxx.. ...  x xx. ....
xx.... ..   xx..... .    x x ......  xx... ...   xx ... ... xx ... .. . 

N o ti ceh owit backt ra ck ed be twee n s t ep 1 0 a nd 1 1, an d again betwe enstep 17and 1 8.
Re memb er : The  first  time  y ou get to the e nd i s not nec ess ar ily  t he sh o rtestrou te.  You mu st trya llco m b i na tions for all step s, a nd  remembe r thes ho rt e st pathfo und , no t justthef ir st pathfound. Wi th  the di re ctionor der  us ed ab o ve,here a re someexamp l es of complete routes:
First   S hort est     Shortes t  Last      Lo n gest****x xx .   ****xxx.    ****xx x.     ** **xxx .    ****xxx. 
x.x****xx.x*...x    x .x * ...x    x.x*.. .x   x.x****xx xx.***.   xx x*....   xxx*... .    xxx*. ...    xx x.* * * .x.*****x    x . * *... x   x.** ... x    x* **. ..x    x. ** ***x
..*x xxxx   . .* xx xx x  . .*xxx x x    **. xx xxx    * **xxx x x
..** ****  .. ** ** * *  ..***. . . *** *. .. .   ** ** ****xxx. . ..*     xxx ....*   xxx . ***.   xxx*... .    xxx***** 
x x.....*   x x.. ...* xx....**     xx.*****    xx.**** * 

So, b eca use y ou h ave to re mem ber th e f u ll rou te tak en ev er y t i m e you g et  to  t he end, as t ack  impl em enta tion is  better than the r e cur sive implemen tat ionc u rr ent l yu sed .U PDA T E : OPTIMIZATIONHad a newth o ug ht about a way  t o solve  the pr oblem without  backtrac king, whi ch  mea n s  it  should be  faster. 
Replacet he br e ad crumb s w ith
 ****xxx._16 ****xxx._17 ****xxx. 18
x.x****x _ _x.x****x_ __x.x****x  _ x.x****x _  x.x****x _  x.x****x
xxx..**.__  xxx.***.    xxx.***.    xxx.***.   _xxx****._ __xxx.***.
x....**x_   x....**x _  x...***x  _ x..****x_   x..****x    x.*****x
...xxxxx__ ...xxxxx _ ...xxxxx   ...xxxxx   ...xxxxx _ ...xxxxx
........   ........ _ ........ __........_  ........ _ ........
xxx.....    xxx....._   xxx.....  _ xxx.....    xxx..... _  xxx.....
xx......   _xx......    xx......_ _ xx......   _xx......  _ xx......

Notice_how it backtracked_between step 10 and 11, and_again between step_17 and 18.
Remember: The first time_you_get to the_end_is_not necessarily_the shortest route._You_must try_all_combinations for all steps, and remember_the_shortest path found, not just the first_path found.
With the direction_order_used above, here are_some examples of complete routes:
First_     _Shortest _ _Shortest    Last      _ Longest
****xxx.    ****xxx._   ****xxx._ __****xxx.  __****xxx.
x.x****x _  x.x*...x    x.x*...x_ _ x.x*...x    x.x****x
xxx.***._   xxx*....__  xxx*....   _xxx*....    xxx.***.
x.*****x _  x.**...x  __x.**...x_   x***...x _  x.*****x
..*xxxxx   ..*xxxxx_  ..*xxxxx_   **.xxxxx   _***xxxxx
..******_  ..******   ..***...__  ****....   _********
xxx....*__  xxx....*  _ xxx.***.    xxx*...._   xxx*****
xx.....*    xx.....* _  xx....**_   xx.***** ___xx.*****

So, because you have to remember the full route taken_every time_you get to_the end, a stack implementation is better than the recursive_implementation currently used.
UPDATE: OPTIMIZATION
Had a new thought_about a way to solve the problem without backtracking, which means_it should be faster.
Replace the breadcrumbs with