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/kt/kotlinalgs/app/graph/GraphMColoring.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph import java.util.* println("Test") Solution().test() data class Vertice<T>( val value: T, var color: Int = -1 ) { override fun equals(other: Any?): Boolean { val oth = other as? Vertice<*> ?: return false return oth.value == value } override fun h...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
4,636
KotlinAlgs
MIT License
kotlin/19.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
import kotlin.math.abs class Day19 : Day<List<Day19.Scanner>>("19") { data class Vertex(val x: Int, val y: Int, val z: Int) { // https://stackoverflow.com/questions/16452383/how-to-get-all-24-rotations-of-a-3-dimensional-array private fun roll() = Vertex(x, z, -y) // Away from me (= rotate around x...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
3,935
advent-of-code-2021
MIT License
src/main/kotlin/nl/kelpin/fleur/advent2018/Day12.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 class Day12(val initialState: State, val rules: Map<String, Char>) { companion object { fun of(input: List<String>): Day12 = Day12(State(input[0], 0), input.drop(1).map { it.split(" => ") }.map { it[0] to it[1][0] }.toMap()) } data class State(val...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
1,410
advent-2018
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem692/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem692 import java.util.* /** * LeetCode page: [692. Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words/); */ class Solution { /* Complexity: * Time O(NLogK) and Space O(N) where N is the size of words and K equals k; */ fun topKFrequent(wor...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,392
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MakeConnected.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
5,149
kotlab
Apache License 2.0
codeforces/vk2022/round1/h1_to_upsolve.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.vk2022.round1 import kotlin.time.ExperimentalTime import kotlin.time.measureTime private fun solve() { val (h, w, k) = readInts() val zero = 0.toModular() val one = 1.toModular() val broken = List(k) { readInts().map { it - 1 } } val powerOfTwo = Array(h * w + 1) { one } for (i in 1 until pow...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,460
competitions
The Unlicense
text2summary/src/main/java/com/ml/quaterion/text2summary/TFIDFSummarizer.kt
shubham0204
255,777,901
false
null
package com.ml.quaterion.text2summary import java.lang.Exception import kotlin.collections.ArrayList import kotlin.collections.HashMap // Uses Term Frequency-Inverse Document Frequency ( TF-IDF ) to summarize texts. First, we vectorize the sentences, // such that each token has its own TF-IDF score. We take the sum o...
1
Kotlin
5
20
3f0f88d193ea81acc5a21d34fe19a630056a11e5
4,695
Text2Summary-Android
Apache License 2.0
day5/src/main/kotlin/App.kt
ascheja
317,918,055
false
null
package net.sinceat.aoc2020.day5 fun main() { val testCodes = listOf( "FBFBBFFRLR", "BFFFBBFRRR", "FFFBBBFRRR", "BBFFBBFRLL" ) testCodes.forEach { testCode -> println(SeatCoordinates.ofSeatCode(testCode)) } ClassLoader.getSystemResourceAsStream("input.txt")!...
0
Kotlin
0
0
f115063875d4d79da32cbdd44ff688f9b418d25e
1,517
aoc2020
MIT License
kotlin/src/katas/kotlin/leetcode/wildcard_matching/v4/WildcardMatching.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.wildcard_matching.v4 import datsok.shouldEqual import org.junit.Test typealias Matcher = (String) -> Set<String> fun char(char: Char): Matcher = { s -> if (s.firstOrNull() == char) setOf(s.drop(1)) else emptySet() } fun anyChar(): Matcher = { s -> if (s.isNotEmpty()) setOf(s.dr...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,830
katas
The Unlicense
2023/day04-25/src/main/kotlin/Day19.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import java.math.BigInteger import kotlin.collections.Map import kotlin.math.max import kotlin.math.min class Day19 { val doubleNewLines = "(\r\n\r\n)|(\n\n)" val newLines = "(\r\n)|(\n)" fun solve1() { val input = File("inputs/19.txt").inputStream().bufferedReader()...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
7,416
AdventOfCode
MIT License
src/main/kotlin/before/test/problem3/OtherSolution.kt
K-Diger
642,489,846
false
{"Kotlin": 105578, "Java": 57609}
package before.test.problem3 import java.time.LocalTime import java.time.format.DateTimeFormatter import kotlin.math.abs class Solution3 { companion object { private const val SPLIT_OF_TIME = ":" private const val SPLIT_OF_TIME_RANGE = "~" private const val DAY_TO_HOUR = 24 privat...
0
Kotlin
0
0
2789df5993923f7aab6e8774a7387ab65c29060a
3,850
algorithm-rehab
MIT License
src/main/kotlin/day17.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.Point import shared.getText fun main() { val input = getText("day17.txt") println(day17A(input)) println(day17B(input)) } fun day17A(input: String) = heightAfter(input, 2022) fun day17B(input: String) = heightAfter(input, 1000000000000) fun heightAfter(jets: String, totalRounds: Long): Long...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
3,660
AdventOfCode2022
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-20.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.lcm import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import java.util.LinkedList fun main() { val input = readInputLines(2023, "20-input") val test1 = readInputLines(2...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
6,029
advent-of-code
MIT License
year2017/src/main/kotlin/net/olegg/aoc/year2017/day3/Day3.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day3 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_8 import net.olegg.aoc.utils.Directions.D import net.olegg.aoc.utils.Directions.L import net.olegg.aoc.utils.Directions.R import net.olegg.aoc.utils.Directions.U import net.olegg.aoc.utils.Vect...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,547
adventofcode
MIT License
src/main/kotlin/day1/Day1.kt
tomaszobac
726,163,227
false
{"Kotlin": 15292}
package day1 import java.io.File fun part1(file: File) { var numbers: Array<Int> = arrayOf() for (line in file.readLines()) { val firstNum = line.indexOfFirst { it.isDigit() } val lastNum = line.indexOfLast { it.isDigit() } val number = "${line[firstNum]}${line[lastNum]}" num...
0
Kotlin
0
0
e0ce68fcf11e126c4680cff75ba959e46c5863aa
1,625
aoc2023
MIT License
src/test/kotlin/com/igorwojda/string/issubstring/solution.kt
tmdroid
498,808,938
true
{"Kotlin": 218846}
package com.igorwojda.string.issubstring //Kotlin Idiomatic Approach private object Solution1 { private fun isSubstring(str: String, subStr: String): Boolean { return str.contains(subStr) && str.isNotEmpty() && subStr.isNotEmpty() } } // Time complexity: O(n+m) // Space complexity: O(1) // // Optimal ...
1
Kotlin
2
0
f82825274ceeaf3bef81334f298e1c7abeeefc99
3,100
kotlin-puzzles
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem33/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem33 /** * LeetCode page: [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/); */ class Solution { /* Complexity: * Time O(LogN) and Space O(1) where N is the size of nums; */ fun search(nums: IntArray, target: Int)...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,267
hj-leetcode-kotlin
Apache License 2.0
src/Day05.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun findNumCrates(input: List<String>): Int { for(line in input) { if(line.startsWith(" 1")) { val nums = line.split(" ") return nums.last().toInt() } } return 0 } fun fillCrates(crates: MutableList<MutableList<String>>, input: List<String>) { for(line i...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
3,001
AdventOfCode2022
Apache License 2.0
2022/src/day03/Day03.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day03 import java.io.File fun main() { val input = File("src/day03/day03input.txt").readLines() println(input.sumOf { getPriority(getDuplicateItemType(it)) }) println(input.chunked(3).sumOf { getPriority(getSharedItem(it)) }) } /** * @return the bad item type. */ fun getDuplicateItemType(input...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
1,211
adventofcode
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day9.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import io.github.clechasseur.adventofcode.util.permutations import io.github.clechasseur.adventofcode.y2015.data.Day9Data object Day9 { private val input = Day9Data.input private val distRegex = """^(\w+) to (\w+) = (\d+)$""".toRegex() fun part1(): Int { ...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
1,363
adventofcode2015
MIT License
openrndr-kartifex/src/commonMain/kotlin/utils/Combinatorics.kt
openrndr
122,222,767
false
{"Kotlin": 2343473, "ANTLR": 9333, "GLSL": 2677, "CSS": 87}
package org.openrndr.kartifex.utils object Combinatorics { val MAX_RESULTS = 32 inline fun <reified V> permutations(values: List<V>): List<List<V>> { // if exhaustive searching is out of the question, put your trust in the RNG if (values.size > 4) { List(MAX_RESULTS) { ...
34
Kotlin
71
808
7707b957f1c32d45f2fbff6b6a95a1a2da028493
2,326
openrndr
BSD 2-Clause FreeBSD License
src/Day12.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
import java.util.* fun main() { data class Point(val x: Int, val y: Int, val elevation: Int) var startPoint: Point? = null var endPoint: Point? = null fun getPoints(input: List<String>): List<List<Point>> = input.mapIndexed { y, line -> line.mapIndexed { x, char -> val elevation = when (char) { 'S' -> '...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
3,052
advent-of-code-2022
Apache License 2.0
numeriko-complex/src/main/kotlin/tomasvolker/numeriko/complex/transforms/fft/FunctionalFFT.kt
TomasVolker
114,266,369
false
null
package tomasvolker.numeriko.complex.transforms.fft import tomasvolker.numeriko.complex.primitives.Complex import tomasvolker.numeriko.complex.primitives.toComplex import tomasvolker.numeriko.complex.transforms.mapBoth import tomasvolker.numeriko.complex.transforms.partitionByIndex import tomasvolker.numeriko.complex....
8
Kotlin
1
3
1e9d64140ec70b692b1b64ecdcd8b63cf41f97af
2,891
numeriko
Apache License 2.0
src/main/kotlin/org/sjoblomj/adventofcode/day7/Day7.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day7 import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.sjoblomj.adventofcode.day7.visualisation.visualise import org.sjoblomj.adventofcode.readFile import kotlin.system.measureTimeMillis private const val inputFile = "src/main/resources/inputs/day7.txt...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
5,253
adventofcode2018
MIT License
src/Day20.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
fun main() { class Node(val value: Long) { lateinit var previous: Node lateinit var next: Node override fun toString() = value.toString() } class MutableRingBuffer(initialItems: List<Long>) : Iterable<Node> { private var head: Node private var zero: Node val...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
3,334
advent-of-code-2022
Apache License 2.0
src/main/java/leetcode/a392_isSubSequence_HARD/Solution.kt
Laomedeia
122,696,571
true
{"Java": 801075, "Kotlin": 38473, "JavaScript": 8268}
package leetcode.a392_isSubSequence_HARD /** * 判断子序列 * * 给定字符串 s 和 t ,判断 s 是否为 t 的子序列。 * 你可以认为 s 和 t 中仅包含英文小写字母。字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 <=100)。 * * 字符串的一个子序列是原始字符串删除一些(也可以不删除)字符而不改变剩余字符相对位置形成的新字符串。(例如,"ace"是"abcde"的一个子序列,而"aec"不是)。 * * 示例 1: * s = "abc", t = "ahbgdc" * 返回 true. * * 示例 2: ...
0
Java
0
0
0dcd8438e0846493ced9c1294ce686bac34c8614
1,661
Java8InAction
MIT License
src/Day01.kt
anoniim
572,264,555
false
{"Kotlin": 8381}
fun main() { Day1().run( 24000, 45000 ) } private class Day1 : Day(1) { override fun part1(input: List<String>): Int { // Find the Elf carrying the most Calories. How many total Calories is that Elf carrying? return parseElves(input).maxOf { it.totalCalories() } } o...
0
Kotlin
0
0
15284441cf14948a5ebdf98179481b34b33e5817
1,153
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/FloydWarshall.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph println("Test") /* https://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/ relax all intermediate nodes O(V^3) 1. create adj matrix directed weighted graph 2. for each intermediate in 0 until V for each start in 0 until V for each end in ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,223
KotlinAlgs
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[72]编辑距离.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你两个单词 word1 和 word2,请你计算出将 word1 转换成 word2 所使用的最少操作数 。 // // 你可以对一个单词进行如下三种操作: // // // 插入一个字符 // 删除一个字符 // 替换一个字符 // // // // // 示例 1: // // //输入:word1 = "horse", word2 = "ros" //输出:3 //解释: //horse -> rorse (将 'h' 替换为 'r') //rorse -> rose (删除 'r') //rose -> ros (删除 'e') // // // 示例 2: // // //输入:word1 ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,019
MyLeetCode
Apache License 2.0
src/main/kotlin/aoc2020/ShuttleSearch.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.lcm fun shuttleService1(time: Long, input: String): Int { val shuttles = input.split(",").filter { it != "x" }.map { it.toInt() } val (shuttle, waitTime) = shuttles.map { it to shuttleWait(it, time) }.minByOrNull { it.second }!! return shu...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,257
advent-of-code
MIT License
Contest/Weekly Contest 299/Maximum Score of Spliced Array/SplicedArray.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun maximumsSplicedArray(nums1: IntArray, nums2: IntArray): Int { val n = nums1.size if (n == 1) return maxOf(nums1[0], nums2[0]) val prefixes1 = IntArray(n) { 0 } var prefix1 = 0 for (i in 0..n-1) { prefix1 += nums1[i] prefixes1[i] =...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,635
leet-code
MIT License
src/Day01.kt
gsalinaslopez
572,839,981
false
{"Kotlin": 21439}
fun main() { fun part1(input: List<String>): Int { var currentElf = 0 var maxElf = -1 input.forEach { if (it.isEmpty()) { maxElf = maxOf(maxElf, currentElf) currentElf = 0 } else { currentElf += it.toInt() }...
0
Kotlin
0
0
041c7c3716bfdfdf4cc89975937fa297ea061830
1,011
aoc-2022-in-kotlin
Apache License 2.0
solutions/qualifications/reverse-sort/src/main/kotlin/solutions.reverse.sort/ReverseSortSolution.kt
Lysoun
351,224,145
false
null
fun main(args: Array<String>) { val casesNumber = readLine()!!.toInt() for (i in 1..casesNumber) { // Ignore first line of case readLine() println("Case #$i: ${computeReverseCostToSortList(readLine()!!.split(" ").map { it.toInt() })}") } } fun computeReverseCostToSortList(numbers:...
0
Kotlin
0
0
98d39fcab3c8898bfdc2c6875006edcf759feddd
1,245
google-code-jam-2021
MIT License
kotlin/src/2023/Day04_2023.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
private fun parseItems(s: String): List<Int> { return s.trim().replace(Regex("\\s+"), " ").split(" ").map {it.toInt()} } fun main() { val input = readInput(4, 2023) val gamePat = Regex("Card\\s+([0-9]+): (.*) \\| (.*)") val games = input.trim().split("\n") .map {gamePat.matchEntire(it)!!.group...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
826
adventofcode
Apache License 2.0
src/2022/Day03.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import java.io.File import java.util.* fun main() { Day03().solve() } class Day03 { val input1 = """ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw """.trimIndent() fun prio(c: Cha...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
1,478
advent-of-code
Apache License 2.0
app/src/y2021/day08/Day08WithoutAnalyzingIndividualSegments.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day08 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle import java.util.* /** * A way nicer solution. * run it by using the main method in the other class */ @AoCPuzzle(2021, 8) class Day08WithoutAnalyzingIndividualSegments : AocSolution { override val answers =...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
2,056
advent-of-code-2021
Apache License 2.0
src/main/kotlin/Day19.kt
Yeah69
317,335,309
false
{"Kotlin": 73241}
class Day19 : Day() { override val label: String get() = "19" private interface Rule { fun buildRegexString(): String } private class EmptyRule : Rule { override fun buildRegexString() = "" } private class CharRule(val char: Char) : Rule { override fun buildRegexString...
0
Kotlin
0
0
23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec
3,548
AdventOfCodeKotlin
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfProvinces.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,184
kotlab
Apache License 2.0
aoc-kotlin/src/main/kotlin/day05/Day05.kt
mahpgnaohhnim
573,579,334
false
{"Kotlin": 29246, "TypeScript": 1975, "Go": 1693, "Rust": 1520, "JavaScript": 123}
package day05 import java.io.File class Day05 { companion object { fun getResultText(inputText: String, part2: Boolean = false): String { val parts = inputText.split("\n\n") val data = parseData(parts[0]) executeCommands(parts[1], data, part2) return data.ma...
0
Kotlin
0
0
c514152e9e2f0047514383fe536f7610a66aff70
2,851
aoc-2022
MIT License
src/main/kotlin/g0501_0600/s0576_out_of_boundary_paths/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0576_out_of_boundary_paths // #Medium #Dynamic_Programming #2023_01_23_Time_153_ms_(100.00%)_Space_34.7_MB_(80.00%) class Solution { private val dRowCol = arrayOf(intArrayOf(1, 0), intArrayOf(-1, 0), intArrayOf(0, 1), intArrayOf(0, -1)) private fun dfs( m: Int, n: Int, ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,528
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g1201_1300/s1300_sum_of_mutated_array_closest_to_target/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1300_sum_of_mutated_array_closest_to_target // #Medium #Array #Sorting #Binary_Search #Binary_Search_II_Day_16 // #2023_06_08_Time_217_ms_(100.00%)_Space_38.8_MB_(100.00%) class Solution { fun findBestValue(arr: IntArray, target: Int): Int { arr.sort() val n = arr.size ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,208
LeetCode-in-Kotlin
MIT License
src/day16/d16_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val tickerTape = mapOf( "children" to 3, "cats" to 7, "samoyeds" to 2, "pomeranians" to 3, "akitas" to 0, "vizslas" to 0, "goldfish" to 5, "trees" to 3, "cars" to 2, "perfumes" to 1 ) println(input.lines...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
800
aoc2015
MIT License
src/main/kotlin/dec8/Main.kt
dladukedev
318,188,745
false
null
package dec8 sealed class Instruction { object Noop : Instruction() data class Jump(val distance: Int) : Instruction() data class Accumulate(val amount: Int) : Instruction() } data class State( val accumulator: Int = 0, val pointer: Int = 0, val calledInstructions: List<Int> = emptyList() ) f...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
2,315
advent-of-code-2020
MIT License
advent-of-code-2020/src/test/java/aoc/Day13ShuttleSearch.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
package aoc import org.assertj.core.api.Assertions.assertThat import org.junit.Test import kotlin.math.abs class Day13ShuttleSearch { @Test fun silverTest() { assertThat(calculateWaitTime(testInput)).isEqualTo(295) } @Test fun silver() { assertThat(calculateWaitTime(taskInput)).is...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
3,715
advent-of-code
MIT License
2023/src/main/kotlin/net/daams/solutions/9a.kt
Michiel-Daams
573,040,288
false
{"Kotlin": 39925, "Nim": 34690}
package net.daams.solutions import net.daams.Solution class `9a`(input: String): Solution(input) { override fun run() { val valueHistories = input.split("\n").map { history -> history.split(" ").map { it.toInt() }.toMutableList() }.toMutableList() val valuePredictions = valueHistories.map { mutab...
0
Kotlin
0
0
f7b2e020f23ec0e5ecaeb97885f6521f7a903238
1,286
advent-of-code
MIT License
facebook/y2020/qual/d1.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.qual private fun solve(): Long { val (n, m) = readInts() val c = List(n) { readInt() } val a = mutableListOf(m to 0L) var low = 0 val inf = c.fold(0L, Long::plus) + 1 for (i in c.indices) { while (a[low].first < i) low++ val cost = a[low].second if (i == n - 1) return cost.takeIf { i...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
859
competitions
The Unlicense
07/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File import kotlin.math.* fun readInput() : List<Int> { return File("input.txt") .readLines() .flatMap { it.split(",") } .map { it.toInt() } } fun movementCost(positions : List<Int>, finalPos : Int) : Int { var result = 0 for (position in positions) { ...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
998
advent-of-code-2021
MIT License
day12/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File fun main() { val rawInput = readInputFile() val initialState = getInitialState(rawInput) val plantGeneratingPatterns = getPlantGeneratingPatterns(rawInput) println("Part I: the solution is ${solvePartI(initialState, plantGeneratingPatterns)}.") println("Part II: the solution is...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
5,659
AdventOfCode2018
MIT License
src/Day11.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
import java.util.PriorityQueue fun <T> Iterable<T>.split(n: Int): Pair<List<T>, List<T>> { val iter = iterator() val head = iter.asSequence().take(n).toList() val tail = iter.asSequence().toList() return head to tail } fun <T: Comparable<T>> Iterable<T>.nLargest(n: Int): List<T> { val (head, tail)...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
3,863
advent-of-code-2022
Apache License 2.0
src/algorithms/sorting/quick_sort/QuickSort.kt
abdurakhmonoff
353,686,707
false
null
package algorithms.sorting.quick_sort /** * Implementation of the quick sort algorithm for sorting a list of integers in ascending order. */ class QuickSort { /** * Sorts an array of integers in ascending order using QuickSort algorithm. * * @param arr the array to be sorted. * @param low th...
0
Kotlin
40
107
cd9746d02b34b54dd0cf8c8dacc2fb91d2a3cc07
2,116
data-structures-and-algorithms-kotlin
MIT License
src/main/kotlin/year2023/day10/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2023.day10 import IProblem import java.lang.Exception import kotlin.math.abs class Problem : IProblem { private val matrix: Array<CharArray> private val n: Int private val m: Int private val start: Pair<Int, Int> init { val lines = javaClass .getResourceAsStream("/...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
2,644
advent-of-code
The Unlicense
src/main/kotlin/day14.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.Point import shared.getText fun main() { val input = getText("day14.txt") println(day14A(input)) println(day14B(input)) } fun day14A(input: String) = fallingSand(input) fun day14B(input: String) = fallingSand(input, true) private fun fallingSand(input: String, hasFloor: Boolean = false): In...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
2,000
AdventOfCode2022
MIT License
src/Day01.kt
Oli2861
572,895,182
false
{"Kotlin": 16729}
fun main() { fun toCalorieList(input: List<String>): MutableList<Int> { val list = mutableListOf<Int>() var currAmount = 0 for ((index, str) in input.withIndex()) { if (str.matches(Regex("[0-9]+"))) { currAmount += Integer.parseInt(str) if (index...
0
Kotlin
0
0
138b79001245ec221d8df2a6db0aaeb131725af2
1,115
Advent-of-Code-2022
Apache License 2.0
src/main/aoc2022/Day20.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import kotlin.math.abs import kotlin.math.sign class Day20(input: List<String>) { private val parsedInput = input.map { it.toInt() } fun solvePart1(): Long { val sequence = Sequence(parsedInput, 1) sequence.mix() return sequence.coordinateSum() } fun solvePar...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
4,403
aoc
MIT License
src/main/kotlin/biz/koziolek/adventofcode/year2021/day25/day25.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day25 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val map = parseSeaCucumberMap(lines) val (stepNumber, _) = moveUntilStop(map) println("Sea cucumbers stop moving ...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,840
advent-of-code
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day05.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day5() = puzzle(day = 5) { val blocks = input.doubleLines() val seeds = blocks.first().substringAfter(": ").split(" ").map(String::toLong) val maps = blocks.drop(1).map { it.lines() }.map { p -> p.drop(1).map { it.spl...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,396
advent-of-code
The Unlicense
src/main/kotlin/sschr15/aocsolutions/Day13.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* /** * AOC 2023 [Day 13](https://adventofcode.com/2023/day/13) * Challenge: Find a bunch of mirrors (so you don't run into them in such an embarrassing way) * * but wait! the mirrors actually got smudged so now you gotta make sure you can avoid them ...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
3,338
advent-of-code
MIT License
day09/src/main/kotlin/Day09.kt
bzabor
160,240,195
false
null
class Day09(private val input: List<String>) { private val circle = arrayListOf(0) private val numberOfPlayers = 439 private val marblesToPlay = 7130700 private val playerScores: MutableMap<Int, Long> = (1..numberOfPlayers).associate { it to 0L }.toMutableMap() private var currentPosition = 0 ...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
3,028
AdventOfCode2018
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2020/Day08.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 8 - Handheld Halting * Problem Description: http://adventofcode.com/2020/day/8 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day8/ */ package com.ginsberg.advent2020 class Day08(input: List<String>) { private v...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
2,924
advent-2020-kotlin
Apache License 2.0
src/nativeMain/kotlin/Day17.kt
rubengees
576,436,006
false
{"Kotlin": 67428}
import kotlin.math.max class Day17 : Day { private data class Point(val x: Int, val y: Int) private data class Shape(val data: Map<Point, Unit>) { fun moveTo(x: Int, y: Int): Shape { return Shape(data.mapKeys { (point, _) -> Point(point.x + x, point.y + y) }) } fun collide...
0
Kotlin
0
0
21f03a1c70d4273739d001dd5434f68e2cc2e6e6
3,105
advent-of-code-2022
MIT License
src/main/kotlin/days/Day01.kt
Kebaan
573,069,009
false
null
package days import utils.Day import utils.splitBy fun main() { Day01.solve() } object Day01 : Day<Int>(2022, 1) { private fun calculateSumOfNLargest(bags: List<List<String>>, n: Int) = bags.map { bagOfCalories -> bagOfCalories.sumOf { it.toInt() } }.sortedDescending().take(n).sum() override...
0
Kotlin
0
0
ef8bba36fedbcc93698f3335fbb5a69074b40da2
1,234
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/polydus/aoc18/Day7.kt
Polydus
160,193,832
false
null
package com.polydus.aoc18 class Day7: Day(7){ //https://adventofcode.com/2018/day/7 init { //partOne() partTwo() } fun partOne(){ val map = HashMap<Char, Node>() input.forEach { val type = it.toCharArray()[36] val parent = it.toCharArray()[5]...
0
Kotlin
0
0
e510e4a9801c228057cb107e3e7463d4a946bdae
4,948
advent-of-code-2018
MIT License
src/medium/_39CombinationSum.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package medium import java.util.* class _39CombinationSum { class Solution { fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> { if (candidates.isEmpty()) { return emptyList() } val result = ArrayList<List<Int>>() val cu...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
2,328
AlgorithmsProject
Apache License 2.0
ceria/04/src/main/kotlin/Solution.kt
VisionistInc
572,963,504
false
null
import java.io.File; fun main(args : Array<String>) { var input = mutableListOf<Pair<ClosedRange<Int>, ClosedRange<Int>>>() File(args.first()).readLines().forEach { var ranges = it.split(',') var firstR = ranges.get(0).split('-') var secondR = ranges.get(1).split('-') input.add(...
0
Rust
0
0
90b348d9c8060a8e967fe1605516e9c126fc7a56
1,372
advent-of-code-2022
MIT License
src/main/kotlin/com/colinodell/advent2023/Day11.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day11(input: List<String>) { private val grid = input.toGrid(ignore = '.') private fun expand(g: Grid<Char>, growthFactor: Int): Grid<Char> { val f = growthFactor - 1 val emptyRows = g.rows().filter { y -> g.none { (pos, _) -> pos.y == y } } val...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
909
advent-2023
MIT License
src/main/kotlin/nl/jhvh/sudoku/util/ListElementStringUtil.kt
JanHendrikVanHeusden
305,492,630
false
null
package nl.jhvh.sudoku.util /* Copyright 2020 <NAME> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable la...
0
Kotlin
0
1
5a487a594600edc28b46067b12ed9a5ac610bea2
7,635
Sudoku
Apache License 2.0
src/day13/Day13.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day13 import helpers.ReadFile import java.lang.Integer.min class Day13 { val lines = ReadFile.named("src/day13/input.txt", "\n\n") val linet = ReadFile.named("src/day13/testinput.txt", "\n\n") class RecursiveArray { var children: MutableList<RecursiveArray>? = null var number: In...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
4,474
adventofcode2022
MIT License
src/main/java/com/booknara/problem/union/NumberOfConnectedComponentsInUndirectedGraphKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.union /** * 323. Number of Connected Components in an Undirected Graph (Medium) * https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ */ class NumberOfConnectedComponentsInUndirectedGraphKt { // T:O(n with path compression), S:O(n) fun countComponent...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,073
playground
MIT License
src/Utils.kt
er453r
572,440,270
false
{"Kotlin": 69456}
import java.io.File import java.math.BigInteger import kotlin.math.abs import kotlin.math.max fun readInput(name: String) = File("aoc2022/src", "$name.txt") .readLines() fun <T> assertEquals(value: T, target: T) { if (value != target) check(false) { "Expected $target got $value" } } fun String.destru...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
8,161
aoc2022
Apache License 2.0
src/main/kotlin/day8/Day8MemoryManeuver.kt
Zordid
160,908,640
false
null
package day8 import shared.extractAllPositiveInts import shared.readPuzzle data class TreeDef(val childrenSize: Int, val metadataSize: Int) { val children = mutableListOf<TreeDef>() val metadata = mutableListOf<Int>() val metadataSum: Int get() = metadata.sum() + children.sumOf { it.metadataSum } val ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
1,156
adventofcode-kotlin-2018
Apache License 2.0
src/advent/of/code/SecondPuzzle.kt
1nco
725,911,911
false
{"Kotlin": 112713, "Shell": 103}
package advent.of.code class SecondPuzzle { companion object { private val day = "2"; private var input: MutableList<String> = arrayListOf(); private val cubes = Game(12,13,14); private var sumOfIds = 0; private var sumOfPowers = 0; fun solve() { in...
0
Kotlin
0
0
0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3
3,148
advent-of-code
Apache License 2.0
src/Day04.kt
othimar
573,607,284
false
{"Kotlin": 14557}
fun main() { fun part1(input: List<String>): Int { var result = 0 val regex = "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRegex() for (line in input) { val matchesResult = regex.find(line) val (a, b, c, d) = matchesResult!!.destructured if ( ((a.to...
0
Kotlin
0
0
ff62a00123fe817773ff6248d34f606947ffad6d
1,337
advent-of-code-2022
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day13/Day13.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day13 import eu.janvdb.aocutil.kotlin.readGroupedLines import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input13-test.txt" const val FILENAME = "input13.txt" fun main() { part1() part2() } private fun part1() { val pairs = readGroupedLines(2022, FILENAME) .map { Pair(i...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
880
advent-of-code
Apache License 2.0
Problems/Algorithms/834. Sum of Distances in Tree/SumDistancesTree.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { val graph: MutableList<HashSet<Int>> init { graph = mutableListOf() } fun sumOfDistancesInTree(n: Int, edges: Array<IntArray>): IntArray { val subsum: IntArray = IntArray(n) val count: IntArray = IntArray(n) { 1 } val ans: IntArray = IntArray(n) ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,301
leet-code
MIT License
datastructures/src/main/kotlin/com/kotlinground/datastructures/arrays/maxlencontiguoussubarray/findmaxlen.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.datastructures.arrays.maxlencontiguoussubarray import kotlin.math.max /** * Finds the maximum length of a contiguous sub array in a binary array. Makes use of a hashmap to store the entries in * the form of (count, index). We make an entry for a count in the map whenever the count is encoun...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
1,470
KotlinGround
MIT License
src/year2021/day01/Day01.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2021.day01 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { fun part1(input: List<String>): Int { var prev = input.first().toInt() var numIncreases = 0 input.drop(1) .map { it.toInt() } .forEach { if (it > pre...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,015
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day2/Day2.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day2 import execute import readAllText import wtf fun main() { val input = readAllText("local/day2_input.txt") execute(::part1, input) execute(::part2, input) } fun part1(input: String) = input.lineSequence().filterNot(String::isBlank).sumOf(::part1result) fun part2(input: String) = input.lineSeq...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
1,018
advent-of-code-2022
MIT License
lib/src/main/kotlin/io/github/nathlrowe/math/distributions/Weights.kt
nathlrowe
741,153,113
false
{"Kotlin": 101522}
package io.github.nathlrowe.math.distributions import io.github.nathlrowe.random.RandomValue import io.github.nathlrowe.utils.toPercentString import kotlin.random.Random class Weights<T>(private val rawWeights: Map<T, Double>) : RandomValue<T>, Iterable<Pair<T, Double>> { val totalWeight: Double = rawWeights.valu...
0
Kotlin
0
0
433528d09a68eb866bec73b96dc3a1537d609f03
4,642
kotlin-utils
MIT License
capitulo5/src/main/kotlin/5.23(Números palíndromos).kt
Cursos-Livros
667,537,024
false
{"Kotlin": 104564}
//5.23 (Números palíndromos) Um número inteiro positivo é um palíndromo se seu valor for o mesmo depois de inverter //a ordem dos dígitos no número. Por exemplo, 12321 é um palíndromo, mas 12563 não é. //Escreva um método que determine se um número é um palíndromo. Use este método em um aplicativo que determina se um /...
0
Kotlin
0
0
f2e005135a62b15360c2a26fb6bc2cbad18812dd
1,537
Kotlin-Como-Programar
MIT License
src/commonMain/kotlin/advent2020/day10/Day10Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day10 // Disclaimer, my solution was much uglier (although it worked in decent time complexity) // This was developed after the hint from a friend // Also, I should've looked at the puzzle name, which literally was "Adapter Array" // It is now true O(n) fun part1(input: String): String { val a...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
1,445
advent-of-code-2020
MIT License
src/main/kotlin/algorithms/Clumps.kt
jimandreas
377,843,697
false
null
@file:Suppress("UnnecessaryVariable") package algorithms /** * Returns a new character sequence that is a subsequence of this character sequence * * @param stringToSearch where to look for clumps * @param occurenceMin filter level for number of clumps in a window * @param windowLen length of window to search *...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
2,123
stepikBioinformaticsCourse
Apache License 2.0
src/day08/Day08Answer1.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
fun main() { val dayId = "08" val input = readInput("Day${dayId}") val a = input.map { s -> s.map { it.digitToInt() } } val n = a.size val m = a[0].size // part 1 val v = Array(n) { BooleanArray(m) } for (i in 0 until n) { var h = -1 for (j in 0 until m) { if ...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
1,981
aoc-2022
Apache License 2.0
kotlin/basics/src/main/kotlin/UnionFind.kt
suzp1984
65,159,392
false
{"C++": 29471, "Java": 26106, "Kotlin": 10984, "Scala": 9694, "JavaScript": 3248, "CMake": 442, "Swift": 171}
package io.github.suzp1984.algorithms class UnionFind(size : Int) { val ids : Array<Int> init { ids = Array(size) { it } } private fun find(p : Int) : Int { if (p < 0 || p > ids.size) throw IllegalArgumentException("array out of scope") return ids[p] } fu...
0
C++
0
0
ea678476a4c70e5135d31fccd8383fac989cc031
1,434
Algorithms-Collection
Apache License 2.0
src/Day01.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
fun main() { fun part1(input: List<String>): Int { val totalCalories = mutableListOf<Int>() var currentTotal = 0 input.forEach { if (it.isBlank()) { totalCalories.add(currentTotal) currentTotal = 0 } else { currentTotal ...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
1,073
aoc-2022
Apache License 2.0
src/main/kotlin/year2022/day18/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day18 import IProblem class Problem : IProblem { private val points = javaClass .getResource("/2022/18.txt")!! .readText() .lines() .filter(String::isNotEmpty) .map { val split = it.split(',').map(String::toInt) Point(split[0], split...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
2,756
advent-of-code
The Unlicense
codeforces/round626/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round626 fun main() { readLn() var a = readInts().sorted() val powers = a.last().toString(2).length downTo 0 val ans = powers.sumBy { k -> val two = 1 shl k val res = (1..4).sumBy { countLess(a, it * two) } and 1 a = a.map { it and two - 1 }.sorted() two * res } println(ans) } private...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
631
competitions
The Unlicense
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day19.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput class Day19 : Day<Int> { private val sections: List<String> = readDayInput().split("\n\n") private val step1Rules: Map<Int, String> = sections[0] .lines() .assoc...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
2,760
adventofcode
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Day09.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day09(input: List<String>) { private val directions = mapOf( "L" to Vector2(-1, 0), "R" to Vector2(1, 0), "U" to Vector2(0, -1), "D" to Vector2(0, 1), ) /** * Generate a sequence of all points the head knot passes through */...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,608
advent-2022
MIT License
src/Day01.kt
daletools
573,114,602
false
{"Kotlin": 8945}
fun main() { fun part1(input: List<String>): Int { val elves = IntArray(input.filter { it.isEmpty() }.size + 1) var elf = 0 for (item in input) { val cal = item.toIntOrNull() if (cal != null) { elves[elf] += cal } else { elf...
0
Kotlin
0
0
c955c5d0b5e19746e12fa6a569eb2b6c3bc4b355
1,156
adventOfCode2022
Apache License 2.0
src/main/kotlin/g1701_1800/s1766_tree_of_coprimes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1766_tree_of_coprimes // #Hard #Math #Depth_First_Search #Breadth_First_Search #Tree // #2023_06_18_Time_991_ms_(100.00%)_Space_89.3_MB_(100.00%) @Suppress("kotlin:S107") class Solution { private fun dfs( v2n: IntArray, v2d: IntArray, depth: Int, parent: Int, ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,723
LeetCode-in-Kotlin
MIT License
kotlin/src/com/s13g/aoc/aoc2021/Day22.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver import kotlin.math.abs /** * --- Day 22: Reactor Reboot --- * https://adventofcode.com/2021/day/22 */ class Day22 : Solver { val regex = """(\w+)+ x=([-]*\d+)..([-]*\d+),y=([-]*\d+)..([-]*\d+),z=([-]*\d+)..([-]*\d+)""".toRegex...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,518
euler
Apache License 2.0
src/aoc2022/Day18.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.checkEquals import utils.sendAnswer private data class Coor3D(val x: Int, val y: Int, val z: Int) fun main() { fun part1(input: List<String>): Int { val cubes = input.map { val cube = it.split(',').map { it.toInt() } Coor3D(cube[0], cube[1], cube[2]...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,112
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/com/github/freekdb/kotlin/workshop/step04/BirthdayPuzzle.kt
FreekDB
230,429,337
false
null
package com.github.freekdb.kotlin.workshop.step04 /** * A puzzle: Calvin and Hobbes are celebrating their birthdays. * * One is '44' in base a, * the other is '55' in base b, * the sum of their ages is '77' in base c and * the difference is '111' in base d. * d < a < b < c and all are natural numbers. * Hobbes...
0
Kotlin
0
2
5a9bb08a8d0bd3d68dd2274becf4758ab10caf5d
2,494
kotlin-for-kurious-koders
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindWinners.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,952
kotlab
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day11/day11.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day11 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val monkeys = parseMonkeys(inputFile.bufferedReader().readLines()) val monkeys20 = playKeepAway(monkeys, rounds = 20) println("Monkey business after 20 rounds:...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
8,849
advent-of-code
MIT License
src/main/kotlin/leetcode/s100/Solution101.kt
IgorPerikov
134,053,571
false
{"Kotlin": 29606}
package leetcode.s100 import leetcode.other.TreeNode import java.util.* class Solution101IterativeDfs { fun isSymmetric(root: TreeNode?): Boolean { if (root == null) return true val leftNodes: Deque<TreeNode> = ArrayDeque<TreeNode>().also { it.addFirst(root.left ?: TreeNode(Int.MIN_VAL...
0
Kotlin
0
0
b30cf179f7b7ae534ee55d432b13859b77bbc4b7
2,954
kotlin-solutions
MIT License
src/Day24.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
import Traveling.* import java.util.* import kotlin.math.absoluteValue @JvmInline private value class Minute(val value: UInt) : Comparable<Minute> { operator fun plus(other: Minute) = Minute(value + other.value) operator fun inc() = Minute(value.inc()) operator fun dec() = Minute(value.dec()) override ...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
6,875
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day12/SpringRecord.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day12 private val CONDITION_REGEX = "[.#?]+".toRegex() private val RECORD_REGEX = "($CONDITION_REGEX) (.*)".toRegex() fun String.toSpringRecord(): SpringRecord { val result = requireNotNull(RECORD_REGEX.matchEntire(this)) { "$this must match $RECORD_REGEX" } ...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
3,243
advent-2023
ISC License
src/main/kotlin/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0101_0200.s0105_construct_binary_tree_from_preorder_and_inorder_traversal // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Tree #Binary_Tree // #Divide_and_Conquer #Data_Structure_II_Day_15_Tree #Big_O_Time_O(N)_Space_O(N) // #2023_07_11_Time_183_ms_(95.45%)_Space_36.9_MB_(82.7...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,404
LeetCode-in-Kotlin
MIT License
src/main/kotlin/days/Day17.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days import util.Point class Day17 : Day(17) { override fun runPartOne(lines: List<String>): Any { //x=150..171, y=-129..-70 val minX = 150 val maxX = 171 val minY = -129 val maxY = -70 val vector = findHighestLaunch(minX, maxX, minY, maxY) return f...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
3,040
aoc2021
Creative Commons Zero v1.0 Universal