path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/Day08.kt | ZiomaleQ | 573,349,910 | false | {"Kotlin": 49609} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0
val trees = input.map { line ->
line.map { c ->
Tree(c.digitToInt())
}
}
for ((rowIndex, rowOfTrees) in trees.withIndex()) {
if (rowIndex == 0 || rowIndex == trees.si... | 0 | Kotlin | 0 | 0 | b8811a6a9c03e80224e4655013879ac8a90e69b5 | 2,778 | aoc-2022 | Apache License 2.0 |
src/Day08.kt | zirman | 572,627,598 | false | {"Kotlin": 89030} | fun main() {
fun part1(input: List<String>): Int {
val trees = input.map { row -> row.map { it.digitToInt() } }
val visible = trees.map { it.indices.map { false }.toMutableList() }
for (c in trees.first().indices) {
var h = -1
for (r in trees.indices) {
... | 0 | Kotlin | 0 | 1 | 2ec1c664f6d6c6e3da2641ff5769faa368fafa0f | 3,317 | aoc2022 | Apache License 2.0 |
src/year2023/day23/Day23.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2023.day23
import check
import readInput
fun main() {
val testInput = readInput("2023", "Day23_test")
check(part1(testInput), 94)
check(part2(testInput), 154)
val input = readInput("2023", "Day23")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 3,011 | AdventOfCode | Apache License 2.0 |
src/Day13.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | fun main() {
val testInput = readInput("Day13_test")
check(part1(testInput) == 13)
check(part2(testInput) == 140)
val input = readInput("Day13")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
return input.partitionBy { it.isEmpty() }
.as... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 2,389 | aoc-22 | Apache License 2.0 |
src/year2021/day08/Day08.kt | fadi426 | 433,496,346 | false | {"Kotlin": 44622} | package year2021.day01.day08
import util.assertTrue
import util.read2021DayInput
fun main() {
fun task01(input: List<String>): Int {
val formattedInput = input.map { it.substringAfter(" | ") }.map { it.split(" ") }
return listOf(2, 4, 3, 7).let { uniqueSegments ->
formattedInput.sumOf... | 0 | Kotlin | 0 | 0 | acf8b6db03edd5ff72ee8cbde0372113824833b6 | 2,853 | advent-of-code-kotlin-template | Apache License 2.0 |
src/Day14.kt | laricchia | 434,141,174 | false | {"Kotlin": 38143} | fun firstPart14(list : List<Pair<String, String>>, start : String) {
var newSeq = start
val steps = 10
for (i in 0 until steps) {
var windows = newSeq.windowed(2).map { StringBuilder(it) }
list.map { insertion ->
windows = windows.map {
if (it.toString() == inser... | 0 | Kotlin | 0 | 0 | 7041d15fafa7256628df5c52fea2a137bdc60727 | 2,589 | Advent_of_Code_2021_Kotlin | Apache License 2.0 |
src/day24/d24_2.kt | svorcmar | 720,683,913 | false | {"Kotlin": 49110} | fun main() {
val input = ""
val list = input.lines().map { it.toInt() }
val groupSize = list.sum() / 4
val firstGroup = solve(list, groupSize)
// order by quantum entanglement and find smallest one for which
// the rest of packages can be divided in three groups of the same weight
val candidates = firstGr... | 0 | Kotlin | 0 | 0 | cb097b59295b2ec76cc0845ee6674f1683c3c91f | 2,361 | aoc2015 | MIT License |
advent-of-code-2022/src/Day08.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | typealias Forest = List<List<Int>>
fun main() {
val testInput = readInput("Day08_test")
val input = readInput("Day08")
"Part 1" {
part1(testInput) shouldBe 21
answer(part1(input))
}
"Part 2" {
part2(testInput) shouldBe 8
answer(part2(input))
}
}
private fun pa... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 2,607 | advent-of-code | Apache License 2.0 |
aoc21/day_08/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
fun segmentsByLen(len: Int): Set<Char> = when (len) {
2 -> setOf('c', 'f')
3 -> setOf('a', 'c', 'f')
4 -> setOf('b', 'c', 'd', 'f')
else -> ('a'..'g').toSet()
}
fun segmentToDigit(segment: Set<Char>): Char? = when (segment) {
setOf('a', 'b', 'c', 'e', 'f', 'g') -> '0'
setOf... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 2,654 | advent-of-code | MIT License |
src/main/kotlin/Day16.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | import kotlin.math.max
fun main() {
fun floydWarshall(
shortestPaths: Map<String, MutableMap<String, Int>>,
valves: Map<String, Valve>
): Map<String, Map<String, Int>> {
for (k in shortestPaths.keys) {
for (i in shortestPaths.keys) {
for (j in shortestPaths.... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 3,082 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2021/day22/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2021.day22
import com.kingsleyadio.adventofcode.util.readInput
fun part1(commands: List<Command>): Int {
val bound = -50..50
val ons = hashSetOf<P3>()
for ((action, cuboid) in commands) {
if (cuboid.x !in bound || cuboid.y !in bound || cuboid.z !in bound) con... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 2,830 | adventofcode | Apache License 2.0 |
src/main/kotlin/Day12.kt | Ostkontentitan | 434,500,914 | false | {"Kotlin": 73563} | fun puzzleDayTwelvePartOne() {
val inputs = readInput(12)
val connections = inputsToConnections(inputs)
val pathes = findUniquePaths(Cave.Start, connections, mapOf(Cave.Start to 1))
println("Number of pathes $pathes")
}
fun puzzleDayTwelvePartTwo() {
val inputs = readInput(12)
val connections ... | 0 | Kotlin | 0 | 0 | e0e5022238747e4b934cac0f6235b92831ca8ac7 | 2,911 | advent-of-kotlin-2021 | Apache License 2.0 |
src/Day13.kt | bigtlb | 573,081,626 | false | {"Kotlin": 38940} | fun main() {
class AdventList : Comparable<AdventList> {
fun terms(input: String): List<String> {
var parenLevel = 0
var start = 0
var next = 0
val termList = mutableListOf<String>()
while (next <= input.length) {
when {
... | 0 | Kotlin | 0 | 0 | d8f76d3c75a30ae00c563c997ed2fb54827ea94a | 3,160 | aoc-2022-demo | Apache License 2.0 |
y2023/src/main/kotlin/adventofcode/y2023/Day25.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
fun main() {
Day25.solve()
}
object Day25 : AdventSolution(2023, 25, "Snowverload") {
override fun solvePartOne(input: String): Any {
val weightedGraph: WeightedGraph = parse(input)
.mapValues { Desc(1, it.value.associateWi... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,750 | advent-of-code | MIT License |
src/Day05/Day05.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import kotlin.math.min
import kotlin.math.max
fun main() {
fun prepare(input: List<String>): List<Pair<Pair<Int, Int>, Pair<Int, Int>>> {
return input.map {
val split = it.split("->").map { x -> x.split(',').map { e -> e.trim() } }
Pair(Pair(split[0][0].toInt(), split[0][1].toInt())... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 2,539 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/day18/Day18.kt | Avataw | 572,709,044 | false | {"Kotlin": 99761} | package day18
fun solveA(input: List<String>): Int {
val cubes = input.map(String::toCube).toSet()
return cubes.size * 6 - cubes.sumOf { it.touches(cubes) }
}
fun solveB(input: List<String>): Int {
val cubes = input.map(String::toCube).toSet()
val min = minOf(cubes.minOf { it.x }, cubes.minOf { it.y... | 0 | Kotlin | 2 | 0 | 769c4bf06ee5b9ad3220e92067d617f07519d2b7 | 1,900 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | SebastianHelzer | 573,026,636 | false | {"Kotlin": 27111} |
fun main() {
fun getTreeMap(input: List<String>): Map<Pair<Int, Int>, Int> {
val heights = input.map { line -> line.toCharArray().map { it.digitToInt() } }
return heights.flatMapIndexed { row, line ->
line.mapIndexed { col, value ->
(col to row) to value
}
... | 0 | Kotlin | 0 | 0 | e48757626eb2fb5286fa1c59960acd4582432700 | 2,457 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | hrach | 572,585,537 | false | {"Kotlin": 32838} | fun main() {
data class Map(
val levels: List<List<Int>>,
val start: Pair<Int, Int>,
val end: Pair<Int, Int>,
) {
fun getSteps(current: Pair<Int, Int>): List<Pair<Int, Int>> {
return listOf(
current.first - 1 to current.second,
current.... | 0 | Kotlin | 0 | 1 | 40b341a527060c23ff44ebfe9a7e5443f76eadf3 | 2,651 | aoc-2022 | Apache License 2.0 |
src/day-14/Day14.kt | skbkontur | 433,022,968 | false | null | fun main() {
fun parseInput(input: List<String>): Pair<String, Map<String, String>> {
val source = input.first()
val replacements = input
.filter { it.contains("->") }
.map { it.split(" -> ") }
.associate { (a, b) -> a to b }
return Pair(source, replacemen... | 2 | 1C Enterprise | 18 | 13 | e5a791492f8c466404eb300708ec09b441872865 | 2,755 | AoC2021 | MIT License |
src/Day08.kt | bin-wang | 572,801,360 | false | {"Kotlin": 19395} | import kotlin.math.min
object Day08 {
data class Tree(val x: Int, val y: Int)
class Forest(private val heights: List<List<Int>>) {
private val h = heights.size
private val w = heights.first().size
private fun leftward(tree: Tree) = ((tree.y - 1) downTo 0).map { Tree(tree.x, it) }
... | 0 | Kotlin | 0 | 0 | dca2c4915594a4b4ca2791843b53b71fd068fe28 | 2,457 | aoc22-kt | Apache License 2.0 |
src/day15/Day15.kt | bartoszm | 572,719,007 | false | {"Kotlin": 39186} | package day15
import readInput
import kotlin.math.absoluteValue
typealias Point = Pair<Long, Long>
fun main() {
println(solve1(parse(readInput("day15/test")), 10))
println(solve1(parse(readInput("day15/input")), 2000000))
println(solve2(parse(readInput("day15/test")), 20))
println(solve2(parse(read... | 0 | Kotlin | 0 | 0 | f1ac6838de23beb71a5636976d6c157a5be344ac | 2,964 | aoc-2022 | Apache License 2.0 |
src/Day08.kt | cypressious | 572,916,585 | false | {"Kotlin": 40281} | fun main() {
val easyDigits = mapOf(
2 to 1,
4 to 4,
3 to 7,
7 to 8,
)
fun part1(input: List<String>): Int {
val characters = input.flatMap { it.split(" | ")[1].split(" ") }
return characters.count { it.length in easyDigits }
}
class Mapping {
... | 0 | Kotlin | 0 | 0 | 169fb9307a34b56c39578e3ee2cca038802bc046 | 3,232 | AdventOfCode2021 | Apache License 2.0 |
src/day15/d15_2.kt | svorcmar | 720,683,913 | false | {"Kotlin": 49110} | fun main() {
val input = ""
val ingredients = input.lines().map { parseIngredient(it) }.associateBy { it.name }
println(forAllCombinations(ingredients, 100) {
it.map { (k, v) -> listOf(
ingredients[k]!!.capacity * v,
ingredients[k]!!.durability * v,
ingredients[k]!!.flavor * v,
ingred... | 0 | Kotlin | 0 | 0 | cb097b59295b2ec76cc0845ee6674f1683c3c91f | 2,067 | aoc2015 | MIT License |
src/main/kotlin/day9/Day9.kt | alxgarcia | 435,549,527 | false | {"Kotlin": 91398} | package day9
import java.io.File
fun parseMap(rows: List<String>): Array<IntArray> =
rows.map { row -> row.trim().map { it - '0' }.toIntArray() }.toTypedArray()
fun expandAdjacent(row: Int, column: Int, map: Array<IntArray>): List<Pair<Int, Int>> =
listOf(0 to -1, -1 to 0, 0 to 1, 1 to 0)
.map { (r, c) -> (... | 0 | Kotlin | 0 | 0 | d6b10093dc6f4a5fc21254f42146af04709f6e30 | 2,140 | advent-of-code-2021 | MIT License |
src/Day12.kt | sebastian-heeschen | 572,932,813 | false | {"Kotlin": 17461} | fun main() {
fun parse(input: List<String>): HeightMap {
val grid = input.map {
it.toCharArray()
}
fun find(characterToFind: Char): Pair<Int, Int> {
val y = grid.indexOfFirst { line -> line.contains(characterToFind) }
val x = grid.map { line -> line.inde... | 0 | Kotlin | 0 | 0 | 4432581c8d9c27852ac217921896d19781f98947 | 3,574 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | razvn | 573,166,955 | false | {"Kotlin": 27208} | private data class Tree(val x: Int, val y: Int, val value: Int)
fun main() {
val day = "Day08"
fun part1(input: List<String>): Int {
val trees = input.mapIndexed { lIdx, line ->
line.mapIndexed { cIdx, col ->
Tree(lIdx, cIdx, col.digitToInt())
}
}.flatte... | 0 | Kotlin | 0 | 0 | 73d1117b49111e5044273767a120142b5797a67b | 3,622 | aoc-2022-kotlin | Apache License 2.0 |
src/Day11.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | private open class Solution11(input: List<String>) {
val monkeys = input.chunked(7).map { Monkey(it) }
fun solve(times: Int): Long {
repeat(times) { doRound() }
return monkeys.map { it.counter }.sorted().takeLast(2).reduce(Long::times)
}
private fun doRound() {
monkeys.forEach... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 2,292 | aoc-2022 | Apache License 2.0 |
src/Day11.kt | iProdigy | 572,297,795 | false | {"Kotlin": 33616} | fun main() {
fun part1(input: List<String>) = run(input, 20, true)
fun part2(input: List<String>) = run(input, 10_000, false)
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day11_test")
check(part1(testInput) == 10605L)
check(part2(testInput) == ... | 0 | Kotlin | 0 | 1 | 784fc926735fc01f4cf18d2ec105956c50a0d663 | 2,442 | advent-of-code-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/year2023/Day19.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
fun main() {
val input = readInput2("Day19")
Day19.part1(input).println()
Day19.part2(input).println()
}
object Day19 {
fun part1(input: String): Int {
val chunks = input.split(DOUBLE_NEW_LINE_REGEX)
val workflows = chunks[0]
.split(NEW_LINE_REGEX)
... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 5,091 | advent-of-code | MIT License |
y2023/src/main/kotlin/adventofcode/y2023/Day12.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
fun main() {
Day12.solve()
}
object Day12 : AdventSolution(2023, 12, "Hot Springs") {
override fun solvePartOne(input: String) = parse(input).sumOf(ConditionRecord::countMatchingConfigurations)
override fun solvePartTwo(input: String) = p... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 3,171 | advent-of-code | MIT License |
src/Day13.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} | import kotlin.math.min
private fun compareSeq(a: List<String>, b: List<String>): Int {
for(i in 0 until min(a.size,b.size)) {
val res = compare(a[i], b[i])
if (res!=0) return res
}
return a.size - b.size
}
private fun String.indexOfClosedPair(from: Int): Int {
var level = 1
for( i ... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 2,048 | aoc2022 | Apache License 2.0 |
src/year2022/12/Day12.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`12`
import kotlin.math.abs
import readInput
data class Square(
val i: Int,
val j: Int,
val height: Int,
)
data class SquareRecord(
val currentNode: Square,
var shortestDistance: Int,
var previousNode: Square?
)
fun calculateDistances(start: Square, grid: List<List<Square>>)... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 4,270 | KotlinAdventOfCode | Apache License 2.0 |
src/Day08.kt | xabgesagtx | 572,139,500 | false | {"Kotlin": 23192} | fun main() {
fun part1(input: List<String>): Int {
val treeValues = input.map { line -> line.toList().map { it.digitToInt() } }
val lastXIndex = treeValues[0].lastIndex
val lastYIndex = treeValues.lastIndex
return treeValues.indices.flatMap { y ->
treeValues[y].indices... | 0 | Kotlin | 0 | 0 | 976d56bd723a7fc712074066949e03a770219b10 | 3,266 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | dmstocking | 575,012,721 | false | {"Kotlin": 40350} | fun main() {
fun part1(input: List<String>): Int {
val heights = input
.map { line -> line.map { it.digitToInt() } }
val height = heights.size
val width = heights.first().size
return heights
.mapIndexed { y, line ->
line.mapIndexed { x, h ->
... | 0 | Kotlin | 0 | 0 | e49d9247340037e4e70f55b0c201b3a39edd0a0f | 2,193 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day9.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 9: Smoke Basin
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.readFileAsString
fun main() {
println(" ** Day 9: Smoke Basin ** \n")
val heightMap = readFileAsString("/Day9HeightMap.txt")
val riskLevel = calculateRiskLevelOfHeightMap(heightMap)
println("The combined ris... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 3,010 | AdventOfCode2021 | MIT License |
kotlin/src/Day14.kt | ekureina | 433,709,362 | false | {"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386} | fun main() {
fun part1(input: List<String>): Int {
val template = input.first()
val rules = input.drop(2).associate { line ->
val (pair, insert) = line.split(" -> ")
(pair[0] to pair[1]) to insert[0]
}
val finalString = (0 until 10).fold(template) { polymer, ... | 0 | Kotlin | 0 | 1 | 391d0017ba9c2494092d27d22d5fd9f73d0c8ded | 2,342 | aoc-2021 | MIT License |
src/year2023/Day2.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2023
import readLines
fun main() {
val input = readLines("2023", "day2")
val testInput = readLines("2023", "day2_test")
check(part1(testInput) == 8)
println("Part 1:" + part1(input))
check(part2(testInput) == 2286)
println("Part 2:" + part2(input))
}
private fun parseInput(input... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 2,026 | advent_of_code | MIT License |
src/Day08.kt | proggler23 | 573,129,757 | false | {"Kotlin": 27990} | fun main() {
fun part1(input: List<String>) = input.parse8().visibleTreeCount
fun part2(input: List<String>) = input.parse8().bestScenicView
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day08_test")
check(part1(testInput) == 21)
check(part2(tes... | 0 | Kotlin | 0 | 0 | 584fa4d73f8589bc17ef56c8e1864d64a23483c8 | 1,750 | advent-of-code-2022 | Apache License 2.0 |
aoc21/day_22/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
import kotlin.math.max
import kotlin.math.min
data class Range(val min: Int, val max: Int) {
fun hasIntersection(range: Range): Boolean = range.min <= max && range.max >= min
fun intersection(range: Range): Range = Range(max(min, range.min), min(max, range.max))
fun minus(range: Range... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 2,539 | advent-of-code | MIT License |
src/Day16.kt | jbotuck | 573,028,687 | false | {"Kotlin": 42401} | import kotlin.math.max
import kotlin.math.min
fun main() {
val valves = readInput("Day16")
.map { Valve.of(it) }
.associateBy { it.name }
val start = valves["AA"]!!
val valvesWithNeighbors = valves.values
.filter { it.name == "AA" || it.flowRate > 0 }
.sortedBy { it.name }
... | 0 | Kotlin | 0 | 0 | d5adefbcc04f37950143f384ff0efcd0bbb0d051 | 4,812 | aoc2022 | Apache License 2.0 |
src/Day12.kt | cisimon7 | 573,872,773 | false | {"Kotlin": 41406} | fun main() {
fun shortestPath(
map: List<List<Elevation>>,
startElevation: Elevation,
endElevation: Elevation
): List<List<Elevation>> {
var paths =
listOf(listOf(map.flatten().firstOrNull { it == endElevation } ?: error("Can't find highest point")))
while (pa... | 0 | Kotlin | 0 | 0 | 29f9cb46955c0f371908996cc729742dc0387017 | 6,956 | aoc-2022 | Apache License 2.0 |
src/Day15.kt | AxelUser | 572,845,434 | false | {"Kotlin": 29744} | import kotlin.math.abs
data class Day15Data(val scanner: Point<Long>, val beacon: Point<Long>, val distance: Long)
fun main() {
fun List<String>.parse(): List<Day15Data> {
return this.map {
Regex("-?\\d++").findAll(it).map { it.value.toLong() }.toList()
.let { (x1, y1, x2, y2) ... | 0 | Kotlin | 0 | 1 | 042e559f80b33694afba08b8de320a7072e18c4e | 2,931 | aoc-2022 | Apache License 2.0 |
src/Day08.kt | wooodenleg | 572,658,318 | false | {"Kotlin": 30668} | data class Tree(val x: Int, val y: Int, val height: Int)
fun makeForrest(input: List<String>): List<Tree> {
val forrest = mutableListOf<Tree>()
input.forEachIndexed { columnIndex, treeLine ->
treeLine.forEachIndexed { rowIndex, height ->
forrest.add(Tree(rowIndex, columnIndex, height.digitT... | 0 | Kotlin | 0 | 1 | ff1f3198f42d1880e067e97f884c66c515c8eb87 | 2,978 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | fun main() {
data class Cube(val x: Int, val y: Int, val z: Int) {
override fun toString(): String = "$x,$y,$z"
}
fun Cube.adjacents() = listOf(
copy(x = x + 1),
copy(x = x - 1),
copy(y = y + 1),
copy(y = y - 1),
copy(z = z + 1),
copy(z = z - 1)
)... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 2,890 | advent-of-code-22 | Apache License 2.0 |
src/Day08.kt | Ajimi | 572,961,710 | false | {"Kotlin": 11228} | fun main() {
fun part1(input: List<List<Int>>): Int {
val height = input.size
val width = input.first().size
fun isVisibleFromOutside(row: Int, column: Int, direction: Direction): Boolean {
val treeHeight = input[row][column]
return input.treesByDirection(row, column... | 0 | Kotlin | 0 | 0 | 8c2211694111ee622ebb48f52f36547fe247be42 | 2,600 | adventofcode-2022 | Apache License 2.0 |
src/Day16.kt | sabercon | 648,989,596 | false | null | fun main() {
data class Rule(val name: String, val range1: IntRange, val range2: IntRange)
fun validRules(value: Int, rules: Set<Rule>): Set<Rule> {
return rules.filter { (_, range1, range2) -> value in range1 || value in range2 }.toSet()
}
fun buildRuleMap(candidates: List<Pair<Int, Set<Rule>... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 1,911 | advent-of-code-2020 | MIT License |
2k23/aoc2k23/src/main/kotlin/19.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d19
fun main() {
val (workflows, ratings) = input.raw("19.txt").split("\n\n").let {
val workflows = it[0].split("\n")
.map { line -> Workflow(line) }.associateBy { workflow -> workflow.id }
val ratings = it[1].split("\n")
.filter { line -> line.isNotBlank() }
... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 5,996 | aoc | The Unlicense |
src/Day22/Day22.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import java.lang.Long.max
import java.lang.Long.min
data class Cube(val x: Pair<Long, Long>, val y: Pair<Long, Long>, val z: Pair<Long, Long>) {
fun inSmallerCube() =
x.first >= -50 && x.second <= 50 && y.first >= -50 && y.second <= 50 && z.first >= -50 && z.second <= 50
}
fun Cube.intersect(other: Cube):... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 2,550 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/Path.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | fun main() = Path.solve()
private typealias Matrix = List<List<Int>>
private object Path {
const val START = 0
const val TARGET = ('z'.code - 'a'.code) + 1
fun solve() {
val input = readInput()
val starts = findAll(input, START)
val target = findAll(input, TARGET).first()
... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 3,014 | aoc2022 | MIT License |
2023/src/day07/day07.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day07
import GREEN
import RESET
import printTimeMillis
import readInput
data class CamelCards(
val hand: String,
val occurences: Map<Char, Int>,
val occurencesWithJoker: Map<Char, Int>,
val bid: Int
)
private fun typeScore(occurences: Map<Char, Int>): Int {
if (occurences.values.contains(... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 3,403 | advent-of-code | Apache License 2.0 |
src/Day07.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} |
sealed class Entry(val name: String)
class File(name: String, val size: Int): Entry(name) {
override fun toString() = "File($name,$size)"
}
class Dir(name: String, val parent: Dir?, var entries: List<Entry> = emptyList(), var size: Int=0): Entry(name) {
override fun toString() = "Dir($name,$size {$entries} )"
... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 2,568 | aoc2022 | Apache License 2.0 |
src/year2023/day07/Day07.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2023.day07
import check
import readInput
import kotlin.math.pow
fun main() {
val testInput = readInput("2023", "Day07_test")
check(part1(testInput), 6440)
check(part2(testInput), 5905)
val input = readInput("2023", "Day07")
println(part1(input))
println(part2(input))
}
private fu... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,021 | AdventOfCode | Apache License 2.0 |
src/day07/Day07.kt | pnavais | 727,416,570 | false | {"Kotlin": 17859} | package day07
import readInput
val cardValueMapping = mapOf('2' to 2, '3' to 3, '4' to 4, '5' to 5, '6' to 6, '7' to 7, '8' to 8,
'9' to 9, 'T' to 10, 'J' to 11, 'Q' to 12, 'K' to 13, 'A' to 14)
enum class Type(val value: Int) {
FIVE_OF_A_KIND(7), FOUR_OF_A_KIND(6), FULL_HOUSE(5)... | 0 | Kotlin | 0 | 0 | f5b1f7ac50d5c0c896d00af83e94a423e984a6b1 | 3,181 | advent-of-code-2k3 | Apache License 2.0 |
src/Day12.kt | coolcut69 | 572,865,721 | false | {"Kotlin": 36853} | import java.util.*
fun main() {
fun part1(input: List<String>): Int {
val heightMap = parseInput(input)
return heightMap.shortestPath(
begin = heightMap.start,
isGoal = { it == heightMap.end },
canMove = { from, to -> to - from <= 1 })
}
fun part2(input:... | 0 | Kotlin | 0 | 0 | 031301607c2e1c21a6d4658b1e96685c4135fd44 | 2,838 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day19.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | fun main() {
val input = readInput("Day19")
data class Rule(val c: Char, val cmp: Char, val v: Int, val to: String)
data class Workflow(val name: String, val rules: List<Rule>, val elseTo: String)
val workflows = input.take(input.indexOfFirst { it.isEmpty() }).map {
val name = it.substringBefore... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 2,725 | advent-of-code-kotlin | Apache License 2.0 |
src/day05/Day05.kt | mherda64 | 512,106,270 | false | {"Kotlin": 10058} | package day05
import readInput
fun main() {
val pattern = Regex("(\\d*),(\\d*) -> (\\d*),(\\d*)")
fun processInput(input: List<String>): List<Pair<Point, Point>> {
return input.map {
val (x1, y1, x2, y2) = pattern.find(it)!!.destructured
Pair(Point(x1.toInt(), y1.toInt()), Po... | 0 | Kotlin | 0 | 0 | d04e179f30ad6468b489d2f094d6973b3556de1d | 2,464 | AoC2021_kotlin | Apache License 2.0 |
src/main/kotlin/days/y2023/day23/Day23.kt | jewell-lgtm | 569,792,185 | false | {"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123} | package days.y2023.day23
import util.InputReader
class Day23(val input: List<String>) {
private val start = Position(0, input.first().indexOfOnly('.'))
private val end = Position(input.size - 1, input.last().indexOfOnly('.'))
private val neighbors = input.flatMapIndexed { y, row ->
row.indices.map... | 0 | Kotlin | 0 | 0 | b274e43441b4ddb163c509ed14944902c2b011ab | 3,534 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/Day24.kt | Flame239 | 570,094,570 | false | {"Kotlin": 60685} | private fun map(): List<String> {
val m = readInput("Day24")
h = m.size
w = m[0].length
cycle = lcm(h - 2, w - 2)
start = CC(0, m[0].indexOf("."))
finish = CC(m.size - 1, m[m.size - 1].indexOf("."))
return m
}
private var h = -1
private var w = -1
private var cycle = -1
private lateinit var... | 0 | Kotlin | 0 | 0 | 27f3133e4cd24b33767e18777187f09e1ed3c214 | 2,231 | advent-of-code-2022 | Apache License 2.0 |
src/day_8/kotlin/Day8.kt | Nxllpointer | 573,051,992 | false | {"Kotlin": 41751} | // AOC Day 8
fun Array<Array<Int>>.isTreeVisible(treePos: Pair<Int, Int>): Boolean {
val maxTreeIndex = this.lastIndex
val treeHeight = this[treePos.first][treePos.second]
return ((0 until treePos.first).all { vIndex -> this[vIndex][treePos.second] < treeHeight } ||
(maxTreeIndex downUntil tre... | 0 | Kotlin | 0 | 0 | b6d7ef06de41ad01a8d64ef19ca7ca2610754151 | 2,743 | AdventOfCode2022 | MIT License |
src/Day12.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} |
private data class Pos(val x:Int, val y: Int)
private fun Pos.neighbors() = listOf( Pos(x-1,y), Pos(x+1,y), Pos(x,y-1), Pos(x,y+1) )
private class Area(input: List<String>) {
val area = input.map { it.map { c ->
when(c) {
'S' -> 0
'E' -> 'z'-'a'
else -> c-'a'
}... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 2,010 | aoc2022 | Apache License 2.0 |
src/poyea/aoc/mmxxii/day16/Day16.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day16
import poyea.aoc.utils.readInput
data class State(val current: String, val minutes: Int, val opened: Set<Valve>)
data class Valve(val from: String, val to: List<String>, val rate: Int) {
companion object {
fun from(line: String): Valve {
return Valve(
... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 2,972 | aoc-mmxxii | MIT License |
src/Day12.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 21L
private const val EXPECTED_2 = 525152L
private class Day12(isTest: Boolean) : Solver(isTest) {
val resultMap = mutableMapOf<Pair<Int, Int>, Long>()
fun arrangements(strLeft: String, groupsLeft: List<Int>): Long {
val damageCount = groupsLeft.sum()
val minDam... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 2,522 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | inssein | 573,116,957 | false | {"Kotlin": 47333} | import java.util.PriorityQueue
data class Edge(val point: Pair<Int, Int>, val elevation: Int) : Comparable<Edge> {
override fun compareTo(other: Edge) = elevation.compareTo(other.elevation)
}
data class Grid(val grid: List<List<Int>>) {
private val height = grid.size
private val width = grid.first().size
... | 0 | Kotlin | 0 | 0 | 095d8f8e06230ab713d9ffba4cd13b87469f5cd5 | 2,673 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | rod41732 | 572,917,438 | false | {"Kotlin": 85344} | import kotlin.math.absoluteValue
import kotlin.math.max
import kotlin.math.min
data class Coord2D(val x: Int, val y: Int) {
fun manhattanDistance(other: Coord2D): Int {
return (x - other.x).absoluteValue + (y - other.y).absoluteValue
}
override fun toString(): String {
return "($x, $y)"
... | 0 | Kotlin | 0 | 0 | 1d2d3d00e90b222085e0989d2b19e6164dfdb1ce | 3,234 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/Day08.kt | alex859 | 573,174,372 | false | {"Kotlin": 80552} | fun main() {
val testInput = readInput("Day08_test.txt")
check(testInput.visibleTrees() == 21)
check(testInput.maxScore() == 8)
val input = readInput("Day08.txt")
println(input.visibleTrees())
println(input.maxScore())
}
internal fun String.visibleTrees(): Int {
val visibleInRows = this.r... | 0 | Kotlin | 0 | 0 | fbbd1543b5c5d57885e620ede296b9103477f61d | 2,838 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day15.kt | proggler23 | 573,129,757 | false | {"Kotlin": 27990} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
fun part1(input: List<String>, y: Int): Int {
return input.parse15().getPositionsInRange(y)
}
fun part2(input: List<String>, boundary: Int): Long {
return input.parse15().getTuningFrequency(boundary)
}
... | 0 | Kotlin | 0 | 0 | 584fa4d73f8589bc17ef56c8e1864d64a23483c8 | 2,942 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | import kotlin.math.abs
private class Solution15(input: List<String>) {
val sensors = input.map { getSensorFrom(it) }
private fun getSensorFrom(line: String): Sensor {
val split = line.split("x=", "y=", ",", ":")
val position = Coordinate(split[1].toInt(), split[3].toInt())
val beacon ... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 2,650 | aoc-2022 | Apache License 2.0 |
src/Day08.kt | davedupplaw | 573,042,501 | false | {"Kotlin": 29190} | fun main() {
fun makeMap(inputs: List<String>): Triple<List<List<Int>>, Int, Int> {
val h = inputs.size
val w = inputs[0].length
val trees = inputs
.map {
it.split("")
.filter { x -> x.isNotBlank() }
.map { x -> x.toInt() }
... | 0 | Kotlin | 0 | 0 | 3b3efb1fb45bd7311565bcb284614e2604b75794 | 2,818 | advent-of-code-2022 | Apache License 2.0 |
src/poyea/aoc/mmxxii/day08/Day08.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day08
import poyea.aoc.utils.readInput
fun part1(input: String): Int {
input.split("\n").toList().map { it.map(Char::digitToInt).toList() }.let { rows ->
fun sightLine(x: Int, y: Int) =
listOf(listOf((x - 1 downTo 0), (x + 1 until rows.size)).map { it.map { xx -> xx to... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 1,508 | aoc-mmxxii | MIT License |
src/com/kingsleyadio/adventofcode/y2023/Day22.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val input = readInput(2023, 22).useLines { lines ->
buildList {
lines.forEachIndexed { index, line ->
val (start, end) = line.split("~")
val (sx, sy, sz)... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 3,043 | adventofcode | Apache License 2.0 |
src/year_2022/day_03/Day03.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2022.day_03
import readInput
import util.toAlphabetPosition
data class Rucksack(
val compartmentOne: List<Char>,
val compartmentTwo: List<Char>
) {
val allItemTypes: List<Char> = compartmentOne + compartmentTwo
val errorItemType: Char = compartmentOne.intersect(compartmentTwo.toSet()).fir... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 2,287 | advent_of_code | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2022/day12/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2022.day12
import com.kingsleyadio.adventofcode.util.readInput
import java.util.*
fun main() {
val grid = buildGrid()
part1(grid)
part2(grid)
}
fun part1(grid: Grid) {
println(shortestDistance(grid))
}
fun part2(grid: Grid) {
var shortestDistance = Int.MAX_... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 2,518 | adventofcode | Apache License 2.0 |
kotlin/src/2022/Day19_2022.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | import kotlin.math.*
private data class State(val resources: List<Int>, val robots: List<Int>, val t: Int)
// ore, clay, obsidian, geode
fun maxGeodes(resources: List<Int>, robots: List<Int>, t: Int, costs: List<List<Int>>): Int {
val cache = mutableMapOf<State, Int>()
var allBest = 0 // best solution found y... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 2,974 | adventofcode | Apache License 2.0 |
src/Day12.kt | mikrise2 | 573,939,318 | false | {"Kotlin": 62406} | import java.lang.Integer.min
import java.util.LinkedList
fun main() {
fun findPath(input: List<String>, start: Pair<Int, Int>, end: Pair<Int, Int>): Int {
val distances = input.map { it.map { Int.MAX_VALUE }.toMutableList() }
distances[start.second][start.first] = 0
val path = mutableSetOf<... | 0 | Kotlin | 0 | 0 | d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8 | 3,512 | Advent-of-code | Apache License 2.0 |
src/Day02.kt | brigittb | 572,958,287 | false | {"Kotlin": 46744} | fun main() {
fun parse(input: List<String>): List<Pair<String, String>> = input
.map { it.split(" ") }
.filter { it.size == 2 }
.map { (opponent, own) -> opponent to own }
fun mapToAbc(own: String): String = when (own) {
"X" -> "A"
"Y" -> "B"
else -> "C"
}
... | 0 | Kotlin | 0 | 0 | 470f026f2632d1a5147919c25dbd4eb4c08091d6 | 1,849 | aoc-2022 | Apache License 2.0 |
src/day08.kts | miedzinski | 434,902,353 | false | {"Kotlin": 22560, "Shell": 113} | fun Int(word: String): Int = word.fold(0) { acc, c -> acc or (1 shl (c - 'a')) }
val input = generateSequence(::readLine).map {
val words = it.split(' ')
val delimiterIndex = words.indexOf("|")
val signals: List<Int> = words.subList(0, delimiterIndex).map { Int(it) }
val output: List<Int> = words.subLi... | 0 | Kotlin | 0 | 0 | 6f32adaba058460f1a9bb6a866ff424912aece2e | 2,060 | aoc2021 | The Unlicense |
src/poyea/aoc/mmxxii/day13/Day13.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day13
import kotlin.collections.MutableList
import poyea.aoc.utils.readInput
fun wrap(list: MutableList<Char>, len: Int): MutableList<Char> {
list.add(len, ']')
list.add(0, '[')
return list
}
fun isInOrder(l: MutableList<Char>, r: MutableList<Char>): Boolean {
var left = l
... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 2,141 | aoc-mmxxii | MIT License |
advent-of-code2015/src/main/kotlin/day9/Advent9.kt | REDNBLACK | 128,669,137 | false | null | package day9
import parseInput
import permutations
import splitToLines
/**
--- Day 9: All in a Single Night ---
Every year, Santa manages to deliver all of his presents in a single night.
This year, however, he has some new locations to visit; his elves have provided him the distances between every pair of location... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 2,772 | courses | MIT License |
src/day5/Day5.kt | bartoszm | 572,719,007 | false | {"Kotlin": 39186} | package day5
import readInput
fun main() {
val testInput = parse(readInput("day05/test"))
val input = parse(readInput("day05/input"))
println(solve1(testInput.first, testInput.second))
println(solve1(input.first, input.second))
println(solve2(testInput.first, testInput.second))
println(so... | 0 | Kotlin | 0 | 0 | f1ac6838de23beb71a5636976d6c157a5be344ac | 2,535 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day05.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import cut
import readInput
import separateBy
private data class MappingRange(val range: LongRange, val offset: Long)
private data class ConversionMap(val name: String, private val mappings: List<MappingRange>) {
companion object {
private val MAP_REGEX = """(?<destination>\d+)\s+(?<sour... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,544 | adventOfCode | Apache License 2.0 |
src/year2023/day07/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day07
import year2023.solveIt
fun main() {
val day = "07"
val expectedTest1 = 6440L
val expectedTest2 = 5905L
val sortingOrder = listOf('A','K','Q','J','T','9','8','7','6','5','4','3','2')
fun getHandValue(eachCount: Map<Char, Int>): Int {
return when(eachCount.size){
... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 2,357 | adventOfCode | Apache License 2.0 |
src/Day13.kt | shepard8 | 573,449,602 | false | {"Kotlin": 73637} | sealed interface Tree13: Comparable<Tree13>
class Node13(private vararg val subtrees: Tree13): Tree13, List<Tree13> by subtrees.toList() {
override fun compareTo(other: Tree13): Int {
return when(other) {
is Leaf13 -> this.compareTo(Node13(other))
is Node13 -> compareToNode13(other)... | 0 | Kotlin | 0 | 1 | 81382d722718efcffdda9b76df1a4ea4e1491b3c | 2,624 | aoc2022-kotlin | Apache License 2.0 |
src/main/kotlin/day-08.kt | warriorzz | 434,696,820 | false | {"Kotlin": 16719} | package com.github.warriorzz.aoc
import java.nio.file.Files
import java.nio.file.Path
private fun main() {
println("Day 8:")
val lines = Files.readAllLines(Path.of("./input/day-08.txt"))
val part1 = lines.map { line ->
line.split(" | ")[1].split(" ").map { it.length == 2 || it.length == 4 || it.... | 0 | Kotlin | 1 | 0 | 0143f59aeb8212d4ff9d65ad30c7d6456bf28513 | 2,684 | aoc-21 | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-19.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2023
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
import kotlin.math.max
import kotlin.math.min
fun main() {
val input = readInputLines(2023, "19-input")
val test1 = readInputLines(2023, "19-test1")
prin... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 3,379 | advent-of-code | MIT License |
src/Day07.kt | qmchenry | 572,682,663 | false | {"Kotlin": 22260} | fun main() {
data class File(val name: String, val size: Int)
class DirectoryTree(val name: String, val parent: DirectoryTree?, var children: List<DirectoryTree> = emptyList(), var files: List<File> = emptyList()) {
fun size(): Int = children.sumOf { it.size() } + files.sumOf { it.size }
fun d... | 0 | Kotlin | 0 | 0 | 2813db929801bcb117445d8c72398e4424706241 | 2,904 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/day16/Part1.kt | ollehagner | 572,141,655 | false | {"Kotlin": 80353} | package day16
import addPermutation
import readInput
import java.util.*
fun main() {
val valves = readInput("day16/input.txt").map { Valve.parse(it) }
val distances = valves
.flatMap { valve ->
valves
.filter { it != valve && it.flowRate > 0 }
.map { Pair(va... | 0 | Kotlin | 0 | 0 | 6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1 | 3,488 | aoc2022 | Apache License 2.0 |
src/Day04.kt | ds411 | 573,543,582 | false | {"Kotlin": 16415} | fun main() {
fun part1(input: List<String>): Int {
return input
.map { it.split(',') }
.fold(0) { acc, pair ->
val range1 = pair[0].split('-').map(String::toInt)
val range2 = pair[1].split('-').map(String::toInt)
if (rangeEncompasses(r... | 0 | Kotlin | 0 | 0 | 6f60b8e23ee80b46e7e1262723960af14670d482 | 1,562 | advent-of-code-2022 | Apache License 2.0 |
src/day04/Day04.kt | martinhrvn | 724,678,473 | false | {"Kotlin": 27307, "Jupyter Notebook": 1336} | package day04
import println
import readInput
data class Scratchcard(val id: Int, val winningNumbers: Set<Int>, val numbers: Set<Int>) {
fun getScore(): Int {
val common = getMatchedNumbers()
if (common == 0) {
return 0
}
return 1 shl (common - 1)
}
fun getMatchedNumbers(): Int {
ret... | 0 | Kotlin | 0 | 0 | 59119fba430700e7e2f8379a7f8ecd3d6a975ab8 | 2,071 | advent-of-code-2023-kotlin | Apache License 2.0 |
src/twentythree/Day02.kt | mihainov | 573,105,304 | false | {"Kotlin": 42574} | package twentythree
import readInputTwentyThree
typealias Turn = Map<Color, Int>
fun Turn.isPossible(constraints: Turn): Boolean {
return constraints.entries.all { constraint ->
// if no balls of a given color are drawn, element is null
// in this case use -1, as it's always possible to draw 0 ba... | 0 | Kotlin | 0 | 0 | a9aae753cf97a8909656b6137918ed176a84765e | 2,374 | kotlin-aoc-1 | Apache License 2.0 |
app/src/main/kotlin/codes/jakob/aoc/solution/Day05.kt | loehnertz | 725,944,961 | false | {"Kotlin": 59236} | package codes.jakob.aoc.solution
import codes.jakob.aoc.shared.splitByLines
object Day05 : Solution() {
private val mapPattern = Regex("(\\w+)-to-(\\w+)\\smap:")
override fun solvePart1(input: String): Any {
val splitInput: List<List<String>> = input.split("\n\n").map { it.splitByLines() }
va... | 0 | Kotlin | 0 | 0 | 6f2bd7bdfc9719fda6432dd172bc53dce049730a | 3,354 | advent-of-code-2023 | MIT License |
src/Day15.kt | jimmymorales | 572,156,554 | false | {"Kotlin": 33914} | import kotlin.math.abs
fun main() {
fun List<String>.parseSensorAreas() = map { line ->
val regex = """Sensor at x=(.*), y=(.*): closest beacon is at x=(.*), y=(.*)""".toRegex()
val (sx, sy, bx, by) = regex.find(line)!!.destructured
(sx.toInt() to sy.toInt()) to (bx.toInt() to by.toInt())
... | 0 | Kotlin | 0 | 0 | fb72806e163055c2a562702d10a19028cab43188 | 2,875 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | fun main() {
fun parseGrid(input: List<String>) = input.map {
it.asIterable().map { c -> c - '0' }
}
fun <T> List<List<T>>.transpose() = this[0].indices.map { i -> map { it[i] } }
fun List<Int>.runningMax(): List<Int> {
return listOf(-1) + runningReduce(::maxOf).dropLast(1)
}
... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 2,869 | AdventOfCode2022 | Apache License 2.0 |
src/Day08.kt | azat-ismagilov | 573,217,326 | false | {"Kotlin": 75114} | fun main() {
fun List<String>.parseTrees(): List<List<Int>> = this.map { line -> line.map { it.digitToInt() } }
fun getPossibleDirections(n: Int, m: Int): List<List<List<Pair<Int, Int>>>> {
val xCoordinates = (0 until n)
val yCoordinates = (0 until m)
return listOf(
xCoordi... | 0 | Kotlin | 0 | 0 | abdd1b8d93b8afb3372cfed23547ec5a8b8298aa | 2,682 | advent-of-code-kotlin-2022 | Apache License 2.0 |
2k23/aoc2k23/src/main/kotlin/23.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d23
import input.read
fun main() {
println("Part 1: ${part1(read("23.txt"))}")
println("Part 2: ${part2(read("23.txt"))}")
}
fun part1(input: List<String>): Int = Maze(input).findLongestPath()
// C'est Noël, on optimise keud'
fun part2(input: List<String>): Int = Maze(input, false).findLongestPath()... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 2,844 | aoc | The Unlicense |
src/main/kotlin/be/swsb/aoc2021/day14/Day14.kt | Sch3lp | 433,542,959 | false | {"Kotlin": 90751} | package be.swsb.aoc2021.day14
object Day14 {
fun solve1(input: List<String>): Int {
val (initialTemplate, rules) = parse(input)
val polymer = (1..10).fold(initialTemplate) { template, _ ->
expandPolymer(template, rules)
}
val mostCommon = polymer.maxOf { c -> polymer.cou... | 0 | Kotlin | 0 | 0 | 7662b3861ca53214e3e3a77c1af7b7c049f81f44 | 3,674 | Advent-of-Code-2021 | MIT License |
src/Day08.kt | mkfsn | 573,042,358 | false | {"Kotlin": 29625} | fun main() {
fun <T> rotate(table: MutableList<MutableList<T>>): MutableList<MutableList<T>> {
val rows = table.size
val cols = if (table.isNotEmpty()) table[0].size else 0
return MutableList<MutableList<T>>(cols) { _ -> ArrayList(rows) }.apply {
table.forEachIndexed { i, row -> ... | 0 | Kotlin | 0 | 1 | 8c7bdd66f8550a82030127aa36c2a6a4262592cd | 3,299 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | buczebar | 572,864,830 | false | {"Kotlin": 39213} | fun main() {
fun parseInput(name: String) =
readInput(name).map { it.toList() }.map { row -> row.map { height -> height.digitToInt() } }
fun getListOfTrees(input: List<List<Int>>): List<Tree> {
val columns = input.transpose()
val (width, height) = columns.size to input.size
val ... | 0 | Kotlin | 0 | 0 | cdb6fe3996ab8216e7a005e766490a2181cd4101 | 2,314 | advent-of-code | Apache License 2.0 |
src/main/kotlin/aoc2020/TicketTranslation.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2020
import komu.adventofcode.utils.nonEmptyLines
import komu.adventofcode.utils.product
fun ticketTranslation1(input: String): Int {
val (rules, _, nearbyTickets) = parseTicketData(input)
return nearbyTickets.sumBy { ticket ->
ticket.filter { v -> !rules.any { it.isSatis... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,648 | advent-of-code | MIT License |
src/Day08.kt | jstapels | 572,982,488 | false | {"Kotlin": 74335} |
fun main() {
fun getCol(nums: List<List<Int>>, col: Int) =
nums.indices.map { nums[it][col] }
fun visible(trees: List<List<Int>>, pos: Pos) =
{ h:Int -> h < trees[pos.y][pos.x] }.let {
trees[pos.y].take(pos.x).all(it) ||
trees[pos.y].takeLast(trees[pos.y].size ... | 0 | Kotlin | 0 | 0 | 0d71521039231c996e2c4e2d410960d34270e876 | 2,023 | aoc22 | Apache License 2.0 |
src/day13/Day13.kt | Volifter | 572,720,551 | false | {"Kotlin": 65483} | package day13
import utils.*
class Packet(private val items: List<Any>) : Comparable<Packet> {
constructor(str: String) : this(
splitList(str.substring(1 until str.lastIndex))
.filter { it.isNotEmpty() }
.map { it.toIntOrNull() ?: Packet(it) }
)
override fun compareTo(othe... | 0 | Kotlin | 0 | 0 | c2c386844c09087c3eac4b66ee675d0a95bc8ccc | 2,563 | AOC-2022-Kotlin | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.