setup 2024
This commit is contained in:
parent
a4fbc02b32
commit
924caa936c
@ -17,10 +17,11 @@ file(GLOB SRC2020 src/2020/*.c)
|
|||||||
file(GLOB SRC2021 src/2021/*.c)
|
file(GLOB SRC2021 src/2021/*.c)
|
||||||
file(GLOB SRC2022 src/2022/*.c)
|
file(GLOB SRC2022 src/2022/*.c)
|
||||||
file(GLOB SRC2023 src/2023/*.c)
|
file(GLOB SRC2023 src/2023/*.c)
|
||||||
|
file(GLOB SRC2024 src/2024/*.c)
|
||||||
|
|
||||||
file(COPY input DESTINATION ${CMAKE_BINARY_DIR})
|
file(COPY input DESTINATION ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(advent ${SRC} ${SRC2015} ${SRC2016} ${SRC2017} ${SRC2018} ${SRC2019} ${SRC2020} ${SRC2021} ${SRC2022} ${SRC2023})
|
add_executable(advent ${SRC} ${SRC2015} ${SRC2016} ${SRC2017} ${SRC2018} ${SRC2019} ${SRC2020} ${SRC2021} ${SRC2022} ${SRC2023} ${SRC2024})
|
||||||
|
|
||||||
if ((${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"))
|
if ((${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"))
|
||||||
target_link_libraries(advent PRIVATE flint)
|
target_link_libraries(advent PRIVATE flint)
|
||||||
|
@ -6,7 +6,7 @@ Advent Of Code solutions using C99. Builds and runs on macOS, Linux, and OpenBSD
|
|||||||
|
|
||||||
Be sure to clone the project with its submodules:
|
Be sure to clone the project with its submodules:
|
||||||
|
|
||||||
git clone --recurse-submodules https://git.burkey.co/eburk/advent
|
git clone --recurse-submodules https://gitlab.com/eburk/aoc
|
||||||
|
|
||||||
This project relies on several BSD extensions to the stdlib. OpenBSD and macOS users should be able to build the project out of the box. Linux users will need `libbsd` installed. The package is called `libbsd-dev` on Debian-based systems.
|
This project relies on several BSD extensions to the stdlib. OpenBSD and macOS users should be able to build the project out of the box. Linux users will need `libbsd` installed. The package is called `libbsd-dev` on Debian-based systems.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
mkdir -p include
|
mkdir -p include
|
||||||
|
|
||||||
for year in {2023..2023}; do
|
for year in {2015..2024}; do
|
||||||
rm -rf "src/${year}"
|
rm -rf "src/${year}"
|
||||||
mkdir -p "src/${year}"
|
mkdir -p "src/${year}"
|
||||||
|
|
||||||
|
17
get_input.sh
17
get_input.sh
@ -4,8 +4,21 @@ get(){
|
|||||||
curl -s --cookie "session=$1" "$2" | perl -pe 'chomp if eof' > "$3"
|
curl -s --cookie "session=$1" "$2" | perl -pe 'chomp if eof' > "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
rm -rf input
|
if [ -n "${2+x}" ] && [ -n "${3+x}" ]; then
|
||||||
for year in {2015..2023}; do
|
year="20$2"
|
||||||
|
day="$3"
|
||||||
|
if [ "$day" -lt 10 ]; then
|
||||||
|
d="0$day"
|
||||||
|
else
|
||||||
|
d="$day"
|
||||||
|
fi
|
||||||
|
url="https://adventofcode.com/$year/day/$day/input"
|
||||||
|
get "$1" "$url" "input/$year/$d"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#rm -rf input
|
||||||
|
for year in {2015..2024}; do
|
||||||
mkdir -p input/"$year"
|
mkdir -p input/"$year"
|
||||||
for day in {1..25}; do
|
for day in {1..25}; do
|
||||||
if [[ day -lt 10 ]]; then
|
if [[ day -lt 10 ]]; then
|
||||||
|
58
include/advent2024.h
Normal file
58
include/advent2024.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#ifndef ADVENT_2024_H
|
||||||
|
#define ADVENT_2024_H
|
||||||
|
|
||||||
|
void advent2024day01(void);
|
||||||
|
void advent2024day02(void);
|
||||||
|
void advent2024day03(void);
|
||||||
|
void advent2024day04(void);
|
||||||
|
void advent2024day05(void);
|
||||||
|
void advent2024day06(void);
|
||||||
|
void advent2024day07(void);
|
||||||
|
void advent2024day08(void);
|
||||||
|
void advent2024day09(void);
|
||||||
|
void advent2024day10(void);
|
||||||
|
void advent2024day11(void);
|
||||||
|
void advent2024day12(void);
|
||||||
|
void advent2024day13(void);
|
||||||
|
void advent2024day14(void);
|
||||||
|
void advent2024day15(void);
|
||||||
|
void advent2024day16(void);
|
||||||
|
void advent2024day17(void);
|
||||||
|
void advent2024day18(void);
|
||||||
|
void advent2024day19(void);
|
||||||
|
void advent2024day20(void);
|
||||||
|
void advent2024day21(void);
|
||||||
|
void advent2024day22(void);
|
||||||
|
void advent2024day23(void);
|
||||||
|
void advent2024day24(void);
|
||||||
|
void advent2024day25(void);
|
||||||
|
|
||||||
|
void (*solutions2024[25])(void) = {
|
||||||
|
advent2024day01,
|
||||||
|
advent2024day02,
|
||||||
|
advent2024day03,
|
||||||
|
advent2024day04,
|
||||||
|
advent2024day05,
|
||||||
|
advent2024day06,
|
||||||
|
advent2024day07,
|
||||||
|
advent2024day08,
|
||||||
|
advent2024day09,
|
||||||
|
advent2024day10,
|
||||||
|
advent2024day11,
|
||||||
|
advent2024day12,
|
||||||
|
advent2024day13,
|
||||||
|
advent2024day14,
|
||||||
|
advent2024day15,
|
||||||
|
advent2024day16,
|
||||||
|
advent2024day17,
|
||||||
|
advent2024day18,
|
||||||
|
advent2024day19,
|
||||||
|
advent2024day20,
|
||||||
|
advent2024day21,
|
||||||
|
advent2024day22,
|
||||||
|
advent2024day23,
|
||||||
|
advent2024day24,
|
||||||
|
advent2024day25
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,13 +1,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "advent_utility.h"
|
#include <lfinput.h>
|
||||||
|
|
||||||
void advent2015day05(void) {
|
void advent2015day05(void) {
|
||||||
/* Sometimes, grep really is the best tool */
|
/* Sometimes, grep really is the best tool */
|
||||||
char *p1 = capture_system(
|
const char *p1 = capture_system(
|
||||||
"grep -E \"(.*[aeiou]){3}\" ./input/2015/05 | grep \"\\(.\\)\\1\" | egrep -v \"(ab|cd|pq|xy)\" | wc -l");
|
"grep -E \"(.*[aeiou]){3}\" ./input/2015/05 | grep \"\\(.\\)\\1\" | egrep -v \"(ab|cd|pq|xy)\" | wc -l", 0);
|
||||||
char *p2 = capture_system("grep \"\\(..\\).*\\1\" ./input/2015/05 | grep \"\\(.\\).\\1\" | wc -l");
|
const char *p2 = capture_system("grep \"\\(..\\).*\\1\" ./input/2015/05 | grep \"\\(.\\).\\1\" | wc -l", 0);
|
||||||
|
|
||||||
printf("%s%s", p1, p2);
|
printf("%s%s", p1, p2);
|
||||||
|
|
||||||
|
10
src/2024/01.c
Normal file
10
src/2024/01.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day01(void) {
|
||||||
|
char *input = get_input("input/2024/01");
|
||||||
|
printf("Solution for Day 01 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/02.c
Normal file
10
src/2024/02.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day02(void) {
|
||||||
|
char *input = get_input("input/2024/02");
|
||||||
|
printf("Solution for Day 02 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/03.c
Normal file
10
src/2024/03.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day03(void) {
|
||||||
|
char *input = get_input("input/2024/03");
|
||||||
|
printf("Solution for Day 03 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/04.c
Normal file
10
src/2024/04.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day04(void) {
|
||||||
|
char *input = get_input("input/2024/04");
|
||||||
|
printf("Solution for Day 04 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/05.c
Normal file
10
src/2024/05.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day05(void) {
|
||||||
|
char *input = get_input("input/2024/05");
|
||||||
|
printf("Solution for Day 05 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/06.c
Normal file
10
src/2024/06.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day06(void) {
|
||||||
|
char *input = get_input("input/2024/06");
|
||||||
|
printf("Solution for Day 06 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/07.c
Normal file
10
src/2024/07.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day07(void) {
|
||||||
|
char *input = get_input("input/2024/07");
|
||||||
|
printf("Solution for Day 07 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/08.c
Normal file
10
src/2024/08.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day08(void) {
|
||||||
|
char *input = get_input("input/2024/08");
|
||||||
|
printf("Solution for Day 08 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/09.c
Normal file
10
src/2024/09.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day09(void) {
|
||||||
|
char *input = get_input("input/2024/09");
|
||||||
|
printf("Solution for Day 09 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/10.c
Normal file
10
src/2024/10.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day10(void) {
|
||||||
|
char *input = get_input("input/2024/10");
|
||||||
|
printf("Solution for Day 10 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/11.c
Normal file
10
src/2024/11.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day11(void) {
|
||||||
|
char *input = get_input("input/2024/11");
|
||||||
|
printf("Solution for Day 11 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/12.c
Normal file
10
src/2024/12.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day12(void) {
|
||||||
|
char *input = get_input("input/2024/12");
|
||||||
|
printf("Solution for Day 12 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/13.c
Normal file
10
src/2024/13.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day13(void) {
|
||||||
|
char *input = get_input("input/2024/13");
|
||||||
|
printf("Solution for Day 13 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/14.c
Normal file
10
src/2024/14.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day14(void) {
|
||||||
|
char *input = get_input("input/2024/14");
|
||||||
|
printf("Solution for Day 14 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/15.c
Normal file
10
src/2024/15.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day15(void) {
|
||||||
|
char *input = get_input("input/2024/15");
|
||||||
|
printf("Solution for Day 15 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/16.c
Normal file
10
src/2024/16.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day16(void) {
|
||||||
|
char *input = get_input("input/2024/16");
|
||||||
|
printf("Solution for Day 16 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/17.c
Normal file
10
src/2024/17.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day17(void) {
|
||||||
|
char *input = get_input("input/2024/17");
|
||||||
|
printf("Solution for Day 17 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/18.c
Normal file
10
src/2024/18.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day18(void) {
|
||||||
|
char *input = get_input("input/2024/18");
|
||||||
|
printf("Solution for Day 18 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/19.c
Normal file
10
src/2024/19.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day19(void) {
|
||||||
|
char *input = get_input("input/2024/19");
|
||||||
|
printf("Solution for Day 19 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/20.c
Normal file
10
src/2024/20.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day20(void) {
|
||||||
|
char *input = get_input("input/2024/20");
|
||||||
|
printf("Solution for Day 20 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/21.c
Normal file
10
src/2024/21.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day21(void) {
|
||||||
|
char *input = get_input("input/2024/21");
|
||||||
|
printf("Solution for Day 21 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/22.c
Normal file
10
src/2024/22.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day22(void) {
|
||||||
|
char *input = get_input("input/2024/22");
|
||||||
|
printf("Solution for Day 22 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/23.c
Normal file
10
src/2024/23.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day23(void) {
|
||||||
|
char *input = get_input("input/2024/23");
|
||||||
|
printf("Solution for Day 23 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/24.c
Normal file
10
src/2024/24.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day24(void) {
|
||||||
|
char *input = get_input("input/2024/24");
|
||||||
|
printf("Solution for Day 24 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
10
src/2024/25.c
Normal file
10
src/2024/25.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "lfinput.h"
|
||||||
|
|
||||||
|
void advent2024day25(void) {
|
||||||
|
char *input = get_input("input/2024/25");
|
||||||
|
printf("Solution for Day 25 of 2024 is not completed yet\n");
|
||||||
|
free(input);
|
||||||
|
}
|
@ -16,6 +16,7 @@
|
|||||||
#include "advent2021.h"
|
#include "advent2021.h"
|
||||||
#include "advent2022.h"
|
#include "advent2022.h"
|
||||||
#include "advent2023.h"
|
#include "advent2023.h"
|
||||||
|
#include "advent2024.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
@ -27,7 +28,7 @@ int main(int argc, char **argv) {
|
|||||||
char buf[32];
|
char buf[32];
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
|
|
||||||
year = strtonum(argv[1], 15, 23, &errstr);
|
year = strtonum(argv[1], 15, 24, &errstr);
|
||||||
if (NULL != errstr) {
|
if (NULL != errstr) {
|
||||||
printf("Input error: %s\n\n", errstr);
|
printf("Input error: %s\n\n", errstr);
|
||||||
return 1;
|
return 1;
|
||||||
@ -67,6 +68,9 @@ int main(int argc, char **argv) {
|
|||||||
case 23:
|
case 23:
|
||||||
solutions2023[day - 1]();
|
solutions2023[day - 1]();
|
||||||
break;
|
break;
|
||||||
|
case 24:
|
||||||
|
solutions2024[day - 1]();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user