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/Day22.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
enum class Direction { UP, DOWN, LEFT, RIGHT; fun getRightDirection(): Direction { return when (this) { UP -> RIGHT DOWN -> LEFT RIGHT -> DOWN LEFT -> UP } } fun getLeftDirection(): Direction { return when (this) { RIG...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
16,100
advent-of-code
Apache License 2.0
src/main/kotlin/y2023/day04/Day04.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2023.day04 import kotlin.math.pow fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } data class ScratchCard( val winningNumber: Set<Int>, val drawnNumbers: Set<Int>, var copies: Int, ) fun input() = AoCGenerics.getInputLines...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,443
AdventOfCode
MIT License
src/main/kotlin/days/Day9.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days import kotlin.streams.toList class Day9 : Day(9) { override fun runPartOne(lines: List<String>): Any { // let's add a border of 9's val firstLine = lines[0] val width: Int = firstLine.length val heightMap: List<List<Int>> = buildHeightMap(lines) val lowSpots = ...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
3,393
aoc2021
Creative Commons Zero v1.0 Universal
advent-of-code/src/main/kotlin/DayThirteen.kt
pauliancu97
518,083,754
false
{"Kotlin": 36950}
typealias RelationshipsMap = Map<String, Map<String, Int>> class DayThirteen { data class Input( val mainPerson: String, val secondaryPerson: String, val happinessUnits: Int ) { companion object { val GAIN_REGEX = """([a-zA-Z]+) would gain (\d+) happiness units by si...
0
Kotlin
0
0
3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6
3,821
advent-of-code-2015
MIT License
src/Day09.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Move(val move: Char, val count: Int) data class Knot(var x: Int = 0, var y: Int = 0) fun parseInput(input: List<String>): List<Move> = input.map { val parts = it.split(" ") Move(parts[0].first(), parts[1].toInt()) ...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
1,728
kotlin_aoc_22
Apache License 2.0
src/Day04.kt
carotkut94
572,816,808
false
{"Kotlin": 7508}
fun prepare(input: List<String>): List<Pair<IntRange, IntRange>> { return input.map { line -> line.split(",") .let { (left, right) -> Pair( left.split("-").let { (first, last) -> first.toInt()..last.toInt() }, right.split("-").let { (first,...
0
Kotlin
0
0
ef3dee8be98abbe7e305e62bfe8c7d2eeff808ad
1,098
aoc-2022
Apache License 2.0
src/main/kotlin/Rope.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
import kotlin.math.abs import kotlin.math.sign fun main() { Rope.solve() } private object Rope { fun solve() { val moves = readInput() println("tail visited ${getTailPath(moves, 10).toSet().size}") } private fun readInput(): Sequence<Move> { return generateSequence(::readLine)...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
2,338
aoc2022
MIT License
src/Day09.kt
dizney
572,581,781
false
{"Kotlin": 105380}
import kotlin.math.abs import kotlin.math.sign object Day09 { const val EXPECTED_PART1_CHECK_ANSWER = 13 const val EXPECTED_PART2_CHECK_ANSWER = 1 const val TAIL_SIZE_PART_2 = 9 } enum class MovementDirection { U, D, L, R } fun main() { data class Location(val x: Int, val y: Int) { fun move(...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
3,250
aoc-2022-in-kotlin
Apache License 2.0
src/Day19.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File import java.util.PriorityQueue // Advent of Code 2022, Day 19: Not Enough Minerals private const val PATTERN = """Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay """ + """robot costs (\d+) ore. Each obsidian robot costs (\d+) ore and (\d+) clay. """ + """Each geode robot cos...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
8,508
AdventOfCode2022
Apache License 2.0
src/Day08.kt
BionicCa
574,904,899
false
{"Kotlin": 20039}
fun CharSequence.splitIgnoreEmpty(vararg delimiters: String): List<String> { return this.split(*delimiters).filter { it.isNotEmpty() } } fun main() { fun part1(input: List<String>): Int { val grid = input.map { it.splitIgnoreEmpty("").map { it.toInt() } } // Count the number of vis...
0
Kotlin
0
0
ed8bda8067386b6cd86ad9704bda5eac81bf0163
3,021
AdventOfCode2022
Apache License 2.0
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem023.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems import dev.mikeburgess.euler.common.properDivisors /** * Problem 23 * * A perfect number is a number for which the sum of its proper divisors is exactly equal to the * number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, * which means ...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
1,664
project-euler
MIT License
src/Day10.kt
rod41732
728,131,475
false
{"Kotlin": 26028}
fun main() { fun part1(input: List<String>): Int { val (startPos, graph) = parseGraph(input) val distance = bfs(startPos, graph) return distance.values.max() } fun part2(input: List<String>): Int { val (startPos, graph) = parseGraph(input) // prune graph so it conta...
0
Kotlin
0
0
05a308a539c8a3f2683b11a3a0d97a7a78c4ffac
4,889
aoc-23
Apache License 2.0
src/Day11.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { data class Monkey( val id: Int, val items: ArrayDeque<Long>, val operation: Char, val operationParam: String, val testParam: Int, val onSuccessTarget: Int, val onFailedTarget: Int, ) val inputLineRegex = """\d+""".toRegex() fun monke...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
2,709
aoc2022
Apache License 2.0
src/main/kotlin/problems/Day9.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day9(override val input: String) : Problem { override val number: Int = 9 private val board: Board = Board.fromStr(input) override fun runPartOne(): String { return board .localMinima() .sumOf { point -> point.riskLevel } .toString() }...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
2,740
AdventOfCode2021
MIT License
src/main/kotlin/day19/Day19.kt
Arch-vile
317,641,541
false
null
package day19 import java.io.File fun main(args: Array<String>) { val input = File("./src/main/resources/day19Input.txt") .readText() .split("\n\n") val rulesInput = input[0].split("\n") .map { if( it.take(2) == "8:" ) { "8: ( 42 ) +" } else if (it.take(3) == "11:") ...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
1,755
adventOfCode2020
Apache License 2.0
src/Day02.kt
gilbertw1
573,027,692
false
{"Kotlin": 5703}
data class Round(val elfPick: Selection, val selfPick: Selection) { fun result(): Result { return when (Pair(selfPick, elfPick)) { Pair(Selection.Rock, Selection.Paper) -> Result.Loss Pair(Selection.Rock, Selection.Scissors) -> Result.Win Pair(Selection.Paper, Selection.R...
0
Kotlin
0
0
e9e66d26125caa1bcf1af7a53b38f05ac55d77fd
3,176
aoc-2022-kotlin
Apache License 2.0
src/Day03.kt
Migge
572,695,764
false
{"Kotlin": 9496}
private fun part1(input: List<String>): Int = input .map { it.toList() } .map { it.chunked(it.size / 2) } .map { (a, b) -> (a.toSet() intersect b.toSet()).first() } .sumOf { alphabet.indexOf(it) + 1 } private fun part2(input: List<String>): Int = input .chunked(3) .map { it.map { str -> str.toS...
0
Kotlin
0
0
c7ca68b2ec6b836e73464d7f5d115af3e6592a21
715
adventofcode2022
Apache License 2.0
src/Day02.kt
alfr1903
573,468,312
false
{"Kotlin": 9628}
fun main() { operator fun String.component1() = this[0] operator fun String.component2() = this[1] operator fun String.component3() = this[2] fun part1(input: List<String>): Int { fun shapeScore(shape: Char) = (shape - 'X' + 1) fun resultScore(theirShape: Char, myShape: Char): Int { ...
0
Kotlin
0
0
c1d1fbf030ac82c643fa5aea4d9f7c302051c38c
1,521
advent-of-code-2022
Apache License 2.0
src/Day07.kt
daividssilverio
572,944,347
false
{"Kotlin": 10575}
fun main() { val logs = readInput("Day07_test") val root = Node( name = "/", parent = null, children = mutableMapOf(), isFolder = true, size = 0 ) var currentFolder: Node = root for (entry in logs) { when { entry.startsWith("$ cd") -> { ...
0
Kotlin
0
0
141236c67fe03692785e0f3ab90248064a1693da
2,870
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
sushovan86
573,586,806
false
{"Kotlin": 47064}
fun main() { fun Char.priority(): Int = when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> 0 } infix fun String.commonItemsIn(other: String) = if (this.isBlank() || other.isBlank()) { "" } else { (this.toSet() intersect other.toSe...
0
Kotlin
0
0
d5f85b6a48e3505d06b4ae1027e734e66b324964
1,206
aoc-2022
Apache License 2.0
src/Day16.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
fun main() { val day = 16 data class Valve(val id: Int, val flowRate: Int, val nextValves: List<Int>) fun prepareInput(input: List<String>): List<Valve> { val grouping = input.map { Regex("Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)") .matchEntire...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
3,777
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
fun main() { fun bagOverlap(contents: String): Char { val (first, second) = contents.chunked(contents.length / 2) return first.toSet().intersect(second.toSet()).first() } fun priority(item: Char): Int { return when (item) { in 'a'..'z' -> item - 'a' + 1 in '...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
1,171
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2022/Day11.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2022 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day11: AdventDay(2022, 11) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day11() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,004
adventofcode
MIT License
src/main/kotlin/days/Day8.kt
VictorWinberg
433,748,855
false
{"Kotlin": 26228}
package days class Day8 : Day(8) { override fun partOne(): Any { val input = inputList.map { it.split(" | ")[1].split(" ") } return input.sumOf { it.count { it.length == 2 || it.length == 4 || it.length == 3 || it.length == 7 } } } override fun partTwo(): Any { return inputList.su...
0
Kotlin
0
0
d61c76eb431fa7b7b66be5b8549d4685a8dd86da
2,081
advent-of-code-kotlin
Creative Commons Zero v1.0 Universal
src/Day15.kt
LauwiMeara
572,498,129
false
{"Kotlin": 109923}
import kotlin.concurrent.thread import kotlin.math.abs const val Y_PART_1 = 2000000 const val MAX_XY_PART_2 = 4000000 fun main() { fun part1(input: List<List<Point>>): Int { val xSensors = input.map{it.first()}.filter{it.y == Y_PART_1}.map{it.x} val xBeacons = input.map{it.last()}.filter{it.y == Y...
0
Kotlin
0
1
34b4d4fa7e562551cb892c272fe7ad406a28fb69
3,676
AoC2022
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day19/Structs.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day19 internal data class Input(val rules: Map<String, Rule>, val workflows: List<Workflow>) internal data class Rule(val name: String, val conditions: List<Condition>) internal sealed class Condition(open val nextRule: String) { data class Short(override val nextRule: String) : Condi...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
3,371
advent-of-code-2023
MIT License
src/day02/Day02.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day02 import utils.* val SHAPES = mapOf( 'A' to 'R', 'B' to 'P', 'C' to 'S', 'X' to 'R', 'Y' to 'P', 'Z' to 'S' ) const val ORDER = "RPS" const val RESULTS = "XYZ" fun getGames(input: List<String>): List<Pair<Char, Char>> = input.map { line -> Pair(line.first(), line.last()) } ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
1,381
AOC-2022-Kotlin
Apache License 2.0
app/src/main/kotlin/day11/Day11.kt
KingOfDog
433,706,881
false
{"Kotlin": 76907}
package day11 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 11 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay11Part1, ::solveDay11Part2) } fun solveDay11Part1(input: List<String>): Int {...
0
Kotlin
0
0
576e5599ada224e5cf21ccf20757673ca6f8310a
2,374
advent-of-code-kt
Apache License 2.0
src/Day03.kt
jandryml
573,188,876
false
{"Kotlin": 6130}
private fun part1(input: List<String>): Int { return input.asSequence() .map { it.chunked(it.length / 2) } .map { (a, b) -> a.find { it in b } } .sumOf { it?.toPriority() ?: 0 } } private fun part2(input: List<String>): Int { return input.chunked(3) .map { (a, b, c) -> a.find { ...
0
Kotlin
0
0
90c5c24334c1f26ee1ae5795b63953b22c7298e2
918
Aoc-2022
Apache License 2.0
src/day18/Day18.kt
gautemo
317,316,447
false
null
package day18 import shared.getLines fun calculate(input: String): Long{ var expression = input while(expression.contains(Regex("""\*|\+"""))){ val first = Regex("""\(?\d+ (\*|\+) \d+\)?""").find(expression) val toCalculate = first!!.value.replace("(", "").replace(")", "") val toReplac...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
2,384
AdventOfCode2020
MIT License
src/Day03.kt
colmmurphyxyz
572,533,739
false
{"Kotlin": 19871}
fun main() { val priorityOf: (Char) -> Int = { c -> val code = c.code if (code in 97..122) { // lower case letters code - 96 } else if (code in 65..90) { // upper case letters code - 38 } else throw IllegalArgumentException() // non-letter characters } ...
0
Kotlin
0
0
c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea
2,456
aoc-2022
Apache License 2.0
src/day03/Day03.kt
hamerlinski
572,951,914
false
{"Kotlin": 25910}
package day03 import readInput fun main() { val input = readInput("Day03", "day03") val inputIterator = input.iterator() fun part1(inputIterator: Iterator<String>) { var part1Solution = 0 inputIterator.forEach { val rucksack = Rucksack(it.toList()) val priority = P...
0
Kotlin
0
0
bbe47c5ae0577f72f8c220b49d4958ae625241b0
2,090
advent-of-code-kotlin-2022
Apache License 2.0
app/src/main/kotlin/day05/Day05.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day05 import common.InputRepo import common.readSessionCookie import common.solve import kotlin.math.abs import kotlin.math.max fun main(args: Array<String>) { val day = 5 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay05Part1, ::solveDay05Part2) } dat...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
2,314
AdventOfCode2021
Apache License 2.0
2022/src/day02/day02.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day02 import GREEN import RESET import printTimeMillis import readInput fun String.shape(startLetter: Char) = (this.first() - startLetter) + 1 // A == "Rock" -- B == "Paper" -- C == "Scissors" // lose == 0, draw == 3, win == 6 val shapeToScore = mapOf( "X" to mapOf("A" to 3, "B" to 0, "C" to 6), "Y" ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,498
advent-of-code
Apache License 2.0
src/main/aoc2020/Day16.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 class Day16(input: List<String>) { private data class Rule(val name: String, val r1: IntRange, val r2: IntRange) { fun validate(i: Int) = i in r1 || i in r2 } private data class Ticket(val fields: List<Int>, val invalidFields: List<Int>) { fun isValid() = invalidFields.isE...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,348
aoc
MIT License
src/Day16.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import java.util.PriorityQueue fun main() { class Valve(val name: String, val rate: Int, val accessible: MutableList<Valve>) { override fun toString() = name } class State(val currentValve: Valve, val openedValves: List<Valve>, val currentRate: Int, val currentOut: Int, val timeElapsed: Int) { ...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
6,209
aoc2022-kotlin
Apache License 2.0
src/Day09.kt
anisch
573,147,806
false
{"Kotlin": 38951}
import kotlin.math.abs private fun Vec.isTouching(o: Vec): Boolean = abs(x - o.x) <= 1 && abs(y - o.y) <= 1 private fun Vec.move(dir: String): Vec = when (dir) { "U" -> Vec(x, y + 1) "D" -> Vec(x, y - 1) "L" -> Vec(x - 1, y) "R" -> Vec(x + 1, y) else -> error("wtf???") } fun main() { fun ...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
2,245
Advent-of-Code-2022
Apache License 2.0
src/Day05.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import java.util.Stack fun main() { fun buildStacks(input: String): List<Stack<String>> { val rows = input.split("\n") val stacks = MutableList<Stack<String>>(rows.last().split(" \\d ".toRegex()).size) { Stack() } rows.reversed().drop(1).map { row -> row.chu...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
1,685
advent-of-code-2022
Apache License 2.0
src/Day04.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> val card = line.substringAfter(":").trim() val (winning, numbers) = card.split('|').map { it.trim().split("\\s+".toRegex()).map(String::toInt).toSet() } val intersections = numbers.intersect(...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
1,424
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day11.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { data class Monkey( val id: Int, val items: MutableList<Long> = mutableListOf(), var operation: (Long) -> Long = { it }, var testDivisor: Int = -1, var trueTarget: Int = -1, var falseTarget: Int = -1, var activity: Long = 0 ) { fun test...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
3,234
aoc-2022
Apache License 2.0
advent_of_code/2018/solutions/day_6_a.kt
migafgarcia
63,630,233
false
{"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343}
import java.io.File import java.lang.Math.abs fun main(args: Array<String>) { val ids = generateSequence(1) { it + 1 } val points = ids.zip(File(args[0]).readLines().map { line -> val s = line.split(",").map { it.trim() } Pair(s[0].toInt(), s[1].toInt()) }.asSequence()).toMap() val xM...
0
C++
3
9
82f5e482c0c3c03fd39e46aa70cab79391ed2dc5
1,298
programming-challenges
MIT License
src/main/Utils.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
import java.io.File import kotlin.math.abs /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() fun <T> List<T>.second() = this[1] fun <T, R> Pair<T, R>.reverse() = second to first data class Point(val x: Int, val y: Int) { fun neighbours(i...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
1,848
aoc-2022
Apache License 2.0
src/main/kotlin/com/jetbrains/typofixer/search/SearchResults.kt
bronti
96,321,194
false
{"Java": 321793, "Kotlin": 127493}
package com.jetbrains.typofixer.search import com.jetbrains.typofixer.search.distance.Distance import com.jetbrains.typofixer.search.index.CombinedIndex class SortedSearchResults( private val base: String, private val maxRoundedError: Int, wordsByMinPossibleError: Map<Int, Iterator<FoundWord>...
0
Java
0
0
33e436b815a86cc7980fbbd18ffda543fb895122
3,105
typofixer
Apache License 2.0
src/Day08.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import java.lang.Integer.max private fun heights(): List<List<Int>> { return readInput("Day08").map { it.map { c -> c.digitToInt() } } } private fun part1(h: List<List<Int>>): Int { val size = h.size val visible = Array(size) { i -> BooleanArray(size) { j -> i == 0 || i == size - 1 || ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
2,424
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day22_reactor_reboot/ReactorReboot.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day22_reactor_reboot import geom.Cuboid /** * Three-space math is easy when it's small! Those huge lines at the end imply * it's not going to stay that way, however. But whatever. Little looping, a bit * of filtering, a smidge of cringe, and done! * * Part two is simply "remove the 100x100x100 constraint...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,153
aoc-2021
MIT License
src/Day12/Day12.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day12 import checkAndPrint import get import getDirectNeighbouringIndices import indicesOf import measureAndPrintTimeMillis import readInput import java.math.BigInteger fun main() { fun prepareInput(input: List<String>): List<List<Int>> = input.map { line -> line.map { c -> c.code } } fun...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
5,018
AdventOfCode2022
Apache License 2.0
src/day14/Day14.kt
iulianpopescu
572,832,973
false
{"Kotlin": 30777}
package day14 import readInput private const val DAY = "14" private const val DAY_TEST = "day${DAY}/Day${DAY}_test" private const val DAY_INPUT = "day${DAY}/Day${DAY}" fun main() { fun part1(input: List<String>): Int { val lines = input.map { it.toPoints() } return Cave(lines).countSandUnits() ...
0
Kotlin
0
0
4ff5afb730d8bc074eb57650521a03961f86bc95
3,512
AOC2022
Apache License 2.0
src/main/kotlin/aoc2022/Day19.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput import kotlin.math.max private enum class Material { ORE, CLAY, OBSIDIAN, GEODE } private typealias Robot = Material private data class BuildCost(val type: Material, val amount: Int) private data class Blueprint(val id: Int, val costs: Map<Robot, List<BuildCost>>) { companion ob...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
6,970
adventOfCode
Apache License 2.0
src/Day07.kt
ChrisCrisis
575,611,028
false
{"Kotlin": 31591}
import java.lang.IllegalStateException const val MAX_DIR_SIZE = 100000 const val MIN_FREE_SPACE = 30000000 const val FILE_SYSTEM_TOTAL = 70000000 class FileTree{ val rootNode: Node = Node("/", null) fun findDirectoriesWhere(condition: (Node) -> Boolean): List<Node> { fun Node.getSmallerDirsRec(): Li...
1
Kotlin
0
0
732b29551d987f246e12b0fa7b26692666bf0e24
3,782
aoc2022-kotlin
Apache License 2.0
src/Day05.kt
esteluk
572,920,449
false
{"Kotlin": 29185}
fun main() { fun parseInitialState(input: List<String>): Array<String> { val rows = input.dropLast(1) val stackCount = input.last().trim().split(" ").last().toInt() val stacks = Array<String>(stackCount) { "" } for (i in rows.lastIndex downTo 0) { for (j in 0 until stack...
0
Kotlin
0
0
5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73
2,808
adventofcode-2022
Apache License 2.0
src/main/kotlin/day07/NoSpaceLeftOnDevice.kt
iamwent
572,947,468
false
{"Kotlin": 18217}
package day07 import readInput class NoSpaceLeftOnDevice( private val name: String ) { private fun readDirectories(): Directory { var root = Directory("/") var pwd: Directory? = root return readInput(name) .drop(1) .fold(root) { acc, line -> whe...
0
Kotlin
0
0
77ce9ea5b227b29bc6424d9a3bc486d7e08f7f58
2,280
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/be/swsb/aoc2021/day15/Day15.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day15 import be.swsb.aoc2021.common.Point import be.swsb.aoc2021.common.Point.Companion.at object Day15 { fun solve1(input: List<String>) : Int { val caveWalls = input.flatMapIndexed { idx, line -> line.mapIndexed { lineIndex, char -> CaveWall(Point.at(lineIndex, idx), ...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
2,623
Advent-of-Code-2021
MIT License
src/main/kotlin/kr/co/programmers/P72412.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers // https://github.com/antop-dev/algorithm/issues/374 class P72412 { fun solution(info: Array<String>, query: Array<String>): IntArray { val aggregate = mutableMapOf<String, MutableList<Int>>() // 경우의 수를 집계한다. for (i in info.indices) { dfs(aggregate, "",...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,762
algorithm
MIT License
src/Day04.kt
MisterTeatime
560,956,854
false
{"Kotlin": 37980}
fun main() { fun part1(input: List<String>): Int { return input .map {line -> line.split(",") .map { range -> IntRange( range.takeWhile { it != '-' }.toInt() ,range.takeLastWhile { it != '-' }.to...
0
Kotlin
0
0
8ba0c36992921e1623d9b2ed3585c8eb8d88718e
1,399
AoC2022
Apache License 2.0
src/Day12.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
fun main() { fun trouveLesVoisins(monArbre: MutableList<Noeud>, leNoeud: Noeud, largeur: Int, hauteur: Int) { val x = leNoeud.x val y = leNoeud.y val laLettre = leNoeud.letter val decalX = arrayOf(0, 0, -1, 1) val decalY = arrayOf(-1, 1, 0, 0) val decalSens = arrayOf...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
3,503
AD2022-01
Apache License 2.0
src/Day09.kt
KarinaCher
572,657,240
false
{"Kotlin": 21749}
fun main() { fun nextPosition(direction: String, position: Pair<Int, Int>): Pair<Int, Int> = when (direction) { "R" -> position.first + 1 to position.second "L" -> position.first - 1 to position.second "U" -> position.first to position.second + 1 "D" -> position.first to position.se...
0
Kotlin
0
0
17d5fc87e1bcb2a65764067610778141110284b6
2,523
KotlinAdvent
Apache License 2.0
src/Day03.kt
ghasemdev
572,632,405
false
{"Kotlin": 7010}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val part1 = line.substring(0 until line.length / 2) val part2 = line.substring(line.length / 2 until line.length) val intersect = part1.toSet().intersect(part2.toSet()).first() ...
0
Kotlin
0
1
7aa5e7824c0d2cf2dad94ed8832a6b9e4d36c446
1,314
aoc-2022-in-kotlin
Apache License 2.0
src/day02/Day02.kt
GrinDeN
574,680,300
false
{"Kotlin": 9920}
fun main() { val part1Map = mapOf<String, Int>( "A X" to 1 + 3, "B X" to 1 + 0, "C X" to 1 + 6, "A Y" to 2 + 6, "B Y" to 2 + 3, "C Y" to 2 + 0, "A Z" to 3 + 0, "B Z" to 3 + 6, "C Z" to 3 + 3 ).withDefault { 0 } fun part1(input: List<S...
0
Kotlin
0
0
f25886a7a3112c330f80ec2a3c25a2ff996d8cf8
1,063
aoc-2022
Apache License 2.0
src/Day03.kt
carotkut94
572,816,808
false
{"Kotlin": 7508}
fun main() { val input = readInput("Day03") val map = createMap() println(part1(input, map)) println(part2(input, map)) } fun part1(input:List<String>, map:Map<Char,Int>):Int{ return input .map { it.chunked(it.length / 2) } .sumOf { item -> map[item.map { it.toSet() }.reduce { left...
0
Kotlin
0
0
ef3dee8be98abbe7e305e62bfe8c7d2eeff808ad
842
aoc-2022
Apache License 2.0
src/Day09.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
import kotlin.math.abs data class Pos(var x: Int, var y: Int) { fun isFar(otherPos: Pos): Boolean { return abs(this.x - otherPos.x) > 1 || abs(this.y - otherPos.y) > 1 } } fun stepInDirection(pos: Pos, direction: String) { when (direction) { "U" -> { pos.y++ } ...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
2,847
advent-of-code
Apache License 2.0
src/Day25.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
fun main() { fun String.toSNAFU(): List<Int> { return this.map { when (it) { '=' -> -2 '-' -> -1 else -> it - '0' } }.reversed() } fun computeCarry(sum: Int): Pair<Int, Int> { var cur = sum % 5 var newC...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
1,738
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
georgiizorabov
573,050,504
false
{"Kotlin": 10501}
fun main() { fun read(input: List<String>): List<Pair<String, String>> { println(input) return input.map { str -> Pair( str.split(",")[0], str.split(",")[1] ) } } fun pred(it: Pair<String, String>): Boolean { val it1 = ...
0
Kotlin
0
0
bf84e55fe052c9c5f3121c245a7ae7c18a70c699
1,263
aoc2022
Apache License 2.0
2022/src/main/kotlin/com/github/akowal/aoc/Day07.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc class Day07 { private val root = loadFileTree() fun solvePart1(): Long { val dirs = findAll(root) { it.size <= 100000 } return dirs.sumOf { it.size } } fun solvePart2(): Long { val spaceToFree = 30000000 - (70000000 - root.size) val dirs =...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
2,415
advent-of-kode
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day05.kt
bacecek
574,824,698
false
null
data class Input( val crates: MutableList<MutableList<String>>, val commands: List<Command> ) data class Command( val howMuch: Int, val from: Int, val to: Int, ) fun main() { val inputRaw = loadInput("day05_input") println(""" part1 = ${part1(parseInput(inputRaw))} part2 =...
0
Kotlin
0
0
c9a99b549d97d1e7a04a1c055492cf41653e78bb
2,648
advent-of-code-2022
Apache License 2.0
src/Day03.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun priorityOf(char: Char): Int { val offset = when (char) { in 'a'..'z' -> 96 in 'A'..'Z' -> 38 else -> throw IllegalArgumentException("Unknown char $char") } return char.code - offset } fun part1(input: List<String>): Int = input.as...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
2,406
advent-of-code-2022
Apache License 2.0
src/Day03.kt
ThijsBoehme
572,628,902
false
{"Kotlin": 16547}
fun main() { fun valueOf(char: Char) = if (char.isUpperCase()) char.code - 'A'.code + 27 else char.code - 'a'.code + 1 fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val firstCompartment = rucksack.take(rucksack.length / 2) val secondCompa...
0
Kotlin
0
0
707e96ec77972145fd050f5c6de352cb92c55937
1,270
Advent-of-Code-2022
Apache License 2.0
src/Day04.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
data class ElfAssignment(val elf1: IntRange, val elf2: IntRange){ fun isContained(): Boolean = (elf1.contains(elf2.first) && elf1.contains(elf2.last)) || (elf2.contains(elf1.first) && elf2.contains(elf1.last)) fun isOverlapping(): Boolean = elf1.contains(elf2.first) || ...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
1,214
kotlin_aoc_22
Apache License 2.0
src/day02/Day02.kt
hamerlinski
572,951,914
false
{"Kotlin": 25910}
package day02 import readInput import java.lang.Exception fun main() { fun part1() { val input = readInput("Day02", "day02") val inputIterator = input.iterator() var solution = 0 inputIterator.forEach { val myTacticWeapon = Tactic(it[2].toString()) val match...
0
Kotlin
0
0
bbe47c5ae0577f72f8c220b49d4958ae625241b0
3,228
advent-of-code-kotlin-2022
Apache License 2.0
src/year2023/day18/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day18 import arrow.core.nonEmptyListOf import utils.Direction import utils.Point import utils.ProblemPart import utils.applyPickTheorem import utils.move import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 18) runAlgorithm( re...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,582
Advent-of-Code
Apache License 2.0
src/day15/day15.kt
felldo
572,762,654
false
{"Kotlin": 76496}
import kotlin.math.abs data class Sensor(var x: Long, var y: Long, var maxDistance: Long) data class Beacon(var x: Long, var y: Long) fun main() { fun findMaxDistance(s: Sensor, b: Beacon) { val xDist = abs(s.x - b.x) val yDist = abs(s.y - b.y) s.maxDistance = xDist + yDist } fun ...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
5,270
advent-of-code-kotlin-2022
Apache License 2.0
src/day12/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day12 import Coords import findAll import findFirst import get import getNeighbours import readInput import toCharMatrix fun main() { fun part1(input: List<String>): Int { return HeightMap.ofInput(input).minStepsFromStart() } fun part2(input: List<String>): Int { return HeightMap....
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
2,039
AoC-2022
Apache License 2.0
src/Day15.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
import kotlin.math.abs fun main() { open class Point(val x: Int, val y: Int) class Sensor(x: Int, y: Int, val beacon: Point) : Point(x, y) fun dist(a: Point, b: Point): Int { return abs(a.x - b.x) + abs(a.y - b.y) } fun canBeBeacon(pos: Point, sensors: List<Sensor>): Boolean { fo...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
2,793
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/Day7_2.kt
vincent-mercier
726,287,758
false
{"Kotlin": 37963}
import java.io.File import java.io.InputStream private val orderedCards = "AKQT98765432J".reversed() private class Hand2(val cards: String): Comparable<Hand2> { enum class HandType(val value: Int) { IMPOSSIBLE(-1), HIGH_CARD(0), ONE_PAIR(1), TWO_PAIR(2), THREE_OF_A_KIND(3), ...
0
Kotlin
0
0
53b5d0a0bb65a77deb5153c8a912d292c628e048
3,319
advent-of-code-2023
MIT License
src/main/kotlin/days/y2023/day09/Day09.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day09 import util.InputReader typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day09(val input: PuzzleInput) { val lines = input.map { line -> line.split(" ").map { it.toInt() } } fun partOne() = lines.sumOf { findSequence(it) } fun partTwo() = lines.sumOf ...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,227
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day19.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
import kotlin.math.max import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { println("start") readInput("day19_input") .mapIndexed { i, it -> val blueprint = it.substringAfter(":") .trim() .split(".") ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
3,580
advent22
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day19/Day19.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day19 import eu.janvdb.aocutil.kotlin.point3d.Point3D import eu.janvdb.aocutil.kotlin.point3d.Transformation import eu.janvdb.aocutil.kotlin.point3d.Transformation.Companion.ALL_ROTATIONS import eu.janvdb.aocutil.kotlin.readGroupedLines const val FILENAME = "input19.txt" fun main() { val s...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,470
advent-of-code
Apache License 2.0
src/main/kotlin/d18_Snailfish/Snailfish.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d18_Snailfish import util.Input import util.Output import kotlin.math.ceil import kotlin.math.floor fun main() { Output.day(18, "Snailfish") val startTime = Output.startTime() val homework = Input.parseLines(filename = "/input/d18_homework.txt") val sumMagnitude = homework .map { Sna...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
4,961
advent-of-code-2021
MIT License
src/day11/Day11.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day11 import readInput fun main() { part1() part2() } fun part1() = common(20) { this / 3 } fun part2() = common(10_000) { this % it.reduce { acc, l -> acc * l } } fun common(rounds: Int, keptManageable: Long.(MutableList<Long>) -> Long) { val input = readInput(11) val items = mutableListOf...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
1,878
advent-of-code-2022
Apache License 2.0
src/Day14.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
data class SandPosition(val x: Int, val y: Int) { companion object { fun of(string: String): SandPosition { val (x, y) = string.split(',').map { it.toInt() } return SandPosition(x, y) } } } fun main() { val day = 14 val start = SandPosition(500, 0) fun uno...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
3,362
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
paul-griffith
572,667,991
false
{"Kotlin": 17620}
fun main() { fun String.toRange(): IntRange { val (first, last) = split('-') return first.toInt()..last.toInt() } operator fun IntRange.contains(other: IntRange): Boolean { return other.first >= this.first && other.last <= this.last } fun part1(input: Sequence<String>): Int...
0
Kotlin
0
0
100a50e280e383b784c3edcf65b74935a92fdfa6
1,192
aoc-2022
Apache License 2.0
src/Day11.kt
esteluk
572,920,449
false
{"Kotlin": 29185}
sealed class Operation { data class Add(val value: Int): Operation() { override fun operate(on: Int): Int { return value + on } } data class Multiply(val value: Int): Operation() { override fun operate(on: Int): Int { return value * on } } obje...
0
Kotlin
0
0
5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73
4,610
adventofcode-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch0/Problem9.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch0 import dev.bogwalk.util.maths.isCoPrime import dev.bogwalk.util.maths.pythagoreanTriplet import kotlin.math.ceil import kotlin.math.sqrt import kotlin.math.hypot /** * Problem 9: Special Pythagorean Triplet * * https://projecteuler.net/problem=9 * * Goal: If there exists any Pythagorea...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
5,608
project-euler-kotlin
MIT License
src/Day05.kt
rafael-ribeiro1
572,657,838
false
{"Kotlin": 15675}
import java.util.* fun main() { fun part1(input: List<String>): String { val stacks = input.getStacks() input.getRearrangementProcedures().forEach { for (i in 1..it.quantity) { stacks[it.to].push(stacks[it.from].pop()) } } return stacks.messag...
0
Kotlin
0
0
5cae94a637567e8a1e911316e2adcc1b2a1ee4af
2,071
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/Problem14.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
/** * Longest Collatz sequence * * The following iterative sequence is defined for the set of positive integers: * * n → n/2 (n is even) * n → 3n + 1 (n is odd) * * Using the rule above and starting with 13, we generate the following sequence: * * 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 * It can be seen t...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,506
project-euler
MIT License
src/main/kotlin/days/day21/Day21.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day21 import days.Day import java.util.* class Day21 : Day() { override fun partOne(): Any { return solve(64) } override fun partTwo(): Any {//131 input size val x = (26501365L - 65) / 131 val values = arrayOf(solve(65), solve(65 + 131), solve(65 + 131 * 2)) v...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
3,859
advent-of-code_2023
The Unlicense
src/main/kotlin/com/sk/set4/452. Minimum Number of Arrows to Burst Balloons.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set4 private fun findMinArrowShots(points: Array<IntArray>): Int { if (points.isEmpty()) return 0 val sortedPoints = points.sortedWith( Comparator { o1, o2 -> if (o1[0] < o2[0]) -1 else if (o1[0] == o2[0]) 0 else 1 }...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,137
leetcode-kotlin
Apache License 2.0
src/chapter2/section5/ex8.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter2.section5 import edu.princeton.cs.algs4.In /** * 编写一段程序Frequency * 从标准输入读取一列字符串并按照字符串出现频率由高到低的顺序打印出每个字符串及其出现的次数 * * 解:读入字符串时,依次放入数组中, * 打印字符串时,先将字符串排序,统计每个字符串的重复次数,将字符串和重复次数关联成一个新对象, * 将新对象按重复次数倒序排序,打印字符串及出现次数 */ class Frequency { class Node(val item: String, var count: Int) : Comparable<No...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,766
Algorithms-4th-Edition-in-Kotlin
MIT License
app/src/main/java/org/watsi/uhp/utils/FuzzySearchUtil.kt
Meso-Health
227,514,539
false
null
package org.watsi.uhp.utils import org.apache.commons.text.similarity.LevenshteinDistance // This util is based on the answer in the following stackoverflow answer // https://stackoverflow.com/questions/5859561/getting-the-closest-string-match object FuzzySearchUtil { private val distanceAlg = LevenshteinDistance...
2
Kotlin
3
5
6e1da182073088f28230fe60a2e09d6f38aab957
3,502
meso-clinic
Apache License 2.0
2021/src/main/kotlin/day12_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.mapItems fun main() { Day12Imp.run() } object Day12Imp : Solution<Map<String, List<String>>>() { override val name = "day12" override val parser = Parser.lines.mapItems { val (start, end) = it.split('-', limit = 2) start to end }.map { ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,722
aoc_kotlin
MIT License
src/main/kotlin/Day5.kt
vw-anton
574,945,231
false
{"Kotlin": 33295}
import java.util.Stack fun main() { val (stack_raw, instructions_raw) = readFile("input/5-test.txt") .splitBy { it.isBlank() } .toPair() val stacks = parseStacks(stack_raw) val instructions = parseInstructions(instructions_raw) /* part1(stacks, instructions) var result = stack...
0
Kotlin
0
0
a823cb9e1677b6285bc47fcf44f523e1483a0143
2,284
aoc2022
The Unlicense
src/Day02.kt
psabata
573,777,105
false
{"Kotlin": 19953}
import Result.* import Symbol.* import java.lang.IllegalArgumentException import java.lang.IllegalStateException fun main() { fun part1(input: List<Round1>): Int { return input.sumOf { it.evaluate() } } fun part2(input: List<Round2>): Int { return input.sumOf { it.evaluate() } } ...
0
Kotlin
0
0
c0d2c21c5feb4ba2aeda4f421cb7b34ba3d97936
2,344
advent-of-code-2022
Apache License 2.0
src/Day10.kt
defvs
572,381,346
false
{"Kotlin": 16089}
class CPU { var regX: Int = 1 var pc: Int = 0 enum class InstructionType(val duration: Int) { ADDX(2), NOOP(1), } class Instruction(val instruction: InstructionType, vararg val args: Int) fun execute(instruction: Instruction) { when (instruction.instruction) { ...
0
Kotlin
0
1
caa75c608d88baf9eb2861eccfd398287a520a8a
2,504
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
JohannesPtaszyk
573,129,811
false
{"Kotlin": 20483}
fun main() { class Rope(knotCount: Int) { val knots: List<MutableList<Pair<Int, Int>>> = buildList { repeat(knotCount) { add(mutableListOf(Pair(0, 0))) } } fun getTailPositions(): Int = knots.last().distinctBy { it }.count() fun move(input: List<String>) { ...
0
Kotlin
0
1
6f6209cacaf93230bfb55df5d91cf92305e8cd26
3,515
advent-of-code-2022
Apache License 2.0
src/main/day20/day20.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day20 import readInput const val encryptionKey = 811589153L fun main() { val input = readInput("main/day20/Day20_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Long { val original = input.mapIndexed { index, s -> Num(originalPosition = index, number = s....
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
1,779
aoc-2022
Apache License 2.0
src/year2022/22/Day22.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`22` import kotlin.math.roundToInt import kotlin.math.sqrt import readInput /** * Point with x,y and side on cube */ data class Point( val x: Int, val y: Int, ) { var side: Int = -1 fun heuristic(): Int = x + y fun copyWithSide( x: Int = this.x, y: Int = this.y...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
19,008
KotlinAdventOfCode
Apache License 2.0
src/year2021/Day18.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readLines fun main() { fun input() = parseInput(readLines("2021", "day18")) fun testInput() = parseInput(readLines("2021", "day18_test")) check(part1(testInput()) == 4140) println("Part 1:" + part1(input())) check(part2(testInput()) == 3993) println("Part 2:" + part2...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
5,824
advent_of_code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistinctCharactersEqual.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
4,652
kotlab
Apache License 2.0
src/main/kotlin/aoc2023/Day16.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.* private data class Beam(val loc: Coordinates, val heading: Direction) { fun move(dir: Direction) = copy(loc=loc.move(dir), heading=dir) } private class Day16(input: List<String>): ArrayAsSurface(input) { fun rotate90_1(dir: Direction) = when(dir) { E -> N N -> E...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
4,074
aoc-2022-kotlin
Apache License 2.0
src/Day18.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val coordsList = getCoordsList(input) return getSidesCount(coordsList) } fun part2(input: List<String>): Int { val coordsList = getCoordsList(input) val minList: Array<Int> = Ar...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
3,929
AdventOfCode2022
Apache License 2.0
src/Day07.kt
hoppjan
433,705,171
false
{"Kotlin": 29015, "Shell": 338}
import kotlin.math.absoluteValue import kotlin.math.roundToInt fun main() { fun part1(input: IntArray) = input.sumOf { crabPosition -> crabPosition distanceTo input.cheapestPointByDistance() } fun part2(input: IntArray) = input.cheapestPointByFuelCosts() .possi...
0
Kotlin
0
0
04f10e8add373884083af2a6de91e9776f9f17b8
2,062
advent-of-code-2021
Apache License 2.0