Basic Examples (3)
Basic Examples
(3)
Find the marks for a sparse ruler of length 9:
In[1]:=
Out[1]=
{0,1,4,7,9}
Check that all differences are covered:
In[2]:=
UnionLast[#]-First[#]&/@Subsets[9,"Full"],{2}
Out[2]=
{1,2,3,4,5,6,7,8,9}
———
Find the marks for a sparse ruler of length 57:
In[1]:=
Out[1]=
{0,1,3,6,13,20,27,34,41,48,52,56,57}
Check that the ruler is complete, i.e. that all differences are covered:
In[2]:=
ComplementRange[57],#[[2]]-#[[1]]&/@Subsets[57,"Full"],{2}
Out[2]=
{}
———
Show the intervals between marks in the full form of a length-396 ruler:
In[1]:=
Differences[396,"Full"]
Out[1]=
{1,1,1,1,1,6,11,11,11,11,11,23,23,23,23,23,23,23,23,23,23,23,12,12,12,12,12,12,1,1,1,1,1}
Split the differences:
In[2]:=
Split[%]
Out[2]=
{{1,1,1,1,1},{6},{11,11,11,11,11},{23,23,23,23,23,23,23,23,23,23,23},{12,12,12,12,12,12},{1,1,1,1,1}}
Make a series of lists from the compact form of a length-396 ruler:
In[3]:=
Table[#[[1]],{#[[2]]}]&/@Transpose[396]
Out[3]=
{{1,1,1,1,1},{6},{11,11,11,11,11},{23,23,23,23,23,23,23,23,23,23,23},{12,12,12,12,12,12},{1,1,1,1,1}}
Show the compact form:
In[4]:=
Out[4]=
{{1,6,11,23,12,1},{5,1,5,11,6,5}}
Verify that the compact form from the previous result has length 396:
In[5]:=
Dot@@%
Out[5]=
396
Show the full form for a length-396 ruler:
In[6]:=
Out[6]=
{0,1,2,3,4,5,11,22,33,44,55,66,89,112,135,158,181,204,227,250,273,296,319,331,343,355,367,379,391,392,393,394,395,396}
Scope (6)
Scope
(6)
Possible Issues (2)
Possible Issues
(2)
Neat Examples (3)
Neat Examples
(3)