1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. :) $\endgroup$ – Pedro Apr 8 '15 at 10:52
  • $\begingroup$ @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. $\endgroup$ – user12345671 Apr 8 '15 at 10:59
  • $\begingroup$ 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. :) $\endgroup$ – Pedro Apr 8 '15 at 11:01
  • $\begingroup$ Where does this problem come from? $\endgroup$ – Andrew Woods Apr 8 '15 at 12:05
  • $\begingroup$ It's a part of bigger problem I'm trying to solve for my code. $\endgroup$ – user12345671 Apr 8 '15 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.