path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/day3.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getLines fun getPowerConsumption(diagnosticReport: List<String>): Int{ val length = diagnosticReport.first().length var gamma = "" var epsilon = "" for(i in 0 until length){ val ones = diagnosticReport.count { it[i] == '1' } val zeros = diagnosticReport.count { it[i] == '0...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
1,528
AdventOfCode2021
MIT License
src/challenges.kt
BenjaminEarley
151,190,621
false
null
import java.math.BigInteger fun String.isPalindrome(): Boolean = when { count() < 2 -> true first() != last() -> false else -> slice(1..count() - 2).isPalindrome() } fun Int.isEven(): Boolean = this % 2 == 0 fun Int.isOdd(): Boolean = this.isEven().not() fun power(x: Int, n: Int): Dou...
0
Kotlin
0
0
1a4278273f3d79d4e5bb7054d0e5fb91274e871c
1,461
Functional_Kotlin
MIT License
src/Day01.kt
rk012
574,169,156
false
{"Kotlin": 9389}
fun main() { fun List<String>.readWithNulls() = scan<_, Int?>(null) { acc, s -> if (s.isBlank()) null else (acc ?: 0) + s.toInt() }.let { it + null } fun part1(input: List<String>) = input.readWithNulls().filterNotNull().max() fun part2(input: List<String>) = input.readWithNulls().let ...
0
Kotlin
0
0
bfb4c56c4d4c8153241fa6aa6ae0e829012e6679
813
advent-of-code-2022
Apache License 2.0
codeforces/codeton6/e_tl.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.codeton6 private fun solve(): Int { readln() val a = readInts() val mark = IntArray(a.size + 1) { -1 } val dp0 = mutableSetOf(0) val dp = MutableList(a.size + 1) { dp0 } val dpMax = IntArray(a.size + 1) { 0 } val dpHashCode = IntArray(a.size + 1) { 0 } val used = mutableSetOf<Long>() var le...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,295
competitions
The Unlicense
y2022/src/main/kotlin/adventofcode/y2022/Day20.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2022 import adventofcode.io.AdventSolution object Day20 : AdventSolution(2022, 20, "Grove Positioning System") { override fun solvePartOne(input: String): Long { val lines = parse(input).withIndex().toList() return solve(1, lines) } override fun solvePartTwo(input:...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,304
advent-of-code
MIT License
codeforces/codeton6/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.codeton6 private fun solve() { val (_, k) = readInts() fun rightmost(a: List<Int>): IntArray { val res = IntArray(k) { -1 } for (i in a.indices) res[a[i]] = i for (i in k - 2 downTo 0) res[i] = maxOf(res[i], res[i + 1]) return res } val a = readInts().map { it - 1 } val present = Boolea...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
781
competitions
The Unlicense
src/main/kotlin/Day1.kt
darwineee
726,871,065
false
{"Kotlin": 1770}
import kotlin.io.path.Path import kotlin.io.path.forEachLine fun day1_part1(path: String) { var result = 0 Path(path).forEachLine { line -> val numLine = line.filter { it.isDigit() } val num = when (numLine.length) { 1 -> numLine + numLine 2 -> numLine else -...
0
Kotlin
0
0
c301358dd55b456337857a8a63a300974f6b8acb
1,588
adventOfCode2023
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2023/Day06.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2023 import com.dvdmunckhof.aoc.multiply import kotlin.math.pow import kotlin.math.sqrt class Day06(private val input: List<String>) { fun solvePart1(): Int { val (times, distances) = input.map { line -> line.split(' ').mapNotNull(String::toIntOrNull) } val wins =...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,047
advent-of-code
Apache License 2.0
code/GeneticAlgorithm/GeneticAlgorithm/src/main/kotlin/GA.kt
Artificial-Intelligence-Games
690,504,479
false
{"Kotlin": 21550, "Prolog": 19264}
import java.lang.Math.random /** * Implementação do Algoritmo Genético, inspirado em mutações genéticas a nivel bioloógico. * O agoritmo admite 3 fases por cada ciclo (epoch): * Seleção --------> Reprodução ---------> Mutação * * @param T é o tipo do invididuo. * @property population a collection of individua...
0
Kotlin
0
1
03419d7db9cbdec371abf8be565e79b181ad8d19
3,202
Sudoku-Solver
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day24/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day24 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import java.util.function.IntFunction @PuzzleName("Arithmetic Logic Unit") fun PuzzleInput.part1() = solve(this, intArrayOf(9, 8, 7, 6, 5, ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
3,566
aoc
MIT License
capitulo5/src/main/kotlin/5.27(Maior Divisor Comum).kt
Cursos-Livros
667,537,024
false
{"Kotlin": 104564}
//5.27 (Maior Divisor Comum) O máximo divisor comum (MDC) de dois números inteiros é o maior //inteiro que divide igualmente cada um dos dois números. Escreva um método gcd que retorne o maior //divisor comum de dois números inteiros. [Dica: você pode querer usar o algoritmo de Euclides. Você pode encontrar //informaçõ...
0
Kotlin
0
0
f2e005135a62b15360c2a26fb6bc2cbad18812dd
1,066
Kotlin-Como-Programar
MIT License
src/commonMain/kotlin/ru/spbstu/wheels/Comparables.kt
vorpal-research
185,828,983
false
null
package ru.spbstu.wheels inline class ComparatorScope<T>(val comparator: Comparator<T>) { operator fun T.compareTo(that: T) = comparator.compare(this, that) fun Iterable<T>.maxOrNull() = maxWithOrNull(comparator) fun Iterable<T>.minOrNull() = minWithOrNull(comparator) fun Collection<T>.sorted() = sort...
0
Kotlin
1
0
389f9c290d496aae3d4f5eaa2a0d4f4863f281c2
2,261
kotlin-wheels
MIT License
src/main/kotlin/Puzzle7.kt
namyxc
317,466,668
false
null
object Puzzle7 { @JvmStatic fun main(args: Array<String>) { val rules = Rules(Puzzle7::class.java.getResource("puzzle7.txt").readText().split("\n")) val sumOfAvailableOuterColors = rules.countContainingBags("shiny gold") println(sumOfAvailableOuterColors) val sumOfAvailableIn...
0
Kotlin
0
0
60fa6991ac204de6a756456406e1f87c3784f0af
2,834
adventOfCode2020
MIT License
src/main/kotlin/Day03.kt
rogierbom1
573,165,407
false
{"Kotlin": 5253}
package main.kotlin import readInput private fun Char.toPriority(): Int { val priorityMap = ('a'..'z').associateWith { it - 'a' + 1 } + ('A'..'Z').associateWith { it - 'A' + 27 } return priorityMap[this] ?: throw Exception("Unmapped character") } fun main() { fun part1(input: List<String>): Int = input.m...
0
Kotlin
0
0
b7a03e95785cb4a2ec0bfa170f4f667fc574c1d2
1,142
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/g0401_0500/s0472_concatenated_words/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0401_0500.s0472_concatenated_words // #Hard #Array #String #Dynamic_Programming #Depth_First_Search #Trie // #2022_12_29_Time_484_ms_(100.00%)_Space_48_MB_(100.00%) class Solution { private val ans: MutableList<String> = ArrayList() private var root: Trie? = null fun findAllConcatenatedWordsInADi...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,841
LeetCode-in-Kotlin
MIT License
src/Day01.kt
phoenixli
574,035,552
false
{"Kotlin": 29419}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currCalories = 0 input.forEach { val foodCal = it.toIntOrNull() if (foodCal != null) { currCalories += foodCal } else { maxCalories = maxOf(currCalo...
0
Kotlin
0
0
5f993c7b3c3f518d4ea926a792767a1381349d75
1,129
Advent-of-Code-2022
Apache License 2.0
src/day01/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day01 import readInput fun main() { val input = readInput("day01") println(solvePartOne(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Int = input.map { value -> value.toInt() } .solveIncreasingTimes() fun solvePartTwo(input: List<String>): Int = input....
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
866
aoc-2021
Apache License 2.0
src/main/kotlin/dev/siller/aoc2023/Day07.kt
chearius
725,594,554
false
{"Kotlin": 50795, "Shell": 299}
package dev.siller.aoc2023 data object Day07 : AocDayTask<UInt, UInt>( day = 7, exampleInput = """ |32T3K 765 |T55J5 684 |KK677 28 |KTJJT 220 |QQQJA 483 """.trimMargin(), expectedExampleOutputPart1 = 6440u, expectedExampleOutputPart2 = 5905u ) { ...
0
Kotlin
0
0
fab1dd509607eab3c66576e3459df0c4f0f2fd94
4,444
advent-of-code-2023
MIT License
src/day14/Day14.kt
tobihein
569,448,315
false
{"Kotlin": 58721}
package day14 import readInput class Day14 { fun part1(): Int { val readInput = readInput("day14/input") return part1(readInput) } fun part2(): Int { val readInput = readInput("day14/input") return part2(readInput) } fun part1(input: List<String>): Int { v...
0
Kotlin
0
0
af8d851702e633eb8ff4020011f762156bfc136b
4,354
adventofcode-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxPathSum.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
1,700
kotlab
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/iteration/Product.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.iteration /* pair */ fun <A, B> Iterable<A>.product(other: Iterable<B>): Sequence<Pair<A, B>> = sequence { for (a in this@product) { for (b in other) { yield(Pair(a, b)) } } } fun <A, B> Pair<Iterable<A>, Iterable<B>>.product(): Sequence<P...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,881
advent-2023
ISC License
src/Day10/Day10.kt
brhliluk
572,914,305
false
{"Kotlin": 16006}
fun main() { fun part1(input: List<String>): Int { var register = 1 var cycle = 0 val signalStrengths = mutableListOf<Int>() val importantCycles = listOf(20, 60, 100, 140, 180, 220) input.forEach { instruction -> when { instruction.startsWith("noop...
0
Kotlin
0
0
96ac4fe0c021edaead8595336aad73ef2f1e0d06
1,989
kotlin-aoc
Apache License 2.0
src/main/kotlin/days/y2023/day16/Day16.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day16 import util.InputReader typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day16(val input: PuzzleInput) { val maze = Maze(Grid2d.from(input)) fun partOne(): Int { val start = Beam(Position(-1, 0), Direction.RIGHT) return energyFor(mutableLi...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
4,713
AdventOfCode
Creative Commons Zero v1.0 Universal
src/aoc2022/Day08.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList import kotlin.math.max fun main() { fun isVisibleOutside(map: List<List<Int>>, row: List<Int>, rowIndex: Int, colIndex: Int) : Boolean { return rowIndex == 0 || colIndex == 0 || rowIndex == map.lastIndex || colIndex == row.lastIndex } fun isLeftVisible(...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
4,081
AOC-2022-Kotlin
Apache License 2.0
2023/src/main/kotlin/sh/weller/aoc/Day08.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day08 : SomeDay<String, Long> { override fun partOne(input: List<String>): Long { val directions = input.first().toCharArray() val nodes = input.drop(2) .associate { line -> val splitLine = line.split("=").map { it.trim() } v...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
3,246
AdventOfCode
MIT License
src/Day04.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
fun main() { @Suppress("unused") fun log(message: Any?) { println(message) } fun part1(input: List<String>): Int { return input.sumOf { record -> // BUG NOTE dammit, forgot to convert these to ints! val (a, b, x, y) = record.split(",", "-").map { it.toInt() } ...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
1,133
aoc2022
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day13.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day import kotlin.math.min class Day13(input: String? = null) : Day(13, "Point of Incidence", input) { override fun partOne() = inputString.sumReflectionsBlockwise() override fun partTwo() = inputString.sumReflectionsBlockwise(tolerance = 1) private fun...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
1,886
advent-of-code-2023
MIT License
implementation/src/main/kotlin/io/github/tomplum/aoc/map/volcano/VolcanoCaveMap.kt
TomPlum
572,260,182
false
{"Kotlin": 224955}
package io.github.tomplum.aoc.map.volcano class VolcanoCaveMap(scan: List<String>) { private val valveRelationships: Map<Valve, List<Valve>> = scan.associate { line -> val label = line.removePrefix("Valve ").split(" ")[0].trim() val flowRate = line.split(" has flow rate=")[1].split(";")[0].toInt()...
0
Kotlin
0
0
703db17fe02a24d809cc50f23a542d9a74f855fb
4,795
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem2050/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2050 /** * LeetCode page: [2050. Parallel Courses III](https://leetcode.com/problems/parallel-courses-iii/); */ class Solution { /* Complexity: * Time O(n+E) and Space O(n+E); */ fun minimumTime(n: Int, relations: Array<IntArray>, time: IntArray): Int { ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,521
hj-leetcode-kotlin
Apache License 2.0
Algorithms/src/main/kotlin/NextClosestTime.kt
ILIYANGERMANOV
557,496,216
false
{"Kotlin": 74485}
fun main() { val sut = NextClosestTime() for (h in 0..23) { val hour = if (h < 10) "0$h" else h.toString() for (m in 0..59) { val minute = if (m < 10) "0$m" else m.toString() val time = "$hour:$minute" println("\"$time\" -> \"${sut.nextClosestTime(time)}\"") ...
0
Kotlin
0
1
4abe4b50b61c9d5fed252c40d361238de74e6f48
3,592
algorithms
MIT License
Day12/src/JupiterMoons.kt
gautemo
225,219,298
false
null
import java.io.File import kotlin.math.abs import kotlinx.coroutines.* fun main(){ val input = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText().trim() val energy = energyAfterStep(getMoons(input), 1000) println(energy) val loop = repeatsAfter(getMoons(input)...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
2,520
AdventOfCode2019
MIT License
src/main/kotlin/day7/part2/Part2.kt
bagguley
329,976,670
false
null
package day7.part2 import day7.data fun main() { val bagMap = data.map{it.split(" bags contain ")}.map{ process2(it) }.toMap() val stack = mutableListOf(bagMap["shiny gold"]) var count = 0 do { val c = stack.removeAt(0) stack.addAll(c!!.map{f -> bagMap[f.second]!!.map{g -> f.first * g...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
824
adventofcode2020
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2022/Y2022D5.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2022 import io.github.pshegger.aoc.common.BaseSolver import io.github.pshegger.aoc.common.extractAll import io.github.pshegger.aoc.common.splitByBlank import io.github.pshegger.aoc.common.toExtractor class Y2022D5 : BaseSolver() { override val year = 2022 override val day = 5 ...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,260
advent-of-code
MIT License
src/aoc2023/Day09.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun resolveSequence(start: List<Int>): Long { var totalLastValues = 0L var current = start var next = mutableListOf<Int>() while (current.any { it != 0 }) { for (i in 0 until current.size - 1) { next.add(curr...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
1,814
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/github/freekdb/kotlin/workshop/step05/MastermindVersion2.kt
FreekDB
230,429,337
false
null
package com.github.freekdb.kotlin.workshop.step05 // Code-breaking game: https://en.wikipedia.org/wiki/Mastermind_(board_game) // Additional information: http://mathworld.wolfram.com/Mastermind.html // Implementation inspired by: http://www.rosettacode.org/wiki/Mastermind#Python // https://www.coursera.org/learn/kotl...
0
Kotlin
0
2
5a9bb08a8d0bd3d68dd2274becf4758ab10caf5d
3,355
kotlin-for-kurious-koders
Apache License 2.0
src/main/kotlin/space/d_lowl/kglsm/problem/TSP.kt
d-lowl
300,622,439
false
null
package space.d_lowl.kglsm.problem import space.d_lowl.kglsm.general.space.isRepeating import java.io.File import kotlin.math.pow import kotlin.math.sqrt import kotlin.random.Random typealias DistanceFunction = (NDPoint, NDPoint) -> Double class NDPoint(vararg val coords: Double) { fun getDimensions(): Int = coo...
17
Kotlin
0
1
0886e814be75a77fa8f33faa867329aef19085a5
3,077
kGLSM
MIT License
kotlin/src/katas/kotlin/sort/heapsort/HeapSort0.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.sort.heapsort import nonstdlib.listOfInts import nonstdlib.permutations import nonstdlib.printed import nonstdlib.swap import datsok.shouldEqual import org.junit.Test import kotlin.random.Random class HeapSort0Tests { @Test fun `sort a list`() { emptyList<Int>().heapSort() shouldEqual...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,660
katas
The Unlicense
src/main/kotlin/de/dikodam/adventofcode2019/days/Day04.kt
dikodam
225,222,616
false
null
package de.dikodam.adventofcode2019.days import de.dikodam.adventofcode2019.utils.TimingData import de.dikodam.adventofcode2019.utils.withTimer fun main() { val (passwordRange, setupDuration) = withTimer { val (start, end) = day04input.split("-").map { it.toInt() } (start..end) } val (t1V...
0
Kotlin
0
0
6db72123172615f4ba5eb047cc2e1fc39243adc7
2,191
adventofcode2019
MIT License
src/main/kotlin/before/test/problem1/test.kt
K-Diger
642,489,846
false
{"Kotlin": 105578, "Java": 57609}
package before.test.problem1 class Solution { fun solution(histogram: Array<IntArray>): Int { var result = 1 val height = histogram.size val width = histogram[0].size var histogramConversionAxis = Array(width) { IntArray(height) } histogramConversionAxis = setHistogramCon...
0
Kotlin
0
0
2789df5993923f7aab6e8774a7387ab65c29060a
1,638
algorithm-rehab
MIT License
src/main/kotlin/aoc2020/ex11.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
fun main() { assert1() assert2() val input = readInputFile("aoc2020/input11") occupiedOnStabilization(matFromInput(input)) { it.update() } occupiedOnStabilization(matFromInput(input)) { it.update3() } } fun Mat.update2() { val r = Mat(array.mapIndexed { rIndex, row -> row.mapIndexed ...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
8,483
AOC-2021
MIT License
src/lib/Combinatorics.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
package lib object Combinatorics { fun <T> permutationsWithReplacement(input: Set<T>, n: Int): List<List<T>> = if (n <= 0) listOf(emptyList()) else input.flatMap { first -> permutationsWithReplacement(input, n - 1).map { rest -> listOf(first) + rest } } fun <T> permutations(input: ...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,001
aoc-kotlin
Apache License 2.0
src/Day04.kt
avarun42
573,407,145
false
{"Kotlin": 8697}
import day04.SectionAssignment fun main() { fun List<String>.toSectionAssignmentPairs(): List<Pair<SectionAssignment, SectionAssignment>> { return this.splitEach(",").map { elfPair -> elfPair.splitEach("-").map { SectionAssignment(it) }.toPair() } } fun part1(input: List<String...
0
Kotlin
0
1
622d022b7556dd0b2b3e3fb2abdda1c854bfe3a3
890
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/kosmx/aoc23/graphs/BFS.kt
KosmX
726,056,762
false
{"Kotlin": 32011}
package dev.kosmx.aoc23.graphs import java.io.File import java.util.PriorityQueue operator fun List<String>.get(x: Int, y: Int): Char = this.getOrNull(y)?.getOrNull(x) ?: '.' operator fun List<String>.get(xy: Pair<Int, Int>): Char = this[xy.first, xy.second] operator fun List<String>.contains(xy: Pair<Int, Int>): B...
0
Kotlin
0
0
ad01ab8e9b8782d15928a7475bbbc5f69b2416c2
4,633
advent-of-code23
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day15.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines import kotlin.math.abs object Day15 : Day { override val input = readInputLines(15).map { SensorBeacon.from(it) } override fun part1(): Int { val y = 10L ...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,220
aoc2022
MIT License
day19/kotlin/corneil/src/main/kotlin/solution.kt
jensnerche
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271053, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust":...
package com.github.corneil.aoc2019.day19 import com.github.corneil.aoc2019.intcode.Program import com.github.corneil.aoc2019.intcode.readProgram import java.io.File import java.io.PrintWriter import java.io.StringWriter data class Coord(val x: Int, val y: Int) class Grid(val cells: MutableMap<Coord, Char> = mutableM...
0
HTML
0
0
a84c00ddbeb7f9114291125e93871d54699da887
4,201
aoc-2019
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day11.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.P import se.saidaspen.aoc.util.neighbors fun main() = Day11.run() object Day11 : Day(2021, 11) { override fun part1(): Any { val lines = input.lines() val octs = mutableMapOf<P<Int, Int>, Int>() ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,877
adventofkotlin
MIT License
src/Day21.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import java.util.* enum class Operation(val c: Char) { PLUS('+'), MINUS('-'), MUL('*'), DIV('/'); companion object { fun parse(c: Char): Operation { return when(c) { '+' -> PLUS '-' -> MINUS '*' -> MUL '/' -> DIV ...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
6,398
AoC-2022
Apache License 2.0
day04/Kotlin/day04.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* fun print_day_4() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 4" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime().exec("figlet Giant Squid -c -f small") ...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
2,612
AOC2021
Apache License 2.0
src/questions/SortCharByFrequency.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBeOneOf import java.util.* /** * * Given a string s, sort it in decreasing order based on the frequency of the characters. * The frequency of a character is the number of times it appears in the string. * Return the sorted string. If the...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,653
algorithms
MIT License
kotlin/src/com/s13g/aoc/aoc2020/Day18.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 18: Operation Order --- * https://adventofcode.com/2020/day/18 */ class Day18 : Solver { /** Either 'v' value or sub-group 'g' are allowed, but not both. */ private data class Expr(val op: Char, val v: Long, val g:...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,220
euler
Apache License 2.0
code/day_07/src/jvm8Main/kotlin/task1.kt
dhakehurst
725,945,024
false
{"Kotlin": 105846}
package day_07 val map1 = mapOf( "A" to 14, "K" to 13, "Q" to 12, "J" to 11, "T" to 10 ) data class Hand1( val cards: String, val bid: Int ) : Comparable<Hand1> { val cardValues = cards.map { map1[it.toString()] ?: it.toString().toInt() } val grouped = cardValues.groupBy { it } ...
0
Kotlin
0
0
be416bd89ac375d49649e7fce68c074f8c4e912e
1,990
advent-of-code
Apache License 2.0
src/net/sheltem/pe/Task11.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.pe import net.sheltem.common.* import net.sheltem.common.Direction8.* fun main() { input .lines() .map { it.split(" ") .filter { string -> string.isNotBlank() } .map { number -> number.toLong() } ...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,320
aoc
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day13.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import io.github.clechasseur.adventofcode.util.permutations import io.github.clechasseur.adventofcode.y2015.data.Day13Data object Day13 { private val input = Day13Data.input private val happyRegex = """^(\w+) would (gain|lose) (\d+) happiness units by sitting ...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
1,966
adventofcode2015
MIT License
2021/01/24/huisam/129_SumRootToLeafNumbers.kt
Road-of-CODEr
323,110,862
false
null
package com.huisam.kotlin.leetcode /** * LeetCode Problem * @see <a href="https://leetcode.com/problems/sum-root-to-leaf-numbers/submissions/">문제링크</a> */ data class TreeNode(var `val`: Int) { var left: TreeNode? = null var right: TreeNode? = null } class Solution3 { fun sumNumbers(root: TreeNode?): In...
1
Java
25
22
cae1df83ac110519a5f5d6b940fa3e90cebb48c1
1,232
stupid-week-2021
MIT License
src/main/kotlin/com/sk/set3/399. Evaluate Division.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set3 class Solution399 { fun calcEquation(equations: List<List<String>>, values: DoubleArray, queries: List<List<String>>): DoubleArray { val map = HashMap<String, Node>() for (i in equations.indices) { val eq = equations[i] val first = eq[0] val s...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,114
leetcode-kotlin
Apache License 2.0
src/main/kotlin/days/Day7.kt
hughjdavey
159,955,618
false
null
package days import util.addAndGet class Day7 : Day(7) { override fun partOne(): String { val steps = parseSteps(inputList) val execution = (0 until steps.size).map { i -> val eligibleSteps = steps.filterNot { it.done } .filter { it.dependencies.isEmpty() } ...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
3,162
aoc-2018
Creative Commons Zero v1.0 Universal
leetcode-75-kotlin/src/main/kotlin/CanPlaceFlowers.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * You have a long flowerbed in which some of the plots are planted, and some are not. * However, flowers cannot be planted in adjacent plots. * * Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, * return true if n new flowers can be planted i...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,291
leetcode-75
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2023/calendar/day23/Day23.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2023.calendar.day23 import arrow.core.fold import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import kotlin.math.max class Day23 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun partOne(filename: String) = generato...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
4,559
advent-of-code
MIT License
src/main/kotlin/g2401_2500/s2428_maximum_sum_of_an_hourglass/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2428_maximum_sum_of_an_hourglass // #Medium #Array #Matrix #Prefix_Sum #2023_07_05_Time_274_ms_(50.00%)_Space_40.5_MB_(100.00%) class Solution { fun maxSum(grid: Array<IntArray>): Int { val m = grid.size val n = grid[0].size var res = 0 for (i in 0 until m) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,349
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/PossibleBipartition.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,107
kotlab
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day3.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay // https://adventofcode.com/2021/day/2 /* correct results: gamma 1114, epsilon 2981, multiplied 3320834 oxygen: 101011101111, decimal: 2799 co2: 011001000001, decimal: 1601 multiply: 4481199 */ fun main() { Day3().run() } class Day3 : BaseDay() { over...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
2,465
advent-of-code
Apache License 2.0
src/aoc2022/day05/AoC05.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day05 import readAll class Cmd(txt: String) { val qty: Int val c1: Int val c2: Int init { val s = txt.split(" ") qty = s[1].toInt() c1 = s[3].toInt() - 1 c2 = s[5].toInt() - 1 } companion object { fun fromTxt(txt: String) = txt.lines().map { Cmd(it) } } } class Stacks(txt: String) ...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
1,503
aoc2022
Apache License 2.0
src/main/kotlin/day8/Day8.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day8 import readToList private val input = readToList("day8.txt") fun main() { val validDigits = input.map { line -> val (signalStr, digitStr) = line.split(" | ") val signals = signalStr.split(" ").map { Digit(it) }.filter { validLengths.contains(it.sorted.size) }.toSet() val digi...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
1,037
aoc2021
Apache License 2.0
kotlin/src/katas/kotlin/eightQueen/EightQueen10.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.eightQueen import org.hamcrest.CoreMatchers.equalTo import org.junit.Assert.assertThat import org.junit.Test import java.lang.Math.abs class EightQueen10 { @Test fun `find all solutions for eight queen puzzle`() { assertThat(findAllSolutions(boardSize = 0), equalTo(listOf( ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,106
katas
The Unlicense
src/Lesson4CountingElements/MaxCounters.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * @param N * @param A * @return */ fun solution(N: Int, A: IntArray): IntArray? { var maxCounter = 0 var lastMaxCounter = 0 val resultCounters = IntArray(N) for (i in A.indices) { if (A[i] <= N) { resultCounters[A[i] - 1] = java.lang.Math.max(resultCounters[A[i] - ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,355
Codility-Kotlin
Apache License 2.0
src/Day03.kt
arksap2002
576,679,233
false
{"Kotlin": 31030}
fun main() { fun part1(input: List<String>): Int { var result = 0 for (bag in input) { val hashSet = mutableSetOf<Char>() for (i in bag.indices) { if (i < bag.length / 2) { hashSet.add(bag[i]) } else { if...
0
Kotlin
0
0
a24a20be5bda37003ef52c84deb8246cdcdb3d07
1,747
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
fun main() { fun getRangeSets(input: List<Pair<String, String>>) = input.map { (first, second) -> first.toRangeSet() to second.toRangeSet() } fun part1(input: List<Pair<String, String>>) = getRangeSets(input).count { (f, s) -> (f union s).size in listOf(f.size, s.size) } fun part2...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
648
advent-of-code-2022
Apache License 2.0
src/Day08.kt
Sagolbah
573,032,320
false
{"Kotlin": 14528}
import kotlin.math.max import kotlin.streams.toList fun main() { fun processInput(input: List<String>): List<List<Int>> { val res = mutableListOf<List<Int>>() for (line in input) { res.add(line.codePoints().map { x -> x - '0'.code }.toList()) } return res } fun...
0
Kotlin
0
0
893c1797f3995c14e094b3baca66e23014e37d92
2,888
advent-of-code-kt
Apache License 2.0
src/main/kotlin/day10/part2/main.kt
TheMrMilchmann
225,375,010
false
null
/* * Copyright (c) 2019 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
9d6e2adbb25a057bffc993dfaedabefcdd52e168
3,674
AdventOfCode2019
MIT License
src/com/ssynhtn/medium/MaximumSubarray.kt
ssynhtn
295,075,844
false
{"Java": 639777, "Kotlin": 34064}
package com.ssynhtn.medium class MaximumSubarray { fun maxSubArrayDivConquer(nums: IntArray): Int { return maxSubArrayDivConquer(nums, 0, nums.size)[0] // max, left max, right max, total, each requiring at least length one } // end > start fun maxSubArrayDivConquer(nums: IntArray, start: Int, ...
0
Java
0
0
511f65845097782127bae825b07a51fe9921c561
1,907
leetcode
Apache License 2.0
src/Day09.kt
SergeiMikhailovskii
573,781,461
false
{"Kotlin": 32574}
val uniqueItems = mutableSetOf<String>() fun main() { val input = readInput("Day09_test") val snake = Array(10) { arrayOf(0, 0) } input.forEach { val direction = it.split(" ").first() val amount = it.split(" ").last().toInt() for (i in 0 until amount) { when...
0
Kotlin
0
0
c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d
1,806
advent-of-code-kotlin
Apache License 2.0
src/day07/Day07.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day07 import readLines import java.lang.Math.random import java.util.* fun main() { fun getDirectorySizes(input: List<String>): HashMap<String, Int> { val directories = Stack<String>() val directorySizes = HashMap<String, Int>() for (line in input) { val splitLine = li...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,794
aoc2022
Apache License 2.0
src/main/kotlin/g0301_0400/s0321_create_maximum_number/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0321_create_maximum_number // #Hard #Greedy #Stack #Monotonic_Stack #2022_11_12_Time_209_ms_(100.00%)_Space_36.2_MB_(100.00%) class Solution { fun maxNumber(nums1: IntArray, nums2: IntArray, k: Int): IntArray { if (k == 0) { return IntArray(0) } val maxSubNu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,021
LeetCode-in-Kotlin
MIT License
src/main/aoc2018/Day10.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 class Day10(input: List<String>) { private data class Pos(val x: Int, val y: Int) { fun hasNeighbour(allPoints: Set<Pos>): Boolean { return List(3) { nx -> List(3) { ny -> Pos(x - 1 + nx, y - 1 + ny) } } .flatten() .filterNot { it == this ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,054
aoc
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LetterCombinations.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,645
kotlab
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day05.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 class Day05(private val input: List<String>) { fun solvePart1(): Int = solve(false) fun solvePart2(): Int = solve(true) private fun solve(diagonal: Boolean): Int { val lineRegex = Regex("""(\d+),(\d+) -> (\d+),(\d+)""") val map = mutableMapOf<Coordin...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,473
advent-of-code
Apache License 2.0
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day14DockingData.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode import kotlin.math.pow class Day14DockingData(val isFluid: Boolean) { private val memRegex by lazy { """(mem\[)(\d+)(\]\s+\=\s+)(\d+)""".toRegex() } private data class Masks(val defaultMask: List<Pair<Char, Int>>, val fluidMask: List<List<Pair<Char, Int>>>) pr...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
2,594
BrainSqueeze
Apache License 2.0
src/day-7/part-1/solution-day-7-part-1.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import `day-7`.Directory import `day-7`.File import `day-7`.FileSystemItem val root = Directory("/") var currentDirectory = root fun addFileSystemItem(string: String) { if (string.startsWith("dir")) { currentDirectory.content.add(Directory(string.substring(4), parent = currentDirectory)) } else { ...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
1,948
advent-of-code-22
MIT License
src/main/kotlin/com/sbg/vindinium/kindinium/model/board/BoardNavigator.kt
SoulBeaver
23,961,494
false
null
package com.sbg.vindinium.kindinium.model.board import java.util.HashMap import com.sbg.vindinium.kindinium.model.Position import java.util.ArrayList /** * The BoardNavigator knows how to navigate a MetaBoard and create the shortest * path to and from any Position. */ private class BoardNavigator(val metaboard: Me...
0
Kotlin
1
4
9150d6619229db4932494e95c92f6911a7dd3443
3,314
kindinium
Apache License 2.0
src/Day03.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun Char.priority() = (if (this <= 'Z') this - 'A' + 26 else this - 'a') + 1 fun part1(input: List<String>): Int = input.map { rubsack -> rubsack.chunked(rubsack.length / 2, CharSequence::toSet) .reduce(Set<Char>::intersect) .single() }.sumOf(Char::priority) ...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
855
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode2023/day16/day16.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day16 import adventofcode2023.Point import adventofcode2023.line import adventofcode2023.readInput import adventofcode2023.col import kotlin.time.measureTime fun main() { println("day 16") val input = readInput("day16") val time1 = measureTime { val output = findEnergized...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
5,446
adventofcode2023
MIT License
src/net/sheltem/aoc/y2023/Day05.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import kotlinx.coroutines.coroutineScope suspend fun main() { Day05().run() } class Day05 : Day<Long>(35, 46) { override suspend fun part1(input: List<String>): Long = input.toAlmanac().minLocationNumber(input[0].toSeedList()) override suspend fun part2(input: List<String...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,631
aoc
Apache License 2.0
src/main/kotlin/g2201_2300/s2246_longest_path_with_different_adjacent_characters/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2246_longest_path_with_different_adjacent_characters // #Hard #Array #String #Depth_First_Search #Tree #Graph #Topological_Sort // #2023_06_27_Time_828_ms_(100.00%)_Space_53.3_MB_(100.00%) import java.util.LinkedList class Solution { fun longestPath(parent: IntArray, s: String): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,189
LeetCode-in-Kotlin
MIT License
src/Day13Alt.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
import com.beust.klaxon.Klaxon import kotlin.reflect.typeOf fun main() { fun isCorrect(leftList: MutableList<Any>?, rightList: MutableList<Any>?): Boolean? { println("$leftList vs. $rightList") if(leftList == null && rightList == null) { return null } if(leftList?.is...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
2,715
AdventOfCode2022
Apache License 2.0
src/main/kotlin/practicecode/coursera/rational/Rational.kt
mnhmasum
556,253,855
false
null
package practicecode.coursera.rational import java.math.BigInteger import java.math.BigInteger.* class Rational(numerator: BigInteger, denominator: BigInteger) : Comparable<Rational> { val numer: BigInteger val denom: BigInteger init { val divisor = numerator.gcd(denominator) val sign = d...
0
Kotlin
0
0
260b8d1e41c3924bc9ac710bb343107bff748aa0
3,367
ProblemSolvingDaily
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem427/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem427 /** * LeetCode page: [427. Construct Quad Tree](https://leetcode.com/problems/construct-quad-tree/); */ class Solution { /* Complexity: * Time O(N^2) and Space O(LogN) where N is the size of grid; */ fun construct(grid: Array<IntArray>): Node? { ret...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,327
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/io/github/raphaeltarita/days/Day9.kt
RaphaelTarita
433,468,222
false
{"Kotlin": 89687}
package io.github.raphaeltarita.days import io.github.raphaeltarita.structure.AoCDay import io.github.raphaeltarita.util.day import io.github.raphaeltarita.util.inputPath import io.github.raphaeltarita.util.minOfBy import kotlinx.datetime.LocalDate import kotlin.io.path.readLines object Day9 : AoCDay { override v...
0
Kotlin
0
3
94ebe1428d8882d61b0463d1f2690348a047e9a1
3,321
AoC-2021
Apache License 2.0
src/Day09B.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
@file:Suppress("DuplicatedCode") import kotlin.math.abs import kotlin.math.sign fun main() { data class Position(val x: Int, val y: Int) fun adjacent(p: Position, q: Position) = abs(p.x - q.x) <= 1 && abs(p.y - q.y) <= 1 fun parse(input: List<String>) = input.map { line -> line[0] to lin...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
2,122
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/example/calculator/domain/useCase/fractionNumber/FractionNumber.kt
vfadin
611,611,259
false
null
package com.example.calculator.domain.useCase.fractionNumber import com.example.calculator.domain.useCase.INumber import kotlin.math.pow import kotlin.math.sqrt class FractionNumber(numerator: Long, denominator: Long = 1L) : INumber { var numerator = 0L private set var denominator = 1L private...
0
Kotlin
0
0
2b7b275fdf7bfdf6fcd74375332be855aac22034
3,217
Calculator
MIT License
src/2022/Day19alt.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import common.BackTracker import java.io.File import java.util.* import kotlin.math.min fun main() { Day19alt().solve() } class Day19alt { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
5,053
advent-of-code
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec10.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec10 : PuzzleDayTester(10, 2020) { override fun part1() = parse().fold(AdapterWad(), AdapterWad::addAnyAdapter).let { it.threeJolt * it.oneJolt } override fun part2() = parse().fold(mutableListOf(AdapterWad(oneJo...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
1,851
advent-of-code
MIT License
src/leecode/215.kt
DavidZhong003
157,566,685
false
null
package leecode import algorithm.print /** * * @author doive * on 2019/6/20 17:17 */ fun main() { fun findKthLargest(nums: IntArray, k: Int): Int { fun sortKth(nums: IntArray, left: Int, right: Int, position: Int) { if (left > right) { return } val ...
0
Kotlin
0
1
7eabe9d651013bf06fa813734d6556d5c05791dc
3,193
LeetCode-kt
Apache License 2.0
kotlin/problems/src/solution/StringProblems.kt
lunabox
86,097,633
false
{"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966}
package solution import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.collections.HashSet import kotlin.math.abs import kotlin.math.max import kotlin.math.min class StringProblems { /** * https://leetcode-cn.com/problems/is-subsequence/ * 给定字符串 s 和 t ,...
0
Kotlin
0
0
cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9
23,007
leetcode
Apache License 2.0
src/main/kotlin/g1201_1300/s1284_minimum_number_of_flips_to_convert_binary_matrix_to_zero_matrix/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1284_minimum_number_of_flips_to_convert_binary_matrix_to_zero_matrix // #Hard #Array #Breadth_First_Search #Matrix #Bit_Manipulation // #2023_06_08_Time_131_ms_(100.00%)_Space_34.3_MB_(100.00%) import java.util.ArrayDeque import java.util.Queue class Solution { private lateinit var visited: M...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,195
LeetCode-in-Kotlin
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day14.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines object Day14 : Day { override val input = Terrain.of(readInputLines(14)) override fun part1() = input.next { y > input.end }.tiles override fun part2() = input.ne...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,284
aoc2022
MIT License
src/Day09.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.cartesian.point.DataPoint import util.cartesian.point.Direction import util.cartesian.point.Point import util.readInput import kotlin.math.* @OptIn(ExperimentalStdlibApi::class) fun main() { fun part1(input: List<String>): Int { var currentHeadPoint = Point.of(0, 0) var currentTailPoint...
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
2,803
aoc-2022
Apache License 2.0
src/main/kotlin/g2401_2500/s2467_most_profitable_path_in_a_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2467_most_profitable_path_in_a_tree // #Medium #Array #Depth_First_Search #Breadth_First_Search #Tree #Graph // #2023_07_05_Time_850_ms_(100.00%)_Space_103.8_MB_(100.00%) class Solution { fun mostProfitablePath(edges: Array<IntArray>, bob: Int, amount: IntArray): Int { // Time: O(E); S...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,501
LeetCode-in-Kotlin
MIT License
2022/Day20.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { fun mix(input: Array<Pair<Long, Int>>) { val n = input.size for (idx in 0 until n) { val oldI = input.indices.find { input[it].second == idx }!! var newI = (oldI + input[oldI].first) % (n-1) newI = (newI + n-1) % (n-1) if (newI == 0L) newI...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,696
advent-of-code-kotlin
Apache License 2.0
advent-of-code-2021/src/code/day5/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day5 import java.io.File import java.lang.Integer.max import kotlin.math.abs fun main() { doIt("Day 5 Part 1: Test Input", "src/code/day5/test.input", part1); doIt("Day 5 Part 1: Real Input", "src/code/day5/part1.input", part1); doIt("Day 5 Part 2: Test Input", "src/code/day5/test.input", par...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
3,466
misc-dev
MIT License
app/src/main/kotlin/com/resurtm/aoc2023/day16/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day16 fun launchDay16(testCase: String) { val grid = readInputGrid(testCase) val part1 = runBeam(grid, Pos(), Dir.RIGHT).size println("Day 16, part 1: $part1") val part2 = runBeams(grid) println("Day 16, part 2: $part2") } private fun runBeams(gr: Grid): Int { var...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
5,703
advent-of-code-2023
MIT License