path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/aoc2020/MonsterMessages.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.nonEmptyLines fun monsterMessages(input: String, alterRule: (String) -> String = { it }): Int { val (rulesPart, messagesPart) = input.split("\n\n") val rule = buildRules(rulesPart.nonEmptyLines().map(alterRule)) val messages = messagesPart....
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,120
advent-of-code
MIT License
advent2022/src/main/kotlin/year2022/Day05.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay private typealias Move = Triple<Int, Int, Int> data class Field(val cols: List<List<Char>>, val pickup: (List<Char>, Int) -> List<Char>): List<List<Char>> by cols { val result: String get() = cols.joinToString("") { it[0].toString() } fun makeMove(move: Move): Field...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,319
advent-of-code
Apache License 2.0
src/Day03.kt
rxptr
572,717,765
false
{"Kotlin": 9737}
fun main() { fun mapPriorities(chars: List<Char>) = chars.map { if (it.isLowerCase()) it.code - 96 else it.code - 38 } fun part1(input: List<String>): Int { val pairs = input.map { val (a, b) = it.chunked(it.length / 2) Pair(a.toSet(), b.toSet()) } val duplicate...
0
Kotlin
0
0
989ae08dd20e1018ef7fe5bf121008fa1c708f09
893
aoc2022
Apache License 2.0
src/Day05.kt
BHFDev
572,832,641
false
null
fun main() { fun part1(input: List<String>): String { val separator = input.indexOf(input.find { it.isBlank() }) val crates = input.subList(0, separator - 1) val instructions = input.subList(separator + 1, input.size) val stacks = mutableListOf<ArrayDeque<Char>>() crates.forE...
0
Kotlin
0
0
b158069483fa02636804450d9ea2dceab6cf9dd7
2,923
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem57/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem57 /** * LeetCode page: [57. Insert Interval](https://leetcode.com/problems/insert-interval/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the size of intervals; */ fun insert(intervals: Array<IntArray>, newInterval: IntArray): Arra...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
3,881
hj-leetcode-kotlin
Apache License 2.0
src/day13/Day13.kt
spyroid
433,555,350
false
null
package day13 import com.github.ajalt.mordant.terminal.Terminal import readInput import kotlin.random.Random import kotlin.system.measureTimeMillis fun main() { data class Point(var x: Int, var y: Int) class Paper(input: List<String>) { var points = mutableSetOf<Point>() val folds = mutable...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
2,426
Advent-of-Code-2021
Apache License 2.0
src/Day04.kt
stephenkao
572,205,897
false
{"Kotlin": 14623}
fun main() { /** * @param rangesStr the ranges string (e.g., '1-2,3-4') * @return list of integer sets per range */ fun getSetsFromRanges(rangesStr: String): Pair<Set<Int>, Set<Int>> { val (startIdx1, endIdx1, startIdx2, endIdx2) = rangesStr.split("[,\\-]".toRegex()) return Pair( ...
0
Kotlin
0
0
7a1156f10c1fef475320ca985badb4167f4116f1
1,553
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch9/Problem92.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch9 import dev.bogwalk.util.combinatorics.permutationID import dev.bogwalk.util.maths.factorial import java.math.BigInteger /** * Problem 92: Square Digit Chains * * https://projecteuler.net/problem=92 * * Goal: Return the count of starting numbers below 10^K will arrive at 89 (modulo 10^9...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
8,762
project-euler-kotlin
MIT License
src/main/kotlin/com/jacobhyphenated/advent2022/day11/Day11.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day11 import com.jacobhyphenated.advent2022.Day /** * Day 11: Monkey in the Middle * * Monkeys are playing keep away with your items. Each item has a score of how worried you are about losing it. * During a round, each monkey inspects each item it has, calculates a new worry...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
4,870
advent2022
The Unlicense
src/main/kotlin/aoc2022/Day16.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* import kotlin.math.absoluteValue private const val empty: Int = Int.MAX_VALUE class Day16() { data class Valve(val name: String, val flowRate: Int, val tunnelsTo: List<String>) { override fun toString() = "$name($flowRate)" } //Valve AA has flow r...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
5,884
aoc-kotlin
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day10.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import adventofcode.util.vector.Direction import adventofcode.util.vector.Direction.* import adventofcode.util.vector.Vec2 import adventofcode.util.vector.toGrid fun main() { Day10.solve() } object Day10 : AdventSolution(2023, 10, "Pipe Maze") { ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,950
advent-of-code
MIT License
2021/src/main/kotlin/day24.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut fun main() { Day24Imp.run(skipTest = true) } object Day24Imp : Solution<List<List<Day24Imp.Insn>>>() { override val name = "day24" private const val DIGITS = 14 override val parser = Parser { input -> val progStrings = input.split("inp w\n").map...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,815
aoc_kotlin
MIT License
y2020/src/main/kotlin/adventofcode/y2020/Day18.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution import java.util.Stack fun main() = Day18.solve() object Day18 : AdventSolution(2020, 18, "Operation Order") { override fun solvePartOne(input: String) = input.lineSequence().sumOf { evaluate(it, ::evalLeftToRight) } override fun solvePartTwo(i...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,745
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumMatrix.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,209
kotlab
Apache License 2.0
src/Day07.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
fun main() { fun part1(input: List<String>): Long { return determineCumulativeDirectorySizes(input) .filter { it.value <= 100000 } .map { it.value } .sum() } fun part2(input: List<String>): Long { val cumulativeSizes = determineCumulativeDirectorySizes(i...
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
2,903
adventofcode-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day17.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.data_structures.Dijkstra import tr.emreone.kotlin_utils.data_structures.Graph import tr.emreone.kotlin_utils.extensions.area import tr.emreone.kotlin_utils.extensions.formatted import tr.emreone.kotlin_uti...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
3,225
advent-of-code-2023
Apache License 2.0
Word_Search_II.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
// Given a 2D board and a list of words from the dictionary, find all words in the board. //https://leetcode.com/problems/word-search-ii/discuss/59780/Java-15ms-Easiest-Solution-(100.00) class Solution { fun findWords(board: Array<CharArray>, words: Array<String>): List<String> { val root = buildTrie(words...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
2,488
leetcode
MIT License
src/Day02.kt
virtualprodigy
572,945,370
false
{"Kotlin": 8043}
import kotlin.math.max fun main() { val winningsMap = hashMapOf<String, Int>( "Lose" to 0, "Win" to 6, "Draw" to 3 ) val fightResultsMap = hashMapOf<String, String>( "ax" to "Draw", "ay" to "Win", "az" to "Lose", "bx" to "Lose", "by" to "Dra...
0
Kotlin
0
0
025f3ae611f71a00e9134f0e2ba4b602432eea93
2,296
advent-code-code-kotlin-jetbrains-2022
Apache License 2.0
src/Day04.kt
mvanderblom
573,009,984
false
{"Kotlin": 25405}
fun String.toIntRange(delimiter: String): IntRange { val (from, to) = this .split(delimiter) .map { it.toInt() } return IntRange(from, to) } fun IntRange.contains(other: IntRange): Boolean = this.first <= other.first && other.last <= this.last fun main() { val dayName = 4.toDayName...
0
Kotlin
0
0
ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690
1,200
advent-of-code-kotlin-2022
Apache License 2.0
src/Day01.kt
geodavies
575,035,123
false
{"Kotlin": 13226}
fun main() { fun part1(input: List<String>): Int { var elfNumber = 1 val elfCalories = mutableMapOf<Int, Int>() var mostCalories = 0 input.forEach { calories -> if (calories == "") { elfNumber++ } else { val currentCalories = e...
0
Kotlin
0
0
d04a336e412ba09a1cf368e2af537d1cf41a2060
1,732
advent-of-code-2022
Apache License 2.0
src/Day06.kt
makobernal
573,037,099
false
{"Kotlin": 16467}
fun findIndex(list: List<String>, condition: (String) -> Boolean): Int { for (i in list.indices) { if (condition(list[i])) { return i } } return -1 } fun main() { fun solutioner(input: List<String>, windowSize: Int): Int { val indexWhereThisHappens = findIndex( ...
0
Kotlin
0
0
63841809f7932901e97465b2dcceb7cec10773b9
1,229
kotlin-advent-of-code-2022
Apache License 2.0
src/Day03/Day03.kt
ctlevi
578,257,705
false
{"Kotlin": 10889}
fun main() { fun part1(input: List<String>): Int { return input.map { row -> val first = row.toList().subList(0, row.length / 2).toSet() val second = row.toList().subList(row.length / 2, row.length).toSet() val overlappingChar = first.intersect(second).first() ...
0
Kotlin
0
0
0fad8816e22ec0df9b2928983713cd5c1ac2d813
1,241
advent_of_code_2022
Apache License 2.0
src/main/kotlin/g1901_2000/s1932_merge_bsts_to_create_single_bst/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1932_merge_bsts_to_create_single_bst // #Hard #Hash_Table #Depth_First_Search #Tree #Binary_Search #Binary_Tree // #2023_06_20_Time_1146_ms_(100.00%)_Space_84.5_MB_(100.00%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary t...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,292
LeetCode-in-Kotlin
MIT License
src/Day07.kt
romainbsl
572,718,344
false
{"Kotlin": 17019}
fun main() { fun initFileSystem(input: List<String>): Directory { val root = Directory("/", null) var dir: Directory = root input.drop(1).forEach { line -> when (line.first()) { '$' -> { val command = line.split(" ") when (...
0
Kotlin
0
0
b72036968769fc67c222a66b97a11abfd610f6ce
2,674
advent-of-code-kotlin-2022
Apache License 2.0
leetcode/src/daily/easy/Q1800.kt
zhangweizhe
387,808,774
false
null
package daily.easy fun main() { // 1800. 最大升序子数组和 // https://leetcode.cn/problems/maximum-ascending-subarray-sum/ println(maxAscendingSum1(intArrayOf(10,20,30,5,10,50))) } fun maxAscendingSum(nums: IntArray): Int { if (nums.size == 1) { return nums[0] } var max = 0 var tmpMax = num...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,437
kotlin-study
MIT License
src/Day08.kt
tigerxy
575,114,927
false
{"Kotlin": 21255}
fun main() { fun part1(input: List<String>): Int { return with(input.parse()) { isVerticalVisible() .or(isHorizontalVisible()) .sum() } } fun part2(input: List<String>): Int { return 0 } val day = "08" // test if implementation m...
0
Kotlin
0
1
d516a3b8516a37fbb261a551cffe44b939f81146
2,192
aoc-2022-in-kotlin
Apache License 2.0
Dynamic Programming/Longest Palindromic Subsequence/src/Task.kt
jetbrains-academy
515,621,972
false
{"Kotlin": 123026, "TeX": 51581, "Java": 3566, "Python": 1156, "CSS": 671}
import kotlin.math.max private class PalindromicSubsequenceFinder(private val seq: CharSequence) { companion object { const val PLACEHOLDER = -1 } val longest = Array(seq.length) { IntArray(seq.length) { PLACEHOLDER } } private fun calculateLongest(left: Int, right: Int): Int { if (le...
2
Kotlin
0
10
a278b09534954656175df39601059fc03bc53741
1,837
algo-challenges-in-kotlin
MIT License
aoc/src/main/kotlin/com/bloidonia/aoc2023/day15/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day15 import com.bloidonia.aoc2023.text import kotlin.streams.asSequence private const val example = "rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7" private fun score(s: String) = s.chars().asSequence().fold(0L) { acc, n -> ((acc + n) * 17).mod(256L) } private fun part1(input...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
1,941
aoc-2023
MIT License
src/Day09.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
import kotlin.math.absoluteValue import kotlin.math.sign data class Point(val x: Int = 0, val y: Int = 0) { fun move(direction: Char): Point = when (direction) { 'U' -> copy(y = y - 1) 'D' -> copy(y = y + 1) 'L' -> copy(x = x - 1) 'R' -> copy(x = x + 1) ...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
1,988
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
cornz
572,867,092
false
{"Kotlin": 35639}
fun main() { fun getUpperAndLowerBounds(input: String): Pair<Int, Int> { //2-4 val parts = input.split("-") val startIndex = parts[0].toInt() val endIndex = parts[1].toInt() return Pair(startIndex, endIndex) } fun intersection(input: String): Boolean { val ...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
2,240
aoc2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day18.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import kotlin.math.ceil open class Part18A : PartSolution() { private val pairPattern = Regex("""\[(\d+),(\d+)]""") private val numberPattern = Regex("""\d+""") private val doubleDigitPattern ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
4,150
advent-of-code-kotlin
MIT License
jk/src/main/kotlin/leetcode/Solution_LeetCode_215_347_Heap_Related.kt
lchang199x
431,924,215
false
{"Kotlin": 86230, "Java": 23581}
package leetcode import java.util.* /** * 堆相关的一些题目解法 */ class Solution_LeetCode_215_347_Heap_Related { /** * 数组中第k大元素: LeetCode_215 * [](https://leetcode-cn.com/problems/kth-largest-element-in-an-array/) * * 另堆排序解法 */ fun findKthLargest(nums: IntArray, k: Int): Int { val qu...
0
Kotlin
0
0
52a008325dd54fed75679f3e43921fcaffd2fa31
3,018
Codelabs
Apache License 2.0
src/Day21.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<Job> = input.map { Job.parse(it) } fun part1(input: List<String>): Long { val jobs = parse(input) val monkeys = jobs.associateBy { it.monkey } monkeys.values.filterIsInstance<Job.Operate>().forEach { operateJob -> operateJo...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
2,492
advent-of-code-2022
Apache License 2.0
src/Day10/Day10.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day10 import readInput fun main() { data class Instruction(val cycle: Int, val increment: Int) fun execute(instruction: String): Instruction { if (instruction == "noop") { return Instruction(1, 0) } val (_, increment) = instruction.split(" ") return Instru...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
1,995
aoc-2022
Apache License 2.0
src/Day07.kt
orirabi
574,124,632
false
{"Kotlin": 14153}
enum class FillUpState { NOT_INIT, IN_PROGRESS, FULL } data class Dir( val parent: Dir?, val name: String, var fillUpState: FillUpState = FillUpState.NOT_INIT, val files: MutableList<File> = mutableListOf(), val directories: MutableList<Dir> = mutableListOf(), ) { val size: Int by lazy { files....
0
Kotlin
0
0
41cb10eac3234ae77ed7f3c7a1f39c2f9d8c777a
3,004
AoC-2022
Apache License 2.0
src/day3/Day03.kt
blundell
572,916,256
false
{"Kotlin": 38491}
package day3 import readInput fun main() { /** * https://theasciicode.com.ar/ */ fun Char.toElfIndex() = if (isLowerCase()) { (code - 96) } else { (code - 38) } /** * Lowercase item types a through z have priorities 1 through 26. * Uppercase item types A throu...
0
Kotlin
0
0
f41982912e3eb10b270061db1f7fe3dcc1931902
1,847
kotlin-advent-of-code-2022
Apache License 2.0
src/Day03.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>): Int = input .map { it.chunked(it.length / 2, CharSequence::toSet) } .map { (a, b) -> a.first { it in b } } .sumOf(::priority) fun part2(input: List<String>): Int = input .map { it.toSet() } .chunked(3) .map { (a, b, c)...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
764
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day11/Day11.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day11 import com.tonnoz.adventofcode23.utils.readInput import com.tonnoz.adventofcode23.utils.toCharMatrix import kotlin.system.measureTimeMillis const val FIRST_CHAR = 47 // starting from 47 because 46 it's '.' which was causing problems object Day11 { @JvmStatic fun main(args:...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,347
adventofcode23
MIT License
src/main/kotlin/biz/koziolek/adventofcode/year2021/day12/day12.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day12 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val graph = parseCavesGraph(lines) val paths1 = findAllPaths(graph, ::visitSmallCavesOnlyOnce) println("There i...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
3,699
advent-of-code
MIT License
src/main/kotlin/days/Day19.kt
mstar95
317,305,289
false
null
package days import arrow.core.extensions.list.foldable.isNotEmpty class Day19 : Day(19) { override fun partOne(): Any { val (grammars, words) = prepareInput(inputList) val map = words.map { parse(grammars, it, grammars[0]!!) } // println(map) return map.filter { it.isNotEmpty() &...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,822
aoc-2020
Creative Commons Zero v1.0 Universal
Create-an-euphonious-word/src/main/kotlin/Main.kt
victorYghor
610,409,660
false
null
val vowels: List<Char> = listOf('a', 'e', 'i', 'o', 'u', 'y') val consonants: List<Char> = listOf('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z') fun fixClusterVowels(cluster: String): String { val listOfVowels: MutableList<Char> = cluster.toMutableList() va...
0
Kotlin
0
0
0d30e37016cd2158d87de59f7cf17125627fc785
4,786
Kotlin-Problems
MIT License
src/Day08.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
fun main() { fun getWest(row: String, until: Int): List<Int> { if (until > 0) { return row.substring(0, until).map { c -> c.digitToInt() } } return emptyList() } fun getEast(row: String, start: Int): List<Int> { if (start < row.length) { return row.su...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
3,836
AoC2022
Apache License 2.0
year2020/src/main/kotlin/net/olegg/aoc/year2020/day19/Day19.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day19 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseInts import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2020.DayOf2020 import net.olegg.aoc.year2020.day19.Day19.Rule.CharRule import net.olegg.aoc.year2020.day19.Day19.Rule.RefRule /** * See [Year 2020,...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,709
adventofcode
MIT License
src/Day09.kt
monsterbrain
572,819,542
false
{"Kotlin": 42040}
import kotlin.math.abs import kotlin.math.sign class Point(val x: Int, val y: Int) { override fun toString(): String { return "[$x,$y]" } override fun equals(other: Any?): Boolean { return x == (other as Point).x && y == (other as Point).y } } class Node(var x: Int, var y: Int, val na...
0
Kotlin
0
0
3a1e8615453dd54ca7c4312417afaa45379ecf6b
3,590
advent-of-code-kotlin-2022-Solutions
Apache License 2.0
src/day10/Day10.kt
pientaa
572,927,825
false
{"Kotlin": 19922}
package day10 import readLines fun main() { fun generateOperations(input: List<String>): List<Operation> = input.map { when { it.contains("noop") -> { Operation(1, 0) } it.contains("addx") -> { Operation(2, it.split(" ").last().toInt())...
0
Kotlin
0
0
63094d8d1887d33b78e2dd73f917d46ca1cbaf9c
1,875
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader import java.util.* fun main() { val testInput = """ A Y B X C Z """.trimIndent() check( partOne(testInput.reader()) == 15 ) val input = file("Day02.txt") println(partOne(input.bufferedReader())) check( partTwo(testInput.reade...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
2,717
advent-of-code-2022-kotlin
Apache License 2.0
codeforces/kotlinheroes3/h.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes3 private fun solve() { val s = readLn() val inf = (s.maxOrNull()!! + 1).toString() val init = listOf(listOf(inf to listOf<Boolean>()), listOf("" to listOf())) val ans = s.foldIndexed(init) { i, (sure, unsure), c -> val next = List(2) { MutableList(i + 1) { inf to listOf<Boolean>()...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,226
competitions
The Unlicense
src/main/kotlin/com/psmay/exp/advent/y2021/Day05.kt
psmay
434,705,473
false
{"Kotlin": 242220}
package com.psmay.exp.advent.y2021 import kotlin.math.abs object Day05 { data class Point(val x: Int, val y: Int) private fun sgn(n: Int) = if (n < 0) -1 else if (n > 0) 1 else 0 fun forwardRange(a: Int, b: Int) = if (a > b) b..a else a..b data class Line(val start: Point, val end: Point) { ...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
2,813
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
src/twentytwentytwo/day11/Day11.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day11 import readInput fun main() { data class Monkey( val items: MutableList<Long>, val operation: (Long, Int) -> Long, val test: Long, val trueId: Int, val falseId: Int, var inspected: Long = 0, ) fun part1(input: List<String>): Lo...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
4,118
advent-of-code
Apache License 2.0
src/main/kotlin/days/y2023/day18/Day18.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day18 import util.InputReader typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day18(val input: PuzzleInput) { val instructions = input.toInstructions() fun partOne(): Int { val loop = instructions.drawLoop() val minX = loop.minOf { it.x } ...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,938
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountRangeSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,883
kotlab
Apache License 2.0
src/Day10.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
package day10 import utils.string.asLines import utils.readInputAsText import utils.runSolver import utils.string.blockChar import utils.string.squiggleChar private typealias SolutionType = Int private const val defaultSolution = 0 private const val dayNumber: String = "10" private val testSolution1: SolutionType? ...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
2,137
2022-AOC-Kotlin
Apache License 2.0
src/main/kotlin/g1301_1400/s1334_find_the_city_with_the_smallest_number_of_neighbors_at_a_threshold_distance/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1334_find_the_city_with_the_smallest_number_of_neighbors_at_a_threshold_distance // #Medium #Dynamic_Programming #Graph #Shortest_Path // #2023_06_06_Time_223_ms_(88.89%)_Space_37.5_MB_(77.78%) class Solution { fun findTheCity(n: Int, edges: Array<IntArray>, maxDist: Int): Int { val gr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,127
LeetCode-in-Kotlin
MIT License
src/Day04.kt
stevefranchak
573,628,312
false
{"Kotlin": 34220}
import java.util.function.Predicate class SectionAssignment( private val start: Int, private val end: Int, ) { fun contains(other: SectionAssignment) = other.start >= start && other.end <= end fun overlaps(other: SectionAssignment) = end >= other.start && start <= other.end companion object { ...
0
Kotlin
0
0
22a0b0544773a6c84285d381d6c21b4b1efe6b8d
1,653
advent-of-code-2022
Apache License 2.0
facebook/y2020/round3/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.round3 import java.util.* private fun solve(): Int { val (n, m, k, x) = readInts() val (sIn, pIn) = listOf(n, m).map { length -> val array = readInts().toIntArray() + IntArray(length - k) { 0 } val (a, b, c, d) = readInts() for (i in k until length) { array[i] = ((a.toLong() * array[...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,089
competitions
The Unlicense
src/main/kotlin/dev/paulshields/aoc/Day19.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 19: Beacon Scanner */ package dev.paulshields.aoc import dev.paulshields.aoc.common.Point3D import dev.paulshields.aoc.common.readFileAsString import kotlin.math.abs fun main() { println(" ** Day 19: Beacon Scanner ** \n") val scannerReport = readFileAsString("/Day19ScannerReport.txt") val a...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
6,446
AdventOfCode2021
MIT License
src/year2023/day18/Day18.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day18 import check import readInput import kotlin.math.absoluteValue fun main() { val testInput = readInput("2023", "Day18_test") check(part1(testInput), 62) check(part2(testInput), 952408144115) val input = readInput("2023", "Day18") println(part1(input)) println(part2(input...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,038
AdventOfCode
Apache License 2.0
solutions/aockt/y2023/Y2023D02.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import io.github.jadarma.aockt.core.Solution object Y2023D02 : Solution { /** * Holds observations for one instance of the elf's game. * @property id The ID of the game. * @property rounds The color-count of the balls revealed during the game. */ private data class Gam...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,820
advent-of-code-kotlin-solutions
The Unlicense
src/day14/Day14.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day14 import readInput fun main() { val testInput = readInput("day14/test") val rocks = mutableSetOf<Position>() testInput.forEach { input -> val iterator = input.split(" -> ").map { Position(it.split(',')[1].toInt(), it.split(',')[0].toInt()) }.iterator() var currentP...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
3,206
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day13/Day13Puzzle.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day13 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver abstract class Day13Puzzle : PuzzleSolver { final override fun solve(inputLines: Sequence<String>): String { val manualSections = inputLines.partition { !it.startsWith("fold") }...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
2,009
AdventOfCode2021
Apache License 2.0
2021/src/day08/day8.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day08 import java.io.File import kotlin.math.pow import kotlin.streams.toList fun main() { val input = File("src/day08", "day8input.txt").readLines().map { parseLine(it) } println(getUniqueSegments(input.map { it.second }).size) val outputSum = input.sumOf { val digitMap = analyzeInput(it...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
6,180
adventofcode
Apache License 2.0
src/Day05.kt
eps90
574,098,235
false
{"Kotlin": 9738}
private fun <T> ArrayDeque<T>.push(element: T) = addLast(element) private fun <T> ArrayDeque<T>.push(elements: Collection<T>) = addAll(elements) private fun <T> ArrayDeque<T>.pop() = removeLast() private fun <T> ArrayDeque<T>.peek() = lastOrNull() fun main() { val componentRegex = """\s?(\[?(\w|\d)]?| {3})""".toR...
0
Kotlin
0
0
bbf58c512fddc0ef1112c3bee5e5c6d43f5aabc0
2,933
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day1.kt
dlew
75,886,947
false
null
class Day1 { enum class Direction { NORTH, EAST, SOUTH, WEST; fun turn(turn: Turn) = when (turn) { Turn.NONE -> this Turn.LEFT -> when (this) { NORTH -> WEST WEST -> SOUTH SOUTH -> EAST EAST -> NORTH } ...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
2,478
aoc-2016
MIT License
src/main/kotlin/puzzle8/SevenSegmentsDemystifier.kt
tpoujol
436,532,129
false
{"Kotlin": 47470}
package puzzle8 import kotlin.math.pow import kotlin.system.measureTimeMillis fun main() { val sevenSegmentsDemystifier = SevenSegmentsDemystifier() val basicDigitWiring = DigitWiring() val time = measureTimeMillis { println("test: ${basicDigitWiring.findNumber("acf")}") println("Part 1 so...
0
Kotlin
0
1
6d474b30e5204d3bd9c86b50ed657f756a638b2b
7,497
aoc-2021
Apache License 2.0
src/Day02.kt
Akaneiro
572,883,913
false
null
import Shape.Scissors.drawShape import Shape.Scissors.losingShape import Shape.Scissors.winningShape import java.lang.Exception fun main() { fun getShapesList(input: List<String>) = input.map { val inputInline = it.split(" ", limit = 2) val opponent = inputInline.first() ...
0
Kotlin
0
0
f987830a70a2a1d9b88696271ef668ba2445331f
2,822
aoc-2022
Apache License 2.0
src/main/kotlin/day19.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.Point3D import shared.getText import kotlin.math.abs val seenFromScanner0 = mutableSetOf<Point3D>() val scannerLocationsFromScanner0 = mutableSetOf<Point3D>() fun findBeacons(input: String, minimumOverlap: Int = 12): Int{ seenFromScanner0.clear() scannerLocationsFromScanner0.clear() val scan...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
4,581
AdventOfCode2021
MIT License
src/aoc2023/Day05.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun part1(lines: List<String>): Long { val seeds = lines[0].substring("seeds: ".length).trim().split(" ").map { it.toLong() } var currentlyTranslating = seeds.toTypedArray() var translated = Array(seeds.size) { 0L } var afterBlank = fa...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
6,809
advent-of-code-kotlin
Apache License 2.0
src/Day10.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun part1(input: List<String>): Int { var sum = 0 var x = 1 var c = 20 for (line in input) { val cmd = line.split(' ') val (dx, dc) = when (cmd[0]) { "noop" -> 0 to 1 "addx" -> cmd[1].toInt() to 2 e...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
1,925
aockt
Apache License 2.0
kotlin/src/main/kotlin/year2021/Day02.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2021 private enum class Direction(val value: String) { FORWARD("forward"), DOWN("down"), UP("up"); companion object { infix fun from(value: String): Direction? = entries.firstOrNull { it.value == value } } } private class Command(val direction: Direction, val unit: Int) private fun p...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
1,696
advent-of-code
MIT License
src/Day04.kt
Kaaveh
572,838,356
false
{"Kotlin": 13188}
infix fun IntRange.fullyOverlap(other: IntRange): Boolean = (first in other && last in other) || other.first in this && other.last in this private fun parse(row: String): Pair<IntRange, IntRange> { val (section1Start, section1End) = row.substringBefore(",").split("-").map { it.toInt() } val (section2Start,...
0
Kotlin
0
1
9022f1a275e9c058655898b64c196f7a0a494b48
981
advent-of-code-kotlin-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2022/day14/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day14 import com.kingsleyadio.adventofcode.util.readInput fun main() { val cave = buildCave() part1(cave) part2(cave) } fun part1(cave: Cave) { val sand = hashSetOf<Point>() fun pourSand(grain: IntArray): Boolean { while (true) { val...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
3,128
adventofcode
Apache License 2.0
atcoder/arc155/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package atcoder.arc155 private fun solve(a: List<Int>, b: List<Int>): Boolean { if (a.sorted() != b.sorted()) return false val aIsOmnipotent = isOmnipotent(a) val bIsOmnipotent = isOmnipotent(b) val aEven = mutableListOf<Int>() val bEven = mutableListOf<Int>() fun canSortEven(): Boolean { return (aEven.size >=...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,457
competitions
The Unlicense
src/day05/Day05.kt
robin-schoch
572,718,550
false
{"Kotlin": 26220}
package day05 import AdventOfCodeSolution fun main() { Day05.run() } object Day05 : AdventOfCodeSolution<String, String> { override val testSolution1 = "CMZ" override val testSolution2 = "MCD" private val stacks = mutableMapOf<Int, ArrayDeque<Char>>() private fun constructStacks(intput: List<St...
0
Kotlin
0
0
fa993787cbeee21ab103d2ce7a02033561e3fac3
1,975
aoc-2022
Apache License 2.0
src/Day02.kt
arturradiuk
571,954,377
false
{"Kotlin": 6340}
fun calculateScore(round: List<Char>): Int = when (round.last() - round.first()) { 21, 24 -> 6 + round.last().code - 87 9, 23 -> 3 + round.last().code - 87 else -> round.last().code - 87 } fun calculateScoreWithInstruction(round: List<Char>): Int = when (round.last()) { 'X' -> (round.first().code).mod(...
0
Kotlin
0
0
85ef357643e5e4bd2ba0d9a09f4a2d45653a8e28
1,048
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
Krzychuk9
573,127,179
false
null
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val opponentStrategy = getGameStrategy(it[0]) val strategy = getGameStrategy(it[2]) strategy.getResult(opponentStrategy) + strategy.getPoint() } } fun part2(input: List<String>): Int ...
0
Kotlin
0
0
ded55d03c9d4586166bf761c7d5f3f45ac968e81
2,518
adventOfCode2022
Apache License 2.0
src/Day02.kt
fex42
575,013,600
false
{"Kotlin": 4342}
import java.lang.IllegalStateException enum class Thing { ROCK, PAPER, SCISOR } enum class Result { WIN, LOOSE, DRAW } fun result(player: Thing, opponent: Thing): Result = when (player) { Thing.ROCK -> when (opponent) { Thing.ROCK -> Result.DRAW Thing.PAPER -> Result.LOOSE ...
0
Kotlin
0
0
dd5d9ff58afc615bcac0fd76b86e737833eb7576
2,811
AuC-2022
Apache License 2.0
yacht/src/main/kotlin/YachtCategory.kt
3mtee
98,672,009
false
null
internal fun countDices(dices: List<Int>, digit: Int) = dices.filter { it == digit }.sum() enum class YachtCategory(val score: (dices: List<Int>) -> Int) { YACHT({ if (it.toSet().size == 1) 50 else 0 }), ONES({ countDices(it, 1) }), TWOS({ countDices(it, 2) }), THREES({ countDices(it, 3) }), FOURS(...
0
Kotlin
0
0
6e3eb88cf58d7f01af2236e8d4727f3cd5840065
1,200
exercism-kotlin
Apache License 2.0
src/Day10.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun List<String>.mapToOps(): List<Op> = this.map { it.split(" ") } .map { if (it[0] == "noop") Op.Nop else Op.AddX(it[1].toInt()) } fun part1(input: List<String>): Int { val timestamps = setOf(20, 60, 100, 140, 180, 220) return sequence { var cycles...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
2,394
aoc-2022
Apache License 2.0
src/year2021/day04/Day04.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day04 import util.assertTrue import util.read2021DayInput fun main() { val input = read2021DayInput("Day04") fun task01() = calculateScores(input).first().first fun task02() = calculateScores(input).last().first assertTrue(task01() == 63424) assertTrue(task02() == 23541) } ...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,639
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1293/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1293 /** * LeetCode page: [1293. Shortest Path in a Grid with Obstacles Elimination](https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination/); */ class Solution { /* Complexity: * Time O(MNK) and Space O(MN) where M and N are the number of rows...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,594
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/adventofcode2022/solution/day_14.kt
dangerground
579,293,233
false
{"Kotlin": 51472}
package adventofcode2022.solution import adventofcode2022.util.readDay import kotlin.math.max import kotlin.math.min fun main() { Day14("14").solve() } class Day14(private val num: String) { private val inputText = readDay(num) fun solve() { println("Day $num Solution") println("* Part ...
0
Kotlin
0
0
f1094ba3ead165adaadce6cffd5f3e78d6505724
4,389
adventofcode-2022
MIT License
src/main/kotlin/advent/y2018/day5.kt
IgorPerikov
134,053,571
false
{"Kotlin": 29606}
package advent.y2018 import misc.readAdventInput import java.util.* fun main(args: Array<String>) { val polymersChain = readAdventInput(5, 2018)[0] println(remainUnitsAfterAllReactions(polymersChain)) println(leastPossiblePolymerChainAfterRemovingAny(polymersChain)) } private fun leastPossiblePolymerChai...
0
Kotlin
0
0
b30cf179f7b7ae534ee55d432b13859b77bbc4b7
1,980
kotlin-solutions
MIT License
src/Day13.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
fun solveDay13() { val lines = readInput("Day13") solve(lines) } private fun solve( input: List<String>, ) { val packets = input .chunked(3) .flatMap { line -> line .take(2) .map { it.parsePacketData() } } val part1 = packets .chunk...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
2,298
AoC-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2022/Day8.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2022 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day8: AdventDay(2022, 8) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day8() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,284
adventofcode
MIT License
src/Day03.kt
kkaptur
573,511,972
false
{"Kotlin": 14524}
fun main() { fun part1(input: List<String>): Int { var score = 0 var firstCompartment = emptySet<Char>() var secondCompartment = emptySet<Char>() input.forEach { rucksack -> firstCompartment = rucksack.subSequence(0, (rucksack.length / 2)).toSet() secondCompar...
0
Kotlin
0
0
055073b7c073c8c1daabbfd293139fecf412632a
1,369
AdventOfCode2022Kotlin
Apache License 2.0
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p09/Leet983.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p09 import java.util.TreeMap import kotlin.system.measureTimeMillis /** * You have planned some train traveling one year in advance. The days of the year in which you will travel are given * as an integer array days. Each day is an integer from 1 to 365. * * Train tickets are sold...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
3,264
playground
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions8.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test8() { printlnResult(intArrayOf(5, 1, 4, 3), 7) } /** * Questions 8: Given an IntArray and an integer k, find the shortest continues sub-array that sum equals or greater than k */ private infix fun IntArray.findShortestSizeOfSubArray(k: Int): Int { require(isNo...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,105
Algorithm
Apache License 2.0
src/Day05.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
import java.util.* fun main() { val instructionRegex = Regex("\\d+") data class Instruction(val count: Int, val from: Int, val to: Int) fun parseStackData(data: List<String>): List<LinkedList<Char>> { val stackSize = (data[0].length + 1) / 4 val stacks = MutableList(stackSize) { LinkedLis...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
2,129
advent-of-code-2022-kt
Apache License 2.0
src/Day11.kt
hrach
572,585,537
false
{"Kotlin": 32838}
data class Monkey( val items: MutableList<Long>, val op: (Long) -> Long, val divBy: Int, val divByTrue: Int, val divByFalse: Int, ) { var inspectCount = 0 } val testInput get() = listOf( Monkey(mutableListOf(79, 98), { it * 19 }, 23, 2, 3), Monkey(mutableListOf(54, 65, 75, 7...
0
Kotlin
0
1
40b341a527060c23ff44ebfe9a7e5443f76eadf3
2,880
aoc-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch3/Problem35.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.maths.isPrime import dev.bogwalk.util.maths.primeNumbers import dev.bogwalk.util.search.binarySearch /** * Problem 35: Circular Primes * * https://projecteuler.net/problem=35 * * Goal: Find the sum of all circular primes less than N, with rotations allowed to ex...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,552
project-euler-kotlin
MIT License
src/main/kotlin/Day2.kt
vw-anton
574,945,231
false
{"Kotlin": 33295}
fun main() { val pairs = readFile("input/2.txt") .map { line -> line.split(" ") } .map { chars -> mapItem(chars.first()) to mapResult(chars.last()) } val items = pairs.map { pair -> chooseItem(pair) }.sumOf { it.points } val results = pairs.sumOf { pair -> pair.second.points }...
0
Kotlin
0
0
a823cb9e1677b6285bc47fcf44f523e1483a0143
2,073
aoc2022
The Unlicense
src/main/kotlin/year2022/day-18.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.TraversalBreadthFirstSearch import lib.aoc.Day import lib.aoc.Part import lib.math.Vector fun main() { Day(18, 2022, PartA18(), PartB18()).run() } open class PartA18 : Part() { protected lateinit var cubes: List<Vector> override fun parse(text: String) { cubes = text...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
2,257
Advent-Of-Code-Kotlin
MIT License
src/main/kotlin/twentytwentytwo/Day5.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo fun main() { val (crates, moves) = {}.javaClass.getResource("input-5.txt")!!.readText().split("\n\n") val day = Day5(crates, moves) println(day.part1()) println(day.part2()) } class Day5(private val crates: String, private val moves: String) { fun part1(): String { ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
1,864
aoc202xkotlin
The Unlicense
src/main/kotlin/com/sk/set0/45. Jump Game II.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set0 // https://www.geeksforgeeks.org/minimum-number-of-jumps-to-reach-end-of-a-given-array/ class Solution45 { fun jump(nums: IntArray): Int { val table = IntArray(nums.size) { Int.MAX_VALUE } table[0] = 0 // find min jumps to reach at every index i for (i in 1..nu...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,791
leetcode-kotlin
Apache License 2.0
src/main/kotlin/lain/RangeList.kt
liminalitythree
269,473,503
false
null
package lain import java.math.BigInteger data class RangeList(val list: List<Range>) { companion object { // creates a rangelist from input range // merges ranges that overlap fun from(list: List<Range>):RangeList { val first = RangeList(listOf(list[0])) val rest = ...
2
Kotlin
0
0
6d5fbcc29da148fd72ecb58b164fc5c845267e5c
4,052
bakadesu
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/sk/topicWise/unionfind/200. Number of Islands.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.unionfind import java.util.* class Solution200 { fun numIslands(grid: Array<CharArray>): Int { val seen = HashSet<Pair<Int, Int>>() var count = 0 for (r in grid.indices) { for (c in grid[0].indices) { if (dfs(grid, r, c, seen)) count++...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
3,792
leetcode-kotlin
Apache License 2.0
2021/src/main/kotlin/days/Day3.kt
pgrosslicht
160,153,674
false
null
package days import Day class Day3 : Day(3) { override fun partOne(): Int { val map = dataList.flatMap { it.mapIndexed { index, c -> index to c } }.groupingBy { it }.eachCount().entries.groupBy( { it.key.first }) { it.key.second to it.value } val gamma = map.values.map ...
0
Kotlin
0
0
1f27fd65651e7860db871ede52a139aebd8c82b2
1,441
advent-of-code
MIT License
src/year2021/day07/Day07.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2021.day07 import readInputFileByYearAndDay import readTestFileByYearAndDay import kotlin.math.abs fun main() { fun minimizeCost(input: List<String>, costFunction: (List<Int>, Int) -> Int): Int { val crabPositions = input[0].split(",").map { it.toInt() } // start in the middle ...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,733
advent-of-code-kotlin
Apache License 2.0
src/Day03.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
import javax.management.Query.match fun main() { fun part1(input: List<String>): Int { var sum = 0 for (rucksack in input) { val firstCompartment = mutableSetOf<Char>() val secondCompartment = mutableSetOf<Char>() for ((index, item) in rucksack.withIndex()) { ...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
1,822
aoc-2022
Apache License 2.0
src/Day12.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day12 : Runner<Int, Int>(12, 31, 29) { private fun grid(input: List<String>): Grid<Square> { val width = input.first().toCharArray().size val height = input.size val grid = Grid<Square>(height, width) input.forEachIndexed { y, s -> s.toCharArray().forEachIndexed ...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
3,623
advent-of-code-2022-kotlin
Apache License 2.0