P169: Enumeration of all ladder lotteries with $k$ bars

P169: Enumeration of all ladder lotteries with $k$ bars
Input:
A permutation $\pi$ and integer $k$.
Output:
All ladder lotteries of $\pi$ with $k$ bars.
Complexity:
$O(1)$ time per ladder lottery.
Comment:
Ladder lotteries are also known as \textit{Amida kuji} in Japan.
Reference:
[Yamanaka2014] (Bibtex)