add script to quickly set up puzzle code templates

This commit is contained in:
alex 2022-12-04 20:25:26 -05:00
parent 0b21259853
commit 618a65bb5d
3 changed files with 62 additions and 0 deletions

21
setup_day.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
day=$1
day_long=$(printf "%02d" "$day")
dir="day_$day_long"
puzzle_name=$2
mkdir -p "$dir"
cp solution.ts.template "$dir/solution.ts"
sed -e "s/%%DAY%%/$day/g" \
-e "s/%%DAY_LONG%%/$day_long/g" \
-e "s/%%PUZZLE_NAME%%/$puzzle_name/g" \
solution.test.ts.template > "$dir/solution.test.ts"
./get_input.sh "$day"
touch "$dir/sample.txt"

27
solution.test.ts.template Normal file
View File

@ -0,0 +1,27 @@
import { readlines } from "../_utils";
const solution = require("./solution");
describe("day %%DAY%%: %%PUZZLE_NAME%%, pt 1", () => {
test("sample input", async () => {
const sample = await readlines("./day_%%DAY_LONG%%/sample.txt");
expect(solution.part1_solver(sample)).toBe(0);
});
test("submission input", async () => {
const input = await readlines("./day_%%DAY_LONG%%/input.txt");
expect(solution.part1_solver(input)).toBe(0);
});
});
describe("day %%DAY%%: %%PUZZLE_NAME%%, pt 2", () => {
test("sample input", async () => {
const sample = await readlines("./day_%%DAY_LONG%%/sample.txt");
expect(solution.part2_solver(sample)).toBe(0);
});
test("submission input", async () => {
const input = await readlines("./day_%%DAY_LONG%%/input.txt");
expect(solution.part2_solver(input)).toBe(0);
});
});

14
solution.ts.template Normal file
View File

@ -0,0 +1,14 @@
/*
*/
export function part1_solver(lines: string[]): number {
return 1;
}
/*
*/
export function part2_solver(lines: string[]): number {
return 1;
}