diff --git a/userspace/aoc2023/day-template/CMakeLists.txt b/userspace/aoc2023/day-template/CMakeLists.txt new file mode 100644 index 0000000000..de3e502eed --- /dev/null +++ b/userspace/aoc2023/day-template/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.26) + +project(aoc2023_day-template CXX) + +set(SOURCES + main.cpp +) + +add_executable(aoc2023_day-template ${SOURCES}) +target_compile_options(aoc2023_day-template PUBLIC -O2 -g) +target_link_libraries(aoc2023_day-template PUBLIC libc ban) + +add_dependencies(aoc2023_day-template libc-install ban-install) + +add_custom_target(aoc2023_day-template-install + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/aoc2023_day-template ${BANAN_AOC2023_BIN}/day-template + DEPENDS aoc2023_day-template + DEPENDS aoc2023_always +) + +add_dependencies(aoc2023 aoc2023_day-template) +add_dependencies(aoc2023-install aoc2023_day-template-install) diff --git a/userspace/aoc2023/day-template/main.cpp b/userspace/aoc2023/day-template/main.cpp new file mode 100644 index 0000000000..29a61acd48 --- /dev/null +++ b/userspace/aoc2023/day-template/main.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +using i8 = int8_t; +using i16 = int16_t; +using i32 = int32_t; +using i64 = int64_t; + +using u8 = uint8_t; +using u16 = uint16_t; +using u32 = uint32_t; +using u64 = uint64_t; + +i64 puzzle1(FILE* fp) +{ + (void)fp; + return -1; +} + +i64 puzzle2(FILE* fp) +{ + (void)fp; + return -1; +} + +int main(int argc, char** argv) +{ + const char* file_path = "/usr/share/aoc2023/day-template_input.txt"; + + if (argc >= 2) + file_path = argv[1]; + + FILE* fp = fopen(file_path, "r"); + if (fp == nullptr) + { + perror("fopen"); + return 1; + } + + printf("puzzle1: %" PRId64 "\n", puzzle1(fp)); + + fseek(fp, 0, SEEK_SET); + + printf("puzzle2: %" PRId64 "\n", puzzle2(fp)); + + fclose(fp); +} diff --git a/userspace/aoc2023/init-day.sh b/userspace/aoc2023/init-day.sh new file mode 100755 index 0000000000..e60eff15e5 --- /dev/null +++ b/userspace/aoc2023/init-day.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo Please specify day number >& 2 + exit 1 +fi + +if [[ ! -d day$1 ]]; then + cp -r day-template day$1 + sed -i "s/day-template/day$1/g" day$1/* +fi + +if [[ ! -f input/day$1_input.txt ]]; then + wget --no-cookies --header "Cookie: session=$AOC_SESSION" https://adventofcode.com/2023/day/$1/input -O input/day$1_input.txt +fi diff --git a/userspace/aoc2023/input/get-input.sh b/userspace/aoc2023/input/get-input.sh deleted file mode 100755 index 059557cee3..0000000000 --- a/userspace/aoc2023/input/get-input.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -wget --no-cookies --header "Cookie: session=$AOC_SESSION" https://adventofcode.com/2023/day/$1/input -O day$1_input.txt