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/Day03.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun rucksacks(): List<Pair<String, String>> { return readInput("Day03").map { Pair(it.substring(0, it.length / 2), it.substring(it.length / 2)) } } private fun rucksackGroups(): List<List<String>> { return readInput("Day03").chunked(3) } private fun part1(rucksacks: List<Pair<String, String>>): Int { ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
829
advent-of-code-2022
Apache License 2.0
src/Day05.kt
MarkRunWu
573,656,261
false
{"Kotlin": 25971}
import java.lang.Math.abs import java.util.Stack fun main() { fun parseStacks(input: List<String>): List<Stack<String>> { val stackStrings = input.joinToString("\n") { it }.split( "\n\n" )[0].split("\n") val labelLine = stackStrings.last().split(" ") val stacks = labe...
0
Kotlin
0
0
ced885dcd6b32e8d3c89a646dbdcf50b5665ba65
2,883
AOC-2022
Apache License 2.0
src/Day04.kt
pejema
576,456,995
false
{"Kotlin": 7994}
import kotlin.streams.toList fun main() { // Example of full range inside other: 1-5,2-4 fun getRanges(rangesPair: List<String>) : Int { val elf1 = rangesPair[0].substringBefore("-").toInt() .. rangesPair[0].substringAfter("-").toInt() val elf2 = rangesPair[1].substringBefore("-").toInt() .. r...
0
Kotlin
0
0
b2a06318f0fcf5c6067058755a44e5567e345e0c
1,523
advent-of-code
Apache License 2.0
src/day12/Day12.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day12 import readInput fun main() { data class Point(val x: Int, val y: Int, var steps: Int = 0) { override fun toString(): String { return "[$x][$y]" } } val directions = listOf( Pair(0, 1), // right Pair(1, 0), // down Pair(0, -1), // left ...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
4,328
advent-of-code-2022
Apache License 2.0
src/Day08.kt
JIghtuse
572,807,913
false
{"Kotlin": 46764}
fun main() { fun isVisibleTree(grid: Array<IntArray>, row: Int, col: Int): Boolean { val treeHeight = grid[row][col] return (0 until row).all { grid[it][col] < treeHeight } || (row + 1..grid.lastIndex).all { grid[it][col] < treeHeight } || (0 until col).all { grid[row][it] < treeHei...
0
Kotlin
0
0
8f33c74e14f30d476267ab3b046b5788a91c642b
2,977
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2021/Day21.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import modulo import readInput import withEachOf import kotlin.math.max private data class Player(var position: Int, var score: Int = 0) { /** * Moves the player on the game board * * @param distance the distance by which to advance the player * @return the player itself to ch...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,389
adventOfCode
Apache License 2.0
src/Day08.kt
arnoutvw
572,860,930
false
{"Kotlin": 33036}
fun main() { fun isGreaterThanAlPrevious(tree: Char, index: Int, line: String): Boolean { return line.subSequence(0, index).all { it.code < tree.code } } fun checkLine(line: String, checked: Array<Array<Boolean>>, lineIndex: Int, columnMode: Boolean, reversed : Boolean) { for ((index, tre...
0
Kotlin
0
0
0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4
3,805
aoc-2022-in-kotlin
Apache License 2.0
src/Day05.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun input(): Stacks { val lines = readInput("Day05") val stacksInput = lines.takeWhile { it.isNotEmpty() } val stacksCount = (stacksInput.last().length + 2) / 4 val stacks = List(stacksCount) { ArrayDeque<Char>() } stacksInput.forEach { for (i in 0 until stacksCount) { va...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,598
advent-of-code-2022
Apache License 2.0
src/day11/day11.kt
bienenjakob
573,125,960
false
{"Kotlin": 53763}
package day11 import inputTextOfDay import testTextOfDay import kotlin.math.floor fun part1(input: String): Long { return monkeyBusiness(input, 20, ::reduceWorryLevels) } fun part2(input: String): Long { return monkeyBusiness(input, 10000, ::manageWorryLevels) } fun monkeyBusiness(input: String, rounds: Int,...
0
Kotlin
0
0
6ff34edab6f7b4b0630fb2760120725bed725daa
3,323
aoc-2022-in-kotlin
Apache License 2.0
gcj/y2020/round1b/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1b import kotlin.math.abs private const val SIZE = 1_000_000_000 private fun solve() { val grid = listOf(-SIZE / 3, SIZE / 3).cartesianSquare() val (xInit, yInit) = grid.first { (x, y) -> hit(x, y) } val (xLeft, _) = furthestInside(xInit, yInit, -1, 0) val (xRight, _) = furthestInside(xIni...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,371
competitions
The Unlicense
src/main/kotlin/year_2022/Day03.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2022 import utils.readInput fun main() { fun proccessInput(input : String) : Pair<String, String>{ val middle = input.length / 2 val first = input.substring(0, middle) val second = input.substring(middle, input.length) return (first to second) } fun part1(inp...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
2,566
advent-of-code
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day22.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import adventofcode.util.vector.Vec3 fun main() { Day22.solve() } object Day22 : AdventSolution(2023, 22, "Sand Slabs") { override fun solvePartOne(input: String): Any { val slabsInAir = parse(input...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
4,369
advent-of-code
MIT License
year2023/src/cz/veleto/aoc/year2023/Day05.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.fullyIn import cz.veleto.aoc.core.intersect import cz.veleto.aoc.core.shift class Day05(config: Config) : AocDay(config) { data class Problem( val rawSeeds: List<Long>, // for part 1 val seedRanges: List<Lon...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
4,581
advent-of-pavel
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-19.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 kotlin.math.max fun main() { val input = readInputLines(2022, "19-input") val testInput1 = readInputLines(2022, "19-test1") println("Part1:") ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
8,797
advent-of-code
MIT License
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day09/Day09.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day09 import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readNonSeparatedDigits import java.util.* private const val FILENAME = "input09.txt" fun main() { val cave = Cave.read() val riskLevel = cave.lowPoints() .map { cave.heightAt(it) + 1 } .sum() print...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,912
advent-of-code
Apache License 2.0
src/main/kotlin/com/briarshore/aoc2022/day02/Puzzle.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day02 import println import readInput enum class Hand(val points: Int) { Rock(1), Paper(2), Scissors(3) } enum class Outcome(val points: Int) { Win(6), Draw(3), Lose(0) } interface IPoints { fun points(): Int } data class Score(val hand: Hand, val outcome: Outcome) : IPoin...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
3,536
2022-AoC-Kotlin
Apache License 2.0
src/Day07.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
fun main() { fun evaluate(input: List<String>): Directory { val root = Directory(name = "/") var current: Directory = root var lineIdx = 0 while (lineIdx < input.size) { val line = input[lineIdx++] val pattern = Regex("\\$ (cd|ls) ?(.+)?") val ...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
3,347
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/day11.kt
josergdev
573,178,933
false
{"Kotlin": 20792}
package days import java.io.File fun String.parseMonkeys() = this .split("\n\n") .map { it.split("\n").map { l -> l.trim() } } .map { Pair( it[0].replace("Monkey ", "").replace(":", "").toLong(), Triple( it[1].replace("Starting items: ", "").split(",").map {...
0
Kotlin
0
0
ea17b3f2a308618883caa7406295d80be2406260
3,534
aoc-2022
MIT License
src/Day02.kt
AlexeyVD
575,495,640
false
{"Kotlin": 11056}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { apply(it, RPS::fight) } } fun part2(input: List<String>): Int { return input.sumOf { apply(it, RPS::getByResult) } } val testInput = readInput("Day02_test") check(part1(testInput) == 15) check(part2(tes...
0
Kotlin
0
0
ec217d9771baaef76fa75c4ce7cbb67c728014c0
2,024
advent-kotlin
Apache License 2.0
src/Day09.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
import kotlin.math.max import kotlin.math.abs data class Position(val x: Int, val y: Int) fun main() { fun sign(a : Int) : Int = if (a > 0) { 1 } else if (a < 0) { -1 } else { 0 } fun snake(commands: List<Pair<Int, Position>>, size : Int): ...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
2,287
aoc-2022-in-kotlin
Apache License 2.0
src/day14/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day14 import println import readInput fun main() { val ROLLING_ROCK = 'O' val SQAURE_ROCK = '#' val EMPTY = '.' fun cacheKey(map: Array<Array<Char>>): String { return map.joinToString(separator = "") { it.joinToString(separator = "") } } fun tiltNorth(map: Array<Array<Char>>)...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
4,083
advent-of-code-2023
Apache License 2.0
src/Day05.kt
jbotuck
573,028,687
false
{"Kotlin": 42401}
fun main() { val lines = readInput("Day05") val indexOfStackKeyLine = lines.indexOfFirst { it.trim().first() == '1' } val part1 = part1(lines, indexOfStackKeyLine) val part2 = part2(lines, indexOfStackKeyLine) println("part 1 $part1") println("part 2 $part2") } private fun part1(lines: List<Str...
0
Kotlin
0
0
d5adefbcc04f37950143f384ff0efcd0bbb0d051
2,180
aoc2022
Apache License 2.0
src/Day24.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { val d = Day24(readInput("inputs/Day24")) println(d.part1()) println(d.part2()) } class Day24(input: List<String>) { private val initialMapState: MapState = MapState.of(input) private val start: Point = Point(input.first().indexOfFirst { it == '.' }, 0) private val goal: Point = Po...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
4,050
aoc-2022
Apache License 2.0
src/day25/day25.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day25 import readInput import kotlin.math.pow fun main() { fun fromSnafu(line: String) = line.mapIndexed { index, digit -> 5.0.pow(line.lastIndex - index) * when (digit) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else ->...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
1,459
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
enum class Symbol { ROCK, PAPER, SCISSOR } fun playRockPaperScissorRound(opponent: Symbol, me: Symbol): Int { // Opponent wins if ((opponent == Symbol.ROCK && me == Symbol.SCISSOR) || (opponent == Symbol.PAPER && me == Symbol.ROCK) || (opponent == Symbol.SCISSOR && me == Symbol.PAPER) ) { ...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
2,497
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/nosswald/aoc/days/Day04.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day import kotlin.math.pow // https://adventofcode.com/2023/day/4 object Day04 : Day<Int>(4, "Scratchcards") { private data class Card(val id: Int, val winning: List<Int>, val actual: List<Int>) private fun parseInput(input: List<String>): List<Card> { ...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
2,563
advent-of-code-2023
MIT License
kotlin/src/main/kotlin/year2023/Day08.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput("Day08") Day08.part1(input).println() Day08.part2(input).println() } object Day08 { fun part1(input: List<String>): Int { val instructions = input[0].map { if (it == 'L') 0 else 1 } val map = input .drop(2).map { ...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
2,472
advent-of-code
MIT License
src/Day12.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
data class Node(val row: Int, val col: Int, var char: Char = '?', var distance: Int = -1, var visited: Boolean = false) { val height get(): Int = when { char.isLowerCase() -> char.code - 'a'.code // 0 - 25 char == 'E' -> 26 // end point is 1 higher than 'z' else -> Int.MAX_VALUE // everythin...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
3,889
aoc2022
Apache License 2.0
src/day18/Day18.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day18 import readInput fun main() { val testInput = readInput("day18/test") val cubes = testInput.map { it.split(',') }.map { Point3D(it[0].toInt(), it[1].toInt(), it[2].toInt()) } println(part1(cubes)) println(part2(cubes)) } private fun part1(cubes: List<Point3D>): Int = cubes.sumOf { ...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
1,592
advent-of-code-2022
Apache License 2.0
src/Day23.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { val d = Day23(readInput("inputs/Day23")) println(d.part1()) println(d.part2()) } class Day23(input: List<String>) { private val startingPositions = parseInput(input) private val nextTurnOffsets: List<List<Point>> = createOffsets() fun part1(): Int { val locations = (0 unt...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,734
aoc-2022
Apache License 2.0
facebook/y2020/round1/a1.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.round1 private fun solve(M: Int = 1_000_000_007): Int { val (n, k, w) = readInts() val (L, h) = List(2) { readInts().toMutableList().also { list -> val (a, b, c, d) = readInts() for (i in k until n) { list.add(((a.toLong() * list[i - 2] + b.toLong() * list[i - 1] + c) % d + 1).toInt()) ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,212
competitions
The Unlicense
src/DayEight.kt
P-ter
572,781,029
false
{"Kotlin": 18422}
import java.util.* fun main() { fun buildTheMap(input: List<String>): Pair<List<List<Int>>, List<List<Int>>> { val row = mutableListOf<MutableList<Int>>() val column = mutableListOf<MutableList<Int>>() input.forEach { line -> val rowLine = mutableListOf<Int>() line....
0
Kotlin
0
1
e28851ee38d6de5600b54fb884ad7199b44e8373
3,734
advent-of-code-kotlin-2022
Apache License 2.0
src/com/ncorti/aoc2023/Day17.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 import com.ncorti.aoc2023.Direction.* import java.util.* fun main() { fun parseInput() = getInputAsText("17") { split("\n").filter(String::isNotBlank).map { it.toCharArray().map { it.digitToInt() }.toIntArray() } }.toTypedArray() data class Item( ...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
2,317
adventofcode-2023
MIT License
dcp_kotlin/src/main/kotlin/dcp/day220/day220.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day220 // day220.kt // By <NAME>, 2019. import kotlin.math.max import kotlin.math.min // Two solutions: backtracking and dynamic programming. // Backtracking: O(2^N) fun coin_backtrack(coins: List<Int>): Int { if (coins.isEmpty()) return 0 fun aux(curr_coins: List<Int>, value: Int): Int { ...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,070
daily-coding-problem
MIT License
src/main/kotlin/aoc/year2023/Day15.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2023 import aoc.Puzzle /** * [Day 15 - Advent of Code 2023](https://adventofcode.com/2023/day/15) */ object Day15 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int = input.split(',') .sumOf { it.map(Char::code).fold(0) { hash, ascii -> ((hash + ascii) * 17).rem(256) }.to...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,738
advent-of-code
Apache License 2.0
src/Day07.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
import kotlin.math.abs fun main() { fun parsePositions(input: List<String>): Map<Int, Int> { val positions = input[0].split(",").map(String::toInt) return positions.groupingBy { it }.eachCount() } fun part1(input: List<String>): Int { val countsByPosition = parsePositions(input) ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
1,416
AdventOfCode2021
Apache License 2.0
src/day03/Day03.kt
Dr4kn
575,092,295
false
{"Kotlin": 12652}
package day03 import readInput import java.lang.Exception fun main() { fun getDuplicateItem(backpack: String): Char { val firstCompartment = backpack .toCharArray(0, backpack.length / 2) .distinct() val secondCompartment = backpack .toCharArray(backp...
0
Kotlin
0
0
6de396cb4eeb27ff0dd9a98b56e68a13c2c90cd5
2,174
advent-of-code-2022
Apache License 2.0
src/year2021/day03/Day03.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day03 import util.assertTrue import util.read2021DayInput fun main() { fun task01(positions: List<String>): Int { var gamma = "" var epsilon = "" positions[0].forEachIndexed { row, _ -> gamma = gamma.plus(findMostOccurringBitInRow(positions, row)) ...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,644
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/io/github/kmakma/adventofcode/y2020/Y2020Day19.kt
kmakma
225,714,388
false
null
package io.github.kmakma.adventofcode.y2020 import io.github.kmakma.adventofcode.utils.Day fun main() { Y2020Day19().solveAndPrint() } class Y2020Day19 : Day(2020, 19, "Monster Messages") { private lateinit var ruleList: List<String> private lateinit var messages: List<String> private lateinit var in...
0
Kotlin
0
0
7e6241173959b9d838fa00f81fdeb39fdb3ef6fe
3,017
adventofcode-kotlin
MIT License
src/Day02.kt
befrvnk
574,229,637
false
{"Kotlin": 15788}
enum class Hand(val points: Int) { Rock(1), Paper(2), Scissor(3) } fun handFromValue(value: String): Hand { return when (value) { "A", "X" -> Hand.Rock "B", "Y" -> Hand.Paper "C", "Z" -> Hand.Scissor else -> throw Exception("Unsupported value $value") } } fun resultFromValu...
0
Kotlin
0
0
68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7
2,480
aoc-2022-kotlin
Apache License 2.0
src/Day03.kt
devheitt
573,207,407
false
{"Kotlin": 11944}
fun main() { fun getPriority(repeated: Char): Int { //Priorities // a to z = 1 to 26 // A to Z = 27 to 52 val priority = if(repeated.code >= 97) { repeated.code - 96 } else { repeated.code - 64 + 26 } return priority } fun pa...
0
Kotlin
0
0
a9026a0253716d36294709a547eaddffc6387261
1,502
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2020/ex10.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
import java.util.* fun main() { val input = readInputFile("aoc2020/input10") val data = input.lines().map { it.toInt() } val sorted = data.sorted() val withActual = listOf(0) + sorted + (sorted.last() + 3) require(withActual.size == withActual.toSet().size) { "size: $withActual set:${withActual.toS...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
4,128
AOC-2021
MIT License
src/Day05.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { fun part1(input: String): String { val (initialState, steps) = input.split("\n\n") val totalStacks = initialState.lines().last().split(" ").mapNotNull { it.toIntOrNull() }.last() val stacks = (1..totalStacks).associateWith { mutableListOf<Char>() } initialState.lines().f...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
2,151
advent-of-code-kotlin-2022
Apache License 2.0
23.kts
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
import kotlin.math.max class Day23 { val up = Pair(0, -1); val right = Pair(1, 0); val down = Pair(0, 1); val left = Pair(-1, 0) val grid = ArrayList<String>() var width = 0 var processed: BooleanArray = BooleanArray(0) inline fun move(pos: Pair<Int, Int>, dir: Pair<Int, Int>): Pair<Int, Int> = Pa...
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
2,692
aoc2023
MIT License
src/Day02.kt
mpylypovych
572,998,434
false
{"Kotlin": 6455}
fun main() { fun isDraw(a: Char, b: Char) = a - 'A' == b -'X' fun isWin(a: Char, b: Char) : Boolean { val opponent = a - 'A' val my = b - 'X' return (my - opponent == 1) || (my == 0 && opponent == 2) } fun score(a: Char) = a.minus('X') + 1 fun part1(input: List<String>) = in...
0
Kotlin
0
0
733b35c3f4eea777a5f666c804f3c92d0cc9854b
1,124
aoc-2022-in-kotlin
Apache License 2.0
src/chapter5/section1/ex12_Alphabet_MSD.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section1 import chapter2.swap import kotlin.math.min /** * 基于字母表的高位优先字符串排序算法 */ fun alphabetMSDSort(array: Array<String>, alphabet: Alphabet) { val aux = Array(array.size) { "" } alphabetMSDSort(array, alphabet, aux, 0, array.size - 1, 0) } private const val M = 10 private fun alphabetMSD...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,450
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/day23/Day23.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day23 import execute import readAllText fun part1(input: String) = parse(input) .let { elves -> (1..10).fold(elves, ::round) } .let { elves -> val rs = elves.minOf { it.first }..elves.maxOf { it.first } val cs = elves.minOf { it.second }..elves.maxOf { it.second } rs.sumOf { r ...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
2,963
advent-of-code-2022
MIT License
src/Day03.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
fun main() { fun part1(input: List<String>): Int { val pointsByCharacter = generatePointsByCharacterMap() return input.sumOf { val firstCompartment = it.substring(0, it.length / 2).toSet() val secondCompartment = it.substring(it.length / 2, it.length).toSet() val...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
1,178
advent_of_code_2022
Apache License 2.0
src/Day7/Day7.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day7 import readInput class File(val name: String, val size: Int) class Folder(val name: String, val subfolders: MutableList<Folder>, val files: MutableList<File>, val parent: Folder?) { fun folderSize(): Int { var size = files.sumOf { it.size } return size + subfolders.sumOf { it.folderSi...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
2,669
aoc-2022-in-kotlin
Apache License 2.0
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day08.kt
triozer
573,964,813
false
{"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716}
package fr.triozer.aoc.y2022 import fr.triozer.aoc.utils.readInput // #region part1 private fun part1(input: List<String>) = input.indices.sumOf { i -> input[0].indices.count { j -> val left = (j - 1 downTo 0).map { i to it } val right = (j + 1 until input[0].length).map { i to it } val up...
0
Kotlin
0
1
a9f47fa0f749a40e9667295ea8a4023045793ac1
1,394
advent-of-code
Apache License 2.0
src/main/kotlin/com/adventofcode/Day02.kt
keeferrourke
434,321,094
false
{"Kotlin": 15727, "Shell": 1301}
package com.adventofcode /** * [https://adventofcode.com/2021/day/2] */ enum class Command { FORWARD, DOWN, UP; companion object { fun of(string: String) = when (string) { "forward" -> FORWARD "down" -> DOWN "up" -> UP else -> error("Unknown command") } } } private data class ...
0
Kotlin
0
0
44677c6ae0ba1a8a8dc80dfa68c17b9c315af8e2
1,726
aoc2021
ISC License
src/Day05.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
const val Empty = " " data class Instruction(val count: Int, val from: Int, val to: Int) typealias BucketsMap = MutableMap<Int, MutableList<Char>> fun main() { fun parseBuckets(input: List<String>): BucketsMap { val stacks: BucketsMap = mutableMapOf() outer@for (line in input) { ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
2,646
aoc2022
Apache License 2.0
src/Day04.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
fun main() { fun part1(input: List<String>): Int { return input .map { parsePair(it) } .sumOf { checkFullOverlap(it) } } fun part2(input: List<String>): Int { return input .map { pars...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
1,527
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day11SeatingSystem.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode import java.util.* import kotlin.math.max import kotlin.math.min enum class Strategy { Plan, Reality } class Day11SeatingSystem(val strategy: Strategy) { private val empty = 'L' private val occupied = '#' private val floor = '.' private val directions = lis...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
2,927
BrainSqueeze
Apache License 2.0
src/day02/Day02.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day02 import readInput fun main() { fun calculatePart1Score(input: List<String>): Int { return input.toPart1Moves().sumOf { it.points } } fun calculatePart2Score(input: List<String>): Int { val toPart2Moves = input.toPart2Moves() return toPart2Moves.sumOf { it.points } ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
3,306
advent-of-code-22-kotlin
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day8/Day8.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day8 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day8 : Day { override val input = readInputLines(8).map { Line(it) } override fun part1() = input.sumOf { it.countDirectSolution() } override fun part...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,059
aoc2021
MIT License
src/Day14.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.math.max fun main() { fun solve(input: List<String>, withFloor: Boolean): Int { val d = Array(200) { CharArray(1000) { '.' } } var maxY = 0 input.forEach { line -> line.split(" -> ") .map { val (x, y) = it.split(",").map(String::...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
1,762
Advent-of-Code-2022
Apache License 2.0
src/day02/Day02.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day02 import readInputString fun main() { fun part1(input: List<String>): Long { var totalScore = 0L // A(ZXY) B(XYZ) C(YZX) // 036 036 036 val ptMap = mapOf( "A" to mapOf("Z" to 0L, "X" to 3L, "Y" to 6L), "B" to mapOf("X" to 0L, "Y" to 3L, ...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
1,787
Advent-Of-Code-2022
Apache License 2.0
src/day2/Day02.kt
jorgensta
573,824,365
false
{"Kotlin": 31676}
package day2 import readInput fun main() { val rockPoints = 1 val paperPoints = 2 val scissorsPoints = 3 val rules = mapOf( "B" to "A", "C" to "B", "A" to "C" ) val mapshit = mapOf( "X" to "A", "Y" to "B", "Z" to "C" ) val points = ma...
0
Kotlin
0
0
7243e32351a926c3a269f1e37c1689dfaf9484de
2,712
AoC2022
Apache License 2.0
src/day20/Day20.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day20 import readInput fun main() { fun parse(input: List<String>): List<Number> { return input.mapIndexed { i, line -> Number(line.toInt(), i) } } fun arrangeNumbers(numbers: List<Number>): MutableList<Number> { val order = numbers.toMutableList() numbers.forEach {curren...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
2,451
advent-of-code-kotlin-2022
Apache License 2.0
src/Day11.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
fun main() { fun part1(input: List<String>): Long { val monkeys = input.chunked(7).map { it.toMonkey() }.toList() val lcm = monkeys.map { it.divider() }.reduce { acc, value -> acc * value } println(lcm) repeat(10000) { monkeys.forEach { ...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
3,174
aoc-2022
Apache License 2.0
src/main/kotlin/day22/Day22.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day22 import groupByBlanks import runDay import stackOf import toPair import utils.Point import utils.Ring import java.util.function.Predicate fun main() { fun part1(input: List<String>) = input.parse() .let { (grid, instructions) -> val initialX = grid[0].indexOf(MapT...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
14,813
advent-of-code-2022
Apache License 2.0
src/Day02.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { val loss = 0 val draw = 3 val win = 6 val rock = 1 val paper = 2 val scissors = 3 // A for Rock, B for Paper, and C for Scissors // X for Rock, Y for Paper, and Z for Scissors fun part1(input: List<String>): Int { val score = input .map { line -> ...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
2,363
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/days/y2023/day08/Day08.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day08 import java.math.BigInteger import util.InputReader typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day08(val input: PuzzleInput) { val nodes = input.drop(2).toNodes() fun partOne(): Int { val lr = input.first().toLR() var currNode = node...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
3,332
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day08.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.util.function.Predicate fun main() { val testInput = """ 30373 25512 65332 33549 35390 """.trimIndent() .split("\n") val testResult = inputToMatrix(testInput) check(partOne(testResult) == 21) val input = inputToMatrix(readInput("Day08.t...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
4,226
advent-of-code-2022-kotlin
Apache License 2.0
2022/src/main/kotlin/Day24.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day24 { fun part1(input: String): Int { val board = parseInput(input) return 1 + shortestPath(board, Point(0, -1), Point(board.width - 1, board.height - 1), 0) } fun part2(input: String): Int { val board = parseInput(input) val start1 = Point(0, -1) val end1 = Point(board.width - 1, ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
4,274
advent-of-code
MIT License
src/Day13.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
sealed interface Data : Comparable<Data> class IntData(val value: Int) : Data { override fun compareTo(other: Data): Int { return if (other is IntData) { value.compareTo(other.value) } else { -other.compareTo(this) } } override fun toString() = value.toStrin...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
2,722
Advent-of-Code-2022
Apache License 2.0
src/Day05.kt
leeturner
572,659,397
false
{"Kotlin": 13839}
typealias Stack = ArrayDeque<Char> val numbersInInstructionRegex = """\d+""".toRegex() data class Instruction(val num: Int, val from: Int, val to: Int) fun List<String>.parseStacks(): MutableList<Stack> { val numberOfStacks = this.takeWhile { it.trim().isNotEmpty() }.last().last { it.isDigit() }.digitToInt()...
0
Kotlin
0
0
8da94b6a0de98c984b2302b2565e696257fbb464
2,323
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2023/Day12.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 12 -Hot Springs * Problem Description: http://adventofcode.com/2023/day/12 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day12/ */ package com.ginsberg.advent2023 class Day12(private val input: List<String>) { ...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
2,455
advent-2023-kotlin
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2020/d01/Day01.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d01 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines fun findTwoSum(nums: List<Int>, target: Int): Pair<Int, Int>? { nums .groupBy { it } .mapValues { (_, v) -> v.size } .let { countsMap -> counts...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,604
advent-of-code
MIT License
src/Day03.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
fun main() { fun part1(input: List<String>): Int { val pointMap = pointValues() var points = 0 for(line in input) { val h1 = line.substring(0..line.lastIndex/2) val h2 = line.substring(line.lastIndex/2 + 1) val overlap = h1.toCharArray().intersect(h2.toCha...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
1,261
aoc-2022-kotlin
Apache License 2.0
src/Day07.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
fun main() { fun log(message: Any?) { println(message) } class Dir(val name: String, val parent: Dir? = null) { val childDirs: MutableList<Dir> = mutableListOf() var fileSize: Int = 0 val fileSizeRecursive: Int get() = fileSize + childDirs.sumOf { it.fileSizeRecursive } ...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
3,044
aoc2022
Apache License 2.0
src/day08/Day08.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day08 import readInput import kotlin.math.min fun main() { fun part1(grid: List<List<Int>>): Int { val rowSize = grid.size val columnSize = grid[0].size val rowRange = (0 until rowSize) val columnRange = (0 until columnSize) val visibleMap = Array(rowSize) { Boolea...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
3,915
advent-of-code-2022
Apache License 2.0
src/Day15.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
import kotlin.math.abs import kotlin.math.max class Sensor( val location: Pair<Int, Int>, val beacon: Pair<Int, Int> ) { val dist = location between beacon override fun toString(): String { return "location=$location, beacon=$beacon, dist=$dist" } } fun main() { fun parseLine(line: St...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
3,212
advent-of-code-kotlin
Apache License 2.0
src/y2015/Day17.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput import kotlin.math.pow object Day17 { private fun parse(input: List<String>): List<Int> { return input.map { it.toInt() } } fun part1(input: List<String>, total: Int): Int { val parsed = parse(input) val variations = 2.0.pow(parsed.size.toDouble...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,579
advent-of-code
Apache License 2.0
src/Day09.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
import kotlin.math.abs import kotlin.math.sign fun main() { val day = "Day09" fun getNextHead(direction: String, head: Coord): Coord { return when (direction) { "U" -> Coord(head.x, head.y + 1) "D" -> Coord(head.x, head.y - 1) "L" -> Coord(head.x - 1, head.y) ...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
2,994
advent-of-code-2022
Apache License 2.0
src/Day09/Day09.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day09 import kotlin.math.* import readInput class RopeMover(val ropeSize: Int) { var rope = MutableList(ropeSize) { _ -> Pair(0, 0) } var visitedLocations = hashSetOf(Pair(0, 0)) fun processInput(input: List<String>) { for (row in input) { processRow(row) } } ...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
2,729
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day3/Shematic.kt
remhiit
727,182,240
false
{"Kotlin": 12212}
package day3 import java.awt.Point import kotlin.math.sqrt class Shematic(input: List<String>) { val mapSize: Point val numbers: List<Num> val symbols: List<Symbol> init { mapSize = Point(input[0].length, input.size) numbers = input.withIndex().map { findNumbersInRow(it.value, it.inde...
0
Kotlin
0
0
122ee235df1af8e3d0ea193b9a37162271bad7cb
1,939
aoc2023
Creative Commons Zero v1.0 Universal
src/Day16.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.max private const val TIME_LIMIT_1 = 30 private const val TIME_LIMIT_2 = 26 fun main() { val testInput = readInput("Day16_test") val testData: ValvesData = createData(testInput) val testValvesSolution = ValvesSolution(testData) check(testValvesSolution.getMaxPressure() == 1651) ...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,895
AdventOfCode2022
Apache License 2.0
src/main/kotlin/days/Day8.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day8 : Day(8) { private val dirs = sequenceOf(0 to 1, 1 to 0, 0 to -1, -1 to 0) override fun partOne(): Any { val trees = inputList.map { it.map { it.code - '0'.code } } val size = trees.size val visible = Array(size) { Array(size) { false } } for (row in 0 ...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
1,679
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day10.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Int = getInstructions(input).foldIndexed(1 to mutableListOf<Int>()) { index, (x, strengths), (instruction, value) -> if (((index + 1) - 20) % 40 == 0) strengths.add(x * (index + 1)) val x1 = if (instruction == "addx" && value != null) x +...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
1,288
aoc-2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day05/day5.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day05 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val almanac = parseAlmanacV1(inputFile.bufferedReader().readLines()) println("Lowest location is: ${almanac.mapAll(from = "seed", to = "location", items = almanac.s...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
3,919
advent-of-code
MIT License
src/day05/day05.kt
taer
573,051,280
false
{"Kotlin": 26121}
package day05 import readInput import split fun main() { fun parseStacks(stacks: List<String>): List<MutableList<String>> { val simpler = stacks.dropLast(1).map { it.drop(1).mapIndexedNotNull { index, c -> if (index % 4 == 0) c.toString() e...
0
Kotlin
0
0
1bd19df8949d4a56b881af28af21a2b35d800b22
2,727
aoc2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-09.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.filterIn import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2021, "09-input") val...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,146
advent-of-code
MIT License
lib/src/main/kotlin/aoc/day14/Day14.kt
Denaun
636,769,784
false
null
package aoc.day14 import kotlin.math.max import kotlin.math.min fun part1(input: String): Int = simulateCave(parse(input), ::simulateFloorless) fun part2(input: String): Int = simulateCave(parse(input), ::simulateFloorful) fun simulateCave( paths: List<Path>, simulateUnit: (originalMaxY: Int, occupiedPoints...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
2,075
aoc-2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2016/Day11.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day11(private val input: List<String>) { fun solve(): Int { // Parse the input val rgx = Regex("(\\w+(?: generator|-compatible microchip))") val floors = input.map { rgx.findAll(it).map { it.groupValues[1] }.toList() } val start = State(0, fl...
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
5,410
advent-2016
Apache License 2.0
src/Day11.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
fun main() { fun solution(input: List<String>, roundCount: Int, worthLevelUpdate: (Long) -> Long): Long { val monkeyList: List<Monkey> = readMonkeyList(input) val inspectionList = Array(monkeyList.size) { 0 } val divider = monkeyList .map { m -> m.divisionCheckNum } ....
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,386
AdventOfCode2022
Apache License 2.0
src/main/kotlin/io/steinh/aoc/day03/GearRatios.kt
daincredibleholg
726,426,347
false
{"Kotlin": 25396}
package io.steinh.aoc.day03 class GearRatios { fun addUpPartNumbers(lines: List<String>): Int { var result = 0 for (lineIndex in lines.indices) { val line = lines[lineIndex] val numberMatches = "(\\d+)".toRegex().findAll(line) for (numberMatch in numberMatches...
0
Kotlin
0
0
4aa7c684d0e337c257ae55a95b80f1cf388972a9
3,242
AdventOfCode2023
MIT License
2023/src/day15/day15.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day15 import GREEN import RESET import printTimeMillis import readInput private fun hash(str: String): Int { var s = 0 for (c in str) { s = ((s + c.code) * 17) % 256 } return s } fun part1(input: List<String>): Int { return input.first().split(",") .map { hash(it) } ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,125
advent-of-code
Apache License 2.0
src/Day03.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
fun main() { fun part1(input: List<String>): Int = input .asSequence() .map { it.toList() }.map { it.chunked(it.size / 2) }.map { it[0] intersect it[1].toSet() }.onEach { check(it.size == 1) }.map { it.first(...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
1,198
advent-of-code-2022
Apache License 2.0
src/Day11.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
class Day11(input: String) { private val monkeys = input.split("\n\n").map { Monkey.from(it.lines()) } fun solvePart1() = keepAway(rounds = 20, manageWorryLevel = { level, _ -> level / 3 }) fun solvePart2() = keepAway(rounds = 10_000, manageWorryLevel = { level, modulus -> level % modulus }) private ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
2,357
advent22
Apache License 2.0
2022/src/main/kotlin/com/github/akowal/aoc/Day02.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc import com.github.akowal.aoc.Day02.Shape.* class Day02 { private val pairs = inputScanner("day02").let { input -> val result = mutableListOf<Pair<Char, Char>>() while (input.hasNextLine()) { val line = input.nextLine() result += line[0] to line...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
2,261
advent-of-kode
Creative Commons Zero v1.0 Universal
src/main/kotlin/day18/Day18SettlersOfTheNorthPole.kt
Zordid
160,908,640
false
null
package day18 import shared.Coordinate import shared.measureRuntime import shared.readPuzzle import shared.toArea class LumberArea(puzzle: List<String>) { private val initialMap = puzzle.map { it.toList() } private val area = initialMap.toArea() fun solve(minutes: Int, debug: Boolean = false): Int { ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
3,074
adventofcode-kotlin-2018
Apache License 2.0
src/day03/Day03.kt
pnavais
574,712,395
false
{"Kotlin": 54079}
package day03 import readInput fun computePriority(item: Char): Short { var itemId = item.code.toShort() itemId = if (itemId >= 'a'.code.toShort() && itemId <= 'z'.code.toShort()) { itemId.minus('a'.code.toShort() - 1).toShort() } else if (itemId >= 'A'.code.toShort() && itemId <= 'Z'.code.toShort...
0
Kotlin
0
0
ed5f521ef2124f84327d3f6c64fdfa0d35872095
1,804
advent-of-code-2k2
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day02.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day02.solve() } object Day02 : AdventSolution(2023, 2, "Cube Conundrum") { override fun solvePartOne(input: String) = parse(input) .filter { it.draws.all { (r, g, b) -> r <= 12 && g <= 13 && b <= 14 } } .sumOf { it...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,519
advent-of-code
MIT License
src/Day07.kt
BrianEstrada
572,700,177
false
{"Kotlin": 22757}
fun main() { // Test Case val testInput = readInput("Day07_test") val part1TestResult = Day07.part1(testInput) println(part1TestResult) check(part1TestResult == 95437) val part2TestResult = Day07.part2(testInput) println(part2TestResult) check(part2TestResult.second == 24933642) /...
1
Kotlin
0
1
032a4693aff514c9b30e979e63560dc48917411d
4,062
aoc-kotlin-2022
Apache License 2.0
src/year2022/day24/Day24.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day24 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day24_test") check(part1(testInput), 18) check(part2(testInput), 54) val input = readInput("2022", "Day24") println(part1(i...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,740
AdventOfCode
Apache License 2.0
src/Day09.kt
iartemiev
573,038,071
false
{"Kotlin": 21075}
import kotlin.math.abs data class Point(val x: Int, val y: Int) { operator fun minus(point2: Point): Point { return Point(abs(x - point2.x), abs(y - point2.y)) } } class Bridge(private val tailLength: Int = 1) { private val knotPositions: MutableList<Point> = MutableList(tailLength + 1) { Point(0, 0) } pr...
0
Kotlin
0
0
8d2b7a974c2736903a9def65282be91fbb104ffd
2,305
advent-of-code
Apache License 2.0
src/Day01.kt
peterfortuin
573,120,586
false
{"Kotlin": 22151}
fun main() { fun part1(input: List<String>): Int { val elfs = input.asElfs() val caloriesPerElf = elfs.map { elfCaloriesList -> elfCaloriesList.map { calories -> calories.toInt() }.toIntArray().sum() } val highestCaloryElf = caloriesPerElf.fol...
0
Kotlin
0
0
c92a8260e0b124e4da55ac6622d4fe80138c5e64
1,629
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode/year2020/Day16TicketTranslation.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.product class Day16TicketTranslation(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val ticketRules by lazy { input .split("\n\n") .first() ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,186
AdventOfCode
MIT License