-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Advent Of Code 2024 | ||
|
||
My [AoC 2024](https://adventofcode.com/2024) Solutions in Swift | ||
|
||
### Overview | ||
|
||
All code for all days is compiled into a single macOS commandline binary, which can be run either from within Xcode or from Terminal. | ||
|
||
Each day has at least 3 associated source files: | ||
|
||
* `DayX.swift` for the solution code | ||
* `DayX+Input.swift` for the puzzle input. This file is created by running the `input.sh` script (see below) but is not included in this repo for [legal reasons](https://www.reddit.com/r/adventofcode/wiki/faqs/copyright/inputs). | ||
* `DayXTests.swift` for the test suite, if the puzzle has test cases | ||
|
||
`AoC.swift` has the `main()` function which simply runs one (or all) of the puzzles. | ||
|
||
The code relies on my own [AoCTools](https://github.com/gereons/AoCTools) package where I started collecting utility functions for things frequently used in AoC, such as 2d and 3d points, hexagonal grids, an A\* pathfinder and more. | ||
|
||
### Xcode | ||
|
||
Open the project via the `Package.swift` file (`xed .` from Terminal in the project directory). By default, hitting `Cmd-R` will run the puzzle for the current calendar day. To override this, change `defaultDay` in `AoC.swift`. | ||
|
||
`Cmd-U` runs the test suite for all 25 days. Run individual tests by clicking on them in the Test Inspector (`Cmd-6`) | ||
|
||
### Commandline | ||
|
||
From the commandline, use `swift run` or `swift run -c release`. | ||
|
||
To run the puzzle for a specific day without changing `AoC.swift`, use `swift run AdventOfCode X` to run day `X`. `X` can be a number from 1 to 25 or `all`. | ||
|
||
To run tests, use `swift test` for all tests, or e.g. `swift test --filter AoCTests.Day02Tests` to run the tests for day 2. | ||
|
||
### Puzzle Inputs | ||
|
||
Use the included `input.sh` script to download your puzzle input. To be able to run this script, [grab the session cookie](https://www.reddit.com/r/adventofcode/comments/a2vonl/how_to_download_inputs_with_a_script/) from [adventofcode.com](https://adventofcode.com) and create a `.aoc-session` file with the contents. `input.sh` downloads the input for the current day by default, use `input.sh X` to download day X's input. | ||
|
||
<!--- advent_readme_stars table ---> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 1 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day01Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay01_part1() throws { | ||
let day = Day01(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay01_part1_solution() throws { | ||
let day = Day01(input: Day01.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay01_part2() throws { | ||
let day = Day01(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay01_part2_solution() throws { | ||
let day = Day01(input: Day01.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 2 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day02Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay02_part1() throws { | ||
let day = Day02(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay02_part1_solution() throws { | ||
let day = Day02(input: Day02.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay02_part2() throws { | ||
let day = Day02(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay02_part2_solution() throws { | ||
let day = Day02(input: Day02.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 3 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day03Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay03_part1() throws { | ||
let day = Day03(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay03_part1_solution() throws { | ||
let day = Day03(input: Day03.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay03_part2() throws { | ||
let day = Day03(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay03_part2_solution() throws { | ||
let day = Day03(input: Day03.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 4 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day04Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay04_part1() throws { | ||
let day = Day04(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay04_part1_solution() throws { | ||
let day = Day04(input: Day04.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay04_part2() throws { | ||
let day = Day04(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay04_part2_solution() throws { | ||
let day = Day04(input: Day04.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 5 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day05Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay05_part1() throws { | ||
let day = Day05(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay05_part1_solution() throws { | ||
let day = Day05(input: Day05.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay05_part2() throws { | ||
let day = Day05(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay05_part2_solution() throws { | ||
let day = Day05(input: Day05.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 6 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day06Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay06_part1() throws { | ||
let day = Day06(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay06_part1_solution() throws { | ||
let day = Day06(input: Day06.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay06_part2() throws { | ||
let day = Day06(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay06_part2_solution() throws { | ||
let day = Day06(input: Day06.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 7 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day07Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay07_part1() throws { | ||
let day = Day07(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay07_part1_solution() throws { | ||
let day = Day07(input: Day07.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay07_part2() throws { | ||
let day = Day07(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay07_part2_solution() throws { | ||
let day = Day07(input: Day07.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 8 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day08Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay08_part1() throws { | ||
let day = Day08(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay08_part1_solution() throws { | ||
let day = Day08(input: Day08.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay08_part2() throws { | ||
let day = Day08(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay08_part2_solution() throws { | ||
let day = Day08(input: Day08.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 9 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day09Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay09_part1() throws { | ||
let day = Day09(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay09_part1_solution() throws { | ||
let day = Day09(input: Day09.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay09_part2() throws { | ||
let day = Day09(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay09_part2_solution() throws { | ||
let day = Day09(input: Day09.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Advent of Code 2024 Day 10 Tests | ||
// | ||
|
||
import XCTest | ||
@testable import AdventOfCode | ||
|
||
@MainActor | ||
final class Day10Tests: XCTestCase { | ||
let testInput = """ | ||
""" | ||
|
||
func testDay10_part1() throws { | ||
let day = Day10(input: testInput) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay10_part1_solution() throws { | ||
let day = Day10(input: Day10.input) | ||
XCTAssertEqual(day.part1(), 0) | ||
} | ||
|
||
func testDay10_part2() throws { | ||
let day = Day10(input: testInput) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
|
||
func testDay10_part2_solution() throws { | ||
let day = Day10(input: Day10.input) | ||
XCTAssertEqual(day.part2(), 0) | ||
} | ||
} |
Oops, something went wrong.