Cody

Problem 45303. Combinatorics - 01

  • Input=[x,n]
  • where x is an array of numbers(or strings) and n is a +ve number.

for example, x=[1,2] and n=6.

The output will be a matrix containing all the possible permutations of the vector x having n elements(no of columns=n). besides that -

  • each row should contain equal number of occurance of the elements of x. (3 ones, 3 twos)
  • no initial segment can have more 2's than 1's. e.g. [2 2 1 2 1 1] - is invalid.since there are more 2's in the 1st appearance than 1's.
  • y=[
     1     1     1     2     2     2
     1     1     2     1     2     2
     1     1     2     2     1     2
     1     2     1     1     2     2
     1     2     1     2     1     2
     1     2     1     2     2     1
     2     1     1     1     2     2
     2     1     1     2     1     2
     2     1     1     2     2     1
     2     1     2     1     1     2
     2     1     2     1     2     1
     2     1     2     2     1     1
     2     2     1     1     1     2
     2     2     1     1     2     1
     2     2     2     1     1     1]

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Apr 02, 2020

Problem Comments

Problem Recent Solvers3

Suggested Problems

More from this Author125

Problem Tags