May 12 2023 11:51 AM - edited May 12 2023 01:02 PM
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!
May 12 2023 12:23 PM
May 12 2023 12:34 PM - edited May 12 2023 12:51 PM
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:
May 12 2023 01:18 PM
May 12 2023 01:23 PM
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:
1
1 1
1 1 1
May 12 2023 02:14 PM - edited May 12 2023 02:56 PM
@Patrick2788 here is a start:
=LET(s,K2,MAKEARRAY(s,2*s,LAMBDA(r,i,LET(c,ROUND((r+i-s)/2,0),IF(c<1,"",IF(AND(r=1,c=1),K3,IF(c=r,K3,IF(c<r,IF(ISODD(INT(COMBIN(r-1,c-1))),IF(ISODD(INT(COMBIN(r-2,c-1)*COMBIN(r-1,c))),K4,K3),""),""))))))))
getting closer:
=LET(s,K2,MAKEARRAY(s,2*s,LAMBDA(r,i,LET(cc,(r+i-s)/2,c,ROUND(cc,0),cp,ROUND(cc+0.5,0),cm,ROUND(cc-0.5,0),
IF(c<1,"", IF(AND(r=1,c=1,cp=1),K5,IF(AND(c=r,cm=r),K6,
IF(c<=r,IF(ISODD(INT(COMBIN(r-1,c-1))),
IF(ISODD(INT(IFERROR(COMBIN(r-1,cm-1),0))),
IF(ISODD(INT(COMBIN(r-1,cp-1))),K7,
IF(ISODD(INT(COMBIN(r-2,c-1))),K8,K6)),
IF(ISODD(INT(IFERROR(COMBIN(r-2,c-1),0))),K5,K9)),""),""))))))))
May 13 2023 07:19 AM
This is my solution:
'Triforce
=DROP(
REDUCE(
"",
SEQUENCE(32),
LAMBDA(a, v,
LET(
binom, INT(COMBIN(v - 1, TAKE(Seq, , v * 2))),
padding, EXPAND("", 1, 64 - v, ""),
resize, EXPAND(1, 1, 2, 1),
VSTACK(
a,
EXPAND(HSTACK(padding, IF(v = 1, resize, IF(ISODD(binom), 1, ""))), 1, 96, "")
)
)
)
),
1,
32
)
I achieved the 'doubling' with some help from Seq which is:
Seq
=INT(SEQUENCE(, 64, 0, 0.5))
Rolled it into a 'Triangle' Lambda where you can pick left justified or Triforce.