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/year2015/day21/Day21.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day21 import readInput import kotlin.math.max fun main() { val input = readInput("2015", "Day21") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val (bossInitialHP, bossDmg, bossArmor) = input.map { it.split(' ').last().toInt() } val c...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,756
AdventOfCode
Apache License 2.0
src/2022/Day18.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun part1(input: List<String>): Int { val drops = input.map { val (x, y, z) = it.split(",").map(String::toInt) Point3(x, y, z) }.toSet() return drops.sumOf { drop -> drop.slideNeighbors().filter { !drops.con...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
2,158
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day7.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser import kotlin.math.pow fun Char.toCardValue(jValue: Int): Int { return when (this) { 'T' -> 10 'J' -> jValue 'Q' -> 12 '...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
2,875
aoc-2023
The Unlicense
src/com/kingsleyadio/adventofcode/y2023/Day11.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput import java.util.* fun main() { part1() part2() } private fun part1() = fastEvaluate(2) private fun part2() = fastEvaluate(1_000_000) private fun fastEvaluate(expansion: Int) { val (world, planets) = buildMo...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
3,393
adventofcode
Apache License 2.0
src/Day04.kt
ktrom
573,216,321
false
{"Kotlin": 19490, "Rich Text Format": 2301}
fun main() { fun part1(input: List<String>): Int { return input.map { line -> val intervals: List<IntRange> = transformIntoIntervals(line) isSubInterval(intervals[0], intervals[1]) || isSubInterval(intervals[1], intervals[0]) }.sumOf { var hasSubInterval = 0 if (it) { hasSubInterval = 1 ...
0
Kotlin
0
0
6940ff5a3a04a29cfa927d0bbc093cd5df15cbcd
1,882
kotlin-advent-of-code
Apache License 2.0
src/Day08.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
import kotlin.math.max fun main() { fun List<Int>.determine(): List<Boolean> { var curMax = -1 val asc = this.map { (it > curMax).apply { curMax = max(it, curMax) } } curMax = -1 val desc = this.reversed().map { (it > curMax).apply { curMax = max(it, curMax) } }.reversed() ...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
1,650
advent-of-code-kotlin
Apache License 2.0
src/day11/Code.kt
fcolasuonno
221,697,249
false
null
package day11 private val test = false fun main() { val parsed = if (test) listOf( setOf<Portable>(Microchip('H'), Microchip('L')), setOf<Portable>(Generator('H')), setOf<Portable>(Generator('L')), setOf<Portable>() ) else listOf( setOf<Portable>(Gene...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
6,709
AOC2016
MIT License
src/day13/Day13.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day13 import readInput fun main() { part1() part2() } data class Thing(val isInt: Boolean, val int: Int = -1, val list: List<Thing> = emptyList()) : Comparable<Thing> { override fun compareTo(other: Thing): Int { if (isInt && other.isInt) return int - other.int if (isInt) return T...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
2,450
advent-of-code-2022
Apache License 2.0
src/Day11.kt
zfz7
573,100,794
false
{"Kotlin": 53499}
fun main() { println(day11A(parseMonkeys(readFile("Day11")))) println(day11B(parseMonkeys(readFile("Day11")))) } fun parseMonkeys(input: String): List<Monkey> = input.split("\n\n").map { mk -> Monkey( items = mk.split("\n").filter{ it.contains("Starting items: ")}[0].split(" Starting ...
0
Kotlin
0
0
c50a12b52127eba3f5706de775a350b1568127ae
2,973
AdventOfCode22
Apache License 2.0
day-09/src/main/kotlin/SmokeBasin2nd.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private fun partOne(): Int { val map = readMap() return map.keys .filter { it.isLowestOfSurroundingPoints(map) } .sumOf { map[it]!! + 1 } } private fun partTwo(): Long { val map =...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
2,096
aoc-2021
MIT License
src/Day13.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
import java.util.* fun main() { fun decode(input: String): List<Any> { var groupStack = Stack<Int>() var numberQueue: Queue<Int> = LinkedList<Int>() var parts = mutableListOf<String>() val inner = input.substring(1, input.length - 1) inner.forEachIndexed { i, ch -> ...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
2,991
advent-of-code-kotlin-2022
Apache License 2.0
src/Day07.kt
timj11dude
572,900,585
false
{"Kotlin": 15953}
sealed class Node sealed class Container : Node() object Root : Container() data class Folder(val name: String, val container: Container) : Container() data class File(val size: Int) : Node() fun main() { fun Map<Container, List<Node>>.update(current: Container, node: Node) = (this + (current to ((this[current] ...
0
Kotlin
0
0
28aa4518ea861bd1b60463b23def22e70b1ed481
3,212
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day12/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day12 import java.io.File import java.util.PriorityQueue data class Hill(val row: Int, val col: Int, val height: Int) class Terrain(private val hills: List<List<Hill>>, val start: Hill, val end: Hill) { companion object { fun parse(str: String): Terrain { lateini...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
2,883
advent-of-code-2022
Apache License 2.0
src/Day08.kt
andrewgadion
572,927,267
false
{"Kotlin": 16973}
fun main() { fun parse(input: List<String>) = input.map { it.map(Char::digitToInt) } fun List<List<Int>>.top(colRow: Pair<Int, Int>) = (colRow.first - 1 downTo 0).map { this[it][colRow.second] } fun List<List<Int>>.bottom(colRow: Pair<Int, Int>) = (colRow.first + 1 .. lastIndex).map { this[i...
0
Kotlin
0
0
4d091e2da5d45a786aee4721624ddcae681664c9
1,931
advent-of-code-2022
Apache License 2.0
src/twentytwo/Day04.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentytwo fun main() { // test if implementation meets criteria from the description, like: val testInput = readInputLines("Day04_test") println(part1(testInput)) check(part1(testInput) == 2) println(part2(testInput)) check(part2(testInput) == 4) println("---") val input = read...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
3,030
advent-of-code-solutions
Apache License 2.0
src/main/kotlin/mkuhn/aoc/Day13.kt
mtkuhn
572,236,871
false
{"Kotlin": 53161}
package mkuhn.aoc import mkuhn.aoc.util.readInput import mkuhn.aoc.util.splitList fun main() { val input = readInput("Day13") println(day13part1(input)) println(day13part2(input)) } fun day13part1(input: List<String>): Int = input.splitList("").asSequence() .map { l -> l.map { parseNestedList...
0
Kotlin
0
1
89138e33bb269f8e0ef99a4be2c029065b69bc5c
1,982
advent-of-code-2022
Apache License 2.0
src/main/day15/Part1.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day15 import common.Point import readInput import kotlin.math.abs fun main() { val sensors = parseInput(readInput("day15/input.txt")) val rowToCheck = 2000000 val beaconsInRow = sensors.map { it.beacon }.filter { it.y == rowToCheck }.distinct().count() val positionsWithNoBeacon = coveredRowPos...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
2,433
aoc2022
Apache License 2.0
src/Day08.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
import kotlin.math.abs import kotlin.math.sign fun main() { val input = readInput("Day08") val grid = Grid.create(input) val visibleTrees = grid.map.entries.filter { entry -> entry.isVisibleIn(grid) } println("visible tree count ${visibleTrees.size}") val bestScenic = grid.map.entrie...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
2,173
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/com/dr206/2022/Day02.kt
dr206
572,377,838
false
{"Kotlin": 9200}
fun main() { fun part1(input: List<String>): Int { val strategyGuide = input .pairs<String>(" ") .map { Pair(it.first.toHand(), it.second.toHand()) } return strategyGuide.sumOf { getTotalPerHand(it) } } fun part2(input: List<String>): Int { val strategyGuide...
0
Kotlin
0
0
57b2e7227d992de87a51094a971e952b3774fd11
1,751
advent-of-code-in-kotlin
Apache License 2.0
src/main/kotlin/days/Day08.kt
Kebaan
573,069,009
false
null
package days import days.Day08.Tree import utils.Day import utils.Point import utils.readInput import utils.takeUntil fun main() { Day08.solve() } private typealias Forest = List<List<Tree>> object Day08 : Day<Int>(2022, 8) { data class Tree(val location: Point, val height: Int) { fun visibleThrough...
0
Kotlin
0
0
ef8bba36fedbcc93698f3335fbb5a69074b40da2
3,220
Advent-of-Code-2022
Apache License 2.0
src/Day08.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
fun main() { data class Tree(val size: Int, var visible: Boolean = false) data class TreeGrid(val trees: Array<Array<Tree>>) { val height = trees.size val width = trees.first().size fun getHorizontalSequence(index: Int) = trees[index].toList() fun getVerticalSequence(index: Int) ...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
3,029
advent-of-code-2022
Apache License 2.0
src/Day13.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
sealed interface DistressSignal : Comparable<DistressSignal> { override operator fun compareTo(other: DistressSignal): Int companion object { fun of(string: String): DistressSignal = if (string.startsWith('[')) DistressList.of(string) else DistressInt.of(string) } } data c...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
2,893
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/dmc/advent2022/Day12.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
//--- Day 12: Hill Climbing Algorithm --- package com.dmc.advent2022 import java.util.* class Day12 : Day<Int> { override val index = 12 override fun part1(input: List<String>): Int { val heightmap = parseInput(input) return heightmap.shortestPath(heightmap.start, heightmap.end)!! } ...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
3,220
aoc-2022-kotlin
Apache License 2.0
src/main/day16/day16.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day16 import kotlin.math.max import readInput const val START = "AA" val flowRegex = """(\d+)""".toRegex() val valveRegex = """[A-Z]{2}""".toRegex() var totalTime = 30 var maxPressureRelease = 0 var allValves: Map<String, Valve> = mapOf() var shortestPaths: MutableMap<String, MutableMap<String, Int>> = muta...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
3,209
aoc-2022
Apache License 2.0
src/year2023/day07/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day07 import arrow.core.NonEmptyList import arrow.core.identity import arrow.core.nonEmptyListOf import arrow.core.toNonEmptyListOrNull import utils.ProblemPart import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 7) runAlgorithm( ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
3,169
Advent-of-Code
Apache License 2.0
src/main/kotlin/aoc2023/Day13.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day13 { fun part1(input: String): Long = parseInput(input) .map { mirrorPattern -> calculateReflection(mirrorPattern.rows) to calculateReflection(mirrorPattern.cols) } .sumOf { (r, c) -> r * 100L + c } fun part2(input: String): Long = parseInput(input)...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
3,104
advent-of-code-2023
MIT License
src/day9/d9_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val edges = input.lines().map { parseEdge(it) }.flatMap { e -> listOf(e, Edge(e.to, e.from, e.distance)) } val nodes = edges.map { e -> e.from }.toSet() val nodeToIdx = nodes.toList().sorted().mapIndexed { i, n -> n to i }.toMap() val edgesMap = edges.groupBy { e -> nodeToIdx[e.fro...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,382
aoc2015
MIT License
src/day03/Day03.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day03 import println import readInput enum class Direction { BEFORE, AFTER } fun String.intVal(): Int { return this.toIntOrNull() ?: 0 } fun List<String>.sum(): Int { return this.sumOf { it.intVal() } } typealias Coordinates = Pair<Int, Int> typealias NumberMap = Map<Coordinates, Int> class PartP...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
2,829
advent-of-code-2023-kotlin
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2021/day04/day4.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day04 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val moves = readMoves(lines) val boards = readBoards(lines) val wonBoards = playBingo(moves, boards) ...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,818
advent-of-code
MIT License
src/commonMain/kotlin/advent2020/day21/Day21Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day21 data class Food(val ingredients: List<String>, val allergens: List<String>) fun part1(input: String): String { val foods = foods(input) val ingredients = foods.map { it.ingredients }.flatten() val unsafe = matches(foods).values.reduce(Set<String>::plus) val safe = ingredients...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
2,070
advent-of-code-2020
MIT License
src/Day08.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
fun main() { fun part1(input: List<String>): Int { var visibleTreesInside = (1 until input.lastIndex).sumOf { rowIndex -> val row = input[rowIndex] (1 until row.lastIndex).count { columnIndex -> val tree = row[columnIndex] when { (0...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
2,334
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day12.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day12 { fun part1(input: String): Long { val (rows, groups) = parseInput(input) return rows.zip(groups).sumOf { (r, c) -> calculateArrangements(r, c) } } fun part2(input: String): Long { val (rows, groups) = parseInput(input) val expandedRows = rows.ma...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
2,752
advent-of-code-2023
MIT License
src/Day08.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
data class Tree( val height: Int, val allToTheLeft: List<Int>, val allToTheTop: List<Int>, val allToTheRight: List<Int>, val allToTheBottom: List<Int>, ) { val isVisible: Boolean get() = listOf(allToTheLeft, allToTheTop, allToTheRight, allToTheBottom) .any { direction -> dire...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
2,015
advent-of-code-2022
Apache License 2.0
src/main/kotlin/twentytwentytwo/Day8.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import twentytwentytwo.Structures.Point2d import kotlin.math.sqrt typealias Tree = Pair<Point2d, Int> fun main() { val input = {}.javaClass.getResource("input-8.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val day = Day8(input) val columns = (0 until input[0].length).map ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
2,677
aoc202xkotlin
The Unlicense
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day08/Day08.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day08 import nerok.aoc.utils.Input import java.util.* import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun predictPairs(x: List<SortedSet<Char>>): MutableMap<SortedSet<Char>, Int> { val map = x.associateWith { -1 }.toMutableMap() map.forEach { ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
2,867
AOC
Apache License 2.0
src/Day04.kt
george-theocharis
573,013,076
false
{"Kotlin": 10656}
fun main() { fun part1(input: List<String>): Int = input .splitByLine() .mapToPairOfRanges() .sumOfPairsThatOverlapEntirely() fun part2(input: List<String>): Int = input .splitByLine() .mapToPairOfRanges() .sumOfPairsThatOverlap() val input = readInput("Day0...
0
Kotlin
0
0
7971bea39439b363f230a44e252c7b9f05a9b764
1,369
aoc-2022
Apache License 2.0
Advent-of-Code-2023/src/Day02.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day02" private const val PART1_TEST_FILE = "${AOC_DAY}_test_part1" private const val PART2_TEST_FILE = "${AOC_DAY}_test_part2" private const val INPUT_FILE = AOC_DAY private const val MAX_COLORS = 3 private data class Cube(val value: Int, val color: String) private val maxCubes = mapOf("...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
3,981
Advent-of-Code-2023
Apache License 2.0
src/Day08.kt
Yasenia
575,276,480
false
{"Kotlin": 15232}
fun main() { fun part1(input: List<String>): Int { val treeMatrix = input.map { line -> line.toCharArray().map { it.digitToInt() } } var visibleCount = 0 for (i in 1 until treeMatrix.lastIndex) { for (j in 1 until treeMatrix[i].lastIndex) { val height = treeMatri...
0
Kotlin
0
0
9300236fa8697530a3c234e9cb39acfb81f913ba
2,041
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
kmakma
574,238,598
false
null
fun main() { fun neighborsOf(coord: Coord2D, map: Map<Coord2D, Int>): List<Coord2D> { val neighbors = mutableListOf<Coord2D>() if (coord.x > 0) { val newCoord = coord.moved(-1, 0) if (map[newCoord]!! - map[coord]!! <= 1) neighbors.add(newCoord) } if (coord.y ...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
3,218
advent-of-kotlin-2022
Apache License 2.0
src/Day04.kt
hnuttin
572,601,761
false
{"Kotlin": 5036}
fun main() { val pairs = readInput("Day04_test") .map { rawPair -> rawPair.split(",") } .map { rawPair -> Pair(toRange(rawPair[0]), toRange(rawPair[1])) }; // part1(pairs) part2(pairs) // print(rangeOverlaps(Pair(2, 6), Pair(4, 8))); } fun part2(pairs: List<Pair<Pair<Int, Int>, Pair<Int, ...
0
Kotlin
0
0
53975ed6acb42858be56c2150e573cdbf3deedc0
1,347
aoc-2022
Apache License 2.0
src/Day15.kt
chbirmes
572,675,727
false
{"Kotlin": 32114}
import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>, row: Int): Int { val sensors = input.map { Sensor.parse(it) } val beaconXs = sensors.map { it.closestBeaconPosition } .filter { (_, y) -> y == row } .map { (x, _) -> x } .toSet() ...
0
Kotlin
0
0
db82954ee965238e19c9c917d5c278a274975f26
3,435
aoc-2022
Apache License 2.0
src/Day08.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
fun main() { infix fun Int.taller(trees: List<Int>): Boolean{ return trees.all{ it < this} } infix fun Int.visibleTrees(trees: List<Int>): Int{ if (this taller trees) return trees.size return trees.indexOfFirst{ it >= this} + 1 } fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
2,272
aoc22
Apache License 2.0
src/Day11.kt
xNakero
572,621,673
false
{"Kotlin": 23869}
object Day11 { fun part1() = solve(20) { level, _ -> level / 3} fun part2() = solve(10_000) {level, mod -> level % mod} private fun solve(rounds: Int, worryLevelStrategy: (Long, Long) -> (Long)): Long { val monkeys = parseInput() val modulus = monkeys.map { it.test.divisibleBy }.reduce(Lo...
0
Kotlin
0
0
c3eff4f4c52ded907f2af6352dd7b3532a2da8c5
2,296
advent-of-code-2022
Apache License 2.0
src/Day12.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
fun main() { operator fun List<CharArray>.get(point: Pair<Int, Int>) = this[point.first][point.second] fun neighbors( current: Pair<Int, Int>, input: List<CharArray>, validator: (Char, Char) -> Boolean, ) = listOf( current.copy(first = current.first - 1), current.cop...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
2,916
aoc-2022
Apache License 2.0
src/Day08.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val numbers = input.toIntMatrix() return countTrees(numbers) } fun part2(input: List<String>): Int { val numbers = input.toIntMatrix() return countScenic(numbers) } // ...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
2,717
aoc-2022
Apache License 2.0
src/Day08.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
fun Iterable<Int>.product() = fold(1) { acc, elt -> acc * elt } inline fun <T> Iterable<T>.productOf(selector: (T) -> Int) = fold(1) { acc, elt -> acc * selector(elt) } fun <T : List<U>, U> Iterable<T>.column(index: Int) = map { it[index] } inline fun <T : List<U>, U> Iterable<T>.columnOrElse(index: Int, defaultValue: ...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
1,631
advent-of-code-2022
Apache License 2.0
src/poyea/aoc/mmxxii/day24/Day24.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day24 import poyea.aoc.utils.readInput data class Point(val x: Int, val y: Int) { operator fun plus(other: Point) = Point(x + other.x, y + other.y) fun neighbours(): List<Point> { return listOf(1, 0, -1, 0, 1).zipWithNext().map { (dx, dy) -> Point(x + dx, y + dy) } } } d...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
3,443
aoc-mmxxii
MIT License
src/year_2023/day_11/Day11.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_11 import readInput import util.Point data class Universe( val galaxies: List<Point>, val horizontalExpansions: List<Int>, val verticalExpansions: List<Int> ) object Day11 { /** * */ fun distances(text: List<String>, age: Int): Long { val distances = muta...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,883
advent_of_code
Apache License 2.0
2021/src/day13/Day13.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day13 import readInput data class Point(val x: Int, val y: Int) sealed class Fold { data class Up(val y: Int) : Fold() data class Left(val x: Int) : Fold() } fun List<String>.toPoints() = filter { !it.contains("fold") }.map { val x = it.split(",")[0] val y = it.split(",")[1] Point(x.toInt...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,932
advent-of-code
Apache License 2.0
src/Day08.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
fun main() { class Forest(private val rows: List<List<Int>>) { private fun isVisible(r: Int, c: Int): Boolean = (0 until c).all { rows[r][it] < rows[r][c] } || (c + 1 until rows[0].size).all { rows[r][it] < rows[r][c] } || (0 until r).all { rows[it][c] < r...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,622
aoc-2022
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day19/day19.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day19 import eu.janvdb.aocutil.kotlin.readGroupedLines //const val FILENAME = "input19-test.txt" const val FILENAME = "input19.txt" val VARIABLES = listOf("x", "m", "a", "s") const val MIN_VALUE = 1 const val MAX_VALUE = 4000 fun main() { val lines = readGroupedLines(2023, FILENAME) ...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
4,730
advent-of-code
Apache License 2.0
src/twentytwentythree/day07/Day07.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day07 import readInput import kotlin.math.max enum class HandType(val value: Int) { FIVE_OF_A_KIND(7), FOUR_OF_A_KIND(6), FULL_HOUSE(5), THREE_OF_A_KIND(4), TWO_PAIR(3), ONE_PAIR(2), HIGH_CARD(1), } class Card(private val value: Char) : Comparable<Card> { override fun compar...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
2,583
advent-of-code
Apache License 2.0
src/day13/Day13_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day13 import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ sealed class PacketV2 : Comparable<PacketV2...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
3,055
aoc2022
Apache License 2.0
src/Day08.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
data class Pos(val x: Int, val y: Int) fun main() { fun List<String>.atPos(pos: Pos): Int = this[pos.y][pos.x].digitToInt() fun visible(input: List<String>, pos: Pos, maxX: Int, maxY: Int): Boolean { val tree = input.atPos(pos) return (pos.x - 1 downTo 0).all { tree > input.atPos(Pos(it, pos....
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
2,362
aoc2022
Apache License 2.0
advent-of-code-2023/src/Day08.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day08" fun main() { fun input() = readInput(DAY) "Part 1" { fun testInput0() = readInput("${DAY}_test0") fun testInput1() = readInput("${DAY}_test1") part1(testInput0()) shouldBe 2 part1(testInput1()) shouldBe 6 measureAnswer { part1(input()) }...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,189
advent-of-code
Apache License 2.0
src/day15/Day15.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day15 import readInput import kotlin.math.abs fun dist(fst: Pair<Int, Int>, snd: Pair<Int, Int>): Int = abs(fst.first - snd.first) + abs(fst.second - snd.second) fun Pair<Int, Int>.add(x: Pair<Int, Int>) = Pair(this.first + x.first, this.second + x.second) fun Pair<Int, Int>.multiplyPairwise(x: Pair<Int, Int...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
3,262
advent-of-code-2022
Apache License 2.0
2021/src/day14/Day14.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day14 import readInput fun List<String>.toPairInsertions() : Map<String, String> { val map = mutableMapOf<String, String>() filter { it.contains("->") }.forEach { map[it.substringBefore("->").trim()] = it.substringAfter("->").trim() } return map } fun applyStep(start: String, pairs: M...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,924
advent-of-code
Apache License 2.0
src/main/kotlin/com/hopkins/aoc/day2/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day2 import java.io.File const val debug = false const val part = 2 val maxCubes = CubeInfo(red = 12, green = 13, blue = 14) /** Advent of Code 2023: Day 2 */ fun main() { val inputFile = File("input/input2.txt") if (debug) { println("Max Cubes: $maxCubes") } // Extra...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
2,995
aoc2023
MIT License
src/main/kotlin/solutions/day24/Day24.kt
Dr-Horv
112,381,975
false
null
package solutions.day24 import solutions.Solver data class Component(val port1: Int, val port2: Int) { override fun toString(): String { return "$port1/$port2" } } fun List<Component>.strength(): Int = this.sumBy { it.port1 + it.port2 } class Day24: Solver { override fun solve(input: List<Strin...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
3,167
Advent-of-Code-2017
MIT License
lib/src/main/kotlin/com/bloidonia/advent/day12/Day12.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day12 import com.bloidonia.advent.readList fun String.isUpper() = this.first().isUpperCase() fun String.isLower() = this.first().isLowerCase() class CaveSystem(private val routes: Map<String, List<String>>) { fun next(path: List<String>, check: (List<String>, String) -> Boolean) = ...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,941
advent-of-kotlin-2021
MIT License
src/Day04.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
fun main() { fun part1(input: List<String>): Int { return input.map {elves -> elves.replace(',', '-').split('-').map { it.toInt() } } .count{edges -> (((edges[2] >= edges[0]) and (edges[1] >= edges[3] )) or ((edges[0] >= edges[2]) and (edges[3] >= edges[1] )))} // learned ab...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
1,532
aoc22
Apache License 2.0
src/main/kotlin/dev/tasso/adventofcode/_2021/day09/Day09.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day09 import dev.tasso.adventofcode.Solution class Day09 : Solution<Int> { override fun part1(input: List<String>): Int { val heightMap = input.map{ row -> row.toCharArray().map { it.digitToInt() }.toTypedArray() }.toTypedArray() return getLowPointCoordinates...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
2,499
advent-of-code
MIT License
src/Day07.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
fun main() { val input = readInput("Day07") fun String.parse(): Triple<Map<Char, Int>, Long, String> { val (hand, bid) = split(" ").let { it[0] to it[1].toLong() } val h = mutableMapOf<Char, Int>() for (c in hand) { h[c] = 1 + (h[c] ?: 0) } ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
3,051
aoc-2023
Apache License 2.0
src/day13/Day13.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day13 import readInput fun main() { println(solve1(parse(readInput("day13/test")))) println(solve1(parse(readInput("day13/input")))) println(solve2(parse(readInput("day13/test")))) println(solve2(parse(readInput("day13/input")))) } fun compare(left: Element, right: Element): Int { fun c...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
2,787
aoc-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2018/Day7.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2018 object Day7 { val dependency = """Step (\w) must be finished before step (\w) can begin\.""".toRegex() data class Requirement(val prereq: Char, val downstream: Char) fun part1(requirements: List<String>): String { val reqAsMap = parseReq(requirements) re...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,344
adventofcode
MIT License
src/day16/Day16.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day16 import readInput import readTestInput private data class Valve( val flowRate: Long, val tunnelsTo: Set<String>, ) private typealias Valves = Map<String, Valve> private fun List<String>.toValves(): Valves { val regex = """Valve (\w+) has flow rate=(\d+);.*valves? (\w+(, \w+)*)""".toRegex() ...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
5,533
advent-of-code-kotlin-2022
Apache License 2.0
src/day8/Day08.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day8 import readInput fun main() { fun part1(input: List<String>): Int { val matrix = input.toMatrix() var visibleTreesCount = 0 val visibleTrees = mutableListOf<String>() matrix.forEachIndexed { i, line -> line.forEachIndexed { j, tree -> val co...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
2,748
AdventOfCode2022
Apache License 2.0
src/year2022/day15/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day15 import io.kotest.matchers.shouldBe import kotlin.math.max import utils.Point import utils.manhattanDistanceTo import utils.plusOrMinus import utils.readInput import utils.size fun main() { val testEmptySpots = readInput("15", "test_input").toSensors().computeEmptySpots() val emptySpots ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,798
Advent-of-Code
Apache License 2.0
src/year2023/Day13.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import Grid import readLines fun main() { val input = parseInput(readLines("2023", "day13")) val testInput = parseInput(readLines("2023", "day13_test")) check(part1(testInput) == 405) println("Part 1:" + part1(input)) check(part2(testInput) == 400) println("Part 2:" + part2(...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
3,098
advent_of_code
MIT License
src/day24/d24_1.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val list = input.lines().map { it.toInt() } val groupSize = list.sum() / 3 val firstGroup = solve(list, groupSize) // order by quantum entanglement and find smallest one for which // the rest of packages can be divided in two groups of the same weight val candidates = firstGrou...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,416
aoc2015
MIT License
src/Day12.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
fun main() { fun parseInput(input: List<String>): List<List<Tile>> = input .map { line -> line.map { it } } .let { map -> map.mapIndexed { rowIndex, row -> row.mapIndexed { index, char -> Tile( x = index, ...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
2,665
advent-of-code-2022
Apache License 2.0
src/day15/Day15.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day15 import readInput import kotlin.math.abs private const val DAY_ID = "15" private data class Point( val x: Int, val y: Int ) { companion object { fun fromString(s: String): Point { // example: x=-2, y=15 val (x, y) = s.split(", ").map { it.substringAfter("=").t...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
3,251
aoc-2022-in-kotlin
Apache License 2.0
src/Day12.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
import java.util.PriorityQueue fun main() { val startChar = 'S' val endChar = 'E' fun getHeight(height: Char) = when(height){ endChar -> 'z' startChar -> 'a' else -> height } fun shortestPathToEnd(priorityQueue: PriorityQueue<Step>, input: List<String>): Int { val ...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
2,709
advent-of-code-2022
Apache License 2.0
src/Day08.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private fun getGrid(input: List<String>) = input.map { it.map(Char::digitToInt).toTypedArray() }.toTypedArray() private fun observeLines(grid: Array<Array<Int>>, res: Array<BooleanArray>, lineInds: IntRange, rowInds: IntProgression) { val maxRowInd = if (rowInds.isRange()) 0 else grid.first().size - 1 for (i ...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
2,750
advent-of-code-kotlin
Apache License 2.0
src/Day15.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
import lib.Coordinates import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min fun IntRange.clamp(minimum: Int, maximum: Int) = max(minimum, first)..min(maximum, last) fun Set<IntRange>.consolidate(): Set<IntRange> { var result = this var lastCount: Int do { lastCount = res...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
3,857
advent-of-code-in-kotlin-2022
Apache License 2.0
src/day15/Day15.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day15 import java.io.File import kotlin.math.abs fun main() { val regexp = Regex("Sensor at x=(-?\\d*), y=(-?\\d*): closest beacon is at x=(-?\\d*), y=(-?\\d*)") val sensors = File("src/day15/input.txt").readLines() .map { regexp.matchEntire(it)!!.groupValues } .map { values -> ...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
2,989
advent-of-code-2022
MIT License
src/year2020/day05/Day05.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day05 import util.assertTrue import util.read2020DayInput import kotlin.math.roundToInt fun main() { val input = read2020DayInput("Day05") assertTrue(task01(input) == 801) assertTrue(task02(input) == 597) } private fun task02(input: List<String>): Int { val sortedSeats = inpu...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,871
advent-of-code-kotlin-template
Apache License 2.0
src/Day08.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
import kotlin.math.max fun main() { val testInput = readInput("Day08_test") check(part1(testInput) == 21) check(part2(testInput) == 8) val input = readInput("Day08") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val trees = parseTrees(input) ...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
2,474
aoc-22
Apache License 2.0
src/Day13.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day13 { private fun ordered(l: MutableList<Char>, r: MutableList<Char>): Boolean { fun MutableList<Char>.addBrackets(len: Int) = apply { add(len, ']'); add(0, '[') } fun List<Char>.num(): Int? = if (!this.first().isDigit()) null else this.takeWhile { it.isDigit() }.joinToString(""...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
1,862
aoc-22-kotlin
Apache License 2.0
src/main/kotlin/advent/of/code/day06/Solution.kt
brunorene
160,263,437
false
null
package advent.of.code.day06 import java.io.File import kotlin.math.abs data class Point(val x: Int, val y: Int) { fun distance(b: Point) = abs(x - b.x) + abs(y - b.y) } val input: List<Point> = File("day06.txt").readLines().map { val parts = it.split(",") Point(parts[0].trim().toInt(), parts[1].trim()....
0
Kotlin
0
0
0cb6814b91038a1ab99c276a33bf248157a88939
2,267
advent_of_code_2018
The Unlicense
src/Day08.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
class Day08(private val input: List<String>) { private val forest = parseInput(input) private fun isVisible(x: Int, y: Int, height: Int): Boolean = requiredIndices(x, y) .any { pairs -> pairs.all { (cx, cy) -> forest[cy][cx] < height } } private fun ...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
2,341
advent-of-code-2022-kotlin
Apache License 2.0
src/Day12.kt
Excape
572,551,865
false
{"Kotlin": 36421}
import util.UnweightedGraph fun main() { val directions = listOf(Pair(1, 0), Pair(-1, 0), Pair(0, 1), Pair(0, -1)) fun inBounds(input: List<String>, p: Point) = p.x >= 0 && p.y >= 0 && p.y <= input.lastIndex && p.x <= input[p.y].lastIndex fun getElevation(input: List<String>, point: Point): Char ...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
2,376
advent-of-code-2022
Apache License 2.0
src/Day13.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import utils.Tree import java.util.Stack import kotlin.math.min import kotlin.math.sign fun buildTree(input: String): Tree<Int> { val stack = Stack<Tree<Int>>() val root = Tree<Int>() var currentValue = 0 var hasValue = false var currentNode = root for (c in input) { when (c) { ...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
2,941
Advent-Of-Code-2022
Apache License 2.0
src/aoc2018/kot/Day18.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import java.io.File object Day18 { fun partOne(input: List<String>): Int { var grid = parse(input) repeat(10) { grid = nextGeneration(grid) } return grid.sumBy { it.count { it == '|' } } * grid.sumBy { it.count { it == '#' } } } fun partTwo(input: List<String>): Int { ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
2,272
Advent_of_Code
MIT License
src/Day08.kt
paulbonugli
574,065,510
false
{"Kotlin": 13681}
class Forest(private val trees : List<List<Int>>) { private val maxX : Int = trees.first().size-1 private val maxY : Int = trees.size-1 private fun getSurroundings(x : Int, y : Int) : Array<List<Int>> { val left = trees[y].slice(0 until x).reversed() val right = trees[y].slice((x + 1)..max...
0
Kotlin
0
0
d2d7952c75001632da6fd95b8463a1d8e5c34880
2,162
aoc-2022-kotlin
Apache License 2.0
advent-of-code-2022/src/Day15.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import kotlin.math.abs fun main() { val testInput = readInput("Day15_test") val input = readInput("Day15") "Part 1" { part1(testInput, targetY = 10) shouldBe 26 answer(part1(input, targetY = 2_000_000)) } "Part 2" { part2(testInput, max = 20) shouldBe 56000011 answ...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,440
advent-of-code
Apache License 2.0
src/year2023/day05/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2023.day05 import java.util.stream.LongStream import year2023.solveIt fun main() { val day = "05" val expectedTest1 = 35L val expectedTest2 = 46L fun part1(input: List<String>): Long { val map = input.joinToString("\n").split("\n\n").map { it.split("\n") } val seeds =...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
1,902
adventOfCode
Apache License 2.0
src/day02/Day02.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day02 import kotlin.math.max import println import readInput data class Colors(val red: Int, val green: Int, val blue: Int) { fun product(): Int { return red * green * blue } } data class Game(val id: Int, val rounds: List<Colors>) val limit = Colors(12, 13, 14) class CubeConundrum(val input: List<...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
1,890
advent-of-code-2023-kotlin
Apache License 2.0
src/Day16.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
import java.util.PriorityQueue interface Graph<T> { fun neighbors(node: T): List<Pair<Int, T>> } interface FiniteGraph<V> : Graph<V> { val nodes: Set<V> } fun <T> dijkstra( graph: Graph<T>, start: Collection<T>, goal: (T) -> Boolean, ): Pair<Int, List<T>>? { val visited = mutableSetOf<T>() ...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
8,317
advent-of-code-2022
Apache License 2.0
src/day16/Day16.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day16 import readInput import kotlin.math.max fun main() { val testInput = readInput("day16/test") val regex = """Valve ([A-Z]+) has flow rate=(\d+); tunnels* leads* to valves* ([A-Z\s,]+)""".toRegex() val valveDataMap = HashMap<String, Valve>() testInput.forEach { val result = regex.m...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
3,627
advent-of-code-2022
Apache License 2.0
src/Day12.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
import java.io.File fun main() { val testInput = """Sabqponm abcryxxl accszExk acctuvwj abdefghi""" val realInput = File("src/Day12.txt").readText() val part1TestOutput = fewestSteps(testInput) { it == 'S' } println("Part 1 Test Output: $part1TestOutput") check(part1TestOutput == 31) val part1RealOutput ...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
3,047
advent-of-code-2022
Apache License 2.0
src/Day08.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { val grid = input.map { it.toCharArray() }.map { chars -> chars.map { it.digitToInt() } } val width = grid.first().size val length = grid.size val visible = Array(length) { BooleanArray(width) } fun di...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
3,426
advent-of-code-2022
Apache License 2.0
src/aoc2022/Day15.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min private class Day15(val lines: List<String>) { val sensors = lines.map { it.removePrefix("Sensor at ").allInts() } .map { Sensor(Coord.xy(it[0], it[1]), Coord.xy(it[2], it[3])) } .toList() data class Sens...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
2,332
aoc2022
Apache License 2.0
src/Day04.kt
RichardLiba
572,867,612
false
{"Kotlin": 16347}
fun main() { fun fullyContainsOther(a: Pair<Int, Int>, b: Pair<Int, Int>): Boolean { return a.first <= b.first && a.second >= b.second } fun intersecting(a: Pair<Int, Int>, b: Pair<Int, Int>): Boolean { return a.first <= b.second && b.first <= a.second } fun intersecting(a: Pair<St...
0
Kotlin
0
0
6a0b6b91b5fb25b8ae9309b8e819320ac70616ed
2,306
aoc-2022-in-kotlin
Apache License 2.0
src/day09/Day09.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day09 import println import readInput import kotlin.system.measureTimeMillis data class Position(val x: Int, val y: Int) typealias Grid = List<List<Int>> fun main() { fun List<String>.parseGrid() = map { row -> row.map { it.toString().toInt() } } fun Grid.withinBounds(it: Position) = it.x >= 0 && i...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
2,677
advent-of-code-2021
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-15.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2015, "15-input") val test1 = readInputLines(2015, "15-test1") println("Part1:") part1(test1).println() p...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,970
advent-of-code
MIT License
src/year2022/day11/Day11.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day11 import check import readInput import java.util.LinkedList fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day11_test") check(part1(testInput), 10605) check(part2(testInput), 2713310158L) val input = readIn...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,932
AdventOfCode
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day10.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution object Day10 : AdventSolution(2016, 10, "Balance Bots") { override fun solvePartOne(input: String): Int? { val (chips, lowInstr, highInstr) = parse(input) while (chips.values.any { it.size > 1 }) { step(chips, lowInstr, ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,472
advent-of-code
MIT License
src/Day12.kt
sungi55
574,867,031
false
{"Kotlin": 23985}
import java.util.* fun main() { val day = "Day12" val testGraph: Graph = readInput(name = "${day}_test").asGraph() val graph: Graph = readInput(name = "Day12").asGraph() fun part1(graph: Graph): Int = graph.bfs( start = graph.start, isComplete = { it == graph.destination }, is...
0
Kotlin
0
0
2a9276b52ed42e0c80e85844c75c1e5e70b383ee
2,661
aoc-2022
Apache License 2.0
src/day04/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day04 import readInput fun main() { val input = readInput("day04") println(solvePartTwo(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Int { val winners = calculateBingoWinners(input) return winners.first().sum } fun solvePartTwo(input: List<String>): Int {...
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
3,493
aoc-2021
Apache License 2.0