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/Day07.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
const val MAX_SIZE = 100000 const val TOTAL_SIZE = 70000000 const val FREE_SPACE = 30000000 fun main() { fun String.isCommand(): Boolean = startsWith("$ ") fun String.isLs(): Boolean = startsWith("$ ls") open class File(val name: String, val parent: File?, var size: Int = 0, val isDir: Boolean = false) { pr...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
2,130
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day08.kt
HaydenMeloche
572,788,925
false
{"Kotlin": 25699}
fun main() { val input = readInput("Day08") val parsed = input.map { it.toList().map { c -> c.toString().toInt() }} val visible = getVisibleCoords(parsed) println("answer one: ${visible.size}") val scenicMeasures = visible.map { calculateScenicMeasure(parsed, it.first, it.second) } println("a...
0
Kotlin
0
1
1a7e13cb525bb19cc9ff4eba40d03669dc301fb9
1,980
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day10.kt
sviams
115,921,582
false
null
object AoC_Day10 { data class SparseState(val list: List<Int>, val currIdx: Int, val skip: Int) fun createSparse(stepSequence: Sequence<Int>, initial: SparseState) = stepSequence.fold(initial) { state, steps -> val endIndex = (state.currIdx + steps) % initial.list.size val chan...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
1,787
aoc17
MIT License
src/day05/Day05.kt
pientaa
572,927,825
false
{"Kotlin": 19922}
package day05 import java.io.File fun main() { fun transformStacks(rawStacks: List<String>) = rawStacks.dropLast(1) .map { row -> row.mapIndexedNotNull { index, s -> if ((index - 1) % 4 == 0) s else null ...
0
Kotlin
0
0
63094d8d1887d33b78e2dd73f917d46ca1cbaf9c
2,809
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day10/SyntaxErrors.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day10 import utils.read fun main( ) { solve().let { println(it) } } fun solve(): List<Long> { val input = read("./src/main/resources/day10Input.txt") .map { it.toCharArray() } val syntaxChecks = input.map { checkSyntax(it) } val failureScore = syntaxChecks .map {...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
2,035
adventOfCode2021
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem336/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem336 /** * LeetCode page: [336. Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs/); * * Note1 : There is an implementation of trieNode that also records the indices of all words whose subString start * from there is a palindrome. It provides fast answer neede...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
5,498
hj-leetcode-kotlin
Apache License 2.0
2021/src/main/kotlin/com/trikzon/aoc2021/Day5.kt
Trikzon
317,622,840
false
{"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397}
package com.trikzon.aoc2021 import kotlin.math.max import kotlin.math.min fun main() { val input = getInputStringFromFile("/day5.txt") benchmark(Part.One, ::dayFivePartOne, input, 5442, 500) benchmark(Part.Two, ::dayFivePartTwo, input, 19571, 500) } fun dayFivePartOne(input: String): Int { val points...
0
Kotlin
1
0
d4dea9f0c1b56dc698b716bb03fc2ad62619ca08
2,179
advent-of-code
MIT License
src/Day08.kt
GreyWolf2020
573,580,087
false
{"Kotlin": 32400}
import java.lang.StrictMath.max fun main() { fun part1(input: List<String>): Int { val treesGraph = AdjacencyList<Int>() val verticesOfTreeHeight = treesGraph.parseVertices(input) return verticesOfTreeHeight .fold(0) { acc, vertex -> if (vertex `is max in all dir...
0
Kotlin
0
0
498da8861d88f588bfef0831c26c458467564c59
6,834
aoc-2022-in-kotlin
Apache License 2.0
src/Day24.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
import java.util.* fun main() { val wall = 0b10000 val u = 0b0001 val r = 0b0010 val d = 0b0100 val l = 0b1000 fun getStates(input: List<String>): List<Array<IntArray>> { val states = mutableListOf<Array<IntArray>>() val height = input.size val width = input[0].length ...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
4,790
AdventOfCode2022
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/day16/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day16 import com.bloidonia.aoc2023.text private const val example = """.|...\.... |.-.\..... .....|-... ........|. .......... .........\ ..../.\\.. .-.-/..|.. .|....-|.\ ..//.|....""" private data class Position(var x: Int, var y: Int) { operator fun plus(other: Position) = Position...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
3,684
aoc-2023
MIT License
src/main/kotlin/_2022/Day09.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput import kotlin.math.abs fun main() { fun tooFarAway(h: IntArray, t: IntArray): Boolean { return (abs(h[0] - t[0]) > 1) || (abs(h[1] - t[1]) > 1) } fun part1(input: List<String>): Int { val h = IntArray(2) var t = IntArray(2) val visitedPosit...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
2,452
advent-of-code
Apache License 2.0
project/src/problems/CountingElements.kt
informramiz
173,284,942
false
null
package problems object CountingElements { /** * Problem: You are given an integer m (1 <= m <= 1 000 000) and two non-empty, zero-indexed * arrays A and B of n integers, a0, a1, . . . , an−1 and b0, b1, . . . , bn−1 respectively (0 <= ai * , bi <= m). * The goal is to check whether there is a ...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
10,902
codility-challenges-practice
Apache License 2.0
src/days/Day02.kt
EnergyFusion
572,490,067
false
{"Kotlin": 48323}
fun main() { val playMap = mapOf( "A" to RPS.ROCK, "B" to RPS.PAPER, "C" to RPS.SCISSOR, "X" to RPS.ROCK, "Y" to RPS.PAPER, "Z" to RPS.SCISSOR, ) val myPlayMap = mapOf<String, (RPS) -> RPS>( "X" to { it.beats }, "Y" to { it }, "Z" to ...
0
Kotlin
0
0
06fb8085a8b1838289a4e1599e2135cb5e28c1bf
2,272
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/de/jball/aoc2022/day12/Day12.kt
fibsifan
573,189,295
false
{"Kotlin": 43681}
package de.jball.aoc2022.day12 import de.jball.aoc2022.Day import java.util.PriorityQueue class Day12(test: Boolean = false): Day<Long>(test, 31, 29) { private val areaMap = input.mapIndexed { line, letters -> letters.chunked(1) .mapIndexed { column, letter -> MountainPosition(...
0
Kotlin
0
3
a6d01b73aca9b54add4546664831baf889e064fb
4,342
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2020/JurassicJigsaw.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.countOccurrences import komu.adventofcode.utils.nonEmptyLines import kotlin.math.sqrt fun jurassicJigsaw1(input: String) = Jigsaw.parse(input).checksum() fun jurassicJigsaw2(input: String): Int { val monster = JigsawPattern( """ ...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
5,074
advent-of-code
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day12.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day12() = puzzle(day = 12) { // data class Memo(val left: List<Boolean?>, val sizes: List<Int>) data class Memo(val configIdx: Int, val sizesIdx: Int) data class Entry(val config: List<Boolean?>, val sizes: List<Int>) ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,986
advent-of-code
The Unlicense
src/main/kotlin/problems/Day4.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day4(override val input: String) : Problem { override val number: Int = 4 private val drawNumbers = input.lines().first().split(",").map { i -> i.toInt() } private val boards = input.split("\n\n").drop(1).map { boardStr -> Board.fromBoardString(boardStr) } override fun runPartO...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
3,338
AdventOfCode2021
MIT License
04maxpath/src/Main.kt
Minkov
125,619,391
false
null
fun fakeInput() { val test = """10 (5 <- 11) (1 <- 8) (11 <- 3) (8 <- 7) (1 <- 5) (11 <- 2) (8 <- 6) (2 <- 15) (8 <- 4)""" System.setIn(test.byteInputStream()) } fun main(args: Array<String>) { // fakeInput() println(solve()) } data class Result(var node: Int, var path: Long) { override fun toStrin...
0
JavaScript
4
1
3c17dcadd5aa201166d4fff69d055d7ec0385018
2,068
judge-solved
MIT License
src/Day09.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
import kotlin.math.abs fun main() { val directions = mapOf( "R" to (0 to 1), "L" to (0 to -1), "U" to (1 to 0), "D" to (-1 to 0) ) fun solvePart1(input: List<String>): Int { val seen = mutableSetOf(0 to 0) var (hx, hy) = 0 to 0 var (tx, ty) = 0 to 0 ...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
2,214
AoC-2022-kotlin
Apache License 2.0
src/Day02.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
fun main() { // Rock: A // Paper: B // Scissors: C val (rock, paper, scissors) = listOf(1, 2, 3); val (win, draw, loss) = listOf(6, 3, 0); fun part1(input: List<String>): Int { // Rock: X // Paper: Y // Scissors: Z val scores = hashMapOf( "A X" to d...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
1,507
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day07.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 import kotlin.math.absoluteValue /** * AoC 2017, Day 7 * * Problem Description: http://adventofcode.com/2017/day/7 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day7/ */ class Day07(input: List<String>) { pri...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
2,823
advent-2017-kotlin
MIT License
src/Day11.kt
RogozhinRoman
572,915,906
false
{"Kotlin": 28985}
fun main() { class Monkey( var items: MutableList<Long>, var operation: (old: Long) -> Long, var divisor: Long, var trueReceiver: Int, var falseReceiver: Int, var totalInspected: Long = 0 ) fun getTask2Monkeys(): List<Monkey> { return listOf( ...
0
Kotlin
0
1
6375cf6275f6d78661e9d4baed84d1db8c1025de
2,737
AoC2022
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day12/Day12.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day12 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseInts import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 12](https://adventofcode.com/2023/day/12) */ object Day12 : DayOf2023(12) { private val EMPTY = setOf('...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,932
adventofcode
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day07.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import com.dvdmunckhof.aoc.splitOnce class Day07(private val input: List<String>) { val root = parseTerminalOutput() fun solvePart1(): Int { val results = filterTree(root) { it.size < 100_000 } return results.sumOf { it.size } } fun solvePart2():...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,388
advent-of-code
Apache License 2.0
src/main/kotlin/year_2023/Day02.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2023 import Day import solve class Day02 : Day(day = 2, year = 2023, "Cube Conundrum") { private fun getGames() : Set<Game> { val games = mutableSetOf<Game>() for(entry in input){ val gameStr = entry.split(":") val id = gameStr.first().split(" ").last().toInt...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
2,325
advent-of-code
Apache License 2.0
src/main/kotlin/me/astynax/aoc2023kt/Day02.kt
astynax
726,011,031
false
{"Kotlin": 9743}
package me.astynax.aoc2023kt object Day02 { data class Take(val r: Int, val g: Int, val b: Int) { infix fun contains(other: Take): Boolean = r >= other.r && g >= other.g && b >= other.b private infix fun Int.max(other: Int): Int = if (this >= other) this else other infix fun max(other: Tak...
0
Kotlin
0
0
9771b5ccde4c591c7edb413578c5a8dadf3736e0
1,449
aoc2023kt
MIT License
archive/2022/Day09.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign private const val EXPECTED_1 = 13 private const val EXPECTED_2 = 1 private fun Pair<Int, Int>.update(other: Pair<Int, Int>): Pair<Int, Int> { val d = other.first - first to other.second - second if (max(d.first.absoluteValue, d.se...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,925
advent-of-code-2022
Apache License 2.0
src/Day05.kt
xNakero
572,621,673
false
{"Kotlin": 23869}
class Day05 { private val input = readInput("day05") private val commands = readCommands() fun part1(): String = readCrates() .let { commands.fold(it) { c, cmd -> moveCratesByOne(cmd, c) } } .toOutput() fun part2(): String = readCrates() .let { commands.fold(it) { c, cmd -> mo...
0
Kotlin
0
0
c3eff4f4c52ded907f2af6352dd7b3532a2da8c5
2,119
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode2019/Day10MonitoringStation.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2019 import java.lang.Math.toDegrees import kotlin.math.abs import kotlin.math.atan2 class Day10MonitoringStation data class Asteroid( val x: Int, val y: Int, var isVaborized: Boolean = false ) class Ceres(map: List<String>) { val asteroids: List<Asteroid> init { ast...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
3,719
kotlin-coding-challenges
MIT License
src/main/kotlin/aoc22/Day09.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import datastructures.Coordinate import readInput enum class Direction { UP, DOWN, LEFT, RIGHT; companion object { fun from(str: String) = when (str) { "U" -> UP "D" -> DOWN "L" -> LEFT "R" -> RIGHT else -> throw Exc...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
2,596
advent-of-code
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day02/day02.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day02 import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input02-test.txt" const val FILENAME = "input02.txt" fun main() { val puzzles = readLines(2023, FILENAME) .map { Puzzle.parse(it) } val possible = puzzles.filter { it.matches(12, 13, 14) }.sumOf { it.id } println(...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,527
advent-of-code
Apache License 2.0
src/y2021/d03/Day03.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2021.d03 import println import readInput fun main() { val classPath = "y2021/d03" fun part1(input: List<String>): Int { val length = input[0].length val halfSize = (input.size / 2) val counts = input.fold(IntArray(length)) { acc, line -> line.forEachIndexed { inde...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
1,728
aoc
Apache License 2.0
src/year2022/day13/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day13 import com.google.gson.JsonElement import io.kotest.matchers.shouldBe import utils.RecursiveList import utils.parseRecursiveList import utils.readInput fun main() { val testInput = readInput("13", "test_input").packetSequence() val realInput = readInput("13", "input").packetSequence() ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,774
Advent-of-Code
Apache License 2.0
2023/11/eleven.kt
charlottemach
433,765,865
false
{"D": 7911, "Haxe": 5698, "Go": 5682, "Julia": 5361, "R": 5032, "Kotlin": 4670, "Dockerfile": 4516, "C++": 4312, "Haskell": 4113, "Scala": 4080, "OCaml": 3901, "Raku": 3680, "Erlang": 3436, "Swift": 2863, "Groovy": 2861, "Vala": 2845, "JavaScript": 2735, "Crystal": 2210, "Python": 2197, "Clojure": 2172, "Ruby": 2163, "...
import java.io.File import java.math.BigInteger import java.util.Collections fun main() { val input = File("input.txt").readText() println(cosmicExpansion(input,2)) println(cosmicExpansion(input,1000000)) } fun cosmicExpansion(input: String, times: Int):BigInteger{ var lines = input.split("\n").dropLa...
0
D
0
0
dc839943639282005751b68a7988890dadf00f41
2,245
adventofcode
Apache License 2.0
2021/src/main/kotlin/day23.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import Day23.Cell.EMPTY import utils.Parser import utils.Point3i import utils.Solution fun main() { Day23.run() } object Day23 : Solution<Day23.Burrow>() { override val name = "day23" override val parser = Parser.lines.map { lines -> val roomCells = lines.drop(2).filter { "#########" !in it } .map { ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
6,358
aoc_kotlin
MIT License
src/Day03.kt
trosendo
572,903,458
false
{"Kotlin": 26100}
fun main() { fun getRepeatedInBothLists( list: Collection<Char>, middlePoint: Int ) = list.foldIndexed(emptySet<Char>() to emptySet<Char>()) { index, (firstHalf, repeated), currentChar -> if (index < middlePoint) firstHalf + currentChar to repeated else if (firstHalf.contains(cur...
0
Kotlin
0
0
ea66a6f6179dc131a73f884c10acf3eef8e66a43
1,455
AoC-2022
Apache License 2.0
src/day3/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day3 import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { Rucksack(it).duplicates().priority ?: 0 } } fun part2(input: List<String>): Int { return input .chunked(3) .mapNotNull { group -> group ...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
1,766
AoC-2022
Apache License 2.0
src/day5/Day05.kt
francoisadam
573,453,961
false
{"Kotlin": 20236}
package day5 import readInput fun main() { fun part1(input: List<String>): String { val stacks = input.takeWhile { it.isNotBlank() } val crates = stacks.toCrateStacks() val instructions = input.drop(stacks.size + 1).map { it.toInstruction() } instructions.forEach { instruction -> c...
0
Kotlin
0
0
e400c2410db4a8343c056252e8c8a93ce19564e7
3,417
AdventOfCode2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day23.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines import kotlin.math.abs object Day23 : Day { private val dirs = Direction.values().map { it.positions } override val input = parse(readInputLines(23)) override fun ...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,943
aoc2022
MIT License
src/main/kotlin/com/github/dangerground/aoc2020/Day13.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput fun main() { val process = Day13(DayInput.asStringList(13)) println("result part 1: ${process.part1()}") println("result part 2: ${process.part2()}") } class Day13(val input: List<String>) { val earliestDep...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
2,828
adventofcode-2020
MIT License
src/main/kotlin/net/navatwo/adventofcode2023/day8/Day8Solution.kt
Nava2
726,034,626
false
{"Kotlin": 100705, "Python": 2640, "Shell": 28}
package net.navatwo.adventofcode2023.day8 import net.navatwo.adventofcode2023.framework.ComputedResult import net.navatwo.adventofcode2023.framework.Solution sealed class Day8Solution : Solution<Day8Solution.Input> { data object Part1 : Day8Solution() { override fun solve(input: Input): ComputedResult { v...
0
Kotlin
0
0
4b45e663120ad7beabdd1a0f304023cc0b236255
5,550
advent-of-code-2023
MIT License
src/Day05.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
data class Command(val move: Int, val from: Int, val to: Int) fun main() { fun makeStacks(input: List<String>): MutableList<MutableList<Char>> { val mid = input.indexOfFirst { it.isEmpty() } val crates = input.take(mid - 1).reversed().map { it.chunked(4).map { it.find { it.isUpperCase() } }} ...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
2,230
aoc2022
Apache License 2.0
src/Day13.kt
acrab
573,191,416
false
{"Kotlin": 52968}
import com.google.common.truth.Truth.assertThat import kotlinx.serialization.json.* enum class ItemOrdering { Correct, Incorrect, Undecided } fun main() { fun compareIntegers(left: Int, right: Int): ItemOrdering = when { left == right -> ItemOrdering.Undecided left < right -> ...
0
Kotlin
0
0
0be1409ceea72963f596e702327c5a875aca305c
3,121
aoc-2022
Apache License 2.0
src/main/kotlin/Day4.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List import kotlin.math.pow object Day4 { data class CardData(val cardIndex: Int, val winningNumberCount: Int) { companion object { fun parseCardData(input: String): CardData { val (cardInformation, numberInformation) = input.split(...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
2,054
kotlin-kringle
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2022/d20/Day20.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d20 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines const val KEY = 811589153 data class Node(val num: Int, var prev: Node?, var next: Node?) { override fun toString() = "Node(num=$num, prev=${pr...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,685
advent-of-code
MIT License
src/main/kotlin/tr/emreone/kotlin_utils/math/Math.kt
EmRe-One
442,916,831
false
{"Kotlin": 173543}
package tr.emreone.kotlin_utils.math import tr.emreone.kotlin_utils.extensions.safeTimes import kotlin.math.absoluteValue import kotlin.math.pow /** * Euclid's algorithm for finding the greatest common divisor of a and b. */ fun gcd(a: Int, b: Int): Int = if (b == 0) a.absoluteValue else gcd(b, a % b) fun gcd(f: In...
0
Kotlin
0
0
aee38364ca1827666949557acb15ae3ea21881a1
2,776
kotlin-utils
Apache License 2.0
src/Day07.kt
jordanfarrer
573,120,618
false
{"Kotlin": 20954}
fun main() { val day = "Day07" fun parseCommands(input: List<String>): FsDirectory { val fs = FsDirectory(null, "", "", mutableListOf(), mutableListOf()) var currentDir = fs input.forEach { command -> val parts = command.split(" ") if (parts.size < 2) error("Not...
0
Kotlin
0
1
aea4bb23029f3b48c94aa742958727d71c3532ac
3,816
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TreeOfCoprimes.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,617
kotlab
Apache License 2.0
src/Day20.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
fun main() { val testInput = readInput("Day20_test") check(part1(testInput) == 3L) check(part2(testInput) == 1623178306L) val input = readInput("Day20") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Long = solve(input, String::toLong, mixesCount = 1) pri...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
2,351
AOC2022
Apache License 2.0
src/day03/Day03.kt
AbolfaZlRezaEe
574,383,383
false
null
package day03 import readInput fun main() { fun alphabetLowercaseCodeList(): HashMap<Char, Int> { return hashMapOf<Char, Int>().apply { put('a', 1) put('b', 2) put('c', 3) put('d', 4) put('e', 5) put('f', 6) put('g', 7) ...
0
Kotlin
0
0
798ff23eaa9f4baf25593368b62c2f671dc2a010
3,720
AOC-With-Me
Apache License 2.0
src/main/kotlin/Day07.kt
joostbaas
573,096,671
false
{"Kotlin": 45397}
sealed interface FileSystem { val name: String val size: Int get() = when (this) { is Directory -> children.sumOf { it.size } is File -> fileSize } } data class File( override val name: String, val fileSize: Int, ) : FileSystem data class Directory( overri...
0
Kotlin
0
0
8d4e3c87f6f2e34002b6dbc89c377f5a0860f571
2,439
advent-of-code-2022
Apache License 2.0
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day15.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 import kotlin.math.abs /** * https://adventofcode.com/2022/day/15 */ class Day15(override val input: String) : Day() { override fun part1(): String { val fixedy = if (input.startsWith(SAMPLE_START)) 10 else 2_000_000 val sd = parseSensorData() val lowx ...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
2,491
adventofcode2022
MIT License
src/Day08.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun main() { fun isVisible(input: List<String>, element: Char, x: Int, y: Int): Boolean { if ((0 until x).all { element.digitToInt() > input[y][it].digitToInt() }) return true if ((x + 1..input[y].lastIndex).all { element.digitToInt() > input[y][it].digitToInt() }) return true if ((0 until ...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
2,277
Advent-of-code
Apache License 2.0
src/main/kotlin/Puzzle16.kt
namyxc
317,466,668
false
null
import java.math.BigInteger object Puzzle16 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle16::class.java.getResource("puzzle16.txt").readText() val ticketInfo = TicketInfo(input) println(ticketInfo.sumInvalidNumbers()) println(ticketInfo.getProdOfDepartmentFie...
0
Kotlin
0
0
60fa6991ac204de6a756456406e1f87c3784f0af
4,123
adventOfCode2020
MIT License
src/Day07.kt
george-theocharis
573,013,076
false
{"Kotlin": 10656}
fun main() { val root = Node("/", null) val nodes = mutableListOf<Node>() var currentNode = root fun part1(input: List<String>): Long { input.forEach { command -> when { command == "$ cd /" -> currentNode = root command == "$ cd .." -> currentNode = ...
0
Kotlin
0
0
7971bea39439b363f230a44e252c7b9f05a9b764
1,475
aoc-2022
Apache License 2.0
src/y2023/Day21.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Pos import util.neighborsManhattan import util.readInput import util.timingStatistics object Day21 { private fun parse(input: List<String>): Pair<Set<Pair<Int, Int>>, Pair<Int, Int>> { var start = 0 to 0 return input.flatMapIndexed { row, line -> line.mapIndex...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
6,141
advent-of-code
Apache License 2.0
src/Day04.kt
cjosan
573,106,026
false
{"Kotlin": 5721}
fun main() { fun String.toIntRange(): List<IntRange> = this.split(",") .map { it.substringBefore("-").toInt() .. it.substringAfter("-").toInt() } infix fun IntRange.fullyOverlaps(other: IntRange): Boolean = first <= other.first && last >= other.last infix fun...
0
Kotlin
0
0
a81f7fb9597361d45ff73ad2a705524cbc64008b
1,191
advent-of-code2022
Apache License 2.0
advent2021/src/main/kotlin/year2021/Day03.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2021 import AdventDay import kotlin.math.pow private operator fun UInt.get(index: Int) = (this shr (UInt.SIZE_BITS - 1 - index)) % 2u private fun UInt.invert(bits: Int) = inv() % 2.0.pow(bits).toUInt() object Day03 : AdventDay(2021, 3) { override fun part1(input: List<String>): Int { val par...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,738
advent-of-code
Apache License 2.0
aoc2023/day13.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day13.execute() } private object Day13 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<ReflectionPattern>): Long = input.s...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
2,348
Advent-Of-Code
MIT License
aoc-2023/src/main/kotlin/aoc/aoc10.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.* val testInput = """ ........... .S-------7. .|F-----7|. .||.....||. .||.....||. .|L-7.F-J|. .|..|.|..|. .L--J.L--J. ........... """.parselines class Maze(val grid: List<String>) { val xr = grid[0].indices val yr = grid.indices val co...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
3,037
advent-of-code
Apache License 2.0
LeetCode2020April/week1/src/main/kotlin/net/twisterrob/challenges/leetcode2020april/week1/happy_number/Solution.kt
TWiStErRob
136,539,340
false
{"Kotlin": 104880, "Java": 11319}
package net.twisterrob.challenges.leetcode2020april.week1.happy_number class Solution { fun isHappy(n: Int): Boolean = !n.happySequence().hasRepeatingElement() } /** * Finds if there's a repetition in the sequence. The input has to be in a strict format: * * either all elements are distinct * * or if there's ...
1
Kotlin
1
2
5cf062322ddecd72d29f7682c3a104d687bd5cfc
1,136
TWiStErRob
The Unlicense
src/main/kotlin/com/ginsberg/advent2021/Day09.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 9 - Smoke Basin * Problem Description: http://adventofcode.com/2021/day/9 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day9/ */ package com.ginsberg.advent2021 class Day09(input: List<String>) { private val ca...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,981
advent-2021-kotlin
Apache License 2.0
src/main/kotlin/y2023/Day5.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day class Day5 : Day(5, 2023, false) { override fun partOne(): Any { return inputString.parseAlmanac().run { seeds.minOf { seed -> maps.findLocationForSeed(seed) } } } override fun partTwo(): Any { return inputStri...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
1,866
adventofcode
MIT License
day-11/src/main/kotlin/DumboOctopus.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private fun partOne(): Int { val matrix = readInputLines() .map { line -> line.toCharArray().map { it.digitToInt() }.toIntArray() } .toTypedArray() var count = 0 for (i in 1..100) ...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
2,621
aoc-2021
MIT License
kotlin/src/main/kotlin/year2023/Day14.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 import year2023.Day14.Direction.* fun main() { val input = readInput("Day14") Day14.part1(input).println() Day14.part2(input).println() } object Day14 { fun part1(input: List<String>): Int { return input .rollRocksToNorth() .mapIndexed { row, line -> c...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
5,939
advent-of-code
MIT License
src/main/kotlin/com/ryanmoelter/advent/day03/Rucksacks.kt
ryanmoelter
573,615,605
false
{"Kotlin": 84397}
package com.ryanmoelter.advent.day03 fun main() { println(calculateBadgePriority(day03input)) } fun calculateBadgePriority(input: String): Int = input.lineSequence() .fold(listOf(emptyList<String>())) { groups, line -> val lastGroup = groups.last() if (lastGroup.size < 3) { groups.minus(element = la...
0
Kotlin
0
0
aba1b98a1753fa3f217b70bf55b1f2ff3f69b769
1,143
advent-of-code-2022
Apache License 2.0
src/Day18.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
fun main() { data class Dot(val x: Int, val y: Int, val z: Int) { fun move(dx: Int = 0, dy: Int = 0, dz: Int = 0): Dot = Dot(x + dx, y + dy, z + dz) } fun getDotsAround(dot: Dot): Sequence<Dot> = sequence { yield(dot.move(dx = 1)) yield(dot.move(dy = 1)) yield(dot.move(dz = ...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
2,558
aoc2022
Apache License 2.0
src/Day08.kt
rod41732
728,131,475
false
{"Kotlin": 26028}
import java.lang.Exception /** * You can edit, run, and share this code. * play.kotlinlang.org */ fun main() { data class Node(val name: String, val left: String, val right: String); fun gcd(a: Long, b: Long): Long { if (b == 0L) return a return gcd(b, a % b) } fun lcm(a: Long, b: ...
0
Kotlin
0
0
05a308a539c8a3f2683b11a3a0d97a7a78c4ffac
2,386
aoc-23
Apache License 2.0
src/Day18.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File // Advent of Code 2022, Day 18, Boiling Boulders fun main() { fun readInputAsOneLine(name: String) = File("src", "$name.txt").readText().trim() fun getNeighbors(cube: List<Int>) : List<List<Int>> { return listOf( listOf(cube[0], cube[1], cube[2] + 1), list...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
2,487
AdventOfCode2022
Apache License 2.0
src/y2021/Day10.kt
Yg0R2
433,731,745
false
null
package y2021 import java.util.ArrayDeque import java.util.Deque private val AUTO_COMPLETE_CHARACTER_SCORE = mapOf( ')' to 1L, ']' to 2L, '}' to 3L, '>' to 4L ) private val ILLEGAL_CHARACTER_SCORE = mapOf( ')' to 3, ']' to 57, '}' to 1197, '>' to 25137 ) private val TAGS = mapOf( ...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
2,338
advent-of-code
Apache License 2.0
src/Day08.kt
acunap
573,116,784
false
{"Kotlin": 23918}
import kotlin.math.max import kotlin.time.ExperimentalTime import kotlin.time.measureTime @OptIn(ExperimentalTime::class) fun main() { fun part1(input: List<String>) : Int { var count = input.size * 2 + input.first().count() * 2 - 4 for (row in 1 until input.lastIndex) { for (column in...
0
Kotlin
0
0
f06f9b409885dd0df78f16dcc1e9a3e90151abe1
2,533
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day03.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay // https://adventofcode.com/2023/day/3 object Day03 : AoCDay<Int>( title = "Gear Ratios", part1ExampleAnswer = 4361, part1Answer = 553079, part2ExampleAnswer = 467835, part2Answer = 84363105, ) { private data class Point(val row: Int, val col: Int) private cla...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,505
advent-of-code-kotlin
MIT License
src/Day04.kt
Yasenia
575,276,480
false
{"Kotlin": 15232}
fun main() { fun String.toAssignments(): Pair<Pair<Int, Int>, Pair<Int, Int>> { val assignments = this.split(",") val assignment1 = assignments[0].split("-") val assignment2 = assignments[1].split("-") return Pair(assignment1[0].toInt() to assignment1[1].toInt(), assignment2[0].toIn...
0
Kotlin
0
0
9300236fa8697530a3c234e9cb39acfb81f913ba
1,143
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/puzzle3/BinaryDiagnostic.kt
tpoujol
436,532,129
false
{"Kotlin": 47470}
package puzzle3 import kotlin.math.pow import kotlin.math.roundToInt fun main() { println("Hello World!") val binaryDiagnostic = BinaryDiagnostic() println("Power consumption is: ${binaryDiagnostic.findPowerConsumption()}, ${binaryDiagnostic.findLifeSupportRating()}") } class BinaryDiagnostic { pri...
0
Kotlin
0
1
6d474b30e5204d3bd9c86b50ed657f756a638b2b
3,222
aoc-2021
Apache License 2.0
src/day8/Day08-solution2.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day8 import readInput private fun part1(input: List<String>): Int { val grid: Array<IntArray> = Array(input.size) { IntArray(input[0].length) } for (row in input.indices) { for (col in 0 until input[row].length) { grid[row][col] = input[row][col].digitToInt() } } v...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
2,074
aoc-2022
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector3D import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 22](https://adventofcode.com/2021/day/22) */ object Day22 : DayOf2021(22) { private val PATTERN = "(on|off) x=(-?\\d+)\\.\\.(-?\\d+),y=(-?...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,640
adventofcode
MIT License
app/src/main/kotlin/aoc2022/day02/Day02.kt
dbubenheim
574,231,602
false
{"Kotlin": 18742}
package aoc2022.day02 import aoc2022.day02.Day02.Result.* import aoc2022.day02.Day02.part1 import aoc2022.day02.Day02.part2 import aoc2022.toFile object Day02 { fun part1() = "input-day02.txt".toFile() .readLines() .map { it.toRound() } .sumOf { it.score } fun part2() = "input-day02.t...
8
Kotlin
0
0
ee381bb9820b493d5e210accbe6d24383ae5b4dc
3,435
advent-of-code-2022
MIT License
src/day3/Day03.kt
mrm1st3r
573,163,888
false
{"Kotlin": 12713}
package day3 import Puzzle fun splitCompartments(s: String): Pair<String, String> { val middle = s.length / 2 return Pair(s.substring(0, middle), s.substring(middle, s.length)) } fun findOverlap(compartments: Pair<String, String>): String { return compartments.first.filter { compartments.second.co...
0
Kotlin
0
0
d8eb5bb8a4ba4223331766530099cc35f6b34e5a
1,183
advent-of-code-22
Apache License 2.0
src/main/kotlin/Day02.kt
NielsSteensma
572,641,496
false
{"Kotlin": 11875}
fun main() { val input = readInput("Day02") println("Day 02 Part 1 ${calculateDay02Part1(input)}") println("Day 02 Part 2 ${calculateDay02Part2(input)}") } fun calculateDay02Part1(input: List<String>): Int { return input.sumOf { val opponentPlayerChars = extractChars(it) calculateRockPa...
0
Kotlin
0
0
4ef38b03694e4ce68e4bc08c390ce860e4530dbc
2,925
aoc22-kotlin
Apache License 2.0
src/Day11.kt
6234456
572,616,769
false
{"Kotlin": 39979}
import java.math.BigInteger data class Monkey(var item: java.util.LinkedList<Long> = java.util.LinkedList<Long>(), var operation: (Long)->Long = {it}, var divisor: Int = 1, var ifTrue: Int = -1, var ifFalse: Int = -1) data class Monkey0(var item: java.util.LinkedList<BigInteger> = java.util.LinkedLi...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
4,480
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day04_test") check(part1(testInput) == 2) check(part2(testInput) == 4) val input = readInput("Day04") println(part1(input)) println(part2(input)) } private fun part1(input: List<Str...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
1,189
aoc-2022
Apache License 2.0
src/Day07.kt
arisaksen
573,116,584
false
{"Kotlin": 42887}
import org.assertj.core.api.Assertions.assertThat // https://adventofcode.com/2022/day/7 fun main() { open class File(var size: Long) class Dir : File(size = 0L) { val files = mutableListOf<File>() var parent: Dir? = null operator fun plusAssign(otherFile: File) { size += o...
0
Kotlin
0
0
85da7e06b3355f2aa92847280c6cb334578c2463
3,197
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/day13/Day13.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day13 import java.io.File import kotlin.math.abs fun main() { val (points, folds) = parse("src/main/kotlin/day13/Day13.txt") val answer1 = part1(points, folds) val answer2 = part2(points, folds) println("🎄 Day 13 🎄") println() println("[Part 1]") println("Answer: $answer1") ...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
2,347
advent-of-code-2021
MIT License
src/Day05.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.util.Stack fun main() { fun List<Char>.toStack(): Stack<Char> { val result = Stack<Char>() this.reversed().forEach { result.push(it) } return result } fun getStacks(stackInput: List<String>): List<Stack<Char>> { val listsByIndex = stackInput[stackInput.size - 2].chunked(4).map { mu...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
1,643
aoc-2022-in-kotlin
Apache License 2.0
AdventOfCode/2022/aoc22/src/main/kotlin/day8.kt
benhunter
330,517,181
false
{"Rust": 172709, "Python": 143372, "Kotlin": 37623, "Java": 17629, "TypeScript": 3422, "JavaScript": 3124, "Just": 1078}
fun day8() { val day = 8 println("day $day") val filename = "$day-input.txt" // val filename = "$day-test.txt" val text = getTextFromResource(filename).trim() val lines = text.split("\n") debugln(lines) val trees = lines.map { line -> line.map { it.digitToInt() } } debugln(trees) ...
0
Rust
0
1
a424c12f4d95f9d6f8c844e36d6940a2ac11d61d
4,187
coding-challenges
MIT License
baparker/15/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File data class CavePosition(val level: Int, val x: Int, val y: Int) { var visited = false var distanceFromStart = Int.MAX_VALUE } fun findPathWithLowestRisk( cavePositionMatrix: MutableList<MutableList<CavePosition>>, x: Int = 0, y: Int = 0, counter: Int = -1 ) ...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
2,469
advent-of-code-2021
MIT License
src/main/kotlin/kt/kotlinalgs/app/graph/PrimMST.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph import java.util.* println("Test") Solution().test() class Solution { fun test() { //https://www.geeksforgeeks.org/prims-mst-for-adjacency-list-representation-greedy-algo-6/ val vertice0 = Vertice(0) val vertice1 = Vertice(1) val vertice2 = Vertice...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
3,951
KotlinAlgs
MIT License
src/Day09.kt
razvn
573,166,955
false
{"Kotlin": 27208}
import kotlin.math.abs fun main() { val day = "Day09" fun part1(input: List<String>): Int { val head = createRope(2) input.map { it.split(" ").let { (d, n) -> Direction.valueOf(d) to n.toInt() } }.forEach { head.move(it.first, it.second) } return...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
3,337
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/adventofcode2023/day19/day19.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day19 import adventofcode2023.readInput import kotlin.math.max import kotlin.math.min import kotlin.reflect.KProperty1 import kotlin.time.measureTime fun main() { println("Day 19") val input = readInput("day19") val time1 = measureTime { println("Puzzle 1 ${puzzle1(input)}...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
6,210
adventofcode2023
MIT License
src/day5/Day05.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day5 import readInput const val NEXT_ELEMENT_DISTANCE = 4 const val ITERATION_NUMBER_INDEX = 1 const val FROM_INDEX = 3 const val TO_INDEX = 5 private fun createInitialStacks(initialInput: List<String>): Array<ArrayDeque<Char>> { val max = initialInput.last().split(" ").last() val stacks = Array(max....
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
2,052
aoc-2022
Apache License 2.0
src/day02/Day02.kt
tobihein
569,448,315
false
{"Kotlin": 58721}
package day02 import readInput class Day02 { fun part1(): Int { val readInput = readInput("day02/input") return part1(readInput) } fun part2(): Int { val readInput = readInput("day02/input") return part2(readInput) } fun part1(input: List<String>): Int = input.map...
0
Kotlin
0
0
af8d851702e633eb8ff4020011f762156bfc136b
2,849
adventofcode-2022
Apache License 2.0
year2018/src/main/kotlin/net/olegg/aoc/year2018/day12/Day12.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day12 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2018.DayOf2018 /** * See [Year 2018, Day 12](https://adventofcode.com/2018/day/12) */ object Day12 : DayOf2018(12) { override fun first(): Any? { return solve(20) } override fun second(): Any? { return ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,110
adventofcode
MIT License
src/main/kotlin/io/math/StringToIntAtoi.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.math import io.utils.runTests import kotlin.math.absoluteValue // https://leetcode.com/problems/string-to-integer-atoi/ class StringToIntAtoi { fun execute(input: String): Int { val firstNoWhiteSpace = input.firstNoWhiteSpace() if (firstNoWhiteSpace !in input.indices) return 0 val firstChar ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,975
coding
MIT License
src/Day03.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
fun letterValue(char: Char): Int { return if (char.isLowerCase()) char.minus('a') + 1 else char.minus('A') + 27 } fun main() { fun part1(input: List<String>): Int { var totalPriority = 0 for (rucksack in input) { val compartment1 = rucksack.substring(0, rucksack.length / 2) ...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
1,337
adventofcode2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/GetMaximumGold.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,864
kotlab
Apache License 2.0
src/Day07.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
const val TOTAL_SPACE = 70_000_000 const val SPACE_NEEDED = 30_000_000 enum class NodeType { DIR, FILE, } class INode(val type: NodeType, val name: String, var size: Int, val parent: INode?, val children: MutableSet<INode>?) { fun attachNode(node: INode): Boolean { if (this.type == NodeType.FILE) ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,327
aoc2022
Apache License 2.0
src/day21/Day21.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day21 import readInput import kotlin.math.abs val addOp = { a: Long, b: Long -> a + b } val subtractOp = { a: Long, b: Long -> a - b } val multiplyOp = { a: Long, b: Long -> a * b } val divideOp = { a: Long, b: Long -> a / b } val symbolToOp = mapOf( '+' to addOp, '-' to subtractOp, '*' to multi...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
3,894
advent-of-code-2022
Apache License 2.0
baparker/09/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File data class Node(val value: Int) { var visited = false } data class Counter(var value: Int) { fun incCounter() { this.value++ } } fun findMins( heightMatrix: MutableList<MutableList<Node>>, x: Int, y: Int, ) { val current = heightMatrix.get(y).get(x)...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
3,008
advent-of-code-2021
MIT License
src/Day02.kt
rxptr
572,717,765
false
{"Kotlin": 9737}
enum class Hand(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); infix fun draw(other: Hand): Hand? { if (beats[this] == other) return this if (beatenBy[this] == other) return other return null } infix fun expect(outcome: Outcome) : Hand { if (outcome == Outcome.First...
0
Kotlin
0
0
989ae08dd20e1018ef7fe5bf121008fa1c708f09
3,258
aoc2022
Apache License 2.0
src/day10/Day10.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day10 import readInput typealias Coord = Pair<Int,Int> enum class Direction(val coord: Coord) { LEFT(Pair(-1, 0)), RIGHT(Pair(1, 0)), TOP(Pair(0, -1)), BOTTOM(Pair(0, 1)) } val rightConnectable = listOf('-', 'F', 'L', 'S') val leftConnectable = listOf('-', '7', 'J', 'S') val bottomConnectable...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
2,988
advent-of-code-2023-kotlin
Apache License 2.0