Forum Discussion
Patrick2788
May 12, 2023Silver Contributor
Create a 'Triforce' array (Sierpiński Triangle) with a formula
I've been studying 'pyramid' arrays lately and with a new Zelda title out, I was inspired to generate a left-justified 'Triforce' array with a formula.
Sierpiński triangle - Wikipedia
I took the approach of identifying and keeping the odd binomial coefficients and discarding evens.
Sierpiński
=LAMBDA(r,c,LET(n, INT(COMBIN(r - 1, c - 1)), IF(AND(r = 1, c = 1), 1, IF(c <= r, IF(ISODD(n), 1, ""), ""))))
Triforce
=LAMBDA(dim,MAKEARRAY(dim, dim, Sierpiński))
I'm interested in any other creative approaches to creating this array!
6 Replies
- mtarlerSilver Contributorok this ISODD() (pun intended). there are a couple of errors in your output and I don't think due to the formula. In particular on cell(26,11) the calculation is COMBIN(25,10) which = 3268760 and the result of ISODD is TRUE. This is the classic roundoff / representation inside of excel causing issues so you need to add INT() around that COMBIN (or around the N)
- Patrick2788Silver Contributor
- mtarlerSilver Contributor
On another note I complicated the formula a bit for aesthetic improvements:
=MAKEARRAY(K2,K2,LAMBDA(r,c, IF(AND(r = 1, c = 1), "\", IF(c = r,"\",IF(c<r, IF(ISODD(INT(COMBIN(r - 1, c - 1)) ), IF(ISODD(INT(COMBIN(r - 2, c-1 )*COMBIN(r-1, c ))),"X","\"), ""), "")))))
or using characters I found in the Cambria Math font I could get:
- Patrick2788Silver Contributor
The left justified one is straightforward and maybe too easy! This one below (Image) would take some work to add spaces where needed for the sake of appearance in Excel:
11 1
1 1 1