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/io/github/clechasseur/adventofcode/y2015/Day2.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import io.github.clechasseur.adventofcode.y2015.data.Day2Data object Day2 { private val input = Day2Data.input fun part1(): Int = input.lines().map { it.toPresent() }.sumOf { it.requiredPaper } fun part2(): Int = input.lines().map { it.toPresent() }.sumOf...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
1,103
adventofcode2015
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/SymmetricTree.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,917
kotlab
Apache License 2.0
src/kotlin2023/Day02.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2023 import readInput import java.lang.IllegalStateException fun main() { val lines = readInput("kotlin2023/Day02_test") println(minimumSet(lines)) } fun minimumSet(input: List<String>): Int { return input.sumOf { val parsedLine = it.substring(it.indexOf(": ") + 1) val gameS...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
1,111
advent-of-code-kotlin
Apache License 2.0
src/Day10.kt
dmstocking
575,012,721
false
{"Kotlin": 40350}
class Cpu { private var tick = 0 private var x = 1 fun line() = StringBuilder("........................................") var screen = listOf(line()) var data = listOf<Int>() fun noop() = tick() fun addx(i: Int) { tick() tick { x += i } } fun tick(action: () ->...
0
Kotlin
0
0
e49d9247340037e4e70f55b0c201b3a39edd0a0f
1,594
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/day01/sonarSweep.kt
aesdeef
433,698,136
false
{"Python": 118972, "Elm": 30537, "JavaScript": 6228, "Kotlin": 2090, "HTML": 244}
package day01 import java.io.File fun main() { val depths = parseInput() val part1 = countIncreases(depths) val slidingWindows = getSlidingWindows(depths) val part2 = countIncreases(slidingWindows) println(part1) println(part2) } fun parseInput(): List<Int> { return File("../../input/01....
0
Python
0
2
4561bcf12ac03d360f5b28c48ef80134f97613b9
859
advent-of-code-2021
MIT License
src/Day15.kt
joshpierce
573,265,121
false
{"Kotlin": 46425}
import java.io.File import kotlin.collections.fill import java.math.BigInteger // So... this returned a couple possible solutions for part 2, the first one that came out ended up being correct // and it's 01:28a so I'm going to bed. Hopefully I'll find time tomorrow to come back to this to clean it up. fun main() { ...
0
Kotlin
0
1
fd5414c3ab919913ed0cd961348c8644db0330f4
7,244
advent-of-code-22
Apache License 2.0
kotlin/524.Longest Word in Dictionary through Deleting(通过删除字母匹配到字典里最长单词).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p> Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty str...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
2,767
leetcode
MIT License
src/Day01.kt
BurgundyDev
572,937,542
false
{"Kotlin": 11050}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("../inputs/Day01_test") check(part1(testInput) == 24000) check(part2(testInput) == 45000) val input = readInput("../inputs/Day01") println(part1(input)) println(part2(input)) } fun gr...
0
Kotlin
0
0
dd931604fa35f75599ef778fc3f0f8bc82b2fce0
949
aoc2022-kotlin
Apache License 2.0
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/Utils.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019 import java.io.File import kotlin.math.PI import kotlin.math.abs import kotlin.math.atan2 const val R90 = PI / 2 const val R360 = PI * 2 fun readFileAsString(name: String): String { return File(name).readText() } fun readFileAsLines(name: String): List<String>...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
2,029
advent-of-code
Apache License 2.0
src/main/java/aoc_2019/Day02.kt
frenchfrie
161,678,638
false
{"Java": 64581, "Kotlin": 12191}
package aoc_2019 import org.slf4j.LoggerFactory import java.util.function.Function import java.util.stream.Collectors import java.util.stream.Stream class Day02 { private val log = LoggerFactory.getLogger(javaClass) fun solve(input: Stream<Int>, noun: Int? = null, verb: Int? = null): List<Int> { val...
2
Java
0
0
b21c991277ce8ae76338620c7002699fb8279f75
3,789
advent-of-code
Apache License 2.0
src/main/kotlin/dev/wilerson/aoc/day5/Day05.kt
wilerson
572,902,668
false
{"Kotlin": 8272}
package dev.wilerson.aoc.day5 import dev.wilerson.aoc.utils.chunkedByPredicate import dev.wilerson.aoc.utils.readInput fun main() { val input = readInput("day5input") val (stacksWithNumbers, instructions) = input.chunkedByPredicate { it != "" } val crateIndices = listOf(1, 5, 9, 13, 17, 21, 25, 29, 33) ...
0
Kotlin
0
0
d6121ef600783c18696211d43b62284f4700adeb
1,324
kotlin-aoc-2022
Apache License 2.0
LeetCode/Medium/top-k-frequent-words/Solution.kt
GregoryHo
254,657,102
false
null
import java.util.PriorityQueue class Solution { fun topKFrequent(words: Array<String>, k: Int): List<String> { val counts = HashMap<String, Int>() for (word in words) { counts[word] = counts.getOrDefault(word, 0) + 1 } val priorityQueue = PriorityQueue<String>(Comparator { o1, o2 -> if ...
0
Kotlin
0
0
8f126ffdf75aa83a6d60689e0b6fcc966a173c70
942
coding-fun
MIT License
baparker/03/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File import kotlin.collections.mutableListOf fun getPowerConsumption() { var countList = IntArray(12) var lineCount = 0 File("input.txt").forEachLine { for (index in it.indices) { countList[index] += it[index].digitToInt() } lineCount++ } var gamm...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
2,451
advent-of-code-2021
MIT License
src/main/kotlin/CollectionFunctions.kt
mustajab-ikram
533,452,617
false
{"Kotlin": 95245}
fun main() { // #Remove Duplicate Strings // There are many ways to remove duplicate strings from an array: // Maintain the original order of items val devs = arrayOf("Amit", "Ali", "Amit", "Sumit", "Sumit", "Himanshu") println(devs.distinct()) // [Amit, Ali, Sumit, Himanshu] // Maintain the original ...
0
Kotlin
0
4
f3293e91212e973945a96f6ae90f2c442acb9298
15,108
Kotlin_Tutorial
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day23/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day23 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntList import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap private const val DUMP_PATH = false val test = TestInput(""" ############# #...........# ###B#C#...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
7,009
aoc
MIT License
src/medium/_36ValidSudoku.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package medium class _36ValidSudoku { class HashMapSolution { fun isValidSudoku(board: Array<CharArray>): Boolean { val rows = Array(9) { HashMap<Int, Int>(9) } val columns = Array(9) { HashMap<Int, Int>(9) } val boxes = Array(9) { HashMap<Int, Int>(9) } for ...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
2,958
AlgorithmsProject
Apache License 2.0
kotlin.web.demo.server/examples/Kotlin Koans/Generics/Generic functions/Solution.kt
JetBrains
3,602,279
false
null
import java.util.* <answer>fun <T, C: MutableCollection<T>> Collection<T>.partitionTo(first: C, second: C, predicate: (T) -> Boolean): Pair<C, C> { for (element in this) { if (predicate(element)) { first.add(element) } else { second.add(element) } } return Pa...
14
Kotlin
75
169
74eb79018f3f6b8d023fa0ef1a4b853503fe97a5
836
kotlin-web-demo
Apache License 2.0
solutions/aockt/y2023/Y2023D22.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import aockt.util.spacial.Area import aockt.util.spacial.overlaps import aockt.util.spacial3d.Point3D import io.github.jadarma.aockt.core.Solution object Y2023D22 : Solution { /** A line of sand cubes, defined by the [start] and [end] coordinates. */ private data c...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
6,003
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/org/domnikl/algorithms/sorting/QuickSort.kt
domnikl
231,452,742
false
null
package org.domnikl.algorithms.sorting fun <T : Comparable<T>> Array<T>.quickSort(): Array<T> { return this.quickSort(0, this.size - 1) } private fun <T : Comparable<T>> Array<T>.quickSort(low: Int, high: Int): Array<T> { if (low < high) { val p = this.partition(low, high) this.quickSort(low, ...
5
Kotlin
3
13
3b2c191876e58415d8221e511e6151a8747d15dc
794
algorithms-and-data-structures
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem655/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem655 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [655. Print Binary Tree](https://leetcode.com/problems/print-binary-tree/); */ class Solution { private val strOfEmptyCell = "" /* Complexity: * Time O(H * 2^H) and Space O(H * 2^H) wher...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,639
hj-leetcode-kotlin
Apache License 2.0
2021/src/main/kotlin/org/suggs/adventofcode/Day10SyntaxScoring.kt
suggitpe
321,028,552
false
{"Kotlin": 156836}
package org.suggs.adventofcode import org.slf4j.LoggerFactory object Day10SyntaxScoring { private val log = LoggerFactory.getLogger(this::class.java) private val charMap: Map<Char, Char> = mapOf('{' to '}', '<' to '>', '[' to ']', '(' to ')') private val valueMap: Map<Char, Int> = mapOf(')' to 3, ']' to ...
0
Kotlin
0
0
9485010cc0ca6e9dff447006d3414cf1709e279e
2,237
advent-of-code
Apache License 2.0
src/Day11.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import java.util.concurrent.atomic.AtomicLong class MonkeyRouter(rule: String, ifTrue: String, ifFalse: String) { val divisible: Long private val trueRoute: Int private val falseRoute: Int init { divisible = rule.removePrefix(" Test: divisible by ").toLong() trueRoute = ifTrue.remove...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
4,784
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day10.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DAY_FILE import util.DayInput import util.GridCell import util.Matrix import java.util.* class Day10 : Day("10") { /* | is a vertical pipe connecting north and south. - is a horizontal pipe connecting east and west. L is a 90-degree bend connecting north and east....
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
6,867
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/leetcode/Problem1402.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import kotlin.math.max /** * https://leetcode.com/problems/reducing-dishes/ */ class Problem1402 { fun maxSatisfaction(satisfaction: IntArray): Int { satisfaction.sort() return maxSatisfaction(satisfaction, 0, 1, Array(satisfaction.size) { IntArray( s...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
889
leetcode
MIT License
src/main/kotlin/days/Day13.kt
andilau
726,429,411
false
{"Kotlin": 37060}
package days @AdventOfCodePuzzle( name = "Point of Incidence", url = "https://adventofcode.com/2023/day/13", date = Date(day = 13, year = 2023) ) class Day13(input: List<String>) : Puzzle { private val patterns: List<List<String>> = extractPatterns(input) override fun partOne(): Int = pat...
3
Kotlin
0
0
9a1f13a9815ab42d7fd1d9e6048085038d26da90
1,537
advent-of-code-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/org/example/adventofcode/puzzle/Day08.kt
nikos-ds
573,046,617
false
null
package org.example.adventofcode.puzzle import org.example.adventofcode.util.FileLoader import java.util.stream.IntStream object Day08 { private const val FILE_PATH = "/day-08-input.txt" fun printSolution() { println("- part 1: ${getResult(Day08::part1Calculator)}") println("- part 2: ${getRe...
0
Kotlin
0
0
3f97096ebcd19f971653762fe29ddec1e379d09a
3,821
advent-of-code-2022-kotlin
MIT License
src/main/kotlin/ca/kiaira/advent2023/day15/Day15.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day15 import ca.kiaira.advent2023.Puzzle import java.util.* /** * Day15 is an object representing the puzzle for Advent of Code 2023, Day 15. * It inherits from the [Puzzle] class with a generic type of [List]<[String]>. * * This object provides methods to parse the input, solve both ...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
2,464
kAdvent-2023
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumTilings.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
1,272
kotlab
Apache License 2.0
year2017/src/main/kotlin/net/olegg/aoc/year2017/day23/Day23.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day23 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2017.DayOf2017 import java.math.BigInteger /** * See [Year 2017, Day 23](https://adventofcode.com/2017/day/23) */ object Day23 : DayOf2017(23) { override fun first(): Any? { val ops = lines.map { it.split(" ") }...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,743
adventofcode
MIT License
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_66_Plus_One.kt
v43d3rm4k4r
515,553,024
false
{"Kotlin": 40113, "Java": 25728}
package leetcode.solutions.concrete.kotlin import leetcode.solutions.* import leetcode.solutions.ProblemDifficulty.* import leetcode.solutions.validation.SolutionValidator.* import leetcode.solutions.annotations.ProblemInputData import leetcode.solutions.annotations.ProblemSolution import kotlin.math.log10 /** * __P...
0
Kotlin
0
1
c5a7e389c943c85a90594315ff99e4aef87bff65
3,123
LeetcodeSolutions
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2022/d18/Day18.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d18 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.points.adjacents import com.groundsfam.advent.timed import com.groundsfam.advent.points.Point3 as Point import kotlin.io.path.div import kotlin.io.path.useLines fun surfaceArea1(points: List<Point>): Int { v...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,215
advent-of-code
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[77]组合.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.collections.ArrayList //给定两个整数 n 和 k,返回范围 [1, n] 中所有可能的 k 个数的组合。 // // 你可以按 任何顺序 返回答案。 // // // // 示例 1: // // //输入:n = 4, k = 2 //输出: //[ // [2,4], // [3,4], // [2,3], // [1,2], // [1,3], // [1,4], //] // // 示例 2: // // //输入:n = 1, k = 1 //输出:[[1]] // // // // 提示: // /...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,350
MyLeetCode
Apache License 2.0
library/src/main/java/com/dawan/multilingualcomparator/MultilingualismComparator.kt
hedawan
327,342,004
false
null
package com.dawan.multilingualcomparator import java.util.* class MultilingualismComparator : Comparator<String> { private val comparatorList = LinkedList<LanguageComparator>() override fun compare(str1: String?, str2: String?): Int { var result = 0 // 判空处理 when { str1 == ...
0
Kotlin
0
0
06286e379d5f736ea0b58c16e7c793be163c3640
4,263
MultilingualComparator
Apache License 2.0
problems/2021adventofcode16a/submissions/accepted/Stefan.kt
stoman
47,287,900
false
{"C": 169266, "C++": 142801, "Kotlin": 115106, "Python": 76047, "Java": 68331, "Go": 46428, "TeX": 27545, "Shell": 3428, "Starlark": 2165, "Makefile": 1582, "SWIG": 722}
import java.util.* abstract class Packet(val version: Int, val type: Int, val bitCount: Int) { fun versionSum(): Int = version + if(this is Operator) subPackets.sumOf { it.versionSum() } else 0 } class Literal(version: Int, type: Int, bitCount: Int, val value: Int) : Packet(version, type, bitCount) class Operator(...
0
C
1
3
ee214c95c1dc1d5e9510052ae425d2b19bf8e2d9
2,028
CompetitiveProgramming
MIT License
src/main/kotlin/org/example/e3fxgaming/adventOfCode/aoc2023/day06/Day06.kt
E3FxGaming
726,041,587
false
{"Kotlin": 38290}
package org.example.e3fxgaming.adventOfCode.aoc2023.day06 import org.example.e3fxgaming.adventOfCode.utility.Day import org.example.e3fxgaming.adventOfCode.utility.InputParser import org.example.e3fxgaming.adventOfCode.utility.MultiLineInputParser class Day06(input: String) : Day<Pair<Int, Int>, Pair<Long, Long>> { ...
0
Kotlin
0
0
3ae9e8b60788733d8bc3f6446d7a9ae4b3dabbc0
2,007
adventOfCode
MIT License
src/Day01.kt
BenHopeITC
573,352,155
false
null
fun main() { fun calsPerElf(input: String): List<Int> { return input.split("\n\n").map(String::toInt) } fun part1(input: String): Int { return calsPerElf(input).max() } fun part2(input: String): Int { return calsPerElf(input).sorted().takeLast(3).sum() } // test i...
0
Kotlin
0
0
851b9522d3a64840494b21ff31d83bf8470c9a03
855
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/it/unito/probability/bayes/CustomEliminationAsk.kt
lamba92
138,590,514
false
{"Kotlin": 123126}
package it.unito.probability.bayes import aima.core.probability.CategoricalDistribution import aima.core.probability.RandomVariable import aima.core.probability.bayes.BayesInference import aima.core.probability.bayes.BayesianNetwork import aima.core.probability.bayes.FiniteNode import aima.core.probability.bayes.impl....
0
Kotlin
2
7
716c241e314e56c9c2b82414a53d9c2336a22070
10,573
bayesian-net-project
MIT License
codechef/snackdown2021/preelim/goodranking_randomized.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codechef.snackdown2021.preelim import java.util.* private fun solve(magic: Int = 96): List<Int> { val n = readInt() val e = List(n) { readLn() } val diff = (n + 1) / 2 fun won(i: Int, j: Int) = e[i][j] == '1' val level = IntArray(n) val r = Random(566) var tries = 0 for (mid in e.indices.shuffled(r)) ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,193
competitions
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/MissingNumber.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,698
kotlab
Apache License 2.0
2021/src/Day17.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/17 fun main() { fun computeY(vy: Int, currX: Int, currVx : Int, currentStep : Int, minX: Int, maxX: Int, minY: Int, maxY: Int) : Int { var steps = currentStep var currentX = currX var currentVx = currVx var currentVy = vy - currentStep var...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
3,237
advent-of-code
Apache License 2.0
src/kotlin2022/Day04.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2022 import readInput fun main() { val gameInput = readInput("Day04_test") val pairs = gameInput.map{it.split(",")} var count = 0 for(pair in pairs) { if(rangeInRange(pair)) { count++ } } println(count) } fun rangeInRange(pair: List<String>): Boolean ...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
772
advent-of-code-kotlin
Apache License 2.0
src/Day01.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
fun main() { fun readCalories(input: List<String>): List<Int> = buildList { var current = 0 for (line in input) { if (line.isEmpty() && current > 0) { add(current) current = 0 } else { current += line.toInt() } ...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
778
advent-of-code-22
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/day20/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day20 import com.bloidonia.aoc2023.lcm import com.bloidonia.aoc2023.text import java.time.LocalTime private enum class Pulse { LOW, HIGH } private data class Signal(val source: String, val target: String, val pulse: Pulse) { override fun toString() = "$source -${pulse}-> $target...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
4,920
aoc-2023
MIT License
2019/src/main/kotlin/days/Day1.kt
pgrosslicht
160,153,674
false
null
package days import Day class Day1 : Day(1) { /*--- Day 1: The Tyranny of the Rocket Equation --- Santa has become stranded at the edge of the Solar System while delivering presents to other planets! To accurately calculate his position in space, safely align his warp drive, and return to Earth in time to sav...
0
Kotlin
0
0
1f27fd65651e7860db871ede52a139aebd8c82b2
3,777
advent-of-code
MIT License
native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/util/TreeNode.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.konan.test.blackbox.support.util import org.jetbrains.kotlin.konan.test.blackbox...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
2,987
kotlin
Apache License 2.0
src/main/kotlin/io/github/raphaeltarita/days/Day15.kt
RaphaelTarita
433,468,222
false
{"Kotlin": 89687}
package io.github.raphaeltarita.days import io.github.raphaeltarita.structure.AoCDay import io.github.raphaeltarita.util.Twin import io.github.raphaeltarita.util.day import io.github.raphaeltarita.util.ds.heap.ArrayHeap import io.github.raphaeltarita.util.ds.heap.MutableHeap import io.github.raphaeltarita.util.inModRa...
0
Kotlin
0
3
94ebe1428d8882d61b0463d1f2690348a047e9a1
3,156
AoC-2021
Apache License 2.0
src/main/kotlin/Day3.kt
aisanu
112,855,402
false
{"Kotlin": 15773}
object Day3 { // TODO: How to fix this mess fun manhattanDistance(est: Long): Long { val last = (1..Long.MAX_VALUE).takeWhile { Day3.bottomRightValue(it) <= est }.last() val box = Day3.bottomRightValue(last) var diff = est - box val n = 2 * last var (x, y) = (last - 1) t...
0
Kotlin
0
0
25dfe70e2bbb9b83a6ece694648a9271d1e21ddd
2,989
advent-of-code
The Unlicense
src/test/kotlin/adventofcode/day07/Day07.kt
jwcarman
573,183,719
false
{"Kotlin": 183494}
/* * Copyright (c) 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 i...
0
Kotlin
0
0
d6be890aa20c4b9478a23fced3bcbabbc60c32e0
2,915
adventofcode2022
Apache License 2.0
src/main/kotlin/g0201_0300/s0221_maximal_square/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0201_0300.s0221_maximal_square // #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix // #Dynamic_Programming_I_Day_16 #Big_O_Time_O(m*n)_Space_O(m*n) // #2022_09_10_Time_614_ms_(44.00%)_Space_76.2_MB_(65.33%) class Solution { fun maximalSquare(matrix: Array<CharArray>): Int { va...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,120
LeetCode-in-Kotlin
MIT License
src/day02/Day02.kt
Frank112
572,910,492
false
null
package day02 import assertThat import readInput fun main() { fun parseInput(input: List<String>): List<Pair<String, String>> { return input.map { s -> Pair(s.substring(0, 1), s.substring(2)) } } fun <T> mapper(map: Map<String, T>): (s: String) -> T { return { s -> map[s] ?: throw Illega...
0
Kotlin
0
0
1e927c95191a154efc0fe91a7b89d8ff526125eb
1,694
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g2001_2100/s2012_sum_of_beauty_in_the_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2012_sum_of_beauty_in_the_array // #Medium #Array #2023_06_23_Time_511_ms_(100.00%)_Space_56.5_MB_(50.00%) class Solution { fun sumOfBeauties(nums: IntArray): Int { val maxArr = IntArray(nums.size) maxArr[0] = nums[0] for (i in 1 until nums.size - 1) { maxAr...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
881
LeetCode-in-Kotlin
MIT License
src/Day21.kt
kipwoker
572,884,607
false
null
import kotlin.time.ExperimentalTime import kotlin.time.measureTime enum class MathOperator { Plus, Minus, Multiply, Divide } class Day21 { data class Monkey(val name: String, var value: Long?, val left: String?, val right: String?, val op: MathOperator?) fun parseOperator(value: String): Math...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
4,518
aoc2022
Apache License 2.0
src/main/kotlin/str/KMP.kt
yx-z
106,589,674
false
null
// KMP Algorithm for Pattern Matching fun main(args: Array<String>) { val kmp = KMP("aabacaabaabaaa", "aabaabaaa") println(kmp.match()) kmp.pattern = "1" println(kmp.match()) } class KMP(var matching: String, pattern: String) { var pattern: String = pattern set(value) { field = value this.patternArray = b...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,014
AlgoKt
MIT License
src/main/kotlin/ctci/chaptertwo/SumLists.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chaptertwo // 2.5 - page 95 // You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in // reverse order, such that the 1's digit is at the head of the list. In Kotlin, write a function that adds the two // numbers and returns the sum as a linked...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
2,235
dsa-kotlin
MIT License
letcode/src/main/java/daily/LeetCode154.kt
chengw315
343,265,699
false
null
package daily fun main() { val solution = Solution154() //1 val array = solution.minArray(intArrayOf(3, 4, 5, 1, 2)) //1 val array1 = solution.minArray(intArrayOf(1, 2, 3, 4, 5)) //5 val array2 = solution.minArray(intArrayOf(5, 15, 5, 5, 5)) //4 val array4 = solution.minArray(intArr...
0
Java
0
2
501b881f56aef2b5d9c35b87b5bcfc5386102967
1,030
daily-study
Apache License 2.0
facebook/y2021/qual/c1.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2021.qual private fun solve(): Int { val n = readInt() val c = readInts() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (v, u) = readInts().map { it - 1 } nei[v].add(u) nei[u].add(v) } fun dfs(v: Int, p: Int): Int { return c[v] + ((nei[v] - p).maxOfOrNull { dfs(it, v) }...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
659
competitions
The Unlicense
src/Day20.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import java.util.LinkedList enum class SignalType { LOW, HIGH } typealias Signal = Triple<String, SignalType, String> sealed class Module(val name: String, var next: List<String>) { abstract fun handleSignal(input: Signal): List<Signal> class Broadcaster(next: List<String>) : Module("broadcaster", next...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
4,675
aoc-2023
Apache License 2.0
src/main/day05/Day05.kt
FlorianGz
573,204,597
false
{"Kotlin": 8491}
package main.day05 import kotlinx.coroutines.* import readInput fun main() = runBlocking { suspend fun part1(): String { return getCode(reversed = true) } suspend fun part2(): String { return getCode(reversed = false) } println(part1()) println(part2()) } suspend fun getCod...
0
Kotlin
0
0
58c9aa8fdec77c25a9d9945ca8e77ecd1170321b
2,285
aoc-kotlin-2022
Apache License 2.0
src/Day08.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
fun main() { fun printForest(forest: Array<IntArray>) { for(i in 0 until forest.size) { for (j in 0 until forest[i].size) { print(forest[i][j]) } println() } } fun buildForest(input: List<String>): Array<IntArray> { var forest = Ar...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
3,967
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day20.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2021/day/20", date = Date(day = 20, year = 2021) ) class Day20(val input: List<String>) : Puzzle { private val enhancement = input.first().toCharArray().map { if (it == '#') 1 else 0 } private val image = Image.parse...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
1,930
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/solutions/Day03.kt
chutchinson
573,586,343
false
{"Kotlin": 21958}
class Day03 : Solver { override fun solve (input: Sequence<String>) { val rucksacks = input.toList() println(first(rucksacks)) println(second(rucksacks)) } fun priority (ch: Char): Int = when(ch) { in 'A'..'Z' -> ch.code - 64 + 26 in 'a'..'z' -> ch.code - 96 ...
0
Kotlin
0
0
5076dcb5aab4adced40adbc64ab26b9b5fdd2a67
1,116
advent-of-code-2022
MIT License
2022/Day25.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { val numbers = mapOf( 2 to '2', 1 to '1', 0 to '0', -1 to '-', -2 to '=', ) fun decodeDigit(c: Char) = numbers.entries.find { it.value == c }!!.key fun encodeDigit(x: Int) = numbers[x]!! fun decode(s: String): Long { var p = 1L var ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,237
advent-of-code-kotlin
Apache License 2.0
codeforces/round573/TokitsukazeMadjong.kt
grine4ka
183,575,046
false
{"Kotlin": 98723, "Java": 28857, "C++": 4529}
package codeforces.round573 // https://codeforces.com/contest/1191/problem/B fun main(args: Array<String>) { val listM = arrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0) val listP = arrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0) val listS = arrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0) val input = readLine()!!.split(" ").map { Ca...
0
Kotlin
0
0
c967e89058772ee2322cb05fb0d892bd39047f47
2,026
samokatas
MIT License
src/main/kotlin/dev/austinzhu/algods/containers/tree/Trie.kt
AustinZhu
287,033,539
false
null
package dev.austinzhu.algods.containers.tree import dev.austinzhu.algods.containers.util.NAryTreePrinter import dev.austinzhu.algods.containers.util.Operation import kotlin.math.sqrt import kotlin.random.Random class Trie<T> : AbstractTrie<T>() { open inner class Node(var value: T? = null) : Tree.Node<String, T, ...
0
Kotlin
0
0
e0188bad8a6519e571bdc3ee21c41764c1271f10
4,655
AlgoDS
MIT License
src/main/kotlin/day11/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day11 import java.io.File fun main() { val lines = File("src/main/kotlin/day11/input.txt").readLines() val mapSize = lines.size val energyLevelsMap: Array<IntArray> = Array(mapSize) { i -> lines[i].map { it.digitToInt() }.toIntArray() } val dumboOctopuses: MutableMap<Coordinate, DumboOctopus>...
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
2,779
aoc-2021
MIT License
semestr.06/ТРСиПВ/bellman/src/main/kotlin/bellman/graph/algorithm/bellmanFord.kt
justnero
43,222,066
false
null
package bellman.graph.algorithm import bellman.graph.Adjacency import bellman.graph.AdjacencyList import bellman.graph.INFINITE import bellman.graph.Util.AdjacencyUtil.destination import bellman.graph.Util.AdjacencyUtil.source import bellman.graph.Util.AdjacencyUtil.weight fun bellmanFord(adjacencyList: AdjacencyList...
0
Java
6
16
14f58f135e57475b98826c4128b2b880b6a2cb9a
1,239
university
MIT License
src/main/kotlin/processor/Matrix.kt
joseluisgs
446,332,521
true
{"HTML": 42079, "Java": 16420, "Kotlin": 10815, "JavaScript": 5252, "CSS": 3780}
package processor import kotlin.system.exitProcess fun main() { doMenuActions() } /** * Menu and Actions * @param data List of data * @param index Index of data */ private fun doMenuActions() { do { val menu = readMenuOption() when (menu) { 0 -> exit() 1 -> addMatr...
0
HTML
1
1
b0d49e42c3e40b9cdd193e07169b25075a06f409
10,815
Kotlin-NumericMatrixProcessor
MIT License
solutions/src/WaysToMakeFairArray.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/ways-to-make-a-fair-array/ * * Got correct big O(N) complexity but timeout still reached */ class WaysToMakeFairArray { fun waysToMakeFair(nums: IntArray): Int { var sumEven = 0 var sumOdd = 0 val sumEvenAscending = mutableListOf<Int>() val ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,821
leetcode-solutions
MIT License
src/main/kotlin/de/consuli/aoc/year2022/days/Day10.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2022.days import de.consuli.aoc.common.Day class Day10 : Day(10, 2022) { override fun partOne(testInput: Boolean): Int { return intArrayOf(20, 60, 100, 140, 180, 220).sumOf { mapInputToCpuCycles(testInput).getSignalStrength(it) } } override fun partTwo(testInput: Boolea...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
1,831
advent-of-code
Apache License 2.0
src/main/kotlin/exs/FunWithVowels.kt
alexaugustobr
289,400,808
false
{"Kotlin": 16766, "Java": 861}
val vowelList = listOf<Char>('a', 'e', 'i', 'o', 'u') fun main(args: Array<String>) { val vowel = readLine()!! //val vowel = "aeiouaeiouaeiouaaeeiioouu" println(longestSubsequence(vowel)) } fun longestSubsequence(searchVowel: String): Int { val chars = searchVowel.toCharArray() val lastIndex = chars.size v...
0
Kotlin
0
0
c70e56d67f44f57053e270a917028e04c2ea2da0
1,113
kotlin-exercises
MIT License
src/main/kotlin/days/Day15.kt
TheMrMilchmann
433,608,462
false
{"Kotlin": 94737}
/* * Copyright (c) 2021 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
dfc91afab12d6dad01de552a77fc22a83237c21d
2,775
AdventOfCode2021
MIT License
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem024.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems import dev.mikeburgess.euler.common.factorial /** * Problem 24 * * A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation * of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, * we call...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
969
project-euler
MIT License
kotlin/src/main/kotlin/com/pbh/soft/day6/Day6Solver.kt
phansen314
579,463,173
false
{"Kotlin": 105902}
package com.pbh.soft.day6 import cc.ekblad.konbini.* import com.pbh.soft.common.Solver import com.pbh.soft.common.parsing.ParsingUtils.onSuccess import com.pbh.soft.day6.Parsing.inputP import com.pbh.soft.day6.Parsing.part2P import mu.KLogging object Day6Solver : Solver, KLogging() { override fun solveP1(text: Stri...
0
Kotlin
0
0
7fcc18f453145d10aa2603c64ace18df25e0bb1a
1,763
advent-of-code
MIT License
generators/main/InterfaceAbstractClassSolver.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.generators.util /* * Assume that we have element `E` with parents `P1, P2` * ...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
5,425
kotlin
Apache License 2.0
src/main/kotlin/org/ageseries/libage/space/Location.kt
age-series
414,408,529
false
{"Kotlin": 260020}
package org.ageseries.libage.space import kotlin.math.abs import kotlin.math.sign import kotlin.math.sqrt /** * A vector in a two-dimensional space of integers. */ data class Vec2i(val x: Int, val y: Int) { /** * Gets the opposite vector. */ operator fun unaryMinus() = Vec2i(-x, -y) /** ...
5
Kotlin
1
1
0ce1c5a1d7eff41a0dbee389d50c6eaa10cac7c0
16,408
libage
MIT License
Lab4/src/main/kotlin/RegionTree.kt
knu-3-velychko
276,473,844
false
null
class RegionTree(private var points: List<Point>) { val root: Node init { points.sortedBy { it.x } root = build(0, points.size) } private fun build(left: Int, right: Int): Node { val node = Node() val m = left + (right - left) / 2 node.mid = points[m].x ...
0
Kotlin
0
0
b16603d78bf44f927f4f6389754a5d015a25f7e2
3,197
ComputerGraphics
MIT License
src/main/kotlin/com/kishor/kotlin/algo/algorithms/tree/RootingATree.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.tree import com.kishor.kotlin.algo.algorithms.graph.AdjacencyMatrixWeightedGraph fun main() { rootATree(AdjacencyMatrixWeightedGraph(0)) } fun rootATree(graph: AdjacencyMatrixWeightedGraph, rootId: Int = 0): CustomTreeNode { val root = CustomTreeNode(rootId, null, ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,536
DS_Algo_Kotlin
MIT License
Practice/Algorithms/implementation/DivisibleSumPairs.kts
kukaro
352,032,273
false
null
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
Kotlin
0
0
4f04ff7b605536398aecc696f644f25ee6d56637
1,281
hacker-rank-solved
MIT License
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt
kyjibo
353,664,422
true
{"Kotlin": 1925455, "Shell": 1179}
package eu.kanade.tachiyomi.data.library import eu.kanade.tachiyomi.data.database.models.Manga import kotlin.math.abs /** * This class will provide various functions to Rank mangas to efficiently schedule mangas to update. */ object LibraryUpdateRanker { val rankingScheme = listOf( (this::lexicographic...
0
Kotlin
0
0
f41b9b399c1b3cbe3e80d2f30b67cdc6ccee3308
2,005
Neko
Apache License 2.0
app/src/main/kotlin/io/github/andrewfitzy/day08/Task02.kt
andrewfitzy
747,793,365
false
{"Kotlin": 60159, "Shell": 1211}
package io.github.andrewfitzy.day08 class Task02(rowsInput: Int, colsInput: Int, puzzleInput: List<String>) { private val rows: Int = rowsInput private val cols: Int = colsInput private val input: List<String> = puzzleInput fun solve(): Int { val display: Array<CharArray> = Array(rows) { CharA...
0
Kotlin
0
0
15ac072a14b83666da095b9ed66da2fd912f5e65
3,186
2016-advent-of-code
Creative Commons Zero v1.0 Universal
src/net/sheltem/aoc/y2023/Day02.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import kotlin.math.max suspend fun main() { Day02().run() } private val maxCubes = mapOf("red" to 12, "green" to 13, "blue" to 14) class Day02 : Day<Long>(8, 2286) { override suspend fun part1(input: List<String>): Long = input .mapIndexed { index, s -> (index + 1) to ...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,387
aoc
Apache License 2.0
src/main/kotlin/Day05.kt
attilaTorok
573,174,988
false
{"Kotlin": 26454}
import java.util.Stack data class Instruction( val count: Int, val from: Int, val to: Int, ) fun main() { fun readStacks(iterator: Iterator<String>): List<Stack<Char>> { val stacks = mutableListOf<Stack<Char>>() val lines = Stack<String>() var numberOfStacks = 0 while...
0
Kotlin
0
0
1799cf8c470d7f47f2fdd4b61a874adcc0de1e73
2,995
AOC2022
Apache License 2.0
grind-75-kotlin/src/main/kotlin/RansomNote.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
/** * Given two strings ransomNote and magazine, * return true if ransomNote can be constructed by using the letters from magazine and false otherwise. * * Each letter in magazine can only be used once in ransomNote. * * * * Example 1: * * Input: ransomNote = "a", magazine = "b" * Output: false * Example 2:...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,137
grind-75
Apache License 2.0
src/day4/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day4 import readInput fun main() { fun part1(input: List<String>): Int { return input.count { val (first, second) = RangePair(it) first in second || second in first } } fun part2(input: List<String>): Int { return input.count { val (fir...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
1,150
AoC-2022
Apache License 2.0
src/Day08.kt
arksap2002
576,679,233
false
{"Kotlin": 31030}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { val arr = mutableListOf<MutableList<Boolean>>() for (i in input.indices) { val l = mutableListOf<Boolean>() for (j in 0 until input[0].length) { l.add(false) } a...
0
Kotlin
0
0
a24a20be5bda37003ef52c84deb8246cdcdb3d07
3,752
advent-of-code-kotlin
Apache License 2.0
Kotlin/binary_Search.kt
manan025
412,155,744
false
null
package com.company fun main(args: Array<String>) { // please pass sorted array in input always because binary search will always run in sorted array val i = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray() val key = readLine()!!.trim().toInt() val ans = binarySearch(i, key) if...
115
Java
89
26
c185dcedc449c7e4f6aa5e0d8989589ef60b9565
978
DS-Algo-Zone
MIT License
src/day2/Day2.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day2 import helpers.ReadFile class Day2 { // val lines = listOf( // "A X", // "A Y", // "A Z", // "B X", // "B Y", // "B Z", // "C X", // "C Y", // "C Z", // ) // val lines = listOf( // "A Y", //...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
2,234
adventofcode2022
MIT License
src/main/kotlin/frc/kyberlib/math/Polynomial.kt
Kanishk-Pandey
625,399,371
false
null
package frc.kyberlib.math import kotlin.math.pow import kotlin.math.sqrt /** * Representation and calculator of a polynomial */ class Polynomial( vararg val coeffs: Double, private val variableName: Char = 'x' ) { companion object { fun regress(args: DoubleArray, outputs: DoubleArray, order: In...
0
Kotlin
0
0
e5d6c96397e1b4ab703e638db2361418fd9d4939
4,139
MyRoboticsCode
Apache License 2.0
combinatorics/src/main/kotlin/com/nickperov/stud/combinatorics/CombinatorialUtils.kt
nickperov
327,780,009
false
null
package com.nickperov.stud.combinatorics import java.math.BigInteger object CombinatorialUtils { /** * Number of ordered samples of size m, without replacement, from n objects. */ fun calculateNumberOfVariationsInt(n: Int, m: Int): Int { val number = calculateNumberOfVariations(n, m) ...
0
Kotlin
0
0
6696f5d8bd73ce3a8dfd4200f902e2efe726cc5a
3,683
Algorithms
MIT License
src/Day01.kt
tstellfe
575,291,176
false
{"Kotlin": 8536}
fun main() { fun List<String>.toSummedList(): MutableList<Int> { val summed: MutableList<Int> = mutableListOf() var temp = 0 this.forEach { if (it != "") temp += it.toInt() else { summed.add(temp) temp = 0 } } summed.add(temp) return summed } fun part1(in...
0
Kotlin
0
0
e100ba705c8e2b83646b172d6407475c27f02eff
775
adventofcode-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/util/Pos.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.util import kotlin.math.pow data class Pos(val x: Int, val y: Int) : Comparable<Pos> { override fun compareTo(other: Pos): Int { val yCmp = y.compareTo(other.y) return if (yCmp == 0) { return x.compareTo(other.x) } else { yCmp } }...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,867
adventofcode
MIT License
src/main/kotlin/g0001_0100/s0047_permutations_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0047_permutations_ii // #Medium #Array #Backtracking #Algorithm_II_Day_10_Recursion_Backtracking // #2023_07_05_Time_199_ms_(100.00%)_Space_39.1_MB_(92.98%) class Solution { private var ans: MutableList<List<Int>>? = null fun permuteUnique(nums: IntArray): List<List<Int>> { ans = ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,151
LeetCode-in-Kotlin
MIT License
kotlin/1579-remove-max-number-of-edges-to-keep-graph-fully-traversable.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 { class DSU(val n: Int) { val parent = IntArray(n + 1) {it} val rank = IntArray(n + 1) {1} var components = n fun find(x: Int): Int { if (parent[x] != x) parent[x] = find(parent[x]) return parent[x] } fun union...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,516
leetcode
MIT License
src/main/kotlin/day10/Day10.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day10 import day10.OperationType.AFTER import day10.OperationType.DURING fun solveA(input: List<String>) = CycleTrackerB(listOf(20, 60, 100, 140, 180, 220)) .apply { parseOperations(input, type = DURING) }.strengths.sum() fun solveB(input: List<String>) = CycleTrackerB(listOf(41, 81, 121, 161, 201, 241))...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
3,910
advent-of-code-2022
Apache License 2.0
src/day12.kt
eldarbogdanov
577,148,841
false
{"Kotlin": 181188}
fun main() { val test = "" val di = listOf(-1, 0, 1, 0); val dj = listOf(0, 1, 0, -1); val mat = test.split("\n"); val n = mat.size; val m = mat[0].length; val best = Array(n) {Array(m) {n * m} }; val next: MutableList<Pair<Int, Int>> = mutableListOf(); for((i, s) in mat.withIndex())...
0
Kotlin
0
0
bdac3ab6cea722465882a7ddede89e497ec0a80c
1,555
aoc-2022
Apache License 2.0
src/main/kotlin/leetcode/Problem2012.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import kotlin.math.max import kotlin.math.min /** * https://leetcode.com/problems/sum-of-beauty-in-the-array/ */ class Problem2012 { fun sumOfBeauties(nums: IntArray): Int { val left = IntArray(nums.size) for ((i, n) in nums.withIndex()) { left[i] = if (i == 0) n els...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
841
leetcode
MIT License
cinema_manager.kt
fufaevlad
626,465,141
false
null
var ifCount = 0 var elseCount = 0 const val cheapSeatCoast = 8 const val expSeatCoast = 10 fun main() { val (rows,seats) = greeting() val cinema = mutListCreator(rows) boardFiller(cinema,rows,seats) multipleChoise(cinema,rows,seats) } fun greeting(): Pair<Int,Int>{ println("Enter the number of r...
0
Kotlin
0
0
b81d03b6942e7c1cd10efa67864f3a021fe203b9
3,461
hyperskill_test_cinema_room_manager
MIT License
src/main/kotlin/abc/287-c.kt
kirimin
197,707,422
false
null
package abc import utilities.debugLog import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val m = sc.nextInt() val uv = (0 until m).map { sc.next().toInt() to sc.next().toInt() } println(problem287c(n, m, uv)) } fun problem287c(n: Int, m: Int, uv:...
0
Kotlin
1
5
23c9b35da486d98ab80cc56fad9adf609c41a446
2,171
AtCoderLog
The Unlicense
src/main/kotlin/com/github/brpeterman/advent2022/KeepAway.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 import java.util.LinkedList import java.util.SortedMap typealias ArithmeticOperation = (Long, Long) -> Long typealias MonkeyRule = (Long) -> KeepAway.ItemPass class KeepAway(input: String, worryDecay: Int) { data class Monkey(val holding: LinkedList<Long>, val rule: Monke...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
4,165
advent2022
MIT License
src/main/kotlin/me/peckb/aoc/_2023/calendar/day11/Day11.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2023.calendar.day11 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day11 @Inject constructor( private val generatorFactory: InputGeneratorFactory ) { fun partOne(filena...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,451
advent-of-code
MIT License