Skip to content

Commit a3dabe4

Browse files
committed
Initial setup and test effort
1 parent 97cd130 commit a3dabe4

File tree

15 files changed

+1608
-1
lines changed

15 files changed

+1608
-1
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Unix-style newlines with a newline ending every file
2+
[*]
3+
# set to lf, cr, or crlf to control how line breaks are represented.
4+
end_of_line = lf
5+
# set to true to ensure file ends with a newline when saving and false to ensure it doesn't.
6+
insert_final_newline = true
7+
# set to tab or space to use hard tabs or soft tabs respectively.
8+
indent_style = space
9+
# a whole number defining the number of columns used for each indentation level and the width of soft tabs (when supported).
10+
indent_size = 4
11+
12+
[{go.mod,go.sum,*.go}]
13+
indent_style = tab

.github/workflows/golang.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Golang
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
GO_VERSION: stable
12+
GOLANGCI_LINT_VERSION: v1.60
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
24+
- name: Set up gotestfmt
25+
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
26+
# - name: Install dependencies
27+
# run: go get .
28+
- name: golangci-lint
29+
uses: golangci/golangci-lint-action@v6
30+
with:
31+
version: ${{ env.GOLANGCI_LINT_VERSION }}
32+
- name: Build
33+
run: go build -v ./...
34+
- name: Test with the Go CLI
35+
run: |
36+
set -euo pipefail
37+
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
38+
- name: Upload test log
39+
uses: actions/upload-artifact@v4
40+
if: always()
41+
with:
42+
name: test-log
43+
path: /tmp/gotest.log
44+
if-no-files-found: error
45+
- name: Benchmarks
46+
run: go test ./... -bench=. -run=^#

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output:
2+
formats:
3+
- format: colored-line-number

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Package",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${fileDirname}"
13+
}
14+
]
15+
}

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
# advent-of-code-2024
1+
# Advent of Code - 2024
2+
3+
An attempt at [Advent of Code](https://adventofcode.com/2024) using [Go](https://go.dev)!
4+
5+
![[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)
6+
7+
Each day will be setup as a separate folder.
8+
9+
- [Day 0](/day-0/) - Trebuchet?! (2023 Day 1)
10+
11+
## Environment Setup
12+
13+
To setup your environment:
14+
15+
1. [Install](https://go.dev/dl/) Golang (or `brew install golang`)
16+
2. Install [Golang CI Lint](https://github.com/golangci/golangci-lint): `brew install golangci-lint`
17+
3. Install [Just](https://github.com/casey/just): `brew install just`
18+
4. Install [gotestfmt](https://github.com/GoTestTools/gotestfmt): `go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest`
19+
- Make sure your GOPATH/bin is in your PATH: `export PATH=$PATH:$(go env GOPATH)/bin`
20+
5. Clone this repository
21+
6. Create a new day from template: `just create X` (where X is the day number)
22+
7. Be Merry! 🎄
23+
24+
## Testing
25+
26+
To run tests for an individual day X, run `just test X` or to run all tests run `just test-all`
27+
28+
## Linting
29+
30+
To run linting for an individual day X, run `just lint X` or to run all linting run `just lint-all`
31+
32+
## Running
33+
34+
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

day-0/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Day 1: Trebuchet?!
2+
3+
## Part 1
4+
5+
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.
6+
7+
You've been doing this long enough to know that to restore snow operations, you need to check all fifty stars by December 25th.
8+
9+
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!
10+
11+
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").
12+
13+
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.
14+
15+
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.
16+
17+
For example:
18+
19+
```
20+
1abc2
21+
pqr3stu8vwx
22+
a1b2c3d4e5f
23+
treb7uchet
24+
```
25+
26+
In this example, the calibration values of these four lines are 12, 38, 15, and 77. Adding these together produces 142.
27+
28+
Consider your entire calibration document. What is the sum of all of the calibration values?
29+
30+
## Part 2
31+
32+
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".
33+
34+
Equipped with this new information, you now need to find the real first and last digit on each line. For example:
35+
36+
```
37+
two1nine
38+
eightwothree
39+
abcone2threexyz
40+
xtwone3four
41+
4nineeightseven2
42+
zoneight234
43+
7pqrstsixteen
44+
```
45+
46+
In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76. Adding these together produces 281.
47+
48+
What is the sum of all of the calibration values?

0 commit comments

Comments
 (0)