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/main/kotlin/Day07.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { data class File( val name: String, val size: Int ) data class Dir( val name: String, val parent: Dir? = null, val dirs: MutableList<Dir> = mutableListOf(), val files: MutableList<File> = mutableListOf() ) { val size: Int g...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
1,915
aoc-2022
Apache License 2.0
src/Day18.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { data class Cube(val x: Int, val y: Int, val z: Int) val sides = listOf( Cube(0, 0, 1), Cube(0, 0, -1), Cube(0, 1, 0), Cube(0, -1, 0), Cube(1, 0, 0), Cube(-1, 0, 0), ) fun parse(input: List<String>): Pair<List<Cube>, List<List<BooleanArray>>>...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
3,410
AdventOfCode2022
Apache License 2.0
src/day03/Day03.kt
wasabi-muffin
726,936,666
false
{"Kotlin": 10804}
package day03 import base.Day fun main() = Day03.run() object Day03 : Day<Int>("03") { override val test1Expected: Int = 4361 override val test2Expected: Int = 4678351 // override val part1Expected: Int = 532331 // override val part2Expected: Int = 823011201 override fun part1(input: List<String>)...
0
Kotlin
0
0
544cdd359e4456a74b1584cbf1e5dddca97f1394
3,962
advent-of-code-2023
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day20.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle import kotlin.math.sqrt class Day20(input: Input) : Puzzle() { data class TileArrangement(val tileId: Long, val image: List<List<Char>>) private val tiles by lazy { input.string...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
6,447
adventofcode-kotlin
MIT License
aoc16/day_22/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import pathutils.Pos import pathutils.fourNeighs import pathutils.shortest import java.io.File data class Node(val size: Int, val used: Int, var target: Boolean) fun parsePos(line: String): Pos = with(line.split(" ")[0].split("-")) { Pos(this[1].drop(1).toInt(), this[2].drop(1).toInt()) } fun parseNode(line: Str...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,741
advent-of-code
MIT License
src/Day04.kt
patrickwilmes
572,922,721
false
{"Kotlin": 6337}
private fun List<String>.buildRanges(): Pair<Set<Int>, Set<Int>> { val ranges = this.map { it.split("-").map { it.toInt() } } val firstRange = (ranges[0][0]..ranges[0][1]).toSet() val secondRange = (ranges[1][0]..ranges[1][1]).toSet() return firstRange to secondRange } // 513, 878 private fun List<Stri...
0
Kotlin
0
0
162c8f1b814805285e10ea4e3ab944c21e8be4c5
1,117
advent-of-code-2022
Apache License 2.0
src/Day04.kt
TheOnlyTails
573,028,916
false
{"Kotlin": 9156}
operator fun IntRange.contains(other: IntRange) = other.first in this && other.last in this infix fun IntRange.overlaps(other: IntRange) = other.first in this || other.last in this fun main() { fun part1(input: List<String>): Int { return input .map { val (range1, r...
0
Kotlin
0
0
685ce47586b6d5cea30dc92f4a8e55e688005d7c
1,547
advent-of-code-2022
Apache License 2.0
src/day02/Day02.kt
pnavais
727,416,570
false
{"Kotlin": 17859}
package day02 import readInput const val MAX_RED = 12L const val MAX_GREEN = 13L const val MAX_BLUE = 14L enum class Color(val maxNum: Long) { RED(MAX_RED), GREEN(MAX_GREEN), BLUE(MAX_BLUE) } data class BallInfo(val number: Long, val color: Color) { fun isValid() = number <= color.maxNum } fun getId(inp...
0
Kotlin
0
0
f5b1f7ac50d5c0c896d00af83e94a423e984a6b1
1,699
advent-of-code-2k3
Apache License 2.0
src/Day12.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
private typealias HeightsMap = Map<Position, Char> private data class Input2( val heightsMap: HeightsMap, val start: Position, val finish: Position, ) private fun parseState(input: List<String>): Input2 { lateinit var position: Position lateinit var target: Position val heights = buildMap { ...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
2,748
aoc-2022
Apache License 2.0
src/adventofcode/day03/Day03.kt
bstoney
574,187,310
false
{"Kotlin": 27851}
package adventofcode.day03 import adventofcode.AdventOfCodeSolution fun main() { Solution.solve() } object Solution : AdventOfCodeSolution<Int>() { override fun solve() { solve(3, 157, 70) } override fun part1(input: List<String>): Int { return getIncorrectItems(input) .m...
0
Kotlin
0
0
81ac98b533f5057fdf59f08940add73c8d5df190
1,893
fantastic-chainsaw
Apache License 2.0
src/Day11.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
package day11 import readInput class Monkey( val items: MutableList<Long>, val op: (Long) -> Long, val divisor: Long, val targets: Pair<Int, Int>, ) { var inspections = 0L fun performRound(calm: (Long) -> Long) { while (true) { val item = items.removeFirstOrNull() ?: retur...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
2,767
advent-of-code-2022
Apache License 2.0
src/day12/day12.kt
bienenjakob
573,125,960
false
{"Kotlin": 53763}
package day12 import inputTextOfDay import testTextOfDay const val day = 12 val testInput = testTextOfDay(day) val input = inputTextOfDay(day) typealias Maze = List<MutableList<Int>> typealias Cell = Pair<Int, Int> fun main() { val maze = createMazeOfInts(input)//.also { printMaze(it) } val start = findSing...
0
Kotlin
0
0
6ff34edab6f7b4b0630fb2760120725bed725daa
4,401
aoc-2022-in-kotlin
Apache License 2.0
src/Day05.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
fun main() { fun loadInitialPositions(input: List<String>): List<String> { val asRead = input .takeWhile { it.isNotBlank() } .filter { it.contains("[") } .map { it.chunked(4) .map { it[1] } } val longest = asRead.ma...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
1,869
aoc-kotlin-2022
Apache License 2.0
src/Day07.kt
iownthegame
573,926,504
false
{"Kotlin": 68002}
class Directory(val dirName: String) { private var files = arrayOf<File>() private var directories = arrayOf<Directory>() var dirSize: Int = 0 fun calculateSize() { println("calculate dir size $dirName") directories.forEach { it.calculateSize() } dirSize = files.sumOf { it.fileS...
0
Kotlin
0
0
4e3d0d698669b598c639ca504d43cf8a62e30b5c
3,737
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jackchapman/adventofcode/Day07.kt
crepppy
317,691,375
false
null
package com.jackchapman.adventofcode fun solveDay7(): Pair<Int, Int> { val rules = getInput(7) val colorMap = parseBagRules(rules) val numberOfBagsThatHold = colorMap.keys.count { canContainBag("shiny gold", it, colorMap) } return numberOfBagsThatHold to numberOfContainedBags("shiny gold"...
0
Kotlin
0
0
b49bb8f62b4542791626950846ca07d1eff4f2d1
1,490
aoc2020
The Unlicense
src/Day03.kt
nielsz
573,185,386
false
{"Kotlin": 12807}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> line.compartments().getNonUniqueValues().getPriority() } } fun part2(input: List<String>): Int { return input .windowed(size = 3, step = 3) .sumOf { group -> ...
0
Kotlin
0
0
05aa7540a950191a8ee32482d1848674a82a0c71
1,482
advent-of-code-2022
Apache License 2.0
src/Day08.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import java.lang.Integer.max fun main() { fun List<Int>.indicesOfVisible(): List<Int> { return indices.filter { cur -> indices.all { it <= cur || get(it) < get(cur) } || indices.all { it >= cur || get(it) < get(cur) } } } ...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
2,299
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/days/day16/Day16.kt
Stenz123
694,797,878
false
{"Kotlin": 27460}
package days.day16 import days.Day import java.util.LinkedList class Day17 : Day() { override fun partOne(): Any { val input = readInput() val rules = parseRules() val tickets = parseTickets() val ranges = rules.map { it.range }.flatten() val invalidValues = tickets.map ...
0
Kotlin
0
0
3e5ee86cd723c293ec44b1be314697ccf5cdaab7
4,172
advent-of-code-2020
The Unlicense
src/Day09.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
import kotlin.math.abs fun moveKnot(knot: Pair<Int, Int>, knotToFollow: Pair<Int, Int>): Pair<Int, Int> { val xDiff = knotToFollow.first - knot.first val yDiff = knotToFollow.second - knot.second var (xNew, yNew) = knot if (abs(xDiff) + abs(yDiff) >= 3) { xNew = if (xDiff > 0) knot.first + 1 el...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
2,712
advent-of-code-2022
Apache License 2.0
src/Day23.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
fun <T> ArrayDeque<T>.rotate(times: Int = 1) = repeat(times) { addLast(removeFirst()) } fun <T> Iterable<T>.duplicates() = groupingBy(::identity).eachCount().filterValues { it > 1 }.keys fun <T : Comparable<T>> Iterable<T>.minmax(): Pair<T, T> { val iter = iterator() val first = iter.next() return iter.as...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
3,096
advent-of-code-2022
Apache License 2.0
src/Day04.kt
GreyWolf2020
573,580,087
false
{"Kotlin": 32400}
fun main() { fun part1(input: List<String>): Int = input .contains(::fullyContains) fun part2(input: List<String>): Int = input .contains(::partiallyContains) // test if implementation meets criteria from the description, like: // val testInput = readInput("Day04_test") // check(part...
0
Kotlin
0
0
498da8861d88f588bfef0831c26c458467564c59
1,424
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2022/Day16.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2022 import me.grison.aoc.* import kotlin.math.max import kotlin.math.min class Day16 : Day(16, 2022) { override fun title() = "Proboscidea Volcanium" override fun partOne(): Int { val valves = parseValves() val distances = findAllDistances(valves) return solve(...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
3,841
advent-of-code
Creative Commons Zero v1.0 Universal
src/Day13.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
private sealed interface Element { data class Integer(val value: Int) : Element data class List(val value: ArrayList<Element>) : Element companion object { fun newList(): Element { return List(ArrayList()) } } } private fun ArrayList<Element>.addAtDepth(element: Element, de...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
3,447
advent-of-code-2022
Apache License 2.0
src/Day14.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
fun main() { val day = 14 data class Coord(val x: Int, val y: Int) { fun to(end: Coord): List<Coord> { val minX = minOf(x, end.x) val minY = minOf(y, end.y) val maxX = maxOf(x, end.x) val maxY = maxOf(y, end.y) return (minX..maxX).flatMap { n...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
2,847
aoc22
Apache License 2.0
src/Day18.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import kotlin.collections.ArrayDeque fun main() { fun parseInput(input: List<String>) = input.map { val (x, y, z) = it.split(",").map { n -> n.toInt() } Triple(x, y, z) }.toList() val directions = listOf( Triple(1, 0, 0), Triple(-1, 0, 0), Triple(0, 1, 0), Tr...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
2,540
aoc-2022
Apache License 2.0
src/main/kotlin/Day7.kt
ueneid
575,213,613
false
null
class Day7(inputs: List<String>) { private val root = parse(inputs).apply { calcSize() } enum class FileType(val type: String) { FILE("file"), DIR("DIR"), DUMMY("DUMMY") } private class FileTree(val type: FileType, val name: String, var size: Int, val children: MutableList<FileTree>) { ...
0
Kotlin
0
0
743c0a7adadf2d4cae13a0e873a7df16ddd1577c
3,386
adventcode2022
MIT License
src/day3/Day03.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day3 import readInput fun main() { fun part1(input: List<String>): Int { return input.map { it.toRucksack() }.sumOf { it.findDuplicate().priority() } } fun part2(input: List<String>): Int { return input.chunked(3).sumOf { it.toElfGroup().findBadge().priority() } } // test...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
1,908
AdventOfCode2022
Apache License 2.0
src/Day17.kt
sabercon
648,989,596
false
null
fun main() { abstract class Point(val dimension: Int) { abstract fun neighbors(): List<Point> protected fun deltas(): List<List<Int>> { val seq = generateSequence(listOf(emptyList<Int>())) { deltas -> deltas.flatMap { delta -> (-1..1).map { delta + it } } } ...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
1,939
advent-of-code-2020
MIT License
src/Day08.kt
raneric
573,109,642
false
{"Kotlin": 13043}
fun main() { fun part1(input: List<String>): Int { val listOfInt = input.convertToIntArray() return countVisibleTree(listOfInt) } fun part2(input: List<String>): Int { val listOfInt = input.convertToIntArray() return getHigherScore(listOfInt) } val input = readInput...
0
Kotlin
0
0
9558d561b67b5df77c725bba7e0b33652c802d41
3,423
aoc-kotlin-challenge
Apache License 2.0
src/Day18.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
import kotlin.math.max import kotlin.math.min data class Point3D(val x: Int, val y: Int, val z: Int) { operator fun plus(other: Point3D) = Point3D(x + other.x, y + other.y, z + other.z) fun within(minPos: Point3D, maxPos: Point3D) = (x in minPos.x..maxPos.x) && (y in minPos.y..maxPos.y) && (z in minPo...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
4,013
advent-of-code-2022
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day10.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import kotlin.math.absoluteValue fun main() = Day10.solve() object Day10 : AdventSolution(2019, 10, "Monitoring Station") { override fun solvePartOne(input: String) = losPerAsteroid(parseToAsteroids(input.lines...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,880
advent-of-code
MIT License
src/Day12.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.util.* fun main() { val input = readInput("Day12") val inputTest = readInput("Day12_test") fun part1(input: List<String>): Int { val mapRaw = input.map { it.toList() } val start = mapRaw.findIndex2D('S').first() val end = mapRaw.findIndex2D('E').first() val m...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
3,067
advent-of-code-kotlin-2022
Apache License 2.0
src/Day15.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
import kotlin.math.absoluteValue import kotlin.time.ExperimentalTime import kotlin.time.measureTime private data class Coord( val x: Long, val y: Long, ) { fun tuningFrequency() = (x * 4000000) + y } private data class Sensor( val x: Long, val y: Long, val maxDistance: Long, ) { operator f...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
2,771
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day21/Day21.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day21 // Syntax sugar private fun <N> Pair<N, N>.swap() = second to first private fun Pair<Long, Long>.max() = if (first > second) first else second private fun Pair<Long, Long>.addFirst(number: Long) = (first + number) to (second) private fun Pair<Long, Long>.timesEach(number: Long) = (first * number) to (sec...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
2,971
advent-of-code-2021
MIT License
src/Day03.kt
copperwall
572,339,673
false
{"Kotlin": 7027}
val priorities = buildPriorities() fun main() { two() } // Each line is a knapsack // Each knapsack is a list of characters, // split evenly across two compartments // Find the only thing shared between the two compartments fun one() { val knapsacks = readInput("Day03") val priorities = knapsacks.map { ge...
0
Kotlin
0
1
f7b856952920ebd651bf78b0e15e9460524c39bb
1,591
advent-of-code-2022
Apache License 2.0
2021/src/day04/Day04.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day04 import readInput fun Array<IntArray>.markNumber(nb: Int) { for (i in 0 until size) { for (j in 0 until this[i].size) { if (this[i][j] == nb) { this[i][j] = -1 } } } } fun Array<IntArray>.isWinning() : Boolean { for (i in 0 until size) ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,216
advent-of-code
Apache License 2.0
src/Day02.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Int = input.parse(calculateOwnPlay = { _, own -> own.asPlay() }) .sumOf { (opponent, your) -> your.vs(opponent).bonus + your.bonus } fun part2(input: List<String>): Int = input.parse(calculateOwnPlay = { opponent, own -> own.matchPlay(op...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
1,812
aoc-2022
Apache License 2.0
src/Day12.kt
stevennoto
573,247,572
false
{"Kotlin": 18058}
fun main() { // Each square/node has a label (S, E, or a level), level, id (for uniqueness), and links to reachable nodes data class Node(val label:Char, val id:Int) { val level = when (label) { 'S' -> 1; 'E' -> 26; else -> label - 'a' + 1 } val sources = mutableSetOf<Node>() // nodes that can r...
0
Kotlin
0
0
42941fc84d50b75f9e3952bb40d17d4145a3036b
3,232
adventofcode2022
Apache License 2.0
src/Day15.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
import kotlin.math.abs import kotlin.math.max private val lineFormat = """Sensor at x=([\d\-]+), y=([\d\-]+): closest beacon is at x=([\d\-]+), y=([\d\-]+)""".toRegex() private fun distance(point1: Pair<Int, Int>, point2: Pair<Int, Int>): Int { return abs(point1.first - point2.first) + abs(point1.second - poi...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
3,939
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day7/Seven.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day7 import com.tonnoz.adventofcode23.utils.readInput object Seven { @JvmStatic fun main(args: Array<String>) { val input = "inputSeven.txt".readInput() problemOne(input) problemTwo(input) } private fun problemOne(input: List<String>){ val time = System.cur...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,271
adventofcode23
MIT License
src/Day16.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
import kotlin.random.Random fun main() { val verbose = false val nodes = mutableMapOf<String, Day16Node>() var usableNodes = mutableListOf<Day16Node>() val map = mutableMapOf<Day16Node, List<Day16Node>>() val distances = mutableMapOf<Set<Day16Node>, Int>() val shortestPath = mutableMapOf<Day16...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
7,027
advent-of-code-2022-kotlin
Apache License 2.0
src/Day09.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
import kotlin.math.abs data class Loc(val x: Int, val y: Int) { fun adjust(tail: Loc): Loc { val diffX = x - tail.x val diffY = y - tail.y if ((abs(diffX) == 1 && diffY == 0) || (diffX == 0 && abs(diffY) == 1) || (diffX == 0 && diffY == 0) || (abs(diffX)...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
3,059
AdventOfCode-2022
Apache License 2.0
day18/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File fun main() { val input = readInputFile() println("Part I: the solution is ${solvePartI(input, 10)}.") /* Determined by inspection that after 1000 iterations (probably sooner), the process repeats itself with a period of 28 iterations. (1000000000 - 1000) % 28 = 0, so the soluti...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
2,751
AdventOfCode2018
MIT License
src/Day24.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day24.printSolutionIfTest(18, 54) } object Day24 : Day<Int, Int>(24) { override fun part1(lines: List<String>): Int { val map = parseMap(lines) return solve(map, map.entryPoint(), map.exitPoint()) } override fun part2(lines: List<String>): Int { val map = parseMap(...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
3,312
advent-of-code-2022
Apache License 2.0
src/Day02.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
private enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3) } private enum class Outcome(val score: Int) { WIN(6), DRAW(3), LOSE(0) } private val Char.shape: Shape get() = when (this) { 'A', 'X' -> Shape.ROCK 'B', 'Y' -> Shape.PAPER 'C', 'Z' -> Shape.SCISSORS ...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
1,737
advent-of-kotlin-2022
Apache License 2.0
src/day01/Day01.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day01 import readInput fun main() { fun topCaloriesElf(input: List<String>): ElfWithCalories { return getElfsWithSumCalories(input) .maxBy { (_, sumCalories) -> sumCalories } } fun topThreeCalories(input: List<String>): Int { return getElfsWithSumCalories(input) ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
1,764
advent-of-code-22-kotlin
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day20.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 fun main() = Day20.solve() object Day20 : AdventSolution(2020, 20, "Jurassic Jigsaw") { override fun solvePartOne(input: String) = unmatchedEdgeCounts(parseInput(input)) .filter { it.value == 2 } ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
5,368
advent-of-code
MIT License
2015/Day13/src/main/kotlin/Main.kt
mcrispim
658,165,735
false
null
import java.io.File import java.util.* fun generateSequence(A: List<String>): Sequence<List<String>> { return sequence { val n = A.size val c = IntArray(n) val list = A.toMutableList() yield(list.toList()) var i = 0; while (i < n) { if (c[i] < i) { ...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
3,414
AdventOfCode
MIT License
src/day8/Day08.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day8 import readInput fun main() { val testInput = readInput("day8/Day08_test") val testField = parseInput(testInput) check(part1(testField) == 21) check(part2(testField) == 8) val input = readInput("day8/Day08") val field = parseInput(input) println(part1(field)) println(part...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,361
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/pg/advent/day6/Main.kt
pgdejardin
159,992,959
false
null
package io.pg.advent.day6 import arrow.core.Some import arrow.instances.list.foldable.exists import arrow.syntax.collections.firstOption import io.pg.advent.utils.FileUtil import kotlin.math.absoluteValue fun main() { val lines = FileUtil.loadFile("/day6.txt") val sizePartOne = day6Part1(lines) println("What is...
0
Kotlin
0
0
259cb440369e9e0a5ce8fc522e672753014efdf2
3,437
advent-of-code-2018
MIT License
src/y2022/Day23.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.Cardinal import util.Cardinal.EAST import util.Cardinal.NORTH import util.Cardinal.SOUTH import util.Cardinal.WEST import util.Cardinal.entries import util.Pos import util.minMax import util.neighbors import util.readInput import java.util.Collections object Day23 { private fun parse(inp...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,195
advent-of-code
Apache License 2.0
src/Day02.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private enum class Hand(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); val loser get() = when (this) { ROCK -> SCISSORS PAPER -> ROCK SCISSORS -> PAPER } val winner get() = when (this) { ROCK -> PAPER PAPER -> SCISSORS ...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
1,880
advent-of-code-22
Apache License 2.0
src/Day11.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
class Monkey( val items: ArrayDeque<Long>, val monkeyOperation: (new: Long) -> Long, val modVal:Long, val trueMonkey:Int, val falseMonkey:Int, val worryLevel: Long = 3 ) { var counter = 0L fun throwThings(monkeys: List<Monkey>) { val mod = monkeys.map{it.modVal}.reduce(Long::tim...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
3,540
aoc-2022-demo
Apache License 2.0
src/day24/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day24 import Coord import closeNeighbours import day06.main import readInput import java.util.* import kotlin.math.abs fun main() { data class Step(val coord: Coord, val time: Int) { fun distanceTo(point: Pair<Int, Int>) = abs(point.first - coord.first) + abs(point.second - coord.second) f...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
4,210
AOC2022
Apache License 2.0
src/Day08.kt
psy667
571,468,780
false
{"Kotlin": 23245}
fun main() { val id = "08" fun parse(input: List<String>): List<List<Int>> { return input.map { it.split("").drop(1).dropLast(1).map(String::toInt) } } fun part1(input: List<String>): Int { val treesMatrix = parse(input) val size = treesMatrix.size ...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
2,665
advent-of-code-2022
Apache License 2.0
src/day05/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day05 import println import readInput fun main() { class MappingLine(val destinationRangeStart: Long, val sourceRangeStart: Long, val rangeLength: Long) { fun isApplicable(input: Long): Boolean { return sourceRangeStart <= input && sourceRangeStart + rangeLength > i...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
3,315
advent-of-code-2023
Apache License 2.0
src/year_2023/day_02/Day02.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_02 import readInput data class Game( val round: Int, var isPossible: Boolean, var power: Int = 0 ) data class GameCube( val name: String, val maxCount: Int, var minPossible: Int = 0 ) { fun reset() { minPossible = 0 } } object Day02 { /** * */ fun soluti...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,103
advent_of_code
Apache License 2.0
src/y2023/Day08.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { fun Pair<String, String>.pickDirection(dir: Char): String { return if ('L' == dir) this.first else this.second } fun part1(input: List<String>): Int { val pattern = input.first() val ruleSeq = generateSequence(0) { (it + 1) % pat...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
2,426
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
virtualprodigy
572,945,370
false
{"Kotlin": 8043}
fun main() { data class Range(val start: Int, val end: Int) fun part1(input: List<String>): Int { var total = 0 for(pair in input){ val ranges = pair.split(",").map { str -> val split = str.split("-") Range(split[0].toInt(),split[1].toInt()) ...
0
Kotlin
0
0
025f3ae611f71a00e9134f0e2ba4b602432eea93
1,700
advent-code-code-kotlin-jetbrains-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1489/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1489 /** * LeetCode page: [1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/); */ class Solution { /* Complexity: * Time O(E^2 * Log n) and Space O(E) w...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
4,652
hj-leetcode-kotlin
Apache License 2.0
src/day14/Day14.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day14 import geometry.* import readLines val SOURCE: Point = 500L to 0L val FALL_ORDER: List<Vector> = listOf(0L to +1L, -1L to +1L, +1L to +1L) data class Simulation(val source: Point = SOURCE, val sand: MutableSet<Point> = mutableSetOf(), val rock: Set<Point>) val Simulation.points get() = sand + rock fu...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
2,191
advent-of-code-22
Apache License 2.0
src/Day16.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
import kotlin.math.* fun main() { var nodes: Int = 16 var dp = Array(1 shl nodes) { Array(nodes) { IntArray(31) { -1 } } } var dist = Array(60) { IntArray(60) { 10000000 } } var flow = IntArray(60) { 0 } var g = Array(60) { mutableListOf<Int>() } var id = mutableMapOf<String, Int>() fun f(...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
2,734
advent-of-code-2022-kotlin
Apache License 2.0
codeforces/round616/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round616 fun solve(k: Int, toSwitch: List<Int>, where: List<List<Int>>): List<Int> { val p = MutableList(k) { it } val odd = MutableList(k) { 0 } val d = List(k) { mutableListOf(0, 1) } fun get(x: Int): Int { if (p[x] == x) return x val par = p[x] p[x] = get(par) odd[x] = odd[x] xor odd[...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,461
competitions
The Unlicense
src/day05/Day05.kt
spyroid
433,555,350
false
null
package day05 import readInput import java.awt.Point import kotlin.math.sign fun main() { fun move(p1: Point, p2: Point): Sequence<Point> = sequence { val dx = (p2.x - p1.x).sign val dy = (p2.y - p1.y).sign var x = p1.x var y = p1.y while (x != p2.x + dx || y != p2.y + dy)...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
1,553
Advent-of-Code-2021
Apache License 2.0
src/Day02.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
import java.lang.IllegalArgumentException enum class Shape(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3), } fun getOpponentsShape(strShape: String): Shape { return when (strShape) { "A" -> Shape.ROCK "B" -> Shape.PAPER "C" -> Shape.SCISSORS else -> throw IllegalArgu...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
2,311
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2016/Day24.kt
tginsberg
74,924,040
false
null
/* * Copyright (c) 2016 by <NAME> */ package com.ginsberg.advent2016 import com.ginsberg.advent2016.utils.asDigit import java.util.ArrayDeque /** * Advent of Code - Day 24: December 24, 2016 * * From http://adventofcode.com/2016/day/24 * */ class Day24(val input: List<String>) { val board: List<List<Spo...
0
Kotlin
0
3
a486b60e1c0f76242b95dd37b51dfa1d50e6b321
2,917
advent-2016-kotlin
MIT License
src/main/kotlin/g1801_1900/s1878_get_biggest_three_rhombus_sums_in_a_grid/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1878_get_biggest_three_rhombus_sums_in_a_grid // #Medium #Array #Math #Sorting #Matrix #Heap_Priority_Queue #Prefix_Sum // #2023_06_22_Time_326_ms_(100.00%)_Space_43.8_MB_(100.00%) import java.util.PriorityQueue class Solution { fun getBiggestThree(grid: Array<IntArray>): IntArray { v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,420
LeetCode-in-Kotlin
MIT License
2023/src/main/kotlin/Day23.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day23 { fun part1(input: String): Int { val maze = parse(input) val start = Pos(maze.first().indexOf('.'), 0) val end = Pos(maze.last().indexOf('.'), maze.size - 1) val queue = java.util.ArrayDeque<Hike>() queue.add(Hike(start.move(Direction.SOUTH), setOf(start))) var longest = 0 ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
4,841
advent-of-code
MIT License
src/main/kotlin/leetcode/kotlin/dp/152. Maximum Product Subarray.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.dp /** 1. Optimal structure f(n) = Max( // max product till index n g`(n-1)*arr[n], // min product ending at index n-1 * arr[n] arr[n], // element at index n, single element product f`(n-1)*arr[n], // max product ending at index n-1 * ...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
2,779
kotlinmaster
Apache License 2.0
src/Day03.kt
meierjan
572,860,548
false
{"Kotlin": 20066}
import java.lang.IllegalArgumentException data class RucksackContent( val first: String, val second: String ) { companion object { fun parse(text: String): RucksackContent { val middle = text.length / 2 return RucksackContent( first = text.substring(0, middle), ...
0
Kotlin
0
0
a7e52209da6427bce8770cc7f458e8ee9548cc14
1,959
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/aoc2015/Day15.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2015 import days.Day class Day15: Day(2015, 15) { override fun partOne(): Any { val ingredients = inputList.map(::parseIngredients) val recipes = permuteRecipes(100, ingredients, null) return recipes.map { recipe -> recipe.contents.flatMap { (amount, ingredien...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,077
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/y2023/day13/Day13.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day13 import util.InputReader typealias PuzzleInput = String class Day13(val input: PuzzleInput) { val maps = input.toPuzzleMaps() fun partOne(): Int { return maps.sumOf { it.score() } } fun partTwo(): Int { for (map in maps) { val y = map.yReflection...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
3,663
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-11.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import com.github.ferinagy.adventOfCode.readInputText fun main() { val input = readInputText(2022, "11-input") val testInput1 = readInputText(2022, "11-test1"...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,604
advent-of-code
MIT License
src/main/kotlin/io/github/aarjavp/aoc/day09/Day09.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day09 import io.github.aarjavp.aoc.readFromClasspath class Day09 { class Grid(val lines: List<String>) { data class Location(val row: Int, val column: Int) operator fun get(row: Int, column: Int): Char? = lines.getOrNull(row)?.getOrNull(column) operator fun ...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
3,449
advent-of-code-2021
MIT License
src/day11/Day11.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day11 import day05.splitAtEmpty import readInput fun main() { fun part1(input: List<String>): Long { val monkeys = input.parseMonkeys() for (round in 0 until 20) { monkeys.mapValues { it.value.inspect() } } return monkeys.map { it.value.inspectCount } ...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
3,518
advent-of-code-22
Apache License 2.0
src/commonMain/kotlin/advent2020/day11/Day11Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day11 import advent2020.utils.atLeast import kotlin.time.TimeSource.Monotonic val directions by lazy { (-1..1).flatMap { dr -> (-1..1).map { dc -> (dr to dc) as Pos } } - (0 to 0) } typealias Vector = Pair<Int, Int> typealias Pos = Pair<Int, Int> operator fun Pos.plus(v: Vector): Pos = first + v.f...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
2,828
advent-of-code-2020
MIT License
src/Day03.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
/** * Each rucksack has 2 compartments with same number of items. Each line represents all items in a rucksack. * Elf that did the packing failed to follow this rule for exactly one item type per rucksack. * Every item type is identified by a single lowercase or uppercase letter. * Lowercase item types a through z...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
1,492
advent-of-code-2022
Apache License 2.0
src/Day07.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution07(input: List<String>) { private val root = Node("/") init { var currentNode = root input.forEach {line -> when (line.substring(0, 4).trim()) { "$ cd" -> currentNode = when (val dirname = line.substring(4).trim()) { "/" -> ...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
2,171
aoc-2022
Apache License 2.0
kotlin/src/2022/Day12_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import java.util.ArrayDeque private fun height(chr: Char) = when (chr) { 'S' -> 0 'E' -> 25 else -> chr - 'a' } private fun neighbors(y: Int, x: Int, yMax: Int, xMax: Int): List<Pair<Int, Int>> = listOf(y to x - 1, y to x + 1, y - 1 to x, y + 1 to x) .filter {it.first >= 0 && it.second >= 0 &&...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
1,659
adventofcode
Apache License 2.0
src/Day02.kt
treegem
572,875,670
false
{"Kotlin": 38876}
import Move.* import Outcome.* import common.readInput val possibleMovesNumber = Move.values().size fun main() { val day = "02" fun part1(input: List<String>) = input.sumOf { calculateScorePart1(it) } fun part2(input: List<String>) = input.sumOf { calculateScorePart2(it) } // test if implementation...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
2,222
advent_of_code_2022
Apache License 2.0
src/day9/Day9.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day9 import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.sign fun main() { val input = File("src/day9/input.txt").readLines() .map { line -> line.split(" ") } .map { parts -> Pair(parts[0], parts[1].toInt()) } .toList() pr...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
2,217
advent-of-code-2022
MIT License
src/2022/Day05.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput import splitBy fun main() { fun readStackChart(stackChart: List<String>): List<MutableList<Char>> { val cargoStacks = stackChart.last().trim().split("\\s+".toRegex()).map { _ -> mutableListOf<Char>() } for (i in 0..(stackChart.size - 2)) { cargoStacks...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,308
aoc-2022-in-kotlin
Apache License 2.0
src/Day22.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import java.lang.Exception import kotlin.math.abs data class Position(val x: Int, val y: Int, val type: Boolean) { val neighbors = mutableListOf<Position?>(null, null, null, null) fun neighborByDirection(direction: Int): Position = neighbors[(direction % 4 + 4) % 4]!! } fun main() { fun part1(inputFirst: ...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
8,585
Advent-of-code
Apache License 2.0
src/Day14/Day14.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
fun main() { fun preprocess(input: List<String>): Pair<String, Map<String, String>> { val rules = input.slice(2 until input.size).associate { val split = it.split(" -> ") split[0] to split[1] } return Pair(input[0], rules) } fun init( input: String, ...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
2,889
advent-of-code-2021
Apache License 2.0
src/main/kotlin/aoc2023/Day04.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import aoc2022.parsedBy import utils.InputUtils class Card(val id: Int, val winners: Set<Int>, val contents: Set<Int>) { fun matches() = winners.intersect(contents) fun score(): Int { val power = matches().size return if (power > 0) { 1 shl (power -1) } else 0 } } fun Strin...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,878
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
faragogergo
573,451,927
false
{"Kotlin": 4406}
fun main() { fun part1(input: List<String>): Int { val scores = mapOf( Pair("A", "X") to 1 + 3, Pair("A", "Y") to 2 + 6, Pair("A", "Z") to 3 + 0, Pair("B", "X") to 1 + 0, Pair("B", "Y") to 2 + 3, Pair("B", "Z") to 3 + 6, Pai...
0
Kotlin
0
0
47dce5333f3c3e74d02ac3aaf51501069ff615bc
1,434
Advent_of_Code_2022
Apache License 2.0
src/Day02.kt
jamesrobert
573,249,440
false
{"Kotlin": 13069}
enum class Outcome(val value: String) { Lose("X"), Draw("Y"), Win("Z"); companion object { fun parse(input: String): Outcome = when (input) { "X" -> Lose "Y" -> Draw "Z" -> Win else -> error("incorrect outcome") } } } enum class RockP...
0
Kotlin
0
0
d0b49770fc313ae42d802489ec757717033a8fda
2,680
advent-of-code-2022
Apache License 2.0
src/main/kotlin/utils/Collections.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package utils /** * Returns all the possible combinations (order does not matter) formed from given values. * Each combination will have at least one element. * * combinations([1,2,3]) => [[1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]] * * Duplicates are allowed if you feed in duplicates: * combinations([1...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
3,440
adventOfCode2021
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day16/day16.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day16 import pl.mrugacz95.aoc.day2.toInt class Ticket(description: String) { private val groups = description.split("\n\n") private val fields = groups[0].split("\n").map { val field = it.split(": ") val values = field[1].split(" or ") .map { range -> range...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
10,123
advent-of-code-2020
Do What The F*ck You Want To Public License
src/year_2021/day_04/Day04.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_04 import readInput import java.lang.NumberFormatException data class BingoSquare( val number: Int, var marked: Boolean = false ) data class Board( val rows: List<List<BingoSquare>> ) { val hasWon: Boolean get() { val rowWin = rows.any { row -> row.all { squa...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,150
advent_of_code
Apache License 2.0
src/main/kotlin/day15/Day15.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day15 import java.io.File import java.util.PriorityQueue // Syntax sugar typealias Matrix<T> = Array<Array<T>> typealias RiskFn = (Pair<Int, Int>) -> Int private fun <T> Matrix<T>.get(pair: Pair<Int, Int>) = this[pair.first][pair.second] private fun <T> Matrix<T>.put(pair: Pair<Int, Int>, element: T) { thi...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
2,492
advent-of-code-2021
MIT License
src/day07/Day07.kt
Ciel-MC
572,868,010
false
{"Kotlin": 55885}
package day07 import readInput sealed interface FileItem { val name: String val size: Int var parent: Folder? fun visit(visitor: (FileItem) -> Unit) } data class Folder(override val name: String, private val children: MutableList<FileItem>, override var parent: Folder?): FileItem { fun addCh...
0
Kotlin
0
0
7eb57c9bced945dcad4750a7cc4835e56d20cbc8
3,430
Advent-Of-Code
Apache License 2.0
src/Day05.kt
bananer
434,885,332
false
{"Kotlin": 36979}
fun main() { data class Point(val x: Int, val y: Int) data class Line(val start: Point, val end: Point) val lineRegex = Regex("(\\d+),(\\d+) -> (\\d+),(\\d+)") infix fun Int.towards(b: Int): IntProgression { return if (this < b) { this .. b } else { (b .. this)...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
2,654
advent-of-code-2021
Apache License 2.0
src/main/kotlin/aoc2015/AllInASingleNight.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2015 import komu.adventofcode.utils.nonEmptyLines fun allInASingleNight(input: String, longest: Boolean = false): Int { val legs = Leg.parseAll(input) val cities = legs.flatMap { it.cities }.toSet() val best = if (longest) Collection<Int>::maxOrNull else Collection<Int>::minO...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,478
advent-of-code
MIT License
src/Day12.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
open class Vertex( val name: Char, val height: Char, val edges: MutableList<Vertex> = mutableListOf() ) private fun buildGraph(input: List<String>): MutableList<MutableList<Vertex>> { val grid = mutableListOf<MutableList<Vertex>>() for (line in input) { grid.add(line.toCharArray().map { Ver...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
2,902
advent-of-code
Apache License 2.0
src/Day15.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min typealias Coordinate = Pair<Int, Int> fun main() { fun parse(input: List<String>): List<Pair<Coordinate, Coordinate>> = input.asSequence() .map { it.split(": ").toList() } .map { it[0].substringAfter("at ") to it[...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,584
aoc2022
Apache License 2.0
src/Day03.kt
treegem
572,875,670
false
{"Kotlin": 38876}
import common.readInput fun main() { val day = "03" fun part1(input: List<String>) = input .map { findBadlyPackedItem(it) } .sumOf { getPriority(it) } fun part2(input: List<String>): Int { return input .chunked(3) .map { findBatch(it) } ...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
1,491
advent_of_code_2022
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day15.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import kotlin.math.absoluteValue private fun manhattenDistance(x: Long, y: Long, foundX: Long, foundY: Long) = (x - foundX).absoluteValue + (y - foundY).absoluteValue class Day15(private val row: Long, private val maxCoordinate: Int) : AdventDay(2022, 15) { data class Senso...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
3,366
advent-of-code
Apache License 2.0
src/Day01.kt
KristianAN
571,726,775
false
{"Kotlin": 9011}
fun main() { fun part1(input: List<String>): Int = input.foldIndexed(MaxCalories(0,0)) { index, acc, s -> if (s.isEmpty()) { val calories = input.subList(acc.startIndex, index).fold(0) { accum, n -> n.toInt() + accum } if (calories > acc.currentMax) MaxCalories(ca...
0
Kotlin
0
0
3a3af6e99794259217bd31b3c4fd0538eb797941
1,750
AoC2022Kt
Apache License 2.0
src/Day24Part1.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import Day24Part1.part1 import kotlin.math.max import kotlin.math.min object Day24Part1 { data class XYZ( val x: Double, val y: Double, val z: Double, ) data class Path( val p1: XYZ, val p2: XYZ, ) { fun onPath(x: Double, y: Double): Boolean { ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
2,965
aoc-2023
Apache License 2.0