Catalan Numbers Poster

Armanpreet Pannu

ts[n_Integer]:=ts[Range[0,n+1]];
ts[{_,_}]={ds[]};
ts[vs_List]:=Module[{l,r,k,t1,t2,tds},Union@@Table[l=ts[Prepend[vs[[k;;]],vs[[1]]]];r=ts[vs[[2;;k]]];Flatten[Table[tds=Join[t1,t2];
If[k>3,AppendTo[tds,d[vs[[2]],vs[[k]]]]];
If[k<Length[vs],AppendTo[tds,d[vs[[1]],vs[[k]]]]];tds,{t1,l},{t2,r}]],{k,3,Length[vs]}]]

(*A function to create a picture of the triangulation*)

Draw[d_ds] := jksdfhsfgksdgklsdfglkfsfkl

tspic[ls_]:=Module[{l1,l2,n=Length[ls]+1},l1=List@@Function[Line[{#1,#2}]]@@@ls/.j_Integer->{Cos[((2π j)/(n+2))],Sin[((2π j)/(n+2))]};
l2=Line[Range[0,n+2]/.j_Integer->{Cos[ ((2π j)/(n+2))],Sin[ ((2π j)/(n+2))]}];
Graphics[Append[l1,l2]]
]

(*A function to create the charts from the triangualtions. The output is a list of {0,1} or {1,0} where {1,0} indicates one step right and {0,1} indicates one step up*)
chart[tri_]:= Module[{tri1,a={R},i=0,n=Length[tri]+1},
tri1=tri;
While[Length[tri1]≠0  ,
a=a~Join~Table[R, Count[tri1,d[i,_]]];
(*a=Nest[Function[Append[#,{1,0}]],a,Count[tri1,d[i,_]]];*)
tri1=DeleteCases[tri1,d[i,_]];
a=Append[a,U];
i++;
];
a=Nest[Function[Append[#,{0,1}]],a,2*n-Length[a]];
a
];

triang=RandomChoice[ts[5]]

(*A function to create the graphics of the chart from the chart list*)
chpic[list_]:=Module[{start={0,0},i=1,output={},n=Length[list]/2},
While[i≤Length[list],
output=Append[output,Line[{start,start+list[[i]]}]];
start=Plus@@list[[1;;i]];
i++;];
Graphics[output,GridLines->{Range[0,n],Range[0,n]},GridLinesStyle->Directive[Gray, Dashed]]
]

Poster[n_Integer]:=Grid[Table[{tspic[i],chpic[chart[i]]},{i,ts[n]}],Frame->All]

Graphics[
Line/@Partition[FoldList[Plus, 0, chart[triang]], 2, 1] /. {U->{0,1},R->{1,0}, 0->{0,0}}
]

Poster[5]