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
calendar/day05/Day5.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day05 import Day import Lines import java.util.Stack class Day5 : Day() { override fun part1(input: Lines): Any { val stacks = initStacks(input.filter { it.contains('[') }) input.filter { it.contains("move") } .forEach {command -> val move = parseMove(command) ...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
2,328
advent-of-code-2022
Apache License 2.0
2015/src/main/kotlin/com/koenv/adventofcode/Day16.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode object Day16 { public fun getIdOfMatchedSue(input: String, rangedValues: Boolean = false): Int { val aunts = input.lines().map { val result = INSTRUCTION_REGEX.find(it)!! val id = result.groups[1]!!.value.toInt() var children: Int? = null ...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
2,893
AdventOfCode-Solutions-Kotlin
MIT License
src/main/kotlin/dp/LPS.kt
yx-z
106,589,674
false
null
package dp import util.get import util.max import util.set // Longest Palindrome Subsequence fun main(args: Array<String>) { val A = intArrayOf(1, 5, 2, 6, 6, 5) println(lps(A)) } fun lps(A: IntArray): Int { val n = A.size // dp(i, j): len of lps of A[i..j] // use a 2d array dp[1..n, 1..n] : dp[i, j] = dp(i, j...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,411
AlgoKt
MIT License
src/main/kotlin/util/VersionRange.kt
minecraft-dev
42,327,118
false
null
/* * Minecraft Dev for IntelliJ * * https://minecraftdev.org * * Copyright (c) 2023 minecraft-dev * * MIT License */ package com.demonwav.mcdev.util /** * A [SemanticVersion] range whose [lower] bound is **inclusive** and [upper] bound is **exclusive** (uncapped if `null`) */ data class VersionRange(val low...
204
Kotlin
152
1,154
36cc3d47f7f39c847c0ebdcbf84980bc7262dab7
2,227
MinecraftDev
MIT License
src/day9/Day9.kt
quinlam
573,215,899
false
{"Kotlin": 31932}
package day9 import utils.Day import kotlin.math.abs /** * Actual answers after submitting; * part1: 5619 * part2: 2376 */ class Day9 : Day<Int, List<Movement>>( testPart1Result = 13, testPart2Result = 1, ) { override fun part1Answer(input: List<Movement>): Int { return trackTail(input, 2) ...
0
Kotlin
0
0
d304bff86dfecd0a99aed5536d4424e34973e7b1
2,111
advent-of-code-2022
Apache License 2.0
solutions/src/Day01.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): Int { var leaderCalories = 0 var runningTotal = 0 input.forEach { line -> if (line == "") { if (runningTotal > leaderCalories) { leaderCalories = runningTotal } runnin...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
1,107
advent-of-code-22
Apache License 2.0
2020/kotlin/src/main/kotlin/io/franmosteiro/aoc2020/Day04.kt
franmosteiro
433,734,642
false
{"Kotlin": 27170, "Ruby": 16611, "Shell": 389}
package io.franmosteiro.aoc2020 /** * Advent of Code 2020 - Day 4: Passport Processing - * Problem Description: http://adventofcode.com/2020/day/4 */ class Day04(input: String) { private val passports = input.split("\\n\\n".toRegex()).map { line -> line.split("\\s".toRegex()).associate { va...
0
Kotlin
0
0
dad555d9cd0c3060c4b1353c7c6f170aa340c285
1,423
advent-of-code
MIT License
src/main/kotlin/github/walkmansit/aoc2020/Day24.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day24(val input: List<String>) : DayAoc<Int, Int> { class Floor { private val deltaForSideMap = mapOf( "e" to Pair(1, 0), "se" to Pair(0, 1), "sw" to Pair(-1, 1), "w" to Pair(-1, 0), "nw" to Pair(0, -1), ...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
3,454
AdventOfCode2020
MIT License
src/main/kotlin/Day13.kt
clechasseur
267,632,210
false
null
import org.clechasseur.adventofcode2016.Direction import org.clechasseur.adventofcode2016.Pt import org.clechasseur.adventofcode2016.dij.Dijkstra import org.clechasseur.adventofcode2016.dij.Graph import org.clechasseur.adventofcode2016.manhattan object Day13 { private const val input = 1362 fun part1(): Int {...
0
Kotlin
0
0
120795d90c47e80bfa2346bd6ab19ab6b7054167
1,128
adventofcode2016
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day17.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import ch.ranil.aoc.PrintColor import ch.ranil.aoc.aoc2023.Direction.* import ch.ranil.aoc.print import ch.ranil.aoc.printColor import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day17 : AbstractDay() { @Test fun part1Test() { ...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
5,903
aoc
Apache License 2.0
kotlin/2421-number-of-good-paths.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 { class UnionFind(val n: Int) { val parent = IntArray (n) { it } val size = IntArray (n) { 1 } fun find(i: Int): Int { if (i != parent[i]) parent[i] = find(parent[i]) return parent[i] } fun union(a: Int, b: Int): Boole...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,851
leetcode
MIT License
src/test/kotlin/days/y2022/Day03Test.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2032 import days.Day import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.core.Is.`is` import org.junit.jupiter.api.Test class Day03Test { @Test fun scores() { assertThat('a'.itemScore(), `is`(1)) assertThat('z'.itemScore(), `is`(26)) assertThat('A'.itemSco...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,698
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Day14.kt
mstar95
317,305,289
false
null
package days class Day14 : Day(14) { override fun partOne(): Any { val input = prepareInput(inputList) val result = input.fold(Program(Mask(""), mutableMapOf())) { program, op -> program.op(op, program::write) } println(input) print(result) return result.memory.values.sum...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,872
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day25.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import java.util.* //const val RIGHT = 0 //const val DOWN = 1 //const val LEFT = 2 //const val UP = 3 //const val GND = '.' //const val ELF = '#' //const val N = 0 //const val S = 1 //const val W = 2 //const val E = 3 fun main() { fun part1(input: List<String>): String { fun convert(s: String): Long { ...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
1,965
AoC-2022
Apache License 2.0
src/Day14.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename fun getSandCount(input: List<String>, addFloor: Boolean = false): Int { // find grid size var numRows = 0 var numCols = 0 for (line in input) { val coordinates = line.split(" -> ") coordinates.windowed(2, 1) { ...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,633
KotlinAdventOfCode2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/medium/LongestPalindrome.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 5. 最长回文子串 * 给你一个字符串 s,找到 s 中最长的回文子串。 */ class LongestPalindrome { companion object { @JvmStatic fun main(args: Array<String>) { println(LongestPalindrome().longestPalindrome("babad")) println(LongestPalindrome().longestPa...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,535
daily_algorithm
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day08.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 private fun part1(instructions: String, nodes: Map<String, Pair<String, String>>) { var currentNode = "AAA" var steps = 0L while (currentNode != "ZZZ") { for (i in instructions) { when (i) { 'L' -> currentNode = nodes[currentNode]!!.first ...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
5,137
advent-of-code
MIT License
src/main/kotlin/_2022/Day04.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun toRanges(it: String) = it.split(",") .map { range -> val (start, end) = range.split("-").map(String::toInt) (start..end).toList() } fun part1(input: List<String>): Int { return input.map(::toRanges).count { ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
951
advent-of-code
Apache License 2.0
src/main/kotlin/be/tabs_spaces/advent2021/days/Day05.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import java.lang.IllegalStateException import kotlin.math.max import kotlin.math.min class Day05 : Day(5) { private val steamVents = inputList .map { it.split(" -> ") } .map { coordinates -> coordinates .map { it.split(",").map(String::toInt) } ...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
1,938
advent-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/day24/Day24.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day24 import java.io.File fun main() { val data = parse("src/main/kotlin/day24/Day24.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 24 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
3,776
advent-of-code-2022
MIT License
kotlin/src/main/kotlin/AoC_Day9.kt
sviams
115,921,582
false
null
object AoC_Day9 { const val START_GARBAGE = '<' const val END_GARBAGE = '>' const val START_GROUP = '{' const val END_GROUP = '}' const val NONE = ' ' const val IGNORE = '!' fun solvePt1(input: Sequence<String>) : Int = input.fold(0) {acc, line -> acc + line.toCharArray...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
2,520
aoc17
MIT License
kotlin/src/com/s13g/aoc/aoc2019/Day6.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2019 import com.s13g.aoc.Result import com.s13g.aoc.Solver import kotlin.math.min /** https://adventofcode.com/2019/day/6 */ class Day6 : Solver { private var map = mutableMapOf<String, Node>() override fun solve(lines: List<String>): Result { map = lines.map { l -> l.split(")...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,560
euler
Apache License 2.0
src/main/kotlin/g1201_1300/s1255_maximum_score_words_formed_by_letters/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1255_maximum_score_words_formed_by_letters // #Hard #Array #String #Dynamic_Programming #Bit_Manipulation #Backtracking #Bitmask // #2023_06_07_Time_131_ms_(100.00%)_Space_34.4_MB_(66.67%) class Solution { private lateinit var score: IntArray private fun updateArr(arr: IntArray, s: String...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,375
LeetCode-in-Kotlin
MIT License
src/Day22.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
private enum class CubeSides { TOP, DOWN, RIGHT, LEFT, FRONT, BACK } private enum class Moves(val coords: Pair<Int, Int>, val ind: Int) { RIGHT(0 to 1, 0), DOWN(1 to 0, 1), LEFT(0 to -1, 2), UP(-1 to 0, 3) } // // L.---. // E.TOP. // F.---. // T FRONT private abstract class MapWithMover(val map: List<S...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
8,807
advent-of-kotlin-2022
Apache License 2.0
endlessRunnersEvo/src/main/kotlin/cz/woitee/endlessRunners/evolution/utils/MathUtils.kt
woitee
219,872,458
false
null
package cz.woitee.endlessRunners.evolution.utils import kotlin.math.sqrt object MathUtils { fun divisorsOf(value: Int): ArrayList<Int> { var reducingValue = value val intSqrt = (sqrt(value.toDouble()) + 0.0001).toInt() val sieve = IntArray(intSqrt + 1) for (potentialDivisor in 2 ....
0
Kotlin
0
1
5c980f44397f0b4f122e7b2cb51b82cf1c0419df
1,935
endlessRunners
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[1]两数之和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 // // 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 // // // // 示例: // // 给定 nums = [2, 7, 11, 15], target = 9 // //因为 nums[0] + nums[1] = 2 + 7 = 9 //所以返回 [0, 1] // // Related Topics 数组 哈希表 // 👍 9778 👎 0 //leetcode submit region begin(Prohibit modificat...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,126
MyLeetCode
Apache License 2.0
codeforces/round637/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round637 fun main() { readLn() val d = readInts().sorted() val (g, r) = readInts() val inf = Int.MAX_VALUE val mark = Array(g) { BooleanArray(d.size) { false } } val queue = Array(g) { IntArray(d.size) } val queueLow = IntArray(g) val queueHigh = IntArray(g) mark[0][0] = true queueHigh[0] ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,149
competitions
The Unlicense
src/main/kotlin/days/Day12.kt
andilau
429,206,599
false
{"Kotlin": 113274}
package days @AdventOfCodePuzzle( name = "The N-Body Problem", url = "https://adventofcode.com/2019/day/12", date = Date(day = 12, year = 2019) ) class Day12(scan: List<String>) : Puzzle { private val moons = scan.map(Moon::from) override fun partOne(): Int = (0 until 1000) .fo...
2
Kotlin
0
0
f51493490f9a0f5650d46bd6083a50d701ed1eb1
3,218
advent-of-code-2019
Creative Commons Zero v1.0 Universal
src/Day10.kt
Kbzinho-66
572,299,619
false
{"Kotlin": 34500}
private data class CycleState(val tick: Int, val register: Int ) { val signalStrength = tick * register val pixelIsVisible = (tick - 1) % 40 in register - 1 .. register + 1 } fun main() { fun getAllStates(input: List<String>): List<CycleState> { val states: MutableList<CycleState> = mutableListOf(...
0
Kotlin
0
0
e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b
1,637
advent_of_code_2022_kotlin
Apache License 2.0
src/main/kotlin/Day17.kt
clechasseur
318,029,920
false
null
import org.clechasseur.adventofcode2020.Pt3D import org.clechasseur.adventofcode2020.Pt4D object Day17 { private val input = """ ##.##### #.##..#. .##...## ###.#... .####### ##....## ###.###. .#.#.#.. """.trimIndent() fun part1(): Int = gener...
0
Kotlin
0
0
6173c9da58e3118803ff6ec5b1f1fc1c134516cb
3,688
adventofcode2020
MIT License
src/com/saurabhtotey/trianglesolver/Triangle.kt
SaurabhTotey
102,925,664
false
null
package com.saurabhtotey.trianglesolver import kotlin.math.* val hasBeenInitialized = { a: Double -> a > 0 } //A function that will return whether a triangle angle or side has been initialized /** * A function that will return indices given a certain predicate */ fun getIndicesSuchThat(predicate: (Int) -> Boolean):...
1
Kotlin
0
0
8f0198c3b9066a4d745a6db072ebd6d41af8c2f3
11,295
Triangle-Solver
MIT License
src/main/kotlin/_2022/Day10.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val queue = ArrayDeque<SimpleCommand>() input.forEach { if ("noop" == it) { queue.add(NoopCommand()) } else if (it.startsWith("addx")) { ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
3,776
advent-of-code
Apache License 2.0
src/main/kotlin/cloud/dqn/leetcode/self/CoinsFromEarlyFallKt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode.self /** * "Problem from after lunch" * Designer: JN */ object CoinsFromEarlyFallKt { @JvmStatic fun main(args: Array<String>) { val coinValues = intArrayOf(5, 25, 50, 100) val possible = possibleSums(coinValues, intArrayOf(4, 3, 2, 1)) println(possible) }...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
2,700
cloud-dqn-leetcode
No Limit Public License
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day09/day09.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day09 import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input09-test.txt" const val FILENAME = "input09.txt" fun main() { val histories = readLines(2023, FILENAME).map { History.parse(it) } val extrapolated = histories.map { it.extrapolate() } val sum = extrapolated.sumO...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,330
advent-of-code
Apache License 2.0
src/day09/Day09.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day09 import readInput import readNumbers class Day09(val input: List<String>) { private fun getSequence() = generateSequence(0) { it + 1 } private fun parseInput(): List<List<Long>> { return input.map { it.readNumbers() } } private fun predictNextValue(numbers: List<Long>): Long { val pred...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
960
advent-of-code-2023-kotlin
Apache License 2.0
src/main/kotlin/week2/DistressSignal.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package week2 import shared.Puzzle import shared.ReadUtils.Companion.debug class DistressSignal : Puzzle(13) { override fun solveFirstPart(): Any { return puzzleInput.asSequence().filter { it.isNotBlank() } .chunked(2) .map { parseEntry(it[0], 0) to parseEntry(it[1], 0) } ...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
5,499
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
day12/Kotlin/day12.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* fun print_day_12() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 12" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime().exec("figlet Passage Pathing -c -f small") ...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
2,879
AOC2021
Apache License 2.0
src/problems/day4/part1/part1.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day4.part1 import java.io.File import kotlin.math.pow //private const val testFile = "input/day4/test.txt" private const val cardsFile = "input/day4/cards.txt" fun main() { val cardValueSum = File(cardsFile).bufferedReader().useLines { sumCardValues(it) } println("Card Values Sum: $cardValue...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
1,244
aoc2023
MIT License
Kotlin for Java Developers. Week 3/Taxi Park/Task/src/taxipark/TaxiParkTask.kt
vnay
251,709,901
false
null
package taxipark /* * Task #1. Find all the drivers who performed no trips. */ fun TaxiPark.findFakeDrivers(): Set<Driver> = allDrivers - trips.map { it.driver } /* * Task #2. Find all the clients who completed at least the given number of trips. */ fun TaxiPark.findFaithfulPassengers(minTrips: Int): Set<...
0
Kotlin
0
0
ce638b0272bd5fac80891a669cd17848bf6d0721
2,458
Kotlin-for-Java-Developers
MIT License
src/main/kotlin/org/example/e3fxgaming/adventOfCode/aoc2023/day08/Day08.kt
E3FxGaming
726,041,587
false
{"Kotlin": 38290}
package org.example.e3fxgaming.adventOfCode.aoc2023.day08 import org.example.e3fxgaming.adventOfCode.utility.Day import org.example.e3fxgaming.adventOfCode.utility.InputParser import org.example.e3fxgaming.adventOfCode.utility.Math import org.example.e3fxgaming.adventOfCode.utility.MultiLineInputParser class Day08(in...
0
Kotlin
0
0
3ae9e8b60788733d8bc3f6446d7a9ae4b3dabbc0
3,334
adventOfCode
MIT License
src/2022/Day20.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import java.io.File import java.math.BigInteger import java.util.* fun main() { Day20().solve() } class Day20 { val input1 = """ 1 2 -3 3 -2 0 4 """.trimIndent() fun MutableList<Pair<Int, BigInteger>>.move(ix: Int) { va...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
2,810
advent-of-code
Apache License 2.0
src/Day09.kt
jbotuck
573,028,687
false
{"Kotlin": 42401}
import kotlin.math.abs import kotlin.math.sign fun main() { val lines = readInput("Day09") var rope = Rope() for (line in lines) { rope.execute(line) } println(rope.countOfSpotsTailVisited()) rope = Rope(10) for (line in lines) { rope.execute(line) } println(rope.cou...
0
Kotlin
0
0
d5adefbcc04f37950143f384ff0efcd0bbb0d051
1,654
aoc2022
Apache License 2.0
src/Day01.kt
ianredman26
572,914,381
false
{"Kotlin": 3237}
fun main() { fun part1(input: List<String>): List<Pair<Int, Int>> { val elves: MutableMap<Int, Int> = mutableMapOf() var total = 0 input.map { total = if (it.isEmpty()) { elves[elves.size.plus(1)] = total 0 } else { tota...
0
Kotlin
0
0
dcd9fae4531622cc974d2eb3d5ded94bf268ad1e
864
advent-of-code-2022
Apache License 2.0
src/Day03.kt
emmanueljohn1
572,809,704
false
{"Kotlin": 12720}
fun main() { fun getScore(ch: Char): Int { if(ch.isLowerCase()) { return (ch.code - 97) + 1 } return (ch.code - 65) + 27 } fun part1(input: List<String>): Int { return input.flatMap { line -> val (chest1, chest2) = line.chunked(line.length / 2) ...
0
Kotlin
0
0
154db2b1648c9d12f82aa00722209741b1de1e1b
1,080
advent22
Apache License 2.0
2015/src/main/kotlin/day18.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.MutableGrid import utils.Solution import utils.createMutableGrid import utils.toMutable fun main() { Day18.run() } object Day18 : Solution<Grid<Char>>() { override val name = "day18" override val parser = Grid.chars(oobBehaviour = Grid.OobBehaviour.Default('.')) private const v...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,281
aoc_kotlin
MIT License
src/main/kotlin/day04/Day04.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day04 import java.io.File fun main() { val (numbers, boards) = parse("src/main/kotlin/day04/Day04.txt") val answer1 = part1(numbers, boards.map(List<Int>::toMutableList)) val answer2 = part2(numbers, boards.map(List<Int>::toMutableList)) println("🎄 Day 04 🎄") println() println("[...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
4,206
advent-of-code-2021
MIT License
src/main/kotlin/QuickSort.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Swap two elements in an array. */ private fun swap(arr: Array<Int>, i: Int, j: Int) { val temp = arr[i] arr[i] = arr[j] arr[j] = temp } /** * Partition the array around a randomly selected pivot. * Return the index of the pivot. */ private fun partition(arr: Array<Int>, left: Int, right: Int): I...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,139
kotlin-codes
Apache License 2.0
leetcode-75-kotlin/src/main/kotlin/UniqueNumberOfOccurrences.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * Given an array of integers arr, * return true if the number of occurrences of each value in the array is unique or false otherwise. * * * * Example 1: * * Input: arr = [1,2,2,1,1,3] * Output: true * Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of oc...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,039
leetcode-75
Apache License 2.0
src/Day08.kt
gojoel
573,543,233
false
{"Kotlin": 28426}
import kotlin.math.max enum class Direction { UP, DOWN, LEFT, RIGHT } // TODO: improve performance fun main() { val input = readInput("08") // val input = readInput("08_test") fun buildGrid(input: List<String>) : ArrayList<IntArray> { val numCols = input[0].length val grid: ArrayList<IntAr...
0
Kotlin
0
0
0690030de456dad6dcfdcd9d6d2bd9300cc23d4a
4,753
aoc-kotlin-22
Apache License 2.0
src/main/kotlin/day02/Problem.kt
xfornesa
572,983,494
false
{"Kotlin": 18402}
package day02 fun solveProblem01(input: List<Pair<String, String>>): Int { var score = 0 input.forEach { score += round01(it) } return score } // A for Rock, B for Paper, and C for Scissors // X for Rock, Y for Paper, and Z for Scissors // score: (1 for Rock, 2 for Paper, and 3 for Scissors) +...
0
Kotlin
0
0
dc142923f8f5bc739564bc93b432616608a8b7cd
2,333
aoc2022
MIT License
src/main/kotlin/endredeak/aoc2023/Day03.kt
edeak
725,919,562
false
{"Kotlin": 26575}
package endredeak.aoc2023 import endredeak.aoc2023.lib.utils.productOf import kotlin.math.max import kotlin.math.min data class Symbol(val x: Int, val y: Int, val c: Char) data class Number(val x: Int, val y: Int, var value: Long) fun Char.isSymbol() = !this.isDigit() && this != '.' fun createMap(lines: List<String...
0
Kotlin
0
0
92c684c42c8934e83ded7881da340222ff11e338
1,983
AdventOfCode2023
Do What The F*ck You Want To Public License
src/main/kotlin/com/staricka/adventofcode2022/Day5.kt
mathstar
569,952,400
false
{"Kotlin": 77567}
package com.staricka.adventofcode2022 import com.staricka.adventofcode2022.Day5.Stacks.Companion.parseToStacks class Day5 : Day { override val id = 5 class Stacks(n: Int) { val stacks = ArrayList<ArrayDeque<Char>>(n) init { for (x in 1..n) { stacks.add(ArrayDeque()) } } fun a...
0
Kotlin
0
0
2fd07f21348a708109d06ea97ae8104eb8ee6a02
2,367
adventOfCode2022
MIT License
src/main/kotlin/com/github/michaelbull/advent2021/day11/Grid.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day11 import com.github.michaelbull.advent2021.math.Vector2 import com.github.michaelbull.advent2021.math.Vector2.Companion.CARDINAL_DIRECTIONS import com.github.michaelbull.advent2021.math.Vector2.Companion.ORDINAL_DIRECTIONS fun Sequence<String>.toGrid(): Grid { val cel...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
3,246
advent-2021
ISC License
src/main/kotlin/us/jwf/aoc2021/Day08SevenSegmentSearch.kt
jasonwyatt
318,073,137
false
null
package us.jwf.aoc2021 import java.io.Reader import us.jwf.aoc.Day /** * AoC 2021 - Day 8 */ class Day08SevenSegmentSearch : Day<Int, Int> { override suspend fun executePart1(input: Reader): Int { return input.readLines() .sumOf { it.countDigitsDumb() } } override suspend fun executePart2(input: Re...
0
Kotlin
0
0
0c92a62ba324aaa1f21d70b0f9f5d1a2c52e6868
2,539
AdventOfCode-Kotlin
Apache License 2.0
src/Day05.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
class Day05(l: List<String>) { init { // println(l) } private val lines = l.joinToString("\n").split("\n\n") private val startingStacks = this.lines[0].lines() private val stackCount = startingStacks.reversed()[0].last().digitToInt() private val moves = this.lines[1].lines() fun ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
1,980
advent22
Apache License 2.0
src/Day04.kt
JonahBreslow
578,314,149
false
{"Kotlin": 6978}
import java.io.File import kotlin.math.min fun main () { fun parseInput(input: String) : List<List<Set<Int>>>{ return File(input) .readLines() .map { it.split(",") } .map{ val set1 = (it[0].split("-")[0].toInt() until it[0].split("-")[1].toInt()...
0
Kotlin
0
1
c307ff29616f613473768168cc831a7a3fa346c2
1,261
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day22.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import Point3 import overlaps import readInput import kotlin.math.max import kotlin.math.min object Day22 { private data class Brick(private val start: Point3, private val end: Point3) { val xRange = min(start.x, end.x)..max(start.x, end.x) val yRange = min(start.y, end.y)..max(s...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,813
adventOfCode
Apache License 2.0
day-02/src/main/kotlin/Dive.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private fun partOne(): Int { var horizontal = 0 var depth = 0 readInput() .forEach { when (it.first) { Command.FORWARD -> horizontal += it.second ...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
1,364
aoc-2021
MIT License
kotlin/src/katas/kotlin/skiena/combinatorial_search/Backtracking.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.skiena.combinatorial_search import katas.kotlin.skiena.combinatorial_search.SudokuTests.Sudoku.Companion.columnIndicesAt import katas.kotlin.skiena.combinatorial_search.SudokuTests.Sudoku.Companion.rowIndicesAt import katas.kotlin.skiena.combinatorial_search.SudokuTests.Sudoku.Companion.squareIndi...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
13,043
katas
The Unlicense
src/Day24.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
const val wall = '#' const val left = '<' const val right = '>' const val up = '^' const val down = 'v' class Maze() { constructor(input: List<String>) : this() { load(input) } var maze = listOf<List<Set<Char>>>() var mazeWidth = 0 val start = Point(1, 0) lateinit var end: Point fu...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
4,229
2022-aoc-kotlin
Apache License 2.0
src/main/kotlin/g0901_1000/s0987_vertical_order_traversal_of_a_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0987_vertical_order_traversal_of_a_binary_tree // #Hard #Hash_Table #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #2023_05_10_Time_189_ms_(66.67%)_Space_36.8_MB_(66.67%) import com_github_leetcode.TreeNode import java.util.PriorityQueue import java.util.Queue import java.util.Tre...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,525
LeetCode-in-Kotlin
MIT License
kotlin/graphs/dfs/StronglyConnectedComponents.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.dfs import java.util.stream.Stream // https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm object StronglyConnectedComponents { fun scc(graph: Array<List<Integer>>): List<List<Integer>> { val n = graph.size val used = BooleanArray(n) val order: List<Integer> = ArrayList() ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,258
codelibrary
The Unlicense
year2016/src/main/kotlin/net/olegg/aoc/year2016/day15/Day15.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day15 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2016.DayOf2016 /** * See [Year 2016, Day 15](https://adventofcode.com/2016/day/15) */ object Day15 : DayOf2016(15) { private val PATTERN = "Disc #(\\d+) has (\\d+) positions; at time=(\\d+), it is at position (\\d+)...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,062
adventofcode
MIT License
src/main/kotlin/com/colinodell/advent2022/Day14.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day14(input: List<String>) { private val grid = input.flatMap { line -> line.split(" -> ") // Things in between -> arrows are points .map { point -> point.split(",").let { (x, y) -> Vector2(x.toInt(), y.toInt()) } } // Group each p...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,945
advent-2022
MIT License
Minimum_Size_Subarray_Sum_v1.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
// Given an array of n positive integers and a positive integer s, find the minimal // length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead. class Solution { fun minSubArrayLen(s: Int, nums: IntArray): Int { if (nums.isEmpty()) return 0 val preSum = IntArray(nu...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,168
leetcode
MIT License
src/main/kotlin/icfp2019/Parsers.kt
teemobean
193,332,580
true
{"JavaScript": 797310, "Kotlin": 85937, "CSS": 9434, "HTML": 5859}
package icfp2019 import com.google.common.base.CharMatcher import com.google.common.base.Splitter import com.google.common.collect.Range import com.google.common.collect.TreeRangeSet import icfp2019.model.* import org.pcollections.TreePVector class Splitters { companion object { val PAREN_MATCHER = CharMa...
13
JavaScript
12
0
afcf5123ffb72ac10cfa6b0772574d9826f15e41
4,289
icfp-2019
The Unlicense
src/main/kotlin/com/ginsberg/advent2019/Day24.kt
tginsberg
222,116,116
false
null
/* * Copyright (c) 2019 by <NAME> */ /** * Advent of Code 2019, Day 24 - Planet of Discord * Problem Description: http://adventofcode.com/2019/day/24 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day24/ */ package com.ginsberg.advent2019 import java.math.BigInteger import java.util....
0
Kotlin
2
23
a83e2ecdb6057af509d1704ebd9f86a8e4206a55
5,109
advent-2019-kotlin
Apache License 2.0
src/pl/shockah/aoc/y2021/Day9.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2021 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.unikorn.collection.Array2D class Day9: AdventTask<Array2D<Int>, Int, Int>(2021, 9) { override fun parseInput(rawInput: String): Array2D<Int> { val lines = rawInp...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
2,543
Advent-of-Code
Apache License 2.0
src/main/kotlin/cc/stevenyin/algorithms/_02_sorts/_06_QuickSort_Basic.kt
StevenYinKop
269,945,740
false
{"Kotlin": 107894, "Java": 9565}
package cc.stevenyin.algorithms._02_sorts import cc.stevenyin.algorithms.RandomType import cc.stevenyin.algorithms.swap import cc.stevenyin.algorithms.testSortAlgorithm import kotlin.random.Random /** * 存在的问题: * 1. 对于一个已经有序或近乎有序的数组来说, * 每一次从第一个位置选取一个元素, * 很可能导致两侧的子数组变得极其不平衡。 * 所以可以采取随机选择的方法来确定待...
0
Kotlin
0
1
748812d291e5c2df64c8620c96189403b19e12dd
2,115
kotlin-demo-code
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[290]单词规律.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一种规律 pattern 和一个字符串 str ,判断 str 是否遵循相同的规律。 // // 这里的 遵循 指完全匹配,例如, pattern 里的每个字母和字符串 str 中的每个非空单词之间存在着双向连接的对应规律。 // // 示例1: // // 输入: pattern = "abba", str = "dog cat cat dog" //输出: true // // 示例 2: // // 输入:pattern = "abba", str = "dog cat cat fish" //输出: false // // 示例 3: // // 输入: pattern = "aaaa", str = ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,579
MyLeetCode
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem2007/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2007 /** * LeetCode page: [2007. Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array/); */ class Solution { /* Complexity: * Time O(N+M) and Aux_Space O(M) where N is size of changed and M is maximum value of chan...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,724
hj-leetcode-kotlin
Apache License 2.0
src/Day23.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
private val neighbours = listOf( Pos(-1, -1), Pos(-1, 0), Pos(-1, 1), Pos(0, 1), Pos(1, 1), Pos(1, 0), Pos(1, -1), Pos(0, -1), ) private val directionNeighbours = mapOf( // direction to move in neighbour occupied Direction.UP to listOf( Pos(-1, -1), Pos(-1, 0), ...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
4,822
advent-of-code-2022
Apache License 2.0
kotlin/2022/day04/Day04.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
class Day04 { fun part1(input: Iterable<String>): Int { return findPairCountBy(input) { ranges -> ranges[0].all { ranges[1].contains(it) } || ranges[1].all { ranges[0].contains(it) } } } fun part2(input: Iterable<String>): Int { return findPairCountBy(input) { ...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
870
adventofcode
MIT License
lib_algorithms_sort_kotlin/src/main/java/net/chris/lib/algorithms/sort/kotlin/KTMergeSorter.kt
chrisfang6
105,401,243
false
{"Java": 68669, "Kotlin": 26275, "C++": 12503, "CMake": 2182, "C": 1403}
package net.chris.lib.algorithms.sort.kotlin /** * Merge sort. * * @param <T> </T> */ abstract class KTMergeSorter : KTSorter() { override fun subSort(array: IntArray) { if (array == null) { return } mergeSort(array, 0, array.size - 1) } private fun mergeSort(A: Int...
0
Java
0
0
1f1c2206d5d9f0a3d6c070a7f6112f60c2714ec0
1,427
sort
Apache License 2.0
src/main/kotlin/Main.kt
NextTurnGames
453,470,447
false
{"Kotlin": 9350}
package games.nextturn import java.io.File import java.lang.RuntimeException var allWords = setOf<String>() var commonWords = setOf<String>() fun main() { loadWords() println("Available choices:") println("[1] Input grades (use as aide)") println("[2] Test against random word") println("[3] Test...
0
Kotlin
0
0
5e0f21a7794b762fd169368b352a146138d4950b
8,698
Wordle
MIT License
src/main/kotlin/days/Day3.kt
Kamefrede
434,954,548
false
{"Kotlin": 9152}
package days class Day3 : Day(3) { override fun partOne(): Any { val bitCount = getBitCount(inputList) val (epsilon, gamma) = getGammaEpsilon(bitCount) return Integer.parseInt(gamma, 2) * Integer.parseInt(epsilon, 2) } override fun partTwo(): Any { val co2 = mostCommon(inpu...
0
Kotlin
0
0
97cae5cd9d38254b1dc75022fc24f10aa868531a
2,204
AoC2021
Creative Commons Zero v1.0 Universal
kotlin/app/src/main/kotlin/coverick/aoc/day5/SupplyStacks.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day5 import readResourceFile import splitOn val INPUT_FILE = "supplyStacks-input.txt" fun parseConfigLine(s:String): List<String>{ var idx = 0 val result = ArrayList<String>() val eatCrate = fun() { if(idx < s.length && s[idx] == '['){ idx++ result.ad...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
2,991
adventofcode2022
Apache License 2.0
solutions/aockt/y2023/Y2023D18.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import aockt.util.spacial.Direction import aockt.util.spacial.Direction.* import aockt.util.spacial.Point import aockt.util.spacial.move import aockt.util.spacial.polygonArea import io.github.jadarma.aockt.core.Solution object Y2023D18 : Solution { /** * A single ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,478
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/day8/Day8.kt
Mee42
433,459,856
false
{"Kotlin": 42703, "Java": 824}
package dev.mee42.day8 import dev.mee42.* val testShort = """ acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf """.trimIndent() val test = """ be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd a...
0
Kotlin
0
0
db64748abc7ae6a92b4efa8ef864e9bb55a3b741
5,257
aoc-2021
MIT License
src/main/aoc2016/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2016 import Direction import Pos import org.magicwerk.brownies.collections.GapList import java.util.* class Day24(input: List<String>) { val theMap = Map(input) /** * A node in the graph. * * A node is a place where the road splits into more than one new direction * or a named ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
10,983
aoc
MIT License
src/main/kotlin/solutions/day09/Day9.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day09 import solutions.Solver import utils.Coordinate import utils.Direction import utils.step import kotlin.math.abs class Day9 : Solver { override fun solve(input: List<String>, partTwo: Boolean): String { val rope = mutableListOf<Coordinate>() val ropeLength = if (!partTwo) {...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
2,376
Advent-of-Code-2022
MIT License
Kotlin Heroes 6 -Practice/G.kt
julianferres
163,219,585
false
{"C++": 768665, "Python": 164172, "Makefile": 51615, "C": 20271, "CMake": 15247, "Kotlin": 4329, "ReScript": 23}
data class Edge(val from: Int, val to: Int, val cost: Long) class DSU(val n: Int){ var par: MutableList<Int> = MutableList<Int>(n){ it } var sz: MutableList<Int> = MutableList<Int>(n){ 1 } fun find(x: Int): Int { if(par[x] != x) par[x] = find(par[x]) return par[x] } fun join(i...
0
C++
0
4
14e8369e82a2403094183d6f7824201f681c9f65
1,392
Codeforces
MIT License
2022/main/day_03/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_03_2022 import java.io.File val map = mapOf( 'a' to 1, 'b' to 2, 'c' to 3, 'd' to 4, 'e' to 5, 'f' to 6, 'g' to 7, 'h' to 8, 'i' to 9, 'j' to 10, 'k' to 11, 'l' to 12, 'm' to 13, 'n' to 14, 'o' to 15, 'p' to 16, 'q' to 17, 'r' to 18, 's' to 19, 't' to 20, 'u' to 21, 'v' to 22, 'w' to 23, 'x' t...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,700
AdventofCode
MIT License
src/main/kotlin/me/circuitrcay/euler/challenges/fiftyOneToSeventyFive/Problem60.kt
adamint
134,989,381
false
null
package me.circuitrcay.euler.challenges.fiftyOneToSeventyFive import me.circuitrcay.euler.Problem import me.circuitrcay.euler.utils.convertSieveToPlaces import me.circuitrcay.euler.utils.sieveOf class Problem60 : Problem<String>() { override fun calculate(): Any { val primes = sieveOf(10000).convertSieveT...
0
Kotlin
0
0
cebe96422207000718dbee46dce92fb332118665
1,770
project-euler-kotlin
Apache License 2.0
src/main/kotlin/com/frankandrobot/rapier/nlp/generalize.kt
frankandrobot
62,833,944
false
null
/* * Copyright 2016 <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 ...
1
Kotlin
1
1
ddbc0dab60ca595e63a701e2f8cd6694ff009adc
2,826
rapier
Apache License 2.0
week7fewestfactors/FewestFactors.kt
laitingsheng
341,616,623
false
null
class FewestFactors { private fun IntArray.swap(l: Int, r: Int) { val tmp = this[l] this[l] = this[r] this[r] = tmp } private val IntArray.number: Int get() = fold(0) { acc, it -> 10 * acc + it } private val Int.factors: Int get() { var nf = 0 ...
0
Kotlin
0
0
2fc3e7a23d37d5e81cdf19a9ea19901b25941a49
1,268
2020S1-COMP-SCI-7007
ISC License
src/main/kotlin/year2022/day20/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day20 import IProblem class Problem : IProblem { private val input = javaClass .getResource("/2022/20.txt")!! .readText() .lines() .filter(String::isNotEmpty) .map(String::toLong) private fun nthForward(node: Node, n: Int): Node { var curr = no...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
1,759
advent-of-code
The Unlicense
src/main/kotlin/g1301_1400/s1339_maximum_product_of_splitted_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1339_maximum_product_of_splitted_binary_tree // #Medium #Depth_First_Search #Tree #Binary_Tree // #2023_06_06_Time_384_ms_(100.00%)_Space_57.2_MB_(66.67%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree node. * class ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,481
LeetCode-in-Kotlin
MIT License
core/src/main/kotlin/dev/komu/kraken/model/region/ShortestPathSearcher.kt
komu
83,556,775
false
{"Kotlin": 225797}
package dev.komu.kraken.model.region import java.util.* open class ShortestPathSearcher(val region: Region) { open val allowSubDirections = true fun findFirstCellOnShortestPath(start: Cell, goal: Cell): Cell? = findShortestPath(start, goal)?.drop(1)?.firstOrNull() fun findShortestPath(start: Ce...
0
Kotlin
0
0
680362d8e27c475b4ef1e2d13b67cb87f67249f6
2,715
kraken
Apache License 2.0
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day14.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput class Day14 : Day<Long> { companion object { private val maskRegex = Regex("^mask = ([01X]+)$") private val setRegex = Regex("^mem\\[([0-9]+)] = ([0-9]+)$") } private val ac...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
3,367
adventofcode
Apache License 2.0
mazes-for-programmers/kotlin/src/main/kotlin/io/github/ocirne/mazes/colorization/Colorization.kt
ocirne
496,354,199
false
{"Kotlin": 128908, "Python": 88203}
package io.github.ocirne.mazes.colorization import io.github.ocirne.mazes.grids.Cell import io.github.ocirne.mazes.grids.Maze import java.awt.Color import kotlin.math.roundToInt open class Colorization( private val grid: Maze, private val fromColor: Color = Color.DARK_GRAY, private val toColor: Color = Co...
0
Kotlin
0
0
9f67bad218f6160fd0459ad258e9f7554c7f0527
3,114
mazes
The Unlicense
src/main/kotlin/ru/timakden/aoc/year2016/Day02.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2016 import ru.timakden.aoc.util.Point import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 2: Bathroom Security](https://adventofcode.com/2016/day/2). */ object Day02 { @JvmStatic fun main(args: Array<String>) { measure { val i...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,271
advent-of-code
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day22.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints fun main() { Day22.run() } object Day22 : Day(2015, 22) { private val costs = mapOf( 'M' to 53, 'D' to 73, 'S' to 113, 'P' to 173, 'R' to 229 ) private val boss...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
4,257
adventofkotlin
MIT License
src/Day06.kt
alexdesi
575,352,526
false
{"Kotlin": 9824}
import java.io.File fun String.occurrences(c: Char) = this.count { it == c } fun main() { fun duplicatesPresent(string4: String): Boolean { string4.forEach { println(string4.occurrences(it)) if (string4.occurrences(it) > 1) return true } return false...
0
Kotlin
0
0
56a6345e0e005da09cb5e2c7f67c49f1379c720d
1,175
advent-of-code-kotlin
Apache License 2.0
app/src/main/java/com/canerkorkmaz/cicek/jobdistribution/solver/GreedySolver.kt
nberktumer
173,110,988
false
{"Kotlin": 47340}
package com.canerkorkmaz.cicek.jobdistribution.solver import com.canerkorkmaz.cicek.jobdistribution.model.InputDataFormatted import com.canerkorkmaz.cicek.jobdistribution.model.JobData import com.canerkorkmaz.cicek.jobdistribution.model.Solution import com.canerkorkmaz.cicek.jobdistribution.model.SolutionPack import c...
0
Kotlin
0
0
bd3356d1dcd0da1fa4a4ed5967205ea488724d3a
2,081
CicekSepeti-Hackathon
Apache License 2.0
src/Day06Alternate.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
class Day06Alternate(private val input: String) { private fun String.indexForUniqSeqLen(size: Int): Int { val checkArray = IntArray(26) { 0 } return withIndex().first { (index, char) -> checkArray[char - 'a']++ if (index >= size) { checkArray[elementAt(index -...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
1,040
advent-of-code-2022-kotlin
Apache License 2.0
src/sorting/AdvancedSorting.kt
ArtemBotnev
136,745,749
false
{"Kotlin": 79256, "Shell": 292}
package sorting import java.util.* /** * sorts array by quick sort algorithm * * @param array which isn't sorted * @return sorted array */ fun quickSort(array: Array<Int>): Array<Int> { /** * sorts array * * @param arr which isn't sorted * @param low lower border in array which should be ...
0
Kotlin
0
0
530c02e5d769ab0a49e7c3a66647dd286e18eb9d
8,720
Algorithms-and-Data-Structures
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day12.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
import se.saidaspen.aoc.util.* fun main() = Day12.run() object Day12 : Day(2022, 12) { private val map = toMap(input) private fun costOf(b: Pair<Int, Int>, a: Pair<Int, Int>) = (map[b]!!.code - 'a'.code) - (map[a]!!.code - 'a'.code) private val startPos = map.entries.first { it.value == 'S' }.key pr...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
945
adventofkotlin
MIT License
src/day10/Day10.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day10 import readInput import readTestInput private fun computeRegisterValues(input: List<String>) = sequence { var registerValue = 1 for (instruction in input) { val instructionParts = instruction.split(' ') val op = instructionParts.first() val args = instructionParts.drop(1...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
2,016
advent-of-code-kotlin-2022
Apache License 2.0
project/src/problems/GreedyAlgorithms.kt
informramiz
173,284,942
false
null
package problems /** * Created by <NAME> on 2019-06-19 * https://codility.com/media/train/14-GreedyAlgorithms.pdf * * ----------Description--------------- * We consider problems in which a result comprises a sequence of steps or choices that have to be made to achieve the * optimal solution. Greedy programming i...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
7,322
codility-challenges-practice
Apache License 2.0