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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
foundations/inversions/Main.kt | ivan-magda | 102,283,964 | false | null | import kotlin.collections.ArrayList
fun getInversions(array: Array<Int>): List<Pair<Int, Int>> {
val inversions = mutableListOf<Pair<Int, Int>>()
for (i in 0 until array.size) {
(i + 1 until array.size)
.asSequence()
.filter { i < it && array[i] > array[it] }
... | 0 | Kotlin | 0 | 2 | da06ec75cbd06c8e158aec86ca813e72bd22a2dc | 1,807 | introduction-algorithms | MIT License |
library/src/commonMain/kotlin/com/darkrockstudios/symspellkt/common/WeightedDamerauLevenshteinDistance.kt | Wavesonics | 752,869,721 | false | {"Kotlin": 123713, "HTML": 304} | package com.darkrockstudios.symspellkt.common
import com.darkrockstudios.symspellkt.api.CharDistance
import com.darkrockstudios.symspellkt.api.StringDistance
/**
* DamerauLevenshteinDistance is a string metric for measuring the edit distance between two
* sequences. Informally, the Damerau–Levenshtein distance betw... | 1 | Kotlin | 0 | 16 | e20a9ef48fe6a154aa1c2a35de701654e1cd0ef1 | 2,944 | SymSpellKt | MIT License |
src/main/kotlin/Word.kt | jGleitz | 232,886,761 | false | {"Kotlin": 22060, "Java": 683} | @file:JvmName("StringToWord")
package de.joshuagleitze.stringnotation
/**
* A notation-agnostic representation of a string. This is a “word” in the sense of “word over the Unicode alphabet”, not in the sense of a
* word in any spoken language. A `Word` consists of [parts].
*
* @property parts The different parts ... | 2 | Kotlin | 0 | 0 | a3fdd5d16da4318ca3aea7727c9c68a18eacafdb | 2,564 | string-notation | MIT License |
src/me/bytebeats/algo/kt/Solution10.kt | bytebeats | 251,234,289 | false | null | package me.bytebeats.algo.kt
import me.bytebeats.algs.ds.TreeNode
class Solution10 {
class Node(val `val`: Int) {
var prev: Node? = null
var next: Node? = null
var child: Node? = null
}
fun flatten(root: Node?): Node? {//430, recursive
if (root == null) return root
... | 0 | Kotlin | 0 | 1 | 7cf372d9acb3274003bb782c51d608e5db6fa743 | 37,133 | Algorithms | MIT License |
src/main/kotlin/com/github/davio/aoc/y2020/Day2.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2020
import com.github.davio.aoc.general.Day
import com.github.davio.aoc.general.call
import com.github.davio.aoc.general.getInputAsSequence
fun main() {
Day2.getResultPart1()
Day2.getResultPart2()
}
object Day2 : Day() {
/*
* --- Day 2: Password Philosophy ---
Yo... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 4,599 | advent-of-code | MIT License |
src/main/java/Day3.kt | mattyb678 | 319,195,903 | false | null | class Day3 : Day {
override fun asInt(): Int = 3
override fun part1InputName(): String = "day3"
override fun part1(input: List<String>): String {
println("Day 3, Part 1")
val treeCount = treeCountForSlope(3, 1, input)
return treeCount.toString()
}
private fun treeCountFor... | 0 | Kotlin | 0 | 1 | f677d61cfd88e18710aafe6038d8d59640448fb3 | 1,274 | aoc-2020 | MIT License |
Kotlin/problem021.kt | emergent | 116,013,843 | false | null | // Problem 21 - Project Euler
// http://projecteuler.net/index.php?section=problems&id=21
import kotlin.math.*
fun divisors(x: Int): List<Int> {
val lim = ceil(sqrt(x.toDouble())).toInt()
return (1..lim)
.map { n ->
if (x % n == 0) listOf(n, x/n) else null
}
... | 0 | Rust | 0 | 0 | d04f5029385c09a569c071254191c75d582fe340 | 741 | ProjectEuler | The Unlicense |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[389]找不同.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定两个字符串 s 和 t,它们只包含小写字母。
//
// 字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母。
//
// 请找出在 t 中被添加的字母。
//
//
//
// 示例 1:
//
// 输入:s = "abcd", t = "abcde"
//输出:"e"
//解释:'e' 是那个被添加的字母。
//
//
// 示例 2:
//
// 输入:s = "", t = "y"
//输出:"y"
//
//
// 示例 3:
//
// 输入:s = "a", t = "aa"
//输出:"a"
//
//
// 示例 4:
//
// 输入:s = "ae", t = "ae... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,252 | MyLeetCode | Apache License 2.0 |
scratch/src/main/kotlin/x/scratch/difference-engine.kt | binkley | 184,655,460 | false | null | package x.scratch
fun main() {
println("==DIFFERENCE ENGINE")
val ours = listOf(
Left("ALICE", 2), // common, unchanged
Left("BOB", 3), // added
Left("DAVE", 5), // common, changed
)
val theirs = listOf(
Right("ALICE", "2"), // common, unchanged
Right("CAROL"... | 0 | Kotlin | 1 | 2 | 4787a43f8e27dbde3a967b35f5a3363864cbd51f | 2,665 | spikes | The Unlicense |
rtron-math/src/main/kotlin/io/rtron/math/range/RangeSetExtensions.kt | tum-gis | 258,142,903 | false | {"Kotlin": 1425220, "C": 12590, "Dockerfile": 511, "CMake": 399, "Shell": 99} | package io.rtron.math.range
import io.rtron.std.powerSet
/**
* Unions a set of [RangeSet] to a single [RangeSet].
*/
fun <T : Comparable<*>> Set<RangeSet<T>>.unionRangeSets(): RangeSet<T> =
reduce { acc, element -> acc.union(element) }
/**
* Returns the intersecting [RangeSet].
*
* @receiver provided set of... | 4 | Kotlin | 12 | 38 | 27969aee5a0c8115cb5eaf085ca7d4c964e1f033 | 1,085 | rtron | Apache License 2.0 |
app/src/main/java/com/dlight/algoguide/dsa/sorting/quick_sort/QuickSort.kt | kodeflap | 535,790,826 | false | {"Kotlin": 129527} | package com.dlight.algoguide.dsa.sorting.quick_sort
/**
* Quick sort
*
* @constructor Create empty Quick sort
*/
class QuickSort {
suspend fun quickSort(
arr: IntArray, left: Int, right: Int) {
/*First finding the partioning index using thepartion function */
val index = partition (... | 0 | Kotlin | 9 | 10 | c4a7ddba54daecb219a1befa12583e3e8f3fa066 | 1,518 | Algo_Guide | Apache License 2.0 |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day9/Day9Puzzle1.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day9
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
class Day9Puzzle1 : PuzzleSolver {
override fun solve(inputLines: Sequence<String>) = lowPointRiskLevelSum(inputLines).toString()
private fun lowPointRiskLevelSum(rawHeightMap: Sequ... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 1,228 | AdventOfCode2021 | Apache License 2.0 |
src/commonMain/kotlin/com/jeffpdavidson/kotwords/model/SpellWeaving.kt | jpd236 | 143,651,464 | false | {"Kotlin": 4390419, "HTML": 41919, "Rouge": 3731, "Perl": 1705, "Shell": 744, "JavaScript": 618} | package com.jeffpdavidson.kotwords.model
import com.jeffpdavidson.kotwords.formats.Puzzleable
import kotlin.math.sqrt
data class SpellWeaving(
val title: String,
val creator: String,
val copyright: String,
val description: String,
val answers: List<String>,
val clues: List<String>
) : Puzzleab... | 5 | Kotlin | 5 | 19 | c2dc23bafc7236ba076a63060e08e6dc134c8e24 | 6,505 | kotwords | Apache License 2.0 |
src/main/kotlin/it/anesin/DefaultPackaging.kt | pieroanesin | 540,757,888 | false | {"Kotlin": 14170} | package it.anesin
class DefaultPackaging(private val catalogue: Catalogue) : Packaging {
override fun wrapFlowers(quantity: Int, type: FlowerType): List<Package> {
val bundles = catalogue.bundlesOf(type).sortedBy { it.size }
val bundleCounter = initBundleCounter(quantity, bundles)
if (quantity < smalle... | 0 | Kotlin | 0 | 0 | 48d7f000126e201092e7278bc7d9c52fd34bae08 | 3,281 | flower-shop | MIT License |
src/academy/learnprogramming/challenges/KotlinOOBicycles.kt | bladefistx2 | 430,293,814 | false | {"Kotlin": 19902, "Java": 1795} | package academy.learnprogramming.challenges
fun main(args: Array<String>) {
val mtb = KotlinMountainBike(33, 1000, 25, 7)
mtb.printDescription()
val bike = KotlinBicycle(1, 1)
bike.printDescription()
val bike2 = KotlinMountainBike("green",1, 2, 1)
bike2.printDescription()
println("===")
... | 0 | Kotlin | 0 | 0 | a8349446e202c187a0860614acc503fb412967ea | 1,761 | learn-kotlin | Apache License 2.0 |
solutions/src/solutions/y20/day 7.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.y20.d07
import helpers.*
import collections.*
import grid.*
import graph.BFS
import itertools.count
import kotlinx.coroutines.*
import kotlin.math.pow
val xxxxx = Clock(3, 6);
private fun part1(data: Data) {
val mm = data.map {
val (a, b) = it.split(" ... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 1,388 | AdventOfCodeSolutions | MIT License |
src/main/kotlin/aoc23/Day10.kt | tahlers | 725,424,936 | false | {"Kotlin": 65626} | package aoc23
import aoc23.Day10.PipeType.HORIZONTAL
import aoc23.Day10.PipeType.NORTH_EAST
import aoc23.Day10.PipeType.NORTH_WEST
import aoc23.Day10.PipeType.SOUTH_EAST
import aoc23.Day10.PipeType.SOUTH_WEST
import aoc23.Day10.PipeType.START
import aoc23.Day10.PipeType.VERTICAL
object Day10 {
enum class PipeTy... | 0 | Kotlin | 0 | 0 | 0cd9676a7d1fec01858ede1ab0adf254d17380b0 | 5,275 | advent-of-code-23 | Apache License 2.0 |
src/main/java/tarehart/rlbot/math/Ray2.kt | tarehart | 101,009,961 | true | {"Kotlin": 781564, "Python": 29120, "Batchfile": 324} | package tarehart.rlbot.math
import tarehart.rlbot.input.CarData
import tarehart.rlbot.math.vector.Vector2
import kotlin.math.pow
import kotlin.math.sqrt
open class Ray2(val position: Vector2, direction: Vector2) {
val direction = direction.normalized()
/**
* Taken from https://math.stackexchange.com/a/3... | 0 | Kotlin | 7 | 10 | 8a5ba0ba751235e775d383c9796ee8fa966030b9 | 1,926 | ReliefBot | MIT License |
src/main/kotlin/days/Day9.kt | andilau | 429,557,457 | false | {"Kotlin": 103829} | package days
@AdventOfCodePuzzle(
name = "All in a Single Night",
url = "https://adventofcode.com/2015/day/9",
date = Date(day = 9, year = 2015)
)
class Day9(input: List<String>) : Puzzle {
private val legDistances: Map<Pair<Location, Location>, Int> = input.parseDistances()
internal val totals: L... | 0 | Kotlin | 0 | 0 | 55932fb63d6a13a1aa8c8df127593d38b760a34c | 1,344 | advent-of-code-2015 | Creative Commons Zero v1.0 Universal |
src/Day06.kt | Vlisie | 572,110,977 | false | {"Kotlin": 31465} | import java.io.File
fun main() {
fun uniqueCharacters(str: String): Boolean{
val chArray = str.toCharArray()
chArray.sort()
for (i in 0..chArray.size - 2) {
if (chArray[i] == chArray[i + 1]) return false else continue
}
return true
}
fun part1(file: Fil... | 0 | Kotlin | 0 | 0 | b5de21ed7ab063067703e4adebac9c98920dd51e | 1,783 | AoC2022 | Apache License 2.0 |
src/Year2021Day02.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | import kotlin.math.abs
internal data class SubmarinePosition(
var x: Int,
var y: Int,
var aim: Int,
)
fun main() {
fun parse(lines: List<String>) = lines.map {
val (direction, distance) = it.split(" ")
direction to distance.toInt()
}
fun part1(lines: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 1,360 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/aoc2020/Day17.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2020
class Day17(val input: List<String>) {
data class Point(val x: Int, val y: Int, val z: Int, val w: Int, private val dimensions: Int) {
// We're accessing neighbours frequently, only calculate the neighbours once and return
// a cached value if calling this later. In this case, much... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,289 | aoc | MIT License |
src/main/kotlin/com/leetcode/P93.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package com.leetcode
// https://github.com/antop-dev/algorithm/issues/331
class P93 {
val answer = mutableListOf<String>()
fun restoreIpAddresses(s: String): List<String> {
if (s.length !in 4..12) return listOf()
dfs(s, 0, 0, StringBuffer())
return answer
}
/**
* @param s... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,513 | algorithm | MIT License |
src/Day21.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import java.util.*
class Day21 {
data class Monkey(var value: Long? = null, val operation: Char?, val leftChild: String?, val rightChild: String?)
private val leafPattern = "(\\w{4}): (\\d+)"
private val trunkPattern = "(\\w{4}): (\\w{4}) ([+\\-\\/\\*]) (\\w{4})"
fun parseLine(line: String): Pair<Str... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 5,163 | Advent-Of-Code-2022 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2021/Day12.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2021
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
/**
* --- Day 12: Passage Pathing ---
* https://adventofcode.com/2021/day/12
*/
class Day12 : Solver {
override fun solve(lines: List<String>): Result {
val connections = lines.map { it.split('-') }.map { Pair(it[0], it[1]) }
... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,507 | euler | Apache License 2.0 |
src/iii_conventions/MyDate.kt | trueddd | 166,991,808 | true | {"Kotlin": 73247, "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{
this.year != other.year -> this.year - other.year
this.month != other.month -> this.month - other.month
... | 0 | Kotlin | 0 | 0 | 9b73d9cf2ddccdd04d083e797c900a2f8a7c3814 | 1,509 | kotlin-koans | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortedListToBST.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 | 4,865 | kotlab | Apache License 2.0 |
LeetCode2020April/week3/src/test/kotlin/net/twisterrob/challenges/leetcode2020april/week3/search_rotated/SolutionTest.kt | TWiStErRob | 136,539,340 | false | {"Kotlin": 104880, "Java": 11319} | package net.twisterrob.challenges.leetcode2020april.week3.search_rotated
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.DynamicTest.dynamicTest
import org.junit.jupiter.api.TestFactory
class SolutionTest {
private fun solutionTest(target: I... | 1 | Kotlin | 1 | 2 | 5cf062322ddecd72d29f7682c3a104d687bd5cfc | 1,853 | TWiStErRob | The Unlicense |
src/main/kotlin/com/psmay/exp/advent/y2021/day18/snailfish/Atom.kt | psmay | 434,705,473 | false | {"Kotlin": 242220} | package com.psmay.exp.advent.y2021.day18.snailfish
import com.psmay.exp.advent.y2021.util.mapIterator
import com.psmay.exp.advent.y2021.util.splice
import com.psmay.exp.advent.y2021.util.withPeeking
internal sealed class Atom {
open val depthChange: Int get() = 0
object DescendAtom : Atom() {
overrid... | 0 | Kotlin | 0 | 0 | c7ca54612ec117d42ba6cf733c4c8fe60689d3a8 | 4,729 | advent-2021-kotlin | Creative Commons Zero v1.0 Universal |
Algorithms/30 - Substring with Concatenation of All Words/src/Solution.kt | mobeigi | 202,966,767 | false | null | class Solution {
fun findSubstring(s: String, words: Array<String>): List<Int> {
if (words.isEmpty()) {
return emptyList()
}
// Find useful lengths we will be working with
val wordLength = words.first().length
val concatenatedSubstringLength = wordLength * words... | 0 | Kotlin | 0 | 0 | e5e29d992b52e4e20ce14a3574d8c981628f38dc | 2,017 | LeetCode-Solutions | Academic Free License v1.1 |
Kotlin/src/dev/aspid812/leetcode/problem0541/Solution.kt | Const-Grigoryev | 367,924,342 | false | {"Python": 35682, "Kotlin": 11162, "C++": 2688, "Java": 2168, "C": 1076} | package dev.aspid812.leetcode.problem0541
/* 541. Reverse String II
* ----------------------
*
* Given a string `s` and an integer `k`, reverse the first `k` characters for every `2k` characters counting
* from the start of the string.
*
* If there are fewer than `k` characters left, reverse all of them. If ther... | 0 | Python | 0 | 0 | cea8e762ff79878e2d5622c937f34cf20f0b385e | 1,303 | LeetCode | MIT License |
src/main/kotlin/g2401_2500/s2438_range_product_queries_of_powers/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2438_range_product_queries_of_powers
// #Medium #Array #Bit_Manipulation #Prefix_Sum
// #2023_07_05_Time_1115_ms_(100.00%)_Space_94.9_MB_(100.00%)
@Suppress("NAME_SHADOWING")
class Solution {
fun productQueries(n: Int, queries: Array<IntArray>): IntArray {
val length = queries.size
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,633 | LeetCode-in-Kotlin | MIT License |
src/main/basicprogramming/implementation/kotlin/BatmanAndTicTacToe.kt | vamsitallapudi | 119,534,182 | false | {"Java": 24691, "Kotlin": 20452} | package main.basicprogramming.implementation.kotlin
fun main(args: Array<String>) {
var testCases:Int = readLine()!!.toInt()
while(testCases-- > 0) {
val line1 = readLine()!!
val line2 = readLine()!!
val line3 = readLine()!!
val line4 = readLine()!!
if(ticTacToeLogic(... | 0 | Java | 1 | 1 | 9349fa7488fcabcb9c58ce5852d97996a9c4efd3 | 2,209 | HackerEarth | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem2706/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2706
import kotlin.math.max
import kotlin.math.min
/**
* LeetCode page: [2706. Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(1) where N is the size of prices;
*/
fun buyChoco(... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,066 | hj-leetcode-kotlin | Apache License 2.0 |
src/palindrome_int/PalindRomeInt.kt | AhmedTawfiqM | 458,182,208 | false | {"Kotlin": 11105} | package palindrome_int
//https://leetcode.com/problems/palindrome-number
object PalindRomeInt {
private fun isPalindrome(input: Int): Boolean {
if (input < 0 || input >= Int.MAX_VALUE) return false
if (input in 0..9) return true
var original = input
var reversed = 0
while... | 0 | Kotlin | 0 | 1 | a569265d5f85bcb51f4ade5ee37c8252e68a5a03 | 1,335 | ProblemSolving | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2023/math/Math.kt | michaelbull | 726,012,340 | false | {"Kotlin": 195941} | package com.github.michaelbull.advent2023.math
import kotlin.math.abs
/* https://en.wikipedia.org/wiki/Greatest_common_divisor */
tailrec fun greatestCommonDivisor(a: Long, b: Long): Long {
return if (b == 0L) {
a
} else {
greatestCommonDivisor(b, a % b)
}
}
fun Iterable<Long>.greatestCo... | 0 | Kotlin | 0 | 1 | ea0b10a9c6528d82ddb481b9cf627841f44184dd | 956 | advent-2023 | ISC License |
solutions/aockt/y2015/Y2015D03.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2015
import io.github.jadarma.aockt.core.Solution
object Y2015D03 : Solution {
/** Keeps track of Santa's visits. */
private class SantaTracker {
private var currentLocation = 0 to 0
private val _visited = mutableSetOf(currentLocation)
/** A set of coordinates of hous... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 1,559 | advent-of-code-kotlin-solutions | The Unlicense |
server/src/main/kotlin/database.kt | GuillaumeEveillard | 259,152,854 | false | null | import com.google.gson.Gson
import parser.ParserResult
import java.io.File
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
import kotlin.math.max
data class Item(val id: Long, val frenchName: String?, val englishName: String?) {
fun complete() = frenchName != null && englishName != null... | 0 | Kotlin | 0 | 0 | 7beb62c8416a84ef2d0619ac1be29f9555515d32 | 4,500 | ah-charts | MIT License |
shared/src/commonMain/kotlin/com/somabits/spanish/regularity/RegularityChecker.kt | chiljamgossow | 581,781,635 | false | {"Kotlin": 918432, "Swift": 1817} | package com.somabits.spanish.regularity
import com.somabits.spanish.comparison.ConjugationComparison
import com.somabits.spanish.comparison.SubstringComparisonResult
import com.somabits.spanish.comparison.compareSubstrings
import com.somabits.spanish.verb.Conjugation
import com.somabits.spanish.verb.VerbForm
class Co... | 1 | Kotlin | 0 | 0 | e680c7048721fb9a2cbfb7cb5a9db3e39ac73b45 | 1,529 | Spanish | MIT License |
lesson-3_dynamic-programming/0-1-knapsack-problem/memoization/main.kt | BioniCosmos | 471,716,962 | false | null | import kotlin.math.max
fun main() {
var tmp = readLine()!!.split(' ')
val n = tmp[0].toInt()
val balance = tmp[1].toInt()
val values = Array(n) { 0 }
val like = Array(n) { 0 }
val rec = Array(n) { Array(balance + 1) { 0 } }
for (i in 0 until n) {
tmp = readLine()!!.split(' ')
... | 0 | Rust | 0 | 1 | 5d6a15ff9aa476956ba3658f1fa9a61351d3f0cd | 996 | neko-programming-class | MIT License |
10/part_one.kt | ivanilos | 433,620,308 | false | {"Kotlin": 97993} | import java.io.File
fun readInput() : List<String> {
return File("input.txt")
.readLines()
}
class SyntaxChecker {
companion object {
val OPEN_CHARS = listOf('(', '[', '{', '<')
val MATCH = mapOf('(' to ')',
'[' to ']',
'{' to '}',
'<' to '>')
... | 0 | Kotlin | 0 | 3 | a24b6f7e8968e513767dfd7e21b935f9fdfb6d72 | 1,173 | advent-of-code-2021 | MIT License |
src/main/kotlin/Day10.kt | goblindegook | 319,372,062 | false | null | package com.goblindegook.adventofcode2020
import com.goblindegook.adventofcode2020.extension.asIntList
import com.goblindegook.adventofcode2020.input.load
fun main() {
val adapters = load("/day10-input.txt").asIntList()
println(multiplyJoltageDiffs(adapters))
println(countPermutations(adapters))
}
tailre... | 0 | Kotlin | 0 | 0 | 85a2ff73899dbb0e563029754e336cbac33cb69b | 999 | adventofcode2020 | MIT License |
src/main/kotlin/day12/SpringGroup.kt | limelier | 725,979,709 | false | {"Kotlin": 48112} | package day12
internal typealias Springs = String
internal class SpringGroup(
springs: Springs,
private val damagedGroups: List<Int>
) {
private val springs = springs.trimStart('.')
companion object {
val waysToCompleteCache = mutableMapOf<String, Long>()
val potentialDamageSpringPre... | 0 | Kotlin | 0 | 0 | 0edcde7c96440b0a59e23ec25677f44ae2cfd20c | 1,878 | advent-of-code-2023-kotlin | MIT License |
src/main/java/com/booknara/problem/backtracking/CombinationSumIIKt.kt | booknara | 226,968,158 | false | {"Java": 1128390, "Kotlin": 177761} | package com.booknara.problem.backtracking
/**
* 40. Combination Sum II (Medium)
* https://leetcode.com/problems/combination-sum-ii/
*/
class CombinationSumIIKt {
// T:O(2^n), S:O(2^n)
fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> {
// input check, the length of candidates >... | 0 | Java | 1 | 1 | 04dcf500ee9789cf10c488a25647f25359b37a53 | 1,226 | playground | MIT License |
year2016/src/main/kotlin/net/olegg/aoc/year2016/day1/Day1.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2016.day1
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions.Companion.CCW
import net.olegg.aoc.utils.Directions.Companion.CW
import net.olegg.aoc.utils.Directions.U
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.year2016.DayOf2016
/**
* See [Year 2016, Day... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,396 | adventofcode | MIT License |
src/main/kotlin/com/askrepps/advent2022/day07/Day07.kt | askrepps | 726,566,200 | false | {"Kotlin": 99712} | /*
* MIT License
*
* Copyright (c) 2022 <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, m... | 0 | Kotlin | 0 | 0 | 5ce2228b0951db49a5cf2a6d974112f57e70030c | 4,202 | advent-of-code-kotlin | MIT License |
archive/src/main/kotlin/com/grappenmaker/aoc/year16/Day04.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year16
import com.grappenmaker.aoc.PuzzleSet
import com.grappenmaker.aoc.deepen
fun PuzzleSet.day4() = puzzle {
val rooms = inputLines.map { l ->
val (name, info) = l.substringBeforeLast('-') to l.substringAfterLast('-')
val (id, check) = info.substringBeforeLast('[') ... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 1,198 | advent-of-code | The Unlicense |
src/main/kotlin/com/sherepenko/leetcode/solutions/LongestCommonSubstring.kt | asherepenko | 264,648,984 | false | null | package com.sherepenko.leetcode.solutions
import com.sherepenko.leetcode.Solution
import kotlin.math.max
class LongestCommonSubstring(
private val text1: String,
private val text2: String
) : Solution {
companion object {
fun longestCommonSubsequence(text1: String, text2: String): Int {
... | 0 | Kotlin | 0 | 0 | 49e676f13bf58f16ba093f73a52d49f2d6d5ee1c | 1,211 | leetcode | The Unlicense |
src/main/kotlin/leetcode/kotlin/hashtable/247. Strobogrammatic Number II.kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.hashtable
import java.util.*
import kotlin.collections.ArrayList
/**
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).
Find all strobogrammatic numbers that are of length = n.
Example:
Input: n = 2
Output: ["11","69","88","96"]
*/
... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 1,947 | kotlinmaster | Apache License 2.0 |
src/Day01.kt | sgc109 | 576,491,331 | false | {"Kotlin": 8641} | fun main() {
fun part1(input: String): Long {
return input.split("\n\n").maxOfOrNull { chunk ->
chunk.split("\n").sumOf { numStr ->
numStr.toLong()
}
}!!
}
fun part2(input: String): Long {
val sums = input.split("\n\n").map {
it.sp... | 0 | Kotlin | 0 | 0 | 03e4e85283d486430345c01d4c03419d95bd6daa | 600 | aoc-2022-in-kotlin | Apache License 2.0 |
src/advent/of/code/18thPuzzle.kt | 1nco | 725,911,911 | false | {"Kotlin": 112713, "Shell": 103} | package advent.of.code
import advent.of.code.types.Pos
import java.util.*
import kotlin.math.absoluteValue
object `18thPuzzle` {
private const val DAY = "18";
private var input: MutableList<String> = arrayListOf();
private var result = 0L;
private var resultSecond = 0L;
private val dirMap: Ma... | 0 | Kotlin | 0 | 0 | 0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3 | 2,962 | advent-of-code | Apache License 2.0 |
src/Day14.kt | zt64 | 572,594,597 | false | null | private object Day14 : Day(14) {
private val grid = MutableList(1000) { y ->
MutableList<Point>(1000) { x -> Air(x, y) }
}
private val directionPairs = listOf(
0 to 1, // Down
-1 to 1, // Down-left
1 to 1 // Down-right
)
private val spawnPoint = Point(500, 0)
i... | 0 | Kotlin | 0 | 0 | 4e4e7ed23d665b33eb10be59670b38d6a5af485d | 3,296 | aoc-2022 | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/hard/LargestRectangleArea.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.hard
import java.util.*
/**
* 84. 柱状图中最大的矩形
*
* 给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。
* 求在该柱状图中,能够勾勒出来的矩形的最大面积。
*/
class LargestRectangleArea {
companion object {
@JvmStatic
fun main(args: Array<String>) {
println(LargestRectangleArea(... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,385 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/main.kt | ngothanhtuan1203 | 359,752,793 | false | null | fun main(args: Array<String>) {
print(
"answer1:${
solution(
listOf(
intArrayOf(1, 4),
intArrayOf(3, 4),
intArrayOf(3, 10)
).toTypedArray()
).contentToString()
}\n"
)
print(
... | 0 | Kotlin | 0 | 0 | 5544f73ac70ea35adf605ac0a2a9210e9f475973 | 1,904 | rectangle_find_fourth_point | Apache License 2.0 |
30-days-leetcoding-challenge/April 18/src/Solution.kt | alexey-agafonov | 240,769,182 | false | null | class Solution {
fun minPathSum(grid: Array<IntArray>): Int {
val m = grid.size
val n = grid[0].size
val result = Array(m) { Array(n) {0} }
result[0][0] = grid[0][0]
// fill the first row
for (i in 1 until n) {
result[0][i] = result[0][i - 1] + grid[0][i]... | 0 | Kotlin | 0 | 0 | d43d9c911c6fd89343e392fd6f93b7e9d02a6c9e | 1,076 | leetcode | MIT License |
src/main/kotlin/com/kishor/kotlin/algo/recursion/Recursion.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.recursion
fun main() {
// headRecursion(5)
// tailRecursion(5)
// println("Result head ${factorial(10)}")
// println("Result tail ${factoTail(10)}")
println("Fibo Head ${headFibonacci(20)}")
println("Fibo Tail ${tailFibo(100, 0, 1)}")
println("Iterative Fibo ${ite... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 1,680 | DS_Algo_Kotlin | MIT License |
src/commonMain/kotlin/math/Path2d.kt | stewsters | 272,030,492 | false | null | package math
fun findPath2d(
size: Vec2,
cost: (Vec2) -> Double,
heuristic: (Vec2, Vec2) -> Double,
neighbors: (Vec2) -> List<Vec2>,
start: Vec2,
end: Vec2
): List<Vec2>? {
val costs = Matrix2d(size.x, size.y) { _, _ -> Double.MAX_VALUE }
val parent = Matrix2d<V... | 1 | Kotlin | 2 | 10 | c5b657801d325e2072dad9736db24144d29eddf8 | 1,934 | dungeon | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestSubsequence.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,324 | kotlab | Apache License 2.0 |
2021/19/program.kt | skrim | 434,960,545 | false | {"F#": 75199, "Zig": 61792, "Assembly": 6641, "Go": 4962, "Kotlin": 4486, "Julia": 3849, "PureScript": 3764, "Ada": 3369, "D": 3090, "Erlang": 3087, "Dhall": 2957, "Lua": 2895, "Fortran": 2626, "Shell": 2444, "Dart": 2246, "TSQL": 2240, "C++": 2189, "Crystal": 2018, "Racket": 1961, "C": 1476, "JetBrains MPS": 1426, "Ra... | data class Coordinate(val x: Int, val y: Int, val z: Int) {
fun add(other: Coordinate) : Coordinate = Coordinate(x + other.x, y + other.y, z + other.z)
fun subtract(other: Coordinate) : Coordinate = Coordinate(x - other.x, y - other.y, z - other.z)
fun manhattanDistance(other: Coordinate) : Int = Math.abs... | 0 | F# | 1 | 0 | 0e7f425fd50c96d52deca7e7868fcbf2a095d51c | 4,486 | AdventOfCode | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/PathSum.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,863 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestMultipleOfThree.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,413 | kotlab | Apache License 2.0 |
src/Day05.kt | halirutan | 575,809,118 | false | {"Kotlin": 24802} | class Cargo(input: List<String>) {
data class Move(val quantity: Int, val from: Int, val to: Int)
private val crates: List<MutableList<Char>> = List(9, init= { mutableListOf() })
private val moves: MutableList<Move>
init {
// Read in the cargo on all crates
for (s in input) {
... | 0 | Kotlin | 0 | 0 | 09de80723028f5f113e86351a5461c2634173168 | 2,542 | AoC2022 | Apache License 2.0 |
src/main/kotlin/org/cryptobiotic/mixnet/VectorQ.kt | JohnLCaron | 754,705,115 | false | {"Kotlin": 363510, "Java": 246365, "Shell": 7749, "C": 5751, "JavaScript": 2517} | package org.cryptobiotic.mixnet
import electionguard.core.*
data class MatrixQ(val elems: List<VectorQ> ) {
val nrows = elems.size
val width = elems[0].nelems
fun elem(row: Int, col: Int) = elems[row].elems[col]
constructor(group: GroupContext, llist: List<List<ElementModQ>>): this(llist.map{ Vector... | 0 | Kotlin | 0 | 0 | 63de19eb8ca2fb2b2d3286213b71c71097ab1d85 | 2,770 | egk-mixnet-vmn | MIT License |
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/heap/AbstractHeap.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.datastructuresandalgorithms.heap
import java.util.Collections
abstract class AbstractHeap<T> : Heap<T> {
abstract fun compare(first: T, second: T): Int
var elements: ArrayList<T> = ArrayList()
override fun peek(): T? = elements.firstOrNull()
private fun leftChildIndex(index: ... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 4,108 | KAHelpers | MIT License |
src/algorithms/MillerRabinPrimalityTest.kt | tpltn | 119,588,847 | false | null | package algorithms
import java.util.*
/**
* Тест простоты Миллера-Рабина
* @return true, если число вероятно простое
*/
fun millerRabinPrimalityTest(n: Int, rounds: Int = Math.log(n.toDouble()).toInt()): Boolean {
if (n % 2 == 0) {
return false
}
val (s, u) = extractPowerOfTwo(n - 1)
for ... | 0 | Kotlin | 1 | 0 | 2257a6a968bb8440f8a2a65a5fd31ff0fa5a5e8f | 1,298 | ads | The Unlicense |
kotlin/src/com/daily/algothrim/leetcode/medium/MaxArea.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.medium
/**
* 11. 盛最多水的容器
* 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0) 。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
*/
class MaxArea {
companion object {
@JvmStatic
fun main(args: Array<String>) {
println(Max... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,388 | daily_algorithm | Apache License 2.0 |
exercises/practice/largest-series-product/.meta/src/reference/kotlin/LargestSeriesProduct.kt | exercism | 47,675,865 | false | {"Kotlin": 382097, "Shell": 14600} | import java.lang.Math.max
class Series(private val digits: String) {
init {
require(digits.all { it.isDigit() })
}
fun getLargestProduct(span: Int): Long {
require(span >= 0)
require(digits.length >= span)
if(digits.isEmpty()) {
return 1
}
ret... | 51 | Kotlin | 190 | 199 | 7f1c7a11cfe84499cfef4ea2ecbc6c6bf34a6ab9 | 1,229 | kotlin | MIT License |
src/test/kotlin/aoc/Day8.kt | Lea369 | 728,236,141 | false | {"Kotlin": 36118} | package aoc_2023
import org.junit.jupiter.api.Nested
import java.math.BigInteger
import java.nio.file.Files
import java.nio.file.Paths
import java.util.stream.Collectors
import kotlin.test.Test
import kotlin.test.assertEquals
class Day8 {
data class Noeud(val origin: String, val destination: Pair<String, String>... | 0 | Kotlin | 0 | 0 | 1874184df87d7e494c0ff787ea187ea3566fbfbb | 3,828 | AoC | Apache License 2.0 |
src/Day04_part2.kt | yashpalrawat | 573,264,560 | false | {"Kotlin": 12474} | fun main() {
val input = readInput("Day04")
/* basically check if one pair is included within other pair
Pair(a,b) Pair(c,d)
the are inclusive if
c >= a && d <= b
a >= c && b <= d
* */
val result = input.sumOf {
val firstPair = it.split(",")[0].toIntPair()
... | 0 | Kotlin | 0 | 0 | 78a3a817709da6689b810a244b128a46a539511a | 970 | code-advent-2022 | Apache License 2.0 |
src/main/kotlin/dp/MinDecomp.kt | yx-z | 106,589,674 | false | null | package dp
import util.min
import kotlin.math.roundToInt
// given an integer, decompose it with combinations of 1, +, and *
// report the minimum amount of 1s needed
// ex. 14 = (1 + 1) * ((1 + 1 + 1) * (1 + 1) + 1) -> 8
fun main(args: Array<String>) {
val ints = intArrayOf(14, 21)
ints.forEach { println(it.minDeco... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 837 | AlgoKt | MIT License |
src/main/kotlin/me/peckb/aoc/_2020/calendar/day11/Day11.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} |
package me.peckb.aoc._2020.calendar.day11
import javax.inject.Inject
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import java.util.*
import kotlin.math.max
import kotlin.math.min
@Suppress("LocalVariableName")
class Day11 @Inject constructor(
private val generatorFactory: InputGeneratorFac... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 5,322 | advent-of-code | MIT License |
src/test/kotlin/io/github/aarjavp/aoc/day14/Day14Test.kt | AarjavP | 433,672,017 | false | {"Kotlin": 73104} | package io.github.aarjavp.aoc.day14
import io.github.aarjavp.aoc.day14.Day14.Rule
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import io.kotest.matchers.longs.shouldBeExactly
import io.kotest.matchers.maps.shouldContainExactly
import org.junit.jupiter.api.Test
class Day14Test {
val soluti... | 0 | Kotlin | 0 | 0 | 3f5908fa4991f9b21bb7e3428a359b218fad2a35 | 2,345 | advent-of-code-2021 | MIT License |
src/Day01.kt | mkfsn | 573,042,358 | false | {"Kotlin": 29625} | fun main() {
fun makeGroups(input: List<String>): List<Int> {
return input.chunkedBy { ele -> ele == "" }.map { nums -> nums.sumOf { it.toInt() } }
}
fun part1(input: List<String>): Int {
return makeGroups(input).max()
}
fun part2(input: List<String>): Int {
return makeGrou... | 0 | Kotlin | 0 | 1 | 8c7bdd66f8550a82030127aa36c2a6a4262592cd | 651 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day7/Day7.kt | crmitchelmore | 576,065,911 | false | {"Kotlin": 115199} | package day7
import helpers.ReadFile
class File {
var size: Int = 0
var parent: File? = null
var contents: MutableMap<String, File>? = null
constructor(size: Int, parent: File?) {
if (size == 0) {
contents = mutableMapOf()
}
this.parent = parent
this.size = ... | 0 | Kotlin | 0 | 0 | fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470 | 3,316 | adventofcode2022 | MIT License |
Algorithms/Warmup/A Very Big Sum/Solution.kt | ahmed-mahmoud-abo-elnaga | 449,443,709 | false | {"Kotlin": 14218} | /*
Problem: https://www.hackerrank.com/challenges/a-very-big-sum/problem
Kotlin Language Version
Tool Version : Android Studio
Thoughts :
1. Store all the input numbers in an array of size n.
2. Let the sum of all the input numbers be s. Initialize s to 0. Ensure that storage width of the data type of s ... | 0 | Kotlin | 1 | 1 | a65ee26d47b470b1cb2c1681e9d49fe48b7cb7fc | 1,385 | HackerRank | MIT License |
Collection/List/part06.kt | scp504677840 | 133,541,707 | false | null | package part06
import java.util.TreeSet
fun main(args: Array<String>) {
/*val treeSet = TreeSet<String>()
treeSet.add("adbbcc")
treeSet.add("abbabc")
treeSet.add("acbcc")
treeSet.add("abbc")
treeSet.add("abcc")
val iterator = treeSet.iterator()
while (iterator.hasNext()) {
p... | 0 | Kotlin | 0 | 0 | 36f9b85bf8d955b12a69684fc013125a26cae846 | 2,051 | JavaKotlin | Apache License 2.0 |
src/main/kotlin/arraysandstrings/NextClosestTime.kt | e-freiman | 471,473,372 | false | {"Kotlin": 78010} | package arraysandstrings
fun isValid(arr: IntArray): Boolean {
var hour = arr[0] * 10 + arr[1]
var minute = arr[2] * 10 + arr[3]
return hour < 24 && minute < 60
}
fun totalMinutes(arr: IntArray): Int {
var hour = arr[0] * 10 + arr[1]
var minute = arr[2] * 10 + arr[3]
return hour * 60 + minute... | 0 | Kotlin | 0 | 0 | fab7f275fbbafeeb79c520622995216f6c7d8642 | 1,578 | LeetcodeGoogleInterview | Apache License 2.0 |
bench/algorithm/pidigits/2n.kt | yonillasky | 509,064,681 | true | {"C#": 228581, "Rust": 201439, "Common Lisp": 142537, "Zig": 72107, "D": 66591, "Java": 60453, "C": 54246, "Go": 51605, "Kotlin": 48614, "Python": 45008, "TypeScript": 44466, "Dart": 40852, "OCaml": 38288, "Julia": 36099, "Chapel": 34726, "Crystal": 34498, "C++": 33006, "JavaScript": 32368, "Nim": 30426, "Odin": 30083,... | /* The Computer Language Benchmarks Game
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
Based on Java version (1) by <NAME>
Contributed by <NAME>
Modified by hanabi1224
*/
import com.soywiz.kbignum.*
fun main(args: Array<String>) {
val L = 10
var n = args[0].toInt()
var j = 0
... | 0 | C# | 0 | 0 | f72b031708c92f9814b8427b0dd08cb058aa6234 | 2,790 | Programming-Language-Benchmarks | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[28]实现 strStr().kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //实现 strStr() 函数。
//
// 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如
//果不存在,则返回 -1。
//
// 示例 1:
//
// 输入: haystack = "hello", needle = "ll"
//输出: 2
//
//
// 示例 2:
//
// 输入: haystack = "aaaaa", needle = "bba"
//输出: -1
//
//
// 说明:
//
// 当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。
/... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,336 | MyLeetCode | Apache License 2.0 |
src/medium/_31NextPermutation.kt | ilinqh | 390,190,883 | false | {"Kotlin": 382147, "Java": 32712} | package medium
class _31NextPermutation {
class Solution {
fun nextPermutation(nums: IntArray) {
var i = nums.size - 2
while (i >= 0 && nums[i] >= nums[i + 1]) {
i--
}
if (i >= 0) {
var j = nums.size - 1
while (... | 0 | Kotlin | 0 | 0 | 8d2060888123915d2ef2ade293e5b12c66fb3a3f | 2,116 | AlgorithmsProject | Apache License 2.0 |
app/src/main/java/com/denox/yugitournament/algorithm/Player.kt | AlleMazza | 479,006,331 | false | {"Kotlin": 46651} | package com.denox.yugitournament.algorithm
import com.denox.yugitournament.database.PlayerEntry
class Player(var seed: Int, var name: String = "placeholder") {
private var matchHistory = mutableListOf<Pair<Int, Int>?>()
// 0 loss 1 draw 3 win
// seed -1 = bye
var isDropped = false
var randomSeed =... | 0 | Kotlin | 0 | 0 | 5c418bb2023acd76715d2d97f5731a1ef0d0679d | 3,236 | YugiTournament | MIT License |
src/Day06.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | // https://adventofcode.com/2022/day/6
fun main() {
fun findMarker(input: String, markerSize: Int): Int? {
val markerCharacters =
input
.take(markerSize - 1)
.groupingBy { it }
.eachCount()
.toMutableMap()
for ((index, newC... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 1,031 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | ty-garside | 573,030,387 | false | {"Kotlin": 75779} | // Day 05 - Supply Stacks
// https://adventofcode.com/2022/day/5
fun main() {
fun Iterator<String>.initStacks() = mutableListOf<ArrayDeque<Char>>().apply {
while (hasNext()) {
val line = next()
if (line.isBlank()) break
line.chunked(4) { it.trim() }
.for... | 0 | Kotlin | 0 | 0 | 49ea6e3ad385b592867676766dafc48625568867 | 6,066 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/console/Runner.kt | oQaris | 402,822,990 | false | {"Kotlin": 147623} | package console
import algorithm.*
import com.udojava.evalex.Expression
import graphs.Graph
import kotlin.math.roundToInt
fun printPath(g: Graph, u: Int, v: Int) {
g.checkCorrectVer(u, v)
val path = route(g, u, v)
if (path.isEmpty())
println("The vertex $v is not reachable from $u.")
else
... | 1 | Kotlin | 0 | 2 | 2424cf11cf382c86e4fb40500dd5fded24f1858f | 3,976 | GraphProcessor | Apache License 2.0 |
src/main/kotlin/algorithms/LongestPathInDirectedGraph.kt | jimandreas | 377,843,697 | false | null | @file:Suppress(
"SameParameterValue", "UnnecessaryVariable", "UNUSED_VARIABLE", "ControlFlowWithEmptyBody", "unused",
"MemberVisibilityCanBePrivate", "LiftReturnOrAssignment"
)
package algorithms
import java.lang.Integer.max
/**
Code Challenge: Solve the Longest Path in a DAG Problem.
Input: An integer repr... | 0 | Kotlin | 0 | 0 | fa92b10ceca125dbe47e8961fa50242d33b2bb34 | 5,721 | stepikBioinformaticsCourse | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/day17/Day17.kt | jacobhyphenated | 572,119,677 | false | {"Kotlin": 157591} | package com.jacobhyphenated.day17
import com.jacobhyphenated.Day
import com.jacobhyphenated.day9.IntCode
import java.io.File
// Set And Forget
class Day17: Day<List<Long>> {
override fun getInput(): List<Long> {
return this.javaClass.classLoader.getResource("day17/input.txt")!!
.readText()
... | 0 | Kotlin | 0 | 0 | 1a0b9cb6e9a11750c5b3b5a9e6b3d63649bf78e4 | 6,297 | advent2019 | The Unlicense |
src/test/kotlin/dev/shtanko/algorithms/leetcode/PalindromePermutationTest.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,608 | kotlab | Apache License 2.0 |
constraints/src/test/kotlin/com/alexb/constraints/core/constraints/ConstraintsTest.kt | alexbaryzhikov | 201,620,351 | false | null | /*
Copyright 2019 <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 writing, software
distribut... | 0 | Kotlin | 0 | 0 | e67ae6b6be3e0012d0d03988afa22236fd62f122 | 7,599 | kotlin-constraints | Apache License 2.0 |
src/main/kotlin/me/peckb/aoc/_2023/calendar/day02/Day02.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2023.calendar.day02
import javax.inject.Inject
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import kotlin.math.max
class Day02 @Inject constructor(
private val generatorFactory: InputGeneratorFactory,
) {
fun partOne(filename: String) = generatorFactory.forFile(filena... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 1,905 | advent-of-code | MIT License |
constraints/src/test/kotlin/com/alexb/constraints/ProblemTest.kt | alexbaryzhikov | 201,620,351 | false | null | /*
Copyright 2019 <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 writing, software
distribut... | 0 | Kotlin | 0 | 0 | e67ae6b6be3e0012d0d03988afa22236fd62f122 | 4,550 | kotlin-constraints | Apache License 2.0 |
shared/src/main/kotlin/edu/cornell/cs/apl/attributes/Trees.kt | s-ren | 386,161,765 | true | {"Kotlin": 878757, "Java": 43761, "C++": 13898, "Python": 11991, "Lex": 6620, "Dockerfile": 1844, "Makefile": 1785, "SWIG": 1212, "Shell": 698} | package edu.cornell.cs.apl.attributes
import java.util.IdentityHashMap
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
/**
* Computes and stores parent/child/sibling relations in a tree structure.
*
* This class is a simplified version of Kiama's tree relat... | 0 | null | 0 | 0 | 337b3873e10f642706b195b10f939e9c1c7832ef | 3,037 | viaduct | MIT License |
src/Day10.kt | ostersc | 572,991,552 | false | {"Kotlin": 46059} | import kotlin.math.absoluteValue
class CPU(var cycle: Int = 0, var register: Int = 1, var total: Int = 0) {
fun tick() {
cycle++
maybeAccumulate()
}
private fun maybeAccumulate() {
if (20 == cycle % 40) {
total += register * cycle
}
}
fun add(toAdd: Int... | 0 | Kotlin | 0 | 1 | 3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9 | 1,784 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day5/day5part1.kts | avrilfanomar | 433,723,983 | false | null | package day5
import java.io.File
import kotlin.math.max
import kotlin.math.min
val resultMap = HashMap<String, Int>()
File("input.txt").forEachLine { line ->
val parts = line.split("->")
val x1y1 = parts[0].trim().split(",").map { it.trim().toInt() }
val x2y2 = parts[1].trim().split(",").map { it.trim().... | 0 | Kotlin | 0 | 0 | 266131628b7a58e9b577b7375d3ad6ad88a00954 | 843 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/g2101_2200/s2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2101_2200.s2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph
// #Medium #Depth_First_Search #Breadth_First_Search #Graph #Topological_Sort
// #2023_06_26_Time_841_ms_(100.00%)_Space_84.4_MB_(100.00%)
class Solution {
private lateinit var adjList: MutableList<MutableList<Int>>
private lateinit ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,791 | LeetCode-in-Kotlin | MIT License |
gcj/y2020/round1a/b.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package gcj.y2020.round1a
private fun solve(n: Int) = (0..n).first { solve(n.toLong(), it, true) }
private fun solve(n: Long, p: Int, dir: Boolean): Boolean {
if (p < 0) return true
if (n <= p || n >= 1L shl (p + 1)) return false
val order = if (dir) 0..p else p downTo 0
when {
solve(n - (1L shl p), p - 1, !dir... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 627 | competitions | The Unlicense |
src/Day01.kt | Frosendroska | 575,572,338 | false | {"Kotlin": 1582} | fun main() {
fun part1(input: List<String>): Int {
var max = 0
var cur = 0
for (i in input.indices) {
if (input[i].isNotEmpty()) {
cur += Integer.parseInt(input[i])
max = Math.max(max, cur)
} else {
cur = 0
}... | 0 | Kotlin | 0 | 0 | 012db7bf55ec0137d2246552676effd98b8cccfb | 919 | advent-of-code-kotlin-Frosendroska | Apache License 2.0 |
src/main/kotlin/03.kts | reitzig | 318,492,753 | false | null | import java.io.File
val map = File(args[0]).readLines()
val mapWidth = map[0].length
assert(args[0][0] == '.')
assert(args.all { it.length == mapWidth })
// I prefered this for part 1, but didn't see a neat way to generalize it
//var trees = map
// .mapIndexed { rowIndex, row -> row[(rowIndex * 3) % mapWidth]}... | 0 | Kotlin | 0 | 0 | f17184fe55dfe06ac8897c2ecfe329a1efbf6a09 | 900 | advent-of-code-2020 | The Unlicense |
base/impl/src/main/kotlin/com/yandex/yatagan/base/comparators.kt | yandex | 570,094,802 | false | {"Kotlin": 1413320} | /*
* Copyright 2022 Yandex LLC
*
* 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 wr... | 15 | Kotlin | 9 | 214 | cf1b298942c137d1681f8a1a0e6c38f4e0d7deb8 | 3,154 | yatagan | Apache License 2.0 |
src/Day05.kt | colmmurphyxyz | 572,533,739 | false | {"Kotlin": 19871} | import java.util.Stack
import kotlin.properties.Delegates
fun main() {
fun inputToStacks(input: List<String>): List<Stack<Char>> {
val stacks = List<Stack<Char>>(9) { Stack<Char>()}
// val stacks = listOf(Stack<Char>(), Stack<Char>(), Stack<Char>())
for (line in input) {
for (ch... | 0 | Kotlin | 0 | 0 | c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea | 2,299 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/kotlinkoans/algorithms/QSort.kt | marregui | 306,930,708 | false | null | /*
* Licensed to <NAME> ("marregui") under one or more contributor
* license agreements. See the LICENSE file distributed with this work
* for additional information regarding copyright ownership. You may
* obtain a copy at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law o... | 11 | Kotlin | 0 | 0 | 7609ec91ee125dae87bb3e654cd36e48853bc9ab | 2,009 | kotlin-koans | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.