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/aoc2022/day12/Day12.kt
svilen-ivanov
572,637,864
false
{"Kotlin": 53827}
package aoc2022.day12 import com.google.common.base.Stopwatch import org.jetbrains.kotlinx.multik.api.d2array import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.ndarray.data.* import org.jetbrains.kotlinx.multik.ndarray.data.set import readInput data class Point(val x: Int, val y: Int) { ...
0
Kotlin
0
0
456bedb4d1082890d78490d3b730b2bb45913fe9
4,137
aoc-2022
Apache License 2.0
src/day21/Day21.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day21 import readInput fun main() { fun parse(input: List<String>): List<Monkey> { val monkeys = input.map { line -> val split = line.split(": ") Monkey( name = split.first(), yell = when { (split.last().toIntOrNull() != n...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
3,492
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/_2022/Day02.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput // seen more elegant solutions via myFigure - "X" - maps into number // and you win when your figure = opponent's figure +1 (mod 3 ofc) fun main() { val scoreOfFigureMap = mapOf("X" to 1, "Y" to 2, "Z" to 3) val enemyWinMap = mapOf("A" to "Z", "B" to "X", "C" to "Y") val dr...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
2,431
advent-of-code
Apache License 2.0
src/main/kotlin/day09/Day09.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day09 import readInput import kotlin.math.abs import kotlin.math.sign data class Position(val x: Int, val y: Int) { operator fun plus(direction: Direction): Position { return Position(x + direction.x, y + direction.y) } fun inTouch(other: Position): Boolean { return abs(x - other...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
2,193
aoc2022
Apache License 2.0
src/aoc2018/kot/Day13.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import java.io.File import java.util.* object Day13 { data class Cart(var x: Int, var y: Int, var dX: Int = 0, var dY: Int = 0, var next: Int = 0, var alive: Boolean = true) : Comparable<Cart> { override fun compareTo(other: Cart) = if (y == other.y) x.compareTo(other.x) else y.compareTo(oth...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
2,054
Advent_of_Code
MIT License
src/year2022/day05/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day05 import java.util.function.Function import readInput fun main() { fun part1(input: List<String>, myFunc: Function<List<Char>, List<Char>> = Function { t: List<Char> -> t.reversed() }): String { val origin: MutableMap<Int, MutableList<Char>> = input.subList(0, input.indexOf("")).map ...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
1,836
adventOfCode
Apache License 2.0
2021/src/Day14.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/14 fun main() { fun step(string: String, rules: Map<String, Char>) : String { var result = "" string.zipWithNext().forEach { result += it.first result += rules.getOrDefault("${it.first}${it.second}", "") } result += string.last() ...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
3,178
advent-of-code
Apache License 2.0
src/Day14.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<CavePosition> { val rocks = input.flatMap { val splits = it.split(" -> ") val list = mutableListOf<CavePosition>() splits.zipWithNext().forEach { (start, end) -> val x1 = start.substringBefore(",").toInt(...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
1,987
advent-of-code-2022
Apache License 2.0
src/Day04.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { data class Range(val a: Int, val b: Int) fun String.build(): Range { val ab = this.split('-').map { it.toInt() } return Range(ab[0], ab[1]) } fun part1(input: List<String>): Int { val result = input .map { line -> line.split(',') } .count { ...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
1,184
aoc-2022-in-kotlin
Apache License 2.0
src/day02/Day02.kt
mahmoud-abdallah863
572,935,594
false
{"Kotlin": 16377}
package day02 import assertEquals import readInput import readTestInput enum class RoundResult(val score: Int) { Win(6), Lost(0), Draw(3); companion object { fun getFromString(s: Char): RoundResult = when(s) { 'X' -> Lost 'Y' -> Draw else -> Win } ...
0
Kotlin
0
0
f6d1a1583267e9813e2846f0ab826a60d2d1b1c9
2,311
advent-of-code-2022
Apache License 2.0
src/main/kotlin/co/csadev/advent2021/Day16.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 16 * Problem Description: http://adventofcode.com/2021/day/16 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsText class Day16(override val input: String = resourceAsText("21day16....
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
3,301
advent-of-kotlin
Apache License 2.0
src/Day09.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
import kotlin.math.absoluteValue enum class Direction { U, D, L, R } fun main() { data class Point(var x: Int, var y: Int) fun moveHead(rope: List<Point>, d: Direction, distance: Int, visitedLocations: MutableSet<Point>) { repeat(distance) { var head = rope[0] when (d) { ...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
2,449
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day06.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun main() { val testInput = """Time: 7 15 30 Distance: 9 40 200""".trimIndent().split("\n") fun distances(racetime: Int): Sequence<Int> = (1 until racetime) .asSequence() ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,904
aoc-2022-kotlin
Apache License 2.0
2021/src/main/kotlin/day4_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.Parser import utils.Solution fun main() { Day4Fast.run() } object Day4All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day4Func, "imp" to Day4Imp, "fast" to Day4Fast).forEach { (header, solution) -> solution.run(header = header, skipPart1 = true, skipTes...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,404
aoc_kotlin
MIT License
src/Day03.kt
b0n541
571,797,079
false
{"Kotlin": 17810}
fun main() { fun stringsToCharSets(strings: List<String>) = strings.map { it.toSet() } fun intersectAll(charSets: List<Set<Char>>) = charSets.reduce { first, second -> first intersect second }.single() fun priority(char: Char) = when (char) { in 'a'..'z' -> char - 'a' + 1 in 'A'..'Z' -> c...
0
Kotlin
0
0
d451f1aee157fd4d47958dab8a0928a45beb10cf
1,511
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2021/Day08.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2021 import com.nibado.projects.advent.* object Day08 : Day { val values = resourceLines(2021, 8).map { it.split("\\s*\\|\\s*".toRegex()) .let { (pattern, digits) -> pattern.split(' ') to digits.split(' ').map { it.trim() } } } override fun part...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,382
adventofcode
MIT License
2022/src/main/kotlin/com/github/akowal/aoc/Day12.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc import kotlin.math.min class Day12 { private val map: Map<Point, Int> private val start: Point private val end: Point init { val lines = inputFile("day12").readLines() start = lines.findPoint('S') end = lines.findPoint('E') map = lines.f...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
2,044
advent-of-kode
Creative Commons Zero v1.0 Universal
src/Day08.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
fun main() { fun log(message: Any?) { // println(message) } fun circumference(n: Int) = 4 * (n - 1) fun iterPairsInside(n: Int) = sequence { (1 until n - 1).forEach { x -> (1 until n - 1).forEach { y -> yield(Pair(x, y)) } } } fun...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
3,381
aoc2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day02.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { part1() part2() } private fun part1() { val maxR = 12 val maxG = 13 val maxB = 14 readInput(2023, 2).useLines { lines -> val result = lines.map { line -> val (id, g...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,114
adventofcode
Apache License 2.0
src/Day03.kt
mdtausifahmad
573,116,146
false
{"Kotlin": 5783}
import java.io.File fun main(){ val groupSize = 3 val sumOfPriorities = File("src/Day03.txt") .readText() .also { println(it) } .split("\n") .flatMap { it.lines() } .map { getCommonCharacters(it) } .flatMap { it.map { elf -> getPriority(elf) } } .sum() ...
0
Kotlin
0
0
13295fd5f5391028822243bb6880a98c70475ee2
1,421
adventofcode2022
Apache License 2.0
src/day13/Day13.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day13 import readInputAsString private const val DAY_ID = "13" private sealed class PacketItem: Comparable<PacketItem> { data class Num(val x: Int) : PacketItem() { fun toSeq(): Seq = Seq(listOf(this)) } data class Seq(val items: List<PacketItem>) : PacketItem() override fun compare...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
4,184
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/advent2019/day14/day14.kt
davidpricedev
225,621,794
false
null
package advent2019.day14 import advent2019.util.pow import kotlin.math.ceil /** * Part 2 Notes: * naive option of starting fuel gueses at 1T/ore-for-1-fuel and incrementing up from there is waaaay to slow * I could look for a way to turn my logic inside out maybe? * Maybe there is an LCM/GCF solution in there som...
0
Kotlin
0
0
2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9
6,572
adventOfCode2019
Apache License 2.0
src/Day18.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<Position3D> = input.map { Position3D.parse(it) } fun part1(input: List<String>): Int { val cubes = parse(input) var count = 0 cubes.forEach { cube -> count += 6 - cube.adjacentCubes().count { it in cubes } } r...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
1,782
advent-of-code-2022
Apache License 2.0
src/Day05.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
fun main() { fun parseState(initial: String): MutableList<String> { return initial.lines() .dropLast(1) .map { line -> line.windowed(3, 4) .map { if (it.trim().isEmpty()) "" else it[1].toString() } } .reduce { current, next...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
1,491
Advent-of-Code-2022
Apache License 2.0
2022/src/day12/day12.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day12 import GREEN import RESET import printTimeMillis import readInput import java.util.* typealias Table = Array<Array<Point>> data class Point(val value: Char, val minRisk: Int? = null) data class Visit(val x: Int, val y: Int, val prev: Char, val currentRisk: Int) fun Table.getValueOrNull(x: Int, y: Int,...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,586
advent-of-code
Apache License 2.0
src/year2015/day14/Day14.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day14 import check import readInput import java.lang.Integer.min fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2015", "Day14_test") check(part1(testInput, 1000), 1120) check(part2(testInput, 1000), 688) val input = re...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,677
AdventOfCode
Apache License 2.0
src/main/kotlin/Day04.kt
NielsSteensma
572,641,496
false
{"Kotlin": 11875}
fun main() { val input = readInput("Day04") println("Day 04 Part 1 ${calculateDay04Part1(input)}") println("Day 04 Part 2 ${calculateDay04Part2(input)}") } fun calculateDay04Part1(input: List<String>): Int { return input.map(::getElvePairSections).count(::fullyOverlappingSections) } fun calculateDay04...
0
Kotlin
0
0
4ef38b03694e4ce68e4bc08c390ce860e4530dbc
1,667
aoc22-kotlin
Apache License 2.0
advent-of-code2015/src/main/kotlin/day12/Advent12.kt
REDNBLACK
128,669,137
false
null
package day12 import parseInput /** --- Day 12: JSAbacusFramework.io --- Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, their accounting software uses a peculiar storage format. That's where you come in. They have a JSON document which contains a variety of things: array...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
2,899
courses
MIT License
src/Day10.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
fun main() { data class RegisterState(val cycle: Int, val adjustment: Int) fun cycleStates(input: List<String>): List<RegisterState> { var cycle = 1 return input .mapNotNull { val instruction = it.split(" ") when (instruction[0]) { ...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
1,966
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/com/dr206/2022/Day05.kt
dr206
572,377,838
false
{"Kotlin": 9200}
import java.util.Stack fun main() { fun createStacks(initialSate: List<String>): List<Stack<Char>> { val stackShape = initialSate.filter { it.contains("[") }.reversed() val numberOfStacks = (stackShape.first().length + 1) / 4 val stacks: List<Stack<Char>> = generateSequence { Stack<Char>(...
0
Kotlin
0
0
57b2e7227d992de87a51094a971e952b3774fd11
2,655
advent-of-code-in-kotlin
Apache License 2.0
src/y2023/Day01.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.timingStatistics val digitStrings = mapOf( "one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7, "eight" to 8, "nine" to 9, "1" to 1, "2" to 2, "3" to 3, "4" to 4, "5" to 5, ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,200
advent-of-code
Apache License 2.0
src/Day07.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
interface Node { val name: String fun size(): Long } data class File(override val name: String, val size: Long): Node { override fun size(): Long = size } data class Folder(override val name: String): Node { private var children: Map<String, Node> = mutableMapOf() private var size: Long? = null ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
3,650
advent-of-code-2022
Apache License 2.0
src/Day12.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun map(): List<CharArray> { return readInput("Day12").map { it.toCharArray() } } private fun part1(map: List<CharArray>): Int { val n = map.size val m = map[0].size val finish = find(map, 'E') map[finish.y][finish.x] = 'z' val start = find(map, 'S') map[start.y][start.x] = 'a' ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
3,136
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day16/Day16.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day16 import PriorityQueue import bfs import execute import parseRecords import readAllText data class Valve(val rate: Long, val exits: List<String>) class Graph(valves: Map<String, Valve>) { val data: List<Long> val moves: Map<Pair<Int, Int>, Move> val totalBits: Int init { var nextI...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
5,899
advent-of-code-2022
MIT License
src/main/kotlin/day11.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day11 import aoc.utils.* import java.math.BigInteger data class Monkey( val index: Int, var inspectionCount: Int, val worryLevels: MutableList<BigInteger>, val op: (BigInteger) -> BigInteger, val divider: Int, val successTarget: Int, val failureTarget: Int ) data class Move(val ta...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
3,012
adventOfCode2022
Apache License 2.0
src/main/kotlin/Day2.kt
ummen-sherry
726,250,829
false
{"Kotlin": 4811}
import java.util.Locale import java.util.Optional import kotlin.jvm.optionals.getOrDefault data class GameLimit(val redLimit: Int = 12, val greenLimit: Int = 13, val blueLimit: Int = 14) fun GameLimit.isValid(color: String, count: Int): Boolean { return when (color.lowercase(Locale.getDefault())) { "red" ...
0
Kotlin
0
0
c91c1b606a17a00e9efa5f2139d0efd0c1270634
3,040
adventofcode2023
MIT License
src/Day07.kt
befrvnk
574,229,637
false
{"Kotlin": 15788}
sealed class Item { abstract val name: String abstract val size: Int data class File( override val name: String, override val size: Int, ) : Item() data class Directory( override val name: String, val items: MutableList<Item> = mutableListOf(), val parent: ...
0
Kotlin
0
0
68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7
3,508
aoc-2022-kotlin
Apache License 2.0
src/day05/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day05 import grouped import readInput data class BoxLocation(val layer: Int, val stackNumber: Int, val value: Char) data class Movement(val amount: Int, val from: Int, val to: Int) fun main() { val format = """move (\d+) from (\d+) to (\d+)""".toRegex() fun parse(input: List<String>) = input.map { i...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
2,290
AOC2022
Apache License 2.0
src/day14/Day14.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day14 import kotlin.math.sign import readInput enum class Direction(val vec: Position) { DOWN(Position(1, 0)), DOWNLEFT(Position(1, -1)), DOWNRIGHT(Position(1, 1)), STAY(Position(0, 0)) } data class Position(val row: Int, val column: Int) { operator fun plus(other: Position): Position { ...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
3,166
aoc-2022
Apache License 2.0
src/Day11.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
fun main() { fun part1(input: List<String>): Long { val monkeys = parseMonkeys(input, manageWorryLevel = true) play(monkeys, rounds = 20) return monkeys .sortedByDescending { it.inspects } .take(2) .fold(1) { acc, i -> acc * i.inspects } } fun p...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
5,417
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day21.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 import com.dvdmunckhof.aoc.splitOnce class Day21(input: List<String>) { private val foods = input.map { line -> val (part1, part2) = line.splitOnce(" (contains ") Food(part1.split(" "), part2.dropLast(1).split(", ")) } fun solvePart1(): Int { ...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,937
advent-of-code
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch1/Problem14.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch1 import kotlin.math.log2 /** * Problem 14: Longest Collatz Sequence * * https://projecteuler.net/problem=14 * * Goal: Find the largest starting number <= N that produces the longest Collatz sequence. * * Constraints: 1 <= N <= 5e6 * * Collatz Sequence: Thought to all finish at 1, a ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,230
project-euler-kotlin
MIT License
src/main/day09/day09.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day09 import Point import kotlin.math.sign import readInput typealias Segment = Point enum class Direction { R, U, D, L } val regex = """([RUDL]) (\d+)""".toRegex() val start = Segment(0, 0) fun main() { val input = readInput("main/day09/Day09") println(part1(input)) println(part2(input)) } ...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,254
aoc-2022
Apache License 2.0
src/main/kotlin/day12.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day12 import aoc.utils.* import aoc.utils.graphs.Node import aoc.utils.graphs.shortestDistance import java.lang.Exception data class Square(var height: Char, var isVisited: Boolean) fun main() { part2() } fun part1(): Long { val map = Matrix( readInput("day12-input.txt").map { it.toCharArray...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
3,783
adventOfCode2022
Apache License 2.0
src/day13/Day13.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day13 import day13.Fragment.CollectionFragment import day13.Fragment.DataFragment import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.int import readInp...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
3,424
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day9/SmokeBasin.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day9 import utils.Cursor import utils.Entry import utils.Matrix import utils.read fun main() { solve().let { println(it) } } val surroundingCoords = listOf( Cursor(0, -1), Cursor(-1, 0), Cursor(1, 0), Cursor(0, 1) ) fun solve(): List<Int> { val input = read("./src/main/resources/day9...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
1,694
adventOfCode2021
Apache License 2.0
src/main/kotlin/aoc2021/Day03.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2021 import utils.InputUtils fun main() { val testInput = """00100 11110 10110 10111 10101 01111 00111 11100 10000 11001 00010 01010""".split("\n") fun <K> Map<K, Int>.topKeyByValues() = if (values.size == values.toSet().size) { this.keys.sortedByDescending { this[it] }.first() } else...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,090
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day08.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.main object Day08 : Day { override val number: Int = 8 override fun part1(input: List<String>): String = input.parseToMap().let { map: Map<String, Pair<String, String>> -> val instr...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,328
advent-of-code
Apache License 2.0
src/Day02.kt
MatthiasDruwe
571,730,990
false
{"Kotlin": 47864}
import java.lang.Error fun main() { fun part1(input: List<String>): Int { val output = input.map { it.split(" ").map { it.convert() } }.sumOf {it[1].value + it[1].score(it[0]) } return output } fun part2(input: List<String>): Int { val output = input.map{convertToPair(it)}.sumOf ...
0
Kotlin
0
0
f35f01cea5075cfe7b4a1ead9b6480ffa57b4989
1,674
Advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day02.kt
julia-kim
569,976,303
false
null
package days import readInput fun main() { // opponent plays - A for Rock, B for Paper, and C for Scissors // you play - X for Rock, Y for Paper, and Z for Scissors // total score: add up shape selected + outcome of the round score // 1 for Rock, 2 for Paper, and 3 for Scissors // ...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
2,352
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day4/Bingo.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day4 import utils.Matrix import utils.read typealias Sheet = Matrix<Pair<Int, Boolean>> fun main() { solve().forEach { println(it) } } fun solve(): List<Any> { val numbers = read("./src/main/resources/day4Input.txt") .take(1) .flatMap { it.split(",") } .map { it.toInt() } ...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
1,837
adventOfCode2021
Apache License 2.0
src/Day11.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
fun main() { data class Item(var worryLevel: Long) class Monkey( val monkeys: MutableList<Monkey>, val items: ArrayDeque<Item>, val operation: Pair<String, String>, val testDivisibleBy: Int, val trueTarget: Int, val falseTarget: Int, var inspectedItems: In...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
3,637
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day4/Day04.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day4 fun solveA(input: List<String>) = input.count { val pair = convertToRanges(it) val intersection = pair.first.intersect(pair.second) intersection.size == pair.first.count() || intersection.size == pair.second.count() } fun solveB(input: List<String>) = input.count { val pair = convertToRan...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
1,736
advent-of-code-2022
Apache License 2.0
src/Day02.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
private const val FIRST_OPPONENT_CODE = 'A' private const val FIRST_SELF_CODE = 'X' private const val LOSE_SCORE = 0 private const val DRAW_SCORE = 3 private const val WIN_SCORE = 6 enum class Shape(private val score: Int) { ROCK(1) { override val beats: Shape get() = SCISSORS }, PAPER...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
1,956
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/day01/Day01.kt
k4vrin
572,914,047
false
{"Kotlin": 2480}
package day01 import readInput import java.util.PriorityQueue fun main() { fun part1(input: String): Int { return sumElfCalories(input).max() } fun part2(input: String): Int { return sumElfCalories(input) caloriesOfTop 3 } val testInput = readInput("day01", "Day01_test") val ...
0
Kotlin
0
1
eb6495e86c35fa428500a137ea60fa4f58ff460f
1,778
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch4/Problem49.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch4 import dev.bogwalk.util.combinatorics.permutationID import dev.bogwalk.util.combinatorics.permutations import dev.bogwalk.util.maths.isPrime import dev.bogwalk.util.maths.primeNumbers import kotlin.math.pow /** * Problem 49: Prime Permutations * * https://projecteuler.net/problem=49 * ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,094
project-euler-kotlin
MIT License
day-12/src/main/kotlin/PassagePathing.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 map = readMap() return getPaths(map, "start", mutableListOf(), false) .count() } private fun partTwo(): Int { val map = readMap() return getPaths(map,...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
1,841
aoc-2021
MIT License
grind-75-kotlin/src/main/kotlin/LowestCommonAncestorOfABinarySearchTree.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
import commonclasses.TreeNode /** * Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. * * According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as desce...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,603
grind-75
Apache License 2.0
codeforces/kotlinheroes4/g.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes4 private fun solve(p: List<Int>, x: List<Int>): List<Int>? { val k = (0..x.size - 3).minByOrNull { x[it + 2] - x[it] } ?: return listOf(x[0], p[0], x[1], p[0]) for (i in k..k + 2) for (j in k until i) for (aPeriod in p) { val rem = x[i] % aPeriod if (x[j] % aPeriod != rem) conti...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,058
competitions
The Unlicense
src/main/kotlin/d21_DiracDice/DiracDice.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d21_DiracDice import util.Input import util.Output import kotlin.math.max val possibleDiracRolls = mapPossibleRolls() fun main() { Output.day(21, "Dirac Dice") val startTime = Output.startTime() // region Part 1 val startPositions = Input.parseLines(filename = "/input/d21_start_positions.txt...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
4,422
advent-of-code-2021
MIT License
src/day24/a/day24a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day24.a import copyClearForEach import inFourDirections import readInputLines import shouldBe import util.IntVector import vec fun main() { val map = read() val start = vec(1,0) val end = map.bbox()[1] val t = calculate(map, 0, start, end) shouldBe(230, t) } fun calculate(map: Map, time: ...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,652
advent-of-code-2022
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day16.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay class Day16 : AdventDay(2022, 16) { data class ValveNode( val name: String, val flowRate: Int, val neighbors: List<String>, val distanceMap: MutableMap<String, Int> = mutableMapOf() ) { companion object { fun of(input: Strin...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
4,546
advent-of-code
Apache License 2.0
src/Day22.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.max import kotlin.math.min enum class Direction { UP, DOWN, LEFT, RIGHT; private fun turnLeft() = when (this) { UP -> LEFT DOWN -> RIGHT LEFT -> DOWN RIGHT -> UP } private fun turnRight() = when (this) { UP -> RIGHT DOWN -> LEFT ...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
8,642
aoc2022
Apache License 2.0
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day11.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.shared.multiply import codes.jakob.aoc.shared.parseInt import codes.jakob.aoc.shared.splitMultiline class Day11 : Solution() { override fun solvePart1(input: String): Any { val monkeys: List<Monkey> = input.split("\n\n").map { parseMonkey(it) } val wo...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
4,333
advent-of-code-2022
MIT License
src/Day02.kt
pavlov200912
572,885,762
false
{"Kotlin": 3267}
fun main() { fun transformMove(move: String): Int { return when (move) { "A" -> 0 // rock "B" -> 1 // paper "C" -> 2 // scissors "X" -> 0 "Y" -> 1 "Z" -> 2 else -> { -1 } } } fun ...
0
Kotlin
0
0
cef9f2d0a5ec231801fa85dfbd92c0e7ee86eddf
1,950
aoc-2022
Apache License 2.0
src/Day16.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import java.util.concurrent.atomic.AtomicInteger fun main() { fun part1(input: List<String>): Int { val spaces = input.map { Space.from(it) } val dista...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
5,360
Advent-Of-Code-2022
Apache License 2.0
src/Day05.kt
ahmadshabib
573,197,533
false
{"Kotlin": 13577}
fun main() { val input = readInput("Day05") val stacks = createStacks(numberOfStacks(line = input[0])) input.filter { it.contains("[") }.reversed().forEach { fillStack(it, stacks) } input .asSequence() .filter { it.startsWith("move") } .map { it.replace("move ", "") } .m...
0
Kotlin
0
0
81db1b287ca3f6cae95dde41919bfa539ac3adb5
1,862
advent-of-code-kotlin-22
Apache License 2.0
src/Day22.kt
bananer
434,885,332
false
{"Kotlin": 36979}
data class Point3d(val x: Int, val y: Int, val z: Int) data class Cuboid(val p1: Point3d, val p2: Point3d) { val points: Sequence<Point3d> get() = generateSequence (p1) { if (it.x < p2.x) { Point3d(it.x + 1, it.y, it.z) } else if(it.y < p2.y) { Point3d(p1.x, it.y + 1...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
2,444
advent-of-code-2021
Apache License 2.0
src/Day09.kt
FuKe
433,722,611
false
{"Kotlin": 19825}
fun main() { val puzzleInput: List<List<Int>> = parseInput(readInput("Day09.txt")) val aResult: Int = aSolver(puzzleInput) println("Part one result: $aResult") // val bResult: Int = bSolver(puzzleInput) // println("Part two result: $bResult") } private fun aSolver(puzzleInput: List<List<Int>>): Int...
0
Kotlin
0
0
1cfe66aedd83ea7df8a2bc26c453df257f349b0e
1,801
advent-of-code-2021
Apache License 2.0
src/main/kotlin/aoc2023/day19/day19Solver.kt
Advent-of-Code-Netcompany-Unions
726,531,711
false
{"Kotlin": 94973}
package aoc2023.day19 import lib.* suspend fun main() { setupChallenge().solveChallenge() } fun setupChallenge(): Challenge<Pair<Map<String, Workflow>, List<Part>>> { return setup { day(19) year(2023) //input("example.txt") parser { val inputGroups = it.getString...
0
Kotlin
0
0
a77584ee012d5b1b0d28501ae42d7b10d28bf070
5,562
AoC-2023-DDJ
MIT License
src/main/kotlin/days/Day11.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DayInput import util.GridCell import util.Matrix import java.util.* class Day11 : Day("11") { override fun partOne(dayInput: DayInput): Any { return calculateDustanceSum(dayInput, 2) } fun distance(star1: GridCell<Char>, star2: GridCell<Char>): Int { return Math....
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
2,069
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/adventofcode/year2021/Day04GiantSquid.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2021 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day04GiantSquid(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val numbers by lazy { input.lines().first().split(",").map(String::toInt) } private val boards by lazy { input ....
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,346
AdventOfCode
MIT License
src/main/kotlin/year2022/Day05.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils.test fun main() { data class Crane(val move: Int, val from: Int, val to: Int) fun part1(input: String, debug: Boolean = false): String { val crates = input.lines().filter { it.startsWith(" 1 ") } .map { it.replace(" ", "") } .last() .toCharArray() ...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
3,073
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/de/dikodam/calendar/Day07.kt
dikodam
573,126,346
false
{"Kotlin": 26584}
package de.dikodam.calendar import de.dikodam.AbstractDay import de.dikodam.executeTasks import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { Day07().executeTasks() } class Day07 : AbstractDay() { private val terminalHistory = readInputLines().map { Day07TerminalLine.parseLine(it) } // priv...
0
Kotlin
0
1
3eb9fc6f1b125565d6d999ebd0e0b1043539d192
5,111
aoc2022
MIT License
y2022/src/main/kotlin/adventofcode/y2022/Day13.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day13 : AdventSolution(2022, 13, "Distress Signal") { override fun solvePartOne(input: String) = parse(input) .chunked(2) .withIndex() .filter { (_, v) -> v[0] < v[1] } .sumOf { it.index + 1 } override fu...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,391
advent-of-code
MIT License
src/main/kotlin/pl/klemba/aoc/day3/Main.kt
aklemba
726,935,468
false
{"Kotlin": 16373}
package pl.klemba.aoc.day3 import java.io.File fun main() { // ----- PART 1 ----- File(inputPath) .readLines() .let { schematic -> schematic.mapIndexed { lineIndex, line -> numberRegex.findAll(line) .filter { schematic.checkIfAdjacentToASymbol(it.range, lineIndex) } .map ...
0
Kotlin
0
1
2432d300d2203ff91c41ffffe266e19a50cca944
3,479
adventOfCode2023
Apache License 2.0
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D16.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2020 import io.github.pshegger.aoc.common.BaseSolver class Y2020D16 : BaseSolver() { override val year = 2020 override val day = 16 override fun part1(): Int = parseInput().let { input -> input.nearby.mapNotNull { it.invalidField(input.validators) }.sum() } ...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
3,693
advent-of-code
MIT License
src/AoC9.kt
Pi143
317,631,443
false
null
import java.io.File fun main() { println("Starting Day 9 A Test 1") calculateDay9PartA("Input/2020_Day9_A_Test1", 5) println("Starting Day 9 A Real") calculateDay9PartA("Input/2020_Day9_A", 25) println("Starting Day 9 B Test 1") calculateDay9PartB("Input/2020_Day9_A_Test1", 5) println("St...
0
Kotlin
0
1
fa21b7f0bd284319e60f964a48a60e1611ccd2c3
2,383
AdventOfCode2020
MIT License
day07/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import com.google.common.graph.GraphBuilder import com.google.common.graph.MutableGraph import java.io.File import java.util.* fun main() { println("Part I: the solution is ${solvePartI(makeGraph(readInputFile(), true))}.") println("Part II: the solution is ${solvePartII(makeGraph(readInputFile(), false))}.") ...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
4,395
AdventOfCode2018
MIT License
src/day9/puzzle09.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day9 import Puzzle import PuzzleInput import java.io.File import kotlin.math.abs fun day9Puzzle() { Day9PuzzleSolution().solve(Day9PuzzleInput("inputs/day9/example.txt", 2, 13)) Day9PuzzleSolution().solve(Day9PuzzleInput("inputs/day9/input.txt", 2, 6271)) Day9PuzzleSolution().solve(Day9PuzzleInpu...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
2,283
aoc_2022
Apache License 2.0
src/main/kotlin/days/Solution08.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.TripleOf import kotlin.math.sqrt typealias TurnOrder = CharArray typealias NodeMap = Map<String, PairOf<String>> typealias CycleNumber = Long object Solution08 : Solution<Pair<TurnOrder...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
5,344
Advent-of-Code-2023
MIT License
src/Day08.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
fun main() { fun part1(forest: Forest): Int { var visibleTrees = 0 for (row in 0..forest.rows.lastIndex) for (column in 0..forest.rows[0].lastIndex) if (forest.isTreeVisible(row, column)) visibleTrees++ return visibleTrees } fun part2(forest: Forest): I...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
3,263
advent-of-code-2022
Apache License 2.0
src/aoc2022/Day08.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 fun main() { fun part1(input: Array<IntArray>): Int { val verticalEdgesCount = input.size * 2 val betweenHorizontalEdgesCount = (input.first().size - 2) * 2 var visibleTreesCount = verticalEdgesCount + betweenHorizontalEdgesCount for (rowIndex in 1 until input.l...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,481
Kotlin-AOC-2023
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day17/Day17.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,539
AdventOfCode
Apache License 2.0
src/Day01.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
val nameToDigit = mapOf( "one" to "1", "two" to "2", "three" to "3", "four" to "4", "five" to "5", "six" to "6", "seven" to "7", "eight" to "8", "nine" to "9", ) fun main() { fun part1(input: List<String>): Int { return input.sumOf { val digits = it.filter ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
1,443
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { val strategy = readInput("Day02") .map (::parseLine) fun part1(strategy: List<Pair<Int, Int>>): Int { // let x, y denotes Rock/Paper/Scissor of opponent and you // the result will be // you win IFF y - x ≡ 1 (mod 3) // draw IFF y - x ≡ 1 (mod 3) // y...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
1,260
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
Kaaveh
572,838,356
false
{"Kotlin": 13188}
private fun parse(input: List<String>): Pair<Int, MutableList<MutableList<Char>>> { val rawMap = mutableListOf<String>() var mapIndex = 0 do { rawMap.add(input[mapIndex]) mapIndex++ } while ("[" in input[mapIndex]) val rowCount = input[mapIndex].trim().split("\\s+".toRegex()).size ...
0
Kotlin
0
1
9022f1a275e9c058655898b64c196f7a0a494b48
2,242
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day16.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import at.mpichler.aoc.lib.ShortestPaths open class Part16A : PartSolution() { private lateinit var valves: Map<String, Valve> protected var maxFlow: Int = 0 protected lateinit var closedValve...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,706
advent-of-code-kotlin
MIT License
src/Day05.kt
fdorssers
575,986,737
false
null
data class Step(val move: Int, val from: Int, val to: Int) fun main() { fun parseLines(lines: List<String>): Pair<MutableMap<Int, String>, List<Step>> { val dock = lines .takeWhile { line -> !line.startsWith(" 1") } .map { line -> (1..line.length) ...
0
Kotlin
0
0
bdd1300b8fd6a1b8bce38aa6851e68d05193c636
1,953
advent-of-code-kotlin
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day17.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day17.solve() object Day17 : AdventSolution(2020, 17, "Conway Cubes") { override fun solvePartOne(input: String): Int { val active = parse(input).map { it + 0 }.toSet() return generateSequence(ConwayCube(active), C...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,921
advent-of-code
MIT License
solutions/aockt/y2022/Y2022D02.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2022 import aockt.y2022.Y2022D02.RpsChoice.* import aockt.y2022.Y2022D02.RpsChoice.Companion.versus import io.github.jadarma.aockt.core.Solution object Y2022D02 : Solution { private enum class RpsChoice(val score: Int) { Rock(1), Paper(2), Scissors(3); val winsAgai...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,477
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/com/chriswk/aoc/advent2018/Day12.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2018 object Day12 { fun part1(input: List<String>): Int { val (pots, rules) = parseInput(input) return (1..20).fold(pots) { state, _ -> step(state, rules) }.fold(0) { sumSoFar, pot -> if (pot.hasPlant) sumSoFar + pot.idx else sumSoFar } } f...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,393
adventofcode
MIT License
src/Day07.kt
frungl
573,598,286
false
{"Kotlin": 86423}
data class Node(var weight: Int, val go: MutableMap<String, Int>, val par: Int) fun main() { fun parseToTree(input: List<String>): MutableList<Node> { val graph = mutableListOf(Node(0, emptyMap<String, Int>().toMutableMap(), -1)) var pos = 0 input.drop(1).forEach { cmd -> if (cmd...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,078
aoc2022
Apache License 2.0
src/main/kotlin/net/mguenther/adventofcode/day14/Day14.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day14 import net.mguenther.adventofcode.day10.KnotHash import java.math.BigInteger /** * @author <NAME> (<EMAIL>) */ class Day14Additive(private val prefix: String) { val grid: List<IntArray> = IntRange(0, 127) .map { "$prefix-$it" } .map { KnotHash(2...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
2,950
advent-of-code-2017
MIT License
src/Day08.kt
nguyendanv
573,066,311
false
{"Kotlin": 18026}
fun main() { fun part1(input: List<String>): Int { val rows = input.map { it.map(Char::digitToInt) } val columns = rows.first().indices.map { i -> rows.map { it[i] } } return rows.flatMapIndexed { i, row -> row.mapIndexed { j, height -> val isTaller: (Int) -> Boo...
0
Kotlin
0
0
376512583af723b4035b170db1fa890eb32f2f0f
2,321
advent2022
Apache License 2.0
src/Day07.kt
melo0187
576,962,981
false
{"Kotlin": 15984}
import Command.Companion.toCommandOrNull import FileSystemNode.Companion.toFileSystemNodeOrNull sealed interface FileSystemNode { fun size(): Long data class Dir(val name: String, val contents: MutableList<FileSystemNode> = mutableListOf()) : FileSystemNode { override fun size(): Long = co...
0
Kotlin
0
0
97d47b84e5a2f97304a078c3ab76bea6672691c5
3,220
kotlin-aoc-2022
Apache License 2.0
src/Day05.kt
paul-matthews
433,857,586
false
{"Kotlin": 18652}
import kotlin.math.sign val VENT_LINE_FORMAT = """^(\d+),(\d+)\s*->\s*(\d+),(\d+)$""".toRegex() typealias Coordinate = Pair<Int, Int> typealias Line = Pair<Coordinate, Coordinate> fun Line.isNotDiagonal(): Boolean = ((first.first == second.first) or (first.second == second.second)) val MatchResult.groupIntValues: Lis...
0
Kotlin
0
0
2f90856b9b03294bc279db81c00b4801cce08e0e
3,047
advent-of-code-kotlin-template
Apache License 2.0
src/Day02.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
fun main() { fun part1(input: List<String>): Int { val scores = mapOf("X" to 1, "Y" to 2, "Z" to 3) val outcomes = mapOf( "A X" to 3, "A Y" to 6, "A Z" to 0, "B X" to 0, "B Y" to 3, "B Z" to 6, "C X" to 6, "C Y" to 0, "C Z" to 3, ) var totalScore =...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
1,283
aoc2022
Apache License 2.0
src/Day02.kt
zirman
572,627,598
false
{"Kotlin": 89030}
fun main() { fun gameScore(myMove: Long, theirMove: Long): Long { return myMove + 1 + when (myMove) { theirMove -> 3 (theirMove + 1) % 3 -> 6 else -> 0 } } fun part1(input: List<String>): Long { return input.sumOf { val round = it.spli...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
1,263
aoc2022
Apache License 2.0
src/Day02.kt
Moonpepperoni
572,940,230
false
{"Kotlin": 6305}
fun main() { fun String.toRPSNumerical() : Int { return if (this == "A" || this == "X") { 0 } else if (this == "B" || this == "Y") { 1 } else { 2 } } fun String.toGame() : Pair<Int, Int> { val strategy = this.split(" ") re...
0
Kotlin
0
0
946073042a985a5ad09e16609ec797c075154a21
1,399
moonpepperoni-aoc-2022
Apache License 2.0