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/aoc2022/day08/AoC08.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day08 import readLines data class P(val x: Int, val y: Int) class Grid(private val lines: List<String>) { val xRange = lines[0].indices val yRange = lines.indices operator fun get(x: Int, y: Int) = lines[y][x] operator fun get(p: P) = lines[p.y][p.x] private fun Iterable<Int>.countUntil(predic...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
1,927
aoc2022
Apache License 2.0
day11/src/main/kotlin/com/lillicoder/adventofcode2023/day11/Day11.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day11 import com.lillicoder.adventofcode2023.grids.Grid import com.lillicoder.adventofcode2023.grids.GridParser import com.lillicoder.adventofcode2023.grids.Node fun main() { val day11 = Day11() val grid = GridParser().parseFile("input.txt").first() println("The sho...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
2,875
advent-of-code-2023
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2022/day11/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day11 import com.kingsleyadio.adventofcode.util.readInput fun main() { solution(loadMonkeys(), 20, true) solution(loadMonkeys(), 10_000, false) } fun solution(monkeys: List<Monkey>, rounds: Int, divisibleBy3: Boolean) { val monkeyOps = IntArray(monkeys.size) ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,658
adventofcode
Apache License 2.0
kotlin/src/x2022/day8/day8.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day8 import readInput enum class Direction { Up, Down, Right, Left } data class Tree(val height: Int, val views: Map<Direction, List<Int>>) { fun visible(): Boolean { return views.any { (_, v) -> v.isEmpty() || v.all { it < height } } } fun locationValue(): Int { return views...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
2,920
adventOfCode
Apache License 2.0
src/Day11.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun monkeys(): List<Monkey> { return readInput("Day11").filter { it.isNotBlank() }.map(String::trim).chunked(6).mapIndexed { i, s -> val items = s[1].substring("Starting items: ".length).split(", ").map(String::toLong).toMutableList() val ops = s[2].substring("Operation: new = old ".length)....
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
2,223
advent-of-code-2022
Apache License 2.0
src/year_2023/day_07/Day07.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_07 import readInput enum class HandType(val strength: Int) { FiveOfAKind(6), FourOfAKind(5), FullHouse(4), ThreeOfAKind(3), TwoPair(2), OnePair(1), HighCard(0), ; companion object { fun fromString(text: String, jIsJoker: Boolean): HandType { ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,735
advent_of_code
Apache License 2.0
src/main/kotlin/aoc2023/Day15.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput private data class Lense(val label: String, var focalLength: Int) private data class Box(val lenses: MutableList<Lense> = mutableListOf()) object Day15 { private fun hash(input: String): Int { var currentValue = 0 input.forEach { char -> currentValue...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,133
adventOfCode
Apache License 2.0
src/Day04.kt
krisbrud
573,455,086
false
{"Kotlin": 8417}
typealias Range = Pair<Int, Int> fun main() { fun parseLine(line: String): List<Range> { // Split on comma val ranges = line.split(",").map { val (first, second) = it.split("-").take(2) Range(first.toInt(), second.toInt()) } return ranges } fun conta...
0
Kotlin
0
0
02caf3a30a292d7b8c9e2b7788df74650e54573c
1,674
advent-of-code-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day04/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day04 import com.kingsleyadio.adventofcode.util.readInput fun solution(numbers: List<Int>, boards: MutableList<Board>, exitFirst: Boolean): Int { for (number in numbers) { val iterator = boards.iterator() for (board in iterator) { board.asSeq...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,910
adventofcode
Apache License 2.0
src/main/kotlin/day17/Day17.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day17 import java.io.File import kotlin.math.absoluteValue import kotlin.math.min import kotlin.math.sqrt fun parseInput(line: String): Pair<IntRange, IntRange> { val rawXRange = line.split("x=")[1].split(",")[0] val rawYRange = line.split("y=")[1] val (minX, maxX) = rawXRange.split("..").map(String::to...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
4,160
advent-of-code-2021
MIT License
src/Day05.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
object Day05 { class State(val stacks: List<List<Char>>) { companion object { fun fromString(input: String): State { val lines = input.lines() // Get the number of stacks val n = lines .last() .split(" ") ...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
2,602
aoc22-kt
Apache License 2.0
src/Day07.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
private class Node7 private constructor(val name: String, val intrinsicSize: Int? = null, val parent: Node7? = null) : Iterable<Node7> { private val children: MutableList<Node7> = mutableListOf() val totalSize: Int get() = (intrinsicSize ?: 0) + children.sumOf { it.totalSize } operator fun get(childName: S...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
2,484
advent-of-code-in-kotlin-2022
Apache License 2.0
src/Day09.kt
Excape
572,551,865
false
{"Kotlin": 36421}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Point(val x: Int, val y: Int) { fun move(move: Pair<Int, Int>) = Point(x + move.first, y + move.second) fun follow(other: Point): Point { if (this == other) { return this } v...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
2,367
advent-of-code-2022
Apache License 2.0
archive/2022/Day12.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import java.util.* private const val EXPECTED_1 = 31 private const val EXPECTED_2 = 29 private const val MAX = 100000 private val DIRS = listOf(1 to 0, -1 to 0, 0 to 1, 0 to -1) /** * Day12 implementation using Dijkstra's */ private class Day12(isTest: Boolean) : Solver(isTest) { var start = 0 to 0 var end...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,860
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day22.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* import kotlin.math.max import kotlin.math.min fun main() { val input = Input.day(22) println(day22A(input)) println(day22B(input)) } fun day22A(input: Input): Int { val bricks = input.lines.map(Brick::init) bricks.fall() return bricks.count { brick -> bricks.none { b ->...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
2,093
AdventOfCode2023
MIT License
src/day10/Day10.kt
spyroid
433,555,350
false
null
package day10 import readInput import kotlin.math.absoluteValue import kotlin.system.measureTimeMillis fun main() { val pairs = mapOf('}' to '{', '>' to '<', ')' to '(', ']' to '[') val scores = mapOf('}' to 1197L, '>' to 25137L, ')' to 3L, ']' to 57L) val scores2 = mapOf('{' to 3L, '<' to 4L, '(' to 1L,...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
1,812
Advent-of-Code-2021
Apache License 2.0
src/Day14.kt
palex65
572,937,600
false
{"Kotlin": 68582}
private data class Point(val x: Int, val y: Int) private enum class Material(val symbol: Char){ ROCK('#'), SAND('o'), PATH('~') } private fun Scan(lines: List<String>): MutableMap<Point,Material> { val res = mutableMapOf<Point,Material>() lines.forEach { path -> var start: Point? = null path.s...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
2,831
aoc2022
Apache License 2.0
src/Day03.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
fun main() { fun part1(input: List<String>): Int { val letterToPriority: (Char) -> Int = { letter -> (if (letter in 'a'..'z') (letter.code - 97) else (letter.code - 39)) + 1 } var sum = 0 for ((index: Int, line: String) in input.withIndex()) { val pack1 = HashSet<Cha...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
1,943
advent-of-code-2022
Apache License 2.0
advent23-kt/app/src/main/kotlin/dev/rockyj/advent_kt/Day7.kt
rocky-jaiswal
726,062,069
false
{"Kotlin": 41834, "Ruby": 2966, "TypeScript": 2848, "JavaScript": 830, "Shell": 455, "Dockerfile": 387}
package dev.rockyj.advent_kt private val cardRanking = "A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2".split(",") .map { it.trim() } .filter { it != "" } .reversed() private val cardRanking2 = "A, K, Q, T, 9, 8, 7, 6, 5, 4, 3, 2, J".split(",") .map { it.trim() } .filter { it != "" } .reversed() priva...
0
Kotlin
0
0
a7bc1dfad8fb784868150d7cf32f35f606a8dafe
9,454
advent-2023
MIT License
src/Day03.kt
Kbzinho-66
572,299,619
false
{"Kotlin": 34500}
fun main() { operator fun String.component1() = this.subSequence(0, this.length / 2).toSet() operator fun String.component2() = this.subSequence(this.length / 2, this.length).toSet() fun priority(char: Char): Int { return when (char) { in 'a'..'z' -> char - 'a' + 1 in 'A'..'...
0
Kotlin
0
0
e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b
1,737
advent_of_code_2022_kotlin
Apache License 2.0
day19/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Part Two --- // Even with your help, the sorting process still isn't fast enough. // // One of the Elves comes up with a new plan: rather than sort parts // individually through all of these workflows, maybe you can figure out in // advance which combinations of ratings will be accepted or rejected. // // Each o...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
4,656
adventofcode2023
MIT License
src/main/kotlin/adventofcode/year2020/Day20JurassicJigsaw.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.product class Day20JurassicJigsaw(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val tiles by lazy { input.split("\n\n").map(::Tile) } override fun partOne(): Long { ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
3,678
AdventOfCode
MIT License
src/main/kotlin/aoc2023/Day12.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput private class SpringRow(private val springs: String, damagedGroups: IntArray) { companion object { fun fromString(input: String): SpringRow { val split = input.split(" ") return SpringRow(split[0], split[1].split(",").map { it.toInt() }.toIntArray()...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,415
adventOfCode
Apache License 2.0
src/main/kotlin/aoc2021/Day09.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput private class HeightMap(input: List<String>) { // heightmap is internally represented as a 2D Byte array private val data = input.map { str -> str.map { it.digitToInt().toByte() }.toByteArray() }.toTypedArray() /** * all the 'low points' in this height map */ ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,687
adventOfCode
Apache License 2.0
src/twentytwo/Day03.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("Day03_test") println(part1(testInput)) check(part1(testInput) == 157) println(part2(testInput)) check(part2(testInput) == 70) println("---") val input = re...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
3,001
advent-of-code-solutions
Apache License 2.0
src/Day12.kt
JIghtuse
572,807,913
false
{"Kotlin": 46764}
package day12.aoc import readInput typealias Position = Pair<Int, Int> fun List<String>.at(p: Position): Char? { if (p.first < 0 || p.first > this.lastIndex) return null if (p.second < 0 || p.second > this[0].lastIndex) return null return this[p.first][p.second] } fun findPosition(input: List<String>, ...
0
Kotlin
0
0
8f33c74e14f30d476267ab3b046b5788a91c642b
3,940
aoc-2022-in-kotlin
Apache License 2.0
src/day11/Day11.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day11 import readInput import java.util.LinkedList fun main() { println( solve1(testMonkeys())) println( solve1(taskMonkeys())) println( solve2(testMonkeys())) println( solve2(taskMonkeys())) } typealias Action = (Long) -> Unit class Monkey(val name: String, initial: List<Long...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
3,534
aoc-2022
Apache License 2.0
src/main/kotlin/day9/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day9 import util.readTestInput import kotlin.math.abs enum class Direction(val symbol: String, val dx: Int, val dy: Int) { LEFT("L", -1, 0), RIGHT("R", 1, 0), UP("U", 0, -1), DOWN("D", 0, 1) } data class Move(val direction: Direction, val amount: Int = 1) { companion object { fun parse(st...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
3,073
advent-of-code-2022
MIT License
kotlin/src/x2022/day11/day11.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day11 import readInput enum class MathOperation { Multiply, Divide, Subtract, Add; } // -1 == old value data class Operation(val op: MathOperation, val value: Long, val useOld: Boolean) { fun compute(input: Long): Long { val v = when (useOld) { true -> input ...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
4,204
adventOfCode
Apache License 2.0
src/Day09.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
fun List<Long>.extrapolate(): List<List<Long>> { return (1..<this.size).map { i -> this[i] - this[i - 1] }.let { if (it.all { it == 0L }) listOf(this) else mutableListOf(this).apply { addAll(it.extrapolate()) } } } fun List<List<Long>>.lastSeq(): Long { return ((this.size - 1) downTo 0).fol...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
1,436
aoc-2023
Apache License 2.0
src/Day08.kt
esteluk
572,920,449
false
{"Kotlin": 29185}
fun main() { fun parseHeights(input: List<String>): Array<IntArray> { val width = input.first().length val array = Array(input.size) { IntArray(width) } for (i in 0..input.lastIndex) { for (j in 0 until width) { array[i][j] = input[i][j].toString().toInt() ...
0
Kotlin
0
0
5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73
2,833
adventofcode-2022
Apache License 2.0
src/main/kotlin/Day05.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset import java.util.SortedMap fun main() { fun readSeads(line: String) = line.substringAfter(": ").split(Regex(" ")).filterNot { it.isEmpty() }.map { it.toLong() } fun readSeadRanges(line: String): List<LongRange> { val numbers = line.substringA...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
5,565
aoc-2023-in-kotlin
Apache License 2.0
src/Day11.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
enum class Operator { ADD, MULTIPLY, } class Monkey( private val id: Long, private val items: ArrayDeque<Long>, private val operation: Pair<Operator, Long?>, private val testDivisibleByValue: Long, private val testSuccessMonkeyId: Long, private val testFailureMonkeyId: Long, ) { var ins...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
3,104
advent-of-code-2022
Apache License 2.0
dsalgo/src/commonMain/kotlin/com/nalin/datastructurealgorithm/problems/AE_List.kt
nalinchhajer1
534,780,196
false
{"Kotlin": 86359, "Ruby": 1605}
package com.nalin.datastructurealgorithm.problems import com.nalin.datastructurealgorithm.ds.LinkedListNode import kotlin.math.max import kotlin.math.min /** * Merge overlapping intervals. They are not likely to be in order */ fun mergeOverlappingIntervals(intervals: List<List<Int>>): List<List<Int>> { val sort...
0
Kotlin
0
0
eca60301dab981d0139788f61149d091c2c557fd
8,465
kotlin-ds-algo
MIT License
src/main/kotlin/io/github/aarjavp/aoc/day04/Day04.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day04 import io.github.aarjavp.aoc.readFromClasspath import io.github.aarjavp.aoc.split class Day04 { data class Location(val x: Int, val y: Int) class BingoBoard(val mapping: Map<Int, Location>, val gridSize: Int) { val markedLocations = mutableSetOf<Location>() ...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
3,523
advent-of-code-2021
MIT License
src/day08/Day08.kt
Ciel-MC
572,868,010
false
{"Kotlin": 55885}
package day08 import readInput fun <T> List<T>.splitExclusive(index: Int): Pair<List<T>, List<T>> = this.take(index) to this.drop(index + 1) data class Vertical(val x: Int) operator fun <T> List<List<T>>.get(vertical: Vertical): List<T> = this.map { it[vertical.x] } fun <T> List<List<T>>.splitExclusiveVertical(y: ...
0
Kotlin
0
0
7eb57c9bced945dcad4750a7cc4835e56d20cbc8
2,021
Advent-Of-Code
Apache License 2.0
src/main/kotlin/day3/Day03.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day3 fun solveA(input: List<String>) = input .map { it.half() } .map { it.distinctLetters() } .sumOf { it.sumOf { c -> convertToPriority(c) } } fun solveB(input: List<String>) = input .chunked(3) .map { it.distinctLetters() } .sumOf { it.sumOf { c -> convertToPriority(c) } } fun conv...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
1,368
advent-of-code-2022
Apache License 2.0
src/Day08.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day8.printSolutionIfTest(21, 8) } object Day8 : Day<Int, Int>(8) { override fun part1(lines: List<String>): Int = buildGrid(lines) { tagVisible(it) }.flatten().count { it.visible } override fun part2(lines: List<String>): Int = buildGrid(lines) { tagScores(it) }.flatten().maxO...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
1,560
advent-of-code-2022
Apache License 2.0
src/day05/Day05.kt
TheJosean
573,113,380
false
{"Kotlin": 20611}
package day05 import readInput import splitList fun main() { data class Step(val amount: Int, val from: Int, val to: Int) fun transpose(matrix: List<List<Char>>): List<List<Char>> { matrix.filter { it.isNotEmpty() }.let { list -> return when { list.isNotEmpty() -> listOf(...
0
Kotlin
0
0
798d5e9b1ce446ba3bac86f70b7888335e1a242b
2,409
advent-of-code
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day12/day12.kt
mrugacz95
317,354,321
false
null
import kotlin.math.abs private operator fun Pair<Int, Int>.plus(other: Pair<Int, Int>): Pair<Int, Int> { return Pair(this.first + other.first, this.second + other.second) } open class Point(var pos: Pair<Int, Int> = Pair(0, 0)) { var angle = 90 open fun apply(command: Pair<Char, Int>) { when (com...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
3,018
advent-of-code-2020
Do What The F*ck You Want To Public License
src/day13/d13_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val graph = input.lines().map { parseChange(it) }.groupBy { it.who }.mapValues { (_, v) -> v.associateBy({ it.nextTo }) { it.delta } } val keys = graph.keys.toList() println(forEachPermutation(keys.size) { (0 until keys.size).map { i -> keys[it[i]].let { who -> (if...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,199
aoc2015
MIT License
src/y2022/Day18.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.readInput typealias Vector = Triple<Int, Int, Int> object Day18 { private fun parse(input: List<String>): Set<Vector> { return input.map { line -> val (x, y, z) = line.split(",").map { it.toInt() } Vector(x, y, z) }.toSet() } fun Vector.n...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,617
advent-of-code
Apache License 2.0
src/Day04.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
private class Assignment(start: Int, end: Int) { val range = start..end infix fun containsAllOf(other: Assignment) = range.intersect(other.range).size == other.range.count() infix fun containsAnyOf(other: Assignment) = range.intersect(other.range).isNotEmpty() companion object { fun parse(inpu...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
1,280
advent-of-code-in-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day8.kt
MisterJack49
574,081,723
false
{"Kotlin": 35586}
package days import common.Coordinates class Day8 : Day(8) { override fun partOne(): Any { val forest: Forest = inputList.mapIndexed { y, s -> s.mapIndexed { x, c -> Tree(c.digitToInt(), Coordinates(x, y)) } }.flatten() val innerForest = forest.getI...
0
Kotlin
0
0
e82699a06156e560bded5465dc39596de67ea007
3,305
AoC-2022
Creative Commons Zero v1.0 Universal
src/Day11.kt
oleskrede
574,122,679
false
{"Kotlin": 24620}
fun main() { class Monkey( val id: Int, val items: MutableList<Long>, val operation: (Long) -> Long, val handleWorryLevel: (Long) -> Long, val test: (Long) -> Int, val monkies: List<Monkey>, ) { var activityCounter = 0L fun takeTurn() { ...
0
Kotlin
0
0
a3484088e5a4200011335ac10a6c888adc2c1ad6
3,384
advent-of-code-2022
Apache License 2.0
jvm/src/main/kotlin/io/prfxn/aoc2021/day15.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Chiton (https://adventofcode.com/2021/day/15) package io.prfxn.aoc2021 fun main() { fun getMinRisk(rlm: List<List<Int>>, start: CP, end: CP): Int { val riskAndPrevOf = PriorityMap(sequenceOf(start to (0 to start))) { (a, _), (b, _) -> a - b } val visited = mutableSetOf<CP>() fun ge...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
1,979
aoc2021
MIT License
src/main/kotlin/days/Day7.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day7 : Day(7) { private val hands = inputList.map { it.split(' ') }.map { (cards, bid) -> Hand(cards, bid.toInt()) } override fun partOne(): Any { return getTotalWinnings(hands, false) } override fun partTwo(): Any { return getTotalWinnings(hands, true) } ...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
2,420
aoc-2023
Creative Commons Zero v1.0 Universal
app/src/main/kotlin/com/engineerclark/advent2022/Day02.kt
engineerclark
577,449,596
false
{"Kotlin": 10394}
package com.engineerclark.advent2022 import com.engineerclark.advent2022.utils.readInput import com.engineerclark.advent2022.utils.readTestInput fun main() { // challenge 1 val rounds = readRounds(readInput(2)) println("Day 2, Challenge 1 -- My total points: ${rounds.totalScores().myPoints}") // chal...
0
Kotlin
0
0
3d03ab2cc9c83b3691fede465a6e3936e7c091e9
2,504
advent-of-code-2022
MIT License
src/year2022/day13/Day13.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day13 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day13_test") check(part1(testInput), 13) check(part2(testInput), 140) val input = readInput("2022", "Day13") println(part1(...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,723
AdventOfCode
Apache License 2.0
src/Day15.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import kotlin.math.abs data class Sensor(val source: Pair<Int, Int>, val target: Pair<Int, Int>, val radius: Int) { fun inRange(other: Pair<Int, Int>): Boolean { return (abs(source.first - other.first) + abs(source.second - other.second)) <= radius } } fun readSensor(input: List<String>): List<Sensor>...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
2,322
Advent-Of-Code-2022
Apache License 2.0
src/Day07.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
data class Directory(val name: String, val parent: Directory? = null) { private val files = mutableMapOf<String, Int>() val children = mutableMapOf<String, Directory>() fun addFile(size: Int, name: String) = files.putIfAbsent(name, size) fun addChild(directory: Directory) = children.putIfAbsent(direct...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
2,578
advent-of-code-2022
Apache License 2.0
src/y2023/Day02.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.product import util.readInput import util.timingStatistics object Day02 { private fun parse(input: List<String>): List<List<Map<String, Int>>> { return input.map { line -> line.substringAfter(": ").split("; ").map { game -> game.split(", ").associate {...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,333
advent-of-code
Apache License 2.0
src/Day09.kt
Xacalet
576,909,107
false
{"Kotlin": 18486}
/** * ADVENT OF CODE 2022 (https://adventofcode.com/2022/) * * Solution to day 9 (https://adventofcode.com/2022/day/9) * */ import kotlin.math.abs private data class Point(val x: Int, val y: Int) { operator fun minus(otherPoint: Point): Point = Point(x - otherPoint.x, y - otherPoint.y) } private class Knot...
0
Kotlin
0
0
5c9cb4650335e1852402c9cd1bf6f2ba96e197b2
2,333
advent-of-code-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/shortest_subarray/ShortestSubarray.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.shortest_subarray import datsok.shouldEqual import org.junit.jupiter.api.Test import java.io.File import kotlin.collections.ArrayDeque import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.collections.forEach import kotlin.collections.indices import kotli...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
4,328
katas
The Unlicense
src/day11/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day11 import readInput import splitBy fun main() { fun part1(input: List<String>): Long { val monkeys = Monkeys.ofNotes(input) return monkeys.start(20, 3).sumOfTwoMostActive() } fun part2(input: List<String>): Long { val monkeys = Monkeys.ofNotes(input) return monk...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
3,954
AoC-2022
Apache License 2.0
src/year2023/day08/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day08 import arrow.core.nonEmptyListOf import io.kotest.matchers.shouldBe import utils.ProblemPart import utils.cyclical import utils.findCycle import utils.leastCommonMultiple import utils.leastCommonMultipleOf import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testIn...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,169
Advent-of-Code
Apache License 2.0
src/Day12.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
import java.util.* fun main() { fun part1(input: List<String>): Int { val (graph, start) = parseInput(input, 'S') val path = bfs( graph = graph, start = start, isAdjacentValid = { current, adj -> adj.value - current.value <= 1 }, isDestination = { c...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
3,415
aoc-2022
Apache License 2.0
src/Day05.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun List<String>.parseStacksAndInstructions(): Pair<List<Triple<Int, String, String>>, Map<String, ArrayDeque<Char>>> { val sepIndex = indexOfFirst(String::isEmpty) val stacksLines = take(sepIndex) val stacks = stacksLines.last().trim().split(" ").associateWith { ArrayDeque<C...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
2,115
advent-of-code-2022
Apache License 2.0
src/day07/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 7: No Space Left On Device * https://adventofcode.com/2022/day/7 */ package day07 import day07.Command.ChangeDirectory import day07.Command.ListDirectoryContent import day07.Command.ListDirectoryContent.ListDirectoryResult import utils.splitBefore import java.io.File fun main() { val fileName...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
3,039
aoc2022-kotlin
Apache License 2.0
src/Day16Part2.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
// Fast solution that builds upon Part1 // n - number of interesting valves with r > 0 // m - number of connections // t - number of time steps // // O(t * 2^n * m) time to solve Part1 // + O(3^n) time to solve Part2 fun main() { val dayId = "16" val input = readInput("Day${dayId}") class VD(val ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
1,979
aoc-2022
Apache License 2.0
2023/src/main/kotlin/day5.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.tesselateWith fun main() { Day5.run() } object Day5 : Solution<Day5.Input>() { override val name = "day5" override val parser = Parser { parseInput(it) } @Parse("{state}s: {r ' ' nums}\n\n{r '\n\n' rules}") data class Input( val ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,171
aoc_kotlin
MIT License
src/Day06.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
fun firstPart06(list : List<LanternFish>) { val totalDays = 80 val updatedList = list.toMutableList() var fishToAdd : Int (0 until totalDays).map { fishToAdd = 0 updatedList.mapIndexed { index, fish -> if (fish.daysToNextBirth == 0) { fishToAdd++ }...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
1,756
Advent_of_Code_2021_Kotlin
Apache License 2.0
solutions/src/Day11.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): Long { val monkeys = buildMonkeys(input) return run(20, monkeys) { monkey, itemWorryLevel -> val operation = monkey.operation(itemWorryLevel) operation / 3 } } fun part2(input: List<String>): Long { val mon...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
3,377
advent-of-code-22
Apache License 2.0
src/shmulik/klein/day02/Day02.kt
shmulik-klein
573,426,488
false
{"Kotlin": 9136}
package shmulik.klein.day02 import readInput fun main() { fun getGame(input: List<String>): List<Pair<String, String>> { val result: MutableList<Pair<String, String>> = mutableListOf() for (row in input) { val pair = row.split(" ") result.add(Pair(pair[0], pair[1])) ...
0
Kotlin
0
0
4d7b945e966dad8514ec784a4837b63a942882e9
2,605
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day09.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day09.solvePart1()) println(Day09.solvePart2()) } object Day09 { private val heightMap = readInput("day09").map { it.map(Char::digitToInt) } fun solvePart1() = findLowPoints().sumOf { heightMap[it.x][it.y] + 1 } fun solvePart2() = findLowPoints() .map { calculateBasin...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,613
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
2017/src/twenty/ParticleSwarmChallenge.kt
Mattias1
116,139,424
false
null
package twenty import kotlin.math.absoluteValue class ParticleSwarmChallenge { fun closestParticleToOrigin(input: List<String>): Int { val particles = parseParticles(input) return particles.sorted().first().index } private fun parseParticles(input: List<String>): List<Particle> = ...
0
Kotlin
0
0
6bcd889c6652681e243d493363eef1c2e57d35ef
2,165
advent-of-code
MIT License
src/Day15.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
import kotlin.math.max import kotlin.math.min fun main() { data class SensorGroup(val sensor: Pair<Int, Int>, val beacon: Pair<Int, Int>, val distance: Int) fun String.parse() = "(-?\\d+)".toRegex().findAll(this).map { it.groupValues[1].toInt() }.toList().chunked(2) .map { Pair(it[0], it[1]) }.let { S...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
3,730
AoC-2022
Apache License 2.0
src/Day15.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
import kotlin.math.absoluteValue fun main() { val day = 15 data class Beacon(val sx: Int, val sy: Int, val bx: Int, val by: Int) { val range = (sx - bx).absoluteValue + (sy - by).absoluteValue fun isCovered(x: Int, y: Int): Boolean { val checkRange = rangeAt(y) return ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
2,089
aoc22
Apache License 2.0
src/main/kotlin/aoc2017/RecursiveCircus.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import komu.adventofcode.utils.nonEmptyLines fun recursiveCircusBottom(input: String): String = buildTree(input).name fun recursiveCircusBalance(input: String): Int = adjustBalance(buildTree(input), 0) // expected value does not matter at the root private fun adjustBalance(...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,318
advent-of-code
MIT License
src/year2022/day21/Day21.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day21 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day21_test") check(part1(testInput), 152) check(part2(testInput), 301) val input = readInput("2022", "Day21") println(part1...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,509
AdventOfCode
Apache License 2.0
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day02.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.Day02.Outcome.* import codes.jakob.aoc.Day02.RockPaperScissors.* import codes.jakob.aoc.shared.splitMultiline class Day02 : Solution() { override fun solvePart1(input: String): Any { return input .splitMultiline() .map { it.split(" ") ...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
3,018
advent-of-code-2022
MIT License
src/main/kotlin/biz/koziolek/adventofcode/year2023/day11/day11.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day11 import biz.koziolek.adventofcode.LongCoord import biz.koziolek.adventofcode.findInput import biz.koziolek.adventofcode.parse2DMap fun main() { val inputFile = findInput(object {}) val map = parseGalaxyMap(inputFile.bufferedReader().readLines()) println("Sum...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,348
advent-of-code
MIT License
src/Day02.kt
roxspring
573,123,316
false
{"Kotlin": 9291}
enum class Play(val score: Int) { Rock(1), Paper(2), Scissors(3); fun next(): Play = values()[(3 + ordinal + 1) % 3] fun prev(): Play = values()[(3 + ordinal - 1) % 3] } enum class Result(val score: Int) { Loss(0), Draw(3), Win(6); companion object { fun of(opponent: Play, strategy: Play)...
0
Kotlin
0
0
535beea93bf84e650d8640f1c635a430b38c169b
2,222
advent-of-code-2022
Apache License 2.0
src/Day24.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import java.util.BitSet import java.util.PriorityQueue import kotlin.math.abs private enum class WinDir { UP, DOWN, LEFT, RIGHT } fun main() { class StormMap(val map: Map<Pair<Int, Int>, BitSet>, val dimensions: Pair<Int, Int>) { val start = Pair(0, 1) val end = Pair(dimensions.first - 1, dimensio...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
6,256
aoc-2022
Apache License 2.0
src/main/kotlin/me/astynax/aoc2023kt/Day03.kt
astynax
726,011,031
false
{"Kotlin": 9743}
package me.astynax.aoc2023kt private val Pair<Int, Int>.neighbors: Iterable<Pair<Int, Int>> get() = listOf( (first - 1) to (second - 1), first to (second - 1), (first + 1) to (second - 1), (first - 1) to second, (first + 1) to second, (first - 1) to (second + 1), first to (s...
0
Kotlin
0
0
9771b5ccde4c591c7edb413578c5a8dadf3736e0
1,617
aoc2023kt
MIT License
src/main/kotlin/day6/Day6.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day6 import java.io.File fun parseInput(line: String) = line.split(",").map { it.toInt() } data class LanternFish(val daysToEngender: Int) { fun ageOneDay(): List<LanternFish> = if (daysToEngender == 0) listOf(LanternFish(6), LanternFish(8)) else listOf(LanternFish(daysToEngender - 1)) } fun naiv...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
1,509
advent-of-code-2021
MIT License
src/main/kotlin/solutions/day07/Day7.kt
Dr-Horv
112,381,975
false
null
package solutions.day07 import solutions.Solver import utils.splitAtWhitespace import java.util.* data class Program(val name: String, val weight: Int, var parent: Program?, var children: List<Program>, var totalWeight: Int, var level: Int) data class Tuple(val program: Program, val diff: Int) class LevelComparator...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
3,964
Advent-of-Code-2017
MIT License
src/aoc2023/Day12.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput fun main() { val (year, day) = "2023" to "Day12" fun countArrangements(row: String, foldFactor: Int): Long { val (springsStr, groupsStr) = row.split(" ") val groupList = groupsStr.split(",").map { it.toInt() } val springs = (1..foldF...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
3,126
aoc-kotlin
Apache License 2.0
src/Day11.kt
a2xchip
573,197,744
false
{"Kotlin": 37206}
import java.io.File class Monkey( val items: MutableList<Long>, val worryLevelOperation: String, val worryLevelOperationValue: String, val testDivisibleBy: Int, val ifTrueThrowToMonkey: Int, val ifFalseThrowToMonkey: Int, var inspected: Int ) { companion object { fun from(monkey...
0
Kotlin
0
2
19a97260db00f9e0c87cd06af515cb872d92f50b
4,078
kotlin-advent-of-code-22
Apache License 2.0
src/Day15.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.math.abs fun main() { data class Point(val x: Int, val y: Int) { fun dist(other: Point) = abs(x - other.x) + abs(y - other.y) fun add(dx: Int, dy: Int) = Point(x + dx, y + dy) } class Sensor(val pos: Point, val closestBeacon: Point) fun parse(input: List<String>): List<...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
2,510
Advent-of-Code-2022
Apache License 2.0
src/Day03.kt
arturkowalczyk300
573,084,149
false
{"Kotlin": 31119}
fun main() { fun calculateItemTypePriority(itemType: Char): Int { val charCode = itemType.code if (charCode in ('a'.code..'z'.code)) return charCode - 'a'.code + 1 else return charCode - 'A'.code + 27 return charCode } fun part1(input: List<String>): ...
0
Kotlin
0
0
69a51e6f0437f5bc2cdf909919c26276317b396d
2,187
aoc-2022-in-kotlin
Apache License 2.0
src/Day15.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.abs import kotlin.math.max fun main() { fun getBlockedOnLine(sensors: List<List<Int>>, shouldCountUsed: Boolean, whichRow: Int, whichLimit: Int? = null): Pair<Int, Int> { val blockedRangesOnRowEvents: MutableList<Pair<Int, Int>> = mutableListOf() sensors.forEach { (x1, y1, x2, y2...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
2,756
advent-of-kotlin-2022
Apache License 2.0
2021/src/main/kotlin/Day16.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day16(val input: String) { private val transmission = input.map { it.digitToInt(16).toString(2).padStart(4, '0') }.joinToString("") fun solve1() = parse(transmission).sumOfVersions() fun solve2() = parse(transmission).value() private fun parse(packet: String): Packet { val type = packe...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
2,940
adventofcode-2021-2025
MIT License
src/twentythree/Day06.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentythree import readInputTwentyThree import java.util.stream.IntStream import kotlin.math.ceil import kotlin.math.max import kotlin.math.min import kotlin.math.sqrt import kotlin.streams.asSequence data class Race(val time: Long, val distance: Long) fun main() { fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
2,866
kotlin-aoc-1
Apache License 2.0
src/Day12.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
import java.util.* import kotlin.collections.ArrayDeque import kotlin.collections.set fun main() { fun bfs(input: List<String>, start: Pair<Int, Int>): MutableMap<Pair<Int, Int>, Pair<Int, Int>> { val visited = mutableMapOf<Pair<Int, Int>, Boolean>() val edgeTo = mutableMapOf<Pair<Int, Int>, Pai...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
2,991
AoC-2022
Apache License 2.0
src/Day08.kt
mandoway
573,027,658
false
{"Kotlin": 22353}
fun parseRowsAndColumns(input: List<String>): Pair<List<List<Int>>, List<List<Int>>> { val rows = input.map { row -> row.map { it.digitToInt() } } val cols = MutableList(input.size) { mutableListOf<Int>() } rows.forEach { row -> row.forEachIndexed { index, height -> cols[in...
0
Kotlin
0
0
0393a4a25ae4bbdb3a2e968e2b1a13795a31bfe2
2,795
advent-of-code-22
Apache License 2.0
src/2022/Day07.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun readFileSystem(input: List<String>): Directory { val root = Directory(name = "/", children = mutableListOf()) var currentFolder = root input.drop(1).forEach { command -> if (command.startsWith("\$ cd")) { val fol...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,342
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day08/TreetopTreeHouse.kt
iamwent
572,947,468
false
{"Kotlin": 18217}
package day08 import readInput class TreetopTreeHouse( private val name: String ) { private fun readMap(): List<List<Int>> { return readInput(name).map { it.map { height -> height.digitToInt() } } } fun part1(): Int { val map = readMap() val width = map.first().size v...
0
Kotlin
0
0
77ce9ea5b227b29bc6424d9a3bc486d7e08f7f58
1,899
advent-of-code-kotlin
Apache License 2.0
advent-of-code-2023/src/Day18.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import lib.matrix.Direction import lib.matrix.Direction.* import lib.matrix.Direction.Companion.moveInDirection import lib.matrix.Direction.Companion.nextInDirection import lib.matrix.Position import kotlin.math.abs private const val DAY = "Day18" fun main() { fun testInput() = readInput("${DAY}_test") fun in...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,441
advent-of-code
Apache License 2.0
src/Day07.kt
JohannesPtaszyk
573,129,811
false
{"Kotlin": 20483}
const val PATH_DELIMITER = "/" const val TOTAL_DISK_CAPACITY = 70_000_000 const val NEEDED_SPACE = 30_000_000 data class File(val size: Int, val name: String, val path: String) { fun parentDirs(): List<String> = path.removeSuffix(PATH_DELIMITER).let { path -> if (path == PATH_DELIMITER) { listO...
0
Kotlin
0
1
6f6209cacaf93230bfb55df5d91cf92305e8cd26
2,716
advent-of-code-2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day03/Day03.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day03 import eu.janvdb.aocutil.kotlin.readNonSeparatedDigits const val FILENAME = "input03.txt" fun main() { val data = readNonSeparatedDigits(2021, FILENAME) part1(data) part2(data) } private fun part1(data: List<List<Int>>) { val gamma = keepBits(data, ::mostCommonAt) val epsilon = ...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,611
advent-of-code
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-24.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 import java.util.* fun main() { val input = readInputLines(2015, "24-input") val test1 = readInputLines(2015, "24-test1") println("Part1:") part1(tes...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,005
advent-of-code
MIT License
2023/src/main/kotlin/day3.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.Parser import utils.Solution import utils.Vec2i fun main() { Day3.run(skipTest = false) } object Day3 : Solution<Grid<Char>>() { override val name = "day3" override val parser = Parser.charGrid data class PartNum( val num: Int, val start: Vec2i, val end: Vec2i, ) ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,652
aoc_kotlin
MIT License
src/com/kingsleyadio/adventofcode/y2021/day15/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day15 import com.kingsleyadio.adventofcode.util.readInput import com.kingsleyadio.adventofcode.y2021.day13.Point import java.util.* fun solution(input: List<IntArray>): Int { val plane = List(input.size) { IntArray(input.size) { Int.MAX_VALUE } } val queue = Priorit...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,855
adventofcode
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2018/Day15.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2018 import se.saidaspen.aoc.util.* fun main() = Day15.run() object Day15 : Day(2018, 15) { enum class Type { G, E } data class Combatant(val id: Char, val type: Type, var pos: Point, var hp: Int = 200) override fun part1(): Any { val (combatants, fullrounds) = simula...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
4,251
adventofkotlin
MIT License
src/Day04.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename fun containedRangesInPair(line: String): Int { val ranges = line.split(",") val range1 = ranges[0].split("-").let { it[0].toInt()..it[1].toInt() } val range2 = ranges[1].split("-").let { it[0].toInt()..it[1].toInt() } val range1inRange2 = ran...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
1,834
KotlinAdventOfCode2022
Apache License 2.0
src/Day11.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
class Monkeys(input: List<String>, val toDivide: Boolean = true) { val monkeys: MutableList<Monkey> = mutableListOf() init { input.chunked(7).forEach { monkeyString -> val items = monkeyString[1].split(" ", ",").map{ it.toLongOrNull() } .filter { it != null }.toMutableList(...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
3,350
AdventOfCode
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day14.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 14: Extended Polymerization */ package dev.paulshields.aoc import dev.paulshields.aoc.common.addToValue import dev.paulshields.aoc.common.incrementValue import dev.paulshields.aoc.common.readFileAsString import dev.paulshields.aoc.common.subtractFromValue fun main() { println(" ** Day 14: Extended Po...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
3,557
AdventOfCode2021
MIT License
src/Day09.kt
floblaf
572,892,347
false
{"Kotlin": 28107}
import kotlin.math.pow import kotlin.math.sign import kotlin.math.sqrt fun main() { val moves = readInput("Day09").map { val (direction, steps) = it.split(" ") Move( direction = when (direction) { "U" -> Direction.UP "D" -> Direction.DOWN ...
0
Kotlin
0
0
a541b14e8cb401390ebdf575a057e19c6caa7c2a
2,459
advent-of-code-2022
Apache License 2.0
src/year2021/Day3.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readLines fun main() { val input = readLines("2021", "day3").map { it.split(("")).filter { bit -> bit == "0" || bit == "1" } } val testInput = readLines("2021", "day3_test").map { it.split(("")).filter { bit -> bit == "0" || bit == "1" } } check(part1(testInput) == 198) printl...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
1,792
advent_of_code
MIT License