AOC2023: Add script to create day template and download input

This commit is contained in:
Bananymous 2023-12-23 18:46:14 +02:00
parent 762d575d70
commit 2faf90bc2b
4 changed files with 85 additions and 3 deletions

View File

@ -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)

View File

@ -0,0 +1,48 @@
#include <ctype.h>
#include <inttypes.h>
#include <stdio.h>
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);
}

15
userspace/aoc2023/init-day.sh Executable file
View File

@ -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

View File

@ -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