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/day24/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day24 import util.Direction2NonDiagonal import util.Direction2NonDiagonal.* import util.PathFindingMove import util.PathFindingState import util.Point import util.Rect import util.boundingRect import util.findPath import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::cla...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
3,123
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/RelativeSortArray.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 1122. 数组的相对排序 * * 给你两个数组,arr1 和 arr2, * * arr2 中的元素各不相同 * arr2 中的每个元素都出现在 arr1 中 * 对 arr1 中的元素进行排序,使 arr1 中项的相对顺序和 arr2 中的相对顺序相同。未在 arr2 中出现过的元素需要按照升序放在 arr1 的末尾。 * * 示例: * * 输入:arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6] * 输出:[2,2,2,1,4,3,3,9,6,7,19] ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
3,981
daily_algorithm
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day07.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part7A : PartSolution() { private lateinit var commands: List<Command> internal lateinit var tree: File override fun parseInput(text: String) { val commands: MutableList<C...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
4,195
advent-of-code-kotlin
MIT License
src/main/kotlin/aoc07/Solution07.kt
rainer-gepardec
573,386,353
false
{"Kotlin": 13070}
package aoc07 import java.nio.file.Paths import kotlin.math.abs class Node(val parent: Node?, val name: String, val type: String, val size: Int = 0) { val children = mutableListOf<Node>() override fun toString(): String { return "$name ($type)" } } fun main() { val lines = Paths.get("src/mai...
0
Kotlin
0
0
c920692d23e8c414a996e8c1f5faeee07d0f18f2
2,431
aoc2022
Apache License 2.0
src/main/kotlin/day8/Day8.kt
afTrolle
572,960,379
false
{"Kotlin": 33530}
package day8 import Day import ext.merge import ext.mergeMatrix import ext.transpose fun main() { Day8("Day08").apply { println(part1(parsedInput)) println(part2(parsedInput)) } } fun <E> List<List<E>>.forEachByRow( rowProgression: IntProgression = this.indices, colProgression: IntPro...
0
Kotlin
0
0
4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545
3,585
aoc-2022
Apache License 2.0
src/main/kotlin/Day09.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
import kotlin.math.abs fun main() { fun count(moves: List<Move>, length: Int): Int { val visited = mutableSetOf<Point>() var head = Point() val tail = mutableListOf<Point>() (0 until length).forEach { tail.add(Point()) } moves.forEach { move -> ...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
2,056
KotlinAdventOfCode2022
Apache License 2.0
src/Day02.kt
jamie23
573,156,415
false
{"Kotlin": 19195}
import Hand.* import kotlin.IllegalArgumentException fun main() { fun part1(input: List<String>) = input.sumOf { it[2].toHand().value + it[2].toHand().result(it[0].toHand()) } fun part2(input: List<String>) = input.sumOf { it[2].requiredHand(it[0].toHand()).value + it[2].resultToInt() ...
0
Kotlin
0
0
cfd08064654baabea03f8bf31c3133214827289c
1,569
Aoc22
Apache License 2.0
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/hashmaps/triplets/CountTriplets.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.hashmaps.triplets import java.util.* fun countTriplets(array: LongArray, ratio: Long): Long { fun modR(iv: IndexedValue<Long>) = iv.value % ratio == 0L fun divR(iv: IndexedValue<Long>) = IndexedValue(iv.index, iv.value / ratio) fun List<In...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
2,623
kotlin-hackerrank
MIT License
y2018/src/main/kotlin/adventofcode/y2018/Day04.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution object Day04 : AdventSolution(2018, 4, "Repose Record") { override fun solvePartOne(input: String): Int { val schedule = parseSchedule(input) val sleepiestGuard = schedule.maxByOrNull { g -> g.value.sumOf { it.last - it.first } }!!...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,762
advent-of-code
MIT License
src/main/kotlin/Problem27.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.pow /** * Quadratic primes * * Euler discovered the remarkable quadratic formula: n^2 + n + 41 * * It turns out that the formula will produce 40 primes for the consecutive integer values 0 <= n <= 39. However, when * is n = 40, 40^2 + 40 +41 = 40(40+1) + 41 divisible by 41, and certainly when ...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
1,716
project-euler
MIT License
src/Day11.kt
phoenixli
574,035,552
false
{"Kotlin": 29419}
fun main() { fun part1(input: List<String>): Long { val monkeys = mutableListOf<Monkey>() input.chunked(7).forEach { monkeys.add(Monkey.of(it)) } repeat(20) { monkeys.forEach { it.inspect(monkeys) } } return monkey...
0
Kotlin
0
0
5f993c7b3c3f518d4ea926a792767a1381349d75
3,346
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/algorithms/SelectionAlgorithms.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms fun main() { val quickSelect = QuickSelect(arrayOf(2, 4, 7, -1, 0, 9)) println("the kth smallest ${quickSelect.select(3)}") } class QuickSelect(val nums: Array<Int>) { // selection phase // quickSelect// // pivot = // partition // swap fun select(k: Int):...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,752
DS_Algo_Kotlin
MIT License
src/main/kotlin/2021/Day9.kt
mstar95
317,305,289
false
null
package `2021` import days.Day class Day9 : Day(9) { override fun partOne(): Any { val board = createBoard(inputList) return lowPoints(board).sumOf { it.second + 1 } } override fun partTwo(): Any { val board = createBoard(inputList) val basins = lowPoints(board).map { ...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,369
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day03.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
import kotlin.streams.toList fun main() { fun parseInput(input: List<String>) = input .filter { it.isNotEmpty() } .map { listOf(it.substring(0, it.length / 2), it.substring(it.length / 2)) } .map { rucksack -> rucksack.map { compartment -> compartment.chars().toL...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
1,279
advent-of-code-2022
Apache License 2.0
src/algorithmdesignmanualbook/sorting/BucketSort.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.sorting import algorithmdesignmanualbook.print import utils.assertIterableSame /** * Maintains bucket of 0..9 or a-z * The number of iterations requires depends on number of characters in longest element (length wise) * * [Algorithm](https://www.youtube.com/watch?v=JMlYkE8hGJM) ...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,538
algorithms
MIT License
src/Day03.kt
inssein
573,116,957
false
{"Kotlin": 47333}
fun main() { fun findCommon(a: String, b: String): String { val set = a.toSet() return b.filter { set.contains(it) } } fun Char.toPriority() = if (this.isLowerCase()) this - 'a' + 1 else this - 'A' + 27 fun part1(input: List<String>): Int { return input.sumOf { val...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,020
advent-of-code-2022
Apache License 2.0
Kotlin/src/dev/aspid812/leetcode/problem0056/Solution.kt
Const-Grigoryev
367,924,342
false
{"Python": 35682, "Kotlin": 11162, "C++": 2688, "Java": 2168, "C": 1076}
package dev.aspid812.leetcode.problem0056 /* 56. Merge Intervals * ------------------- * * Given an array of `intervals` where `intervals[i] = [start_i, end_i]`, merge all overlapping intervals, and return * *an array of the non-overlapping intervals that cover all the intervals in the input*. * * ### Constraint...
0
Python
0
0
cea8e762ff79878e2d5622c937f34cf20f0b385e
1,665
LeetCode
MIT License
src/Day02.kt
ciprig
573,478,617
false
null
fun main() { fun compare(first: Char, second: Char): Int { return when (first - second) { 0 -> 3 1, -2 -> 0 -1, 2 -> 6 else -> throw IllegalArgumentException() } + when (second) { 'X' -> 1 'Y' -> 2 'Z' -> 3 ...
0
Kotlin
0
0
e24dd65a22106bf5375d9d99c8b9d3b3a90e28da
1,451
aoc2022
Apache License 2.0
src/Day03.kt
realpacific
573,561,400
false
{"Kotlin": 59236}
fun main() { fun calculatePriority(item: Char) = if (item.isUpperCase()) item.code - 65 + 27 else item.code - 97 + 1 fun part1(input: List<String>): Int { var prioritySum = 0 input.forEach { rucksack -> val itemsCountInCompartment = rucksack.lastIndex / 2 val fi...
0
Kotlin
0
0
f365d78d381ac3d864cc402c6eb9c0017ce76b8d
1,280
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day12/day12.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package day12 import main.utils.Edge import main.utils.Graph import main.utils.measureAndPrint import utils.Coord import utils.readFile import utils.readLines fun main() { val test = readLines( """Sabqponm abcryxxl accszExk acctuvwj abdefghi""" ) val input = readFile("day12") data class Cell( val c:...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
3,341
aoc-2022-in-kotlin
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions66.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test66() { printlnResult("happy" to 3, trie = "hap") printlnResult("happy" to 3, "happen" to 2, trie = "hap") } /** * Questions 66: Design a data structure that could insert a string and a value. And, it contains * a function that can calculate the sum of all valu...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,988
Algorithm
Apache License 2.0
advent-of-code/src/main/kotlin/DayFourteen.kt
pauliancu97
518,083,754
false
{"Kotlin": 36950}
import kotlin.math.min class DayFourteen { data class Reindeer( val name: String, val speed: Int, val upTime: Int, val downTime: Int ) { companion object { val REGEX = """([a-zA-Z]+) can fly (\d+) km\/s for (\d+) seconds, but then must rest for (\d+) second...
0
Kotlin
0
0
3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6
2,720
advent-of-code-2015
MIT License
2020/src/main/kotlin/de/skyrising/aoc2020/day21/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2020.day21 import de.skyrising.aoc.* import java.util.* private fun solve(input: PuzzleInput): Pair<List<String>, Map<String, String>> { val allIngredients = mutableListOf<String>() val map = mutableMapOf<String, MutableSet<String>>() for (line in input.lines) { val split =...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,674
aoc
MIT License
src/Day01.kt
Lonexera
573,177,106
false
null
fun main() { fun List<String>.splitByEmpty(): List<List<String>> { return buildList { this@splitByEmpty.mapIndexedNotNull { index, string -> if (string.isBlank()) { index } else { null } } ...
0
Kotlin
0
0
c06d394cd98818ec66ba9c0311c815f620fafccb
1,302
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/day10.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day10 : Solvable("10") { override fun solveA(input: List<String>): String { return Math.abs(solve(input).filter { it < 0 }.sum()).toString() } override fun solveB(input: List<String>): String { solve(input).filter { it > 0 }.sorted().let { return it[it.size / 2].toString(...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,805
AdventOfCode
Creative Commons Zero v1.0 Universal
app/src/main/kotlin/de/tobiasdoetzer/aoc2021/Day3.kt
dobbsy
433,868,809
false
{"Kotlin": 13636}
package de.tobiasdoetzer.aoc2021 private fun part1(report: List<String>): Int { var gammaText = "" var epsilonText = "" val limit = report.size / 2 for (i in report[0].indices) { val numberOf0s = report.count { it[i] == '0' } if (numberOf0s > limit) { // more than half of the numbers i...
0
Kotlin
0
0
28f57accccb98d8c2949171cd393669e67789d32
2,230
AdventOfCode2021
Apache License 2.0
src/Day20.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import kotlin.math.abs fun main() { data class Node(val value: Long) { lateinit var next: Node lateinit var prev: Node override fun toString(): String = "${prev.value} < $value > ${next.value}" } val toLeft = {node: Node -> node.prev} val toRight = {node: Node -> node.next }...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
2,623
advent-of-code-2022
Apache License 2.0
src/Day04.kt
JCampbell8
572,669,444
false
{"Kotlin": 10115}
fun main() { fun parsePairs(input: List<String>): List<List<IntRange>> { val map = input.map { it.split(",") } .map { it.map { it2 -> val split = it2.split("-") split[0].toInt()..split[1].toInt() } } ret...
0
Kotlin
0
1
0bac6b866e769d0ac6906456aefc58d4dd9688ad
1,056
advent-of-code-2022
Apache License 2.0
src/day19/Day19.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day19 import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import readInput const val day = "19" fun main() = runBlocking { suspend fun calculatePart1Score(input: List<String>, steps: Int): Int { val blueprints = input.parseBlueprints() ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
4,365
advent-of-code-22-kotlin
Apache License 2.0
src/Day05.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
fun main() { data class MoveInstruction(val amount: Int, val from: Int, val to: Int) data class InputData(val stacks: Array<ArrayDeque<Char>>, val moves: List<MoveInstruction>) fun parseInput(input: String): InputData { fun parseStacks(data: String): Array<ArrayDeque<Char>> { val lines ...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
2,314
advent-of-code-2022
Apache License 2.0
src/Day21.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { abstract class Monkey(val name: String) class NumberMonkey(name: String, val number: Long) : Monkey(name) { override fun toString() = "NumberMonkey(name='$name', number=$number)" } class OperationMonkey( name: String, val leftName: String, val operation: Cha...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
3,694
AdventOfCode2022
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/WeightedLevenshtein.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.min /** * Implementation of Levenshtein that allows to define different weights for different character substitutions. * * @param weights the strategy to determine character operations weights. */ public class WeightedLevenshtein( private val weights: Operation...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
3,391
string-similarity-kotlin
MIT License
src/Day04.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
fun main() { fun IntRange.fullyContains(other: IntRange): Boolean = this.first <= other.first && this.last >= other.last fun findOverlaps(input: List<String>, shouldFullyContain: Boolean): Int = input.map { pair -> pair.split(",").map { range -> range.split("-").map { it.toInt() }.run { this[0]..this...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
847
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day15.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils import java.util.PriorityQueue class Day15 : Day(15) { private val floor = inputList.flatMapIndexed { y, row -> row.mapIndexed { x, c -> Position(Utils.Coord(x, y), c.digitToInt()) } } override fun partOne(): Any { return leastRiskyPath(floor) } override fun p...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
2,285
aoc-2021
Creative Commons Zero v1.0 Universal
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day09.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 import com.akikanellis.adventofcode.year2022.utils.Point import kotlin.math.absoluteValue object Day09 { fun numberOfPositionsTailVisited(input: String, numberOfKnots: Int) = input.lines() .filter { it.isNotBlank() } .map { it.split(" ") } .fla...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
2,717
advent-of-code
MIT License
src/main/kotlin/com/dmc/advent2022/Day10.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
package com.dmc.advent2022 //--- Day 10: Cathode-Ray Tube --- class Day10 : Day<Int> { override val index = 10 fun parseInput(input: List<String>) : List<Int> = buildList { add(1) // start value input.forEach{ line -> when { line.startsWith("...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
1,942
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/net/wrony/aoc2023/a14/14.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a14 import kotlin.io.path.Path import kotlin.io.path.readLines fun main() { Path("src/main/resources/14.txt").readLines().map { it.toCharArray() }.toTypedArray() .also { transpose(it).map { r -> shiftTheRow(r) }.toTypedArray().let { arr -> transpose(ar...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
2,905
aoc-2023-kotlin
MIT License
src/year2023/16/Day16.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`16` import readInput import utils.printDebug import utils.printlnDebug private const val CURRENT_DAY = "16" private data class Point( val x: Int, val y: Int, ) { val left get() = Point(x - 1, y) val right get() = Point(x + 1, y) val top get() = Point(x, y - 1) val bottom ge...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
6,869
KotlinAdventOfCode
Apache License 2.0
src/Day03.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
fun main() { fun charValue(c: Char) = when (c) { in 'A'..'Z' -> c.code - 'A'.code + 27 in 'a'..'z' -> c.code - 'a'.code + 1 else -> throw IllegalArgumentException() } fun part1(input: List<String>): Int { return input.asSequence() .map { it.toCharArray() } ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
1,092
aoc22
Apache License 2.0
src/day05/Day05.kt
commanderpepper
574,647,779
false
{"Kotlin": 44999}
package day05 import readInput fun main(){ val input = readInput("day05") val stacks: List<MutableList<Char>> = createStacks(input) val instructions: List<Instruction> = parseInstructions(input) // println(partOne(instructions, stacks)) println(partTwo(instructions, stacks)) } private fun partTw...
0
Kotlin
0
0
fef291c511408c1a6f34a24ed7070ceabc0894a1
2,066
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day03_binary_diagnostic/BinaryDiagnostic.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day03_binary_diagnostic import util.CountedToForeverException import util.countForever /** * Bit masking is the main idea here, along with avoiding needless redundant * processing. Since the gamma and epsilon rates are inverses, computing one * directly gives the other. * * Part two makes the masking mor...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,855
aoc-2021
MIT License
src/Day10.kt
dustinlewis
572,792,391
false
{"Kotlin": 29162}
import kotlin.math.floor fun main() { fun part1(input: List<String>): Int { val instructions = input.map { val split = it.split(" ") if (split[0] == "noop") Pair(split[0], 0) else Pair(split[0], split[1].toInt()) } println(instructions) val register = mutabl...
0
Kotlin
0
0
c8d1c9f374c2013c49b449f41c7ee60c64ef6cff
2,426
aoc-2022-in-kotlin
Apache License 2.0
Day 05 - Kotlin/source.kt
Lank891
433,842,037
false
{"TypeScript": 7986, "Scala": 7724, "Processing": 6002, "C++": 4359, "Dart": 3800, "Go": 3508, "Kotlin": 3409, "Python": 3330, "C": 3108, "Java": 3003, "C#": 2833, "Rust": 2624, "Ruby": 2441, "Haskell": 1526, "CoffeeScript": 1422, "JavaScript": 1399, "R": 846}
import java.io.File import kotlin.math.sign const val boardSize: Int = 1000; typealias XY = Pair<Int, Int>; typealias VentPath = Pair<XY, XY>; typealias Board = Array<Array<Int>> fun ventPathToString(path: VentPath): String { return "Path (${path.first.first}, ${path.first.second}) -> (${path.second.first}, ${pa...
0
TypeScript
0
1
4164b707630e4d6e84ede983f494e56470f3d080
3,409
Advent-of-Code-2021
MIT License
src/main/kotlin/org/example/adventofcode/puzzle/Day07.kt
peterlambrechtDev
573,146,803
false
{"Kotlin": 39213}
package org.example.adventofcode.puzzle import org.example.adventofcode.util.FileLoader object Day07 { fun part1(filePath: String): Int { val stringLines = FileLoader.loadFromFile<String>(filePath) var tree: FileNode? = buildTree(stringLines) populateDirectorySizes(tree!!) val l...
0
Kotlin
0
0
aa7621de90e551eccb64464940daf4be5ede235b
3,532
adventOfCode2022
MIT License
src/Day04.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
import kotlin.math.abs fun main() { // Processes input into lists of ints for each pair of assignments fun processInput(input: List<String>): List<Int> { val regex = Regex("[0-9]+") val assignments = mutableListOf<Int>() for (line in input) { assignments.addAll(regex.findAll...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
1,250
aoc-2022
Apache License 2.0
src/Day04.kt
mcrispim
573,449,109
false
{"Kotlin": 46488}
fun main() { fun Set<Int>.contains(s: Set<Int>): Boolean = this.intersect(s) == s fun part1(input: List<String>): Int { return input.count { line -> val limits = line.split("-", ",").map { it.toInt() } val (aStart, aEnd, bStart, bEnd) = limits val s1 = (aStart..aEnd...
0
Kotlin
0
0
5fcacc6316e1576a172a46ba5fc9f70bcb41f532
1,048
AoC2022
Apache License 2.0
src/Day13.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File // Advent of Code 2022, Day 13, Distress Signal fun compare(first: Packet, second: Packet) : Int { first.forEachIndexed { i, firstEl -> if (i > second.lastIndex) { return 1 // first is longer } val secondEl = second[i] val diff = if (firstEl.int != n...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
3,573
AdventOfCode2022
Apache License 2.0
src/main/kotlin/Seeding.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
import kotlin.math.abs fun main() = Seeding.solve() private object Seeding { fun solve() { var board = Board(readInput()) println("Initial") board.visualize() var i = 0 while (true) { println("$i") val direction = Direction.values()[i % 4] ...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
4,646
aoc2022
MIT License
src/main/kotlin/cc/stevenyin/leetcode/_0883_ProjectionAreaOf3DShapes.kt
StevenYinKop
269,945,740
false
{"Kotlin": 107894, "Java": 9565}
package cc.stevenyin.leetcode import kotlin.math.max /** * 883. Projection Area of 3D Shapes * https://leetcode.com/problems/projection-area-of-3d-shapes/ You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of ...
0
Kotlin
0
1
748812d291e5c2df64c8620c96189403b19e12dd
1,765
kotlin-demo-code
MIT License
src/main/kotlin/me/peckb/aoc/_2015/calendar/day13/Day13.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2015.calendar.day13 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import me.peckb.aoc.generators.PermutationGenerator import kotlin.math.max class Day13 @Inject constructor( private val permutationGenerator: PermutationGenerator, private val ...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
3,191
advent-of-code
MIT License
src/main/kotlin/com/nibado/projects/advent/y2017/Day24.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day import com.nibado.projects.advent.resourceLines object Day24 : Day { private val input = resourceLines(2017, 24).map { it.split("/").map { it.toInt() } }.map { it[0] to it[1] }.sortedBy { it.first } private val solution: List<List<...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,446
adventofcode
MIT License
src/main/kotlin/aoc2022/Day11.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput import separateBy import kotlin.math.floor /** * @property items the items currently held by this [Monkey] * @property operation a transformation operation representing the change in the "worry-level" * @property testDivisor the operand for the test ope...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,215
adventOfCode
Apache License 2.0
src/test/kotlin/be/brammeerten/y2023/Day7Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2023 import be.brammeerten.readFileAndSplitLines import be.brammeerten.toCharList import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test val POWERS: Map<Char, Int> = mapOf( 'A' to 13, 'K' to 12, 'Q' to 11, 'J' to 10, 'T' to 9, '9' to 8, ...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
4,295
Advent-of-Code
MIT License
src/main/kotlin/dev/bogwalk/util/maths/reusable.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.util.maths import java.math.BigInteger import kotlin.math.abs import kotlin.math.floor import kotlin.math.ln import kotlin.math.log10 import kotlin.math.sqrt /** * Calculates the sum of the first [this] natural numbers, based on the formula: * * {n}Sigma{k=1} k = n * (n + 1) / 2 * * Conv...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
17,505
project-euler-kotlin
MIT License
string-similarity/src/commonMain/kotlin/com/aallam/similarity/OptimalStringAlignment.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.min /** * Implementation of the Optimal String Alignment (sometimes called the restricted edit distance) variant * of the Damerau-Levenshtein distance. * * The difference between the two algorithms consists in that the Optimal String Alignment algorithm computes th...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
2,244
string-similarity-kotlin
MIT License
2018/kotlin/day20p2/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* import kotlin.math.min fun main(args: Array<String>) { val start = Date() val classLoader = RoomEx::class.java.classLoader val input = classLoader.getResource("input.txt").readText() println(numRoomsWithShortestPathOfAtLeast1000(input)) println("in ${Date().time - start.time}ms")...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
6,393
adventofcode
MIT License
src/main/kotlin/aoc2022/Day08.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import Point import readInput data class Tree(val position: Point, val height: Int) fun main() { fun getAllTrees(map: Array<IntArray>): Set<Tree> { val trees = mutableSetOf<Tree>() for (y in map.indices) { for (x in map[0].indices) { trees.add(Tree(Poi...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,818
adventOfCode
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/MergeIntervals.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* The "Merge Intervals" pattern is often used for problems involving intervals, time scheduling, or conflicting schedules. Let's tackle two problems: "Conflicting Appointments" and "Minimum Meeting Rooms." Usage: This technique is used to deal with overlapping intervals. */ //1. Conflicting Appointments data cla...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,337
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/day04/Day04.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day04 import readInput fun main() { fun IntRange.hasOverlap(other: IntRange): Boolean { return !(this.last < other.first || this.first > other.last) } fun IntRange.fullyContains(other: IntRange): Boolean { return this.first >= other.first && this.last <= other.last } fu...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
1,528
advent-of-code-2022
Apache License 2.0
2021/src/test/kotlin/Day09.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.test.Test import kotlin.test.assertEquals class Day09 { data class Coord(val x: Int, val y: Int) data class Location(val coord: Coord, val height: Int) private val moves = listOf(Coord(-1, 0), Coord(1, 0), Coord(0, -1), Coord(0, 1)) @Test fun `run part 01`() { val heatmap = g...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,497
adventofcode
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day10.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part10A : PartSolution() { lateinit var lines: List<String> override fun parseInput(text: String) { lines = text.split("\n") } override fun compute(): Any { ret...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,526
advent-of-code-kotlin
MIT License
src/Day03.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
fun main() { fun part1(input: List<String>): Int { var sum = 0 input.forEach { val (left, right) = it.chunked(it.length / 2) loop@ for (i in left) { for (j in right) { if (i == j) { val priority = if (i < 'a') i - 'A...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
1,435
AoC-2022
Apache License 2.0
src/day9/Code.kt
fcolasuonno
221,697,249
false
null
package day9 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2(parsed)}") } priv...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
1,940
AOC2016
MIT License
src/y2021/d05/Day05.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2021.d03 import kotlin.math.absoluteValue import kotlin.math.sign import println import readInput fun main() { val classPath = "y2021/d05" fun part1(input: List<String>): Int { val points = mutableMapOf<Pair<Int, Int>, Int>() input .forEach { val line = it...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
3,954
aoc
Apache License 2.0
src/Day09.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
import kotlin.math.absoluteValue fun main() { data class Point(var x: Int = 0, var y: Int = 0) { fun isTouching(other: Point) = ((this.x - other.x).absoluteValue <=1 && (this.y - other.y).absoluteValue <=1) } fun follow(curr: Point, next: Point) { if(!next.isTouching(curr)) { ...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
3,377
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/day3.kt
tianyu
574,561,581
false
{"Kotlin": 49942}
private fun main() { part1("The total priorities of all misplaced items is:") { withRucksacks { sumOf { rucksack -> assert(rucksack.length % 2 == 0) { "Rucksack does not have even length: $this" } val (left, right) = rucksack.splitAt(rucksack.length / 2) val mistakes = left.toSet() i...
0
Kotlin
0
0
6144cc0ccf1a51ba2e28c9f38ae4e6dd4c0dc1ea
1,011
AdventOfCode2022
MIT License
src/day4/Day04.kt
MatthewWaanders
573,356,006
false
null
package day4 import utils.readInput fun main() { val testInput = readInput("Day04_test", "day4") check(part1(testInput) == 2) check(part2(testInput) == 4) val input = readInput("Day04", "day4") println(part1(input)) println(part2(input)) } fun part1(input: List<String>) = input .map { pa...
0
Kotlin
0
0
f58c9377edbe6fc5d777fba55d07873aa7775f9f
1,056
aoc-2022
Apache License 2.0
src/main/kotlin/mirecxp/aoc23/day05/Day05.kt
MirecXP
726,044,224
false
{"Kotlin": 42343}
package mirecxp.aoc23.day05 import mirecxp.aoc23.day04.toNumList import mirecxp.aoc23.readInput import java.util.* //https://adventofcode.com/2023/day/5 class Day05(private val inputPath: String) { private val lines: List<String> = readInput(inputPath) class RangeMap(val target: Long, val source: Long, val ...
0
Kotlin
0
0
6518fad9de6fb07f28375e46b50e971d99fce912
6,056
AoC-2023
MIT License
src/main/kotlin/year2021/day-09.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.Grid2d import lib.Position import lib.TraversalBreadthFirstSearch import lib.aoc.Day import lib.aoc.Part fun main() { Day(9, 2021, PartA9(), PartB9()).run() } open class PartA9 : Part() { protected lateinit var heightmap: Grid2d<Int> override fun parse(text: String) { ...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
1,850
Advent-Of-Code-Kotlin
MIT License
2021/src/day09/day9.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day09 import java.io.File fun main() { val heightMap = parseData(File("src/day09", "day9input.txt").readLines()) println(getRiskFactor(heightMap.findLowPointHeights())) val lowPoints = heightMap.findLowPoints() val largest3 = lowPoints.map { heightMap.findBasinSize(it) }.sortedDescending().ta...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,658
adventofcode
Apache License 2.0
src/y2023/Day14.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Cardinal import util.Pos import util.get import util.readInput import util.set import util.timingStatistics import util.transpose object Day14 { enum class TileType(val c: Char) { ROLLER('O'), FIXED('#'), EMPTY('.') } data class Tile( val type: TileType, ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
4,383
advent-of-code
Apache License 2.0
src/main/kotlin/Day09.kt
alex859
573,174,372
false
{"Kotlin": 80552}
import Movement.* import kotlin.math.absoluteValue fun main() { val testInput = readInput("Day09_test.txt") check(testInput.readMovements().tailPositions().size == 13) // check(testInput.result2() == 24933642) val input = readInput("Day09.txt") println(input.readMovements().tailPositions().size) //...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
2,814
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename val paths = mutableSetOf<String>() fun isValidStep( visited: Array<BooleanArray>, grid: List<String>, row: Int, col: Int, curHeight: Char ): Boolean { val numRows = grid.size val numCols = grid[0].length ...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,260
KotlinAdventOfCode2022
Apache License 2.0
src/main/kotlin/day14/Day14.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day14 import runDay import utils.Point fun main() { fun part1(input: List<String>) = input .map { it.toLine() } .toGrid() .dropSand() .size fun part2(input: List<String>) = input .map { it.toLine() } .toGrid() ...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
2,189
advent-of-code-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day08.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day08.run() object Day08 : Day(2022, 8) { override fun part1(): Any { val map = toMapInt(input) var visible = 0 for (p in map.keys) { if (map.keys.filter { it.y == p.y && it.x < p.x }.any { map[it]!!...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,077
adventofkotlin
MIT License
lib/src/main/kotlin/com/bloidonia/advent/day11/Day11.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day11 import com.bloidonia.advent.readList data class Octopus(val x: Int, val y: Int, var power: Int, var willFlash: Boolean = false) data class OctopusGrid(val width: Int, val octopi: List<Octopus>) { constructor(width: Int, octopi: IntArray) : this( width, octopi.ma...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
2,393
advent-of-kotlin-2021
MIT License
src/main/kotlin/days/day18/Day18.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day18 import days.Day import kotlin.math.abs class Day18 : Day() { override fun partOne(): Any { val digMap = mutableSetOf(Coordinate(0, 0)) readInput().forEach { val direction = it[0] val numberOfSteps = it.split(" ")[1].toInt() val currentCoordina...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
3,755
advent-of-code_2023
The Unlicense
src/twentytwo/Day06.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentytwo fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day06_test") println(part1(testInput)) check(part1(testInput) == 7) println(part2(testInput)) check(part2(testInput) == 19) println("---") val input = readInpu...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
1,900
advent-of-code-solutions
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day10/day10.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day10 import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input10-test1.txt" //const val FILENAME = "input10-test2.txt" const val FILENAME = "input10.txt" fun main() { val lines = readLines(2023, FILENAME) val loop = Loop.creat...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,779
advent-of-code
Apache License 2.0
src/main/kotlin/day10.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.util.* fun day10ProblemReader(string: String): List<Int> { return string .split("\n") .map { line -> line.toInt() } .toList() } // https://adventofcode.com/2020/day/10 class Day10( private val numbers: List<Int> ) { fun solvePart1(): Int { var n1 = 0 v...
0
Kotlin
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
1,958
adventofcode_2020
MIT License
src/Day09.kt
zirman
572,627,598
false
{"Kotlin": 89030}
import kotlin.math.absoluteValue data class Knot(val row: Int, val col: Int) fun main() { fun iterateTailKnot(h: Knot, t: Knot): Knot { val (hr, hc) = h var (tr, tc) = t val dr = hr - tr val dc = hc - tc val m = dr.absoluteValue + dc.absoluteValue if ((m == 1 || (m...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
3,338
aoc2022
Apache License 2.0
src/Day05.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
import java.lang.StringBuilder import java.util.Stack fun main() { fun part1(input: List<String>): String { val stackLines = input.takeWhile { it[1] != '1' }.reversed() val numbersLine = input[stackLines.size] val instructionLines = input.subList(stackLines.size + 2, input.size) va...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
3,231
advent-of-code-2022
Apache License 2.0
src/Day05.kt
kuolemax
573,740,719
false
{"Kotlin": 21104}
import java.util.* import kotlin.collections.ArrayList fun main() { fun part1(input: List<String>): String { val (startRow, stackList) = parseStacks(input) val moveRows = input.subList(startRow, input.size) return moveCargo(moveRows, stackList) } fun part2(input: List<String>): St...
0
Kotlin
0
0
3045f307e24b6ca557b84dac18197334b8a8a9bf
3,370
aoc2022--kotlin
Apache License 2.0
src/main/kotlin/day5.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day5 import aoc.utils.Matrix import aoc.utils.readInput fun part1(): String { return solve(::makeMove) } fun part2(): String { return solve(::makeMove2) } fun solve(mover: (Int, Int, Int, MutableList<MutableList<String>>) -> Unit): String { val crates = createCrates() readInput("day5-inpu...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
1,417
adventOfCode2022
Apache License 2.0
src/Day08.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File fun main() { fun part1(file: File): Int { var visibleTrees = 0 val grid = file.readLines() .map { string -> string.chunked(1) .map { it.toInt() } } //Outer trees visibleTrees += (2 * (grid.size + grid[...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
3,974
AoC2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumProductOfWordLengths.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <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,959
kotlab
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2022/Day07.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import arrow.core.tail import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day07.Node.Directory import ru.timakden.aoc.year2022.Day07.Node.File /** * [Day 7: No Space Left On Device](https://adventofcode.com/2022/day/7). */ objec...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
3,618
advent-of-code
MIT License
src/main/kotlin/dev/patbeagan/days/Day03.kt
patbeagan1
576,401,502
false
{"Kotlin": 57404}
package dev.patbeagan.days /** * [Day 3](https://adventofcode.com/2022/day/3) */ class Day03 : AdventDay<Int> { override fun part1(input: String) = parseInput(input) .sumOf { rucksack -> rucksack.getMatchingItems().sumOf { it.toPriority()!! } } overrid...
0
Kotlin
0
0
4e25b38226bcd0dbd9c2ea18553c876bf2ec1722
1,562
AOC-2022-in-Kotlin
Apache License 2.0
src/aoc22/Day09.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day09 import kotlin.math.abs import kotlin.math.sign import lib.Collections.headTail import lib.Solution data class Point(val x: Int, val y: Int) { val absoluteValue by lazy { Point(abs(x), abs(y)) } val signValue by lazy { Point(sign(x.toDouble()).toInt()...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,332
aoc-kotlin
Apache License 2.0
src/Day04/Day04.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day04 import readInput fun main() { fun part1(input: List<String>): Int { var fullyContainedCount = 0 for (line in input) { val (start1, end1) = line.split(",")[0].split("-").map { it.toInt() } val (start2, end2) = line.split(",")[1].split("-").map { it.toInt() } ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
1,455
aoc-2022
Apache License 2.0
src/main/kotlin/_2022/Day14.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun printMap(map: Map<Pair<Int, Int>, Item>) { val minX = map.keys.minBy { it.first }.first - 1 val maxX = map.keys.maxBy { it.first }.first + 1 val minY = 0 val maxY = map.keys.maxBy { it.second }.second + 1 for (y in minY..max...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,106
advent-of-code
Apache License 2.0
src/Day14.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.max private fun map(): Array<BooleanArray> { var maxY = 0 val rocks: List<List<C>> = readInput("Day14").map { it.split(" -> ") .map { c -> c.split(",").map(String::toInt) } .map { c -> C(c[0], c[1].also { y -> maxY = max(maxY, y) }) } } val w = 1000 ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,821
advent-of-code-2022
Apache License 2.0
kotlin/MaxFlowDinic.kt
dirask
202,550,220
true
{"Java": 491556, "C++": 207948, "Kotlin": 23977, "CMake": 346}
// https://en.wikipedia.org/wiki/Dinic%27s_algorithm in O(V^2 * E) object MaxFlowDinic { data class Edge(val t: Int, val rev: Int, val cap: Int, var f: Int = 0) fun addEdge(graph: Array<ArrayList<Edge>>, s: Int, t: Int, cap: Int) { graph[s].add(Edge(t, graph[t].size, cap)) graph[t].add(Edge(s,...
0
Java
1
2
75f52966780cdc6af582e00f9460f17a4a80d19e
2,285
codelibrary
The Unlicense
kotlin/src/com/s13g/aoc/aoc2020/Day7.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver typealias Baggage = Map<String, Map<String, Int>> /** * --- Day 7: Handy Haversacks --- * https://adventofcode.com/2020/day/7 */ class Day7 : Solver { override fun solve(lines: List<String>): Result { val allBags = parseBags(...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,523
euler
Apache License 2.0
app/src/main/kotlin/day11/Day11.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day11 import common.InputRepo import common.readSessionCookie import common.solve data class Coord(val x: Int, val y: Int) class Octopus(val pos: Coord, var energy: Int) { private val flashedAtTime: MutableSet<Int> = mutableSetOf() fun increase(time: Int): Boolean { energy++ if ((ene...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
4,084
AdventOfCode2021
Apache License 2.0
src/Day13.kt
MerickBao
572,842,983
false
{"Kotlin": 28200}
import java.util.LinkedList fun main() { fun compare(a: String, b: String): Int { val mapA = HashMap<Int, Int>() val mapB = HashMap<Int, Int>() val q = LinkedList<Int>() for (i in a.indices) { if (a[i] == '[') q.offerLast(i) else if (a[i] == ']') mapA[q.pollL...
0
Kotlin
0
0
70a4a52aa5164f541a8dd544c2e3231436410f4b
3,077
aoc-2022-in-kotlin
Apache License 2.0
scripts/Day13.kts
matthewm101
573,325,687
false
{"Kotlin": 63435}
import java.io.File import kotlin.math.max sealed class Data { data class Packet(val data: List<Data>) : Data(), Comparable<Packet> { override fun toString() = data.joinToString(separator = ",", prefix = "[", postfix = "]") { it.toString() } override fun compareTo(other: Packet): Int { ...
0
Kotlin
0
0
bbd3cf6868936a9ee03c6783d8b2d02a08fbce85
3,699
adventofcode2022
MIT License
src/Day22.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import java.awt.geom.Point2D object Day22 { val directions = listOf( 1 to 0, // R 0 to 1, // D -1 to 0, // L 0 to -1, // U ) fun parseBoard(board: String): Map<IntPair, Char> { return board.split("\n").flatMapIndexed { y, row -> row.toCh...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
3,464
advent-of-code-2022
Apache License 2.0
src/test/kotlin/io/noobymatze/aoc/y2022/Day13.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2022 import io.noobymatze.aoc.Aoc import io.noobymatze.aoc.y2022.Day13.Order.* import kotlin.test.Test class Day13 { @Test fun test() { val result = Aoc.getInput(13) .split("\n\n") .asSequence() .map { it.lines().map { parse(tokenize(it))...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
3,137
aoc
MIT License
src/Day04.kt
Inn0
573,532,249
false
{"Kotlin": 16938}
fun main() { fun createList(input: List<String>): MutableList<Int> { val output = mutableListOf<Int>() var counter = input[0].toInt() while(counter <= input[1].toInt()){ output.add(counter) counter++ } return output } fun readPairs(input: List...
0
Kotlin
0
0
f35b9caba5f0c76e6e32bc30196a2b462a70dbbe
2,073
aoc-2022
Apache License 2.0