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/Day07.kt
bkosm
572,912,735
false
{"Kotlin": 17839}
typealias File = Pair<String, Int> val List<File>.totalSize: Int get() = sumOf { it.second } class ConsoleParser { private val pathToFiles = mutableMapOf<String, MutableList<File>>() private val childLinks = mutableMapOf<String, MutableSet<String>>() private var currentPath = "" val directories: List...
0
Kotlin
0
1
3f9cccad1e5b6ba3e92cbd836a40207a2f3415a4
2,806
aoc22
Apache License 2.0
comet-utils/src/main/kotlin/ren/natsuyuk1/comet/utils/string/FuzzyMatch.kt
StarWishsama
173,288,057
false
{"Kotlin": 676547, "Shell": 1079, "Dockerfile": 577}
package ren.natsuyuk1.comet.utils.string import java.math.BigDecimal import java.math.RoundingMode import kotlin.math.max /** * The Levenshtein distance between two words is the minimum number of * single-character edits (insertions, deletions or substitutions) required to * change one string into the other. * *...
19
Kotlin
21
193
19ed20ec4003a37be3bc2dfc6b55a9e2548f0542
2,596
Comet-Bot
MIT License
src/main/kotlin/_2022/Day07.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun part1(input: List<String>): Int { var node = Node(Node.dir, 0, "/", null, mutableListOf()) val groupedCommands = mutableListOf<List<String>>() var currentCommand = mutableListOf<String>() for (s in input) { if (s.startsWit...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
4,389
advent-of-code
Apache License 2.0
aoc/src/Scratch.kt
aragos
726,211,893
false
{"Kotlin": 16232}
import java.io.File import kotlin.math.pow fun main() { println(countPoints()) println(countCards()) } private fun countCards(): Int { val cardCount = (0..211).associateWith { 1 }.toMutableMap() File("inputs/scratch.txt").readLines().mapIndexed() { ix, line -> if (line.isBlank()) return@mapIndexed v...
0
Kotlin
0
0
7bca0a857ea42d89435adc658c0ff55207ca374a
1,069
aoc2023
Apache License 2.0
hackerrank/knightl-on-chessboard/Solution.kts
shengmin
5,972,157
false
null
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
Java
18
20
08e65546527436f4bd2a2014350b2f97ac1367e7
2,290
coding-problem
MIT License
src/main/kotlin/g2701_2800/s2800_shortest_string_that_contains_three_strings/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2701_2800.s2800_shortest_string_that_contains_three_strings // #Medium #String #Greedy #Enumeration #2023_08_06_Time_259_ms_(100.00%)_Space_38_MB_(100.00%) class Solution { fun minimumString(a: String, b: String, c: String): String { val ar = a.toCharArray() val br = b.toCharArray() ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,145
LeetCode-in-Kotlin
MIT License
src/Day07.kt
acrab
573,191,416
false
{"Kotlin": 52968}
import com.google.common.truth.Truth.assertThat fun main() { fun calculateDirectorySize( currentPath: String, iterator: Iterator<String>, directoryMap: MutableMap<String, Int> ): Int { var totalFileSize = 0 val subdirectories = mutableMapOf<String, Int>() while ...
0
Kotlin
0
0
0be1409ceea72963f596e702327c5a875aca305c
2,725
aoc-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2021/Day7.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.advent2021.Day5.Companion.diff import com.chriswk.aoc.util.report import com.chriswk.aoc.util.reportNano import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger typealias Crab = Int class Day7: Adven...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,919
adventofcode
MIT License
src/questions/SimplifiedFraction.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.assertIterableSameInAnyOrder import utils.shouldBe /** * Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) * such that the denominator is less-than-or-equal-to n. The fractions can be in any order. * * [...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,823
algorithms
MIT License
src/Day13.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import utils.readInputAsText fun main() { val input = readInputAsText("day13_input") val packetPairs = input.splitToSequence("\n\n") .map { it.split("\n") } .map { (left, right) -> PacketValue(left) to PacketValue(right) } val result1 = packetPairs.mapIndexed { index, (left, right) -> ind...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
2,851
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2022/day16/Day16.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day16 import com.jacobhyphenated.advent2022.Day import java.util.PriorityQueue /** * Day 16: Proboscidea Volcanium * * The cave system contains several different valves connected by tunnels. * Each valve releases some amount of pressure per minute once it's been opened. * ...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
8,795
advent2022
The Unlicense
src/main/kotlin/day03/Solution.kt
TestaDiRapa
573,066,811
false
{"Kotlin": 50405}
package day03 import java.io.File fun getItemsPriorities() = ('a'..'z').foldIndexed(mapOf<Char, Int>()) { index, acc, c -> acc + (c to index+1) } + ('A' .. 'Z').foldIndexed(mapOf()) { index, acc, c -> acc + (c to index + 27) } fun getItemsFromFile() = File("src/main/kotlin/day03/input...
0
Kotlin
0
0
b5b7ebff71cf55fcc26192628738862b6918c879
1,599
advent-of-code-2022
MIT License
src/main/kotlin/com/tecacet/komplex/DivisionAlgorithm.kt
algorythmist
135,095,131
false
{"Kotlin": 26313}
package com.tecacet.komplex /** * Division of polynomials using Euclid's algorithm * @return the quotient and remainder as a pair */ fun divide(dividend: ComplexPolynomial, divisor: ComplexPolynomial): Pair<ComplexPolynomial, ComplexPolynomial> { var quotient = ComplexPolynomial.ZERO var remaind...
1
Kotlin
0
2
9bf0f453d852305dd2c53ceaa0856fb8eb0d6499
1,465
komplex
MIT License
kotlin/src/main/kotlin/year2023/Day10.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 import java.util.* fun main() { val input = readInput("Day10") Day10.part1(input).println() Day10.part2(input).println() } object Day10 { data class Pipe(val row: Int, val column: Int, val value: Char, val previousPipe: Pipe? = null) { fun getDistanceToStart(): Int { ...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
7,740
advent-of-code
MIT License
AdventOfCodeDay14/src/nativeMain/kotlin/Day14.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
class Day14(lines:List<String>) { private val lastChar = lines.first().last() private val template: Map<String, Long> = parseTemplate(lines.first()) private val rules: Map<String, Char> = parseRules(lines) private fun parseTemplate(input: String): Map<String, Long> = input .windowed...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
1,711
AdventOfCode2021
The Unlicense
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day24.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.* fun PuzzleSet.day24() = puzzle { val charGrid = inputLines.asCharGrid() val from = charGrid.row(0).single { charGrid[it] == '.' } val to = charGrid.row(charGrid.height - 1).single { charGrid[it] == '.' } data class Blizard(val pos: Poi...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,229
advent-of-code
The Unlicense
src/main/kotlin/io/dmitrijs/aoc2022/Day14.kt
lakiboy
578,268,213
false
{"Kotlin": 76651}
package io.dmitrijs.aoc2022 class Day14(input: List<String>) { private val points = input .map { s -> s.toPath() } .flatMap { path -> path.toLines() } .flatMap { line -> line.toPoints() } .associateWith { false } fun puzzle1() = Board().unitsOfSand() fun puzzle2() = Board(...
0
Kotlin
0
1
bfce0f4cb924834d44b3aae14686d1c834621456
2,502
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g1001_1100/s1048_longest_string_chain/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1048_longest_string_chain // #Medium #Array #String #Hash_Table #Dynamic_Programming #Two_Pointers // #2023_05_28_Time_273_ms_(75.00%)_Space_46.5_MB_(50.00%) class Solution { fun longestStrChain(words: Array<String>): Int { val lenStr = arrayOfNulls<MutableList<String>?>(20) fo...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,593
LeetCode-in-Kotlin
MIT License
graph/Dijkstra.kt
wangchaohui
737,511,233
false
{"Kotlin": 36737}
class BinaryHeap<T : BinaryHeap.Item>(private val comparator: Comparator<T>) { interface Item { var binaryHeapPos: Int } private val a = mutableListOf<T>() fun add(item: T) { item.binaryHeapPos = a.size a.add(item) popUp(item.binaryHeapPos) } fun peek(): T? = ...
0
Kotlin
0
0
241841f86fdefa9624e2fcae2af014899a959cbe
2,451
kotlin-lib
Apache License 2.0
src/Day01.kt
bjornchaudron
574,072,387
false
{"Kotlin": 18699}
fun main() { fun part1(input: List<String>): Int { return sortByTotalCalories(input).first() } fun part2(input: List<String>): Int { return sortByTotalCalories(input).subList(0, 3).sum() } // test if implementation meets criteria from the description, like: val testInput = read...
0
Kotlin
0
0
f714364698966450eff7983fb3fda3a300cfdef8
1,060
advent-of-code-2022
Apache License 2.0
src/Day03.kt
KorneliuszBarwinski
572,677,168
false
{"Kotlin": 6042}
fun main() { fun convertToCodeInt(symbol: Char) : Int = if (symbol.isUpperCase()) symbol.hashCode() - 38 else symbol.hashCode() - 96 fun part1(input: String): Int = input.split("\r\n").sumOf { rucksack -> val firstCompartment = rucksack.substring(0, rucksack.length / 2).toSet() val secondComp...
0
Kotlin
0
0
d90175134e0c6482986fcf3c144282f189abc875
861
AoC_2022
Apache License 2.0
leetcode2/src/leetcode/permutations.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 46. 全排列 * https://leetcode-cn.com/problems/permutations/ * 给定一个没有重复数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/permutations 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 */ ob...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,594
leetcode
MIT License
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day15/Day15.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day15 import eu.janvdb.aocutil.kotlin.Move import eu.janvdb.aocutil.kotlin.findShortestPath import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readNonSeparatedDigits const val FILENAME = "input15.txt" fun main() { runWithFactor(1) runWithFactor(5) } private f...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,309
advent-of-code
Apache License 2.0
src/adventofcode/blueschu/y2017/day14/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day14 import adventofcode.blueschu.y2017.day10.knotHash import java.util.* import kotlin.test.assertEquals fun input(): String = "ljoxqyyw" fun main(args: Array<String>) { assertEquals("33efeb34ea91902bb2f59c9920caa6cd", knotHash("AoC 2017")) assertEquals(8108, part1(gene...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
4,147
Advent-Of-Code
MIT License
gcj/y2020/round1a/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1a private fun solve(impossible: String = "*"): String { return List(readInt()) { readLn() }.fold("**") { s, t -> val split = listOf(s, t).map { it.split("*") } val prefix = unite(split.map { it[0] }, String::startsWith) ?: return impossible val suffix = unite(split.map { it.last() }, Str...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
787
competitions
The Unlicense
src/main.kt
dasuppan
254,854,694
false
{"Kotlin": 3227}
import java.io.File const val SEPARATOR = "," val EXPECTED_FORMAT_REGEX = Regex("\\w+($SEPARATOR)\\d{1,2}") // Implements the Karmarkar-Karp algorithm // Good read: http://bit-player.org/wp-content/extras/bph-publications/AmSci-2002-03-Hayes-NPP.pdf fun main(args: Array<String>) { if (args.size != 2) throw Error(...
0
Kotlin
0
0
8c1952620eca29fc94119b2dc7baa9cf1046a676
3,096
fair-teams-matcher
MIT License
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/problems/FindIfAnyPairProducesSum.kt
FunkyMuse
168,687,007
false
{"Kotlin": 1728251}
package dev.funkymuse.datastructuresandalgorithms.problems import dev.funkymuse.datastructuresandalgorithms.search.binarySearch /** * Methods are assuming the sorted list. */ /** * O(n^2) worst time complexity */ fun findAnyPairProducesSumNaive(t: List<Int>, sum: Int): Pair<Int, Int> { t.forEachIndexed { in...
0
Kotlin
92
771
e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1
1,461
KAHelpers
MIT License
archive/2022/Day20.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 3L private const val EXPECTED_2 = 1623178306L /** * Looks like a simple problem once it's done, but I lost a lot of time before I realized that * the modulo should be N-1 instead of N and (for part 2) that there are duplicate numbers so * you need to store the original index in additi...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,468
advent-of-code-2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2021/day05/day5.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day05 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val strLines = inputFile.bufferedReader().readLines() val lines = parseLines(strLines) val map1 = createVentMap(lines.filter { it.isHorizontal || it.isVertical }) ...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,455
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/TallestBillboard.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,426
kotlab
Apache License 2.0
src/main/kotlin/year2023/Day04.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 class Day04 { fun Pair<Set<Int>, Set<Int>>.wins() = first.intersect(second).size fun part1(input: String): Int { return parseCards(input) .map { 1 shl (it.wins() - 1) } .sum() } fun part2(input: String): Int { val cards = parseCards(input) ...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
1,207
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day07.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput private val cardOrder = charArrayOf('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A').reversed() private val cardOrderWithJokerRule = charArrayOf('J', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'Q', 'K', 'A').reversed() private enum class Type { FiveOfAKind, ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
5,104
adventOfCode
Apache License 2.0
src/test/kotlin/no/nav/eessi/pensjon/prefill/person/LongestSequenceTest.kt
navikt
358,172,246
false
{"Kotlin": 841438, "Shell": 1714, "Dockerfile": 149}
package no.nav.eessi.pensjon.prefill.person import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test data class Solution(val I: Int = 0, val N: Int = 0, val C: Char? = null) operator fun Solution.compareTo(other: Solution) = this.N.compareTo(other.N) operator fun Solution.plus(int: Int)...
3
Kotlin
0
2
7d88d2535c8a6632561109a31130d040dd458f5a
1,566
eessi-pensjon-prefill
MIT License
src/main/kotlin/day09/Day09.kt
mdenburger
317,466,663
false
null
package day09 import java.io.File fun main() { val numbers = File("src/main/kotlin/day09/day09-input.txt").readLines().map { it.toLong() }.toLongArray() val window = 25 val invalidNumber = answer1(numbers, window) println("Answer 1: $invalidNumber") println("Answer 2: " + answer2(numbers, invalid...
0
Kotlin
0
0
b965f465cad30f949874aeeacd8631ca405d567e
1,634
aoc-2020
MIT License
src/main/kotlin/se/brainleech/adventofcode/aoc2022/Aoc2022Day04.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2022 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readLines import se.brainleech.adventofcode.verify class Aoc2022Day04 { private fun String.idleElves(intersects: Boolean = false): Int { return this.split(",") .asSequence() ...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
1,480
adventofcode
MIT License
src/Day3.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<List<String>> { return input.map { it.chunked(it.length / 2) } } fun part1(input: List<String>): Int { val rucksacks = parse(input) return rucksacks.map { rucksack -> val (compartment1, compartment2) = rucksack ...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
817
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2023/Day16.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay import aoc2023.Day16.Dir.* import util.Vec2 import util.illegalInput import util.plus // https://adventofcode.com/2023/day/16 object Day16 : AoCDay<Int>( title = "The Floor Will Be Lava", part1ExampleAnswer = 46, part1Answer = 7210, part2ExampleAnswer = 51, part2Answe...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
3,589
advent-of-code-kotlin
MIT License
src/Day25.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun nums(): List<String> { return readInput("Day25") } val snafuDigit = mapOf( '2' to 2, '1' to 1, '0' to 0, '-' to -1, '=' to -2 ) private fun snafu2Dec(n: String): Long { var base = 1L var res = 0L n.reversed().forEach { c -> res += base * snafuDigit[c]!! ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
810
advent-of-code-2022
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day04.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Long.parseLong private fun part1(lines: List<String>) { var sum = 0L lines.forEach { line -> val parts = line.split(":") val numbers = parts[1].split("|") val winning = numbers[0].split(" ") .map { it.trim() } .fil...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
1,583
advent-of-code
MIT License
aoc-2015/src/main/kotlin/nl/jstege/adventofcode/aoc2015/days/Day18.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2015.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.Point import nl.jstege.adventofcode.aoccommon.utils.extensions.transformTo import java.util.* /** * * @author <NAME> */ class Day18 : Day(title = "Like a GIF For Your Yard") { ...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
3,162
AdventOfCode
MIT License
src/main/kotlin/aoc2023/Day09.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils fun main() { val testInput = """0 3 6 9 12 15 1 3 6 10 15 21 10 13 16 21 30 45""".trimIndent().split("\n") fun Iterable<Int>.differences() = zip(drop(1)).map { it.second - it.first } fun Iterable<Int>.differencesTable() = generateSequence(this) { it.differe...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,389
aoc-2022-kotlin
Apache License 2.0
src/Day01.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
fun main() { fun part1(input: List<String>): Int { var maxValue = 0 var newMax = 0 input.forEachIndexed{ index, element -> if (element.isEmpty()) { if (newMax > maxValue) { maxValue = newMax } newMax = 0 ...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
1,340
aoc-2022-in-kotlin
Apache License 2.0
2021/src/test/kotlin/Day22.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.math.abs import kotlin.test.Test import kotlin.test.assertEquals class Day22 { data class Cuboid(val minX: Int, val maxX: Int, val minY: Int, val maxY: Int, val minZ: Int, val maxZ: Int) { val initialization get() = minX >= -50 && maxX <= 50 && minY >= -50 && maxY <= 50 && minZ >= -50 && maxZ...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
3,359
adventofcode
MIT License
src/day_1/kotlin/Day1.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
// AOC Day 1 data class Elf(var totalCalories: Int) fun part1(elves: Collection<Elf>) { val elfWithMostCalories = elves.maxByOrNull { it.totalCalories } ?: throw IllegalArgumentException("No elf provided") val topElfTotalCalories = elfWithMostCalories.totalCalories println("Part 1: The elf with ...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
1,167
AdventOfCode2022
MIT License
src/day21/Day21.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day21 import readInput fun main() { data class Operation(val op1: String, val op2: String, val operator: String) data class Data(val numbers: MutableMap<String, Long> = mutableMapOf(), val operations: MutableMap<String, Operation> = mutableMapOf()) fun parseInput(input: List<String>) = input.fo...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
1,801
aoc-2022
Apache License 2.0
src/main/kotlin/Day11.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
class Day11 { fun solvePart1(input: String): Int { // parse the input val monkeys = input.split("\n\n") .map { monkey -> Monkey( items = getListOfItems(monkey), operator = getOperator(monkey), worryMultiplier ...
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
4,572
aoc-2022-kotlin
Apache License 2.0
src/com/mrxyx/algorithm/BinarySearch.kt
Mrxyx
366,778,189
false
null
package com.mrxyx.algorithm /** * 二分查找 */ class BinarySearch { /** * 二分查找 * https://leetcode-cn.com/problems/binary-search/ */ fun binarySearch(nums: IntArray, target: Int): Int { if (nums.isEmpty()) return -1 var left = 0 var right = nums.size - 1 while (left ...
0
Kotlin
0
0
b81b357440e3458bd065017d17d6f69320b025bf
1,887
algorithm-test
The Unlicense
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day11Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith private fun solution1(input: String) = solve(input, 20, 3L) private fun solution2(input: String) = sol...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,639
adventofcode-kotlin
MIT License
kotlin/basics/src/main/kotlin/ElementSort.kt
suzp1984
65,159,392
false
{"C++": 29471, "Java": 26106, "Kotlin": 10984, "Scala": 9694, "JavaScript": 3248, "CMake": 442, "Swift": 171}
package io.github.suzp1984.algorithms import java.util.* import kotlin.math.min fun <T> Array<T>.swap(i : Int, j : Int) { val t = this[i] this[i] = this[j] this[j] = t } fun <T : Comparable<T>> Array<T>.selectionSort() { indices.forEach { i -> var minIndex = i (i + 1 until size) ...
0
C++
0
0
ea678476a4c70e5135d31fccd8383fac989cc031
5,181
Algorithms-Collection
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/bst_validation/ValidateBST.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.bst_validation import katas.kotlin.leetcode.TreeNode import datsok.shouldEqual import org.junit.Test import java.util.* import kotlin.Int.Companion.MAX_VALUE import kotlin.Int.Companion.MIN_VALUE /** * ✅ https://leetcode.com/problems/validate-binary-search-tree */ class ValidateBSTTest...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,694
katas
The Unlicense
src/main/kotlin/aoc2019/PlanetOfDiscord.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.nonEmptyLines import kotlin.math.pow fun planetOfDiscord(input: String): Int { var grid = BugGrid(input) val seen = mutableSetOf<BugGrid>() while (true) { grid = grid.step() if (!seen.add(grid)) break } ...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
4,274
advent-of-code
MIT License
year2020/day21/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day21/part1/Year2020Day21Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 21: Allergen Assessment --- You reach the train's last stop and the closest you can get to your vacation island without getting wet. There aren't even any boats here, but nothing can stop you now: you build a raft. You just need a few days' worth of food for your journey. You don't speak the local language...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,859
AdventOfCode
MIT License
2023/day04-25/src/main/kotlin/Day05.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import kotlin.math.min class Day05 { val doubleNewLines = "(\r\n\r\n)|(\n\n)" val newLines = "(\r\n)|(\n)" fun solve1() { val blocks = File("inputs/5.txt").inputStream().bufferedReader().use { it.readText() }.split(doubleNewLines.toRegex()) val seeds = bloc...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
4,699
AdventOfCode
MIT License
src/day07/Day07.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day07 import readInput fun main() { fun part1(input: List<String>): Long { val filesystem = Filesystem() input.map { it.toStatement() } .forEach { it.accept(filesystem) } val threshold: Long = 100_000 return filesystem.root.flatten().filter { it.size() <= thres...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
4,128
advent-of-code-22
Apache License 2.0
advent-of-code/src/main/kotlin/solution/Day05.kt
kressnick25
573,285,946
false
null
package solution import java.lang.Integer.parseInt import java.util.* import kotlin.collections.ArrayDeque private class Operation ( val move: Int, val from: Int, val to: Int, ) { companion object { fun fromStr(input: String): Operation { val re = """move (?<move>\d+) from (?<from>...
0
Rust
0
0
203284a1941e018c7ad3c5d719a6e366013ffb82
3,018
advent-of-code-2022
MIT License
src/main/kotlin/asaad/DayTwo.kt
Asaad27
573,138,684
false
{"Kotlin": 23483}
package asaad import java.io.File class DayTwo(filePath: String) { /* * rock -> Scissors -> paper ->rock... ->win, <-loose */ private val file = File(filePath) private val input = readInput(file) private fun readInput(file: File) = file.readLines() private var part1 = true priva...
0
Kotlin
0
0
16f018731f39d1233ee22d3325c9933270d9976c
2,222
adventOfCode2022
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day12.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.Graph import at.mpichler.aoc.lib.PartSolution open class Part12A : PartSolution() { private lateinit var graph: Graph override fun parseInput(text: String) { graph = Graph() val edges = text.s...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
1,934
advent-of-code-kotlin
MIT License
src/main/java/challenges/cracking_coding_interview/trees_graphs/first_common_ancestor/Question.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.first_common_ancestor import challenges.util.TreeNode /** * Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. * Avoid storing additional nodes in a data structure. * NOTE: This is not necessarily a binary se...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,221
CodingChallenges
Apache License 2.0
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day04/Day04.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2020.day04 import eu.janvdb.aocutil.kotlin.readGroupedLines val fieldRegex = Regex("(\\S+):(\\S+)") val yearRegex = Regex("^\\d{4}$") val heightRegex = Regex("^(\\d+)(cm|in)$") val hairColorRegex = Regex("^#[0-9a-f]{6}$") val eyeColorRegex = Regex("^amb|blu|brn|gry|grn|hzl|oth$") val passportIdRe...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,112
advent-of-code
Apache License 2.0
src/main/kotlin/g0601_0700/s0689_maximum_sum_of_3_non_overlapping_subarrays/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0689_maximum_sum_of_3_non_overlapping_subarrays // #Hard #Array #Dynamic_Programming #2023_02_20_Time_248_ms_(100.00%)_Space_37.6_MB_(100.00%) class Solution { fun maxSumOfThreeSubarrays(nums: IntArray, k: Int): IntArray { val len = nums.size if (len < 3 * k) { retu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,996
LeetCode-in-Kotlin
MIT License
2021/src/main/kotlin/Day10.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day10(private val input: List<String>) { private val pairs = setOf("()", "[]", "<>", "{}") private val closing = setOf(')', ']', '}', '>') private val points = mapOf( ')' to 3L, ']' to 57L, '}' to 1197L, '>' to 25137L, '(' to 1L, '[' to 2L, '{...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,297
adventofcode-2021-2025
MIT License
src/Day10.kt
Totwart123
573,119,178
false
null
fun main() { data class MutablePair<A, B>(var first: A, var second: B) fun part1(input: List<String>): Int { val iterator = input.iterator() var cycles = 0 var register = 1 val signalStrength = mutableMapOf<Int, Int>() var maxCycles = 0 var currentExecution: ...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
4,290
AoC
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day12.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Integer.parseInt const val DAMAGED = '#' const val UNKNOWN = '?' const val WORKING = '.' data class ComputationKey(val lineIndex: Int, val numberIndex: Int) private fun solve(line: String, numbers: List<Int>): Long { return solve((line + ".").replace("[.]+".toRegex...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
3,492
advent-of-code
MIT License
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day4PassportProcessing.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode class Day4PassportProcessing { private val mandatoryFields = setOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid") private val pidRegex = """^\d{9}$""".toRegex() private val hgtRegex = """^(\d+)(cm|in)$""".toRegex() private val hclRegex = """#[a-f0-9]{6}"""....
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
2,393
BrainSqueeze
Apache License 2.0
src/main/kotlin/com/staricka/adventofcode2022/Day24.kt
mathstar
569,952,400
false
{"Kotlin": 77567}
package com.staricka.adventofcode2022 import com.staricka.adventofcode2022.Day24.Zone.Companion.parseZone class Day24 : Day { override val id = 24 enum class Direction(val vec: Pair<Int, Int>) { UP(Pair(-1, 0)), RIGHT(Pair(0, 1)), DOWN(Pair(1,0)), LEFT(Pair(0,-1)); fun step(i: Int, j: Int): Pair<Int, In...
0
Kotlin
0
0
2fd07f21348a708109d06ea97ae8104eb8ee6a02
3,308
adventOfCode2022
MIT License
ceria/05/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File; fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Int { var seatIDs = mutableListOf<Int>() for (boardingPass in input) ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
2,082
advent-of-code-2020
MIT License
src/main/kotlin/ru/timakden/aoc/year2022/Day11.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.lcm import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day11.Monkey.Companion.toMonkey /** * [Day 11: Monkey in the Middle](https://adventofcode.com/2022/day/11). */ object Day11 { @JvmStatic ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
5,183
advent-of-code
MIT License
src/main/java/NumberSolver.kt
Koallider
557,760,682
false
{"Kotlin": 8930}
import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashSet class NumberSolver @JvmOverloads internal constructor( var target: Int, var nums: List<Int>, var findAllSolutions: Boolean = true ) { private val intRegex = """^[+-]*\d*$""".toRegex() var mem: HashMap<String, ...
0
Kotlin
0
0
9faa2e3e14d1daba1d6a9e4530f03b22ddeace77
4,502
8OO10CDC
Apache License 2.0
src/main/kotlin/men/zhangfei/leetcode/medium/Problem0003.kt
fitzf
257,562,586
false
{"Kotlin": 9251}
package men.zhangfei.leetcode.medium /** * 3. 无重复字符的最长子串 * https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ */ class Problem0003 { companion object { /** * 滑动窗口算法 * 1. 使用 HashSet 作为滑动窗口,存储字符 * 2. 设置窗口的左边和右边索引为 0 val l = 0, val r = 0 *...
1
Kotlin
0
0
a2ea7df7c1e4857808ab054d253dea567049658a
3,082
leetcode
Apache License 2.0
src/main/aoc2020/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 import AMap import Pos import toDirection class Day24(input: List<String>) { // Represent the hex grid as a normal 2 dimensional map (there are just some limits on adjacency) val map = AMap().apply { input.forEach { line -> val pos = parse(line) val current = t...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,489
aoc
MIT License
src/main/kotlin/year_2022/Day10.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2022 import utils.readInput fun main() { fun part1(input: List<String>): Int { val cycleValueMap = mutableMapOf<Int, Int>() cycleValueMap[0] = 1 var cycleCount = 0 input.forEach { if (it.startsWith("noop")) { ++cycleCount ...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
3,617
advent-of-code
Apache License 2.0
src/main/kotlin/g0901_1000/s0963_minimum_area_rectangle_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0963_minimum_area_rectangle_ii // #Medium #Array #Math #Geometry #2023_05_04_Time_183_ms_(100.00%)_Space_38.7_MB_(66.67%) import kotlin.math.abs class Solution { fun minAreaFreeRect(points: Array<IntArray>): Double { val map: MutableMap<Int, MutableSet<Int>> = HashMap() var ar...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,956
LeetCode-in-Kotlin
MIT License
Futoshiki Solver/Main.kt
JChoPop
429,859,326
false
{"Kotlin": 20296}
// By HJC 2021-11-21 // 5x5 Futoshiki (Inequality/Unequal Puzzle) // only works when solution exists... for now... // const val puzzle = """ |0-0>0-0-0| |- - - - -| |0-0-0-0-0| |v v ^ - -| |0-0>0-0-0| |- - - ^ -| |4-0-0-0-0| |^ ...
0
Kotlin
0
0
3fb587f2af747acc29886cdc2a02653196326dbf
5,378
kotlin_projects
MIT License
src/main/kotlin/com/leetcode/P1504.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://leetcode.com/problems/count-submatrices-with-all-ones/ class P1504 { fun numSubmat(mat: Array<IntArray>): Int { // For each row i, create an array nums where: if mat[i][j] == 0 then nums[j] = 0 else nums[j] = nums[j-1] +1. for (i in mat.indices) { for (j ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
971
algorithm
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-07.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText import kotlin.math.abs fun main() { val input = readInputText(2021, "07-input") val test1 = readInputText(2021, "07-test1") println("Part1:") part1(te...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,141
advent-of-code
MIT License
src/main/kotlin/Heuristic2D.kt
MatteoMartinelli97
403,882,570
false
{"Kotlin": 39512}
import kotlin.math.abs import kotlin.math.min import kotlin.math.sqrt /** * This object implements some common heuristic functions for a square (or rectangular) grid, where every * square is a node of the graph. * The name are given as [Int] numbers, from left to right, top to bottom as: * * +--------------+ * ...
0
Kotlin
0
0
f14d4ba7058be629b407e06eebe09fae63aa35c1
2,796
Dijkstra-and-AStar
Apache License 2.0
src/Day04.kt
ezeferex
575,216,631
false
{"Kotlin": 6838}
fun String.getSections() = this.split(",") .map { it.split("-").let { section -> Pair(section[0].toInt(), section[1].toInt()) }} .let { pairSection -> Pair(pairSection[0], pairSection[1]) } fun main() { fun part1() = readInput("04").split("\n") .count { val sections = it.getSections() ...
0
Kotlin
0
0
f06f8441ad0d7d4efb9ae449c9f7848a50f3f57c
984
advent-of-code-2022
Apache License 2.0
src/AOC2022/Day01/Day01.kt
kfbower
573,519,224
false
{"Kotlin": 44562}
package AOC2022.Day01 import AOC2022.readInput fun main() { fun makeSummedList(input: List<String>): MutableList<Int> { var calorieList: MutableList<Int> = mutableListOf() var subTotal: Int = 0 input.forEachIndexed { i, s -> if (i < input.size-1) { if (s != "")...
0
Kotlin
0
0
48a7c563ebee77e44685569d356a05e8695ae36c
1,408
advent-of-code-2022
Apache License 2.0
src/main/kotlin/cz/tomasbublik/Day01.kt
tomasbublik
572,856,220
false
{"Kotlin": 21908}
package cz.tomasbublik fun main() { fun addToGroup( groupedCalories: MutableMap<Int, List<String>>, group: MutableList<String> ) { groupedCalories[group.sumOf { it.toInt() }] = group } fun getGroupedCalories(input: List<String>): MutableMap<Int, List<String>> { val grou...
0
Kotlin
0
0
8c26a93e8f6f7ab0f260c75a287608dd7218d0f0
1,595
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day20.kt
sviams
115,921,582
false
null
import kotlinx.coroutines.experimental.async import kotlinx.coroutines.experimental.runBlocking object AoC_Day20 { fun parseParticleStates(lines: List<String>) : List<ParticleState> = lines.map { line -> val split = line.split(", ") val splits = (0..2).map { split[it].substring(split[it].indexOf('...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
2,751
aoc17
MIT License
src/com/leecode/array/Code3.kt
zys0909
305,335,860
false
null
package com.leecode.array /** 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数位于数组的前半部分,所有偶数位于数组的后半部分。 示例: 输入:nums = [1,2,3,4] 输出:[1,3,2,4] 注:[3,1,2,4] 也是正确的答案之一。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof */ /** * 申请一个新数组,T(n) ,O(n) */ fun ex...
0
Kotlin
0
0
869c7c2f6686a773b2ec7d2aaa5bea2de46f1e0b
1,791
CodeLabs
Apache License 2.0
Coding Challenges/Advent of Code/2021/Day 9/part2.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
import java.io.File import java.util.Scanner var row = 0 var col = 0 var size = 0 val sizeList = mutableListOf<Int>() //list that stores all basin sizes. fun setMapDimensions(file: File) { val scanner = Scanner(file) var bool = false while (scanner.hasNextLine()) { val line = scanner.nextLine() ...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
1,800
Archive
MIT License
src/Day01.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
fun main() { fun part1(input: List<String>): Int { var maxSoFar: Int = -1 var groupSum = 0 for (line: String in input) { val parsedInt = line.toIntOrNull() if (parsedInt != null) { groupSum += parsedInt } else { // group se...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
1,395
aoc2022
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/problems/arrayandstrings/MedianOfTwoSorted.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.problems.arrayandstrings import java.util.* fun main() { val array1 = intArrayOf(1, 2) val array2 = intArrayOf(3, 4) println(findMedianSortedArrays(array1, array2)) } fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val pq = PriorityQueue<Int> (2...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,338
DS_Algo_Kotlin
MIT License
ceria/13/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; import kotlin.math.abs; val folds = mutableListOf<Pair<String, Int>>() fun main(args : Array<String>) { val input = File(args.first()).readLines() val points = mutableSetOf<Pair<Int, Int>>() var foldingInstruction = false for (line in input) { if (line.isEmpty()) { ...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
2,434
advent-of-code-2021
MIT License
src/main/kotlin/dec10/Main.kt
dladukedev
318,188,745
false
null
package dec10 import java.lang.Exception data class JumpResults( val oneJumps: Int = 0, val threeJumps: Int = 0 ) tailrec fun countJumps(input: List<Int>, currentJolts: Int = 0, accum: JumpResults = JumpResults()): JumpResults { return when { input.contains(currentJolts + 1) -> { coun...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
1,801
advent-of-code-2020
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day24.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day class Day24 : Day(24, 2021, "Arithmetic Logic Unit") { class Parameters(val a: Int, val b: Int) class QueueItem(val digitIndex: Int, val addend: Int) /* * 0 inp w inp w inp w .... ...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
3,000
advent-of-code-2021
Apache License 2.0
src/main/kotlin/g1701_1800/s1703_minimum_adjacent_swaps_for_k_consecutive_ones/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1703_minimum_adjacent_swaps_for_k_consecutive_ones // #Hard #Array #Greedy #Prefix_Sum #Sliding_Window // #2023_06_15_Time_518_ms_(100.00%)_Space_52.2_MB_(100.00%) class Solution { fun minMoves(nums: IntArray, k: Int): Int { val len = nums.size var cnt = 0 var min = Lon...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,231
LeetCode-in-Kotlin
MIT License
src/year2020/day06/Day06.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day06 import util.assertTrue import util.read2020DayInput fun main() { val input = inputToGroupInput(read2020DayInput("Day06")) assertTrue(task01(input) == 6903) assertTrue(task02(input) == 3493) } private fun inputToGroupInput(input: List<String>) = input.joinToString() .split(", ,"...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
900
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/aoc2022/Day16.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput import withEachOf import java.util.regex.Pattern import kotlin.math.min data class Valve(val name: String, val flowRate: Int, val tunnels: Set<String>) { companion object { fun fromString(input: String): Valve { // Valve AA has flow rate=0; tunnels lead to val...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
10,487
adventOfCode
Apache License 2.0
src/main/kotlin/graph/variation/Reachability3.kt
yx-z
106,589,674
false
null
package graph.variation import graph.core.Edge import graph.core.Graph import graph.core.Vertex import graph.core.whateverFirstSearch import util.Tuple3 import util.tu // given a connected undirected graph G with three tokens at vertex a, b, and c // in each turn you must move ALL three tokens to an adjacent vertex /...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,728
AlgoKt
MIT License
src/main/kotlin/com/jaspervanmerle/aoc2020/day/Day17.kt
jmerle
317,518,472
false
null
package com.jaspervanmerle.aoc2020.day class Day17 : Day("346", "1632") { private data class Point(val coordinates: List<Int>) private abstract class Dimension(val dimensions: Int, input: String) { private val cubes = mutableSetOf<Point>() private val adjacentDirections = getPoints(-1..1) ...
0
Kotlin
0
0
81765a46df89533842162f3bfc90f25511b4913e
3,673
advent-of-code-2020
MIT License
exercises/practice/yacht/.meta/src/reference/kotlin/Yacht.kt
exercism
47,675,865
false
{"Kotlin": 382097, "Shell": 14600}
import YachtCategory.* object Yacht { fun solve(category: YachtCategory, vararg dices: Int): Int = when (category) { YACHT -> if (dices.distinct().size == 1) 50 else 0 ONES -> dices.filter { it == 1 }.sum() TWOS -> dices.filter { it == 2 }.sum() THREES -> dices.filter { it == 3 }.s...
51
Kotlin
190
199
7f1c7a11cfe84499cfef4ea2ecbc6c6bf34a6ab9
1,098
kotlin
MIT License
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/search/swap/SwapNodes.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.search.swap import java.util.* fun swapNodes(indexes: Array<Array<Int>>, queries: Array<Int>): List<List<Int>> { val root = buildTree(indexes) return queries.map { swapMultiplier -> val queryResult = mutableListOf<Int>() traver...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
2,171
kotlin-hackerrank
MIT License
src/main/kotlin/days/Day18.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days import java.util.ArrayDeque @AdventOfCodePuzzle( name = "Boiling Boulders", url = "https://adventofcode.com/2022/day/18", date = Date(day = 18, year = 2022) ) class Day18(input: List<String>) : Puzzle { private val droplets = input.map(Point3D::from).toSet() override fun partOne() =...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
1,621
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/twentytwo/Day08.kt
Monkey-Matt
572,710,626
false
{"Kotlin": 73188}
package twentytwo fun main() { // test if implementation meets criteria from the description, like: val testInput = readInputLines("Day08_test") println(part1(testInput)) check(part1(testInput) == 21) println(part2(testInput)) check(part2(testInput) == 8) println("---") val input = rea...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
3,438
advent-of-code-solutions
Apache License 2.0
src/main/kotlin/de/bitfroest/aoc2020/Day01.kt
Lazalatin
317,801,508
false
null
package de.bitfroest.aoc2020 object Day01 { private fun Pair<Int, Int>.sum() = first + second private fun Pair<Int, Int>.product() = first * second private fun List<Int>.toPairs(): Sequence<Pair<Int, Int>> { return this.asSequence().flatMapIndexed { i, first -> this.drop(i).map { secon...
0
Kotlin
0
0
816e0e010137f97918ff5e631b3e3155b49b842a
1,263
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/Day20.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
import kotlin.math.abs import kotlin.math.sign typealias Message = MutableList<NumberWithMeta> fun Message.valueAt(index: Int): Long { return this[index % this.size].value } data class NumberWithMeta(val value: Long, val originalPosition: Int) fun main() { fun readInputDay20(filename: String): Message { ...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
2,409
aoc-2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions51.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round0.BinaryTreeNode import kotlin.math.max fun test51() { printlnResult(testCase()) } /** * Questions 51: Find the maximum sum of paths */ private fun BinaryTreeNode<Int>.maxSum(): Int { val max = intArrayOf(Int.MIN_VALUE) maxSum(...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,431
Algorithm
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2021/day19/BeaconMap.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day19 import com.github.michaelbull.advent2021.math.Vector3 fun Sequence<String>.toBeaconMap(): BeaconMap { val it = iterator() val scanners = generateSequence(it::readScanner).toList() return BeaconMap(scanners) } data class BeaconMap( val scanners: List<Sca...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
3,519
advent-2021
ISC License