To round off round one, here is the answer to question four. On the night this went to the Framed team, who wrote a very elegant OO solution in Java (several people have made comments to this effect since the night). This solution is given in (Objective, not that you can tell) — C:
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define X 0
#define Y 1
#define Z 2
#define R 3
int main() {
float p[10][4] = {
{3,3,3,3}, {3,3,8,4}, {1,7,10,1}, {4,3,9,2}, {7,2,7,3},
{7,8,9,2}, {0,3,0,2}, {3,7,4,3}, {1,10,1,4}, {2,2,9,3}};
int i, j, touch;
for (i = 9; i > 0; i--) {
touch = FALSE;
for (j = i - 1; j >= 0; j--) {
if ((p[i][R] + p[j][R]) * (p[i][R] + p[j][R]) >=
((p[i][X] - p[j][X]) * (p[i][X] - p[j][X]) +
(p[i][Y] - p[j][Y]) * (p[i][Y] - p[j][Y]) +
(p[i][Z] - p[j][Z]) * (p[i][Z] - p[j][Z]))) {
touch = TRUE;
break;
}
}
if (!touch) {
printf("Planet %i is the safe planet.\n", i + 1);
break;
}
}
}
Whilst writing this I was thinking about the amount of time spent outside the editor and testing the code by all the teams during the competition, so here's something I tried in my OS X shell which might be a good idea for teams in next year's competition:
similitude:objc robin$ while [ true ] ; do gcc planets.m -o planets; ./planets; done Planet 6 is the safe planet. Planet 6 is the safe planet. Planet 6 is the safe planet. Planet 6 is the safe planet. ...
At about twenty compilations per second, this should probably be described as extreme continuous integration...
Cheers, Robin