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
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[41]缺失的第一个正数.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个未排序的整数数组 nums ,请你找出其中没有出现的最小的正整数。 //请你实现时间复杂度为 O(n) 并且只使用常数级别额外空间的解决方案。 // // // // 示例 1: // // //输入:nums = [1,2,0] //输出:3 // // // 示例 2: // // //输入:nums = [3,4,-1,1] //输出:2 // // // 示例 3: // // //输入:nums = [7,8,9,11,12] //输出:1 // // // // // 提示: // // // 1 <= nums.length <= 5 * 105 // -231 <= nums...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,635
MyLeetCode
Apache License 2.0
src/main/kotlin/_0017_LetterCombinationsOfAPhoneNumber.kt
ryandyoon
664,493,186
false
null
import java.lang.StringBuilder // https://leetcode.com/problems/letter-combinations-of-a-phone-number fun letterCombinations(digits: String): List<String> { val combinations = mutableListOf<String>() val digitToChars = mapOf( '2' to charArrayOf('a', 'b', 'c'), '3' to charArrayOf('d', 'e', 'f'),...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
1,263
leetcode-kotlin
MIT License
2021/src/Day09.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
// https://adventofcode.com/2021/day/9 fun main() { class Table(cols: Int, rows: Int, numbers: Array<Int>) { val cols = cols val rows = rows val numbers = numbers fun computeBasins() { val lowPointIndices = computeLowPoints() val basinSizes = mutableListOf<Int>() val basins = mutab...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
3,778
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day15.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days import java.util.* @AdventOfCodePuzzle( name = "Chiton", url = "https://adventofcode.com/2021/day/15", date = Date(day = 15, year = 2021) ) class Day15(val input: List<String>) : Puzzle { override fun partOne() = SimpleCave.parse(input).totalRisk() override fun partTwo() = ...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
2,833
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/search/triplets/Triplets.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.search.triplets import java.util.* fun triplets(a: IntArray, b: IntArray, c: IntArray): Long { val (aSorted, aSize) = sortUniqueToSize(a) val (bSorted, bSize) = sortUniqueToSize(b) val (cSorted, cSize) = sortUniqueToSize(c) val totalS...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
1,542
kotlin-hackerrank
MIT License
src/day13/Parser.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day13 import PeekableIterator import peekable import readInput /** * */ class Packets (val data: List<Pair<List<Any>, List<Any>>>) { val unsorted: List<List<Any>> get () { return mutableListOf<List<Any>>().apply { data.forEach { val (a, b) = it ...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,921
advent_of_code_2022
Apache License 2.0
src/main/kotlin/days/Day11.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days @AdventOfCodePuzzle( name = "Monkey in the Middle", url = "https://adventofcode.com/2022/day/11", date = Date(day = 11, year = 2022) ) class Day11(val input: String) : Puzzle { private val monkeys = input.split("\n\n").map { Monkey.from(it.lines()) } override fun partOne(): Int = mon...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
3,196
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/Day06.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
// not very efficient but it works for this assignment private fun List<Any>.isUnique(): Boolean { this.forEachIndexed { indexOuter, valueOuter -> this.forEachIndexed { indexInner, valueInner -> if (indexInner != indexOuter && valueInner == valueOuter) return false } } return tru...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
1,472
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g2801_2900/s2818_apply_operations_to_maximize_score/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2818_apply_operations_to_maximize_score // #Hard #Array #Math #Greedy #Stack #Monotonic_Stack #Number_Theory // #2023_12_06_Time_727_ms_(100.00%)_Space_57.4_MB_(100.00%) import java.util.ArrayDeque import java.util.Deque import java.util.PriorityQueue import kotlin.math.min @Suppress("NAME_SHADOW...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,143
LeetCode-in-Kotlin
MIT License
kotlin/src/main/kotlin/com/tolchev/algo/matrix/200NumberOfIslands.kt
VTolchev
692,559,009
false
{"Kotlin": 53858, "C#": 47939, "Java": 1802}
package com.tolchev.algo.matrix class NumberOfIslands { private val DEFAULT_ISLAND = -1 fun numIslands(grid: Array<CharArray>): Int { var islands = Array<IntArray>(grid.size){ IntArray(grid[0].size){DEFAULT_ISLAND} } var topIsland : Int var leftIsland : Int var islandCount =...
0
Kotlin
0
0
c3129f23e4e7ba42b44f9fb4af39a95f4a762550
2,120
algo
MIT License
src/test/kotlin/Day19.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import kotlin.test.assertEquals import kotlin.test.assertTrue typealias Rule = Triple<List<Int>, List<Int>, String> class Day19 { @Test fun `test parse rules`() { val rule: Rule = Triple(listOf(4, 1, 5), listOf(), "") assertEquals(mapOf<Int, Rule>(0 to rule),...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
4,881
advent-of-code
MIT License
src/Day01.kt
shoebham
573,035,954
false
{"Kotlin": 9305}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var sum =0; var ans:Int=0; val sortedList = mutableListOf<Int>() for(x in input){ println("x="+x) if(x==""){ sum=0; } else{ val n...
0
Kotlin
0
0
f9f0e0540c599a8661bb2354ef27086c06a3c9ab
1,426
advent-of-code-2022
Apache License 2.0
src/Day05.kt
ixtryl
575,312,836
false
null
import java.util.* object DAY05 { fun run(fileName: String, crane: Crane): String { val lines = readInput(fileName) val stacks: MutableMap<Int, MutableList<Char>> = getInitialStacks(lines) val operations: List<Operation> = getOperations(lines) val finalStacks = crane.build(stacks, ...
0
Kotlin
0
0
78fa5f6f85bebe085a26333e3f4d0888e510689c
3,766
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
BHFDev
572,832,641
false
null
import java.lang.Error fun main() { fun part1(input: List<String>): Int { return input.sumOf {shapes -> val myShape = shapes[2] val opponentsShape = shapes[0] when (myShape) { 'X' -> 1 + when (opponentsShape) { 'C' -> 6 ...
0
Kotlin
0
0
b158069483fa02636804450d9ea2dceab6cf9dd7
1,758
aoc-2022-in-kotlin
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day11.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.test.assertEquals object Day11 : AbstractDay() { @Test fun part1() { assertEquals(10605, part1(testInput)) assertEquals(54036, part1(puzzleInput)) } @Test fun part2() { ...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
3,677
aoc
Apache License 2.0
2022/src/main/kotlin/de/skyrising/aoc2022/day12/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day12 import de.skyrising.aoc.* private fun parseInput(input: PuzzleInput): Triple<IntGrid, Vec2i, Vec2i> { val height = input.byteLines.size val width = input.byteLines[0].remaining() val data = IntArray(width * height) val grid = IntGrid(width, height, data) var star...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,764
aoc
MIT License
src/Day03.kt
kthun
572,871,866
false
{"Kotlin": 17958}
fun main() { fun Char.characterValue(): Int = when { isLowerCase() -> code - 'a'.code + 1 else -> code - 'A'.code + 27 } fun part1(input: List<String>): Int = input.sumOf { line -> val midPoint = line.length / 2 val compartmentA = line.substring(0, midPoint) val com...
0
Kotlin
0
0
5452702e4e20ef2db3adc8112427c0229ebd1c29
869
aoc-2022
Apache License 2.0
src/Day02_part2.kt
rdbatch02
575,174,840
false
{"Kotlin": 18925}
data class Move_Part2( val points: Int, val beats: String, val losesTo: String ) { companion object { fun rock() = Move_Part2(points = 1, beats = "C", losesTo = "B") fun paper() = Move_Part2(points = 2, beats = "A", losesTo = "C") fun scissors() = Move_Part2(points = 3, beats = "...
0
Kotlin
0
1
330a112806536910bafe6b7083aa5de50165f017
1,551
advent-of-code-kt-22
Apache License 2.0
src/Day05.kt
hubikz
573,170,763
false
{"Kotlin": 8506}
import java.io.File fun main() { fun base(input: String, orderTaken: (moved: List<String>) -> List<String>): String { val (creates, moves: String) = input.split("\n\n") val zm = mutableListOf<MutableList<String>>() creates.lines().last().chunked(4).map{ it.trim() }.map { zm.add...
0
Kotlin
0
0
902c6c3e664ad947c38c8edcb7ffd612b10e58fe
1,492
AoC2022
Apache License 2.0
src/Day07.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
private sealed class File { abstract val name: String abstract val size: Long abstract val parentDirectory: Directory } private class Directory( override val name: String, private val parentDirectoryOrNull: Directory? ) : File() { override val parentDirectory: Directory get() = parentDi...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
4,261
advent-of-code-2022-kotlin
Apache License 2.0
src/day7/FindSubarrayWithSumK.kt
minielectron
332,678,510
false
{"Java": 127791, "Kotlin": 48336}
package day7 import kotlin.math.min // Problem: You are given with an datastructure.array [1,4,5,3,6,8,4,0,8] // 1. find the subarray of length 3 whose sum is equal to 12. // fixed length problem // 2. find the minimum subarray whose sum is equal to 12. // dynamic window size length problem // 3. find how many subarr...
0
Java
0
0
f2aaff0a995071d6e188ee19f72b78d07688a672
2,526
data-structure-and-coding-problems
Apache License 2.0
src/main/kotlin/io/dp/UniquePathWithObstacles.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.dp import io.utils.runTests // https://leetcode.com/problems/unique-paths-ii/ class UniquePathWithObstacles { fun execute(input: Array<IntArray>): Int { if (input.isEmpty() || input.first().isEmpty()) return 0 val row = input.size val col = input.first().size val dp = createDpArray...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,861
coding
MIT License
AdventOfCodeDay01/src/linuxMain/kotlin/sample/Day01.kt
bdlepla
451,523,596
false
{"Kotlin": 153773}
package sample class Day01(lines: List<String>) { private val data = lines.map{it.toLong()}.sorted().asSequence() fun solvePart1() = getAllPairs(data) .filter{it.first + it.second == 2020L} .map{it.first * it.second} .first() fun solvePart1a() = // data is sorted() and th...
0
Kotlin
0
0
043d0cfe3971c83921a489ded3bd45048f02ce83
2,119
AdventOfCode2020
The Unlicense
markdown/markdown/src/commonMain/kotlin/party/markdown/tree/MutableIntGraph+Cycles.kt
markdown-party
341,117,604
false
{"Kotlin": 619763, "Dockerfile": 723, "JavaScript": 715, "Shell": 646, "HTML": 237, "CSS": 133}
package party.markdown.tree private const val NoRoot = -1 /** Finds the root vertex of this graph, that is a vertex with no parent. */ private fun MutableIntGraph.findRoot(): Int { // Store the number of parents that reference each vertex. val parents = IntArray(size) for (i in 0 until size) { neighboursFo...
0
Kotlin
3
53
0135c85488873c2e00720353aba3e6b4c0fcc83b
2,214
mono
MIT License
src/Day09_alternative.kt
a2xchip
573,197,744
false
{"Kotlin": 37206}
import kotlin.math.abs import kotlin.math.sign class KnotChain(private val id: Int, private var head: KnotChain? = null, private var tail: KnotChain? = null) { private val log = mutableSetOf<Pair<Int, Int>>() private var x = 0 private var y = 0 override fun toString(): String { return "#$id - ...
0
Kotlin
0
2
19a97260db00f9e0c87cd06af515cb872d92f50b
2,678
kotlin-advent-of-code-22
Apache License 2.0
src/week1/ThreeSum.kt
anesabml
268,056,512
false
null
package week1 import java.util.* import kotlin.system.measureNanoTime class ThreeSum { /** * Fix the first number and look for the other two by using the two sum algorithm (map) * Time complexity : O(n2) * Space complexity : O(n) */ fun threeSum(nums: IntArray): List<List<Int>> { ...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
2,186
leetCode
Apache License 2.0
src/Day01.kt
llama-0
574,081,845
false
{"Kotlin": 6422}
fun main() { fun convertInputToInts(input: List<String>): List<Int> { val ints = mutableListOf<Int>() for (i in input) { if (i != "") { ints.add(i.toInt()) } else { ints.add(0) } } return ints } fun updateTh...
0
Kotlin
0
0
a3a9a07be54a764a707ab25332a9f324cb84ac2a
1,635
AoC-2022
Apache License 2.0
src/ad/kata/aoc2021/day06/LanternfishPopulation.kt
andrej-dyck
433,401,789
false
{"Kotlin": 161613}
package ad.kata.aoc2021.day06 import ad.kata.aoc2021.PuzzleInput import ad.kata.aoc2021.extensions.plusNotNull import ad.kata.aoc2021.extensions.toIntsSequence import ad.kata.aoc2021.extensions.toMapMerging data class LanternfishPopulation(val state: Map<LanternfishTimer, Amount>) { private constructor(stateEntr...
0
Kotlin
0
0
28d374fee4178e5944cb51114c1804d0c55d1052
1,663
advent-of-code-2021
MIT License
src/year2022/day09/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day09 import arrow.core.NonEmptyList import arrow.core.nonEmptyListOf import arrow.optics.Lens import arrow.optics.optics import io.kotest.matchers.shouldBe import kotlin.math.sign import utils.Point import utils.neighbors import utils.readInput import utils.x import utils.y fun main() { val test...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,599
Advent-of-Code
Apache License 2.0
src/Day14.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
fun main() { val input = readInput("Day14") printTime { println(Day14.part1(input)) } printTime { println(Day14.part2(input)) } } class Day14 { companion object { fun part1(input: List<String>): Int { val pointMatrix = input.map { it.split(" -> ").map(::Point) } val poin...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
5,378
advent-of-code-22
Apache License 2.0
src/main/kotlin/dev/patbeagan/days/Day02.kt
patbeagan1
576,401,502
false
{"Kotlin": 57404}
package dev.patbeagan.days import dev.patbeagan.days.Day02.Move.* /** * [Day 2](https://adventofcode.com/2022/day/2) */ class Day02 : AdventDay<Int> { override fun part1(input: String) = parseInput1(input) .fold(0) { acc, each -> val movePoints = each.self.points val outcomePoint...
0
Kotlin
0
0
4e25b38226bcd0dbd9c2ea18553c876bf2ec1722
2,984
AOC-2022-in-Kotlin
Apache License 2.0
src/Day12.kt
jrmacgill
573,065,109
false
{"Kotlin": 76362}
import utils.* import java.lang.Math.abs import java.lang.Math.min class Day12 { var dir = listOf<Point>(Point(-1,0), Point(1,0), Point(0,1),Point(0,-1)) fun go() { //private val rawInput: List<String> val grid: List<List<Char>> by lazy { readInput("dayTwelve").map { it.toList() }} v...
0
Kotlin
0
1
3dcd590f971b6e9c064b444139d6442df034355b
1,731
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d02/Day02.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d02 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.Tuple3 import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines // tuple order: (red, green, blue) fun parseGame(line: String): List<Tuple3<Int, Int, Int>> { val (_, draws)...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,541
advent-of-code
MIT License
app/src/main/kotlin/me/leon/ext/math/Kgcd.kt
Leon406
381,644,086
false
{"Kotlin": 1392660, "JavaScript": 96128, "Java": 16541, "Batchfile": 4706, "Shell": 259, "CSS": 169}
package me.leon.ext.math import java.math.BigInteger object Kgcd { /** * @param a 第一个参数 * @param b 第二个参数 * @param x x的值,前两个组成的数组 * @param y y的值,前两个组成的数组 * @return 返回值为 {最大公约数,x的值,y的值} */ fun gcdext( a: BigInteger, b: BigInteger, x: Array<BigInteger>, ...
4
Kotlin
236
1,218
dde1cc6e8e589f4a46b89e2e22918e8b789773e4
1,944
ToolsFx
ISC License
src/day02/Day02.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day02 import readInput fun main() { fun part1(input: List<String>): Int { var totalScore = 0 val shapes = parseInputPart1(input) shapes.windowed(2, 2) { (myShape, elvesShape) -> totalScore += myShape.shapeScore + myShape.match(elvesShape).matchScore } re...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
3,622
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinCostTickets.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,985
kotlab
Apache License 2.0
src/main/kotlin/th/in/jamievl/adventofcode/d4/Day4.kt
jamievlin
578,295,680
false
{"Kotlin": 8145, "Starlark": 4278}
package th.`in`.jamievl.adventofcode.d4 import th.`in`.jamievl.adventofcode.common.readFromResource import java.lang.IllegalArgumentException import java.util.regex.Pattern import kotlin.math.min import kotlin.math.max data class AssignmentRange(val start: Int, val end: Int) { init { if (start > end) { ...
0
Kotlin
0
0
4b0f5a8e6bcc411f1a76cfcd6d099872cf220e46
2,495
adventofcode-2022
MIT License
src/Day02RockPaperScissors.kt
zizoh
573,932,084
false
{"Kotlin": 13370}
// A, X -> Rock (1) // B, Y -> Paper (2) // C, Z -> Scissors (3) // lost (0) // draw (3) // win (6) // rock > scissors // scissors > paper // paper > rock // Part 2 // X lose // Y draw // Z win fun main() { val input: List<String> = readInput("input/day02") println("round one score: ${input.sumOf { roundOn...
0
Kotlin
0
0
817017369d257cca648974234f1e4137cdcd3138
1,721
aoc-2022
Apache License 2.0
src/Day24.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import java.io.File import kotlin.math.abs const val EPS = 1E-9 data class Point3(val x: Double, val y: Double, val z: Double) operator fun Point3.plus(p: Point3) = Point3(x + p.x, y + p.y, z + p.z) data class Line2(val a: Double, val b: Double, val c: Double) typealias Hail = Pair<Point3, Point3> fun main() { fu...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
3,492
advent-of-code-kotlin
Apache License 2.0
kotlin/MyTest.kt
char16t
139,452,018
false
{"JavaScript": 1115281, "Jupyter Notebook": 722304, "Java": 362103, "Scala": 319717, "TypeScript": 214516, "HTML": 152089, "Handlebars": 61648, "C++": 35907, "PLpgSQL": 21952, "Clojure": 17487, "CSS": 17421, "SCSS": 11649, "Kotlin": 7383, "Shell": 6892, "Python": 6618, "Jinja": 4302, "Makefile": 4154, "C": 3782, "Docke...
package training import io.kotlintest.specs.StringSpec import java.util.* import kotlin.collections.HashMap class MyTest : StringSpec({ "Test1" { val graph = listOf( // 1-st connected component listOf(1, 2), listOf(1, 3), listOf(2, 4), listOf(2, ...
0
JavaScript
0
0
3669a0b7536a0df61344cf8f69c2c6f0ba7a6ac8
7,383
incubator
The Unlicense
src/test/kotlin/year2015/Day6.kt
abelkov
47,995,527
false
{"Kotlin": 48425}
package year2015 import kotlin.test.Test import kotlin.test.assertEquals class Day6 { @Test fun part1() { val field = Array(1000) { Array(1000) { false } } val regex = """(?>turn )?(\w+) (\d+),(\d+) \w+ (\d+),(\d+)""".toRegex() readInput("year2015/Day6.txt").lines().forEach { line: Str...
0
Kotlin
0
0
0e4b827a742322f42c2015ae49ebc976e2ef0aa8
2,030
advent-of-code
MIT License
src/day07/Day07.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day07 import readLines const val MAX_SIZE = 100000L const val TOTAL_AVAILABLE_SIZE = 70000000L const val UPDATE_SIZE = 30000000L typealias Indexes = MutableList<Index> val empty: Indexes get() = mutableListOf() sealed interface Index { val name: String; val parent: Dir?; val size: Long } class File(overrid...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
2,664
advent-of-code-22
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/Candy.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
3,941
kotlab
Apache License 2.0
src/main/kotlin/days/Day10.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days class Day10 : Day(10) { override fun runPartOne(lines: List<String>): Any { return lines.map { line -> findInvalidChar(line.toCharArray().toList()).first }.sumOf { c -> val n: Int = when(c) { ')' -> 3 ']' -> 57 '}'...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
2,622
aoc2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/sherepenko/leetcode/solutions/NumberOfIslands.kt
asherepenko
264,648,984
false
null
package com.sherepenko.leetcode.solutions import com.sherepenko.leetcode.Solution class NumberOfIslands( private val grid: Array<CharArray> ) : Solution { companion object { fun numIslandsI(grid: Array<CharArray>): Int { var count = 0 for (i in grid.indices) { ...
0
Kotlin
0
0
49e676f13bf58f16ba093f73a52d49f2d6d5ee1c
2,950
leetcode
The Unlicense
src/main/kotlin/days/Day21.kt
nuudles
316,314,995
false
null
package days class Day21 : Day(21) { private val allergenMapping: Map<String, String> private val allIngredients: List<String> init { val mapping = mutableMapOf<String, Set<String>>() val allIngredients = mutableListOf<String>() inputList .forEach { line -> ...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
1,742
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/Day08.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun Int.countVisibleTrees( axisPos: Int, changePosition: (Int) -> Int, condition: (Int) -> Boolean, newTree: (Int) -> Int, ): Int { var newPos = changePosition(axisPos) var count = 0 while (condition(newPos)) { count++ ...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
4,396
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2021/Day06.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2021 import aoc2022.applyN import utils.InputUtils // 8 + 6 + 6 + 6 + 6 fun simulate(i: List<Int>): List<Int> = i.flatMap { when (it) { 0 -> listOf(6, 8) else -> listOf(it - 1) } } fun fishAfterImpl(days: Int): Long = when { days < 0 -> 1 else -> fishAfter(day...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,467
aoc-2022-kotlin
Apache License 2.0
src/Day21.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
private sealed class Monkey(val name: String) { abstract var value: Long? val dependingMonkeys = mutableListOf<DependingMonkey>() class LeafMonkey( name: String, override var value: Long? ) : Monkey(name) class DependingMonkey( name: String, val leftMonkeyName: Str...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
7,152
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g0901_1000/s0993_cousins_in_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0993_cousins_in_binary_tree // #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #2023_05_12_Time_152_ms_(71.43%)_Space_35.2_MB_(71.43%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree node. * clas...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,750
LeetCode-in-Kotlin
MIT License
src/Day23.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day23.run { solve1(110) // 3766 solve2(20) // 954 } }.let { println("Total: $it ms") } } object Day23 : Day.LineInput<Set<Pair<Int, Int>>, Int>("23") { override fun parse(input: List<String>) =...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
2,243
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1296/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1296 import java.util.ArrayDeque /** * LeetCode page: [1296. Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/); */ class Solution2 { /* Complexity: * Time O(N) and Space O(N) where N is the size...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,372
hj-leetcode-kotlin
Apache License 2.0
aoc21/day_13/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File data class Pos(val x: Int, val y: Int) data class Fold(val axe: Char, val n: Int) fun fold(dots: Set<Pos>, f: Fold): Set<Pos> = if (f.axe == 'x') { dots.filter { it.x < f.n } + dots.filter { it.x > f.n }.map { Pos(f.n - (it.x - f.n), it.y) } } else { dots.filter...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,141
advent-of-code
MIT License
src/aoc2022/Day02.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* internal class Day02(lines: List<String>) { init { lines.forEach { println(it) } } private val rounds = lines.map { listOf(it[0].code - 'A'.code, it[2].code - 'X'.code) } fun part1(): Int { return rounds.map { r -> // Computes the result of the round. // Lose = 0...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
1,200
aoc2022
Apache License 2.0
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day06.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2021 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readText import se.brainleech.adventofcode.toListOfInts import se.brainleech.adventofcode.verify class Aoc2021Day06 { companion object { private const val SPAWN_AGE = 8 private co...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
2,045
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/SuperUglyNumber.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,835
kotlab
Apache License 2.0
lib/src/main/kotlin/com/bloidonia/advent/day06/Day06.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day06 import com.bloidonia.advent.readText // The trick is we only need to know how many are at each of the 9 stages of life (count needs to be a Long for Part 2) class Population(val population: Map<Int, Long>) { fun generation() = mutableMapOf<Int, Long>().let { nextGeneration -> ...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,365
advent-of-kotlin-2021
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1466/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1466 /** * LeetCode page: [1466. Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/); */ class Solution { /* Complexity: * Time O(n) and Space O(n); */ fun minReorder(n: ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,028
hj-leetcode-kotlin
Apache License 2.0
src/day07/Day07.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day07 import readInput import java.util.* data class File(val name: String, val bytes: Int) data class Directory(val name: String, val files: MutableList<File> = mutableListOf(), val directories: MutableList<Directory> = mutableListOf(), val uuid: UUID = UUID.randomUUID()) { fun totalBytes(): Int { ...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
5,471
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day09.kt
SimonMarquis
434,880,335
false
{"Kotlin": 38178}
import Neighborhood.VonNeumann class Day09(raw: List<String>) { private val input = raw.mapIndexed { y, line -> line.mapIndexed { x, height -> Point(x, y, height.toString().toInt()) }.toTypedArray() }.toTypedArray().let(::HeightMap) fun part1(): Int = with(input) { poi...
0
Kotlin
0
0
8fd1d7aa27f92ba352e057721af8bbb58b8a40ea
1,372
advent-of-code-2021
Apache License 2.0
kotlin/src/x2023/Day04.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package x2023 open class Day04AExample { open val inputLines: List<String> = read2023Input("day04-example") open val expected = 13 open var answer: Int = 0 fun run() { answer = inputLines.sumOf { line -> val lines = line.split(":") val card = lines[0] val nu...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
3,190
adventOfCode
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day17.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day17(input: List<String>) { private val grid = input.toGrid().mapValues { it.value.digitToInt() } private val start = grid.region().topLeft private val goal = grid.region().bottomRight private data class State(val pos: Vector2, val dir: Direction, val straight...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
1,625
advent-2023
MIT License
src/Day04.kt
Olivki
573,156,936
false
{"Kotlin": 11297}
fun main() { fun parseRange(text: String): List<Int> { val (a, b) = text.split('-') return (a.toInt()..b.toInt()).toList() } fun parseInput(input: List<String>) = input .asSequence() .filter { it.isNotBlank() } .map { it.split(',') } .map { (a, b) -> parseRan...
0
Kotlin
0
1
51c408f62589eada3d8454740c9f6fc378e2d09b
811
aoc-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/TwoSumIiInputArrayIsSorted.kt
faniabdullah
382,893,751
false
null
//Given a 1-indexed array of integers numbers that is already sorted in non- //decreasing order, find two numbers such that they add up to a specific target //number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= first //< second <= numbers.length. // // Return the indices of the two number...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,172
dsa-kotlin
MIT License
kotlin/src/Day07.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt import java.lang.Long.parseLong import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val positions = input.first().split(",").map(::parseInt) val maxPosition = positions.maxOrNull()!! return (0..maxPosition).fold(positions.size * maxPo...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
1,535
aoc-2021
MIT License
2022/src/main/kotlin/sh/weller/aoc/Day02.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day02 : SomeDay<Pair<Char, Char>, Int> { override fun partOne(input: List<Pair<Char, Char>>): Int = input .map { val (opponent, me) = it Shape.fromSymbol(opponent) to Shape.fromSymbol(me) } .map { ...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
3,184
AdventOfCode
MIT License
src/day03/Day03.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day03 import readInputString fun main() { fun calculatePriority(c: Char): Long { var priority = 0L if (c.isUpperCase()) { priority += 26L } priority += c.lowercaseChar().code - 96 return priority } fun part1(input: List<String>): Long { ...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
1,531
Advent-Of-Code-2022
Apache License 2.0
src/Day03.kt
vi-quang
573,647,667
false
{"Kotlin": 49703}
/** * Main ------------------------------------------------------------------- */ fun main() { /** * Compartment ------------------------------------------------------------------- */ data class Compartment(val itemList: MutableList<Char> = mutableListOf()) { fun contains(c: Char) : Boolea...
0
Kotlin
0
2
ae153c99b58ba3749f16b3fe53f06a4b557105d3
3,634
aoc-2022
Apache License 2.0
src/adventofcode/Day11.kt
Timo-Noordzee
573,147,284
false
{"Kotlin": 80936}
package adventofcode import org.openjdk.jmh.annotations.* import java.util.concurrent.TimeUnit private operator fun Monkey.times(other: Monkey) = amountOfInspections.toLong() * other.amountOfInspections private data class Monkey( private var items: ArrayDeque<Long>, private val inspect: (item: Long) -> Long,...
0
Kotlin
0
2
10c3ab966f9520a2c453a2160b143e50c4c4581f
3,204
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g0801_0900/s0882_reachable_nodes_in_subdivided_graph/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0882_reachable_nodes_in_subdivided_graph // #Hard #Heap_Priority_Queue #Graph #Shortest_Path // #2023_04_08_Time_434_ms_(100.00%)_Space_52_MB_(100.00%) import java.util.PriorityQueue class Solution { fun reachableNodes(edges: Array<IntArray>, maxMoves: Int, n: Int): Int { val adList =...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,997
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ScheduleCourse3.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
5,183
kotlab
Apache License 2.0
change/src/main/kotlin/Change.kt
3mtee
98,672,009
false
null
class ChangeCalculator(coins: List<Int>) { private val coins = coins.reversed() fun computeMostEfficientChange(grandTotal: Int): List<Int> { require(grandTotal >= 0) { "Negative totals are not allowed." } require((grandTotal == 0) || (grandTotal >= this.coins.minOrNull()!!)) { "The total $grand...
0
Kotlin
0
0
6e3eb88cf58d7f01af2236e8d4727f3cd5840065
1,438
exercism-kotlin
Apache License 2.0
src/main/kotlin/day20/Day20.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day20 import java.io.File fun main() { val data = parse("src/main/kotlin/day20/Day20.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 20 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
2,501
advent-of-code-2021
MIT License
src/Day01.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
fun main() { fun part1(input: List<String>): Int { var current = 0 var max: Int = -1 input.forEach {s: String -> when { s.isEmpty() -> { max = maxOf(max, current) current = 0 } else -> { ...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
1,275
aoc22-kotlin
Apache License 2.0
2021/src/Day19.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import kotlin.math.abs import kotlin.math.max // https://adventofcode.com/2021/day/19 fun main() { class Position(x: Int, y: Int, z: Int) { val x = x val y = y val z = z override fun toString(): String { return "($x,$y,$z)" } override fun equals(other: Any?): Boolean { return (...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
6,458
advent-of-code
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day12.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import kotlin.math.absoluteValue fun main() = Day12.solve() object Day12 : AdventSolution(2020, 12, "Rain Risk") { override fun solvePartOne(input: String): Int { var orientation = 0 var px ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,058
advent-of-code
MIT License
src/Day14.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
enum class Entity { ROCK, BALL, } private infix fun Int.toward(to: Int): IntProgression { val step = if (this > to) -1 else 1 return IntProgression.fromClosedRange(this, to, step) } fun main() { val source = Vector2(500, 0) fun makeObstacles(input: List<String>): MutableMap<Vector2, Entity> {...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,160
aoc2022
Apache License 2.0
src/Day03.kt
rod41732
728,131,475
false
{"Kotlin": 26028}
fun main() { fun part1(input: List<String>): Int { val r = input.size val c = input[0].length val isSymbols = input.map { it.map { char -> !char.isDigit() && char != '.' }.toMutableList() } val isAdjSymbols = isSymbols.mapIndexed { i, row -> row.mapInd...
0
Kotlin
0
0
05a308a539c8a3f2683b11a3a0d97a7a78c4ffac
3,601
aoc-23
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2021/calendar/day17/Day17.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2021.calendar.day17 import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import javax.inject.Inject import kotlin.math.abs import kotlin.math.max class Day17 @Inject constructor(private val generatorFactory: InputGeneratorFactory) { fun maxHeight(fileName: String) = generatorFa...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,388
advent-of-code
MIT License
src/main/kotlin/Day2.kt
Filipe3xF
433,908,642
false
{"Kotlin": 30093}
import utils.Day fun main() = Day(2, ::extractInstructions, { (0 to 0).followInstructions(it).multiply() }, { SubmarinePosition(0, 0, 0).followInstructions(it).multiply() } ).printResult() fun extractInstructions(inputList: List<String>) = inputList.map { it.split(" ") }.map { (command, delta) -> command...
0
Kotlin
0
1
7df9d17f0ac2b1c103b5618ca676b5a20eb43408
2,302
advent-of-code-2021
MIT License
src/main/kotlin/adventofcode2017/potasz/P14DiskDefrag.kt
potasz
113,064,245
false
null
package adventofcode2017.potasz import java.util.stream.Collectors import java.util.stream.IntStream object P14DiskDefrag { fun String.toBinary(): BooleanArray = this .map { it.toString().toInt(16) } .flatMap { num -> listOf(8, 4, 2, 1).map { num and it == it } } .toBooleanArr...
0
Kotlin
0
1
f787d9deb1f313febff158a38466ee7ddcea10ab
2,251
adventofcode2017
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/AvoidFloodInTheCity.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,594
kotlab
Apache License 2.0
src/aoc2022/Day04.kt
Playacem
573,606,418
false
{"Kotlin": 44779}
package aoc2022 import utils.readInput object Day04 { override fun toString(): String { return this.javaClass.simpleName } } fun main() { fun rangeStringAsIntRange(rangeString: String): IntRange { val (left, right) = rangeString.split('-') return IntRange(left.toInt(10), right.toI...
0
Kotlin
0
0
4ec3831b3d4f576e905076ff80aca035307ed522
1,486
advent-of-code-2022
Apache License 2.0
src/main/aoc2018/Day4.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 class Day4(input: List<String>) { private val guards = parseInput(input) private fun parseInput(input: List<String>): MutableMap<Int, IntArray> { val sorted = input.sorted() var currentGuard = -1 var i = 0 // Map of all guards, value is an array where each entr...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,927
aoc
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestGoodInteger.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,167
kotlab
Apache License 2.0
src/main/kotlin/abc/218-e.kt
kirimin
197,707,422
false
null
package abc import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val m = sc.nextInt() val abc = (0 until m).map { Triple(sc.next().toInt(), sc.next().toInt(), sc.next().toLong()) } println(problem218e(n, m, abc)) } fun problem218e(n: Int, m: Int, a...
0
Kotlin
1
5
23c9b35da486d98ab80cc56fad9adf609c41a446
1,606
AtCoderLog
The Unlicense
src/cn/leetcode/codes/simple15/Simple15_2.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple15 import cn.leetcode.codes.out import java.util.* class Simple15_2 { /* 15. 三数之和 给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重复的三元组。 注意:答案中不可以包含重复的三元组。 示例 1: 输入:nums = [-1,0,1,2,-1,-4] 输出:[[-1,-1,2],[-1,0,1]] 示例 2: 输入:nums = [] 输出:[] 示例 ...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,938
LeetCodeSimple
Apache License 2.0
kotlin/1553-minimum-number-of-days-to-eat-n-oranges.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
// dfs class Solution { fun minDays(n: Int): Int { val dp = HashMap<Int, Int>().apply { this[0] = 0 this[1] = 1 } fun dfs(n: Int): Int { if (n in dp) return dp[n]!! val divByTwo = 1 + (n % 2) + dfs(n / 2) val divByThree = 1 + (n %...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,594
leetcode
MIT License
year2017/src/main/kotlin/net/olegg/aoc/year2017/day20/Day20.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day20 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector3D import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2017.DayOf2017 /** * See [Year 2017, Day 20](https://adventofcode.com/2017/day/20) */ object Day20 : DayOf2017(20) { override fun first(): Any...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,885
adventofcode
MIT License
src/main/kotlin/com/github/brpeterman/advent2022/RopeSnake.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 class RopeSnake { data class Coords(val row: Int, val column: Int) { operator fun plus(other: Coords): Coords { return Coords(row + other.row, column + other.column) } } enum class Direction(val offset: Coords) { UP(Coords(-1, 0))...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
3,109
advent2022
MIT License
src/adventofcode/blueschu/y2017/day02/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day02 import java.io.File import kotlin.test.assertEquals fun input(): List<List<Int>> = File("resources/y2017/day02.txt") .readLines() .map { it.split('\t').map(String::toInt) } fun main(args: Array<String>) { assertEquals(18, part1(listOf( listOf(5, 1, 9, 5),...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
1,260
Advent-Of-Code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/IsSubsequence.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,954
kotlab
Apache License 2.0
src/main/kotlin/days/Day10.kt
hughjdavey
317,575,435
false
null
package days class Day10 : Day(10) { private val ratings = inputList.map { it.toInt() }.let { val outletJoltage = 0 val deviceJoltage = (it.maxOrNull() ?: 0) + 3 it.plus(outletJoltage).plus(deviceJoltage) }.sorted() // 2450 override fun partOne(): Any { return countJol...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
1,874
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day04.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
fun main() { fun getSectionPairOfElves(pair: String): Pair<IntRange,IntRange> = pair.split('-',',') .map { it.toInt() } .chunked(2) .map { IntRange(it[0], it[1]) } .let { it[0] to it[1] } fun part1(input: List<String>): Int = input.map(::getSect...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
856
aoc22
Apache License 2.0
src/Day09.kt
DiamondMiner88
573,073,199
false
{"Kotlin": 26457, "Rust": 4093, "Shell": 188}
import kotlin.math.abs fun main() { d9part1() d9part2() } fun move(target: Pair<Int, Int>, src: Pair<Int, Int>, exact: Boolean): Pair<Int, Int> { val (hX, hY) = target val (tX, tY) = src if (!exact) { if ( abs(hX - tX) <= 1 && abs(hY - tY) <= 1 ) { ...
0
Kotlin
0
0
55bb96af323cab3860ab6988f7d57d04f034c12c
3,595
advent-of-code-2022
Apache License 2.0
hackerrank/algorithms/frequency_queries.kts
SVMarshall
46,183,306
false
{"Python": 47229, "Erlang": 4918, "Kotlin": 3374, "C": 2915, "JavaScript": 1756}
import kotlin.collections.* class FrequenciesMap { private val numberFrequencies = mutableMapOf<Int, Int>() private val frequenciesCounts = mutableMapOf<Int, Int>() fun insert(value: Int) { val newValueFrequency = insertOnNumberFrequencies(value) insertOnFrequenciesLists(newValueFrequency) } fun d...
0
Python
0
1
275e3258c96365a1c886c3529261906deadf90ed
2,260
programming-challanges
Do What The F*ck You Want To Public License
src/main/kotlin/aoc2015/day02_wrap_presents/wrap_presents.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2015.day02_wrap_presents import kotlin.math.min fun main() { util.solve(1598415, ::partOne) util.solve(3812909, ::partTwo) } data class Box(val length: Int, val width: Int, val height: Int) { companion object { fun parse(s: String): Box { val dims = s.split("x") ...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,363
aoc-2021
MIT License
src/aoc2022/Day20.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.checkEquals import utils.sendAnswer private typealias Num = Pair<Int, Long> private val Num.value get() = second fun main() { fun part1(input: List<String>): Long { val original: List<Num> = input.mapIndexed { i, num -> i to num.toLong() } val mixingList = original.to...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,767
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day13.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 class Day13(private val input: List<String>) { private val initialPaper: List<List<Boolean>> private val foldInstructions: List<Pair<Char, Int>> init { val index = input.indexOf("") initialPaper = constructPaper(input.subList(0, index)) foldIns...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
3,427
advent-of-code
Apache License 2.0
solutions/src/DungeonGame.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import kotlin.math.max import kotlin.math.min data class Room(val currentVal: Int, val lowestVal: Int) { } class DungeonGame { //https://leetcode.com/problems/dungeon-game/submissions/1 fun calculateMinimumHP(dungeon : Array<IntArray>) : Int { val rows = dungeon.size val cols = dungeon.first().siz...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
3,328
leetcode-solutions
MIT License