From bb849bc054b3538d1c7e1b4c116ae845e0156ba4 Mon Sep 17 00:00:00 2001 From: kirreen Date: Fri, 8 Dec 2023 01:12:14 +0100 Subject: [PATCH] solved day 6 a --- day6/day6a.c | 30 ++++++++++++++++++++++++++++++ day6/input | 2 ++ day6/run | Bin 0 -> 15480 bytes 3 files changed, 32 insertions(+) create mode 100644 day6/day6a.c create mode 100644 day6/input create mode 100755 day6/run 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 0000000000000000000000000000000000000000..4572253208f08b651a2b2cee67c1abd08cf74c17 GIT binary patch literal 15480 zcmeHOYit}>6~4R9!)cqW6B6PkB^jkLO4@qkSFAj6vVN>HE>2=nM-&81*WR_gs=aG= z*Wi>2984=)RwNe*C{lm85~2u%S_DXy0BO@SFF?W-f1(x%3#Gylfu&U_h=;wq`I1m0(8B`7^4q_{iDG<66fsCXO{x10>D`!U4* z5EQ%Ho<+eBOYdELl~qA+9Cc;3+BnQMEyga+%cG1EM=Hh5aoilo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