Two standard dice are renumbered so that each die is different, but together the pair still gives the same probabilities for rolling sums of 2 to 12 as a standard pair.
If each die is numbered with integers all greater than 0, then what are the numbers on the renumbered dice?
wrote the following to return the answer
die 1 : 1 2 2 3 3 4
die 2 : 1 3 4 5 6 8
used a little common sense to reduce the number of instructions but basically the algorithm is pretty stupid brute force and not optomized for memory speed. Though an optimization would be cool.
Common sense each die can only have one 1 (to keep probability of getting a 2 the same). No die can have a number higher than 11 (or else overflow to > 12). No die can have an 11 (or else the other die would have all 1s and you wouldnt be able to sum up all the numbers).
The print routine was a little longer in the orig to filter permutations - I left that part out.
here is the prog:
void printDie(int *d1, int *d2) {
printf("die 1 : %d %d %d %d %d %d die 2 : %d %d %d %d %d %d\n",
temp1[0],temp1[1],temp1[2],temp1[3],temp1[4],temp1[5],
temp2[0],temp2[1],temp2[2],temp2[3],temp2[4],temp2[5]);
}
int notStd(int *a) {
int i, b[6]= {0,};
for (i = 0; i < 6; i++)
if (a[i] > 0 && a[i] < 7)
b[a[i]-1]=1;
for (i = 0; i < 6; i++)
if (!b[i])
return 1;
return 0;
}
int main (int argc, char *argv[]) {
int d1[6], d2[6], i, j, found;
int toomuch = 12;
int stand[21] = {0,0,1,2,3,4,5,6,5,4,3,2,1,0,};
int prob[21] = {0,};
d1[0] = d2[0] = 1;
for (d1[1] = 2; d1[1] < toomuch; d1[1]++)
for (d1[2] = 2; d1[2] < toomuch; d1[2]++)
for (d1[3] = 2; d1[3] < toomuch; d1[3]++)
for (d1[4] = 2; d1[4] < toomuch; d1[4]++)
for (d1[5] = 2; d1[5] < toomuch; d1[5]++)
for (d2[1] = 2; d2[1] < toomuch; d2[1]++)
for (d2[2] = 2; d2[2] < toomuch; d2[2]++)
for (d2[3] = 2; d2[3] < toomuch; d2[3]++)
for (d2[4] = 2; d2[4] < toomuch; d2[4]++)
for (d2[5] = 2; d2[5] < toomuch; d2[5]++) {
for (i = 0; i < 23; i++)
prob[i] = 0;
for (i = 0; i < 6; i++)
for (j = 0; j < 6; j++)
prob[d1[i]+d2[j]]++;
found = 1;
for (i = 0; i < 21; i++)
if (prob[i] != stand[i])
found = 0;
if (found)
if (notStd(d1))
printDie(d1, d2);
}
printf("no more dice found\n");
return 0;
}