An everyscale “full” sequence

16 Views Asked by At

Let $S$ be a set of $n$ elements.
Let $f:\mathbb N \to S$.
What I’m looking for is a sequence where every $n$ elements all elements appear, and that every $n!n$ elements every sequence of $n$ elements appears and so on.
What I’m looking for is a simple codable function.
I’ve tried to experiment on small numbers, at two we get the fair share sequence. At three we get sequences like:
$$\overbrace{0,1,2},\overbrace{0,2,1},\overbrace{1,0,2},\overbrace{1,2,0},\overbrace{2,0,1},\overbrace{2,1,0}...$$ Any help?

1

There are 1 best solutions below

1
On

Denote $S=\{s_1, \dots, s_n\}$ and enumerates the permutations $\sigma_1, \dots, \sigma_{n!}$ of $\mathfrak S_n$.

Then take for $f$ the periodical map of period $n!n$ defined by

$$f(k) = \sigma_{\lfloor k/n! \rfloor}(k - \lfloor k/n! \rfloor)$$

for $1 \le k \le n!n$.