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/cc/stevenyin/algorithms/_02_sorts/_04_MergeSort.kt
StevenYinKop
269,945,740
false
{"Kotlin": 107894, "Java": 9565}
package cc.stevenyin.algorithms._02_sorts import cc.stevenyin.algorithms.RandomType import cc.stevenyin.algorithms.testSortAlgorithm class _04_MergeSort: SortAlgorithm { override val name: String get() = "MergeSort_Recursive" override fun <T : Comparable<T>> sort(array: Array<T>) { // 维护变量在算法...
0
Kotlin
0
1
748812d291e5c2df64c8620c96189403b19e12dd
1,982
kotlin-demo-code
MIT License
src/main/kotlin/aoc22/Day04.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import readInput fun day4part1(input: List<String>): Int = input.count { inp -> inp.split(",").let { it[0].surrounds(it[1]) || it[1].surrounds(it[0]) } } fun day4part2(input: List<String>): Int = input.count { inp -> inp.split(",").let { ...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
1,436
advent-of-code
Apache License 2.0
src/Day04.kt
rmyhal
573,210,876
false
{"Kotlin": 17741}
fun main() { fun part1(input: List<String>): Int { return fullOverlap(input) } fun part2(input: List<String>): Int { return partialOverlap(input) } val input = readInput("Day04") println(part1(input)) println(part2(input)) } private fun fullOverlap(input: List<String>) = input .map { pair...
0
Kotlin
0
0
e08b65e632ace32b494716c7908ad4a0f5c6d7ef
1,169
AoC22
Apache License 2.0
src/Day02.kt
ManueruEd
573,678,383
false
{"Kotlin": 10647}
fun main() { val shapeScores = mapOf("X" to 1, "Y" to 2, "Z" to 3) fun testMatch(a: String, b: String): Int { when { (a == "A" && b == "X") || (a == "B" && b == "Y") || (a == "C" && b == "Z") -> { println("$a $b draw") ...
0
Kotlin
0
0
09f3357e059e31fda3dd2dfda5ce603c31614d77
2,534
AdventOfCode2022
Apache License 2.0
src/Day02.kt
3n3a-archive
573,389,832
false
{"Kotlin": 41221, "Shell": 534}
fun Day02() { fun getMappedChar( map: Map<Char, Char>, input: Char): Char? { return map.get(input) } fun getPointsForPlayer2( winner: Int, chosenItem: Char? ): Int { var points = 0 when(winner) { 0 -> points += 3 1 -> points += 0 2 -> points += 6...
0
Kotlin
0
0
fd25137d2d2df0aa629e56981f18de52b25a2d28
3,262
aoc_kt
Apache License 2.0
y2015/src/main/kotlin/adventofcode/y2015/Day19.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2015 import adventofcode.io.AdventSolution object Day19 : AdventSolution(2015, 19, "Medicine for Rudolph") { override fun solvePartOne(input: String) = parse(input) .let { (transitions, molecule) -> newMolecules(molecule, transitions) } .count() .toString() override fun solvePartTwo...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,308
advent-of-code
MIT License
src/main/kotlin/de/startat/aoc2023/Day7.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 import de.startat.aoc2023.HandType.* import java.util.* data class D7Play(val cards: List<Card>, val bid: Int) { val type: HandType val jokeredType : HandType init { fun determineType(groupedCards : SortedMap<Int, List<Card>>) : HandType = when { groupedCards...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
18,070
AOC2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/groundsfam/advent/y2021/d08/Day08.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d08 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines fun segmentsToDigit(segments: Set<Char>) = when (segments) { "abcefg".toSet() -> 0 "cf".toSet() -> 1 "acdeg".toSet() -> 2 "acdfg".t...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,866
advent-of-code
MIT License
grind-75-kotlin/src/main/kotlin/FloodFill.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
/** * An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image. * * You are also given three integers sr, sc, and color. * You should perform a flood fill on the image starting from the pixel image[sr][sc]. * * To perform a flood fill, consider the starting ...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
2,487
grind-75
Apache License 2.0
src/year2015/day12/Day12.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day12 import readInput fun main() { val input = readInput("2015", "Day12") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>) = input.first() .split("(\\[|]|,|:|\\{|})".toRegex()) .sumOf { it.toIntOrNull() ?: 0 } private fun part2(input: List<St...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,572
AdventOfCode
Apache License 2.0
src/y2016/Day22.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.Pos import util.printGrid import util.readInput data class DiskNode( val pos: Pos, val size: Int, val used: Int, val avail: Int, val percent: Int ) { companion object { fun fromString(string: String): DiskNode { val els = string.split(Regex("\\s+")...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,918
advent-of-code
Apache License 2.0
aoc-2023/src/main/kotlin/aoc/aoc15.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val testInput = """ rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7 """.parselines fun String.hash(): Int { var hash = 0 for (i in 0 until length) { hash = (17 * (hash + get(i).code)) % 256 } return hash } ...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
1,565
advent-of-code
Apache License 2.0
src/main/kotlin/day7/Day7.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day7 import readToList import kotlin.math.abs val input = readToList("day7.txt").first().split(",").map { it.toInt() } fun main() { println(part1()) println(part2()) } private fun part1(): Int { val sorted = input.sorted() val size = sorted.size val median = if (size % 2 == 0) { ...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
952
aoc2021
Apache License 2.0
src/day16/Code.kt
fcolasuonno
162,470,286
false
null
package day16 import java.io.File fun main(args: Array<String>) { val name = if (true) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
1,716
AOC2015
MIT License
src/main/kotlin/days/Day7.kt
broersma
574,686,709
false
{"Kotlin": 20754}
package days class Day7 : Day(7) { private fun sizeOfPath(tree: Map<List<String>, Set<Any>>, path: List<String>): Int { return tree[path]!! .map { if (it is List<*>) sizeOfPath(tree, it as List<String>) else it as Int } .sum() } override fun partOne(): Int { ...
0
Kotlin
0
0
cd3f87e89f7518eac07dafaaeb0f6adf3ecb44f5
2,823
advent-of-code-2022-kotlin
Creative Commons Zero v1.0 Universal
logicsolver/src/main/kotlin/nl/hiddewieringa/logicsolver/Input.kt
hiddewie
147,922,971
false
null
package nl.hiddewieringa.logicsolver import java.util.regex.Pattern data class LogicSolveError(override val message: String) : Exception(message) data class Coordinate(val a: Int, val b: Int) : Comparable<Coordinate> { override fun compareTo(other: Coordinate): Int { return compareBy<Coordinate>({ it.a }...
0
Kotlin
0
0
bcf12c102f4ab77c5aa380dbf7c98a1cc3e585c0
6,244
LogicSolver
MIT License
src/test/kotlin/Day16.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe /* --- Day 16: Ticket Translation --- See https://adventofcode.com/2020/day/16 */ fun List<List<Int>>.filterTicketsSatisfyingAnyRule(rules: List<TicketRule>): List<List<Int>> = filter { ticket -> ticket.all { value -> ...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
7,954
advent_of_code_2020
Apache License 2.0
src/Day12.kt
tomoki1207
572,815,543
false
{"Kotlin": 28654}
import java.util.* data class Point(val row: Int, val col: Int, val mark: Char) { val elevation = when (mark) { 'S' -> 'a' 'E' -> 'z' else -> mark }.code fun climbable(other: Point): Boolean { return elevation - other.elevation >= -1 } } fun main() { fun solve( ...
0
Kotlin
0
0
2ecd45f48d9d2504874f7ff40d7c21975bc074ec
2,729
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
fun main() { fun processInput(input: List<String>, columns: Int): Pair<Array<MutableList<Char>>, MutableList<Triple<Int,Int, Int>>> { var stacks = Array<MutableList<Char>>(columns){mutableListOf<Char>()} var moves = mutableListOf<Triple<Int,Int, Int>>() input.forEach { line -> if...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
2,650
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/iteration/Combinations.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.iteration /* pair */ fun <T> List<T>.combinationPairs(): Sequence<Pair<T, T>> { return combinations( length = 2, combination = ::combinationPair ) } private fun <T> List<T>.combinationPair(indices: IntArray, count: Int): Pair<T, T> { require(count...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
2,218
advent-2023
ISC License
2021/src/main/kotlin/com/github/afranken/aoc/Day202105.kt
afranken
434,026,010
false
{"Kotlin": 28937}
package com.github.afranken.aoc object Day202105 { fun part1(inputs: Array<String>): Int { val coordinates = getCoordinates(inputs) val matrix = createMatrix(coordinates) coordinates.forEach { val from = Pair(it[0], it[1]) val to = Pair(it[2], it[3]) m...
0
Kotlin
0
0
0140f68e60fa7b37eb7060ade689bb6634ba722b
2,680
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day5/day5.kt
aaronbush
370,490,470
false
null
package day5 import loadFile fun F(num: Pair<Int, Int>): Pair<Int, Int> = num.first to num.second - (num.second - num.first) / 2 - 1 fun B(num: Pair<Int, Int>): Pair<Int, Int> = num.first + (num.second - num.first) / 2 + 1 to num.second fun main() { val data = "/day5/input.txt".loadFile() part1(data) pa...
0
Kotlin
0
0
41d69ebef7cfeae4079e8311b1060b272c5f9a29
1,119
aoc-2020-kotlin
MIT License
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day16/day16.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day16 import eu.janvdb.aocutil.kotlin.point2d.Direction import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines import java.util.* //const val FILENAME = "input16-test.txt" const val FILENAME = "input16.txt" fun main() { val puzzle = Puzzle.parse(readLines...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,764
advent-of-code
Apache License 2.0
src/year2022/day18/Day18.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day18 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { val offsets = arrayOf( Triple(1, 0, 0), Triple(-1, 0, 0), Triple(0, 1, 0), Triple(0, -1, 0), Triple(0, 0, 1), Triple(0, 0, -1), ) fun parseInput(input: Lis...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
3,229
advent-of-code-kotlin
Apache License 2.0
src/Day03.kt
guilherme
574,434,377
false
{"Kotlin": 7468}
import java.lang.RuntimeException fun main() { val PRIORITY_RANGE = concatenate(('a'.rangeTo('z')) .toList(), ('A'.rangeTo('Z')).toList()) fun priority(item: Char): Int { val priority = PRIORITY_RANGE.indexOf(item) + 1 if (priority == 0) { throw RuntimeException("Invalid item ${item}") } el...
0
Kotlin
0
3
dfc0cee1d023be895f265623bec130386ed12f05
1,883
advent-of-code
Apache License 2.0
src/Day05.kt
zhiqiyu
573,221,845
false
{"Kotlin": 20644}
import kotlin.math.max import kotlin.math.abs import java.util.LinkedList import java.util.Queue import java.util.Stack class Stacks() { var stacks: ArrayList<ArrayDeque<Char>> init { stacks = ArrayList<ArrayDeque<Char>>() } fun initialize(input: List<String>) { var nums = (input.get(0...
0
Kotlin
0
0
d3aa03b2ba2a8def927b94c2b7731663041ffd1d
2,857
aoc-2022
Apache License 2.0
src/main/kotlin/Day11.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day11.solvePart1()) println(Day11.solvePart2()) } object Day11 { private val input = readInput("day11") fun solvePart1(): Int { val levels = input.map { it.map(Char::digitToInt).toIntArray() }.toTypedArray() var flashes = 0 repeat(100) { flashes...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,903
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/Day13.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
sealed class Item { class Value(val value: Int): Item() class Nested(val value: List<Item>): Item() } fun main() { fun parseNumber(line: String, startIdx: Int): Pair<Int, Int> { val tmp = line.substring(startIdx).takeWhile { it.isDigit() } return Pair(tmp.toInt(), tmp.length) } fun...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
4,192
aoc2022
Apache License 2.0
src/day09/Day09.kt
gillyobeast
574,413,213
false
{"Kotlin": 27372}
package day09 import utils.appliedTo import utils.readInput import kotlin.math.abs import kotlin.math.sign enum class Move(val regex: Regex, val applyTo: (Point) -> Point) { UP("U \\d+".toRegex(), { it.first to it.second + 1 }), DOWN("D \\d+".toRegex(), { it.first to it.second - 1 }), LEFT("L \\d+".toRege...
0
Kotlin
0
0
8cdbb20c1a544039b0e91101ec3ebd529c2b9062
3,170
aoc-2022-kotlin
Apache License 2.0
2023/src/main/kotlin/day16.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.Parser import utils.Solution import utils.Vec2i import utils.createMutableGrid import java.util.EnumSet fun main() { Day16.run() } object Day16 : Solution<Grid<Char>>() { override val name = "day16" override val parser = Parser.charGrid data class Beam( val location: Vec2i,...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,085
aoc_kotlin
MIT License
y2016/src/main/kotlin/adventofcode/y2016/Day17.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.IState import adventofcode.util.algorithm.aStar import adventofcode.util.algorithm.aStarExhaustive import adventofcode.util.algorithm.md5 object Day17 : AdventSolution(2016, 17, "Two Steps Forward") { override fun so...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,386
advent-of-code
MIT License
dynamic_programming/LongestArithmeticSubsequence/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
import kotlin.math.sign /** * Given an array A of integers, return the length of the longest * arithmetic subsequence in A. * Recall that a subsequence of A is a * list A[i_1], A[i_2], ..., A[i_k] * with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence * B is arithmetic if B[i+1] - B[i] are al...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,528
codility
MIT License
year2018/src/main/kotlin/net/olegg/aoc/year2018/day6/Day6.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day6 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2018.DayOf2018 import kotlin.math.abs /** * See [Year 2018, Day 6](https://adventofcode.com/2018/day/6) */ object Day6 : DayOf2018(6) { private val PATTERN = "(\\d+), (\\d+)".toRegex() private const val TOTAL = 100...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,000
adventofcode
MIT License
src/day3/main.kt
DonaldLika
434,183,449
false
{"Kotlin": 11805}
package day3 import assert import readLines import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { val gammaRate = input.toGamaRate() val epsilonRate = gammaRate.invertBinaryString() return gammaRate.toInt(2) * epsilonRate.toInt(2) } fun part2(input:...
0
Kotlin
0
0
b288f16ee862c0a685a3f9e4db34d71b16c3e457
2,253
advent-of-code-2021
MIT License
src/day04/Day04.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day04 import readLines fun main() { val id = "04" fun readSections(fileName: String): Sequence<String> { return readLines(fileName).asSequence() } // Time — O(), Memory — O() fun part1(input: Sequence<String>): Int { return input.map { val sections = it.split...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
1,683
advent-of-code-2022
Apache License 2.0
gcj/y2022/kickstart_c/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2022.kickstart_c const val M = 1000000007 private fun solve(): Int { val n = readInt() val s = readLn() val a = List(n + 1) { List(n + 1) { IntArray(n + 1) } } for (i in n downTo 0) for (j in i..n) for (k in 0..j - i) { if (k == 0) { a[i][j][k] = 1 continue } if (k == 1) { a[i][j][k] =...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,947
competitions
The Unlicense
kotlin/src/katas/kotlin/skiena/graphs/ShortestPath.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.skiena.graphs import katas.kotlin.skiena.graphs.WeightedGraphs.diamondGraph import katas.kotlin.skiena.graphs.WeightedGraphs.linearGraph import katas.kotlin.skiena.graphs.WeightedGraphs.triangleGraph import datsok.shouldEqual import org.junit.Test class ShortestPathTests { @Test fun `Dijkstra...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
4,618
katas
The Unlicense
src/main/kotlin/day7/Day07.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day7 fun solveA(input: List<String>) = input.createFolderStructure().filter { it.getSize() < 100000L }.sumOf { it.getSize() } fun solveB(input: List<String>): Long { val folders = input.createFolderStructure() val rootFolderSize = folders.find { it.name == "/" }!!.getSize() return folders.findSm...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
4,430
advent-of-code-2022
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import adventofcode.util.vector.Direction import adventofcode.util.vector.Direction.* import adventofcode.util.vector.Vec2 fun main() { Day16.solve() } object Day16 : AdventSolution(2023, 16, "The Floor Will Be Lava") { override fun solvePartO...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
3,296
advent-of-code
MIT License
src/main/kotlin/Day14.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset fun main() { fun calculateWeight(grid: List<List<Char>>): Int { return grid.mapIndexed { y, chars -> chars.sumOf { c -> if (c == 'O') grid.size - y else 0 } }.sum() } fun tiltNorth(input: Li...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
3,766
aoc-2023-in-kotlin
Apache License 2.0
src/Day06.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
fun main() { fun part1(input: String): Int { val distinctCharCount = 4 return input .windowed(distinctCharCount) .mapIndexed { index, chunk -> index to (chunk.toSet().size == distinctCharCount) } .filter { (_, a) -> a } .map { (a, _) -> a + distinctCha...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
1,250
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day04.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput fun main() { fun getBounds(section: String): IntRange { val (lower, upper) = section.split("-", limit = 2).map { it.toInt() } return IntRange(lower, upper) } fun part1(input: List<String>): Int { return input.map { val (section1, secti...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,250
adventOfCode
Apache License 2.0
src/day07/Day07.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day07 import readInput import utils.withStopwatch fun main() { val testInput = readInput("input07_test") withStopwatch { println(part1(testInput)) } // withStopwatch { println(part2(testInput)) } val input = readInput("input07") withStopwatch { println(part1(input)) } // withStopwatch {...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
4,331
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimizeSumDifference.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
4,184
kotlab
Apache License 2.0
src/main/kotlin/day12.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getLines fun String.isUppercase() = this.uppercase() == this class CaveNavigate(lines: List<String>, private val allowTwice: Boolean = false) { private val caveNodes = mutableListOf<CaveNode>() private var options = mutableListOf<List<CaveNode>>() private val reachedEnd = mutableListOf<List<...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
2,583
AdventOfCode2021
MIT License
src/day14/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day14 import java.io.File fun solve(rules: Map<Pair<Char, Char>, Char>, initialPairCounts: Map<Pair<Char, Char>, Long>, steps: Int): Long { var pairCounts = initialPairCounts for (step in 1..steps) { pairCounts = pairCounts.entries.fold(emptyMap()) { acc, pairCount -> val ch = rul...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,361
advent-of-code-2021
MIT License
src/Day03.kt
phamobic
572,925,492
false
{"Kotlin": 12697}
fun main() { val alphabetLetters = "abcdefghijklmnopqrstuvwxyz" val alphabet = ("-$alphabetLetters${alphabetLetters.uppercase()}").toSet() fun part1(input: List<String>): Int { var sum = 0 input.forEach { line -> val middleIndex = line.length / 2 val firstRucksack =...
1
Kotlin
0
0
34b2603470c8325d7cdf80cd5182378a4e822616
1,196
aoc-2022
Apache License 2.0
src/Day08.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
private data class Tree( val height: Int, var left: Boolean? = null, var top: Boolean? = null, var right: Boolean? = null, var bottom: Boolean? = null, val x: Int, val y: Int, ) { fun visible() = top == true || left == true || right == true || bottom =...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
3,566
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/de/skyrising/aoc2023/day24/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day24 import com.microsoft.z3.Context import com.microsoft.z3.Status import de.skyrising.aoc.* val test = TestInput(""" 19, 13, 30 @ -2, 1, -2 18, 19, 22 @ -1, -1, -2 20, 25, 34 @ -2, -2, -4 12, 31, 28 @ -1, -2, -1 20, 19, 15 @ 1, -5, -3 """) fun intersectRays(p1: V...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,397
aoc
MIT License
aoc-2023/src/main/kotlin/aoc/aoc9.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val testInput = """ 0 3 6 9 12 15 1 3 6 10 15 21 10 13 16 21 30 45 """.parselines // part 1 fun String.parse() = split(" ").map { it.toInt() } fun List<Int>.diffs() = zipWithNext { a, b -> b - a } fun List<Int>.extrapolate(): Lon...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
1,455
advent-of-code
Apache License 2.0
src/P14LongestCollatzSequence.kt
rhavran
250,959,542
false
null
fun main(args: Array<String>) { println("Res: " + findSolution()) } /** The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → ...
0
Kotlin
0
0
11156745ef0512ab8aee625ac98cb6b7d74c7e92
1,401
ProjectEuler
MIT License
src/Day10.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
import kotlin.math.abs fun main() { fun getValuesInEachCycle(input: List<String>): List<Int> { val valuesInCycles = mutableListOf(1) var valueAfterLastCycle = valuesInCycles.first() input.forEach { instruction -> when { instruction.startsWith("noop") -> { ...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
1,598
advent-of-code
Apache License 2.0
src/Day05.kt
LesleySommerville-Ki
577,718,331
false
{"Kotlin": 9590}
fun main() { data class Instructions( val amount: Int, val from: Int, val to: Int ) fun parseInstructions(input: List<String>): List<Instructions> = input .dropWhile { !it.startsWith("move") } .map { row -> row.split(" ").let { parts -...
0
Kotlin
0
0
ea657777d8f084077df9a324093af9892c962200
2,093
AoC
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem2477/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2477 /** * LeetCode page: [2477. Minimum Fuel Cost to Report to the Capital](https://leetcode.com/problems/minimum-fuel-cost-to-report-to-the-capital/); */ class Solution { /* Complexity: * Time O(n) and Space O(n) where n is the number of cities and equals roads.size +...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,200
hj-leetcode-kotlin
Apache License 2.0
src/Day02.kt
emmanueljohn1
572,809,704
false
{"Kotlin": 12720}
fun main() { val scoreChart = mapOf("A" to 1, "B" to 2, "C" to 3, "X" to 1, "Y" to 2, "Z" to 3) val winPair = mapOf(3 to 1, 2 to 3, 1 to 2) val losePair = winPair.entries.associateBy({ it.value }) { it.key } fun roundScore (first: Int, second: Int): Int{ if( first == second) return 3 ...
0
Kotlin
0
0
154db2b1648c9d12f82aa00722209741b1de1e1b
1,450
advent22
Apache License 2.0
src/aoc2022/Day04.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import println import readInput fun main() { fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val ranges = line.split(",") val range1 = ranges[0].split("-") val range2 = ranges[1].split("-") if ((range1[0].toIn...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
1,196
advent-of-code-kotlin
Apache License 2.0
src/day03/Day03.kt
devEyosiyas
576,863,541
false
null
package day03 import println import readInput fun main() { fun priority(c: Char): Int = when (val n = c.code) { in 65..90 -> n - 65 + 27 in 97..122 -> n - 96 else -> n } fun processRucksack(rucksack: String, threeRucksacks: Boolean = false): Int { val length = rucksack.len...
0
Kotlin
0
0
91d94b50153bdab1a4d972f57108d6c0ea712b0e
1,547
advent_of_code_2022
Apache License 2.0
src/main/kotlin/combinatorics/Permutations.kt
hastebrot
62,413,557
false
null
package combinatorics import java.util.LinkedList interface Circular<out T> : Iterable<T> { fun state(): T fun inc() fun isZero(): Boolean // `true` in exactly one state fun hasNext(): Boolean // `false` if the next state `isZero()` override fun iterator() : Iterator<T> { return object...
7
Kotlin
4
2
aea1a4d89e469e69568e77173231683687b4895d
2,406
kotlinx.math
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/longest_string_of_vowels/LongestStringOfVowels.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.longest_string_of_vowels import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/233724/Amazon-online-assessment-Longest-string-made-up-of-only-vowels */ class LongestStringOfVowelsTests { @Test fun examples() { longestString("e...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,799
katas
The Unlicense
src/day05/Day05.kt
sophiepoole
573,708,897
false
null
package day05 import readInputText fun main() { val testInput = readInputText("day05/input_test") val input = readInputText("day05/input") val day = Day05() println("Part 1: ${day.part1(testInput)}") println("Part 2: ${day.part2(testInput)}") println("Part 1: ${day.part1(input)}") printl...
0
Kotlin
0
0
00ad7d82cfcac2cb8a902b310f01a6eedba985eb
2,569
advent-of-code-2022
Apache License 2.0
src/Day07.kt
casslabath
573,177,204
false
{"Kotlin": 27085}
class Node (val dir: String, var value: Long, val parent: Node?) { var children: MutableList<Node> = mutableListOf() fun updateDirValues(newValue: Long) { value += newValue if(this.parent != null) { this.parent.updateDirValues(newValue) } } fun addChild(dir: String...
0
Kotlin
0
0
5f7305e45f41a6893b6e12c8d92db7607723425e
2,892
KotlinAdvent2022
Apache License 2.0
src/Day07.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.math.absoluteValue import kotlin.math.pow import kotlin.math.roundToInt import kotlin.streams.toList fun main() { fun part1(input: List<Int>): Int { val pos = input.sorted()[input.size / 2] return input.sumOf { (it - pos).absoluteValue } } fun singleCost(from: Int, to: Int):...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
1,628
advent_of_code21_kotlin
Apache License 2.0
src/Day04.kt
dominik003
573,083,805
false
{"Kotlin": 9376}
fun main() { fun part1(input: List<String>): Int { var counter = 0 input.forEach { val ranges = it.split(",") val leftSide = ranges[0].split("-").map { cur -> Integer.parseInt(cur) } val rightSide = ranges[1].split("-").map { cur -> Integer.parseInt(cur) } ...
0
Kotlin
0
0
b64d1d4c96c3dd95235f604807030970a3f52bfa
1,434
advent-of-code-2022
Apache License 2.0
src/Day02.kt
devLeitner
572,272,654
false
{"Kotlin": 6301}
import RPS.* import RPSRESULT.* fun main() { fun part1() { val input = readInput("./resources/day2source") val list = arrayListOf<Array<String>>() input.forEach { list.add(arrayOf(it.split(" ")[0], it.split(" ")[1])) } val enumList = arrayListOf<List<RPS>>() ...
0
Kotlin
0
0
72b9d184fc58f790b393260fc6b1a0ed24028059
2,795
AOC_2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day02/Day02.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day02 import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource fun main() { val input = readResource("Day02.txt").lines().map { parse(it) } val (answer1, duration1) = measureDuration<Int> { partOne(input) } ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,907
advent-of-code
MIT License
dcp_kotlin/src/main/kotlin/dcp/day011/day011.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day011 // day011.kt // By <NAME>, 2020. typealias Word = String // Use a trie to represent the dictionary. class Trie private constructor(val char: Char, private val isWord: Boolean, val children: Map<Char, Trie>) { constructor(words: List<String>): this('/', false, createTrieWords(words)) compa...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,840
daily-coding-problem
MIT License
src/Day05.kt
kipwoker
572,884,607
false
null
import java.util.Stack class CrateStack(val crates: Stack<Char>) class Move(val quantity: Int, val startIdx: Int, val endIdx: Int) class State(val stacks: Array<CrateStack>, val moves: Array<Move>) { fun applyMoves() { for (move in moves) { for (i in 1..move.quantity) { val crat...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
2,740
aoc2022
Apache License 2.0
src/2020/Day16_2.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
/** * Now that you've identified which tickets contain invalid values, discard those tickets * entirely. Use the remaining valid tickets to determine which field is which. * * Using the valid ranges for each field, determine what order the fields appear on the tickets. * The order is consistent between all tickets...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
3,360
adventofcode
MIT License
MyLib_Kotlin/src/main/kotlin/algorithm/dp/LCS.kt
CWKSC
420,659,931
false
{"Kotlin": 29346}
package algorithm.dp sealed class LCS { companion object { private fun longestOne(A: String, B: String): String { return if (A.length >= B.length) A else B } fun recursionTopDown(A: String, B: String): String { if (A.isEmpty() || B.isEmpty()) return ""; ...
0
Kotlin
0
1
01c8453181012a82b1201ad0e9f896da80282bbf
3,900
MyLib_Kotlin
MIT License
2022/kotlin/src/Day03.kt
tomek0123456789
573,389,936
false
{"Kotlin": 5085}
fun main() { val map = mutableMapOf<Char, Int>().apply { var index = 1 ('a'..'z').forEach { this[it] = index index++ } ('A'..'Z').forEach { this[it] = index index++ } } fun part1(input: List<String>): Int { val ...
0
Kotlin
0
0
5ee55448242ec79475057f43d34f19ae05933eba
1,542
aoc
Apache License 2.0
src/Day03.kt
psy667
571,468,780
false
{"Kotlin": 23245}
fun main() { val id = "03" fun part1(input: List<String>): Int { return input.sumOf { line -> line .chunked(line.length / 2) .map { it.toSet() } .reduce { acc, it -> acc.intersect(it) } .first() .let { ...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
1,184
advent-of-code-2022
Apache License 2.0
2021/src/main/kotlin/sh/weller/aoc/Day03.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day03 : SomeDay<List<Char>, Int> { override fun partOne(input: List<List<Char>>): Int { val gamma = mutableListOf<Char>() val epsilon = mutableListOf<Char>() repeat(input.first().size) { index -> val list = input.map { it[index] } val co...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
2,992
AdventOfCode
MIT License
src/main/kotlin/endredeak/aoc2022/Day19.kt
edeak
571,891,076
false
{"Kotlin": 44975}
package endredeak.aoc2022 fun main() { val pattern = Regex("Blueprint (\\d+): Each ore robot costs (\\d+) ore. " + "Each clay robot costs (\\d+) ore. " + "Each obsidian robot costs (\\d+) ore and (\\d+) clay. " + "Each geode robot costs (\\d+) ore and (\\d+) obsidian.") sol...
0
Kotlin
0
0
e0b95e35c98b15d2b479b28f8548d8c8ac457e3a
3,272
AdventOfCode2022
Do What The F*ck You Want To Public License
src/Day09.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
import kotlin.math.absoluteValue import kotlin.math.sign data class Coords(val x: Int, val y: Int) data class Snake( var head: Coords = Coords(0, 0), val knotsCount: Int = 1 ) { private val knots = mutableListOf<Coords>() private val tailVisits = mutableSetOf<Coords>() init { repeat(knot...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
2,414
aoc2022
Apache License 2.0
app/src/main/java/com/github/codingchili/dice30/model/Scoring.kt
codingchili
276,671,690
false
null
package com.github.codingchili.dice30.model import java.util.* import kotlin.math.max /** * Implements scoring for each dice roll and keeps a history * of each scoring algorithm with its score. */ class Scoring { val history = ArrayList<Pair<Algorithm, Int>>() /** * Records scoring for the given dice...
0
Kotlin
0
2
0212dbd0b2bb491239ad94e4997356c6c6c5c1d5
5,050
android-dice
MIT License
src/main/kotlin/dev/bogwalk/batch7/Problem74.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch7 import dev.bogwalk.util.combinatorics.permutationID import dev.bogwalk.util.maths.factorial /** * Problem 74: Digit Factorial Chains * * https://projecteuler.net/problem=74 * * Goal: For a given length L and limit N, return all integers <= N that start a digit factorial * non-repeatin...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
8,699
project-euler-kotlin
MIT License
src/main/kotlin/day25/Day25.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day25 import readInput import java.math.BigDecimal fun toDec(snafu: String): Long { var result = BigDecimal.ZERO var multiplier = BigDecimal.ONE for (c in snafu.reversed()) { val n = when (c) { '=' -> 0 '-' -> 1 '0' -> 2 '1' -> 3 ...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
1,448
aoc2022
Apache License 2.0
intstar-mcalculus/src/main/kotlin/intstar/mcalculus/Measurement.kt
vikaskushwaha9oct
276,676,290
false
null
package intstar.mcalculus data class Measurement( val left: DerivedMeasure, val comparison: Comparison, val right: Measure, val confidence: List<ConfidenceValue> ) { init { require(confidence.sumsToOne { it.value }) { "Total confidence should be 1" } require(confiden...
0
Kotlin
0
5
27ee78077690f2de1712a2b9f2ca6e4738162b56
1,854
intstar
MIT License
src/main/kotlin/com/github/michaelbull/advent2023/day6/Race.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day6 fun Sequence<String>.toRaces(): Sequence<Race> { val (times, distances) = raceData() return times.findNumbers() .zip(distances.findNumbers()) .map(Pair<Long, Long>::toRace) } fun Sequence<String>.toRace(): Race { val (times, distances) = race...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,759
advent-2023
ISC License
src/Day04.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
fun main() { fun String.toIntRange(): IntRange { val (start, end) = split("-") return start.toInt()..end.toInt() } fun List<String>.parseInput() = map { val (range1, range2) = it.split(',') range1.toIntRange() to range2.toIntRange() } operator fun IntRange.contains(...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
1,129
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day12/Day12.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day12 import common.InputRepo import common.readSessionCookie import common.solve var foundPaths = ArrayList<List<Edge>>() data class Edge(val source: String, val target: String) { override fun toString(): String { return "$source -> $target" } fun invert(): Edge { return Edge(ta...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
2,999
AdventOfCode2021
Apache License 2.0
src/Day08.kt
richardmartinsen
572,910,850
false
{"Kotlin": 14993}
fun main() { fun part1(input: List<String>) { val copyInput = input.map { it } var trees = input.first().count() + input.last().count() input.dropLast(1).drop(1).forEachIndexed { index, row -> row.forEachIndexed { i, currentTree -> // check trees to the left ...
0
Kotlin
0
0
bd71e11a2fe668d67d7ee2af5e75982c78cbe193
3,193
adventKotlin
Apache License 2.0
src/Day02.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
fun main() { fun part1(input: List<String>): Int { val outcomes = mapOf( "A X" to 3 + 1, "A Y" to 6 + 2, "A Z" to 0 + 3, "B X" to 0 + 1, "B Y" to 3 + 2, "B Z" to 6 + 3, "C X" to 6 + 1, "C Y" to 0 + 2, ...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
1,212
aoc-2022
Apache License 2.0
src/Day02.kt
TrevorSStone
573,205,379
false
{"Kotlin": 9656}
private enum class Decoded { WIN, LOSE, DRAW; companion object { fun fromChar(char: Char): Decoded? = when (char) { 'X' -> LOSE 'Y' -> DRAW 'Z' -> WIN else -> null } } } private sealed class RPS(val points: Int) { fun totalPoints(other: RPS): Int ...
0
Kotlin
0
0
2a48776f8bc10fe1d7e2bbef171bf65be9939400
2,601
advent-of-code-2022-kotlin
Apache License 2.0
src/Day07.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { abstract class FileSystem { abstract fun size(): Int } data class Directory(val path: String, val parent: Directory? = null) : FileSystem() { val files = mutableMapOf<String, FileSystem>() override fun size() = files.values.sumOf { it.size() } } data class File...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
2,481
aoc2022
Apache License 2.0
kotlin/1489-find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
class Solution { class UnionFind(val n: Int) { val par = IntArray (n) { it } val rank = IntArray (n) { 1 } fun find(x: Int): Int { if (par[x] != x) par[x] = find(par[x]) return par[x] } fun union(x: Int, y: Int): Boolean { ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,917
leetcode
MIT License
src/Day08.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day08 import patriker.utils.* fun main() { val testInput = readInput("Day08_test") val testGrid = createGridArray(testInput) val input = readInput("Day08_input") val inputGrid = createGridArray(input) println(solvePart1(testGrid)) println(solvePart1(inputGrid)) println(...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
2,625
aoc2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day18/Day18.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day18 import eu.janvdb.aoc2021.day18.ExplodeResult.Companion.explosion import eu.janvdb.aoc2021.day18.ExplodeResult.Companion.noExplosion import eu.janvdb.aocutil.kotlin.readLines const val FILENAME = "input18.txt" fun main() { val numbers = readLines(2021, FILENAME).map(Number::parse) pa...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
4,436
advent-of-code
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day4/Day4.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day4 import com.jacobhyphenated.advent2023.Day import com.jacobhyphenated.advent2023.pow /** * Day 4: Scratchcards * * Scratch cards have lists of winning numbers and a list of your numbers * You have a list of scratch cards as the puzzle input */ class Day4: Day<List<Scrat...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
2,462
advent2023
The Unlicense
src/Day08.kt
punx120
573,421,386
false
{"Kotlin": 30825}
fun main() { fun buildArray(input: List<String>): Array<IntArray> { val n = input[0].length val array = Array(n) { IntArray(n) } for (i in 0 until n) { for (j in 0 until n) { array[i][j] = input[i][j].digitToInt() } } return array ...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
3,539
aoc-2022
Apache License 2.0
src/main/kotlin/day13.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.Input import shared.toInts fun main() { val input = Input.day(13) println(day13A(input)) println(day13B(input)) } fun day13A(input: Input): Int { return input.chunks.sumOf { reflectsVertically(it) ?: (reflectsHorizontally(it)!! * 100) } } fun day13B(input: Input): Int { ...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,717
AdventOfCode2023
MIT License
src/main/java/leetcode/kotlin/IntProblems.kt
Zhaoyy
110,489,661
false
{"Java": 248008, "Kotlin": 18188}
package leetcode.kotlin import leetcode.easy.TreeNodeProblems.TreeNode fun main(args: Array<String>) { val intervals = ArrayList<Interval>() intervals.add(Interval(1, 4)) intervals.add(Interval(0, 4)) println(merge(intervals)) } class Interval( var start: Int = 0, var end: Int = 0 ) fun merge(intervals:...
0
Java
0
0
3f801c8f40b5bfe561c5944743a779dad2eca0d3
5,203
leetcode
Apache License 2.0
src/Day03.kt
hufman
573,586,479
false
{"Kotlin": 29792}
import kotlin.streams.toList fun main() { fun score(char: Char): Int { return if (('a' .. 'z').contains(char)) { char - 'a' + 1 } else if (('A' .. 'Z').contains(char)) { char - 'A' + 27 } else { throw IllegalArgumentException(char.toString()) } } fun parse(input: List<String>): List<Pair<String, St...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
1,212
aoc2022-kt
Apache License 2.0
src/Day09.kt
Misano9699
572,108,457
false
null
fun main() { val head = 0 var tail = 1 var knots = MutableList(tail + 1) { Point(0, 0) } var tailPoints = mutableSetOf(knots[tail]) fun reset() { knots = MutableList(tail + 1) { Point(0, 0) } tailPoints = mutableSetOf(knots[tail]) } fun moveTailY(knot: Int) = when (knots[...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
2,774
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day08.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 class Day08(private val input: List<String>) { fun solvePart1(): Int { val uniqueLengths = setOf(2, 3, 4, 7) return input.asSequence() .flatMap { it.split(" ").drop(11) } .count { uniqueLengths.contains(it.length) } } fun solve...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,572
advent-of-code
Apache License 2.0
src/day4/Day.kt
helbaroudy
573,339,882
false
null
package day4 import readInput typealias Section = Pair<Int, Int> fun main() { fun Section.contains(elf: Section) = this.first >= elf.first && this.second <= elf.second fun Section.overlaps(elf: Section) = this.first >= elf.first && this.first <= elf.second fun parse(entry: String): Pair<Section, Sectio...
0
Kotlin
0
0
e9b98fc0eda739048e68f4e5472068d76ee50e89
1,333
aoc22
Apache License 2.0
src/main/kotlin/days/Day05.kt
Kebaan
573,069,009
false
null
package days import utils.Day import utils.splitBy import java.util.* import kotlin.collections.ArrayDeque import kotlin.collections.component1 import kotlin.collections.component2 typealias Crate = Char fun main() { Day05.solve() } object Day05 : Day<String>(2022, 5) { data class Move(val amount: Int, val ...
0
Kotlin
0
0
ef8bba36fedbcc93698f3335fbb5a69074b40da2
2,771
Advent-of-Code-2022
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day297/day297.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day297 // day297.kt // By <NAME>, 2020. private typealias Drink = Int /** * This is just a specific instance of a set covering problem in disguise. * We want to cover the customers with the fewest number of drinks. * We use the power set and iterate by size to find a minimal set of drinks required to s...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,832
daily-coding-problem
MIT License
src/main/kotlin/dp/FindS.kt
yx-z
106,589,674
false
null
package dp import util.* // given X[1..k] and Y[1..n] : k <= n // 1. determine if X is a subsequence of Y // ex. PPAP is a subsequence of PenPineappleApplePie infix fun IntArray.isSubsequenceOf(Y: IntArray): Boolean { val X = this val k = X.size val n = Y.size // isSub(i, j): whether X[1..i] is a subsequence of...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
6,428
AlgoKt
MIT License
src/Day08.kt
eo
574,058,285
false
{"Kotlin": 45178}
// https://adventofcode.com/2022/day/8 fun main() { fun parseInput(input: List<String>): Array<IntArray> = input.map { it.chunked(1).map(String::toInt).toIntArray() }.toTypedArray() fun part1(input: List<String>): Int { val grid = parseInput(input) val leftMaxGrid = Grid(grid.rowCo...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
4,179
aoc-2022-in-kotlin
Apache License 2.0