aboutsummaryrefslogtreecommitdiffstats
path: root/init.sh
blob: 5239b81d08d029816687a8da832b6fa40bcbd15c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

ADVENT_SESSION=$(cat ../cookie)

if [ $# -eq 0 ]; then
	echo "Usage: ./init.sh <#day>"
	exit 1
fi

DAY=$1
YEAR="${PWD##*/}"
DIR=$(printf "day%02d" $DAY)
echo "Initializing day $DAY in directory $DIR"

mkdir -p $DIR &&
	curl "https://adventofcode.com/$YEAR/day/$DAY/input" -H "Cookie: session=$ADVENT_SESSION" >$DIR/input.txt
echo \
	'const std = @import("std");
const print = std.debug.print;
const assert = std.debug.assert;
const mem = std.mem;
const input = @embedFile("./input.txt");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    var alloc = gpa.allocator();
}' >$DIR/solution.zig