added year of 2023
This commit is contained in:
29
2023/05/Kotlin/.gitignore
vendored
Normal file
29
2023/05/Kotlin/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
8
2023/05/Kotlin/.idea/.gitignore
generated
vendored
Normal file
8
2023/05/Kotlin/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
6
2023/05/Kotlin/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
2023/05/Kotlin/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ReplaceUntilWithRangeUntil" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
6
2023/05/Kotlin/.idea/jpa-buddy.xml
generated
Normal file
6
2023/05/Kotlin/.idea/jpa-buddy.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig">
|
||||
<option name="renamerInitialized" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
10
2023/05/Kotlin/.idea/kotlinc.xml
generated
Normal file
10
2023/05/Kotlin/.idea/kotlinc.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
<component name="KotlinCommonCompilerArguments">
|
||||
<option name="apiVersion" value="1.9" />
|
||||
<option name="languageVersion" value="1.9" />
|
||||
</component>
|
||||
</project>
|
||||
26
2023/05/Kotlin/.idea/libraries/KotlinJavaRuntime.xml
generated
Normal file
26
2023/05/Kotlin/.idea/libraries/KotlinJavaRuntime.xml
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime" type="repository">
|
||||
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.0/kotlin-stdlib-jdk8-1.9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.0/kotlin-stdlib-1.9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.0/kotlin-stdlib-common-1.9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.0/kotlin-stdlib-jdk7-1.9.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.0/kotlin-stdlib-jdk8-1.9.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.0/kotlin-stdlib-1.9.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.0/kotlin-stdlib-common-1.9.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.0/kotlin-stdlib-jdk7-1.9.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.0/kotlin-stdlib-jdk8-1.9.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.0/kotlin-stdlib-1.9.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.0/kotlin-stdlib-common-1.9.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.0/kotlin-stdlib-jdk7-1.9.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
9
2023/05/Kotlin/.idea/misc.xml
generated
Normal file
9
2023/05/Kotlin/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
</project>
|
||||
8
2023/05/Kotlin/.idea/modules.xml
generated
Normal file
8
2023/05/Kotlin/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/advent_5.iml" filepath="$PROJECT_DIR$/advent_5.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
33
2023/05/Kotlin/input.txt
Normal file
33
2023/05/Kotlin/input.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
||||
15
2023/05/Kotlin/kotlin.iml
Normal file
15
2023/05/Kotlin/kotlin.iml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
76
2023/05/Kotlin/src/Main.kt
Normal file
76
2023/05/Kotlin/src/Main.kt
Normal file
@@ -0,0 +1,76 @@
|
||||
import java.io.File
|
||||
|
||||
fun main() {
|
||||
var input = File("input.txt").readLines()
|
||||
val seeds = input[0].split(":")[1].trim().split(" ")
|
||||
var formattedInput = ""
|
||||
val soilMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val fertilizerMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val waterMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val lightMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val temperatureMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val humidityMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
val locationMap: HashMap<IntRange, IntRange> = HashMap()
|
||||
input = input.drop(2)
|
||||
input.forEach { line -> formattedInput += line.ifBlank { "#" }.plus(" ") }
|
||||
val splitValue = formattedInput.split("#")
|
||||
splitValue[0].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
soilMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[1].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
fertilizerMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[2].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
waterMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[3].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
lightMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[4].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
temperatureMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[5].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
humidityMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
splitValue[6].split(": ").drop(1).forEach {
|
||||
val numbers = it.trim().split(" ")
|
||||
for (i in numbers.indices step 3) {
|
||||
locationMap[numbers[i + 1].toInt()..<numbers[i + 1].toInt() + numbers[i + 2].toInt()] =
|
||||
numbers[i].toInt()..<numbers[i].toInt() + numbers[i + 2].toInt()
|
||||
}
|
||||
}
|
||||
|
||||
var lowest = Int.MAX_VALUE
|
||||
seeds.forEach { seed ->
|
||||
val soil = 0
|
||||
soilMap.keys.forEach {range ->
|
||||
if (seed.toInt() in range){
|
||||
soil =
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user