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
leetcode2/src/leetcode/KthLargestElementInAStream.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 数据流中的第k大的元素 * https://leetcode-cn.com/problems/kth-largest-element-in-a-stream/ * Created by test * Date 2019/5/18 15:07 * Description * 设计一个找到数据流中第K大元素的类(class)。注意是排序后的第K大元素,不是第K个不同的元素。 你的 KthLargest 类需要一个同时接收整数 k 和整数数组nums 的构造器,它包含数据流中的初始元素。每次调用 KthLargest.add,返回当前数据...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,752
leetcode
MIT License
P9735.kt
daily-boj
253,815,781
false
null
import kotlin.math.* data class QuadraticEquation(val a: Long, val b: Long, val c: Long) { fun solve(): Set<Double> { val discriminant = b.toDouble() * b.toDouble() - 4.0 * a.toDouble() * c.toDouble() if (discriminant < 0) { return emptySet() } val sqrtedDiscriminant = s...
0
Rust
0
12
74294a4628e96a64def885fdcdd9c1444224802c
1,432
RanolP
The Unlicense
src/main/kotlin/day9.kt
tianyu
574,561,581
false
{"Kotlin": 49942}
import assertk.assertThat import assertk.assertions.isEqualTo import kotlin.math.absoluteValue import kotlin.math.sign private fun main() { tests { val example = """ R 4 U 4 L 3 D 1 R 4 D 1 L 5 R 2 """.trimIndent() "Reading head movements" { val head...
0
Kotlin
0
0
6144cc0ccf1a51ba2e28c9f38ae4e6dd4c0dc1ea
2,730
AdventOfCode2022
MIT License
src/main/kotlin/days/Day11Data.kt
yigitozgumus
572,855,908
false
{"Kotlin": 26037}
package days import utils.SolutionData import utils.Utils.createPart1Monkey import utils.Utils.createPart2Monkey fun main() = with(Day11Data()) { println(" --- Part 1 --- ") solvePart1() println(" --- Part 2 --- ") solvePart2() } data class Item(var worry: Long, val part1: Boolean = true) { operator fun pl...
0
Kotlin
0
0
9a3654b6d1d455aed49d018d9aa02d37c57c8946
2,288
AdventOfCode2022
MIT License
src/main/kotlin/com/staricka/adventofcode2023/days/Day8.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day import com.staricka.adventofcode2023.util.lcm class Day8: Day { enum class Direction { L, R } data class MapPath(val left: String, val right: String) { companion object { fun fromStri...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
2,716
adventOfCode2023
MIT License
src/main/kotlin/me/grison/aoc/y2020/Day20.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2020 import arrow.syntax.collections.tail import me.grison.aoc.* import java.util.* class Day20 : Day(20, 2020) { override fun title() = "Jurassic Jigsaw" private fun tiles() = inputGroups.map { it.lines() } .map { t -> Tile(t.first().allLongs(includeNegative = fals...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
7,554
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/g2601_2700/s2642_design_graph_with_shortest_path_calculator/Graph.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2601_2700.s2642_design_graph_with_shortest_path_calculator // #Hard #Design #Heap_Priority_Queue #Graph #Shortest_Path // #2023_07_18_Time_789_ms_(100.00%)_Space_69.8_MB_(25.00%) import java.util.PriorityQueue class Graph(n: Int, edges: Array<IntArray>) { private val adj = HashMap<Int, ArrayList<Pair<In...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,697
LeetCode-in-Kotlin
MIT License
2020/src/main/kotlin/de/skyrising/aoc2020/day22/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2020.day22 import de.skyrising.aoc.* import java.util.* private fun readInput(input: PuzzleInput): Map<Int, LinkedList<Int>> { val map = mutableMapOf<Int, LinkedList<Int>>() var current = LinkedList<Int>() var id = -1 for (line in input.lines) { when { line....
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,887
aoc
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year20/Day20.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year20 import com.grappenmaker.aoc.* import com.grappenmaker.aoc.Direction.* fun PuzzleSet.day20() = puzzle(day = 20) { data class Tile(val id: Int, val grid: BooleanGrid) val tiles = input.doubleLines().map(String::lines).map { l -> Tile(l.first().splitInts().single(), l...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,233
advent-of-code
The Unlicense
src/main/kotlin/dev/siller/aoc2023/Day03.kt
chearius
725,594,554
false
{"Kotlin": 50795, "Shell": 299}
package dev.siller.aoc2023 import dev.siller.aoc2023.util.Point import dev.siller.aoc2023.util.Vector data object Day03 : AocDayTask<UInt, UInt>( day = 3, exampleInput = """ |467..114.. |...*...... |..35..633. |......#... |617*...... |.....+.58. ...
0
Kotlin
0
0
fab1dd509607eab3c66576e3459df0c4f0f2fd94
3,926
advent-of-code-2023
MIT License
src/main/kotlin/dynamic_programming/PalindromePartitioning.kt
TheAlgorithms
177,334,737
false
{"Kotlin": 41212}
package dynamic_programming /** * Palindrome Partitioning Algorithm * * You are given a string as input, and task is to find the minimum number of partitions to be made, * in the string sot that the resulting strings are all palindrome * eg. s = "nitik" * string s can be partitioned as n | iti | k into 3 palindr...
62
Kotlin
369
1,221
e57a8888dec4454d39414082bbe6a672a9d27ad1
1,853
Kotlin
MIT License
src/main/kotlin/wordle.kt
rileynull
448,412,739
false
null
val solutions = java.io.File("""wordlist_solutions.txt""").readLines().map { it.toUpperCase() } val guesses = java.io.File("""wordlist_guesses.txt""").readLines().map { it.toUpperCase() } enum class Hint { GREEN, YELLOW, GREY } /** * Produce colored hints for a guess with respect to a solution, just like the gam...
0
Kotlin
0
0
9e92a16e9ad517b5afda7c70899bd0c67fd0e0a0
2,059
wordle-kot
Apache License 2.0
src/main/kotlin/adventofcode/Day3.kt
geilsonfonte
226,212,274
false
null
package adventofcode import kotlin.math.abs typealias Point = Pair<Int, Int> typealias Wire = List<Point> val DIRECTIONS = mapOf('U' to Pair(0, 1), 'R' to Pair(1, 0), 'D' to Pair(0, -1), 'L' to Pair(-1, 0)) val ORIGIN = Pair(0, 0) fun manhattan(a: Point, b: Point = ORIGIN): Int { return abs(a.first - b.first) +...
1
Kotlin
0
0
e3fb51a61a9a38e2f5e093362d360a3d5a5abb1a
1,672
advent-of-code-2019
The Unlicense
src/main/kotlin/days/Day4.kt
mir47
433,536,325
false
{"Kotlin": 31075}
package days class Day4 : Day(4) { override fun partOne(): Int { return findWinner(getBoards()).second } override fun partTwo(): Int { val boards = getBoards() while (boards.size > 1) { boards.remove(findWinner(boards).first) } return findWinner(boards)...
0
Kotlin
0
0
686fa5388d712bfdf3c2cc9dd4bab063bac632ce
2,057
aoc-2021
Creative Commons Zero v1.0 Universal
src/Day01.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
fun main() { fun part1(input: List<String>): Long { var prevCalCount: Long = 0 val lastCalCount = input.fold(0L) { acc, cal -> val cur = cal.toLongOrNull() if (cur == null) { if (prevCalCount < acc) { prevCalCount = acc } ...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
1,211
aoc-2022-demo
Apache License 2.0
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/sort/RadixSort.kt
FunkyMuse
168,687,007
false
{"Kotlin": 1728251}
package dev.funkymuse.datastructuresandalgorithms.sort import kotlin.math.pow fun MutableList<Int>.radixSort() { val base = 10 var done = false var digits = 1 while (!done) { done = true val buckets = arrayListOf<MutableList<Int>>().apply { for (i in 0..9) { ...
0
Kotlin
92
771
e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1
2,139
KAHelpers
MIT License
src/main/kotlin/adventofcode/year2020/Day07HandyHaversacks.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day07HandyHaversacks(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val bagRules by lazy { input.lines().map { rule -> val (color) = BAG_RULE_REGEX.find(rule)!!.destructured ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,801
AdventOfCode
MIT License
untitled/src/main/kotlin/Day7.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
class Day7(private val fileName: String) : AocSolution { override val description: String get() = "Day 7 - No Space Left on Device ($fileName)" private val root = parse(InputReader(fileName).lines) override fun part1() = smallDirectories().sumOf { it.size() } private fun smallDirectories() = findDirs...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
2,580
adventofcode2022-kotlin
The Unlicense
15/day-15.kt
nils-degroot
433,879,737
false
null
package some.test import java.io.File import java.util.PriorityQueue data class Point(val x: Int, val y: Int) data class PathCost(val point: Point, val cost: Int) : Comparable<PathCost> { public override fun compareTo(other: PathCost): Int = cost - other.cost } class Chiton(var relativePath: String) { private v...
0
Rust
0
0
8e291bacdbd85ce08eee3920586569a9c146c790
1,578
advent-of-code-2021
MIT License
OddOccurrencesInArray.kt
getnahid
267,415,396
false
null
/* OddOccurrencesInArray Find value that occurs in odd number of elements. A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For ex...
0
Kotlin
0
0
589c392237334f6c53513dc7b75bd8fa81ad3b79
1,451
programing-problem-solves-kotlin
Apache License 2.0
src/Day01.kt
Miguel1235
726,260,839
false
{"Kotlin": 21105}
val findFirstNumber = { word: String -> Regex("""\d""").find(word)!!.value } private fun text2Numbers(word: String): String { val regexNumbers = Regex("""(?=(one|two|three|four|five|six|seven|eight|nine))""") val text2Number = mapOf( "one" to "1", "two" to "2", "three" to "3", ...
0
Kotlin
0
0
69a80acdc8d7ba072e4789044ec2d84f84500e00
971
advent-of-code-2023
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day24.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2016 import se.saidaspen.aoc.util.* fun main() = Day24.run() object Day24 : Day(2016, 24) { data class State(val pos : P<Int, Int>, val visited: Set<Int>) override fun part1(): Any { val map = toMap(input) val goals = map.values.filter { it.digitToIntOrNull() != ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,866
adventofkotlin
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day19/Day19.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day19 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputSplitOnBlank import kotlin.math.abs object Day19 : Day { override val input = readInputSplitOnBlank(19).mapIndexed { i, l -> Scanner.from(i, l.lines().drop(1)) } overr...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
3,443
aoc2021
MIT License
advent-of-code-2023/src/test/kotlin/Day4Test.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test class Day4Test { data class Card( val index: Int, val left: List<Int>, val right: List<Int>, ) { val winning = left.intersect(right.toSet()).size val score: Int = if (winning == 0) 0 else 1.shl(winning - 1) val follo...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,617
advent-of-code
MIT License
src/Day09.kt
dcbertelsen
573,210,061
false
{"Kotlin": 29052}
import java.io.File import kotlin.math.abs import kotlin.math.round import kotlin.math.roundToInt fun main() { fun part1(input: List<String>): Int { val rope = Rope() input.forEach { moveData -> val move = moveData.split(" ") repeat(move[1].toInt()) { rope.m...
0
Kotlin
0
0
9d22341bd031ffbfb82e7349c5684bc461b3c5f7
2,913
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SmallestEquivalentString.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
1,997
kotlab
Apache License 2.0
src/y2022/day09.kt
sapuglha
573,238,440
false
{"Kotlin": 33695}
package y2022 import readFileAsLines data class KnotPosition( val name: String, var x: Int = 0, var y: Int = 0, ) fun KnotPosition.move(direction: String) = when (direction) { "U" -> y++ "D" -> y-- "L" -> x-- else /*RIGHT*/ -> x++ } private fun KnotPosition.tailFollow(head: KnotPosition,...
0
Kotlin
0
0
82a96ccc8dcf38ae4974e6726e27ddcc164e4b54
4,730
adventOfCode2022
Apache License 2.0
src/Day13.kt
xNakero
572,621,673
false
{"Kotlin": 23869}
import Status.* import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonPrimitive object Day13 { fun part1(): Int = parse() .mapIndexed {...
0
Kotlin
0
0
c3eff4f4c52ded907f2af6352dd7b3532a2da8c5
2,765
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1401_1500/s1463_cherry_pickup_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1463_cherry_pickup_ii // #Hard #Array #Dynamic_Programming #Matrix // #2023_06_13_Time_198_ms_(100.00%)_Space_40.3_MB_(100.00%) class Solution { fun cherryPickup(grid: Array<IntArray>): Int { val m = grid.size val n = grid[0].size val dp = Array(n) { Array(n) { IntArray...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,345
LeetCode-in-Kotlin
MIT License
2022/src/main/kotlin/Day13.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import Day13.Data.DataList import Day13.Data.DataValue import kotlin.math.min object Day13 { fun part1(input: String): Int { return input.split("\n\n") .map { it.splitNewlines() } .map { (left, right) -> compare(parse(left), parse(right)) } .foldIndexed(0) { index, acc, result -> acc + if (res...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,466
advent-of-code
MIT License
src/day-8/part-1/solution-day-8-part-1.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File val treeGrid = mutableListOf<String>() File("../input.txt").readLines() .forEach { treeGrid.add(it) } val treeGridWidth = treeGrid.first().length val treeGridHeight = treeGrid.size fun isAtEdge(x: Int, y: Int) = x == 0 || x == treeGridWidth - 1 || y == 0 || y == treeGridHeight - 1 fun isVis...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
1,539
advent-of-code-22
MIT License
src/2017Day10.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
package day2017_10 import utils.runSolver private typealias SolutionType = Int private const val defaultSolution = 0 private const val dayNumber: String = "10" private val testSolution1: SolutionType? = 88 private val testSolution2: SolutionType? = 36 class Node(val number: Int, var node: Node? = null) { fun g...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
1,740
2022-AOC-Kotlin
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day09.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode.days import tr.emreone.adventofcode.manhattanDistanceTo import tr.emreone.adventofcode.move import tr.emreone.kotlin_utils.math.Point2D object Day09 { private val PATTERN = """(\w+) (\d+)""".toRegex() private fun calcNewPositionOfKnot(me: Point2D, nextKnot: Point2D): Point2D ...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
2,542
advent-of-code-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/whac_a_mole/WhacMole.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.whac_a_mole import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/350139/Google-or-Phone-Screen-or-Whac-A-Mole */ class WhacMoleTests { @Test fun `hit max amount of moles`() { hit(arrayOf(0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0), mall...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,707
katas
The Unlicense
src/main/kotlin/info/benjaminhill/stats/preprocess/Preprocessing.kt
salamanders
184,444,482
false
null
package info.benjaminhill.stats.preprocess import org.nield.kotlinstatistics.percentile /** Anything outside the bounds gets clamped to the bounds */ fun List<Double>.coercePercentile(pct: Double = 0.05): List<Double> { require(isNotEmpty()) require(pct in 0.0..1.0) // odd that it is pct of 100, not pct o...
0
Kotlin
0
0
3e3c246c18fa3009f7f54822a70202da3f1b65c5
1,863
ezstats
MIT License
src/Day11.kt
konclave
573,548,763
false
{"Kotlin": 21601}
import kotlin.collections.ArrayDeque fun main() { class Monkey(monkey: List<String>, var worryDivider: Int? = null) { val id: Int val items: ArrayDeque<Long> = ArrayDeque() var actCount: Int = 0 private val operator: String private val opArg: String val testNum: Int ...
0
Kotlin
0
0
337f8d60ed00007d3ace046eaed407df828dfc22
4,114
advent-of-code-2022
Apache License 2.0
src/Day24.kt
kipwoker
572,884,607
false
null
import kotlin.time.ExperimentalTime import kotlin.time.measureTime class Day24 { data class Valley(val blizzards: Map<Point, List<Direction>>, val maxY: Int, val maxX: Int) data class Moment(val expedition: Point, val minutesSpent: Int) fun parse(input: List<String>): Valley { val blizzards = muta...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
7,236
aoc2022
Apache License 2.0
src/Day06.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
fun main() { fun check(input: String, size: Int): Int { for (i in 0..input.length - size) { val message = input.substring(i until i + size) val groupBy: Map<String, List<String>> = message.chunked(1).groupBy { it.uppercase() } if (groupBy.size == size) { ...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
1,386
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day17/Day17.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day17 import java.io.File import kotlin.math.abs import kotlin.math.max fun main() { val data = parse("src/main/kotlin/day17/Day17.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 17 🎄") println() println("[Part 1]") println("Answer: $answer1") pr...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
1,783
advent-of-code-2021
MIT License
src/main/aoc2023/Day3.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 import AMap import Pos import increase class Day3(input: List<String>) { private val map = AMap.parse(input, listOf('.')) private val numbers = findNumbers() private val symbols = map.toMap().filterValues { it !in '0'..'9' } // Map each number to the position of the first digit in th...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,425
aoc
MIT License
src/UsefulStuff.kt
AmandaLi0
574,592,026
false
{"Kotlin": 5338}
fun main(){ val input = readInput("numbers") println("Sum: ${countWords(input)}") } fun sumAllNums(input: List<String>):Int{ var total = 0 for(num in input){ total += num.toInt() } return total // return input.map { it.toInt() }.sum() } fun findMin(input: List<String>):Int{ // v...
0
Kotlin
0
0
5ce0072f3095408688a7812bc3267834f2ee8cee
1,034
AdventOfCode
Apache License 2.0
solutions/aockt/y2023/Y2023D21.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import aockt.util.spacial.Area import aockt.util.spacial.Direction import aockt.util.spacial.Point import aockt.util.spacial.move import aockt.util.validation.assume import io.github.jadarma.aockt.core.Solution object Y2023D21 : Solution { /** * The map to an elve...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
6,009
advent-of-code-kotlin-solutions
The Unlicense
src/Day08.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
fun main() { val input = readInput("Day08") println(Day08.part1(input)) println(Day08.part2(input)) } class Day08 { companion object { fun part1(input: List<String>): Int { val forest = input.map { it.split("").filter { c -> c.isNotEmpty() }.map { character -> char...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
3,744
advent-of-code-22
Apache License 2.0
src/Day09.kt
mr-cell
575,589,839
false
{"Kotlin": 17585}
import java.lang.IllegalArgumentException import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun part1(input: List<String>): Int { val moves = parseInput(input) return followPath(moves, 2) } fun part2(input: List<String>): Int { val moves = parseInput(input) ...
0
Kotlin
0
0
2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9
2,084
advent-of-code-2022
Apache License 2.0
src/day04/Day04.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
package day04 import readInput class Section(sectionRange: String) { var startID: Int = 0 var endID: Int = 0 init { val idRange = sectionRange.split("-") startID = idRange[0].toInt() endID = idRange[1].toInt() } fun isFullyContainedIn(other: Section): Boolean = startID >...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
1,525
AdventOfCode2022
Apache License 2.0
src/Day04.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
fun main() { fun part1(pairs: List<Pair<IntRange, IntRange>>) = pairs.count { (range1, range2) -> range1.contains(range2.first) && range1.contains(range2.last) || range2.contains(range1.first) && range2.contains(range1.last) } fun part2(pairs: List<Pair<IntRange, IntRange>>) = pairs.count { (range1...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
728
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2021/day7/CrabSubmarine.kt
arnab
75,525,311
false
null
package aoc2021.day7 import kotlin.math.abs object CrabSubmarine { fun parse(data: String) = data.split(",").map { it.toInt() } fun findFuelCostForMedian(crabs: List<Int>): Int { val sortedCrabs = crabs.sorted() val midIndex = sortedCrabs.size / 2 return (midIndex - 1..midIndex + 1).m...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,062
adventofcode
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day11.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.abs import kotlin.test.assertEquals class Day11 : AbstractDay() { @Test fun part1Test() { assertEquals(374, compute1(testInput)) } @Test fun part1Puzzle() { assertEqu...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,892
aoc
Apache License 2.0
src/Day20.kt
er453r
572,440,270
false
{"Kotlin": 69456}
import kotlin.math.absoluteValue fun main() { class Wrapper(val value: Long) fun mix(originalOrder:List<Wrapper>, mixed:MutableList<Wrapper>){ // println(mixed.map { it.value }) for (entry in originalOrder) { val entryPositionInMixed = mixed.indexOf(entry) mixed.remove...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
1,955
aoc2022
Apache License 2.0
codeforces/globalround5/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.globalround5 fun main() { val n = readInt() val a = readInts() val b = a.plus(a).plus(a) val st = SegmentsTreeSimple(b) val r = IntArray(b.size) val ans = IntArray(b.size) for (i in b.indices.reversed()) { val v = b[i] var low = i + 1 var high = b.size + 1 while (low + 1 < high) { ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,427
competitions
The Unlicense
src/Day12.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
import java.util.PriorityQueue import kotlin.math.abs fun main() { class ElevationMap(inputMapData: List<String>) { val height = inputMapData.size val width = inputMapData[0].length val map = MutableList(height) { MutableList(width) { "?" } } val listOfPotentialStartingPoints: Mut...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
6,150
advent_of_code_2022
Apache License 2.0
lib/src/main/kotlin/aoc/day15/Day15.kt
Denaun
636,769,784
false
null
@file:Suppress("UnstableApiUsage") package aoc.day15 import com.google.common.collect.ContiguousSet import com.google.common.collect.DiscreteDomain.longs import com.google.common.collect.Range import com.google.common.collect.RangeSet import com.google.common.collect.TreeRangeSet import kotlin.math.abs fun part1(inp...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
2,027
aoc-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day25.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import kotlin.math.absoluteValue import kotlin.math.pow import kotlin.math.sign open class Part25A : PartSolution() { private lateinit var snafu: List<String> override fun parseInput(text: String...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,947
advent-of-code-kotlin
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day21.kt
clechasseur
435,726,930
false
{"Kotlin": 315943}
package io.github.clechasseur.adventofcode2021 import kotlin.math.max object Day21 { private const val player1StartingPos = 8 private const val player2StartingPos = 3 fun part1(): Int = playGame(DeterministicDice()) fun part2(): Long = playQuantumGame() private interface Die { fun roll(...
0
Kotlin
0
0
4b893c001efec7d11a326888a9a98ec03241d331
3,639
adventofcode2021
MIT License
src/main/kotlin/com/github/michaelbull/advent/day10/AsteroidMap.kt
michaelbull
225,205,583
false
null
package com.github.michaelbull.advent.day10 import com.github.michaelbull.advent.Position import java.util.ArrayDeque import java.util.SortedMap data class AsteroidMap( val asteroids: List<Position> ) { fun detectableAsteroids(from: Position): Int { return asteroids .filter { it != from }...
0
Kotlin
0
2
d271a7c43c863acd411bd1203a93fd10485eade6
1,795
advent-2019
ISC License
src/Day15.kt
janbina
112,736,606
false
null
package day15 import getInput import kotlin.coroutines.experimental.buildSequence import kotlin.test.assertEquals fun main(args: Array<String>) { val (genA, genB) = getInput(15).readLines().map { it.split(" ").last().toLong() } val factorA = 16807 val factorB = 48271 val module = 2147483647 asser...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
1,507
advent-of-code-2017
MIT License
src/Day19.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
import java.time.Duration import java.time.Instant import java.util.* fun main() { data class Blueprint(val robotToCosts: Array<IntArray>) { override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is Blueprint) return false if (!robotToCos...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
9,417
advent-of-code-2022
Apache License 2.0
code/data_structures/DisjointMinTable.kt
hakiobo
397,069,173
false
null
private class DisjointMinTable(input: IntArray) { val n = ((input.size shl 1) - 1).takeHighestOneBit() val levels = n.countTrailingZeroBits() val nums = IntArray(n) { idx -> if (idx < input.size) input[idx] else 0 } val table = Array(levels) { IntArray(n) } init { for (level in 0 until leve...
0
Kotlin
1
2
f862cc5e7fb6a81715d6ea8ccf7fb08833a58173
1,290
Kotlinaughts
MIT License
dcp_kotlin/src/main/kotlin/dcp/day289/day289.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day289 // day289.kt // By <NAME>, 2020. // We can do this two ways: // The first way is the more complicated minimax way, which entails calculating all moves and determining if the // winning move is in the moves. If it is, it is possible for the first player to win Misere Nim. fun nimMiniMax(heapList: Li...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,750
daily-coding-problem
MIT License
src/main/kotlin/days/Day5.kt
sicruse
434,002,213
false
{"Kotlin": 29921}
package days class Day5 : Day(5) { private val vents: List<Line> by lazy { inputList.map { Line(it) } } data class Point(val x: Int, val y: Int) { constructor(point: Point) : this(x = point.x, y = point.y) constructor(text: String) : this(fromText(text)) companion object { ...
0
Kotlin
0
0
172babe6ee67a86a7893f8c9c381c5ce8e61908e
2,335
aoc-kotlin-2021
Creative Commons Zero v1.0 Universal
solutions/src/solutions/y19/day 10.kt
Kroppeb
225,582,260
false
null
@file:Suppress("PackageDirectoryMismatch") package solutions.solutions.y19.d10 import helpers.* import kotlin.math.* private fun ggd(a:Int, b:Int):Int = if(a == 0) b else ggd(b % a, a) private fun part1(data: List<List<Boolean>>) { (data.indices).map { x -> (data[x].withIndex().filter { it.value }).map { (y,_) ->...
0
Kotlin
0
1
744b02b4acd5c6799654be998a98c9baeaa25a79
1,500
AdventOfCodeSolutions
MIT License
src/com/zypus/genetic/Selections.kt
zypus
213,665,750
false
null
package com.zypus.SLIP.algorithms.genetic import java.util.* /** * TODO Add description * * @author fabian <<EMAIL>> * * @created 03/03/16 */ object Selections { inline fun <G : Any, P : Any, B : Any, BC : Any> elitist(population: List<Entity<G, P, B, BC>>, count: Int, crossinline fitness: (Entity<G, P, B, ...
0
Kotlin
0
0
418ee8837752143194fd769e86fac85e15136929
1,528
SLIP
MIT License
src/aoc23/Day11.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day11 import kotlin.math.abs import lib.Collections.cumulativeSum1 import lib.Grid import lib.Point import lib.Solution data class Image(val galaxies: List<Point>, val maxBound: Point) { fun expandRows(count: Int): Image { val rowSizes = (0..maxBound.y)....
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,015
aoc-kotlin
Apache License 2.0
src/main/day22/day22.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day22 import Point import day22.Direction.DOWN import day22.Direction.LEFT import day22.Direction.RIGHT import day22.Direction.UP import readInput typealias Board = Map<Point, Char> const val WALL = '#' const val OPEN = '.' fun main() { val input = readInput("main/day22/Day22") println(part1(input)...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
7,626
aoc-2022
Apache License 2.0
math/RomanToInteger/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Roman numerals are represented by seven different symbols: * I, V, X, L, C, D and M. * Symbol Value * I 1 * V 5 * X 10 * L 50 * C 100 * D 500 * M 1000 * For example, 2 is written a...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
2,413
codility
MIT License
src/main/kotlin/dev/tasso/adventofcode/_2021/day04/Day04.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day04 import dev.tasso.adventofcode.Solution class Day04 : Solution<Int> { override fun part1(input: List<String>): Int { val calledNumbers = input[0].split(",") val cards = input.asSequence() .drop(2) .filterNot { it == "" } ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
1,840
advent-of-code
MIT License
src/main/kotlin/g1601_1700/s1671_minimum_number_of_removals_to_make_mountain_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1601_1700.s1671_minimum_number_of_removals_to_make_mountain_array // #Hard #Array #Dynamic_Programming #Greedy #Binary_Search // #2023_06_15_Time_264_ms_(100.00%)_Space_38.4_MB_(100.00%) class Solution { fun minimumMountainRemovals(nums: IntArray): Int { val n = nums.size // lbs -> longes...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,516
LeetCode-in-Kotlin
MIT License
src/Day16.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import kotlin.system.measureTimeMillis fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day16_test") .parseCave() val part1TestInputResult = part1(testInput) println("Part 1 (test input): $part1TestInputResult") check(part1TestInpu...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
7,452
aoc22-kotlin
Apache License 2.0
src/Day03.kt
jdappel
575,879,747
false
{"Kotlin": 10062}
val lowercase = 'a'..'z' val uppercase = 'A'..'Z' fun main() { fun logic(input: List<String>): Int { return input.fold(0) { acc, line -> val (first, second) = line.take(line.length.div(2)) to line.substring(line.length.div(2)) acc + first.toCharArray().intersect(second.toCharArra...
0
Kotlin
0
0
ddcf4f0be47ccbe4409605b37f43534125ee859d
1,383
AdventOfCodeKotlin
Apache License 2.0
aoc21/day_10/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File import java.util.ArrayDeque fun match(c: Char): Char = when (c) { '(' -> ')' '[' -> ']' '{' -> '}' '<' -> '>' else -> c } fun scoreErr(c: Char): Long = when (c) { ')' -> -3 ']' -> -57 '}' -> -1197 '>' -> -25137 else -> 0 } fun scoreMissing(c: Char): Long = ...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,006
advent-of-code
MIT License
src/main/day02/day02.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day02 import readInput import reverse import second const val ROCK = "A" const val PAPER = "B" const val SCISSORS = "C" const val ROCK_ = "X" const val PAPER_ = "Y" const val SCISSORS_ = "Z" const val LOSE = "X" const val DRAW = "Y" const val WIN = "Z" fun part1(input: List<String>): Int { return inpu...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
1,492
aoc-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/regex_matching/v5/RegexMatching.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.regex_matching.v5 import datsok.shouldEqual import org.junit.jupiter.api.Test class RegexMatching { @Test fun `some examples`() { "".matchesRegex("") shouldEqual true "".matchesRegex("a") shouldEqual false "a".matchesRegex("") shouldEqual false "a".mat...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,322
katas
The Unlicense
kotlin/src/2022/Day22_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
private data class P(val x: Int, val y: Int) fun main() { val input = readInput(22).lines() val board = mutableMapOf<P, Int>() // wall = 2, empty field = 1, nothing = not in map val N = input.indexOfFirst {it.isBlank()} val M = input.take(N).maxOf {it.length} input.take(N).withIndex().forEach { ...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
4,019
adventofcode
Apache License 2.0
src/Day02.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (opponent, ally) = it.split(" ") fun map(sign: String): Int { return when (sign) { "A", "X" -> 1 "B", "Y" -> 2 "C", "Z" -> 3 ...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
2,469
aoc-2022
Apache License 2.0
src/main/kotlin/day-03.kt
warriorzz
728,357,548
false
{"Kotlin": 15609, "PowerShell": 237}
package com.github.warriorzz.aoc class Day3 : Day(3) { var lines: List<ScematicLine> = listOf() override fun init() { lines = input.map { line -> val numbers = "\\d+".toRegex().findAll(line).map { result -> val int = result.value.toInt() val range = result....
0
Kotlin
0
1
502993c1cd414c0ecd97cda41475401e40ebb8c1
4,406
aoc-23
MIT License
src/main/kotlin/solutions/Day12.kt
chutchinson
573,586,343
false
{"Kotlin": 21958}
class Day12 : Solver { data class Vector2i(val x: Int, val y: Int) data class Grid(val cells: List<Char>, val width: Int, val height: Int) override fun solve (input: Sequence<String>) { val grid = parse(input) println(first(grid)) println(second(grid)) ...
0
Kotlin
0
0
5076dcb5aab4adced40adbc64ab26b9b5fdd2a67
3,030
advent-of-code-2022
MIT License
src/main/kotlin/g2801_2900/s2850_minimum_moves_to_spread_stones_over_grid/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2850_minimum_moves_to_spread_stones_over_grid // #Medium #Array #Dynamic_Programming #Breadth_First_Search #Matrix // #2023_12_18_Time_133_ms_(100.00%)_Space_34.6_MB_(100.00%) import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Solution { fun minimumMoves(grid: Array<In...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,400
LeetCode-in-Kotlin
MIT License
year2021/src/main/kotlin/net/olegg/aoc/year2021/day9/Day9.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day9 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.get import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 9](https://adventofcode.com/2021/day/9) */ object Day9 ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,841
adventofcode
MIT License
src/com/kingsleyadio/adventofcode/y2022/day02/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day02 import com.kingsleyadio.adventofcode.util.readInput fun main() { val input = readInput(2022, 2).readLines() part1(input) part2(input) } fun part1(input: List<String>) { val result = input.sumOf { line -> when(line) { "A X" -> 4 ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,041
adventofcode
Apache License 2.0
src/Day25.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
fun main() { // convert SNAFU digit (2, 1, 0, -, =) to Dec fun snafuDigit(digit: Char): Int { return when(digit) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else -> 999 } } fun snafuToDec(snafuNum: String): Lon...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
1,457
advent-of-code-2022
Apache License 2.0
src/main/java/org/example/BiPartiteGraph.kt
jaypandya
584,055,319
false
null
package org.example class Solution { enum class Color { Red, Blue, None; } fun isBipartite(graph: Array<IntArray>): Boolean { val queue = ArrayDeque<Int>() val colorArray = Array(graph.size) { Color.None } for (index in colorArray.indices) { if (colorArray[index...
0
Kotlin
0
0
5f94df91e07773239583c520682ed6505b0c186b
2,711
dsa
MIT License
app/src/main/kotlin/day01/Day01.kt
W3D3
726,573,421
false
{"Kotlin": 81242}
package day01 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 1 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay01Part1, ::solveDay01Part2) } val numbers = arrayOf("one", "two", "three", "fou...
0
Kotlin
0
0
da174508f6341f85a1a92159bde3ecd5dcbd3c14
1,449
AdventOfCode2023
Apache License 2.0
calendar/day05/Day5.kt
polarene
572,886,399
false
{"Kotlin": 17947}
package day05 import Day import Lines class Day5 : Day() { override fun part1(input: Lines): Any { val crates = setupCrates(input) val crane = Crane9000(crates) input.asSequence() .dropWhile { it.isNotEmpty() } .drop(1) .map(::readStep) .forE...
0
Kotlin
0
0
0b2c769174601b185227efbd5c0d47f3f78e95e7
2,867
advent-of-code-2022
Apache License 2.0
src/Lesson9MaximumSliceProblem/MaxProfit.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * Check MaxSliceSum for explanation on Kadane's algorithm is applied here * @param A * @return */ fun solution(A: IntArray): Int { if (A.size == 1 || A.size == 0) { return 0 } var maxSoFar = 0 var maxEndingHere = 0 var minPrice = A[0] for (i in 1 until A.size) { ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,196
Codility-Kotlin
Apache License 2.0
advent-of-code-2021/src/code/day2/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day2 import java.io.File fun main() { doIt("Day 2 Part 1: Test Input", "src/code/day2/test.input", part1); doIt("Day 2 Part 1: Real Input", "src/code/day2/part1.input", part1); doIt("Day 2 Part 2: Test Input", "src/code/day2/test.input", part2); doIt("Day 2 Part 2: Real Input", "src/code/...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
1,500
misc-dev
MIT License
src/Day10.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
private sealed interface Command private sealed interface Assembly private object Noop : Command, Assembly private class AddX(val value: Int) : Command private class Add(val value: Int) : Assembly fun main() { fun parseCommand(str: String): Command { return when { str == "noop" -> Noop ...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
3,251
aoc2022
Apache License 2.0
src/Day12.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
import java.util.Stack fun main() { fun prepareGrid( input: List<String>, x: Int, y: Int, ): Triple<Array<Array<Vertex>>, Pair<Int, Int>, Pair<Int, Int>> { val grid = Array(x) { Array(y) { Vertex() } } var source = 0 to 0 var destination = 0 to 0 input ...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
5,369
aoc-2022
Apache License 2.0
day03/part1.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Day 3: Gear Ratios --- // You and the Elf eventually reach a gondola lift station; he says the gondola // lift will take you up to the water source, but this is as far as he can // bring you. You go inside. // // It doesn't take long to find the gondolas, but there seems to be a problem: // they're not moving. /...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
2,636
adventofcode2023
MIT License
AdventOfCodeDay03/src/nativeMain/kotlin/Day03.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
class Day03(private val lines:List<String>) { fun solvePart1():Long { val linesCount = lines.count() val halfCount = linesCount/2 val gammaString = lines[0].indices.map { idx -> val onesCount = lines.count{it[idx] == '1'} val onesGreater = onesCount > halfCount ...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
1,731
AdventOfCode2021
The Unlicense
src/main/kotlin/de/jball/aoc2022/day10/Day10.kt
fibsifan
573,189,295
false
{"Kotlin": 43681}
package de.jball.aoc2022.day10 import de.jball.aoc2022.Day class Day10(test: Boolean = false): Day<Int>(test, 13140, 1 /*cheating here...*/) { private val program = input.map { parseCommand(it) } private val spritePositions = program .runningFold(listOf(Pair(0,1))) { state, operation -> operation.apply(st...
0
Kotlin
0
3
a6d01b73aca9b54add4546664831baf889e064fb
1,646
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day1.kt
andilau
544,512,578
false
{"Kotlin": 29165}
package days import days.Day1.Direction.* import kotlin.math.abs @AdventOfCodePuzzle( name = "No Time for a Taxicab", url = "https://adventofcode.com/2016/day/1", date = Date(day = 1, year = 2016) ) class Day1(input: String) : Puzzle { private val instructions = input .split(", ") .ma...
3
Kotlin
0
0
b2a836bd3f1c5eaec32b89a6ab5fcccc91b665dc
2,029
advent-of-code-2016
Creative Commons Zero v1.0 Universal
src/Day07.kt
psy667
571,468,780
false
{"Kotlin": 23245}
enum class Type { DIR, FILE, } data class Node(val type: Type, val name: String, var size: Int, val children: MutableList<Node>) fun main() { val id = "07" fun Node.addChildDir(name: String) { this.children.add(Node(Type.DIR, name, 0, mutableListOf())) } fun Node.addChildFile(name: ...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
3,932
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/AsFarFromLandAsPossible.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
2,021
kotlab
Apache License 2.0
src/Day01.kt
hoppjan
573,053,610
false
{"Kotlin": 9256}
fun main() { val testLines = readInput("Day01_test") val testResult1 = part1(testLines) check(testResult1 == 24_000) println("test part 1: $testResult1") val testResult2 = part2(testLines) check(testResult2 == 45_000) println("test part 2: $testResult2") val lines = readInput("Day01"...
0
Kotlin
0
0
f83564f50ced1658b811139498d7d64ae8a44f7e
887
advent-of-code-2022
Apache License 2.0
src/Day01.kt
freszu
573,122,040
false
{"Kotlin": 32507}
fun main() { fun part1(input: List<String>) = input.map { it.toIntOrNull() } .fold(0 to 0) { (max, current), value -> if (value != null) { Pair(max, current + value) } else { Pair(if (current > max) current else max, 0) } }.first ...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
840
aoc2022
Apache License 2.0
day3/kt3/src/main/kotlin/Main.kt
smjackson
470,351,294
false
{"Kotlin": 6920, "C++": 1618}
import com.adhara.readFile import kotlin.math.pow fun main(args: Array<String>) { println("--- Day 3 ---") val input = readFile(args[0]) val numBits = input[0].trim().length val intData = inputToInt(input, numBits) partOne(intData, numBits) partTwo(intData, numBits) } fun inputToInt(input: L...
0
Kotlin
0
0
275c278829e4374061895a4ffc27dbb2b2d7891c
2,253
adventofcode2021
MIT License
AoC2021day09-SmokeBasin/src/main/kotlin/Main.kt
mcrispim
533,770,397
false
{"Kotlin": 29888}
import java.io.File class Basin(val points: MutableSet<Pair<Int, Int>> = mutableSetOf()) fun main() { val input = File("data.txt") val gridChar = input.readLines() val grid = readInts(gridChar) val lowPoints: List<Pair<Int, Int>> = getLowPoints(grid) println ("The sum of the risk levels of all low...
0
Kotlin
0
0
ac4aa71c9b5955fa4077ae40fc7e3fc3d5242523
3,199
AoC2021
MIT License
src/pl/shockah/aoc/y2021/Day12.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2021 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.aoc.UnorderedPair class Day12: AdventTask<Day12.Graph, Int, Int>(2021, 12) { data class Graph( val start: Cave, val end: Cave, val caves: Set<Cave> ) data...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
2,379
Advent-of-Code
Apache License 2.0
facebook/y2020/qual/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.qual private fun solve(): Int { val n = readInt() val growsHere = mutableMapOf<Int, Int>() val fallsHere = mutableMapOf<Int, MutableList<Int>>() repeat(n) { val (p, h) = readInts() growsHere[p] = h fallsHere.computeIfAbsent(p - h) { mutableListOf() }.add(h) } val best = mutableMapOf<...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,090
competitions
The Unlicense
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[104]二叉树的最大深度.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.math.max //给定一个二叉树,找出其最大深度。 // // 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 // // 说明: 叶子节点是指没有子节点的节点。 // // 示例: //给定二叉树 [3,9,20,null,null,15,7], // // 3 // / \ // 9 20 // / \ // 15 7 // // 返回它的最大深度 3 。 // Related Topics 树 深度优先搜索 递归 // 👍 756 👎 0 //leetcode submit region be...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,624
MyLeetCode
Apache License 2.0