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
004.median-of-two-sorted-arrays/solution.kt
JC6
45,993,346
false
{"Kotlin": 5788, "Java": 3827, "Python": 2717}
import kotlin.math.max import kotlin.math.min fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val size = nums1.size + nums2.size return if (size % 2 == 0) { (findK(nums1, nums2, size / 2) + findK(nums1, nums2, size / 2 + 1)) / 2.0 } else { findK(nums1, nums2, size / 2...
0
Kotlin
0
0
493dbe86cb1b59d4f3a770a8653ec3be1ff25b6d
773
LeetCode
MIT License
src/main/kotlin/com/nibado/projects/advent/y2018/Day20.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2018 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Direction import com.nibado.projects.advent.Point import com.nibado.projects.advent.resourceString object Day20 : Day { private val input = resourceString(2018, 21).let { it.substring(1, it.length - 1)...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,858
adventofcode
MIT License
src/shmp/lang/language/lexis/Connotation.kt
ShMPMat
240,860,070
false
null
package shmp.lang.language.lexis import shmp.lang.language.LanguageException data class Connotation(var name: String, val strength: Double, var isGlobal: Boolean = false) { fun getCompatibility(that: Connotation) = (if (name == that.name) 1.0 else connotationsCompatibility[name]?.get(that.name))?.times(stren...
0
Kotlin
0
1
4d26b0d50a1c3c6318eede8dd9678d3765902d4b
3,307
LanguageGenerator
MIT License
src/Day07.kt
stephenkao
572,205,897
false
{"Kotlin": 14623}
enum class NodeType { FILE, DIRECTORY } class Node(nodeType: NodeType, filename: String, filesize: Int = 0, parentDirectory: Node? = null) { val nodeType = nodeType val filename = filename val filesize = filesize // only for files var parentDirectory = parentDirectory // only for directories ...
0
Kotlin
0
0
7a1156f10c1fef475320ca985badb4167f4116f1
4,545
advent-of-code-kotlin-2022
Apache License 2.0
src/nativeMain/kotlin/Day12.kt
rubengees
576,436,006
false
{"Kotlin": 67428}
class Day12 : Day { private companion object { private const val START = 'S' private const val END = 'E' } private data class Point(val x: Int, val y: Int) private class Matrix(private val data: List<List<Char>>) { private val points get() = data.indices.flatMap { y -> data[y]....
0
Kotlin
0
0
21f03a1c70d4273739d001dd5434f68e2cc2e6e6
3,743
advent-of-code-2022
MIT License
src/Day03.kt
Pixselve
572,907,486
false
{"Kotlin": 7404}
fun main() { fun characterPriority(char: Char) = if (char.code >= 97) char.code - 96 else char.code - 65 + 27 fun part1(input: List<String>): Int { return input.fold(0) { acc, line -> val firstPart = line.slice(0 until line.length / 2) val secondPart = line.slice(line.length / 2...
0
Kotlin
0
0
10e14393b8b6ee3f98dfd4c37e32ad81f9952533
999
advent-of-code-2022-kotlin
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day13/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day13 fun launchDay13(testCase: String) { val input = readInput(testCase) println("Day 13, part 1: ${calcPart1(input)}") println("Day 13, part 2: ${calcPart2(input)}") } private fun calcPart2(input: Input): Int { var result = 0 input.forEach { pattern -> val res...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
4,214
advent-of-code-2023
MIT License
bot/src/main/kotlin/util/DamerauLevenshtein.kt
NyCodeGHG
511,133,398
false
{"Kotlin": 54668, "Dockerfile": 334}
package dev.nycode.regenbogenice.util import kotlin.math.min /** * Calculates the string distance between source and target strings using * the Damerau-Levenshtein algorithm. The distance is case-sensitive. * * @param source The source String. * @param target The target String. * @return The distance between so...
8
Kotlin
0
6
65738ee9202382834d3accbe27a24c8fa3d7d63f
1,546
regenbogen-ice
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day8.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 Day8 : Day { override val input = readInputLines(8).map { c -> c.map { it.digitToInt() }.toTypedArray() }.toTypedArray() override fun par...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
1,958
aoc2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/UniquePaths2.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
3,258
kotlab
Apache License 2.0
src/year2023/day04/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day04 import arrow.core.nonEmptyListOf import kotlin.math.pow import utils.ProblemPart import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 4, transform = ::parse) runAlgorithm( realInput = realInput, testInputs = testI...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
1,307
Advent-of-Code
Apache License 2.0
src/day22/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day22 import Coord import day06.main import readInput fun main() { abstract class Tile { abstract val nextStep: MutableList<Coord> abstract val nextDir: MutableList<Int> } data class Step( override val nextStep: MutableList<Coord> = mutableListOf(), override val ne...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
8,973
AOC2022
Apache License 2.0
kotlin/structures/WaveletTree.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures import java.util.Arrays object WaveletTree { fun createTree(a: IntArray): Node { val lo: Int = Arrays.stream(a).min().orElse(Integer.MAX_VALUE) val hi: Int = Arrays.stream(a).max().orElse(Integer.MIN_VALUE) return build(a, 0, a.size, lo, hi) } fun build(a: IntAr...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,190
codelibrary
The Unlicense
core/src/org/flightofstairs/redesignedPotato/model/Encounter.kt
FlightOfStairs
95,606,091
false
null
package org.flightofstairs.redesignedPotato.model import org.flightofstairs.redesignedPotato.model.EncounterDifficulty.* data class Thresholds(val easy: Int, val medium: Int, val hard: Int, val deadly: Int) { operator fun plus(other: Thresholds) = Thresholds(easy + other.easy, medium + other.medium, hard + other....
0
Kotlin
0
0
530a011e884ddfa8c6b39529c1d187441e36478a
2,736
redesigned-potato
MIT License
src/Day09.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
import kotlin.math.abs fun main() { val dirs = mapOf( 'U' to Pair(0, 1), 'D' to Pair(0, -1), 'R' to Pair(1, 0), 'L' to Pair(-1, 0) ) fun moveTail (head: Pair<Int, Int>, tail: Pair<Int, Int>): Pair<Int, Int> { var dx = head.first - tail.first var dy = head.s...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
2,092
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BusRoutes.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
4,158
kotlab
Apache License 2.0
src/aoc2018/kot/Day10.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import getNumbers import java.io.File object Day10 { data class Particle(var x: Int, var y: Int, val xSpeed: Int, val ySpeed: Int) { fun tick() { x += xSpeed y += ySpeed } } fun solve(input: List<String>): Pair<String, Int> { val particles = parse(input) var s = ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,838
Advent_of_Code
MIT License
src/main/kotlin/de/pgebert/aoc/days/Day16.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day class Day16(input: String? = null) : Day(16, "The Floor Will Be Lava", input) { private val obstacles = parseObstacles() override fun partOne() = Beam(position = Point(0, -1), direction = Point(0, 1)).getNumberOfEnergizedTiles() override fun partTw...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
3,641
advent-of-code-2023
MIT License
day3/day3/src/main/kotlin/Day8.kt
teemu-rossi
437,894,529
false
{"Kotlin": 28815, "Rust": 4678}
val digits = mapOf( 0 to "abcefg", // 6 1 to "cf", // 2 2 to "acdeg", // 5 3 to "acdfg", // 5 4 to "bcdf", // 4 5 to "abdfg", // 5 6 to "abdefg", // 6 7 to "acf", // 3 8 to "abcdefg", // 7 9 to "abcdfg" // 6 ) fun main() { val values = generateSequence(...
0
Kotlin
0
0
16fe605f26632ac2e134ad4bcf42f4ed13b9cf03
5,103
AdventOfCode
MIT License
knapsack/src/main/kotlin/com/nickperov/stud/algorithms/knapsack/KnapSackProblem.kt
nickperov
327,780,009
false
null
package com.nickperov.stud.algorithms.knapsack import kotlin.random.Random data class KnapSack(val weightLimit: Int) data class Item(val weight: Int, val price: Int) data class ProblemParameters(val knapSackSize: Int, val itemListSize: Int, val itemWeightLimit: Int, val itemPriceLimit: Int) data class Problem(val ...
0
Kotlin
0
0
6696f5d8bd73ce3a8dfd4200f902e2efe726cc5a
2,413
Algorithms
MIT License
y2019/src/main/kotlin/adventofcode/y2019/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import kotlin.math.absoluteValue fun main() = Day16.solve() object Day16 : AdventSolution(2019, 16, "Flawed Frequency Transmission") { override fun solvePartOne(input: String) = generateSequence(input.map(Character::getNumericValue), t...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,359
advent-of-code
MIT License
src/main/kotlin/be/inniger/euler/problems01to10/Problem07.kt
bram-inniger
135,620,989
false
{"Kotlin": 20003}
package be.inniger.euler.problems01to10 import be.inniger.euler.util.EratosthenesSieve import kotlin.math.ln import kotlin.math.roundToInt // -1 as the problem specification is 1-indexed but Kotlin's collections are 0-indexed private const val PRIME_INDEX = 10_001 - 1 /** * 10001st prime * * By listing the first ...
0
Kotlin
0
0
8fea594f1b5081a824d829d795ae53ef5531088c
1,393
euler-kotlin
MIT License
src/Day05.kt
Yasenia
575,276,480
false
{"Kotlin": 15232}
import java.util.Stack fun main() { val stackLinePattern = "^(\\[[A-Z]]| {3})( \\[[A-Z]]| {4})*$".toRegex() val commandLinePattern = "^move (\\d+) from (\\d+) to (\\d+)$".toRegex() fun part1(input: List<String>): String { val stacks = mutableListOf<Stack<Char>>() for (line in input) { ...
0
Kotlin
0
0
9300236fa8697530a3c234e9cb39acfb81f913ba
2,252
advent-of-code-kotlin-2022
Apache License 2.0
2022/main/day_20/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_20_2022 import java.io.File data class Mover(var uuid: Int, var value: Long) fun solve(part1: Boolean, input: List<Long>): String { val movers: MutableList<Mover> = ArrayList() for ((counter, num) in input.withIndex()) { val value: Long = num movers.add(Mover(counter, if (part1) v...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,761
AdventofCode
MIT License
src/main/kotlin/com/dmc/advent2022/Day04.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
// --- Day 4: Camp Cleanup --- package com.dmc.advent2022 class Day04 : Day<Int> { override val index = 4 override fun part1(input: List<String>): Int { return input.map{ it.asRanges() }.count { (left, right) -> left fullyOverlaps right } } override fun part2(input: List<String>): Int { ...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
1,249
aoc-2022-kotlin
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions57.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 fun test57() { printlnResult1(intArrayOf(1, 2, 4, 7, 11, 15), 15) printlnResult1(intArrayOf(0, 1, 2, 4, 7, 11, 15), 15) printlnResult2(15) printlnResult2(1) printlnResult2(6) printlnResult2(9) printlnResult2(10) printlnResult2(12) } /** * Questio...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,914
Algorithm
Apache License 2.0
src/Day07.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
class FileTree(val root: Directory, private val position: MutableList<Directory>) { var answerPart1 = 0 var answerPart2 = 70000000 companion object Factory { fun create(input: List<String>): FileTree { val root = Directory("/") val fileTree = FileTree(root, mutableListOf(roo...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
2,989
aoc-2022
Apache License 2.0
src/main/kotlin/day18/Day18.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day18 import popUntil import readToList import java.util.* val input = readToList("day18.txt") fun main() { var current = createPairExpression(input.first()) input.drop(1).forEach { line -> val parsed = createPairExpression(line) current += parsed } println("magnitude " + curr...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
1,901
aoc2021
Apache License 2.0
2022/src/main/kotlin/Day15.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import kotlin.math.abs object Day15 { fun part1(input: String, y: Int): Int { val sensors = parseInput(input) val startX = sensors.first().closestBeacon.x var left = startX - 1 while (sensors.any { it.rulesOut(left, y) }) { left-- } var right = startX + 1 while (sensors.any { it...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,866
advent-of-code
MIT License
src/main/kotlin/g1301_1400/s1373_maximum_sum_bst_in_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1373_maximum_sum_bst_in_binary_tree // #Hard #Dynamic_Programming #Depth_First_Search #Tree #Binary_Tree #Binary_Search_Tree // #2023_06_06_Time_451_ms_(100.00%)_Space_54.3_MB_(100.00%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition fo...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,579
LeetCode-in-Kotlin
MIT License
src/main/aoc2015/Day9.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 import java.util.* import kotlin.math.max class Day9(input: List<String>) { val parsedInput = parseInput(input) private fun initMapIfNeeded(key: String, map: MutableMap<String, MutableMap<String, Int>>) { if (!map.containsKey(key)) { map[key] = mutableMapOf() } ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,019
aoc
MIT License
src/Day06.kt
frungl
573,598,286
false
{"Kotlin": 86423}
fun main() { fun part1(input: List<String>): Int { val str = input.first() val tmp = str.mapIndexed { index, _ -> when(str.length - index >= 4) { true -> str.substring(index, index + 4) else -> "" } }.dropLast(3) return 4 + tmp....
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
1,206
aoc2022
Apache License 2.0
src/aoc2022/Day08.kt
FluxCapacitor2
573,641,929
false
{"Kotlin": 56956}
package aoc2022 import Day import column object Day08 : Day(2022, 8) { override fun part1() { var totalVisible = 0 val input = lines.filter { it.isNotEmpty() } for ((row, line) in input.withIndex()) { for ((column, char) in line.withIndex()) { if (row == 0 || c...
0
Kotlin
0
0
a48d13763db7684ee9f9129ee84cb2f2f02a6ce4
2,905
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day20/Code.kt
fcolasuonno
317,324,330
false
null
package day20 import isDebug import java.io.File import kotlin.math.sqrt fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/main/kotlin/$dir/$name").readLines() val parsed = parse(input) ...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
5,292
AOC2020
MIT License
src/day3/Day03_A.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day3 import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val compartmentSize = rucksack.length / 2 val firstCompartment = rucksack.substring(0, compartmentSize) val secondCompartment = rucksack.substring(compartm...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
1,380
advent-of-code-2022
Apache License 2.0
src/Lesson1Iterations/BinaryGap.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * @param N * @return */ fun solution(N: Int): Int { val binary: String = java.lang.Integer.toBinaryString(N) var longestGap = 0 var currentGap = 0 var firstLeadingOne = false for (i in 0 until binary.length) { val digit = binary[i] if (firstLeadingOne) { ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
1,859
Codility-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxNumber.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,973
kotlab
Apache License 2.0
src/Day08.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
import kotlin.math.ceil fun main() { fun part1(input: List<String>): Int { val hauteur = input.size val largeur = input[0].length val mesArbres = mutableListOf<trees>() for (indexY in 0 until hauteur) { for (indexX in 0 until largeur) { val visible = (...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
4,448
AD2022-01
Apache License 2.0
src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2213_longest_substring_of_one_repeating_character // #Hard #Array #String #Ordered_Set #Segment_Tree // #2023_06_27_Time_879_ms_(100.00%)_Space_64.8_MB_(100.00%) class Solution { internal class TreeNode(var start: Int, var end: Int) { var leftChar = 0.toChar() var leftCharLen =...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,031
LeetCode-in-Kotlin
MIT License
src/main/kotlin/aoc2021/day10/SyntaxScorer.kt
arnab
75,525,311
false
null
package aoc2021.day10 object SyntaxScorer { fun parse(data: String) = data.split("\n") private val openingTokens = listOf('(', '[', '{', '<') private val closingTokens = listOf(')', ']', '}', '>') fun calculateErrorScore(data: List<String>): Int { val errors = mutableMapOf<Char, Int>() ...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,312
adventofcode
MIT License
src/Day04.kt
colmmurphyxyz
572,533,739
false
{"Kotlin": 19871}
fun main() { fun part1(input: List<String>): Int { var answer = 0 for (line in input) { val pair = line.split(",") val r1 = pair[0].split("-").map { it -> it.toInt() } val r2 = pair[1].split("-").map { it -> it.toInt() } val set1 = (r1[0]..r1[1]).toSet...
0
Kotlin
0
0
c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea
1,137
aoc-2022
Apache License 2.0
src/Day02.kt
emanguy
573,113,840
false
{"Kotlin": 17921}
import java.lang.IllegalArgumentException enum class RPSResult(val resultPoints: Int) { WIN(6) { override fun whatToPlayAgainst(move: RPSMove) = when (move) { RPSMove.ROCK -> RPSMove.PAPER RPSMove.PAPER -> RPSMove.SCISSORS RPSMove.SCISSORS -> RPSMove.ROCK } }...
0
Kotlin
0
1
211e213ec306acc0978f5490524e8abafbd739f3
3,037
advent-of-code-2022
Apache License 2.0
src/year2020/day02/Day02.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day02 import util.assertTrue import util.read2020DayInput fun main() { val input = read2020DayInput("Day02") assertTrue(task01(input) == 460) assertTrue(task02(input) == 251) } private data class Policy(val min: Int, val max: Int, val letter: Char) { fun oldIsValid(value: String): B...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,181
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/net/hiddevb/advent/advent2019/day03/main.kt
hidde-vb
224,606,393
false
null
package net.hiddevb.advent.advent2019.day03 import net.hiddevb.advent.common.initialize import kotlin.math.abs /** * --- Day 3: Crossed Wires --- */ fun main() { val fileStrings = initialize("Day 3: Crossed Wires", arrayOf("day3.txt")) println("Part 1: Basic") val solution1 = solveBasic(fileStrings[0]...
0
Kotlin
0
0
d2005b1bc8c536fe6800f0cbd05ac53c178db9d8
2,617
advent-of-code-2019
MIT License
src/Day03.kt
mythicaleinhorn
572,689,424
false
{"Kotlin": 11494}
fun main() { fun part1(input: List<String>): Int { var result = 0 for (rucksack in input) { val first = rucksack.substring(0 until rucksack.length / 2) val second = rucksack.substring(rucksack.length / 2) val sameItems = first.filter { c -> second.contains(c) } ...
0
Kotlin
0
0
959dc9f82c14f59d8e3f182043c59aa35e059381
1,527
advent-of-code-2022
Apache License 2.0
kotlin/Graph.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
data class Graph<D>(val edges: List<Edge<D>>) { val nodes: Map<D, Node<D>> = edges.flatMap { listOf(Node(it.fromData), Node(it.toData)) }.distinct().associateBy { it.data } init { edges.forEach { edge -> edge.resolve(this) } } fun dijkstra(cur: Node<D>): DijkstraDat...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
2,890
advent-of-code-2021
MIT License
src/main/kotlin/day9/Day09.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day9 //35:30min fun solveA(input: List<String>): Int { val tail = Knot("T", tail = null) val head = Knot("H", tail = tail) input.forEach { movement -> val (direction, amountString) = movement.split(" ") val amount = amountString.toInt() repeat(amount) { head.move(direction)...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
9,700
advent-of-code-2022
Apache License 2.0
src/Day04.kt
daniyarmukhanov
572,847,967
false
{"Kotlin": 9474}
//use this file as template fun main() { fun part1(input: List<String>): Int { var counter = 0 input.forEach { val first = it.split(",").first().split("-").map { i -> i.toInt() }.zipWithNext().first() val last = it.split(",").last().split("-").map { i -> i.toInt() }.zipWithNe...
0
Kotlin
0
0
ebad16b2809ef0e3c7034d5eed75e6a8ea34c854
1,307
aoc22
Apache License 2.0
puzzles/src/main/kotlin/com/kotlinground/puzzles/graph/numberofprovinces/numberOfProvinces.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.puzzles.graph.numberofprovinces /** * Finds the number of connected components(graphs) in a given adjacency list is_connected. Uses DFS traversal algorithm * to find the connected components or the number of graphs from the provided 2D array. * * Complexity: * - Time Complexity: O(n^2). ...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,429
KotlinGround
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxValue2.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
5,349
kotlab
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day20.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution import java.util.* object Day20 : AdventSolution(2018, 20, "A Regular Map") { override fun solvePartOne(input: String) = findDistances(input).values.maxOrNull() override fun solvePartTwo(input: String) = findDistances(input).co...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,001
advent-of-code
MIT License
src/Day14.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import java.io.File fun main() { fun createWall(input: List<String>, xMax: Int, xMin: Int, yMax: Int, yMin: Int): MutableList<MutableList<Int>> { var wall = MutableList(yMax-yMin+1, { MutableList(xMax-xMin+1, {0}) }) fun MutableList<MutableList<Int>>.paintRock(crd: Pair<String, String>): MutableLis...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
6,963
aoc22
Apache License 2.0
src/Utils.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
import java.io.File import java.math.BigInteger import java.security.MessageDigest import java.util.function.Predicate import kotlin.math.absoluteValue import kotlin.system.measureNanoTime /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt").readLines() /** * R...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
4,133
advent-of-code-22
Apache License 2.0
src/Day18.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
fun main() { class Cube(val x: Int, val y: Int, val z: Int) val dirs = listOf( Cube(-1, 0, 0), Cube(1, 0, 0), Cube(0, -1, 0), Cube(0, 1, 0), Cube(0, 0, -1), Cube(0, 0, 1) ) fun part1(cubes: List<Cube>): Int { var ans = 0 val grid = Arra...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
3,250
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day14.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 import com.ginsberg.advent2017.hash.KnotHash import java.math.BigInteger /** * AoC 2017, Day 14 * * Problem Description: http://adventofcode.com/2017/day/14 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day14/ */...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
1,672
advent-2017-kotlin
MIT License
src/aoc2022/day14/AoC14.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day14 import myRange import readLines private data class P(val x: Int, val y: Int) { fun up() = P(x, y - 1) fun down() = P(x, y + 1) fun left() = P(x - 1, y) fun right() = P(x + 1, y) override fun toString() = "($x,$y)" } private class Regolith { private val map = HashMap<P, Char>() private va...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
2,111
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MatrixRankTransform.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,968
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindKthLargest.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,351
kotlab
Apache License 2.0
src/Day04.kt
jalex19100
574,686,993
false
{"Kotlin": 19795}
fun main() { fun part1(input: List<String>): Int { var count = 0 input.forEach { line -> val pairs = line.split(',', '-') val pair1 = (pairs[0].toInt()..pairs[1].toInt()).toSet() val pair2 = (pairs[2].toInt()..pairs[3].toInt()).toSet() if (pair1.isNotE...
0
Kotlin
0
0
a50639447a2ef3f6fc9548f0d89cc643266c1b74
1,146
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/File02.kt
andrewrlee
319,095,151
false
null
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge02 { data class Policy(val low: Int, val high: Int, val v: Char) val pattern = "(\\d+)-(\\d+) (\\w): (\\w+)".toRegex() fun readPoliciesAndPasswords() = File("src/main/resources/02-input.txt").readLines(UTF_8) ...
0
Kotlin
0
0
a9c21a6563f42af7fada3dd2e93bf75a6d7d714c
1,387
adventOfCode2020
MIT License
src/Day16.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
import java.util.* fun main() { data class Valve( val name: String, val flowRate: Int, val vertex: MutableList<Int> = mutableListOf() ) data class State( val openedValves: Set<Int>, val location: Int, val pressure: Int, val timeLeft: Int ) v...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
6,867
advent-of-code-2022
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day8/Day8.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day8 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 8](https://adventofcode.com/2023/day/8) */ object Day8 : DayOf2023(8) { private val PATTERN = "(\\w+) = \\((\\w+), (\\w+)\\)".toRegex() override fun first(): Any? { val...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,671
adventofcode
MIT License
src/main/kotlin/aoc2022/Day05.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* class Day05() { sealed interface Crate { val id: Char } object Empty : Crate { override val id: Char = '#' } data class Filled(override val id: Char): Crate data class Move(val count: Int, val from: Int, val to: Int) val fi...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
2,063
aoc-kotlin
Apache License 2.0
src/leetcode_problems/medium/LongestCommonPref.kt
MhmoudAlim
451,633,139
false
{"Kotlin": 31257, "Java": 586}
package leetcode_problems.medium//https://leetcode.com/problems/longest-common-prefix/ //best fun longestCommonPrefix(strs: Array<String>?): String { if (strs == null || strs.isEmpty()) return "" for (i in 0 until strs[0].length) { val c = strs[0][i] for (j in 1 until strs.size) { i...
0
Kotlin
0
0
31f0b84ebb6e3947e971285c8c641173c2a60b68
1,230
Coding-challanges
MIT License
src/com/leecode/array/Code7.kt
zys0909
305,335,860
false
null
package com.leecode.array /** 给定一个排序数组,你需要在 原地 删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。 示例 1: 给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。 你不需要考虑数组中超出新长度后面的元素。 示例 2: 给定 nums = [0,0,1,1,1,2,2,3,3,4], 函数应该返回新的长度 5, 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4。 你不需要考虑数组...
0
Kotlin
0
0
869c7c2f6686a773b2ec7d2aaa5bea2de46f1e0b
1,235
CodeLabs
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/TransitiveClosure.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph println("Test") /* relax all intermediate nodes O(V^3) 1. create adj matrix directed weighted graph 2. for each intermediate in 0 until V for each start in 0 until V for each end in 0 until V relax if matrix[i][k] + matrix[k][j] < ma...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
3,219
KotlinAlgs
MIT License
implementation/common/src/main/kotlin/io/github/tomplum/aoc/extensions/CollectionExtensions.kt
TomPlum
317,142,882
false
null
package io.github.tomplum.aoc.extensions import kotlin.math.pow /** * Returns the product of all of the integers in the given list. */ fun List<Int>.product(): Int = if (isNotEmpty()) reduce { product, next -> product * next } else 0 fun List<Long>.product(): Long = if (isNotEmpty()) reduce { product, next -> produ...
1
Kotlin
0
0
73b3eacb7cb8a7382f8891d3866eda983b6ea7a9
3,322
advent-of-code-2020
Apache License 2.0
src/main/kotlin/nl/kelpin/fleur/advent2018/Day18.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 class Day18(val input: List<String>) { private fun insideGrid(point: Point, state: List<String>): Boolean = with(point) { (0 until state.size).contains(y) && (0 until state[0].length).contains(x) } private fun charAt(point: Point, state: List<String>): Char = wi...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
2,499
advent-2018
MIT License
src/main/kotlin/dev/shtanko/algorithms/mocks/interview/PairsOfPrefixOrSuffix.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,481
kotlab
Apache License 2.0
src/Day04.kt
Frendzel
573,198,577
false
{"Kotlin": 5336}
fun main() { fun part1(input: List<String>) = input .map { it.split(",") } .map { val first = it[0].split("-") val firstRange = IntRange(first[0].toInt(), first[1].toInt()) val second = it[1].split("-") val secondRange = IntRan...
0
Kotlin
0
0
a8320504be93dfba1f634413a50e7240d16ba6d9
1,381
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch3/Problem34.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.maths.factorial /** * Problem 34: Digit Factorials * * https://projecteuler.net/problem=34 * * Goal: Find the sum of all numbers less than N that divide the sum of the factorial of their * digits (& therefore have minimum 2 digits). * * Constraints: 10 <= N <...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,342
project-euler-kotlin
MIT License
src/day18/Day18B.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day18 import day18.Cube.Companion.normals import readInput import java.util.Stack fun main() { val day = 18 val testInput = readInput("day$day/testInput") // check(part1B(testInput) == 64) // check(part2B(testInput) == 58) val input = readInput("day$day/input") // println(part1B(input))...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
3,359
advent-of-code-2022
Apache License 2.0
src/Day02.kt
konclave
573,548,763
false
{"Kotlin": 21601}
fun main() { fun solve1(input: List<String>): Int { return input.fold(0) { acc, pair -> val (he, me) = pair.split(" ") val heInt = he.first().code val meInt = me.first().code val bonus = meInt - 87 acc + bonus + when (heInt - meInt) { -23 -...
0
Kotlin
0
0
337f8d60ed00007d3ace046eaed407df828dfc22
1,425
advent-of-code-2022
Apache License 2.0
src/day14/Day14.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day14 import java.io.File fun main() { val data = parse("src/day14/Day14.txt") println("🎄 Day 14 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private fun parse(path: String): List<L...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
3,249
advent-of-code-2023
MIT License
src/Day09.kt
diego09310
576,378,549
false
{"Kotlin": 28768}
import kotlin.math.abs fun main() { data class Coordinates (var x: Int, var y: Int) { override fun toString(): String { return "$x $y" } } fun getDirection(or: Coordinates, dest: Coordinates): Coordinates? { val xDiff = dest.x - or.x val yDiff = dest.y - or.y ...
0
Kotlin
0
0
644fee9237c01754fc1a04fef949a76b057a03fc
2,849
aoc-2022-kotlin
Apache License 2.0
2020/11/week1/minhyungPark/algorithm/Leetcode1631.kt
Road-of-CODEr
270,008,701
false
{"Java": 199573, "C++": 42297, "JavaScript": 29489, "Kotlin": 28801, "Python": 20313, "HTML": 7981, "Shell": 7160}
/** * Leetcode 1631. Path With Minimum Effort * https://leetcode.com/contest/weekly-contest-212/problems/path-with-minimum-effort/ */ import kotlin.math.abs import kotlin.math.max class Leetcode1631 { companion object { val dx = intArrayOf(-1, 1, 0, 0) val dy = intArrayOf(0, 0, -1, 1) } ...
3
Java
11
36
1c603bc40359aeb674da9956129887e6f7c8c30a
1,310
stupid-week-2020
MIT License
src/medium/_1508RangeSumOfSortedSubarraySums.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package medium class _1508RangeSumOfSortedSubarraySums { class Solution { private val MODULO = 1000000007 fun rangeSum(nums: IntArray, n: Int, left: Int, right: Int): Int { val prefixSums = IntArray(n + 1) { 0 } for (i in 0 until n) { prefixSums[i + 1] = pref...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
2,214
AlgorithmsProject
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day21.kt
sviams
115,921,582
false
null
import kotlinx.coroutines.experimental.async import kotlinx.coroutines.experimental.runBlocking object AoC_Day21 { val startState = Matrix(listOf( listOf(0,1,0), listOf(0,0,1), listOf(1,1,1) )) data class Matrix(val data: List<List<Int>>) { val size : Int by la...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
3,258
aoc17
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RemoveStones.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,720
kotlab
Apache License 2.0
kotlin/0934-shortest-bridge.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
class Solution { fun shortestBridge(grid: Array<IntArray>): Int { // q = [ (row,column,level) ] val queue: Queue<Triple<Int, Int, Int>> = LinkedList() val rowColumnDirections = arrayOf( intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), in...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,981
leetcode
MIT License
src/Day20.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
import kotlin.system.measureTimeMillis typealias EncryptedList = ArrayDeque<ListItem> // Using ArrayList instead of ArrayDeque consumes about the same time //typealias EncryptedList = ArrayList<ListItem> // Using LinkedList instead of ArrayDeque is roughly 4 times slower for part2! // typealias EncryptedList = Linke...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
2,405
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dp/DreamDollars.kt
yx-z
106,589,674
false
null
package dp // given a util.set of bills with the following values val bills = intArrayOf(365, 91, 52, 28, 13, 7, 4, 1) // a greedy algorithm to make up target money is always taking the largest bill that does not exceed // the remaining amound. ex. $122 = $91 + $28 + $1 + $1 + $1 -> 5 fun billsGreedy(k: Int): Int { ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,325
AlgoKt
MIT License
src/Day08.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import java.util.* fun List<String>.isVisible(row: Int, col: Int): Boolean { val rowSize = size val colSize = this[0].length if (row == 0 || row == rowSize - 1 || col == 0 || col == colSize - 1) return true val tree = this[row][col] var visible = false var lineVisible = true for (i in 0 unt...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
2,522
AoC-2022
Apache License 2.0
src/interview_question/_1714SmallestKLCCI.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package interview_question import java.util.* class _1714SmallestKLCCI { class Solution { fun smallestK(arr: IntArray, k: Int): IntArray { if (k == 0) { return IntArray(0) } val maxHeap = PriorityQueue<Int>(k) { a, b -> b - a } for (i in arr....
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
2,366
AlgorithmsProject
Apache License 2.0
src/main/kotlin/day13.kt
tianyu
574,561,581
false
{"Kotlin": 49942}
import Packet.Mono import Packet.Multi import assertk.assertThat import assertk.assertions.isEqualTo import assertk.assertions.isGreaterThan import assertk.assertions.isLessThan private fun main() { tests { "Parse a packet" { assertThat(Packet("[1,1,3,1,1]")).isEqualTo( Multi(Mono(1), Mono(1), Mono...
0
Kotlin
0
0
6144cc0ccf1a51ba2e28c9f38ae4e6dd4c0dc1ea
3,277
AdventOfCode2022
MIT License
src/main/kotlin/complexity/Complexity.kt
waploaj
520,509,366
false
{"Kotlin": 10629}
package complexity // ------------------------------ Time complexity ---------------------------------- //Big O notation for the different level of scalability in two dimension //-- Execution time //-- Memory Usage //Time complexity - is the time it take for algorithm to run compare with data size. //Constant Time ...
0
Kotlin
0
1
6a44d6089233d316461be07b504a9c17a1de3220
3,451
Masomo
Apache License 2.0
src/problems/day5/part1/part1.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day5.part1 import java.io.File import java.util.* //private const val testFile = "input/day5/test.txt" private const val inputFile = "input/day5/input.txt" fun main() { val lowestLocationNum = File(inputFile).bufferedReader().useLines { lowestLocationNumber(it) } println("Lowest Location Num...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
3,439
aoc2023
MIT License
src/org/aoc2021/Day24.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path private fun <K, V> Map<K, V>.replaceKeyValue(k: K, v: V): Map<K, V> { return this.entries.associate { (thisKey, thisValue) -> if (thisKey == k) (k to v) else (thisKey to thisValue) } } object Day24 { data class Instruction(v...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
10,550
advent-of-code-2021
The Unlicense
src/Day05.kt
mpythonite
572,671,910
false
{"Kotlin": 29542}
fun main() { fun part1(input: List<String>): String { var stacks = mutableListOf<ArrayDeque<Char>>() val pattern = "^[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)\$".toRegex() input.forEach{ var index = 0 if (it.isNotBlank() && it.indexOf('[') >= 0) { ...
0
Kotlin
0
0
cac94823f41f3db4b71deb1413239f6c8878c6e4
2,656
advent-of-code-2022
Apache License 2.0
src/day01/Day01.kt
emartynov
572,129,354
false
{"Kotlin": 11347}
package day01 import readInput fun main() { fun part1(input: List<String>): Int { return input.split { string -> string.isEmpty() } .map { list -> list.sumOf { string -> string.toInt() } }.max() } fun part2(input: List<String>): Int { return input.s...
0
Kotlin
0
1
8f3598cf29948fbf55feda585f613591c1ea4b42
1,240
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day07.kt
nmx
572,850,616
false
{"Kotlin": 18806}
fun main(args: Array<String>) { val TOTAL_DISK_SPACE = 70000000 val UNUSED_SPACE_NEEDED = 30000000 abstract class Node(val name: String, var size: Int) { abstract fun calcSize(): Int abstract fun sumMatchingSizes(): Int } class File(name: String, size: Int): Node(name, size) { ...
0
Kotlin
0
0
33da2136649d08c32728fa7583ecb82cb1a39049
4,470
aoc2022
MIT License
src/twentytwo/Day14.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("Day14_test") val part1 = part1(testInput) println(part1) check(part1 == 24) val part2 = part2(testInput) println(part2) check(part2 == 93) println("--...
1
Kotlin
0
0
600237b66b8cd3145f103b5fab1978e407b19e4c
6,995
advent-of-code-solutions
Apache License 2.0
facebook/y2020/round2/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2020.round2 private fun solve(): Long { val (n, k) = readInts() val (s, x, y) = List(3) { val array = readInts().toIntArray() + IntArray(n - k) { 0 } val (a, b, c, d) = readInts() for (i in k until n) { array[i] = ((a.toLong() * array[i - 2] + b.toLong() * array[i - 1] + c) % d).toInt() ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
918
competitions
The Unlicense
src/aoc2023/Day03.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun createArray(input: List<String>): Array<Array<Char>> { val result = Array(input.size) { Array(input[0].length) { '.' } } for ((index, line) in input.withIndex()) { result[index] = line.toCharArray().toTypedArray() } ret...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
7,013
advent-of-code-kotlin
Apache License 2.0
app/src/y2021/day03/Day03BinaryDiagnostic.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day03 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle import transpose fun main(args: Array<String>) { Day03BinaryDiagnostic().solveThem() } @AoCPuzzle(2021, 3) class Day03BinaryDiagnostic : AocSolution { override val answers = Answers(samplePart1 = 198, samp...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
2,823
advent-of-code-2021
Apache License 2.0
src/main/kotlin/2021/Day3.kt
mstar95
317,305,289
false
null
package `2021` import days.Day class Day3 : Day(3) { override fun partOne(): Any { val pairs = inputList.map { it.split("").drop(1).dropLast(1).map { it.toInt() } } val accumulator = pairs.first().map { 0 }.toMutableList() pairs.forEach { row -> row.forEachIndexed { index, i -...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
1,900
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/SmallestSufficientTeam.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,560
kotlab
Apache License 2.0
src/Day12.kt
nikolakasev
572,681,478
false
{"Kotlin": 35834}
fun main() { fun bothParts(input: Array<Array<Int>>, begin: Pair<Int, Int>): Int { val dist = mutableMapOf<Pair<Int, Int>, Int>() val q = ArrayDeque<Pair<Int, Int>>() for (y in 0..input.size - 1) { for (x in 0..input[y].size - 1) { val pair = Pair(x, y) ...
0
Kotlin
0
1
5620296f1e7f2714c09cdb18c5aa6c59f06b73e6
2,676
advent-of-code-kotlin-2022
Apache License 2.0
aoc-2022/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentytwo/Day05.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwentytwo import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput class Day05 : Day<String> { private val initialState: State = readDayInput() .splitToSequence("\n\n") .first() .lines() .parseState() ...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
3,401
adventofcode
Apache License 2.0
src/Day25.kt
palex65
572,937,600
false
{"Kotlin": 68582}
@file:Suppress("PackageDirectoryMismatch") package day25 import readInput import kotlin.math.abs data class NumberSNAFU(val digits: String) { override fun toString() = digits } val DigitsSNAFU = mapOf('2' to 2, '1' to 1, '0' to 0, '-' to -1, '=' to -2) val SymbolsSNAFU = DigitsSNAFU.keys.toList() fun NumberSNAFU...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
1,478
aoc2022
Apache License 2.0