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
Contest/Biweekly Contest 73/Sort the Jumbled Numbers/SortJumbledNumbers.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun sortJumbled(mapping: IntArray, nums: IntArray): IntArray { val newList = ArrayList<Pair<Int, Int>>() for (i in 0..nums.size-1) { val pair = Pair(transform(mapping, nums[i]), i) newList.add(pair) } val sortedList = newList.sortedWith(compar...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
861
leet-code
MIT License
calendar/day04/Day4.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day04 import Day import Lines class Day4 : Day() { override fun part1(input: Lines): Any { return input .count { line -> val (range1, range2) = line.split(",").map { p -> p.split("-").let { it[0].toInt()..it[1].toInt() } } range1.containsRange(range2) || range2.co...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
878
adventofcode-2022
Apache License 2.0
kotlin/sort/Partition.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package sort import java.util.Random object Partition { // like http://www.cplusplus.com/reference/algorithm/partition/ // but additionally places separator at the end of the first group fun partition(a: IntArray, fromInclusive: Int, toExclusive: Int, separatorIndex: Int): Int { var i = fromInclus...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,524
codelibrary
The Unlicense
src/main/java/dev/haenara/mailprogramming/solution/y2019/m08/d11/UseCase190811.kt
HaenaraShin
226,032,186
false
null
package dev.haenara.mailprogramming.solution.y2019.m08.d11 import dev.haenara.mailprogramming.solution.InvaildProgramArgumentException import dev.haenara.mailprogramming.solution.UseCase class UseCase190811(args: Array<String>) : UseCase<Pair<String, String>, String>(args) { override val solution = Solution190811...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
2,264
MailProgramming
MIT License
src/main/kotlin/22-aug.kt
aladine
276,334,792
false
{"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511}
class Solution(rects: Array<IntArray>) { private var totalPoints:Int = 0 private var prefixSum : List<Int> = mutableListOf() private var rectangles:List<IntArray> = mutableListOf() init { val areas = rects.map { (it[2]-it[0]+1)*(it[3]-it[1]+1) } totalPoints = areas.sum() rectan...
0
C++
1
1
54b7f625f6c4828a72629068d78204514937b2a9
1,215
awesome-leetcode
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-23.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 fun main() { println("Part1:") println(solve(testInput1, 0)) println(solve(input, 7)) println(solve2(7)) println(solve2(12)) println() println("Part2:") println(solve2(12)) } private fun solve(input: String, value: Int): Long { val ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,001
advent-of-code
MIT License
src/main/kotlin/g0001_0100/s0018_4sum/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0018_4sum // #Medium #Array #Sorting #Two_Pointers #2023_07_03_Time_229_ms_(98.59%)_Space_37.8_MB_(100.00%) class Solution { fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val n = nums.size nums.sort() val result: MutableList<List<Int>> = ArrayList() ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,245
LeetCode-in-Kotlin
MIT License
detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/OffsetsToLineColumn.kt
hcknl
212,993,385
true
{"Kotlin": 1474242, "Groovy": 3832, "Shell": 1055, "HTML": 698}
package io.gitlab.arturbosch.detekt.formatting import java.util.ArrayList /** * Extracted and adapted from KtLint. */ internal fun calculateLineColByOffset(text: String): (offset: Int) -> Pair<Int, Int> { var i = -1 val e = text.length val arr = ArrayList<Int>() do { arr.add(i + 1) ...
4
Kotlin
1
1
565d86d780c15ade77b5468a9e342ba334181333
2,006
detekt
Apache License 2.0
kotlin/src/main/kotlin/adventofcode/y2019/Day3.kt
3ygun
115,948,057
false
null
package adventofcode.y2019 import adventofcode.DataLoader import adventofcode.Day import adventofcode.commons.Point import adventofcode.commons.xy import kotlin.math.abs /** * Final solution holds all the points for each wire in memory. * While this isn't super memory efficient it is sure easier to build a solution...
0
Kotlin
0
0
69f95bca3d22032fba6ee7d9d6ec307d4d2163cf
6,484
adventofcode
MIT License
vimcash.kt
rogerkeays
514,601,375
false
{"Kotlin": 1520}
//usr/bin/env [ $0 -nt $0.jar ] && kotlinc -d $0.jar $0; [ $0.jar -nt $0 ] && kotlin -cp $0.jar VimcashKt $@; exit 0 import java.io.File fun String.parseAmount(account: String): Double { return substring(22, 34).toDouble() * if (indexOf(" $account ") > 34) -1 else 1 } fun File.calculateBalance(account: String, c...
0
Kotlin
0
0
f6a1c67e76148d6e1d8f305c64e894d12b2e0c4b
1,520
vimcash
MIT License
kotlin/graphs/lca/LcaSparseTable.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.lca import java.util.stream.Stream // Answering LCA queries in O(1) with O(n*log(n)) preprocessing class LcaSparseTable(tree: Array<List<Integer>>, root: Int) { var len: Int var up: Array<IntArray> var tin: IntArray var tout: IntArray var time = 0 fun dfs(tree: Array<List<Intege...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,710
codelibrary
The Unlicense
src/Day10/Day10.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day10 import kotlin.math.* import readInput import java.util.Dictionary class CPU() { var cycleNum = 1 var x = 1 var part1Result = 0 fun part1(input: List<String>): Int { for (line in input) { processLine(line) } return part1Result } fun part2(in...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
1,721
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day2.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day2 : Day(2) { override fun partOne(): Any { return inputList.map { it.split(" ").let { it[0] to it[1].toLong() } } .fold(Position(0, 0)) { pos, (dir, steps) -> when (dir) { "forward" -> Position(pos.x + steps, pos.depth) ...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
1,232
aoc-2021
Creative Commons Zero v1.0 Universal
TallerRecursion/src/ean/estructuradedatos/taller/TallerRecursion.kt
DinaTuesta27
599,303,436
false
null
package ean.estructuradedatos.taller /** * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Universidad EAN (Bogotá - Colombia) * Departamento de Sistemas * Faculta de Ingeniería * * Taller Funciones Recursivas * Fecha: 18 de abril de 2023 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
0
Kotlin
0
0
ef8ce29b13ab3e7ce2f036447cceb84863046c14
14,203
kotlin
MIT License
day14/kotlin/RJPlog/day2114_1_2.kts
razziel89
433,724,464
true
{"Rust": 368326, "Python": 219109, "Go": 200337, "Kotlin": 80185, "Groovy": 67858, "JavaScript": 45619, "TypeScript": 43504, "CSS": 35030, "Shell": 18611, "C": 5260, "Ruby": 2359, "Dockerfile": 2285, "HTML": 227, "C++": 153}
import java.io.File // tag::poly[] fun poly(input1: Int): Int { var rules = mutableMapOf<String, String>() var polyTemp: String = "" File("day2114_puzzle_input.txt").forEachLine { if (it != "") { if (!it.contains("->")) { polyTemp = it } else { var instruction = it.split(" -> ") rules.put(instr...
1
Rust
0
0
0042891cfcecdc2b65ee32882bd04de80ecd7e1c
4,293
aoc-2021
MIT License
src/Day06.kt
icoffiel
572,651,851
false
{"Kotlin": 29350}
private const val DIFFERENCE_TO_UNIQUE_INDEX_START = 1 fun main() { fun firstNonUniqueStrings(input: String, uniqueStringLength: Int) = input .windowedSequence(uniqueStringLength) // Move over the expected length at a time .takeWhile { it.toSet().size != uniqueStringLength } fun part1(input: S...
0
Kotlin
0
0
515f5681c385f22efab5c711dc983e24157fc84f
1,211
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/divisible_sum_pairs/divisible-sum-pairs.kt
francisakpan
299,567,682
false
{"Kotlin": 16639, "Dart": 2622, "Java": 2384}
package divisible_sum_pairs fun main() { val a = "50 44 77 66 70 58 9 59 74 82 87 15 10 95 10 81 2 4 87 85 28 " + "96 76 18 86 91 94 59 19 58 98 48 38 70 36 38 66 9 72 54 23 23 17 " + "18 8 16 9 56 12 59 73 31 10 62 83 84 28 91 29 22 73 22 3 75 26 31 " + "93 57 15 32 46 74 99 10...
0
Kotlin
0
0
efb8fa9ee0249c01a4822485c40f86bec8a8e4cc
867
random-exercises
MIT License
src/DijkstraAlgorithm.kt
dkoscica
74,512,586
false
null
import java.util.* import models.* class DijkstraAlgorithm(graph: Graph) { private val nodes: List<Vertex> private val edges: List<Edge> private var settledNodes: MutableSet<Vertex> = HashSet() private var unSettledNodes: MutableSet<Vertex> = HashSet() private var predecessors: MutableMap<Vertex, ...
0
Kotlin
0
0
d204fc5dbb97d63bc0be025b3c4616dcfb11c483
3,336
APUI-Dijkstra-Algorithm-Kotlin
MIT License
module-tool/src/main/kotlin/de/twomartens/adventofcode/day11/graph/Graph.kt
2martens
729,312,999
false
{"Kotlin": 89431}
package de.twomartens.adventofcode.day11.graph data class Graph(val name: String, val galaxies: Collection<Pair<Int, Int>>) { override fun toString(): String { return name } companion object { fun of(name: String, rows: List<String>, emptySpaceMultiplier: Int): Graph { if (em...
0
Kotlin
0
0
03a9f7a6c4e0bdf73f0c663ff54e01daf12a9762
3,036
advent-of-code
Apache License 2.0
app/src/main/java/com/itscoder/ljuns/practise/algorithm/InsertionSort.kt
ljuns
148,606,057
false
{"Java": 26841, "Kotlin": 25458}
package com.itscoder.ljuns.practise.algorithm /** * Created by ljuns at 2019/1/5. * I am just a developer. * 插入排序 * 从第 2 个元素开始和前面的元素比较并排序 * 例如:1, 3, 2 * 1、第一次 for 循环:3 和 1 比较,不需要改变 * 2.1、第二次 for 循环:2 和 3 比较,调换位置变成 1, 2, 3,此时 j == 1 * 2.2、2 再和 1 比较,不需要改变,排序结束 */ class InsertionSort { fun main(args: Array...
0
Java
0
0
365062b38a7ac55468b202ebeff1b760663fc676
1,055
Practise
Apache License 2.0
Others/Kotlin/kotlin-koans/src/iii_conventions/MyDate.kt
mrkajetanp
81,245,804
false
{"C++": 1603629, "C": 402718, "Java": 283190, "Rust": 261526, "Python": 116934, "Dart": 86632, "Kotlin": 71503, "Ruby": 45722, "Makefile": 32375, "Shell": 31662, "Emacs Lisp": 23199, "JavaScript": 21065, "Go": 17512, "TypeScript": 13585, "CMake": 6829, "HTML": 2467, "Assembly": 139}
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int = when { year != other.year -> year - other.year month != other.month -> month - other.month else -> dayOfMonth - other.dayOfMonth ...
158
C++
0
2
aee01ff3208ab14e7d0e0a7077798342123bc3e6
1,448
programming-exercises
MIT License
src/main/kotlin/com/github/michaelbull/advent2023/day5/Almanac.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day5 private val SEEDS_REGEX = "seeds: (.*)".toRegex() private val MAP_REGEX = "(.*)-to-(.*) map:".toRegex() fun Sequence<String>.toAlmanac(): Almanac { var seeds = emptyList<Long>() var source = "" var destination = "" val entries = mutableListOf<AlmanacEntry...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,750
advent-2023
ISC License
src/main/kotlin/se/radicalcode/aoc/1.kt
gwendo
162,547,004
false
null
package se.radicalcode.aoc import java.io.File fun main(args: Array<String>) { println(reduceNumbers(readFileAsInts(args[0]))) } fun <T> Sequence<T>.repeat() = sequence { while (true) yieldAll(this@repeat)} fun findDuplicateFrequencies(numbers: List<Int>) : Int { val frequencies = mutableListOf<Int>(0) ...
0
Kotlin
0
0
12d0c841c91695e215f06efaf62d06a5480ba7a2
1,201
advent-of-code-2018
MIT License
distributed-systems/distributed-dijkstra/src/sequential/SequentialDijkstraHeap.kt
Lascor22
331,294,681
false
{"Java": 1706475, "HTML": 436528, "CSS": 371563, "C++": 342426, "Jupyter Notebook": 274491, "Kotlin": 248153, "Haskell": 189045, "Shell": 186916, "JavaScript": 159132, "Vue": 45665, "Python": 25957, "PLpgSQL": 23402, "Clojure": 11410, "Batchfile": 9677, "FreeMarker": 7201, "Yacc": 7148, "ANTLR": 6303, "Scala": 3020, "L...
package dijkstra.sequential import dijkstra.graph.Graph import java.util.* import kotlin.collections.HashSet private fun getClosestNode(notVisitedNodes: TreeMap<Long, HashSet<Int>>): Pair<Int, Long> { val nodesWithMinDist = notVisitedNodes.firstEntry() val closestNodes = nodesWithMinDist.value val minDist...
0
Java
0
0
c41dfeb404ce995abdeb18fc93502027e54239ee
2,350
ITMO-university
MIT License
src/Day13.kt
joshpierce
573,265,121
false
{"Kotlin": 46425}
import java.io.File fun main() { var directions: List<String> = File("Day13.txt").readLines() var pairs = directions.chunked(3).map { Pair(it[0], it[1])} var validIndexes: MutableList<Int> = mutableListOf() var allPackets: MutableList<Any> = mutableListOf() pairs.forEachIndexed { i...
0
Kotlin
0
1
fd5414c3ab919913ed0cd961348c8644db0330f4
5,334
advent-of-code-22
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BasicCalculator.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
5,154
kotlab
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day08.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day08(input: Input) : Puzzle() { private val program by lazy { parseProgram(input.lines()) } private fun parseProgram(code: List<String>) = code.map { it.split(" "...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
1,564
adventofcode-kotlin
MIT License
year2023/day12/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day12/part2/Year2023Day12Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- As you look out at the field of springs, you feel like there are way more springs than the condition records list. When you examine the records, you discover that they were actually folded up this whole time! To unfold the records, on each row, replace the list of spring conditions with five copie...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,023
AdventOfCode
MIT License
Kotlin/src/dev/aspid812/leetcode/problem0539/Solution.kt
Const-Grigoryev
367,924,342
false
{"Python": 35682, "Kotlin": 11162, "C++": 2688, "Java": 2168, "C": 1076}
package dev.aspid812.leetcode.problem0539 /* 539. Minimum Time Difference * ---------------------------- * Given a list of 24-hour clock time points in **"HH:MM"** format, return the *minimum **minutes** difference * between any two time-points in the list*. * * ### Constraints: * * * `2 <= timePoints <= 2 * ...
0
Python
0
0
cea8e762ff79878e2d5622c937f34cf20f0b385e
1,221
LeetCode
MIT License
day03/kotlin/RJPlog/day2003_1_2.kts
smarkwart
317,009,367
true
{"Python": 528881, "Rust": 179510, "Kotlin": 92549, "Ruby": 59698, "TypeScript": 57721, "Groovy": 56394, "CSS": 38649, "Java": 36866, "JavaScript": 27433, "HTML": 5424, "Dockerfile": 3230, "C++": 2171, "Go": 1733, "Jupyter Notebook": 988, "Shell": 897, "Clojure": 567, "PHP": 68, "Tcl": 46, "Dart": 41, "Haskell": 37}
import java.io.File //tag::identify_wood_width[] fun WidthGrid2003(): Int { var width: Int = 0 File("day2003_puzzle_input.txt").forEachLine { width = it.length } return width } //end::identify_wood_width[] //tag::identify_wood_depth[] fun DepthGrid2003(): Int { var depth: Int = 0 File("day2003_puzzle_input.txt")...
0
Python
0
0
b1f9e04177afaf7e7c15fdc7bf7bc76f27a029f6
2,601
aoc-2020
MIT License
src/main/kotlin/string/easy/RomanToInteger.kt
jiahaoliuliu
747,189,993
false
{"Kotlin": 97631}
package string.easy import org.junit.Assert.assertEquals import org.junit.Test /** * Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. * * Symbol Value * I 1 * V 5 * X 10 * L 50 * C 100 * D ...
0
Kotlin
0
0
c5ed998111b2a44d082fc6e6470d197554c0e7c9
4,308
CodingExercises
Apache License 2.0
src/main/kotlin/days/y22/Day03.kt
kezz
572,635,766
false
{"Kotlin": 20772}
package days.y22 import util.Day import util.mapInner public fun main() { Day3().run() } public class Day3 : Day(22, 3) { override fun part1(input: List<String>): Any = input .asSequence() .map(String::toCharArray) .map { items -> items.slice(0 until items.size / 2) to items.slice(ite...
0
Kotlin
0
0
1cef7fe0f72f77a3a409915baac3c674cc058228
969
aoc
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day17/PyroclasticFlow.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day17 import com.barneyb.aoc.util.Solver import com.barneyb.aoc.util.toSlice import com.barneyb.util.Dir import com.barneyb.util.HashMap import com.barneyb.util.HashSet import com.barneyb.util.Vec2 import kotlin.math.max import kotlin.math.min fun main() { Solver.execute( :...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
4,608
aoc-2022
MIT License
src/main/kotlin/computerScience/dataStructures/ListDataStructure.kt
rccorreia
739,621,618
false
{"Kotlin": 51255}
package com.github.rccorreia.computerScience.dataStructures import kotlin.math.abs class ListDataStructureInterviewQuestions { // Question: Given an array a that contains only numbers in the range from 1 to a.length, find // the first duplicate number for which the second occurrence has the minimal index....
0
Kotlin
0
0
33204487651afb603704bea044908d47e3986b8b
10,476
software-engineer-roadmap
MIT License
src/main/kotlin/adventofcode/day07/CamelCardsHand.kt
jwcarman
731,408,177
false
{"Kotlin": 137289}
/* * Copyright (c) 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 ...
0
Kotlin
0
0
dfb226e92a03323ad48c50d7e970d2a745b479bb
3,108
adventofcode2023
Apache License 2.0
buildSrc/src/main/kotlin/kotlinx/html/generate/tag-unions.kt
Kotlin
33,301,379
false
{"Kotlin": 554316}
package kotlinx.html.generate fun tagUnions(repository: Repository) { val groupings = repository.groupsByTags.filter { it.value.size > 1 } val groups = groupings.values.map { it.map { it.name }.toHashSet() }.distinct().sortedByDescending { it.size } val allUnions = repository.groupUnions // initial pa...
89
Kotlin
177
1,514
6c926dda0567d765fe84239e13606e43ff2e3657
1,667
kotlinx.html
Apache License 2.0
src/Day02.kt
mdtausifahmad
573,116,146
false
{"Kotlin": 5783}
import java.io.File fun main(){ val score = File("src/Day02.txt") .readText() .split("\n") .flatMap { it.lines() } .map { it.split(" ") } .sumOf { getPointOfRoundSecondPart(it[0].first(), it[1].first()) } println(score) } fun getPointOfRound(first: Char, second: Char...
0
Kotlin
0
0
13295fd5f5391028822243bb6880a98c70475ee2
1,707
adventofcode2022
Apache License 2.0
src/main/java/challenges/cracking_coding_interview/trees_graphs/paths_with_sum/PathsWithSumB.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.paths_with_sum import challenges.util.TreeNode object PathsWithSumB { fun countPathsWithSum(root: TreeNode?, targetSum: Int): Int { return countPathsWithSum(root, targetSum, 0, HashMap()) } private fun countPathsWithSum( node: Tre...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,928
CodingChallenges
Apache License 2.0
src/Day04.kt
alexladeira
573,196,827
false
{"Kotlin": 3920}
import kotlin.streams.toList fun main() { val result = part2() println(result) } private fun part2() = readInput("Day04").fold(0) { acc, s -> val values = s.replace("-", ",").split(",").stream().mapToInt { it.toInt() }.toList() if (values[1] >= values[2] && values[0] <= values[3]) { acc + 1 ...
0
Kotlin
0
0
facafc2d92de2ad2b6264610be4159c8135babcb
860
aoc-2022-in-kotlin
Apache License 2.0
app/src/main/kotlin/kotlinadventofcode/2015/2015-06.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2015` import com.github.h0tk3y.betterParse.grammar.Grammar import com.github.h0tk3y.betterParse.parser.Parser import kotlinadventofcode.Day import kotlinadventofcode.`2015`.`2015-06`.Instruction.* import kotlin.math.max import com.github.h0...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
13,023
kotlinadventofcode
MIT License
src/main/kotlin/me/grison/aoc/y2016/Day04.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2016 import me.grison.aoc.* class Day04 : Day(4, 2016) { override fun title() = "Security Through Obscurity" private val rooms = inputList.map { Triple( it.substringBeforeLast("-").replace("-", ""), it.allInts(includeNegative = false).first(), ...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,307
advent-of-code
Creative Commons Zero v1.0 Universal
advent/src/test/kotlin/org/elwaxoro/advent/y2021/Dec04.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2021 import org.elwaxoro.advent.PuzzleDayTester import org.elwaxoro.advent.rowColSwap /** * Giant Squid * (in which I abuse for loops) */ class Dec04 : PuzzleDayTester(4, 2021) { override fun part1(): Any = loadBoards().let { (calls, boards) -> calls.forEach { call -> ...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,433
advent-of-code
MIT License
src/main/kotlin/aoc2021/Day11.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import java.util.* import kotlin.math.max import kotlin.math.min typealias Octopus = Pair<Int, Int> private const val ENERGY_THRESHOLD = 9 private class OctopusArray(input: List<String>) { private val maxX: Int private val maxY: Int /** * The number of octopuses i...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,171
adventOfCode
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day20.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 20 - A Regular Map * * Problem Description: http://adventofcode.com/2018/day/20 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day20/ */ package com.ginsberg.advent2018 import java.util.ArrayDeque class Day20(rawI...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
1,652
advent-2018-kotlin
MIT License
plugins/evaluation-plugin/core/src/com/intellij/cce/metric/LatencyMetrics.kt
JetBrains
2,489,216
false
null
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.cce.metric import com.intellij.cce.core.Lookup import com.intellij.cce.core.Session import com.intellij.cce.metric.util.Bootstrap abstract class LatencyMetric(override val name...
251
null
5,079
16,158
831d1a4524048aebf64173c1f0b26e04b61c6880
3,669
intellij-community
Apache License 2.0
src/main/kotlin/Day11.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
import utils.* import kotlin.math.abs data class GalaxyMap( val map: Map<Point2D, List<Point2D>>, val galaxyFreeRows: List<Int>, val galaxyFreeCols: List<Int>, ) class Day11 { fun solve() { val galaxies = createGalaxyMap() println(solve(galaxies)) println(solve(galaxies, 1000...
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
2,757
aoc2023
Apache License 2.0
src/main/kotlin/com/psmay/exp/advent/y2021/day17/Day17.kt
psmay
434,705,473
false
{"Kotlin": 242220}
@file:Suppress("MemberVisibilityCanBePrivate", "unused") package com.psmay.exp.advent.y2021.day17 import com.psmay.exp.advent.y2021.util.repeatedForever import kotlin.math.abs import kotlin.math.sign private typealias IntPair = Pair<Int, Int> private inline val IntPair.x get() = this.first private inline val IntPai...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
3,400
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day05/Day05.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day05 import eu.janvdb.aocutil.kotlin.point2d.Line2D import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines const val FILENAME = "input05.txt" fun main() { val lines = readLines(2021, FILENAME) .map { parseLine(it) } val heatMap = HashMap<Point2D, Int...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
938
advent-of-code
Apache License 2.0
src/chapter07/Intro_运算符重载.kt
xu33liang33
252,216,839
false
null
package chapter07 import java.lang.IndexOutOfBoundsException import java.math.BigDecimal import java.time.LocalDate import kotlin.ranges.ClosedRange as ClosedRange1 /** * *运算符重载 * BigDecimal运算 * 约定 operator * * a * b | times * a / b | div * a % b | mod * a + b | plus * a - b | minu...
0
Kotlin
0
1
cdc74e445c8c487023fbc7917183d47e73ff4bc8
2,914
actioninkotlin
Apache License 2.0
kotlin/0647-palindromic-substrings.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}
/* * Two pointer with outwards extension solution, time O(N^2) and space O(1) */ class Solution { fun countSubstrings(s: String): Int { var res = 0 for(i in s.indices) { var l = i var r = i while(l >= 0 && r < s.length && s[l] == s[r]) { res++ ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,548
leetcode
MIT License
src/Day08.kt
calindumitru
574,154,951
false
{"Kotlin": 20625}
fun main() { val part1 = Implementation("Consider your map; how many trees are visible from outside the grid?", 21) { lines -> val map = convertToMap(lines) return@Implementation map.countVisible() } val part2 = Implementation("Consider your map; how many trees are visible from outs...
0
Kotlin
0
0
d3cd7ff5badd1dca2fe4db293da33856832e7e83
4,458
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dk/lessor/Day13.kt
aoc-team-1
317,571,356
false
{"Java": 70687, "Kotlin": 34171}
package dk.lessor fun main() { val lines = readFile("day_13.txt") val timestamp = lines.first().toLong() val busses = lines.last().split(",").toList() println(simpleBusTable(timestamp, busses)) println(busContestSolver(busses)) } fun simpleBusTable(goal: Long, busses: List<String>): Long { val...
0
Java
0
0
48ea750b60a6a2a92f9048c04971b1dc340780d5
1,189
lessor-aoc-comp-2020
MIT License
src/day06/Day06.kt
veronicamengyan
573,063,888
false
{"Kotlin": 14976}
package day06 import readInput fun main() { fun findMarker(input: List<String>): Int { input.get(0).windowed(4, 1).forEachIndexed{ idx, value -> if (value.length == value.toCharArray().toSet().size) { return idx + 4 } } return...
0
Kotlin
0
0
d443cfa49e9d8c9f76fdb6303ecf104498effb88
1,494
aoc-2022-in-kotlin
Apache License 2.0
core-kotlin-modules/core-kotlin-strings-4/src/test/kotlin/com/baeldung/sortalphabetically/SortStringAlphabeticallyUnitTest.kt
Baeldung
260,481,121
false
{"Kotlin": 1476024, "Java": 43013, "HTML": 4883}
package com.baeldung.sortalphabetically import org.junit.Test import kotlin.test.assertEquals class SortStringAlphabeticallyUnitTest { private fun sortStringWithCharArrayAndSorted(input : String) : String{ return input.toCharArray().sorted().joinToString("") } private fun sortStringWithCharA...
10
Kotlin
273
410
2b718f002ce5ea1cb09217937dc630ff31757693
1,953
kotlin-tutorials
MIT License
src/test/kotlin/com/psmay/exp/advent/y2021/tests/Day09Test.kt
psmay
434,705,473
false
{"Kotlin": 242220}
package com.psmay.exp.advent.y2021.tests import com.psmay.exp.advent.y2021.Day09 import com.psmay.exp.advent.y2021.Day09.mapSurroundingBasin import com.psmay.exp.advent.y2021.tests.helpers.asUseLinesSource import com.psmay.exp.advent.y2021.tests.helpers.getTextLineSource import com.psmay.exp.advent.y2021.util.Grid imp...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
3,678
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
src/strings/LongestSubString.kt
develNerd
456,702,818
false
{"Kotlin": 37635, "Java": 5892}
package strings import java.util.regex.Matcher fun main(){ val mom = " fqabcdeee ghfjkddddlopiugfds " val regex = Regex("([a-z])\\1+") val rGX = Regex("\\s+") val m1 = rGX.findAll(mom) println(m1.toMutableList().size) val m = mom.split(regex) println("3,4.5".split(",",".")) ...
0
Kotlin
0
0
4e6cc8b4bee83361057c8e1bbeb427a43622b511
1,491
Blind75InKotlin
MIT License
src/Day01.kt
kaeaton
572,831,118
false
{"Kotlin": 7766}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currentCalories = 0 input.forEach { if(it.isNotEmpty()) { currentCalories += it.toInt() } else { if(currentCalories > maxCalories) { maxCalor...
0
Kotlin
0
0
c2a92c68bd5822c72c1075f055fc2163762d6deb
987
AoC-2022
Apache License 2.0
src/main/kotlin/g2801_2900/s2876_count_visited_nodes_in_a_directed_graph/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2876_count_visited_nodes_in_a_directed_graph // #Hard #Dynamic_Programming #Graph #Memoization // #2023_12_25_Time_922_ms_(100.00%)_Space_76.6_MB_(100.00%) class Solution { fun countVisitedNodes(edges: List<Int>): IntArray { val n = edges.size val visited = BooleanArray(n) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,182
LeetCode-in-Kotlin
MIT License
day15/src/main/kotlin/com/nohex/aoc/day15/PathComputer.kt
mnohe
433,396,563
false
{"Kotlin": 105740}
package com.nohex.aoc.day15 import com.nohex.aoc.Matrix import com.nohex.aoc.Point import org.slf4j.LoggerFactory import java.util.* val neighbourLocations = setOf( Point(0, -1), // North Point(1, 0), // West Point(-1, 0),// East Point(0, 1) // South ) /** * The [risk] involved in arriving at the l...
0
Kotlin
0
0
4d7363c00252b5668c7e3002bb5d75145af91c23
2,730
advent_of_code_2021
MIT License
year2019/day06/part1/src/main/kotlin/com/curtislb/adventofcode/year2019/day06/part1/Year2019Day06Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 6: Universal Orbit Map --- You've landed at the Universal Orbit Map facility on Mercury. Because navigation in space often involves transferring between orbits, the orbit maps here are useful for finding efficient routes between, for example, you and Santa. You download a map of the local orbits (your puzzl...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,776
AdventOfCode
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-18.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
@file:OptIn(ExperimentalStdlibApi::class) package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2023, "18-input") val test1...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,931
advent-of-code
MIT License
src/main/kotlin/aoc19/Day6.kt
tahlers
225,198,917
false
null
package aoc19 import io.vavr.collection.HashMap import io.vavr.collection.Map import io.vavr.kotlin.tuple object Day6 { fun parseOrbits(orbits: String): Map<String, String> { val lines = orbits.split("\n") val entries = lines.map { val (center, satellite) = it.split(')') t...
0
Kotlin
0
0
dae62345fca42dd9d62faadf78784d230b080c6f
2,059
advent-of-code-19
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/luhn/Luhn.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.luhn /** * @author lusinabrian on 13/03/18. */ @Suppress("MagicNumber") object Luhn { fun isValid(cardNumber: String): Boolean { val newCardNumber = cardNumber.replace(" ", "") if (newCardNumber.length <= 1) { return false } val r...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
1,469
KotlinGround
MIT License
src/iii_conventions/MyDate.kt
gcx11
107,715,456
false
null
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override operator fun compareTo(other: MyDate): Int { return if (year == other.year && month == other.month && dayOfMonth == other.dayOfMonth) 0 else if (year > other.year || (year =...
0
Kotlin
0
0
38a201d3622a59c808dc95caa54824a9f7dace99
1,716
kotlin-koans
MIT License
src/main/kotlin/com/simonorono/aoc2015/solutions/Day07.kt
simonorono
662,846,819
false
{"Kotlin": 28492}
package com.simonorono.aoc2015.solutions import com.simonorono.aoc2015.lib.Day object Day07 : Day(7) { private val input = getInput().lines().map { parseInput(it) } private val values = mutableMapOf<String, UShort?>() private enum class Operator { OR, AND, LSHIFT, RSHIFT, ...
0
Kotlin
0
0
0fec1d4db5b68ea8ee05b20c535df1b7f5570056
3,316
aoc2015
MIT License
src/main/kotlin/me/camdenorrb/timorforest/tree/DecisionTree0.kt
camdenorrb
202,772,314
false
null
package me.camdenorrb.timorforest.tree // TODO: Change comparable to string, you can use .toDoubleOrNull to determine if it's a number /* class DecisionTree0 { private lateinit var root: NodeBase<*> var isTrained = false private set /** * Trains the decision tree with fortune and knowledg...
0
Kotlin
0
0
b746f0ca27b587fbff4dcc08d97051f463cac53e
5,161
TimorForest
MIT License
src/main/kotlin/no/chriswk/aoc2019/Day4.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package no.chriswk.aoc2019 class Day4 { companion object { @JvmStatic fun main(args: Array<String>) { val day4 = Day4() report { day4.part1() } report { day4.part2() } } } fun part1(): Int { val (begin, end) = "day4.txt".fileToString().sp...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
1,718
adventofcode2019
MIT License
src/year2021/day05/Field.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day05 import java.awt.Point import kotlin.math.absoluteValue interface Field { val coordinates: List<Pair<Point, Point>> var hydrothermalVentsMap: MutableList<MutableList<Int>> fun createMap() { hydrothermalVentsMap = MutableList(determineMapDimensions().first) ...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,752
advent-of-code-kotlin-template
Apache License 2.0
src/palindrome_int/PalindRomeString.kt
AhmedTawfiqM
458,182,208
false
{"Kotlin": 11105}
package palindrome_int //https://leetcode.com/problems/palindrome-number object PalindRomeString { private fun isPalindrome(input: Int): Boolean { if (input < 0 || input >= Int.MAX_VALUE) return false if (input in 0..9) return true val original = input.toString() original.forEachI...
0
Kotlin
0
1
a569265d5f85bcb51f4ade5ee37c8252e68a5a03
1,335
ProblemSolving
Apache License 2.0
src/main/kotlin/g2001_2100/s2081_sum_of_k_mirror_numbers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2081_sum_of_k_mirror_numbers // #Hard #Math #Enumeration #2023_06_27_Time_455_ms_(100.00%)_Space_39.9_MB_(100.00%) class Solution { fun kMirror(k: Int, n: Int): Long { val result: MutableList<Long> = ArrayList() var len = 1 while (result.size < n) { backtrac...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,676
LeetCode-in-Kotlin
MIT License
src/main/kotlin/d10/D10_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d10 import input.Input fun main() { val lines = Input.read("input.txt") val diagram = padInput(lines) val pipe = findPipe(diagram) val start = findStart(diagram) val startReplacement = startReplacement(start, findConnections(diagram, start)) diagram[start.first] = diagram[st...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
4,947
aoc2023-kotlin
MIT License
knowledgebase-importer/src/main/kotlin/com/hartwig/hmftools/knowledgebaseimporter/FusionsAnalysis.kt
j-hudecek
152,054,013
true
{"Java": 4078031, "Kotlin": 381037, "R": 991, "Shell": 765}
package com.hartwig.hmftools.knowledgebaseimporter import com.hartwig.hmftools.knowledgebaseimporter.output.ActionableFusionPairOutput import com.hartwig.hmftools.knowledgebaseimporter.output.ActionablePromiscuousGeneOutput import com.hartwig.hmftools.knowledgebaseimporter.output.FusionPair import com.hartwig.hmftools...
0
Java
0
0
f619e02cdb166594e7dd4d7d1dd7fe8592267f2d
3,803
hmftools
MIT License
src/Day01.kt
naturboy
572,742,689
false
{"Kotlin": 6452}
fun main() { fun part1(input: List<String>): Int { return input.maxOf { calories -> calories.split("\n").sumOf { it.toInt() } } } fun part2(input: List<String>): Int { return input.map { calories -> calories.split("\n").sumOf { it.toInt() } }.sorted().takeLast(3).sum() } // test if...
0
Kotlin
0
0
852871f58218d80702c3b49dd0fd453096e56a43
629
advent-of-code-kotlin-2022
Apache License 2.0
Day_11/Solution_Part2.kts
0800LTT
317,590,451
false
null
import java.io.File enum class Seat { Empty, Occupied, Floor } fun File.readSeats(): Array<Array<Seat>> { return readLines().map { line -> line.map { when (it) { '.' -> Seat.Floor 'L' -> Seat.Empty else -> Seat.Occupied } }.toTypedArray() }.toTypedArray() } fun printSeats(seats:...
0
Kotlin
0
0
191c8c307676fb0e7352f7a5444689fc79cc5b54
4,926
advent-of-code-2020
The Unlicense
src/main/kotlin/g1701_1800/s1728_cat_and_mouse_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1728_cat_and_mouse_ii // #Hard #Array #Dynamic_Programming #Math #Matrix #Graph #Memoization #Topological_Sort // #Game_Theory #2023_06_16_Time_193_ms_(100.00%)_Space_37.2_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { private val graphs: Array<Array<List<Int>>> = arrayOf(arrayOf(),...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,141
LeetCode-in-Kotlin
MIT License
src/main/kotlin/QuickSort.kt
wenvelope
692,706,194
false
{"Kotlin": 11474, "Java": 7490}
import java.util.* fun main() { val mutableList = arrayListOf(3,23,5435,2323,43,32,43) println(mutableList) println( mutableList.quickSort().let { mutableList }) } /** *快排 * 思想:分治 * 1.从大到小每一层都一分为二 分到不能再分为止 * 2.对于每一个小部分 都选定一个和标志位 使得标志位的左边都小于右边 */ fun MutableList<Int>.quickSort() { if (this.isEm...
0
Kotlin
0
1
4a5b2581116944c5bf8cf5ab0ed0af410669b9b6
1,743
OnlineJudge
Apache License 2.0
utbot-analytics/src/main/kotlin/org/utbot/RegressionTrainer.kt
UnitTestBot
480,810,501
false
{"Kotlin": 6661796, "Java": 2209528, "Python": 223199, "Go": 99696, "C#": 80947, "JavaScript": 42483, "Shell": 15961, "HTML": 8704, "Batchfile": 8586, "Dockerfile": 2057}
package org.utbot import org.utbot.TrainRegressionModel.* import org.utbot.metrics.RegressionMetrics import org.utbot.models.SimpleRegression import org.utbot.models.SimpleRegressionNeuralNetworks import smile.data.DataFrame import smile.data.formula.Formula import smile.read class RegressionTrainer(data: DataFrame, ...
410
Kotlin
37
110
c7f2ac4286b9861485c67ad3b11cd14e2b3ab82f
2,596
UTBotJava
Apache License 2.0
kotlin/440.K-th Smallest in Lexicographical Order(字典序的第K小数字).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 integers <code>n</code> and <code>k</code>, find the lexicographically k-th smallest integer in the range from <code>1</code> to <code>n</code>.</p> <p>Note: 1 &le; k &le; n &le; 10<sup>9</sup>.</p> <p><b>Example:</b> <pre> <b>Input:</b> n: 13 k: 2 <b>Output:</b> 10 <b>Explanation:</b> The lexicograp...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
1,489
leetcode
MIT License
src/main/kotlin/dev/bogwalk/batch5/Problem58.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.maths.isPrimeMRBI /** * Problem 58: Spiral Primes * * https://projecteuler.net/problem=58 * * Goal: By repeatedly completing a new layer on a square spiral grid, as detailed below, find * the side length at which the ratio of primes along both diagonals first f...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,103
project-euler-kotlin
MIT License
leetcode/src/array/Offer21.kt
zhangweizhe
387,808,774
false
null
package array fun main() { // 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面 // https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/ println(exchange1(intArrayOf(1,3,2,4,5,6)).contentToString()) } private fun exchange(nums: IntArray): IntArray { val ret = IntArray(nums.si...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,491
kotlin-study
MIT License
app/src/main/java/com/binaryquackers/aoc2022/Day2PuzzleSolver.kt
MooseTheGoose
573,219,554
false
{"Kotlin": 16876}
package com.binaryquackers.aoc2022 import java.nio.charset.StandardCharsets class Day2PuzzleSolver: PuzzleSolver() { private enum class Result { Lose, Draw, Win; } private enum class Choice { Rock, Paper, Scissors; private fun idx(): Int { ...
0
Kotlin
0
0
d7f2d6df69dbd74c4d429247213e35da7409015c
3,153
aoc-2022-android
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/DetectCapital.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
1,875
kotlab
Apache License 2.0
src/main/kotlin/org/example/adventofcode/puzzle/Day01.kt
peterlambrechtDev
573,146,803
false
{"Kotlin": 39213}
package org.example.adventofcode.puzzle import org.example.adventofcode.util.FileLoader object Day01 { fun part1(filePath: String): Int { val stringLines = FileLoader.loadFromFile<String>(filePath) var currentSum = 0 var highestCalorie = 0 for (line in stringLines) { ...
0
Kotlin
0
0
aa7621de90e551eccb64464940daf4be5ede235b
1,736
adventOfCode2022
MIT License
src/main/kotlin/g1301_1400/s1382_balance_a_binary_search_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1382_balance_a_binary_search_tree // #Medium #Depth_First_Search #Greedy #Tree #Binary_Tree #Binary_Search_Tree #Divide_and_Conquer // #2023_06_06_Time_369_ms_(85.71%)_Space_42.9_MB_(92.86%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definiti...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,209
LeetCode-in-Kotlin
MIT License
2023/src/main/kotlin/net/daams/solutions/5a.kt
Michiel-Daams
573,040,288
false
{"Kotlin": 39925, "Nim": 34690}
package net.daams.solutions import net.daams.Solution class `5a`(input: String): Solution(input) { override fun run() { val splitInput = input.split("\n\n") val seeds = splitInput[0].removePrefix("seeds: ").split(" ").map{ it.toLong() } val maps = mutableListOf<List<Pair<LongRange, LongRa...
0
Kotlin
0
0
f7b2e020f23ec0e5ecaeb97885f6521f7a903238
1,482
advent-of-code
MIT License
2023/1/solve-2.kts
gugod
48,180,404
false
{"Raku": 170466, "Perl": 121272, "Kotlin": 58674, "Rust": 3189, "C": 2934, "Zig": 850, "Clojure": 734, "Janet": 703, "Go": 595}
import java.io.File val englishDigits = mapOf( "1" to 1, "2" to 2, "3" to 3, "4" to 4, "5" to 5, "6" to 6, "7" to 7, "8" to 8, "9" to 9, "one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7, "eight" to 8, "nine"...
0
Raku
1
5
ca0555efc60176938a857990b4d95a298e32f48a
701
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/co/csadev/advent2020/Day02.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2020, Day 2 * Problem Description: http://adventofcode.com/2020/day/2 */ package co.csadev.advent2020 class Day02(data: List<String>) { private val pattern = """^(\d+)-(\d+) (\w): (.+)$""".toRegex() private val input = data.mapNotNull { pattern.find(it) ...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
886
advent-of-kotlin
Apache License 2.0
src/main/kotlin/problems/Day10.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day10(override val input: String) : Problem { override val number: Int = 10 private val lines: List<Line> = input.lines().map { Line(it) } override fun runPartOne(): String { return lines .mapNotNull { line -> line.firstIllegalCharacter() } .sumOf { c...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
3,090
AdventOfCode2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/interview/BinaryTreeNode.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,377
kotlab
Apache License 2.0
simpleCalculator/Main.kt
victorYghor
610,409,660
false
null
package calculator val numbers = mutableListOf<Int>() fun Char.isOperator(): Boolean { return this == '+' || this == '-' } fun start() { val input = readln().split(' ').joinToString("") when (input) { "" -> start() "/exit" -> throw Exception() "/help" -> println( """Th...
0
Kotlin
0
0
0d30e37016cd2158d87de59f7cf17125627fc785
2,230
Kotlin-Problems
MIT License
src/main/kotlin/com/kishor/kotlin/algo/algorithms/tree/InSufficientPath.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.tree class TreeNode(var `val`: Int) { var left: TreeNode? = null var right: TreeNode? = null } fun sufficientSubset(root: TreeNode, limit: Int): TreeNode? { calculate(root, limit, 0) return if (root.`val` < limit && root.left == null && root.right ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,581
DS_Algo_Kotlin
MIT License
algorithm/src/main/java/com/danny/algorithm/RepeatNumber.kt
dannycx
310,445,112
false
{"Kotlin": 90927, "Java": 34893, "AIDL": 319}
package com.danny.algorithm /** * * @author danny * @since 2022/4/11 */ fun main() { // println(repeatNumber(intArrayOf(0, 2, 4, 4, 7 , 6, 5, 3))) // println(repeatNumberTwo(intArrayOf(1, 2, 5, 4, 3 , 6, 5, 3))) // println(Math.pow(2.0, 3.0)) Test.x3() } /** */ fun repeatNumber(array: IntArray?) :...
0
Kotlin
0
0
5fbfd4a5db1849d67817364b73f9c9e9b16a2e72
2,249
XTools
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ZigzagLevelOrder.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,781
kotlab
Apache License 2.0
src/Day01.kt
ph-pdy
572,944,630
false
{"Kotlin": 1269}
fun main() { fun part1(input: List<String>): Int = input.sumCalories().max() fun part2(input: List<String>): Int = input.sumCalories().apply { sortDescending() }.take(3).sum() // test if implementation meets criteria from the description, like: val testInput = readInput("Day01_test") ...
0
Kotlin
0
0
0559ae99769dbc20e12c5597c7888eda99b8d989
626
advent-of-code
Apache License 2.0
src/day02/Day02.kt
schrami8
572,631,109
false
{"Kotlin": 18696}
package day02 import readInput fun main() { val precalculated = hashMapOf( "A X" to 4, "A Y" to 8, "A Z" to 3, "B X" to 1, "B Y" to 5, "B Z" to 9, "C X" to 7, "C Y" to 2, "C Z" to 6 ) fun part1(input: List<String>): Int { r...
0
Kotlin
0
0
215f89d7cd894ce58244f27e8f756af28420fc94
988
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/io/array/VerifyIsSorted.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.array import io.utils.runTests // https://leetcode.com/problems/verifying-an-alien-dictionary/ class VerifyIsSorted { fun isAlienSorted(words: Array<String>, order: String): Boolean = execute(words, order) fun execute(words: Array<String>, order: String): Boolean { val orderMap = order.mapIndexed...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,371
coding
MIT License
y2022/src/main/kotlin/adventofcode/y2022/Day21.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day21 : AdventSolution(2022, 21, "Monkey Math") { override fun solvePartOne(input: String): Long { val instructions = mutableMap(input) return instructions.getValue("root")() } override fun solvePartTwo(input: Str...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,680
advent-of-code
MIT License
games-core/src/main/kotlin/net/zomis/games/dsl/DslSplendor.kt
Tejpbit
260,966,032
true
{"Kotlin": 395303, "Vue": 83692, "JavaScript": 27193, "Java": 17130, "CSS": 3871, "HTML": 1358, "Dockerfile": 228}
package net.zomis.games.dsl data class Player(var chips: Money = Money(), val owned: MutableSet<Card> = mutableSetOf(), val reserved: MutableSet<Card> = mutableSetOf()) { fun total(): Money = this.discounts() + this.chips fun canBuy(card: Card): Boolean = this.total().has(card.costs) fu...
0
null
0
0
cb1cafb4d5ae5c09a9edb336f04ef7cf48ee2714
8,421
Server2
MIT License
Contiguous_Array.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import kotlin.math.max class Solution { fun findMaxLength(nums: IntArray): Int { if (nums.size <= 1) return 0 val minIndex = HashMap<Int, Int>() minIndex[0] = -1 var count = if (nums[0] == 1) 1 else -1 minIndex[count] = 0 var longestLength = 0 for (i in 1..nu...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
831
leetcode
MIT License
app/src/test/java/com/edgar/movie/demo_study/collections/CollectionFunctionInKotlin.kt
edgardeng
267,626,303
false
null
import org.junit.Test class CollectionFunctionInKotlin { @Test fun main (){ // filter function enables you to filter collections val numbers = listOf(1, -2, 3, -4, 5, -6) // 1 val positives = numbers.filter { x -> x > 0 } // 2 val negatives = numbers.filter { it < 0 } ...
0
Kotlin
1
4
d8b3f740d2f564817ac1ffebe000f952cb175361
6,576
good-kotlin-app
MIT License