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/questions/DegreeOfAnArray.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. * Your task is to find the smallest possible length of a (contiguou...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,315
algorithms
MIT License
src/Day04.kt
davedupplaw
573,042,501
false
{"Kotlin": 29190}
fun main() { fun part1(input: List<String>): Int { return input .asSequence() .map { it.split(",", "-").map { x -> x.toInt() } } .map { listOf(it[0]..it[1], it[2]..it[3]) } .filter { (it[1].first in it[0] && it[1].last in it[0]) || ...
0
Kotlin
0
0
3b3efb1fb45bd7311565bcb284614e2604b75794
1,212
advent-of-code-2022
Apache License 2.0
src/Day07.kt
kthun
572,871,866
false
{"Kotlin": 17958}
class Folder( val name: String, val subFolders: MutableMap<String, Folder> = mutableMapOf(), var parent: Folder? = null, var myFiles: MutableList<MyFile> = mutableListOf() ) { fun addSubFolder(folder: Folder) { subFolders[folder.name] = folder folder.parent = this folders[fol...
0
Kotlin
0
0
5452702e4e20ef2db3adc8112427c0229ebd1c29
3,253
aoc-2022
Apache License 2.0
src/Day12.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
import java.util.* fun main() { class Node( val height: Int, val neighbors: MutableSet<Node> = mutableSetOf(), ) : Comparable<Node> { var distance = Int.MAX_VALUE override fun compareTo(other: Node) = distance.compareTo(other.distance) } fun convertHeight(height: Char)...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
3,404
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dk/lessor/Day11.kt
aoc-team-1
317,571,356
false
{"Java": 70687, "Kotlin": 34171}
package dk.lessor val chairs: (Char) -> Int = { if (it == '#') 1 else 0 } fun main() { val map = readFile("day_11.txt").map { it.toList() } println(gameOfChairs(map)) println(gameOfVisibleChairs(map)) } fun gameOfChairs(chairMap: List<List<Char>>): Int { var oldMap = chairMap.map { it.toMutableList()...
0
Java
0
0
48ea750b60a6a2a92f9048c04971b1dc340780d5
3,263
lessor-aoc-comp-2020
MIT License
src/Day03.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
fun main() { fun Char.toPriority(): Int { return when { this.isLowerCase() -> this - 'a' + 1 else -> this - 'A' + 27 } } fun String.toPriorities() = this.toCharArray().map { it.toPriority() }.toSet() fun getErrorPriority(rucksack: String): Int { val comp...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
1,196
kotlin_aoc_22
Apache License 2.0
src/Day21.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private enum class Operator(val apply: (Long, Long) -> Long) { PLUS(Long::plus), MINUS(Long::minus), TIMES(Long::times), DIV(Long::div) } private sealed interface MonkeyNumber { data class Constant(val value: Long) : MonkeyNumber data class Operation(val monkey1: String, val monkey2: String, val operator:...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
3,891
advent-of-code-22
Apache License 2.0
15/src/main/kotlin/se/nyquist/PathFinder.kt
erinyq712
437,223,266
false
{"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098}
package se.nyquist import java.io.File import java.util.* fun main() { val lines = File("input.txt").readLines() exercise1(lines) exercise2(lines) } private fun exercise1(lines: List<String>) { val map = lines.map { it.toCharArray().map { c -> c.digitToInt() }.toTypedArray() }.toTypedArray() val ...
0
Kotlin
0
0
b463e53f5cd503fe291df692618ef5a30673ac6f
3,763
adventofcode2021
Apache License 2.0
src/Day12.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private sealed interface Point : Comparable<Point> { val elevation: Int override fun compareTo(other: Point): Int = elevation.compareTo(other.elevation) } private object StartPoint : Point { override val elevation: Int get() = 0 override fun toString(): String = "S" } private object EndPoint...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
4,063
advent-of-code-22
Apache License 2.0
src/Day11.kt
tsschmidt
572,649,729
false
{"Kotlin": 24089}
import kotlin.math.floor data class Item(var worry: Long) class Monkey { var id: Int = 0 var items = mutableListOf<Item>() lateinit var opValue: (Long) -> Long var divisibleBy: Long = 0 var divTrue: Int = 0 var divFalse: Int = 0 var inspected = 0L companion object { fun pa...
0
Kotlin
0
0
7bb637364667d075509c1759858a4611c6fbb0c2
2,955
aoc-2022
Apache License 2.0
2021/src/main/kotlin/day21.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.mapItems fun main() { Day21.run() } object Day21 : Solution<Day21.State>() { override val name = "day21" override val parser = Parser.lines .mapItems { it.split(":").last().trim() } .map { State( true, it.first().toInt() - 1, ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,467
aoc_kotlin
MIT License
src/Day08.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
fun main() { fun part1(input: List<String>): Int { val rows = input.size val columns = input.first().length val field = Array(rows) { IntArray(columns) } input.forEachIndexed() { rowIndex, row -> row.forEachIndexed() { columnIndex, column -> field[rowIn...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
2,695
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2016/day4/GetARoom.kt
arnab
75,525,311
false
null
package aoc2016.day4 data class Room(val encryptedName: String, val sectorId: Int, val checkSum: String) { val name: String by lazy { decryptName() } val computedCheckSum: String by lazy { computeCheckSum() } private fun decryptName(): String = encryptedName .split("-") ....
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,382
adventofcode
MIT License
src/Day16.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File import java.util.* import kotlin.math.max import kotlin.system.measureTimeMillis // Advent of Code 2022, Day 16, Proboscidea Volcanium data class ValveData(val name: String, val index: Int, val rate: Int, val tunnels: List<String>) data class State(val currLocn: ValveData, val time: Int, val tot...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
11,066
AdventOfCode2022
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day12.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution object Day12 : AdventSolution(2018, 12, "Subterranean Sustainability") { override fun solvePartOne(input: String): Int { val (initial, rules) = parse(input) val g = 20 return generateSequence(initial) { ("....$it....").windo...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,608
advent-of-code
MIT License
src/main/kotlin/com/hjk/advent22/Day14.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 object Day14 { fun part1(input: List<String>): Int = process(toRocks(input)) fun part2(input: List<String>): Int = toRocks(input).let { rocks -> val floor = Point2d(x = 0, y = rocks.maxOf { it.y } + 2) rocks.fold(Int.MAX_VALUE to Int.MIN_VALUE) { (min, max), rock -> ...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
2,105
advent22
Apache License 2.0
src/day09/Day09.kt
henrikrtfm
570,719,195
false
{"Kotlin": 31473}
package day09 import utils.Resources.resourceAsListOfString typealias Point = Pair<Int, Int> fun main(){ val tailNeighbors = sequenceOf(-1 to 0, 0 to -1, 0 to 1, 1 to 0, -1 to 1, -1 to -1, 1 to 1, 1 to -1) val headNeighbours = sequenceOf(-1 to 0, 0 to -1, 0 to 1, 1 to 0) val diagonals = sequenceOf(-1 to ...
0
Kotlin
0
0
20c5112594141788c9839061cb0de259f242fb1c
2,812
aoc2022
Apache License 2.0
src/day05/Day05.kt
skempy
572,602,725
false
{"Kotlin": 13581}
package day05 import readInputAsList data class CrateInstruction(val quantity: Int, val source: Int, val target: Int) fun main() { fun findStacksOfCrates( input: List<String>, ): MutableMap<Int, MutableList<Char>> { val stacks = mutableMapOf<Int, MutableList<Char>>() val stackPositio...
0
Kotlin
0
0
9b6997b976ea007735898083fdae7d48e0453d7f
2,872
AdventOfCode2022
Apache License 2.0
src/Day07.kt
remidu
573,452,090
false
{"Kotlin": 22113}
class Node(val name: String, var size: Int, val children: ArrayList<Node>, var parent: Node?) { fun addChild(name: String, size: Int) { this.size += size this.children.add(Node(name, size, ArrayList(), this)) } fun addChild(node: Node) { this.children.add(node) } } fun main() { ...
0
Kotlin
0
0
ecda4e162ab8f1d46be1ce4b1b9a75bb901bc106
2,597
advent-of-code-2022
Apache License 2.0
src/main/day03/Day03.kt
rolf-rosenbaum
543,501,223
false
{"Kotlin": 17211}
package day03 import readInput import second fun part1(input: List<String>): Int { val points = addClaims(input) return points.count { it.value.size > 1 } } private fun addClaims(input: List<String>): MutableMap<Point, MutableSet<Claim>> { val points = mutableMapOf<Point, MutableSet<Claim>>() input....
0
Kotlin
0
0
dfd7c57afa91dac42362683291c20e0c2784e38e
2,388
aoc-2018
Apache License 2.0
2022/src/main/kotlin/day16_attempt2.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.mapItems import utils.times fun main() { Day16A2.run() } object Day16A2 : Solution<List<Day16A2.Valve>>() { override val name = "day16" override val parser = Parser.lines .mapItems { it.replace("tunnel leads to valve", "tunnels lead t...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
4,292
aoc_kotlin
MIT License
2022/src/day15/day15.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day15 import GREEN import RESET import printTimeMillis import readInput import kotlin.math.* data class Point(val x: Long, val y: Long) data class Area(val center: Point, val dist: Long) { fun xRangeForY(yPos: Long): Range? { val sizeOfRange = dist - abs(center.y - yPos) val minX = center....
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,811
advent-of-code
Apache License 2.0
src/Day02.kt
hufman
573,586,479
false
{"Kotlin": 29792}
enum class Move(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3); companion object { fun fromStr(input: String): Move { return when(input) { "A" -> ROCK "B" -> PAPER "C" -> SCISSORS "X" -> ROCK "Y" -> PAPER "Z" -> SCISSORS else -> throw IllegalArgumentException(input) } } }...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
2,348
aoc2022-kt
Apache License 2.0
src/main/kotlin/dev/siller/aoc2022/Day08.kt
chearius
575,352,798
false
{"Kotlin": 41999}
package dev.siller.aoc2022 import kotlin.math.max private val example = """ 30373 25512 65332 33549 35390 """.trimIndent() private fun part1(input: List<String>): Int = input .flatMap { l -> l.toList().map { c -> c.digitToInt() } } .let { forest -> val height = input.size ...
0
Kotlin
0
0
e070c0254a658e36566cc9389831b60d9e811cc5
3,735
advent-of-code-2022
MIT License
src/Day08.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
fun main() { data class Pos(val row: Int, val column: Int) { fun moveLeft() = Pos(row, column - 1) fun moveRight() = Pos(row, column + 1) fun moveUp() = Pos(row - 1, column) fun moveDown() = Pos(row + 1, column) } class Forest(private val trees: List<String>) { val r...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
3,051
aoc2022
Apache License 2.0
kotlin/app/src/main/kotlin/coverick/aoc/day12/hillClimbing.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day12 import java.util.PriorityQueue import java.util.HashSet import readResourceFile val INPUT_FILE = "hillClimbing-input.txt" typealias Coordinate = Pair<Int,Int> class Hill(val heightMap:List<CharArray>, val startHeights: Set<Char>, val end:Char){ var startPos: HashSet<Coordinate> = Hash...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
3,817
adventofcode2022
Apache License 2.0
src/com/github/frozengenis/day2/Puzzle.kt
FrozenSync
159,988,833
false
null
package com.github.frozengenis.day2 import java.io.File import java.util.* fun main() { val boxes = File("""src\com\github\frozengenis\day2\input.txt""") .let(::parseToBoxes) val checksum = calculateChecksum(boxes) val commonLetters = findCommonLetters(boxes) StringBuilder("Advent of Code 20...
0
Kotlin
0
0
ec1e3472990a36b4d2a2270705253c679bee7618
2,543
advent-of-code-2018
The Unlicense
src/Day18.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
data class XYZ(val x: Int, val y: Int, val z: Int) fun getImmediateSurrounding(cube: XYZ): List<XYZ> { val rel = listOf(XYZ(-1, 0, 0), XYZ(1, 0, 0), XYZ(0, -1, 0), XYZ(0, 1, 0), XYZ(0, 0, -1), XYZ(0, 0, 1)) return rel.map { coordinate -> XYZ(cube.x + coordinate.x, cube.y + coordinate.y, cube.z + coordinate.z) ...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
1,541
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day11/day11.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day11 class Ferry(private var seats: List<String>, private val tolerance: Int, closeNeighbourhood: Boolean = true) { companion object { const val EMPTY = 'L' const val OCCUPIED = '#' } private val checker = when (closeNeighbourhood) { true -> CloseNeighbou...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
3,441
advent-of-code-2020
Do What The F*ck You Want To Public License
leetcode2/src/leetcode/unique-paths.kt
hewking
68,515,222
false
null
package leetcode import kotlin.math.max import kotlin.math.min /** * 62. 不同路径 * https://leetcode-cn.com/problems/unique-paths/ * 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? 例如,上图是一个7 x 3 的网格。有多少可能的路径? 说明:m 和 n 的值均不超过 100。 示例 1: 输入: m = 3, n =...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,784
leetcode
MIT License
src/y2015/Day06.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.getRange import util.printMatrix import util.readInput import kotlin.math.max data class Light(var on: Boolean = false, var brightness: Int = 0) { fun toggle() { on = !on } fun turnOn() { on = true } fun turnOff() { on = false } fun inc...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
2,803
advent-of-code
Apache License 2.0
src/day5/puzzle05.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day5 import Puzzle import PuzzleInput import java.io.File import java.lang.Integer.min import java.util.* import kotlin.math.max data class Move(val crate: Int, val from: Int, val to: Int) class Day5PuzzleInput(val stacks: List<Vector<Char>>, private val moves: String, expectedResult: String? = null) : Puzzl...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
2,827
aoc_2022
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day14/Day14.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,472
AdventOfCode
Apache License 2.0
src/Day15.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
import kotlin.math.abs fun main() { data class Beacon(val x: Int, val y: Int) data class Sensor(val x: Int, val y: Int, val beaconDist: Int) fun dist(x1: Int, y1: Int, x2: Int, y2: Int): Int { return abs(x1 - x2) + abs(y1 - y2) } fun parse(testInput: List<String>): List<List<Int>> = test...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
3,057
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day7.kt
bfrengley
318,716,410
false
null
package aoc2020.day7 import aoc2020.util.loadTextResource const val bagTypePattern = "([a-z]+ [a-z]+) bags?" val outerBagRegex = Regex(bagTypePattern) val innerBagRegex = Regex("(\\d+) $bagTypePattern") data class Rule(val outer: String, val inners: List<Pair<String, Int>>) fun main(args: Array<String>) { val r...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,176
aoc2020
ISC License
src/Day11.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
fun main() { val input = readInput("Day11") printTime { println(Day11.part1(input)) } printTime { println(Day11.part2(input)) } } class Day11 { companion object { fun part1(input: List<String>): Long { val monkeys = input.toMonkeys() monkeys.playKeepAway { it.floorDiv(3)...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
2,352
advent-of-code-22
Apache License 2.0
src/year2023/day14/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2023.day14 import year2023.solveIt fun main() { val day = "14" val expectedTest1 = 136L val expectedTest2 = 64L fun getColumn(chars: List<Char>): Long { var total = 0L var lastSupport = 0 for (index in chars.indices) { if (chars[index] == 'O') { ...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,525
adventOfCode
Apache License 2.0
src/main/kotlin/day03/engine.kt
cdome
726,684,118
false
{"Kotlin": 17211}
package day03 import java.io.File import kotlin.text.StringBuilder fun main() { val lines = File("src/main/resources/day03-engine").readLines() println("Sum of part numbers: ${engineSum(lines)}") println("Sum of gear ratios: ${gears(lines)}") } fun gears(lines: List<String>): Int { val emptyLine = "...
0
Kotlin
0
0
459a6541af5839ce4437dba20019b7d75b626ecd
3,268
aoc23
The Unlicense
y2017/src/main/kotlin/adventofcode/y2017/Day10.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution object Day10 : AdventSolution(2017, 10, "Knot Hash") { override fun solvePartOne(input: String): String { val lengths = input.split(",").map { it.toInt() } val list = knot(lengths) return (list[0] * list[1]).toString() } override fun solvePa...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,174
advent-of-code
MIT License
src/Day08.kt
maximilianproell
574,109,359
false
{"Kotlin": 17586}
fun main() { fun part1(input: TreeData): Int { val (trees, width, height) = input // That's the border of the map, which is always visible. val visibleEdge = width * 2 + height * 2 - 4 // Minus the corners var insideVisible = 0 val startIndex = width + 1 val endInde...
0
Kotlin
0
0
371cbfc18808b494ed41152256d667c54601d94d
2,832
kotlin-advent-of-code-2022
Apache License 2.0
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day08.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 object Day08 { fun numberOfVisibleTrees(input: String): Int { val trees = trees(input) return trees(input) .flatMap { (rowIndex, row) -> row.map { (columnIndex, tree) -> val hiddenFromTheLeft = row.take(c...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
2,935
advent-of-code
MIT License
src/y2023/Day19.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.split import util.timingStatistics object Day19 { data class MachinePart( val x: Int, val m: Int, val a: Int, val s: Int ) { fun rating(): Int = x + m + a + s } data class RuleResult( val accepted: Boolean...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
9,655
advent-of-code
Apache License 2.0
src/Day11.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
import java.util.function.Function fun main() { fun firstNumberFromString(s: String): Long? { return s.dropWhile { !it.isDigit() }.takeWhile { it.isDigit() }.toLongOrNull() } fun parseMonkeys(input: List<String>): List<Monkey> { val monkeys = input.splitWhen { it == "" } val monke...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
2,813
AdventOfCode2022
Apache License 2.0
src/Day02.kt
jandryml
573,188,876
false
{"Kotlin": 6130}
import java.security.InvalidParameterException private enum class GameMove(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); fun evaluateGameResult(otherPlayerMove: GameMove): GameResult = when { this == otherPlayerMove -> GameResult.TIE this == ROCK && otherPlayerMove == SCISSORS -> G...
0
Kotlin
0
0
90c5c24334c1f26ee1ae5795b63953b22c7298e2
2,774
Aoc-2022
Apache License 2.0
2023/src/day19/Day19.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day19 import java.io.File import java.lang.IllegalArgumentException fun main() { val input = File("src/day19/day19.txt").readLines() val workflowStrings = input.takeWhile { it.isNotEmpty() } val partStrings = input.takeLastWhile { it.isNotEmpty() } val workflows = getWorkflows(workflowStrings...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
4,372
adventofcode
Apache License 2.0
src/aoc2023/Day08.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun part1(lines: List<String>): Int { val steps = lines[0].map { if (it == 'R') 1 else 0 } val regex = "(\\w{3}) = \\((\\w{3}), (\\w{3})\\)".toRegex() val instructions = lines.subList(2, lines.size).map { val groups = regex.find(it...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
2,657
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/aoc2021/Day05.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2021 import aoc2022.parsedBy import aoc2022.takeWhilePlusOne import utils.InputUtils import kotlin.math.sign data class Coord(val x: Int, val y: Int) { // Unit in the direction of the other one fun directionTo(other: Coord): Coord = Coord(other.x - x, other.y - y).normalise() fun normalise() ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,045
aoc-2022-kotlin
Apache License 2.0
src/day07/Day07.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day07 import readInput private const val DAY_ID = "07" private sealed class Filesystem( open val name: String, open val parent: Directory? ) private data class File( override val name: String, val size: Int, override val parent: Directory? ) : Filesystem(name, parent) private data class...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
3,237
aoc-2022-in-kotlin
Apache License 2.0
src/Day11.kt
zirman
572,627,598
false
{"Kotlin": 89030}
import kotlin.system.measureTimeMillis data class Monkey( var items: MutableList<Long>, val operator: String, val operand: String, val divisibleBy: Long, val trueMonkey: Int, val falseMonkey: Int, var inspectedCount: Long, ) fun main() { fun parseMonkeys(input: List<String>): List<Monk...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
3,790
aoc2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2020/d16/Day16.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d16 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines private data class Rule(val fieldName: String, val validRanges: List<IntRange>) private fun Rule.validValue(value: Int): Boolean = validRanges.any { value in it } private fun sc...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,952
advent-of-code
MIT License
src/Day02.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import kotlin.math.max private const val EXPECTED_1 = 8 private const val EXPECTED_2 = 2286 private class Day02(isTest: Boolean) : Solver(isTest) { fun part1(): Any { var sum = 0 var id = 1 for (line in readAsLines()) { val parts = line.substringAfter(": ").split(";").map { it....
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,272
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2021/Day10.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2021 import utils.InputUtils import java.util.* fun main() { val testInput = """[({(<(())[]>[[{[]{<()<>> [(()[<>])]({[<{<<[]>>( {([(<{}[<>[]}>{[]{[(<()> (((({<>}<{<{<>}{[]{[]{} [[<[([]))<([[{}[[()]]] [{[{({}]{}}([{[{{{}}([] {<[[]]>}<{[{[{[]{()[[[] [<(<(<(<{}))><([]([]() <{([([[(<>()){}]>(<<{{ <{([{{}...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,422
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc23/Day04.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day04Domain.ScratchCards import aoc23.Day04Parser.toScratchCards import aoc23.Day04Solution.part1Day04 import aoc23.Day04Solution.part2Day04 import common.Year23 import kotlin.math.pow object Day04 : Year23 { fun List<String>.part1(): Int = part1Day04() fun List<String>.part2(): In...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
1,876
aoc
Apache License 2.0
src/Day14.kt
tomoki1207
572,815,543
false
{"Kotlin": 28654}
import kotlin.math.max import kotlin.math.min data class Cave(val input: List<String>) { data class CavePoint(val x: Int, val y: Int) private val cave: MutableSet<CavePoint> private val maxDepth: Int init { val cave = input.flatMap { line -> val points = line.split("->").map { poi...
0
Kotlin
0
0
2ecd45f48d9d2504874f7ff40d7c21975bc074ec
2,764
advent-of-code-kotlin-2022
Apache License 2.0
src/day03/Day03.kt
marcBrochu
573,884,748
false
{"Kotlin": 12896}
package day03 import readInput fun calculateItemPriority(item: Char): Int { return if(item.isUpperCase()) { item - 'A' + 27 } else if (item.isLowerCase()) { item - 'a' + 1 } else { 0 } } fun main() { fun part1(input: List<String>): Int { fun findDuplicateInRucksack...
0
Kotlin
0
2
8d4796227dace8b012622c071a25385a9c7909d2
1,650
advent-of-code-kotlin
Apache License 2.0
src/Day09.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
import kotlin.math.absoluteValue fun main() { fun getDirVector(vectorChar: Char): Pair<Int, Int> { return when (vectorChar) { 'U' -> Pair(0, 1) 'D' -> Pair(0, -1) 'L' -> Pair(-1, 0) 'R' -> Pair(1, 0) else -> throw IllegalArgumentException("Invali...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
2,834
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day12.kt
joostbaas
573,096,671
false
{"Kotlin": 45397}
data class Day12( private val start: Point, private val end: Point, private val grid: Map<Point, Char>, ) { companion object { fun day12Part1(input: List<String>): Int = input.parse().let { it.calculateShortestPathFromStartToEnd() } fun day12Part2(input: List<String>): Int = input.parse...
0
Kotlin
0
0
8d4e3c87f6f2e34002b6dbc89c377f5a0860f571
3,315
advent-of-code-2022
Apache License 2.0
advent-of-code-2022/src/Day02.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
/* Hints I've used to solve the puzzle: 1. We can map letter to a digit: choice = letter - 'A' // A -> 0, B -> 1, C -> 2 (the same logic may be applied to X, Y, Z) choiceScore = choice + 1 2. Order of symbols (Rock, Paper, Scissors) allows us to quickly understand round outcome. Next symbol always beat...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,324
advent-of-code
Apache License 2.0
2021/kotlin/src/main/kotlin/com/codelicia/advent2021/Day08.kt
codelicia
627,407,402
false
{"Kotlin": 49578, "PHP": 554, "Makefile": 293}
package com.codelicia.advent2021 class Day08(private val signals: List<String>) { data class SegmentMap( val map: Map<String, Int>, val decodedNumber: Int ) { companion object { private fun String.order() = this.split("").sortedDescending().joinToString(sepa...
2
Kotlin
0
0
df0cfd5c559d9726663412c0dec52dbfd5fa54b0
2,903
adventofcode
MIT License
src/main/kotlin/com/jacobhyphenated/advent2023/day7/Day7.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day7 import com.jacobhyphenated.advent2023.Day /** * Day 7: Camel Cards * * Camel is like poker but with its own rules on what cards win. * The puzzle input is a list of hands with a bet for each hand. * * The total score takes the weakest hand and multiplies the bet by 1,...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
4,843
advent2023
The Unlicense
src/Year2022Day08.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
private inline fun <T> Iterable<T>.countDoWhile(predicate: (T) -> Boolean): Int { var counter = 0 for (item in this) { counter++ if (!predicate(item)) return counter } return counter } fun main() { fun part1(input: List<String>): Int { val G = input.map { it.map { c -> c.di...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
2,025
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/phiber/aoc2022/day2/Solution.kt
rsttst
572,967,557
false
{"Kotlin": 7688}
package dev.phiber.aoc2022.day2 import dev.phiber.aoc2022.readAllLinesUntilEmpty enum class Outcome(val points: Int) { LOSS(0), TIE(3), WIN(6); companion object { fun forChar(char: Char) : Outcome = when (char) { 'X' -> LOSS 'Y' -> TIE 'Z' -> WIN else...
0
Kotlin
0
0
2155029ebcee4727cd0af75543d9f6f6ab2b8995
3,376
advent-of-code-2022
Apache License 2.0
src/Day10.kt
bananer
434,885,332
false
{"Kotlin": 36979}
import java.util.* fun main() { fun syntaxErrorScore(c: Char): Int = when (c) { ')' -> 3 ']' -> 57 '}' -> 1197 '>' -> 25137 else -> throw IllegalArgumentException() } fun part1(input: List<String>): Int { return input.sumOf { val stack = Stack<C...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
3,100
advent-of-code-2021
Apache License 2.0
src/Day07.kt
ktrom
573,216,321
false
{"Kotlin": 19490, "Rich Text Format": 2301}
import java.util.Scanner fun main() { // get directories smaller than given size fun getDirectories(input: List<String>, size: Int): Int { val root: Node = getSystemTree(input) return getDirectories(root, size, Condition.LESS_THAN).sumOf { it.size } } fun part1(input: List<String>): In...
0
Kotlin
0
0
6940ff5a3a04a29cfa927d0bbc093cd5df15cbcd
3,494
kotlin-advent-of-code
Apache License 2.0
src/day24/Day24.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day24 import java.io.File import java.util.* fun main() { val valley = Valley.parse(File("src/day24/input.txt").readLines()) val there = solve(valley, Valley.START, valley.finish) println(there.first) val back = solve(there.second, valley.finish, Valley.START) val thereAgain = solve(back.s...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
3,839
advent-of-code-2022
MIT License
src/Day03.kt
hoppjan
433,705,171
false
{"Kotlin": 29015, "Shell": 338}
fun main() { /** * Calculates binary [String] gamma and multiplies it with its inversion, epsilon. * @return decimal power consumption (product of gamma and epsilon) */ fun part1(input: List<String>): Int { val gamma = input.gammaString() val epsilon = gamma.invertBitString() ...
0
Kotlin
0
0
04f10e8add373884083af2a6de91e9776f9f17b8
2,226
advent-of-code-2021
Apache License 2.0
src/Day05.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
fun main() { fun String.parseStacks(stacks: HashMap<Int, ArrayList<Char>>) { chunkedSequence(4) .map { it .replace(Regex("[\\[\\]\\s]"), "") .firstOrNull() } .forEachIndexed { index, char -> if (cha...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
1,901
aoc-2022
Apache License 2.0
src/Day07.kt
nielsz
573,185,386
false
{"Kotlin": 12807}
fun main() { fun part1(input: List<String>): Int { val fileSystem = createFileSystem(input) return fileSystem.getDirectories() .filter { it.getSize() <= 100_000 } .sumOf { it.getSize() } } fun part2(input: List<String>): Int { val totalSize = 70_000_000 ...
0
Kotlin
0
0
05aa7540a950191a8ee32482d1848674a82a0c71
3,246
advent-of-code-2022
Apache License 2.0
src/Day04/Day04.kt
Trisiss
573,815,785
false
{"Kotlin": 16486}
fun main() { fun rangeEntry(firstRange: Pair<Int, Int>, secondRange: Pair<Int, Int>): Boolean = firstRange.first >= secondRange.first && firstRange.second <= secondRange.second || secondRange.first >= firstRange.first && secondRange.second <= firstRange.second fun rangeOverlap(firstRange: Pair<Int...
0
Kotlin
0
0
cb81a0b8d3aa81a3f47b62962812f25ba34b57db
1,278
AOC-2022
Apache License 2.0
src/main/kotlin/day3/Day3.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day3 import java.io.File fun computeGammaAndEpsilon(diagnosticReport: List<String>): Pair<Int, Int> { val p = List(diagnosticReport[0].length) { -diagnosticReport.size / 2 } val sums = diagnosticReport.fold(p) { acc, s -> s.map { it - '0' }.zip(acc){ a, b -> a + b } } val (gammaRaw, epsilonRaw) = sums ...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
1,985
advent-of-code-2021
MIT License
src/day08/Day08.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day08 import readInput fun main() { part1() part2() } enum class Direction { UP, DOWN, LEFT, RIGHT } fun part1() { val input = readInput(8) val grid = input.map { line -> line.map { it.digitToInt() } } fun Pair<Int, Int>.visible(direction: Direction, height: Int): Boolean = ...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
2,808
advent-of-code-2022
Apache License 2.0
src/Day15.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min fun main() { data class Point(val x: Long, val y: Long) { fun manhattan(other: Point): Long = (x - other.x).absoluteValue + (y - other.y).absoluteValue fun tuningFreq() = x * 4_000_000L + y } data class Sensor(v...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
2,014
aoc-2022
Apache License 2.0
src/main/kotlin/days/y2023/day12_a/Day12.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day12_a import util.InputReader import util.timeIt typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day12(val input: PuzzleInput) { fun partOne(): Long { return input.sumOf { line -> val config = line.toConfiguration() getCount(conf...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,911
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day09.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun part1(input: List<String>): Int { return parseMoves(input).generateTailMoves().toSet().size } fun part2(input: List<String>): Int { val moves = parseMoves(input) var knotMoves = moves repeat(9) { ...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
2,067
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
import kotlin.math.max import kotlin.math.min fun main() { fun isCompassing(low1: Int, high1: Int, low2: Int, high2: Int): Boolean { return (low1 <= low2 && high1 >= high2) || (low2 <= low1 && high2 >= high1) } fun part1(input: List<String>): Int { return input.count { val (fir...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
1,397
aoc-2022
Apache License 2.0
src/main/kotlin/day22.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getLines data class Cube(val on: Boolean, var x: Range, var y: Range, var z: Range){ fun volume() = x.length() * y.length() * z.length() } data class Range(val from: Int, val to: Int){ fun length() = (to - from).toLong() + 1 fun valid() = from <= to fun intersect(b: Range) = Range(maxOf(f...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
2,538
AdventOfCode2021
MIT License
app/src/main/kotlin/advent/of/code/twentytwenty/Day11.kt
obarcelonap
320,300,753
false
null
package advent.of.code.twentytwenty fun main(args: Array<String>) { val seatPlan = newSeatPlan(getResourceAsText("/day11-input")) val stabilizedSeatPlanPart1 = stabilizeSeatPlan(seatPlan, ::countAdjacentOccupiedSeats, 4) val occupiedSeatsPart1 = countOccupiedSeats(stabilizedSeatPlanPart1) println("Part...
0
Kotlin
0
0
a721c8f26738fe31190911d96896f781afb795e1
4,154
advent-of-code-2020
MIT License
src/main/kotlin/_50to100/Task54.kt
embuc
735,933,359
false
{"Kotlin": 110920, "Java": 60263}
package se.embuc._50to100 import se.embuc.Task import se.embuc.utils.readFileAsString import kotlin.math.sign // Poker hands class Task54 : Task { override fun solve(): Any { val games = readFileAsString("54_poker.txt").lines().map { parseGame(it) } var countPlayer1 = 0; for (game in games) { if (game.hand1...
0
Kotlin
0
1
79c87068303f862037d27c1b33ea037ab43e500c
2,869
projecteuler
MIT License
src/Day05.kt
achugr
573,234,224
false
null
import java.util.Stack class Move(val amount: Int, val from: Int, val to: Int) { companion object Parser { private val moveRegex = Regex("move (\\d+) from (\\d+) to (\\d+)") fun parse(input: String): Move? { return moveRegex.find(input) ?.groupValues ?.dr...
0
Kotlin
0
0
d91bda244d7025488bff9fc51ca2653eb6a467ee
2,926
advent-of-code-kotlin-2022
Apache License 2.0
src/year_2023/day_10/Day10.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_10 import readInput import util.* import kotlin.math.E enum class Direction() { North, East, South, West, ; fun inverse(): Direction { return when (this) { North -> South East -> West South -> North West -> East ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,546
advent_of_code
Apache License 2.0
src/day11/Day11.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day11 import readInput import java.lang.Exception private fun lowestCommonDenominator(a: Long, b: Long): Long { val biggerNum = if (a > b) a else b var lcm = biggerNum while (true) { if (((lcm % a) == 0L) && ((lcm % b) == 0L)) { break } lcm += biggerNum } ...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
4,520
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day24/Day24.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day24 import readInput import java.util.PriorityQueue import kotlin.math.abs class Map( val width: Int, val height: Int, val map: List<String>, private val horizontal: kotlin.collections.Map<Int, List<Blizzard>>, private val vertical: kotlin.collections.Map<Int, List<Blizzard>> ) { f...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
5,378
aoc2022
Apache License 2.0
src/main/kotlin/day8/Day8.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day8 import java.io.File /* * An entry has the following format: <representation of the ten digits> | <display output> * i.e: * acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf */ fun parseOnlyDigitsOutput(entries: List<String>): List<List<String>> = entries.map { entry -...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
4,227
advent-of-code-2021
MIT License
src/main/kotlin/days/Day2.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day2 : Day(2) { val games = inputList.map(this::parseGame) override fun partOne(): Any { val bag = CubeSet(12, 13, 14) return games.filter { it.isPossible(bag) }.sumOf { it.id } } override fun partTwo(): Any { return games.sumOf { it.minimumCubeSet().power(...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
1,764
aoc-2023
Creative Commons Zero v1.0 Universal
2022/src/Day09.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src import kotlin.math.abs import kotlin.math.sign fun correct(vertex: Pair<Int,Int>) : Pair<Int,Int> { return if (abs(vertex.first) > 1 || abs(vertex.second) > 1) Pair((vertex.first - sign(vertex.first.toDouble())).toInt(), (vertex.second - sign(vertex.second.toDouble())).toInt()) ...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
3,166
AoC
Apache License 2.0
2023/13/solve-1.kts
gugod
48,180,404
false
{"Raku": 170466, "Perl": 121272, "Kotlin": 58674, "Rust": 3189, "C": 2934, "Zig": 850, "Clojure": 734, "Janet": 703, "Go": 595}
import java.io.File fun partiallyMirrored(s1: String, s2: String) = with(s1.reversed()) { this.startsWith(s2) || s2.startsWith(this) } fun vReflectAtCol(input: List<String>): Int { val lastCol = input[0].lastIndex var candidates = (0 .. lastCol-1).filter { x -> input.indices.all { y -> ...
0
Raku
1
5
ca0555efc60176938a857990b4d95a298e32f48a
1,484
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/d23/D23_1.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d23 import d16.Direction import input.Input class D23_1 { companion object { private fun findSplittingIntersections(lines: List<String>): List<Pair<Int, Int>> { val intersections = mutableListOf<Pair<Int, Int>>() for (i in 1..<lines.lastIndex) { for (j in...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
5,329
aoc2023-kotlin
MIT License
src/Day04.kt
camina-apps
572,935,546
false
{"Kotlin": 7782}
data class Section( val start: Int, val end: Int ) fun main() { // horizontal arranged based on starting point fun parseIntoArrangedSections(input: String): Pair<Section, Section> { val elves = input.split(",") val rawSectionA = elves[0].split("-") val rawSectionB = elves[1].s...
0
Kotlin
0
0
fb6c6176f8c127e9d36aa0b7ae1f0e32b5c31171
1,788
aoc_2022
Apache License 2.0
src/Day03.kt
anisch
573,147,806
false
{"Kotlin": 38951}
fun findMatch(s1: String, s2: String): Char { for (c in 'A'..'z') { if (c in s1 && c in s2) return c } error("wtf???") } fun findMatch(s1: String, s2: String, s3: String): Char { for (c in 'A'..'z') { if (c in s1 && c in s2 && c in s3) return c } error("wtf???") } fun getPriori...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
1,097
Advent-of-Code-2022
Apache License 2.0
src/2017Day10_2.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
package day2017_10_2 import utils.runSolver private typealias SolutionType = Int private const val defaultSolution = 0 private const val dayNumber: String = "10" private val testSolution1: SolutionType? = 88 private val testSolution2: SolutionType? = 36 class CircularList(private val backingList: MutableList<Int>...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
2,622
2022-AOC-Kotlin
Apache License 2.0
src/Day16.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun part1(input: List<String>): Int { val grid = ValvesGrid.parse(input) var states = listOf(ValvesSingleOperatorState(me = Operator(listOf("AA")))) repeat(30) { states = states .asSequence() .map { state -> with(st...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
7,647
aoc-2022
Apache License 2.0
src/Day05.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
fun readStacks(input: List<String>, stackNumLine: String): List<ArrayDeque<Char>> { val stackNums = stackNumLine.toCharArray() val countStacks = stackNums.filterNot { it == ' ' }.last().toString().toInt() val stacks = MutableList(countStacks) { ArrayDeque<Char>() } input.forEach { line -> line.t...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
2,204
advent-of-code-2022
Apache License 2.0
src/Day07.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
fun main() { fun parseFileSystem(inputs: List<String>): Directory { val rootDirectory = Directory("/", null) var currentDir = rootDirectory for (action in inputs) { if (action.startsWith("$")) { // command when (action) { "$ ls"...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
3,186
aoc-2022-in-kotlin
Apache License 2.0
year2018/src/main/kotlin/net/olegg/aoc/year2018/day24/Day24.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day24 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2018.DayOf2018 /** * See [Year 2018, Day 24](https://adventofcode.com/2018/day/24) */ object Day24 : DayOf2018(24) { override fun first(): Any? { val (immune, infection) = data .split("\n\n") .map { ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
4,467
adventofcode
MIT License
src/Day11.kt
mcrispim
573,449,109
false
{"Kotlin": 46488}
fun main() { class Monkey( val items: MutableList<Long>, val op: String, val paramStr: String, val testDivisor: Int, val testTrue: Int, val testFalse: Int ) { var inspectionCounter = 0 fun processItems(monkeyList: List<Monkey>, relief: (Long) -> ...
0
Kotlin
0
0
5fcacc6316e1576a172a46ba5fc9f70bcb41f532
3,225
AoC2022
Apache License 2.0
src/day7/Day07.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day7 import Runner fun main() { Day7Runner().solve() } class Day7Runner : Runner<Int>( day = 7, expectedPartOneTestAnswer = 95437, expectedPartTwoTestAnswer = 24933642 ) { override fun partOne(input: List<String>, test: Boolean): Int { val contents = directoryContents(input) ...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
2,999
advent-of-code
Apache License 2.0
src/main/kotlin/net/navatwo/adventofcode2023/day1/Day1Solution.kt
Nava2
726,034,626
false
{"Kotlin": 100705, "Python": 2640, "Shell": 28}
package net.navatwo.adventofcode2023.day1 import net.navatwo.adventofcode2023.framework.ComputedResult import net.navatwo.adventofcode2023.framework.Solution sealed class Day1Solution : Solution<List<Day1Solution.CalibrationLine>> { data object Part1 : Day1Solution() { override fun solve(input: List<Calibration...
0
Kotlin
0
0
4b45e663120ad7beabdd1a0f304023cc0b236255
2,788
advent-of-code-2023
MIT License
src/main/day17/day17.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day17 import Point import day17.Direction.DOWN import day17.Direction.LEFT import day17.Direction.RIGHT import findPattern import readInput import second const val leftWall = 0 const val rightWall = 6 typealias TetrisCave = MutableSet<Point> typealias TetrisRock = Set<Point> data class Jets(val jets: List<D...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
3,850
aoc-2022
Apache License 2.0
src/main/kotlin/name/valery1707/problem/leet/code/RomanToIntegerK.kt
valery1707
541,970,894
false
null
package name.valery1707.problem.leet.code /** * # 13. Roman to Integer * * Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. * * | Symbol | Value | * |--------|-------| * | `I` | `1` | * | `V` | `5` | * | `X` | `10` | * | `L` | `50` | * | `C` | `100` | * | `D`...
3
Kotlin
0
0
76d175f36c7b968f3c674864f775257524f34414
3,662
problem-solving
MIT License
src/Day04.kt
aaronbush
571,776,335
false
{"Kotlin": 34359}
fun main() { fun String.toIntRange(): IntRange { val parts = this.split("-", limit = 2) return parts[0].toInt()..parts[1].toInt() } fun IntRange.subSetOf(other: IntRange) = this.first >= other.first && this.last <= other.last fun IntRange.overlaps(other: IntRange) = th...
0
Kotlin
0
0
d76106244dc7894967cb8ded52387bc4fcadbcde
1,569
aoc-2022-kotlin
Apache License 2.0