Generating a certain sequence
lst1 = TakeList[Range @ 21, Range @ 6]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20, 21}}
lst2 = Table[lst1[[i ;;, i]], {i, 6}]
{{1, 2, 4, 7, 11, 16}, {3, 5, 8, 12, 17}, {6, 9, 13, 18}, {10, 14, 19}, {15, 20}, {21}}
lst3 = Table[lst1[[i ;;, -i]], {i, 6}]
{{1, 3, 6, 10, 15, 21}, {2, 5, 9, 14, 20}, {4, 8, 13, 19}, {7, 12, 18}, {11, 17}, {16}}
ClearAll[threeLists]
threeLists[n_] := Module[{l = TakeList[Range[n (n + 1)/2], Range @ n]}, {l, ## & @@
Table[l[[i ;;, (-1)^j i]], {j, 0, 1}, {i, n} ]}]
threeLists[6] == {lst1, lst2, lst3}
True
threeLists[3] // Column // TeXForm
$\begin{array}{l} \{\{1\},\{2,3\},\{4,5,6\}\} \\ \{\{1,2,4\},\{3,5\},\{6\}\} \\ \{\{1,3,6\},\{2,5\},\{4\}\} \\ \end{array}$
threeLists[4] // Column // TeXForm
$\begin{array}{l} \{\{1\},\{2,3\},\{4,5,6\},\{7,8,9,10\}\} \\ \{\{1,2,4,7\},\{3,5,8\},\{6,9\},\{10\}\} \\ \{\{1,3,6,10\},\{2,5,9\},\{4,8\},\{7\}\} \\ \end{array}$
threeLists[6] // Column // TeXForm
$\begin{array}{l} \{\{1\},\{2,3\},\{4,5,6\},\{7,8,9,10\},\{11,12,13,14,15\},\{16,17,18,19,20,21\}\} \\ \{\{1,2,4,7,11,16\},\{3,5,8,12,17\},\{6,9,13,18\},\{10,14,19\},\{15,20\},\{21\}\} \\ \{\{1,3,6,10,15,21\},\{2,5,9,14,20\},\{4,8,13,19\},\{7,12,18\},\{11,17\},\{16\}\} \\ \end{array}$
An alternative formulation using NestList
:
ClearAll[f, threeLists2]
f = Map[DeleteCases @ 0] @* Transpose @* PadRight;
threeLists2 = NestList[f, TakeList[Range[# (# + 1)/2], Range @ #], 2] &;
threeLists2 /@ Range[100] == threeLists /@ Range[100]
True
As @MarcoB suggested, looking at OEIS really did help. Then using NestList
I obtained the desired result.
list1 = FoldPairList[TakeDrop, Range[21], Range[6]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20, 21}}
list2 = NestList[Delete[#, 1] + 1 &, Table[(i - 1) (i - 2)/2 + 1, {i, 2, 7}], 5]
{{1, 2, 4, 7, 11, 16}, {3, 5, 8, 12, 17}, {6, 9, 13, 18}, {10, 14, 19}, {15, 20}, {21}}
list3 = NestList[Delete[#, 1] - 1 &, Table[i (i + 1)/2, {i, 1, 6}], 5]
{{1, 3, 6, 10, 15, 21}, {2, 5, 9, 14, 20}, {4, 8, 13, 19}, {7, 12, 18}, {11, 17}, {16}}