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/jacobhyphenated/advent2022/day2/Day2.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day2 import com.jacobhyphenated.advent2022.Day /** * Day 2: Rock Paper Scissors * * To cheat at a tournament of paper, rock, scissors, you have a puzzle input of two columns. * The first column consists of "A" = Rock, "B" = Paper, and "C" = Scissors * * Each round is score...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
3,783
advent2022
The Unlicense
src/main/kotlin/dev/bogwalk/batch3/Problem33.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.combinatorics.combinations import dev.bogwalk.util.combinatorics.product import kotlin.math.pow import dev.bogwalk.util.maths.gcd /** * Problem 33: Digit Cancelling Fractions * * https://projecteuler.net/problem=33 * * Goal: Find every non-trivial fraction where...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
10,812
project-euler-kotlin
MIT License
aoc2023/day3.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day3.execute() } private object Day3 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<String>): Int { val numbers =...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
5,263
Advent-Of-Code
MIT License
src/Day10.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val needSave = setOf(20, 60, 100, 140, 180, 220) var x = 1 var cyc = 0 return input.sumOf { s -> var ret = 0 if(s.contains("noop")) { cyc++ if (needSave....
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,100
aoc2022
Apache License 2.0
src/Day04.kt
alex-rieger
573,375,246
false
null
import org.w3c.dom.ranges.Range fun main() { fun toIntRange(inputs: String): IntRange { val (start, end) = inputs.split('-') return start.toInt()..end.toInt() } fun isFullyContained(left: IntRange, right: IntRange): Boolean { return (left.min() >= right.min() && left.max() <= right...
0
Kotlin
0
0
77de0265ff76160e7ea49c9b9d31caa1cd966a46
1,318
aoc-2022-kt
Apache License 2.0
src/main/kotlin/g2201_2300/s2281_sum_of_total_strength_of_wizards/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2281_sum_of_total_strength_of_wizards // #Hard #Array #Stack #Prefix_Sum #Monotonic_Stack // #2023_06_28_Time_673_ms_(100.00%)_Space_58.2_MB_(100.00%) import java.util.Deque import java.util.LinkedList @Suppress("kotlin:S107") class Solution { fun totalStrength(nums: IntArray): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,449
LeetCode-in-Kotlin
MIT License
src/main/kotlin/twentytwentytwo/Day23.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import kotlin.math.abs typealias Elve = Pair<Int, Int> fun main() { val input = {}.javaClass.getResource("input-23.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val tinput = {}.javaClass.getResource("input-23-1.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val day ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
4,410
aoc202xkotlin
The Unlicense
src/main/kotlin/aoc22/Day15.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import aoc22.Day15Domain.Sensor import aoc22.Day15Parser.toSensors import aoc22.Day15RunnerPart1.part1Day15 import aoc22.Day15RunnerPart2.part2Day15 import common.Space2D.Point import common.Space2D.Parser.toPoint import common.Year22 import kotlin.math.absoluteValue object Day15: Year22 { fun List<...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
3,460
aoc
Apache License 2.0
src/main/kotlin/final_450/arrays/kthSmallOrLargeElement.kt
ch8n
312,467,034
false
null
package final_450.arrays fun main() { // Given an array arr[] and a number K where K is smaller // than size of array, the task is to find the Kth smallest // element in the given array. // It is given that all array elements are distinct. /** * * N = 6 arr[] = 7 10 4 3 20 15 K = 3 Output : 7...
3
Kotlin
0
1
e0619ebae131a500cacfacb7523fea5a9e44733d
2,215
Big-Brain-Kotlin
Apache License 2.0
src/Day07.kt
MisterTeatime
561,848,263
false
{"Kotlin": 20300}
fun main() { fun part1(input: List<String>): Int { return calculate(input.map { Relation.create(it) }.filterNot { it.Command == Mnemonic.NOP }, mutableMapOf(), "a") } fun part2(input: List<String>): Int { return calculate(input.map { Relation.create(it) }.filterNot { it.Command == Mnemonic....
0
Kotlin
0
0
d684bd252a9c6e93106bdd8b6f95a45c9924aed6
3,927
AoC2015
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2022/Day24.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 24 - Blizzard Basin * Problem Description: http://adventofcode.com/2022/day/24 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day24/ */ package com.ginsberg.advent2022 class Day24(input: List<String>) { private ...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
4,478
advent-2022-kotlin
Apache License 2.0
src/main/kotlin/days/aoc2021/Day13.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day class Day13 : Day(2021, 13) { override fun partOne(): Any { return calculateDotsAfterFirstFold(inputList) } override fun partTwo(): Any { return calculateDotsAfterFolds(inputList) } fun calculateDotsAfterFirstFold(inputList: List<String>): Int...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,065
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day03.kt
gsalinaslopez
572,839,981
false
{"Kotlin": 21439}
fun main() { fun getRucksackIntersection(rucksack: List<String>): Int = rucksack .map { it.toSet() } .reduce { acc, chars -> acc.intersect(chars) } .first().code.let { if (it <= 90) { it - 38 } else { it - 96 } } ...
0
Kotlin
0
0
041c7c3716bfdfdf4cc89975937fa297ea061830
868
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day07.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 import com.dvdmunckhof.aoc.splitOnce import java.util.regex.Pattern import kotlin.streams.asSequence class Day07(private val input: List<String>) { fun solvePart1(bag: String): Int { val bagMap = mutableMapOf<String, MutableList<String>>() for (rule in input...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,630
advent-of-code
Apache License 2.0
src/main/kotlin/leetcode/Problem2039.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import java.lang.Integer.max import java.util.* /** * https://leetcode.com/problems/the-time-when-the-network-becomes-idle/ */ class Problem2039 { fun networkBecomesIdle(edges: Array<IntArray>, patience: IntArray): Int { val adjList = buildAdjList(edges) val queue = LinkedList<I...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,837
leetcode
MIT License
leetcode/src/daily/Q921.kt
zhangweizhe
387,808,774
false
null
package daily import java.util.* fun main() { // 921. 使括号有效的最少添加 // https://leetcode.cn/problems/minimum-add-to-make-parentheses-valid/ println(minAddToMakeValid1("()))((")) } fun minAddToMakeValid(s: String): Int { val stack = Stack<Char>() for (c in s) { if (c == ')') { val ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,367
kotlin-study
MIT License
src/main/kotlin/com/ginsberg/advent2017/Day20.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 import kotlin.math.absoluteValue /** * AoC 2017, Day 20 * * Problem Description: http://adventofcode.com/2017/day/20 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day20/ */ class Day20(input: List<String>) { ...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
1,971
advent-2017-kotlin
MIT License
src/main/kotlin/com/sk/todo-revise/123. Best Time to Buy and Sell Stock III.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.`todo-revise` class Solution123 { fun maxProfit(prices: IntArray): Int { var ans = 0 for (i in 0 until prices.size) { var max1 = 0 var profit1 = 0 for (k in i downTo 0) { max1 = maxOf(max1, prices[k]) profit1 = maxOf...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,436
leetcode-kotlin
Apache License 2.0
src/Day01.kt
stevennoto
573,247,572
false
{"Kotlin": 18058}
fun main() { fun part1(input: List<String>): Int { // Split into groups separated by 2 newlines. Sum each group and keep max. return input.joinToString("\n") .split("\n\n") .maxOf { it.split("\n").sumOf { it.toInt() } } } fun part2(input: List<String>): Int { ...
0
Kotlin
0
0
42941fc84d50b75f9e3952bb40d17d4145a3036b
867
adventofcode2022
Apache License 2.0
src/Day24.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
import java.util.* import kotlin.math.abs typealias Location = Pair<Int, Int> private operator fun Location.plus(offset: Pair<Int, Int>): Location { return Location(this.first + offset.first, this.second + offset.second) } private fun Location.distanceFrom(another: Location): Int { return abs(this.first - an...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
6,721
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1402/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1402 /** * LeetCode page: [1402. Reducing Dishes](https://leetcode.com/problems/reducing-dishes/); */ class Solution2 { /* Complexity: * Time O(N^2) and Space O(N) where N is the size of satisfaction; */ fun maxSatisfaction(satisfaction: IntArray): Int { ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,690
hj-leetcode-kotlin
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[40]组合总和 II.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.collections.ArrayList //给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 // // candidates 中的每个数字在每个组合中只能使用一次。 // // 说明: // // // 所有数字(包括目标数)都是正整数。 // 解集不能包含重复的组合。 // // // 示例 1: // // 输入: candidates = [10,1,2,7,6,1,5], target = 8, //所求解集为: //[ // [1, 7], //...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,291
MyLeetCode
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/CountAndSay.kt
faniabdullah
382,893,751
false
null
//The count-and-say sequence is a sequence of digit strings defined by the //recursive formula: // // // countAndSay(1) = "1" // countAndSay(n) is the way you would "say" the digit string from countAndSay( //n-1), which is then converted into a different digit string. // // // To determine how you "say" a digit st...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,769
dsa-kotlin
MIT License
src/Day02.kt
arisaksen
573,116,584
false
{"Kotlin": 42887}
import Outcome.* import org.assertj.core.api.Assertions.assertThat enum class Opponent(val char: Char) { ROCK('A'), PAPER('B'), SCISSORS('C') } enum class Response(val char: Char) { ROCK('X'), PAPER('Y'), SCISSORS('Z') } enum class Outcome { LOSE, DRAW, WIN } val responseScore: Map<Response, Int> = mapOf(Response.ROC...
0
Kotlin
0
0
85da7e06b3355f2aa92847280c6cb334578c2463
4,178
aoc-2022-kotlin
Apache License 2.0
src/test/kotlin/chapter2/solutions/ex2/listing.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter2.solutions.ex2 import io.kotest.core.spec.style.WordSpec import io.kotest.matchers.shouldBe import kotlinx.collections.immutable.persistentListOf // tag::init[] val <T> List<T>.tail: List<T> get() = drop(1) val <T> List<T>.head: T get() = first() fun <A> isSorted(aa: List<A>, order: (A, A) -...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
1,774
fp-kotlin
MIT License
src/main/kotlin/me/consuegra/algorithms/KSearchInsertPosition.kt
aconsuegra
91,884,046
false
{"Java": 113554, "Kotlin": 79568}
package me.consuegra.algorithms /** * Given a sorted array and a target value, return the index if the target is found. If not, return the index * where it would be if it were inserted in order. * <p> * You may assume no duplicates in the array. * <p> * Here are few examples. * [1,3,5,6], 5 → 2 * [1,3,5,6], 2 ...
0
Java
0
7
7be2cbb64fe52c9990b209cae21859e54f16171b
1,452
algorithms-playground
MIT License
21/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File import java.util.Collections.max import java.util.Collections.min fun readInput() : Game { val input = File("input.txt") .readLines() val posRegex = """Player (\d+) starting position: (\d+)""".toRegex() val (_, player1Pos) = posRegex.find(input[0])?.destructured!! val (_, ...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,011
advent-of-code-2021
MIT License
kotlin/2022/day03/Day03.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
class Day03 { fun part1(input: Iterable<String>): Int { val result = input .asSequence() .filter { !it.isBlank() } .map { it.toCharArray() } .map { val half = it.size / 2 Pair(it.sliceArray(0 until half), it.sliceArray(half until it.size)) } .map { it.fi...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
1,148
adventofcode
MIT License
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day12/Day12.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2020.day12 import eu.janvdb.aocutil.kotlin.point2d.Direction import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines val INSTRUCTION_REGEX = Regex("([NSEWLRF])(\\d+)") fun main() { val instructions = readLines(2020, "input12.txt").map(::parseInstruction) var ...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,670
advent-of-code
Apache License 2.0
src/main/kotlin/g0401_0500/s0474_ones_and_zeroes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0401_0500.s0474_ones_and_zeroes // #Medium #Array #String #Dynamic_Programming // #2022_12_31_Time_204_ms_(100.00%)_Space_35.7_MB_(92.31%) class Solution { /* * The problem can be interpreted as: * What's the max number of str can we pick from strs with limitation of m "0"s and n "1"s. * ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,296
LeetCode-in-Kotlin
MIT License
2023/src/main/kotlin/de/skyrising/aoc2023/day17/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day17 import de.skyrising.aoc.* import kotlin.math.absoluteValue data class Node(val posX: Int, val posY: Int, val dir: Direction, val dirCount: Int) private inline fun IntGrid.getOutgoing(node: Node): Collection<Edge<Node, Unit?>> { val edges = ArrayList<Edge<Node, Unit?>>(3) fo...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,980
aoc
MIT License
src/main/kotlin/g2801_2900/s2846_minimum_edge_weight_equilibrium_queries_in_a_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2846_minimum_edge_weight_equilibrium_queries_in_a_tree // #Hard #Array #Tree #Graph #Strongly_Connected_Component // #2023_12_18_Time_982_ms_(100.00%)_Space_72.6_MB_(66.67%) import kotlin.math.ln import kotlin.math.max @Suppress("kotlin:S107") class Solution { private class Node(var v: Int, v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
4,617
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day6.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
fun day6 (lines: List<String>) { val races = parseRaces(lines) var part1 = 1L races.forEach { part1 *= getWaysToWin(it) } val longRace = parseRace(lines) val part2 = getWaysToWin(longRace) println("Day 6 part 1: $part1") println("Day 6 part 2: $part2") printl...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
1,361
advent_of_code_2023
MIT License
src/Day04.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
fun main() { fun String.range(): IntRange { val (start, end) = split("-") return IntRange(start.toInt(), end.toInt()) } fun String.rangePair(): Pair<IntRange, IntRange> { val (first, second) = split(",") return Pair(first.range(), second.range()) } fun IntRange.con...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
962
aoc-2022
Apache License 2.0
app/src/main/kotlin/solution/Solution907.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode import java.util.PriorityQueue import kotlin.math.pow class Solution907 { @Leetcode(907) class Solution { fun sumSubarrayMins(arr: IntArray): Int { // monotonic stack + dp var total = 0L val N = arr.size ...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
3,027
leetcode-kotlin
MIT License
pracexam1problem3/TwoStringMasks.kt
laitingsheng
341,616,623
false
null
class TwoStringMasks { private val IMPOSSIBLE: String = "impossible" private fun String.trim(b: Int): String { var i = b while (this[i] != '*') ++i return removeRange(i, i + 1) } private fun String.combine(b1: Int, e1: Int, other: String, b2: Int, e2: Int): String {...
0
Kotlin
0
0
2fc3e7a23d37d5e81cdf19a9ea19901b25941a49
1,605
2020S1-COMP-SCI-7007
ISC License
2021/src/day11/Day11.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day11 import readInput fun flash(list: Array<IntArray>, x: Int, y: Int) { if (x < 0 || y < 0 || y >= list.size || x >= list[y].size) { return } val current = list[y][x] list[y][x] += 1 if (current == 9) { for (i in -1..1) { for (j in -1..1) { if...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,418
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestAlternatingPaths.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,441
kotlab
Apache License 2.0
src/aoc2022/Day21.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.checkEquals object Day21 { fun List<String>.graphYelling(): HashMap<String, String> { val map = hashMapOf<String, String>() this.forEach { val (name, yell) = it.split(": ") map[name] = yell } return map } fun HashMap<St...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,507
Kotlin-AOC-2023
Apache License 2.0
test/leetcode/SumOfDigitsOfStringAfterConvert.kt
andrej-dyck
340,964,799
false
null
package leetcode import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.CsvSource /** * https://leetcode.com/problems/sum-of-digits-of-string-after-convert/ * * 1945. Sum of Digits of String After Convert * [Easy] * * You are ...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
3,749
coding-challenges
MIT License
src/Day10.kt
arnoutvw
572,860,930
false
{"Kotlin": 33036}
import java.util.LinkedList import kotlin.math.abs fun main() { fun checkCycle(cycle: Int) :Boolean { return cycle == 20 || cycle == 60 || cycle == 100 || cycle == 140 || cycle == 180 || cycle == 220 } fun part1(input: List<String>): Int { var cycle = 0 var x = 1 var sum =...
0
Kotlin
0
0
0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4
1,693
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/eric/leetcode/FindTheShortestSuperstring.kt
wanglikun7342
163,727,208
false
{"Kotlin": 172132, "Java": 27019}
package com.eric.leetcode class FindTheShortestSuperstring { fun shortestSuperstring(A: Array<String>): String { val list = A.toMutableList() while (list.size > 1) { var x = 0 var y = 1 for (iv in list.withIndex()) { for (index in iv.index + 1..li...
0
Kotlin
2
8
d7fb5ff5a0a64d9ce0a5ecaed34c0400e7c2c89c
2,286
Leetcode-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SingleThreadedCPU.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,905
kotlab
Apache License 2.0
src/year2023/day10/Day10.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day10 import check import readInput fun main() { val testInput1 = readInput("2023", "Day10_test_part1") val testInput2 = readInput("2023", "Day10_test_part2") check(part1(testInput1), 8) check(part2(testInput2), 8) val input = readInput("2023", "Day10") println(part1(input)) ...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
6,531
AdventOfCode
Apache License 2.0
src/Day10.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
fun main() { fun part1(input: List<String>): Int { val cpu = Cpu() cpu.executeInstructions(input) return cpu.signalStrengthMap.values.sum() } fun part2(input: List<String>): String { val cpu = Cpu() cpu.executeInstructions(input) return cpu.getSprite() ...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
2,297
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kr/co/programmers/P92335.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers import java.math.BigInteger // https://github.com/antop-dev/algorithm/issues/403 class P92335 { companion object { val TEEN: BigInteger = BigInteger("10") } fun solution(n: Int, k: Int): Int { var answer = 0 val kNumber = decimalToK(n, k) + "0" // n.toSt...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,582
algorithm
MIT License
src/main/kotlin/com/ginsberg/advent2018/Day17.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 17 - Reservoir Research * * Problem Description: http://adventofcode.com/2018/day/17 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day17/ */ package com.ginsberg.advent2018 class Day17(rawInput: List<String>) { ...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
3,837
advent-2018-kotlin
MIT License
src/Day04.kt
khongi
572,983,386
false
{"Kotlin": 24901}
fun main() { fun String.getRange(): IntRange { val (start, end) = split('-').map { it.toInt() } return start..end } fun part1(input: List<String>): Int { return input.count { line -> val (first, second) = line.split(',').map { it.getRange() } val intersect = ...
0
Kotlin
0
0
9cc11bac157959f7934b031a941566d0daccdfbf
896
adventofcode2022
Apache License 2.0
src/Day11.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
import java.math.BigInteger fun main() { class Monkey { val items = ArrayDeque<Long>() var operation: (Long, Long) -> Long = { item, _ -> item } var targetTrue: Int = -1 var targetFalse: Int = -1 var inspections = BigInteger.valueOf(0) var divider = 1L override fun toString(): String = "Monkey(items=$i...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
3,118
advent-of-code-2022
Apache License 2.0
aoc2022/day5.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval import java.util.ArrayDeque fun main() { Day5.execute() } object Day5 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: Pair<List<ArrayDeque<Ch...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
2,214
Advent-Of-Code
MIT License
src/Day01.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
fun main() { fun part1(input: List<String>): Int { var max_somme = 0 var somme = 0 input.forEach { if (it != "") { somme += it.toInt() } else { max_somme = if (somme > max_somme) somme else max_somme somme = 0 ...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
1,103
AD2022-01
Apache License 2.0
src/main/kotlin/days/Day3.kt
jgrgt
575,475,683
false
{"Kotlin": 94368}
package days class Day3 : Day(3) { override fun partOne(): Any { return inputList.map { Day3Util.splitString(it) } .map { Day3Util.overlappingChars(it.first, it.second) } .sumOf { chars -> chars.sumOf { Day3Util.letterToScore(it) } } } override fun partTwo(): Any { ...
0
Kotlin
0
0
5174262b5a9fc0ee4c1da9f8fca6fb86860188f4
1,402
aoc2022
Creative Commons Zero v1.0 Universal
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_14_Longest_Common_Prefix.kt
v43d3rm4k4r
515,553,024
false
{"Kotlin": 40113, "Java": 25728}
package leetcode.solutions.concrete.kotlin import leetcode.solutions.* import leetcode.solutions.ProblemDifficulty.* import leetcode.solutions.validation.SolutionValidator.* import leetcode.solutions.annotations.ProblemInputData import leetcode.solutions.annotations.ProblemSolution /** * __Problem:__ Write a functio...
0
Kotlin
0
1
c5a7e389c943c85a90594315ff99e4aef87bff65
2,626
LeetcodeSolutions
Apache License 2.0
codes/src/test/kotlin/katas/nakulgupta18/consecutive_strings.kt
cheroliv
522,283,474
false
{"Kotlin": 82456, "CSS": 52294, "TypeScript": 22466, "FreeMarker": 21485, "JavaScript": 12573, "Astro": 7822, "Groovy": 7785, "Java": 5477, "HTML": 5302, "Python": 3261, "SCSS": 1101, "Gherkin": 919, "Shell": 240}
package katas.nakulgupta18 import katas.nakulgupta18.LongestConsecLog.log import org.slf4j.LoggerFactory.getLogger import kotlin.test.Test import kotlin.test.assertEquals /** * consecutive_strings * @see <a href="https://www.codewars.com/kata/56a5d994ac971f1ac500003e/train/kotlin">nakulgupta18</a> * * * * * Y...
0
Kotlin
0
3
be4085eaee07284723a7fe2fab2cae58c253caf9
4,513
developer-pages
MIT License
src/Day21.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
suspend fun main() { val testInput = readInput("Day21_test") check(part1(testInput) == 152L) check(part2(testInput) == 301L) val input = readInput("Day21") measureAndPrintResult { part1(input) } measureAndPrintResult { part2(input) } } private fun part1(input: List<Stri...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
2,986
aoc-22
Apache License 2.0
2015/Day10/src/main/kotlin/main.kt
mcrispim
658,165,735
false
null
import java.io.File data class Element(val name: String, val sequence: String, val nextSequence: String) { val size get() = sequence.length } fun readTable(name: String): Map<String, Element> { val input = File("src", name).readLines() // first line is header return buildMap<String, Element> {...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
1,857
AdventOfCode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/StringCompression2.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
2,202
kotlab
Apache License 2.0
src/Day25.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
import java.lang.Math.pow private fun decimalToSnafu(dec: Long): String { val quinary = dec.toString(5) val snafuReversed = mutableListOf<Char>() var hasCarry = false for (c in quinary.reversed()) { val decValue = c.digitToInt(10) + if (hasCarry) 1 else 0 when (decValue) { 0...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
1,998
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day14.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 class Day14(private val input: List<String>) { private val cache = Array<MutableMap<String, Map<Char, Long>>>(41) { mutableMapOf() } private val rules = input.drop(2).associate { rule -> rule.substring(0, 2) to rule.last() } fun solvePart1(): Long = solve(...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,195
advent-of-code
Apache License 2.0
day03/main.kts
LOZORD
441,007,912
false
{"Kotlin": 29367, "Python": 963}
import java.util.Scanner import java.util.Collections fun main1() { // ones collects the number of ones at each bit index for each input // binary number. var ones: IntArray? = null val input = Scanner(System.`in`) var total = 0 while (input.hasNextLine()) { val scanned = input.nextLin...
0
Kotlin
0
0
17dd266787acd492d92b5ed0d178ac2840fe4d57
7,457
aoc2021
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1335/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1335 import kotlin.math.max import kotlin.math.min /** * LeetCode page: [1335. Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/); * * TODO : There is solution with time complexity O(Nd) [(see Ref)](https://leetcode.com/p...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,466
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/com/jalgoarena/ranking/BasicRankingCalculator.kt
jalgoarena
128,505,026
false
{"Kotlin": 44176, "Shell": 236, "Dockerfile": 233}
package com.jalgoarena.ranking import com.jalgoarena.domain.* import com.jalgoarena.submissions.SubmissionsFilter import org.slf4j.LoggerFactory class BasicRankingCalculator( private val scoreCalculator: ScoreCalculator ) : RankingCalculator { private val logger = LoggerFactory.getLogger(this.javaClass) ...
3
Kotlin
1
1
d34e72ab09804b0b2470387e87a435e93110686f
2,923
JAlgoArena-Ranking
Apache License 2.0
src/Day01.kt
anisch
573,147,806
false
{"Kotlin": 38951}
fun main() { fun part1(input: List<String>): Int { return input .joinToString(";") { it } .split(";;") .maxOf { elf -> elf .split(";") .sumOf { it.toInt() } } } fun part2(input: List<String>): In...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
903
Advent-of-Code-2022
Apache License 2.0
src/Day03.kt
HenryCadogan
574,509,648
false
{"Kotlin": 12228}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { backpack -> val midPoint = backpack.length / 2 val firstHalf = backpack.substring(0 until midPoint) val secondHalf = backpack.substring(midPoint until backpack.length) val item = firstHal...
0
Kotlin
0
0
0a0999007cf16c11355fcf32fc8bc1c66828bbd8
943
AOC2022
Apache License 2.0
src/jvmMain/kotlin/day11/initial/Day11.kt
liusbl
726,218,737
false
{"Kotlin": 109684}
package day11.initial import day11.initial.Image.Galaxy import day11.initial.Image.Space import util.add import java.io.File fun main() { solvePart1() // Solution: 9565386, time 13:50 } fun solvePart1() { // val input = File("src/jvmMain/kotlin/day11/input/input_part1_test.txt") val input = File("src/jvmM...
0
Kotlin
0
0
1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1
4,004
advent-of-code
MIT License
src/algorithmdesignmanualbook/sorting/FindTransitionIndex.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.sorting import algorithmdesignmanualbook.print import kotlin.math.pow import kotlin.test.assertTrue /** * [otherValue] is the value that is NOT to be searched i.e. index of value other than the [otherValue] is searched. */ private fun getLeftMostOccurrence(otherValue: String, array...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,511
algorithms
MIT License
src/main/kotlin/nl/meine/aoc/_2023/Day2.kt
mtoonen
158,697,380
false
{"Kotlin": 201978, "Java": 138385}
package nl.meine.aoc._2023 import java.util.HashMap class Day2 { fun one(input: String): Int { val lines = input.split("\n") var counter = 0 val maxColor = HashMap<String, Int>(); maxColor["red"] = 12 maxColor["green"] = 13 maxColor["blue"] = 14 val a = l...
0
Kotlin
0
0
a36addef07f61072cbf4c7c71adf2236a53959a5
12,480
advent-code
MIT License
src/Day20.kt
spaikmos
573,196,976
false
{"Kotlin": 83036}
fun main() { fun parseInput(input: List<String>): ArrayDeque<Pair<Int, Long>> { return ArrayDeque(input.mapIndexed{ idx, it -> Pair(idx, it.toLong())}.toCollection(ArrayDeque())) } fun part1(input: ArrayDeque<Pair<Int, Long>>): Long { // Iterate over each element in the list for (i i...
0
Kotlin
0
0
6fee01bbab667f004c86024164c2acbb11566460
2,470
aoc-2022
Apache License 2.0
src/Day01.kt
galiagacandia
573,231,710
false
null
fun main() { fun part1(calories: List<String>): Int { var contadorElfo: Int = 0; var totalCalories: Int = 0 var maximasCalories: Int = 0 var elfoConMasCalories: String = "" var mapElfosCalories = mutableMapOf<Int, Int>() for (calorie in calories) { println...
0
Kotlin
0
0
b2a36f7616f86a68670a398cdefb491ab14a3968
1,341
adventofcode2022Kotlin
Apache License 2.0
src/Day07.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader fun main() { val testInput = """ $ 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 .. ...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
4,099
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestIsland.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
7,741
kotlab
Apache License 2.0
src/day17/Code.kt
fcolasuonno
221,697,249
false
null
package day17 import java.io.File import java.security.MessageDigest fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println(...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
3,296
AOC2016
MIT License
src/main/kotlin/days/Day12.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day12 : Day(12) { private val edges = inputList.map { it.split("-") } .flatMap { (from, to) -> listOf(from to to, to to from) } .groupBy { it.first } .mapValues { (_, value) -> value.map { (_, to) -> to } } override fun partOne(): Any { val visited = setOf("s...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
1,000
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/hj/leetcode/kotlin/problem2251/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2251 /** * LeetCode page: [2251. Number of Flowers in Full Bloom](https://leetcode.com/problems/number-of-flowers-in-full-bloom/); */ class Solution { /* Complexity: * Time O((N+M)LogN) and Space O(N) where N is the size of flowers and * M is the size of people; ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,706
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/cloud/dqn/leetcode/Subsets2Kt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/subsets-ii/description/ Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,2], a sol...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
2,429
cloud-dqn-leetcode
No Limit Public License
src/Day14.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { fun input(input: List<String>): MutableSet<Pair<Int, Int>> { val used = HashSet<Pair<Int, Int>>() for (s in input) { val parts = s.split(" -> ") for (i in 0 until parts.size - 1) { val (x0, y0) = parts[i].split(',').map { it.toInt() } ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
2,197
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximalNetworkRank.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,055
kotlab
Apache License 2.0
src/magic-square-forming.kt
syn-ack42
117,293,780
false
null
package magic_square_forming import java.util.* val origMagicSquare: List<List<Int>> = listOf( listOf(2, 7, 6), listOf(9, 5, 1), listOf(4, 3, 8) ...
0
Kotlin
0
0
aaafc8b59889f2ea49836b2a2d64517167179036
2,532
HackerRank
MIT License
src/day04/Day04.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day04 import readInput fun main() { fun part1(input: List<String>): Int { val lambda = { line: String -> val (range1, range2) = parseLine(line) val unionSection = range1 union range2 if (range1 == unionSection || range2 == unionSection) 1 else 0 } ...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
1,044
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g2401_2500/s2497_maximum_star_sum_of_a_graph/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2497_maximum_star_sum_of_a_graph // #Medium #Array #Sorting #Greedy #Heap_Priority_Queue #Graph // #2023_07_05_Time_773_ms_(100.00%)_Space_94.6_MB_(100.00%) import java.util.PriorityQueue class Solution { private lateinit var graphNodeIdToNodeValues: Array<PriorityQueue<Int>?> fun maxSta...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,919
LeetCode-in-Kotlin
MIT License
a3/a3-enhanced/src/main/kotlin/ui/assignments/connectfour/model/Grid.kt
Gray-Yang
589,632,902
false
null
package ui.assignments.connectfour.model /** * The grid of Connect-Four and functionality to interact with it, i.e., play the game. * version 1.01: BUGFIX: did not detect insertions that form chains > length, e.g., ***_** -> ****** */ class Grid(width: Int, height: Int, private val length: Int) { /** * Th...
0
Kotlin
0
0
4d998822044fc16e5181a813a1ac272c839d9c0a
4,111
Android-Apps
MIT License
calendar/day10/Day10.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day10 import Day import Lines class Day10 : Day() { override fun part1(input: Lines): Any { val cpu = CPU() val statesOverTime = listOf(cpu.state) + input.map { instruction -> cpu.execute(instruction) cpu.stat...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
1,927
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Geometry.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright 2021 by <NAME> */ package com.ginsberg.advent2021 import kotlin.math.absoluteValue import kotlin.math.sign data class Point2d(val x: Int, val y: Int) { infix fun sharesAxisWith(that: Point2d): Boolean = x == that.x || y == that.y infix fun lineTo(that: Point2d): List<Point2d> { ...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
2,203
advent-2021-kotlin
Apache License 2.0
src/day21/Day21.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day21 import java.io.File fun main() { val data = parse("src/day21/Day21.txt") println("🎄 Day 21 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private fun parse(path: String): List<L...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
3,010
advent-of-code-2023
MIT License
src/Day05.kt
kkaptur
573,511,972
false
{"Kotlin": 14524}
import java.io.File import java.util.* fun main() { val input = File("src", "Day05.txt").readText().split("\n\n") val testInput = File("src", "Day05_test.txt").readText().split("\n\n") fun getStacksWithElements(input: List<String>): MutableList<Stack<String>> = mutableListOf<Stack<String>>().apply...
0
Kotlin
0
0
055073b7c073c8c1daabbfd293139fecf412632a
1,953
AdventOfCode2022Kotlin
Apache License 2.0
src/Day01.kt
riFaulkner
576,298,647
false
{"Kotlin": 9466}
fun main() { fun getElfCalorieTotals(input: List<String>): List<Int> { val elfTotals = ArrayList<Int>() var currentElfCalorieCount = 0 input.forEach{ if (it.equals("")) { elfTotals.add(currentElfCalorieCount) currentElfCalorieCount = 0 ...
0
Kotlin
0
0
33ca7468e17c47079fe2e922a3b74fd0887e1b62
1,244
aoc-kotlin-2022
Apache License 2.0
src/Day02.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
fun main() { fun part1(input: List<String>): Int { val scores = mapOf<String, Int>( "A X" to 4, "A Y" to 8, "A Z" to 3, "B X" to 1, "B Y" to 5, "B Z" to 9, "C X" to 7, "C Y" to 2, "C Z" to 6, ...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
1,033
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TopKFrequent.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
7,616
kotlab
Apache License 2.0
codeforces/kotlinheroes6/g_wrong.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes6 import java.util.* import kotlin.system.exitProcess fun main() { for (n in 1..20) solve(n) solve(readInt()) } private fun solve(n: Int) { val set = List(2 * n + 1) { TreeSet<Int>() } val score = IntArray(n + 1) { 0 } val divs = List(n + 1) { mutableListOf<Int>() } for (i in 1..n...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,063
competitions
The Unlicense
Kotlin/src/main/kotlin/org/algorithm/problems/0046_odd_even_jump.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
// Problem Statement // You are given an integer array A. From some starting index, you can make a // series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd // numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered jumps. // // You may from index i jump forwar...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
3,671
algorithms
MIT License
korlibs-datastructure/src/korlibs/datastructure/_GenericSort.kt
korlibs
80,095,683
false
{"WebAssembly": 14293935, "Kotlin": 9727891, "C": 77092, "C++": 20878, "TypeScript": 12397, "HTML": 6043, "Python": 4296, "Swift": 1371, "JavaScript": 328, "Shell": 254, "CMake": 202, "CSS": 66, "Batchfile": 41}
package korlibs.datastructure import kotlin.math.min fun <T> genericSort(subject: T, left: Int, right: Int, ops: SortOps<T>): T = genericSort(subject, left, right, ops, false) fun <T> genericSort(subject: T, left: Int, right: Int, ops: SortOps<T>, reversed: Boolean): T = subject.also { timSort(subjec...
438
WebAssembly
118
2,188
11993ae7828c96ee261b5d610904c8ca5430b8d2
3,750
korge
Apache License 2.0
src/main/kotlin/g1901_2000/s1926_nearest_exit_from_entrance_in_maze/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1926_nearest_exit_from_entrance_in_maze // #Medium #Array #Breadth_First_Search #Matrix #Graph_Theory_I_Day_6_Matrix_Related_Problems // #2023_06_20_Time_351_ms_(94.44%)_Space_45.4_MB_(100.00%) import java.util.LinkedList import java.util.Queue class Solution { fun nearestExit(maze: Array<Cha...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,563
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/paulshields/aoc/Day15.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 15: Chiton */ package dev.paulshields.aoc import dev.paulshields.aoc.common.Point import dev.paulshields.aoc.common.readFileAsString fun main() { println(" ** Day 15: Chiton ** \n") val riskLevelMap = readFileAsString("/Day15RiskLevelMap.txt") val startingPosition = Point(0, 0) val cave...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
4,067
AdventOfCode2021
MIT License
kotlin/src/com/daily/algothrim/leetcode/MaxNumEdgesToRemove.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 1579. 保证图可完全遍历 * * Alice 和 Bob 共有一个无向图,其中包含 n 个节点和 3  种类型的边: * * 类型 1:只能由 Alice 遍历。 * 类型 2:只能由 Bob 遍历。 * 类型 3:Alice 和 Bob 都可以遍历。 * 给你一个数组 edges ,其中 edges[i] = [typei, ui, vi] 表示节点 ui 和 vi 之间存在类型为 typei 的双向边。请你在保证图仍能够被 Alice和 Bob 完全遍历的前提下,找出可以删除的最大边数。如果从任何节点开始,Alice 和 ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,882
daily_algorithm
Apache License 2.0
src/Day21.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
//val monkeys= readInput("day21_input_test").map { // getMonkey(it) //} ////e.g. ////* root = pppw = sjmn (we know sjmm is 150) so pppw must be 150 as well ////* pppw = cczh / lfqf (we know lfgf is 4 so it becomes 150 = cczh / 4 so cczh = 600 ////* cczh = sllz + lgvd (we know cczh is 600, sllz is 4 so lgvd is 596) ....
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
4,677
advent22
Apache License 2.0
year2023/day07/cards/src/main/kotlin/com/curtislb/adventofcode/year2023/day07/cards/Hand.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2023.day07.cards import com.curtislb.adventofcode.common.collection.Counter import com.curtislb.adventofcode.common.comparison.compareLists /** * A hand of Camel Cards, consisting of an ordered list of cards and a bid amount. * * @property cards The cards contained in the hand...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,301
AdventOfCode
MIT License
kotlin-leetcode/src/main/kotlin/io/github/dreamylost/Leetcode_1372.kt
jxnu-liguobin
123,690,567
false
null
/* Licensed under Apache-2.0 @梦境迷离 */ package io.github.dreamylost import kotlin.math.max /** * 1372. 二叉树中的最长交错路径 * * 给你一棵以 root 为根的二叉树,二叉树中的交错路径定义如下: * 选择二叉树中 任意 节点和一个方向(左或者右)。 * 如果前进方向为右,那么移动到当前节点的的右子节点,否则移动到它的左子节点。 * 改变前进方向:左变右或者右变左。 * 重复第二步和第三步,直到你在树中无法继续移动。 * 交错路径的长度定义为:访问过的节点数目 - 1(单个节点的路径长度为 0 )。 * 请你...
13
Java
190
526
a97159e99fc6592bec5032d18391d18b84708175
1,272
cs-summary-reflection
Apache License 2.0
src/twentytwo/Day05.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentytwo import readInputTwentyTwo import java.util.* import java.util.stream.Collectors typealias Crate = Char typealias Stack = LinkedList<Crate> fun List<String>.createDock(): Dock { // does not work correctly when nCrates == 0, but that's impossible val nCrates = (this.first().length + 1) / 4 ...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
3,196
kotlin-aoc-1
Apache License 2.0
BinaryGap.kt
getnahid
267,415,396
false
null
/* BinaryGap Find longest sequence of zeros in binary representation of an integer. A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary...
0
Kotlin
0
0
589c392237334f6c53513dc7b75bd8fa81ad3b79
1,582
programing-problem-solves-kotlin
Apache License 2.0
src/Day03.kt
timj11dude
572,900,585
false
{"Kotlin": 15953}
import kotlin.time.ExperimentalTime import kotlin.time.measureTime @OptIn(ExperimentalTime::class) fun main() { fun Char.toPriority(): Int = when { isUpperCase() -> code - (65 - 27) isLowerCase() -> code - (96) else -> throw IllegalArgumentException("unknown char [$this]") } fun b...
0
Kotlin
0
0
28aa4518ea861bd1b60463b23def22e70b1ed481
1,364
advent-of-code-2022
Apache License 2.0