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/Day15.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
import kotlin.math.abs data class Beacon(val x: Int, val y: Int) { fun toTuningFrequency(): Long = x * 4_000_000L + y } data class Sensor(val x: Int, val y: Int, val closestBeacon: Beacon) { fun intoRange(yLine: Int): IntRange { val distance = abs(x - closestBeacon.x) + abs(y - closestBeacon.y) ...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
3,299
advent-of-code-kotlin-2022
Apache License 2.0
src/year2023/Day7.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import readLines fun main() { val input = parseInput(readLines("2023", "day7")) val testInput = parseInput(readLines("2023", "day7_test")) check(CamelCards("T55J5", 0).cardType(false) == 4) check(CamelCards("T55J5", 0).cardType(true) == 6) check(CamelCards("KTJJT", 0).cardType(fa...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
3,346
advent_of_code
MIT License
src/Day02.kt
pmatsinopoulos
730,162,975
false
{"Kotlin": 10493}
// I need to parse one line and retrieve the following information: // Game index // Number of Sets // For Each Set the number of blue, red, and green cubes // All sets in a game should be possible for the game to be possible. // enum class Color { RED, GREEN, BLUE } data class SetOfCubes( val numbers...
0
Kotlin
0
0
f913207842b2e6491540654f5011127d203706c6
2,643
advent-of-code-kotlin-template
Apache License 2.0
src/year2023/day02/Day02.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day02 import check import readInput fun main() { val testInput = readInput("2023", "Day02_test") check(part1(testInput), 8) check(part2(testInput), 2286) val input = readInput("2023", "Day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<String...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,568
AdventOfCode
Apache License 2.0
src/Day02.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.readInput fun main() { fun part1(input: List<String>) = input.asSequence() .map { it.split(' ') } .map { RPSType.of(it[0].single()) to RPSType.of(it[1].single()) } .map { (opponentSign, mySign) -> mySign to mySign.match(opponentSign) } .map { (mySign, result) -> mySign.s...
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
2,079
aoc-2022
Apache License 2.0
src/Day11.kt
cisimon7
573,872,773
false
{"Kotlin": 41406}
fun main() { fun part1(monkeys: List<Monkey>): Long { val rounds = 20 repeat(rounds) { _ -> monkeys.sortedBy { it.id }.forEach { monkey -> while (monkey.worryLevels.isNotEmpty()) { val (item, id) = monkey.inspectNext { it / 3 } monk...
0
Kotlin
0
0
29f9cb46955c0f371908996cc729742dc0387017
3,274
aoc-2022
Apache License 2.0
archive/2022/Day13.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 13 private const val EXPECTED_2 = 140 fun parse(data: String): Any { if (data[0] != '[') { return data.toInt() } var nesting = 0 var lastIndex = 1 return buildList { for ((i, ch) in data.withIndex()) { when (ch) { '[' -> nes...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,981
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day15.kt
akowal
434,506,777
false
{"Kotlin": 30540}
import java.util.PriorityQueue import kotlin.math.abs fun main() { println(Day15.solvePart1()) println(Day15.solvePart2()) } object Day15 { private val risks = readInput("day15").map { it.map(Char::digitToInt) } fun solvePart1() = findMinRisk(risks) fun solvePart2() = findMinRisk(tile(risks, 5))...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
2,602
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
2015/Day09/src/main/kotlin/Main.kt
mcrispim
658,165,735
false
null
import java.io.File class Graph(input: List<String>) { data class Edge(val from: String, val to: String, val distance: Int) var nodes = mutableSetOf<String>() var shortestEdge: Edge? = null val edges = mutableMapOf<String, List<Edge>>() init { input.forEach { val (city1, _, c...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
3,019
AdventOfCode
MIT License
src/Day12.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
const val BIG = 100_000_000_000 fun main() { fun parsed(lines: List<String>): List<List<Int>> = lines.map { line -> line.map { when (it) { 'S' -> -1 'E' -> 26 else -> it - 'a' } } } ...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
3,196
advent-of-code-kotlin
Apache License 2.0
src/Day08.kt
Miguel1235
726,260,839
false
{"Kotlin": 21105}
private fun createNodes(input: List<String>): Map<String, Pair<String, String>> { val nodeRegex = Regex("""[A-Z0-9]+""") val nodes: MutableMap<String, Pair<String, String>> = mutableMapOf() for (i in 2..<input.size) { val results = nodeRegex.findAll(input[i]) val (name, left, right) = resul...
0
Kotlin
0
0
69a80acdc8d7ba072e4789044ec2d84f84500e00
2,411
advent-of-code-2023
MIT License
src/Day07.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 6440 private const val EXPECTED_2 = 5905 private class Day07(isTest: Boolean) : Solver(isTest) { var withJokers = false val order get() = if(withJokers) listOf("A", "K", "Q", "T", "9", "8", "7", "6", "5", "4", "3", "2", "J") else listOf("A", "K", "Q", "J", "T", "...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,644
advent-of-code-2022
Apache License 2.0
lib/src/main/kotlin/aoc/day08/Day08.kt
Denaun
636,769,784
false
null
package aoc.day08 import aoc.AocGrammar import com.github.h0tk3y.betterParse.combinators.use import com.github.h0tk3y.betterParse.grammar.parseToEnd import kotlin.math.max fun part1(input: String): Int = countAllVisible(parse(input)) fun part2(input: String): Int = bestScenicScore(parse(input)) object Day08Grammar ...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
2,568
aoc-2022
Apache License 2.0
src/Day18.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun pts(): List<C3> { return readInput("Day18").map { it.split(",").map(String::toInt) }.map { C3(it[0], it[1], it[2]) } .also { ptsSet = HashSet(it) } } lateinit var ptsSet: HashSet<C3> private fun part1(pts: List<C3>): Int { val total = pts.size * 6 val covered = pts.sumOf { p -> getAdjac...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
2,378
advent-of-code-2022
Apache License 2.0
src/year2023/day12/Day12.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day12 import check import readInput fun main() { val testInput = readInput("2023", "Day12_test") check(part1(testInput), 21) check(part2(testInput), 525152L) val input = readInput("2023", "Day12") println(part1(input)) println(part2(input)) } private fun part1(input: List<St...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,814
AdventOfCode
Apache License 2.0
src/Day11.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
fun main() { data class Decision(val to: Int, val item: Long) class Monkey(spec: List<String>) { val id: Int val items: MutableList<Long> val operateFn: (Long) -> Long val testFn: (Long) -> Boolean val dividedBy: Long val ifTrue: Int val ifFalse: Int ...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
3,279
advent-of-code-kotlin-2022
Apache License 2.0
src/day15/Day15.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day15 import utils.* import kotlin.math.absoluteValue val COORDS_REGEX = """x=(-?\d+), y=(-?\d+)""".toRegex() data class Coords(var x: Int, var y: Int) { val manhattanDelta: Int get() = x.absoluteValue + y.absoluteValue operator fun plus(other: Coords): Coords = Coords(x + other.x, y + other.y) ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
3,406
AOC-2022-Kotlin
Apache License 2.0
src/Day08.kt
undermark5
574,819,802
false
{"Kotlin": 67472}
fun main() { fun part1(input: List<String>): Int { val trees = input.map { it.toCharArray().map { it.digitToInt() } } val transposed = MutableList( trees.first().size ) { col -> MutableList(trees.size) { row -> ...
0
Kotlin
0
0
e9cf715b922db05e1929f781dc29cf0c7fb62170
3,022
AoC_2022_Kotlin
Apache License 2.0
src/day15/Day15.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day15 import Coordinate import flatten import readInput import java.lang.Integer.max import java.lang.Integer.min import kotlin.math.absoluteValue const val day = "15" fun main() { fun calculatePart1Score(input: List<String>, y: Int): Int { val sensorsAndBeacons = input.parseInputs() v...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
2,927
advent-of-code-22-kotlin
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day03.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val problem = readInput(2023, 3).useLines { lines -> val grid = lines.toList() val numberIndices = mutableMapOf<Index, NumberInfo>() for (y in grid.indices) { val row = ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,915
adventofcode
Apache License 2.0
src/year_2022/day_13/Day13.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_13 import readInput object Day13 { val compare: (String, String) -> Int = { s1: String, s2: String -> if (inOrder(s1.toMutableList(), s2.toMutableList())){ -1 } else { 1 } } /** * @return */ fun solutionOne(text: List<St...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,297
advent_of_code
Apache License 2.0
src/Day09.kt
Soykaa
576,055,206
false
{"Kotlin": 14045}
import kotlin.math.* private operator fun Pair<Int, Int>.plus(b: Pair<Int, Int>) = Pair((first + b.first), (second + b.second)) private fun processInstructions(direction: String): Pair<Int, Int>? = when (direction) { "R" -> Pair(1, 0) "L" -> Pair(-1, 0) "U" -> Pair(0, 1) "D" -> Pair(0, -1) else ->...
0
Kotlin
0
0
1e30571c475da4db99e5643933c5341aa6c72c59
1,699
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2022/day12/Day12.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day12 import com.jacobhyphenated.advent2022.Day import java.util.PriorityQueue /** * Day 12: Hill Climbing Algorithm * * The terrain is given as a 2d map of characters. 'S' is the start position, 'E' is the end position. * The characters indicate the height of the terrain wi...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
4,799
advent2022
The Unlicense
src/day19/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day19 import assert import println import readInput import kotlin.math.min import kotlin.math.max fun main() { data class Rule(val name: String, val operation: Char?, val limit: Int?, val destination: String?) { constructor(name: String) : this(name, null, null, null) } data class Workflo...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
5,243
advent-of-code-2023
Apache License 2.0
src/commonMain/kotlin/advent2020/day17/Day17Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day17 fun part1(input: String): String = common(input) { x, y -> listOf(x, y, 0) } fun part2(input: String): String = common(input) { x, y -> listOf(x, y, 0, 0) } private fun common(input: String, init: (Int, Int) -> List<Int>): String { var pocket = input.trim().lines() .flatMapIndex...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
1,755
advent-of-code-2020
MIT License
src/Day08.kt
MisterTeatime
560,956,854
false
{"Kotlin": 37980}
fun main() { fun part1(input: List<String>): Int { val cols = (0 until input[0].length) .map { input.fold("") {acc, s -> acc + s[it] } } return input.mapIndexed { rIndex, row -> row.mapIndexed { cIndex, c -> isVisible(row, cIndex, c.digitToInt()) || isVisible...
0
Kotlin
0
0
8ba0c36992921e1623d9b2ed3585c8eb8d88718e
1,904
AoC2022
Apache License 2.0
src/Day16.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { class Node(val rate: Int, var paths: List<Node> = emptyList()) val inputLineRegex = """Valve ([A-Z]+) has flow rate=(\d+)""".toRegex() val input2LineRegex = """([A-Z]+)""".toRegex() fun parseData(input: List<String>): Map<String, Node> { val nodes = mutableMapOf<String, Node>() ...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
2,586
aoc2022
Apache License 2.0
src/Day08.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
fun main() { fun readMatrix(input: List<String>) = input .map { row -> row.map { it.digitToInt() } } fun List<List<Int>>.leftOf(x: Int, y: Int) = this[y].subList(0, x) fun List<List<Int>>.rightOf(x: Int, y: Int) = this[y].subList(x+1, this[y]...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
2,596
advent-of-code-2022
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day12/day12.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day12 import eu.janvdb.aocutil.kotlin.readLines //private const val FILENAME = "input12-test.txt" private const val FILENAME = "input12.txt" private val BLOCK_REGEX = Regex("#+") fun main() { val puzzles = readLines(2023, FILENAME).map { Puzzle.parse(it) } val counts = puzzles.map ...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
5,115
advent-of-code
Apache License 2.0
src/day08/Day08.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day08 import println import readInput fun main() { fun part1(input: List<String>) = input.sumOf { it.split("|")[1].split(" ").count { word -> listOf(2, 3, 4, 7).contains(word.length) } } fun String.intersect(decoded: String?) = decoded!!.toCharArray().count { c -> contains(c) } fun List...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
2,022
advent-of-code-2021
Apache License 2.0
src/y2015/Day15.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput import kotlin.math.max data class Ingredient( val capacity: Int, val durability: Int, val flavor: Int, val texture: Int, val calories: Int ) /** * generate all possible ways [total] can be a sum of [n] non-negative integers, taking order into account */ fun g...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,017
advent-of-code
Apache License 2.0
src/day12/Day12.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
package day12 import java.io.File data class Cave( val name: String ) { fun isEnd() = name == "end" fun isStart() = name == "start" fun isLarge(): Boolean = name[0].isUpperCase() fun isSmall() = !isStart() && !isEnd() && name[0].isLowerCase() } fun readCavesFromFile(fileName: String): Map<Cave,...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
3,088
AdventOfCode2021
Apache License 2.0
src/Day12.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
import java.util.Queue import java.util.LinkedList enum class DIRECTION { UP, RIGHT, DOWN, LEFT } fun main() { data class Point(val x: Int, val y: Int) { fun move(d: DIRECTION) = when (d) { DIRECTION.UP -> Point(x - 1 , y) DIRECTION.DOWN -> Point(x + 1, y) DIRECTION.LEF...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
3,349
advent-of-code-kotlin-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day15/Day15.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.day15 import nl.sanderp.aoc.common.* import java.util.* import kotlin.math.min fun main() { val input = parse(readResource("Day15.txt")) val (answer1, duration1) = measureDuration<Int> { shortestPath(input) } println("Part one: $answer1 (took ${duration1.prettyPrint()})") ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,292
advent-of-code
MIT License
src/Day03.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.readInput fun main() { fun part1(input: List<String>) = input .map { it.substring(0, it.length / 2) to it.substring(it.length / 2, it.length) } .map { (first, second) -> first.first(second::contains) } .sumOf { priority(it) } fun part2(input: List<String>): Int { r...
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
1,482
aoc-2022
Apache License 2.0
src/Day04.kt
kuolemax
573,740,719
false
{"Kotlin": 21104}
fun main() { fun parseGroupStringToRange(group: String): Pair<IntRange, IntRange> { val pairs = group.split(",") val pair1: IntRange = (pairs[0].split("-")[0].toInt()..pairs[0].split("-")[1].toInt()) val pair2: IntRange = (pairs[1].split("-")[0].toInt()..pairs[1].split("-")[1].toInt()) ...
0
Kotlin
0
0
3045f307e24b6ca557b84dac18197334b8a8a9bf
1,584
aoc2022--kotlin
Apache License 2.0
src/year2021/day10/Day10.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day10 import util.assertTrue import util.read2021DayInput fun main() { fun task1(input: List<String>, chunks: List<Pair<Char, Char>>): Int { val lastCharsInCorruptedLines = input.mapNotNull { isCorrupted(it, chunks) } return calculateCorruptedScore(lastCharsInCorruptedLines)...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
2,600
advent-of-code-kotlin-template
Apache License 2.0
src/y2023/Day02.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { fun part1(input: List<String>): Int { val limits = mapOf( "red" to 12, "green" to 13, "blue" to 14 ) var sum = 0 input.forEach { gameString -> val gameData = gameString.split("Game") ...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
2,735
advent-of-code-kotlin
Apache License 2.0
src/Day07.kt
razvn
573,166,955
false
{"Kotlin": 27208}
fun main() { val day = "Day07" fun part1(input:List<String>): Long { val root = dirTree(input) val maxSize = 100000 val validDirs = getSubDirs(listOf(root), emptyList()) { it.size() <= maxSize } // getSubDirs(emptyList(), root) { it.size() <= maxSize } // println("Valid dirs: ...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
2,899
aoc-2022-kotlin
Apache License 2.0
src/Day11.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class VirtualGalaxy( val input: Input, val exRows: List<Int>, val exCols: List<Int>, val expandSize: Long, ) fun String.canExpand() = this.all { it == '.' } fun Input.canExpand(i: Int) = this.map { it[i] }.joinToString("").canE...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
2,980
aoc-2023
Apache License 2.0
src/Day19.kt
sabercon
648,989,596
false
null
private fun matchRule(ruleMap: Map<String, List<List<String>>>, message: String, rules: List<List<String>>): List<Int> { return rules.flatMap { rs -> rs.fold(listOf(0)) { acc, rule -> acc.flatMap { size -> matchRule(ruleMap, message.substring(size), rule).map { size + it } } } } } p...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
1,342
advent-of-code-2020
MIT License
src/Day07.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
import kotlin.math.max fun main() { fun part1(input: List<String>): Long { val root = parse(input) var sum = 0L fun run(folder: Folder) { if (folder.size <= 100000L) sum += folder.size folder.subDirectories.forEach { run(it) } } run(ro...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
2,401
advent-of-code-2022
Apache License 2.0
src/Day15.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>, targetY: Int = 2000000): Int { val parsed = input.map(::parse) var minX = Int.MAX_VALUE var maxX = Int.MIN_VALUE parsed.forEach { (sensor, beacon) -> val dist = sensor.manhattanDis...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
3,172
advent-of-code-2022
Apache License 2.0
src/Day13.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
fun main() { fun parseToken(token: String): Pair<Int, Int> { var head = 0 var tail = token.length for (c in token) { when (c) { '[' -> head++ ']' -> tail-- } } return when (head) { tail -> Pair(0, -1) ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
2,340
aoc-2022
Apache License 2.0
src/Day05.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun solve(input: List<String>, reverse: Boolean = false): String { val (stacks, instructions) = parseInput(input) instructions.forEach { val from = stacks[it.fromIndex] val to = stacks[it.toIndex] (1..it.quantity) .map { from.removeF...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
1,927
advent-of-code-2022
Apache License 2.0
src/Day03.kt
winnerwinter
573,917,144
false
{"Kotlin": 20685}
fun main() { fun part1(): Int { val testInput = readInput("Day03_test") val test_ans = computePrioritiesOfMisplacedItems(testInput.toRucksacks()) check(test_ans == 157) val input = readInput("Day03") val ans = computePrioritiesOfMisplacedItems(input.toRucksacks()) r...
0
Kotlin
0
0
a019e5006998224748bcafc1c07011cc1f02aa50
1,911
advent-of-code-22
Apache License 2.0
src/day16/Day16.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day16 import day16.Operation.* import println import readInput import readInputAsText enum class Operation(val id: String) { SUM("000"), PRODUCT("001"), MIN("010"), MAX("011"), LIT("100"), GT("101"), LT("110"), EQ("111")} sealed interface Packet { val version: Int; val length: Int } data class OperationPacket...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
3,554
advent-of-code-2021
Apache License 2.0
src/Day23.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
fun main() { fun List<String>.parse() = mapIndexed { y, row -> row.mapIndexedNotNull { x, cell -> if (cell == '#') y to x else null } }.flatten().toSet() fun Pair<Int, Int>.adjNorth() = listOf( first - 1 to second, first - 1 to second - 1, first - 1 to second + 1, ) ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
2,561
aoc-2022
Apache License 2.0
src/Day08.kt
trosendo
572,903,458
false
{"Kotlin": 26100}
import kotlin.math.abs private data class ForestTree( val height: Int, val yPos: Int, val xPos: Int, val id: Int ) private data class TreeRow( val items: List<ForestTree> ) fun main() { var count = 0 val forest = readInputAsList("Day08").mapIndexed { y, row -> TreeRow(row.mapIndex...
0
Kotlin
0
0
ea66a6f6179dc131a73f884c10acf3eef8e66a43
3,587
AoC-2022
Apache License 2.0
src/day02/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day02 import println import readInput import kotlin.streams.asSequence enum class CubeColor { RED, GREEN, BLUE; companion object { fun find(colorString: String): CubeColor? { return values().find { it.name.equals(colorString, ignoreCase = true) } } } } fun main() { ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
3,027
advent-of-code-2023
Apache License 2.0
src/Day15.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val list = parseInput(input) val intervals = mutableListOf<IntRange>() for ((sX, sY, bX, bY) in list) { val currentDistance = abs(bX - sX) + abs(bY - sY) val distanceToRow = abs(2000000 - sY) ...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
2,041
aoc-2022
Apache License 2.0
src/Day15.kt
kmakma
574,238,598
false
null
import kotlin.math.abs fun main() { data class Interval(var start: Int, var end: Int) { fun limit(minStart: Int, maxEnd: Int) { start = maxOf(minStart, start) end = minOf(maxEnd, end) } fun size(): Int { return 1 + end - start } } fun L...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
2,519
advent-of-kotlin-2022
Apache License 2.0
src/Day02.kt
jorander
571,715,475
false
{"Kotlin": 28471}
import Outcome.* import Outcome.Companion.outcome import Shape.Companion.myShape import Shape.Companion.opponentShape enum class Shape(val opponentCode: String, val myCode: String, val score: Int, val winsOver: Int) { ROCK("A", "X", 1, 2), PAPER("B", "Y", 2, 0), SCISSORS("C", "Z", 3, 1); companion obj...
0
Kotlin
0
0
1681218293cce611b2c0467924e4c0207f47e00c
2,468
advent-of-code-2022
Apache License 2.0
2021/src/main/kotlin/day22.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Component4 import utils.Component4.X import utils.Component4.Y import utils.Component4.Z import utils.Parser import utils.Point3i import utils.Solution import utils.Vec4i import utils.flipped import utils.mapItems fun main() { Day22.run() } object Day22 : Solution<List<Day22.Command>>() { override va...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,262
aoc_kotlin
MIT License
src/day19/Day19.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day19 import utils.* import kotlin.math.ceil val ROBOT_REGEX = """Each (\w+) robot costs (\d+) (\w+)(?: and (\d+) (\w+))?.""".toRegex() val MATERIALS = listOf("ore", "clay", "obsidian", "geode") data class State( val robots: Map<String, Int>, val materials: Map<String, Int>, val time: Int ) ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
4,603
AOC-2022-Kotlin
Apache License 2.0
src/aoc_2023/Day02.kt
jakob-lj
573,335,157
false
{"Kotlin": 38689}
package aoc_2023 import java.lang.RuntimeException data class Round(val blue: Int?, val green: Int?, val red: Int?) data class Game(val consumesTotalDrawings: Round, val gameId: Int) private val testInput = """ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1...
0
Kotlin
0
0
3a7212dff9ef0644d9dce178e7cc9c3b4992c1ab
2,658
advent_of_code
Apache License 2.0
src/day08/Day08.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day08 import readLines typealias Grid = List<List<Int>> val List<String>.grid: Grid get() = this.map { line -> line.toList().map { it.digitToInt() } } val Grid.height: Int get() = size val Grid.width: Int get() = first().size fun <T> Grid.map(block: (row: Int, column: Int, i: Int) -> T) = (0 until height)...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
2,061
advent-of-code-22
Apache License 2.0
y2022/src/main/kotlin/adventofcode/y2022/Day11.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day11 : AdventSolution(2022, 11, "Monkey in the Middle") { override fun solvePartOne(input: String): Long = solve(input, 20, 3) override fun solvePartTwo(input: String): Long = solve(input, 10_000, 1) private fun solve(input: String...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,600
advent-of-code
MIT License
src/main/kotlin/aoc2023/Day03.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day03 { fun part1(input: List<String>): Int { val symbols = getSymbolCoords(input) val numRegex = "(\\d+)".toRegex() var sum = 0 for (y in input.indices) { numRegex.findAll(input[y]).forEach { match -> if (getAdjacentCoords(y to matc...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
2,193
advent-of-code-2023
MIT License
src/Day02.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
import org.apache.commons.lang3.StringUtils fun main() { fun game(playerOne: String, playerTwo: String): Pair<GameResult,Token> { val pOne = Token.getByToken(playerOne) val pTwo = Token.getByToken(playerTwo) if (pOne == pTwo) return Pair(GameResult.DRAW, pTwo) if (pOne.willLose(pTw...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
2,314
AdventOfCode2022
Apache License 2.0
AoC2021day14-ExtendedPolymerization/src/main/kotlin/Main.kt
mcrispim
533,770,397
false
{"Kotlin": 29888}
import java.io.File val transforms = mutableMapOf<Pair<String, Int>, Map<Char, Long>>() var tableOfPairs = mapOf<String, String>() fun main() { val input = File("data.txt").readLines() tableOfPairs = prepareTableOfPairs(input.slice(2..input.lastIndex)) initialTransforms(tableOfPairs) val polymer = ...
0
Kotlin
0
0
ac4aa71c9b5955fa4077ae40fc7e3fc3d5242523
2,254
AoC2021
MIT License
src/day11/Day11.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day11 import java.io.File fun main() { println(solve(readInput(), 20, 3)) println(solve(readInput(), 10000, 1)) } private fun readInput(): List<Monkey> { val regex = """Monkey \d*: Starting items: (.*) Operation: new = (.*) Test: divisible by (\d*) If true: throw to monkey (\d*) If ...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
1,881
advent-of-code-2022
MIT License
src/main/kotlin/Day08.kt
rgawrys
572,698,359
false
{"Kotlin": 20855}
import utils.readInput fun main() { fun part1(input: List<String>): Int = treesCountVisibleOutsideTheGrid(input) fun part2(input: List<String>): Int = highestScenicScore(input) // test if implementation meets criteria from the description, like: val testInput = readInput("Day08_test") part1(testI...
0
Kotlin
0
0
5102fab140d7194bc73701a6090702f2d46da5b4
3,273
advent-of-code-2022
Apache License 2.0
src/Day09.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
import kotlin.math.abs private data class Vector(val x: Int, val y: Int) { operator fun minus(other: Vector) = Vector(x - other.x, y - other.y) operator fun plus(other: Vector) = Vector(x + other.x, y + other.y) } private data class Rope( val head: Vector, val tail: Vector, ) { fun moveHead(direct...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
3,232
aoc-2022
Apache License 2.0
src/Day07.kt
rafael-ribeiro1
572,657,838
false
{"Kotlin": 15675}
fun main() { fun part1(input: List<String>): Long { return input.buildFilesystemTree() .directorySizes() .filter { it <= 100000 } .sum() } fun part2(input: List<String>): Long { val tree = input.buildFilesystemTree() val sizes = tree.directorySize...
0
Kotlin
0
0
5cae94a637567e8a1e911316e2adcc1b2a1ee4af
2,737
aoc-kotlin-2022
Apache License 2.0
src/Day07.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
enum class HandType { K5, K4, FH, K3, P2, P1, HC } val cardOrder1 = "A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2".split(", ").map { it[0] } val cardOrder2 = "A, K, Q, T, 9, 8, 7, 6, 5, 4, 3, 2, J".split(", ").map { it[0] } fun getHandType1(h: String): HandType { val cc = h.groupingBy { it }....
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,732
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day19.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* fun main() { val input = Input.day(19) println(day19A(input)) println(day19B(input)) } fun day19A(input: Input): Int { val workflows = Workflow.init(input) return input.chunks[1].lines().sumOf { line -> val ints = line.toInts() val part = Part(ints[0], ints[1], ints...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
5,068
AdventOfCode2023
MIT License
src/Day08.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.util.Stack import kotlin.math.max typealias ScenicState = Pair<Stack<Pair<Int, Int>>, Int> private enum class Side { UP, DOWN, LEFT, RIGHT } private data class Tree( val height: Int, var up: Tree? = null, var down: Tree? = null, var left: Tree? = null, var right: Tree? = null, ) { ...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
3,226
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/Day04.kt
uipko
572,710,263
false
{"Kotlin": 25828}
fun main() { val pairsContains = contains("Day04.txt") println("The total sum of pairs of elf to reconsider is: $pairsContains") val pairsOverlap = overlap_wip("Day04.txt") println("The total sum of pairs of elf to reconsider is: $pairsOverlap") } fun contains(fileName: String): Int { val test =...
0
Kotlin
0
0
b2604043f387914b7f043e43dbcde574b7173462
1,525
aoc2022
Apache License 2.0
src/main/kotlin/day14/Polymerization.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day14 import utils.merge import utils.read data class Rule(val first: Char, val second: Char, val insert: Char) fun main() { solve().let { println(it) } } fun solve() = listOf(day14.solve(10), day14.solve(40)) fun solve(rounds: Int): Long { val input = read("./src/main/resources/day14Input.txt") ...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
2,474
adventOfCode2021
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/03.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d03 import input.read fun main() { val (numbers, symbols) = parseMap(read("03.txt")) println("Part 1: ${part1(numbers, symbols)}") println("Part 2: ${part2(numbers, symbols)}") } fun part1(numbers: Numbers, symbols: Symbols): Int { return numbers.filter { entry -> (0..<entry.value.toS...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
2,417
aoc
The Unlicense
src/Day05.kt
cisimon7
573,872,773
false
{"Kotlin": 41406}
fun main() { fun part1(pair: Pair<MutableList<MutableList<Char>>, List<Move>>): String { var (stacks, instructions) = pair instructions.forEach { (count, from, to) -> val items = stacks[from].takeLast(count) stacks[to].addAll(items.reversed()) stacks[from] = stack...
0
Kotlin
0
0
29f9cb46955c0f371908996cc729742dc0387017
2,340
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day21.kt
mstar95
317,305,289
false
null
package days inline class Allergen(val value: String) inline class Ingredient(val value: String) class Day21 : Day(21) { override fun partOne(): Any { val entries = prepareInput(inputList) val allergens = basicAllergens(entries) val safe = entries.safeIngredients(allergens) // print...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,899
aoc-2020
Creative Commons Zero v1.0 Universal
src/day12/Day12.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day12 import readInput import java.util.* fun main() { println(solve1(parse(readInput("day12/test")))) println(solve1(parse(readInput("day12/input")))) println(solve2(parse(readInput("day12/test")))) println(solve2(parse(readInput("day12/input")))) } typealias Point = Pair<Int, Int> fun ...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
3,198
aoc-2022
Apache License 2.0
src/Day08.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
import java.io.File fun main() { val testInput = """30373 25512 65332 33549 35390""" val realInput = File("src/Day08.txt").readText() val part1TestOutput = treesVisible(testInput) println("Part 1 Test Output: $part1TestOutput") check(part1TestOutput == 21) val part1RealOutput = treesVisible(realInput) ...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
2,391
advent-of-code-2022
Apache License 2.0
src/twentythree/Day04.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentythree import readInputTwentyThree import kotlin.math.pow /** * Integer power using [Double.pow] */ infix fun Int.pow(exponent: Int): Int = toDouble().pow(exponent).toInt() data class Card(val id: Int, val winningNumbers: Set<Int>, val ownNumbers: Set<Int>) { fun numberOfMatches() = winningNumbers...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
2,583
kotlin-aoc-1
Apache License 2.0
src/Day08.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
typealias GridWalk = Pair<IntProgression, IntProgression> typealias GridCrossWalk = IntProgression fun main() { fun getRanges(size: Int): List<IntProgression> = listOf((0 until size), (size - 1 downTo 0)) fun getRanges(size: Int, start: Int): List<IntProgression> = listOf((start - 1 downTo 0),...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
3,103
advent-of-code-2022-kt
Apache License 2.0
src/main/kotlin/Day13.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
fun main() { fun part1(input: List<Packet>): Int = input.chunked(2) .mapIndexed { index, packets -> if (packets.first() < packets.last()) index + 1 else 0 } .sum() fun part2(input: List<Packet>): Int { val packet1 = ListPacket(listOf(ListPacket(listOf(ListPacket(listOf(IntPacket(2)))))...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
2,269
KotlinAdventOfCode2022
Apache License 2.0
src/Day05.kt
andydenk
573,909,669
false
{"Kotlin": 24096}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day05_test") check(part1(testInput) == "CMZ") check(part2(testInput) == "MCD") val input = readInput("Day05") println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } ...
0
Kotlin
0
0
1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1
2,791
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day15.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
import kotlin.math.abs import kotlin.math.absoluteValue fun main() { fun isValid(point: Point, sensors: List<Sensor>): Boolean = (point.x in 0..MAX_COORDINATES && point.y in 0..MAX_COORDINATES) && sensors.none { (sensor, beacon) -> point.distanceTo(sensor) <= sensor.distanceTo( ...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
2,519
KotlinAdventOfCode2022
Apache License 2.0
src/Day04.kt
peterfortuin
573,120,586
false
{"Kotlin": 22151}
fun main() { fun part1(input: List<String>): Int { return input .map { line -> line.parseLine() }.map { rangePair -> when { rangePair.first.intersect(rangePair.second) == rangePair.second.toSet() -> 1 rangePair.s...
0
Kotlin
0
0
c92a8260e0b124e4da55ac6622d4fe80138c5e64
1,528
advent-of-code-2022
Apache License 2.0
src/Day14.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import kotlin.math.max import kotlin.math.min fun main() { fun solution(input: List<String>, part2: Boolean): Int { val map = HashSet<Pair<Int, Int>>() input.forEach { line -> line.split(" -> ").windowed(2).forEach { (a, b) -> val (x0, y0) = a.split(",").map { it.toInt()...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
2,178
aoc-2022
Apache License 2.0
src/Day02.kt
Misano9699
572,108,457
false
null
const val LOSS = 0 const val DRAW = 3 const val WIN = 6 fun main() { val elvesMap: Map<String, RockPaperScissors> = mapOf("A" to RockPaperScissors.ROCK, "B" to RockPaperScissors.PAPER, "C" to RockPaperScissors.SCISSORS) val meMap: Map<String, RockPaperScissors> = mapOf("X" to RockPaperScissors.ROCK, "Y" to R...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
2,384
advent-of-code-2022
Apache License 2.0
src/Day02.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
enum class Gesture(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3) } fun Gesture.beats() = when (this) { Gesture.ROCK -> Gesture.SCISSORS Gesture.PAPER -> Gesture.ROCK Gesture.SCISSORS -> Gesture.PAPER } fun Gesture.beatenBy() = Gesture.values().find { it beats this }!! infix fun Gesture.be...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
2,531
advent-of-code-2022
Apache License 2.0
src/Day11.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
data class Monkey(val items: MutableList<Long>, val operation: (Long) -> Long, val testValue: Int, val ifTrue: Int, val ifFalse: Int,) { var inspected: Long = 0 // Pair<ToMonkey, newWorryLevel> private fun test(manageWorryLevel: (Long)...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
3,235
advent-of-code-kotlin-2022
Apache License 2.0
src/Day09.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign private val MOVES: Map<Char, Pair<Int, Int>> = mapOf(Pair('U', Pair(0, 1)), Pair('D', Pair(0, -1)), Pair('L', Pair(-1, 0)), Pair('R', Pair(1, 0))) fun main() { fun kingDist(a: Pair<Int, Int>, b: Pair<Int, Int>): Int { return max(abs...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
2,009
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/_2018/Day11.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2018 import aocRun fun main() { aocRun(puzzleInput) { input -> val grid = calcPowerLevels(input.toInt()) //grid.forEach { println(it.joinToString()) } val totals = calcTotals(grid, 3) return@aocRun totals.maxByOrNull { it.value }.let { "(${it!!.key.first + 1},${it.key.sec...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
2,368
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Solution07.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf enum class HandType : Comparable<HandType> { HIGH_CARD, ONE_PAIR, TWO_PAIR, THREE_OF_A_KIND, FULL_HOUSE, FOUR_OF_A_KIND, FIVE_OF_A_KIND } class CamelHand(private val cards: CharArray...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
2,765
Advent-of-Code-2023
MIT License
src/Day13.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private val DIVIDER_PACKETS = listOf("[[2]]", "[[6]]") private sealed interface Signal : Comparable<Signal?> { override operator fun compareTo(signal: Signal?): Int } private data class SingleSignal(val element: Int) : Signal { fun toMultiSignal() = MultiSignal(listOf(this)) override fun compareTo(signal...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
2,732
advent-of-code-kotlin
Apache License 2.0
src/Day11.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
fun main() { fun part1(monkeys: List<Monkey>, rounds: Int): Long { (1..rounds).forEach { _ -> monkeys.forEach { monkey -> monkey.evaluate(monkeys) { it.floorDiv(3) } } } return monkeys .sortedByDescending { it.inspections } .take(2) .fold(1L) ...
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
3,264
adventofcode-2022
Apache License 2.0
src/day08/Day08.kt
pnavais
727,416,570
false
{"Kotlin": 17859}
package day08 import readInput class Node(val name: String, var left: Node? = null, var right: Node? = null) private fun readNetwork(input: List<String>): Map<String, Node> { val nodeMap = mutableMapOf<String, Node>() input.drop(2).forEach { s -> val (currentName, siblings) = s.split("[\\s+]=[\\s+]"...
0
Kotlin
0
0
f5b1f7ac50d5c0c896d00af83e94a423e984a6b1
2,300
advent-of-code-2k3
Apache License 2.0
src/year2021/Day9.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import Point import readLines fun main() { val input = parseInput(readLines("2021", "day9")) val testInput = parseInput(readLines("2021", "day9_test")) check(part1(testInput) == 15) println("Part 1:" + part1(input)) check(part2(testInput) == 1134) println("Part 2:" + part2(i...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
2,190
advent_of_code
MIT License
src/Day04.kt
jwalter
573,111,342
false
{"Kotlin": 19975}
fun main() { fun Pair<Int, Int>.rangeContains(other: Pair<Int, Int>): Boolean { return first <= other.first && second >= other.second } fun fullyContains(a: Pair<Int, Int>, b: Pair<Int, Int>): Boolean { return a.rangeContains(b) || b.rangeContains(a) } fun overlaps(a: Pair<Int, Int...
0
Kotlin
0
0
576aeabd297a7d7ee77eca9bb405ec5d2641b441
1,649
adventofcode2022
Apache License 2.0
src/Day12.kt
ricardorlg-yml
573,098,872
false
{"Kotlin": 38331}
import java.util.* class Graph<T> { private val adjacencyMap: HashMap<T, HashSet<T>> = HashMap() fun addEdge(node1: T, node2: T) { adjacencyMap.computeIfAbsent(node1) { HashSet() }.add(node2) } fun shortestPath(start: T, endCondition: (T) -> Boolean): Int { val visited = HashSet<T>() ...
0
Kotlin
0
0
d7cd903485f41fe8c7023c015e4e606af9e10315
3,769
advent_code_2022
Apache License 2.0
src/main/kotlin/aoc2021/Day07.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import kotlin.math.abs import kotlin.math.min /** * Transforms this [IntArray] so that at each index in the result array gives the amount of occurrences of that index * value in the original array * * For example: [0, 0, 2] -> [2, 0, 1] * -> original array contained two zeros -> ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,638
adventOfCode
Apache License 2.0
src/2022/Day08.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun part1(input: List<String>): Int { val forest = input.map { it.asIterable().map { char -> char.toString().toInt() } } return forest.flatMapIndexed { row, trees -> trees.filterIndexed { column, treeHeight -> val checkTop ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
1,895
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day18.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day18.solvePart1()) println(Day18.solvePart2()) } object Day18 { private val numbers = readInput("day18").map { parse(it) } fun solvePart1() = numbers.reduce(::add).magnitude() fun solvePart2() = (0 until numbers.lastIndex) .flatMap { i -> (i + 1..numbers....
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
2,556
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/twentythree/Day04.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentythree import kotlin.math.pow const val day = "04" fun main() { // test if implementation meets criteria from the description: println("Day$day Test Answers:") val testInput = readInputLines("Day${day}_test") val part1 = part1(testInput) part1.println() check(part1 == 13) val ...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
2,919
advent-of-code-solutions
Apache License 2.0
src/Day07.kt
icoffiel
572,651,851
false
{"Kotlin": 29350}
fun main() { class Node( val name: String, var size: Int, val parent: Node? = null, val children: MutableList<Node> = mutableListOf() ) fun directoryList(node: Node): List<Node> { return listOf(node) + node.children.map { directoryList(it) }.flatten() } fun...
0
Kotlin
0
0
515f5681c385f22efab5c711dc983e24157fc84f
3,458
advent-of-code-2022
Apache License 2.0
src/Day13.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>) = input .partitionBy { it.isEmpty() } .mapIndexed { index, (first, second) -> if (check(first, second)) index + 1 else 0 } .sum() fun part2(input: List<String>) = input .filterTo(mutableListOf("[[2]]", "[[6]]")) { it.isNotEmpty() } ...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
2,663
advent-of-code-2022
Apache License 2.0