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/day02/Day02.kt
voom
573,037,586
false
{"Kotlin": 12156}
package day02 import day02.Move.* import day02.RoundResult.* import readInput /** * --- Day 2: Rock Paper Scissors --- */ fun main() { val choiceScore = mapOf( ROCK to 1, PAPER to 2, SCISSORS to 3 ) fun calcRoundScore(pair: Pair<Move, Move>): Int { val comparator = Resul...
0
Kotlin
0
1
a8eb7f7b881d6643116ab8a29177d738d6946a75
3,796
aoc2022
Apache License 2.0
src/aoc2022/Day12.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* import utils.Coord.Companion.get import java.util.* private class Day12(val lines: List<String>) { private fun parseInput(filter: (Node, Node) -> Boolean): List<Node> { val nodes = lines.map { it.toList() }.mapIndexed { r, row -> row.mapIndexed { c, value -> Node(r,...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
2,447
aoc2022
Apache License 2.0
src/day/_12/Day12.kt
Tchorzyksen37
572,924,533
false
{"Kotlin": 42709}
package day._12 import readInput class Day12(private val nodes: List<List<Node>>) { private val bounds = Bounds(nodes.first().indices, nodes.indices) private val end = findNode { it.state == State.END } fun findShortestPath(isDestination: (Node) -> Boolean): Int { val frontier: ArrayDeque<Step> = ArrayDeque(l...
0
Kotlin
0
0
27d4f1a6efee1c79d8ae601872cd3fa91145a3bd
2,708
advent-of-code-2022
Apache License 2.0
src/Day07.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Long { val (_, dirs) = generateTree(root = TreeItem.Dir("/"), input) return dirs.filter { it.size <= 100000L }.sumOf(TreeItem.Dir::size) } fun part2(input: List<String>): Long { val (root, dirs) = generateTree(root = TreeItem.Dir("/"), ...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
2,112
aoc-2022
Apache License 2.0
src/main/kotlin/Day08.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { data class Tree( val height: Int, var n: Tree? = null, var e: Tree? = null, var s: Tree? = null, var w: Tree? = null ) fun buildForest(map: List<String>) = map .map { it .toCharArray() .map(Char::digitT...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
2,302
aoc-2022
Apache License 2.0
src/Day07.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
fun main() { open class File(val name: String, open val size: Long) class Dir(name: String, val parent: Dir? = null, val files: MutableList<File> = mutableListOf()) : File(name, 0) { val head: Dir get() = parent?.head ?: this override val size: Long get() = files.sumOf(File::size) operat...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
2,454
aoc-2022-demo
Apache License 2.0
src/main/kotlin/com/ryanmoelter/advent/day08/Tree.kt
ryanmoelter
573,615,605
false
{"Kotlin": 84397}
package com.ryanmoelter.advent.day08 typealias Grid<T> = List<List<T>> fun main() { println(findMostScenicTree(treeData)) } fun findMostScenicTree(input: String): Int { val grid = input.parseGrid() val spaceGrid = grid.spaceRight() times grid.spaceLeft() times grid.spaceUp() times grid.spaceDown() retu...
0
Kotlin
0
0
aba1b98a1753fa3f217b70bf55b1f2ff3f69b769
2,713
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day12.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DAY_FILE import util.DayInput class Day12 : Day("12") { class Line(val symbols: List<Char>, val numbers: List<Int>) { fun validSimple(resultIndexes: List<Int>): Boolean { return if (resultIndexes.isEmpty()) { true } else { v...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
3,638
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/Day08.kt
BenHopeITC
573,352,155
false
null
data class Tree( val treeHeight: Int, val treesLeft: List<Int>, val treesRight: List<Int>, val treesTop: List<Int>, val treesBottom: List<Int> ) { fun isVisible(): Boolean { if (treesLeft.isEmpty() || treesRight.isEmpty() || treesTop.isEmpty() || treesBottom.isEmpty()) { retu...
0
Kotlin
0
0
851b9522d3a64840494b21ff31d83bf8470c9a03
3,297
advent-of-code-2022-kotlin
Apache License 2.0
src/Day12.kt
kipwoker
572,884,607
false
null
class Day12Input( val graph: Map<Point, Int>, val start: Point, val end: Point ) data class Trace(val weight: Int, val current: Point, val prev: Point?, val distance: Int) fun main() { fun getNeighbors(point: Point, graph: Map<Point, Int>): List<Point> { return listOf( Point(point....
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
2,760
aoc2022
Apache License 2.0
src/Day12.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
import java.util.LinkedList fun main() { fun buildMap(input: List<String>, sMapping: Char, eMapping: Char): List<List<Int>> { return input.map { s -> s.replace('S', sMapping).replace('E', eMapping).map { it.code } } } fun find(map: List<List<Int>>, start: Char, end: Char, chec...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
2,205
AdventCode2022
Apache License 2.0
src/main/kotlin/Day08.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
class Day08 { fun part1(input: List<String>): Int { return TreeArea(input).getVisibleTrees() } fun part2(input: List<String>): Int { return TreeArea(input).getBestScore() } class TreeArea(input: List<String>) { private val trees: Array<Array<Tree>> private val si...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
3,703
advent-of-code-2022
Apache License 2.0
src/Day07.kt
jamesrobert
573,249,440
false
{"Kotlin": 13069}
import java.util.Deque fun main() { class Command(val name: String, val param: String = "") fun String.command(): Command { val parts = split(" ") return when (parts[1]) { "cd" -> Command(name = "cd", param = parts[2]) "ls" -> Command(name = "ls") else -> er...
0
Kotlin
0
0
d0b49770fc313ae42d802489ec757717033a8fda
2,908
advent-of-code-2022
Apache License 2.0
src/Day15.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
import kotlin.math.abs fun main() { class Position(val x: Long, val y: Long) { fun distance(other: Position): Long { return abs(x - other.x) + abs(y - other.y) } } class Sensor(val pos: Position, val beacon: Position) { fun radius(): Long { return pos.distan...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
3,466
aoc-2022
Apache License 2.0
src/aoc2021/Day04.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput fun main() { val (year, day) = "2021" to "Day04" fun List<List<Int>>.sumBoard(markedNumbers: Set<Int>): Int { return sumOf { it.filter { number -> number !in markedNumbers }.sum() } } fun List<List<Int>>.checkBoard(markedNumbers: Set<Int>): Pair<Boolean, Int>...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
2,485
aoc-kotlin
Apache License 2.0
src/Day11.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
import java.util.* data class Monkey( val items: Queue<Long>, val operation: (Long, Long) -> Long, val operationValue: Long?, val testValue: Long, val ifTrueDestination: Int, val ifFalseDestination: Int, var itemsInspected: Long = 0L ) fun makeMonkeys(input: List<String>): Pair<Int, Monkey...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
2,974
aoc2022
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day08.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
package de.niemeyer.aoc2022 /** * Advent of Code 2022, Day 8: Treetop kotlin.aoc2022.niemeyer.aoc2022.Tree House * Problem Description: https://adventofcode.com/2022/day/8 */ import de.niemeyer.aoc.points.Point2D import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName import...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,572
AoC-2022
Apache License 2.0
src/main/kotlin/day16/Day16.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day16 import readInput fun main() { data class Valve(val id: String, val rate: Int, val linkedWith: Set<String>) data class Valves(val valves: Map<String, Valve>) { val dist: Map<String, Map<String, Int>> = valves.mapValues { (id, _) -> dist(valves, id) } fun di...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
3,216
aoc2022
Apache License 2.0
2022/Day16.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { val input = readInput("Day16") data class Valve( val name: String, val rate: Int, val leads: List<String> ) val valves = input.map { s -> val (valve, rate, leads) = s.split("Valve ", " has flow rate=", "; tunnels lead to valves ", "; tunnel leads to valve ")....
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,654
advent-of-code-kotlin
Apache License 2.0
2022/src/main/kotlin/day13_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.badInput fun main() { Day13Imp.run() } object Day13Imp : Solution<List<Pair<Day13Imp.Fragment.Packet, Day13Imp.Fragment.Packet>>>() { override val name = "day13" sealed class Fragment : Comparable<Fragment> { class Packet(val fragments: List<Fragment>)...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,599
aoc_kotlin
MIT License
src/main/kotlin/Day13.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { fun getNextList(s: String): String { require(s.first() == '[') var level = 0 return s.takeWhile { 0 < when (it) { '[' -> ++level ']' -> --level else -> level } } + ']' } fun parseList(list: ...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
3,167
aoc-2022
Apache License 2.0
src/day15/Day15.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day15 import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min import readInput import utils.withStopwatch fun main() { val testInput = readInput("input15_test") withStopwatch { println(part1(testInput, 10)) } withStopwatch { println(part2(testInput, 0..20)) } val input ...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
3,253
advent-of-code-kotlin-2022
Apache License 2.0
src/day09/Day09.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day09 import readInput import java.lang.Math.abs enum class Direction(val key: String, val xChange: Int, val yChange: Int) { UP("U", 0, 1), DOWN("D", 0, -1), LEFT("L", -1, 0), RIGHT("R", 1, 0); companion object { val keys = Direction.values().associateBy { it.key } } } data c...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
3,239
advent-of-code-2022
Apache License 2.0
2015/Day17/src/main/kotlin/Main.kt
mcrispim
658,165,735
false
null
import java.io.File fun combinations(arr: Array<Int>, r: Int): List<List<Int>> { val data = Array(r) { 0 } val results = mutableListOf<List<Int>>() for (n in 1..r) { combinationUtil(arr, n, 0, data, 0, results) } return results } fun combinationUtil(arr: Array<Int>, r: Int, index: Int, da...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
1,799
AdventOfCode
MIT License
src/Day07.kt
afranken
572,923,112
false
{"Kotlin": 15538}
import Node.Dir import Node.File fun main() { fun treeOf(input: List<String>): Dir { var current = Dir("/", null) input .drop(1) .filterNot(String::isBlank) .forEach { if (it.startsWith("$")) { if (it.startsWith("$ cd")) { ...
0
Kotlin
0
0
f047d34dc2a22286134dc4705b5a7c2558bad9e7
2,926
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/Excercise08.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
private fun part1() { getInputAsTest("08") .map { InputRow.of(it) } .sumOf { row -> row.digitSegments.takeLast(4).count { it.size in setOf(2, 3, 4, 7) } } .let { println("Part1 $it") } } private fun part2() { getInputAsTest("08").map { InputRow.of(it) }.sumOf { row -> row.calculateValue() }.let { p...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
2,469
advent-of-code-2021
MIT License
src/Day03.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
fun main() { fun <T> getItemsInBothLists(list1: List<T>, list2: List<T>) = list1.filter { list2.contains(it) }.distinct() data class Item(val character: Char) { fun getPriorityValue(): Int { return if (character.isLowerCase()) character - 'a' + 1 else if (charact...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
2,987
AdventOfCode2022
Apache License 2.0
src/main/kotlin/Day9.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
fun puzzleDayNinePartOne() { val inputs = readInput(9).map { lines -> lines.map { Integer.parseInt(it.toString()) } } val bumpedSum = findLowPoints(inputs).map { it.height }.sumOf { it + 1 } println("Low point sum is: $bumpedSum") } fun puzzleDayNinePartTwo() { val inputs = readInput(9).map { lines ->...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
2,711
advent-of-kotlin-2021
Apache License 2.0
src/Day07.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
import java.util.* const val TOTAL_DISK_SPACE = 70_000_000 const val REQUIRED_SPACE = 30_000_000 fun Stack<String>.toAbsolutePath(subDir: String = ""): String { val dirs = if (subDir.isNotBlank()) subList(1, this.size) + subDir else subList(1, this.size) return dirs.joinToString("/", "/") } fun main() { ...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
3,031
advent-of-code-2022
Apache License 2.0
src/main/kotlin/_2023/Day07.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2023 import Day import InputReader enum class HandPower(val power: Int, val validation: (cardOccurrences: Map<Char, Int>) -> Boolean) { FIVE_OF_A_KIND(6, ::fiveOfAKindValidation), FOUR_OF_A_KIND(5, ::fourOfAKindValidation), FULL_HOUSE(4, ::fullHouseValidation), THREE_OF_A_KIND(3, ::threeOfAKi...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,779
advent-of-code
Apache License 2.0
src/year2021/09/Day09.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2021.`09` import readInput private data class Point( val x: Int, val y: Int, ) { override fun toString(): String { return "[$x,$y]" } } private fun Point.neighbours(): Set<Point> { return setOf( Point(x = x, y = y + 1), Point(x = x, y = y - 1), Point(x...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
2,633
KotlinAdventOfCode
Apache License 2.0
src/Day13.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
sealed class Node: Comparable<Node> class NumberNode(val value: Int): Node() { override fun compareTo(other: Node): Int { return when (other) { is NumberNode -> this.value.compareTo(other.value) else -> ListNode(listOf(this)).compareTo(other) } } override fun toString(): String { return ...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
2,632
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day08.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day08 : Runner<Int, Int>(8, 21, 8) { override fun part1(input: List<String>): Int { val height = input.size val treePatch = TreePatch(List(height) { input[it].toCharArray().map { c -> Tree(c.digitToInt()) } }) val width = treePatch.trees[0].size for (x in 0 until width) { ...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
2,826
advent-of-code-2022-kotlin
Apache License 2.0
src/day7.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import kotlin.system.exitProcess private const val DAY = 7 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: String -> x.split(" ").let { Pair(it.first(), it.last().toIn...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
2,746
aoc2023
MIT License
src/y2022/Day15.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.Pos import util.readInput import kotlin.math.abs object Day15 { data class SensorBeacon(val sensor: Pos, val beacon: Pos) { constructor(s: List<Int>, b: List<Int>) : this(s.toPair(), b.toPair()) fun manhattanDist(): Int { return sensor.manhattanDist(beacon) ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
4,386
advent-of-code
Apache License 2.0
src/Day11.kt
anisch
573,147,806
false
{"Kotlin": 38951}
data class Monkey( val name: Int, val items: MutableList<Long>, val op: (Long) -> Long, val divBy: Long, val test: (Long) -> Boolean, val success: Int, // if true: throw to val fail: Int, // if false: trow to var inspectCounter: Long = 0, ) fun getMonkeys(input: List<String>): List<Monk...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
2,718
Advent-of-Code-2022
Apache License 2.0
src/Day08/Day08.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
fun main() { fun preprocess(input: List<String>): List<Pair<List<String>, List<String>>> { fun preprocessSingle(input: String): Pair<List<String>, List<String>> { val split = input.split('|') val fst = split[0].split(' ').filter { it.isNotBlank() } val snd = split[1].spli...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
2,151
advent-of-code-2021
Apache License 2.0
src/Day12.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { data class Node(val i: Int, val j: Int, val char: Char, var cost: Int) { val height = when (char) { 'S' -> 'a' 'E' -> 'z' else -> char }.code } fun exists(i: Int, j: Int, map: Array<Node>): Boolean { return map.any { it.i == i && it.j...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
2,399
aoc-2022-in-kotlin
Apache License 2.0
src/day3/Day03.kt
ousa17
573,435,223
false
{"Kotlin": 8095}
package day3 import readInput fun main() { val input = readInput("day3/Day03") part1(input) part2(input) } private fun part2(input: List<String>) { val badges = input.windowed(3, step = 3).map { findBadge(it) } val mapMyList = getMapCharPriority() val sumPriority = badges.map { inp...
0
Kotlin
0
0
aa7f2cb7774925b7e88676a9ca64ca9548bce5b2
1,492
advent-day-1
Apache License 2.0
Advent-of-Code-2023/src/Day22.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day22" private const val INPUT_FILE = AOC_DAY private data class Brick(val minX: Int, val maxX: Int, val minY: Int, val maxY: Int, val minZ: Int, val maxZ: Int) { fun down(): Brick = Brick(minX, maxX, minY, maxY, minZ - 1, maxZ - 1) fun supports(b: Brick) = minX <= b.maxX...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
4,084
Advent-of-Code-2023
Apache License 2.0
src/day11/Day11.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day11 import readText data class Monkey(var items: MutableList<Long>, val operation: List<String>, val divisor: Long, val trueMonkey: Int, val falseMonkey: Int) { var inspected = 0L fun getWorryLevel(item: Long): Long { val operator = operation[0] val number = if (operation[1] == "old...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,866
aoc2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-07.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 fun main() { val input = readInputLines(2023, "07-input") val test1 = readInputLines(2023, "07-test1") println("Part1:") part1(test1).println() p...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,405
advent-of-code
MIT License
src/days/day7/Day7.kt
Riven-Spell
113,698,657
false
{"Kotlin": 25729}
package days.day7 import kotlin.math.abs data class Program(val Name: String, val Weight: Int, val Links: List<String>) val nregex = Regex("[a-z]+") val wregex = Regex("\\(\\d+\\)") val weregex = Regex("\\d+") val lregex = Regex("->") fun day7p1(s: String) : String { var programs = HashMap<String,Program>() ...
0
Kotlin
0
1
dbbdb390a0addee98c7876647106af208c3d9bc7
3,331
Kotlin-AdventOfCode-2017
MIT License
src/main/kotlin/aoc23/Day02.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day02Domain.Bag import aoc23.Day02Domain.Cube import aoc23.Day02Domain.Cube.* import aoc23.Day02Domain.CubeGame import aoc23.Day02Domain.Round import aoc23.Day02Parser.toCubeGame import aoc23.Day02Solution.part1Day02 import aoc23.Day02Solution.part2Day02 import common.Collections.product imp...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
2,951
aoc
Apache License 2.0
advent-of-code-2023/src/Day13.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import kotlin.math.min private const val DAY = "Day13" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) shouldBe 405 measureAnswer { part1(input()) } } "Part 2" { part2(testInput()) shouldBe 400 mea...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
1,711
advent-of-code
Apache License 2.0
src/Day04.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
fun main() { fun part1(input: List<String>): Int { return input.getPairsOfRanges() .map { ranges -> when { ranges.first.first in ranges.second && ranges.first.last in ranges.second -> 1 ranges.second.first in ranges.first && ranges.second.l...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
1,352
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day6.kt
hughjdavey
159,955,618
false
null
package days class Day6 : Day(6) { private val coords = toNamedCoords(inputList) override fun partOne(): Int { println("// Day 6 Part 1 takes about 6 seconds...") val allGridCoords = (0..maxX(coords.values)).flatMap { x -> (0..maxY(coords.values)).map { y -> Pair(x, y) } } return allG...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
2,643
aoc-2018
Creative Commons Zero v1.0 Universal
y2022/src/main/kotlin/adventofcode/y2022/Day15.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import kotlin.math.abs object Day15 : AdventSolution(2022, 15, "Beacon Exclusion Zone") { override fun solvePartOne(input: String) = solvePartOne(input, 2_000_000) fun solvePartOne(input: String, y: Int): ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
4,175
advent-of-code
MIT License
src/Day15.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
import kotlin.math.abs data class Beacon(val x: Int, val y: Int) data class Sensor(val x: Int, val y: Int, val beacon: Beacon) { fun coverRangeAtY(rangeY: Int): IntRange { val distance = abs(x - beacon.x) + abs(y - beacon.y) val yCorrection = abs(y - rangeY) val left = x - distance + yCorre...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
2,699
aoc-2022
Apache License 2.0
src/day22/Code.kt
fcolasuonno
221,697,249
false
null
package day22 import java.io.File import java.util.* import kotlin.math.abs fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") p...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
3,955
AOC2016
MIT License
src/day2/Day2.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day2 import readInput import toPair fun main() { val testInput = parse(readInput("day02/test")) val input = parse(readInput("day02/input")) println(solve1(testInput)) println(solve1(input)) println(solve2(testInput)) println(solve2(input)) } fun parse(input: List<String>): List<Pai...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
2,032
aoc-2022
Apache License 2.0
src/day16/Day16.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day16 import utils.* val LINE_REGEX = ( """Valve (\w+) has flow rate=(\d+); """ + """tunnels? leads? to valves? (.*)""" ).toRegex() data class Valve(val name: String, val rate: Int) { lateinit var links: List<Valve> lateinit var openingCosts: Map<Valve, Int> fun computeOpeningCosts() { ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
3,386
AOC-2022-Kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day11.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import Point import readInput import to2dCharArray object Day11 { fun getDistanceSum(input: List<String>, emptyMultiplier: Int = 2): Long { val initialMap = input.to2dCharArray() val emptyColumns = initialMap.withIndex().filter { (x, column) -> column.all { it == '.' } }.map { it....
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,823
adventOfCode
Apache License 2.0
src/2022/Day19.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun parseBlueprint(blueprintConfig: String): Blueprint { val regex = """Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Each obsidian robot costs (\d+) ore and (\d+) clay. Each geode robot costs (\d+) ore and (\d+)...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
6,251
aoc-2022-in-kotlin
Apache License 2.0
src/day14/Day14.kt
spyroid
433,555,350
false
null
package day14 import com.github.ajalt.mordant.terminal.Terminal import readInput import kotlin.system.measureTimeMillis fun main() { class Polymer(input: List<String>) { var template = input.first() val pairCounts = input.first().asSequence() .windowed(2) .map { it.joinTo...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
2,702
Advent-of-Code-2021
Apache License 2.0
src/Day07.kt
Migge
572,695,764
false
{"Kotlin": 9496}
private fun part1(input: List<String>): Int { val root = buildDisk(input.drop(1)) return root.flatMap() .map { it.size } .filter { it <= 100000 } .sorted() .sum() } private fun part2(input: List<String>): Int { val root = buildDisk(input.drop(1)) val remaining = 30000000...
0
Kotlin
0
0
c7ca68b2ec6b836e73464d7f5d115af3e6592a21
1,706
adventofcode2022
Apache License 2.0
src/year2015/day24/Day24.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day24 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2015", "Day24_test") check(part1(testInput), 99) check(part2(testInput), 44) val input = readInput("2015", "Day24") println(part1(i...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,178
AdventOfCode
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2023/Day19.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 19 - Aplenty * Problem Description: http://adventofcode.com/2023/day/19 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day19/ */ package com.ginsberg.advent2023 class Day19(input: List<String>) { private val wor...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
4,925
advent-2023-kotlin
Apache License 2.0
src/Day13.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
private sealed class Packet : Comparable<Packet> { companion object { fun of(input: String): Packet = of(input.split("""((?<=[\[\],])|(?=[\[\],]))""".toRegex()) .filter { it.isNotBlank() } .filter { it != "," } .iterator() )...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,312
aoc-2022
Apache License 2.0
src/aoc2022/Day18.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* private class Day18(val lines: List<String>) { data class Coord3d(val x:Int, val y:Int, val z:Int) { fun getCrossNeighbors() : List<Coord3d> { return listOf( this.offset(dx = 1), this.offset(dx = -1), this.offset(dy = 1), this.offset(dy = -1)...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
2,689
aoc2022
Apache License 2.0
src/main/kotlin/day7/Day7.kt
stoerti
726,442,865
false
{"Kotlin": 19680}
package io.github.stoerti.aoc.day7 import io.github.stoerti.aoc.IOUtils import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun main(args: Array<String>) { val lines = IOUtils.readInput("day_7_input") val result1 = lines.map { it.split(" ") } .map { Hand(it[1].toInt(), it[0]) } .sort...
0
Kotlin
0
0
05668206293c4c51138bfa61ac64073de174e1b0
2,522
advent-of-code
Apache License 2.0
src/adventofcode/day05/Day05.kt
bstoney
574,187,310
false
{"Kotlin": 27851}
package adventofcode.day05 import adventofcode.* fun main() { Solution.solve() } typealias Crate = Char object Solution : AdventOfCodeSolution<String>() { override fun solve() { solve(5, "CMZ", "MCD") } override fun part1(input: List<String>): String { return getSupplyStacks(input) ...
0
Kotlin
0
0
81ac98b533f5057fdf59f08940add73c8d5df190
3,408
fantastic-chainsaw
Apache License 2.0
src/main/kotlin/d19/D19_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d19 import d13.split import input.Input import kotlin.math.max import kotlin.math.min data class Rule( val breakpoint: Int, val category: Char, val operation: Char, val target: String ) fun parseWorkflows2(lines: List<String>): Map<String, List<Rule>> { return lines.map { line -> ...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
4,107
aoc2023-kotlin
MIT License
src/Day03.kt
ManueruEd
573,678,383
false
{"Kotlin": 10647}
fun main() { val lower = ('a'..'z').mapIndexed { index, c -> c to (index + 1) } val upper = ('A'..'Z').mapIndexed { index, c -> c to (index + 27) } fun part1(input: List<String>): Int { val a = input.map { StringBuilder(it) .insert(it.length / 2, " ") ....
0
Kotlin
0
0
09f3357e059e31fda3dd2dfda5ce603c31614d77
1,547
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch2/Problem26.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import dev.bogwalk.util.maths.primeNumbers import java.math.BigInteger /** * Problem 26: Reciprocal Cycles * * https://projecteuler.net/problem=26 * * Goal: Find the value of the smallest d less than N for which 1/d contains the longest * recurring cycle in its decimal fraction part. ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,847
project-euler-kotlin
MIT License
src/Day15.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
fun main() { fun part1(input: List<String>, yAxis: Int): Int { val points = parseInput(input) var maxX = Int.MIN_VALUE var minX = Int.MAX_VALUE for ((sensor, beacon) in points) { val dist = sensor.distance(beacon) val distanceToY = dist - kotlin.math.abs(yAxis - sensor.y) ...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
2,906
aoc-2022
Apache License 2.0
src/year2022/day19/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day19 import io.kotest.matchers.shouldBe import java.util.PriorityQueue import kotlin.math.ceil import kotlin.math.max import utils.readInput fun main() { val testInput = readInput("19", "test_input").let(::parseBlueprints) val realInput = readInput("19", "input").let(::parseBlueprints) ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
5,327
Advent-of-Code
Apache License 2.0
src/y2023/Day05.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.split import util.timingStatistics object Day05 { data class MyMap(val destinationStart: Long, val sourceRange: LongRange) { fun destinationFor(source: Long): Long { return destinationStart + (source - sourceRange.first) } } priv...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
5,323
advent-of-code
Apache License 2.0
src/Day12.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
fun main() { fun part1(input: List<String>): Int { return HeightMap.fromLines(input).solvePart1() } fun part2(input: List<String>): Int { return HeightMap.fromLines(input).solvePart2() } // test if implementation meets criteria from the description, like: val testInput = readIn...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
2,400
advent-of-code-2022
Apache License 2.0
src/year2023/day04/Day04.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day04 import check import readInput fun main() { val testInput = readInput("2023", "Day04_test") check(part1(testInput), 13) check(part2(testInput), 30) val input = readInput("2023", "Day04") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,683
AdventOfCode
Apache License 2.0
src/Day03.kt
rounakdatta
540,743,612
false
{"Kotlin": 19962}
import kotlin.math.pow fun binaryToDecimal(input: List<Char>): Int { // pair of index, result return input.foldRight(Pair(-1, 0)) { bit, pairOfIndexAndResultSoFar -> Pair( pairOfIndexAndResultSoFar.first + 1, (pairOfIndexAndResultSoFar.second + bit.digitToInt() * 2.0.pow((pairOf...
0
Kotlin
0
1
130d340aa4c6824b7192d533df68fc7e15e7e910
3,551
aoc-2021
Apache License 2.0
src/main/kotlin/adventofcode2023/day17/day17.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day17 import adventofcode2023.Point import adventofcode2023.pointsAround fun main() { val input = listOf( intArrayOf(1, 2, 3), intArrayOf(4, 5, 6), intArrayOf(7, 8, 9) ) val minSumPath = findMinSumPath(input) } fun prepareInput(input: List<String>): List<...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
3,486
adventofcode2023
MIT License
p06/src/main/kotlin/ChronalCoordinates.kt
jcavanagh
159,918,838
false
null
package p06 import common.file.readLines import java.awt.Point fun manhattan(a: Point, b: Point): Int { return Math.abs(a.x - b.x) + Math.abs(a.y - b.y) } fun edges(coords: List<Point>): List<Point> { //Find the edges - all these have "infinite" area val byX = coords.sortedBy { it.x } val byY = coords.sorted...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
2,722
advent2018
MIT License
src/twentytwentytwo/day16/Day16.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day16 import twentytwentytwo.day12.Graph import readInput fun main() { data class ValveNode( val id: String, val flowRate: Int, val neighbours: MutableSet<Pair<String, Int>>, ) val graph = mutableMapOf<String, ValveNode>() var availableMinutes = 30 ...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
5,102
advent-of-code
Apache License 2.0
src/year_2022/day_15/Day15.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_15 import readInput import util.Line import util.Point import util.crossingPoint import util.manhattanDistance import kotlin.math.abs data class Sensor( val position: Point, val closestBeaconPosition: Point, val closestBeaconDistance: Int ) object Day15 { /** * @return ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,443
advent_of_code
Apache License 2.0
advent-of-code-2023/src/Day19.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day19" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) shouldBe 19114 measureAnswer { part1(input()) } } "Part 2" { part2(testInput()) shouldBe 167409079868000 measureAnswer...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
5,207
advent-of-code
Apache License 2.0
archive/2022/Day15.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import kotlin.Int.Companion.MAX_VALUE import kotlin.math.absoluteValue private const val EXPECTED_1 = 26 private const val EXPECTED_2 = 56000011L private class Day15(isTest: Boolean) : Solver(isTest) { val data = readAsLines().map { line -> val (sensorStr, closestStr) = line.split("beacon") fun pa...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,506
advent-of-code-2022
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day18.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day18 : AdventSolution(2021, 18, "Snailfish") { override fun solvePartOne(input: String): Int { val numbers = input.lines().map(::toSnailNumber) return numbers.reduce(SnailfishNumber::plus).magnitude() } override fun ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,697
advent-of-code
MIT License
src/main/kotlin/days/Day2.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days class Day2 : Day(2) { override fun partOne(): Any { val max = Set(mapOf(Color.Red to 12, Color.Green to 13, Color.Blue to 14)) return inputList.parseInput() .map { game -> game to game.sets.all { it <= max } }.filter { it.second } ....
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
1,641
AoC-2023
Creative Commons Zero v1.0 Universal
src/Day23.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun input(): Array<BooleanArray> { val gs = readInput("Day23") val padding = 100 val h = gs.size + 2 * padding val w = gs[0].length + 2 * padding val arr = Array(h) { BooleanArray(w) } gs.forEachIndexed { rowInd, row -> row.forEachIndexed { i, c -> arr[rowInd + paddin...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
2,221
advent-of-code-2022
Apache License 2.0
src/Day15.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
import kotlin.math.abs import kotlin.math.max fun main() { Day15.printSolutionIfTest(26, 56000011) } object Day15: Day<Int, Long>(15) { override fun part1Test(lines: List<String>) = countPositions(lines, 10) override fun part1(lines: List<String>) = countPositions(lines, 2000000) override fun part2T...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
2,182
advent-of-code-2022
Apache License 2.0
src/Day11.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
class Monkey(val items: MutableList<Long>, val operation: (Long, Long?) -> Long, val testAndThrow: (Long) -> Int, val modulo: Long) { } fun main() { fun constructOperation(opToken: Char, value: Long?, divideBy: Long = 3): (Long, Long?) -> Long { return if (opToken == '*') { it: Long, modulo: L...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
3,030
advent-of-kotlin-2022
Apache License 2.0
src/Day12.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
private typealias MapOfHeights = List<List<Char>> private fun Char.elevation() = when (this) { 'S' -> 0 // a 'E' -> 25 // z else -> ('a'..'z').indexOf(this) } private fun MapOfHeights.getFirstPositionOf(mark: Char): Position { forEachIndexed { index, row -> if ...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
3,052
advent-of-code
Apache License 2.0
src/Day16.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { val input = readInput("Day16") val dirs = listOf(0 to 1, 1 to 0, 0 to -1, -1 to 0) // east south west north fun solve(s0: Triple<Int,Int,Int>): Int { val visited = Array(input.size) { Array(input[it].length) { BooleanArray(4) } } v...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
2,397
advent-of-code-kotlin
Apache License 2.0
src/day19/a/day19a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day19.a import readInputLines import shouldBe import util.IntVector import vec import java.util.regex.Pattern import kotlin.math.max fun main() { val input = read() var answer = 0 input.forEach { answer += it.num * simulate(it, 24) } shouldBe(1266, answer) } fun simulate(bp: BluePrint, minute...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,969
advent-of-code-2022
Apache License 2.0
src/day12/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day12 import println import readInput fun main() { var UNKNOWN = '?' var WORKING = '.' var BROKEN = '#' fun findVariations(input: Pair<String, List<Int>>): Long { var map = input.first var blocks = input.second var cache = mutableMapOf<Triple<Int, Int, Int>, Long>() ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
2,636
advent-of-code-2023
Apache License 2.0
src/Day04.kt
geodavies
575,035,123
false
{"Kotlin": 13226}
fun String.toPairOfAssignments(): Pair<Pair<Int, Int>, Pair<Int, Int>> { val pairs = split(",") val assignment1 = pairs[0].split("-") val assignment2 = pairs[1].split("-") return (assignment1[0].toInt() to assignment1[1].toInt()) to (assignment2[0].toInt() to assignment2[1].toInt()) } fun isContained(f...
0
Kotlin
0
0
d04a336e412ba09a1cf368e2af537d1cf41a2060
1,762
advent-of-code-2022
Apache License 2.0
src/Day11.kt
AxelUser
572,845,434
false
{"Kotlin": 29744}
import java.util.* data class Monkey( val items: Queue<Long>, val operation: (old: Long) -> Long, val test: Long, val trueBranch: Int, val falseBranch: Int ) fun main() { fun List<String>.monkeys(): List<Monkey> { val res = mutableListOf<Monkey>() for (data in filter { it != "...
0
Kotlin
0
1
042e559f80b33694afba08b8de320a7072e18c4e
2,340
aoc-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2023/Day05.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2023 class Day05(input: List<String>) { private val seeds = input[0].split(' ').drop(1).map(String::toLong) private val mappings = input.drop(1).map { chunk -> chunk.lines() .drop(1) .map { line -> val values = line.split(' ').map...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
3,252
advent-of-code
Apache License 2.0
src/Day21.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution21(input: List<String>) { val monkeys = input .map { it.split(": ", " ") } .map { if (it.size == 2) Monkey(id = it[0], number = it[1].toLong()) else Monkey( id = it[0], operation = it[2], left = it[1], ...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
3,493
aoc-2022
Apache License 2.0
src/Day12.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
import kotlin.time.ExperimentalTime import kotlin.time.measureTime @OptIn(ExperimentalTime::class) fun main() { val input = readInput("Day12") val graph = Graph.create(input) val time = measureTime { val start = requireNotNull(graph.nodes.find { it.value == 'S' }) val stepsFromStart = bfs(...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
2,464
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day13/day13.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day13 import java.lang.RuntimeException fun part1(arrival: Int, buses: List<Int?>): Int { val departures = buses.filterNotNull() val longestBus = departures.maxOrNull() ?: throw RuntimeException("Wrong departures list") for (i in arrival until arrival + longestBus) { for (...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
2,803
advent-of-code-2020
Do What The F*ck You Want To Public License
src/Day13.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 405 private const val EXPECTED_2 = 400 private class Day13(isTest: Boolean) : Solver(isTest) { fun List<String>.transpose(): List<String> { val Y = this.size val X = this[0].length val res = List(X) { CharArray(Y) } for (y in 0 until Y) { f...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,156
advent-of-code-2022
Apache License 2.0
src/Day07.kt
nguyendanv
573,066,311
false
{"Kotlin": 18026}
fun main() { data class Node(val name: String) { private var sizeOfFiles: Int = 0 private val children: MutableMap<String, Node> = mutableMapOf() fun addFile(size: Int) { sizeOfFiles += size } val size: Int get() = sizeOfFiles + children.values.sumOf...
0
Kotlin
0
0
376512583af723b4035b170db1fa890eb32f2f0f
2,214
advent2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day13/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day13 import com.kingsleyadio.adventofcode.util.readInput import kotlin.math.max fun part1(dots: Set<Point>, command: Point): Int { return fold(dots, command).size } fun part2(dots: Set<Point>, commands: List<Point>): String { val folded = commands.fold(dots) { acc...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,709
adventofcode
Apache License 2.0
src/Day16.kt
zirman
572,627,598
false
{"Kotlin": 89030}
import kotlin.system.measureTimeMillis fun <T> permutation(xs: List<T>): List<List<T>> { return if (xs.isEmpty()) listOf(emptyList()) else xs.flatMapIndexed { index, s -> permutation(buildList { addAll(xs.subList(0, index)) addAll(xs.subList(index + 1, xs.size)) }).map {...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
8,447
aoc2022
Apache License 2.0
src/main/kotlin/com/dmc/advent2022/Day08.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
//--- Day 8: Treetop Tree House --- /* Each tree is represented as a single digit whose value is its height, where 0 is the shortest and 9 is the tallest. A tree is visible if all of the other trees between it and an edge of the grid are shorter than it. Only consider trees in the same row or column; that is, only loo...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
5,226
aoc-2022-kotlin
Apache License 2.0
2022/16/16.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
import java.util.PriorityQueue data class State( var time: Int, var current: String, var elTime: Int? = null, var elephant: String? = null, var opened: Set<String> = setOf(), var flow: Int = 0, ) : Comparable<State> { override fun compareTo(other: State) = compareVal...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
2,487
adventofcode
Apache License 2.0
src/Day03.kt
cnietoc
572,880,374
false
{"Kotlin": 15990}
fun main() { fun part1(input: List<String>): Long { return input.map { Rucksack(it) }.sumOf { it.type.priority } } fun part2(input: List<String>): Long { return input.map { Rucksack(it) }.fold(mutableListOf()) { badges: MutableList<Badge>, rucksack: Rucksack -> if (badges.isEmpt...
0
Kotlin
0
0
bbd8e81751b96b37d9fe48a54e5f4b3a0bab5da3
1,789
aoc-2022
Apache License 2.0
src/Day11.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.MoreMath.lcm import util.readInput import kotlin.math.floor fun main() { fun part1(input: List<String>): Long { val monkeys = parseInput(input) for (round in (1..20)) { for (monkey in monkeys) { while (monkey.items.isNotEmpty()) { monkey....
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
3,121
aoc-2022
Apache License 2.0