path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/io/github/leandroborgesferreira/dagcommand/logic/CompilePhase.kt | leandroBorgesFerreira | 268,720,218 | false | {"Kotlin": 33555} | package io.github.leandroborgesferreira.dagcommand.logic
import io.github.leandroborgesferreira.dagcommand.domain.AdjacencyList
fun compilePhases(adjacencyList: AdjacencyList): MutableList<MutableSet<String>> {
// First, create a topologically sorted version of the graph
val sortedGraph = topologicalSort(adja... | 8 | Kotlin | 10 | 38 | 1bb81d504593b997e43851d09fbdb6a47662909b | 1,994 | dag-command | Apache License 2.0 |
gender/estimation/ssa/src/main/kotlin/org/otnip/gender/ssa/GenderEstimator.kt | equilibric | 127,651,354 | false | null | package org.otnip.gender.ssa
import java.io.IOException
import java.util.HashMap
import java.util.logging.Level
import java.util.logging.Logger
private const val PATH_NAME_COUNTS = "/org/otnip/gender/ssa/names.csv"
/**
* estimates gender based on first-names
*
* @author <NAME>
*/
object GenderEstimator {
pr... | 0 | Kotlin | 0 | 0 | 61b2c1a35679d77c135e6156607cd162c16593d6 | 2,970 | otnip.org | The Unlicense |
FunctionalProgramming/src/com/virtualpairprogrammings/application/KotlinExamples.kt | quickheaven | 379,434,442 | false | null | package com.virtualpairprogrammings.application
import com.virtualpairprogrammings.utilities.toSentenceCase
fun applySomeFunctionToAsString(inputString: String, myFunction: (String) -> String): String {
return myFunction(inputString)
}
fun main(args: Array<String>) {
// val result = applySomeFunctionToAsStri... | 0 | Kotlin | 0 | 0 | 02e261212c66ae0103f1cf2344cca1bb3e73a743 | 1,843 | springboot-app-kotlin | MIT License |
watchmen-model/src/main/kotlin/com/matrdata/watchmen/model/dqc/MonitorRule.kt | Indexical-Metrics-Measure-Advisory | 478,865,509 | false | {"Kotlin": 160616} | package com.matrdata.watchmen.model.dqc
import com.matrdata.watchmen.model.common.*
import java.time.LocalDateTime
enum class MonitorRuleCode(val code: String) {
// structure
RAW_MISMATCH_STRUCTURE("raw-mismatch-structure"),
// type
FACTOR_MISMATCH_ENUM("factor-mismatch-enum"),
FACTOR_MISMATCH_TYPE("factor-mism... | 0 | Kotlin | 0 | 0 | bd8ef342a31c4a2bac57f96f00e9069b386e7c5a | 3,296 | watchmen-kotlin | MIT License |
src/Day07.kt | martintomac | 726,272,603 | false | {"Kotlin": 19489} | data class Hand(val cards: String)
private const val FIVE_OF_A_KIND = 6
private const val FOUR_OF_A_KIND = 5
private const val FULL_HOUSE = 4
private const val THREE_OF_A_KIND = 3
private const val TWO_PAIRS = 2
private const val ONE_PAIRS = 1
val Hand.strength: Int
get() {
val cardToCount = cards.groupBy... | 0 | Kotlin | 0 | 0 | dc97b23f8461ceb9eb5a53d33986fb1e26469964 | 5,147 | advent-of-code-2023 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfSubarrays.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,921 | kotlab | Apache License 2.0 |
src/day13/Tokenizer.kt | g0dzill3r | 576,012,003 | false | {"Kotlin": 172121} | package day13
import peekable
import readInput
sealed class Token {
class LEFT_BRACKET : Token ()
class RIGHT_BRACKET : Token ()
class COMMA : Token ()
class NUMBER (val value: Int): Token ()
}
class Tokenizer (str: String) : Iterator<Token> {
val iter = str.iterator().peekable ()
override f... | 0 | Kotlin | 0 | 0 | 6ec11a5120e4eb180ab6aff3463a2563400cc0c3 | 1,762 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/days/aoc2022/Day22.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2022
import days.Day
import util.Point2d
class Day22 : Day(2022, 22) {
override fun partOne(): Any {
return calculateFinalPassword(inputList)
}
override fun partTwo(): Any {
return calculateFinalPasswordOnCube(inputList, 50)
}
fun calculateFinalPassword(input: Lis... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 19,153 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/_2023/Day02.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2023
import Day
import InputReader
import times
class Day02 : Day(2023, 2) {
private val firstCubesSet = mapOf(
"red" to 12,
"green" to 13,
"blue" to 14
)
override val firstTestAnswer = 8
override val secondTestAnswer = 2286
override fun first(input: InputReader... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 1,504 | advent-of-code | Apache License 2.0 |
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day14.kt | mpichler94 | 656,873,940 | false | {"Kotlin": 196457} | package at.mpichler.aoc.solutions.year2022
import at.mpichler.aoc.lib.*
import org.jetbrains.kotlinx.multik.api.mk
import org.jetbrains.kotlinx.multik.api.zeros
import org.jetbrains.kotlinx.multik.ndarray.data.D2Array
import org.jetbrains.kotlinx.multik.ndarray.data.set
import kotlin.math.max
import kotlin.math.min
o... | 0 | Kotlin | 0 | 0 | 69a0748ed640cf80301d8d93f25fb23cc367819c | 2,891 | advent-of-code-kotlin | MIT License |
src/main/kotlin/_50to100/Task68.kt | embuc | 735,933,359 | false | {"Kotlin": 110920, "Java": 60263} | package se.embuc._50to100
import se.embuc.Task
//Magic 5-gon ring
class Task68:Task {
override fun solve(): Any {
val result = findMagicRing(10)
return result?:""
}
fun findMagicRing(n: Int): String? {
val values = (n downTo 1).toList()
for (permutation in lexicographicalPermutations(values)) {
val sp... | 0 | Kotlin | 0 | 1 | 79c87068303f862037d27c1b33ea037ab43e500c | 1,581 | projecteuler | MIT License |
src/Day10.kt | Aldas25 | 572,846,570 | false | {"Kotlin": 106964} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
val cycles = listOf(20, 60, 100, 140, 180, 220)
var ans = 0
var x = 1
var cycleNumber = 0
fun oneCycle() {
cycleNumber++
if (cycleNumber in cycles)
ans += cycl... | 0 | Kotlin | 0 | 0 | 80785e323369b204c1057f49f5162b8017adb55a | 1,778 | Advent-of-Code-2022 | Apache License 2.0 |
kotlin/1871-jump-game-vii.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /*
* O(n) BFS
*/
class Solution {
fun canReach(s: String, minJump: Int, maxJump: Int): Boolean {
val q = LinkedList<Int>().apply { add(0) }
var farthest = 0
with (q) {
while (isNotEmpty()) {
val i = removeFirst()
val start = maxOf(i + minJump, far... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,192 | leetcode | MIT License |
solutions/src/MiniumSwapToMakeStringsEqual.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | /**
* https://leetcode.com/problems/minimum-swaps-to-make-strings-equal/
*
* Copied Answer. Hate these BS Gotchas
*/
class MiniumSwapToMakeStringsEqual {
fun minimumSwap(s1: String, s2: String): Int {
var x1 = 0 // number of 'x' in s1 (skip equal chars at same index)
var y1 = 0 // number of 'y' ... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,476 | leetcode-solutions | MIT License |
src/main/kotlin/Day18.kt | clechasseur | 267,632,210 | false | null | object Day18 {
private const val input = ".^^^^^.^^^..^^^^^...^.^..^^^.^^....^.^...^^^...^^^^..^...^...^^.^.^.......^..^^...^.^.^^..^^^^^...^."
private val traps = listOf("^^.", ".^^", "^..", "..^")
fun part1(): Int = numSafeTiles(40)
fun part2(): Int = numSafeTiles(400_000)
private fun numSafeT... | 0 | Kotlin | 0 | 0 | 120795d90c47e80bfa2346bd6ab19ab6b7054167 | 860 | adventofcode2016 | MIT License |
src/main/kotlin/aoc2015/MedicineForRudolph.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2015
import komu.adventofcode.utils.contentMatch
import komu.adventofcode.utils.nonEmptyLines
fun medicineForRudolph1(s: String): Int {
val rules = MedicineRule.parseRules(s)
val medicine = Molecule.parse(s.nonEmptyLines().last())
return rules.flatMap { it.rewrite(medicine) }... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,530 | advent-of-code | MIT License |
Kotlin/src/LongestPalindromicSubstring.kt | TonnyL | 106,459,115 | false | null | /**
* Given a string s, find the longest palindromic substring in s.
* You may assume that the maximum length of s is 1000.
*
* Example:
*
* Input: "babad"
*
* Output: "bab"
*
* Note: "aba" is also a valid answer.
* Example:
*
* Input: "cbbd"
*
* Output: "bb"
*
* Accepted.
*/
class LongestPalindromicS... | 1 | Swift | 22 | 189 | 39f85cdedaaf5b85f7ce842ecef975301fc974cf | 1,502 | Windary | MIT License |
capitulo5/src/main/kotlin/5.10ArredondamentoNumero.kt | Cursos-Livros | 667,537,024 | false | {"Kotlin": 104564} |
import kotlin.math.round
//5.10 (Arredondamento de números) Para arredondar números para casas decimais específicas, use uma instrução como
//duplo y = Math.floor(x * 10 + 0,5) / 10;
//que arredonda x para a décima posição (isto é, a primeira posição à direita da vírgula) ou
//duplo y = Math.floor(x * 100 + 0,5) / 10... | 0 | Kotlin | 0 | 0 | f2e005135a62b15360c2a26fb6bc2cbad18812dd | 2,001 | Kotlin-Como-Programar | MIT License |
sudoku_kotlin/src/commonMain/kotlin/Solver.kt | rvaccarim | 282,497,162 | false | {"C#": 24517, "Java": 23012, "Kotlin": 10215, "HTML": 3796, "CSS": 3348} | class Solver {
fun solve(board: Board): Board? {
// optimize board
// reorder so that we have the sections with more hints in the upper section (reduces the
// search space)
val sections = scoreSections(board)
val swapInstructions = HashMap<Int, Int>()
var s = 0
... | 0 | C# | 1 | 2 | 1305cea629767a6ac9dfb253851662aa4b6c7add | 4,535 | sudoku_wasm | MIT License |
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day07.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentyone
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.median
import fr.outadoc.aoc.scaffold.readDayInput
import kotlin.math.abs
class Day07 : Day<Int> {
private val input = readDayInput()
.split(',')
.map { it.toInt() }
.sorted()
ove... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 1,227 | adventofcode | Apache License 2.0 |
kotlin-practice/src/main/kotlin/function/CalculateHoursOfStudying.kt | nicolegeorgieva | 590,020,790 | false | {"Kotlin": 120359} | package function
fun main() {
var calculatedTime: Double = 2.08
val currentStudyMins = try {
calculateCurrentTimeOfStudyingInMin("18:43", "")
} catch (e: Exception) {
0
}
val currentStudy = try {
calculateCurrentTimeOfStudying(currentStudyMins)
} catch (e: Exception) {... | 0 | Kotlin | 0 | 1 | c96a0234cc467dfaee258bdea8ddc743627e2e20 | 2,150 | kotlin-practice | MIT License |
src/main/kotlin/g1001_1100/s1026_maximum_difference_between_node_and_ancestor/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1001_1100.s1026_maximum_difference_between_node_and_ancestor
// #Medium #Depth_First_Search #Tree #Binary_Tree
// #2023_05_23_Time_155_ms_(77.78%)_Space_36.6_MB_(48.15%)
import com_github_leetcode.TreeNode
import kotlin.math.abs
/*
* Example:
* var ti = TreeNode(5)
* var v = ti.`val`
* Definition for a ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,295 | LeetCode-in-Kotlin | MIT License |
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec09.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2020
import org.elwaxoro.advent.PuzzleDayTester
class Dec09 : PuzzleDayTester(9, 2020) {
override fun part1(): Long = parse().findInvalid()
override fun part2(): Long = parse().let { input ->
input.findInvalid().let { target ->
// cheating here, based on puzz... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 1,186 | advent-of-code | MIT License |
src/day01/Day01_idiomatic.kt | armanaaquib | 572,849,507 | false | {"Kotlin": 34114} | package day01
import readInputAsText
fun main() {
fun parseInput(input: String) = input.split("\n\n")
.map { elf -> elf.split("\n").map { it.toInt() } }
fun part1(input: String): Int {
val data = parseInput(input)
return data.maxOf { it.sum() }
}
fun part2(input: String): In... | 0 | Kotlin | 0 | 0 | 47c41ceddacb17e28bdbb9449bfde5881fa851b7 | 719 | aoc-2022 | Apache License 2.0 |
kmath-stat/src/commonMain/kotlin/space/kscience/kmath/optimization/NoDerivFunctionOptimization.kt | therealansh | 373,284,570 | true | {"Kotlin": 1071813, "ANTLR": 887} | /*
* Copyright 2018-2021 KMath contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package space.kscience.kmath.optimization
import space.kscience.kmath.expressions.Expression
import space.kscience.kmath.misc.Symbol
import space.kscien... | 0 | null | 0 | 0 | 4065466be339017780b0ac4b98a9eda2cc2378e4 | 2,513 | kmath | Apache License 2.0 |
puzzles/src/test/kotlin/com/kotlinground/puzzles/arrays/longestincreasingsubsequence/LongestIncreasingSubsequenceTest.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.puzzles.arrays.longestincreasingsubsequence
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
class LongestIncreasingSubsequenceTest {
@Test
fun `should return 3 from input of (1, 2, 1, 5)`() {
val nums = intArrayOf(1, 2, 1, 5)
val expected =... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 2,224 | KotlinGround | MIT License |
src/Day08.kt | mcrispim | 573,449,109 | false | {"Kotlin": 46488} | fun main() {
data class Position(val line: Int, val col: Int)
class Forest2 (input: List<String>) {
val treeMap = mutableMapOf<Position, Int>()
val lines = input.size
val cols = input.first().length
init {
for ((line, lineTrees) in input.withIndex()) {
... | 0 | Kotlin | 0 | 0 | 5fcacc6316e1576a172a46ba5fc9f70bcb41f532 | 5,566 | AoC2022 | Apache License 2.0 |
src/main/kotlin/no/nav/paw/domain/EndeligPeriode.kt | navikt | 617,945,934 | false | {"Kotlin": 53555, "PLpgSQL": 1001, "Dockerfile": 130} | package no.nav.paw.domain
import no.nav.paw.aareg.Arbeidsforhold
import java.time.LocalDate
data class EndeligPeriode(
val fom: LocalDate,
val tom: LocalDate
)
fun List<Arbeidsforhold>.tilEndeligePerioder(): List<EndeligPeriode> = this
.map { it.ansettelsesperiode.periode }
.map { EndeligPeriode(it.f... | 0 | Kotlin | 0 | 0 | d346d269362c328327e2cd38a9bea9ea468da22d | 1,500 | paw-arbeidssoker-profilering | MIT License |
Generics/Generic functions/src/Task.kt | kormeian | 673,850,259 | false | null | fun <T, C : MutableCollection<T>> Collection<T>.partitionTo(
first: C,
second: C,
predicate: (T) -> Boolean
): Pair<C, C> {
this.forEach { if (predicate(it)) first.add(it) else second.add(it) }
return Pair(first, second)
}
fun partitionWordsAndLines() {
val (words, lines) = listOf("a", "a b", "... | 0 | Kotlin | 0 | 0 | 550c822ff144241f6f3c036adb34a29b918c025b | 737 | kotlin_koans | MIT License |
solutions/src/solutions/y20/day 7 converted.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.y20.d07c
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 = mutableMapOf<String, List<String>>()... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 1,508 | AdventOfCodeSolutions | MIT License |
src/main/kotlin/aoc2020/day2.kt | sodaplayer | 434,841,315 | false | {"Kotlin": 31068} | package aoc2020.day2
import aoc2020.utils.loadInput
private val regex = Regex("""(\d+)-(\d+) ([a-z]): ([a-z]+)""")
fun main() {
val passwords = loadInput("/2020/day2")
.bufferedReader()
.readLines()
.map(::parse)
passwords
.count(PasswordEntry::validPassword)
.apply(:... | 0 | Kotlin | 0 | 0 | 2d72897e1202ee816aa0e4834690a13f5ce19747 | 1,023 | aoc-kotlin | Apache License 2.0 |
src/test/kotlin/ch/ranil/aoc/aoc2023/Day22.kt | stravag | 572,872,641 | false | {"Kotlin": 234222} | package ch.ranil.aoc.aoc2023
import ch.ranil.aoc.AbstractDay
import org.junit.jupiter.api.Test
import kotlin.math.abs
import kotlin.math.min
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class Day22 : AbstractDay() {
@Test
fun brickTests() {
val horizontalBrick = Brick.parse("0,0,2~0,... | 0 | Kotlin | 1 | 0 | dbd25877071cbb015f8da161afb30cf1968249a8 | 7,336 | aoc | Apache License 2.0 |
src/main/kotlin/info/jukov/adventofcode/y2022/Day11.kt | jukov | 572,271,165 | false | {"Kotlin": 78755} | package info.jukov.adventofcode.y2022
import info.jukov.adventofcode.Day
import java.io.BufferedReader
/**
* Thanks to https://todd.ginsberg.com/post/advent-of-code/2022/day11/
* for explaining proper solution of part 2
*/
object Day11 : Day() {
override val year: Int = 2022
override val day: Int = 11
... | 0 | Kotlin | 1 | 0 | 5fbdaf39a508dec80e0aa0b87035984cfd8af1bb | 4,177 | AdventOfCode | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/Pow.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 | 2,461 | kotlab | Apache License 2.0 |
src/main/kotlin/io/array/LongestCommonPrefix.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.array
import io.utils.runTests
// https://leetcode.com/explore/learn/card/array-and-string/203/introduction-to-string/1162/
class LongestCommonPrefix {
fun execute(input: Array<String>): String {
var commonPrefix = ""
val minLength = input.fold(null as Int?) { acc, value -> acc?.let { minOf(it, ... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,509 | coding | MIT License |
src/main/kotlin/org/opentripplanner/trakpi/model/transit.kt | opentripplanner | 208,077,511 | false | null | package org.opentripplanner.trakpi.model
import org.opentripplanner.trakpi.model.TransitMode.Companion.DEFAULT
import org.opentripplanner.trakpi.model.TransitMode.Companion.TRANSIT
import java.time.Duration
import java.time.LocalDateTime
/**
* We do not support all modes: CABLE_CAR, GONDOLA, FUNICULAR is not suppor... | 2 | Kotlin | 2 | 4 | 852612750a4fe5748863d8f44525e5cd2a56af8b | 2,699 | TrakPi | MIT License |
radix_sort.kt | mehran-naghizadeh | 439,232,419 | false | {"Elixir": 1610, "JavaScript": 1297, "Kotlin": 1258, "Python": 1213, "Ruby": 1023} | fun main() = unitTest()
fun radixSort(list: List<Int>): List<Int> {
val count = maxDigits(list)
var sorted = stringify(list)
for(i in 1..count) {
sorted = bucketize(sorted, count - i).flatten()
}
return sorted.map { it.toInt() }
}
fun bucketize(list: List<String>, position: Int): List<List<String>> {
... | 0 | Elixir | 0 | 0 | 8b8bb34f1ecb7fc2e10dc81765ab8b0c0b907548 | 1,258 | radix-sort | MIT License |
src/test/kotlin/chapter3/solutions/ex23/listing.kt | DavidGomesh | 680,857,367 | false | {"Kotlin": 204685} | package chapter3.solutions.ex23
import chapter3.Cons
import chapter3.List
import chapter3.Nil
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.WordSpec
// tag::init[]
tailrec fun <A> startsWith(l1: List<A>, l2: List<A>): Boolean =
when (l1) {
is Nil -> l2 == Nil
is Cons -> when ... | 0 | Kotlin | 0 | 0 | 41fd131cd5049cbafce8efff044bc00d8acddebd | 2,772 | fp-kotlin | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem1337/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1337
/**
* LeetCode page: [1337. The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/);
*/
class Solution {
/* Complexity:
* Time O(MN+MLogM) and Space O(M) where MM and N are the number of rows
* and columns of mat;
*/... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,036 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/Day02.kt | AlmazKo | 576,500,782 | false | {"Kotlin": 26733} | import Day02.Result.DRAW
import Day02.Result.LOSS
import Day02.Result.WIN
import Day02.Shape.PAPER
import Day02.Shape.ROCK
import Day02.Shape.SCISSORS
/**
* [Description](https://adventofcode.com/2022/day/2)
*/
object Day02 : Task {
@JvmStatic
fun main(args: Array<String>) = execute()
override fun part... | 0 | Kotlin | 0 | 1 | 109cb10927328ce296a6b0a3600edbc6e7f0dc9f | 2,019 | advent2022 | MIT License |
tabby-fp/src/main/kotlin/com/sksamuel/tabby/results/zip.kt | sksamuel | 280,509,527 | false | {"Kotlin": 82291} | package com.sksamuel.tabby.results
import com.sksamuel.tabby.Tuple4
import com.sksamuel.tabby.Tuple5
fun <A, B> Result<A>.zip(other: Result<B>): Result<Pair<A, B>> {
return this.flatMap { a ->
other.map { b -> Pair(a, b) }
}
}
fun <A, B, C> Result<A>.zip(b: Result<B>, c: Result<C>): Result<Triple<A, B, C... | 0 | Kotlin | 8 | 23 | 0fa37638712efd6b059f280f95a8a2f87c95af89 | 1,201 | tabby | Apache License 2.0 |
common/src/main/kotlin/com/codeviking/kxg/math/Partition.kt | dwbullok | 153,008,678 | true | {"Kotlin": 925045} | package com.codeviking.kxg.math
import kotlin.math.*
/**
* Partitions items with the given comparator. After partitioning, all elements left of k are smaller
* than all elements right of k with respect to the given comparator function.
*
* This method implements the Floyd-Rivest selection algorithm:
* https://e... | 0 | Kotlin | 0 | 0 | 5121acb8d80480bf60624ae9ef87a39b97428e27 | 1,848 | kool | Apache License 2.0 |
src/Day10.kt | floblaf | 572,892,347 | false | {"Kotlin": 28107} | fun main() {
fun part1(cycles: List<Int>): Int {
return listOf(20, 60, 100, 140, 180, 220).sumOf { it * cycles[it-1] }
}
fun part2(cycles: List<Int>): String {
return buildString {
cycles.forEachIndexed { index, i ->
if (index >= 40 && index % 40 == 0) {
... | 0 | Kotlin | 0 | 0 | a541b14e8cb401390ebdf575a057e19c6caa7c2a | 947 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dk/aoc/day13.kt | danielkr | 114,923,329 | false | null | package dk.aoc.day13
import java.io.File
import java.util.*
val LAYER_PATTERN = Regex("""(\d+): (\d+)""")
fun main(args: Array<String>) {
val inputFile = File("src/main/resources/inputs/day13.txt")
val lines = inputFile.readLines()
val layers = parseLayers(lines)
val severity = calculateSeverity(laye... | 0 | Kotlin | 0 | 0 | 366bacfe8c0ac1a135fe0030bdbad01199f21d2a | 1,058 | adventofcode2017 | Apache License 2.0 |
src/day10/result.kt | davidcurrie | 437,645,413 | false | {"Kotlin": 37294} | package day10
import java.io.File
val closings = mapOf('(' to ')', '[' to ']', '{' to '}', '<' to '>')
val partOneScores = mapOf(null to 0, ')' to 3, ']' to 57, '}' to 1197, '>' to 25137)
val partTwoScores = mapOf(')' to 1, ']' to 2, '}' to 3, '>' to 4)
fun main() {
val lines = File("src/day10/input.txt").readLi... | 0 | Kotlin | 0 | 0 | dd37372420dc4b80066efd7250dd3711bc677f4c | 968 | advent-of-code-2021 | MIT License |
y2020/src/main/kotlin/adventofcode/y2020/Day01.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2020
import adventofcode.io.AdventSolution
fun main() = Day01.solve()
object Day01 : AdventSolution(2020, 1, "Report Repair")
{
override fun solvePartOne(input: String): Int
{
val entries = input
.lines()
.map(String::toInt)
.filter { it < 2... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 943 | advent-of-code | MIT License |
src/main/kotlin/io/math/SumClosest3Numbers.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.math
import io.utils.runTests
import kotlin.math.absoluteValue
// https://leetcode.com/problems/3sum-closest/
class SumClosest3Numbers {
fun execute(input: IntArray, target: Int): Int {
input.sort()
var closest: Int? = null
for (index in 0 until input.size - 2) {
val value = input[inde... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,172 | coding | MIT License |
kotlin/src/elves/day03/RuckSack.kt | marc-bouvier-katas | 573,373,008 | false | {"Kotlin": 15017, "TypeScript": 1128, "PHP": 1033, "JavaScript": 201, "Makefile": 74, "Shell": 57} | package elves.day03
class RuckSack(private val elveEncodedContent: String) {
val priorityOfSharedCategory: Int?
init {
val firstCompartment = Compartment(elveEncodedContent.take(elveEncodedContent.length / 2))
val secondCompartment = Compartment(elveEncodedContent.takeLast(elveEncodedContent.... | 0 | Kotlin | 0 | 0 | 2198922b4c7c43220ad10c6e56171868bf464d6f | 3,097 | aoc-02 | MIT License |
src/Day01.kt | Ramo-11 | 573,610,722 | false | {"Kotlin": 21264} | fun main() {
fun helper(input: List<String>): MutableList<Int> {
val list: MutableList<Int> = ArrayList()
var counter = 0
for (i in input.indices) {
if (input[i].isBlank()) {
list.add(counter)
counter = 0
continue
}
... | 0 | Kotlin | 0 | 0 | a122cca3423c9849ceea5a4b69b4d96fdeeadd01 | 924 | advent-of-code-kotlin | Apache License 2.0 |
src/test/kotlin/com/winterbe/challenge/VertexDistance.kt | winterbe | 152,978,821 | false | null | package com.winterbe.challenge
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import kotlin.math.pow
import kotlin.math.sqrt
// Given a list of points as [x,y] pairs; a vertex in [x,y] form; and an integer k,
// return the kth ... | 0 | Kotlin | 4 | 10 | 3a0a911e4f601261ddb544da86647530371c8ba9 | 2,140 | challenge | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions43.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
import platform.posix.pow
/**
* 从n到一个整数中1出现的次数
*/
fun test43() {
println("1出现的次数为:${numberOf1Between1AndN(101)}")
}
fun numberOf1Between1AndN(number: Int): Int {
var divisor = number
var b = 0
while (divisor != 0) {
divisor /= 10
b++
}
divisor = number
val numberA... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,360 | Algorithm | Apache License 2.0 |
exact-numbers/src/main/kotlin/xyz/lbres/exactnumbers/irrationals/sqrt/Sqrt.kt | lbressler13 | 491,698,766 | false | {"Kotlin": 271669} | package xyz.lbres.exactnumbers.irrationals.sqrt
import xyz.lbres.exactnumbers.exactfraction.ExactFraction
import xyz.lbres.exactnumbers.irrationals.IrrationalNumber
import xyz.lbres.kotlinutils.general.simpleIf
import xyz.lbres.kotlinutils.set.multiset.const.ConstMultiSet
import xyz.lbres.kotlinutils.set.multiset.cons... | 0 | Kotlin | 0 | 2 | 814cec02f68f86310f7a9147eb2ee0a8e82b9e1e | 3,311 | exact-numbers | MIT License |
src/main/kotlin/ru/nrcki/biokotlin/BioSequence.kt | laxeye | 164,879,760 | false | null | package ru.nrcki.biokotlin
import kotlin.math.round
interface IBioSequence {
val header: String
val gaplength: Int
val sequence: String
val length: Int
val id: String
fun formatted(): String
fun getChar(i: Int): Char
}
open class BioSequence(final override val header: String, final override val sequence: Str... | 7 | Kotlin | 0 | 0 | fb86e738ee31a082bb71e2c8a73d34e65197f2eb | 5,347 | BioKotlin | MIT License |
advent_of_code/2018/solutions/day_9_b.kt | migafgarcia | 63,630,233 | false | {"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343} | import java.io.File
import java.util.*
fun main(args: Array<String>) {
val input = File(args[0]).readText().split(" ").mapNotNull { it.toIntOrNull() }
assert(score(9, 25) == 32L)
assert(score(10, 1618) == 8317L)
assert(score(13, 7999) == 146373L)
assert(score(17, 1104) == 2764L)
assert(scor... | 0 | C++ | 3 | 9 | 82f5e482c0c3c03fd39e46aa70cab79391ed2dc5 | 1,106 | programming-challenges | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/QuickSort.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
/**
* 快速排序 Kotlin 实现
*/
fun testQuick() {
val array = intArrayOf(5, 7, 2, 9, 3, 1, 4, 0, 8, 6)
array.quickSort()
array.forEach { print("$it ") }
}
fun IntArray.quickSort() {
quickSort(0, this.size - 1)
}
private fun IntArray.quickSort(low: Int, height: Int) {
if (height... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 820 | Algorithm | Apache License 2.0 |
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/kotlin/melegit.kt | mouredev | 581,049,695 | false | {"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ... | package reto4
/*
* Escribe un programa que, dado un número, compruebe y muestre si es primo, fibonacci y par.
* Ejemplos:
* - Con el número 2, nos dirá: "2 es primo, fibonacci y es par"
* - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar"
*/
fun main() {
println(buildStringResult(2))
p... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 1,790 | retos-programacion-2023 | Apache License 2.0 |
src/main/java/com/tutuland/aoc2017/Day3.kt | gacordeiro | 115,743,800 | false | null | package com.tutuland.aoc2017
fun findEnclosingSquareSideFor(num: Int): Int {
var i = 1
while (i*i < num) i += 2
return i
}
fun calculateSpiralDistanceFor(num: Int): Int {
if (num < 2) return 0
val squareSide: Int = findEnclosingSquareSideFor(num)
val squareSteps: Int = (4 * squareSide) - 4
... | 0 | Kotlin | 0 | 0 | dc880decebe5bb1c3f297b9864c491e1cec616b5 | 1,948 | aoc2017 | MIT License |
src/main/kotlin/tree/segmentTree/SubsetSum.kt | ghonix | 88,671,637 | false | null | package tree.segmentTree
import kotlin.math.*
class SubsetSum(list: Array<Int>) {
private var segmentTree: IntArray
override fun toString(): String {
return segmentTree.contentToString()
}
init {
val height = ceil(log(list.size.toDouble(), 2.0))
val maxSize = (height + 1).pow... | 0 | Kotlin | 0 | 2 | 25d4ba029e4223ad88a2c353a56c966316dd577e | 1,954 | Problems | Apache License 2.0 |
src/main/java/de/mrapp/textmining/util/metrics/OptimalStringAlignmentDistance.kt | michael-rapp | 111,042,013 | false | null | /*
* Copyright 2017 - 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 wr... | 0 | Kotlin | 0 | 1 | 2103d68964608780ca1d572887ba57c595adcb7b | 3,016 | TextMiningUtil | Apache License 2.0 |
problems/0005_longest-palindromic-substring/manacher/Solution.kt | xieweiking | 230,633,424 | false | {"C": 18163, "Rust": 11685, "Swift": 10971, "Java": 9906, "PHP": 9807, "C++": 9229, "C#": 8867, "Kotlin": 8762, "Scala": 8523, "JavaScript": 8164, "Go": 8157, "Ruby": 7835, "Python": 7755} | class Solution {
fun longestPalindrome(s: String): String {
if (s.length <= 1)
return s
val size = 2 * s.length + 1;
val t = CharArray(size)
for (i in 0..(s.length - 1))
t[2 * i + 1] = s[i]
val pLens = IntArray(size)
var c = 0
var r = 0... | 0 | C | 0 | 0 | a7a1fc3ac61146a392cb5d81a680015a12c2b44b | 1,158 | leetcode-cn | MIT License |
day10/src/test/kotlin/be/swsb/aoc2020/Day10Test.kt | Sch3lp | 318,098,967 | false | null | package be.swsb.aoc2020
import be.swsb.aoc.common.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class Day10Test {
@Nested
inner class Exercise1... | 0 | Kotlin | 0 | 0 | 32630a7efa7893b4540fd91d52c2ff3588174c96 | 3,115 | Advent-of-Code-2020 | MIT License |
src/test/kotlin/com/igorwojda/string/ispalindrome/basic/Solution.kt | igorwojda | 159,511,104 | false | {"Kotlin": 254856} | package com.igorwojda.string.ispalindrome.basic
// string reverse
private object Solution1 {
private fun isPalindrome(str: String): Boolean {
return str == str.reversed()
}
}
// iterative, double pointer solution
private object Solution2 {
private fun isPalindrome(str: String): Boolean {
v... | 9 | Kotlin | 225 | 895 | b09b738846e9f30ad2e9716e4e1401e2724aeaec | 1,483 | kotlin-coding-challenges | MIT License |
Problems/Algorithms/1020. Number Enclaves/NumberEnclaves.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun numEnclaves(grid: Array<IntArray>): Int {
val n = grid.size
val m = grid[0].size
val visited = Array(n) { BooleanArray(m) { false } }
val neighbors = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0))
var ans = 0
... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,897 | leet-code | MIT License |
src/test/kotlin/samples/samples.kt | junkdog | 79,411,642 | false | null | package samples
import net.onedaybeard.transducers.*
typealias Sample = org.junit.Test
class Samples {
@Sample
fun branch_a() {
intoList(xf = copy<Int>() +
branch(test = { it % 4 == 0 },
xfTrue = map { i: Int -> i * 100 },
... | 0 | Kotlin | 0 | 5 | ebbc0b8928748a3fae63b50558bd3f02d6c24b92 | 3,643 | transducers-kotlin | Apache License 2.0 |
project_euler_kotlin/src/main/kotlin/Solution0015.kt | NekoGoddessAlyx | 522,068,054 | false | {"Kotlin": 44135, "Rust": 24687} | import java.math.BigInteger
class Solution0015 : Solution() {
/*
* (1, 0) can be restated as starting at (0, 0) with goal (19, 20)
* (0, 0) with goal (0, 0) can be said to be complete
*
* solve recursively
*
* The total number of moves that can be made at one point are the sum of bot... | 0 | Kotlin | 0 | 0 | f899b786d5ea5ffd79da51604dc18c16308d2a8a | 1,836 | Project-Euler | The Unlicense |
kex-runner/src/main/kotlin/org/vorpal/research/kex/state/transformer/PathChecker.kt | vorpal-research | 204,454,367 | false | {"Kotlin": 2057972, "Java": 58370, "Python": 1523} | package org.vorpal.research.kex.state.transformer
import org.vorpal.research.kex.smt.SMTModel
import org.vorpal.research.kex.state.BasicState
import org.vorpal.research.kex.state.ChoiceState
import org.vorpal.research.kex.state.PredicateState
import org.vorpal.research.kex.state.predicate.DefaultSwitchPredicate
import... | 6 | Kotlin | 17 | 25 | d028f0e794cd310194de257a1f40399ecdb9ebd7 | 3,358 | kex | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[121]买卖股票的最佳时机.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个数组 prices ,它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格。
//
// 你只能选择 某一天 买入这只股票,并选择在 未来的某一个不同的日子 卖出该股票。设计一个算法来计算你所能获取的最大利润。
//
// 返回你可以从这笔交易中获取的最大利润。如果你不能获取任何利润,返回 0 。
//
//
//
// 示例 1:
//
//
//输入:[7,1,5,3,6,4]
//输出:5
//解释:在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。
// 注意利润不能是 7-1 = 6, 因为卖出价格需要... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,781 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/ru/amai/study/coursera/kotlin/week4/Rational.kt | slobanov | 401,728,467 | true | {"Kotlin": 149929} | package ru.amai.study.coursera.kotlin.week4
import java.math.BigInteger
import java.math.BigInteger.ONE
import java.math.BigInteger.ZERO
class Rational(n: BigInteger, d: BigInteger): Comparable<Rational> {
private val n: BigInteger
private val d: BigInteger
init {
require(d != ZERO) { "denominato... | 1 | Kotlin | 4 | 0 | ff8cafe57166b57900cbddf2a00b670e12ad1410 | 2,273 | kotlin-for-java-dev | MIT License |
src/main/kotlin/wtf/log/xmas2021/day/day17/Day17.kt | damianw | 434,043,459 | false | {"Kotlin": 62890} | package wtf.log.xmas2021.day.day17
import wtf.log.xmas2021.Day
import wtf.log.xmas2021.util.math.Point
import wtf.log.xmas2021.util.math.Rect
import java.io.BufferedReader
import kotlin.math.max
import kotlin.math.sign
object Day17 : Day<Rect, Int, Int> {
private val REGEX = Regex("""target area: x=(-?\d+)..(-?\... | 0 | Kotlin | 0 | 0 | 1c4c12546ea3de0e7298c2771dc93e578f11a9c6 | 1,810 | AdventOfKotlin2021 | BSD Source Code Attribution |
src/leecode/04.kt | DavidZhong003 | 157,566,685 | false | null | package leecode
import kotlin.math.max
import kotlin.math.min
/**
*
* @author doive
* on 2018/11/11 17:17
*/
val quest4 = """
给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 。
请找出这两个有序数组的中位数。要求算法的时间复杂度为 O(log (m+n)) 。
你可以假设 nums1 和 nums2 不同时为空。
""".trimIndent()
/**
* 获取一个数组中[start,end]的中位数
*/
fun IntArray.findMid(star... | 0 | Kotlin | 0 | 1 | 7eabe9d651013bf06fa813734d6556d5c05791dc | 1,961 | LeetCode-kt | Apache License 2.0 |
app/app/src/main/java/com/seljabali/practiceproblems/ui/htree/HTree.kt | seljabali | 213,567,334 | false | null | package com.seljabali.practiceproblems.ui.htree
import kotlin.math.sqrt
class HTree private constructor(midPoint: Point, length: Double) {
private val leftLine: Line
private val rightLine: Line
private val middleLine: Line
private val height: Double
private var topLeftTree: HTree? = null
priv... | 0 | Kotlin | 0 | 0 | 46b8d88f2291782a9148330e4f8d740cbd2ea371 | 3,213 | practice-problems-android | Creative Commons Zero v1.0 Universal |
src/2023/Day16.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2023`
import common.Linearizer
import java.io.File
import java.lang.RuntimeException
import java.util.*
fun main() {
Day16().solve()
}
class Day16 {
val input1 = """
.|...\....
|.-.\.....
.....|-...
........|.
..........
.........\
..../.\\.... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 4,081 | advent-of-code | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/MoveZeroes.kt | faniabdullah | 382,893,751 | false | null | //Given an integer array nums, move all 0's to the end of it while maintaining
//the relative order of the non-zero elements.
//
// Note that you must do this in-place without making a copy of the array.
//
//
// Example 1:
// Input: nums = [0,1,0,3,12]
//Output: [1,3,12,0,0]
// Example 2:
// Input: nums = [0]
//O... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 1,504 | dsa-kotlin | MIT License |
src/Day02.kt | hoppjan | 433,705,171 | false | {"Kotlin": 29015, "Shell": 338} | fun main() {
/**
* Follows the navigation instructions as they are misunderstood
* @param input navigation instructions
* @return [Coordinates.result]
*/
fun part1(input: List<Instruction>) =
Coordinates()
.navigate(instructions = input)
.result
/**
... | 0 | Kotlin | 0 | 0 | 04f10e8add373884083af2a6de91e9776f9f17b8 | 2,474 | advent-of-code-2021 | Apache License 2.0 |
roboquant/src/main/kotlin/org/roboquant/strategies/Rating.kt | neurallayer | 406,929,056 | false | {"JavaScript": 3008153, "Kotlin": 1583428, "CSS": 1977} | /*
* Copyright 2020-2024 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 ag... | 8 | JavaScript | 38 | 286 | 0402d626324d159d2eab9e65977490b1444c5c32 | 3,386 | roboquant | Apache License 2.0 |
src/agents/MCTS/MCStatistics.kt | hopshackle | 225,904,074 | false | null | package agents.MCTS
import ggi.Action
import java.lang.AssertionError
data class MCTSParameters(
val C: Double = 1.0,
val selectionMethod: MCTSSelectionMethod = MCTSSelectionMethod.SIMPLE,
val maxPlayouts: Int = 100,
val timeLimit: Int = 1000,
val horizon: Int = 2000, // li... | 0 | Kotlin | 0 | 0 | e5992d6b535b3f4a6552bf6f2351865a33d56248 | 3,407 | SmarterSims | MIT License |
src/Day23.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | import kotlin.math.abs
const val ROUNDS_DAY_23 = 10
data class Elf(var pos: Point, var proposedPos: Point)
fun main() {
fun getElves(input: List<String>): List<Elf> {
val elves = mutableListOf<Elf>()
for (y in input.indices) {
for (x in input[y].indices) {
if (input[y]... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 6,856 | AoC2022 | Apache License 2.0 |
src/Day06.kt | burtz | 573,411,717 | false | {"Kotlin": 10999} | fun main() {
fun findMarker(inputString : String, numCheckChars : Int) : Int
{
for (i in 0..inputString.length-numCheckChars)
{
if(inputString.substring(i,i+numCheckChars).toSet().size > numCheckChars-1) return(i+numCheckChars)
}
return 1
}
fun part1(input: ... | 0 | Kotlin | 0 | 0 | daac7f91e1069d1490e905ffe7b7f11b5935af06 | 780 | adventOfCode2022 | Apache License 2.0 |
Kotlin/merge_sort_in_kotlin.kt | iam-abbas | 213,309,115 | false | null | fun merge(A: Array<Int>, p: Int, q: Int, r: Int) {
var left = A.copyOfRange(p, q + 1)
var right = A.copyOfRange(q + 1, r + 1)
var i = 0
var j = 0
for (k in p..r) {
if ((i <= left.size - 1) && ((j >= right.size) || (left[i] <= right[j]))) {
A[k] = left[i];
i++;
... | 0 | C++ | 383 | 215 | d04aa8fd9a1fa290266dde96afe9b90ee23c5a92 | 931 | cs-algorithms | MIT License |
src/main/kotlin/Day4.kt | vw-anton | 574,945,231 | false | {"Kotlin": 33295} | fun main() {
val input = readFile("input/4.txt")
.map { it.split(",").toPair() }
.map { it.first.toIntRange() to it.second.toIntRange() }
// In how many assignment pairs does one range fully contain the other?
val part1 = input
.count { pair ->
pair.first.fullyContains(p... | 0 | Kotlin | 0 | 0 | a823cb9e1677b6285bc47fcf44f523e1483a0143 | 1,032 | aoc2022 | The Unlicense |
Generics/Generic functions/src/Task.kt | pkleczek | 401,110,103 | false | null | fun <T, C : MutableCollection<T>> Iterable<T>.partitionTo(
first: C,
second: C,
predicate: (T) -> Boolean
): Pair<C, C> =
this.partition(predicate)
.let {
first.addAll(it.first)
second.addAll(it.second)
first to second
}
fun partitionWordsAndLines() {... | 0 | Kotlin | 0 | 0 | 48e2cc507dac1e7b4841a153f70d93033c959ccc | 783 | Kotlin_Koans | MIT License |
src/day01/Day01.kt | iliascholl | 572,982,464 | false | {"Kotlin": 8373} | package day01
import readInput
fun main() {
fun part1(input: List<String>) = input
.fold(mutableListOf(mutableListOf<String>())) { acc, value ->
if (value.isBlank()) acc.also { it.add(mutableListOf()) }
else acc.also { it.last().add(value) }
}.maxOf { it.sumOf(String::toInt... | 0 | Kotlin | 0 | 1 | 26db12ddf4731e4ee84f45e1dc4385707f9e1d05 | 909 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/g0501_0600/s0546_remove_boxes/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0501_0600.s0546_remove_boxes
// #Hard #Array #Dynamic_Programming #Memoization
// #2023_01_17_Time_283_ms_(100.00%)_Space_46.9_MB_(100.00%)
@Suppress("NAME_SHADOWING")
class Solution {
// dp for memoization
lateinit var dp: Array<Array<IntArray>>
fun removeBoxes(boxes: IntArray): Int {
va... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,952 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/divine/brothers/pizza/BruteForceApproach.kt | AarjavP | 450,892,849 | false | {"Kotlin": 28300} | package divine.brothers.pizza
import com.google.common.collect.Sets
import divine.brothers.takeUntilChanged
import java.util.*
class BruteForceApproach(input: Sequence<String>) : PizzaApproach(input) {
data class BruteForceSolution(
override val ingredients: BitSet,
val topCombinations: List<Comb... | 0 | Kotlin | 0 | 0 | 3aaaefc04d55b1e286dde0895fa32f9c34f5c945 | 1,241 | google-hash-code-2022 | MIT License |
src/Day08.kt | AlaricLightin | 572,897,551 | false | {"Kotlin": 87366} | fun main() {
fun part1(input: List<String>): Int {
val resultSet = mutableSetOf<Point>()
val rowCount = input.size
val columnCount = input[0].length
for (i in 1 .. rowCount - 2) {
checkLine(
input,
Point(i, 0),
{ point -> Po... | 0 | Kotlin | 0 | 0 | ee991f6932b038ce5e96739855df7807c6e06258 | 3,415 | AdventOfCode2022 | Apache License 2.0 |
src/aoc2021/Day01.kt | nguyen-anthony | 572,781,123 | false | null | package aoc2021
import utils.readInputAsList
fun main() {
fun convertToInt(stringList: List<String>) : List<Int> {
return stringList.map { it.toInt() }
}
fun part1(input: List<String>): Int {
return convertToInt(input).zipWithNext().count { (a, b) -> a < b }
}
fun part2(input: L... | 0 | Kotlin | 0 | 0 | 9336088f904e92d801d95abeb53396a2ff01166f | 782 | AOC-2022-Kotlin | Apache License 2.0 |
src/maia/ml/learner/standard/hoeffdingtree/util/ObservedClassDistribution.kt | waikato-maia | 387,326,961 | false | {"Kotlin": 74336} | package maia.ml.learner.standard.hoeffdingtree.util
import maia.util.asIterable
import maia.util.enumerate
import maia.util.filter
import maia.util.map
import maia.util.mapInPlaceIndexed
import maia.util.maxIndex
import maia.util.maxReducer
import maia.util.nonZeroCount
import kotlin.math.log2
/**
* The distribution... | 0 | Kotlin | 0 | 0 | 93650977e4bfce923ed444e8513a6cb7556cf9e9 | 2,941 | maia-standard-learners | Apache License 2.0 |
src/medium/_2AddTwoNumbers.kt | ilinqh | 390,190,883 | false | {"Kotlin": 382147, "Java": 32712} | package medium
import ListNode
class _2AddTwoNumbers {
class Solution {
fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode? {
var tempL1 = l1
var tempL2 = l2
val preHead = ListNode(-1)
var prev = preHead
var plusOne = false
va... | 0 | Kotlin | 0 | 0 | 8d2060888123915d2ef2ade293e5b12c66fb3a3f | 3,475 | AlgorithmsProject | Apache License 2.0 |
2020/Day11/src/main/kotlin/main.kt | airstandley | 225,475,112 | false | {"Python": 104962, "Kotlin": 59337} | import java.io.File
fun getInput(filename: String): List<String> {
return File(filename).readLines()
}
fun parseInput(input: List<String>): MutableList<MutableList<Char>> {
val parsed = mutableListOf<MutableList<Char>>()
for (line in input) {
val parsedRow = mutableListOf<Char>()
for (char... | 0 | Python | 0 | 0 | 86b7e289d67ba3ea31a78f4a4005253098f47254 | 4,698 | AdventofCode | MIT License |
30-days-leetcoding-challenge/April 12/src/Solution.kt | alexey-agafonov | 240,769,182 | false | null | import java.util.*
import kotlin.math.max
import kotlin.math.min
class Solution {
fun lastStoneWeight(stones: IntArray): Int {
var stones = stones.toMutableList()
while (stones.size > 1) {
stones.sort()
val y = stones[stones.lastIndex]
val x = stones[stones.las... | 0 | Kotlin | 0 | 0 | d43d9c911c6fd89343e392fd6f93b7e9d02a6c9e | 1,359 | leetcode | MIT License |
ceria/17/src/main/kotlin/Solution.kt | VisionistInc | 317,503,410 | false | null | import java.io.File
import java.io.Serializable
data class Quad<out X, out Y, out Z, out W>(
val first: X,
val second: Y,
val third: Z,
val fourth: W
) : Serializable {
override fun toString(): String = "($first, $second, $third, $fourth)"
fun <T> Quad<T, T, T, T>.toList(): Li... | 0 | Rust | 0 | 0 | 002734670384aa02ca122086035f45dfb2ea9949 | 7,068 | advent-of-code-2020 | MIT License |
src/org/hiatusuk/BabyNamesBoys.kt | poblish | 48,460,455 | false | null | package org.hiatusuk
fun main(args: Array<String>) {
val foreNames = arrayOf("Rohan","Nathaniel","Anthony","Chris","Jonathan","Lemur","Harry","Percy","Peregrine","James","Jamie","Sidney","Gabriel","Leyton","Curtley","Jarvis");
val middleNames = arrayOf("Rohan","Nathaniel","Tony","Chris","Jonathan","Lemur","Har... | 0 | Kotlin | 0 | 0 | 2935612dc0b5ed4f48a347506001b34313bd3bdd | 2,048 | BabyNamesKotlin | Apache License 2.0 |
src/main/kotlin/0004.kts | ktgw0316 | 373,665,309 | false | null | // http://odz.sakura.ne.jp/projecteuler/?Problem+4
// fun reverse(n: UInt): UInt {
// val list = mutableListOf<UInt>()
// var i = n
// while (i > 0U) {
// val j = i / 10U
// val rightmost = i - j * 10U
// list.add(rightmost)
// i = j
// }
//
// return list.reduce { a... | 0 | Kotlin | 0 | 0 | 1dc3b1bbb647a0541393eedf12be798e5b0ef84a | 795 | EulerKotlin | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day7.kt | guygy-cred | 571,652,830 | false | {"Kotlin": 17444} | package days
class Day7 : Day(7) {
override fun partOne(): Any {
returnDirectories()
return directories.filter { it.size <= 100000 }.sumOf { it.size }
}
override fun partTwo(): Any {
return directories.filter { it.size >= 30000000 - (70000000 - rootDirectory.size) }.minOf { it.size... | 0 | Kotlin | 0 | 0 | 338b33148bb625026e594ceeeeaa658a7921d9e3 | 1,993 | Advent-Of-Code-2022 | Creative Commons Zero v1.0 Universal |
app/src/main/java/com/mospolytech/mospolyhelper/domain/schedule/utils/ScheduleUtils.kt | tonykolomeytsev | 341,524,793 | true | {"Kotlin": 646693} | package com.mospolytech.mospolyhelper.domain.schedule.utils
import com.mospolytech.mospolyhelper.domain.schedule.model.Lesson
import com.mospolytech.mospolyhelper.domain.schedule.model.Schedule
import java.time.LocalDate
fun combine(schedule1: Schedule?, schedule2: Schedule?): Schedule? {
if (schedule1 == null) r... | 0 | null | 0 | 0 | 379c9bb22913da1854f536bf33e348a459db48b9 | 7,415 | mospolyhelper-android | MIT License |
code-sample-kotlin/algorithms/src/main/kotlin/com/codesample/leetcode/easy/9_palindromNumber.kt | aquatir | 76,377,920 | false | {"Java": 674809, "Python": 143889, "Kotlin": 112192, "Haskell": 57852, "Elixir": 33284, "TeX": 20611, "Scala": 17065, "Dockerfile": 6314, "HTML": 4714, "Shell": 387, "Batchfile": 316, "Erlang": 269, "CSS": 97} | package com.codesample.leetcode.easy
fun main() {
val s = Solution2()
println(s.isPalindromeNoConvertToString( -101)) // false
println(s.isPalindromeNoConvertToString(121)) // true
println(s.isPalindromeNoConvertToString(123)) // false
}
/** 9. Palindrome Number — https://leetcode.com/problems/p... | 1 | Java | 3 | 6 | eac3328ecd1c434b1e9aae2cdbec05a44fad4430 | 997 | code-samples | MIT License |
src/main/kotlin/com/staricka/adventofcode2022/Day23.kt | mathstar | 569,952,400 | false | {"Kotlin": 77567} | package com.staricka.adventofcode2022
import kotlin.math.max
import kotlin.math.min
class Day23 : Day {
override val id = 23
enum class Direction(private val vec: Pair<Int, Int>) {
N(Pair(-1,0)),
NE(Pair(-1,1)),
E(Pair(0,1)),
SE(Pair(1,1)),
S(Pair(1,0)),
SW(Pair(1,-1)),
W(Pair(0, -1))... | 0 | Kotlin | 0 | 0 | 2fd07f21348a708109d06ea97ae8104eb8ee6a02 | 3,882 | adventOfCode2022 | MIT License |
src/main/kotlin/dev/siller/aoc2022/Day06.kt | chearius | 575,352,798 | false | {"Kotlin": 41999} | package dev.siller.aoc2022
private val examples = listOf(
"mjqjpqmgbljsphdztnvjfqwrcgsmlb",
"bvwbjplbgvbhsrlpgdmjqwftvncz",
"nppdvjthqldpwncqszvftbrmjlhg",
"nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg",
"zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"
)
private fun part1(input: List<String>): Int = getStartOfMessagePosit... | 0 | Kotlin | 0 | 0 | e070c0254a658e36566cc9389831b60d9e811cc5 | 1,110 | advent-of-code-2022 | MIT License |
aoc-2017/src/main/kotlin/nl/jstege/adventofcode/aoc2017/days/Day03.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2017.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.Point
import nl.jstege.adventofcode.aoccommon.utils.extensions.head
import nl.jstege.adventofcode.aoccommon.utils.extensions.pow
import nl.jstege.adventofcode.aoccommon.utils.exten... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 1,621 | AdventOfCode | MIT License |
src/Day08.kt | lmoustak | 573,003,221 | false | {"Kotlin": 25890} | import kotlin.math.max
fun main() {
fun makeGrid(area: List<String>): Array<IntArray> {
val grid = Array(area[0].length) { IntArray(area.size) }
for (row in area.indices) {
for (column in area[row].indices) {
grid[row][column] = area[row][column].digitToInt()
... | 0 | Kotlin | 0 | 0 | bd259af405b557ab7e6c27e55d3c419c54d9d867 | 3,374 | aoc-2022-kotlin | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.