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/day08/Day08.kt
pientaa
572,927,825
false
{"Kotlin": 19922}
package day08 import readLines fun main() { fun part1(input: List<String>): Int { val transposedInput = input .transpose() return input .mapIndexed { rowIndex, row -> row.mapIndexed { columnIndex, c -> val column = transposedInput[colum...
0
Kotlin
0
0
63094d8d1887d33b78e2dd73f917d46ca1cbaf9c
2,547
aoc-2022-in-kotlin
Apache License 2.0
src/y2023/Day25.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.timingStatistics object Day25 { private fun parse(input: List<String>): List<Pair<String, String>> { return input.flatMap { line -> val (p1, p2) = line.split(": ") p2.split(" ").flatMap { listOf(p1 to it, it to p1) ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
4,120
advent-of-code
Apache License 2.0
src/main/year_2017/day07/day07.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package year_2017.day07 import kotlin.math.absoluteValue import readInput import second fun part1(input: List<String>): String { val programs = input.map(String::parse) return programs.findBottomProgram() } fun part2(input: List<String>): Int { val programs = input.map(String::parse) allPrograms = p...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,220
aoc-2022
Apache License 2.0
src/Day08.kt
Arclights
574,085,358
false
{"Kotlin": 11490}
fun main() { fun <T> List<List<T>>.transpose(): List<List<T>> = this .drop(1) .fold(this.first().map { listOf(it) }) { transposed, row -> transposed.zip(row) { l, r -> l.plus(r) } } fun <T> List<List<T>>.asMatrixString() = this.joinToString("\n") { row -> row.joinToString(""...
0
Kotlin
0
0
121a81ba82ba0d921bd1b689241ffa8727bc806e
2,875
advent_of_code_2022
Apache License 2.0
advent-of-code-2023/src/Day22.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import lib.graph.Graph import lib.graph.GraphNode import lib.graph.GraphNode.Companion.connectToNext import kotlin.math.abs import kotlin.math.min private const val DAY = "Day22" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) sho...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,827
advent-of-code
Apache License 2.0
src/Day03.kt
peterfortuin
573,120,586
false
{"Kotlin": 22151}
fun main() { fun part1(input: List<String>): Int { val incorrectSupplies = input.map { line -> val l = line.toCharArray().map { charToNumber(it) } val twoBags = Pair(l.subList(0, l.size / 2), l.subList(l.size / 2, l.size)) findItemInBothLists(t...
0
Kotlin
0
0
c92a8260e0b124e4da55ac6622d4fe80138c5e64
1,748
advent-of-code-2022
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day24.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution fun main() = Day24.solve() object Day24 : AdventSolution(2018, 24, "Immune System Simulator 20XX") { override fun solvePartOne(input: String): Int { val (immune, disease) = parse(input).chunked(10).toList() val (remI, remD) = runC...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
3,695
advent-of-code
MIT License
src/day8/Day08.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day8 import Runner fun main() { Day8Runner().solve() } class Day8Runner : Runner<Int>( day = 8, expectedPartOneTestAnswer = 21, expectedPartTwoTestAnswer = 8 ) { override fun partOne(input: List<String>, test: Boolean): Int { val rows = rowsOfTrees(input) val columns = co...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
3,247
advent-of-code
Apache License 2.0
src/day11/Day11.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day11 import readText data class Monkey( var items: MutableList<Long>, val operation: (Long) -> Long, val test: Long, val ifTrue: Int, val ifFalse: Int, var inspected: Int = 0 ) fun format(input: String): List<Monkey> = input.split("\n\n") .map { description -> val descriptions = description.split(...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
2,179
advent-of-code-22
Apache License 2.0
src/Day08.kt
ThijsBoehme
572,628,902
false
{"Kotlin": 16547}
fun main() { fun part1(rows: List<String>): Int { val size = rows.size val grid = rows.map { it.toList().map { tree -> tree.digitToInt() } } return grid.mapIndexed { rowNumber, row -> row.mapIndexed { columnNumber, tree -> val visibleFromLeft = tree > (row.take(co...
0
Kotlin
0
0
707e96ec77972145fd050f5c6de352cb92c55937
2,597
Advent-of-Code-2022
Apache License 2.0
src/Day08.kt
timj11dude
572,900,585
false
{"Kotlin": 15953}
typealias Forest = List<List<Tree>> data class Tree(val x: Int, val y: Int, val h: Int, val v: Boolean = false, val s: Int = 0) fun List<List<Tree>>.rotate() = List(size) { rowI -> List(first().size) { colI -> this[first().size - 1 - colI][rowI] } } fun main() { fun parseInput(input: Collection<S...
0
Kotlin
0
0
28aa4518ea861bd1b60463b23def22e70b1ed481
2,173
advent-of-code-2022
Apache License 2.0
src/year_2021/day_08/Day08.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_08 import readInput data class Puzzle( val uniqueNumbers: List<ClockNumber>, val toSolve: List<ClockNumber> ) data class ClockNumber( val segments: List<Char> ) object Day08 { /** * @return */ fun solutionOne(text: List<String>): Int { val puzzles = parse...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
5,025
advent_of_code
Apache License 2.0
src/Day16.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
fun main() { fun part1(input: List<String>): Int { val valves = input.parseReport() return findBestPath(valves).cumulativePressure } fun part2(input: List<String>): Int { val valves = input.parseReport() return findBestPathInPair(valves).cumulativePressure } val tes...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
8,275
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day24/Day24.kt
Jessevanbekkum
112,612,571
false
null
package day24 import util.readLines fun strongest(input: String): Int { val parts = readLines(input).sorted() .map { s -> s.split("/") } .map { s -> s.sorted() } .map { s -> Pair(s[0].toInt(), s[1].toInt()) } return sum(buildStrongestBridge(parts, 0, emptyList())) } fun...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
1,946
aoc-2017
Apache License 2.0
src/Day12.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
import java.util.* fun main() { data class DistancePair( val location: Pair<Int,Int>, val distance: Int ) class DistanceComparator : Comparator<DistancePair> { override fun compare(first:DistancePair, second: DistancePair): Int { return first.distance.compareTo(second....
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
3,049
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
var start = 0 to 0 var end = 0 to 0 private fun heights(input: List<String>) = input.mapIndexed { i, line -> line.mapIndexed { j, char -> when (char) { 'S' -> 'a'.also { start = i to j } 'E' -> 'z'.also { end = i to j } else -> char } ...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
1,723
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/days/y2023/day02/Day02.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day02 import util.InputReader fun partOne(input: String): Int { val parsed = parseInput(input) // The Elf would first like to know which games would have been possible if the bag contained only 12 red cubes, 13 green cubes, and 14 blue cubes? val possible = parsed.filter { it.possible(...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,922
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc2023/Day07.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils enum class HandTypes { FIVE_KIND, FOUR_KIND, FULL_HOUSE, THREE_KIND, TWO_PAIR, ONE_PAIR, HIGH_CARD } val scores = "23456789TJQKA".mapIndexed { index, c -> c to index }.toMap() val jScore = scores['J']!! fun typeForHand(cards: String): HandTypes { val counts = cards.grou...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
3,343
aoc-2022-kotlin
Apache License 2.0
src/com/ncorti/aoc2023/Day19.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 fun main() { fun parseInput(): Pair<Map<String, List<String>>, List<Map<String, Int>>> { val (workflows, parts) = getInputAsText("19") { split("\n\n").filter(String::isNotBlank).map { it.split("\n").filter(String::isNotBlank) } } ...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
4,742
adventofcode-2023
MIT License
src/main/kotlin/com/colinodell/advent2023/Day19.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day19(input: String) { private val workflows = parseWorkflows(input) private val parts = parseParts(input) private class Rule(val category: Char, op: Char, n: Int, val dest: String) { val range = when (op) { '<' -> 1 until n '>' -> n ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
3,604
advent-2023
MIT License
day16/Part2.kt
anthaas
317,622,929
false
null
import java.io.File fun main(args: Array<String>) { val input = File("input.txt").bufferedReader().use { it.readText() }.split("\n\n") val rules = input[0].split("\n").map { it.split(":")[1].split(" or ") .map { it.split('-').let { (low, high) -> low.trim().toInt() to high.trim().toInt() } ...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
2,190
Advent-of-Code-2020
MIT License
src/main/kotlin/codes/jakob/aoc/solution/Day08.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
package codes.jakob.aoc.solution import codes.jakob.aoc.solution.Day08.Digit.* object Day08 : Solution() { override fun solvePart1(input: String): Any { val wantedDigits: Set<Digit> = setOf(ONE, FOUR, SEVEN, EIGHT) return parseInput(input).sumOf { entry: Entry -> val mappings: Map<Patt...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
4,239
advent-of-code-2021
MIT License
src/main/kotlin/be/twofold/aoc2021/Day08.kt
jandk
433,510,612
false
{"Kotlin": 10227}
package be.twofold.aoc2021 object Day08 { fun part1(input: List<String>): Int { return input .map { it.split('|').let { it[1] } } .flatMap { it.split(' ') } .count { it.length in listOf(2, 3, 4, 7) } } fun part2(input: List<String>): Int { return input.s...
0
Kotlin
0
0
2408fb594d6ce7eeb2098bc2e38d8fa2b90f39c3
1,698
aoc2021
MIT License
src/Day08.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
@JvmInline value class Tree(val height: Int) class Forest(private val width: Int, private val height: Int) { private val trees: Array<Array<Tree?>> = Array(width) { Array(height) { null } } fun addTree(x: Int, y: Int, height: Int) { trees[x][y] = Tree(height) } fun coordinates() = Iterable { ...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
2,733
advent-of-code-in-kotlin-2022
Apache License 2.0
src/day15/Day15.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day15 import println import readInput import java.util.Comparator import java.util.PriorityQueue import kotlin.system.measureTimeMillis data class Point(val x: Int, val y: Int) data class Node(val point: Point, val risk: Int, val distance: Int) private fun List<String>.parse(tiles: Int, width: Int, height: I...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
2,386
advent-of-code-2021
Apache License 2.0
src/main/kotlin/net/mguenther/adventofcode/day21/Day21.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day21 import kotlin.math.sqrt /** * @author <NAME> (<EMAIL>) */ data class Pattern(val grid: List<List<Char>>) { constructor(input: String) : this(input.split("/").map { it.toList() }) private fun flip(): Pattern = Pattern(grid.map { it.reversed() }) private fun ro...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
3,422
advent-of-code-2017
MIT License
src/Day02.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
fun main() { val winner = mapOf("A" to "Y", "B" to "Z", "C" to "X") val loser = mapOf("A" to "Z", "B" to "X", "C" to "Y") val equal = mapOf("A" to "X", "B" to "Y", "C" to "Z") fun point_lie_a_mon_jeu(input: List<String>): Int { val somme = input.sumOf { it.substring(2, 3) ...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
1,948
AD2022-01
Apache License 2.0
src/year2022/day12/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day12 import readInput fun main() { val day = "12" val expectedTest1 = 31 val expectedTest2 = 29 fun getPosition(input: List<CharSequence>, positionToFind: Char) = input.mapIndexed { index, charSequence -> charSequence.indexOf(positionToFind) to index }.first { it.first > -...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,890
adventOfCode
Apache License 2.0
src/Day08.kt
Akhunzaada
573,119,655
false
{"Kotlin": 23755}
fun main() { fun List<String>.parseInput(): List<List<Int>> { val grid = MutableList(size) { MutableList(first().length) { 0 } } forEachIndexed { i, row -> row.forEachIndexed { j, c -> grid[i][j] = c - '0' } } return grid } fun isTreeV...
0
Kotlin
0
0
b2754454080989d9579ab39782fd1d18552394f0
2,998
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day15.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day15 import aoc.utils.Cursor import aoc.utils.findInts import aoc.utils.readInput import java.math.BigInteger import kotlin.math.abs import kotlin.math.max data class Sensor(val location: Cursor, val beacon: Cursor) { val distance: Int = location.distance(beacon) fun covers(point: Cursor) = locatio...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
2,757
adventOfCode2022
Apache License 2.0
src/Day08.kt
ktrom
573,216,321
false
{"Kotlin": 19490, "Rich Text Format": 2301}
fun main() { fun part1(input: List<String>): Int { val trees: MutableList<MutableList<Tree>> = mutableListOf() input.forEachIndexed { y, it -> trees.add(it.toCharArray().mapIndexed { x, char -> Tree(char.code, x, y) }.toMutableList()) } return trees.map { row -> ...
0
Kotlin
0
0
6940ff5a3a04a29cfa927d0bbc093cd5df15cbcd
2,652
kotlin-advent-of-code
Apache License 2.0
src/Day08.kt
lassebe
573,423,378
false
{"Kotlin": 33148}
fun main() { fun transformInput(input: List<String>) = input.map { line -> val split = line.split("") split.subList(1, split.size - 1).map { it.toInt() } } fun part1(input: List<String>): Int { val heights = transformInput(input) return heights.indices.su...
0
Kotlin
0
0
c3157c2d66a098598a6b19fd3a2b18a6bae95f0c
2,763
advent_of_code_2022
Apache License 2.0
src/main/kotlin/Day16.kt
gijs-pennings
573,023,936
false
{"Kotlin": 20319}
import kotlin.math.max import kotlin.math.min private var dist: Array<IntArray> = emptyArray() fun main() { val lines = readInput(16) val n = lines.size val nameToIndex = lines.withIndex().associate { it.value.substring(6, 8) to it.index } val nodes = lines.mapIndexed { i, line -> Node(i, line.drop(23...
0
Kotlin
0
0
8ffbcae744b62e36150af7ea9115e351f10e71c1
2,731
aoc-2022
ISC License
src/Day07.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import kotlin.math.min private data class Node( val name: String, val size: Int, val parent: Node? = null, val children: MutableList<Node> = mutableListOf(), ) { val totalSize: Int by lazy { size + children.sumOf { it.totalSize } } fun isDir(): Boolean = children.isNotEmpty() } private fun su...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
2,524
advent-of-code-kotlin-2022
Apache License 2.0
src/y2023/d04/Day04.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2023.d04 import kotlin.math.pow import println import readInput fun main() { val classPath = "y2023/d04" fun score1(input: List<List<Int>>): Int { val winning = input[0] val nums = input[1] return nums .count { winning.contains(it) } .let { ...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
2,276
aoc
Apache License 2.0
src/main/kotlin/org/clechasseur/adventofcode2020/math/Math.kt
clechasseur
318,029,920
false
null
package org.clechasseur.adventofcode2017.math import kotlin.math.abs fun <T> permutations(elements: List<T>): Sequence<List<T>> { if (elements.size == 1) { return sequenceOf(listOf(elements.first())) } return elements.asSequence().flatMap { elem -> val subIt = permutations(elements - elem...
0
Kotlin
0
0
f3e8840700e4c71e59d34fb22850f152f4e6e739
1,951
adventofcode2020
MIT License
src/Day08.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
fun main() { fun part1(input: List<String>): Int { return input.flatMapIndexed { j, treeLine -> treeLine.mapIndexed { i, tree -> when { i == 0 || j == 0 || i == treeLine.length - 1 || j == input.size - 1 -> 1 treeLine.substring(0, i).max() ...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
1,729
advent-of-code-2022
Apache License 2.0
src/DayEight.kt
jrmacgill
573,065,109
false
{"Kotlin": 76362}
import java.lang.Integer.max fun testTree(i : Int, j : Int, data : Array<IntArray> ) : Int { val height = data[i][j] var result = false for (x in -1..1 ) { for (y in -1 .. 1) { if (x == 0 && y == 0) continue if (x != 0 && y != 0) continue result = result || tes...
0
Kotlin
0
1
3dcd590f971b6e9c064b444139d6442df034355b
1,944
aoc-2022-kotlin
Apache License 2.0
kotlin/src/Day15.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt import java.util.* fun main() { fun part1(input: List<String>): Int { val riskLevels = input.map { line -> line.map(Char::toString).map(::parseInt) } val totalRisks = Array(riskLevels.size) { Array(riskLevels[0].size) { 0 } } (riskLevel...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
3,703
aoc-2021
MIT License
src/Day13.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
fun main() { fun parseInput(testInput: String): List<Pair<String, String>> = testInput .split("\n\n") .map { val (left, right) = it.split("\n") left to right } fun arePacketsInOrder(pair: Pair<String, String>): Boolean { val (l...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
2,986
advent-of-code-2022
Apache License 2.0
src/main/kotlin/_2021/Day9.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2021 import REGEX_LINE_SEPARATOR import aoc fun main() { aoc(2021, 9) { aocRun { input -> val grid = parseGrid(input) val deepestDepths = findDeepestDepths(grid) return@aocRun deepestDepths.map { (x, y) -> grid[y][x] }.sumOf { it + 1 } } aocRun { input -> val grid = parseGrid(input) val...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
1,964
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/day4/Day4.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day4 import java.io.File class BingoBoard(private val numbers: List<List<Int>>) { private var visited = MutableList(numbers.size) { MutableList(numbers[0].size) { false } } fun visit(number: Int) { val traversingCellsIndices = visited.indices.flatMap { r -> visited[0].indices.map { c -> Pair(r, c) } ...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
2,697
advent-of-code-2021
MIT License
src/Day08.kt
AleksanderBrzozowski
574,061,559
false
null
import kotlin.math.max fun main() { fun part1() { val rows = readInput("Day08_test") val columnsSize = rows[0].length fun leftTress(rowIndex: Int, columnIndex: Int): List<Int> = (0 until columnIndex).map { rows[rowIndex][it].digitToInt() } fun rightTress(rowIndex: Int,...
0
Kotlin
0
0
161c36e3bccdcbee6291c8d8bacf860cd9a96bee
3,776
kotlin-advent-of-code-2022
Apache License 2.0
src/day16/Day16.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day16 import java.io.File import kotlin.math.max fun main() { val regexp = Regex("Valve (.*) has flow rate=(.*); tunnels? leads? to valves? (.*)") val valves = File("src/day16/input.txt").readLines() .map { regexp.matchEntire(it)!!.groupValues }.associate { values -> values[1] to V...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
3,243
advent-of-code-2022
MIT License
src/Day03.kt
toninau
729,811,683
false
{"Kotlin": 8423}
fun main() { data class FoundNumber(val id: Int, val number: Int) data class Point(val x: Int, val y: Int) fun findPointAdjacentNumbers( point: Point, schematic: List<List<Char>>, numbers: Map<Point, FoundNumber> ): Set<FoundNumber> { val lineLength = schematic[point.y]....
0
Kotlin
0
0
b3ce2cf2b4184beb2342dd62233b54351646722b
3,375
advent-of-code-2023
Apache License 2.0
src/Day04.kt
nielsz
573,185,386
false
{"Kotlin": 12807}
fun main() { fun part1(input: List<String>): Int { val result = input.map { val elves = it.split(",") val elf1 = elves[0].split("-").map { a -> a.toInt() } val elf2 = elves[1].split("-").map { a -> a.toInt() } val elf1range = IntRange(elf1[0], elf1[1]) ...
0
Kotlin
0
0
05aa7540a950191a8ee32482d1848674a82a0c71
1,440
advent-of-code-2022
Apache License 2.0
src/Day08.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
fun main() { fun visualTrees(trees: List<Tree>): Int { var currentHeight = -1 var visibleTrees = 0 for (tree in trees) { if (tree.treeHeight > currentHeight) { currentHeight = tree.treeHeight if (!tree.seen) { visibleTrees = vi...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
2,643
AdventOfCode2022
Apache License 2.0
src/Day08.kt
JohannesPtaszyk
573,129,811
false
{"Kotlin": 20483}
fun main() { fun String.toRow() = toList().map { it.digitToInt() } fun List<List<Int>>.getColumn(x: Int) = map { it[x] } fun part1(input: List<String>): Int { val heightMap = input.map { it.toRow() } return heightMap.mapIndexed { y, row -> row.mapIndexed { x, height -> ...
0
Kotlin
0
1
6f6209cacaf93230bfb55df5d91cf92305e8cd26
1,988
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day23.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* import kotlin.math.max import kotlin.math.min fun main() { val input = Input.day(23) println(day23A(input)) println(day23B(input)) } fun day23A(input: Input): Int { val map = XYMap(input) { if (it == '#') null else it } val options = mutableListOf(listOf(Point(1, 0))) var longe...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
3,526
AdventOfCode2023
MIT License
src/Day18.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution18(input: List<String>) { val coordinates = input.map { it.trim().split(",") }.map { Coordinate3D(it[0].toInt(), it[1].toInt(), it[2].toInt()) }.toSet() val steam = mutableSetOf<Coordinate3D>() val minX = coordinates.minOf { it.x - 1 } val maxX = coordinates.maxOf { it.x...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
2,531
aoc-2022
Apache License 2.0
src/Day18.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun List<String>.parse() = this .map { it.split(',').map { it.toInt() } } .map { (x, y, z) -> Triple(x, y, z) } fun part1(cubes: List<Triple<Int, Int, Int>>): Int { val visited = mutableSetOf<Triple<Int, Int, Int>>() fun scan(cube: Triple<Int, Int, Int>): Int { ...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
3,353
aockt
Apache License 2.0
src/day08/Day08.kt
skokovic
573,361,100
false
{"Kotlin": 12166}
package day08 import readInput fun createForest(input: List<String>): List<List<Int>> { return input .map { it.split("").filter { s -> s.isNotEmpty() }.map(String::toInt).toList() } .toList() } fun isVisible(forest: List<List<Int>>, i: Int, j: Int): Boolean { val elem = forest[i][j] retu...
0
Kotlin
0
0
fa9aee3b5dd09b06bfd5c232272682ede9263970
1,895
advent-of-code-2022
Apache License 2.0
aoc16/day_24/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 fun neighs(pos: Pos, map: List<CharArray>): List<Pos> = fourNeighs(pos).filter { p -> map[p.x][p.y] != '#' } fun allDsts(pois: Map<Char, Pos>, map: List<CharArray>): Map<String, Int> { val dsts = mutableMapOf<String...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,815
advent-of-code
MIT License
src/day08/Day08.kt
gillyobeast
574,413,213
false
{"Kotlin": 27372}
package day08 import utils.* import kotlin.math.max fun part1(input: List<String>): Int { return countVisible(matrixOf(input)) } private fun countVisible(matrix: Matrix<Int>): Int { var visible = 0 matrix.iterate { rowIndex, colIndex -> val (row, column, tree) = matrix[rowIndex, colIndex] ...
0
Kotlin
0
0
8cdbb20c1a544039b0e91101ec3ebd529c2b9062
2,730
aoc-2022-kotlin
Apache License 2.0
src/year2022/day12/Day12.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day12 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day12_test") check(part1(testInput), 31) check(part2(testInput), 29) val input = readInput("2022", "Day12") println(part1(i...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,887
AdventOfCode
Apache License 2.0
2023/src/main/kotlin/Day25.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day25 { fun part1(input: String): Int { val graph = parse(input) // Find the components with the shortest paths to every other node - those *must* be the nodes between the two groups val distances = graph.keys .map { component -> Distance(component, furthestComponent(component, graph)) } ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
3,259
advent-of-code
MIT License
src/year2022/day09/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day09 import java.util.function.Predicate import kotlin.math.abs import readInput fun main() { val day = "09" val expectedTest1 = 13 val expectedTest2 = 1 data class Point(val x: Int, val y: Int) { fun isNear(point: Point): Boolean = abs(x - point.x) <= 1 && abs(y - point.y)...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,851
adventOfCode
Apache License 2.0
src/Day12.kt
zirman
572,627,598
false
{"Kotlin": 89030}
data class Sqr(val rowIndex: Int, val colIndex: Int) fun main() { fun parseMap(input: List<String>): List<List<Int>> { return input.map { line -> line.map { c -> if (c == 'S') 0 else c - 'a' } } } fun search( map: List<List<Int>>, nex...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
4,172
aoc2022
Apache License 2.0
src/year_2023/day_04/Day04.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_04 import readInput data class ScratchCard( val cardNumber: Int, val winningNumbers: List<Int>, val myNumbers: List<Int> ) { val matchingNumbers: Set<Int> get() { return winningNumbers.intersect(myNumbers.toSet()) } val score: Int get() { var points = 0 ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,139
advent_of_code
Apache License 2.0
src/Day03.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
fun main() { fun prio(a: Char): Int { if (a in 'a'..'z') return a - 'a' + 1 if (a in 'A'..'Z') return a - 'A' + 27 return 0 } fun part1(input: List<String>): Int { return input.filter { return@filter it.isNotEmpty() }.sumOf { val firstHalf = it.slice(0 until it.le...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
2,002
aoc-2022
Apache License 2.0
src/Day08.kt
dcbertelsen
573,210,061
false
{"Kotlin": 29052}
import java.io.File fun main() { fun sightAlongAndMark(trees: List<Tree>) { var max = -1 trees.forEach { t -> if (t.height > max) { t.canSee(); max = t.height }} } fun getVisibleTrees(trees: List<Tree>): Int { var count = 0 var max = 0 for (tree in trees.subList(1, ...
0
Kotlin
0
0
9d22341bd031ffbfb82e7349c5684bc461b3c5f7
2,880
advent-of-code-2022-kotlin
Apache License 2.0
src/poyea/aoc/mmxxii/day07/Day07.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day07 import poyea.aoc.utils.readInput import kotlin.Int.Companion.MAX_VALUE import kotlin.math.min class Node(val path: String, var size: Int, val isDir: Boolean, val parent: Node?, val children: MutableSet<Node>) fun buildSize(node: Node?): Int { if (node == null) { return 0 ...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
3,495
aoc-mmxxii
MIT License
app/src/main/kotlin/day09/Day09.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day09 import common.InputRepo import common.colored import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 9 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay09Part1, ::solveDay09Part2) } private fun parseInput(inpu...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
2,638
AdventOfCode2021
Apache License 2.0
src/Day04.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
fun main() { fun overlapsComplete(s1List: List<Int>, s2List: List<Int>): Int { return if ((s1List.first() <= s2List.first() && s1List.last() >= s2List.last()) || (s2List.first() <= s1List.first() && s2List.last() >= s1List.last())) 1 else 0 } fun overlapsPartially(s1List: List<Int>...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
1,589
aoc-2022-in-kotlin
Apache License 2.0
src/year2022/day08/Solution.kt
LewsTherinTelescope
573,240,975
false
{"Kotlin": 33565}
package year2022.day08 import utils.runIt fun main() = runIt( testInput = """ 30373 25512 65332 33549 35390 """.trimIndent(), ::part1, testAnswerPart1 = 21, ::part2, testAnswerPart2 = 8, ) fun part1(input: String): Int { val treeHeights = input.toSingleDigitIntGrid() val rowCount = treeHeights.size...
0
Kotlin
0
0
ee18157a24765cb129f9fe3f2644994f61bb1365
1,957
advent-of-code-kotlin
Do What The F*ck You Want To Public License
src/year2022/day07/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day07 import readInput fun main() { fun getDirectorySize(input: List<String>): List<Pair<String, Int>> { val v = (input + listOf("$ cd \\")).asSequence().mapIndexedNotNull { index, s -> when { s.startsWith("$ cd") -> index to s.substring(...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,361
adventOfCode
Apache License 2.0
src/Day18.kt
dizney
572,581,781
false
{"Kotlin": 105380}
object Day18 { const val EXPECTED_PART1_CHECK_ANSWER = 64 const val EXPECTED_PART2_CHECK_ANSWER = 58 } fun main() { val air = mutableMapOf<Point3D, Boolean>() fun List<String>.parsePoints() = map { line -> val xyz = line.split(',') Point3D(xyz[0].toInt(), xyz[1].toInt()...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
2,673
aoc-2022-in-kotlin
Apache License 2.0
src/Day03.kt
geodavies
575,035,123
false
{"Kotlin": 13226}
fun String.splitInHalf(): Pair<String, String> { val numItems = length return substring(0 until numItems / 2) to substring(numItems / 2 until numItems) } fun Pair<String, String>.findDuplicate(): Char { val firstItems = first.toCharArray().toSet() return second.toCharArray().find { firstItems.contains(...
0
Kotlin
0
0
d04a336e412ba09a1cf368e2af537d1cf41a2060
1,754
advent-of-code-2022
Apache License 2.0
kotlin/src/Day12.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
fun main() { fun String.isLargeCave(): Boolean = get(0).isUpperCase() fun buildMap(input: List<String>): Map<String, List<String>> { val connections = mutableMapOf<String, MutableList<String>>() input.forEach { line -> val (start, end) = line.split("-") connections[star...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
2,858
aoc-2021
MIT License
src/main/kotlin/dev/tasso/adventofcode/_2021/day08/Day08.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day08 import dev.tasso.adventofcode.Solution class Day08 : Solution<Int> { override fun part1(input: List<String>): Int { return input.map { notesEntry -> notesEntry.split("|")[1].trim().split(" ")} .sumOf { it.count { listOf(2,3,4,7).contains(it.length) } ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
3,404
advent-of-code
MIT License
src/Day07.kt
touchman
574,559,057
false
{"Kotlin": 16512}
fun main() { val input = readInput("Day07") val hierarchy: Folder = createHierarchy(input) val allFolders = mutableMapOf<String, Long>() findAllFoldersWithFileSize(allFolders, hierarchy) addSizeOfSubFolders(allFolders) fun part1(allFolders: MutableMap<String, Long>): Long = allFolders.v...
0
Kotlin
0
0
4f7402063a4a7651884be77bb9e97828a31459a7
3,517
advent-of-code-2022
Apache License 2.0
src/Day18.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day18 import patriker.utils.* data class Pos3(val x: Int, val y: Int, val z: Int) val Pos3.adjacentPositions: List<Pos3> get() = listOf(Pos3(x - 1, y, z ), Pos3(x + 1, y, z ) , Pos3(x, y - 1, z ) , Pos3(x, y + 1, z ), Pos3(x, y, z - 1), Pos3(x, y , z + 1)) fun main() { // test if implementat...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
2,856
aoc2022
Apache License 2.0
src/main/kotlin/dec7/Main.kt
dladukedev
318,188,745
false
null
package dec7 data class Bag( val color: String, val count: Int ) data class BagRule( val color: String, val bagsInside: List<Bag> ) fun getBagRules(input: String): List<BagRule> { return input.lines() .filter { it.isNotEmpty() } .map { val color = it.split(" ").take(2)...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
2,120
advent-of-code-2020
MIT License
src/main/kotlin/days/Day5.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days class Day5 : Day(5) { override fun partOne(): Any { val almanac = inputString.split(Regex("\\r\\n\\r\\n")) val seeds = almanac[0].split(":")[1].split(" ").filterNot { it.isEmpty() }.map { it.toLong() } val mappers = almanac.drop(1) .mapIndexed { idx, mapper -> ...
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
3,116
AoC-2023
Creative Commons Zero v1.0 Universal
src/day05/Day05.kt
wickenico
573,158,084
false
{"Kotlin": 6839}
fun main() { fun part1(stacks: List<ArrayDeque<Char>>, steps: List<Step>): String { steps.map { step -> repeat(step.quantity) { stacks[step.target].addFirst(stacks[step.source].removeFirst()) } } return stacks.map { it.first() }.joinToString(separator = "") } fun part2(stacks: List<ArrayDeq...
0
Kotlin
0
0
bc587f433aa38c4d745c09d82b7d231462f777c8
1,596
advent-of-code-kotlin
Apache License 2.0
src/day12/Day12.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day12 import readInput fun Array<IntArray>.hasIndices(indices: Pair<Int, Int>) = indices.first >= 0 && indices.first < this.size && indices.second >= 0 && indices.second < this[indices.first].size fun Array<IntArray>.get(indices: Pair<Int, Int>) = this[indices.first][indices.second] fun Pair<Int, Int>.m...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
2,832
advent-of-code-2022
Apache License 2.0
src/Day15.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
data class Scanner(val center: Vector2, val beacon: Vector2) fun main() { val matcher = ".+?x=(?<x1>-?\\d+), y=(?<y1>-?\\d+).+x=(?<x2>-?\\d+), y=(?<y2>-?\\d+)".toRegex() fun parse(input: List<String>): List<Scanner> { val res = emptyList<Scanner>().toMutableList() for (line in input) { ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
2,980
aoc2022
Apache License 2.0
src/day07/Day07.kt
lpleo
572,702,403
false
{"Kotlin": 30960}
package day07 import TreeNode import readInput class FileSystemItem(val name: String, val type: Char, var dimension: Int) { fun isDirectory() = type == 'D' fun isFile() = type == 'F' } fun main() { fun calculateDimension(node: TreeNode<FileSystemItem>): Int { return node.getChildren().sumOf { ch...
0
Kotlin
0
0
115aba36c004bf1a759b695445451d8569178269
2,967
advent-of-code-2022
Apache License 2.0
src/Day11.kt
palex65
572,937,600
false
{"Kotlin": 68582}
private fun createOperation(txt: String): (Long) -> Long { val (a, op, b) = txt.substringAfter("new = ").split(' ') check(a=="old") val const = b.toIntOrNull() return when(op[0]){ '+' -> if (const==null) { old -> old + old } else { old -> old + const } '*' -> if (const==null) { old -> o...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
1,954
aoc2022
Apache License 2.0
src/year_2022/day_02/Day02.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_02 import readInput enum class Shape(val letters: List<Char>, private val pointValue: Int) { ROCK(listOf('A', 'X'), 1), PAPER(listOf('B', 'Y'), 2), SCISSORS(listOf('C', 'Z'),3), ; companion object { fun fromChar(letter: Char): Shape { return values().firs...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,189
advent_of_code
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day17.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput import java.util.* fun main() { val input = readInput(2023, 17).readLines() part1(input) part2(input) } private fun part1(grid: List<String>) = println(shortestExit(grid, 1, 3)) private fun part2(grid: List<S...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,105
adventofcode
Apache License 2.0
src/year_2023/day_15/Day15.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_15 import readInput object Day15 { /** * */ fun solutionOne(text: List<String>): Int { val values = parseInput(text).map { sequence -> var currValue = 0 sequence.forEach { char -> currValue += char.code currValue *...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,115
advent_of_code
Apache License 2.0
src/Day03.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
fun main() { fun part1(input: List<String>): Long { return input.mapIndexed { i, line -> var observed = "" var partNumber = false var sum = 0L line.forEachIndexed { j, char -> if (char.isDigit()) { observed += char ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,141
aoc-2022-in-kotlin
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day07.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val input = readInput(2023, 7).readLines() part1(input) part2(input) } private fun part1(input: List<String>) { val hands = input.map { Hand.of(it, withJoker = false) } solution(hands) } ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,048
adventofcode
Apache License 2.0
src/main/kotlin/challenges/Day03.kt
mledl
725,995,129
false
{"Kotlin": 66471}
package challenges class Day03(private val input: List<String>) { private val offset = input[0].length + 1 private val inputStr = input.fold("") { acc, s -> acc.plus("$s.") } private val regex = "\\d+".toRegex() fun getPart1(): Int = calcRanges(inputStr, offset, input.size).filter { pair -> pair.second...
0
Kotlin
0
0
7949d61d82d2b1a9b46cea386ae54d88b052606d
3,139
aoc23
Apache License 2.0
src/Day16.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
/* 1. parse into Node(name: String, flow: Int, edgesOne: List<Edge>, edgesAll: List<Edge>) where Edge(to: Node, hop: Int) and edgesOne is the directly connected graph with hop=1 each time 2. derive edgesAll, all possible (N * N) - N connections with the hops in that edge 3. walk every possible non-cyclic path to visi...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
4,097
aoc2022
Apache License 2.0
src/Day12.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
import java.util.* data class Coordinates(val x: Int, val y: Int) { val adjacent: List<Coordinates> by lazy { listOf(Coordinates(x - 1, y), Coordinates(x + 1, y), Coordinates(x, y - 1), Coordinates(x, y + 1)) } } enum class PlotType { START, END, OTHER; companion object { fun from(cha...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
3,072
advent-of-code-in-kotlin-2022
Apache License 2.0
2021/src/day15/Day15.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day15 import readInput import java.util.* typealias Table = Array<Array<Point>> data class Point(val value: Int, val minRisk: Int? = null) data class Visit(val x: Int, val y: Int, val currentRisk: Int) fun List<String>.toMultipliedTable(multiplyBy: Int = 5): Table { val table = Array(size * multiplyBy) ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,047
advent-of-code
Apache License 2.0
src/day10/Day10.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day10 import readInput import toPair fun main() { val testInput = parse(readInput("day10/test")) val input = parse(readInput("day10/input")) println("${solve1(testInput)} ${solve1gen(testInput)}") println("${solve1(input)} ${solve1gen(input)}") solve2(testInput).forEach { println(i...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
2,695
aoc-2022
Apache License 2.0
src/Day15.kt
eo
574,058,285
false
{"Kotlin": 45178}
import kotlin.math.abs // https://adventofcode.com/2022/day/15 fun main() { fun parseInput(input: List<String>): List<SensorBeaconPair> { val regex = "x=(-?\\d+), y=(-?\\d+)".toRegex() return input .flatMap { regex.findAll(it) } .map { Coordinate(it.groupValues[1].toInt(), i...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
4,685
aoc-2022-in-kotlin
Apache License 2.0
src/Day08.kt
leeturner
572,659,397
false
{"Kotlin": 13839}
typealias Grid = List<List<Int>> data class Coordinate(val row: Int, val col: Int) fun List<String>.parseGrid(): Grid { return this.map { line -> line.map { tree -> tree.digitToInt() } } } fun Grid.isEdge(coordinate: Coordinate): Boolean { return coordinate.row == 0 || coordinate.row == this.size - 1 || ...
0
Kotlin
0
0
8da94b6a0de98c984b2302b2565e696257fbb464
3,284
advent-of-code-2022
Apache License 2.0
src/Day08.kt
Shykial
572,927,053
false
{"Kotlin": 29698}
fun main() { fun part1(input: List<String>): Int { val mapped = input.mapInner(Char::digitToInt) return mapped.borderSize + mapped .subList(1, input.lastIndex) .sumOfIndexed { lineIndex, line -> line.subList(1, line.lastIndex).countIndexed { digitIndex, d -> ...
0
Kotlin
0
0
afa053c1753a58e2437f3fb019ad3532cb83b92e
1,865
advent-of-code-2022
Apache License 2.0
src/day07/Day07.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day07 import AdventDay import readInput enum class HandType { HIGH_CARD, ONE_PAIR, TWO_PAIR, THREE_OF_A_KIND, FULL_HOUSE, FOUR_OF_A_KIND, FIVE_OF_A_KIND } data class Hand(val cards: List<String>, val bet: Long) { fun getCardValue(card: String, isJoker: Boolean = false): Long { return whe...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
2,883
advent-of-code-2023-kotlin
Apache License 2.0
src/year2023/day19/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day19 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.readInputs import utils.runAlgorithm import utils.size fun main() { val (realInput, testInputs) = readInputs(2023, 19, transform = ::parse) runAlgorithm( realInput = realInput, testInputs = testInput...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
5,157
Advent-of-Code
Apache License 2.0
src/Day02.kt
palex65
572,937,600
false
{"Kotlin": 68582}
enum class Play(val first: Char, val part1Second: Char) { Rock('A','X'), Paper('B','Y'), Scissors('C','Z'); // More plays can be added, in order val score = ordinal+1 val winner get() = values()[(ordinal + 1) % values().size] val loser get() = values()[(ordinal - 1 + values().size) % values()...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
1,688
aoc2022
Apache License 2.0
2023/src/main/kotlin/day7.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.mapItems import utils.pow import utils.withCounts fun main() { Day7.run() } object Day7 : Solution<List<Day7.Hand>>() { override val name = "day7" override val parser = Parser.lines.mapItems { parseHand(it) } @Parse("{cards} {bid}") ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,847
aoc_kotlin
MIT License
src/Day16b.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
import kotlin.math.abs import kotlin.math.max fun main() { println(Day16b().solve2().toString()) } class Day16b() { private val parsed = readInput("day16_input").map { Valve.from(it) } private val valves = parsed.associateBy { it.id } private val shortestPaths = floydWarshall(parsed.associ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
2,844
advent22
Apache License 2.0
2022/src/day08/day08.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day08 import GREEN import RESET import printTimeMillis import readInput import kotlin.math.max fun isTreeVisible(input: List<String>, posY: Int, posX: Int) : Boolean { val left = input[posY].take(posX).reversed().all { it < input[posY][posX] } val right = input[posY].drop(posX + 1).all { it < input[po...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,543
advent-of-code
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/day07/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day07 import com.bloidonia.aoc2023.lines import java.lang.Math.pow private const val example = """32T3K 765 T55J5 684 KK677 28 KTJJT 220 QQQJA 483""" private val part1CardOrder = listOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A") private val part2CardOrder = li...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
2,414
aoc-2023
MIT License
src/Day02.kt
martintomac
726,272,603
false
{"Kotlin": 19489}
import Game.ColorCubes private val colors = setOf("red", "green", "blue") private val lineFormat = "Game (\\d+): (.+)".toRegex() private fun parseGame(line: String): Game { fun String.extractNumAndColor(): ColorCubes { val (numStr, color) = split(" ") return ColorCubes(numStr.toInt(), color) ...
0
Kotlin
0
0
dc97b23f8461ceb9eb5a53d33986fb1e26469964
2,233
advent-of-code-2023
Apache License 2.0