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
2023/src/main/kotlin/Day12.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day12 { fun part1(input: String) = parseInput(input).sumOf(::numConfigurations) fun part2(input: String) = parseInput(input) .map { it.unfold() } .sumOf(::numConfigurations) private enum class State { OPERATIONAL, DAMAGED, UNKNOWN } private data class Record(val springs: List<State>, val grou...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
3,171
advent-of-code
MIT License
src/main/kotlin/com/groundsfam/advent/y2021/d09/Day09.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d09 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.grids.Grid import com.groundsfam.advent.grids.containsPoint import com.groundsfam.advent.points.Point import com.groundsfam.advent.points.down import com.groundsfam.advent.points.left import com.groundsfam.advent...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,891
advent-of-code
MIT License
src/year2021/day04/Day04.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2021.day04 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { // Stores the board data redundantly as lists of lists of strings, // one per column and row. // this eases the mental model // rawRows: // "1 2" // "3 4" // // becomes // rows: [...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
3,058
advent-of-code-kotlin
Apache License 2.0
src/commonMain/kotlin/com/marcoeckstein/klib/algorithm/NumberSearch.kt
marco-eckstein
344,286,939
false
null
package com.marcoeckstein.klib.algorithm import com.marcoeckstein.klib.kotlin.ranges.binarySearch import kotlin.math.absoluteValue import kotlin.math.sqrt fun findNumber(isNumberInRange: (IntRange) -> Boolean): Int? { val bounds = findNumberBounds(isNumberInRange) ?: return null return bounds.binarySearch { c...
0
Kotlin
0
3
b28b28b76f04c245951dd8d02e3531818f9b6c57
2,299
kotlin-lib
MIT License
aoc-2023/src/main/kotlin/aoc/aoc6.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt val testInput = """ Time: 7 15 30 Distance: 9 40 200 """.parselines class Race(val time: Long, val dist: Long) { fun numToBeat(): Long { va...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
1,530
advent-of-code
Apache License 2.0
src/Day07.kt
dcbertelsen
573,210,061
false
{"Kotlin": 29052}
import java.io.File import java.util.Dictionary fun main() { fun buildFilesystem(data: List<String>): Directory { val root = Directory("/", null) var cwd = root data.forEachIndexed { i, line -> val curr = line.split(" ") when { curr[1] == "cd" -> cwd...
0
Kotlin
0
0
9d22341bd031ffbfb82e7349c5684bc461b3c5f7
3,236
advent-of-code-2022-kotlin
Apache License 2.0
src/Day07.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
fun main() { fun findNextCommand(input: List<String>, cursor: Int): Int { return when (val indexOfNextCommand = input.subList(cursor, input.size - 1).indexOfFirst { line -> line.startsWith("$ ") }) { -1 -> input.size - 1 else -> indexOfNextCommand + cursor } ...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
4,859
AoC2022
Apache License 2.0
src/Day11.kt
Akhunzaada
573,119,655
false
{"Kotlin": 23755}
import java.io.File data class Monkey( private val items: MutableList<Long>, private val operation: String, private val divBy: Int, private val throwToMonkey: Int, private val elseThrowToMonkey: Int ) { private var worryLevel: Long = 0 var inspections: Long = 0 fun divBy() = divBy ...
0
Kotlin
0
0
b2754454080989d9579ab39782fd1d18552394f0
3,231
advent-of-code-2022
Apache License 2.0
src/day25/Day25.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day25 import kotlin.math.max import readInput const val BASE = 5 enum class SNAFUDigit(val value: Int, val symbol: Char) { DOUBLE_MINUS(-2, '='), MINUS(-1, '-'), ZERO(0, '0'), ONE(1, '1'), TWO(2, '2'); companion object { private val charToDigit = SNAFUDigit.values().associate...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
2,253
aoc-2022
Apache License 2.0
codeforces/round584/e1.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round584 private fun solve() { val (n, m) = readInts() val a = List(n) { readInts() } val b = List(m) { i -> a.map { it[i] } }.sortedByDescending { it.maxOrNull() }.take(n) println(solve(b, 1, b[0])) } private fun solve(b: List<List<Int>>, x: Int, best: List<Int>): Int { val bestInit = best.su...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
814
competitions
The Unlicense
advent2022/src/main/kotlin/year2022/Day12.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import graph.AdjacencyListGraph import graph.Graph import graph.dijkstra private typealias Coordinate = Pair<Int, Int> private typealias Terrain = Graph<Coordinate> private fun List<String>.atPoint(point: Coordinate) = when (this[point.second][point.first]) { 'S' -> 'a' 'E' ...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,660
advent-of-code
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day22/day22.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day22 import biz.koziolek.adventofcode.Coord import biz.koziolek.adventofcode.Coord3d import biz.koziolek.adventofcode.findInput import kotlin.math.max import kotlin.math.min fun main() { val inputFile = findInput(object {}) val bricks = parseBricks(inputFile.buffere...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
6,113
advent-of-code
MIT License
src/main/kotlin/day24/Day24.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day24 import Queue import execute import readAllText import kotlin.math.absoluteValue typealias Pos = Pair<Int, Int> typealias Blizzard = Pair<Pos, Dir> enum class Dir(val v: Pos) { N(-1 to 0), W(0 to -1), E(0 to 1), S(1 to 0), } operator fun Pos.plus(o: Pos) = first + o.first to second + o.second o...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
4,069
advent-of-code-2022
MIT License
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day13.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 /** * https://adventofcode.com/2022/day/13 */ class Day13(override val input: String) : Day() { override fun part1(): String { return input.split("\n\n") .map { val lines = it.lines() parseList(lines[0].asTokenDeque()) to parseL...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
3,255
adventofcode2022
MIT License
src/Day12.kt
pavlo-dh
572,882,309
false
{"Kotlin": 39999}
fun main() { data class Point(val y: Int, val x: Int) val deltas = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1) fun mapElevation(c: Char) = when (c) { 'S' -> 'a' 'E' -> 'z' else -> c } fun MutableMap<Point, MutableList<Point>>.addEdge(from: Point, to: Point) { val from...
0
Kotlin
0
2
c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992
2,837
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/days/Day4.kt
VictorWinberg
433,748,855
false
{"Kotlin": 26228}
package days class Day4 : Day(4) { override fun partOne(): Any { return winners().first() } override fun partTwo(): Any { return winners().last() } private fun winners(): List<Int> { val list = inputList.filter { it.isNotEmpty() } val numbers = list.first().split(...
0
Kotlin
0
0
d61c76eb431fa7b7b66be5b8549d4685a8dd86da
1,919
advent-of-code-kotlin
Creative Commons Zero v1.0 Universal
jk/src/main/kotlin/common/Trees.kt
lchang199x
431,924,215
false
{"Kotlin": 86230, "Java": 23581}
@file:JvmName("Trees") package common import java.util.* class KTreeNode(val data: Int, var left: KTreeNode? = null, var right: KTreeNode? = null) class TrieNode(var isWord: Boolean = false, val children: Array<TrieNode?> = arrayOfNulls(26)) /** * 二叉树的最大深度 * [](https://leetcode-cn.com/problems/maximum-depth-of-bi...
0
Kotlin
0
0
52a008325dd54fed75679f3e43921fcaffd2fa31
9,562
Codelabs
Apache License 2.0
src/Day09.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun part1(input: List<String>, knotsCount: Int = 2): Int = buildSet { val knots = Array(knotsCount) { 0 to 0 } input.map { line -> line.split(' ').let { it[0] to it[1].toInt() } } .forEach { move -> repeat(move.second) { knots[0] = knots[...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
1,946
advent-of-code-2022
Apache License 2.0
src/main/kotlin/d19/D19_1.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d19 import d13.split import input.Input data class Part( val x: Int, val m: Int, val a: Int, val s: Int ) { constructor(values: List<Int>) : this(values[0], values[1], values[2], values[3]) fun getTotal(): Int { return x + m + a + s } } fun parseWorkflows(lines: List<Stri...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
3,450
aoc2023-kotlin
MIT License
src/Day04.kt
KristianAN
571,726,775
false
{"Kotlin": 9011}
fun List<String>.rangeToList(): List<Int> = this.map {num -> num.toInt()}.let { (it[0]..it[1]).toList() } fun List<List<Int>>.overlaps(): Boolean = this[0].intersect(this[1].toSet()).let { it.size == this[0].size || it.size == this[1].size } fun List<List<Int>>.containsItem(): Boolean = this[0].intersect(this...
0
Kotlin
0
0
3a3af6e99794259217bd31b3c4fd0538eb797941
823
AoC2022Kt
Apache License 2.0
src/day07/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day07 import readInput sealed class Day06Node { abstract val size: Int } private class File(override val size: Int) : Day06Node() private class Dir( val fileContents: MutableMap<String, File> = mutableMapOf(), val dirContents: MutableMap<String, Dir> = mutableMapOf(), val parent: Dir? = null ...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
1,949
AOC2022
Apache License 2.0
src/Day13.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun main() { data class ListOrInt(var children: MutableList<ListOrInt> = mutableListOf(), var value: Int? = null) : Comparable<ListOrInt> { var parent: ListOrInt? = null override fun compareTo(other: ListOrInt): Int { if (this.value != null) { if (other.value != ...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
3,421
advent-2022
Apache License 2.0
src/Day03.kt
Frendzel
573,198,577
false
{"Kotlin": 5336}
fun String.intersectedItems(): Set<Char> = listOf( substring(0..length / 2), substring(length / 2) ).intersectedItems() fun Char.priority(): Int = when (this) { in 'a'..'z' -> (this.code - 97) + 1 in 'A'..'Z' -> (this.code - 65) + 27 ...
0
Kotlin
0
0
a8320504be93dfba1f634413a50e7240d16ba6d9
1,020
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch7/Problem72.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch7 import kotlin.math.sqrt /** * Problem 72: Counting Fractions * * https://projecteuler.net/problem=72 * * Goal: Count the elements in a set of reduced proper fractions for d <= N, i.e. order N. * * Constraints: 2 <= N <= 1e6 * * Reduced Proper Fraction: A fraction n/d, where n & d a...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
6,179
project-euler-kotlin
MIT License
src/Day10.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
fun main() { data class Instruction(val operator: String, val value: Int) class Solution(input: List<String>) { val instructions: List<Instruction> init { this.instructions = input.map { it.split(" ").run { Instruction(this[0], if (this.size == 1) 0 else this[1].toI...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
2,791
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day17.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day import java.util.* class Day17(input: String? = null) : Day(17, "Day17", input) { data class Node(val x: Int, val y: Int, val direction: Direction, val directionCount: Int) enum class Direction { NORTH, SOUTH, EAST, WEST } private val map = inputL...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
3,153
advent-of-code-2023
MIT License
src/main/kotlin/de/tek/adventofcode/y2022/day02/RockPaperScissors.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day02 import de.tek.adventofcode.y2022.util.readInputLines enum class Result(val score: Int) { Win(6), Lose(0), Draw(3); fun invert(): Result = when (this) { Win -> Lose Lose -> Win Draw -> Draw } } enum class Choice(val s...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
3,334
advent-of-code-2022
Apache License 2.0
year2019/src/main/kotlin/net/olegg/aoc/year2019/day10/Day10.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day10 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.gcd import net.olegg.aoc.year2019.DayOf2019 import kotlin.math.atan2 import kotlin.math.sign /** * See [Year 2019, Day 10](https://adventofcode.com/2019/day/10) */ object Day10 : ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,064
adventofcode
MIT License
src/Day08.kt
psabata
573,777,105
false
{"Kotlin": 19953}
import kotlin.math.max fun main() { val testInput = Day08.Forrest(InputHelper("Day08_test.txt").readLines()) check(testInput.part1() == 21) check(testInput.part2() == 8) val input = Day08.Forrest(InputHelper("Day08.txt").readLines()) println("Part 1: ${input.part1()}") println("Part 2: ${inpu...
0
Kotlin
0
0
c0d2c21c5feb4ba2aeda4f421cb7b34ba3d97936
3,023
advent-of-code-2022
Apache License 2.0
src/Day03.kt
virtualprodigy
572,945,370
false
{"Kotlin": 8043}
fun main() { fun convertToPriorityPoint(item: Char): Int { //convert to Ascii val asciiVal = item.code return if (asciiVal < 97) { //upper case convert // println("converting $item upper $asciiVal -> ${asciiVal-38}") // 65 - 90 A - Z -> 27 - 52 asciiVal - 38 ...
0
Kotlin
0
0
025f3ae611f71a00e9134f0e2ba4b602432eea93
2,034
advent-code-code-kotlin-jetbrains-2022
Apache License 2.0
09/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : HeightMap { val inputLines = File("input.txt") .readLines() .map { line -> line.split("") .filter { it.isNotEmpty() } .map{ it.toInt() }} return HeightMap(inputLines) } class HeightMap(inputLines : List<List<Int>>) { companion...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
1,714
advent-of-code-2021
MIT License
src/Day02-2.kt
casslabath
573,177,204
false
{"Kotlin": 27085}
fun main() { val moves = mapOf( "A" to Move.ROCK, "X" to Move.ROCK, "B" to Move.PAPER, "Y" to Move.PAPER, "C" to Move.SCISSORS, "Z" to Move.SCISSORS) val movePoints = mapOf(Move.ROCK to 1, Move.PAPER to 2, Move.SCISSORS to 3) val winsAgainst = mapOf(Move.ROCK to Move.SCISSORS, Move....
0
Kotlin
0
0
5f7305e45f41a6893b6e12c8d92db7607723425e
3,044
KotlinAdvent2022
Apache License 2.0
src/Day07.kt
PauliusRap
573,434,850
false
{"Kotlin": 20299}
private const val COMMAND_CHANGE_DIR = "$ cd " private const val MOVE_BACK = ".." private const val PREFIX_DIRECTORY = "dir " fun main() { fun parseSystemFolderSizes(input: List<String>): List<Long> { val system = mutableMapOf<String, DirectoryInfo>() val fileRegex = "(\\d+) (\\D+)".toRegex() ...
0
Kotlin
0
0
df510c3afb104c03add6cf2597c433b34b3f7dc7
2,575
advent-of-coding-2022
Apache License 2.0
src/Day03.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day03 import patriker.utils.* val Char.priority get(): Int{ if(this.isUpperCase()){ return this.code - 'A'.code + 27 } return this.code - 'a'.code + 1 } fun main() { val testInput = readInput("Day03_test") val input = readInput("Day03_input") p...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
1,257
aoc2022
Apache License 2.0
src/problems/day6/part1/part1.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day6.part1 import java.io.File import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt private const val inputFile = "input/day6/input.txt" //private const val testFile = "input/day6/test.txt" fun main() { val productOfNumBeats = File(inputFile).bufferedReader().useLines { multi...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
1,687
aoc2023
MIT License
src/day21/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day21 import day21.Operation.Add import day21.Operation.Divide import day21.Operation.Multiply import day21.Operation.Subtract import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 152 testInput.par...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
3,583
advent-of-code-2022
Apache License 2.0
src/Day14.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
fun main() { fun prepareInput(input: List<String>) : Pair<MutableMap<Pair<Int, Int>, Char>, Int> { val map = mutableMapOf<Pair<Int, Int>, Char>() var maxDepth = 0 map.clear() input.forEach { line -> val points = line.split(" -> ").map { point -> val (x, y...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
3,136
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Day16.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import kotlin.math.max import kotlin.math.min class Day16(input: List<String>) { private val regex = Regex("Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)") private val allValves = input.map { regex.find(it)!!.destructured.let { (name, flowRate, tu...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
4,698
advent-2022
MIT License
src/Day03.kt
burtz
573,411,717
false
{"Kotlin": 10999}
fun main() { fun listOfDups(firstComp: List<Char>,secondComp: List<Char>) : List<Char> { var listOfDupes = listOf<Char>() firstComp.forEach { first -> secondComp.forEach { second -> if (first == second) { listOfDupes += first } ...
0
Kotlin
0
0
daac7f91e1069d1490e905ffe7b7f11b5935af06
1,690
adventOfCode2022
Apache License 2.0
src/main/kotlin/days/Day16.kt
jgrgt
575,475,683
false
{"Kotlin": 94368}
package days import itertools.combinations import util.MutableMatrix import util.Point class Day16 : Day(16) { override fun partOne(): Any { // return Game16(inputList).solve() return 0 } override fun partTwo(): Any { return Game16(inputList).solve2() } } class Game16(lines: ...
0
Kotlin
0
0
5174262b5a9fc0ee4c1da9f8fca6fb86860188f4
7,738
aoc2022
Creative Commons Zero v1.0 Universal
kotlin/src/x2023/Day02.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package x2023 data class Dice(var color: String, var count: Int) fun List<Dice>.possible(set: List<Dice>): Boolean { return set.all { die -> this.any { d -> d.color == die.color && d.count >= die.count } } } open class Day02AExample { open val inputLines: List<String> = read20...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
3,347
adventOfCode
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day18.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 18: Boiling Boulders * Problem Description: https://adventofcode.com/2022/day/18 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.points.Point3D import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { val name = getClassN...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,855
AoC-2022
Apache License 2.0
src/poyea/aoc/mmxxii/day17/Day17.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day17 import poyea.aoc.utils.readInput data class Point(val x: Int, val y: Int) { operator fun plus(other: Point) = Point(x + other.x, y + other.y) } data class Shape(val points: List<Point>) { fun push(jet: Char) = when (jet) { '>' -> copy(points = points.map { it.copy(x = i...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
3,709
aoc-mmxxii
MIT License
src/main/kotlin/dev/bogwalk/batch0/Problem4.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch0 import dev.bogwalk.util.maths.primeFactors import dev.bogwalk.util.strings.isPalindrome import kotlin.math.sqrt /** * Problem 4: Largest Palindrome Product * * https://projecteuler.net/problem=4 * * Goal: Find the largest palindrome less than N that is made from the product of two 3-di...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,996
project-euler-kotlin
MIT License
solutions/src/NetworkDelayTime.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import java.util.* import kotlin.collections.HashSet //https://leetcode.com/problems/network-delay-time/ class NetworkDelayTime { fun networkDelayTime(times: Array<IntArray>, N: Int, K: Int): Int { val graph = createGraph(times) val distances : MutableMap<Int,Node> = mutableMapOf() val exp...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,819
leetcode-solutions
MIT License
src/main/kotlin/bk70/Problem3.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package bk70 import java.util.* // [[0,2,0]] // [2,2] // [0,1] // 1 fun main() { val res = Problem3().highestRankedKItems( arrayOf( intArrayOf(0, 2, 0), ), intArrayOf(2, 2), intArrayOf(0, 1), 1 ) println(res) } class Problem3 { private lateinit var ...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
2,738
leetcode-kotlin
MIT License
src/main/kotlin/aoc2018/ModeMaze.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2018 import komu.adventofcode.utils.Point import utils.shortestPathWithCost import java.util.* fun modeMaze1(depth: Int, target: Point) = CaveSystem(depth, target).riskLevel() fun modeMaze2(depth: Int, target: Point) = CaveSystem(depth, target).fastestRoute() private class CaveS...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,659
advent-of-code
MIT License
year2023/src/main/kotlin/net/olegg/aoc/year2023/day13/Day13.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day13 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 13](https://adventofcode.com/2023/day/13) */ object Day13 : DayOf2023(13) { override fun first(): Any? { val patterns = data.split("\n\n").map { pattern -> pattern.lines(...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,595
adventofcode
MIT License
src/Day13.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun packets(): List<Packet> { return readInput("Day13").filter { it.isNotBlank() }.map { parsePacket(it) } } private fun parsePacket(s: String): Packet = ListData().also { parseListData(it, s, 0) } private fun parseListData(curList: ListData, s: String, start: Int): Int { var cur = start + 1 while...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
2,631
advent-of-code-2022
Apache License 2.0
src/Day14.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
import java.lang.StringBuilder enum class State { FINISHED, ADDED, BLOCKED; fun completed(): Boolean { return this != BLOCKED } } class Field() { private var snowCoordinate: Coordinate = Coordinate(500, 0) private var left: Int = 1000000 private var right: Int = 0 private var flo...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
3,045
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/twentytwentytwo/Day22.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import kotlin.math.sqrt fun main() { val input = {}.javaClass.getResource("input-22.txt")!!.readText().split("\n\n"); val tinput = {}.javaClass.getResource("input-22-1.txt")!!.readText().split("\n\n"); val test = Day22(tinput) val day = Day22(input) //val testResult1 = tes...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
8,703
aoc202xkotlin
The Unlicense
src/Day12.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
fun main() { class Field { val field = MutableList(0) { List(0) { 0 } } var start = Coordinate(0, 0) var end = Coordinate(0, 0) var canStep: (Coordinate, Coordinate) -> Boolean = { from, to -> field.at(from) + 1 >= field.at(to) } fun neighbours(current: Coordinate): List<Coordinate> { val r...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
2,346
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day07.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
fun main() { fun handleCommand(command: String, currentDir: CommandDir): CommandDir { if (command.contains("$ ls")) return currentDir val parsedCommand: String = command.split(" ").last() if (parsedCommand == "/"){ var returnDir = currentDir do { ...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
2,963
AdventOfCode2022
Apache License 2.0
9_nine/FallingBlocks.kt
thalees
250,902,664
false
null
import java.util.* private class Block(val l: Int, val r: Int) : Comparable<Block> { fun cover(c: Block) = l <= c.l && r >= c.r override fun compareTo(other: Block): Int = l.compareTo(other.l) } fun main() { val (n, d) = readLine()!!.split(" ").map { it.toInt() } val bh = arrayOfNulls<TreeSet<Block>>(...
0
Kotlin
0
0
3b499d207d366450c7b2facbd99a345c86b6eff8
2,316
kotlin-code-challenges
MIT License
src/main/kotlin/days_2021/Day8.kt
BasKiers
434,124,805
false
{"Kotlin": 40804}
package days_2021 import util.Day import kotlin.math.pow class Day8 : Day(8) { val input = inputList.map { it.split(" | ") }.map { (examples, answer) -> examples.split(" ").map(String::toCharArray).map(CharArray::toSet) to answer.split(" ").map(String::toCharArray).map(CharArray::toSet) } class S...
0
Kotlin
0
0
870715c172f595b731ee6de275687c2d77caf2f3
3,633
advent-of-code-2021
Creative Commons Zero v1.0 Universal
7_seven/MNumbers.kt
thalees
250,902,664
false
null
fun main() { val (m, k) = readLine()!!.split(" ").map { it.toInt() } val f = factor(m) ?: run { println(-1) return } val dp = HashMap<Long,Long>() val dig = IntArray(100_000) fun count(nd: Int, p: Long = -1): Long { val e = f[0] + (f[1] shl 5) + (f[2] shl 10) + (f[3] shl ...
0
Kotlin
0
0
3b499d207d366450c7b2facbd99a345c86b6eff8
1,407
kotlin-code-challenges
MIT License
src/Day03.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { fun part1(input: List<String>): Int { // "abcdaf" -> [[a,b,c],[d,a,f]] -> [a] -> [1] return input.map { it.toList().chunked(it.length/2) } .flatMap { e -> e.first().toSet().intersect(e.last().toSet()) } .sumOf { e -> getAsciiValue(e) } } fun part2(inpu...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
1,456
advent-of-code-2022
Apache License 2.0
src/day09/Day09.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day09 import readInput import readTestInput import kotlin.math.absoluteValue private data class Position(val x: Int, val y: Int) private fun List<String>.asSteps(): List<Char> = flatMap { command -> List(size = command.substring(2).toInt()) { command.first() } } private fun generateRope(size...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
2,345
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
iartemiev
573,038,071
false
{"Kotlin": 21075}
import java.util.* fun makeMoves(moves: List<List<Int>>, stacks: List<MutableList<Char>>): List<MutableList<Char>> { for (move in moves) { val (quantity, source, destination) = move for (i in 1..quantity) { val crate = stacks[source-1].last() stacks[source-1].removeLast() stacks[destination...
0
Kotlin
0
0
8d2b7a974c2736903a9def65282be91fbb104ffd
2,549
advent-of-code
Apache License 2.0
src/main/aoc2015/Day15.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 import kotlin.math.max class Day15(input: List<String>) { // List of ingredients, each entry is a list of parameters describing the ingredient (last is calories) private val ingredients = parseInput(input) private fun parseInput(input: List<String>): List<List<Int>> { return inpu...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,259
aoc
MIT License
src/Day07.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
fun main() { abstract class Entry(val name: String, val children: MutableList<Entry>? = null) { abstract val size: Long override fun toString(): String = name } class Directory(name: String) : Entry(name, mutableListOf()) { override val size: Long get() = children!!.sumO...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
3,225
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/tasso/adventofcode/_2021/day14/Day14.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day14 import dev.tasso.adventofcode.Solution import java.math.BigInteger class Day14 : Solution<BigInteger> { override fun part1(input: List<String>): BigInteger { return runPolymerization(input, 10) } override fun part2(input: List<String>): BigInteger { ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
2,389
advent-of-code
MIT License
src/main/kotlin/dev/pankowski/garcon/domain/Texts.kt
apankowski
360,267,645
false
{"Kotlin": 194512, "Dockerfile": 725, "Shell": 201}
package dev.pankowski.garcon.domain import java.text.BreakIterator import java.util.* import java.util.Collections.unmodifiableList /** * Calculates [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) * between given char sequences. */ fun levenshtein(a: CharSequence, b: CharSequence): Int {...
6
Kotlin
0
2
10f5126bc0c2e09f88bae19035bad64b1fbcd7ca
3,849
garcon
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day24/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day24 import com.anahoret.aoc2022.ManhattanDistanceAware import java.io.File import java.util.PriorityQueue import kotlin.system.measureTimeMillis enum class Direction { LEFT, RIGHT, UP, DOWN } data class Blizzard(val row: Int, val col: Int, val direction: Direction) operator fun Li...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
5,621
advent-of-code-2022
Apache License 2.0
src/Day08.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
fun main() { fun isVisibleInRow(columnIndex: Int,rowIndex: Int, row: IntArray): Boolean { // check left side val left = 0 until columnIndex val fromLeft = left.map { leftIndex -> if (row[leftIndex] >= row[columnIndex]) { // println("Tree ${row[rowIndex]} column $co...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
3,882
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d03/Day03.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d03 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines fun partNumbers(lines: List<String>): List<Int> { val ret = mutableListOf<Int>() lines.forEachIndexed { y, line -> var x = 0 ...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,902
advent-of-code
MIT License
2021/src/main/kotlin/day14_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution fun main() { Day14Fast.run() } object Day14All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day14Func, "imp" to Day14Imp, "fast" to Day14Fast).forEach { (header, solution) -> solution.run(header = header, skipPart1 = false, skipTest = false, prin...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,954
aoc_kotlin
MIT License
src/day13/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day13 import readInput sealed interface Element : Comparable<Element> @JvmInline value class IntElement(val value: Int) : Element { override fun compareTo(other: Element): Int = when (other) { is IntElement -> compareValues(value, other.value) is ListElement -> compareValues(ListElement(t...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
2,299
AoC-2022
Apache License 2.0
2022/src/main/kotlin/day5_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.Parse import utils.Parser import utils.Solution import utils.badInput import utils.mapItems fun main() { Day5Func.run() } typealias Day5Input = Pair<List<List<Char>>, List<Insn>> val stackParser: Parser<List<List<Char>>> = Grid.chars().map { grid -> val stackCount = (grid.width + 1...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,724
aoc_kotlin
MIT License
leetcode/src/daily/mid/Q870.kt
zhangweizhe
387,808,774
false
null
package daily.mid import java.util.* import kotlin.Comparator fun main() { // 870. 优势洗牌 // https://leetcode.cn/problems/advantage-shuffle/ println(advantageCount(intArrayOf(2,7,11,15), intArrayOf(1,10,4,11)).contentToString()) } fun advantageCount(nums1: IntArray, nums2: IntArray): IntArray { // 数组长度...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
3,229
kotlin-study
MIT License
src/main/kotlin/com/dmc/advent2022/Day13.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
//--- Day 13: Distress Signal --- package com.dmc.advent2022 class Day13 : Day<Int> { override val index = 13 override fun part1(input: List<String>): Int { val packets = input.filter { it.isNotEmpty() }.map{ it.toPacket() } return packets.chunked(2).withIndex().filter { it.value[...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
3,975
aoc-2022-kotlin
Apache License 2.0
neetcode/src/main/java/org/slidingwindow/SlidingWindowNeet.kt
gouthamhusky
682,822,938
false
{"Kotlin": 24242, "Java": 24233}
package org.slidingwindow import kotlin.math.abs // https://leetcode.com/problems/minimum-size-subarray-sum/ fun minSubArrayLen(target: Int, nums: IntArray): Int { var i = 0; var j = 0; var sum = 0; var min = Int.MAX_VALUE while (j < nums.size){ sum += nums[j] if (sum >= target){ ...
0
Kotlin
0
0
a0e158c8f9df8b2e1f84660d5b0721af97593920
2,778
leetcode-journey
MIT License
solutions/aockt/y2023/Y2023D05.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D05 : Solution { /** Returns true if there are any values that are contained in both ranges. */ private infix fun LongRange.overlaps(other: LongRange): Boolean = last >= other.first && first <= other.last ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
6,713
advent-of-code-kotlin-solutions
The Unlicense
src/Day20.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
fun main() { data class Number(val value: Long, val originalIndex: Int) fun mix(numbers: MutableList<Number>) { val n = numbers.size for (i in 0 until n) { val nextIndexToMove = numbers.indexOfFirst { it.originalIndex == i } val number = numbers.removeAt(nextIndexToMove)...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
1,520
aoc2022-kotlin
Apache License 2.0
kotlin/1631-path-with-minimum-effort.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
//dijkstra class Solution { fun minimumEffortPath(h: Array<IntArray>): Int { val minHeap = PriorityQueue<IntArray> { a, b -> a[2] - b[2] } val dirs = intArrayOf(0, 1, 0, -1, 0) val n = h.size val m = h[0].size val visited = Array (n) { BooleanArray (m) } fun isValid(...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
3,782
leetcode
MIT License
src/day4/Day4.kt
jorgensta
573,824,365
false
{"Kotlin": 31676}
package day4 import readInput fun main() { val day = "day4" val filename = "Day04" class Section(val intRange: IntRange) { fun containedBy(other: Section): Boolean { return intRange.intersect(other.intRange).size == intRange.toList().size } fun overlappedBy(other: Sec...
0
Kotlin
0
0
7243e32351a926c3a269f1e37c1689dfaf9484de
1,728
AoC2022
Apache License 2.0
2018/kotlin/day20p1/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* import kotlin.math.min fun main(args: Array<String>) { val start = Date() println(answerForPuzzleInput()) println("in ${Date().time - start.time}ms") } fun answerForPuzzleInput(): Int { val classLoader = RoomExParser::class.java.classLoader val input = classLoader.getResource("i...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
5,044
adventofcode
MIT License
src/main/kotlin/adventofcode2017/Day07RecursiveCircus.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2017 class Day07RecursiveCircus data class RCProgram(val name: String, val weight: Int, val dependants: List<String>) data class WeightedChild( val name: String, val parent: String, val weight: Int, val dependants: List<String>, val dependantsWeight: Int ) class RCTower(val p...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
4,409
kotlin-coding-challenges
MIT License
p02/src/main/kotlin/InventoryManagementSystem.kt
jcavanagh
159,918,838
false
null
package p02 import common.file.readLines fun hamming(str1: String, str2: String): Int { if(str1 !== str2) { // Hamming distance val zipped = str1.asIterable().zip(str2.asIterable()) return zipped.sumBy { if (it.first == it.second) 0 else 1 } } return -1 } /** * Returns id1, id2, and the common ch...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
1,360
advent2018
MIT License
src/Day06.kt
seana-zr
725,858,211
false
{"Kotlin": 28265}
import java.util.regex.Pattern fun main() { fun part1(input: List<String>): Int { val result: Int val waysPerRace = mutableListOf<Int>() val timesToBeat = input[0] .dropWhile { !it.isDigit() } .split(Pattern.compile("\\s+")) .map { it.toInt() } v...
0
Kotlin
0
0
da17a5de6e782e06accd3a3cbeeeeb4f1844e427
2,090
advent-of-code-kotlin-template
Apache License 2.0
src/main/aoc2023/Day12.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 class Day12(input: List<String>) { private data class Row(val springs: String, val groups: List<Int>) private val springs = input.map { line -> Row(line.substringBefore(" "), line.substringAfter(" ").split(",").map { it.toInt() }) } /** * The current state of the process...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
4,356
aoc
MIT License
src/main/day17/Part1.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day17 import LoopingIterator import common.Direction import common.Direction.* import common.Grid import common.Point import readInput fun main() { val result = solve(2022, "day17/testinput.txt") println("Day 17 part 1. Highest point: ${result}") } fun solve(iterations: Int, jetsFile: String): Int { ...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
1,651
aoc2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day15/day15.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day15 import biz.koziolek.adventofcode.Coord import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val sensors = parseSensors(inputFile.bufferedReader().readLines()) println("Positions with y=2000000 without beacons: ${coun...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
3,978
advent-of-code
MIT License
solutions/src/MaximumSubArraySum.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import kotlin.test.currentStackTrace /** * https://leetcode.com/problems/k-concatenation-maximum-sum/ */ class MaximumSubArraySum { fun kConcatenationMaxSum(arr: IntArray, k: Int): Int { val MOD = 1000000007 if (arr.none { it < 0 }) { return ((arr.sum()*k.toLong()) % MOD).toInt() ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
2,209
leetcode-solutions
MIT License
src/Day03.kt
maxonof
572,454,805
false
{"Kotlin": 5967}
fun main() { val input = readInput("input03") val uppercase = 'A' until '[' val lowercase = 'a' until '{' val values = (lowercase + uppercase).zip(1 until 53).toMap() println(part1(input, values)) println(part2(input, values)) } fun findCommon(line: String): Char { val mid = line.length / 2...
0
Kotlin
0
0
ef03fc65dcd429d919eb12d054ce7c052780d7d7
851
aoc-2022-in-kotlin
Apache License 2.0
solutions/aockt/y2023/Y2023D03.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.spacial.Point import aockt.util.spacial.Area import aockt.util.spacial.coerceIn import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D03 : Solution { /** A part number label in the engine schematics, drawn at [coords] with a numeric [value]. */ ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,462
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-19.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText import kotlin.math.min fun main() { val input = readInputText(2015, "19-input") val test1 = readInputText(2015, "19-test1") val test2 = readInputText(2015,...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,849
advent-of-code
MIT License
src/year2020/day03/Day03.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day03 import java.awt.Dimension import java.awt.Point import java.math.BigDecimal import util.assertTrue import util.read2020DayInput fun main() { val input = read2020DayInput("Day03") assertTrue(task01(input) == 242) assertTrue(task02(input) == BigDecimal.valueOf(2265549792)) } private ...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
2,473
advent-of-code-kotlin-template
Apache License 2.0
src/day12/Day12.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day12 import Position import log import logEnabled import logln import readInput private const val DAY_NUMBER = 12 typealias Height = Char private const val NOT_VISITED = -1 fun main() { fun parseMap(rawInput: List<String>): Triple<Array<Array<Height>>, Position, Position> { val heightMap = Arr...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
5,188
advent-of-code-2022
Apache License 2.0
src/Day07.kt
phamobic
572,925,492
false
{"Kotlin": 12697}
private const val ROOT = "/" private const val PARENT_DIRECTORY = ".." private const val MARK_DIRECTORY = "dir" private const val FILE_SIZE_DELIMITER = " " private const val COMMAND_CHANGE_DIRECTORY = "$ cd " private const val COMMAND_LIST_DIRECTORY = "$ ls" private const val MAX_DIRECTORY_SIZE = 100000 private const...
1
Kotlin
0
0
34b2603470c8325d7cdf80cd5182378a4e822616
4,067
aoc-2022
Apache License 2.0
src/Day11.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
fun main() { data class Monkey( val id: String, val items: MutableList<Long>, val inspection: (Long) -> Long, val test: Int, val ifTrue: String, val ifFalse: String ) { var inspectedItems = 0L fun inspectItems(afterInspection: (Long) -> Long): Lis...
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
3,145
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import kotlin.collections.ArrayDeque fun main() { fun solution(input: List<String>, part2: Boolean): String { val stacks: List<ArrayDeque<Char>> = (0 until ((input[0].length + 1) / 4)) .map { return@map ArrayDeque<Char>() } .toList() val initial = input.takeWhile { l -> l.isN...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
1,520
aoc-2022
Apache License 2.0
2022/main/day_12/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_12_2022 import java.io.File fun Pair<Int, Int>.directNeighbors(): MutableList<Pair<Int, Int>> { val list = mutableListOf<Pair<Int, Int>>() for (yOff in -1..1) { for (xOff in -1..1) { //if not diagonal or self if ((xOff == 0) xor (yOff == 0)) { list....
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
3,531
AdventofCode
MIT License
2022/Day11/problems.kt
moozzyk
317,429,068
false
{"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794}
import java.io.File import java.util.ArrayDeque class Monkey( var items: ArrayDeque<Long>, val operation: Char, val operand: String, val divisor: Int, val targetIfTrue: Int, val targetIfFalse: Int ) { var timesInspected = 0 fun getItem(): Long { timesIns...
0
Rust
0
0
c265f4c0bddb0357fe90b6a9e6abdc3bee59f585
2,606
AdventOfCode
MIT License
src/aoc2023/Day14.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput fun main() { val (year, day) = "2023" to "Day14" fun loadSum(input: List<String>, maxCycles: Int): Int { var state = PlatformState(input.map { it.toCharArray() }.toTypedArray()) var totalLoad: Int? = null when (maxCycles) { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
3,659
aoc-kotlin
Apache License 2.0
src/Day04.kt
Lonexera
573,177,106
false
null
fun main() { fun String.mapToElvesSections(): Pair<List<Int>, List<Int>> { val sections = split(",") .map { sections -> val (start, end) = sections .split("-") .map { it.toInt() } .zipWit...
0
Kotlin
0
0
c06d394cd98818ec66ba9c0311c815f620fafccb
1,306
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-09.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2023, "09-input") val test1 = readInputLines(2023, "09-test1") println("Part1:") part1(test1).println() p...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,319
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinCost.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,854
kotlab
Apache License 2.0
src/Day07.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { val day = "Day07" fun buildFSTree(input: List<String>): FSTree { val fsTree = FSTree("/") var currentDirectory = fsTree input.drop(1) // skip the first one. It's manually created above .forEach { line -> when { line.isMoveOu...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
2,966
advent-of-code-2022
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day25/Day25.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day25 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.UnionFind import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 25](https://adventofcode.com/2023/day/25) */ object Day25 : DayOf2023(25) { override fun first(): Any? ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,640
adventofcode
MIT License