Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I print all the ways 4 different letters can combine in 2-letter pairs to fill four spots with each individual letter appearing exactly twice?
    primarykey
    data
    text
    <p>What I have so far is this:</p> <pre><code>#include &lt;iostream&gt; #include &lt;algorithm&gt; using namespace std; int main(){ string genePool[16] = {"aa", "ab", "ac", "ad", "ba", "bb", "bc", "bd", "ca", "cb", "cc", "cd", "da", "db", "dc", "dd"}; string coco, code, deco, dede; int total = 0; for (int i = 0; i &lt; 16; i++){ coco = genePool[i]; for (int j = 0; j &lt; 15; j++){ code = genePool[j]; for (int k = 0; k &lt; 14; k++){ code = genePool[k]; for (int l = 0; l &lt; 13; l++){ code = genePool[l]; size_t a = count(coco.begin(), coco.end(), 'a') + count(code.begin(), code.end(), 'a') + count(deco.begin(), deco.end(), 'a') + count(dede.begin(), dede.end(), 'a'); size_t b = count(coco.begin(), coco.end(), 'b') + count(code.begin(), code.end(), 'b') + count(deco.begin(), deco.end(), 'b') + count(dede.begin(), dede.end(), 'b'); size_t c = count(coco.begin(), coco.end(), 'c') + count(code.begin(), code.end(), 'c') + count(deco.begin(), deco.end(), 'c') + count(dede.begin(), dede.end(), 'c'); size_t d = count(coco.begin(), coco.end(), 'd') + count(code.begin(), code.end(), 'd') + count(deco.begin(), deco.end(), 'd') + count(dede.begin(), dede.end(), 'd'); if (a = 2 || b = 2 || and c = 2 || d = 2){ total++; cout &lt;&lt; total &lt;&lt; ") "coco &lt;&lt; "," &lt;&lt; code &lt;&lt; "," &lt;&lt; deco &lt;&lt; "," &lt;&lt; dede &lt;&lt; endl; } } } } } return 0; } </code></pre> <p>It's been awhile since I've done anything with c++ and even then I wasn't too far in, so please excuse any offensively glaring errors. I will obligingly do better whenever better is pointed out :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload