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/Day10.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
fun main() { fun parseSignals(input: List<String>): Map<Int, Int> { val registers = mutableMapOf<Int, Int>() var cycle = 0 var register = 1 input.forEach { line -> cycle += 1 if (line == "noop") { registers[cycle] = register re...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
1,480
advent-of-code-kotlin
Apache License 2.0
kotlin/src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day22Test.kt
dirkgroot
724,049,902
false
{"Kotlin": 203339, "Rust": 123129, "Clojure": 78288}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith private fun solution1(input: String) = parse(input).let { (map, path) -> val height = map.size ...
1
Kotlin
0
0
ced913cd74378a856813973a45dd10fdd3570011
7,814
adventofcode
MIT License
src/day03/Day03.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day03 import readInput fun main() { fun calculatePart1Score(input: List<String>): Int { return input.asSequence() .map { it.substring(0, it.length / 2) to it.substring(it.length / 2) } .map { it.first.toCharArray().toSet() to it.second.toCharArray().toSet() } ....
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
1,649
advent-of-code-22-kotlin
Apache License 2.0
src/Day10.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.readInput fun main() { fun part1(input: List<String>): Int { var registerValue = 1 return input.joinToString(separator = " ") .split(" ") .mapIndexed { index, s -> (index + 1 to registerValue).also { if (s != "noop" && s != "ad...
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
1,593
aoc-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day19.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import kotlin.math.max class Day19(input: List<String>) { private val blueprints = input.map { line -> val numberRegex = Regex("-?\\d+") val numbers = numberRegex.findAll(line).map { it.groupValues.first().toInt() }.toList() Blueprint( numb...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
4,995
advent-of-code
Apache License 2.0
src/Day03.kt
Qdelix
574,590,362
false
null
fun main() { fun part1(input: List<String>): Int { var string = "" input.forEach { line -> val firstCompartment = line.substring(0, line.length / 2) val secondCompartment = line.substring(line.length / 2, line.length) string += firstCompartment.first { letter -> ...
0
Kotlin
0
0
8e5c599d5071d9363c8f33b800b008875eb0b5f5
1,445
aoc22
Apache License 2.0
aoc-2023/src/main/kotlin/aoc/aoc11.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.* import java.lang.Math.abs val testInput = """ ...#...... .......#.. #......... .......... ......#... .#........ .........# .......... .......#.. #...#..... """.parselines class Universe(lines: List<String>) { val colsToExpand = lines[0].indi...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
3,169
advent-of-code
Apache License 2.0
src/Day02.kt
sebastian-heeschen
572,932,813
false
{"Kotlin": 17461}
fun main() { fun draws(input: List<String>) = input.flatMap { line -> line.split(" ") .map { it.first() } .zipWithNext() } fun resultCalculation( input: List<String>, drawsByStrategicGuide: (Pair<Char, Char>) -> Pair<Shape, Shape> ) = draws(input) ...
0
Kotlin
0
0
4432581c8d9c27852ac217921896d19781f98947
2,006
advent-of-code-2022
Apache License 2.0
src/Day02.kt
trosendo
572,903,458
false
{"Kotlin": 26100}
private enum class RockPaperScissor( val points: Int, val winsOver: Char, val loosesOver: Char, val drawsOver: Char, ) { ROCK(1, 'C', 'B', 'A'), PAPER(2, 'A', 'C', 'B'), SCISSOR(3, 'B', 'A', 'C') } private enum class RockPaperScissorOutcome( val points: Int ) { WIN(6), DRAW(3),...
0
Kotlin
0
0
ea66a6f6179dc131a73f884c10acf3eef8e66a43
2,910
AoC-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2022/Day09.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.Point import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day09.Direction.* import ru.timakden.aoc.year2022.Day09.Direction.Companion.toDirection import kotlin.math.absoluteValue /** * [Day 9: Rope Brid...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,741
advent-of-code
MIT License
src/main/kotlin/year2022/day-15.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.aoc.Day import lib.aoc.Part import lib.math.Vector import kotlin.math.abs import kotlin.math.max fun main() { Day(15, 2022, PartA15(), PartB15()).run() } open class PartA15 : Part() { data class Sensor(val position: Vector, val closestBeacon: Vector) { private val beaconR...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
3,432
Advent-Of-Code-Kotlin
MIT License
src/Day04.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import kotlin.math.pow fun main() { val input = readInput("Day04") fun String.splitNumbers(): Pair<Set<String>, Set<String>> { return split(":")[1].split("|").map { it.trim().split("\\s+".toRegex()).toSet() }.let { it[0] to it[1] } } fun String.matchCount(): Int { ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
1,316
aoc-2023
Apache License 2.0
src/Day09.kt
roxanapirlea
572,665,040
false
{"Kotlin": 27613}
import kotlin.math.abs private data class Point(val x: Int, val y: Int) private data class Move(val steps: Int, val dir: String) private data class Rope(val h: Point, val t: Point) fun main() { fun getMoves(input: List<String>) = input.map { line -> val (d, s) = line.split(" ") Mov...
0
Kotlin
0
0
6c4ae6a70678ca361404edabd1e7d1ed11accf32
2,904
aoc-2022
Apache License 2.0
src/day24/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
import java.io.File fun main() { val programs = File("src/day24/input.txt").readText().split("inp w\n").drop(1) .map { it.split("\n").dropLast(1).map { it.split(" ") } } val variables = programs.map { Variables(it[3][2].toInt(), it[4][2].toInt(), it[14][2].toInt()) } val solutions = solve(variables...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,500
advent-of-code-2021
MIT License
src/main/kotlin/g1601_1700/s1632_rank_transform_of_a_matrix/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1601_1700.s1632_rank_transform_of_a_matrix // #Hard #Array #Greedy #Matrix #Graph #Union_Find #Topological_Sort // #2023_06_17_Time_807_ms_(100.00%)_Space_96.5_MB_(100.00%) import java.util.Arrays class Solution { fun matrixRankTransform(matrix: Array<IntArray>): Array<IntArray> { val rowCount =...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,872
LeetCode-in-Kotlin
MIT License
solutions/aockt/y2023/Y2023D06.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D06 : Solution { /** A race record, detailing the [time] it took and the total [distance] travelled. */ private data class RaceRecord(val time: Long, val distance: Long) /** * A race simulation resu...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,489
advent-of-code-kotlin-solutions
The Unlicense
src/Day05.kt
jpereyrol
573,074,843
false
{"Kotlin": 9016}
import java.util.* fun main() { fun part1(input: List<String>): Int { val (moves, stacks) = input.filterNot { it == "" }.partition { it.contains("move") } // stacks val numStacks = stacks.last().last().toString().toInt() val stackValues = stacks.dropLast(1).rev...
0
Kotlin
0
0
e17165afe973392a0cbbac227eb31d215bc8e07c
2,624
advent-of-code
Apache License 2.0
src/day19/Day19.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day19 import readInput import java.util.* import kotlin.system.measureTimeMillis private const val DAY_ID = "19" private data class Blueprint( val id: Int, val costs: List<List<Int>> ) fun main() { fun parseInput(input: List<String>): List<Blueprint> { val regex = """ |Bluepr...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
5,096
aoc-2022-in-kotlin
Apache License 2.0
src/day03/Day03.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day03 import readLines fun main() { val id = "03" fun readRucksacks(fileName: String): Sequence<Pair<String, String>> { return readLines(fileName) .asSequence() .map { it.substring(0, it.length / 2) to it.substring(it.length / 2, it.length) } } fun Char.prior...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
1,316
advent-of-code-2022
Apache License 2.0
year2022/src/cz/veleto/aoc/year2022/Day07.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay class Day07(config: Config) : AocDay(config) { override fun part1(): String { val graph = parseIntoGraph() calculateDirSizes(graph) val atMost100kDirs = findAtMost100kDirs(graph) return atMost100kDirs.sumOf { it.child...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
3,613
advent-of-pavel
Apache License 2.0
src/main/kotlin/g2701_2800/s2719_count_of_integers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2701_2800.s2719_count_of_integers // #Hard #String #Dynamic_Programming #Math #2023_08_02_Time_208_ms_(100.00%)_Space_38_MB_(68.42%) import java.util.Arrays class Solution { private lateinit var dp: Array<Array<Array<IntArray>>> private fun countStrings(i: Int, tight1: Boolean, tight2: Boolean, sum:...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,081
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/bogwalk/batch9/Problem93.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch9 import dev.bogwalk.util.combinatorics.combinations import dev.bogwalk.util.custom.Fraction import kotlin.math.abs import kotlin.math.roundToInt /** * Problem 93: Arithmetic Expressions * * https://projecteuler.net/problem=93 * * Goal: Distinct positive integer outcomes can be achieved ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
6,735
project-euler-kotlin
MIT License
src/main/kotlin/aoc2023/Day19.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import kotlin.IllegalStateException import kotlin.math.min import kotlin.math.max class Day19 { fun part1(input: String): Int { val (workflows, parts) = parseInput(input) var totalSum = 0 for (part in parts) { var result = "in" while (result !in setO...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
6,593
advent-of-code-2023
MIT License
src/Day01.kt
pinkpinkkjn
578,428,998
false
{"Kotlin": 2404}
fun main() { // fun part1(input: List<String>): Int { // return input.size // } fun part1(input: String): Int { val data = input.split("\n\n").map { elf -> elf.lines().map { it.toInt() } } return data.maxOf { it.sum() } } fun part1v2(input: String): Int { ...
0
Kotlin
0
0
e1d3021e2963e8da9187da64a0a1be91da3747e5
1,183
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day16/Day16.kt
Arch-vile
317,641,541
false
null
package day16 import readFile import utils.intersect import utils.transpose data class Field(val name: String, val range1: IntRange, val range2: IntRange) { fun accepts(number: Int): Boolean { return range1.contains(number) || range2.contains(number) } } fun main(args: Array<String>) { val fields = listOf(...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
2,851
adventOfCode2020
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day07.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.isLetter import ru.timakden.aoc.util.isNumber import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 7: Some Assembly Required](https://adventofcode.com/2015/day/7). */ object Day07 { @JvmStatic fun main(args: Array<S...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
3,059
advent-of-code
MIT License
aoc/src/main/kotlin/com/bloidonia/aoc2023/day19/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day19 import com.bloidonia.aoc2023.text private const val example = """px{a<2006:qkq,m>2090:A,rfg} pv{a>1716:R,A} lnx{m>1548:A,A} rfg{s<537:gd,x>2440:R,A} qs{s>3448:A,lnx} qkq{x<1416:A,crn} crn{x>2662:A,R} in{s<1351:px,qqz} qqz{s>2770:qs,m<1801:hdj,R} gd{a>3333:R,R} hdj{m>838:A,pv} {x=7...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
2,632
aoc-2023
MIT License
advent-of-code2015/src/main/kotlin/day3/Advent3.kt
REDNBLACK
128,669,137
false
null
package day3 import parseInput /** --- Day 3: Perfectly Spherical Houses in a Vacuum --- Santa is delivering presents to an infinite two-dimensional grid of houses. He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to m...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,476
courses
MIT License
src/Day02.kt
drothmaler
572,899,837
false
{"Kotlin": 15196}
enum class Shape (val opponent: Char, val response: Char, val score: Int) { Rock('A', 'X', 1), Paper('B', 'Y', 2), Scissors('C', 'Z', 3); private val beats get() = relative(-1) private val loosesTo get() = relative(+1) private fun relative(delta:Int) = Shape.values()[(this.ordinal + delta + siz...
0
Kotlin
0
0
1fa39ebe3e4a43e87f415acaf20a991c930eae1c
2,519
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day3.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
private val part1ExampleInput = """ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw """.trimIndent() fun main() { println("day3") println() println("part1") assertEquals(part1...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
1,708
advent_of_code_2022
MIT License
src/Day16.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
import java.lang.IllegalStateException import java.lang.StringBuilder import java.math.BigInteger fun main() { abstract class Packet(val version: Int) { open fun versionSum() = version abstract fun evaluate(): Long } class Literal(version: Int, val value: Long) : Packet(version) { ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
3,251
AdventOfCode2021
Apache License 2.0
src/Day07.kt
nikolakasev
572,681,478
false
{"Kotlin": 35834}
import ObjectType.Directory import ObjectType.File import java.lang.IllegalStateException fun main() { fun inputToFileSystem(input: List<String>): List<Node> { var currentNode = Node("/", size = 0, Directory, parent = null) val nodes: MutableList<Node> = mutableListOf(currentNode) input.fo...
0
Kotlin
0
1
5620296f1e7f2714c09cdb18c5aa6c59f06b73e6
2,360
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (left, right) = it.chunked(it.length / 2) val common = left.toSet().intersect(right.toSet()).first() if (common.isLowerCase()) { common - 'a' + 1 } else { ...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
1,169
advent-of-code-2022
Apache License 2.0
src/main/kotlin/org/deafsapps/adventofcode/day04/Main.kt
pablodeafsapps
733,033,603
false
{"Kotlin": 6685}
package org.deafsapps.adventofcode.day04 import java.io.File import java.util.Scanner fun main() { val input = Scanner(File("src/main/resources/day04-data.txt")) val scratchCardList = mutableListOf<ScratchCard>() while (input.hasNext()) { val scratchCardLine = input.nextLine() val (winnin...
0
Kotlin
0
0
3a7ea1084715ab7c2ab1bfa8a1a7e357aa3c4b40
1,622
advent-of-code_2023
MIT License
src/Day12alt.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { data class Point(var row: Int, var col: Int, var height: Int) // fun getNeighbors(r: Int, c: Int, maze: List<List<Int>>) : MutableList<Point> { // val height = maze.size // val width = maze[0].size // var neighbors = mutableListOf<Point>() // for(row in -1..1) { // for(col in -1..1) { ...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
2,990
AdventOfCode2022
Apache License 2.0
src/main/kotlin/aoc2017/ParticleSwarm.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import komu.adventofcode.utils.nonEmptyLines import java.util.Comparator.comparing import kotlin.math.sqrt fun particleSwarmClosest(input: String): Int = Particle.parseAll(input).minWithOrNull(comparing(Particle::accelerationDistance) .thenComparing(Particle::...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,735
advent-of-code
MIT License
src/Day03.kt
bunjix
573,915,819
false
{"Kotlin": 9977}
import java.io.File fun main() { val input = File("src/Day03_input.txt").readLines() println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { return input.sumOf { rucksack -> rucksack.chunked(rucksack.length/2) .let { findSharedLetter(it.first(), it.last...
0
Kotlin
0
0
ee2a344f6c0bb2563cdb828485e9a56f2ff08fcc
1,168
aoc-2022-kotlin
Apache License 2.0
src/day7/Day7.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
package day7 import java.io.File import kotlin.math.absoluteValue fun readCrabSubmarines(): List<Int> { return File("day7.txt") .readLines()[0] .split(",") .map { it.toInt() } } fun calculateFuelSimple(crabSubmarines: List<Int>, position: Int): Int { return crabSubmarines.sumOf { curr...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
1,782
AdventOfCode2021
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-05.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText import com.github.ferinagy.adventOfCode.transpose fun main() { val input = readInputText(2022, "05-input") val testInput1 = readInputText(2022, "05-test1") ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,922
advent-of-code
MIT License
src/main/kotlin/Problem29.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.pow /** * Distinct powers * * Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: * * 2^2=4, 2^3=8, 2^4=16, 2^5=32 * 3^2=9, 3^3=27, 3^4=81, 3^5=243 * 4^2=16, 4^3=64, 4^4=256, 4^5=1024 * 5^2=25, 5^3=125, 5^4=625, 55^=3125 * If they are then placed in numerical order, with an...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
911
project-euler
MIT License
src/Day01.kt
armatys
573,477,313
false
{"Kotlin": 4015}
fun main() { fun part1(input: List<String>): Int { return mostCalories(input) } fun part2(input: List<String>): Int { return mostCalories(input, topN = 3) } // test if implementation meets criteria from the description, like: val testInput = readInput("Day01_test") check(pa...
0
Kotlin
0
0
95e93f7e10cbcba06e2ef88c1785779fbaa7c90f
966
kotlin-aoc-2022
Apache License 2.0
src/day24/Day24.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day24 import readInput import java.util.* private const val DAY_ID = "24" private enum class Direction( val dx: Int, val dy: Int ) { UP(-1, 0), DOWN(1, 0), LEFT(0, -1), RIGHT(0, 1); companion object { fun fromChar(c: Char): Direction = when (c) { '^' -> UP ...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
8,289
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day11.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part11A : PartSolution() { internal lateinit var monkeys: MutableList<Monkey> internal open val numRounds = 20 override fun parseInput(text: String) { val lines = text.trim...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,515
advent-of-code-kotlin
MIT License
src/day06/Day06.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day06 import readInput fun main() { /** * As groupBy practically creates a map for each substring * performance: O(n) * space complexity: n/markerLength times allocation of markerLength map (LinkedHashMap) * (each time is eligible for GC after moving forward) */ fun areSymbol...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
3,222
advent-of-code-2022
Apache License 2.0
src/Day17.kt
inssein
573,116,957
false
{"Kotlin": 47333}
import kotlin.math.max fun main() { fun List<String>.toJetDeltas() = this.first().map { if (it == '>') 1 else -1 } val rocks = listOf( listOf(Pair(0, 0), Pair(1, 0), Pair(2, 0), Pair(3, 0)), listOf(Pair(1, 0), Pair(0, 1), Pair(1, 1), Pair(2, 1), Pair(1, 2)), listOf(Pair(0, 0), Pair(1, ...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
3,186
advent-of-code-2022
Apache License 2.0
src/Day03.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
fun main() { fun getItemPriority(item: Char) : Int { val charVal = item.code if (charVal in 'a'.code .. 'z'.code) return charVal - 'a'.code + 1 if(charVal in 'A'.code .. 'Z'.code) return charVal - 'A'.code + 27 return 0 } fun part1(input: List<Stri...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
1,451
AoC2022
Apache License 2.0
src/main/kotlin/org/example/e3fxgaming/adventOfCode/aoc2023/day07/Day07.kt
E3FxGaming
726,041,587
false
{"Kotlin": 38290}
package org.example.e3fxgaming.adventOfCode.aoc2023.day07 import org.example.e3fxgaming.adventOfCode.utility.Day import org.example.e3fxgaming.adventOfCode.utility.IndividualLineInputParser import org.example.e3fxgaming.adventOfCode.utility.InputParser class Day07(input: String) : Day<Pair<String, Int>, Pair<String, ...
0
Kotlin
0
0
3ae9e8b60788733d8bc3f6446d7a9ae4b3dabbc0
4,827
adventOfCode
MIT License
ceria/05/src/main/kotlin/Solution.kt
VisionistInc
572,963,504
false
null
import java.io.File; import java.util.Stack fun main(args : Array<String>) { var input = File(args.first()).readLines() var bottomIndex = 0 var numStacks = 0 run findBottomsLine@ { input.forEachIndexed { index, line -> if (!line.contains("[")) { bottomIndex = index...
0
Rust
0
0
90b348d9c8060a8e967fe1605516e9c126fc7a56
2,408
advent-of-code-2022
MIT License
src/Day05.kt
daividssilverio
572,944,347
false
{"Kotlin": 10575}
private fun buildStacksInfo(stackInput: List<String>): Map<Int, List<String>> { val stacks = mutableMapOf<Int, List<String>>() val iterator = stackInput.iterator() while (iterator.hasNext()) { val line = iterator.next() if (!iterator.hasNext()) break line.chunked(4).forEachIndexed { ...
0
Kotlin
0
0
141236c67fe03692785e0f3ab90248064a1693da
2,465
advent-of-code-kotlin-2022
Apache License 2.0
src/dynamicprogramming/EditDistance.kt
faniabdullah
382,893,751
false
null
package dynamicprogramming class EditDistance { fun minDistance(word1: String, word2: String): Int { val dp = Array(word1.length + 1) { IntArray(word2.length + 1) { 0 } } for (i in dp.indices) { for (j in dp[i].indices) { when { i == 0 -> { ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,941
dsa-kotlin
MIT License
2021/3/Diagnostic.kts
marcoscarceles
317,996,390
false
{"Python": 43384, "Kotlin": 4294}
#!/usr/bin/env kscript fun List<Any>.half():Double = (this.size / 2.0) fun List<Int>.toInt(): Int = this.reversed().withIndex().map { it.value * Math.pow(2.0, it.index.toDouble()) }.toList().sum().toInt() fun getSummary(diagnostic: List<List<Int>>): List<Int> = diagnostic.reduce { acc, next -> ...
0
Python
0
0
c21c977f029bbe403bf107de1c5294d31d90a686
2,090
adventofcode
MIT License
y2019/src/main/kotlin/adventofcode/y2019/Day20.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 import java.util.* fun main() { Day20.solve() } object Day20 : AdventSolution(2019, 20, "Donut maze") { override fun solvePartOne(input: String): Any { val (...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
5,102
advent-of-code
MIT License
year2022/src/main/kotlin/net/olegg/aoc/year2022/day13/Day13.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day13 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2022.DayOf2022 import net.olegg.aoc.year2022.day13.Day13.Node.Collection import net.olegg.aoc.year2022.day13.Day13.Node.Value /** * See [Year 2022, Day 13](https://adventofcode.com/202...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,762
adventofcode
MIT License
src/main/kotlin/day8/Day08.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day8 fun solveA(input: List<String>): Int { val columns = input.getRows() return input.mapIndexed { y, line -> line.filterIndexed { x, tree -> val height = tree.digitToInt() findOutwardTrees(input, columns, x, y).any { it.checkVisibility(height) } }.length ...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
4,551
advent-of-code-2022
Apache License 2.0
src/Day07.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
fun main() { data class Object(var size: Int, val name: String, val isDir: Boolean, var current: Boolean, val parent: Object?) fun executeCommand(cmd: String, fs: MutableList<Object>) { if (cmd.startsWith("$ cd")) { val dir = cmd.split(" ")[2] val cur = fs.first { it.current }...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
3,069
advent-of-code-2022
Apache License 2.0
src/Day07.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { fun dirSizes(commands: List<String>): Map<String, Int> { val sizes = mutableMapOf<String, Int>() var cwd = "" for (command in commands) { val splitCommand = command.split(" ") if (splitCommand[1] == "cd") { cwd = when (splitCommand[2]) ...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
1,556
AoC-2022
Apache License 2.0
src/challenges/Day03.kt
paralleldynamic
572,256,326
false
{"Kotlin": 15982}
package challenges import utils.readInput private const val LABEL = "Day03" private const val SCORES = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun scoreCompartments(rucksack: String): Int { val mid: Int = rucksack.length / 2 val (first, second) = rucksack.chunked((mid)).map{ compartment -> com...
0
Kotlin
0
0
ad32a9609b5ce51ac28225507f77618482710424
1,238
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
Iamlooker
573,103,288
false
{"Kotlin": 5744}
fun main() { fun convertToRange(start: String, end: String): IntRange = start.toInt()..end.toInt() fun part1(input: List<String>): Long = input.sumOf { work -> val workPerElf = work.split(',') val firstWork = workPerElf.first().split('-') val secondWork = workPerElf.last().split('-') ...
0
Kotlin
0
0
91a335428a99db2f2b1fd5c5f51a6b1e55ae2245
1,551
aoc-2022-kotlin
Apache License 2.0
y2017/src/main/kotlin/adventofcode/y2017/Day24.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution object Day24 : AdventSolution(2017, 24, "Electromagnetic Moat") { override fun solvePartOne(input: String): String { val pairs = parseInput(input) return buildAllBridges(emptyList(), pairs, 0) .map { it.sumOf { (a, b) -> a...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,164
advent-of-code
MIT License
src/main/kotlin/com/colinodell/advent2022/Day13.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day13(input: List<String>) { private val packets = input.filter { it.isNotBlank() }.map { Packet(it) } private val dividerPackets = listOf( Packet("[[2]]"), Packet("[[6]]") ) fun solvePart1() = packets .chunked(2) .withIndex() ...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
2,845
advent-2022
MIT License
src/year_2022/day_10/Day10.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_10 import readInput sealed class Operation(var cycleCount: Int) { object NoOp: Operation(1) class Add( val quantity: Int ): Operation(2) { override fun toString(): String { return "Add $quantity - in $cycleCount cyclces" } } } object Day10 { ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,731
advent_of_code
Apache License 2.0
src/Day5/Day5.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day5 import readInputAsText import java.util.Stack fun main() { data class Instruction(val move: Int, val from: Int, val to: Int) fun parseInput(input: String): Pair<List<Stack<Char>>, MutableList<Instruction>> { val (cratesInput, instructionInput) = input.split("\n\n") val cratesSiz...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
2,296
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
fun main() { val perms = listOf( "ABC", // "ACB", // "CAB", // "BAC", // "BCA", // "CBA" ) fun rockPaperScissors(oppC: Char, myC: Char): Int { return when { oppC == myC -> 3 oppC == 'A' && myC == 'C' -> 0 oppC == 'B' &&...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
3,206
aoc-2022
Apache License 2.0
src/Day05.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
import java.util.* fun main() { fun part1(input: List<String>): String { val middleIndex = input.indexOfFirst { it.contains("1") } val indexes = input[middleIndex].mapIndexed { index, c -> if (c == ' ') -1 else index }.filter { it != -1 } val stacks = MutableList(indexes.size) ...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
2,125
Advent-of-code
Apache License 2.0
src/main/kotlin/adventofcode2017/potasz/P03SpiralMemory.kt
potasz
113,064,245
false
null
package adventofcode2017.potasz import kotlin.math.abs import kotlin.math.max import kotlin.math.min // http://adventofcode.com/2017/day/3 object P03SpiralMemory { data class Move(val x: Int, val y: Int) data class Position(val x: Int, val y: Int) { operator fun plus(move: Move) = Position(x + move....
0
Kotlin
0
1
f787d9deb1f313febff158a38466ee7ddcea10ab
2,385
adventofcode2017
Apache License 2.0
src/Day05.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private fun numberOfStack(input: List<String>): Int { return input.find { it.startsWith(" 1 ") }?.let { 1 + it.length / 4 }!! } private fun startingStacks(input: List<String>): Pair<List<MutableList<Char>>, Int> { val numberOfStack = numberOfStack(input) val stacks = List(numberOfStack) { ...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
2,209
advent-of-code-2022
Apache License 2.0
src/Day11.kt
hufman
573,586,479
false
{"Kotlin": 29792}
class MonkeyBrains(val operation: (Long) -> Long, val modulus: Int, val trueDest: Int, val falseDest: Int, var state: State ) { class Builder() { var items: MutableList<Long> = ArrayList() var operation: ((Long) -> Long)? = ...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
5,065
aoc2022-kt
Apache License 2.0
src/main/kotlin/name/valery1707/problem/leet/code/CanPlaceFlowersK.kt
valery1707
541,970,894
false
null
package name.valery1707.problem.leet.code import kotlin.math.max import kotlin.math.roundToInt /** * # 605. Can Place Flowers * * You have a long flowerbed in which some of the plots are planted, and some are not. * However, flowers cannot be planted in **adjacent** plots. * * Given an integer array `flowerbed`...
3
Kotlin
0
0
76d175f36c7b968f3c674864f775257524f34414
3,272
problem-solving
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem835/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem835 /** * LeetCode page: [835. Image Overlap](https://leetcode.com/problems/image-overlap/); */ class Solution { /* Complexity: * Time O(N^4) and Space O(N^2) where N is the size of img1 and img2; */ fun largestOverlap(img1: Array<IntArray>, img2: Array<IntArra...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,475
hj-leetcode-kotlin
Apache License 2.0
src/year2022/02/Day02_more_adequate_solution.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`02` import readInput fun main() { fun part1(input: List<String>): Int { return input .map { it.split(" ") } .map { val opponentFigure = Figure.from(it.first()) val yourFigure = Figure.from(it[1]) calculateOutcomeFo...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,481
KotlinAdventOfCode
Apache License 2.0
project/src/problems/MaxSlice.kt
informramiz
173,284,942
false
null
package problems object MaxSlice { /** * https://codility.com/media/train/7-MaxSlice.pdf * * NOTE: We assume that the slice can be empty and its sum equals 0 SO * a slice CAN NOT be smaller than 0 * * Example: * 5 -7 3 5 -2 4 -1 * In the picture, the slice with the largest ...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
4,339
codility-challenges-practice
Apache License 2.0
src/Day01.kt
hottendo
572,708,982
false
{"Kotlin": 41152}
fun main() { fun part1(input: List<String>): Int { var mostCalories = 0 var sumCalories = 0 for (item in input) { if (item.length == 0) { if (sumCalories > mostCalories) { mostCalories = sumCalories } sumCalori...
0
Kotlin
0
0
a166014be8bf379dcb4012e1904e25610617c550
1,520
advent-of-code-2022
Apache License 2.0
src/algorithmdesignmanualbook/sorting/FindNumberOfOccurrence.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.sorting import algorithmdesignmanualbook.print import java.util.* import kotlin.test.assertTrue /** * Get the left most index using binary search */ private fun getLeftMostMatch(str: String, array: Array<String>, low: Int, high: Int): Int { if (low <= high) { val mid = ...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,931
algorithms
MIT License
2021/src/main/kotlin/days/Day5.kt
pgrosslicht
160,153,674
false
null
package days import Day import com.google.common.collect.HashBasedTable import kotlin.math.sign class Day5 : Day(5) { private val regex = Regex("^((\\d*),(\\d*))\\s->\\s((\\d*),(\\d*))\$") private val lines = dataList.filter { it.isNotEmpty() }.mapNotNull { regex.matchEntire(it) }.map { it.destructure...
0
Kotlin
0
0
1f27fd65651e7860db871ede52a139aebd8c82b2
2,335
advent-of-code
MIT License
src/day4/Code.kt
fcolasuonno
221,697,249
false
null
package day4 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2(parsed)}") } data...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
1,518
AOC2016
MIT License
advent-of-code-2022/src/Day24.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { val (testBlizzards, testSize) = readInput("Day24_test") val (inputBlizzards, inputSize) = readInput("Day24") "Part 1" { part1(testBlizzards, testSize) shouldBe 18 measureAnswer { part1(inputBlizzards, inputSize) } } "Part 2" { part2(testBlizzards, testSize) sho...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
4,602
advent-of-code
Apache License 2.0
src/Day07.kt
MarkRunWu
573,656,261
false
{"Kotlin": 25971}
import java.lang.IllegalStateException import java.util.* import kotlin.collections.ArrayList fun main() { data class File(val name: String, val size: Int) data class Directory( val name: String, val parent: Directory?, val files: ArrayList<File> = arrayListOf(), val childDirec...
0
Kotlin
0
0
ced885dcd6b32e8d3c89a646dbdcf50b5665ba65
3,758
AOC-2022
Apache License 2.0
src/twentytwentythree/day04/Day04.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day04 import readInput import kotlin.math.pow fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> val numbers = line.split(":")[1].split("|") val winningNumbers = numbers[0].split(" ").mapNotNull { it.toIntOrNull() }.toSet() ...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,343
advent-of-code
Apache License 2.0
src/aoc2022/Day08.kt
miknatr
576,275,740
false
{"Kotlin": 413403}
package aoc2022 import kotlin.math.max fun main() { fun parseGrid(input: List<String>) = input .filter { it != "" } .map { it.map { char -> char.digitToInt() } } fun List<List<Int>>.countVisibleTrees(): Int { val gridSize = first().size var invisibleCount = 0 withInd...
0
Kotlin
0
0
400038ce53ff46dc1ff72c92765ed4afdf860e52
2,983
aoc-in-kotlin
Apache License 2.0
archive/2022/Day12_submission.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 31 private const val EXPECTED_2 = 29 /** * Pretty horrible code written during the race. Rushed too quickly to dfs before I * realized that that won't work without revisiting nodes when you see that they can be reached * in fewer steps than before. Fortunately it could be patched up a...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,258
advent-of-code-2022
Apache License 2.0
src/Day01.kt
Jessenw
575,278,448
false
{"Kotlin": 13488}
fun main() { fun part1(input: String): Int { // Split into each elves' list of carried calories val carriedCalories = input.split("\n\n") var maxCalories = -1 carriedCalories.forEach { carried -> val calorieItems = carried.split("\n") var totalCalories = 0 ...
0
Kotlin
0
0
05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3
1,321
aoc-22-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumCostToCutStick.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,816
kotlab
Apache License 2.0
src/Day05.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
private val INSTRUCTION_PATTERN = Regex("[0-9]+") fun main() { fun part1(input: List<String>): String { val cratesPlan = input.takeWhile { it.isNotBlank() } val stackCount = cratesPlan.last().trimEnd().last().digitToInt() val maxStackHeight = cratesPlan.size - 1 val crates = Array(...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
2,991
advent-of-code-2022
Apache License 2.0
src/Day10.kt
ricardorlg-yml
573,098,872
false
{"Kotlin": 38331}
class Day10Solver(private val input: List<String>) { enum class Command(private val _name: String, val cost: Int) { NOOP("noop", 1), ADD("addx", 2); companion object { fun fromName(name: String) = values().first { it._name == name } } } data class Instruction(v...
0
Kotlin
0
0
d7cd903485f41fe8c7023c015e4e606af9e10315
2,061
advent_code_2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2015/Day15.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2015 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import java.lang.Math.max class Day15: AdventDay(2015, 15) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day15() report { day....
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,740
adventofcode
MIT License
src/Day21.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
enum class Operation { PLUS, MINUS, MUL, DIV } data class MonkeyYellOperation(val nameLeft: String, val nameRight: String, val operation: Operation) { fun apply(valueLeft: Long, valueRight: Long) = when (operation) { Operation.PLUS -> valueLeft + valueRight Operation.MINUS -> valueLeft - valueR...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
5,809
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { val indexesPattern = Regex("(:? \\d ? ?)+") val cratePattern = Regex(".{3} ?") fun parseCrates(inputIterator: ListIterator<String>): Map<Int, ArrayDeque<Char>> { val stacks = mutableMapOf<Int, MutableList<Char>>() run breaking@ { inputIterator.forEach { line -> ...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
2,387
advent_of_code_2022
Apache License 2.0
src/day03/Day03.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day03 import readInput data class IndexCount(val stringIndex: Int, val commonCount: Int) fun main() { fun Char.toPriority() = when { this.isLowerCase() -> this - 'a' + 1 else -> this - 'A' + 27 } fun String.toCompartments() = substring(0, length / 2) to substring(length / 2, len...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
2,195
advent-of-code-2022
Apache License 2.0
src/Day08.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
import kotlin.math.max import kotlin.math.min fun main() { fun isTreeHighestLowerBound(tree: Int, list: List<Int>, index: Int): Boolean { if (index == 0) { return true } return list.slice(0 until index).max() < tree } fun isTreeHighestUpperBound(tree: Int, list: List<In...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
6,924
advent_of_code_2022
Apache License 2.0
src/main/kotlin/dev/patbeagan/days/Day08.kt
patbeagan1
576,401,502
false
{"Kotlin": 57404}
package dev.patbeagan.days import dev.patbeagan.CanTraverse import dev.patbeagan.takeUntil /** * [Day 8](https://adventofcode.com/2022/day/8) */ class Day08 : AdventDay<Int> { override fun part1(input: String) = parseInput(input) .let { treeGrid -> var count = 0 treeGrid.walk { _...
0
Kotlin
0
0
4e25b38226bcd0dbd9c2ea18553c876bf2ec1722
4,830
AOC-2022-in-Kotlin
Apache License 2.0
src/Day03.kt
TrevorSStone
573,205,379
false
{"Kotlin": 9656}
fun Char.points(): Int = when { isLowerCase() -> code - 'a'.code + 1 isUpperCase() -> code - 'A'.code + 27 else -> 0 } fun main() { check('a'.points() == 1) check('z'.points() == 26) check('A'.points() == 27) check('Z'.points() == 52) fun part1(input: List<String>): Int = inp...
0
Kotlin
0
0
2a48776f8bc10fe1d7e2bbef171bf65be9939400
1,011
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch1/Problem11.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch1 import dev.bogwalk.util.custom.IntMatrix2D import dev.bogwalk.util.custom.product /** * Problem 11: Largest Product in a Grid * * https://projecteuler.net/problem=11 * * Goal: Find the largest product of 4 adjacent integers in the same direction (up, down, left, * right, diagonal) in ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,531
project-euler-kotlin
MIT License
src/Day10.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day10 : Runner<Int, String>(10, 13140, "") { override fun part1(input: List<String>): Int { val states = mutableListOf(State(0, 0, 1, 1)) input.forEach { s -> states.add(states.lastOrNull()!!.next(Instruction.of(s))) } val output = generateSequence(20) { it + 40 }.takeWhile { it <= ...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
3,212
advent-of-code-2022-kotlin
Apache License 2.0
src/Day05.kt
lassebe
573,423,378
false
{"Kotlin": 33148}
data class Instruction(val count: Int, val from: Int, val to: Int) fun main() { fun getBoxes(input: List<String>): List<ArrayDeque<String>> { val stacks = mutableListOf<ArrayDeque<String>>() val cargoLines = input.filter { l -> l.contains("[") }.reversed() for (i in (0 until cargoLines.fir...
0
Kotlin
0
0
c3157c2d66a098598a6b19fd3a2b18a6bae95f0c
2,227
advent_of_code_2022
Apache License 2.0
src/Day20.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private fun mix(originalFile: List<Pair<Long, Int>>, mixedFile: MutableList<Pair<Long, Int>>): MutableList<Pair<Long, Int>> { val fileSizeMinusOne = originalFile.size - 1 for (nextNum in originalFile) { val index = mixedFile.indexOf(nextNum) mixedFile.removeAt(index) var newIndex = ind...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
1,947
advent-of-code-2022
Apache License 2.0
src/Day03.kt
Kanialdo
573,165,497
false
{"Kotlin": 15615}
fun main() { fun Char.priority() = if (isLowerCase()) { this.code - 'a'.code + 1 } else { this.code - 'A'.code + 27 } fun part1(input: String): Int { val rucksacks = input.lines() return rucksacks.sumOf { rucksack -> rucksack.chunked(size = rucksack.length /...
0
Kotlin
0
0
10a8550a0a85bd0a928970f8c7c5aafca2321a4b
1,368
advent-of-code-2022
Apache License 2.0
kotlin/0441-arranging-coins.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}
/* * Optimized with Binary Search and Gauss summation formula: Time Complexity O(LogN) and Space Complexity O(1) */ class Solution { fun arrangeCoins(n: Int): Int { var left = 1 var right = n var res = 0 while (left <= right) { val mid = left + (right - left) / 2 //avo...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,799
leetcode
MIT License
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day12/Day12.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day12 import eu.janvdb.aocutil.kotlin.ShortestPathMove import eu.janvdb.aocutil.kotlin.findShortestPath import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input12-test.txt" const val FILENAME = "input12.txt" fun main() { val ma...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,080
advent-of-code
Apache License 2.0
src/main/kotlin/Day05.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
import java.util.* import kotlin.collections.ArrayDeque fun main() { fun createStack(input: String): List<ArrayDeque<Char>> { val stack = List(9) { ArrayDeque<Char>() } val crates = input.lines() .dropLast(1) .reversed() .map { it -> it.chunked(4...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
2,407
advent-of-code-Kotlin-2022
Apache License 2.0
src/Day02.kt
Migge
572,695,764
false
{"Kotlin": 9496}
private fun part1(input: List<String>): Int = input .map { it.toGame() } .fold(0) { acc, game -> acc + game.score() } private fun part2(input: List<String>): Int = input .map { it.toForcedGame() } .fold(0) { acc, game -> acc + game.score() } fun main() { val testInput = readInput("Day02_test") ...
0
Kotlin
0
0
c7ca68b2ec6b836e73464d7f5d115af3e6592a21
2,281
adventofcode2022
Apache License 2.0