WOLFRAM NOTEBOOK

Table[FoldWhileList[Plus,1,RandomInteger[{-1,1},100],#>0&],200]
In[]:=
Length/@%
Out[]=
{5,4,15,8,13,8,2,10,12,72,27,101,5,2,15,101,2,7,2,20,2,2,3,5,2,101,2,101,2,101,48,2,101,9,9,7,2,2,91,2,2,101,5,4,2,2,2,3,2,31,7,38,36,18,5,5,9,9,5,2,2,4,2,2,2,2,2,14,2,101,4,2,2,101,4,2,3,2,4,3,3,24,2,33,3,3,3,2,3,2,2,20,5,2,9,20,8,4,2,8}
In[]:=
Histogram[%]
Out[]=
In[]:=
twowalk[list_,opts___]:=Graphics[Polygon[Join[MapIndexed[{#,-First[#2]}&,list],MapIndexed[{-#,-Length[list]+First[#2]-1}&,Reverse[list]]]],opts]
In[]:=
Table[FoldWhileList[Plus,1,RandomInteger[{-1,1},100],#>0&],10]
Out[]=
{{1,2,3,3,2,2,3,3,2,2,2,1,0},{1,2,3,4,5,5,6,7,7,7,8,7,8,9,8,9,9,10,11,12,13,12,11,11,11,11,11,12,11,10,9,9,9,9,9,9,8,9,9,10,9,10,10,10,9,10,11,11,12,12,13,12,13,13,14,14,15,15,16,17,18,17,16,16,16,15,15,16,15,14,14,14,14,15,14,13,12,12,12,12,11,10,11,12,12,12,13,14,13,13,13,14,13,13,14,15,14,14,14,14,13},{1,0},{1,2,1,0},{1,1,2,3,2,2,2,2,2,2,3,3,2,2,1,1,1,2,1,0},{1,2,1,0},{1,2,2,2,1,0},{1,2,1,0},{1,0},{1,0}}
With[{list={1,2,3,3,2,2,3,3,2,2,2,1,0}},Join[MapIndexed[{#,-First[#2]}&,list],MapIndexed[{-#,-Length[list]+First[#2]-1}&,Reverse[list]]]]
Out[]=
{{1,-1},{2,-2},{3,-3},{3,-4},{2,-5},{2,-6},{3,-7},{3,-8},{2,-9},{2,-10},{2,-11},{1,-12},{0,-13},{-1,-12},{-2,-11},{-2,-10},{-2,-9},{-3,-8},{-3,-7},{-2,-6},{-2,-5},{-3,-4},{-3,-3},{-2,-2},{-1,-1}}
In[]:=
twowalk/@%85
Out[]=
,
,
,
,
,
,
,
,
,
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.