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/Day05.kt | jmorozov | 573,077,620 | false | {"Kotlin": 31919} | import java.util.ArrayDeque
import java.util.Deque
fun main() {
val inputData = readInput("Day05")
part1(inputData)
part2(inputData)
}
private fun part1(inputData: List<String>) {
val stacks = mutableListOf<Deque<Char>>()
for (line in inputData) {
when {
line.startsWith(" ... | 0 | Kotlin | 0 | 0 | 480a98838949dbc7b5b7e84acf24f30db644f7b7 | 3,179 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ValidParenthesisString.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,473 | kotlab | Apache License 2.0 |
src/day06/Day06.kt | jpveilleux | 573,221,738 | false | {"Kotlin": 42252} | package day06
import readInput
const val currentDay = 6
const val baseDir = "./day0${currentDay}/"
const val testInputFileName = "${baseDir}Day0${currentDay}_test"
const val part1controlFileName = "${baseDir}Day0${currentDay}_part1_control"
const val part2controlFileName = "${baseDir}Day0${currentDay}_part2_control"
... | 0 | Kotlin | 0 | 0 | 5ece22f84f2373272b26d77f92c92cf9c9e5f4df | 1,652 | jpadventofcode2022 | Apache License 2.0 |
src/day04/Solve04.kt | NKorchagin | 572,397,799 | false | {"Kotlin": 9272} | package day04
import utils.*
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
@ExperimentalTime
fun main() {
fun readRangePairs(fileName: String) =
readInput(fileName)
.map { line ->
line.split(",")
.map { it.splitToPair("-") }
... | 0 | Kotlin | 0 | 0 | ed401ab4de38b83cecbc4e3ac823e4d22a332885 | 1,180 | AOC-2022-Kotlin | Apache License 2.0 |
src/Day02.kt | Vincentvibe3 | 573,202,573 | false | {"Kotlin": 8454} | fun main() {
fun part1(input: List<String>): Int {
val DRAW = 3
val WIN = 6
val LOSS = 0
val ROCK = 1
val PAPER = 2
val SCISSORS = 3
var totalPoints = 0
for (line in input) {
var roundPoints = 0
val split = line.split(" ");
... | 0 | Kotlin | 0 | 0 | 246c8c43a416023343b3ef518ae3e21dd826ee81 | 2,934 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | dominiquejb | 572,656,769 | false | {"Kotlin": 10603} | fun main() {
fun part1(input: List<String>): Int {
val elves = mutableListOf<Int>()
var calorieCount: Int = 0
input.forEach {
if (it.isNullOrBlank()) {
elves.add(calorieCount)
calorieCount = 0
} else {
calorieCount += it... | 0 | Kotlin | 0 | 0 | f4f75f9fc0b5c6c81759357e9dcccb8759486f3a | 1,101 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/me/peckb/aoc/_2016/calendar/day11/Day11.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2016.calendar.day11
import me.peckb.aoc.pathing.GenericIntDijkstra
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import javax.inject.Inject
import kotlin.collections.MutableMap.MutableEntry
class Day11 @Inject constructor(private val generatorFactory: InputGeneratorFactory)... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,584 | advent-of-code | MIT License |
src/main/kotlin/leetcode/kotlin/dp/213. House Robber II.kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.dp
/**
* f(n) = Max( // max amount to robbed till n
* f(n-2) + A[n], // max amount robbed till n-2 and current house
* f(n-1) // max amount robbed till n-1
* )
*/
private fun rob(nums: IntArray): Int {
if (nums.size == 1) return nums[0... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 1,309 | kotlinmaster | Apache License 2.0 |
src/Day06.kt | karloti | 573,006,513 | false | {"Kotlin": 25606} | import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
// <NAME> (my)
fun String.indexOf(n: Int): Int = asSequence()
.withIndex()
.runningFold(mutableMapOf<Char, Int>() to -1) { (m, r), (i, c) -> m to (m.put(c, i)?.coerceAtLeast(r) ?: r) }
.withIndex()
.indexOfFirst { (index, value) -... | 0 | Kotlin | 1 | 2 | 39ac1df5542d9cb07a2f2d3448066e6e8896fdc1 | 1,934 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day14/day14.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day14
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
import kotlin.math.pow
fun main() {
val input = getResourceAsText("/day14/initialization-program.txt")
.split("\n")
.filter { it.isNotEmpty() }
listOf(
::processInstructions to "ol... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 4,364 | advent-of-code-2020 | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-16.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputText
fun main() {
val input = readInputText(2021, "16-input")
val test1 = readInputText(2021, "16-test1")
val test2 = readInputText(2021, "16-test2")
val te... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 4,788 | advent-of-code | MIT License |
src/main/kotlin/de/p58i/utils/tableoptimizer/io/YamlIO.kt | mspoeri | 529,728,917 | false | {"Kotlin": 30057} | package de.p58i.utils.tableoptimizer.io
import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.module.kotlin.kotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
import de.p5... | 4 | Kotlin | 0 | 2 | 7e8765be47352e79b45f6ff0f8e6396e3da9abc9 | 3,079 | table-optimizer | MIT License |
app/src/main/kotlin/aoc2022/day04/Day04.kt | dbubenheim | 574,231,602 | false | {"Kotlin": 18742} | package aoc2022.day04
import aoc2022.day04.Day04.part1
import aoc2022.day04.Day04.part2
import aoc2022.toFile
object Day04 {
fun part1() = "input-day04.txt".toFile()
.readLines()
.map { it.toAssignmentPair() }
.count { it.fullyContains() }
fun part2() = "input-day04.txt".toFile()
... | 8 | Kotlin | 0 | 0 | ee381bb9820b493d5e210accbe6d24383ae5b4dc | 1,040 | advent-of-code-2022 | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day252/Rational.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day252
// day252.kt
// By <NAME>, 2019.
import java.lang.IllegalArgumentException
import java.math.BigInteger
class Rational(n: BigInteger, d: BigInteger): Comparable<Rational> {
val numerator: BigInteger
val denominator: BigInteger
init {
require(d != BigInteger.ZERO) {"Denominator ca... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 3,337 | daily-coding-problem | MIT License |
src/main/kotlin/g2401_2500/s2448_minimum_cost_to_make_array_equal/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2448_minimum_cost_to_make_array_equal
// #Hard #Array #Sorting #Binary_Search #Prefix_Sum
// #2023_07_05_Time_387_ms_(80.40%)_Space_50.7_MB_(80.41%)
import java.util.Collections
class Solution {
private class Pair(var e: Int, var c: Int)
fun minCost(nums: IntArray, cost: IntArray): Long ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,023 | LeetCode-in-Kotlin | MIT License |
plugin/src/main/kotlin/tanvd/grazi/ide/ui/components/rules/RuleWithLang.kt | TanVD | 177,469,390 | false | null | package tanvd.grazi.ide.ui.components.rules
import org.languagetool.rules.Category
import org.languagetool.rules.Rule
import tanvd.grazi.GraziConfig
import tanvd.grazi.language.Lang
import tanvd.grazi.language.LangTool
import java.util.*
data class RuleWithLang(val rule: Rule, val lang: Lang, val enabled: Boolean, va... | 0 | Kotlin | 0 | 36 | d12150715d19aaafcb9b7a474ea911bf1713701f | 2,733 | Grazi | Apache License 2.0 |
src/util/polylines/sortClockwise.kt | JBWills | 291,822,812 | false | null | package util.polylines
import coordinate.Point
fun List<Point>.centroid() =
if (length == 0.0) Point.Zero
else reduceRight { p, acc -> p + acc } / size
fun clockwiseComparator(c: Point) = Comparator { a: Point, b: Point ->
fun ret(boolean: Boolean) = if (boolean) -1 else 1
if (a.x >= c.x && b.x < c.x) return... | 0 | Kotlin | 0 | 0 | 569b27c1cb1dc6b2c37e79dfa527b9396c7a2f88 | 1,301 | processing-sketches | MIT License |
src/Day13.kt | mrugacz95 | 572,881,300 | false | {"Kotlin": 102751} | import java.util.Stack
import kotlin.math.max
private const val DEBUG = false
private sealed class InnerItem
private data class InnerNumber(val value: Int) : InnerItem() {
override fun toString(): String {
return value.toString()
}
}
private data class InnerList(val list: List<InnerItem>) : InnerItem(... | 0 | Kotlin | 0 | 0 | 29aa4f978f6507b182cb6697a0a2896292c83584 | 4,980 | advent-of-code-2022 | Apache License 2.0 |
Day_07/Solution_Part2.kts | 0800LTT | 317,590,451 | false | null | import java.io.File
class Graph() {
val data: MutableMap<String, Set<Pair<String, Int>>> = mutableMapOf()
fun addNodes(container: String, contained: Sequence<Pair<String, Int>>) {
data.put(container, contained.toSet())
}
fun countBags(source: String): Int {
var total = 0
for ((bag, bagCount) in da... | 0 | Kotlin | 0 | 0 | 191c8c307676fb0e7352f7a5444689fc79cc5b54 | 1,121 | advent-of-code-2020 | The Unlicense |
java/app/src/main/kotlin/com/github/ggalmazor/aoc2021/day20/Grid.kt | ggalmazor | 434,148,320 | false | {"JavaScript": 80092, "Java": 33594, "Kotlin": 14508, "C++": 3077, "CMake": 119} | package com.github.ggalmazor.aoc2021.day20
class Grid<T>(private val cells: List<Cell<T>>, private val width: Int, private val height: Int) {
fun cellAt(position: Position): Cell<T>? {
return cells.find { cell -> cell.isAt(position) }
}
fun subGridAt(position: Position, defaultValue: T): Grid<T> =... | 0 | JavaScript | 0 | 0 | 7a7ec831ca89de3f19d78f006fe95590cc533836 | 2,389 | aoc2021 | Apache License 2.0 |
src/main/kotlin/g1401_1500/s1457_pseudo_palindromic_paths_in_a_binary_tree/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1401_1500.s1457_pseudo_palindromic_paths_in_a_binary_tree
// #Medium #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree #Bit_Manipulation
// #2023_06_13_Time_583_ms_(50.00%)_Space_62.9_MB_(100.00%)
import com_github_leetcode.TreeNode
/*
* Example:
* var ti = TreeNode(5)
* var v = ti.`val`
* De... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,395 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-20.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.BooleanGrid
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputText
import com.github.ferinagy.adventOfCode.toBooleanGrid
private typealias Image = BooleanGrid
fun main() {
val i... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,659 | advent-of-code | MIT License |
2020/day17/day17.kt | flwyd | 426,866,266 | false | {"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398} | /*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package day17
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
import kotlin.time.measureTimedValue
/* Input: 2... | 0 | Julia | 1 | 5 | f2d6dbb67d41f8f2898dbbc6a98477d05473888f | 2,576 | adventofcode | MIT License |
src/main/kotlin/com/github/dangerground/Day13.kt | dangerground | 226,153,955 | false | null | package com.github.dangerground
import com.github.dangerground.util.Intcode
class Arcade {
private var robot: Intcode = Intcode.ofFile("/day13input.txt")
val map = HashMap<Coord2D, Long>()
var blockCount = 0
fun run() {
robot.runProgram()
val data = robot.outputs
for (t in 0... | 0 | Kotlin | 0 | 1 | 125d57d20f1fa26a0791ab196d2b94ba45480e41 | 2,884 | adventofcode | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[1232]缀点成线.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //在一个 XY 坐标系中有一些点,我们用数组 coordinates 来分别记录它们的坐标,其中 coordinates[i] = [x, y] 表示横坐标为
// x、纵坐标为 y 的点。
//
// 请你来判断,这些点是否在该坐标系中属于同一条直线上,是则返回 true,否则请返回 false。
//
//
//
// 示例 1:
//
//
//
// 输入:coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]
//输出:true
//
//
// 示例 2:
//
//
//
// 输入:coordinates = [[1,1],[2,2],[3,4],[4... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,389 | MyLeetCode | Apache License 2.0 |
merlin-core/src/main/java/de/micromata/merlin/data/Data.kt | micromata | 145,080,847 | false | null | package de.micromata.merlin.data
import org.apache.commons.lang3.StringUtils
import java.util.*
open class Data(private val type: String) {
private val properties: MutableMap<String, Any?> = HashMap()
fun put(property: String?, value: Any?) {
properties[property!!] = value
if (value != null) {... | 5 | Java | 4 | 16 | 091890ab85f625f76216aacda4b4ce04e42ad98e | 2,574 | Merlin | Apache License 2.0 |
src/test/kotlin/dev/bogwalk/batch7/Problem74Test.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch7
import dev.bogwalk.util.tests.Benchmark
import kotlin.test.Test
import kotlin.test.assertEquals
import dev.bogwalk.util.tests.compareSpeed
import dev.bogwalk.util.tests.getSpeed
import kotlin.test.assertContentEquals
internal class DigitFactorialChainsTest {
private val tool = DigitFact... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,862 | project-euler-kotlin | MIT License |
src/main/kotlin/co/csadev/advent2021/Day11.kt | gtcompscientist | 577,439,489 | false | {"Kotlin": 252918} | /**
* Copyright (c) 2021 by <NAME>
* Advent of Code 2021, Day 11
* Problem Description: http://adventofcode.com/2021/day/11
*/
package co.csadev.advent2021
import co.csadev.adventOfCode.BaseDay
import co.csadev.adventOfCode.Point2D
import co.csadev.adventOfCode.Resources.resourceAsList
class Day11(override val in... | 0 | Kotlin | 0 | 1 | 43cbaac4e8b0a53e8aaae0f67dfc4395080e1383 | 2,180 | advent-of-kotlin | Apache License 2.0 |
src/main/kotlin/dilivia/s2/coords/S2Projection.kt | Enovea | 409,487,197 | false | {"Kotlin": 3249710} | /*
* Copyright © 2021 Enovea (<EMAIL>)
*
* 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 agr... | 0 | Kotlin | 3 | 17 | eb5139ec5c69556e8dc19c864b052e7e45a48b49 | 9,786 | s2-geometry-kotlin | Apache License 2.0 |
src/questions/LongestCommonPrefix.kt | realpacific | 234,499,820 | false | null | package questions
import kotlin.test.assertEquals
/**
* Write a function to find the longest common prefix string amongst an array of strings.
* If there is no common prefix, return an empty string "".
*/
fun longestCommonPrefix(strs: Array<String>): String {
var result = ""
var i = 0
// Infinite loop:... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,362 | algorithms | MIT License |
src/Day21.kt | uekemp | 575,483,293 | false | {"Kotlin": 69253} | sealed class MonkeyWithJob
data class YellingMonkey(var number: Long) : MonkeyWithJob()
class ComputingMonkey(
private val operation: String,
val left: String,
val right: String
) : MonkeyWithJob() {
val compute: ((Long, Long) -> Long) = when(operation) {
"+" -> { x, y -> x + y }
"-" ... | 0 | Kotlin | 0 | 0 | bc32522d49516f561fb8484c8958107c50819f49 | 4,987 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/io/binarysearch/TwoNumberSum.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.binarysearch
// https://leetcode.com/explore/learn/card/binary-search/144/more-practices/1035/
class TwoNumberSum {
fun executeSimpler(numbers: IntArray, target: Int): IntArray {
var index1 = 0
var index2 = numbers.size - 1
while (numbers[index1] + numbers[index2] != target) {
val sum =... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,402 | coding | MIT License |
src/main/kotlin/uk/neilgall/kanren/MicroKanren.kt | neilgall | 132,669,065 | false | null | package uk.neilgall.kanren
typealias Substitutions = Map<out Term, Term>
typealias Goal = (State) -> Sequence<State>
data class State(val subs: Substitutions = mapOf(), val vars: Int = 0) {
fun adding(newSubs: Substitutions): State {
return State(subs + newSubs, vars)
}
fun withNewVar(f: (Term) ... | 0 | Kotlin | 1 | 16 | 28ab8ce1826149735a049f180446ba2a68d39780 | 3,101 | KotlinKanren | MIT License |
src/day24/Code.kt | fcolasuonno | 225,219,560 | false | null | package day24
import isDebug
import java.io.File
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part 1 = ${part1(parsed)}")... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 3,824 | AOC2019 | MIT License |
src/day6/Code.kt | fcolasuonno | 225,219,560 | false | null | package day6
import isDebug
import java.io.File
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part 1 = ${part1(parsed)}")
... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 1,110 | AOC2019 | MIT License |
src/main/kotlin/me/peckb/aoc/pathing/Dijkstra.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc.pathing
import java.util.PriorityQueue
/**
* NOTE: whatever class you use for `Node` should be a `data class`
*/
interface Dijkstra<Node, Cost : Comparable<Cost>, NodeWithCost: DijkstraNodeWithCost<Node, Cost>> {
fun solve(start: Node, end: Node? = null, comparator: Comparator<Node>? = null):... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 1,653 | advent-of-code | MIT License |
src/pl/shockah/aoc/y2015/Day18.kt | Shockah | 159,919,224 | false | null | package pl.shockah.aoc.y2015
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import pl.shockah.aoc.AdventTask
import pl.shockah.unikorn.collection.Array2D
class Day18: AdventTask<Array2D<Boolean>, Int, Int>(2015, 18) {
override fun parseInput(rawInput: String): Array2D<Boolean> {
val line... | 0 | Kotlin | 0 | 0 | 9abb1e3db1cad329cfe1e3d6deae2d6b7456c785 | 2,244 | Advent-of-Code | Apache License 2.0 |
solutions/mediansort/medianSort.kt | arcadioramos | 418,717,198 | true | {"Java": 85120, "Elixir": 51650, "Go": 50067, "Ruby": 24382, "Scala": 19921, "Dart": 19382, "JavaScript": 14831, "Python": 10246, "Rust": 6885, "Clojure": 5403, "F#": 3328, "Kotlin": 2040, "C#": 1590} | fun main(){
var (a, b, c) = readLine()!!.split(' ')
var testCases = a.toInt()
var numOfElemnts = b.toInt()
var numOfQueries = c.toInt()
while(testCases > 0){
if(!medianSort(numOfElemnts, numOfQueries))
return
}
testCases = testCases - 1
}
// Median Sort
fun ... | 0 | Java | 0 | 0 | 57451e0ea2c9836adfcae8964bda11e4d86eaa94 | 2,040 | google-code-jam | MIT License |
src/main/kotlin/turfkt/Conversions.kt | hudsonb | 172,511,286 | false | null | package turfkt
/**
* Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
*/
const val EARTH_RADIUS = 6371008.8
/**
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
*/
private val factors = mapOf(
"centimeters" to EARTH_RADIUS * 10... | 19 | Kotlin | 1 | 1 | e39bf4f24366bc569129a3b3b2239c1909f6b7f1 | 3,010 | turf.kt | MIT License |
src/main/kotlin/com/leetcode/P486.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package com.leetcode
// https://leetcode.com/problems/predict-the-winner/
class P486 {
fun PredictTheWinner(nums: IntArray): Boolean {
if (nums.size <= 2) return true
return predict(nums, 0, 0, nums.lastIndex, 1) >= 0
}
private fun predict(nums: IntArray, score: Int, l: Int, r: Int, t: Int... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 770 | algorithm | MIT License |
Kotlin/5 kyu String incrementer.kt | MechaArms | 508,384,440 | false | {"Kotlin": 22917, "Python": 18312} | /*
Your job is to write a function which increments a string, to create a new string.
If the string already ends with a number, the number should be incremented by 1.
If the string does not end with a number. the number 1 should be appended to the new string.
Examples:
foo -> foo1
foobar23 -> foobar24
foo0042 -> f... | 0 | Kotlin | 0 | 1 | b23611677c5e2fe0f7e813ad2cfa21026b8ac6d3 | 1,873 | My-CodeWars-Solutions | MIT License |
calendar/day02/Day2.kt | starkwan | 573,066,100 | false | {"Kotlin": 43097} | package day02
import Day
import Lines
class Day2 : Day() {
override fun part1(input: Lines): Any {
return input.map { Round.fromPart1(it).toScore() }.sum()
}
override fun part2(input: Lines): Any {
return input.map { Round.fromPart2(it).toScore() }.sum()
}
sealed class Shape {
... | 0 | Kotlin | 0 | 0 | 13fb66c6b98d452e0ebfc5440b0cd283f8b7c352 | 2,488 | advent-of-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LFUCache.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,002 | kotlab | Apache License 2.0 |
src/main/kotlin/day10/Day10.kt | daniilsjb | 434,765,082 | false | {"Kotlin": 77544} | 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 | 1 | bcdd709899fd04ec09f5c96c4b9b197364758aea | 2,056 | advent-of-code-2021 | MIT License |
assertk/src/commonMain/kotlin/assertk/assertions/support/ListDiffer.kt | willowtreeapps | 88,210,079 | false | {"Kotlin": 386666, "Java": 133} | package assertk.assertions.support
/**
* List diffing using the Myers diff algorithm.
*/
internal object ListDiffer {
fun diff(a: List<*>, b: List<*>): List<Edit> {
val diff = mutableListOf<Edit>()
backtrack(a, b) { prevX, prevY, x, y ->
diff.add(
0, when {
... | 31 | Kotlin | 77 | 687 | 5ff8a09f63543a18365dee1bb48dc9c4684aab9e | 2,916 | assertk | MIT License |
src/main/kotlin/leetcode/Problem2044.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
/**
* https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/
*/
class Problem2044 {
fun countMaxOrSubsets(nums: IntArray): Int {
var max = 0
for (num in nums) {
max = max or num
}
var answer = 0
for (i in nums.indices) {
... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 885 | leetcode | MIT License |
src/main/kotlin/kt/kotlinalgs/app/searching/QuickSelect.ws.kts | sjaindl | 384,471,324 | false | null | package kt.kotlinalgs.app.searching
println("test")
val array1 = intArrayOf(3, 2, 1)
val array2 = intArrayOf(2000, 234, 21, 41, 1, 21, 75, 0, -4)
println(QuickSelect().select(intArrayOf(3, 2, 1), 1))
println(QuickSelect().select(intArrayOf(3, 2, 1), 2))
println(QuickSelect().select(intArrayOf(3, 2, 1), 3))
println(... | 0 | Java | 0 | 0 | e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0 | 2,067 | KotlinAlgs | MIT License |
kotlin/structures/KdTreePointQuery.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package structures
import java.util.Random
class KdTreePointQuery(var x: IntArray, var y: IntArray) {
fun build(low: Int, high: Int, divX: Boolean) {
if (high - low <= 1) return
val mid = low + high ushr 1
nth_element(low, high, mid, divX)
build(low, mid, !divX)
build(mid +... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 3,589 | codelibrary | The Unlicense |
kotlin/2022/day07/Day07.kt | nathanjent | 48,783,324 | false | {"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966} | class Day07 {
data class File(val name: String, val size: Int)
class FileSystem {
private var pwd: String = "/"
private val fileSystemStructure = mutableMapOf(
Pair(pwd, mutableMapOf<String, Int>()),
)
fun cd(path: String) {
if (path == "..") {
pwd = pwd.substring(0, pwd.lastI... | 0 | Rust | 0 | 0 | 7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf | 1,981 | adventofcode | MIT License |
roboquant/src/logging/MetricsEntry.kt | idanakav | 465,612,930 | true | {"Kotlin": 1144731, "Jupyter Notebook": 134242} | /*
* Copyright 2021 Neural Layer
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed t... | 0 | Kotlin | 0 | 0 | 9be1931fa0d4a76fc5013009c60e418322a77e60 | 4,120 | roboquant | Apache License 2.0 |
src/Day04.kt | zfz7 | 573,100,794 | false | {"Kotlin": 53499} | fun main() {
println(day4A(readFile("Day04")))
println(day4B(readFile("Day04")))
}
fun day4A(input: String): Int = input.trim().split("\n").count { pair ->
pair.split("-", ",").let { overlapAll(it[0].toInt(), it[1].toInt(), it[2].toInt(), it[3].toInt()) }
}
fun day4B(input: String): Int = input.trim().spl... | 0 | Kotlin | 0 | 0 | c50a12b52127eba3f5706de775a350b1568127ae | 691 | AdventOfCode22 | Apache License 2.0 |
src/day1/Day01.kt | dean95 | 571,923,107 | false | {"Kotlin": 21240} | package day1
import readInput
private fun main() {
fun part1(input: List<String>): Int {
val res = mutableListOf<Int>()
var i = 0
while (i < input.size) {
var totalCalories = 0
while (i < input.size && input[i].isNotBlank()) {
totalCalories += input[... | 0 | Kotlin | 0 | 0 | 0ddf1bdaf9bcbb45116c70d7328b606c2a75e5a5 | 1,108 | advent-of-code-2022 | Apache License 2.0 |
precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/RouteParser.kt | Tlaster | 349,750,473 | false | {"Kotlin": 185353} | package moe.tlaster.precompose.navigation
import moe.tlaster.precompose.navigation.route.Route
import kotlin.math.min
internal class RouteParser {
data class Segment(
val nodeType: Int = 0,
val rexPat: String = "",
val tail: Char = 0.toChar(),
val startIndex: Int = 0,
val e... | 24 | Kotlin | 39 | 657 | e914ffbf2e92eb17aefc43aba82c7b575228eb1c | 26,403 | PreCompose | MIT License |
aoc-2023/src/main/kotlin/aoc/aoc1.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocRunner
import aoc.util.getDayInput
val input = getDayInput(1, 2023)
val digits = listOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
val sum1 = input
.sumOf { it.first { it.isDigit() }.digitToInt() * 10 + it.last { it.isDigit() }.digitToInt() }
val sum2 = input.sumOf { it... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 1,196 | advent-of-code | Apache License 2.0 |
src/main/kotlin/g1101_1200/s1156_swap_for_longest_repeated_character_substring/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1101_1200.s1156_swap_for_longest_repeated_character_substring
// #Medium #String #Sliding_Window #2023_10_02_Time_198_ms_(100.00%)_Space_37.4_MB_(100.00%)
class Solution {
private class Pair(var character: Char, var count: Int)
fun maxRepOpt1(text: String): Int {
val pairs: MutableList<Pair>... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,870 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/leetcode/Problem1438.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
import java.util.*
import kotlin.math.max
/**
* https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/
*/
class Problem1438 {
fun longestSubarray(nums: IntArray, limit: Int): Int {
var answer = 1
val minDeque = LinkedList<Int>()... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 1,203 | leetcode | MIT License |
src/main/kotlin/problems/Day17.kt | PedroDiogo | 432,836,814 | false | {"Kotlin": 128203} | package problems
import kotlin.math.min
class Day17(override val input: String) : Problem {
override val number: Int = 17
private val inputMatch = """target area: x=(-?\d+)..(-?\d+), y=(-?\d+)..(-?\d+)"""
.toRegex()
.find(input)
?.groupValues
?.drop(1)
?.map { it.toInt(... | 0 | Kotlin | 0 | 0 | 93363faee195d5ef90344a4fb74646d2d26176de | 2,044 | AdventOfCode2021 | MIT License |
Essays/Testability/REPL/src/main/kotlin/palbp/laboratory/essays/testability/repl/Tokenizer.kt | palbp | 463,200,783 | false | {"Kotlin": 722657, "C": 16710, "Assembly": 891, "Dockerfile": 610, "Swift": 594, "Makefile": 383} | package palbp.laboratory.essays.testability.repl
data class Token(val container: String, val range: IntRange) {
constructor(container: String, startsAt: Int) : this(container, startsAt until container.length)
init {
require(range.first >= 0 && range.last <= container.length)
require(container.i... | 1 | Kotlin | 0 | 4 | 66fb17fcd9d7b1690492def0bf671cfb408eb6db | 2,223 | laboratory | MIT License |
src/Day17.kt | frungl | 573,598,286 | false | {"Kotlin": 86423} | fun main() {
val figures = listOf(
listOf(-1 to 0, 0 to 0, 1 to 0, 2 to 0),
listOf(0 to 0, -1 to 1, 0 to 1, 1 to 1, 0 to 2),
listOf(-1 to 0, 0 to 0, 1 to 0, 1 to 1, 1 to 2),
listOf(-1 to 0, -1 to 1, -1 to 2, -1 to 3),
listOf(-1 to 0, 0 to 0, -1 to 1, 0 to 1)
)
operat... | 0 | Kotlin | 0 | 0 | d4cecfd5ee13de95f143407735e00c02baac7d5c | 4,582 | aoc2022 | Apache License 2.0 |
src/Day11.kt | weberchu | 573,107,187 | false | {"Kotlin": 91366} | private data class Monkey (
val id: Int,
val items: MutableList<Long> = mutableListOf(),
val operation: (Long) -> Long,
val testDivisor: Int,
val testTrueMonkey: Int,
val testFalseMonkey: Int,
var inspectedItems:Int = 0
)
private fun monkeys(input: List<String>): List<Monkey> {
var curr... | 0 | Kotlin | 0 | 0 | 903ff33037e8dd6dd5504638a281cb4813763873 | 3,875 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day08.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2016
import se.saidaspen.aoc.util.*
fun main() = Day08.run()
object Day08 : Day(2016, 8) {
private const val width = 50
private const val heigh = 6
override fun part1(): Any {
val grid = Grid('.')
List(width){it}.flatMap{ x -> List(heigh){it}.map { y-> x to y... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,651 | adventofkotlin | MIT License |
src/main/kotlin/days/Solution04.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
object Solution04 : Solution<List<Int>>(AOC_YEAR, 4) {
override fun getInput(handler: InputHandler): List<Int> {
return handler.getInput("\n")
.map { it.substringAfter(": ").split(" | ") ... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 1,249 | Advent-of-Code-2023 | MIT License |
src/iii_conventions/MyDate.kt | pleshkov631 | 350,749,403 | true | {"Kotlin": 71902, "Java": 4952} | package iii_conventions
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
override fun compareTo(other: MyDate): Int {
return when {
year != other.year -> year - other.year
month != other.month -> month - other.month
else -> da... | 0 | Kotlin | 0 | 0 | 7cad67d77ed9ce2c70503c297de43574c3854086 | 1,564 | kotlin-koans | MIT License |
src/main/kotlin/aoc2023/Day10.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import Point
import readInput
import to2dCharArray
private data class PipeNetwork(val map: Array<CharArray>, val start: Point) {
companion object {
fun fromStrings(input: List<String>): PipeNetwork {
val map = input.to2dCharArray()
val start = map.withIndex().firstN... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 6,856 | adventOfCode | Apache License 2.0 |
solutions/round1/A/append-sort/src/main/kotlin/append/sort/AppendSortSolution.kt | Lysoun | 351,224,145 | false | null | import java.math.BigInteger
fun main(args: Array<String>) {
val casesNumber = readLine()!!.toInt()
for (i in 1..casesNumber) {
// Ignore list size
readLine()
println("Case #$i: ${countDigitsRequiredForAppendSort(readLine()!!.split(" ").map { it.toBigInteger() })}")
}
}
fun countDi... | 0 | Kotlin | 0 | 0 | 98d39fcab3c8898bfdc2c6875006edcf759feddd | 1,761 | google-code-jam-2021 | MIT License |
src/main/kotlin/year2022/day11/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2022.day11
import IProblem
import java.lang.Exception
class Problem : IProblem {
private val monkeys = mutableListOf<Monkey>()
private var divisor = 1UL
init {
javaClass
.getResourceAsStream("/2022/11.txt")!!
.bufferedReader()
.use {
... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 2,321 | advent-of-code | The Unlicense |
ceria/12/src/main/kotlin/Solution.kt | VisionistInc | 433,099,870 | false | {"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104} | import java.io.File;
val startNodes = mutableSetOf<String>()
val endNodes = mutableSetOf<String>()
val nodePaths = mutableListOf<Pair<String, String>>()
fun main(args : Array<String>) {
val input = File(args.first()).readLines()
for (line in input) {
var nodes = line.split("-")
if (nodes[0].eq... | 0 | Kotlin | 4 | 1 | e22a1d45c38417868f05e0501bacd1cad717a016 | 4,172 | advent-of-code-2021 | MIT License |
src/day03/Day03.kt | GrzegorzBaczek93 | 572,128,118 | false | {"Kotlin": 44027} | package day03
import readInput
import utils.asNumber
import utils.withStopwatch
fun main() {
val testInput = readInput("input03_test")
withStopwatch { println(part1(testInput)) }
withStopwatch { println(part2(testInput)) }
val input = readInput("input03")
withStopwatch { println(part1(input)) }
... | 0 | Kotlin | 0 | 0 | 543e7cf0a2d706d23c3213d3737756b61ccbf94b | 907 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/g2401_2500/s2402_meeting_rooms_iii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2402_meeting_rooms_iii
// #Hard #Array #Sorting #Heap_Priority_Queue
// #2023_07_03_Time_976_ms_(100.00%)_Space_108.7_MB_(66.67%)
import java.util.Arrays
class Solution {
fun mostBooked(n: Int, meetings: Array<IntArray>): Int {
val counts = IntArray(n)
val endTimes = LongArray... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,418 | LeetCode-in-Kotlin | MIT License |
src/aoc2022/day08/Day08.kt | svilen-ivanov | 572,637,864 | false | {"Kotlin": 53827} | package aoc2022.day08
import readInput
@OptIn(ExperimentalStdlibApi::class)
fun main() {
fun part1(input: List<String>) {
val map: MutableList<List<Int>> = mutableListOf()
for (line in input) {
map.add(line.map { it.toString().toInt() })
}
val rows = map.size
va... | 0 | Kotlin | 0 | 0 | 456bedb4d1082890d78490d3b730b2bb45913fe9 | 3,737 | aoc-2022 | Apache License 2.0 |
src/Day01.kt | peterphmikkelsen | 573,069,935 | false | {"Kotlin": 7834} | import java.io.File
fun main() {
fun part1(input: List<List<Int>>) = input.maxOf { it.sum() }
fun part2(input: List<List<Int>>) = input.map(List<Int>::sum).sortedDescending().take(3).sum()
// test if implementation meets criteria from the description, like:
val testInput = readDayOneInput("Day01_test... | 0 | Kotlin | 0 | 0 | 374c421ff8d867a0bdb7e8da2980217c3455ecfd | 796 | aoc-2022 | Apache License 2.0 |
libraries/stdlib/test/OrderingTest.kt | AlexeyTsvetkov | 17,321,988 | true | {"Java": 22837096, "Kotlin": 18913890, "JavaScript": 180163, "HTML": 47571, "Protocol Buffer": 46162, "Lex": 18051, "Groovy": 13300, "ANTLR": 9729, "CSS": 9358, "IDL": 6426, "Shell": 4704, "Batchfile": 3703} | package test.comparisons
import kotlin.test.*
import org.junit.Test
import kotlin.comparisons.*
data class Item(val name: String, val rating: Int) : Comparable<Item> {
public override fun compareTo(other: Item): Int {
return compareValuesBy(this, other, { it.rating }, { it.name })
}
}
val STRING_CASE... | 1 | Java | 1 | 2 | 72a84083fbe50d3d12226925b94ed0fe86c9d794 | 4,720 | kotlin | Apache License 2.0 |
src/net/sheltem/aoc/y2023/Day25.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.aoc.y2023
import net.sheltem.common.SearchGraph
import net.sheltem.common.SearchGraph.Edge
import net.sheltem.common.SearchGraph.Node
import org.jgrapht.alg.StoerWagnerMinimumCut
import org.jgrapht.graph.DefaultWeightedEdge
import org.jgrapht.graph.SimpleWeightedGraph
suspend fun main() {
Day... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 1,621 | aoc | Apache License 2.0 |
src/main/kotlin/days/Day13.kt | TheMrMilchmann | 725,205,189 | false | {"Kotlin": 61669} | /*
* Copyright (c) 2023 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, dis... | 0 | Kotlin | 0 | 1 | f94ff8a4c9fefb71e3ea183dbc3a1d41e6503152 | 3,768 | AdventOfCode2023 | MIT License |
Kotlin/Maths/HappyNumber.kt | HarshCasper | 274,711,817 | false | {"C++": 1488046, "Java": 948670, "Python": 703942, "C": 615475, "JavaScript": 228879, "Go": 166382, "Dart": 107821, "Julia": 82766, "C#": 76519, "Kotlin": 40240, "PHP": 5465} | /*
A number is called happy if it leads to 1 after a sequence of steps
wherein each step number is replaced by the sum of squares of its digit
that is if we start with Happy Number and keep replacing it with digits square sum, we reach 1.
Examples of Happy numbers are:- 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70... | 2 | C++ | 1,086 | 877 | 4f1e5bdd6d9d899fa354de94740e0aecf5ecd2be | 1,351 | NeoAlgo | MIT License |
src/main/kotlin/Day06.kt | SimonMarquis | 724,825,757 | false | {"Kotlin": 30983} | class Day06(private val input: List<String>) {
fun part1(): Long = input
.map { """\d+""".toRegex().findAll(it).map(MatchResult::value).map(String::toLong) }
.let { (times, distances) -> (times zip distances) }
.map { (time, distance) -> wins(time, distance) }
.product()
fun pa... | 0 | Kotlin | 0 | 1 | 043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e | 696 | advent-of-code-2023 | MIT License |
kts/aoc2016/aoc2016_11.kts | miknatr | 576,275,740 | false | {"Kotlin": 413403} | fun solve(input: String, extraOnFirstFloor: Int): Int {
val floorItems = input.split("\n").map { it.split(" a ").count() - 1 }.toMutableList()
floorItems[0] += extraOnFirstFloor
return (1..floorItems.size - 1).map { floorItems.subList(0, it).sum() * 2 - 3 }.sum()
}
val input11 = """The first floor contains... | 0 | Kotlin | 0 | 0 | 400038ce53ff46dc1ff72c92765ed4afdf860e52 | 808 | aoc-in-kotlin | Apache License 2.0 |
src/main/kotlin/io/tree/RearrangeTree.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.tree
import io.models.TreeNode
import io.utils.runTests
import java.util.*
// https://leetcode.com/problems/increasing-order-search-tree/
class RearrangeTree {
fun executeRecursive(input: TreeNode?, acc: TreeNode? = null): TreeNode? = when (input) {
null -> acc
else -> {
executeRecursive(i... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 2,110 | coding | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/DesignHashMap.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,918 | kotlab | Apache License 2.0 |
src/main/kotlin/g2201_2300/s2272_substring_with_largest_variance/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2201_2300.s2272_substring_with_largest_variance
// #Hard #Array #Dynamic_Programming #2023_06_28_Time_338_ms_(100.00%)_Space_36.8_MB_(100.00%)
class Solution {
fun largestVariance(s: String): Int {
val freq = IntArray(26)
for (i in 0 until s.length) {
freq[s[i].code - 'a'.code... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,390 | LeetCode-in-Kotlin | MIT License |
Kotlin/Reference/src/basics.kt | mrkajetanp | 83,730,170 | false | null |
fun sum(a: Int, b: Int): Int {
return a + b
}
fun sum2(a: Int, b: Int) = a + b
fun sum3(a: Int, b: Int): Unit {
println("sum of $a and $b is ${a + b}")
}
fun functions() {
println(sum(3, 5))
println(sum2(3, 5))
sum3(3, 5)
}
val PI = 3.14
fun variables() {
val a: Int = 1
val b = 2
v... | 31 | Rust | 2 | 1 | 85aea40a61fb824a2b4e142331d9ac7971fef263 | 3,318 | learning-programming | MIT License |
src/main/kotlin/algorithms/Utils.kt | Furetur | 439,579,145 | false | {"Kotlin": 21223, "ANTLR": 246} | package algorithms
import model.Lang
import model.Term
import model.TermString
fun kProduct(lang1: Lang, lang2: Lang, k: Int): Lang {
require(k >= 1)
val result = mutableSetOf<TermString>()
for (s1 in lang1) {
for (s2 in lang2) {
result.add((s1 + s2).take(k))
}
}
return... | 0 | Kotlin | 0 | 1 | 002cc53bcca6f9b591c4090d354f03fe3ffd3ed6 | 1,005 | LLkChecker | MIT License |
Java_part/AssignmentD/src/Q1.kt | enihsyou | 58,862,788 | false | {"Java": 77446, "Python": 65409, "Kotlin": 35032, "C++": 6214, "C": 3796, "CMake": 818} | import java.util.*
data class Vertex(val name: String)
data class Edge(val from: Vertex, val to: Vertex, val name: String = "$from -> $to")
class Graph(private val vertexes: List<Vertex>, private val edges: List<Edge>) {//todo 应该使用Set
val adjacencyMatrix = Array(vertexes.size) { row ->
BooleanArray(verte... | 0 | Java | 0 | 0 | 09a109bb26e0d8d165a4d1bbe18ec7b4e538b364 | 6,363 | Sorting-algorithm | MIT License |
archive/2022/Day10.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 13140
private const val EXPECTED_2 = 0
private class Day10(isTest: Boolean) : Solver(isTest) {
fun generateX() = readAsLines().flatMap {
val parts = it.split(" ")
when (parts[0]) {
"noop" -> listOf(0)
"addx" -> listOf(0, parts[1].toInt())
... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 1,229 | advent-of-code-2022 | Apache License 2.0 |
kotlin-math/src/main/kotlin/com/baeldung/math/sum/SumNaturalNumbers.kt | Baeldung | 260,481,121 | false | {"Kotlin": 1476024, "Java": 43013, "HTML": 4883} | package com.baeldung.math.sum
fun sumUsingForLoop(n: Int): Int {
var sum = 0
for (i in 1..n) {
sum += i
}
return sum
}
fun sumUsingWhileLoop(n: Int): Int {
var sum = 0
var i = 1
while (i <= n) {
sum += i
i++
}
return sum
}
fun sumUsingArithmeticProgressionF... | 10 | Kotlin | 273 | 410 | 2b718f002ce5ea1cb09217937dc630ff31757693 | 949 | kotlin-tutorials | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/EditDistance.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,684 | kotlab | Apache License 2.0 |
src/stack/CodilityStackTest1.kt | develNerd | 456,702,818 | false | {"Kotlin": 37635, "Java": 5892} | package stack
import java.util.Stack
/*
*
*
* A string S consisting of N characters is considered to be properly nested if any of the following conditions is true:
S is empty;
S has the form "(U)" or "[U]" or "{U}" where U is a properly nested string;
S has the form "VW" where V and W are properly nested strings.
F... | 0 | Kotlin | 0 | 0 | 4e6cc8b4bee83361057c8e1bbeb427a43622b511 | 1,848 | Blind75InKotlin | MIT License |
day6/src/main/kotlin/aoc2015/day6/Day6.kt | sihamark | 581,653,112 | false | {"Kotlin": 263428, "Shell": 467, "Batchfile": 383} | package aoc2015.day6
/**
* Created by <NAME> on 29.01.2019.
*/
object Day6 {
fun calculateLitLights(): Int {
val matrix = ToggleLightMatrix()
input.forEach { rawCommand ->
val command = Parser.parse(rawCommand)
command.positions.forEach { position ->
when ... | 0 | Kotlin | 0 | 0 | 6d10f4a52b8c7757c40af38d7d814509cf0b9bbb | 5,740 | aoc2015 | Apache License 2.0 |
src/main/kotlin/aoc/year2022/Day04.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2022
import aoc.Puzzle
/**
* [Day 4 - Advent of Code 2022](https://adventofcode.com/2022/day/4)
*/
object Day04 : Puzzle<Int, Int> {
override fun solvePartOne(input: String): Int =
input.lineSequence()
.count {
it.split(',')
.map { range ->... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 1,174 | advent-of-code | Apache License 2.0 |
src/Day01.kt | lassebe | 573,423,378 | false | {"Kotlin": 33148} | fun main() {
fun solve(input: List<String>): List<Int> {
val elves = input.joinToString(":")
.split("::")
.map { it.split(":") }
.map { it.map { it.toInt() } }
.map { it.sum() }
return elves.sorted()
}
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | c3157c2d66a098598a6b19fd3a2b18a6bae95f0c | 726 | advent_of_code_2022 | Apache License 2.0 |
src/main/java/com/barneyb/aoc/aoc2022/day25/FullOfHotAir.kt | barneyb | 553,291,150 | false | {"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020} | package com.barneyb.aoc.aoc2022.day25
import com.barneyb.aoc.util.Solver
import com.barneyb.aoc.util.toSlice
fun main() {
Solver.execute(
::parse,
::totalFuel, // 2-212-2---=00-1--102
)
}
internal fun CharSequence.fromSnafu() =
this.fold(0L) { n, c ->
n * 5 + when (c) {
... | 0 | Kotlin | 0 | 0 | 8b5956164ff0be79a27f68ef09a9e7171cc91995 | 1,166 | aoc-2022 | MIT License |
src/main/kotlin/Main.kt | ronhombre | 753,669,759 | false | {"Kotlin": 2448} | //These values below should be saved since we assume that Q is a constant.
//The Q value for Kyber (ML-KEM). This is a prime number ((2^8 * 13) + 1)
const val Q: Short = 3329
//Negative Modular Inverse of Q base 2^16
const val Q_INV = -62209
//Base 2^16.
const val R_shift = 16
//R
const val R = 1 shl R_shift
//R * R = ... | 0 | Kotlin | 0 | 0 | 24eac84091199663636eab59338e1abe0ae94a9b | 2,448 | MontgomeryArithmeticKotlinExample | Creative Commons Zero v1.0 Universal |
src/Day01.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | fun main() {
fun mostCaloriesCarriedBySingleElf(input: List<List<Int>>) =
input.maxOfOrNull { bundle -> bundle.sum() }
fun mostCaloriesCarriedByThreeElves(input: List<List<Int>>): Int {
val caloriesPerElf = input
.map { bundle -> bundle.sum() }
.sorted()
... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 756 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2018/SettlersOfTheNorthPole.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2018
import komu.adventofcode.aoc2018.MapElement.*
import komu.adventofcode.utils.Point
fun settlersOfTheNorthPoleTest(input: String) =
(1..10).fold(SettlersMap.parse(input)) { m, _ -> m.step() }.resourceValue
fun settlersOfTheNorthPoleTest2(input: String): Int {
var map = Settle... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,376 | advent-of-code | MIT License |
src/main/kotlin/advent/Day7.kt | chjaeggi | 229,756,763 | false | null | /**
* Quest can be found here:
* http://adventofcode.com/2019/day/7
*/
package advent
import com.marcinmoskala.math.permutations
class Day7(input: List<Int>) : Day {
private val intCodeProgram = input.toIntArray()
override fun solvePart1(): Int {
return listOf(0, 1, 2, 3, 4).permutations().map { ... | 0 | Kotlin | 0 | 1 | d31bdf97957794a631e684a2136bd1bd89c55f0e | 1,773 | aoc-2019-kotlin | Apache License 2.0 |
src/main/kotlin/adventofcode/y2021/Day16.kt | Tasaio | 433,879,637 | false | {"Kotlin": 117806} | import adventofcode.*
import java.math.BigInteger
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
fun main() {
val testInput = """
C200B40A82
""".trimIndent()
runDay(
day = Day16::class,
testInput = testInput,
testAnswer1 = 14,
testAnswer2 = 3
... | 0 | Kotlin | 0 | 0 | cc72684e862a782fad78b8ef0d1929b21300ced8 | 4,808 | adventofcode2021 | The Unlicense |
year2018/src/main/kotlin/net/olegg/aoc/year2018/day20/Day20.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2018.day20
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions.Companion.NEXT_4
import net.olegg.aoc.utils.Directions.D
import net.olegg.aoc.utils.Directions.L
import net.olegg.aoc.utils.Directions.R
import net.olegg.aoc.utils.Directions.U
import net.olegg.aoc.utils.Vec... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,951 | adventofcode | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2023/day18/Day18.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day18
import com.jacobhyphenated.advent2023.Day
import kotlin.math.absoluteValue
/**
* Day 18: Lavaduct Lagoon
*
* Workers need to dig a lagoon to hold excess lava. The puzzle input is instructions on how to dig
* Each instruction has a direction, a value, and a color
* By ... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 6,341 | advent2023 | The Unlicense |
movement/src/main/java/com/hawkeye/movement/utils/AngleMeasure.kt | kirvader | 495,356,524 | false | {"Kotlin": 116363} | package com.hawkeye.movement.utils
import kotlin.math.PI
fun cos(angle: AngleMeasure): Float = kotlin.math.cos(angle.radian())
fun sin(angle: AngleMeasure): Float = kotlin.math.sin(angle.radian())
fun abs(angle: AngleMeasure): AngleMeasure = Degree(kotlin.math.abs(angle.degree()))
fun sign(angle: AngleMeasure): Flo... | 0 | Kotlin | 0 | 0 | 9dfbebf977e96fe990c7b5300a28b48c1df11152 | 2,028 | AutomatedSoccerRecordingWithAndroid | MIT License |
src/Day02.kt | kmakma | 574,238,598 | false | null | fun main() {
fun myScore(strategy: String): Int {
return when {
strategy.contains('X') -> 1
strategy.contains('Y') -> 2
strategy.contains('Z') -> 3
else -> throw IllegalArgumentException()
}
}
fun part1(input: List<String>): Int {
val ... | 0 | Kotlin | 0 | 0 | 950ffbce2149df9a7df3aac9289c9a5b38e29135 | 1,860 | advent-of-kotlin-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.