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/math/Vec4.kt | spookyGh0st | 197,557,690 | false | null | package math
import kotlin.math.sqrt
data class Vec4(var x: Double = 0.0, var y: Double = 0.0, var z: Double = 0.0,var w: Double = 0.0){
constructor(x: Number, y: Number, z: Number, t: Number): this(x.toDouble(), y.toDouble(), z.toDouble(), t.toDouble())
val length
get() = sqrt(x * x + y * y + z * z + w *... | 3 | Kotlin | 9 | 19 | 0ba55cb3d9abb3a9e57e8cef6c7eb0234c4f116a | 2,239 | beatwalls | MIT License |
app/src/y2021/day02/Day02Dive.kt | henningBunk | 432,858,990 | false | {"Kotlin": 124495} | package y2021.day02
import common.Answers
import common.AocSolution
import common.annotations.AoCPuzzle
import java.security.InvalidKeyException
fun main(args: Array<String>) {
Day02Dive().solveThem()
}
@AoCPuzzle(2021, 2)
class Day02Dive : AocSolution {
override val answers = Answers(samplePart1 = 150, samp... | 0 | Kotlin | 0 | 0 | 94235f97c436f434561a09272642911c5588560d | 1,972 | advent-of-code-2021 | Apache License 2.0 |
src/test/kotlin/aoc2020/OperationOrderTest.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2020
import komu.adventofcode.utils.nonEmptyLines
import komu.adventofcode.utils.readTestInput
import komu.adventofcode.utils.sumByLong
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
class OperationOrderTest {
@Test
fun `example 1`() {
assertEquals(71, ... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 1,606 | advent-of-code | MIT License |
src/Day02.kt | Daan-Gunnink | 572,614,830 | false | {"Kotlin": 8595} | class Day02 : AdventOfCode(15, 12) {
private fun calculateScoreFromMap(input: List<String>, map: Map<String, Int>): Int {
var totalScore = 0
input.forEach {
totalScore += map[it] ?: 0
}
return totalScore
}
override fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 15a89224f332faaed34fc2d000c00fbefe1a3c08 | 1,305 | advent-of-code-2022 | Apache License 2.0 |
bench/algorithm/merkletrees/1.kt | turururu | 509,064,681 | true | {"C#": 227864, "Rust": 189855, "Common Lisp": 142537, "Java": 56110, "C": 54246, "Go": 49634, "Python": 44672, "Zig": 43293, "Kotlin": 42632, "OCaml": 36915, "Julia": 35976, "TypeScript": 35314, "Dart": 35048, "Chapel": 33907, "Crystal": 33602, "C++": 33006, "Nim": 28654, "JavaScript": 26793, "Vue": 24821, "Haxe": 2369... | import kotlin.math.*
const val MinDepth = 4
fun main(args: Array<String>) {
val maxDepth = if (args.size > 0) max(args[0].toInt(), MinDepth + 2) else 10
val stretchDepth = maxDepth + 1
val stretchTree = Node.create(stretchDepth)
stretchTree.calHash()
println(
"stretch tree of depth ${... | 0 | C# | 0 | 0 | f72b031708c92f9814b8427b0dd08cb058aa6234 | 2,166 | Programming-Language-Benchmarks | MIT License |
Rationals_Board/Rationals/Task/src/rationals/Racional.kt | EdmundoSanchezM | 354,481,310 | false | null | package rationals
import java.lang.IllegalArgumentException
import java.math.BigInteger
import java.util.*
class Rational(numerator: BigInteger, denominator: BigInteger) : Comparable<Rational> {
companion object {
val ZERO = Rational(BigInteger.ZERO, BigInteger.ONE)
}
private val numerator: BigI... | 0 | Kotlin | 0 | 0 | a671a9b35eeae1f56ee1ad448347d9df5e583c9d | 3,749 | Kotlin-for-Java-Developers | MIT License |
core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/RequestMatching.kt | zmot | 336,870,141 | true | {"Groovy": 937121, "Kotlin": 725937, "Java": 707835, "Scala": 96345, "Clojure": 7519, "ANTLR": 7005, "Dockerfile": 582} | package au.com.dius.pact.core.matchers
import au.com.dius.pact.core.model.Interaction
import au.com.dius.pact.core.model.Request
import au.com.dius.pact.core.model.RequestResponseInteraction
import au.com.dius.pact.core.model.Response
import mu.KLogging
sealed class RequestMatch {
private val score: Int
get() {... | 0 | Groovy | 0 | 0 | e5c867ad52d4bc6965f01ce6f1f6d3af06400283 | 3,484 | pact-jvm | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CombinationIterator.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,075 | kotlab | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2016/Day24.kt | colinodell | 495,627,767 | false | {"Kotlin": 80872} | package com.colinodell.advent2016
class Day24(input: List<String>) {
private val layout = input.toGrid()
private val requiredLocations = layout.filter { it.value.isDigit() }.keys
private val start = layout.filter { it.value == '0' }.keys.first()
fun solvePart1() = solve { state: State -> state.seen.co... | 0 | Kotlin | 0 | 0 | 8a387ddc60025a74ace8d4bc874310f4fbee1b65 | 1,110 | advent-2016 | Apache License 2.0 |
2023/18/Solution.kt | AdrianMiozga | 588,519,359 | false | {"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732} | import java.io.File
import java.util.*
private const val FILENAME = "2023/18/input.txt"
private const val GROUND = '.'
private const val TRENCH = '#'
private data class Position(var x: Int, var y: Int)
fun main() {
partOne()
}
private fun partOne() {
val file = File(FILENAME).readLines()
val array: Muta... | 0 | Kotlin | 0 | 0 | c9cba875089d8d4fb145932c45c2d487ccc7e8e5 | 2,486 | Advent-of-Code | MIT License |
src/year2021/day06/Day06.kt | fadi426 | 433,496,346 | false | {"Kotlin": 44622} | package year2021.day01.day06
import util.assertTrue
import util.read2021DayInput
fun main() {
fun calcLanternFishDensity(input: List<Int>, days: Int): Long {
var fishDensityList = (0..9).map { n -> input.count { n == it } }.map { it.toLong() }
for (i in 1..days) {
fishDensityList = mu... | 0 | Kotlin | 0 | 0 | acf8b6db03edd5ff72ee8cbde0372113824833b6 | 1,024 | advent-of-code-kotlin-template | Apache License 2.0 |
src/main/java/hes/nonogram/Puzzle.kt | Hes-Siemelink | 689,215,071 | false | {"Kotlin": 32733} | package hes.nonogram
/**
* Nonogram puzzle state.
*
* Cells are mutable; hints are read-only.
*/
data class Puzzle(
private val rowHints: List<Hints>,
private val columnHints: List<Hints>,
private val cells: List<Cell> = mutableListOf()
) {
private val width: Int = columnHints.size
private val... | 0 | Kotlin | 0 | 0 | 7b96e50eb2973e4e2a906cf20af743909f0ebc8d | 2,842 | Nonogram | MIT License |
src/Day01.kt | chrisjwirth | 573,098,264 | false | {"Kotlin": 28380} | fun main() {
fun part1(input: List<String>): Int {
var maxWeight = 0
var currentWeight = 0
input.forEach {
if (it.isNotBlank()) {
currentWeight += it.toInt()
} else {
maxWeight = maxOf(maxWeight, currentWeight)
currentW... | 0 | Kotlin | 0 | 0 | d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d | 1,123 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/day10/Day10.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day10
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day10/Day10.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 10 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 1,539 | advent-of-code-2022 | MIT License |
src/leetcodeProblem/leetcode/editor/en/RemoveLinkedListElements.kt | faniabdullah | 382,893,751 | false | null | //Given the head of a linked list and an integer val, remove all the nodes of
//the linked list that has Node.val == val, and return the new head.
//
//
// Example 1:
//
//
//Input: head = [1,2,6,3,4,5,6], val = 6
//Output: [1,2,3,4,5]
//
//
// Example 2:
//
//
//Input: head = [], val = 1
//Output: []
//
//
// ... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 1,736 | dsa-kotlin | MIT License |
src/Day03.kt | BerkkanB | 573,764,177 | false | {"Kotlin": 1868} | fun main(){
val testInput = readTestInput("Day03_test")
val actualInput = readInput("Day03")
val score = calculateScore(testInput)
println("The score of given rucksacks is: $score")
}
fun calculateScore(list: List<String>): Int {
var sum = 0
list.forEach {
sum += it.pointOfSameItem()
... | 0 | Kotlin | 0 | 1 | b7a2d163f19545b668df2731b720759089f191bf | 729 | adventOfCode | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxWidthOfVerticalArea.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,281 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RecoverFromPreorder.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,897 | kotlab | Apache License 2.0 |
src/Day02.kt | JaydenPease | 574,590,496 | false | {"Kotlin": 11645} | fun main() {
// fun part1(input: List<String>): Int {
// return input.size
// }
//
// fun part2(input: List<String>): Int {
// return input.size
// }
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day02_test")
//println(Day02_part1(... | 0 | Kotlin | 0 | 0 | 0a5fa22b3653c4b44a716927e2293fc4b2ed9eb7 | 2,654 | AdventOfCode-2022 | Apache License 2.0 |
app/src/main/kotlin/day02/Day02.kt | meli-w | 433,710,859 | false | {"Kotlin": 52501} | package day02
import common.InputRepo
import common.readSessionCookie
import common.solve
import java.lang.IllegalStateException
fun main(args: Array<String>) {
val day = 2
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay02Part1, ::solveDay02Part2)
}
fun solve... | 0 | Kotlin | 0 | 1 | f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1 | 1,495 | AoC-2021 | Apache License 2.0 |
src/year2022/day17/Day17.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day17
import Point2D
import readInputFileByYearAndDay
import readTestFileByYearAndDay
val shapes = mapOf(
0 to setOf(Point2D(0, 0), Point2D(1, 0), Point2D(2, 0), Point2D(3, 0)), // plank
1 to setOf(Point2D(1, 0), Point2D(0, 1), Point2D(1, 1), Point2D(2, 1), Point2D(1, 2)), // cross
2 to s... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 4,597 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/day14/day14.kt | corneil | 572,437,852 | false | {"Kotlin": 93311, "Shell": 595} | package day14
import main.utils.measureAndPrint
import main.utils.scanInts
import utils.Coord
import utils.readFile
import utils.readLines
import utils.separator
import kotlin.math.max
import kotlin.math.min
enum class Substance(val c: Char) {
AIR('.'),
ROCK('#'),
SAND('o')
}
enum class Direction {
STOP,
N... | 0 | Kotlin | 0 | 0 | dd79aed1ecc65654cdaa9bc419d44043aee244b2 | 6,642 | aoc-2022-in-kotlin | Apache License 2.0 |
Problems/Algorithms/1268. Search Suggestions System/SearchSuggestionsSystem.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun suggestedProducts(products: Array<String>, searchWord: String): List<List<String>> {
products.sort()
val n = products.size
var start = 0
val results: MutableList<MutableList<String>> = mutableListOf()
var prefix = StringBuilder()
... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,350 | leet-code | MIT License |
src/Day11.kt | RobvanderMost-TomTom | 572,005,233 | false | {"Kotlin": 47682} | import java.math.BigInteger
import kotlin.math.floor
fun BigInteger.divisibleBy(value: Int) = this % value.toBigInteger() == BigInteger.ZERO
class Monkey(
val items: MutableList<BigInteger>,
private val operation: (old: BigInteger) -> BigInteger,
val divider: Int,
private val trueMonkey: Int,
priv... | 5 | Kotlin | 0 | 0 | b7143bceddae5744d24590e2fe330f4e4ba6d81c | 5,130 | advent-of-code-2022 | Apache License 2.0 |
Chapter06/KotlinCollectionsApi.kt | PacktPublishing | 131,798,556 | false | null | package quickstartguide.kotlin.chapter5
fun filterEvensThenSquare(numbers: Collection<Int>) {
val result: List<String> = numbers.filter { n -> n % 2 == 0 }
.map { n -> n * n }
.sorted()
.takeWhile { n -> n < 1000 }
.map { n -> n.toString() }
}
// FILTERING
fun drop... | 1 | Kotlin | 8 | 9 | 5c781d2da36e8cb3407b8448c5cbff207fe34592 | 3,026 | Kotlin-Quick-Start-Guide | MIT License |
src/test/kotlin/adventofcode/day18/Day18.kt | jwcarman | 573,183,719 | false | {"Kotlin": 183494} | /*
* Copyright (c) 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 i... | 0 | Kotlin | 0 | 0 | d6be890aa20c4b9478a23fced3bcbabbc60c32e0 | 3,338 | adventofcode2022 | Apache License 2.0 |
src/Day02.kt | uzorov | 576,933,382 | false | {"Kotlin": 6068} | import java.io.File
import java.util.*
fun main() {
fun getPoints(guideString: String):Int {
when (guideString) {
"A X" -> return 3
"B X" -> return 1
"C X" -> return 2
"A Y" -> return 4
"B Y" -> return 5
"C Y" -> return 6
"A Z" -> return 8
"B Z... | 0 | Kotlin | 0 | 0 | be4ec026f6114f2fa7ae7ebd9b55af9215de8e7b | 968 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day01.kt | Longtainbin | 573,466,419 | false | {"Kotlin": 22711} | import java.util.PriorityQueue
import kotlin.math.max
fun main() {
val input = readInput("inputDay01")
fun part1(input: List<String>): Int {
val caloriesList = mutableListOf<Int>()
var maxCalories = 0
for (str in input) {
if (str.isEmpty()) {
val curElfCalor... | 0 | Kotlin | 0 | 0 | 48ef88b2e131ba2a5b17ab80a0bf6a641e46891b | 1,156 | advent-of-code-2022 | Apache License 2.0 |
partiql-lang/src/main/kotlin/org/partiql/lang/graph/Graph.kt | partiql | 186,474,394 | false | {"Kotlin": 6425423, "HTML": 103438, "ANTLR": 34368, "Inno Setup": 3838, "Java": 1949, "Shell": 748} | package org.partiql.lang.graph
import org.partiql.lang.eval.ExprValue
/** This is an "external" interface to a graph data value,
* providing functionality needed for a pattern-matching processor.
* The intent is to come up with something that can be implemented by different "platforms"
* in different ways.
* ... | 269 | Kotlin | 60 | 530 | e894fad711bc4126d1022f62d7545b64f5e6bfc8 | 3,644 | partiql-lang-kotlin | Apache License 2.0 |
src/Day11.kt | acrab | 573,191,416 | false | {"Kotlin": 52968} | import com.google.common.truth.Truth.assertThat
import java.math.BigInteger
class Monkey(
val id: String,
startingItems: List<Int>,
private val inspectOperation: (BigInteger) -> BigInteger,
private val testValue: BigInteger,
private val onTrue: String,
private val onFalse: String,
private v... | 0 | Kotlin | 0 | 0 | 0be1409ceea72963f596e702327c5a875aca305c | 4,280 | aoc-2022 | Apache License 2.0 |
app/src/main/kotlin/solution/Solution2454.kt | likexx | 559,794,763 | false | {"Kotlin": 136661} | package solution
import solution.annotation.Leetcode
class Solution2454 {
@Leetcode(2454)
class Solution {
// inspired by https://leetcode.com/problems/next-greater-element-iv/discuss/2756668/JavaC%2B%2BPython-One-Pass-Stack-Solution-O(n)
fun secondGreaterElement(nums: IntArray): IntArray {
... | 0 | Kotlin | 0 | 0 | 376352562faf8131172e7630ab4e6501fabb3002 | 3,236 | leetcode-kotlin | MIT License |
src/main/kotlin/de/niemeyer/aoc2022/Day20.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | /**
* Advent of Code 2022, Day 20: Grove Positioning System
* Problem Description: https://adventofcode.com/2022/day/20
*/
package de.niemeyer.aoc2022
import de.niemeyer.aoc.utils.Resources.resourceAsListOfLong
import de.niemeyer.aoc.utils.getClassName
import kotlin.math.absoluteValue
fun main() {
fun parseIn... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 3,684 | AoC-2022 | Apache License 2.0 |
src/commonMain/kotlin/advent2020/day02/Day02Puzzle.kt | jakubgwozdz | 312,526,719 | false | null | package advent2020.day02
internal data class ParsedLine(val number1: Int, val number2: Int, val char: Char, val password: String)
val regexp by lazy { """(\d+)-(\d+) (\w): (\w*)""".toRegex() }
internal fun parse(line: String): ParsedLine {
val (g1, g2, g3, g4) = regexp.matchEntire(line)?.destructured
?: e... | 0 | Kotlin | 0 | 2 | e233824109515fc4a667ad03e32de630d936838e | 927 | advent-of-code-2020 | MIT License |
src/pl/shockah/aoc/y2019/Day3.kt | Shockah | 159,919,224 | false | null | package pl.shockah.aoc.y2019
import pl.shockah.aoc.AdventTask
import pl.shockah.unikorn.geom.polygon.Polygon
import pl.shockah.unikorn.math.MutableVector2
import pl.shockah.unikorn.math.Vector2
import kotlin.math.abs
class Day3: AdventTask<Pair<Polygon, Polygon>, Int, Int>(2019, 3) {
enum class Direction(
val symb... | 0 | Kotlin | 0 | 0 | 9abb1e3db1cad329cfe1e3d6deae2d6b7456c785 | 2,119 | Advent-of-Code | Apache License 2.0 |
src/main/kotlin/aoc22/Day16.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import aoc22.Day16Domain.Mountain
import aoc22.Day16Domain.Valve
import aoc22.Day16Domain.valvesToVisit
import aoc22.Day16Parser.toValves
import aoc22.Day16Solution.part1Day16
import aoc22.Day16Solution.part2Day16
import com.github.shiguruikai.combinatoricskt.combinations
import common.Year22
object Day... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 5,503 | aoc | Apache License 2.0 |
src/main/kotlin/aoc/Day1.kt | dtsaryov | 573,392,550 | false | {"Kotlin": 28947} | package aoc
/**
* [AoC 2022: Day 1](https://adventofcode.com/2022/day/1)
*/
fun findMaxCalories(): Int {
val input = readInput("day1.txt") ?: return -1
var max = 0
processSums(input) { sum ->
if (sum > max) max = sum
}
return max
}
fun findSumOfTop3Calories(): Int {
val input = read... | 0 | Kotlin | 0 | 0 | 549f255f18b35e5f52ebcd030476993e31185ad3 | 1,028 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/pl/mrugacz95/aoc/day10/day10.kt | mrugacz95 | 317,354,321 | false | null | package pl.mrugacz95.aoc.day10
fun part1(joltages: List<Int>): Int {
val differences = joltages.sorted().windowed(2, 1).map { it[1] - it[0] }.groupingBy { it }.eachCount()
return differences[1]!! * differences[3]!!
}
val cache = HashMap<Int, Long>()
fun findPermutations(startIndex: Int, list: List<Int>): Lon... | 0 | Kotlin | 0 | 1 | a2f7674a8f81f16cd693854d9f564b52ce6aaaaf | 1,138 | advent-of-code-2020 | Do What The F*ck You Want To Public License |
advent/src/test/kotlin/org/elwaxoro/advent/y2021/Dec17.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2021
import org.elwaxoro.advent.Coord
import org.elwaxoro.advent.PuzzleDayTester
import org.elwaxoro.advent.contains
/**
* Trick Shot
*/
class Dec17 : PuzzleDayTester(17, 2021) {
override fun part1(): Any = parse().sprayAndPray().flatten().maxOf { it.pos.y }
override fun part2(... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 1,873 | advent-of-code | MIT License |
Problems/Algorithms/547. Number of Provinces/NumberOfProvinces.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun findCircleNum(isConnected: Array<IntArray>?): Int {
if (isConnected == null || isConnected.size == 0) {
return 0
}
val n = isConnected.size
val uf = UnionFind(n)
for (i in 0..n-1) {
for (j in 0..n-1) {
if (... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,434 | leet-code | MIT License |
src/2022/Day11.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2022`
import java.io.File
import java.math.BigInteger
import java.util.*
fun main() {
Day11().solve()
}
class Day11 {
val input1 = """
Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monke... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 5,387 | advent-of-code | Apache License 2.0 |
src/Day14.kt | greg-burgoon | 573,074,283 | false | {"Kotlin": 120556} | fun main() {
class Point (x: Int, y: Int) {
val x = x
val y = y
}
fun drawLine(grid: MutableList<MutableList<Char>>, firstPoint: Point, secondPoint: Point) {
val isVerticalLine = firstPoint.x == secondPoint.x
if (isVerticalLine) {
var maxY = Math.max(firstPoint.... | 0 | Kotlin | 0 | 1 | 74f10b93d3bad72fa0fc276b503bfa9f01ac0e35 | 5,808 | aoc-kotlin | Apache License 2.0 |
src/main/kotlin/day9/Day9.kt | Mee42 | 433,459,856 | false | {"Kotlin": 42703, "Java": 824} | package dev.mee42.day9
import dev.mee42.*
val test = """
2199943210
3987894921
9856789892
8767896789
9899965678
""".trimIndent()
fun <T> T.println(name: String? = null): T {
if(name == null) println(this)
else System.out.println("$name: $this")
return this
}
fun main() {
val inputRaw = if(1 == 0) tes... | 0 | Kotlin | 0 | 0 | db64748abc7ae6a92b4efa8ef864e9bb55a3b741 | 1,466 | aoc-2021 | MIT License |
src/Day09_part2.kt | jmorozov | 573,077,620 | false | {"Kotlin": 31919} | import kotlin.math.absoluteValue
fun main() {
val inputData = readInput("Day09")
part2(inputData)
}
private fun part2(inputData: List<String>) {
val visitedByTail = mutableSetOf<Point>()
val startPoint = Point.start()
var state = MutableList(ROPE_LENGTH) { _ -> startPoint }
for (line... | 0 | Kotlin | 0 | 0 | 480a98838949dbc7b5b7e84acf24f30db644f7b7 | 5,234 | aoc-2022-in-kotlin | Apache License 2.0 |
src/com/mrxyx/algorithm/LFU.kt | Mrxyx | 366,778,189 | false | null | package com.mrxyx.algorithm
class LFU (capacity: Int){
// key 到 val 的映射,我们后文称为 KV 表
private var keyToVal: HashMap<Int, Int> = HashMap()
// key 到 freq 的映射,我们后文称为 KF 表
private var keyToFreq: HashMap<Int, Int> = HashMap()
// freq 到 key 列表的映射,我们后文称为 FK 表
var freqToKeys: HashMap<Int, LinkedHashSet<... | 0 | Kotlin | 0 | 0 | b81b357440e3458bd065017d17d6f69320b025bf | 2,888 | algorithm-test | The Unlicense |
src/main/java/dev/haenara/mailprogramming/solution/y2020/m03/d29/Solution200329.kt | HaenaraShin | 226,032,186 | false | null | package dev.haenara.mailprogramming.solution.y2020.m03.d29
import dev.haenara.mailprogramming.solution.Solution
/**
* 매일프로그래밍 2020. 03. 29
* 순환 정수 배열이 주어졌을 때, 합이 최대가 되는 부분 배열을 구하시오.
*
* Input: [2, 1, -5, 4, -3, 1, -3, 4, -1]
* Output: 부분 배열 [4, -1, 2, 1], 합 6
* Input: [-3, 1, -3, 4, -1, 2, 1, -5, 4]
* Output: ... | 0 | Kotlin | 0 | 7 | b5e50907b8a7af5db2055a99461bff9cc0268293 | 4,576 | MailProgramming | MIT License |
common/geometry/src/main/kotlin/com/curtislb/adventofcode/common/geometry/Direction.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | package com.curtislb.adventofcode.common.geometry
import com.curtislb.adventofcode.common.collection.getCyclic
/**
* A valid direction in a two-dimensional grid.
*
* @property clockwiseIndex The index of the direction in clockwise order, starting with [UP].
*/
enum class Direction(private val clockwiseIndex: Int)... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 3,084 | AdventOfCode | MIT License |
client/PathFinder/app/src/main/java/com/dijkstra/pathfinder/util/KalmanFilter3D.kt | PathFinder-SSAFY | 643,691,193 | false | null | package com.dijkstra.pathfinder.util
class KalmanFilter3D(
initialState: List<Double>,
initialCovariance: List<List<Double>>
) {
private var state = initialState
private var covariance = initialCovariance
private val processNoise = listOf(
listOf(0.1, 0.0, 0.0),
listOf(0.0, 0.1, 0.0... | 1 | Kotlin | 3 | 1 | 57e9a94594ff2e3561e62b6c5c9db63cfa4ef203 | 1,777 | PathFinder | Apache License 2.0 |
2021/src/main/kotlin/aoc2021/day14/Day14.kt | dkhawk | 433,915,140 | false | {"Kotlin": 170350} | package aoc2021.day14
import kotlin.system.measureTimeMillis
import utils.Input
@OptIn(ExperimentalStdlibApi::class)
class Day14 {
companion object {
fun run() {
val time1 = measureTimeMillis {
Day14().part1()
}
println("millis: $time1")
measureTimeMillis {
Day14().part2... | 0 | Kotlin | 0 | 0 | 64870a6a42038acc777bee375110d2374e35d567 | 2,647 | advent-of-code | MIT License |
aoc-2017/src/main/kotlin/nl/jstege/adventofcode/aoc2017/days/Day15.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2017.days
import nl.jstege.adventofcode.aoccommon.days.Day
/**
*
* @author <NAME>
*/
class Day15 : Day(title = "Dueling Generators") {
private companion object Configuration {
private const val MASK = 0xFFFFL
private const val DIVISOR = 2147483647
priva... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 1,819 | AdventOfCode | MIT License |
src/main/kotlin/utils/Math.kt | sssemil | 268,084,789 | false | null | package utils
val fastLookupFactorial = hashMapOf<Long, Long>()
fun factorialNaive(n: Long): Long {
if (n <= 1) return 1
return n * factorialNaive(n - 1)
}
fun factorialDynamic(n: Long): Long {
if (n <= 1) return 1
if (!fastLookupFactorial.containsKey(n)) {
fastLookupFactorial[n] = n * factor... | 0 | Kotlin | 0 | 0 | 02d951b90e0225bb1fa36f706b19deee827e0d89 | 1,289 | math_playground | MIT License |
src/main/kotlin/kt/kotlinalgs/app/sorting/KMessedArraySort.ws.kts | sjaindl | 384,471,324 | false | null | // https://www.pramp.com/challenge/XdMZJgZoAnFXqwjJwnBZ
// https://www.bezkoder.com/kotlin-priority-queue/
package kt.kotlinalgs.app.sorting
import java.util.*
println("test")
val sorted = sortKMessesArray(
intArrayOf(1, 4, 5, 2, 3, 7, 8, 6, 10, 9), 2
)
val minComparator: Comparator<Int> = compareBy<Int> {
... | 0 | Java | 0 | 0 | e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0 | 1,857 | KotlinAlgs | MIT License |
src/aoc2022/Day10.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2022
import println
import readInput
fun main() {
fun part1(input: List<String>): Int {
var s20: Int? = null
var s60: Int? = null
var s100: Int? = null
var s140: Int? = null
var s180: Int? = null
var s220: Int? = null
var curCycle = 1
va... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 3,842 | advent-of-code-kotlin | Apache License 2.0 |
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day2.kt | Guruth | 328,467,380 | false | {"Kotlin": 188298, "Rust": 13289, "Elixir": 1833} | package sh.weller.adventofcode.twentytwenty
fun List<String>.validatePasswords(validationType: ValidationType): Int =
this.map {
val criteria = it.getCriteria()
val password = it.getPassword()
return@map when (validationType) {
ValidationType.COUNT -> password.validateByCount(c... | 0 | Kotlin | 0 | 0 | 69ac07025ce520cdf285b0faa5131ee5962bd69b | 1,851 | AdventOfCode | MIT License |
src/y2022/Day05.kt | Yg0R2 | 433,731,745 | false | null | package y2022
import DayX
import y2022.Day05.Procedure.Companion.getRearrangementProcedure
import y2022.Day05.Stack.Companion.getInitialStack
class Day05 : DayX<String>("CMZ", "MCD") {
override fun part1(input: List<String>): String {
val stack = input.getInitialStack()
val rearrangementProcedure... | 0 | Kotlin | 0 | 0 | d88df7529665b65617334d84b87762bd3ead1323 | 3,644 | advent-of-code | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[1018]可被 5 整除的二进制前缀.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定由若干 0 和 1 组成的数组 A。我们定义 N_i:从 A[0] 到 A[i] 的第 i 个子数组被解释为一个二进制数(从最高有效位到最低有效位)。
//
//
// 返回布尔值列表 answer,只有当 N_i 可以被 5 整除时,答案 answer[i] 为 true,否则为 false。
//
//
//
// 示例 1:
//
// 输入:[0,1,1]
//输出:[true,false,false]
//解释:
//输入数字为 0, 01, 011;也就是十进制中的 0, 1, 3 。只有第一个数可以被 5 整除,因此 answer[0] 为真。
//
//
// 示例 2:
//
// 输入:[1,... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,482 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/mkuhn/aoc/util/Utils.kt | mtkuhn | 572,236,871 | false | {"Kotlin": 53161} | package mkuhn.aoc.util
import java.io.File
fun readInput(name: String) = File("src/main/resources/", "$name.txt")
.readLines()
fun readTestInput(name: String) = File("src/test/resources/", "$name.txt")
.readLines()
fun String.splitToPair(separator: Char) = this.substringBefore(separator) to this.substringAf... | 0 | Kotlin | 0 | 1 | 89138e33bb269f8e0ef99a4be2c029065b69bc5c | 1,874 | advent-of-code-2022 | Apache License 2.0 |
the-ray-tracer-challenge/src/main/kotlin/io/github/ocirne/ray/challenge/tuples/Tuple.kt | ocirne | 379,563,605 | false | null | package io.github.ocirne.ray.challenge.tuples
import kotlin.math.sqrt
import io.github.ocirne.ray.challenge.math.equalsDelta
open class Tuple(val x: Double, val y: Double, val z: Double, val w: Double) {
constructor(x: Int, y: Int, z: Int, w: Int) : this(x.toDouble(), y.toDouble(), z.toDouble(), w.toDouble())
... | 0 | Kotlin | 0 | 0 | 5075b417be18fd07f61f5182e0381fd283319c66 | 2,503 | ray | The Unlicense |
src/main/kotlin/util/Cell.kt | vovarova | 726,012,901 | false | {"Kotlin": 48551} | package util
import java.util.stream.IntStream
data class Cell(val row: Int, val column: Int) {
fun down(): Cell = Cell(row + 1, column)
fun up(): Cell = Cell(row - 1, column)
fun left(): Cell = Cell(row, column - 1)
fun right(): Cell = Cell(row, column + 1)
fun toPair() = Pair(row, column)
}
i... | 0 | Kotlin | 0 | 0 | 77df1de2a663def33b6f261c87238c17bbf0c1c3 | 3,593 | adventofcode_2023 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day15.kt | andilau | 429,206,599 | false | {"Kotlin": 113274} | package days
import days.Day15.Block.*
import days.Point.Companion.ORIGIN
@AdventOfCodePuzzle(
name = "Oxygen System",
url = "https://adventofcode.com/2019/day/15",
date = Date(day = 15, year = 2019)
)
class Day15(input: LongArray) : Puzzle {
private val computer = CompleteIntCodeComputer(input)
p... | 2 | Kotlin | 0 | 0 | f51493490f9a0f5650d46bd6083a50d701ed1eb1 | 2,588 | advent-of-code-2019 | Creative Commons Zero v1.0 Universal |
challenges/hacker-rank/kotlin/src/main/kotlin/com/raphaelnegrisoli/hackerrank/sorting/MergeSortCountingInversions.kt | rbatista | 36,197,840 | false | {"Scala": 34929, "Kotlin": 23388} | /**
* https://www.hackerrank.com/challenges/ctci-merge-sort/
*/
package com.raphaelnegrisoli.hackerrank.sorting
import java.lang.StringBuilder
fun countInversions(arr: Array<Int>): Long {
return mergeSort(arr, Array(arr.size) { 0 }, 0, arr.size - 1)
}
fun mergeSort(arr: Array<Int>, temp: Array<Int>, begin: I... | 2 | Scala | 0 | 0 | f1267e5d9da0bd5f6538b9c88aca652d9eb2b96c | 1,755 | algorithms | MIT License |
src/main/aoc2016/Day11.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2016
import kotlin.math.abs
class Day11(input: List<String>) {
// First approach used separate classes for Generators and Microchips with their positions
// and names. But that got messy and cumbersome when moving items and when checking for
// equivalent states. Just one list of Ints represen... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 8,500 | aoc | MIT License |
2017/src/main/kotlin/Day06.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import utils.splitWhitespace
import utils.toIntList
object Day06 {
fun part1(input: String): Int {
var banks = input.splitWhitespace().toIntList()
val seen = mutableSetOf<List<Int>>()
var steps = 0
while (!seen.contains(banks)) {
seen.add(banks)
val indexToRedistribute = maxBankIndex(ba... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 1,353 | advent-of-code | MIT License |
src/main/kotlin/day20/Day20.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day20
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day20/Day20.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 20 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 1,251 | advent-of-code-2022 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/GroupThePeople.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,756 | kotlab | Apache License 2.0 |
advent_of_code/2018/solutions/day_6_b.kt | migafgarcia | 63,630,233 | false | {"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343} | import java.io.File
import java.lang.Math.abs
fun main(args: Array<String>) {
val ids = generateSequence(1) { it + 1 }
val points = ids.zip(File(args[0]).readLines().map { line ->
val s = line.split(",").map { it.trim() }
Pair(s[0].toInt(), s[1].toInt())
}.asSequence()).toMap()
val xM... | 0 | C++ | 3 | 9 | 82f5e482c0c3c03fd39e46aa70cab79391ed2dc5 | 921 | programming-challenges | MIT License |
bot/src/main/java/pl/elpassion/elabyrinth/bot/Board.kt | elpassion | 57,039,976 | false | null | package pl.elpassion.elabyrinth.bot
import pl.elpassion.elabyrinth.core.Cell
import pl.elpassion.elabyrinth.core.Direction
import java.util.*
class Board {
val map: Set<Field>
val start: Field
val finish: Field
val visited: MutableSet<Field>
constructor(map: List<List<Cell>>) {
this.map ... | 0 | Kotlin | 0 | 0 | 72800b31ec78c22766ec9ce81e5c70c405d22708 | 2,188 | el-abyrinth-android | MIT License |
src/day08/Day08.kt | ritesh-singh | 572,210,598 | false | {"Kotlin": 99540} | package day08
import readInput
fun main() {
fun List<String>.initMatrix(matrix: Array<IntArray>) {
val rowSize = size
val colSize = this[0].length
for (row in 0 until rowSize) {
for (col in 0 until colSize) {
matrix[row][col] = this[row][col].digitToInt()
... | 0 | Kotlin | 0 | 0 | 17fd65a8fac7fa0c6f4718d218a91a7b7d535eab | 4,184 | aoc-2022-kotlin | Apache License 2.0 |
2022/src/main/kotlin/day2_imp.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
import utils.badInput
import utils.cut
import utils.mapItems
fun main() {
Day2Imp.run()
}
object Day2Imp : Solution<List<Pair<Play, Char>>>() {
override val name = "day2"
override val parser = Parser.lines.mapItems { line -> line.cut(" ", { l -> Play.fromL(l[0]) }) { it... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 892 | aoc_kotlin | MIT License |
src/main/kotlin/g0701_0800/s0720_longest_word_in_dictionary/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0701_0800.s0720_longest_word_in_dictionary
// #Medium #Array #String #Hash_Table #Sorting #Trie
// #2023_02_27_Time_209_ms_(100.00%)_Space_37_MB_(83.33%)
@Suppress("NAME_SHADOWING")
class Solution {
private val root = Node()
private var longestWord: String? = ""
private class Node {
var ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,334 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/aoc/Day2.kt | dtsaryov | 573,392,550 | false | {"Kotlin": 28947} | package aoc
/**
* [AoC 2022: Day 2](https://adventofcode.com/2022/day/2)
*/
fun calcRockPaperScissorsScore(): Int {
val input = readInput("day2.txt") ?: return -1
var score = 0
processRounds(input) { (playerShape, opponentShape) ->
score += getPlayerRoundScore(playerShape, opponentShape)
... | 0 | Kotlin | 0 | 0 | 549f255f18b35e5f52ebcd030476993e31185ad3 | 2,497 | aoc-2022 | Apache License 2.0 |
src/Day19.kt | PascalHonegger | 573,052,507 | false | {"Kotlin": 66208} | import kotlin.math.max
import kotlin.system.measureTimeMillis
fun main() {
val inputPattern =
"Blueprint (.+): Each ore robot costs (.+) ore. Each clay robot costs (.+) ore. Each obsidian robot costs (.+) ore and (.+) clay. Each geode robot costs (.+) ore and (.+) obsidian.".toRegex()
data class Bluep... | 0 | Kotlin | 0 | 0 | 2215ea22a87912012cf2b3e2da600a65b2ad55fc | 5,591 | advent-of-code-2022 | Apache License 2.0 |
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day20/Day20.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.aoc2021.day20
import nl.sanderp.aoc.common.Point2D
import nl.sanderp.aoc.common.readResource
import nl.sanderp.aoc.common.x
import nl.sanderp.aoc.common.y
fun main() {
val input = readResource("Day20.txt").replace('.', '0').replace('#', '1').lines()
val algorithm = input.first()
val... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 1,824 | advent-of-code | MIT License |
advent-of-code-2022/src/main/kotlin/year_2022/Day19.kt | rudii1410 | 575,662,325 | false | {"Kotlin": 37749} | package year_2022
import util.Runner
fun main() {
val size = 100
/* Part 1 */
/**
* ore = 0, clay = 1, obsidian = 2, geode = 3
*/
fun parseRecipe(s: String): List<Int> {
fun List<String>.parse(idx: Int, stone: String): Int {
return this.getOrNull(idx)?.trim()?.split(" ")... | 1 | Kotlin | 0 | 0 | ab63e6cd53746e68713ddfffd65dd25408d5d488 | 1,178 | advent-of-code | Apache License 2.0 |
src/main/kotlin/stacktic/Interpreter.kt | nschulzke | 519,260,020 | false | {"Kotlin": 24938} | package stacktic
import java.lang.Double.parseDouble
import java.lang.Integer.parseInt
class Interpreter(
val printLine: (String) -> Unit = ::println,
) {
private val vocabulary: Vocabulary = Vocabulary()
private val stackStack = Stack<Stack<Value>>(listOf(Stack()))
private val stack get() = stackStac... | 0 | Kotlin | 0 | 1 | d41601100ef2756b97004b8424312f8853b62f33 | 8,022 | stacktic | MIT License |
src/main/kotlin/com/exsilicium/scripture/shared/extensions/LocationExtensions.kt | Ex-Silicium | 103,700,839 | false | null | package com.exsilicium.scripture.shared.extensions
import com.exsilicium.scripture.shared.model.ChapterRanges
import com.exsilicium.scripture.shared.model.VerseRanges
internal fun ChapterRanges.compareChapterRanges(other: ChapterRanges): Int {
val startingChapterComparison = chapterRanges.first().start.compareTo(... | 14 | Kotlin | 1 | 1 | 4815f70f5736080d7533e0d1316f0aa2c31aa85a | 1,232 | scripture-core | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day12.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2022
import com.dvdmunckhof.aoc.common.Grid
import com.dvdmunckhof.aoc.common.Point
import com.dvdmunckhof.aoc.toGrid
import java.util.ArrayDeque
class Day12(input: List<String>) {
private val heightGrid = input.map { row -> row.map { c ->
when (c) {
'S' -> -1
... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,747 | advent-of-code | Apache License 2.0 |
src/main/kotlin/ru/spbstu/generator/TunnelGenerator.kt | belyaev-mikhail | 192,383,116 | false | null | package ru.spbstu.generator
import ru.spbstu.map.*
import ru.spbstu.player.aStarSearch
class TunnelGenerator(private val parameters: Parameters) {
enum class Cell { WALL, PATH }
private val matrix = HashMap<Point, Cell>()
private fun isWall(point: Point) = matrix[point] == Cell.WALL
private fun is... | 1 | Kotlin | 0 | 0 | cd5c7d668bf6615fd7e639ddfce0c135c138de42 | 7,674 | icfpc-2019 | MIT License |
src/main/kotlin/de/consuli/aoc/year2023/days/Day01.kt | ulischulte | 572,773,554 | false | {"Kotlin": 40404} | package de.consuli.aoc.year2023.days
import de.consuli.aoc.common.Day
class Day01 : Day(1, 2023) {
private val digitStrings = mapOf(
"one" to "1",
"two" to "2",
"three" to "3",
"four" to "4",
"five" to "5",
"six" to "6",
"seven" to "7",
"eight" to "... | 0 | Kotlin | 0 | 2 | 21e92b96b7912ad35ecb2a5f2890582674a0dd6a | 1,347 | advent-of-code | Apache License 2.0 |
src/Day12.kt | michaelYuenAE | 573,094,416 | false | {"Kotlin": 74685} | //class Day12 {
//
// fun partOne(): Int = createField()
// .let { (field, start, end) ->
// findShortestPath(mutableListOf(field[start]!!), field, end)
// }
//
// fun partTwo(): Int = createField()
// .let { (field, _, end) ->
// field.values
// .filter {... | 0 | Kotlin | 0 | 0 | ee521263dee60dd3462bea9302476c456bfebdf8 | 3,594 | advent22 | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2021/day12/CaveMap.kt | michaelbull | 433,565,311 | false | {"Kotlin": 162839} | package com.github.michaelbull.advent2021.day12
fun Sequence<CaveConnection>.toCaveMap(): CaveMap {
val connections = mutableMapOf<Cave, Set<Cave>>()
for ((start, end) in this@toCaveMap) {
connections[start] = connections.getOrDefault(start, emptySet()) + end
connections[end] = connections.get... | 0 | Kotlin | 0 | 4 | 7cec2ac03705da007f227306ceb0e87f302e2e54 | 942 | advent-2021 | ISC License |
index-lib/src/main/kotlin/cz/vutbr/fit/knot/enticing/index/collection/manager/postprocess/OverlapFiltering.kt | d-kozak | 180,137,313 | false | {"Kotlin": 1104829, "TypeScript": 477922, "Python": 23617, "Shell": 19609, "HTML": 8510, "ANTLR": 2005, "CSS": 1432} | package cz.vutbr.fit.knot.enticing.index.collection.manager.postprocess
import cz.vutbr.fit.knot.enticing.eql.compiler.matching.DocumentMatch
import cz.vutbr.fit.knot.enticing.index.boundary.IndexedDocument
import cz.vutbr.fit.knot.enticing.index.boundary.MatchInfo
import cz.vutbr.fit.knot.enticing.index.collection.ma... | 0 | Kotlin | 0 | 0 | 1ea9f874c6d2e4ea158e20bbf672fc45bcb4a561 | 2,290 | enticing | MIT License |
src/main/kotlin/org/mechdancer/algebra/function/vector/Distance.kt | MechDancer | 128,765,281 | false | null | package org.mechdancer.algebra.function.vector
import org.mechdancer.algebra.core.Vector
import org.mechdancer.algebra.function.vector.DistanceType.*
import kotlin.math.acos
/** 计算两个向量之间的某种距离 */
enum class DistanceType(val between: (Vector, Vector) -> Double) {
/** 用弧度表示的夹角 */
IncludedAngle({ one, other -> acos((on... | 1 | Kotlin | 1 | 6 | 2cbc7e60b3cd32f46a599878387857f738abda46 | 1,314 | linearalgebra | Do What The F*ck You Want To Public License |
src/Day04.kt | mattfrsn | 573,195,420 | false | {"Kotlin": 5703} | import java.io.File
fun main() {
fun part1(input: List<String>): Int {
val ranges = input.map { elfAssignments ->
elfAssignments.asRanges()
}
return ranges.count { it.first.fullyOverlaps(it.second) || it.second.fullyOverlaps(it.first) }
}
fun part2(input: List<String>):... | 0 | Kotlin | 0 | 0 | f17941024c1a2bac1cea88c3d9f6b7ecb9fd67e4 | 1,129 | kotlinAdvent2022 | Apache License 2.0 |
src/main/kotlin/io/rbrincke/dice/core/Solver.kt | rbrincke | 167,712,634 | false | {"Kotlin": 13146} | package io.rbrincke.dice.core
/**
* Sets up a solver that is able to find allocations of [labels] that lead to non-transitive
* elements. The number of resulting elements equals the size of [labelGroupSizes], and each
* element will contain precisely the number specified in [labelGroupSizes].
*
* @param labels la... | 0 | Kotlin | 0 | 0 | fc5aa0365d91ce360bf6e9c7589e3f5fc6bc8a82 | 2,273 | nontransitive-dice | MIT License |
src/main/kotlin/advent/Advent6.kt | v3rm0n | 225,866,365 | false | null | package advent
class Advent6 : Advent {
private fun orbits(input: List<String>) = input.map { it.split(')').let { (a, b) -> b to a } }.toMap()
override fun firstTask(input: List<String>) = orbits(input).let { orbits ->
orbits.values.map { planets(orbits, it).count() + 1 }.sum()
}
override fu... | 0 | Kotlin | 0 | 1 | 5c36cb254100f80a6e9c16adff5e7aadc8c9e98f | 943 | aoc2019 | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem17/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem17
/**
* LeetCode page: [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/);
*/
class Solution {
private val digitChars = mapOf(
'2' to "abc",
'3' to "def",
'4' to "ghi",
'5' to "j... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,450 | hj-leetcode-kotlin | Apache License 2.0 |
Retos/Reto #7 - EL SOMBRERO SELECCIONADOR [Media]/kotlin/malopezrom.kts | mouredev | 581,049,695 | false | {"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ... | package com.malopezrom.reto7
/*
* Crea un programa que simule el comportamiento del sombrero selccionador del
* universo mágico de <NAME>.
* - De ser posible realizará 5 preguntas (como mínimo) a través de la terminal.
* - Cada pregunta tendrá 4 respuestas posibles (también a selecciona una a través de terminal).
... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 7,756 | retos-programacion-2023 | Apache License 2.0 |
src/day03/Day03.kt | ritesh-singh | 572,210,598 | false | {"Kotlin": 99540} | package day03
import readInput
fun main() {
fun Char.priority() = if (isUpperCase()) this - 'A' + 27 else this - 'a' + 1
fun part1(input: List<String>): Int {
return input.sumOf { item ->
item.chunked(item.length / 2)
.map { it.toSet() }
.reduce { first, s... | 0 | Kotlin | 0 | 0 | 17fd65a8fac7fa0c6f4718d218a91a7b7d535eab | 738 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/sk/set0/91. Decode Ways.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set0
class Solution91 {
fun numDecodings(s: String): Int {
fun isValid(i: Int) = s[i] != '0'
fun isValid(i: Int, j: Int) = (s[i] != '0' && s.substring(i, j + 1).toInt() <= 26)
val dp = IntArray(s.length + 1) { -1 }
dp[0] = if (s[0] == '0') 0 else 1
fun ways(n... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,010 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/tr/emreone/adventofcode/days/Day04.kt | EmRe-One | 433,772,813 | false | {"Kotlin": 118159} | package tr.emreone.adventofcode.days
import tr.emreone.kotlin_utils.automation.Day
class Day04 : Day(4, 2021, "Giant Squid") {
class Field(var value: Int) {
var isMarked = false
}
class Board(lines: List<String>) {
val fields = Array(5) {
Array(5) {
Field(0)
... | 0 | Kotlin | 0 | 0 | 516718bd31fbf00693752c1eabdfcf3fe2ce903c | 3,846 | advent-of-code-2021 | Apache License 2.0 |
src/day01/Day01.kt | cmargonis | 573,161,233 | false | {"Kotlin": 15730} | package day01
import readInput
private const val DIRECTORY = "./day01"
fun main() {
fun getElves(input: List<String>): List<Elf> {
var calories = 0
val elves = mutableListOf<Elf>()
input.forEach {
if (it.isNotBlank()) {
calories += it.toInt()
} else... | 0 | Kotlin | 0 | 0 | bd243c61bf8aae81daf9e50b2117450c4f39e18c | 917 | kotlin-advent-2022 | Apache License 2.0 |
src/main/kotlin/solutions/day23/Day23.kt | Dr-Horv | 112,381,975 | false | null | package solutions.day23
import solutions.Solver
import utils.*
class Day23 : Solver {
override fun solve(input: List<String>, partTwo: Boolean): String {
if (partTwo) {
return doPartTwo()
}
val registers = mutableMapOf<String, Long>().withDefault { 0 }
val instructions... | 0 | Kotlin | 0 | 2 | 975695cc49f19a42c0407f41355abbfe0cb3cc59 | 2,558 | Advent-of-Code-2017 | MIT License |
src/day04/Day04.kt | commanderpepper | 574,647,779 | false | {"Kotlin": 44999} | package day04
import readInput
fun main (){
val dayFourInput = readInput("day04")
val ranges: List<Pair<IntRange,IntRange>> = dayFourInput.map { it.asRanges() }
println(ranges.count { it.first fullyOverlaps it.second || it.second fullyOverlaps it.first })
println(ranges.count { it.first overlaps it.s... | 0 | Kotlin | 0 | 0 | fef291c511408c1a6f34a24ed7070ceabc0894a1 | 987 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordBreak2.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 4,568 | kotlab | Apache License 2.0 |
src/search/ExponentialSearch.kt | daolq3012 | 143,137,563 | false | null | package search
import sort.HeapSort
import java.io.IOException
import java.util.*
class ExponentialSearch : SearchAlgorithms<Int> {
override fun findIndexOf(arr: ArrayList<Int>, value: Int): Int {
val size = arr.size
// If x is present at first location itself
if (arr[0] == value) {
... | 1 | Kotlin | 11 | 74 | 40e00d0d3f1c7cbb93ad28f4197e7ffa5ea36ef9 | 2,329 | Kotlin-Algorithms | Apache License 2.0 |
app/src/main/java/com/developersbreach/hangman/utils/GameDifficultyFilterUitls.kt | RajashekarRaju | 478,249,469 | false | {"Kotlin": 122892} | package com.developersbreach.hangman.utils
import com.developersbreach.hangman.repository.companyData
import com.developersbreach.hangman.repository.countryData
import com.developersbreach.hangman.repository.languageData
/**
* [EASY] -> Filters words of length 4 & 5.
* [MEDIUM] -> Filters words of length 6 & 7
* [... | 2 | Kotlin | 5 | 17 | d5181339eec841407bade176e7293fc65a4a3867 | 2,165 | hangman-compose | Apache License 2.0 |
src/day20/Day20.kt | ayukatawago | 572,742,437 | false | {"Kotlin": 58880} | package day20
import readInput
fun main() {
val input = readInput("day20/test")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Long {
return solve(input)
}
private fun part2(input: List<String>): Long {
return solve(input, 811589153, 10)
}
private fun solv... | 0 | Kotlin | 0 | 0 | 923f08f3de3cdd7baae3cb19b5e9cf3e46745b51 | 1,220 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/io/github/hc1839/crul/chemistry/species/Aggregate.kt | hc1839 | 724,383,874 | false | {"Kotlin": 541316} | /*
* Copyright <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... | 0 | Kotlin | 0 | 0 | 736b3c8377ca2f2f4a4e86fde6312e50b7ea2505 | 2,532 | crul | Apache License 2.0 |
Array/huangxinyu/kotlin/src/Solution.kt | JessonYue | 268,215,243 | false | null | import com.ryujin.algorithm.ListNode
class Solution {
/**
* 删除倒数第n个节点
*/
fun removeNthFromEnd(listNode: ListNode?, n: Int): ListNode? {
val preHead = ListNode(-1, listNode)
var p1 = listNode
var i = 0
while (i < n) {
assert(p1 != null)
p1 = p1!... | 0 | C | 19 | 39 | 3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79 | 3,805 | LeetCodeLearning | MIT License |
kotlin/src/com/s13g/aoc/aoc2019/Day16.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2019
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import kotlin.math.abs
/**
* --- Day 16: Flawed Frequency Transmission ---
* https://adventofcode.com/2019/day/16
*/
class Day16 : Solver {
override fun solve(lines: List<String>): Result {
val input = lines[0].map { "$it".toI... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,679 | euler | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.