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
AdventOfCodeDay21/src/nativeMain/kotlin/Day21.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
private data class GameState( val player1: PlayerState, val player2: PlayerState, val player1Turn: Boolean = true ) { fun next(die: Int): GameState = GameState( if (player1Turn) player1.next(die) else player1, if (!player1Turn) player2.next(die) else player2, ...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
3,150
AdventOfCode2021
The Unlicense
src/Day07.kt
eo
574,058,285
false
{"Kotlin": 45178}
// https://adventofcode.com/2022/day/7 fun main() { fun parseListDirectoryOutput(lines: List<String>): List<File> = lines.map { line -> val (first, second) = line.split(" ") if (first == "dir") { Directory(second) } else { ...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
4,761
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day12.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.dsl.parser.InputParser import javax.swing.Spring const val OPERATIONAL = '.' const val DAMAGED = '#' const val UNKNOWN = '?' val cache = mutableMapOf<String, Long>() data class ...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
3,090
aoc-2023
The Unlicense
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day09.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.P import se.saidaspen.aoc.util.words fun main() = Day09.run() object Day09 : Day(2015, 9) { private val graph = mutableMapOf<P<String, String>, Int>() private val cities = mutableListOf<String>() init { ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,225
adventofkotlin
MIT License
src/Day12.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
import java.util.PriorityQueue import kotlin.streams.toList import kotlin.math.abs const val START = 83 const val END = 69 fun Vector2.manhattanDist(b: Vector2): Int { return abs(this.first-b.first) + abs(this.second-b.second) } fun main() { fun readMap(input: List<String>): List<MutableList<Int>> { ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
4,266
aoc2022
Apache License 2.0
2021/src/day14/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day14 import java.nio.file.Files import java.nio.file.Paths fun main() { fun part1(input: Input): Int { fun iterate(template: String, rules: Map<String, String>) = buildString { append(template[0]) for (i in 1 until template.length) { rules[template.substring(i - 1, i + 1)]?.let { ...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
2,289
advent-of-code
Apache License 2.0
src/day04/Day04.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day04 import println import readInputAsText typealias Board = List<List<BingoNumber>> data class BingoNumber(val number: Int, var called: Boolean = false) data class CompletedBoard(val number: Int, val board: Board) fun main() { fun parseNumbers(input: String) = input.split("\n").first().split(",").map...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
2,141
advent-of-code-2021
Apache License 2.0
src/Day11.kt
mikemac42
573,071,179
false
{"Kotlin": 45264}
import java.io.File fun main() { val testInput = """Monkey 0: Starting items: 79, 98 Operation: new = old * 19 Test: divisible by 23 If true: throw to monkey 2 If false: throw to monkey 3 Monkey 1: Starting items: 54, 65, 75, 74 Operation: new = old + 6 Test: divisible by 19 If true: throw t...
0
Kotlin
1
0
909b245e4a0a440e1e45b4ecdc719c15f77719ab
3,573
advent-of-code-2022
Apache License 2.0
kotlin/src/2022/Day15_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min private fun part1(entries: List<List<Int>>, Y: Int = 2000000) { val beaconsAt = mutableSetOf<Int>() val s = mutableSetOf<Int>() for (e in entries) { val dist = abs(e[0] - e[2]) + abs(e[1] - e[3]) if (abs(Y - e[1]) > dist) ...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
2,016
adventofcode
Apache License 2.0
src/Day12.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
import java.util.* fun main() { val day = "Day12" fun reconstructPath( cameFrom: HashMap<Pair<Int, Int>, Pair<Int, Int>>, node: Pair<Int, Int> ): MutableList<Pair<Int, Int>> { var path = mutableListOf(node) var current = node while (cameFrom.containsKey(current)) {...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
6,180
advent-of-code-2022
Apache License 2.0
src/Day11.kt
dmstocking
575,012,721
false
{"Kotlin": 40350}
import java.lang.Exception import java.util.Base64 fun parseMonkey(lines: List<String>, constructor: (Long, (Long) -> Long, (Long) -> Int, List<Long>) -> Monkey): Monkey { val items = lines[1].substring(18).split(", ").map { it.toLong() } val (a, op, b) = lines[2].substring(19).split(" ") val operation = {...
0
Kotlin
0
0
e49d9247340037e4e70f55b0c201b3a39edd0a0f
2,833
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
splinkmo
573,209,594
false
{"Kotlin": 6593}
fun main() { fun binarySort(searchChar: Char, charList: List<Char>): Boolean{ if (charList.size <= 1){ return charList[0] == searchChar } var chunkedValue = if (charList.size % 2 == 0) charList.size/2 else charList.size/2 + 1 return if (searchChar < charList[chunkedValue]...
0
Kotlin
0
0
4ead85d0868feec13cc300055beba7830b798345
1,599
advent-code-22
Apache License 2.0
src/main/kotlin/Day4.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
private val part1ExampleInput = """ 2-4,6-8 2-3,4-5 5-7,7-9 2-8,3-7 6-6,4-6 2-6,4-8 """.trimIndent() fun main() { println("day4") println() println("part1") assertEquals(part1(part1ExampleInput), 2) assertEquals(part1(readInputFile("day4_input.txt")), 485) // regression fo...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
1,523
advent_of_code_2022
MIT License
day06/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File import java.lang.Double.POSITIVE_INFINITY import kotlin.math.abs fun main() { val input = parseInput(readInputFile()) println("Part I: the solution is ${solvePartI(input)}.") println("Part II: the solution is ${solvePartII(input)}.") } fun readInputFile(): List<String> { return Fi...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
4,179
AdventOfCode2018
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day15.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import kotlin.math.max object Day15 { private val input = mapOf( "Sprinkles" to Ingredient(2, 0, -2, 0, 3), "Butterscotch" to Ingredient(0, 5, -3, 0, 3), "Chocolate" to Ingredient(0, 0, 5, -1, 8), "Candy" to Ingredient(0, -1, 0, 5, 8...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
1,928
adventofcode2015
MIT License
src/Day04.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
fun main() { class Range(val from: Int, val to: Int) { init { require(from <= to) } fun contains(other: Range): Boolean = from <= other.from && other.to <= to fun intersects(other: Range): Boolean = when { to < other.from -> false...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
1,472
aoc2022
Apache License 2.0
src/Day04.kt
devheitt
573,207,407
false
{"Kotlin": 11944}
fun main() { fun part1(input: List<String>): Int { //In how many assignment pairs does one range fully contain the other? var count = 0 for (line in input) { val pairs = line.split(",") val firstPair = pairs[0].split("-").map { c -> c.toInt() } val second...
0
Kotlin
0
0
a9026a0253716d36294709a547eaddffc6387261
1,435
advent-of-code-2022-kotlin
Apache License 2.0
src/test/kotlin/com/igorwojda/list/maxsublistsum/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.list.maxsublistsum import kotlin.math.max // Time Complexity: O(n) // Space Complexity: O(1) // Use "sliding window" - store sum in single variable and with each iteration add (current item) // and remove (first item before current sub-list) private object Solution1 { private fun maxSubListS...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
2,568
kotlin-coding-challenges
MIT License
src/main/kotlin/Day15.kt
brigham
573,127,412
false
{"Kotlin": 59675}
import kotlin.math.absoluteValue val pattern15 = Regex("""Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at x=(-?\d+), y=(-?\d+)""") data class Position15(val x: Int, val y: Int) { fun distance(other: Position15): Int { return (x - other.x).absoluteValue + (y - other.y).absoluteValue } } data clas...
0
Kotlin
0
0
b87ffc772e5bd9fd721d552913cf79c575062f19
4,634
advent-of-code-2022
Apache License 2.0
src/Day08.kt
Advice-Dog
436,116,275
true
{"Kotlin": 25836}
fun main() { val zero = 6 val one = 2 val two = 5 val three = 5 val four = 4 val five = 5 val six = 6 val seven = 3 val eight = 7 val nine = 6 val unique = listOf(one, four, seven, eight) fun part1(input: List<String>): Int { return input.sumOf { va...
0
Kotlin
0
0
2a2a4767e7f0976dba548d039be148074dce85ce
6,358
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2019/Day14.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2019 import com.nibado.projects.advent.Day import com.nibado.projects.advent.graph.Graph import com.nibado.projects.advent.resourceLines import kotlin.math.ceil typealias ElementAmount = Pair<String, Int> object Day14 : Day { private val reactionsReal = resourceLines(2019, 14)...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,230
adventofcode
MIT License
src/Day9/Day9.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day9 import readInput import kotlin.math.abs import kotlin.math.hypot import kotlin.math.max fun main() { data class Point(var x: Int = 0, var y: Int = 0) fun part1(input: List<String>): Int { val size = 800 val visited = Array(size) { BooleanArray(size) } val head = Point(250...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
3,063
aoc-2022-in-kotlin
Apache License 2.0
src/Day12.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.streams.toList fun main() { class Node(val name: String) { val neighbors = HashMap<String, Node>() fun addNeighbor(n: Node) { this.neighbors[n.name] = n n.neighbors[this.name] = this } fun isBig() = name[0].isUpperCase() override fun...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
2,827
advent_of_code21_kotlin
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/04.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 d04 import input.read fun main() { println("Part 1: ${part1(read("04.txt"))}") println("Part 2: ${part2(read("04.txt"))}") } fun part1(lines: List<String>): Int { return lines.map(::Game).sumOf { game -> game.play() } } fun part2(lines: List<String>): Int { val games: List<Game> = lines.map(...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
1,737
aoc
The Unlicense
src/Day03.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val first = rucksack.substring(0 until rucksack.length / 2) val second = rucksack.substring(rucksack.length / 2) val common = first.toSet() intersect second.toSet() common.sing...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
1,143
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day11.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 object Day11 { fun part1(input: List<String>): Long = process(input, 20, 3, false) fun part2(input: List<String>): Long = process(input, 10_000, 1, true) private fun process(input: List<String>, times: Int, divisor: Long, lcmMode: Boolean): Long { val monkeys = input.chu...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
3,278
advent22
Apache License 2.0
src/main/kotlin/day03/Solution.kt
kcchoate
683,597,644
false
{"Kotlin": 25162}
package day03 class Solution { fun solve(items: List<String>): Int { val sums = countArray(items) val target = items.size / 2 val gammaRate = count(sums) { if (it < target) 0 else 1 } val epsilonRate = count(sums) { if (it < target) 1 else 0 } return gammaRate * epsilonRa...
0
Kotlin
0
1
3e7c24bc69a4de168ce0bdff855323c803b9a9a8
1,862
advent-of-kotlin
MIT License
src/year2023/12/Day12.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`12` import kotlinx.coroutines.runBlocking import readInput private const val CURRENT_DAY = "12" private fun parseLineInto( line: String ): Pair<String, List<Int>> { val splitted = line.split(" ") val resLine = splitted.first() val ranges = splitted[1].split(",").mapNotNull { it.toIn...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,590
KotlinAdventOfCode
Apache License 2.0
src/day21/b/day21b.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day21.b import day21.a.Expr import day21.a.Num import day21.a.Op import day21.a.evaluate import readInputLines import shouldBe fun main() { val root = read() val r = solveForUnknown(root.a, root.b) val answer = (evaluate(r) as Num).value shouldBe(3006709232464L, answer) } /** * Solve f = g f...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,752
advent-of-code-2022
Apache License 2.0
src/Day04.kt
SeanDijk
575,314,390
false
{"Kotlin": 29164}
fun main() { data class Assignment(val start: Int, val end: Int) { fun size() = end - start } fun parseAssignment(assignmentString: String): Assignment { val (x, y) = assignmentString.split('-') return Assignment(x.toInt(), y.toInt()) } fun part1(input: List<String>): Int ...
0
Kotlin
0
0
363747c25efb002fe118e362fb0c7fecb02e3708
1,450
advent-of-code-2022
Apache License 2.0
src/Day05.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { data class StacksInfo( val lineStacks: Int, val positions: List<Int>, val stacks: MutableList<MutableList<Char>> ) fun parseInput(input: List<String>): StacksInfo { val tempInfo = input.mapIndexed { index, value -> index to value } .first { (_, it) ...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
2,331
AoC-2022
Apache License 2.0
src/Day05.kt
mvanderblom
573,009,984
false
{"Kotlin": 25405}
import java.util.* data class Move(val amount: Int, val from: Int, val to: Int ) data class GameState(val stacks: List<Stack<String>>, val moves: List<Move>) { fun getTopLevelCrates() = stacks.joinToString("") { it.last() } } fun String.replaceAll(searches: List<String>, replacement: String): String { var s =...
0
Kotlin
0
0
ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690
2,770
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/de/nosswald/aoc/days/Day05.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day // https://adventofcode.com/2023/day/5 object Day05 : Day<Long>(5, "If You Give A Seed A Fertilizer") { data class RangeEntry(val destinationStart: Long, val sourceStart: Long, val length: Long) { val sourceRange get(): LongRange { return...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
3,294
advent-of-code-2023
MIT License
src/Day15.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
import kotlin.math.abs fun Coordinates.distance(to: Coordinates): Int = abs(x - to.x) + abs(y - to.y) data class Sensor( val sensorCoordinates: Coordinates, val beaconCoordinates: Coordinates, ) { val distance: Int get() = sensorCoordinates.distance(beaconCoordinates) fun withinRange(coor...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
3,574
AdventOfCode2022
Apache License 2.0
src/Day04.kt
bendh
573,833,833
false
{"Kotlin": 11618}
fun main() { fun String.toIntRange(): IntRange { val rangeRegex = Regex(pattern = """^\d+-\d+$""") return if (rangeRegex.matches(this)) { val values = this.split("-").map { it.toInt() } values[0]..values[1] } else { 0..0 } } fun hasComple...
0
Kotlin
0
0
e3ef574441b63a99a99a095086a0bf025b8fc475
1,488
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day09.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput private class History(private val initialSequence: List<Int>) { companion object { fun fromString(line: String) = History(line.split(" ").map { char -> char.toInt() }) } fun getNextValue(): Int { var currentSequence = initialSequence val lastValue...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,831
adventOfCode
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2023/Day03.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2023 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part3A : PartSolution() { internal lateinit var symbols: List<Symbol> internal lateinit var numbers: List<Number> override fun parseInput(text: String) { val numbers = muta...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,227
advent-of-code-kotlin
MIT License
aoc-2023/src/main/kotlin/aoc/aoc2.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val day = 2 val testInput = """ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red Game 4: 1 ...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
1,705
advent-of-code
Apache License 2.0
src/main/kotlin/day07/day07.kt
andrew-suprun
725,670,189
false
{"Kotlin": 18354, "Python": 17857, "Dart": 8224}
package day07 import java.io.File data class Bid(val hand: String, val bet: Int) fun main() { run(encode1, ::part1) run(encode2, ::part2) } fun run(encode: Map<Char, Char>, rank: (String) -> Char) { val result = File("input.data").readLines().map { parseHand(it, encode, rank) }.sortedBy { it.hand }.with...
0
Kotlin
0
0
dd5f53e74e59ab0cab71ce7c53975695518cdbde
2,137
AoC-2023
The Unlicense
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem032.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems import dev.mikeburgess.euler.sequences.permutationsOf /** * Problem 32 * * We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n * exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. * * The product 7254 is ...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
1,491
project-euler
MIT License
src/Day11.kt
punx120
573,421,386
false
{"Kotlin": 30825}
import java.util.* fun main() { val opRegex = "Operation: new = old ([+*]) ([a-z|0-9]+)".toRegex() class Monkey(val op: (ULong) -> ULong, val div: ULong, val test: (Boolean) -> Int) { var gcd = 1u.toULong() var count = 0L val items: LinkedList<ULong> = LinkedList<ULong>() fun ...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
3,064
aoc-2022
Apache License 2.0
2015/src/main/kotlin/day15.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.Vec4i import utils.mapItems fun main() { Day15.run(skipTest = false) } object Day15 : Solution<List<Day15.Item>>() { override val name = "day15" override val parser = Parser.lines.mapItems { parseItem(it) } const val TARGET_AMOUNT = 10...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,826
aoc_kotlin
MIT License
src/Day13.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
import kotlinx.serialization.json.* fun main() { fun compare(left: JsonElement, right: JsonElement): Int { val isLeftInt = left is JsonPrimitive val isRightInt = right is JsonPrimitive if(isLeftInt && isRightInt){ return left.jsonPrimitive.int.compareTo(right.jsonPrimitive.int)...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
2,138
advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2021/Day19.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2021 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle import kotlin.math.abs class Day19(input: Input) : Puzzle() { val scanners by lazy { input.string().split("\n\n".toRegex()) .map { scanner -> Scan...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
4,488
adventofcode-kotlin
MIT License
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day12/Day12.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day12 import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource fun main() { val input = readResource("Day12.txt").lines().map { parse(it) } val (answer1, duration1) = measureDuration<Int> { partOne(input) } ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,939
advent-of-code
MIT License
src/Day03.kt
devheitt
487,361,256
false
{"Kotlin": 5549}
fun main() { fun part1(input: List<String>): Int { val mostCommon = input[0].map { 0 }.toMutableList() val lessCommon = input[0].map { 0 }.toMutableList() input.forEach { line -> for (i in line.indices) { if (line[i] == '0') mostCommon[i]-- ...
0
Kotlin
0
0
cd79f4b6ac78b06cfb9b5ee381ae7427895a68c0
2,794
kotlin-aoc-2021
Apache License 2.0
leetcode/src/daily/hard/Q801.kt
zhangweizhe
387,808,774
false
null
package daily.hard import kotlin.math.min fun main() { // 801. 使序列递增的最小交换次数 // https://leetcode.cn/problems/minimum-swaps-to-make-sequences-increasing/ println(minSwap(intArrayOf(1,3,5,4), intArrayOf(1,2,3,7))) } fun minSwap(nums1: IntArray, nums2: IntArray): Int { /** * 1.状态定义 * noSwapDp[]...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
3,731
kotlin-study
MIT License
src/poyea/aoc/mmxxii/day21/Day21.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day21 import poyea.aoc.utils.readInput fun part1(input: String): Long { val numberOf = mutableMapOf<String, Long>() val children = mutableMapOf<String, Pair<String, String>>() val operations = mutableMapOf<String, Char>() input.split("\n").forEach { val (name, rest) =...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
2,991
aoc-mmxxii
MIT License
src/Day05.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
import java.util.Stack fun main() { fun stacks(input: List<String>): Map<Int, Stack<Char>> { val stacks = mutableMapOf<Int, Stack<Char>>() val stacksArea = input.takeWhile { it.isNotEmpty() } stacksArea.reversed().drop(1).forEach { row -> row.windowed(3, 4) { it[1] }.forEachInd...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
2,039
aoc2022
Apache License 2.0
src/Day09.kt
andrewgadion
572,927,267
false
{"Kotlin": 16973}
import kotlin.math.* data class Pos(val x: Int, val y: Int) { fun distance(p: Pos) = max(abs(x - p.x), abs(y - p.y)) } fun main() { fun move(rope: List<Pos>, command: String) = sequence { val (direction, steps) = command.split(" ") var lastRope = rope repeat(steps.to...
0
Kotlin
0
0
4d091e2da5d45a786aee4721624ddcae681664c9
1,781
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/oocode/CamelCards.kt
ivanmoore
725,978,325
false
{"Kotlin": 42155}
package com.oocode fun camelCardHandsFrom(input: String): CamelCardHands = CamelCardHands(input.split("\n") .map { line -> line.split(" ").let { CamelCardHand(it[0]) to it[1].toInt() } }) class CamelCardHands(private val handsWithBids: List<Pair<CamelCardHand, Int>>) { fun totalWinnings(): Int { ...
0
Kotlin
0
0
36ab66daf1241a607682e7f7a736411d7faa6277
2,397
advent-of-code-2023
MIT License
src/Day05.kt
KristianAN
571,726,775
false
{"Kotlin": 9011}
import java.util.* fun main() { fun part1(input: List<String>): String = loadInput(input, 8, 9).move { stacks, i, i2, i3 -> moveOne(stacks, i, i2, i3) }.second.topToString() fun part2(input: List<String>): String = loadInput(input, 8, 9).move { stacks, i, i2, i3 -> moveAll(stac...
0
Kotlin
0
0
3a3af6e99794259217bd31b3c4fd0538eb797941
1,960
AoC2022Kt
Apache License 2.0
src/day14/puzzle14.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day14 import Puzzle import PuzzleInput import java.io.File import java.lang.Integer.max import java.lang.Integer.min fun day14Puzzle() { Day14PuzzleSolution().solve(Day14PuzzleInput("inputs/day14/example.txt", 24)) Day14PuzzleSolution().solve(Day14PuzzleInput("inputs/day14/input.txt", 1016)) Day1...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
4,645
aoc_2022
Apache License 2.0
src/Day02.kt
inssein
573,116,957
false
{"Kotlin": 47333}
enum class Hand(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); } fun Char.toHand() = when (this) { 'A', 'X' -> Hand.ROCK 'B', 'Y' -> Hand.PAPER 'C', 'Z' -> Hand.SCISSORS else -> error("Invalid hand: $this") } fun main() { fun part1(input: List<String>): Int { return input.su...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,350
advent-of-code-2022
Apache License 2.0
src/main/kotlin/fr/pturpin/coursera/greedy/MaximumValueOfTheLoot.kt
TurpIF
159,055,822
false
null
package fr.pturpin.coursera.greedy import java.util.* class MaximumValueOfTheLoot(private val knapsackCapacity: Int) { private val formatPrecision = 4 private var weightOfCandidates = 0 private val sortedByLowValuationCandidates = PriorityQueue<Item>() fun addPotentialItem(itemValue: Int, itemWeight...
0
Kotlin
0
0
86860f8214f9d4ced7e052e008b91a5232830ea0
2,888
coursera-algo-toolbox
MIT License
src/main/kotlin/Day13.kt
brigham
573,127,412
false
{"Kotlin": 59675}
import kotlinx.serialization.json.* sealed class Packet: Comparable<Packet> data class ListPacket(val contents: List<Packet>): Packet() { override fun compareTo(other: Packet): Int { return when (other) { is ListPacket -> { for (pair in this.contents.zip(other.contents)) { ...
0
Kotlin
0
0
b87ffc772e5bd9fd721d552913cf79c575062f19
2,884
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day24/Day24.kt
Arch-vile
317,641,541
false
null
package day24 import java.io.File fun readFile(fileName: String) = File(fileName).readLines() fun main(args: Array<String>) { var steps = readFile("./src/main/resources/day24Input.txt") .map { it .replace("se", "SE") .replace("ne", "NE") .replace("sw", "SW") ...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
2,746
adventOfCode2020
Apache License 2.0
src/main/kotlin/Day03.kt
brigham
573,127,412
false
{"Kotlin": 59675}
fun main() { fun priority(only: Char) = when (only) { in 'A'..'Z' -> (only - 'A') + 27 in 'a'..'z' -> (only - 'a') + 1 else -> error("weird") } fun bisect(s: String): Pair<String, String> { val sz = s.length / 2 return s.slice(0 until sz) to s.substring(sz) } ...
0
Kotlin
0
0
b87ffc772e5bd9fd721d552913cf79c575062f19
991
advent-of-code-2022
Apache License 2.0
src/Day02.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
enum class Shape(val alias: Set<Char>, val points: Int) { Rock(setOf('A', 'X'), 1), Paper(setOf('B', 'Y'), 2), Scissors(setOf('C', 'Z'), 3); fun score(other: Shape): Int { val outcome = when (other) { this -> 3 beats[this] -> 6 else -> 0 } ret...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
1,612
advent-of-code-2022
Apache License 2.0
src/Day04.kt
ghasemdev
572,632,405
false
{"Kotlin": 7010}
private infix fun ClosedRange<Int>.contains(other: ClosedRange<Int>) = start >= other.start && endInclusive <= other.endInclusive private infix fun ClosedRange<Int>.overlap(other: ClosedRange<Int>) = start in other || endInclusive in other fun main() { fun counter(input: List<String>, kFunction2: (ClosedR...
0
Kotlin
0
1
7aa5e7824c0d2cf2dad94ed8832a6b9e4d36c446
1,265
aoc-2022-in-kotlin
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2017/day07/RecursiveCircus.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2017.day07 import com.barneyb.aoc.util.Solver import java.util.* fun main() { Solver.execute( ::parse, Prog::name, ::correction, ) } internal data class Prog( val name: String, val weight: Int, val tower: Collection<Prog> = emptyList(), ) { v...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
2,366
aoc-2022
MIT License
src/day15/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day15 import assert import println import readInput fun main() { class Command(val label: String, val command: Char, val focalLength: Int) class Mirror(val label: String, val focalLength: Int) class Box(val number: Int, val mirrors: MutableList<Mirror>) { fun focusingPower(): Int { ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
2,497
advent-of-code-2023
Apache License 2.0
src/Day11.kt
dcbertelsen
573,210,061
false
{"Kotlin": 29052}
import java.io.File import kotlin.collections.ArrayDeque fun main() { fun readMonkeys(input: List<String>) = input.map { data -> val lines = data.split("\n") Monkey( ArrayDeque(lines[1].split(": ")[1].split(", ").map { it -> it.toLong() }), lines[2].s...
0
Kotlin
0
0
9d22341bd031ffbfb82e7349c5684bc461b3c5f7
3,492
advent-of-code-2022-kotlin
Apache License 2.0
src/Day02.kt
mvmlisb
572,859,923
false
{"Kotlin": 14994}
private enum class GameMove(private val values: List<String>) { Rock(listOf("A", "X")), Paper(listOf("B", "Y")), Scissors(listOf("C", "Z")); private fun getPoints() = when (this) { Rock -> 1 Paper -> 2 Scissors -> 3 } fun fightInFairWay(opponent: GameMove) = (if (this =...
0
Kotlin
0
0
648d594ec0d3b2e41a435b4473b6e6eb26e81833
1,778
advent_of_code_2022
Apache License 2.0
src/main/kotlin/day8.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day8() { val lines: List<String> = readFile("day08.txt") day8part1(lines) day8part2(lines) } fun day8part1(lines: List<String>) { val answer = lines .map { it.split(" | ")[1].split(" ") } .flatten() .filter { intArrayOf(2, 3, 4, 7).contains(it.length) } .size ...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,272
advent_of_code_2021
MIT License
src/Day05.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun readScheme(input: List<String>): Array<MutableList<Char>> { val numberOfCrates = (input.first().length + 1) / 4 val maxHeight = input.indexOfFirst(String::isEmpty) - 1 val crates = Array(numberOfCrates) { mutableListOf<Char>() } input.take(maxHeight).forEach { line ...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
2,091
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-16.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import com.github.ferinagy.adventOfCode.searchGraph import kotlin.math.min fun main() { val input = readInputLines(2022, "16-input") val testInput1 = readInpu...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
5,597
advent-of-code
MIT License
src/day04/Day04.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day04 import readInput fun main() { fun String.toRange(): Pair<Int, Int> { val split = this.split("-") return split.first().toInt() to split.last().toInt() } fun parse(it: String): Pair<Pair<Int, Int>, Pair<Int, Int>> { val (firstRange, secondRange) = it.split(",") ...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
1,726
advent-of-code-kotlin-2022
Apache License 2.0
src/year2022/day17/Day17.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day17 import check import readInput import kotlin.math.max import kotlin.system.measureTimeMillis import kotlin.time.Duration.Companion.milliseconds fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day17_test") check(part...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
8,148
AdventOfCode
Apache License 2.0
src/year2023/24/Day24.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`24` import readInput import utils.printlnDebug import java.math.BigDecimal private const val CURRENT_DAY = "24" private data class Point3D( val x: BigDecimal, val y: BigDecimal, val z: BigDecimal, ) { override fun toString(): String { return "[$x,$y,$z]" } } private da...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
4,895
KotlinAdventOfCode
Apache License 2.0
src/main/kotlin/Day13.kt
SimonMarquis
570,868,366
false
{"Kotlin": 50263}
class Day13(val input: List<String>) { fun part1(): Int = input.windowed(size = 2, step = 3) { (l, r) -> (l to r).parse() } .withIndex().filter { it.value } .sumOf { it.index.inc() } private val dividers = setOf("[[2]]", "[[6]]") fun part2(): Long = input.asSequence().filter(String::isNotE...
0
Kotlin
0
0
a2129cc558c610dfe338594d9f05df6501dff5e6
2,383
advent-of-code-2022
Apache License 2.0
src/year2022/Day12.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 fun main() { fun part1(input: List<String>): Int { val letters = "<KEY>" var start = Pair(0, 0) var destination = Pair(0, 0) val visited = mutableListOf<Pair<Int, Int>>() val grid = input.withIndex().map { (x, line) -> line.withIndex().map { (y, ...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
4,457
adventofcode-kotlin
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day12.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 12: Passage Pathing */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsString fun main() { println(" ** Day 12: Passage Pathing ** \n") val caveConnections = readFileAsString("/Day12CaveConnections.txt") val numberOfPaths = countAllPossiblePathsThroughCaveSystem(cave...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
3,045
AdventOfCode2021
MIT License
src/day12/Day12.kt
Puju2496
576,611,911
false
{"Kotlin": 46156}
package day12 import println import readInput import java.util.* fun main() { // test if implementation meets criteria from the description, like: val input = readInput("src/day12", "Day12") println("Part1") part1(input) println("Part2") part2(input) } private fun part1(inputs: List<String>) ...
0
Kotlin
0
0
e04f89c67f6170441651a1fe2bd1f2448a2cf64e
3,995
advent-of-code-2022
Apache License 2.0
src/Day04.kt
shoresea
576,381,520
false
{"Kotlin": 29960}
fun main() { fun part1(inputs: List<String>): Int { return inputs.map { val input = it.split(",") fullyContainOther(input[0], input[1]) }.count { it } } fun part2(inputs: List<String>): Int { return inputs.map { val input = it.split(",") ...
0
Kotlin
0
0
e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e
1,050
AOC2022InKotlin
Apache License 2.0
src/main/kotlin/dp/MaxPlusMinus.kt
yx-z
106,589,674
false
null
package dp import util.get import util.max import util.min import util.set // given a sequence of integers with +/- signs in between // find the maximum possible value obtained from the sequence (no multiplication) by adding (/) fun main(args: Array<String>) { val arr = arrayOf('1', '+', '3', '-', '2', '-', '5', '+'...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,457
AlgoKt
MIT License
src/Day07.kt
rk012
574,169,156
false
{"Kotlin": 9389}
fun main() { data class File( val size: Int, val name: String, val dirPath: String ) data class Filesystem( val dirs: Set<String>, val files: Set<File> ) fun List<String>.parseFileSystem() = drop(1).fold( Filesystem(emptySet(), emptySet()) to "" ...
0
Kotlin
0
0
bfb4c56c4d4c8153241fa6aa6ae0e829012e6679
1,756
advent-of-code-2022
Apache License 2.0
src/Day07.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.util.LinkedList fun main() { class Node(val size: Int, val children: List<String>) fun getFileMap(input: List<String>): Map<String, Node> { val fileMap = mutableMapOf<String, Node>() val pathList = LinkedList<String>() var i = 0 while (i < input.size) { val splits = input[i].sp...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
2,011
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun part1(inputs: List<String>): Int { return followPath(2, inputs) } fun part2(inputs: List<String>): Int { return followPath(10, inputs) } // test if implementation meets criteria from the description, like: ...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
1,975
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/main/kotlin/year2021/Day07.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2021 import kotlin.math.abs import kotlin.math.ceil import kotlin.math.floor import kotlin.math.roundToInt private fun part1(input: List<Int>): Int { val median = input[((input.size / 2.0)).roundToInt()] return input.fold(0) { acc, value -> acc + abs(value - median) } } private fun calculateStep(...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
1,318
advent-of-code
MIT License
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day21/day21.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input21-test.txt" const val FILENAME = "input21.txt" fun main() { val (map, start) = parseMap(readLines(2023, FILENAME)) var points = setOf(start) val result = mutableL...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,946
advent-of-code
Apache License 2.0
advent-of-code-2022/src/main/kotlin/Day02.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 02: Rock Paper Scissors //https://adventofcode.com/2022/day/2 import java.io.File enum class Hand(val opponentCode: Char, val score: Int) { ROCK('A', 1), PAPER('B', 2), SCISSOR('C', 3); fun versus(opponent: Hand): Boolean { return when (this) { ROCK -> opponent == SCISSOR ...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,031
advent-of-code
Apache License 2.0
src/Day02.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { val scoreMap = mapOf( Pair("A", "X") to 1 + 3, Pair("A", "Y") to 2 + 6, Pair("A", "Z") to 3 + 0, Pair("B", "X") to 1 + 0, Pair("B", "Y") to 2 + 3, Pair("B", "Z") to 3 + 6, Pair("C", "X") to 1 + 6, Pair("C", "Y") to 2 + 0, Pair("C"...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
1,575
AoC-2022
Apache License 2.0
src/Day24.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import kotlin.collections.HashSet fun main() { class BoundedDirection(private val x: Int, private val y: Int, private var d: Direction) { fun move(p: Point): Point { val moved = d.move(p) if (moved.x > x) return Point(0, p.y) if (moved.x < 0) return Point(x, p.y) ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
3,358
advent-of-code-2022
Apache License 2.0
src/Day04.kt
Misano9699
572,108,457
false
null
fun main() { fun fullyContains(range1: Pair<Int,Int>, range2: Pair<Int,Int>) = range1.first <= range2.first && range1.second >= range2.second || range2.first <= range1.first && range2.second >= range1.second fun contains(range1: Pair<Int,Int>, range2: Pair<Int, Int>) = range1.first <= range2.s...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
1,336
advent-of-code-2022
Apache License 2.0
src/Day13.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
import java.util.Stack fun main() { fun List<String>.readPacketPairs(): List<Pair<DataValue, DataValue>> = plus("") .chunked(3) .map { Pair(DataValue.parse(it[0]), DataValue.parse(it[1])) } fun List<String>.readPackets(): List<DataValue> = filter(String::isNotEmpty) .map(DataValue.Com...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
4,217
aoc-2022
Apache License 2.0
src/Day03.kt
pimts
573,091,164
false
{"Kotlin": 8145}
data class Rucksack(val items: String) fun Rucksack.uniqueItems() = items.toSet() fun Rucksack.compartment1() = items.substring(startIndex = 0, endIndex = items.length / 2).toSet() fun Rucksack.compartment2() = items.substring(startIndex = items.length / 2).toSet() fun Char.priority() = if (isLowerCase()) { ...
0
Kotlin
0
0
dc7abb10538bf6ad9950a079bbea315b4fbd011b
1,302
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/org/sjoblomj/adventofcode/day5/Day5.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day5 import java.io.File import kotlin.streams.toList import kotlin.system.measureTimeMillis private const val inputFile = "src/main/resources/inputs/day5.txt" fun day5() { println("== DAY 5 ==") val timeTaken = measureTimeMillis { calculateAndPrintDay5() } println("Finished ...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
2,195
adventofcode2018
MIT License
src/Day09.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import kotlin.math.abs import kotlin.math.sign data class Knot(var x: Int, var y: Int, var next: Knot? = null) { var history = mutableSetOf(0 to 0) fun move(dir: Direction, count: Int) { repeat(count) { move(dir) } } fun move(dir: Direction) { when (dir) { Direction.UP -> ...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
2,450
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/2021/Day8.kt
mstar95
317,305,289
false
null
package `2021` import days.Day class Day8 : Day(8) { val unique = listOf(2, 4, 3, 7) val numbers = mapOf( 0 to listOf(1, 2, 3, 4, 5, 6), 1 to listOf(2, 3), 2 to listOf(1, 2, 4, 5, 7), 3 to listOf(1, 2, 3, 4, 7), 4 to listOf(2, 3, 6, 7), 5 to listOf(1, 3, 4, 6,...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
3,736
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/ginsberg/advent2022/Day15.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 15 - Beacon Exclusion Zone * Problem Description: http://adventofcode.com/2022/day/15 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day15/ */ package com.ginsberg.advent2022 import kotlin.math.absoluteValue class D...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
2,455
advent-2022-kotlin
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day05.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 fun main() { fun List<ArrayDeque<String>>.printStacks() { val copy = this.toList().map { ArrayDeque(it) } println( (0 until (copy.maxOfOrNull { it.size } ?: 0)).joinToString("\n") { copy.joinToString { s -> if (s.isNotEmpty(...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,618
advent-of-code
Apache License 2.0
src/Day03.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun getPriority(c: Char): Int { val asciiCode = c.code return if (asciiCode >= 'a'.code) { asciiCode - 'a'.code + 1 } else { asciiCode - 'A'.code + 27 } } fun part1(input: List<String>): Int { val compartments = input.map { ...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
1,186
aoc2022
Apache License 2.0
src/main/kotlin/dec17/Main.kt
dladukedev
318,188,745
false
null
package dec17 data class Point2(val x: Int, val y: Int) data class Point3(val x: Int, val y: Int, val z: Int) data class Point4(val w: Int, val x: Int, val y: Int, val z: Int) fun getNeighbors(point: Point3): List<Point3> { val (x, y, z) = point return listOf( Point3(x - 1, y - 1, z - 1), Poi...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
3,965
advent-of-code-2020
MIT License
src/Day05.kt
AleksanderBrzozowski
574,061,559
false
null
fun main() { data class Instruction(val quantity: Int, val from: Int, val to: Int) fun readCrates(): Pair<List<ArrayDeque<Char>>, List<Instruction>> { val input = readInput("Day05_test") return input.takeWhile { !it.contains("1") } .reversed() .foldIndexed(emptyList<Arra...
0
Kotlin
0
0
161c36e3bccdcbee6291c8d8bacf860cd9a96bee
2,763
kotlin-advent-of-code-2022
Apache License 2.0
src/Day05.kt
wujingwe
574,096,169
false
null
import java.util.* fun main() { fun parse(input: List<String>): Map<Line, List<String>> { return input.groupBy { s -> when { s.isEmpty() -> Line.Space s.startsWith("move") -> Line.Op else -> Line.Crate } } } fun initC...
0
Kotlin
0
0
a5777a67d234e33dde43589602dc248bc6411aee
2,702
advent-of-code-kotlin-2022
Apache License 2.0
src/Day18.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import java.util.* fun main() { val deltas = listOf( Triple(+1, 0, 0), Triple(-1, 0, 0), Triple(0, +1, 0), Triple(0, -1, 0), Triple(0, 0, +1), Triple(0, 0, -1) ) fun applyDeltas(cube: Triple<Int, Int, Int>): List<Triple<Int, Int, Int>> = deltas.map { Triple(cube.first + it....
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
2,141
Advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfWaysOfCuttingPizza.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,545
kotlab
Apache License 2.0
src/Day15.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
import java.util.stream.IntStream import kotlin.math.abs fun main() { data class Point(val x: Int, val y: Int) { infix fun distanceTo(beacon: Point) = distanceTo(beacon.x, beacon.y) fun distanceTo(xx: Int, yy: Int) = abs(x - xx) + abs(y - yy) } data class Sensor(val position: Point, val c...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
3,142
AdventOfCode2022
Apache License 2.0
src/twentytwentytwo/day15/Day15.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day15 import readInput import kotlin.math.abs fun main() { // row index -> set of spaces that are covered in that row val coveredSpots = mutableMapOf<Int, Set<Int>>() val borderPoints = mutableSetOf<Pair<Int, Int>>() val beacons = mutableSetOf<Pair<Int, Int>>() val sensors ...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
2,812
advent-of-code
Apache License 2.0