title: Having trouble groking multiple exclusive combinations in C++
body: <p>I have an ordered string that I need to present to a user:</p>
  
  <pre><code>ABCCDDCBBBCBBDDBCAAA
  </code></pre>
  
  <p>Objects represented by 'B' are tagged, such that 2 Bs will have a '~' after them. </p>
  
  <pre><code>AB~CCDDCB~BBCBBDDBCAAA
  AB~CCDDCBB~BCBBDDBCAAA
  AB~CCDDCBBB~CBBDDBCAAA
  and so on...
  </code></pre>
  
  <p>I've used the <a href="http://home.roadrunner.com/~hinnant/combinations.html" rel="nofollow">combinations library</a> by Howard Hinnant and it works well for this simple case. My test code uses a vector of locations as ints that was sent through for_each_combination.</p>
  
  <p>However, I'm lost as to what to do when I have multiple tags for B. </p>
  
  <p>For example, 4Bs total need to be tagged, 2 by '~' and 2 by '#'</p>
  
  <pre><code>AB~CCDDCB~B#B#CBBDDBCAAA
  AB#CCDDCB~B~B#CBBDDBCAAA
  AB~CCDDCB#B~B#CBBDDBCAAA
  AB#CCDDCB#B~B~CBBDDBCAAA
  ABCCDDCB~B~B#CB#BDDBCAAA
  and so on...
  </code></pre>
  
  <p>The pseudocode I've written out is a cascade. After the first for_each_combination, for each of the resulting combinations, copy every other location to another vector and do another for_each_combination. </p>
  
  <p>Considering the number of combinations I will be working with, I'm hoping there's a better way.</p>