A little refactoring for day 3.

This commit is contained in:
Alexander Andreev 2023-12-07 00:29:49 +04:00
parent b19aa5edca
commit 2f2b4194c6
Signed by: Arav
GPG Key ID: D22A817D95815393
2 changed files with 5 additions and 4 deletions

View File

@ -3,10 +3,11 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
int main(int argc, char **argv) {
FILE *input;
char *line = NULL;
@ -57,9 +58,8 @@ int main(int argc, char **argv) {
((i+1 <= engine_lines-1 && j+1 <= engine_line_size-1) && !ISDIGIT(engine[i+1][j+1]) && engine[i+1][j+1] != '.') ||
((i+1 <= engine_lines-1 && j-1 >= 0) && !ISDIGIT(engine[i+1][j-1]) && engine[i+1][j-1] != '.') ||
((i-1 >= 0 && j+1 <= engine_line_size-1) && !ISDIGIT(engine[i-1][j+1]) && engine[i-1][j+1] != '.') ||
((i-1 >= 0 && j-1 >= 0) && !ISDIGIT(engine[i-1][j-1]) && engine[i-1][j-1] != '.'))) {
((i-1 >= 0 && j-1 >= 0) && !ISDIGIT(engine[i-1][j-1]) && engine[i-1][j-1] != '.')))
adjacent = true;
}
}
if ((!ISDIGIT(engine[i][j]) || j == 0) && n != 0) {

View File

@ -3,12 +3,13 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
uint64_t parse_number(char *line, ssize_t j);
int main(int argc, char **argv) {
FILE *input;
char *line = NULL;