Forum Discussion
Patrick2788
Oct 21, 2026Silver Contributor
Halloween 2026 Scheduling Challenge 🎃
Happy Halloween! You'll find the rules in the screen capture below and in the attached workbook. Creative solutions are encouraged. Feel free to use any functions available in the Beta ch...
PeterBartholomew1
Oct 25, 2026Silver Contributor
This thread has picked up some discussion since I last looked!
My objective was to move the thinking from basic formulas towards the definition of compound data entities and associated operations, implemented as nested arrays and Lambda functions respectively ( I may address considerations such as efficiency later ).
=LET(
n, SUM(ROUNDUP(Available / m, 0)),
k, SEQUENCE(n),
initialTreats, {HSTACK(Treat, Available)},
initialList, {HSTACK("Treat", "Number")},
initialState, HSTACK(initialTreats, initialList),
results, REDUCE(initialState, k, DISTRIBUTEλ),
return, TAKE(FLATTEN(results, "", 0), , -2),
return
)where the Lambda function is given by
DISTRIBUTEλ = LAMBDA(state▦, [_], // Beginning array of two nested arrays followed by a counter (unused)
LET(
// Separate treat stack and record list
// Update Treats
treats, FLATTEN(INDEX(stateâ–¦,1,1)), // An array showing both product names and counts
item, INDEX(treats,1,1), // A scalar text string showing the next treat
count, INDEX(treats,1,2), // A scalar numeric value showing its current count
otherItems, DROP(treats, 1), // A 2D array of treats
remaining, MAX(count - m, 0), // A scalar value
endTreats, IF(remaining>0, VSTACK(otherItems, HSTACK(item, remaining)), otherItems), // This is a 2D array
// Update List
priorList, FLATTEN(INDEX(stateâ–¦,1,2)),
newList, VSTACK( // This is the final record of an item and the remaining count
priorList,
HSTACK(item, count - remaining)
),
// Combine to form end state
endStateâ–¦, HSTACK({endTreats}, {newList}), // This is to be an array of two nested arrays
endStateâ–¦
)
);
Now, of course, another approach occurs to me. Instead of cycling the formulas each time a treat is given, I could cycle each time one runs through the entire treat basket!
For me though, I am at the stage of attempting to develop techniques, so this has already been a useful excercise!