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1+2-3-4+5+6-7-8+9 = 1
- 1-2+3-4+5+6-7-8+9 = 1 1+2-3+4-5-6+7-8+9 = 1
- 1+2-3+4-5-6+7-8+9 = 1
- 1-2+3+4-5-6+7-8+9 = 1
- 1+2-3-4+5-6+7-8+9 = 1 1-2-3-4-5+6+7-8+9 = 1
- 1-2-3-4-5+6+7-8+9 = 1 1-2 3+4+5+6+7-8+9 = 1
- 1-2 3+4+5+6+7-8+9 = 1 1+2+3+4 5-6 7+8+9 = 1
- 1+2+3+4 5-6 7+8+9 = 1 1 2+3 4+5-6 7+8+9 = 1
- 1 2+3 4+5-6 7+8+9 = 1 1+2+3-4-5-6-7+8+9 = 1
- 1+2+3-4-5-6-7+8+9 = 1
- 1+2-3+4-5-6-7+8+9 = 1 1-2-3-4+5-6-7+8+9 = 1
- 1-2-3-4+5-6-7+8+9 = 1
- 1-2-3-4-5+6-7+8+9 = 1
- 1-2 3+4+5+6-7+8+9 = 1 1-2+3 4-5 6+7+8+9 = 1
- 1-2+3 4-5 6+7+8+9 = 1 1 2-3 4+5-6+7+8+9 = 1
- 1 2-3 4+5-6+7+8+9 = 1
Total solutions = 69 (26 of which have a leading "+", which is redundant)
69/19683 = 0.35 %
- for those who care (it's not very elegant but it did the trick)
- include <stdio.h>
- include <math.h>
main (argc,argv)
int argc; char *argv[];
{
int sresult, result, operator10?,thisop; char buf256?,ops3?; int i,j,tot=0,temp;
ops0? = ' '; ops1? = '-'; ops2? = '+';
for (i=1; i<10; i++) operatori? = 0;
for (j=0; j < 19683; j++) {
result = 0; sresult = 0; thisop = 1; for (i=1; i<10; i++) {
switch (operatori?) {
- case 0
- sresult = sresult * 10 + i; break;
- case 1
- result = result + sresult * thisop; sresult = i; thisop = -1; break;
- case 2
- result = result + sresult * thisop; sresult = i; thisop = 1; break;
}
}
result = result + sresult * thisop; if (result == 1) {
tot++; for (i=1;i<10;i++)
printf("%c%d",opsoperator[i?],i);
printf(" = %d\n",result);
} temp = 0; operator1? += 1; for (i=1;i<10;i++) {
operatori? += temp; if (operatori? > 2) { operatori? = 0; temp = 1;} else temp = 0;
}
}
printf("Total solutions = %d\n" , tot);
}
cwren@media.mit.edu (Christopher Wren)
