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/nl/tiemenschut/aoc/y2023/day17.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.util.Direction import nl.tiemenschut.aoc.lib.util.Direction.DOWN import nl.tiemenschut.aoc.lib.util.Direction.RIGHT import nl.tiemenschut.aoc.lib.util.grid.CharGridParser import nl...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
6,851
aoc-2023
The Unlicense
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/DepthFirstSearch.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
// The Depth-First Search (DFS) coding pattern is used for exploring or //traversing a data structure by going as deep as possible before backtracking. /* Usage: This technique is used to solve problems involving traversing trees or graphs in a depth-first search manner. */ //1. Path With Given Sequence class TreeNode...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
3,021
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/Day13.kt
karloti
573,006,513
false
{"Kotlin": 25606}
/** * https://github.com/dfings/advent-of-code/blob/main/src/2022/problem_13.main.kts * @author <NAME> */ sealed interface PacketData : Comparable<PacketData> data class ListValue(val values: List<PacketData>) : PacketData { override fun toString() = values.toString() override operator fun compareTo(other:...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
2,274
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day15/Day15Part2.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day15 import com.tonnoz.adventofcode23.utils.readInput import kotlin.system.measureTimeMillis typealias BoxNr = Int object Day15Part2 { data class Box(val lensesBox: MutableList<Lens>){ data class Lens(val label: String, val value: String) } @JvmStatic fun main(args: A...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,653
adventofcode23
MIT License
kotlin/src/katas/kotlin/hackerrank/minimum_swaps2/MinimumSwaps2.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.hackerrank.minimum_swaps2 import katas.kotlin.hackerrank.OutputRecorder import katas.kotlin.hackerrank.trimToLineSequence import nonstdlib.permutations import nonstdlib.printed import datsok.shouldEqual import org.junit.Test import java.io.File import java.util.* /** * https://www.hackerrank.com...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
5,546
katas
The Unlicense
src/main/kotlin/com/quakbo/euler/Euler9.kt
quincy
120,237,243
false
null
package com.quakbo.euler /* A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. According to Wikipedia, every Pythagorean triplet is ...
0
Kotlin
0
0
01d96f61bda6e87f1f58ddf7415d9bca8a4913de
1,737
euler-kotlin
The Unlicense
calendar/day09/Day9.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day09 import Day import Lines class Day9 : Day() { data class Position(val x: Int, val y: Int) { val adjacentPositions get() = setOf( Position(x, y), Position(x - 1, y - 1), Position(x - 1, y), Position(x - 1, y + 1), Position(x, y - 1), Position(x, y + 1), Posi...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
1,836
adventofcode-2022
Apache License 2.0
src/day04/Day04.kt
sophiepoole
573,708,897
false
null
package day04 import readInput fun main() { fun getRange(a: String): IntRange { val split = a.split("-") return split[0].toInt()..split[1].toInt() } fun checkPair(pair: String): Int { val split = pair.split(",") val a = getRange(split[0]) val b = getRange(split[1]...
0
Kotlin
0
0
00ad7d82cfcac2cb8a902b310f01a6eedba985eb
1,267
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CheckWays.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,970
kotlab
Apache License 2.0
src/cn/leetcode/codes/simple22/Simple22.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple22 import cn.leetcode.codes.out /** * 刷题情况 * * 题目地址:https://leetcode-cn.com/problems/generate-parentheses/ * * 1 刷是否通过:没有 * * * 2 刷是否完成: * * * 3 刷是否完成: * * * 4 刷是否完成: * * * 5 刷是否完成: * * 最优解析:https://leetcode-cn.com/problems/generate-parentheses/solution/gua-hao-sheng...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,769
LeetCodeSimple
Apache License 2.0
src/extensions/grid/PathfindingDijkstraGraph.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
package extensions.grid import java.util.TreeSet class Edge(val nodeFrom: String, val nodeTo: String, val distance: Int) /** One vertex of the graph, complete with mappings to neighbouring vertices */ class Vertex(val nodeName: String) : Comparable<Vertex> { var distance = Int.MAX_VALUE // MAX_VALUE assumed to...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
4,072
aoc-2022-in-kotlin
Apache License 2.0
src/day4/Day04.kt
omarshaarawi
573,867,009
false
{"Kotlin": 9725}
package day4 import readInput fun main() { fun IntRange.overlaps(other: IntRange): Boolean { return (this.first >= other.first && this.last <= other.last) || (other.first >= this.first && other.last <= this.last) } fun String.toRange(): IntRange { return this.split("-") ...
0
Kotlin
0
0
4347548045f12793a8693c4d31fe3d3dade5100a
1,144
advent-of-code-kotlin-2022
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day02.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.util.collections.cartesian fun main() = Day02.solve() object Day02 : AdventSolution(2019, 2, "1202 Program Alarm") { override fun solvePartOne(input: String) = parse(input).runProgram(12, 2) override fun solvePartTwo(input...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,392
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumFuelCost.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,699
kotlab
Apache License 2.0
src/main/kotlin/aoc2019/OxygenSystem.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.aoc2019.MoveResult.FOUND import komu.adventofcode.aoc2019.MoveResult.WALL import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Direction.* import komu.adventofcode.utils.Point import utils.shortestPathBetween fun oxygenSystem1(input: String...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,680
advent-of-code
MIT License
src/main/kotlin/dev/paulshields/aoc/Day20.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 20: Trench Map */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 20: Trench Map ** \n") val trenchMapImage = readFileAsStringList("/Day20TrenchMapImage.txt") val imageEnhancementAlgorithm = trenchMapImage[0] val image = tr...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
2,440
AdventOfCode2021
MIT License
calendar/day12/Day12.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day12 import Day import Lines import kotlin.math.max class Day12 : Day() { override fun part1(input: Lines): Any { val map = parseMap(input) map.calculateStepsToGoal() println(map) return map.stepsToGoal(map.start) } override fun part2(input: Lines): Any { ...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
5,112
advent-of-code-2022
Apache License 2.0
src/main/kotlin/y2021/Day05.kt
jforatier
432,712,749
false
{"Kotlin": 44692}
package y2021 import kotlin.math.absoluteValue import kotlin.math.sign class Day05(private val data: List<String>) { private val table: MutableMap<Coordinate, Int> = mutableMapOf() data class Coordinate(val x: Int, val y: Int) { fun lineTo(that: Coordinate): List<Coordinate> { val xDelta...
0
Kotlin
0
0
2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae
2,663
advent-of-code-kotlin
MIT License
src/main/kotlin/de/tek/adventofcode/y2022/day09/RopeBridge.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day09 import de.tek.adventofcode.y2022.util.math.* import de.tek.adventofcode.y2022.util.readInputLines class Rope(vararg initialKnotPositions: Point) { private val knotPositions = arrayOf(*initialKnotPositions) private val tailHistory = mutableSetOf(knotPositions.last()) ...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
3,556
advent-of-code-2022
Apache License 2.0
src/main/kotlin/problems/Day20.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day20(override val input: String) : Problem { override val number: Int = 20 private val algorithm = input.lines().first() private val LIT = '#' private val pixelToBinary = mapOf('.' to '0', LIT to '1') override fun runPartOne(): String { return runAlgorithm(2) } ...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
2,298
AdventOfCode2021
MIT License
src/day2/puzzle02.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day2 import Puzzle import PuzzleInput import java.io.File sealed class Gesture(val value: Int) { object Rock : Gesture(1) object Paper : Gesture(2) object Scissors : Gesture(3) private fun win(opponent: Gesture): Boolean { return when(this) { Rock -> opponent == Scissors ...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
5,369
aoc_2022
Apache License 2.0
src/Day04.kt
RogozhinRoman
572,915,906
false
{"Kotlin": 28985}
fun main() { infix fun Pair<Int, Int>.isFullyContain(tested: Pair<Int, Int>) = this.first <= tested.first && this.second >= tested.second infix fun Pair<Int, Int>.includesStart(tested: Pair<Int, Int>) = this.first <= tested.first && this.second >= tested.first infix fun Pair<Int, Int>.hasO...
0
Kotlin
0
1
6375cf6275f6d78661e9d4baed84d1db8c1025de
1,106
AoC2022
Apache License 2.0
src/day3/day3.kt
allout58
159,955,103
false
null
package day3 import java.io.File data class Claim(val id: Int, val atX: Int, val atY: Int, val width: Int, val height: Int) { fun toRectangel() = Rectangle(Point(atX, atY), Point(atX + width, atY + height)) } fun main(args: Array<String>) { val input = File("test.txt").useLines { it.toList() } val regex ...
0
Kotlin
0
0
20a634569ddc0cbcb22a47a2c79e2a4fd1470645
2,335
AdventOfCode2018
Apache License 2.0
src/day2/Day02.kt
helbaroudy
573,339,882
false
null
package day2 import readInput fun main() { fun parse(value: String): Move { return when (value) { "A", "X" -> Move.ROCK____ "B", "Y" -> Move.PAPER___ "C", "Z" -> Move.SCISSORS else -> error("Err: $value") } } fun parseDesiredResult(value: St...
0
Kotlin
0
0
e9b98fc0eda739048e68f4e5472068d76ee50e89
2,013
aoc22
Apache License 2.0
src/Day07.kt
mr-cell
575,589,839
false
{"Kotlin": 17585}
fun main() { fun part1(input: List<String>): Int { val rootDir = parseInput(input) return rootDir.find { it.size <= 100_000 }.sumOf { it.size } } fun part2(input: List<String>): Int { val rootDir = parseInput(input) val unusedSpace = 70_000_000 - rootDir.size val de...
0
Kotlin
0
0
2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9
2,031
advent-of-code-2022
Apache License 2.0
src/Day05.kt
topr
572,937,822
false
{"Kotlin": 9662}
import java.util.Stack data class Stacks(private val stacks: List<Stack<Char>>) { constructor(numberOfStacks: Int) : this((0 until numberOfStacks).map { Stack() }) fun topCrates() = stacks .map(Stack<Char>::peek) .joinToString("") fun moveOneByOne(move: Move) = repeat(move.amount) { ...
0
Kotlin
0
0
8c653385c9a325f5efa2895e94830c83427e5d87
2,657
advent-of-code-kotlin-2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day22.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year18 import com.grappenmaker.aoc.* import java.math.BigInteger // I don't like this code private val mod = 20183.toBigInteger() private val xTimes = 16807L.toBigInteger() private val yTimes = 48271L.toBigInteger() fun PuzzleSet.day22() = puzzle { val (depth, targetX, targetY) = raw...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,496
advent-of-code
The Unlicense
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day05.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwentyone import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput import kotlin.math.abs class Day05 : Day<Int> { private data class Point(val x: Int, val y: Int) { override fun toString() = "($x,$y)" } private data class Segment(val a: Point, ...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
3,502
adventofcode
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day1/One.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day1 import com.tonnoz.adventofcode23.utils.readInput object One{ @JvmStatic fun main(args: Array<String>) { val inputLines = "inputOne.txt".readInput() inputLines .sumOf { "${it.firstDigit()}${it.lastDigit()}".toInt() } .let { println("solution 1st q: $it") ...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
1,754
adventofcode23
MIT License
src/main/kotlin/com/marcdenning/adventofcode/day07/Day07a.kt
marcdenning
317,730,735
false
{"Kotlin": 87536}
package com.marcdenning.adventofcode.day07 import java.io.File import java.util.* import java.util.regex.Pattern import java.util.stream.Collectors fun main(args: Array<String>) { var numberOfColors = 0 Scanner(File(args[0])).use { scanner -> numberOfColors += getAncestorsOfTargetColor(parseRules(sca...
0
Kotlin
0
0
b227acb3876726e5eed3dcdbf6c73475cc86cbc1
1,792
advent-of-code-2020
MIT License
src/Day04.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
fun main() { fun extractRanges(line: String): Pair<IntRange, IntRange> { val (first, second) = line.split(",") val (fStart, fEnd) = first.split("-").map { it.toInt() } val (sStart, sEnd) = second.split("-").map { it.toInt() } return Pair(IntRange(fStart, fEnd), IntRange(sStart, sEn...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,183
aoc-2022
Apache License 2.0
src/Day07.kt
colund
573,040,201
false
{"Kotlin": 10244}
fun main() { val lines = readInput("Day07") day7(lines) } fun day7(lines: List<String>) { val cdCommand = "\\$ cd (.*)".toRegex() val sizeFile = "(\\d+) (.*)".toRegex() val pathSizes = mutableMapOf<String, Int>() var cwd = "" for (line in lines) { if (line == "\$ ls") continue ...
0
Kotlin
0
0
49dcd2fccad0e54ee7b1a9cb99df2acdec146759
1,434
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day8.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DAY_FILE import util.DayInput import java.math.BigInteger class Day8 : Day("8") { override fun partOne(dayInput: DayInput): Any { val instructions = dayInput.inputList()[0].toCharArray() val map = dayInput.inputList().subList(2, dayInput.inputList().size).map { ...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
4,813
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/Day05.kt
6234456
572,616,769
false
{"Kotlin": 39979}
fun main() { fun part1(input: List<String>): String { var sep = -1 input.forEachIndexed { index, s -> if (s.isBlank()){ sep = index return@forEachIndexed } } val indexList = input[sep-1] .toCharArray().mapIndexed...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
2,912
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
mihansweatpants
573,733,975
false
{"Kotlin": 31704}
fun main() { fun part1(input: List<String>): Int { return input .map { it.getCommonItem() } .sumOf { it.getPriority() } } fun part2(input: List<String>): Int { return input.withIndex() .groupBy(keySelector = { it.index / 3 }, valueTransform = { it.value }...
0
Kotlin
0
0
0de332053f6c8f44e94f857ba7fe2d7c5d0aae91
1,077
aoc-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/movies_on_flight/MoviesOnFlight.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.movies_on_flight import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/313719/Amazon-or-Online-Assessment-2019-or-Movies-on-Flight */ class MoviesOnFlightTests { @Test fun examples() { findMovies(movieDurations = emptyArray(),...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,719
katas
The Unlicense
src/main/kotlin/aoc/Day4.kt
dtsaryov
573,392,550
false
{"Kotlin": 28947}
package aoc import kotlin.math.max import kotlin.math.min /** * [AoC 2022: Day 4](https://adventofcode.com/2022/day/4) */ fun getNestedRangesCount(): Int { val input = readInput("day4.txt") ?: return -1 return getRanges(input).fold(0) { acc, (left, right) -> if (left.contains(right) || right.contai...
0
Kotlin
0
0
549f255f18b35e5f52ebcd030476993e31185ad3
1,256
aoc-2022
Apache License 2.0
src/Day01.kt
lukewalker128
573,611,809
false
{"Kotlin": 14077}
fun main() { /** * Returns the maximum number of calories held by a single elf. */ fun part1(calories: List<Int>): Int { return calories.max() } /** * Returns the total number of calories held by the three elves carrying the most calories. */ fun part2(calories: List<Int...
0
Kotlin
0
0
c1aa17de335bd5c2f5f555ecbdf39874c1fb2854
1,584
advent-of-code-2022
Apache License 2.0
src/test/java/quam/features/SimonsProblemFeature.kt
johnhearn
149,781,062
false
null
package quam.features import org.junit.jupiter.api.Test import quam.* import java.util.* import kotlin.test.assertEquals /** * The problem is that given a mapping * * f : (List&lt;Boolean>) -> List&lt;Boolean> * * (as a black box) with the added property that there is a special value, s, such * that f(x) = f(x ...
1
Kotlin
0
1
4215d86e7afad97b803ce850745920b63f75a0f9
2,975
quko
MIT License
codeforces/round614/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round614 fun main() { readLn() val a = readInts() val aCount = a.groupBy { it }.mapValues { it.value.size } var b = aCount.keys.toList() val (primes, factPrimes) = List(2) { MutableList(2) { listOf<Int>() } } for (i in 2..b.maxOrNull()!!) { val j = (2..i).first { i % it == 0 } primes.add(p...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
959
competitions
The Unlicense
src/main/kotlin/com/danielmichalski/algorithms/data_structures/_12_dijkstra_algorithm/WeightedGraph.kt
DanielMichalski
288,453,885
false
{"Kotlin": 101963, "Groovy": 19141}
package com.danielmichalski.algorithms.data_structures._12_dijkstra_algorithm import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap class WeightedGraph { private val adjacencyList: MutableList<Node> = ArrayList() fun addVertex(vertex: String) { val node = findNode(...
0
Kotlin
1
7
c8eb4ddefbbe3fea69a172db1beb66df8fb66850
3,170
algorithms-and-data-structures-in-kotlin
MIT License
src/Day07.kt
timmiller17
577,546,596
false
{"Kotlin": 44667}
fun main() { fun part1(input: List<String>): Int { val root = DirectoryNode(value = "/") var currentDirectory = root outerLoop@ for ((index, line) in input.withIndex()) { // println("index:$index $line") if (line.startsWith("$ cd ..")) { currentDirec...
0
Kotlin
0
0
b6d6b647c7bb0e6d9e5697c28d20e15bfa14406c
5,087
advent-of-code-2022
Apache License 2.0
src/Day09.kt
jalex19100
574,686,993
false
{"Kotlin": 19795}
import kotlin.math.abs fun main() { class Coordinate(val x: Int, val y: Int) { fun moveRight(): Coordinate = Coordinate(x+1, y) fun moveLeft(): Coordinate = Coordinate(x-1, y) fun moveUp(): Coordinate = Coordinate(x, y+1) fun moveDown(): Coordinate = Coordinate(x, y-1) } ...
0
Kotlin
0
0
a50639447a2ef3f6fc9548f0d89cc643266c1b74
1,938
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day08.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 object Day08 { fun part1(input: List<String>): Int = input.pointIndices().count { point -> point.x in setOf(0, input[0].lastIndex) || point.y in setOf(0, input.lastIndex) || setOf( input leftOf point, input rightOf point, ...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
1,495
advent22
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1254/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1254 /** * LeetCode page: [1254. Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands/); */ class Solution { /* Complexity: * Time O(MN) and Space O(MN) where M and N are the number of rows and columns of grid; */ fun closedIsland(gr...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,703
hj-leetcode-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day08.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year21 import com.grappenmaker.aoc.PuzzleSet import kotlin.math.pow // Maps segments count to the number (we do be lazy) val knownLengths = mapOf(1 to 2, 7 to 3, 4 to 4, 8 to 7) fun PuzzleSet.day8() = puzzle(day = 8) { // Part one val data = inputLines.map { it.split(" | ") } ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,566
advent-of-code
The Unlicense
gcj/y2023/farewell_d/d_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2023.farewell_d private fun solve(): Modular { val s = readLn() val dp = ModularArray(s.length) { 0.toModularUnsafe() } var ans = 0.toModularUnsafe() for (i in s.indices) { if (s[i] !in ".o") continue if (s.take(i).all { it in ".>" }) dp[i] = 1.toModularUnsafe() for (j in 0 until i) { var goo...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,905
competitions
The Unlicense
src/Day13.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (i in 0..(input.size / 3)) { val leftPacket = Packet.parse(input[(i * 3)]) val rightPacket = Packet.parse(input[(i * 3) + 1]) val inOrder = leftPacket.rightOrder(rightPacket) if (i...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
9,035
aoc-2022
Apache License 2.0
src/Day11/day11.kt
NST-d
573,224,214
false
null
package Day11 import utils.* operator fun <T> List<T>.component6() = this[5] class Monkey( var worryLevels: MutableList<Long>, val operation: (Long) -> Long, val testCondition: Long, val passTo: Pair<Int, Int>, val updateMonkey: (Int, Long) -> Unit ) { var limiter = 1L var inspectingCount...
0
Kotlin
0
0
c4913b488b8a42c4d7dad94733d35711a9c98992
4,348
aoc22
Apache License 2.0
src/test/kotlin/Day10.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe import java.lang.IllegalStateException /* --- Day 10: Adapter Array --- See https://adventofcode.com/2020/day/10 */ fun Set<Int>.findAdapterChain(start: Int): List<Pair<Int, Int>> { val currentSet = this.toMutableSet() var current...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
9,308
advent_of_code_2020
Apache License 2.0
solutions/qualifications/median-sort/src/main/kotlin/solutions.median.sort/MedianSortSolution.kt
Lysoun
351,224,145
false
null
interface Judge { fun askJudge(numbers: List<Int>): Int } class RealJudge: Judge { override fun askJudge(numbers: List<Int>): Int { println(numbers.joinToString(" ")) return readLine()!!.toInt() } } fun main(args: Array<String>) { val input = readLine()!!.split(" ").map { it.toInt() } ...
0
Kotlin
0
0
98d39fcab3c8898bfdc2c6875006edcf759feddd
2,323
google-code-jam-2021
MIT License
src/main/kotlin/day14/CountProjection.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
package day14 class CountProjection { fun perform(steps: Int, inputs: List<String>): Long { val instructions = extractInstructionMap(inputs) val polyCount = initialPolyPairCount(inputs.first()) val polyTail = inputs.first().last().toString() val countForChars = growPolyCountBySteps(...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
2,319
advent-of-kotlin-2021
Apache License 2.0
src/Day02.kt
Jessenw
575,278,448
false
{"Kotlin": 13488}
fun main() { fun part1(input: List<String>) = input .sumOf { val split = it.split(" ") val opponentPlay = scoreForPlay(split[0]) val myPlay = scoreForPlay(split[1]) val roundPoints = if (opponentPlay == myPlay) ...
0
Kotlin
0
0
05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3
1,503
aoc-22-kotlin
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day5/Day5.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day5 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseLongs import net.olegg.aoc.utils.toTriple import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 5](https://adventofcode.com/2023/day/5) */ object Day5 : DayOf2023(5) { override fun first(): Any? { ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
4,491
adventofcode
MIT License
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day12/Record.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day12 import kotlin.streams.asStream data class Record(val text: String, val groups: List<Int>) { private val ICON_BROKEN_SPRING = '#' private val ICON_OPERATIONAL_SPRING = '.' private val ICON_UNKNOWN_SPRING = '?' private val possibilities = replaceQuestionmark(sequen...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
3,576
advent-of-code
Apache License 2.0
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/greedy/luck/LuckBalance.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.greedy.luck import java.lang.IllegalArgumentException import java.util.* fun luckBalance(k: Int, contests: List<Contest>): Int { val (importantContests, unimportanceContests) = contests.partition { it.importance == Importance.IMPORTANT } ...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
1,602
kotlin-hackerrank
MIT License
src/main/kotlin/Chiton_15.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
val risks: Array<IntArray> by lazy { readFile("Chiton").split("\n").map { it.map { it.digitToInt() }.toIntArray() }.toTypedArray() } fun findLeastRiskyPath(field: Array<IntArray>): Int { val h = field.size val w = field[0].size val edges = mutableListOf<Edge>() for (i in 0 until h) { for ...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
1,814
advent-of-code-2021
Apache License 2.0
WarmUp/CompleteTheProject/src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
jetbrains-academy
504,249,857
false
{"Kotlin": 1108971}
package jetbrains.kotlin.course.mastermind.advanced fun getGameRules(wordLength: Int, maxAttemptsCount: Int, secretExample: String) = "Welcome to the game! $newLineSymbol" + newLineSymbol + "Two people play this game: one chooses a word (a sequence of letters), " + "the other gu...
14
Kotlin
1
6
bc82aaa180fbd589b98779009ca7d4439a72d5e5
3,811
kotlin-onboarding-introduction
MIT License
src/main/kotlin/twentytwentytwo/Day21.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import twentytwentytwo.Day21.Monkey.Operation import twentytwentytwo.Day21.Monkey.Value fun main() { val input = {}.javaClass.getResource("input-21.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val tinput = {}.javaClass.getResource("input-21-1.txt")!!.readText().linesFiltered ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
3,346
aoc202xkotlin
The Unlicense
src/main/kotlin/com/hjk/advent22/Day07.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 object Day07 { fun part1(input: List<String>): Int = process(input).getDirs().sumOf { dir -> dir.size.takeIf { it <= 100000 } ?: 0 } fun part2(input: List<String>): Int { val root = process(input) val spaceRequired = 30000000 - (70000000 - root.size) r...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
1,908
advent22
Apache License 2.0
src/day01/Day01.kt
Barros9
572,616,965
false
{"Kotlin": 2313}
package day01 import Day import readInput class Day01 : Day { private fun part1(input: List<String>): Int { return input .asSequence() .flatMapIndexed { index, value -> when { index == 0 || index == input.lastIndex -> listOf(index) ...
0
Kotlin
0
0
03e03fa69033ee8c5c7bf61fec45a663abbfad28
1,543
aoc-2022-in-kotlin
Apache License 2.0
src/day18/Code.kt
fcolasuonno
225,219,560
false
null
package day18 import isDebug import java.io.File import kotlin.math.abs fun main() { val name = if (isDebug() && false) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val (parsed, walls) = parse(input)...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
8,378
AOC2019
MIT License
codeforces/round901/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round901 private fun solve(): Long { val (_, _, k) = readInts() val (a, b) = List(2) { readInts().toMutableList() } val moves = mutableListOf<Long>() var i = 0 while (i < k) { val move = if (i % 2 == 0) makeMove(a, b) else makeMove(b, a) moves.add(move) if (i >= 4 && moves[moves.size - 1]...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
984
competitions
The Unlicense
src/main/kotlin/year2022/Day03.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils import AoCUtils.test fun main() { fun part1(input: String, debug: Boolean = false): Long { return input.lines().map { line -> val firstItem = line.substring(0, line.length / 2) val secondItem = line.substring(line.length / 2) firstItem.map { c -> if (se...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
1,582
aoc-2022-kotlin
Apache License 2.0
src/2021/Day09.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2021` import java.io.File import java.lang.Integer.max import java.lang.Integer.min import java.util.* fun main() { Day09().solve() } class Day09 { val input = """ 2199943210 3987894921 9856789892 8767896789 9899965678 """.trimIndent() class CaveBuilder(s: Scanner) { val h = mutableList...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
3,681
advent-of-code
Apache License 2.0
src/main/kotlin/com/colinodell/advent2021/Day12.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 class Day12 (input: List<String>) { private val caves: Map<String, Set<String>> = parseInput(input) fun solvePart1() = countDistinctPaths("start", "end", VisitSmallCavesExactlyOnce()) fun solvePart2() = countDistinctPaths("start", "end", VisitOneSmallCaveTwice()) pr...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
2,541
advent-2021
Apache License 2.0
year2018/src/main/kotlin/net/olegg/aoc/year2018/day11/Day11.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day11 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2018.DayOf2018 /** * See [Year 2018, Day 11](https://adventofcode.com/2018/day/11) */ object Day11 : DayOf2018(11) { override fun first(): Any? { val serial = data.toInt() val grid = (1..300).map { y -> ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,675
adventofcode
MIT License
2021/kotlin/src/main/kotlin/com/codelicia/advent2021/Day04.kt
codelicia
627,407,402
false
{"Kotlin": 49578, "PHP": 554, "Makefile": 293}
package com.codelicia.advent2021 class Day04(input: String) { private val newline = "\n" private val section = "\n\n" private val sections = input.split(section) private val draws = sections[0].trim().split(",").map(String::toInt) private val cards : List<BingoBoard> = buildList { for (i...
2
Kotlin
0
0
df0cfd5c559d9726663412c0dec52dbfd5fa54b0
2,043
adventofcode
MIT License
src/day09/Day09.kt
lpleo
572,702,403
false
{"Kotlin": 30960}
package day09 import readInput private const val FILES_DAY_TEST = "files/Day09_test" private const val FILES_DAY = "files/Day09" class Point(var x: Int, var y: Int) { fun go(direction: Char) = run { if (direction == 'R') x += 1; if (direction == 'L') x -= 1; if (direction == 'U') y += 1 ...
0
Kotlin
0
0
115aba36c004bf1a759b695445451d8569178269
3,803
advent-of-code-2022
Apache License 2.0
src/main/kotlin/year2022/day-24.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.Grid2d import lib.Position import lib.TraversalAStar import lib.aoc.Day import lib.aoc.Part import lib.math.Vector import lib.memoize fun main() { Day(24, 2022, PartA24(), PartB24()).run() } open class PartA24 : Part() { private lateinit var blizzards: (Int) -> Set<Position> p...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
3,746
Advent-Of-Code-Kotlin
MIT License
src/main/kotlin/day03.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day03 : Solvable("03") { override fun solveA(input: List<String>): String { val gammaList = getMostCommon(input) val epsilonList = gammaList.map { if (it == 0) 1 else 0 } return (binaryToInt(gammaList) * binaryToInt(epsilonList)).toString() } override fun solveB(input: List<...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,343
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/eu/qiou/aaf4k/finance/Leistungsmatrix.kt
6234456
191,817,083
false
null
package eu.qiou.aaf4k.finance import eu.qiou.aaf4k.util.sortedWithOrderList /** * the matrix of the contribution(Leistungsaustausch) between the auxiliary cost centers (Hilfskostenstellen) and from * auxiliary cost centers to the primary cost centers * * each row of the matrix contains the contributions to all th...
2
Kotlin
0
0
dcd0ef0bad007e37a08ce5a05af52990c9d904e0
6,051
aaf4k-base
MIT License
src/Day15.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.streams.toList fun main() { class Node(val cost: Int, val pos: Pair<Int, Int>) { var parent: Node? = null var gScore = Int.MAX_VALUE fun addParent(n: Node) { parent = n this.gScore = this.cost + n.gScore } fun getFScore(end: Node) = g...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
4,131
advent_of_code21_kotlin
Apache License 2.0
src/main/java/dev/haenara/mailprogramming/solution/y2020/m01/d06/Solution200106.kt
HaenaraShin
226,032,186
false
null
import dev.haenara.mailprogramming.solution.Solution import kotlin.math.max import kotlin.math.min /** * 매일프로그래밍 2020. 01. 06 * 간격(interval)로 이루어진 배열이 주어지면, 겹치는 간격 원소들을 합친 새로운 배열을 만드시오. * 간격은 시작과 끝으로 이루어져 있으며 시작은 끝보다 작거나 같습니다. * Given a list of intervals, merge intersecting intervals. * * Input: {{2,4}, {1,5}, {...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
2,696
MailProgramming
MIT License
src/main/kotlin/adventofcode/day3.kt
Kvest
163,103,813
false
null
package adventofcode import java.io.File import kotlin.math.max fun main(args: Array<String>) { first3(File("./data/day3_1.txt").readLines()) second3(File("./data/day3_2.txt").readLines()) } fun first3(data: List<String>) { val regex = Regex("#(\\d+) @ (\\d+),(\\d+): (\\d+)x(\\d+)") var w = 0 var...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
2,105
aoc2018
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Day15.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import kotlin.math.abs class Day15(input: List<String>) { private val regex = Regex("x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)") private val sensors = input.map { line -> regex.find(line)!!.destructured.let { (sx, sy, bx, by) -> ...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,913
advent-2022
MIT License
src/main/kotlin/com/github/dangerground/aoc2020/Day10.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput fun main() { val process = Day10(DayInput.asIntList(10)) println("result part 1: ${process.part1()}") println("result part 2: ${process.part2()}") } class Day10(adapters: List<Int>) { private val sortedAdap...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
1,500
adventofcode-2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MakeArrayStrictlyIncreasing.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
3,539
kotlab
Apache License 2.0
src/main/kotlin/de/dikodam/day17/Day17.kt
dikodam
317,290,436
false
null
package de.dikodam.day17 import de.dikodam.AbstractDay fun main() { Day17()() } data class Coordinates3D(val x: Int, val y: Int, val z: Int) data class Coordinates4D(val w: Int, val x: Int, val y: Int, val z: Int) private typealias GameState3D = Set<Coordinates3D> private typealias GameState4D = Set<Coordinates...
0
Kotlin
0
0
dc70d185cb9f6fd7d69bd1fe74c6dfc8f4aac097
4,978
adventofcode2020
MIT License
src/day02/Day02.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
@file:Suppress("MagicNumber") package day02 import day02.Type.* import readInput enum class Type(val value: Int) { ROCK(1), PAPER(2), SCISSOR(3) } fun main() { fun translate(s: String): Type = when (s) { "A", "X" -> ROCK "B", "Y" -> PAPER "C", "Z" -> SCISSOR else -> error(""...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
1,865
advent-of-code-kotlin-2022
Apache License 2.0
Kotlin/src/CombinationSumII.kt
TonnyL
106,459,115
false
null
/** * Given a collection of candidate numbers (C) and a target number (T), * find all unique combinations in C where the candidate numbers sums to T. * * Each number in C may only be used once in the combination. * * Note: * All numbers (including target) will be positive integers. * The solution set must not c...
1
Swift
22
189
39f85cdedaaf5b85f7ce842ecef975301fc974cf
1,461
Windary
MIT License
src/ca/josue/rational/Rational.kt
josue-lubaki
432,939,460
false
{"Kotlin": 4542}
package ca.josue.rational import java.math.BigInteger class Rational (private val numerator: BigInteger, private val denominator: BigInteger) : Comparable<Rational>{ init { if (denominator == BigInteger.ZERO) throw IllegalArgumentException("Denominator cannot be 0") } // Redefinition...
0
Kotlin
0
1
cbeb74d26fb742ecaee0c4f3bb0ab77d0ea9c822
4,542
Rational
MIT License
src/day19/Day19.kt
spyroid
433,555,350
false
null
package day19 import readRawInput import kotlin.math.abs import kotlin.system.measureTimeMillis class Scanners(input: String) { private val scanners = input .split("\n\n") .filter { it.isNotEmpty() } .map { s -> Scanner( s.trim().lines().drop(1) ...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
4,518
Advent-of-Code-2021
Apache License 2.0
src/main/aoc2019/Day16.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2019 import kotlin.math.abs class Day16(input: String) { val parsedInput = input.chunked(1).map { it.toInt() } private fun patternLookup(currentDigit: Int, index: Int): Int { // digit 0: length 4, digit 1: length 8, ... val patternLength = 4 * (currentDigit + 1) // First t...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,634
aoc
MIT License
src/main/kotlin/g0501_0600/s0539_minimum_time_difference/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0539_minimum_time_difference // #Medium #Array #String #Math #Sorting #2023_01_16_Time_183_ms_(100.00%)_Space_36_MB_(96.23%) class Solution { fun findMinDifference(timePoints: List<String>): Int { return if (timePoints.size < 300) { smallInputSize(timePoints) } else...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,123
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/zer0rez/euler/util/Util.kt
cgnik
199,092,974
false
{"Python": 110405, "Kotlin": 15347}
package com.zer0rez.euler.util import kotlin.math.sqrt fun Int.isDivisibleBy(i: Int): Boolean = this % i == 0 fun Int.isDivisibleByAll(i: IntArray): Boolean = i.all { this.isDivisibleBy(it) } fun Long.isDivisibleBy(i: Long): Boolean = this % i == 0L fun Long.isDivisibleByAny(i: Collection<Long>): Boolean = i.any { t...
0
Python
0
0
fe70459a0e0d0272980300a4782872f2e545fea5
1,601
euler
MIT License
src/main/kotlin/days/Solution03.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.Point2D object Solution03 : Solution<List<String>>(AOC_YEAR, 3) { override fun getInput(handler: InputHandler) = handler.getInput("\n") private fun Char.isSymbol() = !this.isDig...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
2,172
Advent-of-Code-2023
MIT License
src/main/kotlin/Day05.kt
robert-iits
573,124,643
false
{"Kotlin": 21047}
import java.util.Stack import kotlin.system.measureTimeMillis typealias StackList = List<Stack<Char>> typealias CommandList = List<Command> class Day05 { fun part1(input: List<String>): String { val (stacks, commands) = splitInputIntoStackAndCommand(input) val movedStacks = craneAction(stacks, co...
0
Kotlin
0
0
223017895e483a762d8aa2cdde6d597ab9256b2d
3,483
aoc2022
Apache License 2.0
src/2023/2023Day03.kt
bartee
575,357,037
false
{"Kotlin": 26727}
package `2023` import readInput data class IntIndex(val index: Int, val pos: Pair<Int, Int>) fun createSymbolIndex(input: String): List<Int> { val symbol_pattern = """[^\d\w\.]+""".toRegex() return symbol_pattern.findAll(input).map { it.range.start }.toList<Int>() } fun createNumberIndex(input: String): List<IntI...
0
Kotlin
0
0
c7141d10deffe35675a8ca43297460a4cc16abba
1,467
adventofcode2022
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/StringUtils.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph import ai.hypergraph.kaliningraph.automata.* import ai.hypergraph.kaliningraph.image.escapeHTML import ai.hypergraph.kaliningraph.parsing.* import ai.hypergraph.kaliningraph.tensor.FreeMatrix import ai.hypergraph.kaliningraph.tensor.transpose import ai.hypergraph.kaliningraph.types.*...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
5,476
galoisenne
Apache License 2.0
src/Day04.kt
adrianforsius
573,044,406
false
{"Kotlin": 68131}
import org.assertj.core.api.Assertions.assertThat fun main() { fun part1(input: List<String>): Int { return input.map { it.split("\n") }.map { val parts = it.first().split(",") val part1 = parts[0].split("-") val part2 = parts[1].split("-") ...
0
Kotlin
0
0
f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb
1,879
kotlin-2022
Apache License 2.0
src/main/aoc2018/Day10.kt
Clausr
575,584,811
false
{"Kotlin": 65961}
package aoc2018 class Day10(input: List<String>) { private val lights = input.map(Light::from) fun solvePart1(): String { val message = Sky(lights).getMessageWithLeastArea() println(message.second) return message.first } fun solvePart2(): Int { val message = Sky(ligh...
1
Kotlin
0
0
dd33c886c4a9b93a00b5724f7ce126901c5fb3ea
3,174
advent_of_code
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2019/Day14.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2019 import com.s13g.aoc.Result import com.s13g.aoc.Solver import java.lang.Long.min import kotlin.math.ceil /** https://adventofcode.com/2019/day/14 */ class Day14 : Solver { override fun solve(lines: List<String>): Result { val reactions = parseInput(lines) val resultA = produce("F...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,138
euler
Apache License 2.0
src/net/sheltem/aoc/y2023/Day23.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.* suspend fun main() { Day23().run() } class Day23 : Day<Long>(94, 154) { override suspend fun part1(input: List<String>) = input .adjacencies(true) .dfs(input[0].indexOf('.') to 0, input.last().indexOf('.') to (input.size - 1))!!.toLon...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,535
aoc
Apache License 2.0
src/main/kotlin/aoc2020/ex9.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
fun main() { val input = readInputFile("aoc2020/input9") val data = input.lines().map { it.toLong() } val invalid = findFirstInvalid(data, 25) val (low, high) = findSummingRangeOf(invalid, data) val summands = data.subList(low, high+1) println(summands) println("${summands.minOrNull()}, ${s...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
1,638
AOC-2021
MIT License
src/main/kotlin/Day19.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day19 { private const val MIN_STATES = 1L private const val MAX_STATES = 4000L private const val ACCEPTED_STATE = "A" private const val REJECTED_STATE = "R" private const val START_STATE = "in" data class Part(val ratings: Map<String, ...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
9,079
kotlin-kringle
Apache License 2.0
src/year2022/day16/Day16.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day16 import readInputFileByYearAndDay import readTestFileByYearAndDay import java.lang.Integer.max import java.lang.Integer.min data class Valve(val name: String, val flowRate: Int, val connections: MutableList<Valve> = mutableListOf()) { private val cost = mutableMapOf(this to 0) fun findW...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
4,667
advent-of-code-kotlin
Apache License 2.0
src/day/_4/Day04.kt
Tchorzyksen37
572,924,533
false
{"Kotlin": 42709}
package day._4 import readInput fun main() { fun part1(input: List<String>): Int { var overlappingSectionsCount = 0 for (str in input) { println(str) val elvesPair = str.split(",") val sectionOneRange = elvesPair[0].split("-") val sectionTwoRange = elvesPair[1].split("-") if ((Integer.parseInt(s...
0
Kotlin
0
0
27d4f1a6efee1c79d8ae601872cd3fa91145a3bd
2,016
advent-of-code-2022
Apache License 2.0
src/Day07.kt
matheusfinatti
572,935,471
false
{"Kotlin": 12612}
data class File( val name: String, val size: Long = 0, val parent: File? = null, val children: MutableList<File> = mutableListOf() ) val root = File("/") fun main() { val input = readInput("Day07").split("\n") val lsAcc = mutableListOf<String>() var node = root for (output in input) ...
0
Kotlin
0
0
a914994a19261d1d81c80e0ef8e196422e3cd508
2,569
adventofcode2022
Apache License 2.0
03/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : List<String> { return File("input.txt") .readLines() } fun getRates(report : List<String>) : Pair<Int, Int> { val oxygenGenRating = calcOxygenRating(report) val carbonDioxideScrubRating = calcCarbonDioxideScrubRating(report) return Pair(oxygenGenRatin...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,233
advent-of-code-2021
MIT License