Permutation Happiness | HackerRank

Count the number of permutations subject to some constraints