Let $n$ be a positive integer. Let $S_{n+1}$ be the set of permutations of $1,\dots, n, n+1$. Let $B_n$ be the set of binary sequences of length $n$.
There is a surjection $f:S_{n+1}\to B_n$ where the $i$-th digit of $f(\pi)$ is 1 if $\pi(i+1)>\pi(i)$ and 0 otherwise.
For $n>1$ we have $(n+1)!>2^n$ so $f$ cannot be injective.
Is there a simple formula for the cardinality of the inverse image of a sequence $b\in B_n$? Or an algorithm better than ranging through all permutations?
For $n=5$ the possible cardinalities are 1, 5, 10, 14, 19, 26, 35, 40, 61.
For $n=6$ we get 1, 6, 15, 20, 29, 34, 50, 55, 64, 71, 78, 90, 99, 111, 132, 155, 169, 181, 272.