chore: reorganize files once again
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
f3b014b06c
commit
cc6d212454
15 changed files with 17 additions and 15 deletions
|
@ -2,7 +2,9 @@ import java.io.File
|
|||
import java.math.BigInteger
|
||||
import java.security.MessageDigest
|
||||
|
||||
private fun openFile(day: Int, name: String) = File("src/day%02d".format(day), "$name.txt")
|
||||
var year: Int = 2021
|
||||
|
||||
private fun openFile(day: Int, name: String) = File("src/year%4d/day%02d".format(year, day), "$name.txt")
|
||||
|
||||
/**
|
||||
* Reads lines from the given input txt file.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package day01
|
||||
package year2021.day01
|
||||
|
||||
import readInputAsInts
|
||||
|
||||
|
@ -6,7 +6,7 @@ fun main() {
|
|||
fun part1(input: List<Int>): Int = input.windowed(2).count { it[0] < it[1] }
|
||||
fun part2(input: List<Int>): Int = input.windowed(4).count { it[0] < it[3] }
|
||||
|
||||
val testInput = readInputAsInts(1, "test_input")
|
||||
val testInput = readInputAsInts(1, "sample")
|
||||
val input = readInputAsInts(1, "input")
|
||||
|
||||
check(part1(testInput) == 7)
|
|
@ -1,4 +1,4 @@
|
|||
package day02
|
||||
package year2021.day02
|
||||
|
||||
import readInput
|
||||
|
||||
|
@ -50,7 +50,7 @@ fun part2(input: List<Instruction>): Int {
|
|||
}
|
||||
|
||||
fun main() {
|
||||
val testInput = toCommands(readInput(2, "test_input"))
|
||||
val testInput = toCommands(readInput(2, "sample"))
|
||||
val input = toCommands(readInput(2, "input"))
|
||||
|
||||
check(part1(testInput) == 150)
|
|
@ -1,4 +1,4 @@
|
|||
package day03
|
||||
package year2021.day03
|
||||
|
||||
import readInput
|
||||
|
||||
|
@ -44,7 +44,7 @@ fun part2(input: List<List<Int>>): Int {
|
|||
}
|
||||
|
||||
fun main() {
|
||||
val testInput = toBits(readInput(3, "test_input"))
|
||||
val testInput = toBits(readInput(3, "sample"))
|
||||
val input = toBits(readInput(3, "input"))
|
||||
|
||||
check(part1(testInput) == 198)
|
|
@ -1,4 +1,4 @@
|
|||
package day04
|
||||
package year2021.day04
|
||||
|
||||
import readInput
|
||||
|
||||
|
@ -75,7 +75,7 @@ fun part2(input: Bingo): Int {
|
|||
}
|
||||
|
||||
fun main() {
|
||||
val testInput = Bingo(readInput(4, "test_input"))
|
||||
val testInput = Bingo(readInput(4, "sample"))
|
||||
val input = Bingo(readInput(4, "input"))
|
||||
|
||||
check(part1(testInput) == 4512)
|
|
@ -1,4 +1,4 @@
|
|||
package day05
|
||||
package year2021.day05
|
||||
|
||||
import readInput
|
||||
|
||||
|
@ -56,7 +56,7 @@ fun findOverlaps(input: List<Vector>): Int {
|
|||
}
|
||||
|
||||
fun main() {
|
||||
val testInput = readInput(5, "test_input").map { readVector(it) }
|
||||
val testInput = readInput(5, "sample").map { readVector(it) }
|
||||
val input = readInput(5, "input").map { readVector(it) }
|
||||
|
||||
check(findOverlaps(testInput.filter { it.horizontalOrVertical }) == 5)
|
|
@ -1,4 +1,4 @@
|
|||
package day06
|
||||
package year2021.day06
|
||||
|
||||
import readInputAsCommaSeparatedInts
|
||||
|
||||
|
@ -11,7 +11,7 @@ fun howManyAfter(input: List<Int>, days: Int): Long =
|
|||
.sum()
|
||||
|
||||
fun main() {
|
||||
val testInput = readInputAsCommaSeparatedInts(6, "test_input")
|
||||
val testInput = readInputAsCommaSeparatedInts(6, "sample")
|
||||
val input = readInputAsCommaSeparatedInts(6, "input")
|
||||
|
||||
check(howManyAfter(testInput, 80) == 5934.toLong())
|
|
@ -1,4 +1,4 @@
|
|||
package day07
|
||||
package year2021.day07
|
||||
|
||||
import readInputAsCommaSeparatedInts
|
||||
import kotlin.math.absoluteValue
|
||||
|
@ -20,7 +20,7 @@ fun part2(input: List<Int>): Int = (input.average().toInt()).let { average ->
|
|||
}
|
||||
|
||||
fun main() {
|
||||
val testInput = readInputAsCommaSeparatedInts(7, "test_input").sorted()
|
||||
val testInput = readInputAsCommaSeparatedInts(7, "sample").sorted()
|
||||
val input = readInputAsCommaSeparatedInts(7, "input").sorted()
|
||||
|
||||
check(part1(testInput) == 37)
|
Loading…
Reference in a new issue