Floyd's triangle is an arrangement of the positive integers into a triangle such that the $n$th line contains $n$ integers. To illustrate, here are the first 4 lines of Floyd's triangle:
1
2 3
4 5 6
7 8 9 10
I am trying to design a function that takes as input an integer n
, and returns a list of all the ways to select 3 elements from n
rows of Floyd's triangle such that they lie consecutively in a horizontal, vertical, or diagonal line within the triangle. For example, for an input of 4
(corresponding to the triangle shown above) the expected output would be
{{1,2,4}, {1,3,6}, {2,4,7}, {2,5,9}, {3,5,8}, {3,6,10}, {4,5,6}, {7,8,9}, {8,9,10}}
I have a boring and clunky procedural implementation currently, which I post below as an answer, but I expect there exist pithier solutions that make better use of Mathematica's powers. In particular, I might expect that there would be a solution that does not require me to explicitly generate the triangle.