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
RansomNote.kt
ncschroeder
604,822,497
false
{"Kotlin": 19399}
/* https://leetcode.com/problems/ransom-note/ Given two strings `ransomNote` and `magazine`, return `true` if `ransomNote` can be constructed by using the letters from `magazine` and `false` otherwise. Each letter in `magazine` can only be used once in `ransomNote`. */ // Original solution with eager searching of th...
0
Kotlin
0
0
c77d0c8bb0595e61960193fc9b0c7a31952e8e48
2,085
Coding-Challenges
MIT License
src/main/kotlin/com/github/vqvu/eulerproject/Problem49.kt
vqvu
57,861,531
false
null
package com.github.vqvu.eulerproject import java.util.ArrayList import java.util.Arrays import java.util.HashMap import java.util.SortedSet import java.util.TreeSet /** * @author victor */ fun main(args: Array<String>) { val primePermutations: MutableMap<String, SortedSet<Int>> = HashMap() for (prime in com...
0
Kotlin
0
0
1163894f462045060eda763b3040c0bbb1a68e30
1,455
euler-project
MIT License
src/Day02.kt
StrixG
572,554,618
false
{"Kotlin": 2622}
fun main() { fun part1(input: List<String>): Int { var score = 0 for (line in input) { val (enemyMove, move) = line.let { it[0] - 'A' to it[2] - 'X' } val outcome = ((move - enemyMove).mod(3) + 1) % 3 score += move + 1 + outcome * 3 } return sco...
0
Kotlin
0
0
85f2f28197ad54d8c4344470f0ba80307b068680
885
advent-of-code-2022
Apache License 2.0
src/main/java/challenges/cracking_coding_interview/trees_graphs/first_common_ancestor/QuestionD.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.first_common_ancestor import challenges.util.TreeNode /** * Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. * Avoid storing additional nodes in a data structure. * NOTE: This is not necessarily a binary se...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
1,667
CodingChallenges
Apache License 2.0
src/Day03.kt
xNakero
572,621,673
false
{"Kotlin": 23869}
class Day03 { fun part1() = readInput("day03") .map { it.chunked(it.length / 2) } .map { rucksack -> rucksack.map { it.chunked(1) } } .flatMap { it[0].intersect(it[1].toSet()) } .map { it.toCharArray()[0] } .sumOf { priority(it) } fun part2() = readInput("day03") ...
0
Kotlin
0
0
c3eff4f4c52ded907f2af6352dd7b3532a2da8c5
772
advent-of-code-2022
Apache License 2.0
2023/11/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min private const val FILENAME = "2023/11/input.txt" fun main() { partOne() partTwo() } private fun partOne() { calculate(2) } private fun partTwo() { calculate(1_000_000) } private fun calculate(expandAmount: Int)...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
2,111
Advent-of-Code
MIT License
src/main/MyMath.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
import java.math.BigInteger object MyMath { // Based on // https://en.wikipedia.org/wiki/Modular_multiplicative_inverse#Applications // https://sv.wikipedia.org/wiki/Kinesiska_restklassatsen // https://rosettacode.org/wiki/Chinese_remainder_theorem // Use BigInteger to be able to calculate big numb...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,754
aoc
MIT License
src/main/kotlin/day2/Day2.kt
Wicked7000
573,552,409
false
{"Kotlin": 106288}
package day2 import Day import checkWithMessage import parserCombinators.* import readInput import readInputString import runTimedPart import kotlin.sequences.sequenceOf @Suppress("unused") class Day2(): Day() { private val winningMatchUps = mapOf( Action.SCISSORS to Action.ROCK, Action.PAPER to A...
0
Kotlin
0
0
7919a8ad105f3b9b3a9fed048915b662d3cf482d
6,184
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day08.kt
TheMrMilchmann
725,205,189
false
{"Kotlin": 61669}
/* * Copyright (c) 2023 <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
f94ff8a4c9fefb71e3ea183dbc3a1d41e6503152
2,746
AdventOfCode2023
MIT License
codeforces/round631/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round631 private fun solve(): String { val (h, g) = readInts() val a = (listOf(0) + readInts()).toIntArray() val bottomLevel = 1 shl (h - 1) tailrec fun siftDown(i: Int, act: Boolean): Int { val j = if (i >= bottomLevel) 0 else if (a[2 * i] >= a[2 * i + 1]) 2 * i else 2 * i + 1 if (act) a[i]...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
866
competitions
The Unlicense
2020/kotlin/day-4/main.kt
waikontse
330,900,073
false
null
import util.FileUtils val fileUtils = FileUtils("input.txt") fun main() { val allPassports: List<String> = combineLines(fileUtils.lines) println ("number of passport lines: " + allPassports.size) val validPassportCount = allPassports.map(::splitPassportFields) .filter(::isValidPassport) ...
0
Kotlin
0
0
abeb945e74536763a6c72cebb2b27f1d3a0e0ab5
4,082
advent-of-code
Creative Commons Zero v1.0 Universal
src/Day01/Day01.kt
SelenaChen123
573,253,480
false
{"Kotlin": 14884}
import java.io.File fun main() { fun part1(input: List<String>): Int { var globalMax = 0 var localMax = 0 for (line in input) { if (line != "") { localMax = localMax + line.toInt() } else { if (localMax.compareTo(globalMax) > 0) { ...
0
Kotlin
0
0
551af4f0efe11744f918d1ff5bb2259e34c5ecd3
1,344
AdventOfCode2022
Apache License 2.0
src/main/kotlin/g2101_2200/s2162_minimum_cost_to_set_cooking_time/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2162_minimum_cost_to_set_cooking_time // #Medium #Math #Enumeration #2023_06_26_Time_134_ms_(100.00%)_Space_32.8_MB_(100.00%) class Solution { fun minCostSetTime(startAt: Int, moveCost: Int, pushCost: Int, targetSeconds: Int): Int { val mins = targetSeconds / 60 val secs = targ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,068
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g0601_0700/s0654_maximum_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0654_maximum_binary_tree // #Medium #Array #Tree #Binary_Tree #Stack #Monotonic_Stack #Divide_and_Conquer // #2023_02_13_Time_271_ms_(90.00%)_Space_37.8_MB_(95.00%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree node....
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,129
LeetCode-in-Kotlin
MIT License
src/Day01.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
import java.lang.Integer.max fun main() { fun part1(input: List<String>): Int { var max = 0 input.map { it.toIntOrNull() ?: 0 }.reduce { acc, i -> if (i == 0) { max = max(max, acc) 0 } else { acc + i ...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
886
AdventCode2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day20.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day20.run() object Day20 : Day(2022, 20) { override fun part1() = solve(1, 1) override fun part2() = solve(811589153, 10) private fun solve(key: Long, times: Int): Long { // Changes 1, 2, 3 to (0, 1), (1, 2), (2, 3) to ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,140
adventofkotlin
MIT License
kotlin/368.Largest Divisible Subset(最大整除子集).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 a set of <b>distinct</b> positive integers, find the largest subset such that every pair (S<sub>i</sub>, S<sub>j</sub>) of elements in this subset satisfies: S<sub>i</sub> % S<sub>j</sub> = 0 or S<sub>j</sub> % S<sub>i</sub> = 0. </p> <p>If there are multiple solutions, return any subset is fine. </p> <...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
2,149
leetcode
MIT License
src/main/kotlin/nl/jackploeg/aoc/_2022/calendar/day21/Day21.kt
jackploeg
736,755,380
false
{"Kotlin": 318734}
package nl.jackploeg.aoc._2022.calendar.day21 import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory import nl.jackploeg.aoc.utilities.readStringFile import javax.inject.Inject import kotlin.math.abs class Day21 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { // ...
0
Kotlin
0
0
f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76
6,043
advent-of-code
MIT License
src/main/kotlin/g1401_1500/s1439_find_the_kth_smallest_sum_of_a_matrix_with_sorted_rows/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1439_find_the_kth_smallest_sum_of_a_matrix_with_sorted_rows // #Hard #Array #Binary_Search #Matrix #Heap_Priority_Queue // #2023_06_07_Time_225_ms_(100.00%)_Space_38.5_MB_(100.00%) import java.util.Objects import java.util.TreeSet @Suppress("kotlin:S6510") class Solution { fun kthSmallest(mat...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,696
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g2501_2600/s2532_time_to_cross_a_bridge/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2532_time_to_cross_a_bridge // #Hard #Array #Heap_Priority_Queue #Simulation // #2023_07_04_Time_420_ms_(100.00%)_Space_47.1_MB_(50.00%) import java.util.PriorityQueue @Suppress("NAME_SHADOWING") class Solution { fun findCrossingTime(n: Int, k: Int, time: Array<IntArray>): Int { // cr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,432
LeetCode-in-Kotlin
MIT License
17.kts
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
import java.util.* val grid = System.`in`.bufferedReader().lines().map { it.map { (it - '0') }.toList() }.toList() val up = Pair(0, -1); val right = Pair(1, 0); val down = Pair(0, 1); val left = Pair(-1, 0) data class Crucible(val pos: Pair<Int, Int>, val dir: Pair<Int, Int>, val loss: Int, val straights: Int) var res...
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
2,531
aoc2023
MIT License
sincmathsmp/src/commonMain/kotlin/io/github/gallvp/sincmaths/SincMatrixMaths.kt
GallVp
353,046,891
false
{"Kotlin": 187027, "C": 2472, "Makefile": 2334, "C++": 2258, "Ruby": 2181, "CMake": 1385, "Shell": 730}
package io.github.gallvp.sincmaths import kotlin.math.pow expect operator fun SincMatrix.times(rhs: SincMatrix): SincMatrix expect operator fun SincMatrix.times(rhs: Double): SincMatrix expect operator fun SincMatrix.plus(rhs: SincMatrix): SincMatrix expect operator fun SincMatrix.plus(rhs: Double): SincMatrix ex...
1
Kotlin
0
0
061bed61c37bedc6aedc2312e179d0e507683011
2,468
sincmaths
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountingElements.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,482
kotlab
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions5.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 fun test5() { val charArray0 = charArrayOf('W', 'e', ' ', 'a', 'r', 'e', ' ', 'h', 'a', 'p', 'p', 'y', '.', ' ', ' ', ' ', ' ') charArray0.replaceChar(' ', "%20", 13) println("Input: \"We are happy\", replace the ' ' with \"%20\"") charArray0.forEach { pri...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,798
Algorithm
Apache License 2.0
src/Day01.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var currentCalories = 0 var maxCalories = 0 input.forEach { if (it.isBlank()) { maxCalories = max(maxCalories, currentCalories) currentCalories = 0 } else { ...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
996
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/sorting/QuickSort.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.sorting println("test") val array1 = intArrayOf(3, 2, 1) val array2 = intArrayOf(2000, 234, 21, 41, 1, 21, 75, 0, -4) QuickSort().sort(array1) QuickSort().sort(array2) // runtime: O(N log N) best + average, O(N^2) worst case // space: O(log N) best + average, O(N) worst case // unstable pr...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
1,881
KotlinAlgs
MIT License
src/main/kotlin/days/Day6.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day6 : Day(6) { private val times = inputList.first().split(' ').filter { it.matches(Regex("\\d+")) } private val distances = inputList.last().split(' ').filter { it.matches(Regex("\\d+")) } override fun partOne(): Any { val races = times.zip(distances).map { (time, distance) -...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
1,025
aoc-2023
Creative Commons Zero v1.0 Universal
aoc16/day_10/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 data class Rule(val bot_low: Int?, val out_low: Int?, val bot_high: Int?, val out_high: Int?) fun main() { val instructions = File("input").readLines() val bots = mutableMapOf<Int, MutableList<Int>>() val rules = mutableMapOf<Int, Rule>() val outputs = mutableMapOf<Int, Int>() ...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,996
advent-of-code
MIT License
src/test/kotlin/be/brammeerten/y2022/Day5Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2022 import be.brammeerten.readFile import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import java.util.* class Day5Test { @Test fun `part 1`() { val input = readFile("2022/day5/exampleInput.txt") val stacks = readStacks(input) ...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
2,335
Advent-of-Code
MIT License
src/day12/Day12.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day12 import helpers.ReadFile class Block { var minDistanceFromOrigin = Int.MAX_VALUE var pathOfMinDistance: List<Pair<Int, Int>> = listOf() val isEnd: Boolean val isStart: Boolean val height: Int var position: Pair<Int, Int> = Pair(0, 0) var validEdges: List<Pair<Int, Int>> = list...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
4,132
adventofcode2022
MIT License
src/day21/Code.kt
fcolasuonno
221,697,249
false
null
package day21 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2(parsed)}") } sea...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
4,797
AOC2016
MIT License
src/main/kotlin/de/huddeldaddel/euler/Problem039.kt
huddeldaddel
171,357,298
false
null
package de.huddeldaddel.euler /** * Solution for https://projecteuler.net/problem=39 */ fun main() { var maxCombinations = 0 var result = 0 for(p in 3..1000) { val combinations = mutableSetOf<String>() for(a in 1..p) { for(b in 1..p) { val c = calculateC(a, b) ...
0
Kotlin
1
0
df514adde8c62481d59e78a44060dc80703b8f9f
1,121
euler
MIT License
aoc2022/day2.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval fun main() { Day2.execute() } object Day2 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } /** * Rock Paper Scissors (Part 1) * Opponent Move: * A - Ro...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
1,416
Advent-Of-Code
MIT License
year2021/day04/part2/src/main/kotlin/com/curtislb/adventofcode/year2021/day04/part2/Year2021Day04Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- On the other hand, it might be wise to try a different strategy: let the giant squid win. You aren't sure how many bingo boards a giant squid could play at once, so rather than waste time counting its arms, the safe thing to do is to figure out which board will win last and choose that one. That w...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,242
AdventOfCode
MIT License
src/main/kotlin/g0501_0600/s0516_longest_palindromic_subsequence/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0516_longest_palindromic_subsequence // #Medium #String #Dynamic_Programming #Dynamic_Programming_I_Day_17 // #2023_01_12_Time_243_ms_(87.50%)_Space_45.8_MB_(66.67%) class Solution { fun longestPalindromeSubseq(s: String): Int { if (s.isEmpty()) { return 0 } ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
888
LeetCode-in-Kotlin
MIT License
src/main/kotlin/behavioural_patterns/interpreter/Interpreter.kt
ThijsBoehme
291,005,516
false
{"Kotlin": 88248, "Java": 31062}
package behavioural_patterns.interpreter import java.util.stream.Collectors interface Element { fun eval(): Int } class Integer(private val value: Int): Element { override fun eval(): Int { return value } } class BinaryOperation: Element { lateinit var type: Type lateinit var left: Eleme...
0
Kotlin
0
0
9bdb5be77dcd527493b39ad562291a4023e36a98
3,530
portfolio-design-patterns-udemy
MIT License
kork-plugins/src/main/kotlin/com/netflix/spinnaker/kork/plugins/VersionRequirementsParser.kt
clareliguori
196,099,646
true
{"Java": 871051, "Kotlin": 337241, "Groovy": 121638, "Shell": 2440, "JavaScript": 595, "HTML": 394}
/* * Copyright 2020 Netflix, Inc. * * 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 ...
0
Java
1
2
a2d0804caa518f9a13f750f4a49eda8ea3d349cf
3,467
kork
Apache License 2.0
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_125_Valid_Palindrome.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:__ A phrase is a p...
0
Kotlin
0
1
c5a7e389c943c85a90594315ff99e4aef87bff65
3,059
LeetcodeSolutions
Apache License 2.0
src/chapter2/section5/ex31_Distinct.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter2.section5 import extensions.formatDouble import extensions.formatInt import extensions.random import kotlin.math.pow /** * 不重复元素 * 编写一段程序,接受命令行参数M、N和T,然后使用正文中的代码进行T遍实验: * 生成N个0到M-1间的int值并计算不重复值的个数。 * 令T=10,N=10³、10⁴、10⁵和10⁶以及M=N/2、N和2N * 根据概率论,不重复值的个数应该约为M*(1-e^(-a)),其中a=N/M * 打印一张表格来确认你的实验验证了这个...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,568
Algorithms-4th-Edition-in-Kotlin
MIT License
src/commonMain/kotlin/io/github/alexandrepiveteau/graphs/algorithms/RandomWalk.kt
alexandrepiveteau
630,931,403
false
{"Kotlin": 132267}
package io.github.alexandrepiveteau.graphs.algorithms import io.github.alexandrepiveteau.graphs.Successors import io.github.alexandrepiveteau.graphs.SuccessorsWeight import io.github.alexandrepiveteau.graphs.Vertex import io.github.alexandrepiveteau.graphs.internal.collections.IntVector import kotlin.contracts.contrac...
9
Kotlin
0
6
a4fd159f094aed5b6b8920d0ceaa6a9c5fc7679f
2,851
kotlin-graphs
MIT License
archive/101/solve.kt
daniellionel01
435,306,139
false
null
/* === #101 Optimum polynomial - Project Euler === If we are presented with the first k terms of a sequence it is impossible to say with certainty the value of the next term, as there are infinitely many polynomial functions that can model the sequence. As an example, let us consider the sequence of cube numbers. This...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
1,878
euler
MIT License
src/main/kotlin/leetcode/Problem2266.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/count-number-of-texts/ */ class Problem2266 { fun countTexts(pressedKeys: String): Int { if (pressedKeys.length == 1) { return 1 } var answer = 1L var i = 0 var length = 1 val memo3 = IntArray(pressed...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,712
leetcode
MIT License
src/main/kotlin/org/jetbrains/bio/span/semisupervised/Errors.kt
JetBrains-Research
159,559,994
false
{"Kotlin": 330801}
package org.jetbrains.bio.span.semisupervised import java.util.* /** * Simple counter of correct out of all */ data class ErrorRate(var total: Int = 0, var correct: Int = 0) { fun observe(outcome: Boolean) { total++; if (outcome) correct++ } fun combine(other: ErrorRate) { total += ot...
2
Kotlin
1
7
fe581a3821d7bd28bafa5b8240f7a961a4c1f291
1,463
span
MIT License
src/main/kotlin/ch/heigvd/stats/ranking/KendallTau.kt
rbarazzutti
132,765,154
false
null
package ch.heigvd.stats.ranking import kotlin.coroutines.experimental.buildSequence import kotlin.math.sqrt /** * Rough implementation of Kendall-Tau correlation coefficient computation. * * This implementation: * * - is slow (O(n²)), thanks to efficient sorts a smarter implementation should be O(n·log(n)) * - ...
0
Kotlin
0
0
e1945b7eb928fd204d37ae0e20926855d0197ff5
3,533
kotlin-tau
MIT License
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day02.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput class Day02 : Day<Int> { private val input: Sequence<PasswordEntry> = readDayInput() .lineSequence() .parse() data class Policy(val first: Int, val second: Int, ...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
1,771
adventofcode
Apache License 2.0
BellmanFord/bellmanford.kt
ReciHub
150,083,876
false
{"C++": 2125921, "Java": 329701, "Python": 261837, "C#": 119510, "C": 86966, "JavaScript": 69795, "Jupyter Notebook": 48962, "HTML": 35203, "Kotlin": 20787, "Go": 15812, "CSS": 12510, "TeX": 12253, "TypeScript": 10773, "PHP": 8809, "Swift": 7787, "Scala": 6724, "Rust": 6297, "Shell": 5562, "Ruby": 5488, "Haskell": 4927...
class Edge(val source: Int, val destination: Int, val weight: Int) class Graph(val vertices: Int, val edges: List<Edge>) { fun bellmanFord(startVertex: Int) { val distance = IntArray(vertices) { Int.MAX_VALUE } distance[startVertex] = 0 for (i in 1 until vertices) { for (edge i...
121
C++
750
361
24518dd47bd998548e3e840c27968598396d30ee
1,365
FunnyAlgorithms
Creative Commons Zero v1.0 Universal
src/main/kotlin/nl/kelpin/fleur/advent2018/Day24.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 class Day24(immune: List<String>, infection: List<String>) { companion object { const val INFECTION = "infection" const val IMMUNE = "immune" const val WEAK = "weak" val highestInitiative = compareByDescending(Group::initiative) val mostEff...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
5,629
advent-2018
MIT License
src/commonMain/kotlin/org/jetbrains/packagesearch/packageversionutils/normalization/VersionComparatorUtil.kt
JetBrains
498,634,573
false
{"Kotlin": 44145}
package org.jetbrains.packagesearch.packageversionutils.normalization import kotlin.math.sign object VersionComparatorUtil { private val WORDS_SPLITTER = Regex("\\d+|\\D+") private val ZERO_PATTERN = Regex("0+") private val DIGITS_PATTERN = Regex("\\d+") private val DEFAULT_TOKEN_PRIORITY_PROVIDER: (S...
0
Kotlin
2
4
4a9cf732526a0cd177dbaadb786bd2e41903a33e
3,032
package-search-version-utils
Apache License 2.0
src/test/kotlin/year2015/Day14.kt
abelkov
47,995,527
false
{"Kotlin": 48425}
package year2015 import kotlin.math.max import kotlin.test.* class Day14 { @Test fun part1() { // Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds. val regex = """(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds.""".toRegex() var m...
0
Kotlin
0
0
0e4b827a742322f42c2015ae49ebc976e2ef0aa8
3,311
advent-of-code
MIT License
year2021/src/main/kotlin/net/olegg/aoc/year2021/day25/Day25.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day25 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 25](https://adventofcode.com/2021/day/25) */ object Day25 : DayOf2021(25) { override fun first(): Any? { val map = matrix val hei...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,399
adventofcode
MIT License
src/main/kotlin/g1001_1100/s1022_sum_of_root_to_leaf_binary_numbers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1022_sum_of_root_to_leaf_binary_numbers // #Easy #Depth_First_Search #Tree #Binary_Tree // #2023_05_22_Time_158_ms_(88.89%)_Space_36.3_MB_(11.11%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree node. * class TreeNode...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,280
LeetCode-in-Kotlin
MIT License
chapter_1_arrays_and_strings/1_is_unique/solution.kt
codermrhasan
230,264,289
false
{"Kotlin": 6182, "Python": 6043}
/* PROBLEM Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures? */ /* ALGORITHM 1 - areCharsUnique Keep and array of 256 elements, corresponding to each ASCII character, initially set to false. For each letter in the original string ...
0
Kotlin
0
0
3f40e94f388fc817ffe092772c8a541c3d356c46
2,128
ctci-problems-and-solutions
MIT License
lib_algorithms_sort_kotlin/src/main/java/net/chris/lib/algorithms/sort/kotlin/KTCountingSorter.kt
chrisfang6
105,401,243
false
{"Java": 68669, "Kotlin": 26275, "C++": 12503, "CMake": 2182, "C": 1403}
package net.chris.lib.algorithms.sort.kotlin /** * Counting sort. * */ abstract class KTCountingSorter : KTSorter() { /*override fun sort(list: List<Int>?): List<Int>? { return if (list == null) { list } else toList(sort(toArray(list), false)) }*/ override fun subSort(A: In...
0
Java
0
0
1f1c2206d5d9f0a3d6c070a7f6112f60c2714ec0
1,101
sort
Apache License 2.0
src/main/kotlin/g0001_0100/s0010_regular_expression_matching/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0010_regular_expression_matching // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming #Recursion // #Udemy_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n) // #2023_07_03_Time_171_ms_(85.26%)_Space_34.6_MB_(94.74%) class Solution { fun isMatch(s: String, p...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,278
LeetCode-in-Kotlin
MIT License
src/chapter4/section4/CPM.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter4.section4 import edu.princeton.cs.algs4.In import edu.princeton.cs.algs4.Queue import extensions.formatDouble import extensions.formatInt /** * 优先级限制下的并行任务调度问题的关键路径方法 */ class CPM(private val N: Int) { private val V = N * 2 + 2 private val s = 2 * N // 起点 private val t = 2 * N + 1 // 终点 ...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,807
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/dev/claudio/adventofcode2021/Day4.kt
ClaudioConsolmagno
434,559,159
false
{"Kotlin": 78336}
package dev.claudio.adventofcode2021 fun main() { Day4().main() } private class Day4 { fun main() { val inputList: List<String> = Support.readFileAsListString("day4-input.txt").filter { it != "" } val marks: List<Int> = inputList[0].split(",").map { Integer.valueOf(it) } var start = 1 ...
0
Kotlin
0
0
5f1aff1887ad0a7e5a3af9aca7793f1c719e7f1c
1,815
adventofcode-2021
Apache License 2.0
src/main/kotlin/io/github/kmakma/adventofcode/y2020/Y2020Day20.kt
kmakma
225,714,388
false
null
package io.github.kmakma.adventofcode.y2020 import io.github.kmakma.adventofcode.utils.Day import io.github.kmakma.adventofcode.utils.product fun main() { Y2020Day20().solveAndPrint() } class Y2020Day20 : Day(2020, 20, "Jurassic Jigsaw") { private val monster = listOf( " # ".toCharAr...
0
Kotlin
0
0
7e6241173959b9d838fa00f81fdeb39fdb3ef6fe
9,402
adventofcode-kotlin
MIT License
src/Day11.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
import javax.naming.OperationNotSupportedException data class MonkeyDefinition( val items: List<Int>, val operation: Char, val operationArg: Int?, val divider: Int, val trueTarget: Int, val falseTarget: Int ) interface Monkeys<T> { fun catch(target: Int, item: T) } interface SeriousMonkey...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
5,631
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day01.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
fun main() { fun parseInput(input: String) = input.split("\n\n") .map { elf -> elf.lines().map { it.toInt() } } fun part1(input: String): Int { return parseInput(input) .maxOf { it.sum() } } fun part2(input: String): Int { return parseInput(input) .map {...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
692
advent-of-code-Kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ValidAnagram.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
2,114
kotlab
Apache License 2.0
src/main/kotlin/dev/patbeagan/days/Day07.kt
patbeagan1
576,401,502
false
{"Kotlin": 57404}
package dev.patbeagan.days import java.util.* /** * [Day 7](https://adventofcode.com/2022/day/7) */ class Day07 : AdventDay<Int> { override fun part1(input: String): Int { val dir = parseInput(input) val listOfDirsOfSmallSize = mutableListOf<Dir>() dir.walk { if (it is Dir &&...
0
Kotlin
0
0
4e25b38226bcd0dbd9c2ea18553c876bf2ec1722
6,428
AOC-2022-in-Kotlin
Apache License 2.0
src/Day10.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
import java.lang.StringBuilder import java.util.concurrent.atomic.AtomicInteger fun main() { fun part1(input: List<String>): Int = AtomicInteger().apply { run(input) { cycle, x -> if ((cycle - 20) % 40 == 0) this += (cycle * x) } }.get() fun part2(input: List<St...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
1,629
advent-of-code-2022
Apache License 2.0
src/Day02.kt
samframpton
572,917,565
false
{"Kotlin": 6980}
fun main() { fun part1(input: List<String>) = input.map { when (it) { "A X" -> 4 "A Y" -> 8 "A Z" -> 3 "B X" -> 1 "B Y" -> 5 "B Z" -> 9 "C X" -> 7 "C Y" -> 2 ...
0
Kotlin
0
0
e7f5220b6bd6f3c5a54396fa95f199ff3a8a24be
864
advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/day09/Day9.kt
Dr-Horv
112,381,975
false
null
package solutions.day09 import solutions.Solver data class Node(val parent: Node?, val children: MutableList<Node>) { fun addChild(child: Node) { children.add(child) } } class Day9: Solver { override fun solve(input: List<String>, partTwo: Boolean): String { val first = input.first() ...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
1,953
Advent-of-Code-2017
MIT License
src/main/kotlin/year_2022/Day14.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2022 import utils.readInput fun main() { fun printGrid(grid: Array<Array<String>>) { val row = grid.size val col = grid[0].size for (i in 0..row) { for (j in 0..col) print(grid[i][j]) println() } } fun part1(input: Lis...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
1,452
advent-of-code
Apache License 2.0
src/Day01.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.lang.Long.max // Day 01, Advent of Code 2022, Calorie Counting fun main() { fun part1(input: List<String>): Long { var max = -1L var count = 0L input.forEach { if (it.isEmpty()) { max = max(count ,max) count = 0 } else { ...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
1,060
AdventOfCode2022
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day2/day2.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day2 import java.lang.RuntimeException fun Boolean.toInt() = if (this) 1 else 0 data class Policy(val policy: String) { companion object { val regex = "(?<first>\\d+)-(?<second>\\d+) (?<char>.): (?<pass>[a-z]+)".toRegex() } private val groups = regex.matchEntire(policy)?...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
1,628
advent-of-code-2020
Do What The F*ck You Want To Public License
src/Day08.kt
rickbijkerk
572,911,701
false
{"Kotlin": 31571}
fun main() { data class Tree(val value: Int, var visible: Boolean? = null) { // val sightLeft: Int = 0 // val sightRight: Int = 0 // val sightTop: Int = 0 // val sightBottom: Int = 0 // // fun scenicScore(): Int { // return sightLeft * sightRight * sightT...
0
Kotlin
0
0
817a6348486c8865dbe2f1acf5e87e9403ef42fe
7,571
aoc-2022
Apache License 2.0
src/day02.kts
miedzinski
434,902,353
false
{"Kotlin": 22560, "Shell": 113}
enum class Command { FORWARD, DOWN, UP } val input = generateSequence(::readLine).map { val split = it.split(" ") val command = when (split.first()) { "forward" -> Command.FORWARD "down" -> Command.DOWN "up" -> Command.UP else -> throw IllegalArgumentException() } val un...
0
Kotlin
0
0
6f32adaba058460f1a9bb6a866ff424912aece2e
1,138
aoc2021
The Unlicense
src/main/kotlin/com/sherepenko/leetcode/challenges/ThirtyDayChallenge.kt
asherepenko
264,648,984
false
null
package com.sherepenko.leetcode.challenges import com.sherepenko.leetcode.Solution import com.sherepenko.leetcode.data.ListNode import com.sherepenko.leetcode.data.TreeNode import com.sherepenko.leetcode.solutions.BackspaceCompare import com.sherepenko.leetcode.solutions.BinaryTreeDiameter import com.sherepenko.leetco...
0
Kotlin
0
0
49e676f13bf58f16ba093f73a52d49f2d6d5ee1c
7,556
leetcode
The Unlicense
src/main/kotlin/com/ginsberg/advent2023/Day01.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 1 - Trebuchet?! * Problem Description: http://adventofcode.com/2023/day/1 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day1/ */ package com.ginsberg.advent2023 class Day01(private val input: List<String>) { pr...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
1,829
advent-2023-kotlin
Apache License 2.0
src/main/kotlin/week4/HotAirBalloons.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package week4 import shared.Puzzle import shared.ReadUtils.Companion.debug import kotlin.math.pow class HotAirBalloons : Puzzle(25) { infix fun Int.pow(exponent: Int): Long = toDouble().pow(exponent).toLong() override fun solveFirstPart(): Any { return puzzleInput.map { toDecimal(it) } .s...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
2,476
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
src/day6/day6.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
import java.io.File fun readFishMap(): MutableMap<Int, Long> { val fishes = File("day6.txt") .readLines()[0] .split(",") .map { it.toInt() } val map = mutableMapOf<Int, Long>() fishes.forEach { fish -> val count = map.getOrDefault(fish, 0) map[fish] = count + 1 ...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
1,103
AdventOfCode2021
Apache License 2.0
day08/part1.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Day 8: Haunted Wasteland --- // You're still riding a camel across Desert Island when you spot a sandstorm // quickly approaching. When you turn to warn the Elf, she disappears before // your eyes! To be fair, she had just finished warning you about ghosts a few // minutes ago. // // One of the camel's pouches i...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
2,651
adventofcode2023
MIT License
src/main/kotlin/g0501_0600/s0529_minesweeper/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0529_minesweeper // #Medium #Array #Depth_First_Search #Breadth_First_Search #Matrix // #2023_01_15_Time_243_ms_(87.50%)_Space_37_MB_(87.50%) class Solution { private var row = 0 private var col = 0 private fun dfs(board: Array<CharArray>, row: Int, col: Int) { if (row < 0 || r...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,859
LeetCode-in-Kotlin
MIT License
kotlin/structures/CentroidDecomposition.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures import java.util.stream.Stream // https://sai16vicky.wordpress.com/2014/11/01/divide-and-conquer-on-trees-centroid-decomposition/ object CentroidDecomposition { fun calcSizes(tree: Array<List<Integer>>, size: IntArray, deleted: BooleanArray, u: Int, p: Int) { size[u] = 1 for (v ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,207
codelibrary
The Unlicense
src/main/kotlin/com/danielmichalski/algorithms/data_structures/_11_graph_traversal/UndirectedGraph.kt
DanielMichalski
288,453,885
false
{"Kotlin": 101963, "Groovy": 19141}
package com.danielmichalski.algorithms.data_structures._11_graph_traversal import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashSet class UndirectedGraph { private val adjacencyList: MutableList<Node> = ArrayList() fun addVertex(vertex: String) { val node = findNode(v...
0
Kotlin
1
7
c8eb4ddefbbe3fea69a172db1beb66df8fb66850
3,403
algorithms-and-data-structures-in-kotlin
MIT License
src/main/kotlin/com/nibado/projects/advent/search/Dijkstra.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.search import com.nibado.projects.advent.Point import com.nibado.projects.advent.collect.NumberGrid import com.nibado.projects.advent.graph.Graph import java.util.* object Dijkstra : GraphShortestPath, GridShortestPath { override fun <N, E : Number> shortestPath(graph: Graph<N, ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,880
adventofcode
MIT License
src/Day03.kt
Iamlooker
573,103,288
false
{"Kotlin": 5744}
fun main() { val charactersSmall = "abcdefghijklmnopqrstuvwxyz" val charactersCaps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" val characters = charactersSmall + charactersCaps val range = (1..52).toList() val priority = range.associateBy { characters[it - 1] } fun part1(input: List<String>): Int = input....
0
Kotlin
0
0
91a335428a99db2f2b1fd5c5f51a6b1e55ae2245
829
aoc-2022-kotlin
Apache License 2.0
kotlin/1985-find-the-kth-largest-integer-in-the-array.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}
/* * Using a minHeap (And BigInteger, alternativly you can compare strings too) */ class Solution { fun kthLargestNumber(nums: Array<String>, k: Int): String { val minHeap = PriorityQueue<BigInteger>{ a, b -> if(a < b) 1 else -1 } nu...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,429
leetcode
MIT License
Successive_prime_differences/Kotlin/src/SuccessivePrimeDifferences.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}
private fun sieve(limit: Int): Array<Int> { val primes = mutableListOf<Int>() primes.add(2) val c = BooleanArray(limit + 1) // composite = true // no need to process even numbers > 2 var p = 3 while (true) { val p2 = p * p if (p2 > limit) { break } var...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
1,923
rosetta
MIT License
kotlin/530.Minimum Absolute Difference in BST(二叉搜索树的最小绝对差).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 a binary search tree with non-negative values, find the minimum <a href="https://en.wikipedia.org/wiki/Absolute_difference">absolute difference</a> between values of any two nodes.</p> <p> <b>Example:</b> <pre> <b>Input:</b> 1 \ 3 / 2 <b>Output:</b> 1 <b>Explanation:</b> The minimum ...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
1,586
leetcode
MIT License
src/main/kotlin/com/ikueb/advent18/Day03.kt
h-j-k
159,901,179
false
null
package com.ikueb.advent18 import com.ikueb.advent18.model.Point object Day03 { private const val PATTERN = "#(\\d+) @ (\\d+),(\\d+): (\\d+)x(\\d+)" fun getOverlappingRegions(input: List<String>) = parseAndFindOverlappingPoints(input).second.count() fun getNonOverlappingId(input: List<Strin...
0
Kotlin
0
0
f1d5c58777968e37e81e61a8ed972dc24b30ac76
1,656
advent18
Apache License 2.0
grow/src/main/java/com/suheng/grow/grammar/Grammar.kt
ssywbj
189,440,773
false
null
package com.suheng.grow.grammar class Grammar { private val pi = 3.14 //语句结束不用写分号 private var y: Int = 11 private val items = listOf("kiwifruit", "apple", "banana") private val list = listOf(5, -1, 0, 9, 13) private val map = mapOf("a" to 1, "b" to 2, "c" to 3) //to用于(key, value)映射 fun assignm...
0
Kotlin
0
0
da846c399e5dd3c177983755343f575e685f9735
8,725
HomeShare
Apache License 2.0
src/Day09.kt
MarkRunWu
573,656,261
false
{"Kotlin": 25971}
fun main() { data class Movement(val offsetX: Int, val offsetY: Int); data class Position(var x: Int, var y: Int) { fun getNextStepPosition(target: Position): Position? { val nextX = if (kotlin.math.abs(target.x - this.x) > 1) { this.x + if (target.x - this.x > 0) 1 else -1 ...
0
Kotlin
0
0
ced885dcd6b32e8d3c89a646dbdcf50b5665ba65
4,785
AOC-2022
Apache License 2.0
src/main/kotlin/sorting/QuickSort.kt
Pawlllosss
526,668,214
false
{"Kotlin": 61939}
package sorting class QuickSort { fun sort(input: List<Int>): List<Int> { val arrayToSort = ArrayList(input) sort(arrayToSort, 0, input.size - 1) return arrayToSort } private fun sort(input: MutableList<Int>, low: Int, high: Int) { if (high > low) { val partiti...
0
Kotlin
0
0
94ad00ca3e3e8ab7a2cb46f8846196ae7c55c8b4
1,318
Kotlin-algorithms
MIT License
problems/2904/kotlin/Solution.kt
misut
678,196,869
false
{"Kotlin": 32683}
class Solution { fun shortestBeautifulSubstring(s: String, k: Int): String { val init = s.indexOfFirst { it == '1' } if (init == -1) { return "" } val indices = mutableListOf(init) for (i in 1..<k) { val idx = s.substring(indices.last() + 1).indexOfFi...
0
Kotlin
0
0
52fac3038dd29cb8eefebbf4df04ccf1dda1e332
1,201
ps-leetcode
MIT License
src/Test.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
import easy._2697LexicographicallySmallestPalindrome import easy._2824CountPairsWhoseSumIsLessThanTarget import medium._1276NumberOfBurgersWithNoWasteOfIngredients import medium._1410HtmlEntityParser import java.math.BigInteger import java.security.MessageDigest import java.util.Collections fun printResult(solve: Any?...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
6,667
AlgorithmsProject
Apache License 2.0
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day06/Day06.kt
jackploeg
736,755,380
false
{"Kotlin": 318734}
package nl.jackploeg.aoc._2023.calendar.day06 import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory import nl.jackploeg.aoc.utilities.readStringFile import javax.inject.Inject import kotlin.math.sqrt class Day06 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun co...
0
Kotlin
0
0
f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76
1,970
advent-of-code
MIT License
src/Utils.kt
askeron
572,955,924
false
{"Kotlin": 24616}
import java.io.File import java.math.BigInteger import java.security.MessageDigest import java.util.* import kotlin.collections.ArrayList import kotlin.math.sign /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("resources", "$name.txt") .readLines() /** * Converts string t...
0
Kotlin
0
1
6c7cf9cf12404b8451745c1e5b2f1827264dc3b8
6,611
advent-of-code-kotlin-2022
Apache License 2.0
2017/src/five/CorruptionChecksumChallenge.kt
Mattias1
116,139,424
false
null
package five // Day 2 class CorruptionChecksumChallenge { fun differenceChecksum(input: Array<String>): Int { val numberList = this.toNumberList(input) return numberList .map { this.diffMaxMin(it) } .sum() } private fun toNumberList(input: Array<String>): Li...
0
Kotlin
0
0
6bcd889c6652681e243d493363eef1c2e57d35ef
1,389
advent-of-code
MIT License
solutions/src/MaximalSquare.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
class MaximalSquare { /* This was my solution. It is (m*n)^2. However, the correct solution is m*n. I have noted that for my studies and am leaving this up as a record. */ fun maximalSquare(matrix: Array<CharArray>): Int { var largest = 0 for(i in matrix.indices) { for(j...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,304
leetcode-solutions
MIT License
backend/src/main/kotlin/services/utilities/RequirementsParser.kt
Feng-12138
640,760,018
false
null
package services.utilities import java.util.concurrent.ConcurrentHashMap class RequirementsParser { // requirementsData example: // ["1:CS 115,CS 135,CS 145;1:CS 136,CS 146;1:MATH 127,MATH 137,MATH 147;1:MATH 128,MATH 138,MATH 148;1:MATH 135,MATH 145;1:MATH 136,MATH 146;1:MATH 239,MATH 249;1:STAT 230,STAT ...
0
Kotlin
2
3
f8db57b89cda6f71388cdaa0042a1c2908c86cc3
8,062
LooSchedule
MIT License
src/Day17.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
import kotlin.math.max enum class RockType { ROW, CROSS, COLUMN, L, SQUARE } data class FallResult(val rock: Rock, val isLanded: Boolean) class Rock(val parts: List<Position>, private val type: RockType) { fun moveRight(chamber: MutableList<MutableList<Char>>): Rock { if (this.parts.all { chamber[0]...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
7,224
advent-of-code
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2021/Day18.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2021 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle import java.util.Stack import kotlin.IllegalStateException import kotlin.math.max class Day18(input: Input) : Puzzle() { sealed interface Node { val depth: Int val ex...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
7,271
adventofcode-kotlin
MIT License
src/main/kotlin/days/aoc2022/Day24.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day import util.Point2d class Day24 : Day(2022, 24) { lateinit var blizzardBounds: Pair<IntRange, IntRange> override fun partOne(): Any { return calculateFastestRoute(inputList) } override fun partTwo(): Any { return calculateFastestRouteThereAndBackAn...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
6,597
Advent-Of-Code
Creative Commons Zero v1.0 Universal
jvm-demo/src/main/java/combo/demo/models/autocomplete/AutoCompleteDataSet.kt
rasros
148,620,275
false
null
package combo.demo.models.autocomplete import combo.bandit.glm.* import combo.math.RunningVariance import combo.math.sample import combo.model.* import combo.sat.optimizers.JacopSolver import java.io.InputStreamReader fun main() { val a = AutoCompleteDataSet() val lm = SGDLinearModel.Builder(a.model.problem)...
0
Kotlin
1
2
2f4aab86e1b274c37d0798081bc5500d77f8cd6f
4,052
combo
Apache License 2.0
src/Day10.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
import kotlin.math.abs fun main() { fun parse(input: List<String>): List<Int> { val seq = mutableListOf(1) for (s in input) { if (s.startsWith("addx ")) { val value = s.split(" ")[1].toInt() seq.add(seq.last()) seq.add(seq.last() + value) ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
1,245
advent-of-code-2022
Apache License 2.0
src/main/kotlin/stack/StrCal.kt
yx-z
106,589,674
false
null
package stack import java.util.* fun main(args: Array<String>) { // parse command line calculations such as 1+2*3 // to answer -> 1+6 -> 7 // only +, -, *, /, no `.`, `^`, `(`, `)`, etc. // assume input string is always valid and formatted (no spaces, tabs, etc.) val test1 = "13*2+8" // = 34 val test2 = "3-12+...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,416
AlgoKt
MIT License
Kotlin/SelectionSort.kt
shauryam-exe
412,424,939
true
{"Java": 54671, "C++": 46151, "C": 27439, "Python": 27284, "JavaScript": 19473, "Kotlin": 14848, "C#": 5916, "Go": 4305}
fun main(args: Array<String>) { //Input the array in the format num1 num2 num3 num4 etc print("Enter the elements for the Array: ") var inputArray = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray() var sortedArray = selectionSort(inputArray) println(sortedArray.contentToString()...
0
Java
0
0
3a247451ade57138c3255dbbd27bfb0610f9f02e
924
DS-Algo-Zone
MIT License