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
solutions/aockt/y2016/Y2016D07.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2016 import io.github.jadarma.aockt.core.Solution object Y2016D07 : Solution { /** A valid IPv7 address. */ private data class IPv7Address(val value: String) { /** All sequences in the address, in order. */ val sequences: List<String> = buildList { // Note: This in...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,645
advent-of-code-kotlin-solutions
The Unlicense
src/2020/Day11_1.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File val input = ArrayList<CharArray>() File("input/2020/day11").forEachLine { input.add(it.toCharArray()) } var previous = input var modified = copy(input) var runs = 0 while (isChanged(previous,modified) || runs == 0) { previous = copy(modified) modified = ArrayList<CharArray>() for (y in IntR...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
1,671
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/codingbat/recursion2/GroupSumClump.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <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,514
kotlab
Apache License 2.0
src/main/kotlin/nl/fifthpostulate/specifikation/algebra/Algebra.kt
fifth-postulate
283,838,936
false
null
package nl.fifthpostulate.specifikation.algebra import nl.fifthpostulate.specifikation.* class All<T, V>(private vararg val specifications: Specification<T, V>) : Specification<T, V> { override fun isMetBy(subject: T): Report<V> { return specifications .map { it.isMetBy(subject) } ...
0
Kotlin
0
0
25fc5c99cd1d426c67dfd05d5648a9b2a59779e2
1,476
specifikation
MIT License
src/Day04.kt
mkulak
573,910,880
false
{"Kotlin": 14860}
fun main() { val regex = "([0-9]+)-([0-9]+),([0-9]+)-([0-9]+)".toRegex() fun part1(input: List<String>): Int = input.count { line -> val (s1, e1, s2, e2) = regex.matchEntire(line)!!.groupValues.drop(1).map { it.toInt() } s1 <= s2 && e1 >= e2 || s1 >= s2 && e1 <= e2 } ...
0
Kotlin
0
0
3b4e9b32df24d8b379c60ddc3c007d4be3f17d28
663
AdventOfKo2022
Apache License 2.0
src/day13/Comparator.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day13 import readInput class ComparatorContext { var depth = 0 val debug = false val prefix: String get () = " ".repeat (depth * 2) fun print (s: String) { if (debug) println ("${prefix}$s") return } fun compare (a: Any, b: Any) { if (debug) println ...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,193
advent_of_code_2022
Apache License 2.0
ceres-base/src/main/kotlin/ceres/geo/Selection.kt
regen-network
197,295,201
false
null
package ceres.geo import kotlin.math.* // Floyd-Rivest selection algorithm from https://github.com/mourner/quickselect fun quickselect( arr: Array<Double>, k: Int, left: Int = 0, right: Int = arr.size - 1, compare: Comparator<Double> = defaultCompare ) { quickselectStep(arr, k, left, right, c...
0
Kotlin
1
0
ea053727b75e9adf5a76c337b006be627cd3322f
1,836
regen-kotlin-sdk
Apache License 2.0
src/main/kotlin/com/polydus/aoc18/Day6.kt
Polydus
160,193,832
false
null
package com.polydus.aoc18 class Day6: Day(6){ //https://adventofcode.com/2018/day/6 val map: MutableList<Pos> = mutableListOf() init { //partOne() partTwo() } fun partOne(){ var highestX = 0 var highestY = 0 input.forEach { val chars = it.to...
0
Kotlin
0
0
e510e4a9801c228057cb107e3e7463d4a946bdae
4,937
advent-of-code-2018
MIT License
src/day09/Day09.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day09 import java.io.File fun main() { val data = parse("src/day09/Day09.txt") println("🎄 Day 09 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private fun parse(path: String): List<L...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
1,004
advent-of-code-2023
MIT License
codeforces/kotlinheroes8/i.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes8 import java.util.* private fun solve() { val n = readInt() val (from, toIn) = List(2) { readInts() } data class Doctor(val id: Int, val from: Int, val to: Int) val doctors = List(n) { Doctor(it, from[it], toIn[it] + 1) } val low = doctors.sortedBy { it.from }.withIndex().maxOf { ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,100
competitions
The Unlicense
src/Day09.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
import extensions.* import kotlin.math.absoluteValue class Day09 : Day(9) { class Command(line: String) { var directions = Vector2(0, 0) var amount = 0 init { val split = line.split(" ") when (split[0]) { "R" -> directions = Vector2(1, 0) ...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
1,671
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Snailfish_18.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
val numbers: List<String> by lazy { readFile("Snailfish").split("\n") } fun lexemize(input: String): ArrayDeque<String> { val lexems = ArrayDeque<String>() var i = 0 while (i < input.length) { val char = input[i] if (char.isDigit()) { var end = i while (input[end...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
3,748
advent-of-code-2021
Apache License 2.0
src/Day04/Day04.kt
suttonle24
573,260,518
false
{"Kotlin": 26321}
package Day04 import readInput fun main() { fun part1(input: List<String>): Int { var fullContainments = 0; val itr = input.listIterator(); itr.forEach { var leftStr = ""; var leftLow = 0; var leftHigh = 0; var rightStr = ""; v...
0
Kotlin
0
0
039903c7019413d13368a224fd402625023d6f54
2,511
AoC-2022-Kotlin
Apache License 2.0
src/main/kotlin/d3/D3_1.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d3 import input.Input fun sumOfLine(lines: List<String>, lineIndex: Int): Int { val line = lines[lineIndex] var sum = 0 var i = 0 while (i < line.length) { val c = line[i] if (!c.isDigit()) { i++ continue } val numberStartIndex = i ...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
1,910
aoc2023-kotlin
MIT License
codeforces/kotlinheroes8/h.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes8 fun main() { val den = 1_000_000.toModular() val (n, wid, hei) = readInts() val (pSlash, pBackslash) = List(2) { Array(wid + hei + 1) { 1.toModular() } } // prob of being free val (vertical, horizontal) = listOf(wid, hei).map { s -> BooleanArray(s + 1).also { it[0] = true; it[s] = ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,133
competitions
The Unlicense
src/shreckye/coursera/algorithms/GraphParseUtils.kt
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.io.File typealias VertexLabels = Pair<Int, IntArray> fun readAdjacencyList(filename: String, initialCapacity: Int): List<VertexLabels> = File(filename).useLines { it.map { val vertexLabelInts = it.splitToInts() vertexLabelInts.first...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
2,804
coursera-stanford-algorithms-solutions-kotlin
MIT License
day4/src/main/kotlin/day4/PlayedBingoBoard.kt
snv
434,384,799
false
{"Kotlin": 99328}
package day4 typealias Coordinate = Pair<Int, Int> class PlayedBingoBoard(private val board: BingoBoard, private val drawnNumbers: DrawnNumbers){ val winsAfter: Int private val lastCalledNumber: Int val finalScore: Int init { val (winsAfter, withMarkedNumbers) = play() this.winsAfter ...
0
Kotlin
0
0
0a2d94f278defa13b52f37a938a156666314cd13
1,768
adventOfCode21
The Unlicense
src/Day25.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
fun main() { fun Int.digitTo5() = when (this) { 3 -> "=" 4 -> "-" else -> toString() } fun Char.digitFrom5() = when (this) { '-' -> -1 '=' -> -2 else -> this.digitToInt() } fun Long.to5(): String { var res = "" var cur = this ...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
954
Advent-of-Code-2022
Apache License 2.0
src/test/kotlin/icfp2019/TestUtils.kt
godaddy-icfp
186,746,222
false
{"JavaScript": 797310, "Kotlin": 116879, "CSS": 9434, "HTML": 5859, "Shell": 70}
package icfp2019 import com.google.common.base.CharMatcher import com.google.common.base.Splitter import icfp2019.model.* import org.junit.jupiter.api.Assertions import org.pcollections.PVector import org.pcollections.TreePVector import java.nio.file.Paths fun String.toProblem(): Problem { return parseTestMap(thi...
13
JavaScript
12
0
a1060c109dfaa244f3451f11812ba8228d192e7d
5,485
icfp-2019
The Unlicense
src/main/kotlin/q1_50/q11_20/Solution18.kt
korilin
348,462,546
false
null
package q1_50.q11_20 import java.util.* /** * https://leetcode-cn.com/problems/4sum */ class Solution18 { fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val result = LinkedList<List<Int>>() if(nums.size < 4) return result nums.sort() val n = nums.size for (i1...
0
Kotlin
0
1
1ce05efeaf34536fff5fa6226bdcfd28247b2660
1,639
leetcode_kt_solution
MIT License
src/main/aoc2018/Day17.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 class Day17(input: List<String>, isGraph: Boolean = false) { data class Pos(val x: Int, val y: Int) private val area = mutableMapOf<Pos, Char>() init { if (isGraph) { for (y in input.indices) { for (x in input[0].indices) { area[Pos(...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
5,095
aoc
MIT License
src/test/kotlin/Day15.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.data.forAll import io.kotest.data.headers import io.kotest.data.row import io.kotest.data.table import io.kotest.matchers.shouldBe /* --- Day 15: Rambunctious Recitation --- See https://adventofcode.com/2020/day/15 */ fun playMemGame(start: List<Int>): Se...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
2,890
advent_of_code_2020
Apache License 2.0
src/main/kotlin/g1501_1600/s1589_maximum_sum_obtained_of_any_permutation/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1589_maximum_sum_obtained_of_any_permutation // #Medium #Array #Sorting #Greedy #Prefix_Sum // #2023_06_14_Time_867_ms_(66.67%)_Space_81.6_MB_(66.67%) class Solution { fun maxSumRangeQuery(nums: IntArray, requests: Array<IntArray>): Int { nums.sort() val l = nums.size v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,339
LeetCode-in-Kotlin
MIT License
kotlin/src/commonMain/kotlin/y2015/Day2.kt
emmabritton
358,239,150
false
{"Rust": 18706, "Kotlin": 13302, "JavaScript": 8960}
package y2015 fun runY2015D2(input: String): Pair<String, String> { val result = input.lines() .map { parse(it) } .map { calc(it) } .reduce { acc, pair -> Pair(acc.first + pair.first, acc.second + pair.second) } return Pair(result.first.toString(), result.second.toString()) } private f...
0
Rust
0
0
c041d145c9ac23ce8d7d7f48e419143c73daebda
1,011
advent-of-code
MIT License
2023/src/main/kotlin/org/suggs/adventofcode/Day04Scratchcards.kt
suggitpe
321,028,552
false
{"Kotlin": 156836}
package org.suggs.adventofcode import org.slf4j.LoggerFactory object Day04Scratchcards { private val log = LoggerFactory.getLogger(this::class.java) fun addTotalWinningCardsFrom(smallData: List<String>) = calculateNumberOfWinningCardsFrom(smallData.mapIndexed { i, str -> Wins(i, intersectCountFrom(st...
0
Kotlin
0
0
9485010cc0ca6e9dff447006d3414cf1709e279e
1,631
advent-of-code
Apache License 2.0
src/Day02.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
fun main() { val rockPaperScissor = arrayOf( intArrayOf(4, 8, 3), intArrayOf(1, 5, 9), intArrayOf(7, 2, 6) ) val opponentCodex = arrayOf("A", "B", "C") val yourCodex = arrayOf("X", "Y", "Z") fun part1(input: List<String>): Int { var score = 0 for (line in inp...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
927
Advent-Of-Code-2022
Apache License 2.0
day08/kotlin/RJPlog/day2308_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File import kotlin.math.* fun wasteland(in1: Int): Int { var lines = File("day2308_puzzle_input.txt").readLines() var network = mutableMapOf<String, Pair<String, String>>() var instructions = lines[0] for (i in 2..lines.size - 1) { network.put( lines[i].substringBefore(" ="), Pair(lines[i].s...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
3,071
aoc-2023
MIT License
src/day05/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 5: Supply Stacks * https://adventofcode.com/2022/day/5 */ package day05 import java.io.File fun main() { val fileName = // "day05_sample.txt" "day05_input.txt" val (view, stackLabelOrder, rearrangeOps) = readInput(fileName) // Part 1: rearrange crates by CrateMover 900...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
3,774
aoc2022-kotlin
Apache License 2.0
src/test/kotlin/io/noobymatze/aoc/y2022/Day18.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2022 import io.noobymatze.aoc.Aoc import io.noobymatze.aoc.Aoc.symmetricDifference import kotlin.test.Test class Day18 { data class Pos(val x: Int, val y: Int, val z: Int) { val sides get(): Set<Set<Pos>> { val front = setOf( this, Po...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
2,144
aoc
MIT License
leetcode/src/offer/middle/Offer07.kt
zhangweizhe
387,808,774
false
null
package offer.middle import linkedlist.TreeNode fun main() { // 剑指 Offer 07. 重建二叉树 // https://leetcode.cn/problems/zhong-jian-er-cha-shu-lcof/ val root = buildTree(intArrayOf(3,9,20,15,7), intArrayOf(9,3,15,20,7)) println(root?.`val`) } fun buildTree(preorder: IntArray, inorder: IntArray): TreeNode? ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,211
kotlin-study
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions8.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import com.qiaoyuang.algorithm.round0.BinaryTreeNodeWithFather fun test8() { val a = BinaryTreeNodeWithFather('a') val b = BinaryTreeNodeWithFather('b', a) val c = BinaryTreeNodeWithFather('c', a) val d = BinaryTreeNodeWithFather('d', b) val e = BinaryTreeNod...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,088
Algorithm
Apache License 2.0
src/test/kotlin/com/igorwojda/integer/factorial/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.integer.factorial // iterative solution private object Solution1 { private fun factorial(n: Int): Int { var total = 1 (1..n).forEach { total *= it } return total } } // another iterative solution private object Solution2 { private fun fac...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
924
kotlin-coding-challenges
MIT License
src/main/kotlin/Day07.kt
gtruitt
574,758,122
false
{"Kotlin": 16663}
@file:Suppress("PackageDirectoryMismatch") package day07 import head import tail const val TOKEN_SEP = " " const val PROMPT = "$" const val CD = "cd" const val PATH_SEP = "/" const val PREV_DIR = ".." val filePattern = Regex("""\d+""") val String.tokens get() = split(TOKEN_SEP) val String.isCd get() = tokens.compon...
0
Kotlin
0
2
1c9940faaf7508db275942feeb38d3e57aef413f
2,164
aoc-2022-kotlin
MIT License
src/day09/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 9: Rope Bridge * https://adventofcode.com/2022/day/9 */ package day09 import utils.accumulate import java.io.File fun main() { val fileName = // "day09_sample_a.txt" // "day09_sample_b.txt" "day09_input.txt" val moveInstructions = readInput(fileName) // Part 1: ...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
1,406
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/DumboOctopus_11.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
fun getEnergyLevels(): Array<IntArray> { val lists: List<List<Int>> = readFile("DumboOctopus").split("\n").map { it.map { c -> c.digitToInt() } } return Array(lists.size) { i -> IntArray(lists[i].size) { j -> lists[i][j] } } } fun countFlashes(): Int { val energyLevels = getEnergyLevels() var totalFlas...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
1,928
advent-of-code-2021
Apache License 2.0
src/main/kotlin/day13/Solution.kt
TestaDiRapa
573,066,811
false
{"Kotlin": 50405}
package day13 import java.io.File abstract class Node : Comparable<Node> class IntNode( val value: Int ): Node() { override fun compareTo(other: Node): Int = if (other is IntNode) this.value.compareTo(other.value) else ListNode(listOf(this)).compareTo(other) } class ListNode( val childre...
0
Kotlin
0
0
b5b7ebff71cf55fcc26192628738862b6918c879
4,586
advent-of-code-2022
MIT License
numbers/src/main/kotlin/mathtools/numbers/factors/CompareFactors.kt
RishiKumarRay
467,793,819
true
{"Kotlin": 182604, "Java": 53276}
package mathtools.numbers.factors /** Functions for comparing factors of numbers * @author DK96-OS : 2022 */ object CompareFactors { /** Find the Greatest Common Divisor of two integers. * @param n1 One of the integers to check * @param n2 One of the integers to check * @return The Greatest Common Divisor, or...
0
Kotlin
0
0
a7c4887a2ac37756b5a1c71265b6c006cf22ccb9
1,474
MathTools
Apache License 2.0
src/main/kotlin/day17/Day17.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day17 import day17.JetDirection.LEFT import day17.JetDirection.RIGHT import groupByBlanks import runDay import utils.RepeatingIterator fun main() { fun List<String>.simulate(num: Long) = map { it.map(JetDirection::fromChar) }.map(::RepeatingIterator) .first() ...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
5,203
advent-of-code-2022
Apache License 2.0
2021/04/main.kt
chylex
433,239,393
false
null
import java.io.File const val SIZE = 5 fun main() { val lineIterator = File("input.txt").readLines().iterator() val numbersToDraw = lineIterator.next().split(',').map(String::toInt).toList() val boards = mutableListOf<Board>() while (lineIterator.hasNext()) { require(lineIterator.next().isEmpty()) if (!l...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
2,246
Advent-of-Code
The Unlicense
src/main/kotlin/g0301_0400/s0310_minimum_height_trees/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0310_minimum_height_trees // #Medium #Depth_First_Search #Breadth_First_Search #Graph #Topological_Sort // #2022_11_09_Time_521_ms_(97.56%)_Space_64_MB_(90.24%) class Solution { fun findMinHeightTrees(n: Int, edges: Array<IntArray>): List<Int> { if (n == 1) return mutableListOf(0) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,488
LeetCode-in-Kotlin
MIT License
advent-of-code-2023/src/main/kotlin/Day05.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
// Day 05: If You Give A Seed A Fertilizer // https://adventofcode.com/2023/day/5 import java.io.File fun main() { val lines = File("src/main/resources/Day05.txt").readLines() val seeds = lines.first().substringAfter("seeds: ").split(" ").map { it.toLong() } var index = 3 val seedToSoilL...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,098
advent-of-code
Apache License 2.0
src/day06/Day06.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day06 import println import readInputAsText fun main() { fun parse(input: String) = input.split(",").groupingBy { it.toInt() }.eachCount().mapValues { it.value.toLong() } fun simulate(initial: Map<Int, Long>, days: Int): Map<Int, Long> { val fish = initial.toMutableMap() repeat(days)...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
970
advent-of-code-2021
Apache License 2.0
src/main/algorithms/searching/BinarySearchRecursive.kt
vamsitallapudi
119,534,182
false
{"Java": 24691, "Kotlin": 20452}
package main.algorithms.searching fun main(args: Array<String>) { val input = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray() // to read an array (from user input) val eleToSearch = readLine()!!.trim().toInt() // to read the element to be searched (from user input) val pos = binar...
0
Java
1
1
9349fa7488fcabcb9c58ce5852d97996a9c4efd3
1,229
HackerEarth
Apache License 2.0
src/main/kotlin/days/Day11.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2021/day/11", date = Date(day = 11, year = 2021) ) class Day11(val input: List<String>) : Puzzle { private var dumbos = parseInput(input) override fun partOne() = flashCount(100) override fun partTwo():...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
1,961
advent-of-code-2021
Creative Commons Zero v1.0 Universal
atcoder/arc158/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package atcoder.arc158 fun main() { readLn() val top = readInts() val bottom = readInts() val inf = Long.MAX_VALUE / 4 fun solve(from: Int, to: Int): Modular { if (from + 1 == to) { return (top[from] + bottom[from]).toModular() * 3.toModularUnsafe() } val mid = (from + to) / 2 var result = solve(from, ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
4,040
competitions
The Unlicense
src/Day01.kt
BenD10
572,786,132
false
{"Kotlin": 6791}
import java.lang.Integer.max fun main() { fun part1(input: List<String>): Int { var currentMax = 0 var accumulator = 0 input.forEach { if (it.isEmpty()) { // Reached the end of this elf currentMax = max(currentMax, accumulator) ac...
0
Kotlin
0
0
e26cd35ef64fcedc4c6e40b97a63d7c1332bb61f
1,161
advent-of-code
Apache License 2.0
day5/src/main/kotlin/com/lillicoder/adventofcode2023/day5/Day5.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day5 import kotlin.math.min fun main() { val day5 = Day5() val almanac = AlmanacParser().parseFile("input.txt") println("The lowest location number for all input single seed numbers is ${day5.part1(almanac)}.") println("The lowest location number for all input s...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
6,992
advent-of-code-2023
Apache License 2.0
classroom/src/main/kotlin/com/radix2/algorithms/extras/MinAvg.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.extras import java.util.* fun minimumAverage(orders: Sequence<Order>): Long { val arrivalTimes = PriorityQueue<Order> { o1, o2 -> o1.arrivalTime.compareTo(o2.arrivalTime) } val burstTimes = PriorityQueue<Order> { o1, o2 -> o1.burstTime.compareTo(o2.burstTime) } for (order in...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,798
coursera-algorithms-part1
Apache License 2.0
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day17.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day import kotlin.math.max class Day17 : Day("23005", "2040") { private data class TargetArea(val horizontalRange: IntRange, val verticalRange: IntRange) { fun contains(x: Int, y: Int): Boolean { return x in horizontalRange && y in verticalRange } ...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
1,895
advent-of-code-2021
MIT License
dcp_kotlin/src/main/kotlin/dcp/day201/day201.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day201 // day201.kt // By <NAME> import kotlin.math.max // The problem is really represented by an upper triangle of a matrix. fun maximumWeightPath(lists: List<MutableList<Int>>): Int { val errorMessage: (Int) -> String = { "row $it must have length ${it + 1}" } if (lists.isEmpty()) retu...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,398
daily-coding-problem
MIT License
src/main/java/me/olegthelilfix/leetcoding/old/FindMedianSortedArrays.kt
olegthelilfix
300,408,727
false
null
package me.olegthelilfix.leetcoding.old /** * Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. * The overall run time complexity should be O(log (m+n)). */ class FindMedianSortedArrays { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray)...
0
Kotlin
0
0
bf17d2f6915b7a491d93f57f8e7461adda7029c0
1,266
MyKata
MIT License
src/main/kotlin/g2201_2300/s2234_maximum_total_beauty_of_the_gardens/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2234_maximum_total_beauty_of_the_gardens // #Hard #Array #Sorting #Greedy #Binary_Search #Two_Pointers // #2023_06_27_Time_699_ms_(100.00%)_Space_50.9_MB_(100.00%) class Solution { fun maximumBeauty(flowers: IntArray, newFlowers: Long, target: Int, full: Int, partial: Int): Long { val ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,464
LeetCode-in-Kotlin
MIT License
src/day08/Day08Util.kt
Longtainbin
573,466,419
false
{"Kotlin": 22711}
package day08 import kotlin.math.max fun upLookMatrix(matrix: Array<IntArray>): Array<IntArray> { val row = matrix.size val col = matrix.first().size val result = Array(row) { IntArray(col) } for (j in 0 until col) { result[0][j] = matrix[0][j] var h = result[0][j] for (i in 1 ...
0
Kotlin
0
0
48ef88b2e131ba2a5b17ab80a0bf6a641e46891b
2,003
advent-of-code-2022
Apache License 2.0
src/day11.kt
skuhtic
572,645,300
false
{"Kotlin": 36109}
fun main() { day11.execute(onlyTests = false, forceBothParts = true) } val day11 = object : Day<Long>(11, 10605, 2713310158) { override val testInput: InputData get() = TEST_INPUT.trimIndent().lines() override fun part1(input: InputData): Long { // divisibleBys: [23, 19, 13, 17] val monkey...
0
Kotlin
0
0
8de2933df90259cf53c9cb190624d1fb18566868
4,099
aoc-2022
Apache License 2.0
solutions/aockt/y2015/Y2015D20.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import io.github.jadarma.aockt.core.Solution object Y2015D20 : Solution { /** * Finds the first house to get enough presents from the infinite elves. * * @param target The minimum amount of gifts per house. * @param giftsPerVisit How many gifts each elf visit adds to the h...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
1,519
advent-of-code-kotlin-solutions
The Unlicense
gcj/y2020/qual/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.qual private fun solve(initials: String = "CJ", impossible: String = "IMPOSSIBLE"): String { data class Activity(val start: Int, val end: Int, val id: Int) val activities = List(readInt()) { val (start, end) = readInts(); Activity(start, end, it) } val ans = IntArray(activities.size) val free = I...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
831
competitions
The Unlicense
src/main/kotlin/com/marcdenning/adventofcode/day05/Day05a.kt
marcdenning
317,730,735
false
{"Kotlin": 87536}
package com.marcdenning.adventofcode.day05 import java.io.File import java.util.* import java.util.regex.MatchResult import java.util.stream.Stream private const val NUMBER_OF_ROWS = 128 private const val NUMBER_OF_COLUMNS = 8 fun main(args: Array<String>) { Scanner(File(args[0])).use { scanner -> val ma...
0
Kotlin
0
0
b227acb3876726e5eed3dcdbf6c73475cc86cbc1
1,755
advent-of-code-2020
MIT License
aoc-2017/src/main/kotlin/nl/jstege/adventofcode/aoc2017/days/Day07.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2017.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.extractValues /** * * @author <NAME> */ class Day07 : Day(title = "Recursive Circus") { private companion object Configuration { private const val INPUT_...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
2,539
AdventOfCode
MIT License
src/main/kotlin/util/Evaluator.kt
WarriorsSami
430,104,951
false
{"Kotlin": 10902, "Assembly": 20}
package util import model.LogicConfiguration import java.util.* enum class StatementType(s: String) { VALID("valid"), SATISFIABLE("satisfiable"), CONTINGENT("contingent"), INVALID("invalid"), } // evaluate operation fun evaluate(operator: TokenType, operand1: Boolean, operand2: Boolean): Boolean { ...
0
Kotlin
0
1
cf23e6f52f4074f13549c745f50aa1d9fd639911
3,498
LogicParser
Apache License 2.0
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day19/Aplenty.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day19 import java.util.* class Aplenty(private var filename: String) { private val ICON_ACCEPT = "A" private val ICON_REJECT = "R" private val ICON_START = "in" private val ICON_LESS_THAN = '<' private val ELEMENT_DELIMITER = ',' private val RULE_START_DELIMITER...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
4,041
advent-of-code
Apache License 2.0
src/main/kotlin/aoc2023/Day01.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay import util.illegalInput // https://adventofcode.com/2023/day/1 object Day01 : AoCDay<Int>( title = "Trebuchet?!", part1ExampleAnswer = 142 + (11 + 11 + 22 + 33 + 42 + 24 + 77), part1Answer = 54597, part2ExampleAnswer = 142 + 281, part2Answer = 54504, ) { private ...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
1,442
advent-of-code-kotlin
MIT License
Problems/Algorithms/1926. Nearest Exit from Entrance in Maze/NearestExit.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun nearestExit(maze: Array<CharArray>, entrance: IntArray): Int { val n = maze.size val m = maze[0].size val neighbors = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0)) val visited = Array(n) { BooleanArray(m) { false } } ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,292
leet-code
MIT License
src/2023/Day08.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.lang.RuntimeException import java.math.BigInteger import java.util.* fun main() { Day08().solve() } class Day08 { val input1 = """ RL AAA = (BBB, CCC) BBB = (DDD, EEE) CCC = (ZZZ, GGG) DDD = (DDD, DDD) EEE = (E...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
4,142
advent-of-code
Apache License 2.0
src/main/kotlin/algorithms/sorting/radix_sort/RadixSort.kt
AANikolaev
273,465,105
false
{"Java": 179737, "Kotlin": 13961}
package algorithms.sorting.radix_sort import algorithms.sorting.InplaceSort import kotlin.math.log10 class RadixSort : InplaceSort { override fun sort(values: IntArray) { radixSort(values) } fun getMax(array: IntArray): Int { var max = array[0] for (i in array.indices) { ...
0
Java
0
0
f9f0a14a5c450bd9efb712b28c95df9a0d7d589b
1,656
Algorithms
MIT License
src/Day19.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
import java.util.* import kotlin.math.ceil import kotlin.math.max private class Factory(val blueprint: Blueprint, val minutes: Int) { fun findBest(): Int { var currentBest = 0 val queue = PriorityQueue<Day19State>().apply { add(Day19State(minutes = minutes)) } while (queue.isNotEmpty()) { ...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
4,892
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountNumberOfTeams.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,791
kotlab
Apache License 2.0
kotlin/0721-accounts-merge.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
class DSU(val n: Int) { val parent = IntArray(n) {it} val rank = IntArray(n) {1} fun find(x: Int): Int { if (x != parent[x]) parent[x] = find(parent[x]) return parent[x] } fun union(x: Int, y: Int): Boolean { val pX = find(x) val pY = find(y) i...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,527
leetcode
MIT License
LeetCode2020April/week1/src/test/kotlin/net/twisterrob/challenges/leetcode2020april/week1/happy_number/SquaredSumTest.kt
TWiStErRob
136,539,340
false
{"Kotlin": 104880, "Java": 11319}
package net.twisterrob.challenges.leetcode2020april.week1.happy_number import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DynamicTest.dynamicTest import org.junit.jupiter.api.TestFactory class SquaredSumTest { private fun squaredSumTest(input: Int, expected: Int) = dynamicTest("$inp...
1
Kotlin
1
2
5cf062322ddecd72d29f7682c3a104d687bd5cfc
2,357
TWiStErRob
The Unlicense
2022/main/day_13/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_13_2022 import java.io.File @Suppress("NAME_SHADOWING") internal class Packet(packet: String) : Comparable<Packet?> { private var children: MutableList<Packet> var value = 0 private var integer = true var str: String init { var packet = packet str = packet chil...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
2,696
AdventofCode
MIT License
src/main/kotlin/g1801_1900/s1896_minimum_cost_to_change_the_final_value_of_expression/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1896_minimum_cost_to_change_the_final_value_of_expression // #Hard #String #Dynamic_Programming #Math #Stack // #2023_06_22_Time_252_ms_(100.00%)_Space_41.3_MB_(100.00%) class Solution { private class Result(var `val`: Int, var minFlips: Int) private var cur = 0 fun minOperationsToFl...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,056
LeetCode-in-Kotlin
MIT License
2020/day11/day11.kt
flwyd
426,866,266
false
{"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398}
/* * Copyright 2021 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. */ package day11 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input: g...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
4,568
adventofcode
MIT License
src/main/kotlin/com/leetcode/monthly_challenges/2021/april/palindrome_linked_list/Main.kt
frikit
254,842,734
false
null
package com.leetcode.monthly_challenges.`2021`.april.palindrome_linked_list fun main() { println("Test case 1:") val li = ListNode(1, ListNode(2, ListNode(3, ListNode(4, ListNode(5, null))))) println("" + Solution().isPalindrome(li) + "==" + false) println() println("Test case 2:") val li2 = Li...
0
Kotlin
0
0
dda68313ba468163386239ab07f4d993f80783c7
1,607
leet-code-problems
Apache License 2.0
Kotlin/src/main/kotlin/org/algorithm/problems/0190_minimize_maximum_pair_sum.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
package org.algorithm.problems // Problem Statement // The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs. // For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8. // Given an array nums o...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
924
algorithms
MIT License
Kotlin/problems/0046_odd_even_jump.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
// Problem Statement // You are given an integer array A. From some starting index, you can make a // series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd // numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered jumps. // // You may from index i jump forwar...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
3,666
algorithms
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/StrongPasswordChecker.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,176
kotlab
Apache License 2.0
src/Year2022Day07.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
internal class FileSystem { val root = Directory("/", null) val allDirectories = mutableListOf<Directory>(root) var currentDir = root fun cd(name: String) { currentDir = when (name) { "/" -> root ".." -> currentDir.parent ?: throw IllegalArgumentException() e...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
2,825
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/RestoreIPAddresses.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,624
kotlab
Apache License 2.0
src/main/kotlin/com/litekite/essentials/problems/matrix/DiagonalDiff.kt
svignesh93
400,829,980
false
{"Java": 92174, "Kotlin": 41550}
/* * Copyright 2022 LiteKite Startup. All rights reserved. * * 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 ap...
0
Java
0
2
f8cf1d13b420c1d8ffbdfadd76fb11796298dbbf
1,871
Essentials
Apache License 2.0
Next_highest_int_from_digits/Kotlin/src/NextHighestIntFromDigits.kt
ncoe
108,064,933
false
{"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409}
import java.math.BigInteger import java.text.NumberFormat fun main() { for (s in arrayOf( "0", "9", "12", "21", "12453", "738440", "45072010", "95322020", "9589776899767587796600", "3345333" )) { println("${format(s)} -> ${...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
3,409
rosetta
MIT License
src/main/kotlin/adventofcode/year2022/Day10CathodeRayTube.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2022 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day10CathodeRayTube(customInput: PuzzleInput? = null) : Puzzle(customInput) { override val name = "<NAME>" private val instructionCycles by lazy { input.toInstructionCycles() } override fun partOne() = instruc...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,728
AdventOfCode
MIT License
aoc2022/day20.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval import kotlin.math.abs fun main() { Day20.execute() } object Day20 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<FileNumber>): Long { ...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
1,971
Advent-Of-Code
MIT License
src/Day04.kt
Hwajun1323
574,962,608
false
{"Kotlin": 6799}
fun main() { fun convertToSection(Elf: String): IntRange { val (start, end) = Elf.split("-") return start.toInt()..end.toInt() } fun checkContain(firstSection: IntRange, secondSection: IntRange): Boolean{ return (firstSection.first >= secondSection.first && firstSection.last <= sec...
0
Kotlin
0
0
667a8c7a0220bc10ddfc86b74e3e6de44b73d5dd
964
advent-of-code-2022
Apache License 2.0
aoc/src/Calibration.kt
aragos
726,211,893
false
{"Kotlin": 16232}
import java.io.File fun main() { println(Calibration.readCalibrationDigitsAndWords("aoc/inputs/calibration.txt").sum()) } object Calibration { fun readCalibrationDigits(): List<Int> = buildList { File("aoc/inputs/calibration.txt").forEachLine { line -> val allDigits = Regex("[1-9]").findAll(line).map { ...
0
Kotlin
0
0
7bca0a857ea42d89435adc658c0ff55207ca374a
1,195
aoc2023
Apache License 2.0
src/Day01.kt
Akaneiro
572,883,913
false
null
fun main() { fun getElvesCalSums(input: List<String>): List<Int> = mutableListOf<Int>().apply { var currentCalSum = 0 input.forEachIndexed { index, element -> when { element.isBlank() -> { this.add(currentCalSum) ...
0
Kotlin
0
0
f987830a70a2a1d9b88696271ef668ba2445331f
1,102
aoc-2022
Apache License 2.0
src/day09/Day09.kt
zypus
573,178,215
false
{"Kotlin": 33417, "Shell": 3190}
package day09 import AoCTask import kotlin.math.abs import kotlin.math.sign // https://adventofcode.com/2022/day/9 data class Direction(val x: Int, val y: Int) { companion object { fun fromString(string: String): Direction { val (dir, dist) = string.split(" ") val intDist = dist.t...
0
Kotlin
0
0
f37ed8e9ff028e736e4c205aef5ddace4dc73bfc
6,110
aoc-2022
Apache License 2.0
src/main/kotlin/days/aoc2023/Day22.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2023 import days.Day import kotlin.math.min import util.Point3d import util.toward class Day22 : Day(2023, 22) { override fun partOne(): Any { return calculatePartOne(inputList) } override fun partTwo(): Any { return calculatePartTwo(inputList) } class Brick(priva...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,689
Advent-Of-Code
Creative Commons Zero v1.0 Universal
core/algorithm/src/main/java/com/memorati/algorithm/Algorithm.kt
HeidelX
640,943,698
false
{"Kotlin": 321291, "Ruby": 1925}
package com.memorati.algorithm import com.memorati.core.model.AdditionalInfo import com.memorati.core.model.Flashcard import kotlinx.datetime.Clock import kotlin.math.ln import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.minutes fun Flashcard.review( answerCorrect: Boolean, wordC...
1
Kotlin
0
0
e848ec96866f16c283c6be1e871c2e9e0c47bd98
3,439
Memorati
MIT License
src/main/kotlin/recur/FindInKArr.kt
yx-z
106,589,674
false
null
package recur import util.INF import util.OneArray import util.oneArrayOf // given k SORTED arrays A1, A2,... Ak, w/ a total of n distinct numbers // and another number x, find the smallest number y : y > x in these arrays fun OneArray<OneArray<Int>>.find(x: Int): Int { val A = this val k = size val n = map { siz...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,417
AlgoKt
MIT License
Kotlin/days/src/day4.kt
dukemarty
224,307,841
false
null
const val puzzleInputDay4 = "273025-767253" data class PasswordRange(val range: String) { val lowerBound: Int val upperBound: Int init { val parts = range.split("-") lowerBound = parts[0].toInt() upperBound = parts[1].toInt() } } fun main(args: Array<String>) { println("-...
0
Kotlin
0
0
6af89b0440cc1d0cc3f07d5a62559aeb68e4511a
1,787
dukesaoc2019
MIT License
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day25/Day25.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * 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 wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,534
AdventOfCode
Apache License 2.0
solutions/src/solutions/y21/day 16.kt
Kroppeb
225,582,260
false
null
@file:Suppress("PackageDirectoryMismatch", "UnusedImport") package solutions.y21.d16 /* import grid.Clock import helpers.* import itertools.* import kotlin.math.* */ import grid.Clock import helpers.getLines val xxxxx = Clock(6, 3); /* */ data class Parsed<T>(val t: T, val remaining: List<Int>) { fun <R> ma...
0
Kotlin
0
1
744b02b4acd5c6799654be998a98c9baeaa25a79
3,844
AdventOfCodeSolutions
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MissingRanges.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,761
kotlab
Apache License 2.0
src/Day09_part1.kt
jmorozov
573,077,620
false
{"Kotlin": 31919}
import kotlin.math.absoluteValue fun main() { val inputData = readInput("Day09") part1(inputData) } private fun part1(inputData: List<String>) { val visitedByTail = mutableSetOf<Point>() val startPoint = Point.start() visitedByTail.add(startPoint) var state = RopeState( head ...
0
Kotlin
0
0
480a98838949dbc7b5b7e84acf24f30db644f7b7
3,616
aoc-2022-in-kotlin
Apache License 2.0
src/Day17.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File import kotlin.math.max // Advent of Code 2022, Day 17, Pyroclastic Flow interface Rock { val rows: List<String> // 4 strings, 4 char long val height: Int val width: Int } class Rock1 : Rock { // maybe reverse list? override val rows = listOf("....", "....", "....", "####").reve...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
9,281
AdventOfCode2022
Apache License 2.0
src/Day11.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
import kotlin.math.floor private val MONKEY_REGEX = "Monkey\\s+(?<monkeyNumber>\\d+):".toRegex() private val STARTING_ITEMS_REGEX = "\\s+Starting\\s+items:\\s+(?<items>\\d+(,\\s+\\d+)*)".toRegex() private val OPERATION_REGEX = "\\s+Operation:\\s+new\\s+=\\s+old\\s+(?<operation>[+*])\\s+(?<value>(\\d+|old))".toRegex() ...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
4,931
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinStepsAnagram.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <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,678
kotlab
Apache License 2.0
src/main/kotlin/day1/Day1_2.kt
remhiit
727,182,240
false
{"Kotlin": 12212}
package day1 import Main fun main() { val inputD1 = Main::class.java.getResource("day1.txt")?.readText() var nb = 0 val calc = inputD1?.split("\r\n") ?.filter { it.isNotBlank() } ?.map { findFirstDigit(it).plus(findLastDigit(it)).toInt() } ?.reduce { acc, i -> acc + i } println...
0
Kotlin
0
0
122ee235df1af8e3d0ea193b9a37162271bad7cb
1,127
aoc2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-11.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 import com.github.ferinagy.adventOfCode.searchGraph import com.github.ferinagy.adventOfCode.singleStep import com.github.ferinagy.adventOfCode.subSets import java.util.* import kotlin.system.measureTimeMillis fun main() { println("Part1:") val time1 = measureTi...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
5,140
advent-of-code
MIT License
aoc2023/day6.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day6.execute() } private object Day6 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: List<Race>): Long = input .map { ra...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
1,210
Advent-Of-Code
MIT License
src/main/kotlin/com/kingchampion36/dsa/arrays/KthSmallestAndLargestElement.kt
KingChampion36
666,647,634
false
null
package com.kingchampion36.dsa.arrays import java.util.PriorityQueue /** * Sort the list and find kth smallest element * Time complexity - O(n * log(n)) */ fun List<Int>.kthSmallestElementBySorting(k: Int) = when { isEmpty() -> throw IllegalArgumentException("List should not be empty") k <= 0 || k >= size -> t...
0
Kotlin
0
0
a276937ca52cb9d55e4e92664478ad4a69e491a7
1,780
data-structures-and-algorithms
MIT License