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
solutions/src/BallMaze.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
class BallMaze { fun shortestDistance(maze: Array<IntArray>, start: IntArray, destination: IntArray) : Int { return dfsMaze(maze, Pair(start[0],start[1]), Pair(destination[0],destination[1]),null, mutableSetOf()) ?: -1 } private fun dfsMaze(maze: Array<IntArray>, start: Pair<Int,Int>, target: Pai...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
2,662
leetcode-solutions
MIT License
src/Day20.kt
MartinsCode
572,817,581
false
{"Kotlin": 77324}
class Mixer(val key: Long = 1L) { // a list of pairs <number, original position> val sequence = mutableListOf<Pair<Long, Int>>() fun input(inp: List<String>) { var counter = 0 inp.forEach { check(it.length <= 5) {"Input line >$it< is longer than 5 characters!"} // still in Int ...
0
Kotlin
0
0
1aedb69d80ae13553b913635fbf1df49c5ad58bd
1,994
AoC-2022-12-01
Apache License 2.0
src/Day16.kt
makohn
571,699,522
false
{"Kotlin": 35992}
import kotlin.math.max fun main() { val day = "16" data class Valve(val idx: Int, val flowRate: Int, val tunnels: List<String>) fun parseInput(input: List<String>) = input .map { Regex("([A-Z]{2}|\\d+)").findAll(it).map { res -> res.value }.toList() } .mapIndexed { idx, res -> res[0] to ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
2,993
aoc-2022
Apache License 2.0
project/src/problems/EuclideanAlgorithm.kt
informramiz
173,284,942
false
null
package problems /** * https://codility.com/media/train/10-Gcd.pdf */ object EuclideanAlgorithm { /** * Returns greatest common divisor of both a and b */ fun gcd(a: Int, b: Int): Int { if (a % b == 0) { return b } return gcd(b, a % b) } /** * Bina...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
10,027
codility-challenges-practice
Apache License 2.0
src/day3/Day03.kt
helbaroudy
573,339,882
false
null
package day3 import readInput fun main() { fun getType(compartment1: String, compartment2: String) = compartment1.first { compartment2.contains(it) } fun Char.toPriority() = if (this >= 'a') { this - 'a' + 1 } else { this - 'A' + 1 + 26 } fun part1(input: List<String>): Int = inp...
0
Kotlin
0
0
e9b98fc0eda739048e68f4e5472068d76ee50e89
1,312
aoc22
Apache License 2.0
2020/src/main/kotlin/de/skyrising/aoc2020/day13/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2020.day13 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.longs.LongArrayList fun modInv(a: Long, b: Long): Long { var a = a var b = b val m = b var q = 0L var x = 0L var y = 1L if (b == 1L) return 0 while (a > 1) { if (b == 1L) { y ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
3,522
aoc
MIT License
src/Day05.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import java.util.SortedSet import kotlin.math.min import kotlin.time.measureTimedValue typealias VMap = Pair<LongRange, Long> fun main() { val input = readInput("Day05") fun String.splitRange(): VMap { val p = split("\\s+".toRegex()) val r = p[2].toLong() val dr = p[0].toLong() //.le...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
7,018
aoc-2023
Apache License 2.0
src/main/kotlin/adventofcode/year2020/Day14DockingData.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.String.replaceAt class Day14DockingData(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val initializationInstructions by lazy { input.lines().map(InitializationInstruction::invoke...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
3,090
AdventOfCode
MIT License
src/Day09.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
data class Step(val dir: Direction, val length: Int) data class Move(val x: Int, val y: Int) enum class Direction(val move: Move) { UP(Move(0, 1)), DOWN(Move(0, -1)), LEFT(Move(-1, 0)), RIGHT(Move(1, 0)); companion object { fun fromString(dir: String): Direction { return when (...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
3,223
aoc2022
Apache License 2.0
src/main/kotlin/days/Day3.kt
sicruse
434,002,213
false
{"Kotlin": 29921}
package days class Day3 : Day(3) { class Diagnostics(data: List<String>) { private val signals: List<Int> by lazy { data.map { Integer.parseInt(it, 2); } } private val numberOfBits = data.first().length // sum the 1 bits across each column of data and if greater than half of the total num...
0
Kotlin
0
0
172babe6ee67a86a7893f8c9c381c5ce8e61908e
3,506
aoc-kotlin-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/biz/koziolek/adventofcode/year2021/day24/day24.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day24 import java.util.* fun main() { val validSerialNumbers = generateValidSerialNumbers() println("Max valid serial number: ${validSerialNumbers.maxOf { it }}") println("Min valid serial number: ${validSerialNumbers.minOf { it }}") } sealed interface VarOrNum ...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
4,625
advent-of-code
MIT License
src/Day02.kt
slawa4s
573,050,411
false
{"Kotlin": 20679}
enum class ResultOfGame(val score: Int) { DEFEAT(0), DRAW(3), WIN(6) } val mapOfScores = hashMapOf( 'X' to 1, 'Y' to 2, 'Z' to 3 ) val mapOfPlayersDraw = hashMapOf( 'X' to 'A', 'Y' to 'B', 'Z' to 'C' ) val mapOfPlayersLose = hashMapOf( 'X' to 'B', 'Y' to 'C', 'Z' to 'A...
0
Kotlin
0
0
cd8bbbb3a710dc542c2832959a6a03a0d2516866
1,838
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day01.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils fun main() { val testInput = """1abc2 pqr3stu8vwx a1b2c3d4e5f treb7uchet""".split("\n") val test2Input = """ two1nine eightwothree abcone2threexyz xtwone3four 4nineeightseven2 zoneight234 7pqrstsixteen """.trimIndent().split("\n") val numbers = mapOf( ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,856
aoc-2022-kotlin
Apache License 2.0
src/2021-Day07.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
import java.lang.Integer.min import kotlin.math.absoluteValue import kotlin.math.roundToInt fun main() { fun part1(input: List<String>): Int { val positions = input[0].trim().split(',').map { it.toInt() }.sorted() val median = positions[positions.size / 2] return positions.sumOf { (it - m...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
1,298
2022-aoc-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortItems.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,175
kotlab
Apache License 2.0
mantono-kotlin/src/main/kotlin/com/mantono/aoc/day06/Orbits.kt
LinAGKar
433,981,631
true
{"Python": 390591, "C#": 189476, "Rust": 166608, "C++": 127941, "F#": 68551, "Haskell": 60413, "Nim": 46562, "Kotlin": 29504, "REXX": 13854, "OCaml": 12448, "Go": 11995, "C": 9751, "Swift": 8043, "JavaScript": 1750, "CMake": 1107, "PowerShell": 866, "AppleScript": 493, "Shell": 255}
package com.mantono.aoc.day06 import com.mantono.aoc.AoC import com.mantono.aoc.Part @AoC(6, Part.A) fun calculateOrbits(input: String): Int { val orbits: Map<String, List<String>> = input.split("\n").asSequence() .map { it.trim().split(")") } .groupBy({ it.first() }, { it.last() }) return co...
0
Python
0
0
4f51eed64ba8fc5254dfa6740c8461f2de1c18a0
1,879
advent_of_code_2019
Apache License 2.0
src/Day02.kt
brste
577,510,164
false
{"Kotlin": 2640}
fun main() { val pointsByShape = mapOf("X" to 1, "Y" to 2, "Z" to 3) val leftBeatsRight = mapOf("Y" to "A", "X" to "C", "Z" to "B") val draw = mapOf("X" to "A", "Y" to "B", "Z" to "C") fun String.beats(other: String): Boolean = other == leftBeatsRight[this] fun String.draw(other: String): Boolean ...
0
Kotlin
0
0
e8d6604575021fef95ad3d31cc8d61e929ac9efa
1,027
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/co/csadev/advent2021/Day15.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 15 * Problem Description: http://adventofcode.com/2021/day/15 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point2D import co.csadev.adventOfCode.Resources.resourceAsList import java.util.PriorityQue...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,396
advent-of-kotlin
Apache License 2.0
src/Day04.kt
saphcarter
573,329,337
false
null
fun main() { fun part1(input: List<String>): Int { var counter = 0 input.forEach { val (firstFrom, firstTo, secondFrom, secondTo) = it.split('-', ',').map(String::toInt) if((firstFrom <= secondFrom && firstTo >= secondTo) || (firstFrom >= secondFrom && firstTo <= secondTo)){...
0
Kotlin
0
0
2037106e961dc58e75df2fbf6c31af6e0f44777f
1,177
aoc-2022
Apache License 2.0
src/Day05.kt
bunjix
573,915,819
false
{"Kotlin": 9977}
fun main() { fun part1(input: List<String>, newCrane: Boolean): String { val (stacksInput, craneStepsInput) = splitInput(input) val stackCount = "(\\d*)\\s\$".toRegex().find(stacksInput.last())?.groupValues.orEmpty().last().toInt() val stacks = mutableListOf<MutableList<Char>>() re...
0
Kotlin
0
0
ee2a344f6c0bb2563cdb828485e9a56f2ff08fcc
2,098
aoc-2022-kotlin
Apache License 2.0
2021/src/day10/Day10.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day10 import readInput fun part1(lines: List<String>) : Int { val chars = mapOf('(' to ')', '[' to ']', '{' to '}', '<' to '>') val points = mapOf(')' to 3, ']' to 57, '}' to 1197, '>' to 25137) var total = 0 for (line in lines) { val stack = mutableListOf<Char>() for (c in l...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,119
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day7.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days import days.Day7.CardAlternate.As import days.Day7.CardAlternate.Joker import days.Day7.HandType.FiveOfKind import days.Day7.HandType.FourOfKind import days.Day7.HandType.FullHouse import days.Day7.HandType.None import days.Day7.HandType.OnePair import days.Day7.HandType.ThreeOfKind import days.Day7.HandT...
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
3,922
AoC-2023
Creative Commons Zero v1.0 Universal
AdventOfCodeDay21/src/nativeMain/kotlin/Day21.kt
bdlepla
451,523,596
false
{"Kotlin": 153773}
class Day21(lines: List<String>) { val food = lines.associate { val (ingredients, allergens) = parseLine(it) ingredients to allergens } val allAllergies = food.values.flatten().toSet() val allIngredients = food.keys.flatten().toSet() fun solvePart2(): String { // for each a...
0
Kotlin
0
0
043d0cfe3971c83921a489ded3bd45048f02ce83
2,395
AdventOfCode2020
The Unlicense
src/year2016/day03/Day03.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2016.day03 import readInput fun main() { val input = readInput("2016", "Day03") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>) = input.parseFromRows().countValidTriangles() private fun part2(input: List<String>) = input.parseFromCols().countValidTriangle...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
928
AdventOfCode
Apache License 2.0
src/Day04.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
fun main() { val parSplit = ',' val rangeSplit = '-' fun getRangeList(input: List<String>) = input .map { fullString -> fullString.split(parSplit).map { it.split(rangeSplit) } } .map { pairs -> pairs.map { it[0].toInt()..it[1].toInt() } } fun part1(input: List<String>): Int { v...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
845
AdventOfCode2022
Apache License 2.0
src/Day09.kt
ThijsBoehme
572,628,902
false
{"Kotlin": 16547}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign fun main() { data class Coordinate(var x: Double, var y: Double) { fun move(direction: String) { when (direction) { "D" -> y -= 1 "U" -> y += 1 "L" -> x -= 1 "R"...
0
Kotlin
0
0
707e96ec77972145fd050f5c6de352cb92c55937
2,700
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/day06/day06.kt
andrew-suprun
725,670,189
false
{"Kotlin": 18354, "Python": 17857, "Dart": 8224}
package day06 import java.io.File import kotlin.math.ceil import kotlin.math.sqrt data class Race(val time: Long, val distance: Long) fun main() { run(::part1, ::solve) run(::part1, ::altSolve) run(::part2, ::solve) run(::part2, ::altSolve) } fun run(part: (String) -> List<Long>, solution: (Race) ->...
0
Kotlin
0
0
dd5f53e74e59ab0cab71ce7c53975695518cdbde
1,458
AoC-2023
The Unlicense
src/main/kotlin/com/hopkins/aoc/day3/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day3 import java.io.File const val debug = true const val part = 2 val digitRange = '0'.rangeTo('9') /** Advent of Code 2023: Day 3 */ fun main() { val inputFile = File("input/input3.txt") val lines: List<String> = inputFile.readLines() if (debug) { // Print the lines ...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
3,929
aoc2023
MIT License
src/Day04a.kt
palex65
572,937,600
false
{"Kotlin": 68582}
private fun String.toRanges() = indexOf(',').let { line -> fun String.toRange() = indexOf('-').let { substring(0,it).toInt() .. substring(it+1).toInt() } substring(0,line).toRange() to substring(line+1).toRange() } operator fun IntRange.contains(b: IntRange) = b.first>=first && b.last<=last private fun part1...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
794
aoc2022
Apache License 2.0
src/main/kotlin/year_2022/Day04.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2022 import utils.readInput fun main() { fun part1(input: List<String>): Int { var sum = 0 input.forEach { val entry = it.split(",") val first = entry.first() val second = entry.last() if (first.isContained(second) || second.isContain...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
1,642
advent-of-code
Apache License 2.0
src/Day23.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
fun Coordinates.neighborsIn(direction: Direction): List<Coordinates> = when (direction) { Direction.Up -> listOf( copy(x = x - 1, y = y - 1), copy(x = x, y = y - 1), copy(x = x + 1, y = y - 1), ) Direction.Down -> listOf( copy(x = x - 1, y = y...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
4,839
AdventOfCode2022
Apache License 2.0
src/main/kotlin/graph/variation/ShortestPathNegEdge.kt
yx-z
106,589,674
false
null
package graph.variation import graph.core.Vertex import graph.core.WeightedEdge import graph.core.WeightedGraph import graph.core.dijkstra import util.min // in the standard Dijkstra's algorithm, we assume all edges are positive // what will happen if there is exactly one negative edge in the graph? // you only need ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,082
AlgoKt
MIT License
codeforces/round580/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round580 fun main() { val n = readInt() val a = List(n) { IntArray(n) } a[0][0] = 1 propagate3(0, 1, 1, 2, a) propagate3(1, 2, 1, 0, a) for (i in a.indices) { for (j in a.indices) { if (i + j in setOf(0, 1, 2 * n - 2) || i == 1 && j == 2) continue val ii = maxOf(i - 2, 0) val jj = i...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,423
competitions
The Unlicense
src/Day01.kt
Nplu5
572,211,950
false
{"Kotlin": 15289}
fun main() { fun mapToIndexedElves(input: List<String>) = input.fold(mutableListOf(Elf())) { elves, line -> when { line.isEmpty() -> elves.apply { add(Elf()) } else -> elves.apply { last().addCalorie(Calorie(line.toInt())) } } }.mapIndexed { index, elf -> index + ...
0
Kotlin
0
0
a9d228029f31ca281bd7e4c7eab03e20b49b3b1c
1,283
advent-of-code-2022
Apache License 2.0
src/day3/Day3.kt
omarshaarawi
573,867,009
false
{"Kotlin": 9725}
package day3 import readInput fun main() { fun part1(): Int { val input = readInput("day3/Day03").map { lines -> val (a, b) = lines.chunked(lines.length / 2) Pair(a.toHashSet(), b.toHashSet()) } val lowercaseAlphabet = ('a'..'z').toMutableList() val upperca...
0
Kotlin
0
0
4347548045f12793a8693c4d31fe3d3dade5100a
1,523
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/year2022/day24/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day24 import IProblem class Problem : IProblem { private val blizzards = mutableListOf<Blizzard>() private val map = javaClass .getResourceAsStream("/2022/24.txt")!! .bufferedReader() .readLines() .mapIndexed { i, line -> line.mapIndexed { j, c -> ...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
2,724
advent-of-code
The Unlicense
src/Day03.kt
phoenixli
574,035,552
false
{"Kotlin": 29419}
fun main() { fun part1(input: List<String>): Int { var sum = 0 input.forEach{ val wrongItem = findWrongItem(it)!! if (wrongItem.isLowerCase()) { sum += wrongItem - 'a' + 1 } else if (wrongItem.isUpperCase()) { sum += wrongItem - 'A...
0
Kotlin
0
0
5f993c7b3c3f518d4ea926a792767a1381349d75
2,034
Advent-of-Code-2022
Apache License 2.0
src/day10/puzzle10.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day10 import Puzzle import PuzzleInput import java.io.File fun day10Puzzle() { Day10PuzzleSolution().solve(Day10PuzzleInput("inputs/day10/example.txt", 13140)) Day10PuzzleSolution().solve(Day10PuzzleInput("inputs/day10/input.txt", 13860)) //Day10Puzzle2Solution().solve(Day10PuzzleInput("inputs/day...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
2,114
aoc_2022
Apache License 2.0
app/src/main/kotlin/day09/Day09.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day09 import common.InputRepo import common.readSessionCookie import common.solve import util.splitIntoPair import kotlin.math.abs fun main(args: Array<String>) { val day = 9 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay09Part1, ::solveDay09Part2) } ...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
3,138
AdventOfCode2022
Apache License 2.0
src/day2/Day02.kt
dinoolivo
573,723,263
false
null
package day2 import readInput fun main() { val scoreMatrixPart1:Array<Array<Int>> = arrayOf(arrayOf(4,8,3), arrayOf(1,5,9), arrayOf(7,2,6)) val scoreMatrixPart2:Array<Array<Int>> = arrayOf(arrayOf(3,4,8,), arrayOf(1,5,9), arrayOf(2,6,7)) fun fromCode(code: String):Int = when (code) { "X", "A...
0
Kotlin
0
0
6e75b42c9849cdda682ac18c5a76afe4950e0c9c
1,171
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/days/Day21.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2021/day/21", date = Date(day = 21, year = 2021) ) class Day21(val input: List<String>) : Puzzle { private val start1 = input[0].substringAfter("Player 1 starting position: ").toInt() private val start2 = input[1].su...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
2,884
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/com/leecode/array/Code2.kt
zys0909
305,335,860
false
null
package com.leecode.array /** 找出数组中重复的数字。 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 示例 1: 输入:[2, 3, 1, 0, 2, 5, 3] 输出:2 或 3 限制:2 <= n <= 100000 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof */ /** * 用一个容器装已经确定的数 ...
0
Kotlin
0
0
869c7c2f6686a773b2ec7d2aaa5bea2de46f1e0b
1,498
CodeLabs
Apache License 2.0
kotlin-samples/src/yitian/study/skilled/collections.kt
techstay
83,331,563
false
null
package yitian.study.skilled fun main(args: Array<String>) { //获取订单数最多的顾客 val customerOfMaxOrder = orders().groupBy { it.customer } .maxBy { it.value.size } ?.key println("获取订单数最多的顾客:$customerOfMaxOrder") //获取订单金额最多的顾客 val customerOfMaxOrderPrice = orders().groupBy { it.cu...
2
Kotlin
0
0
822a02ca42783521ac6f5b5c62c52f0ea4b39ec8
3,255
kotlin-study
MIT License
src/day04/Day04_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day04 import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private fun String.asIntRange(): IntRange =...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,344
aoc2022
Apache License 2.0
src/main/kotlin/day20/Day20.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day20 import java.io.File private const val LIGHT_PIXEL = '#' private const val DARK_PIXEL = '.' fun parseInput(lines: List<String>): Pair<String, List<String>> = lines.first() to lines.drop(2) private fun square3x3(center: Pair<Int, Int>): List<Pair<Int, Int>> = listOf( // sorted according to the par...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
2,385
advent-of-code-2021
MIT License
src/main/kotlin/aoc23/Day05.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day05Domain.Almanac import aoc23.Day05Domain.SeedMapper import aoc23.Day05Parser.toSeedMapper import aoc23.Day05Solution.part1Day05 import aoc23.Day05Solution.part2Day05 import common.Year23 object Day05 : Year23 { fun List<String>.part1(): Long = part1Day05() fun List<String>.part...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
3,836
aoc
Apache License 2.0
src/Day03.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
fun main() { val priority = ('a'..'z') + ('A'..'Z') fun part1(input: List<String>): Int = input .map { it.chunked(it.length / 2) } .map { (first, second) -> val itemsOfFirst = first.asSequence().toSet() val itemsOfSecond = second.asSequence().toS...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
1,260
aoc-2022
Apache License 2.0
src/twentytwentytwo/day3/Day03.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day3 import readInput import kotlin.text.CharCategory.UPPERCASE_LETTER fun main() { fun part1(input: List<String>): Int = input.sumOf { sack -> val firstSack = sack.substring(0, sack.length / 2) val secondSack = sack.substring(sack.length / 2) (firstSack.toSet().int...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,129
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day9.kt
mstar95
317,305,289
false
null
package days class Day9 : Day(9) { override fun partOne(): Any { val input = prepareInput(inputList) val result = calculate(input, 25) return result } private fun calculate(input: List<Long>, log: Int): Long { return (log until input.size).asSequence() .ma...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
1,848
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day14.kt
D000L
575,350,411
false
{"Kotlin": 23716}
import kotlin.math.max class Dropper(input: List<String>) { enum class StopCondition { CantMove, TouchFloor } private val cave = mutableMapOf<Pair<Int, Int>, Char>() private var floorHeight = 0 init { input.forEach { line -> line.filterNot { it.isWhitespace() }.split("->").windowe...
0
Kotlin
0
0
b733a4f16ebc7b71af5b08b947ae46afb62df05e
2,029
adventOfCode
Apache License 2.0
src/main/kotlin/mytechtoday/aoc/year2022/Day4.kt
mytechtoday
572,836,399
false
{"Kotlin": 15268, "Java": 1717}
package mytechtoday.aoc.year2022 import mytechtoday.aoc.util.readInput fun main() { fun String.parsePair() = split("-").let { IntRange(it[0].toInt() , it[1].toInt()) } fun contains(pair:List<IntRange>) : Boolean { return (pair[0].contains(pair[1].first) && pair[0].contains(pair[1].last)) ...
0
Kotlin
0
0
3f25cb010e6367af20acaa2906aff17a80f4e623
1,187
aoc2022
Apache License 2.0
src/Day01.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { fun part1(input: List<String>): Int { val energy = input .map(String::trim) .fold(Pair(listOf<Int>(), 0)) { acc, t -> if (t.trim().isEmpty()) { Pair(acc.first + acc.second, 0) } else { Pair(acc.first...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
1,083
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/binary_tree_right_side_view/BinaryTreeRightSideView.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.binary_tree_right_side_view import datsok.shouldEqual import org.junit.jupiter.api.Test import java.util.* import kotlin.collections.ArrayList // // https://leetcode.com/problems/binary-tree-right-side-view ✅ // // Given a binary tree, imagine yourself standing on the right side of it, /...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,775
katas
The Unlicense
src/Day05.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
data class Instruction( val amount: Int, val fromStack: Int, val toStack: Int ) fun main() { fun splitStacksAndInstructions(input: List<String>): Pair<List<String>, List<String>> { val separator = input.indexOfFirst { it.isEmpty() } return input.subList(0, separator) to input.subList(sep...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
4,054
advent-of-code-2022
Apache License 2.0
src/org/aoc2021/Day5.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.sign object Day5 { data class Vent(val x1: Int, val y1: Int, val x2: Int, val y2: Int) private fun solvePart1(filename: String): Int { val v...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
2,447
advent-of-code-2021
The Unlicense
src/main/kotlin/dev/bogwalk/batch3/Problem39.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.maths.isCoPrime import dev.bogwalk.util.maths.pythagoreanTriplet import dev.bogwalk.util.maths.sum import kotlin.math.ceil import kotlin.math.sqrt /** * Problem 39: Integer Right Triangles * * https://projecteuler.net/problem=39 * * Goal: If P is the perimeter o...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,591
project-euler-kotlin
MIT License
src/main/kotlin/practicecode/coursera/functionalcodingpractice/TaxiParkMain.kt
mnhmasum
556,253,855
false
null
package practicecode.coursera.functionalcodingpractice import practicecode.Driver import practicecode.Passenger import practicecode.TaxiPark import practicecode.Trip fun main() { val taxiPark = TaxiPark( setOf(Driver("D1"), Driver("D2")), setOf(Passenger("P1"), Passenger("P2"), Passenger("P3"), Passenger(...
0
Kotlin
0
0
260b8d1e41c3924bc9ac710bb343107bff748aa0
2,184
ProblemSolvingDaily
Apache License 2.0
src/main/java/challenges/educative_grokking_coding_interview/sliding_window/_9/StringPermutation.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.sliding_window._9 /** * Given a string and a pattern, find out if the string contains any permutation of the pattern. * Permutation is defined as the re-arranging of the characters of the string. For example, “abc” has the following six permutations: * abc * a...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,804
CodingChallenges
Apache License 2.0
src/Day03.kt
BHFDev
572,832,641
false
null
import java.lang.Error fun main() { fun part1(input: List<String>): Int { val priorities = mutableMapOf<Char, Int>() var count = 1 ('a'..'z').forEach { priorities[it] = count++ } ('A'..'Z').forEach { priorities[it] = count++ } return input.sumOf {rucksack -> val...
0
Kotlin
0
0
b158069483fa02636804450d9ea2dceab6cf9dd7
1,481
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/wtf/log/xmas2021/day/day08/Day08.kt
damianw
434,043,459
false
{"Kotlin": 62890}
package wtf.log.xmas2021.day.day08 import com.google.common.collect.Multimap import wtf.log.xmas2021.Day import wtf.log.xmas2021.util.collect.copy import wtf.log.xmas2021.util.collect.multimapOf import java.io.BufferedReader object Day08 : Day<List<Entry>, Int, Int> { override fun parseInput(reader: BufferedRead...
0
Kotlin
0
0
1c4c12546ea3de0e7298c2771dc93e578f11a9c6
5,461
AdventOfKotlin2021
BSD Source Code Attribution
src/Day03.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private fun priority(item: Char): Int { return if (item in 'a'..'z') { item - 'a' + 1 } else if (item in 'A' .. 'Z') { item - 'A' + 27 } else { throw IllegalArgumentException("Unknown priority for item $item") } } private fun part1(input: List<String>): Int { var totalPriori...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
1,601
advent-of-code-2022
Apache License 2.0
src/Day05.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
import java.util.ArrayDeque fun parseStacks(input: List<String>): MutableList<ArrayDeque<String>> { val stackIdPattern = Regex("^(\\s+\\d)+$") val stacks = mutableListOf(ArrayDeque<String>()) val crateNameFilter = Regex("[^A-Z]") // parse input lines until we reach something that looks like " 1 2 ...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
2,145
advent-of-code-2022
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day15.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution object Day15 : AdventSolution(2016, 15, "Timing is Everything") { override fun solvePartOne(input: String) = calulateWaitingTime(parseConfig(input)).toString() override fun solvePartTwo(input: String) = calulateWaitingTime(parseConfig(input) + Disc(11...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,677
advent-of-code
MIT License
src/Day12.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
import java.util.PriorityQueue import kotlin.math.sqrt fun main() { val startSymbol = 'S' val endSymbol = 'E' fun Pair<Int, Int>.distance(other: Pair<Int, Int>) = sqrt(0.0 + (this.first - other.first) * (this.first - other.first) + (this.second - other.second) * (this.second - other.second)) ...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
4,513
advent-of-code-2022
Apache License 2.0
src/Day10.kt
hufman
573,586,479
false
{"Kotlin": 29792}
import kotlin.math.absoluteValue sealed class CPUOpcode(val cycles: Int) { companion object { fun fromLine(line: String): CPUOpcode? { val parts = line.split(' ') return when (parts[0]) { "noop" -> NOOP() "addx" -> ADDX(parts[1].toInt()) ...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
2,368
aoc2022-kt
Apache License 2.0
src/Day02.kt
felldo
572,233,925
false
{"Kotlin": 76496}
enum class RPC(val points: Int, val opponent: String, val self: String) { ROCK(1, "A", "X"), PAPER(2, "B", "Y"), SCISSORS(3, "C", "Z"); companion object { fun getByName(x: String): RPC { for (value in values()) { if (value.opponent == x || value.self == x) { ...
0
Kotlin
0
0
0ef7ac4f160f484106b19632cd87ee7594cf3d38
1,806
advent-of-code-kotlin-2022
Apache License 2.0
src/Day06.kt
ajspadial
573,864,089
false
{"Kotlin": 15457}
fun main() { fun areDistinctCharacters(s: String): Boolean { var distinct = true for (i in 0 until s.length) { if (s[i] in s.substring(i + 1)) { distinct = false break } } return distinct } fun findFirstDistinctPacka...
0
Kotlin
0
0
ed7a2010008be17fec1330b41adc7ee5861b956b
1,493
adventofcode2022
Apache License 2.0
src/Day02.kt
jalex19100
574,686,993
false
{"Kotlin": 19795}
// X > C, Z > B, Y > A, X=A, Y=B, Z=C enum class HandShape( val desc: String, private val defeats: Char, private val ties: Char, private val shapeValue: Int ) { X("Rock", 'C', 'A', 1), Y("Paper", 'A', 'B', 2), Z("Scissors", 'B', 'C', 3); fun play(opponentShape: Char): Int { val score = when...
0
Kotlin
0
0
a50639447a2ef3f6fc9548f0d89cc643266c1b74
2,195
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/Day03.kt
zychu312
573,345,747
false
{"Kotlin": 15557}
fun Char.toPriority(): Int = when (this.category) { CharCategory.UPPERCASE_LETTER -> this.code - 'A'.code + 'z'.toPriority() + 1 CharCategory.LOWERCASE_LETTER -> this.code - 'a'.code + 1 else -> error("Wrong letter") } infix fun String.toCompartment(range: IntRange) = this.substring(range).toCharArray().t...
0
Kotlin
0
0
3e49f2e3aafe53ca32dea5bce4c128d16472fee3
1,282
advent-of-code-kt
Apache License 2.0
2021/src/main/kotlin/Day20.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day20(val input: List<String>) { private val algorithm = input[0].map { it == '#' }.toTypedArray() private val image = input[1].split("\n").map { line -> line.map { it == '#' }.toTypedArray() }.toTypedArray() private fun Array<Array<Boolean>>.getAt(x: Int, y: Int, unknown: Boolean): Boo...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,897
adventofcode-2021-2025
MIT License
src/com/ncorti/aoc2023/Day13.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 fun main() { fun parseInput() = getInputAsText("13") { split("\n\n").filter(String::isNotBlank).map { it.split("\n").filter(String::isNotBlank).map { line -> line.toCharArray() }.toTypedArray() } } fun hasSmudgeInCol(map: ...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
4,408
adventofcode-2023
MIT License
src/main/kotlin/day11/Day11.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day11 import java.io.File fun main() { val data = parse("src/main/kotlin/day11/Day11.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 11 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
2,704
advent-of-code-2022
MIT License
src/Day09.kt
punx120
573,421,386
false
{"Kotlin": 30825}
import java.lang.RuntimeException import kotlin.math.abs fun main() { fun moveHead(pos : Pair<Int, Int>, direction : Pair<Int, Int>) : Pair<Int, Int> { return Pair(pos.first + direction.first, pos.second + direction.second) } fun moveTail(hp: Pair<Int, Int>, tp: Pair<Int, Int>): Pair<Int, Int> { ...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
2,758
aoc-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day04.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 4 - Giant Squid * Problem Description: http://adventofcode.com/2021/day/4 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day4/ */ package com.ginsberg.advent2021 typealias BingoBoard = List<List<Int>> class Day04(in...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,879
advent-2021-kotlin
Apache License 2.0
src/Day09.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { var h = Pair(0, 0) var t = Pair(0, 0) val visited = mutableSetOf(t) for (line in input) { val (direction, steps) = line.split(" ") for (step in 1..steps.toInt()) { ...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
4,081
AoC-2022
Apache License 2.0
src/main/kotlin/day11/Day11.kt
Arch-vile
317,641,541
false
null
package day11 import readFile fun straightLineOffsets(xOffset: Int, yOffset: Int): Sequence<Pair<Int, Int>> { var x = xOffset var y = yOffset return sequence { while (true) { yield(Pair(x, y)) x += xOffset y += yOffset } } } fun main(args: Array<String>) { val input = readFile("....
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
2,936
adventOfCode2020
Apache License 2.0
src/Day03.kt
kipwoker
572,884,607
false
null
fun main() { fun getPriority(ch: Char): Long { if (ch in 'A'..'Z') { return ch - 'A' + 27L } return ch - 'a' + 1L } fun part1(input: List<String>): Long { return input.sumOf { line -> line .chunkedSequence(line.length / 2) ...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
1,209
aoc2022
Apache License 2.0
src/com/ajithkumar/aoc2022/Day07.kt
ajithkumar
574,372,025
false
{"Kotlin": 21950}
package com.ajithkumar.aoc2022 import com.ajithkumar.utils.* sealed interface FileSystemNode { fun size() :Int } class File(val name: String, private val size: Int): FileSystemNode { override fun size(): Int = size } class Directory(val name: String, val children: MutableList<FileSystemNode>): FileSystemNode ...
0
Kotlin
0
0
f95b8d1c3c8a67576eb76058a1df5b78af47a29c
3,651
advent-of-code-kotlin-template
Apache License 2.0
src/Day05.kt
raneric
573,109,642
false
{"Kotlin": 13043}
var stackSourceIndex = -1 var stackDestinationIndex = -1 fun main() { fun part1(input: List<String>): String { val stackList = getStackList(input) val moveIndex = stackList.size + 2 val procedure = getMoveList(moveIndex, input) val stackNb = input[moveIndex - 2].trim().split(" ").la...
0
Kotlin
0
0
9558d561b67b5df77c725bba7e0b33652c802d41
3,104
aoc-kotlin-challenge
Apache License 2.0
src/main/aoc2019/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2019 import kotlin.math.pow class Day24(input: List<String>) { // level 0 is same level, -1 or 1 is one lower or higher level private data class Tile(val level: Int, val index: Int) private val parsedInput = input.joinToString("") .replace('.', '0') .replace('#', '1') ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
4,701
aoc
MIT License
src/Day04.kt
hanmet
573,490,488
false
{"Kotlin": 9896}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (i in input) { var leftContainsRight = true var rightContainsLeft = true val sections = i.split(",") .map { it.split("-") } val left = sections[0][0].toInt()..sections[...
0
Kotlin
0
0
e4e1722726587639776df86de8d4e325d1defa02
1,642
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day4.kt
clechasseur
435,726,930
false
{"Kotlin": 315943}
package io.github.clechasseur.adventofcode2021 import io.github.clechasseur.adventofcode2021.data.Day4Data object Day4 { private val data = Day4Data.data fun part1(): Int { val game = Game(data.lines()) for (draw in game.draws) { game.cards.forEach { it.mark(draw) } va...
0
Kotlin
0
0
4b893c001efec7d11a326888a9a98ec03241d331
2,415
adventofcode2021
MIT License
src/cn/leetcode/codes/simple18/Simple18.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple18 import cn.leetcode.codes.out import java.util.* fun main() { // val nums = intArrayOf(1, 0, -1, 0, -2, 2) val nums = intArrayOf(-2,-1,-1,1,1,2,2) // val nums = intArrayOf(1,0,-1,0,-2,2) // val s = fourSum(nums, 0) // [[-2, -1, 1, 2], [-1, -1, 1, 1]] val s2 = Simpl...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
3,124
LeetCodeSimple
Apache License 2.0
src/Day09.kt
6234456
572,616,769
false
{"Kotlin": 39979}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign import kotlin.math.sin data class Pos(val x: Int, val y: Int){ fun move(direction: Char):Pos { return when(direction){ 'R' -> copy(x = x + 1) 'L' -> copy(x= x - 1) 'U' -> copy(y = y - 1) '...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
2,311
advent-of-code-kotlin-2022
Apache License 2.0
src/aoc2022/day07/AoC07.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day07 import readLines interface AnElement { val name: String var size: Int } class AFile( override val name: String, override var size: Int, ) : AnElement class ADir( override val name: String, ) : AnElement { override var size: Int = 0 private val content = HashMap<String, AnElement>() var...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
2,018
aoc2022
Apache License 2.0
src/main/kotlin/days/day05.kt
josergdev
573,178,933
false
{"Kotlin": 20792}
package days import java.nio.file.Files import java.nio.file.Paths import java.util.* fun parseCrates(crates: String) = crates.split("\n").dropLast(1) .map { it.windowed(3,4) } .map { it.map { s -> s.trim(' ', '[', ']') } } .foldRight(mapOf<Int, Stack<String>>()) { line, cratesAcc -> line.foldInde...
0
Kotlin
0
0
ea17b3f2a308618883caa7406295d80be2406260
2,012
aoc-2022
MIT License
day4/src/main/kotlin/com/lillicoder/adventofcode2023/day4/Day4.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day4 import kotlin.math.pow fun main() { val day4 = Day4() val cards = ScratchcardParser().parse("input.txt") println("The total score of the given scratchcards is ${day4.part1(cards)}.") println("The total count of cards, including clones, is ${day4.part2(cards...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
3,987
advent-of-code-2023
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day22.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 22 - Reactor Reboot * Problem Description: http://adventofcode.com/2021/day/22 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day22/ */ package com.ginsberg.advent2021 class Day22(input: List<String>) { private...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
2,048
advent-2021-kotlin
Apache License 2.0
src/main/kotlin/g2601_2700/s2699_modify_graph_edge_weights/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2601_2700.s2699_modify_graph_edge_weights // #Hard #Heap_Priority_Queue #Graph #Shortest_Path // #2023_07_29_Time_1592_ms_(40.00%)_Space_65.3_MB_(60.00%) import java.util.PriorityQueue class Solution { private inner class Edge(var s: Int, var d: Int, var wt: Int) private lateinit var g: Array<ArrayL...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,687
LeetCode-in-Kotlin
MIT License
src/Day13.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
fun main() { class Container { var items: MutableList<Container>? = null var value: Int = -1 var parent: Container? = null fun addContainer(container: Container) { if (items == null) { items = mutableListOf() } items?.add(containe...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
3,444
AdventCode2022
Apache License 2.0
src/main/kotlin/Day18.kt
pavittr
317,532,861
false
null
import java.io.File import java.nio.charset.Charset fun main() { fun calc(ops: List<String> ) : Long { val init = ops.take(1).first().toLong() val output = ops.drop(1).windowed(2, 2, false) .map { Pair(it[0], it[1].toInt()) }.fold(init) {acc, op -> when(op.first) { ...
0
Kotlin
0
0
3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04
2,152
aoc2020
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindMedianSortedArrays.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,202
kotlab
Apache License 2.0
src/Day04.kt
ElenaRgC
572,898,962
false
null
fun main() { fun part1(input: List<String>): Int { val rangos = input .map { it.split(",") } .flatMap { it.map { it.split("-") } } .flatMap { it.map { it.toInt() } } var paresContenidos = 0 var inicioRango1 = 0 var finRango1 = 0 var inicioRango2 = 0 ...
0
Kotlin
0
0
b7505e891429970c377f7b45bfa8b5157f85c457
1,929
advent-of-code-2022
Apache License 2.0
src/Day12.kt
MartinsCode
572,817,581
false
{"Kotlin": 77324}
fun main() { fun find(c: Char, map: List<String>): Pair<Int, Int> { var position = Pair(-1, -1) for (y in map.indices) { for (x in map[y].indices) { if (map[y][x] == c) { position = Pair(x, y) } } } return po...
0
Kotlin
0
0
1aedb69d80ae13553b913635fbf1df49c5ad58bd
7,109
AoC-2022-12-01
Apache License 2.0
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day03/Day03.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2022.day03 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { return input .asSequence() .map { line -> line.take((line.length / 2)) to line.takeLast(line.length / 2) }...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
1,530
AOC
Apache License 2.0
kotlin/src/com/leetcode/152_MaximumProductSubarray.kt
programmerr47
248,502,040
false
null
package com.leetcode import kotlin.math.max import kotlin.math.min /** * Building 2d matrix with products, where products[i][j] is a product from j to i * * Time complexity: O(n^2), Space complexity: O(n^2) */ private class Solution152 { fun maxProduct(nums: IntArray): Int { if (nums.isEmpty()) return...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
2,201
problemsolving
Apache License 2.0
src/main/kotlin/days/Day11.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day11 : Day(11) { override fun partOne(): Any { val monkeys = parseMonkeys().map { monkeyPartTwo -> MonkeyPartOne( monkeyPartTwo.id, monkeyPartTwo.items.map { it.entries.first().value }.let { ArrayDeque(it) }, monkeyPartTwo.ope...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
4,398
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day16.kt
SergeiMikhailovskii
573,781,461
false
{"Kotlin": 32574}
fun main() { val timeLimit = 26 class Valve( val rate: Int, val tunnels: List<String>, ) class PathB( val valvesMe: List<Valve>, val valvesElephant: List<Valve>, /** * Key - valve * value - opened time */ val opened: Map<Valve...
0
Kotlin
0
0
c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d
4,040
advent-of-code-kotlin
Apache License 2.0
src/Day01.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
fun main() { fun part1(input: List<String>): Int { return input.fold(Pair(0, 0)) { max, curr -> val subTotal = if (curr.isEmpty()) max.second else max.second + curr.toInt() Pair(if (max.first > subTotal) max.first else subTotal, if (curr.isEmpty()) 0 else subTotal) }.first ...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
942
advent-of-code-2022
Apache License 2.0
src/day07/Day07.kt
sanyarajan
572,663,282
false
{"Kotlin": 24016}
package day07 import readInput // class to represent an ElfFile that has a name and size class ElfFile(private val name: String, val size: Int) { override fun toString(): String { return "$name (file, size=$size)" } } // class to represent a folder that has a name and a list of ElfFiles and Folders ...
0
Kotlin
0
0
e23413357b13b68ed80f903d659961843f2a1973
3,571
Kotlin-AOC-2022
Apache License 2.0