Tried to work on Day 10 on my Chromebook but yeah...

This commit is contained in:
Bas Dado
2019-12-11 22:43:33 +01:00
parent f422159eb1
commit e6a0b2e1bd
5 changed files with 113 additions and 1 deletions

15
.vscode/launch.json vendored Normal file
View File

@@ -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"
}
]
}

23
pom.xml
View File

@@ -16,6 +16,7 @@
<kotlin.code.style>official</kotlin.code.style> <kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget> <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<main.class>com.basdado.adventofcode.day9.Day9Kt</main.class>
</properties> </properties>
<dependencies> <dependencies>
@@ -67,6 +68,28 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals> <goal>single</goal> </goals>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -2,10 +2,15 @@ package com.basdado.adventofcode
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import java.nio.file.FileSystems
import java.util.stream.Stream import java.util.stream.Stream
fun lines(resourceFile: String): Stream<String> { fun lines(resourceFile: String): Stream<String> {
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 { fun line(resourceFile: String): String {

View File

@@ -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 {
}
}
}

View File

@@ -0,0 +1,36 @@
....#...####.#.#...........#........
#####..#.#.#......#####...#.#...#...
##.##..#.#.#.....#.....##.#.#..#....
...#..#...#.##........#..#.......#.#
#...##...###...###..#...#.....#.....
##.......#.....#.........#.#....#.#.
..#...#.##.##.....#....##..#......#.
..###..##..#..#...#......##...#....#
##..##.....#...#.#...#......#.#.#..#
...###....#..#.#......#...#.......#.
#....#...##.......#..#.......#..#...
#...........#.....#.....#.#...#.##.#
###..#....####..#.###...#....#..#...
##....#.#..#.#......##.......#....#.
..#.#....#.#.#..#...#.##.##..#......
...#.....#......#.#.#.##.....#..###.
..#.#.###.......#..#.#....##.....#..
.#.#.#...#..#.#..##.#..........#...#
.....#.#.#...#..#..#...###.#...#.#..
#..#..#.....#.##..##...##.#.....#...
....##....#.##...#..........#.##....
...#....###.#...##........##.##..##.
#..#....#......#......###...........
##...#..#.##.##..##....#..#..##..#.#
.#....#..##.....#.#............##...
.###.........#....#.##.#..#.#..#.#..
#...#..#...#.#.#.....#....#......###
#...........##.#....#.##......#.#..#
....#...#..#...#.####...#.#..#.##...
......####.....#..#....#....#....#.#
.##.#..###..####...#.......#.#....#.
#.###....#....#..........#.....###.#
...#......#....##...##..#..#...###..
..#...###.###.........#.#..#.#..#...
.#.#.............#.#....#...........
..#...#.###...##....##.#.#.#....#.#.