32 lines
550 B
C
32 lines
550 B
C
#include <stdio.h>
|
|
|
|
#include "../../lib/aoc.h"
|
|
|
|
int main() {
|
|
char *input = aoc_read_input();
|
|
int floor = 0;
|
|
int index = 0;
|
|
while (input[index] > 0) {
|
|
if (input[index] == '(') floor++;
|
|
else if(input[index] == ')') floor--;
|
|
index++;
|
|
}
|
|
|
|
printf("Part 1: %d\n", floor);
|
|
|
|
floor = 0;
|
|
int steps = 0;
|
|
index = 0;
|
|
|
|
while (input[index] > 0) {
|
|
if (input[index] == '(') floor++;
|
|
else if(input[index] == ')') floor--;
|
|
steps++;
|
|
if (floor < 0) break;
|
|
index++;
|
|
}
|
|
|
|
printf("Part 2: %d\n", steps);
|
|
free(input);
|
|
}
|