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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query-tree/src/main/kotlin/name/djsweet/query/tree/IntervalTree.kt | djsweet | 719,705,276 | false | {"Kotlin": 724408, "Java": 3144} | // SPDX-FileCopyrightText: 2023 <NAME> <<EMAIL>>
//
// SPDX-License-Identifier: MIT
package name.djsweet.query.tree
import kotlin.NoSuchElementException
internal fun <T : Comparable<T>>compareRanges(leftLeft: T, leftRight: T, rightLeft: T, rightRight: T): Int {
val leftCompare = leftLeft.compareTo(rightLeft)
... | 5 | Kotlin | 0 | 0 | 023dd1f3cd231f9f62c7e349dd1f59079515364d | 37,104 | sidereal | MIT License |
src/Day01.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
check(part1(testInput) == 24000)
check(part2(testInput) == 45000)
val input = readInput("Day01")
println(part1(input))
println(part2(input))
}
private fun part1(input: ... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 867 | AOC2022 | Apache License 2.0 |
contents/thomas_algorithm/code/kotlin/thomas.kt | algorithm-archivists | 81,649,789 | false | {"Python": 61641, "Assembly": 60055, "C++": 56073, "Julia": 54791, "C": 49744, "Java": 40529, "Rust": 36123, "C#": 26237, "Haskell": 21852, "Common Lisp": 20798, "JavaScript": 18939, "TeX": 14910, "Go": 13136, "PHP": 9196, "Elm": 9135, "Clojure": 8693, "Fortran": 8124, "Gnuplot": 7573, "Swift": 7229, "OCaml": 7226, "Sc... | private fun thomas(a: DoubleArray, b: DoubleArray, c: DoubleArray, d: DoubleArray): DoubleArray {
val cPrime = c.clone()
val x = d.clone()
val size = a.size
cPrime[0] /= b[0]
x[0] /= b[0]
for (i in 1 until size) {
val scale = 1.0 / (b[i] - cPrime[i - 1] * a[i])
cPrime[i] *= scale... | 98 | Python | 390 | 2,240 | 38c40e075d8a454f97aca03624d4ce398d16470a | 1,072 | algorithm-archive | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem947/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem947
/**
* LeetCode page: [947. Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(N) where N is the size of stones;
*/
fun removeSt... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,599 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day07.kt | dirkgroot | 317,968,017 | false | {"Kotlin": 187862} | package nl.dirkgroot.adventofcode.year2020
import nl.dirkgroot.adventofcode.util.Input
import nl.dirkgroot.adventofcode.util.Puzzle
class Day07(input: Input) : Puzzle() {
private val rules by lazy { parseBagRules(input.lines()) }
private fun parseBagRules(input: List<String>) = input.map(this::parseBagRule).... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 1,451 | adventofcode-kotlin | MIT License |
calendar/day07/Day7.kt | maartenh | 572,433,648 | false | {"Kotlin": 50914} | package day07
import Day
import Lines
class Day7 : Day() {
override fun part1(input: Lines): Any {
val fsTree = buildFS(input)
return fsTree.allDirectories
.map(Directory::size)
.filter { it <= 100_000 }
.sum()
}
override fun part2(input: Lines): Any {... | 0 | Kotlin | 0 | 0 | 4297aa0d7addcdc9077f86ad572f72d8e1f90fe8 | 2,646 | advent-of-code-2022 | Apache License 2.0 |
src/questions/DivideTwoIntegers.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import algorithmdesignmanualbook.print
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.test.assertEquals
/**
* Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod oper... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 2,207 | algorithms | MIT License |
kotlin/src/katas/kotlin/adventofcode/day2/Part1.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.adventofcode.day2
import nonstdlib.*
import java.io.*
fun main() {
val text = File("src/katas/kotlin/adventofcode/day2/input.txt").readText()
val program = text.split(",").map(String::toInt).toMutableList()
println(execute(ArrayList(program), programInput1 = 12, programInput2 = 2))
}
... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 1,911 | katas | The Unlicense |
src/Day01.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} | fun main() {
fun getSumOfCalories(input: List<String>): List<Int> = input.fold(mutableListOf(0)) { acc, line ->
when {
line.isBlank() -> acc.add(0)
else -> acc[acc.lastIndex] += line.toInt()
}
return@fold acc
}
fun part1(input: List<String>): Int = getSumOfCa... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 676 | advent-of-code-2022 | Apache License 2.0 |
libraries/formula/src/FormulaParser.kt | featurea | 407,517,337 | false | null | package featurea.formula
private const val operatorSymbols = "+-*/<=>"
fun Char.isOperatorSymbol() = operatorSymbols.contains(this)
val operatorMap = mapOf<String, () -> FormulaOperator<*, *, *>>(
"+" to { Plus() },
"-" to { Minus() },
"*" to { Multiply() },
"/" to { Divide() },
... | 30 | Kotlin | 1 | 6 | 07074dc37a838f16ece90c19a4e8d45e743013d3 | 1,372 | engine | MIT License |
src/main/kotlin/tr/emreone/adventofcode/days/Day07.kt | EmRe-One | 568,569,073 | false | {"Kotlin": 166986} | package tr.emreone.adventofcode.days
import tr.emreone.kotlin_utils.Logger.logger
import tr.emreone.kotlin_utils.extensions.times
object Day07 {
enum class NodeType {
UNKNOWN,
DIRECTORY,
FILE
}
class FileSystem() {
val root = Node(null, "", NodeType.DIRECTORY)
var... | 0 | Kotlin | 0 | 0 | a951d2660145d3bf52db5cd6d6a07998dbfcb316 | 6,217 | advent-of-code-2022 | Apache License 2.0 |
src/day01/Day01.kt | Raibaz | 571,997,684 | false | {"Kotlin": 9423} | fun main() {
fun computeCalories(input: List<String>): MutableMap<Int, Int> {
val calories = mutableMapOf<Int, Int>()
var elfIndex = 0
input.forEach {
if (it.isEmpty()) {
elfIndex++
} else {
var currentCalories = calories[elfIndex] ?: 0... | 0 | Kotlin | 0 | 0 | 99d912f661bd3545ca9ff222ac7d93c12682f42d | 952 | aoc-22 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/PowerOfThree.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,663 | kotlab | Apache License 2.0 |
src/main/kotlin/days/Day10.kt | butnotstupid | 433,717,137 | false | {"Kotlin": 55124} | package days
import java.util.*
class Day10 : Day(10) {
private val closes = mapOf(
'(' to ')', '[' to ']',
'{' to '}', '<' to '>',
)
private val errorPoints = mapOf(')' to 3, ']' to 57, '}' to 1197, '>' to 25137)
private val completionPoints = mapOf(')' to 1, ']' to 2, '}' to 3, '>' t... | 0 | Kotlin | 0 | 0 | a06eaaff7e7c33df58157d8f29236675f9aa7b64 | 1,609 | aoc-2021 | Creative Commons Zero v1.0 Universal |
year2023/day05/almanac/src/main/kotlin/com/curtislb/adventofcode/year2023/day05/almanac/Almanac.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | package com.curtislb.adventofcode.year2023.day05.almanac
import com.curtislb.adventofcode.common.io.forEachSection
import com.curtislb.adventofcode.common.parse.parseLongs
import java.io.File
/**
* A copy of the Island Island Almanac, which contains [CategoryMap]s for converting integer values
* between various cat... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 4,109 | AdventOfCode | MIT License |
src/main/kotlin/Day14.kt | SimonMarquis | 570,868,366 | false | {"Kotlin": 50263} | import kotlin.math.max
import kotlin.math.min
class Day14(input: List<String>) {
private val simulation = Simulation(input.walls())
fun part1(): Long = simulation.apply {
while (simulatePart1().not()) Unit
}.iterations.dec()
fun part2(): Long = simulation.apply {
while (simulatePart2... | 0 | Kotlin | 0 | 0 | a2129cc558c610dfe338594d9f05df6501dff5e6 | 3,603 | advent-of-code-2022 | Apache License 2.0 |
src/main/aoc2020/Day1.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2020
class Day1(input: List<String>) {
// Most of the entries in the input will go past 2020 when summed
// so sort the list to start with smaller numbers to find the solution faster
private val entries = input.map { it.toInt() }.sorted()
fun solve(partOne: Boolean = false, partTwo: Boolea... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,432 | aoc | MIT License |
src/Day11.kt | fmborghino | 573,233,162 | false | {"Kotlin": 60805} | // 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
// round is all monkeys act on all items
// each item ALSO gets divide by 3 and round down before action
// new items go to the end of the list
//
// count n... | 0 | Kotlin | 0 | 0 | 893cab0651ca0bb3bc8108ec31974654600d2bf1 | 5,263 | aoc2022 | Apache License 2.0 |
src/Day03.kt | Hotkeyyy | 573,026,685 | false | {"Kotlin": 7830} | import java.io.File
fun main() {
val lowerCase = ('a'..'z').toList()
val upperCase = ('A'..'Z').toList()
fun part1(input: String) {
var result = 0
input.split("\r").map { it.trim() }.forEach {
val firstCompartment = it.substring(0, it.length / 2)
val secondCompartm... | 0 | Kotlin | 0 | 0 | dfb20f1254127f99bc845e9e13631c53de8784f2 | 1,505 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/tree/bintree/LCS.kt | yx-z | 106,589,674 | false | null | package tree.bintree
import util.get
import util.prettyPrintTree
import util.set
import java.util.*
// given two binary trees A and B, find a largest common subtree between them
// here we only care about their tree structure so no need to compare data
// return the root of this subtree in A
fun BinTreeNode<Int>.lst(... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 4,048 | AlgoKt | MIT License |
2022/Day22/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
enum class Direction {
RIGHT,
DOWN,
LEFT,
UP
}
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
var map = createMap(lines)
var path = getPath(lines)
println(problem1(map, path))
println(problem2(map, path))
}
fun createMap(lines: List<Strin... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 6,546 | AdventOfCode | MIT License |
src/Day01.kt | Virendra115 | 573,122,699 | false | {"Kotlin": 2427} | import java.util.Collections.sort
import java.util.Comparator
fun main() {
fun part1(input: String): Int {
val list = input.split("\r\n\r\n").map { a -> a.split("\r\n").sumOf { it.toInt() } }
return list.max()
}
fun part2(input: String): Int {
val list = input.split("\r\n\r\n").map... | 0 | Kotlin | 0 | 0 | 44aff316ffe08d27d23f2f2d8ce7d027a0e64ff8 | 707 | AdventOfCode-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/sk/set0/77. Combinations.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set0
class Solution77 {
fun combine(n: Int, k: Int): List<List<Int>> {
val result = ArrayList<ArrayList<Int>>()
combine(1, n, k, ArrayList(), result)
return result
}
private fun combine(start: Int, end: Int, k: Int, list: ArrayList<Int>, result: ArrayList<ArrayList<... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,003 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2021/Day02.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 2 - Dive!
* Problem Description: http://adventofcode.com/2021/day/2
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day2/
*/
package com.ginsberg.advent2021
class Day02(input: List<String>) {
private val commands... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 1,739 | advent-2021-kotlin | Apache License 2.0 |
codeforces/round572/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.round572
private const val M = 998244353
private fun solve() {
val (n, m) = readInts()
val a = readInts().sorted()
val maxDiff = (a.last() - a.first()) / (m - 1)
val d = Array(m) { IntArray(n + 1) }
var ans = 0
for (diff in 1..maxDiff) {
var iPrev = 0
for (i in a.indices) {
while (a[i]... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,064 | competitions | The Unlicense |
solutions/src/solutions/y20/day 20.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.y20.d20
import grid.Clock
import helpers.*
val xxxxx = Clock(6, 3);
private fun part1(data: Data) {
val tiles = data.splitOn { it.isBlank() }.filter { it.isNotEmpty() }.map {
val id = it.first().getInt()
val shape = it.drop(1)
id to shape
}.toMap(... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 7,883 | AdventOfCodeSolutions | MIT License |
src/main/java/com/barneyb/aoc/aoc2022/day04/CampCleanup.kt | barneyb | 553,291,150 | false | {"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020} | package com.barneyb.aoc.aoc2022.day04
import com.barneyb.aoc.util.*
fun main() {
Solver.execute(
::parse,
::countContained,
::countOverlapping
)
}
typealias Assignment = IntRange
typealias PairsOfAssignments = List<Pair<Assignment, Assignment>>
fun countContained(pairs: PairsOfAssign... | 0 | Kotlin | 0 | 0 | 8b5956164ff0be79a27f68ef09a9e7171cc91995 | 1,111 | aoc-2022 | MIT License |
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/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": ... | import java.util.*
/*
* Escribe un programa que reciba un texto y transforme lenguaje natural a
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje
* se caracteriza por sustituir caracteres alfanuméricos.
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/)
* ... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 2,192 | retos-programacion-2023 | Apache License 2.0 |
modules/core/src/main/kotlin/datamaintain/core/step/sort/ByCaseInsensitiveSeparatorFreeAlphabeticalSortingStrategy.kt | fbreuneval | 341,502,205 | true | {"Kotlin": 121123, "JavaScript": 533} | package datamaintain.core.step.sort
import datamaintain.core.script.Script
/**
* Allow to sort scripts considering the parts of the value returned by the getter.
* The parts list is given by a split on all chars that are not a figure or a letter.
* The number parts would be sorted as number, and the others as stri... | 0 | Kotlin | 0 | 0 | c1856e0ec9bc4fe54717c94a74e16b80a03d1319 | 2,572 | datamaintain | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem985/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem985
/**
* LeetCode page: [985. Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries/);
*/
class Solution {
/* Complexity:
* Time O(N+M) and Aux_Space O(N) where N and M are the size of nums and queries;
*/
fun sumEv... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,113 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/Connect.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
import java.util.*
/**
* 116. 填充每个节点的下一个右侧节点指针
*
* 给定一个完美二叉树,其所有叶子节点都在同一层,每个父节点都有两个子节点。
* 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。
*
* 初始状态下,所有next 指针都被设置为 NULL。
*/
class Connect {
companion object {
@JvmStatic
fun main(args: Arra... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 2,874 | daily_algorithm | Apache License 2.0 |
src/Day06.kt | JCampbell8 | 572,669,444 | false | {"Kotlin": 10115} | fun main() {
fun String.allUnique(): Boolean = all(hashSetOf<Char>()::add)
fun detectPacketMarker(packet: String, distinct: Int): Int {
val marker = packet.toList().windowed(distinct, 1).first {
it.joinToString("").allUnique()
}
return packet.indexOf(marker.joinToString(""... | 0 | Kotlin | 0 | 1 | 0bac6b866e769d0ac6906456aefc58d4dd9688ad | 809 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day2.kt | sicruse | 434,002,213 | false | {"Kotlin": 29921} | package days
import kotlin.math.absoluteValue
class Day2 : Day(2) {
private val course: List<Instruction> by lazy { inputList.map { code -> Instruction.fromText(code) } }
data class Instruction(val maneuver: Maneuver, val amount: Int) {
companion object {
fun fromText(code: String): Inst... | 0 | Kotlin | 0 | 0 | 172babe6ee67a86a7893f8c9c381c5ce8e61908e | 3,077 | aoc-kotlin-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/Utils.kt | brigham | 573,127,412 | false | {"Kotlin": 59675} | import java.io.File
import java.util.*
import kotlin.collections.ArrayDeque
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src/main/kotlin", "$name.txt")
.also { it.createNewFile() }
.readLines()
fun slurp(name: String): String = File("src/main/kotlin", "$name.txt")
... | 0 | Kotlin | 0 | 0 | b87ffc772e5bd9fd721d552913cf79c575062f19 | 2,327 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2022/solution/day_11.kt | dangerground | 579,293,233 | false | {"Kotlin": 51472} | package adventofcode2022.solution
import adventofcode2022.util.readDay
import java.lang.Long.max
fun main() {
Day11("11").solve()
}
class Day11(private val num: String) {
private val inputText = readDay(num)
fun solve() {
println("Day $num Solution")
println("* Part 1: ${solution1()}")
... | 0 | Kotlin | 0 | 0 | f1094ba3ead165adaadce6cffd5f3e78d6505724 | 5,012 | adventofcode-2022 | MIT License |
src/main/kotlin/euler/Problem5.kt | SackCastellon | 575,340,524 | false | {"Kotlin": 21403} | package euler
import kotlin.math.max
/**
* [#5 Smallest multiple - Project Euler](https://projecteuler.net/problem=5)
*/
object Problem5 : Problem<Int> {
override fun solve(): Int {
return (2..20)
.flatMap { it.primeFactors().groupingBy { it }.eachCount().toList() }
.fold(mutable... | 0 | Kotlin | 0 | 0 | ac2e95b9d3fa09673b9c7a86f1086a759384190a | 894 | project-euler | Apache License 2.0 |
usvm-util/src/main/kotlin/org/usvm/UMachineOptions.kt | UnitTestBot | 586,907,774 | false | {"Kotlin": 2547205, "Java": 471958} | package org.usvm
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
enum class SolverType {
YICES,
Z3
}
enum class PathSelectionStrategy {
/**
* Selects the states in depth-first order.
*/
DFS,
/**
* Selects... | 39 | Kotlin | 0 | 7 | 94c5a49a0812737024dee5be9d642f22baf991a2 | 7,212 | usvm | Apache License 2.0 |
control-core/src/commonMain/kotlin/com.github.oleather.core/geometry/Circle.kt | OLeather | 313,396,280 | false | null | package com.github.oleather.core.geometry
import com.soywiz.korma.geom.Point
import kotlin.math.abs
import kotlin.math.sqrt
public class Circle public constructor(public val radius: Double, public val center: Point) {
//https://cp-algorithms.com/geometry/circle-line-intersection.html
public fun intersection(... | 0 | Kotlin | 0 | 0 | 175a700665d3549539f14dec7ae420747d99f303 | 1,986 | control-theory | MIT License |
src/main/kotlin/tr/emreone/kotlin_utils/extensions/Collections.kt | EmRe-One | 442,916,831 | false | {"Kotlin": 173543} | package tr.emreone.kotlin_utils.extensions
import kotlin.math.max
import kotlin.math.min
/**
*
* @receiver MutableList<Pair<String, Long>>
* @param from MutableList<Pair<String, Long>>
* @param deep Boolean
*/
fun MutableList<Pair<String, Long>>.copy(from: MutableList<Pair<String, Long>>, deep: Boolean = false)... | 0 | Kotlin | 0 | 0 | aee38364ca1827666949557acb15ae3ea21881a1 | 13,040 | kotlin-utils | Apache License 2.0 |
src/day01/Day01.kt | TimberBro | 572,681,059 | false | {"Kotlin": 20536} | package day01
import readInput
import separateInputByEmptyLine
import kotlin.streams.toList
fun main() {
fun part1(input: List<String>): Int {
val inputByEmptyLine = separateInputByEmptyLine(input)
val maxValue = inputByEmptyLine
.stream()
.map {
it.stream... | 0 | Kotlin | 0 | 0 | 516a98e5067d11f0e6ff73ae19f256d8c1bfa905 | 1,146 | AoC2022 | Apache License 2.0 |
src/questions/PlusOne.kt | realpacific | 234,499,820 | false | null | package questions
import utils.assertIterableSame
/**
* You are given a large integer represented as an integer array digits, where each digits[i]
* is the ith digit of the integer. The digits are ordered from most significant to least
* significant in left-to-right order. The large integer does not contain any le... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,933 | algorithms | MIT License |
src/main/kotlin/g0901_1000/s0913_cat_and_mouse/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0901_1000.s0913_cat_and_mouse
// #Hard #Dynamic_Programming #Math #Graph #Memoization #Topological_Sort #Game_Theory
// #2023_04_16_Time_211_ms_(100.00%)_Space_37.1_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
class Solution {
fun catMouseGame(graph: Array<IntArray>): Int {
va... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,785 | LeetCode-in-Kotlin | MIT License |
src/Day01.kt | iartemiev | 573,038,071 | false | {"Kotlin": 21075} | fun main() {
fun reduceInput(input: List<String>): List<Int> {
val calTotals: MutableList<Int> = mutableListOf(0)
for (line in input) {
if (line.isEmpty()) {
calTotals.add(0)
} else {
val cal = Integer.parseInt(line)
calTotals[calTotals.size - 1] += cal
}
}
... | 0 | Kotlin | 0 | 0 | 8d2b7a974c2736903a9def65282be91fbb104ffd | 776 | advent-of-code | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions52.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import com.qiaoyuang.algorithm.round0.Stack
fun test52() {
val (header1, header2) = testData1()
printlnResult(header1, header2)
}
/**
* Questions 52: Find the first public node on two linked lists
*/
private fun <T> findFirstPublicNode(header1: SingleDirectionNode<T>,... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 2,205 | Algorithm | Apache License 2.0 |
Bootcamp_00/src/exercise2/src/main/kotlin/Main.kt | Hasuk1 | 740,111,124 | false | {"Kotlin": 120039} | fun main() {
try {
val order = readOrder()
val inputNumber = readInputNumber()
val numberSet = createNumberSet(inputNumber, order)
checkForPrimes(numberSet)
} catch (e: Exception) {
println("Error: ${e.message}")
}
}
fun readOrder(): Boolean {
try {
print("The grouping order is (lower o... | 0 | Kotlin | 0 | 1 | 1dc4de50dd3cd875e3fe76e3da4a58aa04bb87c7 | 1,947 | Kotlin_bootcamp | MIT License |
src/main/kotlin/fp/kotlin/example/chapter09/solution/9_10_FunListMonoidWithFoldable.kt | funfunStory | 101,662,895 | false | null | package fp.kotlin.example.chapter09.solution
import fp.kotlin.example.chapter09.Foldable
import fp.kotlin.example.chapter09.SumMonoid
/**
*
* 연습문제 9-10
*
* 리스트 모노이드를 ``Foldable`` 타입 클래스의 인스턴스로 만들어서 ``foldLeft`` 함수를 작성하고, ``foldMap`` 함수를 테스트해 보자.
*/
fun main() {
val list1 = Cons(1, Cons(2, Cons(3, Cons(4, Ni... | 1 | Kotlin | 23 | 39 | bb10ea01d9f0e1b02b412305940c1bd270093cb6 | 924 | fp-kotlin-example | MIT License |
leetcode/src/tree/Offer28.kt | zhangweizhe | 387,808,774 | false | null | package tree
import linkedlist.TreeNode
import java.util.*
fun main() {
// 剑指 Offer 28. 对称的二叉树
// https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/
val root = TreeNode(1)
root.left = TreeNode(2)
root.right = TreeNode(2)
root.left?.left = TreeNode(3)
root.left?.right = TreeNode... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 2,880 | kotlin-study | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions17.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
fun test17() {
println1toBiggest(1u)
println1toBiggest(2u)
println1toBiggest(3u)
printlnResult2("123456", "5678")
printlnResult2("9999999", "1")
printlnResult2("5555", "5555")
printlnResult2("0", "0")
printlnResult2("-123456", "-5678")
println... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 5,623 | Algorithm | Apache License 2.0 |
src/year_2023/day_16/Day16.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2023.day_16
import readInput
import util.*
interface Mirror {
fun reflect(fromDirection: Direction): Direction
}
object ForwardSlash: Mirror {
override fun reflect(fromDirection: Direction): Direction {
return when (fromDirection) {
Direction.NORTH -> Direction.EAST
... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 6,214 | advent_of_code | Apache License 2.0 |
src/main/kotlin/me/grison/aoc/y2021/Day09.kt | agrison | 315,292,447 | false | {"Kotlin": 267552} | package me.grison.aoc.y2021
import me.grison.aoc.*
import kotlin.Int.Companion.MAX_VALUE
class Day09 : Day(9, 2021) {
override fun title() = "Smoke Basin"
private var dimensions = p(0, 0)
private val grid = loadGrid()
override fun partOne() =
gridPositions(dimensions)
.map { pos ... | 0 | Kotlin | 3 | 18 | ea6899817458f7ee76d4ba24d36d33f8b58ce9e8 | 1,244 | advent-of-code | Creative Commons Zero v1.0 Universal |
app/src/main/java/com/pr0gramm/app/services/Graph.kt | mopsalarm | 30,804,448 | false | {"Kotlin": 1404981, "Shell": 6752, "Python": 1124} | package com.pr0gramm.app.services
/**
* A simple graph of double values.
*/
data class Graph(val firstX: Double, val lastX: Double, val points: List<Graph.Point>) {
constructor(points: List<Graph.Point>) : this(points.first().x, points.last().x, points)
val range = firstX.rangeTo(lastX)
val first get... | 28 | Kotlin | 41 | 281 | 6e974f9a1ea188e9fcdd2ebde8faf976311772f4 | 2,157 | Pr0 | MIT License |
src/main/kotlin/_2019/Day13.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2019
import aocRun
fun main() {
aocRun(puzzleInput) { input ->
val computer = IntcodeComputer(input).apply { printOut = false }
val screen = runGame(computer)
printScreen(screen)
return@aocRun screen.numBlocks
}
aocRun(puzzleInput) { input ->
val computer ... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 9,802 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/day15/Day15.kt | Ciel-MC | 572,868,010 | false | {"Kotlin": 55885} | package day15
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import readInput
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
... | 0 | Kotlin | 0 | 0 | 7eb57c9bced945dcad4750a7cc4835e56d20cbc8 | 5,208 | Advent-Of-Code | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2021/Day07.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 7 - The Treachery of Whales
* Problem Description: http://adventofcode.com/2021/day/7
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day7/
*/
package com.ginsberg.advent2021
import kotlin.math.absoluteValue
class Da... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 954 | advent-2021-kotlin | Apache License 2.0 |
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day25/Day25.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.day25
import nl.sanderp.aoc.common.*
private typealias Grid = Map<Point2D, Char>
fun main() {
val input = readResource("Day25.txt").lines().flatMapIndexed { y, row ->
row.mapIndexed { x, c -> Point2D(x, y) to c }
}.toMap()
val width = input.maxOf { it.key.x } + 1
... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 1,239 | advent-of-code | MIT License |
src/main/kotlin/com/sk/set2/279. Perfect Squares.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set2
class Solution279 {
fun numSquares(n: Int): Int {
val dp = IntArray(n + 1) { Int.MAX_VALUE }
dp[0] = 0
for (i in 1..n) {
var min = Int.MAX_VALUE
var j = 1
while (i - j * j >= 0) {
min = minOf(min, dp[i - j * j] + 1)
... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 1,053 | leetcode-kotlin | Apache License 2.0 |
leetcode/src/linkedlist/Q206.kt | zhangweizhe | 387,808,774 | false | null | package linkedlist
import linkedlist.kt.ListNode
fun main() {
// 206. 反转链表
// https://leetcode-cn.com/problems/reverse-linked-list/
val createList = LinkedListUtil.createList(intArrayOf(1, 2, 3, 4, 5))
LinkedListUtil.printLinkedList(reverseList(createList))
}
/**
* 反转链表,返回一个新的链表
*/
fun reverseList1... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 1,599 | kotlin-study | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day17.kt | clechasseur | 435,726,930 | false | {"Kotlin": 315943} | package io.github.clechasseur.adventofcode2021
import io.github.clechasseur.adventofcode2021.util.Pt
import kotlin.math.max
object Day17 {
private val targetArea = object {
val x = 175..227
val y = -134..-79
}
fun part1(): Int {
val xVelocity = findXVelocity()
val highY = ... | 0 | Kotlin | 0 | 0 | 4b893c001efec7d11a326888a9a98ec03241d331 | 1,681 | adventofcode2021 | MIT License |
year2019/day14/part2/src/main/kotlin/com/curtislb/adventofcode/year2019/day14/part2/Year2019Day14Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
After collecting ORE for a while, you check your cargo hold: 1 trillion (1000000000000) units of
ORE.
With that much ore, given the examples above:
- The 13312 ORE-per-FUEL example could produce 82892753 FUEL.
- The 180697 ORE-per-FUEL example could produce 5586022 FUEL.
- The 2210736 ORE-per-FUE... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,094 | AdventOfCode | MIT License |
src/main/aoc2023/Day6.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2023
class Day6(input: List<String>) {
private data class Race(val time: Int, val distance: Long)
private val races: List<Race>
private val race2: Race
init {
races = buildList {
val times = input.first().substringAfter(":").trim().split("\\s+".toRegex())
v... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,280 | aoc | MIT License |
src/main/java/challenges/coderbyte/StringReduction.kt | ShabanKamell | 342,007,920 | false | null | package challenges.coderbyte
/*
Have the function StringReduction(str) take the str parameter being passed and return the smallest
number you can get through the following reduction method. The method is: Only the letters a, b, and c
will be given in str and you must take two different adjacent characters and replace ... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 1,950 | CodingChallenges | Apache License 2.0 |
src/main/kotlin/tr/emreone/kotlin_utils/data_structures/GraphSearch.kt | EmRe-One | 442,916,831 | false | {"Kotlin": 173543} | package tr.emreone.kotlin_utils.data_structures
import java.util.*
import kotlin.collections.ArrayDeque
enum class SearchControl { STOP, CONTINUE }
typealias DebugHandler<N> = (level: Int, nodesOnLevel: Collection<N>, nodesVisited: Collection<N>) -> SearchControl
typealias SolutionPredicate<N> = (node: N) -> Boolean... | 0 | Kotlin | 0 | 0 | aee38364ca1827666949557acb15ae3ea21881a1 | 13,142 | kotlin-utils | Apache License 2.0 |
src/Day01.kt | rinas-ink | 572,920,513 | false | {"Kotlin": 14483} | fun main() {
fun getSetOfElves(input: List<String>): List<Int> {
val elves = mutableListOf<Int>();
var last = 0
for (i in input) {
try {
last += i.toInt()
} catch (_: NumberFormatException) {
elves.add(last)
last = 0
... | 0 | Kotlin | 0 | 0 | 462bcba7779f7bfc9a109d886af8f722ec14c485 | 945 | anvent-kotlin | Apache License 2.0 |
src/Day08.kt | RickShaa | 572,623,247 | false | {"Kotlin": 34294} | import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.math.sign
fun main() {
val fileName = "day08.txt"
val testFileName = "day08_test.txt"
val input = FileUtil.getListOfLines(fileName);
val trees = input.map { it -> it.toCharArray().map { it.toString().toInt() } }
//PART1
f... | 0 | Kotlin | 0 | 1 | 76257b971649e656c1be6436f8cb70b80d5c992b | 5,061 | aoc | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2015/Day11.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2015
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 11: Corporate Policy](https://adventofcode.com/2015/day/11).
*/
object Day11 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val input = readInput("year2015/Day11"... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 1,750 | advent-of-code | MIT License |
src/main/kotlin/d7_TheTreacheryOfWhales/TheTreacheryOfWhales.kt | aormsby | 425,644,961 | false | {"Kotlin": 68415} | package d7_TheTreacheryOfWhales
import util.Input
import util.Output
import kotlin.math.abs
import kotlin.math.min
import kotlin.math.roundToInt
fun main() {
Output.day(7, "The Treachery of Whales")
val startTime = Output.startTime()
val crabmarines = Input.parseToListOf<Int>(
rawData = Input.par... | 0 | Kotlin | 1 | 1 | 193d7b47085c3e84a1f24b11177206e82110bfad | 1,414 | advent-of-code-2021 | MIT License |
src/main/kotlin/aoc/Graph.kt | w8mr | 572,700,604 | false | {"Kotlin": 140954} | package aoc
import java.util.*
interface GraphNode<T> {
val neighbours: List<Pair<Int, GraphNode<T>>>
val value: T
}
fun <T> findShortestPaths(node: GraphNode<T>): MutableMap<GraphNode<T>, Pair<Int, GraphNode<T>?>> {
val shortestPaths = mutableMapOf<GraphNode<T>, Pair<Int, GraphNode<T>?>>()
val toIns... | 0 | Kotlin | 0 | 0 | e9bd07770ccf8949f718a02db8d09daf5804273d | 1,429 | aoc-kotlin | Apache License 2.0 |
src/main/kotlin/Day05.kt | AlmazKo | 576,500,782 | false | {"Kotlin": 26733} | import java.util.Deque
import java.util.LinkedList
import java.util.SortedMap
import java.util.TreeMap
object Day05 : Task {
@JvmStatic
fun main(args: Array<String>) = execute()
override fun part1(input: Iterable<String>): Any {
val stacks = parseCrates(input)
parseCommands(input).forEach... | 0 | Kotlin | 0 | 1 | 109cb10927328ce296a6b0a3600edbc6e7f0dc9f | 2,112 | advent2022 | MIT License |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day3/Day3Puzzle2.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day3
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
class Day3Puzzle2 : PuzzleSolver {
override fun solve(inputLines: Sequence<String>) = lifeSupportRating(inputLines).toString();
private fun lifeSupportRating(diagnosticReport: Seque... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 1,472 | AdventOfCode2021 | Apache License 2.0 |
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day04.kt | mpichler94 | 656,873,940 | false | {"Kotlin": 196457} | package at.mpichler.aoc.solutions.year2021
import at.mpichler.aoc.lib.Day
import at.mpichler.aoc.lib.PartSolution
import org.jetbrains.kotlinx.multik.api.mk
import org.jetbrains.kotlinx.multik.api.zeros
import org.jetbrains.kotlinx.multik.ndarray.data.D2Array
import org.jetbrains.kotlinx.multik.ndarray.data.get
import... | 0 | Kotlin | 0 | 0 | 69a0748ed640cf80301d8d93f25fb23cc367819c | 3,885 | advent-of-code-kotlin | MIT License |
src/Day03.kt | jgodort | 573,181,128 | false | null | const val LOWERCASE_DIFFERENCE = 96
const val UPPERCASE_DIFFERENCE = 38
fun main() {
val inputData = readInput("Day3_input")
println(day3Part1(inputData))
println(day3Part2(inputData))
}
fun day3Part1(input: String): Int = input.lines().map { line ->
val content = line.toList()
val rucksacks = cont... | 0 | Kotlin | 0 | 0 | 355f476765948c79bfc61367c1afe446fe9f6083 | 880 | aoc2022Kotlin | Apache License 2.0 |
aoc-2015/src/main/kotlin/nl/jstege/adventofcode/aoc2015/days/Day21.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2015.days
import nl.jstege.adventofcode.aoccommon.days.Day
/**
*
* @author <NAME>
*/
class Day21 : Day(title = "RPG Simulator 20XX") {
private companion object Configuration {
private val ITEMS = listOf(
8 to Item.Weapon(4),
10 to Item.Weapon(5)... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 4,331 | AdventOfCode | MIT License |
src/main/kotlin/_0064_MinimumPathSum.kt | ryandyoon | 664,493,186 | false | null | import kotlin.math.min
// https://leetcode.com/problems/minimum-path-sum
fun minPathSum(grid: Array<IntArray>): Int {
val lastRow = grid.lastIndex
val lastCol = grid.first().lastIndex
val memo = Array(lastRow + 1) { IntArray(lastCol + 1) }
memo[lastRow][lastCol] = grid[lastRow][lastCol]
for (row in... | 0 | Kotlin | 0 | 0 | 7f75078ddeb22983b2521d8ac80f5973f58fd123 | 757 | leetcode-kotlin | MIT License |
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day08.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2018.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.extensions.head
class Day08 : Day(title = "Memory Maneuver") {
override fun first(input: Sequence<String>): Any =
input.head
.parse()
.sumMetad... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 1,705 | AdventOfCode | MIT License |
06/06.kt | Steve2608 | 433,779,296 | false | {"Python": 34592, "Julia": 13999, "Kotlin": 11412, "Shell": 349, "Cython": 211} | import java.io.File
const val resetDays = 6
const val newbornDays = 8
private class Population(data: IntArray) : Iterable<MutableMap.MutableEntry<Int, Long>> {
constructor() : this(IntArray(0))
private val populationCount: MutableMap<Int, Long> = HashMap()
val nFish: Long
get() = populationCount.values.sum()
... | 0 | Python | 0 | 1 | 2dcad5ecdce5e166eb053593d40b40d3e8e3f9b6 | 1,545 | AoC-2021 | MIT License |
src/commonMain/kotlin/advent2020/day09/Day09Puzzle.kt | jakubgwozdz | 312,526,719 | false | null | package advent2020.day09
import advent2020.ProgressLogger
internal fun String.parsedData() = trim().lines().map(String::toLong)
fun valid(preamble: List<Long>, expectedSum: Long): Boolean {
val sortedPreamble = preamble.sorted()
var startIndex = 0
var endIndex = sortedPreamble.lastIndex
while (star... | 0 | Kotlin | 0 | 2 | e233824109515fc4a667ad03e32de630d936838e | 2,836 | advent-of-code-2020 | MIT License |
UncommonWordsFromTwoSentences.kt | ncschroeder | 604,822,497 | false | {"Kotlin": 19399} | /*
https://leetcode.com/problems/uncommon-words-from-two-sentences/
A sentence is a string of single-space separated words where each word consists only of lowercase letters.
A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.
Given two sentences `s1` and... | 0 | Kotlin | 0 | 0 | c77d0c8bb0595e61960193fc9b0c7a31952e8e48 | 1,544 | Coding-Challenges | MIT License |
src/test/kotlin/Day17.kt | christof-vollrath | 317,635,262 | false | null | import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.collections.shouldBeIn
import io.kotest.matchers.collections.shouldNotBeIn
import io.kotest.matchers.shouldBe
/*
--- Day 17: Conway Cubes ---
See https://adventofcode.com/2020/day/17
*/
fun Map<Coord3, Char>.cycle(): Map<Coord3, Char> {
val sur... | 1 | Kotlin | 0 | 0 | 8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8 | 11,422 | advent_of_code_2020 | Apache License 2.0 |
src/algorithmdesignmanualbook/sorting/MergeSort.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.sorting
import utils.assertArraysSame
import java.util.*
private fun mergeSort(array: IntArray, low: Int, high: Int) {
if (array.isEmpty()) {
return
}
// WARNING: if statement and not while
if (low < high) {
val mid = (low + high) / 2
// break ... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,841 | algorithms | MIT License |
src/lib/lib.kt | somei-san | 476,528,544 | false | {"Kotlin": 12475} | package lib
import java.util.*
// 約数のList
fun divisor(value: Long): List<Long> {
val max = Math.sqrt(value.toDouble()).toLong()
return (1..max)
.filter { value % it == 0L }
.map { listOf(it, value / it) }
.flatten()
.sorted()
}
// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun pr... | 0 | Kotlin | 0 | 0 | 43ea45fc0bc135d6d33af1fd0d7de6a7b3b651ec | 3,643 | atcoder-kotline | MIT License |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem038.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
import dev.mikeburgess.euler.common.isPandigital
/**
* Take the number 192 and multiply it by each of 1, 2, and 3:
*
* 192 × 1 = 192
* 192 × 2 = 384
* 192 × 3 = 576
*
* By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576
* the co... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 869 | project-euler | MIT License |
src/Day14.kt | SnyderConsulting | 573,040,913 | false | {"Kotlin": 46459} | fun main() {
fun part1(input: List<String>): Int {
val rockLines = input.map { line ->
line.split(" -> ").map {
Coordinate.from(it)
}.fillRockLines()
}.flatten()
val (left, right, bottom) = rockLines.getEdgeLocations()
val grid = List(bottom ... | 0 | Kotlin | 0 | 0 | ee8806b1b4916fe0b3d576b37269c7e76712a921 | 5,383 | Advent-Of-Code-2022 | Apache License 2.0 |
src/Day17.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Long {
val chamber = CaveChamber(JetPattern(input.first()))
repeat(2022) { chamber.dropRock() }
return chamber.towerSize
}
fun part2(input: List<String>): Long {
val chamber = CaveChamber(JetPattern(input.first()))
... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 7,332 | aoc2022 | Apache License 2.0 |
shared/account/src/commonMain/kotlin/io/edugma/features/account/domain/usecase/MenuDataConverterUseCase.kt | Edugma | 474,423,768 | false | {"Kotlin": 971204, "Swift": 1255, "JavaScript": 1169, "HTML": 299, "Ruby": 102} | package io.edugma.features.account.domain.usecase
import io.edugma.features.account.domain.model.Personal
import io.edugma.features.account.domain.model.payments.Contract
import io.edugma.features.account.domain.model.performance.GradePosition
import kotlin.math.roundToInt
class MenuDataConverterUseCase {
fun co... | 1 | Kotlin | 0 | 2 | 80e49696cbd50a47ad515481511d972c283acb3e | 2,816 | app | MIT License |
src/main/kotlin/me/peckb/aoc/_2015/calendar/day20/Day20.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2015.calendar.day20
import arrow.core.fold
import javax.inject.Inject
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import kotlin.math.pow
import kotlin.math.sqrt
class Day20 @Inject constructor(private val generatorFactory: InputGeneratorFactory) {
fun partOne(filename:... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,041 | advent-of-code | MIT License |
src/main/kotlin/net/hiddevb/advent/advent2019/day05/main.kt | hidde-vb | 224,606,393 | false | null | package net.hiddevb.advent.advent2019.day05
import net.hiddevb.advent.common.initialize
import kotlin.math.floor
/**
* --- Day 5: Sunny with a Chance of Asteroids ---
*/
fun main() {
val fileStrings = initialize("Day 5: Sunny with a Chance of Asteroids", arrayOf("day5.txt"))
println("Part 1: Basic")
v... | 0 | Kotlin | 0 | 0 | d2005b1bc8c536fe6800f0cbd05ac53c178db9d8 | 1,481 | advent-of-code-2019 | MIT License |
google/2019/round1_a/3/main.kt | seirion | 17,619,607 | false | {"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294} | import java.util.*
fun main(args: Array<String>) {
repeat(readLine()!!.toInt()) {
print("Case #${it + 1}: ")
solve()
}
}
fun solve() {
val n = readLine()!!.toInt()
val input = ArrayList<String>()
repeat(n) { input.add(readLine()!!.reversed()) }
input.sort()
val t = Trie('_... | 0 | C++ | 4 | 4 | a59df98712c7eeceabc98f6535f7814d3a1c2c9f | 1,094 | code | Apache License 2.0 |
src/main/kotlin/Day01.kt | Vampire | 572,990,104 | false | {"Kotlin": 57326} | fun main() {
fun calorySums(caloryList: List<String>): List<Int> {
var calories = 0
val calorySums = caloryList.mapNotNull {
if (it.isEmpty()) {
return@mapNotNull calories.also { calories = 0 }
} else {
calories += it.toInt()
re... | 0 | Kotlin | 0 | 0 | 16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f | 764 | aoc-2022 | Apache License 2.0 |
solution/#122 Best Time to Buy and Sell Stock II/Solution.kt | enihsyou | 116,918,868 | false | {"Java": 179666, "Python": 36379, "Kotlin": 32431, "Shell": 367} | package leetcode.q122.kotlin;
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
/**
* 122. Best Time to Buy and Sell Stock II
*
* [LeetCode](https://leetcode-cn.com/probl... | 1 | Java | 0 | 0 | 230325d1dfd666ee53f304edf74c9c0f60f81d75 | 1,670 | LeetCode | MIT License |
src/main/kotlin/Day02.kt | SimonMarquis | 570,868,366 | false | {"Kotlin": 50263} | class Day02(private val input: List<String>) {
fun part1() = input.sumOf { round ->
when (round) {
"A Y", "B Z", "C X" -> 6 // win
"A X", "B Y", "C Z" -> 3 // draw
"A Z", "B X", "C Y" -> 0 // lose
else -> error(round)
} + (round.last() - 'X').inc()
... | 0 | Kotlin | 0 | 0 | a2129cc558c610dfe338594d9f05df6501dff5e6 | 693 | advent-of-code-2022 | Apache License 2.0 |
src/com/mrxyx/algorithm/linked/list/Reverse.kt | Mrxyx | 366,778,189 | false | null | package com.mrxyx.algorithm.linked.list
import com.mrxyx.algorithm.model.ListNode
/**
* 反转链表
*/
class Reverse {
/**
* 反转整个链表
*/
fun reverseAll(head: ListNode): ListNode {
//base case
if (head.next == null) return head
val last = reverseAll(head.next)
head.next.next... | 0 | Kotlin | 0 | 0 | b81b357440e3458bd065017d17d6f69320b025bf | 2,181 | algorithm-test | The Unlicense |
src/Day01.kt | gischthoge | 573,509,147 | false | {"Kotlin": 5583} | fun main() {
fun part1(input: List<String>): Int {
return input.splitByBlank().maxOf { elf -> elf.sumOf { it.toInt() } } }
fun part2(input: List<String>): Int {
return input.splitByBlank().map { elf -> elf.sumOf { it.toInt() } }
.sortedDescending()
.take(3)
... | 0 | Kotlin | 0 | 0 | e403f738572360d4682f9edb6006d81ce350ff9d | 945 | aock | Apache License 2.0 |
src/year2023/day09/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day09
import year2023.solveIt
fun main() {
val day = "09"
val expectedTest1 = 114L
val expectedTest2 = 2L
fun solveIt(values: List<Long>): Long {
if (values.all { it == 0L }) {
return 0L;
}
val rest = solveIt(values.zipWithNext { a, b -> b - a })... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 733 | adventOfCode | Apache License 2.0 |
src/main/kotlin/aoc2022/Day03.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import utils.InputUtils
fun main() {
val testInput = """<KEY>""".split("\n")
fun inHalf(s: String) = (s.length / 2).let { split -> s.substring(0, split) to s.substring(split) }
fun Char.score() = when (this) {
in 'a'..'z' -> 1 + (this - 'a')
in 'A'..'Z' -> 27 + (this - '... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 1,221 | aoc-2022-kotlin | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions68.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
/**
* 题目:给出两个树的节点,求这两个节点的公共子节点
* 本题根据给出的具体条件的不同则解法也不同,例如,树是否是二叉树,
* 是否是二叉搜索树,每个节点是否包含指向父节点的引用等,
* 为了编程方便,以及难度又较高,我给出的解法为,适用于该树是二叉树,
* 但是不是二叉搜索树,子节点也没有指向父节点的引用。
*/
fun test68() {
val a = BinaryTreeNode('A')
val b = BinaryTreeNode('B')
val c = BinaryTreeNode('C')
val d =... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 2,512 | Algorithm | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ReverseLinkedList2.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,684 | kotlab | Apache License 2.0 |
kotlin/src/main/kotlin/com/pbh/soft/day15/Day15Solver.kt | phansen314 | 579,463,173 | false | {"Kotlin": 105902} | package com.pbh.soft.day15
import com.pbh.soft.common.Solver
import com.pbh.soft.common.parsing.ParsingUtils.onSuccess
import com.pbh.soft.day15.Op.Del
import com.pbh.soft.day15.Op.Ins
import com.pbh.soft.kparse.KParser
import com.pbh.soft.kparse.KParser.Companion.chr
import com.pbh.soft.kparse.KParser.Companion.intNu... | 0 | Kotlin | 0 | 0 | 7fcc18f453145d10aa2603c64ace18df25e0bb1a | 3,131 | advent-of-code | MIT License |
src/main/kotlin/aoc2020/CrabCups.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2020
fun crabCups1(labels: String) =
crapCups(labels, iterations = 100, maxLabel = 9).answer()
fun crabCups2(labels: String): Long {
val one = crapCups(labels, iterations = 10_000_000, maxLabel = 1_000_000)
return one.next.label.toLong() * one.next.next.label
}
private fun cr... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,647 | advent-of-code | MIT License |
src/week1/MaxProfit.kt | anesabml | 268,056,512 | false | null | package week1
import kotlin.math.max
import kotlin.math.min
import kotlin.system.measureNanoTime
class MaxProfit {
/** Brute force
* Search for the max profit by calculating the profit between all the elements
* Time complexity : O(n2)
* Space complexity : O(1)
*/
fun maxProfit(prices: Int... | 0 | Kotlin | 0 | 1 | a7734672f5fcbdb3321e2993e64227fb49ec73e8 | 1,513 | leetCode | Apache License 2.0 |
src/main/kotlin/aoc23/Day08.kt | asmundh | 573,096,020 | false | {"Kotlin": 56155} | package aoc23
import lcm
import lcmOfList
import runTask
import utils.InputReader
import java.lang.IllegalStateException
import kotlin.collections.Map
fun day8part1(input: List<String>): Int {
val m = input.toSwampMap()
var current = "AAA"
var index = 0
var moves = 0
while (current != "ZZZ") {
... | 0 | Kotlin | 0 | 0 | 7d0803d9b1d6b92212ee4cecb7b824514f597d09 | 1,938 | advent-of-code | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.