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
kotlin/Rational.kt
indy256
1,493,359
false
{"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571}
import java.math.BigInteger class Rational(n: BigInteger, d: BigInteger = BigInteger.ONE) : Comparable<Rational> { val num: BigInteger val den: BigInteger init { val gcd = n.gcd(d) val g = if (d.signum() > 0) gcd else if (d.signum() < 0) gcd.negate() else BigInteger.ONE num = n.div...
97
Java
561
1,806
405552617ba1cd4a74010da38470d44f1c2e4ae3
1,991
codelibrary
The Unlicense
src/main/kotlin/net/voldrich/aoc2021/Day2.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay // https://adventofcode.com/2021/day/2 fun main() { Day2().run() } class Day2 : BaseDay() { override fun task1() : Int { var depth = 0 var forward = 0 parseInstructions().forEach { when (it.instruction) { ...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
1,872
advent-of-code
Apache License 2.0
rtron-std/src/main/kotlin/io/rtron/std/Collections.kt
tum-gis
258,142,903
false
{"Kotlin": 1425220, "C": 12590, "Dockerfile": 511, "CMake": 399, "Shell": 99}
/* * Copyright 2019-2023 Chair of Geoinformatics, Technical University of Munich * * 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 * ...
4
Kotlin
12
38
27969aee5a0c8115cb5eaf085ca7d4c964e1f033
6,995
rtron
Apache License 2.0
app/src/main/kotlin/kotlinadventofcode/2015/2015-13.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2015` import com.github.h0tk3y.betterParse.combinators.* import com.github.h0tk3y.betterParse.grammar.* import com.github.h0tk3y.betterParse.lexer.* import com.github.h0tk3y.betterParse.parser.Parser import kotlinadventofcode.Day class `20...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
7,709
kotlinadventofcode
MIT License
src/Day10.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
fun main() { fun signalStrength(cycle: Int, X: Int): Int { if (cycle == 20 || cycle == 60 || cycle == 100 || cycle == 140 || cycle == 180 || cycle == 220) { //println(Pair(cycle, X)) return cycle * X } return 0 } fun part1(input: List<String>): Int { v...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
2,156
advent-of-code-2022
Apache License 2.0
kotlin/684.Redundant Connection(冗余连接).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p> In this problem, a tree is an <b>undirected</b> graph that is connected and has no cycles. </p><p> The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one additional edge added. The added edge has two different vertices chosen from 1 to N, and was not an edg...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
5,584
leetcode
MIT License
src/LongestUniqueSubSequence.kt
philipphofmann
236,017,177
false
{"Kotlin": 17647}
/** * Returns the longest subsequence with unique character. */ fun longestUniqueSubSequence(value: String): String { var longestUniqueSubSequence = "" value.forEachIndexed { index, _ -> val uniqueSubsequence = uniqueSubSequence(value.subSequence(index, value.length)) if (longestUniqueSubSeque...
0
Kotlin
0
1
db0889c8b459af683149530f9aad93ce2926a658
789
coding-problems
Apache License 2.0
src/Day16.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
//class Day16(val lines: List<String>) { // fun partOne(): Int { // val (tunnelMap, paths) = preProcess(getTunnelList()) // return findBestPressure("AA", 0, 30, tunnelMap, paths, emptySet()) // } // // fun partTwo() : Int { // val (tunnelMap, paths) = preProcess(getTunnelList()) // ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
6,902
advent22
Apache License 2.0
kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
therealansh
373,284,570
true
{"Kotlin": 1071813, "ANTLR": 887}
/* * Copyright 2018-2021 KMath contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package space.kscience.kmath.functions import space.kscience.kmath.operations.Ring /** * Represents piecewise-defined function. * * @param T the pie...
0
null
0
0
4065466be339017780b0ac4b98a9eda2cc2378e4
2,837
kmath
Apache License 2.0
src/main/kotlin/days/Day4.kt
teunw
573,164,590
false
{"Kotlin": 20073}
package days class Day4 : Day(4) { private fun containsTheOther(rangeA: IntRange, rangeB: IntRange): Boolean = (rangeA.contains(rangeB.first) && rangeA.contains(rangeB.last)) || (rangeB.contains(rangeA.first) && rangeB.contains(rangeA.last)) private fun parseLines(): List<Pair<IntRang...
0
Kotlin
0
0
149219285efdb1a4d2edc306cc449cce19250e85
790
advent-of-code-22
Creative Commons Zero v1.0 Universal
year2020/day16/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day16/part2/Year2020Day16Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Now that you've identified which tickets contain invalid values, discard those tickets entirely. Use the remaining valid tickets to determine which field is which. Using the valid ranges for each field, determine what order the fields appear on the tickets. The order is consistent between all tick...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
5,052
AdventOfCode
MIT License
src/main/kotlin/com/dambra/adventofcode2018/day18/Forest.kt
pauldambra
159,939,178
false
null
package com.dambra.adventofcode2018.day18 class Forest(map: String) { private var acres: MutableMap<Coord, Acre> private val maxX: Int private val maxY: Int fun resourceValue() : Int { val trees = acres .values .count { it.type == Acre.trees } val lumberyard = a...
0
Kotlin
0
1
7d11bb8a07fb156dc92322e06e76e4ecf8402d1d
2,777
adventofcode2018
The Unlicense
leetcode2/src/leetcode/odd-even-linked-list.kt
hewking
68,515,222
false
null
package leetcode import leetcode.structure.ListNode /** * 328. 奇偶链表 * https://leetcode-cn.com/problems/odd-even-linked-list/ * @program: leetcode * @description: ${description} * @author: hewking * @create: 2019-10-18 21:09 * 给定一个单链表,把所有的奇数节点和偶数节点分别排在一起。请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性。 请尝试使用原地算法完成。你的算...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,719
leetcode
MIT License
app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt
johnwtt
537,907,731
true
{"Kotlin": 3018671}
package eu.kanade.tachiyomi.util import eu.kanade.tachiyomi.source.model.SChapter import org.nekomanga.domain.chapter.ChapterItem import kotlin.math.floor /** * Calculate the missing chapters for a given list of chapters. Return null if none are missing */ fun List<SChapter>.getMissingChapterCount(mangaStatus: Int)...
1
Kotlin
0
0
4925e28fdf4490004372eae120b738470fbeea58
2,775
Neko-Reader
Apache License 2.0
src/kickstart2020/c/Candies.kt
vubogovich
256,984,714
false
null
package kickstart2020.c // TODO still slow fun main() { val inputFileName = "src/kickstart2020/c/Candies.in" java.io.File(inputFileName).takeIf { it.exists() }?.also { System.setIn(it.inputStream()) } for (case in 1..readLine()!!.toInt()) { val (_, q) = readLine()!!.split(' ').map { it.toInt() } ...
0
Kotlin
0
0
fc694f84bd313cc9e8fcaa629bafa1d16ca570fb
2,574
kickstart
MIT License
neat-core/src/main/kotlin/neat/novelty/Levenshtein.kt
MikeDepies
325,124,905
false
{"CSS": 7942948, "Kotlin": 700526, "Python": 545415, "TypeScript": 76204, "Svelte": 50830, "JavaScript": 6857, "HTML": 2446, "Dockerfile": 772}
package neat.novelty import kotlin.math.min fun levenshtein(lhs: CharSequence, rhs: CharSequence): Int { if (lhs == rhs) { return 0 } if (lhs.isEmpty()) { return rhs.length } if (rhs.isEmpty()) { return lhs.length } val lhsLength = lhs.length + 1 val rhsLength ...
0
CSS
0
3
215f13fd4140e32b882e3a8c68900b174d388d9f
1,768
NeatKotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordLadder2BFS.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
4,034
kotlab
Apache License 2.0
src/main/kotlin/str/Anagram.kt
yx-z
106,589,674
false
null
package str import java.util.* import kotlin.collections.HashMap // Determine If 2 Strings are Anagram (re-ordering of each other) fun main(args: Array<String>) { // test strings val s1 = "abcd" val s2 = "dcab" // true println(isAnagram(s1, s2)) // test array val sArr = arrayOf("abc", "123", "cba", "132", "21...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,174
AlgoKt
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindDuplicateNumber.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
4,105
kotlab
Apache License 2.0
src/main/kotlin/me/giacomozama/adventofcode2022/days/Day11.kt
giacomozama
572,965,253
false
{"Kotlin": 75671}
package me.giacomozama.adventofcode2022.days import java.io.File import java.util.* class Day11 : Day() { private class Monkey( val startingItems: List<Long>, val operation: (Long) -> Long, val test: IntArray ) private lateinit var input: List<Monkey> private fun parseOperat...
0
Kotlin
0
0
c30f4a37dc9911f3e42bbf5088fe246aabbee239
3,272
aoc2022
MIT License
src/main/kotlin/twentytwenty/Day9.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
fun main() { val input = {}.javaClass.getResource("twentytwenty/input9.txt").readText().lines().map { it.toLong() } val key = input.findElementWhichHasNoSumInPreamble(25) println(key) println(input.findRangeThatSumsTo(key).sumOfMinAndMax()) } fun List<Long>.findElementWhichHasNoSumInPreamble(preamble: ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
895
aoc202xkotlin
The Unlicense
src/main/kotlin/homeworks/homework8/task1/model/MinimaxAlgorithm.kt
GirZ0n
210,118,779
false
null
package homeworks.homework7.task2.model object MinimaxAlgorithm { private const val MAX_VALUE = 1000 private const val MIN_VALUE = -MAX_VALUE private const val BASIC_VALUE = 10 fun getBestMove(board: Array<CharArray>, playerSign: Char, opponentSign: Char, emptySign: Char): Pair<Int, Int> { var...
0
Kotlin
0
0
05f2bda1d4480681e616fba94c75da5937436961
5,863
SPBU-Homework-2
The Unlicense
src/main/kotlin/io/tree/MinPathSum.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.tree import io.utils.runTests // https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/530/week-3/3303/ class MinPathSum { fun execute(grid: Array<IntArray>): Int { val height = grid.size val width: Int = grid.first().size for (row in 0 until height) { for (col in 0 un...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,505
coding
MIT License
advent-of-code-2019/src/test/java/Day7AmplificationCircuit.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList import org.assertj.core.api.Assertions.assertThat import org.junit.Test class Day7AmplificationCircuit { private fun evaluateThrustersPower(inputs: List<...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
11,806
advent-of-code
MIT License
2018/kotlin/day6p2/src/main/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Coord(val x: Int, val y: Int) fun main(args: Array<String>) { val start = Date() val input = "292, 73\n" + "204, 176\n" + "106, 197\n" + "155, 265\n" + "195, 59\n"...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
3,342
adventofcode
MIT License
src/main/kotlin/y2023/Day1.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day class Day1 : Day(1, 2023, false) { override fun partOne(): Any { return inputList.findSumOfFirstAndLastDigit().sum() } override fun partTwo(): Any { return inputList.findSumOfFirstAndLastNumber().sum() } } private fun List<String>.findSumOfFirstAndLastD...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
1,551
adventofcode
MIT License
Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/kotlin/nicodevelop.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": ...
fun main() { println("Introduce un nuevo numero para empezar el juego") execute(readLine() ?: "") } var sum : Int = 0 fun execute(letters: String) { if (!containsOnlyLetters(letters) || letters.isEmpty()) { println("Introduce un valor correcto") execute(readLine() ?: "") return ...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
1,491
retos-programacion-2023
Apache License 2.0
src/Day6/December6.kt
Nandi
47,216,709
false
null
package Day6 import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Stream /** * 6.December challenge from www.adventofcode.com * * Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to * deploy one million lights in a 1000x1000...
0
Kotlin
0
0
34a4b4c0926b5ba7e9b32ca6eeedd530f6e95bdc
4,229
adventofcode
MIT License
src/main/kotlin/g0001_0100/s0072_edit_distance/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0072_edit_distance // #Hard #Top_100_Liked_Questions #String #Dynamic_Programming // #Algorithm_II_Day_18_Dynamic_Programming #Dynamic_Programming_I_Day_19 // #Udemy_Dynamic_Programming #Big_O_Time_O(n^2)_Space_O(n2) // #2023_07_10_Time_182_ms_(92.16%)_Space_36.2_MB_(98.04%) class Solution { f...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
936
LeetCode-in-Kotlin
MIT License
2015/kt/src/test/kotlin/org/adventofcode/Day18.kt
windmaomao
225,344,109
false
{"JavaScript": 538717, "Ruby": 89779, "Kotlin": 58408, "Rust": 21350, "Go": 19106, "TypeScript": 9930, "Haskell": 8908, "Dhall": 3201, "PureScript": 1488, "HTML": 1307, "CSS": 1092}
package org.adventofcode class Day18 { var n = 0 var m = 0 fun setSize(s: Int) { n = s m = n + 2 } private fun neighbors() = listOf( -m-1, -m, -m+1, -1 , +1, m-1, m , m+1 ) private fun pos(i: Int, j: Int) = i * m + j fun extractState(str: List<String>): BooleanArray { va...
5
JavaScript
0
0
1d64d7fffa6fcfc6825e6aa9322eda76e790700f
1,400
adventofcode
MIT License
src/chapter3/section2/ex8.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section2 /** * 编写一个静态方法optCompares(),接受一个整型参数N并计算一颗最优(完美平衡的)二叉查找树中的 * 一次随机查找命中平均所需的比较次数, * 如果树中的链接数量为2的幂,那么所有的空链接都应该在同一层,否则则分布在最底部的两层中。 * * 解:第i层的一个元素需要比较i次才可以查找命中(根结点为第一层), * i不断自增,将每层所有元素需要比较的次数相加,直到完全二叉查找树的总数大于等于N */ fun optCompares(N: Int): Int { if (N <= 0) return 0 //第i层的结点数量 ...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,632
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/me/peckb/aoc/_2023/calendar/day03/Day03.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2023.calendar.day03 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory class Day03 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun partOne(filename: String) = generatorFactory.forFile(filename).read { input -> ...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,868
advent-of-code
MIT License
src/Day18.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min private const val EXPECTED_1 = 62L private const val EXPECTED_2 = 952408144115L private class Day18(isTest: Boolean) : Solver(isTest) { data class Point(val y: Int, val x: Int) fun part1Bfs(): Any { val walls = mutableSetO...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,992
advent-of-code-2022
Apache License 2.0
year2023/src/cz/veleto/aoc/year2023/Day01.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay class Day01(config: Config) : AocDay(config) { private val spelledOutDigits: Map<String, Int> = listOf( "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
1,531
advent-of-pavel
Apache License 2.0
src/Day05.kt
timmiller17
577,546,596
false
{"Kotlin": 44667}
fun main() { fun part1(input: List<String>): String { val indexOfColumnRow = input.indexOfFirst { it.contains("1") } val numberOfStacks = input[indexOfColumnRow].trim().takeLast(1).toInt() val crateIds = mutableListOf<List<String>>() for (row in input.take(indexOfColumnRow)) { ...
0
Kotlin
0
0
b6d6b647c7bb0e6d9e5697c28d20e15bfa14406c
4,217
advent-of-code-2022
Apache License 2.0
src/main/kotlin/recur/MedianTwoArr.kt
yx-z
106,589,674
false
null
package recur import util.OneArray import util.append import util.get import util.oneArrayOf // given two sorted arrays A[1..n] and B[1..n], // find the median of sorted(A append B)[1..2n] // that is the n-th smallest element in their concatenated sorted array infix fun OneArray<Int>.medianUnion(B: OneArray<Int>): In...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,194
AlgoKt
MIT License
client/logistics.kt
GitProger
400,501,895
false
null
import java.io.InputStreamReader import java.net.URL import java.util.* import kotlin.math.absoluteValue import java.io.File data class Kettle(val id: Int, val room: String, var boilTime: Long, var ml: Int) var room = "1" var ml = 200 private const val MILLIES_IN_DAY = 86_400_000 private val start = "http://192.168....
0
Kotlin
0
0
cb1cd6d58125fb0ed983e5af0aef998c75b6ea63
3,392
Alferov-Lyceum-PTHS
MIT License
solutions/aockt/y2023/Y2023D24.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.math.distinctPairs import aockt.util.parse import aockt.util.spacial3d.Point3D import io.github.jadarma.aockt.core.Solution /** * This complicated day was only possible due to amazing insights and other solutions shared by the community: * - Collision formulae for part 1: [Hype...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
7,976
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/g2401_2500/s2452_words_within_two_edits_of_dictionary/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2452_words_within_two_edits_of_dictionary // #Medium #Array #String #2023_07_04_Time_256_ms_(100.00%)_Space_40.8_MB_(100.00%) class Solution { private var root: Node? = null internal class Node { var childs = HashMap<Char, Node?>() } private fun insert(s: String) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,670
LeetCode-in-Kotlin
MIT License
src/main/kotlin/org/vitrivr/cottontail/database/index/va/signature/MarksGenerator.kt
corner4world
368,444,276
true
{"Kotlin": 1810422, "Dockerfile": 478}
package org.vitrivr.cottontail.database.index.va.signature import kotlin.math.max import kotlin.math.min import kotlin.math.pow object MarksGenerator { /** */ const val EPSILON = 1E-9 /** * Get marks. * Todo: Tests indicate that these marks are less tight than the equidistant ones */ f...
0
Kotlin
0
0
dd722bd144642ae7ee91e482cb313d2813471afe
7,475
cottontaildb
MIT License
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Boyer_Moore_Algorithm/Boyer_Moore.kt
rajatenzyme
325,100,742
false
{"C++": 709855, "Java": 559443, "Python": 397216, "C": 381274, "Jupyter Notebook": 127469, "Go": 123745, "Dart": 118962, "JavaScript": 109884, "C#": 109817, "Ruby": 86344, "PHP": 63402, "Kotlin": 52237, "TypeScript": 21623, "Rust": 20123, "CoffeeScript": 13585, "Julia": 2385, "Shell": 506, "Erlang": 385, "Scala": 310, ...
/* Boyer Moore String Matching Algorithm in Kotlin Author: <NAME> (@darkmatter18) */ import java.util.* internal object Main { private var NO_OF_CHARACTERS = 256 private fun maxOfAAndB(a: Int, b: Int): Int { return a.coerceAtLeast(b) } private fun badCharacterHeuristic(str: CharArray, size: I...
0
C++
0
0
65a0570153b7e3393d78352e78fb2111223049f3
2,428
Coding-Journey
MIT License
src/main/kotlin/com/adventofcode/Day.kt
reactivedevelopment
572,826,252
false
{"Kotlin": 2883, "Dockerfile": 379}
package com.adventofcode import com.adventofcode.Figure.* import com.adventofcode.Game.game import com.adventofcode.Game.rightScores import com.adventofcode.Round.* enum class Round(val scores: Long) { Win(6), Lose(0), Draw(3), } enum class Figure(val scores: Long) { Rock(1) { override fun roundWith(oth...
0
Kotlin
0
0
dac46829eb85db869fd73bedf215c7aafd599983
2,396
aoc-2022-2
MIT License
reporter/src/main/kotlin/model/Statistics.kt
mercedes-benz
246,283,016
true
{"Kotlin": 1936701, "JavaScript": 310482, "HTML": 27680, "CSS": 25864, "Python": 21638, "Shell": 5460, "Dockerfile": 4679, "Ruby": 3545, "ANTLR": 1938, "Go": 328, "Rust": 280}
/* * Copyright (C) 2017-2020 HERE Europe B.V. * * 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...
0
null
1
0
5babc890a34127d4ab20177d823eb31fd76f79a1
3,398
oss-review-toolkit
Apache License 2.0
src/day19/Code.kt
fcolasuonno
225,219,560
false
null
package day19 import IntCode import IntCodeComputer import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) ...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
1,258
AOC2019
MIT License
libraries/stdlib/samples/test/samples/collections/grouping.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package samples.collections import samples.* class Grouping { @Sample fun groupingByEachCount() { ...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
5,420
kotlin
Apache License 2.0
common/src/main/kotlin/combo/bandit/dt/TreeNodes.kt
rasros
148,620,275
false
null
package combo.bandit.dt import combo.bandit.univariate.BanditPolicy import combo.math.VarianceEstimator import combo.sat.Instance import combo.sat.not import combo.sat.toBoolean import combo.sat.toIx import combo.util.IntCollection import combo.util.RandomListCache import combo.util.isEmpty sealed class Node(var data...
0
Kotlin
1
2
2f4aab86e1b274c37d0798081bc5500d77f8cd6f
3,820
combo
Apache License 2.0
aoc25/src/main/kotlin/de/havox_design/aoc2022/day25/SNAFUNumber.kt
Gentleman1983
737,309,232
false
{"Kotlin": 342004, "Scala": 9632}
package de.havox_design.aoc2022.day25 import kotlin.math.* enum class SNAFUNumber(private var symbol: Char, private var value: Long) { TWO('2', 2L), ONE('1', 1L), ZERO('0', 0L), MINUS('-', -1L), DOUBLE_MINUS('=', -2L); fun toSnafuSymbol(): Char = symbol fun toLong(): Long = value fun...
4
Kotlin
0
1
b94716fbc95f18e68774eb99069c0b703875615c
2,477
aoc2022
Apache License 2.0
Kotlin/days/src/day16.kt
dukemarty
224,307,841
false
null
import java.io.BufferedReader import java.io.FileReader import java.lang.Integer.min import java.lang.Integer.parseInt data class Signal(var data: List<Int>) { constructor(raw: String) : this(raw.toCharArray().map { parseInt(it.toString()) }) fun calcFFT(pattern: FFTPattern) { val resList = mutableLi...
0
Kotlin
0
0
6af89b0440cc1d0cc3f07d5a62559aeb68e4511a
2,491
dukesaoc2019
MIT License
src/main/kotlin/marais/villagers/game/GameMap.kt
Gui-Yom
315,269,112
false
null
package marais.villagers.game class GameMap(val width: Int, val height: Int) : Iterable<Position> { val inner = Array(width) { Array(height) { Tile.EMPTY } } operator fun get(pos: Position) = get(pos.x, pos.y) operator fun get(x: Int, y: Int): Tile = inner[x][y] operator fun set(pos: Position, tile:...
0
Kotlin
0
0
9665ce10f361d151f8ce33adab650809a02f7d82
2,004
villagers
Apache License 2.0
src/test/kotlin/Day6Test.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import java.io.File import kotlin.test.assertEquals class Day6Test { @Test fun test_demo_input() { assertEquals( 11, getTotalNumberOfQuestionsThatAnyoneAnsweredYesOn( ("abc\n" + "\n" + "a\n" ...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
4,981
advent-of-code
MIT License
kotlinP/src/main/java/com/jadyn/kotlinp/leetcode/array/array_0.kt
JadynAi
136,196,478
false
null
package com.jadyn.kotlinp.leetcode.array /** *JadynAi since 5/12/21 */ fun main() { println("test ${removeDuplicates(intArrayOf(0, 0, 1, 1, 1, 2, 2))}") } /** * 给你一个有序数组 nums ,请你 原地 删除重复出现的元素,使每个元素 只出现一次 , * 返回删除后数组的新长度. * * 双指针:快慢指针 * 关键点:实时修改数组的值 * 快指针对比的条件是什么? * * */ fun removeDuplicates(nums: IntA...
0
Kotlin
6
17
9c5efa0da4346d9f3712333ca02356fa4616a904
757
Kotlin-D
Apache License 2.0
src/chapter2/problem4/solution2.kts
neelkamath
395,940,983
false
null
/* Question: Partition: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. If x is contained within the list the values of x only need to be after the elements less than x (see below). The partition element x can appear anywhere in t...
0
Kotlin
0
0
4421a061e5bf032368b3f7a4cee924e65b43f690
2,223
ctci-practice
MIT License
src/day14/Cave.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day14 import kotlin.math.sign enum class Detected (val symbol: Char, val isEmpty: Boolean) { AIR ('.', true), ROCK ('#', false), SAND ('o', false), SOURCE ('+', true) } data class Cave (val paths: List<List<Point>>) { var x0: Int = paths.fold<Point, Int> (null) { s, _, _, p -> if (s == nu...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
4,790
advent_of_code_2022
Apache License 2.0
src/main/kotlin/g0501_0600/s0547_number_of_provinces/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0547_number_of_provinces // #Medium #Depth_First_Search #Breadth_First_Search #Graph #Union_Find // #Algorithm_II_Day_6_Breadth_First_Search_Depth_First_Search // #Graph_Theory_I_Day_8_Standard_Traversal #Level_2_Day_19_Union_Find // #2023_01_17_Time_229_ms_(79.73%)_Space_43_MB_(66.22%) class Solu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,116
LeetCode-in-Kotlin
MIT License
src/main/kotlin/days/Day9.kt
wmichaelshirk
315,495,224
false
null
package days class Day9 : Day(9) { private fun sums(input: Iterable<Long>): Sequence<Long> = sequence { input.forEachIndexed { i, a -> input.forEachIndexed { j, b -> if (i != j) yield(a + b) } } } private val inputDat...
0
Kotlin
0
0
b36e5236f81e5368f9f6dbed09a9e4a8d3da8e30
1,325
2020-Advent-of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/kt/kotlinalgs/app/tree/FirstCommonAncestor.ws.kts
sjaindl
384,471,324
false
null
println("test") val root = Node(20) root.left = Node(10) root.right = Node(30) root.left?.right = Node(15) root.left?.right?.right = Node(17) root.left?.left = Node(5) root.left?.left?.left = Node(3) root.left?.left?.right = Node(7) val tree = BinarySearchTree<Int>() println(tree.firstCommonAncestor( // 10 root.l...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
1,463
KotlinAlgs
MIT License
src/days/Day11.kt
EnergyFusion
572,490,067
false
{"Kotlin": 48323}
import java.io.BufferedReader fun main() { val day = 11 fun createMonkeys(inputReader: BufferedReader): List<Monkey> { val monkeys = mutableListOf<Monkey>() var currentListOfItems = mutableListOf<Long>() var testStrings = mutableListOf<String>() var testDiv = 0L lateini...
0
Kotlin
0
0
06fb8085a8b1838289a4e1599e2135cb5e28c1bf
5,118
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/nl/meine/aoc/_2023/Day5.kt
mtoonen
158,697,380
false
{"Kotlin": 201978, "Java": 138385}
package nl.meine.aoc._2023 class Day5 { fun one( seeds: String, seed2soil: String, soil2fertilizer: String, fertilizer2water: String, water2light: String, light2temp: String, temp2humid: String, humidity2loc: String ): Long { val seed2soi...
0
Kotlin
0
0
a36addef07f61072cbf4c7c71adf2236a53959a5
13,408
advent-code
MIT License
src/Day14/Day14.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day14 import readInput import kotlin.math.* class RockStructure(var points: List<Pair<Int, Int>>) { fun maxX(): Int { return points.maxOf { it.first } } fun maxY(): Int { return points.maxOf { it.second } } } class MazePart1() { var matrix: Array<Array<Int>> = arrayOf(arra...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
5,898
advent-of-code-2022
Apache License 2.0
src/test/kotlin/dev/shtanko/algorithms/leetcode/MinimumAbsoluteDifferenceBSTTest.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,647
kotlab
Apache License 2.0
src/Day10.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.lang.RuntimeException import kotlin.math.abs fun main() { fun List<String>.parse(): List<Int?> { val addPattern = "addx (?<num>-?\\d+)".toRegex() return map { val addx = addPattern.matchEntire(it)?.groups?.get("num")?.value when { it == "noop" -> ...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
3,192
advent-of-code-2022
Apache License 2.0
aoc-2023/src/main/kotlin/aoc/aoc19.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val testInput = """ px{a<2006:qkq,m>2090:A,rfg} pv{a>1716:R,A} lnx{m>1548:A,A} rfg{s<537:gd,x>2440:R,A} qs{s>3448:A,lnx} qkq{x<1416:A,crn} crn{x>2662:A,R} in{s<1351:px,qqz} qqz{s>2770:qs,m<1801:hdj,R} gd{a>3333:R,R} hdj{m>838:A,pv} {x=...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
7,438
advent-of-code
Apache License 2.0
2022/src/Day21.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src class NewMonkey { var id: String = "" var hasYelled: Boolean = false var operation: String = "" var firstOperand: String = "" var secondOperand: String = "" var firstLong: Long = Long.MIN_VALUE var secondLong: Long = Long.MIN_VALUE var result: Long = Long.MIN_VALUE cons...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
2,827
AoC
Apache License 2.0
src/main/kotlin/g2801_2900/s2851_string_transformation/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2851_string_transformation // #Hard #String #Dynamic_Programming #Math #String_Matching // #2023_12_18_Time_377_ms_(100.00%)_Space_49_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { private lateinit var g: Array<LongArray> fun numberOfWays(s: String, t: String, k: Long): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,204
LeetCode-in-Kotlin
MIT License
src/Utils.kt
acrab
573,191,416
false
{"Kotlin": 52968}
import java.io.File import java.math.BigInteger import java.security.MessageDigest /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() /** * Converts string to md5 hash. */ fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").dig...
0
Kotlin
0
0
0be1409ceea72963f596e702327c5a875aca305c
2,307
aoc-2022
Apache License 2.0
src/day11/Monkey.kt
quinlam
573,215,899
false
{"Kotlin": 31932}
package day11 import java.util.LinkedList data class Monkey( val items: LinkedList<Long>, val operation: (Long) -> Long, val testNumber: Int, val trueMonkey: Int, val falseMonkey: Int, var inspectionCount: Int = 0 ) { fun inspect(relief: Int, commonModulo: Int, throwTo: (Int, Long) -> Uni...
0
Kotlin
0
0
d304bff86dfecd0a99aed5536d4424e34973e7b1
1,739
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/oowekyala/ijcc/lang/model/LexicalState.kt
oowekyala
160,946,520
false
{"Kotlin": 636537, "HTML": 12345, "Lex": 10654, "Shell": 1940, "Just": 101}
package com.github.oowekyala.ijcc.lang.model import com.github.oowekyala.ijcc.lang.psi.JccIdentifier import com.github.oowekyala.ijcc.lang.psi.JccLiteralRegexUnit import com.github.oowekyala.ijcc.lang.psi.JccRefRegularExpression import com.github.oowekyala.ijcc.lang.psi.match import com.intellij.psi.SmartPsiElementPoi...
9
Kotlin
6
39
3c737d631f562e85361480b17c26824b560898a8
6,942
intellij-javacc
MIT License
src/aoc22/Day14.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc2022.day14 import lib.Path import lib.Point import lib.Solution data class Cave( private val bricks: MutableSet<Point>, private val sands: MutableSet<Point>, ) { constructor(bricks: Set<Point> = emptySet()) : this(bricks.toMutableSet(), mutableSetOf()) p...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,913
aoc-kotlin
Apache License 2.0
src/Day03.kt
karloti
573,006,513
false
{"Kotlin": 25606}
fun main() { val code = (('a'..'z') + ('A'..'Z')).withIndex().associate { (i, c) -> c to i + 1 } fun part1(input: List<String>): Int = input .map { s -> s.chunked(s.length / 2, CharSequence::toSet) } .map { it.reduce(Set<Char>::intersect).single() } .sumOf { code[it]!! } fun part2(...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
691
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CommonChars.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
2,040
kotlab
Apache License 2.0
day12/Part2.kt
anthaas
317,622,929
false
null
import java.io.File import kotlin.math.abs fun main(args: Array<String>) { val input = File("input.txt").readLines().map { Pair(it[0], it.substring(1).toInt()) } var northDistanceFromStartWaypoint = 1 var eastDistanceFromStartWaypoint = 10 var northDistanceFromStartShip = 0 var eastDistanceFromSt...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
2,079
Advent-of-Code-2020
MIT License
src/main/kotlin/me/grison/aoc/y2020/Day22.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2020 import me.grison.aoc.* class Day22 : Day(22, 2020) { override fun title() = "Crab Combat" override fun partOne(): Any { val (player1, player2) = decks() while (player1.isNotEmpty() && player2.isNotEmpty()) { val (p1, p2) = p(player1.shift(), player2.shi...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,584
advent-of-code
Creative Commons Zero v1.0 Universal
src/Day03.kt
mnajborowski
573,619,699
false
{"Kotlin": 7975}
fun main() { val itemPriorities = (('a'..'z') + ('A'..'Z')).mapIndexed { i, e -> e to i + 1 }.toMap() fun part1(input: List<String>): Int = input.sumOf { rucksack -> itemPriorities.getValue( rucksack.chunked(rucksack.length / 2).let { compartments -> comp...
0
Kotlin
0
0
e54c13bc5229c6cb1504db7e3be29fc9b9c4d386
745
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/hard/MergeKLists.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.hard import com.daily.algothrim.leetcode.ListNode /** * 23. 合并K个升序链表 * * 给你一个链表数组,每个链表都已经按升序排列。 * 请你将所有链表合并到一个升序链表中,返回合并后的链表。 */ class MergeKLists { companion object { @JvmStatic fun main(args: Array<String>) { MergeKLists().mergeKLists(arrayO...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,942
daily_algorithm
Apache License 2.0
src/main/kotlin/co/csadev/advent2021/Day18.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 18 * Problem Description: http://adventofcode.com/2021/day/18 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsList import com.github.shiguruikai.combinatoricskt.combinations import ...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
4,203
advent-of-kotlin
Apache License 2.0
src/main/kotlin/aoc2015/Day17.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2015 import AoCDay // https://adventofcode.com/2015/day/17 object Day17 : AoCDay<Int>( title = "No Such Thing as Too Much", part1Answer = 654, part2Answer = 57, ) { private fun parseContainers(input: String) = input.lines().map(String::toInt).toIntArray() override fun part1(input: Stri...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
1,668
advent-of-code-kotlin
MIT License
src/main/kotlin/numberFraction.kt
AlBovo
574,593,169
false
{"Kotlin": 75843}
class NumberFraction(var numerator: Int, denominatorValue: Int){ var denominator = denominatorValue set(value){ require(value != 0){ "The denominator must be different from 0" } field = value } init{ require(denominatorValue != ...
0
Kotlin
0
0
56a31313c53cc3525d2aa3c29b3a2085b1b1b506
2,313
Compiti
MIT License
core/src/main/kotlin/com/bsse2018/salavatov/flt/algorithms/CFPQMatrix.kt
vsalavatov
241,599,920
false
{"Kotlin": 149462, "ANTLR": 1960}
package com.bsse2018.salavatov.flt.algorithms import com.bsse2018.salavatov.flt.grammars.ContextFreeGrammar import com.bsse2018.salavatov.flt.utils.Graph import org.la4j.matrix.SparseMatrix import org.la4j.matrix.sparse.CRSMatrix fun CFPQMatrixQuery(graph: Graph, wcnf: ContextFreeGrammar): HashSet<Pair<Int, Int>> { ...
0
Kotlin
0
1
c1c229c113546ef8080fc9d3568c5024a22b80a5
1,812
bsse-2020-flt
MIT License
src/main/kotlin/zanagram/DynamicArraySorting.kt
HenriqueRocha
259,845,874
false
null
package zanagram fun <T : Comparable<T>> DynamicArray<out T>.bubbleSort() { var n = size() var swapped: Boolean do { swapped = false for (i in 1 until n) { if (this[i - i] > this[i]) { swap(this, i - 1, i) swapped = true } } ...
1
Kotlin
0
0
fbc4f2fc5489306dbc0eddfcd2a527745e297b78
2,095
zanagram
MIT License
src/main/kotlin/io/undefined/ExclusiveTimeOfFunctions.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.undefined import io.utils.runTests import java.util.* // https://leetcode.com/problems/exclusive-time-of-functions/ class ExclusiveTimeOfFunctions { // https://leetcode.com/problems/exclusive-time-of-functions/discuss/105062/Java-Stack-Solution-O(n)-Time-O(n)-Space fun execute(n: Int, logs: List<Stri...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,593
coding
MIT License
src/main/kotlin/com/colinodell/advent2022/Day03.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day03(input: List<String>) { private val rucksacks = input.map { it.toList() } fun solvePart1() = rucksacks .map { it.chunked(it.size / 2) } // Split each line into two compartments .map { it[0].intersect(it[1]) } // Find the common item type .su...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
718
advent-2022
MIT License
src/main/kotlin/day12/DayTwelve.kt
Neonader
572,678,494
false
{"Kotlin": 19255}
package day12 import java.io.File import kotlin.math.min val fileList = File("puzzle_input/day12.txt").readLines() // the rows of 'S' and 'E' respectively val startLine = fileList.indexOfFirst { line -> line.contains('S') } val goalLine = fileList.indexOfFirst { line -> line.contains('E') } // the coordinates of 'S'...
0
Kotlin
0
3
4d0cb6fd285c8f5f439cb86cb881b4cd80e248bc
3,051
Advent-of-Code-2022
MIT License
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_9_Palindrome_Number.kt
v43d3rm4k4r
515,553,024
false
{"Kotlin": 40113, "Java": 25728}
package leetcode.solutions.concrete.kotlin import leetcode.solutions.* import leetcode.solutions.ProblemDifficulty.* import leetcode.solutions.validation.SolutionValidator.* import leetcode.solutions.annotations.ProblemInputData import leetcode.solutions.annotations.ProblemSolution /** * __Problem:__ Given an intege...
0
Kotlin
0
1
c5a7e389c943c85a90594315ff99e4aef87bff65
2,411
LeetcodeSolutions
Apache License 2.0
src/Day04.kt
emersonf
572,870,317
false
{"Kotlin": 17689}
@file:OptIn(ExperimentalStdlibApi::class) fun main() { fun String.toIntRange(): IntRange { val (lowerBound, upperBound) = split("-") return lowerBound.toInt()..upperBound.toInt() } fun String.asRangePair(): Pair<IntRange, IntRange> { val (first, second) = split(",") return ...
0
Kotlin
0
0
0e97351ec1954364648ec74c557e18ccce058ae6
1,367
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/katas/kotlin/graph/Traversal3.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.graph import katas.kotlin.graph.Graph.Node import nonstdlib.join import datsok.shouldEqual import org.junit.Test import java.util.* class Traversal3 { @Test fun `depth-first traversal`() { "[a]".toGraph().dft("a").join("-") shouldEqual "a" "[a-b]".toGraph().dft("a").join("-") ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,481
katas
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/IsPossible.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
2,826
kotlab
Apache License 2.0
day06/kotlin/RJPlog/day2306_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File fun waitForIt(in1: Int): Long { val pattern = """(\d)+""".toRegex() var lines = File("day2306_puzzle_input.txt").readLines() var line0 = pattern.findAll(lines[0]).map { it.value }.toList() var line1 = pattern.findAll(lines[1]).map { it.value }.toList() var time = mutableListOf<Pair<Long, L...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
1,403
aoc-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ArrayOfDoubledPairs.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,504
kotlab
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day01.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.math.max import kotlin.test.assertEquals object Day01 : AbstractDay() { @Test fun tests() { assertEquals(24000, part1(testInput)) assertEquals(70374, part1(puzzleInput)) assert...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
1,526
aoc
Apache License 2.0
src/main/kotlin/day10/Day10Second.kt
mdenburger
317,466,663
false
null
package day10 import java.io.File import kotlin.math.pow fun main() { val differences = File("src/main/kotlin/day10/day10-input.txt") .readLines() .map { it.toInt() } .sorted() .let { listOf(0) + it + listOf(it.last() + 3) } .windowed(2) .map { it[1] - it[0] } ...
0
Kotlin
0
0
b965f465cad30f949874aeeacd8631ca405d567e
935
aoc-2020
MIT License
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day16/Packet.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day16 sealed class Packet(open val version: Int, open val subPackets: List<Packet> = emptyList()) { companion object { const val LITERAL_VALUE = 4; } abstract fun evaluate(): Long data class LiteralValue(override val version: Int, val va...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
1,991
AdventOfCode2021
Apache License 2.0
Kotlin/problems/0033_sort_linked_list.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
//Problem Statement /* Sort a linked list in O(n log n) time using constant space complexity. */ class ListNode(var `val`: Int = 0) { var next: ListNode? = null } class Solution { fun sortList(head: ListNode?): ListNode? { if(head == null ) return head; var helper:MutableList<L...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
2,242
algorithms
MIT License
src/main/kotlin/days/aoc2022/Day2.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day class Day2 : Day(2022, 2) { override fun partOne(): Any { return calculateScoreOfGame1(inputList) } override fun partTwo(): Any { return calculateScoreOfGame2(inputList) } fun calculateScoreOfGame1(input: List<String>): Int { return in...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
1,175
Advent-Of-Code
Creative Commons Zero v1.0 Universal
js/js.translator/testData/webDemoExamples2/maze.kt
android
263,405,600
true
null
/** * Let's Walk Through a Maze. * * Imagine there is a maze whose walls are the big 'O' letters. * Now, I stand where a big 'I' stands and some cool prize lies * somewhere marked with a '$' sign. Like this: * * OOOOOOOOOOOOOOOOO * O O * O$ O O * OOOOO O * O ...
34
Kotlin
37
316
74126637a097f5e6b099a7b7a4263468ecfda144
5,698
kotlin
Apache License 2.0
kotlin/300.Longest Increasing Subsequence(最长上升子序列).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p>Given an unsorted array of integers, find the length of longest increasing subsequence.</p> <p><b>Example:</b></p> <pre> <b>Input:</b> <code>[10,9,2,5,3,7,101,18] </code><b>Output: </b>4 <strong>Explanation: </strong>The longest increasing subsequence is <code>[2,3,7,101]</code>, therefore the length is <code...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
2,110
leetcode
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2017/Day22.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2017 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.plus fun main() = Day22.run() object Day22 : Day(2017, 22) { // Dirs UP, RIGHT, DOWN, LEFT private var dirs = arrayOf(Pair(0, 1), Pair(1, 0), Pair(0, -1), Pair(-1, 0)); override fun part1(): Int { val...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,223
adventofkotlin
MIT License
advent_of_code/2018/solutions/day_7_b.kt
migafgarcia
63,630,233
false
{"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343}
import java.io.File import java.util.* data class Task(val id: Char, val incoming: ArrayList<Task>, val outgoing: ArrayList<Task>, var discovered: Boolean = false, var finished: Boolean = false, var executed: Boolean = false) data class Worker(var currentTask: Task? = null, var timeLeft: Int = 0) fun main(args: Arr...
0
C++
3
9
82f5e482c0c3c03fd39e46aa70cab79391ed2dc5
2,558
programming-challenges
MIT License
app/src/main/java/com/alexjlockwood/beesandbombs/demos/utils/MathUtils.kt
alexjlockwood
270,120,227
false
null
package com.alexjlockwood.beesandbombs.demos.utils import kotlin.math.pow import kotlin.math.sqrt const val PI = Math.PI.toFloat() const val TWO_PI = 2 * PI const val HALF_PI = PI / 2 /** * Calculates the cartesian distance between two points. */ fun dist(x1: Float, y1: Float, x2: Float, y2: Float): Float { re...
0
Kotlin
23
374
0d7a86ba60c1734c7b4376d649b019e0c8241c4d
1,174
bees-and-bombs-compose
MIT License
src/main/kotlin/Day14.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.TreeMap fun main() { val input = readFileAsList("Day14") println(Day14.part1(input)) println(Day14.part2(input)) } object Day14 { fun part1(input: List<String>): Int { val field = Field.from(input) return simulateSand(field) } fun part2(input: List<String>): ...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
4,564
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day14/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day14 fun launchDay14(testCase: String) { launchPart1(testCase) launchPart2(testCase) } private fun launchPart1(testCase: String) { val input = readInput(testCase) tiltNorth(input) println("Day 14, part 1: ${calcSum(input)}") } private fun launchPart2(testCase: String)...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
4,056
advent-of-code-2023
MIT License