diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Readme.textile | 13 | ||||
-rwxr-xr-x | new | 10 | ||||
-rw-r--r-- | skel/Dockerfile | 7 | ||||
-rw-r--r-- | skel/Makefile | 13 | ||||
-rwxr-xr-x | skel/entrypoint | 13 | ||||
-rw-r--r-- | skel/input | 0 | ||||
-rwxr-xr-x | skel/part1 | 3 |
8 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5a1572 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +build diff --git a/Readme.textile b/Readme.textile new file mode 100644 index 0000000..9305de5 --- /dev/null +++ b/Readme.textile @@ -0,0 +1,13 @@ +h1. Advent of Code 2019 + +p. My answers to the "2019 Advent of Code":https://adventofcode.com/2019. + +h2. Running a day + +bc. cd day01 +make + +h2. Creating a new day + +bc.. ./new # Create today +./new 01 # Create a specific day @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ "x$1" == "x" ]; then + D=$(date +%d) +else + D=$1 +fi + +cp -r skel day$D +sed -i "s/DAY = /DAY = ${D}/" day${D}/Makefile diff --git a/skel/Dockerfile b/skel/Dockerfile new file mode 100644 index 0000000..e5adcb1 --- /dev/null +++ b/skel/Dockerfile @@ -0,0 +1,7 @@ +FROM ruby:2.6.5-slim + +WORKDIR /opt + +COPY . . + +ENTRYPOINT ["./entrypoint"] diff --git a/skel/Makefile b/skel/Makefile new file mode 100644 index 0000000..6faa80b --- /dev/null +++ b/skel/Makefile @@ -0,0 +1,13 @@ +DAY = + +.PHONY: run clean + +run: build + docker run -it --rm aoc2019day$(DAY) + +build: part* input + docker build -t aoc2019day$(DAY) . + touch build + +clean: + rm -f build diff --git a/skel/entrypoint b/skel/entrypoint new file mode 100755 index 0000000..8982d21 --- /dev/null +++ b/skel/entrypoint @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ -x part1 ] ; then + echo -ne "Part 1:\n\t" + time ./part1 < input +fi +if [ -x part1 -a -x part2 ] ; then + echo +fi +if [ -x part2 ] ; then + echo -ne "Part 2:\n\t" + time ./part2 < input +fi diff --git a/skel/input b/skel/input new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/skel/input diff --git a/skel/part1 b/skel/part1 new file mode 100755 index 0000000..5c15e00 --- /dev/null +++ b/skel/part1 @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +input = $stdin.readlines.map(&:strip) |