mirror of
https://github.com/peter-tanner/advent-of-code-2021.git
synced 2024-11-30 11:10:20 +08:00
line
This commit is contained in:
parent
30b223a5f3
commit
604bc29b90
4
1/1-1.c
4
1/1-1.c
|
@ -6,8 +6,8 @@ int main(int argc, char const *argv[])
|
|||
{
|
||||
FILE *p_file = fopen("input", "r");
|
||||
char line[50];
|
||||
uint increases = 0;
|
||||
uint previous_depth = 0;
|
||||
unsigned int increases = 0;
|
||||
unsigned int previous_depth = 0;
|
||||
while (fgets(line, sizeof line, p_file) != NULL)
|
||||
{
|
||||
if (atoi(line) > previous_depth)
|
||||
|
|
10
1/1-2.c
10
1/1-2.c
|
@ -8,8 +8,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
uint sum;
|
||||
uint count;
|
||||
unsigned int sum;
|
||||
unsigned int count;
|
||||
bool written; // IGNORE COMPARISONS AT THE START.
|
||||
} MEASUREMENT_WINDOW;
|
||||
|
||||
|
@ -17,14 +17,14 @@ int main(int argc, char const *argv[])
|
|||
{
|
||||
FILE *p_file = fopen("input", "r");
|
||||
char line[50];
|
||||
uint increases = 0;
|
||||
unsigned int increases = 0;
|
||||
|
||||
MEASUREMENT_WINDOW windows[N_WINDOWS];
|
||||
|
||||
uint i = 0;
|
||||
unsigned int i = 0;
|
||||
while (fgets(line, sizeof line, p_file) != NULL)
|
||||
{
|
||||
uint n = atoi(line);
|
||||
unsigned int n = atoi(line);
|
||||
// UPDATE MEASURING WINDOWS
|
||||
for (size_t j = 0; j < N_WINDOWS; j++)
|
||||
{
|
||||
|
|
8
3/3-1.c
8
3/3-1.c
|
@ -7,8 +7,8 @@ int main(int argc, char const *argv[])
|
|||
{
|
||||
FILE *p_file = fopen("input", "r");
|
||||
|
||||
uint n_one[WIDTH] = {0};
|
||||
uint length = 0;
|
||||
unsigned int n_one[WIDTH] = {0};
|
||||
unsigned int length = 0;
|
||||
|
||||
char line[WIDTH + 2];
|
||||
while (fgets(line, sizeof line, p_file) != NULL)
|
||||
|
@ -24,8 +24,8 @@ int main(int argc, char const *argv[])
|
|||
}
|
||||
|
||||
// GET GAMMA/EPSILON
|
||||
uint gamma = 0, epsilon = 0;
|
||||
uint place = 1;
|
||||
unsigned int gamma = 0, epsilon = 0;
|
||||
unsigned int place = 1;
|
||||
for (size_t i = WIDTH; i--;)
|
||||
{
|
||||
if (n_one[i] > length / 2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user