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/day09/Day09_2.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day09 import readInput import kotlin.math.abs fun main() { data class Position(val row: Int, val col: Int) val size = 50000000 val middle = size / 2 var headMain = Position(row = middle, col = middle) var tailsMap = hashMapOf<Int, Position>().apply { for (i in 1..9) { ...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
4,199
aoc-2022-kotlin
Apache License 2.0
src/Day01.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var highestSum = 0 var currentSum = 0 for (s in input) { if (s.isEmpty()) { highestSum = max(highestSum, currentSum) currentSum = 0 } else { curr...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
1,098
advent-of-code-2022-kietyo
Apache License 2.0
src/Day06.kt
brunojensen
572,665,994
false
{"Kotlin": 13161}
// first implementation private fun String.startOfPacketMarker1(size: Int): Int { var index = 0 while ((index + size) < length - 1) { val subSequence = subSequence(index, index + size) if (subSequence.countDistinct() == size) { return index + size } index++ } return -1 } // Using kotlin s...
0
Kotlin
0
0
2707e76f5abd96c9d59c782e7122427fc6fdaad1
1,048
advent-of-code-kotlin-1
Apache License 2.0
src/main/kotlin/com/ikueb/advent18/Day07.kt
h-j-k
159,901,179
false
null
package com.ikueb.advent18 object Day07 { private const val DEFINITION = "Step (.) must be finished before step (.) can begin." fun getOrderedSteps(input: List<String>, total: Int = 1, effort: (String) -> Int = { 1 }): Pair<String, ElfWorkers> { val ste...
0
Kotlin
0
0
f1d5c58777968e37e81e61a8ed972dc24b30ac76
3,024
advent18
Apache License 2.0
src/main/kotlin/cloud/dqn/leetcode/PermutationsKt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/permutations/description/ Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
1,859
cloud-dqn-leetcode
No Limit Public License
plugin/src/main/kotlin/com/jraska/module/graph/DependencyGraph.kt
jraska
227,907,412
false
{"Kotlin": 63377}
package com.jraska.module.graph import java.io.Serializable class DependencyGraph private constructor() { private val nodes = mutableMapOf<String, Node>() fun findRoot(): Node { require(nodes.isNotEmpty()) { "Dependency Tree is empty" } val rootCandidates = nodes().toMutableSet() nodes().flatMap { ...
2
Kotlin
16
433
c37ef1d9b4b3f2d61abc6c606b3e08715b73097b
4,185
modules-graph-assert
Apache License 2.0
2016/main/day_03/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_03_2016 import java.io.File fun part1(input: List<String>) { input.map { val strings = it.split(" ").filter { it1 -> it1.isBlank() } strings.map { it1 -> it1.toInt() } }.stream() .filter { (it[0] + it[1] > it[2]) && (it[0] + it[2] > it[1]) && (it[1] + it[2] > it[0]...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,084
AdventofCode
MIT License
src/Day04.kt
Scholar17
579,871,947
false
{"Kotlin": 24751}
import java.io.File fun main() { fun parseInputCommaAndNewLine(input: String): List<String> { return input.split(",", "\r\n") } fun parseInputDash(input: String): List<Int> { return input.split("-").map { str -> str.toInt() } } val fileName = "src/Day0...
0
Kotlin
0
2
d3d79fbeeb640a990dbeccf2404612b4f7922b38
2,363
aoc-2022-in-kotlin
Apache License 2.0
src/Day14.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
import kotlin.math.max import kotlin.math.min fun main() { val factor = 1000 fun Set<Int>.contains(x: Int, y: Int): Boolean { return this.contains(x * factor + y) } fun MutableSet<Int>.add(x: Int, y: Int) { this.add(x * factor + y) } fun drawX(fill: MutableSet<Int>, start: In...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
3,212
AdventCode2022
Apache License 2.0
src/day11/Day11.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day11 import readInput import utils.multiply import utils.split import utils.withStopwatch fun main() { val testInput = readInput("input11_test") withStopwatch { println(part1(testInput)) } withStopwatch { println(part2(testInput)) } val input = readInput("input11") withStopwatch { printl...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
1,203
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2016/AirDuctSpelunking.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 import komu.adventofcode.utils.Point import komu.adventofcode.utils.nonEmptyLines import komu.adventofcode.utils.permutations import utils.shortestPathBetween fun airDuctSpelunking(input: String, returnToStart: Boolean): Int { val map = AirDuctMap.parse(input) val start = ma...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,570
advent-of-code
MIT License
src/Day03.kt
Scholar17
579,871,947
false
{"Kotlin": 24751}
import java.io.File import kotlin.math.absoluteValue fun main() { fun parseInput(input: String): List<String> { return input.split("\r\n").map { value -> value } } val fileName = // "src/Day03_sample.txt" "src/Day03_quiz.txt" val inputText = File(fileName).readT...
0
Kotlin
0
2
d3d79fbeeb640a990dbeccf2404612b4f7922b38
2,622
aoc-2022-in-kotlin
Apache License 2.0
src/pj_euler/pj57.kt
BenjiDayan
287,910,169
false
{"Kotlin": 19944}
package pj_euler import kotlin.math.floor import kotlin.math.sqrt import kotlin.comparisons.minOf import kotlin.comparisons.maxOf import java.math.BigInteger import kotlin.Boolean //TODO pj 64 fun main(args: Array<String>) { val frac = Fraction(BigInteger.valueOf(6), BigInteger.valueOf(4)) println(frac) fr...
0
Kotlin
0
0
cde700c0249c115bc305afd7094ce07a2f9963b7
3,555
hello_kotlin
MIT License
year2020/day06/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day06/part2/Year2020Day06Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- As you finish the last group's customs declaration, you notice that you misread one word in the instructions: You don't need to identify the questions to which anyone answered "yes"; you need to identify the questions to which everyone answered "yes"! Using the same example as above: abc a b c ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,696
AdventOfCode
MIT License
src/main/kotlin/days/Day21.kt
julia-kim
569,976,303
false
null
package days import readInput import kotlin.math.absoluteValue fun main() { fun evaluateExpression(val1: Long, val2: Long, op: Char): Long { return when (op) { '+' -> val1 + val2 '-' -> val1 - val2 '*' -> val1 * val2 '/' -> val1 / val2 else -> th...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
4,888
advent-of-code-2022
Apache License 2.0
day7/src/main/kotlin/be/swsb/aoc2020/Day7.kt
Sch3lp
318,098,967
false
null
package be.swsb.aoc2020 import be.swsb.aoc.common.WeightedGraph class BagRules(stringList: List<String>) : WeightedGraph<Color, Amount>() { init { stringList.map(String::toBagRule) .associateBy { it.color } .mapValues { (_, value) -> value.containedBags } .forEach { (co...
0
Kotlin
0
0
32630a7efa7893b4540fd91d52c2ff3588174c96
2,040
Advent-of-Code-2020
MIT License
src/Day03.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
fun main() { fun Char.priority() = if (isLowerCase()) code - 96 else code - 38 fun part1(input: List<String>) = input.sumOf { rucksack -> val (first, second) = rucksack.chunked(rucksack.length / 2) second.first { first.contains(it) }.priority() } fun part2(input: List<String>) = input...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
709
aoc-2022
Apache License 2.0
src/Day05.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import java.lang.IllegalArgumentException class CratesState(private val rows: MutableList<MutableList<Char>>) { fun move(count: Int, from: Int, to: Int, reverse: Boolean) { val buffer = mutableListOf<Char>() for (i in 0 until count) { buffer.add(rows[from - 1].removeLast()) } ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
2,239
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day-2.kt
joebutler2
577,057,170
false
{"Kotlin": 5432}
enum class Move { ROCK, PAPER, SCISSORS } val translations = mapOf( "A" to Move.ROCK, "X" to Move.ROCK, "B" to Move.PAPER, "Y" to Move.PAPER, "C" to Move.SCISSORS, "Z" to Move.SCISSORS, ) fun main(args: Array<String>) { val input = object {}.javaClass.getResourceAsStream("day-2.txt")?.buffe...
0
Kotlin
0
0
7abdecbc4a4397f917c84bd8d8b9f05fb7079c75
1,637
advent-of-code-kotlin
MIT License
src/aoc2022/Day10.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import java.util.* fun main() { fun List<String>.designEachCycleAddedX() = flatMap { line -> val instructionSplit = line.split(" ") return@flatMap if (instructionSplit.first() == "noop") listOf(0) else listOf(0, instructionSplit[1].toInt()) } ...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,288
Kotlin-AOC-2023
Apache License 2.0
leetcode/src/daily/Q811.kt
zhangweizhe
387,808,774
false
null
package daily fun main() { // 811. 子域名访问计数 // https://leetcode.cn/problems/subdomain-visit-count/ println(subdomainVisits(arrayOf("900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"))) } fun subdomainVisits(cpdomains: Array<String>): List<String> { val map = HashMap<String ,Int>()...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,577
kotlin-study
MIT License
src/Lesson4CountingElements/FrogRiverOne.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.HashSet /** * 100/100 * @param X * @param A * @return */ fun solution(X: Int, A: IntArray): Int { val steps: HashSet<Int> = HashSet<Int>() val result = -1 for (i in A.indices) { steps.add(A[i]) if (steps.size == X) { return i } } return res...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,263
Codility-Kotlin
Apache License 2.0
src/Day10.kt
shoresea
576,381,520
false
{"Kotlin": 29960}
import Command.Instruction.addx import Command.Instruction.noop fun main() { fun part1(inputs: List<String>): Int { val cpu = CPU() for (input in inputs) { val command = Command.parseFrom(input) cpu.process(command) } return cpu.strength() } fun par...
0
Kotlin
0
0
e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e
2,365
AOC2022InKotlin
Apache License 2.0
day01/src/main/kotlin/Main.kt
rstockbridge
225,212,001
false
null
fun main() { val inputAsInts = resourceFile("input.txt") .readLines() .map(String::toInt) println("Part I: the solution is ${solvePartI(inputAsInts)}.") println("Part II: the solution is ${solvePartII(inputAsInts)}.") } fun solvePartI(inputAsInts: List<Int>): Int { return calculateTota...
0
Kotlin
0
0
bcd6daf81787ed9a1d90afaa9646b1c513505d75
1,045
AdventOfCode2019
MIT License
src/main/kotlin/aoc2020/HandyHaversacks.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.nonEmptyLines private val rulePattern = Regex("""(.+) bags contain (.+)\.""") private val countPattern = Regex("""(\d+) (.+) bags?""") fun handyHaversacks1(data: String): Int { val rules = parseHaversackRules(data) val work = mutableListOf("sh...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,581
advent-of-code
MIT License
bio-common/src/main/kotlin/bio/relatives/common/utils/MathUtils.kt
SHvatov
325,566,887
false
null
package bio.relatives.common.utils import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sqrt /** * Based on the provided [values] calculates the median value. * @author Created by <NAME> on 28.01.2021 */ fun <T : Number> calculateMedianVale(values: List<T>): Double = with(values.map { it.toD...
1
Kotlin
0
0
f85c14499c53569ed0cddfd110c20178defaa1f2
1,651
bio-relatives-kt
MIT License
Kotlin/BreadthFirstPaths.kt
lprimeroo
41,106,663
false
null
class BreadthFirstPaths { private var marked: BooleanArray? = null // marked[v] = is there an s-v path private var edgeTo: IntArray? = null // edgeTo[v] = previous edge on shortest s-v path private var distTo: IntArray? = null // distTo[v] = number of edges shortest s-v path /** * Compu...
56
C++
186
99
16367eb9796b6d4681c5ddf45248e2bcda72de80
6,117
DSA
MIT License
Continuous_Subarray_Sum.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
// Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer. class Solution { fun checkSubarraySum(nums: IntArray, k: Int): Boolean { va...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,498
leetcode
MIT License
src/main/kotlin/aoc2021/day2/DepthOnARoll.kt
arnab
75,525,311
false
null
package aoc2021.day2 object DepthOnARoll { data class Command(val direction: String, val units: Int) { companion object { fun from(data: String): Command { val direction = data.split(" ")[0] val units = data.split(" ")[1].toInt() return Command(d...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,005
adventofcode
MIT License
src/Day01.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
fun main() { fun getElves(input: List<String>): List<Int> { val elves = mutableListOf(0) var index = 0 input.forEach { line -> when (line) { "" -> { elves.add(0) index++ } else -> { ...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
1,004
advent-of-code-2022
Apache License 2.0
src/cn/leetcode/codes/simple11/Simple11_2.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple11 import kotlin.math.max import kotlin.math.min class Simple11_2 { /** * 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0) 。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器。   示例 1: 输入:[1,8,6,2,5,4,8,3,7] 输出:49 ...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,814
LeetCodeSimple
Apache License 2.0
src/main/kotlin/net/dilius/daily/coding/problem/n00x/003.kt
diliuskh
298,020,928
false
null
package net.dilius.daily.coding.problem.n00x import net.dilius.daily.coding.problem.Problem import java.util.StringTokenizer /* Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. For example, given...
0
Kotlin
0
0
7e5739f87dbce2b56d24e7bab63b6cee6bbc54bc
3,388
dailyCodingProblem
Apache License 2.0
src/Day06/Day06.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
fun main() { fun calc(input: List<Int>, iterations: Int): Long { val counts = MutableList<Long>(9) { 0 } input.forEach { counts[it]++ } for (i in 0 until iterations) { val numNew = counts.removeFirst() counts[6] += numNew counts.add(numNew) } ...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
778
advent-of-code-2021
Apache License 2.0
src/main/kotlin/g1701_1800/s1739_building_boxes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1739_building_boxes // #Hard #Math #Greedy #Binary_Search #2023_06_16_Time_133_ms_(100.00%)_Space_32.8_MB_(100.00%) class Solution { fun minimumBoxes(n: Int): Int { val k: Int = findLargestTetrahedralNotGreaterThan(n) val used: Int = tetrahedral(k) val floor: Int = tria...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,618
LeetCode-in-Kotlin
MIT License
src/main/kotlin/io/binarysearch/SearchRange.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.binarysearch // https://leetcode.com/explore/learn/card/binary-search/135/template-iii/944/ class SearchRange { fun execute(nums: IntArray, target: Int): IntArray = intArrayOf(find(nums, target) { it < target }, find(nums, target) { it <= target }) private fun find(nums: IntArray, target: Int, evaluato...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,316
coding
MIT License
src/day04/Day04.kt
elenavuceljic
575,436,628
false
{"Kotlin": 5472}
package day04 import java.io.File fun main() { fun String.asIntRange() = substringBefore('-').toInt()..substringAfter('-').toInt() infix fun IntRange.contains(other: IntRange) = first <= other.first && last >= other.last infix fun IntRange.overlaps(other: IntRange) = first <= other.last && last...
0
Kotlin
0
0
c5093b111fd02e28823d31f2edddb7e66c295add
1,276
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day6.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.util.stream.Collectors fun day6ProblemReader(string: String): List<List<Set<String>>> { val problemSplit = string.split("\n") val problem = mutableListOf<List<Set<String>>>() var group = mutableListOf<Set<String>>() for (lineCount in problemSplit.indices) { val line = problemSplit[l...
0
Kotlin
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
2,335
adventofcode_2020
MIT License
src/utils/Dijkstra.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package utils import arrow.core.NonEmptyList import arrow.core.nonEmptyListOf import java.util.PriorityQueue fun <T> findShortestRoute( map: List<List<T>>, start: Point, end: Point, includeDiagonalRoutes: Boolean = false, movementCost: (movementStart: MapDetails<T>, movementEnd: MapDetails<T>) -> ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
3,446
Advent-of-Code
Apache License 2.0
src/main/aoc2020/Day20.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 import Direction import Grid import Pos import xRange import yRange class Day20(input: List<String>) { private data class Tile(val id: Long, val data: Grid) { var rotation: Grid.Transformation.Rotation = Grid.Transformation.NoRotation var flip: Grid.Transformation.Flip = Grid.Tran...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
5,830
aoc
MIT License
src/Day01.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
fun main() { fun splitInput(input: List<String>): List<List<String>> { val result = mutableListOf<List<String>>() var current = mutableListOf<String>() for (line in input) { if (line == "") { result.add(current) current = mutableListOf() ...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
978
advent-of-code-kotlin-2022
Apache License 2.0
jvm/src/main/kotlin/io/prfxn/aoc2021/day06.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Lanternfish (https://adventofcode.com/2021/day/6) package io.prfxn.aoc2021 fun main() { val initialCountsByDaysUntilRepro = textResourceReader("input/06.txt").readText().trim().split(",") .map { it.toInt() } .groupBy { it } .map { (daysUntilRepro, instances) -> ...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
1,307
aoc2021
MIT License
codeforces/round580/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round580 fun main() { val n = readInt() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (a, b) = readInts().map { it - 1 } nei[a].add(b) nei[b].add(a) } nei.indices.flatMap { v -> val (sizes, vertices) = nei[v].map { Pair(dfs(it, setOf(v), 0, nei), it) }.sortedBy { it.fir...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
970
competitions
The Unlicense
src/day11/Day11.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
@file:Suppress("MagicNumber") package day11 import readInput fun main() { data class Monkey( val number: Int, val items: MutableList<Item>, val operation: (Long) -> Long, val testValue: Int, val favoredMonkey: Int, val hatedMonkey: Int, var inspectCount: Lo...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
4,447
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day17.kt
clechasseur
567,968,171
false
{"Kotlin": 493887}
package io.github.clechasseur.adventofcode.y2022 import io.github.clechasseur.adventofcode.util.Direction import io.github.clechasseur.adventofcode.util.Pt import io.github.clechasseur.adventofcode.y2022.data.Day17Data object Day17 { private val shapes = Day17Data.shapes.map { it.toShape() } private const val...
0
Kotlin
0
0
7ead7db6491d6fba2479cd604f684f0f8c1e450f
3,800
adventofcode2022
MIT License
src/main/kotlin/symbolik/parser/tokenize.kt
Andlon
55,359,009
false
null
package symbolik.parser class TokenizationException(message: String) : Exception(message) fun tokenize(str: String) : List<Token> = processUnaryOperators(recursivelyTokenize(emptyList(), str)) tailrec private fun recursivelyTokenize(tokens: List<Token>, remaining: String): List<Token> { // By ignoring leading wh...
0
Kotlin
0
0
9711157eda9a56ba622475bf994cef8ff9d16946
2,635
symbolik
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/Intersection.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
3,227
kotlab
Apache License 2.0
src/main/kotlin/solved/p672/Solution.kt
mr-nothing
469,475,608
false
{"Kotlin": 162430}
package solved.p672 class Solution { class BruteForceSolution { // This was the first idea: generate all possible combinations of button presses // and simulate it on given bulbs. Clearly it does't fit any time limits :D fun flipLights(n: Int, presses: Int): Int { val states = H...
0
Kotlin
0
0
0f7418ecc8675d8361ef31cbc1ee26ea51f7708a
4,304
leetcode
Apache License 2.0
src/main/kotlin/aoc2021/Day19.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import kotlin.math.abs import kotlin.math.max private enum class Axis { X, Y, Z } private const val OVERLAPPING_BEACONS_REQUIRED = 12 /** * A beacon scanner * * @property name the name of the scanner * @property beacons the position of all beacons within range of this scanner, w...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
7,290
adventOfCode
Apache License 2.0
src/test/kotlin/amb/aoc2020/day16.kt
andreasmuellerbluemlein
318,221,589
false
null
package amb.aoc2020 import org.junit.jupiter.api.Test class Day16 : TestBase() { data class Input( var validValues: Map<String, List<Int>>, var myTicket: List<Int>, var nearbyTickets: List<List<Int>> ) fun getInput(file: String): Input { val validValues = emptyMap<String...
1
Kotlin
0
0
dad1fa57c2b11bf05a51e5fa183775206cf055cf
4,130
aoc2020
MIT License
src/main/kotlin/y2016/day02/Day02.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2016.day02 import AoCGenerics fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } fun input(): List<String> { return AoCGenerics.getInputLines("/y2016/day02/input.txt") } val SQUARE_FIELD = listOf( listOf(1, 2, 3), listOf(4, 5, 6...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,648
AdventOfCode
MIT License
src/Day04.kt
felldo
572,233,925
false
{"Kotlin": 76496}
fun main() { val testInput = readInput("Day04") val input = testInput .map { it.split(",") } .map { listOf( Pair(it[0].split("-")[0].toInt(), it[0].split("-")[1].toInt()), Pair(it[1].split("-")[0].toInt(), it[1].split("-")[1].toInt()) ) ...
0
Kotlin
0
0
0ef7ac4f160f484106b19632cd87ee7594cf3d38
727
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/g1001_1100/s1001_grid_illumination/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1001_grid_illumination // #Hard #Array #Hash_Table #2023_05_14_Time_801_ms_(100.00%)_Space_121_MB_(100.00%) class Solution { fun gridIllumination(n: Int, lamps: Array<IntArray>, queries: Array<IntArray>): IntArray { val rowIlluminations: MutableMap<Int, Int> = HashMap() val col...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,619
LeetCode-in-Kotlin
MIT License
kotlin/src/main/kotlin/be/swsb/aoc2023/day6/Day6.kt
Sch3lp
724,797,927
false
{"Kotlin": 44815, "Rust": 14075}
package be.swsb.aoc2023.day6 fun parse(input: String): Races { val (times, distances) = input.lines() .map { line -> """\d{1,4}""".toRegex().findAll(line).map { it.value.toLong() } } return Races(times.zip(distances).toList()) } fun parse2(input: String): Races { val (time, distance) = input.lines...
0
Kotlin
0
1
dec9331d3c0976b4de09ce16fb8f3462e6f54f6e
1,086
Advent-of-Code-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/codingbat/recursion2/GroupSum5.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <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
3,222
kotlab
Apache License 2.0
src/Day03/Day03.kt
brhliluk
572,914,305
false
{"Kotlin": 16006}
fun main() { val backpackItems = ('a'..'z' union 'A'..'Z') val itemValues = (1..52).toMutableList() val valuedItems = backpackItems.associateWith { itemValues.removeFirst() } var totalGroupValue = 0 fun part1(input: List<String>) = input.map { backpack -> val firstHalf = backpack.take(backp...
0
Kotlin
0
0
96ac4fe0c021edaead8595336aad73ef2f1e0d06
868
kotlin-aoc
Apache License 2.0
src/commonMain/kotlin/io/github/z4kn4fein/semver/constraints/ComparatorBuilder.kt
z4kn4fein
444,514,222
false
{"Kotlin": 112810, "CSS": 380}
package io.github.z4kn4fein.semver.constraints import io.github.z4kn4fein.semver.Version import io.github.z4kn4fein.semver.nextMajor import io.github.z4kn4fein.semver.nextMinor import io.github.z4kn4fein.semver.nextPatch internal interface ComparatorBuilder { val acceptedOperators: Array<String> fun buildComp...
0
Kotlin
0
76
ad9da0fc82a213acbb0e1b174db05c0fa0e8f2ba
4,481
kotlin-semver
MIT License
src/main/kotlin/g0001_0100/s0023_merge_k_sorted_lists/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0023_merge_k_sorted_lists // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Heap_Priority_Queue #Linked_List // #Divide_and_Conquer #Merge_Sort #Big_O_Time_O(k*n*log(k))_Space_O(log(k)) // #2023_07_03_Time_198_ms_(93.77%)_Space_37.6_MB_(97.03%) import com_github_leetcode.ListNode /* * ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,211
LeetCode-in-Kotlin
MIT License
src/main/kotlin/uk/co/skipoles/eventmodeller/visualisation/render/CenteredMultiLineStringRenderer.kt
skipoleschris
506,202,133
false
{"Kotlin": 119832}
package uk.co.skipoles.eventmodeller.visualisation.render import java.awt.Graphics2D import java.awt.geom.Rectangle2D internal fun Graphics2D.drawCentredMultiLineString( s: String, x: Int, y: Int, width: Int, height: Int ) { val lines = divideIntoLines("", s, width, areaForString(this)) val li...
0
Kotlin
0
0
4e7fe756d0c203cd7e781cc40c2b16776aa9f3ab
2,877
event-modeller
Apache License 2.0
src/main/java/io/github/lunarwatcher/aoc/day10/Day10.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day10 import io.github.lunarwatcher.aoc.commons.Vector2i import io.github.lunarwatcher.aoc.commons.readFile val regex = "pos=<(-?\\d*),(-?\\d*)>velocity=<(-?\\d*),(-?\\d*)>".toRegex(); fun parseVectors(raw: List<String>) : List<Pair<Vector2i, Vector2i>>{ return raw.map { ...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
2,809
AoC-2018
MIT License
src/iii_conventions/MyDate.kt
splendie
104,372,378
false
null
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int { if (this.year < other.year) return -1 else if (this.year > other.year) return 1 else { if (th...
0
Kotlin
0
0
44f5da525b197525508bf5e6063a32b48cd52530
2,424
kotlin_koans_exercise
MIT License
src/Day14.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
enum class CaveType(val char: Char) { OPEN('.'), ROCK('#'), SAND('o') } class Cave { val data = mutableMapOf<Coordinate, CaveType>() private val left: Int get() = data.keys.minOf { it.x } private val right: Int get() = data.keys.maxOf { it.x } private val top: Int ...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
3,945
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/src/main/kotlin/de/p58i/advent-08.kt
mspoeri
573,120,274
false
{"Kotlin": 31279}
package de.p58i import java.io.File data class Tree( val height: Int ) { var visible: Boolean = false var scenicScore: Int = 0 } val lowTree = Tree(-1) fun main() { val forest = ArrayList<Array<Tree>>() File("./task-inputs/advent-08.input").forEachLine { forest.add( it...
0
Kotlin
0
1
62d7f145702d9126a80dac6d820831eeb4104bd0
4,611
Advent-of-Code-2022
MIT License
src/Day06.kt
afranken
572,923,112
false
{"Kotlin": 15538}
fun main() { fun part1(input: List<String>): Int { val count = 4 return input[0] .windowed(count) .mapIndexed { index, chunk -> if (chunk.toSet().size == count) { index + count } else { ...
0
Kotlin
0
0
f047d34dc2a22286134dc4705b5a7c2558bad9e7
1,109
advent-of-code-kotlin-2022
Apache License 2.0
aoc2023/day10.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2023 import utils.InputRetrieval fun main() { Day10.execute() } private object Day10 { fun execute() { val input = readInput() val foundPositions = mutableMapOf<Position, Int>() println("Part 1: ${part1(input, foundPositions)}") println("Part 2: The answer is one of...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
7,353
Advent-Of-Code
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day15.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 15 - Lens Library * Problem Description: http://adventofcode.com/2023/day/15 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day15/ */ package com.ginsberg.advent2023 class Day15(input: String) { private val inst...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
1,279
advent-2023-kotlin
Apache License 2.0
src/main/kotlin/pl/klemba/aoc/day10/Main.kt
aklemba
726,935,468
false
{"Kotlin": 16373}
package pl.klemba.aoc.day10 import java.io.File fun main() { // ----- PART 1 ----- val pipeField = File(inputPath) .readLines() // Find starting point val startingIndex: Coordinates = pipeField.findStartingIndex() println("Starting index: ${startingIndex}") // Find one of the pipes that create the l...
0
Kotlin
0
1
2432d300d2203ff91c41ffffe266e19a50cca944
4,155
adventOfCode2023
Apache License 2.0
src/main/kotlin/g2801_2900/s2858_minimum_edge_reversals_so_every_node_is_reachable/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2858_minimum_edge_reversals_so_every_node_is_reachable // #Hard #Dynamic_Programming #Depth_First_Search #Breadth_First_Search #Graph // #2023_12_21_Time_1161_ms_(100.00%)_Space_139.8_MB_(100.00%) import java.util.LinkedList import java.util.Queue class Solution { fun minEdgeReversals(n: Int,...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,744
LeetCode-in-Kotlin
MIT License
src/main/aoc2020/Day4.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 class Day4(input: List<String>) { private data class Field(private val key: String, private val value: String) { private fun String.splitAt(index: Int) = take(index) to substring(index) fun isMandatory() = key != "cid" fun isValid() = when (key) { "byr" -> value...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,721
aoc
MIT License
src/main/kotlin/BeaconScanner_19.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
import kotlin.math.abs val scanners: List<Scanner> by lazy { val lines = readFile("BeaconScanner").split("\n") val scanners = mutableListOf<Scanner>() var curLine = 1 var curScanerId = 0 var curBeacons = mutableListOf<V3>() var curScanner = Scanner(curScanerId, curBeacons) while (curLine < ...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
3,609
advent-of-code-2021
Apache License 2.0
src/Day01.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
fun main() { fun List<String>.sumSplit(predicate: (String) -> Boolean): List<Int> { if (this.isEmpty()) return listOf() val left = this.takeWhile(predicate).sumOf { it.toInt() } val right = this.dropWhile(predicate).drop(1) return listOf(left) + right.sumSplit(predicate) } ...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
718
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/aoc2020/day3/Forest.kt
arnab
75,525,311
false
null
package aoc2020.day3 object Forest { /** * Forest is organized as a 2D array where, Y -> 1st dim, X -> 2nd dim. * Each spot can be analyzed with [isOccupied] to see if there is a tree there. */ fun parse(data: String): List<List<Char>> = data.split("\n") .reversed() ...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,891
adventofcode
MIT License
src/day01/Day01.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day01 import readInput fun main() { fun batchSumAndSort(input: List<String>): List<Int> { val batches = mutableListOf<List<String>>() val currList = mutableListOf<String>() input.forEach { entry -> if (entry == "") { batches.add(currList.toList()) ...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
1,112
advent-of-code-2022
Apache License 2.0
src/Day04.kt
thelmstedt
572,818,960
false
{"Kotlin": 30245}
import java.io.File typealias Range = Pair<Int, Int> fun main() { fun range(l: String): Range { val (l1, l2) = l.split("-") return Pair(l1.toInt(), l2.toInt()) } fun fullyContains(r1: Range, r2: Range): Boolean { val rr1 = (r1.first..r1.second).toSet() val rr2 = (r2.firs...
0
Kotlin
0
0
e98cd2054c1fe5891494d8a042cf5504014078d3
1,292
advent2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day22.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.extensions.intersect import tr.emreone.kotlin_utils.extensions.intersects import tr.emreone.kotlin_utils.extensions.size class Day22 : Day(22, 2021, "Reactor Reboot") { private class Cuboid(val on: ...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
2,293
advent-of-code-2021
Apache License 2.0
src/Day03.kt
daletools
573,114,602
false
{"Kotlin": 8945}
fun main() { fun part1(input: List<String>): Int { var score = 0 for (line in input) { val pockets = line.chunked(line.length / 2) for (char in pockets[0]) { if (pockets[1].contains(char)) { score += char.lowercaseChar() - '`' ...
0
Kotlin
0
0
c955c5d0b5e19746e12fa6a569eb2b6c3bc4b355
1,286
adventOfCode2022
Apache License 2.0
src/day16/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day16 import util.extractStringGroups import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 1651 testInput.part2() shouldBe 1707 val input = readInput(Input::class).parseInput() println("ou...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
5,944
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TwoSum4.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,675
kotlab
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Extensions.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 import kotlin.math.max import kotlin.math.min import kotlin.math.pow fun <T> Iterable<T>.chunkedBy(separator: (T) -> Boolean): List<List<T>> = fold(mutableListOf(mutableListOf<T>())) { acc, t -> if (separator(t)) { acc.add(mutableListOf()) } else { ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
4,373
advent-2023
MIT License
src/day10/Day10.kt
robin-schoch
572,718,550
false
{"Kotlin": 26220}
package day10 import AdventOfCodeSolution fun main() { Day10.run() } object Day10 : AdventOfCodeSolution<Int, Unit> { override val testSolution1 = 13140 override val testSolution2 = Unit private operator fun String.component1() = split(" ")[0] private operator fun String.component2() = split(" ...
0
Kotlin
0
0
fa993787cbeee21ab103d2ce7a02033561e3fac3
1,797
aoc-2022
Apache License 2.0
src/main/kotlin/Day6.kt
ivan-gusiev
726,608,707
false
{"Kotlin": 34715, "Python": 2022, "Makefile": 50}
import util.AocDay import util.AocInput import java.math.BigInteger typealias Day6InputType = List<String>; class Day6 : Runner { var TEST_INPUT = """ Time: 7 15 30 Distance: 9 40 200 """.trimIndent() data class TimeDistance(val time: BigInteger, val distance: BigInteger) { ...
0
Kotlin
0
0
5585816b435b42b4e7c77ce9c8cabc544b2ada18
2,696
advent-of-code-2023
MIT License
lab10/src/main/kotlin/cs/put/pmds/lab10/MinHash.kt
Azbesciak
153,350,976
false
null
package cs.put.pmds.lab10 import java.util.Random import kotlin.math.min data class HashFunction(val a: Long, val b: Long, val mod: Int = LARGE_PRIME) { companion object { private const val LARGE_PRIME = 1299827 infix fun create(r: Random) = HashFunction(nextVal(r), nextVal(r)) private fun...
0
Kotlin
0
0
f1d3cf4d51ad6588e39583f7b958c92b619799f8
1,902
BigDataLabs
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/SumOfDistancesInTree.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,836
kotlab
Apache License 2.0
src/main/kotlin/com/rtarita/days/Day9.kt
RaphaelTarita
570,100,357
false
{"Kotlin": 79822}
package com.rtarita.days import com.rtarita.structure.AoCDay import com.rtarita.util.day import com.rtarita.util.sign import kotlinx.datetime.LocalDate import kotlin.math.abs import kotlin.math.max object Day9 : AoCDay { private data class Coord(val x: Int, val y: Int) override val day: LocalDate = day(9) ...
0
Kotlin
0
9
491923041fc7051f289775ac62ceadf50e2f0fbe
3,073
AoC-2022
Apache License 2.0
app/src/main/kotlin/io/github/andrewfitzy/day04/Task01.kt
andrewfitzy
747,793,365
false
{"Kotlin": 60159, "Shell": 1211}
package io.github.andrewfitzy.day04 class Task01(puzzleInput: List<String>) { private val input: List<String> = puzzleInput fun solve(): Int { var checksumTotal = 0 for (entry in input) { val splits = entry.split("-") val name = splits.subList(0, splits.size - 1).joinTo...
0
Kotlin
0
0
15ac072a14b83666da095b9ed66da2fd912f5e65
1,443
2016-advent-of-code
Creative Commons Zero v1.0 Universal
year2023/src/main/kotlin/net/olegg/aoc/year2023/day16/Day16.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day16 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions import net.olegg.aoc.utils.Directions.D import net.olegg.aoc.utils.Directions.L import net.olegg.aoc.utils.Directions.R import net.olegg.aoc.utils.Directions.U import net.olegg.aoc.utils.Vector2D import net....
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,591
adventofcode
MIT License
src/Day02.kt
matheusfinatti
572,935,471
false
{"Kotlin": 12612}
import kotlin.math.abs fun main() { val input = readInput("Day02").trim().split("\n") input .map { round -> round.split(" ").map(String::single) } .map { round -> listOf(round[0] - 'A', round[1] - 'X') } .also { game -> game.sumOf { round -> val (p1, p2) = r...
0
Kotlin
0
0
a914994a19261d1d81c80e0ef8e196422e3cd508
1,794
adventofcode2022
Apache License 2.0
logicsolver/src/main/kotlin/nl/hiddewieringa/logicsolver/Strategy.kt
hiddewie
147,922,971
false
null
package nl.hiddewieringa.logicsolver /** * A conclusion is either a found value, or a value which is not allowed somewhere */ typealias Conclusion = OneOf<Value, NotAllowed> fun concludeNotAllowed(coordinate: Coordinate, value: Int): Conclusion { return OneOf.right(NotAllowed(coordinate, value)) } fun <T> Coll...
0
Kotlin
0
0
bcf12c102f4ab77c5aa380dbf7c98a1cc3e585c0
10,128
LogicSolver
MIT License
day_07/src/main/kotlin/io/github/zebalu/advent2020/BagRuleReader.kt
zebalu
317,448,231
false
null
package io.github.zebalu.advent2020 typealias Rules = Map<String, Set<Pair<Int, String>>> object BagRuleReader { fun readRules(lines: List<String>): Rules { val result = mutableMapOf<String, MutableSet<Pair<Int, String>>>() lines.forEach { line -> val parts = line.split(" bags contain ") val type = parts...
0
Kotlin
0
1
ca54c64a07755ba044440832ba4abaa7105cdd6e
1,813
advent2020
Apache License 2.0
src/Day02.kt
derkalaender
433,927,806
false
{"Kotlin": 4155}
fun main() { class Values(var x: Int, var y: Int, var aim: Int) fun part1(input: List<String>): Int { return input .map { l -> l.split(' ').let { Pair(it[0], it[1].toInt()) } } .fold(Values(0, 0, 0)) { acc, cmd -> when (cmd.first) { "forward" ...
0
Kotlin
0
0
bf258ea0cf7cada31288a91d2204d5c7b3492433
1,437
aoc2021
The Unlicense
src/main/kotlin/ProblemSolution.kt
YaroslavGamayunov
299,554,569
false
null
import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.math.min /** * The problem: * Given a regex in Reverse Polish Notation and numbers k and l satisfying the property: 0 <= l < k * The task is to find minimal n which equals to l modulo k * such that language of re...
0
Kotlin
0
0
8fb282f5be75fc8b7e0ff999fcd9e419860aea15
1,535
FiniteStateMachine
MIT License
kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/longs.kt
dave08
371,333,515
true
{"Kotlin": 2920151, "CSS": 352, "Java": 145}
package io.kotest.property.arbitrary import io.kotest.property.Arb import io.kotest.property.Shrinker import kotlin.math.abs import kotlin.random.nextLong import kotlin.random.nextULong /** * Returns an [Arb] that produces [Long]s, where the edge cases are [min], -1, 0, 1 and [max]. * -1, 0 and 1 will only be inclu...
0
Kotlin
0
0
77ce26af5690956fc29b8adf4ff14abbdda188ec
2,766
kotest
Apache License 2.0
kotlin/1968-array-with-elements-not-equal-to-average-of-neighbors.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
/* * O(nlogn) solution (similar to wiggle sort) */ class Solution { fun rearrangeArray(nums: IntArray): IntArray { nums.sort() val res = IntArray(nums.size) var i = 0 var left = 0 var right = nums.lastIndex while (i < res.size) { res[i++] = nums[left++] ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
938
leetcode
MIT License
advent-of-code2015/src/main/kotlin/day16/Advent16.kt
REDNBLACK
128,669,137
false
null
package day16 import parseInput import splitToLines /** --- Day 16: Aunt Sue --- Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. However, there's a small problem: she signed it "From, <NAME>". You have 500 Aunts named "Sue". So, to avoid sending the card to the wrong pers...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,907
courses
MIT License
test/leetcode/PrisonCellsAfterNDays.kt
andrej-dyck
340,964,799
false
null
package leetcode import lib.* import misc.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.* import org.junit.jupiter.params.converter.* import org.junit.jupiter.params.provider.* /** * https://leetcode.com/problems/prison-cells-after-n-days/ * * 957. Prison Cells After N Days *...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
3,639
coding-challenges
MIT License
src/Day02.kt
gylee2011
573,544,473
false
{"Kotlin": 9419}
import day02.* fun main() { fun part1(input: List<String>): Int = input .map(String::toShapePair) .sumOf { (opponent, me) -> Outcome.of(opponent, me).score + me.score } fun part2(input: List<String>): Int = input .map { val (opponent, expectedOutcome) = ...
0
Kotlin
0
0
339e0895fd2484b7f712b966a0dae8a4cfebc2fa
957
aoc2022-kotlin
Apache License 2.0
app/src/main/kotlin/solution/Solution947.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode class Solution947 { @Leetcode(947) class Solution { fun removeStones(stones: Array<IntArray>): Int { // union find. remove all connected components val N = stones.size val parents = IntArray(N) { -1 } ...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
3,919
leetcode-kotlin
MIT License
src/main/kotlin/day02/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day02 import java.io.File fun main() { val lines = File("src/main/kotlin/day02/input.txt").readLines() val submarineV1 = lines .fold(SubmarineV1()) { submarine, commandString -> submarine.execute(commandString.toCommand()) } println(submarineV1.x * submarineV1.y) ...
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
1,545
aoc-2021
MIT License
src/Day17.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
import kotlin.math.absoluteValue suspend fun main() { val testInput = readInput("Day17_test") check(part1(testInput.first()) == 3068) check(part2(testInput.first()) == 1514285714288L) val input = readInput("Day17") measureAndPrintResult { part1(input.first()) } measureAndPrintResul...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
3,864
aoc-22
Apache License 2.0
code-sample-kotlin/algorithms/src/main/kotlin/com/codesample/leetcode/medium/22_generateParentheses.kt
aquatir
76,377,920
false
{"Java": 674809, "Python": 143889, "Kotlin": 112192, "Haskell": 57852, "Elixir": 33284, "TeX": 20611, "Scala": 17065, "Dockerfile": 6314, "HTML": 4714, "Shell": 387, "Batchfile": 316, "Erlang": 269, "CSS": 97}
package com.codesample.leetcode.medium import java.lang.StringBuilder /** 22. Generate Parentheses https://leetcode.com/problems/generate-parentheses/ * * Given n, output every correct parenthesis sequence with size 2*n. Input should be sorted lexicographically * e.g: * n = 1: () * n = 2: (()),()() * n = 3: (((...
1
Java
3
6
eac3328ecd1c434b1e9aae2cdbec05a44fad4430
1,393
code-samples
MIT License
aoc2022/day14.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval fun main() { Day14.execute() } object Day14 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: Set<Pair<Int, Int>>): Int { val map = in...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
3,990
Advent-Of-Code
MIT License