path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/year2015/day03/Day03.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day03 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2015", "Day03_test") check(part1(testInput), 4) check(part2(testInput), 3) val input = readInput("2015", "Day03") println(part1(inp...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,372
AdventOfCode
Apache License 2.0
src/y2022/Day17.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.Direction import util.PosL import util.readInput import java.lang.Long.max object Day17 { const val CHAMBER_WIDTH = 7 enum class Shape(grid: List<String>) { FLOOR(listOf("████")), PLUS(listOf(" █ ", "███", " █ ")), CORNER(listOf("███", " █", " █")), // ! re...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
5,508
advent-of-code
Apache License 2.0
src/Day05.kt
vladislav-og
573,326,483
false
{"Kotlin": 27072}
fun main() { fun extractData(row: String, stacks: ArrayList<ArrayDeque<String>>) { val regex = Regex("\\d+") val (n, stackFrom, stackTo) = regex.findAll(row).map { c -> c.value.toInt() - 1 }.toList() for (i in 0..n) { val removeFirst = stacks[stackFrom].removeFirst() ...
0
Kotlin
0
0
b230ebcb5705786af4c7867ef5f09ab2262297b6
2,819
advent-of-code-2022
Apache License 2.0
src/Day20.kt
IvanChadin
576,061,081
false
{"Kotlin": 26282}
import java.util.* import kotlin.math.abs fun main() { val inputName = "Day20_test" fun part1(): Long { val list = readInput(inputName).mapIndexed { i, s -> Pair(i, s.toLong()) } val indexes = ArrayList(list.indices.toList()) for (i in list.indices) { var j = indexes[i] ...
0
Kotlin
0
0
2241437e6c3a20de70306a0cb37b6fe2ed8f9e3a
2,195
aoc-2022
Apache License 2.0
src/Day01.kt
Derrick-Mwendwa
573,947,669
false
{"Kotlin": 8707}
fun main() { fun part1(input: List<String>): Int { val calories = input.joinToString("\n").split("\n\n").map { it.lines().sumOf { line -> line.toInt() } } return calories.max() } fun part2(input: List<String>): Int { val calories = inp...
0
Kotlin
0
1
7870800afa54c831c143b5cec84af97e079612a3
779
advent-of-code-kotlin-2022
Apache License 2.0
src/hongwei/leetcode/playground/leetcodecba/M54SpiralMatrix.kt
hongwei-bai
201,601,468
false
{"Java": 143669, "Kotlin": 38875}
package hongwei.leetcode.playground.leetcodecba class M54SpiralMatrix { companion object { const val OFF = 444 } fun test() { val input = arrayOf(intArrayOf(1, 2, 3), intArrayOf(4, 5, 6), intArrayOf(7, 8, 9)) val answer = listOf(1, 2, 3, 6, 9, 8, 7, 4, 5) val result = spir...
0
Java
0
1
9d871de96e6b19292582b0df2d60bbba0c9a895c
3,445
leetcode-exercise-playground
Apache License 2.0
src/main/kotlin/string/MinimumWindowSubstring.kt
ghonix
88,671,637
false
null
package string /* https://leetcode.com/problems/minimum-window-substring/ */ class MinimumWindowSubstring { val tMap = HashMap<Char, Int>() private fun isAcceptable(map: HashMap<Char, Int>): Boolean { for (key in map.keys) { if (map[key]!! > 0) { return false }...
0
Kotlin
0
2
25d4ba029e4223ad88a2c353a56c966316dd577e
2,451
Problems
Apache License 2.0
src/main/kotlin/dp/LargestPattern.kt
yx-z
106,589,674
false
null
package dp import math.isPrime import util.* // given a bitmap as a 2d array, identify the largest rectangular pattern that appear more than once // the copies of a pattern may overlap but cannot coincide // report its size fun main(args: Array<String>) { val bitmap = arrayOf( intArrayOf(0, 1, 0, 0, 0), intArr...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
3,286
AlgoKt
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day18.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.* fun main() = Day18.run() object Day18 : Day(2015, 18) { override fun part1(): Any { var lMap = toMap(input) val alwaysOn = listOf<P<Int, Int>>() repeat(100) {lMap = switchLights(lMap, alwaysOn)} return lMap.values.co...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,592
adventofkotlin
MIT License
src/main/kotlin/th/in/jamievl/adventofcode/d2/Day2.kt
jamievlin
578,295,680
false
{"Kotlin": 8145, "Starlark": 4278}
package th.`in`.jamievl.adventofcode.d2 import th.`in`.jamievl.adventofcode.common.readFromResource import java.lang.IllegalArgumentException enum class WinState { LOSE, WIN, DRAW } enum class RpsPlay { ROCK, PAPER, SCISSORS; fun calculateOutcomePartScore() = when (this) { ROCK -> 1 SC...
0
Kotlin
0
0
4b0f5a8e6bcc411f1a76cfcd6d099872cf220e46
3,249
adventofcode-2022
MIT License
src/main/kotlin/com/colinodell/advent2022/Day25.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import kotlin.math.pow class Day25(private val input: List<String>) { fun solvePart1() = input.sumOf { snafuToDecimal(it) }.toSnafu() companion object { private val digitMap = mapOf( '=' to -2L, '-' to -1L, '0' to 0L, '...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,208
advent-2022
MIT License
src/Day08.kt
ChristianNavolskyi
573,154,881
false
{"Kotlin": 29804}
class Day08 : Challenge<Int> { override val name: String get() = "Day 08" override fun inputName(): String = "Day08" override fun testInputName(): String = "Day08_test" override fun testResult1(): Int = 21 override fun testResult2(): Int = 8 override fun part1(input: String): Int { ...
0
Kotlin
0
0
222e25771039bdc5b447bf90583214bf26ced417
3,864
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d11/Day11.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d11 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.points.Point import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines import kotlin.math.exp import kotlin.math.max import kotlin.math.min val galaxies = mutableListOf<Point>(...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,542
advent-of-code
MIT License
src/cn/leetcode/codes/simple20/Simple20_2.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple20 import cn.leetcode.codes.out import java.util.HashMap /* 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 注意空字符串可被认为是有效字符串。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/valid-parentheses 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 */ fun ...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,516
LeetCodeSimple
Apache License 2.0
src/Day01.kt
Vincentvibe3
573,202,573
false
{"Kotlin": 8454}
fun main() { fun part1(input: List<String>): Int { var max = -1 var currentElf = 0 for (line in input) { if (line.isBlank()){ if (currentElf>max){ max = currentElf } currentElf = 0 } else{ ...
0
Kotlin
0
0
246c8c43a416023343b3ef518ae3e21dd826ee81
1,017
advent-of-code-2022
Apache License 2.0
src/net/sheltem/aoc/y2021/Day03.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2021 suspend fun main() { Day03().run() } class Day03 : Day<Long>(198, 230) { override suspend fun part1(input: List<String>): Long = input .toBits() .let { it.first.toDecimal() to it.second.toDecimal() } .let { it.first * it.second } override suspend fun...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,502
aoc
Apache License 2.0
src/main/kotlin/Day4.kt
ueneid
575,213,613
false
null
class Day4(val inputs: List<String>) { fun solve1(): Int { return inputs.asSequence() .map { line -> line.split(",") .flatMap { it.split("-") } .map { it.toInt() } } .count { it[0] <= it[2] && it[3] <= it[1] || it[2]...
0
Kotlin
0
0
743c0a7adadf2d4cae13a0e873a7df16ddd1577c
836
adventcode2022
MIT License
src/day18/b/day18b.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day18.b import day18.a.Side import day18.a.read import inBounds import repeatUntilEmpty import shouldBe import util.IntVector import vec fun main() { val dir = listOf( vec(1,0,0), vec(0,1,0), vec(0,0,1), ) val cubes = read() // Bounding box with an added margin of 1 ...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,300
advent-of-code-2022
Apache License 2.0
src/Day01.kt
hadiamin
572,509,248
false
null
fun main() { fun part1(input: List<String>): Int { val sumedList = mutableListOf<Int>() var sum = 0 for (item in input) { if (item != "") { sum += item.toInt() } else { sumedList.add(sum) sum = 0 } } ...
0
Kotlin
0
0
e63aea2a55b629b9ac3202cdab2a59b334fb7041
982
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/NumEquivDominoPairs.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 1128. 等价多米诺骨牌对的数量 * * 给你一个由一些多米诺骨牌组成的列表 dominoes。 * * 如果其中某一张多米诺骨牌可以通过旋转 0 度或 180 度得到另一张多米诺骨牌,我们就认为这两张牌是等价的。 * * 形式上,dominoes[i] = [a, b] 和 dominoes[j] = [c, d] 等价的前提是 a==c 且 b==d,或是 a==d 且 b==c。 * * 在 0 <= i < j < dominoes.length 的前提下,找出满足 dominoes[i] 和 dominoes[j] ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,406
daily_algorithm
Apache License 2.0
src/day14/day14.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
package day14 import streamInput //val file = "Day14Example" val file = "Day14" data class Point(val x: Int, val y: Int) fun Sequence<String>.parseInput(): Sequence<List<Point>> { return map { line -> line.split(" -> ").map { it.split(',') }.map { (x, y) -> Point(x.toInt(), y.toInt()) } } } enum cl...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
3,680
aoc-2022
Apache License 2.0
src/day3/Solution.kt
Zlate87
572,858,682
false
{"Kotlin": 12960}
package day3 import readInput fun main() { fun getIntValue(it: Char) = if (it.isLowerCase()) it.toInt() - 96 else it.toInt() - 38 fun getValue1(line: String): Int { val substring1 = line.substring(0, line.length / 2) val substring2 = line.substring(line.length / 2) substring1.forEach...
0
Kotlin
0
0
57acf4ede18b72df129ea932258ad2d0e2f1b6c3
1,120
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g2201_2300/s2209_minimum_white_tiles_after_covering_with_carpets/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2209_minimum_white_tiles_after_covering_with_carpets // #Hard #String #Dynamic_Programming #Prefix_Sum // #2023_06_27_Time_373_ms_(100.00%)_Space_40_MB_(100.00%) class Solution { fun minimumWhiteTiles(floor: String, numCarpets: Int, carpetLen: Int): Int { val len = floor.length ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,574
LeetCode-in-Kotlin
MIT License
solver/src/main/kotlin/dev/mrichter/mapf/solver/CTSolver.kt
matyasrichter
493,165,334
false
{"Kotlin": 51082}
package dev.mrichter.mapf.solver import dev.mrichter.mapf.graph.Agent import java.util.* class ConstraintTreeNode<CT>( val parent: ConstraintTreeNode<CT>?, val vertexConstraint: VertexConstraint<CT>?, val edgeConstraint: EdgeConstraint<CT>?, val agentId: UUID, val solution: List<List<CT>>, val...
0
Kotlin
0
0
2ef0b766ab91087fb2b51d01e058c9fb2f6abbaf
6,930
mapf-cbs
MIT License
src/main/kotlin/heap/top_k_frequent/TopKFrequentElements.kt
Pawlllosss
526,668,214
false
{"Kotlin": 61939}
package heap.top_k_frequent import java.util.* fun topKFrequent(nums: IntArray, k: Int): IntArray { val frequencyByNumber = getFrequencyByNumber(nums) val numbersSortedByFrequency = PriorityQueue<Pair<Int, Int>> { pair1, pair2 -> pair2.first - pair1.first } frequencyByNumber.forEach { (key, value) -> num...
0
Kotlin
0
0
94ad00ca3e3e8ab7a2cb46f8846196ae7c55c8b4
1,197
Kotlin-algorithms
MIT License
kotlin/structures/FenwickTree2D.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures object FenwickTree2D { fun add(t: Array<IntArray>, r: Int, c: Int, value: Int) { var i = r while (i < t.size) { var j = c while (j < t[0].length) { t[i][j] += value j = j or j + 1 } i = i or i + 1 ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,344
codelibrary
The Unlicense
2021/src/main/kotlin/Day03.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day03(private val input: List<String>) { private fun List<String>.bitwiseFilter(keepMostCommon: Boolean, width: Int): String = (0 until width).fold(this) { inputs, column -> if (inputs.size == 1) inputs else { val split = inputs.partition { it[column] == '1' } ...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,010
adventofcode-2021-2025
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-24.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import java.util.* fun main() { val input = readInputLines(2021, "24-input") println("Part1:") part1(input).println() println() println("Part2:"...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,143
advent-of-code
MIT License
gcj/y2020/kickstart_b/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.kickstart_b import kotlin.math.pow private fun solve(): Double { val (w, h, x1, y1, x2, y2) = readInts() return solve(x1 - 1, y2 - 1, h) + solve(y1 - 1, x2 - 1, w) } private fun solve(x: Int, y: Int, h: Int): Double { if (y + 1 >= h) return 0.0 var res = 0.0 var c = 1.0 var p = x + y for (i ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
784
competitions
The Unlicense
src/main/kotlin/com/github/solairerove/algs4/leprosorium/dynamic_programming/EditDistance.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.dynamic_programming import kotlin.math.min fun main() { println(minDistance("horse", "ros")) // 3 println(minDistance("abc", "zabd")) // 2 } // O(nm) time | O(nm) space private fun minDistance(word1: String, word2: String): Int { val n1 = word1.length ...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,030
algs4-leprosorium
MIT License
src/main/kotlin/helpthebookseller/StockList.kt
borisskert
492,139,934
false
{"Kotlin": 11866}
package solution /** * https://www.codewars.com/kata/54dc6f5a224c26032800005c/train/kotlin */ object StockList { fun stockSummary(lstOfArt: Array<String>, lstOfCat: Array<String>): String { if (lstOfArt.isEmpty()) { return "" } val stock = lstOfArt .map(::readOne)...
0
Kotlin
0
0
0659b332819751d7d89a7cf5f8239d17b7245c28
1,114
kotlin-katas
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2022/Day20.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.math.abs import kotlin.test.assertEquals class Day20 : AbstractDay() { @Test fun part1Test() { assertEquals(3, compute1(testInput)) } @Test fun part1Puzzle() { assertEqual...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,985
aoc
Apache License 2.0
src/Day06.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
fun String.findMarker(markerSize: Int) = windowed(markerSize) .first { window -> val repeatedChar = window.find { testedChar -> window.count { testedChar == it } > 1 } repeatedChar == null } fun main() { fun part1(input: String): Int { val marker = input.findMark...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
1,199
advent-of-code-2022
Apache License 2.0
src/Day03.kt
tomoki1207
572,815,543
false
{"Kotlin": 28654}
fun main() { val types = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun part1(input: List<String>) = input.map { line -> val items = line.chunked(line.length / 2) items[0].toCharArray().intersect(items[1].toCharArray().toSet()) }.sumOf { shared -> shared.sumOf { types.in...
0
Kotlin
0
0
2ecd45f48d9d2504874f7ff40d7c21975bc074ec
855
advent-of-code-kotlin-2022
Apache License 2.0
advent-of-code-2023/src/test/kotlin/Day8Test.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test class Day8Test { private val testInput2 = """RL AAA = (BBB, CCC) BBB = (DDD, EEE) CCC = (ZZZ, GGG) DDD = (DDD, DDD) EEE = (EEE, EEE) GGG = (GGG, GGG) ZZZ = (ZZZ, ZZZ) """ private val testInput6 = """LLR AAA = (BBB, BBB) BBB = (AAA, ZZZ) ...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,614
advent-of-code
MIT License
2020/src/main/kotlin/Day2.kt
osipxd
388,214,845
false
null
/** * # Day 2: Password Philosophy * * Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here * is via [toboggan](https://en.wikipedia.org/wiki/Toboggan). * * The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with * our ...
0
Kotlin
0
0
66553923d8d221bcd1bd108f701fceb41f4d1cbf
3,781
advent-of-code
MIT License
kotlin/src/com/s13g/aoc/aoc2015/Day13.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2015 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom /** * --- Day 13: Knights of the Dinner Table --- * https://adventofcode.com/2015/day/13 */ class Day13 : Solver { override fun solve(lines: List<String>): Result { val diffs = mutableMapOf<Set<S...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,643
euler
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d22/Day22.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d22 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.mapWithPutDefault import com.groundsfam.advent.rangeIntersect import com.groundsfam.advent.timed import java.util.TreeSet import kotlin.io.path.div import kotlin.io.path.useLines private data class Brick(val x:...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
4,399
advent-of-code
MIT License
kotlin/src/com/s13g/aoc/aoc2022/Day2.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom /** * --- Day 2: Rock Paper Scissors --- * https://adventofcode.com/2022/day/2 */ class Day2 : Solver { override fun solve(lines: List<String>): Result { val beats = mapOf(1 to 3, 2 to 1, 3 to 2)...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,078
euler
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestIncreasingPath.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
3,393
kotlab
Apache License 2.0
day12/src/main/kotlin/ver_b.kt
jabbalaci
115,397,721
false
null
package b import java.io.File object Groups { /* A feltárt csoportokat egy listában tároljuk. A lista elemei halmazok, ezek a halmazok az egyes csoportok. */ private val groups = mutableListOf<Set<Int>>() /* Ha a start pl. 0, akkor elindul a 0-tól, s feltárja, hogy a linkeket követv...
0
Kotlin
0
0
bce7c57fbedb78d61390366539cd3ba32b7726da
2,410
aoc2017
MIT License
src/year2022/day23/Day23.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day23 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day23_test") check(part1(testInput), 110) check(part2(testInput), 20) val input = readInput("2022", "Day23") println(part1(...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
4,767
AdventOfCode
Apache License 2.0
app/src/main/java/com/softaai/dsa_kotlin/graph/dijkstra/Dijkstra.kt
amoljp19
537,774,597
false
{"Kotlin": 139041}
package com.softaai.dsa_kotlin.graph.dijkstra import com.softaai.dsa_kotlin.graph.Edge import com.softaai.dsa_kotlin.graph.Graph import com.softaai.dsa_kotlin.graph.Vertex import com.softaai.dsa_kotlin.graph.adjacencylist.AdjacencyListGraph import com.softaai.dsa_kotlin.priorityqueue.ComparatorPriorityQueueImpl /** ...
0
Kotlin
0
1
3dabfbb1e506bec741aed3aa13607a585b26ac4c
3,016
DSA_KOTLIN
Apache License 2.0
aoc_2023/src/main/kotlin/problems/day22/SandBrickSimulator.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day22 class SandBrickSimulator(lines: List<String>) { var bricks = lines.map { line -> val (coord1, coord2) = line.split("~").map { coordStr -> val splitCoord = coordStr.split(",").map { it.toLong() } Coordinate(splitCoord[0], splitCoord[1], splitCoord[2]) ...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
2,415
advent-of-code-2023
MIT License
src/main/kotlin/dev/bogwalk/batch3/Problem40.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import kotlin.math.pow /** * Problem 40: Champernowne's Constant * * https://projecteuler.net/problem=40 * * Goal: Calculate the value of the expression d_i1 * d_i2 * .. d_i7 if d_in represents the nth * digit of the fractional part of Champernowne's Constant. * * Constraints: 1 <= ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,016
project-euler-kotlin
MIT License
src/algorithmsinanutshell/networkflow/FordFulkersonAlgorithm.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell.networkflow import kotlin.test.assertEquals /** * Algorithm to find the max flow to the sink in a given [network] * * https://brilliant.org/wiki/ford-fulkerson-algorithm/ * * https://www.youtube.com/watch?v=NwenwITjMys * * O(E*mf) where E=edge, mf=value of max flow */ class Ford...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,190
algorithms
MIT License
src/main/java/com/booknara/problem/union/NumberOfProvincesKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.union /** * 547. Number of Provinces (Medium) * https://leetcode.com/problems/number-of-provinces/ */ class NumberOfProvincesKt { // T:O(n*n*logn), S:O(n) fun findCircleNum(isConnected: Array<IntArray>): Int { // input check val n = isConnected.size val roots = IntArray...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,329
playground
MIT License
Kotlin/src/main/kotlin/org/algorithm/problems/0011_evaluate_division.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
//Problem Statement // Equations are given in the format A / B = k, where A and B are variables // represented as strings, and k is a real number (floating point number). // Given some queries, return the answers. If the answer does not exist, return -1.0. // // Example: // Given a / b = 2.0, b / c = 3.0. // queries a...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
2,919
algorithms
MIT License
src/main/kotlin/wk271/Problem3.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package wk271 fun main() { // val res = Problem3().minimumRefill(intArrayOf(2,2,3,3), 5 ,5) // val res = Problem3().minimumRefill(intArrayOf(2,2,3,3), 3 ,4) val res = Problem3().minimumRefill(intArrayOf(2, 2, 5, 2, 2), 5, 5) println(res) } class Problem3 { fun minimumRefill(plants: IntArray, capacit...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
1,752
leetcode-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem148/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem148 import com.hj.leetcode.kotlin.common.model.ListNode /** * LeetCode page: [148. Sort List](https://leetcode.com/problems/sort-list/); */ class Solution2 { /* Complexity: * Time O(NLogN) and Space O(1) where N is the number of nodes in head; */ fun sortList(...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,730
hj-leetcode-kotlin
Apache License 2.0
src/main/day16/State.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day16 import java.lang.IllegalArgumentException import java.lang.IllegalStateException data class State(val openers: List<ValveOpener>, val valves: List<Valve>) { fun potentialMax(timeLimit: Int, distances: Map<Pair<String, String>, Int>): Int { var remainingTime = (timeLimit * openers.size) - op...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
2,581
aoc2022
Apache License 2.0
src/day10/Day10.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day10 import addOrSet import getOrAdd import readInput fun main() { val testInput = readInput("day10_test") check(resolve(testInput, true, 20, 60, 100, 140, 180, 220) == 13140) println() val input = readInput("day10") println(resolve(input, true, 20, 60, 100, 140, 180, 220)) // FBURHZCH...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
1,839
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day04.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day import kotlin.math.pow class Day04(input: String? = null) : Day(4, "Scratchcards", input) { private val scratchcard = ".*:(.*)\\|(.*)".toRegex() override fun partOne() = inputList.sumOf { line -> scratchcard.find(line) ?.destructured ...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
1,322
advent-of-code-2023
MIT License
src/Day20.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day20.printSolutionIfTest(3, 1623178306) } object Day20 : Day<Long, Long>(20) { override fun part1(lines: List<String>) = solve(lines,1,1) override fun part2(lines: List<String>) = solve(lines, 10, 811589153L) private fun solve(lines: List<String>, reps: Int, key: Long): Long { va...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
930
advent-of-code-2022
Apache License 2.0
aoc_2023/src/main/kotlin/problems/day4/Scratchcards.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day4 import kotlin.math.pow class Scratchcards(val scratchcards: Array<Scratchcard>) { companion object { fun fromLines(lines: List<String>): Scratchcards { val scratchcards: Array<Scratchcard> = lines.map { line -> val (card, numbers) = line.split(':') ...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
1,848
advent-of-code-2023
MIT License
2022/kotlin-lang/src/main/kotlin/mmxxii/days/Day14.kt
Delni
317,500,911
false
{"Kotlin": 66017, "Dart": 53066, "Go": 28200, "TypeScript": 7238, "Rust": 7104, "JavaScript": 2873}
package mmxxii.days import java.awt.Point import kotlin.math.sign class Day14 : Abstract2022<Int>("14", "Regolith Reservoir") { override fun part1(input: List<String>): Int = input .map(String::toPath) .let { paths -> val grid = mutableSetOf<Point>() grid.addPaths(paths) ...
0
Kotlin
0
1
d8cce76d15117777740c839d2ac2e74a38b0cb58
3,059
advent-of-code
MIT License
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day10/Day10.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day10 import eu.janvdb.aocutil.kotlin.readLines import java.util.* const val FILENAME = "input10.txt" val MATCHING_CHARS = mapOf(Pair('(', ')'), Pair('{', '}'), Pair('[', ']'), Pair('<', '>')) val SCORES1 = mapOf(Pair(')', 3L), Pair(']', 57L), Pair('}', 1197L), Pair('>', 25137L)) val SCORES...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,282
advent-of-code
Apache License 2.0
src/Day09.kt
ChristianNavolskyi
573,154,881
false
{"Kotlin": 29804}
import kotlin.math.absoluteValue import kotlin.math.ceil import kotlin.math.sign class Day09 : Challenge<Int> { override val name: String get() = "Day 09" override fun inputName(): String = "Day09" override fun testInputName(): String = "Day09_test" override fun testInputName2(): String = "D...
0
Kotlin
0
0
222e25771039bdc5b447bf90583214bf26ced417
4,884
advent-of-code-2022
Apache License 2.0
Kotlin-Knn/src/main/kotlin/dataKNN.kt
JUSTNic3
739,087,623
false
{"Kotlin": 11542}
import kotlin.math.* import com.github.doyaaaaaken.kotlincsv.dsl.csvReader data class KNNMovie( val name: String, val genre: String, val crew: String, val language: String ) class KNNAlgorithm( private val movies: List<KNNMovie>, private val k: Int = 5 ) { fun findNearestNeighbors(input: K...
0
Kotlin
0
0
2c74d4e143d082a61c8a72de9b1c8469fdf82b30
3,258
Kotlin-Knn
MIT License
src/adventofcode/Day12.kt
Timo-Noordzee
573,147,284
false
{"Kotlin": 80936}
package adventofcode import org.openjdk.jmh.annotations.* import java.util.* import java.util.concurrent.TimeUnit import kotlin.collections.ArrayDeque private typealias Grid = Array<IntArray> private operator fun Array<IntArray>.get(point: Point): Int = this[point.y][point.x] private class Terrain( val start: Po...
0
Kotlin
0
2
10c3ab966f9520a2c453a2160b143e50c4c4581f
3,133
advent-of-code-2022-kotlin
Apache License 2.0
src/day1/Day01.kt
kongminghan
573,466,303
false
{"Kotlin": 7118}
package day1 import readInput fun main() { fun highestSumCalories(input: List<String>, limit: Int): Int { return input .foldIndexed(mutableListOf<MutableList<Int>>(mutableListOf())) { _, acc, item -> if (item == "") { acc.add(mutableListOf()) ...
0
Kotlin
0
0
f602900209712090778c161d407ded8c013ae581
1,086
advent-of-code-kotlin
Apache License 2.0
advent-of-code-2022/src/main/kotlin/year_2022/Day16.kt
rudii1410
575,662,325
false
{"Kotlin": 37749}
package year_2022 import util.Runner import java.util.Stack import kotlin.math.min data class Node1(val label: String, val rate: Int, val child: MutableList<Node1>) fun main() { /* Part 1 */ fun part1(input: List<String>): Int { val map = mutableMapOf<String, Pair<Int, List<String>>>() val v...
1
Kotlin
0
0
ab63e6cd53746e68713ddfffd65dd25408d5d488
1,959
advent-of-code
Apache License 2.0
src/util/algorithms/LineSimplification.kt
JBWills
291,822,812
false
null
package util.algorithms import coordinate.Point import coordinate.Segment import util.numbers.times import util.polylines.PolyLine import util.polylines.iterators.mapBySegment import util.tuple.map import java.util.LinkedList import java.util.Queue fun PolyLine.douglassPeucker(epsilon: Double): PolyLine { // Find ...
0
Kotlin
0
0
569b27c1cb1dc6b2c37e79dfa527b9396c7a2f88
2,380
processing-sketches
MIT License
Collections/Sum/src/Task.kt
diskostu
554,658,487
false
{"Kotlin": 36179}
// Return the sum of prices for all the products ordered by a given customer fun moneySpentBy(customer: Customer): Double = customer.orders.flatMap { it.products }.sumOf { it.price } fun main() { // demo code to find the solutions val shop = createSampleShop() val customer = shop.customers[0] val...
0
Kotlin
0
0
3cad6559e1add8d202e15501165e2aca0ee82168
1,271
Kotlin_Koans
MIT License
samples/camera/camera2/src/main/java/com/example/platform/camera/common/CameraSizes.kt
Anglemmj7
652,373,352
false
null
/* * Copyright 2023 The Android Open Source Project * * 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 * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
0
Kotlin
0
0
f4e8993b7052082f03f0d8f787ecea862e7b8c3a
3,174
Android-
Apache License 2.0
src/Day05.kt
rounakdatta
540,743,612
false
{"Kotlin": 19962}
fun parseLine(input: String): Pair<Pair<Int, Int>, Pair<Int, Int>> { return input.split(" -> ") .map { it -> it.split(",") } .map { it -> Pair(it.first().toInt(), it.last().toInt()) } .let { Pair(it.first(), it.last()) } } fun drawStraightLineOnChart(chart: MutableList<M...
0
Kotlin
0
1
130d340aa4c6824b7192d533df68fc7e15e7e910
5,671
aoc-2021
Apache License 2.0
src/main/kotlin/Day23.kt
clechasseur
258,279,622
false
null
import org.clechasseur.adventofcode2019.Day23Data import org.clechasseur.adventofcode2019.IntcodeComputer object Day23 { private val input = Day23Data.input fun part1(): Long { val computers = List(50) { idx -> IntcodeComputer(input, idx.toLong()) } val queues = List(50) { mutableListOf<Packet...
0
Kotlin
0
0
187acc910eccb7dcb97ff534e5f93786f0341818
2,658
adventofcode2019
MIT License
src/main/kotlin/days/aoc2020/Day14.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2020 import days.Day class Day14: Day(2020, 14) { override fun partOne(): Any { val memory = mutableMapOf<Long,Long>() var bitMaskClear = 0L var bitMaskSet = 0L inputList.forEach { instruction -> when { instruction.startsWith("mask") -> ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,720
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day11.kt
Misano9699
572,108,457
false
null
var monkeys: MutableList<Monkey> = mutableListOf() var reliefModifier = 0L var keepInCheck = 1L fun main() { fun reset() { monkeys = mutableListOf() keepInCheck = 1L } fun listOfItems(line: String): MutableList<Long> = line.replace(" ", "").split(",").map { it.toLong() }.toMutableList() ...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
4,369
advent-of-code-2022
Apache License 2.0
src/main/kotlin/leetcode/Problem2231.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/largest-number-after-digit-swaps-by-parity/ */ class Problem2231 { fun largestInteger(num: Int): Int { val oddIndexes = mutableListOf<Int>() val evenIndexes = mutableListOf<Int>() val numString = num.toString() for ((i, n) in nu...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,392
leetcode
MIT License
src/Day03.kt
joshpierce
573,265,121
false
{"Kotlin": 46425}
import java.io.File fun main() { // read the lines from the file var lines: List<String> = File("Day03.txt").readLines() // sum up the total of all priorities var total: Int = lines.map { // Find the priority by intersecting the two lists of items to get the common item //...
0
Kotlin
0
1
fd5414c3ab919913ed0cd961348c8644db0330f4
1,697
advent-of-code-22
Apache License 2.0
src/day03/Day03.kt
scottpeterson
573,109,888
false
{"Kotlin": 15611}
fun Char.toValue() = if (code <= 'Z'.code) this - 'A' + 27 else this - 'a' + 1 fun partOne(input: List<String>): Int { val result = input .map { rucksack -> rucksack.chunked(rucksack.length / 2) } .map { (compartment1, compartment2) -> compartment1.first { it in compartment2 } } .sumOf { it...
0
Kotlin
0
0
0d86213c5e0cd5403349366d0f71e0c09588ca70
713
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/array/ReverseWordsInString.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.array import io.utils.runTests import kotlin.math.absoluteValue // https://leetcode.com/explore/learn/card/array-and-string/204/conclusion/1164/ class ReverseWordsInString { fun execute(phrase: String): String { val input = generateStringBuilderWithoutExtraSpaces(phrase) var startFirst = 0 ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
3,781
coding
MIT License
solutions/src/FindHighestPeak.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/map-of-highest-peak/ * * Time Limit Exceeded, but same O(N) complexity (O(m*n)) as accepted solution */ class FindHighestPeak { fun highestPeak(isWater: Array<IntArray>): Array<IntArray> { val queue = mutableListOf<Space>() val visited = mutableSetOf<Pair<Int...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,521
leetcode-solutions
MIT License
src/main/kotlin/co/csadev/advent2021/Day09.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 9 * Problem Description: http://adventofcode.com/2021/day/9 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point2D import co.csadev.adventOfCode.Resources.resourceAsList import co.csadev.adventOfCode....
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,545
advent-of-kotlin
Apache License 2.0
Project/GameOfBones.kts
HKhademian
388,339,870
false
{"C++": 121772, "Python": 5608, "CMake": 2456, "Kotlin": 1815, "C": 14}
#! kotlinc -script // https://kotlinlang.org/docs/command-line.html#run-scripts // https://www.baeldung.com/java-minimax-algorithm object GameOfBones { fun getPossibleStates(noOfBonesInHeap: Int): List<Integer> { return (1..3) .map { noOfBonesInHeap - it } .filter { it >= 0 }.toList() } fun constructTree(...
0
C++
0
0
0abfe552ce863338a04e4efc38d3e87c31a99013
1,815
UniGameDev
The Unlicense
src/test/kotlin/leetcode/hackercub/ProblemA2.kt
Magdi
390,731,717
false
null
package leetcode.hackercub import java.io.File import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet class ProblemA2 { fun minSeconds(s: String, edges: List<String>): Int { val graph = HashMap<Char, HashSet<Char>>() edges.forEach { val adj = graph.getOr...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
2,380
ProblemSolving
Apache License 2.0
2023/src/main/kotlin/net/daams/solutions/3b.kt
Michiel-Daams
573,040,288
false
{"Kotlin": 39925, "Nim": 34690}
package net.daams.solutions import net.daams.Solution class `3b`(input: String): Solution(input) { val gears: MutableList<List<Int>> = mutableListOf() var splitInput: List<String> = listOf() override fun run() { val gearRatios: MutableList<Int> = mutableListOf() splitInput = input.split(...
0
Kotlin
0
0
f7b2e020f23ec0e5ecaeb97885f6521f7a903238
2,068
advent-of-code
MIT License
src/star05.kt
a-red-christmas
112,728,147
false
null
import java.lang.Math.abs import java.lang.Math.pow import kotlin.math.roundToInt import kotlin.math.sqrt fun main(args: Array<String>) { println(findManhattanDistance(368078)) } fun findManhattanDistance(start: Int) : Int { val size = getSpiralArraySize(start) val center = getSpiralArrayCenter(size) // q...
0
Kotlin
0
0
14e50f42c6550110b7007088af96f0260f4ac887
1,373
aoc2017-kt
Apache License 2.0
artifactfinder/src/main/kotlin/com/birbit/artifactfinder/VersionSelector.kt
yigit
209,722,505
false
null
/* * Copyright 2019 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
27
Kotlin
5
190
ee9f2870d32b8e438f36f0c405473edff28b6b3e
3,129
ArtifactFinder
Apache License 2.0
tmp/arrays/youTrackTests/8578.kt
vitekkor
600,111,569
true
{"Kotlin": 11763351, "JavaScript": 2761845, "ANTLR": 28803, "Java": 12579}
// Original bug: KT-20373 import java.util.Stack fun sumSubsets(arr: MutableList<Int>, num: Int): MutableList<MutableList<Int>> { class Subset(val indexes: IntArray) { fun add(index: Int) = Subset(indexes + index) fun values() = indexes.map { arr[it] } fun sum() = values().sum() fun missingValues()...
1
Kotlin
12
0
f47406356a160ac61ab788f985b37121cc2e2a2a
1,293
bbfgradle
Apache License 2.0
src/Day09.kt
RickShaa
572,623,247
false
{"Kotlin": 34294}
import java.util.* import kotlin.collections.ArrayDeque import kotlin.math.abs import kotlin.math.sign fun main() { val fileName = "day09.txt" val testFileName = "day09_test.txt" val input = FileUtil.getListOfLines(fileName) fun moveHead(move: String, head: Point) { when (Direction.valueOf(mov...
0
Kotlin
0
1
76257b971649e656c1be6436f8cb70b80d5c992b
3,699
aoc
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfAtoms.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
6,199
kotlab
Apache License 2.0
src/questions/RestoreIPAddresses.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.assertIterableSameInAnyOrder /** * A valid IP address consists of exactly four integers separated by single dots. * Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. * Given a string s containing only digits, return a...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
4,213
algorithms
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[137]只出现一次的数字 II.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个整数数组 nums ,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 // // // // 示例 1: // // //输入:nums = [2,2,3,2] //输出:3 // // // 示例 2: // // //输入:nums = [0,1,0,1,0,1,99] //输出:99 // // // // // 提示: // // // 1 <= nums.length <= 3 * 104 // -231 <= nums[i] <= 231 - 1 // nums 中,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 // /...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,567
MyLeetCode
Apache License 2.0
src/main/kotlin/io/recursion/SkylineProblem.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.recursion // https://leetcode.com/explore/learn/card/recursion-ii/507/beyond-recursion/3006/ class SkylineProblem { fun execute(buildings: Array<IntArray>): List<List<Int>> { val sortDots = convertToPoints(buildings) val currentArea = mutableListOf<Int>() val result: MutableList<List<Int>> = ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,997
coding
MIT License
src/main/kotlin/day12/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day12 import java.io.File fun main() { val lines = File("src/main/kotlin/day12/input.txt").readLines() val cavesByName: MutableMap<String, Cave> = mutableMapOf() lines.forEach { val fromCaveName = it.substringBefore("-") val toCaveName = it.substringAfter("-") val fromCave...
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
1,968
aoc-2021
MIT License
exercises/practice/etl/src/test/kotlin/ETLTest.kt
exercism
47,675,865
false
{"Kotlin": 382097, "Shell": 14600}
import org.junit.Test import org.junit.Ignore import kotlin.test.assertEquals class ETLTest { @Test fun `single letter`() = assertTransformedEquals( mapOf( 1 to listOf('A')), mapOf( 'a' to 1)) @Ignore @Test fun `single score with mul...
51
Kotlin
190
199
7f1c7a11cfe84499cfef4ea2ecbc6c6bf34a6ab9
1,983
kotlin
MIT License
src/main/kotlin/utils/graph/Dijkstra.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
package utils.graph import AdjacencyList import Edge import Vertex import java.util.PriorityQueue import kotlin.Comparator import kotlin.collections.ArrayList import kotlin.collections.HashMap class Dijkstra<T : Any>(private val graph: AdjacencyList<T>) { private fun route( destination: Vertex<T>, ...
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
2,674
aoc2023
Apache License 2.0
kotlin/src/main/kotlin/adventofcode/day12/Day12_1.kt
thelastnode
160,586,229
false
null
package adventofcode.day12 import java.io.File import java.lang.Exception import java.lang.IllegalArgumentException object Day12_1 { data class Rule(val condition: String, val result: Char) fun parse(lines: List<String>): Pair<String, List<Rule>> { val initialState = lines[0].split(": ")[1].trim() ...
0
Kotlin
0
0
8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa
1,820
adventofcode
MIT License
src/test/kotlin/be/brammeerten/y2022/Day11Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2022 import be.brammeerten.extractRegexGroups import be.brammeerten.readFileSplitted import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class Day11Test { val ITEMS_REGEX = "^ {2}Starting items: ((-?\\d+, )*(-?\\d+)+)$" val OP_REGEX = "^ {2}Operation: new = (.+)$...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
3,599
Advent-of-Code
MIT License
src/Day01.kt
splinkmo
573,209,594
false
{"Kotlin": 6593}
fun main() { fun part1(input: List<String>): Int { var maxCalorie = 0 var elfCalories = 0 for (value in input){ if (value != ""){ elfCalories += value.toInt() } else { if (elfCalories > maxCalorie) { maxC...
0
Kotlin
0
0
4ead85d0868feec13cc300055beba7830b798345
1,507
advent-code-22
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day7.kt
clechasseur
567,968,171
false
{"Kotlin": 493887}
package io.github.clechasseur.adventofcode.y2022 import io.github.clechasseur.adventofcode.y2022.data.Day7Data object Day7 { private val input = Day7Data.input private val shellRegex = """^\$ (cd|ls)(?: ([a-zA-Z./]+))?$""".toRegex() private val fileRegex = """^(\d+|dir) (.+)$""".toRegex() fun part1(...
0
Kotlin
0
0
7ead7db6491d6fba2479cd604f684f0f8c1e450f
2,525
adventofcode2022
MIT License
src/main/kotlin/graph/variation/PathReachability.kt
yx-z
106,589,674
false
null
package graph.variation import java.util.* import kotlin.collections.HashSet // given a isDirected graph // and two nodes in the graph // find if there exists a valid (isDirected) path between them fun main(args: Array<String>) { // a -> b -> e // | ^ | // | | | // | -> d | // | ^ | // | ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,666
AlgoKt
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day3.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import kotlin.math.pow class Day3 : AdventDay(2021, 3) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day3() report { day.part1(...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,412
adventofcode
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[5]最长回文子串.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个字符串 s,找到 s 中最长的回文子串。 // // // // 示例 1: // // //输入:s = "babad" //输出:"bab" //解释:"aba" 同样是符合题意的答案。 // // // 示例 2: // // //输入:s = "cbbd" //输出:"bb" // // // 示例 3: // // //输入:s = "a" //输出:"a" // // // 示例 4: // // //输入:s = "ac" //输出:"a" // // // // // 提示: // // // 1 <= s.length <= 1000 // s 仅由数字和英文字母(大...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,848
MyLeetCode
Apache License 2.0
src/day10/Day10_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day10 import readLines import kotlin.math.absoluteValue /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private fu...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,499
aoc2022
Apache License 2.0
2022/main/day_05/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_05_2022 import java.io.File fun extractStacks(input: List<String>): MutableList<MutableList<Char>> { val boxes = input.subList(0, 8) val stacks = mutableListOf(mutableListOf<Char>(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,985
AdventofCode
MIT License
src/Day02.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
fun main() { fun part1(input: List<String>) = input .map { it[0] - 'A' to it[2] - 'X' } .sumOf { (opponent, mine) -> 1 + mine + 3 * (mine - opponent + 1).mod(3) } fun part2(input: List<String>) = input .map { it[0] - 'A' to it[2] - 'X' } .sumOf {...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
596
aoc22-kt
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PalindromePermutation.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
3,305
kotlab
Apache License 2.0