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/Day09.kt | HylkeB | 573,815,567 | false | {"Kotlin": 83982} | import kotlin.math.absoluteValue
private data class Position(val x: Int, val y: Int) {
operator fun plus(other: Position): Position {
return Position(x + other.x, y + other.y)
}
operator fun minus(other: Position): Position {
return Position(x - other.x, y - other.y)
}
infix fun m... | 0 | Kotlin | 0 | 0 | 8649209f4b1264f51b07212ef08fa8ca5c7d465b | 3,023 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/day21/Code.kt | fcolasuonno | 162,470,286 | false | null | package day21
import java.io.File
import java.lang.Character.isDigit
import kotlin.math.max
fun main(args: Array<String>) {
val name = if (true) "test.txt" else "input.txt"
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val (parsed, equipment) = parse(input)... | 0 | Kotlin | 0 | 0 | 24f54bf7be4b5d2a91a82a6998f633f353b2afb6 | 2,508 | AOC2015 | MIT License |
y2016/src/main/kotlin/adventofcode/y2016/Day20.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2016
import adventofcode.io.AdventSolution
object Day20 : AdventSolution(2016, 20, "Firewall Rules") {
override fun solvePartOne(input: String): String {
val blacklistedIpRanges = coalesceIpRanges(input)
.first()
return if (blacklistedIpRanges.first > 0) "0"
else (blacklistedIpRange... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,652 | advent-of-code | MIT License |
src/aoc2023/Day07.kt | dayanruben | 433,250,590 | false | {"Kotlin": 79134} | package aoc2023
import checkValue
import readInput
fun main() {
val (year, day) = "2023" to "Day07"
fun totalWinning(input: List<String>, hasJoker: Boolean): Long {
val size = input.size
return input.map { line ->
val (cards, bid) = line.split(" ").map { it.trim() }
Ha... | 1 | Kotlin | 2 | 30 | df1f04b90e81fbb9078a30f528d52295689f7de7 | 2,961 | aoc-kotlin | Apache License 2.0 |
src/Day11.kt | JanTie | 573,131,468 | false | {"Kotlin": 31854} | fun main() {
fun parseInput(input: List<String>): List<Monkey> = input.chunked(7)
.mapIndexed { index, it ->
val items = it[1].split(": ")[1].split(", ").map { it.toLong() }
val operation = it[2].split(": ")[1]
val test = it[3].split(": ")[1]
val ifTrue = it[4... | 0 | Kotlin | 0 | 0 | 3452e167f7afe291960d41b6fe86d79fd821a545 | 3,606 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | Jessenw | 575,278,448 | false | {"Kotlin": 13488} | fun main() {
fun part1(input: List<String>) =
input.map { pair ->
val sections =
processRangePair(pair)
.map { Pair(it[0], it[1]) }
if (rangeInRange(sections[0], sections[1])
|| rangeInRange(sections[1], sections[0])) 1
... | 0 | Kotlin | 0 | 0 | 05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3 | 1,496 | aoc-22-kotlin | Apache License 2.0 |
year2023/src/main/kotlin/net/olegg/aoc/year2023/day7/Day7.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2023.day7
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.toPair
import net.olegg.aoc.year2023.DayOf2023
/**
* See [Year 2023, Day 7](https://adventofcode.com/2023/day/7)
*/
object Day7 : DayOf2023(7) {
private val JOKERS = "23456789TQKA".toList()
override fun first():... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,145 | adventofcode | MIT License |
src/Day08.kt | ivancordonm | 572,816,777 | false | {"Kotlin": 36235} | fun main() {
fun part1(input: List<String>): Int {
val matrix = input.map { it.map { elem -> elem.digitToInt() } }
val transpose = List(matrix.first().size) { index -> matrix.map { it[index] } }
var total = input.size * 4 - 4
for (i in 1..input.size - 2)
for (j in 1..... | 0 | Kotlin | 0 | 2 | dc9522fd509cb582d46d2d1021e9f0f291b2e6ce | 1,956 | AoC-2022 | Apache License 2.0 |
src/year2023/day17/Day17.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2023.day17
import check
import readInput
import util.aStar
import kotlin.math.abs
fun main() {
val testInput = readInput("2023", "Day17_test")
check(part1(testInput), 102)
check(part2(testInput), 94)
val input = readInput("2023", "Day17")
println(part1(input))
println(part2(input)... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,672 | AdventOfCode | Apache License 2.0 |
src/Day12.kt | jbotuck | 573,028,687 | false | {"Kotlin": 42401} | fun main() {
val lines = readInput("Day12")
solve('S', lines)
solve('a', lines)
}
fun solve(target: Char, lines: List<String>) {
val distances = Array(lines.size) { Array(lines.first().length) { Int.MAX_VALUE } }
val visited = mutableSetOf<Pair<Int, Int>>()
val start = lines.withIndex().firstNo... | 0 | Kotlin | 0 | 0 | d5adefbcc04f37950143f384ff0efcd0bbb0d051 | 2,387 | aoc2022 | Apache License 2.0 |
src/poyea/aoc/mmxxii/day15/Day15.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day15
import kotlin.math.abs
import poyea.aoc.utils.readInput
data class Beacon(val x: Int, val y: Int)
data class Sensor(
val x: Int,
val y: Int,
val min_x: Int,
val max_x: Int,
val min_y: Int,
val max_y: Int
) {
companion object {
fun of(x: Int, y: Int, ... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 2,650 | aoc-mmxxii | MIT License |
src/main/kotlin/com/anahoret/aoc2022/day08/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day08
import java.io.File
fun main() {
val input = File("src/main/kotlin/com/anahoret/aoc2022/day08/input.txt")
.readText()
.trim()
val matrix = parse(input)
// Part 1
part1(matrix)
// Part 2
part2(matrix)
}
fun parse(input: String): List<List<I... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 2,175 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | fun main() {
fun readHeightMap(input: List<String>): Array<IntArray> =
Array(input.size) { row -> IntArray(input[row].length) { input[row][it].digitToInt() } }
fun Array<IntArray>.isVisible(row: Int, col: Int): Boolean {
val height = this[row][col]
return (0 until col).all { this[row][i... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 1,895 | advent-of-code-22 | Apache License 2.0 |
2k23/aoc2k23/src/main/kotlin/08.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d08
import input.raw
fun main() {
println("Part 1: ${part1(raw("08.txt"))}")
println("Part 2: ${part2(raw("08.txt"))}")
}
enum class Direction {
Left,
Right,
None;
companion object {
fun fromChar(c: Char): Direction = when (c) {
'R' -> Right
'L' -> Lef... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 2,119 | aoc | The Unlicense |
src/Day11.kt | RusticFlare | 574,508,778 | false | {"Kotlin": 78496} | private class Monkey(
val items: MutableList<Long>,
val operation: (Long) -> Long,
val test: Long,
val ifTrue: Int,
val ifFalse: Int,
) {
var inspected : Long = 0
}
private fun monkeys(input: String) = input.split("\n\n").map { it.lines() }.map { monkey ->
Monkey(
items = monkey[1].... | 0 | Kotlin | 0 | 1 | 10df3955c4008261737f02a041fdd357756aa37f | 2,566 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | rafael-ribeiro1 | 572,657,838 | false | {"Kotlin": 15675} | fun main() {
fun part1(input: List<String>): Int {
return input.buildMatrix()
.visibleTrees()
}
fun part2(input: List<String>): Int {
return input.buildMatrix()
.highestScenicScore()
}
// test if implementation meets criteria from the description, like:
... | 0 | Kotlin | 0 | 0 | 5cae94a637567e8a1e911316e2adcc1b2a1ee4af | 2,740 | aoc-kotlin-2022 | Apache License 2.0 |
src/2022/Day12.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | package `2022`
import readInput
fun main() {
fun parseInput(input: List<String>): Day12Input {
val field = input.map { it.asIterable().toMutableList() }
var startPoint = Point(0, 0)
var endPoint = Point(0, 0)
field.forEachIndexed { i,line ->
line.forEachIndexed { j, ... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 2,983 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day08.kt | inssein | 573,116,957 | false | {"Kotlin": 47333} | fun main() {
fun List<String>.toGrid(): List<List<Int>> = this.map { s ->
s.map { it.digitToInt() }
}
fun List<List<Int>>.toView(row: Int, col: Int): List<List<Int>> = listOf(
(row - 1 downTo 0).map { this[it][col] }, // up
(row + 1 until this.size).map { this[it][col] }, // down
... | 0 | Kotlin | 0 | 0 | 095d8f8e06230ab713d9ffba4cd13b87469f5cd5 | 1,883 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | fun main() {
fun part1(input: List<String>): Int =
HeightGrid.parse(input).shortestPathLengthToTopFrom { it.isStart }
fun part2(input: List<String>): Int =
HeightGrid.parse(input).shortestPathLengthToTopFrom { it.height == 'a' }
val testInput = readInput("Day12_test")
check(part1(tes... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 2,529 | aoc-2022 | Apache License 2.0 |
src/Day15.kt | nikolakasev | 572,681,478 | false | {"Kotlin": 35834} | import java.math.BigInteger
import kotlin.math.absoluteValue
fun main() {
fun part1(input: List<String>, targetY: Int): Int {
val sensorsAndBeacons = inputToSensorsAndBeacons(input)
val inRange = sensorsAndBeacons.filter {
val coverageRadius = it.first.manhattanDinstanceTo(it.second)
... | 0 | Kotlin | 0 | 1 | 5620296f1e7f2714c09cdb18c5aa6c59f06b73e6 | 3,478 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day12/Day12_functional.kt | seastco | 574,758,881 | false | {"Kotlin": 72220} | package day12
import Point2D
import readLines
import java.util.PriorityQueue
/**
* 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.
*... | 0 | Kotlin | 0 | 0 | 2d8f796089cd53afc6b575d4b4279e70d99875f5 | 2,955 | aoc2022 | Apache License 2.0 |
src/Day01.kt | ralstonba | 573,072,217 | false | {"Kotlin": 4128} | fun main() {
fun part1(input: List<String>): Int {
var currentMax = Int.MIN_VALUE
var runningSum = 0
for (i in input) {
// Check that the current value is a number
if (i.toIntOrNull() != null) {
runningSum += i.toInt()
} else {
... | 0 | Kotlin | 0 | 0 | 93a8ba96db519f4f3d42e2b4148614969faa79b1 | 2,002 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/be/twofold/aoc2021/Day05.kt | jandk | 433,510,612 | false | {"Kotlin": 10227} | package be.twofold.aoc2021
object Day05 {
fun part1(lines: List<Line>): Int {
return solve(lines, false)
}
fun part2(lines: List<Line>): Int {
return solve(lines, true)
}
private fun solve(lines: List<Line>, useDiagonal: Boolean): Int {
val horizontal = lines
.... | 0 | Kotlin | 0 | 0 | 2408fb594d6ce7eeb2098bc2e38d8fa2b90f39c3 | 1,698 | aoc2021 | MIT License |
src/Day02.kt | schoi80 | 726,076,340 | false | {"Kotlin": 83778} | import kotlin.math.max
fun main() {
fun isPossible(mm: Map<String, Int>, marbles: String): Boolean {
marbles.trim().split(";").forEach { mb ->
mb.trim().split(",").associate {
it.trim().split(" ").let { it[1] to it[0].toInt() }
}.forEach { (color, count) ->
... | 0 | Kotlin | 0 | 0 | ee9fb20d0ed2471496185b6f5f2ee665803b7393 | 1,636 | aoc-2023 | Apache License 2.0 |
src/day08/Day08.kt | Harvindsokhal | 572,911,840 | false | {"Kotlin": 11823} | package day08
import readInput
enum class Direction { LEFT, RIGHT, UP, DOWN }
fun main() {
val data = readInput("day08/day08_data")
fun visibleTrees(x: Int, y: Int) =
if (x == 0 || x == data[0].lastIndex || y == 0 || y == data.lastIndex) {
true
} else {
(0 until x).no... | 0 | Kotlin | 0 | 0 | 7ebaee4887ea41aca4663390d4eadff9dc604f69 | 1,931 | aoc-2022-kotlin | Apache License 2.0 |
src/Day08.kt | mhuerster | 572,728,068 | false | {"Kotlin": 24302} | enum class Direction { NORTH, SOUTH, EAST, WEST }
fun main() {
class Tree(val height: Int, val y: Int, val x: Int) {
override fun toString() : String {
return "$height at [$y, $x]"
}
fun viewingDistance(direction: Direction, trees: List<List<Tree>>) : Int {
val neighbors = when (direction) {... | 0 | Kotlin | 0 | 0 | 5f333beaafb8fe17ff7b9d69bac87d368fe6c7b6 | 4,111 | 2022-advent-of-code | Apache License 2.0 |
2021/src/main/kotlin/Day09.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | class Day09(private val input: List<String>) {
private fun List<String>.heightMap(): Grid = this.map { it.toList().map { Character.getNumericValue(it) } }
private fun Grid.lowPoints(): List<Pair<Int, Int>> = this.foldIndexed(emptyList()) { rowIdx, allPoints, row ->
row.foldIndexed(allPoints) { colIdx,... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 1,537 | adventofcode-2021-2025 | MIT License |
src/Day07.kt | Totwart123 | 573,119,178 | false | null | fun main() {
data class File(val name: String, val size: Int)
data class Folder(val name: String, val files: MutableList<File>, val folders: MutableList<Folder>, val parentFolder: Folder?)
fun calculateFolderSize(folder: Folder): Int{
val size = folder.files.sumOf { it.size } + folder.folders.sumOf... | 0 | Kotlin | 0 | 0 | 33e912156d3dd4244c0a3dc9c328c26f1455b6fb | 2,805 | AoC | Apache License 2.0 |
src/main/kotlin/Day24.kt | gijs-pennings | 573,023,936 | false | {"Kotlin": 20319} | import java.util.*
fun main() {
val lines = readInput(24)
val blizzards = mutableListOf<Blizzard>()
lines.forEachIndexed { y, row ->
row.forEachIndexed { x, pos ->
if (pos != '.' && pos != '#')
blizzards += Blizzard(x, y, when (pos) {
'^' -> 1
... | 0 | Kotlin | 0 | 0 | 8ffbcae744b62e36150af7ea9115e351f10e71c1 | 2,478 | aoc-2022 | ISC License |
src/day8/Day8.kt | bartoszm | 572,719,007 | false | {"Kotlin": 39186} | package day8
import readInput
fun main() {
val testInput = parse(readInput("day08/test"))
val input = parse(readInput("day08/input"))
println(solve1(testInput))
println(solve1(input))
println(solve2(testInput))
println(solve2(input))
}
fun row(arr: Array<IntArray>, idx: Int, ids: IntProgre... | 0 | Kotlin | 0 | 0 | f1ac6838de23beb71a5636976d6c157a5be344ac | 2,183 | aoc-2022 | Apache License 2.0 |
src/Day11.kt | jorgecastrejon | 573,097,701 | false | {"Kotlin": 33669} | fun main() {
fun part1(input: List<String>): Long {
return solve(monkeys = input.asMonkeys(), iterations = 20, reliefOp = { x -> x / 3 })
}
fun part2(input: List<String>): Long {
val monkeys = input.asMonkeys()
val moduloOp = monkeys.fold(1) { acc, b -> acc * b.divisibleBy }
... | 0 | Kotlin | 0 | 0 | d83b6cea997bd18956141fa10e9188a82c138035 | 2,533 | aoc-2022 | Apache License 2.0 |
src/day12/Day12.kt | Volifter | 572,720,551 | false | {"Kotlin": 65483} | package day12
import utils.*
data class Coords(var x: Int, var y: Int) {
operator fun plus(other: Coords): Coords = Coords(x + other.x, y + other.y)
operator fun minus(other: Coords): Coords = Coords(x - other.x, y - other.y)
}
class Map(lines: List<String>) {
lateinit var start: Coords
private lat... | 0 | Kotlin | 0 | 0 | c2c386844c09087c3eac4b66ee675d0a95bc8ccc | 2,690 | AOC-2022-Kotlin | Apache License 2.0 |
src/Day11.kt | bananer | 434,885,332 | false | {"Kotlin": 36979} | fun increase(levels: Array<IntArray>, flashes: MutableSet<Pair<Int, Int>>, x: Int, y: Int) {
if(++levels[x][y] > 9 && !flashes.contains(Pair(x, y))) {
flash(levels, flashes, x, y)
}
}
fun flash(levels: Array<IntArray>, flashes: MutableSet<Pair<Int, Int>>, x: Int, y: Int) {
flashes.add(Pair(x, y))
... | 0 | Kotlin | 0 | 0 | 98f7d6b3dd9eefebef5fa3179ca331fef5ed975b | 2,322 | advent-of-code-2021 | Apache License 2.0 |
src/day08/Day08.kt | PoisonedYouth | 571,927,632 | false | {"Kotlin": 27144} | package day08
import readInput
fun main() {
data class Point(
val x: Int,
val y: Int,
val height: Int,
var matching: Boolean = false,
var scenicScore: Int = 0
)
fun createGrid(input: List<String>): List<List<Point>> {
val grid = mutableListOf<MutableList<Po... | 0 | Kotlin | 1 | 0 | dbcb627e693339170ba344847b610f32429f93d1 | 3,230 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/aoc2021/day5.kt | sodaplayer | 434,841,315 | false | {"Kotlin": 31068} | package aoc2021
import aoc2021.utils.loadInput
import aoc2021.utils.partitionWhen
import kotlin.math.max
import kotlin.math.min
fun main() {
val pattern = Regex("""(\d+),(\d+) -> (\d+),(\d+)""")
val lines = loadInput("/2021/day5-test")
.bufferedReader()
.readLines()
.map {
... | 0 | Kotlin | 0 | 0 | 2d72897e1202ee816aa0e4834690a13f5ce19747 | 1,963 | aoc-kotlin | Apache License 2.0 |
src/day9/Day9.kt | bartoszm | 572,719,007 | false | {"Kotlin": 39186} | package day9
import readInput
import toPair
import kotlin.math.absoluteValue
import kotlin.math.sign
fun main() {
val testInput = parse(readInput("day09/test"))
val input = parse(readInput("day09/input"))
println("${solve1(testInput)} , ${solve2(testInput, 1)}")
println("${solve1(input)} , ${solve2(... | 0 | Kotlin | 0 | 0 | f1ac6838de23beb71a5636976d6c157a5be344ac | 2,611 | aoc-2022 | Apache License 2.0 |
src/year2021/day09/Day09.kt | fadi426 | 433,496,346 | false | {"Kotlin": 44622} | package year2021.day01.day09
import util.assertTrue
import util.model.Counter
import util.read2021DayInput
import java.awt.Point
fun main() {
fun task01(input: List<List<Int>>): Int {
return findLowPoints(input).sumOf { it.first + 1 }
}
fun task02(input: List<List<Int>>): Int {
val lowPo... | 0 | Kotlin | 0 | 0 | acf8b6db03edd5ff72ee8cbde0372113824833b6 | 2,517 | advent-of-code-kotlin-template | Apache License 2.0 |
src/Day08.kt | zdenekobornik | 572,882,216 | false | null | import java.lang.Integer.max
fun main() {
fun <T> Iterable<T>.countWhile(predicate: (T) -> Boolean): Int {
var count = 0
for (item in this) {
if (!predicate(item))
break
count++
}
return count
}
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | f73e4a32802fa43b90c9d687d3c3247bf089e0e5 | 2,029 | advent-of-code-2022 | Apache License 2.0 |
src/day15/Day15.kt | gr4cza | 572,863,297 | false | {"Kotlin": 93944} | package day15
import Edges
import Position
import readInput
import kotlin.math.abs
fun main() {
fun parse(input: List<String>): Pair<List<Position>, List<Position>> {
return input.map { line ->
val chunks = line.split(" ").map { it.replace(Regex("""[xy,:=]"""), "") }
Position(chunk... | 0 | Kotlin | 0 | 0 | ceca4b99e562b4d8d3179c0a4b3856800fc6fe27 | 3,477 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day07.kt | anisch | 573,147,806 | false | {"Kotlin": 38951} | data class File(val name: String, val size: Long = 0)
class Directory {
var name: String = ""
var upDir: Directory? = null
val listDirs = mutableListOf<Directory>()
val listFiles = mutableListOf<File>()
var totalSize = 0L
}
fun calculateSizes(root: Directory): Directory {
if (root.listDirs.isN... | 0 | Kotlin | 0 | 0 | 4f45d264d578661957800cb01d63b6c7c00f97b1 | 2,937 | Advent-of-Code-2022 | Apache License 2.0 |
src/day08/Day08.kt | zypus | 573,178,215 | false | {"Kotlin": 33417, "Shell": 3190} | package day08
import AoCTask
// https://adventofcode.com/2022/day/8
private fun firstPassFromEdge(input: List<String>): List<List<Pair<Int, Boolean>>> {
val rowHeights = input.first().map { -1 }.toMutableList()
val firstPass = input.map { row ->
var maxPreviousHeight = -1
row.mapIndexed { in... | 0 | Kotlin | 0 | 0 | f37ed8e9ff028e736e4c205aef5ddace4dc73bfc | 2,757 | aoc-2022 | Apache License 2.0 |
src/year2023/Day17.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2023
import Direction
import Grid
import Point
import readLines
import java.util.PriorityQueue
fun main() {
val input = parseInput(readLines("2023", "day17"))
val testInput = parseInput(readLines("2023", "day17_test"))
check(part1(testInput) == 102) { "Incorrect result for part 1: ${part1(tes... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 2,916 | advent_of_code | MIT License |
src/Day18.kt | nikolakasev | 572,681,478 | false | {"Kotlin": 35834} | import kotlin.math.max
import kotlin.math.min
fun main() {
fun part1(input: List<String>): Int {
val cubes = inputToCubes(input)
return surfaceArea(cubes)
}
fun part2(input: List<String>): Int {
val cubes = inputToCubes(input)
val minX = cubes.minByOrNull { it.first }
... | 0 | Kotlin | 0 | 1 | 5620296f1e7f2714c09cdb18c5aa6c59f06b73e6 | 2,678 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day02.kt | zhtk | 579,137,192 | false | {"Kotlin": 9893} | enum class Shape { PAPER, ROCK, SCISSORS }
enum class RoundOutcome { WIN, DRAW, LOSS }
val shapeWinsWithMap = mapOf(Shape.PAPER to Shape.ROCK, Shape.ROCK to Shape.SCISSORS, Shape.SCISSORS to Shape.PAPER)
data class Round(val you: Shape, val opponent: Shape) {
fun getOutcome(): RoundOutcome = when {
you ==... | 0 | Kotlin | 0 | 0 | bb498e93f9c1dd2cdd5699faa2736c2b359cc9f1 | 1,762 | aoc2022 | Apache License 2.0 |
y2022/src/main/kotlin/adventofcode/y2022/Day12.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
import adventofcode.util.vector.Vec2
import adventofcode.util.vector.neighbors
object Day12 : AdventSolution(2022, 12, "Hill Climbing Algorithm") {
override fun solvePartOne(input: String): Int {
val landscape = parse(input)
return ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,147 | advent-of-code | MIT License |
src/year2021/08/Day08.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2021.`08`
import readInput
fun main() {
fun deductMappingOfNumbers(left: List<String>): Map<Set<Char>, Int> {
val leftSet = left.toSortedSet()
val one = leftSet.find { it.length == 2 }!!.toSortedSet()
val four = leftSet.find { it.length == 4 }!!.toSortedSet()
val seve... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 3,691 | KotlinAdventOfCode | Apache License 2.0 |
src/main/kotlin/solutions/day15/Day15.kt | Dr-Horv | 570,666,285 | false | {"Kotlin": 115643} | package solutions.day15
import solutions.Solver
import utils.Coordinate
import utils.manhattanDistance
import kotlin.math.abs
data class SensorBeaconPair(
val sensor: Coordinate,
val beacon: Coordinate,
val distance: Int
)
fun SensorBeaconPair.distance(): Int = sensor.manhattanDistance(beacon)
class Day... | 0 | Kotlin | 0 | 2 | 6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e | 3,104 | Advent-of-Code-2022 | MIT License |
src/day09/Day09.kt | EdwinChang24 | 572,839,052 | false | {"Kotlin": 20838} | package day09
import readInput
fun main() {
part1()
part2()
}
data class Pos(var x: Int, var y: Int)
fun moveNext(h: Pos, t: Pos) {
when {
h.x == t.x && h.y - t.y == 2 -> t.y++
h.x == t.x && t.y - h.y == 2 -> t.y--
h.y == t.y && h.x - t.x == 2 -> t.x++
h.y == t.y && t.x -... | 0 | Kotlin | 0 | 0 | e9e187dff7f5aa342eb207dc2473610dd001add3 | 2,322 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | kipwoker | 572,884,607 | false | null | import kotlin.math.max
class Tree(val value: Int, var visible: Boolean)
fun main() {
fun parse(input: List<String>): List<List<Tree>> {
return input.map { line ->
line.toCharArray().map {
Tree(it.digitToInt(), false)
}
}
}
fun findVisible(trees: Lis... | 0 | Kotlin | 0 | 0 | d8aeea88d1ab3dc4a07b2ff5b071df0715202af2 | 3,089 | aoc2022 | Apache License 2.0 |
src/Day12.kt | RobvanderMost-TomTom | 572,005,233 | false | {"Kotlin": 47682} | data class Day12Pos(
val x: Int,
val y: Int,
) {
fun up() = Day12Pos(x, y - 1)
fun down() = Day12Pos(x, y + 1)
fun left() = Day12Pos(x - 1, y)
fun right() = Day12Pos(x + 1, y)
}
data class Hill(
val height: Char,
var minDistance: Int = Int.MAX_VALUE
) {
fun reachableFrom(origin: Hil... | 5 | Kotlin | 0 | 0 | b7143bceddae5744d24590e2fe330f4e4ba6d81c | 3,245 | advent-of-code-2022 | Apache License 2.0 |
src/day04/Day04.kt | GrinDeN | 574,680,300 | false | {"Kotlin": 9920} | fun main() {
fun part1(input: List<String>): Int {
return input
.map { it.split(',') }
.map { Pair(it[0], it[1]) }
.map { Pair(
Pair(it.first.split('-')[0], it.first.split('-')[1]),
Pair(it.second.split('-')[0], it.second.split('-')[1])) }
... | 0 | Kotlin | 0 | 0 | f25886a7a3112c330f80ec2a3c25a2ff996d8cf8 | 1,637 | aoc-2022 | Apache License 2.0 |
src/day15/day15.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day15
import readInput
import kotlin.math.abs
private fun parse(input: List<String>): List<Pair<Pair<Int, Int>, Pair<Int, Int>>> {
return input.map { it.split(" ", ",", "=", ":") }
.map {
val startPoint = Pair(it[3].toInt(), it[6].toInt())
val beaconPoint = Pair(it[13].toIn... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 2,910 | aoc-2022 | Apache License 2.0 |
src/Day15.kt | PascalHonegger | 573,052,507 | false | {"Kotlin": 66208} | import kotlin.math.*
fun main() {
val inputPattern = "Sensor at x=(.*), y=(.*): closest beacon is at x=(.*), y=(.*)".toRegex()
data class Point(val x: Int, val y: Int)
infix fun Point.distanceTo(other: Point): Int {
// https://en.wikipedia.org/wiki/Taxicab_geometry
return abs(x - other.x... | 0 | Kotlin | 0 | 0 | 2215ea22a87912012cf2b3e2da600a65b2ad55fc | 3,018 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2023/src/Day05.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | import kotlin.math.max
import kotlin.math.min
private const val DAY = "Day05"
fun main() {
fun testInput() = readInput("${DAY}_test")
fun input() = readInput(DAY)
"Part 1" {
part1(testInput()) shouldBe 35
measureAnswer { part1(input()) }
}
"Part 2" {
part2(testInput()) sh... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 3,456 | advent-of-code | Apache License 2.0 |
src/main/kotlin/aoc2023/Day03.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import Point
import multiplyOf
import readInput
private data class SchemanticsChar(val point: Point, val char: Char)
object Day03 {
/**
* Reads the complete part number starting from any position within the number
*
* @param allPoints all possible [SchemanticsChar] in the original... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,543 | adventOfCode | Apache License 2.0 |
src/day12/Day12.kt | gr4cza | 572,863,297 | false | {"Kotlin": 93944} | package day12
import Direction
import Position
import readInput
import set
import get
fun main() {
fun parseInput(input: List<String>): List<List<Char>> {
return input.map { line ->
line.chunked(1).map {
when (val char = it.toCharArray().first()) {
'S' -> 'a... | 0 | Kotlin | 0 | 0 | ceca4b99e562b4d8d3179c0a4b3856800fc6fe27 | 3,031 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/year2021/Day8.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2021
import readLines
fun main() {
val input = parseInput(readLines("2021", "day8"))
val smallTestInput = parseInput(readLines("2021", "day8_test_small"))
val bigTestInput = parseInput(readLines("2021", "day8_test_big"))
check(part1(bigTestInput) == 26)
println("Part 1:" + part1(input... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 3,435 | advent_of_code | MIT License |
advent-of-code-2023/src/Day15.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | import LensOperation.Put
import LensOperation.Remove
import java.util.*
private const val DAY = "Day15"
fun main() {
fun testInput() = readInput("${DAY}_test")
fun input() = readInput(DAY)
"Part 1" {
part1(testInput()) shouldBe 1320
measureAnswer { part1(input()) }
}
"Part 2" {
... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 2,255 | advent-of-code | Apache License 2.0 |
src/Day08.kt | rdbatch02 | 575,174,840 | false | {"Kotlin": 18925} |
fun <T : Comparable<T>> Iterable<T>.maxOrDefault(default: T): T = this.maxOrNull() ?: default
public inline fun <T> List<T>.indexOfFirstOrSize(predicate: (T) -> Boolean): Int {
val firstIndex = this.indexOfFirst(predicate)
return if (firstIndex > -1) firstIndex else this.size
}
fun main() {
fun parseMap(in... | 0 | Kotlin | 0 | 1 | 330a112806536910bafe6b7083aa5de50165f017 | 3,375 | advent-of-code-kt-22 | Apache License 2.0 |
src/main/kotlin/day18.kt | gautemo | 725,273,259 | false | {"Kotlin": 79259} | import shared.*
fun main() {
val input = Input.day(18)
println(day18A(input))
println(day18B(input))
}
fun day18A(input: Input): Long {
var on = Point(0, 0)
val vectors = input.lines.map { line ->
val (direction, meters) = line.split(' ')
when(direction) {
"R" -> Vector... | 0 | Kotlin | 0 | 0 | 6862b6d7429b09f2a1d29aaf3c0cd544b779ed25 | 2,402 | AdventOfCode2023 | MIT License |
src/main/kotlin/aoc23/Day01.kt | asmundh | 573,096,020 | false | {"Kotlin": 56155} | package aoc23
import runTask
import utils.InputReader
fun day1part1(input: List<String>): Int {
return input.sumOf {
val d1 = it.first { it.isDigit() }.digitToInt()
val d2 = it.last { it.isDigit() }.digitToInt()
"$d1$d2".toInt()
}
}
fun day1part2(input: List<String>): Int {
return... | 0 | Kotlin | 0 | 0 | 7d0803d9b1d6b92212ee4cecb7b824514f597d09 | 2,471 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/nibado/projects/advent/y2017/Day07.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2017
import com.nibado.projects.advent.Day
import com.nibado.projects.advent.resourceLines
val regex = Regex("([a-z]{4,8}) \\(([0-9]+)\\)( -> ([a-z ,]+))?")
object Day07 : Day {
val tree: Tree by lazy { parseTree(resourceLines(2017, 7)) }
override fun part1() = tree.name
... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 2,139 | adventofcode | MIT License |
src/Day08.kt | wujingwe | 574,096,169 | false | null | object Day08 {
private val DIRS = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
fun part1(inputs: List<String>): Int {
val forest = inputs
.withIndex()
.flatMap { (row, line) ->
line.withIndex().map { (col, value) -> (row to col) to value - '0'}
}
... | 0 | Kotlin | 0 | 0 | a5777a67d234e33dde43589602dc248bc6411aee | 2,578 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | stevefranchak | 573,628,312 | false | {"Kotlin": 34220} | class RucksacksAnalyzer {
companion object {
private const val CODE_PRIOR_TO_LOWERCASE_A = 96
private const val CODE_PRIOR_TO_UPPERCASE_A = 64
private const val ENGLISH_ALPHABET_LENGTH = 26
private const val ELVES_PER_GROUP = 3
fun sumPrioritiesOfCommonItems(input: List<Stri... | 0 | Kotlin | 0 | 0 | 22a0b0544773a6c84285d381d6c21b4b1efe6b8d | 2,371 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day15.kt | Vampire | 572,990,104 | false | {"Kotlin": 57326} | import kotlin.math.abs
typealias Coordinates = Pair<Int, Int>
fun main() {
fun Coordinates.distance(other: Coordinates) =
abs(other.first - first) + abs(other.second - second)
data class SensorResult(val sensor: Coordinates, val beacon: Coordinates) {
val distance = sensor.distance(beacon)
... | 0 | Kotlin | 0 | 0 | 16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f | 3,253 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/day2/main.kt | janneri | 572,969,955 | false | {"Kotlin": 99028} | package day2
import day2.Hand.*
import day2.RoundResult.*
import util.readTestInput
enum class Hand(val points: Int, val symbols: List<String>) {
ROCK(1, listOf("X", "A")),
PAPER(2, listOf("Y", "B")),
SCISSORS(3, listOf("Z", "C"));
companion object {
fun ofSymbol(symbol: String): Hand {
... | 0 | Kotlin | 0 | 0 | 1de6781b4d48852f4a6c44943cc25f9c864a4906 | 2,432 | advent-of-code-2022 | MIT License |
src/Day12.kt | cypressious | 572,916,585 | false | {"Kotlin": 40281} | import java.util.*
fun main() {
class Node(
val name: String,
val edges: MutableSet<Node> = TreeSet(compareBy { it.name })
) {
val isSmallCave get() = name.first().isLowerCase() && name != "start" && name != "end"
val isBigCave get() = name.first().isUpperCase()
overrid... | 0 | Kotlin | 0 | 0 | 169fb9307a34b56c39578e3ee2cca038802bc046 | 2,246 | AdventOfCode2021 | Apache License 2.0 |
src/main/kotlin/com/oocode/Bag.kt | ivanmoore | 725,978,325 | false | {"Kotlin": 42155} | package com.oocode
fun powerOf(input: String) =
input.split("\n").sumOf { line -> gameFrom(line).power() }
data class Bag(val red: Int, val green: Int, val blue: Int) {
fun possibilityTotal(input: String) =
input.split("\n").sumOf { line -> line.possibilityValue(this) }
fun power() = red * green ... | 0 | Kotlin | 0 | 0 | 36ab66daf1241a607682e7f7a736411d7faa6277 | 1,832 | advent-of-code-2023 | MIT License |
src/year2023/Day5.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2023
import readLines
fun main() {
check(LongRange(98, 99).fastIntersect(LongRange(10, 200)).toList() == listOf(98L, 99L))
check(LongRange(98, 99).fastIntersect(LongRange(100, 200)).isEmpty())
check(LongRange(10, 20).fastIntersect(LongRange(15, 22)).toList() == listOf<Long>(15, 16, 17, 18, 19,... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 3,721 | advent_of_code | MIT License |
src/Day15.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | import kotlin.math.abs
import kotlin.math.max
class MutableIntRange(var first: Int, var last: Int)
fun List<IntRange>.combine(): List<IntRange> {
val result = mutableListOf<IntRange>()
var ranger: MutableIntRange? = null
this.sortedBy { it.first }.forEachIndexed { idx, range ->
if (ranger == null... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 3,158 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | hnuttin | 572,601,761 | false | {"Kotlin": 5036} | fun main() {
val priorities = "0abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
part1(readInput("Day03_test"), priorities)
part2(readInput("Day03_test"), priorities)
// part2(readInput("Day03_example"), priorities)
}
fun part2(readInput: List<String>, priorities: String) {
val priorities = r... | 0 | Kotlin | 0 | 0 | 53975ed6acb42858be56c2150e573cdbf3deedc0 | 1,487 | aoc-2022 | Apache License 2.0 |
src/Day18.kt | inssein | 573,116,957 | false | {"Kotlin": 47333} | fun main() {
fun List<String>.toCubes(): Set<Triple<Int, Int, Int>> = this.map {
val parts = it.split(",").map { s -> s.toInt() }
Triple(parts[0], parts[1], parts[2])
}.toSet()
fun Triple<Int, Int, Int>.toSides(): List<Triple<Int, Int, Int>> {
val (x, y, z) = this
return l... | 0 | Kotlin | 0 | 0 | 095d8f8e06230ab713d9ffba4cd13b87469f5cd5 | 1,915 | advent-of-code-2022 | Apache License 2.0 |
src/Day11.kt | sabercon | 648,989,596 | false | null | typealias Seats = List<List<Char>>
typealias Point = Pair<Int, Int>
typealias Direction = Pair<Int, Int>
typealias Rule = (Seats, Point, Direction) -> Boolean
fun main() {
fun hasAdjacentOccupiedSeats(seats: Seats, point: Point, direction: Direction): Boolean {
val (i, j) = point
val (di, dj) = dir... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 2,055 | advent-of-code-2020 | MIT License |
src/main/kotlin/dp/LCIS.kt | yx-z | 106,589,674 | false | null | package dp
import util.get
import util.max
import util.set
// longest common increasing subsequence
// given two sequences A[1..m], and B[1..n]
// find the length of longest common sequence that is also increasing
fun main(args: Array<String>) {
val A = intArrayOf(1, 5, 6)
val B = intArrayOf(1, 5, 3, 6)
println(... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,151 | AlgoKt | MIT License |
src/main/kotlin/aoc2022/Day12.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2022
import Point
import readInput
private class Input(val map: Array<IntArray>, val start: Point, val end: Point)
private fun parseInput(input: List<String>): Input {
lateinit var start: Point
lateinit var end: Point
val map = input.withIndex().map { row ->
row.value.toCharArray().wit... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,577 | adventOfCode | Apache License 2.0 |
src/Day07.kt | szymon-kaczorowski | 572,839,642 | false | {"Kotlin": 45324} | data class Directory(
val name: String,
val parent: Directory? = null,
val directories: MutableMap<String, Directory> = mutableMapOf(),
val files: MutableList<AdventFile> = mutableListOf(),
) {
override fun toString(): String =
"name=${name},directories=$directories,files=$files"
fun s... | 0 | Kotlin | 0 | 0 | 1d7ab334f38a9e260c72725d3f583228acb6aa0e | 2,647 | advent-2022 | Apache License 2.0 |
src/jvmMain/kotlin/day07/initial/Day07.kt | liusbl | 726,218,737 | false | {"Kotlin": 109684} | package day07.initial
import java.io.File
fun main() {
// solvePart1() // Solution: 253910319, time: 08:02
solvePart2() // Solution: 253910319, time: 08:02
}
fun solvePart2() {
val input = File("src/jvmMain/kotlin/day07/input/input_part1_test.txt")
// val input = File("src/jvmMain/kotlin/day07/input/in... | 0 | Kotlin | 0 | 0 | 1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1 | 5,588 | advent-of-code | MIT License |
y2020/src/main/kotlin/adventofcode/y2020/Day16.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2020
import adventofcode.io.AdventSolution
import adventofcode.util.algorithm.transpose
object Day16 : AdventSolution(2020, 16, "Ticket Translation") {
override fun solvePartOne(input: String): Int {
val (fields, _, otherTickets) = parse(input)
return otherTickets.flatten()
... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,451 | advent-of-code | MIT License |
src/Day15.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | import java.util.Date
import kotlin.math.abs
fun main() {
fun parseSensorBeaconPairs(input: List<String>): List<Pair<Coordinates, Coordinates>> {
return input
.map { it.substring(12).split(": closest beacon is at x=") }
.map {
val sensorRaw = it[0].split(", y=")
... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 3,776 | aoc2022 | Apache License 2.0 |
src/day11/Day11.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day11
import groupByBlankLine
import readInput
const val day = "11"
fun main() {
fun calculatePart1Score(input: List<String>): Long {
val monkeys = input.groupByBlankLine().values.map { it.toMonkey(3) }
val gameRounds = monkeys.runGame(20)
return gameRounds.calculateMonkeyBusines... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 4,282 | advent-of-code-22-kotlin | Apache License 2.0 |
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day03.kt | JamJaws | 725,792,497 | false | {"Kotlin": 30656} | package com.jamjaws.adventofcode.xxiii.day
import com.jamjaws.adventofcode.xxiii.readInput
class Day03 {
fun part1(text: List<String>): Int {
val numbers = getNumbers(text)
val coordinates = getCoordinates(text, "[^.\\d]").flatMap(::getAdjacentCoordinates)
return numbers.filter { it.coor... | 0 | Kotlin | 0 | 0 | e2683305d762e3d96500d7268e617891fa397e9b | 2,279 | advent-of-code-2023 | MIT License |
src/main/kotlin/Day19.kt | gijs-pennings | 573,023,936 | false | {"Kotlin": 20319} | import kotlin.math.max
private const val MAX_TIME = 24 // set MAX_TIME=32 for part 2
fun main() {
val recipes = readInput(19).map { line ->
val nums = Regex("\\d+").findAll(line).map { it.value.toInt() }.toList()
mapOf(
RobotType.ORE to Resources(ore = nums[1]),
Robot... | 0 | Kotlin | 0 | 0 | 8ffbcae744b62e36150af7ea9115e351f10e71c1 | 3,258 | aoc-2022 | ISC License |
src/day16/Day16.kt | gr4cza | 572,863,297 | false | {"Kotlin": 93944} | package day16
import readInput
fun main() {
fun parse(input: List<String>): List<Valve> {
val split = input.map {
val (valves, connections) = it.split(";")
valves to connections
}
val valveList = split.map { (valves, _) ->
val (_, name, _, _, rate) = val... | 0 | Kotlin | 0 | 0 | ceca4b99e562b4d8d3179c0a4b3856800fc6fe27 | 4,115 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/pl/jpodeszwik/aoc2023/Day07.kt | jpodeszwik | 729,812,099 | false | {"Kotlin": 55101} | package pl.jpodeszwik.aoc2023
private val cardValues = mapOf(
'A' to 14,
'K' to 13,
'Q' to 12,
'J' to 11,
'T' to 10,
'9' to 9,
'8' to 8,
'7' to 7,
'6' to 6,
'5' to 5,
'4' to 4,
'3' to 3,
'2' to 2,
)
private fun rank(cards: String): Int {
val groups = cards.group... | 0 | Kotlin | 0 | 0 | 2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63 | 2,648 | advent-of-code | MIT License |
src/poyea/aoc/mmxxii/day14/Day14.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day14
import kotlin.math.abs
import kotlin.math.sign
import poyea.aoc.utils.readInput
fun lineBetween(p1: Pair<Int, Int>, p2: Pair<Int, Int>): List<Pair<Int, Int>> {
val dx = (p2.first - p1.first).sign
val dy = (p2.second - p1.second).sign
val steps = maxOf(abs(p1.first - p2.first... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 2,453 | aoc-mmxxii | MIT License |
src/main/kotlin/Day11.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | fun main() {
fun calculate(monkeys: List<Monkey>, numberOfRounds: Int, worryLevel: (Long) -> Long): Long {
val inspections = monkeys.associate { it.name to MonkeyInspections(it.name, it.items) }
.toMutableMap()
val rounds = mutableMapOf<Int, Map<String, MonkeyInspections>>()
(... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 4,045 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/Day08.kt | roxanapirlea | 572,665,040 | false | {"Kotlin": 27613} | import kotlin.math.max
private data class Tree(
val height: Int,
val maxLeft: Int = -1,
val maxRight: Int = -1,
val maxTop: Int = -1,
val maxBottom: Int = -1
)
fun main() {
fun List<String>.toTrees(): List<List<Tree>> {
return map { line -> line.toCharArray().map { c -> Tree(c.digitToI... | 0 | Kotlin | 0 | 0 | 6c4ae6a70678ca361404edabd1e7d1ed11accf32 | 3,077 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2023/day12/day12.kt | dzkoirn | 725,682,258 | false | {"Kotlin": 133478} | package adventofcode2023.day12
import adventofcode2023.readInput
import kotlin.time.measureTime
fun main() {
println("Day 12")
val input = readInput("day12")
val puzzle1Duration = measureTime {
println("Puzzle 1 ${puzzle1(input)}")
}
println("Puzzle 1 took $puzzle1Duration")
val puzzle... | 0 | Kotlin | 0 | 0 | 8f248fcdcd84176ab0875969822b3f2b02d8dea6 | 3,257 | adventofcode2023 | MIT License |
src/day07/Day07.kt | pnavais | 574,712,395 | false | {"Kotlin": 54079} | package day07
import readInput
private const val TOTAL_DISK_SIZE: Long = 70000000
private const val REQUIRED_UNUSED_SPACE: Long = 30000000
private const val MAX_SIZE_LIMIT: Int = 100000
class File(val name: String, val size: Long) {
}
class Directory(val name: String, val parent: Directory?) {
val subDirectorie... | 0 | Kotlin | 0 | 0 | ed5f521ef2124f84327d3f6c64fdfa0d35872095 | 2,867 | advent-of-code-2k2 | Apache License 2.0 |
advent-of-code-2022/src/Day12.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
"Part 1" {
val testInput = readInput("Day12_test")
val input = readInput("Day12")
part1(testInput) shouldBe 31
answer(part1(input))
}
"Part 2" {
val testInput = readInput("Day12_test")
val input = readInput("Day12")
part2(testInput) shoul... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 2,976 | advent-of-code | Apache License 2.0 |
src/Day11.kt | andrewgadion | 572,927,267 | false | {"Kotlin": 16973} | import java.util.LinkedList
fun Long.isDivisible(other: Long) = this % other == 0L
class Monkey(val inspect: Command, val divisor: Long, val ifTrueMonkey: Int, val ifFalseMonkey: Int) {
private val items = LinkedList<Long>()
var inspectCount = 0
private set
fun addItem(item: Long) = items.add(item)... | 0 | Kotlin | 0 | 0 | 4d091e2da5d45a786aee4721624ddcae681664c9 | 2,472 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | tomoki1207 | 572,815,543 | false | {"Kotlin": 28654} | import kotlin.math.min
fun main() {
fun withGrid(input: List<String>, operation: (Int, List<Int>, List<Int>, List<Int>, List<Int>) -> Unit) {
val grid = input.map { line -> line.toList().map { it.digitToInt() } }
val rowSize = grid.size
val colSize = grid[0].size
for (row in 0 unt... | 0 | Kotlin | 0 | 0 | 2ecd45f48d9d2504874f7ff40d7c21975bc074ec | 2,018 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day12.kt | StephenVinouze | 572,377,941 | false | {"Kotlin": 55719} | data class Square(
val x: Int,
val y: Int,
val height: Int,
val isStart: Boolean,
val isEnd: Boolean,
)
fun main() {
fun Char.toHeight(): Int =
when (this) {
'S' -> 0
'E' -> 26
else -> this - 'a'
}
fun List<String>.toSquares(): List<List... | 0 | Kotlin | 0 | 0 | 11b9c8816ded366aed1a5282a0eb30af20fff0c5 | 3,014 | AdventOfCode2022 | Apache License 2.0 |
src/Day13.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | fun <T : Comparable<T>> List<T>.compareTo(other: List<T>) =
zip(other)
.map { (a, b) -> a.compareTo(b) }
.firstOrNull { it != 0 }
?: size.compareTo(other.size)
fun <T : Comparable<T>> Iterable<T>.isSorted() = zipWithNext().all { (a, b) -> a < b }
sealed interface Packet: Comparable<Packet>... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 2,595 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | fasfsfgs | 573,562,215 | false | {"Kotlin": 52546} | data class Rucksack(val firstCompartment: String, val secondCompartment: String)
data class RucksackGroup(val firstRucksack: String, val secondRucksack: String, val thirdRucksack: String)
fun createRucksack(allTypes: String): Rucksack {
val firstCompartment = allTypes.take(allTypes.length / 2)
val secondCompa... | 0 | Kotlin | 0 | 0 | 17cfd7ff4c1c48295021213e5a53cf09607b7144 | 1,842 | advent-of-code-2022 | Apache License 2.0 |
src/Day19.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | data class Blueprint(
val ID: Int,
val oreCost: Int,
val clayCost: Int,
val obsidianCost: Pair<Int, Int>,
val geodeCost: Pair<Int, Int>,
)
data class RobotNode(
val ore: Int,
val oreRobots: Int,
val clay: Int,
val clayRobots: Int,
val obsidian: Int,
val obsidianRobots: Int,
... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 3,494 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | michaelYuenAE | 573,094,416 | false | {"Kotlin": 74685} | fun main() {
data class Point(val x: Int, val y: Int, val z: Int)
fun List<String>.parse(): Set<Point> {
val pointRegex = "(\\d+),(\\d+),(\\d+)".toRegex()
return this
.mapNotNull { line -> pointRegex.matchEntire(line)?.groupValues }
.map { gv -> Point(gv[1].toInt(), gv[... | 0 | Kotlin | 0 | 0 | ee521263dee60dd3462bea9302476c456bfebdf8 | 2,660 | advent22 | Apache License 2.0 |
src/Day07.kt | Jessenw | 575,278,448 | false | {"Kotlin": 13488} | data class Node<T>(
val value: T,
val children: MutableList<Node<T>> = mutableListOf()
)
fun Node<Directory>.calculateSize(): Int =
children.sumOf {
it.calculateSize()
} + value.fileSize()
data class File(
val name: String,
val size: Int
)
data class Directory(
val name: String,
... | 0 | Kotlin | 0 | 0 | 05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3 | 3,580 | aoc-22-kotlin | Apache License 2.0 |
2021/src/day14/day14.kt | scrubskip | 160,313,272 | false | {"Kotlin": 198319, "Python": 114888, "Dart": 86314} | package day14
import java.io.File
fun main() {
val data = parseInput(File("src/day14", "day14input.txt").readLines())
var chain = data.first
var rules = data.second
for (i in 1..10) {
chain = runStep(chain, rules)
}
println(getQuantityDifference(chain))
val countMap = runStepExte... | 0 | Kotlin | 0 | 0 | a5b7f69b43ad02b9356d19c15ce478866e6c38a1 | 2,958 | adventofcode | Apache License 2.0 |
src/Day13.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} | fun main() {
fun findMatchingBracket(input: String): Int {
var counter = 1
input.substring(1)
.forEachIndexed { i, c ->
when (c) {
'[' -> counter++
']' -> counter --
}
if (counter == 0) return i + 1
}
thr... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 3,156 | advent-of-code-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.