Skip to content

Instantly share code, notes, and snippets.

@dishbreak
Last active December 1, 2021 23:47
Show Gist options
  • Save dishbreak/cb2b937b57c2848899eda613f241e462 to your computer and use it in GitHub Desktop.
Save dishbreak/cb2b937b57c2848899eda613f241e462 to your computer and use it in GitHub Desktop.
Advent of Code Bootstrap Script
#!/bin/bash
YEAR=${1:?need year as argument}
cat <<EOF >go.mod
go 1.17
module github.com/dishbreak/aoc$YEAR
EOF
go get -u github.com/dishbreak/aoc2020
go get -u github.com/stretchr/testify
mkdir cmd
mkdir inputs
cd cmd || exit
mkdir day1
cat <<EOF >day1/main.go
package main
import (
"fmt"
"github.com/dishbreak/aoc2020/lib"
)
func main() {
input, err := lib.GetInput("inputs/dayNN.txt")
if err != nil {
panic(err)
}
fmt.Printf("Part 1: %d\n", part1(input))
fmt.Printf("Part 2: %d\n", part2(input))
}
func part1(input []string) int {
return 0
}
func part2(input []string) int {
return 0
}
EOF
cat <<EOF >day1/main_test.go
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
var input = []string{}
func TestPart1(t *testing.T) {
assert.Equal(t, 0, part1(input))
}
func TestPart2(t *testing.T) {
assert.Equal(t, 0, part2(input))
}
EOF
for i in {2..25}; do
cp -r day1 "day$i"
done
cat << EOF >README.md
# Advent of Code $YEAR Solutions
The following are my solutions to the $YEAR [Advent of Code](https://adventofcode.com/$YEAR) challenge.
To run a specific challenge, from the root of the repo:
$ go run ./cmd/day18
Part 1: 23507031841020
Part 2: 218621700997826
Note that this repo uses my own individual solutions. In order to play you'll need to download your own puzzle inputs from the Advent of Code website.
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment