Mathematica 491 323
コメントなしでゴルフ
プロシージャは、フィニッシュ( "*")から始まり、それを指す矢印を見つけて、開始に達するまで続きます。
関数、f [maze]。
(* positions of the arrowheads *)
aHeads[a_]:=Position[m,#]&/@{"^","v",">","<"}
(* position of the final labyrinth exit*)
final[a_]:=Position[a,"*"][[1]];
(* find arrowheads that point to the current location at {r,c} *)
aboveMe[{r_,c_},a_]:=Cases[aHeads[a][[2]],{r1_,c}/;r1<r]
belowMe[{r_,c_},a_]:=Cases[aHeads[a][[1]],{r1_,c}/;r1>r]
rightOfMe[{r_,c_},a_]:=Cases[aHeads[a][[4]],{r,c1_}/;c1>c]
leftOfMe[{r_,c_},a_]:=Cases[aHeads[a][[3]],{r,c1_}/;c1<c]
(*find the precursor arrowhead*)
precursor[{loc_,a_,list_:{}}]:=
(* end the search when the precursor has already been traversed or when there is no precursor *)
Which[MemberQ[list,loc],list,
loc=={},list,True,
(* otherwise find the next precursor *)
前駆体[{Flatten [{aboveMe [loc、a]、belowMe [loc、a]、rightOfMe [loc、a]、leftOfMe [loc、a]}、2]、a、Prepend [list、loc]}]]
(* return the path through the maze from start to finish *)
f[maze_]:= precursor[{final[maze[[1]]],maze[[1]]}]
ゴルフ
f@z_:=Module[{p,h,m=z[[1]]},h@a_:=Position[a,#]&/@{"^","v",">","<","*"};
p[{v_,a_,j_:{}}]:=Module[{r,c,x=Cases},{r,c}=v;
Which[MemberQ[j,v],j,v=={},j,True,
p[{Flatten[{x[h[a][[2]],{r1_,c}/;r1<r],x[h[a][[1]],{r1_,c}/;r1>r],
x[h[a][[4]],{r,c1_}/;c1>c],x[h[a][[3]],{r,c1_}/;c1<c]},2],a,Prepend[j,v]}]]];
p[{Position[m,"*"][[1]],m}]]
例
迷路。順序付けられた各ペアには、セルの行と列が含まれます。たとえば、{2、3}は行2、列3のセルを示します。
maze=Grid[Normal@ SparseArray[{{5, 5} -> "*",{1, 2} -> "v", {1, 5} -> "<",{2, 1} -> ">",
{2, 3} -> "v",{3, 3} -> ">", {3, 5} -> "^",{4, 1} -> ">", {4, 5} -> "v",{5, 1} -> "^",
{5, 2} -> "<",{_, _} -> " "}]]

入力
f[maze]
出力:開始から終了までのパス。
{{2、1}、{2、3}、{3、3}、{3、5}、{1、5}、{1、2}、{5、2}、{5、1}、{ 4、1}、{4、5}、{5、5}}