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/g2901_3000/s2911_minimum_changes_to_make_k_semi_palindromes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2911_minimum_changes_to_make_k_semi_palindromes // #Hard #String #Dynamic_Programming #Two_Pointers // #2023_12_27_Time_216_ms_(100.00%)_Space_37.2_MB_(100.00%) import kotlin.math.min class Solution { private val divisors = getDivisors() private lateinit var cs: CharArray private late...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,297
LeetCode-in-Kotlin
MIT License
src/Day08_2.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
import kotlin.math.max fun main() { fun visilityInRow(columnIndex: Int, rowIndex: Int, row: IntArray): Int { // check left side val left = (columnIndex - 1) downTo 0 var leftScore = 0 for (leftIndex in left) { if (row[leftIndex] < row[columnIndex]) { left...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
2,913
advent-of-code-2022
Apache License 2.0
src/day03/Day03.kt
ignazio-castrogiovanni
434,481,121
false
{"Kotlin": 8657}
package day03 import readInput import kotlin.math.roundToInt fun main() { val exampleInput = listOf( "00100", "11110", "10110", "10111", "10101", "01111", "00111", "11100", "10000", "11001", "00010", "01010") val input = readInput("Day03_test", "day03") println(part1(exampleInput)) p...
0
Kotlin
0
0
5ce48ba58da7ec5f5c8b05e4430a652710a0b4b9
2,745
advent_of_code_kotlin
Apache License 2.0
src/day12/second/Solution.kt
verwoerd
224,986,977
false
null
package day12.second import day12.first.applyGravity import day12.first.readPlanetCoordinates import tools.timeSolution fun main() = timeSolution { val scan = readPlanetCoordinates().map { it.first } val xSteps = calculateLoop(scan.map { it.x }) val ySteps = calculateLoop(scan.map { it.y }) val zSteps = calc...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,127
AoC2019
MIT License
src/day4/Day04.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day4 import readInput fun main() { fun parseInput(input: List<String>) = input.map { pair -> pair.split(",").map { sections -> sections.split("-").map { it.toInt() } } } fun isCover(range1: List<Int>, range2: List<Int>): Boolean { return range2[0] >= range1[0] && range2[1] <= range1[...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
1,350
aoc-2022
Apache License 2.0
src/Day05.kt
inssein
573,116,957
false
{"Kotlin": 47333}
fun main() { fun Array<ArrayDeque<Char>>.topOfStack() = this.mapNotNull { it.firstOrNull() }.joinToString("") fun move(command: String, list: Array<ArrayDeque<Char>>, oneAtATime: Boolean = true) { // could use a regex like "move ([0-9]*) from ([0-9]*) to ([0-9]*)", but prefer split val parts = ...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,887
advent-of-code-2022
Apache License 2.0
src/aoc2023/Day13.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInputText fun main() { val (year, day) = "2023" to "Day13" fun parseInput(input: String): List<Pair<List<Int>, List<Int>>> { return input.split("\n\n").map { line -> val pattern = line.split("\n") fun List<Char>.toBinInt() = this.ma...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,651
aoc-kotlin
Apache License 2.0
src/Day14.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val lines = input.flatMap { it.split("->") .map { segment -> segment.trim().split(',').let { numbers -> Cords(numbers[0].toInt(), numbers[1].toInt()) } } ...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
5,178
aoc-2022
Apache License 2.0
src/commonMain/kotlin/advent2020/day12/Day12Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day12 import advent2020.day12.Action.* import kotlin.math.absoluteValue enum class Action { N, S, E, W, L, R, F } data class Command(val action: Action, val count: Int) { constructor(s: String) : this(Action.valueOf(s.take(1)), s.drop(1).toInt()) } internal fun parseAsSequence(input: String) ...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
2,665
advent-of-code-2020
MIT License
src/Day14.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun part1(input: List<String>): Int { val grid = RocksGrid.parse(input) var counter = 0 while (grid.addSandUnit()) { counter++ } return counter } fun part2(input: List<String>): Int { val grid = RocksGrid.parse(input) var cou...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
3,973
aoc-2022
Apache License 2.0
problems/2020adventofcode11b/submissions/accepted/Stefan.kt
stoman
47,287,900
false
{"C": 169266, "C++": 142801, "Kotlin": 115106, "Python": 76047, "Java": 68331, "Go": 46428, "TeX": 27545, "Shell": 3428, "Starlark": 2165, "Makefile": 1582, "SWIG": 722}
import java.util.* enum class Seat { EMPTY, OCCUPIED, FLOOR } data class WaitingArea(val seats: List<List<Seat>>) { private val neighbors = listOf(Pair(-1, -1), Pair(-1, 0), Pair(-1, 1), Pair(0, -1), Pair(0, 1), Pair(1, -1), Pair(1, 0), Pair(1, 1)) fun people(): Int = seats.sumOf { it.count { cell -> cell ==...
0
C
1
3
ee214c95c1dc1d5e9510052ae425d2b19bf8e2d9
1,528
CompetitiveProgramming
MIT License
src/questions/FirstBadVersion.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe abstract class VersionControl(open val badVersion: Int) { fun isBadVersion(version: Int): Boolean { return version >= badVersion } abstract fun firstBadVersion(n: Int): Int } /** * Suppose you have n versions [1, 2...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,002
algorithms
MIT License
src/Day03.kt
Jenner-Zhl
576,294,907
false
{"Kotlin": 8369}
fun main() { fun findCommonTypes(s: String): Set<Char> { val res = HashSet<Char>() val size = s.length val compartmentSize = size / 2 val firstSet = HashSet<Char>(compartmentSize) for (i in 0 until compartmentSize) { val c = s[i] firstSet.add(c) ...
0
Kotlin
0
0
5940b844155069e020d1859bb2d3fb06cb820981
1,924
aoc
Apache License 2.0
year2023/src/cz/veleto/aoc/year2023/Day18.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.plus class Day18(config: Config) : AocDay(config) { override fun part1(): String { val startState = State() val endState = input .map { line -> val (...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
3,095
advent-of-pavel
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day7.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 7: The Treachery of Whales */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsString import kotlin.math.abs fun main() { println(" ** Day 7: The Treachery of Whales ** \n") val crabPositions = readFileAsString("/Day7CrabPositions.txt").split(",").mapNotNull { it.toIntOrNu...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
1,377
AdventOfCode2021
MIT License
2022/src/day13/day13.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day13 import GREEN import RESET import kotlinx.serialization.json.Json import kotlinx.serialization.json.jsonArray import printTimeMillis import readInput enum class Result { RIGHT, WRONG, PROCEED } fun rightOrWrong(leftStr: String, rightStr: String): Result { val left = Json.parseToJsonElement(leftStr)....
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,468
advent-of-code
Apache License 2.0
src/main/kotlin/solutions/day17/Day17.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day17 import solutions.Solver import utils.Coordinate import utils.Direction import utils.plus import utils.step import kotlin.math.abs data class Rock(val position: Coordinate, val parts: List<Coordinate>) { fun partsAbsolutePositions(): List<Coordinate> = parts.map { position.plus(it) } } val...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
6,221
Advent-of-Code-2022
MIT License
src/main/kotlin/com/colinodell/advent2023/Day13.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day13(input: String) { private val patterns = input.split("\n\n").map { it.split("\n") } private fun findHorizontalLineOfSymmetry(lines: List<String>, desiredCharDifference: Int = 0) = lines .indices .drop(1) .firstOrNull { calculateSymmetry(line...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
2,037
advent-2023
MIT License
src/main/kotlin/day13.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day13() { val lines: List<String> = readFile("day13.txt") day13part1(lines) day13part2(lines) } fun day13part1(lines: List<String>) { var paper = getPaper(lines) val foldInstructions = getFoldInstructions(lines) paper = fold(paper, foldInstructions[0]) val answer = paper.map { row -...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,393
advent_of_code_2021
MIT License
src/Day11.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
private data class Monkey( val id: Int, var items: MutableList<Int>, var part2Items: MutableList<Item>, val operation: (Int) -> Int, val testDivisibleBy: Int, val testTrueMonkey: Int, val testFalseMonkey: Int ) private object Patterns { val monkey = "Monkey (?<id>\\d+):".toRegex() v...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
5,755
advent-of-code-2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions41.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import com.qiaoyuang.algorithm.round0.exchange fun test41() { val sequence = sequence { repeat(80) { yield(it) } } printMedian(sequence) } private fun printMedian(sequence: Sequence<Int>) { val heapMax = IntArray(50) var maxIndex ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,863
Algorithm
Apache License 2.0
src/Day05.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.util.Stack fun main() { fun parse(input: List<String>): Pair<MutableList<Stack<Char>>, List<Triple<Int, Int, Int>>> { val crates = mutableListOf<Stack<Char>>() val cratesInput = input.subList(0, input.indexOf("")) val movesInputs = input.subList(input.indexOf("") + 1, input.size...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
2,367
advent-of-code-2022
Apache License 2.0
src/Day05.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
fun main() { val move = """move (\d+) from (\d+) to (\d+)""".toRegex() fun playInstructions(input: List<String>, allAtOnce: Boolean = false): String { val state = mutableListOf<ArrayDeque<Char>>() input.takeWhile { !it.startsWith(" 1 ") }.map { while (state.size < Math.floorDiv((it....
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
1,817
aoc-2022-demo
Apache License 2.0
src/Day04.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
private fun parseLine(line: String): Pair<Pair<Int, Int>, Pair<Int, Int>> { val (left, right)= line.split(",") .map { val (start, end) = it.split("-") .map(String::toInt) start to end } return left to right } fun main() { fun part1(input: List<Stri...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
1,050
aoc-2022
Apache License 2.0
src/main/kotlin/problems/Day13.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day13(override val input: String) : Problem { override val number: Int = 13 private val dots = input .split("\n\n") .first() .lines() .map { line -> line.split(",") } .map { (x, y) -> Pair(x.toInt(), y.toInt()) } .toSet() private val f...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
2,175
AdventOfCode2021
MIT License
src/main/kotlin/com/ginsberg/advent2022/Day23.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 23 - Unstable Diffusion * Problem Description: http://adventofcode.com/2022/day/23 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day23/ */ package com.ginsberg.advent2022 class Day23(input: List<String>) { priv...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
2,648
advent-2022-kotlin
Apache License 2.0
src/Day03.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename fun getPriorityScore(priority: Char) = if (priority.isUpperCase()) { priority - 'A' + 27 } else { priority - 'a' + 1 } fun calcPriority(line: String): Int { val rucksacks = line.chunked(line.length / 2) val priority = rucksacks[0...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
1,472
KotlinAdventOfCode2022
Apache License 2.0
y2022/src/main/kotlin/adventofcode/y2022/Day02.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day02 : AdventSolution(2022, 2, "Rock Paper Scissors") { override fun solvePartOne(input: String) = input .lines() .map { line -> line.first().toRps() to line.last().toRps() } .sumOf { (opp, play) -> play.score + scor...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,604
advent-of-code
MIT License
src/main/kotlin/ca/kiaira/advent2023/day8/Day8.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day8 import ca.kiaira.advent2023.Puzzle /** * Solution for Day 8 of the Advent of Code challenge. * It involves navigating a network of nodes based on a sequence of left/right instructions. * * @author <NAME> <<EMAIL>> * @since December 8th, 2023 */ object Day8 : Puzzle<Pair<List<Da...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
3,367
kAdvent-2023
Apache License 2.0
src/Day09.kt
inssein
573,116,957
false
{"Kotlin": 47333}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { data class Position(val x: Int, val y: Int) { fun move(direction: Char): Position { return when (direction) { 'U' -> copy(y = y - 1) 'D' -> copy(y = y + 1) 'L' -> copy(x = x - 1...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,783
advent-of-code-2022
Apache License 2.0
src/year2022/day13/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day13 import readInput sealed class Data { data class Integer(val value: Int) : Data() data class ListData(val data: List<Data> = listOf()) : Data() } fun String.findClosingBracketFromPos(openBracketPos: Int): Int { var closedBracketPos = openBracketPos var counter = 1 while (co...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,599
adventOfCode
Apache License 2.0
src/main/kotlin/be/seppevolkaerts/day1/Day1.kt
Cybermaxke
727,453,020
false
{"Kotlin": 35118}
package be.seppevolkaerts.day1 fun part1CalibrationValue(value: String): Int { val firstDigit = value.first { it.isDigit() } val lastDigit = value.last { it.isDigit() } return "$firstDigit$lastDigit".toInt() } fun part1SumOfCalibrationValues(iterable: Iterable<String>): Int { return iterable.sumOf { part1Cali...
0
Kotlin
0
1
56ed086f8493b9f5ff1b688e2f128c69e3e1962c
1,248
advent-2023
MIT License
src/main/kotlin/com/nibado/projects/advent/y2020/Day17.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2020 import com.nibado.projects.advent.* object Day17 : Day { private val grid = resourceLines(2020, 17) .mapIndexed { y, s -> s.mapIndexedNotNull { x, c -> if (c == '#') listOf(x, y, 0) else null } } .flatten().toSet() override fun part1() = solve(...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,223
adventofcode
MIT License
src/Day04.kt
inssein
573,116,957
false
{"Kotlin": 47333}
fun main() { fun String.toRange(): IntRange = this.split('-') .let { (first, second) -> first.toInt()..second.toInt() } fun String.toRanges(): Pair<IntRange, IntRange> = this.split(',') .let { (first, second) -> first.toRange() to second.toRange() } fun IntRange.fullyOverlaps(other: IntRan...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,109
advent-of-code-2022
Apache License 2.0
src/day07/Day07.kt
TheRishka
573,352,778
false
{"Kotlin": 29720}
package day07 import readInput import java.util.* fun main() { val input = readInput("day07/Day07") val rootFolder = Folder( name = "/", files = mutableMapOf(), folders = mutableMapOf(), totalSize = 0L ) var currentFolder: Stack<Folder> = Stack<Folder>().apply { add(ro...
0
Kotlin
0
1
54c6abe68c4867207b37e9798e1fdcf264e38658
4,380
AOC2022-Kotlin
Apache License 2.0
src/Day07.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
import java.util.Stack fun main() { fun getSizesMap(input: List<String>): Map<String, Long> { val mutableMapOf = mutableMapOf<String, Long>() val folders = Stack<String>() for (line in input) { if (line.startsWith("$ cd") && !line.startsWith("$ cd ..")) { va...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
1,868
aoc-2022
Apache License 2.0
src/day23/Day23.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
package day23 import day23.Direction.* import kotlin.test.assertEquals import readInput fun main() { fun part1(input: List<String>): Int { val grove = Grove.parse(input) grove.simulate(10) return grove.emptyGroundTiles() } fun part2(input: List<String>): Int { val grove = Grove.parse(input) ...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
3,976
aoc2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day23/Day23.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day23 import eu.janvdb.aocutil.kotlin.Move import eu.janvdb.aocutil.kotlin.findShortestPath import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines import eu.janvdb.aocutil.kotlin.runWithTimer import kotlin.math.abs const val FILENAME = "input23.txt" val co...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
6,212
advent-of-code
Apache License 2.0
src/commonMain/kotlin/advent2020/day16/Day16Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day16 data class Field(val name: String, val range1: LongRange, val range2: LongRange) { operator fun contains(v: Long) = v in range1 || v in range2 } val fieldRegex by lazy { """(.+): (\d+)-(\d+) or (\d+)-(\d+)""".toRegex() } private fun fields(lines: Sequence<String>): List<Field> = lines ...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
3,542
advent-of-code-2020
MIT License
src/Day03.kt
alexaldev
573,318,666
false
{"Kotlin": 10807}
fun main() { val priorities = ('a'..'z').zip( (1..26)) .toMap(hashMapOf()).apply { putAll(('A'..'Z').zip((27..52)).toMap()) } fun part1(input: List<String>): Int { var acc = 0 input.forEach { line -> val compartments = line.splitInHalf() val first = compartmen...
0
Kotlin
0
0
5abf10b2947e1c6379d179a48f1bdcc719e7062b
1,484
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day19.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 import at.mpichler.aoc.lib.ShortestPaths import kotlin.math.min open class Part19A : PartSolution() { protected lateinit var blueprints: List<Blueprint> override fun parseInput(text: String) { ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
6,913
advent-of-code-kotlin
MIT License
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day17.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2021 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readText import se.brainleech.adventofcode.verify import kotlin.math.abs import kotlin.math.sign class Aoc2021Day17 { companion object { private const val debug = false private ...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
3,716
adventofcode
MIT License
src/main/kotlin/day14/Day14.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day14 import Stack import execute import readAllText import wtf class Cave(val abyss: Int) { private val data: Array<BooleanArray> = Array(abyss + 2) { BooleanArray(abyss * 2 + 6) } private val offset: Int = 500 - abyss - 3 operator fun plusAssign(point: Pair<Int, Int>) { val (x, y) = poi...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
2,857
advent-of-code-2022
MIT License
src/Day09.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { Day9.printSolutionIfTest(88, 36) } object Day9 : Day<Int, Int>(9) { override fun part1(lines: List<String>) = solveForLength(lines, 1) override fun part2(lines: List<String>) = solveForLength(lines, 9) private val moves = mapOf("R...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
1,606
advent-of-code-2022
Apache License 2.0
src/Day03.kt
mpythonite
572,671,910
false
{"Kotlin": 29542}
fun main() { fun part1(input: List<String>): Int { var score = 0 for (i in input.indices) { val split = input[i].length / 2 val first = input[i].subSequence(0, split).toString().asIterable() val second = input[i].subSequence(split, input[i].length).toStrin...
0
Kotlin
0
0
cac94823f41f3db4b71deb1413239f6c8878c6e4
1,481
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/dikodam/adventofcode2019/days/Day12.kt
dikodam
225,222,616
false
null
package de.dikodam.adventofcode2019.days import de.dikodam.adventofcode2019.utils.* import kotlin.math.abs fun main() { val (moonsInput, setupDuration) = withTimer { day12input.split("\n") .map { it.drop(1).dropLast(1) } .map { line -> inputlineToCoordinates(line) } .ma...
0
Kotlin
0
0
6db72123172615f4ba5eb047cc2e1fc39243adc7
3,823
adventofcode2019
MIT License
src/day8/Day8.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
package day8 import java.io.File fun find_one_chars(input: List<List<Char>>): List<Char> { return input.find { it.size == 2 } ?: throw IllegalStateException("One not found") } fun find_four_chars(input: List<List<Char>>): List<Char> { return input.find { it.size == 4 } ?: throw IllegalStateException("Four no...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
5,739
AdventOfCode2021
Apache License 2.0
src/main/kotlin/day19/Code.kt
fcolasuonno
317,324,330
false
null
package day19 import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/main/kotlin/$dir/$name").readLines() val parsed = parse(input) part1(parsed) part2(...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
2,530
AOC2020
MIT License
src/Utils.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
import java.io.File import java.math.BigInteger import java.security.MessageDigest import kotlin.math.abs import kotlin.math.max /** * Extension function to get all index positions of a given element in a collection */ fun <E> Iterable<E>.indexesOf(e: E) = mapIndexedNotNull { index, elem -> index.takeIf { elem == e ...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
3,291
aoc-2022-in-kotlin
Apache License 2.0
src/Day03.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
import java.lang.IllegalArgumentException fun mapItemToPriority(item: Char): Int { return when (item) { 'a' -> 1 'b' -> 2 'c' -> 3 'd' -> 4 'e' -> 5 'f' -> 6 'g' -> 7 'h' -> 8 'i' -> 9 'j' -> 10 'k' -> 11 'l' -> 12 ...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
2,896
advent-of-code-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/MergeSortedArray.kt
faniabdullah
382,893,751
false
null
//You are given two integer arrays nums1 and nums2, sorted in non-decreasing //order, and two integers m and n, representing the number of elements in nums1 and //nums2 respectively. // // Merge nums1 and nums2 into a single array sorted in non-decreasing order. // // The final sorted array should not be returned by...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,839
dsa-kotlin
MIT License
2022/src/Day12.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src import kotlin.Double.Companion.POSITIVE_INFINITY import kotlin.math.min fun main() { val mountain = readInput("input12") .map { it.trim().split("") } .map { it.filter { it2 -> it2 != "" } } .map { it.map { it2 -> it2.first() }.toMutableList() } .toMutableList() v...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
2,726
AoC
Apache License 2.0
src/day12/first/Solution.kt
verwoerd
224,986,977
false
null
package day12.first import tools.timeSolution import java.util.stream.Collectors import kotlin.math.abs const val STEPS = 1000 fun main() = timeSolution { var scan = readPlanetCoordinates() for (step in 1..STEPS) { scan = scan.map { (location, velocity) -> val newVelocity = scan.fold(velocity) { (x, y,...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,958
AoC2019
MIT License
src/Day13.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
import com.beust.klaxon.Klaxon private val FIRST_DIVIDER = listOf(listOf(2)) private val SECOND_DIVIDER = listOf(listOf(6)) fun <T> MutableList<T>.swap(from: Int, to: Int) { val temp = this[from] this[from] = this[to] this[to] = temp } fun main() { fun inRightOrder(left: Any, right: Any, index: Int,...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
2,755
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/Day05.kt
alexdesi
575,352,526
false
{"Kotlin": 9824}
import java.io.File fun main() { val regex = """\s*\[(\w)\]\s*""".toRegex() fun getStacks(input: List<String>): MutableList<MutableList<Char>> { val stackSize = (input.first().length + 1) / 4 val stacks: MutableList<MutableList<Char>> = mutableListOf() repeat(stackSize) { ...
0
Kotlin
0
0
56a6345e0e005da09cb5e2c7f67c49f1379c720d
2,736
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/jackchapman/codingchallenges/hackerrank/QueensAttack.kt
crepppy
381,882,392
false
null
package com.jackchapman.codingchallenges.hackerrank import kotlin.math.abs /** * Problem: [Queen's Attack II](https://www.hackerrank.com/challenges/queens-attack-2/) * * Given a chess board and a list of obstacles, find the number of valid moves a queen can make * @param size The size of the chess board * @param...
0
Kotlin
0
0
9bcfed84a9850c3977ccff229948cc31e319da1b
1,661
coding-challenges
The Unlicense
src/Day02/Day02.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day02 import readInput fun main() { fun part1(input: List<String>): Int { val shapePoints: HashMap<Char, Int> = hashMapOf( 'A' to 1, // Rock 'B' to 2, // Paper 'C' to 3, // Scissors 'X' to 1, // Rock 'Y' to 2, // Paper 'Z' to ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
3,421
aoc-2022
Apache License 2.0
src/main/kotlin/aoc/year2021/Day04.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2021 import aoc.Puzzle /** * [Day 4 - Advent of Code 2021](https://adventofcode.com/2021/day/4) */ object Day04 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { val split = input.split(Regex("(\\r?\\n){2}")) val boards = split.drop(1) .map { it.sp...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,950
advent-of-code
Apache License 2.0
src/Day07.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
fun main() { fun part1(input: List<String>): Int { val fileSystem = AOCFileSystem() fillFileSystem(input, fileSystem) val nestedDirectories = getNestedDirectories(fileSystem) return nestedDirectories.map { it.getSize() }.filter { it < 100000 }.sum() } fun part2(input: Lis...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
3,268
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/day7/HandyHaversacks.kt
Pkshields
318,658,287
false
null
package dev.paulshields.aoc.day7 import dev.paulshields.aoc.common.readFileAsStringList val bagRuleRegex = Regex("(.+?) bags? contain (.+)") val captureInnerBagDetailsRegex = Regex("(\\d) (.+?) bags?") fun main() { println(" ** Day 7: Handy Haversacks ** \n") val input = readFileAsStringList("/day7/BagRules...
0
Kotlin
0
0
a7bd42ee17fed44766cfdeb04d41459becd95803
2,254
AdventOfCode2020
MIT License
src/main/kotlin/_2022/Day12.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun getChar(input: List<String>, vertex: Pair<Int, Int>): Char { var first = input[vertex.first][vertex.second] if (first == 'S') { first = 'a' } else if (first == 'E') { first = 'z' } return first } ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,518
advent-of-code
Apache License 2.0
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day19Part2.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty fun List<String>.day19Part2(): Int { val ruleMap = this.filter { it.contains(":") } .associate { rule -> rule.split(":").let { it.first().trim() to it.last().trim() } } .toMutableMap() val messages = this.filter { it.contains(":").not() }.filter { it....
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
3,680
AdventOfCode
MIT License
src/main/kotlin/aoc2020/day04_passport_processing/PassportProcessing.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2020.day04_passport_processing import util.paragraphs fun main() { util.solve(206, ::partOne) util.solve(123, ::partTwo) } private fun String.toKeyMap() = paragraphs() .map { it.split(' ') .map { it.split(':') } .associate { (a, b) -> Pair(a,...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,479
aoc-2021
MIT License
src/main/kotlin/day21/Day21.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day21 import readInput sealed interface Node { val id: String } class Expr(override val id: String, val v1: Node, val v2: Node, val op: String) : Node { override fun toString(): String = "($v1 $op $v2)" } class Num(override val id: String, val v: Long) : Node { override fun toString(): String =...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
3,972
aoc2022
Apache License 2.0
src/Day04.kt
Flexicon
576,933,699
false
{"Kotlin": 5474}
fun main() { fun String.toRange(): IntRange = split("-") .map { it.toInt() } .let { (from, to) -> from..to } fun List<String>.toRangePairs() = map { it.split(",").map { r -> r.toRange() } } fun IntRange.contains(other: IntRange): Boolean = (other.first in this) && (othe...
0
Kotlin
0
0
7109cf333c31999296e1990ce297aa2db3a622f2
1,160
aoc-2022-in-kotlin
Apache License 2.0
src/day01/Day01.kt
shiddarthbista
572,833,784
false
{"Kotlin": 9985}
package day01 import readInput fun main() { fun part1(input: List<String>): Int { return getCalorieSums(input).maxOrNull() ?: 0 } fun part2(input: List<String>): Int { val calorieSums = getCalorieSums(input) calorieSums.sortDescending() return calorieSums.subList(0, 3).sum...
0
Kotlin
0
0
ed1b6a132e201e98ab46c8df67d4e9dd074801fe
1,421
aoc-2022-kotlin
Apache License 2.0
src/day05/Day05.kt
Raibaz
571,997,684
false
{"Kotlin": 9423}
package day05 import readInput typealias Stacks = List<ArrayDeque<Char>> fun parseInput(input: List<String>): Pair<Stacks, List<Operation>> { val stacksInput = input.takeWhile { it.contains("[A-Z]".toRegex()) } val stackCount = input.first { it.contains("[0-9]".toRegex()) }.split(" ").last().toInt() va...
0
Kotlin
0
0
99d912f661bd3545ca9ff222ac7d93c12682f42d
2,954
aoc-22
Apache License 2.0
src/Day05.kt
treegem
572,875,670
false
{"Kotlin": 38876}
import common.readInput fun main() { fun part1(input: List<String>): String { val crates = input.getCrates() input .getInstructions() .forEach { it.applyMovingSingleBoxes(crates) } return crates.readTopCrates() } fun part2(input: List<String>): String { ...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
2,952
advent_of_code_2022
Apache License 2.0
2021/src/main/kotlin/alternative/Day04.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
package alternative class Day04(private val input: List<String>) { private fun prepareBoards(): Pair<List<Int>, List<Board>> { val numbers = input.first().trim().split(",").map(String::toInt) val grids = input.drop(1) val boards = grids.map(Board.Companion::parse) return Pair(numbe...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
2,102
adventofcode-2021-2025
MIT License
src/Day20.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import java.util.LinkedList fun main() { fun parseInput(input: List<String>) = LinkedList(input.mapIndexed { idx, n -> idx to n.toLong() }) fun decrypt(out: LinkedList<Pair<Int, Long>>) { out.indices.forEach { idx -> val currentItem = out.withIndex().find { it.value.first == idx }!! ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
1,415
aoc-2022
Apache License 2.0
src/Day04CampCleanup.kt
zizoh
573,932,084
false
{"Kotlin": 13370}
fun main() { val input: List<String> = readInput("input/day04") println("total complete overlap: ${getCompleteOverlap(input)}") println("total partial overlap: ${getPartialOverlap(input)}") } private fun getCompleteOverlap(input: List<String>) = input.sumOf { val reorderedList: List<Int> = getReordered...
0
Kotlin
0
0
817017369d257cca648974234f1e4137cdcd3138
2,191
aoc-2022
Apache License 2.0
src/Day07.kt
brunojensen
572,665,994
false
{"Kotlin": 13161}
/** * This method looks terrible, needs a good refactoring! */ private fun createDirectoryMap(input: List<String>): Map<String, Int> { return buildMap { val directory = mutableListOf<String>() input.forEach { val splittedInput = it.split(" ") when (splittedInput.first()) { "$" -> when (s...
0
Kotlin
0
0
2707e76f5abd96c9d59c782e7122427fc6fdaad1
1,531
advent-of-code-kotlin-1
Apache License 2.0
src/Day21.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private interface MonkeyJob private data class NumberJob( val number: Long ): MonkeyJob private data class MathsJob( val left: String, val right: String, val operation: String ): MonkeyJob private val mathsFormat = """(\w+) ([\+\-*/]) (\w+)""".toRegex() private fun parseJobs(input: List<String>): Ma...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
3,433
advent-of-code-2022
Apache License 2.0
src/Day04.kt
Moonpepperoni
572,940,230
false
{"Kotlin": 6305}
fun main() { fun String.sectionPairs() : Pair<IntRange, IntRange> { val inputPattern = """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() val (firstStart, firstEnd, secondStart, secondEnd) = inputPattern.matchEntire(this)?.destructured ?: error("Input incorrect") return firstStart.toInt()..firstEnd.to...
0
Kotlin
0
0
946073042a985a5ad09e16609ec797c075154a21
1,303
moonpepperoni-aoc-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem2316/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2316 class Solution2 { /* Complexity: * Time O(n+E) and Space O(n) where E is the size of edges; */ fun countPairs(n: Int, edges: Array<IntArray>): Long { val nodeUnionFind = UnionFind(n, edges) val componentSizes = sizesOfConnectedComponents(n, n...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,942
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/days/Day4.kt
hughjdavey
159,955,618
false
null
package days import days.Day4.Record.RecordType.GUARD import days.Day4.Record.RecordType.SLEEP import days.Day4.Record.RecordType.WAKE import java.time.LocalDateTime class Day4 : Day(4) { private val sortedRecords: List<Record> = inputList.map { Record(it) }.sortedBy { it.dateTime } private val guards: Set<G...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
2,821
aoc-2018
Creative Commons Zero v1.0 Universal
src/test/kotlin/io/noobymatze/aoc/y2022/Day11.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2022 import io.noobymatze.aoc.Aoc import kotlin.test.Test class Day11 { data class Monkey( val items: MutableList<Long>, val op: (Long) -> Long, val test: Long, val then: Int, val `else`: Int, var inspections: Long = 0, ) @Test ...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
3,058
aoc
MIT License
src/Day20.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { fun part1(input: List<String>): Long { val encryptedCoordinates = input.map { it.toLong() }.withIndex().toMutableList() encryptedCoordinates.mix() return encryptedCoordinates.map { it.value }.groveCoordinatesSum() } val DECRYPTION_KEY = 811589153L fun part2(input: L...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
1,333
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
kprow
573,685,824
false
{"Kotlin": 23005}
fun main() { fun priority(fromChar: Char): Int { return if (fromChar.isLowerCase()) { fromChar.code - 96 } else { fromChar.code - 38 } } fun part1(input: List<String>): Int { var commonItems = arrayOf<Char>() var sumOfPriorities = 0 for...
0
Kotlin
0
0
9a1f48d2a49aeac71fa948656ae8c0a32862334c
1,678
AdventOfCode2022
Apache License 2.0
year2016/src/main/kotlin/net/olegg/aoc/year2016/day20/Day20.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day20 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2016.DayOf2016 import java.util.TreeSet /** * See [Year 2016, Day 20](https://adventofcode.com/2016/day/20) */ object Day20 : DayOf2016(20) { private val PATTERN = "(\\d+)-(\\d+)".toRegex() override fun first(): ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,723
adventofcode
MIT License
src/main/java/hes/nonogram/LogicSolver.kt
Hes-Siemelink
689,215,071
false
{"Kotlin": 32733}
package hes.nonogram import hes.nonogram.State.EMPTY import hes.nonogram.State.UNKNOWN import io.github.oshai.kotlinlogging.KotlinLogging class LogicSolver() : PuzzleSolver { private val log = KotlinLogging.logger {} override fun solve(puzzle: Puzzle): Puzzle? { var previousState: Puzzle? ...
0
Kotlin
0
0
7b96e50eb2973e4e2a906cf20af743909f0ebc8d
2,729
Nonogram
MIT License
src/cn/leetcode/codes/simple101/Simple101.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple101 import cn.leetcode.codes.common.TreeNode import cn.leetcode.codes.createTreeNode import cn.leetcode.codes.out import cn.leetcode.codes.outTreeNote import java.util.* fun main() { // val node = createTreeNode(arrayOf(1,2,2,3,4,4,3)) val node = createTreeNode(arrayOf(9, -42, ...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
2,347
LeetCodeSimple
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day06.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput("Day06") Day06.part1(input).println() Day06.part2(input).println() } object Day06 { fun part1(input: List<String>): Int { val times = input[0].split(":")[1].split(" ").filter { it.isNotBlank() } val distances = input[1].split(":")[1]....
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
1,448
advent-of-code
MIT License
src/aoc22/Day19.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day19 import lib.Bag import lib.Solution import lib.Strings.words enum class Mineral { ORE, CLAY, OBSIDIAN, GEODE; companion object { fun parse(mineral: String): Mineral = Mineral.values().find { it.name.lowercase() == mineral } ?: error("Bad in...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
4,568
aoc-kotlin
Apache License 2.0
src/Day15Part1.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.abs import kotlin.math.max class Day15Part1 { companion object { fun main() { val regex = Regex("-?\\d+") val input = readInput("Day15_input") val y = 2000000 val sensors = input.asSequence() .mapNotNull { regex.findAll(it)....
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
2,389
aoc-2022
Apache License 2.0
src/day13/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day13 import util.PeekingIterator import util.nextOrNull import util.peekingIterator import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 13 testInput.part2() shouldBe 140 val input = readInpu...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
4,042
advent-of-code-2022
Apache License 2.0
src/Day09.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
import kotlin.math.absoluteValue import kotlin.math.sign private data class Cell(var x: Int = 0, var y: Int = 0) { fun move(other: Cell) { x += other.x y += other.y } fun isAttached(other: Cell) = (x - other.x).absoluteValue < 2 && (y - other.y).absoluteValue < 2 fun follow(other: Ce...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
1,574
advent-of-code-kotlin
Apache License 2.0
src/Day03.kt
F-bh
579,719,291
false
{"Kotlin": 5785}
fun main() { val tempMap = ('a'..'z'). fold(mutableMapOf<Char, Int>()) { map, ch -> map[ch] = map.size+1; map } val valueMap = ('A'..'Z'). fold(tempMap) { map, ch -> map[ch] = map.size+1; map }.toMap() val input = readDayInput(3) pt1(valueMap, input) pt2(valueMap, input) } fun pt1(valMap...
0
Kotlin
0
0
19fa2db8842f166daf3aaffd201544658f41d9e0
1,238
Christmas2022
Apache License 2.0
src/y2022/Day11.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.readInput import util.split object Day11 { data class Monkey( var items: MutableList<Long>, val operation: (Long) -> Long, val divisible: Int, val targetTrue: Int, val targetFalse: Int, var numInspections: Long = 0 ) { companion...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,923
advent-of-code
Apache License 2.0
src/Day17.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import utils.Coord2DLong import kotlin.math.min val rocks = listOf( (0..3L).map { Coord2DLong(it, 0) }, listOf(Coord2DLong(0, 1), Coord2DLong(1, 2), Coord2DLong(1, 1), Coord2DLong(1, 0), Coord2DLong(2, 1)), listOf(Coord2DLong(0, 0), Coord2DLong(1, 0), Coord2DLong(2, 2), Coord2DLong(2, 1), Coord2DLong(2, 0)...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
3,466
Advent-Of-Code-2022
Apache License 2.0
src/Day05.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun part1(input: List<String>): String { val (stacks, instructions) = input.asStacksAndInstructions() instructions.forEach { stacks.handle(it) { from, to, quantity -> from.moveSingleCrateAtOnce(quantity, to) } } return stacks.mes...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
3,693
advent-of-code-2022
Apache License 2.0
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day15/Day15.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2015.day15 import kotlin.math.max fun Array<Array<Int>>.totals(): Array<Int> { return Array(this[0].size) { j -> this.sumOf { it[j] } } } operator fun Array<Array<Int>>.times(factors: Array<Int>): Array<Array<Int>> { return Array(size) { i -> Array(this[i].size) ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,128
advent-of-code
MIT License
src/day02/Day02.kt
wasabi-muffin
726,936,666
false
{"Kotlin": 10804}
package day02 import base.Day import base.filterDigits import base.filterLetters fun main() = Day02.run() object Day02 : Day<Int>("02") { override val test1Expected: Int = 8 override val test2Expected: Int = 2286 override fun part1(input: List<String>): Int { return input.map { Game(it) }.sumOf ...
0
Kotlin
0
0
544cdd359e4456a74b1584cbf1e5dddca97f1394
1,609
advent-of-code-2023
Apache License 2.0
src/Day14.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import kotlin.math.max import kotlin.math.min fun main() { val testInput = readInput("Day14_test") check(part1(testInput) == 24) check(part2(testInput) == 93) val input = readInput("Day14") println(part1(input)) println(part2(input)) } private val SAND_START_POINT = XY(500, 0) private fun pa...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
2,117
AOC2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-22.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.searchGraph import com.github.ferinagy.adventOfCode.singleStep import kotlin.math.abs fun main() { println("Part1:") println(part1()) println() println("Part2:") ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
51,884
advent-of-code
MIT License
src/main/kotlin/de/niemeyer/aoc2022/Day12.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 12: Hill Climbing Algorithm * Problem Description: https://adventofcode.com/2022/day/12 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.points.Point2D import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { fun part1(inp...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,492
AoC-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/arrays/DistinctEvenPairSum.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.arrays /** * Given a circular array of N integers (i.e. A[0] and A[N — 1] are adjacent to each other), * what's the maximum number of adjacent pairs that you can form whose sum are even? * Note that each element can belong to at most one pair. * * Examples: * 1. G...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
2,589
algs4-leprosorium
MIT License
src/Day15.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import Day15.rangesFor import utils.Coordinate2D import utils.readInputAsLines import utils.union import kotlin.math.abs fun main() { val input = readInputAsLines("day15_input") val regex = """x=(-?[0-9]+), y=(-?[0-9]+).*x=(-?[0-9]+), y=(-?[0-9]+)""".toRegex() val sensorReports = input .mapNotNull...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
1,558
advent-of-code-2022
Apache License 2.0
src/Day14.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
import java.awt.Point fun main() { val startPoint = Point(500, 0) fun buildWalls(input: List<String>): Set<Point> { return input.flatMap { row -> row.split("->") .map { cord -> cord.split(",") .map { it.trim().toInt() } ...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
2,464
AdventOfCode2022
Apache License 2.0
src/main/kotlin/aoc2023/Day11.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.ArrayAsSurface import utils.Coordinates import utils.InputUtils import utils.boundingBox fun Coordinates.distanceTo(other: Coordinates) = (other - this).length() fun <T> allPairs(items: List<T>): Sequence<Pair<T,T>> = items.asSequence().flatMapIndexed { a, first -> (a..<items.size).m...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,487
aoc-2022-kotlin
Apache License 2.0