Forum Discussion
Brian_MacLeod
Jan 05, 2024Copper Contributor
Roulette Tracking
I have a spreadsheet where I count the results of spins on a Roulette wheel. How can I track the number of spins since the last time a specific result occurred? For example, how many spins has it bee...
- Jan 05, 2024
PeterBartholomew1
Jul 20, 2024Silver Contributor
This is, frankly, playtime! It uses range composition to build subsets taken from the results range. Sample worksheet formulas are
= LET(
Fnλ, LAMBDA(x, x),
MAP(result, SpinCounter(Fnλ))
)
and
= LET(
Fnλ, LAMBDA(x, IF(x, ISEVEN(+x), "zero")),
MAP(result, SpinCounter(Fnλ))
)
which give results for the winning number and even/odd respectively.
A function Fnλ should be defined to return a unique value for each category of interest, even/odd, black/red etc. MAP passes one cell at a time to SpinCounter(Fnλ).
SpinCounter
= LAMBDA(Fnλ, LAMBDA(current,
// "Fnλ is a function that maps results to distinct roulette categories"
// "current is a specific cell taken from the array of results"
LET(
//"Define results up to but not including the current cell as a range"
priorResults, DROP(top:current, -1),
//"Look up cell mapping within the mapped array"
priorMatch, XLOOKUP(Fnλ(current), Fnλ(priorResults), priorResults,,,-1),
//"Count the results between the current cell and its matched prior cell"
count, COUNT(priorMatch:current),
IF(count, count - 1, "")
)
))
There is more to do, but that will have to be another day!
PeterBartholomew1
Jul 21, 2024Silver Contributor
Played around a bit further with formulas to determine where a number is red or black and count offsets to prior occurrence.
To return the color
= RedBlackλ(result)
and the count
= MAP(result, SpinCounter(EvenOddλ))
where
RedBlackλ
= LAMBDA(number,
LET(
iseven?, ISEVEN(+number),
isRed?, IF(number, IF(1+MOD(number-1, 18) > 10, iseven?, NOT(iseven?)), "zero"),
SWITCH(isRed?, TRUE, "red", FALSE, "black", "green")
)
);