├── .idea ├── fileTemplates │ ├── Advent of Code.kt.child.0.txt │ └── Advent of Code.kt └── file.template.settings.xml ├── .gitignore ├── .github ├── readme │ ├── run.png │ ├── cover.png │ └── livestream.png ├── template-cleanup │ ├── settings.gradle.kts │ └── README.md └── workflows │ └── template-cleanup.yml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle.kts ├── src ├── Utils.kt └── Day01.kt ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /.idea/fileTemplates/Advent of Code.kt.child.0.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | .kotlin/ 4 | build 5 | src/**/*.txt 6 | local.properties 7 | -------------------------------------------------------------------------------- /.github/readme/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotlin-hands-on/advent-of-code-kotlin-template/HEAD/.github/readme/run.png -------------------------------------------------------------------------------- /.github/readme/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotlin-hands-on/advent-of-code-kotlin-template/HEAD/.github/readme/cover.png -------------------------------------------------------------------------------- /.github/readme/livestream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotlin-hands-on/advent-of-code-kotlin-template/HEAD/.github/readme/livestream.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotlin-hands-on/advent-of-code-kotlin-template/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "Advent of Code Kotlin Template" 2 | 3 | dependencyResolutionManagement { 4 | repositories { 5 | mavenCentral() 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.github/template-cleanup/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "%NAME%" 2 | 3 | dependencyResolutionManagement { 4 | repositories { 5 | mavenCentral() 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.idea/fileTemplates/Advent of Code.kt: -------------------------------------------------------------------------------- 1 | #set( $Code = "bar" ) 2 | fun main() { 3 | fun part1(input: List): Int { 4 | return input.size 5 | } 6 | 7 | fun part2(input: List): Int { 8 | return input.size 9 | } 10 | 11 | check(part1(listOf("...")) == 1) 12 | 13 | val input = readInput("Day$Day") 14 | part1(input).println() 15 | part2(input).println() 16 | } 17 | -------------------------------------------------------------------------------- /src/Utils.kt: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger 2 | import java.security.MessageDigest 3 | import kotlin.io.path.Path 4 | import kotlin.io.path.readText 5 | 6 | /** 7 | * Reads lines from the given input txt file. 8 | */ 9 | fun readInput(name: String) = Path("src/$name.txt").readText().trim().lines() 10 | 11 | /** 12 | * Converts string to md5 hash. 13 | */ 14 | fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())) 15 | .toString(16) 16 | .padStart(32, '0') 17 | 18 | /** 19 | * The cleaner shorthand for printing output. 20 | */ 21 | fun Any?.println() = println(this) 22 | -------------------------------------------------------------------------------- /.idea/file.template.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |