path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/dev/shtanko/algorithms/leetcode/DailyTemperatures.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,171
kotlab
Apache License 2.0
src/main/kotlin/days/Day4.kt
hughjdavey
317,575,435
false
null
package days import isIntAndInRange class Day4 : Day(4) { private val passports = inputString.split(Regex("\\W\\n", RegexOption.MULTILINE)).map { Passport(it) } // 213 override fun partOne(): Any { return passports.count { it.hasValidKeys() } } // 147 override fun partTwo(): Any { ...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
2,003
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/WiggleSort.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,608
kotlab
Apache License 2.0
kotlin/src/main/kotlin/adventofcode/day9/Day9_1.kt
thelastnode
160,586,229
false
null
package adventofcode.day8 import java.util.* object Day9_1 { fun process(playerCount: Int, marbleCount: Int): Int { val marbles = ArrayList<Int>(marbleCount + 1) marbles.add(0) val scores = (0 until playerCount).map { 0 }.toMutableList() var currentMarbleIndex = 0 var curr...
0
Kotlin
0
0
8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa
1,628
adventofcode
MIT License
src/main/kotlin/com/colinodell/advent2022/Day17.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import kotlin.math.min class Day17(input: String) { private val jetPattern = input.map { when (it) { '<' -> Vector2(-1, 0) '>' -> Vector2(1, 0) else -> error("Invalid jet pattern") } } private val shapes = listOf( ...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
4,240
advent-2022
MIT License
year2021/src/main/kotlin/net/olegg/aoc/year2021/day19/Day19.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day19 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector3D import net.olegg.aoc.utils.pairs import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 19](https://adventofcode.com/2021/day/19) */ object Day19 : DayOf2021(...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
5,836
adventofcode
MIT License
src/Day21.kt
felldo
572,233,925
false
{"Kotlin": 76496}
import java.lang.Exception import java.lang.Long.max data class Monkeyy(val name: String, val monkey1: String, val monkey2: String, val operation: Char, var output: Long = Long.MIN_VALUE) fun main() { fun recurseMonkeys(monkeyys: MutableList<Monkeyy>, current: String, target: Long): Long { if (current == ...
0
Kotlin
0
0
0ef7ac4f160f484106b19632cd87ee7594cf3d38
5,572
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/adventOfCode2023/Day03.kt
TetraTsunami
726,140,343
false
{"Kotlin": 80024}
package adventOfCode2023 import util.* @Suppress("unused") class Day03(input: String, context: RunContext = RunContext.PROD) : Day(input, context) { override fun solve() { var s1 = 0 var s2 = 0 for ((i, line) in lines.withIndex()) { val symbolsAbove = findSymbols(lines[maxOf(i -...
0
Kotlin
0
0
78d1b5d1c17122fed4f4e0a25fdacf1e62c17bfd
3,168
AdventOfCode2023
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[372]超级次方.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//你的任务是计算 ab 对 1337 取模,a 是一个正整数,b 是一个非常大的正整数且会以数组形式给出。 // // // // 示例 1: // // //输入:a = 2, b = [3] //输出:8 // // // 示例 2: // // //输入:a = 2, b = [1,0] //输出:1024 // // // 示例 3: // // //输入:a = 1, b = [4,3,3,8,5,2] //输出:1 // // // 示例 4: // // //输入:a = 2147483647, b = [2,0,0] //输出:1198 // // // // // 提示: // /...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,278
MyLeetCode
Apache License 2.0
src/aoc22/Day05_Simple.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day05_simple import lib.Collections.headTail import lib.Solution import lib.Strings.ints import lib.Strings.words data class Step(val quantity: Int, val from: Int, val to: Int) data class Input(val cargo: List<ArrayDeque<Char>>, val procedure: List<Step>) ty...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,870
aoc-kotlin
Apache License 2.0
src/aoc2022/Day06.kt
miknatr
576,275,740
false
{"Kotlin": 413403}
package aoc2022 fun main() { fun part1(input: List<String>) = input .filter { it != "" } .map { line -> var lastFour = line.substring(0..3) for (i in 4 until line.length) { if (lastFour.toList().distinct().size == 4) { return@map i ...
0
Kotlin
0
0
400038ce53ff46dc1ff72c92765ed4afdf860e52
1,053
aoc-in-kotlin
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2017/Day1.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2017 import com.chriswk.aoc.util.asInt object Day1 { fun partOne(str: String): Int { val sum = str.fold(Pair('a', 0)) { (lastChar, count), c -> when (lastChar) { c -> Pair(c, count + c.asInt()) else -> Pair(c, count) } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
823
adventofcode
MIT License
aoc-2017/src/main/kotlin/nl/jstege/adventofcode/aoc2017/days/Day25.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2017.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.extractValue /** * * @author <NAME> */ class Day25 : Day(title = "The Halting Problem") { companion object Configuration { private val BEGIN_REGEX = ...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
4,691
AdventOfCode
MIT License
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day04.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 object Day04 { fun numberOfFullyOverlappingPairs(input: String) = firstToSecondSectionRange(input) .count { (firstSectionRange, secondSectionRange) -> firstSectionRange.containsFully(secondSectionRange) || secondSectionRange.contains...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
1,510
advent-of-code
MIT License
src/Day18.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
fun main() { val dayId = "18" val input = readInput("Day${dayId}") val cs = input.map { s -> s.split(",").map { it.toInt() }}.toHashSet() var ans = 0 val mins = List(3) { i -> cs.map { it[i] }.min() } val maxs = List(3) { i -> cs.map { it[i] }.max() } val v = HashMap<List<Int>, Boolean>() ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
1,231
aoc-2022
Apache License 2.0
AdventOfCode/Challenge2023Day05.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.test.assertEquals class Challenge2023Day05 { private fun solve1(lines: List<String>): Long { val seedsLine = lines.first() val seeds = seedsLine.split(":")[1].trim().split(" ").map { it.toLong() to 0 }.toMutableList() var currentMappin...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
6,056
KotlinCodeJourney
MIT License
src/main/kotlin/g2101_2200/s2179_count_good_triplets_in_an_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2179_count_good_triplets_in_an_array // #Hard #Array #Binary_Search #Ordered_Set #Divide_and_Conquer #Segment_Tree #Binary_Indexed_Tree // #Merge_Sort #2023_06_26_Time_563_ms_(100.00%)_Space_62.1_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun goodTriplets(nums1: IntArray, nums2:...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,483
LeetCode-in-Kotlin
MIT License
src/main/kotlin/01-sep.kt
aladine
276,334,792
false
{"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511}
class Solution01Sep { private fun isValid(A: IntArray): Boolean { val hour = 10 * A[0] + A[1] val mins = 10 * A[2] + A[3] return hour < 24 && mins < 60 } fun largestTimeFromDigits(A: IntArray): String { // sort asc A.sort() if (!isValid(A)) return "" ...
0
C++
1
1
54b7f625f6c4828a72629068d78204514937b2a9
2,738
awesome-leetcode
Apache License 2.0
src/main/kotlin/days/Day18.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days class Day18 : Day(18) { override fun runPartOne(lines: List<String>): Any { val numbers = lines.map { SnailFishNumber.parse(it) } return numbers.reduce { acc, n -> val new = acc.add(n) new.reduce() }.magnitude() } override fun runPartTwo(lines: ...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
5,981
aoc2021
Creative Commons Zero v1.0 Universal
2022/src/main/kotlin/Day20.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import kotlin.math.abs object Day20 { fun part1(input: String): Long { val order = input.splitNewlines().mapIndexed { index, s -> Number(index, s.toLong()) } val file = order.toMutableList() mix(order, file) return groveCoordinates(file) } fun part2(input: String): Long { val order = input....
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,361
advent-of-code
MIT License
src/Day01/Day01.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
fun main() { fun part1(input: List<Int>): Int { var res = 0 var last = input[0] for (e in input) { if (e > last) res++ last = e } return res } fun part2(input: List<Int>): Int { var res = 0 for (i in 0 until inp...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
709
advent-of-code-2021
Apache License 2.0
2021/src/day08/Day8KtTest.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day08 import org.junit.jupiter.api.Assertions.* import kotlin.test.Test internal class Day8KtTest { @Test fun testParse() { val input = "be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | " + "fdgacbe cefdb cefbgd gcbe" val parsed = parseLine(input) as...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,129
adventofcode
Apache License 2.0
Yellowstone_sequence/Kotlin/src/main/kotlin/YellowstoneSequence.kt
ncoe
108,064,933
false
{"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409}
fun main() { println("First 30 values in the yellowstone sequence:") println(yellowstoneSequence(30)) } private fun yellowstoneSequence(sequenceCount: Int): List<Int> { val yellowstoneList = mutableListOf(1, 2, 3) var num = 4 val notYellowstoneList = mutableListOf<Int>() var yellowSize = 3 ...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
1,445
rosetta
MIT License
app/src/main/kotlin/com/bloidonia/advent2020/Day_13.kt
timyates
317,965,519
false
null
package com.bloidonia.advent2020 import com.bloidonia.linesFromResource class Day_13(val now: Long, val busses: String) { companion object { // Lowest common multiple calculations (thanks to Google) fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y) fun lcm(x: Long, y: Lo...
0
Kotlin
0
0
cab3c65ac33ac61aab63a1081c31a16ac54e4fcd
2,016
advent-of-code-2020-kotlin
Apache License 2.0
src/main/resources/CucumberFeatureReport.kt
joshdur
120,290,788
false
null
package {OUTPUT_PACKAGE} private const val PASSED = "passed" private const val FAILED = "failed" private const val IGNORED = "ignored" private const val FEATURE = "Feature" private const val SCENARIO = "Scenario" private const val DEFAULT_LOCATION = "location" private const val DEFAULT_LINE = 0 private const val DE...
0
Kotlin
0
1
139edd1f0492dc880b448e00d63d193d19b2eda1
3,201
GherkPlugin
Apache License 2.0
src/main/kotlin/g0801_0900/s0862_shortest_subarray_with_sum_at_least_k/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0862_shortest_subarray_with_sum_at_least_k // #Hard #Array #Binary_Search #Heap_Priority_Queue #Prefix_Sum #Sliding_Window #Queue // #Monotonic_Queue #2023_04_04_Time_563_ms_(84.62%)_Space_51.6_MB_(38.46%) import java.util.Deque import java.util.LinkedList class Solution { internal class Pair...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,213
LeetCode-in-Kotlin
MIT License
LeetCode/Easy/intersection-of-two-arrays/Solution.kt
GregoryHo
254,657,102
false
null
class Solution { fun intersection(nums1: IntArray, nums2: IntArray): IntArray { val answer = mutableListOf<Int>() val set1 = nums1.toHashSet().sortedWith(Comparator { o1, o2 -> when { o1 < o2 -> -1 o1 == o2 -> 0 else -> 1 } }) val set2 = nums2.toHashSet().sorted...
0
Kotlin
0
0
8f126ffdf75aa83a6d60689e0b6fcc966a173c70
994
coding-fun
MIT License
src/main/kotlin/day17/Day17.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day17 private val target = Area(60..94, -171..-136) fun main() { var globalMax = 0 var velocitiesCount = 0 for (x in 0..100) { for (y in -200..200) { val maxY = findMaxY(Velocity(Point(x, y))) if (maxY != null) { if (maxY > globalMax) globalMax = m...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
1,326
aoc2021
Apache License 2.0
src/main/kotlin/g2901_3000/s2935_maximum_strong_pair_xor_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2935_maximum_strong_pair_xor_ii // #Hard #Array #Hash_Table #Bit_Manipulation #Sliding_Window #Trie // #2024_01_03_Time_748_ms_(84.38%)_Space_63.6_MB_(59.38%) import java.util.BitSet class Solution { private val map = IntArray(1 shl 20) fun maximumStrongPairXor(nums: IntArray): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,291
LeetCode-in-Kotlin
MIT License
src/main/kotlin/io/tree/ConvertSortedArrayIntoBinaryTreeSearch.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.tree import io.models.TreeNode import io.utils.runTests // https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ class ConvertSortedArrayIntoBinaryTreeSearch { fun execute( input: IntArray, leftBoundary: Int = 0, rightBoundary: Int = input.lastIndex): TreeNode? = wh...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,610
coding
MIT License
src/Day06.kt
jamesrobert
573,249,440
false
{"Kotlin": 13069}
fun main() { fun String.hasUniqueChars(): Boolean { for (i in indices) if (substring(i + 1).contains(this[i])) return false return true } fun String.indexAfterFirstNUnique(n: Int): Int { for (i in indices) if (substring(i, i + n).hasUniqueChars()) return i + ...
0
Kotlin
0
0
d0b49770fc313ae42d802489ec757717033a8fda
1,295
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day16_packet_decoder/PacketDecoder.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day16_packet_decoder import util.CountingIterator import util.countingIterator /** * Binary things again! "One or more sub-packets" means recursion. Lots of * bookkeeping. But a simple question: find all the version numbers and sum. * Nailing the parsing is key, since the input data looks like an optimized...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
3,842
aoc-2021
MIT License
LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/FourSum.kt
ani03sha
297,402,125
false
null
package org.redquark.tutorials.leetcode import java.util.* import kotlin.collections.ArrayList fun fourSum(nums: IntArray, target: Int): List<List<Int>> { // Resultant list val quadruplets: MutableList<List<Int>> = ArrayList() // Base condition if (nums.size < 4) { return quadruplets } ...
2
Java
40
64
67b6ebaf56ec1878289f22a0324c28b077bcd59c
2,048
RedQuarkTutorials
MIT License
src/Day01.kt
k3vonk
573,555,443
false
{"Kotlin": 17347}
fun main() { fun part1(input: List<String>): Int { var highestCalories = 0 var currentCalories = 0 for (row in input) { if (row.isEmpty()) { if (currentCalories > highestCalories) highestCalories = currentCalories currentCalori...
0
Kotlin
0
1
68a42c5b8d67442524b40c0ce2e132898683da61
989
AOC-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/Main.kt
snikiforov4
485,917,499
false
{"Kotlin": 9895}
package processor import java.text.DecimalFormat private val regexp = "\\s+".toRegex() var decimalFormat = DecimalFormat("#0.##") fun main() { while (true) { printMenu() print("Your choice: ") when (readln().toInt()) { 0 -> break 1 -> { val m1 = re...
0
Kotlin
0
0
ace36ad30c0a2024966744792a45e98b3358e10d
5,143
numeric-matrix-processor
Apache License 2.0
aoc_2023/src/main/kotlin/problems/day19/part1/PartsSorter.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day19.part1 class PartsSorter(lines: List<String>) { val workflows: Map<String, PartWorkflow> val parts: List<Part> init { val workflowLines = lines.takeWhile { it.isNotEmpty() } val workflowRegex = Regex("""(\w+)\{(.*)\}""") val innerWorkflowRegex = Regex("""(\...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
2,087
advent-of-code-2023
MIT License
src/main/kotlin/abc/229-e.kt
kirimin
197,707,422
false
null
package abc import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val m = sc.nextInt() val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() } println(problem229e(n, m, ab)) } fun problem229e(n: Int, m: Int, ab: List<Pair<Int, Int>>): St...
0
Kotlin
1
5
23c9b35da486d98ab80cc56fad9adf609c41a446
1,656
AtCoderLog
The Unlicense
Shortest_Unsorted_Continuous_Subarray_v2.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import java.util.* // https://leetcode.com/problems/shortest-unsorted-continuous-subarray/solution/#approach-4-using-stack // We need to determine the correct position of the minimum and the maximum element // in the unsorted subarray to determine the boundaries of the required unsorted subarray. class Solution { ...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,467
leetcode
MIT License
src/aoc2022/Day03.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList import utils.alphaToInt fun main() { fun part1(input : List<String>) : Int { var sum = 0 for(rucksack in input) { val first = rucksack.substring(0, rucksack.length / 2) val second = rucksack.substring(rucksack.length / 2) ...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
1,397
AOC-2022-Kotlin
Apache License 2.0
src/main/kotlin/math/Vec3.kt
spookyGh0st
197,557,690
false
null
package math import kotlin.math.sqrt data class Vec3(var x: Double = 0.0, var y: Double = 0.0, var z: Double = 0.0){ constructor(x: Number, y: Number, z: Number): this(x.toDouble(), y.toDouble(), z.toDouble()) val length get() = sqrt(x * x + y * y + z * z) /** * Normalise the vector to length 1 ...
3
Kotlin
9
19
0ba55cb3d9abb3a9e57e8cef6c7eb0234c4f116a
2,011
beatwalls
MIT License
src/day3.kt
SerggioC
573,171,085
false
{"Kotlin": 8824}
fun main() { val input: List<String> = readInput("day3") var total = 0 input.forEach { val input2: List<String> = it.chunked(it.length / 2) val left = input2.get(0) val right = input2.get(1) val result: Char = left.first { right.contains(it) } pri...
0
Kotlin
0
0
d56fb119196e2617868c248ae48dcde315e5a0b3
962
aoc-2022
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/CommonUtils.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph import ai.hypergraph.kaliningraph.sampling.randomVector import ai.hypergraph.kaliningraph.tensor.* import ai.hypergraph.kaliningraph.types.* import kotlin.math.* import kotlin.random.* import kotlin.reflect.KClass fun <T, R : Ring<T>, M : Matrix<T, R, M>> Matrix<T, R, M>.elwise(op: ...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
4,389
galoisenne
Apache License 2.0
src/Day02.kt
ixtryl
575,312,836
false
null
import java.lang.IllegalArgumentException import java.lang.RuntimeException enum class TOKEN(val value: Int) { ROCK(1), SCISSORS(2), PAPER(3) } fun matchPoints(player: TOKEN, opponent: TOKEN): Int { when { player == TOKEN.ROCK && opponent == TOKEN.SCISSORS || player == TOKEN.PAPER && o...
0
Kotlin
0
0
78fa5f6f85bebe085a26333e3f4d0888e510689c
1,633
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/co/csadev/advent2022/Day19.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 19 * Problem Description: http://adventofcode.com/2021/day/19 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsList import co.csadev.adventOfCode.product import kotlin.math.max clas...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,747
advent-of-kotlin
Apache License 2.0
src/Day03.kt
calindumitru
574,154,951
false
{"Kotlin": 20625}
fun main() { val part1 = Implementation("Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types?", 157) { lines -> val sum = lines.map { it.chunked(it.length / 2) } .map { twoChunks -> (twoChunks.get(0).toCharSet() to ...
0
Kotlin
0
0
d3cd7ff5badd1dca2fe4db293da33856832e7e83
1,228
advent-of-code-2022
Apache License 2.0
src/main/aoc2018/Day25.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 import kotlin.math.abs class Day25(input: List<String>) { data class Point(val coord: List<Int>) { fun distanceTo(other: Point): Int { return coord.zip(other.coord).sumOf { abs(it.first - it.second) } } } private val points = parseInput(input) private fun...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,373
aoc
MIT License
src/Day01.kt
acrab
573,191,416
false
{"Kotlin": 52968}
import com.google.common.truth.Truth.assertThat fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 for (line in input) { if (line.isEmpty()) { if (current > max) { max = current } cur...
0
Kotlin
0
0
0be1409ceea72963f596e702327c5a875aca305c
1,280
aoc-2022
Apache License 2.0
src/main/kotlin/dev/dakoda/dvr/skills/Skills.kt
vanilla-refresh
707,433,202
false
{"Kotlin": 116265, "Java": 31150}
package dev.dakoda.dvr.skills import dev.dakoda.dvr.skills.exp.data.EXPGain class Skills( val values: MutableMap<Skill, EXP> = mutableMapOf() ) { fun increase(inc: Int, subSkill: Skill.Sub) = increase(inc, subSkill as Skill) fun increase(gain: EXPGain) = increase(gain.amount, gain.skill) fun increas...
0
Kotlin
0
0
89680960c244f892f7859ee5edfd5e7136860534
2,907
dvr-skills
MIT License
src/main/kotlin/com/manalili/advent/Day03.kt
maines-pet
162,116,190
false
null
package com.manalili.advent typealias Coordinates = Pair<Int, Int> class Day03(input: List<String>) { val claims = input.map { Claim.destructureClaim(it) } var singleClaimedSections: Set<Coordinates>? = null fun overlapSection(): Int{ val sections: MutableMap<Coordinates, Int> = mutableMapOf() ...
0
Kotlin
0
0
25a01e13b0e3374c4abb6d00cd9b8d7873ea6c25
1,553
adventOfCode2018
MIT License
src/main/kotlin/com/github/rloic/quadinsa5if/findindandqueryingtext/service/implementation/FaginSolverImp.kt
Quad-INSA-5IF
150,790,729
false
{"Java": 94105, "Kotlin": 33850, "Batchfile": 251, "Shell": 183}
package com.github.rloic.quadinsa5if.findindandqueryingtext.service.implementation import com.github.quadinsa5if.findingandqueryingtext.lang.Iter import com.github.quadinsa5if.findingandqueryingtext.model.Entry import com.github.quadinsa5if.findingandqueryingtext.model.vocabulary.Vocabulary import com.github.quadinsa5...
0
Java
1
0
4d2fd34e3e0637f041fbc4b1fbfc9c565a3100aa
3,678
finding-and-querying-text
MIT License
src/src/main/kotlin/sort/quicksort/QuickSort.kt
Akardian
406,427,845
false
{"Kotlin": 10155}
/** * This Class Implements the sorting algorithm Bubble Sort */ package sort.quicksort import sort.Sort abstract class QuickSort<T> : Sort<T> { constructor(_array: Array<T>) : super(_array){ } override fun sort() { quicksort(lowIndex = 0, highIndex = size - 1) } private fun quicksort(lowI...
0
Kotlin
0
0
b3557400236e904b8f443c5a43ed90d99a712d4c
1,976
Kotlin-Sorting
MIT License
src/Day03.kt
theofarris27
574,591,163
false
null
fun main() { fun part1(input: List<String>): Int { var sum = 0; for (line in input) { var half1 = line.substring(0, line.length / 2) var half2 = line.substring(line.length / 2) for (letters in half1) { if (half2.contains(letters)) { ...
0
Kotlin
0
0
cf77115471a7f1caeedf13ae7a5cdcbdcec3eab7
6,432
AdventOfCode
Apache License 2.0
src/main/kotlin/days/Day13.kt
hughjdavey
225,440,374
false
null
package days import common.IntcodeComputer import common.stackOf class Day13 : Day(13) { private fun program() = inputString.split(",").map { it.trim().toLong() }.toMutableList() override fun partOne(): Any { val arcadeCabinet = ArcadeCabinet(program()) return arcadeCabinet.runGame().count {...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
2,279
aoc-2019
Creative Commons Zero v1.0 Universal
15.kts
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
val steps = System.`in`.bufferedReader().readLine().split(',') fun hash(s: String): Int { var result = 0 for (c in s) { result += c.code; result *= 17; result %= 256 } return result } val boxes = ArrayList<ArrayList<Pair<String, Int>>>() for (i in 0..255) boxes.add(ArrayList()) for (step in steps) { if ...
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
960
aoc2023
MIT License
common/number/src/main/kotlin/com/curtislb/adventofcode/common/number/Primes.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.common.number /** * Finds the unique prime factorization of the natural number [n]. * * Returns a map from each prime factor of [n] to that factor's corresponding power in the prime * factorization of [n]. If [n] is 1, this function instead returns an empty map. * * @throws Ille...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,422
AdventOfCode
MIT License
src/day01/Day01.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day01 import utils.* fun getElvesCalories(input: List<String>): List<Int> = (input + listOf("")).fold(Pair(listOf<Int>(), 0)) { (cals, n), line -> if (line.isEmpty()) Pair(cals + listOf(n), 0) else Pair(cals, n + line.toInt()) }.first fun part1(input: List<Stri...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
689
AOC-2022-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ContainsDuplicate.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,248
kotlab
Apache License 2.0
src/main/kotlin/ru/itmo/ctlab/gmwcs/solver/preprocessing/Dijkstra.kt
ctlab
290,164,889
false
{"Java": 250115, "Kotlin": 21543}
package ru.itmo.ctlab.gmwcs.solver.preprocessing import ru.itmo.ctlab.virgo.gmwcs.graph.Edge import ru.itmo.ctlab.virgo.gmwcs.graph.Elem import ru.itmo.ctlab.virgo.gmwcs.graph.Node import ru.itmo.ctlab.virgo.gmwcs.graph.Graph import java.util.* import kotlin.math.abs /** * Created by <NAME> on 04/10/2017. */ class...
0
Java
0
3
f561bdce02f43b7c58cd5334896c2aec513bda15
2,750
virgo-solver
Apache License 2.0
src/Day23.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun print(elves: Set<Coordinates>) { // for(row in elves.minOf { it.row } .. elves.maxOf { it.row }) { // for(col in elves.minOf { it.col } .. elves.maxOf { it.col }) { for(row in -2 .. 9) { for(col in -3 .. 10) { if (elves.contains(Coordinates(row,...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
4,410
aoc2022
Apache License 2.0
quantum/src/main/kotlin/me/khol/quantum/gate/PermutationGates.kt
Antimonit
210,850,479
false
null
package me.khol.quantum.gate import me.khol.quantum.util.WeakCache import me.khol.quantum.math.Complex import me.khol.quantum.math.Matrix typealias Permutation = List<Int> /** * Reorders input and output qubits of [this] gate. * * This is most useful when we need to use some kind of a controlled gate where the co...
0
Kotlin
1
12
97975ba74728ee7a71f96d12a80282ed38890148
1,828
Quantum
Apache License 2.0
src/main/kotlin/com/ikueb/advent18/Day25.kt
h-j-k
159,901,179
false
null
package com.ikueb.advent18 import java.util.* object Day25 { private const val DEFINITION = "([-\\d ]+),([-\\d ]+),([-\\d ]+),([-\\d ]+)" fun getConstellations(input: List<String>) = with( input.parseWith(DEFINITION) { (a, b, c, d) -> Point4d(a.trimInt(), b.trimInt(), c.trimInt()...
0
Kotlin
0
0
f1d5c58777968e37e81e61a8ed972dc24b30ac76
1,580
advent18
Apache License 2.0
src/Day06.kt
rickbijkerk
572,911,701
false
{"Kotlin": 31571}
fun main() { fun part1(input: List<String>): Int { val line = input.first() val result = (0..line.length - 4).first { index -> line.substring(index, index + 4).toSet().size == 4 } return result + 4 } fun part2(input: List<String>): Int { val line = inp...
0
Kotlin
0
0
817a6348486c8865dbe2f1acf5e87e9403ef42fe
1,141
aoc-2022
Apache License 2.0
src/test/kotlin/aoc/Day3.kt
Lea369
728,236,141
false
{"Kotlin": 36118}
package aoc import org.junit.jupiter.api.Nested import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Collectors import kotlin.test.Test import kotlin.test.assertEquals class Day3 { @Nested internal inner class Day3Test { private val day3: Day3 = Day3() @Test ...
0
Kotlin
0
0
1874184df87d7e494c0ff787ea187ea3566fbfbb
4,046
AoC
Apache License 2.0
src/Day02/Day02.kt
SelenaChen123
573,253,480
false
{"Kotlin": 14884}
import java.io.File fun main() { fun part1(input: List<String>): Int { var points = 0 for (line in input) { val them = line.split(" ")[0] val you = line.split(" ")[1] val theirValue = when (them) { "A" -> 1 ...
0
Kotlin
0
0
551af4f0efe11744f918d1ff5bb2259e34c5ecd3
2,208
AdventOfCode2022
Apache License 2.0
kmath-stat/src/commonMain/kotlin/space/kscience/kmath/optimization/FunctionOptimization.kt
therealansh
373,284,570
true
{"Kotlin": 1071813, "ANTLR": 887}
/* * Copyright 2018-2021 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.optimization import space.kscience.kmath.expressions.AutoDiffProcessor import space.kscience.kmath.expressions.Differentiab...
0
null
0
0
4065466be339017780b0ac4b98a9eda2cc2378e4
3,393
kmath
Apache License 2.0
exercises/src/test/kotlin/solutions/chapter5/SolutionTest.kt
rmolinamir
705,132,794
false
{"Kotlin": 690308, "HTML": 34654, "CSS": 1900, "Shell": 593}
package solutions.chapter5 import org.junit.jupiter.api.Test import strikt.api.expectThat import strikt.assertions.isEqualTo class E1SolutionTest { @Test fun `collatzR returns the correct sequence`() { expectThat(13.collatz()).isEqualTo(listOf(13, 40, 20, 10, 5, 16, 8, 4, 2, 1)) expectThat(8.collatz()).isEqual...
0
Kotlin
0
0
ccfed75476263e780c5a8c61e02178532cc9f3f4
1,835
fotf
MIT License
jetbrains-core/src/software/aws/toolkits/jetbrains/core/tools/Versions.kt
aws
91,485,909
false
{"Kotlin": 6503168, "C#": 96334, "TypeScript": 84848, "Java": 20765, "JavaScript": 8806, "Shell": 2920, "Dockerfile": 2209, "SCSS": 242, "Batchfile": 77}
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package software.aws.toolkits.jetbrains.core.tools /** * Top level interface for different versioning schemes such as semantic version */ interface Version : Comparable<Version> { /** * @return...
405
Kotlin
184
719
8a8ba8859d3b711b1a90a357913adb9bb920ca26
1,295
aws-toolkit-jetbrains
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/day3/Day3.kt
jacobhyphenated
572,119,677
false
{"Kotlin": 157591}
package com.jacobhyphenated.day3 import com.jacobhyphenated.Day import java.io.File import kotlin.math.absoluteValue // Crossed Wires class Day3: Day<Pair<List<String>, List<String>>> { override fun getInput(): Pair<List<String>, List<String>> { val lines = this.javaClass.classLoader.getResource("day3/inp...
0
Kotlin
0
0
1a0b9cb6e9a11750c5b3b5a9e6b3d63649bf78e4
2,638
advent2019
The Unlicense
src/Day10.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
fun main() { data class CycleState( val crtGeneration: Boolean, var cycle: Int = 0, var regX: Int = 1, var rayPosition: Int = 0, var signalSum: Int = 0, var crtImage: MutableList<Char> = mutableListOf() ) { fun processInstruction(instruction: String): Cycl...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
1,607
advent-of-code-2022-kt
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem640/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem640 /** * LeetCode page: [640. Solve the Equation](https://leetcode.com/problems/solve-the-equation/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) where N is the length of equation; */ fun solveEquation(equation: String): String { val ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,246
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/Day3.kt
clechasseur
264,758,910
false
null
import org.clechasseur.adventofcode2017.Direction import org.clechasseur.adventofcode2017.Pt import org.clechasseur.adventofcode2017.manhattan object Day3 { private const val input = 368078 private val allAround = listOf( Pt(-1, -1), Pt(-1, 0), Pt(-1, 1), Pt(0, -1), Pt(0, 1), Pt(1, -1)...
0
Kotlin
0
0
f3e8840700e4c71e59d34fb22850f152f4e6e739
1,370
adventofcode2017
MIT License
Lab 4/src/main/kotlin/Tree2D.kt
knu-3-tochanenko
273,874,096
false
null
import kotlin.math.pow class Tree2D { companion object { private var result = mutableListOf<Dot>() fun calculate(dots: List<Dot>, rectangle: Rectangle): List<Dot> { val root = buildTree(dots) findDotsInRectangle(root, rectangle) return result } ...
0
Kotlin
0
0
d33c5e03ccec496ffa6400c7824780886a46b1ba
3,578
ComputerGraphics
MIT License
modulo4/src/aula14/Exercicio08.kt
ProgramaCatalisa
491,134,850
false
{"Kotlin": 80614}
package aula14 /*Exercício 04 da parte 'Exercícios gerais'*/ fun main() { print("Informe a quantidade de alunes a turma tem: ") val quantidadeAlunos = readln().toInt() val turma = receberDadosAlune(quantidadeAlunos) val medias = calcularMedia(quantidadeAlunos, turma) printarMedias(turma, medias) ...
0
Kotlin
0
0
e0b994cd6b173da0f791fd3cb2eca96316cb6a6d
1,393
ResolucaoExerciciosKotlin
Apache License 2.0
src/main/kotlin/aoc2022/Day02.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.parser.* import aoc.parser.Parsers.eol class Day02() { enum class Item(val name1: String, val name2: String, val score: Int) { ROCK("A", "X", 1), PAPER("B", "Y", 2), SCISSOR("C", "Z", 3), } enum class Result(val name1: String, val score: Int) { L...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
1,491
aoc-kotlin
Apache License 2.0
src/main/kotlin/endredeak/aoc2022/Day09.kt
edeak
571,891,076
false
{"Kotlin": 44975}
package endredeak.aoc2022 import kotlin.math.absoluteValue import kotlin.math.sign fun main() { solve("Rope Bridge") { val input = lines .map { it.split(" ") } .map { (d, a) -> d to a.toInt() } operator fun Pair<Int, Int>.plus(p: Pair<Int, Int>) = this.first + p.first to t...
0
Kotlin
0
0
e0b95e35c98b15d2b479b28f8548d8c8ac457e3a
1,675
AdventOfCode2022
Do What The F*ck You Want To Public License
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day12/Day12Puzzle2.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day12 class Day12Puzzle2 : Day12Puzzle() { override fun countWaysThroughCaves(caveConnections: Map<Cave, Set<Cave>>) = caveConnections.keys .filterIsInstance<Cave.SmallCave>() .minus(setOf(START, END)) .flatMap { waysThroughCaves(caveC...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
1,479
AdventOfCode2021
Apache License 2.0
src/Day01.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
import utils.readInputAsLines fun main() { fun part1(input: List<String>): Int { val elves = buildElfList(input) return elves.maxOf { it.sum() } } fun part2(input: List<String>): Int { val elves = buildElfList(input) return elves.map { it.sum() }.sorted().takeLast(3).sum() ...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
946
2022-AOC-Kotlin
Apache License 2.0
src/main/kotlin/File09.kt
andrewrlee
319,095,151
false
null
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge09 { val numbers = File("src/main/resources/09-input.txt").readLines(UTF_8).map { it.toLong() } fun <A, B> cartesianProduct(listA: Iterable<A>, listB: Iterable<B>): Sequence<Pair<A, B>> = sequence { list...
0
Kotlin
0
0
a9c21a6563f42af7fada3dd2e93bf75a6d7d714c
1,417
adventOfCode2020
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem109/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem109 import com.hj.leetcode.kotlin.common.model.ListNode import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [109. Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/); */ class Solution2 { ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,887
hj-leetcode-kotlin
Apache License 2.0
17/kotlin/src/main/kotlin/se/nyquist/Main.kt
erinyq712
437,223,266
false
{"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098}
package se.nyquist import java.io.File import kotlin.math.absoluteValue fun readRange(input: String): IntRange { val xCoordStr = input.split("..") return IntRange(xCoordStr[0].toInt(), xCoordStr[1].toInt()) } fun main() { val ranges = readInput("input.txt") val targetArea = TargetArea(ranges) val...
0
Kotlin
0
0
b463e53f5cd503fe291df692618ef5a30673ac6f
2,334
adventofcode2021
Apache License 2.0
src/hard/_212WordSearchII.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package hard class _212WordSearchII { class Solution { var dirs = arrayOf(intArrayOf(1, 0), intArrayOf(-1, 0), intArrayOf(0, 1), intArrayOf(0, -1)) fun findWords(board: Array<CharArray>, words: Array<String>): List<String> { val trie = Trie() for (word in words) { ...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
1,802
AlgorithmsProject
Apache License 2.0
src/main/kotlin/d16/D16.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d16 enum class Direction { LEFT, RIGHT, BELOW, ABOVE } data class Tile( val content: Char, var energized: Boolean = false, val incomingLightDirections: MutableList<Direction> = mutableListOf() ) fun move(contraption: List<List<Tile>>, row: Int, col: Int, from: Direction) { if ...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
2,989
aoc2023-kotlin
MIT License
src/main/kotlin/Model.kt
thomasnield
150,822,564
false
null
import koma.pow import org.apache.commons.math3.distribution.TDistribution import org.nield.kotlinstatistics.sum import org.nield.kotlinstatistics.weightedCoinFlip import java.math.MathContext import java.math.RoundingMode import kotlin.math.exp enum class Solver { ORDINARY_LEAST_SQUARES { // great refe...
0
Kotlin
2
5
26f92910c8528f13caae1477dd2be0af45124b28
11,587
kotlin_linear_regression
Apache License 2.0
2022/src/main/kotlin/Day25.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import kotlin.math.pow object Day25 { fun part1(input: String) = numToSnafu(input.splitNewlines().sumOf(::snafuToNum)) private fun snafuToNum(snafu: String): Long { return snafu .reversed() .withIndex() .sumOf { (index, char) -> 5.0.pow(index).toLong() * snafuCharToNum(char) }...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,040
advent-of-code
MIT License
src/main/kotlin/aoc2018/day10/PointsInTheSky.kt
arnab
75,525,311
false
null
package aoc2018.day10 data class Point(val x: Int, val y: Int, val vX: Int, val vY: Int) { companion object { // Matches "position=< 9, 1> velocity=< 0, 2>" private val dataLineRegex = """position=<\s*(-?\d+),\s*(-?\d+)> velocity=<\s*(-?\d+),\s*(-?\d+)>""".toRegex() fun from(data: Stri...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,048
adventofcode
MIT License
src/main/kotlin/ctci/chaptersixteen/ContiguousSequence.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chaptersixteen // 16.17 - page 183 // You are given an array of integers (both positive and negative). Find the contiguous sequence with the largest // sum. Return the sum. fun main() { val arr1 = intArrayOf(1, -2, 3, 10, -4, 7, 2, -5) val arr2 = intArrayOf(-2, -3, 4, -1, -2, 1, 5, -3) val ar...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
1,274
dsa-kotlin
MIT License
archive/406/solve.kt
daniellionel01
435,306,139
false
null
/* === #406 Guessing Game - Project Euler === We are trying to find a hidden number selected from the set of integers {1, 2, ..., n} by asking questions. Each number (question) we ask, we get one of three possible answers: "Your guess is lower than the hidden number" (and you incur a cost of a), or "Your guess is hi...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
2,080
euler
MIT License
src/main/java/Exercise20.kt
cortinico
317,667,457
false
null
fun main() { val tiles = object {}.javaClass.getResource("input-20.txt").readText().split("\n\n").map { val number = it.split("\n")[0].replace(":", "").replace("Tile ", "").toLong() val top = it.split("\n")[1] val bottom = it.split("\n").last() val (left, righ...
1
Kotlin
0
4
a0d980a6253ec210433e2688cfc6df35104aa9df
3,773
adventofcode-2020
MIT License
src/Day06.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
fun main() { fun searchForMarker(buffer: String, markerLength: Int): Int { val lettersCount = mutableMapOf<Char, Int>() for (i in buffer.indices) { if (i >= markerLength) { val letterToRemove = buffer[i - markerLength] if (lettersCount[letterToRemove] == 1...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
1,169
adventofcode2022
Apache License 2.0
src/main/kotlin/solutions/constantTime/iteration2/BoundedMemorizedTaxCalculator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package solutions.constantTime.iteration2 import dataModel.base.Money import dataModel.base.Money.Companion.cents import dataModel.base.TaxBracket import dataModel.base.TaxCalculator import solutions.constantTime.iteration1.MemorizedTaxCalculator import solutions.logN.LogNTaxCalculator import dataModel.v2.toAccumulate...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
1,768
tax-calculator
MIT License
src/commonTest/kotlin/io/github/arashiyama11/PolynomialTest.kt
arashiyama11
581,833,835
false
{"Kotlin": 69471}
package io.github.arashiyama11 import kotlin.test.Test import kotlin.test.assertEquals class PolynomialTest { @Test fun parseAndToStringTest() { assert(Polynomial("1 + 5 * 2 - 8 / 2"), "1+10-4") assert(Polynomial("1.2+5.4-3.2/2"), "6/5+27/5-8/5") assert(Polynomial("2x^2-5x+ 3x -1"), "2x^2-5x+3x-1") ...
0
Kotlin
0
0
c3832fb4248060b55d2a0528ece479ac799002d8
6,269
mojishiki
MIT License
src/main/java/com/barneyb/aoc/aoc2022/day15/BeaconExclusionZone.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day15 import com.barneyb.aoc.util.* import com.barneyb.util.HashSet import com.barneyb.util.Rect import com.barneyb.util.Vec2 import kotlin.math.abs import kotlin.math.max import kotlin.text.toInt fun main() { Solver.execute( ::parse, ::countNonBeaconPositionsOnRow,...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
6,591
aoc-2022
MIT License
src/main/kotlin/be/tabs_spaces/advent2021/days/Day06.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days class Day06 : Day(6) { companion object { private const val HAS_SPAWNED = 6 } private val numberOfFishByAge = groupFishByAge() override fun partOne() = iterateSpawnCycle(numberOfFishByAge, 80).values.sum() override fun partTwo() = iterateSpawnCycle...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
1,499
advent-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/colinodell/advent2016/Day14.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day14(private val salt: String) { fun solvePart1(): Int = solve(0) fun solvePart2(): Int = solve(2016) private fun solve(stretchFactor: Int) = generateHashes(1, stretchFactor) .map { PossibleKey(it, findTripleDigit(it.hash)) } .filter...
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
1,775
advent-2016
Apache License 2.0
src/Day10.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
fun main() { fun part1(input: List<String>): Int { var registerX = 1 var instructionPointer = 0 var instructionCyclesLeftToComplete = 0 var cycle = 0 var signalStrenghtSum = 0 while (instructionPointer < input.size) { cycle++ val instruction ...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
2,579
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/com/resurtm/aoc2023/day19/Parse.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day19 internal fun readInput(testCase: String): Input { val reader = object {}.javaClass.getResourceAsStream(testCase)?.bufferedReader() ?: throw Exception("Cannot read an input, probably an invalid input provided") val rules = mutableMapOf<String, Rule>() v...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
2,108
advent-of-code-2023
MIT License
facebook/y2019/round1/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2019.round1 private const val INF = Int.MAX_VALUE / 3 private fun solve(): String { val (n, m) = readInts() val edgesInput = List(m) { readInts() } val graph = Array(n) { IntArray(n) { INF } } for ((aInput, bInput, d) in edgesInput) { val a = aInput - 1 val b = bInput - 1 graph[a][b] = d ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,318
competitions
The Unlicense
src/main/kotlin/wk269/Problem2.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package wk269 // fun main() { val result = Problem2().getAverages(intArrayOf(7, 4, 3, 9, 1, 8, 5, 2, 6), 3) // val result = Problem2().getAverages(intArr, 10) println(result) } class Problem2 { fun getAverages(nums: IntArray, k: Int): IntArray { if (k * 2 > nums.size - 1) return IntArray(nums.s...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
1,047
leetcode-kotlin
MIT License
core/compiler.common/src/org/jetbrains/kotlin/contracts/description/EventOccurrencesRange.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.contracts.description import kotlin.math.max import kotlin.math.min enum class ...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
2,326
kotlin
Apache License 2.0
src/main/kotlin/de/tek/adventofcode/y2022/day14/RegolithReservoir.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day14 import de.tek.adventofcode.y2022.util.math.* import de.tek.adventofcode.y2022.util.readInputLines enum class Material(private val visualization: Char) { AIR('.'), SAND('o'), ROCK('#'); override fun toString() = visualization.toString() } class Cave(private val sandSou...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
5,750
advent-of-code-2022
Apache License 2.0