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/Day03.kt
kent10000
573,114,356
false
{"Kotlin": 11288}
fun main() { fun getPriority(letter: Char): Int { var code = letter.code - 96 if (code < 0) code += 58 return code } fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val parts = line.chunked(line.length/2) //splits into two ...
0
Kotlin
0
0
c128d05ab06ecb2cb56206e22988c7ca688886ad
1,463
advent-of-code-2022
Apache License 2.0
src/day11.kts
miedzinski
434,902,353
false
{"Kotlin": 22560, "Shell": 113}
val grid = generateSequence(::readLine).flatMap { it.asSequence().map(Char::digitToInt) }.toMutableList() val gridSize = 10 typealias Grid = MutableList<Int> data class Point(val x: Int, val y: Int) operator fun Grid.get(point: Point): Int = get(point.y * gridSize + point.x) operator fun Grid.set(point: Po...
0
Kotlin
0
0
6f32adaba058460f1a9bb6a866ff424912aece2e
1,961
aoc2021
The Unlicense
src/Day02.kt
paulbonugli
574,065,510
false
{"Kotlin": 13681}
enum class GameChoice() { ROCK(), PAPER(), SCISSORS() } enum class GameOutcome(val score: Int) { WIN(6), DRAW(3), LOSE(0) } fun main() { fun parseGameChoice(str: String): GameChoice { return when (str) { "A", "X" -> GameChoice.ROCK "B", "Y" -> GameChoice.PA...
0
Kotlin
0
0
d2d7952c75001632da6fd95b8463a1d8e5c34880
3,161
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
Excape
572,551,865
false
{"Kotlin": 36421}
fun main() { fun part1(input: List<String>): Int { val mapOfResults = mapOf( "A X" to 1 + 3, "A Y" to 2 + 6, "A Z" to 3 + 0, "B X" to 1 + 0, "B Y" to 2 + 3, "B Z" to 3 + 6, "C X" to 1 + 6, "C Y" to 2 + 0, ...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
1,037
advent-of-code-2022
Apache License 2.0
src/day09/Day09.kt
marcBrochu
573,884,748
false
{"Kotlin": 12896}
package day09 import readInput import day09.Direction.* import kotlin.math.sign data class Point(var x: Int, var y: Int) { fun move(direction: Direction, distance: Int = 1) = when (direction) { EAST -> x += distance WEST -> x -= distance NORTH -> y += distance SOUTH -> y -= distan...
0
Kotlin
0
2
8d4796227dace8b012622c071a25385a9c7909d2
2,509
advent-of-code-kotlin
Apache License 2.0
src/day05/Day05.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day05 import readInput import java.util.Stack private data class Action(val amount: Int, val from: Int, val to: Int) { companion object { fun from(input: String): Action? { val regex = """move (\d*) from (\d*) to (\d*)""".toRegex() val result = regex.matchEntire(input) ?: r...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
2,938
advent-of-code-2022
Apache License 2.0
src/aoc2022/Day13.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList import kotlin.math.min fun main() { data class NumberOrList( var number: Int?, var list: List<NumberOrList>?, val isDivider: Boolean ) { constructor( value: Int, isDivider: Boolean = false, ) : this(v...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
4,026
AOC-2022-Kotlin
Apache License 2.0
src/Day04.kt
strindberg
572,685,170
false
{"Kotlin": 15804}
data class RangePair(val start1: Int, val end1: Int, val start2: Int, val end2: Int) fun ranges(line: String): RangePair { val pair1 = line.split(",")[0].split("-") val pair2 = line.split(",")[1].split("-") return RangePair(pair1[0].toInt(), pair1[1].toInt(), pair2[0].toInt(), pair2[1].toInt()) } fun main...
0
Kotlin
0
0
c5d26b5bdc320ca2aeb39eba8c776fcfc50ea6c8
1,092
aoc-2022
Apache License 2.0
src/Day04.kt
makohn
571,699,522
false
{"Kotlin": 35992}
fun main() { operator fun IntRange.contains(other: IntRange) = other.first >= this.first && other.last <= this.last infix fun IntRange.overlapsWith(other: IntRange) = ( (other.first >= this.first && other.last <= this.last) || (other.first >= this.first && other.first <= this.last) || ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
1,955
aoc-2022
Apache License 2.0
src/Day04.kt
jarmstrong
572,742,103
false
{"Kotlin": 5377}
fun main() { data class SectionIDRange(val startSectionId: Int, val endSectionId: Int) data class ElfPair(val firstElf: SectionIDRange, val secondElf: SectionIDRange) fun List<String>.createElfPairs(): List<ElfPair> { return map { val linePair = it.split(",").map { rangeString -> ...
0
Kotlin
0
0
bba73a80dcd02fb4a76fe3938733cb4b73c365a6
1,499
aoc-2022
Apache License 2.0
src/Day07.kt
BenHopeITC
573,352,155
false
null
private fun String.isFileWithSize() = split(" ").first().toIntOrNull() != null private fun String.isMoveToChildDirectory() = startsWith("\$ cd") && !endsWith("..") private fun String.isMoveToParentDirectory() = startsWith("\$ cd") && (endsWith("..") || endsWith("/")) private fun String.movePathOneBack() = substringB...
0
Kotlin
0
0
851b9522d3a64840494b21ff31d83bf8470c9a03
2,440
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day19/Day19.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day19 import com.tonnoz.adventofcode23.utils.println import com.tonnoz.adventofcode23.utils.readInput import kotlin.system.measureTimeMillis object Day19 { data class Workflow(val name: String, val rules: List<Rule>) data class Rule(val part: Char, val next: String, val conditio...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,474
adventofcode23
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day19.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 import com.dvdmunckhof.aoc.splitOnce class Day19(input: String) { private val inputRules: List<String> private val inputMessages: List<String> init { val (rules, messages) = input.splitOnce("\n\n") inputRules = rules.split("\n") inputMessages ...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,782
advent-of-code
Apache License 2.0
src/main/day14/day14.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day14 import kotlin.math.max import kotlin.math.min import readInput private typealias Cave = MutableSet<Point> private typealias Rock = Point private typealias Grain = Point private data class Point(val x: Int, val y: Int) private val source = Point(500, 0) fun main() { val input = readInput("main/day...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,490
aoc-2022
Apache License 2.0
src/Day23.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.max import kotlin.math.min fun main() { fun readElvesArray(input: List<String>): Array<Coords> { val resultList = mutableListOf<Coords>() input.forEachIndexed { rowIndex, s -> s.forEachIndexed { index, c -> if (c == '#') resultList....
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,202
AdventOfCode2022
Apache License 2.0
src/Day04.kt
oleskrede
574,122,679
false
{"Kotlin": 24620}
fun main() { fun part1(input: List<String>): Int { return input.map { it.split(",") } .count { (a, b) -> val (aStart, aEnd) = a.split("-").map { it.toInt() } val (bStart, bEnd) = b.split("-").map { it.toInt() } val aInB = aStart >= bStart && aEnd <...
0
Kotlin
0
0
a3484088e5a4200011335ac10a6c888adc2c1ad6
1,044
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/codes/jakob/aoc/solution/Day07.kt
loehnertz
725,944,961
false
{"Kotlin": 59236}
package codes.jakob.aoc.solution import codes.jakob.aoc.shared.* import codes.jakob.aoc.solution.Day07.HandType.* object Day07 : Solution() { private val handComparator: Comparator<Hand> = compareBy( { it.type }, { it.cards[0] }, { it.cards[1] }, { it.cards[2] }, { it.cards...
0
Kotlin
0
0
6f2bd7bdfc9719fda6432dd172bc53dce049730a
5,638
advent-of-code-2023
MIT License
src/main/kotlin/com/groundsfam/advent/y2020/d19/Day19.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d19 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines class Solver(private val rules: Map<Int, Rule>, private val string: String, private val partTwo: Boolean = false) { data class Key(val from: Int, val to: Int, val rule: Int) ...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,218
advent-of-code
MIT License
src/Day18.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.math.abs fun main() { data class Point(val x: Int, val y: Int, val z: Int) { fun touches(other: Point): Boolean { return (x == other.x && y == other.y && abs(z - other.z) == 1) || (x == other.x && z == other.z && abs(y - other.y) == 1) || (y...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
2,979
Advent-of-Code-2022
Apache License 2.0
12/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Graph { val edges = File("input.txt") .readLines() .map { it.split("-") } return Graph(edges) } class Graph(edges : List<List<String>>) { companion object { const val START = "start" const val END = "end" } private var start ...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
3,205
advent-of-code-2021
MIT License
src/Day03.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun Char.charValue(): Int = when { isUpperCase() -> this - 'A' + 27 isLowerCase() -> this - 'a' + 1 else -> 0 } fun main() { fun part1(input: List<String>): Int { var sum = 0 for (ransack in input) { val first = ransack.substring(0, ransack.length / 2) val second...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
1,162
advent-2022
Apache License 2.0
src/Day10.kt
tigerxy
575,114,927
false
{"Kotlin": 21255}
import Operation.Add import Operation.Nop fun main() { fun part1(input: List<String>): Int { val parsedInput = input.parse() .addHead(Add(1)) .chunked(10) return (2..22 step 4) .sumOf { parsedInput .take(it) ...
0
Kotlin
0
1
d516a3b8516a37fbb261a551cffe44b939f81146
2,085
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/days/Day10Data.kt
yigitozgumus
572,855,908
false
{"Kotlin": 26037}
package days import utils.SolutionData fun main() = with(Day10Data()) { println(" --- Part 1 --- ") solvePart1() println(" --- Part 2 --- ") solvePart2() } sealed class Command(val name: String, val effect: Int = 0, val cycle: Int) { class NOOP(): Command("noop", 0, 1) class ADDX(effect: Int): Command("a...
0
Kotlin
0
0
9a3654b6d1d455aed49d018d9aa02d37c57c8946
1,450
AdventOfCode2022
MIT License
src/test/kotlin/io/noobymatze/aoc/y2023/Day7.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2023 import io.noobymatze.aoc.Aoc import kotlin.math.exp import kotlin.test.Test class Day7 { fun compareCards(cards: String, a: String, b: String): Int { var result = 0 for (i in 0..5) { result = cards.indexOf(a[i]) - cards.indexOf(b[i]) if (re...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
3,214
aoc
MIT License
src/year2022/day11/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day11 import io.kotest.matchers.shouldBe import utils.readInput fun main() { val testInput = readInput("11", "test_input") val realInput = readInput("11", "input") val testStartMonkeyList = testInput.buildMonkeyList() val realStartMonkeyList = realInput.buildMonkeyList() runRoun...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
3,782
Advent-of-Code
Apache License 2.0
src/main/kotlin/aoc2016/day02_bathroom_security/BathroomSecurity.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2016.day02_bathroom_security import geom2d.Dir.* import geom2d.toDir fun main() { util.solve("61529", ::partOne) util.solve("C2C28", ::partTwo) } internal fun String.asKeymap(): Array<IntArray> { val map = mutableMapOf<Int, IntArray>() var max = -1 val grid = trimIndent().lines().map {...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,291
aoc-2021
MIT License
src/Day07.kt
Feketerig
571,677,145
false
{"Kotlin": 14818}
fun main(){ fun buildFileSystem(input: List<String>): Dir { val root = Dir("/", mutableListOf(), null) var currentDir = root input.drop(1).forEach {line -> when(line.substring(0,4)){ "$ ls" -> { } "$ cd" -> { v...
0
Kotlin
0
0
c65e4022120610d930293788d9584d20b81bc4d7
2,585
Advent-of-Code-2022
Apache License 2.0
src/day05/Day05.kt
cmargonis
573,161,233
false
{"Kotlin": 15730}
package day05 import readInput private const val DIRECTORY = "./day05" fun main() { fun getStack(input: List<String>): Pair<Int, Map<Int, ArrayDeque<String>>> { var stackIndex = 0 val stackRows: List<List<String>> = input.takeWhile { it.isNotBlank() }.mapIndexed { runningIndex, row -> ...
0
Kotlin
0
0
bd243c61bf8aae81daf9e50b2117450c4f39e18c
3,434
kotlin-advent-2022
Apache License 2.0
src/Day10.kt
Shykial
572,927,053
false
{"Kotlin": 29698}
private val SIGNAL_REGEX = Regex("""(\w+)(?:\s(-?\d+))?""") fun main() { fun part1(input: List<String>): Int { val searchedCycles = (20..220 step 40).toList().run(::ArrayDeque) return input .map { SIGNAL_REGEX.find(it)?.groups?.get(2)?.value } .fold(Triple(1, 1, 0)) { (cycle...
0
Kotlin
0
0
afa053c1753a58e2437f3fb019ad3532cb83b92e
1,965
advent-of-code-2022
Apache License 2.0
src/Day02.kt
arhor
572,349,244
false
{"Kotlin": 36845}
fun main() { val input = readInput {} println( "Part 1: " + solvePuzzle( input, resultTable = hashMapOf( "A X" to Shape.ROCK + Round.DRAW, "A Y" to Shape.PAPER + Round.WIN, "A Z" to Shape.SCISSORS + Round.LOOSE, "B X" t...
0
Kotlin
0
0
047d4bdac687fd6719796eb69eab2dd8ebb5ba2f
1,684
aoc-2022-in-kotlin
Apache License 2.0
algorithms/src/main/kotlin/com/kotlinground/algorithms/searching/trie/searchsuggestions/suggestedProducts.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.searching.trie.searchsuggestions import java.util.* import kotlin.collections.ArrayList import kotlin.math.abs import kotlin.math.min /** * Since the question asks for the result in a sorted order, let's start with sorting products. * An advantage that comes with sorting is Binar...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,796
KotlinGround
MIT License
src/main/kotlin/days/Day07.kt
julia-kim
569,976,303
false
null
package days import readInput fun main() { tailrec fun sumFiles( filesystem: MutableList<Directory>, children: List<String>, sum: Long ): Long { var total = sum if (children.isEmpty()) return total val dirs = children.map { child -> filesystem.first ...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
3,182
advent-of-code-2022
Apache License 2.0
src/Day07.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
import java.util.Collections fun main() { fun part1(input: List<String>): Long { val fileSystem = RootDirectory() val allDirectories = mutableListOf<FileDirectory>() var currentDirectory: FileSystemNode = fileSystem input.forEach { line -> if (line == "$ cd /" || line ==...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
4,493
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode2023/day4/day4.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day4 import adventofcode2023.readInput typealias Card = Pair<List<Int>, List<Int>> val Card.winning: List<Int> get() = this.first val Card.myNumbers: List<Int> get() = this.second fun main() { val input = readInput("day4") println("Day 4") println("Puzzle 1: ${puzzle1(i...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
1,484
adventofcode2023
MIT License
src/Day14.kt
adrianforsius
573,044,406
false
{"Kotlin": 68131}
import org.assertj.core.api.Assertions.assertThat import java.lang.Integer.max import java.lang.Integer.min fun rangeBetween(a: Int, b: Int) = min(a, b) .. max(a, b) fun main() { fun part1(input: List<String>): Int { val lines = input.map { it.split(" -> ") .map { ...
0
Kotlin
0
0
f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb
3,688
kotlin-2022
Apache License 2.0
src/days/Day05.kt
nicole-terc
574,130,441
false
{"Kotlin": 29131}
package days import readInput import java.util.* import kotlin.math.ceil fun main() { fun getInitialStacks(input: List<String>): List<Stack<Char>> { val grid = input.takeWhile { it.contains('[') } val numberOfStacks = grid.last().count{it == '['} val stacks = List(numberOfStacks) { Stack<...
0
Kotlin
0
2
9b0eb9b20e308e5fbfcb2eb7878ba21b45e7e815
2,448
AdventOfCode2022
Apache License 2.0
src/main/kotlin/Day14.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day14.solvePart1()) println(Day14.solvePart2()) } object Day14 { private val input = readInput("day14") private val template = input.first() private val insertions = input.drop(2) .map { it.split(" -> ") } .associate { (pair, insert) -> pair to insert.single() }...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,302
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/Day04.kt
Sghazzawi
574,678,250
false
{"Kotlin": 10945}
fun getRange(input: String): IntRange { val split = input.split("-") return (split[0].toInt()..split[1].toInt()) } fun main() { fun part1(input: List<String>): Int { return input .map { it.split(",") } .map { Pair(getRange(it[0]), getRange(it[1])) } .fold(0) { ac...
0
Kotlin
0
0
a26111fa1bcfec28cc43a2f48877455b783acc0d
940
advent-of-code-kotlin
Apache License 2.0
advent8/src/main/kotlin/Main.kt
thastreet
574,294,123
false
{"Kotlin": 29380}
import java.io.File fun main(args: Array<String>) { val lines = File("input.txt").readLines() val trees: Array<Array<Int>> = parseTrees(lines) val part1Answer = part1(trees) println("part1Answer: $part1Answer") val part2Answer = part2(trees) println("part2Answer: $part2Answer") } fun parseT...
0
Kotlin
0
0
e296de7db91dba0b44453601fa2b1696af9dbb15
2,545
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2020/ex19.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
package aoc2020 import readInputFile fun main() { val input = readInputFile("aoc2020/input19") //.replace(Regex("8: 42")) { "8: 42 | 42 8"} //.replace(Regex("11: 42 31")) { "11: 42 31 | 42 11 31"} // val input = """ // 0: 4 1 5 // 1: 2 3 | 3 2 // 2: 4 4 | 5 5 // 3: 4 5 | 5 4...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
4,048
AOC-2021
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day23/Day23.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputSplitOnBlank import java.util.* import kotlin.math.abs object Day23 : Day { private val exits = listOf(2, 4, 6, 8) override val input = readInputSplitOnBlank(23) override fun part1() = sort(parseInput(0), 2) ...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
4,108
aoc2021
MIT License
src/Day13.kt
6234456
572,616,769
false
{"Kotlin": 39979}
import java.util.* fun main() { val digit = """\d+""".toRegex() fun parse(s:String):List<Any>{ val stack = Stack<Any>() var cnt = 0 while(cnt < s.length){ if(s[cnt] == '['){ stack.push('[') }else if (digit.matchesAt(s, cnt)){ val v = ...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
2,073
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
mythicaleinhorn
572,689,424
false
{"Kotlin": 11494}
fun IntRange.contains(range: IntRange): Boolean { return this.first <= range.first && this.last >= range.last } fun IntRange.overlaps(range: IntRange): Boolean { for (i in this) { if (range.contains(i)) { return true } } return false } fun main() { fun part1(input: Lis...
0
Kotlin
0
0
959dc9f82c14f59d8e3f182043c59aa35e059381
1,737
advent-of-code-2022
Apache License 2.0
mapigate/src/main/java/com/github/unbearables/mapigate/gps/DijkstraGraph.kt
unbearables
342,620,219
false
{"Kotlin": 28908}
package com.github.unbearables.mapigate.gps import com.github.unbearables.mapigate.map.MapMarker data class Edge(val from: MapMarker, val to: MapMarker, val value: Double) data class DijkstraResult(val markers: List<MapMarker>, val distanceStepMap: Map<Any, Double>, val totalDistance: Doubl...
0
Kotlin
0
1
db314e26978d89e450137b24ddf54bb8e1611a19
3,567
mapigate
Apache License 2.0
src/Day05.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
fun main() { class Command( val amount: Int, val from: Int, val to: Int ) class Puzzle( val commands: List<Command>, val stacks: Array<ArrayDeque<Char>> ) fun parseCommands(input: List<String>) = input.map { val split = it.split(" ") Command...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
2,332
aoc-2022
Apache License 2.0
src/kotlin2022/Day08.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2022 import readInput import java.util.* fun main() { val gameInput = readInput("Day08_test") val mapOfTrees = parseInput(gameInput) var score = 0 val scoreSet = TreeSet<Int>() for ((i, row) in mapOfTrees.withIndex()) { for ((n, tree) in row.withIndex()) { if (no...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
2,306
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/solutions/Day16ProboscideaVolcanium.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Input import utils.Solution import kotlin.math.max // run only this day fun main() { Day16ProboscideaVolcanium() } class Day16ProboscideaVolcanium : Solution() { private val thirty = 30 init { begin("Day 16 - Proboscidea Volcanium") val input = Input.parse...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
6,846
advent-of-code-2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumFinishTime.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,478
kotlab
Apache License 2.0
src/main/kotlin/Day15.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.* import kotlin.math.abs fun main() { val input = readFileAsList("Day15") println(Day15.part1(input, 10)) println(Day15.part2(input, 4000000)) } object Day15 { fun part1(input: List<String>, lookupY: Int): Int { val sensors = parseSensors(input) val coveredXsAtY = cov...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
2,792
advent-of-code-2022
Apache License 2.0
src/Day03.kt
KliminV
573,758,839
false
{"Kotlin": 19586}
fun main() { fun part1(input: List<String>): Int { return input.map { it.chunkAtIndex(it.length / 2) } .map { strings -> val things = strings.get(0).toCharArray().toSet() val wrongThing = strings.get(1).filter { things.contains(it) } ...
0
Kotlin
0
0
542991741cf37481515900894480304d52a989ae
1,250
AOC-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day09/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day09 import java.io.File import kotlin.math.* data class Point(val x: Int, val y: Int) { operator fun plus(move: Move): Point { return Point(x + move.dx, y + move.dy) } fun follow(target: Point): Point { val dx = target.x - x val dy = target.y - y ...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
1,937
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-08.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.IntGrid import com.github.ferinagy.adventOfCode.get import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import com.github.ferinagy....
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,360
advent-of-code
MIT License
src/Day04.kt
bananer
434,885,332
false
{"Kotlin": 36979}
fun main() { class Field( val number: Int, var checked: Boolean = false, ) { override fun toString(): String = (if (checked) "X" else " ") + number } val boardSize = 5 class Board( val fields: Array<Array<Field>>, var win: Boolean = false, ) { c...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
3,863
advent-of-code-2021
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2023/Day17.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import arrow.core.partially1 import arrow.core.partially2 import ru.timakden.aoc.util.Point import ru.timakden.aoc.util.Point.Companion.DOWN import ru.timakden.aoc.util.Point.Companion.LEFT import ru.timakden.aoc.util.Point.Companion.RIGHT import ru.timakden.aoc.util.Point.Companion.UP...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,559
advent-of-code
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-15.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText fun main() { val input = readInputText(2023, "15-input") val test1 = readInputText(2023, "15-test1") println("Part1:") part1(test1).println() part...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,546
advent-of-code
MIT License
2022/Day23.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { data class Pos( val x: Int, val y: Int ) { fun nw() = Pos(x-1, y-1) fun n() = Pos(x, y-1) fun ne() = Pos(x+1, y-1) fun e() = Pos(x+1, y) fun se() = Pos(x+1, y+1) fun s() = Pos(x, y+1) fun sw() = Pos(x-1, y+1) fun w() = ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
2,241
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/me/ccampo/librepoker/engine/util/HandEvaluator.kt
ccampo133
113,806,624
false
null
package me.ccampo.librepoker.engine.util import me.ccampo.librepoker.engine.model.Card import me.ccampo.librepoker.engine.model.Hand import me.ccampo.librepoker.engine.model.HandScore import me.ccampo.librepoker.engine.model.HandType /** * @author <NAME> */ /** * First sort the cards in descending order, and then...
0
null
0
0
77e678d9c0d871569ebcbedb3f0c835722a4f4c3
2,486
librepoker
MIT License
src/main/kotlin/aoc/year2023/Day03.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2023 import aoc.Puzzle private typealias Cell = Pair<Int, Int> /** * [Day 3 - Advent of Code 2023](https://adventofcode.com/2023/day/3) */ object Day03 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { val lines = input.lines() val (symbolCells, digitCells) =...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
2,374
advent-of-code
Apache License 2.0
src/days/Day01.kt
EnergyFusion
572,490,067
false
{"Kotlin": 48323}
fun main() { fun part1(input: List<String>): Int { val elfCalorieMap = mutableMapOf<Int, Int>() var currentElf = 0 for (line in input) { if (line.isBlank()) { currentElf++ } else { val calorie = line.toInt() val currentV...
0
Kotlin
0
0
06fb8085a8b1838289a4e1599e2135cb5e28c1bf
1,663
advent-of-code-kotlin
Apache License 2.0
2022/src/main/kotlin/de/skyrising/aoc2022/day11/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day11 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.longs.LongArrayList import it.unimi.dsi.fastutil.longs.LongList import java.util.function.LongConsumer data class Monkey(val items: LongList, val op: (Long) -> Long, val divisor: Int, val trueMonkey: Int, val falseMonkey: Int) {...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,216
aoc
MIT License
src/Day10.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
class CPU { private val cyclesMap = mutableMapOf<IntRange, Int>() private var x = 1 private var cycle = 1 private val toCompute = listOf(20, 60, 100, 140, 180, 220) fun add(v: Int) { val startCycle = cycle cycle += 2 cyclesMap[startCycle until cycle] = x x += v ...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
2,064
aoc2022
Apache License 2.0
src/day13.kts
miedzinski
434,902,353
false
{"Kotlin": 22560, "Shell": 113}
data class Point(val x: Int, val y: Int) enum class Axis { X, Y } data class Fold(val axis: Axis, val position: Int) val dots = generateSequence(::readLine) .takeWhile(String::isNotEmpty) .map { it.split(',').map(String::toInt).let { Point(it[0], it[1]) } } .toSet() val foldRegex = "fold along ([xy])=(\\d...
0
Kotlin
0
0
6f32adaba058460f1a9bb6a866ff424912aece2e
1,707
aoc2021
The Unlicense
advent-of-code-2021/src/main/kotlin/Day11.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 11: Dumbo Octopus //https://adventofcode.com/2021/day/11 import java.io.File import kotlin.math.sqrt fun main() { val octopuses = mutableListOf<Octopus>() File("src/main/resources/Day11.txt").readLines().forEachIndexed { x, line -> line.toList().forEachIndexed { y, energy -> octopuse...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,449
advent-of-code
Apache License 2.0
src/main/kotlin/Day11.kt
corentinnormand
725,992,109
false
{"Kotlin": 40576}
import kotlin.math.abs fun main() { Day11().main() } class Day11 : Aoc("day11.txt") { val test = """ ...#...... .......#.. #......... .......... ......#... .#........ .........# .......... .......#.. #...#..... """.trimIndent(...
0
Kotlin
0
0
2b177a98ab112850b0f985c5926d15493a9a1373
2,679
aoc_2023
Apache License 2.0
src/Day09.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
import kotlin.math.abs data class Move(val dx: Int, val dy: Int) enum class Direction(val move: Move) { R(Move(1, 0)), L(Move(-1, 0)), U(Move(0, 1)), D(Move(0, -1)); } fun main() { fun lostTouch(head: Point, tail: Point): Boolean = !(abs(head.x - tail.x) <= 1 && abs(head.y - tail.y) <= 1)...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
2,474
advent-of-code-2022
Apache License 2.0
src/Day01.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 142 private const val EXPECTED_2 = 281 private class Day01(isTest: Boolean) : Solver(isTest) { fun part1(): Any { return readAsLines().sumOf { line -> val first = line.first { it.isDigit() } val last = line.last { it.isDigit() } (first - '0...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,682
advent-of-code-2022
Apache License 2.0
src/AoC7.kt
Pi143
317,631,443
false
null
import java.io.File fun main() { println("Starting Day 7 A Test 1") calculateDay7PartA("Input/2020_Day7_A_Test1") println("Starting Day 7 A Real") calculateDay7PartA("Input/2020_Day7_A") println("Starting Day 7 B Test 1") calculateDay7PartB("Input/2020_Day7_A_Test1") println("Starting Day...
0
Kotlin
0
1
fa21b7f0bd284319e60f964a48a60e1611ccd2c3
4,261
AdventOfCode2020
MIT License
src/Day08.kt
PauliusRap
573,434,850
false
{"Kotlin": 20299}
fun main() { fun createGrid(input: List<String>): Array<Array<Int>> { val matrix = Array<Array<Int>>(input.size) { emptyArray() } input.forEachIndexed { index, line -> line.forEach { matrix[index] = matrix[index] + it.digitToInt() } } return m...
0
Kotlin
0
0
df510c3afb104c03add6cf2597c433b34b3f7dc7
3,792
advent-of-coding-2022
Apache License 2.0
src/day21/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day21 import java.io.File fun Int.mod(m: Int) = ((this - 1) % m) + 1 class Die(val sides: Int) { var value = 1 var rolled = 0 fun roll() : Int { return value.also { value = (value + 1).mod(sides) rolled++ } } } fun partOne(initialPositions: List<Int>) ...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
2,155
advent-of-code-2021
MIT License
src/main/Day07.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day07 import utils.readInput typealias Path = List<String> data class File(val name: String, val size: Long) data class Directory( val name: String, private val files: MutableList<File> = mutableListOf(), private val subdirectories: MutableList<Directory> = mutableListOf(), ) { fun addDirect...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
2,570
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2015/day06_fire_hazard/FireHazard.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2015.day06_fire_hazard import geom2d.Point import java.util.* fun main() { util.solve(543903, ::partOne) util.solve(14687245, ::partTwo) } private fun String.toPoint(): Point { val dims = split(",") .map { it.toLong() } return Point(dims[0], dims[1]) } private fun gridRanges(a: Po...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,553
aoc-2021
MIT License
src/Day04.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
fun main() { fun getElfRangePairs(input: List<String>): List<Pair<IntRange, IntRange>> { return input.map { pair -> val parts = pair.split(",") val elf1 = parts[0].split("-") val elf2 = parts[1].split("-") val rangeElf1 = elf1[0].toInt() .. elf1[1].toInt() ...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
1,201
advent-of-code-2022-kotlin
Apache License 2.0
advent-of-code-2022/src/Day23.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { val testInput = readInput("Day23_test") val input = readInput("Day23") "Part 1" { part1(testInput) shouldBe 110 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 20 measureAnswer { part2(input) } } } private fun part1(input: Lis...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
3,461
advent-of-code
Apache License 2.0
src/main/kotlin/twentytwentytwo/Day18.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import twentytwentytwo.Structures.Point3d fun main() { val input = {}.javaClass.getResource("input-18.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val test = {}.javaClass.getResource("input-18-1.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val day = Day18(input) ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
2,510
aoc202xkotlin
The Unlicense
kotlin/src/katas/kotlin/leetcode/max_points_on_a_line/FindPoints.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.max_points_on_a_line import datsok.shouldEqual import org.junit.jupiter.api.Test import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.math.absoluteValue // // https://leetcode.com/problems/max-points-on-a-line ❌ // // Given n points on a 2D plane, find...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
5,771
katas
The Unlicense
src/Day03.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
fun main() { fun priority(char: Char): Int { return when (char.isUpperCase()) { true -> char.code - 38 else -> char.code - 96 } } fun part1(input: List<String>): Int { return input.map { it.trim().toCharArray() } .map { val pair =...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
1,199
Kotlin-AoC-2022
Apache License 2.0
src/main/kotlin/dev/kosmx/aoc23/springs/Sets.kt
KosmX
726,056,762
false
{"Kotlin": 32011}
package dev.kosmx.aoc23.springs import java.io.File import java.math.BigInteger import javax.swing.Spring fun <T> Collection<T>.subsets(k: Int): Sequence<Collection<T>> = sequence { if (k > size) throw IllegalArgumentException("k must be smaller than the superset size") if (k == size) yield(this@subsets) ...
0
Kotlin
0
0
ad01ab8e9b8782d15928a7475bbbc5f69b2416c2
4,076
advent-of-code23
MIT License
src/Day03.kt
cornz
572,867,092
false
{"Kotlin": 35639}
fun main() { fun charToIntValues(char: Char): Int { return if (char.isUpperCase()) { char.code - 64 + 26 } else { char.code - 96 } } fun findCommonItem(line: String): Char? { val mid = line.length / 2 val parts = arrayOf(line.substring(0, mid...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
1,769
aoc2022
Apache License 2.0
2022/src/Day23.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src import java.util.function.Predicate val cardinals = listOf( Pair(-1,1), // northwest Pair(0,1), // north Pair(1,1), // northeast Pair(1,0), // east Pair(-1,0), // west Pair(-1,-1), // southwest Pair(0,-1), // south Pair(1,-1) // southeast ) var moveOrder = mutableListOf( ...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
2,986
AoC
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day01/day1.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day01 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() println("Sum of all calibration values is: ${sumCalibrationValues(parseCalibrationValues(lines))}") println("...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,463
advent-of-code
MIT License
src/main/kotlin/de/pgebert/aoc/days/Day14.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day class Day14(input: String? = null) : Day(14, "Parabolic Reflector Dish", input) { data class Point(val x: Int, val y: Int) private var cubicStones = setOf<Point>() private var roundStones = setOf<Point>() init { parseStones() } ...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
2,844
advent-of-code-2023
MIT License
kotlin/graphs/shortestpaths/DijkstraSegmentTree.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.shortestpaths import java.util.stream.Stream // https://en.wikipedia.org/wiki/Dijkstra's_algorithm object DijkstraSegmentTree { // calculate shortest paths in O(E*log(V)) time and O(V) memory fun shortestPaths(edges: Array<List<Edge>>, s: Int, prio: LongArray, pred: IntArray) { Arrays.f...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,383
codelibrary
The Unlicense
src/main/kotlin/days/Day11.kt
julia-kim
569,976,303
false
null
package days import readInput fun main() { fun parseMonkeys(input: List<String>) = input.chunked(7) { val monkey = Monkey() it.forEach { string -> val line = string.trim() when { line.startsWith("Monkey") -> return@forEach line.startsWith("St...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
3,415
advent-of-code-2022
Apache License 2.0
kotlin/src/com/leetcode/16_3SumClosest.kt
programmerr47
248,502,040
false
null
package com.leetcode import kotlin.math.abs private class Solution16 { fun threeSumClosest(nums: IntArray, target: Int): Int { val sorted = nums.sorted() var result = sorted[0] + sorted[1] + sorted[2] for (i1 in sorted.indices) { for (i2 in i1 + 1 until sorted.size) { ...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,966
problemsolving
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day12/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day12 import com.kingsleyadio.adventofcode.util.readInput fun part1(graph: Map<String, List<String>>, start: String, end: String): Int { var count = 0 fun travel(current: String, visited: MutableSet<String>) { if (current == end) { count++; return } ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,808
adventofcode
Apache License 2.0
src/main/kotlin/aoc2022/Day05.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import popTo import readInput import java.util.Stack data class Instruction(val count: Int, val from: Int, val to: Int) { companion object { fun fromString(str: String): Instruction { // example: move 1 from 2 to 1 val split = str.split(" ").toList().mapNotNull { it...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,159
adventOfCode
Apache License 2.0
src/me/bytebeats/algo/kt/design/NumMatrix.kt
bytebeats
251,234,289
false
null
package me.bytebeats.algo.kt.design class NumMatrix(val matrix: Array<IntArray>) {//308 fun update(row: Int, col: Int, `val`: Int) { matrix[row][col] = `val` } fun sumRegion(row1: Int, col1: Int, row2: Int, col2: Int): Int { var sum = 0 for (i in row1..row2) { for (j i...
0
Kotlin
0
1
7cf372d9acb3274003bb782c51d608e5db6fa743
1,969
Algorithms
MIT License
src/day22/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day22 import java.io.File import kotlin.math.max import kotlin.math.min data class Line(val min: Int, val max: Int) { fun overlap(other: Line): Line? { val start = max(min, other.min) val end = min(max, other.max) return if (start <= end) Line(start, end) else null } } data cl...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,927
advent-of-code-2021
MIT License
src/Day03.kt
psabata
573,777,105
false
{"Kotlin": 19953}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val size = rucksack.length val compartment1 = rucksack.substring(0, size / 2).toSet() val compartment2 = rucksack.substring(size / 2, size).toSet() val item = compartment1.int...
0
Kotlin
0
0
c0d2c21c5feb4ba2aeda4f421cb7b34ba3d97936
1,169
advent-of-code-2022
Apache License 2.0
src/Day07.kt
cerberus97
579,910,396
false
{"Kotlin": 11722}
fun main() { class Node(val name: String, val parent: Node? = null) { val children = mutableMapOf<String, Node>() val files = mutableMapOf<String, Int>() var size = 0 fun getChild(childName: String): Node { if (!children.containsKey(childName)) children[childName] = Node(childName, this) ...
0
Kotlin
0
0
ed7b5bd7ad90bfa85e868fa2a2cdefead087d710
1,674
advent-of-code-2022-kotlin
Apache License 2.0
src/day07/Day07.kt
TheJosean
573,113,380
false
{"Kotlin": 20611}
package day07 import readInput fun main() { data class Directory(val size: Int, val index: Int) fun parseDirectories(input: List<String>, startingIndex: Int): List<Directory> { val items = input.subList(startingIndex + 2, input.size).takeWhile { !it.startsWith('$') } var size = 0; var index ...
0
Kotlin
0
0
798d5e9b1ce446ba3bac86f70b7888335e1a242b
1,739
advent-of-code
Apache License 2.0
src/Day11.kt
chbirmes
572,675,727
false
{"Kotlin": 32114}
fun main() { fun part1(input: List<String>): Long { val monkeys = input.filter { it.isNotEmpty() } .chunked(6) { Monkey.parse(it) } repeat(20) { monkeys.playRound(true) } return monkeys.map { it.inspectionCount } .sortedDescending() .let { it[0] * it[1] }...
0
Kotlin
0
0
db82954ee965238e19c9c917d5c278a274975f26
2,885
aoc-2022
Apache License 2.0
src/Day04.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
import org.jetbrains.kotlinx.multik.api.toNDArray import org.jetbrains.kotlinx.multik.ndarray.operations.toListD2 fun firstPart04(list : List<String>) { val extractions = list.first().split(",").map { it.toInt() } val tables = list.subList(1, list.size).map { it.split(" ").filter { it.isNotEmpty() }.map { it....
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
2,893
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day13Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith private fun solution1(input: String) = parse(input) .mapIndexed { index, packets -> index to packe...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
2,782
adventofcode-kotlin
MIT License
src/day15/Parser.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day15 import readInput import java.util.regex.Pattern data class Point (val x: Int, val y: Int) { fun add (dx: Int, dy: Int) = Point (x + dx, y + dy) fun min (other: Point): Point = Point (Math.min (x, other.x), Math.min (y, other.y)) fun max (other: Point): Point = Point (Math.max (x, other.x), M...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,919
advent_of_code_2022
Apache License 2.0
src/main/kotlin/day08/Day08.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day08 import readInput import java.util.BitSet import java.util.PriorityQueue fun main() { fun part1(input: List<String>): Int { val m = input.size val n = input[0].length val bitSet = BitSet(m * n) fun check(startX: Int, startY: Int, deltaX: Int, deltaY: Int) { ...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
2,708
aoc2022
Apache License 2.0
src/Day08.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun parseInput(input: List<String>): Map<Coordinates, Tree> { val rows = input.size val cols = input[0].length val grid = mutableMapOf<Coordinates, Tree>() for(row in 0 until rows) { for (col in 0 until cols) { val position = Coordinates(row,...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
5,292
aoc2022
Apache License 2.0
src/Day16.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
import Graph16.* fun main() { fun parseInput(input: List<String>): Set<Valve> = input .asSequence() .filter(String::isNotBlank) .map { it .replace(Regex("(Valve |has flow rate=|; tunnels? leads? to valves?)"), "") .split(' ', ',') ...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
6,441
aoc-2022
Apache License 2.0
src/Day04.kt
Ramo-11
573,610,722
false
{"Kotlin": 21264}
fun main() { fun part1(input: List<String>): Int { var pair1 = "" var pair2 = "" var total = 0 for (i in input.indices) { pair1 = input[i].split(",")[0] pair2 = input[i].split(",")[1] if ((pair1.split("-")[0].toInt() >= pair2.split("-")[0].toInt...
0
Kotlin
0
0
a122cca3423c9849ceea5a4b69b4d96fdeeadd01
1,485
advent-of-code-kotlin
Apache License 2.0
archive/2022/Day04.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
package aoc2022 private const val EXPECTED_1 = 2 private const val EXPECTED_2 = 4 private class Day04(isTest: Boolean) : Solver(isTest) { fun part1(): Any { return readAsLines().sumInt { val parts = it.split(",") var elf1 = parts[0].split("-").map { it.toInt() } var elf...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,293
advent-of-code-2022
Apache License 2.0