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/main/kotlin/com/ginsberg/advent2018/Day10.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 10 - The Stars Align * * Problem Description: http://adventofcode.com/2018/day/10 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day10/ */ package com.ginsberg.advent2018 class Day10(rawInput: List<String>) { p...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
2,460
advent-2018-kotlin
MIT License
year2020/src/main/kotlin/net/olegg/aoc/year2020/day9/Day9.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day9 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseLongs import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 9](https://adventofcode.com/2020/day/9) */ object Day9 : DayOf2020(9) { override fun first(): Any? { val nums = data.parseLongs("\n")...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,367
adventofcode
MIT License
src/main/kotlin/dev/siller/aoc2022/Day09.kt
chearius
575,352,798
false
{"Kotlin": 41999}
package dev.siller.aoc2022 import kotlin.math.sign private val examples = listOf( """ R 4 U 4 L 3 D 1 R 4 D 1 L 5 R 2 """.trimIndent(), """ R 5 U 8 L 8 D 3 R 17 D 10 L 25 U 20 ...
0
Kotlin
0
0
e070c0254a658e36566cc9389831b60d9e811cc5
2,912
advent-of-code-2022
MIT License
test/leetcode/KSimilarStrings.kt
andrej-dyck
340,964,799
false
null
package leetcode import lib.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.* import org.junit.jupiter.params.provider.* /** * https://leetcode.com/problems/k-similar-strings/ * * 854. K-Similar Strings * [Hard] * * Strings A and B are K-similar (for some non-negative integer...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
1,874
coding-challenges
MIT License
domain/src/main/kotlin/com/seanshubin/kotlin/tryme/domain/ratio/Ratio.kt
SeanShubin
228,113,855
false
null
package com.seanshubin.kotlin.tryme.domain.ratio data class Ratio(val numerator: Int, val denominator: Int) : Comparable<Ratio> { operator fun plus(that: Ratio): Ratio { val lcm = leastCommonMultiple(denominator, that.denominator) return Ratio(numerator * lcm / denominator + that.numerator * lcm / that.denom...
0
Kotlin
0
0
abc67c5f43c01bdf55c6d4adcf05b77610c0473a
2,247
kotlin-tryme
The Unlicense
src/Day10.kt
Redstonecrafter0
571,787,306
false
{"Kotlin": 19087}
fun main() { fun part1(input: List<String>): Int { var x = 1 var cycle = 0 var result = 0 var lastAdd = 0 for (cmd in input.map { it.split(" ") }) { when (cmd[0]) { "noop" -> cycle++ "addx" -> cycle += 2 } i...
0
Kotlin
0
0
e5dbabe247457aabd6dd0f0eb2eb56f9e4c68858
1,844
Advent-of-Code-2022
Apache License 2.0
advent9/src/main/kotlin/Main.kt
thastreet
574,294,123
false
{"Kotlin": 29380}
import java.io.File import kotlin.math.abs data class Command( val direction: Char, val steps: Int ) data class Position( val x: Int, val y: Int ) fun Position.distanceFrom(other: Position) = Distance(x - other.x, y - other.y) fun Position.incrementX() = copy(x = x + 1) fun Position.decreme...
0
Kotlin
0
0
e296de7db91dba0b44453601fa2b1696af9dbb15
3,172
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day9.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days import java.util.Stack class Day9 : Day(9) { override fun partOne(): Any { val map = inputList.map { it.map { Character.getNumericValue(it) } } return map.flatMapIndexed { i, row -> row.mapIndexed { j, height -> var risk = height + 1 if (i ...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
2,266
aoc-2021
Creative Commons Zero v1.0 Universal
kotlin/graphs/TreeCenters.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs import java.util.stream.Stream object TreeCenters { // returns 1 or 2 tree centers // http://en.wikipedia.org/wiki/Graph_center fun findTreeCenters(tree: Array<List<Integer>>): List<Integer> { val n = tree.size var leaves: List<Integer> = ArrayList() val degree = Int...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,449
codelibrary
The Unlicense
code/string/SuffixArray.kt
hakiobo
397,069,173
false
null
private fun constructSuffixArray(t: String): IntArray { val n = t.length val c = IntArray(max(n, 256)) val rank = IntArray(n) { t[it].toInt() } val tempRank = IntArray(n) val suffix = IntArray(n) { it } val tempSuffix = IntArray(n) fun countingSort(k: Int) { var sum = 0 c.fi...
0
Kotlin
1
2
f862cc5e7fb6a81715d6ea8ccf7fb08833a58173
1,686
Kotlinaughts
MIT License
src/main/kotlin/solutions/day25/Day25.kt
Dr-Horv
112,381,975
false
null
package solutions.day25 import solutions.Solver import utils.splitAtWhitespace import java.lang.RuntimeException import java.util.regex.Pattern enum class Direction { LEFT, RIGHT } fun Int.move(direction: Direction) = when(direction) { Direction.LEFT -> this - 1 Direction.RIGHT -> this + 1 } fun St...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
2,362
Advent-of-Code-2017
MIT License
src/main/kotlin/days/aoc2021/Day15.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day import java.util.* import kotlin.Comparator class Day15 : Day(2021, 15) { override fun partOne(): Any { val cave = createCave(inputList) return calculateLowestRiskPath(cave) } override fun partTwo(): Any { val cave = createFullCave(createCave(i...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,251
Advent-Of-Code
Creative Commons Zero v1.0 Universal
2015/src/main/kotlin/com/koenv/adventofcode/Day7.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode class Day7 { val numberOfWires: Int get() = wires.size private val wires = hashMapOf<String, Int>() private val unsatisfiedDependencies = arrayListOf<Dependency>() public fun parseCommand(input: String) { val inputParts = input.trim().split(" -> ", ignor...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
4,670
AdventOfCode-Solutions-Kotlin
MIT License
src/Day09.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import kotlin.math.abs fun main() { fun headsCount(input: List<String>, size: Int): Int { val x = MutableList(size) { 0 } val y = MutableList(size) { 0 } val tails = mutableSetOf(Pair(0, 0)) input.forEach { line -> val command = line.split(" ") repeat(command...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
1,290
Advent-of-code
Apache License 2.0
src/Day03.kt
SebastianHelzer
573,026,636
false
{"Kotlin": 27111}
fun main() { fun Char.getCharPriority(): Int = when (this) { in 'A'..'Z' -> this - 'A' + 27 in 'a'..'z' -> this - 'a' + 1 else -> error("Input $this must be a letter") } fun part1(input: List<String>): Int = input .map { line -> line.chunked(line.length/2).map { it.toSet()...
0
Kotlin
0
0
e48757626eb2fb5286fa1c59960acd4582432700
937
advent-of-code-2022
Apache License 2.0
src/DayThree.kt
P-ter
573,301,805
false
{"Kotlin": 9464}
data class House(val rowIndex: Int, val colIndex: Int) fun main() { fun part1(input: List<String>): Int { val direction = input.first() val santaMap = mutableMapOf(House(0, 0) to 1) var count = 1 var currentHouse = santaMap.keys.first() direction.forEach { val (r...
0
Kotlin
0
0
fc46b19451145e0c41b1a50f62c77693865f9894
2,245
aoc-2015
Apache License 2.0
strings/BuddyStrings/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
import kotlin.math.sign /** * 859. Buddy Strings. * <br/> * Given two strings A and B of lowercase letters, * return true if you can swap two letters in A so the result is equal to B, * otherwise, return false. * Swapping letters is defined as taking two indices * i and j (0-indexed) such that i != j and swa...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,555
codility
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/SplitArrayLargestSum.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
5,357
kotlab
Apache License 2.0
year2021/day18/part2/src/main/kotlin/com/curtislb/adventofcode/year2021/day18/part2/Year2021Day18Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- You notice a second question on the back of the homework assignment: What is the largest magnitude you can get from adding only two of the snailfish numbers? Note that snailfish addition is not commutative - that is, `x + y` and `y + x `can produce different results. Again considering the last e...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,003
AdventOfCode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxProductTree.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,991
kotlab
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-11.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.filterIn import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2021, "11-input") val...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,471
advent-of-code
MIT License
difference/src/commonMain/kotlin/dev/andrewbailey/diff/impl/MyersDiffAlgorithm.kt
andrewbailey
264,575,064
false
null
package dev.andrewbailey.diff.impl import dev.andrewbailey.diff.impl.MyersDiffOperation.* import kotlin.math.ceil /** * This class implements a variation of Eugene Myers' Diffing Algorithm that uses linear space. This * algorithm has a worst-case runtime of O(M + N + D^2), where N and M are the lengths of [original...
2
Kotlin
1
15
3917a096f61bb26efba601436b49f88e10edcd51
8,155
Difference
MIT License
2021/src/day05/day5.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day05 import java.io.File import kotlin.math.abs fun main() { val input = File("src/day05", "day5_input.txt").readLines() val lines = input.mapNotNull { parseLine(it) } val ventMap = VentMap() lines.filter { isCardinal(it) }.forEach() { ventMap.processLine(it.first, it.second) } ...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
2,126
adventofcode
Apache License 2.0
2021/src/day21/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day21 import java.nio.file.Files import java.nio.file.Paths fun main() { fun part1(input: Input): Int { var rolled = 0 val score = intArrayOf(0, 0) val position = input.map { it - 1 }.toIntArray() var current = 0 while (score.all { it < 1000 }) { var move = 0 repeat(3) { ...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
2,413
advent-of-code
Apache License 2.0
src/2021-Day01.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
fun main() { fun part1(input: List<String>): Int { var increments = 0 var last: Int? = null var next: Int? = null for (line in input) { next = line.trim().toInt() if (last != null && next > last) { increments++ } last =...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
1,519
2022-aoc-kotlin
Apache License 2.0
src/Year2022Day01.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
fun main() { // O(size * log size) -> O(size * log n) -> O(size) fun List<Int>.topN(n: Int): List<Int> { if (this.size == n) return this val x = this.random() val small = this.filter { it < x } val equal = this.filter { it == x } val big = this.filter { it > x } i...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
894
aoc-2022-in-kotlin
Apache License 2.0
src/test/kotlin/days/y2022/Day08Test.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2022 import days.Day import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.core.Is.`is` import org.junit.jupiter.api.Test class Day08 : Day(2022, 8) { override fun partOne(input: String): Any { val grid = parseInput(input) return grid .cells() .co...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
3,683
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Day5.kt
andilau
726,429,411
false
{"Kotlin": 37060}
package days @AdventOfCodePuzzle( name = "If You Give A Seed A Fertilizer", url = "https://adventofcode.com/2023/day/5", date = Date(day = 5, year = 2023) ) class Day5(input: List<String>) : Puzzle { private val seeds = input.first().substringAfter("seeds: ").split(' ').map { it.toLong() } private...
3
Kotlin
0
0
9a1f13a9815ab42d7fd1d9e6048085038d26da90
2,023
advent-of-code-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/pl/mrugacz95/aoc/day14/day14.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day14 import java.lang.RuntimeException sealed class Command data class Mem(val addr: Long, val value: Long) : Command() data class Mask(val mask: String) : Command() fun generateValues(floatingValue: String): Sequence<String> = sequence { when { floatingValue.isEmpty() -> yield(...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
3,096
advent-of-code-2020
Do What The F*ck You Want To Public License
kotlin-practice/src/main/kotlin/exercise/collection/CollectionOperators3.kt
nicolegeorgieva
590,020,790
false
{"Kotlin": 120359}
package exercise.collection fun main() { val employees = listOf( Employee( employeeId = 124, name = "Kayla", department = "HR", salary = 2000.00 ), Employee( employeeId = 125, name = "Lulu", department = "IT...
0
Kotlin
0
1
c96a0234cc467dfaee258bdea8ddc743627e2e20
2,271
kotlin-practice
MIT License
src/main/kotlin/g0801_0900/s0864_shortest_path_to_get_all_keys/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0864_shortest_path_to_get_all_keys // #Hard #Breadth_First_Search #Bit_Manipulation // #2022_03_29_Time_176_ms_(100.00%)_Space_36.3_MB_(100.00%) import java.util.LinkedList import java.util.Queue class Solution { private var m = 0 private var n = 0 fun shortestPathAllKeys(stringGrid: ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,506
LeetCode-in-Kotlin
MIT License
codeforces/globalround7/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.globalround7 fun main() { val n = readInt() val p = readInts().map { it - 1 } val q = readInts().map { it - 1 } val pRev = IntArray(n) for (i in p.indices) pRev[p[i]] = i val st = SegmentsTreeSimple(2 * n) var alive = n val ans = q.map { while (st.getMinBalance() >= 0) st[2 * n - 2 * pRev...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,037
competitions
The Unlicense
src/main/java/challenges/educative_grokking_coding_interview/twe_pointers/_2/SumOfThree.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.twe_pointers._2 import challenges.util.PrintHyphens import java.util.* /** Given an array of integers, nums, and an integer value, target, determine if there are any three integers in nums whose sum is equal to the target, that is, nums[i] + nums[j] + nums[k] ==...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,347
CodingChallenges
Apache License 2.0
src/Day02.kt
timj11dude
572,900,585
false
{"Kotlin": 15953}
fun main() { /** * A , X = Rock * B , Y = Paper * C , Z = Scissors */ fun points(theirs: String, yours: String) = when (theirs) { "A" -> when (yours) { "X" -> 3 "Y" -> 6 "Z" -> 0 else -> throw IllegalArgumentException("Unknown yours va...
0
Kotlin
0
0
28aa4518ea861bd1b60463b23def22e70b1ed481
2,366
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountCharacters.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,841
kotlab
Apache License 2.0
src/Day14.kt
SergeiMikhailovskii
573,781,461
false
{"Kotlin": 32574}
import kotlin.math.max import kotlin.math.min fun main() { class Point( val x: Int, val y: Int ) val initial = 500 val input = readInput("Day14_test") val mapped = input.map { it.split(" -> ").map { val arr = it.split(",") Point(arr[0].toInt(), arr[...
0
Kotlin
0
0
c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d
2,214
advent-of-code-kotlin
Apache License 2.0
app/src/main/kotlin/day02/Day02.kt
tobiasbexelius
437,250,135
false
{"Kotlin": 33606}
package day02 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 2 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay02Part1, ::solveDay02Part2) } fun solveDay02Part1(input: List<String>): Int = ...
0
Kotlin
0
0
3f9783e78e7507eeddde869cf24d34ec6e7e3078
1,431
advent-of-code-21
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2021/Day4.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 4: Giant Squid --- * https://adventofcode.com/2021/day/4 */ class Day4 : Solver { override fun solve(lines: List<String>): Result { val (numbers, boards) = parseData(lines) return Result("${solve(boards, numb...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,855
euler
Apache License 2.0
src/Day13.kt
freszu
573,122,040
false
{"Kotlin": 32507}
import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.* sealed interface Packet : Comparable<Packet> { @JvmInline value class IntValue(val int: Int) : Packet { override fun compareTo(other: Packet): Int = when (other) { is IntValue -> int.compareTo(other.int) ...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
2,923
aoc2022
Apache License 2.0
src/Day02.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
fun main() { val testInput = readInput("Day02_test") check(part1(testInput) == 15) check(part2(testInput) == 12) val input = readInput("Day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.map(::parseLine) .sumOf { (oppone...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
1,055
aoc-22
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2022/Day12.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.XY import com.s13g.aoc.resultFrom /** * --- Day 12: Hill Climbing Algorithm --- * https://adventofcode.com/2022/day/12 */ class Day12 : Solver { override fun solve(lines: List<String>): Result { return resu...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,192
euler
Apache License 2.0
src/main/kotlin/aoc2018/day7/Steps.kt
arnab
75,525,311
false
null
package aoc2018.day7 data class Step(val id: String, val timeToComplete: Int = 0) data class Worker(val id: Int, var currentStep: Step? = null, var secondsSpent: Int = 0) { fun isWorking() = currentStep != null @Synchronized fun assignWork(step: Step?, seconds: Int = 0) { currentStep = step s...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
3,877
adventofcode
MIT License
src/main/kotlin/com/headlessideas/adventofcode/december10/KnotHash.kt
Nandi
113,094,752
false
null
package com.headlessideas.adventofcode.december10 fun main(args: Array<String>) { val input = "147,37,249,1,31,2,226,0,161,71,254,243,183,255,30,70" val knotHash = KnotHash(input) println(knotHash.hash()) } class KnotHash(input: String) { private val seed = input.toCharArray().map { it.toInt() } + li...
0
Kotlin
0
0
2d8f72b785cf53ff374e9322a84c001e525b9ee6
2,064
adventofcode-2017
MIT License
src/Day06.kt
kent10000
573,114,356
false
{"Kotlin": 11288}
fun main() { fun MutableList<Char>.addRemove(char: Char) { this.removeAt(0) this.add(char) } fun CharIterator.nextChars(count: Int): List<Char> { val list = mutableListOf<Char>() for (u in 0 until count) { list.add(this.nextChar()) } return l...
0
Kotlin
0
0
c128d05ab06ecb2cb56206e22988c7ca688886ad
1,387
advent-of-code-2022
Apache License 2.0
parserkt-ext/src/commonMain/kotlin/org/parserkt/pat/ext/NumUnitPattern.kt
ParserKt
242,278,819
false
null
package org.parserkt.pat.ext import org.parserkt.* import org.parserkt.util.* import org.parserkt.pat.* import org.parserkt.pat.complex.PairedTriePattern // File: pat/ext/NumUnitPattern typealias NumUnit<NUM, IN> = Pair<NUM, Iterable<IN>> /* val num = RepeatUn(asInt(), LexicalBasics.digitFor('0'..'9')) { it.toString...
1
Kotlin
0
11
37599098dc9aafef7b509536e6d17ceca370d6cf
2,852
ParserKt
MIT License
src/day04/Day04.kt
Puju2496
576,611,911
false
{"Kotlin": 46156}
package day04 import readInput fun main() { // test if implementation meets criteria from the description, like: val input = readInput("src/day04", "Day04") println("Part1") part1(input) println("Part2") part2(input) } private fun part1(inputs: List<String>) { var sum = 0 inputs.forEa...
0
Kotlin
0
0
e04f89c67f6170441651a1fe2bd1f2448a2cf64e
1,131
advent-of-code-2022
Apache License 2.0
src/Day01.kt
SebastianHelzer
573,026,636
false
{"Kotlin": 27111}
fun main() { fun getTotalCalories(input: List<String>): List<Int> { val indicesOfSpaces = input.mapIndexedNotNull { index, value -> if (value.isBlank()) index else null } + input.lastIndex val calories = indicesOfSpaces.windowed(2, 1) { indices -> input ...
0
Kotlin
0
0
e48757626eb2fb5286fa1c59960acd4582432700
952
advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/day11/Day11.kt
Dr-Horv
112,381,975
false
null
package solutions.day11 import solutions.Solver data class Position(val x: Int, val y: Int) enum class Direction { N, NE, SE, S, SW, NW } fun String.toDirection(): Direction = when(this) { "n" -> Direction.N "ne" -> Direction.NE "se" -> Direction.SE "s" -> Direction.S "sw...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
1,457
Advent-of-Code-2017
MIT License
src/main/kotlin/com/ginsberg/advent2020/Day18.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 18 - Operation Order * Problem Description: http://adventofcode.com/2020/day/18 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day18/ */ package com.ginsberg.advent2020 class Day18(input: List<String>) { private...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
1,796
advent-2020-kotlin
Apache License 2.0
leetcode-75-kotlin/src/main/kotlin/MaximumAverageSubarrayI.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * You are given an integer array nums consisting of n elements, and an integer k. * * Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. * Any answer with a calculation error less than 10-5 will be accepted. * * * * Example 1: * * Input: nums = ...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,136
leetcode-75
Apache License 2.0
src/Day12.kt
MerickBao
572,842,983
false
{"Kotlin": 28200}
import java.util.LinkedList import kotlin.math.min fun main() { fun bfs(grid: Array<CharArray>, sx: Int, sy: Int, ex: Int, ey: Int): Int { var ans = 0 val n = grid.size val m = grid[0].size val seen = Array(n){ BooleanArray(m) } seen[sx][sy] = true val dx = listOf(-1...
0
Kotlin
0
0
70a4a52aa5164f541a8dd544c2e3231436410f4b
2,105
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/de/dikodam/calendar/Day09.kt
dikodam
433,719,746
false
{"Kotlin": 51383}
package de.dikodam.calendar import de.dikodam.AbstractDay import de.dikodam.Coordinates2D import de.dikodam.executeTasks import java.util.* import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { Day09().executeTasks() } class Day09 : AbstractDay() { val input: Map<Coordinates2D, Int> = readInput...
0
Kotlin
0
1
4934242280cebe5f56ca8d7dcf46a43f5f75a2a2
3,175
aoc-2021
MIT License
src/Day08.kt
makohn
571,699,522
false
{"Kotlin": 35992}
fun main() { fun part1(input: List<String>): Int { val grid = input .map { it.chars().map { c -> c - 48 }.toArray() }.toTypedArray() val width = grid[0].size val height = grid.size var visibleTrees = width*2 + height*2 - 4 for (row in 1..< grid.lastIndex) { ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
3,214
aoc-2022
Apache License 2.0
src/main/algorithms/searching/IceCreamParlour.kt
vamsitallapudi
119,534,182
false
{"Java": 24691, "Kotlin": 20452}
package main.algorithms.searching import java.util.* import kotlin.collections.* import kotlin.ranges.* import kotlin.text.* // Complete the whatFlavors function below. fun whatFlavors(menu: Array<Int>, money: Int): Array<Int>? { val sortedMenu = menu.clone() Arrays.sort(sortedMenu) for ( i in 0 until ...
0
Java
1
1
9349fa7488fcabcb9c58ce5852d97996a9c4efd3
1,619
HackerEarth
Apache License 2.0
src/main/kotlin/codes/jakob/aoc/solution/Day10.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
package codes.jakob.aoc.solution import java.util.* object Day10 : Solution() { override fun solvePart1(input: String): Any { return parseInput(input) .mapNotNull { characters: List<Character> -> try { match(characters) null ...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
5,200
advent-of-code-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MergeIntervals.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,861
kotlab
Apache License 2.0
src/Day08.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
fun main() { fun part1(input: List<String>): Int { val treeGrid = fillTreeGrid(input) checkRtl(input, treeGrid) checkLtr(input, treeGrid) checkTtb(input, treeGrid) checkBtt(input, treeGrid) return treeGrid.flatten().count { it } } fun part2(input: List<Stri...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
5,614
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/Day7.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
import java.lang.Integer.max private val exampleInput = """ ${'$'} cd / ${'$'} ls dir a 14848514 b.txt 8504156 c.dat dir d ${'$'} cd a ${'$'} ls dir e 29116 f 2557 g 62596 h.lst ${'$'} cd e ${'$'} ls 584 i ${'$'} cd .. ${'$'} cd .. ${'$'} cd d ...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
4,890
advent_of_code_2022
MIT License
src/main/kotlin/dp/LFBS.kt
yx-z
106,589,674
false
null
package dp import util.* // find the length of the longest CONTIGUOUS SUBSTRING that appears both // forward and backward in T[1..n] fun main(args: Array<String>) { val Ts = arrayOf( "ALGORITHM", // 0 "RECURSION", // "R ... R" -> 1 "REDIVIDE", // "EDI ... IDE" -> 3 "DYNAMICPROGRAMMINGMANYTIMES" // "YNAM ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,244
AlgoKt
MIT License
src/main/kotlin/g0701_0800/s0787_cheapest_flights_within_k_stops/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0787_cheapest_flights_within_k_stops // #Medium #Dynamic_Programming #Depth_First_Search #Breadth_First_Search #Heap_Priority_Queue // #Graph #Shortest_Path #2023_03_13_Time_185_ms_(99.20%)_Space_36.6_MB_(89.64%) class Solution { fun findCheapestPrice(n: Int, flights: Array<IntArray>, src: Int...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,744
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Day04.kt
joostbaas
573,096,671
false
{"Kotlin": 45397}
typealias AssignedSections = IntRange fun readIntoPairOfSectionAssignments(line: String): Pair<AssignedSections, AssignedSections> { val (first, second) = line.split(',').map { range -> val (begin, end) = range.split('-').map { it.toInt() } (begin..end) } return first to second } fun Pair<...
0
Kotlin
0
0
8d4e3c87f6f2e34002b6dbc89c377f5a0860f571
1,006
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day12.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day12 : Solvable("12") { override fun solveA(input: List<String>): String { return countWays(getMap(input), setOf("start"), "start").toString() } override fun solveB(input: List<String>): String { return countWaysDouble(getMap(input), setOf("start"), false, "start").toString() } ...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,735
AdventOfCode
Creative Commons Zero v1.0 Universal
src/day02/Day02.kt
sophiepoole
573,708,897
false
null
package day02 import readInput fun main() { // A/X = 1 = Rock // B/Y = 2 = Paper // C/Z = 3 = Scissors // 0 loss(X) 3 draw(Y) 6 for win(Z) fun part1GetScore(round: Pair<Char, Char>) = when (round) { 'A' to 'X' -> 4 'A' to 'Y' -> 8 'A' to 'Z' -> 3 ...
0
Kotlin
0
0
00ad7d82cfcac2cb8a902b310f01a6eedba985eb
1,409
advent-of-code-2022
Apache License 2.0
src/Day11.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
private const val OLD = -1 fun main() { val dayId = "11" val input = readInput("Day${dayId}") class R(var r: IntArray) class Monkey( val its: ArrayList<R>, val oc: Char, val z: Int, val d: Int, val tt: Int, val tf: Int ) { var cnt: Int = 0 ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
2,013
aoc-2022
Apache License 2.0
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day10.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 import com.akikanellis.adventofcode.year2022.utils.Point object Day10 { fun sumOfSignalStrengths(input: String): Int { val cyclesOfInterest = IntProgression.fromClosedRange(20, 220, 40) return systemSnapshots(input) .filter { cyclesOfInter...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
3,919
advent-of-code
MIT License
src/main/kotlin/com/groundsfam/advent/y2023/d10/Day10.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d10 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.Direction import com.groundsfam.advent.Direction.DOWN import com.groundsfam.advent.Direction.LEFT import com.groundsfam.advent.Direction.RIGHT import com.groundsfam.advent.Direction.UP import com.groundsfam.adven...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,827
advent-of-code
MIT License
src/main/kotlin/Day17.kt
Yeah69
317,335,309
false
{"Kotlin": 73241}
class Day17 : Day() { override val label: String get() = "17" private data class Quadruple(val x: Int, val y: Int, val z: Int, val w: Int) private fun <T> initialState(factory: (Int, Int) -> T) = input .lineSequence() .flatMapIndexed { y, line -> line .asSequence() ...
0
Kotlin
0
0
23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec
2,037
AdventOfCodeKotlin
The Unlicense
src/day05/Day05.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day05 import readText import java.util.* fun main() { fun getCrateStacks(input: List<String>): MutableList<Stack<Char>> { var crates = input[0].split("\n") val numStacks = crates.last().last() val stacks = MutableList<Stack<Char>>(numStacks.digitToInt()) { Stack() } crates ...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,731
aoc2022
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2021/Day5.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver import kotlin.math.sign /** * --- Day 5: Hydrothermal Venture --- * https://adventofcode.com/2021/day/5 */ class Day5 : Solver { override fun solve(lines: List<String>): Result { val regex = """([0-9]+),([0-9]+) -> ([0-9]+),([...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,208
euler
Apache License 2.0
src/year2022/day03/Day03.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day03 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day03_test") check(part1(testInput), 157) check(part2(testInput), 70) val input = readInput("2022", "Day03") println(part1(...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,260
AdventOfCode
Apache License 2.0
src/Day03.kt
wbars
576,906,839
false
{"Kotlin": 32565}
val alphabet = (('a'..'z') + ('A' .. 'Z')).toList() fun main() { fun duplicates(first: String, second: String) = (first.indices) .filter { second.indexOf(first[it]) >= 0 } .map { first[it] } fun priority(element: Char) = alphabet.indexOf(element) + 1 fun...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
949
advent-of-code-2022
Apache License 2.0
src/Day08.kt
askeron
572,955,924
false
{"Kotlin": 24616}
import kotlin.math.max typealias PointMap = Map<Point, Int> class Day08 : Day<Int>(21, 8, 1779, 172224) { private fun parseInput(input: List<String>): PointMap { return input.IntMatrixToPointMap() } override fun part1(input: List<String>): Int { return parseInput(input).let { pointMap -> ...
0
Kotlin
0
1
6c7cf9cf12404b8451745c1e5b2f1827264dc3b8
1,285
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
daniyarmukhanov
572,847,967
false
{"Kotlin": 9474}
fun main() { fun part1(inputStack: Array<String>, input: List<String>): String { input.forEachIndexed { index, line -> val digits = line.split(" ").mapNotNull { it.toIntOrNull() } val size = digits[0] val from = digits[1] - 1 val to = digits[2] - 1 ...
0
Kotlin
0
0
ebad16b2809ef0e3c7034d5eed75e6a8ea34c854
2,185
aoc22
Apache License 2.0
src/main/kotlin/day05/Day05.kt
Malo-T
575,370,082
false
null
package day05 import day05.Day05.Step private typealias Stack = MutableList<Char> private typealias Storage = MutableList<Stack> private const val EMPTY = ' ' private fun List<String>.indexOfStackNumbers() = indexOfFirst { it.startsWith(" 1") } private val stepRegex = """move (\d+) from (\d+) to (\d+)""".toRegex()...
0
Kotlin
0
0
f4edefa30c568716e71a5379d0a02b0275199963
2,986
AoC-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinFlips.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,776
kotlab
Apache License 2.0
src/Day14.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import Material.* import java.awt.Point import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { val cave = Cave.parse(input) // .also { println(it) } val sandSource = Point(500, 0) var steps = 0 while (cave.pourSand(sandSource)) { steps++ } return steps } ...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
4,638
aoc2022
Apache License 2.0
kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/combinations.kt
xiaodongw
247,462,184
true
{"Kotlin": 2089944, "HTML": 423, "Java": 153}
package io.kotest.property.arbitrary import io.kotest.property.Gen import io.kotest.property.RandomSource import io.kotest.property.Sample /** * Returns a stream of values based on weights: * * Arb.choose(1 to 'A', 2 to 'B') will generate 'A' 33% of the time * and 'B' 66% of the time. * * @throws IllegalArgumen...
1
Kotlin
0
0
f14814a8d8d3ade611b8b004219ba6b3dd9cf979
2,036
kotest
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2020/d24/Day24.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d24 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.points.Point import kotlin.io.path.div import kotlin.io.path.useLines enum class Direction { W, NW, NE, E, SE, SW } // convention for this problem: // going NE changes only Y coord, wh...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,623
advent-of-code
MIT License
src/main/java/challenges/educative_grokking_coding_interview/k_way_merge/_2/KSmallestNumber.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.k_way_merge._2 import java.util.* /** You are given an m number of sorted lists in ascending order and an integer, k, find the kth smallest number among all the given lists. Although there can be repeating values in the lists, each element is considered unique an...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,764
CodingChallenges
Apache License 2.0
src/day20/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day20 import java.io.File import kotlin.math.abs val workingDir = "src/${object {}.javaClass.`package`.name}" fun main() { val sample = File("$workingDir/sample.txt") val input1 = File("$workingDir/input_1.txt") println("Step 1a: ${runStep1(sample)}") // 3 println("Step 1b: ${runStep1(input1)...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
5,415
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day20.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day20 : Day(20) { override fun partOne(): Any { val numbers = parseNumbers() mixNumbers(numbers) return generateSequence(numbers.find { it.value == 0L }) { it.next }.take(numbers.size).map { it.value }.toList() .let { it[1000 % numbers.size] + it[2000 % number...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
2,327
aoc-2022
Creative Commons Zero v1.0 Universal
src/questions/DailyTemperatures.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * Given an array of integers `temperatures` represents the daily temperatures, return an array answer * such that `answer[i]` is the number of days you have to wait after the `ith` day to get a warmer temperature...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,825
algorithms
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2022/Dec21.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2022 import org.elwaxoro.advent.PuzzleDayTester import java.lang.IllegalStateException /** * Day 21: Monkey Math */ class Dec21 : PuzzleDayTester(21, 2022) { /** * Root monkey shout. Computer monkey type that into AOC */ override fun part1(): Any = loader().solveForRo...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
3,337
advent-of-code
MIT License
src/year_2022/day_22/Day22.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_22 import readInput import util.* import kotlin.IllegalArgumentException import kotlin.math.abs typealias BoardPositions = Map<Point, Boolean> sealed class Movement { data class Move(val steps: Int): Movement() data class Turn(val direction: TurnDirection): Movement() } enum class Turn...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
14,944
advent_of_code
Apache License 2.0
src/main/kotlin/adventofcode/y2021/Day12.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.* fun main() { val testInput = """ start-A start-b A-c A-b b-d A-end b-end """.trimIndent() runDay( day = Day12::class, testInput = testInput, testAnswer1 = 10, testAnswer2 = 36 ) } open class D...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
1,577
adventofcode2021
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountPaths.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
4,337
kotlab
Apache License 2.0
kotlin/2021/qualification-round/moons-and-umbrellas/src/main/kotlin/CumbersomeAndFlawedSolution.kts
ShreckYe
345,946,821
false
null
fun main() { val t = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val lineInputs = readLine()!!.split(' ') val x = lineInputs[0].toInt() val y = lineInputs[1].toInt() val s = lineInputs[2] val numStartingEmptySpaces = s.asSequence().takeWhile { it == '?' }.count() ...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
3,719
google-code-jam
MIT License
src/main/kotlin/de/igorakkerman/challenge/maxtableprod/MaxTableProd.kt
igorakkerman
187,291,299
false
null
package de.igorakkerman.challenge.maxtableprod import java.lang.Integer.max class MaxTableProd(val prodSize: Int, numbersTable: String) { val numbers: List<List<Int>> val width: Int val height: Int init { numbers = numbersTable .lines() .map { it.trim() } ...
0
Kotlin
0
0
c8d705f5d1856e8b9bf93d69984dc61eb9864fa6
2,394
maxtableprod-challenge
MIT License
kotlin/src/katas/kotlin/leetcode/subtree_with_max_average/SubtreeWithMaxAverage.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.subtree_with_max_average import datsok.shouldEqual import org.junit.Test import java.util.* class SubtreeWithMaxAverageTests { @Test fun example() { val tree = NTreeNode(20, NTreeNode(12, NTreeNode(11), NTreeNode(2), NTreeNode(3)), NTreeNode(18, NTreeN...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,433
katas
The Unlicense
codeforces/round633/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round633 fun main() { val n = readInt() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (u, v) = readInts().map { it - 1 } nei[u].add(v); nei[v].add(u) } val canTake = IntArray(n) { 1 } val cannotTake = IntArray(n) val canTakeAnswer = IntArray(n) { 1 } val cannotTakeAnswer...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,133
competitions
The Unlicense
src/main/kotlin/dev/bogwalk/batch5/Problem55.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.strings.isPalindrome /** * Problem 55: Lychrel Numbers * * https://projecteuler.net/problem=55 * * Goal: Given N, find the palindrome to which the maximum positive numbers <= N converge if * non-Lychrel and return both the palindrome and the maxCount. * * Con...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
6,064
project-euler-kotlin
MIT License
src/main/kotlin/com/tonnoz/adventofcode23/day8/EightTwo.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day8 import com.tonnoz.adventofcode23.utils.readInput object EightTwo { @JvmStatic fun main(args: Array<String>) { val input = "inputEight.txt".readInput() problemTwo(input) } private fun problemTwo(input: List<String>) { val time = System.currentTimeMillis() ...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,499
adventofcode23
MIT License
src/main/kotlin/day5/Day05.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day5 fun solveA(input: List<String>): String { val stacks = input.filterStackLines().parseToStack() input.filterOperationLines().parseOperations().runOperations(stacks, oneByOne = true) return stacks.getTopValues() } fun solveB(input: List<String>): String { val stacks = input.filterStackL...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
4,604
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/KthLargestValue.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 1738. 找出第 K 大的异或坐标值 *给你一个二维矩阵 matrix 和一个整数 k ,矩阵大小为 m x n 由非负整数组成。 * * 矩阵中坐标 (a, b) 的 值 可由对所有满足 0 <= i <= a < m 且 0 <= j <= b < n 的元素 matrix[i][j](下标从 0 开始计数)执行异或运算得到。 * * 请你找出 matrix 的所有坐标中第 k 大的值(k 的值从 1 开始计数)。 */ class KthLargestValue { companion object { ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,628
daily_algorithm
Apache License 2.0
src/day01/Day01.kt
KirkB1693
573,133,220
false
{"Kotlin": 8203}
package day01 import data.Elf import readInput fun main() { fun getElvesFromInput(input: List<String>): ArrayList<Elf> { val elfList = ArrayList<Elf>() var tempElf: Elf? = null input.forEach { calorieValue -> if (calorieValue.isNotEmpty()) { if (tempElf == null)...
0
Kotlin
0
0
c9610a76d15fdb96db5b3555a6d6d4b5c3e687f0
1,915
Advent_of_code_2022
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day21/Day21.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * 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 wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,226
AdventOfCode
Apache License 2.0
src/day03/Day03.kt
chskela
574,228,146
false
{"Kotlin": 9406}
package day03 import java.io.File fun main() { fun Char.getPriorities(): Int = when { isLowerCase() -> code - 96 isUpperCase() -> code - 38 else -> 0 } fun parseInput(input: String) = input.lines() fun part1(input: String): Int { val data = parseInput(input) ...
0
Kotlin
0
0
951d38a894dcf0109fd0847eef9ff3ed3293fca0
1,309
adventofcode-2022-kotlin
Apache License 2.0
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day05.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 /** * https://adventofcode.com/2022/day/5 */ class Day05(override val input: String) : Day() { private val inputStacks: Map<Int, List<Char>> = run { input.split("\n\n")[0].let { initialStacksInput -> val stackLabels = initialStacksInput.trim().lines().last() ...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
2,161
adventofcode2022
MIT License
src/main/kotlin/g1601_1700/s1631_path_with_minimum_effort/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1601_1700.s1631_path_with_minimum_effort // #Medium #Array #Depth_First_Search #Breadth_First_Search #Binary_Search #Matrix // #Heap_Priority_Queue #Union_Find #2023_06_17_Time_384_ms_(100.00%)_Space_39.5_MB_(100.00%) import java.util.PriorityQueue import kotlin.math.abs class Solution { private class P...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,818
LeetCode-in-Kotlin
MIT License
src/main/kotlin/offer/40.kt
Eynnzerr
621,254,277
false
null
package offer import java.util.PriorityQueue class Solution40 { // 方法1. 简单排序 fun getLeastNumbers1(arr: IntArray, k: Int) = arr.sorted().slice(0 until k).toIntArray() // 方法2. 优先队列(大根堆) 维护一个k大小的大根堆 fun getLeastNumbers2(arr: IntArray, k: Int): IntArray { // k <= arr.size if (k <= 0) ret...
0
Kotlin
0
0
0327df84200444e1e4ef4b7d7a9f8779e8d7443f
1,672
leetcode-kotlin
MIT License