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/Day03.kt
tsdenouden
572,703,357
false
{"Kotlin": 8295}
import kotlin.math.* fun main() { fun part1(input: List<String>): Int { var compartmentOne: CharSequence var compartmentTwo: CharSequence val commonItems: MutableList<Int> = mutableListOf() input.forEach { line -> val rucksack = line.trim() val middle = cei...
0
Kotlin
0
0
68982ebffc116f3b49a622d81e725c8ad2356fed
2,185
aoc-2022-kotlin
Apache License 2.0
2022/src/main/kotlin/day14_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.MutableIntGrid import utils.Parser import utils.Segment import utils.Solution import utils.Vec2i import utils.mapItems fun main() { Day14Imp.run() } object Day14Imp : Solution<List<List<Segment>>>() { override val name = "day14" override val parser = Parser.lines.mapItems { lin...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,985
aoc_kotlin
MIT License
src/Day01.kt
SeanDijk
575,314,390
false
{"Kotlin": 29164}
fun main() { fun part1(input: List<String>): Int { var current = 0 var max = 0 for (line in input) { if (line.isBlank()) { if (current > max) { max = current } current = 0 } else { cur...
0
Kotlin
0
0
363747c25efb002fe118e362fb0c7fecb02e3708
1,334
advent-of-code-2022
Apache License 2.0
day21/src/Day21.kt
simonrules
491,302,880
false
{"Kotlin": 68645}
import java.io.File class Day21(path: String) { private var start = listOf<Int>() private var numRolls = 0 // Each player always rolls 3 times, but it doesn't matter what the order of the dice are. // Since there are 3^3=27 possibilities, we can just assume the universe branches on each // cluster...
0
Kotlin
0
0
d9e4ae66e546f174bcf66b8bf3e7145bfab2f498
3,492
aoc2021
Apache License 2.0
src/Day04.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
fun main() { fun part1(input: List<String>): Int { var count = 0 for (assignment in input) { val pairs = assignment.split(',') val elf1 = pairs[0].split('-').map { it.toInt() } val elf2 = pairs[1].split('-').map { it.toInt() } if (elf1[0] <= elf2[0] ...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
1,081
adventofcode2022
Apache License 2.0
src/day/_11/Day11.kt
Tchorzyksen37
572,924,533
false
{"Kotlin": 42709}
package day._11 import lcm import java.io.File typealias WorryLevel = Long class Day11 { fun part1(monkeys: List<Monkey>): Int { for (round in 1..20) { for (monkey in monkeys) { while (monkey.itemList.isNotEmpty()) { val item = monkey.itemList.removeFirst() val worryLevel = monkey.operation(item...
0
Kotlin
0
0
27d4f1a6efee1c79d8ae601872cd3fa91145a3bd
3,534
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/day19/Day19.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day19 import days.Day class Day19 : Day() { override fun partOne(): Any { val process = parseInput() val machineParts = parseMachineParts() var result = 0 for (part in machineParts) { var currentProcessIdentifier = "in" while (currentProcessId...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
5,531
advent-of-code_2023
The Unlicense
2022/main/day_11/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_11_2022 import java.io.File import java.math.BigInteger fun part1(input: List<String>) { val monkeys = mutableListOf<Monkey>() for (monkey in input.chunked(7)) { val items = monkey[1].substring(18).split(", ").map{ BigInteger(it) }.toMutableList() val op = monkey[2].toCharArray()[2...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
2,177
AdventofCode
MIT License
kotlin/src/main/kotlin/StreetRgb.kt
funfunStudy
93,757,087
false
null
fun main(args: Array<String>) { val list: List<List<Int>> = listOf(listOf(26, 40, 83), listOf(49, 60, 57), listOf(13, 89, 99)) val list2: List<List<Int>> = listOf(listOf(1, 20, 30), listOf(50, 5, 6), listOf(9, 3, 7)) println(solve(list)) println(solve(list2)) } fun solve(list: List<List<Int>>, index:...
0
Kotlin
3
14
a207e4db320e8126169154aa1a7a96a58c71785f
1,556
algorithm
MIT License
src/day18/d18_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
typealias Board = Array<Array<Char>> fun main() { val input = "" val board = sequence { var board = stuck(parseBoard(input)) while(true) { yield(board) board = step(board) } } println(board.take(100 + 1).last().map { r -> r.count { it == '#' } }.sum()) } fun parseBoard(s: String):...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,207
aoc2015
MIT License
advent-of-code/src/main/kotlin/DayTwo.kt
pauliancu97
518,083,754
false
{"Kotlin": 36950}
import kotlin.math.min class DayTwo { data class Cuboid( val length: Int, val width: Int, val height: Int ) { companion object { val REGEX = """(\d+)x(\d+)x(\d+)""".toRegex() } fun getSurfaceArea() = 2 * length * width + 2 * length * height + 2 * wi...
0
Kotlin
0
0
3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6
2,268
advent-of-code-2015
MIT License
src/Day02.kt
a2xchip
573,197,744
false
{"Kotlin": 37206}
fun main() { fun evaluateGame(game: String): Int { // A Rock, // B Paper // C Scissors // X for Rock // Y for Paper // Z for Scissors // i.e // (A Z) Rock defeats Scissors // (B X) Paper defeats Rock // (C Y) Scissors defeats Paper // ABC ...
0
Kotlin
0
2
19a97260db00f9e0c87cd06af515cb872d92f50b
2,466
kotlin-advent-of-code-22
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2021/Day21.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2021 import me.grison.aoc.* class Day21 : Day(21, 2021) { override fun title() = "<NAME>" private val initialPositions = inputList.map { it.allLongs().last() }.toMutableList() override fun partOne(): Long { val positions = initialPositions.copy() val scores = mutab...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
2,155
advent-of-code
Creative Commons Zero v1.0 Universal
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day02.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 /** * https://adventofcode.com/2022/day/2 */ class Day02(override val input: String) : Day() { override fun part1(): String = calcScore { theirCode: Char, myCode: Char -> val myMove = Move.fromCode(myCode) val theirMove = Move.fromCode(theirCode) myMove.sc...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
1,725
adventofcode2022
MIT License
leetcode-75-kotlin/src/main/kotlin/FindPivotIndex.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * Given an array of integers nums, calculate the pivot index of this array. * * The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. * * If the index is on the left edge of the array, then the left ...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,585
leetcode-75
Apache License 2.0
src/main/kotlin/leetcode/Problem2049.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/count-nodes-with-the-highest-score/ */ class Problem2049 { fun countHighestScoreNodes(parents: IntArray): Int { val root = buildTree(parents) val scores = mutableMapOf<Long, Int>() countHighestScore(parents.size, root, scores) v...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,786
leetcode
MIT License
src/test/kotlin/leetcode/mock/MockInterview3.kt
Magdi
390,731,717
false
null
package leetcode.mock import org.junit.Assert import org.junit.Test class MockInterview3 { @Test fun `test case 1`() { Assert.assertTrue( SimilarSentences().areSentencesSimilar( arrayOf("great", "acting", "skills"), arrayOf("fine", "drama", "talent"), ...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
3,995
ProblemSolving
Apache License 2.0
src/Day02.kt
zt64
572,594,597
false
null
enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3) } enum class Result { WIN, LOSE, DRAW } fun main() { val input = readInput("Day02") val mappings = mapOf( "A" to Shape.ROCK, "B" to Shape.PAPER, "C" to Shape.SCISSORS, "X" to Shape.ROCK, ...
0
Kotlin
0
0
4e4e7ed23d665b33eb10be59670b38d6a5af485d
2,192
aoc-2022
Apache License 2.0
src/Day14.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
fun toPoints(input: String): List<Point> { return input.split(" -> ").map { it.split(",") }.map { split -> Point(split[1].toInt(), split[0].toInt()) } } fun range(start: Int, end: Int): IntProgression = if (start <= end) start..end else start downTo end fun getBlocked(input: List<String>): Set<Point> { val ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
3,640
advent-of-code-2022
Apache License 2.0
src/day12/Day12.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day12 import readInputString import java.lang.Integer.min import kotlin.system.measureNanoTime fun main() { fun buildMinMountain(mountain: Array<Array<Int>>, ey: Int, ex: Int): Array<Array<Int>> { val minMountain = Array(mountain.size) { Array(mountain[0].size) { Int.MAX_VALUE - 10 } } min...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
6,911
Advent-Of-Code-2022
Apache License 2.0
src/Day01.kt
rtperson
434,792,067
false
{"Kotlin": 6811}
fun main() { fun part1(input: List<String>): Int { var lastNum = 20000000 var bigger = 0 for ( num in input ) { if (num.toInt() > lastNum) bigger += 1 lastNum = num.toInt() } return bigger } fun part2BruteForce(input: List<String>): Int { ...
0
Kotlin
0
0
ae827a46c8aba336a7d46762f4e1a94bc1b9d850
1,395
Advent_of_Code_Kotlin
Apache License 2.0
src/Day03.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
import java.lang.IllegalArgumentException fun main() { fun calculatePriorityOfItem(item: Char): Int { return when (item) { in 'a'..'z' -> 1 + (item - 'a') in 'A'..'Z' -> 27 + (item - 'A') else -> throw IllegalArgumentException("Unknown item: $item") } } ...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
1,562
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/Day10.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day10 { data class Coordinate(val x: Int, val y: Int) data class Node(val coordinate: Coordinate, val pipe: String, val connections: List<Coordinate>) fun part1(input: List<String>): String { val graph = parse(input) val nodesInLo...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
13,645
kotlin-kringle
Apache License 2.0
src/Day06.kt
TrevorSStone
573,205,379
false
{"Kotlin": 9656}
fun main() { fun part1(input: List<String>): Int { val windowSize = 4 return input.sumOf { line -> line .asSequence() .withIndex() .windowed(windowSize, 1) .filter { it.map { it.value }.toSet().size == windowSize } .onEach { println(it) } .fir...
0
Kotlin
0
0
2a48776f8bc10fe1d7e2bbef171bf65be9939400
1,049
advent-of-code-2022-kotlin
Apache License 2.0
src/Day02.kt
roxanapirlea
572,665,040
false
{"Kotlin": 27613}
fun main() { fun getOutcomeScore(you: Int, opponent: Int): Int { return when ((you - opponent).mod(3)) { 1 -> 6 2 -> 0 0 -> 3 else -> throw IllegalArgumentException() } } fun String.toRPSScore(): Int = when (this) { "A", "X...
0
Kotlin
0
0
6c4ae6a70678ca361404edabd1e7d1ed11accf32
1,721
aoc-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2023/Day15.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 15: Lens Library](https://adventofcode.com/2023/day/15). */ object Day15 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2023/Day15").si...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
1,837
advent-of-code
MIT License
src/Day02.kt
flexable777
571,712,576
false
{"Kotlin": 38005}
import Draw.* enum class Draw(val value: Int) { ROCK(1), PAPER(2), SCISSORS(3) } fun main() { fun getDraw(draw: String): Draw { return when (draw) { "A", "X" -> ROCK "B", "Y" -> PAPER "C", "Z" -> SCISSORS else -> error("Invalid draw") } } ...
0
Kotlin
0
0
d9a739eb203c535a3d83bc5da1b6a6a90a0c7bd6
2,663
advent-of-code-2022
Apache License 2.0
src/Day02.kt
dmstocking
575,012,721
false
{"Kotlin": 40350}
import java.lang.Exception enum class Play { ROCK, PAPER, SCISSORS; fun losses(other: Play): Boolean { return Play.values()[(this.ordinal + 1) % 3] == other } } fun Play.loser(): Play { return Play.values()[(this.ordinal - 1).mod(3)] } fun Play.winner(): Play { return Play.values()[(this....
0
Kotlin
0
0
e49d9247340037e4e70f55b0c201b3a39edd0a0f
2,190
advent-of-code-kotlin-2022
Apache License 2.0
src/y2022/Day22.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.Direction import util.Direction.DOWN import util.Direction.LEFT import util.Direction.RIGHT import util.Direction.UP import util.Pos import util.get import util.printGrid import util.readInput import util.split import util.transpose object Day22 { sealed class Instruction { data ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
8,799
advent-of-code
Apache License 2.0
2022/src/main/kotlin/Day02.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day02 { fun totalScore(input: String): Int { return input .splitNewlines() .map(String::splitWhitespace) .sumOf { score(it[0].toPlay(), it[1].toPlay()) } } fun totalScoreWithStrategy(input: String): Int { return input .splitNewlines() .map(String::splitWhitespace) ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,617
advent-of-code
MIT License
src/main/kotlin/aoc2021/Day06.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput private class FishPopulation(input: List<String>) { // every slot in the array corresponds to one day in the fish cycle private val fishes = LongArray(9) private var currentDay = 0 init { input.first().split(",").map { it.toInt() }.forEach { fishes[it]++ } ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,469
adventOfCode
Apache License 2.0
src/leecode/63.kt
DavidZhong003
157,566,685
false
null
package leecode /** * 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径? 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/unique-paths-ii 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 * @author doive * on 2020/1/6 19:52 */ fun main() { ...
0
Kotlin
0
1
7eabe9d651013bf06fa813734d6556d5c05791dc
1,559
LeetCode-kt
Apache License 2.0
src/main/kotlin/algosds/dynamicprogramming/ClimbingStairs.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package algosds.dynamicprogramming import util.timeIt import kotlin.math.min import kotlin.random.Random // For a given staircase, the i-th step is assigned a non-negative cost indicated by a cost array. // Once you pay the cost for a step, you can either climb one or two steps. Find the minimum cost to reach the top...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
3,419
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/day17/Day17.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day17 import java.io.File import kotlin.math.max fun main() { val data = parse("src/main/kotlin/day17/Day17.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 17 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
3,440
advent-of-code-2022
MIT License
calendar/day13/Day13.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day13 import Day import Lines import tools.* import kotlin.math.min class Day13 : Day() { override fun part1(input: Lines): Any { val packetPairs = parsePacketPairs(input) return packetPairs .map { it.first < it.second } .zip(1..packetPairs.size) .filte...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
2,408
advent-of-code-2022
Apache License 2.0
src/main/kotlin/KInversePairsArray.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j]. * * Given two integers n and k, return the number of different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. * Since the answer can be huge, return...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
2,180
kotlin-codes
Apache License 2.0
google/2019/round1_b/1/main.kt
seirion
17,619,607
false
{"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294}
import java.util.* fun main(args: Array<String>) { val t = readLine()!!.toInt() repeat(t) { solve(it) } } data class Input(val x: Int, val y: Int, val c: Char) fun solve(num: Int) { val (P, _) = readLine()!!.split(" ").map { it.toInt() } val xValues = TreeMap<Int, Int>() val yValues = TreeMap<In...
0
C++
4
4
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
1,412
code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxDetonation.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <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
4,457
kotlab
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day14.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution fun main() = repeat(10){Day14.solve()} object Day14 : AdventSolution(2018, 14, "Chocolate Charts") { override fun solvePartOne(input: String): String { val targetSize = input.toInt() + 10 return generateRecipes { it.size == targetS...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,484
advent-of-code
MIT License
year2015/src/main/kotlin/net/olegg/aoc/year2015/day6/Day6.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day6 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 6](https://adventofcode.com/2015/day/6) */ object Day6 : DayOf2015(6) { private fun toPoints(command: String): List<Int> { val matcher = "\\D*(\\d+),(\\d+)\\D*(\\d+),(\\d+...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,551
adventofcode
MIT License
src/Day07.kt
cornz
572,867,092
false
{"Kotlin": 35639}
import java.util.* fun main() { fun getDirSizes(input: List<String>): HashMap<String, Int> { val directories = Stack<String>() val directorySizes = HashMap<String, Int>() for ((index, line) in input.withIndex()) { val splitLine = line.split(" ") if (splitLine[1] ==...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
1,738
aoc2022
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day8/Day8Puzzle2.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day8 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver class Day8Puzzle2 : PuzzleSolver { override fun solve(inputLines: Sequence<String>) = sumOfDecodedNumbers(inputLines).toString() private fun sumOfDecodedNumbers(digitSignalsAndReadi...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
3,126
AdventOfCode2021
Apache License 2.0
src/main/aoc2016/Day4.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2016 class Day4(input: List<String>) { companion object { private val alphabet = ('a'..'z').toList().joinToString("") fun decrypt(name: String, sectorId: Int): String { return name.map { when (it) { '-' -> ' ' else -> al...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,054
aoc
MIT License
src/Day04.kt
gojoel
573,543,233
false
{"Kotlin": 28426}
fun main() { val input = readInput("04") // val input = readInput("04_test") data class Section(val lower: Int, val upper: Int) fun getPairs(input: List<String>) : ArrayList<Pair<Section, Section>> { val list: ArrayList<Pair<Section, Section>> = arrayListOf() input.map {line -> ...
0
Kotlin
0
0
0690030de456dad6dcfdcd9d6d2bd9300cc23d4a
1,607
aoc-kotlin-22
Apache License 2.0
year2020/src/main/kotlin/net/olegg/aoc/year2020/day7/Day7.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day7 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 7](https://adventofcode.com/2020/day/7) */ object Day7 : DayOf2020(7) { private val PATTERN = "(\\d+) (\\D*) bags?".toRegex() private const...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,648
adventofcode
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day11.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 11 - Cosmic Expansion * Problem Description: http://adventofcode.com/2023/day/11 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day11/ */ package com.ginsberg.advent2023 class Day11(input: List<String>) { privat...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
1,665
advent-2023-kotlin
Apache License 2.0
src/day04/Day04.kt
AbolfaZlRezaEe
574,383,383
false
null
package day04 import readInput fun main() { fun part01(lines: List<String>): Int { var result = 0 lines.forEach { line -> val ranges = line.split(",") val firstRangeInRaw = ranges[0].split("-") val secondRangeInRaw = ranges[1].split("-") val firstRa...
0
Kotlin
0
0
798ff23eaa9f4baf25593368b62c2f671dc2a010
2,057
AOC-With-Me
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions13.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test13() { val matrix = NumsMatrix( arrayOf( intArrayOf(3, 0, 1, 4, 2), intArrayOf(5, 6, 3, 2, 1), intArrayOf(1, 2, 0, 1, 5), intArrayOf(4, 1, 0, 1 ,7), intArrayOf(1, 0, 3, 0, 5), ) ) pri...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,433
Algorithm
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day09.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
package de.niemeyer.aoc2022 /** * Advent of Code 2022, Day 9: Rope Bridge * Problem Description: https://adventofcode.com/2022/day/9 */ import de.niemeyer.aoc.direction.DirectionCCS import de.niemeyer.aoc.direction.toDirectionCCS import de.niemeyer.aoc.points.Point2D import de.niemeyer.aoc.utils.Resources.resource...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,419
AoC-2022
Apache License 2.0
src/Day21.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
sealed interface MonkeyTree { fun yell(): Long fun isResolved(): Boolean fun resolve(input: Long): Long } class MonkeyNode(var opcode: String) : MonkeyTree { lateinit var leftChild: MonkeyTree lateinit var rightChild: MonkeyTree val operation: (Long, Long) -> Long = when (opcode) { "+"...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
3,175
advent-of-code-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/SubtreeOfAnotherTree.kt
faniabdullah
382,893,751
false
null
//Given the roots of two binary trees root and subRoot, return true if there is //a subtree of root with the same structure and node values of subRoot and false //otherwise. // // A subtree of a binary tree tree is a tree that consists of a node in tree //and all of this node's descendants. The tree tree could also ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,628
dsa-kotlin
MIT License
src/y2023/Day12.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.split import util.timingStatistics import y2023.Day12.part1Fast object Day12 { enum class SpringCondition(val c: Char) { BROKEN('#'), OPERATIONAL('.'), UNKNOWN('?') } val conditions = SpringCondition.entries.associateBy { it.c } private fun par...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
8,038
advent-of-code
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day19.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2023, Day 19: Not Enough Minerals * Problem Description: https://adventofcode.com/2023/day/02 * * This mainly is a reimplementation of forketyfork's solution * https://github.com/forketyfork/aoc-2022/blob/main/src/main/kotlin/year2022/Day19.kt */ package de.niemeyer.aoc2022 import de.niemey...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
6,001
AoC-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/LongestIncreasingSubsequence.kt
faniabdullah
382,893,751
false
null
//Given an integer array nums, return the length of 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 order of the remaining elements. For //example, [3,6,2,7] is a subsequence of the array [0,3,1,...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,888
dsa-kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinInsertionsPalindrome.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,319
kotlab
Apache License 2.0
src/Day09.kt
marciprete
574,547,125
false
{"Kotlin": 13734}
import kotlin.math.max import kotlin.math.sign import kotlin.math.abs data class Position(var x: Int, var y: Int) data class Rope(var head: Position, var tail: Position) { private var path = mutableSetOf<Position>() fun getPath(): MutableSet<Position> { return this.path } fun move(offset: Pos...
0
Kotlin
0
0
6345abc8f2c90d9bd1f5f82072af678e3f80e486
1,995
Kotlin-AoC-2022
Apache License 2.0
src/Day14.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
const val rock = 1 const val sand = 2 val Grid.maxY: Int get() { return this.grid.keys.max() } fun main() { fun Grid.addSandAt(point: Point, limit: Int? = null, limitIsFloor: Boolean = false): Boolean { if (this[point] != 0) return false var x = point.x var lastY = (limit ?: maxY) - 1...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
2,176
2022-aoc-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day08.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput private data class Node(val name: String) { lateinit var left: Node lateinit var right: Node } private data class InputMap(val directions: Sequence<Char>, val nodes: Map<String, Node>) { companion object { fun fromStrings(input: List<String>): InputMap { ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,857
adventOfCode
Apache License 2.0
src/Day17.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Int { val directions = input.first() val pushTo: Array<Direction> = Array(directions.length) { index -> Direction.from(directions[index]) } var windIndex = 0 val types = Array(5) { index -> PieceType.from(index) } var typeIndex = ...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
3,458
aoc-2022
Apache License 2.0
src/day05/Day05.kt
PoisonedYouth
571,927,632
false
{"Kotlin": 27144}
package day05 import readInput import java.util.* val cratesRegex = Regex("""\[(.)\]""") val instructionRegex = Regex("""move (\d+) from (\d+) to (\d+)""") data class Instruction( val amount: Int, val origin: Int, val target: Int ) fun main() { fun initStack(input: List<String>): List<Stack<String>>...
0
Kotlin
1
0
dbcb627e693339170ba344847b610f32429f93d1
2,230
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day14/day14.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day14 import biz.koziolek.adventofcode.Coord import biz.koziolek.adventofcode.Line import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val rockLines = parseRockLines(inputFile.bufferedReader().readLines()) val rockMap = bu...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
4,581
advent-of-code
MIT License
src/Day04.kt
bunjix
573,915,819
false
{"Kotlin": 9977}
fun main() { fun fullOverlap(first: IntRange, second: IntRange): Boolean { return (first.first >= second.first && first.last <= second.last) || (first.first <= second.first && first.last >= second.last) } fun overlap(first: IntRange, second: IntRange): Boolean { return first...
0
Kotlin
0
0
ee2a344f6c0bb2563cdb828485e9a56f2ff08fcc
1,264
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/2021/Day7.kt
mstar95
317,305,289
false
null
package `2021` import days.Day import java.lang.Integer.min class Day7 : Day(7) { override fun partOne(): Any { val crabs = inputString.split(",").map { it.toInt() }.sorted() val crabsPos = crabs.groupBy { it }.mapValues { it.value.size } val end = crabs.last() val start = crabs.f...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,125
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day05.kt
mcrispim
573,449,109
false
{"Kotlin": 46488}
fun main() { fun mountStacks(input: List<String>): MutableList<MutableList<Char>> { val lines = mutableListOf<String>() var i = 0 while (true) { val line = input[i] if (line.isEmpty()) break lines.add(line) i++ } val nStacks = ...
0
Kotlin
0
0
5fcacc6316e1576a172a46ba5fc9f70bcb41f532
2,668
AoC2022
Apache License 2.0
src/main/java/com/booknara/problem/union/SmallestStringWithSwapsKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.union import java.util.* import kotlin.collections.HashMap /** * 1202. Smallest String With Swaps (Medium) * https://leetcode.com/problems/smallest-string-with-swaps/ */ class SmallestStringWithSwapsKt { // T:O(n), S:O(n) fun smallestStringWithSwaps(s: String, pairs: List<List<Int>...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,430
playground
MIT License
src/Day21.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
enum class Day21Operator { Plus, Minus, Times, Div, } sealed class Expression { data class Value(val value: Int): Expression() data class Operation(val op: Day21Operator, val left: String, val right: String): Expression() } fun main() { fun parseInput(input: List<String>): Map<String, Expr...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
4,704
aoc-2022
Apache License 2.0
src/day11/day11.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day11 import util.readInput import util.shouldBe import java.util.LinkedList fun main() { val day = 11 val testInput = readInput(day, testInput = true).parseInput() part1(testInput) shouldBe 10605L part2(testInput) shouldBe 2713310158L val input = readInput(day).parseInput() println("...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
4,111
advent-of-code-2022
Apache License 2.0
src/Day05/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day05 import readInput fun main() { fun parseSlot(slot: String) : Char? { return slot .replace("[", "") .replace("]", "") .trim() .firstOrNull() } fun parseContainerLine(line: String) : MutableList<Char?> { return line.chunked(4) { ...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
3,336
aoc-2022
Apache License 2.0
modules/randomly/src/main/kotlin/silentorb/mythic/randomly/WeightedPoolTable.kt
silentorb
227,508,449
false
null
package silentorb.mythic.randomly data class WeightedPoolTable( val alias: List<Int>, val probability: List<Int>, val total: Int, ) fun newWeightedPoolTable(probabilities: List<Int>): WeightedPoolTable { require(probabilities.any()) { "Alias table probabilities list cannot be empty." } val alias = Int...
0
Kotlin
0
2
74462fcba9e7805dddec1bfcb3431665df7d0dee
1,598
mythic-kotlin
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day25.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day25() = puzzle(day = 25) { // I am quite happy I solved it with a viz, this algorithm is... not great val total = buildMap<String, List<String>> { inputLines.forEach { l -> val (n, rest) = l.split(": ") ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,668
advent-of-code
The Unlicense
src/Day07.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
// Node can be either a file or directory // directories will have size 0 data class Node(val nodes: MutableList<Node>, val parent: Node?, val name: String, val size: Int) fun main() { fun buildFilesystem(input: List<String>): Node { var filesystem = Node(mutableListOf(), null, "/" , 0) var current...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
3,152
advent-of-code-2022
Apache License 2.0
src/Day11.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
import java.math.BigInteger fun main() { data class Monkey( var items: MutableList<BigInteger> = mutableListOf(), var testDivision: Int = 1, var operation: (BigInteger) -> BigInteger = { it }, var targetTrue: Int = -1, var targetFalse: Int = -1, var process: Int = 0,...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
4,576
advent-2022
Apache License 2.0
src/main/kotlin/d7/D7_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d7 import input.Input const val CARD_LABELS_JOKER = "AKQT98765432J" data class JokerHand( val cards: String, val bid: Int ) : Comparable<JokerHand> { override fun compareTo(other: JokerHand): Int { val typeDiff = this.getTypeStrength() - other.getTypeStrength() if (typeDiff != 0) ...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
2,712
aoc2023-kotlin
MIT License
src/day_15/kotlin/Day15.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
import kotlin.math.absoluteValue import kotlin.system.measureTimeMillis // AOC Day 15 fun Vector2D.manhattanDistanceTo(other: Vector2D) = (this - other).abs().run { x + y } data class Sensor(val position: Vector2D, val beaconPosition: Vector2D) { val beaconDistance = position.manhattanDistanceTo(beaconPosition) ...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
3,500
AdventOfCode2022
MIT License
src/main/kotlin/g1401_1500/s1467_probability_of_a_two_boxes_having_the_same_number_of_distinct_balls/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1467_probability_of_a_two_boxes_having_the_same_number_of_distinct_balls // #Hard #Dynamic_Programming #Math #Backtracking #Combinatorics #Probability_and_Statistics // #2023_06_13_Time_150_ms_(100.00%)_Space_34_MB_(100.00%) class Solution { fun getProbability(balls: IntArray): Double { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,620
LeetCode-in-Kotlin
MIT License
kotlin/src/main/kotlin/year2023/Day09.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 import java.util.* fun main() { val input = readInput("Day09") Day09.part1(input).println() Day09.part2(input).println() } object Day09 { fun part1(input: List<String>): Long { return input .map { line -> toIntList(line) } .sumOf { history -> predictio...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
1,924
advent-of-code
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2360/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2360 /** * LeetCode page: [2360. Longest Cycle in a Graph](https://leetcode.com/problems/longest-cycle-in-a-graph/); */ class Solution { private val unknownLength = -1 /* Complexity: * Time O(N) and Space O(N) where N is the size of edges; */ fun longestC...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,972
hj-leetcode-kotlin
Apache License 2.0
src/test/kotlin/year2015/Day9.kt
abelkov
47,995,527
false
{"Kotlin": 48425}
package year2015 import kotlin.math.max import kotlin.math.min import kotlin.test.Test import kotlin.test.assertEquals class Day9 { @Test fun part1() { val regex = """(\w+) to (\w+) = (\d+)""".toRegex() val cities = mutableSetOf<String>() val map = mutableMapOf<Pair<String, String>, In...
0
Kotlin
0
0
0e4b827a742322f42c2015ae49ebc976e2ef0aa8
2,075
advent-of-code
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day22.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.intersect import com.chriswk.aoc.util.intersects import com.chriswk.aoc.util.report import com.chriswk.aoc.util.size class Day22 : AdventDay(2021, 22) { companion object { @JvmStatic fun main(args: Arra...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,537
adventofcode
MIT License
src/main/kotlin/leetcode/google/Problem1548.kt
Magdi
390,731,717
false
null
package leetcode.google /** * The Most Similar Path in a Graph * https://leetcode.com/problems/the-most-similar-path-in-a-graph/ */ class Problem1548 { private val cache = hashMapOf<Pair<Int, Int>, Int>() /** * Time * O ( p * n * n ) * p: path length * n: number of nodes * * S...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
2,037
ProblemSolving
Apache License 2.0
src/Day13.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
import kotlinx.serialization.json.* class PacketComparator: Comparator<JsonElement> { override fun compare(o1: JsonElement, o2: JsonElement): Int { var a = o1; var b = o2 if (a is JsonArray && b is JsonArray) { // compare lists for (i in 0 until a.size.coerceAtMost(b.size)) ...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
2,559
advent-of-code-2022
Apache License 2.0
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/simple/interview/Massage.kt
scientificCommunity
352,868,267
false
{"Java": 154453, "Kotlin": 69817}
package org.baichuan.sample.algorithms.leetcode.simple.interview /** * https://leetcode.cn/problems/the-masseuse-lcci/ * 面试题 17.16. 按摩师 */ class Massage { /** * 时间复杂度:O(n) * 空间复杂度:O(n) * 状态转移方程: dp[i] = max(dp[i-1],dp[i-2]) */ fun massage(nums: IntArray): Int { if (nums.isEmpty()...
1
Java
0
8
36e291c0135a06f3064e6ac0e573691ac70714b6
1,784
blog-sample
Apache License 2.0
src/Day18.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import utils.BBox3D import utils.Coord3D import java.util.LinkedList enum class Direction3D(val vector: Coord3D) { RIGHT(Coord3D(1, 0, 0)), LEFT(Coord3D(-1, 0, 0)), TOP(Coord3D(0, 1, 0)), BOTTOM(Coord3D(0, -1, 0)), BACK(Coord3D(0, 0, 1)), FORWARD(Coord3D(0, 0, -1)); } fun main() { fun part...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
2,603
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/graph/variation/LoopedTree.kt
yx-z
106,589,674
false
null
package graph.variation import graph.core.Vertex import graph.core.WeightedEdge import graph.core.WeightedGraph import util.Tuple2 import util.tu import java.util.* import kotlin.collections.HashMap // given a looped binary tree - non-negatively weighted, directed graph, // built from a binary tree by adding an edge ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
3,463
AlgoKt
MIT License
src/Day05.kt
emmanueljohn1
572,809,704
false
{"Kotlin": 12720}
fun buildStacks (stackList: List<List<Char>>, size: Int): ArrayList<ArrayDeque<Char>> { val stacks = ArrayList<ArrayDeque<Char>>() for(i in 0 until size){ val stack = ArrayDeque<Char>() for (j in stackList.indices){ if(stackList[j][i] != ' '){ stack.add(stackList[j][i...
0
Kotlin
0
0
154db2b1648c9d12f82aa00722209741b1de1e1b
2,392
advent22
Apache License 2.0
kotest-property/src/commonMain/kotlin/io/kotest/property/Shrinker.kt
kotest
47,071,082
false
{"Kotlin": 4460715, "CSS": 352, "Java": 145}
package io.kotest.property /** * Given a value, T, this function returns reduced values to be used as candidates * for shrinking. * * A smaller value is defined per Shrinker. For a string it may be considered a string with * less characters, or less duplication/variation in the characters. For an integer it is ty...
102
Kotlin
615
4,198
7fee2503fbbdc24df3c594ac6b240c11b265d03e
2,522
kotest
Apache License 2.0
src/Day08.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
fun main() { fun left2right(grid: List<String>, dp: Array<Array<Boolean>>) { for (i in grid.indices) { var max = -1 for (j in grid[0].indices) { if (grid[i][j] - '0' > max) dp[i][j] = true max = maxOf(grid[i][j] - '0', max) } } } fun right2left(grid: List<String>, dp: A...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
2,354
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/nl/kelpin/fleur/advent2018/Day15.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 import java.util.* class Day15(val input: List<String>) { val cave: List<String> = input.map { it.map { c -> when (c) { '#' -> '#' else -> '.' } }.joinToString("") } val xRange: IntRange = cave[0].in...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
5,344
advent-2018
MIT License
kotlin/src/katas/kotlin/leetcode/maximum_area_serving_cake/MaximumAreaServingCake.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.leetcode.maximum_area_serving_cake import datsok.shouldEqual import org.junit.Test import kotlin.math.PI import kotlin.math.abs /** * https://leetcode.com/discuss/interview-question/348510 */ class MaximumAreaServingCakeTests { @Test fun examples() { findLargestPiece(radii = arrayOf...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,754
katas
The Unlicense
src/Day02.kt
cznno
573,052,391
false
{"Kotlin": 7890}
import java.nio.file.Files import java.nio.file.Path object Day02 { private val map1 = mapOf("X" to 1, "Y" to 2, "Z" to 3) private val map2 = mapOf( "A X" to 3, "A Y" to 6, "A Z" to 0, "B X" to 0, "B Y" to 3, "B Z" to 6, "C X" to 6, "C Y" to 0, "C Z" to 3, ) private val list = ...
0
Kotlin
0
0
423e7111e2f1b457b0f2b30ffdcf5c00ca95aed9
2,093
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/io/WordLadderII.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io import io.utils.runTests import java.util.* //https://leetcode.com/problems/word-ladder-ii/description/ class WordLadderII { // WIP , not working yet fun execute(beginWord: String, endWord: String, wordList: List<String>): List<List<String>> { val list = arrayListOf<List<String>>() val queue ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,209
coding
MIT License
src/main/kotlin/com/groundsfam/advent/y2022/d12/Day12.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d12 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.grids.Grid import com.groundsfam.advent.grids.containsPoint import com.groundsfam.advent.points.Point import com.groundsfam.advent.points.down import com.groundsfam.advent.points.left import com.groundsfam.advent...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
4,488
advent-of-code
MIT License
src/day8/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day8 import Coords import asCoordsSequence import readInput import takeWhileInclusive import toIntMatrix fun main() { fun part1(input: List<String>): Int { val forest = input.toIntMatrix() return forest .asCoordsSequence() .count(forest::isVisible) } fun p...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
1,760
AoC-2022
Apache License 2.0
src/Day03.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
fun main() { fun computePriority(c: Char): Int { return if (Character.isUpperCase(c)) c.lowercaseChar().code - 96 + 26 else c.code - 96 } fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val m = line.length / 2 ...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
1,196
AdventOfCode-2022
Apache License 2.0
src/Day13.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
import kotlin.math.sign fun main() { open class Value data class IntValue(val value: Int) : Value() data class ListValue(val values: List<Value>) : Value() { fun isSmaller(other: ListValue): Int { val toCheck = values.size.coerceAtLeast(other.values.size) for (i in 0 until...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
4,218
AdventOfCode2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day09/Day09.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.day09 import nl.sanderp.aoc.common.* fun main() { val input = readResource("Day09.txt") .lines() .flatMapIndexed { y, s -> s.mapIndexed { x, c -> Point2D(x, y) to c.asDigit() } } .toMap() val (answer1, duration1) = measureDuration<Int> { partOne(input) }...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,453
advent-of-code
MIT License
src/day07/Day07Answer2.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day07 import readString /** * Answers from [Advent of Code 2022 Day 7 | Kotlin](https://youtu.be/Q819VW8yxFo) */ val input = readString("day07").split("$ ").drop(1).map { it.trim() } fun main() { var current = VFolder("/", parent = null) val root = current for (i in input.drop(1)) { whe...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
2,348
advent-of-code-2022
Apache License 2.0
aockt-test/src/test/kotlin/io/github/jadarma/aockt/test/integration/MultipleSolutions.kt
Jadarma
324,646,170
false
{"Kotlin": 38013}
package io.github.jadarma.aockt.test.integration import io.github.jadarma.aockt.core.Solution import io.github.jadarma.aockt.test.AdventDay import io.github.jadarma.aockt.test.AdventSpec /** A solution to a fictitious puzzle used for testing using collections. */ class Y9999D01UsingCollections : Solution { priva...
0
Kotlin
0
4
1db6da68069a72256c3e2424a0d2729fc59eb0cf
1,850
advent-of-code-kotlin
MIT License
src/day8/Code.kt
fcolasuonno
221,697,249
false
null
package day8 import printWith import java.io.File const val test = false fun main() { val name = if (test) "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)}") prin...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
2,309
AOC2016
MIT License
kotlin/src/com/leetcode/304_RangeSumQuery2DImmutable.kt
programmerr47
248,502,040
false
null
package com.leetcode class NumMatrix(matrix: Array<IntArray>) { private val partialSums = Array(matrix.size) { IntArray(matrix[it].size) } init { for (i in matrix.indices) { for (j in matrix[i].indices) { partialSums[i][j] = when { i == 0 && j == 0 -> ma...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,348
problemsolving
Apache License 2.0