advent2021

Advent of Code 2021 Solutions
git clone git://bsandro.tech/advent2021
Log | Files | Refs

commit 53c8d632d6ff7da0980ecec35c40d37a5acdf77a
parent 3a5c7cf1411e4fd9def7de63c832458a7e132fb7
Author: bsandro <brian.drosan@gmail.com>
Date:   Thu, 23 Dec 2021 01:20:50 +0200

cuboids -> sequence

Diffstat:
Mday22/puzzle.c | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/day22/puzzle.c b/day22/puzzle.c @@ -32,34 +32,34 @@ void puzzle(const char *filename, long long *result1, long long *result2) { char buf[STR_LEN] = {0}; - struct array_t cuboids = { .data = NULL }; - array_init(&cuboids, sizeof(struct cuboid_t), 10); + struct array_t sequence = { .data = NULL }; + array_init(&sequence, sizeof(struct cuboid_t), 10); while (fgets(buf, STR_LEN, infile) != NULL) { - parse_cuboid(&cuboids, buf); + parse_cuboid(&sequence, buf); bzero(buf, STR_LEN); } bool cubes[101][101][101] = {0}; - init_cubes(&cubes, &cuboids); + init_cubes(&cubes, &sequence); *result1 = count_cubes(&cubes); *result2 = 0; - free(cuboids.data); + free(sequence.data); // mutiny! ignoring feof/ferror. fclose(infile); } -void init_cubes(bool (*cubes)[101][101][101], struct array_t *cuboids) { +void init_cubes(bool (*cubes)[101][101][101], struct array_t *sequence) { assert(cubes != NULL); - assert(cuboids != NULL); - assert(cuboids->data != NULL); + assert(sequence != NULL); + assert(sequence->data != NULL); - struct cuboid_t *cuboids_data = cuboids->data; - for (size_t i = 0; i < cuboids->count; ++i) { - struct cuboid_t *cuboid = &cuboids_data[i]; + struct cuboid_t *sequence_data = sequence->data; + for (size_t i = 0; i < sequence->count; ++i) { + struct cuboid_t *cuboid = &sequence_data[i]; if (cuboid->x1 >= -50 && cuboid->x2 <= 50 && cuboid->y1 >= -50 && cuboid->y2 <= 50 && cuboid->z1 >= -50 && cuboid->z2 <= 50) {