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/day18/Day18.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day18 import readInput enum class Axis { X, Y, Z } data class Side(val x: Int, val y: Int, val z: Int, val axis: Axis) { companion object { fun fromCoordinatesAndAxis(coordinates: Triple<Int, Int, Int>, axis: Axis): Side = Side(coordinates.first, coordinates.second, coordinates.third,...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
3,664
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D21.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2020 import io.github.pshegger.aoc.common.BaseSolver class Y2020D21 : BaseSolver() { override val year = 2020 override val day = 21 override fun part1(): Int { val foods = parseInput() val possibilities = foods.calculatePossibleAllergens() val nonA...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,482
advent-of-code
MIT License
src/year2023/19/Day19.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`19` import readInput import utils.printlnDebug private const val CURRENT_DAY = "19" data class XmasRanged( val x: IntRange, val m: IntRange, val a: IntRange, val s: IntRange, ) { fun countAll(): Long { return x.count().toLong() * m.count() * a.count() * s.count() } ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
9,385
KotlinAdventOfCode
Apache License 2.0
src/Day18.kt
zirman
572,627,598
false
{"Kotlin": 89030}
sealed interface LavaCube { object Lava : LavaCube object Air : LavaCube object Visited : LavaCube } typealias LavaMatrix = List<List<MutableList<LavaCube>>> fun main() { fun LavaMatrix.widths(): Triple<Int, Int, Int> { return Triple(this[0][0].size, this[0].size, size) } fun parseLav...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
3,149
aoc2022
Apache License 2.0
2021/src/day12/Day12.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day12 import readInput fun buildGraph(lines: List<String>) : Map<String, MutableSet<String>> { val points = mutableMapOf<String, MutableSet<String>>() for (line in lines) { val connexion = line.split("-") val from = connexion[0] val to = connexion[1] if (points.contai...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,948
advent-of-code
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d06/Day06.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d06 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.readLines import kotlin.math.ceil import kotlin.math.floor import kotlin.math.pow import kotlin.math.sqrt data class Race(val time: Long, val recordDistance:...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,818
advent-of-code
MIT License
src/day08/Day08.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day08 import readInput const val day = "08" fun main() { fun calculatePart1Score(input: List<String>): Int { val heightsHorizontal = input.map { it.toCharArray().map { char -> char.digitToInt() } } val rows = heightsHorizontal.size val columns = heightsHorizontal[0].size ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
3,277
advent-of-code-22-kotlin
Apache License 2.0
src/twentytwo/Day08.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentytwo import readInputTwentyTwo data class Visibility( var fromTop: Boolean = false, var fromLeft: Boolean = false, var fromRight: Boolean = false, var fromBot: Boolean = false ) { fun isVisible(): Boolean { return fromBot || fromLeft || fromRight || fromTop } } fun ltrSee...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
3,147
kotlin-aoc-1
Apache License 2.0
src/main/kotlin/day07/Solution.kt
TestaDiRapa
573,066,811
false
{"Kotlin": 50405}
package day07 import java.io.File import kotlin.system.measureTimeMillis data class DirectoryTree ( val name: String, val size: Int = 0, val children: List<DirectoryTree> = listOf() ) { val fullSize: Int by lazy { size + children.sumOf { it.fullSize } } fun getDirectorySizeList(): List<Int> = ...
0
Kotlin
0
0
b5b7ebff71cf55fcc26192628738862b6918c879
2,988
advent-of-code-2022
MIT License
src/year2023/Day6.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import readLines import kotlin.random.Random fun main() { val input = parseInput(readLines("2023", "day6")) val testInput = parseInput(readLines("2023", "day6_test")) check(part1(testInput) == 288) println("Part 1:" + part1(input)) check(part2(testInput) == 71503) println("P...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
2,541
advent_of_code
MIT License
src/main/kotlin/day16/Tickets.kt
lukasz-marek
317,632,409
false
{"Kotlin": 172913}
package day16 data class ValidationRule(val name: String, val ranges: List<Pair<Int, Int>>) data class Ticket(val numbers: List<Int>) fun Ticket.invalidNumbers(rules: List<ValidationRule>): List<Int> = numbers.filterNot { number -> rules.any { it.isSatisfied(number) } } fun ValidationRule.isSatisfied(value: Int)...
0
Kotlin
0
0
a16e95841e9b8ff9156b54e74ace9ccf33e6f2a6
2,703
aoc2020
MIT License
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day19/Day19.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2020.day19 import eu.janvdb.aocutil.kotlin.readGroupedLines fun main() { val groupedLines = readGroupedLines(2020, "input19b.txt") val rules = groupedLines[0].map(::parseRule).map { Pair(it.ruleNumber, it) }.toMap() val regexes = calculateRegexes(rules) val regex = Regex("^" + regexes[0] + "$...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,430
advent-of-code
Apache License 2.0
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day04.kt
JamJaws
725,792,497
false
{"Kotlin": 30656}
package com.jamjaws.adventofcode.xxiii.day import com.jamjaws.adventofcode.xxiii.readInput import kotlin.collections.Set import kotlin.math.pow class Day04 { fun part1(text: List<String>): Int = text.asSequence() .map(::getMatches) .map(Set<String>::size) .map { 2.0.po...
0
Kotlin
0
0
e2683305d762e3d96500d7268e617891fa397e9b
1,541
advent-of-code-2023
MIT License
src/Day07.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
sealed class FileSystemNode() { data class File(val name: String, val size: Int) : FileSystemNode() data class Directory( val name: String, val items: MutableList<FileSystemNode> = mutableListOf() ) : FileSystemNode() { fun size(): Int { return items.sumOf { item -> ...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
3,038
kotlin_aoc_22
Apache License 2.0
src/Day07.kt
tigerxy
575,114,927
false
{"Kotlin": 21255}
import Line.* private fun List<String>.isCommand(): Boolean = first() == "$" fun main() { fun part1(input: List<String>): Int { return createTree(input) .getFolderSizes() .filter { it <= 100000 } .sum() } fun part2(input: List<String>): Int { val tree =...
0
Kotlin
0
1
d516a3b8516a37fbb261a551cffe44b939f81146
3,715
aoc-2022-in-kotlin
Apache License 2.0
src/Day07.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { val totalSpace = 70_000_000 val requiredSpace = 30_000_000 fun buildFileTree(input: List<String>): Map<String, Dir> { val fileTree = mutableMapOf<String, Dir>() var currentDir = "" fun MutableMap<String, Dir>.currentDir(): Dir = getValue(currentDir) fun String....
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
2,676
aoc-2022
Apache License 2.0
src/aoc2022/Day02.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 private enum class Game(val initScore: Int) { ROCK(1), PAPER(2), SCISSORS(3); val whatDefeat: Game get() = when (this) { ROCK -> SCISSORS SCISSORS -> PAPER PAPER -> ROCK } } private fun Game.canDefeat(other: Game): Boolean = this.whatDefe...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,001
Kotlin-AOC-2023
Apache License 2.0
src/day03/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day03 import readInput import kotlin.math.pow fun main() { val input = readInput("Day03") println(solvePartOne(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Int { val counterArray = IntArray(input.first().length) { 0 } input.onEach { value -> value....
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
2,704
aoc-2021
Apache License 2.0
src/main/kotlin/y2023/Day3.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day class Day3 : Day(3, 2023, false) { override fun partOne(): Any { return inputList.mapToSchema().numbersWithAdjacentSymbol().sumOf { it.value } } override fun partTwo(): Any { return inputList.mapToSchema().findGearRatios().sum() } } private fun Map<Int,...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
2,847
adventofcode
MIT License
src/main/kotlin/aoc22/Day08.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import common.Collections.product import aoc22.Day08Solution.visibleTreeCount import aoc22.Day08Solution.maxScenicScore import common.Space2D.Point import common.Space2D.Parser.toPointToChars import common.Year22 object Day08: Year22 { fun List<String>.part1(): Int = visibleTreeCount() fun List...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
1,927
aoc
Apache License 2.0
src/day19/Day19.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day19 import java.io.File fun main() { val (workflows, parts) = parse("src/day19/Day19.txt") println("🎄 Day 19 🎄") println() println("[Part 1]") println("Answer: ${part1(workflows, parts)}") println() println("[Part 2]") println("Answer: ${part2(workflows)}") } private ...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
4,119
advent-of-code-2023
MIT License
app/src/main/kotlin/day05/Day05.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day05 import common.InputRepo import common.readSessionCookie import common.solve import kotlin.math.abs import kotlin.math.max import kotlin.math.roundToInt fun main(args: Array<String>) { val day = 5 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay05Pa...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
2,223
advent-of-code-kt
Apache License 2.0
src/main/kotlin/aoc2022/Day02.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput import java.lang.IllegalArgumentException enum class Shape(val value: Int) { ROCK(1), PAPER(2), SCISSORS(3); companion object { fun fromChar(char: Char) = when (char) { 'A', 'X' -> ROCK 'B', 'Y' -> PAPER 'C', 'Z' -> SCISSORS ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,880
adventOfCode
Apache License 2.0
src/Day04.kt
anisch
573,147,806
false
{"Kotlin": 38951}
fun inRange(a: Int, b: Int, c: Int, d: Int): Boolean = (c <= a && b <= d) || (a <= c && d <= b) fun overlaps(a: Int, b: Int, c: Int, d: Int): Boolean = (a in c..d) || (b in c..d) || (c in a..b) || (d in a..b) fun main() { fun part1(input: List<String>): Int { return input .map { it.spl...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
1,198
Advent-of-Code-2022
Apache License 2.0
src/Day05.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
import java.util.Stack fun main() { class Solution(input: List<String>) { val supplyStacks: List<Stack<String>> val procedures: List<String> init { val (spec, procedures) = input.chunkedBy { ele -> ele == "" }; val (indexes, configurations) = spec.asReversed().run {...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
2,050
advent-of-code-kotlin-2022
Apache License 2.0
src/Day15.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import kotlin.math.abs import kotlin.math.absoluteValue class UnRange constructor(private var list: List<IntRange>) { constructor(r: IntRange) : this(listOf(r)) fun minus(s: IntRange): UnRange { if (s.isEmpty()) { return this } val ranges = ArrayList<IntRange>(list.size + 2)...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
3,603
Advent-of-code
Apache License 2.0
Advent-of-Code-2023/src/Day12.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day12" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY /** * Hashmap used for memoization, to avoid recalculating the same values. */ private val cache = hashMapOf<Pair<String, List<Int>>, Long>() fun count(springs: String, springsSize: List<Int>): ...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
2,445
Advent-of-Code-2023
Apache License 2.0
src/Day02.kt
EemeliHeinonen
574,062,219
false
{"Kotlin": 6073}
import Choice.* import Result.* enum class Choice(val firstLetter: Char, val secondLetter: Char, val points: Int) { ROCK('A', 'X', 1), PAPER('B', 'Y', 2), SCISSORS('C', 'Z', 3); companion object { infix fun fromFirstLetter(firstLetter: Char): Choice = values().first { it.firstLetter == firstLe...
0
Kotlin
0
0
33775d9e6e848ab0efae0e3f00f43368c036799d
2,845
aoc-22-kotlin
Apache License 2.0
src/main/kotlin/days/y2023/day12/Day12.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day12 import util.InputReader typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day12(val input: PuzzleInput) { fun partOne(): Int { return input.sumOf { line -> line.toConfiguration().arrangements().size } } fun partTwo(): Int { val bigInput...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,442
AdventOfCode
Creative Commons Zero v1.0 Universal
src/y2023/Day04.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.timingStatistics import kotlin.math.pow object Day04 { private fun parse(input: List<String>): List<Pair<List<Int>, List<Int>>> { return input.map { line -> val (winning, mine) = line.substringAfter(":").trim().split(" | ") winning.sp...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,937
advent-of-code
Apache License 2.0
src/Day03.kt
Oli2861
572,895,182
false
{"Kotlin": 16729}
fun toCompartments(rucksack: String): Pair<String, String> { val length = rucksack.length val middle = length / 2 return Pair(rucksack.substring(0, middle), rucksack.substring(middle, length)) } fun getPriority(char: Char) = if (char.isUpperCase()) char.lowercaseChar().code - 64 - 6 else char.uppercase...
0
Kotlin
0
0
138b79001245ec221d8df2a6db0aaeb131725af2
1,487
Advent-of-Code-2022
Apache License 2.0
src/year2022/11/Day11.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`11` import java.math.BigInteger import readInput fun main() { fun runRound(monkeys: List<Monkey>, is3: Boolean) { val divider = monkeys.fold(1L) { item, monkey -> item * monkey.divisibleBy } monkeys.forEach { monkey -> monkey.startingItems.forEach { item -> ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,467
KotlinAdventOfCode
Apache License 2.0
src/day_12/Day12.kt
BrumelisMartins
572,847,918
false
{"Kotlin": 32376}
package day_12 import day_03.alphabet import readInput import java.util.* import kotlin.collections.ArrayList fun main() { val input = readInput("day_12/Day12") val testInput = fromRawData(readInput("day_12/Day12_test")) fun part1(): Int { val finder = PathFinder(fromRawData(input)) fi...
0
Kotlin
0
0
3391b6df8f61d72272f07b89819c5b1c21d7806f
3,591
aoc-2022
Apache License 2.0
src/Day02.kt
hoppjan
573,053,610
false
{"Kotlin": 9256}
import RPS.* import Tactic.* fun main() { val testLines = readInput("Day02_test") val testResult1 = part1(testLines) println("test part 1: $testResult1") check(testResult1 == 15) val testResult2 = part2(testLines) println("test part 2: $testResult2") check(testResult2 == 12) val lin...
0
Kotlin
0
0
f83564f50ced1658b811139498d7d64ae8a44f7e
2,237
advent-of-code-2022
Apache License 2.0
src/day08/day08.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day08 import util.Grid import util.readInput import util.shouldBe import util.toGrid fun main() { val day = 8 val testInput = readInput(day, testInput = true).parseInput() part1(testInput) shouldBe 21 part2(testInput) shouldBe 8 val input = readInput(day).parseInput() println("output ...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
1,883
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kr/co/programmers/P72411.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers // https://github.com/antop-dev/algorithm/issues/386 class P72411 { fun solution(orders: Array<String>, course: IntArray): Array<String> { val answer = mutableListOf<String>() // 메뉴조합을 오름차순으로 정렬 val sorted = orders.map { it.toCharArray().sorted() } // 메뉴별 갯...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,976
algorithm
MIT License
src/day07/Day07.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day07 import utils.* open class Entity(open val size: Int = 0) class File(size: Int) : Entity(size) class Directory(val parent: Directory? = null) : Entity() { val contents: MutableMap<String, Entity> = mutableMapOf() private var _size: Int? = null override val size: Int get() = _size ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
1,941
AOC-2022-Kotlin
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day07.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day class Day07(input: String? = null) : Day(7, "Camel Cards ", input) { private val positionsWithoutJoker = listOf('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') private val positionsWithJoker = listOf('J', '2', '3', '4', '5', '6', '7', '8...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
3,151
advent-of-code-2023
MIT License
Advent-of-Code-2023/src/Day06.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day06" private const val PART1_TEST_FILE = "${AOC_DAY}_test_part1" private const val PART2_TEST_FILE = "${AOC_DAY}_test_part2" private const val INPUT_FILE = AOC_DAY /** * Finds the minimum time required to go further than the record distance, and then, since the results are symmetric, ...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
2,681
Advent-of-Code-2023
Apache License 2.0
src/day11/Day11.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day11 import readText import kotlin.math.pow fun main() { val id = "11" val testOutput = 10605 val testInput = readInput("day$id/Day${id}_test_simple") println(part1(testInput)) check(part1(testInput) == testOutput.toLong()) val input = readInput("day$id/Day${id}_simple") printl...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
3,242
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/codes/jakob/aoc/solution/Day02.kt
loehnertz
725,944,961
false
{"Kotlin": 59236}
package codes.jakob.aoc.solution import codes.jakob.aoc.shared.associateByIndex import codes.jakob.aoc.shared.multiply import codes.jakob.aoc.shared.splitByLines object Day02 : Solution() { override fun solvePart1(input: String): Any { // The amount of cubes of each type is constrained by the following ru...
0
Kotlin
0
0
6f2bd7bdfc9719fda6432dd172bc53dce049730a
4,604
advent-of-code-2023
MIT License
src/Day08.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
data class Grid(val cells: List<Cell>) { fun getLeftNeighbors(cell: Cell): List<Cell> { return cells.filter { it.row == cell.row && it.col < cell.col } } fun getRightNeighbors(cell: Cell): List<Cell> { return cells.filter { it.row == cell.row && it.col > cell.col } } fun getTopNei...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
2,809
aoc2022
Apache License 2.0
src/main/kotlin/aoc2021/Day13.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import kotlin.math.max private fun Boolean.toInt() = if (this) 1 else 0 /** * Folds the transparent input page according to the given instructions * * @param array the page to aoc2021.fold * @param foldInstruction folding instruction in the form of 'aoc2021.fold along x=42' * @r...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,909
adventOfCode
Apache License 2.0
src/main/kotlin/days/Day12.kt
julia-kim
569,976,303
false
null
package days import Point import readInput import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { /* Dijkstra's algorithm */ val heightmap = input.flatMapIndexed { i, string -> string.mapIndexed { j, char -> Point(j, i) to char } }.toMap().toMutable...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
3,896
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day3.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
fun main() { fun part2(lines: List<String>): Int { val oxygen = lines.toMutableList() val scrubber = lines.toMutableList() for (i in 0 until lines.first().length) { val ox = oxygen.groupingBy { it[i] } .eachCount() .entries .maxWith...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
2,008
AOC2021
Apache License 2.0
src/main/kotlin/be/swsb/aoc2021/day9/Day9.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day9 import be.swsb.aoc2021.common.Point import java.util.* object Day9 { fun solve1(input: List<String>): Int { val heightmap = input.toHeightmap() return heightmap.findLowest().sumOf { it.riskLevel } } fun solve2(input: List<String>): Int { val heightmap ...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
3,925
Advent-of-Code-2021
MIT License
src/main/day13/Part1.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day13 import dequeOf import readInput import java.util.* fun main() { val packets = parseInput(readInput("day13/input.txt")) val indiceSum = packets .mapIndexed { index, packet -> Pair(index + 1, validateOrder(dequeOf(packet.first), dequeOf(packet.second))) } .filter { it.second } ...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
3,232
aoc2022
Apache License 2.0
src/Day24.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import java.util.* fun main() { fun start() = Vec2(0, 1) fun List<String>.target() = Vec2(size - 1, get(0).length - 2) data class State(val minute: Int, val pos: Vec2): Comparable<State> { override fun compareTo(other: State): Int { return compareValuesBy(this, other, { it.minute }, {...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
2,700
Advent-of-Code-2022
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day22.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day22.solve() object Day22 : AdventSolution(2020, 22, "Crab Combat") { override fun solvePartOne(input: String): Long { val combat = generateSequence(parse(input)) { round(it.first, it.second) } .first { it.firs...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,110
advent-of-code
MIT License
src/Day05.kt
sebastian-heeschen
572,932,813
false
{"Kotlin": 17461}
fun main() { fun part1(input: List<String>): String = topOfTheStacks(input) { move, stacks -> repeat(move.count) { val crateToMove = stacks[move.from].removeLast() stacks[move.to].add(crateToMove) } } fun part2(input: List<String>): String = topOfTheStacks(input) {...
0
Kotlin
0
0
4432581c8d9c27852ac217921896d19781f98947
2,525
advent-of-code-2022
Apache License 2.0
src/Day15.kt
karloti
573,006,513
false
{"Kotlin": 25606}
import kotlin.math.abs import kotlin.time.ExperimentalTime import kotlin.time.measureTimedValue class Day15(input: List<String>) { private val regex = Regex("(-*\\d+)") private val beacons = mutableSetOf<Beacon>() private val sensors = mutableSetOf<Sensor>() val IntRange.size get() = last.toLong() - fi...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
2,368
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/day16/Day16ChronalClassification.kt
Zordid
160,908,640
false
null
package day16 import shared.ElfDeviceCpu import shared.extractAllInts import shared.readPuzzle fun part1(puzzle: List<String>): Int { val samples = readSamples(puzzle) return samples.count { (_, couldBe) -> couldBe.size >= 3 } } fun part2(puzzle: List<String>): Int { val samples = readSamples(puzzle) ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
2,815
adventofcode-kotlin-2018
Apache License 2.0
src/Day08_old.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.util.Stack import kotlin.math.max fun main() { val input = readInput("Day08") fun part1(input: List<String>): Int { val map = parseGrid(input) val left = accMaxFromLeft(map) val right = accMaxFromRight(map) val down = accMaxFromDown(map) val up = accMaxFrom...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
3,118
advent-of-code-kotlin-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day05.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val (seeds, pipeline) = readInput(2023, 5).useLines { sequence -> val lines = sequence.iterator() val seeds = lines.next().substringAfter(": ").split(" ").map { it.toLong() } lines....
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,139
adventofcode
Apache License 2.0
src/Day09.kt
hoppjan
433,705,171
false
{"Kotlin": 29015, "Shell": 338}
typealias HeightMap = List<List<Int>> typealias Basin = List<Position> typealias UnexploredBasin = MutableList<Position> fun main() { fun part1(map: HeightMap) = map.foldIndexed(mutableListOf<Int>()) { x, acc, row -> row.forEachIndexed { y, number -> if (map.hasLowestPointAt(x,...
0
Kotlin
0
0
04f10e8add373884083af2a6de91e9776f9f17b8
2,730
advent-of-code-2021
Apache License 2.0
app/src/main/kotlin/day02/Day02.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day02 import common.InputRepo import common.readSessionCookie import common.solve import util.splitIntoPair fun main(args: Array<String>) { val day = 2 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay02Part1, ::solveDay02Part2) } fun solveDay02Part1(in...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
2,643
AdventOfCode2022
Apache License 2.0
src/Day07.kt
dizney
572,581,781
false
{"Kotlin": 105380}
object Day07 { const val EXPECTED_PART1_CHECK_ANSWER = 95437 const val EXPECTED_PART2_CHECK_ANSWER = 24933642 const val DIR_SIZE_THRESHOLD = 100_000 const val FS_TOTAL_SIZE = 70_000_000 const val FS_NEEDED_FREE_SPACE = 30_000_000 } sealed class Entry(val name: String) class File(name: String, val...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
3,009
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day07.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
fun main() { fun parseInput(input: List<String>): Dir { val root = Dir("/") var current = root input.drop(1).forEach { line -> when { line.startsWith("$ cd ..") -> current = current.parent!! line.startsWith("$ cd") -> current = current.dirs.firs...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
1,802
advent-of-code-Kotlin-2022
Apache License 2.0
src/day08/Day08.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day08 import readInput private const val DAY_ID = "08" fun main() { fun parseInput(input: List<String>): List<List<Int>> = input.map { line -> line.map { it.digitToInt() } } fun findVisibleTreesInInterior(grid: List<List<Int>>): Set<Pair<Int, Int>> { val m = grid.size val n =...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
3,465
aoc-2022-in-kotlin
Apache License 2.0
2022/src/main/kotlin/day15_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Segment import utils.Solution import utils.Vec2i import utils.mapItems import kotlin.math.abs fun main() { Day15Imp.run() } object Day15Imp : Solution<List<Pair<Vec2i, Vec2i>>>() { override val name = "day15" override val parser: Parser<List<Pair<Vec2i, Vec2i>>> = Parser.lines.m...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,285
aoc_kotlin
MIT License
2015/src/main/kotlin/com/koenv/adventofcode/Day15.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode import java.util.* object Day15 { fun getHighestScore(input: String): Int { val (ingredients, combinations) = getCombinations(input) return combinations.map { ingredients.sumAll(it) }.max()!! } fun getBestCalories(input: String): Int { val (ingredien...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
2,636
AdventOfCode-Solutions-Kotlin
MIT License
src/main/java/leetcode/kotlin/ArrayProblems.kt
Zhaoyy
110,489,661
false
{"Java": 248008, "Kotlin": 18188}
package leetcode.kotlin import java.lang.StringBuilder import kotlin.math.abs import kotlin.math.max fun main(args: Array<String>) { val problems = ArrayProblems() // println(problems.maximumProduct( // intArrayOf(722, 634, -504, -379, 163, -613, -842, -578, 750, 951, -158, 30, -238, -392, -487, // -...
0
Java
0
0
3f801c8f40b5bfe561c5944743a779dad2eca0d3
12,985
leetcode
Apache License 2.0
src/day15/Day15.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day15 import readInput import readTestInput import kotlin.math.absoluteValue private data class Position(val x: Int, val y: Int) private data class Sensor(val position: Position) { constructor(x: Int, y: Int) : this(Position(x, y)) } private data class Beacon(val position: Position) { constructor(x:...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
3,914
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day5/Day5.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day5 import execute import readAllText import splitBy import wtf fun main() { val input = readAllText("local/day5_input.txt") val test = """ [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 ...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
2,079
advent-of-code-2022
MIT License
src/main/kotlin/day11.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.util.stream.Collectors fun day11ProblemReader(text: String): List<List<String>> = text .split('\n') .stream() .map { line -> line.trim() .split("") .stream() .filter { it != "" } .collect(Collectors.toList()) } .collect(Collectors....
0
Ruby
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
3,382
adventofcode_2020
MIT License
src/poyea/aoc/mmxxii/day18/Day18.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day18 import poyea.aoc.utils.readInput data class Point(val x: Int, val y: Int, val z: Int) { operator fun plus(other: Point) = Point(x + other.x, y + other.y, z + other.z) fun neighbours() = listOf( copy(x = x - 1), copy(x = x + 1), copy(y = y - 1), ...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
2,035
aoc-mmxxii
MIT License
src/main/kotlin/day7/Day7SumOfItsParts.kt
Zordid
160,908,640
false
null
package day7 import shared.readPuzzle fun part1(input: List<String>): Any { val required = prepareData(input) val order = mutableListOf<Char>() while (required.filter { (step, requires) -> !order.contains(step) && order.containsAll(requires) }.keys.minOrNull()?.also { orde...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
3,323
adventofcode-kotlin-2018
Apache License 2.0
gcj/y2020/kickstart_c/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.kickstart_c private fun solve(): Long { val (n, q) = readInts() val ft = FenwickTree(n) val ftCoef = FenwickTree(n) fun set(i: Int, value: Int) { ft[i] = minusOnePow(i) * value ftCoef[i] = minusOnePow(i) * value * (i + 1) } fun query(start: Int, end: Int) = (ftCoef.sum(start, end) - ft.sum(...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,366
competitions
The Unlicense
src/Day08.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
fun main() { fun condensedString(map: List<List<Int>>): String { return map.map { it.joinToString(" ") }.joinToString("\n") } fun condensedString(map: List<List<Boolean>>): String { return map.map { it.map { if (it) "#" else "." }.joinToString("") }.joinToString("\n") ...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
3,507
aoc-kotlin-2022
Apache License 2.0
15/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File import java.util.PriorityQueue fun readInput() : Grid { val input = File("input.txt") .readText() .split("\r\n") .filter { it.isNotEmpty() } .map { row -> row.map { it.digitToInt() }} return Grid(input) } class Grid(mat : List<List<Int>>) { companion o...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,045
advent-of-code-2021
MIT License
src/Day02.kt
derivz
575,340,267
false
{"Kotlin": 6141}
val rules = mapOf( "A" to mapOf("X" to 3, "Y" to 6, "Z" to 0), "B" to mapOf("X" to 0, "Y" to 3, "Z" to 6), "C" to mapOf("X" to 6, "Y" to 0, "Z" to 3), ) val extraPoints = mapOf( "X" to 1, "Y" to 2, "Z" to 3 ) val desiredPoints = mapOf( "X" to 0, "Y" to 3, "Z" to 6 ) fun main() { fun part1(lines:...
0
Kotlin
0
0
24da2ff43dc3878c4e025f5b737dca31913f40a5
1,045
AoC2022.kt
Apache License 2.0
src/main/kotlin/Day13.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day13.solvePart1()) Day13.solvePart2() } object Day13 { private val input = readInput("day13") private val points = input.takeWhile { it.isNotBlank() } .map { it.toIntArray() } .map { (x, y) -> Point(x, y) } private val folds = input.takeLastWhile { it.isNotBlan...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,788
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
y2021/src/main/kotlin/adventofcode/y2021/Day23.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution import java.util.PriorityQueue fun main() { Day23.solve() } object Day23 : AdventSolution(2021, 23, "Amphipods") { override fun solvePartOne(input: String) = solve( AmphipodState( corridor = " ", rooms = li...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
3,636
advent-of-code
MIT License
src/main/kotlin/solutions/day20/Day20.kt
Dr-Horv
112,381,975
false
null
package solutions.day20 import solutions.Solver data class Vector3D(val x: Int, val y: Int, val z: Int) operator fun Vector3D.plus(v2: Vector3D) = Vector3D(x+v2.x, y+v2.y, z+v2.z) class Particle(var position: Vector3D, var velocity: Vector3D, val acceleration: Vector3D) { companion object { var nbr = ...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
2,545
Advent-of-Code-2017
MIT License
src/main/kotlin/org/hydev/lcci/lcci_04.kt
VergeDX
334,298,924
false
null
package org.hydev.lcci import kotlin.math.abs // https://leetcode-cn.com/problems/route-between-nodes-lcci/ fun findWhetherExistsPath(n: Int, graph: Array<IntArray>, start: Int, target: Int): Boolean { val filteredGraph = graph.distinctBy { (it[0] to it[1]).hashCode() }.toTypedArray() val nodeEdgeMap = HashMa...
0
Kotlin
0
0
9a26ac2e24b0a0bdf4ec5c491523fe9721c6c406
6,873
LeetCode_Practice
MIT License
src/main/kotlin/solutions/day18/Day18.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day18 import solutions.Solver import kotlin.math.abs data class Coordinate3D(val x: Int, val y: Int, val z: Int) { override fun toString(): String { return "($x, $y, $z)" } } operator fun Coordinate3D.plus(coordinate: Coordinate3D) = Coordinate3D(x + coordinate.x, y + coordinate...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
2,638
Advent-of-Code-2022
MIT License
src/Day03.kt
arisaksen
573,116,584
false
{"Kotlin": 42887}
import org.assertj.core.api.Assertions.assertThat val items: List<Char> = ('a'..'z') + ('A'..'Z') val priority: List<Int> = (1..26) + (27..52) val itemPriority: Map<Char, Int> = items.zip(priority).toMap() typealias Compartment1 = String typealias Compartment2 = String typealias Rucksack = Pair<Compartment1, Compartm...
0
Kotlin
0
0
85da7e06b3355f2aa92847280c6cb334578c2463
1,983
aoc-2022-kotlin
Apache License 2.0
src/year_2023/day_19/Day19.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_19 import readInput data class System( val workflows: Map<String, Workflow>, val parts: List<Part> ) data class Workflow( val name: String, val conditions: List<String> ) data class Part( val x: Int, val m: Int, val a: Int, val s: Int ) object Day19 { /** ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
4,017
advent_of_code
Apache License 2.0
src/main/kotlin/day12/Day12SubterraneanSustainability.kt
Zordid
160,908,640
false
null
package day12 import shared.measureRuntime import shared.readPuzzle class Pots(puzzle: List<String>) { private val initial = puzzle.first().split(" ")[2] to 0L private val transforms = puzzle.filter { it.contains("=>") }.associate { l -> l.split(" ").let { it[0] to it[2] } } fun solvePart...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
2,855
adventofcode-kotlin-2018
Apache License 2.0
src/main/kotlin/Day02.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
fun main() { fun parseInput(input: String) = input.split("\n") .flatMap { line -> line.split(" ") .zipWithNext() } fun part1(input: String): Int { return parseInput(input) .map { Pair(toSymbol(it.first), toSymbol(it.second)) } .sumOf ...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
2,513
advent-of-code-Kotlin-2022
Apache License 2.0
advent-of-code-2023/src/Day23.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 lib.matrix.* import lib.matrix.Direction.* import lib.matrix.Direction.Companion.nextInDirection private const val DAY = "Day23" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = rea...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
3,677
advent-of-code
Apache License 2.0
src/Day13.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
private sealed class Item : Comparable<Item> { override fun compareTo(other: Item): Int { return when { this is IntItem && other is IntItem -> this.value.compareTo(other.value) this is ListItem && other is ListItem -> { val nonEqualItem = this.values.zip(other.values...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
3,192
aoc2022
Apache License 2.0
02friendsinneed/src/Main.kt
Minkov
125,619,391
false
null
import java.util.* import kotlin.math.min fun fakeInput() { val test = """3 2 1 1 1 2 1 3 2 2 5 8 2 1 2 1 2 5 4 1 2 1 3 1 3 4 4 4 5 1 2 4 3 5 2 1 2 3 20""" val stream = test.byteInputStream() System.setIn(stream) } fun main(args: Array<String>) { // fakeInput() // println(solve()) // println("-"...
0
JavaScript
4
1
3c17dcadd5aa201166d4fff69d055d7ec0385018
2,183
judge-solved
MIT License
src/Day08.kt
mvmlisb
572,859,923
false
{"Kotlin": 14994}
private inline fun processInnerRow(rows: List<List<Int>>, process: (rowIndex: Int, row: List<Int>, indexInRow: Int) -> Unit) { rows.forEachIndexed { rowIndex, row -> val isOuterRowIndex = rowIndex == 0 || rowIndex == rows.lastIndex if (!isOuterRowIndex) row.indices.forEach { indexInRow -...
0
Kotlin
0
0
648d594ec0d3b2e41a435b4473b6e6eb26e81833
2,991
advent_of_code_2022
Apache License 2.0
src/Day04.kt
razvn
573,166,955
false
{"Kotlin": 27208}
fun main() { val day = "Day04" fun part1(input: List<String>): Int { val pairs = parse(input) val including = pairs.filter { rangeContains(it.first, it.second)} return including.size } fun part2(input: List<String>): Int { val pairs = parse(input) val including...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
1,456
aoc-2022-kotlin
Apache License 2.0
2022/src/main/kotlin/Day12.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day12 { fun part1(input: String): Int { val map = input.splitNewlines() val start = findChar(map, 'S')[0] val end = findChar(map, 'E')[0] return shortestPath(map, start, end)!!.size - 1 } fun part2(input: String): Int { val map = input.splitNewlines() val starts = findChar(map, 'a...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,031
advent-of-code
MIT License
src/Day08.kt
dragere
440,914,403
false
{"Kotlin": 62581}
fun main() { fun decode(notes: List<String>): HashMap<Char, Char> { val segMap = HashMap<Char, Char>() val segCount = HashMap<Char, Int>() val decodeDigMap = HashMap<Int, String>() segCount['a'] = 0 segCount['b'] = 0 segCount['c'] = 0 segCount['d'] = 0 ...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
3,880
advent_of_code21_kotlin
Apache License 2.0
src/main/Day14.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day14 import geometry.* import utils.readInput private val source: Position = 500 to 0 class Cave(private val rocks: Set<Position>) { private val filled = rocks.toMutableSet() private val depth = rocks.maxOf(Position::y) fun fill(): Int = generateSequence { drop() }.takeWhile { it == Dro...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
2,814
aoc-2022
Apache License 2.0
src/day2/Day02.kt
kongminghan
573,466,303
false
{"Kotlin": 7118}
package day2 import readInput import java.lang.IllegalArgumentException const val wonScore = 6 const val drawScore = 3 enum class Move(val score: Int) { Rock(1), Paper(2), Scissors(3) } data class Play( val letter: String, val move: Move ) fun main() { val winPairs = mapOf( Move.Roc...
0
Kotlin
0
0
f602900209712090778c161d407ded8c013ae581
2,374
advent-of-code-kotlin
Apache License 2.0
src/Day08.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
fun <T> List<List<T>>.column(y: Int): List<T> { return (0 .. this.lastIndex).map { this[it][y] } } fun main() { fun part1(input: List<List<Int>>): String { val max = input.lastIndex var visible = (max * 4) (1 until max).forEach { x -> (1 until max).forEach { y -> ...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
2,369
aoc2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day08/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day08 import com.kingsleyadio.adventofcode.util.readInput fun main() { println(part1()) println(part2()) } fun part1(): Int { readInput(2021, 8).useLines { lines -> val knownLengths = listOf(2, 3, 4, 7) return lines .map { it.substri...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,885
adventofcode
Apache License 2.0
leetcode2/src/leetcode/maximum-product-subarray.kt
hewking
68,515,222
false
null
/** * 152. 乘积最大子序列 * https://leetcode-cn.com/problems/maximum-product-subarray/ * 给定一个整数数组 nums ,找出一个序列中乘积最大的连续子序列(该序列至少包含一个数)。 示例 1: 输入: [2,3,-2,4] 输出: 6 解释: 子数组 [2,3] 有最大乘积 6。 示例 2: 输入: [-2,0,-1] 输出: 0 解释: 结果不能为 2, 因为 [-2,-1] 不是子数组。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/maximum-product-subarray 著...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,364
leetcode
MIT License
src/Day05.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
typealias Stack = List<Char> fun main() { fun solve(input: Pair<MutableList<Stack>, List<StackMove>>, inputModifier: (List<Char>) -> List<Char>): String { val (stacks, moves) = input moves.forEach { move -> stacks[move.to] = stacks[move.from].take(move.amount).let { inputModifier.invok...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
1,912
advent-of-code
Apache License 2.0
src/main/kotlin/aoc2023/Day05.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import kotlinx.coroutines.* import utils.InputUtils import kotlin.math.max import kotlin.math.min enum class Mode { PARALLEL, BRUTE, SPLIT } val mode = Mode.SPLIT data class SeedRange(val destStart: Long, val sourceStart: Long, val size: Int) { fun contains(x: Long) = (x >= sourceStart) && (x ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
5,314
aoc-2022-kotlin
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/SlidingWindow.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Sliding window is a technique used for efficiently processing arrays or lists by maintaining a "window" of elements as you iterate through the data. This can be particularly useful for problems where you need to find a subarray, substring, or some other contiguous segment of the data that satisfies a certain cond...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
3,133
Kotlin-Data-Structures-Algorithms
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day21.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput("Day21") Day21.part1(input).println() Day21.part2(input).println() } object Day21 { fun part1(input: List<String>): Int { return input.gardenPlotsReached(64) } fun part2(input: List<String>): Long { println("f(x) = a*x^2 + b*...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
2,468
advent-of-code
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2023/Day02.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2023 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part2A : PartSolution() { internal lateinit var games: List<Game> override fun parseInput(text: String) { games = text.trim().split("\n").map { Game(it) } } override f...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,107
advent-of-code-kotlin
MIT License
src/Day01.kt
muellerml
573,601,715
false
{"Kotlin": 14872}
fun main() { fun part1(input: List<String>): Int { return input.foldIndexed(Calories(0, 0)) { index, calories, addition -> when (val addToInt = addition.toIntOrNull()) { null -> if (calories.max < calories.current) { println("Highest value found for index $ind...
0
Kotlin
0
0
028ae0751d041491009ed361962962a64f18e7ab
1,753
aoc-2022
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day5.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser import java.lang.RuntimeException data class CategoryMap(val source: LongRange, val dest: LongRange) data class Almanac( val seeds: List<Long>, val...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
4,235
aoc-2023
The Unlicense
src/Day05.kt
winnerwinter
573,917,144
false
{"Kotlin": 20685}
fun main() { fun parseInstruction(input: String): Instruction { val instructionParts = input.split(" ") val move = instructionParts[1].toInt() val from = instructionParts[3].toInt() val to = instructionParts[5].toInt() return Triple(move, from, to) } fun parseInput...
0
Kotlin
0
0
a019e5006998224748bcafc1c07011cc1f02aa50
3,038
advent-of-code-22
Apache License 2.0