# AXMAS  	Happy Holidays everyone!! For the ones who celebrate Xmas, 2 Xmas tree designs.



## Xlambda (Dec 24, 2021)

*AXMAS , AX* two Xmas's trees design.
AX is a "tree" that is already decorated, does not call any other lambda. The ornaments are embedded in the function.
AXMAS  is an undecorated one. We can choose our own ornaments array "or". Call AFLAT.
AFLAT , flattens the ornament array, and gives us the versatility to deal with arrays of any shape, size, dimensions, with blanks/null strings, ranges, or other array formulas.
Both designs, randomly, change the display of ornaments every time spreadsheet recalculates, or if we hit F9.
Both lambdas share same concept design, creating a Xmas tree shape, a "triangular" array that can be filled with random values.
A triangular array is like designing a symmetric staircase, it has stairs or steps, and has 2 input parameters "ht", the approximate total height, and "sh", each stair height. Each stair width or depth is by default 1. Knowing these parameters, the function knows how to calculate nr. of steps, exact total height to accommodate nr. of steps and total width footprint of the "staircase".
Both lambdas share same ornament topper (2 parts), and same tree base, (last row) where presents boxes are placed. First variables after LET.
*AXMAS(ht,sh,or)*

```
=LAMBDA(ht,sh,or,
     LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),
        o,AFLAT(or),n,ROWS(o),h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
       IF(a,w,"")
    )
)
```
*AX(ht,sh)*

```
=LAMBDA(ht,sh,
    LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),
        n,44,h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
        IF(a,w,"")
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS1AXMAS(ht,sh,or)ornaments array sample2ht: approx.. height; if ht ignored or <9 => ht=9, (min tree height=9)❀❁❂❃❅❆??✿✽✾3sh: each "step" height; if ignored or <3 =>sh=3 (3 min."stair" height=3 )smallest treeht,15,sh,44or: ornaments array, any array, any shape, any valuesht,,sh,,(ignored)=AXMAS(15,4,X2:AH2)5Increasing sh value makes triangle's top angle smaller, (higher tree "slope")=AXMAS(,,X2:AH2) ⭐6For better visual experience, change the grids width to tiny squares, all centered aligned. ⭐▒7Predetermined ornaments, topper, 2 parts, tree base,present boxes.▒✿8If you want to change them, just after LET, variables t,i,p?❁9❅❃❀✽❅✽1011088⭐topper 1❃❆????119618▒topper 2❃❆❅✽✽❀12127873?base✽?❂✿❂❅❀❅13❂✽❅✾❁✾❀❆✿✾14Ornaments array values used by these trees in next post.?✾✾❀❀❆❁❆❆✿15Note: Ornaments shape, color, can look different on your spreadsheet.??❅❂❀❃16✿?❂❂❃17ht,30,sh,4❀✾❀?❁❅❅18=AXMAS(30,4,BH17:CU20)❃?❃❃❃✿✽19 ⭐ht,20,sh,, ❆✾?❃✿❀❃20▒=AXMAS(20,,BH17:CU20)❂✽✽❂❅❃✿21⏬ ⭐???22?▒23????24?????♕ornaments array as numbers25⏬???✼?=AXMAS(13,4,SEQUENCE(9))26?????? ⭐27???❀??????▒28✷?????????529?????⚽????330❊❇?❉?????❄??64131✻???✅????⏪?⭕??65232???⭕?⚓???✺???✴39733????❌??????❎??❄?25434?⏩✼?⭕✴????❈?????4694435?????❇????⭕✻?❆?✻??5363736✺⏩❂?⛄??✺??????????⚡⚡5323937?????⚓???❈????✿?✾?❂?2822838???✸???✿?????❁???❁??277348439?❉?????✿?♕❉??❎??✶???⏩??❀139769540???????????✻????❂???❉??❂619618241?✼??❅❈?❃✅✅?❆✹⚓??⭐⏬❊???⚡?621498342???????????????????????43????✅???⛄????44???❄??❄?✼⏬???Note: This values can be used with CF45???????????♔❅46??❊????????❀?47??????????????⚡48??⚽??????✾?❊???49??✵✵???❊?❃?????50?✶??✻?????❈????51???????????52AXMAS 1Cell FormulasRangeFormulaAG4,AI25,T20,B18,Y5AG4=FORMULATEXT(AG5)AG5:AM21AG5=AXMAS(15,4,X2:AH2)Y6:AC15Y6=AXMAS(,,X2:AH2)B10:B12B10=UNICHAR(A10:A12)B19:P51B19=AXMAS(30,4,BH17:CU20)T21:AF42T21=AXMAS(20,,BH17:CU20)AI26:AO42AI26=AXMAS(13,4,SEQUENCE(9))Dynamic array formulas.


----------



## Xlambda (Dec 24, 2021)

AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG1Ornaments array in ascending order, includes geometrical shapes, fruits, sweets, sports, toys, objects, pets …etc23⏩⏪⏫⏬⏩ 9193⏪ 9194⏫ 9195⏬ 9196=AXMAS(30,5,A3:D42)=AXMAS(20,4,A3:D42)4♔♕⚓⚡♔ 9812♕ 9813⚓ 9875⚡ 9889 ⭐ ⭐5⚽⛄✅✳⚽ 9917⛄ 9924✅ 9989✳ 10035▒▒6✴✵✶✷✴ 10036✵ 10037✶ 10038✷ 10039✹?7✸✹✺✻✸ 10040✹ 10041✺ 10042✻ 10043❄?8✼✽✾✿✼ 10044✽ 10045✾ 10046✿ 10047⏫?❇⏫9❀❁❂❃❀ 10048❁ 10049❂ 10050❃ 10051??????10❄❅❆❇❄ 10052❅ 10053❆ 10054❇ 10055??????11❈❉❊❌❈ 10056❉ 10057❊ 10058❌ 10060???⏪??12❎⭐⭕?❎ 10062⭐ 11088⭕ 11093? 127744??✴????✼13????? 127757? 127758? 127759? 127760????⏩⏩??14????? 127761? 127762? 127763? 127764❀❃❈✾?✷???✅15????? 127765? 127766? 127767? 127768??✵????✳?♔16????? 127769? 127770? 127771? 127772???⚡??????⏫?17????? 127773? 127774? 127775? 127776✺???✅???????18????? 127792? 127793? 127794? 127799✅???✻?❊?????19????? 127800? 127801? 127802? 127803?♕?????❈✼✻???❀20????? 127804? 127805? 127806? 127807???❄⛄?????????✺?21????? 127808? 127809? 127810? 127811???⛄?⭕?❅???????❅22????? 127812? 127813? 127815? 127816?❈❉??⭕?????????⏩23????? 127817? 127818? 127819? 127820????????✼✻?????✾24????? 127821? 127822? 127823? 127824???????✸❊?????25????? 127825? 127826? 127827? 127851??⛄???✳✅?26????? 127852? 127853? 127870? 127871❌✿???????27????? 127872? 127873? 127874? 127875????❁??✳?28????? 127876? 127877? 127878? 127879????❆?⚽??29????? 127880? 127881? 127882? 127883??✺??⚓??⭐??30????? 127890? 127936? 127944? 128030??????✅?⏩??31????? 128036? 128037? 128038? 128039❉?✹???✳✻??⏩32????? 128040? 128125? 128141? 128142??❎?❊??????33????? 128151? 128152? 128153? 128154?❈??❊?????⚓34????? 128155? 128156? 128157? 128158???????35????? 128159? 128160? 128161? 12816236????? 128205? 128269? 128270? 12830237????? 128303? 128308? 128309? 12831038????? 128311? 128312? 128313? 12831439????? 128315? 128508? 128509? 12875640????? 128757? 128758? 128759? 12876041????? 128761? 128762? 128763? 12876442????? 129351? 129352? 129353? 12935843AXMAS 2Cell FormulasRangeFormulaF3:I42F3=A3:D42&" "&UNICODE(A3:D42)K3,X3K3=FORMULATEXT(K4)K4:U34K4=AXMAS(30,5,A3:D42)X4:AF24X4=AXMAS(20,4,A3:D42)Dynamic array formulas.


----------



## Xlambda (Dec 24, 2021)

Noticed that making the chars bold, they apear in black and white (like Windows computers show them, no color).
AXMAS.xlsxHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM1Other ornaments array, letters, numbers23??????????????????????????4?????????????????????????5①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳6❶❷❸❹❺❻❼❽❾❿⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴7?✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊8??????????????????????????910=AXMAS(30,4,H3:AG8)11 ⭐section of an array with blanks12▒=AXMAS(20,3,H5:AF7)13❇ ⭐14?▒15?❄?⓭16?⑫?❀❸✽17⑰⑭?⑲⑲⓲18??✺⑰⑥❃19?⑫??③✻⓬✵❆✷20?✺?④?❇❆❸❽⓰21⓬?⑯⑤?⓳❀✷❄✸22???⓲?⓬⓭⓱⑰❷✽④23②?❷⑳❸⑮?❶①⓮✾❾✹⑨24?❺????❅⑲③❆?⑩⓰⑱25✺?✵?⑮⓲?❾❼❄⓭⓫❼⓰⓰✾26?✾⓰????✳⑪⓬⑭❶❽✷✶❺27?⑧⑪??????❁❸③✵❀❹❷✷⑭28?✷??????✶①⑩❸⓳❂❁❹❅✴✺⑮29?⓱⑰??⑫⑰??✴⑱❃❇⓮⓭✳❿⓳⑲✼30⓮??❿④?✵?⑪❁⑫✳❷✳❂⑲⑰❃✷❸31⑫❆❃✸?❅⑳⑳❉??⑪✼❈✿❆⑩⑬✻⓴❿✷✸❺32?✶??✾?⓱?⑯✹?⑩✽❆❸⑪①⓬✽⑫⑨❊①⓱33???⑰?❾??⓭??❾✷⑲❻✻⓯⓫①⓯✻②❇❸34①??❼?????✶❼?????????35???✶⓫⑤?❾❀⑤⓲❆?36?⑪??⑩①✶??⑳✾❊❽37?②??⑰⑤?⓳④⑥???38❈③❀?⑫⑦?✺④✽?❀?39④⑯??✷?⑪⓫?⓯❾❈???40❻✻❁⑤???❀??✶✻⓲✳⑲41②???✺???✴⑨⓴???❾42❇???⓲⓲⑳④⓯?❿?⑪?❶43???????????44AXMAS 3Cell FormulasRangeFormulaI10,Z12I10=FORMULATEXT(I11)I11:W43I11=AXMAS(30,4,H3:AG8)Z13:AL34Z13=AXMAS(20,3,H5:AF7)Dynamic array formulas.


----------



## Xlambda (Dec 24, 2021)

*AXMAS* with numbers as ornaments array and CF, icon sets, data bars, color scales.
To get rid of the number values, for icon sets check "show icons only", for color scales and data bars, custom number formatting, at "type" field only ";"
=AXMAS(30,5,SEQUENCE(50))
*Unfortunately, here, on mini-sheet do not show*. On spreadsheet looks very nice, especially the data bars. Uploaded (inserted) some captures. ✌️


----------



## Xlambda (Dec 24, 2021)

AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG1AX(ht,sh) no ornaments array, does not call any lambda2- this is the part of the function that embeds the ornaments values array, for that reason, the formula does not need AFLAT anymore.3….q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q))….4This was possible because I found 2 large enough segments of consecutive unicode values,5that also look nice as ornaments.67=LET(q,SEQUENCE(44,,10035),UNICHAR(IF(q>10058,q+117698,q)))8✳9✴=AX(30,5)=AX(30,4)10✵ ⭐ ⭐11✶▒▒12✷??13✸?✽14✹❆✿✾?15✺✶?✳❊❆✻16✻✴??✼?❅17✼❊✾???❇18✽?✴✷?❁?✿?19✾✶❆✳?❉??✺20✿✸✼❈✵❆?✺✵❅❇21❀✸✿???❂❀✴??22❁❈?????????❅?23❂??✻✻✴✾??✷✶??24❃❄✽❄?✶❇✴?❅??❀25❄❃??✺?❊✶???❃???26❅❉❅✵?❈❉?✸??❊❀???✳27❆❂✾✵❃❃❇❁✳✴❇❁?❆?✸✸28❇❇❂✹❊?❂??????✹❀✽✽29❈✺?✺✹?????❇??❂???30❉✺???❈?✳✶❇???✳?❃??✳✼?31❊✿✹✺?✸❇?❀???✺❁?✻?✽❈❊❁32?❁❂?✸✻❁???❅❊?❃?✹✷????33?✼?❁?✳✺✸✵?????✸?❄❅❁??34?✸✴?✵?✺❆❅?✸❊????❄✷❈❉❉?❉35??❃❊??✽????❂?✿???✼✿?✿❇?✺❇36?❁???✵??✵?✺❄❂?✺?❃❊?✿✳✿❈❆✽37?✸❉❇??❊?✷????✿✶??❇✼✹❀❃??❊38??✿?✹❉❀????✿???❁??????✹?✼❅✸39?✻???❀❃??❊❇✽??✴✳✼❁❅❄??❅????40????????✵✶❈?✿❉✹?✿❃??❊?❃41?✽?❄??✹❇❈❈??❂✻✴❂42????????????43?AXMAS 5Cell FormulasRangeFormulaB7,R9,E9B7=FORMULATEXT(B8)B8:B51B8=LET(q,SEQUENCE(44,,10035),UNICHAR(IF(q>10058,q+117698,q)))E10:O40E10=AX(30,5)R10:AF42R10=AX(30,4)Dynamic array formulas.


----------



## Xlambda (Dec 24, 2021)

*Writing an **argument free** lambda that can store values with formulas. LAMBDA(LET(...*
*AO()* - Array Ornaments

```
=LAMBDA(LET(q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),INDEX(o,SEQUENCE(4,11))))
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD1Crazy scenario for fun: Using AX embedded ornaments array with AXMAS function.23We can write an argument free lambda called AO()  45=LAMBDA(LET(q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),INDEX(o,SEQUENCE(4,11))))()6✳✴✵✶✷✸✹✺✻✼✽7✾✿❀❁❂❃❄❅❆❇❈=AXMAS(23,4,AO())8❉❊????????? ⭐9???????????▒10✾11Note: Added the INDEX at the end to see it in a more compact way,✽12AXMAS being able to deal with any arrays.?❇❅13❊?✺14=AO()storage box✵??15✳✴✵✶✷✸✹✺✻✼✽❃??16✾✿❀❁❂❃❄❅❆❇❈❉✽❇?✻17❉❊?????????❄❂❁?❆18???????????❄???✹19??❇?✽20We can consider Array Ornaments lambda, AO() ,??✾❃✿✿?21the storage box that saves them for next years use.?????❅✸?22?❁?✷❈❄✷23?✻✴❃???24❃?✷✶✷??✺?25✺?✾❂??❁??26❉❄✸?❉??❉?27?✶✿✴??✾❇❁28✾✸✻❆✹?✾?❈✹?29✿❀✵✾?✽?????30✳???❇???❂??31❇?✶???????✼32???????33AXMAS 6Cell FormulasRangeFormulaB5,B14,R7B5=FORMULATEXT(B6)B6:L9B6=LAMBDA(LET(q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),INDEX(o,SEQUENCE(4,11))))()R8:AB32R8=AXMAS(23,4,AO())B15:L18B15=AO()Dynamic array formulas.


----------



## Xlambda (Dec 25, 2021)

Everybody is free to believe in whatever they consider. Me, I believe in Santa, *Excel's Santa*. So, the other day, I wrote him a letter. It was a *secret wish*, but now I am going to disclose it. I've wished for *more recursive iterations*. Very anxious, when I woke up this morning, I run under my Xmas tree to open the present boxes, hoping that I will find at least *"1000 iterations"*. Instead, look what I found. ?
AXMAS.xlsxABCDEFGHIJKLMNO123 ⭐4▒5✾6?7?❂❉8❅?❉9?❉❉10✿✻?11??✻?✳12?????13????✻14?✻???15✺✵?✸❉✿✽16???✵?✾✺17✺❇???✹❀18✳??✸✹?✿19❊?✸✹✴?✶✶?20???✷?❉❂✷✼21??????❂??22❃❀❄?✳❄❂✷?23❀✶✻???❈❅❁??24✾??✾✶❄✻?❅✳✻25???✿❄?✳???✷26????✻?❂✹?✶✵27✻✿?❆❊❊???✻✵❇✾28✵✻?✿❁?❄?❀?❊??29❇❃???❄❄✾??❄✿?30?❂✴?✾?✻?✹??✵?31#NUM!#NUM!#NUM!#NUM!#NUM!#NUM!#NUM!#NUM!#NUM!3233I know what Santa did, he hacked my AX function, just at the beginning, 34=LAMBDA(ht,sh,LET(t,UNICHAR(11088),i,UNICHAR(9618),p,0^0,….,35and replaced the present boxes unichar value "p" with 0^0  ☹️☹️36Sheet6Cell FormulasRangeFormulaB3:N31B3=LAMBDA(ht,sh,LET(t,UNICHAR(11088),i,UNICHAR(9618),p,0^0,q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),n,44,h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),IF(a,w,"")))(25,4)Dynamic array formulas.


----------



## Xlambda (Dec 25, 2021)

As I've shared with you, I did not receive anything good from Excel's Santa, but, I've missed a present box, and….what I found inside is amazing. 
It's a *solution* for something that has been bothering me since day one of the new lambda helper functions. The fact that *BYROW or BYCOL do not spill arrays, only single values*. 
Solved it before though, with an "external" function as "accumulator" (latest posts ASCAN's thread). This solution does not need any. Good Excel's Santa after all*. *?✌️?
AXMAS.xlsxABCDEFGHIJKLMNOPQR12asort ascending byrow does not spill323114=BYROW(B3:F5,LAMBDA(a,SORT(a,,1,1)))478598#CALC!56446367The Solution8sort ascending "byrow"9=LET(a,B3:F5,r,ROWS(a),s,SEQUENCE(r),REDUCE(0,s,LAMBDA(v,i,IF(SEQUENCE(i)=i,SORT(INDEX(a,i,),,1,1),v))))101123411578891234466Works!!!1314unique "byrow"15same formula, we only have to replace function SORT with UNIQUE16=LET(a,B3:F5,r,ROWS(a),s,SEQUENCE(r),REDUCE(0,s,LAMBDA(v,i,IF(SEQUENCE(i)=i,UNIQUE(INDEX(a,i,),1),v))))17231418785919643#N/AWorks!!!2021this is the construction that works without any other "accumulator", performing calculations "byrow" that can spill.22 =REDUCE(0,SEQUENCE(ROWS(a)),LAMBDA(v,i,IF(SEQUENCE(i)=i, function(INDEX(a,i,)),v)))23This is the solution I found in the present box!!!! ✌️✌️2425Defining a custom made lambda helper "byrow" that spills (name it AROW),26needs a lambda as argument that embeds the function that instructs REDUCE what to perform. (like in our examples)2728if y(x)=LAMBDA(x,function(x)), then:29AROW(a,y)=LAMBDA(a,y,LET(r,ROWS(a),s,SEQUENCE(a),REDUCE(0,s,LAMBDA(v,i,IF(SEQUENCE(i)=i,y(INDEX(a,i,)),v)))))30Calling it =AROW(a,LAMBDA(x,function(x))) will work for any function(x)31In other words, whatever results y(x) can spill (horizontally) for a single row,32AROW will do it "byrow", for each row of an array "a"3334Ofcourse "y" can represent lambdas with more arguments, will see how to instruct reduce to handle them.35AXMAS giftCell FormulasRangeFormulaI3,B16,B9I3=FORMULATEXT(I4)I4I4=BYROW(B3:F5,LAMBDA(a,SORT(a,,1,1)))B10:F12B10=LET(a,B3:F5,r,ROWS(a),s,SEQUENCE(r),REDUCE(0,s,LAMBDA(v,i,IF(SEQUENCE(i)=i,SORT(INDEX(a,i,),,1,1),v))))B17:E19B17=LET(a,B3:F5,r,ROWS(a),s,SEQUENCE(r),REDUCE(0,s,LAMBDA(v,i,IF(SEQUENCE(i)=i,UNIQUE(INDEX(a,i,),1),v))))Dynamic array formulas.


----------



## Xlambda (Dec 27, 2021)

Ornaments "storage" array *AO()* was not the first *lambda argument free function*. First was about creating a chessboard *ACHESS()
For fun*, I found a way to be able to play *chess*. Other functions on mini-sheet *ACHESS, AROTATE* (last post AFLIP thread)
Other ideas that can use lambda argument free functions could be *shuffling n decks of cards* or *rolling n dices.
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD11. All 4 chessboard possible orientations, CF "pattern" conceptCF "pattern" rules a1=h8=black=TRUE ; h1=a8=white=FALSE2CF formula (drag and drop)3CF formula concepta8=153=odd=white=false=ISEVEN(a8)4=ACHESS()=UNICODE(B5:B12)+UNICODE(C13:J13)=ISEVEN(UNICODE($B5)+UNICODE(C$13))58♜♞♝♛♚♝♞♜153154155156157158159160FALSETRUEFALSETRUEFALSETRUEFALSETRUE67♟♟♟♟♟♟♟♟152153154155156157158159TRUEFALSETRUEFALSETRUEFALSETRUEFALSE76151152153154155156157158FALSETRUEFALSETRUEFALSETRUEFALSETRUE85150151152153154155156157TRUEFALSETRUEFALSETRUEFALSETRUEFALSE94149150151152153154155156FALSETRUEFALSETRUEFALSETRUEFALSETRUE103148149150151152153154155TRUEFALSETRUEFALSETRUEFALSETRUEFALSE112♙♙♙♙♙♙♙♙147148149150151152153154FALSETRUEFALSETRUEFALSETRUEFALSETRUE121♖♘♗♕♔♗♘♖146147148149150151152153TRUEFALSETRUEFALSETRUEFALSETRUEFALSE13abcdefgh1415=AROTATE(ACHESS(),1)a1=146=even=black=true=ISEVEN(a1)16 12345678=UNICODE($B17)+UNICODE(C$16)=ISEVEN(UNICODE($B17)+UNICODE(C$16))17a♖♙♟♜146147148149150151152153TRUEFALSETRUEFALSETRUEFALSETRUEFALSE18b♘♙♟♞147148149150151152153154FALSETRUEFALSETRUEFALSETRUEFALSETRUE19c♗♙♟♝148149150151152153154155TRUEFALSETRUEFALSETRUEFALSETRUEFALSE20d♕♙♟♛149150151152153154155156FALSETRUEFALSETRUEFALSETRUEFALSETRUE21e♔♙♟♚150151152153154155156157TRUEFALSETRUEFALSETRUEFALSETRUEFALSE22f♗♙♟♝151152153154155156157158FALSETRUEFALSETRUEFALSETRUEFALSETRUE23g♘♙♟♞152153154155156157158159TRUEFALSETRUEFALSETRUEFALSETRUEFALSE24h♖♙♟♜153154155156157158159160FALSETRUEFALSETRUEFALSETRUEFALSETRUE2526h8=160=even=black=true=ISEVEN(h8)27=AROTATE(ACHESS(),-1)=UNICODE($J28)+UNICODE(B$36)=ISEVEN(UNICODE($J28)+UNICODE(B$36))28♜♟♙♖h160159158157156155154153TRUEFALSETRUEFALSETRUEFALSETRUEFALSE29♞♟♙♘g159158157156155154153152FALSETRUEFALSETRUEFALSETRUEFALSETRUE30♝♟♙♗f158157156155154153152151TRUEFALSETRUEFALSETRUEFALSETRUEFALSE31♚♟♙♔e157156155154153152151150FALSETRUEFALSETRUEFALSETRUEFALSETRUE32♛♟♙♕d156155154153152151150149TRUEFALSETRUEFALSETRUEFALSETRUEFALSE33♝♟♙♗c155154153152151150149148FALSETRUEFALSETRUEFALSETRUEFALSETRUE34♞♟♙♘b154153152151150149148147TRUEFALSETRUEFALSETRUEFALSETRUEFALSE35♜♟♙♖a153152151150149148147146FALSETRUEFALSETRUEFALSETRUEFALSETRUE36876543213738=AROTATE(ACHESS(),2)h1=153=odd=white=false=ISEVEN(h1)39hgfedcba=UNICODE($J40)+UNICODE(B$39)=ISEVEN(UNICODE($J40)+UNICODE(B$39))40♖♘♗♔♕♗♘♖1153152151150149148147146FALSETRUEFALSETRUEFALSETRUEFALSETRUE41♙♙♙♙♙♙♙♙2154153152151150149148147TRUEFALSETRUEFALSETRUEFALSETRUEFALSE423155154153152151150149148FALSETRUEFALSETRUEFALSETRUEFALSETRUE434156155154153152151150149TRUEFALSETRUEFALSETRUEFALSETRUEFALSE445157156155154153152151150FALSETRUEFALSETRUEFALSETRUEFALSETRUE456158157156155154153152151TRUEFALSETRUEFALSETRUEFALSETRUEFALSE46♟♟♟♟♟♟♟♟7159158157156155154153152FALSETRUEFALSETRUEFALSETRUEFALSETRUE47♜♞♝♚♛♝♞♜8160159158157156155154153TRUEFALSETRUEFALSETRUEFALSETRUEFALSE4849general formula 50=iseven(unicode($horiz)+unicode(vert$))51ACHESS CFCell FormulasRangeFormulaB4,V39,M39,B38,V27,M27,B27,V16,M16,B15,V4,M4B4=FORMULATEXT(B5)B5:J13B5=ACHESS()M5:T12M5=UNICODE(B5:B12)+UNICODE(C13:J13)V5:AC12V5=ISEVEN(UNICODE($B5)+UNICODE(C$13))B16:J24B16=AROTATE(ACHESS(),1)M17:T24M17=UNICODE($B17)+UNICODE(C$16)V17:AC24V17=ISEVEN(UNICODE($B17)+UNICODE(C$16))B28:J36B28=AROTATE(ACHESS(),-1)M28:T35M28=UNICODE($J28)+UNICODE(B$36)V28:AC35V28=ISEVEN(UNICODE($J28)+UNICODE(B$36))B39:J47B39=AROTATE(ACHESS(),2)M40:T47M40=UNICODE($J40)+UNICODE(B$39)V40:AC47V40=ISEVEN(UNICODE($J40)+UNICODE(B$39))Dynamic array formulas.*


----------



## Xlambda (Dec 27, 2021)

AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZ12. Playing chess2step 2. copy the board as values3step 1. pick board orientationstep 3. CF the board =ISEVEN(UNICODE($M6)+UNICODE(N$5))4=AROTATE(ACHESS(),1)5 12345678123456786a♖♙♟♜a♖♙♟♜7b♘♙♟♞b♘♙♟8c♗♙♟♝c♗♙♗♞♟♝9d♕♙♟♛d♕♙♟♛10e♔♙♟♚e♔♙♟♚11f♗♙♟♝f♙♘♟♝12g♘♙♟♞g♙♟♞13h♖♙♟♜h♖♙♟♜1415step 4. moving pieces example:16e2-e4 => copy e2, right click e4, hit V (copy as value), delete e217This method keeps CF in place1819Note: we can not select a cell and move it with the mouse, 20because will disrupt CF21ACHESS playCell FormulasRangeFormulaB4B4=FORMULATEXT(B5)B5:J13B5=AROTATE(ACHESS(),1)Dynamic array formulas.Cells with Conditional FormattingCellConditionCell FormatStop If TrueN16,N6:U13Expression=ISEVEN(UNICODE($M6)+UNICODE(N$5))textNO


----------



## Xlambda (Dec 24, 2021)

*AXMAS , AX* two Xmas's trees design.
AX is a "tree" that is already decorated, does not call any other lambda. The ornaments are embedded in the function.
AXMAS  is an undecorated one. We can choose our own ornaments array "or". Call AFLAT.
AFLAT , flattens the ornament array, and gives us the versatility to deal with arrays of any shape, size, dimensions, with blanks/null strings, ranges, or other array formulas.
Both designs, randomly, change the display of ornaments every time spreadsheet recalculates, or if we hit F9.
Both lambdas share same concept design, creating a Xmas tree shape, a "triangular" array that can be filled with random values.
A triangular array is like designing a symmetric staircase, it has stairs or steps, and has 2 input parameters "ht", the approximate total height, and "sh", each stair height. Each stair width or depth is by default 1. Knowing these parameters, the function knows how to calculate nr. of steps, exact total height to accommodate nr. of steps and total width footprint of the "staircase".
Both lambdas share same ornament topper (2 parts), and same tree base, (last row) where presents boxes are placed. First variables after LET.
*AXMAS(ht,sh,or)*

```
=LAMBDA(ht,sh,or,
     LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),
        o,AFLAT(or),n,ROWS(o),h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
       IF(a,w,"")
    )
)
```
*AX(ht,sh)*

```
=LAMBDA(ht,sh,
    LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),
        n,44,h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
        IF(a,w,"")
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS1AXMAS(ht,sh,or)ornaments array sample2ht: approx.. height; if ht ignored or <9 => ht=9, (min tree height=9)❀❁❂❃❅❆??✿✽✾3sh: each "step" height; if ignored or <3 =>sh=3 (3 min."stair" height=3 )smallest treeht,15,sh,44or: ornaments array, any array, any shape, any valuesht,,sh,,(ignored)=AXMAS(15,4,X2:AH2)5Increasing sh value makes triangle's top angle smaller, (higher tree "slope")=AXMAS(,,X2:AH2) ⭐6For better visual experience, change the grids width to tiny squares, all centered aligned. ⭐▒7Predetermined ornaments, topper, 2 parts, tree base,present boxes.▒✿8If you want to change them, just after LET, variables t,i,p?❁9❅❃❀✽❅✽1011088⭐topper 1❃❆????119618▒topper 2❃❆❅✽✽❀12127873?base✽?❂✿❂❅❀❅13❂✽❅✾❁✾❀❆✿✾14Ornaments array values used by these trees in next post.?✾✾❀❀❆❁❆❆✿15Note: Ornaments shape, color, can look different on your spreadsheet.??❅❂❀❃16✿?❂❂❃17ht,30,sh,4❀✾❀?❁❅❅18=AXMAS(30,4,BH17:CU20)❃?❃❃❃✿✽19 ⭐ht,20,sh,, ❆✾?❃✿❀❃20▒=AXMAS(20,,BH17:CU20)❂✽✽❂❅❃✿21⏬ ⭐???22?▒23????24?????♕ornaments array as numbers25⏬???✼?=AXMAS(13,4,SEQUENCE(9))26?????? ⭐27???❀??????▒28✷?????????529?????⚽????330❊❇?❉?????❄??64131✻???✅????⏪?⭕??65232???⭕?⚓???✺???✴39733????❌??????❎??❄?25434?⏩✼?⭕✴????❈?????4694435?????❇????⭕✻?❆?✻??5363736✺⏩❂?⛄??✺??????????⚡⚡5323937?????⚓???❈????✿?✾?❂?2822838???✸???✿?????❁???❁??277348439?❉?????✿?♕❉??❎??✶???⏩??❀139769540???????????✻????❂???❉??❂619618241?✼??❅❈?❃✅✅?❆✹⚓??⭐⏬❊???⚡?621498342???????????????????????43????✅???⛄????44???❄??❄?✼⏬???Note: This values can be used with CF45???????????♔❅46??❊????????❀?47??????????????⚡48??⚽??????✾?❊???49??✵✵???❊?❃?????50?✶??✻?????❈????51???????????52AXMAS 1Cell FormulasRangeFormulaAG4,AI25,T20,B18,Y5AG4=FORMULATEXT(AG5)AG5:AM21AG5=AXMAS(15,4,X2:AH2)Y6:AC15Y6=AXMAS(,,X2:AH2)B10:B12B10=UNICHAR(A10:A12)B19:P51B19=AXMAS(30,4,BH17:CU20)T21:AF42T21=AXMAS(20,,BH17:CU20)AI26:AO42AI26=AXMAS(13,4,SEQUENCE(9))Dynamic array formulas.


----------



## Xlambda (Dec 28, 2021)

Having *fun*, again. *Deck of cards*, 13 ranks, 4 suits. *Concept
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWX1browsing for suits unicodesorder by suitsclmn with CForder by ranksclmn with CF2=AUNICHAR(9812,20,1,1)=SEQUENCE(52)↓=SEQUENCE(52)↓3♔ 9812↓=QUOTIENT(G8#-1,4)+2↓=MOD(P8#-1,13)+24♕ 98139824♠spades↓↓=MOD(G8#-1,4)↓↓=QUOTIENT(P8#-1,13)5♖ 98149827♣clubs↓↓↓=SWITCH(H8#,11,"A",12,"J",13,"Q",14,"K",H8#)↓↓↓=SWITCH(Q8#,11,"A",12,"J",13,"Q",14,"K",Q8#)6♗ 98159829♥hearts↓↓↓↓=SWITCH(I8#,0,D4,1,D5,2,D6,3,D7)↓↓↓↓=SWITCH(R8#,0,D4,1,D5,2,D6,3,D7)7♘ 98169830♦diamonds↓↓↓↓↓=J8#&K8#↓↓↓↓↓=S8#&T8#8♙ 98171202♠2♠1202♠2♠9♚ 98182212♣2♣2303♠3♠10♛ 98199825♡hearts3222♥2♥3404♠4♠11♜ 98209826♢diamonds4232♦2♦4505♠5♠12♝ 98219828♤spades5303♠3♠5606♠6♠13♞ 98229831♧clubs6313♣3♣6707♠7♠14♟ 98237323♥3♥7808♠8♠15♠ 9824other function8333♦3♦8909♠9♠16♡ 9825AUNICHAR9404♠4♠910010♠10♠17♢ 982610414♣4♣10110A♠A♠18♣ 982711424♥4♥11120J♠J♠19♤ 982812434♦4♦12130Q♠Q♠20♥ 982913505♠5♠13140K♠K♠21♦ 983014515♣5♣14212♣2♣22♧ 983115525♥5♥15313♣3♣2316535♦5♦16414♣4♣2417606♠6♠17515♣5♣2518616♣6♣18616♣6♣2619626♥6♥19717♣7♣2720636♦6♦20818♣8♣2821707♠7♠21919♣9♣2922717♣7♣2210110♣10♣3023727♥7♥23111A♣A♣3124737♦7♦24121J♣J♣3225808♠8♠25131Q♣Q♣3326818♣8♣26141K♣K♣3427828♥8♥27222♥2♥3528838♦8♦28323♥3♥3629909♠9♠29424♥4♥3730919♣9♣30525♥5♥3831929♥9♥31626♥6♥3932939♦9♦32727♥7♥403310010♠10♠33828♥8♥413410110♣10♣34929♥9♥423510210♥10♥3510210♥10♥433610310♦10♦36112A♥A♥4437110A♠A♠37122J♥J♥4538111A♣A♣38132Q♥Q♥4639112A♥A♥39142K♥K♥4740113A♦A♦40232♦2♦4841120J♠J♠41333♦3♦4942121J♣J♣42434♦4♦5043122J♥J♥43535♦5♦5144123J♦J♦44636♦6♦5245130Q♠Q♠45737♦7♦5346131Q♣Q♣46838♦8♦5447132Q♥Q♥47939♦9♦5548133Q♦Q♦4810310♦10♦5649140K♠K♠49113A♦A♦5750141K♣K♣50123J♦J♦5851142K♥K♥51133Q♦Q♦5952143K♦K♦52143K♦K♦6061CF for L8:L5962 =OR(UNICODE(RIGHT(L8,1))=9829,UNICODE(RIGHT(L8,1))=9830)63ADECK 1Cell FormulasRangeFormulaA2,U7,L7A2=FORMULATEXT(A3)G2,P2G2=FORMULATEXT(G8)A3:A22A3=AUNICHAR(9812,20,1,1)H3,Q3H3=FORMULATEXT(H8)D4:D7,D10:D13D4=UNICHAR(C4:C7)I4,R4I4=FORMULATEXT(I8)J5,S5J5=FORMULATEXT(J8)K6,T6K6=FORMULATEXT(K8)G8:G59,P8:P59G8=SEQUENCE(52)H8:H59H8=QUOTIENT(G8#-1,4)+2I8:I59I8=MOD(G8#-1,4)J8:J59,S8:S59J8=SWITCH(H8#,11,"A",12,"J",13,"Q",14,"K",H8#)K8:K59K8=SWITCH(I8#,0,D4,1,D5,2,D6,3,D7)L8:L59,U8:U59L8=J8#&K8#Q8:Q59Q8=MOD(P8#-1,13)+2R8:R59R8=QUOTIENT(P8#-1,13)T8:T59T8=SWITCH(R8#,0,D4,1,D5,2,D6,3,D7)Dynamic array formulas.Cells with Conditional FormattingCellConditionCell FormatStop If TrueU8:U59Expression=OR(UNICODE(RIGHT(U8,1))=9829,UNICODE(RIGHT(U8,1))=9830)textNOL8:L59Expression=OR(UNICODE(RIGHT(L8,1))=9829,UNICODE(RIGHT(L8,1))=9830)textNO*


----------



## Xlambda (Dec 28, 2021)

*ADECK([sh])*. The function.
*[sh]: shuffling argument: 0 or omitted deck shuffled, 1, cards ordered by suits.*
First variables after LET, s,c,h,d unicode values for spades, clubs, hearts, diamonds, if we want to change them.
*Note: *I could have chosen to make ADECK argument free, and always shuffle it, but I've considered that also having a deck in order could be useful. Anyhow ADECK() looks like an argument free function, but it isn't, has a single argument that can be omitted.

```
=LAMBDA([sh],
    LET(s,9824,c,9827,h,9829,d,9830,sq,SEQUENCE(52),q,QUOTIENT(sq-1,4)+2,m,MOD(sq-1,4),
       k,SWITCH(q,11,"A",12,"J",13,"Q",14,"K",q)&UNICHAR(SWITCH(m,0,s,1,c,2,h,3,d)),
       IF(sh,k,SORTBY(k,RANDARRAY(52)))
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMN1ADECK([sh]) function. A shuffled deck needs to have all the cards, and no duplicates23Shuffling a single deckcheck4=RANDARRAY(52)=SORTBY(A5:A56,B5#)=ADECK(1)=ADECK()=ADECK()=ROWS(UNIQUE(J5#))52♠0.15922610♣2♠2♦10♠5262♣0.341684♠2♣J♣A♣72♥0.125188J♠2♥J♠J♣82♦0.9404582♥2♦2♥5♠93♠0.6931822♠3♠A♥8♠103♣0.4525344♥3♣8♣J♦113♥0.2081919♠3♥8♦J♠123♦0.6427789♣3♦5♣9♦134♠0.0269043♥4♠Q♣3♥144♣0.9741189♦4♣9♥3♣154♥0.1635164♦4♥2♠8♣164♦0.2971466♣4♦4♦7♣175♠0.390451A♥5♠10♦9♠185♣0.8353325♥5♣Q♦Q♣195♥0.339222♣5♥A♣Q♠205♦0.8098568♥5♦K♣Q♦216♠0.846066K♠6♠3♦10♥226♣0.309345♠6♣Q♥4♦236♥0.445142A♠6♥7♦A♥246♦0.4023466♦6♦A♠A♦257♠0.736334K♥7♠Q♠3♦267♣0.905782J♥7♣3♣9♣277♥0.4226757♥7♥6♥J♥287♦0.6239046♥7♦6♦4♠298♠0.6529653♣8♠K♠7♦308♣0.9625369♥8♣9♠9♥318♥0.380866J♣8♥5♠6♠328♦0.64167210♦8♦4♥2♣339♠0.187997♦9♠J♥3♠349♣0.2059878♦9♣7♣10♦359♥0.5079993♦9♥10♥K♥369♦0.234728♠9♦K♦Q♥3710♠0.824449A♦10♠4♠8♦3810♣0.0039123♠10♣8♠5♦3910♥0.927853A♣10♥2♣10♣4010♦0.600534Q♦10♦3♥7♥41A♠0.3985497♠A♠5♥K♦42A♣0.713083Q♣A♣9♣6♥43A♥0.330515Q♥A♥8♥K♣44A♦0.662569J♦A♦6♠2♥45J♠0.03395♦J♠10♣6♣46J♣0.52591310♠J♣4♣A♠47J♥0.4146265♣J♥K♥5♥48J♦0.7832176♠J♦6♣2♦49Q♠0.9952497♣Q♠7♠5♣50Q♣0.744687K♦Q♣3♠4♣51Q♥0.75253910♥Q♥5♦K♠52Q♦0.73581K♣Q♦J♦8♥53K♠0.3883672♦K♠A♦4♥54K♣0.9324068♣K♣7♥6♦55K♥0.404414♣K♥9♦7♠56K♦0.91445Q♠K♦10♠2♠57ADECK 2Cell FormulasRangeFormulaB4,D4,F4,H4,J4,L4B4=FORMULATEXT(B5)B5:B56B5=RANDARRAY(52)D5:D56D5=SORTBY(A5:A56,B5#)F5:F56F5=ADECK(1)H5:H56,J5:J56H5=ADECK()L5L5=ROWS(UNIQUE(J5#))Dynamic array formulas.Cells with Conditional FormattingCellConditionCell FormatStop If TrueD5:P56Expression=OR(UNICODE(RIGHT(D5,1))=9829,UNICODE(RIGHT(D5,1))=9830)textNOA5:A56Expression=OR(UNICODE(RIGHT(A5,1))=9829,UNICODE(RIGHT(A5,1))=9830)textNO


----------



## Xlambda (Dec 28, 2021)

*Shuffling n separate decks of cards**.* It could be a very useful tool for *memory athletes.
Alex Mullen* is an American memory competitor, three-time world memory champion, and physician.
Alex Mullen memorized the order of over *28 decks* of cards at the 2015 World Memory Championships in Chengdu, China.
AXMAS.xlsxABCDEFGHIJKLMNO1Part 1. Static method. Shuffle n deck of cards, separate decks, each deck a separate column, easy to visualize, like in a memory contest, see picture.23Shuffling 3 decks of cards with IFShuffling 3 decks of cards with CHOOSEShuffling 3 decks of cards with SWITCH4not good, for every iterationok, ADECK() calculates 3 times, butok, but, like CHOOSE we have to write 5ADECK() should recalculatetoo static, imagine writing ADECK() 28timesexplicitly all iterations6=IF(SEQUENCE(,3),ADECK())=CHOOSE({1,2,3},ADECK(),ADECK(),ADECK())=SWITCH(SEQUENCE(,3),1,ADECK(),2,ADECK(),3,ADECK())77♣7♣7♣5♣8♦4♣J♣8♣J♦8Q♣Q♣Q♣Q♠3♦6♥7♥J♥A♠910♣10♣10♣8♥10♣4♠K♦7♥8♥10A♣A♣A♣Q♣A♥J♥9♥J♠2♦116♣6♣6♣6♣6♦A♦6♦7♣5♠125♥5♥5♥6♠7♠K♦5♠6♠4♦1310♥10♥10♥6♦Q♣Q♦10♣3♣3♣145♦5♦5♦K♣K♠8♣10♥3♦10♦157♦7♦7♦J♣5♠3♣10♠A♦3♥168♣8♣8♣3♦4♠3♥3♣Q♦K♠179♣9♣9♣K♠9♦8♠6♣2♠7♣18Q♥Q♥Q♥5♠Q♠Q♣2♠6♦K♥192♦2♦2♦2♥A♦9♣6♥J♣5♣204♦4♦4♦10♠10♠10♠4♠J♦6♣214♣4♣4♣3♥10♦5♥Q♣5♥6♥22Q♦Q♦Q♦3♠6♠7♣Q♠9♣10♥238♠8♠8♠J♥J♥9♠A♥10♠5♦2410♦10♦10♦7♣7♥6♦2♣4♥Q♦257♠7♠7♠10♦7♦K♣7♣2♥J♠262♠2♠2♠A♦K♥7♥3♠8♦9♦27A♠A♠A♠5♥2♣A♠7♠K♣A♦283♦3♦3♦9♣A♠5♠6♠K♥3♦29K♠K♠K♠9♥3♥7♦5♦5♦A♥304♠4♠4♠4♦2♥4♦9♣10♦Q♣3110♠10♠10♠9♠10♥3♠3♥K♦9♣329♥9♥9♥J♠9♥10♦8♣8♠3♠339♦9♦9♦A♥J♦J♣5♥8♥4♥346♥6♥6♥10♥8♣Q♠4♣K♠10♠356♦6♦6♦8♦Q♥10♥K♣Q♥6♠36K♥K♥K♥Q♦Q♦7♠8♦4♣K♣37A♦A♦A♦4♥2♦2♣J♠10♥2♥38Q♠Q♠Q♠5♦9♣3♦7♦Q♠7♠39J♦J♦J♦8♣7♣5♣Q♥A♠4♣405♣5♣5♣K♦9♠K♠2♥4♠A♣413♣3♣3♣2♠5♦2♦5♣3♠2♠42J♣J♣J♣6♥K♦2♠A♦6♥Q♥432♣2♣2♣2♣5♣J♦2♦5♠J♣442♥2♥2♥Q♥K♣5♦A♣2♣8♣453♥3♥3♥A♠6♣6♠9♠7♠K♦466♠6♠6♠A♣4♥K♥3♦4♦J♥47J♠J♠J♠7♥8♥A♣9♦9♠7♥485♠5♠5♠J♦8♠4♥8♥3♥6♦499♠9♠9♠4♣3♣8♦10♦7♦2♣508♦8♦8♦8♠A♣J♠Q♦9♦8♠513♠3♠3♠K♥J♠9♦A♠Q♣9♥52A♥A♥A♥9♦4♦A♥J♥9♥8♦534♥4♥4♥4♠6♥Q♥4♦6♣5♥54K♦K♦K♦7♦J♣2♥J♦2♦Q♠55J♥J♥J♥2♦2♠10♣K♥A♥10♣56K♣K♣K♣7♠3♠6♣K♠10♣9♠578♥8♥8♥10♣4♣8♥8♠5♣7♦587♥7♥7♥3♣5♥9♥4♥A♣4♠59Sheet3Cell FormulasRangeFormulaA6,F6,J6A6=FORMULATEXT(A7)A7:C58A7=IF(SEQUENCE(,3),ADECK())F7:H58F7=CHOOSE({1,2,3},ADECK(),ADECK(),ADECK())J7:L58J7=SWITCH(SEQUENCE(,3),1,ADECK(),2,ADECK(),3,ADECK())Dynamic array formulas.


----------



## Xlambda (Dec 28, 2021)

This is how a new challenge for *Alex Mullen* looks like. *29 decks*. This is surreal !!
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE1Part 2. Dynamic method. Shuffle n deck of cards, separate decks, each deck a separate column, easy to visualize, like in a memory contest2The "solution" (Excel's Santa's gift) comes to rescue, this time on a column orientation.check for no dups each deck (column)3nr. decks29=SUM(BYCOL(B7#,LAMBDA(a,COUNTA(UNIQUE(a)))))/D3=524shufflenD4 -if "n" array freezed, if "y" array of D3 decks recalculatesTRUE5checks if total count of unique elements of each column divided by nr. decks =526=LET(n,D3,x,REDUCE(0,SEQUENCE(,n),LAMBDA(v,i,IF(SEQUENCE(,i)=i,ADECK(),v))),IF(D4="y",x,B7#))7A♥7♣2♣7♦7♣Q♥8♥4♥9♥9♦2♦Q♦9♥10♠A♠2♦6♦6♦9♣10♥9♦2♠7♠A♥J♠4♥2♣9♥2♥810♥K♠Q♥Q♥Q♠8♥8♣3♥2♠6♥2♣Q♥J♥9♠8♦2♠9♠9♦9♥9♥7♥7♣3♣9♣6♥J♦A♥A♦3♠96♠8♥K♣K♦9♥Q♣7♦10♣Q♠Q♠K♥4♦5♣7♦7♦J♦Q♥9♠10♠J♦8♠4♦Q♣Q♥10♣3♠9♠J♥10♥109♣10♦3♠2♠3♦5♠6♣3♣8♣8♥7♥8♣5♠3♦4♥10♥8♦3♦J♥4♣J♠6♠A♠2♠7♦7♦8♦Q♦9♣118♠Q♦8♥7♠9♦10♥4♦4♠3♠9♣J♣4♥A♣8♥10♥J♥5♥K♥10♦K♦10♠8♠K♣2♥8♣8♥7♦10♠Q♥124♥4♠A♣7♥J♦J♦K♣7♣2♥J♣8♦3♣2♥Q♦5♠4♠A♦Q♦5♦4♠7♦Q♥Q♠6♦10♦7♣3♥J♣2♠13J♠3♠7♠J♣7♦4♠8♦5♦J♦Q♦Q♦K♠2♣9♦4♠A♣2♣5♣2♣K♣3♥K♣2♥9♥K♦2♦2♥J♦7♦14K♦9♠J♦J♥10♣A♥6♠K♠2♦7♦9♠J♦9♣6♣Q♣J♠K♦6♥3♣4♦9♣3♣4♦A♣9♥Q♦J♦10♦7♠153♠Q♥K♦5♣3♠2♥5♥K♦6♥6♦J♠2♥J♣A♥3♣7♦5♣5♦Q♠7♦3♣K♦10♣4♦3♥Q♥5♦6♣J♦16J♣J♣10♦5♥A♦8♦Q♥9♥8♦4♦9♥9♦7♠3♣9♠3♣7♣7♥Q♣A♠A♦Q♣9♣7♣J♦6♠K♥5♥5♥176♥9♥2♦4♠J♥5♦7♠J♠8♥10♣2♥7♣8♥5♠4♦4♦2♦9♣J♦3♦K♥8♦8♠K♠Q♦5♦Q♥K♥6♠183♥K♥J♠10♦8♦2♠Q♠Q♣7♣9♠A♥9♠7♣J♥9♣5♣10♥10♦Q♥7♠4♣5♣5♥7♠6♦A♠6♣8♥5♣193♣J♠A♠3♥K♣4♣5♦7♥4♠8♠A♣6♥3♦3♥8♥A♥3♦7♣8♦Q♣3♠2♦9♦8♦8♦2♣6♦K♣8♣2010♣K♣K♠J♦6♥8♠3♥5♣3♦3♦7♠5♣A♠2♥8♠3♦10♣3♥8♥A♦6♦J♥6♦4♠2♦Q♣A♣7♦A♦21K♠K♦2♥Q♦5♥Q♠8♠6♥10♠10♠8♣K♥4♣2♦J♥5♥8♣9♥3♥10♠6♣7♠A♦4♣5♣10♣8♠K♠5♦225♥7♥Q♠9♠5♠A♠5♣6♦6♦2♠9♣2♠6♠7♥7♣8♣2♥Q♣3♦6♣7♣3♠4♠10♦K♠8♣4♠10♣8♠239♦9♦9♣2♥7♥3♠3♣A♣J♣4♠7♦5♦9♦K♥K♠5♦Q♦3♠10♣3♠2♦A♠8♣K♦6♣2♠5♠6♦8♦244♠A♣10♣6♦5♦10♦J♥A♥Q♣4♣3♣10♥3♣3♠J♦9♦A♣10♥5♠Q♦K♣10♥3♦10♣4♣10♥K♠3♥K♣256♦5♦4♠3♣4♦J♥J♦7♦A♦4♥10♠J♥9♠J♣4♣2♣5♦A♣4♣6♠10♦A♦J♠8♣A♦7♥4♣5♣3♣26Q♦4♥A♥10♥4♣10♠A♥2♣K♦8♣4♠A♦K♥10♣K♦3♥J♠J♠6♠6♥4♠9♥4♣2♣9♠3♣9♣9♠9♦275♦2♦7♥8♠8♣K♥A♠6♣J♠K♥6♣J♠2♠K♣7♥6♠9♥7♠10♥8♦5♦10♣7♦5♥3♣Q♠J♠6♥J♠289♠4♦A♦6♠2♦K♦2♣4♦4♣J♠8♠10♣K♦A♠Q♥K♣K♠A♦A♥8♣Q♥J♠8♥6♠3♠8♦3♣2♥A♥299♥8♦7♣A♥9♣7♦K♦Q♠Q♥10♦5♣Q♠Q♣8♣10♠7♥4♣A♠9♦10♣K♦6♦9♥9♦5♦5♣8♥5♠4♠30A♠A♥9♠Q♠A♥6♣6♦5♥7♥2♥8♥4♠Q♦6♥2♠Q♥4♥4♠3♠2♣2♠7♥K♦A♦10♠10♠J♣3♣3♦312♥3♣6♠K♣6♠9♥4♥Q♦7♠3♣3♠A♥10♣6♦6♦6♣7♦8♠A♠K♥2♣2♥8♦8♥2♥K♦A♠2♠4♣322♠5♥3♣3♠A♣6♠2♦9♣10♥3♥J♥7♥Q♠10♥5♦K♦6♣10♣7♠8♠4♦9♠3♠5♠7♥9♣Q♣8♦K♦332♣10♠8♠8♥2♣9♣9♠K♥5♥7♣2♠10♠10♠4♣K♥8♥A♠2♣K♦A♣10♣6♣7♥5♣2♠7♠10♣8♠4♥344♦6♠6♣5♠A♠3♥9♥J♦K♣J♥10♣8♥8♦7♣5♣5♠4♦4♦J♣J♠4♥9♦10♦K♣2♣8♠A♦7♣J♥352♦8♠J♣6♣4♥A♦A♣10♦3♥J♦5♦2♦6♥4♥Q♠9♠7♥2♦2♥2♠5♥A♣J♣4♥8♠9♦9♥J♠A♣366♣2♣6♦2♣10♠5♥10♦2♦9♠7♠4♦5♥5♦9♥6♣K♥8♥K♣K♠8♥A♠J♦J♥10♥A♥10♦Q♦4♥2♣37K♣4♣3♥K♠J♣6♦2♥2♥5♠5♣7♣A♠7♦A♦2♣4♥A♥5♥2♠9♣J♦4♠K♠3♠7♣K♣7♣Q♠3♥388♣7♠Q♣3♦2♥2♣3♠7♠4♥7♥6♥3♦6♣4♠7♠4♣2♠J♥6♣J♣5♠5♠10♥J♣4♠A♥7♥3♦7♥39A♦A♠5♦J♠5♣10♣3♦9♠9♦A♥3♥4♣J♠J♦3♥9♣K♥6♠A♦Q♥8♣8♥K♥Q♣6♠6♥2♠4♣Q♣404♣J♥3♦7♣Q♥3♦2♠2♠6♣Q♣6♦3♥3♥7♠10♦8♦Q♠5♠A♣3♣8♥7♦A♣Q♠5♥4♠5♣K♦K♠41Q♥10♣8♣9♦8♠4♦10♠8♦3♣8♦Q♥7♦4♦Q♣2♦K♠3♥8♥4♥2♦J♥5♥2♦8♠8♥A♦8♣Q♣10♠4210♠5♠K♥5♦4♠A♣Q♦8♣Q♦A♦A♦9♣Q♥4♦6♥Q♦J♦K♠K♣4♥Q♠K♥4♥Q♦Q♣3♥9♦2♣7♣437♠6♦2♠10♣7♠J♠K♥8♥9♣5♠4♣K♦A♦5♦2♥Q♠K♣Q♥7♣7♣A♣4♣A♥7♥4♦J♣5♥A♥Q♠445♠10♥6♥6♥K♥9♠9♣10♥2♣5♦5♠Q♣7♥5♣Q♦3♠4♠2♠8♠Q♠5♣4♥Q♥K♥9♣9♥2♦2♦6♦457♣2♠Q♦Q♣3♣3♣A♦K♣A♥10♥5♥3♠8♠2♠10♣10♠9♦7♦J♠9♠7♠10♠3♥6♥7♠5♠4♥5♦5♠46A♣3♦J♥A♦3♥7♥5♠J♣5♦K♠10♦A♣6♦6♠3♠A♦3♣8♦8♣5♠6♥6♥5♦3♣5♠K♥K♦8♣J♣4710♦6♥5♣K♥J♠4♥10♥A♦7♦2♣9♦6♦10♥5♥J♠6♦Q♣10♠Q♦7♥J♣Q♦6♥5♦3♦J♥10♦3♠10♦48J♦Q♠7♦8♦9♠5♣J♣Q♥K♥6♣10♥6♣5♥8♦A♥10♣9♣4♥6♦3♥10♥10♦9♠A♠K♥6♦Q♠10♥6♣493♦A♦8♦4♥10♥J♣9♦8♠4♦A♣3♦5♠3♠8♠8♣A♠J♣J♦7♥9♦Q♣K♠6♠3♥Q♠5♥4♦9♣10♣50Q♣3♥4♥9♣K♦2♦J♠5♠A♣Q♥K♠J♣K♣K♠9♥9♥7♠A♥6♥2♥6♠3♦10♠J♠A♠K♠3♠6♠9♠515♣Q♣5♥4♦K♠Q♦4♣6♠10♦K♣6♠8♦4♥2♣9♦10♦3♠Q♠K♥J♥8♦9♣7♣7♦10♥9♠10♠A♠8♥528♥5♣5♠2♦Q♦8♣Q♣J♥5♣2♦J♦9♥4♠10♦K♣8♠10♦6♣4♦5♦2♥A♥2♣J♦J♥J♠6♠7♠2♦537♦8♣4♣A♣8♥6♥K♠A♠6♠K♦Q♣6♠A♥K♦3♦Q♣6♥3♣2♦10♦K♠3♥5♣10♠K♣3♦7♠7♥K♥54J♥J♦9♦10♠6♣9♦4♠3♠K♠3♠K♣2♣2♦Q♠6♠6♥6♠8♣4♠5♥A♥8♣2♠3♦J♣A♣3♦A♣9♥558♦2♥4♦9♥Q♣7♣6♥9♦J♥6♠K♦10♦J♦9♣5♥7♠J♥J♣5♣K♠3♦2♣J♦9♠A♣2♥J♥9♦6♥56Q♠6♣9♥A♠6♦7♠7♣10♠8♠A♠4♥8♠10♦A♣A♣J♣10♠K♦5♥6♦9♥5♦Q♦2♦9♦4♣K♣4♠4♦577♥9♣10♥4♣10♦K♠10♣3♦10♣5♥A♠K♣K♠J♠J♣7♣8♠2♥9♠A♥9♠Q♠6♣J♥Q♥6♣10♥Q♥A♠58K♥7♦10♠8♣2♠K♣7♥4♣A♠9♥Q♠7♠8♣Q♥A♦2♥5♠4♣7♦5♣Q♦J♣5♠6♣4♥4♦6♥4♦Q♦59ADECK 4Cell FormulasRangeFormulaR3,B6R3=FORMULATEXT(R4)R4R4=SUM(BYCOL(B7#,LAMBDA(a,COUNTA(UNIQUE(a)))))/D3=52B7:AD58B7=LET(n,D3,x,REDUCE(0,SEQUENCE(,n),LAMBDA(v,i,IF(SEQUENCE(,i)=i,ADECK(),v))),IF(D4="y",x,B7#))Dynamic array formulas.


----------



## Xlambda (Dec 29, 2021)

*Shuffling n deck of cards together* and dealing them in rounds of *k cards/round* until we run out of cards. 
To check the accuracy of the result array, the total number of occurrences of each card should be equal with the nr. of decks we have started with. ACOUNT was designed for scenarios like this.
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAAB1Part 3. Dynamic method. Shuffle n deck of cards, together,dealing them in rounds of k cards. Kind of casino approach.AFLATother functions on minisheet2Shuffling n=6 decks together and randomly deal all rounds of k=5 card/round until we run out of cards.ARESIZE3ACOUNT4Now we can use IF with ADECK()flatten 6 decks will have (rounds can have dups)checking using ACOUNT5or ADECK(1), randomizing will take place after.6*52=312 cardsshuffling 6 decks togetherdeal rounds of k=5 cards with ARESIZEas we see all unique cards are 6=nr. of decks6=IF(SEQUENCE(,6),ADECK())=AFLAT(B7#)=RANDARRAY(312)=SORTBY(J7#,L7#)=ARESIZE(N7#,,5)=SORT(ACOUNT(Q7#,2,1))7J♣J♣J♣J♣J♣J♣J♣0.8064276♦6♦3♦8♠9♣3♠10♠68A♦A♦A♦A♦A♦A♦J♣0.2559933♦J♦2♠6♣9♣10♣10♣697♥7♥7♥7♥7♥7♥J♣0.7804628♠10♥Q♦2♦7♠9♥10♥610A♥A♥A♥A♥A♥A♥J♣0.301579♣5♥10♥8♦4♠A♦10♦61110♥10♥10♥10♥10♥10♥J♣0.3834233♠Q♣10♥7♦K♣J♦2♠6129♥9♥9♥9♥9♥9♥J♣0.216767J♦6♥10♠3♥9♥3♣2♣613K♥K♥K♥K♥K♥K♥A♦0.1920332♠9♥9♣8♥Q♠10♠2♥614J♠J♠J♠J♠J♠J♠A♦0.7369436♣9♠2♦A♠4♦6♠2♦6156♦6♦6♦6♦6♦6♦A♦0.2367699♣2♦9♥5♠8♦10♦3♠6165♣5♣5♣5♣5♣5♣A♦0.58631410♣9♠3♣2♥5♠10♣3♣617Q♦Q♦Q♦Q♦Q♦Q♦A♦0.05599910♥2♥4♥3♠10♠7♣3♥618A♣A♣A♣A♣A♣A♣A♦0.470341Q♦8♥K♠9♥6♥J♠3♦6196♠6♠6♠6♠6♠6♠7♥0.7183662♦K♥J♠8♣A♠A♦4♠6207♣7♣7♣7♣7♣7♣7♥0.322877♠3♠2♦6♠3♣2♦4♣6214♣4♣4♣4♣4♣4♣7♥0.7711949♥J♣Q♥Q♣5♦K♦4♥6229♣9♣9♣9♣9♣9♣7♥0.8469385♥10♦2♣8♦A♦8♦4♦6232♠2♠2♠2♠2♠2♠7♥0.91400610♥4♣6♦Q♥Q♦K♥5♠62410♣10♣10♣10♣10♣10♣7♥0.9110688♦2♠J♣6♦4♠4♠5♣6253♦3♦3♦3♦3♦3♦A♥0.5146864♠5♦J♠7♦7♦6♠5♥62610♦10♦10♦10♦10♦10♦A♥0.692273A♦3♦4♥8♣5♠A♣5♦627K♣K♣K♣K♣K♣K♣A♥0.584992Q♣4♦3♥4♥5♥J♣6♠6285♥5♥5♥5♥5♥5♥A♥0.59323810♥7♠7♠6♠3♣6♦6♣6298♣8♣8♣8♣8♣8♣A♥0.9836217♦8♣3♦7♥6♦8♦6♥6309♦9♦9♦9♦9♦9♦A♥0.731489K♣9♠K♣K♣5♣9♣6♦6316♣6♣6♣6♣6♣6♣10♥0.060334J♦4♦7♠2♠9♦2♠7♠6323♣3♣3♣3♣3♣3♣10♥0.4504396♥Q♠Q♥5♥J♣Q♣7♣633Q♥Q♥Q♥Q♥Q♥Q♥10♥0.74654610♠6♣K♥Q♠Q♥3♥7♥634Q♣Q♣Q♣Q♣Q♣Q♣10♥0.0265883♥8♣7♣8♠7♣9♠7♦6356♥6♥6♥6♥6♥6♥10♥0.0516319♥2♠2♣10♣2♥6♠8♠636A♠A♠A♠A♠A♠A♠10♥0.5842893♣4♥9♠10♥5♦4♠8♣6373♥3♥3♥3♥3♥3♥9♥0.5748359♥2♥Q♠3♥2♣A♦8♥6388♦8♦8♦8♦8♦8♦9♥0.0976739♣9♣4♣5♦K♥Q♣8♦639K♠K♠K♠K♠K♠K♠9♥0.1248758♥A♥8♠4♥5♣8♣9♠6407♠7♠7♠7♠7♠7♠9♥0.178976Q♠J♥5♥4♣7♣5♣9♣641Q♠Q♠Q♠Q♠Q♠Q♠9♥0.0915910♠J♠A♣K♠9♥6♣9♥6424♠4♠4♠4♠4♠4♠9♥0.0498199♠10♥A♥A♦5♥A♥9♦6432♦2♦2♦2♦2♦2♦K♥0.483662♦10♦K♥7♦9♦K♠A♠6449♠9♠9♠9♠9♠9♠K♥0.253596A♠9♠10♣6♣K♦5♠A♣645K♦K♦K♦K♦K♦K♦K♥0.6021144♦K♣3♥K♣10♦8♦A♥6464♥4♥4♥4♥4♥4♥K♥0.1889216♠4♦4♥10♠6♥K♠A♦647J♥J♥J♥J♥J♥J♥K♥0.8025252♦K♦A♠7♠9♣10♠J♠6483♠3♠3♠3♠3♠3♠K♥0.3919899♥8♥Q♦5♣8♥3♦J♣6498♠8♠8♠8♠8♠8♠J♠0.1853235♠J♥2♦J♦Q♥Q♦J♥6507♦7♦7♦7♦7♦7♦J♠0.7812998♦K♠A♥7♣5♠K♦J♦6515♠5♠5♠5♠5♠5♠J♠0.55238310♦4♦9♦A♣6♦4♠K♠65210♠10♠10♠10♠10♠10♠J♠0.8876059♠K♣7♥3♠4♣3♠K♣6534♦4♦4♦4♦4♦4♦J♠0.2686383♣Q♠J♦A♥A♦10♣K♥6542♥2♥2♥2♥2♥2♥J♠0.1902532♥9♦10♥4♣J♦A♠K♦6555♦5♦5♦5♦5♦5♦6♦0.7129115♠Q♦8♥7♥6♣K♠Q♠656J♦J♦J♦J♦J♦J♦6♦0.31008410♣A♣3♠J♣J♠5♦Q♣6572♣2♣2♣2♣2♣2♣6♦0.3290882♥6♥J♥6♥3♣10♠Q♥6588♥8♥8♥8♥8♥8♥6♦0.0031014♥K♥3♦10♣J♣7♠Q♦6596♦0.258773♠A♠2♥6♣6♠10♦606♦0.24058810♠8♠2♣2♣7♥4♦615♣0.3480877♣4♣8♠K♦5♠J♠625♣0.8980278♥Q♥5♣A♣7♦9♦635♣0.549973K♠2♥7♥7♥4♠J♥645♣0.6656999♥Q♣J♥7♦7♣K♦655♣0.9805746♥3♦Q♦5♥2♣8♥665♣0.521563J♠8♣3♣6♥3♥2♠67Q♦0.659746K♥5♦5♣Q♣9♦10♦68Q♦0.681618J♠A♥J♥A♣8♠Q♠69Q♦0.9440268♣J♦A♠70Q♦0.248347A♠71down toQ♦0.764906A♦down to72312 rowsQ♦0.0281283♠312 rows73↓↓↓↓A♣0.5634692♦↓↓↓↓74A♣0.7100226♠ADECK 5Cell FormulasRangeFormulaB6,W6,J6,L6,N6,Q6B6=FORMULATEXT(B7)B7:G58B7=IF(SEQUENCE(,6),ADECK())J7:J318J7=AFLAT(B7#)L7:L318L7=RANDARRAY(312)N7:N318N7=SORTBY(J7#,L7#)Q7:U69Q7=ARESIZE(N7#,,5)W7:X58W7=SORT(ACOUNT(Q7#,2,1))Dynamic array formulas.


----------



## Xlambda (Dec 30, 2021)

*ANDECK([n],[k],[r])* *The function.* 
*Shuffles "n" decks of cards, 2 ways, separately (memory contest approach), or all together and deals "k" cards/round for a nr. of "r" rounds (casino approach).*
*Functionality:* 
- if k=0 or omitted, shuffles "n" decks of cards, separately, 1 deck/column, columns will have no dups (*memory contest approach*).
- if k>0, shuffles "n" decks of cards together in a single "pile", and extracts (deals) out of it, a nr. of "k" cards/round for a number of "r" rounds. (columns can have dups)(*casino approach*)
*Arguments:*
*[n]: nr. of decks to shuffle
[k]: nr. cards to deal/round
[r]: nr. of rounds when k>0, (decks shuffled together), or, when k=0 first "r" rows of the array of decks shuffled separately*

```
=LAMBDA([n],[k],[r],
    LET(c,SEQUENCE(,n),s,SEQUENCE(r),
      d,REDUCE(0,c,LAMBDA(v,i,IF(SEQUENCE(,i)=i,ADECK(),v))),
      f,AFLAT(d),a,ARESIZE(f,,k),
      IFS(n=0,ADECK(),k=0,IF(r,INDEX(d,s,c),d),r=0,a,TRUE,INDEX(a,s,SEQUENCE(,k)))
   )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAAB1arguments scenarios2nr.decksnr.cardsnr.rounds·1·2·4check3[n][k][r]Descriptionn,k,r omittedn,3,k,r omittedn,3,k,5,r omittedcount unique=n4·10001 deck shuffled=ANDECK()=ANDECK(3)=ANDECK(3,5)=ACOUNT(S5#,2,1)5·2n00n decks shuffled separately2♦6♠7♣5♥K♣7♥K♣2♥J♦K♣36·3n0rn decks, r rows of. whole array6♠3♣9♦2♠J♣6♠J♠6♦K♦7♥37·4nk0n decks, k cards, all rounds3♥5♦10♥Q♥9♠4♠5♦5♣Q♠2♥38·5nkrn decks, k cards, r rounds8♠9♥8♥5♣4♣J♥7♠A♠8♠J♦395♣10♥4♦10♣K♦7♥Q♦A♠J♣J♣310·33♠Q♦6♠J♥6♠8♠10♥8♦4♥6♠311n,3,k,,r,5K♦A♣8♦9♥A♥3♠A♥9♥A♥J♠312=ANDECK(3,,5)A♠8♣Q♥4♣10♥Q♦8♣J♦6♥6♦3132♦10♥9♦K♣10♠J♥4♦4♠5♥Q♥7♣4♦K♦3142♠3♦10♣2♥7♣4♣6♥3♣10♠J♥9♦9♣9♠315A♥Q♦Q♠9♦10♣A♣Q♣10♣8♠6♦Q♣7♠4♠3169♠4♦10♦A♣5♥8♠4♥A♦9♠6♣5♥5♣5♦3173♥5♣7♥7♠9♠K♠7♦4♥A♣6♣J♠K♣5♣318A♦6♥A♥8♣3♠4♦10♦2♣2♦Q♠319·5Q♦8♠Q♣K♦10♥8♥8♦2♦8♦4♣320n,3,k,5,r,79♥K♠9♣10♠10♣Q♥6♥5♠4♦J♥321=ANDECK(3,5,7)K♠5♣5♠J♣3♣4♠2♥5♠8♣7♠322A♦4♠3♦6♠7♠roundsQ♠Q♥10♦K♠4♥Q♦8♥K♠K♥A♠323K♥7♦2♥8♣Q♥J♥J♥7♥9♠7♦5♦2♠9♣9♦8♠3248♣6♦7♣9♥3♠9♣9♦5♣5♦7♣7♣6♥4♣2♠Q♦3257♠3♥A♠10♣Q♦Q♣A♠6♥A♠7♠A♦10♦Q♣10♦10♥3267♥8♣A♥4♣8♦7♦4♣9♠A♥6♦Q♠A♣A♣5♠8♦327K♠K♠3♣A♠J♥10♠J♦8♣10♥3♥Q♣K♦9♣9♠4♥3285♥6♠6♣6♥9♦10♣2♥5♥Q♠3♥J♠A♦3♣6♠A♥329c a r d s8♥7♦7♠K♣3♠7♦5♦Q♠K♥3♠3302♠4♠5♦A♣2♥3♥A♠K♠5♥9♥331K♥9♣3♥10♦3♦Q♥3♦2♠8♣8♣33210♦J♠3♦A♦2♣9♥9♥J♦4♣6♥3332♣2♠K♦7♥10♠J♥6♣9♦K♥5♥3344♠3♥6♣2♦J♣7♥10♠10♣7♦Q♥3358♣10♦Q♦3♥K♠2♣3♦5♣8♥7♣3364♦2♣2♠6♠2♦4♦3377♥4♥A♦8♦3♣338J♠7♠J♠Q♦10♠3396♥3♦4♥9♣9♦340Q♥5♠2♦6♦9♣3415♠K♦A♠8♠10♣34210♥6♣10♣K♥Q♣3433♦8♦K♥2♥A♦3444♣2♦2♣4♠6♣3459♠A♦10♠6♣A♣3464♥8♥2♥2♣10♦3476♦K♣6♦3♦2♣3486♣A♥K♣J♦2♦3497♣Q♠J♦3♣8♥3508♦K♥3♣J♠5♠351J♦3♠7♦3♠K♠3525♦J♣4♠5♠K♥353J♣7♥3♠8♥7♦3543♣6♦J♣9♦2♠3555♥4♦Q♠7♠3♥356A♥Q♣9♥7♣3♦357ANDECK 1Cell FormulasRangeFormulaL4,O4,E21,E12,Y4,S4L4=FORMULATEXT(L5)L5:L56L5=ANDECK()O5:Q56O5=ANDECK(3)S5:W36S5=ANDECK(3,5)Y5:Z56Y5=ACOUNT(S5#,2,1)E13:G17E13=ANDECK(3,,5)E22:I28E22=ANDECK(3,5,7)Dynamic array formulas.


----------



## Xlambda (Dec 30, 2021)

Forgot to mention *ANDECK* calls *ADECK* AFLAT , ARESIZE
Other functions on mini-sheet ACOUNT


----------



## Xlambda (Dec 30, 2021)

Checking the functionality, the differences between shuffling decks separately and all together, realized that something that was covered in the concept design was not reflected in the formula.
Shuffling n decks together requires creating a "pile" of all decks with AFLAT that needs another shuffling with SORTBY(f,RANDARRAY(ROWS(f)) . This part was missing. 
*ANDECK([n],[k],[r]) *Calls *ADECK *AFLAT , ARESIZE*. *Other functions on mini-sheet ACOUNT.

```
=LAMBDA([n],[k],[r],
    LET(c,SEQUENCE(,n),s,SEQUENCE(r),
       d,REDUCE(0,c,LAMBDA(v,i,IF(SEQUENCE(,i)=i,ADECK(),v))),
       f,AFLAT(d),a,ARESIZE(SORTBY(f,RANDARRAY(ROWS(f))),,k),
       IFS(n=0,ADECK(),k=0,IF(r,INDEX(d,s,c),d),r=0,a,TRUE,INDEX(a,s,SEQUENCE(,k)))
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAA1Differences between shuffling separately and all togetherother functionsfor both shuffling methods 2-checking the differences between ANDECK(5) and ANDECK(5,5)ACOUNTnr. of occurrences of all cards3(k=0, shuffling sep. ; k<>0 shuffling together)should be =  nr of decks4dealing 5 decks shuffled together=AND(V8:V59=5,Y8:Y59=5)55 decks shuffled separatelyin rounds of 5cards/round, all roundschecking for dups by clmsTRUE6no dups on columnsdups on columns possibleall values=52 => no dups7=ANDECK(5)=ANDECK(5,5)=BYCOL(B8#,LAMBDA(a,COUNTA(UNIQUE(a))))=SORT(ACOUNT(B8#,2,1))=SORT(ACOUNT(H8#,2,1))82♠9♠K♠4♣J♥3♣4♦7♦4♥6♦525252525210♠510♠59A♠K♠7♣2♣J♦9♣A♠Q♦Q♥A♥10♣510♣5103♣2♦A♠10♠8♠5♦7♣K♥Q♦6♥values <52 => clms have dups10♥510♥5119♠A♣7♠5♦9♠J♠2♠3♥J♠8♥=BYCOL(H8#,LAMBDA(a,COUNTA(UNIQUE(a))))10♦510♦512J♦J♣5♥Q♥J♠Q♥A♥3♦2♣8♥33373838342♠52♠513J♣6♦8♠6♣A♥7♠6♠J♣4♥5♥2♣52♣5143♥A♠3♥2♦5♠A♣5♣3♠K♦3♦2♥52♥5155♥10♥J♥K♣3♥2♦7♠A♠6♥2♣2♦52♦5164♣J♦10♥3♠10♠7♥7♣A♦8♠K♠3♠53♠5179♥2♥K♣3♦4♠2♦Q♠K♠Q♠8♦3♣53♣518K♥K♦Q♠8♣K♣4♠7♠6♦2♥A♥3♥53♥5197♦3♥5♦4♥4♦4♠4♥8♣3♥5♠3♦53♦5204♥5♥K♥6♦8♥K♣J♠10♠4♠5♣4♠54♠521A♣2♣7♥10♣10♣J♦4♣10♦10♠10♣4♣54♣5228♣6♠4♣8♦7♣5♣2♣10♦10♠6♦4♥54♥5232♦4♠4♠K♦A♣9♣A♣10♥3♠K♠4♦54♦5249♦8♥6♥K♠Q♣A♥J♦7♠6♥10♣5♠55♠525A♦9♥6♦5♠5♣9♠5♥K♦5♠3♥5♣55♣5262♥4♦3♣A♥7♦9♣J♣7♥8♣6♠5♥55♥5277♠8♣3♦J♣7♠4♦5♠5♠4♥5♥5♦55♦5288♦10♣J♣9♥2♥A♣4♦5♥J♦2♦6♠56♠5293♠4♣8♥A♦6♠10♦9♥Q♦6♣8♥6♣56♣5308♠10♦K♦7♥4♥8♠9♦8♦K♦6♦6♥56♥531J♠K♣2♠10♦Q♠J♦8♠8♠8♦7♦6♦56♦53210♦4♥7♦7♠A♦Q♥K♦10♥8♣Q♦7♠57♠53310♣J♥9♥4♦6♥Q♠7♥6♠J♠A♦7♣57♣5347♣8♠2♦9♣A♠4♠4♦6♣4♣Q♣7♥57♥5359♣3♦2♥10♥Q♦4♥9♥K♥2♣5♠7♦57♦536Q♣J♠9♣8♥5♥J♣3♦2♠10♥6♦8♠58♠537K♦K♥Q♣2♥7♥8♦2♥5♣3♣8♦8♣58♣538Q♠6♣9♠6♥9♥J♥Q♠3♣Q♣3♥8♥58♥5396♦2♠Q♦J♥4♣9♦7♣10♠2♠Q♠8♦58♦5408♥Q♦A♦8♠9♦3♣A♦9♠7♦10♣9♠59♠5416♣5♣A♥7♦K♠K♣5♦J♠4♦Q♦9♣59♣54210♥A♦5♠5♥2♣7♥K♦8♥9♥J♦9♥59♥5432♣5♠4♥9♦2♦K♠10♣3♦Q♣7♠9♦59♦544K♠7♣J♠9♠8♦10♥K♣A♣5♥K♣A♠5A♠5455♣7♥A♣7♣Q♥A♦4♣9♣J♥10♥A♣5A♣5467♥10♠10♣4♠10♦10♦K♣9♥10♣2♥A♥5A♥5476♥5♦6♣3♣K♥A♦6♥Q♣6♣5♦A♦5A♦548Q♥3♣2♣A♣6♦7♦3♣10♠Q♣9♣J♠5J♠5495♦7♠8♣Q♣3♠4♠K♥K♥5♦8♠J♣5J♣55010♠A♥Q♥J♦6♣2♠7♣3♦A♣8♣J♥5J♥551K♣Q♥J♦3♥2♠6♠3♥J♥K♠J♣J♦5J♦552J♥Q♣5♣K♥9♣7♣3♠6♥9♦2♠K♠5K♠5533♦6♥10♦A♠5♦2♥8♥6♠8♣K♥K♣5K♣554A♥Q♠9♦J♠K♦9♠6♣J♥5♣A♠K♥5K♥5556♠7♦6♠Q♠3♣7♥A♠9♦2♦Q♥K♦5K♦5564♠9♣4♦Q♦3♦4♣9♦Q♥10♦J♣Q♠5Q♠5575♠9♦10♠5♣J♣J♥7♦3♠6♣5♦Q♣5Q♣5584♦8♦3♠6♠8♣4♣2♥9♠9♠A♥Q♥5Q♥559Q♦3♠8♦2♠10♥2♦9♥A♠3♠2♣Q♦5Q♦560ANDECK 2Cell FormulasRangeFormulaU4,N11,N7,U7,X7,H7,B7U4=FORMULATEXT(U5)U5U5=AND(V8:V59=5,Y8:Y59=5)B8:F59B8=ANDECK(5)H8:L59H8=ANDECK(5,5)N8:R8N8=BYCOL(B8#,LAMBDA(a,COUNTA(UNIQUE(a))))U8:V59U8=SORT(ACOUNT(B8#,2,1))X8:Y59X8=SORT(ACOUNT(H8#,2,1))N12:R12N12=BYCOL(H8#,LAMBDA(a,COUNTA(UNIQUE(a))))Dynamic array formulas.


----------



## Xlambda (Dec 30, 2021)

What about *slot machines?* (named also *fruit machines*) ?
Fun fact from Wikipedia: "Slot machines are also known pejoratively as *one-armed bandits* because of the large mechanical levers affixed to the sides of early mechanical machines and the games' ability to empty players' pockets and wallets as thieves would."
A classical mechanical slot machine has "n" reels (3, 5 or more), each reel has same nr. of symbols.
Also, there is a "window" on which we can see 3 or more "lines"(rows) at a time,
The middle line is called payline.
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVW1Slot machines. Concept2If we "unfold" the reels in columns shape, a 3 reels slot machine with 10 symbols each, perfectly aligned will look like this:3(1-10 represents the index values of the 10 symbols)45all reels alignedsimulate "spinning" the reels with random values6111is like adding this values to each column (10 as top random value induces a "360º" spin)7222=RANDARRAY(,3,1,10,1)8333266to ensure that 9444index order is keptsingle cell formula for all steps10555=A6#+E8#=MOD(E11#-1,10)+1=MOD(SEQUENCE(10)+RANDARRAY(,3,1,10,1)-1,10)+111666377377437127774884885481388859959965914999610106101076101510101071111711871168121282298217913139331093181014141044110419111515155215201216162663262122reelall reels spined randomlyfor a  "window" that has 3 lines2310 symbols=INDEX(A24:A33,O11#)=INDEX(E24#,SEQUENCE(3),SEQUENCE(,3))24???????25???????← pay line26???????27???BAR28????Only thing left is hitting F9 to spin the reels29????30?BAR??31??BAR?32????33BAR???3435Note that on mechanical reels, order is kept36ASLOT 1Cell FormulasRangeFormulaA6:C15A6=SEQUENCE(10)+SEQUENCE(,3)^0-1E7,L23,E23,J10,O10,E10E7=FORMULATEXT(E8)E8:G8E8=RANDARRAY(,3,1,10,1)E11:G20E11=A6#+E8#J11:L20J11=MOD(E11#-1,10)+1O11:Q20O11=MOD(SEQUENCE(10)+RANDARRAY(,3,1,10,1)-1,10)+1E24:G33E24=INDEX(A24:A33,O11#)L24:N26L24=INDEX(E24#,SEQUENCE(3),SEQUENCE(,3))Dynamic array formulas.


----------



## Xlambda (Dec 30, 2021)

*ASLOT(ra,[nr],[nl])* The function.
ra: reel array (vertical 1D array)
[nr]: nr. reels: if 0 or omitted nr=3, or 3<=nr<=rows(ra)
[nl]: nr. lines: 0 or omitted, all reels revealed, or 1<=nl<=rows(ra)

```
=LAMBDA(ra,[nr],[nl],
    LET(r,ROWS(ra),w,MEDIAN(3,nr,r),l,MEDIAN(0,nl,r),
       a,INDEX(ra,MOD(SEQUENCE(r)+RANDARRAY(,w,1,r,1)-1,r)+1),
       IF(l,INDEX(a,SEQUENCE(l),SEQUENCE(,w)),a)
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD1ASLOT. The function23reel arraynr,nl,omitted =>nr,5,nl,omittednr,omitted,nl,3nr,omitted,nl,14?=> nr=3, nl=rows(ra)=> nl=rows(ra)=> nr=3=ASLOT(A4:A16,,1)5?=ASLOT(A4:A16)=ASLOT(A4:A16,5)=ASLOT(A4:A16,,3)???6????????????7??BAR??BAR??????nr,5,nl,78????????BAR???=ASLOT(A4:A16,5,7)9??????BAR???????10????BAR????nr,omitted,nl,5BAR???BAR11?BAR???????=ASLOT(A4:A16,,5)?????12?????????????????13?????????????????14???????????BAR?????15?????????????????16BAR??BAR???BAR????17????????18????????1920wrong arguments 21nr,omitted,nl,20nr,4,nl,-222nr,20,nl,3 if nr>rows(ra)=>nr=rows(ra) max nr=rows(ra)nl>rows(ra)=>nl=rows(ra)nl<0=>nl=0=>nl=rows(ra)23=ASLOT(A4:A16,20,3)=ASLOT(A4:A16,,20)=ASLOT(A4:A16,4,-2)24????????????BAR???????25?????BAR??????????BAR???26???????BAR??????BAR?????27?????BAR?28nr,-3,nl,4  if nr<0=>nr=3???????29=ASLOT(A4:A16,-3,4)??BAR????30??????????31BAR?????????32???BAR??????33???????BAR??34???????35??????BAR36???????37ASLOT 2Cell FormulasRangeFormulaS4,C29,X23,R23,C23,N11,S8,N5,H5,C5S4=FORMULATEXT(S5)S5:U5S5=ASLOT(A4:A16,,1)C6:E18C6=ASLOT(A4:A16)H6:L18H6=ASLOT(A4:A16,5)N6:P8N6=ASLOT(A4:A16,,3)S9:W15S9=ASLOT(A4:A16,5,7)N12:P16N12=ASLOT(A4:A16,,5)C24:O26C24=ASLOT(A4:A16,20,3)R24:T36R24=ASLOT(A4:A16,,20)X24:AA36X24=ASLOT(A4:A16,4,-2)C30:E33C30=ASLOT(A4:A16,-3,4)Dynamic array formulas.


----------



## Xlambda (Dec 24, 2021)

*AXMAS , AX* two Xmas's trees design.
AX is a "tree" that is already decorated, does not call any other lambda. The ornaments are embedded in the function.
AXMAS  is an undecorated one. We can choose our own ornaments array "or". Call AFLAT.
AFLAT , flattens the ornament array, and gives us the versatility to deal with arrays of any shape, size, dimensions, with blanks/null strings, ranges, or other array formulas.
Both designs, randomly, change the display of ornaments every time spreadsheet recalculates, or if we hit F9.
Both lambdas share same concept design, creating a Xmas tree shape, a "triangular" array that can be filled with random values.
A triangular array is like designing a symmetric staircase, it has stairs or steps, and has 2 input parameters "ht", the approximate total height, and "sh", each stair height. Each stair width or depth is by default 1. Knowing these parameters, the function knows how to calculate nr. of steps, exact total height to accommodate nr. of steps and total width footprint of the "staircase".
Both lambdas share same ornament topper (2 parts), and same tree base, (last row) where presents boxes are placed. First variables after LET.
*AXMAS(ht,sh,or)*

```
=LAMBDA(ht,sh,or,
     LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),
        o,AFLAT(or),n,ROWS(o),h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
       IF(a,w,"")
    )
)
```
*AX(ht,sh)*

```
=LAMBDA(ht,sh,
    LET(t,UNICHAR(11088),i,UNICHAR(9618),p,UNICHAR(127873),q,SEQUENCE(44,,10035),o,UNICHAR(IF(q>10058,q+117698,q)),
        n,44,h,MAX(9,ht),s,MAX(3,sh),ns,ROUNDUP(h/s,0),y,ns*s+1,x,2*ns-1,r,SEQUENCE(y),c,ABS(SEQUENCE(,x)-ns),
        a,QUOTIENT(r-1,s)>=c,b,INDEX(o,RANDARRAY(y,x,1,n,1)*a),w,SWITCH(r,1,t,2,i,y,IF(c<ns-2,p,""),b),
        IF(a,w,"")
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS1AXMAS(ht,sh,or)ornaments array sample2ht: approx.. height; if ht ignored or <9 => ht=9, (min tree height=9)❀❁❂❃❅❆??✿✽✾3sh: each "step" height; if ignored or <3 =>sh=3 (3 min."stair" height=3 )smallest treeht,15,sh,44or: ornaments array, any array, any shape, any valuesht,,sh,,(ignored)=AXMAS(15,4,X2:AH2)5Increasing sh value makes triangle's top angle smaller, (higher tree "slope")=AXMAS(,,X2:AH2) ⭐6For better visual experience, change the grids width to tiny squares, all centered aligned. ⭐▒7Predetermined ornaments, topper, 2 parts, tree base,present boxes.▒✿8If you want to change them, just after LET, variables t,i,p?❁9❅❃❀✽❅✽1011088⭐topper 1❃❆????119618▒topper 2❃❆❅✽✽❀12127873?base✽?❂✿❂❅❀❅13❂✽❅✾❁✾❀❆✿✾14Ornaments array values used by these trees in next post.?✾✾❀❀❆❁❆❆✿15Note: Ornaments shape, color, can look different on your spreadsheet.??❅❂❀❃16✿?❂❂❃17ht,30,sh,4❀✾❀?❁❅❅18=AXMAS(30,4,BH17:CU20)❃?❃❃❃✿✽19 ⭐ht,20,sh,, ❆✾?❃✿❀❃20▒=AXMAS(20,,BH17:CU20)❂✽✽❂❅❃✿21⏬ ⭐???22?▒23????24?????♕ornaments array as numbers25⏬???✼?=AXMAS(13,4,SEQUENCE(9))26?????? ⭐27???❀??????▒28✷?????????529?????⚽????330❊❇?❉?????❄??64131✻???✅????⏪?⭕??65232???⭕?⚓???✺???✴39733????❌??????❎??❄?25434?⏩✼?⭕✴????❈?????4694435?????❇????⭕✻?❆?✻??5363736✺⏩❂?⛄??✺??????????⚡⚡5323937?????⚓???❈????✿?✾?❂?2822838???✸???✿?????❁???❁??277348439?❉?????✿?♕❉??❎??✶???⏩??❀139769540???????????✻????❂???❉??❂619618241?✼??❅❈?❃✅✅?❆✹⚓??⭐⏬❊???⚡?621498342???????????????????????43????✅???⛄????44???❄??❄?✼⏬???Note: This values can be used with CF45???????????♔❅46??❊????????❀?47??????????????⚡48??⚽??????✾?❊???49??✵✵???❊?❃?????50?✶??✻?????❈????51???????????52AXMAS 1Cell FormulasRangeFormulaAG4,AI25,T20,B18,Y5AG4=FORMULATEXT(AG5)AG5:AM21AG5=AXMAS(15,4,X2:AH2)Y6:AC15Y6=AXMAS(,,X2:AH2)B10:B12B10=UNICHAR(A10:A12)B19:P51B19=AXMAS(30,4,BH17:CU20)T21:AF42T21=AXMAS(20,,BH17:CU20)AI26:AO42AI26=AXMAS(13,4,SEQUENCE(9))Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

Simulating *Slot machine*, mechanical, with *Form Controls*.
To be able to see the form controls, also inserted a screen capture.
AXMAS.xlsxABCDEFGHIJKLMNOPQR123Simulating Slot machine, mechanical, with Form Controls. (can be done with 3 or 5 reels)45=IF(AND(NOT(N11),N10=1),INDEX($D$7#,,1),I9#)6reel array=ASLOT(B7:B19,,3)↓=IF(AND(NOT(O11),N10=1),INDEX($D$7#,,2),J9#)7????↓↓=IF(AND(NOT(P11),N10=1),INDEX($D$7#,,3),K9#)8??BAR?↓↓↓9???????cell link option buttons form control10????111????TRUETRUEFALSE12?↑cell links check box form control13?   ↑   ↑   ↑↑14?block reel from spinning↑slot machine lever15?16?17?18?19BAR20ASLOT 3Cell FormulasRangeFormulaI5I5=FORMULATEXT(I9)D6D6=FORMULATEXT(D7)J6J6=FORMULATEXT(J9)D7:F9D7=ASLOT(B7:B19,,3)K7K7=FORMULATEXT(K9)I9:I11I9=IF(AND(NOT(N11),N10=1),INDEX($D$7#,,1),I9#)J9:J11J9=IF(AND(NOT(O11),N10=1),INDEX($D$7#,,2),J9#)K9:K11K9=IF(AND(NOT(P11),N10=1),INDEX($D$7#,,3),K9#)Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

*Digital* or virtual *slot machine* with a *deck of cards*. *Poker slot machine*. Mechanical vs digital.
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVW1Slot machine (mechanical or digitalized) with a deck of cards. Can we simulate dealing poker hands?2reel, deck of cards in order3=ADECK(1)- using ASLOT (mechanical)42♠As we see does not make a lot of sense when the cards are in order. 52♣Vertically order is kept whatever we use as reels, ADECK(1) or ADECK(), horizontally, 2 or more reels can be aligned,62♥meaning there will be lines with dups, fact that is not acurate with simulating dealing hands in a poker game72♦83♠all reels unfoldedcheking for dups "byrow" , if values <5 we have dups93♣=ASLOT(ADECK(1),5)=BYROW(C10#,LAMBDA(a,COUNTA(UNIQUE(a,1))))103♥Q♦Q♠7♠6♥7♠4113♦K♠Q♣7♣6♦7♣4- using ANDECK (digital, no mechanical reels possible)124♠K♣Q♥7♥7♠7♥4The only way to simulate poker hands slot machine is to134♣K♥Q♦7♦7♣7♦4digitalize it with ANDECK using a single deck of cards, to be sure 144♥K♦K♠8♠7♥8♠4will not have dups154♦2♠K♣8♣7♦8♣4165♠2♣K♥8♥8♠8♥4all rounds for single deckdigital poker slot machine with a 3x5 "window"175♣2♥K♦8♦8♣8♦4=ANDECK(1,5)=INDEX(K18#,SEQUENCE(3),SEQUENCE(,5))185♥2♦2♠9♠8♥9♠46♥7♣3♣A♦10♥6♥7♣3♣A♦10♥195♦3♠2♣9♣8♦9♣47♠9♠5♠2♠3♠7♠9♠5♠2♠3♠206♠3♣2♥9♥9♠9♥42♥2♣K♦5♣J♦2♥2♣K♦5♣J♦216♣3♥2♦9♦9♣9♦46♦K♠8♠8♥10♠226♥3♦3♠10♠9♥10♠49♦10♦6♣J♠Q♥or236♦4♠3♣10♣9♦10♣4Q♠9♥A♥7♦Q♣247♠4♣3♥10♥10♠10♥4K♥6♠J♥9♣4♠=ANDECK(1,5,3)257♣4♥3♦10♦10♣10♦47♥8♦5♦8♣A♠8♠7♠10♥K♠8♣267♥4♦4♠A♠10♥A♠44♦10♣K♣3♥A♣8♦4♥3♣A♥3♦277♦5♠4♣A♣10♦A♣44♣Q♦5♥3♦2♦6♥5♠Q♥4♦4♣288♠5♣4♥A♥A♠A♥44♥J♣298♣5♥4♦A♦A♣A♦4hit F9 to "spin"308♥5♦5♠J♠A♥J♠4318♦6♠5♣J♣A♦J♣4329♠6♣5♥J♥J♠J♥4339♣6♥5♦J♦J♣J♦4349♥6♦6♠Q♠J♥Q♠4359♦7♠6♣Q♣J♦Q♣43610♠7♣6♥Q♥Q♠Q♥43710♣7♥6♦Q♦Q♣Q♦43810♥7♦7♠K♠Q♥K♠43910♦8♠7♣K♣Q♦K♣440A♠8♣7♥K♥K♠K♥441A♣8♥7♦K♦K♣K♦442A♥8♦8♠2♠K♥2♠443A♦9♠8♣2♣K♦2♣444J♠9♣8♥2♥2♠2♥445J♣9♥8♦2♦2♣2♦446J♥9♦9♠3♠2♥3♠447J♦10♠9♣3♣2♦3♣448Q♠10♣9♥3♥3♠3♥449Q♣10♥9♦3♦3♣3♦450Q♥10♦10♠4♠3♥4♠451Q♦A♠10♣4♣3♦4♣452K♠A♣10♥4♥4♠4♥453K♣A♥10♦4♦4♣4♦454K♥A♦A♠5♠4♥5♠455K♦J♠A♣5♣4♦5♣456J♣A♥5♥5♠5♥457J♥A♦5♦5♣5♦458J♦J♠6♠5♥6♠459Q♠J♣6♣5♦6♣460Q♣J♥6♥6♠6♥461Q♥J♦6♦6♣6♦462ASLOT 4Cell FormulasRangeFormulaA3,Q24,Q17,K17,I9,C9A3=FORMULATEXT(A4)A4:A55A4=ADECK(1)C10:G61C10=ASLOT(ADECK(1),5)I10:I61I10=BYROW(C10#,LAMBDA(a,COUNTA(UNIQUE(a,1))))K18:O28K18=ANDECK(1,5)Q18:U20Q18=INDEX(K18#,SEQUENCE(3),SEQUENCE(,5))Q25:U27Q25=ANDECK(1,5,3)Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

Simulating a poker digital slot machine makes sense to also cover *poker hands rankings (PHR).*
PHR: straight flush (royal flush when 10-A same suit), 4 of a kind, full house, flush, straight, 3 of a kind, 2 pairs, 1 pair, high card (I will consider it as "nothing"). *See attached picture*.
Came out with PHR, Poker Hand Rankings function.
*PHR(a,[t])*: arguments and functionality:
*a: array of n rows x 5 clms, each row representing an accurate poker hand (no dups)
[t]: type argument
- t, 0 or omitted, total occurrences of each rank for whole array of hands "a" => result array 10x1 array  (10 ranks)
- t,1 rank of each row (hand, round) => result array rows(a)x1
- t,2 => array result 10x2, 1st clm rank names, 2nd clm ranking occurrences of "a"
- t,3 ranking names only => 10x1*
Only one thing about the concept, main trick for checking all possibilities was using the arguments functionality of *UNIQUE* function "by_col" and "*exactly_once*".

```
=LAMBDA(a,[t],
    LET(k,{"rf";"sf";"4k";"fh";"f";"s";"3k";"2p";"1p";"n"},IF(t=3,k,
       LET(b,BYROW(a,LAMBDA(r,LET(f,COUNTA(UNIQUE(RIGHT(r,1),1))=1,k,LEFT(r,LEN(r)-1),v,SWITCH(k,"A",14,"K",13,"Q",12,"J",11,--k),
         x,MAX(v)=14,q,SORT(v-MIN(v)+1,,,1),s,AND(q=SEQUENCE(,5)),u,COUNT(UNIQUE(q,1)),o,UNIQUE(q,1,1),n,IF(AND(ISERR(o)),0,COUNT(o)),
         SWITCH(n,0,"fh",3,"1p",2,"3k",1,IF(u=2,"4k","2p"),5,IF(s,IF(f,IF(x,"rf","sf"),"s"),IF(f,"f","n")))))),p,MAP(k,LAMBDA(a,SUM(--(a=b)))),
      SWITCH(t,0,p,1,b,2,IF({1,0},k,p))))
   )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAAB1Poker Hand Ranking, PHR functiont,1t,omittedt,22sampleranking/handt,3 ranking namesall ranking ocurrences in "a"array ranking names and their occurrence in "a"3rankingnameexamplesa=PHR(J4:N22,1)=PHR(D4:H13,3)=PHR(J4:N22)=PHR(J4:N22,2)4royal flushrf10♣J♣Q♣K♣A♣10♣A♣J♣Q♣K♣rfrf1rf15straight flushsf2♥3♥4♥5♥6♥5♥6♥7♥8♥9♥sfsf2sf264 of a kind4k9♠9♥9♣9♦Q♥2♠3♠4♠5♠6♠sf4k24k27full housefhA♠A♥A♦J♠J♦K♠K♣K♥K♦8♣4kfh2fh28flushf2♠4♠5♠6♠7♠10♣9♥10♠10♥10♦4kf2f29straights4♦5♣6♦7♣8♥J♣7♣7♦7♥J♥fhs2s2103 of a kind3k10♠10♥10♦3♣2♦5♥A♥3♥Q♥9♥f3k23k2112 pair2pK♠K♥Q♠Q♦3♠4♣10♣Q♣7♣J♣f2p22p2121 pair1p8♦8♠6♣3♦J♥7♠8♥9♦10♠J♦s1p21p213nothingnK♦8♣4♣5♦7♥6♠8♠7♥10♣9♦sn2n214K♠3♦K♣3♥K♥fh15Q♦8♦5♣Q♥Q♠3k1610♥10♣2♦A♣10♦3k17A♥6♦J♠A♦J♣2p18To simulate dealing a shuffled2♣Q♣Q♥10♠2♥2p19deck of cards, 5 cards/roundK♥6♥K♣4♥A♣1p20we can use ANDECK(1,5)3♣5♦3♥9♠7♦1p21To eliminate last row of 2 cards10♥9♠J♠5♦Q♠n22we can extract only 10 rounds 8♦5♣6♥3♣K♥n23with:24ranking/hand(round)distribution/whole deck25=ANDECK(1,5,10)a=PHR(D26#,1)=PHR(D26#,2)263♣K♠10♠3♠7♦1prf027J♠Q♣Q♦3♦3♥2psf0282♠9♠A♥9♦2♥2p4k0298♦2♣K♦5♦4♦nfh0308♠5♥A♠10♣K♣nf0316♣J♥2♦7♥9♣ns0327♠5♣7♣6♥Q♠1p3k0339♥4♥A♣8♣J♦n2p23410♥4♠J♣A♦8♥n1p335Q♥K♥6♦10♦6♠1pn536PHR 1Cell FormulasRangeFormulaP3,R3,T3,N25,J25,D25,W3P3=FORMULATEXT(P4)P4:P22P4=PHR(J4:N22,1)R4:R13R4=PHR(D4:H13,3)T4:T13T4=PHR(J4:N22)W4:X13W4=PHR(J4:N22,2)D26:H35D26=ANDECK(1,5,10)J26:J35J26=PHR(D26#,1)N26:O35N26=PHR(D26#,2)Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

AXMAS.xlsxABCDEFGHIJKLMNOPQ1PHR for more decks (5). Cumulative stats of rankings distribution2To be sure that no hands(rounds) can have duplicates we need to create a stack of single decks shuffled randomly.3rankings4rankings/rounddistribution/all 5 decksdistribution values only5=PHR(C6:G55,1)=PHR(C6:G55,2)=PHR(C6:G55)6deck 1=ANDECK(1,5,10)8♦2♣3♥Q♥5♣nrf007Q♠7♠10♥4♣10♠1psf008A♥2♥8♣5♠A♣1p4k00910♣7♥K♠3♦7♦1pfh0010A♠4♠6♥K♥J♥nf00115♦7♣J♣Q♣2♠ns1112K♣4♥2♦3♣10♦n3k00135♥J♦9♠Q♦9♣1p2p11146♠3♠9♥4♦8♥n1p2525158♠K♦J♠A♦6♣nn232316deck 2=ANDECK(1,5,10)8♠A♥8♦4♠5♦1p173♥6♦7♦Q♣5♠n18J♣9♠9♦7♥4♣1p194♥4♦9♥6♠2♥1p20K♦K♠3♦J♠9♣1p218♥3♣3♠2♣Q♠1p22A♣A♠K♥2♠7♠1p235♥10♥10♠8♣6♣1p2410♦2♦J♦Q♦7♣n255♣10♣A♦K♣J♥n26deck 3=ANDECK(1,5,10)Q♣J♥5♣A♣10♠n277♣J♠8♥K♦5♥n286♦J♦8♣10♣2♣n292♦4♠A♠4♣3♥1p305♦7♠9♠8♠6♥s314♥9♣Q♦7♥3♦n32K♠10♥9♥2♥A♦n33K♥7♦6♠Q♠J♣n346♣A♥2♠10♦8♦n35K♣4♦3♣3♠Q♥1p36deck 4=ANDECK(1,5,10)10♥10♠3♥7♣J♦1p376♣K♣2♠6♠A♣1p38A♥8♦4♦10♣5♣n398♠9♥3♣6♦10♦n409♣9♦K♠Q♠A♠1p415♦3♦9♠Q♦K♦n42Q♣Q♥7♥4♠J♥1p435♥7♠J♣K♥4♥n448♣A♦8♥2♥4♣1p452♦6♥7♦2♣3♠1p46deck 5=ANDECK(1,5,10)K♦A♥K♠4♣J♠1p472♦3♣2♥3♥4♥2p489♦2♣A♠7♥5♠n498♦Q♦10♦2♠Q♣1p506♥J♣5♦8♥A♦n515♥10♠7♠5♣6♠1p526♣6♦3♠Q♠4♠1p539♠7♣K♣4♦A♣n54J♦10♥9♣10♣Q♥1p558♠3♦8♣9♥7♦1p56PHR 2Cell FormulasRangeFormulaI5,K5,N5I5=FORMULATEXT(I6)B6,B46,B36,B26,B16B6=FORMULATEXT(C6)C6:G55C6=ANDECK(1,5,10)I6:I55I6=PHR(C6:G55,1)K6:L15K6=PHR(C6:G55,2)N6:N15N6=PHR(C6:G55)Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

Noticed that creating a big stack of shuffled decks, and hitting F9 a considerable number of times, the *higher rankings* like royal flush and straight flush, *did not register occurrences*. How many virtual decks we must shuffle until will start to get a straight flush or even a royal flush? This will represent one of many ways we can evaluate the "performance" of the randomizing "engine" in general, with a fun experiment like a virtual deck of cards.
So, why not to "*automate*" the process and create a *virtual "stack"* of large nr. of decks and *accumulate* the results. Here is the function, *main engine*, mighty *REDUCE* again:
*Note*: *MAKEARRAY* is used here only for *cosmetics*, the presentation of the result.
*NPHR(n*): *N* decks of cards, cumulative *P*oker *H*ands *R*ankings distribution.
*n:* integer >=1, nr. of virtual decks 

```
=LAMBDA(n,
    LET(k,PHR(1,3),nk,REDUCE(0,SEQUENCE(n),LAMBDA(v,i,LET(d,ANDECK(1,5,10),v+PHR(d)))),
      MAKEARRAY(12,2,LAMBDA(r,c,SWITCH(r,1,IF(c=1,"Decks",n),12,IF(c=1,"Hands",SUM(nk)),IF(c=1,INDEX(k,r-1),INDEX(nk,r-1)))))
    )
)
```
AXMAS.xlsxABCDEFGHIJKLMNOPQR1NPHR(n). The function. Cumulative rankings distribution for "n" decks of cards. 23=NPHR(10)=NPHR(50)=NPHR(100)=NPHR(500)=NPHR(1000)=NPHR(5000)4Decks10Decks50Decks100Decks500Decks1000Decks50005rf0rf0rf0rf0rf0rf06sf0sf0sf0sf0sf0sf074k04k04k04k14k44k98fh0fh1fh0fh9fh10fh739f0f1f2f4f20f9510s0s2s5s25s33s213113k23k73k263k1013k2303k1052122p42p302p662p2432p4962p2285131p391p2051p4261p20501p41991p2120614n55n254n475n2567n5008n2506715Hands100Hands500Hands1000Hands5000Hands10000Hands50000161718After"dealing" 5,000 decks, 50,000 hands, still no "rf" royal flush or "sf" straight flush19NPHR 1Cell FormulasRangeFormulaA3,P3,M3,J3,G3,D3A3=FORMULATEXT(A4)A4:B15A4=NPHR(10)D4:E15D4=NPHR(50)G4:H15G4=NPHR(100)J4:K15J4=NPHR(500)M4:N15M4=NPHR(1000)P4:Q15P4=NPHR(5000)Dynamic array formulas.


----------



## Xlambda (Jan 9, 2022)

Let's raise the stakes for up to *200,000 virtual decks or 2,000,000 hands*!
AXMAS.xlsxABCDEFGHIJKLMNOPQR1For values of n>10000, calculation time takes some time (seconds for 10,000 and for 200,000 decks, or 2M hands close to 3min),2so the following data are all copies as values of NPHR function results.34Decks10,000Decks20,000Decks30,000Decks40,000Decks50,0005rf0rf0rf0rf0rf16sf1sf3sf4sf5sf1074k314k444k634k1004k1178fh147fh290fh428fh616fh6949f215f399f573f784f101710s378s730s1055s1381s1780113k20833k42803k62873k84593k10670122p47652p95302p142422p189222p23692131p423161p843341p1263761p1687851p21170614n50064n100390n150972n200948n25031315Hands100,000Hands200,000Hands300,000Hands400,000Hands500,000161718Decks60,000Decks70,000Decks80,000Decks90,000Decks100,000Decks200,00019rf2rf0rf1rf3rf1rf620sf9sf10sf10sf9sf18sf20214k1354k1524k1774k2164k2374k49222fh823fh991fh1175fh1205fh1493fh287923f1155f1399f1486f1673f1946f390924s2032s2444s2816s3209s3438s7188253k124443k149313k169373k190083k213023k42001262p286022p331582p382512p428012p472512p95213271p2537501p2962431p3380881p3803581p4221441p84483828n301048n350672n401059n451518n502170n100345429Hands600,000Hands700,000Hands800,000Hands900,000Hands1,000,000Hands2,000,0003031Notes:32 - "nothing" occurrences almost half of all hands, all other rankings, the other half33 - first "sf" for 10,000 decks34 - first "rf" for 50,000 decks or half million hands35 - 200,000 or 2,000,000 hands, exceeds physical real estate of a spreadsheet36NPHR 2


----------



## Xlambda (Feb 8, 2022)

*Great news!!* Remember post #7, this thread? Quote:
"I believe in Santa, *Excel's Santa*. So, the other day, I wrote him a letter. It was a *secret wish*, but now I am going to disclose it. I've wished for *more recursive iterations*."
Check this out, latest MrExcel YT:  New Excel Formula Editor Debuts - 2466 
Among other nice "gifts" we received the one with "*better recursion limits, 16x larger*". How cool is that!!!
*Thanks Excel Team, excellent work!!!!* I think this forum, in the near future, will get its deserved traction. *Thanks MrExcel.com team for creating this fabulous leading-edge lambda environment!!!!*
(Seems that these gifts were lost in "transportation", that's way they did not get to us sooner) ✌☺️????


----------



## Xlambda (Dec 25, 2022)

*Happy 2022 Holidays All !!*✌️
This year Mike was so kind to choose my lambdas as his traditional Xmas tree video.
Check this out. It also has the *downloadable workbook* link in the description or here
PS: Just seen on previous posts here a lot of ornaments not printed (apear as "?") and I remember they were ok 1 year ago. Something happened. I will check them later.


----------



## Xlambda (Dec 25, 2022)

XMAS , same like AXMAS, replaced my good old AFLAT to TOCOL
*XMAS* same arguments as AXMAS

```
=LAMBDA(ht, sh, or,
    LET(
        t, UNICHAR(11088),
        i, UNICHAR(9618),
        p, UNICHAR(127873),
        o, TOCOL(or),
        n, ROWS(o),
        h, MAX(9, ht),
        s, MAX(3, sh),
        ns, INT(h / s),
        y, ns * s + 1,
        x, 2 * ns - 1,
        r, SEQUENCE(y),
        c, ABS(SEQUENCE(, x) - ns),
        a, QUOTIENT(r - 1, s) >= c,
        b, INDEX(o, RANDARRAY(y, x, 1, n, 1) * a),
        w, SWITCH(r, 1, t, 2, i, y, IF(c < ns - 2, p, ""), b),
        IF(a, w, "")
    )
)
```
and predefined array of ornaments "storage box" argument free lambda:
*AO() *

```
=LAMBDA(LET(q,SEQUENCE(44,,10035),UNICHAR(IF(q>10058,q+117698,q))))
```
Checking ornaments in mini-sheet, work OK
EIF Xmas Tree 2022.xlsxABCDEFGHIJKLMNOPQRSTU12=XMAS(28,3,AO())3 ⭐4▒5🌐6🌞🌚❄7🌕✾🌛8❇❇✾9❁🌕🌍✶🌜10🌏❂✺❊✻11❀✻❅🌜🌠12❉🌕🌙🌑✴✳🌍13🌗✽❇❃❈🌠❆14✾🌖🌒✸❊🌝🌑15🌙✴🌕❉✾✾🌠✷✸16✸🌒✿✷✾🌎🌎❅🌕17🌙✳🌜❉✴🌟🌙✺❃18✺✶✿🌔🌘🌙🌏❄✾🌛🌚19🌓🌞✽🌜🌑✺✸✽❅❄🌝20🌙🌓🌗✽✽✿🌓🌝✵✿🌑21🌚🌙❈❈❆❁🌞🌘❀🌕✷❅✽22❅✼✻🌛🌠🌞✶✼❂❁❉❆✴23✻✼❊✽🌜❈✶🌕✹🌏🌙❅🌏24✿❅🌒❉✴❈🌗✿❅🌎🌝❄🌟✸✺25❃🌖✶❄✾✷❄🌛🌗🌞✳🌐✾✵✴26✴🌓❃🌠❁🌙🌔🌛🌠🌔🌎🌞✶🌍❄27🌚✹✾🌐❇❂🌒❆❈✾✻✴🌖🌓✵✽🌘28🌖🌏🌘❄🌞✿🌜🌙🌍✾❇❊🌝✸🌝❉✽29🌠✿🌚❂✾❁✵🌓❁🌘✶❄✷❅🌓🌛🌏30🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁3132Sheet2Cell FormulasRangeFormulaC2C2=FORMULATEXT(C3)C3:S30C3=XMAS(28,3,AO())Dynamic array formulas.


----------



## Xlambda (Dec 25, 2022)

Also, only CF that works (can be displayed in mini-sheet) is Color Scales
EIF Xmas Tree 2022.xlsxABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBE1CF color scales23=XMAS(27,,AO())=XMAS(27,,SEQUENCE(20))=XMAS(27,,SEQUENCE(20))4 ⭐ ⭐ ⭐5▒▒▒6❄47✶🌔🌑614118🌕🌙✷1510179❅✸🌙1211510🌠🌠❆❇🌐75918211🌏❅✴✵✽13141312✵🌐🌘🌕❈128812813🌗✻✻🌚🌕🌎❂8153204101414❃🌝❉🌎🌏✼❉11419812132015✶❁🌙🌙❇✾🌗212514125516✺🌖🌝✽🌍🌑✴🌐🌛17110351210201317🌖🌓❆🌗🌗❉🌏🌚❁3179147312121118🌏🌚✹🌕✻❅🌙❆🌗131481012215819🌖🌗🌔🌠🌗✶❈🌒🌑🌗✾1412115121098184220🌗✺❂❆🌑✺✳❀✷✻🌚1011317172913120321🌗🌏✾🌙🌟🌛🌑✿✷✴✽1817911611313319722🌒❈🌟✶❇✽🌍✷🌘🌠🌖❇🌝215123531536351123✿❅✷❂🌔✼🌒🌗❈🌎🌙✹❃7524814191362201024🌑✷🌐✼❈✷🌞✶✻🌠❄✷✽1614168151614161663141125🌛✵✷🌏🌛✻✷🌕✾🌒🌍✵🌑✸🌗1481446158466166551126🌎❈✳🌟🌏🌘🌟🌓🌒🌖🌕✾✿✵✸13114204151181155101142027🌙🌐🌏✴✳🌜✺🌙🌚🌞✶🌟🌖🌐❄5611373171711198916828🌓✹✶🌍✳❇🌔🌜🌠🌝🌚🌚✵🌕🌔✻🌘31620161218171469191011818829❈🌝🌘✹✹🌛🌘❅🌘🌓✹🌓🌔✳🌗❉✸810153111111317457991971230❀🌔✴✺✸✺❉❇🌟🌛❈🌐✶❀🌖❁🌙181114311172120121420864831🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁32Sheet3Cell FormulasRangeFormulaB3,AM3,T3B3=FORMULATEXT(B4)B4:R31B4=XMAS(27,,AO())T4:AJ31,AM4:BC31T4=XMAS(27,,SEQUENCE(20))Dynamic array formulas.Cells with Conditional FormattingCellConditionCell FormatStop If TrueAM4:BC31Other TypeColor scaleNOAM4:BC31Other TypeColor scaleNOT4:AJ31Other TypeColor scaleNO


----------

