Baltić, Vladimir. “Applications of the Finite State Automata for Counting Restricted Permutations and Variations”. Yugoslav Journal of Operations Research, vol. 22, no. 2, Sept. 2012, pp. 183-98, doi:10.2298/YJOR120211023B.