Guyz. Im in a competition. Please help me solve this. I need to code a program to solve this. I dont know where to start. Can anyone setup a recurrence relation?

On an island chameleons of different color live.

Every Monday , the following events occur

The number of Black chameleons born is 1000 more than sum of { existing Blue , existing Green and twice the existing White chameleons }

The number of Brown chameleons becomes 13 more than twice the existing Brown

The number of Red chameleons triples

All the Yellow chameleons change their color to Black
Every Tuesday , the following events occur

The number of Yellow chameleons born is 1000 more than sum of { existing Black , existing Red and twice the existing Brown chameleons }

The number of Blue chameleons becomes 13 more than twice the existing Blue

The number of White chameleons triples

All the Green chameleons change their color to Yellow

Every Wednesday , the following events occur

The number of Green chameleons born is 1000 more than sum of { existing Yellow , existing White and twice the existing Blue chameleons }

The number of Black chameleons becomes 13 more than twice the existing Black

The number of Brown chameleons triples

All the Red chameleons change their color to Green

Every Thursday , the following events occur

The number of Red chameleons born is 1000 more than sum of { existing Green , existing Brown and twice the existing Black chameleons }

The number of Yellow chameleons becomes 13 more than twice the existing Yellow

The number of Blue chameleons triples

All the White chameleons change their color to Red

Every Friday , the following events occur

The number of White chameleons born is 1000 more than sum of { existing Red , existing Blue and twice the existing Yellow chameleons }

The number of Green chameleons becomes 13 more than twice the existing Green

The number of Black chameleons triples

All the Brown chameleons change their color to White

Every Saturday , the following events occur

The number of Brown chameleons born is 1000 more than sum of { existing White , existing Black and twice the existing Green chameleons }

The number of Red chameleons becomes 13 more than twice the existing Red

The number of Yellow chameleons triples

All the Blue chameleons change their color to Brown

Every Sunday , the following events occur

The number of Blue chameleons born is 1000 more than sum of { existing Brown , existing Yellow and twice the existing Red chameleons }

The number of White chameleons becomes 13 more than twice the existing White

The number of Green chameleons triples

All the Black chameleons change their color to Blue

On the same island there lives a monster . Whenever he sees 10^7 chameleons of the same color he eats them all immediately . How many chameleons change their color on the 3rd day after the 10^17th week . Initially there are no chameleons on the island . The first day is a Monday .

don't think you should be in this competition
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by stevanity

This is called cheating dude!! You'd better use your brain and solve it.

Make a chart of equation describing each statement

monday.txt

``````8,8
0,1,1,2,0,0,1,1000
0,1,0,0,0,0,0,0
0,0,1,0,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,0,2,0,0,13
0,0,0,0,0,3,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,1``````

tuesday.txt

``````8,8
1,0,0,0,0,0,0,0
0,2,0,0,0,0,0,13
0,0,0,0,0,0,0,0
0,0,0,3,0,0,0,0
0,0,0,0,1,0,0,0
0,0,0,0,0,1,0,0
1,0,1,0,2,1,0,1000
0,0,0,0,0,0,0,1``````

wednesday.txt

``````8,8
2,0,0,0,0,0,0,13
0,1,0,0,0,0,0,0
0,2,0,1,0,1,1,1000
0,0,0,1,0,0,0,0
0,0,0,0,3,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,1,0
0,0,0,0,0,0,0,1``````

thursday.txt

``````8,8
1,0,0,0,0,0,0,0
0,3,0,0,0,0,0,0
0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,1,0,0,0
2,0,1,1,1,0,0,1000
0,0,0,0,0,0,2,13
0,0,0,0,0,0,0,1``````

friday.txt

``````8,8
3,0,0,0,0,0,0,0
0,1,0,0,0,0,0,0
0,0,2,0,0,0,0,13
0,1,0,0,1,1,2,1000
0,0,0,0,0,0,0,0
0,0,0,0,0,1,0,0
0,0,0,0,0,0,1,0
0,0,0,0,0,0,0,1``````

saturday.txt

``````8,8
1,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,1,0,0,0,0,0
0,0,0,1,0,0,0,0
1,1,2,1,0,0,0,1000
0,0,0,0,0,2,0,13
0,0,0,0,0,0,3,0
0,0,0,0,0,0,0,1``````

sunday.txt

``````8,8
0,0,0,0,0,0,0,0
1,0,0,0,1,2,1,1000
0,0,3,0,0,0,0,0
0,0,0,2,0,0,0,13
0,0,0,0,1,0,0,0
0,0,0,0,0,1,0,0
0,0,0,0,0,0,1,0
0,0,0,0,0,0,0,1``````

finalize.txt

``````1,8
0
0
0
0
0
0
0
1``````
``````#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

struct MiniMatrix {
int cols, rows;
int vals[8][8];
};

int parsematrix(struct MiniMatrix* dest, char* filename) {
int i, j;
char end;
FILE* in = fopen(filename, "r");

if(in == NULL) {
return 1;
}

fscanf(in, "%d,%d\n", &amp;dest-&gt;cols, &amp;dest-&gt;rows);

for(i = 0; i &lt; dest-&gt;rows; i++) {
for(j = 0; j &lt; dest-&gt;cols; j++) {
fscanf(in, "%d%c", &amp;dest-&gt;vals[i][j], &amp;end);
}
}
fclose(in);

return 0;
}

int outputmatrix(struct MiniMatrix* src, char* filename) {
int i, j;
FILE* out = fopen(filename, "w");

if(out == NULL) {
return 1;
}

fprintf(out, "%d,%d\n", src-&gt;cols, src-&gt;rows);

for(i = 0; i &lt; src-&gt;rows; i++) {
for(j = 0; j &lt; src-&gt;cols; j++) {
fprintf(out, "%d", src-&gt;vals[i][j]);

if(j &lt; src-&gt;cols-1) {
fprintf(out, ",");
}
}
fprintf(out, "\n");
}

fclose(out);

return 0;
}

int multmatrix(struct MiniMatrix* c, struct MiniMatrix* a, struct MiniMatrix* b) {
int i, j, k;

if(a-&gt;cols != b-&gt;rows) {
return 1;
}

c-&gt;cols = b-&gt;cols;
c-&gt;rows = a-&gt;rows;

for(i = 0; i &lt; a-&gt;rows; i++) {
for(j = 0; j &lt; b-&gt;cols; j++) {
c-&gt;vals[i][j] = 0;

for(k = 0; k &lt; a-&gt;cols; k++) {
c-&gt;vals[i][j] += (int)((((long long)a-&gt;vals[i][k])*((long long)b-&gt;vals[k][j]))%10000000LL);
}
}
}

return 0;
}

int main() {
struct MiniMatrix res1, res2, res3;

parsematrix(&amp;res1, "monday.txt");
parsematrix(&amp;res3, "tuesday.txt");
multmatrix(&amp;res2, &amp;res1, &amp;res3);
parsematrix(&amp;res3, "wednesday.txt");
multmatrix(&amp;res1, &amp;res2, &amp;res3);
parsematrix(&amp;res3, "thursday.txt");
multmatrix(&amp;res2, &amp;res1, &amp;res3);
parsematrix(&amp;res3, "friday.txt");
multmatrix(&amp;res1, &amp;res2, &amp;res3);
parsematrix(&amp;res3, "saturday.txt");
multmatrix(&amp;res2, &amp;res1, &amp;res3);
parsematrix(&amp;res3, "sunday.txt");
multmatrix(&amp;res1, &amp;res2, &amp;res3); //one week??

multmatrix(&amp;res2, &amp;res1, &amp;res1);
multmatrix(&amp;res3, &amp;res2, &amp;res2);
multmatrix(&amp;res2, &amp;res3, &amp;res3);
multmatrix(&amp;res3, &amp;res2, &amp;res1);
multmatrix(&amp;res2, &amp;res3, &amp;res1);//raised to 10

multmatrix(&amp;res2, &amp;res1, &amp;res1);
multmatrix(&amp;res3, &amp;res2, &amp;res2);
multmatrix(&amp;res2, &amp;res3, &amp;res3);
multmatrix(&amp;res3, &amp;res2, &amp;res2);
multmatrix(&amp;res2, &amp;res3, &amp;res1); //raised to 7

parsematrix(&amp;res1, "monday.txt");
multmatrix(&amp;res3, &amp;res2, &amp;res1);
parsematrix(&amp;res2, "tuesday.txt");
multmatrix(&amp;res1, &amp;res2, &amp;res3);

parsematrix(&amp;res3, "finalize.txt");
multmatrix(&amp;res2, &amp;res1, &amp;res3);

outputmatrix(&amp;res2, "result.txt");

return 0;
}``````