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/Day14.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
import kotlin.math.sign enum class ContentType { Air, Rock, Sand, Hole } data class Point(var x: Int, var y: Int) { fun down(): Point { return this.copy(y = y + 1) } fun diagLeft(): Point { return this.copy(x = x - 1, y = y + 1) } fun diagRight(): Point { return this.copy(...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
4,449
advent-of-code-2022
Apache License 2.0
src/Day9/December9.kt
Nandi
47,216,709
false
null
package Day9 import org.jgrapht.experimental.permutation.CollectionPermutationIter import org.jgrapht.graph.DefaultWeightedEdge import org.jgrapht.graph.SimpleWeightedGraph import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Stream /** * todo: visualize * * Every year, Santa manages to de...
0
Kotlin
0
0
34a4b4c0926b5ba7e9b32ca6eeedd530f6e95bdc
2,705
adventofcode
MIT License
src/main/kotlin/day23/part2/Part2.kt
bagguley
329,976,670
false
null
package day23.part2 fun main() { println("Start") val t1 = System.currentTimeMillis() val nodes = createNodes() var ptr = nodes.first() println("Run") for (i in 1..10_000_000) { addAfter(take3(ptr), ptr) ptr = ptr.nextNode } val one = nodes.find { n -> n.value == 1 }!...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
2,235
adventofcode2020
MIT License
src/Day04.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
fun main() { fun parseInput(input: String): List<IntRange> { return input.split(',') .map { it.split('-').map { it.toInt() } } .sortedWith(compareBy<List<Int>> { it[0] }.thenByDescending { it[1] - it[0] }) .map { it[0] .. it[1] } } fun part1(input: List<String>): Int { return input.map(...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
700
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/g0801_0900/s0835_image_overlap/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0835_image_overlap // #Medium #Array #Matrix #2023_03_27_Time_163_ms_(100.00%)_Space_35.3_MB_(100.00%) class Solution { fun largestOverlap(img1: Array<IntArray>, img2: Array<IntArray>): Int { val bits1 = bitwise(img1) val bits2 = bitwise(img2) val n = img1.size ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,748
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Excercise16.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
private val input = getInputAsTest("16")[0].map { it.digitToInt(16).toString(2).padStart(4, '0') }.joinToString("") private fun part1() { var i = 0 fun next(n: Int) = input.substring(i, i + n).toInt(2).also { i += n } var ans = 0 fun parse(maxLen: Int = Int.MAX_VALUE, maxPackets: Int = Int.MAX_VALUE) { ...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
2,339
advent-of-code-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordDictionary.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,346
kotlab
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem636/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem636 /** * LeetCode page: [636. Exclusive Time of Functions](https://leetcode.com/problems/exclusive-time-of-functions/); */ class Solution { /* Complexity: * Time O(M+L) and Space O(M+N+K) where * M is the size of logs, * L is the flat length of logs, ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,595
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-16.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 import java.util.* fun main() { println("Part1:") println(solve2(testInput1, 20)) println(solve2(input, 272)) println() println("Part2:") println(solve2(input, 35651584)) } private fun solve2(input: String, length: Int): String { val bits ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,223
advent-of-code
MIT License
src/day10/Day10.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day10 import readInput fun main() { val importantCycles = listOf(20, 60, 100, 140, 180, 220) fun checkImportantCycle(currentCycle: Int, registerX: Int): Int { if (currentCycle in importantCycles) { return registerX * currentCycle } return 0 } fun part1(in...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
2,379
advent-of-code-kotlin-2022
Apache License 2.0
year2020/src/main/kotlin/net/olegg/aoc/year2020/day14/Day14.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day14 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 14](https://adventofcode.com/2020/day/14) */ object Day14 : DayOf2020(14) { private val PATTERN = "^mem\\[(\\d+)] = (\\d+)$".toRegex() override fun first(): Any? { val ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,270
adventofcode
MIT License
src/main/aoc2022/Day5.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 class Day5(input: List<String>) { /** * A list of all stacks, the top of each stack is position 0 in each stack. */ private val stacks = parseStacks(input.first().split("\n")) /** * List of instructions, first entry is how many to move, second from index and last to index. ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,059
aoc
MIT License
src/main/kotlin/day13/Day13.kt
vitalir2
572,865,549
false
{"Kotlin": 89962}
package day13 import Challenge import product object Day13 : Challenge(13) { override fun part1(input: List<String>): Int { val packetPairs = parseInput(input) val inRightOrderIndices = mutableSetOf<Int>() packetPairs.forEachIndexed { index, pair -> if (isPairInTheRightOrder(pair)) inRigh...
0
Kotlin
0
0
ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6
6,152
AdventOfCode2022
Apache License 2.0
src/aoc2023/Day06.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput fun main() { val (year, day) = "2023" to "Day06" fun countWays(times: List<Long>, distances: List<Long>) = times.mapIndexed { index, time -> (1L until time).map { it * (time - it) }.count { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,141
aoc-kotlin
Apache License 2.0
src/Day18.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import utils.Coordinate3D import utils.readInputAsLines fun main() { val input = readInputAsLines("day18_input_test") val cubes = input.map { it.split(',') } .map { (x, y, z) -> Coordinate3D(x.toInt(), y.toInt(), z.toInt()) }.toSet() fun part1() = cubes.sumOf { cube -> cube.neighbours().count { it...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
1,241
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountSubmatricesWithAllOnes.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,589
kotlab
Apache License 2.0
src/main/java/challenges/educative_grokking_coding_interview/top_k_elements/_5/KthLargestElement.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.top_k_elements._5 import challenges.util.PrintHyphens import java.util.* /** Find the kth largest element in an unsorted array. Note: We need to find the kth largest element in the sorted order, not the kth distinct element. https://www.educative.io/courses/grok...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
1,913
CodingChallenges
Apache License 2.0
src/main/kotlin/days/Day05.kt
TheMrMilchmann
433,608,462
false
{"Kotlin": 94737}
/* * Copyright (c) 2021 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
dfc91afab12d6dad01de552a77fc22a83237c21d
3,185
AdventOfCode2021
MIT License
src/main/problem4/solution2.kt
lorenzo-piersante
515,177,846
false
{"Kotlin": 15798, "Java": 4893}
package problem4 import java.util.Scanner private fun isPalindrome(n : Int) : Boolean { val straight = n.toString() val reversed = straight.reversed() return straight == reversed } private fun getPreviousPalindrome(n : Int) : Int { var prev = n while (! isPalindrome(prev)) prev-- return pre...
0
Kotlin
0
0
6159bb49cdfe94310a34edad138de2998352f1c2
1,184
HackerRank-ProjectEuler
MIT License
core-kotlin-modules/core-kotlin-collections-map/src/test/kotlin/com/baeldung/maptransform/MapTransformUnitTest.kt
Baeldung
260,481,121
false
{"Kotlin": 1476024, "Java": 43013, "HTML": 4883}
package com.baeldung.maptransform import org.junit.Test import kotlin.test.assertEquals class MapTransformUnitTest { @Test fun `transform map using mapValues() method`() { val map = mapOf("one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5) val transformedMap = map.mapValues { it.va...
10
Kotlin
273
410
2b718f002ce5ea1cb09217937dc630ff31757693
2,392
kotlin-tutorials
MIT License
Kotlin/heap_sort_in_kotlin.kt
iam-abbas
213,309,115
false
null
var heapSize = 0 fun left(i: Int): Int { return 2 * i } fun right(i: Int): Int { return 2 * i + 1 } fun swap(A: Array<Int>, i: Int, j: Int) { var temp = A[i] A[i] = A[j] A[j] = temp } fun max_heapify(A: Array<Int>, i: Int) { var l = left(i); var r = right(i); var largest: Int; i...
3
C++
383
215
d04aa8fd9a1fa290266dde96afe9b90ee23c5a92
1,225
cs-algorithms
MIT License
kotlin/problems/src/solution/LinkProblems.kt
lunabox
86,097,633
false
{"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966}
package solution import data.structure.ListNode class LinkProblems { /** * https://leetcode-cn.com/problems/merge-k-sorted-lists/ */ fun mergeKLists(lists: Array<ListNode?>): ListNode? { var currentNode = Array<ListNode?>(lists.size) { null } var result: ListNode? = null var...
0
Kotlin
0
0
cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9
10,550
leetcode
Apache License 2.0
src/day04/Day04_part2.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day04 import readLines fun main() { fun part2(pairs: List<String>): Int { var total = 0 // e.g. 10-15,3-10 for (pair in pairs) { // ["10-15", "3-10"] val assignments = pair.split(",") // [10,15] val assignment1 = assignments[0].spl...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,060
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DecodeMessage.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,026
kotlab
Apache License 2.0
src/Day15.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
import kotlin.math.absoluteValue fun main() { val inputLineRegex = """Sensor at x=([-\d]+), y=([-\d]+): closest beacon is at x=([-\d]+), y=([-\d]+)""".toRegex() data class SensorData(val sensorPos: Pair<Int, Int>, val beaconPos: Pair<Int, Int>, val distance: Int) fun manhattanDistance(p1: Pair<Int, Int>,...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
5,665
advent-of-code-2022
Apache License 2.0
CelebrityMashup.kts
breun
294,154,833
false
null
import java.io.File // Models data class Mashup( val mashupName: String, val overlap: Int, val originalNames: Pair<String, String> ) // Functions fun readNamesFromTxtFiles(path: String): List<String> = File(path) .listFiles { _, name -> name.endsWith(".txt") } .flatMap { it.readLines...
0
Kotlin
0
0
741f038625de1bf835c8ed58320fad45c39439cb
2,013
celebrity-mashups
Apache License 2.0
src/main/kotlin/days/aoc2021/Day4.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day class Day4 : Day(2021, 4) { override fun partOne(): Any { return parseInput(inputList).calculateFirstWinner() } override fun partTwo(): Any { return parseInput(inputList).calculateLastWinner() } fun parseInput(input: List<String>): BingoGame {...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,811
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/hj/leetcode/kotlin/problem47/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem47 /** * LeetCode page: [47. Permutations II](https://leetcode.com/problems/permutations-ii/); */ class Solution { /* Complexity: * Time O(N * N!) and Aux_Space O(N) where N is the size of nums; */ fun permuteUnique(nums: IntArray): List<List<Int>> { va...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,557
hj-leetcode-kotlin
Apache License 2.0
src/chapter3/section5/ex16.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section5 import chapter3.section4.LinearProbingHashST import extensions.formatDouble import kotlin.math.abs /** * 为SparseVector添加一个sum()方法,接受一个SparseVector对象作为参数并将两者相加的结果返回为一个SparseVector对象 * 请注意:你需要使用delete()方法来处理向量中的一项变为0的情况(请特别注意精度) * * 解:向量相加等于对应位置的数相加 */ class SparseVector(val st: LinearPro...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
3,051
Algorithms-4th-Edition-in-Kotlin
MIT License
Strategy.kt
kgw78
671,116,967
false
null
// Strategy Pattern Example // ソートアルゴリズムのStrategyインターフェース interface SortStrategy { fun sort(numbers: IntArray): IntArray } // バブルソートアルゴリズム class BubbleSortStrategy : SortStrategy { override fun sort(numbers: IntArray): IntArray { val sortedArray = numbers.clone() val n = sortedArray.size ...
0
Kotlin
0
0
24b8993c533373ffdfab4e56fe1bb4e59a6933b0
2,104
kotlin-design-patterns
MIT License
src/day07/Day07.kt
cmargonis
573,161,233
false
{"Kotlin": 15730}
package day07 import readInput import java.util.LinkedList private const val DIRECTORY = "./day07" private const val COMMAND = "$" private const val SPACE_NEEDED_FOR_UPDATE = 30000000 fun main() { fun traverseFileSystem(node: Node, action: (node: Node) -> Unit) { if (node is Node.Directory) node.childr...
0
Kotlin
0
0
bd243c61bf8aae81daf9e50b2117450c4f39e18c
4,869
kotlin-advent-2022
Apache License 2.0
src/chapter3/section2/ex6.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section2 import chapter3.section1.testOrderedST import extensions.random /** * 为二叉查找树添加一个方法height()来计算树的高度 * 实现两种方案:一种使用递归(用时为线性级别,所需空间和树高度成正比) * 一种模仿size()在每个结点种添加一个变量(所需空间为线性级别,查询耗时为常数) */ fun <K : Comparable<K>, V : Any> BinarySearchTree<K, V>.height(): Int { if (isEmpty()) return 0 re...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
4,518
Algorithms-4th-Edition-in-Kotlin
MIT License
src/y2022/Day01.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2022 import utils.readInput fun main() { fun foldIt(input: List<String>): List<Int> { return input.fold(mutableListOf(0)) { acc, next -> if (next.isNotBlank()) acc[acc.lastIndex] = next.toInt() + acc.last() else acc.add(0) // this is the first argument - operation acc //...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
995
advent-of-code-kotlin
Apache License 2.0
src/y2022/Day02.kt
Yg0R2
433,731,745
false
null
package y2022 import DayX import y2022.Day02.Results.DRAW import y2022.Day02.Results.LOOS import y2022.Day02.Results.WIN import y2022.Day02.Signals.PAPER import y2022.Day02.Signals.ROCK import y2022.Day02.Signals.SCISSORS class Day02 : DayX<Int>(15, 12) { /** * A, X => Rock (1 point) * B, Y => Paper (2...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
3,371
advent-of-code
Apache License 2.0
src/Day06.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
fun main() { fun part1(input: List<String>): Int { val chars = input.first().toCharArray().toList() repeat(chars.size) { i -> val endIdx = i + 4 if (chars.subList(i, endIdx).distinct().size == 4) { return endIdx } } return 0 } ...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
831
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/djei/balltree/BallTree.kt
Djei
492,503,847
false
{"Kotlin": 19152}
package com.djei.balltree import java.util.* class BallTree( points: List<Point>, private val distance: (Point, Point) -> Double, maxDepth: Int ) { val root: BallTreeNode = BallTreeNode(points, distance, maxDepth) init { val queue = LinkedList<BallTreeNode>() queue.push(root) ...
0
Kotlin
0
0
dbd801c2189c9b67a3904c7be33b9b055216babb
5,120
balltree
MIT License
src/Day05.kt
vonElfvin
572,857,181
false
{"Kotlin": 11658}
fun main() { fun solve(input: List<String>, reversed: Boolean): String { val boxRegex = "[A-Z]".toRegex() val boxes: MutableMap<Int, List<Pair<Int, Char>>> = mutableMapOf() var row = 0 do { val rowBoxes = boxRegex.findAll(input[row]).toList().map { Pair((it.range.first - ...
0
Kotlin
0
0
6210f23f871f646fcd370ec77deba17da4196efb
1,373
Advent-of-Code-2022
Apache License 2.0
src/main/java/leetcode/searchmatrix2/Solution.kt
thuytrinh
106,045,038
false
null
package leetcode.searchmatrix2 sealed class Result object Found : Result() data class NotFoundYet(val maxIndex: Int) : Result() /** * https://leetcode.com/problems/search-a-2d-matrix-ii/description/ */ class Solution { // a = [7, 8, 11, 15, 15], target = 12 private fun IntArray.bs( left: Int = 0, // left ...
0
Kotlin
0
1
23da0286a88f855dcab1999bcd7174343ccc1164
1,213
algorithms
MIT License
src/main/kotlin/com/groundsfam/advent/y2021/d10/Day10.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d10 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines val syntaxScores = mapOf( ')' to 3, ']' to 57, '}' to 1197, '>' to 25137, ) val autocompleteScores = mapOf( ')' to 1, ']' t...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,832
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RestoreTheArray.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
5,222
kotlab
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[145]二叉树的后序遍历.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.collections.ArrayList //给定一个二叉树,返回它的 后序 遍历。 // // 示例: // // 输入: [1,null,2,3] // 1 // \ // 2 // / // 3 // //输出: [3,2,1] // // 进阶: 递归算法很简单,你可以通过迭代算法完成吗? // Related Topics 栈 树 // 👍 511 👎 0 //leetcode submit region begin(Prohibit modification and deletion) /** * E...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,654
MyLeetCode
Apache License 2.0
src/main/kotlin/com/github/davio/aoc/y2022/Day10.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2022 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.call import com.github.davio.aoc.general.getInputReader import kotlin.system.measureTimeMillis fun main() { println(Day10.getResultPart1()) measureTimeMillis { println(Day10.getResultPart2())...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
3,271
advent-of-code
MIT License
platform/ml-impl/src/com/intellij/internal/ml/models/local/LocalRandomForestModel.kt
JetBrains
2,489,216
false
null
package com.intellij.internal.ml.models.local import com.intellij.internal.ml.DecisionFunction import com.intellij.internal.ml.FeaturesInfo import com.intellij.internal.ml.completion.CompletionRankingModelBase private class Tree(val thresholds: List<Double>, val values: List<Double>, ...
251
null
5,079
16,158
831d1a4524048aebf64173c1f0b26e04b61c6880
2,726
intellij-community
Apache License 2.0
src/Day04_2.kt
FuKe
433,722,611
false
{"Kotlin": 19825}
import models.BingoPlate fun main() { val rawInput: List<String> = readInput("Day04.txt") val numbersToDrawn: List<Int> = rawInput[0].split(",").map { it.toInt() } val bingoPlates: List<BingoPlate> = parseBingoPlates(rawInput) val (winningNumber, lastPlateToWin) = play(numbersToDrawn, bingoPlates) ...
0
Kotlin
0
0
1cfe66aedd83ea7df8a2bc26c453df257f349b0e
1,139
advent-of-code-2021
Apache License 2.0
day02/kotlin/gysel/src/main/kotlin/Main.kt
rdmueller
158,926,869
false
null
import java.util.concurrent.atomic.AtomicInteger fun main(args: Array<String>) { /* part one */ val exactlyTwo = AtomicInteger(0) val exactlyThree = AtomicInteger(0) openStream().reader().useLines { lines: Sequence<String> -> lines.map(::groupByCharacter) .forEach ...
26
HTML
18
19
1a0e6d89d5594d4e6e132172abea78b41be3850b
2,251
aoc-2018
MIT License
solutions/src/MiniumSizeSubArraySum.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import kotlin.math.min /** * https://leetcode.com/problems/minimum-size-subarray-sum/ */ class MiniumSizeSubArraySum { fun minSubArrayLen(s: Int, nums: IntArray) : Int { if (nums.isEmpty()) { return 0 } var minLength : Int? = null var lower = 0 var upper = 0 ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,535
leetcode-solutions
MIT License
bin/main/solutions/CHK/CheckoutSolution.kt
DPNT-Sourcecode
749,496,960
false
{"Kotlin": 37004, "Shell": 2184}
package solutions.CHK object CheckoutSolution { val prices = hashMapOf( "A" to 50, "B" to 30, "C" to 20, "D" to 15, "E" to 40, "F" to 10, "G" to 20, "H" to 10, "I" to 35, "J" to 60, "K" to 80, "L" to 90, "M" to 15, "N" to 40, "O" to 10, "P" to 50, ...
0
Kotlin
0
0
2955860e9436e1b06d5a895c1418d8f1c588a938
2,594
CHK-dkni01
Apache License 2.0
src/main/kotlin/adventofcode/y2021/Day03.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.applyToEachColumn import adventofcode.binaryStringToInt fun main() { val day = Day03() println(day.part1()) day.reset() println(day.part2()) } class Day03 : Y2021Day(3) { private val input = fetchInput() override fun part1(): Number? { val gamma = input.applyToEach...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
1,897
adventofcode2021
The Unlicense
google/2019/qualification_round/3/main.kt
seirion
17,619,607
false
{"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294}
import java.math.BigInteger import java.util.* fun main(args: Array<String>) { val t = readLine()!!.toInt() (1..t).forEach { print("Case #$it: ") solve() } } val ZERO = BigInteger("0") fun solve() { val out = ArrayList<BigInteger>() var prev = BigInteger("0") var next = BigInte...
0
C++
4
4
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
1,321
code
Apache License 2.0
src/main/kotlin/day06/boats.kt
cdome
726,684,118
false
{"Kotlin": 17211}
package day06 import java.io.File import kotlin.math.ceil import kotlin.math.sqrt fun main() { races() singleRace() } private fun races() { val file = File("src/main/resources/day06-boats").readLines() val times = file[0].split(":")[1].trim().split(" ").filter { it.isNotBlank() }.map { it.toLong() } ...
0
Kotlin
0
0
459a6541af5839ce4437dba20019b7d75b626ecd
1,119
aoc23
The Unlicense
src/main/kotlin/wtf/log/xmas2021/day/day16/Day16.kt
damianw
434,043,459
false
{"Kotlin": 62890}
package wtf.log.xmas2021.day.day16 import wtf.log.xmas2021.Day import wtf.log.xmas2021.util.collect.removeFirst import wtf.log.xmas2021.util.math.toBits import wtf.log.xmas2021.util.math.toInt import wtf.log.xmas2021.util.math.toLong import java.io.BufferedReader import java.util.* /** * It would be better to use a ...
0
Kotlin
0
0
1c4c12546ea3de0e7298c2771dc93e578f11a9c6
4,480
AdventOfKotlin2021
BSD Source Code Attribution
advent2022/src/main/kotlin/year2022/Day10.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import kotlin.math.absoluteValue class Day10 : AdventDay(2022, 10) { class Screen( val rows: Array<BooleanArray> = (0 until 6) .map { BooleanArray(40) { false } } .toTypedArray() ) { override fun toString(): String =...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,811
advent-of-code
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/dynprog/Knapsack.ws.kts
sjaindl
384,471,324
false
null
package com.sjaindl.kotlinalgsandroid.dynprog // https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/ class KnapSack { // [60, 100, 120] fun calculateKnapsack(values: IntArray, weights: IntArray, maxWeight: Int): Int { val cache: MutableMap<Memo, Int> = mutableMapOf() println("cache.size"...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,352
KotlinAlgs
MIT License
src/questions/SurroundedRegions.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe /** * Given an `m x n` matrix board containing 'X' and 'O', * capture all regions that are 4-directionally surrounded by 'X'. * A region is captured by flipping all 'O's into 'X's in that surrounded region. * * [Source](https://leetc...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
5,410
algorithms
MIT License
src/main/kotlin/solutions/Day14RegolithReservoir.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import models.Coord2d import models.Grid import utils.Input import utils.Solution // run only this day fun main() { Day14RegolithReservoir() } class Day14RegolithReservoir : Solution() { private val rock = '#' private val sand = 'o' private val sandSpout = '+' private val air = ...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
3,404
advent-of-code-2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfArithmeticSlices.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,037
kotlab
Apache License 2.0
src/main/kotlin/File08.kt
andrewrlee
319,095,151
false
null
import Challenge08.Operation.* import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge08 { enum class Operation { acc, jmp, nop } enum class Mode { ALLOW_MODIFY, NO_MODIFY } data class Instruction(val index: Int, val op: Operation, val value: Int) { constructor(...
0
Kotlin
0
0
a9c21a6563f42af7fada3dd2e93bf75a6d7d714c
2,183
adventOfCode2020
MIT License
src/Day01.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
fun main() { fun readCalories(input: List<String>): List<Int> { return input.fold(mutableListOf(mutableListOf<Int>())) { acc, line -> if (line.isBlank()) { acc.add(mutableListOf()) } else { acc.last().add(line.toInt()) ...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
968
advent-of-code-2022
Apache License 2.0
src/day09/Day09_1.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day09 import readInput import kotlin.math.abs fun main() { data class Position(val row: Int, val col: Int) val size = 5000 val middle = size / 2 var head = Position(row = middle, col = middle) var tail = Position(row = middle, col = middle) var answer = 1 val visited = hashSet...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
3,583
aoc-2022-kotlin
Apache License 2.0
src/main/year_2017/day02/day03.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package year_2017.day02 import readInput fun part1(input: List<String>): Int = input.map { line -> line.split(" ").map { it.toInt() }.sortedDescending() }.sumOf { it.first() - it.last() } fun part2(input: List<String>): Int = input.map { line -> line.split(" ").map { it.toInt() }.sortedDescending() }.sumOf {...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
736
aoc-2022
Apache License 2.0
src/Day17.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
private val List<List<Boolean>>.height: Int get() = this.indexOfLast { line -> line.any { it } } data class Block(val data: List<List<Boolean>>) { fun intersects(other: List<List<Boolean>>): Boolean = data.zip(other).any { (firstLine, secondLine) -> firstLine.zip(secondLine).any { (bitFirst, bitSecond)...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
5,791
advent-of-code-kotlin-2022
Apache License 2.0
src/main/Day04.kt
ssiegler
572,678,606
false
{"Kotlin": 76434}
package day04 import utils.readInput fun part1(filename: String): Int = readInput(filename).map(String::pairOfAssignments).count { (first, second) -> second in first || first in second } fun part2(filename: String): Int = readInput(filename).map(String::pairOfAssignments).count(Pair<Assignment, A...
0
Kotlin
0
0
9133485ca742ec16ee4c7f7f2a78410e66f51d80
952
aoc-2022
Apache License 2.0
src/main/kotlin/com/ab/advent/day05/Models.kt
battagliandrea
574,137,910
false
{"Kotlin": 27923}
package com.ab.advent.day05 import java.util.Stack typealias Stacks = List<Stack<Crate>> typealias CrateMover = (src: Stack<Crate>, dst: Stack<Crate>, count: Int) -> Unit data class Movement(val count: Int, val sourceId: Int, val destinationId: Int) data class Crate(val id: Char) class Crane(private val stacks: St...
0
Kotlin
0
0
cb66735eea19a5f37dcd4a31ae64f5b450975005
1,644
Advent-of-Kotlin
Apache License 2.0
letcode/src/main/java/daily/LeetCode309.kt
chengw315
343,265,699
false
null
package daily fun main() { val solution = Solution309() //10 val i8 = solution.maxProfit(intArrayOf(8,6,4,3,3,2,3,5,8,3,8,2,6)) //13 val i7 = solution.maxProfit(intArrayOf(1,7,2,4,11)) //6 val i4 = solution.maxProfit(intArrayOf(3, 3, 5, 0, 0, 3, 1, 4)) //3 val i = solution.maxProfit...
0
Java
0
2
501b881f56aef2b5d9c35b87b5bcfc5386102967
3,340
daily-study
Apache License 2.0
src/main/kotlin/days/aoc2022/Day11.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day class Day11 : Day(2022, 11) { override fun partOne(): Any { return calculateTopTwoMonkeysMonkeyBusinessAfterRounds(inputList, 20, true) } override fun partTwo(): Any { return calculateTopTwoMonkeysMonkeyBusinessAfterRounds(inputList, 10000, false) ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,710
Advent-Of-Code
Creative Commons Zero v1.0 Universal
year2023/day08/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day08/part2/Year2023Day08Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- The sandstorm is upon you and you aren't any closer to escaping the wasteland. You had the camel follow the instructions, but you've barely left your starting position. It's going to take significantly more steps to escape! What if the map isn't for people - what if the map is for ghosts? Are ghos...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,069
AdventOfCode
MIT License
src/main/java/com/gitlab/lae/intellij/jump/Tree.kt
laech
294,076,464
false
{"Kotlin": 17491}
package com.gitlab.lae.intellij.jump data class TreePath<out K>(val keys: List<K>) operator fun <K> TreePath<K>.plus(key: K) = TreePath(keys + key) sealed class Tree<out K, out V> data class TreeLeaf<out V>(val value: V) : Tree<Nothing, V>() { override fun toString() = "TreeLeaf($value)" } data class TreeNode<ou...
0
Kotlin
1
2
a404fe41602e10d161a4b3e990aed92a0b9af95e
1,985
intellij-jump
Apache License 2.0
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/search/candies/MinimumPasses.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.search.candies import java.math.BigDecimal import java.math.BigDecimal.ONE import java.math.BigDecimal.ZERO import java.math.BigDecimal.valueOf import java.math.RoundingMode.CEILING import java.math.RoundingMode.FLOOR import java.util.* fun minimumPass...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
3,428
kotlin-hackerrank
MIT License
java-kotlin/src/main/kotlin/com/example/dataset/CollectionOperations.kt
chubbyhippo
464,697,650
false
{"Kotlin": 20661, "Java": 1634}
package com.example.dataset fun main() { val courseList = courseList() val devPredicate = { c: Course -> c.category == CourseCategory.DEVELOPMENT } exploreFilter(courseList, devPredicate) exploreMap(courseList, devPredicate) val list = listOf(listOf(1, 2, 3), listOf(4, 5, 6)) println(list) ...
0
Kotlin
0
0
d4d6aedc22235eb84684c510759f0f6bac888e0f
2,274
kotlin-tinkering
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SuperPalindromes.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,695
kotlab
Apache License 2.0
src/main/kotlin/day12/Day12.kt
Mee42
433,459,856
false
{"Kotlin": 42703, "Java": 824}
package dev.mee42.day12 import dev.mee42.* import dev.mee42.day9.println typealias Path = List<String> fun main() { val input = input(day = 12, year = 2021).trim().lines() val caves0 = mutableMapOf<String, MutableList<String>>() input.map { val (name, con) = it.split("-") if(caves0[name] =...
0
Kotlin
0
0
db64748abc7ae6a92b4efa8ef864e9bb55a3b741
1,374
aoc-2021
MIT License
src/main/kotlin/day4/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day4 import util.readTestInput data class SectionPair(val first: IntRange, val second: IntRange) // Input etc 2-4,6-8 private val inputRegex = Regex("""(\d+)-(\d+),(\d+)-(\d+)""") fun parseInputToSectionPairs(line: String): SectionPair = inputRegex.matchEntire(line)!! .destructured .let {...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
1,161
advent-of-code-2022
MIT License
src/main/kotlin/net/danlew/wordle/algorithm/KnuthSolver.kt
dlew
446,149,485
false
{"Kotlin": 14254}
package net.danlew.wordle.algorithm import net.danlew.wordle.* /** * Solver based on Knuth's Mastermind algorithm */ class KnuthSolver( /** * The first guess to make lacking any previous guesses. * * If null, it's calculated from scratch (warning: takes hours). */ private val firstGuess: String? ) :...
0
Kotlin
1
12
73f46bf70178ab9aba6cdb6c2d7aadadf6ef7fa0
2,077
wordle-solver
MIT License
src/main/kotlin/g1901_2000/s1981_minimize_the_difference_between_target_and_chosen_elements/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1981_minimize_the_difference_between_target_and_chosen_elements // #Medium #Array #Dynamic_Programming #Matrix // #2023_06_21_Time_588_ms_(100.00%)_Space_44.8_MB_(100.00%) class Solution { fun minimizeTheDifference(mat: Array<IntArray>, target: Int): Int { val m = mat.size val ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,119
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumOfMinutes.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,382
kotlab
Apache License 2.0
src/Day05.kt
mnajborowski
573,619,699
false
{"Kotlin": 7975}
fun main() { val input = readInput("Day05") val stackLabels = input[8] fun prepareStacks(): List<ArrayDeque<Char>> = stackLabels.last { it.isDigit() }.let { finalStackLabel -> ('1'..finalStackLabel).map { label -> ArrayDeque( input.take(8).map { floor...
0
Kotlin
0
0
e54c13bc5229c6cb1504db7e3be29fc9b9c4d386
1,446
advent-of-code-2022
Apache License 2.0
src/Day02.kt
YunxiangHuang
572,333,905
false
{"Kotlin": 20157}
class shap(s: String) { private val mark = { when (s) { "A", "X" -> { "Rock" } "B", "Y" -> { "Paper" } else -> { "Scissors" } } }; private val score = { when (s)...
0
Kotlin
0
0
f62cc39dd4881f4fcf3d7493f23d4d65a7eb6d66
2,230
AoC_2022
Apache License 2.0
src/main/kotlin/g1501_1600/s1579_remove_max_number_of_edges_to_keep_graph_fully_traversable/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1579_remove_max_number_of_edges_to_keep_graph_fully_traversable // #Hard #Graph #Union_Find #2023_06_14_Time_942_ms_(32.52%)_Space_92.5_MB_(100.00%) import java.util.Arrays class Solution { fun maxNumEdgesToRemove(n: Int, edges: Array<IntArray>): Int { Arrays.sort(edges) { a: IntArray...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,329
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/anahoret/aoc2022/day22/CubeSolver.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day22 import com.anahoret.aoc2022.Vector3 import com.anahoret.aoc2022.Vector3Int import com.anahoret.aoc2022.degToRad import java.lang.RuntimeException import kotlin.math.roundToInt import kotlin.math.sqrt class CubeSolver(private val input: String) { fun solve(): List<Int> { ...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
14,871
advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day09.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle import kotlin.math.max import kotlin.math.min import kotlin.random.Random class Day09(input: Input, private val preambleLenght: Int, private val part1Solution: Long) : Puzzle() { pri...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
1,657
adventofcode-kotlin
MIT License
Main.kt
callej
448,166,727
false
{"Kotlin": 2610}
package search import java.io.File const val MENU = "=== Menu ===\n" + "1. Find a person\n" + "2. Print all people\n" + "0. Exit" fun findPerson(people: List<String> ,pIndex: Map<String, Set<Int>>) { println("\nSelect a matching strategy: ALL, ANY, NONE") val strategy = readLine()!!.u...
0
Kotlin
0
0
81f9b14f48e3f8f796875ae84546689a0e550501
2,610
Search-Engine
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day9.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines import kotlin.math.abs object Day9 : Day { override val input = readInputLines(9) .map { line -> line.split(" ").map { it.trim() } } .map { (dir, steps) -> ...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,151
aoc2022
MIT License
src/main/kotlin/g1101_1200/s1178_number_of_valid_words_for_each_puzzle/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1101_1200.s1178_number_of_valid_words_for_each_puzzle // #Hard #Array #String #Hash_Table #Bit_Manipulation #Trie // #2023_05_25_Time_675_ms_(100.00%)_Space_121.2_MB_(100.00%) class Solution { fun findNumOfValidWords(words: Array<String>, puzzles: Array<String>): List<Int> { val ans: MutableList<...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,561
LeetCode-in-Kotlin
MIT License
year2018/src/main/kotlin/net/olegg/aoc/year2018/day15/Day15.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day15 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.get import net.olegg.aoc.utils.set import net.olegg.aoc.year2018.DayOf2018 /** * See [Year 2018, Day 15](https://adventofcode...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
7,348
adventofcode
MIT License
src/test/kotlin/com/igorwojda/string/maxoccurringchar/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.string.maxoccurringchar // Kotlin idiomatic solution private object Solution1 { private fun maxOccurringChar(str: String): Char? { if (str.isBlank()) return null return str.toCharArray() .groupBy { it } .maxBy { it.value.size } .key } }...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
1,337
kotlin-coding-challenges
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/KthSymbolInGrammar.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,721
kotlab
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day18/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day18 import kotlin.math.max import kotlin.math.min fun launchDay18(testCase: String) { val moves = readMoves(testCase) val part1 = solvePart1(moves) println("Day 18, part 1: $part1") // val part2 = solvePart2(moves) // println("Day 18, part 2: $part2") val part2...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
5,762
advent-of-code-2023
MIT License
src/Day03.kt
sebastian-heeschen
572,932,813
false
{"Kotlin": 17461}
fun main() { fun priority(char: Char) = char.code - (if (char.isUpperCase()) ('A'.code - 27) else 'a'.code - 1) fun part1(input: List<String>): Int = input .flatMap { it.chunked(it.length / 2).zipWithNext() } .map { (first, second) -> first.first { second.contain...
0
Kotlin
0
0
4432581c8d9c27852ac217921896d19781f98947
899
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/Complexity/TimeComplexity/TimeComplexity.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
package com.betulnecanli.kotlindatastructuresalgorithms.Complexity.TimeComplexity fun main(){ //For brevity, programmers use a notation known as Big O notation to represent //various magnitudes of time complexity. val list = mutableListOf<String>("a","b","c") checkFirst(list) printNames(list) multiplic...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
4,972
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/y2015/Day20.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import kotlin.math.ceil import kotlin.math.sqrt object Day20 { fun factors(n: Int): List<Int> { return (1..ceil(sqrt(n.toDouble())).toInt()).mapNotNull { if (n % it == 0) listOf(it, n / it) else null }.flatten() } fun part1(input: Int): Int { val target =...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,061
advent-of-code
Apache License 2.0
platform/smRunner/src/com/intellij/execution/testframework/sm/runner/LongLineCutter.kt
JetBrains
2,489,216
false
null
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.testframework.sm.runner import com.intellij.execution.impl.ConsoleBuffer import com.intellij.execution.testframework.sm.ServiceMessageUtil import j...
251
null
5,079
16,158
831d1a4524048aebf64173c1f0b26e04b61c6880
2,677
intellij-community
Apache License 2.0
codechef/snackdown2021/round1a/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codechef.snackdown2021.round1a import kotlin.math.abs private fun solve(): Int { readLn() val a = readInts().sorted() if (a.size == 2) return 0 var ans = minOf(makeEqual(a.drop(1)), makeEqual(a.dropLast(1))).coerceInInt() var i = 1 var j = a.lastIndex - 1 val borders = a[0] + a.last() while (i < j) { ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,106
competitions
The Unlicense
src/Day02.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun part1(input: List<String>): Int = input.sumOf { (it[2] - it[0] - ('X' - 'A') + 4) % 3 * 3 + (it[2] - 'X' + 1) } fun part2(input: List<String>): Int = input.sumOf { (it[2] - 'X') * 3 + (it[0] - 'A' + (it[2] - 'X' - 1) + 3) % 3 + 1 } // test if implementation meets criteria fro...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
547
aockt
Apache License 2.0
src/adventOfCode/day8Problem.kt
cunrein
159,861,371
false
null
package adventOfCode import java.util.* val day8TestData = "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2" fun createTree(data: String): TreeNode<Int> { val parts = data.split(" ") val items = parts.map { it.toInt() }.toMutableList() return createTree(items) } fun createTree(data: MutableList<Int>): TreeNode<Int...
0
Kotlin
0
0
3488ccb200f993a84f1e9302eca3fe3977dbfcd9
33,122
ProblemOfTheDay
Apache License 2.0
2021/src/main/kotlin/day15.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.IntGrid import utils.Solution import utils.Vec2i fun main() { Day15.run() } object Day15 : Solution<IntGrid>() { override val name = "day15" override val parser = IntGrid.singleDigits override fun part1(input: IntGrid): Int { return solve(input) } override fun part2(i...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
960
aoc_kotlin
MIT License
src/main/kotlin/com/hackerrank/ConnectedCellsInAGrid.kt
iluu
94,996,114
false
{"Java": 89400, "Kotlin": 14594, "Scala": 1758, "Haskell": 776}
package com.hackerrank import java.util.* fun main(args: Array<String>) { val scan = Scanner(System.`in`) val n = scan.nextInt() val m = scan.nextInt() val arr = Array(n, { Array(m, { scan.nextInt() }) }) println(sizeOfMaxRegion(Board(arr, n, m))) } fun sizeOfMaxRegion(board: Board): Int { ...
0
Java
3
5
a89b0d332a3d4a257618e9ae6c7f898cb1695246
2,181
algs-progfun
MIT License
src/main/kotlin/days/Day19.kt
vovarova
572,952,098
false
{"Kotlin": 103799}
package days import java.util.* class Day19 : Day(19) { data class Assets(val ore: Int = 0, val clay: Int = 0, val obsidian: Int = 0, val openGeode: Int = 0) { fun isValid(): Boolean { return ore >= 0 && clay >= 0 && obsidian >= 0 && openGeode >= 0 } operator fun plus(other:...
0
Kotlin
0
0
e34e353c7733549146653341e4b1a5e9195fece6
9,077
adventofcode_2022
Creative Commons Zero v1.0 Universal
kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatioTest.kt
SciProgCentre
129,486,382
false
{"Kotlin": 1974351, "ANTLR": 887}
/* * Copyright 2018-2024 KMath contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package space.kscience.kmath.series import space.kscience.kmath.distributions.NormalDistribution import space.kscience.kmath.operations.Float64Field.pow...
91
Kotlin
52
600
83d9e1f0afb3024101a2f90a99b54f2a8b6e4212
2,777
kmath
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day18/Day18Puzzle.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day18 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver import kotlin.math.ceil import kotlin.math.floor abstract class Day18Puzzle : PuzzleSolver { final override fun solve(inputLines: Sequence<String>) = homework(inputLines).toString() ...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
5,139
AdventOfCode2021
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/QGram.kt
aallam
597,692,521
false
null
package com.aallam.similarity import com.aallam.similarity.internal.Profile import com.aallam.similarity.internal.Shingle import kotlin.math.abs /** * Q-gram distance, as defined by Ukkonen in [Approximate string-matching with q-grams and maximal matches](http://www.sciencedirect.com/science/article/pii/030439759290...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
1,599
string-similarity-kotlin
MIT License