path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/dev/sirch/aoc/y2022/days/Day05.kt
kristofferchr
573,549,785
false
{"Kotlin": 28399, "Mustache": 1231}
package dev.sirch.aoc.y2022.days import dev.sirch.aoc.Day class Stack { private val stack = mutableListOf<Char>() fun peek(): Char { return stack.last() } fun pop(amount: Int = 1): List<Char> { return (0 until amount).map { stack.removeLast() } } fun pus...
0
Kotlin
0
0
867e19b0876a901228803215bed8e146d67dba3f
3,176
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2022/d14/Day14.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d14 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines data class Point(val x: Int, val y: Int) fun String.toPoint(): Point = split(",").let { (a, b) -> Point(a.toInt(), b.toInt()) } class Solver(in...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,009
advent-of-code
MIT License
src/Day09.kt
MartinsCode
572,817,581
false
{"Kotlin": 77324}
import kotlin.math.abs fun main() { /** * Calculate new position of tails after movement of head. */ fun newPosOfTail(head: Pair<Int, Int>, tail: Pair<Int, Int>): Pair<Int, Int> { val newtail: Pair<Int, Int> // no tail movement, if there is no "big" difference in positions if ...
0
Kotlin
0
0
1aedb69d80ae13553b913635fbf1df49c5ad58bd
4,636
AoC-2022-12-01
Apache License 2.0
src/Day07.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
import kotlin.math.abs import kotlin.math.roundToInt fun firstPart07(list : List<Int>) { getFuelConsumptionDescGrad(list) { average: Int -> sumOf { abs(it - average) } } } fun secondPart07(list : List<Int>) { getFuelConsumptionDescGrad(list) { average -> sumOf { val steps = abs...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
2,122
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/main/kotlin/ALU_24.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
val instructions: List<Instruction> by lazy { readFile("ALU").split("\n").map { l -> l.split(" ").let { if (it.size == 2) Instruction(it[0], it[1], "") else Instruction(it[0], it[1], it[2]) } } } val mapVarToInd = mapOf( "w" to 0, "x" to 1, "y" to 2, "z" to 3 ) val variables = IntArray...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
1,778
advent-of-code-2021
Apache License 2.0
src/day14/Day14.kt
felldo
572,762,654
false
{"Kotlin": 104604}
package day14 import readInputString import java.lang.Integer.max fun main() { fun buildCave(input: List<String>, addFloor: Boolean): Array<Array<Int>> { val cave = Array(1_000) { Array(1_000) { 0 } } var lowest = 0 for (line in input) { val pts = line.split(" -> ").toMutableL...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
2,534
advent-of-code-kotlin-2022
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day06.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun main() { Day06.solve() } object Day06 : AdventSolution(2023, 6, "Wait For It") { override fun solvePartOne(input: String): Long { val (times, distances) = inp...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,474
advent-of-code
MIT License
src/main/kotlin/com/github/michaelbull/advent2023/day13/MirrorMap.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day13 import com.github.michaelbull.advent2023.math.Vector2CharMap import com.github.michaelbull.advent2023.math.toVector2CharMap fun Sequence<String>.toMirrorMap(): MirrorMap { val patterns = mutableListOf<Vector2CharMap>() val pattern = mutableListOf<String>() ...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
2,373
advent-2023
ISC License
src/Day09.kt
bjornchaudron
574,072,387
false
{"Kotlin": 18699}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val sim = Simulation(2) input.forEach { sim.move(it) } return sim.tailHistory.size } fun part2(input: List<String>): Int { val sim = Simulation(10) input.forEach { sim.move(it) } retur...
0
Kotlin
0
0
f714364698966450eff7983fb3fda3a300cfdef8
2,170
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch5/Problem51.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.combinatorics.combinations import dev.bogwalk.util.maths.isPrime import dev.bogwalk.util.maths.primeNumbers import dev.bogwalk.util.search.binarySearch import kotlin.math.pow /** * Problem 51: Prime Digit Replacements * * https://projecteuler.net/problem=51 * * ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
5,900
project-euler-kotlin
MIT License
src/2022/Day14.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { val startY = 0 val startX = 500 fun simulateSandFall(filledPoints: Set<Point>, maxY: Int): Point? { var x = startX var lastSandPoint = Point(0, 500) (startY..maxY).forEach { y -> listOf(x, x - 1, x + 1).find { ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,701
aoc-2022-in-kotlin
Apache License 2.0
src/Day11.kt
robinpokorny
572,434,148
false
{"Kotlin": 38009}
data class Monkey( val items: ArrayDeque<Int>, val operation: (Int, Int?) -> Int, val test: Int, val onPass: Int, val onFail: Int, var inspected: Long = 0 ) private fun parse(input: List<String>) = input .joinToString("\n") .split("\n\n") .map { it.lines() } .map { Monke...
0
Kotlin
0
2
56a108aaf90b98030a7d7165d55d74d2aff22ecc
3,563
advent-of-code-2022
MIT License
src/Day14.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day14.run { solve1(24) // 674 solve2(93) // 24958 } }.let { println("Total: $it ms") } } object Day14 : Day.LineInput<Day14.Data, Int>("14") { class Data(val map: Array<BooleanArray>, val start...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
3,194
AdventOfCode2022
Apache License 2.0
src/Day10.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
import kotlin.math.absoluteValue class CPU(instructions: Sequence<Instruction>) { private val instructionsIterator = instructions.iterator() private var runningInstruction: Instruction? = null private var instructionCyclesLeft = 0 var regX = 1 private set var cycles = 0 private set ...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
3,191
aoc-2022
Apache License 2.0
src/Day13.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
fun main() { fun parseString(input: String): List<*> { val mutableList = mutableListOf<Any>() fun listAtDepth(depth: Int): MutableList<Any> { var list = mutableList repeat((0 until depth).count()) { list = list.last() as MutableList<Any> } ...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
4,061
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day04.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 class Day04(private val input: String) { fun solvePart1(): Int = solve(true) fun solvePart2(): Int = solve(false) private fun solve(firstMatch: Boolean): Int { val parts = input.split("\n\n") val numbers = parts.first().split(",").map(String::toInt) ...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,923
advent-of-code
Apache License 2.0
src/Day19.kt
inssein
573,116,957
false
{"Kotlin": 47333}
import java.util.PriorityQueue import kotlin.math.ceil fun main() { data class Cost(val ore: Int, val clay: Int, val obsidian: Int) data class Blueprint( val id: Int, val oreRobotCost: Cost, val clayRobotCost: Cost, val obsidianRobotCost: Cost, val geodeRobotCost: Cost ...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
4,270
advent-of-code-2022
Apache License 2.0
day20/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File import java.lang.IllegalStateException import java.util.* fun main() { val regex = readInputFile()[0] val result = solveProblem(regex) println("Part I: the solution is ${result.largestNumberOfDoors}.") println("Part II: the solution is ${result.numberOfRoomsRequiring1000Doors}.") ...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
2,057
AdventOfCode2018
MIT License
2023/src/main/kotlin/day12.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Memo import utils.Parse import utils.Parser import utils.Solution import utils.mapItems fun main() { Day12.run() } object Day12 : Solution<List<Day12.Input>>() { override val name = "day12" override val parser = Parser.lines.mapItems { parseInput(it) } @Parse("{map} {r ',' dmgGroups}") data cl...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,838
aoc_kotlin
MIT License
advent-of-code-2021/src/main/kotlin/Day15.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 15: Chiton //https://adventofcode.com/2021/day/15 import java.io.File import java.util.PriorityQueue data class Position(val xy: Pair<Int, Int>, val risk: Int) val queue = PriorityQueue(compareBy(Position::risk)) fun main() { val risks = File("src/main/resources/Day15.txt").readLines().map { positions -> ...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,030
advent-of-code
Apache License 2.0
src/main/kotlin/aoc23/Day04.kt
tahlers
725,424,936
false
{"Kotlin": 65626}
package aoc23 import java.math.BigInteger object Day04 { data class Card(val id: Int, val winningNumbers: Set<Int>, val numbers: Set<Int>) { val hits = numbers.filter { it in winningNumbers }.size fun calculateScore(): BigInteger = if (hits == 0) BigInteger.ZERO else BigInteger.valueO...
0
Kotlin
0
0
0cd9676a7d1fec01858ede1ab0adf254d17380b0
2,041
advent-of-code-23
Apache License 2.0
src/Day01.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
fun main() { fun part1(input: List<String>): Int { return getCalorieSumsPerElf(input).maxOrNull() ?: -1 } fun part2(input: List<String>): Int { val mutableCalorieSumsPerElf = getCalorieSumsPerElf(input).toMutableList() var sumOfTop3Sums = 0 for (i in 1..3) { va...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
1,357
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day06.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt // https://adventofcode.com/2023/day/6 object Day06 : AoCDay<Long>( title = "Wait For It", part1ExampleAnswer = 288, part1Answer = 1660968, part2ExampleAnswer = 71503, part2Answer = 26499773, ) {...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
1,726
advent-of-code-kotlin
MIT License
src/day14/day14.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day14 import readInput private fun parse(input: List<String>): Pair<Array<CharArray>, IntRange> { var left = Int.MAX_VALUE var right = Int.MIN_VALUE var top = Int.MIN_VALUE for (line in input) { val parts = line.split(" -> ") for (item in parts) { val coordinates =...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
3,592
aoc-2022
Apache License 2.0
src/main/kotlin/icfp2019/app.kt
jzogg
193,197,477
true
{"JavaScript": 797354, "Kotlin": 19302, "HTML": 9922, "CSS": 9434}
package icfp2019 import java.io.File import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths fun main() { val workingDir: Path = Paths.get("") val solutions = mutableListOf<Solution>() readZipFile(File("problems.zip")) .filter { it.line.isNotEmpty() } .forEach { ...
0
JavaScript
0
0
8d637f7feee33d2c7a030f94732bb16c850e047c
3,069
icfp-2019
The Unlicense
src/main/kotlin/adventofcode/day11.kt
Kvest
163,103,813
false
null
package adventofcode fun main(args: Array<String>) { first11(7803) second11(7803) } private const val SIZE = 300 fun first11(gsn: Int) { val f = calcField(gsn) maxSqr(f, 3).printXYK() } fun second11(gsn: Int) { val f = calcField(gsn) val max = (1..SIZE).map { maxSqr(f, it) }.maxBy { it.max ...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
1,576
aoc2018
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/LengthOfLongestSubstring.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import java.util.* /** * 3. 无重复字符的最长子串 * 给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。 * * 示例1: * * 输入: "abcabcbb" * 输出: 3 * 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 * 示例 2: * * 输入: "bbbbb" * 输出: 1 * 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 * 示例 3: * * 输入: "pwwkew" * 输出: 3 * 解释: 因为无重复字符的最长子串是"...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,053
daily_algorithm
Apache License 2.0
src/Day02.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
fun main() { fun calculateRound(round: RoundPart1): Int = when (round.opponentsTurn) { "A" -> if (round.myTurn == "Y") 6 else if (round.myTurn == "X") 3 else 0 "B" -> if (round.myTurn == "Z") 6 else if (round.myTurn == "Y") 3 else 0 "C" -> if (round.myTurn == "X") 6 else ...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
3,351
advent-of-code-2022
Apache License 2.0
src/day03/Day03.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day03 import readInput fun main() { fun priorityOf(itemType: Char): Int { return when (itemType) { in 'a'..'z' -> itemType - 'a' + 1 in 'A'..'Z' -> itemType - 'A' + 27 else -> throw IllegalArgumentException("Invalid item type: $itemType") } } fu...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
1,667
advent-of-code-2022
Apache License 2.0
src/Day02.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { return input .map { it.split(" ")[0] to it.split(" ")[1] } .map { val opponentShape = when (it.first) { "A" -> 0 "B" -> 1 "C" -> 2 ...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
2,152
aoc2022
Apache License 2.0
src/year2023/day16/Day16.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day16 import check import parallelMap import readInput fun main() { val testInput = readInput("2023", "Day16_test") check(part1(testInput), 46) check(part2(testInput), 51) val input = readInput("2023", "Day16") println(part1(input)) println(part2(input)) } private fun part1(...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
4,486
AdventOfCode
Apache License 2.0
src/Day05.kt
ranveeraggarwal
573,754,764
false
{"Kotlin": 12574}
fun main() { fun part1(input: List<String>): String { val numStacks = input[0].length / 4 + 1 val stacks = Array<ArrayDeque<Char>>(numStacks) { ArrayDeque() } var cursor = 0 // process initial state while (true) { if (input[cursor][1] == '1') break (i...
0
Kotlin
0
0
c8df23daf979404f3891cdc44f7899725b041863
2,770
advent-of-code-2022-kotlin
Apache License 2.0
day16/src/main/kotlin/aoc2015/day16/Day16.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day16 object Day16 { private val targetSueProperties = listOf( "children" to 3, "cats" to 7, "samoyeds" to 2, "pomeranians" to 3, "akitas" to 0, "vizslas" to 0, "goldfish" to 5, "trees" to 3, ...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
2,499
aoc2015
Apache License 2.0
AOC2022/src/main/kotlin/AOC9.kt
bsautner
575,496,785
false
{"Kotlin": 16189, "Assembly": 496}
package com.yp.day9 import java.io.File import kotlin.math.abs class AOC9 { fun process() { val input = File("/home/ben/aoc/input-9.txt") val instructions = input.useLines { it.toList() } val p1 = (0..1).map { Pair(0, 0) }.toMutableList() val p2 = (0..9).map { Pair(0, 0) }.to...
0
Kotlin
0
0
5f53cb1c4214c960f693c4f6a2b432b983b9cb53
3,302
Advent-of-Code-2022
The Unlicense
src/aoc22/day15.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day15 import kotlin.math.abs import lib.Point import lib.Ranges.size import lib.Ranges.overlaps import lib.Ranges.intersect import lib.Ranges.union import lib.Solution import lib.Strings.extractInts data class Sensor( val position: Point, val closestBeacon...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,778
aoc-kotlin
Apache License 2.0
kotlin/2022/round-1a/equal-sum/src/main/kotlin/oldsolutionnottakingintoaccountnneq100/Solution.kt
ShreckYe
345,946,821
false
null
package oldsolutionnottakingintoaccountnneq100 import kotlin.system.exitProcess fun main() { val t = readLineOrExit()!!.toInt() repeat(t) { testCase() } } fun readLineOrExit() = readLine().also { if (it == "-1") exitProcess(0) } fun testCase() { val nn = readLineOrExit()!!.to...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,714
google-code-jam
MIT License
code-sample-kotlin/algorithms/src/main/kotlin/com/codesample/leetcode/easy/1752_CheckIfArrayIsSorderAndRotated.kt
aquatir
76,377,920
false
{"Java": 674809, "Python": 143889, "Kotlin": 112192, "Haskell": 57852, "Elixir": 33284, "TeX": 20611, "Scala": 17065, "Dockerfile": 6314, "HTML": 4714, "Shell": 387, "Batchfile": 316, "Erlang": 269, "CSS": 97}
package com.codesample.leetcode.easy /** 1752. Check if Array Is Sorted and Rotated https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/ * Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number * of positions (including zero). Otherwise, r...
1
Java
3
6
eac3328ecd1c434b1e9aae2cdbec05a44fad4430
1,679
code-samples
MIT License
src/Day04.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
fun main() { fun Pair<Int,Int>.fullyOverlaps(with: Pair<Int, Int>) = this.first >= with.first && this.second <= with.second fun Pair<Int,Int>.partiallyOverlaps(with: Pair<Int, Int>) = this.first <= with.second && with.first <= this.second fun part1(input: List<String>): Int = input .map { it.split(...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
854
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxIceCream.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,125
kotlab
Apache License 2.0
journey-to-the-moon/src/main/kotlin/com/felipecsl/Main.kt
felipecsl
94,643,403
false
null
package com.felipecsl import java.util.* // https://www.hackerrank.com/challenges/journey-to-the-moon // the entire graph val NODES: MutableMap<Astronaut, MutableList<Edge>> = mutableMapOf() // list of every disjoint graph (with astronauts grouped by nation) val countries: MutableList<Country> = mutableListOf() val...
0
Kotlin
0
3
a4c07dd1531aae23d67ff52284b6fcca17b6c37c
3,135
hackerrank
MIT License
src/main/kotlin/aoc2022/Day23.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import aoc2022.Day23.Direction.* import util.illegalInput // https://adventofcode.com/2022/day/23 object Day23 : AoCDay<Int>( title = "Unstable Diffusion", part1ExampleAnswer = 110, part1Answer = 4146, part2ExampleAnswer = 20, part2Answer = 957, ) { private data c...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
3,495
advent-of-code-kotlin
MIT License
src/main/aoc2022/Day14.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import AMap import Direction import Pos import kotlin.math.max import kotlin.math.min class Day14(input: List<String>) { val map = AMap().apply { input.forEach { line -> line.split(" -> ").windowed(2).forEach { (a, b) -> val (x1, y1) = a.split(",").map { it.toI...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,944
aoc
MIT License
src/main/kotlin/dk/lessor/Day9.kt
aoc-team-1
317,571,356
false
{"Java": 70687, "Kotlin": 34171}
package dk.lessor fun main() { val xmas = readFile("day_9.txt").map { it.toLong() } val invalid = analyzeXmas(xmas) println(invalid) println(findEncryptionWeakness(xmas, invalid)) } fun analyzeXmas(xmas: List<Long>, preambleSize: Int = 25): Long { for (i in preambleSize..xmas.lastIndex) { ...
0
Java
0
0
48ea750b60a6a2a92f9048c04971b1dc340780d5
1,442
lessor-aoc-comp-2020
MIT License
src/main/kotlin/com/github/brpeterman/advent2022/DirTree.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 class DirTree(input: String, val root: Folder = Folder("")) { init { constructTree(parseInput(input)) } data class Folder(val name: String, val parent: Folder? = null, val children: MutableMap<String, Folder> = mutableMapOf(), val files: MutableMap<String, ...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
2,636
advent2022
MIT License
src/Day05.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import java.io.File import java.util.Deque fun main() { fun parseBox(index: Int, box: String, boxes: List<ArrayDeque<Char>>) { if (box.isNotBlank()) { boxes[index].add(box[1]) } } // [T] [R] [Z] [H] [H] [G] [C] fun parseLine(line: String, boxes: List<ArrayDeque<Char>...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
2,643
advent-of-code-2022
Apache License 2.0
src/Day17.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import java.util.BitSet private enum class WindDirection { LEFT, RIGHT } private enum class TetrisBlock { ROW, PLUS, REVERSE_L, COLUMN, SQUARE; fun toPointCloud(x: Int, y: Long): List<Pair<Int, Long>> { return when (this) { ROW -> listOf( x to y, x + 1 ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
5,141
aoc-2022
Apache License 2.0
src/main/kotlin/days/Solution05.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.TripleOf import adventOfCode.util.longs import kotlin.math.max import kotlin.math.min typealias PlantNumber = Long typealias Almanac = List<List<TripleOf<PlantNumber>>> object Solution0...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
2,644
Advent-of-Code-2023
MIT License
src/main/kotlin/y2016/day03/Day03.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2016.day03 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } typealias Triangle = List<Int> fun input(): List<Triangle> = AoCGenerics.getInputLines("/y2016/day03/input.txt") .map { val parts = it.trim().split(" ").f...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,459
AdventOfCode
MIT License
year2018/src/main/kotlin/net/olegg/aoc/year2018/day3/Day3.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day3 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2018.DayOf2018 /** * See [Year 2018, Day 3](https://adventofcode.com/2018/day/3) */ object Day3 : DayOf2018(3) { override fun first(): Any? { val requests = lines.mapNotNull { Request.fromString(it) } val wid...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,858
adventofcode
MIT License
src/Day02.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
import utils.readInputAsLines val possibleHands = mapOf( "A X" to 4, "B X" to 1, "C X" to 7, "A Y" to 8, "B Y" to 5, "C Y" to 2, "A Z" to 3, "B Z" to 9, "C Z" to 6 ) val possibleHandsStrat2 = mapOf( "A X" to 3, "B X" to 1, "C X" to 2, "A Y" to 4, "B Y" to 5, ...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
971
2022-AOC-Kotlin
Apache License 2.0
advent-of-code-2022/src/Day21.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { val testInput = readInput("Day21_test") val input = readInput("Day21") "Part 1" { part1(testInput) shouldBe 152 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 301 measureAnswer { part2(input) } } } private fun part1(input: Ma...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
3,481
advent-of-code
Apache License 2.0
src/Day04.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
typealias SectionRange = Pair<Int, Int> fun main() { infix fun SectionRange.contains(range: SectionRange): Boolean { return first <= range.first && this.second >= range.second } infix fun SectionRange.overlap(range: SectionRange): Boolean { return first <= range.second && range.first <= se...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
1,268
advent-of-code
Apache License 2.0
src/Day03.kt
TheOnlyTails
573,028,916
false
{"Kotlin": 9156}
fun Char.toPriority() = code - if (this > 'Z') { 96 } else { 38 } fun main() { fun part1(input: List<String>): Int { return input .map { // split into each rucksack compartment it.substring(0 until (it.length / 2)) to it.substring(it.length / 2) ...
0
Kotlin
0
0
685ce47586b6d5cea30dc92f4a8e55e688005d7c
1,029
advent-of-code-2022
Apache License 2.0
src/Day05.kt
Daan-Gunnink
572,614,830
false
{"Kotlin": 8595}
class Day05 : AdventOfCode("CMZ", "MCD") { internal data class Move( val amount: Int, val fromColumn: Int, val toColumn: Int ) private fun parseBoxes(input: List<String>): MutableList<MutableList<String>> { return input.map { it.withIndex().filter { it.value.isL...
0
Kotlin
0
0
15a89224f332faaed34fc2d000c00fbefe1a3c08
2,055
advent-of-code-2022
Apache License 2.0
2020/03.kt
Albert221
318,762,813
false
null
import java.io.File fun main() { val map = File("2020/input/03.txt").run { Map.parse(readText()) } val partOne = treesEncountered(map, Coords(3, 1)) var partTwo = 1L for (step in listOf( Coords(1, 1), Coords(3, 1), Coords(5, 1), Coords(7, 1), ...
0
Kotlin
0
0
8de13af4c68a46d2e509284af36130b214e22e4c
1,756
advent-of-code
Apache License 2.0
year2015/src/main/kotlin/net/olegg/aoc/year2015/day24/Day24.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day24 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseLongs import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 24](https://adventofcode.com/2015/day/24) */ object Day24 : DayOf2015(24) { private val WEIGHTS = data.parseLongs("\n") override fun ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,077
adventofcode
MIT License
src/Day22.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { val d = Day22(readInput("inputs/Day22")) println(d.part1()) println(d.part2()) } class Day22(input: List<String>) { private val blockedPlaces: Set<Point> = parseBlockedPlaces(input) private val instructions: List<Instruction> = Instruction.ofList(input) fun part1(): Int = ...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
12,574
aoc-2022
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/10.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d10 import input.read import java.util.* fun main() { println("Part 1: ${part1(read("10.txt"))}") println("Part 2: ~${part2(read("10.txt"))}, you need to debug a bit by yourself ¯\\_(ツ)_/¯") } fun part1(input: List<String>): Int { val maze = Maze(input) val start = maze.getStart()!! maze...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
5,479
aoc
The Unlicense
src/day2/main.kt
DonaldLika
434,183,449
false
{"Kotlin": 11805}
package day2 import assert import readLines fun main() { fun readCommands(fileName: String): List<Pair<String, Int>> { return readLines(fileName).map { it.split(" ").zipWithNext().first() }.map { Pair(it.first, it.second.toInt()) } } fun part1(input: List<...
0
Kotlin
0
0
b288f16ee862c0a685a3f9e4db34d71b16c3e457
1,573
advent-of-code-2021
MIT License
src/day03/Day03.kt
veronicamengyan
573,063,888
false
{"Kotlin": 14976}
package day03 import readInput import splitToListOfList /** * Potential improvement: * * use chunked instead of splitToListOfList * * use extension class */ fun main() { fun findItemsScore(input: String): Int { val firstBag = input.substring(0, input.length/2).toSet() val secondBag = input.subs...
0
Kotlin
0
0
d443cfa49e9d8c9f76fdb6303ecf104498effb88
1,686
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/io/matrix/SortMatrixDiagonally.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.matrix import io.utils.runTests import java.util.* // https://leetcode.com/problems/sort-the-matrix-diagonally/ class SortMatrixDiagonally { fun execute(input: Array<IntArray>?): Array<IntArray>? { val queue = PriorityQueue<Int>() if (input?.isEmpty() != false) return input (input.size - 2 ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,787
coding
MIT License
src/main/kotlin/Excercise05.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
import kotlin.math.abs private fun part1() { getInputAsTest("05") { split("\n") } .map { preProcess(it) } .let { input -> buildMap<EntryPoint, Int> { for ((start, end) in input) { val (x0, y0) = start val (x1, y1) = end when { x0 == x1 -> ...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
2,038
advent-of-code-2021
MIT License
src/Day07.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
class TreeNode { var size: Int = 0; var idDir: Boolean = false; var parent = -1; var children = mutableMapOf<String, Int>(); } var tree = mutableListOf<TreeNode>(); fun newNode(): Int { tree.add(TreeNode()); return tree.size-1; } fun dfs(v: Int) { if (tree[v].idDir) { for (child i...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
3,344
advent-of-code-2022-kotlin
Apache License 2.0
src/aoc2021/Day03.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput fun main() { val (year, day) = "2021" to "Day03" fun List<String>.countBits(index: Int): Pair<Int, Int> { var zeros = 0 var ones = 0 this.forEach { when (it[index]) { '0' -> zeros++ '1' -> ones++ ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,693
aoc-kotlin
Apache License 2.0
src/Day09.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
import kotlin.math.abs enum class Direction(val value: String) { Up("U"), Down("D"), Left("L"), Right("R") } data class Movement( val direction: Direction, val step: Int ) data class Coordinates( val x: Int, val y: Int, ) fun main() { fun List<String>.toMovements(): List<Movemen...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
3,599
AdventOfCode2022
Apache License 2.0
src/Day13.kt
hufman
573,586,479
false
{"Kotlin": 29792}
import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.* fun main() { fun parse(input: List<String>): List<JsonArray> { return input .filter { it.isNotEmpty() } .map { Json.decodeFromString(it) } } fun comparePacket(left: JsonArray, right: JsonArray): Int { // println(" - Compar...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
2,211
aoc2022-kt
Apache License 2.0
2020/src/year2021/day12/code.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2021.day12 import util.readAllLines enum class Size { SMALL, LARGE; } data class Node(val name: String) { val size = if (name[0].isUpperCase()) Size.LARGE else Size.SMALL val paths = mutableMapOf<Node, MutableSet<MutableList<Node>>>() val isVisitable: Boolean get() = (size == Size...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
3,412
adventofcode
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day20/Day20.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day20 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputSplitOnBlank object Day20 : Day { override val input = ScannerImage.from(readInputSplitOnBlank(20)) override fun part1() = enhance(2).image.filterValues { it == 1 }.si...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,013
aoc2021
MIT License
src/aoc2016/kot/Day22.kt
Tandrial
47,354,790
false
null
package aoc2016.kot import java.nio.file.Files import java.nio.file.Paths import java.util.regex.Pattern object Day22 { data class Node(val x: Int, val y: Int, val size: Int, val used: Int, val avail: Int) fun parse(input: List<String>): List<Node> = input.mapNotNull { val m = Pattern.compile("(\\d+)-y(\\d+)...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,559
Advent_of_Code
MIT License
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p00/Leet4.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p00 import com.artemkaxboy.leetcode.LeetUtils.stringToIntArray private class Leet4 { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val size1 = nums1.size val size2 = nums2.size val size = size1 + size2 val mergedList = Array...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
1,469
playground
MIT License
src/main/kotlin/day05/Day05.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day05 import java.io.File import kotlin.math.min import kotlin.math.max fun main() { val data = parse("src/main/kotlin/day05/Day05.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 05 🎄") println() println("[Part 1]") println("Answer: $answer1") pr...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
2,118
advent-of-code-2021
MIT License
src/Day04.kt
leeturner
572,659,397
false
{"Kotlin": 13839}
fun List<String>.parse(): List<List<Set<Int>>> { return this.map { it.split(',') .map { pair -> pair.split('-').map { assignment -> assignment.toInt() } } .map { (start, end) -> (start..end).toSet() } } } fun main() { fun part1(input: List<String>): Int { return input.parse().count { (fi...
0
Kotlin
0
0
8da94b6a0de98c984b2302b2565e696257fbb464
914
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g0901_1000/s0934_shortest_bridge/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0934_shortest_bridge // #Medium #Array #Depth_First_Search #Breadth_First_Search #Matrix // #Graph_Theory_I_Day_6_Matrix_Related_Problems // #2023_04_27_Time_301_ms_(80.95%)_Space_77.9_MB_(9.52%) class Solution { private class Pair(var x: Int, var y: Int) private val dirs = arrayOf(intArr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,320
LeetCode-in-Kotlin
MIT License
src/Day04.kt
burtz
573,411,717
false
{"Kotlin": 10999}
fun main() { fun returnSet(low : Int,high : Int) : Set<Int> { val set = mutableSetOf<Int>() for (i in low..high) set += i return set } fun part1(input: List<String>): Int { var counter = 0 input.forEach { var elfs = it.split(',') var shif...
0
Kotlin
0
0
daac7f91e1069d1490e905ffe7b7f11b5935af06
1,402
adventOfCode2022
Apache License 2.0
src/Day10.kt
treegem
572,875,670
false
{"Kotlin": 38876}
import common.readInput fun main() { fun part1(input: List<String>): Int { val registerHistory = input.toRegisterHistory() return (20..220 step 40).sumOf { registerHistory[it]!! * it } } fun part2(input: List<String>) = input.toRegisterHistory() .toSortedMap() ...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
1,243
advent_of_code_2022
Apache License 2.0
src/main/kotlin/aoc2023/Day02.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay import kotlin.math.max // https://adventofcode.com/2023/day/2 object Day02 : AoCDay<Int>( title = "Cube Conundrum", part1ExampleAnswer = 8, part1Answer = 2256, part2ExampleAnswer = 2286, part2Answer = 74229, ) { private class CubeSet(val red: Int, val green: Int, ...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
1,717
advent-of-code-kotlin
MIT License
src/main/kotlin/com/jacobhyphenated/advent2023/day17/Day17.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day17 import com.jacobhyphenated.advent2023.Day import java.util.* /** * Day 17: Clumsy Crucible * * The cart that carries the lava needs to travel from the top left corner * to the bottom right of the puzzle input. Each space has a cost. * Need to find path with the lowest...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
6,746
advent2023
The Unlicense
src/Day02.kt
Jaavv
571,865,629
false
{"Kotlin": 14896}
// https://adventofcode.com/2022/day/2 fun main() { val input = readInput("Day02") val testinput = readInput("Day02_test") println(Day02Part1(input)) // 12276 println(Day02Part2(input)) // 9975 println(day02part1op(input)) println(day02part2op(input)) } fun rock(vs: String): Int { val resul...
0
Kotlin
0
0
5ef23a16d13218cb1169e969f1633f548fdf5b3b
3,416
advent-of-code-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day25.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val connections = readInput(2023, 25, false).useLines { lines -> buildMap<String, MutableSet<String>> { for (line in lines) { val (key, other) = line.split(": ") ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,746
adventofcode
Apache License 2.0
src/Day03.kt
flexable777
571,712,576
false
{"Kotlin": 38005}
fun main() { fun Char.getPriority(): Int = if (this.isLowerCase()) { this - 'a' + 1 } else { this - 'A' + 27 } fun part1(input: List<String>): Int = input.sumOf { line -> //Better way to split these? val middleIndex = line.length ...
0
Kotlin
0
0
d9a739eb203c535a3d83bc5da1b6a6a90a0c7bd6
1,377
advent-of-code-2022
Apache License 2.0
src/Day09.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val steps = input.toSteps() val visitedPlaces = mutableSetOf<Position>() val head = Position(0, 0) val tail = Position(0, 0) steps.forEach { step -> when (step) { Step.UP ->...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
2,957
aoc-2022
Apache License 2.0
src/main/kotlin/lesson1/BinaryGap.kt
iafsilva
633,017,063
false
null
package lesson1 /** * A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. * * For example: * - The number 9 has binary representation 1001 and contains a binary gap of length 2. * - The number 529 has bina...
0
Kotlin
0
0
5d86aefe70e9401d160c3d87c09a9bf98f6d7ab9
2,206
codility-lessons
Apache License 2.0
src/problems/day5/part2/part2.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day5.part2 import java.io.File import java.util.* //const val testFile = "input/day5/test.txt" const val inputFile = "input/day5/input.txt" fun main() { val lowestLocationNum = File(inputFile).bufferedReader().useLines { lowestLocationNumber(it) } println("Lowest Location Num: $lowestLocatio...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
3,925
aoc2023
MIT License
src/day01/Day01.kt
benjaminknauer
574,102,077
false
{"Kotlin": 6414}
package day01 import java.io.File data class Sweet(val calories: Int) data class Elf(val sweets: List<Sweet>) { fun getCaloriesSum(): Int { return sweets.sumOf { it.calories } } } fun parseInput(input: String): List<Elf> { return input.split("\n\n") .map { elf -> val sweets = ...
0
Kotlin
0
0
fcf41bed56884d777ff1f95eddbecc5d8ef731d1
1,295
advent-of-code-22-kotlin
Apache License 2.0
src/Day09.kt
kipwoker
572,884,607
false
null
import kotlin.math.abs class Command(val direction: Direction, val count: Int) fun main() { fun parse(input: List<String>): List<Command> { return input.map { line -> val parts = line.split(' ') val direction = when (parts[0]) { "U" -> Direction.Up "...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
2,696
aoc2022
Apache License 2.0
src/day12/Day12.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day12 import readInput import utils.withStopwatch import java.util.LinkedList fun main() { val testInput = readInput("input12_test") withStopwatch { println(part1(testInput)) } withStopwatch { println(part2(testInput)) } val input = readInput("input12") withStopwatch { println(part1(input...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
1,806
advent-of-code-kotlin-2022
Apache License 2.0
src/day9/day9.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day9 import lib.Point2D import readInput import kotlin.math.abs import kotlin.math.min import kotlin.math.sign fun main() { val day = 9 val testInput = readInput("day$day/testInput") check(part1(testInput) == 13) val input = readInput("day$day/input") println(part1(input)) println(par...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
1,904
advent-of-code-2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day19/day19.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day19 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val xmasSystem = parseXmasSystem(inputFile.bufferedReader().readLines()) val acceptedParts = xmasSystem.runWorkflows() println("Sum of accepted parts: ${accepte...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
9,195
advent-of-code
MIT License
src/Day13.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { data class Node( var single: Int? = null, var list: List<Node>? = null, ) : Comparable<Node> { fun compare(a: List<Node>, b: List<Node>): Int { for (i in 0 until minOf(a.size, b.size)) { val c = a[i].compareTo(b[i]) if (c != 0) ret...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
2,729
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/leetcode/P980.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://github.com/antop-dev/algorithm/issues/467 class P980 { fun uniquePathsIII(grid: Array<IntArray>): Int { var y = 0 var x = 0 var total = 0 // 갈 수 있는 남은 칸 수 for (i in grid.indices) { for (j in grid[i].indices) { val v = grid[...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,462
algorithm
MIT License
src/Day05.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
import java.util.Stack fun main() { fun parseCrates(input: List<String>): List<MutableList<String>> { val stacks = mutableListOf<MutableList<String>>() for (line in input) { if (line.isEmpty()) { break; } else { line.chunked(4).forEachIndexed ...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
3,038
advent-of-code-2022
Apache License 2.0
src/day02/Day02.kt
TheRishka
573,352,778
false
{"Kotlin": 29720}
package day02 import readInput fun main() { val shapeScore = mapOf( 'X' to 1, // Rock 'Y' to 2, // Paper 'Z' to 3 // Scissors ) val winMap = mapOf( 'A' to 'Y', // Rock <-- Paper WIN 'B' to 'Z', // Paper <-- Scissors WIN 'C' to 'X' // Scissors <-- Rock WIN ...
0
Kotlin
0
1
54c6abe68c4867207b37e9798e1fdcf264e38658
2,533
AOC2022-Kotlin
Apache License 2.0
src/Day05.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
private data class Move(val howMany: Int, val fromStack: Int, val toStack: Int) class Day05(input: List<List<String>>) { private val stacks = getStacks(input.first().dropLast(1).reversed()) private val moves = input.last().mapNotNull(::extractMove) private fun getStacks(stacksText: List<String>): Muta...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
2,524
advent-of-code-2022-kotlin
Apache License 2.0
src/Day10.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.streams.toList fun main() { fun part1(input: List<List<Char>>): Int { val stk = ArrayDeque<Char>() val open = listOf('(', '[', '{', '<') val close = listOf(')', ']', '}', '>') val scores = mapOf( Pair(')', 3), Pair(']', 57), Pair('}...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
2,391
advent_of_code21_kotlin
Apache License 2.0
Bootcamp_00/src/exercise5/src/main/kotlin/Main.kt
Hasuk1
740,111,124
false
{"Kotlin": 120039}
import kotlin.math.* fun main() { val x1 = readCoordinate("Input x1:") val y1 = readCoordinate("Input y1:") val r1 = readRadius("Input r1:") val x2 = readCoordinate("Input x2:") val y2 = readCoordinate("Input y2:") val r2 = readRadius("Input r2:") val distance = sqrt((x2 - x1).pow(2) + (y2 - y1).pow(2)) ...
0
Kotlin
0
1
1dc4de50dd3cd875e3fe76e3da4a58aa04bb87c7
2,237
Kotlin_bootcamp
MIT License
src/Day02.kt
henryjcee
573,492,716
false
{"Kotlin": 2217}
fun main() { val mapping = mapOf( "A" to 0, "B" to 1, "C" to 2, "X" to 0, "Y" to 1, "Z" to 2, ) fun score(theirs: Int, mine: Int) = mine + 1 + ((mine - theirs).mod(3) + 1) % 3 * 3 fun score2(theirs: Int, mine: Int) = (theirs - 1 + mine).mod(3) + 1 + (mi...
0
Kotlin
0
0
2fde9f3db7454583ac9c47cfca524cfa6a16eb61
810
aoc-2022
Apache License 2.0
Coding Challenges/Advent of Code/2021/Day 5/part2.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
import java.io.File import java.util.* import kotlin.math.abs const val DIM = 1000 var m = Array(DIM) { IntArray(DIM) { 0 } } fun rangeMinMax (x: Int, y: Int) = minOf(x, y)..maxOf(x, y) fun fillMatrix(s: String) { val n = s.split(" -> ") val (x1, y1) = n[0].split(',').map { it.toInt() } val (x2, y2) = n[...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
1,509
Archive
MIT License
src/Day05.kt
zodiia
573,067,225
false
{"Kotlin": 11268}
typealias Stacks = ArrayList<ArrayDeque<Char>> fun main() { fun getStacks(input: List<String>): Stacks { val lines = input.subList(0, input.indexOf("")).dropLast(1).map { it.filterIndexed { idx, _ -> idx % 4 == 1 } } val stacks = Stacks() lines.last().forEach { _ -> stacks.add(ArrayDeque()...
0
Kotlin
0
1
4f978c50bb7603adb9ff8a2f0280f8fdbc652bf2
1,425
aoc-2022
Apache License 2.0
src/main/java/io/github/lunarwatcher/aoc/day3/Day3.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day3 import io.github.lunarwatcher.aoc.commons.readFile fun day3(part: Boolean = false){ val rawObjects = readFile("day3.txt") val res = if(!part) day3part1processor(rawObjects) else day3part2processor(rawObjects) println(res) } fun day3part1processor(rawObjects: List<...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
2,527
AoC-2018
MIT License
src/day05/Day05.kt
Xlebo
572,928,568
false
{"Kotlin": 10125}
package day05 import getOrFetchInputData import readInput import java.util.* fun main() { val operation1: (Int, Stack<Char>, Stack<Char>) -> Unit = { amount: Int, base: Stack<Char>, target: Stack<Char> -> repeat(amount) { target.add(base.pop()) } } val operation2: (Int, Stack<Char>, Stack<Char>)...
0
Kotlin
0
0
cd718c2c7cb59528080d2aef599bd93e0919d2d9
2,632
aoc2022
Apache License 2.0