From a29c0008d8a485ec1174f127c15e23c7754d7770 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 2 Dec 2024 16:06:24 +0100 Subject: [PATCH] chore(pre-commit): autoupdate Signed-off-by: Matej Focko --- .pre-commit-config.yaml | 6 +++--- src/Utils.kt | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd8fd51..8793b73 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: check-yaml - id: check-added-large-files repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 - hooks: - args: @@ -16,7 +16,7 @@ repos: exclude: ^\.idea/fileTemplates/.*\.kt$ id: pretty-format-kotlin repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.12.0 + rev: v2.14.0 - hooks: - id: commitizen @@ -24,4 +24,4 @@ repos: stages: - push repo: https://github.com/commitizen-tools/commitizen - rev: v3.15.0 + rev: v4.0.0 diff --git a/src/Utils.kt b/src/Utils.kt index 0ae3d04..304afe4 100644 --- a/src/Utils.kt +++ b/src/Utils.kt @@ -75,13 +75,14 @@ fun readInputAsCommaSeparatedInts( fun readGraph( day: Int, name: String, -) = readInput(day, name).fold(mapOf>()) { currentGraph, edge -> - val (fromVertex, toVertex) = edge.split("-") - val fromNeighbours = currentGraph.getOrDefault(fromVertex, emptySet()) + toVertex - val toNeighbours = currentGraph.getOrDefault(toVertex, emptySet()) + fromVertex +) = readInput(day, name) + .fold(mapOf>()) { currentGraph, edge -> + val (fromVertex, toVertex) = edge.split("-") + val fromNeighbours = currentGraph.getOrDefault(fromVertex, emptySet()) + toVertex + val toNeighbours = currentGraph.getOrDefault(toVertex, emptySet()) + fromVertex - currentGraph + mapOf(fromVertex to fromNeighbours, toVertex to toNeighbours) -}.toMap() + currentGraph + mapOf(fromVertex to fromNeighbours, toVertex to toNeighbours) + }.toMap() /** * Constructs product of two sequences.