path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/com/jacobhyphenated/advent2023/day19/Day19.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day19 import com.jacobhyphenated.advent2023.Day import com.jacobhyphenated.advent2023.product /** * Day 19: Aplenty * * There is an elaborate system for telling if a part is approved or rejected. * Each part has 4 categories (x, m, a, s) * Each workflow has a series of step...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
6,781
advent2023
The Unlicense
src/twentythree/Day02.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentythree fun main() { val day = "02" // test if implementation meets criteria from the description: println("Day$day Test Answers:") val testInput = readInputLines("Day${day}_test") val part1 = part1(testInput) part1.println() check(part1 == 8) val part2 = part2(testInput) ...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
3,574
advent-of-code-solutions
Apache License 2.0
src/main/kotlin/days/Day5.kt
C06A
435,034,782
false
{"Kotlin": 20662}
package days class Day5 : Day(5) { override fun partOne(): Any { return readLines(inputList).filter { it.isVertical() || it.isHorizontal() }.count() } override fun partTwo(): Any { return readLines(inputList).count() } } fun readLines(inputList: List<String>): Li...
0
Kotlin
0
0
afbe60427eddd2b6814815bf7937a67c20515642
1,801
Aoc2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/tr/emreone/adventofcode/days/Day11.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.math.Coords import tr.emreone.kotlin_utils.math.manhattanDistanceTo class Day11 : Day(11, 2023, "Cosmic Expansion") { class Galaxy(x: Int, y: Int) { var coord = Coords(x, y) fun dist...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
2,899
advent-of-code-2023
Apache License 2.0
src/main/kotlin/de/jball/aoc2022/day15/Day15.kt
fibsifan
573,189,295
false
{"Kotlin": 43681}
package de.jball.aoc2022.day15 import de.jball.aoc2022.Day import kotlin.math.abs class Day15(test: Boolean = false) : Day<Long>(test, 26L, 56_000_011L) { private val parserRegex = "Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)".toRegex() private val sensors = input.map { parse...
0
Kotlin
0
3
a6d01b73aca9b54add4546664831baf889e064fb
3,539
aoc-2022
Apache License 2.0
src/Day07.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
import java.lang.IllegalStateException import java.util.function.Predicate fun main() { fun part1(input: List<String>): Int { val rootDirectory = createDirectoryTree(input) val result = findDirectoriesWithSizeAtMost(rootDirectory, 100000) return result.sumOf { it.size } } fun part...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
3,555
advent-of-code-2022
Apache License 2.0
advent-of-code2016/src/main/kotlin/day13/Advent13.kt
REDNBLACK
128,669,137
false
null
package day13 import day13.Pos.Pos2D import java.util.* /** --- Day 13: A Maze of Twisty Little Cubicles --- You arrive at the first floor of this new building to discover a much less welcoming environment than the shiny atrium of the last one. Instead, you are in a maze of twisty little cubicles, all alike. Every ...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,119
courses
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day11.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 class Day11(input: List<String>) { private val directionOffsets = (-1..1).flatMap { a -> (-1..1).map { b -> a to b } }.minus(0 to 0) private val inputSeatGrid = input.map { row -> row.map { when (it) { 'L' -> false '#' -...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,394
advent-of-code
Apache License 2.0
src/day07/Day07.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day07 import readLines fun main() { val id = "07" val testOutput = 95437 fun readTerminalOutput(fileName: String): List<String> { return readLines(fileName) } fun createFileSystemTree(input: List<String>): FileSystemNode.Directory { val rootNode = FileSystemNode.Director...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
4,104
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-02.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.readInputLines fun main() { val input = readInputLines(2015, "02-input") val test1 = readInputLines(2015, "02-test1") println("Part1:") calculatePaper(test1).printl...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,147
advent-of-code
MIT License
src/day03/Day03.kt
emartynov
572,129,354
false
{"Kotlin": 11347}
package day03 import readInput private fun Char.toScore() = if (isLowerCase()) this - 'a' + 1 else this - 'A' + 27 fun main() { fun part1(input: List<String>): Int { return input.map { rugzakContent -> rugzakContent.chunked(size = rugzakContent.length / 2) }.map { compartment...
0
Kotlin
0
1
8f3598cf29948fbf55feda585f613591c1ea4b42
1,363
advent-of-code-2022
Apache License 2.0
src/Day09.kt
davedupplaw
573,042,501
false
{"Kotlin": 29190}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Position(var x: Int, var y: Int) { fun moveX(v: Int) { x += v } fun moveY(v: Int) { y += v } fun toPair() = Pair(x, y) } fun moveHead(command: String, headPosition: Posi...
0
Kotlin
0
0
3b3efb1fb45bd7311565bcb284614e2604b75794
2,538
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/day6.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut import utils.mapItems fun main() { Day6.run(skipTest = false) } object Day6 : Solution<List<Day6.Race>>() { override val name = "day6" override val parser = Parser.lines.mapItems { input -> input.cut(":").second.split(" ").mapNotNull { it.trim().ta...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,214
aoc_kotlin
MIT License
src/main/kotlin/solutions/year2022/Day4.kt
neewrobert
573,028,531
false
{"Kotlin": 7605}
package solutions.year2022 import readInputLines /** * split te pairs * * compare both to see which if one pair is fully contained in the other * * count */ fun main() { fun getSectionRange(line: String): List<IntRange> { return line.split(",").map { pairs -> val (a, b) = pairs.split("-...
0
Kotlin
0
0
7ecf680845af9d22ef1b9038c05d72724e3914f1
1,144
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.abs import kotlin.math.sign private fun moves(): List<Pair<String, Int>> { return readInput("Day09").map { it.split(" ") }.map { Pair(it[0], it[1].toInt()) } } private fun part1(moves: List<Pair<String, Int>>): Int = uniqueTailPositions(moves, 2) private fun part2(moves: List<Pair<String, Int>>...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,352
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/leonra/adventofcode/advent2023/day05/Day5.kt
LeonRa
726,688,446
false
{"Kotlin": 30456}
package com.leonra.adventofcode.advent2023.day05 import com.leonra.adventofcode.shared.readResource /** https://adventofcode.com/2023/day/5 */ private object Day5 { data class Mapping(val source: LongRange, val diff: Long) fun partOne(): Long { val mapped = mutableSetOf<Long>() val ranges = ...
0
Kotlin
0
0
46bdb5d54abf834b244ba9657d0d4c81a2d92487
3,970
AdventOfCode
Apache License 2.0
src/Day11.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b) fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b data class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val test: Long, val ifTrue: Int, val ifFalse: Int, ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
3,534
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/problems/arrayandstrings/DetermineDNAHealth.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.problems.arrayandstrings import java.util.* fun main(args: Array<String>) { // val scan = Scanner(System.`in`) // // val n = scan.nextLine().trim().toInt() // // val genes = scan.nextLine().split(" ").toTypedArray() // // val health = scan.nextLine().split(" ").map{ it.trim(...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,958
DS_Algo_Kotlin
MIT License
string-similarity/src/commonMain/kotlin/com/aallam/similarity/RatcliffObershelp.kt
aallam
597,692,521
false
null
package com.aallam.similarity /** * The Ratcliff/Obershelp algorithm computes the similarity of two strings the doubled number of matching characters * divided by the total number of characters in the two strings. Matching characters are those in the longest common * subsequence plus, recursively, matching characte...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
2,513
string-similarity-kotlin
MIT License
src/Day06.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
import java.util.LinkedList import java.util.Queue fun main() { fun getFirstStartOfPacketMarker(input: List<String>, distinctCharacters: Int): List<Int> { return input.map outer@{ text -> val queue: Queue<Char> = LinkedList(text.take(distinctCharacters - 1).toList()) val dict = text...
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
1,407
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day14/Day14.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day14 import readToList import java.util.UUID private val input = readToList("day14.txt") fun main() { val template = input.first() .mapIndexed { index, char -> Element(char, index.toString()) } val rules = input.drop(2) .map { line -> val (pair, insertion) = line.split("...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
2,075
aoc2021
Apache License 2.0
src/main/kotlin/day24.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
const val MIN_INTERSECTION = 200000000000000.0 const val MAX_INTERSECTION = 400000000000000.0 fun day24 (lines: List<String>) { val hailstones = parseHailstones(lines) val intersections = mutableListOf<Intersection>() for (i in hailstones.indices) { for (j in i + 1..hailstones.indices.las...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
2,311
advent_of_code_2023
MIT License
src/main/kotlin/net/mguenther/adventofcode/day24/Day24.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day24 /** * @author <NAME> (<EMAIL>) */ class ElectromagneticHost { private fun initialComponents(components: List<Component>) = components.filter { c -> c.hasZeroPin() } private fun candidates(components: List<Component>, tail: Component) = compon...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
2,174
advent-of-code-2017
MIT License
kotlin/src/katas/kotlin/convolve-fft/zero-sum-triplets.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.`convolve-fft` import com.natpryce.hamkrest.assertion.assertThat import com.natpryce.hamkrest.equalTo import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertTimeoutPreemptively import java.time.Duration import kotlin.random.Random // // https://leetcode.com/problems/3sum // https://...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,926
katas
The Unlicense
src/main/kotlin/Day17.kt
akowal
434,506,777
false
{"Kotlin": 30540}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min fun main() { println(Day17.solvePart1()) println(Day17.solvePart2()) } object Day17 { private val targetTopLeft: Point private val targetBottomRight: Point init { val input = readInput("day17").single() ...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
1,626
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/Day07a.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { val day = "Day07" fun parseInput(input: List<String>): List<Int> { var path = "/root" var dirs = mutableListOf<String>("root") var paths:MutableMap<String, Int> = mutableMapOf() input .drop(1) .forEach { line -> when { ...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
1,932
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/briarshore/aoc2022/day07/NoSpaceLeftOnDevicePuzzle.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day07 import println import readInput fun main() { fun shared(input: List<String>): Map<String, Int> { return buildMap { put("", 0) var cwd = "" input.fold(this) { acc, value -> run { when { ...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
2,224
2022-AoC-Kotlin
Apache License 2.0
src/Day04.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
fun main() { fun String.toRange(): Pair<IntRange, IntRange> = this.split(',') .map { it.takeWhile { c -> c.isDigit() }.toInt()..it.takeLastWhile { c -> c.isDigit() }.toInt() } .let { Pair(it[0], it[1]) } fun part1(input: List<String>): Int { return input.map { it.toRange...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
818
advent-of-code-kotlin
Apache License 2.0
src/org/aoc2021/Day9.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path object Day9 { data class Point(val x: Int, val y: Int) private fun solvePart1(lines: List<String>): Int { val heights = lines.map { line -> line.map(Char::digitToInt) } val lowPoints = findLowPoints(h...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
2,851
advent-of-code-2021
The Unlicense
src/Day07.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
private val file = "Day07" //private val file = "Day07Example" private sealed class Instruction { data class CD(val target: String) : Instruction() object LS : Instruction() data class FileSizeInfo(val file: String, val size: Long) : Instruction() data class DirectoryInfo(val name: String) : Instructio...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
2,572
aoc-2022
Apache License 2.0
src/main/kotlin/day06_lanternfish_growth/LanternfishGrowth.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day06_lanternfish_growth import histogram.Histogram import histogram.buildHistogram import histogram.count import histogram.total import util.saveTextFile import java.io.PrintWriter /** * The first analysis day! Implementing a solution based on the description of * the "business" problem will get it done, b...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,645
aoc-2021
MIT License
src/Day08.kt
Sasikuttan2163
647,296,570
false
null
import kotlin.math.abs fun main() { val input = readInput("Day08") var matrix = mutableListOf<MutableList<Int>>() var part1 = 0 matrix = input.foldIndexed(mutableListOf<MutableList<Int>>()) { index, matrix, line -> matrix.add(line.map { it -> it.digitToInt() }.toMutableList()) matrix ...
0
Kotlin
0
0
fb2ade48707c2df7b0ace27250d5ee240b01a4d6
2,905
AoC-2022-Solutions-In-Kotlin
MIT License
src/Day02.kt
Frendzel
573,198,577
false
{"Kotlin": 5336}
/** * Rock - A, X -> 1 point * Paper - B, Y -> 2 points * Scissors - C, Z -> 3 points * * Won -> 6 * Draw -> 3 * Lose -> 0 */ private val gameToPoints: Map<String, Int> = mapOf( "A X" to 1 + 3, "A Y" to 2 + 6, "A Z" to 3 + 0, "B X" to 1 + 0...
0
Kotlin
0
0
a8320504be93dfba1f634413a50e7240d16ba6d9
1,491
advent-of-code-kotlin
Apache License 2.0
src/day03/Day03.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day03 import readInput private const val DAY_ID = "03" fun main() { fun itemPriority(c: Char): Int = if (c.isLowerCase()) c - 'a' + 1 else c - 'A' + 27 fun part1(input: List<String>): Int = input.sumOf { rucksack -> val h1 = rucksack.substring(0, rucksack.length / 2).toSet() ...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
1,235
aoc-2022-in-kotlin
Apache License 2.0
src/Day01.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
fun main() { fun part1(input: List<String>): Int { var mutInput: List<String> = input var maxCalorie = 0 var elfSnacks: List<Int> var curCalorie: Int while (mutInput.isNotEmpty()){ elfSnacks = mutInput.takeWhile { !it.isEmpty() }.map { it.toInt() } cur...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
1,299
aoc22
Apache License 2.0
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/warmUpChallenges/clouds/JumpingOnClouds.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.warmUpChallenges.clouds import java.util.* private const val MAX_CLOUDS = 100 private const val MIN_CLOUDS = 2 fun jumpingOnClouds(clouds: Array<Int>): Int { checkRequirement(clouds) fun isThunder(cloud: Int) = cloud == 1 val (totalPenal...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
1,853
kotlin-hackerrank
MIT License
src/main/kotlin/_2021/Day3.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2021 import REGEX_LINE_SEPARATOR import aoc fun main() { aoc(2021, 3) { aocRun { input -> val bitList = input.split(REGEX_LINE_SEPARATOR).map { it.toBinaryByteArray() } val numOfOnes = numberOfOnes(bitList) val listSizeHalf = bitList.size / 2 val mostSigBits = numOfOnes.map { if (it >= listSiz...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
2,307
AdventOfCode
Creative Commons Zero v1.0 Universal
lib_algorithms_sort_kotlin/src/main/java/net/chris/lib/algorithms/sort/kotlin/KTRadixSorter.kt
chrisfang6
105,401,243
false
{"Java": 68669, "Kotlin": 26275, "C++": 12503, "CMake": 2182, "C": 1403}
package net.chris.lib.algorithms.sort.kotlin /** * Radix sort. */ abstract class KTRadixSorter : KTSorter() { override fun subSort(array: IntArray) { if (array == null) { return } val d = getDigit(array) var n = 1//代表位数对应的数:1,10,100... var k = 0//保存每一位排序后的结果用于...
0
Java
0
0
1f1c2206d5d9f0a3d6c070a7f6112f60c2714ec0
1,889
sort
Apache License 2.0
src/main/kotlin/Day02.kt
arosenf
726,114,493
false
{"Kotlin": 40487}
import kotlin.math.max import kotlin.system.exitProcess fun main(args: Array<String>) { if (args.isEmpty() or (args.size < 2)) { println("Games document not specified") exitProcess(1) } val fileName = args.first() println("Reading $fileName") val lines = readLines(fileName) val...
0
Kotlin
0
0
d9ce83ee89db7081cf7c14bcad09e1348d9059cb
2,439
adventofcode2023
MIT License
src/main/kotlin/com/ginsberg/advent2022/Day11.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 11 - Monkey in the Middle * Problem Description: http://adventofcode.com/2022/day/11 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day11/ */ package com.ginsberg.advent2022 class Day11(input: List<String>) { pr...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
2,642
advent-2022-kotlin
Apache License 2.0
day9/src/main/kotlin/aoc2015/day9/Day9.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day9 import aoc2015.utility.allPermutations object Day9 { fun findShortestRoute() = distances().min()!! fun findLongestRoute() = distances().max()!! private fun distances(): List<Int> { val distances = input.map { Parser.parse(it) } val map = distances .a...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
2,635
aoc2015
Apache License 2.0
src/Day05.kt
oleskrede
574,122,679
false
{"Kotlin": 24620}
fun main() { /* I didn't bother with parsing the stacks as they were specified in the initial input. So I rotated them clockwise. E.g. the example input became: ZN MCD P move 1 from 2 to 1 ... */ fun parseInput(input: List<String>): Pair<MutableList<Mut...
0
Kotlin
0
0
a3484088e5a4200011335ac10a6c888adc2c1ad6
2,123
advent-of-code-2022
Apache License 2.0
src/Day01/Day01.kt
S-Flavius
573,063,719
false
{"Kotlin": 6843}
package day01 import readInput import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var curMax = -1 var curElf = 0 for (line in input) when { line.isNotEmpty() -> curElf += line.toInt() else -> { curMax = max(curMax, curElf) ...
0
Kotlin
0
0
47ce29125ff6071edbb07ae725ac0b9d672c5356
2,002
AoC-Kotlin-2022
Apache License 2.0
2022/src/test/kotlin/Day14.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe private data class Unit(var x: Int, var y: Int) class Day14 : StringSpec({ "puzzle part 01" { val rocks = getRocks() val countOfSand = rocks.produceSand() - rocks.count() countOfSand shouldBe 808 } "p...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,353
adventofcode
MIT License
Kotlin/DiameterBinaryTree.kt
sukritishah15
299,329,204
false
null
/** * Algorithm: Diameter of Binary Tree * Language: Kotlin * Input: * Sample Binary Tree * Output: * Diameter of Binary Tree * Time Complexity: O(n) as we are visiting every node once. * Space Complexity: O(d) where d is the depth of the binary tree * * Sample Input: * 8 * ...
164
Java
295
955
1b6040f7d9af5830882b53916e83d53a9c0d67d1
1,716
DS-Algo-Point
MIT License
src/Day04.kt
paulbonugli
574,065,510
false
{"Kotlin": 13681}
fun main() { fun determineRange(range: String): IntRange { val (first, last) = range.split("-").map { it.toInt() } return IntRange(first, last) } fun parseInput(input: List<String>): List<Pair<IntRange, IntRange>> { return input.map { it.split(",") }.map { determineRange...
0
Kotlin
0
0
d2d7952c75001632da6fd95b8463a1d8e5c34880
1,081
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
0xBuro
572,308,139
false
{"Kotlin": 4929}
fun main() { fun encryptedStrategyGuide(input: String): List<List<String>> { return input.replace(" ", "").split("\n") .map { it.lines() } } fun getShapeWeight(shape: Char): Int { if(shape == 'X') { return 1 //rock } if(shape == 'Y') { re...
0
Kotlin
0
0
c05c4db78e24fc36f6f112bc1e8cf24ad5fd7698
2,545
Advent-of-Kotlin
Apache License 2.0
src/questions/LongestIncreasingSubSeq.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import utils.shouldBeOneOf /** * Given an integer array nums, return the longest strictly increasing subsequence. * A subsequence is a sequence that can be derived from an array by deleting some or no elements * without changing the or...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,522
algorithms
MIT License
day17/src/main/kotlin/aoc2015/day17/Day17.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day17 object Day17 { private const val TARGET_LITRES = 150 fun findAmountOfTargetCombinations(): Int { val buckets = input.map { Parser.parse(it) } val factors = Factors(buckets.size) return factors.asSequence() .map { buckets * it } .f...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
2,676
aoc2015
Apache License 2.0
src/leetcode/juneChallenge2020/weekfive/WordSearchII.kt
adnaan1703
268,060,522
false
null
package leetcode.juneChallenge2020.weekfive import utils.print fun main() { val board = arrayOf( charArrayOf('o', 'a', 'a', 'n'), charArrayOf('e', 't', 'a', 'e'), charArrayOf('i', 'h', 'k', 'r'), charArrayOf('i', 'f', 'l', 'v') ) findWords(board, arrayOf("oath", "pea", "eat...
0
Kotlin
0
0
e81915db469551342e78e4b3f431859157471229
2,803
KotlinCodes
The Unlicense
src/Day08.kt
stcastle
573,145,217
false
{"Kotlin": 24899}
import kotlin.math.max /** Holds values for the max tree height in all directions leading up to this spot. */ data class MaxTreeHeight( var north: Int = -1, var east: Int = -1, var south: Int = -1, var west: Int = -1 ) fun MaxTreeHeight.treeIsVisible(tree: Int) = tree > north || tree > east || tre...
0
Kotlin
0
0
746809a72ea9262c6347f7bc8942924f179438d5
4,503
aoc2022
Apache License 2.0
src/main/kotlin/aoc2023/Day12.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils val dots = "\\.+".toRegex() fun String.replaceAt(index: Int, c: Char): String { val sb = StringBuilder(this) sb.setCharAt(index, c) return sb.toString() } fun main() { val testInput = """???.### 1,1,3 .??..??...?##. 1,1,3 ?#?#?#?#?#?#?#? 1,3,1,6 ????.#...#... 4...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,983
aoc-2022-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day11.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.product fun PuzzleSet.day11() = puzzle { val monkeys = input.split("\n\n").map { m -> val (items, op, test, t, f) = m.lines().drop(1) val (operator, operand) = op.split(" ").takeLast(2) va...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,991
advent-of-code
The Unlicense
src/main/kotlin/aoc2018/RegularMap.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2018 import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Direction.* import komu.adventofcode.utils.Point import utils.shortestPathBetween fun regularMap(input: String) = RoomMap.create(input).solution() fun regularMap2(input: String) = RoomMap.create(input).s...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
4,003
advent-of-code
MIT License
src/Day03/Day03.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day03 import readInput import java.lang.Error import java.util.BitSet fun charToInt(char: Char): Int { val asciiValue = char.code return when(asciiValue) { in 65..90 -> asciiValue - 38 in 97..122 -> asciiValue - 96 else -> 0 } } fun findCommonInt(leftInput: List<Int>, rig...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
2,102
advent-of-code-2022
Apache License 2.0
gcj/y2023/farewell_d/a_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2023.farewell_d private fun solve(): String { val (nLeft, nRight, c) = readInts() val (leftIn, rightIn) = List(2) { readInts().map { it - 1 } } val n = nLeft + nRight return List(c) { val (cu, cvIn) = readInts().map { it - 1 } val cv = nLeft + cvIn val nei = List(n) { mutableListOf<Int>() } fu...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,128
competitions
The Unlicense
src/Day03.kt
makohn
571,699,522
false
{"Kotlin": 35992}
fun main() { fun part1(input: List<String>): Int { val items = mutableListOf<Char>() for (r in input) { outer@for (c in 0 until r.length/2) { for (c2 in r.length/2 until r.length) { if (r[c] == r[c2]) { items.add(r[c]) ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
1,245
aoc-2022
Apache License 2.0
src/Day04.kt
kprow
573,685,824
false
{"Kotlin": 23005}
fun main() { class SectionAssignment { val start: Int val end: Int val sequence: IntArray constructor(assignment: String) { val startEnd = assignment.split("-") this.start = startEnd[0].toInt() this.end = startEnd[1].toInt() this.sequen...
0
Kotlin
0
0
9a1f48d2a49aeac71fa948656ae8c0a32862334c
1,974
AdventOfCode2022
Apache License 2.0
src/Day03.kt
rtperson
434,792,067
false
{"Kotlin": 6811}
fun main() { fun countBitN(input: List<String>, n: Int): Int { var ones = 0 var zeroes = 0 for (y in input.indices) { when (input[y][n]) { '0' -> zeroes++ '1' -> ones++ } } if (zeroes > ones) return 0 else return 1 ...
0
Kotlin
0
0
ae827a46c8aba336a7d46762f4e1a94bc1b9d850
2,098
Advent_of_Code_Kotlin
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day05.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 object Day05 { fun part1(input: List<String>): String = process(input) { it.reversed() } fun part2(input: List<String>): String = process(input) { it } private fun process(input: List<String>, mapper: (String) -> String): String { val (stacks, instructions) = input.index...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
1,586
advent22
Apache License 2.0
src/Day04.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
fun main() { fun part1(input: List<String>): Int { var summary = 0 for (line in input) { val (first, second) = line.split(',').let { Pair(it[0], it[1]) } val firstRange = first.split('-').let { it[0].toInt()..it[1].toInt() } val secondRange = second.split('-').l...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
1,465
aoc-2022
Apache License 2.0
day11/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Part Two --- // The galaxies are much older (and thus much farther apart) than the // researcher initially estimated. // // Now, instead of the expansion you did before, make each empty row or column // one million times larger. That is, each empty row should be replaced with // 1000000 empty rows, and each empt...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
2,246
adventofcode2023
MIT License
src/Day04.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
fun main() { fun part1(input: List<String>): Int { var count = 0 input.forEach { line -> val (range1, range2) = line.split(",").map { assignment -> assignment.split("-").map { it.toInt() }.let { (it.first()..it.last()) } } if ((range1.first <= rang...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
1,135
advent-of-code-2022
Apache License 2.0
src/Day03.kt
muellerml
573,601,715
false
{"Kotlin": 14872}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> val split = line.count() / 2 val first = line.take(split) val last = line.takeLast(split) val character = first.first { last.contains(it) } val value = character.getVal...
0
Kotlin
0
0
028ae0751d041491009ed361962962a64f18e7ab
1,044
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2021/Day01.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import java.util.* /** * @return a sequence of the result of the [compareTo] invocation on each element and its predecessor */ private fun <T : Comparable<T>> Sequence<T>.compareWithPrevious(): Sequence<Int> { val input = this return sequence { yield(0) var p...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,188
adventOfCode
Apache License 2.0
solutions/aockt/y2021/Y2021D17.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import io.github.jadarma.aockt.core.Solution import kotlin.math.absoluteValue import kotlin.math.sign object Y2021D17 : Solution { /** Represents a discrete point in 2D space. */ private data class Point(val x: Int, val y: Int) /** Generates the sequence of all the triangular numbers...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,186
advent-of-code-kotlin-solutions
The Unlicense
src/day02/Day02.kt
sanyarajan
572,663,282
false
{"Kotlin": 24016}
package day02 import readInput enum class RPSOptions { ROCK, PAPER, SCISSORS; companion object { fun beatenBy(rpsOptions: RPSOptions): RPSOptions { return when (rpsOptions) { ROCK -> PAPER PAPER -> SCISSORS SCISSORS -> ROCK } ...
0
Kotlin
0
0
e23413357b13b68ed80f903d659961843f2a1973
3,752
Kotlin-AOC-2022
Apache License 2.0
src/main/kotlin/Day01V2Simplified.kt
rgawrys
572,698,359
false
{"Kotlin": 20855}
import utils.readRawInput fun main() { fun part1(input: String): Int = maxCaloriesOfElves(input) fun part2(input: String): Int = sumCaloriesOfTopElves(input, 3) // test if implementation meets criteria from the description, like: val testInput = readRawInput("Day01_test") part1(testInput).let { ...
0
Kotlin
0
0
5102fab140d7194bc73701a6090702f2d46da5b4
1,199
advent-of-code-2022
Apache License 2.0
src/Day11.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import java.util.* fun main() { val testInput = readInput("Day11_test") check(part1(testInput) == 10605L) check(part2(testInput) == 2713310158L) val input = readInput("Day11") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Long { val monkeys = input....
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
4,478
AOC2022
Apache License 2.0
y2017/src/main/kotlin/adventofcode/y2017/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution import adventofcode.util.collections.takeWhileDistinct object Day16 : AdventSolution(2017, 16, "Permutation Promenade") { override fun solvePartOne(input: String): String = dance(parseInput(input), "abcdefghijklmnop") //There's actually a small upp...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,024
advent-of-code
MIT License
src/main/kotlin/aoc2022/Day11.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* class Day11 { sealed class Argument { data class Number(val value: Long) : Argument() object Old : Argument() } data class Monkey( val index: Int, var items: List<Long>, val operator: Pair<(Long, Long) -> Long, Argu...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
2,779
aoc-kotlin
Apache License 2.0
src/Day04.kt
jamesrobert
573,249,440
false
{"Kotlin": 13069}
typealias Section = Pair<Int, Int> fun main() { fun parseSectionRange(item: String): Section = item.split('-') .map { it.toInt() } .let { (first, second) -> Pair(first, second) } fun calculateOverlap(input: List<String>, compare: (Section, Section) -> Int?): Int = input...
0
Kotlin
0
0
d0b49770fc313ae42d802489ec757717033a8fda
1,435
advent-of-code-2022
Apache License 2.0
2021/src/main/kotlin/com/github/afranken/aoc/Day202104.kt
afranken
434,026,010
false
{"Kotlin": 28937}
package com.github.afranken.aoc object Day202104 { fun part1(inputs: Array<String>): Int { val draws = inputs[0].split(',') val boards = inputs .drop(1) .filter { it.isNotEmpty() } .chunked(5) .map { Board.of(it.map { ...
0
Kotlin
0
0
0140f68e60fa7b37eb7060ade689bb6634ba722b
3,171
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SumOfFlooredPairs.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,500
kotlab
Apache License 2.0
src/Day05.kt
roxanapirlea
572,665,040
false
{"Kotlin": 27613}
private data class Procedure(val count: Int, val from: Int, val to: Int) fun main() { fun String.getStackedCrates(): List<ArrayDeque<Char>> { val linesOfCrates = substringBefore("${System.lineSeparator()}${System.lineSeparator()}") .split(System.lineSeparator()) .map { ...
0
Kotlin
0
0
6c4ae6a70678ca361404edabd1e7d1ed11accf32
2,504
aoc-2022
Apache License 2.0
Algorithms/Search/Minimum Loss/Solution.kt
ahmed-mahmoud-abo-elnaga
449,443,709
false
{"Kotlin": 14218}
/* Problem: https://www.hackerrank.com/challenges/minimum-loss Kotlin Language Version Tool Version : Android Studio Initial Thoughts: We can sort the array to reduce the number of comparisons since we know that the absolute difference is always smallest between ...
0
Kotlin
1
1
a65ee26d47b470b1cb2c1681e9d49fe48b7cb7fc
2,048
HackerRank
MIT License
src/main/kotlin/aoc23/Day13.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day13Domain.PointOfIncidence import aoc23.Day13Parser.toPointsOfIncidence import common.Collections.partitionedBy import common.Strings.transpose import common.Year23 object Day13 : Year23 { fun List<String>.part1(): Int = toPointsOfIncidence(targetNumberOfDifferences = 0) ...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
2,394
aoc
Apache License 2.0
src/main/kotlin/y2023/day08/Day08.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2023.day08 import NumberStuff fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } data class Input( val instruction: String, val maps: Map<String, Pair<String,String>> ) fun input(): Input { val lines = AoCGenerics.getInputLines...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,998
AdventOfCode
MIT License
src/main/kotlin/utils/graphs/Graph.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package utils.graphs import utils.SortedLookup // Not immutable by any means data class Node<T>(val value: T) { val edges: MutableSet<Edge<T>> = mutableSetOf() fun link(distance: Long, target: Node<T>) { edges.add(Edge(distance, target)) } fun link(distance: Long, targets: List<Node<T>>) {...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
2,951
adventOfCode2021
Apache License 2.0
src/Day05.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
data class Instruction(val qty: Int, val from: Int, val to: Int) fun main() { fun initStack(columns: Int): List<ArrayDeque<String>> = buildList { for (x in 0 until columns) { add(ArrayDeque()) } } fun parseToStack(input: List<String>): List<ArrayDeque<String>> { var c...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
3,209
aoc2022
Apache License 2.0
src/main/kotlin/aoc22/Day19.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import common.Collections.product import aoc22.Day19Domain.Blueprint import aoc22.Day19Domain.Material.* import aoc22.Day19Domain.RobotBlueprint import aoc22.Day19Domain.State import aoc22.Day19Parser.toBluePrints import aoc22.Day19Runner.GeodeFactory import aoc22.Day19Solution.part1Day19 import aoc22.Da...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
7,111
aoc
Apache License 2.0
src/Day09.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import kotlin.math.abs import kotlin.math.sign fun main() { val testInput1 = readInput("Day09_test1") val testInput2 = readInput("Day09_test2") check(part1(testInput1) == 13) check(part2(testInput1) == 1) check(part2(testInput2) == 36) val input = readInput("Day09") println(part1(input)) ...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
1,831
AOC2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day10/Day10.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day10 import nl.sanderp.aoc.common.measureDuration import nl.sanderp.aoc.common.prettyPrint import nl.sanderp.aoc.common.readResource import java.util.* fun main() { val input = readResource("Day10.txt").lines().map { parse(it) } val (answer1, duration1) = measureDuration<Long>...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,148
advent-of-code
MIT License
src/main/kotlin/16_solution.kt
barta3
112,792,199
false
null
fun solve(input: List<String>, times: Int = 1): String { val sequence = mutableListOf<List<Char>>() var curr = (0 until 16).map { 'a' + it } repeat(times) { if (curr in sequence) { return sequence[times % sequence.size].joinToString(separator = "") } else { sequence.a...
0
Kotlin
0
0
51ba74dc7b922ac11f202cece8802d23011f34f1
1,412
AdventOfCode2017
MIT License
src/main/kotlin/day16.kt
bfrengley
318,716,410
false
null
package aoc2020.day16 import aoc2020.util.loadTextResource fun main(args: Array<String>) { val lines = loadTextResource("/day16.txt").lines() val fields = lines.takeWhile { it.isNotBlank() }.toList() val ticket = lines.drop(fields.size + 2).first().split(',').map { it.toInt() } val nearTickets = line...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,681
aoc2020
ISC License
src/main/kotlin/algorithms/SigmaTable.kt
Furetur
439,579,145
false
{"Kotlin": 21223, "ANTLR": 246}
package algorithms import model.Grammar import model.Lang import model.NonTerm private typealias SigmaInput = Pair<NonTerm, NonTerm> class SigmaTable(private val grammar: Grammar, private val firstTable: FirstTable, private val k: Int) { private var sigmas = mutableMapOf<SigmaInput, Set<Lang>>() private val ...
0
Kotlin
0
1
002cc53bcca6f9b591c4090d354f03fe3ffd3ed6
2,610
LLkChecker
MIT License
src/day11/Day11.kt
zypus
573,178,215
false
{"Kotlin": 33417, "Shell": 3190}
package day11 import AoCTask import java.math.BigInteger // https://adventofcode.com/2022/day/11 sealed class Operation { abstract operator fun invoke(value: BigInteger): BigInteger data class Add(val amount: BigInteger): Operation() { override fun invoke(value: BigInteger): BigInteger = value + am...
0
Kotlin
0
0
f37ed8e9ff028e736e4c205aef5ddace4dc73bfc
4,244
aoc-2022
Apache License 2.0
src/2023/Day07.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.util.* fun main() { Day07().solve() } class Day07 { val input1 = """ 32T3K 765 T55J5 684 KK677 28 KTJJT 220 QQQJA 483 """.trimIndent() fun String.rank1(): Long { val m = mutableMapOf<Char, Int>() ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
3,174
advent-of-code
Apache License 2.0
src/Day02.kt
polbins
573,082,325
false
{"Kotlin": 9981}
fun main() { // Rock/Paper/Scissor = 1,2,3 // Lose/Draw/Win = 0,3,6 fun part1(input: List<String>): Int { var result = 0 for (s in input) { val left = s[0].toScore() val right = s[2].toScore() val outcome = when (right - left) { 1, -2 -> 6 // greater or -overlap (rock - scissor)...
0
Kotlin
0
0
fb9438d78fed7509a4a2cf6c9ea9e2eb9d059f14
1,478
AoC-2022
Apache License 2.0
src/Day10.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
fun main() { fun getProgram(line: String): ProgramLine = if (line == "noop") { ProgramLine(1, 0) } else { ProgramLine(2, line.split(" ")[1].toInt()) } fun getSignalStrengthList(input: List<String>): List<Int> { val signalStrengthList = ArrayList<Int>() ...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
1,588
aoc22
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumBuildingHeight.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
3,684
kotlab
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem179/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem179 /** * LeetCode page: [179. Largest Number](https://leetcode.com/problems/largest-number/); */ class Solution { /* Complexity: * Time O(NLogN) and Space O(N) where N is the size of nums; */ fun largestNumber(nums: IntArray): String { val sortedBucket...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,043
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/dev/siller/aoc2023/Day04.kt
chearius
725,594,554
false
{"Kotlin": 50795, "Shell": 299}
package dev.siller.aoc2023 import java.util.LinkedList import kotlin.math.pow data object Day04 : AocDayTask<UInt, UInt>( day = 4, exampleInput = """ |Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 |Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 |Card 3: 1 21 53 59 44 | 69...
0
Kotlin
0
0
fab1dd509607eab3c66576e3459df0c4f0f2fd94
2,710
advent-of-code-2023
MIT License
src/Day05.kt
RandomUserIK
572,624,698
false
{"Kotlin": 21278}
import java.util.* private const val STACK_DISTANCE = 4 data class Directive( val numberOfCrates: Int, val from: Int, val to: Int, ) fun List<String>.toStacks(): List<Stack<Char>> { val numberOfStacks = last().split(" ").size val result = List(numberOfStacks) { Stack<Char>() } takeWhile { it.contains("[") }.r...
0
Kotlin
0
0
f22f10da922832d78dd444b5c9cc08fadc566b4b
1,831
advent-of-code-2022
Apache License 2.0
lib/src/main/kotlin/aoeiuv020/DynamicProgramming.kt
AoEiuV020
85,785,447
false
{"Java": 22453, "Kotlin": 2576}
package aoeiuv020 import java.util.* typealias StringBuilder = java.lang.StringBuilder /** * 最长公共子序列, * 输出所有子序列, * Created by AoEiuV020 on 2017/05/14. */ object DynamicProgramming { enum class Last { XY, X, Y, E } fun longestCommonSubsequence(x: String, y: String): List<String> = longestCommo...
0
Java
0
0
6161b9630e936c071d654f8c2364f3d5acf8a3a1
1,997
DataStructuresTraining
MIT License
src/main/kotlin/leetcode/Problem1878.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import java.util.TreeSet /** * https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/ */ class Problem1878 { fun getBiggestThree(grid: Array<IntArray>): IntArray { val rightDiagonalSums = mutableMapOf<RowCol, Int>() val maxRow = grid.size val maxCol = if...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
4,112
leetcode
MIT License
src/test/kotlin/chapter3/solutions/ex28/listing.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter3.solutions.ex28 import chapter3.Branch import chapter3.Leaf import chapter3.Tree import io.kotest.matchers.shouldBe import io.kotest.core.spec.style.WordSpec // tag::init[] fun <A, B> fold(ta: Tree<A>, l: (A) -> B, b: (B, B) -> B): B = when (ta) { is Leaf -> l(ta.value) is Branch -...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
1,986
fp-kotlin
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day9/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day9 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.ints.IntArrayList val test = TestInput(""" 2199943210 3987894921 9856789892 8767896789 9899965678 """) @PuzzleName("Smoke Basin") fun PuzzleInput.part1(): Any { val (points, width, height) = parseInput(th...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,347
aoc
MIT License
2018/kotlin/day18p1/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.* fun main(args: Array<String>) { val start = Date() val classLoader = World::class.java.classLoader val input = classLoader.getResource("input.txt").readText() val result = scoreAfter10(World.parse(input)) println(result) println("in ${Date().time - start.time} ms") } enum cl...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
3,524
adventofcode
MIT License
src/day12/Day12.kt
PoisonedYouth
571,927,632
false
{"Kotlin": 27144}
package day12 import readInput import java.util.* private class Point( val x: Int, val y: Int, val code: Char, val height: Int, ) : Comparable<Point> { var dist: Int = -1 override fun compareTo(other: Point): Int { return this.dist.compareTo(other.dist) } } fun main() { fun...
0
Kotlin
1
0
dbcb627e693339170ba344847b610f32429f93d1
2,639
advent-of-code-kotlin-2022
Apache License 2.0