Skip to content

Instantly share code, notes, and snippets.

@ncalm
Last active June 15, 2023 09:41
Show Gist options
  • Save ncalm/7af590f1cc8cb94c1c945fbbf7faf91d to your computer and use it in GitHub Desktop.
Save ncalm/7af590f1cc8cb94c1c945fbbf7faf91d to your computer and use it in GitHub Desktop.
This Excel lambda function produces an increasing sequence of non-consecutive integers
/*
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