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/Day04.kt
Nplu5
572,211,950
false
{"Kotlin": 15289}
fun main() { fun createSections(input: List<String>) = input.flatMap { line -> line.split(",") } .map { sectionString -> IntRange.fromSectionString(sectionString) } .windowed(2, 2) .map { Sections(it) } fun part1(input: List<String>): Int { return createSections(input) ...
0
Kotlin
0
0
a9d228029f31ca281bd7e4c7eab03e20b49b3b1c
1,800
advent-of-code-2022
Apache License 2.0
src/day12/Day12.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day12 import readInput fun main() { part1() part2() } fun part1() = common { s, _ -> setOf(s) } fun part2() = common { _, aSet -> aSet } fun common(startingPoints: (s: Pair<Int, Int>, aSet: Set<Pair<Int, Int>>) -> Set<Pair<Int, Int>>) { val input = readInput(12) val grid = input.map { ...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
2,264
advent-of-code-2022
Apache License 2.0
src/Day04.kt
trosendo
572,903,458
false
{"Kotlin": 26100}
fun main() { fun getElfZones(elfPair: String): Pair<Sequence<Int>, Sequence<Int>> { val (elf1, elf2) = elfPair.split(",").map { it.split("-").map { it.toInt() } } val elf1Zones = generateSequence(elf1[0]) { if (it < elf1[1]) it + 1 else null } val elf2Zones = generateSequence(elf2[0]) { if (...
0
Kotlin
0
0
ea66a6f6179dc131a73f884c10acf3eef8e66a43
1,204
AoC-2022
Apache License 2.0
src/Day13.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<Packet> = input.filter { it.isNotEmpty() }.map { Packet.parse(it) } fun part1(input: List<String>): Int { val packets = parse(input) var sum = 0 packets.chunked(2).forEachIndexed { index, pair -> if (pair[0] < pair[1]...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
2,575
advent-of-code-2022
Apache License 2.0
src/Day12/day12.kt
NST-d
573,224,214
false
null
package Day12 import utils.* import java.lang.Integer.min data class Point(val x: Int, val y: Int) data class DistancePoints( val point: Point, var distance: Int) fun main() { fun findChar(input: List<String>, char: Char): Point { val x = input.indexOfFirst { it.contains(char) } val y = input[x]...
0
Kotlin
0
0
c4913b488b8a42c4d7dad94733d35711a9c98992
3,782
aoc22
Apache License 2.0
src/main/kotlin/day11/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day11 import util.readTestInput import java.lang.IllegalArgumentException data class Operation(val leftOperand: String, val symbol: String, val rightOperand: String) { companion object { fun parse(str: String) = str.split(" ").let{Operation(it[0], it[1], it[2])} } } data class Monkey(val monk...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
3,105
advent-of-code-2022
MIT License
src/Day05.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
fun main() { fun move(cargos: MutableList<MutableList<Char>>, move: Int, from: Int, to: Int, reverse: Boolean) { val target = cargos[from].takeLast(move).let { if (reverse) it.reversed() else it } (1..move).forEach { _ -> cargos[from].removeLast() } cargos[to].addAll(target) } fun p...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
1,780
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day24.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day24(input: List<String>) { private val hailstones = input.map { MovingObject.parse(it) } data class Intersection(val point: Vector3D?, val hailstones: Pair<MovingObject, MovingObject>, private val coincident: Boolean = false, private val parallel: Boolean = false) { ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
4,127
advent-2023
MIT License
src/Solution.kt
Shahroz16
114,043,227
false
null
import ListPartitioner.getAllPartitions import java.util.ArrayList import java.util.concurrent.TimeUnit lateinit var distances: Array2D<Double> /** * Vehicle Routing Problem, brute-force solution * Ported from python code at https://github.com/ybashir/vrpfun */ fun main(args: Array<String>) { val vehicles = 3...
0
Kotlin
2
2
3ce13662ee2f93d7308fab3d9173a812331c0b74
3,270
VRP
Apache License 2.0
src/Day21.kt
inssein
573,116,957
false
{"Kotlin": 47333}
sealed class Monkey21 { abstract val name: String abstract fun yell(): Long data class NumberMonkey(override val name: String, val number: Long) : Monkey21() { override fun yell(): Long = number } data class MathMonkey( override val name: String, val leftName: String, ...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
3,315
advent-of-code-2022
Apache License 2.0
src/Day07.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
interface FileOrDirectory { val size: Int } data class File(val name: String, override val size: Int): FileOrDirectory class Directory(val name: String): FileOrDirectory { private var files = mutableListOf<FileOrDirectory>() fun addFile(newFile: FileOrDirectory) { files.add(newFile) } va...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
2,805
2022-Advent-of-Code
Apache License 2.0
src/main/kotlin/letterboxed/Solver.kt
gmarmstrong
531,249,433
false
{"Kotlin": 22711}
package letterboxed import util.zigzagsOver const val MIN_WORD_LENGTH = 3 /** * Logic for solving the puzzles. */ class Solver(wordsProvider: WordsProvider, private val solutionSteps: Int = 2) { val words: MutableSet<String> = wordsProvider.getWords() init { // Filters a list of words to remove w...
2
Kotlin
0
0
a0545396ebe135ebd602f1d874bf8c4dd9b037d5
3,534
letter-boxed
MIT License
src/Day05.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
fun main() { fun findDividingRow(input: List<String>): Int { return input.indexOf("") } fun getCargoMap(cargoMap: List<String>): MutableMap<Int, String> { val stacks = mutableMapOf<Int,String>() val last = cargoMap.last().trimEnd().last().digitToInt() for (i in 1..last) { ...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
2,419
AoC2022
Apache License 2.0
src/Day04/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day04 import readInput fun main() { fun parseLine(input: String) : Pair<IntRange, IntRange> { return input .split(",") .map { assignmentString -> assignmentString.split("-") .map { it.toInt() } .let { assigmentList ->...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
1,885
aoc-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day08.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 8 - Seven Segment Search * Problem Description: http://adventofcode.com/2021/day/8 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day8/ */ package com.ginsberg.advent2021 class Day08(input: List<String>) { priva...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
3,165
advent-2021-kotlin
Apache License 2.0
src/Day07.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
import java.util.* sealed class Node { abstract val name: String abstract val size: Int data class FileNode(override val name: String, override val size: Int) : Node() data class DirNode(override val name: String, val nodes: MutableSet<Node> = mutableSetOf()) : Node() { override val size: Int...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
2,558
advent-of-code-2022-kt
Apache License 2.0
src/Day07.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename data class DirInfo( val path: String, var size: Long = 0, val subDirs: MutableList<String> = mutableListOf() ) fun getDirInfo(input: List<String>): Map<String, DirInfo> { val dirInfo = mutableMapOf<String, DirInfo>() var curDi...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
2,937
KotlinAdventOfCode2022
Apache License 2.0
src/day09/Day09.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day09 import readLines import kotlin.math.abs data class Knot(var x: Int, var y: Int) enum class Direction(val x: Int, val y: Int) { R(1, 0), L(-1, 0), U(0, 1), D(0, -1) } fun tailVisitedCount(input: List<String>, ropeLength: Int): Int { val rope = ArrayList<Knot>() (1..ropeLength).m...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,796
aoc2022
Apache License 2.0
src/main/kotlin/LargestDivisibleSubset.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * 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] % answer[i] == 0 * If there are multiple solutions, return any of them. * * * * Example 1: ...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,443
kotlin-codes
Apache License 2.0
src/Day03.kt
Jessenw
575,278,448
false
{"Kotlin": 13488}
fun main() { fun part1(input: List<String>): Int = input.sumOf { line -> val compartments = line.chunked(line.length / 2) .map { it.toCharArray() } compartments[0] .map { // Look for duplicate between compartments. ...
0
Kotlin
0
0
05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3
1,349
aoc-22-kotlin
Apache License 2.0
src/aoc2022/Day07.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import println import readInput fun main() { class DirNode(val name: String, val parent: DirNode?) { val subdirs = mutableMapOf<String, DirNode>() var immediateFilesSum: Int = 0 var subdirsSum: Int? = null } fun calculateSum(node: DirNode): Int { if (node....
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
3,269
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
novotnyradekcz
579,767,169
false
{"Kotlin": 11517}
fun main() { fun part1(input: List<String>): Int { var total = 0 for (line in input) { val sections = line.split(",") // [1-2, 3-4] val firstElf = sections[0].split("-") // [1, 2] val secondElf = sections[1].split("-") // [3, 4] if ((firstElf[0]...
0
Kotlin
0
0
2f1907dc63344cf536f5031bc7e1c61db03fc570
1,382
advent-of-code-kotlin-2022
Apache License 2.0
day11/Part1.kt
anthaas
317,622,929
false
null
import java.io.File private const val EMPTY = 'L' private const val OCCUPIED = '#' fun main(args: Array<String>) { var board = File("input.txt").readLines().map { it.toCharArray() } var nextIter = evolve(board) var same = areSame(board, nextIter) while (!same) { nextIter = evolve(board) ...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
1,719
Advent-of-Code-2020
MIT License
src/main/kotlin/days/Day8.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days class Day8 : Day(8) { override fun partOne(): Any { val outputValues = inputList.map { it.split(" | ")[1] }.flatMap { it.split(" ") } return outputValues.count { listOf(2, 3, 4, 7).contains(it.length) } } override fun partTwo(): Any { val signals = inputList.map { it....
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
2,419
aoc-2021
Creative Commons Zero v1.0 Universal
src/Day15_pt2.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { /** * Solution of part one with ranges is way too slow, would take in the order of 90 days, so need to start from scratch * Steps: * - for each of the lines between 0 and 4000000 (= y position): * - for each se...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
2,320
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
alfr1903
573,468,312
false
{"Kotlin": 9628}
fun main() { fun part1(input: List<String>): Int = input.count { hasCompleteOverlap(it) } fun part2(input: List<String>): Int = input.count { hasPartialOverlap(it) } val input = readInputAsList("Day04Input") println(part1(input)) println(part2(input)) } private fun hasCompleteOverlap(inp: String):...
0
Kotlin
0
0
c1d1fbf030ac82c643fa5aea4d9f7c302051c38c
1,330
advent-of-code-2022
Apache License 2.0
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p04/Leet435.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p04 import java.util.TreeMap private class Leet435 { val overlaps = TreeMap<Int, Int>() fun eraseOverlapIntervals(intervals: Array<IntArray>): Int { for (k in intervals.indices) { isOverlapPrevious(k, intervals) println(overlaps) } ...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
3,376
playground
MIT License
src/Day09.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Point(val x: Int, val y: Int) { val up get() = Point(x, y + 1) val down get() = Point(x, y - 1) val left get() = Point(x - 1, y) val right get() = Point(x + 1, y) private fun isAdjacent(other: Point) = o...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,969
aoc-2022
Apache License 2.0
src/Day05.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): String { val emptyLineIndex = input.indexOf("") val stackInput = input.take(emptyLineIndex) val rearrangementProcedureInput = input.drop(emptyLineIndex + 1) val stacks = parseInitialStacks(stackInput) val rearrangementA...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
2,331
aoc2022
Apache License 2.0
src/main/kotlin/Day12.kt
clechasseur
258,279,622
false
null
import org.clechasseur.adventofcode2019.Pt3D import org.clechasseur.adventofcode2019.math.leastCommonMultiple import org.clechasseur.adventofcode2019.toPt3D import kotlin.math.abs import kotlin.math.sign object Day12 { private val input = """ <x=16, y=-8, z=13> <x=4, y=10, z=10> <x=17, y=-5...
0
Kotlin
0
0
187acc910eccb7dcb97ff534e5f93786f0341818
3,211
adventofcode2019
MIT License
src/Day02.kt
jordanfarrer
573,120,618
false
{"Kotlin": 20954}
fun main() { val day = "Day02" val winValue = 6 val loseValue = 0 val drawValue = 3 val rock = Choice("Rock", "X", theirChoice = "A", myPointValue = 1) val paper = Choice("Paper", "Y", theirChoice = "B", myPointValue = 2) val scissors = Choice("Scissors", "Z", theirChoice = "C", myPointVal...
0
Kotlin
0
1
aea4bb23029f3b48c94aa742958727d71c3532ac
2,804
advent-of-code-2022-kotlin
Apache License 2.0
2021/src/main/kotlin/day8_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut import utils.mapItems fun main() { Day8Imp.run() } object Day8Imp : Solution<List<Day8Imp.Key>>() { override val name = "day8" override val parser = Parser.lines.mapItems { it.cut("|") { input, output -> Key(input.split(' '), output.split(' ')) } ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,119
aoc_kotlin
MIT License
src/main/kotlin/de/consuli/aoc/year2023/days/Day03.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2023.days import de.consuli.aoc.common.Day class Day03 : Day(3, 2023) { data class Point(val y: Int, val x: Int) override fun partOne(testInput: Boolean): Int = calculateSumOfMetrics(toCharArrayList(getInput(testInput)), this::partOnePredicate, this::partOneSelector) ...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
2,705
advent-of-code
Apache License 2.0
src/2022/Day11.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput import splitBy import top fun main() { fun part1(input: List<String>): Int { val monkeys = input.splitBy { it.isEmpty() }.map { Monkey.fromDesc(it) } repeat(20) { monkeys.processRound() } val (first, second) = monkeys.map { it.inspects }...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,617
aoc-2022-in-kotlin
Apache License 2.0
2021/app/src/main/kotlin/net/sympower/aok2021/tonis/Day04.kt
tonisojandu
573,036,346
false
{"Rust": 158858, "Kotlin": 15806, "Shell": 1265}
package net.sympower.aok2021.tonis fun main() { println("1st: ${day04Part01("/Day04.in")}") println("2nd: ${day04Part02("/Day04.in")}") } fun day04Part01(fileIn: String): Int { val (pickedNumbers, boards) = readNumbersAndBoards(fileIn) val (winningBoard, onNumber) = pickWinningBoard(boards, pickedNumbers) ...
0
Rust
0
0
5ee0c3fb2e461dcfd4a3bdd7db3efae9a4d5aabd
3,489
to-advent-of-code
MIT License
src/main/kotlin/com/anahoret/aoc2022/day02/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day02 import java.io.File enum class Choice(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3) } enum class Outcome(val points: Int) { LOOSE(0), DRAW(3), WIN(6) } val opponentChoice = mapOf( "A" to Choice.ROCK, "B" to Choice.PAPER, "C" to Choice.SCISSO...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
2,576
advent-of-code-2022
Apache License 2.0
src/Day02.kt
wbars
576,906,839
false
{"Kotlin": 32565}
fun main() { fun part1(input: List<String>): Int { return input.asSequence() .map { Pair(it[0].toCode(), it[2].toCode()) } .map { it.second + 1 + it.solve() } .sum() } fun part2(input: List<String>): Int { return input.asSequence() ...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
1,087
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day22.kt
poqueque
430,806,840
false
{"Kotlin": 101024}
package days import Coor3 import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day22 : Day(22) { data class Cube(val x: IntRange, val y: IntRange, val z: IntRange) { fun within(c: Cube): Boolean { return (x.first in c.x && x.last in c.x && y.first in ...
0
Kotlin
0
0
4fa363be46ca5cfcfb271a37564af15233f2a141
3,450
adventofcode2021
MIT License
src/2022/Day16.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { lateinit var nameToValve: Map<String, Valve> lateinit var valves: List<Valve> lateinit var valuableValves: List<Valve> val pathToCost: MutableMap<Pair<Valve, Valve>, Int> = mutableMapOf() fun parseInput(input: List<String>) { valves = input.ma...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,797
aoc-2022-in-kotlin
Apache License 2.0
src/y2023/Day05.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { fun List<Long>.toPairs(): List<Pair<Long, Long>> { return this.chunked(size = 2) { it[0] to it[1] } } fun part1(input: List<String>): Long? { val seeds = input.first().split("seeds: ")[1].split(" ").map { it.toLong() } val mapping...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
3,014
advent-of-code-kotlin
Apache License 2.0
src/Day08.kt
touchman
574,559,057
false
{"Kotlin": 16512}
fun main() { val input = readInput("Day08") fun checkIfValueBiggerThanLeftAndRightValues(listOfInts: List<Int>, j: Int): Boolean { val height = listOfInts[j] val leftList = listOfInts.dropLast(listOfInts.size - j) val rightList = listOfInts.drop(j + 1) return height > leftList...
0
Kotlin
0
0
4f7402063a4a7651884be77bb9e97828a31459a7
2,680
advent-of-code-2022
Apache License 2.0
src/Day05.kt
psy667
571,468,780
false
{"Kotlin": 23245}
//[ , M, , , , Z, , V, ], //[ , Z, , P, , L, , Z, J], //[S, D, , W, , W, , H, Q], //[P, V, N, D, , P, , C, V], //[H, B, J, V, B, M, , N, P], //[V, F, L, Z, C, S, P, S, G], //[F, J, M, G, R, R, H, R, L], //[G, G, G, N, V, V, T, Q, F] fun main() { val id = "05" fun part1(input: List<String>): Stri...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
2,630
advent-of-code-2022
Apache License 2.0
src/Day11.kt
Shykial
572,927,053
false
{"Kotlin": 29698}
fun main() { fun part1(input: List<String>): Int { val monkeys = parseInput(input) val monkeysInspects = monkeys.associate { it.number to 0 }.toMutableMap() repeat(20) { _ -> monkeys.forEach { monkey -> monkeysInspects.computeIfPresent(monkey.number) { _, count ->...
0
Kotlin
0
0
afa053c1753a58e2437f3fb019ad3532cb83b92e
3,511
advent-of-code-2022
Apache License 2.0
src/Day02.kt
jwalter
573,111,342
false
{"Kotlin": 19975}
fun main() { fun valOf(v: String): Int { return when { "AX".contains(v) -> 1 "BY".contains(v) -> 2 "CZ".contains(v) -> 3 else -> 0 } } fun score(theirs: Int, mine: Int): Int { val outcome = when(mine - theirs) { 1 -> 6 ...
0
Kotlin
0
0
576aeabd297a7d7ee77eca9bb405ec5d2641b441
1,392
adventofcode2022
Apache License 2.0
src/Day02.kt
jsebasct
572,954,137
false
{"Kotlin": 29119}
enum class PlayOption { ROCK, PAPER, SCISSOR; fun score(): Int { return this.ordinal + 1 } fun result(another: PlayOption): GameResult { val res = if (this == another) GameResult.DRAW else if (this == ROCK && another == PAPER) GameResult.LOST else if (this == P...
0
Kotlin
0
0
c4a587d9d98d02b9520a9697d6fc269509b32220
2,930
aoc2022
Apache License 2.0
src/day13/Day13.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day13 import readInput interface PacketContent { val type: String } data class PacketItem( val value: Int ) : PacketContent { override val type: String = "Item" } data class PacketArray( val items: List<PacketContent> ) : PacketContent { override val type: String = "Array" } fun isOrder...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
4,272
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode2023/day10/day10.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day10 import adventofcode2023.* import kotlin.time.measureTime fun main() { println("Day 10") val input = readInput("day10") val puzzle1Timing = measureTime { println("Puzzle 1 ${puzzle1(input)}") } println("Puzzle 1 took $puzzle1Timing") val puzzle2Timing = m...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
3,286
adventofcode2023
MIT License
aoc2023/day5.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day5.execute() } private object Day5 { fun execute() { val input = readInput() val (seedRanges, maps) = input println("Part 1: ${part1(seedRanges, maps)}") println("Part 2: ${part2(seedRanges, maps)}") } private...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
2,226
Advent-Of-Code
MIT License
src/Day12.kt
D000L
575,350,411
false
{"Kotlin": 23716}
import java.util.* fun main() { data class Data(val x: Int, val y: Int, val value: Char, val step: Int) fun part1(input: List<String>, sx: Int = 0, sy: Int = 0): Int { val visited = mutableMapOf<Pair<Int, Int>, Int>() val queue = LinkedList<Data>() var min = Int.MAX_VALUE que...
0
Kotlin
0
0
b733a4f16ebc7b71af5b08b947ae46afb62df05e
1,658
adventOfCode
Apache License 2.0
src/main/kotlin/dp/LAS.kt
yx-z
106,589,674
false
null
package dp import util.max // longest alternating subsequence fun main(args: Array<String>) { val A = intArrayOf(7, 5, 6, 10, 2) println(las(A)) println(lasNoDP(A)) } // time complexity: O(n) // space complexity: O(1) // count the number of local extrema fun lasNoDP(A: IntArray) = A.indices.filter { it in 1 unti...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,614
AlgoKt
MIT License
src/Day04.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
fun main() { fun checkSubRange(range1: Pair<Int, Int>, range2: Pair<Int, Int>): Boolean { val (firstStarts, firstEnd) = range1 val (secondStarts, secondEnd) = range2 if (firstStarts <= secondStarts && firstEnd >= secondEnd) return true if (secondStarts <= firstStarts && secondEnd >...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
1,558
aoc-2022
Apache License 2.0
src/aoc2023/Day11.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2023 import utils.checkEquals import utils.readInputAs2DCharArray import kotlin.math.abs fun main(): Unit = with(Day11) { testInput.solve(2).checkEquals(374) part1(input) .checkEquals(10313550) // .sendAnswer(part = 1, day = "11", year = 2023) testInput.solve(10).checkEquals(10...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,099
Kotlin-AOC-2023
Apache License 2.0
src/com/ncorti/aoc2023/Day05.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 data class Almanac(val seeds: List<Long>, val maps: List<List<Triple<Long, Long, Long>>>) { companion object { fun from(input: List<String>): Almanac { val seeds = input[0].substringAfter("seeds: ") .split(" ") .filter(String::isNotBlan...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
2,598
adventofcode-2023
MIT License
src/main/kotlin/day11/Day11.kt
Jessevanbekkum
112,612,571
false
null
package day11 import java.lang.Integer.min import java.util.function.BiFunction fun walk(input: String):Int { val split = input.split(',') return walk(split) } fun walk (split:List<String>):Int { val counters = mutableMapOf<String, Int>() val dirs = listOf("n", "ne", "se", "s", "sw", "nw") dirs.forE...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
1,958
aoc-2017
Apache License 2.0
src/main/kotlin/aoc2021/day3.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.loadInput import java.util.* fun main() { // part 1 val lines = loadInput("/2021/day3") .bufferedReader() .readLines() fun add(count: List<Int>, line: String) = count.zip(line.toCharArray().map { it.digitToInt() }) .map { it.first +...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
2,562
aoc-kotlin
Apache License 2.0
aoc-2023/src/main/kotlin/aoc/aoc8.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val testInput = """ LR AAA = (11B, XXX) 11B = (XXX, ZZZ) ZZZ = (11B, XXX) 22A = (22B, XXX) 22B = (22C, 22C) 22C = (22Z, 22Z) 22Z = (22B, 22B) XXX = (XXX, XXX) """.parselines class LeftRight(val left: String, val right: String) fun St...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
2,114
advent-of-code
Apache License 2.0
2021/src/main/kotlin/day13.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.MutableIntGrid import utils.Parser import utils.Solution import utils.Vec2i fun main() { Day13.run() } object Day13 : Solution<Pair<IntGrid, List<Day13.FoldInsn>>>() { override val name = "day13" override val parser = Parser { input -> val (ptsLines, insnLines) = input.spli...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,463
aoc_kotlin
MIT License
src/main/kotlin/io/matrix/IslandPerimeter.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.matrix import io.utils.runTests import java.util.* // https://leetcode.com/problems/island-perimeter/ class IslandPerimeter { fun execute(input: Array<IntArray>): Int { input.forEachIndexed { row, rowValue -> rowValue.forEachIndexed { col, value -> if (value == 1) return calculateIslan...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,257
coding
MIT License
src/Day20.kt
dizney
572,581,781
false
{"Kotlin": 105380}
import java.util.LinkedList object Day20 { const val EXPECTED_PART1_CHECK_ANSWER = 3 const val EXPECTED_PART2_CHECK_ANSWER = 1623178306L val ANSWER_POSITIONS = setOf(1000, 2000, 3000) const val DECRYPTION_KEY = 811589153L } fun main() { fun List<String>.parse() = map(String::toLong).foldIndexed(L...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
2,287
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/endredeak/aoc2022/Day16.kt
edeak
571,891,076
false
{"Kotlin": 44975}
package endredeak.aoc2022 import kotlin.math.max fun main() { solve("Proboscidea Volcanium") { println("PART 2 takes around a minute!") val input = lines .map { it.split(" ", "=", "; ", ", ").filter { s -> s.none { c -> c.isLowerCase() } } } .map { l -> Triple(l[0], l[1].t...
0
Kotlin
0
0
e0b95e35c98b15d2b479b28f8548d8c8ac457e3a
1,992
AdventOfCode2022
Do What The F*ck You Want To Public License
src/Day08.kt
mr-cell
575,589,839
false
{"Kotlin": 17585}
fun main() { fun part1(input: List<String>): Int { val grid = parseInput(input) return (1 until grid.size - 1).sumOf { y -> (1 until grid[y].size - 1).count { x -> grid.isVisible(x, y) } } + (2 * grid.size) + (2 * grid[0].size) - 4 } fun part...
0
Kotlin
0
0
2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9
1,552
advent-of-code-2022
Apache License 2.0
src/d02/Day02.kt
Ezike
573,181,935
false
{"Kotlin": 7967}
package d02 import readInput enum class Card(val value: Int) { Rock(1), Paper(2), Scissors(3) } fun Card.next() = when (this) { Card.Rock -> Card.Paper Card.Paper -> Card.Scissors Card.Scissors -> Card.Rock } fun Card.prev() = when (this) { Card.Rock -> Card.Scissors Card.Paper -> Ca...
0
Kotlin
0
0
07ed8acc2dcee09cc4f5868299a8eb5efefeef6d
1,675
advent-of-code
Apache License 2.0
src/aoc2023/Day5.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2023 import utils.checkEquals import utils.readInputAsText fun main(): Unit = with(Day5) { part1(testInput).checkEquals(35) part1(input) .checkEquals(84470622) // .sendAnswer(part = 1, day = "5", year = 2023) part2(testInput).checkEquals(46) part2(input) .checkEqual...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,722
Kotlin-AOC-2023
Apache License 2.0
y2017/src/main/kotlin/adventofcode/y2017/Day22.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution import adventofcode.y2017.Day22.Health.* object Day22 : AdventSolution(2017, 22, "Sporifica Virus") { override fun solvePartOne(input: String): String { val map: MutableMap<Point, Health> = parseInput(input) val weakWorm = object : Worm() { ov...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,433
advent-of-code
MIT License
src/day11/Day11.kt
lpleo
572,702,403
false
{"Kotlin": 30960}
package day11 import readInput import java.util.DoubleSummaryStatistics import kotlin.math.floor private const val FILES_DAY_TEST = "files/Day11_test" private const val FILES_DAY = "files/Day11" abstract class Monkey(var worryLevels: ArrayDeque<Double>, var percent: Double) { var itemInspected = 0L; abstra...
0
Kotlin
0
0
115aba36c004bf1a759b695445451d8569178269
7,430
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day04.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
fun main() { fun calculate(input: List<String>, isOverlap: (IntRange, IntRange) -> Boolean): Int = input.map { val ranges = it.split(",") val leftRange = ranges[0].split("-").let { range -> range[0].toInt()..range[1].toInt() } val rightRange = ranges[1].split("-").let { range -> range[0].to...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
1,231
KotlinAdventOfCode2022
Apache License 2.0
src/Day07.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
data class Dir( var name: String, var size: Long = 0L, var parent: Dir? ) fun main() { fun calculateSize(dir: Dir, addSize: Long) { dir.size += addSize if (dir.parent != null) calculateSize(dir.parent!!, addSize) } fun parseLine(line: List<String>, current: Dir, dirs: MutableMap...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
1,900
aoc-2022-in-kotlin
Apache License 2.0
aoc2016/src/main/kotlin/io/github/ajoz/aoc16/Day3.kt
ajoz
116,427,939
false
null
package io.github.ajoz.aoc16 import java.io.File /** * Day 3: Squares With Three Sides * * -------------------- Part 1 ----------------------- * * Now that you can think clearly, you move deeper into the labyrinth of hallways and office furniture that makes up * this part of Easter Bunny HQ. This must be a grap...
0
Kotlin
0
0
49ba07dd5fbc2949ed3c3ff245d6f8cd7af5bebe
3,226
challenges-kotlin
Apache License 2.0
src/main/aoc2022/Day12.kt
Clausr
575,584,811
false
{"Kotlin": 65961}
package aoc2022 import java.util.* typealias Coordinates = Pair<Int, Int> private fun Coordinates.getNeighbors(): List<Coordinates> { val leftOf = Coordinates(first - 1, second) val rightOf = Coordinates(first + 1, second) val topOf = Coordinates(first, second - 1) val bottomOf = Coordinates(first, ...
1
Kotlin
0
0
dd33c886c4a9b93a00b5724f7ce126901c5fb3ea
2,845
advent_of_code
Apache License 2.0
src/main/kotlin/com/github/davio/aoc/y2023/Day2.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2023 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.getInputAsList /** * See [Advent of Code 2023 Day X](https://adventofcode.com/2023/day/2#part2]) */ object Day2 : Day() { private val bag = mapOf( "red" to 12, "green" to 13, "...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
2,023
advent-of-code
MIT License
src/main/kotlin/day02.kt
mgellert
572,594,052
false
{"Kotlin": 19842}
object RockPaperScissors : Solution { fun scoreAllRounds(rounds: List<Pair<String, String>>): Int = rounds .map { Pair(it.first.toHand(), it.second.toHand()) } .sumOf { Hand.scoreRound(it.second, it.first) } fun calculateHandAndScoreAllRounds(rounds: List<Pair<String, String>>): Int = rounds ...
0
Kotlin
0
0
4224c762ad4961b28e47cd3db35e5bc73587a118
2,729
advent-of-code-2022-kotlin
The Unlicense
14/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File const val LAST_STEP = 10 fun readInput() : Polymer { val input = File("input.txt") .readText() .split("\r\n\r\n") val original = input[0] val rules = mutableMapOf<String, String>() input[1].split("\n").filter{ it.isNotEmpty() }.forEach { val regex = "(\\w+...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,158
advent-of-code-2021
MIT License
src/main/kotlin/io/github/aarjavp/aoc/day12/Day12.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day12 import io.github.aarjavp.aoc.readFromClasspath class Day12 { enum class CaveType { BIG, SMALL } data class Node(val id: String, val neighbors: MutableSet<String>, val caveType: CaveType) { constructor(id: String): this( id = id, neighbors = mutableSetOf...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
3,482
advent-of-code-2021
MIT License
src/Day03.kt
chasebleyl
573,058,526
false
{"Kotlin": 15274}
fun Char.toPriorityValue(): Int { // LOWERCASE a-z 97-122 if (this.code in 97..122) return this.code - 96 // UPPERCASE A-Z 65-90, with a 26 priority drop due to uppercase (lowercase prioritized ahead of uppercase) return this.code - 64 + 26 } fun main() { fun part1(input: List<String>): Int { ...
0
Kotlin
0
1
f2f5cb5fd50fb3e7fb9deeab2ae637d2e3605ea3
1,869
aoc-2022
Apache License 2.0
src/Day04/Day04.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day04 import readInput import java.lang.Error import java.util.BitSet fun fullContained(leftPair: Pair<Int, Int>, rightPair: Pair<Int, Int>): Int { if (leftPair.first >= rightPair.first && leftPair.second <= rightPair.second) { return 1 } else if (rightPair.first >= leftPair.first && rightPair...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
1,989
advent-of-code-2022
Apache License 2.0
day9/src/main/kotlin/com/lillicoder/adventofcode2023/day9/Day9.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day9 fun main() { val day9 = Day9() val readings = ReadingsParser().parse("input.txt") println("The sum of all next predictions for all sequences is ${day9.part1(readings)}.") println("The sum of all previous predictions for all sequences is ${day9.part2(readings...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
3,133
advent-of-code-2023
Apache License 2.0
src/main/kotlin/dec13/Main.kt
dladukedev
318,188,745
false
null
package dec13 import kotlin.math.ceil fun getTimestamp(input: String): Int = input.lines().first().toInt() fun getBusTimes(input: String): List<Int> = input .lines() .last() .split(",") .filter { it != "x" } .map { it.toInt() } fun getQuickestBus(target: Int, buses: List<Int>): Int { return ...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
1,726
advent-of-code-2020
MIT License
jvm/src/main/kotlin/io/prfxn/aoc2021/day21.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// <NAME> (https://adventofcode.com/2021/day/21) package io.prfxn.aoc2021 import kotlin.math.max import kotlin.math.min private typealias PositionAndScore = Pair<Int, Int> fun main() { val (p1sp, p2sp) = textResourceReader("input/21.txt").readLines().map { it.split(":").last().trim().toInt() } val rollDice...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
3,074
aoc2021
MIT License
src/Day04.kt
sgc109
576,491,331
false
{"Kotlin": 8641}
fun main() { fun isIncluded(p1: List<Int>, p2: List<Int>): Boolean { return (p1[0] <= p2[0] && p1[1] >= p2[1]) || (p1[0] >= p2[0] && p1[1] <= p2[1]) } fun isOverlapped(p1: List<Int>, p2: List<Int>): Boolean { return !(p1[1] < p2[0] || p2[1] < p1[0]) } fun toPairs(li...
0
Kotlin
0
0
03e4e85283d486430345c01d4c03419d95bd6daa
1,156
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
/* * Hindsight notes * - yeah too much string typing here :-/ */ fun main() { fun getScore(key: String): Int { /* * Hindsight notes * `when` here would allow multiple matches to the same value, like * "AX", "BY", "CZ" -> 3 etc, which is more readable than this */ ...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
2,478
aoc2022
Apache License 2.0
src/Day07.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
import kotlin.math.abs abstract class DirectoryItem(open val name: String, open val parent: Directory?) { abstract fun computeSize(): Int } data class File(override val name: String, val size: Int, override val parent: Directory) : DirectoryItem(name, parent) { override fun computeSize(): Int = size } da...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
3,816
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
private sealed class RPS { object Rock : RPS() object Paper : RPS() object Scissors : RPS() fun beats(other: RPS): Boolean { return when (this) { Rock -> other == Scissors Paper -> other == Rock Scissors -> other == Paper } } val winVs: RPS ...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
3,368
aoc-kotlin-2022
Apache License 2.0
src/Day07.kt
Kanialdo
573,165,497
false
{"Kotlin": 15615}
import kotlin.math.min fun main() { class Node( val name: String, val parent: Node?, val children: MutableList<Node> = mutableListOf(), var size: Int = 0, ) { fun print(index: Int = 0) { println("-".padStart(index * 2, ' ') + " " + name) children...
0
Kotlin
0
0
10a8550a0a85bd0a928970f8c7c5aafca2321a4b
2,358
advent-of-code-2022
Apache License 2.0
src/year2022/09/Day09.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`09` import kotlin.math.abs import readInput data class Position( val x: Int, val y: Int ) data class Command( val direction: Direction, val amount: Int ) { enum class Direction { UP, DOWN, LEFT, RIGHT; companion object { fun from(string: String): Dir...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,319
KotlinAdventOfCode
Apache License 2.0
src/day04/Day04.kt
ignazio-castrogiovanni
434,481,121
false
{"Kotlin": 8657}
package day04 import readInput fun main() { val exampleInput = readInput("Day04_example", "day04") var (numbers, boards) = parseInput(exampleInput) println("Result for example values: ${part1(numbers, boards)}") val input = readInput("Day04_test", "day04") val (numbersData, boardsData) = parseInp...
0
Kotlin
0
0
5ce48ba58da7ec5f5c8b05e4430a652710a0b4b9
3,616
advent_of_code_kotlin
Apache License 2.0
day-09/src/main/kotlin/SmokeBasin.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private fun partOne(): Int { val heightMap = readHeightMap() val lowPoints = findLowPoints(heightMap) return lowPoints.sumOf { heightMap[it.first][it.second] + 1 } } private fun partTwo(): Long ...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
3,891
aoc-2021
MIT License
src/main/kotlin/Day22.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
fun main() { val input = readFileAsList("Day22") println(Day22.part1(input)) println(Day22.part2(input)) } object Day22 { fun part1(input: List<String>): Int { val (grid, instructions) = parseInput(input) return followInstructions(instructions, grid) { p,d -> wrapFlat(grid, p, d) } ...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
5,090
advent-of-code-2022
Apache License 2.0
lib/src/main/kotlin/aoc/day12/Day12.kt
Denaun
636,769,784
false
null
package aoc.day12 const val START: Char = 'S' const val END: Char = 'E' typealias HeightMap = List<List<Char>> fun part1(input: String): Int = shortestPath(parse(input))!! fun part2(input: String): Int = mostScenicPath(parse(input))!! fun shortestPath(heightMap: HeightMap): Int? = bfs( findFirst(heightMap, STA...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
2,482
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2019/SpaceStoichiometry.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.nonEmptyLines fun spaceStoichiometry1(input: String): Long { val rules = input.nonEmptyLines().map { Rule.parse(it) } return requirements(rules, 1) } private fun requirements(rules: List<Rule>, fuel: Long): Long { val stock = Stock() s...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
3,190
advent-of-code
MIT License
2022/src/main/kotlin/de/skyrising/aoc2022/day21/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day21 import de.skyrising.aoc.* private interface MonkeyMath { fun compute(monkeys: Map<String, MonkeyMath>): LongFraction fun toPolynomial(monkeys: Map<String, MonkeyMath>): LongPolynomial } private data class MonkeyConst(val value: Long) : MonkeyMath { override fun compute(...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,553
aoc
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day15/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day15 import de.skyrising.aoc.* val test = TestInput(""" 1163751742 1381373672 2136511328 3694931569 7463417111 1319128137 1359912421 3125421639 1293138521 2311944581 """) @PuzzleName("Chiton") fun PuzzleInput.part1(): Any? { val input = lines ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,621
aoc
MIT License
src/main/kotlin/sschr15/aocsolutions/Day7.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* enum class HandResult(val next: HandResult? = null) { FIVE_OF_A_KIND, FOUR_OF_A_KIND(FIVE_OF_A_KIND), FULL_HOUSE(FOUR_OF_A_KIND), THREE_OF_A_KIND(FOUR_OF_A_KIND), TWO_PAIRS(FULL_HOUSE), ONE_PAIR(THREE_OF_A_KIND), HIGH_CARD(ONE...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
3,448
advent-of-code
MIT License
src/main/kotlin/com/tonnoz/adventofcode23/day11/Day11Part2.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day11 import com.tonnoz.adventofcode23.utils.readInput import com.tonnoz.adventofcode23.utils.toCharMatrix import kotlin.system.measureTimeMillis const val EXPANDING_FACTOR = 1_000_000L object Day11Part2 { @JvmStatic fun main(args: Array<String>) { val input = "input11.txt"....
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,955
adventofcode23
MIT License
app/src/main/kotlin/day14/Day14.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day14 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 14 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay14Part1, ::solveDay14Part2) } fun solveDay14Part1(input: List<String>): Long ...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
3,108
advent-of-code-kt
Apache License 2.0
src/day18/Day18.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day18 import Runner fun main() { Day18Runner().solve() } class Day18Runner : Runner<Int>( day = 18, expectedPartOneTestAnswer = 64, expectedPartTwoTestAnswer = 58 ) { override fun partOne(input: List<String>, test: Boolean): Int { val cubes = cubes(input) return cubes.map...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
3,372
advent-of-code
Apache License 2.0
src/main/kotlin/Day3.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day3 { data class NumberPosition( val number: Int, val start: Int, val end: Int, val row: Int ) data class Symbol(val symbol: Char, val coordinate: Coordinate) data class Coordinate(val x: Int, val y: Int) ...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
3,881
kotlin-kringle
Apache License 2.0
src/twentytwo/Day10.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentytwo fun main() { // test if implementation meets criteria from the description, like: val testInput = readInputLines("Day10_test") val part1 = part1(testInput) println(part1) check(part1 == 13140) val part2 = part2(testInput) println(part2) check(part2 == """ ##...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
2,496
advent-of-code-solutions
Apache License 2.0
src/day02/Day02.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day02 import readInput import readTestInput private fun String.toShape(): Shape = when (this) { "A", "X" -> Shape.Rock "B", "Y" -> Shape.Paper "C", "Z" -> Shape.Scissor else -> error(""""$this" is NOT a legal shape!""") } private fun String.toResult(): DuelResult = when (this) { "X" -> Du...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
2,662
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day19/day19.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day19 import java.lang.RuntimeException fun Iterable<String>.cartesianProduct(other: Iterable<String>): List<String> { return this.flatMap { lhsElem -> other.map { rhsElem -> lhsElem + rhsElem } } } const val debug = true fun println(str: String) { if (debug) print("$str\n")...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
7,790
advent-of-code-2020
Do What The F*ck You Want To Public License
src/Day13.kt
eo
574,058,285
false
{"Kotlin": 45178}
import kotlin.math.sign // https://adventofcode.com/2022/day/13 fun main() { fun part1(input: List<String>): Int { return input .windowed(size = 2, step = 3) .map { (first, second) -> PacketListItem.fromString(first) to PacketListItem.fromString(second) }...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
3,371
aoc-2022-in-kotlin
Apache License 2.0