path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/net/colors_wind/particleswarmoptimization/Particles.kt
ColorsWind
351,369,022
false
null
package net.colors_wind.particleswarmoptimization import net.colors_wind.particleswarmoptimization.Vector.Companion.times import kotlin.random.Random class Particles(val question: Question) { var iterations: Int = 0 val particles: Array<Particle> = Array(question.N){ Particle(this, it) } /** attribute *...
0
Kotlin
0
0
54f289a61436be27758a21a5581dd478c1d9f840
2,274
ParticleSwarmOptimization
MIT License
src/main/kotlin/kt/kotlinalgs/app/sorting/CountingSort.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.sorting println("test") /* array: (2, 6, 4) 0 1 2 3 4 5 6 7 8 9 10 counts bei max 10: (0,0,1,0,1,0,1,0,0,0,0 ) accumulated: (0,0,1,1,2,2,3,3,3,3,3 ) adj.: (0,0,0,1,2,2,3,3,3,3,3 ) ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
3,382
KotlinAlgs
MIT License
src/Day10.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
fun main() { fun part1(input: List<String>): Int { return countSignals(input, draw = false) } fun part2(input: List<String>): Int { return countSignals(input, draw = true) } val testInput = readInput("Day10_test") check(part1(testInput) == 13140) // check(part2(testInput) ==...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
3,476
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/frankandrobot/rapier/parse/getMatchedFillers.kt
frankandrobot
62,833,944
false
null
/* * Copyright 2016 <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 ...
1
Kotlin
1
1
ddbc0dab60ca595e63a701e2f8cd6694ff009adc
3,092
rapier
Apache License 2.0
src/main/kotlin/org/hildan/ipm/helper/galaxy/money/Money.kt
joffrey-bion
226,177,839
false
null
package org.hildan.ipm.helper.galaxy.money import org.hildan.ipm.helper.utils.formatWithSuffix import kotlin.time.Duration import kotlin.time.seconds fun min(p1: Price, p2: Price) = if (p1 < p2) p1 else p2 fun List<Price>.sum() = fold(Price.ZERO) { p1, p2 -> p1 + p2} fun List<ValueRate>.sumRates() = fold(ValueRate....
0
Kotlin
0
1
0458e397d5ccdc48015628c79c69fde47e2d4f22
2,626
idle-planet-miner-helper
MIT License
src/main/kotlin/com/github/shmvanhouten/adventofcode/day3/ValidTriangleCounter.kt
SHMvanHouten
109,886,692
false
{"Kotlin": 616528}
package com.github.shmvanhouten.adventofcode.day3 class ValidTriangleCounter(private val validTriangleChecker: ValidTriangleChecker = ValidTriangleChecker()) { fun countValidTriangles(inputTrianglesString: String): Int { val trianglesList = formatInputStringToList(inputTrianglesString) return tri...
0
Kotlin
0
0
a8abc74816edf7cd63aae81cb856feb776452786
1,496
adventOfCode2016
MIT License
src/main/kotlin/utilities/TaxBracketGenerator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package utilities import dataModel.base.Money.Companion.dollars import dataModel.base.Percent import dataModel.base.Percent.Companion.percent import dataModel.base.TaxBracket import kotlin.random.Random private val maxPercentBps = 100.percent.amountBps object TaxBracketGenerator { /** * The current data mod...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
3,211
tax-calculator
MIT License
src/main/kotlin/solutions/CHK/CheckoutSolution.kt
DPNT-Sourcecode
749,456,768
false
{"Kotlin": 13106, "Shell": 2184}
package solutions.CHK //+------+-------+------------------------+ //| Item | Price | Special offers | //+------+-------+------------------------+ //| H | 10 | 5H for 45, 10H for 80 | //| K | 80 | 2K for 150 | //| N | 40 | 3N get one M free | //| P | 50 | 5P for 200 ...
0
Kotlin
0
0
cb056a981f511e8c887ce03317b94c28e62d4318
3,328
CHK-gply01
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindGoodStrings.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
5,265
kotlab
Apache License 2.0
src/main/kotlin/org/gnit/cpsd/GeoCalculation.kt
nehemiaharchives
325,581,086
false
null
package org.gnit.cpsd import kotlin.math.* /** * [Reference](https://stackoverflow.com/questions/3694380/calculating-distance-between-two-points-using-latitude-longitude) * * Calculate distance between two points in latitude and longitude taking * into account height difference. If you are not interested in heigh...
0
Kotlin
0
0
055a7baf597e25ae48b6f4b5421cf249a1fb3dbe
2,868
cpsd
MIT License
src/main/java/com/booknara/problem/string/LongestPalindromicSubstringKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.string /** * 5. Longest Palindromic Substring (Medium) * https://leetcode.com/problems/longest-palindromic-substring/ */ class LongestPalindromicSubstringKt { // T:O(n^2), S:O(1) fun longestPalindrome(s: String): String { // input check, s.length >= 1 if (s.length == 1) retu...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,065
playground
MIT License
src/Day01.kt
Sagolbah
573,032,320
false
{"Kotlin": 14528}
import kotlin.math.max fun main() { fun part1(input: List<String>): Long { var ans: Long = -1 var curr: Long = 0 for (line in input) { if (line.isEmpty()) { ans = max(ans, curr) curr = 0 } else { curr += line.toLong() ...
0
Kotlin
0
0
893c1797f3995c14e094b3baca66e23014e37d92
956
advent-of-code-kt
Apache License 2.0
kotlin/src/main/kotlin/com/ximedes/aoc/day04/PassportProcessing.kt
rolfchess
314,041,772
false
null
package com.ximedes.aoc.day04 import com.javamonitor.tools.Stopwatch import com.ximedes.aoc.util.assertTrue import com.ximedes.aoc.util.getClasspathFile // :warning: *Day 4: Toboggan Trajectory* solution thread - here be spoilers! :warning: fun main() { val sw = Stopwatch("Day 4", "load input") val file = g...
0
Kotlin
0
0
e666ef0358980656e1c52a3ec08482dd7f86e8a3
2,252
aoc-2020
The Unlicense
src/main/kotlin/g2401_2500/s2407_longest_increasing_subsequence_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2407_longest_increasing_subsequence_ii // #Hard #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Segment_Tree #Binary_Indexed_Tree // #Monotonic_Queue #2023_07_03_Time_518_ms_(100.00%)_Space_56.7_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { private class SegTree(private val...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,676
LeetCode-in-Kotlin
MIT License
src/shmp/simulation/culture/group/centers/RelationCenter.kt
ShMPMat
212,499,539
false
null
package shmp.simulation.culture.group.centers import shmp.utils.getTruncated import shmp.simulation.culture.group.GroupConglomerate import shmp.simulation.culture.group.GroupError import shmp.simulation.culture.group.intergroup.Relation import shmp.simulation.space.tile.Tile import shmp.simulation.space.tile.getDistan...
0
Kotlin
0
0
9fc6faafa1dbd9737dac71dc8a77960accdae81f
3,472
CulturesSim
MIT License
src/codility/NumberOfDiscIntersections.kt
faniabdullah
382,893,751
false
null
package codility /* We draw N discs on a plane. The discs are numbered from 0 to N − 1. An array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn with its center at (J, 0) and radius A[J]. We say that the J-th disc and K-th disc intersect if J ≠ K and the J-th and K...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,570
dsa-kotlin
MIT License
LR6/src/main/kotlin/Task2V1.kt
Kirchberg
602,987,232
false
null
// Списки (стеки, очереди) I(1..n) и U(1..n) содержат результаты n измерений тока и напряжения на неизвестном // сопротивлении R. Найти приближенное число R методом наименьших квадратов. import kotlin.math.pow // Create a class LeastSquaresR that takes two lists of measurements, currents, and voltages class LeastSqua...
0
Kotlin
0
0
b6a459a30ef20b0f38c4869d0949e22f4239183e
1,888
BigDataPL
MIT License
src/main/kotlin/com/colinodell/advent2023/Day06.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day06(private val input: List<String>) { private fun countWaysToWin(time: Long, recordDistance: Long) = 0.rangeTo(time) .takeWhile { holdTime -> ((time - holdTime) * holdTime) <= recordDistance } .count() .let { time - (it * 2) + 1 } fun solvePar...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
913
advent-2023
MIT License
app/src/test/java/com/terencepeh/leetcodepractice/IntersectionArrays.kt
tieren1
560,012,707
false
{"Kotlin": 26346}
package com.terencepeh.leetcodepractice fun intersection(nums1: IntArray, nums2: IntArray): IntArray { return nums1.intersect(nums2.toHashSet()).toIntArray() } fun intersection2(nums1: IntArray, nums2: IntArray): IntArray { val set1 = nums1.toHashSet() val set2 = nums2.toHashSet() return if (set1.siz...
0
Kotlin
0
0
427fa2855c01fbc1e85a840d0be381cbb4eec858
927
LeetCodePractice
MIT License
src/day13/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day13 import java.io.File import kotlin.math.abs fun main() { val input = File("src/day13/input.txt").readText() val coords = Regex("([0-9]*),([0-9]*)").findAll(input) .map { Pair(it.groupValues[1].toInt(), it.groupValues[2].toInt()) } .toSet() val folds = Regex("fold along ([xy])...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,027
advent-of-code-2021
MIT License
src/main/kotlin/algorithms/sorting/quick_sort/QuickSort.kt
AANikolaev
273,465,105
false
{"Java": 179737, "Kotlin": 13961}
package algorithms.sorting.quick_sort import algorithms.sorting.InplaceSort class QuickSort : InplaceSort { override fun sort(values: IntArray) { quickSort(values) } private fun quickSort(ar: IntArray?) { if (ar == null) return quickSort(ar, 0, ar.size - 1) } // Sort int...
0
Java
0
0
f9f0a14a5c450bd9efb712b28c95df9a0d7d589b
1,182
Algorithms
MIT License
src/main/kotlin/aoc05/Solution05.kt
rainer-gepardec
573,386,353
false
{"Kotlin": 13070}
package aoc05 import java.nio.file.Paths /* [D] [N] [C] [Z] [M] [P] 1 2 3 [J] [Z] [G] [Z] [T] [S] [P] [R] [R] [Q] [V] [B] [G] [J] [W] [W] [N] [L] [V] [W] [C] [F] [Q] [T] [G] [C] [T] [T] [W] [H] [D] [W] [W] [H] [T] [R] [M] [B] [T] [G] [T] [R] [B] [P] [B] [G] [G] [S] ...
0
Kotlin
0
0
c920692d23e8c414a996e8c1f5faeee07d0f18f2
2,324
aoc2022
Apache License 2.0
Generics/Generic functions/src/Task.kt
margalis
393,934,017
false
null
import java.util.* public fun <T, C : MutableCollection<in T>> Collection<T>.partitionTo(col1: C, col2: C, predicate: (T)-> Boolean): Pair<C,C> { //T-n itemi tesak, C-n` Collectioni mejini //greladzevy` toCollectioni pes for( item in this){ if(predicate(item)){ col1.add(item) } ...
0
Kotlin
0
0
faf2034dcc4e0c90cd39b6c059de7aae4faade73
957
Kotlin_Koans_mg
MIT License
kotlin/2020/round-1b/expogo/src/main/kotlin/bfs/Solution.kt
ShreckYe
345,946,821
false
null
package bfs fun main() { val T = readLine()!!.toInt() repeat(T) { t -> val (X, Y) = readLine()!!.splitToSequence(' ').map(String::toInt).toList() val zero = Point(0, 0) val goal = Point(X, Y) val bfsPoints = bfsPointsWithin(sequenceOf(zero to emptySequence()), 0, 9) val ...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
1,389
google-code-jam
MIT License
src/main/kotlin/wtf/log/xmas2021/day/day05/Day05.kt
damianw
434,043,459
false
{"Kotlin": 62890}
package wtf.log.xmas2021.day.day05 import com.google.common.collect.HashMultiset import com.google.common.collect.Multiset import wtf.log.xmas2021.Day import wtf.log.xmas2021.util.math.Line import wtf.log.xmas2021.util.math.Point import wtf.log.xmas2021.util.math.points import java.io.BufferedReader object Day05 : Da...
0
Kotlin
0
0
1c4c12546ea3de0e7298c2771dc93e578f11a9c6
1,483
AdventOfKotlin2021
BSD Source Code Attribution
leetcode/src/array/Q73.kt
zhangweizhe
387,808,774
false
null
package array fun main() { // 73. 矩阵置零 // https://leetcode-cn.com/problems/set-matrix-zeroes/ val mat = Array<IntArray>(3) { when(it) { // 0 -> intArrayOf(0,1,2,0) // 1 -> intArrayOf(3,4,5,2) // 2 -> intArrayOf(1,3,1,5) // else -> intArrayOf() ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,220
kotlin-study
MIT License
grokking-algorithms/06 - Breadth-first Search/01_BFS_Person.kt
arturschaefer
427,090,600
false
{"C": 48055, "Kotlin": 24446, "C++": 16696, "Dart": 3630, "QMake": 168}
import java.util.Deque import java.util.LinkedList import kotlin.collections.last fun main() { val valuesList = listOf( Person("you") to listOf(Person("alice"), Person("bob"), Person("claire")), Person("bob") to listOf(Person("anuj"), Person("peggy")), Person("alice") to listOf(Person("peg...
0
C
0
0
04c34298739cab13b5cd755b4c6786fc1fe236cd
1,999
computer-science-studies
Apache License 2.0
src/main/kotlin/me/grison/aoc/Extensions.kt
agrison
315,292,447
false
{"Kotlin": 267552}
/** * This file contains useful Kotlin extensions to deal with * various problems that we need to solve during Advent Of Code * * Including String, Ints, Longs, Iterable & Collections, Ranges, Pairs, Complex, ... * * These extensions are used in all the different years solutions. */ package me.grison.aoc import...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
14,264
advent-of-code
Creative Commons Zero v1.0 Universal
app/src/y2021/day24/Day24.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day24 import common.* import common.annotations.AoCPuzzle import y2021.day24.Variable.* import java.io.File import javax.xml.stream.events.Characters import kotlin.math.roundToInt import kotlin.time.Duration import kotlin.time.ExperimentalTime import kotlin.time.milliseconds fun main(args: Array<String>...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
10,027
advent-of-code-2021
Apache License 2.0
src/Day02.kt
greeshmaramya
514,310,903
false
{"Kotlin": 8307}
data class Day2( val password: String, val l: Int, val r: Int, val c: Char ) fun main() { fun String.modifyInput(): Day2 { val s = split(':') val s1 = s.first().split(' ') val s2 = s1.first().split('-') return Day2(password = <PASSWORD>(), l = s2.first().toInt(), r...
0
Kotlin
0
0
9e1128ee084145f5a70fe3ad4e71b05944260d6e
1,079
aoc2020
Apache License 2.0
src/kotlin2022/Day02.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2022 import readInput //rock A X //paper B Y //scissors C Z val winningPairs = mapOf( "A" to "Y", "B" to "Z", "C" to "X" ) val loosingPairs = mapOf( "A" to "Z", "B" to "X", "C" to "Y" ) val drawPairs = mapOf( "A" to "X", "B" to "Y", "C" to "Z" ) fun main() { va...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
909
advent-of-code-kotlin
Apache License 2.0
src/test/kotlin/com/igorwojda/string/reverse/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.string.reverse // Kotlin idiomatic way private object Solution1 { private fun reverse(str: String): String { return str.reversed() } } // Iterative approach private object Solution2 { private fun reverse(str: String): String { var reversed = "" str.forEach { ...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
1,358
kotlin-coding-challenges
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day15.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.* import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.ndarray import org.jetbrains.kotlinx.multik.ndarray.data.D2Array import org.jetbrains.kotlinx.multik.ndarray.data.get open class Part15A : PartSolution() { la...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
1,880
advent-of-code-kotlin
MIT License
src/Day10.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
import java.lang.StringBuilder fun main() { class Cpu(val input: List<String>) { var cycle = 0 var instructionPointer = 0 var instruction: String? = null var register = 1 var cyclesToExecute = 0 fun beforeCycle(): Boolean { cycle++ if (instr...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
2,136
AdventOfCode2022
Apache License 2.0
src/main/kotlin/Day10.kt
alex859
573,174,372
false
{"Kotlin": 80552}
fun main() { val testInput = readInput("Day10_test.txt") check(testInput.day10Part1() == 13140) check(testInput.day10Part2() == """ ##..##..##..##..##..##..##..##..##..##.. ###...###...###...###...###...###...###. ####....####....####....####....####.... #####.....#####.....#...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
2,008
advent-of-code-kotlin-2022
Apache License 2.0
src/Day06.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
fun main() { fun indexOfMarker(input: String, length: Int): Int { val unique = input .windowed(length) .map { it.toSet() } .first { it.size == length } .joinToString("") return input.indexOf(unique) + length } fun part1(input: List<String>): ...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
760
aoc-2022
Apache License 2.0
app/src/main/kotlin/com/bloidonia/advent2020/Day_09.kt
timyates
317,965,519
false
null
package com.bloidonia.advent2020 import com.bloidonia.longsFromResource class Day_09 { // Given a list of T, return a sequence of every combination of pairs fun <T> combinationPairs(input: List<T>): Sequence<Pair<T, T>> = sequence { for (i in 0 until input.size - 1) for (j in i + 1 until ...
0
Kotlin
0
0
cab3c65ac33ac61aab63a1081c31a16ac54e4fcd
1,489
advent-of-code-2020-kotlin
Apache License 2.0
03/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : List<String> { return File("input.txt") .readLines() } fun getRates(report : List<String>) : Pair<Int, Int> { var lineFreq = Array(report[0].length) { Array(2) {0} } for (line in report) { for ((idx, char) in line.withIndex()) { lineFr...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
999
advent-of-code-2021
MIT License
Problems/Algorithms/1856. Maximum Subarray Min-Product/MaxMinProduct.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun maxSumMinProduct(nums: IntArray): Int { val n = nums.size val stack = Stack<Int>() val nextSmaller = IntArray(n) { n } val prevSmaller = IntArray(n) { -1 } for (i in 0..n-1) { while (!stack.isEmpty() && nums[i] < nums[stack.peek()]) ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,267
leet-code
MIT License
kotlin/1254-number-of-closed-islands.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 closedIsland(grid: Array<IntArray>): Int { val rows = grid.size val cols = grid[0].size val visited = Array(rows){BooleanArray(cols)} fun isValid(r: Int, c: Int) = r in (0 until rows) && c in (0 until cols) fun dfs(r: Int, c: Int): Int { if...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,071
leetcode
MIT License
src/test/kotlin/Day7Test.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day7Test { @Test fun test_demo_input() { assertEquals( 4, numberOfBagColorsThatCanContainGoldBag( ("light red bags contain 1 bright white bag, 2 muted yellow bags.\n" + "dark or...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
9,951
advent-of-code
MIT License
src/main/kotlin/g0901_1000/s0939_minimum_area_rectangle/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0939_minimum_area_rectangle // #Medium #Array #Hash_Table #Math #Sorting #Geometry // #2023_04_29_Time_461_ms_(100.00%)_Space_74.8_MB_(20.00%) import java.util.Arrays import kotlin.math.abs class Solution { fun minAreaRect(points: Array<IntArray>): Int { if (points.size < 4) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,349
LeetCode-in-Kotlin
MIT License
src/main/kotlin/cloud/dqn/leetcode/self/IslandFinder.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode.self /** * Nov 12, 2017 * Self generated problem * * Find the islands in a (0,1) * * Island is defined as a 1 surrounded by 0's * - ?? Are pairs found on edges considered Islands (Peninsula) * Planned improvements: * Handle easily convertable resutl * Handle non NxN ...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
6,375
cloud-dqn-leetcode
No Limit Public License
jvm/word-finder/src/test/kotlin/net/maelbrancke/filip/service/SolverDataTest.kt
filipmaelbrancke
597,192,385
false
{"Rust": 268793, "Kotlin": 38872, "Shell": 17239, "Dockerfile": 478, "PLpgSQL": 238}
package net.maelbrancke.filip.service import net.maelbrancke.filip.KotestProject import io.kotest.assertions.arrow.core.shouldBeLeft import io.kotest.assertions.arrow.core.shouldBeRight import io.kotest.core.spec.style.FunSpec import io.kotest.datatest.WithDataTestName import io.kotest.datatest.withData import io.kote...
0
Rust
0
0
ce407259666c3908f2f2c3a79659f0a16c68efd0
3,472
playground
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RepeatedSubstringPattern.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
1,699
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindBall.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,663
kotlab
Apache License 2.0
src/main/kotlin/Grid2D.kt
MatteoMartinelli97
403,882,570
false
{"Kotlin": 39512}
import kotlin.random.Random /** * 2D grid container as a graph * * This class builds a graph from a 2D grid of squares, where each square is a node, and the length of each edge * is 1.0. * 2 adjacent squares are considered also adjacent nodes. * Since [Graph] works with node IDs, also [Grid2D] does, but provides...
0
Kotlin
0
0
f14d4ba7058be629b407e06eebe09fae63aa35c1
3,999
Dijkstra-and-AStar
Apache License 2.0
Rare_numbers/Kotlin/src/RareNumbers.kt
ncoe
108,064,933
false
{"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409}
import java.time.Duration import java.time.LocalDateTime import kotlin.math.sqrt class Term(var coeff: Long, var ix1: Byte, var ix2: Byte) const val maxDigits = 16 fun toLong(digits: List<Byte>, reverse: Boolean): Long { var sum: Long = 0 if (reverse) { var i = digits.size - 1 while (i >= 0) ...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
7,606
rosetta
MIT License
android/app/src/main/java/com/thepyprogrammer/ktlib/signalProcessing/SignalProcessing.kt
terminalai
312,471,067
false
null
package com.thepyprogrammer.ktlib.signalProcessing import div import normalise import slice import sum import timesConj import toComplex import transpose import kotlin.math.pow import kotlin.math.roundToInt const val SR = 64.0 const val stepSize = 1 const val windowLength = 256 private val f_nr_LBs: Int = (0.5 * win...
1
Jupyter Notebook
4
10
2064375ddc36bf38f3ff65f09e776328b8b4612a
2,430
GaitMonitoringForParkinsonsDiseasePatients
MIT License
src/commonMain/kotlin/model/model.kt
chausknecht
544,439,666
false
null
package model import dev.fritz2.core.Lenses import kotlin.random.Random data class Coordinate(val x: Int, val y: Int) { companion object { fun of(index: Int) = Coordinate(index % World.MAX_X, index / World.MAX_X) } val index: Int = y * World.MAX_X + x operator fun plus(move: Move) = Coordin...
0
Kotlin
0
1
6850193ca4902c55b4d4bcaea71f8c63bffa89fe
13,101
wimmel-fritz
MIT License
src/main/kotlin/wk269/Problem3.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package wk269 import kotlin.math.min fun main() { val result = Problem3().minimumDeletions(intArrayOf(1, 2)) println(result) } class Problem3 { fun minimumDeletions(nums: IntArray): Int { // Find indices of min and max elements var minIndex = 0 var maxIndex = 0 for ((index...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
1,714
leetcode-kotlin
MIT License
src/main/kotlin/g2601_2700/s2654_minimum_number_of_operations_to_make_all_array_elements_equal_to_1/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2601_2700.s2654_minimum_number_of_operations_to_make_all_array_elements_equal_to_1 // #Medium #Array #Math #Number_Theory #2023_07_20_Time_172_ms_(100.00%)_Space_35.3_MB_(100.00%) class Solution { fun minOperations(nums: IntArray): Int { var g = nums[0] var list = mutableListOf<Int>() ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,103
LeetCode-in-Kotlin
MIT License
src/Day22.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import utils.Coord2DInt import kotlin.math.max class Day22 { enum class Direction(val movement: Coord2DInt, val value: Int) { RIGHT(Coord2DInt(0, 1), 0), DOWN(Coord2DInt(1, 0), 1), LEFT(Coord2DInt(0, -1), 2), UP(Coord2DInt(-1, 0), 3) } companion object { val part1 =...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
12,274
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountGoodNumbers.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
1,397
kotlab
Apache License 2.0
src/Day09.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign fun main() { data class Coords( val column: Int, val row: Int, ) { fun distance(other: Coords): Int { return max(abs(column - other.column), abs(row - other.row)) } } fun part1(input: Li...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
8,067
advent-2022
Apache License 2.0
src/main/kotlin/Day-7.kt
joebutler2
577,057,170
false
{"Kotlin": 5432}
import java.util.Stack interface IOObject { fun getBaseName(): String fun calculateSize(): Int } // Composite class Dir : IOObject { private var children: MutableList<IOObject> = mutableListOf() var name: String constructor(name: String) { this.name = name } override fun getBaseN...
0
Kotlin
0
0
7abdecbc4a4397f917c84bd8d8b9f05fb7079c75
2,714
advent-of-code-kotlin
MIT License
src/Day08.kt
an4
575,331,225
false
{"Kotlin": 117105}
fun main() { fun part1(input: List<String>): Int { val matrix = Array(input.size) { IntArray(input[0].length) } for (row in input.indices) { val charArr = input[row].toCharArray() for (column in charArr.indices) { matrix[row][column] = charArr[column].digitToI...
0
Kotlin
0
0
df64adcc5d1ccab370acef01a7ed4d480ffbe2be
14,340
aoc22
Apache License 2.0
src/main/java/dev/haenara/mailprogramming/solution/y2020/m01/d26/Solution200126.kt
HaenaraShin
226,032,186
false
null
package dev.haenara.mailprogramming.solution.y2020.m01.d26 import dev.haenara.mailprogramming.solution.Solution /** * 매일프로그래밍 2020. 01. 26 * 정수 배열이 주어졌을 때, 오른쪽 원소가 왼쪽 원소보다 더 큰 경우 중 두 원소의 차가 최대가 되는 값을 찾으시오. * Input: [2, 7, 9, 5, 1, 3, 5] * Output: 7 (원소 2와 9) * * 풀이 * 문제의 조건대로 만약 두 원소의 차가 최대가 되는 경우는 둘중의 하나의 원소가...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
1,558
MailProgramming
MIT License
src/Day01.kt
0nko
573,144,534
false
{"Kotlin": 1263}
fun getSums(input: List<String>): List<Int> { val sums = mutableListOf(0) input.forEach { if (it.isBlank()) { sums += 0 } else { sums[sums.lastIndex] += it.toInt() } } return sums } fun main() { fun part1(input: List<String>): Int { return ge...
0
Kotlin
0
0
4cd45703107377a05ee582ef7ed876c43b64f1ed
627
aoc2022
Apache License 2.0
src/aoc2021/Day11.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput fun main() { val (year, day) = "2021" to "Day11" fun navigate(input: List<String>, maxStep: Int = 0): Int { val energy = input.flatMap { line -> line.map { c -> c - '0' } }.toMutableList() var flashes = 0 var step = 0 while (true) { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
2,163
aoc-kotlin
Apache License 2.0
src/main/kotlin/g0701_0800/s0719_find_k_th_smallest_pair_distance/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0719_find_k_th_smallest_pair_distance // #Hard #Array #Sorting #Binary_Search #Two_Pointers // #2023_02_27_Time_172_ms_(100.00%)_Space_37.2_MB_(100.00%) class Solution { fun smallestDistancePair(nums: IntArray, k: Int): Int { nums.sort() val length = nums.size val maxDi...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
947
LeetCode-in-Kotlin
MIT License
day21/kotlin/RJPlog/day2121_1_2.kts
razziel89
433,724,464
true
{"Rust": 368326, "Python": 219109, "Go": 200337, "Kotlin": 80185, "Groovy": 67858, "JavaScript": 45619, "TypeScript": 43504, "CSS": 35030, "Shell": 18611, "C": 5260, "Ruby": 2359, "Dockerfile": 2285, "HTML": 227, "C++": 153}
import java.io.File // tag::standardDice[] fun standardDice(in1: Int, in2: Int): Int { var play1 = in1 var play2 = in2 var play1Score: Int = 0 var play2Score: Int = 0 var dice: Int = 1 var diceCount = 0 while (play1Score < 1000 && play2Score < 1000) { // three turns player 1 for (i in 0..2) { play1 = ((...
1
Rust
0
0
0042891cfcecdc2b65ee32882bd04de80ecd7e1c
4,170
aoc-2021
MIT License
src/commonMain/kotlin/io/schlawiner/game/Score.kt
schl4win3r
658,803,928
false
{"Kotlin": 74826}
package io.schlawiner.game import io.schlawiner.game.Score.Companion.EMPTY // use String instead of Term here, since the 'term' could also be "skipped" or "timeout" data class Score(val term: String, val difference: Int) { override fun toString(): String = "$term Δ $difference" companion object { va...
0
Kotlin
0
0
124cf417ef4247aa6080d47fbef016a988a098e0
3,294
schlawiner-engine-kotlin
Apache License 2.0
sort/src/main/kotlin/com/lillicoder/algorithms/sort/Quicksort.kt
lillicoder
754,271,079
false
{"Kotlin": 16213}
package com.lillicoder.algorithms.sort import com.lillicoder.algorithms.collections.swap /** * Implementation of [Quicksort](https://en.wikipedia.org/wiki/Quicksort). */ class Quicksort : Sort { override fun <T : Comparable<T>> sort(list: List<T>) = list.toMutableList().apply { sort(this) } /** * Sort...
0
Kotlin
0
0
8f96def65d07f646facaa3007cee6c8c99e71320
1,291
algorithms-kotlin
Apache License 2.0
src/Day06.kt
rafael-ribeiro1
572,657,838
false
{"Kotlin": 15675}
fun main() { fun part1(input: String): Int { return input.detectMarkerFinalPosition(4) } fun part2(input: String): Int { return input.detectMarkerFinalPosition(14) } // test if implementation meets criteria from the description, like: val testInput = readInput("Day06_test")[0] ...
0
Kotlin
0
0
5cae94a637567e8a1e911316e2adcc1b2a1ee4af
764
aoc-kotlin-2022
Apache License 2.0
src/2022/Day24.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import common.Linearizer import common.Offset import common.around import java.io.File import java.util.* fun main() { Day24().solve() } class Day24 { val maxTime = 10000 val input1 = """ #.##### #.....# #>....# #.....# #...v.# #.....# ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
10,973
advent-of-code
Apache License 2.0
src/main/kotlin/SparseMerkleTree.kt
avoloshko
122,376,429
false
null
import kotlin.math.pow class SparseMerkleTree(input: Map<Int, ByteArray>, val depth: Int = 256, val hash: (ByteArray) -> ByteArray = { data -> SHA256Digest.digest(data) }) { val root: ByteArray private val defaultNodes: Array<ByteArray> private val tree: Array...
1
Kotlin
4
11
ff8dd711bdb113c5932d54d682574886a568deb3
3,588
merkle-tree
MIT License
src/main/kotlin/com/ComplexCalculator/MeanValueCalculatorClassInterval.kt
tamalbag117
430,126,002
false
{"Kotlin": 36650}
package com.ComplexCalculator import java.util.* class MeanValueCalculatorClassInterval { fun meanValueCalculatorClassInterval() { val sc = Scanner(System.`in`) val obj = Summation() println( "\n\n\t\tMeasures of Central Tendency\t\n\nTopic:\tClass interval and Mean Value calcu...
0
Kotlin
0
1
82b987343250624cfdedec4d59d3a35d85393345
3,072
ArithmaticComplexCalculator
MIT License
grokking-algorithms/07 - Dijkstra’s/01_dijkstras.kt
arturschaefer
427,090,600
false
{"C": 48055, "Kotlin": 24446, "C++": 16696, "Dart": 3630, "QMake": 168}
import java.util.Deque import java.util.LinkedList import kotlin.collections.last import kotlin.math.cos private const val START = "start" private const val A = "A" private const val B = "B" private const val FIN = "FIN" private const val NONE = "none" fun main() { val graph = hashMapOf( START to hashMap...
0
C
0
0
04c34298739cab13b5cd755b4c6786fc1fe236cd
1,794
computer-science-studies
Apache License 2.0
kotlin/src/com/leetcode/17_LetterCombinationsOfAPhoneNumber.kt
programmerr47
248,502,040
false
null
package com.leetcode private class Solution17 { private val letterDict = arrayOf( arrayOf('a', 'b', 'c'), arrayOf('d', 'e', 'f'), arrayOf('g', 'h', 'i'), arrayOf('j', 'k', 'l'), arrayOf('m', 'n', 'o'), arrayOf('p', 'q', 'r', 's'), ...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,384
problemsolving
Apache License 2.0
ion-schema/src/main/kotlin/com/amazon/ionschema/model/ContinuousRange.kt
amazon-ion
148,685,964
false
{"Kotlin": 802107, "Inno Setup": 15625, "Java": 795, "Shell": 631}
package com.amazon.ionschema.model import com.amazon.ionschema.model.ContinuousRange.Limit interface IContinuousRange<T> where T : Comparable<T>, T : Any { val start: Limit<T> val end: Limit<T> operator fun contains(value: T): Boolean fun intersect(that: ContinuousRange<T>): Pair<Limit<T>, Limit<T>>? ...
38
Kotlin
14
26
bbab678c12fdd07bcb9b5d632fb7364a04541a73
4,897
ion-schema-kotlin
Apache License 2.0
aoc21/day_02/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File fun String.name() = this.split(" ")[0] fun String.x() = this.split(" ")[1].toInt() data class Pos(val horiz: Int, val depth: Int, val aim: Int) { fun nextFirst(cmd: String, x: Int) = when (cmd) { "forward" -> Pos(horiz + x, depth, aim) "down" -> Pos(horiz, depth + x, aim) ...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
967
advent-of-code
MIT License
kotlin/src/Day09.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.IllegalStateException import java.lang.Integer.parseInt fun main() { fun part1(input: List<String>): Int { val heightMap = input.map { line -> line.map(Char::toString).map(::parseInt) } return heightMap.flatMapIndexed { lineIndex, line -> line.filter...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
8,552
aoc-2021
MIT License
2019/04 - Secure Container/kotlin/src/app.kt
Adriel-M
225,250,242
false
null
import kotlin.math.pow data class DedupeDigitEntry(val digit: Int, var repeats: Int) open class NumberValidator(private val number: Int) { val encodedNumber = encodeNumber() private fun getPowValue(position: Int): Int { val base = 10.toDouble() val exponent = (5 - position).toDouble() ...
0
Kotlin
0
0
ceb1f27013835f13d99dd44b1cd8d073eade8d67
2,685
advent-of-code
MIT License
src/main/kotlin/problems/OutOfBoundary.kt
amartya-maveriq
510,824,460
false
{"Kotlin": 42296}
package problems /** * Leetcode : medium * https://leetcode.com/problems/out-of-boundary-paths/ * There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. * You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the * grid crossin...
0
Kotlin
0
0
2f12e7d7510516de9fbab866a59f7d00e603188b
1,647
data-structures
MIT License
src/main/kotlin/com/ichipsea/kotlin/matrix/NumberMatrix.kt
mouEsam
143,008,487
true
{"Kotlin": 19119}
package com.ichipsea.kotlin.matrix import kotlin.math.* operator fun <M : Number, N : Number> Matrix<M>.plus(other: Matrix<N>): Matrix<Double> { if (rows != other.rows || cols != other.cols) throw IllegalArgumentException("Matrices not match") return mapIndexed { x, y, value -> value.toDouble() + oth...
0
Kotlin
0
0
137b9e93dbd34821210484081730448d8709ec15
5,738
kotlin-matrix
Apache License 2.0
src/main/kotlin/be/tabs_spaces/advent2021/days/Day02.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import be.tabs_spaces.advent2021.days.Day02.Position.ReferenceFrame.ABSOLUTE import be.tabs_spaces.advent2021.days.Day02.Position.ReferenceFrame.AIMED class Day02 : Day(2) { override fun partOne(): Any { val submarine = Submarine.absolutelyPositioned() move...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
2,535
advent-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindNumOfLIS.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,105
kotlab
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[330]按要求补齐数组.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个已排序的正整数数组 nums,和一个正整数 n 。从 [1, n] 区间内选取任意个数字补充到 nums 中,使得 [1, n] 区间内的任何数字都 //可以用 nums 中某几个数字的和来表示。请输出满足上述要求的最少需要补充的数字个数。 // // 示例 1: // // 输入: nums = [1,3], n = 6 //输出: 1 //解释: //根据 nums 里现有的组合 [1], [3], [1,3],可以得出 1, 3, 4。 //现在如果我们将 2 添加到 nums 中, 组合变为: [1], [2], [3], [1,3], [2,3], [1,2,3]。 //其和可以表示数字 1, 2, 3,...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,064
MyLeetCode
Apache License 2.0
codeforces/kotlinheroes6/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes6 import kotlin.math.abs private fun solve() { val (n, xIn, yIn) = readInts() val (x, y) = listOf(xIn, yIn).sorted().map { it - 1 } val ans = List(n) { m -> maxOf(solve(0, m, x), solve(m, n, y)) }.minOrNull() println(ans) } private fun solve(from: Int, to: Int, x: Int): Int { i...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
698
competitions
The Unlicense
src/easy/Math/744-CountPrimes.kt
diov
170,882,024
false
null
import kotlin.math.sqrt fun main() { val n = 10 println(countPrimes2(n)) } // [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) fun countPrimes1(n: Int): Int { if (n < 3) return 0 val array = IntArray(n) { 1 } array[0] = 0 for (i in 2..sqrt(n.toFloat()).toInt()) { ...
0
Kotlin
0
0
668ef7d6d1296ab4df2654d5a913a0edabc72a3c
856
leetcode
MIT License
src/main/kotlin/days/Day5.kt
tcrawford-figure
435,911,433
false
{"Kotlin": 23558}
package days import kotlin.math.absoluteValue import kotlin.math.sign /** * https://adventofcode.com/2021/day/5 * Taken with advice from: https://todd.ginsberg.com/post/advent-of-code/2021/day5/ */ class Day5 : Day(5) { private data class Point(val x: Int, val y: Int) { infix fun sharesAxisWith(that: ...
0
Kotlin
0
0
87f689c4315e2f8eaca587b2f20fc245958efec8
1,684
aoc
Creative Commons Zero v1.0 Universal
kotlin/roman-numerals/src/main/kotlin/RomanNumeral.kt
ikr
147,076,927
false
{"C++": 22451113, "Kotlin": 136005, "CMake": 90716, "Java": 30028}
object RomanNumeral { fun value(x: Int): String { val result = StringBuilder() var remainder = x while (remainder > 0) { val next = firstNotExceeding(remainder) result.append(next.literal) remainder -= next.value } return result.toString(...
0
C++
0
0
37f505476ae13dd003c1de24b5113a0d7e94aaf2
1,431
exercism
MIT License
src/main/kotlin/days/Day18.kt
felix-ebert
317,592,241
false
null
package days class Day18 : Day(18) { // source: https://todd.ginsberg.com/post/advent-of-code/2020/day18/ // own try was based on substrings + recursion // keep this solution because of the simplicity and understandability override fun partOne(): Any { return inputList.map { it.replace(" ", ""...
0
Kotlin
0
4
dba66bc2aba639bdc34463ec4e3ad5d301266cb1
1,877
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/schlaubi/aoc/Utils.kt
DRSchlaubi
573,014,474
false
{"Kotlin": 21541}
package dev.schlaubi.aoc /** * Splits a list each time [delimiter] occurs. */ fun <T> List<T>.splitBy(delimiter: T): List<List<T>> = splitWhen { it == delimiter } /** * Splits a list of Strings each time a blank entry occurs. */ fun <T : CharSequence> List<T>.splitByBlank(): List<List<T>> = splitWhen(CharSequence...
1
Kotlin
0
4
4514e4ac86dd3ed480afa907d907e3ae26457bba
1,671
aoc-2022
MIT License
src/main/kotlin/day4/Day4.kt
tomaszobac
726,163,227
false
{"Kotlin": 15292}
package day4 import java.io.File fun part1(file: File): List<Int> { val pilePoints: MutableList<Int> = mutableListOf() val part2AmountOfNumbers: MutableList<Int> = mutableListOf() var index = 0 file.bufferedReader().useLines { readLines -> readLines.forEach { line -> val sets = (line.split(Re...
0
Kotlin
0
0
e0ce68fcf11e126c4680cff75ba959e46c5863aa
1,480
aoc2023
MIT License
src/Day11.kt
JohannaGudmandsen
573,090,573
false
{"Kotlin": 19316}
import java.io.File import kotlin.collections.* class Test(var divisibleBy:Int, var trueThrowsToMonkey:Int, var falseThrowsToMonkey:Int) class Operation(var type:String, var rightValue:String, var leftValue:String) class Monkey(var id:Int, var items:ArrayList<Long>, var op:Operation, var test:Test, var inspect:Long)...
0
Kotlin
0
1
21daaa4415bd20c14d67132e615971519211ab16
3,847
aoc-2022
Apache License 2.0
Algorithms/src/main/kotlin/PermutationInString.kt
ILIYANGERMANOV
557,496,216
false
{"Kotlin": 74485}
/** * # 567. Permutation in String * Problem: * https://leetcode.com/problems/permutation-in-string/ * * WARNING: This solution is not optimal! */ class PermutationInString { fun checkInclusion(target: String, source: String): Boolean { if (target.length > source.length) return false return pe...
0
Kotlin
0
1
4abe4b50b61c9d5fed252c40d361238de74e6f48
1,120
algorithms
MIT License
src/Day17.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import CHAMBER_UNIT.* fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day17_test") .single() .parseMovs() val part1TestResult = part1(testInput) println("Result on test input: $part1TestResult") check(part1TestResult == 30...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
8,140
aoc22-kotlin
Apache License 2.0
2021/kotlin/src/main/kotlin/aoc/days/day4/Day4Input.kt
tupini07
76,610,908
false
{"Haskell": 35857, "Elixir": 22701, "Clojure": 20266, "Kotlin": 12288, "F#": 4426, "HTML": 4256, "CSS": 4163, "Dockerfile": 1374, "Shell": 963, "C#": 489, "TypeScript": 320, "Emacs Lisp": 299, "Makefile": 182}
package aoc.days.day4 import aoc.entities.Vector2d import kotlin.math.pow class Day4Input(val orderOfDraws: List<Int>, val boards: MutableList<BingoBoard>) class BingoBoard(boardRep: String) { private val boardNumbers: List<Int> private val numbersSet: MutableList<Boolean> private val boardSize: Int ...
0
Haskell
0
0
4aee7ef03880e3cec9467347dc817b1db8a5fc0f
2,735
advent-of-code
MIT License
src/main/kotlin/day03/part1/main.kt
TheMrMilchmann
225,375,010
false
null
/* * Copyright (c) 2019 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
9d6e2adbb25a057bffc993dfaedabefcdd52e168
2,593
AdventOfCode2019
MIT License
pulsar-skeleton/src/test/kotlin/ai/platon/pulsar/crawl/common/TestSuffixStringMatcher.kt
platonai
124,882,400
false
null
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may...
1
HTML
32
110
f93bccf5075009dc7766442d3a23b5268c721f54
3,828
pulsar
GNU Affero General Public License v3.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[19]删除链表的倒数第 N 个结点.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。 // // 进阶:你能尝试使用一趟扫描实现吗? // // // // 示例 1: // // //输入:head = [1,2,3,4,5], n = 2 //输出:[1,2,3,5] // // // 示例 2: // // //输入:head = [1], n = 1 //输出:[] // // // 示例 3: // // //输入:head = [1,2], n = 1 //输出:[1] // // // // // 提示: // // // 链表中结点的数目为 sz // 1 <= sz <= 30 // 0 <= ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,604
MyLeetCode
Apache License 2.0
test/com/zypus/SLIP/algorithms/genetic/UnitTest.kt
zypus
213,665,750
false
null
package com.zypus.SLIP.algorithms.genetic import com.zypus.Maze.algorithms.RnnMazeEvolution import com.zypus.Maze.controller.ARobotController import com.zypus.Maze.models.Maze import com.zypus.utilities.squared import org.junit.Assert import org.junit.Test import org.knowm.xchart.Histogram import java.util.* /** * T...
0
Kotlin
0
0
418ee8837752143194fd769e86fac85e15136929
4,220
SLIP
MIT License
src/main/kotlin/algorithms/LongestSubsequence.kt
jimandreas
377,843,697
false
null
@file:Suppress( "SameParameterValue", "UnnecessaryVariable", "UNUSED_VARIABLE", "ControlFlowWithEmptyBody", "unused", "MemberVisibilityCanBePrivate" ) package algorithms import org.jetbrains.kotlinx.multik.api.d1array import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.ndarray.data....
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
3,691
stepikBioinformaticsCourse
Apache License 2.0
2017/src/main/kotlin/Day12.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import utils.splitCommas import utils.splitNewlines import utils.toIntList import java.util.regex.Pattern object Day12 { fun part1(input: String): Int { val map = parse(input) return visit(map, 0).numConnected } fun part2(input: String): Int { val map = parse(input) val allIds = map.keys.toMuta...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,644
advent-of-code
MIT License
src/main/kotlin/com/github/davio/aoc/y2021/Day7.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2021 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.getInputAsList import kotlin.math.abs import kotlin.math.pow import kotlin.math.roundToInt import kotlin.system.measureTimeMillis fun main() { Day7.getResultPart1() measureTimeMillis { Day7.g...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
5,081
advent-of-code
MIT License
src/main/kotlin/com/colinodell/advent2016/Day02.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day02(private val instructions: List<String>) { fun solvePart1(): String = getCode(instructions, partA) fun solvePart2(): String = getCode(instructions, partB) private val movements = mapOf( 'U' to Vector2(0, -1), 'D' to Vector2(0, 1), 'L' to...
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
1,634
advent-2016
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day08/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day08 import com.resurtm.aoc2023.utils.findListLCM fun launchDay08(testCase: String) { val input = readInput(testCase) println("Day 08, part 1: ${calculate(input)}") println("Day 08, part 2: ${calculateV2(input)}") } private fun calculateV2(inp: Input): Long = findListLCM(...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
1,748
advent-of-code-2023
MIT License
day20/Part1.kt
anthaas
317,622,929
false
null
import java.io.File fun main(args: Array<String>) { val tiles = File("input.txt").bufferedReader().use { it.readText() }.split("\n\n") .map { it.split("\n").let { it[0].replace(":", "").split(" ")[1].toLong() to it.subList(1, it.size) } } val result = tiles.map { tile1 -> var count = 0 ...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
950
Advent-of-Code-2020
MIT License