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/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions53.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 fun test53() { printlnResult1(3, intArrayOf(1, 2, 3, 3, 3, 3, 4, 5)) printlnResult1(3, intArrayOf(3, 3, 3, 3, 4, 5, 6)) printlnResult1(3, intArrayOf(1, 1, 2, 3, 3, 3, 3)) printlnResult1(1, intArrayOf(1)) printlnResult1(0, intArrayOf(1, 1, 1, 1, 1, 1)) pri...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
4,513
Algorithm
Apache License 2.0
src/main/kotlin/Day10.kt
andrewrlee
434,584,657
false
{"Kotlin": 29493, "Clojure": 14117, "Shell": 398}
import Day10.Type.CLOSE import Day10.Type.OPEN import java.io.File import java.nio.charset.Charset.defaultCharset import java.util.Stack object Day10 { data class Bracket(val bracketType: BracketType, val type: Type) enum class Type { OPEN, CLOSE } enum class BracketType(val open: Char, val close: Char, ...
0
Kotlin
0
0
aace0fccf9bb739d57f781b0b79f2f3a5d9d038e
2,551
adventOfCode2021
MIT License
src/main/kotlin/g2601_2700/s2601_prime_subtraction_operation/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2601_2700.s2601_prime_subtraction_operation // #Medium #Array #Math #Greedy #Binary_Search #Number_Theory // #2023_07_13_Time_233_ms_(100.00%)_Space_38.4_MB_(100.00%) class Solution { private fun primesUntil(n: Int): IntArray { if (n < 2) return intArrayOf() val primes = IntArray(200) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,246
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Day05.kt
uipko
572,710,263
false
{"Kotlin": 25828}
enum class MoverType { TYPE_9000, TYPE_9001 } fun main() { val crates = crateMover("Day05.txt", MoverType.TYPE_9000) println("CrateMover 9000 top crates are $crates") val crates2 = crateMover("Day05.txt", MoverType.TYPE_9001) println("CrateMover 9001 top crates are $crates2") } fun crateMov...
0
Kotlin
0
0
b2604043f387914b7f043e43dbcde574b7173462
1,198
aoc2022
Apache License 2.0
src/jvmMain/kotlin/Atom.kt
leonhardbrenner
327,734,139
false
null
import java.util.* val Pair<Int, Int>.a: Int get() = first val Pair<Int, Int>.b: Int get() = second fun <T, R> Sequence<T>.reductions(initial: R, operation: (acc: R, T) -> R) : Sequence<R> = sequence { var last = initial forEach { last = operation(last, it) yield(last) } } class Atom(val ...
0
Kotlin
0
1
a7b970179bb6a740475879a036dc4d9189203290
3,628
kitchensink
MIT License
src/utils/Itertools.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
package utils import java.util.* /** * Chain multiple sequences together. */ fun <T> Sequence<T>.chain(other: Sequence<T>): Sequence<T> = this.iterator().let { iterator -> sequence { for (item in iterator) { this.yield(item) } for (item in other.iterat...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
5,336
aoc2022-kotlin
Apache License 2.0
src/Day01.kt
korsik
573,366,257
false
{"Kotlin": 5186}
fun main() { fun part1(input: List<String>): Int { val data = mutableListOf<Int>() var point = 0 data.add(0) for (num in input) { if (num == "") { point++ data.add(0) } else { data[point] += num.toInt...
0
Kotlin
0
0
1a576c51fc8233b1a2d64e44e9301c7f4f2b6b01
1,055
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DesignTicTacToe.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <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,416
kotlab
Apache License 2.0
src/Day14.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import kotlin.math.abs object Day14 { @JvmStatic fun main(args: Array<String>) { val input = downloadAndReadInput("Day14", "\n").filter { it.isNotBlank() }.map { it.split(" -> ").map { it.split(",").let { (x, y) -> Point(x.toInt(), y.toInt()) } } } val minX = input.flatten(...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
3,759
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day20/part2/Part2.kt
bagguley
329,976,670
false
null
package day20.part2 import day20.* import java.lang.StringBuilder fun main() { val tiles = load(data) val corners = findCorners(tiles) println(corners.map { it.number }.fold(1L, {a,i -> a * i} )) val edges = findEdges(tiles) val allEdges: MutableList<Tile> = mutableListOf() allEdges.addAll...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
6,604
adventofcode2020
MIT License
year2015/src/main/kotlin/net/olegg/aoc/year2015/day9/Day9.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day9 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.permutations import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 9](https://adventofcode.com/2015/day/9) */ object Day9 : DayOf2015(9) { private val PATTERN = "^\\b(\\w*)\\b to \\b(\\w*)\\b = (\\d*)$"...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,136
adventofcode
MIT License
src/main/kotlin/aoc/utils/Collections.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package aoc.utils fun <T> List<T>.splitMiddle(): Pair<List<T>,List<T>> { if(size % 2 != 0) throw Error("Cannot split middle list of size $size") return Pair(subList(0,size/2),subList(size/2,size)) } fun <E> List<E>.getLooping(index: Int): E { if(index < 0) { return this[(index+(-1 * index /...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
1,689
adventOfCode2022
Apache License 2.0
src/Day06.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
fun main() { fun solvePart1(s: String): Int { for (i in 4 until s.length) { if (s.substring(i - 4, i).toSet().size == 4) { return i } } return -1 } fun solvePart2(s: String): Int { val chars = MutableList<Int>(26) { 0 } // uni...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
1,093
AoC-2022-kotlin
Apache License 2.0
advent-of-code-2023/src/main/kotlin/Day01.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
// Day 1: Trebuchet?! // https://adventofcode.com/2023/day/1 import java.io.File private val digits = listOf("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") fun main() { val lines = File("src/main/resources/Day01.txt").readLines() val sum1 = lines.sumOf { line -> line....
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
1,593
advent-of-code
Apache License 2.0
jtransc-core/src/com/jtransc/graph/LCA.kt
jtransc
51,313,992
false
null
package com.jtransc.graph // https://en.wikipedia.org/wiki/Lowest_common_ancestor class LCATree(val capacity: Int) { val parents: IntArray = IntArray(capacity) val depths: IntArray = IntArray(capacity) private var current: Int = 1 val Int.parent:Int get() = parents[this] val Int.depth:Int get() = depths[this] ...
59
Java
66
619
6f9a2166f128c2ce5fb66f9af46fdbdbcbbe4ba4
992
jtransc
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PancakeSortLeetcode.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,846
kotlab
Apache License 2.0
tonilopezmr/day6/MemoryBank.kt
CloudCoders
112,667,277
false
{"Mathematica": 37090, "Python": 36924, "Scala": 26540, "Kotlin": 24988, "Ruby": 5084, "Java": 4495, "JavaScript": 3440, "MATLAB": 3013}
package day6 import kategory.combine import org.junit.Assert.assertEquals import org.junit.Test typealias P = Pair<Int, Int> class MemoryBank { private fun chooseBank(input: List<Int>): Pair<Int, Int> = input.foldRightIndexed(P(0, 0)) { idx, bank, (index, blocks) -> if (bank >= blocks) P(idx, bank) ...
2
Mathematica
0
8
5a52d1e89076eccb55686e4af5848de289309813
2,763
AdventOfCode2017
MIT License
src/main/kotlin/org/flightofstairs/kpd/TreeMap.kt
FlightOfStairs
229,950,208
false
null
package org.flightofstairs.kpd import org.flightofstairs.kpd.utils.maybeUpdate import kotlin.math.sign private class TreeMapNode<K, V>( private val entry: Map.Entry<K, V>, private val comparator: Comparator<K>, private val left: TreeMapNode<K, V>?, private val right: TreeMapNode<K, V>? ) { constru...
0
Kotlin
0
0
c5e61094a6f398f3ddce6d84f5284588cc21d37d
2,609
kotlin-persistent-datastructures
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/BinaryTreePaths.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,536
kotlab
Apache License 2.0
src/main/kotlin/dev/claudio/adventofcode2021/Day4Part2.kt
ClaudioConsolmagno
434,559,159
false
{"Kotlin": 78336}
package dev.claudio.adventofcode2021 fun main() { Day4Part2().main() } private class Day4Part2 { fun main() { val inputList: List<String> = Support.readFileAsListString("day4-input.txt").filter { it != "" } val marks: List<Int> = inputList[0].split(",").map { Integer.valueOf(it) } var ...
0
Kotlin
0
0
5f1aff1887ad0a7e5a3af9aca7793f1c719e7f1c
1,976
adventofcode-2021
Apache License 2.0
src/main/java/com/booknara/practice/kotlin/higherorderfunction/Groceries.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.practice.kotlin.higherorderfunction data class Grocery( val name: String, val category: String, val unit: String, val unitPrice: Double, val quantity: Int) fun main(args: Array<String>) { val groceries = listOf<Grocery>( Grocery("Tomatoes", ...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
2,820
playground
MIT License
src/2021/Day12_2.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File import java.util.LinkedList import java.util.Queue class UndirectedGraph { private val graph = hashMapOf<String, MutableList<String>>() private fun addVertex(vertex: String) { graph[vertex] = LinkedList<String>() } fun addEdge(source: String, destination: String) { ...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
3,030
adventofcode
MIT License
src/iii_conventions/MyDate.kt
mariusz-zawadzki
99,572,209
true
{"Kotlin": 73383, "Java": 4953}
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int { val compareList = listOf(year.compareTo(other.year), month.compareTo(other.month), dayOfMonth.compareTo(other.day...
0
Kotlin
0
0
dd14ec8c516f36d29fc74db29875d8cb476f74db
1,564
kotlin-koans
MIT License
kotlin/src/com/daily/algothrim/graph/TopologySort.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.graph import java.util.* /** * 拓扑排序 */ class TopologySort(private val v: Int) { companion object { @JvmStatic fun main(args: Array<String>) { TopologySort(4).apply { addEdge(0, 1) addEdge(0, 2) addEdge(0, 3)...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,889
daily_algorithm
Apache License 2.0
lib/src/main/kotlin/aoc/day03/Day03.kt
Denaun
636,769,784
false
null
package aoc.day03 import aoc.AocGrammar import com.github.h0tk3y.betterParse.combinators.use import com.github.h0tk3y.betterParse.grammar.parseToEnd import com.github.h0tk3y.betterParse.lexer.regexToken import com.google.common.collect.Iterables.getOnlyElement object Day03Grammar : AocGrammar<List<String>>() { pr...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
1,476
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/davio/aoc/y2022/Day13.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2022 import com.github.davio.aoc.general.* import kotlinx.serialization.json.* import kotlin.system.measureTimeMillis fun main() { println(Day13.getResultPart1()) measureTimeMillis { println(Day13.getResultPart2()) }.call { println("Took $it ms") } } /** * See [Adve...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
3,050
advent-of-code
MIT License
src/day-9/part-1/solution-day-9-part-1.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File import kotlin.math.abs class Coordinate(val x: Int = 0, val y: Int = 0) { fun moveRight() = Coordinate(x + 1, y) fun moveLeft() = Coordinate(x - 1, y) fun moveUp() = Coordinate(x, y + 1) fun moveDown() = Coordinate(x, y - 1) fun isTouching(other: Coordinate) = abs(x - other.x) <...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
1,923
advent-of-code-22
MIT License
src/questions/MaxSubarray.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.assertAllWithArgs /** * Given an integer array nums, find the contiguous subarray (containing at least one number) * which has the largest sum and return its sum. * [Source](https://leetcode.com/problems/maximum-subarray/) – [Solution](https://...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,600
algorithms
MIT License
src/main/kotlin/kgp/fitness/Metric.kt
JedS6391
90,571,337
false
null
package kgp.fitness /** * A feature of some case in a data set. * * A feature is essentially a variable to a GP program. * * @param value The value of this feature. * @param name A name for this feature. */ data class Feature(val value: Double, val name: String) /** * A case in a data set. * * A case is rea...
0
Kotlin
0
1
045fd23e0fac9ea31c20489ae459bd168846d30b
4,800
KGP
MIT License
usvm-core/src/main/kotlin/org/usvm/PathNode.kt
UnitTestBot
586,907,774
false
{"Kotlin": 2547205, "Java": 471958}
package org.usvm import org.usvm.algorithms.findLcaLinear import org.usvm.merging.UMergeable sealed interface PathSegment<Statement> { val statement: Statement data class Single<Statement>( override val statement: Statement, ) : PathSegment<Statement> { override fun toString(): String = "...
39
Kotlin
0
7
94c5a49a0812737024dee5be9d642f22baf991a2
3,367
usvm
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2021/day3/DiagnosticReport.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day3 import java.util.BitSet private typealias BitCriteria = (Int, Int) -> Int private fun String.toBitSet(): BitSet { return BitSet.valueOf(longArrayOf(this.toLong(radix = 2))) } fun List<String>.toDiagnosticReport(): DiagnosticReport { return DiagnosticReport( ...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
3,105
advent-2021
ISC License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[155]最小栈.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 // // // push(x) —— 将元素 x 推入栈中。 // pop() —— 删除栈顶的元素。 // top() —— 获取栈顶元素。 // getMin() —— 检索栈中的最小元素。 // // // // // 示例: // // 输入: //["MinStack","push","push","push","getMin","pop","top","getMin"] //[[],[-2],[0],[-3],[],[],[],[]] // //输出: //[null,nu...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,792
MyLeetCode
Apache License 2.0
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day21Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import java.lang.IllegalStateException private fun solution1(input: String) = parse(input).let { ctx -...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,988
adventofcode-kotlin
MIT License
src/Day06.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun main() { fun part1(input: List<String>): Int { val subList = mutableListOf<Char>() var result = 0 input.first().toCharArray().forEachIndexed { index, char -> subList += char if (subList.size > 4) { subList.removeFirst() } ...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
1,270
advent-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DinnerPlates.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
3,252
kotlab
Apache License 2.0
src/main/aoc2023/Day9.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 class Day9(input: List<String>) { private val histories = input.map { it.split(" ").map { raw -> raw.toInt() } } private fun differences(history: List<Int>): List<List<Int>> { return buildList { add(history) var current = history do { ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,151
aoc
MIT License
src/commonMain/kotlin/guru/nidi/simple3d/model/Line.kt
nidi3
159,038,498
false
null
package guru.nidi.simple3d.model import kotlin.math.abs import kotlin.math.max import kotlin.math.min open class Line(val a: Vector, val b: Vector) { protected fun insideSegment(p: Vector): Boolean = min(abs(p.x - a.x), abs(p.x - b.x)) + min(abs(p.y - a.y), abs(p.y - b.y)) + ...
0
Kotlin
0
5
bd2a72ac34b32588da31e74aef299ca29e31bde7
1,830
simple-3d
Apache License 2.0
app/src/main/kotlin/com/github/ilikeyourhat/kudoku/solving/deduction/algorithm/NakedValuesAlgorithm.kt
ILikeYourHat
139,063,649
false
{"Kotlin": 166134}
package com.github.ilikeyourhat.kudoku.solving.deduction.algorithm import com.github.ilikeyourhat.kudoku.model.Region import com.github.ilikeyourhat.kudoku.model.hint.SudokuHintGrid import com.github.ilikeyourhat.kudoku.solving.deduction.combinations.CollectionCombinator class NakedValuesAlgorithm( regions: List<...
1
Kotlin
0
0
b234b2de2edb753844c88ea3cd573444675fc1cf
2,096
Kudoku
Apache License 2.0
librefit-service/src/main/kotlin/io/tohuwabohu/calc/Tdee.kt
tohuwabohu-io
606,202,766
false
{"Kotlin": 125186, "Svelte": 69183, "JavaScript": 48573, "HTML": 13431, "CSS": 850, "Shell": 252}
package io.tohuwabohu.calc import kotlin.math.pow import kotlin.math.round /** * Calculation of basic metabolic rate (BMR) and total daily energy expenditure (TDEE) based on the Harris-Benedict * formula. */ data class Tdee( val age: Number, val sex: CalculationSex, val weight: Number, val height: ...
6
Kotlin
0
0
031d34cd2b343884e0009d76007e10e4261df828
2,783
librefit
MIT License
src/main/kotlin/kt/kotlinalgs/app/leetcode/ArrayProdExceptSelf.ws.kts
sjaindl
384,471,324
false
null
package com.sjaindl.kotlinalgsandroid.leetcode // https://docs.google.com/document/d/1Z8ia8-90S7QFfq5S0LkE_TbFoG9fXQekmeTEnzZx9aY/edit // https://leetcode.com/problems/product-of-array-except-self/ fun productExceptSelf(nums: IntArray): IntArray { //[1,2,4,3] if (nums.isEmpty()) return IntArray(0) val left ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
961
KotlinAlgs
MIT License
src/main/kotlin/g1301_1400/s1330_reverse_subarray_to_maximize_array_value/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1330_reverse_subarray_to_maximize_array_value // #Hard #Array #Math #Greedy #2023_06_06_Time_347_ms_(100.00%)_Space_43.1_MB_(100.00%) class Solution { private fun getAbsoluteDifference(a: Int, b: Int): Int { return Math.abs(a - b) } fun maxValueAfterReverse(nums: IntArray): In...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,310
LeetCode-in-Kotlin
MIT License
src/main/kotlin/d24/D24_1.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d24 import input.Input import java.math.BigDecimal import java.math.RoundingMode val MIN = BigDecimal(200_000_000_000_000L) val MAX = BigDecimal(400_000_000_000_000L) data class Line( val a: BigDecimal, val b: BigDecimal ) fun parseToLine(hailstone: Hailstone): Line { val vx = hailstone.velocity...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
1,964
aoc2023-kotlin
MIT License
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day09.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day class Day09 : Day("572", "847044") { private val map = input .lines() .map { line -> line.toCharArray().map { it.digitToInt() } } private val mapWidth = map[0].size private val mapHeight = map.size override fun solvePartOne(): Any { var r...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
2,421
advent-of-code-2021
MIT License
src/main/kotlin/com/colinodell/advent2021/Day16.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 class Day16(input: String) { private val transmission = decodePacket(BitString(input)) fun solvePart1() = transmission.versionSum() fun solvePart2() = transmission.value() interface Packet { val version: Int fun versionSum(): Int fun value():...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
3,199
advent-2021
Apache License 2.0
src/main/kotlin/aoc23/Day19.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day19Domain.Accepted import common.Year23 import aoc23.Day19Domain.Aplenty import aoc23.Day19Domain.Part import aoc23.Day19Domain.Rating import aoc23.Day19Domain.RatingCategory import aoc23.Day19Domain.Rejected import aoc23.Day19Domain.Rule import aoc23.Day19Domain.Transitional import aoc23....
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
7,281
aoc
Apache License 2.0
src/Day01.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
import java.util.* fun main() { fun sorted(input: List<String>): SortedSet<Int> { var sum = 0 return TreeSet(Comparator.naturalOrder<Int>().reversed()).apply { input.map { if (it.isBlank()) { add(sum) sum = 0 } else...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
956
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1701_1800/s1713_minimum_operations_to_make_a_subsequence/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1713_minimum_operations_to_make_a_subsequence // #Hard #Array #Hash_Table #Greedy #Binary_Search // #2023_06_16_Time_862_ms_(100.00%)_Space_67.3_MB_(100.00%) import java.util.Arrays class Solution { fun minOperations(target: IntArray, arr: IntArray): Int { val map: MutableMap<Int, Int...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,099
LeetCode-in-Kotlin
MIT License
src/Day10.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun part1(input: List<String>): Int { var x = 1 var cycle = 1 var addValue = 0 var adding = false val cycleValues = mutableListOf<Int>() var i = 0 while (i < input.size) { if (adding) { x += addValue adding = false i++ } else if (input[i]...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
1,920
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dynamicProgramming/EditDistance.kt
TheAlgorithms
177,334,737
false
{"Kotlin": 41212}
package dynamicProgramming fun min(x: Int, y: Int, z: Int): Int { if (x <= y && x <= z) return x return if (y <= x && y <= z) y else z } /* * This is a dynamic programming implementation of edit distance. * @Params str1,str2 - strings to be compared * @Return minimum number of operations to convert one str...
62
Kotlin
369
1,221
e57a8888dec4454d39414082bbe6a672a9d27ad1
894
Kotlin
MIT License
aoc-2016/src/main/kotlin/nl/jstege/adventofcode/aoc2016/days/Day04.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2016.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.extractValues /** * * @author <NAME> */ class Day04 : Day(title = "Security Through Obscurity") { private companion object Configuration { private const ...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
2,145
AdventOfCode
MIT License
src/main/kotlin/days/Day8.kt
hughjdavey
317,575,435
false
null
package days import days.Day8.Operation.ACC import days.Day8.Operation.JMP import days.Day8.Operation.NOP class Day8 : Day(8) { // 1928 override fun partOne(): Any { return Program(inputList).run().accumulator } // 1319 override fun partTwo(): Any { return sequence { yieldAll(inp...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
2,323
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/java/challenges/educative_grokking_coding_interview/fast_slow_pointers/_6/PalindromeList.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.fast_slow_pointers._6 import challenges.educative_grokking_coding_interview.LinkedList import challenges.educative_grokking_coding_interview.LinkedListNode import challenges.educative_grokking_coding_interview.PrintList.printListWithForwardArrow /** Given the hea...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,932
CodingChallenges
Apache License 2.0
src/main/kotlin/day07/Day07.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day07 import java.io.File fun main() { val data = parse("src/main/kotlin/day07/Day07-Sample.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 07 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") pr...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
1,424
advent-of-code-2022
MIT License
src/Day12.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
fun main() { fun part1(input: List<String>): Int { val grid = mutableListOf<MutableList<Position>>() var startPosition = Position(0, 0, 0) var endPosition = Position(0, 0, 0) input.forEachIndexed { y, line -> grid.add(mutableListOf()) line.forEachIndexed { x...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
4,228
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/day7/day7.kt
lavong
317,978,236
false
null
/* --- Day 7: Handy Haversacks --- You land at the regional airport in time for your next flight. In fact, it looks like you'll even have time to grab some food: all flights are currently delayed due to issues in luggage processing. Due to recent aviation regulations, many rules (your puzzle input) are being enforced...
0
Kotlin
0
1
a4ccec64a614d73edb4b9c4d4a72c55f04a4b77f
5,324
adventofcode-2020
MIT License
src/main/Day01.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day01 import utils.readInput data class Reader(val elves: List<List<Int>> = listOf(), val elf: List<Int> = listOf()) { fun read(line: String): Reader = when { line.isBlank() -> Reader(complete()) else -> Reader(elves, elf + line.toInt()) } fun complete(): List<...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
825
aoc-2022
Apache License 2.0
AdventOfCode/Challenge2023Day02.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.test.assertEquals class Challenge2023Day02 { private fun solve( gameConfig: GameConfig, file: String, ): Int { val games = File(file).bufferedReader().readLines() val validGamesIdList = mutableListOf<Int>() val allo...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
2,629
KotlinCodeJourney
MIT License
src/Day01.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
fun part1MostCalories(input: String): Int { var currentFood = 0 var maxFood = 0 input.lines().forEach { line -> if (line.isBlank()) { if (currentFood > maxFood) { maxFood = currentFood } currentFood = 0 } else { currentFood += line.toInt() } } if (currentFood > max...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
858
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2016/day8/BoardGamer.kt
arnab
75,525,311
false
null
package aoc2016.day8 data class Cell(val x: Int, val y: Int, var on: Boolean = false) { fun draw() = if (on) "#" else "-" } data class Board(val size: Pair<Int, Int>) { val cells: List<List<Cell>> by lazy { IntRange(0, size.second - 1).map { x-> IntRange(0, size.first - 1).map { y-> ...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,848
adventofcode
MIT License
games-core/src/main/kotlin/net/zomis/games/Map2D.kt
talsewell
309,196,629
true
{"Kotlin": 395303, "Vue": 83692, "JavaScript": 27193, "Java": 17130, "CSS": 3871, "HTML": 1358, "Dockerfile": 228}
package net.zomis.games import net.zomis.Best import net.zomis.games.dsl.Point private fun flipX(start: Position): Position { return Position(start.sizeX - 1 - start.x, start.y, start.sizeX, start.sizeY) } private fun flipY(start: Position): Position { return Position(start.x, start.sizeY - 1 - start.y, start...
0
Kotlin
0
0
f1447cca699325a37cc7f02a67fca2aa4e2d12c8
7,365
Server2
MIT License
year2020/day03/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day03/part2/Year2020Day03Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Time to check the rest of the slopes - you need to minimize the probability of a sudden arboreal stop, after all. Determine the number of trees you would encounter if, for each of the following slopes, you start at the top-left corner and traverse the map all the way to the bottom: - Right 1, dow...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,467
AdventOfCode
MIT License
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day23.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day23(val input: Input) : Puzzle() { private val order by lazy { input.string().map { it - '0' - 1 } } override fun part1(): String { val index = createIndex(order...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
1,962
adventofcode-kotlin
MIT License
src/Day05.kt
peterphmikkelsen
573,069,935
false
{"Kotlin": 7834}
fun main() { val stacks = mutableListOf( ArrayDeque(listOf('T', 'D', 'W', 'Z', 'V', 'P')), ArrayDeque(listOf('L', 'S', 'W', 'V', 'F', 'J', 'D')), ArrayDeque(listOf('Z', 'M', 'L', 'S', 'V', 'T', 'B', 'H')), ArrayDeque(listOf('R', 'S', 'J')), ArrayDeque(listOf('C', 'Z', 'B', '...
0
Kotlin
0
0
374c421ff8d867a0bdb7e8da2980217c3455ecfd
1,862
aoc-2022
Apache License 2.0
solutions/src/NumberOfEnclaves.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/number-of-enclaves/ */ class NumberOfEnclaves { fun numEnclaves(grid: Array<IntArray>): Int { var numEnclaves = 0 val visited = mutableSetOf<Pair<Int,Int>>() for (i in grid.indices) { for (j in grid[0].indices) { val enclav...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,389
leetcode-solutions
MIT License
src/main/kotlin/com/ginsberg/advent2016/Day08.kt
tginsberg
74,924,040
false
null
/* * Copyright (c) 2016 by <NAME> */ package com.ginsberg.advent2016 /** * Advent of Code - Day 8: December 8, 2016 * * From http://adventofcode.com/2016/day/8 * */ class Day08(input: List<String>, val height: Int = 6, val width: Int = 50) { private val digits = Regex("""^\D*(\d+)\D*(\d+)\D*$""") pri...
0
Kotlin
0
3
a486b60e1c0f76242b95dd37b51dfa1d50e6b321
1,922
advent-2016-kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindLucky.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,573
kotlab
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day21/Common.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day21 internal data class Grid(val grid: List<List<Char>>) { internal fun traverse(maxSteps: Long, useInf: Boolean = false): TraverseResult { var coords = mutableSetOf(findStart()) var steps = 0L while (steps < maxSteps) { val nextCoords = mutableSet...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
4,054
advent-of-code-2023
MIT License
core/src/main/kotlin/org/jetbrains/research/kex/state/transformer/Optimizer.kt
Saloed
227,350,941
true
{"Kotlin": 1844577, "Python": 10439, "Java": 5186, "Shell": 168}
package org.jetbrains.research.kex.state.transformer import org.jetbrains.research.kex.state.* import org.jetbrains.research.kex.state.predicate.ConstantPredicate import org.jetbrains.research.kex.state.predicate.EqualityPredicate import org.jetbrains.research.kex.state.predicate.Predicate import org.jetbrains.researc...
1
Kotlin
0
0
6ead750e33c91afafaa7d315a979396b391a5093
3,677
kex
Apache License 2.0
src/Day02.kt
thelmstedt
572,818,960
false
{"Kotlin": 30245}
import java.io.File fun main() { fun part1(file: File) = file .readText() .lineSequence() .map { when (it) { "A X" -> 3 + 1 "A Y" -> 6 + 2 "A Z" -> 0 + 3 "B X" -> 0 + 1 "B Y" -> 3 + 2 ...
0
Kotlin
0
0
e98cd2054c1fe5891494d8a042cf5504014078d3
1,168
advent2022
Apache License 2.0
src/day4/first/Solution.kt
verwoerd
224,986,977
false
null
package day4.first import tools.timeSolution fun main() = timeSolution { println(isValidPassword(111111)) println(isValidPassword(<PASSWORD>)) println(isValidPassword(123789)) val (min, max) = readLine()!!.split("-").map { it.toInt() } val valid = mutableSetOf<Int>() for (i in min..max) { if (isValidP...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,075
AoC2019
MIT License
src/main/kotlin/P014_LongestCollatzSequence.kt
perihanmirkelam
291,833,878
false
null
/** * P14-Longest Collatz sequence * 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 → 1 * It can be...
0
Kotlin
1
3
a24ac440871220c87419bfd5938f80dc22a422b2
1,159
ProjectEuler
MIT License
src/main/kotlin/alg03sorting/S3ShellSort.kt
deemson
349,702,470
false
null
package alg03sorting import alg03indexable.Indexable import alg03indexable.swap /** * Shell sort is similar to previous algorithm (S2InsertionSort). * Insertion sort (S2InsertionSort) moves a single item at a time, thus being slow * when sorting an array that requires a lot of swaps. * Shell sort tries to compens...
0
Kotlin
0
0
a4bba4dfa962302114065032facefdf98585cfd7
1,958
algorithms
MIT License
src/main/kotlin/aoc2020/day8/InfiniteLoop.kt
arnab
75,525,311
false
null
package aoc2020.day8 import java.lang.IllegalArgumentException object InfiniteLoop { data class Program( val instructions: List<Pair<String, Int>>, val currentState: State ) { companion object { fun parse(rawInstructions: String): Program = rawInstructions....
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
4,442
adventofcode
MIT License
src/day01/Day01.kt
GrinDeN
574,680,300
false
{"Kotlin": 9920}
package day01 import readInput import splitWhen fun main() { fun part1(input: List<String>): Int { val values = input.splitWhen { it == "" } println(values) val calories = values.stream().map { it -> it.sumOf { el -> el.toInt() } }.toList() println(calories) return calories...
0
Kotlin
0
0
f25886a7a3112c330f80ec2a3c25a2ff996d8cf8
876
aoc-2022
Apache License 2.0
src/main/kotlin/day25_sea_cucumber/SeaCucumber.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day25_sea_cucumber /** * It's a torus! */ fun main() { util.solve(386, ::partOne) // util.solve(::partTwo) } private const val OPEN = '.' private const val EAST = '>' private const val SOUTH = 'v' fun partOne(input: String): Int { val width = input.indexOf('\n') var g = input .filter...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,376
aoc-2021
MIT License
src/main/kotlin/fp/kotlin/example/chapter08/solution/8_17_sequenceTree.kt
funfunStory
101,662,895
false
null
package fp.kotlin.example.chapter08.solution import fp.kotlin.example.chapter04.solution.curried import fp.kotlin.example.chapter08.Node import fp.kotlin.example.chapter08.Tree import fp.kotlin.example.chapter08.apply import fp.kotlin.example.chapter08.pure /** * * 연습문제 8-17 * * Tree 에도 동작하는 ``sequenceA`` 함수를 추가하...
1
Kotlin
23
39
bb10ea01d9f0e1b02b412305940c1bd270093cb6
1,217
fp-kotlin-example
MIT License
AdventOfCode/Challenge2023Day03.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.test.assertEquals class Challenge2023Day03 { private fun solve1(schema: List<String>): Int { val numberList = mutableListOf<Int>() var formerLine: String? = null var currentLine: String var nextLine: String? val nummerR...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
2,885
KotlinCodeJourney
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfWays.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
1,420
kotlab
Apache License 2.0
src/shreckye/coursera/algorithms/Course 3 Programming Assignment #1 Question 1 & 2.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.io.File val filename = args[0] data class Job(val weight: Int, val length: Int) val (numJobs, jobs) = File(filename).inputStream().bufferedReader().use { val numJobs = it.readLine().toInt() val jobs = it.lineSequence().map { it.splitToInts().run { Job(get(0), ...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
1,397
coursera-stanford-algorithms-solutions-kotlin
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions13.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round0 /** * 机器人在一个矩阵中运动,当机器人当某一个格子的横纵坐标各位的值相加 * 小于等于k时机器人可以进入该格子,求问机器人可以进入多少个格子 */ fun test13() { println(movingCount(5, 10, 10)) println(movingCount(15, 20, 20)) println(movingCount(10, 1, 100)) println(movingCount(10, 1, 10)) println(movingCount(15, 100, 1)) println(movingC...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,377
Algorithm
Apache License 2.0
src/main/kotlin/d25/D25_1.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d25 import input.Input data class Wire( val v1: String, val v2: String ) fun parseWires(lines: List<String>): List<Wire> { return lines.flatMap { line -> val parts = line.split(": ") val from = parts[0] val toMany = parts[1].split(" ") toMany.map { Wire(from, it) ...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
4,262
aoc2023-kotlin
MIT License
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/kotlin/nlarrea.kt
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
/* * Escribe un programa que muestre cómo transcurre un juego de tenis y quién lo ha ganado. * El programa recibirá una secuencia formada por "P1" (Player 1) o "P2" (Player 2), según quien * gane cada punto del juego. * * - Las puntuaciones de un juego son "Love" (cero), 15, 30, 40, "Deuce" (empate), ventaja. * ...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
2,672
retos-programacion-2023
Apache License 2.0
combinatorics/src/main/kotlin/com/nickperov/stud/combinatorics/experiment/PermutationsCalculatorExperiment.kt
nickperov
327,780,009
false
null
package com.nickperov.stud.combinatorics.experiment import com.nickperov.stud.combinatorics.CombinatorialUtils import java.util.* /** * Test sample to try different approaches to calculate permutations */ object PermutationsCalculatorExperiment { /** * Provides all permutations of the elements in the given...
0
Kotlin
0
0
6696f5d8bd73ce3a8dfd4200f902e2efe726cc5a
7,809
Algorithms
MIT License
app/src/test/java/com/terencepeh/leetcodepractice/BestTimeToBuyAndSellStock.kt
tieren1
560,012,707
false
{"Kotlin": 26346}
package com.terencepeh.leetcodepractice /** * Created by <NAME> on 7/9/22. */ // o(n2) fun maxProfitBruteForce(prices: IntArray): Int { var maxProfit = 0 for (i in 0 until prices.size - 1) { for (j in i until prices.size) { val profit = prices[j] - prices[i] if (profit > maxP...
0
Kotlin
0
0
427fa2855c01fbc1e85a840d0be381cbb4eec858
1,654
LeetCodePractice
MIT License
18.kt
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
fun main() { val up = Pair(0, -1); val right = Pair(1, 0); val down = Pair(0, 1); val left = Pair(-1, 0) fun move(pos: Pair<Int, Int>, dir: Pair<Int, Int>, n: Int): Pair<Int, Int> = Pair(pos.first + dir.first * n, pos.second + dir.second * n) fun result(len: Long, corners: List<Pair<Int, Int>>): Long { ...
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
1,508
aoc2023
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem848/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem848 /** * LeetCode page: [848. Shifting Letters](https://leetcode.com/problems/shifting-letters/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the length of s and the size of shifts; */ fun shiftingLetters(s: String, shifts: IntArra...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,218
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day10.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day class Day10(input: String? = null) : Day(10, "Pipe Maze", input) { data class Cell( val x: Int, val y: Int, val char: Char, val weight: Int ) data class Point(val x: Int, val y: Int) override fun partOne() = find...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
4,256
advent-of-code-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountConsistentStrings.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
1,479
kotlab
Apache License 2.0
src/day11/Day11.kt
tschens95
573,743,557
false
{"Kotlin": 32775}
package day11 import readText fun main() { val inspectingMap = mutableListOf<Int>() fun mapToMonkey(it: String): Monkey { val lines = it.split("\n") val operator = lines[2].split("=")[1].trim().substring(4, 5) val operand = lines[2].split(operator)[1].trim() val operation = ...
0
Kotlin
0
2
9d78a9bcd69abc9f025a6a0bde923f53c2d8b301
3,618
AdventOfCode2022
Apache License 2.0
codeforces/round614/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round614 import kotlin.math.abs fun main() { val (x0, y0, ax, ay, bx, by) = readLongs() val (xs, ys, t) = readLongs() val points = mutableListOf(x0 to y0) while (true) { val (x, y) = ax * points.last().first + bx to ay * points.last().second + by if (xs + ys + t < x + y) break points.add(...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
876
competitions
The Unlicense
src/main/kotlin/g1901_2000/s1960_maximum_product_of_the_length_of_two_palindromic_substrings/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1960_maximum_product_of_the_length_of_two_palindromic_substrings // #Hard #String #Hash_Function #Rolling_Hash // #2023_06_21_Time_247_ms_(100.00%)_Space_37.5_MB_(100.00%) class Solution { fun maxProduct(s: String): Long { val n = s.length if (n == 2) { return 1 ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,723
LeetCode-in-Kotlin
MIT License
src/day_9/kotlin/Day9.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
import kotlin.math.absoluteValue import kotlin.math.sign // AOC Day 9 // Simulating the tail movement is done by storing its relative position to the head. // This enables not having to simulate the head itself and is easier to work with. // So if we want to move the head we actually have to move the tails relative p...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
3,254
AdventOfCode2022
MIT License
src/Day08.kt
b0n541
571,797,079
false
{"Kotlin": 17810}
fun main() { fun allTreesToTheLeftAreShorter(trees: Array<IntArray>, row: Int, column: Int): Boolean { val treeHeight = trees[row][column] for (i in column - 1 downTo 0) { if (trees[row][i] >= treeHeight) { return false } } return true }...
0
Kotlin
0
0
d451f1aee157fd4d47958dab8a0928a45beb10cf
5,051
advent-of-code-2022
Apache License 2.0
kotlin/1514-path-with-maximum-probability.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 { fun maxProbability(n: Int, edges: Array<IntArray>, succProb: DoubleArray, start: Int, end: Int): Double { val adj = HashMap<Int, ArrayList<Pair<Int, Double>>>().apply { for ((i, edge) in edges.withIndex()) { val (u, v) = edge this[u] = getOrDefaul...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,149
leetcode
MIT License
src/main/kotlin/problems/SubtreeOfAnotherTree.kt
amartya-maveriq
510,824,460
false
{"Kotlin": 42296}
package problems import models.TreeNode /** * Leetcode : easy * * Given the roots of two binary trees root and subRoot, return true if * there is a subtree of root with the same structure and node values of * subRoot and false otherwise. * A subtree of a binary tree is a tree that consists of a node in tree * ...
0
Kotlin
0
0
2f12e7d7510516de9fbab866a59f7d00e603188b
1,889
data-structures
MIT License
src/main/kotlin/me/peckb/aoc/_2016/calendar/day08/Day08.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2016.calendar.day08 import me.peckb.aoc._2016.calendar.day08.Day08.Operation.Rect import me.peckb.aoc._2016.calendar.day08.Day08.Operation.RotateColumn import me.peckb.aoc._2016.calendar.day08.Day08.Operation.RotateRow import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.Inpu...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,897
advent-of-code
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day11.kt
EmRe-One
434,793,519
false
{"Kotlin": 44202}
package tr.emreone.adventofcode.days object Day11 { class Password(var password: String) { fun incrementPassword() { val length = password.length var index = length - 1 while (index >= 0) { val c = password[index] if (c == 'z') { ...
0
Kotlin
0
0
57f6dea222f4f3e97b697b3b0c7af58f01fc4f53
2,404
advent-of-code-2015
Apache License 2.0
src/Day04.kt
marvingrewe
573,069,044
false
{"Kotlin": 6473}
import kotlin.system.measureTimeMillis fun main() { val day = "Day04" fun toRange(it: String) = it.split("-").map(String::toInt).let { (lower, upper) -> lower..upper } fun List<String>.checkRangesFor(rangePredicate: (IntRangePair) -> Boolean) = count { it.split(",").map(::toRange).let { (left, ri...
0
Kotlin
0
0
adec59f236b5f92cfcaf9e595fb913bf0010ac41
1,137
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day24/Day24ImmuneSystemSimulator.kt
Zordid
160,908,640
false
null
package day24 import shared.extractAllInts import shared.measureRuntime import shared.readPuzzle enum class OpponentType(private val s: String) { ImmuneSystem("Immune System"), Infection("Infection"); override fun toString() = s } data class ImmuneGroup( val type: OpponentType, val id: Int, val ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
6,729
adventofcode-kotlin-2018
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day13.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 13 - Transparent Origami * Problem Description: http://adventofcode.com/2021/day/13 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day13/ */ package com.ginsberg.advent2021 class Day13(input: List<String>) { pri...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,877
advent-2021-kotlin
Apache License 2.0