Skip to content

Switched to reading input directly from AOC as per rules. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ build/
!**/src/test/**/build/

### Advent of Code Input ###
src/main/resources
src/main/resources/cookie
src/main/resources/day*.txt

### IntelliJ IDEA ###
.idea
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

My attempt in Kotlin to complete the [2024 Advent of Code](https://adventofcode.com/2024).

**Current status:** Day 5 complete.
To retrieve input data, you must obtain your session cookie from
the Advent of Code website and add it to the [resources](src/main/resources) directory.

**Last updated:** 2024-12-05.
**Current status:** Day 8 complete.

**Last updated:** 2024-12-08.
5 changes: 2 additions & 3 deletions src/main/kotlin/day01/day01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

package day01

import common.day
import common.aocreader.fetchAdventOfCodeInput
import common.parsing.parseColumns
import common.readInput
import common.collectionops.toFrequencyMap
import kotlin.math.abs

Expand All @@ -25,7 +24,7 @@ fun answer2(input: String): Int =
}

fun main() {
val input = readInput({}::class.day())
val input = fetchAdventOfCodeInput(2024, 1)

println("--- Day 1: Historian Hysteria ---")

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/day02/day02.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

package day02

import common.aocreader.fetchAdventOfCodeInput
import common.collectionops.allListDrops
import common.day
import common.parsing.parseGrid
import common.readInput

private const val Lower = 1
private const val Upper = 3
Expand All @@ -30,7 +29,7 @@ fun answer2(input: String): Int =
parseGrid(input, String::toInt).count(::isReportAlmostSafe)

fun main() {
val input = readInput({}::class.day())
val input = fetchAdventOfCodeInput(2024, 2)

println("--- Day 2: Red-Nosed Reports ---")

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/day03/day03.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

package day03

import common.day
import common.readInput
import common.aocreader.fetchAdventOfCodeInput

/**
* We want to turn off processing for substrings of the form:
Expand All @@ -31,7 +30,7 @@ fun answer2(input: String): Int =
answer1(preprocess(input))

fun main() {
val input = readInput({}::class.day())
val input = fetchAdventOfCodeInput(2024, 3)

println("--- Day 3: Mull It Over ---")

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/day04/day04.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

package day04

import common.aocreader.fetchAdventOfCodeInput
import common.countSubstrings
import common.day
import common.collectionops.*
import common.readInput

private const val XMAS = "XMAS"

Expand Down Expand Up @@ -60,7 +59,7 @@ fun answer2(input: String): Int =
countXXmases(input.lines())

fun main() {
val input = readInput({}::class.day())
val input = fetchAdventOfCodeInput(2024, 4)

println("--- Day 4: Ceres Search ---")

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/day05/day05.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

package day05

import common.day
import common.aocreader.fetchAdventOfCodeInput
import common.collectionops.middle
import common.readInput

private typealias OrderingRules = Map<Int, Set<Int>>
private typealias Updates = List<Int>
Expand Down Expand Up @@ -96,7 +95,7 @@ fun answer2(input: String): Int =
}

fun main() {
val input = readInput({}::class.day()).trim()
val input = fetchAdventOfCodeInput(2024, 5)

println("--- Day 5: Print Queue ---")

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/day06/day06.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

package day06

import common.aocreader.fetchAdventOfCodeInput
import common.intpos2d.*
import common.day
import common.readInput

/**
* The direction that the guard is facing and moves in.
Expand Down Expand Up @@ -101,7 +100,7 @@ fun answer2(input: String): Int =
}

fun main() {
val input = readInput({}::class.day()).trim()
val input = fetchAdventOfCodeInput(2024, 6)

println("--- Day 6: Guard Gallivant ---")

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/day07/day07.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package day07

import common.aocreader.fetchAdventOfCodeInput
import common.day
import common.parsing.WhitespaceParser
import common.readInput
Expand Down Expand Up @@ -58,7 +59,7 @@ fun answer2(input: String): BigInteger =


fun main() {
val input = readInput({}::class.day()).trim()
val input = fetchAdventOfCodeInput(2024, 7)

println("--- Day 7: Bridge Repair ---")

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/day08/day08.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package day08

import common.aocreader.fetchAdventOfCodeInput
import common.day
import common.intpos2d.*
import common.readInput
Expand Down Expand Up @@ -83,7 +84,7 @@ fun answer2(input: String): Int =


fun main() {
val input = readInput({}::class.day()).trim()
val input = fetchAdventOfCodeInput(2024, 8)

println("--- Day 8: Resonant Collinearity ---")

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Resources

This directory should contain a single file named `cookie` (not included in GitHub)
that contains, on a single line, the cookie associated with your Advent of Code account.
Loading