Mutations Problem

Nothing Here
Last edited on
I think you shoud make all possible mutations for the mautated sequences, and see wich ones are present in all the sets of mutations(from mustations). I'l try to code it and post back.
For N=5 this is easy and ok, but for a large length i think that this is not possible because it will take much time!
I made this program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string bla[]={"132", "213", "231", "312", "132"};
    vector<string> niz(bla, bla+5);
    vector<vector<string> > mut;
    int i, j, k;
    mut.reserve(5);
    for (i=0; i<5; i++)
    {
        for (j=0; j<3; j++)
        {
            for (k=0; k<3; k++)
            {
                if (j!=k)
                {
                    string temp=niz[i];
                    temp.insert(k, 1, temp[j]);
                    temp.erase(j+1, 1);
                    mut[i].push_back(temp);
                    }
                }
            }
        }
    for (i=0; i<mut[0].size(); i++)
    {
        bool a=true;
        string b=mut[0][i];
        for (j=1; j<5; j++)
        {
            if (mut[j][i]!=b) a=false;
            }
        if (a)
        {
            cout<<mut[i][0]<<endl;
            break;
            }
        }
    system ("pause");
    return 0;
}

But, it only runs in debug mode(if I run it normally it says "this application has caused a runtime error..." etc. yadda yadda yadda, andit never finds a match. What's the problem?
Can you explain me what have you done?
If you write mut.resize(5) instead of mut.reserve(5) it works, but it doesn't print any solution and i didn't understand what you wrote.
Last edited on
Topic archived. No new replies allowed.