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
2022/src/day04/Day04.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day04 import java.io.File fun main() { val input = File("src/day04/day04input.txt").readLines() println(input.filter { isTotalOverlapping(parseSchedule(it)) }.size) println(input.filter { isAnyOverlapping(parseSchedule(it)) }.size) } val RANGE_REGEX: Regex = "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRege...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
1,213
adventofcode
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day17.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 import com.dvdmunckhof.aoc.common.Point import com.dvdmunckhof.aoc.common.Rectangle class Day17(input: String) { private val rectangle: Rectangle init { val regex = Regex("target area: x=(\\d+)\\.\\.(\\d+), y=(-\\d+)\\.\\.(-\\d+)") val (leftX, rightX, bot...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,212
advent-of-code
Apache License 2.0
kotlin/combinatorics/PruferCode.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package combinatorics import java.util.stream.Stream // https://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence object PruferCode { // O(n) complexity fun pruferCode2Tree(pruferCode: IntArray): Array<List<Integer>> { val n = pruferCode.size + 2 val tree: Array<List<Integer>> = Stream.generate { Arr...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,512
codelibrary
The Unlicense
2021/src/main/kotlin/aoc2021/day10/Day10.kt
dkhawk
433,915,140
false
{"Kotlin": 170350}
package aoc2021.day10 import java.util.LinkedList import utils.Input @OptIn(ExperimentalStdlibApi::class) class Day10 { companion object { fun run() { Day10().part1() Day10().part2() } } val sample = """ [({(<(())[]>[[{[]{<()<>> [(()[<>])]({[<{<<[]>>( {([(<{}[<>[]}>{[]{[(<...
0
Kotlin
0
0
64870a6a42038acc777bee375110d2374e35d567
2,999
advent-of-code
MIT License
src/main/kotlin/com/github/fantom/codeowners/search/CodeownersSearchFilter.kt
fan-tom
325,829,611
false
{"Kotlin": 257763, "Lex": 5866, "HTML": 966}
package com.github.fantom.codeowners.search import com.github.fantom.codeowners.CodeownersManager import com.github.fantom.codeowners.OwnersList import com.github.fantom.codeowners.indexing.CodeownersEntryOccurrence import com.github.fantom.codeowners.indexing.OwnerString import com.intellij.openapi.vfs.VirtualFile i...
22
Kotlin
4
15
f898c1113f2f81b25aaeb6ba87f8e570da0ba08e
4,726
intellij-codeowners
MIT License
puzzles/kotlin/src/war/war.kt
charlesfranciscodev
179,561,845
false
{"Python": 141140, "Java": 34848, "Kotlin": 33981, "C++": 27526, "TypeScript": 22844, "C#": 22075, "Go": 12617, "JavaScript": 11282, "Ruby": 6255, "Swift": 3911, "Shell": 3090, "Haskell": 1375, "PHP": 1126, "Perl": 667, "C": 493}
import java.util.Scanner import kotlin.system.exitProcess fun main(args : Array<String>) { val game = Game() game.play() } /** * Represents the result of one game turn: * PLAYER1 if player 1 wins this round, * PLAYER2 if player 2 wins this round, * WAR if the two cards played are of equal value * */ enum cla...
0
Python
19
45
3ec80602e58572a0b7baf3a2829a97e24ca3460c
2,779
codingame
MIT License
src/main/kotlin/endredeak/aoc2023/Day05.kt
edeak
725,919,562
false
{"Kotlin": 26575}
package endredeak.aoc2023 // import endredeak.aoc2023.lib.utils.pMap data class SeedMap(val ranges: List<Triple<Long, Long, Long>>) { fun map(n: Long): Long = ranges .singleOrNull { (_, s, r) -> n in s..< (s + r) } ?.let { (d, s, _) -> n + d - s } ?: n } fun main() { ...
0
Kotlin
0
0
92c684c42c8934e83ded7881da340222ff11e338
1,753
AdventOfCode2023
Do What The F*ck You Want To Public License
src/leetcodeProblem/leetcode/editor/en/ContainsDuplicate.kt
faniabdullah
382,893,751
false
null
//Given an integer array nums, return true if any value appears at least twice //in the array, and return false if every element is distinct. // // // Example 1: // Input: nums = [1,2,3,1] //Output: true // Example 2: // Input: nums = [1,2,3,4] //Output: false // Example 3: // Input: nums = [1,1,1,3,3,4,3,2,4,2] /...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,148
dsa-kotlin
MIT License
classroom/src/main/kotlin/com/radix2/algorithms/week3/HalfSizedAuxArray.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week3 // Merging with smaller auxiliary array. // Suppose that the sub array 𝚊[𝟶] to 𝚊[𝚗−𝟷] is sorted and the subarray 𝚊[𝚗] to 𝚊[𝟸 ∗ 𝚗 − 𝟷] is sorted. // How can you merge the two sub arrays so that 𝚊[𝟶] to 𝚊[𝟸 ∗ 𝚗−𝟷] is sorted using an auxiliary array of length n (instea...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,089
coursera-algorithms-part1
Apache License 2.0
src/main/kotlin/org/holo/kGrammar/Tree.kt
Holo314
343,512,707
false
null
package org.holo.kGrammar import java.util.* /** * A class that represent the set of all possible symbols, it is partitioned into 2 classes: * * [Terminal] - the class that represent all of the terminal symbols * * [NonTerminal] - the class that represent all non-terminal symbols */ sealed class Symbol { ...
0
Kotlin
0
0
af5568fc4d1a56d98a93a645ca0ffbbf966a450b
5,650
KGrammar
MIT License
day22/src/main/kotlin/Day22.kt
bzabor
160,240,195
false
null
import kotlin.math.pow import kotlin.math.sqrt typealias CellTool = Pair<Cell, Tool> class Day22(private val input: List<String>) { // sample // val depth = 510 // val targetRow = 10 // val targetCol = 10 //actual val depth = 11817 val targetCol = 9 val targetRow = 751 val gridExt...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
8,857
AdventOfCode2018
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/StrobogrammaticNumber.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,182
kotlab
Apache License 2.0
src/main/kotlin/days/aoc2020/Day7.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2020 import days.Day class Day7: Day(2020, 7) { fun createBagList(list: List<String>): Map<String,Bag> { val bags: MutableMap<String,Bag> = mutableMapOf() list.forEach { Regex("(\\w+ \\w+)").find(it)?.destructured?.let { (bagDescriptor) -> bags.putIfAbs...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
1,936
Advent-Of-Code
Creative Commons Zero v1.0 Universal
Kotlin for Java Developers. Week 2/Mastermind/Task/src/mastermind/playMastermind.kt
binout
159,054,839
false
null
package mastermind import java.util.* val ALPHABET = 'A'..'F' val CODE_LENGTH = 4 fun main(args: Array<String>) { playBullsAndCows() } fun playBullsAndCows( secret: String = generateSecret() ) { val scanner = Scanner(System.`in`) var evaluation: Evaluation do { print("Your guess: ")...
0
Kotlin
1
5
40ff182f63d29443fa3c29730560d37e2325501a
1,520
coursera-kotlin
Apache License 2.0
src/main/kotlin/day6.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* fun main() { val input = Input.day(6) println(day6A(input)) println(day6B(input)) } fun day6A(input: Input): Int { val times = input.lines[0].toLongs() val records = input.lines[1].toLongs() val winOptions = times.mapIndexed { index, time -> raceWinOptions(time, records...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
819
AdventOfCode2023
MIT License
year2022/src/cz/veleto/aoc/year2022/Day09.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.minus import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign class Day09(config: Config) : AocDay(config) { override fun part1(): String = countTailPositions(ropeLength...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
1,915
advent-of-pavel
Apache License 2.0
2022/src/main/kotlin/de/skyrising/aoc2022/day3/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day3 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.chars.CharOpenHashSet @PuzzleName("Rucksack Reorganization") fun PuzzleInput.part1(): Any { var sum = 0 for (line in lines) { val comp1 = line.slice(0 until line.length / 2) val comp2 = line.slice(line.len...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,287
aoc
MIT License
calendar/day01/Day1.kt
rscuddertnow
726,288,081
false
{"Kotlin": 9759}
package day01 import Day import Lines class Day1 : Day() { val digits:List<String> = listOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") override fun part1(input: Lines): Any { return input.fold(0) { total, l...
0
Kotlin
0
0
30bc609fa9fda383de74d267a86d6ecf2e782402
1,257
aoc2023-kotlin
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day08.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution fun main() = Day08.solve() object Day08 : AdventSolution(2019, 8, "Space Image Format") { override fun solvePartOne(input: String) = input .chunked(6 * 25) .map { layer -> layer.groupingBy { it }.eachCount() } .minByOrNull ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
964
advent-of-code
MIT License
kotlin/154.Find Minimum in Rotated Sorted Array II(寻找旋转排序数组中的最小值 II).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>Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.</p> <p>(i.e., &nbsp;<code>[0,1,2,4,5,6,7]</code>&nbsp;might become &nbsp;<code>[4,5,6,7,0,1,2]</code>).</p> <p>Find the minimum element.</p> <p>The array may contain duplicates.</p> <p><strong>Example 1:</strong></...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
2,634
leetcode
MIT License
src/main/kotlin/Day08R.kt
rileynull
437,153,864
false
null
package rileynull.aoc // This code is heinous. See the note in Day08.kt. object Day08R { data class Line(val inputs: List<Set<Segment>>, val outputs: List<Set<Segment>>) enum class Segment { A, B, C, D, E, F, G } object SevenSegmentDisplay { val digits = mapOf( Pair(0...
0
Kotlin
0
0
2ac42faa192767f00be5db18f4f1aade756c772b
7,134
adventofcode
Apache License 2.0
src/Day08_part1.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
class Tree { val list = mutableListOf<MutableList<String>>() var visibleCount: Int= 0 private fun checkAll(i: Int, j: Int): Boolean = checkLeft(i, j) || checkRight(i, j) || checkTop(i, j) || checkBottom(i, j) private fun checkLeft(i: Int, j: Int): Boolean { for (n in 0 until j) { i...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
1,917
aoc2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day06/Day06.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day06 import eu.janvdb.aocutil.kotlin.readCommaSeparatedNumbers const val FILENAME = "input06.txt" const val SPAWN_DELAY = 7 const val INITIAL_DELAY = 2 fun main() { val state = State.readFromInput() // Part 1 runDays(state, 80) // Part 2 runDays(state, 256) } private fun runDays(i...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,336
advent-of-code
Apache License 2.0
src/main/kotlin/com/sk/topicWise/tree/easy/637. Average of Levels in Binary Tree.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.tree.easy import com.sk.topicWise.tree.TreeNode class Solution637 { fun averageOfLevels(root: TreeNode?): DoubleArray { val list = arrayListOf<Pair<Int, Double>>() dfs(root, 0, list) return list.map { it.second / it.first }.toDoubleArray() } fun dfs(root: ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,524
leetcode-kotlin
Apache License 2.0
src/main/kotlin/day2/Day2.kt
erolsvik
573,456,869
false
{"Kotlin": 2081}
package day2 import java.io.File val values = mapOf("A" to 1, "B" to 2, "C" to 3) val values2 = mapOf("X" to 1, "Y" to 2, "Z" to 3) val winValues = mapOf("X" to "C", "Y" to "A", "Z" to "B") val lossValues = mapOf("X" to "B", "Y" to "C", "Z" to "A") val drawValues = mapOf("X" to "A", "Y" to "B", "Z" to "C") var totalS...
0
Kotlin
0
0
82f1bbbdfb3c1a6c74be88fc48107e8d4e0c43eb
1,493
advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/Day05.kt
chutchinson
573,586,343
false
{"Kotlin": 21958}
typealias Action = Triple<Int, Int, Int> typealias Stack = ArrayDeque<Char> class Day05 : Solver { data class Puzzle( val stacks: List<Stack>, val actions: List<Action>) fun Puzzle.move (multiple: Boolean): Puzzle { for (action in this.actions) { val (count, from, to) = ac...
0
Kotlin
0
0
5076dcb5aab4adced40adbc64ab26b9b5fdd2a67
2,244
advent-of-code-2022
MIT License
common/src/commonMain/kotlin/ticketToRide/PlayerScore.kt
Kiryushin-Andrey
253,543,902
false
{"Kotlin": 278687, "Dockerfile": 845, "JavaScript": 191}
package ticketToRide import graph.* const val InitialStationsCount = 3 const val PointsPerStation = 4 class PlayerScore( override val name: PlayerName, override val color: PlayerColor, val occupiedSegments: List<Segment>, val placedStations: List<CityId>, tickets: List<Ticket>, segmentsOccupi...
1
Kotlin
3
11
0ad7aa0b79f7d97cbac6bc4cd1b13b6a1d81e442
1,989
TicketToRide
MIT License
src/main/java/challenges/educative_grokking_coding_interview/two_heaps/_4/ScheduleTask.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.two_heaps._4 import challenges.util.PrintHyphens import java.util.* /** Given a set of n number of tasks, implement a task scheduler method, tasks(), to run in O(n logn) time that finds the minimum number of machines required to complete these n tasks. https://w...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
4,258
CodingChallenges
Apache License 2.0
kotlin/graphs/lca/LcaSchieberVishkin.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.lca import java.util.stream.Stream // Answering LCA queries in O(1) with O(n) preprocessing class LcaSchieberVishkin(tree: Array<List<Integer>>, root: Int) { var parent: IntArray var preOrder: IntArray var I: IntArray var head: IntArray var A: IntArray var time = 0 fun dfs1(...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,272
codelibrary
The Unlicense
src/main/kotlin/com/cbrew/unify/Unifiable.kt
cbrew
248,690,438
false
{"Kotlin": 147469, "ANTLR": 8870, "Vue": 8502, "HTML": 303, "Dockerfile": 123}
package com.cbrew.unify sealed class Unifiable { fun label(): String = when (this) { is AtomicValue -> value is FeatureMap -> "${get("cat")?.label()}[${get("f")?.label()}]" else -> "??" } fun key(): String = when (this) { ...
1
Kotlin
0
0
16c4e42911782595e419f38c23796ce34b65f384
6,608
quadruplet
Apache License 2.0
src/main/kotlin/arr/MaxPop.kt
yx-z
106,589,674
false
null
package arr fun main(args: Array<String>) { // given a list of [birth year, death year] // find the year that the most people are alive val testArr = arrayOf( 1961 to 2000, 1978 to 2015, 1858 to 1912, 1900 to 1950, 1992 to 2025, 1990 to 1991 ) println(testArr.getMostPopulationYear()) println(te...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,243
AlgoKt
MIT License
2022/programming/AtCoder/220312_ABC243/src/main/kotlin/MainE.kt
kyoya-p
253,926,918
false
{"Kotlin": 797744, "JavaScript": 82500, "HTML": 54815, "TypeScript": 51200, "Java": 30096, "C++": 28982, "CMake": 20831, "Dart": 14886, "Shell": 7841, "Batchfile": 6182, "CSS": 5729, "Dockerfile": 3451, "Swift": 1622, "C": 1489, "PowerShell": 234, "Objective-C": 78}
package main.e import testenv.stdioEmulatior import testenv.testEnv val ex = testEnv { debug = true intake.println( """ 5 6 1 2 4 1 4 1 1 5 9 2 5 1 2 3 1 3 4 1 """.trimIndent() ) outlet.readLine() == "2" } val envs = listOf( testEnv { intake.println(""" 3 3 1 2 2 2 3 3...
16
Kotlin
0
1
2cb2843b2100d96b453ff7d4ced99091e45ed17a
5,773
samples
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[21]合并两个有序链表.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 // // // // 示例 1: // // //输入:l1 = [1,2,4], l2 = [1,3,4] //输出:[1,1,2,3,4,4] // // // 示例 2: // // //输入:l1 = [], l2 = [] //输出:[] // // // 示例 3: // // //输入:l1 = [], l2 = [0] //输出:[0] // // // // // 提示: // // // 两个链表的节点数目范围是 [0, 50] // -100 <= Node.val <= 100...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,165
MyLeetCode
Apache License 2.0
src/main/kotlin/days/Day1.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day1 : Day(1) { override fun partOne(): Any { return calibrationSum(inputList, REGEX_NUMBERS) } override fun partTwo(): Any { return calibrationSum(inputList, REGEX_NUMBER_WORDS) } fun calibrationSum(lines: List<String>, digitRegex: Regex): Int { return...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
1,407
aoc-2023
Creative Commons Zero v1.0 Universal
12/src/main/kotlin/com/lillicoder/projecteuler/Problem12.kt
lillicoder
33,462,498
false
{"Java": 43120, "Kotlin": 2486}
/* * Copyright 2019 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this project 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...
0
Java
0
0
4e181d121d96d8d201c21b49a5183d2cc0afe19a
2,486
projecteuler-java
Apache License 2.0
day13/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Part Two --- // You resume walking through the valley of mirrors and - SMACK! - run directly // into one. Hopefully nobody was watching, because that must have been pretty // embarrassing. // // Upon closer inspection, you discover that every mirror has exactly one // smudge: exactly one . or # should be the opp...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
3,339
adventofcode2023
MIT License
src/main/kotlin/kt/kotlinalgs/app/kickstart/WiggleWalk.ws.kts
sjaindl
384,471,324
false
null
/* https://codingcompetitions.withgoogle.com/kickstart/round/00000000008f49d7/0000000000bcf0fd Banny has just bought a new programmable robot. Eager to test his coding skills, he has placed the robot in a grid of squares with R rows (numbered 1 to R from north to south) and C columns (numbered 1 to C from west to east...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
7,666
KotlinAlgs
MIT License
src/y2015/Day10.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import java.lang.StringBuilder import kotlin.math.min object Day10 { fun part1(input: String): Int { var result = input repeat(40) { result = lookAndSay(result) } return result.length } private fun lookAndSay(string: String): String { val...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,453
advent-of-code
Apache License 2.0
src/main/kotlin/solved/p1418/Solution.kt
mr-nothing
469,475,608
false
{"Kotlin": 162430}
package solved.p1418 class Solution { fun displayTable(orders: List<List<String>>): List<List<String>> { // A tree set of all tables sorted by natural order val tables = sortedSetOf<Int>() // A tree set of all dishes sorted by natural order val dishes = sortedSetOf<String>() ...
0
Kotlin
0
0
0f7418ecc8675d8361ef31cbc1ee26ea51f7708a
2,941
leetcode
Apache License 2.0
src/Day13.kt
RickShaa
572,623,247
false
{"Kotlin": 34294}
import com.beust.klaxon.Klaxon fun main() { val fileName = "day13.txt" val testFileName = "day13_test.txt" val input = FileUtil.getListOfLines(testFileName); fun Any.isInt():Boolean{ return this is Int } fun Any.isList():Boolean{ return this is List<*> } fun minTuple...
0
Kotlin
0
1
76257b971649e656c1be6436f8cb70b80d5c992b
2,263
aoc
Apache License 2.0
kt/001 Two Sum/TwoSum.kt
JiangKlijna
55,755,751
false
null
/** * Given an array of integers, return indices of the two numbers such that they add up to a specific target. * You may assume that each input would have exactly one solution. * 给出一个int数组和目标值,从数组中找到两个值使得其和为目标值.返回两个下标位置. * */ class TwoSum { fun twoSum(numbers: IntArray, target: Int): IntArray { val re = IntA...
0
Java
4
12
65a1348d276ce0a00c8f429c0cba68df0296c541
744
leetcode-learning
MIT License
src/main/kotlin/days/aoc2020/Day17.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2020 import days.Day class Day17: Day(2020, 17) { override fun partOne(): Any { var cube = Cube(inputList) for (i in 0 until 6) { cube.calculateNextState() } return cube.getActiveCount() } override fun partTwo(): Any { var cube = Hyper...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
5,078
Advent-Of-Code
Creative Commons Zero v1.0 Universal
app/src/main/java/com/mospolytech/mospolyhelper/domain/schedule/utils/LessonUtils.kt
tonykolomeytsev
341,524,793
true
{"Kotlin": 646693}
package com.mospolytech.mospolyhelper.domain.schedule.utils import com.mospolytech.mospolyhelper.domain.schedule.model.Lesson private const val minCriticalTitleLength = 10 private const val minCriticalWordLength = 5 private const val vowels = "аеёиоуыэюя" fun cutTitle(title: String): String { if (title.length <...
0
null
0
0
379c9bb22913da1854f536bf33e348a459db48b9
2,593
mospolyhelper-android
MIT License
src/main/kotlin/Day06.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
fun main() { fun calculate(input: String, chunkSize: Int): Int { val data = input.toCharArray().toList() var start = 0 var to = chunkSize while (to <= data.size) { val chunk = data.subList(start, to) var index = 0 while (index <= chunk.size) { ...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
1,087
KotlinAdventOfCode2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SingleElementInSortedArray.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,387
kotlab
Apache License 2.0
src/chapter5/section1/ex12_Alphabet_LSD.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section1 /** * 字母表 * 实现5.0.2节给出的Alphabet类的API并用它实现能够处理任意字母表的低位优先的和高位优先的字符串排序算法。 * * 解:基于字母表的低位优先字符串排序算法,参考练习5.1.9 */ fun alphabetLSDSort(array: Array<String>, alphabet: Alphabet) { var maxLength = 0 array.forEach { if (it.length > maxLength) maxLength = it.length } val aux...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,353
Algorithms-4th-Edition-in-Kotlin
MIT License
Collections/Sort/src/TaskExtensionSort.kt
Rosietesting
373,564,502
false
{"HTML": 178715, "JavaScript": 147056, "Kotlin": 113135, "CSS": 105840}
fun main(){ //Natural order val numbers = listOf("one", "two", "three") println("Sorted descending: ${numbers.sortedDescending()}") println("Sorted ascending: ${numbers.sorted()}") //Custom orders val numbers2 = listOf("one", "two", "three", "Four") val sortedNumbers = numbers2.sortedBy...
0
HTML
0
0
b0aa518d220bb43c9398dacc8a6d9b6c602912d5
1,836
KotlinKoans
MIT License
kotlin/src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day25Test.kt
dirkgroot
724,049,902
false
{"Kotlin": 203339, "Rust": 123129, "Clojure": 78288}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import kotlin.math.pow private fun solution1(input: String) = input.lines().sumOf { it.snafuToLong() }...
1
Kotlin
0
0
ced913cd74378a856813973a45dd10fdd3570011
1,497
adventofcode
MIT License
mynlp/src/main/java/com/mayabot/nlp/module/nwd/ValueObjects.kt
mayabot
113,726,044
false
{"Java": 985672, "Kotlin": 575923, "Shell": 530}
package com.mayabot.nlp.module.nwd import kotlin.math.* class IntCount { var value : Int = 1 } /** * 词和词数量 */ class WordCount(val word: String, val count: Int) : Comparable<WordCount> { override fun compareTo(other: WordCount): Int { return other.count.compareTo(count) } } data class NewWord( ...
18
Java
90
658
b980da3a6f9cdcb83e0800f6cab50656df94a22a
2,489
mynlp
Apache License 2.0
src/Day17.kt
jbotuck
573,028,687
false
{"Kotlin": 42401}
import kotlin.math.max fun main() { @Suppress("unused") fun board17() = TetrisBoard(readInput("Day17").first()) @Suppress("unused") fun boardSample() = TetrisBoard(">>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>") fun board() = board17() //change to use sample val shapesToPlay = 1_000_000_000_000 //...
0
Kotlin
0
0
d5adefbcc04f37950143f384ff0efcd0bbb0d051
4,813
aoc2022
Apache License 2.0
src/main/kotlin/no/quist/aoc18/days/Day2.kt
haakonmt
159,945,133
false
null
package no.quist.aoc18.days import no.quist.aoc18.Day object Day2 : Day<List<String>, Any>() { override fun createInput(): List<String> = inputLines override fun part1(input: List<String>): Int { val (twos, threes) = input.fold(Pair(0, 0)) { (accTwos, accThrees), currentLine -> val charCo...
0
Kotlin
0
1
4591ae7aa9cbb70e26ae2c3a65ec9e55559c2690
1,166
aoc18
MIT License
src/Day11/Day11.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day11 import readInput import java.math.BigInteger class Item(var worry: BigInteger) class Monkey(val id: Int, var items: MutableList<Item>, val operation: (BigInteger) -> BigInteger, val test: (BigInteger) -> Boolean, val divisor: BigInteger) { var testFalseMoney: Monkey? = null var testTrueMonkey: M...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
4,780
advent-of-code-2022
Apache License 2.0
src/test/resources/scripts/clusterer.kts
xrrocha
264,292,094
false
null
// DEPS info.debatty:java-string-similarity:2.0.0 import grappolo.ClusteringResult import info.debatty.java.stringsimilarity.Damerau import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentSetOf import java.io.File import java.time.LocalDateTime import java.time.format.Date...
0
Kotlin
0
0
93a065ab98d5551bc2f2e39ff4b069d524e04870
10,722
grappolo-kotlin
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/SortValiant.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
@file:Suppress("NonAsciiCharacters") package ai.hypergraph.kaliningraph.parsing import ai.hypergraph.kaliningraph.* import ai.hypergraph.kaliningraph.tensor.UTMatrix import ai.hypergraph.kaliningraph.types.* // The main issue with SortValiant is we eagerly compute the Cartesian product // and this blows up very quic...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
4,632
galoisenne
Apache License 2.0
src/main/kotlin/solutions/constantTime/iteration1/MemorizedTaxCalculator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package solutions.constantTime.iteration1 import dataModel.base.Money import dataModel.base.Money.Companion.cents import dataModel.base.TaxBracket import dataModel.base.TaxCalculator import sampleData.SampleTaxBrackets import solutions.logN.LogNTaxCalculator /** * Temporary assumption on the max supported income to ...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
1,707
tax-calculator
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/PaintWalls.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,128
kotlab
Apache License 2.0
src/Day01.kt
rdbatch02
575,174,840
false
{"Kotlin": 18925}
fun main() { fun getElfTotals(input: List<String>): List<Int> { val elfTotals: MutableList<Int> = mutableListOf(0) input.forEach{ if (it.isNotBlank()) { elfTotals[elfTotals.lastIndex] = elfTotals.last() + it.toInt() } else { elfTota...
0
Kotlin
0
1
330a112806536910bafe6b7083aa5de50165f017
820
advent-of-code-kt-22
Apache License 2.0
src/main/kotlin/aoc2016/ExplosivesInCyberspace.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 fun explosivesInCyberspace1(input: CharSequence): Long = explosivesInCyberspace(input, recurse = false) fun explosivesInCyberspace2(input: CharSequence): Long = explosivesInCyberspace(input, recurse = true) private fun explosivesInCyberspace(input: CharSequence, recurse: Boo...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,493
advent-of-code
MIT License
src/adventofcode/Day21.kt
Timo-Noordzee
573,147,284
false
{"Kotlin": 80936}
package adventofcode import org.openjdk.jmh.annotations.* import java.util.concurrent.TimeUnit private const val ROOT = "root" private const val HUMAN = "humn" private operator fun List<String>.component2() = this[1][0] private fun MutableMap<String, String>.compute(monkeyId: String): Long? { val monkeyValue = ...
0
Kotlin
0
2
10c3ab966f9520a2c453a2160b143e50c4c4581f
3,547
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/easy/RomanToInt.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.easy /** * 13. 罗马数字转整数 * 罗马数字包含以下七种字符:I,V,X,L,C,D和M。 * * 字符 数值 * I 1 * V 5 * X 10 * L 50 * C 100 * D 500 * M 1000 * * 例如, 罗马数字 2 写做II,即为两个并列的 1 。12 写做XII,即为X+II。 27 写做XXVII, 即为...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,954
daily_algorithm
Apache License 2.0
2016/src/main/kotlin/com/koenv/adventofcode/Day7.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode object Day7 { fun parseParts(input: String): List<Part> { val result = mutableListOf<Part>() var currentType = Type.IP val currentPart = StringBuilder() val chars = input.toCharArray() chars.forEach { when (it) { ...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
3,837
AdventOfCode-Solutions-Kotlin
MIT License
2022/main/day_10/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_10_2022 import java.io.File import kotlin.math.abs fun part1(input: List<String>) { val signalStrengths = mutableListOf<Int>() var signalStrength = 1 for (signal in input) { if (signal.startsWith("addx")) { val arg = signal.split(" ")[1].toInt() signalStrengths....
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,670
AdventofCode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ArrangingCoins.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,538
kotlab
Apache License 2.0
day19/src/Day19.kt
simonrules
491,302,880
false
{"Kotlin": 68645}
import java.io.File import kotlin.math.abs data class Point(val x: Int, val y: Int, val z: Int) { operator fun plus(other: Point): Point = Point(x + other.x, y + other.y, z + other.z) operator fun minus(other: Point): Point = Point(x - other.x, y - other.y, z - other.z) fun manhattan(othe...
0
Kotlin
0
0
d9e4ae66e546f174bcf66b8bf3e7145bfab2f498
4,779
aoc2021
Apache License 2.0
src/main/kotlin/days/Day16.kt
vovarova
572,952,098
false
{"Kotlin": 103799}
package days import java.util.* class Day16 : Day(16) { class Valves(intput: List<String>) { inner class Valve(val name: String, val rate: Int, val lead: List<String>) { fun leads(): List<Valve> = lead.map { index[it]!! } override fun toString(): String { return "...
0
Kotlin
0
0
e34e353c7733549146653341e4b1a5e9195fece6
6,664
adventofcode_2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/github/javadev/sort/QuickSort.kt
javadev
156,964,261
false
null
package com.github.javadev.sort /* public class QuickSort { public void quickSort(int[] array) { quickSort(array, 0, array.length - 1); } void quickSort(int[] array, int low, int high) { if (low < high) { int p = partition(array, low, high); quickSort(array, low, p); quickSort(array, ...
0
Kotlin
0
5
3f71122f1d88ee1d83acc049f9f5d44179c34147
2,720
classic-cherries-kotlin
Apache License 2.0
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/middle/SwapPairs.kt
scientificCommunity
352,868,267
false
{"Java": 154453, "Kotlin": 69817}
package org.baichuan.sample.algorithms.leetcode.middle /** * https://leetcode.cn/problems/swap-nodes-in-pairs/ */ class SwapPairs { fun swapPairs(head: ListNode?): ListNode? { if (head?.next == null) { return head } val newHead = head.next //交换后head变成后面的节点,所以head需要连接递归...
1
Java
0
8
36e291c0135a06f3064e6ac0e573691ac70714b6
1,411
blog-sample
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/arrays/SmallestDifference.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.arrays fun main() { val arrOne = mutableListOf(2, -9, 0, 14, 1, -8, -3, -1, 8, -6, 5, -5) val arrTwo = mutableListOf(15, -8, 3, 1, 7, -10, 2, -1, 4, -3, 17, -2) print(smallestDifference(arrOne, arrTwo)) // [-8, -8] } // O(nlog(n) + mlog(m)) time | O(1) spa...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,167
algs4-leprosorium
MIT License
test/leetcode/MissingNumber.kt
andrej-dyck
340,964,799
false
null
package leetcode import lib.* import net.jqwik.api.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.* import org.junit.jupiter.params.converter.* import org.junit.jupiter.params.provider.* /** * https://leetcode.com/problems/missing-number/ * * 268. Missing Number * [Easy] * *...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
2,545
coding-challenges
MIT License
src/leetcode_study_badge/data_structure/Day8.kt
faniabdullah
382,893,751
false
null
package leetcode_study_badge.data_structure class Day8 { fun groupAnagrams(strs: Array<String>): List<List<String>> { val hashToStrs = HashMap<Int, MutableList<String>>() for (str in strs) { hashToStrs.getOrPut(hash(str)) { mutableListOf() }.add(str) } return hashToStr...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,625
dsa-kotlin
MIT License
src/main/kotlin/algorithms/FindSharedMotif.kt
jimandreas
377,843,697
false
null
@file:Suppress("unused") package algorithms /** * See also: * http://rosalind.info/problems/lcsm/ * Finding a Shared Motif (Longest Common Substring) * * Problem A common substring of a collection of strings is a substring of every member of the collection. We say that a common substring is a longest common su...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
2,023
stepikBioinformaticsCourse
Apache License 2.0
Codeforces/1530/C.kt
thedevelopersanjeev
112,687,950
false
null
private fun readLn() = readLine() ?: "" private fun readLns() = readLn().split(" ") private fun readInt() = readLn().toInt() private fun readInts() = readLns().map { it.toInt() } private fun good( a: List<Int>, b: List<Int>, extra: Int ): Boolean { var contests = a.size + extra contests -= (contest...
0
C++
58
146
610520cc396fb13a03c606b5fb6739cfd68cc444
1,316
Competitive-Programming
MIT License
src/Day04.kt
paul-matthews
433,857,586
false
{"Kotlin": 18652}
typealias BingoNumbers = List<Int> fun List<String>.toInts(): List<Int> = map{ it.toInt() } fun List<String>.getBingoNumbers(): BingoNumbers = first().split(",").map { it.toInt() } data class BingoBoard(val raw: RawBingoBoard, val scoreLines: List<BingoScoreLine>, val matched: BingoNumbers, va...
0
Kotlin
0
0
2f90856b9b03294bc279db81c00b4801cce08e0e
4,257
advent-of-code-kotlin-template
Apache License 2.0
shape/src/commonMain/kotlin/io/data2viz/shape/stack/StackOrder.kt
data2viz
89,368,762
false
null
/* * Copyright (c) 2018-2021. data2viz sàrl. * * 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...
79
Kotlin
29
389
5640d3e8f1ce4cd4e5d651431726869e329520fc
3,619
data2viz
Apache License 2.0
solutions/aockt/y2023/Y2023D10.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.spacial.Direction import aockt.util.spacial.Direction.* import aockt.util.spacial.Point import aockt.util.spacial.move import aockt.util.spacial.opposite import aockt.util.parse import aockt.util.spacial.polygonArea import io.github.jadarma.aockt.core.Solution object Y2023D10 : S...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
4,617
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountPrimes.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,797
kotlab
Apache License 2.0
src/main/kotlin/Day2Problem2.kt
hbandi188
434,551,848
false
null
fun main() { Day2Problem1.solve() } object Day2Problem1 { fun solve() { val instructions = getInput() val start = State(distance = 0, depth = 0) val end = instructions.fold(start) { state, instruction -> instruction.applyToState(state) } println("Result: ${end.distance * end.de...
0
Kotlin
0
0
d33605a7ccb3dc049bef4feba16c45c936a349cf
1,315
adventofcode-2021
Creative Commons Zero v1.0 Universal
src/Day10.kt
kmakma
574,238,598
false
null
fun main() { /** * cathode-ray tube screen and simple CPU */ class CRT { var cycle = 0 var register = 1 var row = mutableListOf<Char>() fun exec(op: String) { doCycle() if ("noop" == op) return doCycle() register += op.s...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
1,686
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day01.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day01(private val calibrationDocument: List<String>) { private val digitMap = mapOf( "one" to "1", "two" to "2", "three" to "3", "four" to "4", "five" to "5", "six" to "6", "seven" to "7", "eight" to "8", ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
1,280
advent-2023
MIT License
src/main/kotlin/com/kevinschreuder/adventofcode/days/Day4.kt
TheCoati
435,561,957
false
{"Kotlin": 15259}
package com.kevinschreuder.adventofcode.days import com.kevinschreuder.adventofcode.FileInput import kotlin.collections.ArrayList /** * Day 4: Giant Squid * @see <a href="https://adventofcode.com/2021/day/4">Advent of code</a> */ class Day4 : Day { private val input = FileInput("day4") @Override over...
0
Kotlin
0
1
a780b4cf8acf4349d64764e27fb57bac33aa31d3
3,851
Advent-of-Code-2021
Apache License 2.0
src/Ext.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.max infix fun Int.toward(to: Int): IntProgression { val step = if (this > to) -1 else 1 return IntProgression.fromClosedRange(this, to, step) } infix fun Int.towardExclusiveFrom(to: Int): IntProgression { val step = if (this > to) -1 else 1 return IntProgression.fromClosedRange(this...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,147
advent-of-code-2022
Apache License 2.0
2015/src/main/kotlin/day9_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.Parser import utils.Solution import utils.mapItems import utils.triplicut fun main() { Day9Func.run() } object Day9Func : Solution<Graph<String, Int>>() { override val name = "day9" override val parser = Parser.lines.mapItems { line -> line.triplicut(" to ", " = ") }.map { ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
858
aoc_kotlin
MIT License
LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/RegularExpressionMatching.kt
ani03sha
297,402,125
false
null
package org.redquark.tutorials.leetcode fun isMatch(s: String, p: String): Boolean { val rows = s.length val columns = p.length /// Base conditions if (rows == 0 && columns == 0) { return true } if (columns == 0) { return false } // DP array val dp = Array(rows + 1) ...
2
Java
40
64
67b6ebaf56ec1878289f22a0324c28b077bcd59c
1,303
RedQuarkTutorials
MIT License
src/Day01.kt
wujingwe
574,096,169
false
null
fun main() { fun total(input: String): List<Int> { return input.split("\n\n") .map { elf -> elf.lines().sumOf { it.toInt() } } } fun part1(testInput: String): Int { return total(testInput).max() } fun part2(testInput: String): Int { return total(testInput) ...
0
Kotlin
0
0
a5777a67d234e33dde43589602dc248bc6411aee
646
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day01.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2016 import se.saidaspen.aoc.util.* fun main() = Day01.run() object Day01 : Day(2016, 1) { override fun part1(): Any { val walker = Walker(Pair(0, 0), Walker.Dir.N) input.split(",") .map { it.trim() } .map { P(if (it.substring(0, 1) == "R") Tur...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,192
adventofkotlin
MIT License
app/src/main/kotlin/xyz/lbres/trickcalculator/ui/history/generateRandomHistory.kt
lbressler13
464,331,572
false
{"Kotlin": 360254}
package xyz.lbres.trickcalculator.ui.history import xyz.lbres.exactnumbers.exactfraction.ExactFraction import xyz.lbres.kotlinutils.general.simpleIf import xyz.lbres.kotlinutils.list.StringList import xyz.lbres.kotlinutils.random.ext.nextBoolean import xyz.lbres.trickcalculator.SharedValues.random import xyz.lbres.tri...
0
Kotlin
0
2
5569809d1754159f4b5c6b409f7f93b09f8fcdb6
2,227
trick-calculator
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem36/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem36 /** * LeetCode page: [36. Valid Sudoku](https://leetcode.com/problems/valid-sudoku/); */ class Solution { /* Complexity: * Time O(|board|) and Space O(1); */ fun isValidSudoku(board: Array<CharArray>): Boolean { return checkRows(board) && checkColumn...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,037
hj-leetcode-kotlin
Apache License 2.0
src/chapter4/section2/ex30_QueueBasedTopologicalSort.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter4.section2 import edu.princeton.cs.algs4.Queue /** * 基于队列的拓扑排序 * 实现一种拓扑排序,使用由顶点索引的数组来保存每个顶点的入度。 * 遍历一遍所有边并使用练习4.2.7给出的Degrees类来初始化数组以及一条含有所有起点的队列。 * 然后,重复以下操作直到起点队列为空: * 1、从队列中删去一个起点并将其标记 * 2、遍历由被删除顶点指出的所有边,将所有被指向的顶点的入度减一 * 3、如果顶点的入度变为0,将它插入起点队列 */ class QueueBasedTopologicalSort(digraph: Digra...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,247
Algorithms-4th-Edition-in-Kotlin
MIT License
src/test/kotlin/com/dambra/adventofcode2018/day12/GrowingPlants.kt
pauldambra
159,939,178
false
null
package com.dambra.adventofcode2018.day12 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test internal class GrowingPlants { private val exampleInput = """initial state: #..#.#..##......###...### ...## => # ..#.. => # .#... => # .#.#. => # .#.## => # .##.. => # .#### => # #.#.# =>...
0
Kotlin
0
1
7d11bb8a07fb156dc92322e06e76e4ecf8402d1d
3,596
adventofcode2018
The Unlicense
src/main/kotlin/GiveDirections.kt
sam-hoodie
534,831,633
false
{"Kotlin": 43732}
fun printDirections() { println("To get the directions to commands for these genres, type: ") println(" 0: Names Information") println(" 1: Age and Gender Information") println(" 2: Term Information") println(" 3: Current Legislator Information") print(" > ") when (readLine().toString...
0
Kotlin
0
0
9efea9f9eec55c1e61ac1cb11d3e3460f825994b
4,761
congress-challenge
Apache License 2.0
src/day01/Day01.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day01 import println import readInput fun main() { fun readSignal(input: List<String>) = input.filter { line -> line.trim().isNotEmpty() } .map(String::toInt) fun countIncreases(readSignal: List<Int>) = readSignal .windowed(2) .fold(0) { acc, next -> if (next[1] > next[0]) ac...
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
783
advent-of-code-2021
Apache License 2.0
kotlin/app/src/main/kotlin/coverick/aoc/day10/CathodeRayTube.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day10 import readResourceFile val INPUT_FILE = "cathodeRayTube-input.txt" class CRT(x:Int) { var clock: Int var pixels: ArrayList<ArrayList<Char>> val WIDTH = x init { clock = 1 pixels = ArrayList<ArrayList<Char>>() pixels.add(ArrayList<Char>()) } ...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
2,518
adventofcode2022
Apache License 2.0
src/main/kotlin/descriptive/Descriptive.kt
widi-nugroho
280,354,028
false
null
package descriptive import java.util.* import kotlin.math.floor import kotlin.math.sqrt object Descriptive { fun mean (a:List<Double>):Double{ var res=0.0 for (i in a){ res+=i } return res/a.size } fun median(a:List<Double>):Double{ val sorted=a.sorted(...
0
Kotlin
0
0
a1166092e50303dcd6da9ee3146696c64f6d1bcf
1,663
kotlin-statistics
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1456/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1456 /** * LeetCode page: [1456. Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) where N is the length of s; ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,591
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/twentytwenty/Day8.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
data class Instruction(val operation: String, val value: Int){ var seen = false } fun main() { val run = readInput().run() println("part 1: ${run.first}") readInput().forEachIndexed { index, _ -> val output = readInput().run(index) if (!output.second) { println("part 2: ${out...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
1,181
aoc202xkotlin
The Unlicense
src/main/kotlin/com/colinodell/advent2021/Day17.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 import kotlin.math.abs class Day17(input: String) { private val targetArea: Region init { "target area: x=(-?\\d+)..(-?\\d+), y=(-?\\d+)..(-?\\d+)".toRegex().matchEntire(input)!!.groupValues.drop(1).map { it.toInt() }.let { targetArea = Region(Vector2(it[...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
1,635
advent-2021
Apache License 2.0
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/kotlin/IsmaelMatiz.kts
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
/* * Escribe un programa que, dado un número, compruebe y muestre si es primo, * fibonacci y par. * Ejemplos: * - Con el número 2, nos dirá: "2 es primo, fibonacci y es par" * - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar" */ var num = 89 var result = "$num " result += if (checkPrime(num)...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
1,534
retos-programacion-2023
Apache License 2.0
src/Day06.kt
haraldsperre
572,671,018
false
{"Kotlin": 17302}
fun main() { fun getFirstDistinctSubSequence(input: String, length: Int): Int { for (i in length..input.length) { if (input.subSequence(i - length, i).toSet().size == length) { return i } } return -1 } fun part1(input: String): Int { ...
0
Kotlin
0
0
c4224fd73a52a2c9b218556c169c129cf21ea415
759
advent-of-code-2022
Apache License 2.0
calendar/day13/Day13.kt
starkwan
573,066,100
false
{"Kotlin": 43097}
package day13 import Day import Lines import kotlin.math.sign class Day13 : Day() { override fun part1(input: Lines): Any { return input.windowed(2, 3) .map { isRightOrder(parse(it[0]), parse(it[1])) >= 0 } .mapIndexed { i, isRightOrder -> if (isRightOrder) i + 1 else 0 } ...
0
Kotlin
0
0
13fb66c6b98d452e0ebfc5440b0cd283f8b7c352
3,557
advent-of-kotlin-2022
Apache License 2.0
src/Day06.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
import java.util.* fun main() { // test if implementation meets criteria from the description, like: val testInput = readInputAsString("Day06_test") check(part1(testInput) == 7) check(part2(testInput) == 19) val input = readInputAsString("Day06") println(part1(input)) println(part2(input))...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
908
aoc-2022
Apache License 2.0