- #1
DavidSnider
Gold Member
- 511
- 147
Let's say you have a triangle like:
1
2 3
4 5 6
7 8 9 10
The children of each element in the triangle are those directly adjacent on the next row. For example the children of 4 are 7 and 8. The children of 5 are 8 and 9.
Now let's say we flatten it to: [1,2,3,4,5,6,7,8,9,10]
Is there a way to compose a function that takes the index of the parent and returns a tuple containing the indexes of the children? (Assume 0 based indexes. The 1 through 10 are values, not indexes)
1
2 3
4 5 6
7 8 9 10
The children of each element in the triangle are those directly adjacent on the next row. For example the children of 4 are 7 and 8. The children of 5 are 8 and 9.
Now let's say we flatten it to: [1,2,3,4,5,6,7,8,9,10]
Is there a way to compose a function that takes the index of the parent and returns a tuple containing the indexes of the children? (Assume 0 based indexes. The 1 through 10 are values, not indexes)
Last edited: