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/Day02.kt | xNakero | 572,621,673 | false | {"Kotlin": 23869} | class Day02 {
private val rules: Map<String, Rules> = mapOf(
"A" to Rules("Y", "Z", "X"),
"B" to Rules("Z", "X", "Y"),
"C" to Rules("X", "Y", "Z")
)
private val points: Map<String, Int> = mapOf(
"X" to 1,
"Y" to 2,
"Z" to 3,
)
fun part1() = parseData... | 0 | Kotlin | 0 | 0 | c3eff4f4c52ded907f2af6352dd7b3532a2da8c5 | 1,400 | advent-of-code-2022 | Apache License 2.0 |
src/day02/Day02.kt | lpleo | 572,702,403 | false | {"Kotlin": 30960} | package day02
import readInput
enum class Symbol(val encode: String, val value: Int) {
ROCK("A,X", 1),
PAPER("B,Y", 2),
SCISSOR("C,Z", 3);
companion object {
fun getSymbolByEncode(encode: String): Symbol? {
return Symbol.values().firstOrNull { symbol: Symbol ->
sym... | 0 | Kotlin | 0 | 0 | 115aba36c004bf1a759b695445451d8569178269 | 2,530 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day14.kt | w8mr | 572,700,604 | false | {"Kotlin": 140954} | package aoc2022
import aoc.*
import aoc.parser.*
import java.util.*
class Day14 {
data class Line(val start: Coord, val end: Coord)
class State(val ls: List<Line>) {
fun build(): MutableMap<Int, TreeSet<Int>> {
val map = mutableMapOf<Int, TreeSet<Int>>()
ls.forEach { (start, e... | 0 | Kotlin | 0 | 0 | e9bd07770ccf8949f718a02db8d09daf5804273d | 3,016 | aoc-kotlin | Apache License 2.0 |
src/Day15.kt | dmstocking | 575,012,721 | false | {"Kotlin": 40350} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
data class Sensor(val x: Int, val y: Int, val bx: Int, val by: Int) {
val radius: Int = abs(bx - x) + abs(by - y)
companion object {
private val parseRegex = "Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d... | 0 | Kotlin | 0 | 0 | e49d9247340037e4e70f55b0c201b3a39edd0a0f | 4,221 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/day05/Day05.kt | TheSench | 572,930,570 | false | {"Kotlin": 128505} | package day05
import Lines
import groupByBlanks
import runDay
import toStack
import kotlin.collections.ArrayDeque
fun main() {
fun part1(input: List<String>): String = input.parsed()
.moveCrates { stacks, instruction ->
repeat(instruction.count) {
val container = stacks[instruc... | 0 | Kotlin | 0 | 0 | c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb | 2,654 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | Oktosha | 573,139,677 | false | {"Kotlin": 110908} | import kotlin.math.abs
import kotlin.math.sign
class Knot(var x: Int, var y: Int)
fun solve(input: List<String>, ropeLength: Int): Int {
val totalSteps = mutableMapOf("L" to 0, "R" to 0, "U" to 0, "D" to 0)
input.forEach { x ->
run {
val (direction, count) = x.split(" ")
totalS... | 0 | Kotlin | 0 | 0 | e53eea61440f7de4f2284eb811d355f2f4a25f8c | 1,649 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | A55enz10 | 573,364,112 | false | {"Kotlin": 15119} | import java.util.*
enum class Sign {ROCK, PAPER, SCISSORS}
fun main() {
fun part1(input: List<String>): Int {
val valueToSignP1 = mapOf("A" to Sign.ROCK, "B" to Sign.PAPER, "C" to Sign.SCISSORS)
val valueToSignP2 = mapOf("X" to Sign.ROCK, "Y" to Sign.PAPER, "Z" to Sign.SCISSORS)
val... | 0 | Kotlin | 0 | 1 | 8627efc194d281a0e9c328eb6e0b5f401b759c6c | 2,265 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | mlidal | 572,869,919 | false | {"Kotlin": 20582} | import java.lang.IllegalArgumentException
fun main() {
fun sumPriorities(input: List<Char>) : Int {
return input.sumOf { char: Char ->
val value = if (char.isUpperCase()) {
char.code - 'A'.code + 27
} else {
char.code - 'a'.code + 1
}
... | 0 | Kotlin | 0 | 0 | bea7801ed5398dcf86a82b633a011397a154a53d | 1,763 | AdventOfCode2022 | Apache License 2.0 |
src/year2021/03/Day03.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2021.`03`
import readInput
fun main() {
fun parse(input: List<String>): List<List<Boolean>> {
return input
.map { line ->
line.split("")
.filter { it.isNotBlank() }
.map { bitline ->
when (bitline) {
... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 2,737 | KotlinAdventOfCode | Apache License 2.0 |
src/Day03.kt | stevennoto | 573,247,572 | false | {"Kotlin": 18058} | fun main() {
fun part1(input: List<String>): Int {
// Split each string into 2 halves, find intersection = char that's in both halves, map to numeric value
return input.map {
val firstHalf = it.substring(0, it.length/2)
val secondHalf = it.substring(it.length/2)
f... | 0 | Kotlin | 0 | 0 | 42941fc84d50b75f9e3952bb40d17d4145a3036b | 1,190 | adventofcode2022 | Apache License 2.0 |
2023/src/main/kotlin/Day19.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import Day19.Rule.Outcome
import java.util.regex.Pattern
private enum class Category { X, M, A, S }
private typealias Part = Map<Category, Int>
private typealias PartRange = Map<Category, IntRange>
object Day19 {
fun part1(input: String): Int {
val system = parse(input)
val acceptedParts = system.parts.f... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 5,745 | advent-of-code | MIT License |
src/main/kotlin/Day7.kt | Ostkontentitan | 434,500,914 | false | {"Kotlin": 73563} | import kotlin.math.abs
fun puzzleDaySevenPartOne() {
val input = readInput(7)[0]
val initialPositions = parseCrabPositions(input)
val distances = calculateFuelConsumptions(initialPositions) { target, position -> abs(position - target) }
val (optimalPoint, leastFuelConsumption) = distances.first()
... | 0 | Kotlin | 0 | 0 | e0e5022238747e4b934cac0f6235b92831ca8ac7 | 1,335 | advent-of-kotlin-2021 | Apache License 2.0 |
src/Day08.kt | iownthegame | 573,926,504 | false | {"Kotlin": 68002} | import kotlin.math.max
fun main() {
fun parseTrees(input: List<String>): Array<List<Int>> {
var treeHeights = arrayOf<List<Int>>()
for (line in input) {
val heights = line.map { it.toString().toInt() }
treeHeights += heights
}
return treeHeights
}
f... | 0 | Kotlin | 0 | 0 | 4e3d0d698669b598c639ca504d43cf8a62e30b5c | 5,514 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | polbins | 573,082,325 | false | {"Kotlin": 9981} | fun main() {
fun part1(input: List<String>): Int {
var result = 0
for (s in input) {
val intList = s.split("-", ",")
.map { it.toInt() }
val left = intList[0] to intList[1]
val right = intList[2] to intList[3]
if (left.withinRange(right) || right.withinRange(left)) {
... | 0 | Kotlin | 0 | 0 | fb9438d78fed7509a4a2cf6c9ea9e2eb9d059f14 | 1,378 | AoC-2022 | Apache License 2.0 |
src/day02/Day02.kt | xxfast | 572,724,963 | false | {"Kotlin": 32696} | package day02
import day02.Hand.*
import day02.Outcome.*
import readLines
enum class Hand { Rock, Paper, Scissors; }
enum class Outcome { Loss, Draw, Win }
val Hand.score: Int get() = ordinal + 1
val Outcome.score: Int get() = ordinal * 3
val String.hand: Hand get() = when (this) {
"A", "X" -> Rock
"B", "Y" -> ... | 0 | Kotlin | 0 | 1 | a8c40224ec25b7f3739da144cbbb25c505eab2e4 | 1,752 | advent-of-code-22 | Apache License 2.0 |
src/Day11.kt | Jintin | 573,640,224 | false | {"Kotlin": 30591} | import java.lang.RuntimeException
fun main() {
data class Monkey(
val list: MutableList<MutableList<Long>>,
var op: String,
val extraOp: (Monkey, Long) -> Long,
val divide: Int,
val success: Int,
val fail: Int,
) {
var count: Long = 0
fun check(... | 0 | Kotlin | 0 | 2 | 4aa00f0d258d55600a623f0118979a25d76b3ecb | 3,000 | AdventCode2022 | Apache License 2.0 |
src/main/kotlin/com/anahoret/aoc2022/day16/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day16
import java.io.File
import kotlin.math.max
import kotlin.system.measureTimeMillis
data class Valve(val name: String, val flowRate: Long, var tunnels: List<String>)
fun parse(str: String): List<Valve> {
val regex = "Valve (.+) has flow rate=(\\d+); tunnels* leads* to valves* (.+... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 5,208 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/nibado/projects/advent/y2020/Day16.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2020
import com.nibado.projects.advent.*
object Day16 : Day {
private val ruleRegex = "([a-z ]+): ([0-9]+)-([0-9]+) or ([0-9]+)-([0-9]+)".toRegex()
private val values = resourceStrings(2020, 16)
private val rules = values[0].split("\n").map { it.matchGroups(ruleRegex).... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,763 | adventofcode | MIT License |
src/Day09.kt | ked4ma | 573,017,240 | false | {"Kotlin": 51348} | import kotlin.math.abs
/**
* [Day09](https://adventofcode.com/2022/day/9)
*/
private class Day09 {
data class Point(val x: Int, val y: Int)
enum class Direction(val dx: Int, val dy: Int) {
LEFT(-1, 0),
UP(0, -1),
RIGHT(1, 0),
DOWN(0, 1);
companion object {
... | 1 | Kotlin | 0 | 0 | 6d4794d75b33c4ca7e83e45a85823e828c833c62 | 2,588 | aoc-in-kotlin-2022 | Apache License 2.0 |
src/Day09.kt | zuevmaxim | 572,255,617 | false | {"Kotlin": 17901} | import java.awt.Point
import kotlin.math.abs
private val move = hashMapOf("U" to (0 to 1), "D" to (0 to -1), "L" to (-1 to 0), "R" to (1 to 0))
private fun List<String>.toSteps() = sequence {
val p = Point(0, 0)
for (line in this@toSteps) {
val (step, count) = line.split(" ")
val (dx, dy) = m... | 0 | Kotlin | 0 | 0 | 34356dd1f6e27cc45c8b4f0d9849f89604af0dfd | 1,362 | AOC2022 | Apache License 2.0 |
foundations/find-pair-with-given-sum-array/Main.kt | ivan-magda | 102,283,964 | false | null | import java.util.*
import kotlin.collections.HashMap
/**
* Naive Solution O(n^2).
* <p>
* Naive solution would be to considered every pair in a given array
* and return if desired sum is found.
*/
fun findPairWithGivenSumNaive(array: Array<Int>, sum: Int): Pair<Int, Int>? {
for (i in 0 until array.size) {
... | 0 | Kotlin | 0 | 2 | da06ec75cbd06c8e158aec86ca813e72bd22a2dc | 2,560 | introduction-algorithms | MIT License |
y2023/src/main/kotlin/adventofcode/y2023/Day08.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
import adventofcode.util.collections.cycle
import adventofcode.util.math.lcm
fun main() {
Day08.solve()
}
object Day08 : AdventSolution(2023, 8, "<NAME>") {
override fun solvePartOne(input: String): Int {
val (turns, graph) = parse(inp... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,327 | advent-of-code | MIT License |
y2019/src/main/kotlin/adventofcode/y2019/Day22.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2019
import adventofcode.io.AdventSolution
import adventofcode.util.SimpleParser
import java.math.BigInteger
import java.math.BigInteger.ONE
import java.math.BigInteger.ZERO
fun main() = Day22.solve()
object Day22 : AdventSolution(2019, 22, "Slam Shuffle") {
override fun solvePartOne(input... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,667 | advent-of-code | MIT License |
src/Day15.kt | arksap2002 | 576,679,233 | false | {"Kotlin": 31030} | import kotlin.math.abs
fun main() {
fun dist(x: Long, y: Long, x1: Long, y1: Long): Long = abs(x - x1) + abs(y - y1)
fun part1(input: List<String>): Long {
val arr = mutableListOf<Boolean>()
val n = 100_000_000
val y: Long = 2000000
for (i in -n..n) {
arr.add(false)... | 0 | Kotlin | 0 | 0 | a24a20be5bda37003ef52c84deb8246cdcdb3d07 | 2,910 | advent-of-code-kotlin | Apache License 2.0 |
src/day12/day12.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day12
import readInput
private fun parse(input: List<String>): Array<CharArray> {
val result = Array(input.size) { CharArray(input[0].length) }
for ((row, line) in input.withIndex()) {
for ((col, item) in line.withIndex()) {
result[row][col] = item
}
}
return resul... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 2,375 | aoc-2022 | Apache License 2.0 |
src/Day01.kt | richardmartinsen | 572,910,850 | false | {"Kotlin": 14993} | fun main() {
fun part1(input: List<String>): Int {
return input.foldIndexed(Pair(listOf<List<Int>>(), listOf<Int>())) { idx, acc, line ->
when {
idx + 1 == input.size -> {
Pair(acc.first + listOf(acc.second + line.toInt()), listOf())
}
... | 0 | Kotlin | 0 | 0 | bd71e11a2fe668d67d7ee2af5e75982c78cbe193 | 1,444 | adventKotlin | Apache License 2.0 |
src/Day12.kt | TinusHeystek | 574,474,118 | false | {"Kotlin": 53071} | import extensions.grid.*
class HeightNode(point: Point, val character: Char) : PathNode(point) {
var elevation: Int = 0
init {
elevation = when (character) {
'S' -> 'a' - 'a'
'E' -> 'z' - 'a'
else -> character - 'a'
}
}
override fun toString(): Strin... | 0 | Kotlin | 0 | 0 | 80b9ea6b25869a8267432c3a6f794fcaed2cf28b | 2,119 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day12.kt | vw-anton | 574,945,231 | false | {"Kotlin": 33295} | fun main() {
val lines = readFile("input/12.txt")
.map { it.toList() }
val graph = createGraph(lines)
part1(graph)
part2(graph, getAPositions(lines))
}
private fun part1(graph: Graph<String, Int>) {
val (_, value) = shortestPath(graph, "S", "E")
println("part1: $value")
}
private fun... | 0 | Kotlin | 0 | 0 | a823cb9e1677b6285bc47fcf44f523e1483a0143 | 2,615 | aoc2022 | The Unlicense |
src/day05/Day05.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day05
import readInput
typealias Day05InputType1 = Pair<Map<Int, List<Char>>, List<Triple<Int, Int, Int>>>
fun main() {
fun part1(input: Day05InputType1): String {
val crateStatus = input.first.mapValues { it.value.toMutableList() }
input.second.forEach {
for (i in 0 until i... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 2,249 | advent-of-code-2022 | Apache License 2.0 |
src/day15/fr/Day15_1.kt | BrunoKrantzy | 433,844,189 | false | {"Kotlin": 63580} | package day15.fr
import java.io.File
private fun readChars(): CharArray = readLn().toCharArray()
private fun readLn() = readLine()!! // string line
private fun readSb() = StringBuilder(readLn())
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fu... | 0 | Kotlin | 0 | 0 | 0d460afc81fddb9875e6634ee08165e63c76cf3a | 7,066 | Advent-of-Code-2021 | Apache License 2.0 |
scripts/Day12.kts | matthewm101 | 573,325,687 | false | {"Kotlin": 63435} | import java.io.File
import java.util.*
data class Pos(val x: Int, val y: Int) {
fun up() = Pos(x, y-1)
fun down() = Pos(x, y+1)
fun left() = Pos(x-1, y)
fun right() = Pos(x+1, y)
fun neighbors() = listOf(up(), down(), left(), right())
}
data class Grid(val raw: List<String>) {
val width = raw[... | 0 | Kotlin | 0 | 0 | bbd3cf6868936a9ee03c6783d8b2d02a08fbce85 | 2,762 | adventofcode2022 | MIT License |
src/Day05/Day05.kt | ctlevi | 578,257,705 | false | {"Kotlin": 10889} | data class Move(val amount: Int, val from: Int, val to: Int)
fun main() {
fun parseInput(input: List<String>): Pair<List<MutableList<Char>>, List<Move>> {
val blankLineIndex = input.indexOf("")
val paletCountIndex = blankLineIndex - 1
val paletCount = input[paletCountIndex].last().digitToI... | 0 | Kotlin | 0 | 0 | 0fad8816e22ec0df9b2928983713cd5c1ac2d813 | 2,418 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/days/Day10.kt | nuudles | 316,314,995 | false | null | package days
class Day10 : Day(10) {
fun calculate(list: List<Int>): Pair<Int, Int> {
var lastValue = 0
var oneCount = 0
var threeCount = 0
list
.sorted()
.forEach { value ->
when (value) {
lastValue + 1 -> oneCount++
... | 0 | Kotlin | 0 | 0 | 5ac4aac0b6c1e79392701b588b07f57079af4b03 | 1,927 | advent-of-code-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/aoc2023/Day13.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import readInput
import separateBy
import to2dCharArray
object Day13 {
private fun searchHorizontalReflectionLine(input: Array<CharArray>, smudges: Int = 0): Int? {
for (y in 1..<input.first().size) {
var distanceToCheck = 0
var remainingSmudges = smudges
... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 2,632 | adventOfCode | Apache License 2.0 |
src/Day04.kt | akijowski | 574,262,746 | false | {"Kotlin": 56887, "Shell": 101} | data class Assignment(val start: Int, val end: Int) {
fun fullyContains(other: Assignment): Boolean {
return start >= other.start && end <= other.end
}
fun overlaps(other: Assignment): Boolean {
return end >= other.start
}
}
fun toAssignments(ids: List<String>): Pair<Assignment, Assig... | 0 | Kotlin | 1 | 0 | 84d86a4bbaee40de72243c25b57e8eaf1d88e6d1 | 1,204 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day02.kt | margaret-lin | 575,169,915 | false | {"Kotlin": 9536} | package main.kotlin
import main.kotlin.Gesture.*
import main.kotlin.Outcome.*
/*
* this solution is credited to Sebastian from Advent of Code 2022 live stream
* */
fun main() {
println(part1())
println(part2())
}
private var input = readInput("day02_input").map {
val (a, b) = it.split(" ")
a[0] to... | 0 | Kotlin | 0 | 0 | 7ef7606a04651ef88f7ca96f4407bae7e5de8a45 | 2,094 | advent-of-code-kotlin-22 | Apache License 2.0 |
src/Day05.kt | defvs | 572,381,346 | false | {"Kotlin": 16089} | fun main() {
data class Move(val items: Int, val from: Int, val to: Int)
fun <T> List<List<T>>.transpose(): List<List<T>> {
// Check if the matrix is empty
if (this.isEmpty()) return emptyList()
// Get the number of rows and columns in the matrix
val numRows = this.size
val numCols = this.maxBy { it.si... | 0 | Kotlin | 0 | 1 | caa75c608d88baf9eb2861eccfd398287a520a8a | 2,398 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day05/Day05.kt | banshay | 572,450,866 | false | {"Kotlin": 33644} | package day05
import readInput
import java.util.*
fun main() {
fun part1(input: List<String>): String {
val (stacksUnparsed, instructionStrings) = input.splitAtEmpty()
val instructions = instructionStrings.map { it.parseInstruction() }
val cargoArea = stacksUnparsed.parseStacks()
... | 0 | Kotlin | 0 | 0 | c3de3641c20c8c2598359e7aae3051d6d7582e7e | 3,990 | advent-of-code-22 | Apache License 2.0 |
src/Day14.kt | punx120 | 573,421,386 | false | {"Kotlin": 30825} | import kotlin.math.max
fun main() {
class Waterfall(val map: Array<CharArray>, val depth: Int)
fun parseInput(input: List<String>): Waterfall {
val map = Array(1000) { CharArray(200) { '.' } }
var depth = 0
for (line in input) {
val l = line.split("->").map { it.trim().spl... | 0 | Kotlin | 0 | 0 | eda0e2d6455dd8daa58ffc7292fc41d7411e1693 | 3,197 | aoc-2022 | Apache License 2.0 |
2021/src/main/kotlin/com/trikzon/aoc2021/Day4.kt | Trikzon | 317,622,840 | false | {"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397} | package com.trikzon.aoc2021
fun main() {
val input = getInputStringFromFile("/day4.txt")
println(dayFourPartOne(input))
println(dayFourPartTwo(input))
}
fun dayFourPartOne(input: String): Int {
val lines = input.lines().filter { line -> line.isNotEmpty() }
val drawnNumbers = lines[0].split(',').... | 0 | Kotlin | 1 | 0 | d4dea9f0c1b56dc698b716bb03fc2ad62619ca08 | 2,976 | advent-of-code | MIT License |
src/adventofcode/day09/Day09.kt | bstoney | 574,187,310 | false | {"Kotlin": 27851} | package adventofcode.day09
import adventofcode.AdventOfCodeSolution
import kotlin.math.abs
fun main() {
Solution.solve()
}
object Solution : AdventOfCodeSolution<Int>() {
override fun solve() {
solve(9, 13, 36)
}
override fun part1TestFile(inputFile: String) = "${inputFile}_test-part1"
... | 0 | Kotlin | 0 | 0 | 81ac98b533f5057fdf59f08940add73c8d5df190 | 2,438 | fantastic-chainsaw | Apache License 2.0 |
src/day09/Day09.kt | palpfiction | 572,688,778 | false | {"Kotlin": 38770} | package day09
import readInput
import java.lang.IllegalArgumentException
import kotlin.math.absoluteValue
enum class Direction {
UP, DOWN, RIGHT, LEFT
}
fun String.toDirection(): Direction = when (this) {
"U" -> Direction.UP
"D" -> Direction.DOWN
"R" -> Direction.RIGHT
"L" -> Direction.LEFT
... | 0 | Kotlin | 0 | 0 | 5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7 | 4,005 | advent-of-code | Apache License 2.0 |
src/main/kotlin/io/pg/advent/day3/Main.kt | pgdejardin | 159,992,959 | false | null | package io.pg.advent.day3
import io.pg.advent.utils.FileUtil
fun main() {
val lines = FileUtil.loadFile("/day3.txt")
val inches = calculateFabricOverlap(lines)
println("Overlap inches: $inches")
val id = findIDofNotOverlapFabric(lines)
println("Fabric ID which is not overlapping: $id")
}
fun findIDofNotOve... | 0 | Kotlin | 0 | 0 | 259cb440369e9e0a5ce8fc522e672753014efdf2 | 2,039 | advent-of-code-2018 | MIT License |
src/main/kotlin/dev/paulshields/aoc/Day3.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 3: Binary Diagnostic
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.readFileAsStringList
fun main() {
println(" ** Day 3: Binary Diagnostic ** \n")
val diagnosticsReport = readFileAsStringList("/Day3DiagnosticsReport.txt")
val powerConsumption = decodePowerConsumptionFromD... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 2,813 | AdventOfCode2021 | MIT License |
app/src/y2021/day05/Day05HydrothermalVenture.kt | henningBunk | 432,858,990 | false | {"Kotlin": 124495} | package y2021.day05
import common.Answers
import common.AocSolution
import common.annotations.AoCPuzzle
import helper.Point
import kotlin.math.sign
typealias VentMap = List<MutableList<Int>>
fun main(args: Array<String>) {
Day05HydrothermalVenture().solveThem()
}
@AoCPuzzle(2021, 5)
class Day05HydrothermalVent... | 0 | Kotlin | 0 | 0 | 94235f97c436f434561a09272642911c5588560d | 1,929 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2022/day12/day12.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2022.day12
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val heightMap = parseHeightMap(inputFile.bufferedReader().readLines())
val elevationGraph = buildElevationGraph(heightMap)
println("Fewest steps from S to E: ${findFewe... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 2,703 | advent-of-code | MIT License |
src/day20/Day20.kt | maxmil | 578,287,889 | false | {"Kotlin": 32792} | package day20
import println
import readInput
fun String.value() = map { c -> if (c == '#') "1" else "0" }.joinToString("").toInt(2)
fun enhance(image: List<String>, enhancement: String): List<String> =
(1..image.size - 2).map { y ->
(1..image[0].length - 2).map { x ->
val square = image[y - 1... | 0 | Kotlin | 0 | 0 | 246353788b1259ba11321d2b8079c044af2e211a | 1,605 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/net/mguenther/adventofcode/day7/Day7.kt | mguenther | 115,937,032 | false | null | package net.mguenther.adventofcode.day7
/**
* @author <NAME> (<EMAIL>)
*/
data class Node(val id: String, val weight: Int, val successors: List<String>)
class Graph(nodes: List<Node>) {
private val nodes = nodes
fun inDegreeOf(fromId: String): Int {
return nodes
.filter { node ->... | 0 | Kotlin | 0 | 0 | c2f80c7edc81a4927b0537ca6b6a156cabb905ba | 2,156 | advent-of-code-2017 | MIT License |
src/Day09.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | import kotlin.math.abs
fun main() {
data class Position(val x: Int, val y: Int) {
operator fun plus(dir: String) = when (dir) {
"R" -> Position(x + 1, y)
"L" -> Position(x - 1, y)
"U" -> Position(x, y + 1)
else -> Position(x, y - 1)
}
}
data... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 2,428 | AdventOfCode2022 | Apache License 2.0 |
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day16/Day16.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2020.day16
import eu.janvdb.aocutil.kotlin.MatchFinder
import eu.janvdb.aocutil.kotlin.readGroupedLines
fun main() {
val (fields, tickets) = readInput()
part1(tickets, fields)
part2(tickets, fields)
}
private fun readInput(): Pair<List<TicketField>, List<Ticket>> {
val groupedLines = readGr... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,479 | advent-of-code | Apache License 2.0 |
src/Day02.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} | enum class RockPaperScissors(val score: Int)
{
ROCK(1),
PAPER(2),
SCISSORS(3);
fun winsOver(): RockPaperScissors {
return when(this) {
ROCK -> SCISSORS
PAPER -> ROCK
SCISSORS -> PAPER
}
}
fun losesTo(): RockPaperScissors {
return when... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 2,513 | 2022-advent | Apache License 2.0 |
src/Day07.kt | StephenVinouze | 572,377,941 | false | {"Kotlin": 55719} | data class Directory(
val name: String,
val head: String?,
val directories: MutableList<Directory> = mutableListOf(),
val files: MutableList<File> = mutableListOf(),
)
data class File(
val name: String,
val size: Int,
)
fun main() {
fun computeDirectorySize(directory: Directory): Int {
... | 0 | Kotlin | 0 | 0 | 11b9c8816ded366aed1a5282a0eb30af20fff0c5 | 2,568 | AdventOfCode2022 | Apache License 2.0 |
src/Day13.kt | schoi80 | 726,076,340 | false | {"Kotlin": 83778} | import kotlin.math.min
fun Input.split(): List<Input> {
val r = mutableListOf<Input>()
var curr = mutableListOf<String>()
for (l in this) {
if (l == "") {
r.add(curr)
curr = mutableListOf()
} else
curr.add(l)
}
r.add(curr)
return r
}
fun Stri... | 0 | Kotlin | 0 | 0 | ee9fb20d0ed2471496185b6f5f2ee665803b7393 | 1,659 | aoc-2023 | Apache License 2.0 |
src/Day05.kt | dustinlewis | 572,792,391 | false | {"Kotlin": 29162} | fun main() {
fun part1(input: List<String>): String {
// println(input)
// val splitIndex = input.indexOf("")
// val stackData = input.subList(0, splitIndex - 1)
// val transitionData = input.subList(splitIndex + 1, input.lastIndex)
val (transitionData, stackData) = input.partiti... | 0 | Kotlin | 0 | 0 | c8d1c9f374c2013c49b449f41c7ee60c64ef6cff | 2,767 | aoc-2022-in-kotlin | Apache License 2.0 |
2021/src/day05/Solution.kt | vadimsemenov | 437,677,116 | false | {"Kotlin": 56211, "Rust": 37295} | package day05
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.math.sign
fun main() {
fun part1(lines: List<Line>): Int {
val maxX = lines.maxOf { maxOf(it.first.first, it.second.first) }
val maxY = lines.maxOf { maxOf(it.first.second, it.second.second) }
val map = Array(maxX + 1) {
... | 0 | Kotlin | 0 | 0 | 8f31d39d1a94c862f88278f22430e620b424bd68 | 1,928 | advent-of-code | Apache License 2.0 |
src/main/kotlin/mkuhn/aoc/Day07.kt | mtkuhn | 572,236,871 | false | {"Kotlin": 53161} | package mkuhn.aoc
import mkuhn.aoc.util.readInput
import mkuhn.aoc.util.splitToPair
fun main() {
val input = readInput("Day07")
println(day07part1(input))
println(day07part2(input))
}
fun day07part1(input: List<String>): Int =
FileStructure().apply {
expandByCommands(input.associateCommandsTo... | 0 | Kotlin | 0 | 1 | 89138e33bb269f8e0ef99a4be2c029065b69bc5c | 2,609 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | NatoNathan | 572,672,396 | false | {"Kotlin": 6460} | enum class Play(val score: Int) {
Rock(1),
Paper(2),
Scissors(3);
fun getResult(player: Play): Result = when {
this == player -> Result.Draw
this == Rock && player != Paper -> Result.Win
this == Scissors && player != Rock -> Result.Win
this == Paper && player != Scissors... | 0 | Kotlin | 0 | 0 | c0c9e2a2d0ca2503afe33684a3fbba1f9eefb2b0 | 1,983 | advent-of-code-kt | Apache License 2.0 |
src/day03/Day03.kt | GrinDeN | 574,680,300 | false | {"Kotlin": 9920} | fun main() {
fun findSharedCharacter(pair: Pair<String, String>): Char {
return pair.first.toCharArray()
.filter { pair.second.contains(it) }
.toSet()
.toList()[0]
}
fun findSharedCharacter(triple: Triple<String, String, String>): Char {
return triple.fi... | 0 | Kotlin | 0 | 0 | f25886a7a3112c330f80ec2a3c25a2ff996d8cf8 | 1,317 | aoc-2022 | Apache License 2.0 |
2021/src/main/kotlin/days/Day8.kt | pgrosslicht | 160,153,674 | false | null | package days
import Day
import com.google.common.collect.Collections2
import kotlin.math.pow
class Day8 : Day(8) {
override fun partOne(): Int {
val easyDigits = setOf(2, 3, 4, 7)
return dataList.map {
val split = it.split("|")
split.last().split(" ")
}.sumOf { it.... | 0 | Kotlin | 0 | 0 | 1f27fd65651e7860db871ede52a139aebd8c82b2 | 1,501 | advent-of-code | MIT License |
src/Day05.kt | SeanDijk | 575,314,390 | false | {"Kotlin": 29164} | fun main() {
data class Command(val fromIndex: Int, val toIndex: Int, val times: Int)
data class Input(val stacks: List<ArrayDeque<String>>, val commands: List<Command>)
fun parseInput(input: List<String>): Input {
println("---------- Parse ----------")
// Split at the blank line
v... | 0 | Kotlin | 0 | 0 | 363747c25efb002fe118e362fb0c7fecb02e3708 | 3,233 | advent-of-code-2022 | Apache License 2.0 |
src/Day08/Day08.kt | Trisiss | 573,815,785 | false | {"Kotlin": 16486} | fun main() {
fun getNumberVisibleTree(listTree: List<Int>, element: Int, isRevert: Boolean = false): Int {
val range = if (isRevert) listTree.indices.reversed() else listTree.indices
var count = 0
for (i in range) {
if (listTree[i] >= element) {
return count + 1
... | 0 | Kotlin | 0 | 0 | cb81a0b8d3aa81a3f47b62962812f25ba34b57db | 4,540 | AOC-2022 | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2022/day13/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2022.day13
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val input = parseInput()
part1(input)
part2(input)
}
fun part1(input: List<*>) {
val result = input
.asSequence()
.windowed(2, 2)
.withIndex()
.sumOf { (i... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 2,607 | adventofcode | Apache License 2.0 |
src/Day11_MonkeyBusiness.kt | sherviiin | 575,114,981 | false | {"Kotlin": 14948} | fun main() {
check(10605 == findHighestChance(input = readInput("Day11_sample_data"), rounds = 20, divideBy3 = true).toInt())
println(findHighestChance(input = readInput("Day11"), rounds = 10000, divideBy3 = false))
}
fun findHighestChance(input: List<String>, rounds: Int, divideBy3: Boolean): Long {
val... | 0 | Kotlin | 0 | 1 | 5e52c1b26ab0c8eca8d8d93ece96cd2c19cbc28a | 3,942 | advent-of-code | Apache License 2.0 |
src/Day25.kt | RusticFlare | 574,508,778 | false | {"Kotlin": 78496} | import kotlin.math.max
private data class CarryOverState(val previousDigit: Int, val carryOver: Int) {
init {
require(previousDigit in Snafu.validDigits) { "Invalid previousValue <$previousDigit>" }
}
companion object {
val INITIAL = CarryOverState(previousDigit = 0, carryOver = 0)
}
}... | 0 | Kotlin | 0 | 1 | 10df3955c4008261737f02a041fdd357756aa37f | 2,877 | advent-of-code-kotlin-2022 | Apache License 2.0 |
lib/src/main/kotlin/com/bloidonia/advent/day18/Day18.kt | timyates | 433,372,884 | false | {"Kotlin": 48604, "Groovy": 33934} | package com.bloidonia.advent.day18
import com.bloidonia.advent.readList
import kotlin.math.ceil
import kotlin.math.floor
data class Num(val n: Int, val level: Int)
data class SnailFish(val values: List<Num>) {
operator fun plus(other: SnailFish) =
SnailFish(values.map { Num(it.n, it.level + 1) } + other.v... | 0 | Kotlin | 0 | 1 | 9714e5b2c6a57db1b06e5ee6526eb30d587b94b4 | 3,612 | advent-of-kotlin-2021 | MIT License |
src/year2023/day11/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day11
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import year2023.solveIt
fun main() {
val day = "11"
val expectedTest1 = 374L
val expectedTest2 = 82000210L
fun getDistance(
expansionItems: Set<Int>, factor: Long, a: Int, b: Int
): Long {
... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,757 | adventOfCode | Apache License 2.0 |
src/day02/Day02.kt | barbulescu | 572,834,428 | false | {"Kotlin": 17042} | package day02
import day02.Choice.*
import readInput
fun main() {
val total = readInput("day02/Day02")
.map { line -> line.split("\\s".toRegex()) }
.map { BattleV1(it) }
.sumOf { it.calculate() }
println("Total: $total")
val total2 = readInput("day02/Day02")
.map { line -... | 0 | Kotlin | 0 | 0 | 89bccafb91b4494bfe4d6563f190d1b789cde7a4 | 2,123 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/ru/glukhov/aoc/Day2.kt | cobaku | 576,736,856 | false | {"Kotlin": 25268} | package ru.glukhov.aoc
import java.io.BufferedReader
enum class Element(val value: String, val weight: Int) {
ROCK("A", 1), PAPER("B", 2), SCISSORS("C", 3);
companion object {
fun rockPaperScissors(row: String): Int = row.split(" ")
.let { Pair(Element.parse(it[0]), Element.parse(it[1])... | 0 | Kotlin | 0 | 0 | a40975c1852db83a193c173067aba36b6fe11e7b | 2,426 | aoc2022 | MIT License |
src/Day04.kt | hiteshchalise | 572,795,242 | false | {"Kotlin": 10694} | fun main() {
fun part1(input: List<String>): Int {
val fullyOverlappingRangeList = input.filter { line ->
val (first, second) = line.split(",")
val firstRange = first.split('-').map { it.toInt() }
val secondRange = second.split('-').map { it.toInt() }
// Check... | 0 | Kotlin | 0 | 0 | e4d66d8d1f686570355b63fce29c0ecae7a3e915 | 1,655 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day10/day10.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day10
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
const val CHARGING_OUTLET_JOLTAGE = 0
fun main() {
val bagAdapterJoltages = getResourceAsText("/day10/adapters-output-joltage.txt")
.split("\n")
.filter { it.isNotEmpty() }
.map { it.t... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 2,441 | advent-of-code-2020 | MIT License |
src/main/kotlin/com/ryanmoelter/advent/day02/RockPaperScissors.kt | ryanmoelter | 573,615,605 | false | {"Kotlin": 84397} | package com.ryanmoelter.advent.day02
import com.ryanmoelter.advent.day02.Result.*
import com.ryanmoelter.advent.day02.Shape.*
enum class Shape(val value: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
infix fun vs(other: Shape) = when (this) {
ROCK -> when (other) {
ROCK -> DRAW
PAPER -> LOSE
SCISS... | 0 | Kotlin | 0 | 0 | aba1b98a1753fa3f217b70bf55b1f2ff3f69b769 | 1,837 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | meierjan | 572,860,548 | false | {"Kotlin": 20066} | import Interval.Companion.parseLine
import java.util.*
import kotlin.io.path.createTempDirectory
data class CrateStack(
val stacks: List<Stack<Char>>
) {
companion object {
fun parse(text: List<String>): CrateStack {
val stackNumber = text.first().length / 4 + 1
val stacks = Mut... | 0 | Kotlin | 0 | 0 | a7e52209da6427bce8770cc7f458e8ee9548cc14 | 2,937 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/day7/day7Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day7
import lib.*
suspend fun main() {
setupChallenge().solveChallenge()
}
data class Hand(val cards: List<Int>, val bid: Long)
fun setupChallenge(): Challenge<List<Hand>> {
return setup {
day(7)
year(2023)
parser {
it.readLines()
.map { i... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 2,260 | AoC-2023-DDJ | MIT License |
src/twentytwo/Day05.kt | Monkey-Matt | 572,710,626 | false | {"Kotlin": 73188} | package twentytwo
import java.util.*
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInputLines("Day05_test")
println(part1(testInput))
check(part1(testInput) == "CMZ")
println(part2(testInput))
check(part2(testInput) == "MCD")
println... | 1 | Kotlin | 0 | 0 | 600237b66b8cd3145f103b5fab1978e407b19e4c | 2,672 | advent-of-code-solutions | Apache License 2.0 |
src/main/kotlin/d12/D12_1.kt | MTender | 734,007,442 | false | {"Kotlin": 108628} | package d12
import input.Input
fun parseInput(lines: List<String>): List<SpringRow> {
return lines.map { line ->
val parts = line.split(" ")
val springs = parts[0].trim { it == '.' }.replace("\\.+".toRegex(), ".")
val groups = parts[1].split(",").map { it.toInt() }
SpringRow(spring... | 0 | Kotlin | 0 | 0 | a6eec4168b4a98b73d4496c9d610854a0165dbeb | 2,013 | aoc2023-kotlin | MIT License |
src/Day01.kt | pmatsinopoulos | 730,162,975 | false | {"Kotlin": 10493} | val ZERO_TO_DIGITS = mapOf(
"one" to "1",
"two" to "2",
"three" to "3",
"four" to "4",
"five" to "5",
"six" to "6",
"seven" to "7",
"eight" to "8",
"nine" to "9"
)
private fun calibrate(s: String): Int = "${s.first { it.isDigit() }}${s.last { it.isDigit() }}".toInt()
private fun ca... | 0 | Kotlin | 0 | 0 | f913207842b2e6491540654f5011127d203706c6 | 1,296 | advent-of-code-kotlin-template | Apache License 2.0 |
src/Day07.kt | AlaricLightin | 572,897,551 | false | {"Kotlin": 87366} | fun main() {
fun part1(input: List<String>): Int {
val rootDir = fillTree(input)
return getSumSizesLess100K(rootDir)
}
fun part2(input: List<String>): Int {
val rootDir = fillTree(input)
return getDeletingDirSize(rootDir)
}
val testInput = readInput("Day07_test")
... | 0 | Kotlin | 0 | 0 | ee991f6932b038ce5e96739855df7807c6e06258 | 3,025 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/kr/co/programmers/P12978.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/411
class P12978 {
companion object {
const val INF = 500_001 // 최대 시간은 K + 1
}
fun solution(N: Int, road: Array<IntArray>, k: Int): Int {
if (N == 1) return 1
// 행노드 -> 열노드간의 거리를 2차원 배열에 담는다.
val gr... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 2,356 | algorithm | MIT License |
src/Day08.kt | petoS6 | 573,018,212 | false | {"Kotlin": 14258} | fun main() {
fun part1(lines: List<String>): Int {
val matrix = lines.map {
it.map { it.toString().toInt() }
}
var visible = 0
matrix.forEachIndexed { rowIndex, row ->
row.forEachIndexed { colIndex, tree ->
val leftVisible = row.filterIndexed { index, _ -> index < colIndex }.all... | 0 | Kotlin | 0 | 0 | 40bd094155e664a89892400aaf8ba8505fdd1986 | 2,052 | kotlin-aoc-2022 | Apache License 2.0 |
src/Day15.kt | iownthegame | 573,926,504 | false | {"Kotlin": 68002} | import java.math.BigDecimal
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
class Sensor(val position: Position, val beaconPosition: Position)
fun main() {
fun parseMap(input: List<String>): MutableList<Sensor> {
// Sensor at x=20, y=1: closest beacon is at x=15, y=3
val sens... | 0 | Kotlin | 0 | 0 | 4e3d0d698669b598c639ca504d43cf8a62e30b5c | 4,951 | advent-of-code-2022 | Apache License 2.0 |
src/Day16.kt | schoi80 | 726,076,340 | false | {"Kotlin": 83778} | import kotlin.math.max
enum class Direction {
LEFT, RIGHT, UP, DOWN
}
fun MutableInput<Char>.getDirection(i: Int, j: Int, d: Direction): List<Direction> {
return when (d) {
Direction.LEFT -> when (this[i][j]) {
'.', '-' -> listOf(d)
'\\' -> listOf(Direction.UP)
'/' ... | 0 | Kotlin | 0 | 0 | ee9fb20d0ed2471496185b6f5f2ee665803b7393 | 3,373 | aoc-2023 | Apache License 2.0 |
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day11/Day11.kt | jntakpe | 433,584,164 | false | {"Kotlin": 64657, "Rust": 51491} | package com.github.jntakpe.aoc2021.days.day11
import com.github.jntakpe.aoc2021.shared.Day
import com.github.jntakpe.aoc2021.shared.readInputLines
object Day11 : Day {
override val input = readInputLines(11)
.map { l -> l.toCharArray().map { it.digitToInt() } }
.flatMapIndexed { y, i -> i.mapInde... | 0 | Kotlin | 1 | 5 | 230b957cd18e44719fd581c7e380b5bcd46ea615 | 1,791 | aoc2021 | MIT License |
src/day9.kt | eldarbogdanov | 577,148,841 | false | {"Kotlin": 181188} | val di = listOf(-1, 0, 1, 0);
val dj = listOf(0, 1, 0, -1);
val dirMap: Map<String, Int> = mapOf("U" to 0, "R" to 1, "D" to 2, "L" to 3);
fun dist(a: Pair<Int, Int>, b: Pair<Int, Int>): Int {
return Math.max(Math.abs(a.first - b.first), Math.abs(a.second - b.second));
}
fun dist2(a: Pair<Int, Int>, b: Pair<Int, ... | 0 | Kotlin | 0 | 0 | bdac3ab6cea722465882a7ddede89e497ec0a80c | 2,158 | aoc-2022 | Apache License 2.0 |
src/y2023/Day06.kt | a3nv | 574,208,224 | false | {"Kotlin": 34115, "Java": 1914} | package y2023
import utils.readInput
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.sqrt
fun main() {
/**
* Equation speed * (time - speed) represents parabola. In this case upside-down U shaped because time - speed is a negative value.
*/
fun part1(input: List<String>): Long ... | 0 | Kotlin | 0 | 0 | ab2206ab5030ace967e08c7051becb4ae44aea39 | 2,156 | advent-of-code-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/com/github/fstaudt/aoc2021/day4/Day4.kt | fstaudt | 433,733,254 | true | {"Kotlin": 9482, "Rust": 1574} | package com.github.fstaudt.aoc2021.day4
import com.github.fstaudt.aoc2021.day4.Day4.BingoBoard.Companion.toBingoBoard
import com.github.fstaudt.aoc2021.shared.Day
import com.github.fstaudt.aoc2021.shared.readInputLines
fun main() {
Day4().run()
}
class Day4 : Day {
override val input = readInputLines(4)
... | 0 | Kotlin | 0 | 0 | f2ee9bca82711bc9aae115400ecff6db5d683c9e | 2,358 | aoc2021 | MIT License |
src/main/kotlin/dp/ConstructAVLT.kt | yx-z | 106,589,674 | false | null | package dp
import util.*
import kotlin.math.ceil
import kotlin.math.log2
// similar to ConstructBST, now we should construct an AVL Tree with its property
// that for every node, the height difference between its left child and right
// child should not differ by more than 1
// here we define a NULL node having heig... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,031 | AlgoKt | MIT License |
src/Day07.kt | wujingwe | 574,096,169 | false | null | class Day07 {
sealed class Node(val name: String, val parent: Node? = null) {
val children = mutableMapOf<String, Node>()
}
class Directory(name: String, parent: Node? = null) : Node(name, parent)
class File(name: String, val size: Int, parent: Node) : Node(name, parent)
fun parse(inputs... | 0 | Kotlin | 0 | 0 | a5777a67d234e33dde43589602dc248bc6411aee | 2,585 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day09/Day09.kt | banshay | 572,450,866 | false | {"Kotlin": 33644} | package day09
import readInput
fun main() {
fun part1(input: List<String>): Int {
val head = Head(0 to 0, null)
val tail = createRopeSegment(0 to 0, 1, head)!!
val visitedTailSpots = mutableSetOf<Pair<Int, Int>>()
val moves = input.map { it.toMove() }
val size = moves.maxO... | 0 | Kotlin | 0 | 0 | c3de3641c20c8c2598359e7aae3051d6d7582e7e | 5,135 | advent-of-code-22 | Apache License 2.0 |
2021/kotlin/src/main/kotlin/com/codelicia/advent2021/Day15.kt | codelicia | 627,407,402 | false | {"Kotlin": 49578, "PHP": 554, "Makefile": 293} | package com.codelicia.advent2021
import java.util.*
import kotlin.math.min
class Day15(val input: String) {
// Split the input string into a 2D grid of integers
private val grid = input.split("\n").map { it ->
it.toCharArray().map { it.digitToInt() }
}
private val maxRow = grid.lastIndex
... | 2 | Kotlin | 0 | 0 | df0cfd5c559d9726663412c0dec52dbfd5fa54b0 | 2,617 | adventofcode | MIT License |
src/main/kotlin/de/niemeyer/aoc2022/Day16.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | /**
* Advent of Code 2022, Day 16: Proboscidea Volcanium
* Problem Description: https://adventofcode.com/2022/day/16
*
* The searchPaths functions comes from <NAME> https://todd.ginsberg.com/post/advent-of-code/2022/day16
*/
package de.niemeyer.aoc2022
import de.niemeyer.aoc.utils.Resources.resourceAsList
import... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 4,969 | AoC-2022 | Apache License 2.0 |
src/year2015/day15/Day15.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2015.day15
import readInput
import kotlin.math.max
fun main() {
// test if implementation meets criteria from the description, like:
// val testInput = readInput("2015", "Day15_test")
// check(part1(testInput), 0)
// check(part2(testInput), 0)
val input = readInput("2015", "Day15")
p... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 3,244 | AdventOfCode | Apache License 2.0 |
src/Day15.kt | maciekbartczak | 573,160,363 | false | {"Kotlin": 41932} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.system.measureTimeMillis
fun main() {
fun part1(input: List<String>, height: Int): Int {
val (sensors, beacons) = parseInput(input)
val sensorRanges = sensors
.map { it.getSensorXRange(height) }
... | 0 | Kotlin | 0 | 0 | 53c83d9eb49d126e91f3768140476a52ba4cd4f8 | 4,026 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2022/Aoc2022Day02.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2022
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
class Aoc2022Day02 {
companion object {
private const val ROCK = "A"
private const val PAPER = "B"
private const val SC... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 2,541 | adventofcode | MIT License |
2017/src/ten/BalancingTowersChallenge.kt | Mattias1 | 116,139,424 | false | null | package ten
class BalancingTowersChallenge {
fun getBase(input: List<String>): BalancingTower {
val towers = buildTowerMap(input)
return getTowerBase(towers.values)
}
private fun buildTowerMap(input: List<String>): Map<String, BalancingTower> {
return input.map { BalancingTower(it)... | 0 | Kotlin | 0 | 0 | 6bcd889c6652681e243d493363eef1c2e57d35ef | 2,592 | advent-of-code | MIT License |
src/Day12.kt | wgolyakov | 572,463,468 | false | null | fun main() {
fun parse(input: List<String>): Triple<List<CharArray>, Pair<Int, Int>, Pair<Int, Int>> {
var start = 0 to 0
var stop = 0 to 0
val map = List(input.size) { CharArray(input[0].length) }
for (i in input.indices) {
for (j in input[i].indices) {
if (input[i][j] == 'S') {
start = i to j
... | 0 | Kotlin | 0 | 0 | 789a2a027ea57954301d7267a14e26e39bfbc3c7 | 2,735 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | slawa4s | 573,050,411 | false | {"Kotlin": 20679} | const val diskSpace = 70000000
const val unusedSpace = 30000000
const val maxDirectorySize = 100000
fun main() {
fun getInputGroupedByOperations(input: List<String>): List<List<String>> {
var indexOperation = 0
return input.groupBy {
if (it.startsWith("\$ cd") or it.startsWith("\$ ls"))... | 0 | Kotlin | 0 | 0 | cd8bbbb3a710dc542c2832959a6a03a0d2516866 | 2,805 | aoc-2022-in-kotlin | Apache License 2.0 |
src/aoc2021/Day05.kt | dayanruben | 433,250,590 | false | {"Kotlin": 79134} | package aoc2021
import readInput
import kotlin.math.abs
import kotlin.math.min
import kotlin.math.max
fun main() {
val (year, day) = "2021" to "Day05"
data class Point(val x: Int, val y: Int)
data class Line(val p1: Point, val p2: Point)
data class Info(val lines: List<Line>, val maxX: Int, val maxY... | 1 | Kotlin | 2 | 30 | df1f04b90e81fbb9078a30f528d52295689f7de7 | 2,891 | aoc-kotlin | Apache License 2.0 |
src/day09/Day09.kt | GrzegorzBaczek93 | 572,128,118 | false | {"Kotlin": 44027} | package day09
import readInput
import utils.withStopwatch
import kotlin.math.pow
import kotlin.math.sqrt
fun main() {
val testInput = readInput("input09_test")
withStopwatch { println(part1(testInput)) }
withStopwatch { println(part2(testInput)) }
val input = readInput("input09")
withStopwatch { ... | 0 | Kotlin | 0 | 0 | 543e7cf0a2d706d23c3213d3737756b61ccbf94b | 2,201 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | zuevmaxim | 572,255,617 | false | {"Kotlin": 17901} | import kotlin.math.max
private fun List<String>.toGrid(): List<IntArray> = this.map { line -> line.map { it.toString().toInt() }.toIntArray() }
private fun List<IntArray>.isVisible(i: Int, j: Int): Boolean {
val vertical = { x: Int -> this[x][j] < this[i][j] }
val horizontal = { x: Int -> this[i][x] < this[i]... | 0 | Kotlin | 0 | 0 | 34356dd1f6e27cc45c8b4f0d9849f89604af0dfd | 1,925 | AOC2022 | Apache License 2.0 |
src/day02/Day02.kt | ivanovmeya | 573,150,306 | false | {"Kotlin": 43768} | package day02
import readInput
enum class Figure(val score: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3)
}
enum class RoundScore(val score: Int) {
DRAW(3),
WIN(6),
LOOSE(0)
}
fun main() {
fun Char.toRoundScore() = when(this) {
'X' -> RoundScore.LOOSE
'Y' -> RoundScore.DRAW
... | 0 | Kotlin | 0 | 0 | 7530367fb453f012249f1dc37869f950bda018e0 | 2,929 | 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.