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/com/github/solairerove/algs4/leprosorium/sorting/MergeSortBU.kt | solairerove | 282,922,172 | false | {"Kotlin": 251919} | package com.github.solairerove.algs4.leprosorium.sorting
import kotlin.math.min
fun main() {
val items = mutableListOf(5, 6, 4, 3, 10, 9, 5, 6, 7)
print("items: $items \n")
mergeSort(items)
print("items: $items \n")
}
// O(nlog(n)) time | O(n) space
private fun mergeSort(arr: MutableList<Int>) {
... | 1 | Kotlin | 0 | 3 | 64c1acb0c0d54b031e4b2e539b3bc70710137578 | 1,059 | algs4-leprosorium | MIT License |
hacker-rank/sorting/MergeSortCountingInversions.kt | piazentin | 62,427,919 | false | {"Python": 34824, "Jupyter Notebook": 29307, "Kotlin": 19570, "C++": 2465, "R": 2425, "C": 158} | import java.lang.StringBuilder
private fun IntArray.toNiceString(): String {
val sb = StringBuilder().append("[")
this.forEach { sb.append(it).append(",") }
if (sb.length > 1) sb.deleteCharAt(sb.lastIndex).append("]")
return sb.toString()
}
private val IntRange.size: Int
get() = this.last - this.... | 0 | Python | 0 | 0 | db490b1b2d41ed6913b4cacee1b4bb40e15186b7 | 1,776 | programming-challenges | MIT License |
2023/src/main/kotlin/Day21.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import java.util.*
object Day21 {
fun part1(input: String, steps: Int): Long {
check(steps % 2 == 0) { "Number of steps must be even" }
val (grid, start) = parse(input)
return explore(grid, start, steps).even
}
fun part2(input: String, steps: Int): Long {
val (grid, start) = parse(input)
/... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 5,237 | advent-of-code | MIT License |
src/main/kotlin/day08/map.kt | cdome | 726,684,118 | false | {"Kotlin": 17211} | package day08
import java.io.File
fun main() {
val file = File("src/main/resources/day08-map").readLines()
val instructions = file[0]
val map = file.stream().skip(2).map { line ->
val (def, dirs) = line.split(" = ")
val (l, r) = dirs.split(", ")
def.trim() to Pair(l.removePrefix("... | 0 | Kotlin | 0 | 0 | 459a6541af5839ce4437dba20019b7d75b626ecd | 1,228 | aoc23 | The Unlicense |
test/leetcode/NestingDepthOfParentheses.kt | andrej-dyck | 340,964,799 | false | null | package leetcode
import lib.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.params.*
import org.junit.jupiter.params.provider.*
/**
* https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/
*
* 1614. Maximum Nesting Depth of the Parentheses
* [Easy]
*
* A string is a... | 0 | Kotlin | 0 | 0 | 3e3baf8454c34793d9771f05f330e2668fda7e9d | 1,884 | coding-challenges | MIT License |
2021/five.kt | charlottemach | 433,765,865 | false | {"D": 7911, "Haxe": 5698, "Go": 5682, "Julia": 5361, "R": 5032, "Kotlin": 4670, "Dockerfile": 4516, "C++": 4312, "Haskell": 4113, "Scala": 4080, "OCaml": 3901, "Raku": 3680, "Erlang": 3436, "Swift": 2863, "Groovy": 2861, "Vala": 2845, "JavaScript": 2735, "Crystal": 2210, "Python": 2197, "Clojure": 2172, "Ruby": 2163, "... | import java.io.File
import kotlin.math.abs
fun main() {
val input = File("five.txt").readText()
val coord = input.trim().split("\n").map{ it.split(" -> ")}
val mat = Array(1000) {Array(1000) {0} }
//val mat = Array(10) {Array(10) {0} }
for (c in coord) {
val start = c.first().split(","); va... | 0 | D | 0 | 0 | dc839943639282005751b68a7988890dadf00f41 | 1,793 | adventofcode | Apache License 2.0 |
src/Lesson7StacksAndQueues/Brackets.kt | slobodanantonijevic | 557,942,075 | false | {"Kotlin": 50634} |
import java.util.Stack
/**
* 100/100
* @param S
* @return
*/
fun solution(S: String): Int {
if (S.length == 0) return 1
if (S.length % 2 != 0) return 0
val stack: Stack<Char> = Stack<Char>()
for (i in 0 until S.length) {
val character = S[i]
when (character) {
')' -> i... | 0 | Kotlin | 0 | 0 | 155cf983b1f06550e99c8e13c5e6015a7e7ffb0f | 1,794 | Codility-Kotlin | Apache License 2.0 |
src/Lesson4CountingElements/PermCheck.kt | slobodanantonijevic | 557,942,075 | false | {"Kotlin": 50634} | /**
* 100/100
* @param A
* @return
*/
fun solution(A: IntArray): Int {
val uniqueCheck = IntArray(A.size)
for (i in A.indices) {
val current = A[i] - 1
if (A[i] > A.size) return 0
uniqueCheck[current]++
if (uniqueCheck[current] > 1) return 0
}
return 1
}
/**
* A non... | 0 | Kotlin | 0 | 0 | 155cf983b1f06550e99c8e13c5e6015a7e7ffb0f | 1,401 | Codility-Kotlin | Apache License 2.0 |
2021/src/test/kotlin/Day14.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import java.lang.IllegalStateException
import kotlin.test.Test
import kotlin.test.assertEquals
class Day14 {
@Test
fun `run part 01`() {
val (template, insertions) = getInstructions()
val result = template
.toInitialPairs()
.processPairInsertions(insertions, 10)
... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 2,569 | adventofcode | MIT License |
src/main/kotlin/common/Utils.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package common
import common.Collections.transpose
import common.Misc.next
import common.Space2D.Direction.*
import common.Space2D.Point
import common.Space2D.toLoggable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import java.math.BigInteger
import java.s... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 14,401 | aoc | Apache License 2.0 |
algorithms/src/main/kotlin/com/thepyprogrammer/ktlib/math/types/Complex.kt | terminalai | 312,471,067 | false | null | package com.thepyprogrammer.ktlib.math.types
import kotlin.math.*
data class Complex(val re: Double, val im: Double = 0.0, val isUnit: Boolean = false) {
constructor(value: Complex): this(value.re, value.im, value.isUnit)
constructor(mag: Double, arg: Angle) : this(cos(arg.angle) * mag, sin(arg.angle) * mag,... | 1 | Jupyter Notebook | 4 | 10 | 2064375ddc36bf38f3ff65f09e776328b8b4612a | 2,578 | GaitMonitoringForParkinsonsDiseasePatients | MIT License |
src/Day11.kt | roxanapirlea | 572,665,040 | false | {"Kotlin": 27613} | import kotlin.math.floor
private enum class Operation { MULTIPLY, ADD, SQUARE }
private data class Monkey(
val items: MutableList<Long> = mutableListOf(),
val operation: Pair<Operation, Int> = Pair(Operation.ADD, 0),
val testDivider: Int = 1,
val monkeyTrue: Int = -1,
val monkeyFalse: Int = -1
)
f... | 0 | Kotlin | 0 | 0 | 6c4ae6a70678ca361404edabd1e7d1ed11accf32 | 5,459 | aoc-2022 | Apache License 2.0 |
src/test/kotlin/be/brammeerten/y2022/Day14Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2022
import be.brammeerten.Co
import be.brammeerten.readFile
import be.brammeerten.y2022.Tile.*
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import kotlin.math.max
import kotlin.math.min
class Day14Test {
@Test
fun `part 1a`() {
val map = Cave(scan... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 3,792 | Advent-of-Code | MIT License |
solutions/src/solutions/y20/day 16.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.y20.d16
import grid.Clock
import helpers.*
val xxxxx = Clock(6, 3);
private fun part1(data: Data) {
val rules = data.takeWhile { it.isNotBlank() }.map{
it.split(": ")[1].split(" or ").map{it.getPosInts()}.map{(a,b)->a..b}
}
val rem = data.drop(rules.... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 1,926 | AdventOfCodeSolutions | MIT License |
src/main/kotlin/fraug/droid/features/Leaderboard.kt | paug | 252,267,402 | false | null | package fraug.droid.features
import fraug.droid.Attempt
import fraug.droid.Fish
data class Score(
val found: Int,
val errors: Int,
val first: Int
)
object Leaderboard {
fun asString(scores: Map<String, Score>, limit: Int = Int.MAX_VALUE): String {
return "position. username: score (found - er... | 0 | Kotlin | 1 | 2 | b9b820c98e283a11d4286255dd41363baaac7933 | 3,733 | fraugdroid | MIT License |
src/Day05.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | class Stack{
val elements: MutableList<Char> = mutableListOf()
fun isEmpty() = elements.isEmpty()
fun size() = elements.size
fun push(item: Char) = elements.add(item)
fun insert(item: Char) = elements.add(0, item)
fun pop() : Char {
val item = elements.last()
if (!isEmpty())... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 3,691 | AoC-2022 | Apache License 2.0 |
src/year2022/day05/Solution.kt | LewsTherinTelescope | 573,240,975 | false | {"Kotlin": 33565} | package year2022.day05
import utils.runIt
import utils.splitOnBlankLines
fun main() = runIt(
testInput = """
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
""".trimIndent(),
::part1,
testAnswerPart1 = "CMZ",
::part2,
... | 0 | Kotlin | 0 | 0 | ee18157a24765cb129f9fe3f2644994f61bb1365 | 2,704 | advent-of-code-kotlin | Do What The F*ck You Want To Public License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions56.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
import com.qiaoyuang.algorithm.round0.BinaryTreeNode
fun test56() {
val testTree1 = binarySearchTreeTestCase()
printlnResult(testTree1, 13)
printlnResult(testTree1, 8)
val testTree2 = binarySearchTreeTestCase2()
printlnResult(testTree2, 12)
printlnResult... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,953 | Algorithm | Apache License 2.0 |
src/main/kotlin/g0601_0700/s0638_shopping_offers/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0601_0700.s0638_shopping_offers
// #Medium #Array #Dynamic_Programming #Bit_Manipulation #Backtracking #Bitmask #Memoization
// #2023_02_10_Time_195_ms_(100.00%)_Space_35.1_MB_(100.00%)
class Solution {
fun shoppingOffers(
price: List<Int>,
special: List<List<Int>>,
needs: List<In... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,019 | LeetCode-in-Kotlin | MIT License |
src/y2016/Day01.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2016
import util.Cardinal
import util.Turn
import util.plus
import util.readInput
import util.times
import kotlin.math.abs
object Day01 {
private fun parse(input: List<String>): List<Pair<Turn, Int>> {
return input.first().split(", ").map {
Turn.fromChar(it.first()) to it.drop(1).toIn... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 1,681 | advent-of-code | Apache License 2.0 |
src/main/kotlin/y2021/Day03.kt | jforatier | 432,712,749 | false | {"Kotlin": 44692} | package y2021
class Day03(private val data: List<String>) {
class Report(private val data: List<String>) {
fun gamma(): String {
// Using first line to determine limits of my browse (indices of line 1 will tell me I can look through column 0 to 4)
// Then for each column (0 to 4), ... | 0 | Kotlin | 0 | 0 | 2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae | 1,832 | advent-of-code-kotlin | MIT License |
src/year_2022/day_14/Day14.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2022.day_14
import readInput
import util.connect
import util.down
import util.downLeft
import util.downRight
sealed class DropSandResult {
object Infinity: DropSandResult()
data class Stopped(val at: Pair<Int, Int>): DropSandResult()
}
object Day14 {
private val sandStartingPosition = 500 t... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 4,664 | advent_of_code | Apache License 2.0 |
Coding Challenges/Advent of Code/2021/Day 4/part1.kt | Alphabeater | 435,048,407 | false | {"Kotlin": 69566, "Python": 5974} | import java.io.File
import java.util.Scanner
import kotlin.system.exitProcess
const val DIM = 5
class BingoBoard {
private val size = DIM
val board = Array(size) { IntArray(size) } //this represents a single bingo board[x][x].
val found = Array(size) { Array(size){ false } } //this represents what numbers... | 0 | Kotlin | 0 | 0 | 05c8d4614e025ed2f26fef2e5b1581630201adf0 | 2,846 | Archive | MIT License |
src/main/kotlin/days_2021/Day5.kt | BasKiers | 434,124,805 | false | {"Kotlin": 40804} | package days_2021
import util.Day
import kotlin.math.absoluteValue
class Day5 : Day(5) {
val lines: List<Pair<Pair<Int, Int>, Pair<Int, Int>>> = inputList.map { line ->
val (from, to) = line.split(" -> ")
val (fromX, fromY) = from.split(",").map(String::toInt)
val (toX, toY) = to.split(","... | 0 | Kotlin | 0 | 0 | 870715c172f595b731ee6de275687c2d77caf2f3 | 1,972 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dev/shtanko/algorithms/leetcode/GenerateTrees.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,845 | kotlab | Apache License 2.0 |
src/main/kotlin/g1801_1900/s1879_minimum_xor_sum_of_two_arrays/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1801_1900.s1879_minimum_xor_sum_of_two_arrays
// #Hard #Array #Dynamic_Programming #Bit_Manipulation #Bitmask
// #2023_06_22_Time_173_ms_(100.00%)_Space_36.9_MB_(100.00%)
class Solution {
fun minimumXORSum(nums1: IntArray, nums2: IntArray): Int {
val l = nums1.size
val dp = IntArray(1 shl... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,102 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/org/cryptobiotic/mixnet/Permutation.kt | JohnLCaron | 754,705,115 | false | {"Kotlin": 363510, "Java": 246365, "Shell": 7749, "C": 5751, "JavaScript": 2517} | package org.cryptobiotic.mixnet
import java.security.SecureRandom
/**
psi: {0..N-1} -> {0..N-1}
for any vector e, pe = psi.permute(e). then e_i = pe_j, where j = psi.inv(i), i = psi.of(j)
so e[idx] = pe[psi.inv(idx)]; you have an element in e, and need to get the corresponding element from pe
so pe[jd... | 0 | Kotlin | 0 | 0 | 63de19eb8ca2fb2b2d3286213b71c71097ab1d85 | 2,273 | egk-mixnet-vmn | MIT License |
src/commonMain/kotlin/ai/hypergraph/kaliningraph/theory/Theory.kt | breandan | 245,074,037 | false | {"Kotlin": 1482924, "Haskell": 744, "OCaml": 200} | package ai.hypergraph.kaliningraph.theory
import ai.hypergraph.kaliningraph.*
import ai.hypergraph.kaliningraph.sampling.randomMatrix
import ai.hypergraph.kaliningraph.sampling.sample
import ai.hypergraph.kaliningraph.tensor.*
import ai.hypergraph.kaliningraph.types.*
// https://en.wikipedia.org/wiki/Barab%C3%A1si%E2... | 0 | Kotlin | 8 | 100 | c755dc4858ed2c202c71e12b083ab0518d113714 | 3,981 | galoisenne | Apache License 2.0 |
src/PuzzleSolver.kt | JosephPrichard | 477,595,077 | false | null | /*
* Implements AStar algorithm to solve the puzzle
* 4/16/20
*/
package src
import java.util.*
import kotlin.math.abs
/**
*
* @author <NAME>
*/
class PuzzleSolver(private val boardSize: Int) {
private val goalState: PuzzleState
init {
// creates the goal state for the specified board size
... | 0 | Kotlin | 0 | 1 | 9075414576cf92e23c3c0ad6bb222591f0d05d14 | 5,822 | SlidingPuzzle | MIT License |
day02/src/main/kotlin/Main.kt | rstockbridge | 159,586,951 | false | null | import java.io.File
import java.lang.IllegalStateException
fun main() {
val input = readInputFile()
println("Part I: the solution is ${solvePartI(input)}.")
println("Part II: the solution is ${solvePartII(input)}.")
}
fun readInputFile(): List<String> {
return File(ClassLoader.getSystemResource("inpu... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 1,272 | AdventOfCode2018 | MIT License |
solutions/src/MinTimeToCollectAllApples.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | /**
* https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/
*/
class MinTimeToCollectAllApples {
fun minTime(n: Int, edges: Array<IntArray>, hasApple: List<Boolean>) : Int {
val edgeMap = edges.map { Pair(it[0],it[1]) }.groupBy { it.first }.mapValues { entry -> entry.value.map { it.s... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,169 | leetcode-solutions | MIT License |
Algorithms/432 - All O one Data Structure/src/Solution2.kt | mobeigi | 202,966,767 | false | null | /**
* Solution2
*
* We use two maps to allow us to lookup keys by string in O(1) and lookup by frequency in O(1).
* This solution does NOT meet the requirements as getMaxKey and getMinKey are both O(N) functions.
* However, this solution is simple to read and understand and is quite performant nevertheless.
*/
cl... | 0 | Kotlin | 0 | 0 | e5e29d992b52e4e20ce14a3574d8c981628f38dc | 1,673 | LeetCode-Solutions | Academic Free License v1.1 |
solutions/src/KnightDialer.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | class KnightDialer {
/**
* https://leetcode.com/problems/knight-dialer/
*/
fun knightDialer(n: Int) : Int {
val MOD = 1000000007
val dialerDP = Array(n){LongArray(12) { 0 } }
for (i in 0..11) {
if (i != 9 && i != 11) {
dialerDP[0][i] = 1;
... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,560 | leetcode-solutions | MIT License |
src/Day03.kt | bkosm | 572,912,735 | false | {"Kotlin": 17839} | import dev.forkhandles.result4k.partition
import kotlin.math.roundToInt
object Day03 : DailyRunner<Int, Int> {
@JvmInline
private value class Prio private constructor(val value: Int) {
companion object {
private val PriorityMap = ((('a'..'z') zip (1..26)) + (('A'..'Z') zip (27..52))).toMap(... | 0 | Kotlin | 0 | 1 | 3f9cccad1e5b6ba3e92cbd836a40207a2f3415a4 | 1,565 | aoc22 | Apache License 2.0 |
src/Day01.kt | jarmstrong | 572,742,103 | false | {"Kotlin": 5377} | fun main() {
fun calorieCountsByElf(input: List<String>): Map<Int, Int> {
var currentElfIndex = 0
val elfCalorieCounts = mutableMapOf<Int, Int>()
input.forEach {
if (it.isEmpty()) {
currentElfIndex++
return@forEach
}
val cu... | 0 | Kotlin | 0 | 0 | bba73a80dcd02fb4a76fe3938733cb4b73c365a6 | 918 | aoc-2022 | Apache License 2.0 |
src/Day09.kt | ixtryl | 575,312,836 | false | null | import java.util.*
import kotlin.math.abs
fun main() {
// if (DAY09().run("Day09_test", 2) != 13) {
// throw RuntimeException("Fail: Expected 13")
// }
// if (DAY09().run("Day09", 2) != 6081) {
// throw RuntimeException("Fail: Expected 6081")
// }
if (DAY09().run("Day09_test2", 10) != 36)... | 0 | Kotlin | 0 | 0 | 78fa5f6f85bebe085a26333e3f4d0888e510689c | 5,955 | advent-of-code-kotlin-2022 | Apache License 2.0 |
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/kotlin/westwbn.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": ... | import kotlin.math.sqrt
fun main() {
print("Ingresa un numero : ")
val n = readln().toInt()
evaluateNumber(n)
}
fun evaluateNumber(number:Int){
if (number < 0){
println("Ingresa un numero entero")
} else {
println("$number ${isPrime(number)}, ${isFibonacci(number)} y ${isPar(numbe... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 989 | retos-programacion-2023 | Apache License 2.0 |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day13/Game.kt | jrhenderson1988 | 289,786,400 | false | {"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37} | package com.github.jrhenderson1988.adventofcode2019.day13
class Game(private val intCodeComputer: IntCodeComputer) {
fun totalBlocksOnScreen(): Int {
val cpu = intCodeComputer
return generateSequence { Pair(cpu.execute()!!, cpu.execute()!!) to (Tile.fromValue(cpu.execute()!!)) }
.takeWh... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 2,123 | advent-of-code | Apache License 2.0 |
src/main/Main.kt | somei-san | 476,528,544 | false | {"Kotlin": 12475} | import java.util.*
fun main(args: Array<String>) {
abc000X()
}
fun abc000X() {
System.err.println("!!!!!!!!!!!テスト!!!!!!!!!")
val N = readLine()!!
val As = readLine()!!.split(" ").map { it.toInt() }.sorted()
System.err.println(As)
val sets = mutableListOf<kakeru>()
for (k in 0 until As.c... | 0 | Kotlin | 0 | 0 | 43ea45fc0bc135d6d33af1fd0d7de6a7b3b651ec | 4,465 | atcoder-kotline | MIT License |
src/main/kotlin/com/londogard/summarize/summarizers/TfIdfSummarizer.kt | londogard | 222,868,849 | false | null | package com.londogard.summarize.summarizers
import com.londogard.summarize.extensions.mutableSumByCols
import smile.nlp.*
import kotlin.math.roundToInt
internal class TfIdfSummarizer : Summarizer {
private fun getSentences(text: String): List<String> = text.normalize().sentences().toList()
override fun summa... | 3 | Kotlin | 0 | 2 | 521818ed9057e5ffb58a8ae7b3f0a6c3269e93cc | 1,640 | summarize-kt | Apache License 2.0 |
src/Day10.kt | fouksf | 572,530,146 | false | {"Kotlin": 43124} | import java.lang.Exception
import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
var register = 1
var result = 0
var cycle = 1
val cyclesOfInterest = arrayListOf(20, 60, 100, 140, 180, 220)
for (line in input) {
if (cycle in cyclesOfInterest)... | 0 | Kotlin | 0 | 0 | 701bae4d350353e2c49845adcd5087f8f5409307 | 1,730 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | kedvinas | 572,850,757 | false | {"Kotlin": 15366} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
val grid = input.map {
it.toCharArray().map { it.digitToInt() }
}
val visible = Array(grid.size) {
Array(grid.size) {
0
}
}
for (i in 0 until grid.... | 0 | Kotlin | 0 | 0 | 04437e66eef8cf9388fd1aaea3c442dcb02ddb9e | 3,063 | adventofcode2022 | Apache License 2.0 |
solutions/aockt/y2023/Y2023D25.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2023
import aockt.util.parse
import io.github.jadarma.aockt.core.Solution
import kotlin.random.Random
object Y2023D25 : Solution {
/**
* The internal wiring of a Snow Machine.
* @property nodes The names of the parts.
* @property edges Pairs of parts, determining bidirectional conne... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 3,910 | advent-of-code-kotlin-solutions | The Unlicense |
src/main/kotlin/org/example/e3fxgaming/adventOfCode/aoc2023/day05/Day05.kt | E3FxGaming | 726,041,587 | false | {"Kotlin": 38290} | package org.example.e3fxgaming.adventOfCode.aoc2023.day05
import org.example.e3fxgaming.adventOfCode.utility.Day
import org.example.e3fxgaming.adventOfCode.utility.InputParser
import org.example.e3fxgaming.adventOfCode.utility.MultiLineInputParser
import java.util.PriorityQueue
class Day05(input: String) : Day<Day05.... | 0 | Kotlin | 0 | 0 | 3ae9e8b60788733d8bc3f6446d7a9ae4b3dabbc0 | 5,170 | adventOfCode | MIT License |
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day13/Day13.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2020.day13
import eu.janvdb.aocutil.kotlin.ChineseRemainderTheoremEquation
import eu.janvdb.aocutil.kotlin.ModuloMath
import java.math.BigInteger
//const val TIME_ = 939L
//const val BUSSES = "7,13,x,x,59,x,31,19"
const val TIME = 1000052L
const val BUSSES =
"23,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,785 | advent-of-code | Apache License 2.0 |
src/main/kotlin/aoc2023/day20/day20Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day20
import lib.*
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<List<Module>> {
return setup {
day(20)
year(2023)
//input("example.txt")
parser {
it.readLines()
.map {
... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 4,495 | AoC-2023-DDJ | MIT License |
src/main/kotlin/day13/main.kt | janneri | 572,969,955 | false | {"Kotlin": 99028} | package day13
import util.*
data class PacketPair(val left: Packet, val right: Packet)
open class Packet
data class IntValue(val value: Int): Packet() {
override fun toString(): String = value.toString()
}
data class ListValue(val values: List<Packet>): Packet() {
constructor(value: Packet): this(listOf(valu... | 0 | Kotlin | 0 | 0 | 1de6781b4d48852f4a6c44943cc25f9c864a4906 | 4,461 | advent-of-code-2022 | MIT License |
src/Day01.kt | yturkkan-figure | 434,994,594 | false | {"Kotlin": 3305} | fun main() {
fun part1(input: List<String>): Int {
var count = 0
var cur: Int = input[0].toInt()
for (i in 1..input.size-1){
if (input[i].toInt() > cur){
count += 1
}
cur = input[i].toInt()
if (i == input.size-1){
... | 0 | Kotlin | 0 | 0 | 8c7bd9bfeba3f31833a0df822ad52add02ec1a0d | 1,184 | advent-of-code-kotlin-template | Apache License 2.0 |
kotlin/src/main/kotlin/dev/egonr/leetcode/03_LongestSubstring.kt | egon-r | 575,970,173 | false | null | package dev.egonr.leetcode
/* Medium
Given a string s, find the length of the longest
substring
without repeating characters.
Example 1:
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: s = "bbbbb"
Output: 1
Explanation: The answer is "b", with the length ... | 0 | Kotlin | 0 | 0 | b9c59e54ca2d1399d34d1ee844e03c16a580cbcb | 2,211 | leetcode | The Unlicense |
kotlin/0028-find-the-index-of-the-first-occurrence-in-a-string.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} | /*
* KMP algorithm
*/
class Solution {
fun strStr(haystack: String, needle: String): Int {
if(needle == "") return 0
val lps = IntArray(needle.length)
var prevLPS = 0
var i = 1
while(i < needle.length) {
if(needle[i] == needle[prevLPS]) {
lps[i] =... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 4,565 | leetcode | MIT License |
src/Day01.kt | AleksanderBrzozowski | 574,061,559 | false | null | fun main() {
val testInput = elves("Day01_test")
println(testInput.maxBy { it.calories.sum() }.calories.sum())
val input = elves("Day01")
val (first, second, third) = input.map { it.calories.sum() }.sortedByDescending { it }
println(first + second + third)
}
private data class Elf(val calories: Li... | 0 | Kotlin | 0 | 0 | 161c36e3bccdcbee6291c8d8bacf860cd9a96bee | 688 | kotlin-advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/pl/mrugacz95/aoc/day5/day5.kt | mrugacz95 | 317,354,321 | false | null | package pl.mrugacz95.aoc.day5
import kotlin.math.floor
class Range(var lowerRange: Int, var upperRange: Int) {
fun select(upper: Boolean) {
val mid: Int = floor((lowerRange + upperRange) / 2.0).toInt()
if (upper) {
lowerRange = mid + 1
} else {
upperRange = mid
... | 0 | Kotlin | 0 | 1 | a2f7674a8f81f16cd693854d9f564b52ce6aaaaf | 1,524 | advent-of-code-2020 | Do What The F*ck You Want To Public License |
2020/src/year2020/day06/Day06.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2020.day06
import util.readAllLines
private fun getAnswers(filename: String): List<Set<Char>> {
val result = mutableListOf<Set<Char>>()
val set = mutableSetOf<Char>()
readAllLines(filename).map { line ->
if (line.isBlank()) {
if (set.isNotEmpty()) {
result.... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 1,519 | adventofcode | MIT License |
src/medium/ArrayAndStrings/776-3Sum.kt | diov | 170,882,024 | false | null | fun main() {
// val nums = intArrayOf(-1, 0, 1, 2, -1, -4)
val nums = intArrayOf(0, 0, 0, 0)
// val nums = intArrayOf(-1, 0, 1, 2, -1, -4)
// val nums = intArrayOf(3, 0, -2, -1, 1, 2)
// val nums = intArrayOf(-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6)
println(threeSum(nums))
}
fun threeSum(nu... | 0 | Kotlin | 0 | 0 | 668ef7d6d1296ab4df2654d5a913a0edabc72a3c | 1,396 | leetcode | MIT License |
src/Day03.kt | Tomcat88 | 572,566,485 | false | {"Kotlin": 52372} | fun main() {
fun part1(input: List<String>) =
input.sumOf { rucksack ->
rucksack.chunked(rucksack.length / 2)
.map { it.toSet() }
.reduce { acc, e -> acc intersect e }
.singleOrNull().priority
}
fun part2(input: List<Strin... | 0 | Kotlin | 0 | 0 | 6d95882887128c322d46cbf975b283e4a985f74f | 799 | advent-of-code-2022 | Apache License 2.0 |
2021/src/main/kotlin/de/skyrising/aoc2021/day14/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2021.day14
import de.skyrising.aoc.*
import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap
import it.unimi.dsi.fastutil.chars.Char2LongMap
import it.unimi.dsi.fastutil.chars.Char2LongOpenHashMap
import it.unimi.dsi.fastutil.ints.Int2LongMap
import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 3,752 | aoc | MIT License |
kotlin/structures/FenwickTreeExtended.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package structures
object FenwickTreeExtended {
// T[i] += value
fun add(t: IntArray, i: Int, value: Int) {
var i = i
while (i < t.size) {
t[i] += value
i = i or i + 1
}
}
// sum[0..i]
fun sum(t: IntArray, i: Int): Int {
var i = i
var... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 3,093 | codelibrary | The Unlicense |
src/main/kotlin/com/nibado/projects/advent/y2020/Day22.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2020
import com.nibado.projects.advent.*
object Day22 : Day {
private val players = resourceStrings(2020, 22).let { (a, b) ->
a.split("\n").drop(1).map { it.toInt() } to
b.split("\n").drop(1).map { it.toInt() }
}
override fun part1(): Int {
... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 2,184 | adventofcode | MIT License |
jvm_sandbox/projects/advent_of_code/src/main/kotlin/year2018/Day3.kt | jduan | 166,515,850 | false | {"Rust": 876461, "Kotlin": 257167, "Java": 139101, "Python": 114308, "Vim Script": 100117, "Shell": 96665, "C": 67784, "Starlark": 23497, "JavaScript": 20939, "HTML": 12920, "Ruby": 5087, "Thrift": 4518, "Nix": 2919, "HCL": 1069, "Lua": 926, "CSS": 826, "Assembly": 761, "Makefile": 591, "Haskell": 585, "Dockerfile": 50... | package year2018.day3
import java.io.File
data class Rectangle(
val id: Int,
val x: Int,
val y: Int,
val width: Int,
val height: Int
) {
/**
* Return a list of pairs (x, y) that are covered by this rectangle.
*/
fun coveredCells(): List<Pair<Int, Int>> {
val pairs = mutableListOf<Pai... | 58 | Rust | 1 | 0 | d5143e89ce25d761eac67e9c357620231cab303e | 1,977 | cosmos | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day18.kt | clechasseur | 568,233,589 | false | {"Kotlin": 242914} | package io.github.clechasseur.adventofcode.y2015
import io.github.clechasseur.adventofcode.util.Pt
import io.github.clechasseur.adventofcode.y2015.data.Day18Data
object Day18 {
private val input = Day18Data.input
fun part1(): Int = generateSequence(input.toGrid(false)) { it.animate() }.drop(100).first().litC... | 0 | Kotlin | 0 | 0 | e5a83093156cd7cd4afa41c93967a5181fd6ab80 | 1,736 | adventofcode2015 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LetterTilePossibilities.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,585 | kotlab | Apache License 2.0 |
Retos/Reto #3 - EL GENERADOR DE CONTRASEÑAS [Media]/kotlin/masdos.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": ... | fun main() {
/*
* Escribe un programa que sea capaz de generar contraseñas de forma aleatoria.
* Podrás configurar generar contraseñas con los siguientes parámetros:
* - Longitud: Entre 8 y 16.
* - Con o sin letras mayúsculas.
* - Con o sin números.
* - Con o sin símbolos.
* (Pudiendo combinar t... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 3,854 | retos-programacion-2023 | Apache License 2.0 |
src/main/kotlin/com/github/wakingrufus/aoc/Day3.kt | wakingrufus | 159,674,364 | false | null | package com.github.wakingrufus.aoc
import mu.KLogging
class Day3 {
companion object : KLogging()
fun findContestedArea(claims: List<String>): Int {
val claimedPlots: MutableSet<Pair<Int, Int>> = mutableSetOf()
val contestedPlots: MutableSet<Pair<Int, Int>> = mutableSetOf()
claims.map(... | 0 | Kotlin | 0 | 0 | bdf846cb0e4d53bd8beda6fdb3e07bfce59d21ea | 1,977 | advent-of-code-2018 | MIT License |
src/day04/Day04.kt | PoisonedYouth | 571,927,632 | false | {"Kotlin": 27144} | package day04
import readInput
fun main() {
fun splitToRange(input: String): IntRange {
val (start, end) = input.split("-")
return IntRange(
start = start.toInt(),
endInclusive = end.toInt()
)
}
infix fun IntRange.fullyContains(other: IntRange): Boolean {
... | 0 | Kotlin | 1 | 0 | dbcb627e693339170ba344847b610f32429f93d1 | 1,178 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/Day5.kt | ivan-gusiev | 726,608,707 | false | {"Kotlin": 34715, "Python": 2022, "Makefile": 50} | import util.AocDay
import util.AocInput
import util.AocSequence
import kotlin.math.min
typealias Day5InputType = List<List<String>>;
class Day5 : Runner {
// constant that holds the test input
val TEST_INPUT: String = """
seeds: 79 14 55 13
seed-to-soil map:
50 98 2
52... | 0 | Kotlin | 0 | 0 | 5585816b435b42b4e7c77ce9c8cabc544b2ada18 | 4,956 | advent-of-code-2023 | MIT License |
src/main/kotlin/cloud/dqn/leetcode/LRUCache.kt | aviuswen | 112,305,062 | false | null | package cloud.dqn.leetcode
/**
* Your LRUCache object will be instantiated and called as such:
* var obj = LRUCache(capacity)
* var param_1 = obj.get(key)
* obj.put(key,value)
*/
/**
* https://leetcode.com/problems/lru-cache/discuss/
Design and implement a data structure for Least Recently Used
(LRU) ca... | 0 | Kotlin | 0 | 0 | 23458b98104fa5d32efe811c3d2d4c1578b67f4b | 4,329 | cloud-dqn-leetcode | No Limit Public License |
src/Day10.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} | class Cycle {
private var cycle = 1
private var x = 1
private val signalStrengths: MutableList<Int> = ArrayList()
val art: StringBuilder = java.lang.StringBuilder()
fun run(line: String) {
if (line == "noop") {
noop()
} else if (line.startsWith("addx")) {
val... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 1,509 | 2022-advent | Apache License 2.0 |
src/main/kotlin/days/Day22.kt | andilau | 433,504,283 | false | {"Kotlin": 137815} | package days
import kotlin.math.max
import kotlin.math.min
@AdventOfCodePuzzle(
name = "Reactor Reboot",
url = "https://adventofcode.com/2021/day/22",
date = Date(day = 22, year = 2021)
)
class Day22(private val instructions: List<String>) : Puzzle {
override fun partOne() = instructions
.fi... | 0 | Kotlin | 0 | 0 | b3f06a73e7d9d207ee3051879b83e92b049a0304 | 3,343 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/g2601_2700/s2608_shortest_cycle_in_a_graph/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2601_2700.s2608_shortest_cycle_in_a_graph
// #Hard #Breadth_First_Search #Graph #2023_07_14_Time_1061_ms_(100.00%)_Space_54.9_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
class Solution {
private var min = Int.MAX_VALUE
fun findShortestCycle(n: Int, edges: Array<IntArray>): Int {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,530 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ExtraCharactersInString.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 | 5,005 | kotlab | Apache License 2.0 |
src/main/kotlin/day22/main.kt | janneri | 572,969,955 | false | {"Kotlin": 99028} | package day22
import day22.Direction.*
import day22.Grid.TileType.*
import util.readTestInput
import java.lang.IllegalArgumentException
private enum class Direction(val dx: Int, val dy: Int, val symbol: Char, val facingPoints: Int) {
UP( 0, -1, '^', 3) {
override fun turnLeft() = LEFT
override fun... | 0 | Kotlin | 0 | 0 | 1de6781b4d48852f4a6c44943cc25f9c864a4906 | 6,118 | advent-of-code-2022 | MIT License |
src/Day01.kt | befrvnk | 574,229,637 | false | {"Kotlin": 15788} | fun List<String>.elves(): List<Int> {
val elf = mutableListOf<Int>()
val elves = mutableListOf<List<Int>>()
forEach { line ->
if (line == "") {
elves.add(elf.toList())
elf.clear()
} else {
elf.add(line.toInt())
}
}
elves.add(elf.toList())
... | 0 | Kotlin | 0 | 0 | 68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7 | 845 | aoc-2022-kotlin | Apache License 2.0 |
src/day10/Day10.kt | Puju2496 | 576,611,911 | false | {"Kotlin": 46156} | package day10
import println
import readInput
import java.util.*
import kotlin.math.abs
import kotlin.collections.MutableList
fun main() {
// test if implementation meets criteria from the description, like:
val input = readInput("src/day10", "Day10")
println("Part1")
part1(input)
println("Part2")... | 0 | Kotlin | 0 | 0 | e04f89c67f6170441651a1fe2bd1f2448a2cf64e | 2,481 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/it/prima/pairProgramming/ui/exercise/FrizzBuzz.kt | tonyno92 | 565,214,953 | false | {"Kotlin": 27416} | package it.prima.pairProgramming.ui.exercise
import it.prima.pairProgramming.ext.digit
class FrizzBuzz {
/**
* WHAT IS FIZZBUZZ?
*
* FizzBuzz is a common coding task given during interviews that tasks candidates to write
* a solution that prints integers one-to-N, labeling any integers divisi... | 0 | Kotlin | 0 | 0 | b036cb800c5256e0276f457f4d022907d79affb2 | 2,728 | KotlinAlgorithmsAndAdt | Apache License 2.0 |
src/main/kotlin/com/sk/set1/135. Candy.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set1
class Solution135 {
fun candy(ratings: IntArray): Int {
val candies = IntArray(ratings.size) { 1 }
for (i in 1..ratings.lastIndex) {
if (ratings[i] > ratings[i - 1]) {
candies[i] = candies[i - 1] + 1
}
}
println(candies.toL... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 1,244 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/day12/part2/main.kt | TheMrMilchmann | 225,375,010 | false | null | /*
* Copyright (c) 2019 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, dis... | 0 | Kotlin | 0 | 1 | 9d6e2adbb25a057bffc993dfaedabefcdd52e168 | 3,474 | AdventOfCode2019 | MIT License |
src/Day06.kt | BrianEstrada | 572,700,177 | false | {"Kotlin": 22757} | fun main() {
// Test Case
val testInput = readInput("Day06_test")
println("Part 1 Test")
Day06.part1(testInput)
println("Part 2 Test")
Day06.part2(testInput)
// Actual Case
val input = readInput("Day06")
println("Part 1")
Day06.part1(input)
println("Part 2")
Day06.part2... | 1 | Kotlin | 0 | 1 | 032a4693aff514c9b30e979e63560dc48917411d | 1,250 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2017/Day25.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2017
import se.saidaspen.aoc.util.Day
import se.saidaspen.aoc.util.ints
fun main() = Day25.run()
data class Rule(val value: Int, val move: String, val nextState: String)
object Day25 : Day(2017, 25) {
override fun part1(): Int {
val parts = input.split("\n\n")
var st... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,602 | adventofkotlin | MIT License |
y2018/src/main/kotlin/adventofcode/y2018/Day09.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2018
import adventofcode.io.AdventSolution
import java.util.*
object Day09 : AdventSolution(2018, 9, "<NAME>") {
override fun solvePartOne(input: String) = parse(input).let { (p, m) -> game(p, m) }
override fun solvePartTwo(input: String) = parse(input).let { (p, m) -> game(p, m * 100)... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,340 | advent-of-code | MIT License |
kotlin/src/com/s13g/aoc/aoc2021/Day18.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2021
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import kotlin.math.max
/**
* --- Day 18: Snailfish ---
* https://adventofcode.com/2021/day/18
*/
class Day18 : Solver {
override fun solve(lines: List<String>): Result {
val input = lines.map { parseNum(it) }
var result =... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 5,519 | euler | Apache License 2.0 |
source/math/src/main/kotlin/de/webis/webisstud/thesis/reimer/math/PostCorrelationUtil.kt | webis-de | 261,803,727 | false | {"Kotlin": 235840, "Jupyter Notebook": 43040, "Java": 7525} | package de.webis.webisstud.thesis.reimer.math
import org.apache.commons.math3.stat.correlation.KendallsCorrelation
import org.apache.commons.math3.util.Precision.equals
private val kendalls = KendallsCorrelation()
internal fun <T : Comparable<T>> List<T>.intersectionKendallTauCorrelation(other: List<T>): Double {
... | 0 | Kotlin | 2 | 2 | 0935389fc7b1d377b203ed7fc4d2a019dcf9d65e | 1,740 | sigir20-sampling-bias-due-to-near-duplicates-in-learning-to-rank | MIT License |
src/main/kotlin/day7/FileSystem.kt | errob37 | 573,508,650 | false | {"Kotlin": 18301} | package day7
class FileSystem(private val totalSize: Long?) {
private val root: Directory = Directory("/")
fun getRootDirectory() = root
override fun toString() = "FileSystem(root=$root)"
fun sumOfSizeForDirectoriesBelow(size: Long): Long {
return getSubdirectoriesRecursive(root)
... | 0 | Kotlin | 0 | 0 | 7e84babb58eabbdb636f8cca87fdcf4314fb2af0 | 2,015 | adventofcode-2022 | Apache License 2.0 |
src/Day04.kt | frango9000 | 573,098,370 | false | {"Kotlin": 73317} | fun main() {
val input = readInput("Day04")
println(Day04.part1(input))
println(Day04.part2(input))
}
class Day04 {
companion object {
fun part1(input: List<String>): Int {
return input.filter { it: String ->
val (a1, a2, b1, b2) = it.split(",")
.... | 0 | Kotlin | 0 | 0 | 62e91dd429554853564484d93575b607a2d137a3 | 773 | advent-of-code-22 | Apache License 2.0 |
src/Day01.kt | Akhunzaada | 573,119,655 | false | {"Kotlin": 23755} | fun main() {
fun part1(input: List<String>): Int {
return input.split { it.isEmpty() }
.maxOf { it.sumOf { calories -> calories.toInt() } }
}
fun part2(input: List<String>): Int {
return input.split { it.isEmpty() }
.map { it.sumOf { calories -> calories.toInt() } }
... | 0 | Kotlin | 0 | 0 | b2754454080989d9579ab39782fd1d18552394f0 | 680 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2019/src/test/java/Day12TheNBodyProblem.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import kotlin.math.absoluteValue
class Day12TheNBodyProblem {
data class Vector(val x: Int, val y: Int, val z: Int) {
operator fun plus(vel: Vector): Vector {
return Vector(x + vel.x, y + vel.y, z + vel.z)
}
}
... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 7,538 | advent-of-code | MIT License |
src/Day03.kt | avarun42 | 573,407,145 | false | {"Kotlin": 8697} | import day03.Item
import day03.Rucksack
import day03.sharedItem
fun main() {
fun List<String>.toRucksacks(): Sequence<Rucksack> {
return this.asSequence()
.map { rucksackItems -> rucksackItems.map { Item.fromChar(it) } }
.map { Rucksack(it) }
}
fun part1(input: List<String>... | 0 | Kotlin | 0 | 1 | 622d022b7556dd0b2b3e3fb2abdda1c854bfe3a3 | 821 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/adventofcode/Day01.kt | keeferrourke | 434,321,094 | false | {"Kotlin": 15727, "Shell": 1301} | package com.adventofcode
/**
* [https://adventofcode.com/2021/day/1]
*/
fun sonarSweep(readings: Sequence<Int>, window: Int = 1): Int = readings
.windowed(window)
.map { it.sum() }
.fold(listOf<Pair<Int, DepthChange>>()) { acc, windowedSum ->
acc + (acc.lastOrNull()?.let { windowedSum to DepthChange.of(it.... | 0 | Kotlin | 0 | 0 | 44677c6ae0ba1a8a8dc80dfa68c17b9c315af8e2 | 912 | aoc2021 | ISC License |
examples/src/main/kotlin/EightQueens.kt | alexbaryzhikov | 201,620,351 | false | null | import com.alexb.constraints.Problem
import kotlin.math.abs
import kotlin.system.measureTimeMillis
/*
The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard
so that no two queens threaten each other; thus, a solution requires that no two queens
share the same row, column, or diagonal... | 0 | Kotlin | 0 | 0 | e67ae6b6be3e0012d0d03988afa22236fd62f122 | 1,232 | kotlin-constraints | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2022/Day3.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2022
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.report
class Day3: AdventDay(2022, 3) {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val day = Day3()
report {
day.part1()
}
... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 1,524 | adventofcode | MIT License |
src/main/kotlin/adventofcode2017/Day25TheHaltingProblem.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2017
class Day25TheHaltingProblem
data class StateResult(val writeValue: Int, val nextDirection: Int, val nextState: TuringState)
data class StateRule(val ruleOnNull: StateResult, val ruleOnOne: StateResult)
sealed class TuringState {
object A : TuringState()
object B : TuringState()
... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 2,746 | kotlin-coding-challenges | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/PowOfFour.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,837 | kotlab | Apache License 2.0 |
src/main/kotlin/days/Day12.kt | TheMrMilchmann | 725,205,189 | false | {"Kotlin": 61669} | /*
* Copyright (c) 2023 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, dis... | 0 | Kotlin | 0 | 1 | f94ff8a4c9fefb71e3ea183dbc3a1d41e6503152 | 3,226 | AdventOfCode2023 | MIT License |
src/main/aoc2021/Day17.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2021
import Pos
import kotlin.math.max
class Day17(input: List<String>) {
private val targetX: IntRange
private val targetY: IntRange
init {
val (x1, x2, y1, y2) = """target area: x=(\d+)..(\d+), y=-(\d+)..-(\d+)"""
.toRegex()
.find(input.single())!!
... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,877 | aoc | MIT License |
2022/Day04/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import kotlin.text.*
data class Segment(val from: Int, val to: Int) {}
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
val regex = Regex("""(\d+)-(\d+),(\d+)-(\d+)""")
val segments =
lines.map { regex.matchEntire(it)!!.destructured }.map { (s1from, s1t... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 1,129 | AdventOfCode | MIT License |
src/main/kotlin/com/kishor/kotlin/algo/problems/arrayandstrings/LongestBalancedSubstring.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.problems.arrayandstrings
import java.util.*
import kotlin.math.max
class LongestBalancedSubstring {
// O(n^3)
fun longestBalancedSubstringNaive(string: String): Int {
var maxLength = 0
for (i in 0 until string.length) {
for (j in i + 2 until string.l... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 3,094 | DS_Algo_Kotlin | MIT License |
src/Day04.kt | DiamondMiner88 | 573,073,199 | false | {"Kotlin": 26457, "Rust": 4093, "Shell": 188} | fun main() {
d4part1()
d4part2()
}
fun d4part1() {
val input = readInput("input/day04.txt")
.split("\n")
.filter { it.isNotBlank() }
.map { it.split(",").map { val range = it.split("-"); (range[0].toInt()..range[1].toInt()) } }
var total = 0
for ((elf1, elf2) in input) {
... | 0 | Kotlin | 0 | 0 | 55bb96af323cab3860ab6988f7d57d04f034c12c | 1,115 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/de/niemeyer/aoc2022/Day23.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | /**
* Advent of Code 2022, Day 23: Unstable Diffusion
* Problem Description: https://adventofcode.com/2022/day/23
*/
package de.niemeyer.aoc2022
import de.niemeyer.aoc.direction.CompassDirectionCCS
import de.niemeyer.aoc.points.*
import de.niemeyer.aoc.utils.Resources.resourceAsList
import de.niemeyer.aoc.utils.ge... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 2,845 | AoC-2022 | Apache License 2.0 |
src/main/kotlin/icfp2019/analyzers/ConservativeDistanceAnalyzer.kt | teemobean | 193,117,049 | true | {"JavaScript": 797310, "Kotlin": 129405, "CSS": 9434, "HTML": 5859, "Shell": 70} | package icfp2019.analyzers
import icfp2019.core.Analyzer
import icfp2019.core.DistanceEstimate
import icfp2019.model.*
import org.jgrapht.Graph
import org.jgrapht.alg.connectivity.ConnectivityInspector
import org.jgrapht.alg.spanning.PrimMinimumSpanningTree
import org.jgrapht.graph.AsSubgraph
import org.jgrapht.graph.... | 13 | JavaScript | 12 | 0 | a1060c109dfaa244f3451f11812ba8228d192e7d | 2,558 | icfp-2019 | The Unlicense |
src/main/aoc2023/Day01.kt | Clausr | 575,584,811 | false | {"Kotlin": 65961} | package aoc2023
class Day01(val input: List<String>) {
fun solvePart1(): Int {
val sum = input.sumOf {
addFirstAndLastDigit(it)
}
return sum
}
private fun addFirstAndLastDigit(line: String): Int {
val first = line.first { it.isDigit() }
val last = line.l... | 1 | Kotlin | 0 | 0 | dd33c886c4a9b93a00b5724f7ce126901c5fb3ea | 1,237 | advent_of_code | Apache License 2.0 |
src/Day14.kt | dmarcato | 576,511,169 | false | {"Kotlin": 36664} | import kotlin.math.max
import kotlin.math.min
data class CavePos(val x: Int, val y: Int)
enum class CaveMaterial { ROCK, SAND }
fun CaveMaterial?.symbol() = when (this) {
CaveMaterial.ROCK -> "#"
CaveMaterial.SAND -> "o"
else -> "."
}
class Cave {
private val grid = mutableMapOf<CavePos, CaveMateria... | 0 | Kotlin | 0 | 0 | 6abd8ca89a1acce49ecc0ca8a51acd3969979464 | 3,954 | aoc2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.