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
day-08/src/main/kotlin/SevenSegmentSearch.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private const val DELIMITER = " | " private const val SPACE = " " private fun partOne(): Int { return readInputLines() .flatMap { it.split(DELIMITER)[1].split(SPACE) } ...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
2,991
aoc-2021
MIT License
src/Day04.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
fun main() { fun part1(input: List<String>): Int { return input .map { val split = it.trim().split(",") Pair(split.get(0).toRange(), split.get(1).toRange()) .inEachOther() }.count { it } } fun part2(input: List<String>): I...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
1,530
Kotlin-AoC-2022
Apache License 2.0
src/Day08.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Int { val trees = input.map { line -> line.split("").filter(String::isNotBlank).map(String::toInt) } val visibleTrees = mutableListOf<Int>() for (y in trees.indices) { val row = trees[y] for (x in row.indices) { ...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
2,121
aoc-2022
Apache License 2.0
src/Day15.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { fun IntRange.intersects(other: IntRange) = (first <= other.first && last in other.first..other.last) || (last <= other.last && first in other.last..other.first) || (first <= other.first && last >= other.last) ...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
3,888
aoc-2022
Apache License 2.0
src/com/ncorti/aoc2023/Day23.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 fun main() { fun parseInput(): Array<CharArray> { return getInputAsText("23") { split("\n").filter(String::isNotBlank).map { it.toCharArray() } }.toTypedArray() } val neighbours = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1) fun computeMaxPath(map: ...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
4,825
adventofcode-2023
MIT License
src/Day03.kt
martintomac
726,272,603
false
{"Kotlin": 19489}
fun main() { fun extractSymbols(line: String) = "([^0-9.])".toRegex() .findAll(line) .map { match -> match.value to match.range.first } .toList() fun extractNumbers(line: String) = "(\\d+)".toRegex().findAll(line) .map { match -> match.value.toInt() to match.range } .to...
0
Kotlin
0
0
dc97b23f8461ceb9eb5a53d33986fb1e26469964
2,638
advent-of-code-2023
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day08/Day08.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.day08 import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource data class Entry(val pattern: List<String>, val values: List<String>) fun main() { val input = readResource("Day08.txt").lines().map { line -> ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,098
advent-of-code
MIT License
src/Day08.kt
romainbsl
572,718,344
false
{"Kotlin": 17019}
fun main() { fun initForest(input: List<String>): Forest { val width = input.first().count() val height = input.count() val grid = input.foldIndexed(Array(height) { Tree.emptyArray(width) }) { rowId, forest, row -> forest.apply { this[rowId] = row.foldIndexed(Tr...
0
Kotlin
0
0
b72036968769fc67c222a66b97a11abfd610f6ce
3,282
advent-of-code-kotlin-2022
Apache License 2.0
y2022/src/main/kotlin/adventofcode/y2022/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day16 : AdventSolution(2022, 16, "Proboscidea Volcanium") { override fun solvePartOne(input: String): Int { val valves = parse(input) val interestingValves = valves.filter { it.rate > 0 || it.name == "AA" }.associate { it.na...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
4,470
advent-of-code
MIT License
src/Day08.kt
palex65
572,937,600
false
{"Kotlin": 68582}
fun <R> List<String>.mapEachCharIndexed(transform: (row: Int, col: Int, char: Char)->R ): List<R> { val res = mutableListOf<R>() for(row in indices) { val line = get(row) for (col in line.indices) res.add(transform(row, col, line[col])) } return res } private fun part1(grid...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
1,930
aoc2022
Apache License 2.0
src/Day08.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
fun main() { fun forest(input: List<String>) = input.map { r -> r.map { it.digitToInt() } } fun trees(forest: List<List<Int>>) = forest.flatMapIndexed { y, r -> r.mapIndexed { x, h -> Triple(x, y, h) } } // the 4 top-level sequences the 4 directions we can travel (left, right, up, down), the inner sequence...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
1,659
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-05.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText import kotlin.math.max import kotlin.math.min fun main() { val input1 = readInputText(2023, "05-input") val test1 = readInputText(2023, "05-test1") print...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,252
advent-of-code
MIT License
src/year2021/day13/Day13.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day13 import util.assertTrue import util.model.Counter import util.read2021DayInput import java.awt.Point fun main() { fun task1(input: List<String>): Int { val foldInstructions = input.filter { it.contains("fold along") } val board = foldRecursively(Cave(input).board, fold...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
2,887
advent-of-code-kotlin-template
Apache License 2.0
src/Day15.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import kotlin.math.abs import kotlin.math.max fun main() { fun manhattanDistance(a: Pair<Long, Long>, b: Pair<Long, Long>): Long { return abs(a.first - b.first) + abs(a.second - b.second) } class Station(val pos: Pair<Long, Long>, val closestRadio: Pair<Long, Long>) { val distance = manhatt...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
3,089
aoc-2022
Apache License 2.0
src/year2023/day25/Day25.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day25 import check import readInput import util.aStar fun main() { val testInput = readInput("2023", "Day25_test") check(part1(testInput), 54) val input = readInput("2023", "Day25") part1(input) } private fun part1(input: List<String>): Int { val graph = input.parseGraph() v...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,249
AdventOfCode
Apache License 2.0
2015/15/kotlin/a.kt
shrivatsas
583,681,989
false
{"Kotlin": 17998, "Python": 9402, "Racket": 4669, "Clojure": 2953}
import java.io.File import kotlin.math.max data class Ingredient(val name: String, val capacity: Int, val durability: Int, val flavor: Int, val texture: Int, val calories: Int) fun main() { val lines: List<String> = File("../15.input").useLines { it.toList() } // Sugar: capacity 3, durability 0, flavor 0, textu...
0
Kotlin
0
1
529a72ff55f1d90af97f8e83b6c93a05afccb44c
2,538
AoC
MIT License
src/Day15.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
import kotlin.math.abs private fun parseInput(name: String) = readInput(name).map { line -> line.split(":").map { it.getAllInts().pair() } }.map { (sensorXY, beaconXY) -> Sensor(sensorXY, beaconXY) } fun main() { fun Position.tuningFrequency() = 4000000L * x + y fun coverageRangesForY(y: Int,...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
2,504
advent-of-code
Apache License 2.0
src/Day03.kt
AlexeyVD
575,495,640
false
{"Kotlin": 11056}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { getPrioritiesSum(it) } } fun part2(input: List<String>): Int { return input.chunked(3).sumOf { getBadgeItemPriority(it) } } initPriorities() val testInput = readInput("Day03_test") check(part1(testInpu...
0
Kotlin
0
0
ec217d9771baaef76fa75c4ce7cbb67c728014c0
1,704
advent-kotlin
Apache License 2.0
src/Day08.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { fun part1(input: List<String>): Int { val forestHeights = input.map { it.map { tree -> tree.digitToInt() } } return forestHeights.withIndex().drop(1).dropLast(1).sumOf { (row, rowTreesHeights) -> rowTreesHeights.withIndex().drop(1).dropLast(1).count { (column, treeHeight) ->...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
2,067
advent-of-code-kotlin-2022
Apache License 2.0
src/day08/Day08.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day08 import readInput import readTestInput private data class Tree( val x: Int, val y: Int, val height: Int, ) private fun List<String>.parse(): List<List<Tree>> { return this.mapIndexed { y, row -> row.mapIndexed { x, cell -> Tree(x = x, y = y, height = cell.digitToInt()...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
2,632
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>): Int { val (start, end, map) = parse(input) return findShortest(start, end, map, heuristic = Point2D::manhattanDist)!!.size - 1 } fun part2(input: List<String>): Int { val grid = input.map { it.toCharArray() }.toTypedArray() val en...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
2,125
advent-of-code-2022
Apache License 2.0
src/main/kotlin/y2023/Day7.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day class Day7 : Day(7, 2023, false) { override fun partOne(): Any { return inputList .map { val (hand, bid) = it.split(" ") hand to bid }.sortedWith(RegularCardComparator()) .mapIndexed { index, (_, bid) -> (in...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
3,440
adventofcode
MIT License
2k23/aoc2k23/src/main/kotlin/22.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 d22 import input.read import kotlin.math.max import kotlin.math.min fun main() { println("Part 1: ${part1(read("22.txt"))}") println("Part 2: ${part2(read("22.txt"))}") } fun part1(input: List<String>): Int { val bricks = input.map { Brick(it) }.toMutableList() val (supports, supportedBy) = ...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
2,868
aoc
The Unlicense
src/Day15.kt
anisch
573,147,806
false
{"Kotlin": 38951}
import kotlin.math.abs private fun getPositions(input: List<String>) = input .map { line -> val (s, b) = line.split(": ") val (xs, ys) = s.removeRange(0..9).split(",") val (xb, yb) = b.removeRange(0..20).split(",") val vecS = Vec( xs.substringAfter("=").toInt(), ...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
2,883
Advent-of-Code-2022
Apache License 2.0
src/day14/Day14.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day14 import println import readInput fun String.parseInput() = readInput(this).let { lines -> Pair( lines[0], lines.slice(2 until lines.size).associate { line -> line.split(" -> ").let { Pair(it[0], it[1]) } } ) } fun Map<String, String>.step(initial: String):...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
2,127
advent-of-code-2021
Apache License 2.0
src/day08/Day08.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day08 import utils.* data class Tree(val height: Int, var score: Int = 0) fun readMap(input: List<String>): List<List<Tree>> = input.map { line -> line.map { c -> Tree(c.digitToInt()) } } fun <T> getClockwiseRotation(mtx: List<List<T>>): List<List<T>> = mtx[0].indices...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
2,093
AOC-2022-Kotlin
Apache License 2.0
src/day15/d15_1.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val ingredients = input.lines().map { parseIngredient(it) }.associateBy { it.name } println(forAllCombinations(ingredients, 100) { it.map { (k, v) -> listOf( ingredients[k]!!.capacity * v, ingredients[k]!!.durability * v, ingredients[k]!!.flavor * v, ingred...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,836
aoc2015
MIT License
src/Day15.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
import kotlin.math.abs private val LINE_REGEX = "Sensor\\s+at\\s+x=(?<sensorX>-?\\d+),\\s+y=(?<sensorY>-?\\d+):\\s+closest\\s+beacon\\s+is\\s+at\\s+x=(?<beaconX>-?\\d+),\\s+y=(?<beaconY>-?\\d+)".toRegex() private const val TUNING_FACTOR_X = 4000000L data class Sensor( val position: Pair<Int, Int>, val closest...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
4,269
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/main/kotlin/Day8.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
fun puzzleDayEightPartOne() { val inputs = readInput(8) val structured = structureInputs(inputs) val count = structured.countOneFourSevenEight() println("Count of 1,4,7,8 -> $count") } fun puzzleDayEightPartTwo() { val inputs = readInput(8) val structured = structureInputs(inputs) val sum =...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
2,397
advent-of-kotlin-2021
Apache License 2.0
src/Day15.kt
paulgrugnale
573,105,050
false
{"Kotlin": 6378}
import Position.Companion.manhattanDistance import java.lang.Integer.max import java.lang.Integer.min import kotlin.math.abs fun main() { fun positionsWithoutBeaconForRow(input: List<Position>, row: Int): List<IntRange> { val sensorsAffectingRow = input.filter { abs(it.sensorY - row) <= it.manh...
0
Kotlin
0
0
e62edc817a8b75e401d6c8a0a66243d009c31fbd
3,733
advent2022
Apache License 2.0
src/y2022/Day08.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.getCol import util.getRow import util.readInput import util.split object Day08 { fun part1(input: List<String>): Int { val heightGrid = input.mapIndexed { rowIdx, row -> row.mapIndexed { colIdx, h -> Tree(h, rowIdx, colIdx) } } return heightGrid ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,327
advent-of-code
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day09/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day09 import com.kingsleyadio.adventofcode.util.readInput fun part1(input: List<List<Int>>): Int { var result = 0 for (i in input.indices) { val inner = input[i] for (j in inner.indices) { val current = inner[j] val adjacents ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,010
adventofcode
Apache License 2.0
src/Day11.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun List<String>.parseMonkeys() = map { section -> val lines = section.split('\n') val index = lines[0].split(' ')[1].dropLast(1).toInt() val items = lines[1].trim().split(' ').drop(2).map { it.removeSuffix(",").toLong() }.toMutableList() val condition: (Long) -> Long =...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
2,721
advent-of-code-2022
Apache License 2.0
src/Day09.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
fun main() { fun parse(input: List<String>) = input.map { it.toCharArray().map { c -> c.toString().toInt() } } fun isLowPoint(map: List<List<Int>>, y: Int, x: Int): Boolean { val value = map[y][x] if (y > 0 && map[y - 1][x] <= value) return false if (y < map.lastIndex && map[y ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
2,408
AdventOfCode2021
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day19.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day19.solve() } object Day19 : AdventSolution(2023, 19, "Aplenty") { override fun solvePartOne(input: String): Int { val (workflows, parts) = parse(input) val flows = workflows.associateBy { it.name } ret...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
5,029
advent-of-code
MIT License
src/Day08.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
fun main() { fun part1(trees: List<List<Int>>): Int { return trees.indices .flatMap { y -> trees.first().indices .map { x -> trees.isVisible(x, y) } }.count { it } } fun part2(trees: List<List<Int>>): Int { return trees.indices ...
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
1,782
adventofcode-2022
Apache License 2.0
app/src/main/kotlin/day09/Day09.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day09 import common.InputRepo 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) } fun solveDay09Part1(input: List<String>): Int { ...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
2,881
advent-of-code-kt
Apache License 2.0
src/Day12.kt
dmstocking
575,012,721
false
{"Kotlin": 40350}
// Cheat the package to get true isolation between source files package day12 import readInput import java.util.PriorityQueue import kotlin.math.abs data class Position(val x: Int, val y: Int) { var cost = 0 fun up(): Position = copy(y = y - 1) fun down(): Position = copy(y = y + 1) fun right(): Pos...
0
Kotlin
0
0
e49d9247340037e4e70f55b0c201b3a39edd0a0f
3,528
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/advent/y2018/day6.kt
IgorPerikov
134,053,571
false
{"Kotlin": 29606}
package advent.y2018 import misc.readAdventInput fun main(args: Array<String>) { val points = parsePoints() println(getSizeOfBiggestLimitedArea(points)) println(getSizeOfSafeRegion(points)) } private fun getSizeOfSafeRegion(points: Set<Point>): Int { var result = 0 val maxX = points.map { it.x }...
0
Kotlin
0
0
b30cf179f7b7ae534ee55d432b13859b77bbc4b7
2,916
kotlin-solutions
MIT License
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day11.kt
JamJaws
725,792,497
false
{"Kotlin": 30656}
package com.jamjaws.adventofcode.xxiii.day import com.jamjaws.adventofcode.xxiii.readInput import kotlin.math.abs class Day11 { fun part1(text: List<String>): Long { val expandingRows = text.getExpansionRowIndexes() val expandingColumns = text.transpose().getExpansionRowIndexes() val gal...
0
Kotlin
0
0
e2683305d762e3d96500d7268e617891fa397e9b
2,575
advent-of-code-2023
MIT License
src/y2023/Day22.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.timingStatistics object Day22 { data class Brick( val xRange: IntRange, val yRange: IntRange, val zRange: IntRange ) { fun xyOverlap(other: Brick): Boolean { return xRange.intersects(other.xRange) && yRange.intersects(...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
4,004
advent-of-code
Apache License 2.0
src/Day02.kt
djleeds
572,720,298
false
{"Kotlin": 43505}
private enum class Outcome(val score: Int) { WIN(6), DRAW(3), LOSE(0); fun inverted(): Outcome = when (this) { WIN -> LOSE; DRAW -> DRAW; LOSE -> WIN } } private sealed class Shape(val score: Int) { object Rock : Shape(1) object Paper : Shape(2) object Scissors : Shape(3) fun eval...
0
Kotlin
0
4
98946a517c5ab8cbb337439565f9eb35e0ce1c72
2,792
advent-of-code-in-kotlin-2022
Apache License 2.0
src/Day07.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
object Day07 { data class File(val name: String, val size: Int) class Directory(val name: String, val parent: Directory?) { var dirs: List<Directory> = listOf() var files: List<File> = listOf() val size: Int by lazy { files.sumOf { it.size } + dirs.sumOf { it.size } ...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
2,993
aoc22-kt
Apache License 2.0
src/main/kotlin/adventofcode2023/day2/day2.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day2 import adventofcode2023.readInput import kotlin.math.max fun main() { val input = readInput("day2.txt") println("Day 2") println("Puzzle 1: ${puzzle1(input, GameRecord(red = 12, green = 13, blue = 14))}") println("Puzzle 2: ${puzzle2(input)}") } data class GameRecord( ...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
1,871
adventofcode2023
MIT License
src/Day08.kt
kthun
572,871,866
false
{"Kotlin": 17958}
enum class Direction { NORTH, SOUTH, EAST, WEST } fun main() { fun part1(input: List<String>): Int { val trees = input.map { line -> line.toCharArray().map { it.toString().toInt() } } val height = trees.size val width = trees[0].size val numVisibleTrees = trees.mapIndexed { ro...
0
Kotlin
0
0
5452702e4e20ef2db3adc8112427c0229ebd1c29
3,605
aoc-2022
Apache License 2.0
src/year2021/day14/Day14.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day14 import util.assertTrue import util.model.Counter import util.read2021DayInput fun main() { fun task1(input: List<String>) = findOptimalPolymer(input, 10) fun task2(input: List<String>) = findOptimalPolymer(input, 40) val input = read2021DayInput("Day14") assertTrue(task1(input...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
2,106
advent-of-code-kotlin-template
Apache License 2.0
src/Day02.kt
WaatzeG
573,594,703
false
{"Kotlin": 7476}
fun main() { val testInput = readInput("Day02_input") val solutionPart1 = part1(testInput) println("Solution part 1: $solutionPart1") val solutionPart2 = part2(testInput) println("Solution part 2: $solutionPart2") } /** * Total score strategy 1 */ private fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
324a98c51580b86121b6962651f1ba9eaad8f468
3,219
advent_of_code_2022_kotlin
Apache License 2.0
src/Day15.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
import kotlin.math.abs import kotlin.math.sign fun main() { fun List<IntRange>.union(): List<IntRange> { val sorted = sortedBy { it.first } val init = mutableListOf(sorted.first()) return sortedBy { it.first }.fold(init) { acc, r -> val last = acc.last() if (r.fir...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
3,008
aoc-2022
Apache License 2.0
src/Day08.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution08(input: List<String>) { val trees = input.map { it.toCharArray() } val coords = trees.indices.cartesianProduct(trees[0].indices) val maxX = trees[0].indices.max() val maxY = trees.indices.max() fun getTree(c: Coordinate) = trees[c.y][c.x] fun getTreesAbove(c: Coordinat...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
1,880
aoc-2022
Apache License 2.0
src/Day08.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
fun main() { fun part1(input: List<String>): Int { val grid = input.map { line -> line.map { it.digitToInt() } } var visible = 0 grid.forEachIndexed { y, row -> // Add all trees in first or last row if (y == 0 || y == grid.lastIndex) { visible += row...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
2,180
aoc-2022-kotlin
Apache License 2.0
src/com/ncorti/aoc2023/Day07.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 class CardComparator(val withJoker: Boolean) : Comparator<Pair<String, Int>> { private val cardRank = arrayOf('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') private val cardRankWithJoker = arrayOf('J', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'Q', 'K', 'A') ...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
3,011
adventofcode-2023
MIT License
src/Day12.kt
arhor
572,349,244
false
{"Kotlin": 36845}
import java.util.* fun main() { val input = readInput {} val yIndicies = 0..input.lastIndex val xIndicies = 0..input.first().lastIndex fun validNeighbours(curr: Point, next: Point): Boolean { if (next.x in xIndicies && next.y in yIndicies) { val currHeight = determineHeight(input[...
0
Kotlin
0
0
047d4bdac687fd6719796eb69eab2dd8ebb5ba2f
2,231
aoc-2022-in-kotlin
Apache License 2.0
src/main/Day08.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day08 import geometry.Direction import geometry.Direction.* import utils.readInput import kotlin.math.max typealias Grid = List<String> data class Tree(val height: Int) { operator fun compareTo(tree: Tree): Int = height.compareTo(tree.height) } fun Grid.tree(row: Int, column: Int) = get(row)[column].toS...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
2,502
aoc-2022
Apache License 2.0
src/Day02.kt
TheOnlyTails
573,028,916
false
{"Kotlin": 9156}
private enum class RockPaperScissors(val play: Char, val response: Char, val score: Int) { Rock('A', 'X', 1), Paper('B', 'Y', 2), Scissors('C', 'Z', 3); companion object { val winners = mapOf( Rock to Paper, Paper to Scissors, Scissors to Rock, ) ...
0
Kotlin
0
0
685ce47586b6d5cea30dc92f4a8e55e688005d7c
2,342
advent-of-code-2022
Apache License 2.0
advent-of-code-2023/src/Day03.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private typealias EngineSchematic = List<CharArray> private const val DAY = "Day03" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) shouldBe 4361 measureAnswer { part1(input()) } } "Part 2" { part2(testInp...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,314
advent-of-code
Apache License 2.0
src/day08/Day08.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day08 import readLines typealias Forest = List<List<Int>> fun main() { val id = "08" val testOutputPart1 = 21 val testOutputPart2 = 8 val testInput = readTreeHeightMap("day$id/Day${id}_test") println("--- Part 1 ---") println(part1(testInput)) check(part1(testInput) == testOutp...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
2,718
advent-of-code-2022
Apache License 2.0
src/poyea/aoc/mmxxii/day23/Day23.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day23 import poyea.aoc.utils.readInput data class Point(val x: Int, val y: Int) { operator fun plus(other: Point) = Point(x + other.x, y + other.y) } enum class Direction(val neighbours: (Point) -> Set<Point>, val destination: (Point) -> Point) { EAST( neighbours = { (x, y) -...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
3,165
aoc-mmxxii
MIT License
y2017/src/main/kotlin/adventofcode/y2017/Day07.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution object Day07 : AdventSolution(2017, 7, "Recursive Circus") { override fun solvePartOne(input: String): String { return findRootProgram(parse(input)).name } override fun solvePartTwo(input: String): String { val rows = parse(input) val root = ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,399
advent-of-code
MIT License
src/Day13.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.min class WeirdLists(private val intValue: Int? = null) : Comparable<WeirdLists> { constructor(list: List<WeirdLists>): this(null) { container = list as MutableList<WeirdLists> } var container: MutableList<WeirdLists> = mutableListOf() override fun compareTo(other: WeirdLists...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
3,392
advent-of-kotlin-2022
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day07.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import java.util.Arrays import java.util.Collections fun main() { Day07.solve() } object Day07 : AdventSolution(2023, 7, "Camel Cards") { override fun solvePartOne(input: String): Long { val hands = input.lines().map { val ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,531
advent-of-code
MIT License
src/main/kotlin/aoc2020/ex7.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
fun main() { val input = readInputFile("aoc2020/input7") //println(input.lines()[0]) val rawRequirements = input.lines().map { parseLine(it) } val (colorMap, requirements) = createColorMap(rawRequirements) part1(colorMap, requirements) part2(colorMap, requirements) } private fun part2(colorMap:...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
4,614
AOC-2021
MIT License
src/day03/Day03.kt
gagandeep-io
573,585,563
false
{"Kotlin": 9775}
package day03 import readInput fun main() { fun Char.priority(): Int = when (this) { in 'a'..'z' -> { (this - 'a') + 1 } in 'A'..'Z' -> { (this - 'A') + 27 } else -> { 0 } } fun part1(input: List<String>): Int = input.s...
0
Kotlin
0
0
952887dd94ccc81c6a8763abade862e2d73ef924
1,770
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day02.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import multiplyOf import readInput import java.util.* import kotlin.math.min private enum class Color { RED, GREEN, BLUE } private data class Cube(val amount: Int, val color: Color) private data class Round(val cubes: Set<Cube>) private data class Game(val id: Int, val rounds: List<Round>) { co...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,453
adventOfCode
Apache License 2.0
2022/src/main/kotlin/day24.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.Parser import utils.Solution import utils.Vec2i import utils.badInput import utils.mapParser fun main() { Day24.run() } object Day24 : Solution<Pair<Day24.Context, List<Day24.Blizzard>>>() { override val name = "day24" override val parser = Parser { it.trim() }.mapParser(Parser.c...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,902
aoc_kotlin
MIT License
advent-of-code-2022/src/Day16.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import kotlin.math.abs fun main() { val testInput = readInput("Day16_test") val input = readInput("Day16") "Part 1" { part1(testInput) shouldBe 1651 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 1707 measureAnswer { part2(input) } } } p...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
3,207
advent-of-code
Apache License 2.0
src/day08/Day08.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day08 import readInput fun main() { fun part1(input: List<String>): Int { val intInput = input.map { row -> row.map { it.toString().toInt() } } val forest = createForest(intInput) return forest.flatten().count { it.visible() } } fun part2(input: List<String>): Int { ...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
2,029
advent-of-code-22
Apache License 2.0
src/Day15.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
import java.awt.Point import kotlin.math.abs fun main() { data class Sensor(val pos: Point, val beacon: Point) { val xDistance = abs(beacon.x - pos.x) val yDistance = abs(beacon.y - pos.y) fun abscessesCoveredAt(y: Int): Set<Int> { val evaluationYDistance = abs(y - pos.y) ...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
3,054
advent_of_code_2022
Apache License 2.0
src/Day16.kt
felldo
572,233,925
false
{"Kotlin": 76496}
private fun dijkstra(grid: Map<String, Pair<Int, List<String>>>, from: String): Map<String, Int> { val distances = grid.asSequence().map { it.key to Int.MAX_VALUE }.toMap().toMutableMap() val used = mutableSetOf<String>() distances[from] = 0 for (iteration in 0 until grid.size) { val v = dista...
0
Kotlin
0
0
0ef7ac4f160f484106b19632cd87ee7594cf3d38
2,482
advent-of-code-kotlin-2022
Apache License 2.0
src/day16/a/day16a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day16.a import readInputLines import shouldBe import util.Graph import java.util.regex.Pattern import kotlin.math.max fun main() { val graph = simplifyGraph(read()) var best = 0 fun step(v: Valve, t: Int, sum: Int) { for (vtx in graph[v.key]!!.connected) { val len = vtx.distan...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,712
advent-of-code-2022
Apache License 2.0
src/Day08.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
fun main() { fun isVisible(row: Int, col: Int, height: Int, forest: List<String>): Boolean = when { // Outter trees are always visible (col == 0 || col == forest[row].lastIndex || row == 0 || row == forest.lastIndex) -> true // Visible from Left forest[row].subSequence(0 until col)....
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
2,531
aoc-2022-demo
Apache License 2.0
src/year2021/Day14.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readLines fun main() { val input = parseInput(readLines("2021", "day14").filter { it != "" }) val testInput = parseInput(readLines("2021", "day14_test").filter { it != "" }) check(part1(testInput) == 1588L) println("Part 1:" + part1(input)) check(part2(testInput) == 21881...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
2,102
advent_of_code
MIT License
src/day18/Day18.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day18 import utils.* val NEIGHBOR_OFFSETS = listOf( Voxel(1, 0, 0), Voxel(0, 1, 0), Voxel(0, 0, 1), Voxel(-1, 0, 0), Voxel(0, -1, 0), Voxel(0, 0, -1) ) data class Voxel(val x: Int, val y: Int, val z: Int) { val neighbors get() = NEIGHBOR_OFFSETS.map { dir -> this + dir } ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
2,646
AOC-2022-Kotlin
Apache License 2.0
src/Day08.kt
slawa4s
573,050,411
false
{"Kotlin": 20679}
fun main() { fun getColumn(matrix: List<List<Int>>, col: Int) = List(matrix.size) { matrix[it][col] } fun getRow(matrix: List<List<Int>>, row: Int) = matrix[row] fun isVisible(treeGrid: List<List<Int>>, i: Int, j: Int): Boolean { val element = treeGrid[i][j] return i == 0 || j == 0 || i ==...
0
Kotlin
0
0
cd8bbbb3a710dc542c2832959a6a03a0d2516866
2,092
aoc-2022-in-kotlin
Apache License 2.0
src/Day15.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
import kotlin.math.abs import kotlin.math.max /** * [Day15](https://adventofcode.com/2022/day/15) */ private class Day15 { data class Point(val x: Int, val y: Int) } fun main() { fun toDetects(input: List<String>): List<Pair<Day15.Point, Day15.Point>> = input.map { line -> """Sensor at x=(-?\d+), y...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
3,344
aoc-in-kotlin-2022
Apache License 2.0
src/Day13.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
interface Packets {} class PacketList(val packets: List<Packets>): Packets {} class PacketItem(val packets: Int) : Packets {} fun compare(p1: Packets, p2: Packets): Int { return when { p1 is PacketItem && p2 is PacketItem -> (p1.packets.compareTo(p2.packets)) p1 is PacketList && p2 is PacketList ->...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
2,464
advent-of-code-kotlin-2022
Apache License 2.0
src/Day08.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
fun main() { fun toRightFrom(input: List<String>, i: Int, j: Int) = (j + 1 until input[0].length).map { input[i][it] } fun toLeftFrom(input: List<String>, i: Int, j: Int) = (j - 1 downTo 0).map { input[i][it] } fun toDownFrom(input: List<String>, i: Int, j: Int) = (i + 1 until input.size).map { input[it][j]...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
1,778
advent-of-kotlin-2022
Apache License 2.0
src/Day16.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
data class Day16Valve(val name: String, val rate: Int, val connections: List<String>) { val distanceMap = mutableMapOf<String, Int>() fun computeDistances(nodes: List<Day16Valve>) = apply { distanceMap[name] = 0 ArrayDeque<Day16Valve>().let { queue -> queue.add(this) va...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
3,672
aoc-2022-demo
Apache License 2.0
src/main/kotlin/Day07.kt
alex859
573,174,372
false
{"Kotlin": 80552}
fun main() { val testInput = readInput("Day07_test.txt") check(testInput.result() == 95437) check(testInput.result2() == 24933642) val input = readInput("Day07.txt") println(input.result()) println(input.result2()) } fun String.result(): Int { return readCommandsAsStrings().directories().s...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
3,212
advent-of-code-kotlin-2022
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day12.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import kotlin.math.absoluteValue import kotlin.math.sign fun main() = Day12.solve() object Day12 : AdventSolution(2019, 12, "The N-body problem") { override fun solvePartOne(input: String): Int { val moons = parse(input).map { Moon(it, Vec...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,293
advent-of-code
MIT License
src/day12/Day12ToddGinsbergSolution.kt
commanderpepper
574,647,779
false
{"Kotlin": 44999}
package day12 import readInput import java.util.* fun main(){ val dayTwelveInput = readInput("day12") val heightMap = parseInput(dayTwelveInput) heightMap.elevations.forEach(::println) val shortestPath = heightMap.shortestPath( begin = heightMap.start, isGoal = { it == heightMap.end },...
0
Kotlin
0
0
fef291c511408c1a6f34a24ed7070ceabc0894a1
3,282
advent-of-code-kotlin-2022
Apache License 2.0
src/Day16.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import java.util.BitSet fun main() { class Valve(val rate: Int, val targets: List<Int>) fun parseInput(input: List<String>): List<Valve> { val regex = Regex("Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)") val tempMap: Map<String, Pair<Int, List<String>>> = input.associate...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
5,579
aoc-2022
Apache License 2.0
src/Day18.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
fun main() { data class Point(val x: Int, val y: Int, val z: Int) { fun neighbours() = setOf( Point(x + 1, y, z), // right Point(x - 1, y, z), // left Point(x, y + 1, z), // up Point(x, y - 1, z), // down Point(x, y, z + 1), // front Po...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,850
aoc-2022
Apache License 2.0
src/Day08.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
fun main() { fun part1(input: List<String>): Int { return input.indices.sumOf { i -> input.first().indices.count { j -> createListOfTrees(i, j, input.size, input.first().length).any { trees -> trees.all { (x, y) -> input[x][y] < input[i][j] } }...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
1,366
advent-of-code-kotlin-2022
Apache License 2.0
advent-of-code-2023/src/Day07.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day07" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { solve(testInput()) shouldBe 6440 measureAnswer { solve(input()) } } "Part 2" { solve(testInput(), withJoker = true) shouldBe 5905 measure...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,453
advent-of-code
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day05/day05.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day05 import eu.janvdb.aocutil.kotlin.CombinedRange import eu.janvdb.aocutil.kotlin.SimpleRange import eu.janvdb.aocutil.kotlin.readGroupedLines import java.util.* //const val FILENAME = "input05-test.txt" const val FILENAME = "input05.txt" fun main() { val groupedLines = readGroupedLin...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,241
advent-of-code
Apache License 2.0
src/Day08.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
import kotlin.math.max /** * [Day08](https://adventofcode.com/2022/day/8) */ fun main() { fun trees(input: List<String>): Array<Array<Int>> = input.map { line -> line.toCharArray().map(Char::digitToInt).toTypedArray() }.toTypedArray() fun toInfoList(input: List<String>): Pair<Array<Array<Int>>,...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
3,215
aoc-in-kotlin-2022
Apache License 2.0
src/Day13.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { val input = readInput("Day13") val testInput = readInput("Day13_test") fun part1(input: List<String>): Int { return input.filter { it.isNotBlank() }.map(::parseList).chunked(2) .sumOfIndexed { idx, (x, y) -> if (x.compareTo(y) == -1) idx + 1 else 0 } } fun part2(in...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
2,761
advent-of-code-kotlin-2022
Apache License 2.0
advent-of-code-2022/src/Day11.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { "Part 1" { val testInput = readInput("Day11_test") val input = readInput("Day11") part1(testInput) shouldBe 10605 answer(part1(input)) } "Part 2" { val testInput = readInput("Day11_test") val input = readInput("Day11") part2(testInput) sh...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,687
advent-of-code
Apache License 2.0
src/day08/Day08.kt
spyroid
433,555,350
false
null
package day08 import readInput import kotlin.system.measureTimeMillis fun main() { fun part1(seq: Sequence<Box>) = seq.map { box -> box.numbers().count { it in listOf(1, 4, 7, 8) } }.sum() fun part2(seq: Sequence<Box>) = seq.map { box -> box.asValue() }.sum() val testSeq = readDigits(readInput("day08/...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
2,344
Advent-of-Code-2021
Apache License 2.0
src/main/kotlin/day15/Day15.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day15 import readInput import kotlin.math.abs fun main() { data class Scanner(val sx: Int, val sy: Int, val bx: Int, val by: Int) { val dist: Int get() = abs(sx - bx) + abs(sy - by) } val pattern = "Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
2,849
aoc2022
Apache License 2.0
src/Day08.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
fun main() { data class Tree(val height: Int, var seen: Boolean = false, var scenic: Int = 0) { fun getCount(): Int = if (seen) 1 else 0 } fun parseInput(input: List<String>): Array<Array<Tree>> = input.map { it.toList().map { tree -> Tree(tree.toString().toInt()) }.toTypedArray() }.to...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
3,389
kotlin_aoc_22
Apache License 2.0
src/y2021/Day09.kt
Yg0R2
433,731,745
false
null
package y2021 fun main() { fun part1(input: List<String>): Int { val heightmap: Array<Array<Int>> = input.toHeightMap() return heightmap .getLowestPointCoordinates() .sumOf { (x, y) -> heightmap[x][y] + 1 } } fun part2(input: List<String...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
2,663
advent-of-code
Apache License 2.0
src/Day13.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun chunkStringToList(str: String): List<String> { val withoutBrackets = str.filterIndexed { index, _ -> index != 0 && index != str.lastIndex } val elements = mutableListOf<String>() var bracketIndex = 0 val current = StringBuilder("") for (i in withoutBrackets.indices) { if ((withoutBracket...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
3,028
Advent-of-code
Apache License 2.0
src/main/kotlin/day9/Day9.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day9 import readToList fun main() { println(part1()) println(part2()) } private fun part1(): Int { val heightMatrix = HeightMatrix(readInput()) heightMatrix.setLowPoints() val filter = heightMatrix.matrix .flatten() .filter { it.lowest } return filter .sumOf { ...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
2,417
aoc2021
Apache License 2.0
src/Day18.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { fun part1(input: List<String>): Int { val points = mutableSetOf<Triple<Int, Int, Int>>() fun Triple<Int, Int, Int>.adjacent() = listOf( copy(first = first + 1), copy(first = first - 1), copy(second = second + 1), copy(second = second - 1),...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
2,531
advent-of-code-kotlin-2022
Apache License 2.0
src/Day23.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import java.util.SortedSet import kotlin.math.abs fun main() { class Elf(val x: Int, val y: Int): Comparable<Elf> { fun propose(turn: Int, elves: SortedSet<Elf>): Elf { val nElf = Elf(x, y - 1) val sElf = Elf(x, y + 1) val eElf = Elf(x + 1, y) val wElf = Elf(...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
3,931
aoc2022-kotlin
Apache License 2.0
src/Day08.kt
befrvnk
574,229,637
false
{"Kotlin": 15788}
import java.lang.Integer.min fun List<List<Int>>.isVisible(x: Int, y: Int): Boolean { val maxXSize = this.first().size return when { x == 0 || x == maxXSize - 1 -> true y == 0 || y == size - 1 -> true else -> { val tree = this[x][y] val left = (0 until x).all { t...
0
Kotlin
0
0
68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7
2,297
aoc-2022-kotlin
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2022/day15/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day15 import com.kingsleyadio.adventofcode.util.readInput import kotlin.math.abs fun main() { val data = parseInput() part1(data, 2_000_000) part2(data, 4_000_000) } fun part1(data: Map<Point, Point>, rowIndex: Int) { val (exclusions, sortedBeacons) = evalu...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,697
adventofcode
Apache License 2.0
src/day05/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day05 import readInput import kotlin.math.max import kotlin.collections.sumOf import kotlin.math.abs fun main() { val input = readInput("day05") println(solvePartOne(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Int = input.toLineList() .filterStraightL...
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
2,287
aoc-2021
Apache License 2.0
src/Day18.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
import java.util.* data class Cube(val x: Int, val y: Int, val z: Int) { fun adjacentNeighbours(): Set<Cube> = setOf( Cube(x + 1, y, z), Cube(x - 1, y, z), Cube(x, y + 1, z), Cube(x, y - 1, z), Cube(x, y, z + 1), Cube(x, y, z - 1), ) companion object { ...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
2,686
advent-of-code-2022
Apache License 2.0