Skip to content

Commit

Permalink
Initial setup and test effort
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunburdick committed Nov 19, 2024
1 parent 97cd130 commit a3dabe4
Show file tree
Hide file tree
Showing 15 changed files with 1,608 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Unix-style newlines with a newline ending every file
[*]
# set to lf, cr, or crlf to control how line breaks are represented.
end_of_line = lf
# set to true to ensure file ends with a newline when saving and false to ensure it doesn't.
insert_final_newline = true
# set to tab or space to use hard tabs or soft tabs respectively.
indent_style = space
# a whole number defining the number of columns used for each indentation level and the width of soft tabs (when supported).
indent_size = 4

[{go.mod,go.sum,*.go}]
indent_style = tab
46 changes: 46 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Golang

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

env:
CARGO_TERM_COLOR: always
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.60

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
# - name: Install dependencies
# run: go get .
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
- name: Benchmarks
run: go test ./... -bench=. -run=^#
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output:
formats:
- format: colored-line-number
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# advent-of-code-2024
# Advent of Code - 2024

An attempt at [Advent of Code](https://adventofcode.com/2024) using [Go](https://go.dev)!

![[Workflow Status](https://github.com/shaunburdick/advent-of-code-2024/actions/workflows/golang.yml)](https://github.com/shaunburdick/advent-of-code-2024/actions/workflows/golang.yml/badge.svg)

Each day will be setup as a separate folder.

- [Day 0](/day-0/) - Trebuchet?! (2023 Day 1)

## Environment Setup

To setup your environment:

1. [Install](https://go.dev/dl/) Golang (or `brew install golang`)
2. Install [Golang CI Lint](https://github.com/golangci/golangci-lint): `brew install golangci-lint`
3. Install [Just](https://github.com/casey/just): `brew install just`
4. Install [gotestfmt](https://github.com/GoTestTools/gotestfmt): `go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest`
- Make sure your GOPATH/bin is in your PATH: `export PATH=$PATH:$(go env GOPATH)/bin`
5. Clone this repository
6. Create a new day from template: `just create X` (where X is the day number)
7. Be Merry! 🎄

## Testing

To run tests for an individual day X, run `just test X` or to run all tests run `just test-all`

## Linting

To run linting for an individual day X, run `just lint X` or to run all linting run `just lint-all`

## Running

To run a solution, run `just run <day> <part>` where day is the day number and part is the part number. Example: `just run 1 1` to run day 1, part 1
48 changes: 48 additions & 0 deletions day-0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Day 1: Trebuchet?!

## Part 1

Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems.

You've been doing this long enough to know that to restore snow operations, you need to check all fifty stars by December 25th.

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!

You try to ask why they can't just use a weather machine ("not powerful enough") and where they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a lot of questions") and hang on did you just say the sky ("of course, where do you think snow comes from") when you realize that the Elves are already loading you into a trebuchet ("please hold still, we need to strap you in").

As they're making the final adjustments, they discover that their calibration document (your puzzle input) has been amended by a very young Elf who was apparently just excited to show off her art skills. Consequently, the Elves are having trouble reading the values on the document.

The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number.

For example:

```
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
```

In this example, the calibration values of these four lines are 12, 38, 15, and 77. Adding these together produces 142.

Consider your entire calibration document. What is the sum of all of the calibration values?

## Part 2

Your calculation isn't quite right. It looks like some of the digits are actually spelled out with letters: one, two, three, four, five, six, seven, eight, and nine also count as valid "digits".

Equipped with this new information, you now need to find the real first and last digit on each line. For example:

```
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
```

In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76. Adding these together produces 281.

What is the sum of all of the calibration values?
Loading

0 comments on commit a3dabe4

Please sign in to comment.