Skip to content

Commit

Permalink
feat: move code to top level project
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixDombek committed Dec 5, 2023
1 parent 6e60f0b commit 888c3c8
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 219 deletions.
16 changes: 8 additions & 8 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# AdventOfCode
AdventOfCode puzzle solutions
2023: [AdventOfCode2023.kt](app/src/test/kotlin/com/example/adventofcode/AdventOfCode2023.kt)
# AdventOfCode
AdventOfCode puzzle solutions
2023: [AdventOfCode2023.kt](src/test/kotlin/com/example/adventofcode/AdventOfCode2023.kt)
1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

143 changes: 0 additions & 143 deletions app/bin/test/com/example/adventofcode/AdventOfCode2023.kt

This file was deleted.

24 changes: 0 additions & 24 deletions app/build.gradle.kts

This file was deleted.

36 changes: 0 additions & 36 deletions app/src/test/kotlin/com/example/adventofcode/AdventOfCode2022.kt

This file was deleted.

17 changes: 17 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,21 @@ tasks {
wrapper {
gradleVersion = "8.5"
}
test {
useJUnit()
testLogging {
events("passed", "skipped", "failed")
}
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
}
}
}

dependencies {
testImplementation(kotlin("test"))
testImplementation("junit:junit:4.13.2")
testImplementation("com.google.guava:guava:31.1-jre")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.Scanner
import kotlin.math.max
import kotlin.math.min
import kotlin.math.pow
import kotlin.system.measureTimeMillis


fun getFile(day: String): File {
Expand Down Expand Up @@ -148,8 +149,7 @@ class AdventOfCode2023 {
@Test
fun day5() {
val input = getString("5").split("\n\n")
val seedLine = input[0].split(" ").drop(1)
val seeds = seedLine.map { it.toLong() }
val seeds = input[0].split(" ").drop(1).map { it.toLong() }
val maps = input.drop(1).map { mapBlock ->
mapBlock.split("\n").drop(1).map { mapLine ->
val (to, from, len) = mapLine.split(" ").map { it.toLong() }
Expand All @@ -168,8 +168,13 @@ class AdventOfCode2023 {
println("Day 5.1: $loc")
assertEquals(600279879, loc)

val loc2 = seedLine.chunked(2) { (s, l) ->
mapSeeds((s.toLong()..<s.toLong()+l.toLong()).asSequence())
val loc2 = seeds.chunked(2) { (seed, len) -> // takes 12 mins, needs optimization
var m: Long
val millis = measureTimeMillis {
m = mapSeeds((seed..<seed + len).asSequence())
}
println("Day 5.2: $seed, len=$len took ${millis / 1000.0}s")
m
}.min()
println("Day 5.2: $loc2")
assertEquals(20191102, loc2)
Expand Down

0 comments on commit 888c3c8

Please sign in to comment.