path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/dev/bogwalk/batch8/Problem85.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch8 import kotlin.math.abs import kotlin.math.sqrt /** * Problem 85: Counting Rectangles * * https://projecteuler.net/problem=85 * * Goal: Find the area of a grid (made up of 1x1 squares) that can contain a number of rectangles * closest to T. If multiple such areas exist, output the one ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,242
project-euler-kotlin
MIT License
kotlin/udemy_course/src/main/kotlin/random/RandomQuestions.kt
pradyotprksh
385,586,594
false
{"Kotlin": 1973871, "Dart": 1066884, "Python": 313491, "Swift": 147167, "C++": 113494, "CMake": 94132, "Go": 45704, "HTML": 21089, "Ruby": 12424, "Rust": 8550, "C": 7125, "Makefile": 1480, "Shell": 817, "JavaScript": 781, "CSS": 588, "Objective-C": 380, "Dockerfile": 32}
package random class RandomQuestions { fun solveRandomQuestions() { println("Solving random questions") println(youWillAllConform(listOf("F", "B", "B", "F", "B", "F", "F", "B", "B", "B", "F"))) println(theBestTimeToParty(listOf(6, 7, 10, 10, 8, 9, 6), listOf(7, 9, 11, 12, 10, 11, 8))) ...
0
Kotlin
10
17
2520dc56fc407f97564ed9f7c086292803d5d92d
3,889
development_learning
MIT License
src/main/java/challenges/cracking_coding_interview/linked_list/sum_lists/SumListsB.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.linked_list.sum_lists import challenges.data_structure.LinkedListNode object SumListsB { private fun length(l: LinkedListNode?): Int { return if (l == null) { 0 } else { 1 + length(l.next) } } private fun addLis...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,611
CodingChallenges
Apache License 2.0
src/main/kotlin/lesson3/PermMissingElem.kt
iafsilva
633,017,063
false
null
package lesson3 /** * An array A consisting of N different integers is given. * * The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. * * Your goal is to find that missing element. * * Write a function: * * fun solution(A: IntArray): Int * * that, give...
0
Kotlin
0
0
5d86aefe70e9401d160c3d87c09a9bf98f6d7ab9
1,262
codility-lessons
Apache License 2.0
src/Day22.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private enum class FaceDirection(val score: Int) { Up(3), Down(1), Left(2), Right(0) } private interface Instruction private data class Move( val steps: Int ) : Instruction private data class Turn( val direction: String ) : Instruction private fun path(input: String): List<Instruction> { val instruc...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
7,648
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day9.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day9 { fun part1(input: List<String>): String { return parse(input) .sumOf { extrapolate(it) { deltas, ret -> deltas.last() + ret } }.toString() } fun part2(input: List<String>): String { return parse(input) ...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
883
kotlin-kringle
Apache License 2.0
src/Day01.kt
jandryml
573,188,876
false
{"Kotlin": 6130}
private fun getSumOfHighestElements(input: List<String>, elementCount: Int) = input.joinToString(";") .split(";;") .map { it.split(";").sumOf { calories -> calories.toInt() } } .sortedDescending() .take(elementCount) .sum() private fun part1(input: List<String>) = getSumOfHi...
0
Kotlin
0
0
90c5c24334c1f26ee1ae5795b63953b22c7298e2
774
Aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ParallelCourses.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
2,294
kotlab
Apache License 2.0
src/nativeMain/kotlin/Day5.kt
rubengees
576,436,006
false
{"Kotlin": 67428}
class Day5 : Day { private data class Instruction(val times: Int, val from: Int, val to: Int) private fun parseInput(input: String): Pair<MutableList<ArrayDeque<Char>>, List<Instruction>> { val stackLines = input.lines().takeWhile { !it.startsWith(" 1 ") } val stackLineChars = stackLines.map {...
0
Kotlin
0
0
21f03a1c70d4273739d001dd5434f68e2cc2e6e6
2,128
advent-of-code-2022
MIT License
2023/src/main/kotlin/de/skyrising/aoc2023/day12/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day12 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntList import it.unimi.dsi.fastutil.objects.Object2LongMap import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap import java.util.* fun IntList.dec(index: Int) { set...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
5,854
aoc
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/IntersectionThreeSortedArrays.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,033
kotlab
Apache License 2.0
src/main/kotlin/aoc22/Day09.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import aoc22.Day09Solution.part1Day09 import aoc22.Day09Solution.part2Day09 import common.Space2D.Direction import common.Space2D.Direction.* import common.Space2D.Point import common.Year22 import common.Monitoring import kotlin.math.sign object Day09: Year22 { fun List<String>.part1(): Int = part1...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
2,682
aoc
Apache License 2.0
src/algorithmsinanutshell/spatialtree/NearestNeighbourQueries.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell.spatialtree import algorithmdesignmanualbook.print import kotlin.math.pow /** * Given a target T and a set of points S, find the nearest neighbour of T in S. * * https://www.youtube.com/watch?v=Glp7THUpGow * * https://www.youtube.com/watch?v=XG4zpiJAkD4 * * https://www.cs.cmu.edu...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,631
algorithms
MIT License
src/day7/Day07.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day7 import readInput private fun handle(input: List<String>, handler: (value: Int) -> Unit) { val stack = ArrayDeque<Int>() stack.addFirst(0) for (line in input) { if (line.startsWith("$ cd ..")) { val temp = stack.removeFirst() handler(temp) val newIt...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
1,925
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2016/BalanceBots.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 import komu.adventofcode.utils.nonEmptyLines fun balanceBots1(input: String): Int = buildBalanceRules(input).first.find { it.low() == 17 && it.high() == 61 }?.id!! fun balanceBots2(input: String): Int { val bins = buildBalanceRules(input).second return bins[0].value * b...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
3,516
advent-of-code
MIT License
src/main/kotlin/knn/KnnClassificator.kt
widi-nugroho
280,304,894
false
null
package knn class KnnClassificator(val k:Int) { fun getKNearestNeighbour(sorteddata:List<Pair<Double,DataClassificator>>):List<Pair<Double,DataClassificator>>{ var res= mutableListOf<Pair<Double,DataClassificator>>() for (i in 0..k-1){ res.add(sorteddata[i]) } return res...
0
Kotlin
0
0
139d768e4e02c76193443c06285d918b0fbbfc7f
2,252
kotlin-machine-learning
Apache License 2.0
src/Day06.kt
rk012
574,169,156
false
{"Kotlin": 9389}
fun main() { fun String.getSequences(size: Int) = runningFold("") { acc, c -> (acc + c).takeLast(size) }.drop(size) tailrec fun hasSameChars(c: Char?, s: String): Boolean = when { s.isEmpty() -> false c?.let { s.contains(it) } == true -> true else -> hasSameChars(s.first(), ...
0
Kotlin
0
0
bfb4c56c4d4c8153241fa6aa6ae0e829012e6679
831
advent-of-code-2022
Apache License 2.0
leetcode/kotlin/flood-fill.kt
PaiZuZe
629,690,446
false
null
data class Cell(val row: Int, val col: Int) class Solution { fun numIslands(grid: Array<CharArray>): Int { val visited = mutableSetOf<Cell>() var islands = 0 for (i in grid.indices) { for (j in grid[i].indices) { val cell = Cell(i, j) if (grid[i][...
0
Kotlin
0
0
175a5cd88959a34bcb4703d8dfe4d895e37463f0
1,566
interprep
MIT License
src/main/aoc2023/Day10.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 import AMap import Direction import Pos class Day10(input: List<String>) { private val map = AMap.parse(input) private val start = map.toMap().filterValues { it == 'S' }.keys.single() // All points on the right/left hand side of the loop while walking in one direction around the loop ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
6,209
aoc
MIT License
advent-of-code-2023/src/main/kotlin/Day23.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
// Day 23: A Long Walk // https://adventofcode.com/2023/day/23 import java.io.File private const val FOREST = '#' private const val PATH = '.' data class Tile(val char: Char, val xy: Pair<Int, Int>) fun main() { val trails = File("src/main/resources/Day23.txt").readLines().mapIndexed { x, chars -> chars...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,940
advent-of-code
Apache License 2.0
src/main/kotlin/Day19.kt
clechasseur
318,029,920
false
null
import org.clechasseur.adventofcode2020.Day19Data object Day19 { private val rules = Day19Data.rules private val messages = Day19Data.messages private val letterRuleRegex = """^(\d+): "(\w)"$""".toRegex() private val multiRuleRegex = """^(\d+): (\d+(?: \d+)*)$""".toRegex() private val orRuleRegex ...
0
Kotlin
0
0
6173c9da58e3118803ff6ec5b1f1fc1c134516cb
3,259
adventofcode2020
MIT License
src/main/kotlin/days/Day10Solution.kt
yigitozgumus
434,108,608
false
{"Kotlin": 17835}
package days import BaseSolution class Day10Solution(inputList: List<String>) : BaseSolution(inputList) { private fun getClosing(operator: Char): Char = when (operator) { '(' -> ')' '[' -> ']' '{' -> '}' else -> '>' } private fun isOpen(operator: Char): Boolean = listOf('(...
0
Kotlin
0
0
c0f6fc83fd4dac8f24dbd0d581563daf88fe166a
2,856
AdventOfCode2021
MIT License
src/day12/RouteCache.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day12 typealias RouteCacheEntry = Pair<Point, Int> class RouteCache (val terrain: Terrain) { val grid = Array<RouteCacheEntry?> (terrain.xs * terrain.ys) { null } fun toIndex(x: Int, y: Int) = y * terrain.xs + x fun toIndex (point: Point) = point.y * terrain.xs + point.x fun get (x: Int, y: In...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,787
advent_of_code_2022
Apache License 2.0
src/main/kotlin/day14.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day14() { val lines: List<String> = readFile("day14.txt") day14part1(lines) day14part2(lines) } fun day14part1(lines: List<String>) { val answer = findFinalPolymer(lines, 10) println("14a: $answer") } fun day14part2(lines: List<String>) { val answer = findFinalPolymer(lines, 40) pri...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,271
advent_of_code_2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RingsAndRods.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
3,317
kotlab
Apache License 2.0
AOC-2017/src/main/kotlin/Day07.kt
sagar-viradiya
117,343,471
false
{"Kotlin": 72737}
import utils.DiskUnbalancedException import utils.Node import utils.splitAtComma import utils.splitAtNewLines import java.util.regex.Matcher import java.util.regex.Pattern object Day07 { private val PATTERN = Pattern.compile("(\\w+) \\((\\d+)\\)( -> (.*))?") fun part1(input: String) : String { val m...
0
Kotlin
0
0
7f88418f4eb5bb59a69333595dffa19bee270064
3,229
advent-of-code
MIT License
src/main/kotlin/org/flightofstairs/ctci/treesAndGraphs/BinarySearchTree.kt
FlightOfStairs
509,587,102
false
{"Kotlin": 38930}
package org.flightofstairs.ctci.treesAndGraphs import org.flightofstairs.ctci.treesAndGraphs.BstDirection.LEFT import org.flightofstairs.ctci.treesAndGraphs.BstDirection.MATCH import org.flightofstairs.ctci.treesAndGraphs.BstDirection.RIGHT class BinarySearchTree<Key : Comparable<Key>, Value>(private val comparator: ...
0
Kotlin
0
0
5f4636ac342f0ee5e4f3517f7b5771e5aabe5992
3,854
FlightOfStairs-ctci
MIT License
app/src/main/kotlin/solution/Solution2131.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode import kotlin.math.* class Solution2131 { @Leetcode(2131) class Solution { fun longestPalindrome(words: Array<String>): Int { val counter = hashMapOf<String, Int>() var totalLength = 0 for (w in words) { ...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
2,162
leetcode-kotlin
MIT License
src/main/kotlin/io/github/ajoz/puzzles/Day02.kt
ajoz
574,043,593
false
{"Kotlin": 21275}
package io.github.ajoz.puzzles import io.github.ajoz.utils.readInput import java.lang.IllegalArgumentException /** * --- Day 2: Rock Paper Scissors --- * * The Elves begin to set up camp on the beach. To decide whose tent gets to be closest to the snack storage, a giant * Rock Paper Scissors tournament is already...
0
Kotlin
0
0
6ccc37a4078325edbc4ac1faed81fab4427845b8
5,706
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountNicePairs.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,905
kotlab
Apache License 2.0
src/main/kotlin/g0901_1000/s0920_number_of_music_playlists/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0920_number_of_music_playlists // #Hard #Dynamic_Programming #Math #Combinatorics // #2023_04_17_Time_136_ms_(100.00%)_Space_35.3_MB_(100.00%) class Solution { fun numMusicPlaylists(n: Int, l: Int, k: Int): Int { val dp = Array(l) { LongArray(n + 1) } for (i in 0 until l) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,283
LeetCode-in-Kotlin
MIT License
src/com/aaron/helloalgorithm/algorithm/数组/_20_有效的括号.kt
aaronzzx
431,740,908
false
null
package com.aaron.helloalgorithm.algorithm.数组 import com.aaron.helloalgorithm.algorithm.LeetCode import java.util.* /** * # 20. 有效的括号 * * 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 * * 有效字符串需满足: * * 左括号必须用相同类型的右括号闭合。 * 左括号必须以正确的顺序闭合。 * * 来源:力扣(LeetCode) * * 链接:[https://leetcode-cn.com/problems/val...
0
Kotlin
0
0
2d3d823b794fd0712990cbfef804ac2e138a9db3
1,716
HelloAlgorithm
Apache License 2.0
calendar/day14/Day14.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day14 import Day import Lines class Day14 : Day() { data class Point(val x: Int, val y: Int) val source = Point(500, 0) fun rockPoints(input: Lines): Set<Point> = input.flatMap { i -> i.split(" -> ") .map { vertex -> vertex.split(",").let { Point(it[0].toInt(), it[1].toInt()) } ...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
3,447
adventofcode-2022
Apache License 2.0
src/main/kotlin/days/Day18.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day18 : Day(18) { override fun partOne(): Any { return inputList.map { line -> parseNumber(line) }.reduce(FishNumber::plus).magnitude } override fun partTwo(): Any { return inputList.flatMap { one -> inputList.flatMap { another -> ...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
5,868
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/uber/tagir/advent2018/day02/day02.kt
groz
159,977,575
false
null
package com.uber.tagir.advent2018.day02 import com.uber.tagir.advent2018.utils.resourceAsString fun main(args: Array<String>) { Day02().checksum() Day02().findFabric() } data class Repetitions(val twice: Boolean, val thrice: Boolean) class Day02 { private val lines = resourceAsString("input.txt").lines(...
0
Kotlin
0
0
19b5a5b86c9a3d2803192b8c6786a25151b5144f
1,720
advent2018
MIT License
src/Day09.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
import java.lang.Integer.min import java.lang.Integer.max import kotlin.math.abs fun main() { var hPos = Pair(0, 0) var tPos = Pair(0, 0) fun calcTailMove(h: Pair<Int, Int>, t: Pair<Int, Int>, dir: String): Pair<Int, Int> { val (x, y) = h val (tx, ty) = t if (x == tx && y == ty)...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
6,027
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/sk/set2/289. Game of Life.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set2 private fun gameOfLife(board: Array<IntArray>) { val neighbors = intArrayOf(0, 1, -1) val rows = board.size val cols: Int = board[0].size val copyBoard = Array(rows) { IntArray(cols) } for (row in 0 until rows) { for (col in 0 until cols) { copyBoard[row][co...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
5,001
leetcode-kotlin
Apache License 2.0
src/commonMain/kotlin/eu/yeger/cyk/CYK.kt
DerYeger
302,742,119
false
null
package eu.yeger.cyk import eu.yeger.cyk.model.* import eu.yeger.cyk.model.withSymbolAt import eu.yeger.cyk.parser.word public fun cyk( wordString: String, grammar: () -> Result<Grammar> ): Result<CYKModel> { return word(wordString).with(grammar(), ::cyk) } public fun cyk( word: Result<Word>, gra...
0
Kotlin
0
2
76b895e3e8ea6b696b3ad6595493fda9ee3da067
2,432
cyk-algorithm
MIT License
leetcode/src/offer/Offer32.kt
zhangweizhe
387,808,774
false
null
package offer import linkedlist.TreeNode import java.util.* import kotlin.collections.ArrayList fun main() { // 剑指 Offer 32 - II. 从上到下打印二叉树 II // https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-ii-lcof/ val root = TreeNode(3) root.left = TreeNode(9) root.right = TreeNode(20)...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,882
kotlin-study
MIT License
src/main/kotlin/quantum/core/QuantumState.kt
AlexanderScherbatiy
155,193,555
false
{"Kotlin": 58447}
package quantum.core import quantum.core.Complex.Companion.One import quantum.core.Complex.Companion.Zero interface QuantumState { val size: Int operator fun get(index: Int): Complex infix fun scalar(other: QuantumState): Complex { var scalar = Complex.Zero for (i in 0 until size) { ...
0
Kotlin
0
0
673dd1c2a6c9964700ea682d49410d10843070db
4,615
quntum-gates
Apache License 2.0
Kotlin/problems/0004_advantage_shuffle.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
//Problem Statement // Given two arrays A and B of equal size, the advantage of A with // respect to B is the number of indices i for which A[i] > B[i]. // // Return any permutation of A that maximizes its advantage with respect to B. class Solution { fun advantageCount(A: IntArray, B: IntArray): IntArray { ...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,451
algorithms
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/OddStringDifference.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,008
kotlab
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day21/Day21.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day21 import eu.janvdb.aocutil.kotlin.runWithTimer import kotlin.math.max //val START_1 = Player(4) //val START_2 = Player(8) val START_1 = Player(3) val START_2 = Player(5) fun main() { runWithTimer("Part 1", ::part1) runWithTimer("Part 2", ::part2) } private fun part1() { val die = D...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,076
advent-of-code
Apache License 2.0
src/day22/Code.kt
fcolasuonno
225,219,560
false
null
package day22 import isDebug import java.io.File import java.math.BigInteger 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/$dir/$name").readLines() val parsed = parse(input) println(...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
3,490
AOC2019
MIT License
src/main/kotlin/aoc2018/day3/FabricClaimCalculator.kt
arnab
75,525,311
false
null
package aoc2018.day3 data class Square(val x: Int, val y: Int) data class Claim( val id: Int, val left: Int, val top: Int, val width: Int, val height: Int, val topLeftSquare: Square = Square(left, top), val bottomRightSquare: Square = Square(left + width - 1, top + height - 1) ) { fun ...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,978
adventofcode
MIT License
src/main/adventofcode/Day07Solver.kt
eduardofandrade
317,942,586
false
null
package adventofcode import java.io.InputStream class Day07Solver(stream: InputStream) : Solver { private val bags: HashMap<String, Bag> = hashMapOf() init { processInput(stream) } private fun processInput(stream: InputStream) { val bagRuleRegex = " bags| bag[s]? | bag[s]?\\.|\\.\$|...
0
Kotlin
0
0
147553654412ae1da4b803328e9fc13700280c17
1,991
adventofcode2020
MIT License
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day11/Day11.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day11 import nl.sanderp.aoc.common.* import java.util.* fun main() { val input = readResource("Day11.txt").lines().map { line -> line.map { it.asDigit() } } val (answer1, duration1) = measureDuration<Int> { partOne(input) } println("Part one: $answer1 (took ${duration1.pret...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,686
advent-of-code
MIT License
StreamCiphers/src/main/kotlin/utils/BBSAnalyzer.kt
damcyb
427,749,560
false
{"Kotlin": 73312, "HTML": 39484, "JavaScript": 21008, "CSS": 15120, "PowerShell": 8834, "Python": 3780, "PureBasic": 3134, "Shell": 2894, "Java": 2266, "Assembly": 253}
package utils import java.math.BigDecimal class BBSAnalyzer { fun countOnes(bbs: String): Int = bbs.count { c: Char -> c == '1'} fun countSeries(bbs: String, character: Char): Map<Int, Int> { val occurrencesMap: MutableMap<Int, Int> = initializeOccurrencesMap() var lastFoundChar: Char = 'x' ...
0
Kotlin
0
0
1dd03a20e69e1b3f73b03b9e286c9978e1f122a1
3,074
BasicsOfCryptography
MIT License
src/Day05.kt
nikolakasev
572,681,478
false
{"Kotlin": 35834}
fun main() { fun part1(crates: List<ArrayDeque<String>>, input: String): String { "(\\d+)".toRegex().findAll(input.split("\n\n")[1]).chunked(3).forEach { val amount = it[0].value.toInt() val from = it[1].value.toInt() - 1 val to = it[2].value.toInt() - 1 (1.....
0
Kotlin
0
1
5620296f1e7f2714c09cdb18c5aa6c59f06b73e6
1,883
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/adventofcode/y2021/Day09.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.GridNode fun main() { val testInput = """ 2199943210 3987894921 9856789892 8767896789 9899965678 """.trimIndent() val test = Day09(testInput) println("TEST: " + test.part1()) println("TEST: " + test.part2()) val day = Day09() val...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
1,984
adventofcode2021
The Unlicense
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day11.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2018.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.applyIf import nl.jstege.adventofcode.aoccommon.utils.extensions.head import nl.jstege.adventofcode.aoccommon.utils.extensions.min import kotlin.math.min class Day11 : ...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
2,483
AdventOfCode
MIT License
src/main/kotlin/io/nozemi/aoc/solutions/year2021/day11/DumboOctopus.kt
Nozemi
433,882,587
false
{"Kotlin": 92614, "Shell": 421}
package io.nozemi.aoc.solutions.year2021.day11 import io.nozemi.aoc.puzzle.Puzzle import kotlin.reflect.KFunction0 fun main() { DumboOctopus( """ 5665114554 4882665427 6185582113 7762852744 7255621841 8842753123 8225372176 7212865827 ...
0
Kotlin
0
0
fc7994829e4329e9a726154ffc19e5c0135f5442
5,339
advent-of-code
MIT License
src/main/kotlin/io/dmitrijs/aoc2022/Day02.kt
lakiboy
578,268,213
false
{"Kotlin": 76651}
package io.dmitrijs.aoc2022 class Day02(private val input: List<String>) { fun puzzle1() = input.map(::createGame).sumOf { it.myScore } fun puzzle2() = input.map(::createPrediction).sumOf { it.game.myScore } private fun createGame(moves: String) = Shape.of(moves[0]) to Shape.of(moves[2]) private fun...
0
Kotlin
0
1
bfce0f4cb924834d44b3aae14686d1c834621456
2,016
advent-of-code-2022-kotlin
Apache License 2.0
src/algorithmsinanutshell/spatialtree/QuadTree.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell.spatialtree import algorithmsinanutshell.Point /** * https://algs4.cs.princeton.edu/92search/QuadTree.java.html * * https://www.youtube.com/watch?v=jxbDYxm-pXg * * https://www.youtube.com/watch?v=xFcQaig5Z2A */ class QuadTree { /** * QuadNode consists of a value and 4 qua...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,061
algorithms
MIT License
src/test/kotlin/Day20.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe import kotlin.math.sqrt /* --- Day 20: Jurassic Jigsaw --- See https://adventofcode.com/2020/day/20 */ fun findSolutionTiles(tiles: List<Tile>): List<List<Tile>> { val expectedSizeOfSolution = sqrt(tiles.size.toFloat()).toInt() val...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
24,969
advent_of_code_2020
Apache License 2.0
src/day01/Day01.kt
skempy
572,602,725
false
{"Kotlin": 13581}
package day01 import readInputAsString fun main() { data class Elf(val calories: List<Int>) fun part1(input: String): Int { val elves = input.split("\n\n").map { group -> Elf(group.split("\n").map { it.toInt() }) } return elves.maxOf { it.calories.sum() } } fun part2(input: String):...
0
Kotlin
0
0
9b6997b976ea007735898083fdae7d48e0453d7f
947
AdventOfCode2022
Apache License 2.0
day-22/src/main/kotlin/ReactorReboot.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis fun main() { val partOneMillis = measureTimeMillis { println("Part One Solution: ${partOne()}") } println("Part One Solved in: $partOneMillis ms") val partTwoMillis = measureTimeMillis { println("Part ...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
8,398
aoc-2021
MIT License
workshops/moscow_prefinals2020/day3/k.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package workshops.moscow_prefinals2020.day3 fun main() { val (x, y, z) = List(3) { readInts().drop(1).reversed() } var (low, high) = maxOf((x + y + z).maxOrNull()!!, 1).toLong() to Long.MAX_VALUE / 2 binarySearch@while (low + 1 < high) { val b = (low + high) / 2 val zNew = LongArray(z.size) var tooLarge = fal...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,042
competitions
The Unlicense
src/Day03.kt
ChrisCrisis
575,611,028
false
{"Kotlin": 31591}
import java.lang.IllegalStateException fun main() { fun processInput(data: List<String>): List<Char> { return data.map{ bucket -> val firstHalf = bucket.substring(0 until bucket.length/2) val secondHalf = bucket.substring(bucket.length/2 until bucket.length ) firstHalf....
1
Kotlin
0
0
732b29551d987f246e12b0fa7b26692666bf0e24
1,575
aoc2022-kotlin
Apache License 2.0
src/Day03.kt
ty-garside
573,030,387
false
{"Kotlin": 75779}
// Day 03 - Rucksack Reorganization // https://adventofcode.com/2022/day/3 fun main() { fun compartments(line: String): Pair<String, String> { val mid = line.length / 2 return line.substring(0, mid) to line.substring(mid, line.length) } fun priority(char: Char) = when { ...
0
Kotlin
0
0
49ea6e3ad385b592867676766dafc48625568867
5,904
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/g1501_1600/s1559_detect_cycles_in_2d_grid/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1559_detect_cycles_in_2d_grid // #Medium #Array #Depth_First_Search #Breadth_First_Search #Matrix #Union_Find // #2023_06_13_Time_871_ms_(33.33%)_Space_103.6_MB_(33.33%) class Solution { fun containsCycle(grid: Array<CharArray>): Boolean { val n = grid.size val m = grid[0].size...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,308
LeetCode-in-Kotlin
MIT License
app/src/main/java/com/alpriest/energystats/ui/statsgraph/SelfSufficiencyCalculator.kt
alpriest
606,081,400
false
{"Kotlin": 742930}
package com.alpriest.energystats.ui.statsgraph import com.alpriest.energystats.models.rounded import com.alpriest.energystats.ui.CalculationBreakdown import com.alpriest.energystats.ui.flow.roundedToString import kotlin.math.pow import kotlin.math.roundToInt class AbsoluteSelfSufficiencyCalculator { fun calculate...
6
Kotlin
3
3
6de8f2a01a047aa1fe79d8888673141612e37a3b
2,667
EnergyStats-Android
MIT License
src/main/kotlin/Day13.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
data class Dot(val x: Int, val y: Int) fun main() { val data = readInputFile("day13") var dots = makeData(data) fun makeDots(s: String, value: Int) { dots = if (s.first() == 'x') { dots.map { p -> if (p.x > value) { Dot(2 * value - p.x, p.y) ...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
1,899
AOC2021
Apache License 2.0
src/main/kotlin/com/sk/topicWise/dp/medium/1043. Partition Array for Maximum Sum.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.dp.medium class Solution1043 { fun maxSumAfterPartitioning(arr: IntArray, k: Int): Int { val dp = IntArray(arr.size) { -1 } fun maxFromCurrentPart(s: Int, e: Int): Int { val start = maxOf(0, s) val end = e return arr.slice(start..end).ma...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,254
leetcode-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ValidPathInGraph.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
5,610
kotlab
Apache License 2.0
src/main/kotlin/com/vvv/engine/utils/Trie.kt
vicol13
530,589,547
false
{"Kotlin": 40611, "Jupyter Notebook": 36031}
package com.vvv.engine.utils import java.util.TreeMap import kotlin.RuntimeException class TrieException(msg: String) : RuntimeException(msg) /** * Class which represent trie structure for input recommendation * * Beside child node each tree has a property word, which mean * this tree is a leaf(represent a wor...
0
Kotlin
0
1
534a40c5a4c0b02f1935ba4ea976d47cd8c43485
4,363
search-engine
MIT License
app/src/main/java/site/paulo/pathfinding/algorithm/Djikstra.kt
paulofernando
238,713,514
false
{"Kotlin": 117418}
package site.paulo.pathfinding.algorithm import site.paulo.pathfinding.data.model.graph.GraphTypes import site.paulo.pathfinding.data.model.Node import site.paulo.pathfinding.data.model.PathFindingAlgorithms import java.util.* import kotlin.collections.HashMap open class Djikstra ( var graph: LinkedList<Node>, ...
0
Kotlin
0
7
ba6c2438159424fdb325191cb94d78daf404db3c
3,894
pathfinding
MIT License
src/day17/Day17.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day17 import containsAny import readInput enum class Direction(val symbol: Char, val vec: Point) { UP('^', Point(0, 1)), RIGHT('>', Point(1, 0)), DOWN('v', Point(0, -1)), LEFT('<', Point(-1, 0)); companion object { private val symbolMap = Direction.values().associateBy { it.symbol...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
6,365
aoc-2022
Apache License 2.0
src/Day14.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
fun main() { val grid = mutableSetOf<Pair<Int, Int>>() fun part1(input: List<String>, bottom: Boolean = false): Int { fun diff(x: Int, y: Int) = if (x == y) 0 else { if (x < y) 1 else -1 } var maxy = 0 for (s in input) { val splits = s.split(" -> ") ...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
2,100
AOC-2022
Apache License 2.0
algorithms/src/main/kotlin/com/kotlinground/algorithms/backtracking/restoreipaddresses/restoreIpAddresses.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.backtracking.restoreipaddresses /** * Complexity Analysis * Let's assume we need to separate the input string into N integers, each integer is at most M digits. * * - Time complexity: O(M ^ N * N) * There are at most M ^ {N - 1} possibilities, and for each possibility checking ...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
4,796
KotlinGround
MIT License
Lapindrome.kt
sysion
353,734,921
false
null
/** * https://www.codechef.com/problems/LAPIN * * * Lapindromes Problem Code: LAPIN * * Lapindrome is defined as a string which when split in the middle, gives two halves * having the same characters and same frequency of each character. If there are odd * number of characters in the string, we ignore the middle char...
0
Kotlin
0
0
6f9afda7f70264456c93a69184f37156abc49c5f
2,491
DataStructureAlgorithmKt
Apache License 2.0
03/src/commonMain/kotlin/Main.kt
daphil19
725,415,769
false
{"Kotlin": 131380}
expect fun getLines(inputOrPath: String): List<String> fun main() { var lines = getLines(INPUT_FILE) // lines = ("467..114..\n" + // "...*......\n" + // "..35..633.\n" + // "......#...\n" + // "617*......\n" + // ".....+.58.\n" + // "..592.....\...
0
Kotlin
0
0
70646b330cc1cea4828a10a6bb825212e2f0fb18
3,946
advent-of-code-2023
Apache License 2.0
src/main/kotlin/aoc2017/HexEd.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import kotlin.math.absoluteValue fun hexEdDistance(input: String): Int = hexEdDistance(input.split(",").map { HexMove.valueOf(it.toUpperCase().trim()) }) fun hexEdMaxDistance(input: String): Int = hexEdMaxDistance(input.split(",").map { HexMove.valueOf(it.toUpperCase().trim(...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,176
advent-of-code
MIT License
src/Day17.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
sealed class Block { class HorizLine : Block() { override val shape = listOf( "####".toCharArray() ) } class Cross : Block() { override val shape = listOf( ".#.".toCharArray(), "###".toCharArray(), ".#.".toCharArray() ) } ...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,322
KotlinAdventOfCode2022
Apache License 2.0
src/main/kotlin/g1901_2000/s1998_gcd_sort_of_an_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1998_gcd_sort_of_an_array // #Hard #Array #Math #Sorting #Union_Find #2023_06_21_Time_437_ms_(100.00%)_Space_45.4_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun gcdSort(nums: IntArray): Boolean { val sorted = nums.clone() sorted.sort() val len = nums.size...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,990
LeetCode-in-Kotlin
MIT License
src/main/kotlin/lib/Solver.kt
jetpants
130,976,101
false
null
package judoku class Solver(private val puzzle: Grid) { init { check(puzzle.isLegal()) } fun findSolution(): Grid? { val solutions = findSolutions(1) return if (solutions.size == 0) null else solutions[0] } fun findSolutions(max: Int): ArrayList<Grid> { val solutions = ArrayLi...
0
Kotlin
2
3
904c05456ecf83f8707f4d3c6c5afa0a50f4b9e7
7,041
judoku
Apache License 2.0
src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1072_flip_columns_for_maximum_number_of_equal_rows // #Medium #Array #Hash_Table #Matrix #2023_05_31_Time_536_ms_(100.00%)_Space_108.4_MB_(50.00%) class Solution { fun maxEqualRowsAfterFlips(matrix: Array<IntArray>): Int { /* Idea: For a given row[i], 0<=i<m, row[j], 0<...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,523
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/dmc/advent2022/Day07.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
package com.dmc.advent2022 import kotlin.time.ExperimentalTime import kotlin.time.measureTime // --- Day 7: No Space Left On Device --- class Day07 : Day<Int> { override val index = 7 fun parseInput(input: List<String>) : List<Directory> { val root = Directory("/") val dirs = mutableListOf(r...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
4,024
aoc-2022-kotlin
Apache License 2.0
src/Day09.kt
Totwart123
573,119,178
false
null
import kotlin.math.absoluteValue fun main() { data class MutablePair(var first: Int, var second: Int){ override fun equals(other: Any?): Boolean { if(other?.javaClass != javaClass) return false other as MutablePair return other.first == first && other.second == second...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
7,007
AoC
Apache License 2.0
2022/src/main/kotlin/day3_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.map import utils.mapItems import utils.split object Day3All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day3Func, "imp" to Day3Imp, "fast" to Day3Fast).forEach { (header, solution) -> solution.run( header = header, prin...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,060
aoc_kotlin
MIT License
src/Lesson5PrefixSums/PassingCars.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { var numCarsGoingEast = 0 var numPassing = 0 if (A.size > 1) { for (i in A.indices) { if (A[i] == 0) { numCarsGoingEast++ } else { numPassing += numCarsGoingEast ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
1,686
Codility-Kotlin
Apache License 2.0
src/day10/Day10.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day10 import Runner fun main() { Day10Runner().solve() } class Day10Runner : Runner<Int>( day = 10, expectedPartOneTestAnswer = 13140, expectedPartTwoTestAnswer = null ) { override fun partOne(input: List<String>, test: Boolean): Int { val cycles = cycles(input) return li...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
1,832
advent-of-code
Apache License 2.0
src/9DynamicProgramming2/TheCitrusIntern.kt
bejohi
136,087,641
false
{"Java": 63408, "Kotlin": 5933, "C++": 5711, "Python": 3670}
import java.util.* // Solution for https://open.kattis.com/problems/citrusintern // With help from https://github.com/amartop var numberOfEmployees = 0 var input = Scanner(System.`in`) var costs = mutableListOf<Int>() var inL = arrayOf<Long>() var outUpL = arrayOf<Long>() var outDownL = arrayOf<Long>() var root = -1 ...
0
Java
0
0
7e346636786215dee4c681b80bc694c8e016e762
2,072
UiB_INF237
MIT License
y2017/src/main/kotlin/adventofcode/y2017/Day19.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution object Day19 : AdventSolution(2017, 19, "A Series of Tubes") { override fun solvePartOne(input: String): String { val lines = input.lines() val pipeRunner = PipeRunner(lines) pipeRunner.run() return pipeRunner.word } override fun solvePartT...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,283
advent-of-code
MIT License
src/main/kotlin/g2701_2800/s2746_decremental_string_concatenation/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2701_2800.s2746_decremental_string_concatenation // #Medium #Array #String #Dynamic_Programming // #2023_08_08_Time_264_ms_(100.00%)_Space_44.7_MB_(59.38%) class Solution { private val inf = 1e9.toInt() private lateinit var dp: Array<Array<Array<Int?>>> fun minimizeConcatenatedLength(words: Arra...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,780
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g1501_1600/s1519_number_of_nodes_in_the_sub_tree_with_the_same_label/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1519_number_of_nodes_in_the_sub_tree_with_the_same_label // #Medium #Hash_Table #Depth_First_Search #Breadth_First_Search #Tree #Counting // #2023_06_12_Time_1130_ms_(87.50%)_Space_290.4_MB_(12.50%) class Solution { fun countSubTrees(n: Int, edges: Array<IntArray>, labelsString: String): IntAr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,757
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Day9.kt
corentinnormand
725,992,109
false
{"Kotlin": 40576}
fun main(args: Array<String>) { Day9().two() } class Day9 : Aoc("day9.txt") { val test = """ 10 13 16 21 30 45 """.trimIndent() override fun one() { val input = readFile("day9.txt").lines() val first = input .map { it.split(" ") } .map { it.map { str -> str.to...
0
Kotlin
0
0
2b177a98ab112850b0f985c5926d15493a9a1373
2,115
aoc_2023
Apache License 2.0
src/main/kotlin/aoc/Day8.kt
dtsaryov
573,392,550
false
{"Kotlin": 28947}
package aoc /** * [AoC 2022: Day 8](https://adventofcode.com/2022/day/8) */ fun amountOfVisibleTrees(input: List<String>): Int { val grid = parseGrid(input) val visibleTrees = mutableSetOf<Pair<Int, Int>>() walk(grid) { tree, i, j -> if (visibleFromTop(tree, i, j, grid)) visibleTree...
0
Kotlin
0
0
549f255f18b35e5f52ebcd030476993e31185ad3
3,777
aoc-2022
Apache License 2.0
src/Lesson3TimeComplexity/PermMissingElem.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Arrays /** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { Arrays.sort(A) if (A.size == 0 || A[0] != 1) return 1 for (i in 0 until A.size - 1) { if (A[i] + 1 != A[i + 1]) { return A[i] + 1 } } return A[A.size - 1] + 1 } /** * An...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
1,077
Codility-Kotlin
Apache License 2.0
src/main/kotlin/com/sk/leetcode/kotlin/253. Meeting Rooms II.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package leetcode.kotlin.array.easy import java.util.PriorityQueue private fun minMeetingRooms(intervals: Array<IntArray>): Int { intervals.sortBy { it[0] } var pq = PriorityQueue<IntArray>() { a1, a2 -> a1[1] - a2[1] } // sort by end time for (meeting in intervals) { if (!pq.isEmpty() && pq.peek(...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,676
leetcode-kotlin
Apache License 2.0
src/main/kotlin/g1701_1800/s1755_closest_subsequence_sum/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1755_closest_subsequence_sum // #Hard #Array #Dynamic_Programming #Two_Pointers #Bit_Manipulation #Bitmask // #2023_06_18_Time_620_ms_(100.00%)_Space_43.5_MB_(100.00%) class Solution { private var idx = 0 private var sum = 0 fun minAbsDifference(nums: IntArray, goal: Int): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,414
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day4.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger class Day4 : AdventDay(2021, 4) { companion object { @JvmStatic fun main(args: Array<String>) { val d...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,072
adventofcode
MIT License
src/Day03.kt
azarovalex
573,931,704
false
{"Kotlin": 4391}
fun main() { val costs = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun part1(input: List<String>): Int { return input .map { val halfSize = it.length / 2 val leftHalf = it.subSequence(0, halfSize) val rightHalf = it.subSequence(h...
0
Kotlin
0
0
48578aeed4250987d4ee339d801f8d5e6577b55b
918
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g2901_3000/s2983_palindrome_rearrangement_queries/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2983_palindrome_rearrangement_queries // #Hard #String #Hash_Table #Prefix_Sum #2024_01_19_Time_905_ms_(87.50%)_Space_131.9_MB_(37.50%) class Solution { private var n = 0 // get associated index in the other half private fun opp(i: Int): Int { return n - 1 - i } fun c...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
4,573
LeetCode-in-Kotlin
MIT License
src/Day01.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
fun main() { fun parseInput(input: List<String>): List<List<Int>> { return input.fold(emptyList()) { acc, cal -> when { cal.isBlank() -> acc.plusElement(emptyList()) else -> acc.dropLast(1).plusElement((acc.lastOrNull() ?: emptyList()) + cal.toInt()) } ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
886
aoc22
Apache License 2.0
src/main/kotlin/info/dgjones/barnable/parser/TextSplitter.kt
jonesd
442,279,905
false
{"Kotlin": 474251}
/* * 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...
1
Kotlin
0
0
b5b7453e2fe0b2ae7b21533db1b2b437b294c63f
2,428
barnable
Apache License 2.0
src/main/kotlin/twentytwenty/Day11.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwenty fun main() { var input = {}.javaClass.getResource("twentytwenty/input11.txt").readText().lines().asSequence() .map { it.toCharArray().toMutableList() } .toList() SeatingArea({}.javaClass.getResource("twentytwenty/input11.txt").readText().lines()).countStableState().also { ...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
3,565
aoc202xkotlin
The Unlicense
src/main/kotlin/com/polydus/aoc18/Day15.kt
Polydus
160,193,832
false
null
package com.polydus.aoc18 class Day15: Day(15){ //https://adventofcode.com/2018/day/15 val height = input.size val width = input.sortedBy { it.length }.last().length val map = Array(height) {CharArray(width){ ' '}} val mapVecs = Array(height) {Array<Vec?>(width) {null} } val goblins = arr...
0
Kotlin
0
0
e510e4a9801c228057cb107e3e7463d4a946bdae
18,752
advent-of-code-2018
MIT License
src/year_2022/day_07/Day07.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_07 import readInput import java.util.Stack sealed class IFile { data class Directory( val name: String, var files: MutableList<IFile> = mutableListOf() ): IFile() { fun totalSize(): Int { return files.sumOf { file -> when (file) { ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
5,124
advent_of_code
Apache License 2.0
src/Day08.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
fun main() { fun parseArray(input: List<String>): Array<IntArray> { val row = input.size val column = input[0].length val array = Array(row) { IntArray(column) } for (r in 0 until row) { val line = input[r] for (c in 0 until column) { array[r]...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
3,272
AdventOfCode-2022
Apache License 2.0