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/Day12.kt | ambrosil | 572,667,754 | false | {"Kotlin": 70967} | fun main() {
class Terrain constructor(input: List<String>) {
val distances: HashMap<Point, Int> = HashMap()
var queue: ArrayDeque<Point> = ArrayDeque()
var heightmap: List<List<Char>> = input.map { it.toList() }
fun enqueue(point: Point, distance: Int) {
if (distances[... | 0 | Kotlin | 0 | 0 | ebaacfc65877bb5387ba6b43e748898c15b1b80a | 2,651 | aoc-2022 | Apache License 2.0 |
src/Day12.kt | RogozhinRoman | 572,915,906 | false | {"Kotlin": 28985} | fun main() {
fun getNeighbours(currentNode: Pair<Int, Int>, grid: Array<CharArray>): MutableSet<Pair<Int, Int>> {
val cord = arrayOf(0, 1, 0, -1, 0)
val neighbours = mutableSetOf<Pair<Int, Int>>()
for (i in 0 until cord.lastIndex) {
val newX = currentNode.first + cord[i]
... | 0 | Kotlin | 0 | 1 | 6375cf6275f6d78661e9d4baed84d1db8c1025de | 3,110 | AoC2022 | Apache License 2.0 |
src/Day11.kt | kmes055 | 577,555,032 | false | {"Kotlin": 35314} | fun main() {
class Monkey(
val holding: MutableList<Long>,
val operation: (Long) -> Long,
val test: Long,
val target: Pair<Long, Long>,
var throwCount: Long = 0
) {
fun inspect(): List<Pair<Long, Long>> = holding
.map(operation)
.map { it ... | 0 | Kotlin | 0 | 0 | 84c2107fd70305353d953e9d8ba86a1a3d12fe49 | 4,178 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2021/day5/Venting.kt | arnab | 75,525,311 | false | null | package aoc2021.day5
import kotlin.math.absoluteValue
object Venting {
data class Point(val x: Int, val y: Int) {
companion object {
fun from(data: String): Point {
val x = data.split(",").first().toInt()
val y = data.split(",").last().toInt()
re... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 2,642 | adventofcode | MIT License |
src/Day12.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | import kotlin.math.max
fun main() {
fun parseInput(input: List<String>): Pair<MutableList<MutableList<Char>>, Pair<Pair<Int, Int>, Pair<Int, Int>>> {
var startPos = Pair(-1, -1)
var endPos = Pair(-1, -1)
var maze = input.mapIndexed{row, itRow -> itRow.toMutableList()
.also { if... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 5,489 | aoc22 | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2023/d07/Day07.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d07
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.readLines
val cardOrderPartOne = listOf(
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'T',
'J',
'Q',
'K',
'A',... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,728 | advent-of-code | MIT License |
app/src/main/kotlin/day10/Day10.kt | KingOfDog | 433,706,881 | false | {"Kotlin": 76907} | package day10
import common.InputRepo
import common.readSessionCookie
import common.solve
import java.util.*
import kotlin.math.floor
fun main(args: Array<String>) {
val day = 10
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay10Part1, ::solveDay10Part2)
}
fun... | 0 | Kotlin | 0 | 0 | 576e5599ada224e5cf21ccf20757673ca6f8310a | 2,483 | advent-of-code-kt | Apache License 2.0 |
_posts/2020-12-20/solve.kts | booniepepper | 317,946,432 | false | {"Go": 6095, "Rust": 5639, "Prolog": 4681, "Raku": 3895, "Elixir": 3361, "Kotlin": 3076, "Zig": 2873, "Common Lisp": 2105, "C": 2083, "Haskell": 1967, "Racket": 1873, "Scheme": 1498, "Awk": 1342, "Erlang": 1294, "OCaml": 1179, "Groovy": 1100, "JavaScript": 1099, "Tcl": 954, "Shell": 924, "Perl": 834, "PureScript": 806,... | #!/usr/bin/env kotlin
import java.io.File
import java.math.BigInteger
class Tile(raw: String) {
val n: BigInteger
val borders: List<String>
val rborders: List<String>
val tile: List<String>
init {
val lines = raw.split("\n")
n = lines[0].replace(Regex("\\D"), "").toBigInteger()
... | 0 | Go | 0 | 2 | c9645f1df08b83180ccc574a91e02a26099d0cba | 1,957 | adventofcode-solutions | Do What The F*ck You Want To Public License |
src/Day21.kt | sabercon | 648,989,596 | false | null | fun main() {
fun buildIngredientAllergenMap(allergenIngredientMap: Map<String, Set<String>>): Map<String, String> {
if (allergenIngredientMap.isEmpty()) return emptyMap()
val (allergen, ingredients) = allergenIngredientMap.entries.first { it.value.size == 1 }
val ingredient = ingredients.si... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 1,362 | advent-of-code-2020 | MIT License |
src/aoc2023/Day19.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
fun main() {
data class Part(val x: Int, val m: Int, val a: Int, val s: Int)
abstract class Condition {
abstract fun evaluate(part: Part): Boolean
}
class TrueCondition : Condition() {
override fun evaluate(part: Part) = true
}
class Conditio... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 3,843 | advent-of-code-kotlin | Apache License 2.0 |
src/Day16.kt | joy32812 | 573,132,774 | false | {"Kotlin": 62766} |
data class Valve(val id: String, val rate: Int, val neighbors: List<String>)
data class VNode(val rate: Int, val friends: List<Int>)
fun main() {
fun String.toValve(): Valve {
val id = split(" ")[1]
val rate = split(";")[0].split("=")[1].toInt()
val neighbors = if (" valves " in this) split(" valves "... | 0 | Kotlin | 0 | 0 | 5e87958ebb415083801b4d03ceb6465f7ae56002 | 3,646 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | f1qwase | 572,888,869 | false | {"Kotlin": 33268} | private data class Store(val stacks: Array<List<Char>>) {
fun move(from: Int, to: Int, count: Int) {
val movedCrates = stacks[from].take(count)
stacks[from] = stacks[from].drop(count)
stacks[to] = movedCrates + stacks[to]
}
val topCrates: List<Char>
get() = stacks.map { it.f... | 0 | Kotlin | 0 | 0 | 3fc7b74df8b6595d7cd48915c717905c4d124729 | 2,439 | aoc-2022 | Apache License 2.0 |
y2023/src/main/kotlin/adventofcode/y2023/Day17.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
import adventofcode.util.vector.Direction
import adventofcode.util.vector.Vec2
import java.util.*
fun main() {
Day17.solve()
}
object Day17 : AdventSolution(2023, 17, "<NAME>") {
override fun solvePartOne(input: String): Int =
solve(in... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,485 | advent-of-code | MIT License |
aoc/src/Parts.kt | aragos | 726,211,893 | false | {"Kotlin": 16232} | import java.io.File
fun main() {
// countPartNumbers()
countGearRatios()
}
private data class PartNumber(val value: Int, val location: IntRange) {
fun isAdjacentTo(i: Int) = i in (location.first-1)..(location.last+1)
}
private fun countGearRatios() {
var line1: Set<PartNumber>
var line2 = setOf<PartNumber... | 0 | Kotlin | 0 | 0 | 7bca0a857ea42d89435adc658c0ff55207ca374a | 2,177 | aoc2023 | Apache License 2.0 |
src/main/kotlin/day13/Day13.kt | jakubgwozdz | 571,298,326 | false | {"Kotlin": 85100} | package day13
import execute
import readAllText
sealed class Node : Comparable<Node>
data class NumberNode(val value: Int) : Node() {
override fun compareTo(other: Node): Int = when (other) {
is ListNode -> ListNode(listOf(this)).compareTo(other)
is NumberNode -> value.compareTo(other.value)
... | 0 | Kotlin | 0 | 0 | 7589942906f9f524018c130b0be8976c824c4c2a | 2,509 | advent-of-code-2022 | MIT License |
lib/src/main/kotlin/com/bloidonia/advent/day09/Day09.kt | timyates | 433,372,884 | false | {"Kotlin": 48604, "Groovy": 33934} | package com.bloidonia.advent.day09
import com.bloidonia.advent.readList
data class Point(val x: Int, val y: Int)
data class Cave(val width: Int, val z: IntArray) {
private fun p(pt: Point) = p(pt.x, pt.y)
private fun p(x: Int, y: Int) =
if (x < 0 || y < 0 || x >= width || y >= z.size / width) Int.MAX... | 0 | Kotlin | 0 | 1 | 9714e5b2c6a57db1b06e5ee6526eb30d587b94b4 | 1,882 | advent-of-kotlin-2021 | MIT License |
src/Day07.kt | Inn0 | 573,532,249 | false | {"Kotlin": 16938} | data class Dir(
val name: String,
val parent: Dir? = null,
val dirs: MutableList<Dir> = mutableListOf(),
val files: MutableList<File> = mutableListOf()
) {
fun allDirs(): List<Dir> = dirs + dirs.flatMap { it.allDirs() }
fun size(): Int = files.sumOf { it.size } + dirs.sumOf { it.size() }
}
data... | 0 | Kotlin | 0 | 0 | f35b9caba5f0c76e6e32bc30196a2b462a70dbbe | 1,668 | aoc-2022 | Apache License 2.0 |
src/Day05.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} |
class Stack {
private val data = mutableListOf<Char>()
fun push(e: Char) { data.add(e) }
fun pop() = data.removeLast()
fun top() = data.last()
fun moveTo(n: Int, to: Stack) {
List(n){ pop() }.reversed().forEach { to.push(it) }
}
}
private fun List<String>.toStacks(): List<Stack> {
... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 1,618 | aoc2022 | Apache License 2.0 |
src/Day02.kt | alexaldev | 573,318,666 | false | {"Kotlin": 10807} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf {
val (opp, me) = it.split(" ")
val oppM = OpponentMove.valueOf(opp)
val meM = MyMove.valueOf(me)
scorePart1(oppM, meM)
}
}
fun part2(input: List<String>): Int {
r... | 0 | Kotlin | 0 | 0 | 5abf10b2947e1c6379d179a48f1bdcc719e7062b | 2,773 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day09.kt | mvanderblom | 573,009,984 | false | {"Kotlin": 25405} | import kotlin.math.abs
operator fun Pair<Int,Int>.minus(other: Pair<Int, Int>): Pair<Int, Int> = this.first - other.first to this.second - other.second
fun main() {
val dayName = 9.toDayName()
val moves = mapOf(
"L" to { coords: Pair<Int, Int> -> coords.first - 1 to coords.second },
"R"... | 0 | Kotlin | 0 | 0 | ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690 | 4,877 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day13.kt | D000L | 575,350,411 | false | {"Kotlin": 23716} | sealed interface Packet {
infix fun compareTo(other: Packet): Int
}
class NumPacket(val num: Int) : Packet {
override fun toString(): String {
return num.toString()
}
override fun compareTo(other: Packet): Int {
return when (other) {
is NumPacket -> when {
n... | 0 | Kotlin | 0 | 0 | b733a4f16ebc7b71af5b08b947ae46afb62df05e | 2,481 | adventOfCode | Apache License 2.0 |
src/Day04.kt | aamielsan | 572,653,361 | false | {"Kotlin": 9363} | fun main() {
fun part1(input: List<String>): Int =
input
.map { line ->
line
.split(",")
.map(ElfCleaner::fromString)
.let { it[0].overlapsWithAllSection(it[1]) }
}
.sumOf(Boolean::toInt)
fun... | 0 | Kotlin | 0 | 0 | 9a522271bedb77496e572f5166c1884253cb635b | 1,719 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day20.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | import java.lang.Math.floorMod
import kotlin.math.sign
private class Solution20(input: List<String>) {
val numbersPart1 = input.mapIndexed { index, it -> Number(it.toLong(), moveIndex = index) }.toMutableList()
val numbersPart2 = input.mapIndexed { index, it -> Number(it.toLong() * 811589153L, moveIndex = ind... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 1,687 | aoc-2022 | Apache License 2.0 |
05/05.kt | Steve2608 | 433,779,296 | false | {"Python": 34592, "Julia": 13999, "Kotlin": 11412, "Shell": 349, "Cython": 211} | import java.io.File
private class Ocean(val diagonals: Boolean) {
data class Point(val x: Int, val y: Int)
private val counts: MutableMap<Point, Int> = HashMap()
val mostDangerous: Int
get() = counts.values.filter { it >= 2 }.size
private fun addPoint(point: Point) {
counts[point] = counts.getOrDefault(poin... | 0 | Python | 0 | 1 | 2dcad5ecdce5e166eb053593d40b40d3e8e3f9b6 | 2,480 | AoC-2021 | MIT License |
src/year2022/08/Day08.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`08`
import readInput
import transpose
fun main() {
fun createGrid(input: List<String>): List<List<Int>> {
return input.map {
it.split("")
.drop(1)
.dropLast(1)
.map { item -> item.toInt() }
}
}
fun <T> genericC... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 3,344 | KotlinAdventOfCode | Apache License 2.0 |
src/Day02.kt | armandmgt | 573,595,523 | false | {"Kotlin": 47774} | fun main() {
val scores = mapOf(
Pair("A", "X") to 4, Pair("A", "Y") to 8, Pair("A", "Z") to 3,
Pair("B", "X") to 1, Pair("B", "Y") to 5, Pair("B", "Z") to 9,
Pair("C", "X") to 7, Pair("C", "Y") to 2, Pair("C", "Z") to 6,
)
fun part1(input: List<String>): Int {
return input.... | 0 | Kotlin | 0 | 1 | 0d63a5974dd65a88e99a70e04243512a8f286145 | 1,197 | advent_of_code_2022 | Apache License 2.0 |
Advent-of-Code-2023/src/Day13.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | private const val AOC_DAY = "Day13"
private const val TEST_FILE = "${AOC_DAY}_test"
private const val INPUT_FILE = AOC_DAY
/**
* Finds the reflection line of a pattern by comparing the last line of the first part reversed with the first line
* of the second part.
*/
fun findReflectionLine(grid: List<String>): Int ... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 2,877 | Advent-of-Code-2023 | Apache License 2.0 |
src/Day02.kt | JanTie | 573,131,468 | false | {"Kotlin": 31854} | import kotlin.math.absoluteValue
enum class Symbol(val points: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3);
fun resultAgainst(other: Symbol): Result {
return if (other == this) Result.DRAW
else if (this.ordinal > other.ordinal) {
// this ordinal is higher
if ((this.or... | 0 | Kotlin | 0 | 0 | 3452e167f7afe291960d41b6fe86d79fd821a545 | 2,674 | advent-of-code-2022 | Apache License 2.0 |
untitled/src/main/kotlin/Day5.kt | jlacar | 572,845,298 | false | {"Kotlin": 41161} | class Day5(private val fileName: String) : AocSolution {
override val description: String get() = "Day 5 - Supply Stacks ($fileName)"
private val input = InputReader(fileName).rawLines.filter { it.isNotBlank() }
override fun part1() = Day5X(input).solve()
override fun part2() = Day5X(input).solve2()
}
... | 0 | Kotlin | 0 | 2 | dbdefda9a354589de31bc27e0690f7c61c1dc7c9 | 3,581 | adventofcode2022-kotlin | The Unlicense |
src/main/kotlin/days/Day10.kt | mstar95 | 317,305,289 | false | null | package days
import java.text.DecimalFormat
class Day10 : Day(10) {
override fun partOne(): Any {
val input = prepareInput(inputList)
val sorted = input.sorted()
val result = calculateDifferences(0, sorted, Differences(0, 0, 0))
println(result)
return result.one * result.... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 2,388 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/day13/TransparentOrigami.kt | Arch-vile | 433,381,878 | false | {"Kotlin": 57129} | package day13
import utils.Matrix
import utils.Point
import utils.read
fun main() {
solve().let { println(it) }
}
fun solve(): Pair<Int, String> {
val lines = read("./src/main/resources/day13Input.txt")
val points = lines.takeWhile { it.isNotEmpty() }
.map { it.split(",") }
.map { Point(i... | 0 | Kotlin | 0 | 0 | 4cdafaa524a863e28067beb668a3f3e06edcef96 | 1,888 | adventOfCode2021 | Apache License 2.0 |
y2023/src/main/kotlin/adventofcode/y2023/Day24.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
import adventofcode.util.collections.combinations
import java.math.BigDecimal
fun main() {
Day24.solve()
}
object Day24 : AdventSolution(2023, 24, "Never Tell Me The Odds") {
override fun solvePartOne(input: String): Any {
return solve... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 3,759 | advent-of-code | MIT License |
2023/src/day04/day04.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day04
import GREEN
import RESET
import printTimeMillis
import readInput
import kotlin.math.pow
data class Card(
val winning: List<String>,
val numbers: List<String>
) {
fun matches() = numbers.toSet().intersect(winning.toSet())
fun score(): Double {
val matches = matches()
va... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,629 | advent-of-code | Apache License 2.0 |
src/Day02.kt | allisonjoycarter | 574,207,005 | false | {"Kotlin": 22303} |
enum class Scoring(val value: Int) {
Lose(0),
Draw(3),
Win(6)
}
fun main() {
fun part1(input: List<String>): Int {
val shapes = mapOf(
'A' to 1, // rock
'B' to 2, // paper
'C' to 3 // scissors
)
val responses = mapOf(
... | 0 | Kotlin | 0 | 0 | 86306ee6f4e90c1cab7c2743eb437fa86d4238e5 | 2,339 | adventofcode2022 | Apache License 2.0 |
src/Day09.kt | iProdigy | 572,297,795 | false | {"Kotlin": 33616} | import kotlin.math.abs
import kotlin.math.sign
fun main() {
fun part1(input: List<String>) = run(input, 2)
fun part2(input: List<String>) = run(input, 10)
// test if implementation meets criteria from the description, like:
check(part1(readInput("Day09_test")) == 13)
check(part2(readInput("Day09_t... | 0 | Kotlin | 0 | 1 | 784fc926735fc01f4cf18d2ec105956c50a0d663 | 1,770 | advent-of-code-2022 | Apache License 2.0 |
src/day_7/kotlin/Day7.kt | Nxllpointer | 573,051,992 | false | {"Kotlin": 41751} | // AOC Day 7
data class File(val name: String, val size: Long)
data class Directory(
val name: String,
val parent: Directory?,
val subDirectories: MutableList<Directory> = mutableListOf(),
val files: MutableList<File> = mutableListOf()
) {
fun getOrCreateSubDirectory(name: String): Directory =
... | 0 | Kotlin | 0 | 0 | b6d7ef06de41ad01a8d64ef19ca7ca2610754151 | 2,606 | AdventOfCode2022 | MIT License |
src/Day02.kt | defvs | 572,381,346 | false | {"Kotlin": 16089} | import RPSResult.Companion.getShapeForResult
import Shapes.Companion.getResult
enum class RPSResult(val value: Int) {
Loss(0), Draw(3), Win(6);
companion object {
fun fromString(str: String) = when (str) {
"X" -> Loss
"Y" -> Draw
"Z" -> Win
else -> throw IllegalArgumentException("RPSResult fromString... | 0 | Kotlin | 0 | 1 | caa75c608d88baf9eb2861eccfd398287a520a8a | 1,825 | aoc-2022-in-kotlin | Apache License 2.0 |
facebook/y2019/qual/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2019.qual
import kotlin.random.Random
private fun solve(): String {
val (n, m) = readInts()
val requirements = List(m) { readInts().map { it - 1 } }
val ans = IntArray(n)
try {
construct(ans, -1, List(n) { it }, requirements)
} catch (_: IllegalArgumentException) {
return "Impossible"
}
r... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,199 | competitions | The Unlicense |
src/Day13.kt | djleeds | 572,720,298 | false | {"Kotlin": 43505} | import kotlinx.serialization.json.*
import java.util.*
import kotlin.math.max
fun <T, R> List<T>.zipWithPadding(other: List<R>): List<Pair<T?, R?>> =
buildList { for (i in 0 until max(this@zipWithPadding.size, other.size)) add(this@zipWithPadding.getOrNull(i) to other.getOrNull(i)) }
private fun JsonArray.zipWith... | 0 | Kotlin | 0 | 4 | 98946a517c5ab8cbb337439565f9eb35e0ce1c72 | 2,681 | advent-of-code-in-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Solution19.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
import adventOfCode.util.ints
import kotlin.math.max
import kotlin.math.min
typealias WorkflowCondition = Triple<String, Int, PairOf<Int>>
typealias WorkflowMap = Map<String, List<WorkflowCondition>>
object Sol... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 4,034 | Advent-of-Code-2023 | MIT License |
src/main/kotlin/dk/lessor/Day16.kt | aoc-team-1 | 317,571,356 | false | {"Java": 70687, "Kotlin": 34171} | package dk.lessor
fun main() {
val lines = readFile("day_16.txt")
val (ranges, myTicket, otherTickets) = parseTicketInformation(lines)
println(otherInvalidTickets(ranges, otherTickets))
println(determineTicketFields(ranges, myTicket, otherTickets))
}
fun parseTicketInformation(lines: List<String>): T... | 0 | Java | 0 | 0 | 48ea750b60a6a2a92f9048c04971b1dc340780d5 | 2,357 | lessor-aoc-comp-2020 | MIT License |
src/Day02.kt | ajmfulcher | 573,611,837 | false | {"Kotlin": 24722} | fun main() {
val scores = hashMapOf(
"A" to 1,
"X" to 1,
"B" to 2,
"Y" to 2,
"C" to 3,
"Z" to 3
)
fun calculateScore(line: String): Int {
val them = scores[line.substring(0,1)]!!
val us = scores[line.substring(2,3)]!!
return us + when ... | 0 | Kotlin | 0 | 0 | 981f6014b09e347241e64ba85e0c2c96de78ef8a | 1,572 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/de/consuli/aoc/year2022/days/Day11.kt | ulischulte | 572,773,554 | false | {"Kotlin": 40404} | package de.consuli.aoc.year2022.days
import de.consuli.aoc.common.Day
class Day11 : Day(11, 2022) {
override fun partOne(testInput: Boolean): Any {
return doMonkeyBusiness(testInput, 20, true)
}
override fun partTwo(testInput: Boolean): Any {
return doMonkeyBusiness(testInput, 10000, fals... | 0 | Kotlin | 0 | 2 | 21e92b96b7912ad35ecb2a5f2890582674a0dd6a | 3,114 | advent-of-code | Apache License 2.0 |
src/Day05.kt | dmstocking | 575,012,721 | false | {"Kotlin": 40350} | import java.util.Stack
fun main() {
val regex = "move (\\d+) from (\\d+) to (\\d+)".toRegex()
fun part1(input: List<String>): String {
val stacks = input
.first { it[1] == '1' }
.trim()
.split("\\s+".toRegex())
.last()
.toInt()
.l... | 0 | Kotlin | 0 | 0 | e49d9247340037e4e70f55b0c201b3a39edd0a0f | 2,999 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day14/Day14.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day14
import readInput
import java.lang.Integer.max
import java.lang.Integer.min
enum class Point {
AIR,
ROCK,
SAND;
}
fun Array<Array<Point>>.get(pos: Pair<Int, Int>) = this[pos.first][pos.second]
fun Array<Array<Point>>.set(pos: Pair<Int, Int>, value: Point) {
this[pos.first][pos.second] = ... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 3,071 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | dannyrm | 573,100,803 | false | null | typealias Forest = List<IntArray>
fun main() {
fun part1(input: List<String>): Int {
return input
.map { it.toCharArray() }
.map { IntArray(it.size) { i -> it[i].digitToInt() } }
.numberOfVisibleTrees()
}
fun part2(input: List<String>): Int {
return inpu... | 0 | Kotlin | 0 | 0 | 9c89b27614acd268d0d620ac62245858b85ba92e | 3,070 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day23.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import PointL
import readInput
import to2dCharArray
import java.util.*
object Day23 {
private class HikingMap(input: List<String>) {
private val map = input.to2dCharArray()
private val start = PointL(
x = map.withIndex().find { (x, column) -> column.first() == '.' }?.i... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 5,158 | adventOfCode | Apache License 2.0 |
src/day05/Day05.kt | gr4cza | 572,863,297 | false | {"Kotlin": 93944} | package day05
import component6
import readInput
fun main() {
fun readColumnCount(crateLines: List<String>) =
crateLines.last().split("\\s+".toRegex()).filter { it.isNotBlank() }.maxOf { it.toInt() }
fun createCrates(columnsCount: Int): List<MutableList<Char>> {
return (0 until columnsCount).... | 0 | Kotlin | 0 | 0 | ceca4b99e562b4d8d3179c0a4b3856800fc6fe27 | 3,154 | advent-of-code-kotlin-2022 | Apache License 2.0 |
2015/Day16/src/main/kotlin/Main.kt | mcrispim | 658,165,735 | false | null | import java.io.File
typealias Auntie = Map<String, Int>
typealias SearchAuntie = Map<String, Pair<String, Int>>
val aunties = mutableListOf<Auntie>()
fun readAunties(input: List<String>): List<Auntie> {
input.forEach { line ->
val auntie = mutableMapOf<String, Int>()
val properties = line.substri... | 0 | Kotlin | 0 | 0 | 2f4be35e78a8a56fd1e078858f4965886dfcd7fd | 2,952 | AdventOfCode | MIT License |
kotlin/src/main/kotlin/year2023/Day07.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
fun main() {
val input = readInput("Day07")
Day07.part1(input).println()
Day07.part2(input).println()
}
object Day07 {
fun part1(input: List<String>): Long {
val cardValues = { card: Char ->
when (card) {
'A' -> 14
'K' -> 13
... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 4,764 | advent-of-code | MIT License |
src/Day15.kt | Fedannie | 572,872,414 | false | {"Kotlin": 64631} | import kotlin.concurrent.fixedRateTimer
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
fun parseInput(input: List<String>): List<List<Coordinate>> {
return input.map {
it
.replace("Sensor at x=", "")
.replace(" y=", "")
.replace(": closest beacon i... | 0 | Kotlin | 0 | 0 | 1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f | 2,311 | Advent-of-Code-2022-in-Kotlin | Apache License 2.0 |
src/Day07.kt | KliminV | 573,758,839 | false | {"Kotlin": 19586} | fun main() {
fun part1(input:Map<String, Int>): Int {
return input.values
.filter { it < 100_000 }
.sum()
}
fun part2(input: Map<String, Int>): Int {
val occupied = input[""]
val toFree = occupied!! - 40_000_000
val result = input.values
... | 0 | Kotlin | 0 | 0 | 542991741cf37481515900894480304d52a989ae | 1,639 | AOC-2022-in-kotlin | Apache License 2.0 |
src/Day08.kt | Jaavv | 571,865,629 | false | {"Kotlin": 14896} | // https://adventofcode.com/2022/day/6
fun main() {
val testInput = readInput("Day08_test")
val input = readInput("Day08")
val grid = input.toString()
.removeSurrounding("[", "]")
.split(",")
.map { it.trim() }
.map { it.chunked(1) }
.map { it -> it.map { it.toInt()... | 0 | Kotlin | 0 | 0 | 5ef23a16d13218cb1169e969f1633f548fdf5b3b | 2,968 | advent-of-code-2022 | Apache License 2.0 |
src/Day13.kt | jorgecastrejon | 573,097,701 | false | {"Kotlin": 33669} | fun main() {
fun part1(input: List<String>): Int =
input.windowed(2, 3).mapNotNull {
(createPacket(it.first()) as Packet.Composed compare createPacket(it.last()) as Packet.Composed)
}.foldRightIndexed(0) { index, isRight, acc -> if (isRight) acc + (index + 1) else acc }
fun part2(i... | 0 | Kotlin | 0 | 0 | d83b6cea997bd18956141fa10e9188a82c138035 | 2,976 | aoc-2022 | Apache License 2.0 |
src/Day12.kt | pimtegelaar | 572,939,409 | false | {"Kotlin": 24985} | import java.util.*
fun main() {
data class Node(
val x: Int,
val y: Int,
val value: String
) {
var top: Node? = null
var bottom: Node? = null
var left: Node? = null
var right: Node? = null
val neighbors get() = mutableListOf(bottom, right, top, le... | 0 | Kotlin | 0 | 0 | 16ac3580cafa74140530667413900640b80dcf35 | 3,098 | aoc-2022 | Apache License 2.0 |
src/Day03.kt | bjornchaudron | 574,072,387 | false | {"Kotlin": 18699} | val priorities = ('a'..'z').mapPriorities(1) + ('A'..'Z').mapPriorities(27)
fun CharRange.mapPriorities(target: Int): Map<Char, Int> {
val delta = target - first.code
return associateWith { it.code + delta }
}
fun groupSacks(sacks: List<String>): List<Triple<Set<Char>, Set<Char>, Set<Char>>> {
val groupsS... | 0 | Kotlin | 0 | 0 | f714364698966450eff7983fb3fda3a300cfdef8 | 1,500 | advent-of-code-2022 | Apache License 2.0 |
src/day11/Day11.kt | maxmil | 578,287,889 | false | {"Kotlin": 32792} | package day11
import println
import readInput
data class Point(val x: Int, val y: Int)
typealias Grid = List<MutableList<Int>>
fun Grid.step(): Int {
this.forEachIndexed { rowIndex, row -> row.forEachIndexed { colIndex, _ -> this[rowIndex][colIndex]++ } }
val flashed = this.flatMapIndexed { rowIndex, row -... | 0 | Kotlin | 0 | 0 | 246353788b1259ba11321d2b8079c044af2e211a | 1,987 | advent-of-code-2021 | Apache License 2.0 |
src/Day07.kt | trosendo | 572,903,458 | false | {"Kotlin": 26100} | import utils.TreeNode
private data class Folder(
val path: String,
val name: String,
val files: MutableSet<File> = mutableSetOf()
) {
fun getFilesSize() = files.sumOf { it.size }
}
data class File(
val name: String,
val size: Int
)
fun main() {
fun TreeNode<Folder>.getTotalSizeOfFolder(... | 0 | Kotlin | 0 | 0 | ea66a6f6179dc131a73f884c10acf3eef8e66a43 | 3,963 | AoC-2022 | Apache License 2.0 |
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day16/Day16.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2022.day16
import eu.janvdb.aocutil.kotlin.readLines
//const val FILENAME = "input16-test.txt"
const val FILENAME = "input16.txt"
/*
* Part 2 gives the correct result for the full input, but not for the test input.
* Probably the elephant needs enough empty nodes to operate independently.
*/... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 2,213 | advent-of-code | Apache License 2.0 |
src/main/kotlin/days/aoc2022/Day12.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2022
import days.Day
import java.util.*
class Day12 : Day(2022, 12) {
override fun partOne(): Any {
return calculateShortestRoute(inputList)
}
override fun partTwo(): Any {
return calculateShortestRouteFromAnyAToEnd(inputList)
}
fun calculateShortestRouteFromAnyAT... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 3,548 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/Day07.kt | carloxavier | 574,841,315 | false | {"Kotlin": 14082} | // https://adventofcode.com/2022/day/7
fun main() {
fun firstPart(inputFilePath: String): Long {
val rootDir = FileTreeParser(readInput(inputFilePath)).parse()
val dirSizes = TreeClimber(rootDir).climb().values
return dirSizes.filter { it <= 100000 }.sum()
}
check(firstPart("Day07_t... | 0 | Kotlin | 0 | 0 | 4e84433fe866ce1a8c073a7a1e352595f3ea8372 | 3,720 | adventOfCode2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2023/day7/day7.kt | dzkoirn | 725,682,258 | false | {"Kotlin": 133478} | package adventofcode2023.day7
import adventofcode2023.readInput
import kotlin.time.measureTime
fun main() {
val input = readInput("day7")
println("Day 7")
val puzzle1Time = measureTime {
println("Puzzle 1: ${puzzle1(input)}")
}
println("Puzzle 1 took $puzzle1Time")
val puzzle2Time = m... | 0 | Kotlin | 0 | 0 | 8f248fcdcd84176ab0875969822b3f2b02d8dea6 | 3,549 | adventofcode2023 | MIT License |
src/2023/2023Day02.kt | bartee | 575,357,037 | false | {"Kotlin": 26727} |
data class GameResult (val ID: Int, val resultset: Map<String, Int>)
private fun calculateGameResult(it: String): GameResult{
val (gamestr, setsstr) = it.split(":")
var maxes = mutableMapOf<String, Int>()
// Create the set and the
val ID = gamestr.split(" ")[1].toInt()
val sets = setsstr.split(';')
for ... | 0 | Kotlin | 0 | 0 | c7141d10deffe35675a8ca43297460a4cc16abba | 2,288 | adventofcode2022 | Apache License 2.0 |
day10/src/main/kotlin/Main.kt | rstockbridge | 225,212,001 | false | null | import kotlin.math.atan2
fun main() {
val input = resourceFile("input.txt")
.readLines()
println("Part I: the solution is ${solvePartI(input)}.")
println("Part II: the solution is ${solvePartII(input)}.")
}
fun solvePartI(input: List<String>): Int {
return calculateBestLocationAndNumberDetect... | 0 | Kotlin | 0 | 0 | bcd6daf81787ed9a1d90afaa9646b1c513505d75 | 4,560 | AdventOfCode2019 | MIT License |
src/day03/Day03.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day03
import readInput
import readTestInput
private data class Rucksack(val items: String) {
val compartmentA: Compartment = items.take(items.length / 2)
val compartmentB: Compartment = items.drop(items.length / 2)
}
private typealias Compartment = String
private typealias Item = Char
private typealia... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 1,729 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | nikolakasev | 572,681,478 | false | {"Kotlin": 35834} | fun main() {
fun inputTo2DArray(input: String): Array<Array<Int>> {
return input.split("\n").map {
it.chunked(1).map { tree ->
tree.toInt()
}.toTypedArray()
}.toTypedArray()
}
fun part1(forest: Array<Array<Int>>): Int {
var count = 0
... | 0 | Kotlin | 0 | 1 | 5620296f1e7f2714c09cdb18c5aa6c59f06b73e6 | 2,481 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/Day2.kt | ivan-gusiev | 726,608,707 | false | {"Kotlin": 34715, "Python": 2022, "Makefile": 50} | import util.AocDay
import util.AocInput
import kotlin.math.max
typealias InputType = List<String>;
class Day2 : Runner {
data class CubeSet(val red: Int, val green: Int, val blue: Int) {
companion object {
fun parse(input: String): CubeSet {
var red = 0;
var gre... | 0 | Kotlin | 0 | 0 | 5585816b435b42b4e7c77ce9c8cabc544b2ada18 | 3,279 | advent-of-code-2023 | MIT License |
src/com/kingsleyadio/adventofcode/y2021/day03/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2021.day03
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
part1()
part2()
}
fun part1() {
var size = 0
var array = IntArray(0)
readInput(2021, 3).forEachLine { line ->
size++
if (array.isEmpty()) array = IntArray(line.length... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,710 | adventofcode | Apache License 2.0 |
src/Day16.kt | sebokopter | 570,715,585 | false | {"Kotlin": 38263} | fun main() {
val regex = """Valve (\w{2}) has flow rate=(\d+); tunnels? leads? to valves? ((\w{2})(, \w{2})*)""".toRegex()
fun mostPressure(nodes: List<Node>, currentValve: String, minutesLeft: Int, totalFlowRate: Int, valvesOpened: Set<String>): Int {
if (minutesLeft <= 0) return totalFlowRate
... | 0 | Kotlin | 0 | 0 | bb2b689f48063d7a1b6892fc1807587f7050b9db | 2,140 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | dmarmelo | 573,485,455 | false | {"Kotlin": 28178} | typealias Stack = Pair<Int, List<Char>>
private data class Move(
val quantity: Int,
val from: Int,
val to: Int
)
fun main() {
fun <T> List<List<T>>.transpose(): List<List<T>> {
return buildList {
for (column in this@transpose[0].indices) {
add(
b... | 0 | Kotlin | 0 | 0 | 5d3cbd227f950693b813d2a5dc3220463ea9f0e4 | 2,848 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | stcastle | 573,145,217 | false | {"Kotlin": 24899} | import java.util.LinkedList
import java.util.Queue
fun canGo(from: Char, to: Char): Boolean {
val tFrom = if (from == 'S') 'a' else from
val tTo = if (to == 'E') 'z' else to
return tTo.code - tFrom.code <= 1
}
fun getNeighbors(
row: Int,
col: Int,
grid: List<List<Char>>,
visited: List<List<Boole... | 0 | Kotlin | 0 | 0 | 746809a72ea9262c6347f7bc8942924f179438d5 | 3,602 | aoc2022 | Apache License 2.0 |
src/Day08.kt | Soykaa | 576,055,206 | false | {"Kotlin": 14045} | data class Quadtuple(
val a: Pair<Boolean, Int>,
val b: Pair<Boolean, Int>,
val c: Pair<Boolean, Int>,
val d: Pair<Boolean, Int>
)
private fun checkDirection(line: List<Int>, element: Int): Pair<Boolean, Int> {
var scenicScore = 0
for (currentElement in line) {
scenicScore++
if ... | 0 | Kotlin | 0 | 0 | 1e30571c475da4db99e5643933c5341aa6c72c59 | 2,034 | advent-of-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/mkuhn/aoc/Day11.kt | mtkuhn | 572,236,871 | false | {"Kotlin": 53161} | package mkuhn.aoc
import mkuhn.aoc.util.readInput
import mkuhn.aoc.util.splitList
fun main() {
val input = readInput("Day11")
println(day11part1(input))
println(day11part2(input))
}
fun day11part1(input: List<String>): Long {
val monkeys = Monkey.fromInputList(input)
(1 .. 20).forEach { round ->... | 0 | Kotlin | 0 | 1 | 89138e33bb269f8e0ef99a4be2c029065b69bc5c | 2,715 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day05.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2021
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
class Aoc2021Day05 {
companion object {
private const val POINT_SEPARATOR = " -> "
private const val NUMBER_SEPARATOR = ","
... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 3,586 | adventofcode | MIT License |
solutions/aockt/y2023/Y2023D11.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2023
import aockt.util.math.distinctPairs
import aockt.util.parse
import aockt.util.spacial.Point
import aockt.util.spacial.distanceTo
import io.github.jadarma.aockt.core.Solution
object Y2023D11 : Solution {
/**
* A galaxy expansion simulator.
* @param galaxies The apparent locations of... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 2,600 | advent-of-code-kotlin-solutions | The Unlicense |
src/Day13.kt | zsmb13 | 572,719,881 | false | {"Kotlin": 32865} | package day13
import readInputString
sealed interface PData : Comparable<PData>
data class PInt(val value: Int) : PData {
override fun toString() = value.toString()
override fun compareTo(other: PData): Int {
return when (other) {
is PInt -> value compareTo other.value
is PLi... | 0 | Kotlin | 0 | 6 | 32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35 | 3,021 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | GarrettShorr | 571,769,671 | false | {"Kotlin": 82669} | fun main() {
fun part1(input: List<String>): Int {
val THEIR_ROCK = "A"
val THEIR_PAPER = "B"
val THEIR_SCISSORS = "C"
val MY_ROCK = "X"
val MY_PAPER = "Y"
val MY_SCISSORS = "Z"
val scores = mutableListOf<Int>()
val rounds = input.map { it.split(" ")... | 0 | Kotlin | 0 | 0 | 391336623968f210a19797b44d027b05f31484b5 | 2,375 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/days/Day8.kt | butnotstupid | 433,717,137 | false | {"Kotlin": 55124} | package days
class Day8 : Day(8) {
override fun partOne(): Any {
val uniqueDigitsLength = setOf(2, 3, 4, 7)
return inputList.sumOf { input ->
val (_, display) = input.split(" | ")
display.split(" ").count { it.length in uniqueDigitsLength }
}
}
override fun... | 0 | Kotlin | 0 | 0 | a06eaaff7e7c33df58157d8f29236675f9aa7b64 | 1,866 | aoc-2021 | Creative Commons Zero v1.0 Universal |
kotlin/0973-k-closest-points-to-origin.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /**
Solution using min heap
*/
class Solution {
fun kClosest(points: Array<IntArray>, k: Int): Array<IntArray> {
val minHeap = PriorityQueue<IntArray> { a, b -> a[0] - b[0] }
val result = Array<IntArray>(k) { IntArray(2) { 0 } }
for (point in points) {
minHeap.add(
... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 3,090 | leetcode | MIT License |
src/Day15.kt | wlghdu97 | 573,333,153 | false | {"Kotlin": 50633} | import kotlin.collections.List
import kotlin.collections.any
import kotlin.collections.firstOrNull
import kotlin.collections.map
import kotlin.collections.maxOf
import kotlin.collections.minOf
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
private class Map constructor(val sensors: List<Sensor>) ... | 0 | Kotlin | 0 | 0 | 2b95aaaa9075986fa5023d1bf0331db23cf2822b | 3,227 | aoc-2022 | Apache License 2.0 |
src/day11/Day11.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day11
import readInput
import readTestInput
private data class Monkey(
val items: MutableList<Long>,
val operation: (initialWorryLevel: Long) -> Long,
val nextMonkey: (worryLevel: Long) -> Int,
)
private fun List<String>.toMonkeys(withStressRelief: Boolean): List<Monkey> {
val commonDivisor =... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 3,708 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day05.kt | tbilou | 572,829,933 | false | {"Kotlin": 40925} | fun main() {
val day = "Day05"
fun part1(input: String): String {
var parsedInput = parseInput(input)
parsedInput.instuctions.forEach { instruction ->
val fromStack = parsedInput.stacks.get(instruction.from - 1)
val toStack = parsedInput.stacks.get(instruction.to - 1)
... | 0 | Kotlin | 0 | 0 | de480bb94785492a27f020a9e56f9ccf89f648b7 | 2,863 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/icu/trub/aoc/day11/Universe.kt | dtruebin | 728,432,747 | false | {"Kotlin": 76202} | package icu.trub.aoc.day11
import icu.trub.aoc.util.Point
data class Universe(val galaxyIdToCoordinates: Map<Int, Point>) {
/**
* @return [Point] for galaxy with the provided id
*/
fun get(galaxyId: Int) = galaxyIdToCoordinates[galaxyId]!!
/**
* @return a new universe, with each empty lin... | 0 | Kotlin | 0 | 0 | 1753629bb13573145a9781f984a97e9bafc34b6d | 2,367 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinCostArrayEqual.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,719 | kotlab | Apache License 2.0 |
src/problems/day7/part2/part2.kt | klnusbaum | 733,782,662 | false | {"Kotlin": 43060} | package problems.day7.part2
import java.io.File
private const val inputFile = "input/day7/input.txt"
//private const val testFile = "input/day7/test.txt"
fun main() {
val scoreSum = File(inputFile).bufferedReader().useLines { sumScores(it) }
println("Sum of scores is $scoreSum")
}
private fun sumScores(line... | 0 | Kotlin | 0 | 0 | d30db2441acfc5b12b52b4d56f6dee9247a6f3ed | 3,364 | aoc2023 | MIT License |
src/year2022/day02/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2022.day02
import java.lang.RuntimeException
import readInput
private const val ROCK = 1
private const val PAPER = 2
private const val SCISSORS = 3
private const val WIN = 3
private const val DRAW = 2
private const val LOOSE = 1
fun main() {
fun combatA(abc:String, xyz:String): Int{
val a :... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 2,067 | adventOfCode | Apache License 2.0 |
src/day25/Day25.kt | spyroid | 433,555,350 | false | null | package day25
import readInput
import kotlin.system.measureTimeMillis
data class Area(val input: List<String>) {
private val width = input.first().length
private val height = input.size
data class Herd(val x: Int, val y: Int, val isHor: Boolean)
private var herds = buildList {
input.forEach... | 0 | Kotlin | 0 | 0 | 939c77c47e6337138a277b5e6e883a7a3a92f5c7 | 2,070 | Advent-of-Code-2021 | Apache License 2.0 |
src/main/kotlin/Day8.kt | Walop | 573,012,840 | false | {"Kotlin": 53630} | import java.io.InputStream
import kotlin.math.sqrt
class Day8 {
companion object {
private fun readTreeMap(input: InputStream?): String {
if (input == null) {
throw Exception("Input missing")
}
return input.reader().readLines().joinToString("")
}... | 0 | Kotlin | 0 | 0 | 7a13f6500da8cb2240972fbea780c0d8e0fde910 | 4,184 | AdventOfCode2022 | The Unlicense |
src/Day10.kt | niltsiar | 572,887,970 | false | {"Kotlin": 16548} | fun main() {
fun part1(input: List<String>): Int {
val inputs = parseInput(input)
val interestingCycles = listOf(20, 60, 100, 140, 180, 220)
return interestingCycles.sumOf { cycle -> cycle * calculateRegisterValue(inputs, cycle) }
}
fun part2(input: List<String>) {
val input... | 0 | Kotlin | 0 | 0 | 766b3e168fc481e4039fc41a90de4283133d3dd5 | 1,458 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day04.kt | binaryannie | 573,120,071 | false | {"Kotlin": 10437} | private const val DAY = "04"
private const val PART_1_CHECK = 2
private const val PART_2_CHECK = 4
fun inputToRanges(input:List<String>):List<List<Set<Int>>> {
return input
.map {
it
.split(',', '-')
.map { zone -> zone.toInt() }
.chunked(2)
... | 0 | Kotlin | 0 | 0 | 511fc33f9dded71937b6bfb55a675beace84ca22 | 1,319 | advent-of-code-2022 | Apache License 2.0 |
src/day18/Day18.kt | MaxBeauchemin | 573,094,480 | false | {"Kotlin": 60619} | package day18
import readInput
import java.util.*
data class Coordinate(
val x: Int,
val y: Int,
val z: Int
) {
val key = <KEY>"
fun surrounding(): List<Coordinate> {
return listOf(
Coordinate(x = this.x + 1, y = this.y, z = this.z),
Coordinate(x = this.x - 1, y = ... | 0 | Kotlin | 0 | 0 | 38018d252183bd6b64095a8c9f2920e900863a79 | 5,535 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | WaatzeG | 573,594,703 | false | {"Kotlin": 7476} | fun main() {
val testInput = readInput("Day03_input")
val solutionPart1 = part1(testInput)
println("Solution part 1: $solutionPart1")
val solutionPart2 = part2(testInput)
println("Solution part 2: $solutionPart2")
}
/**
* Total score of overlap
*/
private fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 324a98c51580b86121b6962651f1ba9eaad8f468 | 1,305 | advent_of_code_2022_kotlin | Apache License 2.0 |
src/Day05.kt | mlidal | 572,869,919 | false | {"Kotlin": 20582} | import java.util.*
data class Operation(val number: Int, val start: Int, val end: Int) {
}
fun parseCargo(input: List<String>) : List<Stack<Char>> {
val stacks = input.last().split(Regex(" \\d ")).map { Stack<Char>() }.toList()
input.subList(0, input.size - 1).forEach {
it.chunked(4).forEachIndexed {... | 0 | Kotlin | 0 | 0 | bea7801ed5398dcf86a82b633a011397a154a53d | 2,553 | AdventOfCode2022 | Apache License 2.0 |
src/Day07.kt | tomoki1207 | 572,815,543 | false | {"Kotlin": 28654} | import Entry.Dir
import Entry.File
sealed class Entry(open val parent: Dir?, open val name: String) {
abstract fun size(): Int
data class File(override val parent: Dir, override val name: String, val size: Int) : Entry(parent, name) {
override fun size() = size
}
data class Dir(override val pa... | 0 | Kotlin | 0 | 0 | 2ecd45f48d9d2504874f7ff40d7c21975bc074ec | 2,752 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Dec12.kt | karlstjarne | 572,529,215 | false | {"Kotlin": 45095} | object Dec12 {
fun a(): Int {
val matrix = getMatrix(true)
return dijkstrasDistance(matrix)
}
fun b(): Int {
val matrix = getMatrix(false)
return matrix.flatten()
.filter { it.height == 'a'.toInt() }
.map {
it.dist = 0
... | 0 | Kotlin | 0 | 0 | 9220750bf71f39f693d129d170679f3be4328576 | 3,409 | AoC_2022 | Apache License 2.0 |
src/main/kotlin/Day12.kt | N-Silbernagel | 573,145,327 | false | {"Kotlin": 118156} |
fun main() {
val input = readFileAsList("Day12")
println(Day12.part1(input))
println(Day12.part2(input))
}
typealias Elevation = Char
object Day12 {
fun part1(input: List<String>): Int {
return findBestPath(input, 'S')
}
fun part2(input: List<String>): Int {
return findBestPa... | 0 | Kotlin | 0 | 0 | b0d61ba950a4278a69ac1751d33bdc1263233d81 | 1,968 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | SeanDijk | 575,314,390 | false | {"Kotlin": 29164} | fun main() {
fun splitBackpackInCompartments(input: List<String>) = input.asSequence().map {
val half = it.length / 2
Pair(it.substring(0, half), it.substring(half, it.length))
}
fun score(char: Char): Int {
// Use the char code so we don't have to make a score table.
// A... | 0 | Kotlin | 0 | 0 | 363747c25efb002fe118e362fb0c7fecb02e3708 | 2,050 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem1626/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1626
/**
* LeetCode page: [1626. Best Team With No Conflicts](https://leetcode.com/problems/best-team-with-no-conflicts/);
*
* TODO : There is a solution which make use of Fenwick Tree (see [Ref.](https://leetcode.com/problems/best-team-with-no-conflicts/solution/));
*/
class ... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,335 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day05.kt | rweekers | 573,305,041 | false | {"Kotlin": 38747} | fun main() {
fun part1(
stacks: Map<Int, Stack<Char>>,
instructions: List<Instruction>
): String {
instructions
.forEach { instruction ->
repeat((1..instruction.times).count()) {
stacks[instruction.to]?.push(
stacks... | 0 | Kotlin | 0 | 1 | 276eae0afbc4fd9da596466e06866ae8a66c1807 | 3,303 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/com/github/solairerove/algs4/leprosorium/dynamic_programming/EqualSumArraysWithMinimumNumberOfOperations.kt | solairerove | 282,922,172 | false | {"Kotlin": 251919} | package com.github.solairerove.algs4.leprosorium.dynamic_programming
/**
* You are given two arrays of integers nums1 and nums2, possibly of different lengths.
* The values in the arrays are between 1 and 6, inclusive.
*
* In one operation, you can change any integer's value in any of the arrays to any value betwe... | 1 | Kotlin | 0 | 3 | 64c1acb0c0d54b031e4b2e539b3bc70710137578 | 2,088 | algs4-leprosorium | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.