Skip to content

Commit 2998476

Browse files
authored
Merge pull request #12 from sraaphorst/I02
Switched to reading input directly from AOC as per rules.
2 parents 8b44b92 + 27342f5 commit 2998476

File tree

11 files changed

+26
-23
lines changed

11 files changed

+26
-23
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ build/
55
!**/src/test/**/build/
66

77
### Advent of Code Input ###
8-
src/main/resources
98
src/main/resources/cookie
9+
src/main/resources/day*.txt
1010

1111
### IntelliJ IDEA ###
1212
.idea

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

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

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

7-
**Last updated:** 2024-12-05.
8+
**Current status:** Day 8 complete.
9+
10+
**Last updated:** 2024-12-08.

src/main/kotlin/day01/day01.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
package day01
55

6-
import common.day
6+
import common.aocreader.fetchAdventOfCodeInput
77
import common.parsing.parseColumns
8-
import common.readInput
98
import common.collectionops.toFrequencyMap
109
import kotlin.math.abs
1110

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

2726
fun main() {
28-
val input = readInput({}::class.day())
27+
val input = fetchAdventOfCodeInput(2024, 1)
2928

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

src/main/kotlin/day02/day02.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
package day02
55

6+
import common.aocreader.fetchAdventOfCodeInput
67
import common.collectionops.allListDrops
7-
import common.day
88
import common.parsing.parseGrid
9-
import common.readInput
109

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

3231
fun main() {
33-
val input = readInput({}::class.day())
32+
val input = fetchAdventOfCodeInput(2024, 2)
3433

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

src/main/kotlin/day03/day03.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
package day03
55

6-
import common.day
7-
import common.readInput
6+
import common.aocreader.fetchAdventOfCodeInput
87

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

3332
fun main() {
34-
val input = readInput({}::class.day())
33+
val input = fetchAdventOfCodeInput(2024, 3)
3534

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

src/main/kotlin/day04/day04.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
package day04
55

6+
import common.aocreader.fetchAdventOfCodeInput
67
import common.countSubstrings
7-
import common.day
88
import common.collectionops.*
9-
import common.readInput
109

1110
private const val XMAS = "XMAS"
1211

@@ -60,7 +59,7 @@ fun answer2(input: String): Int =
6059
countXXmases(input.lines())
6160

6261
fun main() {
63-
val input = readInput({}::class.day())
62+
val input = fetchAdventOfCodeInput(2024, 4)
6463

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

src/main/kotlin/day05/day05.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
package day05
55

6-
import common.day
6+
import common.aocreader.fetchAdventOfCodeInput
77
import common.collectionops.middle
8-
import common.readInput
98

109
private typealias OrderingRules = Map<Int, Set<Int>>
1110
private typealias Updates = List<Int>
@@ -96,7 +95,7 @@ fun answer2(input: String): Int =
9695
}
9796

9897
fun main() {
99-
val input = readInput({}::class.day()).trim()
98+
val input = fetchAdventOfCodeInput(2024, 5)
10099

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

src/main/kotlin/day06/day06.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
package day06
88

9+
import common.aocreader.fetchAdventOfCodeInput
910
import common.intpos2d.*
10-
import common.day
11-
import common.readInput
1211

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

103102
fun main() {
104-
val input = readInput({}::class.day()).trim()
103+
val input = fetchAdventOfCodeInput(2024, 6)
105104

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

src/main/kotlin/day07/day07.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package day07
55

6+
import common.aocreader.fetchAdventOfCodeInput
67
import common.day
78
import common.parsing.WhitespaceParser
89
import common.readInput
@@ -58,7 +59,7 @@ fun answer2(input: String): BigInteger =
5859

5960

6061
fun main() {
61-
val input = readInput({}::class.day()).trim()
62+
val input = fetchAdventOfCodeInput(2024, 7)
6263

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

src/main/kotlin/day08/day08.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package day08
55

6+
import common.aocreader.fetchAdventOfCodeInput
67
import common.day
78
import common.intpos2d.*
89
import common.readInput
@@ -83,7 +84,7 @@ fun answer2(input: String): Int =
8384

8485

8586
fun main() {
86-
val input = readInput({}::class.day()).trim()
87+
val input = fetchAdventOfCodeInput(2024, 8)
8788

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

src/main/resources/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Resources
2+
3+
This directory should contain a single file named `cookie` (not included in GitHub)
4+
that contains, on a single line, the cookie associated with your Advent of Code account.

0 commit comments

Comments
 (0)