path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/leetcode/Problem1895.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import kotlin.math.max /** * https://leetcode.com/problems/largest-magic-square/ */ class Problem1895 { fun largestMagicSquare(grid: Array<IntArray>): Int { val maxRow = grid.size val maxCol = if (maxRow > 0) grid[0].size else 0 val rowSums = Array(maxRow) { IntArray(max...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
3,601
leetcode
MIT License
src/Day02.kt
BjornstadThomas
572,616,128
false
{"Kotlin": 9666}
fun main() { fun calcualteValueOfMove(input: String): Int { var AlvMove = 0 var HumanMove = 0 // println(input[0]) when (input[0]) { 'A' -> AlvMove = 1 'B' -> AlvMove = 2 'C' -> AlvMove = 3 } when (input[2]) { 'X' ->...
0
Kotlin
0
0
553e3381ca26e1e316ecc6c3831354928cf7463b
3,280
AdventOfCode-2022-Kotlin
Apache License 2.0
src/aoc2023/Day16.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput fun main() { val (year, day) = "2023" to "Day16" fun energizedTiles(layout: List<String>, startBeam: Beam): Int { val rows = layout.size val cols = layout.first().length val energized = Array(rows) { BooleanArray(cols) } v...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
4,183
aoc-kotlin
Apache License 2.0
src/Day18.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
data class Cube3D(val x: Int, val y: Int, val z: Int) { private fun toList() = listOf(x, y, z) constructor(list: List<Int>) : this(list[0], list[1], list[2]) private operator fun get(index: Int) = toList()[index] fun adjacentBlock(side: Int): Cube3D { val coordinates = this.toList().toMutable...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
3,102
advent-of-code-kotlin-2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day21.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year21 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.repeatInfinitely import com.grappenmaker.aoc.splitInts import kotlin.math.max fun PuzzleSet.day21() = puzzle(day = 21) { val (startOne, startTwo) = inputLines.map { it.splitInts().last() } data class PlayerSt...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,429
advent-of-code
The Unlicense
src/day18/Day18.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day18 import readInput import java.util.Stack fun main() { data class Coord( val x: Int, val y: Int, val z: Int ) fun List<String>.toCoordsSet(): Set<Coord> { return buildSet { this@toCoordsSet.forEach { add( it.spli...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
3,065
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
llama-0
574,081,845
false
{"Kotlin": 6422}
enum class Goal(val value: Char) { Win('Z'), Loose('X'), Draw('Y'), } enum class Variant(val value: Char) { Rock('A'), Paper('B'), Scissors('C') } fun main() { val outcomesForSecond = mapOf( Pair('A', 'A') to 4, // Pair('A', 'B') to 8, Pair('A', 'C') to 3, ...
0
Kotlin
0
0
a3a9a07be54a764a707ab25332a9f324cb84ac2a
2,481
AoC-2022
Apache License 2.0
src/Day16.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day16.run { solve1(1651) // 1638 solve2(1707) // 2400 } }.let { println("Total: $it ms") } } object Day16 : Day.LineInput<Day16.Data, Int>("16") { data class Data(private val valves: List<Valve...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
2,878
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day12.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 import kotlin.math.absoluteValue class Day12(private val input: List<String>) { fun solvePart1(initialState: AbsoluteState): Int { val finalState = input.fold(initialState) { state, instruction -> state + Instruction(instruction) } return manhattanDistance(in...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
3,119
advent-of-code
Apache License 2.0
src/Day09.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
fun main() { val input = readInput("Day09") println(Day09.part1(input)) println(Day09.part2(input)) } data class HeadMovement(val direction: Direction, val steps: Int) enum class Direction { U, R, D, L, } class Day09 { companion object { fun part1(input: List<String>): Int { retur...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
1,865
advent-of-code-22
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-22.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import java.util.LinkedList import kotlin.math.max import kotlin.math.min fun main() { val input = readInputLines(2023, "22-input") val test1 = readInputLines...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,258
advent-of-code
MIT License
src/Day05.kt
Arclights
574,085,358
false
{"Kotlin": 11490}
fun main() { fun part1(input: Input): String = input .instructions .fold(input.stacks) { stacks, (move, from, to) -> stacks[to - 1] = stacks[to - 1].plus(stacks[from - 1].takeLast(move).reversed()) stacks[from - 1] = stacks[from - 1].dropLast(move) stacks ...
0
Kotlin
0
0
121a81ba82ba0d921bd1b689241ffa8727bc806e
2,071
advent_of_code_2022
Apache License 2.0
src/aoc2022/Day07.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 fun main() { fun ArrayDeque<String>.toPWDs(): List<String> = runningReduce { pwdAcc, curDir -> pwdAcc + curDir } fun Map<String, Int>.getDeviceFreeSpace(): Int = (70_000_000 - this.getValue("/")) fun List<String>.readDirsSizes(): Map<String, Int> { val filesStack = ArrayDeque(li...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,676
Kotlin-AOC-2023
Apache License 2.0
src/nativeMain/kotlin/Day13.kt
rubengees
576,436,006
false
{"Kotlin": 67428}
import Day13.Tree.Node import Day13.Tree.Num import kotlin.math.max class Day13 : Day { private sealed class Tree { class Num(val value: Int) : Tree() class Node(vararg val items: Tree) : Tree(), Comparable<Node> { override fun compareTo(other: Node): Int { val otherNum...
0
Kotlin
0
0
21f03a1c70d4273739d001dd5434f68e2cc2e6e6
3,256
advent-of-code-2022
MIT License
src/Day17.kt
er453r
572,440,270
false
{"Kotlin": 69456}
import kotlin.math.min fun main() { val blockShapes = """#### .#. ### .#. ..# ..# ### # # # # ## ##""" class Block(val points: List<Vector2d>) { fun move(vector2d: Vector2d) = points.forEach { it.increment(vector2d) } fun collides(other: Set<Vector2d>) = points.any { it in other } ...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
3,403
aoc2022
Apache License 2.0
2021/src/main/kotlin/day12_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution fun main() { Day12Fast.run() } object Day12All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day12Func, "imp" to Day12Imp, "fast" to Day12Fast).forEach { (header, solution) -> solution.run(header = header, skipPart1 = false, skipTest = false, prin...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,963
aoc_kotlin
MIT License
src/day23/Day23.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day23 import Coordinate import maxEach import minEach import readInput const val day = "23" val directions = listOf( Triple(Coordinate(-1, -1), Coordinate(0, -1), Coordinate(1, -1)), // N Triple(Coordinate(-1, 1), Coordinate(0, 1), Coordinate(1, 1)), // S Triple(Coordinate(-1, -1), Coordin...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
4,698
advent-of-code-22-kotlin
Apache License 2.0
src/Day09.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
import kotlin.math.absoluteValue import kotlin.math.max data class Point(var x: Int, var y: Int) { companion object { fun zero() = Point(0, 0) } operator fun plusAssign(vector: Vector) { x += vector.dx y += vector.dy } operator fun minus(other: Point): Vector { ret...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
2,919
aoc-2022
Apache License 2.0
advent-of-code-2022/src/Day05.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import java.util.* // Use run { ... } to reuse the same local variables names :P fun main() { run { val (testStacks, testCommands) = readInput("Day05_test") check(part1(testStacks.clone(), testCommands) == "CMZ") val (inputStacks, inputCommands) = readInput("Day05") println("Part 1...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,168
advent-of-code
Apache License 2.0
src/Day19.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import java.util.LinkedList import kotlin.math.max import kotlin.math.min typealias Workflow = Map<String, List<String>> typealias PartRange = Array<IntRange> fun initPartRange(i: Int) = arrayOf(1..i, 1..i, 1..i, 1..i) fun initWorkflow(input: Input): Workflow { return input.takeWhile { it.isNotEmpty() }.associat...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
4,133
aoc-2023
Apache License 2.0
src/aoc2023/Day15.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2023 import utils.checkEquals import utils.readInput fun main(): Unit = with(Day15) { part1(testInput.first()).checkEquals(52) part1(testInput[1]).checkEquals(1320) part1(input.single()) .checkEquals(516657) // .sendAnswer(part = 1, day = "15", year = 2023) part2(testInput[...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,904
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/org/sj/aoc2022/day05/CrateReArranger.kt
sadhasivam
573,168,428
false
{"Kotlin": 10910}
package org.sj.aoc2022.day05 import org.sj.aoc2022.util.readInput fun rearrange(crates: List<MutableList<String>>, count: Int, from: Int, to: Int, inOrder: Boolean) { val fromCrate = crates[from] val toCrate = crates[to] val toCrateSize = toCrate.size repeat(count) { if (inOrder) { ...
0
Kotlin
0
0
7a1ceaddbe7e72bad0e9dfce268387d333b62143
2,152
advent-of-code-kotlin-2022
Apache License 2.0
src/Day07.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { // Returns root directory fun setupFileSystem(input: List<String>): Directory { // Setup root val root = Directory("/", null) var currentDir = root // Run through commands for(line in input) { val split = line.split(' ') if (split[0] ...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
2,603
aoc2022
Apache License 2.0
src/Day03.kt
rinas-ink
572,920,513
false
{"Kotlin": 14483}
import java.lang.IllegalArgumentException fun main() { fun evalLetter(c: Char) = 1 + if (c - 'a' + 1 > 0) c - 'a' else c - 'A' + 26 fun evalStep1(s: String): Int { val comp1: CharArray = s.substring(0, s.length / 2).toCharArray() comp1.sort() val comp2: CharArray = s.substring(s.le...
0
Kotlin
0
0
462bcba7779f7bfc9a109d886af8f722ec14c485
1,334
anvent-kotlin
Apache License 2.0
src/Day10.kt
FuKe
433,722,611
false
{"Kotlin": 19825}
import java.util.* private val pointMap: Map<String, Int> = mapOf( ")" to 3, "]" to 57, "}" to 1197, ">" to 25137 ) private val closes: Map<String, String> = mapOf( "(" to ")", "[" to "]", "{" to "}", "<" to ">" ) fun main() { test() val puzzleInput: List<String> = readInput(...
0
Kotlin
0
0
1cfe66aedd83ea7df8a2bc26c453df257f349b0e
1,537
advent-of-code-2021
Apache License 2.0
src/day08/Day08.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day08 import readInput import java.lang.Integer.max /** * indicates the highest tree to the left/up/right/down from this position */ data class HeightLookup(var left: Int, var up: Int, var right: Int, var down: Int) fun main() { fun copyOuterTreeRing( lookupHeights: Array<Array<HeightLookup>>,...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
5,942
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode/year2023/Day07CamelCards.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2023 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.year2023.Day07CamelCards.Companion.HandType.FIVE_OF_A_KIND import adventofcode.year2023.Day07CamelCards.Companion.HandType.FOUR_OF_A_KIND import adventofcode.year2023.Day07CamelCards.Companion.HandType.FULL_HOU...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,868
AdventOfCode
MIT License
kotlin/src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day24Test.kt
dirkgroot
724,049,902
false
{"Kotlin": 203339, "Rust": 123129, "Clojure": 78288}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith private fun solution1(input: String) = Valley.parse(input).let { valley -> generateSequence(valley...
1
Kotlin
0
0
ced913cd74378a856813973a45dd10fdd3570011
4,547
adventofcode
MIT License
src/main/kotlin/days/Day7.kt
minibugdev
322,172,909
true
{"Kotlin": 17258}
package days class Day7 : Day(7) { private val bags = transformInputToBags(inputList) override fun partOne(): Any { fun searchBag(name: String): Set<Bag> { val containerBags = bags.filter { bag -> bag.contains?.keys?.contains(Bag(name, null)) == true }.toSet() return if (containerBags.isNotEmpty())...
0
Kotlin
0
1
572f6b5620c87a41d90f1474b5e89eddb903fd6f
1,398
aoc-kotlin-starter
Creative Commons Zero v1.0 Universal
src/aoc2022/Day03.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import println import readInput fun main() { fun priority(c: Char): Int { if (c in 'A'..'Z') { return c - 'A' + 27 } else if (c in 'a'..'z') { return c - 'a' + 1 } return 0 } fun part1(input: List<String>): Int { var sum = 0 ...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
1,504
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/aoc2022/Day24.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import Point import readInput import kotlin.math.min object Day24 { private enum class Direction(val delta: Point) { NORTH(Point(0, -1)), SOUTH(Point(0, 1)), EAST(Point(1, 0)), WEST(Point(-1, 0)); override fun toString() = when (this) { NORTH -> "^" SOUTH ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
5,457
adventOfCode
Apache License 2.0
src/Day01.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader import java.util.SortedSet fun main() { val testInput = """ 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 """.trimIndent() check( partOne(countCalories(testInput.reader())) == 24000 )...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
1,687
advent-of-code-2022-kotlin
Apache License 2.0
src/Day03.kt
bogdanbeczkowski
572,679,090
false
{"Kotlin": 8398}
fun main() { fun part1(input: List<String>): Int { var priority = 0 for (line in input) { val compartmentLength = line.length / 2 val compartments = line.chunked(compartmentLength) val first = compartments.first().toCharArray() val second = compartment...
0
Kotlin
0
0
03c29c7571e0d98ab00ee5c4c625954c0a46ab00
1,644
AoC-2022-Kotlin
Apache License 2.0
src/main/kotlin/Day3.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
fun puzzleDayThreePartOne() { val inputs = readInput(3) val totalInputs = inputs.size val chunkSize = inputs[0].length val mostSignificant = (0 until chunkSize).joinToString(separator = "") { index -> val oneCount = inputs.map { it[index] }.count { char -> char == '1' } if (oneCount > ...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
1,520
advent-of-kotlin-2021
Apache License 2.0
src/main/kotlin/day18/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day18 import util.readTestInput private data class Coord3d(val x: Int, val y: Int, val z: Int) { fun neighbors(): List<Coord3d> = listOf( copy(x = x + 1), copy(x = x - 1), copy(y = y + 1), copy(y = y - 1), copy(z = z + 1), copy(z = z - 1) ) companio...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
2,062
advent-of-code-2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountSubgraphsForEachDiameter.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,663
kotlab
Apache License 2.0
src/Day03.kt
BrianEstrada
572,700,177
false
{"Kotlin": 22757}
fun main() { // Test Case val testInput = readInput("Day03_test") val part1TestResult = Day03.part1(testInput) println(part1TestResult) check(part1TestResult == 157) val part2TestResult = Day03.part2(testInput) println(part2TestResult) check(part2TestResult == 70) // Actual Case ...
1
Kotlin
0
1
032a4693aff514c9b30e979e63560dc48917411d
1,767
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2022/d07/Day07.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d07 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines sealed class File { abstract val name: String } data class RegularFile(override val name: String, val size: Int) : File() { override fun toS...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,899
advent-of-code
MIT License
src/main/kotlin/aoc2018/ImmuneSystemSimulator.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2018 import komu.adventofcode.utils.nonEmptyLines import java.util.* fun immuneSystemSimulator1(input: String): Int { val (x, y) = runSimulation(input, boost = 0) return maxOf(x, y) } fun immuneSystemSimulator2(input: String): Int { var min = 0 var max = 1_000_000 wh...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
5,332
advent-of-code
MIT License
src/main/kotlin/Day15.kt
SimonMarquis
570,868,366
false
{"Kotlin": 50263}
import kotlin.math.absoluteValue import kotlin.math.max class Day15(input: List<String>) { private val regex = """x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)""".toRegex() private val sensorsToBeacons = input.map { regex.find(it)!!.destructured.toList().map(String::toInt) }.map { (sensorX, sensorY,...
0
Kotlin
0
0
a2129cc558c610dfe338594d9f05df6501dff5e6
2,035
advent-of-code-2022
Apache License 2.0
src/day4/Day04.kt
ousa17
573,435,223
false
{"Kotlin": 8095}
package day4 import readInput fun main() { val input = readInput("day4/Day04") part1(input) part2(input) } private fun part1(input: List<String>) { val sum = input.map { it.split(",").let { (firstElfRange, secondElfRange) -> firstElfRange.toRange() to secondElfRange.toRange() ...
0
Kotlin
0
0
aa7f2cb7774925b7e88676a9ca64ca9548bce5b2
1,031
advent-day-1
Apache License 2.0
src/year2023/08/Day08.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`08` import readInput import utils.lcm import utils.printlnDebug private const val CURRENT_DAY = "08" private data class Node( val data: String, val left: String, val right: String, ) private fun parseLineIntoNode(line: String): Node { val a = line.substring(0, 3) val b = line....
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,363
KotlinAdventOfCode
Apache License 2.0
src/main/kotlin/g1801_1900/s1895_largest_magic_square/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1895_largest_magic_square // #Medium #Array #Matrix #Prefix_Sum #2023_06_22_Time_202_ms_(100.00%)_Space_36.7_MB_(100.00%) class Solution { fun largestMagicSquare(grid: Array<IntArray>): Int { val m = grid.size val n = grid[0].size val rows = Array(m) { IntArray(n + 1) }...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,858
LeetCode-in-Kotlin
MIT License
scripts/Day15.kts
matthewm101
573,325,687
false
{"Kotlin": 63435}
import java.io.File import kotlin.math.absoluteValue data class Interval(val a: Int, val b: Int) { val size = b - a + 1 fun tryMerge(other: Interval): Interval? { if (a <= other.a && other.b <= b) return this if (other.a <= a && b <= other.b) return other if (other.a in a..b) return In...
0
Kotlin
0
0
bbd3cf6868936a9ee03c6783d8b2d02a08fbce85
3,127
adventofcode2022
MIT License
src/Day02.kt
yeung66
574,904,673
false
{"Kotlin": 8143}
fun main() { val winRelations = hashMapOf(0 to 2, 1 to 0, 2 to 1) fun part1(input: List<Pair<Int, Int>>): Int { return input.sumOf { val (theirs, yours) = it val score = when (theirs) { yours -> 3 winRelations[yours]!! -> 6 else ->...
0
Kotlin
0
0
554217f83e81021229759bccc8b616a6b270902c
1,129
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc/year2023/Day08.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2023 import aoc.Puzzle import kotlin.math.abs /** * [Day 8 - Advent of Code 2023](https://adventofcode.com/2023/day/8) */ object Day08 : Puzzle<Int, Long> { override fun solvePartOne(input: String): Int { val (instructions, network) = processInput(input) return instructions.asIn...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
2,214
advent-of-code
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day18.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput import kotlin.math.absoluteValue fun main() { val input = readInput(2023, 18).readLines() part1(input) part2(input) } private fun part1(input: List<String>) { evaluate(input) { entry -> val (direct...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,597
adventofcode
Apache License 2.0
src/Day24.kt
syncd010
324,790,559
false
null
import kotlin.math.sqrt class Day24: Day { private fun convert(input: List<String>) : IntArray { return input.map { line -> line.mapNotNull { c -> when (c) { '.', '?' -> 0; '#' -> 1; else -> null } }.toIntArray() }.reduce {...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
4,756
AoC2019
Apache License 2.0
src/Day04.kt
baghaii
573,918,961
false
{"Kotlin": 11922}
fun main() { fun part1(input: List<String>): Int { var overlap = 0 input.forEach{ line -> val ranges = line.split(",") val firstAssignment = ranges[0].split("-").map{it.toInt()} val secondAssignment = ranges[1].split("-").map{it.toInt()} if (firstAssi...
0
Kotlin
0
0
8c66dae6569f4b269d1cad9bf901e0a686437469
1,542
AdventOfCode2022
Apache License 2.0
src/day01/Day01.kt
AbolfaZlRezaEe
574,383,383
false
null
package day01 import readInput fun main() { fun part01(lines: List<String>): Int { var sumOfCalories = 0 var finalResult = 0 lines.forEach { line -> if (line.isEmpty()) { if (sumOfCalories > finalResult) { finalResult = sumOfCalories ...
0
Kotlin
0
0
798ff23eaa9f4baf25593368b62c2f671dc2a010
1,906
AOC-With-Me
Apache License 2.0
src/Day03.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
fun main() { fun part1(input: List<String>): Int { return input.map { it.splitInHalf() } .flatMap { commonCharacters(it.first, it.second) } .sumOf { it.priority } } fun part2(input: List<String>): Int { return input .chunked(3) .flatMap { com...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
1,019
advent-of-code-2022
Apache License 2.0
src/Day21.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
fun main() { class Monkey(var num: Long? = null, var operation: String? = null, var operLeft: String? = null, var operRight: String? = null){} fun Monkey.print(){ println("num: ${this.num}") println("${this.operLeft} ${this.operation} ${this.operRight}") } fun Monkey.update(mapMonkeys...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
10,234
aoc22
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day20/Day20.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,991
AdventOfCode
Apache License 2.0
src/main/kotlin/year2021/day-22.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.aoc.Day import lib.aoc.Part import lib.splitLines import kotlin.math.max import kotlin.math.min fun main() { Day(22, 2021, PartA22(), PartB22()).run() } open class PartA22(private val limit: Int = 50) : Part() { private enum class Command { On, Off } private data class Step(va...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
3,170
Advent-Of-Code-Kotlin
MIT License
src/main/kotlin/Problem21.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.floor import kotlin.math.sqrt /** * Amicable numbers * * Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). * If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable * numbers. * * F...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,482
project-euler
MIT License
src/day02/Day02.kt
ubuntudroid
571,771,936
false
{"Kotlin": 7845}
package day02 import day02.Result.* import day02.Result.Companion.toResult import day02.Shape.Companion.toShape import ensureBlankLastItem import readInput fun main() { val input = readInput("Day02") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int = input .map { it.s...
0
Kotlin
0
0
fde55dcf7583aac6571c0f6fc2d323d235337c27
2,280
advent-of-code-2022
Apache License 2.0
src/Day14.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
import java.io.File fun main() { val testInput = """498,4 -> 498,6 -> 496,6 503,4 -> 502,4 -> 502,9 -> 494,9""" val realInput = File("src/Day14.txt").readText() val part1TestOutput = unitsOfSandToAbyss(testInput) println("Part 1 Test Output: $part1TestOutput") check(part1TestOutput == 24) val part1RealOu...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
3,816
advent-of-code-2022
Apache License 2.0
src/day13/Day13.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day13 import println import readInputAsText data class Position(val x: Int, val y: Int) data class Fold(val axis: Char, val position: Int) typealias Paper = Set<Position> fun String.parse(): Pair<Paper, List<Fold>> { val (coords, foldLines) = split("\n\n") val paper = coords.split("\n") .map ...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
1,625
advent-of-code-2021
Apache License 2.0
src/Day05.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
data class ProcedureStep(val src: Int, val dest: Int, val times: Int) fun getProcedure(strProcedure: String): List<ProcedureStep> = strProcedure .lines() .map { it.toProcedureStep() } fun String.toProcedureStep() = run { val times = getInstructionPart(this, "move") val src = getInstructionPart(this, "...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
2,779
advent-of-code-2022
Apache License 2.0
src/year2023/day16/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2023.day16 import java.util.LinkedList import java.util.Queue import year2023.solveIt enum class Direction { RIGHT, LEFT, UP, DOWN } data class Position(val line: Int, val column: Int) { fun nav(other: Position): Position = Position(line + other.line, column + other.column) fun nav(direction...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
3,938
adventOfCode
Apache License 2.0
src/Day02.kt
GreyWolf2020
573,580,087
false
{"Kotlin": 32400}
/*enum class RockPaperScissorsPermutation(val result: Int) { `A X`(3 + 1), `A Y`(6 + 2), `A Z`(0 + 3), `B X`(0 + 1), `B Y`(3 + 2), `B Z`(6 + 3), `C X`(6 + 1), `C Y`(0 + 2), `C Z`(3 + 3) }*/ val RoPaScPermutations = mapOf<String, Int>( "A X" to 3 + 1, "A Y" to 6 + 2, "A Z" to 0 + 3, "B X" to 0 + 1, ...
0
Kotlin
0
0
498da8861d88f588bfef0831c26c458467564c59
1,243
aoc-2022-in-kotlin
Apache License 2.0
2023/src/day11/day11.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day11 import GREEN import RESET import printTimeMillis import readInput import kotlin.math.abs data class Point(val x: Int, val y: Int) private fun calculateDistances( galaxies: List<Point>, emptyColumns: List<Int>, emptyRows: List<Int>, stretchFactor: Int ): Long { var distance = 0L ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,447
advent-of-code
Apache License 2.0
src/day04/Day04.kt
JakubMosakowski
572,993,890
false
{"Kotlin": 66633}
package day04 import readInput /** * Space needs to be cleared before the last supplies can be unloaded from the ships, * and so several Elves have been assigned the job of cleaning up sections of the camp. * Every section has a unique ID number, and each Elf is assigned a range of section IDs. * However, as som...
0
Kotlin
0
0
f6e9a0b6c2b66c28f052d461c79ad4f427dbdfc8
4,288
advent-of-code-2022
Apache License 2.0
src/Day20.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import java.io.File import java.lang.Integer.max fun main() { val debug = false fun getEnhanced(alg: String, img: HashMap<Pair<Int, Int>, Char>, round: Int, pos: Pair<Int, Int>): Char { val algIdx = pos.neighbors(center = true).map { if (img.getOrElse(pos) { '.' //tod...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
1,902
advent_of_code21_kotlin
Apache License 2.0
src/main/kotlin/solutions/day07/Day7.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day07 import solutions.Solver enum class FileType { DIRECTORY, FILE } data class Node( val name: String, val type: FileType, val children: MutableList<Node>, val size: Int, var explored: Boolean, val parent: Node? ) class Day7 : Solver { private fun isCommand(s...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
3,781
Advent-of-Code-2022
MIT License
src/Day15.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import java.lang.Integer.max import java.lang.Integer.min import kotlin.LazyThreadSafetyMode.NONE import kotlin.math.abs fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day15_test") .parseField() val part1TestResult = part1(testInput, 10)...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
3,345
aoc22-kotlin
Apache License 2.0
src/main/kotlin/day11.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.Input import shared.XYMap fun main() { val input = Input.day(11) println(day11A(input)) println(day11B(input)) } fun day11A(input: Input): Long { val map = XYMap(input) { if(it == '#') it else null } return sumGalaxyPairDistance(map) } fun day11B(input: Input, emptySize: Long = 1000...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,242
AdventOfCode2023
MIT License
src/com/kingsleyadio/adventofcode/y2023/Day16.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val grid = readInput(2023, 16).readLines() part1(grid) part2(grid) } private fun part1(grid: List<String>) { val energized = energize(grid, Index(0, 0), Index(1, 0)) println(energized) } ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,885
adventofcode
Apache License 2.0
src/Day07.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
import utils.string.asLines import utils.readInputAsText import utils.runSolver private typealias SolutionType = Int private val dayNumber: String = "07" private val testSolution1: SolutionType = 95437 private val testSolution2: SolutionType? = 24933642 interface ElfItem { val size: Int } class ElfFile(val nam...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
3,788
2022-AOC-Kotlin
Apache License 2.0
src/main/kotlin/day10_syntax_scoring/SyntaxScoring.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day10_syntax_scoring import java.util.* /** * "Chunks contain ... other chunks" means recursion is the name of the game, * and that means a stack. Some lookup tables for matching delimiters and scores * will be needed too. Since we're again interpreting the input (not treating it * as data), this will be ...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,658
aoc-2021
MIT License
2022/kotlin/app/src/main/kotlin/day04/Day04.kt
jghoman
726,228,039
false
{"Kotlin": 15309, "Rust": 14555, "Scala": 1804, "Shell": 737}
package day04 data class Range(val start: Int, val end: Int) { fun span() = end - start } data class Assignments(val first: Range, val second: Range) fun parseLine(line: String): Assignments { val first = line.split(",")[0] val second = line.split(",")[1] fun parseRange(r: String): Range { v...
0
Kotlin
0
0
2eb856af5d696505742f7c77e6292bb83a6c126c
1,576
aoc
Apache License 2.0
src/year_2021/day_05/Day05.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_05 import readInput data class Point( val x: Int, val y: Int ) data class LineSegment( val pointA: Point, val pointB: Point ) { val allHorizontalAndVerticalPoints: List<Point> get() { return when { pointA.x == pointB.x -> { // vertical ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
4,596
advent_of_code
Apache License 2.0
src/main/kotlin/de/startat/aoc2023/Day2.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 data class D2Play(val shownRed: Int, val shownGreen: Int, val shownBlue: Int) data class Game(val id: Int, val plays: List<D2Play>) fun isValid(game : Game, maxRed: Int, maxGreen: Int, maxBlue: Int): Boolean = game.plays.all { play -> play.shownRed <= maxRed && play.shownGreen <= maxGre...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
12,312
AOC2023
Creative Commons Zero v1.0 Universal
day09/main.kt
LOZORD
441,007,912
false
{"Kotlin": 29367, "Python": 963}
import java.util.Scanner data class Position(val row: Int, val col: Int) fun findLowPoints(grid: Array<IntArray>): Set<Position> { val lowPoints = HashSet<Position>() fun visit(i: Int, j: Int) { if (getNeighbors(grid, i, j).all { grid[i][j] < grid[it.row][it.col] }) { lowPoints.add(Positi...
0
Kotlin
0
0
17dd266787acd492d92b5ed0d178ac2840fe4d57
2,522
aoc2021
MIT License
src/Day12.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<List<HillPosition>> = buildList { input.forEach { row -> val list = mutableListOf<HillPosition>() row.forEach { char -> val elevation = char.toElevation() list += HillPosition(elevation, Type.parse(char...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
3,355
advent-of-code-2022
Apache License 2.0
src/Day12.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
import java.util.* import kotlin.math.abs fun main() { data class Node(val x: Int, val y: Int, val height: Int) data class Puzzle(val start: Node, val end: Node, val nodes: List<List<Node>>) fun parse(input: List<String>): Puzzle { var start: Node? = null var end: Node? = null val...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
4,073
advent_of_code_2022
Apache License 2.0
src/day05/Day05.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day05 import readText typealias Crate = Char typealias Stack = MutableList<Crate> data class Instruction(val count: Int, val fromIndex: Int, val toIndex: Int) data class Crane(val stacks: List<Stack>, val instructions: List<Instruction>) // Parsing is long 🤮 fun Crane(input: String): Crane { val lines: L...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
3,003
advent-of-code-22
Apache License 2.0
src/Day03.kt
hijst
572,885,261
false
{"Kotlin": 26466}
fun main() { val itemTypePriorities: Map<Char, Int> = ( (('a'..'z').toList() + ('A'..'Z').toList()) .zip(1..52) ) .toMap() fun Char.toPriority(): Int = itemTypePriorities.getOrDefault(this, 0) fun String.splitInHalves() = substring(0, (length / 2)) to substring(length /...
0
Kotlin
0
0
2258fd315b8933642964c3ca4848c0658174a0a5
1,166
AoC-2022
Apache License 2.0
src/main/kotlin/day02/Day02.kt
Malo-T
575,370,082
false
null
package day02 class Day02 { enum class Play(val points: Int) { ROCK(1) { override fun scoreAgainst(other: Play) = when (other) { ROCK -> Result.DRAW PAPER -> Result.LOSS SCISSORS -> Result.WIN }.points + points }, PAPE...
0
Kotlin
0
0
f4edefa30c568716e71a5379d0a02b0275199963
2,929
AoC-2022
Apache License 2.0
src/main/kotlin/_2022/Day18.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun getNearCoords(coord: Triple<Int, Int, Int>): Set<Triple<Int, Int, Int>> { return setOf( Triple(coord.first + 1, coord.second, coord.third), Triple(coord.first - 1, coord.second, coord.third), Triple(coord.first, coord.seco...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
2,512
advent-of-code
Apache License 2.0
day 02/Wouter - kotlin/solution.kts
AE-nv
420,076,649
false
{"Python": 254337, "Java": 180867, "C#": 167466, "F#": 114222, "Clojure": 88016, "C++": 45744, "HTML": 22679, "TypeScript": 19433, "Go": 16626, "JavaScript": 10488, "Assembly": 8364, "Rust": 6671, "Kotlin": 3264, "Scala": 2328, "CSS": 252}
data class Position(val depth: Int, val horizontal: Int, val aim:Int) { fun execute(command: Command) = when(command.direction) { "forward" -> Position(depth, horizontal+command.amount, aim) "down" -> Position(depth+command.amount, horizontal, aim) "up" -> Position(depth-command.amount, hori...
0
Python
1
1
e9c803dc5fab3c51a2acbbaade56b71d4f5ce7d2
1,367
aedvent-code-2021
MIT License
2021/src/main/kotlin/day4_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.Parser import utils.Solution fun main() { Day4Imp.run() } object Day4Imp : Solution<Pair<List<Int>, List<IntGrid>>>() { override val name = "day4" override val parser = Parser.compoundList(Parser.ints, IntGrid.table) override fun part1(input: Pair<List<Int>, List<IntGrid>>):...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,684
aoc_kotlin
MIT License
src/day12/Day12.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day12 import readInput import kotlin.math.min fun main() { fun parseInput(input: List<String>) = input.map { it.toCharArray().toList() } fun findStart(heightMap: List<List<Char>>): Pair<Int, Int> { for (i in heightMap.indices) { for (j in heightMap[0].indices) { if...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
3,461
aoc-2022
Apache License 2.0
src/main/kotlin/_2022/Day11.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readGroupedInput import java.math.BigInteger fun main() { fun getNewItemLvl(item: BigInteger, operation: String): BigInteger { val (first, operationChar, second) = operation.replace("old", item.toString()) .split(" ") when (operationChar) { "+" -> retu...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,226
advent-of-code
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day02/day2.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day02 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val encryptedGuide = parseRockPaperScissorsGuide(inputFile.bufferedReader().readLines()) val guessedMoves = decodeGuessedMoves(encryptedGuide) println("Total s...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,907
advent-of-code
MIT License
src/main/aoc2022/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import Pos import Search class Day24(input: List<String>) { private val width = input[0].length - 2 private val height = input.size - 2 private val map = parseInput(input) private fun parseInput(input: List<String>): Map<Pos, Char> { return buildMap { for (y in 1 ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,476
aoc
MIT License
y2020/src/main/kotlin/adventofcode/y2020/Day08.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day08.solve() object Day08 : AdventSolution(2020, 8, "Handheld Halting") { override fun solvePartOne(input: String): Int { val instructions = parseInstructions(input) return Program(0, instructions).run().first ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,278
advent-of-code
MIT License
src/main/kotlin/cloud/dqn/leetcode/CombinationSumKt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/combination-sum/description/ Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimit...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
3,269
cloud-dqn-leetcode
No Limit Public License
src/com/ncorti/aoc2023/Day02.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 import kotlin.math.max data class Game(val id: Int, val sets : List<Triple<Int, Int, Int>>) { companion object { fun from(input: String): Game { val gameId = input.substringBefore(":").substringAfter(" ").toInt() val sets = input.substringAfter(":").split...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
1,868
adventofcode-2023
MIT License
solutions/aockt/y2016/Y2016D04.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2016 import io.github.jadarma.aockt.core.Solution object Y2016D04 : Solution { /** The actual value of a room, containing its real name and location. */ private data class Room(val name: String, val sector: Int) { init { require(sector > 0) { "Invalid sector; must be posit...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,971
advent-of-code-kotlin-solutions
The Unlicense
src/aoc2022/Day07.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2022 import readInputText fun main() { val (year, day) = "2022" to "Day07" fun directorySizes(input: String): List<Int> { var currentDir = Directory("/") val directories = mutableListOf(currentDir) input.split("$ ").drop(2).forEach { entry -> val details = entry...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
2,555
aoc-kotlin
Apache License 2.0
src/main/kotlin/day11.kt
bfrengley
318,716,410
false
null
package aoc2020.day11 import aoc2020.util.* enum class Seat { EMPTY, FLOOR, OCCUPIED; companion object { fun parse(chr: Char): Seat = when (chr) { '#' -> OCCUPIED '.' -> FLOOR 'L' -> EMPTY else -> throw IllegalArgumentException("Invalid value: $chr") //...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,805
aoc2020
ISC License
src/day18/Day18.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
package day18 import readInput import java.lang.Math.abs data class Point(val x: Int, val y: Int, val z: Int) fun parseCubes(input: List<String>): List<Point> { var returnList = MutableList<Point>(0){ Point(0, 0, 0) } for (cube in input) { val components = cube.split(",") if (components.size...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
4,187
AdventOfCode2022
Apache License 2.0
src/Day05.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
data class Instruction( val quantity: Int, val sourceStackId: Int, val targetStackId: Int ) fun String.asInstruction(): Instruction { val (quantity, source, target) = split(" ") .filter { text -> text.all(Char::isDigit) } .map(String::toInt) return Instruction(quantity, source, targ...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
3,297
advent-of-code-2022
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day03.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day03 : AdventSolution(2021, 3, "Binary Diagnostic") { override fun solvePartOne(input: String): Int { val lines = input.lines() return lines[0].indices.map(lines::mostFrequentDigitAt) .joinToString("") ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,309
advent-of-code
MIT License
src/Day15.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
import java.util.SortedSet import kotlin.math.abs class PositionLong(val x: Long, val y: Long) { val posKey: String get() = "${this.x},${this.y}" } fun PositionLong.getManhattanDistance(otherPos: PositionLong) = abs(this.x - otherPos.x) + abs(this.y - otherPos.y) class Day15 { val occupiedPositio...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
3,546
advent-of-code
Apache License 2.0
src/day5/day5.kt
bienenjakob
573,125,960
false
{"Kotlin": 53763}
package day5 import inputTextOfDay fun parseInput(input: String): Pair<MutableList<MutableList<Char>>, List<List<Int>>> { return input.split("\r\n\r\n").let { (_, second) -> getStacks() to parseInstructions(second) } } fun getStacks(): MutableList<MutableList<Char>> { val s1 = listOf('N', 'R', 'J', 'T', 'Z',...
0
Kotlin
0
0
6ff34edab6f7b4b0630fb2760120725bed725daa
2,016
aoc-2022-in-kotlin
Apache License 2.0
src/Day14.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
import kotlin.math.max import kotlin.math.min fun main() { operator fun Pair<Int, Int>.rangeTo(other: Pair<Int, Int>): Set<Pair<Int, Int>> { val minX = min(first, other.first) val maxX = max(first, other.first) val minY = min(second, other.second) val maxY = max(second, other.second...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
2,942
aoc-2022
Apache License 2.0
src/Day07.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun parseDir(input: List<String>, node: TreeNode, currentIndex: Int = 1): Int { var index = currentIndex while (index < input.count()) { val parts = input[index].split(' ') val (op1, op2) = parts when { op1 == "$" && op2 == "ls" -> {}...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
2,886
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day12.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.math.Point2D object Day12 { class Area(private val width: Int, private val height: Int) { private val squares = Array<Array<Char>>(height) { Array(width) { ' ' } } lateinit var startPosition: Point2D lateinit var endPosit...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
3,535
advent-of-code-2022
Apache License 2.0