Suppose, for example, that I have $d=4$ dials on a lock each with $s=3$ possible settings: $a, b, c$. As shown by Ned in this post, the subset of lock permutations that are in alphabetical order in this particular case is:
aaaa
aaab
aaac
aabb
aabc
aacc
abbb
abbc
abcc
accc
bbbb
bbbc
bbcc
bccc
cccc
Can an algorithm be created in MATLAB, which generates the subset of all permutations that are in alphabetical order (or if the settings of the lock are numbers, then in descending order) WITHOUT visiting all possible permutations to check if the particular permutation belongs to the subset?
I do not know how to code in MATLAB, but here is some pseudo code which works: