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/g2801_2900/s2866_beautiful_towers_ii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2801_2900.s2866_beautiful_towers_ii
// #Medium #Array #Stack #Monotonic_Stack #2023_12_21_Time_676_ms_(85.71%)_Space_70.9_MB_(71.43%)
import java.util.Deque
import java.util.LinkedList
import kotlin.math.max
class Solution {
fun maximumSumOfHeights(mH: List<Int>): Long {
val n = mH.size
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,037 | LeetCode-in-Kotlin | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day255/day255.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day255
// day255.kt
// By <NAME>, 2020.
typealias Vertex = Int
typealias AdjacencyList = Set<Vertex>
typealias AdjacencyGraph = Map<Vertex, AdjacencyList>
typealias AdjacencyMatrix = List<List<Vertex>>
/**
* Convert an adjacency graph into an adjacency matrix.
*/
fun adjacencyGraphToMatrix(adjacencyGrap... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 1,696 | daily-coding-problem | MIT License |
src/main/kotlin/com/groundsfam/advent/y2022/d04/Day04.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2022.d04
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
fun redundantPair(pair: List<Int>): Boolean =
(pair[0] <= pair[2] && pair[1] >= pair[3]) || (pair[2] <= pair[0] && pair[3] >= pair[1])
fun ov... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 990 | advent-of-code | MIT License |
src/main/java/com/carson/commands/Chain.kt | Mee42 | 152,824,065 | false | null | package com.carson.commands
import com.carson.core.Main
import java.lang.StringBuilder
import java.util.*
class Chain{
private val map :MutableMap<String,MutableList<String>> = mutableMapOf()
/** feeds another message into the chain */
fun feed(input: String) {
if(input.startsWith("!"))return
... | 0 | Kotlin | 0 | 0 | f68dcf2091edf6429b70c89fa537eef526d83939 | 3,147 | community-bot | The Unlicense |
src/Day03.kt | mvmlisb | 572,859,923 | false | {"Kotlin": 14994} | private val Priorities = (('a'.code..'z'.code) + ('A'.code..'Z'.code))
.mapIndexed { charIndex, charCode -> charCode to charIndex + 1 }.toMap()
private fun findCommonChar(strings: List<String>) =
strings.first().first { char -> strings.drop(1).all { string -> string.contains(char) } }
fun main() {
val inp... | 0 | Kotlin | 0 | 0 | 648d594ec0d3b2e41a435b4473b6e6eb26e81833 | 596 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/g1401_1500/s1494_parallel_courses_ii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1401_1500.s1494_parallel_courses_ii
// #Hard #Dynamic_Programming #Bit_Manipulation #Graph #Bitmask
// #2023_06_13_Time_381_ms_(100.00%)_Space_37_MB_(100.00%)
class Solution {
fun minNumberOfSemesters(n: Int, relations: Array<IntArray>, k: Int): Int {
val pres = IntArray(n)
for (r in rela... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,349 | LeetCode-in-Kotlin | MIT License |
2022/src/main/kotlin/sh/weller/aoc/Day04.kt | Guruth | 328,467,380 | false | {"Kotlin": 188298, "Rust": 13289, "Elixir": 1833} | package sh.weller.aoc
object Day04 : SomeDay<String, Int> {
override fun partOne(input: List<String>): Int =
input
.map { inputString ->
val sections = inputString.split(",")
val firstValues = sections.first().split("-").map { it.toInt() }
val sec... | 0 | Kotlin | 0 | 0 | 69ac07025ce520cdf285b0faa5131ee5962bd69b | 1,463 | AdventOfCode | MIT License |
src/Day04.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
fun part1(input: List<String>): Int {
var num = 0
for (i in input) {
var parts = i.split(",", "-").map{it.toInt()}.toTypedArray()
if ((parts[0] <= parts[2]) && (parts[1] >= parts[3])) {
num++
} else if ((parts[2] <= parts[0]) && (parts... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 812 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/ru/byprogminer/compmath/lab4/math/LagrangeMethod.kt | ProgMiner | 242,443,008 | false | null | package ru.byprogminer.compmath.lab4.math
import ru.byprogminer.compmath.lab4.expression.Expression
import ru.byprogminer.compmath.lab4.expression.InvalidExpression
import ru.byprogminer.compmath.lab5.util.toPlainString
object LagrangeMethod: InterpolationMethod {
override fun interpolate(expression: Expression,... | 0 | Kotlin | 0 | 1 | 201b562e7e07961c695ed4d09ad0b381281f6d10 | 2,366 | Lab_CompMath | MIT License |
advent10/src/main/kotlin/Main.kt | thastreet | 574,294,123 | false | {"Kotlin": 29380} | import java.io.File
import java.lang.IllegalArgumentException
import java.util.Stack
sealed interface Instruction {
val cycles: Int
}
object Noop : Instruction {
override val cycles = 1
}
data class Add(val value: Int) : Instruction {
override val cycles = 2
}
fun main(args: Array<String>) {
val lin... | 0 | Kotlin | 0 | 0 | e296de7db91dba0b44453601fa2b1696af9dbb15 | 2,585 | advent-of-code-2022 | Apache License 2.0 |
src/test/kotlin/ch/ranil/aoc/aoc2023/Day13.kt | stravag | 572,872,641 | false | {"Kotlin": 234222} | package ch.ranil.aoc.aoc2023
import ch.ranil.aoc.AbstractDay
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
class Day13 : AbstractDay() {
@Test
fun part1Test() {
assertEquals(405, compute1(testInput))
}
@Test
fun part1Test2() {
assertEquals(
1400,
... | 0 | Kotlin | 1 | 0 | dbd25877071cbb015f8da161afb30cf1968249a8 | 3,425 | aoc | Apache License 2.0 |
src/Day02.kt | monsterbrain | 572,819,542 | false | {"Kotlin": 42040} | enum class SHAPE(val score: Int, val oppCode: Char, val ourCode:Char) {
ROCK(1, 'A', 'X'),
PAPER(2, 'B', 'Y'),
SCISSORS(3, 'C', 'Z');
companion object {
fun getOppShape(code: Char): SHAPE {
return when (code) {
ROCK.oppCode -> ROCK
PAPER.oppCode -> PA... | 0 | Kotlin | 0 | 0 | 3a1e8615453dd54ca7c4312417afaa45379ecf6b | 3,418 | advent-of-code-kotlin-2022-Solutions | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2021/day25/Seafloor.kt | michaelbull | 433,565,311 | false | {"Kotlin": 162839} | package com.github.michaelbull.advent2021.day25
import com.github.michaelbull.advent2021.math.Vector2
fun Sequence<String>.toSeafloor(): Seafloor {
val cells = buildMap {
for ((y, line) in this@toSeafloor.withIndex()) {
for ((x, char) in line.withIndex()) {
this[Vector2(x, y)] ... | 0 | Kotlin | 0 | 4 | 7cec2ac03705da007f227306ceb0e87f302e2e54 | 1,824 | advent-2021 | ISC License |
day03/Kotlin/day03.kt | Ad0lphus | 353,610,043 | false | {"C++": 195638, "Python": 139359, "Kotlin": 80248} | import java.io.*
fun print_day_3() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 3" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Binary Diagnostic -c -f small")... | 0 | C++ | 0 | 0 | 02f219ea278d85c7799d739294c664aa5a47719a | 2,138 | AOC2021 | Apache License 2.0 |
src/main/kotlin/g1001_1100/s1012_numbers_with_repeated_digits/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1001_1100.s1012_numbers_with_repeated_digits
// #Hard #Dynamic_Programming #Math #2023_05_16_Time_123_ms_(100.00%)_Space_34_MB_(33.33%)
import kotlin.math.pow
class Solution {
private var noRepeatCount = 0
fun numDupDigitsAtMostN(n: Int): Int {
val nStrLength = n.toString().length
va... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 3,030 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/ikueb/advent18/Day15.kt | h-j-k | 159,901,179 | false | null | package com.ikueb.advent18
import com.ikueb.advent18.model.*
import java.util.*
object Day15 {
fun getBattleOutcome(input: List<String>) = battle(input)
fun getModifiedBattleOutcome(input: List<String>) = generateSequence(4) { it + 1 }
.map { elfPowerUp ->
battle(input, elfPowerU... | 0 | Kotlin | 0 | 0 | f1d5c58777968e37e81e61a8ed972dc24b30ac76 | 4,419 | advent18 | Apache License 2.0 |
app/src/main/java/com/canerkorkmaz/cicek/jobdistribution/solver/IPSolver.kt | nberktumer | 173,110,988 | false | {"Kotlin": 47340} | package com.canerkorkmaz.cicek.jobdistribution.solver
import com.canerkorkmaz.cicek.jobdistribution.model.InputDataFormatted
import com.canerkorkmaz.cicek.jobdistribution.model.JobData
import com.canerkorkmaz.cicek.jobdistribution.model.Solution
import com.canerkorkmaz.cicek.jobdistribution.model.SolutionPack
import c... | 0 | Kotlin | 0 | 0 | bd3356d1dcd0da1fa4a4ed5967205ea488724d3a | 2,670 | CicekSepeti-Hackathon | Apache License 2.0 |
Kotlin for Java Developers. Week 3/Taxi Park/Task/src/taxipark/TaxiParkTask.kt | tinglu | 248,072,283 | false | null | package taxipark
/*
* Task #1. Find all the drivers who performed no trips.
*/
fun TaxiPark.findFakeDrivers(): Set<Driver> =
allDrivers.subtract(trips.map { it.driver })
fun TaxiPark.findFakeDrivers2(): Set<Driver> =
allDrivers.minus(trips.map { it.driver })
fun TaxiPark.findFakeDrivers3(): Set<Driver> =
... | 0 | Kotlin | 0 | 0 | 7a2e9034e6e51c6ffb619a525c1b1c932b265b0c | 6,109 | learn-kotlin | BSD with attribution |
src/day_04/Day04.kt | BrumelisMartins | 572,847,918 | false | {"Kotlin": 32376} | package day_04
import readInput
fun main() {
fun doAllTasksOverlap(group: Group): Boolean {
val intersectedList = group.firstAssignmentList.intersect(group.secondAssignmentList.toSet())
val containsInFirstList = intersectedList.containsAll(group.firstAssignmentList)
val containsInSecondLis... | 0 | Kotlin | 0 | 0 | 3391b6df8f61d72272f07b89819c5b1c21d7806f | 1,268 | aoc-2022 | Apache License 2.0 |
Lah_numbers/Kotlin/src/LahNumbers.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 java.math.BigInteger
fun factorial(n: BigInteger): BigInteger {
if (n == BigInteger.ZERO) return BigInteger.ONE
if (n == BigInteger.ONE) return BigInteger.ONE
var prod = BigInteger.ONE
var num = n
while (num > BigInteger.ONE) {
prod *= num
num--
}
return prod
}
fun l... | 0 | D | 0 | 4 | c2a9f154a5ae77eea2b34bbe5e0cc2248333e421 | 1,258 | rosetta | MIT License |
src/Day05.kt | vitind | 578,020,578 | false | {"Kotlin": 60987} |
fun main() {
fun getOriginalCrateStack(): Array<ArrayList<Char>> {
return arrayOf(
arrayListOf('G', 'T', 'R', 'W'), // 1
arrayListOf('G', 'C', 'H', 'P', 'M', 'S', 'V', 'W'), // 2
arrayListOf('C', 'L', 'T', 'S', 'G', 'M'), // 3
... | 0 | Kotlin | 0 | 0 | 2698c65af0acd1fce51525737ab50f225d6502d1 | 2,368 | aoc2022 | Apache License 2.0 |
src/Day01.kt | wlghdu97 | 573,333,153 | false | {"Kotlin": 50633} | fun main() {
fun part1(input: List<String>): Int {
var max = 0
var inc = 0
input.forEach {
if (it.isBlank()) {
if (inc > max) {
max = inc
}
inc = 0
} else {
inc += it.toInt()
... | 0 | Kotlin | 0 | 0 | 2b95aaaa9075986fa5023d1bf0331db23cf2822b | 1,421 | aoc-2022 | Apache License 2.0 |
src/year2022/day22/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day22
import arrow.core.Either
import arrow.core.left
import arrow.core.right
import arrow.optics.optics
import io.kotest.matchers.shouldBe
import utils.Direction
import utils.Point
import utils.cyclical
import utils.readInput
import utils.y
fun main() {
val (testMaze, testRoute) = readInput("22"... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 9,390 | Advent-of-Code | Apache License 2.0 |
Coding Challenges/Advent of Code/2021/Day 7/part2.kt | Alphabeater | 435,048,407 | false | {"Kotlin": 69566, "Python": 5974} | import java.io.File
import java.util.Scanner
import kotlin.math.abs
var crabPositions = listOf<Int>()
var minVal = 0
var maxVal = 0
var value = -1 //used to return the last value of the recursive function.
fun getMinFuel(minPos: Int, maxPos: Int): Int {
val midPos = (maxPos + minPos) / 2
if (getFuel(minPos +... | 0 | Kotlin | 0 | 0 | 05c8d4614e025ed2f26fef2e5b1581630201adf0 | 1,193 | Archive | MIT License |
src/main/kotlin/dayEleven/DayEleven.kt | janreppien | 573,041,132 | false | {"Kotlin": 26432} | package dayEleven
import AocSolution
class DayEleven : AocSolution(11) {
override fun solvePartOne(): String {
val monkeys = createRealMonkeys()
for (i in 0 until 20) {
for (monkey in monkeys) {
monkey.items.map { monkey.operation(it) / 3 }.forEach {
... | 0 | Kotlin | 0 | 0 | b53f6c253966536a3edc8897d1420a5ceed59aa9 | 2,925 | aoc2022 | MIT License |
atcoder/arc128/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package atcoder.arc128
fun main() {
readLn()
val a = readInts()
val cumSum = mutableListOf(0.toModular())
fun sum(from: Int, to: Int) = cumSum[maxOf(to, from)] - cumSum[from]
var same = 0
var diff = 0
var ans = 1.toModular()
for (i in a.indices) {
if (i < 2 || a[i] != a[i - 2]) diff = i
if (i < 1 || a[i] =... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,554 | competitions | The Unlicense |
src/Day05.kt | YunxiangHuang | 572,333,905 | false | {"Kotlin": 20157} | import java.util.Scanner
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
fun main() {
val input = readInput("Day05")
var matrix = HashMap<Int, ArrayList<Char>>(10)
var rawMatrix = ArrayList<ArrayList<Char>>(10)
// parse
var actionBegin = 0
for ((i, line) in input.withInde... | 0 | Kotlin | 0 | 0 | f62cc39dd4881f4fcf3d7493f23d4d65a7eb6d66 | 2,001 | AoC_2022 | Apache License 2.0 |
src/main/kotlin/leetcode/Problem1914.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
/**
* https://leetcode.com/problems/cyclically-rotating-a-grid/
*/
class Problem1914 {
fun rotateGrid(grid: Array<IntArray>, k: Int): Array<IntArray> {
val maxRows: Int = grid.size
val maxCols: Int = if (grid.isNotEmpty()) grid[0].size else 0
var row = 0
var col =... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 2,048 | leetcode | MIT License |
src/Day12.kt | underwindfall | 573,471,357 | false | {"Kotlin": 42718} | fun main() {
val dayId = "12"
val a = readInput("Day${dayId}").map { it.toCharArray() }
val n = a.size
val m = a[0].size
data class P(val i: Int, val j: Int)
var e: P? = null
var s: P? = null
for (i in 0 until n) for (j in 0 until m) {
when (a[i][j]) {
'E' -> e = P(i,... | 0 | Kotlin | 0 | 0 | 0e7caf00319ce99c6772add017c6dd3c933b96f0 | 1,368 | aoc-2022 | Apache License 2.0 |
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day17Test.kt | dirkgroot | 317,968,017 | false | {"Kotlin": 187862} | package nl.dirkgroot.adventofcode.year2022
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import nl.dirkgroot.adventofcode.util.input
import nl.dirkgroot.adventofcode.util.invokedWith
import java.lang.Integer.max
private fun solution1(input: String) = Tower(input.toJetPattern()).simula... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 5,662 | adventofcode-kotlin | MIT License |
src/main/kotlin/com/nibado/projects/advent/y2021/Day09.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2021
import com.nibado.projects.advent.*
object Day09 : Day {
private val values = resourceLines(2021, 9).map { it.toCharArray().map { it.digitToInt() } }
private val points = values.indices.flatMap { y -> values[0].indices.map { x -> Point(x, y) } }
override fun part1... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,202 | adventofcode | MIT License |
src/Day02.kt | zfz7 | 573,100,794 | false | {"Kotlin": 53499} | fun main() {
println(day2A(readFile("Day02")))
println(day2B(readFile("Day02")))
}
fun day2A(input: String): Int = input.trim().split("\n").sumOf { playedValue(it[2]) + winner(it[0], it[2]) }
fun day2B(input: String): Int = input.trim().split("\n").sumOf { outcome(it[2]) + playedValue(it[0], it[2]) }
fun play... | 0 | Kotlin | 0 | 0 | c50a12b52127eba3f5706de775a350b1568127ae | 1,233 | AdventOfCode22 | Apache License 2.0 |
src/Day04.kt | rromanowski-figure | 573,003,468 | false | {"Kotlin": 35951} | object Day04 : Runner<Int, Int>(4, 2, 4) {
override fun part1(input: List<String>): Int {
return input.count {
val ranges = it.split(",")
val section1 = ranges[0].toSection()
val section2 = ranges[1].toSection()
(section1.first >= section2.first && section1.l... | 0 | Kotlin | 0 | 0 | 6ca5f70872f1185429c04dcb8bc3f3651e3c2a84 | 875 | advent-of-code-2022-kotlin | Apache License 2.0 |
alchemist/alchemist-cognitive-agents/src/main/kotlin/it/unibo/alchemist/model/implementations/actions/steeringstrategies/Weighted.kt | cric96 | 390,057,153 | true | {"Java": 1915234, "Kotlin": 1101587, "Scala": 43027, "HTML": 6547, "ANTLR": 4034, "CSS": 1075, "JavaScript": 998} | package it.unibo.alchemist.model.implementations.actions.steeringstrategies
import it.unibo.alchemist.model.implementations.positions.Euclidean2DPosition
import it.unibo.alchemist.model.interfaces.GroupSteeringAction
import it.unibo.alchemist.model.interfaces.Node
import it.unibo.alchemist.model.interfaces.SteeringAct... | 0 | Java | 0 | 0 | cbc75fbf8ac1b11ab0ef658f3ee1537ae39764fa | 2,790 | Alchemist | Creative Commons Attribution 3.0 Unported |
src/main/kotlin/day1.kt | sviams | 726,160,356 | false | {"Kotlin": 9233} | object day1 {
val digitMap = mapOf(
"one" to "1",
"two" to "2",
"three" to "3",
"four" to "4",
"five" to "5",
"six" to "6",
"seven" to "7",
"eight" to "8",
"nine" to "9"
)
fun firstAndLast(input: String): String {
val onlyDigi... | 0 | Kotlin | 0 | 0 | 4914a54b21e8aac77ce7bbea3abc88ac04037d50 | 1,059 | aoc23 | Apache License 2.0 |
advent/src/test/kotlin/org/elwaxoro/advent/y2015/Dec06.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2015
import org.elwaxoro.advent.Coord
import org.elwaxoro.advent.PuzzleDayTester
import kotlin.math.max
/**
* https://adventofcode.com/2015/day/6
* Part 1: 569999
* Part 2: 17836115
*/
class Dec06 : PuzzleDayTester(6, 2015) {
override fun part1(): Any = doTheThing(::cmdPuzzle1)
... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 1,633 | advent-of-code | MIT License |
src/days/day14/Day14.kt | Riven-Spell | 113,698,657 | false | {"Kotlin": 25729} | package days.day14
import days.day10.binaryKnotHash
import days.day3.plus
fun day14p1(s: String): String = (0..127).map { "$s-$it" }.map { binaryKnotHash(it).toCharArray() }.map { it.filter { it == '1' }.size }.sum().toString()
fun day14p2(s: String): String {
(0..127).map { "$s-$it" }.map { binaryKnotHash(it).t... | 0 | Kotlin | 0 | 1 | dbbdb390a0addee98c7876647106af208c3d9bc7 | 1,001 | Kotlin-AdventOfCode-2017 | MIT License |
src/main/kotlin/Day16.kt | cbrentharris | 712,962,396 | false | {"Kotlin": 171464} | import kotlin.String
import kotlin.collections.List
public object Day16 {
enum class Direction {
UP,
DOWN,
LEFT,
RIGHT
}
public fun part1(input: List<String>): String {
val startCoordinate = Day10.Coordinate(0, 0)
val startDirection = Direction.RIGHT
... | 0 | Kotlin | 0 | 1 | f689f8bbbf1a63fecf66e5e03b382becac5d0025 | 6,354 | kotlin-kringle | Apache License 2.0 |
src/Day01.kt | fouksf | 572,530,146 | false | {"Kotlin": 43124} | fun main() {
fun readCalories(input: List<String>): List<Int> {
val calories = ArrayList<Int>()
var current = 0
for (cal in input) {
if (cal.isBlank()) {
calories.add(current)
current = 0
} else {
current += cal.toInt()... | 0 | Kotlin | 0 | 0 | 701bae4d350353e2c49845adcd5087f8f5409307 | 984 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | m0r0 | 576,999,741 | false | null | import kotlin.properties.Delegates
fun main() {
fun part1(input: List<String>): Int {
return input.map { Rucksack(it) }.sumOf { it.calculatePriorityOfSharedItem() }
}
fun part2(input: List<String>): Int {
val rucksacks = mutableListOf<String>()
val rucksackGroups = mutableListOf<Ru... | 0 | Kotlin | 0 | 0 | b6f3c5229ad758f61f219040f8db61f654d7fc00 | 2,247 | kotlin-AoC-2022 | Apache License 2.0 |
ceria/11/src/main/kotlin/Solution.kt | VisionistInc | 317,503,410 | false | null | import java.io.File;
import java.util.LinkedList;
val floor = '.'
val seat = 'L'
val occupied = '#'
fun main(args : Array<String>) {
val input = File(args.first()).readLines()
println("Solution 1: ${solution1(input)}")
println("Solution 2: ${solution2(input)}")
}
private fun solution1(input :List<String>... | 0 | Rust | 0 | 0 | 002734670384aa02ca122086035f45dfb2ea9949 | 6,842 | advent-of-code-2020 | MIT License |
src/AoC17.kt | Pi143 | 317,631,443 | false | null | import java.io.File
fun main() {
println("Starting Day 17 A Test 1")
calculateDay17PartA("Input/2020_Day17_A_Test1")
println("Starting Day 17 A Real")
calculateDay17PartA("Input/2020_Day17_A")
println("Starting Day 17 B Test 1")
calculateDay17PartB("Input/2020_Day17_A_Test1")
println("Sta... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 5,734 | AdventOfCode2020 | MIT License |
Rat Maze Problem/RatMaze.kt | ReciHub | 150,083,876 | false | {"C++": 2125921, "Java": 329701, "Python": 261837, "C#": 119510, "C": 86966, "JavaScript": 69795, "Jupyter Notebook": 48962, "HTML": 35203, "Kotlin": 20787, "Go": 15812, "CSS": 12510, "TeX": 12253, "TypeScript": 10773, "PHP": 8809, "Swift": 7787, "Scala": 6724, "Rust": 6297, "Shell": 5562, "Ruby": 5488, "Haskell": 4927... | /**
* @created October 2, 2019
* Kotlin Program that solves Rat in a maze problem using backtracking.
*/
class RatMaze {
// Size of the maze.
private var n: Int = 0 // Just in case. Primitive types cannot be lateinit.
private lateinit var solution: Array<IntArray>
private lateinit var maze: Array<In... | 121 | C++ | 750 | 361 | 24518dd47bd998548e3e840c27968598396d30ee | 3,279 | FunnyAlgorithms | Creative Commons Zero v1.0 Universal |
src/main/kotlin/net/danlew/wordle/wordleLogic.kt | dlew | 446,149,485 | false | {"Kotlin": 14254} | package net.danlew.wordle
fun filterValidHardModeGuesses(wordList: List<String>, lastGuess: GuessResult): List<String> {
return wordList.filter { guess -> validHardModeGuess(guess, lastGuess) }
}
fun validHardModeGuess(guess: String, lastGuess: GuessResult): Boolean {
require(guess.length == lastGuess.guess.lengt... | 0 | Kotlin | 1 | 12 | 73f46bf70178ab9aba6cdb6c2d7aadadf6ef7fa0 | 1,827 | wordle-solver | MIT License |
src/main/kotlin/kr/co/programmers/P1138.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
import kotlin.math.abs
// https://leetcode.com/problems/alphabet-board-path/
class P1138 {
fun alphabetBoardPath(target: String): String {
var moves = ""
var p = intArrayOf(0, 0)
for (s in target) {
// 아스키 코드의 특성을 이용한다.
val t = (s - 97).toI... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,224 | algorithm | MIT License |
src/Day01.kt | ekgame | 573,100,811 | false | {"Kotlin": 20661} | fun main() {
fun part1(input: List<String>): Int {
return input
.fold(mutableListOf<MutableList<Int>>(mutableListOf())) { acc, s ->
if (s.isBlank()) {
acc.add(mutableListOf())
} else {
acc.last().add(s.toInt())
... | 0 | Kotlin | 0 | 2 | 0c2a68cedfa5a0579292248aba8c73ad779430cd | 1,029 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/graph/EvaluateDivision.kt | ghonix | 88,671,637 | false | null | /**
* https://leetcode.com/problems/evaluate-division/
*/
package graph
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.HashSet
import kotlin.collections.LinkedHashSet
class EvaluateDivision {
data class Edge(val division: Double, val to: String)
fun calcEquation(equations: L... | 0 | Kotlin | 0 | 2 | 25d4ba029e4223ad88a2c353a56c966316dd577e | 2,300 | Problems | Apache License 2.0 |
src/main/kotlin/days/aoc2023/Day1.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2023
import days.Day
class Day1: Day(2023, 1) {
override fun partOne(): Any {
return calculatePartOne(inputList)
}
override fun partTwo(): Any {
return calculatePartTwo(inputList)
}
fun calculatePartOne(input: List<String>): Int {
return input.sumOf { line... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 1,670 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day17/Day17Puzzle1.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day17
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
import kotlin.math.max
class Day17Puzzle1 : PuzzleSolver {
override fun solve(inputLines: Sequence<String>) = bruteForceHighestYPosition(inputLines.first()).toString()
private fun ... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 1,684 | AdventOfCode2021 | Apache License 2.0 |
src/day2/Code.kt | fcolasuonno | 221,697,249 | false | null | package day2
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)}")
println("Part 2 = ${part2(parsed)}")
}
fun ... | 0 | Kotlin | 0 | 0 | 73110eb4b40f474e91e53a1569b9a24455984900 | 2,736 | AOC2016 | MIT License |
src/main/kotlin/net/voldrich/aoc2021/Day19.kt | MavoCz | 434,703,997 | false | {"Kotlin": 119158} | package net.voldrich.aoc2021
import net.voldrich.BaseDay
import kotlin.math.abs
import kotlin.math.max
// link to task
fun main() {
Day19().run()
}
typealias ScFn = (Day19.ScannerPoint) -> Day19.ScannerPoint
class Day19 : BaseDay() {
override fun task1() : Int {
return ScannerAnalyzer().findTotalPoi... | 0 | Kotlin | 0 | 0 | 0cedad1d393d9040c4cc9b50b120647884ea99d9 | 8,267 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day10/Solution.kt | TestaDiRapa | 573,066,811 | false | {"Kotlin": 50405} | package day10
import java.io.File
data class RegisterHistory(
val history: Map<Int, Int> = mapOf(0 to 1)
) {
fun addNoOp(): RegisterHistory {
val lastClock = history.keys.last()
val lastRegister = history.values.last()
return this.copy(history = history + (lastClock+1 to lastRegister))... | 0 | Kotlin | 0 | 0 | b5b7ebff71cf55fcc26192628738862b6918c879 | 2,178 | advent-of-code-2022 | MIT License |
LeetCode/Kotlin/TopKFrequent.kt | vale-c | 177,558,551 | false | null | /**
* 347. Top K Frequent Elements
* https://leetcode.com/problems/top-k-frequent-elements/
*/
class Solution {
fun topKFrequent(nums: IntArray, k: Int): List<Int> {
val frequencyMap = mutableMapOf<Int, Int>()
var maxCount = 0
nums.forEach {
val currentFrequency = frequencyMap.computeIfAbse... | 0 | Java | 5 | 9 | 977e232fa334a3f065b0122f94bd44f18a152078 | 1,095 | CodingInterviewProblems | MIT License |
src/main/kotlin/kr/co/programmers/P86052.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/409
class P86052 {
companion object {
const val UP = 0
const val RIGHT = 1
const val DOWN = 2
const val LEFT = 3
}
fun solution(grid: Array<String>): IntArray {
// 각 격자에서 네방향으로 이동한 기록
... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 2,184 | algorithm | MIT License |
src/main/kotlin/Day3_2.kt | vincent-mercier | 726,287,758 | false | {"Kotlin": 37963} | import java.io.File
import java.io.InputStream
import kotlin.streams.asSequence
fun getGearRatios(input: List<Pair<List<MatchResult>, Sequence<Int>>>): List<Int> =
input.flatMapIndexed { index: Int, pair: Pair<List<MatchResult>, Sequence<Int>> ->
when (index) {
0 -> {
pair.secon... | 0 | Kotlin | 0 | 0 | 53b5d0a0bb65a77deb5153c8a912d292c628e048 | 2,236 | advent-of-code-2023 | MIT License |
core/src/main/kotlin/com/bsse2018/salavatov/flt/algorithms/Hellings.kt | vsalavatov | 241,599,920 | false | {"Kotlin": 149462, "ANTLR": 1960} | package com.bsse2018.salavatov.flt.algorithms
import com.bsse2018.salavatov.flt.grammars.ContextFreeGrammar
import com.bsse2018.salavatov.flt.utils.Graph
import java.util.*
import kotlin.collections.MutableSet
fun HellingsQuery(graph: Graph, wcnf: ContextFreeGrammar): MutableSet<Pair<Int, Int>> {
val dp = List(gr... | 0 | Kotlin | 0 | 1 | c1c229c113546ef8080fc9d3568c5024a22b80a5 | 2,713 | bsse-2020-flt | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-02.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2021, "02-input")
val test1 = readInputLines(2021, "02-test1")
println("Part1:")
part1(test1).println()
p... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,371 | advent-of-code | MIT License |
src/main/kotlin/g2601_2700/s2603_collect_coins_in_a_tree/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2601_2700.s2603_collect_coins_in_a_tree
// #Hard #Array #Tree #Graph #Topological_Sort
// #2023_07_13_Time_986_ms_(100.00%)_Space_67.7_MB_(100.00%)
class Solution {
private lateinit var coins: IntArray
private var n = 0
private lateinit var graph: Array<ArrayList<Int>?>
private var sum = 0
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,302 | LeetCode-in-Kotlin | MIT License |
backend/src/main/kotlin/com/example/tictactoe/model/Winner.kt | ezhaka | 140,628,510 | false | {"JavaScript": 112184, "Kotlin": 56312, "HTML": 2377, "SCSS": 1686, "Procfile": 83} | package com.example.tictactoe.model
import kotlin.ranges.IntProgression.Companion.fromClosedRange
data class Winner(
val userId: String,
val ranges: List<CoordinateRange>
)
data class CoordinateRange(
val from: Coordinates,
val to: Coordinates
)
class WinnerCalculator(private val movesMap: Map<Coord... | 0 | JavaScript | 0 | 1 | 359d6ee3251505e41223583e11bdc58c8e7de2fa | 3,221 | tic-tac-toe | MIT License |
src/day06/Day06.kt | pnavais | 574,712,395 | false | {"Kotlin": 54079} | package day06
import readInput
private fun readPackets(input: List<String>, maxLength: Int): List<Pair<String, Long>> {
return input.map { s ->
var idx = 0L
val charSet = HashSet<Char>()
var packetMarker = mutableListOf<Char>()
for (c in s.toCharArray()) {
idx++
... | 0 | Kotlin | 0 | 0 | ed5f521ef2124f84327d3f6c64fdfa0d35872095 | 1,167 | advent-of-code-2k2 | Apache License 2.0 |
src/main/kotlin/Day09.kt | bent-lorentzen | 727,619,283 | false | {"Kotlin": 68153} | import java.time.LocalDateTime
import java.time.ZoneOffset
fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { line ->
var ints = line.split(" ").map { it.toInt() }
var sum = 0
while (ints.any { it != 0 }) {
sum += ints.last
... | 0 | Kotlin | 0 | 0 | 41f376bd71a8449e05bbd5b9dd03b3019bde040b | 1,310 | aoc-2023-in-kotlin | Apache License 2.0 |
year2022/src/main/kotlin/net/olegg/aoc/year2022/day11/Day11.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2022.day11
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.parseLongs
import net.olegg.aoc.year2022.DayOf2022
/**
* See [Year 2022, Day 11](https://adventofcode.com/2022/day/11)
*/
object Day11 : DayOf2022(11) {
override fun first(): Any? {
val monkeys = parseMonkeys(... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 3,301 | adventofcode | MIT License |
advent-of-code-2019/src/test/java/Day10MonitoringStation.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | import org.assertj.core.api.AbstractFloatAssert
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.data.Percentage
import org.junit.Test
import kotlin.math.PI
import kotlin.math.atan2
import kotlin.math.sqrt
class Day10MonitoringStation {
data class Asteroid(val x: Int, val y: Int) {
... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 8,638 | advent-of-code | MIT License |
src/adventofcode/day01/Day01.kt | bstoney | 574,187,310 | false | {"Kotlin": 27851} | package adventofcode.day01
import adventofcode.AdventOfCodeSolution
import adventofcode.split
fun main() {
Solution.solve()
}
object Solution : AdventOfCodeSolution<Int>() {
override fun solve() {
solve(1, 24000, 45000)
}
override fun part1(input: List<String>): Int {
return getMaxCa... | 0 | Kotlin | 0 | 0 | 81ac98b533f5057fdf59f08940add73c8d5df190 | 1,048 | fantastic-chainsaw | Apache License 2.0 |
2020/day18/day18.kt | flwyd | 426,866,266 | false | {"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398} | /*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package day18
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
import kotlin.time.measureTimedValue
/* Input: L... | 0 | Julia | 1 | 5 | f2d6dbb67d41f8f2898dbbc6a98477d05473888f | 3,722 | adventofcode | MIT License |
src/shmulik/klein/day01/Day01.kt | shmulik-klein | 573,426,488 | false | {"Kotlin": 9136} | fun main() {
fun getCaloriesList(input: List<String>): List<Int> {
val result: MutableList<Int> = mutableListOf()
var current = 0
for (row in input) {
if (row.isEmpty()) {
result.add(current)
current = 0
continue
}
... | 0 | Kotlin | 0 | 0 | 4d7b945e966dad8514ec784a4837b63a942882e9 | 980 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/expressions/Expression.kt | rinatisk | 355,830,207 | false | null | package expressions
import exceptions.ParseException
import exceptions.TypeException
import expressions.bool.*
import expressions.num.*
import kotlin.math.max
interface Expression
open class BinaryExpression(open val leftPart: Expression, open val rightPart: Expression, open val type: String) : Expression
open clas... | 0 | Kotlin | 0 | 0 | e622fdb1f6487d7dfb3aaa531587801308493d25 | 4,566 | call-chain-converter | Apache License 2.0 |
src/main/kotlin/adventofcode2018/Day22ModeMaze.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2018
class Day22ModeMaze
class MazeCalculator(val depth: Int, val targetX: Int, val targetY: Int) {
val regions: List<MutableList<Int>>
val errosionLevels: List<MutableList<Int>> = List(targetY + 1) { MutableList(targetX + 1) { 0 } }
val riskLevel: Int
get() = regions.map { lin... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 1,780 | kotlin-coding-challenges | MIT License |
src/main/kotlin/g0601_0700/s0698_partition_to_k_equal_sum_subsets/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0601_0700.s0698_partition_to_k_equal_sum_subsets
// #Medium #Array #Dynamic_Programming #Bit_Manipulation #Backtracking #Bitmask #Memoization
// #2023_02_22_Time_191_ms_(100.00%)_Space_45.5_MB_(50.00%)
class Solution {
fun canPartitionKSubsets(nums: IntArray, k: Int): Boolean {
if (nums.isEmpty()... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,373 | LeetCode-in-Kotlin | MIT License |
src/day01/Day01.kt | zypus | 573,178,215 | false | {"Kotlin": 33417, "Shell": 3190} | package day01
import AoCTask
// https://adventofcode.com/2022/day/1
fun part1(input: List<String>): Int {
val elvesRations = getTotalRationsPerElf(input)
return elvesRations.max()
}
fun part2(input: List<String>): Int {
val elvesRations = getTotalRationsPerElf(input)
return elvesRations.sortedDe... | 0 | Kotlin | 0 | 0 | f37ed8e9ff028e736e4c205aef5ddace4dc73bfc | 824 | aoc-2022 | Apache License 2.0 |
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/kotlin/icedrek.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": ... | /*
* Escribe un programa que reciba un texto y transforme lenguaje natural a
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje
* se caracteriza por sustituir caracteres alfanuméricos.
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/)
* con el alfabeto y l... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 1,652 | retos-programacion-2023 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2019/Day3.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2019
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import kotlin.math.abs
/** https://adventofcode.com/2019/day/3 */
class Day3 : Solver {
override fun solve(lines: List<String>): Result {
val dirs1 = traceWire(lines[0].split(","))
val dirs2 = traceWire(lines[1].split(","))
... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,292 | euler | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NAryTreePreorderTraversal.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,689 | kotlab | Apache License 2.0 |
src/Day24.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | enum class Symbol {
BLIZZARD_RIGHT,
BLIZZARD_DOWN,
BLIZZARD_LEFT,
BLIZZARD_UP,
ELF
}
fun main() {
fun printGrid(grid:Map<Point, MutableList<Symbol>>) {
// Make gridArray
val gridArray = Array(grid.keys.maxOf{it.y} + 1) { CharArray(grid.keys.maxOf{it.x} + 2) }
for (entry ... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 8,157 | AoC2022 | Apache License 2.0 |
src/main/kotlin/com/booleworks/packagesolver/data/Package.kt | booleworks | 497,876,711 | false | {"Kotlin": 30454} | package com.booleworks.packagesolver.data
import org.logicng.formulas.Formula
import org.logicng.formulas.FormulaFactory
import org.logicng.formulas.Variable
import java.util.*
const val PREFIX_INSTALLED = "i"
const val PREFIX_INSTALLED_GREATER = "ig"
const val PREFIX_INSTALLED_LESS = "il"
const val PREFIX_UNINSTALLE... | 0 | Kotlin | 0 | 0 | e99b2e19599720866a0172b5c30047d37862343c | 6,147 | package-solving-poc | MIT License |
src/main/kotlin/adventofcode/year2021/Day06Lanternfish.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2021
import adventofcode.Puzzle
import adventofcode.PuzzleInput
class Day06Lanternfish(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val fish by lazy { input.split(",").map(String::toInt) }
private val fishByAge by lazy { fish.groupingBy { it }.eachCount().map { (... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 984 | AdventOfCode | MIT License |
src/commonMain/kotlin/redblack/RedBlackUtils.kt | EdwarDDay | 174,175,328 | false | null | /*
* Copyright 2019 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wr... | 0 | Kotlin | 0 | 0 | 219a58640619c74f60c02742baaeb9346524215b | 17,161 | SortedList | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem1269/Solution2.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1269
/**
* LeetCode page: [1269. Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/);
*/
class Solution2 {
/* Complexity:
* Time O(step * N) and Space O(N) where N represent... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,063 | hj-leetcode-kotlin | Apache License 2.0 |
src/com/aaron/helloalgorithm/algorithm/链表/_141_环形链表.kt | aaronzzx | 431,740,908 | false | null | package com.aaron.helloalgorithm.algorithm.链表
import com.aaron.helloalgorithm.algorithm.LeetCode
import com.aaron.helloalgorithm.algorithm.ListNode
/**
* # 141. 环形链表
*
* 给你一个链表的头节点 head ,判断链表中是否有环。
*
* 如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环。 为了表示给定链表中的环,评测系统内部使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。如果 pos 是 -1,则在该链表... | 0 | Kotlin | 0 | 0 | 2d3d823b794fd0712990cbfef804ac2e138a9db3 | 1,342 | HelloAlgorithm | Apache License 2.0 |
src/Day01/Day01.kt | JamesKing95 | 574,470,043 | false | {"Kotlin": 7225} | package Day01
import readInput
fun main() {
fun getElfBagTotals(input: List<String>): MutableList<Int> {
val bagTotals = mutableListOf<Int>()
var currentTotal = 0
input.forEach { line ->
if (line == "") {
bagTotals.add(currentTotal)
currentTotal ... | 0 | Kotlin | 0 | 0 | cf7b6bd5ae6e13b83d871dfd6f0a75b6ae8f04cf | 1,033 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day06.kt | RickShaa | 572,623,247 | false | {"Kotlin": 34294} | import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.math.sign
fun main() {
val fileName = "day06.txt"
val testFileName = "day06_test.txt"
val input = FileUtil.getTrimmedText(testFileName);
/**
* Initial solution
*/
fun isStarterPacket(packet:List<Char>):Boolean{
... | 0 | Kotlin | 0 | 1 | 76257b971649e656c1be6436f8cb70b80d5c992b | 4,934 | aoc | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RemoveZeroSumSublists.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 | 2,393 | kotlab | Apache License 2.0 |
src/main/java/quam/ComplexMatrix.kt | johnhearn | 149,781,062 | false | null | package quam
class ComplexMatrix(val width : Int, internal val components: List<ComplexNumber>) {
constructor(width : Int, vararg components: ComplexNumber) : this(width, listOf(*components))
constructor(width : Int, vararg components: Double) : this(width, components.map { it + 0.0 * i })
constructor(w... | 1 | Kotlin | 0 | 1 | 4215d86e7afad97b803ce850745920b63f75a0f9 | 4,140 | quko | MIT License |
src/main/kotlin/day19/Grammar.kt | lukasz-marek | 317,632,409 | false | {"Kotlin": 172913} | package day19
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.runBlocking
data class RuleMatch(val matched: List<Char>)
interface ProductionRule {
suspend fun match(input: List<Char>): Flow<RuleMatch>
}
data class RuleRefere... | 0 | Kotlin | 0 | 0 | a16e95841e9b8ff9156b54e74ace9ccf33e6f2a6 | 3,897 | aoc2020 | MIT License |
src/main/kotlin/15/15.kt | Wrent | 225,133,563 | false | null | import java.math.BigInteger
fun main() {
val ship = mutableMapOf<Coord, ShipBlock>()
ship[Coord(0, 0)] = ShipBlock(0, ShipBlockType.EMPTY)
val data = mutableMapOf<BigInteger, BigInteger>()
INPUT15.split(",").map { it.toBigInteger() }.forEachIndexed { index, i -> data[index.toBigInteger()] = i }
v... | 0 | Kotlin | 0 | 0 | 0a783ed8b137c31cd0ce2e56e451c6777465af5d | 7,030 | advent-of-code-2019 | MIT License |
src/main/kotlin/report/cpf/iteration/ReducedProgram.kt | Tiofx | 175,697,373 | false | null | package report.cpf.iteration
import algorithm.CPF
import kotlin.math.min
class ReducedProgram(val limit: Int = 17,
val groupMinSize: Int = 3,
val startMinSize: Int = 3,
val endMinSize: Int = 6) {
lateinit var iteration: CPF.Iteration
private val ... | 0 | Kotlin | 0 | 0 | 32c1cc3e95940e377ed9a99293eccc871ce13864 | 3,123 | CPF | The Unlicense |
day13/Kotlin/day13.kt | Ad0lphus | 353,610,043 | false | {"C++": 195638, "Python": 139359, "Kotlin": 80248} | import java.io.*
fun print_day_13() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 13" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Transparent Origami -c -f small")
... | 0 | C++ | 0 | 0 | 02f219ea278d85c7799d739294c664aa5a47719a | 3,211 | AOC2021 | Apache License 2.0 |
src/Day14.kt | er453r | 572,440,270 | false | {"Kotlin": 69456} | fun main() {
fun fallingSand(input: List<String>, hardFloor: Boolean, stopOnOverflow: Boolean, startPoint: Vector2d = Vector2d(500, 0)): Int {
val lines = input.map {
it.ints().chunked(2).map { (x, y) ->
Vector2d(x, y)
}.toList()
}
val xMin = lines.fl... | 0 | Kotlin | 0 | 0 | 9f98e24485cd7afda383c273ff2479ec4fa9c6dd | 2,565 | aoc2022 | Apache License 2.0 |
src/main/kotlin/day4.kt | nerok | 436,232,451 | false | {"Kotlin": 32118} | import java.io.File
fun main(args: Array<String>) {
day4()
}
fun day4() {
val input = File("day4input.txt").bufferedReader()
val drawings = input.readLine().split(",").map { it.toInt() }
input.readLines()
.asSequence()
.windowed(6, step = 6)
.map { board ->
board.fi... | 0 | Kotlin | 0 | 0 | 4dee925c0f003fdeca6c6f17c9875dbc42106e1b | 1,646 | Advent-of-code-2021 | MIT License |
src/twentytwentytwo/day1/Day01.kt | colinmarsch | 571,723,956 | false | {"Kotlin": 65403, "Python": 6148} | fun main() {
fun part1(input: List<String>): Int {
var maxCalorie = 0
var currentCalorieCount = 0
var currentIndex = 0
input.forEach { line ->
val currentInt = line.toIntOrNull()
if (currentInt != null) {
currentCalorieCount += currentInt
... | 0 | Kotlin | 0 | 0 | bcd7a08494e6db8140478b5f0a5f26ac1585ad76 | 1,451 | advent-of-code | Apache License 2.0 |
src/main/kotlin/g1301_1400/s1335_minimum_difficulty_of_a_job_schedule/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1301_1400.s1335_minimum_difficulty_of_a_job_schedule
// #Hard #Array #Dynamic_Programming #2023_06_06_Time_154_ms_(100.00%)_Space_34.1_MB_(100.00%)
class Solution {
fun minDifficulty(jobDifficulty: IntArray, d: Int): Int {
val totalJobs = jobDifficulty.size
if (totalJobs < d) {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,322 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/info/dgjones/barnable/domain/general/Group.kt | jonesd | 442,279,905 | false | {"Kotlin": 474251} | /*
* 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... | 1 | Kotlin | 0 | 0 | b5b7453e2fe0b2ae7b21533db1b2b437b294c63f | 4,607 | barnable | Apache License 2.0 |
src/main/kotlin/day3/Day3.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day3
import Day
fun main() {
Day3("Day03").solve()
}
class Day3(input: String) : Day<List<Day3.Rucksack>>(input) {
data class Rucksack(val data: String) {
private val compartmentSize = data.length / 2
private val a = data.take(compartmentSize).toSet()
private val b = data.dro... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 1,044 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/sk/topicWise/tree/medium/236. Lowest Common Ancestor of a Binary Tree.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.topicWise.tree.medium
import com.sk.topicWise.tree.TreeNode
class Solution236_1 {
fun lowestCommonAncestor(root: TreeNode?, p: TreeNode?, q: TreeNode?): TreeNode? {
if (root == null || root === p || root === q) return root
val left = lowestCommonAncestor(root.left, p, q)
val... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 1,529 | leetcode-kotlin | Apache License 2.0 |
src/day06/Day06.kt | MaxBeauchemin | 573,094,480 | false | {"Kotlin": 60619} | package day06
import readInput
fun main() {
fun findUniqueBufferStartIndex(input: String, desiredSize: Int): Int {
var buffer = ""
input.toList().forEachIndexed { index, c ->
buffer += c
if (buffer.length == desiredSize + 1) {
buffer = buffer.slice(1..desi... | 0 | Kotlin | 0 | 0 | 38018d252183bd6b64095a8c9f2920e900863a79 | 1,094 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g0201_0300/s0210_course_schedule_ii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0201_0300.s0210_course_schedule_ii
// #Medium #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search #Graph
// #Topological_Sort #Level_2_Day_11_Graph/BFS/DFS
// #2022_10_20_Time_266_ms_(96.32%)_Space_45.9_MB_(92.65%)
class Solution {
fun findOrder(numCourses: Int, prerequisites: Array<IntArr... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,435 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/io/github/nillkki/aoc/Day08.kt | Nillkki | 572,858,950 | false | {"Kotlin": 38345} | package io.github.nillkki.aoc
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.Measurement
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.Setup
import org.openjdk.jmh.annotations.State
import org.openjdk.jmh.annotations.Warmup
@State(Scope.Benchmark)
@Warmup... | 0 | Kotlin | 0 | 0 | 42b38e2a2592a8a5191c221b3dc648b879920ef8 | 5,414 | aoc-2022 | Apache License 2.0 |
src/pl/shockah/aoc/y2021/Day13.kt | Shockah | 159,919,224 | false | null | package pl.shockah.aoc.y2021
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import pl.shockah.aoc.AdventTask
import pl.shockah.aoc.toCharString
import pl.shockah.unikorn.collection.Array2D
class Day13: AdventTask<Day13.Input, Int, String>(2021, 13) {
data class Input(
val dots: List<Pair... | 0 | Kotlin | 0 | 0 | 9abb1e3db1cad329cfe1e3d6deae2d6b7456c785 | 2,864 | Advent-of-Code | Apache License 2.0 |
src/Day01.kt | kedvinas | 572,850,757 | false | {"Kotlin": 15366} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
var max = 0
var current = 0
for (i in input) {
if (i.isNotEmpty()) {
current += i.toInt()
} else {
max = max(current, max)
current = 0
... | 0 | Kotlin | 0 | 0 | 04437e66eef8cf9388fd1aaea3c442dcb02ddb9e | 982 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/leetcode/problem0015/ThreeSum.kt | ayukatawago | 456,312,186 | false | {"Kotlin": 266300, "Python": 1842} | package leetcode.problem0015
class ThreeSum {
fun threeSum(nums: IntArray): List<List<Int>> {
if (nums.isEmpty()) {
return emptyList()
}
val answerMap = HashMap<Int, Int>()
val answerSet = mutableSetOf<List<Int>>()
nums.forEachIndexed { index, num ->
... | 0 | Kotlin | 0 | 0 | f9602f2560a6c9102728ccbc5c1ff8fa421341b8 | 1,442 | leetcode-kotlin | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.