Skip to content

Commit

Permalink
moved utils into lib, removed input from version control
Browse files Browse the repository at this point in the history
  • Loading branch information
norganos committed Dec 2, 2023
1 parent 188b1c4 commit a03a159
Show file tree
Hide file tree
Showing 48 changed files with 118 additions and 3,213 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
registries:
maven-github:
type: maven-repository
url: https://maven.pkg.github.com/versicherungskammer/shared-libs
username: dummy
password: ${{secrets.VKB_GITHUB_DEPS_TOKEN}}
updates:
- package-ecosystem: "gradle"
directory: /
schedule:
interval: "weekly"
registries:
- maven-github
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Build
on:
push:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: build & test
uses: gradle/gradle-build-action@v2
with:
arguments: test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ bin/

### Mac OS ###
.DS_Store

### personal input data ###
src/main/resources/input*.txt
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Advent of Code 2023

This repo contains solutions for [Advent of code](https://adventofcode.com) puzzles in Kotlin.

It is based on micronaut for dependency injection.

As it depends on [aoc-utils](https://github.com/norganos/aoc-utils) authentication is necessary to access GitHub's
Maven Package Repository: as of now, the gradle config in use assumes that you provide a PAT either via Env-Variables
(`GITHUB_ACTOR` and `GITHUB_TOKEN`) or in gradle.properties (under `github.registry.user` and `github.registry.key`).

input files `src/main/resources/input*.txt` are ignored in `.gitignore`.
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ group = "com.example"

val kotlinVersion=project.properties.get("kotlinVersion")
repositories {
mavenLocal()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/norganos/aoc-utils")
credentials {
username = project.findProperty("github.registry.user")?.toString() ?: System.getenv("GITHUB_ACTOR") ?: "nobody"
password = project.findProperty("github.registry.key")?.toString() ?: System.getenv("GITHUB_TOKEN") ?: "none"
}
}
}

dependencies {
Expand All @@ -25,6 +34,7 @@ dependencies {
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("de.linkel.aoc:aoc-utils:1.0.0")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
testImplementation("org.assertj:assertj-core:3.24.2")
Expand Down
49 changes: 48 additions & 1 deletion src/main/kotlin/de/linkel/aoc/Day02.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,60 @@ package de.linkel.aoc
import de.linkel.aoc.base.AbstractLinesAdventDay
import de.linkel.aoc.base.QuizPart
import jakarta.inject.Singleton
import java.lang.Exception

@Singleton
class Day02: AbstractLinesAdventDay<Int>() {
override val day = 2
override val parts = QuizPart.BOTH

override fun process(part: QuizPart, lines: Sequence<String>): Int {
return 0
val linePattern = Regex("Game ([0-9]+): (.+)")
val pickPattern = Regex("\\s*([0-9]+) (blue|red|green)\\s*")
val games = lines
.map { line ->
val lm = linePattern.matchEntire(line) ?: throw Exception("can't parse line $line")
val gameNr = lm.groupValues[1].toInt()
val picks = lm.groupValues[2]
.split(";")
.map { pick ->
pick.split(",")
.map { pickPattern.matchEntire(it) ?: throw Exception("can't parse picked cubes $it") }
.associate { it.groupValues[2] to it.groupValues[1].toInt() }
}
Game(
nr = gameNr,
picks = picks
)
}

val constraints = mapOf(
"red" to 12,
"green" to 13,
"blue" to 14
)
return if (part == QuizPart.A) games
.filter { game ->
game.picks.all { pick ->
pick.entries.all { cube ->
cube.value <= constraints[cube.key]!!
}
}
}
.sumOf { it.nr }
else games
.map { game ->
constraints.keys
.map { color ->
game.picks.maxOf { it[color] ?: 0 }
}
.fold(1) { p, c -> p * c }
}
.sum()
}

data class Game(
val nr: Int,
val picks: List<Map<String,Int>>
)
}
55 changes: 0 additions & 55 deletions src/main/kotlin/de/linkel/aoc/utils/TopList.kt

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/kotlin/de/linkel/aoc/utils/computer/Command.kt

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/kotlin/de/linkel/aoc/utils/computer/CommandLine.kt

This file was deleted.

This file was deleted.

This file was deleted.

122 changes: 0 additions & 122 deletions src/main/kotlin/de/linkel/aoc/utils/computer/PosixCommandLineParser.kt

This file was deleted.

Loading

0 comments on commit a03a159

Please sign in to comment.