no more crash on day3
This commit is contained in:
4
Makefile
4
Makefile
@@ -2,8 +2,8 @@ FILES = $(wildcard ./*)
|
|||||||
SRCS = $(filter %.c,$(FILES))
|
SRCS = $(filter %.c,$(FILES))
|
||||||
BINS = $(SRCS:%.c=%.elf)
|
BINS = $(SRCS:%.c=%.elf)
|
||||||
|
|
||||||
CFLAGS = -Wall -Werror -pedantic -D_GNU_SOURCE -std=gnu2y -O3 -g -Wno-unused\
|
CFLAGS = -Wall -Werror -pedantic -Wno-unused -D_GNU_SOURCE -std=gnu2y\
|
||||||
-nostartfiles -static -Ttext=C475000
|
-O3 -g -Ttext=C475000 -static -nostartfiles -fno-stack-protector -march=native
|
||||||
|
|
||||||
all: $(BINS)
|
all: $(BINS)
|
||||||
|
|
||||||
|
|||||||
9
day3.c
9
day3.c
@@ -49,20 +49,17 @@ unsigned long do_part2(size_t file_len, unsigned char file[file_len]) {
|
|||||||
unsigned char *s = file;
|
unsigned char *s = file;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// for some reason this crashes
|
|
||||||
// but works fine under blink so.
|
|
||||||
// whatever
|
|
||||||
unsigned char n[12] = { };
|
unsigned char n[12] = { };
|
||||||
unsigned char *np[12] = { };
|
unsigned char *np = NULL;
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
do {
|
do {
|
||||||
if (s[0] > n[i]) {
|
if (s[0] > n[i]) {
|
||||||
n[i] = s[0];
|
n[i] = s[0];
|
||||||
np[i] = s;
|
np = s;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
} while (s[11-i] != '\n');
|
} while (s[11-i] != '\n');
|
||||||
s = np[i]+1;
|
s = np+1;
|
||||||
}
|
}
|
||||||
unsigned long v = 0;
|
unsigned long v = 0;
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user