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
kotlin/src/katas/kotlin/leetcode/super_egg_drop/SuperEggDrop.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.super_egg_drop import datsok.shouldEqual import org.junit.jupiter.api.Test // https://leetcode.com/problems/super-egg-drop ❌ // https://www.youtube.com/watch?v=xsOCvSiSrSs // // You are given K eggs, and you have access to a building with N floors from 1 to N. // Each egg is identical in...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,360
katas
The Unlicense
compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/transformers/ImportUtils.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnos...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
2,965
kotlin
Apache License 2.0
kotlin/src/com/leetcode/31_NextPermutation.kt
programmerr47
248,502,040
false
null
package com.leetcode /** * Possibly we can combine reverse method and fixSortedAsc * But I'm not sure about it since 2 cycles one operation in each * is equal to 1 cycle with two operations. So to gain some boost * we need to have less operations than sum of what we have. And * I'm not sure we can achieve that. ...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,743
problemsolving
Apache License 2.0
clikt/src/commonMain/kotlin/com/github/ajalt/clikt/sources/ValueSource.kt
ajalt
128,975,548
false
{"Kotlin": 546659, "Shell": 1814, "Batchfile": 662}
package com.github.ajalt.clikt.sources import com.github.ajalt.clikt.core.Context import com.github.ajalt.clikt.parameters.options.* interface ValueSource { data class Invocation(val values: List<String>) { companion object { /** Create a list of a single Invocation with a single value */ ...
14
Kotlin
120
2,314
5cb5ab199947709a26754c6f8eeb73da775fac07
3,146
clikt
Apache License 2.0
src/main/kotlin/_2022/Day25.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput import kotlin.math.pow fun main() { fun getNumber(char: Char): Long { return when (char) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else -> throw RuntimeException("unknown char") } } ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
1,504
advent-of-code
Apache License 2.0
2023/src/main/kotlin/de/skyrising/aoc2023/day3/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day3 import de.skyrising.aoc.* val test = TestInput(""" 467..114.. ...*...... ..35..633. ......#... 617*...... .....+.58. ..592..... ......755. ...${'$'}.*.... .664.598.. """) fun findNumbers(grid: CharGrid, pos: Vec2i, numbers: MutableMap<Vec2i, I...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,232
aoc
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountGoodStrings.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
2,891
kotlab
Apache License 2.0
aoc-kotlin/src/main/kotlin/day07/Day07.kt
mahpgnaohhnim
573,579,334
false
{"Kotlin": 29246, "TypeScript": 1975, "Go": 1693, "Rust": 1520, "JavaScript": 123}
package day07 import java.io.File class Day07 { companion object { val inputFile = File(this::class.java.getResource("input.txt")?.path.orEmpty()) fun getTotalSumSize(input: String, maxFolderSize: Int = 100000): Int { val rootFolder = createRootFolder(input) return sumUpByM...
0
Kotlin
0
0
c514152e9e2f0047514383fe536f7610a66aff70
4,393
aoc-2022
MIT License
src/main/kotlin/aoc2021/day6.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.loadInput import kotlin.math.roundToInt fun main() { val fishes = loadInput("/2021/day6") .bufferedReader() .readLines() .flatMap { it.split(",") } .map(String::toInt) // Part 1 - Naive solution which works but is slow ...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
1,319
aoc-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1770/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1770 /** * LeetCode page: [1770. Maximum Score from Performing Multiplication Operations](https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations/); */ class Solution { /* Complexity: * Time O(M^2) and Space O(M) where M is the size of mult...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
3,537
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/Fuel.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
fun main() = Fuel.solve() private object Fuel { fun solve() { println("${fromSnafu("1=11-2")}") println("-> ${toSnafu(12345)}") val nums = readInput() println("$nums") val sum = nums.sum() println("Sum: $sum, SNAFU: ${toSnafu(sum)}") } private fun readInput(...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
1,824
aoc2022
MIT License
src/Day02.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") private const val DAY = "02" private const val PART1_CHECK = 15 private const val PART2_CHECK = 12 private enum class RockPaperScissors(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3), ; } private val rock = RockPaperScissors.ROCK private val paper = RockPaperScissors....
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
3,092
adventofcode2022
Apache License 2.0
src/Day10.kt
cagriyildirimR
572,811,424
false
{"Kotlin": 34697}
fun day10Part1(){ val input = readInput("Day10").map { it.split(" ") } var cycle = 1 val l = listOf(20, 60, 100, 140, 180, 220) var register = 1 val cs = arrayOf(0,0,0,0,0,0) for (i in input) { when(i.first()) { "noop" -> { cycle++ checking(cy...
0
Kotlin
0
0
343efa0fb8ee76b7b2530269bd986e6171d8bb68
1,645
AoC
Apache License 2.0
src/Day10.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
import java.util.* fun main() { fun part1(input: List<String>): Int { val state = mutableListOf(1) for (line in input) { val scan = Scanner(line) val op = scan.next() when (op) { "noop" -> state.add(0) "addx" -> { ...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
1,767
aoc-2022
Apache License 2.0
src/main/kotlin/days/y2022/day19/Day19.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2022.day19 import util.InputReader import kotlin.math.ceil typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day19(val input: PuzzleInput) { val bluePrints = input.map { it.toBlueprint() } fun partOne(): Int { val initialState = GameState.initial() va...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
7,110
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/leetcode/Problem2055.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/plates-between-candles/ */ class Problem2055 { fun platesBetweenCandles(s: String, queries: Array<IntArray>): IntArray { val answer = IntArray(queries.size) var startIndex = 0 while (startIndex < s.length && s[startIndex] != '|') { ...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
2,454
leetcode
MIT License
src/ch6Arrays/6.1DutchFlag.kt
codingstoic
138,465,452
false
{"Kotlin": 17019}
package ch6Arrays fun main(args: Array<String>) { solution1(arrayOf(3, 5, 4, 6, 7, 1, 2), 2).forEach { print(it) } println() solution2(arrayOf(3, 5, 4, 6, 7, 1, 2), 2).forEach { print(it) } println() solution3(arrayOf(3, 5, 4, 6, 7, 1, 2), 2).forEach { print(it) ...
0
Kotlin
0
2
fdec1aba315405e140f605aa00a9409746cb518a
3,154
elements-of-programming-interviews-solutions
MIT License
y2021/src/main/kotlin/adventofcode/y2021/Day11.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import adventofcode.util.vector.mooreNeighbors object Day11 : AdventSolution(2021, 11, "Dumbo Octopus") { override fun solvePartOne(input: String) = generateSequence(parseInput(input), Grid::step).drop(1)...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,260
advent-of-code
MIT License
src/main/kotlin/Day6.kt
maldoinc
726,264,110
false
{"Kotlin": 14472}
import kotlin.io.path.Path import kotlin.io.path.readLines import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun waysToWin(time: Long, distance: Long): Long { val x1 = 0.5 * (time - sqrt(time * time - 4.0 * distance)) val x2 = 0.5 * (time + sqrt(time * time - 4.0 * distance)) return...
0
Kotlin
0
1
47a1ab8185eb6cf16bc012f20af28a4a3fef2f47
1,028
advent-2023
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem838/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem838 /** * LeetCode page: [838. Push Dominoes](https://leetcode.com/problems/push-dominoes/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the length of dominoes; */ fun pushDominoes(dominoes: String): String { val pushed = St...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,681
hj-leetcode-kotlin
Apache License 2.0
src/Day03.kt
othimar
573,607,284
false
{"Kotlin": 14557}
fun main(){ fun part1(input:List<String>):Int{ var priority = 0 for(bag in input){ val compSize = bag.length/2 val firstComp = bag.filterIndexed { index, _ -> index < compSize } val secondComp = bag.filterIndexed { index, _ -> index >= compSize} for ...
0
Kotlin
0
0
ff62a00123fe817773ff6248d34f606947ffad6d
1,304
advent-of-code-2022
Apache License 2.0
2016/src/main/kotlin/com/koenv/adventofcode/Day11.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode import java.util.* import java.util.regex.Pattern /** * This one is quite slow, probably due to a lot of allocations in getAdjacentStates, which allocates * a new list for every possible state */ object Day11 { fun getRequiredSteps(input: String): Int { val types = hashSe...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
9,305
AdventOfCode-Solutions-Kotlin
MIT License
day08/src/main/kotlin/Day08.kt
bzabor
160,240,195
false
null
class Day08(private val input: List<String>) { private val regex = Regex("""\D+""") private var numList: MutableList<Int> = regex.split(input[0]).map { it.toInt() }.toMutableList() private var sum = 0 fun part1(): Int { process1() return sum } private fun process1() { ...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
2,689
AdventOfCode2018
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PalindromePartitioning.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
3,014
kotlab
Apache License 2.0
year2020/day18/expression/src/main/kotlin/com/curtislb/adventofcode/year2020/day18/expression/evaluate.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2020.day18.expression import com.curtislb.adventofcode.common.number.productOf /** * TODO */ fun evaluate(expression: String): Long { val results = mutableListOf<Long>() val operators = mutableListOf('(') for (token in expression) { when (token) { ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,231
AdventOfCode
MIT License
src/main/kotlin/day13/Departures.kt
lukasz-marek
317,632,409
false
{"Kotlin": 172913}
package day13 data class Bus(val id: Long) fun Bus.departures(startingPoint: Long = 0): Sequence<Long> { val multiplier = startingPoint / id val seed = multiplier * id return generateSequence(seed) { it + id } } data class Passenger(val arrivesAt: Long) fun Bus.earliestDepartureFor(passenger: Passenger)...
0
Kotlin
0
0
a16e95841e9b8ff9156b54e74ace9ccf33e6f2a6
2,602
aoc2020
MIT License
src/main/kotlin/Day12.kt
SimonMarquis
434,880,335
false
{"Kotlin": 38178}
class Day12(raw: List<String>) { companion object { val START = Cave("start") val END = Cave("end") } private val input = raw.toGraph() fun part1(): Int = input.paths(allowTwoSmalls = false).size fun part2(): Int = input.paths(allowTwoSmalls = true).size @JvmInline value...
0
Kotlin
0
0
8fd1d7aa27f92ba352e057721af8bbb58b8a40ea
1,917
advent-of-code-2021
Apache License 2.0
src/day16/Day16.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day16 import helpers.ReadFile import java.lang.Integer.min class Day16 { class Node { val name: String var isOn = false val rate: Int val connections: MutableList<Node> = mutableListOf() val shortestDistanceToNode: MutableMap<String, Int> = mutableMapOf() v...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
15,671
adventofcode2022
MIT License
kotlin/combinatorics/Permutations.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package combinatorics import numeric.FFT import optimization.Simplex object Permutations { fun nextPermutation(p: IntArray): Boolean { var a = p.size - 2 while (a >= 0) { if (p[a] < p[a + 1]) { var b = p.size - 1 while (true) { if (p[...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,939
codelibrary
The Unlicense
src/questions/RemoveDuplicateFromSortedArray.kt
realpacific
234,499,820
false
null
package questions import algorithmdesignmanualbook.print import kotlin.test.assertEquals import kotlin.test.assertTrue /** * Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place. * The relative order of the elements should be kept the same. * More formally, if there are k elem...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,414
algorithms
MIT License
examples/regression/src/main/kotlin/WeightedRegression.kt
Kotlin
225,367,588
false
{"Kotlin": 435270, "C": 152277, "Python": 7577}
import org.jetbrains.numkt.* import org.jetbrains.numkt.core.KtNDArray import org.jetbrains.numkt.core.dot import org.jetbrains.numkt.core.ravel import org.jetbrains.numkt.core.reshape import org.jetbrains.numkt.linalg.Linalg import org.jetbrains.numkt.math.* import org.jetbrains.numkt.random.Random import org.jetbrain...
11
Kotlin
11
313
2f1421883c201df60c57eaa4db4c3ee74dc40413
1,857
kotlin-numpy
Apache License 2.0
src/Day02.kt
marvingrewe
573,069,044
false
{"Kotlin": 6473}
import kotlin.system.measureTimeMillis fun main() { val day = "Day02" fun matchUpPoints1(letter: String): Int = when (letter) { "A X" -> 4 "B X" -> 1 "C X" -> 7 "A Y" -> 8 "B Y" -> 5 "C Y" -> 2 "A Z" -> 3 "B Z" -> 9 "C Z" -> 6 els...
0
Kotlin
0
0
adec59f236b5f92cfcaf9e595fb913bf0010ac41
1,304
advent-of-code-2022
Apache License 2.0
src/Day02.kt
yashpalrawat
573,264,560
false
{"Kotlin": 12474}
enum class MOVETYPE(val value: Int) { ROCK(1), PAPER(2), SCISSOR(3) } val mapping = mapOf( "X" to MOVETYPE.ROCK, "Y" to MOVETYPE.PAPER, "Z" to MOVETYPE.SCISSOR, "A" to MOVETYPE.ROCK, "B" to MOVETYPE.PAPER, "C" to MOVETYPE.SCISSOR, ) fun findWinningPlayer(firstMove: MOVETYPE, second...
0
Kotlin
0
0
78a3a817709da6689b810a244b128a46a539511a
1,672
code-advent-2022
Apache License 2.0
Kotlin/days/src/day14.kt
dukemarty
224,307,841
false
null
import java.io.BufferedReader import java.io.FileReader import java.lang.Integer.min class ChemicalStore { private val store = mutableListOf<Chemical>() fun contains(name: String): Boolean { val stored = store.firstOrNull { it.name == name } return stored != null } fun getStoreSize(...
0
Kotlin
0
0
6af89b0440cc1d0cc3f07d5a62559aeb68e4511a
6,602
dukesaoc2019
MIT License
src/Utils.kt
hoppjan
433,705,171
false
{"Kotlin": 29015, "Shell": 338}
/** * Prints test result of a part and solution. */ fun <T> printTestResult(part: Int = 1, result: T, expected: T) = println("test result $part: $result, $expected expected") /** * Prints result of a part. */ fun <T> printResult(part: Int, result: T) = println("result part $part: $result") /** * Boilerp...
0
Kotlin
0
0
04f10e8add373884083af2a6de91e9776f9f17b8
1,528
advent-of-code-2021
Apache License 2.0
src/Day08.kt
A55enz10
573,364,112
false
{"Kotlin": 15119}
import java.lang.Integer.max fun main() { fun String.isVisibleFromSides(idx: Int): Boolean { return this.substring(0,idx).all { it.digitToInt() < this[idx].digitToInt() } || this.substring(idx+1).all { it.digitToInt() < this[idx].digitToInt() } } fun part1(input: List<String>): I...
0
Kotlin
0
1
8627efc194d281a0e9c328eb6e0b5f401b759c6c
3,243
advent-of-code-2022
Apache License 2.0
src/Day08.kt
kuolemax
573,740,719
false
{"Kotlin": 21104}
fun main() { fun part1(input: List<String>): Int { val size = input.size var result = (size - 1) * 4 val matrix = input.map { row -> val map = row.map { it.toString().toInt() } map } // col 从 2 -> size - 1 check // row 从 2 -> size - 1 check ...
0
Kotlin
0
0
3045f307e24b6ca557b84dac18197334b8a8a9bf
3,881
aoc2022--kotlin
Apache License 2.0
year2020/src/main/kotlin/net/olegg/aoc/year2020/day13/Day13.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day13 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseLongs import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 13](https://adventofcode.com/2020/day/13) */ object Day13 : DayOf2020(13) { override fun first(): Any? { val (startLine, busLine) = ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,138
adventofcode
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2022/Day12.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.test.assertEquals object Day12 : AbstractDay() { @Test fun part1() { assertEquals(31, compute1(testInput)) assertEquals(437, compute1(puzzleInput)) } @Test fun part2() { ...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
3,884
aoc
Apache License 2.0
src/Day06.kt
tblechmann
574,236,696
false
{"Kotlin": 5756}
fun main() { fun part1(input: String, windowLength: Int = 4): Int { var slidingWindowEnd = windowLength var slidingWindowStart = 0 while (input .substring(slidingWindowStart, slidingWindowEnd) .toCharArray() .distinct().size < windowLength) { ...
0
Kotlin
0
0
4a65f6468a0cddd8081f2f0e3c1a96935438755f
1,286
aoc2022
Apache License 2.0
src/main/kotlin/problems/Day6.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day6(override val input: String) : Problem { override val number: Int = 6 private val fishAges = input.split(",").map { i -> i.toInt() } override fun runPartOne(): String { return runMultipleDays(80, fishAges).toString() } override fun runPartTwo(): String { ...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
1,314
AdventOfCode2021
MIT License
year2023/day05/almanac/src/main/kotlin/com/curtislb/adventofcode/year2023/day05/almanac/CategoryMap.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2023.day05.almanac import com.curtislb.adventofcode.common.range.overlap import com.curtislb.adventofcode.common.range.size /** * A map that provides rules converting values of one category to new values of another category. * * @property sourceCategory The category of values ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
6,683
AdventOfCode
MIT License
src/Day04_part2.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part2(input: List<String>): Int { fun hasOverlap(elf1: Pair<Int, Int>, elf2: Pair<Int, Int>): Boolean { if (elf2.first < elf1.first) { return hasOverlap(elf2, elf1) } if (elf2.first <= elf1.second) { return true ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
1,068
advent-of-code-2022
Apache License 2.0
src/adventofcode/blueschu/y2017/day06/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day06 import java.io.File import kotlin.test.assertEquals fun input(): List<Byte> { return File("resources/y2017/day06.txt") .bufferedReader() .use { it.readText() } .trim() .split(Regex("\\s+")) // only 119 blocks in input, might as well...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
2,674
Advent-Of-Code
MIT License
src/2023/Day14.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.lang.StringBuilder import java.util.* fun main() { Day14().solve() } class Day14 { val input1 = """ O....#.... O.OO#....# .....##... OO.#O....O .O.....O#. O.#..O.#.# ..O..#O..O .......O.. ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
2,908
advent-of-code
Apache License 2.0
src/main/kotlin/dp/maximalSquare/SolutionKt.kt
eleven-max
441,597,605
false
{"Java": 104251, "Kotlin": 41506}
package dp.maximalSquare import com.evan.dynamicprogramming.Common.CommonUtil //https://leetcode-cn.com/problems/maximal-square/ class SolutionKt { fun maximalSquare(matrix: Array<CharArray>): Int { val dp = Array(matrix.size) { IntArray(matrix[0].size) { 0 } } var r = 0 //第一行 for ...
0
Java
0
0
2e9b234b052896c6b8be07044d2b0c6812133e66
1,265
Learn_Algorithm
Apache License 2.0
src/Day02.kt
Pixselve
572,907,486
false
{"Kotlin": 7404}
fun main() { /** * First: A for Rock, B for Paper, and C for Scissors * Second: X for Rock, Y for Paper, and Z for Scissors * * A beats Z * B beats X * C beats Y * */ fun pointPerPair(pair: Pair<Char, Char>): Int { return when (pair.second) { 'X' -> 1 ...
0
Kotlin
0
0
10e14393b8b6ee3f98dfd4c37e32ad81f9952533
3,188
advent-of-code-2022-kotlin
Apache License 2.0
2022/src/main/kotlin/org/suggs/adventofcode/Day12HillClimbing.kt
suggitpe
321,028,552
false
{"Kotlin": 156836}
package org.suggs.adventofcode import org.slf4j.LoggerFactory object Day12HillClimbing { private val log = LoggerFactory.getLogger(this::class.java) // ====== DEPTH FIRST fun findShortestDepthFirstRouteToEnd(grid: List<List<Char>>): Int { val startEnd = findStartAndEndFrom(grid) log.debug...
0
Kotlin
0
0
9485010cc0ca6e9dff447006d3414cf1709e279e
3,267
advent-of-code
Apache License 2.0
src/me/bytebeats/algo/kt/Solution6.kt
bytebeats
251,234,289
false
null
package me.bytebeats.algo.kt import kotlin.collections.ArrayList import me.bytebeats.algs.ds.ListNode import me.bytebeats.algs.ds.Node import me.bytebeats.algs.ds.TreeNode class Solution6 { fun nextGreatestLetter(letters: CharArray, target: Char): Char {//744, O(n) var index = -1 for (i in letter...
0
Kotlin
0
1
7cf372d9acb3274003bb782c51d608e5db6fa743
40,233
Algorithms
MIT License
src/net/sheltem/aoc/y2023/Day11.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.PositionInt import net.sheltem.common.manhattan suspend fun main() { Day11().run() } class Day11 : Day<Long>(374, 82000210) { override suspend fun part1(input: List<String>): Long = input.toUniverseMap(1).pairUp().sumOf { it.first manhattan it.second }...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,603
aoc
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/NormalizedLevenshtein.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.max /** * This distance is computed as levenshtein distance divided by the length of the longest string. * The resulting value is always in the interval 0 to 1. * * [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance) */ public class Normaliz...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
1,522
string-similarity-kotlin
MIT License
src/main/kotlin/sschr15/aocsolutions/Day17.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* /** * AOC 2023 [Day 17](https://adventofcode.com/2023/day/17) * Challenge: How do you best fuel all those metal crucibles, anyway? */ object Day17 : Challenge { @ReflectivelyUsed override fun solve() = challenge(2023, 17) { // test() ...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
2,948
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/DiagonalMatrixSort.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
3,592
kotlab
Apache License 2.0
src/Day3/Day3.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day3 import readInput fun main() { val priority = CharRange('a', 'z').plus(CharRange('A', 'Z')) fun part1(input: List<String>): Int { return input .map { rucksack: String -> val half = rucksack.length / 2 listOf(rucksack.take(half).toSet(), rucksac...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
1,051
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day3/Day3.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day3 import execute import readAllText import wtf fun part1(input: String) = input.lineSequence().filter(String::isNotBlank) .map { it.chunked(it.length / 2).map(String::toSet) } .map { (p1, p2) -> p1.first { it in p2 } } .sumOf(::priority) fun part2(input: String) = input.lineSequence().filter(S...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
1,028
advent-of-code-2022
MIT License
src/main/kotlin/g0801_0900/s0834_sum_of_distances_in_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0834_sum_of_distances_in_tree // #Hard #Dynamic_Programming #Depth_First_Search #Tree #Graph // #2023_03_27_Time_746_ms_(100.00%)_Space_65.9_MB_(100.00%) class Solution { private var n = 0 private lateinit var count: IntArray private lateinit var answer: IntArray private lateinit v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,410
LeetCode-in-Kotlin
MIT License
src/main/aoc2018/Day18.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 import Grid import Pos class Day18(input: List<String>) { private var area = Grid.parse(input) private fun nextState(area: Grid, pos: Pos): Char { val trees = area.numNeighboursWithValue(pos, '|', true) val yards = area.numNeighboursWithValue(pos, '#', true) return whe...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,060
aoc
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day25.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day25.run() object Day25 : Day(2022, 25) { override fun part1() = dec2Snafu(input.lines().map { snafu2Dec(it) }.sumOf { it }) override fun part2() = "" private fun dec2Snafu(dec: Long): String { var left = dec v...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,283
adventofkotlin
MIT License
kotlin/src/com/daily/algothrim/leetcode/PivotIndex.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 724. 寻找数组的中心索引 * * 给定一个整数类型的数组 nums,请编写一个能够返回数组 “中心索引” 的方法。 * * 我们是这样定义数组 中心索引 的:数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 * * 如果数组不存在中心索引,那么我们应该返回 -1。如果数组有多个中心索引,那么我们应该返回最靠近左边的那一个。 * */ class PivotIndex { companion object { @JvmStatic fun main(args: Array<S...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,557
daily_algorithm
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch5/Problem54.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 /** * Problem 54: Poker Hands * * https://projecteuler.net/problem=54 * * Goal: Determine the winner when presented with 2 poker hands, based on the rules detailed * below and assuming that all cards are valid and a winner is possible. * * Constraints: None * * Poker Hand Rankings:...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
6,552
project-euler-kotlin
MIT License
2017/src/fifteen/DiskDefragmentationChallenge.kt
Mattias1
116,139,424
false
null
package fifteen class DiskDefragmentationChallenge { fun usedSquares(salt: String): Int { val diskGrid = getDiskGrid(salt) return diskGrid.sumBy { it.count { it } } } private fun getDiskGrid(salt: String): List<List<Boolean>> { return (0..127).map { knotHash(salt + '-' ...
0
Kotlin
0
0
6bcd889c6652681e243d493363eef1c2e57d35ef
3,172
advent-of-code
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day04.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 class Day04(input: String) { private val fieldNames = listOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid") private val entries = input.split("\n\n").map(this::splitEntry) fun solvePart1(): Int { return entries.count { val list = fieldNames.toMu...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,283
advent-of-code
Apache License 2.0
src/main/java/com/booknara/problem/twopointers/LongestMountainInArrayKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.twopointers /** * 845. Longest Mountain in Array (Medium) * https://leetcode.com/problems/longest-mountain-in-array/ */ class LongestMountainInArrayKt { // T:O(n), S:O(1) fun longestMountain(A: IntArray): Int { // input check if (A.size <= 2) return 0 va...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,237
playground
MIT License
src/main/kotlin/days/Day13.kt
TheMrMilchmann
571,779,671
false
{"Kotlin": 56525}
/* * Copyright (c) 2022 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
2e01ab62e44d965a626198127699720563ed934b
3,722
AdventOfCode2022
MIT License
src/Day08.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import java.math.BigInteger fun main() { val input = readInput("Day08") val instructions = input[0] val map = input.drop(2).associate { val key = it.substringBefore(' ') val left = it.substringAfter('(').substringBefore(',') val right = it.substringAfter(", ").substringBefore(')') ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,574
advent-of-code-kotlin
Apache License 2.0
src/day08/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 8: Treetop Tree House * https://adventofcode.com/2022/day/8 */ package day08 import utils.Grid import java.io.File import kotlin.math.max fun main() { val fileName = // "day08_sample.txt" "day08_input.txt" val forest = readInput(fileName) // Part 1: visible trees from ...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
4,241
aoc2022-kotlin
Apache License 2.0
src/Lesson7StacksAndQueues/Fish.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Stack /** * 100/100 * @param A * @param B * @return */ fun solution(A: IntArray, B: IntArray): Int { // main idea: use "stack" to store the fishes with B[i]==1 // that is, "push" the downstream fishes into "stack" // note: "push" the Size of the downstream fish val downstream: ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
3,789
Codility-Kotlin
Apache License 2.0
src/main/kotlin/year2023/Day01.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 class Day01 { companion object { val digits = (0..9).associateBy { it.toString() } val words = listOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine") .withIndex().associate { (idx, word) -> word to idx + 1 } val digitsAndWords = digits +...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
854
aoc-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2019/Day22.kt
tginsberg
222,116,116
false
null
/* * Copyright (c) 2019 by <NAME> */ /** * Advent of Code 2019, Day 22 - Slam Shuffle * Problem Description: http://adventofcode.com/2019/day/22 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day22/ */ package com.ginsberg.advent2019 import java.math.BigInteger import java.math.BigIn...
0
Kotlin
2
23
a83e2ecdb6057af509d1704ebd9f86a8e4206a55
3,096
advent-2019-kotlin
Apache License 2.0
kotlin/combinatorics/Combinations.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package combinatorics import java.util.Arrays // https://en.wikipedia.org/wiki/Combination object Combinations { fun nextCombination(comb: IntArray, n: Int): Boolean { val k = comb.size var i = k - 1 while (i >= 0) { if (comb[i] < n - k + i) { ++comb[i] ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,823
codelibrary
The Unlicense
src/Day02.kt
luix
573,258,926
false
{"Kotlin": 7897, "Java": 232}
fun main() { fun part1(input: List<String>): Int { var max = 0 var sum = 0 input.forEach { if (it == "") { max = if (sum > max) sum else max sum = 0 } else { sum += it.toInt() } } return max ...
0
Kotlin
0
0
8e9b605950049cc9a0dced9c7ba99e1e2458e53e
1,047
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day10.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getLines private val invalidRightParantheses = Regex("""[\[<{]\)""") private val invalidRightSquareBracket = Regex("""[(<{]]""") private val invalidRightSquirlyBracket = Regex("""[\[<(]}""") private val invalidRightCrocodile = Regex("""[\[({]>""") fun totalSyntaxScore(lines: List<String>): Int{ var ...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
2,534
AdventOfCode2021
MIT License
solver/src/commonMain/kotlin/org/hildan/sudoku/solver/techniques/NakedTuples.kt
joffrey-bion
9,559,943
false
{"Kotlin": 51198, "HTML": 187}
package org.hildan.sudoku.solver.techniques import org.hildan.sudoku.model.* /** * Trivially sets the digit of a cell when only one candidate remains for that cell. */ object NakedSingles : Technique { override fun attemptOn(grid: Grid): List<NakedSinglesStep> { val actions = grid.emptyCells.asSequence...
0
Kotlin
0
0
441fbb345afe89b28df9fe589944f40dbaccaec5
4,112
sudoku-solver
MIT License
src/main/kotlin/d15/d15.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d15 import readInput import java.util.Scanner import kotlin.math.abs fun part1(input: List<String>, row : Long): Int { val ranges = mutableListOf<LongRange>() val beacons = mutableSetOf<LongRange>() for (line in input) { val scan = Scanner(line) scan.useDelimit...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
5,121
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/me/peckb/aoc/_2019/calendar/day18/Day18.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2019.calendar.day18 import arrow.core.mapNotNull import me.peckb.aoc._2019.calendar.day18.Day18.Section.* import me.peckb.aoc._2019.calendar.day18.Day18.Section.Source.* import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory typealias Distance = Int clas...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
3,461
advent-of-code
MIT License
src/main/kotlin/summarisation/Summarise.kt
rock3125
138,799,834
false
{"Kotlin": 30711, "Java": 939, "Shell": 774}
package summarisation import summarisation.parser.Sentence import summarisation.parser.StanfordParser import summarisation.parser.Token import summarisation.parser.Undesirables import java.util.* import kotlin.collections.ArrayList import kotlin.math.ln import kotlin.math.sqrt /** * Extractive Summarization of text...
0
Kotlin
0
4
24d8916dbecde35eaeb760eb4307ca32a4ecb768
16,681
ExtractiveSummarisation
MIT License
BestFit/src/Main.kt
nepinney
218,421,434
false
{"Kotlin": 2566}
import java.util.* import kotlin.collections.ArrayList import kotlin.math.ceil import kotlin.random.Random fun generatePackages() = sequence { val i = 100 while (true) yield((i*Random.nextFloat()).toInt()) } fun generateBins() = sequence { var i = 0 while (true) yield(Bin(i...
0
Kotlin
0
0
2404ae78a0af3c4771bd06685e66cf087226195f
2,208
Best-Fit-Bin-Packing
The Unlicense
src/Day06.kt
jalex19100
574,686,993
false
{"Kotlin": 19795}
fun main() { fun allUnique(string: String): Boolean { val setOfChars = string.toSet().distinct() // println("$string <=> $setOfChars: ${string.length == setOfChars.size}") return (string.length == setOfChars.size) } fun part1(input: String, markerSize: Int = 4): Int { var in...
0
Kotlin
0
0
a50639447a2ef3f6fc9548f0d89cc643266c1b74
979
advent-of-code-kotlin-2022
Apache License 2.0
src/day06/Day06.kt
zypus
573,178,215
false
{"Kotlin": 33417, "Shell": 3190}
package day06 import AoCTask // https://adventofcode.com/2022/day/6 fun Sequence<Char>.charactersReadToFindSequenceOfDistinctSize(size: Int): Int { val index = this .windowed(size, step = 1) .indexOfFirst { it.toSet().size == size } return index + size } fun part1(input: ...
0
Kotlin
0
0
f37ed8e9ff028e736e4c205aef5ddace4dc73bfc
1,214
aoc-2022
Apache License 2.0
src/day3/main.kt
rafagalan
573,145,902
false
{"Kotlin": 5674}
package day3 import readInput fun Char.toPriority(): Int { if(this.isLowerCase()) return this.code - 96 return this.code - 38 } fun <A> setIntersect(a: Set<A>, b: Set<A>) = a.intersect(b) fun main() { fun part1(input: List<String>) = input.sumOf { it.windowed(it.length/2, it.length/...
0
Kotlin
0
0
8e7d3f25fe52a4153479adb56c5924b50f6c0be9
1,033
AdventOfCode2022
Apache License 2.0
src/day04/Day04.kt
TimberBro
567,240,136
false
{"Kotlin": 11186}
package day04 import utils.readInput import kotlin.streams.toList fun main() { fun separatePassports(input: List<String>): List<List<String>> { val passportsList = ArrayList<List<String>>() var passport = ArrayList<String>() val iterator = input.listIterator() while (iterator.hasNe...
0
Kotlin
0
0
1959383d2f422cc565560eefb1ed4f05bb87a386
4,603
aoc2020
Apache License 2.0
src/day04/Day04.kt
cmargonis
573,161,233
false
{"Kotlin": 15730}
package day04 import readInput private const val DIRECTORY = "./day04" fun main() { fun IntRange.contains(other: IntRange): Boolean = first <= other.first && last >= other.last /** * Converts e.g. 22-34 to a [IntRange] */ fun textToRange(rawRange: String): IntRange = rawRange .split("...
0
Kotlin
0
0
bd243c61bf8aae81daf9e50b2117450c4f39e18c
1,012
kotlin-advent-2022
Apache License 2.0
gcj/y2020/qual/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.qual private fun solve(n: Int, period: Int = 10) { val a = IntArray(n) var iter = 0 fun ask(index: Int): Int { iter++ println(index + 1) return readInt() } val first = IntArray(2) { -1 } val negated = IntArray(2) { -1 } fun fetchNegated(d: Int) { negated[d] = if (first[d] == -1) 0 else...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,234
competitions
The Unlicense
src/main/kotlin/org/gmd/service/alg/ELOMemberRatingAlgorithm.kt
akustik
184,784,065
false
null
package org.gmd.service.alg import org.gmd.model.Evolution import org.gmd.model.Game import org.gmd.model.Score import org.springframework.stereotype.Component @Component open class ELOMemberRatingAlgorithm : MemberRatingAlgorithm { companion object { fun probabilityOfWinForBRating(ratingA: Double, ratin...
9
Kotlin
3
4
07184b0ea0889b22c78b46f710818187d36b1af7
3,439
topscores
MIT License
src/main/kotlin/dev/phiber/aoc2022/day4/Solution.kt
rsttst
572,967,557
false
{"Kotlin": 7688}
package dev.phiber.aoc2022.day4 import dev.phiber.aoc2022.readAllLinesUntilEmpty fun parseRange(rangeStr: String) : IntRange { val (rangeStartStr, rangeEndStr) = rangeStr.split("-", limit = 2) return rangeStartStr.toInt()..rangeEndStr.toInt() } infix fun IntRange.fullyContains(other: IntRange) : Boolean = t...
0
Kotlin
0
0
2155029ebcee4727cd0af75543d9f6f6ab2b8995
1,254
advent-of-code-2022
Apache License 2.0
src/day_14/kotlin/Day14.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
import kotlin.math.sign // AOC Day 14 const val rockCharacter = '#' const val sandCharacter = '.' const val airCharacter = ' ' const val printCave = false typealias Cave = Array<CharArray> fun Cave.print() = forEach { println(it.joinToString(" ")) }.also { println() } operator fun Cave.get(point: Vector2D) = this[...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
3,912
AdventOfCode2022
MIT License
src/day02/Day02.kt
jimsaidov
572,881,855
false
{"Kotlin": 10629}
package day02 class Day02(private val input: List<String>) { private val DRAW = 3 private val WIN = 6 private val points = mapOf('X' to 1, 'Y' to 2, 'Z' to 3) private val drawPoints = mapOf("A X" to 4, "B Y" to 5, "C Z" to 6) private val lossPoints = mapOf("A Z" to 3, "B X" to 1, "C Y" to 2) ...
0
Kotlin
0
0
d4eb926b57460d4ba4acced14658f211e1ccc12c
1,525
aoc2022
Apache License 2.0
kotlin/14.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
class Day14 : Day<Day14.Replacements>("14") { data class Replacements(val template: String, val mappings: Map<String, String>) override fun dataStar1(lines: List<String>) = Replacements(lines.first(), lines.drop(1).associate { it.strings("->").let { it[0] to it[1] } }) override fun dataStar2(lines...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
1,722
advent-of-code-2021
MIT License
src/Day08_part2.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.max private data class Score(var left: Int, var right: Int, var up: Int, var down: Int) { override fun toString() = "$left, $right, $up, $down" } fun main() { val lines = readInput("Day08_input") val rows = lines.size val cols = lines[0].length val input = Array(rows) { i -> Arr...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,847
aoc-2022
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[剑指 Offer 53 - II]0~n-1中缺失的数字.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//一个长度为n-1的递增排序数组中的所有数字都是唯一的,并且每个数字都在范围0~n-1之内。在范围0~n-1内的n个数字中有且只有一个数字不在该数组中,请找出 //这个数字。 // // // // 示例 1: // // 输入: [0,1,3] //输出: 2 // // // 示例 2: // // 输入: [0,1,2,3,4,5,6,7,9] //输出: 8 // // // // 限制: // // 1 <= 数组长度 <= 10000 // Related Topics 数组 二分查找 // 👍 90 👎 0 //leetcode submit region begin(Prohibit m...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,357
MyLeetCode
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NetworkDelayTime.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,523
kotlab
Apache License 2.0
src/Day10.kt
slawa4s
573,050,411
false
{"Kotlin": 20679}
data class Command(val command: String, val value: Int?) const val ADDX = "addx" const val NOOP = "noop" val mapOfTimeOfCommand = mapOf( ADDX to 2, NOOP to 1 ) fun main() { fun isCycleCounted(cycle: Int): Boolean = (cycle - 20) % 40 == 0 fun prepareInput(input: List<String>): List<Command> = input.m...
0
Kotlin
0
0
cd8bbbb3a710dc542c2832959a6a03a0d2516866
1,053
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day10.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day10 { fun part1(input: String): Int { val (start, grid) = parseInput(input) val loop = findLoop(start, grid) return loop.size / 2 } fun part2(input: String): Int { val (start, grid) = parseInput(input) val loop = findLoop(start, grid) ...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
5,675
advent-of-code-2023
MIT License
src/main/de/ddkfm/Day3.kt
DDKFM
433,861,159
false
{"Kotlin": 13522}
package de.ddkfm class Day3 : DayInterface<List<String>, Int> { override fun part1(input: List<String>): Int { val maxLength = input.maxOf { it.length } val rates = (0 until maxLength).map { i -> var recognizableChars = input.map { it[i] } val mostCommonBit = getMostCommonBi...
0
Kotlin
0
0
6e147b526414ab5d11732dc32c18ad760f97ff59
1,997
AdventOfCode21
MIT License
src/com/github/frozengenis/day4/Puzzle.kt
FrozenSync
159,988,833
false
null
package com.github.frozengenis.day4 import java.io.File import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.* fun main() { val guards = File("""src\com\github\frozengenis\day4\input.txt""") .let(::parseInputToLogs) .let(::applyLogsToGuards) val guardMostS...
0
Kotlin
0
0
ec1e3472990a36b4d2a2270705253c679bee7618
2,449
advent-of-code-2018
The Unlicense
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/ModifiedBinarySearch.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Use this technique to search a sorted set of elements efficiently. The "Modified Binary Search" coding pattern is a variation of the standard binary search, often used to find specific elements or conditions in a sorted array that doesn't necessarily have a straightforward match. */ //1. Ceiling of a Number fun sea...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,257
Kotlin-Data-Structures-Algorithms
Apache License 2.0
advent-of-code2016/src/main/kotlin/day05/Advent5.kt
REDNBLACK
128,669,137
false
null
package day05 import toHex import toMD5 /** --- Day 5: How About a Nice Game of Chess? --- You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies. The eight-character password for the door is generated one characte...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
4,006
courses
MIT License
src/Day05.kt
emanguy
573,113,840
false
{"Kotlin": 17921}
import java.util.Stack data class Instruction( val quantity: Int, val sourceIdx: Int, val destinationIdx: Int, ) data class ParsedInput( val stacks: MutableList<Stack<Char>>, val instructions: List<Instruction> ) fun MutableList<Stack<Char>>.addCrate(stackIdx: Int, value: Char) { while (this....
0
Kotlin
0
1
211e213ec306acc0978f5490524e8abafbd739f3
4,202
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/startat/aoc2023/Day6.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 import kotlin.math.sqrt data class Race(val raceTime:Long, val bestDistance : Long) class Day6 { fun star1(){ var numberOfResults = 1 numberOfResults *= simulateRace(Race(46,214)) numberOfResults *= simulateRace(Race(80,1177)) numberOfResults *= simulate...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
1,786
AOC2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/day05/AlmanacMap.kt
limelier
725,979,709
false
{"Kotlin": 48112}
package day05 import day05.Domain.Companion.domain import day05.Interval.Companion.startInterval import kotlin.math.sign internal class AlmanacMap( entries: List<Entry> ) { private val entries = entries.sortedBy { it.source.lower } internal class Entry( destinationStart: Long, sourceStart...
0
Kotlin
0
0
0edcde7c96440b0a59e23ec25677f44ae2cfd20c
3,589
advent-of-code-2023-kotlin
MIT License