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/Day11.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { data class Monkey( var items: MutableList<Long>, val operation: String, val opValue: String, val div: Long, val ifTrue: Int, val ifFalse: Int, var itemsRevised: Long ) fun buildMonkeys(input: List<String>): List<Monkey> = buildList { ...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
3,036
AoC-2022
Apache License 2.0
src/main/kotlin/day3.kt
sviams
726,160,356
false
{"Kotlin": 9233}
import kotlin.math.max import kotlin.math.min object day3 { data class Number(val chars: String, val startIndex: Int, val row: Int) { fun toInt() = chars.toInt() val range by lazy { IntRange(startIndex, startIndex+chars.length-1) } fun isAdjacentToSymbol(world: List<Line>): Boolean = ...
0
Kotlin
0
0
4914a54b21e8aac77ce7bbea3abc88ac04037d50
3,055
aoc23
Apache License 2.0
src/year2023/day03/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day03 import arrow.core.nonEmptyListOf import utils.Point import utils.ProblemPart import utils.neighbors import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 3, transform = ::parse) runAlgorithm( realInput = realInput, ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,441
Advent-of-Code
Apache License 2.0
src/year_2021/day_09/Day09.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_09 import readInput import util.neighbors import util.product object Day09 { /** * @return */ fun solutionOne(text: List<String>): Int { val heightmap = parseText(text) val lowPoints = heightmap.flatMapIndexed { rowIndex, row -> row.filterIndexed {...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,826
advent_of_code
Apache License 2.0
src/main/kotlin/aoc2023/Day02.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils enum class Colours { red, blue, green } typealias BallCount = Map<Colours, Int> fun BallCount.fitsIn(limits: BallCount) = limits.all { (col, limit) -> (this[col] ?: 0) <= limit } data class Game(val id: Int, val contents: List<BallCount>) { fun fitsIn(limits: Bal...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,204
aoc-2022-kotlin
Apache License 2.0
src/y2023/Day08.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.product import util.readInput import util.timingStatistics import y2015.Day20 import y2022.Day15.toPair object Day08 { private fun parse(input: List<String>): Pair<List<(Pair<String, String>) -> String>, Map<String, Pair<String, String>>> { val leftRight: List<(Pair<String, Strin...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,970
advent-of-code
Apache License 2.0
src/main/day19/Part1.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day19 import day19.Resource.* import groupUntil import readInput import java.util.* typealias Materials = Map<Resource, Int> fun main() { val blueprints = parseTestInput() val robots = Robots(mapOf(Robot(ORE) to 1, Robot(CLAY) to 1)) val materials = mapOf(ORE to 2, CLAY to 1) val qualityLeve...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
6,174
aoc2022
Apache License 2.0
2021/src/day20/Day20.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day20 import readInput typealias Table = Array<CharArray> fun Table.print() { for (line in this) { println(line) } } fun List<String>.toTable() : Table { val ret = Array(size) { CharArray(0) } for (idx in indices) ret[idx] = this[idx].toCharArray() return ret } fun Table.getVal...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,437
advent-of-code
Apache License 2.0
src/2021/Day8_2.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File fun String.matchAnyOrder(values: String) = this.toList().containsAll(values.toList()) fun map(pattern: List<String>, nine: String, six: String, five: String, three: String, two: String, zero: String): Map<String, String> = mapOf<String, String>( Pair(pattern.filter { it.length == nine.l...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
3,127
adventofcode
MIT License
src/day13/Day13.kt
palpfiction
572,688,778
false
{"Kotlin": 38770}
package day13 import readInput sealed interface Item : Comparable<Item> class ListItem(val items: List<Item> = listOf()) : Item { override fun toString(): String { return "$items" } override infix fun compareTo(other: Item): Int = when (other) { is IntItem -> this compareTo L...
0
Kotlin
0
0
5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7
2,849
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day8.kt
teunw
573,164,590
false
{"Kotlin": 20073}
package days import java.util.* data class Point2D(val x: Int, val y: Int) : Comparable<Point2D> { fun copy(newX: Int? = null, newY: Int? = null): Point2D { return Point2D(newX ?: this.x, newY ?: this.y) } override fun compareTo(other: Point2D): Int { return ((this.x - other.x)) - ((other...
0
Kotlin
0
0
149219285efdb1a4d2edc306cc449cce19250e85
3,331
advent-of-code-22
Creative Commons Zero v1.0 Universal
src/year2022/day08/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day08 import readInput fun main() { val day = "08" val expectedTest1 = 21 val expectedTest2 = 8 fun checkIt(trees: CharSequence, index: Int, sz: Char) = trees.subSequence(0, index).any { t -> t >= sz } && trees.subSequence(index+1, tr...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,189
adventOfCode
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/descreasing_subsequences/DecreasingSubsequences.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.descreasing_subsequences import nonstdlib.printed import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/350233/Google-or-Summer-Intern-OA-2019-or-Decreasing-Subsequences */ class DecreasingSubsequencesTests { @Test fun `split array in...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,436
katas
The Unlicense
src/aoc2021/Day09.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput fun main() { val (year, day) = "2021" to "Day09" data class Point(val x: Int, val y: Int, val number: Int, var visited: Boolean = false) { val directions = arrayOf(1 to 0, -1 to 0, 0 to 1, 0 to -1) fun adjacent(mx: Int, my: Int) = directions.mapNo...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,977
aoc-kotlin
Apache License 2.0
src/main/kotlin/adventofcode2023/day6/day6.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day6 import adventofcode2023.readInput import kotlin.math.sqrt import kotlin.time.measureTime fun main() { val input = readInput("day6") println("Day 6") val duration1 = measureTime { println("Puzzle 1: ${puzzle1(input)}") } println("Puzzle 1 took $duration1") ...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
3,819
adventofcode2023
MIT License
src/Day02.kt
emersonf
572,870,317
false
{"Kotlin": 17689}
typealias Round = Pair<Char, Char> fun toRound(line: String): Round { val segments = line.split(" ") return segments[0].first() to segments[1].first() } fun Round.scoreWithSecondColumnAsHand(): Int { // A == X == Rock // B == Y == Paper // C == Z == Scissors return when { first == 'A' ...
0
Kotlin
0
0
0e97351ec1954364648ec74c557e18ccce058ae6
2,076
advent-of-code-2022-kotlin
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day23/day23.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day23 import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input23-test.txt" const val FILENAME = "input23.txt" fun main() { val map = Puzzle.parse(readLines(2023, FILENAME)) val nodes = map.getNodes() println(nodes.longestPath...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,359
advent-of-code
Apache License 2.0
src/main/day18/day18.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day18 import readInput fun main() { val input = readInput("main/day18/Day18") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int = input.toCubes().surfaceArea() fun part2(input: List<String>): Int = exteriorSurfaceArea(input.toCubes()) private fun List<String>.toC...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
1,528
aoc-2022
Apache License 2.0
src/year2023/Day4.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import powerOfTwo import readLines fun main() { val input = parseInput(readLines("2023", "day4")) val testInput = parseInput(readLines("2023", "day4_test")) check(part1(testInput) == 13) println("Part 1:" + part1(input)) check(part2(testInput) == 30) println("Part 2:" + part...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
1,511
advent_of_code
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day22/Day22.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day22 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day22 : Day { override val input = readInputLines(22).map { Step.from(it) } override fun part1(): Number { return input .filter { it.c...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,528
aoc2021
MIT License
src/main/kotlin/advent/y2018/day3.kt
IgorPerikov
134,053,571
false
{"Kotlin": 29606}
package advent.y2018 import misc.readAdventInput /** * https://adventofcode.com/2018/day/3 */ const val notVisited = 0 const val visited = 1 const val collision = 2 fun main(args: Array<String>) { val claims = readClaims() val collisionsMap = buildCollisionsMap(claims) calculateCollisions(collisionsMap...
0
Kotlin
0
0
b30cf179f7b7ae534ee55d432b13859b77bbc4b7
2,286
kotlin-solutions
MIT License
src/main/kotlin/Day08.kt
joostbaas
573,096,671
false
{"Kotlin": 45397}
fun List<String>.parse(): Forest = Forest(map { line -> line.map { it.digitToInt() } }) data class Tree(val x: Int, val y: Int) { fun treesBetween(other: Tree): List<Tree> { require(other.x == x || other.y == y) require(other != this) return when { other.x < x -> (other.x u...
0
Kotlin
0
0
8d4e3c87f6f2e34002b6dbc89c377f5a0860f571
2,820
advent-of-code-2022
Apache License 2.0
kotlin/src/Day17.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt import kotlin.math.abs fun main() { fun updateVelocity(velocity: Pair<Int, Int>): Pair<Int, Int> { val xVelocityChange = if (velocity.first == 0) { 0 } else if (velocity.first > 0) { -1 } else { 1 } return (velocity.first + xVelocityChange) to (velocity.second - 1)...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
2,464
aoc-2021
MIT License
src/day16/Day16.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day16 import readInput data class Node(val value: Int, val next: MutableList<String>) data class BfsEntry(val position: String, val remainder: Int, val open: List<String>) fun main() { fun floydWarshall(graph: Map<String, Node>): Map<String, Map<String, Int>> { val distances = mutableMapOf<Stri...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
4,379
advent-of-code-2022
Apache License 2.0
src/Day02.kt
brunojensen
572,665,994
false
{"Kotlin": 13161}
private operator fun String.component1() = this[0].toString() private operator fun String.component2() = this[1].toString() private operator fun String.component3() = this[2].toString() private enum class Play(val point: Int, val beats: Play? = null, val loses: Play? = null) { // Rock, Paper, Scissor A(0), B(0), ...
0
Kotlin
0
0
2707e76f5abd96c9d59c782e7122427fc6fdaad1
1,572
advent-of-code-kotlin-1
Apache License 2.0
gcj/y2020/kickstart_d/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.kickstart_d private fun solve(): Double { val (n, a, b) = readInts() val p = listOf(0, 0) + readInts() val p1 = probs(p, a) val p2 = probs(p, b) val x = (1 until p.size).map { p1[it].toLong() * p2[it] }.sum() return p.size - 1 - x / (p.size - 1.0) / (p.size - 1) } private fun probs(p: List<Int...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,092
competitions
The Unlicense
src/Day05.kt
Miguel1235
726,260,839
false
{"Kotlin": 21105}
val obtainSeeds = { input: List<String> -> input[0].split(":")[1].trim().split(" ") } private data class Mapper(val name: String, val ranges: List<Range>) private data class Range(val ds: Long, val de: Long, val ss: Long, val se: Long, val range: Long, val diff: Long) private fun obtainMappers(input: List<String>): L...
0
Kotlin
0
0
69a80acdc8d7ba072e4789044ec2d84f84500e00
2,686
advent-of-code-2023
MIT License
src/main/kotlin/aoc2023/Day04.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput import java.util.* import java.util.regex.Pattern import kotlin.math.pow private data class Card(val id: Int, val winningNumbers: Set<Int>, val cardNumbers: Set<Int>) { val matches = winningNumbers.intersect(cardNumbers) val worth = if (matches.isEmpty()) 0 else 2f.pow(matches...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,150
adventOfCode
Apache License 2.0
src/day02/day02.kt
taer
573,051,280
false
{"Kotlin": 26121}
package day02 import readInput enum class RPS(val value: Int) { ROCK(1), PAPER(2), Scissors(3) } fun translate(input: String): RPS { return when (input) { "A", "X" -> RPS.ROCK "B", "Y" -> RPS.PAPER "C", "Z" -> RPS.Scissors else -> throw RuntimeException("Dunno what $in...
0
Kotlin
0
0
1bd19df8949d4a56b881af28af21a2b35d800b22
2,551
aoc2022
Apache License 2.0
src/main/kotlin/Day19.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset fun main() { class Rule(val category: Char, val limit: Int, val greater: Boolean, val result: String) { fun run(part: Map<Char, Int>): String? { return if (greater) { if (part[category]!! > limit) result else null ...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
4,911
aoc-2023-in-kotlin
Apache License 2.0
codeforces/globalround16/f.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.globalround16 private fun solve() { val (_, m) = readInts() val points = readInts().sorted() val segments = List(m) { readInts().let { it[0] to it[1] } } val groups = List(points.size + 1) { mutableListOf<Pair<Int, Int>>() } for (segment in segments) { val index = (-1..points.size).binarySear...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,190
competitions
The Unlicense
src/Day18.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
enum class Material { WATER, LAVA } fun main() { data class Cube(val x: Int, val y: Int, val z: Int) { operator fun plus(other: Cube): Cube { return Cube(x + other.x, y + other.y, z + other.z) } operator fun minus(other: Cube): Cube { return Cube(x - other.x, y ...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
2,695
aoc-2022
Apache License 2.0
src/Day08.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
fun List<Char>.distance(): Int = if (isNotEmpty()) size else 1 fun List<Char>.takeUntilEquals(target: Int): List<Char> { val list = mutableListOf<Char>() for (c in this) { list.add(c) if (c.digitToInt() >= target) { break } } return list } fun main() { fun part1...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
2,406
advent-of-code-2022
Apache License 2.0
src/y2023/Day03.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Pos import util.indexOfAll import util.neighbors import util.readInput import util.timingStatistics object Day03 { private fun numbers(input: List<String>): List<Pair<Set<Pos>, Int>> { return input.flatMapIndexed { row, line -> val numbers = Regex("\\d+").findAll(line...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,648
advent-of-code
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day08/day8.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day08 import biz.koziolek.adventofcode.Coord import biz.koziolek.adventofcode.findInput import biz.koziolek.adventofcode.parse2DMap fun main() { val inputFile = findInput(object {}) val trees = parseTrees(inputFile.bufferedReader().readLines()) println("Trees vis...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,763
advent-of-code
MIT License
src/Day08.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { val day = "Day08" fun part1(input: List<String>): Int { var visible = 0 var forest = input.map { it -> it.toList().map { it.digitToInt() } } // Skip the edges for (i in 1..forest.size - 2) { for (j in 1..forest.size - 2) { var horizonta...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
3,787
advent-of-code-2022
Apache License 2.0
src/Day15.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
import kotlin.math.absoluteValue import kotlin.math.max fun main() { class Sensor(val x: Int, val y: Int, val bx: Int, val by: Int) { val d = (x - bx).absoluteValue + (y - by).absoluteValue } fun List<String>.sensors() = map { it.split('=', ',', ':') } .map { Sensor(it[1].toInt(), it[3].t...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
1,800
aockt
Apache License 2.0
src/Day03.kt
lukewalker128
573,611,809
false
{"Kotlin": 14077}
fun main() { val testInput = readInput("Day03_test") checkEquals(157, part1(testInput)) checkEquals(70, part2(testInput)) val input = readInput("Day03") println("Part 2: ${part2(input)}") println("Part 1: ${part1(input)}") } /** * Sums the priorities of items appearing in both compartments of...
0
Kotlin
0
0
c1aa17de335bd5c2f5f555ecbdf39874c1fb2854
1,567
advent-of-code-2022
Apache License 2.0
src/year_2023/day_12/Day12.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_12 import readInput data class SpringCollection( val pattern: List<Char>, val damageCounts: List<Int> ) object Day12 { private val memory = mutableMapOf<Pair<List<Char>, List<Int>>, Int>() /** * */ fun solutionOne(text: List<String>): Int { return text.sum...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,332
advent_of_code
Apache License 2.0
src/Day07.kt
rinas-ink
572,920,513
false
{"Kotlin": 14483}
import java.lang.Integer.min fun main() { data class Node( var name: String, var isFile: Boolean, var parent: Node? = null, var size: Int = 0 ) { var children: MutableList<Node> = mutableListOf() } var root = Node("/", false) fun countSize(r: Node): Int { if (!r.isFile) r....
0
Kotlin
0
0
462bcba7779f7bfc9a109d886af8f722ec14c485
2,709
anvent-kotlin
Apache License 2.0
src/Day02.kt
geodavies
575,035,123
false
{"Kotlin": 13226}
import Outcome.DRAW import Outcome.LOSE import Outcome.WIN import Shape.PAPER import Shape.ROCK import Shape.SCISSORS enum class Shape(private val mappings: List<String>) { ROCK(listOf("A", "X")), PAPER(listOf("B", "Y")), SCISSORS(listOf("C", "Z")); companion object { fun of(input: String): Shape { ...
0
Kotlin
0
0
d04a336e412ba09a1cf368e2af537d1cf41a2060
2,175
advent-of-code-2022
Apache License 2.0
src/Day09.kt
gsalinaslopez
572,839,981
false
{"Kotlin": 21439}
import kotlin.math.pow import kotlin.math.sqrt enum class Direction(val xDiff: Int, val yDiff: Int) { C(0, 0), R(1, 0), L(-1, 0), U(0, 1), UR(1, 1), UL(-1, 1), D(0, -1), DR(1, -1), DL(-1, -1) } fun main() { fun distance(x1: Int, x2: Int, y1: Int, y2: Int) = sqrt((x2 - x1).toDouble().pow(2) + (...
0
Kotlin
0
0
041c7c3716bfdfdf4cc89975937fa297ea061830
2,957
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
fun main() { fun parseInput(input: String): List<Char> { return input.split(' ').map { it[0] } } fun part1(input: List<String>): Int { val shapeValue = hashMapOf(Pair('X', 1), Pair('Y', 2), Pair('Z', 3)) val wins = hashMapOf(Pair('A', 'Y'), Pair('B', 'Z'), Pair('C', 'X')) return input .map...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
1,419
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day13.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
import kotlin.math.max fun main() { val input = readInput("Day13") printTime { println(Day13.part1(input)) } printTime { println(Day13.part2(input)) } } class Day13 { companion object { fun part1(input: List<String>): Int { val packetPairs = input.partitionOnElement("").map { it.ma...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
3,287
advent-of-code-22
Apache License 2.0
src/Day16.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { val day16 = Day16(readInput("inputs/Day16")) println(day16.part1()) println(day16.part2()) } class Day16(input: List<String>) { private val valves = input.map(Valve::from).associateBy(Valve::name) private val usefulValves = valves.filter { it.value.rate > 0 } private val distances...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,840
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2020/AllergenAssessment.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.nonEmptyLines fun allergenAssessment1(input: String): Int { val foods = input.nonEmptyLines().map { Food.parse(it) } val ingredientsWithAllergens = ingredientsByAllergens(foods).flatMap { it.value } val safe = foods.flatMap { it.ingredients...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,012
advent-of-code
MIT License
advent-of-code-2023/src/main/kotlin/Day07.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
// Day 07: Camel Cards // https://adventofcode.com/2023/day/7 import java.io.File data class Card(val char: Char) fun Card.getValue(hasJoker: Boolean): Int { return when { char.isDigit() -> char.digitToInt() char == 'T' -> 10 char == 'J' && hasJoker.not() -> 11 char == 'J' && hasJ...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
3,426
advent-of-code
Apache License 2.0
src/2022/Day15.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput import kotlin.math.abs fun main() { fun findDistressedBeacon(sensorToDistance: List<Day15Input>, maxSize: Int): YPoint { (0..maxSize).forEach { y -> val ranges = sensorToDistance.toReverseRanges(y, maxSize) if (ranges.isNotEmpty()) { ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,799
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
import kotlin.math.abs fun main() { fun _process(input: List<String>, noOfKnots: Int): Int { val visited = mutableSetOf<Pair<Int, Int>>() visited.add(Pair(0, 0)) val knots = mutableListOf<Pair<Int, Int>>() (0..noOfKnots).forEach { _ -> knots.add(Pair(0, 0)) } input.forEachI...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
2,581
advent-of-code-2022-kotlin
Apache License 2.0
src/Day07.kt
seana-zr
725,858,211
false
{"Kotlin": 28265}
const val JOKER = true enum class HandType { HIGH, ONE_PAIR, TWO_PAIR, THREE, FULL, FOUR, FIVE; } fun String.distinct() = toSet().size fun String.frequencies() = groupingBy { it }.eachCount() fun String.getHandType(): HandType { return when (distinct()) { 1 -> HandType.FIVE 2 -> { ...
0
Kotlin
0
0
da17a5de6e782e06accd3a3cbeeeeb4f1844e427
3,740
advent-of-code-kotlin-template
Apache License 2.0
src/Day15.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
import kotlin.math.abs fun Coordinate.manhattanDistanceTo(other: Coordinate) = abs(x - other.x) + abs(y - other.y) data class Sensor( val location: Coordinate, val closestBeacon: Coordinate, val distanceToBeacon: Int = location.manhattanDistanceTo(closestBeacon) ) fun main() { fun readSensors(inp...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
2,678
advent-of-code-2022
Apache License 2.0
src/Day07.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private sealed interface FileSystemObject { val name: String val parent: Directory val size: Int } private sealed interface Directory : FileSystemObject { val children: MutableList<FileSystemObject> fun getChild(name: String): FileSystemObject } private class File (override val name: String, overr...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
3,184
advent-of-code-22
Apache License 2.0
src/main/kotlin/Day5.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import java.lang.Long.min import kotlin.String import kotlin.collections.List object Day5 { data class Range(val start: Long, val end: Long) data class RangeMapping(val destinationRangeStart: Long, val sourceRangeStart: Long, val rangeLength: Long) { fun next(id: Long): Long { return if (so...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
5,096
kotlin-kringle
Apache License 2.0
src/Day15.kt
6234456
572,616,769
false
{"Kotlin": 39979}
import kotlin.math.abs fun main() { fun merge(list: List<Pair<Int, Int>>):List<Pair<Int, Int>>{ if (list.isEmpty()) return emptyList() var ans:MutableList<Pair<Int, Int>> = mutableListOf(list.first()) list.drop(1).forEach { val last = ans.last() if (it.first...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
3,270
advent-of-code-kotlin-2022
Apache License 2.0
lib/src/main/kotlin/com/bloidonia/advent/day08/Day08.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day08 import com.bloidonia.advent.readList data class Digit(val wires: Set<Char>) { private fun intersections(vararg other: Digit) = other.map { wires.intersect(it.wires).size }.toList() fun matches(expectedSegmentCount: Int, known: Array<Digit>, overlapWith1: Int, overlapWith4: I...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,969
advent-of-kotlin-2021
MIT License
src/Day11.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
fun main() { fun part1(input: List<String>): Long { val monkeys = parse11(input) repeat(20) { monkeys.forEach { it.takeTurn(monkeys) } } return monkeys.sortedByDescending { it.inspections }.take(2).productOfLong { it.inspections } } fun part2(input: List<String>)...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
2,613
advent-of-code-2022
Apache License 2.0
src/day18/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day18 import day06.main import readInput fun main() { data class Cube(val x: Int, val y: Int, val z: Int) { fun dimension(i: Int) = when (i % 3) { 0 -> x 1 -> y else -> z } fun adjacent() = setOf( copy(x = x - 1), copy(x ...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
2,284
AOC2022
Apache License 2.0
src/day02/Day02.kt
emartynov
572,129,354
false
{"Kotlin": 11347}
package day02 import readInput /* A,X - Rock B,Y - Paper C,Z - Scissors Rock -> Scissors Scissors -> Paper Paper -> Rock */ enum class Variants { Rock, Paper, Scissors } val mapping = mapOf( 'A' to Variants.Rock, 'X' to Variants.Rock, 'B' to Variants.Paper, 'Y' to Variants.Paper, ...
0
Kotlin
0
1
8f3598cf29948fbf55feda585f613591c1ea4b42
2,000
advent-of-code-2022
Apache License 2.0
src/main/Day19.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day19 import utils.readInput import java.lang.Integer.max enum class Material { Ore, Clay, Obsidian, Geode } typealias Cost = Map<Material, Int> data class Blueprint(val id: Int, val costs: Map<Material, Cost>) { private val maxNeeded: Cost = costs.values .flatMap(Co...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
4,729
aoc-2022
Apache License 2.0
src/year2023/day11/Day11.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day11 import check import readInput fun main() { val testInput1 = readInput("2023", "Day11_test") check(part1(testInput1), 374) check(part2(testInput1, expansionFactor = 10), 1030) check(part2(testInput1, expansionFactor = 100), 8410) val input = readInput("2023", "Day11") pr...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,852
AdventOfCode
Apache License 2.0
src/main/java/com/ncorti/aoc2021/Exercise08.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 object Exercise08 { fun part1(): Int = getInputAsTest("08") { split("\n") } .map { it.substring(it.indexOf(" | ") + 1) } .map(String::trim) .flatMap { it.split(" ") } .count { it.length in setOf(2, 3, 4, 7) } fun part2(): Int ...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
3,606
adventofcode-2021
MIT License
src/Day08.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
class Day08 : Day(8) { private fun parseInput(input: String) : Array<IntArray> { val lines = input.lines() val rows = lines.count() val col = lines[0].length val array: Array<IntArray> = Array(rows) { IntArray(col) } lines.forEachIndexed { index, line -> array[in...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
2,538
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
fun main() { fun part1(inputs: List<String>): Int { inputs.asSequence() val sections: List<Sections> = inputs.map { it.split(",") } .map { Sections(Section.from(it.first()), Section.from(it.last())) } return sections.count { it.fullyOverlap() } } fun part...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
1,771
aoc-2022-in-kotlin
Apache License 2.0
src/Day11.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
object Day11 { } fun main() { data class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val divisor: Int, val trueMonkeyIndex: Int, val falseMonkeyIndex: Int ) { fun testAndThrow(item: Long) = if (item % divisor == 0L) trueMonkeyIndex else ...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
2,887
aoc22-kt
Apache License 2.0
src/main/kotlin/Day11.kt
amitdev
574,336,754
false
{"Kotlin": 21489}
import java.io.File fun main() { val result = File("inputs/day_11_1.txt").useLines { totalBusiness(monkeys(it), 10000, 1) } println(result) } fun totalBusiness(startState: Map<Int, Monkey>, times: Int = 20, divideBy: Int = 3) = (1..times) .fold(startState) { acc, _ -> simulateThrows(acc, divideBy, startStat...
0
Kotlin
0
0
b2cb4ecac94fdbf8f71547465b2d6543710adbb9
2,725
advent_2022
MIT License
lib/src/main/kotlin/com/bloidonia/advent/day17/Day17.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day17 import com.bloidonia.advent.readText private fun integerSumCalc(n: Int) = n * (n + 1) / 2 fun yRanges(speed: Int): Sequence<Int> = integerSumCalc(speed).let { initialSpeed -> val initial = if (speed >= 0) { generateSequence(speed) { it - 1 }.takeWhile { it > 0 }.map { i...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
3,148
advent-of-kotlin-2021
MIT License
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day23Test.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).let { map -> repeat(10) { map.round() } va...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,699
adventofcode-kotlin
MIT License
y2015/src/main/kotlin/adventofcode/y2015/Day24.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2015 import adventofcode.io.AdventSolution object Day24 : AdventSolution(2015, 24, "It Hangs in the Balance") { override fun solvePartOne(input: String) = input.lines().map(String::toInt).let { solve(it, 3) } override fun solvePartTwo(input: String) = input.lines().map(String::toInt).le...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,758
advent-of-code
MIT License
src/main/kotlin/aoc2022/Day15.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import Point import readInput import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class SensorBeaconPair(val sensor: Point, val beacon: Point) { val hammingDistance = abs(sensor.x - beacon.x) + abs(sensor.y - beacon.y) companion object { fun fr...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,361
adventOfCode
Apache License 2.0
app/src/main/kotlin/day12/Day12.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day12 import common.InputRepo import common.readSessionCookie import common.solve import java.nio.file.Path fun main(args: Array<String>) { val day = 12 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay12Part1, ::solveDay12Part2) } fun solveDay12Part1(i...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
2,467
advent-of-code-kt
Apache License 2.0
src/Day02.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
enum class Result { LOSE, DRAW, WIN; companion object { fun of(char: String) = Result.values()[char.single() - 'X'] } } enum class Choice { PAPER, ROCK, SCISSORS; private val value get() = when (this) {ROCK -> 1; PAPER -> 2; SCISSORS -> 3 } fun against(other: Choice) = (4 + other.or...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
1,574
aoc22
Apache License 2.0
src/Day16.kt
inssein
573,116,957
false
{"Kotlin": 47333}
import kotlin.math.max data class Valve( val name: String, val flowRate: Int, val tunnels: List<String>, val index: Int ) data class Path(val time: Int, val valve: String, val bitmask: Int) fun main() { fun List<String>.toValves() = this.mapIndexed { i, it -> val name = it.substringAfter(...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
3,672
advent-of-code-2022
Apache License 2.0
src/Day13.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
import kotlin.math.sign typealias Signal = List<Any> fun main() { fun parse(input: Iterator<Char>): List<Any> { val list = mutableListOf<Any>() while(input.hasNext()) { var c = input.next() if(c=='[') { list.add(parse(input)) } else if(c.isDigit(...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
3,471
Kotlin-AoC-2022
Apache License 2.0
src/main/kotlin/Day5.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
private const val MIN_COUNT_CROSSING = 2 data class Point(val x: Int, val y: Int) class Segment(val start: Point, val end: Point) { private fun checkPoints(): Segment { if (start.x < end.x) return this if (start.x == end.x && start.y < end.y) return this return Segment(end, start) } ...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
1,955
AOC2021
Apache License 2.0
src/y2023/Day04.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { /* Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 */ fun part1(input: List<String>): Int { var sum = 0 input.forEach { card -> val cardData = card.split(":") cardData.filter { it.isNotBlank() && !it.startsWit...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
2,404
advent-of-code-kotlin
Apache License 2.0
src/year2023/day05/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day05 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.intersect import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 5, transform = ::parse) runAlgorithm( realInput = realInput, testInputs = testI...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
3,046
Advent-of-Code
Apache License 2.0
src/main/kotlin/day19.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day19 import aoc.utils.Timer import aoc.utils.findInts import aoc.utils.readInput fun main() { part2().let { println(it) } } fun part1(): Int { val bluePrints = bluePrints() return run(24, bluePrints) .map { it.first * it.second.geode } .sum() } fun part2(): I...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
8,426
adventOfCode2022
Apache License 2.0
src/Day12.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
private data class HeightMap( val elevations: Map<Point2D, Int>, val start: Point2D, val end: Point2D ) { fun getNeighbors(point: Point2D) = point.cardinalNeighbors.filter { n -> n in elevations } } fun main() { fun List<String>.parseInput(): HeightMap { var start: Point2D? = null ...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
2,445
advent-of-code-2022
Apache License 2.0
src/Day13.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
fun main() { val day = 13 fun parseItems(s: MutableList<Char>): List<Any> { val list = mutableListOf<Any>() var token: String? = null while (s.isNotEmpty()) { when (val ch = s.removeFirst()) { '[' -> list.add(parseItems(s)) ']' -> { ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
2,734
aoc22
Apache License 2.0
src/main/kotlin/day7/solver.kt
derekaspaulding
317,756,568
false
null
package day7 import java.io.File typealias RuleSet = Map<String, List<Pair<String, Int>>> val BAG_REGEX = Regex("(^|no|\\d).+?(?=\\sbags?)") fun parseRuleset(rules: List<String>): RuleSet { var ruleSet: RuleSet = mapOf() for (rule in rules) { val bagDescriptions = BAG_REGEX.findAll(rule).toList().m...
0
Kotlin
0
0
0e26fdbb3415fac413ea833bc7579c09561b49e5
1,827
advent-of-code-2020
MIT License
src/year2022/15/Day15.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`15` import kotlin.math.abs import readInput data class Point( val x: Int, val y: Int ) data class SensorToBeacon( val sensor: Point, val beacon: Point ) fun parseInput(input: List<String>): List<SensorToBeacon> { return input.map { val items = it.split("=", ",", ":").mapNotNull...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,795
KotlinAdventOfCode
Apache License 2.0
src/Day04.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
fun checkOverlap(pair: Pair<IntRange, IntRange>, completely: Boolean = true): Boolean { val elf1 = pair.first val elf2 = pair.second return if (completely) { val smallest = minOf(elf1.last - elf1.first + 1, elf2.last - elf2.first + 1) smallest == elf1.intersect(elf2).size } else { ...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
1,412
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/nilsdruyen/aoc/Day08.kt
nilsjr
571,758,796
false
{"Kotlin": 15971}
package de.nilsdruyen.aoc fun main() { fun part1(input: List<String>): Int { val forest = input.map { it.map { tree -> tree.digitToInt() } } val forestWidth = forest.first().size - 1 val forestHeight = forest.size - 1 val outerVisible = forest.first().size * 2 + (forest.size * 2) ...
0
Kotlin
0
0
1b71664d18076210e54b60bab1afda92e975d9ff
3,575
advent-of-code-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day14/Day14.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day14 import nl.sanderp.aoc.common.increaseBy import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource fun main() { val input = readResource("Day14.txt").lines() val template = parseTemplate(input.first()) ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,049
advent-of-code
MIT License
src/year2022/day11/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day11 import readInput fun main() { val day = "11" val expectedTest1 = 10605L val expectedTest2 = 2713310158L data class Monkey( var items: List<Long>, val operType: (Long) -> Long, val testDivisor: Long, val destinationDivisible: Long, val d...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
3,748
adventOfCode
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day12.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput("Day12") Day12.part1(input).println() Day12.part2(input).println() } object Day12 { private val memo = hashMapOf<Pair<String, List<Int>>, Long>() fun part1(input: List<String>): Long { return input.map { line -> val springs =...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
2,270
advent-of-code
MIT License
src/Day09.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
import kotlin.math.abs import kotlin.math.sign private class Solution09(input: List<String>, ropeLength: Int) { val moves = input.map { it.split(" ") }.flatMap { (move, count) -> (0 until count.toInt()).map { move } } var rope = (0 until ropeLength).map { Coordinate() }.toMutableList() val tailPositions =...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
1,960
aoc-2022
Apache License 2.0
y2017/src/main/kotlin/adventofcode/y2017/Day21.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.transpose private val startingConfiguration: Square = ".#./..#/###".split('/') object Day21 : AdventSolution(2017, 21, "Fractal Art") { override fun solvePartOne(input: String) = puzzle(input, 5) override fun solv...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,723
advent-of-code
MIT License
src/main/kotlin/Day7.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day7 { interface CardHand : Comparable<CardHand> { val maxSimilarCards: Int val bid: Long val secondMaxSimilarCards: Int val cards: CharArray val cardValues: Map<Char, Int> fun score(rank: Int): Long { ...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
3,507
kotlin-kringle
Apache License 2.0
src/year2015/day13/Day13.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day13 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2015", "Day13_test") check(part1(testInput), 330) val input = readInput("2015", "Day13") println(part1(input)) println(part2(input)...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,038
AdventOfCode
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day15/Day15.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day15 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines import java.util.* object Day15 : Day { override val input = Instructions.from(readInputLines(15)) override fun part1() = input.shortestPath() override fun ...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,885
aoc2021
MIT License
12/kotlin/src/main/kotlin/se/nyquist/Main.kt
erinyq712
437,223,266
false
{"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098}
package se.nyquist import java.io.File fun main() { val lines = File("input.txt").readLines() val values = lines.map { it.split("-") }.toList() val pairs = values.map { Pair(it[0], it[1] )}.union(values.map { Pair(it[1], it[0] )}) exercise1(pairs.distinct().toList()) exercise2(pairs.distinct().toLi...
0
Kotlin
0
0
b463e53f5cd503fe291df692618ef5a30673ac6f
3,523
adventofcode2021
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day05.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day05.solve() } object Day05 : AdventSolution(2023, 5, "If You Give A Seed A Fertilizer") { override fun solvePartOne(input: String): Long? { val (seeds, converters) = parse(input) return seeds.minOfOrNull { seed ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,324
advent-of-code
MIT License
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day07.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 sealed class File data class DataFile(val size: Long) : File() data class Directory(val path: String, val files: MutableList<File>) : File() { fun size(): Long = files.sumOf { when (it) { is DataFile -> it.size is Directory -> it.size()...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,494
advent-of-code
Apache License 2.0
src/day08/Day08_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day08 import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private val input: List<String> = readLine...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,643
aoc2022
Apache License 2.0
src/year2023/day08/Day08.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day08 import check import lcm import readInput fun main() { val testInput1 = readInput("2023", "Day08_test_part1") val testInput2 = readInput("2023", "Day08_test_part2") check(part1(testInput1), 6) check(part2(testInput2), 6) val input = readInput("2023", "Day08") println(par...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,953
AdventOfCode
Apache License 2.0
src/Day15.kt
MatthiasDruwe
571,730,990
false
{"Kotlin": 47864}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>, y: Long): Int { val sensors = input.map { val values = it.split(" ") val sensorX = values[2].split("=")[1].removeSuffix(",").toLong() val sensorY = values[3...
0
Kotlin
0
0
f35f01cea5075cfe7b4a1ead9b6480ffa57b4989
3,302
Advent-of-code-2022
Apache License 2.0
src/Day08.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { fun countInDir(input: List<String>, dir: Direction): MutableList<Pair<Int, Int>> { val visibleTrees = mutableListOf<Pair<Int, Int>>() var currentSize = -1 val range = when (dir) { Direction.NORTH, Direction.WEST -> input.indices.reversed() Direction.SOUT...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
2,654
advent_of_code_2022
Apache License 2.0
src/Day07.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
private typealias Command = Pair<String, List<String>> sealed class FsEntry( val name: String ) { abstract val size: Int } private class Directory( name: String, var children: List<FsEntry> = emptyList() ) : FsEntry(name) { override val size: Int get() = children.sumOf { it.size } } priva...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
3,667
advent-of-code-2022
Apache License 2.0
src/year_2022/day_01/Day01.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_01 import readInput data class Elf(val foodCalories: List<Int>) { val totalCalories: Int get() = foodCalories.sum() } object Day01 { /** * Calculate the position and elf with the most calories * * @return Elf position to Total Calories */ fun solutionOne(elvesTex...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
1,954
advent_of_code
Apache License 2.0