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
WorldviewGenerator/src/shmp/generator/culture/worldview/reasoning/Reasonings.kt
ShMPMat
212,499,539
false
null
package shmp.generator.culture.worldview.reasoning import shmp.generator.culture.worldview.reasoning.concept.ActionConcept import shmp.generator.culture.worldview.reasoning.concept.ObjectConcept import shmp.generator.culture.worldview.reasoning.concept.ReasonConcept import shmp.generator.culture.worldview.Meme open ...
0
Kotlin
0
0
9fc6faafa1dbd9737dac71dc8a77960accdae81f
3,202
CulturesSim
MIT License
leetcode/src/linkedlist/Q21.kt
zhangweizhe
387,808,774
false
null
package linkedlist import linkedlist.kt.ListNode fun main() { // https://leetcode-cn.com/problems/merge-two-sorted-lists/ val l1 = LinkedListUtil.createList(intArrayOf(1, 2, 4)) val l2 = LinkedListUtil.createList(intArrayOf(1, 3, 4)) LinkedListUtil.printLinkedList(mergeTwoLists(l1, l2)) } /** * 递归 ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,438
kotlin-study
MIT License
2023/src/main/kotlin/net/daams/solutions/3a.kt
Michiel-Daams
573,040,288
false
{"Kotlin": 39925, "Nim": 34690}
package net.daams.solutions import net.daams.Solution class `3a`(input: String): Solution(input) { private val allNumbers: MutableList<List<Pair<String, Int>>> = mutableListOf() private val allSymbols: MutableList<List<Int>> = mutableListOf() private val adjacentNumbers: MutableList<Int> = mutableListOf(...
0
Kotlin
0
0
f7b2e020f23ec0e5ecaeb97885f6521f7a903238
2,074
advent-of-code
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D18.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2020 import io.github.pshegger.aoc.common.BaseSolver @ExperimentalStdlibApi class Y2020D18 : BaseSolver() { override val year = 2020 override val day = 18 override fun part1(): Long = parseInput(false).fold(0L) { acc, expression -> acc + expression.appl...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
3,345
advent-of-code
MIT License
src/Day10.kt
wbars
576,906,839
false
{"Kotlin": 32565}
fun main() { fun part1(input: List<String>): Int { var nextCycle = 20 var curCycle = 0 var x = 1 var res = 0 for (line in input) { if (line == "noop") { curCycle++ if (curCycle == nextCycle) { res += nextCycle *...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
1,492
advent-of-code-2022
Apache License 2.0
kotlinP/src/main/java/com/jadyn/kotlinp/leetcode/linknode/LinkNode-0.kt
JadynAi
136,196,478
false
null
package com.jadyn.kotlinp.leetcode.linknode import org.w3c.dom.Node import kotlin.random.Random /** *JadynAi since 4/5/21 */ fun main() { val first = ListNode(1) val random = Random(3) var next = first val set = hashSetOf<Int>() for (i in 0..6) { var v = random.nextInt(0, 66) whi...
0
Kotlin
6
17
9c5efa0da4346d9f3712333ca02356fa4616a904
2,926
Kotlin-D
Apache License 2.0
src/main/kotlin/g1301_1400/s1326_minimum_number_of_taps_to_open_to_water_a_garden/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1326_minimum_number_of_taps_to_open_to_water_a_garden // #Hard #Array #Dynamic_Programming #Greedy // #2023_06_06_Time_189_ms_(100.00%)_Space_38.5_MB_(42.86%) class Solution { fun minTaps(n: Int, ranges: IntArray): Int { if (n == 0 || ranges.size == 0) { return if (n == 0) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
959
LeetCode-in-Kotlin
MIT License
src/main/kotlin/info/jukov/adventofcode/y2022/Day13.kt
jukov
572,271,165
false
{"Kotlin": 78755}
package info.jukov.adventofcode.y2022 import info.jukov.adventofcode.Day import org.json.JSONArray import java.io.BufferedReader /** * Thanks to some dude from vas3k whiteboard chat who point me that * puzzle input is valid json arrays. */ object Day13 : Day() { override val year: Int = 2022 override val...
0
Kotlin
1
0
5fbdaf39a508dec80e0aa0b87035984cfd8af1bb
2,952
AdventOfCode
The Unlicense
src/main/kotlin/co/csadev/advent2021/Day25.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 25 * Problem Description: http://adventofcode.com/2021/day/25 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point2D import co.csadev.adventOfCode.Resources.resourceAsList class Day25(override val in...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,938
advent-of-kotlin
Apache License 2.0
src/main/kotlin/g2101_2200/s2122_recover_the_original_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2122_recover_the_original_array // #Hard #Array #Hash_Table #Sorting #Enumeration // #2023_06_25_Time_299_ms_(100.00%)_Space_40.1_MB_(100.00%) class Solution { private lateinit var res: IntArray fun recoverArray(nums: IntArray): IntArray { val n = nums.size nums.sort() ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,660
LeetCode-in-Kotlin
MIT License
src/main/kotlin/be/inniger/euler/problems01to10/Problem06.kt
bram-inniger
135,620,989
false
{"Kotlin": 20003}
package be.inniger.euler.problems01to10 private const val MAX_VALUE = 100 /** * Sum square difference * * The sum of the squares of the first ten natural numbers is, * 1^2 + 2^2 + ... + 10^2 = 385 * The square of the sum of the first ten natural numbers is, * (1 + 2 + ... + 10)^2 = 55^2 = 3025 * Hence the diff...
0
Kotlin
0
0
8fea594f1b5081a824d829d795ae53ef5531088c
663
euler-kotlin
MIT License
csp-framework/src/main/kotlin/com/tsovedenski/csp/Job.kt
RedShuhart
152,120,429
false
null
package com.tsovedenski.csp import com.tsovedenski.csp.heuristics.ordering.comparators.VariableComparator import com.tsovedenski.csp.heuristics.pruning.PruneSchema import com.tsovedenski.csp.heuristics.pruning.Slice /** * Created by <NAME> on 14/10/2018. */ /** * Represents a problem being solved. * * @param V ...
0
Kotlin
1
4
29d59ec7ff4f0893c0d1ec895118f961dd221c7f
3,164
csp-framework
MIT License
src/2021/Day14_2.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File val inputs = File("input/2021/day14").readLines() val polymerTemplate = inputs[0] val pairInsertionMap = hashMapOf<String, String>() for (index in 2 until inputs.size) { val (first, second) = inputs[index].split("->") pairInsertionMap[first.trim()] = second.trim() } val polymerMap = mutab...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
1,538
adventofcode
MIT License
src/main/kotlin/advent/of/code/day14/Solution.kt
brunorene
160,263,437
false
null
package advent.of.code.day14 fun processUntil10(e1: Byte, e2: Byte, created: Int): String { val recipes = mutableListOf(e1, e2) var elf1 = 0 var elf2 = 1 while (recipes.size < created + 10) { val combine = recipes[elf1] + recipes[elf2] val recipe1 = if (combine > 9) 1.toByte() else null...
0
Kotlin
0
0
0cb6814b91038a1ab99c276a33bf248157a88939
1,501
advent_of_code_2018
The Unlicense
src/questions/Sqrtx.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe /** * Given a non-negative integer x, compute and return the square root of x. * [Source](https://leetcode.com/problems/sqrtx/) */ @UseCommentAsDocumentation private fun mySqrt(x: Int): Int { if (x == 1) return x val xLong = x....
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,529
algorithms
MIT License
src/main/kotlin/g0101_0200/s0139_word_break/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0101_0200.s0139_word_break // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table // #Dynamic_Programming #Trie #Memoization #Algorithm_II_Day_15_Dynamic_Programming // #Dynamic_Programming_I_Day_9 #Udemy_Dynamic_Programming #Big_O_Time_O(M+max*N)_Space_O(M+N+max) // #2022_09_03_Time...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,387
LeetCode-in-Kotlin
MIT License
src/main/kotlin/solutions/year2022/Day1.kt
neewrobert
573,028,531
false
{"Kotlin": 7605}
package solutions.year2022 import readInputText fun main() { fun sumCalories(input: String): List<Int> { return input.split("\n\n").map { it.lines().sumOf { cal -> cal.toInt() } } } fun part1(input: String): Int { return sumCalories(input).sortedDescending().take(1).sum() } fun p...
0
Kotlin
0
0
7ecf680845af9d22ef1b9038c05d72724e3914f1
710
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/zachjones/languageclassifier/entities/MultiLanguageDecision.kt
zachtjones
184,465,284
false
{"Kotlin": 73431}
package com.zachjones.languageclassifier.entities import com.zachjones.languageclassifier.model.types.Language /*** * Represents a language decision where there's multiple languages or multiple weighted * parts in each decision. */ data class MultiLanguageDecision( val weights: Map<Language, Double> ) : Langua...
0
Kotlin
0
1
dfe8710fcf8daa1bc57ad90f7fa3c07a228b819f
1,342
Multi-Language-Classifier
Apache License 2.0
Others/kt_misc/SortInclude.kt
duangsuse-valid-projects
163,751,200
false
{"HTML": 426651, "JavaScript": 355495, "Kotlin": 240112, "TypeScript": 129004, "Python": 115314, "C": 88823, "C++": 54980, "Makefile": 39662, "TeX": 35614, "Assembly": 32921, "CSS": 15035, "Java": 8098, "Shell": 3838, "Haskell": 3542, "Visual Basic .NET": 3227, "Lua": 3220, "Ruby": 2185, "QMake": 508}
typealias CategoryMap<K, V> = Set<Map<K, V>> typealias IncludePath = String /** Descending level */ typealias Level = /*Comparable*/ Int class DescendAllocator(private var max: Int = Int.MAX_VALUE) { fun less() = max-- } val kmap: CategoryMap<IncludePath, Level> = DescendAllocator().run { setOf( mapOf( "QObje...
4
HTML
0
4
e89301b326713bf949bcf9fbaa3992e83c2cba88
1,993
Share
MIT License
src/main/kotlin/com/colinodell/advent2022/Day11.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day11(private val allMonkeys: List<Monkey>) { private val lcm = allMonkeys.map { it.divisorTest }.fold(1L, Long::times) fun solvePart1() = solve(20) { it.floorDiv(3) } fun solvePart2() = solve(10000) { it.mod(lcm) } private fun solve(times: Int, modifier: (Long...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,329
advent-2022
MIT License
src/main/kotlin/leetcode/kotlin/binarysearch/1341. The K Weakest Rows in a Matrix.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.binarysearch import java.util.PriorityQueue private fun kWeakestRows(mat: Array<IntArray>, k: Int): IntArray { fun findSoldiers(arr: IntArray): Int { var l = 0 var r = arr.size - 1 while (l < r) { var m = l + (r - l + 1) / 2 if (arr[m] >= 1) ...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
2,346
kotlinmaster
Apache License 2.0
src/main/kotlin/day24.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day24() { val lines: List<String> = readFile("day24.txt") day24part1(lines) day24part2(lines) } var w = 0 var x = 0 var y = 0 var z = 0 fun day24part1(lines: List<String>) { val blocks = getBlocks(lines) var serialNumber = 99999999999999 var solved = false var tries = 0L while (...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
3,189
advent_of_code_2021
MIT License
src/chapter3/section3/ex3.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section3 import chapter3.section2.fullArray /** * 使用什么顺序插入键 S E A C H X M 能够得到一颗高度为1的2-3树? * * 解:先添加一个计算红黑树的高度的方法(只统计黑色结点),再根据练习3.2.9中的方法生成所有可能的排序, * 统计所有让树高度为1的插入顺序(我实现的方法树高度从1开始,所以应该统计让height()方法返回2的树) */ fun ex3() { val list = ArrayList<Array<Char>>() fullArray("SEACHXM".toCharArray()...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,800
Algorithms-4th-Edition-in-Kotlin
MIT License
parcial-1-Juan/AsignarCupo.kt
lmisea
640,071,913
false
null
fun swapDual(A: Array<Int>, B: Array<Int>, i: Int, j: Int): Unit { val aux: Int = A[i] A[i] = A[j] A[j] = aux val temp: Int = B[i] B[i] = B[j] B[j] = temp } fun compararEstudiantes(A: Array<Int>, B: Array<Int>, i: Int, j: Int): Boolean{ return A[i] < A[j] || (A[i] == A[j] && B[i] <= B[j]) }...
0
Kotlin
1
0
948a9e52d0760a82a163d01c4361e07a021444cb
2,102
lab-algos-2
MIT License
kotlin/src/katas/kotlin/knapsack/Knapsack0.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.knapsack import datsok.* import org.junit.* import java.util.* import kotlin.collections.HashSet class Knapsack0Tests { @Test fun `single item`() { checkPacking( Bag(width = 1, height = 1), items = setOf(Item(Cell(0, 0))), output = "0" ) ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
4,702
katas
The Unlicense
src/main/kotlin/com/manerfan/althorithm/sort/MergeSort.kt
manerfan
122,578,493
false
null
/* * ManerFan(http://manerfan.com). All Rights Reserved. * * 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 app...
0
Kotlin
0
0
9210934e15acefd1b5bafc7f11b2078643ded239
2,515
algorithm-with-kotlin
Apache License 2.0
contest1907/src/main/kotlin/C.kt
austin226
729,634,548
false
{"Kotlin": 23837}
import kotlin.math.min // https://codeforces.com/contest/1907/problem/C private fun readInt(): Int = readln().toInt() private fun solve(n: Int, s: String): Int { var min = n val checked = mutableSetOf(s) val q = ArrayDeque<String>() q.addFirst(s) while (q.isNotEmpty()) { val str = q.remove...
0
Kotlin
0
0
4377021827ffcf8e920343adf61a93c88c56d8aa
1,399
codeforces-kt
MIT License
2k23/aoc2k23/src/main/kotlin/16.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d16 import java.util.* import java.util.concurrent.Callable import java.util.concurrent.ExecutorService import java.util.concurrent.Executors fun main() { println("Part 1: ${part1(input.read("16.txt"))}") println("Part 2: ${part2(input.read("16.txt"))}") } fun part1(input: List<String>): Int = Maze(i...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
3,746
aoc
The Unlicense
challenges/hacker-rank/kotlin/src/main/kotlin/com/raphaelnegrisoli/hackerrank/trees/HeightOfABinaryTree.kt
rbatista
36,197,840
false
{"Scala": 34929, "Kotlin": 23388}
/** * https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree/problem */ package com.raphaelnegrisoli.hackerrank.trees import kotlin.math.max data class Node( val data: Int, var left: Node? = null, var right: Node? = null ) { fun insert(data: Int) { if (data < this.da...
2
Scala
0
0
f1267e5d9da0bd5f6538b9c88aca652d9eb2b96c
1,025
algorithms
MIT License
collections/src/main/kotlin/com/lillicoder/algorithms/collections/Heap.kt
lillicoder
754,271,079
false
{"Kotlin": 16213}
package com.lillicoder.algorithms.collections /** * Implementation of a [Heap](https://en.wikipedia.org/wiki/Heap_(data_structure)). */ class Heap<T : Comparable<T>>( collection: Collection<T>, private val buffer: MutableList<T> = collection.toMutableList(), ) { init { heapify(buffer) } ...
0
Kotlin
0
0
8f96def65d07f646facaa3007cee6c8c99e71320
2,912
algorithms-kotlin
Apache License 2.0
atcoder/arc154/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package atcoder.arc154 import kotlin.random.Random fun main() { val n = readInt() val random = Random(566) val shuffle = (0 until n).shuffled(random) val memo = mutableMapOf<Triple<Int, Int, Int>, Boolean>() // p[i] + p[j] > p[k] fun ask(i: Int, j: Int, k: Int): Boolean { if (i > j) return ask(j, i, k) retu...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,195
competitions
The Unlicense
src/year2021/day07/Day07.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day07 import util.assertTrue import util.read2021DayInput import kotlin.math.absoluteValue fun main() { fun task01(input: List<Int>): Int { var cheapestOutcome = Int.MAX_VALUE for (i in 0..input.maxOrNull()!!) { var maxValue = 0 for (j in input.indic...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,072
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/suicideburn.kt
rasmusbergpalm
278,299,208
false
null
import kotlin.math.max import kotlin.math.pow import kotlin.math.sqrt /** * Compute the time to wait before applying constant throttle*engineForce force such that altitude will be zero when velocity is zero. * Takes into account changing mass and gravitational pull. * * Note: not used at the moment */ fun suicid...
3
Kotlin
0
0
19e718714a29e81e452b43181f6fe71e531cbd92
3,119
ksp
MIT License
src/test/kotlin/dev/shtanko/algorithms/leetcode/PermutationInStringTest.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,578
kotlab
Apache License 2.0
src/Day06.kt
SebastianHelzer
573,026,636
false
{"Kotlin": 27111}
fun main() { fun getSecretIndex(size: Int, input: String) : Int { return input.windowed(size, 1, false).indexOfFirst { it.toSet().size == size } + size } fun part1(input: String): Int = getSecretIndex(4, input) fun part2(input: String): Int = getSecretIndex(14, input) // test if impleme...
0
Kotlin
0
0
e48757626eb2fb5286fa1c59960acd4582432700
914
advent-of-code-2022
Apache License 2.0
Explore/Learn/Introduction to Data Structure/Arrays 101/Squares of A Sorted Array/SquaresSorted.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 Solution1 { fun sortedSquares(A: IntArray): IntArray { val B = IntArray(A.size) for (id in B.indices) { B[id] = A[id] * A[id] } return B.sortedArray() } } class Solution2 { fun sortedSquares(A: IntArray): IntArray { val N = A.size ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
916
leet-code
MIT License
kotlin/MutableCategoricalMap.kt
danftang
193,937,824
false
null
import java.util.* import kotlin.NoSuchElementException import kotlin.collections.HashMap import kotlin.random.Random open class MutableCategoricalMap<T> : AbstractMutableMap<T, Double> { private var sumTreeRoot: SumTreeNode<T>? = null private val leafNodes: MutableMap<T, LeafNode<T>> enum class MapType {...
0
C++
1
2
ac84d5b255d9f09ea5de21bb08f96072af2e32e7
11,706
MutableCategoricalDistribution
MIT License
00-code(源代码)/src/com/hi/dhl/algorithms/offer/_13/kotlin/Solution.kt
hi-dhl
256,677,224
false
null
package com.hi.dhl.algorithms.offer._13.kotlin import java.util.* /** * <pre> * author: dhl * desc : * </pre> */ class Solution { fun movingCount(m: Int, n: Int, k: Int): Int { val robot = Array(m, { IntArray(n) }) return dfs(robot, 0, 0, m, n, k) } fun dfs(robot: Array<Int...
0
Kotlin
48
396
b5e34ac9d1da60adcd9fad61da4ec82e2cefc044
1,446
Leetcode-Solutions-with-Java-And-Kotlin
Apache License 2.0
aqua/app/src/main/java/com/garmin/android/aquamarine/Basic.kt
catalintira
244,655,458
false
null
package com.garmin.android.aquamarine // Exercise 1 open class Account(var balance: Float) { open fun withdraw(sumToWithdraw: Float) { balance -= sumToWithdraw } fun deposit(sumToDeposit: Float) { balance += sumToDeposit } } class SavingAccount(balance: Float) : Account(balance) { ...
2
Kotlin
0
0
a55bb2a74344249ded557ef760609caaaf89bebd
3,984
aquamarine
Apache License 2.0
kotlin/backtracking/Coloring.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package backtracking import java.util.Random class Coloring { var minColors = 0 var bestColoring: IntArray fun minColors(graph: Array<BooleanArray>): Int { val n = graph.size bestColoring = IntArray(n) val id = IntArray(n + 1) val deg = IntArray(n + 1) for (i in 0.....
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,205
codelibrary
The Unlicense
model/src/main/java/com/kentvu/csproblems/Playground.kt
KentVu
210,312,595
false
null
package com.kentvu.csproblems import kotlin.reflect.full.hasAnnotation import kotlin.reflect.full.memberFunctions class Playground { @Target(AnnotationTarget.FUNCTION) annotation class AlgoFunction @OptIn(ExperimentalStdlibApi::class) val algos: List<String> get() { return Playground::class.m...
0
Kotlin
0
0
52cb15d5a5d70336617f56e3961fdaff7b94ca84
2,508
CSProblems
Apache License 2.0
src/main/kotlin/days/aoc2023/Day16.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2023 import days.Day import util.CharArray2d import util.Point2d import kotlin.math.max class Day16 : Day(2023, 16) { override fun partOne(): Any { return calculatePartOne(inputList) } override fun partTwo(): Any { return calculatePartTwo(inputList) } fun calculat...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,123
Advent-Of-Code
Creative Commons Zero v1.0 Universal
Chapter_7/src/main/kotlin/exercises/7.15 Enhanced GradeBook.kt
Cursos-Livros
667,537,024
false
{"Kotlin": 104564}
package exercises fun main() { println("Enter with the number of students:") val inputNumberStudents = readlnOrNull()?.toInt() ?: 0 println("Enter with the number of exams:") val inputNumberExams = readlnOrNull()?.toInt() ?: 0 // Create a GradeBook object val myGradeBook = GradeBook("CS101 Int...
0
Kotlin
0
0
f2e005135a62b15360c2a26fb6bc2cbad18812dd
4,373
Kotlin-Como-Programar
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day20.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day20() = puzzle(day = 20) { data class Module(val op: Char, val name: String, val to: List<String>) val m = inputLines.associate { l -> val (a, b) = l.split(" -> ") val n = if (a == "broadcaster") a else a.drop(1...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,618
advent-of-code
The Unlicense
2021/02/main.kt
chylex
433,239,393
false
null
import java.io.File fun main() { val lines = File("input.txt").readLines() val directions = lines.map { line -> line.split(' ', limit = 2).let { it[0] to it[1].toInt() } } println("Part 1:") part1(directions) println() println("Part 2:") part2(directions) } private fun part1(directions: List<Pair<String,...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
1,074
Advent-of-Code
The Unlicense
src/day1/solution.kt
0pilatos0
572,642,222
false
{"Kotlin": 4586}
fun main(){ fun part1(input:List<String>): Int{ var mostCalories = 0 var currentCalories = 0 for (calorie in input){ try{ currentCalories += calorie.toInt() if (currentCalories > mostCalories){ mostCalories = currentCalories ...
0
Kotlin
0
0
424653e1ec515bacc9423d4b1f1e221ac53b7659
1,339
adventofcodekotlin
Apache License 2.0
src/commonMain/kotlin/edu/unito/probability/bayes/AssignmentProposition.kt
lamba92
150,039,952
false
null
package edu.unito.probability.bayes import edu.unito.probability.RandomVariable class AssignmentProposition(forVariable: RandomVariable, val value: Any): AbstractTermProposition(forVariable) { override fun holds(possibleWorld: Map<RandomVariable, Any>) = value == possibleWorld[termVariable] } abstract clas...
0
Kotlin
0
0
acbae0d12d9501ca531b8e619b49ce38793a7697
2,151
bayes-net-project-multiplatform
MIT License
Lab 7/src/main/kotlin/DoubleArrayUnilities.kt
knu-3-tochanenko
273,870,242
false
null
operator fun DoubleArray.plus(array: DoubleArray): DoubleArray { val size = Math.max(this.size, array.size) val result = DoubleArray(size) { 0.0 } for (i in 1..this.size) result[size - i] += this[this.size - i] for (i in 1..array.size) result[size - i] += array[array.size - i] retur...
0
Kotlin
0
0
84818b225f1aa4812cc5515d6fdda31d9d373e86
2,022
NumericalMethods
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/JumpGame5.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
7,048
kotlab
Apache License 2.0
app/src/main/kotlin/kotlinadventofcode/2023/2023-15.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2023` import com.github.h0tk3y.betterParse.combinators.* import com.github.h0tk3y.betterParse.grammar.* import com.github.h0tk3y.betterParse.lexer.* import kotlinadventofcode.Day class `2023-15` : Day { override fun runPartOneNoUI(inp...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
26,541
kotlinadventofcode
MIT License
src/Day01.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
fun main() { fun countElfCalories(input: List<String>): ArrayList<Int> { val results = arrayListOf<Int>() var current = 0 for (s in input) { if (s.isBlank()) { results.add(current) current = 0 } else { current += s.toInt...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
764
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumOfArrays.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
6,381
kotlab
Apache License 2.0
src/main/kotlin/leetcode/kotlin/array/easy/1. Two Sum.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.array.easy fun main() { println(twoSum(intArrayOf(2, 11, 7, 15), 9).toList()) println(twoSum2(intArrayOf(2, 11, 7, 15), 9).toList()) println(twoSum3(intArrayOf(2, 11, 7, 15), 9).toList()) println(twoSum4(intArrayOf(2, 11, 7, 15), 9).toList()) } private fun twoSum(nums: IntArray...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
1,382
kotlinmaster
Apache License 2.0
src/main/kotlin/g2001_2100/s2039_the_time_when_the_network_becomes_idle/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2039_the_time_when_the_network_becomes_idle // #Medium #Array #Breadth_First_Search #Graph // #2023_06_23_Time_1197_ms_(100.00%)_Space_104.9_MB_(100.00%) import java.util.PriorityQueue class Solution { fun networkBecomesIdle(edges: Array<IntArray>, pat: IntArray): Int { val n = pat.si...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,492
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/leetcode/random_problems/medium/atoi/Main.kt
frikit
254,842,734
false
null
package com.leetcode.random_problems.medium.atoi fun main() { println("Test case 1:") println(Solution().myAtoi("42")) // 42 println() println("Test case 2:") println(Solution().myAtoi(" -42")) // -42 println() println("Test case 3:") println(Solution().myAtoi("4193 with words")) //...
0
Kotlin
0
0
dda68313ba468163386239ab07f4d993f80783c7
2,143
leet-code-problems
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortList.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,694
kotlab
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2021/Day18.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2021 import com.nibado.projects.advent.* object Day18 : Day { private val input = resourceLines(2021, 18) private fun String.toSnailNumber() = if(length == 1) toSnailNumberLit() else toSnailNumberPair() private fun String.toSnailNumberLit() = SnailNumberLit(toInt()) ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
4,476
adventofcode
MIT License
year2020/day12/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day12/part1/Year2020Day12Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 12: Rain Risk --- Your ferry made decent progress toward the island, but the storm came in faster than anyone expected. The ferry needs to take evasive actions! Unfortunately, the ship's navigation computer seems to be malfunctioning; rather than giving a route directly to safety, it produced extremely cir...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,014
AdventOfCode
MIT License
src/main/kotlin/com/ginsberg/advent2021/Day05.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 5 - Hydrothermal Venture * Problem Description: http://adventofcode.com/2021/day/5 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day5/ */ package com.ginsberg.advent2021 class Day05(input: List<String>) { priva...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,099
advent-2021-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year19/Day06.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year19 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.asPair import com.grappenmaker.aoc.bfsDistance fun PuzzleSet.day6() = puzzle { data class Entry(val around: String, val orbiter: String) val entries = inputLines.map { val (around, orbiter) = it.spli...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,031
advent-of-code
The Unlicense
kotlin/src/com/daily/algothrim/leetcode/SortArrayByParityII.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 922. 按奇偶排序数组 II * * 给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数。 * 对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数;当 A[i] 为偶数时, i 也是偶数。 * * 你可以返回任何满足上述条件的数组作为答案。 * * 示例: * * 输入:[4,2,5,7] * 输出:[4,5,2,7] * 解释:[4,7,2,5],[2,5,4,7],[2,7,4,5] 也会被接受。 * */ class SortArrayByParityII { companion o...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,425
daily_algorithm
Apache License 2.0
src/Day06.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
fun main() { fun checkForMarker(input: String, distinctCharacters: Int): Int { return input .windowed(distinctCharacters) .indexOfFirst { window -> window.toSet().size == distinctCharacters } + distinctCharacters } fun part1(input: String): Int { return checkForMark...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
765
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc/year2021/Day07.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2021 import aoc.Puzzle import kotlin.math.abs /** * [Day 7 - Advent of Code 2021](https://adventofcode.com/2021/day/7) */ object Day07 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { val map = input.lineSequence() .single() .split(",") ...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
940
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountingBits.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,524
kotlab
Apache License 2.0
src/main/kotlin/com/github/wakingrufus/eloleague/swiss/Swiss.kt
wakingrufus
113,580,870
false
null
package com.github.wakingrufus.eloleague.swiss import com.github.wakingrufus.eloleague.game.GameItem import java.util.* import kotlin.math.pow import kotlin.math.roundToInt fun totalRounds(teams: Int): Int { return teams.toDouble().pow(2).roundToInt() } fun randomPairing(teams: List<SwissTeamItem>): List<SwissP...
3
Kotlin
0
1
49fdacf104b5bb42ea72ec72f6b36aab33b1b8f8
4,310
elo-league-jfx
MIT License
src/commonMain/kotlin/io/nacular/measured/units/Units.kt
nacular
153,705,303
false
{"Kotlin": 58838}
package io.nacular.measured.units import kotlin.jvm.JvmName import kotlin.math.roundToInt /** * Base class for all types that can represent a unit of measure. * A Units type can have multiple "members", each being some fraction of the base * unit for that type. Time for example, might have seconds as the base unit...
1
Kotlin
3
108
9341443ee423e64a6b78006935b5394c7b2f7756
33,985
measured
MIT License
Retos/Reto #45 - EL CALENDARIO DE ADEVIENTO 2023 [Fácil]/kotlin/codigo-alan.kt
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
package retos2023 import java.util.* /* * ¿Conoces el calendario de aDEViento de la comunidad (https://adviento.dev)? * 24 días, 24 regalos sorpresa relacionados con desarrollo de software. * Desde el 1 al 24 de diciembre. * * Crea un programa que simule el mecanismo de participación: * - Mediante la terminal, ...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
3,110
retos-programacion-2023
Apache License 2.0
LeetCode/Easy/maximum-depth-of-binary-tree/Solution.kt
GregoryHo
254,657,102
false
null
import java.util.* class Solution { fun maxDepth(root: TreeNode?): Int { // return bfs(root) return dfs(root) } // time complexity O(N) // space complexity O(N/2) private fun bfs(root: TreeNode?): Int { if (root == null) { return 0 } var depth = 0 val stack = Stack<TreeNode>(...
0
Kotlin
0
0
8f126ffdf75aa83a6d60689e0b6fcc966a173c70
1,348
coding-fun
MIT License
src/day13/fr/Day13_1-2.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
package day13.fr import java.io.File private fun readChars(): CharArray = readLn().toCharArray() private fun readLn() = readLine()!! // string line private fun readSb() = StringBuilder(readLn()) private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fu...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
3,111
Advent-of-Code-2021
Apache License 2.0
src/main/kotlin/dayFive/DayFive.kt
janreppien
573,041,132
false
{"Kotlin": 26432}
package dayFive import AocSolution import java.io.File import java.util.Stack class DayFive : AocSolution(5) { private val file = File("src/main/resources/inputs/dayFive/input.txt") private var stacks1 = readStacks() private var stacks2 = readStacks() private val instructions = readInstructions() ...
0
Kotlin
0
0
b53f6c253966536a3edc8897d1420a5ceed59aa9
2,499
aoc2022
MIT License
src/main/kotlin/com/github/wtfjoke/day3/Day3Part2.kts
WtfJoke
434,008,687
false
{"Kotlin": 80582}
import java.nio.file.Paths val inputs = Paths.get("inputs.txt").toFile() .useLines { it.toList() } val bitLength = inputs.first().length fun determineOxygen(): Int { var oxygens = inputs for (i in 0 until bitLength) { val oxygensCount = oxygens .groupingBy { it[i] } .eachCo...
1
Kotlin
0
0
9185b9ddf3892be24838139fcfc849d3cb6e89b4
1,131
adventofcode-21
MIT License
src/main/kotlin/org/olafneumann/regex/generator/diff/Diff.kt
noxone
239,624,807
false
{"Kotlin": 246877, "HTML": 22083, "CSS": 5034, "C": 2817, "Dockerfile": 1748, "JavaScript": 220}
package org.olafneumann.regex.generator.diff //import dev.andrewbailey.diff.DiffOperation //import dev.andrewbailey.diff.differenceOf import io.github.petertrr.diffutils.diff import io.github.petertrr.diffutils.patch.Delta import io.github.petertrr.diffutils.patch.DeltaType import org.olafneumann.regex.generator.Regex...
13
Kotlin
69
355
001cc69d2592afa70b492441e119753789494816
3,401
regex-generator
MIT License
src/main/kotlin/leetcode/problem0047/Permutations2.kt
ayukatawago
456,312,186
false
{"Kotlin": 266300, "Python": 1842}
package leetcode.problem0047 class Permutations2 { fun permuteUnique(nums: IntArray): List<List<Int>> { val hashMap = hashMapOf<Int, Int>() nums.forEach { hashMap[it] = if (hashMap.containsKey(it)) { requireNotNull(hashMap[it]) + 1 } else { 1 ...
0
Kotlin
0
0
f9602f2560a6c9102728ccbc5c1ff8fa421341b8
1,235
leetcode-kotlin
MIT License
Algorithm/coding_interviews/Kotlin/Questions39.kt
ck76
314,136,865
false
{"HTML": 1420929, "Java": 723214, "JavaScript": 534260, "Python": 437495, "CSS": 348978, "C++": 348274, "Swift": 325819, "Go": 310456, "Less": 203040, "Rust": 105712, "Ruby": 96050, "Kotlin": 88868, "PHP": 67753, "Lua": 52032, "C": 30808, "TypeScript": 23395, "C#": 4973, "Elixir": 4945, "Pug": 1853, "PowerShell": 471, ...
package com.qiaoyuang.algorithm /** * 找出一个数组中出现次数超过数组长度一般的数字 */ fun main() { try { val arg0 = intArrayOf(1, 2, 3, 2, 2, 2, 5, 4, 2) val arg1 = intArrayOf(1, 2, 3, 2, 2, 2, 5, 4) val message = "超过数组长度一半的数为:" println("$message${arg0.moreThanHalfNum2()}") println("$message${arg1.moreThanHalfNum2...
0
HTML
0
2
2a989fe85941f27b9dd85b3958514371c8ace13b
1,554
awesome-cs
Apache License 2.0
kotlin/udemy_course/src/main/kotlin/geek_for_geeks/GeekForGeeks.kt
pradyotprksh
385,586,594
false
{"Kotlin": 1973871, "Dart": 1066884, "Python": 313491, "Swift": 147167, "C++": 113494, "CMake": 94132, "Go": 45704, "HTML": 21089, "Ruby": 12424, "Rust": 8550, "C": 7125, "Makefile": 1480, "Shell": 817, "JavaScript": 781, "CSS": 588, "Objective-C": 380, "Dockerfile": 32}
package geek_for_geeks import data_structures.trees.BinarySearchTree import data_structures.trees.MaxBinaryHeap import data_structures.trees.TreeNode class GeekForGeeks { fun startGeekForGeeks() { println("Starting problems from GeekForGeeks [https://practice.geeksforgeeks.org/explore?page=1]") pr...
0
Kotlin
10
17
2520dc56fc407f97564ed9f7c086292803d5d92d
16,511
development_learning
MIT License
src/main/kotlin/org/mony/investor/Portfolio.kt
joow
121,801,144
false
null
package org.mony.investor import java.math.BigDecimal import java.math.RoundingMode class Portfolio(private val positions: List<Position>) { private val amount: BigDecimal = positions.map { it.amount }.fold(BigDecimal.ZERO) { acc, amount -> acc + amount } private fun allocations() = positions.groupi...
0
Kotlin
0
0
a931de56cd10d5f9f948e0bf1e26994a84f235b3
1,734
investor
MIT License
kotlin/src/katas/kotlin/leetcode/partition_labels/PartitionLabels.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.partition_labels import datsok.* import org.junit.* /** * https://leetcode.com/problems/partition-labels/ * * A string S of lowercase letters is given. We want to partition this string into as many parts as possible * so that each letter appears in at most one part, and return a list...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,116
katas
The Unlicense
year2023/day03/engine/src/main/kotlin/com/curtislb/adventofcode/year2023/day03/engine/EngineSchematic.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2023.day03.engine import com.curtislb.adventofcode.common.geometry.Point import com.curtislb.adventofcode.common.grid.Grid import com.curtislb.adventofcode.common.grid.forEachPointValue import com.curtislb.adventofcode.common.grid.mutableGridOf import com.curtislb.adventofcode.com...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
4,718
AdventOfCode
MIT License
2022/14/14.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
fun main() { val lines = generateSequence(::readlnOrNull).toList() .map { it.split(" -> ", ",").map { it.toInt() }.chunked(2) } val width = lines.flatten().maxOf { it[0] } + 200 val height = lines.flatten().maxOf { it[1] } + 2 val field = MutableList(height) { MutableList(width) { '.' } } fu...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
1,119
adventofcode
Apache License 2.0
kotlin/0322-coin-change.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}
// DP class Solution { fun coinChange(coins: IntArray, amount: Int): Int { val dp = IntArray (amount + 1) { amount + 1 } dp[0] = 0 for (i in 0..amount) { for (j in 0 until coins.size) { if (coins[j] <= i) { dp[i] = minOf(dp[i], dp[i - coins[j]]...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,172
leetcode
MIT License
day07/Kotlin/day07.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* import kotlin.math.abs fun print_day_7() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 7" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime().exec("figlet The Trea...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
1,840
AOC2021
Apache License 2.0
src/main/kotlin/g0801_0900/s0850_rectangle_area_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0850_rectangle_area_ii // #Hard #Array #Ordered_Set #Segment_Tree #Line_Sweep // #2023_03_30_Time_171_ms_(100.00%)_Space_35.7_MB_(100.00%) class Solution { fun rectangleArea(rectangles: Array<IntArray>): Int { val memo: MutableList<IntArray> = ArrayList() for (rectangle in rect...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,965
LeetCode-in-Kotlin
MIT License
src/main/kotlin/co/csadev/advent2022/Day23.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 23 * Problem Description: http://adventofcode.com/2021/day/23 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point2D import co.csadev.adventOfCode.Resources.resourceAsList import co.csadev.adventOfCod...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,910
advent-of-kotlin
Apache License 2.0
src/main/kotlin/io/dkozak/search/astar/sokoban/map.kt
d-kozak
156,193,078
false
null
package io.dkozak.search.astar.sokoban typealias Location = Pair<Int, Int> /** * The neighbour indexes in the clockwise fashion, starting from the top */ val Location.neighbours: List<Location> get() { return listOf( first - 1 to second, first to second + 1, ...
0
Kotlin
0
0
da0a0de3872558293cb71cbc71a5fc374a3939a6
3,282
search
MIT License
diceroller/src/main/kotlin/com/nicolas/diceroller/roll/FacesReport.kt
CNicolas
124,060,465
false
null
package com.nicolas.diceroller.roll import com.nicolas.models.dice.Face typealias FacesReport = Map<Face, Int> internal fun facesToFacesReport(faces: List<Face>): FacesReport { val report = hashMapOf<Face, Int>() faces.distinct() .map { face -> report.put(face, faces.count { it == face }) } ...
0
Kotlin
0
1
ec6e8048f7f01c75b19bddf7ec5c0485b76aea99
1,146
WHFRP3Companion
Apache License 2.0
src/main/kotlin/week1/DiskDrive.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package week1 import shared.Puzzle class DiskDrive : Puzzle(7) { enum class NodeType { DIR, FILE } data class Node( val parent: Node?, val type: NodeType, var fileSize: Int, val name: String ) { val nodes: MutableList<Node> = mutableListOf() ...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
3,851
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions50.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round0 fun test50() { val str1 = "abacdeff" println(findNotRepeatingChar(str1)) val str2 = "We are Students." val str3 = "aeiou" println(deleteChar(str2, str3)) val str4 = "google" println(deleteRepeatChar(str4)) val str5 = "silent" val str6 = "listen" val str7 = "evil" val s...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,216
Algorithm
Apache License 2.0
src/Day03.kt
JonasDBB
573,382,821
false
{"Kotlin": 17550}
private fun stringHalves(line: String) = Pair(line.substring(0, line.length / 2), line.substring(line.length / 2)) private fun part1(input: List<String>) { var ret = 0 for (line in input) { val strings = stringHalves(line) run end@ { strings.first.forEach { c -> if (...
0
Kotlin
0
0
199303ae86f294bdcb2f50b73e0f33dca3a3ac0a
1,057
AoC2022
Apache License 2.0
src/Day06.kt
BHFDev
572,832,641
false
null
fun main() { fun part1(input: List<String>): Int { val mostRecentCharactersQueue = ArrayDeque<Char>() fun checkQueue(): Boolean { var success = true (1..(mostRecentCharactersQueue.size)).forEach { _ -> val currentChar = mostRecentCharactersQueue.removeFirst()...
0
Kotlin
0
0
b158069483fa02636804450d9ea2dceab6cf9dd7
2,139
aoc-2022-in-kotlin
Apache License 2.0
src/main/aoc2016/Day16.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2016 class Day16(private val length: Int, private val input: String) { private fun String.reverseInvert(): String { return this.reversed().map { when (it) { '1' -> '0' '0' -> '1' else -> it } }.joinToString("") ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,746
aoc
MIT License
packages/dotlin/lib/src/kotlin/ranges/Ranges.kt
dotlin-org
434,960,829
false
{"Kotlin": 2136413, "Dart": 128641, "Java": 6266}
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2021-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.apa...
5
Kotlin
3
223
174ade2b64fb8275eb6914e29df2b18e6f74f85f
5,367
dotlin
Apache License 2.0
codeforces/kotlinheroes8/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes8 private fun solve(): Int { val n = readInt() val s = readLn().map { "()".indexOf(it) } val a = readLn() val must = IntArray(n) { -1 } val diff = BooleanArray(n) for (i in a.indices) { if (a[i] == '0') continue if (must[i] == 1) return -1 must[i] = 0 must[i + 3] = 1 diff...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
710
competitions
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem1220/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1220 /** * LeetCode page: [1220. Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation/); */ class Solution { /* Complexity: * Time O(n) and Space O(1); */ fun countVowelPermutation(n: Int): Int { val modulo = 1_000_000_007 ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
855
hj-leetcode-kotlin
Apache License 2.0
_7Function/src/main/kotlin/practice/76 Array Is All Larger.kt
Meus-Livros-Lidos
690,208,771
false
{"Kotlin": 166470}
package practice /** * Write a method arrayIsAllLarger that, given two Int arrays, * returns true if all the values in the first array are larger than * or equal to all the values in the same position in the second array. * If the first array is longer than the second array, or the second array is longer than the ...
0
Kotlin
0
1
2d05e5528b9dd2cf9ed8799bce47444246be6b42
2,729
LearnCsOnline-Kotlin
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[59]螺旋矩阵 II.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。 // // // // 示例 1: // // //输入:n = 3 //输出:[[1,2,3],[8,9,4],[7,6,5]] // // // 示例 2: // // //输入:n = 1 //输出:[[1]] // // // // // 提示: // // // 1 <= n <= 20 // // Related Topics 数组 矩阵 模拟 // 👍 444 👎 0 //leetcode submit region begin(Prohibit m...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,374
MyLeetCode
Apache License 2.0
testers/SortedSquaresTester.kt
GwGibson
590,189,035
false
null
package challenges.testers import challenges.sortedSquares object SortedSquaresTester { private val t1 = listOf(1, 2, 3, 5, 6, 8, 9, 10) private val r1 = listOf(1, 4, 9, 25, 36, 64, 81, 100) private val t2 = listOf(1) private val r2 = listOf(1) private val t3 = listOf(0) private val r3 = listO...
0
Kotlin
19
1
71d24dcf63ba5f09e6f2f32a4c3dfe2ec82030b5
1,368
jav1001-challenges
MIT License
src/main/kotlin/net/codetreats/aoc2021/day16/Package.kt
codetreats
433,929,847
false
{"Kotlin": 133030, "Shell": 811}
package net.codetreats.aoc2021.day16 import net.codetreats.aoc2021.util.Logger data class Package( val bitsConsumed: Int, val version: Int, val type: Int, val literal: Long?, val subPackages: List<Package> ) { fun versionSum(): Int = version + subPackages.map { it.versionSum() }.sum() fun...
0
Kotlin
0
0
f7c456faa31f85420e988baa47682e0de973e906
3,411
aoc2021
MIT License
src/main/kotlin/me/giacomozama/adventofcode2023/days/Day01.kt
giacomozama
725,810,476
false
{"Kotlin": 12023}
package me.giacomozama.adventofcode2023.days import java.io.File class Day01 : Day() { private lateinit var input: List<String> override fun parseInput(inputFile: File) { input = inputFile.readLines() } override fun solveFirstPuzzle(): Int { var result = 0 for (line in input...
0
Kotlin
0
0
a86e9757288c63778e1f8f1f3fa5a2cfdaa6dcdd
1,799
aoc2023
MIT License
LeetCode/Kth Smallest Element in a Sorted Matrix/main.kt
thedevelopersanjeev
112,687,950
false
null
class Solution { private fun lowerBound(arr: IntArray, ele: Int): Int { var (lo, hi, ans) = listOf(0, arr.size - 1, 0) while (lo <= hi) { val mid = lo + (hi - lo) / 2 if (arr[mid] < ele) { ans = mid + 1 lo = mid + 1 } else { ...
0
C++
58
146
610520cc396fb13a03c606b5fb6739cfd68cc444
994
Competitive-Programming
MIT License
src/leetcodeProblem/leetcode/editor/en/StringWithoutAaaOrBbb.kt
faniabdullah
382,893,751
false
null
//Given two integers a and b, return any string s such that: // // // s has length a + b and contains exactly a 'a' letters, and exactly b 'b' //letters, // The substring 'aaa' does not occur in s, and // The substring 'bbb' does not occur in s. // // // // Example 1: // // //Input: a = 1, b = 2 //Output: "abb...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,693
dsa-kotlin
MIT License