path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/Day04.kt
ajmfulcher
573,611,837
false
{"Kotlin": 24722}
fun main() { fun parse(line: String): List<List<Int>> = line .split(",") .map { it.split("-").map { it.toInt() } } fun fullyContains(pair1: List<Int>, pair2: List<Int>): Boolean { if (pair1[0] == pair2[0] || pair1[1] == pair2[1]) return true if (pair1[0] > pair2[0]) return full...
0
Kotlin
0
0
981f6014b09e347241e64ba85e0c2c96de78ef8a
1,325
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/solutions/Day11MonkeyInTheMiddle.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Input import utils.Maths import utils.Solution // run only this day fun main() { Day11MonkeyInTheMiddle() } class Day11MonkeyInTheMiddle : Solution() { init { begin("Day 11 - Monkey in the Middle") val input = Input.parseLines(filename = "/d11_monkey_decisions....
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
2,951
advent-of-code-2022
MIT License
src/day13/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day13 import println import readInput fun main() { class Block(block: List<String>) { val width = block[0].length val height = block.size var map = block.map { it.toCharArray() } var smudgePoint: Pair<Int, Int> = Pair(0, 0) var withSmudgePoint = false var O...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
3,534
advent-of-code-2023
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2017/Day21.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Point import com.nibado.projects.advent.resourceLines object Day21 : Day { private val input = resourceLines(2017, 21).map { it.split(" => ") }.map { Square(it[0].split("/")) to Square(it[1].split("/")...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,903
adventofcode
MIT License
src/y2021/d04/Day04.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2021.d03 import println import readInput fun main() { val classPath = "y2021/d04" class Board { private var board: Array<IntArray> private var marked: Array<BooleanArray> constructor(input: List<String>) { val board = Array(5) { IntArray(5) } input ...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
3,153
aoc
Apache License 2.0
src/day20/d20_1.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val k = input.toInt() / 10 // sieve[i] == 0 iff i is prime // == k iff k is a prime divisor of i val sieve = sieve(k) val memo = Array<Map<Int, Int>?>(sieve.size) { null } for (i in 2 until sieve.size) { val s = sigma1(i, sieve, memo) if (s >= k) { printl...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,173
aoc2015
MIT License
src/Day02.kt
BenD10
572,786,132
false
{"Kotlin": 6791}
val matrix = mapOf( Move.ROCK to mapOf( Move.SCISSORS to Move.LOSE, Move.ROCK to Move.DRAW, Move.PAPER to Move.WIN, ), Move.PAPER to mapOf( Move.ROCK to Move.LOSE, Move.PAPER to Move.DRAW, Move.SCISSORS to Move.WIN, ), Move.SCISSORS to mapOf( ...
0
Kotlin
0
0
e26cd35ef64fcedc4c6e40b97a63d7c1332bb61f
2,122
advent-of-code
Apache License 2.0
codeforces/kotlinheroes4/i.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes4 fun main() { val (n, m, _, sIn) = readInts() val s = sIn - 1 val a = readInts() val inf = n * n * n val e = List(n) { IntArray(n) { inf } } repeat(m) { val (u, v) = readInts().map { it - 1 } e[u][v] = 1 } for (k in e.indices) for (i in e.indices) for (j in e.indices) e[i][...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,675
competitions
The Unlicense
src/aoc2022/day02/Day02.kt
svilen-ivanov
572,637,864
false
{"Kotlin": 53827}
package aoc2022.day02 import aoc2022.day02.Outcome.* import readInput enum class RockPaperScissors( val otherSymbol: String, val mySymbol: String, val myScore: Int, val order: Int, ) { ROCK("A", "X", 1, 1), SCISSORS("C", "Z", 3, 2), PAPER("B", "Y", 2, 3), } enum class Outcome(val symbol: ...
0
Kotlin
0
0
456bedb4d1082890d78490d3b730b2bb45913fe9
3,081
aoc-2022
Apache License 2.0
src/adventofcode/day02/Day02.kt
bstoney
574,187,310
false
{"Kotlin": 27851}
package adventofcode.day02 import adventofcode.AdventOfCodeSolution fun main() { Solution.solve() } object Solution : AdventOfCodeSolution<Int>() { override fun solve() { solve(2, 15, 12) } override fun part1(input: List<String>): Int { return getRounds(input) { _: Play, playerInput:...
0
Kotlin
0
0
81ac98b533f5057fdf59f08940add73c8d5df190
2,765
fantastic-chainsaw
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2022/Day16.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 16 - Proboscidea Volcanium * Problem Description: http://adventofcode.com/2022/day/16 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day16/ */ package com.ginsberg.advent2022 import com.github.shiguruikai.combinatori...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
3,433
advent-2022-kotlin
Apache License 2.0
src/Day15.kt
palex65
572,937,600
false
{"Kotlin": 68582}
@file:Suppress("PackageDirectoryMismatch") package day15 import readInput import kotlin.math.* data class Pos(val x:Int, val y: Int) fun Pos.distance(p: Pos) = abs(p.x-x)+abs(p.y-y) data class Sensor(val pos: Pos, val beacon: Pos){ val range = pos.distance(beacon) val minX get() = pos.x - range val maxX ...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
2,962
aoc2022
Apache License 2.0
src/main/kotlin/aoc2022/Day16.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import aoc2022.utils.MazeToTarget import java.lang.Integer.min val parseValve = "Valve (\\S+) has flow rate=(\\d+); tunnels? leads? to valves? (.*)".toRegex() data class LocationAndBusy(val valve: Valve, val time: Int) data class Valve(val id: String, val rate: Int, val link...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
5,320
aoc-2022-kotlin
Apache License 2.0
src/day11/Day11_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day11 import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private class MonkeyV2( val items: Muta...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,721
aoc2022
Apache License 2.0
src/main/kotlin/day8.kt
nerok
436,232,451
false
{"Kotlin": 32118}
import java.io.File import java.util.* fun main(args: Array<String>) { day8part2() } fun day8part1() { val countArray = IntArray(8) { 0 } val input = File("day8input.txt").bufferedReader().readLines() input.map { line -> line.split(" | ").map { it.split(" ") }.let { it.first() to it.last() } ...
0
Kotlin
0
0
4dee925c0f003fdeca6c6f17c9875dbc42106e1b
2,350
Advent-of-code-2021
MIT License
advent-of-code-2022/src/Day18.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { val testInput = readInput("Day18_test") val input = readInput("Day18") "Part 1" { part1(testInput) shouldBe 64 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 58 measureAnswer { part2(input) } } } private val directions = list...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,212
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day8.kt
C06A
435,034,782
false
{"Kotlin": 20662}
package days class Day8 : Day(8) { override fun partOne(): Any { return inputList.map { it.split("|")[1] }.map { it.split(Regex("\\W")) }.flatten( ).filter { it.trim().length in setOf(2, 3, 4, 7) }.count() } override fun partTwo(...
0
Kotlin
0
0
afbe60427eddd2b6814815bf7937a67c20515642
3,037
Aoc2021
Creative Commons Zero v1.0 Universal
src/Day02.kt
oleksandrbalan
572,863,834
false
{"Kotlin": 27338}
fun main() { val input = readInput("Day02") .map { val options = it.split(" ") options[0] to options[1] } val roundsPart1 = input .map { (first, second) -> Round( your = Option.from(second), opponent = Option.from(first...
0
Kotlin
0
2
1493b9752ea4e3db8164edc2dc899f73146eeb50
2,275
advent-of-code-2022
Apache License 2.0
src/Day21/Day21.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day21 import readInput import java.math.BigInteger data class Node(val id: String, val nodeType: NodeType) { enum class NodeType { LEAF, BRANCH } var leafValue: BigInteger = BigInteger.ZERO var nodeChildren: Pair<Node, Node>? = null var nodeChildrenIds: Pair<String, String>? = null var ope...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
3,919
advent-of-code-2022
Apache License 2.0
src/Day15.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { fun parseInput(input: List<String>, lineNumber: Int): HashMap<Pair<Int, Int>, String> { val map = HashMap<Pair<Int, Int>, String>() for (line in input) { val coordinates = line.replace("Sensor at", "") ...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
2,291
advent-of-code-2022
Apache License 2.0
src/commonMain/kotlin/advent2020/day24/Day24Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day24 enum class Vector(val dx: Int, val dy: Int) { E(2, 0), W(-2, 0), SE(1, 1), SW(-1, 1), NE(1, -1), NW(-1, -1), } data class Position(val x: Int, val y: Int) { operator fun plus(v: Vector) = Position(x + v.dx, y + v.dy) override fun toString() = "($x,$y)" } fun...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
1,729
advent-of-code-2020
MIT License
src/main/kotlin/days/Day5.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DayInput class Day5 : Day("5") { class Range(val start: Long, val length: Long) { val end = start + length - 1 fun validValue(value: Long): Boolean { return start <= value && value - start <= length - 1 } fun intersect(otherRange: Range): Ran...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
4,723
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc/Day07.kt
fluxxion82
573,716,300
false
{"Kotlin": 39632}
package aoc import java.io.File data class ElfFile(val name: String, val size: Long) class Node( val file: ElfFile, val parent: Node?, val children: MutableList<Node> = mutableListOf() ) { val totalSize: Long = file.size + children.sumOf { it.totalSize } } fun parseTerminal(input: String, root: Node...
0
Kotlin
0
0
3920d2c3adfa83c1549a9137ffea477a9734a467
2,548
advent-of-code-kotlin-22
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day03/RucksackReorganization.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day03 import com.barneyb.aoc.util.Solver fun main() { Solver.execute( ::parse, ::partOne, ::partTwo, ) } internal data class Rucksack( val left: Set<Int>, val right: Set<Int>, ) { val intersection = left.intersect(right).first() fun con...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
1,596
aoc-2022
MIT License
src/main/kotlin/Day2.kt
ryanclanigan
440,047,375
false
{"Kotlin": 8400}
import java.io.File enum class Direction { UP, DOWN, FORWARD } class SubmarineCommand(val direction: Direction, val magnitude: Int) fun parseSubmarineCommand(command: String): SubmarineCommand { val pieces = command.split(" ") if (pieces.size != 2) throw Exception("Ruh roh") return SubmarineC...
0
Kotlin
0
0
766fa81b4085a79feb98cef840ac9f4361d43e73
2,976
AdventOfCode2021
MIT License
program/program/find-the-adjoint-of-a-matrix/FindTheAdjointOfAMatrix.kt
codinasion
646,154,989
false
{"TypeScript": 1253398, "JavaScript": 300972, "Java": 117345, "C#": 113493, "C": 108834, "C++": 108619, "Go": 71308, "Kotlin": 67478, "Python": 61284, "PHP": 60087, "Rust": 55932, "Swift": 49088, "Scala": 43272, "Ruby": 42267, "Dart": 41951, "R": 37264, "Perl": 33321, "Julia": 29785, "F#": 25527, "Haskell": 22115, "She...
fun main() { val matrixA = listOf( listOf(1, 2, 3), listOf(4, 5, 6), listOf(7, 8, 9) ) val matrixAdjoint = calculateAdjoint(matrixA) println("Input (A): $matrixA") println("Matrix of Adjoint (A*): $matrixAdjoint") } fun calculateAdjoint(matrix: List<List<Int>>): List<List<...
951
TypeScript
141
45
98267f35088871b601c609ce125f08a49c543adc
1,728
codinasion
MIT License
kotlin/src/main/kotlin/AoC_Day7.kt
sviams
115,921,582
false
null
object AoC_Day7 { data class TreeNode(val name: String, val weight: Int, val totalWeight: Int, val children: List<String>) private fun parseUnweighted(input: List<String>) : List<TreeNode> = input.map { val split = it.split(" ") TreeNode(split[0], split[1].substring(1, split[1...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
1,904
aoc17
MIT License
src/Day03.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
import java.lang.IllegalArgumentException fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day03_test") check(part1(testInput) == 157) check(part2(testInput) == 70) val input = readInput("Day03") println(part1(input)) println(part...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
1,390
aoc-2022
Apache License 2.0
src/day22/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day22 import assert import println import readInput import java.util.* data class Brick(val index: Int, var x: IntRange, var y: IntRange, var z: IntRange) { val top by lazy { copy(z = z.last..z.last) } val bottom by lazy { copy(z = z.first..z.first) } val holding = mutableListOf<Brick>() val s...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
3,194
advent-of-code-2023
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day11.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 11: Monkey in the Middle * Problem Description: https://adventofcode.com/2022/day/11 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsText import de.niemeyer.aoc.utils.getClassName import de.niemeyer.aoc.utils.product fun main() { fun solve(input: ...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
3,475
AoC-2022
Apache License 2.0
src/main/kotlin/Day21.kt
clechasseur
318,029,920
false
null
import org.clechasseur.adventofcode2020.Day21Data object Day21 { private val input = Day21Data.input private val foodRegex = """^([a-z]+(?: [a-z]+)*) \(contains ([a-z]+(?:, [a-z]+)*)\)$""".toRegex() fun part1(): Int { val allFood = input.lines().map { it.toFood() } val allergenMap = build...
0
Kotlin
0
0
6173c9da58e3118803ff6ec5b1f1fc1c134516cb
1,929
adventofcode2020
MIT License
src/main/kotlin/aoc2023/Day07.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day07 { fun part1(input: List<String>): Long { val sortedCards = input.map { parseCameCard(it, isJokerRule = false) }.sorted() return IntRange(1, sortedCards.size).zip(sortedCards).sumOf { (rank, card) -> rank * card.bid * 1L } } fun part2(input: List<String>): Long {...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
4,542
advent-of-code-2023
MIT License
src/y2021/Day13.kt
Yg0R2
433,731,745
false
null
package y2021 fun main() { fun part1(input: List<String>): Int { // y (column) to x (row) val coordinates: List<Pair<Int, Int>> = input.getCoordinates() // y => horizontal (row) // x => vertical (column) val folds: List<Pair<String, Int>> = input.getFoldAlongs() re...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
3,206
advent-of-code
Apache License 2.0
src/Day09.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
import kotlin.math.abs import kotlin.math.sqrt import kotlin.math.pow fun main() { fun euclidienne(xH: Int, yH: Int, xT: Int, yT: Int): Float { return sqrt((xH - xT).toFloat().pow(2) + (yH - yT).toFloat().pow(2)) } fun solution(input: List<String>, nombreDeNoeuds: Int): Int { val liste = ...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
2,277
AD2022-01
Apache License 2.0
src/Day17.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
fun main() { data class Point(var x: Int, var y: Int) class Rock(val lines: List<String>) { val width = lines[0].length val height = lines.size fun canPush(field: Array<CharArray>, pos: Point, moveX: Int) = !willIntersect(field, pos, moveX, 0) fun canFall(field: Array<CharArra...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
3,682
Advent-of-Code-2022
Apache License 2.0
src/day17/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day17 import Coord import day06.main import readInput import java.util.* fun main() { fun Set<Coord>.moveRight() = buildSet { this@moveRight.forEach { add(it.copy(first = it.first + 1)) } } fun Set<Coord>.moveLeft() = buildSet { this@moveLeft.forEach { add(it.copy(first = it.first - 1)) } } fun Se...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
3,046
AOC2022
Apache License 2.0
src/main/kotlin/day12/CaveExpedition.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day12 import utils.read fun main() { solve() .let { println(it) } } data class Cave(var accessTo: MutableList<Cave>, val name: String) { fun isSmall(): Boolean { if(isEnd() || isStart()) return false; return """[a-z]*""".toRegex().matches(name) } private ...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
2,570
adventOfCode2021
Apache License 2.0
src/main/kotlin/day4.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
private val testInput1 = """ 7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 22 13 17 11 0 8 2 23 4 24 21 9 14 16 7 6 10 3 18 5 1 12 20 15 19 3 15 0 2 22 9 18 13 17 5 19 8 7 25 23 20 11 10 24 4 14 21 16 12 6 14 21 17 24 4 10 16 15 9 19 18 8 23 26 20 22 11 13 6 5 2 ...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
3,984
AOC-2021
MIT License
src/main/kotlin/solutions/day14/Day14.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day14 import solutions.Solver import utils.Coordinate import utils.Direction import utils.step import java.lang.Integer.max import java.lang.Integer.min enum class CaveState { SAND, AIR, ROCK; override fun toString(): String { return when (this) { SAND -> "o" ...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
2,755
Advent-of-Code-2022
MIT License
2021/src/main/kotlin/day20_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.MutableIntGrid import utils.Parser import utils.Solution fun main() { Day20Fast.run() } object Day20All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day20Func, "fast" to Day20Fast).forEach { (header, solution) -> solution.run(header = header, skipPart1 =...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,553
aoc_kotlin
MIT License
src/day13/Day13.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day13 import readInput const val day = "13" fun main() { fun calculatePart1Score(input: List<String>): Int { val packetGroups = input .map { it.parsePackets() } .windowed(2, step = 3) val valid = packetGroups .map { (left, right) -> left.isValid(righ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
4,571
advent-of-code-22-kotlin
Apache License 2.0
2019/src/main/kotlin/day3.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Segment import utils.Solution import utils.Vec2i import utils.mapItems import utils.times private typealias D3Input = Pair<List<Vec2i>, List<Vec2i>> fun main() { Day3.run(skipTest = false) } object Day3 : Solution<D3Input>() { override val name = "day3" override val parser = Pa...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,945
aoc_kotlin
MIT License
src/day08/Day08.kt
jacobprudhomme
573,057,457
false
{"Kotlin": 29699}
import java.io.File class Matrix<T>(private val mtx: List<List<T>>) { fun dimensions(): Pair<Int, Int> = Pair(mtx.size, mtx[0].size) fun getRow(rowIdx: Int): List<T> = mtx[rowIdx] fun getColumn(colIdx: Int): List<T> = mtx.map { row -> row[colIdx] } fun forEachIndexed(f: (rowIndex: Int, columnIndex: ...
0
Kotlin
0
1
9c2b080aea8b069d2796d58bcfc90ce4651c215b
3,786
advent-of-code-2022
Apache License 2.0
src/day13/Day13.kt
iulianpopescu
572,832,973
false
{"Kotlin": 30777}
package day13 import readFile private const val DAY = "13" private const val DAY_TEST = "day${DAY}/Day${DAY}_test" private const val DAY_INPUT = "day${DAY}/Day${DAY}" fun main() { fun parseInput(input: String): List<Pair<Node, Node>> { val lists = input.split("\n\n") val pairs = lists.map { ...
0
Kotlin
0
0
4ff5afb730d8bc074eb57650521a03961f86bc95
3,147
AOC2022
Apache License 2.0
src/Day02.kt
ghasemdev
572,632,405
false
{"Kotlin": 7010}
import RoundAction.* private enum class Action(private val score: Int) { Rock(1), Paper(2), Scissors(3); infix fun compare(action: Action): Int = when { this == action -> Draw.score this == Rock && action == Scissors -> Win.score this == Scissors && action == Paper -> Win.score ...
0
Kotlin
0
1
7aa5e7824c0d2cf2dad94ed8832a6b9e4d36c446
2,446
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
sms-system
572,903,655
false
{"Kotlin": 4632}
typealias Moves = List<Pair<Int, Int>> fun Moves.calculateScore(): Int = fold(0) { acc, move -> var roundResult = if (move.first == move.second) { 1 } else { if (move.second > move.first) { 2 } else { 0 } } if (move.first == 1 && move.second == 3) { roundResult = 0 } else if (move.first == ...
0
Kotlin
0
0
266dd4e52f3b01912fbe2aa23d1ee70d1292827d
1,432
adventofcode-2022-kotlin
Apache License 2.0
src/Day12.kt
davedupplaw
573,042,501
false
{"Kotlin": 29190}
fun main() { fun bestSteps(map: List<List<Int>>, x: Int, y: Int, current: Int): List<Pair<Int, Int>> { val output = mutableListOf<Pair<Int, Int>>() val allowedStep = listOf(current, current + 1, 'E'.code) if (x > 0 && y > 0 && map[y - 1][x - 1] in allowedStep) { output.add(Pair(...
0
Kotlin
0
0
3b3efb1fb45bd7311565bcb284614e2604b75794
3,015
advent-of-code-2022
Apache License 2.0
src/Day05.kt
aamielsan
572,653,361
false
{"Kotlin": 9363}
fun main() { fun part1(input: String): String { val (crateInput, instructionInput) = input.split("\n\n") val crates = crateInput.toCrates() instructionInput .toInstructions() .forEach { (count, from, to) -> val boxes = crates[from].takeLast(count).rev...
0
Kotlin
0
0
9a522271bedb77496e572f5166c1884253cb635b
2,133
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
fun main() { val directions = listOf( -1 to 0, 1 to 0, 0 to -1, 0 to 1 ) fun part1(input: List<String>): Int { var start: GraphNode? = null var end: GraphNode? = null // graph weights val heights = buildList { for (y in input.indic...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
4,047
advent-of-code-2022
Apache License 2.0
src/day4/Day04.kt
Johnett
572,834,907
false
{"Kotlin": 9781}
package day4 import readInput fun main() { fun getSectionRangePair(assignments: String): Pair<IntRange, IntRange> { fun getRange(values: Pair<Int, Int>): IntRange = values.first..values.second val sectionRanges = assignments.split(",").map { sections -> sections.split("-").let { secti...
0
Kotlin
0
1
c8b0ac2184bdad65db7d2f185806b9bb2071f159
1,713
AOC-2022-in-Kotlin
Apache License 2.0
src/Day14.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
import kotlin.math.max import kotlin.math.min private class Solution14(input: List<String>) { val paths = input.map { line -> line.split(" -> ").map { c -> c.split(",").map { it.toInt() } } } val maxY = paths.flatten().maxOf { it[1] } var initialCave = paths.flatMap { path -> (1 until path.size)...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
2,916
aoc-2022
Apache License 2.0
src/year2022/day12/Day12.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day12 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { infix fun List<CharArray>.findMatching(toSearch: Char): Set<Pair<Int, Int>> { val ret = mutableSetOf<Pair<Int, Int>>() for (i in this.indices) for (j in this[0].indices) ...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
2,897
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2023/Day03.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2023 import net.voldrich.BaseDay // https://adventofcode.com/2023/day/3 fun main() { Day03().run() } class Day03 : BaseDay() { val numberPattern = "\\d+".toRegex() val specialCharPattern = "[^.\\d]".toRegex() data class Line(val index: Int, val numbers: List<LineNum>, val sp...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
2,384
advent-of-code
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day20/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day20 import com.kingsleyadio.adventofcode.util.readInput fun solution(input: List<BooleanArray>, algorithm: String, sampleSize: Int): Int { fun enhance(image: List<BooleanArray>, infinityPixel: Boolean): Pair<List<BooleanArray>, Boolean> { val enhanced = List(i...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,329
adventofcode
Apache License 2.0
src/Day05.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
fun main() { fun prepareConfiguration(input: List<String>): MutableList<ArrayDeque<String>> { val stacks = input .first { it.contains("1") } .split(" ") .map { it.trim() } .map { ArrayDeque<String>() } .toMutableList() input ...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
2,742
aoc-2022
Apache License 2.0
src/Day03.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
private fun priority(c: Char): Int { if (c in 'a'..'z') return c - 'a' + 1 check(c in 'A'..'Z') return c - 'A' + 27 } private fun part1(input: List<String>) = input.sumOf { line -> val m = line.length / 2 val (left, right) = line.take(m).toSet() to line.drop(m).toSet() val intersect = left.inte...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
836
AOC2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day03/Day03.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day03 import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource data class Result(val a: String, val b: String) { val product by lazy { a.toLong(2) * b.toLong(2) } } fun main() { val input = readResource("Day...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,946
advent-of-code
MIT License
src/Day07.kt
A55enz10
573,364,112
false
{"Kotlin": 15119}
fun main() { fun part1(input: List<String>): Int { return getFilesystem(input).directoryList.filter { it.getSize() <= 100000 }.sumOf { it.getSize() } } fun part2(input: List<String>): Int { val memToFree = getFilesystem(input).fileList.sumOf { it.getSize() } - 40000000 return getFi...
0
Kotlin
0
1
8627efc194d281a0e9c328eb6e0b5f401b759c6c
2,942
advent-of-code-2022
Apache License 2.0
src/day02/Day02.kt
ankushg
573,188,873
false
{"Kotlin": 7320}
object Day02 : Solution<Int>( dayNumber = "02", part1ExpectedAnswer = 15, part2ExpectedAnswer = 12 ) { // region helpers private fun <T> List<T>.asPair(): Pair<T, T> = this[0]!! to this[1]!! private fun scorePair(pair: Pair<Shape, Shape>): Int { return pair.second.score + determineResul...
0
Kotlin
0
0
b4c93b6f12f5677173cb9bacfe5aa4ce4afa5667
3,058
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/y2023/day13_a/Day13.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day13_a import util.InputReader import util.timeIt import kotlin.math.pow class Day13(val input: String) { private val grids = input.split("\n\n").map { it.lines() } fun partOne(): Int { return grids.sumOf { grid -> grid.findMirror()?.let { it * 100 } ?...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,934
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day02.kt
Teg79
573,881,244
false
{"Kotlin": 4306}
import Outcome.* import Shape.* enum class Shape(private val beats: String, val points: Int) { ROCK("C", 1), PAPER("A", 2), SCISSORS("B", 3); fun beats() = convertShape(beats) } fun convertShape(code: String) = when (code) { "A", "X" -> ROCK "B", "Y" -> PAPER "C", "Z" -> S...
0
Kotlin
0
0
735ed402e8dbee2011d75c71545c14589c0aabb4
1,923
aoc-2022
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day11.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import adventofcode.util.vector.mooreDelta import adventofcode.util.vector.mooreNeighbors fun main() = Day11.solve() object Day11 : AdventSolution(2020, 11, "Seating System") { override fun solvePartOne(input: ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,666
advent-of-code
MIT License
src/Day04.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
fun main() { class Board( val numbers: List<IntArray> ) { val marked = Array(numbers.size) { BooleanArray(numbers[0].size) } fun mark(n: Int) { for ((rowIndex, row) in numbers.withIndex()) { for ((columnIndex, x) in row.withIndex()) { if ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
2,707
AdventOfCode2021
Apache License 2.0
src/Day15.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
import kotlin.math.abs import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min private const val ROW = 2_000_000 private const val TUNING_FREQUENCY_MULTIPLIER = 4_000_000 fun solveDay15() { val lines = readInput("Day15") solve(lines) } var minX = 0 var minY = 0 var maxX = 0 var maxY = 0...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
2,589
AoC-2022
Apache License 2.0
2018/kotlin/day24p2/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import kotlin.math.max import kotlin.system.measureTimeMillis fun main(args: Array<String>) { val ms = measureTimeMillis { val classLoader = UnitGroup::class.java.classLoader val input = classLoader.getResource("input.txt").readText() val armies = parseArmies(input) println(fightUnt...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
5,508
adventofcode
MIT License
app/src/main/kotlin/day13/Day13.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day13 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 13 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay13Part1, ::solveDay13Part2) } fun solveDay13Part1(input: List<String>): Int {...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
2,849
advent-of-code-kt
Apache License 2.0
src/main/kotlin/day08/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day08 import java.io.File import java.util.* fun main() { val lines = File("src/main/kotlin/day08/input.txt").readLines() val signalToOutputList = lines.map { line -> line.substringBefore(" | ").split(" ").map { it.toSortedSet() } to line.substringAfter(" | ").split(" ") ....
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
2,819
aoc-2021
MIT License
src/Day04.kt
mddanishansari
576,622,315
false
{"Kotlin": 11861}
fun main() { fun IntRange.contains(other: IntRange): Boolean { return contains(other.max()) && contains(other.min()) } fun IntRange.doesOverlap(other: IntRange): Boolean { return contains(other.max()) || contains(other.min()) } fun List<String>.pairOfRange(): List<Pair<IntRange, I...
0
Kotlin
0
0
e032e14b57f5e6c2321e2b02b2e09d256a27b2e2
1,657
advent-of-code-2022
Apache License 2.0
src/Day05.kt
freszu
573,122,040
false
{"Kotlin": 32507}
/** * For [A,B,C,D,E,F] updated list [D,E,F] and returned list [A,B,C] */ private fun <T> MutableList<T>.removeFirst(count: Int) = List(count) { removeAt(0) } private data class CraneMove(val count: Int, val from: Int, val to: Int) private fun parse(input: String): Pair<List<ArrayDeque<Char>>, List<CraneMove>> { ...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
2,285
aoc2022
Apache License 2.0
src/Day08.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
import kotlin.math.max fun main() { fun List<String>.toGrid(): List<List<Int>> = map { row -> row.map { it.digitToInt() } } fun List<List<Int>>.dimensions() = Pair(size, first().size) fun List<List<Int>>.columns(): List<List<Int>> { val (_, columns) = dimensions() val response = (1..columns...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
2,860
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/day13/ShuttleSearch.kt
Pkshields
318,658,287
false
null
package dev.paulshields.aoc.day13 import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 13: Shuttle Search ** \n") val fileInput = readFileAsStringList("/day13/BusTimes.txt") val leavingAirportTime = fileInput[0].toInt() val busIds = fileInput[1] .split(",") ...
0
Kotlin
0
0
a7bd42ee17fed44766cfdeb04d41459becd95803
1,981
AdventOfCode2020
MIT License
2022/kotlin/src/Day02.kt
tomek0123456789
573,389,936
false
{"Kotlin": 5085}
fun main() { fun part1(input: List<String>): Int { val scoreMap = mapOf("A" to mapOf("X" to 3, "Y" to 6, "Z" to 0), "B" to mapOf("X" to 0, "Y" to 3, "Z" to 6), "C" to mapOf("X" to 6, "Y" to 0, "Z" to 3)) val choiceMap = mapOf("X" to 1, "Y" to 2, "Z" to...
0
Kotlin
0
0
5ee55448242ec79475057f43d34f19ae05933eba
1,328
aoc
Apache License 2.0
src/day11/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day11 import println import readInput fun main() { class Galaxy(val id: Int, val x: Int, val y: Int) class GalaxyGame() { lateinit var galaxies: List<Galaxy> val GALAXY = '#' constructor(input: List<String>, emptySpaceMultiplier: Int = 2) : this() { this.galaxies = ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
2,760
advent-of-code-2023
Apache License 2.0
day03/src/main/kotlin/Main.kt
rstockbridge
225,212,001
false
null
fun main() { val inputAsLines = resourceFile("input.txt") .readLines() val wire1 = parseInput(inputAsLines[0]) val wire2 = parseInput(inputAsLines[1]) println("Part I: the solution is ${solvePartI(wire1, wire2)}.") println("Part II: the solution is ${solvePartII(wire1, wire2)}.") } fun p...
0
Kotlin
0
0
bcd6daf81787ed9a1d90afaa9646b1c513505d75
2,678
AdventOfCode2019
MIT License
src/day22/Day22.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day22 import java.io.File import kotlin.reflect.KFunction3 fun main() { val input = File("src/day22/input.txt").readText().split("\n\n") val tiles = mutableSetOf<Pair<Int, Int>>() val walls = mutableSetOf<Pair<Int, Int>>() input[0].split("\n").forEachIndexed { row, s -> s.toList().forE...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
5,790
advent-of-code-2022
MIT License
src/main/kotlin/aoc2021/day9/SmokeBasin.kt
arnab
75,525,311
false
null
package aoc2021.day9 import java.util.LinkedList object SmokeBasin { data class Loc(val x: Int, val y: Int) fun parse(data: String) = data.split("\n") .foldIndexed(mutableMapOf()) { row, heights: MutableMap<Loc, Int>, line -> line.split("").filter { it.isNotBlank() } .foldIndexed(heights...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,120
adventofcode
MIT License
src/Day13.kt
Shykial
572,927,053
false
{"Kotlin": 29698}
fun main() { fun part1(input: List<String>) = input .chunkedBy { it.isBlank() } .map { (first, second) -> DataPacketPair( parsePacketLine(first), parsePacketLine(second) ) }.foldIndexed(0) { index, acc, (first, second) -> if...
0
Kotlin
0
0
afa053c1753a58e2437f3fb019ad3532cb83b92e
3,580
advent-of-code-2022
Apache License 2.0
src/Day2.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<Game> = input.map { Game(Move.parse(it[0]), Move.parse(it[2])) } fun part1(input: List<String>): Int { val games = parse(input) return games.sumOf { it.score() } } fun part2(input: List<String>): Int { val games = pa...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
2,056
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc/year2021/Day03.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2021 import aoc.Puzzle import aoc.year2021.Day03.Criteria.LEAST_COMMON import aoc.year2021.Day03.Criteria.MOST_COMMON /** * [Day 3 - Advent of Code 2021](https://adventofcode.com/2021/day/3) */ object Day03 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { val lines = ...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
2,034
advent-of-code
Apache License 2.0
src/Day13.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
import Packet.PacketInteger import Packet.PacketList sealed class Packet : Comparable<Packet> { data class PacketList(val value: List<Packet>) : Packet() { override fun compareTo(other: Packet): Int = when (other) { is PacketInteger -> compareTo(PacketList(listOf(other))) is PacketL...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
2,905
aoc-2022
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day10.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 fun main() { fun List<String>.toInstructionValuePairs() = asSequence() .map { it.split(" ") } .map { (it[0] to it.getOrNull(1)?.run { toInt() }) } .map { if (it.first == "addx") listOf(it, "noop" to null) else listOf(it) } .flatten() ...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
1,974
advent-of-code
Apache License 2.0
src/Day18.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
fun main() { val testInput = readInput("Day18_test") .map(String::toCoordinates) val input = readInput("Day18") .map(String::toCoordinates) part1(testInput).also { println("Part 1, test input: $it") check(it == 64) } part1(input).also { println("Part 1, real...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
3,003
aoc22-kotlin
Apache License 2.0
src/Day02.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
fun main() { fun getScoreOfSelection(selection: String): Int { return when(selection) { "X" -> 1 "Y" -> 2 "Z" -> 3 else -> 0 } } fun getScore(choices: String): Int { // A - Rock, B - Paper, C - Scissors // X - Rock, Y - Paper...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
2,250
aoc-2022
Apache License 2.0
src/Day04.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { val f = readInput("Day04") fun parseLine(line: String): List<IntRange> { return line.split(',') .map { it.split('-').map { it.toInt() }.let { (x, y) -> x..y } } } fun part1(input: List<String>): Int { return input .map(::parseLine) .coun...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
1,206
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/_2021/Day5.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2021 import aoc import parseInput import range import java.util.regex.Pattern private val REGEX = Pattern.compile("(\\d+),(\\d+) -> (\\d+),(\\d+)") fun main() { aoc(2021, 5) { aocRun { countOverlappingPoints(it, true) } aocRun { countOverlappingPoints(it, false) } } } private fun parseLines...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
1,891
AdventOfCode
Creative Commons Zero v1.0 Universal
src/day04/Day04.kt
mherda64
512,106,270
false
{"Kotlin": 10058}
package day04 import readInput fun main() { fun processInput(input: List<String>): Pair<List<Int>, List<BingoBoard>> { val draws = input.first().split(",").map { it.toInt() } val boards = input.drop(1).chunked(6).map { board -> board.filter { it.isNotBlank() }.map { line -> ...
0
Kotlin
0
0
d04e179f30ad6468b489d2f094d6973b3556de1d
2,690
AoC2021_kotlin
Apache License 2.0
src/Day11.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Long { val monkeys = parseMonkeys(input) repeat(20) { for (monkey in monkeys) { monkey.takeTurn(monkeys) { it / 3 } } } return monkeys.map { it.inspectedItems }.sorted().takeLast(2).reduce { acc, i -> a...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
3,924
aoc2022
Apache License 2.0
src/Day04.kt
stcastle
573,145,217
false
{"Kotlin": 24899}
fun getIntRanges(input: List<String>): Pair<List<IntRange>, List<IntRange>> { val first: MutableList<IntRange> = mutableListOf() val second: MutableList<IntRange> = mutableListOf() input.forEach { line -> val ranges: List<String> = line.split(',') require(ranges.size == 2) val firstRange: List<String>...
0
Kotlin
0
0
746809a72ea9262c6347f7bc8942924f179438d5
1,470
aoc2022
Apache License 2.0
src/Day07.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { data class Node(val name: String, var size: Int = 0, val dir: Boolean = false, val parent: Node? = null) { fun propagateSize() { var curr = parent while (curr != null) { curr.size += size curr = curr.parent } } } ...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,195
aoc-2022
Apache License 2.0
src/Day04.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
fun solveDay04() { val values = readInput("Day04") .map { line -> line.split("-", ",").map { it.toInt() } } val part1 = values.count { (a, b, c, d) -> (a <= c && b >= d) || (a >= c && b <= d) } println(part1) val part2 = values.count { (a, b, c, d) -> a <= d && b >= c } println(part2) v...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
1,199
AoC-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch9/Problem98.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch9 import dev.bogwalk.util.combinatorics.permutationID import kotlin.math.max import kotlin.math.pow import kotlin.math.sqrt /** * Problem 98: Anagramic Squares * * https://projecteuler.net/problem=98 * * Goal: Find all square numbers with N digits that have at least 1 anagram that is als...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
5,942
project-euler-kotlin
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day9.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.Pos import com.chriswk.aoc.util.report class Day9 : AdventDay(2021, 9) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day9() report { d...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,527
adventofcode
MIT License
src/Day05.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
data class Instruction(val number: Int, val fromColumn: Int, val toColumn: Int) fun main() { fun part1(input: List<String>): String { // build a map of the towers val towers = input.takeWhile { it.isNotBlank() }.reversed() .map { it .windowed(3, 4, true) ...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
3,078
2022-Advent-of-Code
Apache License 2.0
src/aoc2022/Day07.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList data class FileInfo(val fileSize: Int, val name: String, val isDirectory: Boolean) fun main() { fun parseDirectories(input: List<String>): Map<String, List<FileInfo>> { var path = listOf("/") val map = mutableMapOf<String, List<FileInfo>>() fo...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
2,566
AOC-2022-Kotlin
Apache License 2.0
src/main/kotlin/Day14.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import Day13.transpose import kotlin.String import kotlin.collections.List object Day14 { private const val ROUNDED = 'O' fun part1(input: List<String>): String { val transposedDish = transpose(input) return transposedDish.sumOf { row -> val rolled = roll(row) rolled.rev...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
2,778
kotlin-kringle
Apache License 2.0
src/day11/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day11 import day06.main import grouped import readInput data class Monkey( var inspections: Long = 0L, val items: MutableList<Long>, val operation: (Long) -> Long, val test: Long, val nextMonkeyTrue: Int, val nextMonkeyFalse: Int ) { fun doBusiness(monkeys: List<Monkey>, relief: (L...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
2,556
AOC2022
Apache License 2.0
src/Day02.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
fun main() { val circularArray = setOf<Char>('A', 'B', 'C', 'X', 'Y', 'Z') fun score(a: Char, b: Char): Int { val idA = circularArray.indexOf(a) % 3 val idB = circularArray.indexOf(b) % 3 return when ((idB - idA + 2) % 3) { 2 -> 4 //Draw 1 -> 7 //Win ...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
1,347
Kotlin-AoC-2022
Apache License 2.0
src/day13/Day13.kt
treegem
572,875,670
false
{"Kotlin": 38876}
package day13 import common.readInput // i am sorry for the mess, but i fell behind in schedule and will not refactor or optimize this code // still hoping to catch up fun main() { fun part1(input: List<String>) = input .asSequence() .filter { it.isNotBlank() } .chunk...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
3,152
advent_of_code_2022
Apache License 2.0
src/Day02.kt
DeltaSonic62
572,718,847
false
{"Kotlin": 8676}
fun main() { fun part1(input: List<String>): Int { val opponentScoreMap = mapOf("A" to 1, "B" to 2, "C" to 3) val playerScoreMap = mapOf("X" to 1, "Y" to 2, "Z" to 3) var score = 0 for (line in input) { val opponent = line.split(" ")[0] val player = line.spl...
0
Kotlin
0
0
7cdf94ad807933ab4769ce4995a43ed562edac83
1,699
aoc-2022-kt
Apache License 2.0
src/Day02.kt
petitJAM
572,737,836
false
{"Kotlin": 4868, "Shell": 749}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { inputLine -> inputLine.split(" ").let { val opponent = RPS.fromInput(it[0]) val me = RPS.fromInput(it[1]) scoreGame(me = me, opponent = opponent) } } }...
0
Kotlin
0
0
1965ded0e0ad09b77e001b1b87ac48f47066f479
3,015
adventofcode2022
Apache License 2.0