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/day02/Day02.kt
rolf-rosenbaum
543,501,223
false
{"Kotlin": 17211}
package day02 import diff import readInput import second fun part1(input: List<String>): Int { val pairs = input.map { it.findPairsAndTriples() } return pairs.count { it.first } * pairs.count { it.second } } fun part2(input: List<String>): String { input.forEach { line -> val similar = input.fi...
0
Kotlin
0
0
dfd7c57afa91dac42362683291c20e0c2784e38e
948
aoc-2018
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day24.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day24() = puzzle(day = 24) { data class Stone(val pos: List<Double>, val vel: List<Double>) val stones = inputLines.map { l -> val (a, b) = l.split(" @ ").map { "-?\\d+".toRegex().findAll(it).map { p -> p.value...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,085
advent-of-code
The Unlicense
src/Day08.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
fun main() { fun toGrid(input: List<String>): List<IntArray> = input.map { line -> line.map { it.digitToInt() }.toIntArray() } fun List<IntArray>.getColumn(index: Int): IntArray = this.map { it[index] }.toIntArray() fun IntArray.toPrintableString(): String = joinToString(",") fun visibleIn(line: IntArray, index: I...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
2,376
advent-of-code-2022
Apache License 2.0
src/Day11.kt
Excape
572,551,865
false
{"Kotlin": 36421}
fun main() { val monkeyRegex = Regex("""Starting items:\s(?<startingItems>.+)\n.+old\s(?<op>.)\s(?<rhs>.+)\n.+by\s(?<mod>\d+)\n.+monkey\s(?<m1>\d+)\n.+monkey\s(?<m2>\d+)""") class Monkey(input: String, val part2: Boolean) { val items: ArrayDeque<Long> private val operation: (old: Long)...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
4,041
advent-of-code-2022
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day12.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay // link to task fun main() { Day12().run() } class Day12 : BaseDay() { override fun task1() : Int { val uniquePaths = CaveGraph(false).getUniquePaths() //uniquePaths.forEach { path -> println(path) } return uniquePaths.size ...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
2,913
advent-of-code
Apache License 2.0
aoc-day14/src/Day14.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.lang.StringBuilder import java.nio.file.Files import java.nio.file.Path object Day14 { val cache: MutableMap<Triple<Char, Char, Int>, Map<Char, Long>> = mutableMapOf() } fun main() { var input: String? = null val instructions = mutableListOf<Instruction>() Files.readAllLines(Path.of("input...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
3,372
adventofcode2021
MIT License
src/main/kotlin/net/navatwo/adventofcode2023/day9/Day9Solution.kt
Nava2
726,034,626
false
{"Kotlin": 100705, "Python": 2640, "Shell": 28}
package net.navatwo.adventofcode2023.day9 import net.navatwo.adventofcode2023.framework.ComputedResult import net.navatwo.adventofcode2023.framework.Solution sealed class Day9Solution : Solution<List<Day9Solution.History>> { data object Part1 : Day9Solution() { override fun solve(input: List<History>): Computed...
0
Kotlin
0
0
4b45e663120ad7beabdd1a0f304023cc0b236255
3,013
advent-of-code-2023
MIT License
src/main/Day11.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day11 import utils.readInput typealias ThrowItem = Pair<Long, Int> val ThrowItem.item get() = first val ThrowItem.target get() = second class Monkey( private var items: List<Long>, private val operation: Long.() -> Long, val divisor: Long, private val whenTrue: Int, private val ...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
3,400
aoc-2022
Apache License 2.0
src/main/kotlin/day20.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day20 import aoc.utils.readInput import kotlin.math.E import kotlin.math.abs fun main() { part2().let { println(it) } } data class Holder(var left: Holder?, var right: Holder?, var move: Long, var originalValue: Long) { override fun toString(): String { return "$move" } } fun part2(): ...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
2,796
adventOfCode2022
Apache License 2.0
common/number/src/main/kotlin/com/curtislb/adventofcode/common/number/Multiples.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.common.number import com.curtislb.adventofcode.common.collection.mapToMap import java.math.BigInteger /** * Returns the largest positive integer that evenly divides both [m] and [n]. * * @throws IllegalArgumentException If either [m] or [n] is negative or 0. */ fun greatestCommon...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
7,856
AdventOfCode
MIT License
kotlin/2021/round-1a/hacked-exam/src/main/kotlin/AnalysisSolution.kt
ShreckYe
345,946,821
false
null
import java.math.BigInteger fun main() { val t = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val (n, q) = readLine()!!.splitToSequence(' ').map { it.toInt() }.toList() val ass = List(n) { val lineInputs = readLine()!!.splitToSequence(' ').toList() lineInputs[0]...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,948
google-code-jam
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day18.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 import kotlin.math.ceil import kotlin.math.floor class Day18(input: List<String>) { private val numbers = input.map(::parse) fun solvePart1(): Int = sum().magnitude() fun solvePart2(): Int = numbers.maxOf { numberA -> numbers.minus(numberA).maxOf { numberB -...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
4,198
advent-of-code
Apache License 2.0
src/Day04.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
class Day04(input: List<String>) { private val data = parseInput(input) fun partOne() = data .filter { (assign1, assign2) -> assign1 contains assign2 || assign2 contains assign1 } .size fun partTwo(): Int = data .filter { (assign1, assign2) -> as...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
1,353
advent-of-code-2022-kotlin
Apache License 2.0
src/Day04.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution04(input: List<String>) { private val sections = input.map { Section(it) } private class Section(line: String) { private var elf1: IntRange private var elf2: IntRange init { val limits = line.split(",", "-").map { it.toInt() } elf1 = IntR...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
959
aoc-2022
Apache License 2.0
src/Day05.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
private typealias Stacks = Array<ArrayDeque<Char>> private typealias Instructions = List<List<Int>> private fun buildStacks(startingPosition: List<String>): Stacks { val numStacks = startingPosition.last().split(" ").last().toInt() val stacks = Stacks(numStacks + 1) { // add one for easier indexing Arr...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
1,569
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/day20/Day20.kt
jacobhyphenated
572,119,677
false
{"Kotlin": 157591}
package com.jacobhyphenated.day20 import com.jacobhyphenated.Day import java.io.File import java.util.* // Donut Maze class Day20: Day<String> { override fun getInput(): String { return this.javaClass.classLoader.getResource("day20/input.txt")!! .readText() } /** * The maze has p...
0
Kotlin
0
0
1a0b9cb6e9a11750c5b3b5a9e6b3d63649bf78e4
13,833
advent2019
The Unlicense
app/src/main/kotlin/day08/Day08.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day08 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 8 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay08Part1, ::solveDay08Part2) } fun solveDay08Part1(input: List<String>): Int { ...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
7,765
advent-of-code-kt
Apache License 2.0
src/Day02.kt
chbirmes
572,675,727
false
{"Kotlin": 32114}
import java.lang.IllegalArgumentException fun main() { fun score1(opponentChoice: Char, ownChoice: Char) = when (Pair(opponentChoice, ownChoice)) { Pair('A', 'X') -> 1 + 3 Pair('A', 'Y') -> 2 + 6 Pair('A', 'Z') -> 3 + 0 Pair('B', 'X') -> 1 + 0 Pa...
0
Kotlin
0
0
db82954ee965238e19c9c917d5c278a274975f26
1,402
aoc-2022
Apache License 2.0
kotlin/2022/round-1a/equal-sum/src/main/kotlin/Solution.kt
ShreckYe
345,946,821
false
null
import kotlin.system.exitProcess fun main() { val t = readLineOrExit()!!.toInt() repeat(t) { testCase() } } fun readLineOrExit() = readLine().also { if (it == "-1") exitProcess(0) } fun testCase() { val nn = readLineOrExit()!!.toInt() val aas = generateAas(nn) println(...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,078
google-code-jam
MIT License
src/main/kotlin/day9.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day9() { val lines: List<String> = readFile("day09.txt") day9part1(lines) day9part2(lines) } fun day9part1(lines: List<String>) { val heightMap = getHeightMap(lines) val lowPoints = getLowPoints(heightMap) val answer = lowPoints.sumOf { heightMap[it.first][it.second] + 1 } println("9...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,893
advent_of_code_2021
MIT License
src/Day04.kt
kent10000
573,114,356
false
{"Kotlin": 11288}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { var count = 0 for (line in input) { val parts = line.split(Regex("[-,]")) val elf1 = Pair(parts.component1().toInt(), parts.component2().toInt()) val elf2 = Pair(parts.component3().toInt...
0
Kotlin
0
0
c128d05ab06ecb2cb56206e22988c7ca688886ad
1,637
advent-of-code-2022
Apache License 2.0
src/stack/LeetCode150.kt
Alex-Linrk
180,918,573
false
null
package stack import java.util.* /** * 根据逆波兰表示法,求表达式的值。 有效的运算符包括 +, -, *, / 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。 说明: 整数除法只保留整数部分。 给定逆波兰表达式总是有效的。换句话说,表达式总会得出有效数值且不存在除数为 0 的情况。 示例 1: 输入: ["2", "1", "+", "3", "*"] 输出: 9 解释: ((2 + 1) * 3) = 9 示例 2: 输入: ["4", "13", "5", "/", "+"] 输出: 6 解释: (4 + (13 / 5)) = 6 示例 3: 输入: ["10"...
0
Kotlin
0
0
59f4ab02819b7782a6af19bc73307b93fdc5bf37
2,476
LeetCode
Apache License 2.0
app/src/main/kotlin/solution/Solution834.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode class Solution834 { @Leetcode(834) class Solution { fun sumOfDistancesInTree(n: Int, edges: Array<IntArray>): IntArray { // we could come up with 2 formulas: // 1. if j is the neighbor of i, distances[i] += distances[j] + # o...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
4,184
leetcode-kotlin
MIT License
src/Day06.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
fun main() { fun part1(input: String, markerLength: Int = 4): Int { var i = markerLength - 1 while (i <= input.lastIndex) { var lastMatch: Int? = null var j = 0 while (lastMatch == null && j < markerLength) { val compareSymbol = input[i - j] ...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
1,533
aoc22-kotlin
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/k_closest_points_to_origin/KClosestPointsToOrigin.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.k_closest_points_to_origin import datsok.shouldEqual import org.junit.Test import kotlin.math.sqrt class KClosestPointsToOriginTests { @Test fun examples() { kClosest(listOf(Point(1, 1), Point(2, 2)), k = 2) shouldEqual setOf(Point(1, 1), Point(2, 2)) kClosest(listOf(...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,499
katas
The Unlicense
src/main/kotlin/day17/Day17.kt
Arch-vile
317,641,541
false
null
package day17 import readFile data class Coordinates(val x: Int, val y: Int, val z: Int, val w: Int) data class Cube(var state: Boolean) { fun stateSymbol(): Char { return if (state) '#' else '.' } } class World { // Let's make world enough to contain everything after 6 rounds of expansion // Also +2 to...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
3,066
adventOfCode2020
Apache License 2.0
src/Day02_part1.kt
rdbatch02
575,174,840
false
{"Kotlin": 18925}
class Move( val representations: List<String>, val points: Int, val beats: String ) { companion object { fun parseMove(input: String): Move { return when(input) { "A" -> rock() "X" -> rock() "B" -> paper() "Y" -> paper(...
0
Kotlin
0
1
330a112806536910bafe6b7083aa5de50165f017
1,905
advent-of-code-kt-22
Apache License 2.0
src/Day01.kt
ajmfulcher
573,611,837
false
{"Kotlin": 24722}
fun main() { fun part1(input: List<String>): Int { var curr = 0 var largest = 0 input.forEach { item -> when (item) { "" -> { if (curr > largest) largest = curr curr = 0 } else -> curr += item...
0
Kotlin
0
0
981f6014b09e347241e64ba85e0c2c96de78ef8a
1,037
advent-of-code-2022-kotlin
Apache License 2.0
2023/src/main/kotlin/day4_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.mapItems import utils.pow2 fun main() { Day4Imp.run(skipTest = false) } object Day4Imp : Solution<List<Day4Imp.Card>>() { override val name = "day4" override val parser = Parser.lines .mapItems { Day4.parseCard(it) } .mapItems { card -> val sz...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,105
aoc_kotlin
MIT License
src/Day05.kt
sungi55
574,867,031
false
{"Kotlin": 23985}
fun main() { val day = "Day05" val testPackages = mapOf<Int, List<String>>( 1 to mutableListOf("N", "Z"), 2 to mutableListOf("D", "C", "M"), 3 to mutableListOf("P") ) val inputPackages = mapOf<Int, List<String>>( 1 to mutableListOf("N", "R", "J", "T", "Z", "B", "D", "F...
0
Kotlin
0
0
2a9276b52ed42e0c80e85844c75c1e5e70b383ee
2,189
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-04.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2022, "04-input") val testInput1 = readInputLines(2022, "04-test1") println("Part1:") part1(testInput1).print...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,038
advent-of-code
MIT License
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day03.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.shared.splitByEach import codes.jakob.aoc.shared.splitInHalf import codes.jakob.aoc.shared.splitMultiline class Day03 : Solution() { override fun solvePart1(input: String): Any { return input .splitMultiline() .asSequence() ...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
1,294
advent-of-code-2022
MIT License
src/Day10.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
private sealed class Instruction { abstract val cycles: Int object Noop : Instruction() { override val cycles: Int get() = 1 } data class Addx(val argument: Int) : Instruction() { override val cycles: Int get() = 2 } } fun main() { fun String.toInstruct...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
2,368
advent-of-code-2022
Apache License 2.0
src/Day05.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
fun main() { fun executeInstructions( input: List<String>, transactionHandling: (map: MutableMap<Int, List<Char>>, amount: Int, from: Int, to: Int) -> Unit, ): Map<Int, List<Char>> { val dividerIndex = input.indexOfFirst { it.isBlank() } val map = input.subList(0, dividerIndex - ...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
2,143
advent-of-code-2022
Apache License 2.0
src/day14/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day14 import day14.Tile.Empty import day14.Tile.Sand import day14.Tile.Wall import util.Grid import util.Point import util.readInput import util.shouldBe import kotlin.math.sign fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 24 testIn...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
3,197
advent-of-code-2022
Apache License 2.0
mpp-library/src/commonMain/kotlin/ru/tetraquark/kotlin/playground/shared/leetcode/FunWithArrays.kt
Tetraquark
378,612,246
false
null
package ru.tetraquark.kotlin.playground.shared.leetcode import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flow import kotlinx.coroutines.runBlocking import kotlin.math.pow fun listWork(list: List<*>) { val anyList = list as List<Any> println("listWork: ${anyList.joinToString()}") } fun main...
0
Kotlin
0
0
bd86209874d438233cc5383cec2e705d5e7d9f83
4,755
KotlinPlayground
Apache License 2.0
src/com/ajithkumar/aoc2022/Day03.kt
ajithkumar
574,372,025
false
{"Kotlin": 21950}
package com.ajithkumar.aoc2022 import com.ajithkumar.utils.* import kotlin.streams.toList fun main() { fun charToPriorityTranslate(char: Int): Int { if(char in 97..122) return char-96 if(char in 65..90) return char-64+26 return 0 } fun findIntersection(spli...
0
Kotlin
0
0
f95b8d1c3c8a67576eb76058a1df5b78af47a29c
1,370
advent-of-code-kotlin-template
Apache License 2.0
src/day11/Day11.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day11 import readString import java.math.BigInteger import java.util.* fun main() { fun part1(input: String): Long { val monkeyList = parseInput(input) repeat(20) { // 20 rounds monkeyList.forEach { monkey -> monkey.inspect(monkeyList) // ea...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
3,613
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day10/Day10.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day10 import runDay import utils.Point fun main() { fun part1(input: List<String>): Int { val counter = Counter(20) input.toInstructions() .fold(Signals(counter::track)) { signals, processor -> signals.processInstruction(processor) } return c...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
3,417
advent-of-code-2022
Apache License 2.0
src/Day03.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private fun compartments(input: List<String>) = input.map { it.trim().chunked(it.length / 2) } private fun groups(input: List<String>) = input.windowed(3, 3) private fun List<List<String>>.intersect() = flatMap { it.map(String::toSet).reduce(Set<Char>::intersect) } private fun Char.toPriority() = if (isLowerCase()) th...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
830
advent-of-code-kotlin
Apache License 2.0
code-sample-kotlin/algorithms/src/main/kotlin/com/codesample/leetcode/medium/1609_even_odd_tree.kt
aquatir
76,377,920
false
{"Java": 674809, "Python": 143889, "Kotlin": 112192, "Haskell": 57852, "Elixir": 33284, "TeX": 20611, "Scala": 17065, "Dockerfile": 6314, "HTML": 4714, "Shell": 387, "Batchfile": 316, "Erlang": 269, "CSS": 97}
package com.codesample.leetcode.medium fun main() { // [5,9,1,3,5,7] -> false val root1 = TreeNode(5); val childLeft1 = TreeNode(9); val childRight1 = TreeNode(1); root1.left = childLeft1; root1.right = childRight1; childLeft1.left = TreeNode(3) childLeft1.right = TreeNode(5) chil...
1
Java
3
6
eac3328ecd1c434b1e9aae2cdbec05a44fad4430
4,333
code-samples
MIT License
src/main/kotlin/adventofcode/year2021/Day08SevenSegmentSearch.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2021 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day08SevenSegmentSearch(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val signalPatterns by lazy { input.lines().map { it.split("|").first().trim().split(" ") } } private val outputValues by lazy...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
3,749
AdventOfCode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FreedomTrail.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <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,021
kotlab
Apache License 2.0
app/src/y2021/day07/Day07TheTreacheryOfWhales.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day07 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle import kotlin.math.abs fun main(args: Array<String>) { Day07TheTreacheryOfWhales().solveThem() } @AoCPuzzle(2021, 7) class Day07TheTreacheryOfWhales : AocSolution { override val answers = Answers(samplePar...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
3,861
advent-of-code-2021
Apache License 2.0
src/pl/shockah/aoc/y2021/Day5.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2021 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.aoc.UnorderedPair import kotlin.math.max import kotlin.math.min class Day5: AdventTask<List<UnorderedPair<Day5.Point>>, Int, Int>(2021, 5) { data class Point( va...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
2,785
Advent-of-Code
Apache License 2.0
app/src/main/java/org/sil/storyproducer/model/WordLinkSearchTree.kt
sillsdev
93,890,166
false
null
package org.sil.storyproducer.model /** * The purpose of this class is to make searching for multi-word wordlinks possible and fast within a larger paragraph of text. * The point of this class is to quickly differentiate between similar wordlinks (ones which begin with the same words). * Example: feast, Feast of Pe...
92
Kotlin
8
3
0220d9acf4aa63b82e6f29655328354265e6cab5
5,734
StoryProducer
MIT License
src/Day24.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
fun main() { fun part1(input: List<String>): Int { val simulation = ValleySimulation(input) return simulation.simulate(simulation.mapStartPoint, simulation.mapEndPoint) } fun part2(input: List<String>): Int { val simulation = ValleySimulation(input) return simulation.simulat...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,631
AdventOfCode2022
Apache License 2.0
src/main/kotlin/aoc2023/Day09.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day09 { fun part1(input: List<String>): Int = predictNextElement(input, isBackward = false) fun part2(input: List<String>): Int = predictNextElement(input, isBackward = true) private fun predictNextElement(input: List<String>, isBackward: Boolean = false): Int { val historie...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
1,379
advent-of-code-2023
MIT License
advent-of-code2015/src/main/kotlin/day5/Advent5.kt
REDNBLACK
128,669,137
false
null
package day5 import chunk import parseInput import splitToLines /** --- Day 5: Doesn't He Have Intern-Elves For This? --- Santa needs help figuring out which strings in his text file are naughty or nice. A nice string is one with all of the following properties: It contains at least three vowels (aeiou only), like...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,574
courses
MIT License
src/Day20.kt
MisterTeatime
560,956,854
false
{"Kotlin": 37980}
import java.math.BigInteger fun main() { fun part1(input: List<String>): Int { val encrypted = input.map { it.toInt() }.mapIndexed { index, i -> index to i } val decrypted = encrypted.toMutableList() encrypted.forEach { (key, steps) -> val index = decrypted.indexOfFirst { it.fi...
0
Kotlin
0
0
8ba0c36992921e1623d9b2ed3585c8eb8d88718e
2,023
AoC2022
Apache License 2.0
2021/src/test/kotlin/Day04.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.test.Test import kotlin.test.assertEquals class Day04 { data class Board constructor(val rows: List<List<Int>>, val cols: List<List<Int>>) { constructor(rows: List<List<Int>>) : this( rows, List(rows.first().size) { index -> rows.map { it[index] } }...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,412
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxRequests.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <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
3,782
kotlab
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1639/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1639 /** * LeetCode page: [1639. Number of Ways to Form a Target String Given a Dictionary](https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/); */ class Solution { private val mod = 1_000_000_007 /* Complexity: * Time O(MN+KN...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,996
hj-leetcode-kotlin
Apache License 2.0
src/Day14.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
import java.lang.Exception import java.lang.Integer.max import java.lang.Integer.min data class Point(val x: Int, val y: Int) data class Line(val p1: Point, val p2: Point) { fun isHorizontal() : Boolean { return p1.x != p2.x && p1.y == p2.y } fun isVertical() : Boolean { return p1.x == p2.x && p1.y != ...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
4,305
AdventOfCode2022
Apache License 2.0
src/aoc2022/Day11.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* import java.rmi.UnexpectedException internal class Day11(val lines: List<String>) { /** Parse the input into a number of monkeys. */ fun parseInputs(): Pair<List<Monkey>, Long> { val monkeys = lines.splitBy { it == "" } // Groups the lines by the blank line. // Map the li...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
3,488
aoc2022
Apache License 2.0
src/main/kotlin/Day8.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
import kotlin.math.max private val exampleInput = """ 30373 25512 65332 33549 35390 """.trimIndent() fun main() { println("day8") println() println("part1") assertEquals(part1(exampleInput), 21) println(part1(readInputFile("day8_input.txt"))) println() println("part...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
3,755
advent_of_code_2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestIncreasingPathInMatrix.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <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,078
kotlab
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day10/Day10.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day10 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day10 : Day { override val input = readInputLines(10) override fun part1() = input.mapNotNull { Line.from(it).illegalPoints() }.sum() override fun pa...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,079
aoc2021
MIT License
app/src/main/java/online/vapcom/codewars/algorithms/Skyscrapers.kt
vapcomm
503,057,535
false
{"Kotlin": 142486}
package online.vapcom.codewars.algorithms /** * #25 7×7 Skyscrapers * * We use universal algorithm for all this katas: *``` * https://www.codewars.com/kata/4-by-4-skyscrapers/ -- 4 kyu * https://www.codewars.com/kata/6-by-6-skyscrapers/ -- 2 kyu * https://www.codewars.com/kata/5917a2205ffc30ec3a0000a8 -- 1 k...
0
Kotlin
0
0
97b50e8e25211f43ccd49bcee2395c4bc942a37a
22,104
codewars
MIT License
src/Day07.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import java.util.* import kotlin.math.min class Directory(val path: String) { val children = mutableListOf<Directory>() var totalSize: Int = 0 } fun main() { fun part1(input: Directory): Int { val rec = input.children.sumOf { part1(it) } return (input.totalSize.takeIf { it < 100000 } ?: 0)...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
1,761
aoc2022-kotlin
Apache License 2.0
src/year2021/11/Day11.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2021.`11` import readInput //private const val NUMBER = 5 private const val NUMBER = 10 private const val ENABLE_LOGS = false private data class Point( val x: Int, val y: Int, ) { override fun toString(): String = "[$x,$y]" } private fun Point.neighbours(): Set<Point> { return setOf( ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
4,681
KotlinAdventOfCode
Apache License 2.0
src/main/kotlin/aoc2015/Day06.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2015 import AoCDay import aoc2015.Day06.Instruction.* import util.illegalInput import util.match // https://adventofcode.com/2015/day/6 object Day06 : AoCDay<Int>( title = "Probably a Fire Hazard", part1ExampleAnswer = 1_000_000 - 1_000 - 4, part1Answer = 400410, part2ExampleAnswer = 1_000_...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,458
advent-of-code-kotlin
MIT License
src/day07/Day07.kt
Puju2496
576,611,911
false
{"Kotlin": 46156}
package day07 import readInput import java.util.* fun main() { // test if implementation meets criteria from the description, like: val input = readInput("src/day07", "Day07") println("Part1") val tree = part1(input) println("Part2") part2(tree) } private fun part1(inputs: List<String>): Node...
0
Kotlin
0
0
e04f89c67f6170441651a1fe2bd1f2448a2cf64e
2,415
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DisjointIntervals.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <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,337
kotlab
Apache License 2.0
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day21AllergenAssessment.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode import java.lang.StringBuilder class Day21AllergenAssessment { private val splitPattern = """([^\(]*)(\(contains\s)([^\)]*)""".toRegex() private data class Food( val allIngredients: MutableMap<String, Int>, val allergenToIngredients: MutableM...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
2,489
BrainSqueeze
Apache License 2.0
src/test/kotlin/amb/aoc2020/day11.kt
andreasmuellerbluemlein
318,221,589
false
null
package amb.aoc2020 import org.junit.jupiter.api.Test import java.util.stream.IntStream.range import kotlin.streams.toList class Spot(val isSeat: Boolean, var isOccupied: Boolean) { override fun toString(): String { return if (!isSeat) "." else if (isOccupied) "#" else "L" } } typealias SpotMap = Lis...
1
Kotlin
0
0
dad1fa57c2b11bf05a51e5fa183775206cf055cf
5,713
aoc2020
MIT License
src/main/kotlin/day19/Day19.kt
Jessevanbekkum
112,612,571
false
null
package day19 import util.readLines val n = Pair(0, -1) val o = Pair(1, 0) val w = Pair(-1, 0) val z = Pair(0, 1) fun day19_1(input: String): Pair<String, Int> { val maze = readMaze(input) val result = mutableListOf<Char>() val startX = maze.indexOfFirst { l -> l[0] != ' ' } var current = Pair(startX,...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
2,059
aoc-2017
Apache License 2.0
src/Day02.kt
aadityaguptaa
572,618,899
false
null
fun main() { fun part1(input: List<String>): Int { var points = mapOf('X' to 1, 'Y' to 2, 'Z' to 3) var draw = mapOf('A' to 'X', 'B' to 'Y', 'C' to 'Z') var loss = mapOf('C' to 'Y', 'A' to 'Z', 'B' to 'X') var score = 0; for(element in input){ var li = elemen...
0
Python
2
10
d76ac48851a9b833fbbd3493a7730f7e0b365da8
1,359
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/day09.kt
josergdev
573,178,933
false
{"Kotlin": 20792}
package days import java.io.File import kotlin.math.abs import kotlin.math.max fun Pair<Int, Int>.moveHead(cmd: Char) = when (cmd) { 'U' -> this.first to this.second + 1 'R' -> this.first + 1 to this.second 'D' -> this.first to this.second - 1 'L' -> this.first - 1 to this.second else -> throw Ill...
0
Kotlin
0
0
ea17b3f2a308618883caa7406295d80be2406260
1,800
aoc-2022
MIT License
2023/src/day15/Day15.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day15 import java.io.File fun main() { val input = File("src/day15/day15.txt").readLines().first().split(",") println(input.sumOf { getHash(it) }) val boxes = getBoxes(input) // println(boxes.map { "${it.boxNumber} ${it.getFocusPower()}" }) println(boxes.sumOf { it.getFocusPower() }) } f...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
1,842
adventofcode
Apache License 2.0
src/Day04.kt
alexdesi
575,352,526
false
{"Kotlin": 9824}
import java.io.File fun main() { val regex = """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() // to group use round parenthesis fun sections(input: List<String>): List<List<Int>> { return input.map { line -> val matchResult = regex.find(line) matchResult!!.groupValues.subList(1, 5).map ...
0
Kotlin
0
0
56a6345e0e005da09cb5e2c7f67c49f1379c720d
1,118
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dp/LConvexS.kt
yx-z
106,589,674
false
null
package dp import util.* // longest convex subsequence // a convex sequence satisfies a[i] - a[i - 1] > a[i - 1] - a[i - 2] fun main(args: Array<String>) { val A = oneArrayOf(1, 4, 8, 13, 14, 18, 19) println(A.lcs()) } fun OneArray<Int>.lcs(): Int { val A = this val n = size // dp[i, j] = len of lcs w/ 1st 2 e...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,243
AlgoKt
MIT License
src/Day02.kt
alexladeira
573,196,827
false
{"Kotlin": 3920}
fun main() { val finalValues = mapOf("X" to 1, "Y" to 2, "Z" to 3) val sum = readInput("Day02").fold(0) { acc, s -> val values = s.split(" ").toMutableList() values[1] = updateSecondValue(values) when { "A" == values[0] && "Z" == values[1] || "C" == values[0] && "Y" == value...
0
Kotlin
0
0
facafc2d92de2ad2b6264610be4159c8135babcb
1,058
aoc-2022-in-kotlin
Apache License 2.0
src/AoC18.kt
Pi143
317,631,443
false
null
import java.io.File fun main() { println("Starting Day 18 A Test 1") calculateDay18PartA("Input/2020_Day18_A_Test1") println("Starting Day 18 A Real") calculateDay18PartA("Input/2020_Day18_A") println("Starting Day 18 B Test 1") calculateDay18PartB("Input/2020_Day18_A_Test1") println("Sta...
0
Kotlin
0
1
fa21b7f0bd284319e60f964a48a60e1611ccd2c3
5,156
AdventOfCode2020
MIT License
src/Day02.kt
kritanta
574,453,685
false
{"Kotlin": 8568}
import java.util.zip.DataFormatException enum class Hand { Rock, Paper, Scissors } enum class CodedHand(val hand: Hand, val handScore: Int) { A(Hand.Rock, 1), B(Hand.Paper, 2), C(Hand.Scissors, 3), X(Hand.Rock, 1), Y(Hand.Paper, 2), Z(Hand.Scissors, 3), } enum class CodedHand2(val score: I...
0
Kotlin
0
0
834259cf076d0bfaf3d2e06d1bc1d5df13cffd6c
2,437
AOC-2022-Kotlin
Apache License 2.0
src/Day04.kt
LesleySommerville-Ki
577,718,331
false
{"Kotlin": 9590}
fun main() { fun part1(input: List<String>): Int { var totalNumber = 0 input.forEach { val split = it.split(",") val start = split[0].split("-")[0].toInt() val end = split[0].split("-")[1].toInt() val array = (start.. end).toList().toMutableSet() ...
0
Kotlin
0
0
ea657777d8f084077df9a324093af9892c962200
1,600
AoC
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day15/Day15.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day15 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.fit import net.olegg.aoc.utils.get import net.olegg.aoc.utils.set import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 202...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,693
adventofcode
MIT License
src/main/kotlin/Day07.kt
zychu312
573,345,747
false
{"Kotlin": 15557}
class Day07 { interface Size { val size: Int } data class File(val path: String, val filename: String, override val size: Int) : Size data class Folder( val path: String, val name: String, val parentFolder: Folder?, var folders: MutableSet<Folder> = mutableSet...
0
Kotlin
0
0
3e49f2e3aafe53ca32dea5bce4c128d16472fee3
4,206
advent-of-code-kt
Apache License 2.0
src/main/kotlin/adventofcode/common/Collections.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.common // Returns every nth element in a list shifted by an optional offset // e.g. listOf(1, 2, 3, 4).everyNth(2, 1) -> listOf(2, 4) inline fun <reified T : Any?> Collection<T>.everyNth(n: Int, offset: Int = 0) = filterIndexed { index, _ -> index % n == offset } // Returns the product of all ele...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,134
AdventOfCode
MIT License
solutions/aockt/y2021/Y2021D22.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import io.github.jadarma.aockt.core.Solution import kotlin.math.absoluteValue object Y2021D22 : Solution { /** Represents a cuboid in 3D space, arranged orthogonally with respect to the axes. */ private data class Cuboid(val xRange: LongRange, val yRange: LongRange, val zRange: LongRange)...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
5,520
advent-of-code-kotlin-solutions
The Unlicense
2016/src/main/java/p2/Problem2.kt
ununhexium
113,359,669
false
null
package p2 import com.google.common.io.Resources import more.Input import p1.Direction import p1.Direction.DOWN import p1.Direction.LEFT import p1.Direction.RIGHT import p1.Direction.UP import kotlin.math.max import kotlin.math.min val keypad = listOf( listOf(1, 2, 3), listOf(4, 5, 6), listOf(7, 8, 9) ).m...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
2,232
adventofcode
The Unlicense
src/Day12.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import java.util.Stack object Day12 { @JvmStatic fun main(args: Array<String>) { fun part1(grid: List<List<GridLetter>>) { val visited = mutableSetOf<GridLetter>() val start = grid.column(0).first { it.c == 'S' } var currList = setOf(start) var step = 0 ...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
5,071
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1401_1500/s1420_build_array_where_you_can_find_the_maximum_exactly_k_comparisons/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1420_build_array_where_you_can_find_the_maximum_exactly_k_comparisons // #Hard #Dynamic_Programming #2023_06_07_Time_153_ms_(100.00%)_Space_36.8_MB_(100.00%) class Solution { fun numOfArrays(n: Int, m: Int, k: Int): Int { var ways = Array(m + 1) { LongArray(k + 1) } var sums = ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,172
LeetCode-in-Kotlin
MIT License
Kotlin for Java Developers. Week 4/Rationals/Task/src/rationals/Rational.kt
vnay
251,709,901
false
null
package rationals import java.math.BigInteger infix fun Int.divBy(r: Int): Rational = Rational(toBigInteger(), r.toBigInteger()) infix fun Long.divBy(r: Long): Rational = Rational(toBigInteger(), r.toBigInteger()) infix fun BigInteger.divBy(r: BigInteger): Rational = Rational(this, r) fun S...
0
Kotlin
0
0
ce638b0272bd5fac80891a669cd17848bf6d0721
3,462
Kotlin-for-Java-Developers
MIT License
src/Day11.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
import java.math.BigInteger import kotlin.math.absoluteValue import kotlin.math.min import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sign import kotlin.math.sqrt fun main() { data class Monkey( val items: MutableList<BigInteger>, val op: (old: BigInteger) -> BigInteger, ...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
4,203
advent-of-code-2022-kietyo
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2018/Day15.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2018 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Point import com.nibado.projects.advent.collect.CharMap import com.nibado.projects.advent.resourceLines object Day15 : Day { val input = resourceLines(2018, 17) fun log(s: String) { //prin...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
6,777
adventofcode
MIT License
src/main/kotlin/_2022/Day16.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun findDistances( valveMap: Map<String, WaterNode>, startNode: String, toVisit: Set<String> ): Map<String, Int> { if (toVisit.isEmpty()) { return emptyMap() } val start = valveMap[startNode]!! va...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,854
advent-of-code
Apache License 2.0
src/net/sheltem/aoc/y2023/Day24.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 suspend fun main() { Day24().run() } class Day24 : Day<Long>(0, 47) { override suspend fun part1(input: List<String>) = input.map { it.toHailstone() }.intersections() override suspend fun part2(input: List<String>) = input.map { it.toHailstone() }.findStone() } private fu...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
4,538
aoc
Apache License 2.0
codeforces/round614/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round614 fun main() { val n = readInt() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (a, b) = readInts().map { it - 1 } nei[a].add(b); nei[b].add(a) } val par = List(n) { IntArray(n) { 0 } } val count = List(n) { IntArray(n) { 1 } } for (root in nei.indices) { fun dfs(...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
971
competitions
The Unlicense
jvm/src/main/kotlin/io/prfxn/aoc2021/day12.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Passage Pathing (https://adventofcode.com/2021/day/12) package io.prfxn.aoc2021 fun main() { val connections = textResourceReader("input/12.txt").readLines().map { ln -> with (ln.split("-")) { first() to last() } } fun getNumPaths(pathSoFar: MutableList<String>, destinati...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
1,845
aoc2021
MIT License
src/day10/Day10.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day10 import readInput import java.util.LinkedList fun main() { fun part1(instructions: List<Instruction>): Int { var signalStrength = 0 var register = 1 var cycle = 0 val queue = LinkedList<Instruction>() queue.addAll(instructions) var nexeCheckCycle = 20 ...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
2,861
advent-of-code-2022
Apache License 2.0
Minimum_Operations_to_Reduce_X_to_Zero_v2.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import kotlin.math.max // [[Java] Detailed Explanation - O(N) Prefix Sum/Map - Longest Target Sub-Array](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero/discuss/935935/Java-Detailed-Explanation-O(N)-Prefix-SumMap-Longest-Target-Sub-Array ) class Solution { fun minOperations(nums: IntArray, x: ...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,368
leetcode
MIT License
src/day1/Day01.kt
blundell
572,916,256
false
{"Kotlin": 38491}
package day1 import readInput fun main() { fun collectElvesCalories(input: List<String>): Map<Int, List<String>> { val caloriesByTotal = mutableMapOf<Int, List<String>>() var elvesCalories = mutableListOf<String>() var runningTotal = 0 for (calories in input) { if (calo...
0
Kotlin
0
0
f41982912e3eb10b270061db1f7fe3dcc1931902
1,701
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/day05/Day05.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day05 import java.io.File fun main() { val data = parse("src/main/kotlin/day05/Day05.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 05 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
2,057
advent-of-code-2022
MIT License
2023/src/main/kotlin/Day14.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day14 { fun part1(input: String): Int { val grid = input.splitNewlines() // Calculates total load *as if* it were tilted north return grid[0].indices.sumOf { x -> var totalLoad = 0 var nextLoad = grid.size grid.indices.forEach { y -> when (grid[y][x]) { '#' -> ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,908
advent-of-code
MIT License
src/main/kotlin/ca/kiaira/advent2023/day7/Day7.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day7 import ca.kiaira.advent2023.Puzzle /** * Solution for Day 7 of the Advent of Code challenge. * This class extends the Puzzle class and is specialized in handling poker hands. * * @author <NAME> <<EMAIL>> * @since December 8th, 2023 */ object Day7 : Puzzle<List<Day7.Hand>>(7) { ...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
3,710
kAdvent-2023
Apache License 2.0
src/adventofcode/blueschu/y2017/day19/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day19 import java.io.File import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day19.txt") .bufferedReader() .use { it.readLines() } } fun main(args: Array<String>) { assertEquals("ABCDEF" to 38, walkMap(listOf( " ...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
2,644
Advent-Of-Code
MIT License
src/Day15.kt
syncd010
324,790,559
false
null
class Day15: Day { private fun convert(input: List<String>) : List<Long> { return input[0].split(",").map { it.toLong() } } data class Direction(val dir: Long, val opposite: Long, val posChange: Position) val dirs = listOf( Direction(1, 2, Position(0, -1)), Direction(2, ...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
3,900
AoC2019
Apache License 2.0
src/Day4.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<Pair<IntRange, IntRange>> { return input.map { val (section1, section2) = it.split(",") section1.toRange("-") to section2.toRange("-") } } fun part1(input: List<String>): Int { val mapped = parse(input) ...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
1,044
advent-of-code-2022
Apache License 2.0
src/Day12.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { val dx = intArrayOf(0, 1, 0, -1) val dy = intArrayOf(1, 0, -1, 0) fun part1(input: List<String>): Int { val n = input.size val m = input[0].length fun inside(p: Pair<Int, Int>): Boolean { val (x, y) = p return x in 0 until n && y in 0 until m ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
3,053
advent-of-code-2022
Apache License 2.0