path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day2.kt
clechasseur
567,968,171
false
{"Kotlin": 493887}
package io.github.clechasseur.adventofcode.y2022 import io.github.clechasseur.adventofcode.y2022.data.Day2Data object Day2 { private val input = Day2Data.input fun part1(): Int = input.lines().sumOf { score(it) } fun part2(): Int = input.lines().sumOf { score2(it) } private enum class Choice(val op...
0
Kotlin
0
0
7ead7db6491d6fba2479cd604f684f0f8c1e450f
1,835
adventofcode2022
MIT License
src/main/kotlin/Day05.kt
joostbaas
573,096,671
false
{"Kotlin": 45397}
import kotlinx.collections.immutable.* @JvmInline value class Box(val content: Char) typealias Stack = PersistentList<Box> typealias Stacks = PersistentMap<Char, Stack> data class Move(val count: Int, val from: Char, val to: Char) interface CrateMover { val stacks: Stacks fun doMove(move: Move): CrateMover...
0
Kotlin
0
0
8d4e3c87f6f2e34002b6dbc89c377f5a0860f571
2,634
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day005.kt
ruffCode
398,923,968
false
null
object Day005 { private val sample = listOf("FBFBBFFRLR") private val input = PuzzleInput("day005.txt") @JvmStatic fun main(args: Array<String>) { val passes = input.readLines() println( """ part1: ${partOne(passes)} part2: ${partTwo(passes)} ...
0
Kotlin
0
0
477510cd67dac9653fc61d6b3cb294ac424d2244
2,117
advent-of-code-2020-kt
MIT License
src/day16/day16.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day16 import readInput import java.util.UUID import kotlin.math.max fun parse(input: List<String>): Pair<Map<String, Map<String, Int>>, Map<String, Int>> { val rates = HashMap<String, Int>() val graph = HashMap<String, MutableMap<String, Int>>() // create connections based on input for (line ...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
3,941
aoc-2022
Apache License 2.0
src/Day16_try.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
import extensions.grid.* import kotlin.math.max class Day16Try : Day(16) { class Valve(val input: String) { val name: String val flowRate: Int val connectedVales: List<String> var isOpen: Boolean = false var openedOnXMinutesLeft : Int = 0 init { name = ...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
3,344
aoc-2022-in-kotlin
Apache License 2.0
src/Day23.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import Day23.Direction fun main() { val testInput = readInput("Day23_test") .parseGround() val input = readInput("Day23") .parseGround() part1(testInput).also { println("Part 1, test input: $it") check(it == 110) } part1(input).also { println("Part 1, real ...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
5,273
aoc22-kotlin
Apache License 2.0
src/Day07.kt
phoenixli
574,035,552
false
{"Kotlin": 29419}
fun main() { fun part1(input: List<String>): Int { val root = parseInput(input) return root.find { it.size <= 100000 }.sumOf { it.size } } fun part2(input: List<String>): Int { val root = parseInput(input) val unused = 70000000 - root.size val needToFree = 30000000 -...
0
Kotlin
0
0
5f993c7b3c3f518d4ea926a792767a1381349d75
1,801
Advent-of-Code-2022
Apache License 2.0
src/DayFour.kt
P-ter
572,781,029
false
{"Kotlin": 18422}
import kotlin.math.roundToInt fun main() { fun partOne(input: List<String>): Int { var total = 0 input.forEach { line -> val (firstElf, secondElf) = line.split(",") val firstElfRange = firstElf.split("-").map { it.toInt() } val secondElfRange = secondElf.split(...
0
Kotlin
0
1
e28851ee38d6de5600b54fb884ad7199b44e8373
1,490
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/_2021/Day10.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2021 import REGEX_LINE_SEPARATOR import aoc import kotlin.math.ceil private val CHUNK_MAP = mapOf( ')' to '(', ']' to '[', '}' to '{', '>' to '<' ) private val CHUNK_MAP_REVERSED = CHUNK_MAP.entries.associateBy({ it.value }, { it.key }) fun main() { aoc(2021, 10) { aocRun { input -> input.split(RE...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
1,629
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/dp/BoxDepth.kt
yx-z
106,589,674
false
null
package dp import util.* typealias Square = Tuple4<Int, Int, Int, Int> // given n squares of size 10 as (X, Y) where X is the x-coordinate of its bottom // left corner and Y is the y-coordinate of its bottom left corner // find the largest subset of such squares : there is a common point in them // and report the si...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,843
AlgoKt
MIT License
aoc-2019/src/commonMain/kotlin/fr/outadoc/aoc/twentynineteen/Day03.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentynineteen import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.max import fr.outadoc.aoc.scaffold.min import fr.outadoc.aoc.scaffold.readDayInput import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day03 : Day<Int> { private val input: List<String> ...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
6,040
adventofcode
Apache License 2.0
src/Day02.kt
manuel-martos
574,260,226
false
{"Kotlin": 7235}
fun main() { println("part01 -> ${solveDay02Part01()}") println("part02 -> ${solveDay02Part02()}") } private fun solveDay02Part01() = readInput("day02") .sumOf { val other = it[0] - 'A' + 1 val mine = it[2] - 'X' + 1 val outcome = calcOutcome(mine, other) ...
0
Kotlin
0
0
5836682fe0cd88b4feb9091d416af183f7f70317
1,157
advent-of-code-2022
Apache License 2.0
src/main/kotlin/mkuhn/aoc/Day09.kt
mtkuhn
572,236,871
false
{"Kotlin": 53161}
package mkuhn.aoc import mkuhn.aoc.util.Point import mkuhn.aoc.util.readInput import mkuhn.aoc.util.splitToPair fun main() { val input = readInput("Day09") println(day09part1(input)) println(day09part2(input)) } fun day09part1(input: List<String>): Int { val moves = input.map { it.lineToMovement() } ...
0
Kotlin
0
1
89138e33bb269f8e0ef99a4be2c029065b69bc5c
1,955
advent-of-code-2022
Apache License 2.0
kotlin/graphs/shortestpaths/DijkstraCustomHeap.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.shortestpaths import java.util.stream.Stream // https://en.wikipedia.org/wiki/Dijkstra's_algorithm object DijkstraCustomHeap { // calculate shortest paths in O(E*log(V)) time and O(V) memory fun shortestPaths(edges: Array<List<Edge>>, s: Int, prio: LongArray, pred: IntArray) { Arrays.fi...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,509
codelibrary
The Unlicense
src/Day03.kt
cisimon7
573,872,773
false
{"Kotlin": 41406}
fun main() { fun Char.priority(): Int { return if (this.isLowerCase()) this.code - 96 else this.code - 64 + 26 } fun part1(stringList: List<String>): Int { return stringList .map { rucksack -> rucksack.chunked(rucksack.length / 2) } .flatMap { (compartment1, compart...
0
Kotlin
0
0
29f9cb46955c0f371908996cc729742dc0387017
948
aoc-2022
Apache License 2.0
src/Day25.kt
LauwiMeara
572,498,129
false
{"Kotlin": 109923}
import kotlin.math.pow fun main() { fun getStringLength(decimalSum: Long): Int { var i = 0 while (true) { val place = 5.toDouble().pow(i).toLong() if (place <= decimalSum) { i++ } else { break } } return...
0
Kotlin
0
1
34b4d4fa7e562551cb892c272fe7ad406a28fb69
2,547
AoC2022
Apache License 2.0
src/Day14.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign data class SandPoint(val x: Int = 0, val y: Int = 0) { fun fromString(s: String, separator: String = ","): SandPoint { val (a, b) = s.trim().split(separator) return SandPoint(a.toInt(), b.toInt()) } operator fun plus(ot...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
4,243
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day15.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import kotlin.math.abs import kotlin.math.max class Day15(private val input: List<String>) { private val sensors = parseSensors() fun solvePart1(targetY: Int): Int { val range = coveredRange(targetY) return range.last - range.first } fun solvePar...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,096
advent-of-code
Apache License 2.0
src/main/kotlin/net/rafaeltoledo/kotlin/advent/Day02.kt
rafaeltoledo
726,542,427
false
{"Kotlin": 11895}
package net.rafaeltoledo.kotlin.advent class Day02 { val validRound = Round(red = 12, green = 13, blue = 14) fun invoke(input: List<String>): Int { val games = input.map { it.toGame() } return games.filter { it.isValid() }.sumOf { it.id } } fun invoke2(input: List<String>): Int { val games = in...
0
Kotlin
0
0
7bee985147466cd796e0183d7c719ca6d01b5908
1,602
aoc2023
Apache License 2.0
src/Day03.kt
esteluk
572,920,449
false
{"Kotlin": 29185}
fun main() { fun code(char: Char): Int { return if (char.isLowerCase()) { char.code - 96 } else { char.code - 38 } } fun part1(input: List<String>): Int { val chars = input.map { val length = it.length val co1 = it.substring(0...
0
Kotlin
0
0
5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73
1,124
adventofcode-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/number_of_music_playlists/NumberOfPlaylistsTests.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.number_of_music_playlists import datsok.shouldEqual import org.junit.jupiter.api.Test // // https://leetcode.com/problems/number-of-music-playlists // // Your music player contains N different songs and she wants to listen to L (not necessarily different) songs during your trip. // You c...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,975
katas
The Unlicense
src/test/kotlin/icfp2019/TestUtils.kt
bspradling
193,332,580
true
{"JavaScript": 797310, "Kotlin": 85937, "CSS": 9434, "HTML": 5859}
package icfp2019 import com.google.common.base.CharMatcher import com.google.common.base.Splitter import icfp2019.model.* import org.pcollections.TreePVector import java.nio.file.Paths fun loadProblem(problemNumber: Int): String { val path = Paths.get("problems/prob-${problemNumber.toString().padStart(3, padChar ...
0
JavaScript
0
0
9f7e48cce858cd6a517d4fb69b9a0ec2d2a69dc5
2,605
icfp-2019
The Unlicense
src/twentytwo/Day07.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentytwo import java.util.* fun main() { // test if implementation meets criteria from the description, like: val testInput = readInputLines("Day07_test") println(part1(testInput)) check(part1(testInput) == 95_437) println(part2(testInput)) check(part2(testInput) == 24_933_642) p...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
6,359
advent-of-code-solutions
Apache License 2.0
src/Day02.kt
mlidal
572,869,919
false
{"Kotlin": 20582}
import java.lang.IllegalArgumentException enum class Result { WIN, LOOSE, DRAW; companion object { fun parseResult(name: String) : Result { return when(name) { "X" -> LOOSE "Y" -> DRAW "Z" -> WIN else -> throw IllegalArgumentE...
0
Kotlin
0
0
bea7801ed5398dcf86a82b633a011397a154a53d
3,734
AdventOfCode2022
Apache License 2.0
src/Day07.kt
rmyhal
573,210,876
false
{"Kotlin": 17741}
fun main() { fun part1(input: List<String>): Long { return dirsSize(input) } fun part2(input: List<String>): Long { return dirSizeToDelete(input) } val input = readInput("Day07") println(part1(input)) println(part2(input)) } private fun dirsSize(input: List<String>): Long { return getDirsTre...
0
Kotlin
0
0
e08b65e632ace32b494716c7908ad4a0f5c6d7ef
1,695
AoC22
Apache License 2.0
src/Day04.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
fun main() { fun doesOneRangeContainTheOther(rangeA: IntRange, rangeB: IntRange): Boolean { return rangeA.all { it in rangeB } || rangeB.all { it in rangeA } } fun doRangesHaveAnyValueThatOverlap(rangeA: IntRange, rangeB: IntRange): Boolean { return rangeA.any { it in rangeB } } fu...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
1,147
advent_of_code_2022
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2023/Day5.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2023 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom import kotlin.math.max import kotlin.math.min /** * --- Day 5: If You Give A Seed A Fertilizer --- * https://adventofcode.com/2023/day/5 */ class Day5 : Solver { override fun solve(lines: List<String...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,636
euler
Apache License 2.0
src/day3/Day03.kt
dean95
571,923,107
false
{"Kotlin": 21240}
package day3 import readInput private fun main() { fun part1(input: List<String>): Int { var prioritiesSum = 0 input.forEach { item -> val middle = item.length / 2 val firstRucksack = item.substring(0 until middle).toSet() val secondRucksack = item.substring(mi...
0
Kotlin
0
0
0ddf1bdaf9bcbb45116c70d7328b606c2a75e5a5
1,530
advent-of-code-2022
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day08/TreetopTreeHouse.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day08 import com.barneyb.aoc.util.Solver import com.barneyb.aoc.util.toSlice import com.barneyb.util.Vec2 import kotlin.math.max fun main() { Solver.execute( ::parse, ::visibleTreeCount, ::bestScenicScore, ) } private const val MAX_HEIGHT = 9 internal ...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
2,511
aoc-2022
MIT License
src/Day13.kt
floblaf
572,892,347
false
{"Kotlin": 28107}
fun main() { fun parse(input: String): Packet.Data { if (input.all { it in '0'..'9' }) { return Packet.Data.Single(input.toInt()) } if (input == "[]") { return Packet.Data.Collection() } if (input.startsWith("[")) { var depth = 0 ...
0
Kotlin
0
0
a541b14e8cb401390ebdf575a057e19c6caa7c2a
3,331
advent-of-code-2022
Apache License 2.0
src/Day05.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
import java.util.* import kotlin.collections.ArrayDeque fun main() { fun List<String>.firstBlankIndex(): Int = this.indexOfFirst { it.isBlank() } fun toStacks(input: List<String>, splitIdx: Int): List<Stack<Char>> { //for i in row, if row[i] == num; for j in start-1 downTo 0, if input[j][i] == char; ...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
2,762
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day21.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days typealias Operation = (Day21.LinearFunction, Day21.LinearFunction) -> Day21.LinearFunction class Day21 : Day(21) { override fun partOne(): Any { val monkeys = parseMonkeys().associateBy { it.name } return monkeys.getValue("root").eval(monkeys).b.toLong() } override fun partT...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
3,082
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day13.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private sealed interface Packet private data class ListPacket(val packets: List<Packet>) : Packet private data class IntPacket(val value: Int) : Packet private class PacketParser private constructor(data: String) { private val iterator = data.iterator() private var current: Char = 'd' fun parse(): Packe...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
3,022
advent-of-code-22
Apache License 2.0
src/leetcode_daily_chalange/WordSearch2.kt
faniabdullah
382,893,751
false
null
//Given an m x n board of characters and a list of strings words, return all //words on the board. // // Each word must be constructed from letters of sequentially adjacent cells, //where adjacent cells are horizontally or vertically neighboring. The same letter //cell may not be used more than once in a word. // /...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
3,520
dsa-kotlin
MIT License
year2019/src/main/kotlin/net/olegg/aoc/year2019/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2019.DayOf2019 import java.math.BigInteger /** * See [Year 2019, Day 22](https://adventofcode.com/2019/day/22) */ object Day22 : DayOf2019(22) { override fun first(): Any? { val deckSize = BigInteger.valueOf(100...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,804
adventofcode
MIT License
src/main/kotlin/solutions/CHK/CheckoutSolution.kt
DPNT-Sourcecode
690,804,775
false
{"Kotlin": 16401, "Shell": 2184}
package solutions.CHK data class Product(val price: Int, val offers: List<Offer> = listOf()) data class Offer( val requiredCount: Int, val price: Int, val freeItem: Char? = null, val freeItemCount: Int = 1, val groupItems: List<Char>? = null ) object CheckoutSolution { private var productMap =...
0
Kotlin
0
0
035af07445aefe0270570419abf5b96e8c04b3a0
4,915
CHK-ojzb01
Apache License 2.0
src/Day04.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
import kotlin.math.max import kotlin.math.min fun main() { fun IntRange.contains(other: IntRange) = other.first in this && other.last in this fun IntRange.overlaps(other: IntRange) = max(first, other.first) <= min(last, other.last) fun <T> List<T>.toPair(): Pair<T, T> = if (this.size != 2) throw I...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
1,187
advent-of-code-kotlin-2022
Apache License 2.0
app/src/y2021/day12/Day12PassagePathing.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day12 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle fun main(args: Array<String>) { Day12PassagePathing().solveThem() } @AoCPuzzle(2021, 12) class Day12PassagePathing : AocSolution { override val answers = Answers(samplePart1 = 19, samplePart2 = 103, part1 ...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
2,372
advent-of-code-2021
Apache License 2.0
src/Day04.kt
ajspadial
573,864,089
false
{"Kotlin": 15457}
fun main() { fun getRange(rangeString: String): IntRange { val values = rangeString.split("-") val min = values[0].toInt() val max = values[1].toInt() return min..max } fun part1(input: List<String>): Int { var score = 0 for (lines in input) { v...
0
Kotlin
0
0
ed7a2010008be17fec1330b41adc7ee5861b956b
1,317
adventofcode2022
Apache License 2.0
17/src/main/kotlin/EggNogContainers.kt
kopernic-pl
109,750,709
false
null
import com.google.common.collect.Sets.combinations internal val CONTAINERS = """ 33 14 18 20 45 35 16 35 1 13 18 13 50 44 48 6 24 41 30 42 """.trimIndent().lines().map { it.toInt() } internal const val EXPECTED_VOLUME = 150 internal fun ...
0
Kotlin
0
0
06367f7e16c0db340c7bda8bc2ff991756e80e5b
1,336
aoc-2015-kotlin
The Unlicense
day1/src/main/kotlin/com/lillicoder/adventofcode2023/day1/Day1.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day1 fun main() { val day1 = Day1() val calibrationDocument = CalibrationDocumentParser().parse("input.txt") println("[Part 1] The sum of calibration values is ${day1.part1(calibrationDocument)}.") println("[Part 2] The sum of calibration values is ${day1.part2(c...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
3,513
advent-of-code-2023
Apache License 2.0
src/day04/day04.kt
PS-MS
572,890,533
false
null
package day04 import readInput fun main() { fun String.toIntRange(): IntRange { val (min, max) = this.split("-").map { it.toInt() } return IntRange(min, max) } operator fun IntRange.contains(other: IntRange): Boolean { return (this.min() >= other.min() && this.max() <= other.max()...
0
Kotlin
0
0
24f280a1d8ad69e83755391121f6107f12ffebc0
1,625
AOC2022
Apache License 2.0
src/main/kotlin/Day03.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
class Day03 { fun part1(input: List<String>): Int { return input .map { Rucksack(it) } .flatMap { it.getCompartmentIntersection() } .sumOf { it.toPriorityScore() } } fun part2(input: List<String>): Int { return input .chunked(3) ....
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
1,550
advent-of-code-2022
Apache License 2.0
src/day_5/kotlin/Day5.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
// AOC Day 5 typealias Container = Char typealias ContainerStack = ArrayDeque<Container> typealias StackNumber = Int data class MoveInstruction(val amount: Int, val from: Int, val to: Int) fun Map<StackNumber, ContainerStack>.deepCopy(): Map<StackNumber, ContainerStack> { return toMap().mapValues { ArrayDeque(it...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
2,560
AdventOfCode2022
MIT License
src/Day04.kt
kkaptur
573,511,972
false
{"Kotlin": 14524}
fun main() { fun getRanges(input: List<String>): Pair<List<Int>, List<Int>> = Pair( input[0].split("-").let { IntRange(it[0].toInt(), it[1].toInt()) }.toList(), input[1].split("-").let { IntRange(it[0].toInt(), it[1].toInt()) }.toList() ) fun part1(input: List<String>): Int = input.count { ...
0
Kotlin
0
0
055073b7c073c8c1daabbfd293139fecf412632a
971
AdventOfCode2022Kotlin
Apache License 2.0
src/Day05.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.math.absoluteValue import kotlin.reflect.KType import kotlin.reflect.typeOf import kotlin.streams.toList class Line2D constructor(points: List<List<Int>>) { val support: Pair<Int, Int> val direction: Pair<Int, Int> init { support = Pair(points[0][0], points[0][1]) val tmp = P...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
2,035
advent_of_code21_kotlin
Apache License 2.0
src/main/java/challenges/coderbyte/BoggleSolver.kt
ShabanKamell
342,007,920
false
null
package challenges.coderbyte /* Have the function BoggleSolver(strArr) read the array of strings stored in strArr, which will contain 2 elements: the first element will represent a 4x4 matrix of letters, and the second element will be a long string of comma-separated words each at least 3 letters long, in alphabetical...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
5,959
CodingChallenges
Apache License 2.0
src/Day05.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import java.lang.Long.min import kotlin.math.max private const val EXPECTED_1 = 35L private const val EXPECTED_2 = 46L private class Day05(isTest: Boolean) : Solver(isTest) { val transitions = listOf("seed-to-soil", "soil-to-fertilizer", "fertilizer-to-water", "water-to-light", "light-to-temperature", "temperatur...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,386
advent-of-code-2022
Apache License 2.0
src/year2022/Day08.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 fun main() { fun isVisible(x: Int, y: Int, list: List<List<Int>>): Boolean { if (x == 0 || x == list[y].size - 1 || y == 0 || y == list.size - 1) return true val tree = list[y][x] if ((0 until x).toList().all { list[y][it] < tree }) return true ...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
2,709
adventofcode-kotlin
Apache License 2.0
src/day04/Day04.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day04 import readInput private fun String.toIntRange(): IntRange = IntRange(this.substringBefore('-').toInt(), this.substringAfter('-').toInt()) private fun String.toIntRangePair(): Pair<IntRange, IntRange> = Pair(this.substringBefore(',').toIntRange(), this.substringAfter(',').toIntRange()) private...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
1,633
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day21.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import java.util.concurrent.ConcurrentHashMap sealed class Expression { data class Add(val a:Long, val b: Long) { override fun toString(): String = "$a+$b" } data class Sub(val a:Long, val b: Long) { override fun toString(): String = "$a-$b" } ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,679
aoc-2022-kotlin
Apache License 2.0
src/Day05.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { fun parseStacks(input: List<String>): List<ArrayList<Char>> { val splitIndex = input.indexOf("") val initialLines = input.take(splitIndex - 1).asReversed() val stacksCount = (initialLines[0].length + 1) / 4 val stacks = (0 until stacksCount).map { arrayListOf<Char>() }...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
1,936
AdventOfCode2022
Apache License 2.0
src/Day04.kt
bogdanbeczkowski
572,679,090
false
{"Kotlin": 8398}
fun main() { fun part1(input: List<String>): Int { var count = 0 for (line in input) { val (first, second) = line.split(",") val (firstStart, firstEnd) = first.split("-") val (secondStart, secondEnd) = second.split("-") val firstRange = firstStart.toIn...
0
Kotlin
0
0
03c29c7571e0d98ab00ee5c4c625954c0a46ab00
1,781
AoC-2022-Kotlin
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day12.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 import java.util.PriorityQueue object Day12 { fun part1(input: List<String>): Int = process(input) { map -> map.mapNotNull { (p, char) -> p.takeIf { char == 'S' } } } fun part2(input: List<String>): Int = process(input) { map -> map.mapNotNull { (p, char) -> p.takeIf...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
1,526
advent22
Apache License 2.0
src/main/kotlin/Day09.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { fun part1(input: List<String>, ropeLength: Int = 2): Int { val rope = ropeLength.downTo(1).map { Pair(0, 0) }.toMutableList() return input .asSequence() .map { it.split(" ") } .flatMap { (direction, amount) -> amount.toInt().downTo(1)....
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
4,468
aoc-2022
Apache License 2.0
src/day6/Day06.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day6 import readInput fun main() { fun part1(input: List<String>): Int { val signal = input.first().toCharArray() return List(signal.size) { index -> if (index in (3 until signal.size)) { if (signal.checkDistinct(index, 4)) { return@List inde...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
2,490
AdventOfCode2022
Apache License 2.0
src/main/kotlin/codes/jakob/aoc/solution/Day15.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
@file:Suppress("SameParameterValue") package codes.jakob.aoc.solution import codes.jakob.aoc.shared.Grid import codes.jakob.aoc.shared.UndirectedGraph import codes.jakob.aoc.shared.UndirectedGraph.Vertex object Day15 : Solution() { override fun solvePart1(input: String): Any { val grid: Grid<Int> = Grid(...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
2,578
advent-of-code-2021
MIT License
src/Day10.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
fun main() { val braces = mapOf( '(' to ')', '[' to ']', '{' to '}', '<' to '>', ) val wrongScores = mapOf( ')' to 3, ']' to 57, '}' to 1197, '>' to 25137, ) val autocompleteScores = mapOf( ')' to 1, ']' to 2, ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
1,727
AdventOfCode2021
Apache License 2.0
leetcode-75-kotlin/src/main/kotlin/KidsWithTheGreatestNumberOfCandies.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * There are n kids with candies. * You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, * and an integer extraCandies, denoting the number of extra candies that you have. * * Return a boolean array result of length n, where result[i] is true if, after ...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,870
leetcode-75
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day2.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 2: Dive! */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 2: Dive! ** \n") val diveCommands = readFileAsStringList("/Day2DiveCommands.txt") val finalPositionByDepth = processDiveCommandsByDepth(diveCommands) println("Fin...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
2,408
AdventOfCode2021
MIT License
src/Day19.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import java.util.LinkedList import java.util.Queue import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis fun main() { fun part1(input: List<String>): Int { val blueprints = parseBlueprints(input) return blueprints.sumOf { it.qualityLevel(24) } } fun part2(input: List<Strin...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
10,072
aoc2022
Apache License 2.0
src/main/kotlin/com/lucaszeta/adventofcode2020/day05/day05.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day05 import com.lucaszeta.adventofcode2020.ext.getResourceAsText fun main() { val input = getResourceAsText("/day05/boarding-passes.txt") .split("\n") .filter { it.isNotEmpty() } val seatIds = input .map(::findSeat) .map(::calculateSeatI...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
1,447
advent-of-code-2020
MIT License
src/main/kotlin/days/Day18.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days import java.lang.Integer.max import kotlin.math.abs class Day18 : Day(18) { override fun partOne(): Any { val cubes = inputList.map { it.split(",").map { it.toInt() }.let { Cube(it[0], it[1], it[2]) } } val touchingSurfaces = cubes.flatMap { left -> cubes.mapNotNul...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
2,213
aoc-2022
Creative Commons Zero v1.0 Universal
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day10/Day10.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day10 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { var score = 0 input.forEach{ line -> val stack = ArrayDeque<String>() var mismatchedBracket = "" ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
3,381
AOC
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day09.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 import kotlin.math.abs import kotlin.math.sign object Day09 { fun part1(input: List<String>): Int { var head = Point2d(x = 0, y = 0) val tailPositions = mutableListOf(head) for (next in input) { val (direction, distance) = next.split(" ").let { (a, b) ...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
3,699
advent22
Apache License 2.0
2022/src/day20/day20.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day20 import GREEN import RESET import printTimeMillis import readInput // List of Pair(idx, number) fun mixString( mapOfIdx: MutableList<Pair<Int, Long>>, mixTimes: Int = 1, decryptionKey: Long = 1 ): Long { for (i in 0 until mixTimes) { for (idx in mapOfIdx.indices) { va...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,850
advent-of-code
Apache License 2.0
src/main/kotlin/day19/Day19.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day19 fun solveA(input: List<String>) = input .map { Factory(it) } .sumOf { it.id * it.run(minutes = 24, times = 100000) } fun solveB(input: List<String>) = input .take(3) .map { Factory(it) } .map { it.run(minutes = 32, times = 10000000) } .reduce(Int::times) data class OreRobotBluep...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
4,221
advent-of-code-2022
Apache License 2.0
src/day10/Day10.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day10 import utils.* import kotlin.math.absoluteValue val THRESHOLDS = (20..220 step 40) const val WIDTH = 40 fun getOperations(input: List<String>): List<Pair<Int, Int>> = input.map { line -> val args = line.split(" ") when (args.first()) { "noop" -> Pair(1, 0) ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
1,620
AOC-2022-Kotlin
Apache License 2.0
src/Day01.kt
ktrom
573,216,321
false
{"Kotlin": 19490, "Rich Text Format": 2301}
import java.util.stream.Collectors import java.util.stream.Stream fun main() { fun part1(input: List<String>): Int { val inputWithDelimiter = Stream.concat(input.stream(), Stream.of("")).collect(Collectors.toList()) var maxCalories = 0 var elfCalories = 0 inputWithDelimiter.forEach { foodCalorie -> if (...
0
Kotlin
0
0
6940ff5a3a04a29cfa927d0bbc093cd5df15cbcd
1,733
kotlin-advent-of-code
Apache License 2.0
kotlinP/src/main/java/com/jadyn/kotlinp/leetcode/sort/sort_0.kt
JadynAi
136,196,478
false
null
package com.jadyn.kotlinp.leetcode.sort import com.jadyn.kotlinp.leetcode.thought.merge import java.util.* import kotlin.math.log /** *JadynAi since 3/25/21 */ fun main() { // print("sort ${Arrays.toString(fastSort(arrayOf(3, 1, 9, 10, 7, 5, 4)))}") val array = arrayOf(6, 10, 7, 9, 8, 11) // print("sort $...
0
Kotlin
6
17
9c5efa0da4346d9f3712333ca02356fa4616a904
4,227
Kotlin-D
Apache License 2.0
src/Day15.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
import kotlin.math.absoluteValue fun main() { data class Coordinate(var x: Int, var y: Int) { fun manhattanDistance(other: Coordinate): Int { return (this.x - other.x).absoluteValue + (this.y - other.y).absoluteValue } } val regex = """Sensor at x=(-?\d+), y=(-?\d+): closest be...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
3,960
aoc-2022-kotlin
Apache License 2.0
src/problems/1807-evaluateBracketPairsString.kt
w1374720640
352,006,409
false
null
package problems /** * 1807. 替换字符串中的括号内容 https://leetcode-cn.com/problems/evaluate-the-bracket-pairs-of-a-string/ * * 解:先处理knowledge数组,将所有键值对转换成HashMap中的键值对,方便查找 * 因为括号成对出现且不会出现嵌套,分别使用两个整数记录左括号和右括号的索引 * 以括号中间的内容为键,在HashMap中查找对应的值或'?'符号, * 所有的值用StringBuilder拼接成新的字符串 */ fun evaluateBracketPairsString(s: String, k...
0
Kotlin
0
0
21c96a75d13030009943474e2495f1fc5a7716ad
2,364
LeetCode
MIT License
src/main/kotlin/aoc2021/Day22.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import java.util.* import kotlin.math.max import kotlin.math.min private data class Instruction( val newState: Boolean, val xRange: IntRange, val yRange: IntRange, val zRange: IntRange ) { companion object { fun fromString(input: String): Instruction { ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
6,754
adventOfCode
Apache License 2.0
gcj/y2020/round3/b_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round3 private fun solve(): Int { val (c, n) = readInts() val xIn = readInts() val x = (xIn.map { it - xIn[0] } + c).map { it * 2 } readLn() var maxMask = (1 shl (2 * c + 1)) - 1 for (v in x) maxMask = maxMask xor (1 shl v) var ans = 2 * n var mask = maxMask while (mask > 0) { if (mask.cou...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,459
competitions
The Unlicense
codeforces/round901/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round901 private fun precalc(mask: Int): IntArray { val (a, b, m) = listOf(0x55, 0x33, 0x0F).map { it and mask } val source = a with b val queue = mutableListOf<Int>() val dist = IntArray(1 shl 14) { -1 } queue.add(source) dist[source] = 0 var low = 0 while (low < queue.size) { val v = que...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,561
competitions
The Unlicense
src/Day12.kt
bananer
434,885,332
false
{"Kotlin": 36979}
fun main() { class Cave( val name: String, val connections: MutableSet<Cave> = mutableSetOf() ) { val isStart get() = name == "start" val isEnd get() = name == "end" val isSmall get() = !isStart && !isEnd && name.lowercase() == name...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
3,744
advent-of-code-2021
Apache License 2.0
src/main/kotlin/solutions/Day5SupplyStacks.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Collections import utils.Input import utils.Solution // run only this day fun main() { Day5SupplyStacks() } class Day5SupplyStacks : Solution() { init { begin("Day 5 - Supply Stacks") val input = Input.parseLines(filename = "/d5_crane_procedure.txt") va...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
4,441
advent-of-code-2022
MIT License
src/Day22.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
object Day22 { private enum class MoveDirection { RIGHT, DOWN, LEFT, UP; val opposite: MoveDirection get() = when (this) { UP -> DOWN RIGHT -> LEFT DOWN -> UP LEFT -> RIGHT } fun turn(where: Turn): Mov...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
4,915
aoc2022
Apache License 2.0
src/main/kotlin/Day15.kt
andrewrlee
434,584,657
false
{"Kotlin": 29493, "Clojure": 14117, "Shell": 398}
import java.io.File import java.nio.charset.Charset.defaultCharset import kotlin.streams.toList typealias ChitonGrid = Map<Pair<Int, Int>, Day15.Square> object Day15 { private fun toCoordinates(row: Int, line: String) = line.chars() .map(Character::getNumericValue) .toList() .mapIndexed { ...
0
Kotlin
0
0
aace0fccf9bb739d57f781b0b79f2f3a5d9d038e
4,872
adventOfCode2021
MIT License
year2019/src/main/kotlin/net/olegg/aoc/year2019/day24/Day24.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day24 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Directions.D import net.olegg.aoc.utils.Directions.L import net.olegg.aoc.utils.Directions.R import net.olegg.aoc.utils.Directions.U import net.olegg.aoc.utils.Vec...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,225
adventofcode
MIT License
src/main/kotlin/day23/Day23.kt
Zordid
160,908,640
false
null
package day23 import shared.extractAllInts import shared.measureRuntime import shared.minToMaxRange import shared.readPuzzle import kotlin.math.abs import kotlin.math.max import kotlin.random.Random data class Coordinate3d(val x: Int, val y: Int, val z: Int) { infix fun manhattanDistanceTo(other: Coordinate3d) =...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
4,033
adventofcode-kotlin-2018
Apache License 2.0
src/Day09/Day09.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day09 import readInput fun main() { fun move(position: Pair<Int, Int>, to: String): Pair<Int, Int> { return when (to) { "R" -> position + Pair(1, 0) "L" -> position + Pair(-1, 0) "U" -> position + Pair(0, 1) "D" -> position + Pair(0, -1) ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
3,383
aoc-2022
Apache License 2.0
src/Day03.kt
alexdesi
575,352,526
false
{"Kotlin": 9824}
import java.io.File fun main() { fun priority(item: Char): Int { return if (item.isUpperCase()) item.code - 38 else item.code - 96 } fun part1(input: List<String>): Int { val splittedLines = input.map { Pair( it.substring(0, it.le...
0
Kotlin
0
0
56a6345e0e005da09cb5e2c7f67c49f1379c720d
1,147
advent-of-code-kotlin
Apache License 2.0
src/day03/day04.kt
zoricbruno
573,440,038
false
{"Kotlin": 13739}
package day03 import readInput fun getWrongItem(rucksack: String): Char { val firstPocket = rucksack.take(rucksack.length / 2).toSet() val secondPocket = rucksack.takeLast(rucksack.length / 2).toSet() return firstPocket.intersect(secondPocket).first() } fun getBadge(elf1: String, elf2: String, elf3: Stri...
0
Kotlin
0
0
16afa06aff0b6e988cbea8081885236e4b7e0555
1,251
kotlin_aoc_2022
Apache License 2.0
src/main/kotlin/com/adrielm/aoc2020/solutions/day13/Day13.kt
Adriel-M
318,860,784
false
null
package com.adrielm.aoc2020.solutions.day13 import com.adrielm.aoc2020.common.Solution import org.koin.dsl.module class Day13 : Solution<Day13.Input, Long>(13) { override fun solveProblem1(input: Input): Long { val mods = input.buses.map { input.startingTime % it.number } if (mods.any { it == 0 })...
0
Kotlin
0
0
8984378d0297f7bc75c5e41a80424d091ac08ad0
1,743
advent-of-code-2020
MIT License
src/day07.kt
skuhtic
572,645,300
false
{"Kotlin": 36109}
fun main() { day07.execute(forceBothParts = true) } val day07 = object : Day<Long>(7, 95437, 24933642) { override val testInput: InputData = """ ${'$'} cd / ${'$'} ls dir a 14848514 b.txt 8504156 c.dat dir d ${'$'} cd a ${'$'} ls dir e ...
0
Kotlin
0
0
8de2933df90259cf53c9cb190624d1fb18566868
2,350
aoc-2022
Apache License 2.0
src/Day01.kt
TrevorSStone
573,205,379
false
{"Kotlin": 9656}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 (input + "end").fold(0) { currentElfCalories, calLine -> calLine.toIntOrNull()?.let { currentElfCalories + it } ?: run { if (currentElfCalories > maxCalories) { maxCalories = currentElfCalories ...
0
Kotlin
0
0
2a48776f8bc10fe1d7e2bbef171bf65be9939400
1,547
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day21/Day21.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day21 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day21 : Day { override val input = readInputLines(21).map { Player.from(it) } override fun part1(): Int { var count = 0 val dice = Determi...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,063
aoc2021
MIT License
src/main/kotlin/aoc2021/Day17.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import Point import readInput import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign /** * A path is just a collection of points * @property points the points along this path */ @JvmInline private value class Path(val points: List<Point>) /** * @param vx the initial x vel...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,497
adventOfCode
Apache License 2.0
src/Day05.kt
mrwhoknows55
573,993,349
false
{"Kotlin": 4863}
import java.io.File import java.util.Stack fun main() { val inputPair = getInputPair("src/day05_input.txt") part1(inputPair) } fun part1(inputPair: Pair<List<Stack<Char>>, List<Triple<Int, Int, Int>>>) { val stacks = inputPair.first val inputs = inputPair.second inputs.forEach { for (i in ...
0
Kotlin
0
1
f307e524412a3ed27acb93b7b9aa6aa7269a6d03
1,947
advent-of-code-2022
Apache License 2.0
src/Day02.kt
khongi
572,983,386
false
{"Kotlin": 24901}
sealed class HandGesture { abstract val score: Int abstract val defeats: HandGesture abstract val losesTo: HandGesture } object Rock : HandGesture() { override val score = 1 override val defeats = Scissors override val losesTo = Paper } object Paper : HandGesture() { override val score: In...
0
Kotlin
0
0
9cc11bac157959f7934b031a941566d0daccdfbf
2,111
adventofcode2022
Apache License 2.0
src/Day08.kt
tristanrothman
572,898,348
false
null
import kotlin.math.abs data class Tree( val height: Int, var visible: Boolean = false, var scenicScore: Int = 0 ) typealias Grid = List<List<Tree>> fun main() { val input = readInput("Day08") val testInput = readInput("Day08_test") fun List<String>.toGrid() = this.map { row -> row.map { Tree...
0
Kotlin
0
0
e794ab7e0d50f22d250c65b20e13d9b5aeba23e2
3,075
advent-of-code-2022
Apache License 2.0
src/Day04.kt
jdpaton
578,869,545
false
{"Kotlin": 10658}
fun main() { fun part1() { val testInput = readInput("Day04_test") var fullOverlapCount = 0 val rangeIter = mapToRanges(testInput).iterator() while(rangeIter.hasNext()) { val rangePair = rangeIter.next() val allInOne = rangePair.first.all { t-> rangePair.seco...
0
Kotlin
0
0
f6738f72e2a6395815840a13dccf0f6516198d8e
1,571
aoc-2022-in-kotlin
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day08/day08.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day08 import eu.janvdb.aocutil.kotlin.lcm import eu.janvdb.aocutil.kotlin.readGroupedLines //const val FILENAME = "input08-test1.txt" //const val FILENAME = "input08-test2.txt" //const val FILENAME = "input08-test3.txt" const val FILENAME = "input08.txt" val LINE_REGEX = Regex("(\\S+) = \\(...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,466
advent-of-code
Apache License 2.0
src/main/kotlin/dev/siller/aoc2022/Day12.kt
chearius
575,352,798
false
{"Kotlin": 41999}
package dev.siller.aoc2022 private val example = """ Sabqponm abcryxxl accszExk acctuvwj abdefghi """.trimIndent() data class Coordinates(val x: Int, val y: Int) data class Point( val x: Int, val y: Int, val elevation: Int, val startPoint: Boolean = false, val endPoint: Boolea...
0
Kotlin
0
0
e070c0254a658e36566cc9389831b60d9e811cc5
2,115
advent-of-code-2022
MIT License
kotlin/src/com/s13g/aoc/aoc2021/Day15.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 15: Chiton --- * https://adventofcode.com/2021/day/15 */ class Day15 : Solver { override fun solve(lines: List<String>): Result { val width = lines[0].length val height = lines.size val data = IntArray(li...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,827
euler
Apache License 2.0
src/Day02.kt
bherbst
572,621,759
false
{"Kotlin": 8206}
import java.lang.IllegalArgumentException import kotlin.math.round fun main() { fun parseChoice(char: Char): Choice { return when (char) { 'A', 'X' -> Choice.Rock 'B', 'Y' -> Choice.Paper 'C', 'Z' -> Choice.Scissors else -> throw IllegalArgumentException("In...
0
Kotlin
0
0
64ce532d7a0c9904db8c8d09ff64ad3ab726ec7e
3,726
2022-advent-of-code
Apache License 2.0
src/Day05.kt
sgc109
576,491,331
false
{"Kotlin": 8641}
private const val COMMAND_TEMPLATE = "move (\\d+) from (\\d+) to (\\d+)" fun main() { data class Command( val cnt: Int, val from: Int, val to: Int, val retained: Boolean = false, ) data class Game( val stacks: List<ArrayDeque<Char>>, val commands: List<Comma...
0
Kotlin
0
0
03e4e85283d486430345c01d4c03419d95bd6daa
2,577
aoc-2022-in-kotlin
Apache License 2.0
src/Day03.kt
richardmartinsen
572,910,850
false
{"Kotlin": 14993}
fun main() { fun findDuplicate(first: String, second: String): Char { first.forEach { if (second.contains(it)) { return it } } return 'X' } fun findTriplicate(first: String, second: String, third: String): Char { first.forEach { ...
0
Kotlin
0
0
bd71e11a2fe668d67d7ee2af5e75982c78cbe193
2,056
adventKotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/sorts/MergeSort.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,212
kotlab
Apache License 2.0