A little refactoring for day 3.
This commit is contained in:
parent
b19aa5edca
commit
2f2b4194c6
@ -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,10 +58,9 @@ 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) {
|
||||
if (adjacent)
|
||||
|
Loading…
Reference in New Issue
Block a user