Andrew Kensler's permute(), a function for stateless, constant-time pseudorandom-order array iteration
Andrew Kensler's permute() function is a stateless, constant-time pseudorandom-order array iteration technique that is useful in various fields such as graphics and cryptography. The function solves the problem of iterating over k items of an array of length n in random order without duplicates. Unlike the Fisher-Yates shuffle, permute() requires O(k) time and O(1) memory, making it more efficient for iterating over a random sample of k items from an array of length n.
Kensler introduced permute() in his paper Correlated Multi-Jittered Sampling, and it has been applied in various areas beyond its initial use in graphics and cryptography.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.