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
2022/src/day09/Day09.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day09 import java.io.File import kotlin.math.absoluteValue fun main() { val input = File("src/day09/day09input.txt").readLines() val rope = Rope(2) rope.processInput(input) println(rope.getVisitedCount()) val longRope = Rope(10) longRope.processInput(input) println(longRope.getVis...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
2,611
adventofcode
Apache License 2.0
src/day9/fr/Day09_1.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
package day9.fr import java.io.File private fun readChars(): CharArray = readLn().toCharArray() private fun readLn() = readLine()!! // string line private fun readSb() = StringBuilder(readLn()) private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fun...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
2,433
Advent-of-Code-2021
Apache License 2.0
jeorg-kotlin-algorithms/jeorg-kotlin-alg-2-bfs/src/main/kotlin/org/jesperancinha/algorithms/bfs/Bfs.kt
jesperancinha
354,756,418
false
{"Kotlin": 35444, "Java": 14401, "JavaScript": 10140, "Python": 4018, "Makefile": 1258, "Shell": 89}
package org.jesperancinha.algorithms.bfs import org.jesperancinha.algorithms.bfs.model.Station import org.jesperancinha.algorithms.bfs.model.TravelNode import org.jesperancinha.console.consolerizer.console.ConsolerizerComposer fun main(args: Array<String>) { val railwaySystemMap = createRailwaySystem() outRou...
1
Kotlin
0
1
7a382ed529ebdc53cc025671a453c7bd5699539e
12,168
jeorg-algorithms-test-drives
Apache License 2.0
src/Day15.kt
Totwart123
573,119,178
false
null
import kotlin.math.abs import kotlin.math.absoluteValue import kotlin.math.min fun main() { data class Beacon(val x: Int, val y: Int){ override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as Be...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
6,558
AoC
Apache License 2.0
src/Day06.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
fun main() { fun solution(input: List<String>, n: Int): Int { return input.filter { return@filter it.isNotEmpty() }.sumOf { l -> val (i, _) = l .windowed(n) .withIndex() .find { (_, w) -> w.toSet().size == n }!! ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
633
aoc-2022
Apache License 2.0
2020/kotlin/src/main/kotlin/io/franmosteiro/aoc2020/Day08.kt
franmosteiro
433,734,642
false
{"Kotlin": 27170, "Ruby": 16611, "Shell": 389}
package io.franmosteiro.aoc2020 /** * Advent of Code 2020 - Day 8: Handheld Halting - * Problem Description: http://adventofcode.com/2020/day/8 */ class Day08(input: List<String>) { private val orders: List<Order> = input.map { val (name, offset) = it.split("\\s".toRegex()) Order(name, offset.t...
0
Kotlin
0
0
dad555d9cd0c3060c4b1353c7c6f170aa340c285
2,001
advent-of-code
MIT License
src/main/kotlin/com/github/nicomincuzzi/Day2Dive.kt
NicoMincuzzi
435,492,958
false
{"Kotlin": 11507}
package com.github.nicomincuzzi import kotlin.math.abs class Day2Dive { fun horizontalPositionAndDepth(commands: List<Pair<String, Int>>): Int { val result = hashMapOf<String, Int>() for (command in commands) { if (calculateHorizontalPosition(result, command)) continue if (...
0
Kotlin
0
0
345b69cc4f995f369c1dc509ccfd3db8336d3dd8
3,012
adventofcode-2021
Apache License 2.0
src/main/kotlin/days/Day14.kt
sicruse
315,469,617
false
null
package days class Day14 : Day(14) { class BitMask(val bitMask: Long, val setBits: Long, val floatingBits: Set<Long>) { constructor(pattern: String):this(maskFromString(pattern), valueFromString(pattern), floatingFromString(pattern)) {} fun apply(data: Long): Long = data.and(bitMask).or(setBits)...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
4,599
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/day2.kt
danielfreer
297,196,924
false
null
import kotlin.time.ExperimentalTime @ExperimentalTime fun day2(input: List<String>): List<Solution> { val program = input.flatMap { it.split(",") }.map(String::toInt) return listOf( solve(2, 1) { executeWithReplacements(program) }, solve(2, 2) { calculateNounVerb(program) } ) } private co...
0
Kotlin
0
0
74371d15f95492dee1ac434f0bfab3f1160c5d3b
1,692
advent2019
The Unlicense
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions43.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round0.BinaryTreeNode import com.qiaoyuang.algorithm.round0.Queue fun test43() { printlnResult(testCase1(), 7) printlnResult(binaryTreeTestCase2(), 9) printlnResult(testCase3(), 8) } /** * Questions 43: Inset value to a complete bina...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,595
Algorithm
Apache License 2.0
solutions/aockt/y2023/Y2023D09.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D09 : Solution { /** A history report from an OASIS Scanner, with the [values] of the sensor readings. */ private data class History(val values: List<Int>) : List<Int> by values { /** Predict the nex...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
1,377
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/fluency.ws.kts
mikaelstaldal
531,628,632
false
{"Kotlin": 28924}
import kotlin.math.abs data class Complex(val real: Double, val imaginary: Double) { operator fun times(other: Complex) = Complex(real * other.real - imaginary * other.imaginary, real * other.imaginary + imaginary * other.real) private fun sign() = if (imaginary < 0) "-" else "+" ...
0
Kotlin
0
0
668df246d08e5b0fcf42cae02f4282f85c93f422
1,844
KotlinPlayground
Apache License 2.0
src/main/kotlin/leetcode/problem0120/Triangle.kt
ayukatawago
456,312,186
false
{"Kotlin": 266300, "Python": 1842}
package leetcode.problem0120 import kotlin.math.min class Triangle { fun minimumTotal(triangle: List<List<Int>>): Int = when (triangle.size) { 1 -> triangle[0][0] else -> { val array = Array(triangle.size) { intArrayOf() } array[0] = intArrayOf(trian...
0
Kotlin
0
0
f9602f2560a6c9102728ccbc5c1ff8fa421341b8
1,187
leetcode-kotlin
MIT License
src/questions/TopKFrequent.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBeOneOf import java.util.* /** * Given an integer array nums and an integer k, return the k most frequent elements. * You may return the answer in any order. * [Source](https://leetcode.com/problems/top-k-frequent-elements//) */ @UseCom...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,957
algorithms
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day09.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day09 : AbstractDay() { @Test fun part1Test() { assertEquals(114, compute1(testInput)) } @Test fun part1Puzzle() { assertEquals(1731106378, compute...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,312
aoc
Apache License 2.0
src/Day10.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
private const val NOOP_INSTRUCTION = "noop" private val ADDX_INSTRUCTION_REGEX = "addx\\s+(?<value>-?\\d+)".toRegex() private const val CRT_WIDTH = 40 private const val CRT_HEIGHT = 6 sealed class Instruction { object Noop: Instruction() { override val cycles: Int get() = 1 override f...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
3,728
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day09.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.* import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.ndarray import org.jetbrains.kotlinx.multik.ndarray.data.D2Array open class Part9A : PartSolution() { lateinit var heights: D2Array<Int> lateinit var lowPo...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,022
advent-of-code-kotlin
MIT License
src/main/kotlin/ru/glukhov/aoc/Day3.kt
cobaku
576,736,856
false
{"Kotlin": 25268}
package ru.glukhov.aoc import java.io.BufferedReader import java.util.* fun main() { Problem.forDay("day3").use { solveFirst(it) }.let { println("Result of the first problem is $it") } Problem.forDay("day3").use { solveSecond(it) }.let { println("Result of the second problem is $it") } } private fun solveFir...
0
Kotlin
0
0
a40975c1852db83a193c173067aba36b6fe11e7b
1,489
aoc2022
MIT License
src/Day03.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
private val Char.priority: Int get() = if (isLowerCase()) { minus('a') + 1 } else { minus('A') + 27 } fun <T> Iterable<Set<T>>.intersection(): Set<T> = reduceOrNull { acc, ts -> acc.intersect(ts) } ?: emptySet() fun <T> Iterable<Set<T>>.union(): Set<T> = reduceOrNull { acc, ts -> a...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
755
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/sherepenko/leetcode/solutions/LengthOfLongestUniqueSubstring.kt
asherepenko
264,648,984
false
null
package com.sherepenko.leetcode.solutions import com.sherepenko.leetcode.Solution import kotlin.math.max class LengthOfLongestUniqueSubstring( private val str: String ) : Solution { companion object { fun lengthOfLongestSubstring(str: String): Int { val indices = mutableMapOf<Char, Int>()...
0
Kotlin
0
0
49e676f13bf58f16ba093f73a52d49f2d6d5ee1c
1,583
leetcode
The Unlicense
src/main/kotlin/ru/byprogminer/compmath/lab5/math/AdamsMethod.kt
ProgMiner
242,443,008
false
null
package ru.byprogminer.compmath.lab5.math import ru.byprogminer.compmath.lab4.expression.Expression import kotlin.math.min object AdamsMethod: OrderedCauchyProblemMethod(4) { override fun solve( function: Expression, startX: Double, startY: Double, step: Double, ...
0
Kotlin
0
1
201b562e7e07961c695ed4d09ad0b381281f6d10
2,093
Lab_CompMath
MIT License
src/main/kotlin/SubarraySumEqualsK.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. * * A subarray is a contiguous non-empty sequence of elements within an array. * * * * Example 1: * * Input: nums = [1,1,1], k = 2 * Output: 2 * Example 2: * * Input: nums = [1,2,3], k = 3 *...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
937
kotlin-codes
Apache License 2.0
kotlin/src/katas/kotlin/longest_subsequence/LongestSubsequence0.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.longest_subsequence import nonstdlib.printed import datsok.shouldEqual import org.junit.Test import kotlin.random.Random class LongestSubsequence0 { @Test fun `longest subsequence of two strings`() { longestSubsequence("", "") shouldEqual "" longestSubsequence("a", "") shouldE...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,049
katas
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/WiggleSubsequence.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,088
kotlab
Apache License 2.0
src/main/kotlin/problems/Day7.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems import kotlin.math.abs class Day7(override val input: String) : Problem { override val number: Int = 7 private val crabPositions = input.split(",").map { i -> i.toInt() } override fun runPartOne(): String { val median = crabPositions.median() return crabPositions.sumOf { ...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
1,198
AdventOfCode2021
MIT License
src/main/kotlin/juuxel/advent/Day2.kt
Juuxel
226,936,488
false
{"Kotlin": 2545}
package juuxel.advent import java.nio.file.Files import java.nio.file.Paths fun main() { val input = Files.readAllLines(Paths.get("day2.txt")).joinToString(separator = "") val mem = input.split(',').map { it.toInt() }.toIntArray() part1(mem.copyOf()) part2(mem) // Part 2 is mem-safe } private fun pa...
0
Kotlin
0
0
3e9d21801346af2c79e3f28718101c4b6aeb3bfc
1,833
Advent2019
MIT License
src/day10/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day10 import day10.Op.AddX import day10.Op.Noop import readInput fun main() { fun part1(input: List<String>): Int { val summarizer = SignalStrengthSummarizer() Cpu.execute(input, summarizer::update) return summarizer.getSum() } fun part2(input: List<String>): Int { ...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
3,715
AoC-2022
Apache License 2.0
jeorg-kotlin-algorithms/jeorg-kotlin-alg-1-hannoi-towers/src/main/kotlin/org/jesperancinha/algorithms/HanoiStarter.kt
jesperancinha
354,756,418
false
{"Kotlin": 35444, "Java": 14401, "JavaScript": 10140, "Python": 4018, "Makefile": 1258, "Shell": 89}
package org.jesperancinha.algorithms import org.jesperancinha.algorithms.data.PyramidElement fun main(args: Array<String>) { val startPositions = intArrayOf(1, 1, 1) val firstNode = PyramidElement(startPositions) calculateStartTriangle(firstNode) println("This is how you move the plates in an Hanoi ...
1
Kotlin
0
1
7a382ed529ebdc53cc025671a453c7bd5699539e
3,531
jeorg-algorithms-test-drives
Apache License 2.0
src/Day03.kt
raneric
573,109,642
false
{"Kotlin": 13043}
fun main() { fun part1(input: List<String>): Int { return input.map { it.splitAndCheckRec() }.flatten().sum() } fun part2(input: List<String>): Int { return input.findBadgeSum() } val input = readInput("Day03") println(part1(input)) println(part2(input)) } fun String.split...
0
Kotlin
0
0
9558d561b67b5df77c725bba7e0b33652c802d41
911
aoc-kotlin-challenge
Apache License 2.0
src/main/kotlin/org/jetbrains/bio/util/BinaryLut.kt
JetBrains-Research
173,494,429
false
{"Kotlin": 1220056}
package org.jetbrains.bio.util import java.util.* /** * A lookup table reducing the search space for binary search * over a sorted array of non-negative integers. * * See https://geidav.wordpress.com/2013/12/29/optimizing-binary-search. * * @author <NAME> */ open class BinaryLut( private val index: IntArra...
2
Kotlin
3
30
3f806c069e127430b91712a003e552490bff0820
7,990
bioinf-commons
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/Nqueens.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
4,012
kotlab
Apache License 2.0
src/day11/Day11.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day11 import helpers.ReadFile class Day11 { val lines = ReadFile.named("src/day11/input.txt", blocks = "\n\n").map { it.split("\n") } val lines1 = listOf( listOf("Monkey 0:", "Starting items: 79, 98", "Operation: new = old * 19", "Test: divisible by 23", "If true: throw to ...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
2,800
adventofcode2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountOrders.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,888
kotlab
Apache License 2.0
2021/src/test/kotlin/Day25.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.test.Test import kotlin.test.assertEquals class Day25 { enum class Direction { EAST, SOUTH } data class Coord(val x: Int, val y: Int, val maxX: Int, val maxY: Int) { fun next(direction: Direction) = Coord( if (direction == Direction.EAST) { if (x.inc() < maxX) ...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,727
adventofcode
MIT License
src/main/kotlin/com/leetcode/P187.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://leetcode.com/problems/repeated-dna-sequences/ class P187 { fun findRepeatedDnaSequences(s: String): List<String> { val answer = mutableSetOf<String>() if (s.length <= 10) return listOf() // 해시값들이 들어갈 Set val seen = mutableSetOf<Int>() // 처음 10...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,166
algorithm
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FlattenBinaryTree.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,072
kotlab
Apache License 2.0
common/inference.kt
waterlink
53,756,002
false
null
package com.tddfellow.inference data class Relation(val name: String, val subject: String, val relative: String) { private fun matcherFor(getter: (Relation) -> String): (Relation) -> Boolean { val value = getter(this) return if (value == "?") { { getter(it) != "?" } } else { ...
3
Kotlin
0
0
159f87bf7eb94519933f1348a4dde232ce012db6
3,021
inference
MIT License
Problems/Algorithms/53. Maximum Subarray/MaxSubarray2.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 maxSubArray(nums: IntArray): Int { return maxSum(nums, 0, nums.size-1) } private fun maxSum(nums: IntArray, start: Int, end: Int): Int { if (start == end) return nums[start] val middle: Int = (start + end) / 2 val leftMax: Int = max...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,060
leet-code
MIT License
src/main/kotlin/com/github/solairerove/algs4/leprosorium/arrays/LongestPeak.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.arrays import kotlin.math.max fun main() { val arr = listOf(3, -4, 7, 12, 4, 20, 15, 6, -2, 5, 16, 11, 1) print(longestPeak(arr)) // 5 } // O(n) time | O(1) space private fun longestPeak(arr: List<Int>): Int { var longestPeakLen = 0 var i = 1 whil...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
807
algs4-leprosorium
MIT License
src/Day09.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import utils.Coordinate2D import utils.readInputAsLines import kotlin.math.abs import kotlin.math.sign fun main() { val input = readInputAsLines("day09_input") val moves = input.asSequence() .map { it.substringBefore(' ').single() to it.substringAfter(' ').toInt() } val directions = mapOf( ...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
1,480
advent-of-code-2022
Apache License 2.0
learning-algorithm/src/main/kotlin/io/vincent/learning/stack/algorithm/leetcode/No206ReverseLinkedList.kt
search-cloud
137,825,867
false
{"Kotlin": 172535, "Java": 154592, "C": 89374, "HTML": 1736, "Python": 502, "Go": 130}
package io.vincent.learning.stack.algorithm.leetcode import io.vincent.learning.stack.algorithm.leetcode.linked.ListNode import org.jetbrains.annotations.Contract /** * Reverse linked List. (Iteratively) * </p> * https://leetcode.com/problems/reverse-linked-list/ * * @author Vincent * @since 1.0, 2019/3/23 */ ...
0
Kotlin
0
1
5011813d9796c0ccc8a174c98549d5b3727adfb4
2,938
learning-stack
Apache License 2.0
src/main/kotlin/astminer/featureextraction/TreeFeature.kt
neomatrix369
273,848,522
true
{"Java": 199970, "Kotlin": 170672, "ANTLR": 76421, "C++": 25952, "Python": 12730, "JavaScript": 7698, "Shell": 754}
package astminer.featureextraction import astminer.common.model.Node import astminer.common.preOrder /** * Interface that describes tree feature. * @param T tree feature's type */ interface TreeFeature<out T> { /** * Computes this feature for given tree. * @param tree tree for which this feature is c...
1
null
1
2
6e53d0245ef4980bf2b46bf3741947b632227d16
3,363
astminer
MIT License
src/main/kotlin/days/day3/Day3.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day3 import days.Day import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet class Day3: Day(false) { //NOTE: I Didn't impliment the edgecase for the edge. If you just add a padding of '.' it works. override fun partOne(): Any { val input: HashMap<Coordinate...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
6,162
advent-of-code_2023
The Unlicense
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[400]第 N 位数字.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个整数 n ,请你在无限的整数序列 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...] 中找出并返回第 n 位上的数字。 // // // // // 示例 1: // // //输入:n = 3 //输出:3 // // // 示例 2: // // //输入:n = 11 //输出:0 //解释:第 11 位数字在序列 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... 里是 0 ,它是 10 的一部分。 // // // // // 提示: // // // 1 <= n <= 231 - 1 // 第 n 位上的数字是按计数单位(dig...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,246
MyLeetCode
Apache License 2.0
code/graph/MCMM.kt
hakiobo
397,069,173
false
null
//i make no guarantess about the accuracy of this code private class MCMM(private val d: Int, private val costs: Array<DoubleArray>) { companion object { const val EPSILON = 1E-9 } private val n = 2 + (d shl 1) private val src = n - 1 private val snk = n - 2 private val prices = Double...
0
Kotlin
1
2
f862cc5e7fb6a81715d6ea8ccf7fb08833a58173
5,103
Kotlinaughts
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-09.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.TspGraph import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2015, "09-input") val test1 = readInputLines(2015, "09-test1") p...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,056
advent-of-code
MIT License
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day7HandyHaversacks.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode import com.scavi.brainsqueeze.adventofcode.util.GraphAccess import java.lang.IllegalArgumentException class Day7HandyHaversacks { private val bagSplit = """[a-z]*\s[a-z]*(?=\sbag)|((?<=\s)\d+)""".toRegex() fun solveA(input: List<String>): Int { val graph =...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
1,656
BrainSqueeze
Apache License 2.0
src/Day01.kt
alexaldev
573,318,666
false
{"Kotlin": 10807}
fun main() { fun part1(input: List<String>): Int { val caloriesPerElf = mutableListOf<Int>() var elfIndex = 0 input.forEachIndexed { index, s -> if (s == "") { elfIndex += 1 return@forEachIndexed } if (caloriesPerE...
0
Kotlin
0
0
5abf10b2947e1c6379d179a48f1bdcc719e7062b
1,406
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/de/huddeldaddel/euler/Problem050.kt
huddeldaddel
171,357,298
false
null
package de.huddeldaddel.euler import de.huddeldaddel.euler.sequences.PrimeSequence import de.huddeldaddel.euler.extensions.isPrime /** * Solution for https://projecteuler.net/problem=50 */ fun main() { val upperLimit = 1_000_000L val primes = getPrimes(upperLimit) var result = listOf<Long>() for(i ...
0
Kotlin
1
0
df514adde8c62481d59e78a44060dc80703b8f9f
1,206
euler
MIT License
Kotlin/src/main/kotlin/org/algorithm/problems/0059_rotting_oranges.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
//Problem Statement // In a given grid, each cell can have one of three values: // // the value 0 representing an empty cell; // the value 1 representing a fresh orange; // the value 2 representing a rotten orange. // Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. /...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
2,170
algorithms
MIT License
src/year2023/22/Day22.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`22` import readInput import kotlin.math.max import kotlin.math.min private const val CURRENT_DAY = "22" data class Point( val x: Int, val y: Int, val z: Int, ) { override fun toString(): String = "[$x,$y,$z]" } private val cache = mutableMapOf<Brick, Set<Point>>() data class Brick...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
5,837
KotlinAdventOfCode
Apache License 2.0
src/main/kotlin/io/github/t45k/scm/matching/algorithms/suffixArray/DoublingConstructor.kt
T45K
255,912,849
false
null
package io.github.t45k.scm.matching.algorithms.suffixArray import io.github.t45k.scm.entity.TokenSequence class DoublingConstructor : ArrayConstructor { override fun construct(from: TokenSequence, querySize: Int): SuffixArray { val size: Int = from.size - querySize val sortedIndices: Array<Int> =...
0
Kotlin
0
0
37b3ffac9bdf6e24a3fc3ae9282f3f692ec8d12d
1,423
SCM
MIT License
src/Day01.kt
ciprig
573,478,617
false
null
import java.util.TreeSet fun main() { fun parseInput(input: List<String>): TreeSet<Int> { val elfs = sortedSetOf<Int>(compareByDescending { it }) var sum = 0 for (s in input) { if (s.isEmpty()) { elfs.add(sum) sum = 0 } else { ...
0
Kotlin
0
0
e24dd65a22106bf5375d9d99c8b9d3b3a90e28da
983
aoc2022
Apache License 2.0
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day10.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.max import fr.outadoc.aoc.scaffold.min import fr.outadoc.aoc.scaffold.readDayInput class Day10 : Day<Long> { companion object { const val OUTLET_JOLTS = 0L const val BUILT_IN_ADAPTER_JOLTS_DIFFER...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
2,827
adventofcode
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year20/Day22.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year20 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.doubleLines import com.grappenmaker.aoc.toQueue fun PuzzleSet.day22() = puzzle(day = 22) { val (initialP1, initialP2) = input.doubleLines().map { it.lines().drop(1).map(String::toInt) } data class Outcome(va...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,825
advent-of-code
The Unlicense
day05/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Part Two --- // Everyone will starve if you only plant such a small number of seeds. // Re-reading the almanac, it looks like the seeds: line actually describes // ranges of seed numbers. // // The values on the initial seeds: line come in pairs. Within each pair, the // first value is the start of the range and...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
3,789
adventofcode2023
MIT License
kotlin/376.Wiggle Subsequence(摆动序列).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>A sequence of numbers is called a <strong>wiggle sequence</strong> if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. </p> ...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
4,363
leetcode
MIT License
src/test/kotlin/Test.kt
lhDream
708,889,856
false
{"Kotlin": 20990}
import java.util.* import kotlin.math.abs // 棋盘大小 const val BOARD_SIZE = 15 // 评估函数(简化版本,根据棋局评估得分) // 五子棋中针对当前局面的评估函数 fun evaluate(board: Array<Array<Int>>, player: Int): Int { val opponent = if (player == 2) 1 else 2 var score = 0 // 检查每个位置的行、列、对角线是否存在连续的棋子 for (i in 0 until BOARD_SIZE) { fo...
0
Kotlin
0
0
c83c58cba821f0b8663bea53750495f3dfbfce34
4,428
wuziqi
MIT License
src/main/kotlin/g1701_1800/s1719_number_of_ways_to_reconstruct_a_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1719_number_of_ways_to_reconstruct_a_tree // #Hard #Tree #Graph #Topological_Sort #2023_06_16_Time_1015_ms_(100.00%)_Space_102_MB_(100.00%) class Solution { fun checkWays(pairs: Array<IntArray>): Int { val adj = Array(501) { IntArray(501) } val set = HashSet<Int>() for ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,798
LeetCode-in-Kotlin
MIT License
src/Day08.kt
othimar
573,607,284
false
{"Kotlin": 14557}
fun main() { fun part1(input: List<String>): Int { var number = 0; for (i in 1 until input.size - 1) { val line = input[i] for (j in 1 until line.length - 1) { val tree = line[j].toString().toInt() var visibleTop = true var visi...
0
Kotlin
0
0
ff62a00123fe817773ff6248d34f606947ffad6d
3,633
advent-of-code-2022
Apache License 2.0
src/Day02.kt
mihansweatpants
573,733,975
false
{"Kotlin": 31704}
import java.lang.IllegalArgumentException fun main() { fun part1(input: List<String>): Int { var totalPoints = 0 for (line in input) { val opponent = PlayerChoice.fromCode(line.first()) val me = PlayerChoice.fromCode(line.last()) totalPoints += me.playAgainst(o...
0
Kotlin
0
0
0de332053f6c8f44e94f857ba7fe2d7c5d0aae91
1,977
aoc-2022
Apache License 2.0
src/Day05.kt
Sasikuttan2163
647,296,570
false
null
import java.util.* fun main() { val input = readInput("Day05") val start = input.indexOf("") - 1 lateinit var data: MutableList<Stack<Char>> fun collectData() { var i = start - 1 data = MutableList(input[start].trim().substringAfterLast(" ").toInt()) { Stack<Char>() } while (i >...
0
Kotlin
0
0
fb2ade48707c2df7b0ace27250d5ee240b01a4d6
1,796
AoC-2022-Solutions-In-Kotlin
MIT License
src/main/kotlin/g1301_1400/s1349_maximum_students_taking_exam/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1349_maximum_students_taking_exam // #Hard #Array #Dynamic_Programming #Matrix #Bit_Manipulation #Bitmask // #2023_06_06_Time_173_ms_(100.00%)_Space_35.7_MB_(100.00%) class Solution { fun maxStudents(seats: Array<CharArray>): Int { val m = seats.size val n = seats[0].size ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,409
LeetCode-in-Kotlin
MIT License
src/main/aoc2021/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2021 class Day24(input: List<String>) { // The input has 14 chunks, one for each digit, of 18 instructions each where // the 6th and 16th instructions varies and the rest are the same. private val variantOne = input.chunked(18).map { it[5].split(" ").last().toInt() } private val variantTwo ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,718
aoc
MIT License
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/middle/Operations.kt
scientificCommunity
352,868,267
false
{"Java": 154453, "Kotlin": 69817}
package org.baichuan.sample.algorithms.leetcode.middle /** * @author: tk (<EMAIL>) * @date: 2022/1/11 */ class Operations { var negatives = LongArray(32) var positives = LongArray(32) var cacheA = LongArray(32) var cacheB = LongArray(32) val NEGATIVE_UNIT = -1 fun Operations() { neg...
1
Java
0
8
36e291c0135a06f3064e6ac0e573691ac70714b6
4,084
blog-sample
Apache License 2.0
src/main/kotlin/io/github/fbiville/solver/Tree.kt
fbiville
129,937,320
false
null
package io.github.fbiville.solver import kotlin.coroutines.experimental.buildIterator class Tree<T>(private val breadth: Int, private val depth: Int, private val root: T) { internal val values: MutableList<T> = MutableList(capacity(breadth, depth), { _ -> root }) internal val capacity: Int get() = va...
4
Kotlin
0
0
490d55d8b6af8fc40704439c19effbcc1a8f9e1b
3,047
calculator-solver
Apache License 2.0
src/year2020/day4/Solution.kt
Niallfitzy1
319,123,397
false
null
package year2020.day4 import com.github.ajalt.mordant.TermColors import java.io.File fun main() { val passports: MutableList<Passport> = mutableListOf() val fields: MutableList<Field> = mutableListOf() File("src/year2020/day4/input").forEachLine { line -> if (line.isNotEmpty()) { line....
0
Kotlin
0
0
67a69b89f22b7198995d5abc19c4840ab2099e96
2,737
AdventOfCode
The Unlicense
src/Day01.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
fun firstPart(measurements : List<Int>) { var count = 0 if (measurements.isNotEmpty()) { var currItem = measurements.first().toInt() measurements.subList(1, measurements.size).map { if (it > currItem) count++ currItem = it } } println("Increases = $count...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
883
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/Day24.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.util.* private data class Blizzard(val coord: Coord2D, val direction: Char) /** wrap the integer if it goes outside the range e.g. * (1..5).wrap(0) == 5 * (1..5).wrap(6) == 1 * (1..5).wrap(3) == 1 */ private fun IntRange.wrap(num: Int): Int { return first + (num - first).mod(last - first + 1) } pr...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
4,615
advent-of-code-kotlin-2022
Apache License 2.0
30 Days of Code (Kotlin)/day11-2dArrays.kt
swapnanildutta
259,629,657
false
null
/* Question Today, we're building on our knowledge of Arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video! Context Given a 2D Array, : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of valu...
41
Python
202
65
01b04ee56f1e4b151ff5b98094accfeb09b55a95
1,978
Hackerrank-Codes
MIT License
src/main/kotlin/day23.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day23() { val lines: List<String> = readFile("day23.txt") day23part1(lines) day23part2(lines) } fun day23part1(burrow: List<String>) { val amphipods = initAmphipods(burrow) val answer = "TBD" println("23a: $answer") } fun day23part2(lines: List<String>) { val answer = "TBD" pri...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,086
advent_of_code_2021
MIT License
archive/691/solve.kt
daniellionel01
435,306,139
false
null
/* === #691 Long substring with many repetitions - Project Euler === Given a character string $s$, we define $L(k,s)$ to be the length of the longest substring of $s$ which appears at least $k$ times in $s$, or $0$ if such a substring does not exist. For example, $L(3,\text{“bbabcabcabcacba”})=4$ because of the three ...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
1,230
euler
MIT License
src/ad/kata/aoc2021/day12/CaveSystem.kt
andrej-dyck
433,401,789
false
{"Kotlin": 161613}
package ad.kata.aoc2021.day12 import ad.kata.aoc2021.PuzzleInput data class CaveSystem(private val connections: Graph<Cave>) { fun findPaths(): Paths<Cave> = connections.distinctPaths(start, end, canRevisit = { c, _ -> c.isLargeCave() }) fun findPathsWithSlightlyMoreTime(): Paths<Cave> = con...
0
Kotlin
0
0
28d374fee4178e5944cb51114c1804d0c55d1052
1,038
advent-of-code-2021
MIT License
src/day11/Day11.kt
jpveilleux
573,221,738
false
{"Kotlin": 42252}
package day11 import utils.Setup val daySetup = Setup(11) data class Player (var worryLevel: Int) class Monkey ( var itemsList: MutableList<Int> = mutableListOf(), var operation: String = "", var test: Int = 0, var nextMonkey: MutableList<Int> = mutableListOf(), var inspectedItems: Int = 0 ) { ...
0
Kotlin
0
0
5ece22f84f2373272b26d77f92c92cf9c9e5f4df
4,680
jpadventofcode2022
Apache License 2.0
src/main/kotlin/Day9.kt
Walop
573,012,840
false
{"Kotlin": 53630}
import java.io.InputStream import kotlin.math.abs import kotlin.math.pow import kotlin.math.sqrt data class Vec2( var x: Int, var y: Int ) { operator fun plus(other: Vec2): Vec2 { return Vec2(x + other.x, y + other.y) } operator fun minus(other: Vec2): Vec2 { return Vec2(x - other....
0
Kotlin
0
0
7a13f6500da8cb2240972fbea780c0d8e0fde910
3,326
AdventOfCode2022
The Unlicense
src/day1/Day01.kt
jorgensta
573,824,365
false
{"Kotlin": 31676}
package day1 import readInput fun main() { fun part1(input: List<String>): Int { var mostAmountOfCaloriesByElf = 0 var currentCalories = 0 input.forEach { if (it.isBlank()) { currentCalories = 0 return@forEach } current...
0
Kotlin
0
0
7243e32351a926c3a269f1e37c1689dfaf9484de
1,233
AoC2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/GraphColoring.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph import java.util.* println("Test") Solution().test() class Solution { fun test() { //https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/ val vertice0 = Vertice(0) val vertice1 = Vertice(1) val vertice2 = Vertice(2)...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
3,613
KotlinAlgs
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDeletionSize.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,801
kotlab
Apache License 2.0
src/main/kotlin/day2/Aoc.kt
widarlein
225,589,345
false
null
package day2 fun main(args: Array<String>) { if (args.size < 1) { println("Must provide input program") System.exit(0) } val inputProgram = args[0].split(",").map { it.toInt() }.toIntArray() val program = inputProgram.clone() val output = runProgram(program) println("Part 1 ou...
0
Kotlin
0
0
b4977e4a97ad61177977b8eeb1dcf298067e8ab4
2,043
AdventOfCode2019
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumRookCaptures.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,065
kotlab
Apache License 2.0
src/main/kotlin/leetcode/Problem1801.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import java.util.* /** * https://leetcode.com/problems/number-of-orders-in-the-backlog/ */ class Problem1801 { fun getNumberOfBacklogOrders(orders: Array<IntArray>): Int { val buyMap = TreeMap<Int, Long> { a, b -> b.compareTo(a) } val sellMap = TreeMap<Int, Long> { a, b -> a.com...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
2,145
leetcode
MIT License
src/Day06.kt
Olivki
573,156,936
false
{"Kotlin": 11297}
fun main() { data class DataChunk(val chunk: String, val lastCharacter: Int) fun String.findUniqueDataChunk(chunkSize: Int): DataChunk = asSequence() .withIndex() .windowed(chunkSize) { chars -> val chunk = chars.joinToString(separator = "") { it.value.toString() } DataC...
0
Kotlin
0
1
51c408f62589eada3d8454740c9f6fc378e2d09b
1,288
aoc-2022
Apache License 2.0
src/leetcode_study_badge/dynamic_programming/Day2.kt
faniabdullah
382,893,751
false
null
package leetcode_study_badge.dynamic_programming class Day2 { // https://leetcode.com/problems/climbing-stairs/ // Bottom up fun climbStairs(n: Int): Int { if (n <= 3) return n var one = 1 var two = 2 var result = one + two for (i in 3..n) { result = one...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,117
dsa-kotlin
MIT License
src/Day02.kt
punx120
573,421,386
false
{"Kotlin": 30825}
fun main() { fun score(opp: String, me:String) : Int { if (opp == "A") { if (me == "X") { return 3 } else if (me == "Y") { return 6 } else if (me == "Z") { return 0 } } else if (opp == "B") { ...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
2,704
aoc-2022
Apache License 2.0
advent-of-code2016/src/main/kotlin/day21/Advent21.kt
REDNBLACK
128,669,137
false
null
package day21 import day21.Operation.Type.* import move import parseInput import reverseSubstring import rotate import splitToLines import swap /** --- Day 21: Scrambled Letters and Hash --- The computer system you're breaking into uses a weird scrambling function to store its passwords. It shouldn't be much trouble...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
7,051
courses
MIT License
src/main/kotlin/g0401_0500/s0450_delete_node_in_a_bst/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0401_0500.s0450_delete_node_in_a_bst // #Medium #Tree #Binary_Tree #Binary_Search_Tree #Data_Structure_II_Day_16_Tree // #2022_12_25_Time_257_ms_(84.62%)_Space_38.6_MB_(92.31%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree node...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,534
LeetCode-in-Kotlin
MIT License
2020/day/13/bus.kt
mboos
318,232,614
false
{"Python": 45197, "Swift": 25305, "Kotlin": 3701}
/** * Solution to https://adventofcode.com/2020/day/13 */ import java.io.File fun gcf(a: Long, b: Long): Long { var tmp: Long var aa = a var bb = b while (bb != 0L) { tmp = aa % bb aa = bb bb = tmp } return aa } fun lcm(vals: List<Long>): Long { return vals.reduce{a, b -> a*b/gcf(a,b)} } ...
0
Python
0
0
4477bb32c50b951b0a1be4850ed28a2c6f78e65d
1,752
advent-of-code
Apache License 2.0
src/Day06.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
private fun findUniqueSymbolsSequence(input: String, uniqueCount: Int): Int = input.windowed(uniqueCount) { it.toSet().size == uniqueCount }.indexOf(true) + uniqueCount fun main() { fun part1(input: List<String>): Int = findUniqueSymbolsSequence(input.single(), 4) fun part2(input: List<String...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
707
aoc-2022
Apache License 2.0
src/org/aoc2021/Day16.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path object Day16 { interface Packet { val version: Int val typeId: Int fun sumSubPacketVersions(): Int fun evaluate(): Long } data class LiteralValuePacket( override val version: Int, ov...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
4,536
advent-of-code-2021
The Unlicense
day3/src/main/kotlin/part1.kt
Lysoun
725,939,287
false
{"Kotlin": 16038, "OCaml": 224}
package day3 import java.io.File fun isSymbol(char: Char): Boolean = !char.isDigit() && char != '.' fun isNextToASymbol(position: Pair<Int, Int>, engineSchematic: Map<Pair<Int, Int>, Char>): Boolean { val neighbourPositions = listOf( position.first to position.second -1, position.first + 1 to pos...
0
Kotlin
0
0
96ecbcef1bd29a97f2230457f4e233ca6b1cc108
2,034
advent-of-code-2023
MIT License
src/main/kotlin/days/aoc2022/Day15.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day import util.Point2d import kotlin.math.abs import kotlin.math.min import kotlin.math.max import kotlin.time.ExperimentalTime import kotlin.time.TimeMark import kotlin.time.TimeSource class Day15 : Day(2022, 15) { override fun partOne(): Any { return countCoveredBeaconP...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,247
Advent-Of-Code
Creative Commons Zero v1.0 Universal
solutions/src/solutions/y19/day 24.kt
Kroppeb
225,582,260
false
null
@file:Suppress("PackageDirectoryMismatch") package solutions.solutions.y19.d24 import helpers.* import kotlin.collections.* import grid.entityGrid private fun bio1(s: Set<Point>): Int { var b = 0 var p = 1 for (i in (0..4)) for (j in (0..4)) { if (i toP j in s) b += p p *= 2 } return b } private f...
0
Kotlin
0
1
744b02b4acd5c6799654be998a98c9baeaa25a79
2,893
AdventOfCodeSolutions
MIT License
src/commonMain/kotlin/com/github/knok16/regrunch/dfa/DFAIntersection.kt
knok16
593,302,527
false
null
package com.github.knok16.regrunch.dfa import com.github.knok16.regrunch.State fun <A, S1, S2> intersection(dfa1: DFA<A, S1>, dfa2: DFA<A, S2>): DFA<A, State> { if (dfa1.alphabet != dfa2.alphabet) throw IllegalArgumentException("DFAs have different alphabets") val alphabet = dfa1.alphabet val builder = DF...
0
Kotlin
1
11
87c6a7ab9f6db4e48e9d3caf88b278c59297ed7b
1,395
regrunch
MIT License
src/main/kotlin/de/startat/aoc2023/Day8.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 import java.math.BigInteger import kotlin.math.sqrt class Day8 { data class WastelandMap(val map : Map<String,Pair<String,String>>) { operator fun get(currentNode: String): Pair<String, String> = map[currentNode]!! } private val mapLineRegex = Regex("(\\w*) = \\((\\w*)...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
23,597
AOC2023
Creative Commons Zero v1.0 Universal
kotlin/src/katas/kotlin/adventofcode/day3/Part1.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.adventofcode.day3 import java.io.* import kotlin.math.* fun main() { val lines = File("src/katas/kotlin/adventofcode/day3/input.txt").readLines() val positions1 = movesToPositions(moves = lines[0].split(",")) val positions2 = movesToPositions(moves = lines[1].split(",")) println(p...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,407
katas
The Unlicense
08/kotlin/src/main/kotlin/se/nyquist/Digit.kt
erinyq712
437,223,266
false
{"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098}
package se.nyquist // abcdefg // 0 = 1110111 // 1 = 0010010 // 2 = 1011101 // 3 = 1011011 // 4 = 0111010 // 5 = 1101011 // 6 = 1101111 // 7 = 1010010 // 8 = 1111111 // 9 = 1111011 enum class Digit(val number: Int, val representation : String, val signals : Int) { ZERO(0, "abcefg", 5), ONE(1, "cf", 2), ...
0
Kotlin
0
0
b463e53f5cd503fe291df692618ef5a30673ac6f
1,924
adventofcode2021
Apache License 2.0
src/main/kotlin/g0001_0100/s0037_sudoku_solver/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0037_sudoku_solver // #Hard #Array #Matrix #Backtracking #2023_07_05_Time_148_ms_(100.00%)_Space_34.3_MB_(96.30%) class Solution { private val emptyCells: MutableList<IntArray> = ArrayList() private val rows = IntArray(9) private val cols = IntArray(9) private val boxes = IntArray(...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,057
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day4/Solution.kt
krazyglitch
573,086,664
false
{"Kotlin": 31494}
package day4 import util.Utils import java.lang.IllegalArgumentException import java.time.Duration import java.time.LocalDateTime class Solution { class Elf(input: String) { private val left: Int private val right: Int init { val splitString = input.split("-") if ...
0
Kotlin
0
0
db6b25f7668532f24d2737bc680feffc71342491
2,342
advent-of-code2022
MIT License
src/day11/puzzle11.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day11 import Puzzle import PuzzleInput import java.io.File import java.util.PriorityQueue fun day11Puzzle() { Day11PuzzleSolution().solve(Day11PuzzleInput("inputs/day11/example.txt", 10605)) Day11PuzzleSolution().solve(Day11PuzzleInput("inputs/day11/input.txt", 120056)) Day11Puzzle2Solution().solv...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
4,701
aoc_2022
Apache License 2.0
src/main/kotlin/solutions/day03/Day3.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day03 import solutions.Solver class Day3 : Solver { private fun findCommonChar(strings: List<String>): Char? { val charSets = strings.map { it.toSet() } if (charSets.isNotEmpty()) { val first = charSets.first() val rest = charSets.drop(1) re...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
1,220
Advent-of-Code-2022
MIT License