path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/day7/fr/Day07_2.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
package day7.fr import kotlin.math.abs 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 ...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
1,665
Advent-of-Code-2021
Apache License 2.0
11/src/main/kotlin/SantaPass.kt
kopernic-pl
109,750,709
false
null
const val INPUT = "hepxcrrq" typealias IncrementResult = Pair<Boolean, Char> fun main() { val generator = SantaPass() val passwords = generator.generateNextPasswords(INPUT, 2) println(passwords) } internal class SantaPass { fun generateNextPasswords(currentPass: String, n: Int): List<String> { ...
0
Kotlin
0
0
06367f7e16c0db340c7bda8bc2ff991756e80e5b
1,778
aoc-2015-kotlin
The Unlicense
src/Day07.kt
RichardLiba
572,867,612
false
{"Kotlin": 16347}
data class TempFile( val name: String, val isDir: Boolean, val parentName: String, val children: MutableList<TempFile>?, val size: Int? = null, ) { override fun toString(): String { return """- $name (${if (isDir) "dir" else "file, size=$size, parent = $parentName"}) ${if (!isDir) "" e...
0
Kotlin
0
0
6a0b6b91b5fb25b8ae9309b8e819320ac70616ed
3,920
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/d14/D14_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d14 import input.Input import kotlin.math.sqrt fun getPlatformString(platform: Array<CharArray>): String { return platform.joinToString("") { it.joinToString("") } } fun parsePlatformStr(platformStr: String): Array<CharArray> { val lineLength = sqrt(platformStr.length.toDouble()).toInt() val line...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
1,517
aoc2023-kotlin
MIT License
kotlin/src/com/s13g/aoc/aoc2018/Day2.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2018 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** https://adventofcode.com/2018/day/2 */ class Day2 : Solver { override fun solve(lines: List<String>): Result { val counts = Counts() lines.map { s -> count(s) }.forEach { c -> counts.add(c) } return Result(counts.chec...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,347
euler
Apache License 2.0
src/main/kotlin/y2023/day05/Day05.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2023.day05 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } data class Input( val seeds: List<Long>, val seedRanges: List<Pair<Long, Long>>, val seedToSoil: List<Triple<Long, Long, Long>>, val soilToFert: List<Triple<Long, L...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
5,276
AdventOfCode
MIT License
src/Day02.kt
ozzush
579,610,908
false
{"Kotlin": 5111}
fun main() { fun winPoints(elf: Char, you: Char): Int { val outcomePoints = mapOf('X' to 0, 'Y' to 3, 'Z' to 6)[you]!! val win = mapOf('A' to 'B', 'B' to 'C', 'C' to 'A') val lose = mapOf('A' to 'C', 'B' to 'A', 'C' to 'B') val points = mapOf('A' to 1, 'B' to 2, 'C' to 3) ret...
0
Kotlin
0
0
9b29a13833659f86d3791b5c07f9decb0dcee475
689
AdventOfCode2022
Apache License 2.0
day2-kotlin/src/main/kotlin/GameRequirements.kt
davidwhitney
725,882,326
false
{"Kotlin": 3532, "TypeScript": 3348}
import java.util.stream.Stream class GameRequirements(val gameId: Int, private val requirements: HashMap<String, Int>) { val power: Int get() { return requirements["red"]!! * requirements["green"]!! * requirements["blue"]!!; } fun isViable(red: Int, green: Int, blue: Int): Boolean ...
0
Kotlin
0
1
7989c1b555e93199f36cdb9a8871f91b9cfe2828
2,013
Aoc2023
MIT License
src/main/kotlin/io/queue/LastStoneWeight.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.queue import io.models.TreeNode import io.utils.runTests import java.util.* // https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/529/week-2/3297/ class LastStoneWeight { fun execute(stones: IntArray): Int { val stack = LinkedList(stones.toList()) stack.sortDescending() w...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,424
coding
MIT License
src/main/kotlin/year2021/day-17.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.aoc.Day import lib.aoc.Part import lib.math.product import kotlin.math.sign import kotlin.math.sqrt fun main() { Day(17, 2021, PartA17(), PartB17()).run() } open class PartA17 : Part() { protected var xMin: Int = 0 protected var xMax: Int = 0 protected var yMin: Int = 0 ...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
1,906
Advent-Of-Code-Kotlin
MIT License
aoc2023/day14.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day14.execute() } private object Day14 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: Platform): Long = input.moveRocksNorth()...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
4,499
Advent-Of-Code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShipWithinDays.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,875
kotlab
Apache License 2.0
src/aoc2022/Day14.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* import utils.Coord.Companion.get import utils.Coord.Companion.set import kotlin.math.max import kotlin.math.min private class Day14(val lines: List<String>) { val rocks: List<List<Coord>> = lines .map { it.split(" -> ") .map { val (x, y) = it.split(",").map...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
2,844
aoc2022
Apache License 2.0
src/main/kotlin/year2023/day-05.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2023 import lib.aoc.Day import lib.aoc.Part import lib.splitLines fun main() { Day(5, 2023, PartA5(), PartB5()).run() } open class PartA5 : Part() { protected data class Lut(val destinationStart: Long, val sourceStart: Long, val length: Long) { val sourceRange: LongRange get()...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
2,728
Advent-Of-Code-Kotlin
MIT License
src/Day01.kt
PauliusRap
573,434,850
false
{"Kotlin": 20299}
fun main() { fun getSortedCalorieList(input: List<String>): List<Int> { val list = mutableListOf<Int>() var individualCalories = 0 input.forEach { line -> if (line.isBlank()) { list.add(individualCalories) individualCalories = 0 } else ...
0
Kotlin
0
0
df510c3afb104c03add6cf2597c433b34b3f7dc7
1,024
advent-of-coding-2022
Apache License 2.0
src/main/kotlin/Dayxx.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
import se.saidaspen.aoc.util.* fun main() = Dayxx.run() object Dayxx : Day(2022, 25) { override fun part1(): Any { var temp = "1=-0-2\n" + "12111\n" + "2=0=\n" + "21\n" + "2=01\n" + "111\n" + "20012\n" + ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,822
adventofkotlin
MIT License
src/test/kotlin/io/noobymatze/aoc/y2023/Day8.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2023 import io.noobymatze.aoc.Aoc import kotlin.test.Test class Day8 { @Test fun test() { val (movement, nodesString) = Aoc.getInput(8) .split("\n\n") val map = nodesString.lines().associate { val (start, target) = it.split(" = ") ...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
2,062
aoc
MIT License
src/main/kotlin/Day16.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset enum class Direction(val action: (Pair<Int, Int>) -> Pair<Int, Int>) { UP({ it.first - 1 to it.second }), UP_LEFT({ it.first - 1 to it.second - 1 }), UP_RIGHT({ it.first - 1 to it.second + 1 }), DOWN({ it.first + 1 to it.second }), DOWN_LEF...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
5,005
aoc-2023-in-kotlin
Apache License 2.0
src/Day14.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
import kotlin.math.max import kotlin.math.min fun main() { var left = 0 var maxDepth = 0 fun Array<CharArray>.print() { for (row in this) { println(row.contentToString().filterNot { it == ',' }) } } fun String.parse() = this.split(" -> ") .map { it...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
5,982
AoC-2022
Apache License 2.0
src/Day07.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
enum class Type { COMMAND, OUTPUT } fun main() { val TOTAL_SPACE = 70000000 val REQUIRED_SPACE = 30000000 class Node(name: String, parentNode: Node?){ val childNodes = HashMap<String, Node>() var parentNode = parentNode var size = -1 var calculatedSize = -1 fun...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
4,953
aoc-kotlin
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day245/day245.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day245 // day245.kt // By <NAME>, 2019. import kotlin.math.min fun brute_force(moves: List<Int>): Int? { if (moves.isEmpty()) return 0 fun aux(position: Int = 0, movesSoFar: Int = 0): Int? { // Determine the possible moves. if (position == moves.size - 1) retur...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,377
daily-coding-problem
MIT License
src/main/kotlin/d12_PassagePathing/PassagePathing.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d12_PassagePathing import util.Input import util.Output val upperAlpha = "A".."Z" val lowerAlpha = "a".."z" fun main() { Output.day(12, "Passage Pathing") val startTime = Output.startTime() val input = Input.parseTo2dList<String>(filename = "/input/d12_path_map.txt", delimiter = "-") val ca...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
3,894
advent-of-code-2021
MIT License
src/main/kotlin/aoc2022/Day20.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.parser.followedBy import aoc.parser.number import aoc.parser.zeroOrMore class Day20() { val parser = zeroOrMore(number() followedBy "\n") private fun solve(parsed: List<Long>, repeat: Long): Long { val size = parsed.size val sizem1 = size - 1 //println(size)...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
1,261
aoc-kotlin
Apache License 2.0
src/main/kotlin/leetcode/Problem1559.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/detect-cycles-in-2d-grid/ */ class Problem1559 { fun containsCycle(grid: Array<CharArray>): Boolean { val maxRow = grid.size val maxCol = if (maxRow == 0) 0 else grid[0].size val visited = Array(grid.size) { BooleanArray(maxCol) } ...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
2,044
leetcode
MIT License
src/main/kotlin/day14.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
sealed class CodeInstruction { data class Mask(val off: Long, val on: Long) : CodeInstruction() data class Write(val addr: Long, val value: Long) : CodeInstruction() } fun day14ProblemReader(text: String): List<CodeInstruction> { val maskRegex = "mask\\s=\\s(\\w+)".toRegex() val memRegex = "mem\\[(\\d+...
0
Kotlin
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
3,190
adventofcode_2020
MIT License
src/Day19.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime import kotlin.time.TimeSource fun main() { day19Part(1) day19Part(2) } @OptIn(ExperimentalTime::class) fun day19Part(part: Int) { println("=============== Solving part$part") val start = TimeSource.Monotonic.markNow() val dayId = ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
4,720
aoc-2022
Apache License 2.0
src/main/kotlin/day08/Day08.kt
mdenburger
317,466,663
false
null
package day08 import java.io.File data class Operation(val name: String, val argument: Int) class Program(private val operations: List<Operation>) { private var instruction = 0 private var accumulator = 0 private val visited = BooleanArray(operations.size) fun run(): Int { while (instruction...
0
Kotlin
0
0
b965f465cad30f949874aeeacd8631ca405d567e
2,024
aoc-2020
MIT License
Advent-of-Code-2023/src/Day23.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day23" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY private fun part1(input: List<String>): Int { val start = Position(0, input.first().indexOf('.')) val end = Position(input.size - 1, input.last().indexOf('.')) val points = mutableL...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
5,215
Advent-of-Code-2023
Apache License 2.0
src/Day14.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import java.lang.IndexOutOfBoundsException fun main() { fun createWalls( walls: List<List<Pair<Int, Int>>>, height: Int, width: Int, mapStartX: Int ): List<MutableList<Int>> { val map = List(height) { MutableList(width) { 0 } } walls.forEach { wall -> ...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
5,365
Advent-of-code
Apache License 2.0
src/main/kotlin/homework_5/Task1.kt
al-volkov
340,614,622
false
{"Kotlin": 124832}
package homework_5 import java.io.File fun String.isNumber() = this.toIntOrNull() != null enum class OperationType(val operation: String) { Addition("+"), Multiplication("*"), Subtraction("-"), Division("/") } interface ArithmeticTreeNode { fun getValue(): Int override fun toString(): String...
0
Kotlin
0
0
5049681dd2a57625309584a6e50b9a6e0b65948a
2,418
spbu_2020_kotlin_homeworks
Apache License 2.0
src/Day03.kt
tsschmidt
572,649,729
false
{"Kotlin": 24089}
fun main() { fun priority(item: Char): Int = if (item.isUpperCase()) item.code - 38 else item.code - 96 fun part1(input: List<String>): Int { return input.sumOf { val compartments = it.chunked(it.length / 2) val common = compartments[0].toSet().intersect(compartments[1].toSet(...
0
Kotlin
0
0
7bb637364667d075509c1759858a4611c6fbb0c2
794
aoc-2022
Apache License 2.0
day03/kotlin/RJPlog/day2303_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File import kotlin.math.* fun gearRatio(): Int { var result = 0 val patternSymbol = """\W""".toRegex() val patternPartNumber = """(\d)+""".toRegex() var y = 0 File("day2303_puzzle_input.txt").forEachLine { var matchSymbol = patternSymbol.findAll(it.replace(".", "a")) matchSymbol.forEach { v...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
2,555
aoc-2023
MIT License
src/main/kotlin/lesson2/CyclicRotation.kt
iafsilva
633,017,063
false
null
package lesson2 /** * An array A consisting of N integers is given. * * Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. * * For example, the rotation of array A = [[3, 8, 9, 7, 6]] is [[6, 3, 8, 9, 7]] (elements are shifte...
0
Kotlin
0
0
5d86aefe70e9401d160c3d87c09a9bf98f6d7ab9
1,954
codility-lessons
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BuyTwoChocolates.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
7,656
kotlab
Apache License 2.0
src/main/kotlin/knn/KnnRegressor.kt
widi-nugroho
280,304,894
false
null
package knn class KnnRegressor (val k:Int,val inputweight:List<Double>){ fun getKNearestNeighbour(sorteddata:List<Pair<Double,DataRegressor>>):List<Pair<Double,DataRegressor>>{ var res= mutableListOf<Pair<Double,DataRegressor>>() for (i in 0..k-1){ res.add(sorteddata[i]) } ...
0
Kotlin
0
0
139d768e4e02c76193443c06285d918b0fbbfc7f
1,521
kotlin-machine-learning
Apache License 2.0
src/Day10.kt
Donald-rdex
576,629,787
false
{"Kotlin": 3974}
fun main() { fun part1(instructionQueue: ArrayDeque<String>): Int { var registerX = 1 var cycle = 1 val interestingCyles = listOf<Int>(20, 60, 100, 140, 180, 220) var signalStrength: Int var totalSignalStr = 0 while (instructionQueue.isNotEmpty()) { val n...
0
Kotlin
0
0
6d9503a6be80691b9bcb5e2a31e0b483c192e2c1
2,836
kotlin-aoc2022
Apache License 2.0
src/day21/Jobs.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day21 import readInput data class Jobs (val map: MutableMap<String, Expression>) { fun evalInputs (symbol: String = ROOT, set: MutableSet<String> = mutableSetOf<String> ()): Set<String> { return evalInputs (map[symbol] as Expression, set) } fun evalInputs (expr: Expression, set: MutableSe...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,604
advent_of_code_2022
Apache License 2.0
src/main/kotlin/Day04.kt
margaret-lin
575,169,915
false
{"Kotlin": 9536}
package main.kotlin fun main() { println(part1(input)) } private val input = readInput("day04_input") private fun part1(input: List<String>): Pair<Int, Int> { val sectionPairs = input.map { line -> val sections = line.split(",") // [2-4, 6-8] val (sectionA, sectionB) = sections.map { rangeSt...
0
Kotlin
0
0
7ef7606a04651ef88f7ca96f4407bae7e5de8a45
789
advent-of-code-kotlin-22
Apache License 2.0
kotlin/src/com/leetcode/46_Permutations.kt
programmerr47
248,502,040
false
null
package com.leetcode import kotlin.math.pow /** * We use straightforward approach with helping bit array. * Every time we go into the next level of recursion, * we mark the number as used. * * Tip: * This approach would not work in case of recurrent numbers! * * Time: O(n^n) - actually the total number of per...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,997
problemsolving
Apache License 2.0
src/Day01.kt
Jenner-Zhl
576,294,907
false
{"Kotlin": 8369}
fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 input.forEach { if (it != "") { current += it.toInt() } else { max = maxOf(max, current) current = 0 } if (current !=...
0
Kotlin
0
0
5940b844155069e020d1859bb2d3fb06cb820981
1,472
aoc
Apache License 2.0
src/main/kotlin/dp/LIS.kt
yx-z
106,589,674
false
null
import util.OneArray import util.max import java.util.* // Longest Increasing Subsequence fun main(args: Array<String>) { // test array val arr = arrayOf(4, 2, 3, 5, 7) println(lenLISDP(arr)) println(lenLISDP2(arr)) println(lenLISDP3(arr)) println(lenLISDPOpt(arr)) } // DP with O(N^2) fun lenLISDP(arr: Array<I...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,110
AlgoKt
MIT License
src/day02.kt
skuhtic
572,645,300
false
{"Kotlin": 36109}
fun main() { day02.execute(forceBothParts = true) } val day02 = object : Day<Int>(2, 15, 12) { override val testInput: InputData = """ A Y B X C Z """.trimIndent().lines() override fun part1(input: InputData): Int = input .fold(0) { score, line -> line.parse...
0
Kotlin
0
0
8de2933df90259cf53c9cb190624d1fb18566868
1,386
aoc-2022
Apache License 2.0
Advent-of-Code-2023/src/Day05.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
import kotlin.math.max import kotlin.math.min private const val AOC_DAY = "Day05" private const val PART1_TEST_FILE = "${AOC_DAY}_test_part1" private const val PART2_TEST_FILE = "${AOC_DAY}_test_part2" private const val INPUT_FILE = AOC_DAY // destination range start | source range start | range length private data c...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
5,409
Advent-of-Code-2023
Apache License 2.0
Problems/Algorithms/1202. Smallest String with Swaps/SmallestStringSwaps.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 smallestStringWithSwaps(s: String, pairs: List<List<Int>>): String { val numberOfVertices = s.length val res = CharArray(numberOfVertices) val uf = UnionFind(numberOfVertices) for (pair in pairs) { uf.union(pair.get(0), pair.get(1)) }...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
2,266
leet-code
MIT License
src/main/kotlin/com/github/davio/aoc/y2022/Day4.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2022 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.getInputAsSequence import kotlin.system.measureTimeMillis fun main() { println(Day4.getResultPart1()) measureTimeMillis { println(Day4.getResultPart2()) }.also { println("Took $it ms") } ...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
1,322
advent-of-code
MIT License
src/main/kotlin/dev/wilerson/aoc/day3/Day03.kt
wilerson
572,902,668
false
{"Kotlin": 8272}
package dev.wilerson.aoc.day3 import dev.wilerson.aoc.utils.readInput fun main() { val input = readInput("day3input") val itemTypes = ('a'..'z') + ('A'..'Z') val priorities = (1 .. 52).toList() val priorityMap = itemTypes.mapIndexed { index, c -> c to priorities[index] }.toMap() // part1(input, pr...
0
Kotlin
0
0
d6121ef600783c18696211d43b62284f4700adeb
847
kotlin-aoc-2022
Apache License 2.0
src/Day01.kt
LesleySommerville-Ki
577,718,331
false
{"Kotlin": 9590}
fun main() { data class Elf ( var calories: Int? = 0 ) fun parseElves(input: List<String>): ArrayDeque<Elf> { val listOfElves = ArrayDeque<Elf>() var currentElf = Elf() input.forEach { if (it == "") { listOfElves.add(currentElf) cu...
0
Kotlin
0
0
ea657777d8f084077df9a324093af9892c962200
1,038
AoC
Apache License 2.0
atcoder/arc153/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package atcoder.arc153 private const val M = 1e12.toLong() private fun solve(s: IntArray): LongArray? { val n = s.size val sSum = s.sum() val a = LongArray(n) { it + 1L } fun aSum() = a.indices.sumOf { i -> a[i] * s[i] } if (sSum != 0) { val x = M / 4 val delta = (-x - aSum()) / sSum for (i in a.indices) a...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
966
competitions
The Unlicense
src/main/kotlin/SimplifySquareRootBigDecimal.kt
BjornvdLaan
459,274,171
false
{"Kotlin": 19109}
import java.math.BigInteger /** * Square root with its coefficient. * * Definitions: a square root is of form 'coefficient * sqrt(radicand)'. * In other words, the coefficient is outside the square root * and the radicand in inside the square root. * * @property coefficient number in front of the radical ('root...
0
Kotlin
0
0
c6d895d1c011628db4c7c5082e37dc32ac5f9a8a
2,060
KotlinTestApproachExamples
MIT License
src/main/kotlin/com/londogard/summarize/summarizers/EmbeddingClusterSummarizer.kt
londogard
222,868,849
false
null
package com.londogard.summarize.summarizers import com.londogard.embeddings.LightWordEmbeddings import com.londogard.summarize.extensions.* import com.londogard.summarize.extensions.mutableSumByCols import com.londogard.summarize.extensions.normalize import smile.nlp.* import kotlin.math.min import kotlin.math.roundTo...
3
Kotlin
0
2
521818ed9057e5ffb58a8ae7b3f0a6c3269e93cc
6,091
summarize-kt
Apache License 2.0
src/main/kotlin/RangeExtraction.kt
Flight552
408,072,383
false
{"Kotlin": 26115, "Assembly": 1320}
//A format for expressing an ordered list of //integers is to use a comma separated list of either // //individual integers //or a range of integers denoted by the //starting integer separated from the end integer in //the range by a dash, '-'. The range includes all //integers in the interval including both endpoints....
0
Kotlin
0
0
b9fb9378120455c55a413ba2e5a95796612143bc
3,926
codewars
MIT License
src/algorithmdesignmanualbook/datastructures/LargestOccuringOrderedPair.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.datastructures import algorithmdesignmanualbook.print import kotlin.test.assertTrue private data class GenericNode<T>(val value: T?) { val nodes = mutableListOf<GenericNode<T>>() var count = 1 fun add(node: GenericNode<T>) { nodes.add(node) } fun find(s...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,234
algorithms
MIT License
src/algorithmsinanutshell/FloydWarshallAlgorithm.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell import utils.PrintUtils import java.lang.Integer.min /** * # All pair shortest path algorithm * * While Dijkstra Shortest Path algorithm helps find shortest path between start and end vertex, [FloydWarshallAlgorithm] * finds the shortest path between all vertices in a [graph] * * [...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,360
algorithms
MIT License
src/Day01.kt
andyludeveloper
573,249,939
false
{"Kotlin": 7818}
fun main() { fun part1(input: List<String>): Int { var sum = 0 var temp = 0 input.forEach { if (it.isEmpty()) { if (temp > sum) { sum = temp } temp = 0 } else { temp += it.toInt() ...
0
Kotlin
0
1
684cf9ff315f15bf29914ca25b44cca87ceeeedf
1,134
Kotlin-in-Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/d19/d19b.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d19 import readInput import java.util.* // > 1175 // > 1183 fun part1b(input: List<String>): Int { var sum = 0 for (line in input) { if (line.isBlank()) continue val (idx, bp) = readBluePrint(line) println(bp) val score = trailB(bp, 0, 0, 0, 1, 0, 0, 0, 24, 0) ...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
5,668
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc22/Day05.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import readInput val startingStack = """ [T] [V] [W] [V] [C] [P] [D] [B] [J] [P] [R] [N] [B] [Z] [W] [Q] [D] [M] [T] [L] [T] [N] [J] [H] [B] [P] [T] [P] [L] [R] [D] [F] [P] [R] [P] [R] [S] [G] [M] [W] [J] [R] [V] [B] [J] [C] [S] ...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
2,886
advent-of-code
Apache License 2.0
src/main/kotlin/io/permutation/PermutationGenerator.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.permutation import io.utils.runTests // Given a number n, generate all the permutations list of 1 to n // https://www.youtube.com/watch?v=V7hHupttzVk class PermutationGenerator { fun execute(input: Int): Array<IntArray> = Array(input.factorial()) { IntArray(input) }.apply { (1..input).forEach { fi...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,597
coding
MIT License
kotlin/practice/src/main/kotlin/hackerrank/Arrays.kt
pradyotprksh
385,586,594
false
{"Kotlin": 1973871, "Dart": 1066884, "Python": 313491, "Swift": 147167, "C++": 113494, "CMake": 94132, "Go": 45704, "HTML": 21089, "Ruby": 12424, "Rust": 8550, "C": 7125, "Makefile": 1480, "Shell": 817, "JavaScript": 781, "CSS": 588, "Objective-C": 380, "Dockerfile": 32}
package hackerrank class Arrays { fun solveAllProblems() { println("Solution for hour glass sum problem") val hourglassSumArr = arrayOf( arrayOf(1, 1, 1, 0, 0, 0), arrayOf(0, 1, 0, 0, 0, 0), arrayOf(1, 1, 1, 0, 0, 0), arrayOf(0, 0, 2, 4, 4, 0), ...
0
Kotlin
10
17
2520dc56fc407f97564ed9f7c086292803d5d92d
4,370
development_learning
MIT License
src/main/kotlin/TrieNode.kt
bgraves-lo
134,632,043
false
{"Kotlin": 7092}
class TrieNode { private val children = mutableMapOf<Char, TrieNode>() private var isWord = false fun add(word: String) { add(word.toLowerCase().asIterable().iterator()) } fun isWord(word: String): Boolean { return isWord(word.toLowerCase().asIterable().iterator()) } fun f...
0
Kotlin
0
0
d1fece663d6936750b951cdbcabcbc5f05b93521
3,120
ktscrabble
Apache License 2.0
base/sdk-common/src/main/java/com/android/projectmodel/SubmodulePath.kt
qiangxu1996
255,410,085
false
{"Java": 38854631, "Kotlin": 10438678, "C++": 1701601, "HTML": 795500, "FreeMarker": 695102, "Starlark": 542991, "C": 148853, "RenderScript": 58853, "Shell": 51803, "CSS": 36591, "Python": 32879, "XSLT": 23593, "Batchfile": 8747, "Dockerfile": 7341, "Emacs Lisp": 4737, "Makefile": 4067, "JavaScript": 3488, "CMake": 329...
/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
0
Java
1
1
3411c5436d0d34e6e2b84cbf0e9395ac8c55c9d4
3,095
vmtrace
Apache License 2.0
src/2022/Day17.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun printField(field: List<Int>) { println(field.reversed().joinToString(separator = "\n") { it.toString(2) .padStart(7, '0') .replace('0', '.') .replace('1', '#') }) } fun part1(inp...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
6,089
aoc-2022-in-kotlin
Apache License 2.0
src/Day01.kt
meletios
573,316,028
false
{"Kotlin": 4032}
import java.util.InputMismatchException fun main() { fun part1(input: List<String>): Int { var maxCalories: Int = 0 var tempSum: Int = 0 input.forEach { line -> when (val test = line.toIntOrNull()) { null -> { if (tempSum > maxCalories) { ...
0
Kotlin
0
0
25549bde439b949f6dd091ccd69beb590d078787
2,001
advent-of-code-2022
Apache License 2.0
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Prims_Algorithm/Prims_Algorithm.kt
rajatenzyme
325,100,742
false
{"C++": 709855, "Java": 559443, "Python": 397216, "C": 381274, "Jupyter Notebook": 127469, "Go": 123745, "Dart": 118962, "JavaScript": 109884, "C#": 109817, "Ruby": 86344, "PHP": 63402, "Kotlin": 52237, "TypeScript": 21623, "Rust": 20123, "CoffeeScript": 13585, "Julia": 2385, "Shell": 506, "Erlang": 385, "Scala": 310, ...
import java.util.* internal class Edge(var from: Int, var to: Int, var weight: Int) internal object Prims { /** * Function to compute MST * * @param graph * @return mst */ private fun prims(graph: ArrayList<ArrayList<Edge?>>): ArrayList<Edge?> { // ArrayList to store obtained MST ...
0
C++
0
0
65a0570153b7e3393d78352e78fb2111223049f3
4,012
Coding-Journey
MIT License
AOC-2023/src/main/kotlin/Day02.kt
sagar-viradiya
117,343,471
false
{"Kotlin": 72737}
import utils.* const val RED_BALLS = 12 const val BLUE_BALLS = 14 const val GREEN_BALLS = 13 object Day02 { fun part01(input: String): Int { val games = input.splitAtNewLines() return games.mapIndexed { index, s -> Pair(index, s.splitAtColon()[1]) }.map { sets -> v...
0
Kotlin
0
0
7f88418f4eb5bb59a69333595dffa19bee270064
2,207
advent-of-code
MIT License
src/Day03.kt
dominik003
573,083,805
false
{"Kotlin": 9376}
fun main() { fun calcCharValue(char: Char): Int { if (char.isLowerCase()) { return (char.code - 97) + 1 } return (char.code - 65) + 27 } fun part1(input: List<String>): Int { var prioritySum = 0 input.forEach { val compartments: List<String> =...
0
Kotlin
0
0
b64d1d4c96c3dd95235f604807030970a3f52bfa
1,230
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2017/DigitalPlumber.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import komu.adventofcode.utils.commaSeparatedInts import komu.adventofcode.utils.nonEmptyLines fun pipesConnectedTo(startPipe: Int, input: String): Int { val pipesById = buildPipes(input) val start = pipesById[startPipe]!! val connected = mutableSetOf<Int>() collectC...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,074
advent-of-code
MIT License
src/Day23.kt
kuangbin
575,873,763
false
{"Kotlin": 8252}
fun main() { fun part1(input: List<String>): Int { var positions = buildSet{ for (i in 0 until input.size) { for (j in 0 until input[i].length) { if (input[i][j] == '#') { add(i to j) } } } } for (i in 0 until 10) { positions = gao(positio...
0
Kotlin
0
0
ea0d89065b4d3cb4f6f78f768882d5b5473624d1
3,209
advent-of-code-2022
Apache License 2.0
aoc_2023/src/main/kotlin/problems/day2/CubeConundrum.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day2 class CubeConundrum(val games: List<CubeGame>) { companion object { fun fromLines(input: List<String>): CubeConundrum { val mutableListGames: MutableList<CubeGame> = mutableListOf() for (line in input) { val (gameStr, contentStr) = line.split(...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
1,787
advent-of-code-2023
MIT License
src/main/kotlin/year2023/Day02.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 class Day02 { companion object { @JvmStatic val maxColorNumbers = mapOf( "red" to 12, "green" to 13, "blue" to 14 ) } fun parseLine(line: String): Pair<Int, List<Pair<String, Int>>> { val (lineStart, lineEnd) = line.spli...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
1,481
aoc-2022
Apache License 2.0
src/Day10.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
fun main() { // 20th, 60th, 100th, 140th, 180th, and 220th cycles val interestingPositions = generateSequence(20) { it + 40 }.take(6).toList() fun isInterestingCycle(cycleNumber: Int): Boolean { return cycleNumber in interestingPositions } fun part1(input: List<String>): Int { var ...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
3,437
aoc-2022-kotlin
Apache License 2.0
src/mathFunctions/FunctionEvaluator.kt
hopshackle
225,904,074
false
null
package mathFunctions import evodef.* import kotlin.AssertionError import kotlin.random.Random class FunctionEvaluator(val f: NTBEAFunction, val searchSpace: FunctionSearchSpace) : SolutionEvaluator { private val rnd = Random(System.currentTimeMillis()) override fun optimalFound() = false override fun o...
0
Kotlin
0
0
e5992d6b535b3f4a6552bf6f2351865a33d56248
3,380
SmarterSims
MIT License
src/main/day25/day25.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day25 import kotlin.math.pow import kotlin.math.roundToLong import readInput val UNSNAFU = mapOf( "=" to -2.0, "-" to -1.0, "0" to 0.0, "1" to 1.0, "2" to 2.0, ) fun main() { val input = readInput("main/day25/Day25") println(part1(input)) } fun part1(input: List<String>): String...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
793
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/searching/BinarySearch.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.searching fun main() { val items = listOf(5, 6, 4, 3, 10, 9, 5, 6, 7) print("items: $items \n") val sorted = items.sorted() print("items: $items \n") print("trying to find 10, index: ${binarySearch(sorted, 10)} - ${rank(sorted, 10)} \n") // 8 pr...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,376
algs4-leprosorium
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindLeaves.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,145
kotlab
Apache License 2.0
src/main/kotlin/g2201_2300/s2290_minimum_obstacle_removal_to_reach_corner/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2290_minimum_obstacle_removal_to_reach_corner // #Hard #Array #Breadth_First_Search #Matrix #Heap_Priority_Queue #Graph #Shortest_Path // #2023_06_28_Time_765_ms_(100.00%)_Space_66.1_MB_(100.00%) import java.util.PriorityQueue import java.util.Queue class Solution { fun minimumObstacles(grid:...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,448
LeetCode-in-Kotlin
MIT License
src/Day16.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.max @OptIn(ExperimentalStdlibApi::class) fun main() { fun part1(input: List<String>): Int { val name = input.map { it.substringAfter("Valve ").substringBefore(' ') } val flow = input.map { it.substringAfter("rate=").substringBefore(';').toInt() } val leads = input.map { i...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
6,164
aoc2022
Apache License 2.0
src/Day06.kt
andyludeveloper
573,249,939
false
{"Kotlin": 7818}
fun main() { val test1 = "bvwbjplbgvbhsrlpgdmjqwftvncz" val test2 = "nppdvjthqldpwncqszvftbrmjlhg" val test3 = "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" val test4 = "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" println(solution(test1, 1)) check(solution(test1, 1) == 5) check(solution(test2, 1) == 6) che...
0
Kotlin
0
1
684cf9ff315f15bf29914ca25b44cca87ceeeedf
822
Kotlin-in-Advent-of-Code-2022
Apache License 2.0
year2019/src/main/kotlin/net/olegg/aoc/year2019/day16/Day16.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day16 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2019.DayOf2019 import kotlin.math.abs /** * See [Year 2019, Day 16](https://adventofcode.com/2019/day/16) */ object Day16 : DayOf2019(16) { override fun first(): Any? { val input = data.map { it - '0' } ret...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,434
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinMaxGasDist.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,795
kotlab
Apache License 2.0
kotlin/1857-largest-color-value-in-a-directed-graph.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
class Solution { fun largestPathValue(colors: String, edges: Array<IntArray>): Int { val adj = HashMap<Int, ArrayList<Int>>() for ((from, to) in edges) adj[from] = adj.getOrDefault(from, ArrayList<Int>()).apply{this.add(to)} val visited = HashSet<Int>() val path = HashSe...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,350
leetcode
MIT License
advent2022/src/main/kotlin/year2022/Day23.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import Point2D import findAllPositionsOf import year2022.Day23.Direction.* typealias PointComputation = Point2D.() -> Set<Point2D> class Day23 : AdventDay(2022, 23) { private val Point2D.allNeighbors: Set<Point2D> get() = entries.map { this + it.pointDiff }.toSet() ...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
3,481
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindAndReplacePattern.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,447
kotlab
Apache License 2.0
src/Day24.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import java.util.PriorityQueue import kotlin.math.abs fun main() { val windUp = 0b0001 val windRight = 0b0010 val windDown = 0b0100 val windLeft = 0b1000 class Map(val width: Int = 120, val height: Int = 25) { private val winds = Array(width * height) { 0 } fun addWind(x: Int, y: ...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
6,005
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PrimePalindrome.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,986
kotlab
Apache License 2.0
src/main/kotlin/io/rbrincke/dice/core/Combination.kt
rbrincke
167,712,634
false
{"Kotlin": 13146}
package io.rbrincke.dice.core class Combination<T : Element<T>>(private val elements: List<T>) { init { check(elements.isNotEmpty()) { "Elements may not be empty." } } /** * Matches element 1 to 2, ..., N - 1 to N, N to 1. */ private val elementPairs = elements.mapIndexed { currentId...
0
Kotlin
0
0
fc5aa0365d91ce360bf6e9c7589e3f5fc6bc8a82
1,811
nontransitive-dice
MIT License
src/main/kotlin/adventofcode/year2021/Day02Dive.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2021 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.year2021.Day02Dive.Companion.Direction.DOWN import adventofcode.year2021.Day02Dive.Companion.Direction.FORWARD import adventofcode.year2021.Day02Dive.Companion.Direction.UP class Day02Dive(customInput: PuzzleI...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,960
AdventOfCode
MIT License
src/Day02.kt
xiaofeiMophsic
575,326,884
false
null
// A 石头(1) B 布(2) C 剪刀(3) // X 石头 Y 布 Z 剪刀 // 0(L), 3(D), 6(W) val part1ScoreList = mapOf( "A X" to 4, "A Y" to 8, "A Z" to 3, "B X" to 1, "B Y" to 5, "B Z" to 9, "C X" to 7, "C Y" to 2, "C Z" to 6 ) val part2ScoreList = mapOf( "A X" to 3, "A Y" to 4, "A Z" to 8, "B ...
0
Kotlin
0
0
13e5063928c0eb6416ce266e2083816ca78b8240
781
aoc-kotlin
Apache License 2.0
src/Day20.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { fun day20(input: List<String>, decryptionKey: Long, repeat: Int): Long { val encryptedFile = input.map { it.toInt() * decryptionKey }.withIndex().toMutableList() repeat(repeat) { input.indices.forEach { initialIndex -> val currentIndex = encryptedFile.index...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
1,620
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dp/LCS.kt
yx-z
106,589,674
false
null
package dp import util.* // Longest Common Subsequence fun main(args: Array<String>) { val a1 = intArrayOf(1, 5, 0, 12, 9) val a2 = intArrayOf(5, 12, 9, 1) // println(a1 lcs a2) // [5, 12, 9] -> 3 // how about three arrays? val A = oneArrayOf(1, 1, 1, 2, 2, 2, 2, 2) val B = oneArrayOf(2, 2, 2, 2, 1, 1, 1, 1) v...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,582
AlgoKt
MIT License
src/Day08.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
fun main() { val testInput = readInput("Day08_test").toMatrix() check(part1(testInput) == 21) check(part2(testInput) == 8) val input = readInput("Day08").toMatrix() println(part1(input)) println(part2(input)) } private fun part1(input: Matrix): Int { val width = input[0].size val heigh...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
2,549
AOC2022
Apache License 2.0
src/day15/Day15.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day15 import java.io.File fun main() { val data = parse("src/day15/Day15.txt") println("🎄 Day 15 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private fun parse(path: String): List<S...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
1,540
advent-of-code-2023
MIT License
kotlin/905.Length of Longest Fibonacci 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 <code>X_1, X_2, ..., X_n</code>&nbsp;is <em>fibonacci-like</em> if:</p> <ul> <li><code>n &gt;= 3</code></li> <li><code>X_i + X_{i+1} = X_{i+2}</code>&nbsp;for all&nbsp;<code>i + 2 &lt;= n</code></li> </ul> <p>Given a <b>strictly increasing</b>&nbsp;array&nbsp;<code>A</code> of positive integers fo...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
4,842
leetcode
MIT License
2015/src/main/kotlin/day8_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution fun main() { Day8Func.run() } object Day8Func : Solution<List<String>>() { override val name = "day8" override val parser = Parser.lines private fun unescape(input: String): String { val slash = input.indexOf('\\') if (slash == -1) return input val secon...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,507
aoc_kotlin
MIT License
src/main/kotlin/days/Day17.kt
nuudles
316,314,995
false
null
package days class Day17 : Day(17) { private fun findNeighbors( target: Triple<Int, Int, Int>, candidates: Set<Triple<Int, Int, Int>> ): Set<Triple<Int, Int, Int>> { val neighbors = mutableSetOf<Triple<Int, Int, Int>>() for (candidate in candidates.minus(target)) { i...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
6,014
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day19.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
import kotlin.math.* import kotlin.time.* data class P3D(val x: Int, val y: Int, val z: Int) @ExperimentalStdlibApi @ExperimentalTime fun main() { val start = TimeSource.Monotonic.markNow() val input = readInputFile("day19") val a = ArrayList<HashSet<P3D>>() for (s in input) { if (s == "--- sc...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
2,607
AOC2021
Apache License 2.0
src/Day01.kt
lampenlampen
573,064,227
false
{"Kotlin": 1907}
import kotlin.time.ExperimentalTime @OptIn(ExperimentalTime::class) fun main() { fun parseInput(input: String): List<Int> = input .split("\n\n") .map { elv -> elv.lines().sumOf { it.toInt() } } fun topNElves(elves: List<Int>, n: Int): Int { fun findTopN(n: Int, element: List<Int>): List<Int> { if (element....
0
Kotlin
0
0
f63812280aaacb9e4af7995d2ee7b0b6d1ffecac
1,188
AdventOfCode2022
Apache License 2.0
src/Day10.kt
SebastianHelzer
573,026,636
false
{"Kotlin": 27111}
fun main() { fun processOps(ops: List<Int?>, cycle: (Int, Int) -> Unit) { var cycleNumber = 1 var x = 1 ops.forEach { if(it == null) { cycle(cycleNumber++, x) } else { cycle(cycleNumber++, x) cycle(cycleNumber++, x) ...
0
Kotlin
0
0
e48757626eb2fb5286fa1c59960acd4582432700
1,393
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dynamicprogramming/LongestPalindromicSubstring.kt
e-freiman
471,473,372
false
{"Kotlin": 78010}
package dynamicprogramming private var memo: Array<Array<Boolean?>>? = null fun isPalindrome(s: String, i: Int, j: Int): Boolean { if (memo!![i][j] != null) { return memo!![i][j]!! } if (i == j) { memo!![i][j] = true return true } if (i == j - 1) { memo!![i][j] = s[...
0
Kotlin
0
0
fab7f275fbbafeeb79c520622995216f6c7d8642
915
LeetcodeGoogleInterview
Apache License 2.0
src/Day01.kt
mythicaleinhorn
572,689,424
false
{"Kotlin": 11494}
fun main() { fun part1(input: List<String>): Int { var highest = 0 var temp = 0 for (line in input) { if (line == "") { highest = highest.coerceAtLeast(temp) temp = 0 continue } temp += line.toInt() ...
0
Kotlin
0
0
959dc9f82c14f59d8e3f182043c59aa35e059381
1,131
advent-of-code-2022
Apache License 2.0
src/Day10.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { fun part1(input: List<String>): Int { var x = 1 var cycle = 1 var total = 0 for(line in input) { val command = line.trim().split(" ") if(command.first() == "addx") { for(i in 1..2) { if (i == 2) x += command.l...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
1,567
AoC-2022
Apache License 2.0