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
2015/Day01/src/main/kotlin/Main.kt
mcrispim
658,165,735
false
null
import java.io.File fun main() { fun part1(input: List<String>): Int { val directions = input[0].groupingBy { it }.eachCount() val ups = directions['('] ?: 0 val downs = directions[')'] ?: 0 return ups - downs } fun part2(input: List<String>): Int { var floor = 0 ...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
1,090
AdventOfCode
MIT License
src/Day09.kt
wbars
576,906,839
false
{"Kotlin": 32565}
import kotlin.math.abs fun main() { fun newPos(x: Int, y: Int, tx: Int, ty: Int): Pair<Int, Int> { var tx1 = tx var ty1 = ty if (x > tx1 && abs(x - tx1) > 1) { tx1++ if (y > ty1) ty1++ else if (y < ty1) ty1-- } else if (tx1 > x && abs(tx1 - x) > 1) { ...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
2,834
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/com/kondenko/pocketwaka/domain/summary/model/Project.kt
Kondenko
95,912,101
false
null
package com.kondenko.pocketwaka.domain.summary.model import com.kondenko.pocketwaka.utils.WakaLog data class Project( val name: String, val totalSeconds: Long, val isRepoConnected: Boolean = true, val branches: Map<String, Branch>, val repositoryUrl: String ) interface ProjectInternalL...
2
Kotlin
7
58
6f1423415e2a23f12626ac67c9afb25f2df9e302
2,399
pocketwaka
MIT License
src/Day05.kt
MerickBao
572,842,983
false
{"Kotlin": 28200}
import java.util.LinkedList fun main() { val supply = arrayOf("", "BWN", "LZSPTDMB", "QHZWR", "WDVJZR", "SHMB", "LGNJHVPB", "JQZFHDLS", "WSFJGQB", "ZWMSCDJ") fun part1(input: List<String>): String { val stacks = Array(10) {LinkedList<Char>()} for (i in supply.indices) { for (j in ...
0
Kotlin
0
0
70a4a52aa5164f541a8dd544c2e3231436410f4b
1,882
aoc-2022-in-kotlin
Apache License 2.0
year2022/src/cz/veleto/aoc/year2022/Day22.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.plus import cz.veleto.aoc.core.rotateBy import kotlin.math.roundToInt import kotlin.math.sqrt class Day22(config: Config) : AocDay(config) { override fun part1(): String { val (tiles, w...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
9,335
advent-of-pavel
Apache License 2.0
src/main/kotlin/com/colinodell/advent2016/Day20.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day20(val input: List<String>) { private val firewallRules = optimize( input .map { it.split("-") } .map { LongRange(it[0].toLong(), it[1].toLong()) } .sortedBy { it.first } ) fun solvePart1() = firewallRules.first().last....
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
1,106
advent-2016
Apache License 2.0
src/main/kotlin/g1801_1900/s1830_minimum_number_of_operations_to_make_string_sorted/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1830_minimum_number_of_operations_to_make_string_sorted // #Hard #String #Math #Combinatorics #2023_06_21_Time_226_ms_(100.00%)_Space_36.3_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun makeStringSorted(s: String): Int { val n = s.length val count = IntArray(26) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,636
LeetCode-in-Kotlin
MIT License
src/jvmMain/kotlin/ai/hypergraph/kaliningraph/sat/Debugging.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.sat import ai.hypergraph.kaliningraph.graphs.LabeledGraph import ai.hypergraph.kaliningraph.image.toHtmlPage import ai.hypergraph.kaliningraph.parsing.* import ai.hypergraph.kaliningraph.tensor.FreeMatrix import ai.hypergraph.kaliningraph.visualization.html import org.logicng.formula...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
2,827
galoisenne
Apache License 2.0
Course_Schedule_II_v2.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import java.util.* import kotlin.collections.ArrayList // Given the total number of courses and a list of prerequisite pairs, // return the ordering of courses you should take to finish all courses. class Solution { fun findOrder(numCourses: Int, prerequisites: Array<IntArray>): IntArray { val res = Array...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,736
leetcode
MIT License
kotlin/src/katas/kotlin/leetcode/sort_colors/SortColors.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.sort_colors import datsok.shouldEqual import nonstdlib.permutationsSequence import nonstdlib.printed import org.junit.jupiter.api.Test /** * https://leetcode.com/problems/sort-colors */ class SortColors { @Test fun `it works`() { listOf(0, 1, 2).permutationsSequence().forEa...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,183
katas
The Unlicense
src/Day01.kt
kuangbin
575,873,763
false
{"Kotlin": 8252}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var ans = 0 var tmp = 0 for (ss in input) { if (ss.isEmpty()) { ans = max(ans, tmp) tmp = 0 continue } tmp += ss.toInt() } ...
0
Kotlin
0
0
ea0d89065b4d3cb4f6f78f768882d5b5473624d1
1,029
advent-of-code-2022
Apache License 2.0
logic/src/main/java/lt/markmerkk/durak/Card.kt
marius-m
733,676,467
false
{"Kotlin": 167943}
package lt.markmerkk.durak import kotlin.random.Random data class Card( val suite: CardSuite, val rank: CardRank, val isTrump: Boolean = false ): Comparable<Card> { override fun compareTo(other: Card): Int { if (weight() > other.weight()) { return 1 } i...
0
Kotlin
0
0
8f2346cfcbb3c0871fb0db2768fd33d9b2fe277a
3,841
stupid2
Apache License 2.0
src/Day08.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import kotlin.math.max fun main() { fun initGrid(input: List<String>): Array<IntArray> { val result = Array(input.size) { IntArray(input[0].length) } for (i in input.indices) { for (j in input[i].indices) { result[i][j] = input[i][j].digitToInt() } } ...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
3,148
Advent-Of-Code-2022
Apache License 2.0
src/Day11.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import java.util.* class Monkey( items: List<Long>, private val op: (Long) -> Long, private val divisor: Long, private val monkeyTrue: Int, private val monkeyFalse: Int ) { companion object { fun round(monkeys: List<Monkey>, easyMode: Boolean) { monkeys.forEach { ...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
2,545
aoc2022-kotlin
Apache License 2.0
Matrix/Matrix.kt
xfl03
154,698,285
false
null
/** * 邻接矩阵 * 1 2 0 0 * 0 0 1 0 * 1 0 0 1 * 0 0 1 0 */ val matrix = arrayOf( "1200", "0010", "1001", "0010" ) /** * 矩阵乘法 */ fun multiply(a: Array<IntArray>, b: Array<IntArray>): Array<IntArray> { val arr = Array(a.size) { IntArray(b[0].size) } for (i in a.indices) { ...
0
Kotlin
0
0
281042e307c349d95a4ec4c49aee40b4ab9fa4b0
2,162
DiscreteCourseWork
MIT License
src/Day02.kt
SpencerDamon
573,244,838
false
{"Kotlin": 6482}
fun main() { fun part1(input: List<String>): Int { var myTotalScore = 0 for (i in input) { val (otherPlayer, myPlay) = i.split(" ") when (otherPlayer) { "A" -> if (myPlay == "X") { myTotalScore += 4 // 1 for rock, 3 for draw ...
0
Kotlin
0
0
659a9e9ae4687bd633bddfb924416c80a8a2db2e
2,618
aoc-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/adventofcode2017/potasz/P10KnotHash.kt
potasz
113,064,245
false
null
package adventofcode2017.potasz object P10KnotHash { val SUFFIX = listOf(17, 31, 73, 47, 23) val sampleLengths = arrayListOf(3, 4, 1, 5) val inputLengths = arrayListOf(165,1,255,31,87,52,24,113,0,91,148,254,158,2,73,153) val inputString = "165,1,255,31,87,52,24,113,0,91,148,254,158,2,73,153" priv...
0
Kotlin
0
1
f787d9deb1f313febff158a38466ee7ddcea10ab
1,773
adventofcode2017
Apache License 2.0
src/main/kotlin/leetcode/problem0040/CombinationSumSecond.kt
ayukatawago
456,312,186
false
{"Kotlin": 266300, "Python": 1842}
package leetcode.problem0040 class CombinationSumSecond { fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> { if (candidates.all { it > target }) { return emptyList() } val countMap = hashMapOf<Int, Int>() candidates.forEach { countMap[...
0
Kotlin
0
0
f9602f2560a6c9102728ccbc5c1ff8fa421341b8
1,242
leetcode-kotlin
MIT License
leetcode/kotlin/basic-calculator-ii.kt
PaiZuZe
629,690,446
false
null
class Solution { fun calculate(s: String): Int { val rpn = toReversePolishNotation(toList(s)) val stack = ArrayDeque<Int>() for (x in rpn) { if (x in "+-*/") { val operand2 = stack.removeLast() val operand1 = stack.removeLast() val ...
0
Kotlin
0
0
175a5cd88959a34bcb4703d8dfe4d895e37463f0
2,968
interprep
MIT License
tegral-niwen/tegral-niwen-lexer/src/main/kotlin/guru/zoroark/tegral/niwen/lexer/matchers/RepeatedRecognizer.kt
utybo
491,247,680
false
{"Kotlin": 1071223, "Nix": 2449}
/* * 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 writing, software * distribut...
21
Kotlin
3
33
eb71e752b91cac01f24ad12563c3f25d6a8f8630
3,084
Tegral
Apache License 2.0
src/main/kotlin/adventofcode2019/Day06UniversalOrbitMap.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2019 class Day06UniversalOrbitMap data class OrbitObject(val code: String) data class Orbit(val center: OrbitObject, val satelite: OrbitObject) class SpaceOrbit(val orbitMap: List<String>) { val orbits: List<Orbit> init { orbits = orbitMap.map { val (center, satelite...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
1,752
kotlin-coding-challenges
MIT License
src/day01/Day01.kt
TheRishka
573,352,778
false
{"Kotlin": 29720}
package day01 import readInput fun main() { fun extractGnomeCalories(input: List<String>): Map<Int, Int> { var gnomeIndex = 0 var gnomeCalories = mutableMapOf<Int, Int>() input.forEach { if (it.isEmpty()) { gnomeIndex++ } else { gnome...
0
Kotlin
0
1
54c6abe68c4867207b37e9798e1fdcf264e38658
970
AOC2022-Kotlin
Apache License 2.0
src/main/aoc2015/Day25.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 class Day25(input: List<String>) { private val row = input.first().substringBeforeLast(",").substringAfterLast(" ").toInt() private val col = input.first().substringBeforeLast(".").substringAfterLast(" ").toInt() private val firstCode = 20151125L private val multiplicand = 252533 p...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,493
aoc
MIT License
src/day-2/part-1/solution-day-2-part-1.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File fun convertToPair(string: String): Pair<Char, Char> { val split = string.split(" ") return Pair(split.get(0).first(), split.get(1).first()) } fun letterValue(char: Char): Int { return mapOf('A' to 1, 'B' to 2, 'C' to 3, 'X' to 1, 'Y' to 2, 'Z' to 3).getOrDefault(char, 0) } fun compare...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
763
advent-of-code-22
MIT License
src/main/kotlin/16-jun.kt
aladine
276,334,792
false
{"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511}
import java.util.* class Solution16Jun { // Regex for digit from 0 to 255. val zeroTo255 = "([0-9]|[1-9]\\d{1}|1\\d{2}|2[0-4]\\d|25[0-5])" val fourHexa = "([0-9A-Fa-f]+)" // "([0-9A-Fa-f]{1,2,3,4})" val rgv4 = zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255 val rgv6 = fourH...
0
C++
1
1
54b7f625f6c4828a72629068d78204514937b2a9
1,886
awesome-leetcode
Apache License 2.0
src/main/kotlin/org/kollektions/permutester/Permutator.kt
AlexCue987
224,866,962
false
null
package org.kollektions.permutester class Permutator(val expectedPermutations: List<List<Any>>) { constructor(vararg items: List<Any>): this(permutate(*items)) fun match(actualPermutations: List<List<Any>>) { val duplicates = findDuplicates(actualPermutations) val missing = expectedPermutation...
0
Kotlin
0
0
3ec2425775851f44539542c428f19194c656d87b
2,063
permutester
Apache License 2.0
year2020/day12/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day12/part2/Year2020Day12Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Before you can give the destination to the captain, you realize that the actual action meanings were printed on the back of the instructions the whole time. Almost all of the actions indicate how to move a waypoint which is relative to the ship's position: - Action N means to move the waypoint no...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,916
AdventOfCode
MIT License
year2019/day06/part2/src/main/kotlin/com/curtislb/adventofcode/year2019/day06/part2/Year2019Day06Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Now, you just need to figure out how many orbital transfers you (YOU) need to take to get to Santa (SAN). You start at the object YOU are orbiting; your destination is the object SAN is orbiting. An orbital transfer lets you move from any object to an object orbiting or orbited by that object. Fo...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,084
AdventOfCode
MIT License
year2019/day04/part2/src/main/kotlin/com/curtislb/adventofcode/year2019/day04/part2/Year2019Day04Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- An Elf just remembered one more important detail: the two adjacent matching digits are not part of a larger group of matching digits. Given this additional criterion, but still ignoring the range rule, the following are now true: - 112233 meets these criteria because the digits never decrease and...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,064
AdventOfCode
MIT License
2020/december09.kt
cuuzis
318,759,108
false
{"TypeScript": 105346, "Java": 65959, "Kotlin": 17038, "Scala": 5674, "JavaScript": 3511, "Shell": 724}
import java.io.File /** * https://adventofcode.com/2020/day/9 */ fun main() { val weakNumber = star1() println(weakNumber) // 85848519 println(star2(weakNumber)) // 13414198 } private fun input(): List<String> { return File("2020/december09.txt").readLines(); } private val preambleSize = ...
0
TypeScript
0
1
35e56aa97f33fae5ed3e717dd01d303153caf467
1,754
adventofcode
MIT License
src/Atoi.kt
philipphofmann
236,017,177
false
{"Kotlin": 17647}
/** * Parses the string as an [Int] number and returns the result. * See https://leetcode.com/problems/string-to-integer-atoi/ * * @throws NumberFormatException if the string is not a valid representation of a number. */ fun atoi(string: String): Int { val noWhitespaces = string.trim { it.isWhitespace() } ...
0
Kotlin
0
1
db0889c8b459af683149530f9aad93ce2926a658
1,690
coding-problems
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem54/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem54 /** * LeetCode page: [54. Spiral Matrix](https://leetcode.com/problems/spiral-matrix/); */ class Solution { /* Complexity: * Time O(N) and Auxiliary Space O(1) where N is the number of elements in matrix; */ fun spiralOrder(matrix: Array<IntArray>): List<Int...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,498
hj-leetcode-kotlin
Apache License 2.0
day13/src/main/kotlin/Main.kt
rstockbridge
225,212,001
false
null
fun main() { val inputAsList = resourceFile("input.txt") .readLines()[0] .split(',') .map(String::toLong) val inputAsMap = convertInputToMap(inputAsList) println("Part I: the solution is ${solvePartI(inputAsMap)}.") println("Part II: the solution is ${solvePartII(inputAsMap, 2....
0
Kotlin
0
0
bcd6daf81787ed9a1d90afaa9646b1c513505d75
924
AdventOfCode2019
MIT License
src/main/kotlin/com/github/davio/aoc/general/Matrix.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.general data class Matrix<T>(val data: List<List<T>>) { val maxX: Int = data.lastIndex val maxY: Int = data[0].lastIndex val rows: List<List<T>> get() = data.toList() val columns: List<List<T>> get() = data[0].indices.map { x -> data.indices.map { y ->...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
2,172
advent-of-code
MIT License
src/main/kotlin/cloud/dqn/leetcode/FindModeInBinarySearchTreeKt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/find-mode-in-binary-search-tree/description/ Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is defined as follows: The left subtree of a node contains only no...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
2,110
cloud-dqn-leetcode
No Limit Public License
advent-of-code-2022/src/main/kotlin/year_2022/Day13.kt
rudii1410
575,662,325
false
{"Kotlin": 37749}
package year_2022 import kotlinx.serialization.json.* import util.Runner import java.util.LinkedList fun main() { fun String.toJsonArray(): JsonArray = Json.parseToJsonElement(this).jsonArray fun checkSignal(left: LinkedList<JsonElement>, right: LinkedList<JsonElement>): Boolean? { while (left.isNotE...
1
Kotlin
0
0
ab63e6cd53746e68713ddfffd65dd25408d5d488
2,173
advent-of-code
Apache License 2.0
src/main/kotlin/test1/SparseVector.kt
samorojy
340,891,499
false
null
package test1 data class SparseVectorElementData<T : ArithmeticAvailable<T>>(val positionNumber: Int, var value: T) data class SparseVector<T : ArithmeticAvailable<T>>( private val spaceSize: Int, private val list: MutableList<SparseVectorElementData<T>> ) { private val mapOfSparseVectorElements = ...
0
Kotlin
0
0
d77c0af26cb55c74ae463f59244de233133b2320
3,728
spbu_kotlin_course
Apache License 2.0
2021/src/day02/Day02.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day02 import readInput fun part1(input: List<String>) : Int { var depth = 0 var horizontal = 0 input.forEach { it.split(" ").let { val instruction = it.firstOrNull() ?: return@let val nb = it.elementAtOrNull(1)?.toInt() ?: return@let if (instruction ==...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,385
advent-of-code
Apache License 2.0
src/main/kotlin/adventofcode2020/solution/Day3.kt
lhess
320,667,380
false
null
package adventofcode2020.solution import adventofcode2020.Solution import adventofcode2020.resource.PuzzleInput class Day3(puzzleInput: PuzzleInput<String>) : Solution<String, Any>(puzzleInput) { override fun runPart1() = puzzleInput .traverse(stepsRight = 3, stepsDown = 1) .apply ...
0
null
0
1
cfc3234f79c27d63315994f8e05990b5ddf6e8d4
1,281
adventofcode2020
The Unlicense
src/main/kotlin/problems/S05c06p10ManhattenTouristProblem.kt
jimandreas
377,843,697
false
null
@file:Suppress("SameParameterValue", "UnnecessaryVariable", "UNUSED_VARIABLE", "ReplaceManualRangeWithIndicesCalls") package problems import algorithms.ManhattanTouristProblem /** * stepik: @link: https://stepik.org/lesson/240301/step/10?unit=212647 * rosalind: @link: http://rosalind.info/problems/ba5b/ * Code...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
1,278
stepikBioinformaticsCourse
Apache License 2.0
src/Day06.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
fun detect(line: String, markerCount: Int): Int { val chars = line.toCharArray() val bucket = mutableSetOf<Char>() for (index in 0 until chars.size - markerCount) { chars.copyTo(index, index + markerCount, bucket) if (bucket.size == markerCount) { return index + markerCount ...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
949
advent-of-code-kotlin-2022
Apache License 2.0
src/jvmMain/kotlin/matt/math/jmath/jmath.kt
mgroth0
532,380,281
false
{"Kotlin": 233084}
package matt.math.jmath import matt.lang.require.requireNonNegative import matt.math.angle.Sides import matt.math.exp.sq import org.apache.commons.math3.special.Gamma import java.math.BigDecimal import java.math.BigInteger import kotlin.math.pow import kotlin.math.roundToInt val e = Math.E const val eFloat = Math.E....
0
Kotlin
0
0
f2a1a04cee2b5eb0e577b033984a3df25a2e3983
1,978
math
MIT License
src/ii_collections/n22Fold.kt
shterrett
156,087,921
true
{"Kotlin": 72655, "Java": 4952}
package ii_collections fun example9() { val result = listOf(1, 2, 3, 4).fold(1, { partResult, element -> element * partResult }) result == 24 } // The same as fun whatFoldDoes(): Int { var result = 1 listOf(1, 2, 3, 4).forEach { element -> result = element * result} return result } fun Shop.getSe...
0
Kotlin
0
0
31058af629263c067a8ebb35ad84b10d3a226df6
1,201
kotlin-koans
MIT License
src/main/kotlin/aoc2022/Day24.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import aoc2022.Blizzard.* import util.illegalInput private enum class Blizzard { UP, DOWN, LEFT, RIGHT } private typealias Blizzards = List<List<Set<Blizzard>>> // https://adventofcode.com/2022/day/24 object Day24 : AoCDay<Int>( title = "Blizzard Basin", part1ExampleAnswer = 18,...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
4,080
advent-of-code-kotlin
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day16.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import io.github.clechasseur.adventofcode.y2015.data.Day16Data object Day16 { private val target = Day16Data.target private val input = Day16Data.input private val targetRegex = """^(\w+): (\d+)$""".toRegex() private val inputRegex = """^Sue (\d+): ((?...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
1,958
adventofcode2015
MIT License
src/day02/Game.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
package day02 /** * Possible actions for the game of Rock Paper Scissors. */ enum class Action(val value: Int) { ROCK(0), PAPER(1), SCISSORS(2); companion object { /** * Reverse lookup for action enum object based of [value]. */ infix fun from(value: Int): Action = ...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
2,066
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/icu/trub/aoc/day13/MirrorValley.kt
dtruebin
728,432,747
false
{"Kotlin": 76202}
package icu.trub.aoc.day13 import icu.trub.aoc.util.Point import icu.trub.aoc.util.collections.rotate import icu.trub.aoc.util.columnToString import icu.trub.aoc.util.rowToString internal class MirrorValley(val patterns: List<Pattern>) { companion object { fun parse(input: List<String>): MirrorValley = M...
0
Kotlin
0
0
1753629bb13573145a9781f984a97e9bafc34b6d
4,317
advent-of-code
MIT License
src/day24/first/Solution.kt
verwoerd
224,986,977
false
null
package day24.first import day24.first.ErisTile.BUG import day24.first.ErisTile.EMPTY import tools.Coordinate import tools.adjacentCoordinates import tools.timeSolution import java.math.BigInteger fun main() = timeSolution { var maze = System.`in`.bufferedReader().readLines() .mapIndexed { y, line -> line.toCh...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,487
AoC2019
MIT License
Actividades/EjerciciosKotlin/src/main/kotlin/Operaciones.kt
alanmalagonb
606,216,253
false
null
fun main() { var option: Int do{ println("- Ejercicios Kotlin -\n" + "1. Par o no\n" + "2. Tabla de multiplicar\n" + "3. Producto mediante sumas\n" + "4. Posicion del mayor valor\n" + "5. Suma de vectores\n" + "6. Media\n" + ...
0
Kotlin
0
0
9db7265c6ea553648e092da019ce812f51980ec6
3,699
DesarrolloDeAplicacionesMovilesNativas
MIT License
year2015/src/main/kotlin/net/olegg/aoc/year2015/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2015.DayOf2015 import kotlin.math.max import kotlin.math.min /** * See [Year 2015, Day 22](https://adventofcode.com/2015/day/22) */ object Day22 : DayOf2015(22) { private const val HP = 50 private const val MANA =...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,355
adventofcode
MIT License
src/main/kotlin/com/leetcode/top_interview_questions/easy/merge/Main.kt
frikit
254,842,734
false
null
package com.leetcode.top_interview_questions.easy.merge fun main() { println("Test case 1:") val arr1 = intArrayOf(1, 2, 3, 0, 0, 0) val arr2 = intArrayOf(2, 5, 6) println(Solution().merge(arr1, 3, arr2, 3)) // [1,2,2,3,5,6] println(arr1.toList()) println() println("Test case 2:") val ...
0
Kotlin
0
0
dda68313ba468163386239ab07f4d993f80783c7
1,432
leet-code-problems
Apache License 2.0
2023/src/main/kotlin/com/github/akowal/aoc/Day01.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc import java.io.File class Day01(input: File) : Problem<Int> { private val lines = input.readLines() override fun solve1(): Int { return lines.sumOf { s -> s.first(Char::isDigit).digitToInt() * 10 + s.last(Char::isDigit).digitToInt() } } overr...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
1,063
advent-of-kode
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day15.kt
Walop
573,012,840
false
{"Kotlin": 53630}
import java.io.InputStream import kotlin.math.absoluteValue data class Sensor(val pos: Vec2, val range: Int) class Day15 { companion object { private fun readSensors(input: InputStream?): Pair<List<Sensor>, Set<Vec2>> { if (input == null) { throw Exception("Input missing") ...
0
Kotlin
0
0
7a13f6500da8cb2240972fbea780c0d8e0fde910
3,506
AdventOfCode2022
The Unlicense
LongestPalindrome.kt
linisme
111,369,586
false
null
class LongestPalindromeSolution { fun longestPalindrome(s: String): String { var chars = s.toCharArray() val sourceLength = s.length var maxLength = 0 var maxLeft = 0 var maxRight = 0 for (l in 0 until sourceLength) { if (maxLength > sourceLength - l) { break ...
0
Kotlin
1
0
4382afcc782da539ed0d535c0a5b3a257e0c8097
1,151
LeetCodeInKotlin
MIT License
src/main/kotlin/g2901_3000/s2982_find_longest_special_substring_that_occurs_thrice_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2982_find_longest_special_substring_that_occurs_thrice_ii // #Medium #String #Hash_Table #Binary_Search #Counting #Sliding_Window // #2024_01_19_Time_343_ms_(100.00%)_Space_48.4_MB_(100.00%) import kotlin.math.max class Solution { fun maximumLength(s: String): Int { val arr = Array(26...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,551
LeetCode-in-Kotlin
MIT License
src/main/kotlin/pl/msulima/pkpchecker/Summarize.kt
msulima
96,702,742
false
null
package pl.msulima.pkpchecker import java.io.File fun printSummary(databaseDirectory: File): Unit { val completed = readAllCompleted(databaseDirectory) .mapNotNull { readStatisticsForTrain(it) } completed .sortedBy { -it.stops.last().arrivalDelay } .take(30) ....
0
Kotlin
0
0
1ae892bde66be9c226bf80506c92f7e25d4ba7bb
1,894
pkp-checker
Apache License 2.0
src/main/java/io/github/lunarwatcher/aoc/day7/Day7.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day7 import io.github.lunarwatcher.aoc.commons.readFile import kotlin.math.absoluteValue fun day7part1processor(raw: List<String>) : String{ val letters = raw.map { val split = it.split(" ").filter { it.length == 1 } split[0][0] to split[1][0] } // Char,...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
3,264
AoC-2018
MIT License
src/Day06.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
fun main() { fun String.allUnique(): Boolean = all(hashSetOf<Char>()::add) fun part1(input: List<String>): Int { val signalStartLength = 4 return input .map { it.windowed(signalStartLength) } .flatten() .indexOfFirst { it.allUnique() } + signalStartLength...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
1,134
aoc2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem981/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem981 /** * LeetCode page: [981. Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store/); */ class TimeMap() { private val timeValuesPerKey = hashMapOf<String, MutableList<TimeValue>>() private data class TimeValue(val timestamp: Int, val v...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,969
hj-leetcode-kotlin
Apache License 2.0
Kotlin/BogoSort.kt
argonautica
212,698,136
false
{"Java": 42011, "C++": 24846, "C#": 15801, "Python": 14547, "Kotlin": 11794, "C": 10528, "JavaScript": 9054, "Assembly": 5049, "Go": 3662, "Ruby": 1949, "Lua": 687, "Elixir": 589, "Rust": 447}
import kotlin.random.Random fun main(args : Array<String>) { //Create Array var array = intArrayOf(4,5,3,9,1) array = sort(array) array.forEach { println(it) } } /** * Use Bogo sort to randomly swap two inputs and then check if the list is sorted */ fun sort(input:IntArray):IntArray{ ...
4
Java
138
45
b9ebd2aadc6b59e5feba7d1fe9e0c6a036d33dba
1,001
sorting-algorithms
MIT License
src/Day01.kt
NatoNathan
572,672,396
false
{"Kotlin": 6460}
fun main() { fun getElivs(input: List<String>): List<Int> { val elivs = mutableListOf<Int>() var current = 0 input.forEach { when (it) { "" -> { elivs.add(current) current = 0 } else -> curr...
0
Kotlin
0
0
c0c9e2a2d0ca2503afe33684a3fbba1f9eefb2b0
897
advent-of-code-kt
Apache License 2.0
Lab/src/main/kotlin/VisibilityGraph.kt
knu-3-tochanenko
273,871,388
false
{"Java": 81147, "Kotlin": 26815, "Python": 5190}
import java.util.* import kotlin.math.pow import kotlin.math.sqrt object VisibilityGraph { private fun lineOfSight(v1: Vector, v2: Vector): Boolean { val denominator = (v1.p1.x - v1.p0.x) * (v2.p1.y - v2.p0.y) - (v1.p1.y - v1.p0.y) * (v2.p1.x - v2.p0.x) if (denominator == 0.0) { return...
0
Java
0
0
e7ce6b3561d0b26f136852b409f5518660e40665
4,696
ComputationalGeometry
MIT License
app/src/main/java/com/problemsolver/androidplayground/utils/SortAlgorithm.kt
odiapratama
283,957,884
false
null
package com.problemsolver.androidplayground.utils import java.util.* object SortAlgorithm { /** * TIME COMPLEXITY * Best : Ω(n) * Average : Θ(n^2) * Worst : O(n^2) * */ fun <T : Comparable<T>> bubbleSort(array: List<T>, asc: Boolean = true) { val length = array.size - 1 ...
0
Kotlin
0
0
cf1a9a0ff1e7556a283021a79e2b985fed821d69
4,327
Android-Playground
MIT License
2020/src/main/kotlin/de/skyrising/aoc2020/day15/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2020.day15 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.HashCommon import it.unimi.dsi.fastutil.ints.Int2IntMap import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap private fun day15next(mem: Int2IntMap, turn: Int, next: Int): Int { val n = turn - mem.getOrDefault(next, turn) ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
3,085
aoc
MIT License
src/main/kotlin/sschr15/aocsolutions/Day23.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* import java.util.ArrayDeque import kotlin.time.measureTime /** * AOC 2023 [Day 23](https://adventofcode.com/2023/day/23) * Challenge: How does one take a leisurely walk through a forest, pretending there *isn't* * a global snow shortage mere days befo...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
6,355
advent-of-code
MIT License
2021/kotlin/src/main/kotlin/com/codelicia/advent2021/Day16.kt
codelicia
627,407,402
false
{"Kotlin": 49578, "PHP": 554, "Makefile": 293}
package com.codelicia.advent2021 class Day16(val input: String) { private fun hexToBinary(input: String): List<Char> = input.map { it.digitToInt(16).toString(2).padStart(4, '0') }.flatMap { it.toList() } private var transmission: Iterator<Char> = hexToBinary(input).iterator() fun Iterator<Char>....
2
Kotlin
0
0
df0cfd5c559d9726663412c0dec52dbfd5fa54b0
2,907
adventofcode
MIT License
src/Day06.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { val datastream = input.first() return datastream .withIndex() .windowed(4) .map { indexedCharSequence -> if (indexedCharSequence.map { it.value }.toSet().size == 4) { indexedCharSe...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
1,086
aoc2022
Apache License 2.0
2023/src/main/kotlin/org/suggs/adventofcode/Day03GearRatios.kt
suggitpe
321,028,552
false
{"Kotlin": 156836}
package org.suggs.adventofcode import org.slf4j.LoggerFactory object Day03GearRatios { private val log = LoggerFactory.getLogger(this::class.java) fun sumAllNumbersWithAdjacentSymbolsFrom(data: String) = sumNumbersWithAdjacentSymbols(Grid(data), Coordinate(0, 0), 0) .also { log.debug("Par...
0
Kotlin
0
0
9485010cc0ca6e9dff447006d3414cf1709e279e
5,844
advent-of-code
Apache License 2.0
2021/07/main.kt
chylex
433,239,393
false
null
import java.io.File import kotlin.math.abs fun main() { val originalPositions = File("input.txt").readLines().single().split(',').map(String::toInt).toIntArray() val p1 = originalPositions.minOrNull() ?: return val p2 = originalPositions.maxOrNull() ?: return val candidates = p1..p2 part1(originalPositions, c...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
878
Advent-of-Code
The Unlicense
src/main/kotlin/Day09.kt
andrewrlee
434,584,657
false
{"Kotlin": 29493, "Clojure": 14117, "Shell": 398}
import java.io.File import java.nio.charset.Charset.defaultCharset import kotlin.streams.toList typealias Coordinate = Pair<Int, Int> typealias Basin = Set<Coordinate> typealias ValidCells = Set<Coordinate> object Day09 { fun toCoordinates(row: Int, line: String) = line.chars() .map(Character::getNumericV...
0
Kotlin
0
0
aace0fccf9bb739d57f781b0b79f2f3a5d9d038e
2,139
adventOfCode2021
MIT License
src/pl/shockah/aoc/y2018/Day6.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2018 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.unikorn.collection.MutableArray2D import java.util.* import kotlin.math.absoluteValue class Day6: AdventTask<List<Day6.Point>, Int, Int>(2018, 6) { data class Poin...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
4,762
Advent-of-Code
Apache License 2.0
day09/Part2.kt
anthaas
317,622,929
false
null
import java.io.File fun main(args: Array<String>) { val input = File("input.txt").readLines().map { it.toLong() } var index = 25 var valid = true while (valid) { valid = existsSum(input.subList(index - 25, index), input[index]) index++ } val invalidNumber = input[index - 1] ...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
1,039
Advent-of-Code-2020
MIT License
src/main/kotlin/com/sherepenko/leetcode/solutions/MaximalSquare.kt
asherepenko
264,648,984
false
null
package com.sherepenko.leetcode.solutions import com.sherepenko.leetcode.Solution import kotlin.math.max import kotlin.math.min class MaximalSquare( private val matrix: Array<CharArray> ) : Solution { companion object { fun maximalSquare(matrix: Array<CharArray>): Int { val m = matrix.siz...
0
Kotlin
0
0
49e676f13bf58f16ba093f73a52d49f2d6d5ee1c
1,298
leetcode
The Unlicense
src/Day03/Day03.kt
NST-d
573,224,214
false
null
package Day03 import utils.* fun main() { fun part1(input : List<String>): Int = input .map { it.chunked(it.length/2) } .sumOf { val left = it[0] val right = it[1] var value = 0 (left.toCharArray()).distinct().forEac...
0
Kotlin
0
0
c4913b488b8a42c4d7dad94733d35711a9c98992
1,412
aoc22
Apache License 2.0
2021/src/day11/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day11 import java.nio.file.Files import java.nio.file.Paths fun main() { fun iterate(octopuses: Input): Int { var flashes = 0 val queue = mutableListOf<Pair<Int, Int>>() val flashed = Array(octopuses.size) { BooleanArray(octopuses[it].size) } for ((i, row) in octopuses.withIndex()) { f...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
1,791
advent-of-code
Apache License 2.0
src/boj_14888/Kotlin.kt
devetude
70,114,524
false
{"Java": 564034, "Kotlin": 80457}
package boj_14888 import java.util.StringTokenizer import kotlin.math.max import kotlin.math.min var maxValue = Int.MIN_VALUE var minValue = Int.MAX_VALUE fun main() { val n = readln().toInt() var st = StringTokenizer(readln()) val numbers = IntArray(n) repeat(n) { numbers[it] = st.nextToken().toInt(...
0
Java
7
20
4c6acff4654c49d15827ef87c8e41f972ff47222
1,480
BOJ-PSJ
Apache License 2.0
src/main/kotlin/day6/Aoc.kt
widarlein
225,589,345
false
null
package day6 import java.io.File fun main(args: Array<String>) { if (args.isEmpty()) { println("Must provide input orbits") System.exit(0) } val inputLines = File("src/main/kotlin/day6/${args[0]}").readLines() val objects = buildGraph(inputLines) val numberOfOrbits = objects.sum...
0
Kotlin
0
0
b4977e4a97ad61177977b8eeb1dcf298067e8ab4
2,233
AdventOfCode2019
MIT License
src/main/kotlin/days/Day1.kt
nicopico-dev
726,255,944
false
{"Kotlin": 37616}
package days import util.allIndexesOf class Day1( inputFileNameOverride: String? = null, ) : Day(1, inputFileNameOverride) { override fun partOne(): Any { return inputList .sumOf { line -> val first = line.first(Char::isDigit) val last = line.last(Char::isD...
0
Kotlin
0
0
1a13c8bd3b837c1ce5b13f90f326f0277249d23e
1,751
aoc-2023
Creative Commons Zero v1.0 Universal
Palindrome_Partitioning.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
class Solution { fun partition(s: String): List<List<String>> { val res = mutableListOf<List<String>>() combine(s, mutableListOf(), res) return res } private fun combine(s: String, path: MutableList<String>, res: MutableList<List<String>>) { if (s.isEmpty()) { r...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,336
leetcode
MIT License
src/Day01.kt
Frendzel
573,198,577
false
{"Kotlin": 5336}
fun main() { fun part1(input: List<String>): Int = input.joinToString(",") .split(",,") .map { it.split(",").sumOf(String::toInt) } .maxOf { it } fun part2(input: List<String>): Int = input.joinToString(",") ...
0
Kotlin
0
0
a8320504be93dfba1f634413a50e7240d16ba6d9
772
advent-of-code-kotlin
Apache License 2.0
kotlin/Determinant.kt
dirask
202,550,220
true
{"Java": 491556, "C++": 207948, "Kotlin": 23977, "CMake": 346}
// https://en.wikipedia.org/wiki/Determinant fun det(matrix: Array<DoubleArray>): Double { val EPS = 1e-10 val a = matrix.map { it.copyOf() }.toTypedArray() val n = a.size var res = 1.0 for (i in 0 until n) { val p = (i until n).maxBy { Math.abs(a[it][i]) }!! if (Math.abs(a[p][i]) < ...
0
Java
1
2
75f52966780cdc6af582e00f9460f17a4a80d19e
937
codelibrary
The Unlicense
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/SortingAlgorithms/HeapSort/HeapSort.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
package com.betulnecanli.kotlindatastructuresalgorithms.SortingAlgorithms.HeapSort //Heapsort is another comparison-based algorithm that sorts an array in ascending //order using a heap. private fun leftChildIndex(index: Int) = (2 * index) + 1 private fun rightChildIndex(index: Int) = ...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,862
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/questions/WildcardSearchDS.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import kotlin.test.assertFalse import kotlin.test.assertTrue /** * Design a data structure that supports adding new words and finding if a string matches any previously added string. * Your data structure should implement two methods * * `addWord(word)`- Ad...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
4,365
algorithms
MIT License
src/main/kotlin/me/grison/aoc/y2022/Day09.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2022 import me.grison.aoc.* class Day09 : Day(9, 2022) { override fun title() = "Rope Bridge" override fun partOne() = solve(2) override fun partTwo() = solve(10) private fun solve(ropeSize: Int): Int { val seen = mutableSetOf<Position>() val movements = mapOf...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,271
advent-of-code
Creative Commons Zero v1.0 Universal
src/Day10.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun main() { val day = "Day10" fun part1(input: List<String>): Int { val sim = Simulator(input) var cycle = 0 var total = 0 while (cycle < 240) { cycle++ if (cycle in listOf(20, 60, 100, 140, 180, 220)) { total += cycle * sim.register ...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
2,525
advent-of-code-2022
Apache License 2.0
year2021/day15/part1/src/main/kotlin/com/curtislb/adventofcode/year2021/day15/part1/Year2021Day15Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 15: Chiton --- You've almost reached the exit of the cave, but the walls are getting closer together. Your submarine can barely still fit, though; the main problem is that the walls of the cave are covered in chitons, and it would be best not to bump any of them. The cavern is large, but has a very low cei...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,078
AdventOfCode
MIT License
src/Day04.kt
rxptr
572,717,765
false
{"Kotlin": 9737}
fun main() { fun parsInput(inputLines: List<String>) = inputLines.map { it.split(',').map { id -> id.split('-') .let { (a, b) -> a.toInt() .. b.toInt() } }.let { (f, s) -> Pair(f, s) } } fun part1(input: List<String>) = parsInput(input).count { val commo...
0
Kotlin
0
0
989ae08dd20e1018ef7fe5bf121008fa1c708f09
790
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SmallestCommonElement.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
5,855
kotlab
Apache License 2.0
src/Day20.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import kotlin.system.exitProcess fun main() { val input = readInput("Day20").associate { val (name, out) = it.split(" -> ") name to out.split(", ").toSet() } fun withSign(s: String) = when { input.keys.contains("%$s") -> "%$s" input.keys.contains("&$s") -> "&$s" else...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
2,746
advent-of-code-kotlin
Apache License 2.0
kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/char.kt
swanandvk
284,610,632
true
{"Kotlin": 2715433, "HTML": 423, "Java": 145}
package io.kotest.property.arbitrary import io.kotest.property.Arb /** * Returns a [Arb] that generates randomly-chosen Chars. Custom characters can be generated by * providing CharRanges. Distribution will be even across the ranges of Chars. * For example: * Gen.char('A'..'C', 'D'..'E') * Ths will choose A, B, ...
5
Kotlin
0
1
e176cc3e14364d74ee593533b50eb9b08df1f5d1
2,003
kotest
Apache License 2.0
src/main/kotlin/solutions/day10/Day10.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day10 import solutions.Solver class Day10 : Solver { override fun solve(input: List<String>, partTwo: Boolean): String { var crt = "" var checkpoint = if (!partTwo) { 20 } else { 40 } var x = 1 var cycles = 0 val r...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
2,234
Advent-of-Code-2022
MIT License
src/main/kotlin/g1901_2000/s1914_cyclically_rotating_a_grid/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1914_cyclically_rotating_a_grid // #Medium #Array #Matrix #Simulation #2023_06_20_Time_282_ms_(100.00%)_Space_39.6_MB_(100.00%) class Solution { fun rotateGrid(grid: Array<IntArray>, k: Int): Array<IntArray> { rotateInternal(grid, 0, grid[0].size - 1, 0, grid.size - 1, k) retur...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,242
LeetCode-in-Kotlin
MIT License
src/Day13.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") import kotlin.Comparator as KComparator private const val DAY = "13" private const val PART1_CHECK = 13 private const val PART2_CHECK = 140 private enum class Order { RIGHT, WRONG, UNDETERMINED } private sealed interface Lol { class Number(val value: Int) : Lol { ...
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
4,955
adventofcode2022
Apache License 2.0
solutions/aockt/y2016/Y2016D08.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2016 import aockt.util.OcrDecoder import aockt.y2016.Y2016D08.Instruction.* import io.github.jadarma.aockt.core.Solution object Y2016D08 : Solution { /** An instruction for building the display. */ private sealed class Instruction { /** Turns on all of the pixels in a rectangle at the ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
4,065
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/solutions/day13/Day13.kt
Dr-Horv
112,381,975
false
null
package solutions.day13 import solutions.Solver data class Scanner(val depth: Int, val range: Int) { fun positionAt(t: Int) = t % ((range-1) * 2) fun caught(t: Int) = positionAt(t) == 0 fun severity() = depth * range } class Day13 : Solver { override fun solve(input: List<String>, partTwo: Boolean)...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
1,139
Advent-of-Code-2017
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RemoveAllAdjacentDuplicates.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
2,315
kotlab
Apache License 2.0
solutions/src/Day18.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): Int { val coords = toCoords(input) var count = 0 coords.forEach { (x, y, z) -> val front = CubeCoord(x, y, z - 1) if (front !in coords) { count++ } val back = CubeCoord(x, y, z + 1) ...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
5,857
advent-of-code-22
Apache License 2.0
src/main/aoc2021/Day13.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2021 import AMap import Pos class Day13(input: List<String>) { sealed class Fold(val at: Int) { class Horizontal(at: Int) : Fold(at) class Vertical(at: Int) : Fold(at) } private val paper = AMap() private val folds: List<Fold> init { input.takeWhile { it.isNot...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,542
aoc
MIT License
src/Day05.kt
Longtainbin
573,466,419
false
{"Kotlin": 22711}
fun main() { val input = readInput("inputDay05") val operations = initOperation(input) fun part1(input: List<String>): String { val stack = initStack(input) for (ope in operations) { for (count in 1..ope[0]) { stack[ope[2] - 1].add(stack[ope[1] - 1].removeLast()) ...
0
Kotlin
0
0
48ef88b2e131ba2a5b17ab80a0bf6a641e46891b
2,387
advent-of-code-2022
Apache License 2.0
Kotlin/problems/0022_partition_labels.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
class Solution { fun partitionLabels(S: String): List<Int> { val lettersIntervals = MutableList<Pair<Int,Int>>(26) { _ -> Pair(Int.MAX_VALUE,Int.MIN_VALUE)} val result = mutableListOf<Int>() for(i in 0 until S.length){ val index = S[i]-'a' if(lettersIntervals[index...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,788
algorithms
MIT License