From e6a0b2e1bd9f6167b2cb98a7e6080268eccfc7d4 Mon Sep 17 00:00:00 2001 From: Bas Dado Date: Wed, 11 Dec 2019 22:43:33 +0100 Subject: [PATCH] Tried to work on Day 10 on my Chromebook but yeah... --- .vscode/launch.json | 15 ++++++++ pom.xml | 23 ++++++++++++ .../kotlin/com/basdado/adventofcode/Utils.kt | 7 +++- .../com/basdado/adventofcode/day10/Day10.kt | 33 +++++++++++++++++ src/main/resources/day/10/input.txt | 36 +++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 src/main/kotlin/com/basdado/adventofcode/day10/Day10.kt create mode 100644 src/main/resources/day/10/input.txt diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3b6793f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "kotlin", + "request": "launch", + "name": "Day 9", + "projectRoot": "${workspaceFolder}", + "mainClass": "com.basdado.adventofcode.day9.Day9Kt" + } + ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index e6147bb..f69c17b 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ official 4.12 1.8 + com.basdado.adventofcode.day9.Day9Kt @@ -67,6 +68,28 @@ + + org.apache.maven.plugins + maven-assembly-plugin + 2.6 + + + make-assembly + package + single + + + + ${main.class} + + + + jar-with-dependencies + + + + + diff --git a/src/main/kotlin/com/basdado/adventofcode/Utils.kt b/src/main/kotlin/com/basdado/adventofcode/Utils.kt index 8ed2dee..efafb5c 100644 --- a/src/main/kotlin/com/basdado/adventofcode/Utils.kt +++ b/src/main/kotlin/com/basdado/adventofcode/Utils.kt @@ -2,10 +2,15 @@ package com.basdado.adventofcode import java.nio.file.Files import java.nio.file.Paths +import java.nio.file.FileSystems import java.util.stream.Stream fun lines(resourceFile: String): Stream { - return Files.lines(Paths.get(Utils::class.java.getResource(resourceFile).toURI())) + + val uri = Paths.get(Utils::class.java.getResource(resourceFile).toURI()) + val env = mapOf(Pair("create", "true")) + FileSystems.newFileSystem(uri, env) + return Files.lines(uri) } fun line(resourceFile: String): String { diff --git a/src/main/kotlin/com/basdado/adventofcode/day10/Day10.kt b/src/main/kotlin/com/basdado/adventofcode/day10/Day10.kt new file mode 100644 index 0000000..4a53ab4 --- /dev/null +++ b/src/main/kotlin/com/basdado/adventofcode/day10/Day10.kt @@ -0,0 +1,33 @@ +const val DAY10_INPUT_PATH = "/day/10/input.txt" + +import com.basdado.adventofcode.lines; +import java.util.stream.Collectors; + +fun main() { + + Day10.puzzle1() + // Day10.puzzle2() +} + +object Day10 { + + fun puzzle1() { + println("Hello world!") + val rawData = lines(DAY10_INPUT_PATH).collect(Collectors.toList()) + val asteroids = + (0..rawData.size).forEach { y -> + (0..rawData[y].length).forEach { x -> + if (rawData[y][x] == '#') { + + } + } + } + + } + + data class Vector2i(val x: Int, val y: Int) { + fun normalize(): Vector2i { + + } + } +} \ No newline at end of file diff --git a/src/main/resources/day/10/input.txt b/src/main/resources/day/10/input.txt new file mode 100644 index 0000000..c942777 --- /dev/null +++ b/src/main/resources/day/10/input.txt @@ -0,0 +1,36 @@ +....#...####.#.#...........#........ +#####..#.#.#......#####...#.#...#... +##.##..#.#.#.....#.....##.#.#..#.... +...#..#...#.##........#..#.......#.# +#...##...###...###..#...#.....#..... +##.......#.....#.........#.#....#.#. +..#...#.##.##.....#....##..#......#. +..###..##..#..#...#......##...#....# +##..##.....#...#.#...#......#.#.#..# +...###....#..#.#......#...#.......#. +#....#...##.......#..#.......#..#... +#...........#.....#.....#.#...#.##.# +###..#....####..#.###...#....#..#... +##....#.#..#.#......##.......#....#. +..#.#....#.#.#..#...#.##.##..#...... +...#.....#......#.#.#.##.....#..###. +..#.#.###.......#..#.#....##.....#.. +.#.#.#...#..#.#..##.#..........#...# +.....#.#.#...#..#..#...###.#...#.#.. +#..#..#.....#.##..##...##.#.....#... +....##....#.##...#..........#.##.... +...#....###.#...##........##.##..##. +#..#....#......#......###........... +##...#..#.##.##..##....#..#..##..#.# +.#....#..##.....#.#............##... +.###.........#....#.##.#..#.#..#.#.. +#...#..#...#.#.#.....#....#......### +#...........##.#....#.##......#.#..# +....#...#..#...#.####...#.#..#.##... +......####.....#..#....#....#....#.# +.##.#..###..####...#.......#.#....#. +#.###....#....#..........#.....###.# +...#......#....##...##..#..#...###.. +..#...###.###.........#.#..#.#..#... +.#.#.............#.#....#........... +..#...#.###...##....##.#.#.#....#.#. \ No newline at end of file