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/Day09/Day09.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
import java.lang.Integer.MAX_VALUE import java.util.* fun main() { fun preprocess(input: List<String>): List<List<Int>> { val parsed = input.map { x -> x.map { it.toString().toInt() } }.toMutableList() val padding = MutableList(input[0].length) { MAX_VALUE } parsed.add(0, padding) p...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
2,434
advent-of-code-2021
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day14.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay class Day14 : AdventDay(2022, 14) { private val startPoint = 500 to 0 data class Area( val blockedByRock: Set<Pair<Int, Int>>, val blockedBySand: Set<Pair<Int, Int>> = emptySet() ) { companion object { private fun allBetween(a: Pair<Int...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
3,622
advent-of-code
Apache License 2.0
src/Day21.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
sealed interface Expression { data class Add(val left: Expression, val right: Expression) : Expression data class Mul(val left: Expression, val right: Expression) : Expression data class Divide(val left: Expression, val right: Expression) : Expression data class Sub(val left: Expression, val right: Expr...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
2,667
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2019/SetAndForget.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Point fun setAndForget1(input: String): Int { val map = createAsciiMap(input) fun get(x: Int, y: Int): Char? = map.getOrNull(y)?.getOrNull(x) var sum = 0 for ((y, line) in map.withIndex(...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,658
advent-of-code
MIT License
src/Day01.kt
cornz
572,867,092
false
{"Kotlin": 35639}
fun main() { fun getBiggestKcal(input: List<String>): ArrayList<Int> { val summedUpValues = arrayListOf<Int>() var summedUpValue = 0 for (it in input) { when (it) { "" -> { summedUpValues.add(summedUpValue) summedUpValue = ...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
1,430
aoc2022
Apache License 2.0
2023/src/main/kotlin/day24.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.SegmentD import utils.Solution import utils.Vec2d import utils.Vec4d import utils.Vec4l import utils.cut import utils.eq import utils.map import utils.minus import utils.pairs import utils.parseItems import utils.plus import utils.times import utils.z3 fun main() { Day24.run() } obj...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
4,479
aoc_kotlin
MIT License
src/Day02.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
fun main() { //A for Rock, B for Paper, and C for Scissors. // X for Rock, Y for Paper, and Z for Scissors. //The score for a single round is the score for the shape you selected // (1 for Rock, 2 for Paper, and 3 for Scissors) // plus the score for the outcome of the round // (0 if you lost, 3...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
2,202
advent-of-code-2022
Apache License 2.0
src/aoc2022/Day13.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import aoc2022.resources.data import aoc2022.resources.data2 fun main() { data class NCont(val nums: List<Int>, val subCon: NCont? = null) fun look(first: Any, second: Any): Int = when { first is Int && second is Int -> first - second first is List<*> && second is List<*> ->...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,533
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindCriticalEdges.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
3,006
kotlab
Apache License 2.0
leetcode/src/offer/middle/Offer63.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 63. 股票的最大利润 // https://leetcode.cn/problems/gu-piao-de-zui-da-li-run-lcof/ println(maxProfit1(intArrayOf(7,1,5,3,6,4))) } fun maxProfit(prices: IntArray): Int { if (prices.isEmpty()) { return 0 } // 1、状态定义:dp[i] 表示前 i 天的最大利润 // 2、转移方程:前...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,380
kotlin-study
MIT License
src/main/day23/day23.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day23 import Point import readInput private typealias Grove = Set<Point> var directionsToCheck = mutableListOf( Point::northernNeighbours, Point::southernNeighbours, Point::westernNeighbours, Point::easternNeighbours ) fun main() { val input = readInput("main/day23/Day23") println(y...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
3,103
aoc-2022
Apache License 2.0
src/Day07.kt
stcastle
573,145,217
false
{"Kotlin": 24899}
sealed interface Item { val name: String val size: Int fun nameSuffix(): String { val nameSuffix = name.split("/").last() return if (nameSuffix == "") "/" else nameSuffix } } /** Default size is -1 when unknown. */ class Directory(override val name: String, val parent: Directory?) : Item { override...
0
Kotlin
0
0
746809a72ea9262c6347f7bc8942924f179438d5
4,853
aoc2022
Apache License 2.0
src/Day01.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
fun main() { fun part1(input: List<String>): Int { return (input + "").fold(Pair(0, 0)) { acc, curr -> // Pair(max so far, current elf) if (curr.isBlank()) { Pair(maxOf(acc.first, acc.second), 0) // is an empty line } else { Pair(acc.first, acc.second...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,063
aoc-2022
Apache License 2.0
leetcode2/src/leetcode/word-search.kt
hewking
68,515,222
false
null
package leetcode /** 79. 单词搜索 https://leetcode-cn.com/problems/word-search/ 给定一个二维网格和一个单词,找出该单词是否存在于网格中。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。 示例: board = [ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ] 给定 word = "ABCCED", 返回 true. 给定 word = "SEE", 返回 true. 给定 word = "...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,351
leetcode
MIT License
src/year2022/02/Day02.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`02` import readInput fun main() { fun part1(input: List<String>): Int { return input .map { it.split(" ") } .map { Round(it.first(), it[1]) } .sumOf { it.outcome() } } fun part2(input: List<String>): Int { return input .ma...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
2,531
KotlinAdventOfCode
Apache License 2.0
src/main/java/com/booknara/problem/math/ValidSquare.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.math /** * 593. Valid Square (Medium) * https://leetcode.com/problems/valid-square/ */ class ValidSquare { // T:O(1), S:O(1) fun validSquare(p1: IntArray, p2: IntArray, p3: IntArray, p4: IntArray): Boolean { // input check, there are four points val points = arra...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,267
playground
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day02.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.math.max import kotlin.test.assertEquals class Day02 : AbstractDay() { @Test fun part1() { assertEquals(8, compute1(testInput)) assertEquals(2617, compute1(puzzleInput)) } @Te...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
3,213
aoc
Apache License 2.0
src/main/kotlin/aoc2023/Day14.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.ArrayAsSurface import utils.Coordinates import utils.Direction import utils.E import utils.InputUtils import utils.N import utils.S import utils.W private fun getRocks(input: List<String>) = ArrayAsSurface(input) .indexed() .filter { (_, c) -> c == 'O' } .map { it.first }.toSe...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
3,341
aoc-2022-kotlin
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day13.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import kotlin.math.abs object Day13 : AdventSolution(2021, 13, "Transparent Origami") { override fun solvePartOne(input: String): Int { val (points, folds) = parse(input) return foldPaper(points, ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,645
advent-of-code
MIT License
src/day12/Day12.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day12 import lib.Point2D import lib.directionsClockwise import readInput import java.util.LinkedList import kotlin.math.min fun main() { val input = readInput("day12/input") val h = input.size val w = input[0].length var start = Point2D(0, 0) var end = Point2D(0, 0) val heights = Li...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,350
advent-of-code-2022
Apache License 2.0
src/Day05.kt
mborromeo
571,999,097
false
{"Kotlin": 10600}
fun main() { fun parseCrates(input: List<String>): List<MutableList<Char>> { val crates: List<MutableList<Char>> = List(input.last().last().digitToInt()) { mutableListOf() } for (i in 1 until input.size){ input.reversed()[i].chunked(4).forEachIndexed { index, s -> val cr...
0
Kotlin
0
0
d01860ecaff005aaf8e1e4ba3777a325a84c557c
2,053
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
emanguy
573,113,840
false
{"Kotlin": 17921}
fun itemPriority(item: Char): Int = when(item) { in 'a'..'z' -> item - 'a' + 1 in 'A'..'Z' -> item - 'A' + 27 else -> throw IllegalArgumentException("Not an item: $item") } fun main() { fun part1(inputs: List<String>): Int { var totalValue = 0 inputLoop@ for (input in inputs) { ...
0
Kotlin
0
1
211e213ec306acc0978f5490524e8abafbd739f3
1,670
advent-of-code-2022
Apache License 2.0
src/Day04.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
fun String.toClosedRange(): IntRange { val (first, second) = this.split("-").map { it.toInt() } return first..second } fun main() { fun part1(input: List<String>): Unit { var count = 0 input.forEach { line -> val (first, second) = line.split(",").map { it.toClosedRange() } ...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
1,352
advent-of-code-2022-kietyo
Apache License 2.0
src/2021/Day23.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
import java.io.File import java.util.* import kotlin.math.abs fun main() { Day23().solve() } private enum class LocationType {CORRIDOR, ROOM} // ############# // #01.2.3.4.56# // ###0#1#2#3### // #.#.#.#.# private data class Location(val type: LocationType, val index: Int) { companion object { val a...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
12,986
advent-of-code
Apache License 2.0
src/day02/Day02.kt
skokovic
573,361,100
false
{"Kotlin": 12166}
package day02 import readInput fun calculateTuple(elf: String, me: String): Int { var sum = 0 when (me) { "X" -> sum += 1 "Y" -> sum += 2 "Z" -> sum += 3 } when (elf) { "A" -> when (me) { "X" -> sum += 3 "Y" -> sum += 6 "Z" -> sum +...
0
Kotlin
0
0
fa9aee3b5dd09b06bfd5c232272682ede9263970
1,788
advent-of-code-2022
Apache License 2.0
src/year2022/Day02.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 fun main() { fun part1(input: List<String>): Int { return input.sumOf { var s = 0 when (it.last()) { 'X' -> s += 1 'Y' -> s += 2 'Z' -> s += 3 } when (it) { "A X", "B Y", "C Z" -...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
1,975
adventofcode-kotlin
Apache License 2.0
leetcode/src/offer/middle/Offer38.kt
zhangweizhe
387,808,774
false
null
package offer.middle import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashSet fun main() { // 剑指 Offer 38. 字符串的排列 // https://leetcode.cn/problems/zi-fu-chuan-de-pai-lie-lcof/ println(permutation("1234567").contentToString()) } fun permutation(s: String): Array<String> { ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,862
kotlin-study
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-05.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.math.abs import kotlin.math.max fun main() { val input = readInputLines(2021, "05-input") val te...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,669
advent-of-code
MIT License
src/Day05.kt
jdappel
575,879,747
false
{"Kotlin": 10062}
fun makeStack(items: Collection<String>): ArrayDeque<String> { val stack = ArrayDeque<String>() items.forEach { stack.add(it) } return stack } fun main() { val st1 = makeStack(listOf("Q","F","M","R","L","W","C","V")) val st2 = makeStack(listOf("D","Q","L")) val st3 = makeStack(listOf("P","S","R...
0
Kotlin
0
0
ddcf4f0be47ccbe4409605b37f43534125ee859d
2,416
AdventOfCodeKotlin
Apache License 2.0
src/Day13.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.math.sign import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day13.run { solve1(13) // 6369 solve2(140) // 25800 } }.let { println("Total: $it ms") } } object Day13 : Day.GroupInput<List<Day13.Data>, Int>("13") { data class Data(v...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
2,578
AdventOfCode2022
Apache License 2.0
src/Day9.kt
jrmacgill
573,065,109
false
{"Kotlin": 76362}
import java.lang.Integer.max import kotlin.math.abs class Day9 constructor(length: Int){ var head = Pair(0,0) var tails = MutableList<Pair<Int,Int>>(length) { Pair(0,0)} var width = 0 var height = 0 var visited : HashMap<Pair<Int,Int>, Int> = HashMap<Pair<Int,Int>, Int>() fun Pair<Int, Int>...
0
Kotlin
0
1
3dcd590f971b6e9c064b444139d6442df034355b
2,916
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/day05/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day05 import java.io.File import kotlin.math.abs fun main() { val segmentPattern = Regex("""(\d+),(\d+) -> (\d+),(\d+)""") val inputLines = File("src/main/kotlin/day05/input.txt").readLines() val segments = inputLines .mapNotNull { segmentPattern.matchEntire(it) } .map { ...
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
1,739
aoc-2021
MIT License
src/main/kotlin/aoc2023/day16/day16Solver.kt
Advent-of-Code-Netcompany-Unions
726,531,711
false
{"Kotlin": 94973}
package aoc2023.day16 import lib.* suspend fun main() { setupChallenge().solveChallenge() } fun setupChallenge(): Challenge<Array<Array<Char>>> { return setup { day(16) year(2023) //input("example.txt") parser { it.readLines().get2DArrayOfColumns() } ...
0
Kotlin
0
0
a77584ee012d5b1b0d28501ae42d7b10d28bf070
4,018
AoC-2023-DDJ
MIT License
src/main/kotlin/days/Day14.kt
julia-kim
569,976,303
false
null
package days import Point import readInput fun main() { fun getRockCoordinates(input: List<String>): List<Point> { val pourPoint = Point(500, 0) val rocks = mutableListOf(pourPoint) input.forEach { line -> // 498,4 -> 498,6 -> 496,6 val paths = line.split(" -> ") ...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
3,915
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2022/day13/Day13.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day13 import com.jacobhyphenated.advent2022.Day /** * Day 13: Distress Signal * * Packets are coming in out of order. * Packets come in pairs (one on each line of the input). * * A packet consists of a number or list of packets, ex: * [[1],[2,3,4]] turns into Packet[...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
5,666
advent2022
The Unlicense
src/Day04v2.kt
vi-quang
573,647,667
false
{"Kotlin": 49703}
fun main() { class Elf(range: String) { init { val token = range.split("-") val (rangeMin, rangeMax) = token[0].toInt() to token[1].toInt() this.range = rangeMin .. rangeMax } val range : ClosedRange<Int> } fun ClosedRange<Int>.length() : Int { ...
0
Kotlin
0
2
ae153c99b58ba3749f16b3fe53f06a4b557105d3
2,181
aoc-2022
Apache License 2.0
src/Day03.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
import java.lang.RuntimeException /** * [Day03](https://adventofcode.com/2022/day/3) */ fun main() { fun toCompartments(input: List<String>): List<Pair<String, String>> = input.map { it.substring(0 until it.length / 2) to it.substring(it.length / 2 until it.length) } fun toIndex(c: Char): Int = ...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
1,546
aoc-in-kotlin-2022
Apache License 2.0
src/main/kotlin/com/hopkins/aoc/day6/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day6 import java.io.File const val debug = true const val part = 2 /** Advent of Code 2023: Day 6 */ fun main() { val inputFile = File("input/input6.txt") val lines: List<String> = inputFile.readLines() val times = readValues(lines[0]) val distances = readValues(lines[1]) ...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
1,960
aoc2023
MIT License
src/Day08.kt
ahmadshabib
573,197,533
false
{"Kotlin": 13577}
fun main() { val input = readInput("Day08") val treesMap = Array(input.size) { Array(input[0].length) { 0 } } input.forEachIndexed { index, s -> s.toCharArray().forEachIndexed { columnIndex, c -> treesMap[index][columnIndex] = c.toString().toInt() } } var numberOfVisible...
0
Kotlin
0
0
81db1b287ca3f6cae95dde41919bfa539ac3adb5
4,180
advent-of-code-kotlin-22
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/single_element/SingleElement.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.single_element import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/346626/google-phone-screen-single-element * * Given an array nums of length n. All elements appear in pairs except one of them. Find this single element that appears al...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,892
katas
The Unlicense
src/day09/Day09Answer2.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day09 import day09.Directions.* import readInput import kotlin.math.abs /** * Answers from [Advent of Code 2022 Day 9 | Kotlin](https://youtu.be/ShU9dNUa_3g) */ enum class Directions { UP, DOWN, LEFT, RIGHT, } data class Movement(val direction: Directions) { fun move(v: Vec2): Vec2 { ...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
2,660
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day23/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day23 import kotlin.math.abs import kotlin.math.max fun launchDay23(testCase: String) { println("Day 23, part 1: ${Grid.readInput(testCase).solvePart1()}") // println("Day 23, part 2 (slow): ${Grid.readInput(testCase).solvePart2Slow()}") // println("Day 23, part 2 (fast): ${Gri...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
9,357
advent-of-code-2023
MIT License
kotlin/src/com/leetcode/1314_MatrixBlockSum.kt
programmerr47
248,502,040
false
null
package com.leetcode import java.lang.Integer.min import kotlin.math.max //Partial sum matrix O(n * m) private class Solution1314 { fun matrixBlockSum(mat: Array<IntArray>, k: Int): Array<IntArray> { val partCols = fillPartColumns(mat, k) val result = Array(mat.size) { IntArray(mat[it].size) } ...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
6,910
problemsolving
Apache License 2.0
src/Day15.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import java.util.* import kotlin.math.abs import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day15.run { solve1(26L) // 4907780L solve2(56000011L) // 13639962836448L } }.let { println("Total: $it ms") } } object Day15 : Day.GroupInput<Day15.Data, Lo...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
1,914
AdventOfCode2022
Apache License 2.0
src/Day13.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import java.util.Stack import kotlin.math.sign fun main() { fun part1(input: List<String>): Int { var result = 0 var pairIndex = 0 var firstLine = "" input.forEachIndexed { index, s -> when(index % 3) { 0 -> firstLine = s 1 -> { ...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,117
AdventOfCode2022
Apache License 2.0
src/main/kotlin/de/consuli/aoc/year2023/days/Day04.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2023.days import de.consuli.aoc.common.Day import kotlin.math.pow class Day04 : Day(4, 2023) { data class ScratchCard(val winningNumbers: Set<Int>, val numbers: Set<Int>) override fun partOne(testInput: Boolean): Int = mapInputToScratchCards(getInput(testInput)) .sumOf { c...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
1,859
advent-of-code
Apache License 2.0
kotlin/src/x2022/day9/day9.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day9 import readInput import kotlin.math.absoluteValue enum class Direction { Right, Left, Up, Down } data class Position(val x: Int, val y: Int) data class Move(val direction: Direction, val distance: Int) class Grid(parts: Int) { val ropeParts = MutableList(parts) { Position(0, 0) } val visite...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
3,154
adventOfCode
Apache License 2.0
src/d20.main.kts
cjfuller
317,725,797
false
null
import java.io.File fun Long.mirror(): Long = (0 until 10).map { i -> if (this and (1L shl i) != 0L) { 1L shl (9 - i) } else { 0 } }.sum() data class Tile(val number: Long, val borders: List<Long>) { fun mirrorLR(): Tile = this.copy( borders = this.borders.take(2).m...
0
Kotlin
0
0
c3812868da97838653048e63b4d9cb076af58a3b
2,665
adventofcode2020
MIT License
src/Day03.kt
jmorozov
573,077,620
false
{"Kotlin": 31919}
fun main() { val inputData = readInput("Day03") part1(inputData) part2(inputData) } private const val ASCII_DIFF_UPPER_CASE = 38 private const val ASCII_DIFF_LOWER_CASE = 96 fun Char.priority(): Int = when { this.isLowerCase() -> this.code - ASCII_DIFF_LOWER_CASE this.isUpperCase() -> this.code - ...
0
Kotlin
0
0
480a98838949dbc7b5b7e84acf24f30db644f7b7
1,777
aoc-2022-in-kotlin
Apache License 2.0
src/day12/Day12.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day12 import readInput import java.util.* private const val DAY_ID = "12" private data class Cell( val row: Int, val col: Int ) { fun isInBounds(numRows: Int, numCols: Int): Boolean = row in 0 until numRows && col in 0 until numCols } private data class Input( val grid: List<List<Int...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
3,591
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-18.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.math.max fun main() { val input = readInputLines(2021, "18-input") val test1 = readInputLines(2021, "18-test1") println("Part1:") part1...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
5,683
advent-of-code
MIT License
advent2/src/main/kotlin/Main.kt
thastreet
574,294,123
false
{"Kotlin": 29380}
import Outcome.DRAW import Outcome.LOSS import Outcome.WIN import Shape.PAPER import Shape.ROCK import Shape.SCISSOR import java.io.File enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSOR(3) } enum class Outcome(val score: Int) { WIN(6), DRAW(3), LOSS(0) } val Shape.beats: Shape ...
0
Kotlin
0
0
e296de7db91dba0b44453601fa2b1696af9dbb15
2,292
advent-of-code-2022
Apache License 2.0
src/_2015/Day02.kt
albertogarrido
572,874,945
false
{"Kotlin": 36434}
package _2015 import readInput fun main() { runTests() val input = readInput("2015", "day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { var total = 0 input.forEach { dimen -> total += part1Count(dimen) } return total } privat...
0
Kotlin
0
0
ef310c5375f67d66f4709b5ac410d3a6a4889ca6
1,806
AdventOfCode.kt
Apache License 2.0
src/Day05.kt
icoffiel
572,651,851
false
{"Kotlin": 29350}
fun main() { operator fun <E> List<E>.component6(): E = get(5) fun <E>ArrayDeque<E>.pop() = removeLast() fun <E>ArrayDeque<E>.push(element: E) = addLast(element) fun <E>ArrayDeque<E>.push(elements: List<E>) { elements.forEach { element -> push(element) } } fun String.toMovement(): Move...
0
Kotlin
0
0
515f5681c385f22efab5c711dc983e24157fc84f
3,147
advent-of-code-2022
Apache License 2.0
src/main/kotlin/week3/Volcano.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package week3 import shared.AdjacencyMatrix import shared.Algorithms.Companion.floydWarshall import shared.Puzzle import shared.ReadUtils.Companion.debug class Volcano : Puzzle(16) { data class VolcanoConfig( val adjacencyMatrix: AdjacencyMatrix, val translationMap: Map<String, Int>, val c...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
8,130
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
advent-of-code-2021/src/main/kotlin/Day4.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 4: Giant Squid //https://adventofcode.com/2021/day/4 import java.io.File fun main() { val lines = File("src/main/resources/Day4.txt").readLines() val draws = lines.first().split(",").map { it.toInt() } val boards = lines.asSequence().drop(1).chunked(6).map { board -> board.drop(1).map { it....
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,201
advent-of-code
Apache License 2.0
src/Day03.kt
JohannesPtaszyk
573,129,811
false
{"Kotlin": 20483}
fun main() { val possibleItems: List<Char> = ('a'..'z') + ('A'..'Z') fun part1(input: List<String>): Int = input.sumOf { val centerIndex = it.length / 2 val firstCompartment = it.substring(0, centerIndex).toSet() val secondCompartment = it.substring(centerIndex, it.length).toSet() ...
0
Kotlin
0
1
6f6209cacaf93230bfb55df5d91cf92305e8cd26
1,268
advent-of-code-2022
Apache License 2.0
src/Day09.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
import kotlin.math.abs typealias Step = Pair<Direction, Int> fun buildStep(dir: String, count: String): Step? { return when (dir) { "R" -> Step(Direction.RIGHT, count.toInt()-1) "L" -> Step(Direction.LEFT, count.toInt()-1) "U" -> Step(Direction.UP, count.toInt()-1) "D" -> Step(Dire...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,275
aoc2022
Apache License 2.0
src/d09/Main.kt
cweckerl
572,838,803
false
{"Kotlin": 12921}
package d09 import java.io.File import kotlin.math.pow import kotlin.math.sqrt fun main() { fun dist(p1: Pair<Int, Int>, p2: Pair<Int, Int>) = sqrt( (p1.first - p2.first).toDouble().pow(2) + (p1.second - p2.second).toDouble().pow(2) ) fun part1(input: List<String>) { var ...
0
Kotlin
0
0
612badffbc42c3b4524f5d539c5cbbfe5abc15d3
2,601
aoc
Apache License 2.0
src/main/kotlin/me/mattco/days/day06.kt
mattco98
160,000,311
false
null
package me.mattco.days import me.mattco.utils.ResourceLoader.getTextResource import java.lang.Math.abs import kotlin.math.max object Day6 { private val input = getTextResource("/day06").split(System.lineSeparator()) private fun getGrid(): List<Pair<Int, Int>> = input.map { val v = it.split(", ") ...
0
Kotlin
0
0
9ec878de1cd727bb56ba7cb17796c766d4894252
2,407
AdventOfCode2018
MIT License
src/main/kotlin/g2901_3000/s2954_count_the_number_of_infection_sequences/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2954_count_the_number_of_infection_sequences // #Hard #Array #Math #Combinatorics #2024_01_16_Time_1446_ms_(14.29%)_Space_69.1_MB_(14.29%) import kotlin.math.max class Solution { private val fact = LongArray(M + 1) private val invFact = LongArray(M + 1) private var init: Long = 0 ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,669
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day11/Day11.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day11 import groupByBlanks import runDay fun main() { fun part1(input: List<String>) = input.toMonkeys() .let { monkeys -> repeat(20) { processRound(monkeys) } monkeys.map { it.inspectedItems } .sortedDescending() .take(2) .re...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
3,321
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dp/ConstructBST.kt
yx-z
106,589,674
false
null
package dp import util.get // given an array of look-up frequencies of some sorted array // find the minimum cost for all look-ups if the sorted array is stored as a // binary search tree (the sorted key values is actually irrelevant to this problem! // cost = sum over all nodes (# of ancestors * freq) [one's ances...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
947
AlgoKt
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/KthSmallest.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
3,916
kotlab
Apache License 2.0
src/main/kotlin/solutions/year2022/Day3.kt
neewrobert
573,028,531
false
{"Kotlin": 7605}
package solutions.year2022 import readInputLines /** * For each element you should split it on half = input.size() / 2 * * compare both to see which element appears more than once * * check the priority and save it * * sum up all the priority */ fun main() { fun Char.toPriority() = if (this in 'a'..'z') ...
0
Kotlin
0
0
7ecf680845af9d22ef1b9038c05d72724e3914f1
1,154
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/sschr15/aocsolutions/Day19.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* import sschr15.aocsolutions.util.watched.sumOf import sschr15.aocsolutions.util.watched.times import java.util.ArrayDeque import kotlin.collections.sumOf /** * AOC 2023 [Day 19](https://adventofcode.com/2023/day/19) * Challenge: Help those poor Desert ...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
7,875
advent-of-code
MIT License
src/Day04.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
fun main() { fun part1(input: List<String>): Int { return input.count { val (first, second) = it.split(',') val (firstStart, firstEnd) = first.split('-') val (secondStart, secondEnd) = second.split('-') val firstRange = firstStart.toInt()..firstEnd.toInt() ...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
1,247
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/be/seppevolkaerts/day6/Day6.kt
Cybermaxke
727,453,020
false
{"Kotlin": 35118}
package be.seppevolkaerts.day6 import be.seppevolkaerts.splitLongs import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt data class Race( val time: Long, val recordDistance: Long, ) fun Race.waysToWin(): Long { // Loops, although fast enough, is it really? /* var count = 0L for (holdTi...
0
Kotlin
0
1
56ed086f8493b9f5ff1b688e2f128c69e3e1962c
1,673
advent-2023
MIT License
src/day4/Day4.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
package day4 import java.io.File data class Number( val value: Int, var marked: Boolean = false ) data class Board( val data: Array<Array<Number>> = Array(5) { Array(5) { Number(0) } } ) { override fun equals(other: Any?): Boolean { if (other !is Board) return false return data.conten...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
3,860
AdventOfCode2021
Apache License 2.0
year2016/src/main/kotlin/net/olegg/aoc/year2016/day11/Day11.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day11 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2016.DayOf2016 import java.util.BitSet /** * See [Year 2016, Day 11](https://adventofcode.com/2016/day/11) */ object Day11 : DayOf2016(11) { private val GEN_PATTERN = "(\\w+) generator".toRegex() private val CHIP_...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
4,130
adventofcode
MIT License
dynamic_programming/MinimumScoreTriangulationOfPolygon/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Given N, consider a convex N-sided polygon with vertices * labelled A[0], A[i], ..., A[N-1] in clockwise order. * * Suppose you triangulate the polygon into N-2 triangles. * For each triangle, the value of that triangle is the product of the * labels of the vertices, and the total score of the triangul...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,390
codility
MIT License
src/year_2021/day_01/Day01.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_01 import readInput object Day01 { /** * @return number of increases in depths */ fun solutionOne(sonarDepthsText: List<String>): Int { val depths = parseDepths(sonarDepthsText) var increases = 0 for (i in 0..depths.size - 2) { if (depths[i]...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
1,386
advent_of_code
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-09.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.math.absoluteValue fun main() { val input = readInputLines(2022, "09-input") val testInput1 = re...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,736
advent-of-code
MIT License
src/main/kotlin/com/colinodell/advent2022/Day02.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day02(input: List<String>) { private val strategyGuide = input.map { Pair(it[0], it[2]) } fun solvePart1(): Int { return strategyGuide .map { Pair(Shape.from(it.first), Shape.from(it.second)) } .sumOf { score(it.first.outcomeWhenIPlay(it....
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
2,642
advent-2022
MIT License
day15/src/main/kotlin/aoc2015/day15/Day15.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day15 object Day15 { fun highestCookieScore() = recipes() .map { it.calculateScore() } .max()!! fun highestCookieScoreWith500Calories() = recipes() .filter { it.calculateCalories() == 500 } .map { it.calculateScore() } .max()!! ...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
3,288
aoc2015
Apache License 2.0
aoc2022/day13.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval import kotlin.math.min fun main() { Day13.execute() } object Day13 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
4,225
Advent-Of-Code
MIT License
src/main/kotlin/leetcode/google/Problem792.kt
Magdi
390,731,717
false
null
package leetcode.google /** * https://leetcode.com/problems/number-of-matching-subsequences/ * Number of Matching Subsequences */ class Problem792 { fun numMatchingSubseq(s: String, words: Array<String>): Int { val histogram = Array(s.length) { IntArray(26) { -1 } } for (i ...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
2,028
ProblemSolving
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day16.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 import year2023.Day16.Direction.* fun main() { val input = readInput("Day16") Day16.part1(input).println() Day16.part2(input).println() } object Day16 { fun part1(input: List<String>): Int { val contraption = input.map { line -> line.map { Box(it) } } contraption.ene...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
4,258
advent-of-code
MIT License
src/main/kotlin/day12/Day12.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day12 import java.io.File fun main() { val data = parse("src/main/kotlin/day12/Day12.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 12 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
1,757
advent-of-code-2021
MIT License
src/day09/Day09.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day09 import readInput import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val head = Node() val tail = Node() head.next = tail doMove(head, input) return tail.visited.size } fun part2(input: List<String>): Int { val head = Nod...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
1,900
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day18.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 18 - Settlers of The North Pole * * Problem Description: http://adventofcode.com/2018/day/18 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day18/ */ package com.ginsberg.advent2018 import java.util.Arrays typealia...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
2,961
advent-2018-kotlin
MIT License
src/main/kotlin/g2901_3000/s2910_minimum_number_of_groups_to_create_a_valid_assignment/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2910_minimum_number_of_groups_to_create_a_valid_assignment // #Medium #Array #Hash_Table #Greedy #2023_12_27_Time_745_ms_(75.00%)_Space_65.6_MB_(75.00%) class Solution { fun minGroupsForValidAssignment(nums: IntArray): Int { val count = getCountMap(nums) val countFreq = getCoun...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,096
LeetCode-in-Kotlin
MIT License
src/Day03.kt
AxelUser
572,845,434
false
{"Kotlin": 29744}
fun main() { fun List<String>.solve1(): Int { var res = 0 for (rucksack in this) { val set = mutableSetOf<Char>() for (i in 0 until rucksack.length / 2) { set.add(rucksack[i]) } for (i in rucksack.length / 2 until rucksack.length) { ...
0
Kotlin
0
1
042e559f80b33694afba08b8de320a7072e18c4e
1,437
aoc-2022
Apache License 2.0
src/Day02_RockPaperScissors.kt
raipc
574,467,742
false
{"Kotlin": 9511}
fun main() { checkAndSolve("Day02", 15) { calculateScore(it, Strategy.SUGGEST_EXACT_MOVE) } checkAndSolve("Day02", 12) { calculateScore(it, Strategy.SUGGEST_OUTPUT) } } private fun calculateScore(lines: List<String>, strategy: Strategy): Int = lines .sumOf { calculateScoreForSingleGame(it, strategy) } pri...
0
Kotlin
0
0
9068c21dc0acb5e1009652b4a074432000540d71
1,529
adventofcode22
Apache License 2.0
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day07.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.Day07.Directory import codes.jakob.aoc.Day07.File import codes.jakob.aoc.shared.splitMultiline import codes.jakob.aoc.shared.toPair class Day07 : Solution() { override fun solvePart1(input: String): Any { val root: Directory = buildDirectoryTree(input) ...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
5,468
advent-of-code-2022
MIT License
src/Day04.kt
6234456
572,616,769
false
{"Kotlin": 39979}
fun main() { fun overlapping(l: List<List<Int>>):Boolean{ val a = l.first() val b = l.last() val a1 = a.first() val a2 = a.last() val b1 = b.first() val b2 = b.last() return (a1 <= b1 && b2 <= a2) || (b1 <= a1 && a2 <= b2) } fun overlapping0(l: Lis...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
1,224
advent-of-code-kotlin-2022
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/Levenshtein.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.parsing import ai.hypergraph.kaliningraph.* import ai.hypergraph.kaliningraph.automata.* import ai.hypergraph.kaliningraph.repair.* import ai.hypergraph.kaliningraph.types.* import ai.hypergraph.kaliningraph.types.times import kotlin.math.* // Only accept states that are within radi...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
9,122
galoisenne
Apache License 2.0
src/main/Day21.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day21 import day21.Operation.* import utils.readInput import java.util.* sealed interface Job data class Number(val value: Long) : Job data class Wait(val left: String, val right: String, val operation: Operation) : Job enum class Operation(val operation: (Long, Long) -> Long) { ADD(Long::plus), SU...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
2,925
aoc-2022
Apache License 2.0
src/main/kotlin/com/briarshore/aoc2022/day01/Puzzle1.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day01 import println import readInput import kotlin.math.max fun main() { fun part1Simple(input: List<String>): Int { var max = 0; var total = 0; for (s in input) { if (s.isNotEmpty()) { total += s.toInt() } else { ...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
3,266
2022-AoC-Kotlin
Apache License 2.0
src/Day11.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
fun main() { fun runRounds(monkeys: List<Monkey>, rounds: Int, reliefer: (Long) -> Long): Long { for (round in 1..rounds) { monkeys.forEach { monkey -> monkey.inspectItems(reliefer).forEach { val (toMonkey, worryLevel) = it monkeys[toMo...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
3,456
aoc2022
Apache License 2.0
src/Day04.kt
copperwall
572,339,673
false
{"Kotlin": 7027}
fun main() { //main1(); main2() } fun main1() { val inputLines = readInput("Day04-basic") val pairs = inputLines.map { line -> line.split(",").map { it.split("-").map { str -> str.toInt() } } } // Find var duplicates = 0 for (pair in pairs) { val (firstElf, secondElf) = pair ...
0
Kotlin
0
1
f7b856952920ebd651bf78b0e15e9460524c39bb
1,531
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day10.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 10: Syntax Scoring */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 10: Syntax Scoring ** \n") val navigationSubsystemCode = readFileAsStringList("/Day10NavigationSubsystemCode.txt") val illegalCharacterSyntaxScore = calcula...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
2,756
AdventOfCode2021
MIT License
solutions/src/Day02.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
import java.lang.IllegalStateException fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (opponentChoice, myChoice) = it.split(" ") myRoundScore(opponentChoice, myChoice) } } fun part2(input: List<String>): Int { return input.sumOf ...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
2,129
advent-of-code-22
Apache License 2.0
aoc-2023/src/main/kotlin/nerok/aoc/aoc2023/day04/Day04.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2023.day04 import nerok.aoc.utils.Input import kotlin.math.pow import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { return input.map { game -> var inWinning = false var inPlayers = false ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
4,162
AOC
Apache License 2.0
src/Day12.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private val offsets = listOf( Pair(0, 1), Pair(0, -1), Pair(1, 0), Pair(-1, 0) ) private fun part1(map: List<String>): Int { val mapWidth = map[0].length val mapHeight = map.size var start = Pair(0, 0) var end = Pair(0, 0) for ((r, line) in map.withIndex()) { val s = line.i...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
3,336
advent-of-code-2022
Apache License 2.0
src/Day09.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
import kotlin.math.sign private data class Position(val x: Int, val y: Int) { operator fun plus(other: Position) = Position(x = x + other.x, y = y + other.y) operator fun minus(other: Position) = Position(x = x - other.x, y = y - other.y) fun isNeighbour(other: Position): Boolean { val diff = this ...
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
2,502
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/aoc2021/Day9.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day import kotlin.math.exp class Day9 : Day(2021, 9) { override fun partOne(): Any { return calculateRiskLevelSum(inputList) } override fun partTwo(): Any { return calculateThreeLargestBasins(inputList) } fun calculateThreeLargestBasins(inputList:...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,539
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/algorithmdesignmanualbook/partialsum/PartialSumUsingFenwickTree.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.partialsum import algorithmdesignmanualbook.print import java.util.* import kotlin.experimental.and import kotlin.experimental.inv /** * Let A be an array of n real numbers. Design an algorithm to perform any sequence of the following operations: * • Add(i,y) – Add the value y to t...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,186
algorithms
MIT License
src/Day04.kt
wgolyakov
572,463,468
false
null
fun main() { fun part1(input: List<String>): Int { return input.count { val (r1, r2) = it.split(',') .map { r -> r.split('-').map(String::toInt).let { (a, b) -> a..b } } (r1.first in r2 && r1.last in r2) || (r2.first in r1 && r2.last in r1) } } fun part2(input: List<String>): Int { return input.coun...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
689
advent-of-code-2022
Apache License 2.0
src/Day03.kt
Krzychuk9
573,127,179
false
null
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val midPoint = it.length / 2 val itemsInFirstCompartment = it.substring(0, midPoint).toSet() val itemsInSecondCompartment = it.substring(midPoint).toSet() val item = itemsInFirstCompartmen...
0
Kotlin
0
0
ded55d03c9d4586166bf761c7d5f3f45ac968e81
1,097
adventOfCode2022
Apache License 2.0