# Counting all permutations(repeating) with no adjacent elements equal and m majority elements.

Counting all permutations(repeating) of 1 to n which have size n.
1. with no adjacent elements equal, and
2. m majority elements(A element is majority element when it appears max number of times in the permutation.)

for n = 5
{1 2 3 4 5} has 5 majority elements.
{3 2 3 2 3} has 1 majority element(3).
{3 2 3 2 1} has 2 majority elements(2, 3).

Example ->

n = 3, m = 3 => ans = 3!
{321 312 231 132 213 123}

n = 3, m = 1 => ans = 6
{121 131 212 232 313 323}

I have made a few observations,
1. If n = m then ans is always n!
2. answer for all values m > n/2 is 0.

• Welcome to math.stackexchange. Can you tell us what your thoughts are about the problem and/or what you tried already? We sort of expect that here. :) – Pedro Apr 8 '15 at 10:52
• @pedro Thanks, I have made a few observations, If n==m then ans is always n!. secondly, answer for all values m > n/2 is 0. I tried to formulate but got stuck, unable to find any patterns. – user12345671 Apr 8 '15 at 10:59
• Ok, nice that you have done work. Best thing you can do is immediatly share your work in your post, that's the few it goes on MSE. :) – Pedro Apr 8 '15 at 11:01
• Where does this problem come from? – Andrew Woods Apr 8 '15 at 12:05
• It's a part of bigger problem I'm trying to solve for my code. – user12345671 Apr 8 '15 at 12:17