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/com/ncorti/aoc2023/Day14.kt | cortinico | 723,409,155 | false | {"Kotlin": 76642} | package com.ncorti.aoc2023
fun main() {
fun parseInput() = getInputAsText("14") {
split("\n").filter(String::isNotBlank).map {
it.toCharArray()
}.toTypedArray()
}
fun computeWeight(input: Array<CharArray>): Long {
var total = 0L
for (i in input.indices) {
... | 1 | Kotlin | 0 | 1 | 84e06f0cb0350a1eed17317a762359e9c9543ae5 | 3,832 | adventofcode-2023 | MIT License |
versions/Kotlin/src/simulator/SimulatorBase.kt | qiskit-community | 198,048,454 | false | null | package simulator
import model.ComplexNumber
import model.QuantumCircuit
import util.MathConstants
import kotlin.math.pow
abstract class SimulatorBase {
open fun simulate(circuit: QuantumCircuit): List<ComplexNumber> {
val sum = circuit.probabilitySum()
return if (sum > MathConstants.Eps) {
... | 8 | Jupyter Notebook | 23 | 42 | 4e5d67708f248c0c4be949ce27ea8d449b07d216 | 2,318 | MicroQiskit | Apache License 2.0 |
src/chapter4/section1/ex24.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter4.section1
import edu.princeton.cs.algs4.Queue
import edu.princeton.cs.algs4.Stack
import edu.princeton.cs.algs4.StdIn
import extensions.inputPrompt
import extensions.readLine
import java.util.*
import java.util.regex.Pattern
/**
* 修改DegreesOfSeparation,从命令行接受一个整型参数y,忽略上映年数超过y的电影
*
* 解:重写[DegreesOfS... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 3,341 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/main/kotlin/days/Day7.kt | andilau | 429,557,457 | false | {"Kotlin": 103829} | package days
import days.Day7.Instruction.*
@AdventOfCodePuzzle(
name = "Some Assembly Required",
url = "https://adventofcode.com/2015/day/7",
date = Date(day = 7, year = 2015)
)
class Day7(instructions: List<String>) : Puzzle {
private val wires: Map<String, Instruction> = instructions.parseInstructi... | 0 | Kotlin | 0 | 0 | 55932fb63d6a13a1aa8c8df127593d38b760a34c | 3,376 | advent-of-code-2015 | Creative Commons Zero v1.0 Universal |
src/day08/Day08.kt | apeinte | 574,487,528 | false | {"Kotlin": 47438} | package day08
import readDayInput
//Don't forget to fill this constant.
const val RESULT_EXAMPLE_PART_ONE = 21
const val RESULT_EXAMPLE_PART_TWO = 8
const val VALUE_OF_THE_DAY = 8
fun main() {
fun getNumberOfTreeVisibleLeftOrRight(
treesOnTheDirection: List<Char>,
treeHeight: Int,
includ... | 0 | Kotlin | 0 | 0 | 4bb3df5eb017eda769b29c03c6f090ca5cdef5bb | 8,422 | my-advent-of-code | Apache License 2.0 |
src/main/java/sortingalgorithms/mergesort/kotlin/MergeSort.kt | ucdevinda123 | 267,009,882 | false | {"Java": 44875, "Kotlin": 10712, "Python": 796} | package sortingalgorithms.mergesort.kotlin
import sortingalgorithms.SortingAlgorithm
class MergeSort : SortingAlgorithm() {
override fun sort(input: IntArray) {
val length = input.size
if (length < 2) return //Base condition
//1.Find the middle and divide the array O(log)
var middl... | 0 | Java | 0 | 1 | c082b07bd687a3cf937b64db3100fb19ccb15340 | 1,567 | data-structures-and-algorithms | MIT License |
localization/src/main/java/com/technokratos/compose/localization/plurals.kt | TechnokratosDev | 312,540,588 | false | null | package com.technokratos.compose.localization
import java.util.Locale
import kotlin.math.absoluteValue
import android.util.Log
class PluralRule(
val zero: (Double, Long, Long, Int, Int) -> Boolean = { _, _, _, _, _ -> false },
val one: (Double, Long, Long, Int, Int) -> Boolean = { _, _, _, _, _ -> false },
... | 9 | Kotlin | 5 | 18 | 6f8e8a2abe8caa9a4a6770d2afa31898413baf9d | 3,403 | jetpack-compose-localization | MIT License |
src/Day06.kt | KarinaCher | 572,657,240 | false | {"Kotlin": 21749} | fun main() {
fun findMarker(windowSize: Int, input: List<String>): Int {
var index = windowSize
for (line in input) {
val windowed = line.toCharArray().toList().windowed(windowSize)
for (window in windowed) {
if (window.toSet().size == windowSize) {
... | 0 | Kotlin | 0 | 0 | 17d5fc87e1bcb2a65764067610778141110284b6 | 879 | KotlinAdvent | Apache License 2.0 |
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/LowestCommonAncestor.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.algorithms.graph
class LowestCommonAncestor {
class AncestralTree(name: Char) {
val name = name
var ancestor: AncestralTree? = null
}
fun getYoungestCommonAncestor(
topAncestor: AncestralTree,
descendantOne: AncestralTree,
descendantT... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 1,567 | DS_Algo_Kotlin | MIT License |
app/src/main/java/com/themobilecoder/adventofcode/day2/DayTwo.kt | themobilecoder | 726,690,255 | false | {"Kotlin": 323477} | package com.themobilecoder.adventofcode.day2
import com.themobilecoder.adventofcode.splitByNewLine
class DayTwo {
fun solveDayTwoPartOne(input: String): Int {
val lines = input.splitByNewLine()
var sum = 0
lines.forEach { line ->
val score = line.getGameIdAsScore()
... | 0 | Kotlin | 0 | 0 | b7770e1f912f52d7a6b0d13871f934096cf8e1aa | 2,093 | Advent-of-Code-2023 | MIT License |
src/Day05.kt | coolcut69 | 572,865,721 | false | {"Kotlin": 36853} | fun main() {
fun parseAction(actionString: String): Action {
val fromPosition = actionString.indexOf("from")
val movePosition = actionString.indexOf("move")
val toPosition = actionString.indexOf("to")
val numberOfCrates = actionString.substring(movePosition + 5, fromPosition - 1).t... | 0 | Kotlin | 0 | 0 | 031301607c2e1c21a6d4658b1e96685c4135fd44 | 3,757 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/manalili/advent/Day05.kt | maines-pet | 162,116,190 | false | null | package com.manalili.advent
class Day05(val input: String) {
fun react(polymerInput: String = input): Int {
var polymer = polymerInput
var index = 0
while (true) {
if (index >= polymer.length - 1) break
if (polymer[index] same polymer[index + 1]) {
p... | 0 | Kotlin | 0 | 0 | 25a01e13b0e3374c4abb6d00cd9b8d7873ea6c25 | 1,046 | adventOfCode2018 | MIT License |
kork-plugins/src/main/kotlin/com/netflix/spinnaker/kork/plugins/VersionRequirementsParser.kt | spinnaker | 19,836,152 | false | {"Java": 1483624, "Kotlin": 592931, "Groovy": 116064, "Shell": 969, "JavaScript": 595, "HTML": 394} | /*
* Copyright 2020 Netflix, Inc.
*
* 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 ... | 18 | Java | 172 | 38 | a24bcbe15b13213e42a293658fce2cb5b1949835 | 3,271 | kork | Apache License 2.0 |
src/main/kotlin/io/github/pshegger/aoc/y2015/Y2015D10.kt | PsHegger | 325,498,299 | false | null | package io.github.pshegger.aoc.y2015
import io.github.pshegger.aoc.common.BaseSolver
class Y2015D10 : BaseSolver() {
override val year = 2015
override val day = 10
override fun part1(): Int = solve(ITERATION_COUNT1)
override fun part2(): Int = solve(ITERATION_COUNT2)
private fun solve(iterationC... | 0 | Kotlin | 0 | 0 | 346a8994246775023686c10f3bde90642d681474 | 2,011 | advent-of-code | MIT License |
src/main/kotlin/days/Solution06.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.sqrt
object Solution06 : Solution<PairOf<List<String>>>(AOC_YEAR, 6) {
override fun getInput(handler: InputHandler) = handler.getInput("\n"... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 1,170 | Advent-of-Code-2023 | MIT License |
y2017/src/main/kotlin/adventofcode/y2017/Day23.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2017
import adventofcode.io.AdventSolution
object Day23 : AdventSolution(2017, 23, "Coprocessor Conflagration") {
override fun solvePartOne(input: String): String {
val instructions = parseInstructions(input)
val context = ExecutionContext()
var ip = 0
var mulCount = 0
while (ip in ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 958 | advent-of-code | MIT License |
src/Day06.kt | emersonf | 572,870,317 | false | {"Kotlin": 17689} | fun main() {
fun findMarkers(input: List<String>, windowSize: Int): List<Int> =
input.map { line ->
var windows = 0
line.windowedSequence(windowSize) { window ->
windows++
window.toSet().size
}
.first { uniqueSize -> uniqueS... | 0 | Kotlin | 0 | 0 | 0e97351ec1954364648ec74c557e18ccce058ae6 | 842 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/nl/meine/aoc/_2023/Day1.kt | mtoonen | 158,697,380 | false | {"Kotlin": 201978, "Java": 138385} | package nl.meine.aoc._2023
class Day1 {
fun one(input: String):Int{
val lines=input.split("\n")
var counter=0
for (line in lines){
val first = line;
var result = line.filter { it.isDigit() }
val num = ""+result.first()+ result.last()
counte... | 0 | Kotlin | 0 | 0 | a36addef07f61072cbf4c7c71adf2236a53959a5 | 23,764 | advent-code | MIT License |
src/main/kotlin/days/Day9.kt | hughjdavey | 572,954,098 | false | {"Kotlin": 61752} | package days
import days.Day9.Direction.DOWN
import days.Day9.Direction.LEFT
import days.Day9.Direction.RIGHT
import days.Day9.Direction.UP
import days.Day9.LongRope.Companion.INITIAL_COORDS
import xyz.hughjd.aocutils.Coords.Coord
class Day9 : Day(9) {
private val motions = inputList.map { it.split(" ") }
... | 0 | Kotlin | 0 | 2 | 65014f2872e5eb84a15df8e80284e43795e4c700 | 5,830 | aoc-2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/abc/198-d.kt | kirimin | 197,707,422 | false | null | package abc
fun main(args: Array<String>) {
val s1 = readLine()!!
val s2 = readLine()!!
val s3 = readLine()!!
println(problem198d(s1, s2, s3))
}
fun problem198d(s1: String, s2: String, s3: String): String {
/**
* 辞書順で順列の次の組み合わせにarrayを書き換える
*/
fun nextPermutation(array: IntArray): Boo... | 0 | Kotlin | 1 | 5 | 23c9b35da486d98ab80cc56fad9adf609c41a446 | 1,900 | AtCoderLog | The Unlicense |
src/main/kotlin/com/hj/leetcode/kotlin/problem1572/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1572
/**
* LeetCode page: [1572. Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(1) where N is the number of rows(columns) of mat;
*/
fun diagonalSum(mat: Array<IntArray>): Int... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,111 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/com/github/mmauro94/media_merger/util/DurationUtils.kt | MMauro94 | 177,452,540 | false | {"Kotlin": 218767, "Dockerfile": 357} | package com.github.mmauro94.media_merger.util
import java.math.BigDecimal
import java.time.Duration
import java.util.concurrent.TimeUnit
fun Duration.toTimeString(): String {
val abs = abs()
val firstPart = (if (isNegative) "-" else "") + mutableListOf<String>().apply {
fun add(v: Int) {
... | 0 | Kotlin | 0 | 0 | 40a1d363e2260a41bfb6cb77e4c07f49b8cccc89 | 2,573 | media-merger | MIT License |
Phone Book (Kotlin)/Phone Book (Kotlin)/task/src/phonebook/Main.kt | Undiy | 617,323,453 | false | null | package phonebook
import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.lang.Integer.min
import java.util.*
import kotlin.math.sqrt
import kotlin.streams.asSequence
const val FIND_FILENAME = "find.txt"
const val DIRECTORY_FILENAME = "directory.txt"
fun getRecordName(record: String) ... | 0 | Kotlin | 0 | 0 | 70695fbaa9b5909be4740c57a49a955855dfd738 | 5,193 | hyperskill-kotlin-core | MIT License |
src/main/kotlin/g0201_0300/s0208_implement_trie_prefix_tree/Trie.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0201_0300.s0208_implement_trie_prefix_tree
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Design #Trie
// #Level_2_Day_16_Design #Udemy_Trie_and_Heap
// #Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N)
// #2022_09_10_Time_689_ms_(61.00%)_Space_87.9_MB_(36.00%)
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,770 | LeetCode-in-Kotlin | MIT License |
kotlin/673.Number of Longest Increasing Subsequence(最长递增子序列的个数).kt | learningtheory | 141,790,045 | false | {"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944} | /**
<p>
Given an unsorted array of integers, find the number of longest increasing subsequence.
</p>
<p><b>Example 1:</b><br />
<pre>
<b>Input:</b> [1,3,5,4,7]
<b>Output:</b> 2
<b>Explanation:</b> The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].
</pre>
</p>
<p><b>Example 2:</b><br />
<pre>
<b... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 2,031 | leetcode | MIT License |
Peaceful_chess_queen_armies/Kotlin/src/Peaceful.kt | ncoe | 108,064,933 | false | {"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409} | import kotlin.math.abs
enum class Piece {
Empty,
Black,
White,
}
typealias Position = Pair<Int, Int>
fun place(m: Int, n: Int, pBlackQueens: MutableList<Position>, pWhiteQueens: MutableList<Position>): Boolean {
if (m == 0) {
return true
}
var placingBlack = true
for (i in 0 until... | 0 | D | 0 | 4 | c2a9f154a5ae77eea2b34bbe5e0cc2248333e421 | 3,109 | rosetta | MIT License |
src/Day09.kt | ka1eka | 574,248,838 | false | {"Kotlin": 36739} | import kotlin.math.abs
fun main() {
fun Pair<Int, Int>.isTouching(other: Pair<Int, Int>): Boolean =
this == other || abs(first - other.first) <= 1 && abs(second - other.second) <= 1
fun Pair<Int, Int>.moveUp(): Pair<Int, Int> = Pair(first, second - 1)
fun Pair<Int, Int>.moveDown(): Pair<Int, Int>... | 0 | Kotlin | 0 | 0 | 4f7893448db92a313c48693b64b3b2998c744f3b | 4,103 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/kr/co/programmers/P49191.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/532
class P49191 {
fun solution(n: Int, results: Array<IntArray>): Int {
// 승/패로 초기화
val graph = Array(n) { IntArray(n) }
for ((win, lose) in results) {
graph[win - 1][lose - 1] = 1
graph[lose... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 887 | algorithm | MIT License |
src/main/kotlin/com/leetcode/monthly_challenges/2021/april/phone_number_to_words/Main.kt | frikit | 254,842,734 | false | null | package com.leetcode.monthly_challenges.`2021`.april.phone_number_to_words
fun main() {
println("Test case 1:")
println(Solution().letterCombinations("23"))//["ad","ae","af","bd","be","bf","cd","ce","cf"]
println()
println("Test case 2:")
println(Solution().letterCombinations(""))//[]
println(... | 0 | Kotlin | 0 | 0 | dda68313ba468163386239ab07f4d993f80783c7 | 1,543 | leet-code-problems | Apache License 2.0 |
src/day8/TreeGrid.kt | g0dzill3r | 576,012,003 | false | {"Kotlin": 172121} | package day8
/**
*
*/
data class TreeGrid (val data: List<List<Int>>) {
init {
data.forEach {
assert (it.size == data.size)
}
}
val cols: Int = data[0].size
val rows: Int = data.size
fun height (x: Int, y: Int): Int = data[y][x]
fun row (y: Int): List<Int> = dat... | 0 | Kotlin | 0 | 0 | 6ec11a5120e4eb180ab6aff3463a2563400cc0c3 | 3,688 | advent_of_code_2022 | Apache License 2.0 |
src/main/java/challenges/educative_grokking_coding_interview/fast_slow_pointers/_5/FindDuplicate.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.fast_slow_pointers._5
import challenges.util.PrintHyphens
import java.util.*
/**
Given an array of integers, nums, find a duplicate number such that the array contains n+1
elements, and each integer is in the range [1,n] inclusive.
There is only one repeated num... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,606 | CodingChallenges | Apache License 2.0 |
src/Day20.kt | felldo | 572,233,925 | false | {"Kotlin": 76496} | import java.lang.Exception
data class WorkingNumber(val original: Int, val number: Long)
fun main() {
fun moveItem(coords: MutableList<WorkingNumber>, index: Int) {
val item = coords.find { it.original == index } ?: throw Exception()
val oldIndex = coords.indexOf(item)
var newIndex = (oldI... | 0 | Kotlin | 0 | 0 | 0ef7ac4f160f484106b19632cd87ee7594cf3d38 | 1,684 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/top/solver/State.kt | kaarthiksundar | 366,758,030 | false | null | package top.solver
import top.data.Parameters
import top.main.TOPException
/**
* Class representing a partial path used in solving the elementary shortest path problem with
* resource constraints in the pricing problem.
*
* @param vertex Current vertex
* @param cost Accumulated reduced cost
* @param score Accum... | 1 | Kotlin | 1 | 0 | 13d8af37d35fff8251d89db2cb95b5c10d31a5a0 | 6,132 | top-sensitivity | MIT License |
src/main/kotlin/days/Day14.kt | vovarova | 572,952,098 | false | {"Kotlin": 103799} | package days
import util.Cell
import util.range
class Day14 : Day(14) {
class CaveMap(input: List<String>) {
val rock: Set<Cell>
var maxRow: Int
val sand: MutableSet<Cell> = mutableSetOf()
init {
rock = createRockIndex(input)
maxRow = rock.map { it.row }.... | 0 | Kotlin | 0 | 0 | e34e353c7733549146653341e4b1a5e9195fece6 | 2,709 | adventofcode_2022 | Creative Commons Zero v1.0 Universal |
src/graphs/weighted/UndirectedWeightedGraph.kt | ArtemBotnev | 136,745,749 | false | {"Kotlin": 79256, "Shell": 292} | package graphs.weighted
import java.util.*
import kotlin.collections.HashMap
/**
* Model of undirected weighted graph
*/
class UndirectedWeightedGraph<T>(maxVertexCount: Int, infinity: Long)
: WeightedGraph<T>(maxVertexCount, infinity) {
override fun addEdge(first: T, second: T, weight: Long): Boolean {
... | 0 | Kotlin | 0 | 0 | 530c02e5d769ab0a49e7c3a66647dd286e18eb9d | 3,150 | Algorithms-and-Data-Structures | MIT License |
src/2023/Day18.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2023`
import common.Linearizer
import java.io.File
import java.lang.RuntimeException
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
Day18().solve()
}
class Day18 {
val input1 = """
R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 9,990 | advent-of-code | Apache License 2.0 |
src/utils/SolutionUtils.kt | Arch-vile | 162,448,942 | false | null | package utils
import model.Location
import model.Route
import shortestPath
/**
* Shortest route from Korvatunturi visiting all locations. Route will start and end to Korvatunturi.
* Given locations must not include Korvatunturi.
*/
fun shortestRouteFromKorvatunturi(locations: List<Location>): Route {
val stop... | 0 | Kotlin | 0 | 0 | 03160a5ea318082a0995b08ba1f70b8101215ed7 | 1,521 | santasLittleHelper | Apache License 2.0 |
CF_892_2_B/CF_892_2_B.kt | AZenhom | 680,515,632 | false | null | package com.ahmedzenhom.problem_solving.cf_892_2_b
var input =
mutableListOf<String>( // Not to be included in your submitting
"3",
"2",
"2",
"1 2",
"2",
"4 3",
"1",
"3",
... | 0 | Kotlin | 0 | 0 | a2ea0ddda92216103ad1b06a61abedb4298d1562 | 1,641 | Problem-Solving | Apache License 2.0 |
src/games/simplegridgame/fdc/FitnessDistanceCorrelation.kt | GAIGResearch | 186,301,600 | false | null | package games.simplegridgame.fdc
import agents.DoNothingAgent
import games.gridgame.UpdateRule
import games.simplegridgame.*
import utilities.ElapsedTimer
import utilities.StatSummary
import java.util.*
import kotlin.random.Random
val predictionSteps = 5
// set this true to force a random rule
val forceRandom = true... | 0 | Kotlin | 0 | 1 | 247583c5286c45893e8377fe357a56903859f800 | 6,216 | LearningFM | MIT License |
src/advent/of/code/NinethPuzzle.kt | 1nco | 725,911,911 | false | {"Kotlin": 112713, "Shell": 103} | package advent.of.code
import utils.Util
import java.util.*
class NinethPuzzle {
companion object {
private val day = "9";
private var input: MutableList<String> = arrayListOf();
private var result = 0L;
private var resultSecond = 0L;
private var histories = arrayListO... | 0 | Kotlin | 0 | 0 | 0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3 | 3,604 | advent-of-code | Apache License 2.0 |
2021/kotlin-lang/src/main/kotlin/mmxxi/days/DayOne.kt | Delni | 317,500,911 | false | {"Kotlin": 66017, "Dart": 53066, "Go": 28200, "TypeScript": 7238, "Rust": 7104, "JavaScript": 2873} | package mmxxi.days
/**
* --- Day 1: Sonar Sweep ---
*/
class DayOne: Abstract2021("01", "Sonar Sweep", 7, 5) {
override fun part1(input: List<String>): Int {
return input
.map(Integer::parseInt)
.foldIndexed(0) { index, accumulator, element ->
val previous = index.... | 0 | Kotlin | 0 | 1 | d8cce76d15117777740c839d2ac2e74a38b0cb58 | 1,319 | advent-of-code | MIT License |
day10/src/Day10.kt | simonrules | 491,302,880 | false | {"Kotlin": 68645} | import java.io.File
class Day10(private val path: String) {
private val lines = mutableListOf<String>()
init {
File(path).forEachLine { line ->
lines.add(line)
}
}
private fun match(a: Char, b: Char): Boolean {
if (a == '(' && b == ')') {
return true
... | 0 | Kotlin | 0 | 0 | d9e4ae66e546f174bcf66b8bf3e7145bfab2f498 | 2,853 | aoc2021 | Apache License 2.0 |
scripts/Day9.kts | matthewm101 | 573,325,687 | false | {"Kotlin": 63435} | import java.io.File
import kotlin.math.abs
import kotlin.math.sign
val program = File("../inputs/9.txt").readLines().map {
val splits = it.split(" ")
Pair(splits[0][0], splits[1].toInt())
}
val visited: MutableSet<Pair<Int,Int>> = mutableSetOf(Pair(0,0))
var xh = 0
var yh = 0
var xt = 0
var yt = 0
program.fo... | 0 | Kotlin | 0 | 0 | bbd3cf6868936a9ee03c6783d8b2d02a08fbce85 | 1,987 | adventofcode2022 | MIT License |
year2018/src/main/kotlin/net/olegg/aoc/year2018/day8/Day8.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2018.day8
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.parseInts
import net.olegg.aoc.year2018.DayOf2018
/**
* See [Year 2018, Day 8](https://adventofcode.com/2018/day/8)
*/
object Day8 : DayOf2018(8) {
override fun first(): Any? {
val numbers = data.parseInts()
... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,116 | adventofcode | MIT License |
src/main/kotlin/dev/claudio/adventofcode2021/Day5Part2.kt | ClaudioConsolmagno | 434,559,159 | false | {"Kotlin": 78336} | package dev.claudio.adventofcode2021
import kotlin.math.abs
import kotlin.math.sign
fun main() {
Day5Part2().main()
}
private class Day5Part2 {
fun main() {
val inputList: List<String> = Support.readFileAsListString("day5-input.txt")
val lines = inputList
.map {
va... | 0 | Kotlin | 0 | 0 | 5f1aff1887ad0a7e5a3af9aca7793f1c719e7f1c | 2,362 | adventofcode-2021 | Apache License 2.0 |
src/main/kotlin/com/sk/set1/127. Word Ladder.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set1
class Solution127 {
fun ladderLength(beginWord: String, endWord: String, wordList: List<String>): Int {
val seen = mutableSetOf<String>()
val q = ArrayDeque<String>()
q.add(beginWord)
var ladder = 1
while (q.isNotEmpty()) {
var size = q.size
... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,223 | leetcode-kotlin | Apache License 2.0 |
Retos/Reto #7 - EL SOMBRERO SELECCIONADOR [Media]/kotlin/Mariopolonia0.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 EjercicioKotlin.Mouredev
/*
* Crea un programa que simule el comportamiento del sombrero selccionador del
* universo mágico de <NAME>.
* - De ser posible realizará 5 preguntas (como mínimo) a través de la terminal.
* - Cada pregunta tendrá 4 respuestas posibles (también a selecciona una a través de termina... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 3,769 | retos-programacion-2023 | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/AddTwoNumbers.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
import com.daily.algothrim.linked.LinkedNode
/**
* 两数相加(leetcode 2)
*
* 给出两个非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。
*
* 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。
*
* 您可以假设除了数字 0 之外,这两个数都不会以 0开头。
*
* 示例:
*
* 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)
* 输出:7 -> 0 -> 8
... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,506 | daily_algorithm | Apache License 2.0 |
src/Day06.kt | devheitt | 573,207,407 | false | {"Kotlin": 11944} | import java.lang.RuntimeException
fun main() {
// first approach
fun part1(input: List<String>): Int {
val data = input[0]
var i = 3
while (i < data.length) {
val first = data[i - 3]
val second = data[i - 2]
val third = data[i - 1]
val for... | 0 | Kotlin | 0 | 0 | a9026a0253716d36294709a547eaddffc6387261 | 999 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/tr/emreone/adventofcode/days/Day15.kt | EmRe-One | 568,569,073 | false | {"Kotlin": 166986} | package tr.emreone.adventofcode.days
import kotlinx.coroutines.*
import tr.emreone.adventofcode.manhattanDistanceTo
import tr.emreone.kotlin_utils.Logger.logger
import tr.emreone.kotlin_utils.math.Point2D
import kotlin.math.abs
object Day15 {
private val REPORT_PATTERN =
"""Sensor at x=(-?\d+), y=(-?\d+)... | 0 | Kotlin | 0 | 0 | a951d2660145d3bf52db5cd6d6a07998dbfcb316 | 5,865 | advent-of-code-2022 | Apache License 2.0 |
egklib/src/commonTest/kotlin/electionguard/tally/LagrangeCoefficientsTest.kt | votingworks | 425,905,229 | false | {"Kotlin": 1268236} | package electionguard.tally
import electionguard.core.productionGroup
import electionguard.decrypt.computeLagrangeCoefficient
import kotlin.test.Test
import kotlin.test.assertEquals
private val group = productionGroup()
class LagrangeCoefficientsTest {
@Test
fun testLagrangeCoefficientAreIntegral() {
... | 32 | Kotlin | 3 | 8 | 4e759afe9d57fa8f8beea82c3b78b920351023d8 | 2,584 | electionguard-kotlin-multiplatform | MIT License |
src/main/kotlin/algorithms/OverlapGraphsOofN.kt | jimandreas | 377,843,697 | false | null | @file:Suppress("unused")
package algorithms
/**
* See also:
* http://rosalind.info/problems/grph/
* Overlap Graphs
*
* Problem
A graph whose nodes have all been labeled can be represented by an
adjacency list, in which each row of the list contains the two node
labels corresponding to a unique edge.
A directed... | 0 | Kotlin | 0 | 0 | fa92b10ceca125dbe47e8961fa50242d33b2bb34 | 2,585 | stepikBioinformaticsCourse | Apache License 2.0 |
kotlin/07.kt | NeonMika | 433,743,141 | false | {"Kotlin": 68645} | import kotlin.math.absoluteValue
class Day7 : Day<List<Int>>("07") {
override fun dataStar1(lines: List<String>): List<Int> = lines[0].split(",").map(String::toInt)
override fun dataStar2(lines: List<String>): List<Int> = dataStar1(lines)
override fun star1(data: List<Int>): Number = data.minOf { it }.ra... | 0 | Kotlin | 0 | 0 | c625d684147395fc2b347f5bc82476668da98b31 | 984 | advent-of-code-2021 | MIT License |
src/arrays/Experiment.kt | agapeteo | 157,038,583 | false | null | package arrays
import java.io.File
import java.util.*
fun main() {
printDirContent(File("/Users/emix/go/src/practicalalgo"))
}
fun printDirContent(dir: File, tabsCount: Int = 0, ignoreHidden: Boolean = true) {
require(dir.exists()) { "$dir must exist" }
require(dir.isDirectory) { "$dir must be directo... | 0 | Kotlin | 0 | 1 | b5662c8fe416e277c593931caa1b29b7f017ef60 | 2,820 | kotlin-data-algo | MIT License |
Java_part/AssignmentC/src/Q2.kt | enihsyou | 58,862,788 | false | {"Java": 77446, "Python": 65409, "Kotlin": 35032, "C++": 6214, "C": 3796, "CMake": 818} | import kotlin.math.max
import kotlin.text.Typography.times
/*
某一印刷厂有6项加工任务,对印刷车间和装订车间所需时间如表所示。完成每项任务都要先去印刷车间印刷,
再去装订车间装订。问怎样安排这6项加工任务的加工工序,使得加工总工时最少。
任务 J1 J2 J3 J4 J5 J6
印刷车间 3 12 5 2 9 11
装订车间 8 10 9 6 3 1
*/
fun main(args: Array<String>) {
v... | 0 | Java | 0 | 0 | 09a109bb26e0d8d165a4d1bbe18ec7b4e538b364 | 1,306 | Sorting-algorithm | MIT License |
src/day23/Code.kt | fcolasuonno | 221,697,249 | false | null | package day23
import java.io.File
fun main() {
val name = if (false) "test.txt" else "input.txt"
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part 1 = ${part1(parsed.toMutableList())}")
println("Part 2 = ${part2(p... | 0 | Kotlin | 0 | 0 | 73110eb4b40f474e91e53a1569b9a24455984900 | 4,338 | AOC2016 | MIT License |
src/main/kotlin/com/hopkins/aoc/day17/main.kt | edenrox | 726,934,488 | false | {"Kotlin": 88215} | package com.hopkins.aoc.day17
import java.io.File
import kotlin.math.abs
const val debug = true
const val part = 1
lateinit var mapSize: Point
lateinit var map: Map<Point, Int>
lateinit var endPoint: Point
val minDistanceLookup = mutableMapOf<PathKey, Int>()
/** Advent of Code 2023: Day 17 */
fun main() {
// St... | 0 | Kotlin | 0 | 0 | 45dce3d76bf3bf140d7336c4767e74971e827c35 | 11,834 | aoc2023 | MIT License |
archive/720/solve.kt | daniellionel01 | 435,306,139 | false | null | /*
=== #720 Unpredictable Permutations - Project Euler ===
Consider all permutations of $\{1, 2, \ldots N\}$, listed in lexicographic order.For example, for $N=4$, the list starts as follows:
$$\displaylines{
(1, 2, 3, 4) \\
(1, 2, 4, 3) \\
(1, 3, 2, 4) \\
(1, 3, 4, 2) \\
(1, 4, 2, 3) \\
(1, 4, 3, 2) \\
(2, 1, 3, 4) ... | 0 | Kotlin | 0 | 1 | 1ad6a549a0a420ac04906cfa86d99d8c612056f6 | 1,089 | euler | MIT License |
aoc_2023/src/main/kotlin/problems/day24/Hailstone.kt | Cavitedev | 725,682,393 | false | {"Kotlin": 228779} | package problems.day24
class Hailstone(val pos: HailCoordinate, val vel: HailCoordinate) {
override fun toString(): String {
return "$pos @ $vel"
}
fun intersectionXY(other: Hailstone): HailCoordinate? {
if (other.vel.x.toDouble() == 0.0 || other.vel.y.toDouble() == 0.0 || (this.vel.x / o... | 0 | Kotlin | 0 | 1 | aa7af2d5aa0eb30df4563c513956ed41f18791d5 | 4,119 | advent-of-code-2023 | MIT License |
src/main/kotlin/net/navatwo/adventofcode2023/day3/Day3Solution.kt | Nava2 | 726,034,626 | false | {"Kotlin": 100705, "Python": 2640, "Shell": 28} | package net.navatwo.adventofcode2023.day3
import net.navatwo.adventofcode2023.Coord
import net.navatwo.adventofcode2023.Grid
import net.navatwo.adventofcode2023.forEachCoord
import net.navatwo.adventofcode2023.framework.ComputedResult
import net.navatwo.adventofcode2023.framework.Solution
sealed class Day3Solution : ... | 0 | Kotlin | 0 | 0 | 4b45e663120ad7beabdd1a0f304023cc0b236255 | 8,870 | advent-of-code-2023 | MIT License |
src/main/kotlin/com/polydus/aoc18/Day8.kt | Polydus | 160,193,832 | false | null | package com.polydus.aoc18
class Day8: Day(8){
//https://adventofcode.com/2018/day/8
init {
//partOne()
partTwo()
}
fun partOne(){
val list = ArrayList<Int>()
input.forEach {
println()
val chars = it.toCharArray()
var i = 0
... | 0 | Kotlin | 0 | 0 | e510e4a9801c228057cb107e3e7463d4a946bdae | 4,705 | advent-of-code-2018 | MIT License |
src/main/kotlin/model/method/SecantMethod.kt | Roggired | 348,065,860 | false | null | package model.method
import model.equation.Equation
import kotlin.math.abs
import kotlin.math.sign
class SecantMethod(
equation: Equation,
private val secondDerivativeInLeftBound: Double,
private val secondDerivativeInRightBound: Double,
leftBound: Double,
rightBound: Double,
accuracy: Double
... | 0 | Kotlin | 0 | 2 | 983935fc1ca2a6da564ff8300c2a53cc85dd8701 | 2,598 | maths_lab2 | MIT License |
test/src/me/anno/tests/maths/ContinuousMedian.kt | AntonioNoack | 456,513,348 | false | {"Kotlin": 9845766, "C": 236481, "GLSL": 9454, "Java": 6754, "Lua": 4404} | package me.anno.tests.maths
import me.anno.maths.ContinuousMedian
import me.anno.maths.Maths
import me.anno.utils.types.Floats.f6
import me.anno.utils.types.Floats.f6s
import me.anno.utils.types.Strings.withLength
import kotlin.math.sqrt
fun main() {
testDirect()
testDiscrete()
testContinuous()
}
fun tes... | 0 | Kotlin | 3 | 17 | 3d0d08566309a84e1e68585593b76844633132c4 | 2,745 | RemsEngine | Apache License 2.0 |
src/main/kotlin/days/Day5.kt | felix-ebert | 433,847,657 | false | {"Kotlin": 12718} | package days
class Day5 : Day(5) {
data class Position(val x: Int, val y: Int)
override fun partOne(): Any {
val maxPosition = inputList.flatMap { it.split(" -> ", ",").map { str -> str.toInt() } }.maxOrNull()!!.plus(1)
val grid = Array(maxPosition) { IntArray(maxPosition) }
inputLis... | 0 | Kotlin | 0 | 2 | cf7535d1c4f8a327de19660bb3a9977750894f30 | 1,277 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/be/twofold/aoc2021/Day06.kt | jandk | 433,510,612 | false | {"Kotlin": 10227} | package be.twofold.aoc2021
object Day06 {
fun part1(input: List<Int>): Long {
return solve(input, 80)
}
fun part2(input: List<Int>): Long {
return solve(input, 256)
}
private fun solve(input: List<Int>, days: Int): Long {
val groups = LongArray(9)
input.forEach { g... | 0 | Kotlin | 0 | 0 | 2408fb594d6ce7eeb2098bc2e38d8fa2b90f39c3 | 784 | aoc2021 | MIT License |
Kotlin/src/PermutationsII.kt | TonnyL | 106,459,115 | false | null | /**
* Given a collection of numbers that might contain duplicates, return all possible unique permutations.
*
* For example,
* [1,1,2] have the following unique permutations:
* [
* [1,1,2],
* [1,2,1],
* [2,1,1]
* ]
*
* Accepted.
*/
class PermutationsII {
fun permuteUnique(nums: IntArray): List<List<Int... | 1 | Swift | 22 | 189 | 39f85cdedaaf5b85f7ce842ecef975301fc974cf | 1,041 | Windary | MIT License |
common/src/commonMain/kotlin/io/github/opletter/courseevals/common/data/Ratings.kt | opLetter | 597,896,755 | false | {"Kotlin": 390300} | package io.github.opletter.courseevals.common.data
typealias Ratings = List<List<Int>>
class RatingStats(
val ratings: List<Double>,
val numResponses: Int,
)
fun Collection<Ratings>.combine(): Ratings {
return reduce { accByQuestion, responsesByQ ->
// nums from each entry get zipped with each ot... | 0 | Kotlin | 0 | 3 | 44077ad89388cead3944975e975840580d2c9d0b | 1,384 | course-evals | MIT License |
atcoder/arc156/c_research.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package atcoder.arc156
import kotlin.random.Random
fun main() {
val n = readInt()
val nei = List(n) { mutableListOf<Int>() }
repeat(n - 1) {
val (u, v) = readInts().map { it - 1 }
nei[u].add(v); nei[v].add(u)
}
val r = Random(566)
val byDegree = nei.indices.sortedBy { nei[it].size }
val p = IntArray(n)
fo... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,034 | competitions | The Unlicense |
yandex/y2022/finals/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package yandex.y2022.finals
fun main() {
val (a, m) = readLongs()
val ps = mutableListOf<Long>()
var b = a
for (p in 2..b) {
if (b == 1L) break
if (p * p > b) {
ps.add(b)
break
}
if (b % p != 0L) continue
ps.add(p)
while (b % p == 0L) b /= p
}
var ans = Long.MAX_VALUE
for (r in 0..2) {
if ((... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,698 | competitions | The Unlicense |
year2018/src/main/kotlin/net/olegg/aoc/year2018/day19/Day19.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2018.day19
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2018.Command
import net.olegg.aoc.year2018.DayOf2018
import net.olegg.aoc.year2018.Ops
/**
* See [Year 2018, Day 19](https://adventofcode.com/2018/day/19)
*/
object Day19 : DayOf2018(19) {
private val OPS_PATTERN = ... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,301 | adventofcode | MIT License |
gcj/y2020/kickstart_b/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package gcj.y2020.kickstart_b
const val M = 1000000000
val DX = intArrayOf(1, 0, M - 1, 0)
val DY = intArrayOf(0, 1, 0, M - 1)
const val DIR_ROSE = "ESWN"
private fun solve(): String {
val s = "1(" + readLn() + ")"
var i = 0
fun readMove(): Pair<Int, Int> {
val c = s[i++]
if (c in DIR_ROSE) return DIR_ROSE.ind... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 815 | competitions | The Unlicense |
kotlin.web.demo.server/examples/Examples/Longer examples/Maze/Maze.kt | JetBrains | 3,602,279 | false | null | /**
* Let's Walk Through a Maze.
*
* Imagine there is a maze whose walls are the big 'O' letters.
* Now, I stand where a big 'I' stands and some cool prize lies
* somewhere marked with a '$' sign. Like this:
*
* OOOOOOOOOOOOOOOOO
* O O
* O$ O O
* OOOOO O
* O ... | 2 | Kotlin | 75 | 169 | 74eb79018f3f6b8d023fa0ef1a4b853503fe97a5 | 5,212 | kotlin-web-demo | Apache License 2.0 |
src/main/kotlin/net/mguenther/adventofcode/day16/Day16.kt | mguenther | 115,937,032 | false | null | package net.mguenther.adventofcode.day16
/**
* @author <NAME> (<EMAIL>)
*/
val alphabet: Array<String> = arrayOf(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
class Promenade(size: Int) {
private val numberOfP... | 0 | Kotlin | 0 | 0 | c2f80c7edc81a4927b0537ca6b6a156cabb905ba | 2,366 | advent-of-code-2017 | MIT License |
src/commonMain/kotlin/io/github/alexandrepiveteau/graphs/algorithms/ShortestPathFasterAlgorithm.kt | alexandrepiveteau | 630,931,403 | false | {"Kotlin": 132267} | @file:JvmName("Algorithms")
@file:JvmMultifileClass
package io.github.alexandrepiveteau.graphs.algorithms
import io.github.alexandrepiveteau.graphs.*
import io.github.alexandrepiveteau.graphs.internal.collections.IntDequeue
import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName
/**
* Returns the list of pare... | 9 | Kotlin | 0 | 6 | a4fd159f094aed5b6b8920d0ceaa6a9c5fc7679f | 3,779 | kotlin-graphs | MIT License |
app/src/main/kotlin/kotlinadventofcode/2015/2015-09.kt | pragmaticpandy | 356,481,847 | false | {"Kotlin": 1003522, "Shell": 219} | // Originally generated by the template in CodeDAO
package kotlinadventofcode.`2015`
import com.github.h0tk3y.betterParse.combinators.*
import com.github.h0tk3y.betterParse.grammar.*
import com.github.h0tk3y.betterParse.lexer.*
import kotlinadventofcode.Day
import kotlin.math.max
import kotlin.math.min
class `2015-09... | 0 | Kotlin | 0 | 3 | 26ef6b194f3e22783cbbaf1489fc125d9aff9566 | 3,764 | kotlinadventofcode | MIT License |
src/main/kotlin/com/askrepps/advent2021/day06/Day06.kt | askrepps | 726,566,200 | false | {"Kotlin": 302802} | /*
* MIT License
*
* Copyright (c) 2021-2023 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modi... | 0 | Kotlin | 0 | 0 | 89de848ddc43c5106dc6b3be290fef5bbaed2e5a | 2,652 | advent-of-code-kotlin | MIT License |
src/main/kotlin/Problem35.kt | jimmymorales | 496,703,114 | false | {"Kotlin": 67323} | /**
* Circular primes
*
* The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves
* prime.
*
* There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
*
* How many circular primes are there below one million?
*
* ... | 0 | Kotlin | 0 | 0 | e881cadf85377374e544af0a75cb073c6b496998 | 915 | project-euler | MIT License |
src/questions/SetMismatch.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.shouldBe
/**
* You have a set of integers s, which originally contains all the numbers from 1 to n.
* Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set,
* which results in repetition of one nu... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,868 | algorithms | MIT License |
src/main/kotlin/g1201_1300/s1254_number_of_closed_islands/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1201_1300.s1254_number_of_closed_islands
// #Medium #Array #Depth_First_Search #Breadth_First_Search #Matrix #Union_Find
// #Graph_Theory_I_Day_2_Matrix_Related_Problems
// #2023_06_07_Time_177_ms_(89.47%)_Space_36.7_MB_(81.58%)
class Solution {
private var rows = 0
private var cols = 0
private v... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,366 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/ginsberg/advent2018/Day16.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 16 - Chronal Classification
*
* Problem Description: http://adventofcode.com/2018/day/16
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day16/
*/
package com.ginsberg.advent2018
typealias Registers = IntArray
typeal... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 6,792 | advent-2018-kotlin | MIT License |
src/Day05.kt | daletools | 573,114,602 | false | {"Kotlin": 8945} | fun main() {
fun parseInput(input: List<String>) {
val inventorySize = input.indexOfFirst { it.isEmpty() }
var (boxes, commands) = input.partition { input.indexOf(it) <= inventorySize }
boxes = boxes.reversed().drop(2)
println(boxes)
println(commands)
}
fun part1(in... | 0 | Kotlin | 0 | 0 | c955c5d0b5e19746e12fa6a569eb2b6c3bc4b355 | 896 | adventOfCode2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RemoveDuplicates.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,261 | kotlab | Apache License 2.0 |
src/bonus/FindIndexOfTarget.kt | develNerd | 456,702,818 | false | {"Kotlin": 37635, "Java": 5892} | package bonus
import array.mergeSort
import kotlin.math.absoluteValue
class Api(){
companion object{
public var does = ""
}
}
/**
*
* if you are given an int array [3,1,11,5,10,19]. Find the index of target 10
* if the array was sorted.
*
* solution
*
* is to try to sort and while sorting find ... | 0 | Kotlin | 0 | 0 | 4e6cc8b4bee83361057c8e1bbeb427a43622b511 | 6,230 | Blind75InKotlin | MIT License |
src/Day01.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | fun main() {
fun groups(input: List<String>): List<Int> {
val groups = mutableListOf<Int>()
var current = 0
input.forEach {
if (it.isEmpty()) {
groups += current
current = 0
} else {
current += it.toInt()
}
... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 818 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SearchMatrix.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,544 | kotlab | Apache License 2.0 |
app/src/main/java/com/niekam/smartmeter/logic/BalanceCalculator.kt | NieKam | 456,935,979 | false | {"Kotlin": 108121} | package com.niekam.smartmeter.logic
import com.niekam.smartmeter.data.model.INSUFFICIENT_MEASUREMENTS
import com.niekam.smartmeter.data.model.Measurement
import com.niekam.smartmeter.data.model.NO_BALANCE
import com.niekam.smartmeter.tools.now
import java.util.concurrent.TimeUnit
private const val W1 = 1.0
private co... | 0 | Kotlin | 0 | 0 | d7a5e0c5c243b6f1e3c41ff398ed8e1d6eda7eb1 | 4,741 | smart-meter | Apache License 2.0 |
app/src/main/kotlin/me/mataha/misaki/solutions/adventofcode/aoc2015/d02/Day.kt | mataha | 302,513,601 | false | {"Kotlin": 92734, "Gosu": 702, "Batchfile": 104, "Shell": 90} | package me.mataha.misaki.solutions.adventofcode.aoc2015.d02
import me.mataha.misaki.domain.adventofcode.AdventOfCode
import me.mataha.misaki.domain.adventofcode.AdventOfCodeDay
/** See the puzzle's full description [here](https://adventofcode.com/2015/day/2). */
@AdventOfCode("I Was Told There Would Be No Math", 2015... | 0 | Kotlin | 0 | 0 | 748a5b25a39d01b2ffdcc94f1a99a6fbc8a02685 | 1,124 | misaki | MIT License |
src/main/kotlin/model/Grammar.kt | Furetur | 439,579,145 | false | {"Kotlin": 21223, "ANTLR": 246} | package model
import java.util.*
// Symbols
sealed class Symbol {
abstract val name: String
}
data class Term(override val name: String) : Symbol() {
override fun toString(): String = name
}
data class NonTerm(override val name: String): Symbol() {
override fun toString(): String = name
}
typealias Sy... | 0 | Kotlin | 0 | 1 | 002cc53bcca6f9b591c4090d354f03fe3ffd3ed6 | 1,887 | LLkChecker | MIT License |
buildSrc/src/main/kotlin/kotlinx/html/generate/parent-ifaces-gen.kt | Kotlin | 33,301,379 | false | {"Kotlin": 554316} | package kotlinx.html.generate
import java.io.*
import java.util.*
fun generateParentInterfaces(repository: Repository, todir: String, packg: String) {
val allParentIfaces = repository.tags.values.filterIgnored().map { tag ->
val parentAttributeIfaces = tag.attributeGroups.map { it.name.humanize().capitali... | 89 | Kotlin | 177 | 1,514 | 6c926dda0567d765fe84239e13606e43ff2e3657 | 3,530 | kotlinx.html | Apache License 2.0 |
src/day7/fr/Day07_1.kt | BrunoKrantzy | 433,844,189 | false | {"Kotlin": 63580} | package day7.fr
import java.io.File
import kotlin.math.abs
private fun readChars(): CharArray = readLn().toCharArray()
private fun readLn() = readLine()!! // string line
private fun readSb() = StringBuilder(readLn())
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // ... | 0 | Kotlin | 0 | 0 | 0d460afc81fddb9875e6634ee08165e63c76cf3a | 1,424 | Advent-of-Code-2021 | Apache License 2.0 |
src/test/kotlin/com/igorwojda/pochallenges/6-13-2022.kt | RyanKCox | 498,808,938 | false | {"Kotlin": 254610} | package com.igorwojda.pochallenges
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
import kotlin.math.max
import kotlin.math.min
/**
* Median of sorted array challenge
*/
private fun medianSortedArray(num1:IntArray,num2:IntArray):Double
{
if(num1.size > num2.size)
return med... | 0 | Kotlin | 0 | 0 | f7657f9a60cd20f98c2da95bf65a7981758e8337 | 5,292 | kotlin-coding-challenges | MIT License |
src/Day06.kt | arisaksen | 573,116,584 | false | {"Kotlin": 42887} | import org.assertj.core.api.Assertions.assertThat
import java.util.LinkedList
// https://adventofcode.com/2022/day/6
fun main() {
val moreThanTwoEqual = """^.*(.).*\1.*${'$'}""".toRegex()
fun part1(input: String): Int {
val limitedQue = LinkedList<Char>()
val queSize = 4
input.forEach... | 0 | Kotlin | 0 | 0 | 85da7e06b3355f2aa92847280c6cb334578c2463 | 1,583 | aoc-2022-kotlin | Apache License 2.0 |
src/day07/day07.kt | mahmoud-abdallah863 | 572,935,594 | false | {"Kotlin": 16377} | package day07
import assertEquals
import readInput
import readTestInput
import kotlin.math.min
fun main() {
fun calculateShit(directory: MyDirectory): Int {
val currentDirSize = directory.calculateSize()
val currentSize = if (currentDirSize < 100_000) currentDirSize else 0
return current... | 0 | Kotlin | 0 | 0 | f6d1a1583267e9813e2846f0ab826a60d2d1b1c9 | 1,356 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day23/Day23.kt | Jessevanbekkum | 112,612,571 | false | null | package day23
import util.readLines
class Day23(input: String, a: Long) {
val set = Regex("set (\\w) ([\\w-]*)")
val mul = Regex("mul (\\w) ([\\w-]*)")
val sub = Regex("sub (\\w) ([\\w-]*)")
val jnz = Regex("jnz (\\w) ([\\w-]*)")
val reg = mutableMapOf<String, Long>()
val regex = listOf<Regex>... | 0 | Kotlin | 0 | 0 | 1340efd354c61cd070c621cdf1eadecfc23a7cc5 | 1,974 | aoc-2017 | Apache License 2.0 |
src/main/kotlin/endredeak/aoc2022/Day25.kt | edeak | 571,891,076 | false | {"Kotlin": 44975} | package endredeak.aoc2022
fun main() {
solve( "Full of Hot Air") {
fun Long.pow(i: Int): Long {
var ret = 1L
repeat(i) { ret *= this }
return ret
}
fun String.toSnofuDigit() =
this.reversed().mapIndexed { i, c ->
when(c) {
... | 0 | Kotlin | 0 | 0 | e0b95e35c98b15d2b479b28f8548d8c8ac457e3a | 1,150 | AdventOfCode2022 | Do What The F*ck You Want To Public License |
src/main/kotlin/Day01.kt | SimonMarquis | 724,825,757 | false | {"Kotlin": 30983} | class Day01(private val input: List<String>) {
fun part1() = input.asSequence()
.map { it.filter(Char::isDigit) }
.sumOf { "${it.first()}${it.last()}".toInt() }
private val replacements = listOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
fun part2() = input.as... | 0 | Kotlin | 0 | 1 | 043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e | 814 | advent-of-code-2023 | MIT License |
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/middle/Search.kt | scientificCommunity | 352,868,267 | false | {"Java": 154453, "Kotlin": 69817} | package org.baichuan.sample.algorithms.leetcode.middle
/**
* https://leetcode.cn/problems/search-in-rotated-sorted-array/
* 33. 搜索旋转排序数组
*/
class Search {
fun search(nums: IntArray, target: Int): Int {
val first = nums[0]
if (target == first) {
return 0
}
var i = nums... | 1 | Java | 0 | 8 | 36e291c0135a06f3064e6ac0e573691ac70714b6 | 1,534 | blog-sample | Apache License 2.0 |
src/main/kotlin/com/dood/kotlin/basicstuff/iteration/7_Iteration.kt | coderdude1 | 164,117,770 | false | null | package com.dood.kotlin.basicstuff.iteration
import java.util.*
fun main(args: Array<String>) {
simpleLoop()
countDownwardEvenOnly()
countDownToLimit()
populateAndIterateOverMap()
iterateListWithIndex()
rangeMembership()
}
/**
* while and do-while loops are the same as java
*
* the for loo... | 0 | Kotlin | 0 | 0 | 5f5dcb954152b81f458bf614c79a5116dd554385 | 3,127 | KotlinBasicExperiments | Apache License 2.0 |
src/main/java/challenges/educative_grokking_coding_interview/merge_intervals/_5/MeetingRooms.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.merge_intervals._5
import challenges.educative_grokking_coding_interview.merge_intervals.Interval
object MeetingRooms {
private fun minMeetingRooms(intervals: List<Interval>): Int {
if (intervals.isEmpty()) {
return 0
}
//... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 1,795 | CodingChallenges | Apache License 2.0 |
src/main/kotlin/g1001_1100/s1081_smallest_subsequence_of_distinct_characters/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1001_1100.s1081_smallest_subsequence_of_distinct_characters
// #Medium #String #Greedy #Stack #Monotonic_Stack
// #2023_06_02_Time_146_ms_(100.00%)_Space_34_MB_(100.00%)
import java.util.Arrays
import java.util.Deque
import java.util.LinkedList
class Solution {
fun smallestSubsequence(s: String): String... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,272 | LeetCode-in-Kotlin | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.