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/2023/Day12.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import common.BackTracker import java.io.File import java.math.BigInteger import java.util.* import kotlin.collections.ArrayList import kotlin.math.max import kotlin.math.min fun main() { Day12().solve() } class Day12 { val input1 = """ ???.### 1,1,3 .??..??...?##. 1,1,3 ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
5,772
advent-of-code
Apache License 2.0
src/Day10.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
fun main() { class Register(var value: Int) { val signalStrengths = mutableListOf<Int>() val queue = mutableListOf<Int>() fun executeQueue() { val queueElement = if (queue.size > 0) queue.removeFirst() else 0 value += queueElement } fun checkSignalS...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
2,805
advent_of_code_2022
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[738]单调递增的数字.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个非负整数 N,找出小于或等于 N 的最大的整数,同时这个整数需要满足其各个位数上的数字是单调递增。 // // (当且仅当每个相邻位数上的数字 x 和 y 满足 x <= y 时,我们称这个整数是单调递增的。) // // 示例 1: // // 输入: N = 10 //输出: 9 // // // 示例 2: // // 输入: N = 1234 //输出: 1234 // // // 示例 3: // // 输入: N = 332 //输出: 299 // // // 说明: N 是在 [0, 10^9] 范围内的一个整数。 // Related Topics 贪心算法 // 👍 140 👎...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,375
MyLeetCode
Apache License 2.0
src/main/kotlin/org/github/poel/mazely/generator/algorithm/RecursiveDivision.kt
Poooel
303,827,188
false
null
package org.github.poel.mazely.generator.algorithm import org.github.poel.mazely.entity.Grid import org.github.poel.mazely.generator.Generator import kotlin.random.Random class RecursiveDivision: Generator { override fun on(grid: Grid, random: Random): Grid { grid.cells.flatten().forEach { cell -> ...
1
Kotlin
0
0
e5b365eefe3c6a3e287145f3dc235b4b3841e9af
2,093
mazely
MIT License
2018/kotlin/day16p2/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* fun main(args: Array<String>) { val start = Date() val classLoader = Opcode::class.java.classLoader val puzzle = PuzzleInput.parse(classLoader.getResource("input.txt").readText()) val opcodeMap = findOpcodes(puzzle.hints) val result = execute(puzzle.program, opcodeMap) printl...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
4,053
adventofcode
MIT License
day11/kotlin/corneil/src/main/kotlin/solution.kt
timgrossmann
224,991,491
true
{"HTML": 2739009, "Python": 169603, "Java": 157274, "Jupyter Notebook": 116902, "TypeScript": 113866, "Kotlin": 89503, "Groovy": 73664, "Dart": 47763, "C++": 43677, "CSS": 34994, "Ruby": 27091, "Haskell": 26727, "Scala": 11409, "Dockerfile": 10370, "JavaScript": 6496, "PHP": 4152, "Go": 2838, "Shell": 2493, "Rust": 208...
package com.github.corneil.aoc2019.day11 import com.github.corneil.aoc2019.day11.DIRECTION.EAST import com.github.corneil.aoc2019.day11.DIRECTION.NORTH import com.github.corneil.aoc2019.day11.DIRECTION.SOUTH import com.github.corneil.aoc2019.day11.DIRECTION.WEST import com.github.corneil.aoc2019.intcode.Program import...
0
HTML
0
1
bb19fda33ac6e91a27dfaea27f9c77c7f1745b9b
3,153
aoc-2019
MIT License
src/main/kotlin/day4/Day4.kt
stoerti
726,442,865
false
{"Kotlin": 19680}
package io.github.stoerti.aoc.day4 import io.github.stoerti.aoc.IOUtils import io.github.stoerti.aoc.StringExt.intValues import kotlin.math.pow fun main(args: Array<String>) { val cards = IOUtils.readInput("day_4_input") .map { Card.fromString(it) } .onEach { println(it) } val result1 = cards .map { ...
0
Kotlin
0
0
05668206293c4c51138bfa61ac64073de174e1b0
1,436
advent-of-code
Apache License 2.0
src/main/kotlin/other/FactorialAdvanced.kt
DmitryTsyvtsyn
418,166,620
false
{"Kotlin": 223256}
package other import java.math.BigInteger /** * * This algorithm is taken from Google Guava library * */ class FactorialAdvanced { // precomputed factorials private val factorials = longArrayOf( 1L, 1L, 1L * 2, 1L * 2 * 3, 1L * 2 * 3 * 4, 1L * 2 * 3 * 4 * ...
0
Kotlin
135
767
7ec0bf4f7b3767e10b9863499be3b622a8f47a5f
5,169
Kotlin-Algorithms-and-Design-Patterns
MIT License
src/Day11.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
fun main() { class Monkey( startingItems: List<Long>, private val operation: (Long) -> Long, val divisibleBy: Long, ) { private val queue: ArrayDeque<Long> = ArrayDeque(startingItems) private lateinit var nextMonkeyTrue: Monkey private lateinit var nextMonkeyFals...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
4,659
aoc2022
Apache License 2.0
src/test/kotlin/algorithms/sorting/SortingTest.kt
AANikolaev
273,465,105
false
{"Java": 179737, "Kotlin": 13961}
package algorithms.sorting import algorithms.sorting.bubble_sort.BubbleSort import algorithms.sorting.counting_sort.CountingSort import algorithms.sorting.heap_sort.Heapsort import algorithms.sorting.insertion_sort.InsertionSort import algorithms.sorting.merge_sort.MergeSort import algorithms.sorting.quick_sort.QuickS...
0
Java
0
0
f9f0a14a5c450bd9efb712b28c95df9a0d7d589b
3,158
Algorithms
MIT License
src/Day06.kt
WilsonSunBritten
572,338,927
false
{"Kotlin": 40606}
fun main() { fun part1(input: List<String>): Int { return input.first().windowedSequence(4, 1).mapIndexed { index, window -> index to window }.first { (_, window) -> window.toList().distinct().size == 4 }.first + 4 } fun part2(input: List<String>): Int { return input.fi...
0
Kotlin
0
0
363252ffd64c6dbdbef7fd847518b642ec47afb8
922
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/recursion/Permutations.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.recursion fun main() { print(permutations(listOf(1, 2))) // [[1, 2], [2, 1]] } // O(n*n!) time | O(n*n!) space private fun permutations(arr: List<Int>): List<List<Int>> { val perms = mutableListOf<List<Int>>() permutations(arr.toMutableList(), 0, perms) ...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
766
algs4-leprosorium
MIT License
Kotlin/src/main/kotlin/org/algorithm/problems/0015_koko_eating_bananas.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
//Problem Statement // Koko loves to eat bananas. // There are N piles of bananas, the i-th pile has piles[i] bananas. // The guards have gone and will come back in H hours. // // Koko can decide her bananas-per-hour eating speed of K. // Each hour, she chooses some pile of bananas, and eats K bananas from that pile. /...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
1,546
algorithms
MIT License
src/chapter5/section3/ex25_Streaming.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section3 import edu.princeton.cs.algs4.In import edu.princeton.cs.algs4.Queue /** * 流输入 * 为KMP类添加一个search()方法,接受一个In类型的变量作为参数, * 在不使用其他任何实例变量的条件下在指定的输入流中查找模式字符串。 * 为RabinKarp类也添加一个类似的方法。 */ fun KMP.search(input: In): Int { var i = 0 var j = 0 while (input.hasNextChar() && j < pat.len...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,916
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/SubArray.kt
alexiscrack3
310,484,737
false
{"Kotlin": 44433}
class SubArray { fun getLengthOfLongestContiguousSubarray(array: Array<Int>): Int { var maxLength = 1 for (i in 0 until array.size - 1) { var minimum = array[i] var maximum = array[i] for (j in i + 1 until array.size) { minimum = Math.min(minimum...
0
Kotlin
0
0
a2019868ece9ee319d08a150466304bfa41a8ad3
1,713
algorithms-kotlin
MIT License
classroom/src/main/kotlin/com/radix2/algorithms/week4/BST.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week4 import java.util.* interface SymbolTable<K : Comparable<K>, V> { fun put(key: K, value: V) fun get(key: K): V? fun min(): Pair<K, V>? fun max(): Pair<K, V>? fun floor(key: K): Pair<K, V>? fun ceil(key: K): Pair<K, V>? fun size(): Int fun rank(...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
6,791
coursera-algorithms-part1
Apache License 2.0
src/Day01.kt
casslabath
573,177,204
false
{"Kotlin": 27085}
fun main() { fun part1(input: List<String>): Int { var most = Int.MIN_VALUE var currentCals = 0 for(cal in input) { if(cal.isEmpty()) { most = currentCals.coerceAtLeast(most) currentCals = 0 } else { currentCals += Integ...
0
Kotlin
0
0
5f7305e45f41a6893b6e12c8d92db7607723425e
967
KotlinAdvent2022
Apache License 2.0
src/year2021/Day1.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readLines fun main() { val input = readLines("2021", "day1").map { it.toInt() } val testInput = readLines("2021", "day1_test").map { it.toInt() } check(part1(testInput) == 7) println("Part 1:" + part1(input)) check(part2(testInput) == 5) println("Part 2:" + part2(inpu...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
655
advent_of_code
MIT License
src/main/kotlin/org/geepawhill/dungeon/Area.kt
GeePawHill
308,920,321
false
null
package org.geepawhill.dungeon import java.lang.Integer.max import java.lang.Integer.min data class Area(val west: Int, val north: Int, val east: Int, val south: Int) { val longest: Int get() = max(east - west, south - north) val size = (east - west) * (south - north) fun margin(amount: Int): Area { ...
0
Kotlin
0
1
94bd1d7d1cf204ea08a721592d1b6430141966fd
1,226
dungeon
MIT License
src/main/kotlin/graph/Graph.kt
ghonix
88,671,637
false
null
package graph import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet class Graph { companion object { @JvmStatic fun createAdjacencyList(edges: Array<Pair<String, String>>): Map<String, Set<String>> { val graph = HashMap<String, MutableSet<String>>() ...
0
Kotlin
0
2
25d4ba029e4223ad88a2c353a56c966316dd577e
5,582
Problems
Apache License 2.0
2020/december10.kt
cuuzis
318,759,108
false
{"TypeScript": 105346, "Java": 65959, "Kotlin": 17038, "Scala": 5674, "JavaScript": 3511, "Shell": 724}
import java.io.File /** * https://adventofcode.com/2020/day/10 */ fun main() { println(star1()) // 1998 println(star2()) // 347250213298688 } private fun input(): List<String> { return File("2020/december10.txt").readLines(); } private fun star1(): Int { val adapters = input().map(String::toLong).s...
0
TypeScript
0
1
35e56aa97f33fae5ed3e717dd01d303153caf467
1,439
adventofcode
MIT License
advent-of-code-2022/src/Day17.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import java.util.* fun main() { val testInput = readInput("Day17_test") val input = readInput("Day17") "Part 1" { part1(testInput) shouldBe 3068 measureAnswer { part1(input, print = true) } } "Part 2" { part2(testInput) shouldBe 1514285714288 println() meas...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
5,185
advent-of-code
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2021/Day16.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.mul import com.s13g.aoc.toBinary /** * --- Day 16: Packet Decoder --- * https://adventofcode.com/2021/day/16 */ class Day16 : Solver { override fun solve(lines: List<String>): Result { val input = Data(line...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,146
euler
Apache License 2.0
Kotlin/problems/0003_add_two_numbers.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
// Problem Statement // You are given two non-empty linked lists representing two non-negative integers. // The digits are stored in reverse order and each of their nodes contain a single digit. // Add the two numbers and return it as a linked list. // // You may assume the two numbers do not contain any leading zero,...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
2,140
algorithms
MIT License
graph/MinimumSpanningTree.kt
wangchaohui
737,511,233
false
{"Kotlin": 36737}
class DisjointSet(size: Int) { private data class Node( var id: Int, ) { var parent: Node = this var size: Int = 1 } private val set = Array(size, ::Node) fun find(i: Int): Int = findNode(i).id private fun findNode(i: Int): Node { var x = set[i] while (...
0
Kotlin
0
0
241841f86fdefa9624e2fcae2af014899a959cbe
1,126
kotlin-lib
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day16.kt
sviams
115,921,582
false
null
import kotlin.streams.asStream object AoC_Day16 { val startState = ('a'..'p').joinToString("").toCharArray() val size = startState.size fun parseMoves(instructions: List<String>) : List<(CharArray) -> CharArray> { return instructions.fold(listOf()) { acc, instruction -> acc + parseInstruction(inst...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
2,212
aoc17
MIT License
dcp_kotlin/src/main/kotlin/dcp/day207/day207.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day207 // day207.kt // By <NAME>, 2019. /** * A graph is bipartite if it is 2-colourable, and to determine if a graph is 2-colourable can be accomplished by * a greedy algorithm. This is due to detecting odd cycles, and a graph is bipartite iff it has no odd cycles. */ enum class Colour { BLACK, WHI...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,109
daily-coding-problem
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordBreak.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,897
kotlab
Apache License 2.0
Day18/src/Cave.kt
gautemo
225,219,298
false
null
import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import java.io.File import kotlin.math.abs import kotlin.system.measureTimeMillis fun main(){ val input = File(Thread.currentThread().contextClassLoader.getResource("...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
10,180
AdventOfCode2019
MIT License
src/me/bytebeats/algo/kt/Solution11.kt
bytebeats
251,234,289
false
null
package me.bytebeats.algo.kt import me.bytebeats.algs.ds.ListNode import me.bytebeats.algs.ds.TreeNode /** * @author bytebeats * @email <<EMAIL>> * @github https://github.com/bytebeats * @created on 2020/9/3 11:07 * @version 1.0 * @description TO-DO */ class Solution11 { fun solveNQueens(n: Int): List<Lis...
0
Kotlin
0
1
7cf372d9acb3274003bb782c51d608e5db6fa743
34,431
Algorithms
MIT License
feature/home/src/main/kotlin/com/xeladevmobile/medicalassistant/feature/home/Extensions.kt
Alexminator99
702,145,143
false
{"Kotlin": 534097}
package com.xeladevmobile.medicalassistant.feature.home import com.xeladevmobile.medicalassistant.core.model.data.Audio import com.xeladevmobile.medicalassistant.core.model.data.Emotion import com.xeladevmobile.medicalassistant.core.model.data.PatientStatistics import java.text.SimpleDateFormat import java.util.* fun...
0
Kotlin
0
0
37a35835a2562b0c6b4129e7b86cfca081a24783
7,731
Medical_Assistant
MIT License
src/main/kotlin/day4/Day4.kt
Wicked7000
573,552,409
false
{"Kotlin": 106288}
package day4 import Day import checkWithMessage import readInput import runTimedPart @Suppress("unused") class Day4(): Day() { data class Range(val start: Int, val end: Int) private fun processRange(rangeStr: String): Range { val (start, end) = rangeStr.split("-").map { it.toInt() } return Ra...
0
Kotlin
0
0
7919a8ad105f3b9b3a9fed048915b662d3cf482d
2,337
aoc-2022
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day22/common.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day22 import com.anahoret.aoc2022.ManhattanDistanceAware sealed class Tile(val row: Int, val col: Int) : ManhattanDistanceAware { override val x = col override val y = row companion object { fun parse(row: Int, col: Int, char: Char): Tile? { return when (...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
3,442
advent-of-code-2022
Apache License 2.0
src/zh/pufei/src/eu/kanade/tachiyomi/extension/zh/pufei/PufeiFilters.kt
lmk1988
253,204,269
true
{"Kotlin": 4659131}
package eu.kanade.tachiyomi.extension.zh.pufei import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList internal fun getFilters() = FilterList( Filter.Header("排序只对文本搜索和分类筛选有效"), SortFilter(), Filter.Separator(), Filter.Header("以下筛选最多使用一个,使用文本搜索时将会忽略"), Cate...
0
Kotlin
0
5
3e1df100b87358d8b50ce8dd998e04552db9c91d
2,250
tachiyomi-extensions
Apache License 2.0
src/Day06.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
fun main() { fun compareN (string: CharSequence, n: Int): Boolean { for (i in 0 until n) { for (j in i+1 until n) { if (string[i] == string[j]) return true } } return false } fun part1(input: List<String>): Int { input.forEach { line -...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
1,144
advent-of-code-kotlin-2022
Apache License 2.0
facebook/y2023/round1/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2023.round1 private fun precalc(s: Int = 41): List<MutableMap<Int, Sequence<Int>>> { val dp = List(s + 1) { List(it + 1) { mutableMapOf<Int, Sequence<Int>>() } } dp[0][0][1] = emptySequence() for (sum in 0 until s) { for (count in 0..sum) { for (entry in dp[sum][count]) { for (x in 1..s -...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
887
competitions
The Unlicense
year2017/src/main/kotlin/net/olegg/aoc/year2017/day8/Day8.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day8 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2017.DayOf2017 /** * See [Year 2017, Day 8](https://adventofcode.com/2017/day/8) */ object Day8 : DayOf2017(8) { override fun first(): Any? { val registers = mutableMapOf<String, Int>() lines .map { it...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,764
adventofcode
MIT License
src/array/ContainsDuplicate.kt
develNerd
456,702,818
false
{"Kotlin": 37635, "Java": 5892}
package array /** * * 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] Output...
0
Kotlin
0
0
4e6cc8b4bee83361057c8e1bbeb427a43622b511
1,461
Blind75InKotlin
MIT License
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day20/day20.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day20 import eu.janvdb.aocutil.kotlin.gcd import eu.janvdb.aocutil.kotlin.readLines import java.util.* //const val FILENAME = "input20-test.txt" //const val OUTPUT_NAME = "output" const val FILENAME = "input20.txt" const val OUTPUT_NAME = "rx" fun main() { val system = System.parse(readLin...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
6,166
advent-of-code
Apache License 2.0
kotlin/graphs/flows/MinCostFlowDijkstra.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.flows import java.util.stream.Stream // https://cp-algorithms.com/graph/min_cost_flow.html in O(E * V + min(E * logV * FLOW, V^2 * FLOW)) // negative-cost edges are allowed // negative-cost cycles are not allowed class MinCostFlowDijkstra(nodes: Int) { var graph: Array<List<Edge>> inner class ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
5,530
codelibrary
The Unlicense
src/day03/Day03.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day03 import readInput fun main() { part1() part2() } fun part1() { val input = readInput(3) var total = 0 for (string in input) { val first = string.subSequence(0, string.length / 2) val second = string.subSequence(string.length / 2, string.length) val intersect =...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
1,017
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2019/FlawedFrequencyTransmission.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import kotlin.math.absoluteValue fun flawedFrequencyTransmission1(input: String): String { var s = input.map { it - '0' }.toIntArray() repeat(100) { s = phase(s) } return s.take(8).joinToString("") } fun flawedFrequencyTransmission2(input: String): String {...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,148
advent-of-code
MIT License
src/main/kotlin/info/jukov/adventofcode/y2022/Day7.kt
jukov
572,271,165
false
{"Kotlin": 78755}
package info.jukov.adventofcode.y2022 import info.jukov.adventofcode.Day import java.io.BufferedReader import java.util.LinkedList import java.util.SortedSet import java.util.TreeSet object Day7 : Day() { override val year: Int = 2022 override val day: Int = 7 private const val NEED_SPACE = 30_000_000 ...
0
Kotlin
1
0
5fbdaf39a508dec80e0aa0b87035984cfd8af1bb
4,052
AdventOfCode
The Unlicense
src/test/kotlin/com/igorwojda/string/ispalindrome/tolerant/solution.kt
tmdroid
498,808,938
true
{"Kotlin": 217983}
package com.igorwojda.string.ispalindrome.tolerant // iterative solution private object Solution1 { private fun isTolerantPalindrome(str: String): Boolean { var characterRemoved = false str.forEachIndexed { index, c -> var lastIndex = str.lastIndex - index if (characterRem...
1
Kotlin
2
0
f82825274ceeaf3bef81334f298e1c7abeeefc99
2,466
kotlin-puzzles
MIT License
src/Day05.kt
zfz7
573,100,794
false
{"Kotlin": 53499}
fun main() { println(day5(readFile("Day05"), true)) println(day5(readFile("Day05"), false)) } fun day5(input: String, reverse: Boolean): String { val (moves, startingStack) = input.split("\n").partition { it.startsWith("move") } val stack = buildStack(startingStack.dropLast(2)) moves.forEach { move...
0
Kotlin
0
0
c50a12b52127eba3f5706de775a350b1568127ae
1,152
AdventOfCode22
Apache License 2.0
src/Day05.kt
vi-quang
573,647,667
false
{"Kotlin": 49703}
/** * Main ------------------------------------------------------------------- */ fun main() { class Move(val numberOfCratesToMove : Int, val indexOfCrateToMoveFrom : Int, val indexOfCrateToMoveTo: Int) { } fun createStackList(input: List<String>) : MutableList<ArrayDeque<Char>> { val returnLis...
0
Kotlin
0
2
ae153c99b58ba3749f16b3fe53f06a4b557105d3
2,933
aoc-2022
Apache License 2.0
src/Day05.kt
arksap2002
576,679,233
false
{"Kotlin": 31030}
import java.util.* import kotlin.collections.ArrayDeque fun main() { fun part1(input: List<String>): String { var result = "" val letters = mutableListOf<ArrayDeque<Char>>( ArrayDeque(listOf('V', 'C', 'D', 'R', 'Z', 'G', 'B', 'W')), ArrayDeque(listOf('G', 'W', 'F', 'C', 'B',...
0
Kotlin
0
0
a24a20be5bda37003ef52c84deb8246cdcdb3d07
2,618
advent-of-code-kotlin
Apache License 2.0
src/Day06.kt
ajmfulcher
573,611,837
false
{"Kotlin": 24722}
fun main() { fun findUniqueBlockEnd(input: String, size: Int): Int { val line = input.toCharArray() val set = HashSet<Char>() var idx = 0 while (set.size != size) { set.clear() set.addAll(line.copyOfRange(idx, idx + size).toList()) idx += 1 ...
0
Kotlin
0
0
981f6014b09e347241e64ba85e0c2c96de78ef8a
889
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/day02/Day02.kt
tiefenauer
727,712,214
false
{"Kotlin": 11843}
/** * --- Day 2: Cube Conundrum --- * You're launched high into the atmosphere! The apex of your trajectory just barely reaches the surface of a large island floating in the sky. You gently land in a fluffy pile of leaves. It's quite cold, but you don't see much snow. An Elf runs over to greet you. * * The Elf expl...
0
Kotlin
0
0
ffa90fbdaa779cfff956fab614c819274b793d04
4,900
adventofcode-2023
MIT License
solutions/src/NumberOfClosedIslands.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/number-of-closed-islands/ */ class NumberOfClosedIslands { fun closedIsland(grid: Array<IntArray>): Int { var numIslands = 0 val visited = mutableSetOf<Pair<Int,Int>>() for (i in grid.indices) { for (j in grid[0].indices) { ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,484
leetcode-solutions
MIT License
kotlin/Determinant.kt
indy256
1,493,359
false
{"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571}
import kotlin.math.abs // https://en.wikipedia.org/wiki/Determinant fun det(matrix: Array<DoubleArray>): Double { val EPS = 1e-10 val a = matrix.map { it.copyOf() }.toTypedArray() val n = a.size var res = 1.0 for (i in 0 until n) { val p = (i until n).maxByOrNull { abs(a[it][i]) }!! ...
97
Java
561
1,806
405552617ba1cd4a74010da38470d44f1c2e4ae3
947
codelibrary
The Unlicense
src/main/kotlin/aoc2020/DockingData.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.nonEmptyLines fun dockingData1(input: String): Long { val memory = mutableMapOf<Long, Long>() for ((mask, assignments) in parseDockingData(input)) for ((address, value) in assignments) memory[address] = applyMask(value, mask...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,526
advent-of-code
MIT License
src/main/kotlin/Chapter05/Map.kt
PacktPublishing
143,155,611
false
null
package Chapter5 fun createMap(){ val map: Map<Int,String> = mapOf( Pair(1,"One"), Pair(1,"One"), Pair(2,"Two"), Pair(3,"Three"), 4 to "Four", 5 to "Five") for(pair in map){ println("${pair.key} ${pair.value}") } val setOfPairs = map.entries for ((key, value) in setOfPairs) { pri...
0
Kotlin
13
22
1d36b576b8763387645a505cb8566c679c1e522b
2,524
Hands-On-Object-Oriented-Programming-with-Kotlin
MIT License
src/algorithm/BubbleSort.kt
DavidZhong003
157,566,685
false
null
package algorithm /** * 冒泡排序算法 * 时间复杂度 O(n²) * 空间复杂度 O(1) * 步骤: * 1. 比较相邻的两个元素,如果第一个大于第二个(或者小于),进行交换. * 2. 重复进行,最后一个元素是最大(最小)元素. * 3. 对所有未排序元素进行上述操作,知道排序完成. * @author doive * on 2018/12/17 10:56 */ class BubbleSort : IArraySort{ override fun sort(array: IntArray): IntArray { for (index in array....
0
Kotlin
0
1
7eabe9d651013bf06fa813734d6556d5c05791dc
953
LeetCode-kt
Apache License 2.0
src/main/kotlin/org/wow/learning/vectorizers/planet/PlanetVectorizer.kt
WonderBeat
22,673,830
false
null
package org.wow.learning.vectorizers.planet import com.epam.starwors.galaxy.Planet import org.wow.evaluation.transition.PlayerGameTurn import org.wow.logger.PlayerMove import org.apache.mahout.vectorizer.encoders.FeatureVectorEncoder import org.wow.learning.vectorizers.Vectorizer import org.apache.mahout.math.Vector i...
0
Kotlin
0
0
92625c1e4031ab4439f8d8a47cfeb107c5bd7e31
2,003
suchmarines
MIT License
src/Day11.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
typealias ApeId = Int data class Event( val inspectedItem: Long, val throwerId: ApeId, val receiverId: ApeId ) data class Ape( val id: ApeId, val items: List<Long>, val worryLevelInc: (Long) -> Long, val throwToTrue: ApeId, val throwToFalse: ApeId, val dividend: Long, val numIt...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
5,249
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MedianFinder.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
1,711
kotlab
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/FibonacciNumbers.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Use this technique to solve problems that follow the Fibonacci numbers sequence, i.e., every subsequent number is calculated from the last few numbers. */ //1. Staircase fun countWaysToClimbStairs(n: Int): Int { if (n <= 1) { return 1 } var first = 1 var second = 1 for (i in 2..n) { ...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
1,763
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/Day01.kt
bherbst
572,621,759
false
{"Kotlin": 8206}
fun main() { fun getCalories(input: List<String>): List<Int> { var index = 0; return input.fold(mutableListOf(0)) { values, line -> if (line.isBlank()) { index++ values.add(0) } else { values[index] += line.toInt() ...
0
Kotlin
0
0
64ce532d7a0c9904db8c8d09ff64ad3ab726ec7e
846
2022-advent-of-code
Apache License 2.0
src/main/kotlin/algos/Sorting.kt
amartya-maveriq
510,824,460
false
{"Kotlin": 42296}
package algos object Sorting { // 100,000 random numbers took 17226 milliseconds fun bubbleSort(arr: IntArray) { for (i in arr.indices) { for (j in 0 until arr.lastIndex - i) { if (arr[j] > arr[j + 1]) { arr[j] += arr[j + 1] arr[j + 1...
0
Kotlin
0
0
2f12e7d7510516de9fbab866a59f7d00e603188b
1,846
data-structures
MIT License
src/test/kotlin/Day14.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day14 { @Test fun `part1`() { val input = readFileAsLinesUsingUseLines("/Users/fredrikfolkesson/git/advent-of-code/inputs/input-day14.txt") println(getSumOfMemory(input)) } private fun getSumOfMemory(instruction...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
4,778
advent-of-code
MIT License
src/main/kotlin/tw/gasol/aoc/aoc2022/Day8.kt
Gasol
574,784,477
false
{"Kotlin": 70912, "Shell": 1291, "Makefile": 59}
package tw.gasol.aoc.aoc2022 import org.jetbrains.annotations.TestOnly class Day8 { fun part1(input: String): Int { val treeMap = TreeMap.fromInput(input) // treeMap.printVisibleMap() return treeMap.countVisible() } fun part2(input: String): Int { val treeMap = TreeMap.from...
0
Kotlin
0
0
a14582ea15f1554803e63e5ba12e303be2879b8a
5,851
aoc2022
MIT License
src/main/kotlin/day08/Day08.kt
vitalir2
572,865,549
false
{"Kotlin": 89962}
package day08 import Challenge private typealias Forest = List<List<Int>> object Day08 : Challenge(8) { override fun part1(input: List<String>): Any { val forest = createForest(input) val visibleTrees = mutableListOf<Int>() for ((rowIndex, row) in forest.withIndex()) { for ((...
0
Kotlin
0
0
ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6
4,241
AdventOfCode2022
Apache License 2.0
codeforces/vk2021/qual/ad.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.vk2021.qual fun main() { val words = "lock, unlock, red, orange, yellow, green, blue, indigo, violet".split(", ") val wordsMap = words.withIndex().associate { it.value to it.index } val init = List(readInt()) { wordsMap[readLn()]!! } val st = SegmentsTreeSimple(init.size) for (i in init.indices...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,287
competitions
The Unlicense
test/com/zypus/SLIP/algorithms/genetic/GeneticTest.kt
zypus
213,665,750
false
null
package com.zypus.SLIP.algorithms.genetic import com.zypus.SLIP.algorithms.genetic.builder.evolution import com.zypus.utilities.pickRandom import org.junit.Assert import org.junit.Test import java.util.* /** * TODO Add description * * @author fabian <<EMAIL>> * * @created 03/03/16 */ class GeneticTest { @Tes...
0
Kotlin
0
0
418ee8837752143194fd769e86fac85e15136929
4,259
SLIP
MIT License
modules/fathom/src/main/kotlin/silentorb/mythic/fathom/surfacing/CellAccumulation.kt
silentorb
227,508,449
false
null
package silentorb.mythic.fathom.surfacing import silentorb.mythic.spatial.Vector3 import silentorb.mythic.spatial.getCenter import kotlin.math.abs data class MergeConfig( val distanceTolerance: Float, val axis: Int, val boundaryRange: Float, val cellSize: Float ) data class Clump( val first: Vect...
0
Kotlin
0
2
74462fcba9e7805dddec1bfcb3431665df7d0dee
5,921
mythic-kotlin
MIT License
AdventOfCodeDay09/src/nativeMain/kotlin/Day09.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
class Day09(lines:List<String>) { private val data = Matrix.create(lines) fun solvePart1() = generateLowPointValues(data).sumOf{it+1} fun solvePart2() = generateBasins(data) .map{it.count()} .sortedDescending() .take(3).product() private fun generateBasins(data: Matrix): Sequen...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
906
AdventOfCode2021
The Unlicense
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec17.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec17 : PuzzleDayTester(17, 2020) { private data class Coord(val w: Int, val z: Int, val y: Int, val x: Int) override fun part1(): Any = doDumbShit((0..0)) override fun part2(): Any = doDumbShit((-1..1)) private fun ...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
6,539
advent-of-code
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day17.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints fun main() = Day17.run() object Day17 : Day(2015, 17) { override fun part1(): Any { val containers = ints(input) var ways = mapOf(150 to 1) for (container in containers) { val ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,261
adventofkotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2269/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2269 /** * LeetCode page: [2269. Find the K-Beauty of a Number](https://leetcode.com/problems/find-the-k-beauty-of-a-number/); */ class Solution { /* Complexity: * Time O(LogN) and Space O(LogN) where N equals num; */ fun divisorSubstrings(num: Int, k: Int): In...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,461
hj-leetcode-kotlin
Apache License 2.0
day15/kotlin/corneil/src/main/kotlin/solution.kt
mehalter
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271053, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust":...
package com.github.corneil.aoc2019.day15 import com.github.corneil.aoc2019.common.Graph import com.github.corneil.aoc2019.common.Graph.Edge import com.github.corneil.aoc2019.day15.DIRECTION.EAST import com.github.corneil.aoc2019.day15.DIRECTION.NORTH import com.github.corneil.aoc2019.day15.DIRECTION.SOUTH import com....
0
HTML
0
0
afcaede5326b69fedb7588b1fe771fd0c0b3f6e6
11,001
docToolchain-aoc-2019
MIT License
src/Day04.kt
acrab
573,191,416
false
{"Kotlin": 52968}
import com.google.common.truth.Truth.assertThat fun main() { fun List<String>.parseList(): List<List<List<Int>>> = map { it.split(",").map { sublist -> sublist.split("-").map(String::toInt) } } fun part1(input: List<String>): Int = input.parseList() .count { (it[0][0] <= it[1][0] ...
0
Kotlin
0
0
0be1409ceea72963f596e702327c5a875aca305c
902
aoc-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/RemoveKDigits.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import java.util.* /** * 402. 移掉K位数字 * * 给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小。 * * 注意: * * num 的长度小于 10002 且 ≥ k。 * num 不会包含任何前导零。 * 示例 1 : * * 输入: num = "1432219", k = 3 * 输出: "1219" * 解释: 移除掉三个数字 4, 3, 和 2 形成一个新的最小的数字 1219。 * 示例 2 : * * 输入: num = "10200", ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,241
daily_algorithm
Apache License 2.0
src/main/kotlin/chjaeggi/Day9.kt
chjaeggi
296,447,759
false
null
package chjaeggi class Day9(private val input: List<Long>, private val preAmble: Int) { fun solvePart1(): Long { input.forEachIndexed { index, _ -> if (index < (preAmble)) { return@forEachIndexed } else if (index + 1 >= input.size) { return@forEachIn...
0
Kotlin
0
1
3ab7867a5c3b06b8f5f90380f0ada1a73f5ffa71
1,700
aoc2020
Apache License 2.0
src/main/kotlin/graph/variation/Island.kt
yx-z
106,589,674
false
null
package graph.variation import java.util.* fun main(args: Array<String>) { // given an m * n array representing a map // mark 1 as island, 0 as ocean // and given that islands are four-directionally connected val testMap = arrayOf( intArrayOf(1, 1, 0, 0, 1), intArrayOf(1, 0, 0, 1, 0), intArrayOf(0, 1, 1,...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
3,225
AlgoKt
MIT License
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt
nekomangaorg
182,704,531
false
{"Kotlin": 3454839}
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 mangaList to efficiently schedule mangaList to * update. */ object LibraryUpdateRanker { val rankingScheme = listOf( ...
85
Kotlin
111
1,985
4dc7daf0334499ca72c7f5cbc7833f38a9dfa2c3
2,136
Neko
Apache License 2.0
array/src/commonMain/kotlin/array/kotlin-complex.kt
lokedhs
236,192,362
false
null
package array.complex import kotlin.math.* data class Complex(val real: Double, val imaginary: Double) { constructor(value: Double) : this(value, 0.0) fun reciprocal(): Complex { val scale = (real * real) + (imaginary * imaginary) return Complex(real / scale, -imaginary / scale) } f...
0
Kotlin
2
42
02445a1e8763d0d95860672071d6762f52a8004b
3,196
array
MIT License
Algorithms/432 - All O one Data Structure/src/Solution.kt
mobeigi
202,966,767
false
null
/** * Solution * * We use two maps to allow us to lookup keys by string in O(1) and lookup by frequency in O(1). * We also maintain a key count for the minimum and maximum at all times. * We maintain the maximum and minimum as we increment and decrement. * * The getMaxKey and getMinKey are guaranteed to always b...
0
Kotlin
0
0
e5e29d992b52e4e20ce14a3574d8c981628f38dc
4,556
LeetCode-Solutions
Academic Free License v1.1
bdd/src/commonTest/kotlin/it/unibo/tuprolog/bdd/TestBinaryDecisionDiagram.kt
tuProlog
230,784,338
false
{"Kotlin": 3879230, "Java": 18690, "ANTLR": 10366, "CSS": 1535, "JavaScript": 894, "Prolog": 818}
package it.unibo.tuprolog.bdd import kotlin.test.Test import kotlin.test.assertTrue class TestBinaryDecisionDiagram { private val doubleEpsilon = 0.0001 private class ComparablePair(val id: Long, val first: String, val second: Double) : Comparable<ComparablePair> { override fun compareTo(other: Compa...
71
Kotlin
13
79
804e57913f072066a4e66455ccd91d13a5d9299a
3,424
2p-kt
Apache License 2.0
Array/huangxinyu/kotlin/src/StrStr.kt
JessonYue
268,215,243
false
null
package com.ryujin.algorithm /** * 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回  -1 * 来源:力扣(LeetCode) * 链接:https://leetcode-cn.com/problems/implement-strstr * * 理解视频:https://www.bilibili.com/video/BV1jb411V78H */ class StrStr { companion object { /** ...
0
C
19
39
3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79
2,610
LeetCodeLearning
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day05.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import kotlin.math.min import kotlin.system.measureTimeMillis import kotlin.test.Ignore import kotlin.test.assertEquals class Day05 : AbstractDay() { @Test fun part1Test() { ...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
4,274
aoc
Apache License 2.0
project/src/problems/CaterPillarMethod.kt
informramiz
173,284,942
false
null
package problems /** * https://codility.com/media/train/13-CaterpillarMethod.pdf * * The Caterpillar method is a likeable name for a popular means of solving algorithmic tasks. * The idea is to check elements in a way that’s reminiscent of movements of a caterpillar. * The caterpillar crawls through the array. We...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
17,499
codility-challenges-practice
Apache License 2.0
src/Day03_part2.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part2(input: List<String>): Int { fun calcPriority(input: Char): Int { return if (input.code <= 'Z'.code) { input.code - 'A'.code + 27 } else { input.code - 'a'.code + 1 } } var priority = 0 var i =...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
799
advent-of-code-2022
Apache License 2.0
common/src/main/kotlin/combo/bandit/dt/SplitMetric.kt
rasros
148,620,275
false
null
package combo.bandit.dt import combo.math.VarianceEstimator import combo.math.chi2CdfDf1 import combo.math.fCdfDf1 import kotlin.math.log2 import kotlin.math.sqrt interface SplitMetric { fun split(total: VarianceEstimator, pos: Array<VarianceEstimator>, neg: Array<VarianceEstimator>, minSamplesSpl...
0
Kotlin
1
2
2f4aab86e1b274c37d0798081bc5500d77f8cd6f
4,548
combo
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day23.kt
clechasseur
435,726,930
false
{"Kotlin": 315943}
package io.github.clechasseur.adventofcode2021 import io.github.clechasseur.adventofcode2021.dij.Dijkstra import io.github.clechasseur.adventofcode2021.dij.Graph import io.github.clechasseur.adventofcode2021.util.Direction import io.github.clechasseur.adventofcode2021.util.Pt import kotlin.math.min object Day23 { ...
0
Kotlin
0
0
4b893c001efec7d11a326888a9a98ec03241d331
4,719
adventofcode2021
MIT License
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day13.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 object Day13 { private val DIVIDER_PACKETS = Pair(packet("[[2]]"), packet("[[6]]")) fun sumOfPacketPairIndicesInRightOrder(input: String) = packetPairs(input) .withIndex() .filter { (_, packetPair) -> rightOrder(packetPair.first, packetPair.second)...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
3,803
advent-of-code
MIT License
src/main/year_2016/day15/day15.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package year_2016.day15 import readInput val reg = """\b\d+\b""".toRegex() fun main() { val input = readInput("main/year_2016/day15/Day15") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { return part2(input.dropLast(1)) } fun part2(input: List<String>): Int { ...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
859
aoc-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Space.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.common import kotlin.math.* typealias Point2D = Pair<Int, Int> val Point2D.x: Int get() = first val Point2D.y: Int get() = second operator fun Point2D.plus(other: Point2D) = Point2D(x + other.x, y + other.y) operator fun Point2D.minus(other: Point2D) = Point2D(x - other.x, y - other....
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,218
advent-of-code
MIT License
src/Day09.kt
RogozhinRoman
572,915,906
false
{"Kotlin": 28985}
import kotlin.math.abs fun main() { fun printGrid( grid: Array<MutableList<String>>, H: Pair<Int, Int>, T: Pair<Int, Int> ) { for (i in grid.indices) { for (j in grid[i].indices) { if (H.first == i && H.second == j) { print("H") ...
0
Kotlin
0
1
6375cf6275f6d78661e9d4baed84d1db8c1025de
4,765
AoC2022
Apache License 2.0
advent5/src/main/kotlin/Main.kt
thastreet
574,294,123
false
{"Kotlin": 29380}
import java.io.File import java.util.Stack data class Command( val count: Int, val from: Int, val to: Int ) fun main(args: Array<String>) { val lines = File("input.txt").readLines() val commands = parseCommands(lines) val part1Result = part1(getStacks(), commands) println("part1Result: $p...
0
Kotlin
0
0
e296de7db91dba0b44453601fa2b1696af9dbb15
2,229
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/themobilecoder/adventofcode/day5/DayFiveUtils.kt
themobilecoder
726,690,255
false
{"Kotlin": 323477}
package com.themobilecoder.adventofcode.day5 import com.themobilecoder.adventofcode.splitByNewLine fun String.getSeedsToBePlanted(): List<UInt> { val lines = splitByNewLine() return lines.first { it.contains("seeds:") }.split(":")[1] .trim() .split(" ") .map { i...
0
Kotlin
0
0
b7770e1f912f52d7a6b0d13871f934096cf8e1aa
4,279
Advent-of-Code-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/AnswerQueries.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,427
kotlab
Apache License 2.0
src/main/kotlin/day15/Day15.kt
limelier
725,979,709
false
{"Kotlin": 48112}
package day15 import common.InputReader private fun String.hash(): Int { var hash = 0 for (c in this) { hash += c.code hash *= 17 hash %= 256 } return hash } private data class Lens(val label: String, val focalLength: Int) private sealed interface Step { val label: String } pr...
0
Kotlin
0
0
0edcde7c96440b0a59e23ec25677f44ae2cfd20c
1,848
advent-of-code-2023-kotlin
MIT License
src/main/kotlin/com/github/dangerground/Day14.kt
dangerground
226,153,955
false
null
package com.github.dangerground import kotlin.math.ceil import kotlin.math.floor typealias Chemical = String class Nanofactory(reactionsInput: String) { val reactions = HashMap<Chemical, Reaction>() init { reactionsInput.lines().forEach { reaction -> val reactionParts = reaction.split("...
0
Kotlin
0
1
125d57d20f1fa26a0791ab196d2b94ba45480e41
2,753
adventofcode
MIT License
src/com/ncorti/aoc2023/Day20.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 data class Wire( val name: String, val type: String, val next: List<String>, var status: Boolean = false, var memory: MutableMap<String, Boolean> = mutableMapOf(), ) { fun initMemory(input: Map<String, Wire>) { input.forEach { (key, value) -> if (v...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
4,235
adventofcode-2023
MIT License
src/Day02.kt
kprow
573,685,824
false
{"Kotlin": 23005}
fun main() { var scoreSum2 = 0 fun part1(input: List<String>): Int { var scoreSum = 0 scoreSum2 = 0 var yours = YourHand.X var theirs = OpponentHand.A var result = YourResult.X for (game in input) { theirs = OpponentHand.valueOf(game[0].toString()) ...
0
Kotlin
0
0
9a1f48d2a49aeac71fa948656ae8c0a32862334c
3,156
AdventOfCode2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day02.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints fun main() { Day02.run() } object Day02 : Day(2015, 2) { override fun part1() = input.lines().map { ints(it) }.sumOf { surfaceArea(it) + extra(it) } private fun extra(inp: List<Int>) = (inp[0] * inp[1]).c...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
799
adventofkotlin
MIT License
src/main/kotlin/algorithms/LongestCommonSubsequenceLCS.kt
jimandreas
377,843,697
false
null
@file:Suppress("SameParameterValue", "UnnecessaryVariable", "UNUSED_VARIABLE", "ControlFlowWithEmptyBody", "unused", "MemberVisibilityCanBePrivate", "LiftReturnOrAssignment" ) package algorithms import kotlin.math.max /** Code Challenge: Solve the Longest Common Subsequence Problem. Input: Two strings s and t. ...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
3,027
stepikBioinformaticsCourse
Apache License 2.0
2020/04/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File private const val FILENAME = "2020/04/input.txt" fun main() { partOne() partTwo() } private fun partOne() { val passports = File(FILENAME) .readText() .trim() .split("\r\n\r\n") .map { it.replace("\r\n", " ") } val requiredFields = listOf("byr", "i...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
2,481
Advent-of-Code
MIT License
src/main/kotlin/g0401_0500/s0497_random_point_in_non_overlapping_rectangles/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0401_0500.s0497_random_point_in_non_overlapping_rectangles // #Medium #Math #Binary_Search #Prefix_Sum #Ordered_Set #Randomized #Reservoir_Sampling // #2023_01_04_Time_759_ms_(100.00%)_Space_100.1_MB_(100.00%) import java.util.Random @Suppress("kotlin:S2245") class Solution(rects: Array<IntArray>) { pri...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,782
LeetCode-in-Kotlin
MIT License