Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
23
2021/day01/day01.c
Normal file
23
2021/day01/day01.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int buf[5000] = {0};
|
||||
int count = 0;
|
||||
while (scanf("%d\n", &buf[count++]) != EOF);
|
||||
count--;
|
||||
|
||||
int part1 = 0;
|
||||
for (int i = 1; i < count; ++i) {
|
||||
part1 += buf[i] > buf[i - 1];
|
||||
}
|
||||
printf("%d\n", part1);
|
||||
|
||||
int part2 = 0;
|
||||
for (int i = 3; i < count; ++i) {
|
||||
part2 += buf[i] > buf[i-3];
|
||||
}
|
||||
printf("%d\n", part2);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue