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/ExtendedPolymerization_14.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
val polymerInput: PolymerInput by lazy { val lines = readFile("ExtendedPolymerization").split("\n") val initialPolymer = lines[0] val rulesMap = mutableMapOf<String, String>() lines.drop(2).map { line -> line.split(" -> ").also { rulesMap[it[0]] = it[1] } } PolymerInput(initialPolymer, ...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
2,291
advent-of-code-2021
Apache License 2.0
src/Day05.kt
MisterTeatime
560,956,854
false
{"Kotlin": 37980}
fun main() { fun part1(input: List<String>): String { val stacks = getStackSetup(input.takeWhile { it.isNotEmpty() }.dropLast(1)) val instructions = getInstructions(input.takeLastWhile { it.isNotEmpty() }) instructions.forEach { var sourceStack = stacks[it.source - 1] ...
0
Kotlin
0
0
8ba0c36992921e1623d9b2ed3585c8eb8d88718e
2,717
AoC2022
Apache License 2.0
src/day22/Day22.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day22 import readInputAsString private const val DAY_ID = "22" private enum class Turn { // turn 90 degrees clockwise R, // turn 90 degrees counterclockwise L } private enum class Facing(val score: Int, val dx: Int, val dy: Int) { RIGHT(0, 0, 1) { override fun change(turn: Turn)...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
5,797
aoc-2022-in-kotlin
Apache License 2.0
src/day07/day07.kt
PS-MS
572,890,533
false
null
package day07 import readInput fun main() { open class DeviceObj { } data class DeviceFile(val fileSize: Long, val name: String) : DeviceObj() data class DeviceDir(val name: String, val content: List<DeviceObj>) : DeviceObj() fun buildDirectoryTree(input: List<String>): HashMap<String, MutableL...
0
Kotlin
0
0
24f280a1d8ad69e83755391121f6107f12ffebc0
3,112
AOC2022
Apache License 2.0
src/day11/Day11.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day11 import readInput fun main() { val testInput = readInput("day11/test") part1(testInput) part2(testInput) } private fun part1(testInput: List<String>) { val solution = Solution.from(testInput) solution.calculate1() } private fun part2(testInput: List<String>) { val solution = So...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
4,062
advent-of-code-2022
Apache License 2.0
src/Day10.kt
syncd010
324,790,559
false
null
import kotlin.math.abs import kotlin.math.asin import kotlin.math.hypot import kotlin.math.PI class Day10: Day { private fun Position.direction(): Position? { val g = abs(gcd(x, y)) return if (g == 0) null else Position(x / g, y / g) } fun Position.angleFromVertical(): Double { val...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
2,110
AoC2019
Apache License 2.0
src/day02/Day02.kt
tiginamaria
573,173,440
false
{"Kotlin": 7901}
package day02 import readInput enum class Shape(val score: Int) { Rock(1), Paper(2), Scissors(3); fun compare(opponent: Shape): Result { if (this.score == opponent.score) return Result.Draw if ((this.score + 1) % 3 == opponent.score % 3) return Result.Lose return Result.Win } ...
0
Kotlin
0
0
bf81cc9fbe11dce4cefcb80284e3b19c4be9640e
1,808
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
fun main() { fun contains(firstElf: List<Int>, secondElf: List<Int>): Boolean { return firstElf[0] <= secondElf[0] && secondElf[1] <= firstElf[1] } fun overlaps(firstElf: List<Int>, secondElf: List<Int>): Boolean { return !(firstElf[0] > secondElf[1] || secondElf[0] > firstElf[1]) } ...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
1,333
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/day23/Day23.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day23 import readInput data class Position(val col: Int, val row: Int) enum class Direction(val dx: Int, val dy: Int, val horizontal: Boolean) { LEFT(-1, 0, false), UP(0, -1, true), RIGHT(1, 0, false), DOWN(0, 1, true); } data class Limits(val minX: Int, val minY: Int, val maxX: Int, val ...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
4,583
aoc2022
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/LongestCommonSubsequence.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.max /** * The longest common subsequence (LCS) problem consists in finding the longest subsequence common to two (or more) * sequences. It differs from problems of finding common substrings: unlike substrings, subsequences are not required * to occupy consecutive po...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
1,879
string-similarity-kotlin
MIT License
solutions/aockt/y2015/Y2015D14.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import io.github.jadarma.aockt.core.Solution object Y2015D14 : Solution { private data class Reindeer(val name: String, val speed: Int, val sprint: Int, val rest: Int) private val inputRegex = Regex("""(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) secon...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,169
advent-of-code-kotlin-solutions
The Unlicense
src/Day05.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day5.printSolutionIfTest("CMZ", "MCD") } typealias Stacks = MutableMap<Int, List<String>> object Day5 : Day<String, String>(5) { override fun part1(lines: List<String>) = solve(lines, true) override fun part2(lines: List<String>) = solve(lines, false) private fun solve(lines: List<String>...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
1,350
advent-of-code-2022
Apache License 2.0
2018/kotlin/day18p2/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* fun main(args: Array<String>) { val start = Date() val input = puzzleInput() val result = scoreAfter(1000000000, input) val end = Date() println(result) println("in ${end.time - start.time} ms") } fun puzzleInput(): World { val classLoader = World::class.java.classLoader...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
4,569
adventofcode
MIT License
src/Day04.kt
hubikz
573,170,763
false
{"Kotlin": 8506}
fun main() { fun pairElves(it: String): Pair<List<Int>, List<Int>> { val (left, right) = it.split(",") val (leftStart, leftStop) = left.split("-") val (rightStart, rightStop) = right.split("-") val leftRange = (leftStart.toInt()..leftStop.toInt()).toList() val rightRange = ...
0
Kotlin
0
0
902c6c3e664ad947c38c8edcb7ffd612b10e58fe
1,272
AoC2022
Apache License 2.0
src/Day07.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
fun main() { fun getDirectoryList(input: List<String>): List<Directory> { val dirs = mutableListOf<Directory>() var currentDirectory: Directory? = Directory() input.forEach { line -> if (line.startsWith("$ cd")) { if (line.split(" ").last() == "..") { ...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
1,925
aoc22
Apache License 2.0
2023/src/main/kotlin/Day13.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import java.util.regex.Pattern object Day13 { fun part1(input: String) = solve(input, ::findHorizontalReflection) fun part2(input: String) = solve(input, ::findSmudgedHorizontalReflection) private fun solve(input: String, finder: (List<String>) -> Int?): Int { return parseInput(input) .sumOf { patte...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,886
advent-of-code
MIT License
src/main/kotlin/aoc2023/Day15.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils import java.lang.IllegalArgumentException val parseInstruction = "([a-z]+)(-)?(=(\\d))?".toRegex() private fun String.day15Hash() = fold(0) { acc, c -> ((acc + c.code) * 17) % 256 } private class HashTable { val buckets = Array(256) { mutableListOf<Pair<String, Int>>()...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,203
aoc-2022-kotlin
Apache License 2.0
advent-of-code-2023/src/Day16.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import lib.countDistinctBy import lib.matrix.* import lib.matrix.Direction.* import lib.matrix.Direction.Companion.nextInDirection private const val DAY = "Day16" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) shouldBe 46 ...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,811
advent-of-code
Apache License 2.0
2019/src/main/kotlin/adventofcode/day03/main.kt
analogrelay
47,284,386
false
{"Go": 93140, "F#": 42601, "Common Lisp": 36618, "Rust": 35214, "Kotlin": 15705, "Erlang": 15613, "TypeScript": 9933, "Swift": 4317, "HTML": 1721, "Shell": 1388, "PowerShell": 1180, "CSS": 990, "Makefile": 293, "JavaScript": 165}
package adventofcode.day03 import java.io.File data class Point(val x: Int, val y: Int) { public fun moveLeft(distance: Int)= Point(x - distance, y) public fun moveRight(distance: Int)= Point(x + distance, y) public fun moveUp(distance: Int)= Point(x, y + distance) public fun moveDown(distance: Int)= ...
0
Go
0
2
006343d0c05d12556605cc4d2c2d47938ce09045
3,808
advent-of-code
Apache License 2.0
src/year2022/day21/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day21 import arrow.core.Either import arrow.core.flatMap import arrow.core.identity import arrow.core.left import arrow.core.right import io.kotest.matchers.shouldBe import utils.Identifier import utils.Tree import utils.asIdentifier import utils.fold import utils.readInput fun main() { val testI...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
6,038
Advent-of-Code
Apache License 2.0
code-sample-kotlin/algorithms/src/main/kotlin/com/codesample/leetcode/medium/939_MinimumAreaRectangle.kt
aquatir
76,377,920
false
{"Java": 674809, "Python": 143889, "Kotlin": 112192, "Haskell": 57852, "Elixir": 33284, "TeX": 20611, "Scala": 17065, "Dockerfile": 6314, "HTML": 4714, "Shell": 387, "Batchfile": 316, "Erlang": 269, "CSS": 97}
package com.codesample.leetcode.medium /** * 939. Minimum Area Rectangle https://leetcode.com/problems/minimum-area-rectangle/ * * Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides * parallel to the x and y axes. If there isn't any rectangle, retu...
1
Java
3
6
eac3328ecd1c434b1e9aae2cdbec05a44fad4430
2,035
code-samples
MIT License
src/Day05.kt
jaldhar
573,188,501
false
{"Kotlin": 14191}
import kotlin.collections.first import kotlin.collections.removeFirst class Stacks { val stacks = mutableMapOf<Int, MutableList<Char>>() fun readDiagram(line: String) { val matches = """\[(\p{Upper})\]""".toRegex().findAll(line) for (match in matches) { val index = (match.range....
0
Kotlin
0
0
b193df75071022cfb5e7172cc044dd6cff0f6fdf
2,446
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2023/Day07.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 7 - Camel Cards * Problem Description: http://adventofcode.com/2023/day/7 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day7/ */ package com.ginsberg.advent2023 class Day07(private val input: List<String>) { fu...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
2,666
advent-2023-kotlin
Apache License 2.0
kotlin/src/x2022/day7/Day7.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day7 import readInput data class File(val name: String, val size: Int) data class Dir( val name: String, val parent: Dir? = null, val children: MutableMap<String, Dir>, val files: MutableList<File> ) { fun size(): Int { return files.sumOf { it.size } + children.values.sumOf { it.s...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
2,816
adventOfCode
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day13.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput2("Day13") Day13.part1(input).println() Day13.part2(input).println() } object Day13 { fun part1(input: String): Int { val inputChunks = input.split(DOUBLE_NEW_LINE_REGEX) return inputChunks .map { it.split(NEW_LINE_REGEX) ...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
2,926
advent-of-code
MIT License
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day12Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
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 import java.io.File import java.util.* private fun solution1(input: String) = Grid(input).let { it.sho...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
2,690
adventofcode-kotlin
MIT License
src/questions/LargestDivisibleSubset.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBeOneOf /** * Given a set of distinct positive integers nums, return the largest subset answer * such that every pair (`answer[i]`, `answer[j]`) of elements in this subset satisfies: * * `answer[i] % answer[j] == 0`, or * `answer[j] % a...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,516
algorithms
MIT License
src/main/kotlin/adventofcode2022/solution/day_7.kt
dangerground
579,293,233
false
{"Kotlin": 51472}
package adventofcode2022.solution import adventofcode2022.util.readDay import java.util.Objects fun main() { Day7("7").solve() } class Day7(private val num: String) { private val inputText = readDay(num) private val startNumeric = Regex("^\\d+.*$") fun solve() { println("Day $num Solution"...
0
Kotlin
0
0
f1094ba3ead165adaadce6cffd5f3e78d6505724
3,899
adventofcode-2022
MIT License
src/main/kotlin/Day12.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
import java.util.* class Day12 { fun part1(input: List<String>): Int { val area = mapToArea(input) return area.traverseFromStart() } fun part2(input: List<String>): Int { return mapToArea(input).traverseFromEnd() } private fun mapToArea(input: List<String>): Area { ...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
3,584
advent-of-code-2022
Apache License 2.0
src/main/kotlin/d7/d7.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d7 import readInput data class File(val name: String, val content: MutableMap<String, File>, var size: Int) { var parent: File? = null constructor(name: String, content: MutableMap<String, File>, size: Int, parent: File?) : this(name, content, size) { this.parent = parent } fun print...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
3,409
aoc2022
Creative Commons Zero v1.0 Universal
src/Day02.kt
tomoki1207
572,815,543
false
{"Kotlin": 28654}
import Result.* import Sign.* sealed class Result(val score: Int) { object Win : Result(6) object Draw : Result(3) object Lose : Result(0) } sealed class Sign(val score: Int) { abstract fun vs(sign: Sign): Result abstract fun simulate(result: Result): Sign object Rock : Sign(1) { over...
0
Kotlin
0
0
2ecd45f48d9d2504874f7ff40d7c21975bc074ec
2,896
advent-of-code-kotlin-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day10.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 grid = readInput(2023, 10, false).readLines() val sIndex = findS(grid) val next = findNext(sIndex.x, sIndex.y, grid) val path = buildPath(sIndex, next, grid...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
3,214
adventofcode
Apache License 2.0
src/main/day4/Day04.kt
Derek52
572,850,008
false
{"Kotlin": 22102}
package main.day4 import main.readInput fun main() { val input = readInput("day4/day4") val firstHalf = true testAlg(firstHalf) if (firstHalf) { println(part1(input)) } else { println(part2(input)) } } data class Range(val x:Int, val y:Int) fun rangeInRange(left: Range, ri...
0
Kotlin
0
0
c11d16f34589117f290e2b9e85f307665952ea76
2,016
2022AdventOfCodeKotlin
Apache License 2.0
src/main/kotlin/Day03.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day03.solvePart1()) println(Day03.solvePart2()) } object Day03 { private val input = readInput("day03") private val nbits = input.first().length fun solvePart1(): Int { val gamma = (0 until nbits) .map { pos -> input.count { bits -> bits[pos] == '1' } } ...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,416
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/sk/topicWise/dp/5. Longest Palindromic Substring.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.dp class Solution5 { private var start = 0 private var maxLen = 0 fun longestPalindrome(s: String): String { val len = s.length if (len < 2) return s for (i in 0 until len - 1) { extendPalindrome(s, i, i) //assume odd length, try to extend Palind...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
4,781
leetcode-kotlin
Apache License 2.0
src/day7/Day07.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day7 import readInput import java.nio.file.Path import java.nio.file.Paths import kotlin.io.path.div fun main() { fun part1(input: List<String>): Long { val dirMap = getDirAndFiles(input) val dirSizes = getDirSizes(dirMap) return dirSizes.filter { it.value <= 100000 }.map { it.valu...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
3,728
AdventOfCode2022
Apache License 2.0
src/Day05.kt
imavroukakis
572,438,536
false
{"Kotlin": 12355}
fun main() { val regex = "move (\\d+) from (\\d+) to (\\d+)".toRegex() operator fun MatchResult?.component1() = this?.destructured?.let { (moveN, _, _) -> moveN.toInt() } ?: throw IllegalArgumentException() operator fun MatchResult?.component2() = this?.destructured?.let { (_, from, _) -> ...
0
Kotlin
0
0
bb823d49058aa175d1e0e136187b24ef0032edcb
2,668
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/Problem10.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.floor import kotlin.math.sqrt import kotlin.system.measureNanoTime /** * Summation of primes * * The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. * Find the sum of all the primes below two million. * * https://projecteuler.net/problem=10 */ fun main() { println(sumOfPrimes(10)) ...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,285
project-euler
MIT License
src/day16/Day16.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day16 import logEnabled import logln import readInput private const val DAY_NUMBER = 16 val valveRegex = """Valve ([A-Z]{2}) has flow rate=(\d+); tunnels? leads? to valves? ([A-Z, ]+)""".toRegex() typealias NodeId = String fun parseFile(rawInput: List<String>): Map<NodeId, ValveNode> { val flowMap = mu...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
4,776
advent-of-code-2022
Apache License 2.0
src/day08/Day08.kt
Frank112
572,910,492
false
null
package day08 import assertThat import readInput fun main() { fun parseInput(input: List<String>): List<List<Int>> { return input.map { l -> l.chunked(1).map { it.toInt() } } } fun isTreeVisibleFromLeft(input: List<List<Int>>, x: Int, y: Int): Boolean { val treeHeight = input[x][y] ...
0
Kotlin
0
0
1e927c95191a154efc0fe91a7b89d8ff526125eb
3,593
advent-of-code-2022
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day21/Day21.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day21 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2021.DayOf2021 import java.util.PriorityQueue /** * See [Year 2021, Day 21](https://adventofcode.com/2021/day/21) */ object Day21 : DayOf2021(21) { override fun first(): Any? { val start = lines.map { it.split("...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,200
adventofcode
MIT License
src/year2023/day08/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2023.day08 import year2023.getLCM import year2023.solveIt fun main() { val day = "08" val expectedTest1 = 6L val expectedTest2 = 6L fun navigateToNext( instructions: String, currIdx: Int, paths: Map<String, Pair<String, String>>, current: String ) = if (instructions[currIdx]...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
1,530
adventOfCode
Apache License 2.0
src/Day11.kt
arnoutvw
572,860,930
false
{"Kotlin": 33036}
import com.notkamui.keval.Keval fun main() { data class Monkey(val numbers: MutableList<Long>, val operation: String, val divisibleBy: Int, val monkyIfTrue: Int, val monkeyIfFalse: Int, var inspections: Long = 0) fun part1(input: List<String>, monkeys: MutableMap<Int, Monkey>): Int { for(i in 1..20) ...
0
Kotlin
0
0
0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4
3,603
aoc-2022-in-kotlin
Apache License 2.0
day-10/src/main/kotlin/SyntaxScoring.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
import java.util.LinkedList import java.util.Stack fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } val closingMatch = mapOf( ')' to '(', ']' to '[', '}' to '{', '>' to '<', ) val openingMatch = mapOf( '(' to ')', '[' to ']', '{'...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
2,266
aoc-2021
MIT License
src/Day02.kt
Hwajun1323
574,962,608
false
{"Kotlin": 6799}
import kotlin.math.min enum class RPS(val value: Int){ ROCK(1), PAPER(2), SCISSORS(3), } object WinScore{ const val WIN = 6 const val LOOSE = 0 const val DRAW = 3 } fun main() { fun Char.toGameChoice():RPS = when(this) { 'A', 'X' -> RPS.ROCK 'B', 'Y' -> RP...
0
Kotlin
0
0
667a8c7a0220bc10ddfc86b74e3e6de44b73d5dd
2,636
advent-of-code-2022
Apache License 2.0
src/Day02.kt
seana-zr
725,858,211
false
{"Kotlin": 28265}
import java.lang.IllegalStateException import java.util.regex.Pattern import kotlin.math.max fun main() { data class GameRound( var red: Int = 0, var green: Int = 0, var blue: Int = 0, ) /** * which games would have been possible if the bag contained only * 12 red cubes, ...
0
Kotlin
0
0
da17a5de6e782e06accd3a3cbeeeeb4f1844e427
3,095
advent-of-code-kotlin-template
Apache License 2.0
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day04.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 class Day04 : Day<Int> { private val input = readDayInput() .split("\n\n") .map { chunk -> chunk.lines() } private val draw = input .first() .first() ...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
3,697
adventofcode
Apache License 2.0
src/Day14.kt
oleksandrbalan
572,863,834
false
{"Kotlin": 27338}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { val input = readInput("Day14") .filterNot { it.isEmpty() } .map { row -> row.split(" -> ").map { Point.from(it) } } val part1 = input.sandSimulation() println("Part1: $part1") val bounds = input.flatten(...
0
Kotlin
0
2
1493b9752ea4e3db8164edc2dc899f73146eeb50
2,662
advent-of-code-2022
Apache License 2.0
src/Day15.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
import extensions.grid.* import kotlin.math.abs class Day15 : Day(15) { data class SensorInfo(val sensor: Point, val beacon: Point) private fun parseInput(input: String): List<SensorInfo> { return input.lines() .map { line -> line.filter { it.isDigit() || it == '-' || it == '='} } ...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
2,233
aoc-2022-in-kotlin
Apache License 2.0
src/day19/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day19 import util.extractIntGroups import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 33 testInput.part2() shouldBe 56 * 62 val input = readInput(Input::class).parseInput() println("outp...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
4,360
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Valves.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
fun main() = Valves.solve() private object Valves { fun solve() { val nodes = readInput() val maxPressure = findMaxPressureRelease(nodes, "AA", 26) println("Max releasable pressure: ${maxPressure}") } private fun readInput(): Map<String, Node> = buildMap<String, Node> { gen...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
5,273
aoc2022
MIT License
src/Day13.kt
wbars
576,906,839
false
{"Kotlin": 32565}
import java.lang.Integer.min sealed interface Value { fun lessThan(value: Value): Boolean? } class IntValue(val v: Int) : Value { override fun lessThan(value: Value): Boolean? { return if (value is IntValue) { if (this.v < value.v) true else if (this.v > value.v) false else null } ...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
2,797
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc22/Day11.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import lcm import readInput data class Monkey( val name: String, val items: MutableList<Long> = mutableListOf(), val operation: String, val divisor: Long, val ifTrueTarget: Int, val ifFalseTarget: Int, var inspections: Long = 0 ) { fun doRound(worryDivisor: Long, leastCom...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
3,290
advent-of-code
Apache License 2.0
2022/src/main/kotlin/de/skyrising/aoc2022/day24/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day24 import de.skyrising.aoc.* private class Day24Setup(val start: Vec2i, val end: Vec2i, val grid: CharGrid, val blizzardsX: Array<Set<Vec2i>>, val blizzardsY: Array<Set<Vec2i>>) { fun validPos(pos: Vec2i) = pos in grid || pos == start || pos == end fun blizzardAt(pos: Vec2i, t:...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,262
aoc
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem15/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem15 /** * LeetCode page: [15. 3Sum](https://leetcode.com/problems/3sum/); */ class Solution { /* Complexity: * Time O(N^2) and Space O(N) where N is the size of nums; */ fun threeSum(nums: IntArray): List<List<Int>> { val sortedNumbers = getSortedNumbers...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,200
hj-leetcode-kotlin
Apache License 2.0
src/Day09.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import kotlin.math.abs data class Coord(var x: Int, var y: Int) const val dim = 1000 val field = Array(dim) { ByteArray(dim) } val rope = Array(10) { Coord(dim / 2, dim / 2) } var hx = dim / 2 var hy = dim / 2 var tx = dim / 2 var ty = dim / 2 fun moveHead(dir: Char) { when (dir) { 'U' -> hy++ ...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
2,552
AoC-2022
Apache License 2.0
src/day16/day16.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
package day16 import streamInput import java.util.* import kotlin.math.max data class Valve(val name: String, val rate: Int, val tunnels: Set<String>) private val regex = Regex("""Valve (\w+) has flow rate=([\d]+); tunnels? leads? to valves? ((?:\w+(?:, )?)+)""") fun Sequence<String>.parseInput(): Sequence<Valve> {...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
4,788
aoc-2022
Apache License 2.0
src/main/kotlin/aoc22/Day08.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import datastructures.Direction import readInput fun List<List<Int>>.heightOfTreeInDirection(direction: Direction, y: Int, x: Int): Int { if ((y == 0) || (x == 0) || (y == lastIndex) || x == lastIndex) return -1 return when (direction) { Direction.NORTH -> this[y - 1][x] Directi...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
2,500
advent-of-code
Apache License 2.0
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day16.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty import sh.weller.adventofcode.util.product fun List<String>.day16Part2(): Long { val splitInput = mutableListOf<List<String>>() var lastIndex = 0 this.forEachIndexed { index, s -> if (s == "") { splitInput.add(this.subList(lastIndex, index))...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
4,526
AdventOfCode
MIT License
src/day06/Day06.kt
pnavais
727,416,570
false
{"Kotlin": 17859}
package day06 import readInput enum class Direction { UP, DOWN } fun traverse(time: Long, refTime: Long, distance: Long, direction: Direction): Long { var isValid = true var numWays = 0L var startTime = time while (isValid) { if (startTime.times(refTime.minus(startTime)) > distance) { ...
0
Kotlin
0
0
f5b1f7ac50d5c0c896d00af83e94a423e984a6b1
1,657
advent-of-code-2k3
Apache License 2.0
src/Day09.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.abs private val moves = mapOf("R" to Pair(1, 0), "L" to Pair(-1, 0), "U" to Pair(0, 1), "D" to Pair(0, -1)) private data class Point(var x: Int, var y: Int) { fun move(direction: String, steps: Int) { x += steps * moves[direction]!!.first y += steps * moves[direction]!!.second ...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,830
aoc-2022
Apache License 2.0
src/Day03.kt
defvs
572,381,346
false
{"Kotlin": 16089}
fun main() { fun part1(input: List<String>) = input.sumOf { rucksack -> // Create a set of the items in the first compartment val first = rucksack.substring(0, rucksack.length / 2).toSet() // Create a set of the items in the second compartment val second = rucksack.substring(rucksack.length / 2).toSet() ...
0
Kotlin
0
1
caa75c608d88baf9eb2861eccfd398287a520a8a
1,330
aoc-2022-in-kotlin
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/15.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d15 fun main() { println("Part 1: ${part1(input.read("15.txt"))}") println("Part 2: ${part2(input.read("15.txt"))}") } fun part1(input: List<String>): Int = input[0].split(",").sumOf { hash(it) } fun part2(input: List<String>): Int { val boxes: MutableMap<Int, MutableMap<String, Int>> = mutab...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
1,276
aoc
The Unlicense
src/Day03.kt
riFaulkner
576,298,647
false
{"Kotlin": 9466}
fun main() { fun part1(input: List<String>): Int { val rucksackPriorities = input.map {rucksack -> val (comp1, comp2) = getRucksackCompartments(rucksack) calculatePriority(comp1, comp2) } return rucksackPriorities.sum() } fun part2(input: List<String>): Int { ...
0
Kotlin
0
0
33ca7468e17c47079fe2e922a3b74fd0887e1b62
2,481
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/Main.kt
Jeff-Gillot
521,245,168
false
{"Kotlin": 8976}
import java.io.File import kotlin.system.measureTimeMillis fun main() { val time = measureTimeMillis { // Read the words and keep only 5 letters words val textWords = File(Signature::class.java.getResource("words_alpha.txt")!!.toURI()) .readLines() .filter { it.length == 5 ...
0
Kotlin
1
2
4b110074945cf161680a6e804038f7fb54e54ca9
8,526
word-clique
MIT License
src/Day15/Day15.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day15 import checkAndPrint import discreteDistanceTo import measureAndPrintTimeMillis import readInput import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { val lineRgx = """Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at x=(-?\d+), y=(-?\d+)""".toRegex() fun List<Str...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
3,410
AdventOfCode2022
Apache License 2.0
src/day13/Day13.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day13 import readLines fun main() { val id = "13" val testOutput = 13 val testInput = readInput("day$id/Day${id}_test") println(part1(testInput)) check(part1(testInput) == testOutput) val input = readInput("day$id/Day$id") println(part1(input)) println(part2(input)) } priv...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
3,030
advent-of-code-2022
Apache License 2.0
src/Day16.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
import kotlin.system.measureTimeMillis data class Valve(val id: String, val flowRate: Int = 0, val neighbors: List<String>) { companion object { private val valveRegex = "^Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? ((?:\\w+(?:, )?)+)$".toRegex() fun from(line: String): Valve { ...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
6,911
advent-of-code-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2017/Day24.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2017 import se.saidaspen.aoc.util.Day fun main() = Day24.run() data class Port(val inPins: Int, val outPins: Int) object Day24 : Day(2017, 24) { private val ports: List<Port> = input.lines().map { it.split("/") }.map { Port(it[0].toInt(), it[1].toInt()) } override fun part1(): ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,906
adventofkotlin
MIT License
src/Day05.kt
nielsz
573,185,386
false
{"Kotlin": 12807}
typealias StackLot = Array<ArrayDeque<Char>> fun main() { fun part1(stackLot: StackLot, operations: List<List<Int>>): String { operations.onEach { operation -> repeat(operation[0]) { val crate = stackLot[operation[1] - 1].removeLast() stackLot[operation[2] - 1].a...
0
Kotlin
0
0
05aa7540a950191a8ee32482d1848674a82a0c71
2,521
advent-of-code-2022
Apache License 2.0
src/Day02.kt
dannyrm
573,100,803
false
null
import DesiredOutcome.* import Move.* import kotlin.reflect.KFunction2 fun main() { fun part1(input: List<String>): Int { return input.map { convertToMovePair(it, ::calculatePart1Move) }.sumOf { calculateMoveResult(it) } } fun part2(input: List<String>): Int { return input.map { convertToM...
0
Kotlin
0
0
9c89b27614acd268d0d620ac62245858b85ba92e
2,257
advent-of-code-2022
Apache License 2.0
2022/src/main/kotlin/day22.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import Day22.Direction.DOWN import Day22.Direction.LEFT import Day22.Direction.RIGHT import Day22.Direction.UP import utils.Grid import utils.IntGrid import utils.Parser import utils.Solution import utils.Vec2i import utils.badInput fun main() { Day22.run() } object Day22 : Solution<Pair<Grid<Char>, List<Day22.Insn...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
6,624
aoc_kotlin
MIT License
src/Day14.kt
ricardorlg-yml
573,098,872
false
{"Kotlin": 38331}
import java.lang.Integer.max import java.lang.Integer.min class Day14Solver(private val input: List<String>) { private var maxCol: Int = -1 private var maxRow: Int = -1 data class Path(val point1: Point, val point2: Point) { fun range(): List<Point> { return if (point1.row == point2.r...
0
Kotlin
0
0
d7cd903485f41fe8c7023c015e4e606af9e10315
3,726
advent_code_2022
Apache License 2.0
src/Day04.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
fun main() { fun processInput(input: List<String>): List<Pair<IntRange, IntRange>> { return input.map { val (first, second) = it.split(",") val (firstFirst, firstSecond) = first.split("-") val (secondFirst, secondSecond) = second.split("-") (firstFirst.toInt...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
1,121
aoc-2022-in-kotlin
Apache License 2.0
src/Day05.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { data class Common(val input: List<String>) { lateinit var moves: List<String> lateinit var stacks: List<ArrayDeque<Char>> init { parse() } fun parse() { val map = input.groupBy { when { it.contains("...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,905
aoc-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day04.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { part1() part2() } private fun part1() { val points = readInput(2023, 4).useLines { lines -> lines.sumOf { line -> val (winner, own) = line.split(" | ") val numbers ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,297
adventofcode
Apache License 2.0
src/Day04.kt
sebastian-heeschen
572,932,813
false
{"Kotlin": 17461}
fun main() { fun part1(input: List<String>): Int = intRanges(input) .count { (firstSections, secondSections) -> firstSections.all { secondSections.contains(it) } || secondSections.all { firstSections.contains(it) } } fun part2(input: List<String>): Int { return intRanges(in...
0
Kotlin
0
0
4432581c8d9c27852ac217921896d19781f98947
1,163
advent-of-code-2022
Apache License 2.0
src/Day07.kt
wbars
576,906,839
false
{"Kotlin": 32565}
class Node(val name: String, val parent: Node? = null, val children: MutableMap<String, Node> = mutableMapOf(), val size: Long = 0) { override fun toString(): String { return name + " " + (if (children.isEmpty()) size else "dir") } } fun main() { fun putNode(cur: Node, dir: String, size: Long = 0) =...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
2,168
advent-of-code-2022
Apache License 2.0
src/day4/Day04.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day4 import readInput fun main() { fun part1(input: List<String>): Int { return input.map { row -> row.split(",").map { it.toAssignment() }.isDuplicate() }.map { overlapping -> if (overlapping) 1 else 0 }.sum() } fun part2(input: List<String>): Int { return inp...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
1,663
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dp/LOS.kt
yx-z
106,589,674
false
null
package dp import util.OneArray import util.max import util.oneArrayOf // longest oscillating subsequence // X[1..n] is oscillating if X[i] < X[i + 1] for even i, and X[i] > X[i + 1] for odd i // find the length of los of A[1..n] fun main(args: Array<String>) { val A = intArrayOf(-1 /* ignored value to be one-inde...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,426
AlgoKt
MIT License
src/com/ncorti/aoc2023/Day01.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 import kotlin.math.max fun main() { fun part1() = getInputAsText("01") { split("\n") } .filterNot(String::isBlank) .map(String::toCharArray) .sumOf { array -> val firstDigit = array.first { it.isDigit() }.digitToInt() val lastD...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
2,658
adventofcode-2023
MIT License
src/Day05.kt
razvn
573,166,955
false
{"Kotlin": 27208}
fun main() { val day = "Day05" fun part1(input: List<String>): String { val (creates, cmds) = load(input) cmds.forEach { c -> val take = creates[c.from]!!.take(c.number) creates[c.from] = creates[c.from]!!.drop(c.number) take.forEach { creates...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
2,228
aoc-2022-kotlin
Apache License 2.0
src/Day13.kt
pavlo-dh
572,882,309
false
{"Kotlin": 39999}
sealed class E : Comparable<E> class L(vararg elements: E) : E() { val elements = mutableListOf(*elements) override fun compareTo(other: E): Int = when (other) { is L -> { elements.forEachIndexed { index, element -> val otherElement = other.elements.getOrNull(index) ?: retu...
0
Kotlin
0
2
c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992
3,957
aoc-2022-in-kotlin
Apache License 2.0
src/year2023/day19/Day19.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day19 import check import readInput import splitByEmptyLines fun main() { val testInput = readInput("2023", "Day19_test") check(part1(testInput), 19114) check(part2(testInput), 167409079868000) val input = readInput("2023", "Day19") println(part1(input)) println(part2(input))...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
8,126
AdventOfCode
Apache License 2.0
src/Day03/Day03.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
import kotlin.math.pow fun main() { fun bitListToInt(input: List<Int>) = input.foldIndexed(0) { index, sum, elem -> sum + elem * (2.0).pow(input.size - index - 1).toInt() } fun part1(input: List<String>): Int { val zeros = MutableList(input[0].length) { 0 } for (e in input) { ...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
1,555
advent-of-code-2021
Apache License 2.0
src/Day09.kt
stevennoto
573,247,572
false
{"Kotlin": 18058}
import java.util.Deque import kotlin.math.absoluteValue fun main() { // Adjust rope head position based on direction fun moveHead(head: Pair<Int, Int>, direction: String): Pair<Int, Int> { return when (direction) { "U" -> Pair(head.first, head.second + 1) "D" -> Pair(head.first,...
0
Kotlin
0
0
42941fc84d50b75f9e3952bb40d17d4145a3036b
3,095
adventofcode2022
Apache License 2.0
src/main/kotlin/day12.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.getText import shared.placeInAlphabet import shared.Point fun main() { val input = getText("day12.txt") println(day12A(input)) println(day12B(input)) } fun day12A(input: String): Int { val startY = input.lines().indexOfFirst { it.contains("S") } val startX = input.lines()[startY].ind...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
2,662
AdventOfCode2022
MIT License
src/main/kotlin/y2023/Day2.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day import kotlin.math.max class Day2 : Day(2, 2023, false) { override fun partOne(): Any { return inputList .mapToGame() .filter { game -> game.grabs.fold(true) { acc1, cubes -> acc1 && cubes.fold(true) { acc2, cube ->...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
2,499
adventofcode
MIT License
src/Day05.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
data class Move(val from: Int, val to: Int, val count: Int) data class Input( val dequeues: List<ArrayDeque<Char>>, val moves: List<Move> ) fun main() { fun part1(input: Input): List<Char> { val dequeues = List(input.dequeues.size) { i -> ArrayDeque(input.dequeues[i]) } input.moves.forEach ...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
3,028
aoc22-kotlin
Apache License 2.0
src/main/kotlin/advent/day5/HydrothermalVenture.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day5 import advent.loadInput import java.io.File import kotlin.math.abs /** * @author <NAME> */ data class Coordinate(val x: Int, val y: Int) data class LineSegment(val start: Coordinate, val end: Coordinate) fun LineSegment.isHorizontalOrVertical() = start.x == end.x || start.y == end.y fun LineSeg...
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
2,520
Advent-of-code-2021
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day13/Day13.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day13 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputSplitOnBlank import kotlin.math.abs object Day13 : Day { override val input = Grid.from(readInputSplitOnBlank(13).map { it.lines() }) override fun part1() = input.fold...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,230
aoc2021
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day17.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2016 import se.saidaspen.aoc.util.* fun main() = Day17.run() typealias State = P<P<Int, Int>, String> object Day17 : Day(2016, 17) { val next : (State) -> Iterable<State> = { (pos, inp) -> val doorState = doorState(inp, pos) val next = mutableListOf<State>() ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,020
adventofkotlin
MIT License
src/DayTwo.kt
P-ter
573,301,805
false
{"Kotlin": 9464}
data class Dimension(val length: Int, val width: Int, val height: Int) fun main() { fun part1(input: List<String>): Int { val dimensions = input.map { val dimension = it.split("x") Dimension(dimension[0].toInt(), dimension[1].toInt(), dimension[2].toInt()) } val tota...
0
Kotlin
0
0
fc46b19451145e0c41b1a50f62c77693865f9894
1,426
aoc-2015
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day06/day6.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day06 import biz.koziolek.adventofcode.findInput import kotlin.math.ceil import kotlin.math.floor import kotlin.math.pow import kotlin.math.sqrt fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val races = pars...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,640
advent-of-code
MIT License
src/day14/first/Solution.kt
verwoerd
224,986,977
false
null
package day14.first import tools.ceilDivision import tools.timeSolution import java.util.LinkedList import kotlin.math.max fun main() = timeSolution { val reactionList = readReactionInput() println(solver(reactionList, 1L)) } fun readReactionInput() = System.`in`.bufferedReader().readLines() .map { it.split("=...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
2,292
AoC2019
MIT License
src/main/kotlin/org/hydev/lcci/lcci_01.kt
VergeDX
334,298,924
false
null
import kotlin.collections.set import kotlin.math.abs // https://leetcode-cn.com/problems/is-unique-lcci/ fun isUnique(astr: String): Boolean { // All character, maybe not in English...? // if (astr.length > 24) return false astr.forEachIndexed { index, c -> if (astr.indexOf(c) != index) return false } ...
0
Kotlin
0
0
9a26ac2e24b0a0bdf4ec5c491523fe9721c6c406
4,963
LeetCode_Practice
MIT License
src/main/kotlin/pl/bizarre/day7_1.kt
gosak
572,644,357
false
{"Kotlin": 26456}
package pl.bizarre import pl.bizarre.common.loadInput fun main() { val input = loadInput(7) println("result ${day7_1(input)}") } fun day7_1(input: List<String>): Int { val fileSystem = input.getFileSystem() val allDirectories = fileSystem.allDirectories() val allDirectoriesWithSizeAtMost100000 = ...
0
Kotlin
0
0
aaabc56532c4a5b12a9ce23d54c76a2316b933a6
2,497
adventofcode2022
Apache License 2.0
src/main/kotlin/Day07.kt
SimonMarquis
724,825,757
false
{"Kotlin": 30983}
import Day07.Card.J class Day07(private val input: List<String>) { private fun String.toHand() = split(" ").let { (cards, bid) -> Hand( cards = cards.map(Char::toString).map(Card::valueOf), bid = bid.toLong(), ) } private data class Hand(val cards: List<Card>, val ...
0
Kotlin
0
1
043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e
2,423
advent-of-code-2023
MIT License
src/main/kotlin/dev/bogwalk/batch8/Problem83.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch8 import java.util.PriorityQueue /** * Problem 83: Path Sum 4 Ways * * https://projecteuler.net/problem=83 * * Goal: Find the minimum path sum for an NxN grid, starting at (0,0) and ending at (n,n), by * moving left, right, up, or down with each step. * * Constraints: 1 <= N <= 1000, ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,395
project-euler-kotlin
MIT License
src/Day02.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
fun main() { fun pair(inputLine: String): Pair<Char, Char> { val split = inputLine.split(" ") val opponent = split[0].toCharArray()[0] val we = split[1].toCharArray()[0] return Pair(opponent, we) } fun solve1(inputLine: String): Int { val (opponent, we) = pair(input...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
1,564
aoc-2022
Apache License 2.0