title: How to generate permutations without generating repeating results but with a fixed amount of characters Python
body: <p>I am trying to figure out a way to generate all permutations possible of a string that has a couple repeating characters but without generating repeated tuples.</p>
  
  <p>Right now I am using <code>itertools.permutations()</code>. It works but I need to remove repetition and I <strong>cannot</strong> use <code>set()</code> to remove the repetition.</p>
  
  <p>What kind of results am I expecting? Well, for example, I want to get all the combinations for <code>DDRR</code>, the thing with <code>itertools.permutations()</code> is that I would get <code>DDRR</code> about four times, given that <code>itertools</code> sees the <code>D</code>s as if they were different, same with <code>R</code>s.</p>
  
  <p>With <code>list(itertools.permutations('DDRR'))</code> I get:</p>
  
  <pre><code>[('D', 'D', 'R', 'R'), ('D', 'D', 'R', 'R'), ('D', 'R', 'D', 'R'), ('D', 'R', 'R', 'D'), ('D', 'R', 'D', 'R'), ('D', 'R', 'R', 'D'), ('D', 'D', 'R', 'R'), ('D', 'D', 'R', 'R'), ('D', 'R', 'D', 'R'), ('D', 'R', 'R', 'D'), ('D', 'R', 'D', 'R'), ('D', 'R', 'R', 'D'), ('R', 'D', 'D', 'R'), ('R', 'D', 'R', 'D'), ('R', 'D', 'D', 'R'), ('R', 'D', 'R', 'D'), ('R', 'R', 'D', 'D'), ('R', 'R', 'D', 'D'), ('R', 'D', 'D', 'R'), ('R', 'D', 'R', 'D'), ('R', 'D', 'D', 'R'), ('R', 'D', 'R', 'D'), ('R', 'R', 'D', 'D'), ('R', 'R', 'D', 'D')]
  </code></pre>
  
  <p>The ideal result I want is:</p>
  
  <pre><code>[('D', 'R', 'R', 'D'), ('R', 'D', 'R', 'D'), ('R', 'R', 'D', 'D'), ('D', 'R', 'D', 'R'), ('D', 'D', 'R', 'R'), ('R', 'D', 'D', 'R')]
  </code></pre>