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/Day11/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day11 import readInput object Solution { data class Monkey( var startingItems: MutableList<ULong>, val operation: Char, val operationValue: String, val testDivisibleBy: ULong, val monkeyTrue: Int, val monkeyFalse: Int, var activities: ULong = 0UL, ...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
4,487
aoc-2022
Apache License 2.0
src/year2023/day15/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day15 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 15, transform = List<String>::first) runAlgorithm( realInput = realInput, testInputs = testInputs, ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
1,751
Advent-of-Code
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-18.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.Coord3D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import com.github.ferinagy.adventOfCode.searchGraph import com.github.ferinagy.adventOfCode.singleStep import kotlin.ma...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,210
advent-of-code
MIT License
src/Day05.kt
Jaavv
571,865,629
false
{"Kotlin": 14896}
// https://adventofcode.com/2022/day/5 fun main() { val testInput = readInput("Day05_test") val input = readInput("Day05") val parse = input.map { it.split("\n") }.flatten() val emptySpaceIndex = parse.indexOfFirst { it.isBlank() } val padding = parse[emptySpaceIndex - 1].length + 1 val crates ...
0
Kotlin
0
0
5ef23a16d13218cb1169e969f1633f548fdf5b3b
2,781
advent-of-code-2022
Apache License 2.0
src/day05/Day05.kt
tiginamaria
573,173,440
false
{"Kotlin": 7901}
package day05 import readInput import java.lang.Integer.min import java.util.Stack data class Move(val count: Int, val from: Int, val to: Int) fun main() { fun parseStacks(stacksInput: List<String>, stacksNums: String): List<Stack<Char>> { val positions = (1..stacksNums.length step 4) val stack...
0
Kotlin
0
0
bf81cc9fbe11dce4cefcb80284e3b19c4be9640e
2,511
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/ab/advent/day03/Models.kt
battagliandrea
574,137,910
false
{"Kotlin": 27923}
package com.ab.advent.day03 data class Group(val rucksacks: List<Rucksack>){ val priority: Int = rucksacks.sumOf { it.commonItem.value.toPriority() } } data class ChankedGroup(val chunks: List<List<Rucksack>>){ val priority: Int = chunks .map { c -> c.map { it.id } } .map {(sack1, sack12, sack...
0
Kotlin
0
0
cb66735eea19a5f37dcd4a31ae64f5b450975005
1,164
Advent-of-Kotlin
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2023/Day07.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2023.Day07.HandType.* /** * [Day 7: Camel Cards](https://adventofcode.com/2023/day/7). */ object Day07 { @JvmStatic fun main(args: Array<String>) { measure { ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
5,416
advent-of-code
MIT License
src/day02/Day02.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day02 import readInput enum class RPS(val points: Int) { Rock(1), Paper(2), Scissors(3) } enum class RoundResult(val points: Int) { Loose(0), Draw(3), Win(6) } data class TournamentPair(val opponentChoice: RPS, val roundResult: RoundResult) val inputLineRegex = """([ABC]) ([XYZ])"""...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
2,542
advent-of-code-2022
Apache License 2.0
src/Day08.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
fun main() { fun getColumn(matrix: Array<IntArray>, col: Int): IntArray { val nums = IntArray(matrix.size) for (i in nums.indices) { nums[i] = matrix[i][col] } return nums } fun getMatrix(input: List<String>): Array<IntArray> { val matrix = Array(input.g...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
2,735
Kotlin-AoC-2022
Apache License 2.0
src/Day04.kt
hrach
572,585,537
false
{"Kotlin": 32838}
fun main() { fun part1(input: List<String>): Int { return input .filter { it.isNotBlank() } .map { val (a, b) = it.split(",") val (aa, ab) = a.split("-").map { it.toInt() } val (ba, bb) = b.split("-").map { it.toInt() } IntRange(aa, ab) to IntRange(ba, bb) } .count { (a, b) -> (a.firs...
0
Kotlin
0
1
40b341a527060c23ff44ebfe9a7e5443f76eadf3
917
aoc-2022
Apache License 2.0
src/Day18.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.util.* private data class Region3D(val mn: Point3D, val mx: Point3D) { fun contains(point: Point3D): Boolean { val (x1, y1, z1) = mn val (x2, y2, z2) = mx val (x, y, z) = point return (x1..x2).contains(x) && (y1..y2).contains(y) && (z1..z...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
3,191
advent-of-code-kotlin-2022
Apache License 2.0
src/year2021/Day13.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import Point import readFile fun main() { val input = parseInput(readFile("2021", "day13")) val testInput = parseInput(readFile("2021", "day13_test")) check(part1(testInput) == 17) println("Part 1:" + part1(input)) println("Part 2:") val (width, height) = part2(input) in...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
3,221
advent_of_code
MIT License
src/Day09.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
import kotlin.math.abs import kotlin.math.sign const val FIELD_SIZE = 610 fun main() { fun parseInput(input: List<String>): List<Pair<Int, Int>> { return input.map { val (direction, stepsStr) = it.split(' ') val steps = stepsStr.toInt() when (direction) { "D" -> steps to 0 "U" ...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
1,898
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/day09/Day09.kt
pientaa
572,927,825
false
{"Kotlin": 19922}
package day09 import day09.Direction.DOWN import day09.Direction.LEFT import day09.Direction.RIGHT import day09.Direction.UP import readLines import kotlin.math.abs fun main() { fun applyMoves(input: List<String>, knots: List<Knot>) { input.map { line -> val (direction, steps) = line.split(" ...
0
Kotlin
0
0
63094d8d1887d33b78e2dd73f917d46ca1cbaf9c
3,371
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day09.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.* fun main() = Day09.run() object Day09 : Day(2021, 9) { override fun part1() : Any { val map = toMap(input) val lowpoints = map.keys.filter { p -> (p.neighborsSimple().mapNotNull { map[it] }.all { it.toString().toInt() > map[p].toSt...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,737
adventofkotlin
MIT License
src/day11/Day11.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day11 import readInput fun main() { data class Test(val testDivider: Long, val predicate: (Long) -> Boolean, val trueMonkey: Int, val falseMonkey: Int) data class Monkey( val worries: ArrayDeque<Long>, val operation: (Long) -> Long, val test: Test, var inspections: In...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
4,188
advent-of-code-2022
Apache License 2.0
src/main/kotlin/2021/Day5.kt
mstar95
317,305,289
false
null
package `2021` import days.Day import java.lang.Integer.max import java.lang.Integer.min class Day5 : Day(5) { override fun partOne(): Any { val lanes = inputList.map { it.split(" -> ") .map { it.split(",").map { it.toInt() } } .map { Point(it[0], it[1]) } ...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,470
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day18.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import java.util.* fun main() { fun part1(input: List<String>): Int { val lava = input.map { it.split(',').toList().map { it.toInt() } } val dirs = listOf( listOf(1, 0, 0), listOf(0, 1, 0), listOf(0, 0, 1), listOf(-1, 0, 0), listOf(0, -1, ...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,515
aoc2022
Apache License 2.0
src/main/kotlin/aoc2021/day12.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.loadInput fun main() { val pattern = Regex("""(\w+)-(\w+)""") val edges = loadInput("/2021/day12") .bufferedReader() .readLines() .map { val (u, v) = pattern.find(it)!!.destructured Edge(u, v).normalize() } ....
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
2,008
aoc-kotlin
Apache License 2.0
src/day17/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day17 import assert import println import readInput import java.util.* enum class Direction(val row: Int, val column: Int) { UP(-1, 0), DOWN(1, 0), LEFT(0, -1), RIGHT(0, 1); val opposite by lazy { when (this) { UP -> DOWN RIGHT -> LEFT DOWN -> U...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
4,026
advent-of-code-2023
Apache License 2.0
src/Day03.kt
jdpaton
578,869,545
false
{"Kotlin": 10658}
fun main() { fun part1() { val testInput = readInput("Day03_test") var sum = 0 testInput.forEach { line -> val compartmentOne = line.substring(0, (line.length/2)).toCharArray() val compartmentTwo = line.substring(line.length/2, line.length).toCharArray() ...
0
Kotlin
0
0
f6738f72e2a6395815840a13dccf0f6516198d8e
2,126
aoc-2022-in-kotlin
Apache License 2.0
src/day05/Day05.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day05 import readInput import java.util.* data class Instruction( val moveCount: Int, val origin: Int, val destination: Int ) fun main() { val instructionRegex = """move ([0-9]+) from ([0-9]+) to ([0-9]+)""".toRegex() // 1: 1, 2: 5, 3: 9, 4: 13 fun crateKeyToLineIndex(key: Int): Int ...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
3,444
advent-of-code-2022
Apache License 2.0
src/year2023/day14/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day14 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.findCycle import utils.readInputs import utils.runAlgorithm import utils.transpose fun main() { val (realInput, testInputs) = readInputs(2023, 14) runAlgorithm( realInput = realInput, testInputs = te...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,391
Advent-of-Code
Apache License 2.0
src/Day11.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import java.util.LinkedList import java.util.Queue fun main() { data class Monkey( val items: Queue<Long>, val operation: (Long) -> Long, val divisibleBy: Long, val trueMonkey: Int, val falseMonkey: Int, ) fun progress(input: List<String>, div: Boolean, repeats: Int...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
2,842
Advent-of-code
Apache License 2.0
src/Day05.kt
MatthiasDruwe
571,730,990
false
{"Kotlin": 47864}
fun main() { fun part1(input: List<String>): String { val start = input.subList(0, input.indexOf("")) val actions = input.subList(input.indexOf("") + 1, input.size).map { val items = it.split(" ") Triple(items[1].toInt(), items[3].toInt(), items[5].toInt()) } ...
0
Kotlin
0
0
f35f01cea5075cfe7b4a1ead9b6480ffa57b4989
2,037
Advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day9/Day9.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day9 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day9 : Day { override val input = readInputLines(9) .map { l -> l.toCharArray().map { it.digitToInt() } } .flatMapIndexed { y, i -> i.mapIndexed...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
1,541
aoc2021
MIT License
src/day07/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day07 import day07.FileSystemThing.Dir import java.io.File const val workingDir = "src/day07" fun main() { val sample = File("$workingDir/sample.txt") val input1 = File("$workingDir/input_1.txt") println("Step 1a: ${runStep1(sample)}") println("Step 1b: ${runStep1(input1)}") println("Step...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
2,654
advent-of-code-2022
Apache License 2.0
kotlin/src/Day06.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt fun main() { val part1Iterations = 80 val part2Iterations = 256 data class LanternFish(val timer: Int) fun updateLanternFish(fish: List<LanternFish>): List<LanternFish> { val oldFish = fish.map { singleFish -> if (singleFish.timer == 0) { ...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
2,159
aoc-2021
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/dynamicprogramming/longestcommonsubsequence/longestCommonSubsequence.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.dynamicprogramming.longestcommonsubsequence import kotlin.math.max /** * LCS is a classic problem. Let dp[i][j] be the LCS for string text1 ends at index i and string text2 ends at index j. * If text1[i]==text2[j], then dp[i][j] would be 1+dp[i−1][j−1]. Otherwise, we target the l...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
1,710
KotlinGround
MIT License
src/Day08.kt
gsalinaslopez
572,839,981
false
{"Kotlin": 21439}
fun main() { fun buildTreeGrid(input: List<String>) = Array(input.size) { i -> Array(input[i].length) { j -> input[i][j].digitToInt() } } fun part1(treeGrid: Array<Array<Int>>): Int { val markerGrid = Array(treeGrid.size) { i -> Array(treeGrid[i].size) { j -> i == 0 ...
0
Kotlin
0
0
041c7c3716bfdfdf4cc89975937fa297ea061830
3,735
aoc-2022-in-kotlin
Apache License 2.0
src/Day16.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import kotlin.collections.ArrayDeque import kotlin.math.max private const val EXPECTED_1 = 46 private const val EXPECTED_2 = 51 private class Day16(isTest: Boolean) : Solver(isTest) { data class Point(val y: Int, val x: Int, val dir: Int) val dirs = listOf(0 to -1, 1 to 0, 0 to 1, -1 to 0) val field = re...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,029
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day02/Day02.kt
W3D3
726,573,421
false
{"Kotlin": 81242}
package day02 import common.InputRepo import common.readSessionCookie import common.solve import util.splitIntoPair fun main(args: Array<String>) { val day = 2 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay02Part1, ::solveDay02Part2) } fun solveDay02Part1(in...
0
Kotlin
0
0
da174508f6341f85a1a92159bde3ecd5dcbd3c14
2,159
AdventOfCode2023
Apache License 2.0
src/Day12.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
enum class Direction(val dColumn: Int, val dRow: Int) { Up(0, -1), Down(0, 1), Left(-1, 0), Right(1, 0), } fun main() { fun findMinSteps(input: List<String>, stepsDelta: (Int, Int) -> Int): Int { var start = 0 to 0 var end = 0 to 0 var heightMap = input.mapIndexed { rowInde...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
2,615
aoc-2022
Apache License 2.0
src/Day15.kt
kipwoker
572,884,607
false
null
import kotlin.math.abs fun main() { data class Signal(val sensor: Point, val beacon: Point) { fun getDistance(): Int { return abs(sensor.x - beacon.x) + abs(sensor.y - beacon.y) } } fun parse(input: List<String>): List<Signal> { val regex = """Sensor at x=(-?\d+), y=(-?...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
2,805
aoc2022
Apache License 2.0
src/Day07.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
private interface Node { fun dirSize(): Int } private data class Dir(val name: String, val parent: Dir?) : HashMap<String, Node>(), Node { private var dirSize = -1 override fun dirSize(): Int { if (dirSize == -1) { dirSize = values.sumOf { it.dirSize() } } return dirSize...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
3,611
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/startat/aoc2023/Day5.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 data class SparseMapping(val srcStart : Long, val destStart : Long, val length : Long){ val sourceRange = srcStart..<srcStart+length } data class SparseRangeMap(val from : String, val to: String, private val mappings : MutableList<SparseMapping> = mutableListOf()){ fun addMappings(s...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
10,260
AOC2023
Creative Commons Zero v1.0 Universal
src/Day09.kt
petoS6
573,018,212
false
{"Kotlin": 14258}
import java.lang.Math.abs import kotlin.math.sign data class P(val x: Int, val y: Int) private fun P.isCloseTo(other: P) = (x == other.x && y == other.y) || (x == other.x + 1 && y == other.y) || (x == other.x - 1 && y == other.y) || (x == other.x && y == other.y + 1) || (x == other.x && y =...
0
Kotlin
0
0
40bd094155e664a89892400aaf8ba8505fdd1986
2,686
kotlin-aoc-2022
Apache License 2.0
src/Day02.kt
Maririri
572,844,816
false
null
fun main() { // A = X = 1 for Rock, B = Y = 2 for Paper, and C = Z = 3 for Scissors // 0 - you lost, 3 - draw, and 6 - you won // A - X(1) = 1 + 3 = 4 // A - Y(2) = 2 + 6 = 8 // A - Z(3) = 3 + 0 = 3 // B - X(1) = 1 + 0 = 1 // B - Y(2) = 2 + 3 = 5 // B - Z(3) = 3 + 6 = 9 // C + X(1) =...
0
Kotlin
0
0
ffda30a2c538ef1cb1e15cac14d424f807727769
1,678
AdventOfCode2022
Apache License 2.0
src/Day03.kt
jsebasct
572,954,137
false
{"Kotlin": 29119}
fun main() { fun getPriority(letter: Char): Int { return if (letter.isLowerCase()) { val range = 'a'..'z' val res = range.indexOfFirst { letter == it } res + 1 } else { val range = 'A'..'Z' val res = range.indexOfFirst { letter == it } ...
0
Kotlin
0
0
c4a587d9d98d02b9520a9697d6fc269509b32220
2,977
aoc2022
Apache License 2.0
src/Day02.kt
aaronbush
571,776,335
false
{"Kotlin": 34359}
sealed class RpsPlay(val points: Int) { companion object { fun of(s: String): RpsPlay { return when (s) { "A" -> ROCK "X" -> ROCK "B" -> PAPER "Y" -> PAPER "C" -> SCISSORS "Z" -> SCISSORS ...
0
Kotlin
0
0
d76106244dc7894967cb8ded52387bc4fcadbcde
3,181
aoc-2022-kotlin
Apache License 2.0
src/Day14.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
import java.awt.Point fun main() { val pointPattern = Regex("(\\d+),(\\d+)") class Line(def: String) { val points: List<Point> init { this.points = def.split(" -> ").map { val (x, y) = pointPattern.find(it)!!.destructured Point(x.toInt(), y.toInt())...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
2,579
advent_of_code_2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day09.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.Permutations import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 9: All in a Single Night](https://adventofcode.com/2015/day/9). */ object Day09 { @JvmStatic fun main(args: Array<String>) { measure { ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,614
advent-of-code
MIT License
jvm/src/main/kotlin/io/prfxn/aoc2021/day23.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Amphipod (https://adventofcode.com/2021/day/23) package io.prfxn.aoc2021 fun main() { val pods = ('A'..'D').toList() val energiesByPod = pods.asSequence().zip(generateSequence(1) { it * 10 }).toMap() fun readInput(lines: Sequence<String>): Map<CP, Char> { val coi = pods.toSet() + '.' ...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
7,752
aoc2021
MIT License
src/day12/Day12.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day12 import readInput import java.lang.Math.abs import java.util.* class Graph { val nodes: MutableSet<Node> = HashSet() fun findByKey(key: String) = nodes.find { it.key == key }!! } class Node( val key: String, val elevation: Int, val isStart: Boolean, val isEnd: Boolean ) { var...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
4,177
advent-of-code-2022
Apache License 2.0
src/Day12.kt
bjornchaudron
574,072,387
false
{"Kotlin": 18699}
fun main() { fun part1(input: List<String>): Int { val grid = input.flatMapIndexed { y, line -> line.mapIndexed { x, c -> Point(x, y) to c } }.toMap() return findShortestPath(grid, goal = 'S') } fun part2(input: List<String>): Int { val grid = input.flatMapIndexed { y, line -> line....
0
Kotlin
0
0
f714364698966450eff7983fb3fda3a300cfdef8
1,796
advent-of-code-2022
Apache License 2.0
src/Day12.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
fun main() { fun findFirstOrNull(input: List<String>, target: Char): Coord? { for (i in input.indices) { for (j in input[i].indices) { when (input[i][j]) { target -> return Coord(j, i) } } } return null } ...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
3,687
AoC2022
Apache License 2.0
src/day11/Day11.kt
PoisonedYouth
571,927,632
false
{"Kotlin": 27144}
package day11 import readInput data class Monkey( val index: Int, val items: MutableList<Long>, val worryOperation: (Long) -> Long, val throwOperation: (Long) -> Int, val divisor: Int, var inspections: Long = 0 ) { companion object { fun from(input: List<String>): Monkey { ...
0
Kotlin
1
0
dbcb627e693339170ba344847b610f32429f93d1
3,301
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
fun main() { fun part1(input: List<String>): Int { return input .asSequence() .map { it.split(" ") } .map { Pair(RockPaperScissors.fromABCSyntax(it[0]), RockPaperScissors.fromXYZSyntax(it[1])) } .map { it.second.totalScore(it.first) } .sum() } ...
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
2,656
adventofcode-2022
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day3.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser const val SYMBOL = -1 const val NOTHING = -2 const val GEAR = -3 object EngineSchematicParser : InputParser<List<MutableList<Int>>> { override fun pars...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
3,444
aoc-2023
The Unlicense
src/Day02.kt
armatys
573,477,313
false
{"Kotlin": 4015}
fun main() { fun part1(input: List<String>): Int { return input.fold(0) { acc, line -> val figures = line.split(" ", limit = 2).toPair(String::toFigure, String::toFigure) acc + figures.matchScore() } } fun part2(input: List<String>): Int { return input.fold(0...
0
Kotlin
0
0
95e93f7e10cbcba06e2ef88c1785779fbaa7c90f
2,405
kotlin-aoc-2022
Apache License 2.0
src/day5/Day05.kt
MatthewWaanders
573,356,006
false
null
package day5 import utils.readInput import java.util.Stack fun main() { val testInput = readInput("Day05_test", "day5") check(part1(testInput) == "CMZ") val input = readInput("Day05", "day5") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): String { val (stacks, ...
0
Kotlin
0
0
f58c9377edbe6fc5d777fba55d07873aa7775f9f
2,090
aoc-2022
Apache License 2.0
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day08.kt
JamJaws
725,792,497
false
{"Kotlin": 30656}
package com.jamjaws.adventofcode.xxiii.day import com.jamjaws.adventofcode.xxiii.readInput import java.math.BigInteger class Day08 { fun part1(text: List<String>): Long { val path = text.first() val nodes = parseNodes(text) return getNumberOfStepsUntil("AAA", path, nodes) { node -> node =...
0
Kotlin
0
0
e2683305d762e3d96500d7268e617891fa397e9b
1,915
advent-of-code-2023
MIT License
y2020/src/main/kotlin/adventofcode/y2020/Day04.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day04.solve() object Day04 : AdventSolution(2020, 4, "Passport Processing") { override fun solvePartOne(input: String): Int { val keys = listOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid") return input ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,868
advent-of-code
MIT License
src/Day12.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun setupGrid(input: List<String>, grid: MutableMap<Coordinates, GridPosition>): Pair<Coordinates, Coordinates> { var start = Coordinates(-1,-1) var end = Coordinates(-1,-1) for(row in input.indices) { for(col in input[0].indices) { val height = when...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
3,319
aoc2022
Apache License 2.0
src/day07/Day07.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day07 import java.io.File fun main() { val data = parse("src/day07/Day07.txt") println("🎄 Day 07 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private data class Hand( val cards:...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
2,576
advent-of-code-2023
MIT License
src/Day11.kt
Totwart123
573,119,178
false
null
import kotlin.math.round fun main() { class Monkey( val number: Int, val items: MutableList<Long>, val operation: String, val operationValue: String, val test: Int, val testTrue: Int, val testFalse: Int, var itemsInspected: Long = 0 ) { ov...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
4,999
AoC
Apache License 2.0
src/main/kotlin/adventofcode2022/solution/day_12.kt
dangerground
579,293,233
false
{"Kotlin": 51472}
package adventofcode2022.solution import adventofcode2022.util.readDay import java.util.Objects import java.util.PriorityQueue fun main() { Day12("12").solve() } class Day12(private val num: String) { private val inputText = readDay(num) fun solve() { println("Day $num Solution") printl...
0
Kotlin
0
0
f1094ba3ead165adaadce6cffd5f3e78d6505724
4,732
adventofcode-2022
MIT License
solutions/src/Day13.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val packetPairs = input.split { it.isBlank() }.map { it[0] to it[1] } return packetPairs.mapIndexed { index, (packet1, packet2) -> val (packet1List, packet2List) = parseToLists(packet1, packet2) if (co...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
4,154
advent-of-code-22
Apache License 2.0
src/day07/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day07 import println import readInput import kotlin.math.pow enum class HandType(val weight: Int, val sequencePattern: List<Int>) { FIVE_OF_A_KIND(7, listOf(5)), FOUR_OF_A_KIND(6, listOf(4, 1)), FULL_HOUSE(5, listOf(3, 2)), THREE_OF_A_KIND(4, listOf(3, 1, 1)), TWO_PAIR(3, listOf(2, 2, 1)),...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
3,542
advent-of-code-2023
Apache License 2.0
src/main/kotlin/com/staricka/adventofcode2023/days/Day5.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day import java.util.TreeMap import kotlin.math.min data class Mapping(val destinationStart: Long, val sourceStart: Long, val length: Long) { fun inRange(value: Long): Boolean = value >= sourceStart && value < sourceStart + ...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
5,380
adventOfCode2023
MIT License
kotlin/2021/round-1a/prime-time/src/main/kotlin/OldSimplerSolution.kts
ShreckYe
345,946,821
false
null
import kotlin.math.E import kotlin.math.exp import kotlin.math.pow fun main() { val t = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val m = readLine()!!.toInt() val pns = List(m) { val lineInputs = readLine()!!.split(' ') Pn(lineInputs[0].toInt(), lineInputs[1]...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,167
google-code-jam
MIT License
src/Day02.kt
aemson
577,677,183
false
{"Kotlin": 7385}
import GameChoices.ROCK import GameChoices.PAPER import GameChoices.SCISSORS fun main() { val inputData = readInput("Day02_input") val rock = GameOption( choice = ROCK, choicePoint = 1, firstPlayerChoice = 'A', secondPlayerChoice = 'X', winOve...
0
Kotlin
0
0
ffec4b848ed5c2ba9b2f2bfc5b991a2019c8b3d4
3,420
advent-of-code-22
Apache License 2.0
src/main/kotlin/be/seppevolkaerts/day2/Day2.kt
Cybermaxke
727,453,020
false
{"Kotlin": 35118}
package be.seppevolkaerts.day2 import kotlin.math.max class Game( val id: Int, val sets: List<CubeSet> ) class CubeSet( val cubes: Map<String, Int> ) fun parseGame(string: String): Game { val idAndSets = string.split(':', limit = 2) val id = idAndSets[0].replace("Game ", "").toInt() val sets = idAndSets...
0
Kotlin
0
1
56ed086f8493b9f5ff1b688e2f128c69e3e1962c
1,536
advent-2023
MIT License
src/Day04.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { // "2-4,6-8" // [[2-4],[6-8]] // [[2,3,4],[6,7,8]] fun parseInput(input: List<String>) = input .map { p -> p.split(',') } .map { (r1, r2) -> listOf(r1.toRange(), r2.toRange()).sortedBy { it.size } } fun part1(input: List<String>): Int { return parseIn...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
1,188
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Main.kt
NiksonJD
628,972,288
false
null
package processor import kotlin.math.pow fun input(prompt: String) = println(prompt).run { readln() } fun inputList(prompt: String) = input(prompt).split(" ").map { it.toInt() } val inputListDouble = { readln().split(" ").map { it.toDouble() } } val menuMap = mapOf( "1" to ::addMatrices, "2" to ::multiplyByCons...
0
Kotlin
0
0
823db67ed40be631865b53233dfd71dad72b32c4
3,821
Kotlin_NumericMatrixProcessor
Apache License 2.0
src/main/kotlin/day10/solver.kt
derekaspaulding
317,756,568
false
null
package day10 import java.io.File fun buildJoltageAdapterChain(joltages: List<Int>) = joltages.sorted() fun solveFirstProblem(joltages: List<Int>): Int { val chain = buildJoltageAdapterChain(joltages) var oneJoltDifferences = 0 // There is always a final 3 jolt difference from the end of the chain to the...
0
Kotlin
0
0
0e26fdbb3415fac413ea833bc7579c09561b49e5
2,274
advent-of-code-2020
MIT License
src/y2015/Day02.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput object Day02 { private fun parse(input: List<String>): List<Triple<Int, Int, Int>> { return input.map { it.split('x').map { it.toInt() } }.map { Triple(it.first(), it.last(), it[1]) } } fun part1(input: List<String>): Long { val pars...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,458
advent-of-code
Apache License 2.0
src/Day13.kt
cagriyildirimR
572,811,424
false
{"Kotlin": 34697}
fun day13Part1() { val input = readInput("Day13") var count = 0 for (i in input.indices step 3) { if (compare2(input[i], input[i + 1])) count += (1 + i / 3) } println(count) } fun compare2(left: String, right: String): Boolean { val (l, ls) = firstAndRest(left) val (r, rs) = firstAn...
0
Kotlin
0
0
343efa0fb8ee76b7b2530269bd986e6171d8bb68
1,452
AoC
Apache License 2.0
src/main/kotlin/Day12.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
import kotlin.math.min typealias Distance = Int fun main() { data class Node(val x: Int, val y: Int) { var height: Int? = null var n: Node? = null var e: Node? = null var s: Node? = null var w: Node? = null var distance: Distance = Distance.MAX_VALUE } fun ...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
4,010
aoc-2022
Apache License 2.0
src/Day12.kt
realpacific
573,561,400
false
{"Kotlin": 59236}
import java.util.* private data class Step(val position: Coordinate) { fun generateNextSteps(heightmap: Array<Array<Char>>): List<Step> { return arrayOf( Step(this.position.first + 1 to this.position.second), Step(this.position.first - 1 to this.position.second), Step(th...
0
Kotlin
0
0
f365d78d381ac3d864cc402c6eb9c0017ce76b8d
4,794
advent-of-code-2022
Apache License 2.0
src/Day09.kt
Miguel1235
726,260,839
false
{"Kotlin": 21105}
private fun obtainNewSequence(sequence: List<Int>): List<Int> { val newSequence: List<Int> = mutableListOf() for (i in 1..<sequence.size) { val curr = sequence[i] val prev = sequence[i - 1] newSequence.addLast(curr - prev) } return newSequence } private val string2IntList = { in...
0
Kotlin
0
0
69a80acdc8d7ba072e4789044ec2d84f84500e00
2,289
advent-of-code-2023
MIT License
src/Day04.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
fun main() { fun sectionsToInterval(sections: String): IntRange { val split = sections.split("-") return when { split.size > 1 -> IntRange(split[0].toInt(), split[1].toInt()) else -> IntRange(sections.toInt(), sections.toInt()) } } fun isOverlapping(rangeA:...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
1,637
AoC2022
Apache License 2.0
2022/src/main/kotlin/day8_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.Solution import utils.Vec2i import utils.takeWhileInclusive fun main() { Day8Imp.run() } object Day8Imp : Solution<IntGrid>() { override val name = "day8" override val parser = IntGrid.singleDigits override fun part1(input: IntGrid): Int { val rows = input.rows.flatMap {...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,641
aoc_kotlin
MIT License
src/Day16.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
data class Room(val rate: Int, val dest: List<String>) fun main() { val leftMatcher = "Valve\\s(?<valve>\\w{2}).+rate=(?<rate>\\d+)".toRegex() fun parse(input: List<String>): Map<String, Room> { val tunnelsMap = mutableMapOf<String, Room>() for (line in input) { val (left, right) ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,530
aoc2022
Apache License 2.0
src/day05/Day05.kt
skokovic
573,361,100
false
{"Kotlin": 12166}
package day05 import readInputText val moveRegex = """move\s+(\d+)\s+from\s+(\d+)\s+to\s+(\d+)""".toRegex() data class Move(val count: Int, val from: Int, val to: Int) fun createStacks(str: String): Map<Int, ArrayDeque<Char>> { val lines = str.lines() val stackNums = lines[lines.size - 1].trim().split("\\s+...
0
Kotlin
0
0
fa9aee3b5dd09b06bfd5c232272682ede9263970
2,231
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day19/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day19 import java.io.File import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis typealias ResourcePile = Map<Resource, Int> enum class Resource(val priority: Int) { ORE(0), CLAY(1), OBSIDIAN(2), GEODE(3) } class Blueprint(val id: Int, val r...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
7,408
advent-of-code-2022
Apache License 2.0
src/Day02_first.kt
ChristianNavolskyi
573,154,881
false
{"Kotlin": 29804}
import kotlin.time.ExperimentalTime import kotlin.time.measureTime enum class Weapon(val opponent: Char, val me: Char, val value: Int) { ROCK('A', 'X', 1), PAPER('B', 'Y', 2), SCISSORS('C', 'Z', 3); companion object { private val opponentMap: Map<Char, Weapon> = mapOf(Pair('A', ROCK), Pair('B', PAPER)...
0
Kotlin
0
0
222e25771039bdc5b447bf90583214bf26ced417
2,114
advent-of-code-2022
Apache License 2.0
src/Day15.kt
dizney
572,581,781
false
{"Kotlin": 105380}
import kotlin.math.abs object Day15 { const val EXPECTED_PART1_CHECK_ANSWER = 26 const val EXPECTED_PART2_CHECK_ANSWER = 56000011L const val PART1_CHECK_ROW = 10 const val PART1_ROW = 2_000_000 const val PART2_CHECK_MAX = 20 const val PART2_MAX = 4_000_000 const val PART2_MULTIPLY_VALUE = ...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
5,153
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day15.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day15 { fun part1(input: String): Int = input .split(',', '\n') .filter { it.isNotEmpty() } .sumOf { getHash(it) } fun part2(input: String): Int { val lensHashMap = IntRange(0, 255).map { mutableListOf<Pair<String, Int>>() }.toMutableList() val ins...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
1,877
advent-of-code-2023
MIT License
src/main/kotlin/com/sk/set0/56. Merge Intervals.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set0 import java.util.LinkedList import java.util.Stack class Solution56 { fun merge(intervals: Array<IntArray>): Array<IntArray> { if (intervals.isEmpty()) return emptyArray() intervals.sortBy { it[0] } // sort with start time val result = ArrayList<IntArray>() for ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
3,809
leetcode-kotlin
Apache License 2.0
src/Day04.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun main() { fun part1(input: List<String>): Int { return input.map { it.split(",") }.map { var firstElf = it[0].split("-") var secondElf = it[1].split("-") (firstElf[0].toInt()..firstElf[1].toInt()) to (secondElf[0].toInt()..secondElf[1].toInt()) ...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
1,559
advent-2022
Apache License 2.0
src/Day13.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
fun main() { /** * Custom compare to compare nested arrays based on the integers in them. */ fun compareFn(left: Any, right: Any): Int { // both integers if (left is Int && right is Int) return left.compareTo(right) // both lists if (left is List<*> && right is List<*>...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
1,797
aoc-2022-in-kotlin
Apache License 2.0
src/day04/Day04.kt
TheRishka
573,352,778
false
{"Kotlin": 29720}
package day04 import readInput import kotlin.math.max import kotlin.math.min fun main() { /* // min(7, 8) <= min(24, 8) = true // actually true min(2, 37) <= min(75, 51) = true // actually true min(47,20) <= min(78, 39) // approach 1 min(24, 8) - max(7, 8) = 8 - 8 = 0 min(75, 51) -...
0
Kotlin
0
1
54c6abe68c4867207b37e9798e1fdcf264e38658
2,097
AOC2022-Kotlin
Apache License 2.0
src/Day09.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun isEnd(head: Pair<Int, Int>, tail: Pair<Int, Int>): Boolean { return head.first - 1 <= tail.first && head.first + 1 >= tail.first && head.second - 1 <= tail.second && head.second + 1 >= tail.second } fun step(head: Pair<Int, Int>, tail: Pair<Int, Int>): Pair<Int, Int> { val ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
2,869
advent-of-code-2022
Apache License 2.0
src/Day03.kt
Misano9699
572,108,457
false
null
fun main() { fun splitInTwo(rucksack: String): List<Set<Char>> = listOf(rucksack.take(rucksack.length / 2).toSet(), rucksack.takeLast(rucksack.length / 2).toSet()) fun priority(item: Char): Int = when { item.isLowerCase() -> item.code - 96 // lowercase a starts at 97 in ASCII table els...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
1,273
advent-of-code-2022
Apache License 2.0
Algorithms/src/main/kotlin/LargestPalindromicNumber.kt
ILIYANGERMANOV
557,496,216
false
{"Kotlin": 74485}
/** * # Largest Palindromic Number * Problem: * https://leetcode.com/problems/largest-palindromic-number/ */ class LargestPalindromicNumber { fun largestPalindromic(num: String): String { val digits = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) for (c in num) { val digit = c.digitToI...
0
Kotlin
0
1
4abe4b50b61c9d5fed252c40d361238de74e6f48
2,857
algorithms
MIT License
src/Day07.kt
kmakma
574,238,598
false
null
fun main() { fun buildFileSystem(input: List<String>): Directory { val root = Directory(null, "/") var currentDir: Directory = root val iter = input.iterator() while (iter.hasNext()) { val line = iter.next() when { line == "$ cd /" -> current...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
3,009
advent-of-kotlin-2022
Apache License 2.0
2021/app/src/main/kotlin/net/sympower/aok2021/tonis/Day03.kt
tonisojandu
573,036,346
false
{"Rust": 158858, "Kotlin": 15806, "Shell": 1265}
package net.sympower.aok2021.tonis fun main() { println("1st: ${day03Part01("/Day03.in")}") println("2nd: ${day03Part02("/Day03.in")}") } fun day03Part01(fileIn: String): Int { val numbers = readLineFromResource(fileIn) { it } val threshold = numbers.size / 2 val overThreshold = numbers .map { it.toCha...
0
Rust
0
0
5ee0c3fb2e461dcfd4a3bdd7db3efae9a4d5aabd
2,422
to-advent-of-code
MIT License
src/main/kotlin/utils/rangeUtils.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package utils /** * This will return a range that combine the 2 range. * It may result in one or more items since the 2 ranges may not overlap. * The assumption is that ranges have an end that is the same or a higher value than the start. */ fun IntRange.intersect(r: IntRange): List<IntRange> { val minR = if (fi...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
2,517
aoc-2022-in-kotlin
Apache License 2.0
src/day21/Day21.kt
gautemo
317,316,447
false
null
package day21 import shared.getLines fun nonAllergensCount(input: List<String>): Int{ val foods = toAllergenInIngredient(input) val allergens = mutableSetOf<String>() val ingredients = mutableSetOf<String>() foods.forEach { allergens.addAll(it.allergens) ingredients.addAll(it.ingredien...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
2,582
AdventOfCode2020
MIT License
src/Day08.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
fun <T> Iterable<T>.takeUntil(predicate: (T) -> Boolean): Iterable<T> { var shouldContinue = true return takeWhile { val result = shouldContinue shouldContinue = !predicate(it) result } } fun main() { fun part1(input: List<String>): Int { val width = input[0].length ...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
2,219
2022-Advent-of-Code
Apache License 2.0
src/Day05.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
fun main() { fun part1(input: List<String>): String { val stacks = input.initialStackValues input.moveLines.forEach { line -> stacks.doMove9000(line) } return stacks.entries.sortedBy { it.key }.map { it.value.last() }.joinToString("") } fun part2(input: List<Str...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
2,365
advent-of-code-2022
Apache License 2.0
solutions/aockt/y2023/Y2023D15.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D15 : Solution { /** * A lens boxing operation. * @property label The label of the lens to apply the operation on. * @property box The ID of the box the operation should be performed in. */ ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,109
advent-of-code-kotlin-solutions
The Unlicense
src/day2/Day02.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day2 import readInput fun main() { fun parseInput(input: List<String>) = input.map { it.split(" ") } fun part1(input: List<String>): Int { val data = parseInput(input) val shapeScores = mapOf(Pair("X", 1), Pair("Y", 2), Pair("Z", 3)) val scores = mapOf( Pair(listOf...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
2,030
aoc-2022
Apache License 2.0
src/main/kotlin/twentytwentytwo/Day11.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import java.math.BigInteger fun main() { val input = {}.javaClass.getResource("input-11.txt")!!.readText().split("\n\n"); val day = Day11(input) println(day.part1()) println(day.part2()) } class Day11(private val input: List<String>) { fun part1(): Long { val monke...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
3,278
aoc202xkotlin
The Unlicense
src/day07/Day07.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day07 import readInput import readTestInput import java.nio.file.Path import kotlin.io.path.Path import kotlin.io.path.div private fun List<String>.toFileIndex(): Map<Path, Int> { var path = Path("/") val fileIndex = mutableMapOf<Path, Int>() for (line in this) { if (line.startsWith("$ cd...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
2,792
advent-of-code-kotlin-2022
Apache License 2.0
src/Day18.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
class Coord3(val x: Int, val y: Int, val z: Int) { private val delta = listOf(-1, 1) val neighbours: List<Coord3> get() { val result = MutableList(0) { Coord3(0, 0, 0) } for (d in delta) { result.add(Coord3(x + d, y, z)) result.add(Coord3(x, y + d, z)) result.add(Coord3(x, y,...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
2,182
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day02.kt
mvanderblom
573,009,984
false
{"Kotlin": 25405}
val ROCK = 1 val PAPER = 2 val SCICCORS = 3 val LOSS = 0 val TIE = 3 val WIN = 6 val inputMapping = mapOf( "A" to ROCK, "B" to PAPER, "C" to SCICCORS ) fun <K, V> Map<K, V>.pivot(): Map<V, List<K>> = this.entries.groupBy({it.value}, {it.key}) fun <K, V> List<Pair<K, V>>.toMap(): Map<K, V> = t...
0
Kotlin
0
0
ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690
2,176
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/solutions/constantTime/iteration4/GCDTaxCalculator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package solutions.constantTime.iteration4 import dataModel.base.Money import dataModel.base.Money.Companion.cents import dataModel.base.TaxBracket import dataModel.base.TaxCalculator import solutions.constantTime.iteration3.MemorizedBracketTaxCalculator import dataModel.v2.AccumulatedTaxBracket import dataModel.v2.toA...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
2,728
tax-calculator
MIT License
src/Day07.kt
6234456
572,616,769
false
{"Kotlin": 39979}
data class Node(val name:String, val value: Int = -1, val children: MutableList<Node> = mutableListOf<Node>()){ fun size():Int{ if (!isDir()) return value return children.fold(0){acc, node -> acc + node.size() } } fun isDir():Boolean = value < 0 } fun main() { fun buildTree(input: List...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
2,402
advent-of-code-kotlin-2022
Apache License 2.0