A little refactoring for day 3.
This commit is contained in:
parent
b19aa5edca
commit
2f2b4194c6
@ -3,10 +3,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
|
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
FILE *input;
|
FILE *input;
|
||||||
char *line = NULL;
|
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 <= 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 <= 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 <= 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;
|
adjacent = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!ISDIGIT(engine[i][j]) || j == 0) && n != 0) {
|
if ((!ISDIGIT(engine[i][j]) || j == 0) && n != 0) {
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
|
#define ISDIGIT(c) (c >= 0x30 && c <= 0x39)
|
||||||
|
|
||||||
uint64_t parse_number(char *line, ssize_t j);
|
uint64_t parse_number(char *line, ssize_t j);
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
FILE *input;
|
FILE *input;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user