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/tr/emreone/adventofcode/days/Day14.kt
EmRe-One
434,793,519
false
{"Kotlin": 44202}
package tr.emreone.adventofcode.days object Day14 { class Reindeer(val name: String, val speed: Int, val flyTime: Int, val restTime: Int) { /** * |__fly__|______________rest______________||__fly__|______________rest______________| * |-----------------------seconds-----------------------...
0
Kotlin
0
0
57f6dea222f4f3e97b697b3b0c7af58f01fc4f53
2,215
advent-of-code-2015
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem16/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem16 /** * LeetCode page: [16. 3Sum Closest](https://leetcode.com/problems/3sum-closest/); */ class Solution { /* Complexity: * Time O(N^2) and Space O(N) where N is the size of nums; */ fun threeSumClosest(nums: IntArray, target: Int): Int { val sorted =...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,115
hj-leetcode-kotlin
Apache License 2.0
src/Day15.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.math.BigInteger import java.util.LinkedList import kotlin.math.abs data class Sensor(val x: Int, val y: Int, val bx: Int, val by: Int, val dis: Int) fun main() { val dx = listOf(-1, -1, -1, 0, 0, 1, 1, 1) val dy = listOf(-1, 0, 1, -1, 1, -1, 0, 1) fun toKey(x: Int, y: Int) = "${x}_${y}" fun toPai...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
2,674
aoc-2022-in-kotlin
Apache License 2.0
2021/src/main/kotlin/Day22.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day22(val input: List<String>) { private var instructions = input.map { Instruction(it) } fun solve1(): Long { val reactor = Reactor() return with(-50..50) { instructions.mapNotNull { it.limit(this, this, this) } .forEach { reactor.execute(it) } }.let ...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
4,232
adventofcode-2021-2025
MIT License
common/graph/src/main/kotlin/com/curtislb/adventofcode/common/graph/WeightedGraph.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.common.graph import com.curtislb.adventofcode.common.heap.MinimumHeap /** * A graph consisting of unique nodes of type [V], connected by directed edges with integer weights. */ abstract class WeightedGraph<V> { /** * An edge from one node to another in a weighted graph. ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,706
AdventOfCode
MIT License
src/Day16.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
// I hate this code. Please don't look at it. fun main() { fun calcDistance(valveSource: String, valveDestination: String, valves: Map<String, Valve>): Int { val active = mutableSetOf(TunnelPath(valves[valveSource]!!, 0)) val visited = mutableSetOf<Valve>() while (active.isNotEmpty()) { ...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
9,751
aoc2022
Apache License 2.0
src/Day02.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
private val file = "Day02" private enum class RoundResult(val char: Char, val score: Int) { LOOSE('X', 0), DRAW('Y', 3), WIN('Z', 6); companion object { fun of(char: Char): RoundResult { return values().singleOrNull { it.char == char } ?: throw NoSuchElementException("No element fo...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
1,845
aoc-2022
Apache License 2.0
src/Day04.kt
hottendo
572,708,982
false
{"Kotlin": 41152}
fun main() { fun doCompleteSectionsOverlap(a: String, b: String): Boolean { val firstElvesSections = a.split('-').map { it.toInt() } val secondElvesSections = b.split('-').map { it.toInt() } // Test: first elve's sections completely in second elves sections if(firstElvesSections....
0
Kotlin
0
0
a166014be8bf379dcb4012e1904e25610617c550
2,200
advent-of-code-2022
Apache License 2.0
src/y2022/Day25.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.readInput object Day25 { private fun powersOf(n: Int) = sequence { var p = 1L while (true) { yield(p) p *= n } } private val breaks = powersOf(5).runningFold(0L) { acc, p -> acc + p * 2 }.takeWhile { it < 33078355623611 }.toList() ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,948
advent-of-code
Apache License 2.0
kotlin/problems/src/solution/LeetCodeKt.kt
lunabox
86,097,633
false
{"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966}
package solution import kotlin.math.abs class LeetCodeKt { fun licenseKeyFormatting(S: String, K: Int): String { val chars = S.filter { it != '-' } val buffer = StringBuilder(chars) val step = (chars.length - K).downTo(1).step(K) for (i in step) { b...
0
Kotlin
0
0
cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9
3,762
leetcode
Apache License 2.0
src/Day14.kt
MatthiasDruwe
571,730,990
false
{"Kotlin": 47864}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val rocks = mutableSetOf<Pair<Int, Int>>() input.forEach { row -> row.split(" -> ").map { point -> val x = point.split(",") Pair(x[0].toInt(), x[1].toInt()...
0
Kotlin
0
0
f35f01cea5075cfe7b4a1ead9b6480ffa57b4989
5,717
Advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day19.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser enum class XMAS { X, M, A, S } data class WorkFlowStart(val start: WorkFlow, val accepted: WorkFlow, val rejected: WorkFlow) data class WorkFlow(val name:...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
6,129
aoc-2023
The Unlicense
src/main/kotlin/roundC2021/rockpaperscissors-testset3-solution.kt
kristofersokk
422,727,227
false
null
package roundC2021 fun main() { val days = readLine()!!.toInt() readLine() (1..days).forEach { dayIndex -> val (W, E) = readLine()!!.split(" ").map { it.toInt() } println("Case #$dayIndex: ${getSequence(W, E)}") } } const val SEQUENCE_LENGTH = 60 private fun getSequence(w: Int, e: Int...
0
Kotlin
0
0
3ebd59df60ee425b7af86a147f49361dc56ee38d
3,000
Google-coding-competitions
MIT License
src/main/kotlin/day05/Day05.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day05 import readInput fun main() { class State(val stacks: Array<MutableList<Char>>, val allAtOnce: Boolean) { fun move(num: Int, from: Int, to: Int) { val buffer = ArrayDeque<Char>() repeat(num) { val c = stacks[from].removeLast() if (allA...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
2,237
aoc2022
Apache License 2.0
src/day19/Day19.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
@file:Suppress("MagicNumber") package day19 import readInput fun main() { fun parse(input: List<String>): List<BluePrint> = input.map { line -> val sentences = line.split("""[\.:]""".toRegex()).filter { it.isNotEmpty() }.map { it.trim() } val id = sentences[0].split(" ").last().to...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
6,815
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
Akhunzaada
573,119,655
false
{"Kotlin": 23755}
fun main() { /** A = X = Rock B = Y = Paper C = Z = Scissors Score: 1 for Rock, 2 for Paper, and 3 for Scissors 0 if you lost, 3 if the round was a draw, and 6 if you won S: Selection, R: Result Permutations: S R ...
0
Kotlin
0
0
b2754454080989d9579ab39782fd1d18552394f0
1,880
advent-of-code-2022
Apache License 2.0
src/Day05.kt
orirabi
574,124,632
false
{"Kotlin": 14153}
data class Order(val from: Int, val to: Int, val amount: Int) class Crates() { /* * [J] [B] [T] [M] [L] [Q] [L] [R] [G] [Q] [W] [S] [B] [L] [D] [D] [T] [M] [G] [V] [P] [T] [N] [N] [N] [D] [J] [G] [N] [W] [H] [H] [S] [C] [N] [R] [W] [D] [N] [P] [P] [W] [H]...
0
Kotlin
0
0
41cb10eac3234ae77ed7f3c7a1f39c2f9d8c777a
2,518
AoC-2022
Apache License 2.0
src/main/kotlin/Day05.kt
ripla
573,901,460
false
{"Kotlin": 19599}
object Day5 { class Command(val amount: Int, val from: Int, val to: Int) private val commandRegex = Regex("""\d+""") fun part1(input: List<String>): String { val (commandLines, rest) = input.partition { it.startsWith("move") } val stackLines = rest.dropLast(2); val numberOfStacks...
0
Kotlin
0
0
e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8
3,052
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/sk/todo-revise/1531. String Compression II.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.`todo-revise` class Solution1531 { fun getLengthOfOptimalCompression(str: String, k: Int): Int { fun calcLen(len: Int): Int { return when { len == 0 -> 0 len == 1 -> 1 len < 10 -> 2 len < 100 -> 3 el...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,934
leetcode-kotlin
Apache License 2.0
src/main/kotlin/days/Day4.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days class Day4 : Day(4) { private val numbers = inputList.first().split(",").map { it.toInt() } override fun partOne(): Any { return winningBoardSet(true).find { it.winningNumber != null }?.score() ?: 0 } override fun partTwo(): Any { return winningBoardSet(false).maxByOrNul...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
1,869
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/java/com/booknara/problem/graph/EvaluateDivisionKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.graph /** * 399. Evaluate Division (Medium) * https://leetcode.com/problems/evaluate-division/ */ class EvaluateDivisionKt { // T:O(v+e), S:O(v+e) fun calcEquation(equations: List<List<String>>, values: DoubleArray, queries: List<List<String>>): DoubleArray { // build a graph fo...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,969
playground
MIT License
src/adventofcode/blueschu/y2017/day24/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day24 import java.io.File import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day24.txt") .bufferedReader() .use { it.readLines() } } fun main(args: Array<String>) { val exampleSegments = listOf( "0/2", "...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
2,586
Advent-Of-Code
MIT License
src/Day07.kt
flexable777
571,712,576
false
{"Kotlin": 38005}
import java.util.* fun main() { data class File( val name: String, val size: Long, ) data class Folder( val name: String, val folders: MutableSet<Folder> = mutableSetOf(), val files: MutableSet<File> = mutableSetOf(), ) fun Folder.size(): Long { va...
0
Kotlin
0
0
d9a739eb203c535a3d83bc5da1b6a6a90a0c7bd6
3,152
advent-of-code-2022
Apache License 2.0
Array/cuijilin/Array0604.kt
JessonYue
268,215,243
false
null
package luge /* 2020.06.4 面试题 10.01. 合并排序的数组 //https://leetcode-cn.com/problems/sorted-merge-lcci/ 给定两个排序后的数组 A 和 B,其中 A 的末端有足够的缓冲空间容纳 B。 编写一个方法,将 B 合并入 A 并排序。 初始化 A 和 B 的元素数量分别为 m 和 n。 示例: 输入: A = [1,2,3,0,0,0], m = 3 B = [2,5,6], n = 3 输出: [1,2,2,3,5,6] 说明: A.length == n + m*/ fun main() { var arra...
0
C
19
39
3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79
1,240
LeetCodeLearning
MIT License
src/Day18.kt
palex65
572,937,600
false
{"Kotlin": 68582}
@file:Suppress("PackageDirectoryMismatch") package day18 import readInput data class Cube(val x: Int, val y: Int, val z: Int) fun Cube.connected(c: Cube) = x == c.x && y == c.y && (z == c.z-1 || z == c.z+1) || y == c.y && z == c.z && (x == c.x-1 || x == c.x+1) || z == c.z && x == c.x && (y == c.y-1 || y ...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
2,114
aoc2022
Apache License 2.0
src/main/year_2017/day23/day23.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package year_2017.day23 import readInput import second val registers = mutableMapOf( 'a' to 0, 'b' to 0, 'c' to 0, 'd' to 0, 'e' to 0, 'f' to 0, 'g' to 0, 'h' to 0, ) fun part1(input: List<String>): Int { val instructions = input.map(String::toInstruction) return runInstructio...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,318
aoc-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day12.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.Day fun main() = Day12.run() private const val VST = "visitedSmallCaveOnce" object Day12 : Day(2021, 12) { override fun part1(): Any { val paths = input.lines() .flatMap { listOf(it.split("-")[0] to it.split("-")[1], it.split("-"...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,514
adventofkotlin
MIT License
src/Day08/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day08 import readInput fun main() { fun parseInput(input: List<String>) : List<List<Int>> { return input.map { line -> line.map { it.digitToInt() } } } fun isVisible1D(input: List<Int>, targetIndex: Int) : Boolean { if(targetIndex == 0 || targetIndex == input....
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
3,109
aoc-2022
Apache License 2.0
kotlin/15.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
class Day15 : Day<Graph<Pair<Int, Int>>>("15") { override fun dataStar1(lines: List<String>): Graph<Pair<Int, Int>> { val arr = TwoDimensionalArray(lines.ints("")) val edges = arr.map2DIndexed { row, col, _ -> arr.getHorizontalAndVerticalNeighbors(row, col) .map { neighbo...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
1,952
advent-of-code-2021
MIT License
src/Day02.kt
riFaulkner
576,298,647
false
{"Kotlin": 9466}
fun main() { fun part1(input: List<String>): Int { val scorePerRound = input.map {round -> val opponentChoice = getChoiceValue(round.subSequence(0, 1).toString()) val myChoice = getChoiceValue(round.subSequence(2,3).toString()) scoreRound(opponentChoice, myChoice) ...
0
Kotlin
0
0
33ca7468e17c47079fe2e922a3b74fd0887e1b62
2,797
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2020/Day16.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day16 : AdventDay(2020, 16) { val rangesReg = """(\d+)-(\d+)""".toRegex() companion object { @JvmStatic fun main(args: Array<String>) { val day = Day16() report...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,838
adventofcode
MIT License
src/Day14.kt
karloti
573,006,513
false
{"Kotlin": 25606}
import kotlin.math.absoluteValue import kotlin.math.sign class Day14(private val input: Sequence<String>) { private val String.numbers get() = Regex("(\\d+)").findAll(this).map { it.groupValues[1].toInt() } private val directions = listOf(Point(0, 1), Point(-1, 1), Point(1, 1)) val yLine by lazy { initCoor...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
1,956
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day11.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import com.dvdmunckhof.aoc.toDeque class Day11(private val input: List<String>) { fun solvePart1() = solve(20, false) fun solvePart2() = solve(10_000, true) fun solve(rounds: Long, alternativeLevelManagement: Boolean): Long { val monkeys = input.windowed(6,...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,891
advent-of-code
Apache License 2.0
src/main/kotlin/Day4.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
const val SIZE = 5 typealias BingoGame = Pair<List<Int>, MutableList<Board>> private fun make(lines: List<String>): BingoGame { val numbers = lines[0].split(",").map { it.toInt() } val boards = mutableListOf<Board>() var line = 2 while (line < lines.size) { boards.add( Board.crea...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
2,442
AOC2021
Apache License 2.0
src/Day07.kt
rdbatch02
575,174,840
false
{"Kotlin": 18925}
import java.util.* interface FileSystemObject { val name: String } fun main() { data class File( override val name: String, val size: Int ): FileSystemObject data class Directory( override val name: String, val contents: MutableMap<String, FileSystemObject> = mutableMapO...
0
Kotlin
0
1
330a112806536910bafe6b7083aa5de50165f017
4,278
advent-of-code-kt-22
Apache License 2.0
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day21/Day21.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2020.day21 import eu.janvdb.aocutil.kotlin.MatchFinder import eu.janvdb.aocutil.kotlin.readLines val INGREDIENT_LIST_REGEX = Regex("([^()]+) \\(contains ([^()]+)\\)") fun main() { val recipes = readRecipes() val ingredients = recipes.getIngredients().toList() val allergens = recipes.getAllerg...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,682
advent-of-code
Apache License 2.0
src/main/kotlin/algo/expert/solutions/medium/MinCoinsForChange.kt
swstack
329,129,910
false
null
package algo.expert.solutions.medium import java.lang.Integer.min // Solution: Dynamic programming fun minNumberOfCoinsForChange(n: Int, denoms: List<Int>): Int { val coins = IntArray(n + 1) { -1 } coins[0] = 0 for (d in denoms.sorted()) { for (i in 1 until coins.size) { if (d <= i) {...
0
Kotlin
0
0
3ddad9724ed022d87a47a664b4c87f37cac0b61f
2,599
algo-expert-solutions
MIT License
src/main/kotlin/day18.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.getText fun main() { val input = getText("day18.txt") println(day18A(input)) println(day18B(input)) } fun day18A(input: String): Int { val grid = input.lines().map { line -> line.split(",").map { it.toInt() }.let { XYZ(it[0], it[1], it[2]) } } return grid.sumOf { ...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
1,744
AdventOfCode2022
MIT License
gcj/y2022/round3/c_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2022.round3 private fun solve(letters: String = "ACDEHIJKMORST"): String { val n = readInt() val exits = List(2) { readInts().map { it - 1 } } val dist1 = List(n) { v -> listOf(exits[0][v], exits[1][v]) } val dist2 = List(n) { v -> val d1 = dist1[v]; dist1[d1[0]] + dist1[d1[1]] } val dist12 = List(n)...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
982
competitions
The Unlicense
puzzles/kotlin/src/tan-network/tan-network.kt
charlesfranciscodev
179,561,845
false
{"Python": 141140, "Java": 34848, "Kotlin": 33981, "C++": 27526, "TypeScript": 22844, "C#": 22075, "Go": 12617, "JavaScript": 11282, "Ruby": 6255, "Swift": 3911, "Shell": 3090, "Haskell": 1375, "PHP": 1126, "Perl": 667, "C": 493}
import java.util.Scanner import java.util.Stack fun main(args : Array<String>) { val network = Network() network.readGameInput() network.solve() } class Stop(val id: String, val fullName: String, val latitude: Double, val longitude: Double) { val routes = ArrayList<String>() fun distance(other: Stop): Doub...
0
Python
19
45
3ec80602e58572a0b7baf3a2829a97e24ca3460c
4,013
codingame
MIT License
src/com/github/crunchynomnom/aoc2022/puzzles/Day08.kt
CrunchyNomNom
573,394,553
false
{"Kotlin": 14290, "Shell": 518}
package com.github.crunchynomnom.aoc2022.puzzles import Puzzle import java.io.File import java.lang.Integer.max class Day08 : Puzzle() { private lateinit var forest: List<List<Tree>> override fun part1(input: File) { forest = input.readLines().map { x -> x.map { Tree(it.code) }.toList()} for...
0
Kotlin
0
0
88bae9c0ce7f66a78f672b419e247cdd7374cdc1
3,171
advent-of-code-2022
Apache License 2.0
src/Day12.kt
Totwart123
573,119,178
false
null
fun main() { data class Node( var visited:Boolean = false, val height:Int = -1, var distance: Int = Int.MAX_VALUE, val neighbors: MutableList<Node> = mutableListOf() ) fun visitNext(nodeList: List<List<Node>>){ val node = nodeList.flatten().filter { !it.visited && it...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
3,594
AoC
Apache License 2.0
src/Day05.kt
MT-Jacobs
574,577,538
false
{"Kotlin": 19905}
import java.util.Queue fun main() { fun part1(input: List<String>): String { return getJob(input).run { instructions.map { it.run { repeat(count) { stacks[destIndex].addFirst(stacks[sourceIndex].removeFirst()) } } } sta...
0
Kotlin
0
0
2f41a665760efc56d531e56eaa08c9afb185277c
2,598
advent-of-code-2022
Apache License 2.0
src/day23/Day23.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day23 import containsAny import readInput enum class Direction(val vec: Position) { N(Position(-1, 0)), NE(Position(-1, 1)), E(Position(0, 1)), SE(Position(1, 1)), S(Position(1, 0)), SW(Position(1, -1)), W(Position(0, -1)), NW(Position(-1, -1)); companion object { /...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
7,471
aoc-2022
Apache License 2.0
src/Day08.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day08_test") check(part1(testInput) == 21) check(part2(testInput) == 8) val input = readInput("Day08") println(part1(input)) println(part2(input)) } private fun part1(input: List<St...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
3,267
aoc-2022
Apache License 2.0
src/Day02.kt
kent10000
573,114,356
false
{"Kotlin": 11288}
import java.lang.Exception import kotlin.math.abs fun main() { //rock //paper fun determineWinner(player1: Hand, player2: Hand): Int { //Paper Beats Rock Beats Scissors Beats Paper if (player1 == player2) { return 0 } //Draw if (player1.ordinal + 1 == player2.ordinal || (player1.ordina...
0
Kotlin
0
0
c128d05ab06ecb2cb56206e22988c7ca688886ad
2,748
advent-of-code-2022
Apache License 2.0
src/day5/Day05.kt
Johnett
572,834,907
false
{"Kotlin": 9781}
package day5 import readInput fun main() { fun rearrangeCrates(isCrateMover9001: Boolean, values: List<String>): String { val crateValues = values.takeWhile { createValue -> createValue.contains("[") }.map { it.replace("[", "") .replace("]", "") ...
0
Kotlin
0
1
c8b0ac2184bdad65db7d2f185806b9bb2071f159
2,150
AOC-2022-in-Kotlin
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec21.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec21 : PuzzleDayTester(21, 2020) { override fun part1(): Any = parse().let { inputLines -> foodPoisioningMap(inputLines).let { poisoning -> val badIngredients = poisoning.values // remove all the b...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,762
advent-of-code
MIT License
src/Day12.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
private class Highmap( val area: List<List<Int>>, val startPosition: Position, val endPosition: Position ) { val width: Int get() = area[0].size val height: Int get() = area.size fun elevationAt(pos: Position): Int { return area[pos.y][pos.x] } fun hasPathBetwee...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
3,276
aoc22-kotlin
Apache License 2.0
src/year_2022/day_11/Day11.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_11 import readInput import java.math.BigInteger data class Monkey( val id: Int, val items: MutableList<Int>, val operation: List<String>, val divisibleBy: Int, val whenTrue: Int, val whenFalse: Int ) { var inspectionCount: Long = 0 /** * @return pair of worr...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
4,704
advent_of_code
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2019/Day12.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2019 import com.s13g.aoc.Result import com.s13g.aoc.Solver import kotlin.math.abs /** https://adventofcode.com/2019/day/12 */ class Day12 : Solver { override fun solve(lines: List<String>): Result { val planetsA = lines.map { parse(it) } (1..1000).forEach { _ -> step(planetsA) } ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,511
euler
Apache License 2.0
src/Day02.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
fun main() { fun gameResult(yourMove: HandShape, opponentMove: HandShape) = when (yourMove) { opponentMove.greater() -> GameResult.WIN opponentMove.lower() -> GameResult.LOSS else -> GameResult.DRAW } fun part1(input: List<Pair<HandShape, HandShape>>): Int { ...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
2,725
advent-of-code
Apache License 2.0
src/aoc2023/Day2.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2023 import utils.checkEquals import utils.readInput fun main(): Unit = with(Day2) { part1(testInput).checkEquals(8) part1(input) .checkEquals(2176) // .sendAnswer(part = 1, day = "2", year = 2023) part2(testInput).checkEquals(2286) part2(input) .checkEquals(63700) ...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,030
Kotlin-AOC-2023
Apache License 2.0
src/main/java/com/ncorti/aoc2021/Exercise09.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 object Exercise09 { private fun getInput(): List<List<Int>> = getInputAsTest("09") { split("\n") }.map { line -> line.toCharArray().map { it.digitToInt() } } private fun List<List<Int>>.isALowerPoint(i: Int, j: Int): Boolean = (i == 0 || this[i][...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
2,269
adventofcode-2021
MIT License
src/main/java/dev/haenara/mailprogramming/solution/y2020/m02/d23/Solution200223.kt
HaenaraShin
226,032,186
false
null
package dev.haenara.mailprogramming.solution.y2020.m02.d23 import dev.haenara.mailprogramming.solution.Solution /** * 매일프로그래밍 2020. 02. 23 * * M x N 크기의 양의 정수 매트릭스와 비용(cost)가 주어졌을 때, * 주어진 비용으로 매트릭스의 시작 위치 (0, 0)에서 마지막 위치 (M-1, N-1)까지 도달하는 경로의 수를 구하시오. * 매트릭스에서 이동한 경로의 비용은 거쳐간 셀 값의 합이다. * 매트릭스에서는 오직 오른쪽 한 칸 또는 ...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
1,891
MailProgramming
MIT License
src/main/kotlin/Day2.kt
corentinnormand
725,992,109
false
{"Kotlin": 40576}
class Day2 : Aoc("day2.txt") { override fun one() { val input = readFile("day2.txt").lines() val result = input.asSequence().map { it.split(":") } .map { s -> val second = s[1].split(';') .map { str -> str.split(",") } .map { str ...
0
Kotlin
0
0
2b177a98ab112850b0f985c5926d15493a9a1373
1,838
aoc_2023
Apache License 2.0
src/Day05.kt
frungl
573,598,286
false
{"Kotlin": 86423}
fun main() { fun parseStacks(i: List<String>): MutableList<MutableList<String>> { val tmp = i.map { it.padEnd(i.last().length, ' ') .chunked(1) .filterIndexed { index, _ -> index % 4 == 1 } }.dropLast(1) val res = MutableList<MutableList<String>>(t...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,107
aoc2022
Apache License 2.0
2021/src/main/kotlin/day5_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Segment import kotlin.math.abs import kotlin.math.roundToInt import utils.Parser import utils.Solution import utils.mapItems fun main() { Day5Fast.run() } object Day5All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day5Func, "imp" to Day5Imp, "fast" to Day5Fast).forEach { (header,...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,716
aoc_kotlin
MIT License
aoc2022/day7.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval import java.lang.Integer.min fun main() { Day7.execute() } object Day7 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: Dir): Int = calcCumula...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
3,627
Advent-Of-Code
MIT License
src/Day08.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
typealias MyPair = Pair<Boolean, Int> class Field(val f: (MyPair, MyPair, MyPair, MyPair) -> Int): Iterable<Int> { val field: MutableList<List<Int>> = mutableListOf() override fun iterator(): Iterator<Int> { return object : Iterator<Int> { var col = -1 var row = 0 o...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,061
aoc2022
Apache License 2.0
2023/src/main/kotlin/Day02.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import Color.BLUE import Color.GREEN import Color.RED private enum class Color { RED, GREEN, BLUE } private typealias Cubes = Map<Color, Int> private data class Game(val num: Int, val draws: List<Cubes>) object Day02 { fun part1(input: String): Int { return input.splitNewlines() .map { parseGame(it) ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,652
advent-of-code
MIT License
aoc2023/day4.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval import kotlin.math.pow fun main() { Day4.execute() } private object Day4 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<ScratchCard>):...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
2,343
Advent-Of-Code
MIT License
kotlin/src/katas/kotlin/leetcode/magic_square/MagicSquare.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.magic_square import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/341295/Google-or-Online-Assessment-2019-or-Fill-Matrix */ class MagicSquareTests { @Test fun `find magic square of size n`() { magicSquare(size = 2) shouldEqua...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,101
katas
The Unlicense
untitled/src/main/kotlin/Day2.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
class Day2(private val fileName: String) : AocSolution { override val description: String get() = "Day 2 - Rock Paper Scissors ($fileName)" private val input = InputReader(fileName).lines override fun part1() = input.sumOf { rpsScore(it) } override fun part2() = input.sumOf { rpsStrategicScore(it) } } ...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
1,990
adventofcode2022-kotlin
The Unlicense
src/2022/Day04.kt
bartee
575,357,037
false
{"Kotlin": 26727}
fun main () { fun createRangeFromDelimiters(it: String) : List<Int> { val borders = it.split("-") val list = mutableListOf<Int>() for (i in borders[0].toInt().rangeTo(borders[1].toInt())) { list.add(i) } return list } fun isOverlapping(list1: List<Int>, list2: List<Int>): Boolean { ...
0
Kotlin
0
0
c7141d10deffe35675a8ca43297460a4cc16abba
2,733
adventofcode2022
Apache License 2.0
src/Day11.kt
mvanderblom
573,009,984
false
{"Kotlin": 25405}
val operations = mapOf( "+" to {a: Long, b: Long -> a + b}, "*" to {a: Long, b: Long -> a * b} ) data class ItemForMonkey(val item: Long, val monkey: Int) class Monkey( val items: MutableList<Long>, val operation: String, val divisibleBy: Long, val trueMonkeyIndex: Int,...
0
Kotlin
0
0
ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690
3,522
advent-of-code-kotlin-2022
Apache License 2.0
src/l_sieve/CountSemiprimes.kts
HungUnicorn
219,005,946
false
null
package l_sieve import kotlin.math.pow import kotlin.math.sqrt fun solution(N: Int, P: IntArray, Q: IntArray): IntArray { if (P.size != Q.size || P.isEmpty() || Q.isEmpty()) { return emptyList<Int>().toIntArray() } if (N <= 3) { val zeros = Array(P.size) { 0 } return zeros.toIntAr...
0
Kotlin
1
10
e53167d4db538a963af8de1be7038380577ea2e6
2,170
Kotlin-Solution-for-Codility-Lesson
MIT License
src/day08/Day08.kt
iulianpopescu
572,832,973
false
{"Kotlin": 30777}
package day08 import readInput import kotlin.math.max private const val DAY = "08" private const val DAY_TEST = "day${DAY}/Day${DAY}_test" private const val DAY_INPUT = "day${DAY}/Day${DAY}" fun main() { fun isTreeVisible(i: Int, j: Int, input: List<String>): Boolean { if (i == 0 || j == 0 || i == input.l...
0
Kotlin
0
0
4ff5afb730d8bc074eb57650521a03961f86bc95
3,840
AOC2022
Apache License 2.0
src/Day20/Day20.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
fun Array<Array<Boolean>>.print() { for (row in this) { row.print() } } fun Array<Boolean>.print() { for (e in this) { print(if (e) "#" else ".") } println() } fun Boolean.toInt() = if (this) 1 else 0 fun main() { val paddingSize = 200 fun preprocess(input: List<String>):...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
2,670
advent-of-code-2021
Apache License 2.0
src/problems/day7/part1/part1.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day7.part1 import java.io.File private const val inputFile = "input/day7/input.txt" //private const val testFile = "input/day7/test.txt" fun main() { val scoreSum = File(inputFile).bufferedReader().useLines { sumScores(it) } println("Sum of scores is $scoreSum") } private fun sumScores(line...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
2,743
aoc2023
MIT License
src/Day09.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
import kotlin.math.abs import kotlin.math.sign enum class Direction { U, D, L, R; } class Instruction(val direction: Direction, val distance: Int) data class Position(val x: Int, val y: Int) fun List<Instruction>.calculateTailVisitedPositionCount(ropeLength: Int = 2): Int { assert(ropeLength > 1) val t...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
3,512
aoc-2022
Apache License 2.0
src/main/kotlin/pub/edholm/aoc2017/day2/Checksum.kt
Edholm
112,762,269
false
null
package pub.edholm.aoc2017.day2 import pub.edholm.aoc2017.utils.getInputForDay fun main(args: Array<String>) { val inputForDay2 = getInputForDay(2) val matrix = buildMatrix(inputForDay2) val checksum = Checksum() println("Day 2:") println(" Part I: ${checksum.calculatePartOne(matrix)}") println(" Part ...
0
Kotlin
0
3
1a087fa3dff79f7da293852a59b9a3daec38a6fb
1,737
aoc2017
The Unlicense
src/Day03.kt
hoppjan
573,053,610
false
{"Kotlin": 9256}
fun main() { val testLines = readInput("Day03_test") val testResult1 = part1(testLines) println("test part 1: $testResult1") check(testResult1 == 157) val testResult2 = part2(testLines) println("test part 2: $testResult2") check(testResult2 == 70) val lines = readInput("Day03") ...
0
Kotlin
0
0
f83564f50ced1658b811139498d7d64ae8a44f7e
1,140
advent-of-code-2022
Apache License 2.0
gcj/y2020/round1b/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1b private fun greedy(init: List<Int>): String { var a = init val moves = mutableListOf<String>() while (a.zipWithNext().any { it.first > it.second }) { val pairs = mutableMapOf<Int, Pair<Int, Int>>() loop@for (i in 1 until a.size) for (j in i + 1 until a.size) { val score = sequenceOf...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,024
competitions
The Unlicense
src/main/kotlin/io/github/aarjavp/aoc/day03/Day03.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day03 import io.github.aarjavp.aoc.readFromClasspath class Day03 { data class PowerConsumption(val gammaRate: Int, val epsilonRate: Int) { val value = gammaRate * epsilonRate } fun calculatePowerConsumption(diagnostic: Sequence<String>, bits: Int): PowerConsumption {...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
2,620
advent-of-code-2021
MIT License
src/day02/day02.kt
PS-MS
572,890,533
false
null
package day02 import readInput sealed class RockPaperScissors(val value: Int) { abstract infix fun beats(other: RockPaperScissors): Boolean abstract fun fixResult(x: String): RockPaperScissors? class Rock : RockPaperScissors(1) { override fun beats(other: RockPaperScissors): Boolean { ...
0
Kotlin
0
0
24f280a1d8ad69e83755391121f6107f12ffebc0
2,933
AOC2022
Apache License 2.0
src/main/kotlin/adventofcode/day2/Day2.kt
SanderSmee
160,828,336
false
null
package adventofcode.day2 import java.io.File /** * */ fun main(args: Array<String>) { val input = File(ClassLoader.getSystemResource("day-02-input.txt").file).readLines() // part 1 val (twos, threes, checksum) = calculateChecksum(input) println("$twos x $threes = $checksum") // part 2 val...
0
Kotlin
0
0
e5fc4aef3b4fc635d04335062585da5c1e810555
2,061
adventofcode-2018
The Unlicense
src/day08/Day08.kt
taer
573,051,280
false
{"Kotlin": 26121}
package day08 import readInput class Cell(val value: Int, var visible: Boolean = false){ override fun toString(): String { return "$value $visible" } } fun main() { fun mySeq( rows: Iterable<Int>, columns: Iterable<Int> ) = sequence { rows.forEach { r -> c...
0
Kotlin
0
0
1bd19df8949d4a56b881af28af21a2b35d800b22
3,409
aoc2022
Apache License 2.0
src/main/kotlin/solutions/day19/Day19.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day19 import solutions.Solver import kotlin.math.abs import kotlin.math.ceil import kotlin.math.max enum class RobotType { ORE, CLAY, OBSIDIAN, GEODE } data class RobotCost(val ore: Int, val clay: Int = 0, val obsidian: Int = 0) data class Blueprint( val nbr: Int, val costs...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
6,809
Advent-of-Code-2022
MIT License
src/main/kotlin/com/dambra/adventofcode2018/day11/Grid.kt
pauldambra
159,939,178
false
null
package com.dambra.adventofcode2018.day11 class Grid(private val gridSerial: Int) { //ugh topleft to gridsize to power private val powersAt: MutableMap<Cell, MutableMap<Int, Int>> = mutableMapOf() fun seekLargestThreeByThreeSquare(): Triple<Int, Cell, Int> { return seekLargestCellSquareOfAnySize(...
0
Kotlin
0
1
7d11bb8a07fb156dc92322e06e76e4ecf8402d1d
3,149
adventofcode2018
The Unlicense
2022/kotlin-lang/src/main/kotlin/mmxxii/days/Day8.kt
Delni
317,500,911
false
{"Kotlin": 66017, "Dart": 53066, "Go": 28200, "TypeScript": 7238, "Rust": 7104, "JavaScript": 2873}
package mmxxii.days import mmxxii.entities.canSeeFarWithTrees import mmxxii.entities.toTrees class Day8 : Abstract2022<Int>("08", "Treetop Tree House") { override fun part1(input: List<String>) = input .toTrees() .flatMapIndexed { i, trees -> trees.mapIndexed { j, tree -> ...
0
Kotlin
0
1
d8cce76d15117777740c839d2ac2e74a38b0cb58
1,988
advent-of-code
MIT License
advent23-kt/app/src/main/kotlin/dev/rockyj/advent_kt/Day4.kt
rocky-jaiswal
726,062,069
false
{"Kotlin": 41834, "Ruby": 2966, "TypeScript": 2848, "JavaScript": 830, "Shell": 455, "Dockerfile": 387}
package dev.rockyj.advent_kt private data class ScratchCard(val id: Int, val wins: List<Int>, val nums: List<Int>) private fun toCards(input: List<String>): List<Pair<List<Int>, List<Int>>> { val cards = mutableListOf<Pair<List<Int>, List<Int>>>() input.forEachIndexed { _idx, line -> val card = line....
0
Kotlin
0
0
a7bc1dfad8fb784868150d7cf32f35f606a8dafe
2,196
advent-2023
MIT License
src/day07/Day07.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day07 import readInput fun main() { val testInput = readInput("day07/Day07_test") println(part1(testInput)) println(part2(testInput)) } private fun createDirMap(input: List<String>): Map<String, Int> { val dirMap = hashMapOf("/" to 0) var currentDirName = "/" input.forEach { ...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
1,713
advent-of-code-2022
Apache License 2.0
aoc2023/day2.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day2.execute() } private object Day2 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<Game>): Int { // Only 12 red ...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
1,844
Advent-Of-Code
MIT License
src/main/kotlin/LongestCommonSubsequence.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given two strings text1 and text2, return the length of their longest common subsequence. * If there is no common subsequence, return 0. * * A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remain...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,821
kotlin-codes
Apache License 2.0
src/com/wd/algorithm/leetcode/ALGO0004.kt
WalkerDenial
327,944,547
false
null
package com.wd.algorithm.leetcode import com.wd.algorithm.test /** * 4. 寻找两个正序数组的中位数 * * 给定两个大小为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的中位数。 * */ class ALGO0004 { /** * 方式一:暴力解法 * 将 2 个数组合并,然后取中位数 * 时间复杂度 T(m + n) */ fun findMedianSortedArrays1(nums1: IntArray, nums2: IntArra...
0
Kotlin
0
0
245ab89bd8bf467625901034dc1139f0a626887b
1,908
AlgorithmAnalyze
Apache License 2.0
src/y2015/Day16.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput object Day16 { private fun parse(input: List<String>): List<Map<String, Int>> { return input.map { val els = it.replace(Regex("[:,]"), "").split(" ") mapOf( els[2] to els[3].toInt(), els[4] to els[5].toInt(), ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,482
advent-of-code
Apache License 2.0
src/year_2022/day_16/Day16.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_16 import readInput import kotlin.math.max data class Valve( val name: String, val flowRate: Int, val toValves: List<String> ) object Day16 { var score = 0 /** * @return */ fun solutionOne(text: List<String>): Int { score = 0 val valvesMap = pa...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
4,616
advent_of_code
Apache License 2.0
src/Day02.kt
mandoway
573,027,658
false
{"Kotlin": 22353}
enum class Outcome(val points: Int) { LOSE(0), DRAW(3), WIN(6) } fun String.decrypt() = when (this) { "X" -> "A" "Y" -> "B" "Z" -> "C" else -> throw IllegalArgumentException("char must be in X, Y, Z") } val shapes = listOf("A", "B", "C") fun String.pointsByShape() = shapes.indexOf(this) +...
0
Kotlin
0
0
0393a4a25ae4bbdb3a2e968e2b1a13795a31bfe2
1,873
advent-of-code-22
Apache License 2.0
src/day02/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day02 import readInput private enum class Outcome(val score: Int) { Lost(0), Draw(3), Win(6); } private enum class HandShape(val value: Int) { Rock(1), Paper(2), Scissor(3) } fun <E> Iterable<E>.cartesian() = flatMap { left -> map { right -> left to right } } fun main() { val game = HandShape.v...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
1,453
AOC2022
Apache License 2.0
src/Day10.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
import kotlin.math.floor fun main() { fun rempliCycle(input: List<String>): Array<Int> { val nombreAdd = input.filter { it.contains("addx") }.size val nombreNoop = input.filter { it.contains("noop") }.size val nombreCycles = nombreAdd * 2 + nombreNoop var cycles = Array(nombreCycles...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
2,016
AD2022-01
Apache License 2.0
src/Day05.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
import java.io.File import java.util.Stack fun main() { data class Move( val amount: Int, val from: Int, val to: Int, ) fun readInput(name: String) = File("src", "$name.txt").readText().split("\n\n") fun getMoves(moves: String) = moves .split("\n") .filter { i...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
2,602
aoc-2022
Apache License 2.0
2023/src/main/kotlin/de/skyrising/aoc2023/day19/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day19 import de.skyrising.aoc.* enum class Operator { LT, GT; companion object { inline operator fun get(c: Char) = entries[(c.code - '<'.code) / 2] } } enum class Category { X, M, A, S; companion object { val HASHED = arrayOf(X, A, S, M) inlin...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
5,624
aoc
MIT License
src/main/kotlin/advent2019/day15/day15.kt
davidpricedev
225,621,794
false
null
package advent2019.day15 import advent2019.IntCode.ICComp import advent2019.IntCode.startComputer import java.util.ArrayDeque /** * 1 = North, 2 = S, 3 = W, 4 = E * 0 = no change (wall), 1 = confirm movement, 2 = confirm movement + on location */ fun main() { // part1 println(walkTheDronePart1(getProgram()...
0
Kotlin
0
0
2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9
6,371
adventOfCode2019
Apache License 2.0
src/Day01.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
fun main() { fun part1(input: List<String>): Int { val elves = inputToElves(input) return getElvesWithMostCalories(elves).sumOf { elf -> elf.sum() } } fun part2(input: List<String>): Int { val elves = inputToElves(input) return getElvesWithMostCalories(elves, 3).sumOf { elf ...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
1,545
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day16/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day16 import util.readTestInput import kotlin.math.min private typealias ValveId = String private data class Valve(val valveId: ValveId) { var flowrate: Int = 0 var neighbors: List<String> = listOf() private constructor(valveId: ValveId, flowrate: Int, neighbors: List<ValveId>): this(valveId) { ...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
8,382
advent-of-code-2022
MIT License
src/main/kotlin/aoc2018/ExperimentalEmergencyTeleportation.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2018 import komu.adventofcode.utils.nonEmptyLines import kotlin.math.abs fun experimentalEmergencyTeleportation1(input: String): Int { val bots = input.nonEmptyLines().map { Nanobot.parse(it) } val strongest = bots.maxBy { it.range } return bots.count { strongest.pos.manhattan...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
3,155
advent-of-code
MIT License
src/main/kotlin/ai/hypergraph/kaliningraph/types/TypeSystem.kt
ileasile
424,362,465
true
{"Kotlin": 121295}
package ai.hypergraph.kaliningraph.types import ai.hypergraph.kaliningraph.times /** Corecursive Fibonacci sequence of [Nat]s **/ tailrec fun <T, R: Nat<T, R>> Nat<T, R>.fibonacci( n: T, seed: Pair<T, T> = nil to one, fib: (Pair<T, T>) -> Pair<T, T> = { (a, b) -> b to a + b }, i: T = nil, ): T = if (i == n)...
0
null
0
0
4b6aadf379ec40fe0c7d5de0ee25fa64520e31b3
6,517
kaliningraph
Apache License 2.0
src/Day11.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
import Operator.PLUS import Operator.TIMES fun main() { val day = "Day11" fun readMonkeys(input: List<String>): Map<Int, Monkey> { return input.filter { it.isNotBlank() } .chunked(6) .mapIndexed { index, lines -> lines.toMonkey(index) } .associateBy { it.number } ...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
3,730
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-14.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.CharGrid import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import com.github.ferinagy.adventOfCode.toCharGrid fun main() { v...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,696
advent-of-code
MIT License