Last active
June 15, 2023 09:41
-
-
Save ncalm/7af590f1cc8cb94c1c945fbbf7faf91d to your computer and use it in GitHub Desktop.
This Excel lambda function produces an increasing sequence of non-consecutive integers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
RANDSEQUENCE | |
Inputs: | |
- numbers: the length of the sequence to be produced | |
- max_between: the maximum difference between consecutive integers | |
Note: the minimum difference between one row and the next is assumed to be 1. | |
*/ | |
RANDSEQUENCE =LAMBDA(numbers,max_between, | |
LET( | |
seq,SEQUENCE(numbers), | |
SCAN( | |
RANDBETWEEN(0,max_between), | |
seq, | |
LAMBDA(a,b, | |
a+RANDBETWEEN(1,max_between) | |
) | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment