title: Permutation with repeated elements and partitioned spaces (can be left once blank)
body: <p>I have some repeated elements and partitioned spaces:</p>
  
  <pre><code># Elements
  people = [0, 0, 1]
  # Index
  seats = ['a', 'a', 'b', 'b', 'c', 'd']
  </code></pre>
  
  <p>The number of elements <strong>cannot greater than</strong> the number of index. If the number of elements is lower than the number of index, each type of index can  left <strong>one</strong> index as blank.</p>
  
  <pre><code>from collections import Counter
  
  
  def _is_elem_valid(people, seats) -&gt; bool:
      """Valid elements check."""
      counter = 0
      for seat, c in Counter(seats).items():
          if c &gt; 1:
              counter += 1
  
      # "True" is valid.
      # In this case is 6 &gt;= 3 &gt;= 2.
      return len(seats) &gt;= len(people) &gt;= counter
  </code></pre>
  
  <p>Same type of index are <strong>unordered</strong> and <strong>continuously</strong>. Otherwise the rules are same as normal permutation.</p>
  
  <p>So the results will show as follows:</p>
  
  <pre><code># None represent blank seats.
  # Sorry about PEP8.
  # Actual elements: (filled to the length of index)
  [0, 0, 1, None, None, None]
  
  # Index:
  ['a', 'a', 'b', 'b', 'c', 'd']
  # Correspond to normal index:
  [[0], [0], [1], [1], [2], [3]]
  
  # For all 'a'
  [ 0,   0,   1,  None,None,None]
  [ 0,   1,   0,  None,None,None]
  # For all 'b'
  [ 0,  None, 0,   1,  None,None]
  [ 1,  None, 0,   0,  None,None]
  # For 'c'
  [ 0,  None, 1,  None, 0,  None]
  [ 1,  None, 0,  None, 0,  None]
  [ 0,  None, 0,  None, 1,  None]
  # For 'd'
  [ 0,  None, 1,  None,None, 0  ]
  [ 1,  None, 0,  None,None, 0  ]
  [ 0,  None, 0,  None,None, 1  ]
  </code></pre>
  
  <p>I'm not so familiar with permutation algorithm. Is there any efficient solution here?</p>