diff --git a/day6/day6a.c b/day6/day6a.c new file mode 100644 index 0000000..e5daaa3 --- /dev/null +++ b/day6/day6a.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include + +#define RACES 4 + +int main() +{ + // unsigned long int times[RACES] = {7, 15, 30}; + // unsigned long int distances[RACES] = {9, 40, 200}; + unsigned long int times[RACES] = {44, 80, 65, 72}; + unsigned long int distances[RACES] = {208, 1581, 1050, 1102}; + unsigned long int numWins[RACES] = {0}; + unsigned long int range = 0; + unsigned long int sum = 1; + + for (unsigned long int i = 0; i < RACES; i++) { + for (unsigned long int j = 0; j < times[i]; j++) { + range = j * (times[i] - j); + printf("%d = %d * (%d - %d)\n", range, j, times[i], j); + if (range > distances[i]) numWins[i]++; + } + if (numWins[i] > 0) sum *= numWins[i]; + } + + printf("sum: %d\n", sum); +} diff --git a/day6/input b/day6/input new file mode 100644 index 0000000..28f5ae9 --- /dev/null +++ b/day6/input @@ -0,0 +1,2 @@ +Time: 7 15 30 +Distance: 9 40 200 diff --git a/day6/run b/day6/run new file mode 100755 index 0000000..4572253 Binary files /dev/null and b/day6/run differ