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/de/nosswald/aoc/days/Day11.kt | 7rebux | 722,943,964 | false | {"Kotlin": 34890} | package de.nosswald.aoc.days
import de.nosswald.aoc.Day
// https://adventofcode.com/2023/day/11
object Day11 : Day<Long>(11, "Cosmic Expansion") {
private const val GALAXY = '#'
private const val EXPANDED = 'x'
private data class Galaxy(val x: Int, val y: Int)
private fun List<String>.expand(): List... | 0 | Kotlin | 0 | 1 | 398fb9873cceecb2496c79c7adf792bb41ea85d7 | 2,718 | advent-of-code-2023 | MIT License |
src/Day10.kt | ShuffleZZZ | 572,630,279 | false | {"Kotlin": 29686} | private const val SCREEN_WIDTH = 40
private const val SCREEN_SIZE = 6 * SCREEN_WIDTH
private const val SIGNAL_STRENGTH = SCREEN_WIDTH / 2
private fun cycleSignals(input: List<String>): List<Int> {
val signals = MutableList(2 * input.size + 1) { 1 }
var cycle = 0
for (i in input.indices) {
signals[... | 0 | Kotlin | 0 | 0 | 5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e | 1,374 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/Day19.kt | clechasseur | 267,632,210 | false | null | object Day19 {
private const val input = 3004953
fun part1(): Int = generateSequence(State((1..input).toList())) {
it.next()
}.dropWhile {
it.elves.size > 1
}.first().elves.single()
fun part2(): Int = generateSequence(State2((1..input).toList())) {
it.next()
}.dropWhile... | 0 | Kotlin | 0 | 0 | 120795d90c47e80bfa2346bd6ab19ab6b7054167 | 1,499 | adventofcode2016 | MIT License |
2023/src/main/kotlin/de/skyrising/aoc2023/day2/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2023.day2
import de.skyrising.aoc.*
val test = TestInput("""
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
Game 4: 1 green, 3 red, ... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 1,502 | aoc | MIT License |
2021/src/main/kotlin/Day17.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | class Day17(val input: String) {
private fun String.prepareInput(): List<Int> =
"target area: x=([-\\d]+)..([-\\d]+), y=([-\\d]+)..([-\\d]+)".toRegex()
.matchEntire(this)!!.destructured.toList().map { it.toInt() }
private val area = input.prepareInput()
private var minY = minOf(area[2... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 1,322 | adventofcode-2021-2025 | MIT License |
y2021/src/main/kotlin/adventofcode/y2021/Day24.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
import adventofcode.util.algorithm.transpose
import java.util.*
object Day24 : AdventSolution(2021, 24, "Arithmetic Logic Unit") {
override fun solvePartOne(input: String) = "36969794979199"
override fun solvePartTwo(input: String) = "11419161... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,845 | advent-of-code | MIT License |
src/Day04.kt | robotfooder | 573,164,789 | false | {"Kotlin": 25811} | fun main() {
fun isFullyOverLapping(it: Pair<IntRange, IntRange>): Boolean =
it.first.toSet().containsAll(it.second.toSet()) || it.second.toSet().containsAll(it.first.toSet())
fun isOverLapping(it: Pair<IntRange, IntRange>): Boolean =
(it.first.toSet() intersect it.second.toSet()).isNotEmpty... | 0 | Kotlin | 0 | 0 | 9876a52ef9288353d64685f294a899a58b2de9b5 | 1,387 | aoc2022 | Apache License 2.0 |
src/Day01.kt | purdyk | 572,817,231 | false | {"Kotlin": 19066} | fun main() {
fun part1(input: List<String>): Int {
val groups = input.fold(mutableListOf(mutableListOf<Int>())) { acc, it ->
if (it.isEmpty()) {
acc.add(mutableListOf())
} else {
acc.last().add(it.toInt())
}
acc
}
... | 0 | Kotlin | 0 | 0 | 02ac9118326b1deec7dcfbcc59db8c268d9df096 | 1,384 | aoc2022 | Apache License 2.0 |
src/main/kotlin/be/seppevolkaerts/day5/Day5.kt | Cybermaxke | 727,453,020 | false | {"Kotlin": 35118} | package be.seppevolkaerts.day5
import be.seppevolkaerts.splitLongs
import kotlin.math.max
import kotlin.math.min
class Data(
val seeds: List<Long>,
val maps: RangeMaps,
)
data class RangeMaps(
val maps: List<RangeMap>
) {
private val mapsByInputType = maps.associateBy { it.inputType }
fun mapper(inputTyp... | 0 | Kotlin | 0 | 1 | 56ed086f8493b9f5ff1b688e2f128c69e3e1962c | 4,045 | advent-2023 | MIT License |
src/Day04.kt | allisonjoycarter | 574,207,005 | false | {"Kotlin": 22303} |
fun main() {
fun getRangeFromText(input: String): IntRange {
return input.split("-").first().toInt().rangeTo(
input.split("-").last().toInt()
)
}
fun part1(input: List<String>): Int {
val contained = input.count { line ->
val firstStart = line.split(",")... | 0 | Kotlin | 0 | 0 | 86306ee6f4e90c1cab7c2743eb437fa86d4238e5 | 1,469 | adventofcode2022 | Apache License 2.0 |
src/Day14.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 136
private const val EXPECTED_2 = 64
private class Day14(isTest: Boolean) : Solver(isTest) {
fun part1(): Any {
val field = readAsLines()
var sum = 0
fun add(row: Int, count: Int) {
for (i in 0 until count) {
sum += field.size - ro... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 3,234 | advent-of-code-2022 | Apache License 2.0 |
src/day10/Code.kt | fcolasuonno | 225,219,560 | false | null | package day10
import isDebug
import java.io.File
import kotlin.math.abs
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 2,022 | AOC2019 | MIT License |
src/main/kotlin/advent2019/day12/day12.kt | davidpricedev | 225,621,794 | false | null | package advent2019.day12
import advent2019.util.lcm
import kotlin.math.absoluteValue
/**
* Might be another use case for generateSequence?
* Logic for calculating the velocity has to be aware of the entire system.
* For every axis of every moon we'll have to calculate how all the other moons affect it to calculate... | 0 | Kotlin | 0 | 0 | 2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9 | 4,831 | adventOfCode2019 | Apache License 2.0 |
y2022/src/main/kotlin/adventofcode/y2022/Day17.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
import adventofcode.util.collections.cycle
import adventofcode.util.collections.takeWhileDistinct
import adventofcode.util.vector.Direction
import adventofcode.util.vector.Vec2
object Day17 : AdventSolution(2022, 17, "Pyroclastic Flow") {
override... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 4,474 | advent-of-code | MIT License |
src/Day03.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | fun main() {
fun Char.priority(): Int {
return when (this.isUpperCase()){
true -> this - 'A' + 27
else -> this - 'a' + 1
}
}
fun part1(input: List<String>): Int {
val res = input.flatMap { rucksack ->
rucksack.take(rucksack.length / 2).toSet() int... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 982 | aoc22 | Apache License 2.0 |
src/Day05.kt | slawa4s | 573,050,411 | false | {"Kotlin": 20679} | import java.util.Stack
fun main() {
fun getInitialStacks(input: List<String>): List<ArrayDeque<Char>> {
val filteredInput = input.map { it.toList().filterIndexed { index, _ -> index % 4 == 1 } }
val stacks: List<ArrayDeque<Char>> = List(filteredInput[0].size) { ArrayDeque() }
for (indexOfLi... | 0 | Kotlin | 0 | 0 | cd8bbbb3a710dc542c2832959a6a03a0d2516866 | 2,848 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day22.kt | davidkna | 572,439,882 | false | {"Kotlin": 79526} | import arrow.core.Either
private enum class Facing {
Right, Down, Left, Up
}
private enum class Turn {
Left, Right
}
fun main() {
fun parseInput(input: List<List<String>>): Pair<Map<Pair<Int, Int>, Boolean>, List<Either<Int, Turn>>> {
val map = input[0].mapIndexed { y, line ->
line.wi... | 0 | Kotlin | 0 | 0 | ccd666cc12312537fec6e0c7ca904f5d9ebf75a3 | 8,474 | aoc-2022 | Apache License 2.0 |
src/Day16.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | data class Valve(val id: String, val rate: Int, val vertexIds: List<String>)
fun makeValveSpecs(input: List<String>): Map<String, Valve> = input.map {
val regex = """Valve ([\w\s]+) has flow rate=(\d+); tunnels? leads? to valves? ([A-Z, ]+)""".toRegex()
val matchResult = regex.find(it)
val (id, rate, verte... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 3,411 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | cnietoc | 572,880,374 | false | {"Kotlin": 15990} | fun main() {
fun processRoot(input: List<String>): Directory {
val root = Directory(null, null)
var currentDirectory = root
val lastCommand = ArrayDeque<String>()
val inputIterator = input.iterator()
while (inputIterator.hasNext() || lastCommand.isNotEmpty()) {
va... | 0 | Kotlin | 0 | 0 | bbd8e81751b96b37d9fe48a54e5f4b3a0bab5da3 | 3,761 | aoc-2022 | Apache License 2.0 |
src/day25/Day25.kt | dkoval | 572,138,985 | false | {"Kotlin": 86889} | package day25
import readInput
private const val DAY_ID = "25"
fun main() {
val snafuToIntDigits = mapOf('=' to -2, '-' to -1, '0' to 0, '1' to 1, '2' to 2)
val intToSnafuDigits = mapOf(0 to '0', 1 to '1', 2 to '2', -2 to '=', -1 to '-')
fun snafuToInt(num: String): Long {
var ans = 0L
f... | 0 | Kotlin | 1 | 0 | 791dd54a4e23f937d5fc16d46d85577d91b1507a | 1,462 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day10/Day10.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import java.util.*
fun main() {
val scores = mapOf(')' to 3, ']' to 57, '}' to 1197, '>' to 25137)
val opening = setOf('(', '[', '{', '<')
val closing = setOf(')', ']', '}', '>')
val openingFrom = mapOf(')' to '(', ']' to '[', '}' to '{', '>' to '<')
val closingFrom = mapOf('(' to 1, '[' to 2, '{'... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 1,707 | advent-of-code-2021 | Apache License 2.0 |
app/src/main/kotlin/day10/Day10.kt | meli-w | 433,710,859 | false | {"Kotlin": 52501} | package day10
import common.InputRepo
import common.readSessionCookie
import common.solve
fun main(args: Array<String>) {
val day = 10
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay10Part1, ::solveDay10Part2)
}
fun solveDay10Part1(input: List<String>): Any =... | 0 | Kotlin | 0 | 1 | f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1 | 2,487 | AoC-2021 | Apache License 2.0 |
y2015/src/main/kotlin/adventofcode/y2015/Day18.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2015
import adventofcode.io.AdventSolution
import kotlin.math.max
import kotlin.math.min
object Day18 : AdventSolution(2015, 18, "Like a GIF For Your Yard") {
override fun solvePartOne(input: String) = generateSequence(ConwayGrid(input), ConwayGrid::next)
.drop(100)
... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,505 | advent-of-code | MIT License |
src/day15/Day15.kt | idle-code | 572,642,410 | false | {"Kotlin": 79612} | package day15
import Position
import logln
import logEnabled
import readInput
import java.lang.IllegalStateException
import java.lang.Math.abs
private const val DAY_NUMBER = 15
data class Sensor(val sensorPosition: Position, val beaconPosition: Position) {
private val distanceToBeacon: Int = sensorPosition.manha... | 0 | Kotlin | 0 | 0 | 1b261c399a0a84c333cf16f1031b4b1f18b651c7 | 3,783 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | import java.lang.IllegalStateException
sealed class FsEntity(val name: String) {
abstract val size: Int
}
class Dir(name: String, val parent: Dir?) : FsEntity(name) {
val children = mutableListOf<FsEntity>()
fun findChild(name: String): Dir =
children.find { it.name == name } as? Dir ?: throw Ill... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 2,038 | Advent-of-Code-2022 | Apache License 2.0 |
src/day19/Code.kt | fcolasuonno | 572,734,674 | false | {"Kotlin": 63451, "Dockerfile": 1340} | package day19
import day06.main
import readInput
fun main() {
val ORE = 0
val CLAY = 1
val OBSIDIAN = 2
val GEODE = 3
data class Blueprint(
val time: Int = 24,
val resources: List<Int> = List(4) { 0 },
val robots: List<Int> = List(4) { if (it == ORE) 1 else 0 },
v... | 0 | Kotlin | 0 | 0 | 9cb653bd6a5abb214a9310f7cac3d0a5a478a71a | 5,600 | AOC2022 | Apache License 2.0 |
src/main/Day05.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day05
import utils.readInput
import java.util.*
typealias Stacks = List<Deque<Char>>
fun List<String>.stacks(): Stacks {
val lines = takeWhile { it.isNotBlank() }
val numberOfStacks = lines.last().splitToSequence(" +".toRegex()).last().toInt()
val stacks = (1..numberOfStacks).map { ArrayDeque<Cha... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 1,905 | aoc-2022 | Apache License 2.0 |
y2021/src/main/kotlin/adventofcode/y2021/Day20.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
object Day20 : AdventSolution(2021, 20, "Trench Map") {
override fun solvePartOne(input: String) = parse(input).let { (rules, grid) -> solve(rules, grid, 2) }
override fun solvePartTwo(input: String) = parse(input).let { (rules, grid) -> solve(r... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,347 | advent-of-code | MIT License |
kotlin/src/main/kotlin/icfp2019/app.kt | AnushaSankara | 193,136,077 | true | {"JavaScript": 672516, "HTML": 5520, "Kotlin": 3029, "Python": 2607, "Rust": 45} | package icfp2019
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
fun main() {
val workingDir: Path = Paths.get("")
val solutions = mutableListOf<Solution>()
readZipFile(File("problems.zip"))
.filter { it.file.isFile }
.forEach {
val proble... | 0 | JavaScript | 0 | 0 | 93fb25e41a78c066c87f237d2896f57664cc66d5 | 3,012 | icfp-2019 | The Unlicense |
src/Day14.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | import kotlin.math.max
import kotlin.math.min
fun main() {
val testInput = readInput("Day14_test")
check(part1(testInput) == 24)
check(part2(testInput) == 93)
val input = readInput("Day14")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
val (ca... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 3,090 | aoc-22 | Apache License 2.0 |
src/Day07.kt | jwalter | 573,111,342 | false | {"Kotlin": 19975} | import kotlin.math.abs
fun main() {
data class Dir(
val name: String,
val parent: Dir?,
var ownSize: Int = 0,
val children: MutableList<Dir> = mutableListOf(),
var totalSize: Int = 0
)
fun parseInput(input: List<String>): Dir {
val root = Dir("/", null)
... | 0 | Kotlin | 0 | 0 | 576aeabd297a7d7ee77eca9bb405ec5d2641b441 | 1,856 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/de/pgebert/aoc/days/Day12.kt | pgebert | 724,032,034 | false | {"Kotlin": 65831} | package de.pgebert.aoc.days
import de.pgebert.aoc.Day
class Day12(input: String? = null) : Day(12, "Hot Springs", input) {
override fun partOne() = inputList.sumOf { line ->
val splitted = line.split(" ")
val configuration = splitted.first()
val specification = splitted.last().split(","... | 0 | Kotlin | 1 | 0 | a30d3987f1976889b8d143f0843bbf95ff51bad2 | 2,783 | advent-of-code-2023 | MIT License |
src/main/kotlin/d23/D23_2.kt | MTender | 734,007,442 | false | {"Kotlin": 108628} | package d23
import input.Input
class D23_2 {
companion object {
private fun removeAllSlopes(lines: List<String>): List<String> {
return lines.map { it.replace("[<>v^]".toRegex(), ".") }
}
private fun findIntersections(lines: List<String>): List<Pair<Int, Int>> {
... | 0 | Kotlin | 0 | 0 | a6eec4168b4a98b73d4496c9d610854a0165dbeb | 4,953 | aoc2023-kotlin | MIT License |
src/Day04.kt | jordan-thirus | 573,476,470 | false | {"Kotlin": 41711} | fun main() {
fun getPairs(line: String) : List<Pair<Int, Int>> {
val assignments = line.split(',','-')
return listOf(Pair(assignments[0].toInt(), assignments[1].toInt()),
Pair(assignments[2].toInt(), assignments[3].toInt()))
.sortedBy { pair -> pair.first }
}
fun co... | 0 | Kotlin | 0 | 0 | 59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e | 1,374 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g1901_2000/s1976_number_of_ways_to_arrive_at_destination/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1901_2000.s1976_number_of_ways_to_arrive_at_destination
// #Medium #Dynamic_Programming #Graph #Topological_Sort #Shortest_Path
// #2023_06_21_Time_282_ms_(100.00%)_Space_46.8_MB_(100.00%)
import java.util.PriorityQueue
import java.util.Queue
class Solution {
private fun dijkstra(roads: Array<IntArray>,... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,952 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/aoc2021/Day02.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2021
import aoc2022.parsedBy
import utils.InputUtils
import utils.Coordinates
private sealed class Command {
data class Up(val distance: Int) : Command()
data class Down(val distance: Int) : Command()
data class Forward(val distance: Int) : Command()
}
private val parser = "(up|down|forward) (... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,141 | aoc-2022-kotlin | Apache License 2.0 |
kotlin/app/src/main/kotlin/coverick/aoc/day3/RucksackReorganization.kt | RyTheTurtle | 574,328,652 | false | {"Kotlin": 82616} | package coverick.aoc.day3
import readResourceFile
//https://adventofcode.com/2022/day/3
val INPUT_FILE = "rucksackReorganization-input.txt"
fun getRucksackCompartments(contents:String): Pair<String,String>{
val split = contents.length / 2
return Pair(contents.substring(0,split),
contents.subs... | 0 | Kotlin | 0 | 0 | 35a8021fdfb700ce926fcf7958bea45ee530e359 | 2,072 | adventofcode2022 | Apache License 2.0 |
aoc2022/day16.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import utils.InputRetrieval
fun main() {
Day16.execute()
}
object Day16 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
private fun part1(input: List<Valve>): Int {
val startingPoint = i... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 4,169 | Advent-Of-Code | MIT License |
src/year_2022/day_24/Day24.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2022.day_24
import readInput
import util.Bounds
import util.Bounds.Companion.bounds
import util.Direction.*
import util.Point
import util.isWithin
import util.plus
private data class Move(val position: Point, val step: Int)
class Day24(text: List<String>) {
companion object {
private const ... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 7,390 | advent_of_code | Apache License 2.0 |
src/Day08.kt | catcutecat | 572,816,768 | false | {"Kotlin": 53001} | import java.util.*
import kotlin.math.abs
import kotlin.system.measureTimeMillis
fun main() {
measureTimeMillis {
Day08.run {
solve1(21) // 1851
solve2(8) // 574080
}
}.let { println("Total: $it ms") }
}
object Day08 : Day.LineInput<Day08.Data, Int>("08") {
class D... | 0 | Kotlin | 0 | 2 | fd771ff0fddeb9dcd1f04611559c7f87ac048721 | 2,758 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/codes/jakob/aoc/solution/Day11.kt | The-Self-Taught-Software-Engineer | 433,875,929 | false | {"Kotlin": 56277} | package codes.jakob.aoc.solution
import codes.jakob.aoc.shared.Grid
object Day11 : Solution() {
override fun solvePart1(input: String): Any {
val grid: Grid<Octopus> = Grid(parseInput(input))
val octopuses: List<Octopus> = grid.cells.map { it.value }
return (1..100).sumOf {
val... | 0 | Kotlin | 0 | 6 | d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c | 2,821 | advent-of-code-2021 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumLevelSumOfBinaryTree.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <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 | 2,534 | kotlab | Apache License 2.0 |
src/Day04.kt | Akhunzaada | 573,119,655 | false | {"Kotlin": 23755} | fun main() {
fun String.toIntRange(delimiter: Char = '-') =
split(delimiter).let { (first, second) ->
IntRange(first.toInt(), second.toInt())
}
fun String.toSectionsPair() =
split(',').let { (first, second) ->
Pair(first.toIntRange(), second.toIntRange())
... | 0 | Kotlin | 0 | 0 | b2754454080989d9579ab39782fd1d18552394f0 | 1,225 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/y22/Day08.kt | kezz | 572,635,766 | false | {"Kotlin": 20772} | package days.y22
import util.Day
public fun main() {
Day08().run()
}
public class Day08 : Day(22, 8) {
override fun part1(input: List<String>): Any = input
.mapIndexed { y, row ->
row.mapIndexed { x, tree ->
tree.digitToInt().let { value ->
listOf(
... | 0 | Kotlin | 0 | 0 | 1cef7fe0f72f77a3a409915baac3c674cc058228 | 3,197 | aoc | Apache License 2.0 |
src/Parser.kt | rfermontero | 121,166,046 | false | {"Kotlin": 1682} | fun parseGrammar(grammar: List<Pair<String, String>>) = getFirsts(grammar)
fun getFirsts(grammar: List<Pair<String, String>>): Map<String, List<String>> =
grammar.groupBy { it.first }
.mapValues { it.value.map { it.second } }
.mapValues {
it.value.map {
... | 0 | Kotlin | 0 | 0 | ca693f265bafab1d3b2d53c9adcc421fe038f5b4 | 1,159 | LalL-a-rLar | MIT License |
src/Day11.kt | slawa4s | 573,050,411 | false | {"Kotlin": 20679} | import java.io.IOException
class Monkey(
var items: MutableList<Int>,
private val operation: List<String>,
private val derive: Int,
private val ifTrueThrow: Int,
private val ifFalseThrow: Int,
) {
private var inspectedItems = 0
fun getInspectedItems() = inspectedItems
private fun make... | 0 | Kotlin | 0 | 0 | cd8bbbb3a710dc542c2832959a6a03a0d2516866 | 3,645 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/day08/Forest.kt | jankase | 573,187,696 | false | {"Kotlin": 70242} | package day08
data class Forest(val trees: List<Tree>) {
companion object {
fun valueOf(value: List<String>) =
Forest(
value.mapIndexed { rowIndex, rowTreesHeight ->
rowTreesHeight.mapIndexed { columnIndex, heightChar ->
Tree(rowIndex,... | 0 | Kotlin | 0 | 0 | 0dac4ec92c82a5ebb2179988fb91fccaed8f800a | 3,241 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/extensions/sequences/Collect.kt | swantescholz | 102,711,230 | false | null | package extensions.sequences
import datastructures.HashCounter
import extensions.*
import math.LOG2
import java.math.BigInteger
import java.text.DecimalFormat
import java.util.*
fun <T> Sequence<T>.takeLast(numberOfElementsToTakeFromBackOfSequence: Int): ArrayList<T> {
val list = LinkedList<T>()
for (element in thi... | 0 | Kotlin | 0 | 0 | 20736acc7e6a004c29c328a923d058f85d29de91 | 2,964 | ai | Do What The F*ck You Want To Public License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day16.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.dij.Dijkstra
import io.github.clechasseur.adventofcode.dij.Graph
import io.github.clechasseur.adventofcode.y2022.data.Day16Data
object Day16 {
private val input = Day16Data.input
private val valveRegex = """^Valve ([A-... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 3,054 | adventofcode2022 | MIT License |
src/main/kotlin/com/groundsfam/advent/y2022/d08/Day08.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2022.d08
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import java.util.ArrayDeque
import java.util.Deque
import kotlin.io.path.div
import kotlin.io.path.useLines
import kotlin.math.abs
/**
* Collection of walks to take across the grid of trees. A walk is a l... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 4,489 | advent-of-code | MIT License |
src/Day05.kt | alfr1903 | 573,468,312 | false | {"Kotlin": 9628} | fun main() {
fun part1(moves: List<String>, stacks: Map<Int, List<Char>>): Int {
var mutableStacks = stacks
for (moveInstruction in moves) {
val moveList = moveInstruction.split(" from ")
val quantity = moveList.first().last().digitToInt()
val from = moveList.last... | 0 | Kotlin | 0 | 0 | c1d1fbf030ac82c643fa5aea4d9f7c302051c38c | 1,563 | advent-of-code-2022 | Apache License 2.0 |
aoc-2023/src/main/kotlin/nerok/aoc/aoc2023/day01/Day01.kt | nerok | 572,862,875 | false | {"Kotlin": 113337} | package nerok.aoc.aoc2023.day01
import nerok.aoc.utils.Input
import kotlin.time.DurationUnit
import kotlin.time.measureTime
fun main() {
fun part1(input: List<String>): Long {
return input.map { line ->
line.filter { it.isDigit() }
}.sumOf { "${it.first()}${it.last()}".toLong() }
}... | 0 | Kotlin | 0 | 0 | 7553c28ac9053a70706c6af98b954fbdda6fb5d2 | 1,750 | AOC | Apache License 2.0 |
src/Day11.kt | pimtegelaar | 572,939,409 | false | {"Kotlin": 24985} | fun main() {
data class Item(var fear: Long)
class Monkey(
val items: MutableList<Item>,
val operation: (Long) -> Long,
val test: (Long) -> Boolean,
val divisor: Long,
val positive: Int,
val negative: Int,
var inspections: Long = 0
)
fun List<St... | 0 | Kotlin | 0 | 0 | 16ac3580cafa74140530667413900640b80dcf35 | 2,508 | aoc-2022 | Apache License 2.0 |
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p02/Leet236.kt | artemkaxboy | 513,636,701 | false | {"Kotlin": 547181, "Java": 13948} | package com.artemkaxboy.leetcode.p02
import com.artemkaxboy.leetcode.TreeNode
import java.util.*
/**
* Runtime 199ms Beats 83.59%
* Memory 37.2MB Beats 89.60%
*/
class Leet236 {
class Solution {
fun lowestCommonAncestor(root: TreeNode?, p: TreeNode?, q: TreeNode?): TreeNode? {
... | 0 | Kotlin | 0 | 0 | 516a8a05112e57eb922b9a272f8fd5209b7d0727 | 2,686 | playground | MIT License |
src/Day07.kt | mandoway | 573,027,658 | false | {"Kotlin": 22353} | sealed class Path(val name: String, val parent: Directory?) {
class Directory(name: String, parent: Directory? = null, val subPaths: MutableSet<Path> = mutableSetOf()) :
Path(name, parent) {
fun forEachDepthFirst(action: (Directory) -> Unit) {
action(this)
subPaths.forEach {
... | 0 | Kotlin | 0 | 0 | 0393a4a25ae4bbdb3a2e968e2b1a13795a31bfe2 | 3,156 | advent-of-code-22 | Apache License 2.0 |
src/main/kotlin/org/sjoblomj/adventofcode/day8/Day8.kt | sjoblomj | 161,537,410 | false | null | package org.sjoblomj.adventofcode.day8
import org.sjoblomj.adventofcode.readFile
import kotlin.system.measureTimeMillis
private const val inputFile = "src/main/resources/inputs/day8.txt"
fun day8() {
println("== DAY 8 ==")
val timeTaken = measureTimeMillis { calculateAndPrintDay8() }
println("Finished Day 8 i... | 0 | Kotlin | 0 | 0 | 80db7e7029dace244a05f7e6327accb212d369cc | 1,722 | adventofcode2018 | MIT License |
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day22.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2022
import se.saidaspen.aoc.aoc2022.Day22.DIR.*
import se.saidaspen.aoc.aoc2022.Day22.SIDE.*
import se.saidaspen.aoc.util.*
import kotlin.collections.minBy
fun main() = Day22.run()
object Day22 : Day(2022, 22) {
enum class DIR(val p: Point) { RIGHT(P(1, 0)), DOWN(P(0, 1)), LEFT(P(-1... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 5,577 | adventofkotlin | MIT License |
2023/src/main/kotlin/day8.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parse
import utils.Parser
import utils.Solution
import utils.lcm
fun main() {
Day8.run()
}
object Day8 : Solution<Day8.Input>() {
override val name = "day8"
override val parser = Parser { parseInput(it) }
@Parse("{instructions}\n\n{r '\n' edges}")
data class Input(
val instructions: String... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,872 | aoc_kotlin | MIT License |
src/main/kotlin/days/Day3.kt | vovarova | 726,012,901 | false | {"Kotlin": 48551} | package days
import util.GridCell
import util.DayInput
import util.Matrix
class Day3 : Day("3") {
private fun gridNumbers(input: List<String>): MutableList<Pair<Int, List<GridCell<Char>>>> {
val matrix = Matrix(input.map {
it.toCharArray().toTypedArray()
}.toTypedArray())
val ... | 0 | Kotlin | 0 | 0 | 77df1de2a663def33b6f261c87238c17bbf0c1c3 | 2,642 | adventofcode_2023 | Creative Commons Zero v1.0 Universal |
src/Day11.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
fun calcAns(numRuns: Int, isPart1: Boolean): Long {
repeat(numRuns) {
Monkey.monkeys.map{ it.Run(isPart1) }
}
return Monkey.monkeys.map{ it.numItemsInspected }.sortedDescending().take(2).reduce{ tot, it -> it * tot }
}
val input = readInput("../input/Day11")... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 2,591 | aoc-2022 | Apache License 2.0 |
src/Day24.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | fun main() {
fun Char.toDirection() = when (this) {
'^' -> Direction.UP
'v' -> Direction.DOWN
'<' -> Direction.LEFT
'>' -> Direction.RIGHT
else -> error("$this is not a direction")
}
data class Point(val row: Int, val col: Int)
fun Point.next(direction: Directio... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 4,424 | advent-of-code-22 | Apache License 2.0 |
src/Day16.kt | fedochet | 573,033,793 | false | {"Kotlin": 77129} | fun main() {
class ValueInfo(val name: String, val rate: Int, val connectedTo: List<String>)
fun parseValve(str: String): ValueInfo {
val pattern = Regex("Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (\\w+(, \\w+)*)")
val (name, rate, connectedTo) = pattern.matchEntire(str)?.de... | 0 | Kotlin | 0 | 1 | 975362ac7b1f1522818fc87cf2505aedc087738d | 5,268 | aoc2022 | Apache License 2.0 |
src/Day04.kt | wbars | 576,906,839 | false | {"Kotlin": 32565} | import java.lang.Integer.min
import kotlin.math.max
data class Range(val l: Int, var r: Int) {
fun contains(range: Range): Boolean {
return l <= range.l && r >= range.r
}
fun overlap(second: Range): Boolean {
return max(second.l, l) <= min(second.r, r)
}
}
fun main() {
fun ranges(... | 0 | Kotlin | 0 | 0 | 344961d40f7fc1bb4e57f472c1f6c23dd29cb23f | 932 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | import java.util.*
fun main() {
val testInput = readInput("Day05_test")
check(part1(testInput) == "CMZ")
check(part2(testInput) == "MCD")
val input = readInput("Day05")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): String =
solve(input) { stacks, cm... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 2,211 | AOC2022 | Apache License 2.0 |
src/day20/Day20.kt | dkoval | 572,138,985 | false | {"Kotlin": 86889} | package day20
import readInput
private const val DAY_ID = "20"
fun main() {
fun solve(input: List<String>, mixes: Int, transform: (x: Long) -> Long): Long {
val nums = input.asSequence()
.map { transform(it.toLong()) }
.withIndex()
.toMutableList()
val n = num... | 0 | Kotlin | 1 | 0 | 791dd54a4e23f937d5fc16d46d85577d91b1507a | 1,712 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | package day05
import java.io.File
import java.util.Stack
data class Movement(val amount: Int, val stackFrom: Int, val stackTo: Int)
fun String.toMovement(): Movement {
val parts = this.split(" ")
return Movement(parts[1].toInt(), parts[3].toInt() - 1, parts[5].toInt() - 1)
}
typealias Stacks = List<Stack<Ch... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 2,716 | aoc-2022-in-kotlin | Apache License 2.0 |
src/poyea/aoc/mmxxii/day04/Day04.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day04
import poyea.aoc.utils.readInput
fun part1(input: String): Int {
return input.split("\n").flatMap {
it.split(",").map { sections ->
sections.split("-").map { array -> array.toInt() }
}.chunked(2).map { assignment ->
val list1 = assignment[0]
... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 1,046 | aoc-mmxxii | MIT License |
src/main/kotlin/day5.kt | gautemo | 433,582,833 | false | {"Kotlin": 91784} | import shared.getLines
fun findOverlappingVents(lines: List<String>, includeDiagonals: Boolean = false): Int{
val vents = lines.map { Vent(it) }.filter { includeDiagonals || !it.isDiagonal }
val maxX = vents.maxOf { maxOf(it.xLine.first, it.xLine.last) }
val maxY = vents.maxOf { maxOf(it.yLine.first, it.yL... | 0 | Kotlin | 0 | 0 | c50d872601ba52474fcf9451a78e3e1bcfa476f7 | 1,750 | AdventOfCode2021 | MIT License |
y2022/src/main/kotlin/adventofcode/y2022/Day08.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
import adventofcode.util.algorithm.transpose
import adventofcode.util.vector.Direction
import adventofcode.util.vector.Vec2
object Day08 : AdventSolution(2022, 8, "Treetop Tree House") {
override fun solvePartOne(input: String): Int {
val ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,821 | advent-of-code | MIT License |
src/main/kotlin/day09_smoke_basin/SmokeBasin.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day09_smoke_basin
import geom2d.Point
import geom2d.Rect
import geom2d.asLinearOffset
import util.saveTextFile
import java.io.PrintWriter
import java.util.*
/**
* "The 2D plane" needs a refresher. Move around it, find neighbors, a bit of
* parsing, find the right data structures... Partially review, and als... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 3,148 | aoc-2021 | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day228/day228.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day228
// day228.kt
// By <NAME>, 2019.
import java.math.BigInteger
import java.util.LinkedList
// https://medium.com/@voddan/a-handful-of-kotlin-permutations-7659c555d42
// Typeclass that circulates over its members.
interface Circular<T> : Iterable<T> {
fun state(): T
fun inc()
fun isZero()... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 3,613 | daily-coding-problem | MIT License |
src/main/kotlin/dev/bogwalk/batch6/Problem62.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch6
import dev.bogwalk.util.combinatorics.permutationID
/**
* Problem 62: Cubic Permutations
*
* https://projecteuler.net/problem=62
*
* Goal: Given N, find the smallest cubes for which exactly K permutations of its digits are the
* cube of some number < N.
*
* Constraints: 1e3 <= N <= ... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 2,547 | project-euler-kotlin | MIT License |
src/Day03.kt | ranveeraggarwal | 573,754,764 | false | {"Kotlin": 12574} | fun main() {
fun getPriority(c: Char): Int {
return if (c.isUpperCase()) c.code - 'A'.code + 27 else c.code - 'a'.code + 1
}
fun part1(input: List<String>): Int {
var result = 0
input.forEach {
val map = HashSet<Char>()
it.substring(0, it.length / 2).forEach ... | 0 | Kotlin | 0 | 0 | c8df23daf979404f3891cdc44f7899725b041863 | 1,054 | advent-of-code-2022-kotlin | Apache License 2.0 |
aoc/src/main/kotlin/com/bloidonia/aoc2023/day11/Main.kt | timyates | 725,647,758 | false | {"Kotlin": 45518, "Groovy": 202} | package com.bloidonia.aoc2023.day11
import com.bloidonia.aoc2023.text
import kotlin.math.abs
private const val example = """...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#....."""
private data class Position(val x: Long, val y: Long) {
operator fun plus(ot... | 0 | Kotlin | 0 | 0 | 158162b1034e3998445a4f5e3f476f3ebf1dc952 | 2,131 | aoc-2023 | MIT License |
day06/src/main/kotlin/Main.kt | rstockbridge | 225,212,001 | false | null | fun main() {
val inputAsLines = resourceFile("input.txt")
.readLines()
val directOrbits = parseInput(inputAsLines)
println("Part I: the solution is ${solvePartI(directOrbits)}.")
println("Part II: the solution is ${solvePartII(directOrbits)}.")
}
fun parseInput(inputAsLines: List<String>): Li... | 0 | Kotlin | 0 | 0 | bcd6daf81787ed9a1d90afaa9646b1c513505d75 | 2,931 | AdventOfCode2019 | MIT License |
src/Day03.kt | mr-cell | 575,589,839 | false | {"Kotlin": 17585} | fun main() {
fun part1(input: List<String>): Int =
input.sumOf { it.sharedItem().priority() }
fun part2(input: List<String>): Int =
input.chunked(3)
.sumOf { it.sharedItem().priority() }
// test if implementation meets criteria from the description, like:
val testInput = re... | 0 | Kotlin | 0 | 0 | 2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9 | 986 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | hiteshchalise | 572,795,242 | false | {"Kotlin": 10694} | fun main() {
fun part1(input: List<String>): Int {
val priorityList = input.map { rucksack ->
val firstCompartment = rucksack.subSequence(0, rucksack.length / 2)
val secondCompartment = rucksack.subSequence(rucksack.length / 2, rucksack.length)
val matchingItem = firstCom... | 0 | Kotlin | 0 | 0 | e4d66d8d1f686570355b63fce29c0ecae7a3e915 | 1,235 | aoc-2022-kotlin | Apache License 2.0 |
src/Day21.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | import kotlin.math.abs
fun main() {
data class Point(val r: Int, val c: Int)
operator fun Point.plus(p: Point) = Point(r + p.r, c + p.c)
val dirs = listOf(Point(0, 1), Point(1, 0), Point(0, -1), Point(-1, 0))
fun solve1(input: List<String>, steps: Int): Int {
val start = input.indexOfFirst { i... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 3,322 | advent-of-code-kotlin | Apache License 2.0 |
Problems/Algorithms/329. Longest Increasing Path in a Matrix/LongestIncreasingPath.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun longestIncreasingPath(matrix: Array<IntArray>): Int {
val n = matrix.size
val m = matrix[0].size
val neighbors = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0))
val dp = Array(n) { IntArray(m) { -1 } }
... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,267 | leet-code | MIT License |
src/main/kotlin/com/groundsfam/advent/y2020/d07/Day07.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2020.d07
import com.groundsfam.advent.DATAPATH
import java.util.ArrayDeque
import java.util.Queue
import kotlin.io.path.div
import kotlin.io.path.useLines
private fun parseRule(line: String): Rule {
val tokens = line.split(" ")
return rule {
bagColor = "${tokens[0]} ${t... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,412 | advent-of-code | MIT License |
src/day03/Day03.kt | voom | 573,037,586 | false | {"Kotlin": 12156} | package day03
import readInput
/**
* --- Day 3: Rucksack Reorganization ---
*/
fun main() {
fun defineType(p1: String, p2: String): Char {
return p1.first { p2.contains(it) }
}
fun calcPrio(it: Char) = if (it.isLowerCase()) it - 'a' + 1 else it - 'A' + 27
/**
* Sum priorities of rucks... | 0 | Kotlin | 0 | 1 | a8eb7f7b881d6643116ab8a29177d738d6946a75 | 1,355 | aoc2022 | Apache License 2.0 |
src/day20/day.kt | LostMekka | 574,697,945 | false | {"Kotlin": 92218} | package day20
import util.readInput
import util.shouldBe
import util.skipEvery
fun main() {
val testInput = readInput(Input::class, testInput = true).parseInput()
testInput.part1() shouldBe 3
testInput.part2() shouldBe 1623178306
val input = readInput(Input::class).parseInput()
println("output fo... | 0 | Kotlin | 0 | 0 | 58d92387825cf6b3d6b7567a9e6578684963b578 | 2,227 | advent-of-code-2022 | Apache License 2.0 |
2022/src/main/kotlin/Day19.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | object Day19 {
fun part1(input: String): Int {
return parseInput(input)
.sumOf { blueprint -> maxGeodes(blueprint, 24) * blueprint.number }
}
fun part2(input: String): Int {
return parseInput(input)
.take(3)
.map { blueprint -> maxGeodes(blueprint, 32) }
.reduce(Int::times)
}
... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 6,036 | advent-of-code | MIT License |
src/main/kotlin/me/consuegra/algorithms/KSumLinkedLists.kt | aconsuegra | 91,884,046 | false | {"Java": 113554, "Kotlin": 79568} | package me.consuegra.algorithms
import me.consuegra.datastructure.KListNode
/**
* You have two numbers represented by a linked list, where each node represents a single digit. The digits are
* stored in reverse1 order, such as the 1's digit is at the head of the list. Write a function that adds the two
* numbers a... | 0 | Java | 0 | 7 | 7be2cbb64fe52c9990b209cae21859e54f16171b | 2,017 | algorithms-playground | MIT License |
Kotlin for Java Developers. Week 2/Mastermind/Task/src/mastermind/evaluateGuess.kt | Anna-Sentyakova | 186,426,055 | false | null | package mastermind
import java.util.*
import kotlin.math.min
data class Evaluation(val rightPosition: Int, val wrongPosition: Int)
fun evaluateGuess(secret: String, guess: String): Evaluation {
val rightPositions = secret.zip(guess).count { it.first == it.second }
val commonLetters = "ABCDEF".sumBy { ch ->... | 0 | Kotlin | 0 | 1 | e5db4940fa844aa8a5de7f90dd872909a06756e6 | 1,871 | coursera | Apache License 2.0 |
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day22.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 Day22(input: Input) : Puzzle() {
private val decks by lazy {
input.string().split("\n\n")
.map { deck -> deck.split("\n").drop(1).map { card -> card.toInt()... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 2,787 | adventofcode-kotlin | MIT License |
src/day06/Day06.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day06
import java.io.File
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.sqrt
fun main() {
val data = parse("src/day06/Day06.txt")
println("🎄 Day 06 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
pri... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 1,417 | advent-of-code-2023 | MIT License |
src/Day08.kt | asm0dey | 572,860,747 | false | {"Kotlin": 61384} | fun main() {
fun part1(input: List<String>): Int {
val matrix = input.map { it.map(Char::digitToInt) }
var counter = 0
for ((i, _) in matrix.withIndex()) {
val row = matrix[i]
for ((j, _) in row.withIndex()) {
if (i == 0 || i == matrix.size - 1 || j =... | 1 | Kotlin | 0 | 1 | f49aea1755c8b2d479d730d9653603421c355b60 | 2,363 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | frozbiz | 573,457,870 | false | {"Kotlin": 124645} | import java.util.SortedMap
import java.util.SortedSet
class FileSystem(consoleOutput: List<String>) {
interface Node {
val type: Type
val name: String
val size: Int
enum class Type {
DIRECTORY, FILE
}
fun print(tabSize: Int = 2, indent: Int = 0) {
... | 0 | Kotlin | 0 | 0 | 4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388 | 4,524 | 2022-aoc-kotlin | Apache License 2.0 |
src/Day11.kt | li-xin-yi | 573,617,763 | false | {"Kotlin": 23422} | fun main() {
fun gcd(a: Int, b: Int): Int {
if (a == 0) return b
return gcd(b % a, a)
}
fun solvePart1(input: List<String>): Int {
val starts = mutableListOf<MutableList<Int>>()
val funcs = mutableListOf<(Int) -> Unit>()
val n = (input.size + 1) / 7
val res... | 0 | Kotlin | 0 | 1 | fb18bb7e462b8b415875a82c5c69962d254c8255 | 3,650 | AoC-2022-kotlin | Apache License 2.0 |
solutions/aockt/y2023/Y2023D19.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2023
import aockt.util.parse
import io.github.jadarma.aockt.core.Solution
object Y2023D19 : Solution {
/** The Xmas rating system categories. */
private enum class XmasCategory { X, M, A, S }
/** A mechanical part, rated by its XMAS category scores. */
@JvmInline
private value cla... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 6,634 | advent-of-code-kotlin-solutions | The Unlicense |
src/Day02.kt | phamobic | 572,925,492 | false | {"Kotlin": 12697} | private enum class RoundEnd(
val score: Int
) {
LOSE(0),
DRAW(3),
WIN(6);
fun getOppositeEnd(): RoundEnd = when (this) {
LOSE -> WIN
DRAW -> DRAW
WIN -> LOSE
}
}
private sealed class Shape {
abstract val score: Int
abstract val opponentShapeToRoundEndMap: Map<Sh... | 1 | Kotlin | 0 | 0 | 34b2603470c8325d7cdf80cd5182378a4e822616 | 2,965 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/year_2022/Day07.kt | krllus | 572,617,904 | false | {"Kotlin": 97314} | package year_2022
import utils.readInput
fun main() {
fun processInput(input: List<String>): ElfFileItem {
val root = ElfFileItem(
parentNode = null, name = "/", type = ElfFileType.DIRECTORY
)
var currentNode: ElfFileItem? = null
var currentCommand: ElfCommand? = null
... | 0 | Kotlin | 0 | 0 | b5280f3592ba3a0fbe04da72d4b77fcc9754597e | 4,421 | advent-of-code | Apache License 2.0 |
LR7/src/main/kotlin/Task1V3.kt | Kirchberg | 602,987,232 | false | null | // В тексте нет слов, начинающихся одинаковыми буквами. Напечатать слова текста в таком порядке, чтобы последняя буква
// каждого слова совпадала с первой буквой последующего слова. Если все слова нельзя напечатать в таком порядке, найти
// такую цепочку, состоящую из наибольшего количества слов.
// The WordChainFinde... | 0 | Kotlin | 0 | 0 | b6a459a30ef20b0f38c4869d0949e22f4239183e | 2,938 | BigDataPL | MIT License |
src/main/kotlin/com/adventofcode/Forest.kt | reactivedevelopment | 575,344,265 | false | {"Kotlin": 2600, "Dockerfile": 379} | package com.adventofcode
import com.adventofcode.Forest.addTrees
import com.adventofcode.Forest.crosswalks
class Crosswalk(
private val tree: Int,
private val left: List<Int>,
private val right: List<Int>,
private val top: List<Int>,
private val bottom: List<Int>
) {
fun scenicScore(): Int {
val lef... | 0 | Kotlin | 0 | 0 | cf3ac594bf5966202ff95540a2113264a47ef76e | 2,113 | aoc-2022-8 | MIT License |
src/main/kotlin/com/ginsberg/advent2023/Day24.kt | tginsberg | 723,688,654 | false | {"Kotlin": 112398} | /*
* Copyright (c) 2023 by <NAME>
*/
/**
* Advent of Code 2023, Day 24 - Never Tell Me The Odds
* Problem Description: http://adventofcode.com/2023/day/24
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day24/
*/
package com.ginsberg.advent2023
class Day24(input: List<String>) {
... | 0 | Kotlin | 0 | 12 | 0d5732508025a7e340366594c879b99fe6e7cbf0 | 3,668 | advent-2023-kotlin | Apache License 2.0 |
advent-of-code2016/src/main/kotlin/day01/Advent1.kt | REDNBLACK | 128,669,137 | false | null | package day01
import day01.State.Direction.*
import parseInput
import splitToLines
/**
* --- Day 1: No Time for a Taxicab ---
Santa's sleigh uses a very high-precision clock to guide its movements, and the clock's oscillator is regulated by stars. Unfortunately, the stars have been stolen... by the Easter Bunny. To... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 3,514 | courses | MIT License |
src/main/kotlin/io/korti/adventofcode/day/DayTwelve.kt | korti11 | 225,589,330 | false | null | package io.korti.adventofcode.day
import io.korti.adventofcode.math.Axis
import io.korti.adventofcode.math.Vec3
import java.lang.Math.pow
import java.text.DecimalFormat
import java.util.*
import kotlin.math.abs
import kotlin.math.min
import kotlin.math.pow
typealias Planet = Pair<Vec3, Vec3>
class DayTwelve : Abstra... | 0 | Kotlin | 0 | 0 | 410c82ef8782f874c2d8a6c687688716effc7edd | 4,584 | advent-of-code-2019 | MIT License |
src/Day01.kt | djleeds | 572,720,298 | false | {"Kotlin": 43505} | fun main() {
data class Food(val calories: Int)
data class Elf(val inventory: List<Food>) {
val calorieCount = inventory.sumOf { it.calories }
}
fun List<String>.toElf() = Elf(map { Food(it.toInt()) })
fun <T> List<T>.split(boundary: (T) -> Boolean): List<List<T>> =
mapIndexed { in... | 0 | Kotlin | 0 | 4 | 98946a517c5ab8cbb337439565f9eb35e0ce1c72 | 1,115 | advent-of-code-in-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day15/Day15Puzzle.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day15
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
import java.util.*
abstract class Day15Puzzle : PuzzleSolver {
final override fun solve(inputLines: Sequence<String>) = lowestPathRisk(inputLines.toList()).toString()
abstract fun ... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 2,526 | AdventOfCode2021 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.