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/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-03.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2022, "03-input") val testInput1 = readInputLines(2022, "03-test1") println("Part1:") part1(testInput1).print...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,032
advent-of-code
MIT License
src/main/day24/day24.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day24 import Point import day24.Blizzard.DOWN import day24.Blizzard.LEFT import day24.Blizzard.RIGHT import day24.Blizzard.UP import day24.Blizzard.WALL import readInput typealias Valley = Map<Point, List<Blizzard>> private val initialValley = readInput("main/day24/Day24").toValley() private val maxX = initi...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
4,166
aoc-2022
Apache License 2.0
src/Day04.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
val IntRange.size get() = if (last < first) { 0 } else { last - first + 1 } fun main() { fun calculateRangeIntersection(input: List<String>, intersectionPredicate: (Set<Int>, IntRange, IntRange) -> Boolean) = input.map { line -> val (firstRange,...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
1,122
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/Day04.kt
emanguy
573,113,840
false
{"Kotlin": 17921}
data class ElfRange(val start: Int, val stop: Int) { operator fun contains(other: ElfRange) = start <= other.start && stop >= other.stop infix fun partiallyIn(other: ElfRange) = start in other.start..other.stop || stop in other.start..other.stop } fun main() { fun parseInput(inputs: List<String>): List<Pai...
0
Kotlin
0
1
211e213ec306acc0978f5490524e8abafbd739f3
1,378
advent-of-code-2022
Apache License 2.0
packages/solutions/src/Day04.kt
ffluk3
576,832,574
false
{"Kotlin": 21246, "Shell": 85}
class Range { var min: Int var max: Int constructor(min: Int, max: Int) { this.min = min this.max = max } fun fullyContains(range: Range): Boolean { return (this.min <= range.min && this.max >= range.max) } fun overlaps(range: Range): Boolean { return (this...
0
Kotlin
0
0
f9b68a8953a7452d804990e01175665dffc5ab6e
1,452
advent-of-code-2022
Apache License 2.0
src/net/sheltem/aoc/y2023/Day07.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.count suspend fun main() { Day07().run() } class Day07 : Day<Long>(6440, 5905) { override suspend fun part1(input: List<String>): Long = input.map { line -> line.toPokerHand() }.sorted() .toWinnings() override suspend fun part2...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,385
aoc
Apache License 2.0
src/main/kotlin/Problem1.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.system.measureNanoTime /** * Multiples of 3 or 5 * * If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these * multiples is 23. * * Find the sum of all the multiples of 3 or 5 below 1000. * * https://projecteuler.net/problem=1 */ fun main...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,127
project-euler
MIT License
src/day05/Day05.kt
schrami8
572,631,109
false
{"Kotlin": 18696}
package day05 import readInput import java.util.LinkedList fun makeMovementsPart1(stacks: Array<LinkedList<Char>>, count: Int, from: Int, to: Int) { for (i in 1..count) { val toMove = stacks[from].first stacks[from].removeFirst() stacks[to].add(0, toMove) } } fun makeMovementsPart2(st...
0
Kotlin
0
0
215f89d7cd894ce58244f27e8f756af28420fc94
2,571
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/Day19.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
import Operator.GREATER_THAN import Operator.SMALLER_THAN import Status.* import utils.execFileByLine private enum class Status(value: String) { REJECTED("R"), ACCEPTED("A"), UNEVALUATED("") } private fun String.toStatus(): Status = when (this) { "A" -> ACCEPTED "R" -> REJECTED else -> UNEVALUATED } ...
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
7,241
aoc2023
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch3/Problem32.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.combinatorics.permutations import dev.bogwalk.util.strings.isPandigital /** * Problem 32: Pandigital Products * * https://projecteuler.net/problem=32 * * Goal: Find the sum of all products whose identity expression can be written as an * N-pandigital number. *...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,154
project-euler-kotlin
MIT License
src/main/kotlin/Skew.kt
nkkarpov
605,326,618
false
null
import kotlin.math.max fun Uniform(environment: DistributedEnvironment, m: Int, K: Int, T: Int): List<Int> { val cnt = Array(environment.n) { DoubleArray(K) { 0.0 } } val est = Array(environment.n) { DoubleArray(K) { 0.0 } } for (agent in 0 until K) { for (arm in 0 until environment.n) { ...
0
Kotlin
0
0
f0dd06b07bf9ebc5bc199c5280e63103189f5397
2,901
collab-comm
MIT License
src/main/kotlin/dev/bogwalk/batch8/Problem90.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch8 import dev.bogwalk.util.combinatorics.combinations /** * Problem 90: Cube Digit Pairs * * https://projecteuler.net/problem=90 * * Goal: Count the distinct arrangements of M cubes that allow for all square numbers [1, N^2] to * be displayed. * * Constraints: 1 <= M <= 3, 1 <= N < 10^...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,632
project-euler-kotlin
MIT License
main/src/day_3/App.kt
vmariano
434,035,667
false
{"Kotlin": 6341}
package day_3 class MatrixHelpers { companion object { fun reduceMatrix(readsMatrix: Array<Array<String>>, filterIndexes: MutableList<Int>): Array<Array<String>> { val newMatrix = Array(readsMatrix.size) { Array(filterIndexes.size) { "" } } val columnSize = readsMatrix.size ...
0
Kotlin
0
0
68f5be206070143f99c533252e8872e9e71481ef
4,002
advent-of-code-2021
MIT License
src/UsefulStuff.kt
eleung4
574,590,563
false
{"Kotlin": 7285}
fun main() { val input = readInput("numbers") println("Sum: ${sumAllNums(input)}") println("Min: ${findMin(input)}") println("Sum two smallest nums: ${findTwoSmallest(input)}") println("Number of words: ${countWords(wordInput)}") } fun sumAllNums(input: List<String>) : Int { // var total = 0 //...
0
Kotlin
0
0
9013be242f7c2a13f73b297eee9be60655b531ac
1,799
AdventOfCode
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/TravellingSalesman.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph Solution().test() data class DirectedWeightedGraphWithAdjMatrix(val matrix: Array<IntArray>) class Solution { fun test() { println("Test") val graph = DirectedWeightedGraphWithAdjMatrix( arrayOf( intArrayOf(0, 10, 15, 20), ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,371
KotlinAlgs
MIT License
src/Day01.kt
petitJAM
572,737,836
false
{"Kotlin": 4868, "Shell": 749}
fun main() { fun part1(input: List<String>): Int { return input .map(String::toIntOrNull) .fold(emptyList<List<Int>>()) { acc, i -> if (i == null) { acc + listOf(emptyList()) } else { acc.dropLast(1) + listOf((ac...
0
Kotlin
0
0
1965ded0e0ad09b77e001b1b87ac48f47066f479
1,208
adventofcode2022
Apache License 2.0
src/Day05.kt
derivz
575,340,267
false
{"Kotlin": 6141}
import java.util.ArrayDeque fun main() { fun getState(lines: String): Map<Int, ArrayDeque<Char>> { val state = mutableMapOf<Int, ArrayDeque<Char>>() val rules = lines.split("\n\n")[0].split("\n").reversed() val size = rules[0].length rules.map { it.padEnd(size) }.map { it.toCharArra...
0
Kotlin
0
0
24da2ff43dc3878c4e025f5b737dca31913f40a5
1,746
AoC2022.kt
Apache License 2.0
src/main/kotlin/com/adventofcode/Day06.kt
keeferrourke
434,321,094
false
{"Kotlin": 15727, "Shell": 1301}
package com.adventofcode private const val DAYS_TO_REPRODUCE = 7 private const val DAYS_TO_MATURE = 2 data class Generation(val distribution: Map<Int, Long>) { private fun fillGaps(sparseMap: Map<Int, Long>): Map<Int, Long> { val result = mutableMapOf<Int, Long>() for (i in 0..DAYS_TO_MATURE + DAYS_TO_REPRO...
0
Kotlin
0
0
44677c6ae0ba1a8a8dc80dfa68c17b9c315af8e2
1,661
aoc2021
ISC License
src/Day15Part2.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.abs import kotlin.math.max class Day15Part2 { companion object { fun main() { val regex = Regex("-?\\d+") val input = readInput("Day15_input") val multiplier = 4000000 val maxRange = multiplier val sensors = input.asSequence() ...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
2,701
aoc-2022
Apache License 2.0
src/y2023/Day13.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.split import util.timingStatistics import util.transpose object Day13 { private fun parse(input: List<String>): List<List<String>> { return input.split { it.isBlank() } } fun part1(input: List<String>): Int { val parsed = parse(input) ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,056
advent-of-code
Apache License 2.0
src/main/kotlin/io/github/aarjavp/aoc/day13/Day13.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day13 import io.github.aarjavp.aoc.readFromClasspath import io.github.aarjavp.aoc.split class Day13 { data class Location(val x: Int, val y: Int) class Grid { companion object { const val MISSING_CHAR = '.' const val DOT_CHAR = '#' } ...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
3,614
advent-of-code-2021
MIT License
src/main/kotlin/com/leonra/adventofcode/advent2023/day04/Day4.kt
LeonRa
726,688,446
false
{"Kotlin": 30456}
package com.leonra.adventofcode.advent2023.day04 import com.leonra.adventofcode.shared.readResource import kotlin.math.pow /** https://adventofcode.com/2023/day/4 */ private object Day4 { fun partOne(): Int { var sum = 0 readResource("/2023/day04/part1.txt") { line -> val winnersAndC...
0
Kotlin
0
0
46bdb5d54abf834b244ba9657d0d4c81a2d92487
2,404
AdventOfCode
Apache License 2.0
src/Day07.kt
Oli2861
572,895,182
false
{"Kotlin": 16729}
import kotlin.math.absoluteValue fun String.getDigits(): Int? { return this.filter { it.isDigit() }.toIntOrNull() } object CommandConstants { const val CD_COMMAND = "$ cd" const val DESTINATION_HOME = "/" const val DESTINATION_UP = ".." } fun evaluateLog(lines: List<String>): MutableMap<String, Long>...
0
Kotlin
0
0
138b79001245ec221d8df2a6db0aaeb131725af2
2,609
Advent-of-Code-2022
Apache License 2.0
src/day20/Code.kt
fcolasuonno
221,697,249
false
null
package day20 import java.io.File import java.util.* fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
1,616
AOC2016
MIT License
src/main/Day18.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day18 import utils.readInput fun readCubes(filename: String) = readInput(filename) .map { val (x, y, z) = it.split(",").map { it.toInt() } V3(x, y, z) } .toSet() typealias V3 = Triple<Int, Int, Int> fun Set<V3>.surface(): Int = flatMap(V3::neighbors).count...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
1,769
aoc-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2022/day16/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day16 import com.kingsleyadio.adventofcode.util.readInput import java.util.* fun main() { // nav(arrayOf("A", "B", "C")) val input = parseInput() part1priority(input) // part1a(input) // part2(input) } fun part1priority(input: Map<String, ValveInfo>) { ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
9,473
adventofcode
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2021/day13/day13.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day13 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val dotsMap = parseTransparentPaper(lines) val foldInstructions = parseFoldInstructions(lines) val foldedOnce =...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
2,628
advent-of-code
MIT License
src/main/kotlin/Day2.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
private val part1ExampleInput = """ A Y B X C Z """.trimIndent() private fun main() { println("day1") println() println("part1") assertEquals(part1(part1ExampleInput), 15) println(part1(readInputFile("day2_input.txt"))) // 17_189 println() println("part2") assertEquals(par...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
1,917
advent_of_code_2022
MIT License
src/main/kotlin/Day24.kt
clechasseur
258,279,622
false
null
import org.clechasseur.adventofcode2019.Direction import org.clechasseur.adventofcode2019.Pt import org.clechasseur.adventofcode2019.Pt3D object Day24 { private val input = """ ..##. ..#.. ##... #.... ...## """.trimIndent() private val initialState = State(input.lin...
0
Kotlin
0
0
187acc910eccb7dcb97ff534e5f93786f0341818
3,766
adventofcode2019
MIT License
src/Day22.kt
thpz2210
575,577,457
false
{"Kotlin": 50995}
private class Solution22(val input: List<String>) { companion object { fun wireAsBoard(board: Board) { fun wireRight(tile: Tile, map: Map<Pair<Int, Int>, Tile>): Tile { val newRight = map.getOrDefault( Pair(tile.x + 1, tile.y), board.tile...
0
Kotlin
0
0
69ed62889ed90692de2f40b42634b74245398633
4,770
aoc-2022
Apache License 2.0
src/day15/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day15 import util.Point import util.extractIntGroups import util.readInput import util.shouldBe import util.without import kotlin.math.abs fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1(10) shouldBe 26 testInput.part2(20) shouldBe 56000011 ...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
2,080
advent-of-code-2022
Apache License 2.0
src/Day03/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day03 import readInput fun main() { fun String.getCompartments() : Pair<String, String> { return Pair( this.slice(0 until this.length/2), this.slice(this.length/2 until this.length) ) } fun Pair<String, String>.getDuplicateCharacter() : Char { retu...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
1,975
aoc-2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day19.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.product import com.grappenmaker.aoc.splitInts import kotlin.math.max import kotlin.math.min fun PuzzleSet.day19() = puzzle { val costs = inputLines.map { l -> l.splitInts().drop(1).parseCosts() } fun RobotsC...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,690
advent-of-code
The Unlicense
src/Day04.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val ranges = it.split(",") val values = ranges.map { range -> range.split("-").map { number -> number.toInt() } } if ((values[0][0] >= values[1][0] && values[0][1] <= values[1][1]) || (values[1][0] >=...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
908
Advent-of-code
Apache License 2.0
src/Day04.kt
rinas-ink
572,920,513
false
{"Kotlin": 14483}
import java.lang.Integer.max import java.lang.Integer.min fun main() { fun containingSeg(pair: List<List<Int>>) = listOf(min(pair[0][0], pair[1][0]), max(pair[0][1], pair[1][1])) fun segLen(s: List<Int>) = s[1] - s[0] + 1 fun checkPair1(pair: List<List<Int>>) = (segLen(containingSeg(pair)) == max...
0
Kotlin
0
0
462bcba7779f7bfc9a109d886af8f722ec14c485
1,130
anvent-kotlin
Apache License 2.0
src/Day02.kt
patrickwilmes
572,922,721
false
{"Kotlin": 6337}
private fun translate(input: String): String = when (input) { "X" -> "A" "Y" -> "B" "Z" -> "C" else -> throw IllegalArgumentException("Not a valid RPS symbol") } private fun getScoreFor(rpc: String): Int = when (rpc) { "A" -> 1 // rock "B" -> 2 // paper "C" -> 3 // scissors else -> thro...
0
Kotlin
0
0
162c8f1b814805285e10ea4e3ab944c21e8be4c5
2,019
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/MinSpanningTreeKruskal.ws.kts
sjaindl
384,471,324
false
null
package com.sjaindl.kotlinalgsandroid.graph import java.util.* /* MinSpanningTreeKruskal - MST weighted undirected graph pick smallest edge (PQ) check for cycle (DFS or UnionFind) */ //https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/ class MinSpanningTreeKruskal<T> {...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
4,364
KotlinAlgs
MIT License
solutions/aockt/y2023/Y2023D07.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import aockt.y2023.Y2023D07.HandType.* import io.github.jadarma.aockt.core.Solution object Y2023D07 : Solution { /** A type of playing card for Camel Cards. */ private enum class Card(val symbol: Char) : Comparable<Card> { Joker('*'), Two('2'), Three('3'), ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
4,084
advent-of-code-kotlin-solutions
The Unlicense
src/Day05.kt
floblaf
572,892,347
false
{"Kotlin": 28107}
fun main() { data class Operation(val count: Int, val from: Int, val to: Int) val input = readInput("Day05") val blankLine = input.indexOfFirst { it.isEmpty() } val crates = input.take(blankLine - 1) .map { line -> line.chunked(4).map { it[1] } } .reversed() val cargo = buildList...
0
Kotlin
0
0
a541b14e8cb401390ebdf575a057e19c6caa7c2a
1,841
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day7.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
data class Bag( val tag: String, val count: Int ) fun day7ProblemReader(string: String): Map<String, List<Bag>> { return string .split("\n") .map { line -> line .replace("bags", "bag") .replace(".", "") .replace(" contain", ",") ...
0
Ruby
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
2,206
adventofcode_2020
MIT License
src/Day14.kt
hrach
572,585,537
false
{"Kotlin": 32838}
class Map { val points = mutableMapOf<Pair<Int, Int>, Char>() @Suppress("unused") fun print() { val minX = points.keys.minBy { it.first }.first val maxX = points.keys.maxBy { it.first }.first val minY = points.keys.minBy { it.second }.second val maxY = points.keys.maxBy { it...
0
Kotlin
0
1
40b341a527060c23ff44ebfe9a7e5443f76eadf3
2,881
aoc-2022
Apache License 2.0
app/src/main/kotlin/day05/Day05.kt
meli-w
433,710,859
false
{"Kotlin": 52501}
package day05 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 5 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay05Part1, ::solveDay05Part2) } fun solveDay05Part1(input: List<String>): Int = ...
0
Kotlin
0
1
f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1
3,488
AoC-2021
Apache License 2.0
src/main/kotlin/de/consuli/aoc/year2023/days/Day02.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2023.days import de.consuli.aoc.common.Day data class Cube(val color: String, val count: Int) class Day02 : Day(2, 2023) { private val limits = mapOf("blue" to 14, "green" to 13, "red" to 12) override fun partOne(testInput: Boolean): Int = getInput(testInput) ...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
1,677
advent-of-code
Apache License 2.0
src/main/kotlin/Problem23.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
/** * Non-abundant sums * * 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 that 28 is a perfect number. * * A number n is called deficient if the sum of its prop...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,712
project-euler
MIT License
src/main/kotlin/day07.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day07 : Solvable("07") { override fun solveA(input: List<String>): String { val positions = input.first().split(",").map(String::toInt) return binarySearch(positions, this::getFuel).toString() } override fun solveB(input: List<String>): String { val positions = input.first()....
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,534
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day21.kt
robert-iits
573,124,643
false
{"Kotlin": 21047}
import java.lang.IllegalArgumentException import java.math.BigInteger import kotlin.system.measureTimeMillis class Day21 { fun part1(input: List<String>): BigInteger { val monkeys = parseInputToMonkeys(input) val root = getMonkey("root", monkeys) while (root.number == null) { m...
0
Kotlin
0
0
223017895e483a762d8aa2cdde6d597ab9256b2d
3,654
aoc2022
Apache License 2.0
src/Day07.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
private fun create(a: String, b: String): Node { return if (a == "dir") Node(name = b, inside = hashMapOf()) else Node(name = b, size = a.toInt()) } private class Node( val name: String, val size: Int? = null, val inside: MutableMap<String, Node>? = null, ) { fun advance(name: String): Node { ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
2,767
advent-of-code-2022
Apache License 2.0
src/day9/Code.kt
fcolasuonno
162,470,286
false
null
package day9 import MultiMap import permutations import java.io.File fun main(args: Array<String>) { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(pars...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
1,255
AOC2015
MIT License
year2019/day18/vault/src/main/kotlin/com/curtislb/adventofcode/year2019/day18/vault/search/KeySearch.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2019.day18.vault.search import com.curtislb.adventofcode.common.collection.mapToMap import com.curtislb.adventofcode.common.collection.replaceAt import com.curtislb.adventofcode.common.geometry.Point import com.curtislb.adventofcode.common.graph.UnweightedGraph import com.curtislb...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
4,270
AdventOfCode
MIT License
src/Day14.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val map = getMapFromInput(input) return map.startDropping(stopWhen = { _, y -> y > map.bottom }) } fun part2(input: List<String>): Int { val map = getMapFromInput(input) return map.startDropping(sto...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
2,019
aoc-2022
Apache License 2.0
src/main/kotlin/adventofcode/year2020/Day17ConwayCubes.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.year2020.Day17ConwayCubes.Companion.Cube.Cube3d import adventofcode.year2020.Day17ConwayCubes.Companion.Cube.Cube4d class Day17ConwayCubes(customInput: PuzzleInput? = null) : Puzzle(customInput) { override...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
3,110
AdventOfCode
MIT License
src/Day09.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.abs import kotlin.math.sign fun main() { fun solution(input: List<String>, ropeLength: Int): Int { val visitedSet = mutableSetOf<Coords>() val rope: Array<Coords> = Array(ropeLength) { Coords(0, 0) } visitedSet.add(rope.last()) input.forEach { val head...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
1,499
AdventOfCode2022
Apache License 2.0
src/main/kotlin/problems/Day14.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day14(override val input: String) : Problem { override val number: Int = 14 private val polymerTemplate: String = input.split("\n\n").first() private val pairInsertionRules: Map<String, Char> = input.split("\n\n")[1] .lines() .map { line -> line.split(" -> ") } ...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
2,175
AdventOfCode2021
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/dynamicprogramming/uniquepaths/uniquePaths.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.dynamicprogramming.uniquepaths import kotlin.math.min /** * Uses a math formula to determine the number of unique paths. * We need to make n-1 + m-1 steps in total. How many ways to choose from m-1 right steps and n-1 down steps out of the * total steps? */ fun uniquePathsMath(...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,303
KotlinGround
MIT License
src/Day03.kt
semanticer
577,822,514
false
{"Kotlin": 9812}
import java.lang.Character.isUpperCase fun main() { fun part1(input: List<String>): Int { return input.sumOf { val firstCompartment = it.subSequence(0, it.length / 2) val secondCompartment = it.subSequence(it.length / 2, it.length) val charInBoth = firstCompartment.find ...
0
Kotlin
0
0
9013cb13f0489a5c77d4392f284191cceed75b92
1,005
Kotlin-Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/Day24.kt
dlew
75,886,947
false
null
import java.util.* class Day24 constructor(input: String) { data class Coord(val x: Int, val y: Int) data class Wire(val num: Int, val loc: Coord) data class Path(val from: Int, val to: Int) val maze: List<List<Boolean>> val wires: List<Wire> val distances: Map<Path, Int> init { val wireBuilder ...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
2,993
aoc-2016
MIT License
src/Day09.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun String.toCommand(): Command = split(" ") .let { (dir, steps) -> Command(Direction.valueOf(dir), steps.toInt()) } fun Position.move(direction: Direction) { when (direction) { Direction.L -> x-- Direction.U -> y++ Direction.R -> x++ ...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
3,227
aoc-2022
Apache License 2.0
src/Day04.kt
melo0187
576,962,981
false
{"Kotlin": 15984}
fun main() { fun List<String>.toSectionAssignmentPairs(): List<Pair<List<Int>, List<Int>>> { fun String.toSectionIdList(): List<Int> = let { split('-', limit = 2) .takeIf { it.size == 2 } ?: throw IllegalArgumentException("String does not ...
0
Kotlin
0
0
97d47b84e5a2f97304a078c3ab76bea6672691c5
1,790
kotlin-aoc-2022
Apache License 2.0
src/Day07.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import java.io.File import java.util.Deque fun main() { class Dir(val name: String, val parent: Dir?) { val files = HashMap<String, Long>() val children = ArrayList<Dir>() fun getSize(): Long { return children.sumOf { it.getSize() } + files.values.sum() } } fun...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
2,640
advent-of-code-2022
Apache License 2.0
src/Day01.kt
razvn
573,166,955
false
{"Kotlin": 27208}
fun main() { val day = "Day01" tailrec fun calcMax(acc: Int, max: Int, input: List<String>): Int { val newMax = if (acc > max) acc else max return when { input.isEmpty() -> newMax input.first().isBlank() -> calcMax(0, newMax, input.drop(1)) else -> calcMax(ac...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
1,217
aoc-2022-kotlin
Apache License 2.0
src/Day04.kt
Qdelix
574,590,362
false
null
fun main() { fun part1(input: List<String>): Int { var sum = 0 input.forEach { pair -> val first = pair.substringBefore(",") val second = pair.substringAfter(",") val firstPair = Pair(first.substringBefore("-").toInt(), first.substringAfter("-").toInt()) ...
0
Kotlin
0
0
8e5c599d5071d9363c8f33b800b008875eb0b5f5
1,574
aoc22
Apache License 2.0
gcj/y2020/round1b/c_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1b private fun search(init: List<Int>): String { val queue = mutableListOf(init) val dist = mutableMapOf(init to 0) val how = mutableMapOf<List<Int>, Way?>() var index = 0 while (true) { val a = queue[index++] if (a.zipWithNext().all { it.first <= it.second }) return "${dist[a]}\n${how[...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,091
competitions
The Unlicense
src/main/kotlin/Excercise24.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
val inputList = getInputAsTest("24") private fun solve(range: IntProgression): Long { val cycleSize = inputList.drop(1).withIndex().first { it.value.startsWith("inp") }.index + 1 val parts = inputList.chunked(cycleSize).map { Values(it) } for (input in range) { var (z, digitPosition, submarineNumb...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
2,343
advent-of-code-2021
MIT License
src/Day02.kt
jdpaton
578,869,545
false
{"Kotlin": 10658}
enum class Move{ ROCK, PAPER, SCISSORS } enum class MoveNext { WIN, LOSE, DRAW } data class MoveMapper(val move: Move) { fun beats(): Move { return when(move) { Move.ROCK -> Move.SCISSORS Move.SCISSORS -> Move.PAPER Move.PAPER -> Move.ROCK } } fun draws...
0
Kotlin
0
0
f6738f72e2a6395815840a13dccf0f6516198d8e
2,646
aoc-2022-in-kotlin
Apache License 2.0
src/Day12.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
fun main() { fun elevation(i: Int, j: Int, grid: List<String>): Int { val c = grid[i][j] if (c in 'a'..'z') return c - 'a' if (c == 'S') return 'a' - 'a' // else c == 'E' return 'z' - 'a' } fun part1(grid: List<String>): Int { val r ...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
2,910
Advent-of-Code-2022
Apache License 2.0
src/Day04.kt
josemarcilio
572,290,152
false
{"Kotlin": 5535}
fun main() { fun part1(input: List<String>): Int { return input.count { line -> val (dumb, dumber) = line.split(',').map{ it.split('-').map(String::toInt) } val dumbContainsDumber = dumb.first() <= dumber.first() && dumb.last() >= dumber.last() val dumberContainsDumb = du...
0
Kotlin
0
0
d628345afeb014adce189fddac53a1fcd98479fb
1,098
advent-of-code-2022
Apache License 2.0
src/Day19.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
import kotlin.math.min private enum class Material { Geode, Obsidian, Clay, Ore } private data class Blueprint( val id: Int, val robots: Map<Material, Map<Material, Int>>, val maxRobotRequired: Map<Material, Int> = Material.values().associateWith { material -> robots.maxOf { if (material == Ma...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
7,130
advent-of-code-2022
Apache License 2.0
src/day02/Day02Answer3.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day02 import readInput /** * Answers from [Advent of Code 2022 Day 2 | Kotlin](https://youtu.be/Fn0SY2yGDSA) */ fun main() { fun score(myShape: Shape1, theirShape: Shape1): Int { return myShape.score + when { theirShape beats myShape -> 0 theirShape beatenBy myShape -> 6 ...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
2,055
advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day16.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day16(input: Input) : Puzzle() { class Notes(val rules: Map<String, (Int) -> Boolean>, val myTicket: List<Int>, val nearbyTickets: List<List<Int>>) private val notes by la...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
2,451
adventofcode-kotlin
MIT License
src/Day03.kt
MT-Jacobs
574,577,538
false
{"Kotlin": 19905}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val splitString: Pair<List<Char>, List<Char>> = it.halve() // since we converted to a set, technically we've destroyed some info about the comparments' contents val leftCompartment = splitString.first...
0
Kotlin
0
0
2f41a665760efc56d531e56eaa08c9afb185277c
1,630
advent-of-code-2022
Apache License 2.0
aoc/src/Hands.kt
aragos
726,211,893
false
{"Kotlin": 16232}
import Card.Companion.toCard import java.io.File fun main() { val lines = File("aoc/inputs/hands.txt").readLines() println(linesToWinnings(lines)) } internal fun linesToWinnings(lines: List<String>): Int { return lines .map { line -> HandWinnings( Hand(line.substring(0, 5).map { it.toCard() ...
0
Kotlin
0
0
7bca0a857ea42d89435adc658c0ff55207ca374a
2,843
aoc2023
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year20/Day19.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year20 import com.grappenmaker.aoc.PuzzleSet fun PuzzleSet.day19() = puzzle(day = 19) { val (rulesPart, messagesPart) = input.split("\n\n") fun parseRule(rest: String) = when { rest.startsWith("\"") -> CharRule(rest.removeSurrounding("\"").single()) else -> rest.sp...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,698
advent-of-code
The Unlicense
kotlin/src/com/leetcode/1372_LongestZigZagPathInABinaryTree.kt
programmerr47
248,502,040
false
null
package com.leetcode import com.leetcode.data.TreeNode import java.lang.Integer.max import java.util.* class TreeZigZagNode(var value: Int) { var left: TreeZigZagNode? = null var right: TreeZigZagNode? = null var leftZigZag: Boolean? = null var maxZigZag: Int = 0 } //DFS. Time: O(n). Space: O(log(n)...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
3,583
problemsolving
Apache License 2.0
src/test/kotlin/io/noobymatze/aoc/y2023/Day11.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2023 import io.noobymatze.aoc.Aoc import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.test.Test class Day11 { data class Pos(val row: Int, val col: Int) @Test fun test() { val input = Aoc.getInput(11) .lines() .exp...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
2,666
aoc
MIT License
2015/src/main/kotlin/day22.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.Parse import utils.Parser import utils.Solution fun main() { Day22.run() } object Day22 : Solution<Day22.Boss>() { override val name = "day22" override val parser = Parser { parseBoss(it) } @Parse("Hit Points: {hp}\nDamage: {dmg}") data class Boss( val hp: Int, val d...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,989
aoc_kotlin
MIT License
src/Day12.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
class Day12Graph(val nodes: MutableMap<Loc, Node> = mutableMapOf()) { fun add(node: Node) { nodes[node.loc] = node } fun path(start: Node, end: Node): List<Node>? { initialize(start) var visiting: Node? = start while (visiting != end) { visiting!!.visited = true ...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
4,478
aoc-2022-demo
Apache License 2.0
src/day04/Day04.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day04 import readInput fun main() { fun IntRange.fullyContains(other: IntRange) = this.first <= other.first && this.last >= other.last fun IntRange.overlaps(other: IntRange): Boolean { return this.first in other || this.last in other || other.first in this || other.last in this } fu...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
1,461
advent-of-code-2022
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12940.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12940 * * 최대공약수와 최소공배수 * 문제 설명 * 두 수를 입력받아 두 수의 최대공약수와 최소공배수를 반환하는 함수, solution을 완성해 보세요. * 배열의 맨 앞에 최대공약수, 그다음 최소공배수를 넣어 반환하면 됩니다. * 예를 들어 두 수 3, 12의 최대공약수는 3, 최소공배수는 12이므로 solution(3, 12)는 [3, 12]를 반환해야 합니다...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,411
HoOne
Apache License 2.0
src/y2023/Day11.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Pos import util.readInput import util.timingStatistics import util.transpose import y2022.Day15.manhattanDist object Day11 { private fun parse(input: List<String>): List<Pos> { val asChars = input.map { it.toCharArray().toList() }.transpose() val expandedCols = expanded(a...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,435
advent-of-code
Apache License 2.0
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day10/Day10.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2022.day10 import nerok.aoc.utils.Input import java.util.* import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { var cycle = 0L var xValue = 1L var checkCycle = 20L val checkCyclePeriod = 40L ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
3,345
AOC
Apache License 2.0
src/day24/Day24.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day24 import readInput import readTestInput private data class Position(var x: Int, var y: Int) private enum class Direction { LEFT, RIGHT, UP, DOWN } private data class Blizzard(val position: Position, val direction: Direction) private data class BlizzardValley( val blizzards: List<Blizzard>, val h...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
7,000
advent-of-code-kotlin-2022
Apache License 2.0
src/Day21.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
fun main() { fun buildMonkey(inp: String, input: List<String>): MonkeyEval { val split = inp.split(" ") val name = split[0].substringBefore(":") return if (split.size == 2) { MonkeyEval(name, Operation.RETURN, value = split[1].toLong()) } else { val monkey1Lin...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
3,859
advent-of-code-2022
Apache License 2.0
AdventOfCode/2022/aoc22/src/main/kotlin/day5.kt
benhunter
330,517,181
false
{"Rust": 172709, "Python": 143372, "Kotlin": 37623, "Java": 17629, "TypeScript": 3422, "JavaScript": 3124, "Just": 1078}
fun day5() { println("day 5") val filename = "5-input.txt" // val filename = "5-test.txt" val text = getTextFromResource(filename) val input = text.split("\n\n") var inputLines = input[0].split("\n").toMutableList().map { line -> line.chunked(4) } inputLines = inputLines.slice(0 until input...
0
Rust
0
1
a424c12f4d95f9d6f8c844e36d6940a2ac11d61d
2,838
coding-challenges
MIT License
src/Day11.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day11.printSolutionIfTest(10605, 2713310158L) } typealias Operation = (Long) -> Long object Day11 : Day<Long, Long>(11) { override fun part1(lines: List<String>) = parseMonkeys(lines).doRounds(20) { it / 3 }.monkeyBusiness() override fun part2(lines: List<String>):Long { val ...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
3,033
advent-of-code-2022
Apache License 2.0
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day19.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty fun List<String>.day19Part1(): Int { val ruleMap = this.filter { it.contains(":") } .associate { rule -> rule.split(":").let { it.first().trim() to it.last().trim() } } .toMutableMap() val ruleList = ruleMap.toRuleList("0") val messages = this....
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
1,783
AdventOfCode
MIT License
src/net/sheltem/aoc/y2023/Day19.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.multiply import net.sheltem.aoc.y2023.Day19.Part import net.sheltem.aoc.y2023.Day19.RangePart import net.sheltem.aoc.y2023.Day19.Rule import net.sheltem.aoc.y2023.Day19.RuleSet suspend fun main() { Day19().run() } class Day19 : Day<Long>(19114, 167409079868...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
4,439
aoc
Apache License 2.0
src/main/kotlin/year2021/day-12.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.TraversalBreadthFirstSearch import lib.aoc.Day import lib.aoc.Part fun main() { Day(12, 2021, PartA12(), PartB12()).run() } open class PartA12 : Part() { private data class State(val pos: String, val visited: List<String>) private lateinit var edges: Map<String, List<String>>...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
2,036
Advent-Of-Code-Kotlin
MIT License
src/aoc2023/Day10.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput fun main() { val (year, day) = "2023" to "Day10" fun parse(input: List<String>): Pair<Array<Array<Tile>>, Tile> { val grid = buildList { val emptyLine = (1..input.first().length + 2).map { '.' }.joinToString("") add(emptyLine)...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
4,635
aoc-kotlin
Apache License 2.0
src/y2022/Day05.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.readInput object Day05 { data class Move( val amount: Int, val from: Int, val to: Int ) private fun transpose(matrix: List<List<Char>>): List<List<Char>> { return List(matrix.last().last().toString().toInt()) { stackIdx -> List(matrix....
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,702
advent-of-code
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2022/day19/Day19.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day19 import com.jacobhyphenated.advent2022.Day /** * Day 19: Not Enough Minerals * * We want to collect geodes using a geode producing robot. * To build the robot we need other materials, and materials to build robots to harvest those materials. * It takes 1 minute for a r...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
8,682
advent2022
The Unlicense
facebook/y2020/round3/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.round3 private fun solve(): String { val (n, k) = readInts() data class Measurement(val time: Int, val p: Int, val r: Int) val measurements = List(n) { val (p, r) = readInts() Measurement(it, p, r) } val ps = measurements.map { it.p }.toSet().sorted() var a = Array(k + 1) { n + 1 to 0 ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,120
competitions
The Unlicense
src/main/kotlin/aoc23/Day09.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import common.Year23 import aoc23.Day09Domain.Oasis import aoc23.Day09Parser.toOasis import aoc23.Day09Solution.part1Day09 import aoc23.Day09Solution.part2Day09 object Day09 : Year23 { fun List<String>.part1(): Int = part1Day09() fun List<String>.part2(): Int = part2Day09() } object Day09Solut...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
1,580
aoc
Apache License 2.0
src/Day13.kt
cisimon7
573,872,773
false
{"Kotlin": 41406}
fun main() { fun part1(pairs: List<Pair<Packet.Parent, Packet.Parent>>): Int { return pairs.map { (left, right) -> compare(left, right) } .mapIndexed { idx, case -> idx + 1 to case } .filter { (_, case) -> case == true } .sumOf { (idx, _) -> idx } } fun part2(pa...
0
Kotlin
0
0
29f9cb46955c0f371908996cc729742dc0387017
10,078
aoc-2022
Apache License 2.0
src/day07/Day07.kt
barbulescu
572,834,428
false
{"Kotlin": 17042}
package day07 import readInput private val root = Directory(null, "/") fun main() { var currentDirectory = root val content = readInput("day07/Day07").joinToString(separator = "|") content.split("$").asSequence() .map { it.trim() } .filterNot { it.isBlank() } .map { if (it.endsWi...
0
Kotlin
0
0
89bccafb91b4494bfe4d6563f190d1b789cde7a4
3,708
aoc-2022-in-kotlin
Apache License 2.0
src/Day24.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import java.util.LinkedList import java.util.Queue import kotlin.math.min import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { return Valley(input.drop(1).dropLast(1).map { it.drop(1).dropLast(1) }).minutesToGoal() } fun part2(input: List<String>): Int { return Valley(input...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
3,381
aoc2022
Apache License 2.0
src/main/kotlin/day04/day04.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package main.day04 import utils.readFile import utils.readLines fun main() { fun convertRange(input: String): IntRange { val values = input.split("-") return values[0].toInt()..values[1].toInt() } fun convertRanges(input: List<String>): List<Pair<Set<Int>, Set<Int>>> = input.map { it.split(",") } ...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
1,390
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day14/Day14.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day14 import readInput fun main() { data class Location(val x: Int, val y: Int) class Waterfall(val cond:(Location, Int) -> Boolean) { val state = Array(1000) { IntArray(1000) } var max = 0 fun addLine(f: Location, t: Location) { for (x in minOf(f.x, t.x)..maxOf...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
2,209
aoc2022
Apache License 2.0
src/year2022/day07/Day07.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day07 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day07_test") check(part1(testInput), 95437) check(part2(testInput), 24933642) val input = readInput("2022", "Day07") printl...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,034
AdventOfCode
Apache License 2.0
src/Day03.kt
halirutan
575,809,118
false
{"Kotlin": 24802}
import kotlin.streams.toList class Rucksack(contents: String) { private val contents1: IntArray private val contents2: IntArray init { assert(contents.isNotEmpty() && contents.length.mod(2) == 0) val chars = contents.chars().toArray() ?: throw Error("Converting string to array failed.") ...
0
Kotlin
0
0
09de80723028f5f113e86351a5461c2634173168
2,119
AoC2022
Apache License 2.0
src/Day09.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
import java.util.Scanner import kotlin.math.pow import kotlin.math.sqrt fun main() { fun part1(input: List<String>): Int { val tail = Node.Tail(0, 0) val head = Node.Head(0, 0) val positions = mutableListOf<Pair<Int, Int>>() for (line in input) { val move = Scanner(li...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
3,859
aoc-2022
Apache License 2.0