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/Day14.kt
syncd010
324,790,559
false
null
class Day14: Day { data class ChemSpec(val element: String, var quantity: Long) private fun convert(input: List<String>) : Map<ChemSpec, List<ChemSpec>> { return input.associate { line: String -> val spec = line.split(" => ") val outElement = spec[1].split(" ") val i...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
2,611
AoC2019
Apache License 2.0
src/main/kotlin/Day03.kt
robfletcher
724,814,488
false
{"Kotlin": 18682}
import kotlin.math.max import kotlin.math.min class Day03 : Puzzle { override fun test() { val input = """ 467..114.. ...*...... ..35..633. ......#... 617*...... .....+.58. ..592..... ......755. ...\$.*.... .664.598..""".trimIndent() assert(part1(i...
0
Kotlin
0
0
cf10b596c00322ea004712e34e6a0793ba1029ed
1,810
aoc2023
The Unlicense
src/main/kotlin/dev/tasso/adventofcode/_2022/day07/Day07.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2022.day07 import dev.tasso.adventofcode.Solution class Day07 : Solution<Int> { override fun part1(input: List<String>): Int = input.asSequence() .chunkedByCommand() .drop(1) .fold(FileSystemNode("/", "dir")) { currNode , command -> ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
4,218
advent-of-code
MIT License
src/test/kotlin/Solution001.kt
cia-exe
331,877,092
false
null
import org.junit.jupiter.api.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.api.TestMethodOrder import org.junit.jupiter.api.MethodOrderer.OrderAnnotation import java.util.* import java.util.AbstractMap.SimpleEntry internal class Solution410 { @Test ...
0
Kotlin
0
0
5e5731c1ca55c68eb40722c035d2d9e28c190281
22,193
LeetCode
Apache License 2.0
src/main/kotlin/suggestions/KtSuggestions2.kt
hermannhueck
46,933,495
false
{"Java": 53536, "Scala": 43388, "Kotlin": 4114}
@file:JvmName("KtSuggestions2") package suggestions private val MAX_WORDS = 13 data class Suggestion2(val text: String) { override fun toString() = text } private val INPUT = listOf("The", "moon", "is", "not", "a", "planet", "and", "also", "not", "a", "star", ".", "But", ",", "I", "digress", "we", "peop...
0
Java
0
0
4ff6af70ecec5847652fb593b9d70cde7db5256d
1,996
BrainTwisters
Apache License 2.0
src/Day03.kt
haitekki
572,959,197
false
{"Kotlin": 24688}
fun main() { fun part1(input: String): Int { return input.lines().map { Pair( it.subSequence(0, it.length/2), it.subSequence(it.length/2, it.length) ).let { pair -> var number = 0 for (fChar in pair.first) { ...
0
Kotlin
0
0
b7262133f9115f6456aa77d9c0a1e9d6c891ea0f
1,774
aoc2022
Apache License 2.0
src/Day03.kt
bromhagen
572,988,081
false
{"Kotlin": 3615}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> line.substring(0, line.length/2).toSet() .intersect(line.substring(line.length/2).toSet()) .map { char -> char.code - if (char.isUpperCase()) 38 else 96 ...
0
Kotlin
0
0
0ee6d96e790d9ebfab882351b3949c9ba372cb3e
885
advent-of-code
Apache License 2.0
src/aoc2017/kot/Day03.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import itertools.cartProd object Day03 { fun partOne(input: Int): Int { val size = Math.ceil(Math.sqrt(input.toDouble())).toInt() val start: Pair<Int, Int> = Pair(size / 2, size / 2) var len = 1 var x = start.first var y = start.second var value = 1 loop@ while (tru...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,805
Advent_of_Code
MIT License
src/day21/d21_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
import kotlin.math.* val weapons = listOf( Item("Dagger", 8, 4, 0), Item("Shortsword", 10, 5, 0), Item("Warhammer", 25, 6, 0), Item("Longsword", 40, 7, 0), Item("Greataxe", 74, 8, 0) ) val armors = listOf( Item("Leather", 13, 0, 1), Item("Chainmail", 31, 0, 2), Item("Splintmail", 53, 0, 3...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,803
aoc2015
MIT License
src/test/kotlin/Day03.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.datatest.forAll import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe /* --- Day 3: Toboggan Trajectory --- See https://adventofcode.com/2020/day/3 */ fun parseTreeArray(input: String): TobogganTreeArray = TobogganTreeArray( input.split("\n").map { it.trim()....
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
3,146
advent_of_code_2020
Apache License 2.0
src/Day12.kt
carotkut94
572,816,808
false
{"Kotlin": 7508}
fun main() { val input = readInput("Day12") lateinit var start: Pair<Int, Int> // starting indexes lateinit var end: Pair<Int, Int> // target indexes val allA: MutableList<Pair<Int, Int>> = mutableListOf() // all positions with minimum elevation val grid = buildList { input.forEach { ...
0
Kotlin
0
0
ef3dee8be98abbe7e305e62bfe8c7d2eeff808ad
2,336
aoc-2022
Apache License 2.0
src/Day15/December15.kt
Nandi
47,216,709
false
null
package Day15 import java.nio.file.Files import java.nio.file.Paths import java.util.* import java.util.stream.Stream /** * Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to do is find the right * balance of ingredients. * * Your recipe leaves room for exactly 100 teasp...
0
Kotlin
0
0
34a4b4c0926b5ba7e9b32ca6eeedd530f6e95bdc
4,794
adventofcode
MIT License
src/Day02.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
fun main() { fun part1(input: List<String>): Int = input.sumOf { line -> val (a, b) = line.split(" ") when (b) { "X" -> 1 + when (a) { "A" -> 3 "B" -> 0 "C" -> 6 else -> error("") ...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
1,800
AdventOfCode
Apache License 2.0
src/Day01.kt
Redstonecrafter0
571,787,306
false
{"Kotlin": 19087}
fun main() { fun parse(input: List<String>): List<Int> { val separators = listOf(-1) + input.withIndex().filter { it.value == "" }.map { it.index } + (input.lastIndex + 1) val elves = separators.windowed(2).map { input.subList(it[0] + 1, it[1]) } return elves.map { it.sumOf { i -> i.toInt()...
0
Kotlin
0
0
e5dbabe247457aabd6dd0f0eb2eb56f9e4c68858
843
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2021/Day12.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day12: AdventDay(2021, 12) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day12() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
1,653
adventofcode
MIT License
src/Day03.kt
xiaofeiMophsic
575,326,884
false
null
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val half = it.length / 2 val firstComp = it.substring(0, half) val secondComp = it.substring(half) val result: Int = firstComp.find { c -> secondComp.contains(c, false) }?.let { common ...
0
Kotlin
0
0
13e5063928c0eb6416ce266e2083816ca78b8240
1,683
aoc-kotlin
Apache License 2.0
src/day14/Code.kt
fcolasuonno
572,734,674
false
{"Kotlin": 63451, "Dockerfile": 1340}
package day14 import Coord import day06.main import readInput fun main() { operator fun Coord.rangeTo(other: Coord) = (minOf(first, other.first)..maxOf(first, other.first)).flatMap { x -> (minOf(second, other.second)..maxOf(second, other.second)).map { y -> Coord(x, y) } } fun String.toCoord() = ...
0
Kotlin
0
0
9cb653bd6a5abb214a9310f7cac3d0a5a478a71a
2,136
AOC2022
Apache License 2.0
src/main/kotlin/aoc2022/Day13.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.IntNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue private val...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
3,125
aoc-2022-kotlin
Apache License 2.0
src/day07/Day07.kt
EdwinChang24
572,839,052
false
{"Kotlin": 20838}
package day07 import readInput fun main() { part1() part2() } fun part1() = common { sizes -> println(sizes.sumOf { if (it <= 100000) it else 0 }) } fun part2() = common { sizes -> val currentFree = 70000000 - sizes.max() println(sizes.filter { currentFree + it >= 30000000 }.min()) } fun common...
0
Kotlin
0
0
e9e187dff7f5aa342eb207dc2473610dd001add3
1,958
advent-of-code-2022
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day2/Day2.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day2 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 2](https://adventofcode.com/2023/day/2) */ object Day2 : DayOf2023(2) { private val GAME_PATTERN = "Game \\d+: ".toRegex() override fun fi...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,340
adventofcode
MIT License
src/main/kotlin/com/chriswk/aoc/advent2022/Day7.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2022 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day7: AdventDay(2022, 7) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day7() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,814
adventofcode
MIT License
src/Day10.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
fun main() { fun createRegister(inputs: List<String>): Register { val register = Register() for (s in inputs) { if (s == "noop") { register.addInstruction(Instruction("noop", 0)) } else { register.addInstruction(Instruction("addx", s.split(" "...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
2,188
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
arhor
572,349,244
false
{"Kotlin": 36845}
fun main() { val input = readInput {} println("Part 1: " + solvePuzzle(input, tailSize = 1)) println("Part 2: " + solvePuzzle(input, tailSize = 9)) } private fun solvePuzzle(input: List<String>, tailSize: Int): Int { val rope = MutableList(1 + tailSize) { Point(0, 0) } val visited = HashSet<Point>...
0
Kotlin
0
0
047d4bdac687fd6719796eb69eab2dd8ebb5ba2f
1,476
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
enum class Sign(val value: Int, val symbol: Char) { rock(1, 'A'), paper(2, 'B'), scissors(3, 'C'); companion object { infix fun from(value: Int): Sign { return Sign.values().first { it.value == value } } infix fun from(symbol: Char): Sign { return Sign.v...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
2,249
2022-aoc-kotlin
Apache License 2.0
src/day17/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day17 import day17.MoveDirection.* import util.readInput import util.repeatingIterator import util.shouldBe import kotlin.math.max fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 3068 testInput.part2() shouldBe 1514285714288L val ...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
4,894
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day6/Six.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day6 import com.tonnoz.adventofcode23.utils.readInput import com.tonnoz.adventofcode23.utils.transpose import kotlin.math.floor import kotlin.math.max import kotlin.math.sqrt object Six { @JvmStatic fun main(args: Array<String>) { val input = "inputSix.txt".readInput() pr...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,201
adventofcode23
MIT License
src/Day03.kt
jorander
571,715,475
false
{"Kotlin": 28471}
fun main() { val day = "Day03" fun List<String>.findCommonChar() = this.drop(1).fold(this.first().toSet()) { acc, s -> s.toSet().intersect(acc) }.first() fun calculatePriority(badge: Char) = if (badge.isLowerCase()) { badge - 'a' + 1 } else { badge - 'A' + ...
0
Kotlin
0
0
1681218293cce611b2c0467924e4c0207f47e00c
1,099
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2020/d10/Day10.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d10 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines private fun joltDifferences(adapters: List<Int>): Map<Int, Int> = mutableMapOf<Int, Int>().apply { adapters.forEachIndexed { i, num -> if (i == 0) { ...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,571
advent-of-code
MIT License
src/Day07.kt
Ramo-11
573,610,722
false
{"Kotlin": 21264}
// Source: https://github.com/DDihanov/Advent-Of-Code-2022-Kotlin/blob/master/src/main/kotlin/day07/Day7.kt package day07 import java.io.File sealed class Directory( open val name: String, open val files: MutableList<DirFile>, open val directories: MutableList<Directory> ) { data class Root( ...
0
Kotlin
0
0
a122cca3423c9849ceea5a4b69b4d96fdeeadd01
4,044
advent-of-code-kotlin
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions03.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round0 fun test3() { val array1 = intArrayOf(2, 3, 1, 0, 2, 5, 3) println("数组 1 重复的数字是:${array1.findRepeat1()}") val array2 = intArrayOf(2, 3, 5, 4, 3, 2, 6, 7) println("数组 2 重复的数字是:${array2.findRepeat2()}") } /** * 题目一:寻找数组中重复的数字,数组长度 n,数字都在 0 ~ n-1 的范围内 */ fun IntAr...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,917
Algorithm
Apache License 2.0
app/src/main/kotlin/solution/Solution952.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode class Solution952 { @Leetcode(952) class Solution { fun largestComponentSize(nums: IntArray): Int { // use prime factor decomposition var maxN = -1 nums.forEach { maxN = kotlin.math.max(it, maxN) } va...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
3,886
leetcode-kotlin
MIT License
baparker/16/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File val VERSION_TYPEID_LENGTH = 3 val BIT_GROUP_SIZE = 4 val LITERAL_GROUP_SIZE = 5 val LENGTH_TYPE_ZERO_SIZE = 15 val LENGTH_TYPE_ONE_SIZE = 11 fun binFromHex(hex: String): String { return String.format( "%" + BIT_GROUP_SIZE + "s", Integer.toBinaryString(In...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
3,384
advent-of-code-2021
MIT License
src/Day23.kt
kipwoker
572,884,607
false
null
import kotlin.time.ExperimentalTime import kotlin.time.measureTime class Day23 { fun parse(input: List<String>): Set<Point> { return input.flatMapIndexed { y, line -> line.mapIndexed { x, c -> if (c == '#') { Point(x, y) } else { ...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
5,964
aoc2022
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[53]最大子序和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import kotlin.math.max //给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 // // 示例: // // 输入: [-2,1,-3,4,-1,2,1,-5,4] //输出: 6 //解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。 // // // 进阶: // // 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 // Related Topics 数组 分治算法 动态规划 // 👍 2807 👎 0 //leetcode submit region begin(Prohibit modific...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,133
MyLeetCode
Apache License 2.0
livingdoc-engine/src/main/kotlin/org/livingdoc/engine/algo/DamerauLevenshtein.kt
pkleimann
91,075,858
true
{"Kotlin": 309171, "Java": 50176, "HTML": 1293}
package org.livingdoc.engine.algo import java.lang.Math.min /** * Calculates the Damerau-Levenshtein distance, a string similarity metric used e.g. by spell checkers. * * By default, the algorithm calculates the minimum number of four different editing operations * required to turn one string into another. The fo...
0
Kotlin
0
0
b81fe455a24ea8cd4b46083d443178039fffb2e3
3,854
livingdoc2
Apache License 2.0
p07/src/main/kotlin/SumOfItsParts.kt
jcavanagh
159,918,838
false
null
package p07 import common.file.readLines import java.util.* import kotlin.NoSuchElementException class Node<T : Comparable<T>>(var value: T, val cost: Int) : Comparable<Node<T>> { //Paths to other nodes var edges = sortedSetOf<Node<T>>() //Paths from other nodes var refs = sortedSetOf<Node<T>>() //A node i...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
4,068
advent2018
MIT License
src/main/kotlin/Excercise23.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet import kotlin.math.abs data class Burrow( val roomSize: Int, val hallway: Map<Int, Char>, val rooms: Map<Int, List<Char>>, ) val roomAssignments = mapOf(2 to 'A', 4 to 'B', 6 to 'C', 8 to 'D') fun getPossibleMoves(burr...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
7,698
advent-of-code-2021
MIT License
leetcode-75-kotlin/src/main/kotlin/GreatestCommonDivisorOfStrings.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * For two strings s and t, * we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). * * Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. * * * * Example 1: * * Input: str1 = "ABCABC", str2 = "ABC" * ...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
965
leetcode-75
Apache License 2.0
src/day09/Day09.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day09 import log import logln import logEnabled import readInput import kotlin.math.abs import kotlin.math.min import kotlin.math.max private const val DAY_NUMBER = 9 data class Offset(val x: Int, val y: Int) enum class Direction(val offset: Offset) { UP(Offset(0, 1)), DOWN(Offset(0, -1)), LEFT...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
3,727
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day8.kt
bfrengley
318,716,410
false
null
package aoc2020.day8 import aoc2020.util.loadTextResource enum class Operation { NOP, ACC, JMP; } data class Instruction(val op: Operation, val arg: Int) { companion object { fun parse(instrStr: String) = Instruction( Operation.valueOf(instrStr.substringBefore(' ').toUpperCase()), ...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,411
aoc2020
ISC License
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day13/Day13.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day13 import eu.janvdb.aocutil.kotlin.point2d.Point2D import eu.janvdb.aocutil.kotlin.readGroupedLines const val FILENAME = "input13.txt" // < 912 fun main() { val groupedLines = readGroupedLines(2021, FILENAME) val sheet = Sheet.create(groupedLines[0]) val instructions = groupedLines[1...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,967
advent-of-code
Apache License 2.0
2022/main/day_14/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_14_2022 import java.io.File tailrec fun placeSandPart1(map: HashMap<Pair<Int, Int>, Boolean>, from: Pair<Int, Int>, xBounds: Pair<Int, Int>, yBound: Int): Boolean { return if ((from.second > yBound) || (from.first !in xBounds.first..xBounds.second)) { false } else if (map[from.first to fro...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
3,994
AdventofCode
MIT License
src/day05/Day05.kt
devEyosiyas
576,863,541
false
null
package day05 import println import readInput import kotlin.collections.ArrayDeque fun main() { fun generateInput( input: List<String>, stack: Int, ): Pair<List<String>, MutableList<ArrayDeque<String>>> { val split = input.joinToString("\n").split("\n\n") val stacksList = spli...
0
Kotlin
0
0
91d94b50153bdab1a4d972f57108d6c0ea712b0e
2,574
advent_of_code_2022
Apache License 2.0
src/org/aoc2021/Day4.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path class Board(boardLines: List<String>) { companion object { const val boardSize = 5 } private val board: List<List<Int>> private val chosenNumbers: Array<Array<Boolean>> = Array(boardSize) { Array(boardSize) { false } } ...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
3,148
advent-of-code-2021
The Unlicense
project/src/problems/PrefixSums.kt
informramiz
173,284,942
false
null
package problems import extensions.toInt import kotlin.math.max import kotlin.math.min object PrefixSums { //https://codility.com/media/train/3-PrefixSums.pdf /** * There is a simple yet powerful technique that allows for the fast calculation of sums of * elements in given slice (contiguous segments...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
20,143
codility-challenges-practice
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumRounds.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,067
kotlab
Apache License 2.0
src/main/kotlin/Day25.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package aoc import kotlin.math.abs import kotlin.math.pow //2-=102--02--=1-12=22 fun solve25A(input: List<String>) = input.sumOf { it.fromSNAFU() }.toSNAFU() fun String.fromSNAFU() = this.reversed().mapIndexed { index, c -> val fiveSquared = 5.0.pow(index) when (c) { '2' -> fiveSquared * 2 '...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
1,621
advent-of-code-2022
Apache License 2.0
src/Day02.kt
colund
573,040,201
false
{"Kotlin": 10244}
enum class RPS(val value: Int) { Rock(1), Paper(2), Scissors(3) } fun main() { data class RockPaperScissors(val rock: Char, val paper: Char, val scissors: Char) { fun toRPS(char: Char) = when (char) { rock -> RPS.Rock paper -> RPS.Paper scissors -> RPS.Scissors ...
0
Kotlin
0
0
49dcd2fccad0e54ee7b1a9cb99df2acdec146759
2,249
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day20.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import kotlin.math.abs // https://adventofcode.com/2022/day/20 object Day20 : AoCDay<Long>( title = "Grove Positioning System", part1ExampleAnswer = 3, part1Answer = 19559, part2ExampleAnswer = 1623178306, part2Answer = 912226207972, ) { private fun parseNumbers(f...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,918
advent-of-code-kotlin
MIT License
src/main/kotlin/fr/o80/aoc/kit/knapsack/Knapsack.kt
olivierperez
310,899,127
false
{"Kotlin": 104427}
package fr.o80.aoc.kit.knapsack import fr.o80.aoc.kit.table.Table /** // Example ``` val packets: List<Packet> = input .filterIndexed { index, _ -> index != 0 } .map(::toPacket) .sortedBy { -it.volume } .toList() val truckSize = packets.sumBy { it.volume } / 2 va...
0
Kotlin
1
2
c92001b5d4651e67e17c20eb8ddc2ac62b14f2c2
2,256
AdventOfCode-KotlinStarterKit
Apache License 2.0
src/Day09.kt
casslabath
573,177,204
false
{"Kotlin": 27085}
import kotlin.math.abs fun main() { fun MutableList<MutableList<Int>>.head(): MutableList<Int> { return this[0] } fun MutableList<MutableList<Int>>.tail(): MutableList<Int> { return this[9] } fun updatedCoords(dir: String): Pair<Int, Int> { return when (dir) { ...
0
Kotlin
0
0
5f7305e45f41a6893b6e12c8d92db7607723425e
3,772
KotlinAdvent2022
Apache License 2.0
src/main/kotlin/com/leetcode/top100LikedQuestions/easy/mergind_two_binaries_tree/Main.kt
frikit
254,842,734
false
null
package com.leetcode.top100LikedQuestions.easy.mergind_two_binaries_tree /** * Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes o...
0
Kotlin
0
0
dda68313ba468163386239ab07f4d993f80783c7
2,466
leet-code-problems
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day12/Day12.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day12 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 12](https://adventofcode.com/2021/day/12) */ object Day12 : DayOf2021(12) { override fun first(): Any? { val edges = lines .map { it.split("-") } .flatMap { l...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,479
adventofcode
MIT License
kotlin-stlc/app/src/main/kotlin/stlc/Constraints.kt
graeme-lockley
540,723,061
false
{"Kotlin": 57141, "TypeScript": 41966, "C": 36472, "Shell": 8245, "Makefile": 679, "Dockerfile": 574}
package stlc typealias Constraint = Pair<Type, Type> data class Constraints(private val constraints: MutableList<Constraint> = mutableListOf()) { fun add(t1: Type, t2: Type) { constraints.add(Pair(t1, t2)) } fun solve(): Subst = solver(constraints) override fun toString(): String = c...
0
Kotlin
0
0
bb29888a15584b9539ba6ae04e112022779b974d
2,233
little-languages
MIT License
shark/shark/src/main/java/shark/ReferenceMatcher.kt
square
34,824,499
false
{"Kotlin": 1430657, "Java": 4762, "Shell": 531, "AIDL": 203}
package shark /** * Used to pattern match known patterns of references in the heap, either to ignore them * ([IgnoredReferenceMatcher]) or to mark them as library leaks ([LibraryLeakReferenceMatcher]). */ sealed class ReferenceMatcher { /** The pattern that references will be matched against. */ abstract val p...
91
Kotlin
4,013
29,004
b3d151194b8501ea85f96d236f7ab2bb7a3e8762
1,933
leakcanary
Apache License 2.0
src/Day04.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day04 { fun part1(input: List<String>): Int{ return input.map { val pair = it.split(",") val a = pair[0].split("-").map { it.toInt() } val b = pair[1].split("-").map { it.toInt() } if (((b[0] >= a[0]).and(b[1] <= a[1])) or ((a[0] >= b[0]).and(a[1] <= b[1...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
1,019
aoc-22-kotlin
Apache License 2.0
src/Day09.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
import kotlin.math.abs import kotlin.math.sign fun main() { infix fun Point.follow(head: Point) { val dx = head.x - x val dy = head.y - y if (abs(dx) > 1 || abs(dy) > 1) { this += Point(dx.sign, dy.sign) } } fun part1(input: List<String>): Int { val he...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,047
aoc-2022
Apache License 2.0
src/Day03.kt
Ajimi
572,961,710
false
{"Kotlin": 11228}
fun main() { fun Char.score() = if (isLowerCase()) { this - 'a' + 1 } else { this - 'A' + 27 } fun part1(input: List<String>): Int = input .map { it.chunked(it.length / 2) } .fold(listOf<Int>()) { acc, (first, second) -> first.forEach { character -> ...
0
Kotlin
0
0
8c2211694111ee622ebb48f52f36547fe247be42
1,090
adventofcode-2022
Apache License 2.0
src/main/kotlin/day4.kt
sviams
726,160,356
false
{"Kotlin": 9233}
object day4 { data class Card(val id: Int, val winning: List<Int>, val mine: List<Int>) { val matches by lazy { mine.intersect(winning) } val value by lazy { if (matches.isEmpty()) 0 else ( 0 until matches.size-1).fold(1) { acc, i -> acc * 2 } } val copie...
0
Kotlin
0
0
4914a54b21e8aac77ce7bbea3abc88ac04037d50
1,141
aoc23
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1383/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1383 import java.util.* /** * LeetCode page: [1383. Maximum Performance of a Team](https://leetcode.com/problems/maximum-performance-of-a-team/); */ class Solution { /* Complexity: * Time O(NLogN) and Space O(N) where N equals n; */ fun maxPerformance(n: Int, ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,706
hj-leetcode-kotlin
Apache License 2.0
src/day7/Day7.kt
blundell
572,916,256
false
{"Kotlin": 38491}
package day7 import readInput data class FileDetails( val name: String, val size: Long, ) data class Directory( val name: String, val parent: Directory?, val directories: MutableList<Directory> = mutableListOf(), val files: MutableList<FileDetails> = mutableListOf(), ) { val size: Long by...
0
Kotlin
0
0
f41982912e3eb10b270061db1f7fe3dcc1931902
4,458
kotlin-advent-of-code-2022
Apache License 2.0
year2023/src/cz/veleto/aoc/year2023/Day08.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.allSame import cz.veleto.aoc.core.leastCommonMultiple class Day08(config: Config) : AocDay(config) { private val nodeRegex = Regex("""^(\w{3}) = \((\w{3}), (\w{3})\)$""") override fun part1(): String { val (ins...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
3,446
advent-of-pavel
Apache License 2.0
src/main/kotlin/Algorithms/MaxSubarraySum/DivideAndConquer.kt
walkmansit
383,766,158
false
null
package Algorithms.MaxSubarraySum class DivideAndConquer { companion object { fun findMaxSubarraySum(array: IntArray): Int { return findMaxSubarrayDiapason(array, 0, array.size - 1).third } private fun findMaxSubarrayDiapason( array: IntArray, low: Int...
0
Kotlin
0
1
2497fccef5ee2eeac08c4e7b79c9faa761736535
2,021
AlgoHub
Apache License 2.0
src/test/kotlin/be/brammeerten/y2023/Day3Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2023 import be.brammeerten.Co import be.brammeerten.readFile import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class Day3Test { @Test fun `part 1`() { val inputLines = readFile("2023/day3/exampleInput.txt") val lines = inputLines ...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
4,080
Advent-of-Code
MIT License
src/day11/a/day11a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day11.a import readInputLines import shouldBe fun main() { val monkeys = readInput() fun doMonkey(m: Monkey) { val it = m.items.iterator() while(it.hasNext()) { val item = it.next(); it.remove() m.activity++ item.level = m.operation(item.level) ...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,004
advent-of-code-2022
Apache License 2.0
src/Day12.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
fun main() { fun part1(input: List<String>): Int { val solution = Solution(input) { c -> c == 'S' } return solution.getPathLength() } fun part2(input: List<String>): Int { val solution = Solution(input) { c -> c == 'S' || c == 'a' } return solution.getPathLength() } ...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
2,237
AdventOfCode2022
Apache License 2.0
src/main/kotlin/nl/kelpin/fleur/advent2018/Day23.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 import arrow.syntax.function.memoize import java.util.* class Day23(input: List<String>) { companion object { val origin = Point3D(0, 0, 0) } data class Sphere(val pos: Point3D, val r: Int) { companion object { private val regex = Regex("""po...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
2,310
advent-2018
MIT License
src/chapter5/section3/ex20.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section3 import chapter5.section1.Alphabet import java.math.BigInteger import java.util.* import kotlin.collections.HashSet /** * 如何修改Rabin-Karp算法才能够判定k个模式(假设它们的长度全部相同)中的任意子集出现在文本之中? * 解答:计算所有k个模式字符串的散列值并将散列值保存在一个StringSET(请见练习5.2.6)对象中。 * * 解:散列值是Int或Long,不能保存在StringSET中,应该保存到普通SET中 * 遍历txt时,判断...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,713
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/algorithms/ArrayAlgorithms.kt
AgentKnopf
240,955,745
false
null
package algorithms /** * Sliding window problem: Two buckets, each can only hold one type of fruit, what's the most fruits we can collect. * https://levelup.gitconnected.com/an-introduction-to-sliding-window-algorithms-5533c4fe1cc7 */ internal fun totalFruit(tree: Array<Int>): Int { //Find the longest contiguou...
0
Kotlin
1
0
5367ce67e54633e53b2b951c2534bf7b2315c2d8
2,575
technical-interview
MIT License
src/Day05.kt
allisonjoycarter
574,207,005
false
{"Kotlin": 22303}
import java.util.* import kotlin.collections.ArrayList fun main() { fun part1(input: List<String>): String { val stacks = input.count { it.contains("[") } val crates = input.take(stacks) val columns = input[stacks] val amountOfColumns = columns.trim().split(" ").last().toInt() ...
0
Kotlin
0
0
86306ee6f4e90c1cab7c2743eb437fa86d4238e5
3,719
adventofcode2022
Apache License 2.0
src/day11/Parser.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day11 import readInput import java.math.BigInteger import java.util.regex.Pattern private val REGEX = """ ^Monkey (\d+):\s+Starting items: ([0-9, ]+)\s+Operation: new = old\s([+*])\s([\w\d]+)\s+Test: divisible by (\d+)\s+If true: throw to monkey (\d+)\s+If false: throw to monkey (\d+)${'$'} """.trimIndent() ...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
3,463
advent_of_code_2022
Apache License 2.0
src/main/kotlin/_2022/Day20.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput import java.util.* fun main() { fun part1(input: List<String>): Long { val intInput = input.map { it.toLong() } .mapIndexed { index, value -> SortNode(index, value) } val arrayToSort = LinkedList<SortNode>() arrayToSor...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
2,411
advent-of-code
Apache License 2.0
src/day2/Day02.kt
dean95
571,923,107
false
{"Kotlin": 21240}
package day2 import day2.Choice.* import readInput private fun main() { val myPlayCodes = mutableMapOf( "X" to ROCK, "Y" to PAPER, "Z" to SCISSORS ) val opponentPlayCodes = mutableMapOf( "A" to ROCK, "B" to PAPER, "C" to SCISSORS ) val choiceToDefe...
0
Kotlin
0
0
0ddf1bdaf9bcbb45116c70d7328b606c2a75e5a5
2,153
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day15.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day15 { fun part1(input: List<String>): String { val steps = input[0].split(",").map { it.trim() } return steps.sumOf { hash(it) }.toString() } private fun hash(it: String): Int { return it.toCharArray().fold(0) { acc, c -...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
1,196
kotlin-kringle
Apache License 2.0
src/UsefulStuff.kt
lucsrathbun
574,590,457
false
null
fun main() { val input = readInput("sentences") //println("Sum: ${sumAllNums(input)}") //println("Min: ${findMin(input)}") println("Count: ${countHWords(input)}") } fun sumAllNums(input: List<String>) : Int { var total = 0 for(num in input) { total += num.toInt() } return total ...
0
Kotlin
0
0
3b0ec8488f54ee219bd3de8b1b2aa4f4187f03b0
1,028
AdventOfCode2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day10.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.* fun main() = Day10.run() object Day10 : Day(2021, 10) { private var chunkDelims = mapOf('(' to ')', '{' to '}', '[' to ']', '<' to '>') private var scoreErrorChar = mapOf(')' to 3, '}' to 1197, ']' to 57, '>' to 25137) private var scoreClos...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,474
adventofkotlin
MIT License
year2022/src/cz/veleto/aoc/year2022/Day25.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import kotlin.math.abs class Day25(config: Config) : AocDay(config) { private val snafus = listOf(-2, -1, 0, 1, 2) private val maxSnafuOrder = 27 // so 2*5^maxSnafuOrder < Long.MAX_VALUE private val snafuPowers: List<Long> = (0..maxSnafuOrde...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
1,787
advent-of-pavel
Apache License 2.0
src/Day04.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File fun main() { fun intRangeFromDashString(s: String): IntRange { return IntRange(s.split("-".toRegex())[0].toInt(), s.split("-".toRegex())[1].toInt()) } fun compareCompleteOverlapRanges(s: String, s1: String): Int { val range1 = intRangeFromDashString(s) val rang...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
1,774
AoC2022
Apache License 2.0
day3/src/main/kotlin/com/lillicoder/adventofcode2023/day3/Day3.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day3 import com.lillicoder.adventofcode2023.grids.Grid import com.lillicoder.adventofcode2023.grids.GridParser import com.lillicoder.adventofcode2023.grids.Node fun main() { val day3 = Day3() val schematic = EngineSchematicParser().parse("input.txt") println("The su...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
5,654
advent-of-code-2023
Apache License 2.0
2020/src/year2020/day04/Day04.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2020.day04 import util.readAllLines import java.util.regex.Pattern private data class Passport( val byr: String?, val iyr: String?, val eyr: String?, val hgt: String?, val hcl: String?, val ecl: String?, val pid: String?, val cid: String?) { constructor(map: Map<String...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
3,081
adventofcode
MIT License
src/main/kotlin/day9/Day9.kt
afTrolle
572,960,379
false
{"Kotlin": 33530}
package day9 import Day fun main() { Day9("Day09").apply { println(part1(parsedInput)) println(part2(parsedInput)) } } data class Point( var height: Int = 0, var width: Int = 0 ) class Day9(input: String) : Day<List<Char>>(input) { override fun parseInput() = inputByLines.map {...
0
Kotlin
0
0
4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545
2,240
aoc-2022
Apache License 2.0
src/main/kotlin/adventofcode2018/Day15BeverageBandits.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2018 class Day15BeverageBandits sealed class Token(val sign: Char, var posX: Int, var posY: Int) : Comparable<Token> { open fun nextEnemy(): Token = NullToken() override fun toString(): String = sign.toString() override fun compareTo(other: Token): Int { return when { ...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
2,743
kotlin-coding-challenges
MIT License
src/main/kotlin/io/dmitrijs/aoc2022/Day13.kt
lakiboy
578,268,213
false
{"Kotlin": 76651}
package io.dmitrijs.aoc2022 class Day13(private val input: String) { fun puzzle1() = input .split("\n\n") .map { it.toPairs() } .foldIndexed(0) { index, acc, (left, right) -> (if (left < right) (index + 1) else 0) + acc } fun puzzle2(): Int { val dividers: P...
0
Kotlin
0
1
bfce0f4cb924834d44b3aae14686d1c834621456
2,833
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/OnesAndZeroes.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
5,758
kotlab
Apache License 2.0
2020/day16/day16.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 day16 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input: t...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
4,725
adventofcode
MIT License
src/main/kotlin/dev/bogwalk/batch7/Problem79.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch7 /** * Problem 79: Passcode Derivation * * https://projecteuler.net/problem=79 * * Goal: Based on a collection of successful login attempts using 3 characters (ASCII codes [33, * 126]) in order (but not necessarily consecutive), determine the shortest (& lexicographically * smallest) o...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
8,961
project-euler-kotlin
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/arrays/majorityelement/majorityElement.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.arrays.majorityelement /** * Finds the element that occurs more than n/2 times, where n is the size of the input list. * * This first sorts the list in place and finds the element at index n/2, since the majority element will always occupy * the middle position when the array is...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
5,673
KotlinGround
MIT License
src/main/kotlin/days/Day13.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days @AdventOfCodePuzzle( name = "Distress Signal", url = "https://adventofcode.com/2022/day/13", date = Date(day = 13, year = 2022) ) class Day13(val input: List<String>) : Puzzle { private val divider: List<String> = listOf("[[2]]", "[[6]]") private val pairs = input .asSequence(...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,603
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/Day04.kt
PauliusRap
573,434,850
false
{"Kotlin": 20299}
fun main() { fun getAssignmentRange(assignment: String) = with(assignment.split("-")) { this[0].toInt()..this[1].toInt() } fun isAnyAssignmentCovered(input: String): Boolean { val assignments = input.split(",") val range1 = getAssignmentRange(assignments[0]).toList() val ra...
0
Kotlin
0
0
df510c3afb104c03add6cf2597c433b34b3f7dc7
1,156
advent-of-coding-2022
Apache License 2.0
src/day03/Day03.kt
pientaa
572,927,825
false
{"Kotlin": 19922}
package day03 import readLines fun main() { fun findPriority(rucksack: String): Char { val first = rucksack.substring(0, rucksack.length / 2) val second = rucksack.substring(rucksack.length / 2) return first.first { second.contains(it) } } fun Char.toPriority...
0
Kotlin
0
0
63094d8d1887d33b78e2dd73f917d46ca1cbaf9c
1,060
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/2022/Day24_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
fun main() { val chMap = listOf('<', '^', '>', 'v').withIndex().associate {it.value to (1 shl it.index)} val input = readInput(24).trim().lines() val mStart = input.map { it.map {ch -> chMap.getOrDefault(ch, 0)} } val (N, M) = mStart.size to mStart[0].size // directions for each type o...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
2,430
adventofcode
Apache License 2.0
lib/src/main/java/anatoldevelopers/by/functional/Extensions.kt
Nublo
141,798,429
false
null
package anatoldevelopers.by.functional val <T> List<T>.head: T get() = when (this.isEmpty()) { true -> throw NoSuchElementException("List is empty.") false -> this[0] } val <T> List<T>.tail: List<T> get() = drop(1) val List<Int>.sum: Int get() = sum(this) fun sum(xs: List<Int>): Int ...
0
Kotlin
0
0
ab51d422a886a1b4d9ee35c8cfb2a1b3b82ba17b
2,294
KotlinByHaskell
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day13/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day13 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntList val test = TestInput(""" 6,10 0,14 9,10 0,3 10,4 4,11 6,0 6,12 4,1 0,13 10,12 3,4 3,0 8,4 1,10 2,14 ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,832
aoc
MIT License
src/main/kotlin/day17/Code.kt
fcolasuonno
317,324,330
false
null
package day17 import isDebug import java.io.File private val Triple<Int, Int, Int>.neighbours: Set<Triple<Int, Int, Int>> get() = (-1..1).flatMap { d1 -> (-1..1).flatMap { d2 -> (-1..1).map { d3 -> Triple(first + d1, second + d2, third + d3) } } }.filter...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
2,305
AOC2020
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1071/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1071 /** * LeetCode page: [1071. Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings/); */ class Solution { /* Complexity: * Time O(|str1|+|str2|) and Space O(min(|str1|, |str2|)); */ fun gcdOfStrings(str1: Strin...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,542
hj-leetcode-kotlin
Apache License 2.0
src/Day15.kt
wbars
576,906,839
false
{"Kotlin": 32565}
import java.lang.IllegalStateException import kotlin.math.abs private const val i = 4000000 fun main() { fun beacons(input: List<String>): List<Pair<Pair<Int, Int>, Pair<Int, Int>>> { val a = input.map { val m = Regex("Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
3,299
advent-of-code-2022
Apache License 2.0
src/Day04.kt
kthun
572,871,866
false
{"Kotlin": 17958}
fun main() { fun String.createElfRanges() = split(",") .map { it.split("-") } .map { it[0].toInt()..it[1].toInt() } fun part1(input: List<String>): Int { return input.count { line -> val (elf1, elf2) = line.createElfRanges() elf1 in elf2 || elf2 in elf1 ...
0
Kotlin
0
0
5452702e4e20ef2db3adc8112427c0229ebd1c29
868
aoc-2022
Apache License 2.0
2020/Day2/src/main/kotlin/main.kt
airstandley
225,475,112
false
{"Python": 104962, "Kotlin": 59337}
import java.io.File data class PasswordPolicy(val char: Char, val first: Int = 0, val second: Int = 0) fun getInput(): List<String> { return File("Input").readLines() } private val linRegex = Regex("(\\d*)-(\\d*) (\\w): (\\w*)") fun parseInputLine(line: String): Pair<PasswordPolicy, String>? { // Input is fo...
0
Python
0
0
86b7e289d67ba3ea31a78f4a4005253098f47254
2,268
AdventofCode
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day12.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year21 import com.grappenmaker.aoc.PuzzleSet fun PuzzleSet.day12() = puzzle(day = 12) { // Part one val graph = inputLines.generateGraph() // Initialize queue for BFS val queue = ArrayDeque(listOf(Node("start"))) // Initialize counters var result = 0 var addi...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,636
advent-of-code
The Unlicense
src/main/kotlin/sort/HeapSort.kt
TheAlgorithms
177,334,737
false
{"Kotlin": 41212}
package sort /** * This function implements the Heap Sort. * * @param array The array to be sorted * Sorts the array in increasing order * * Worst-case performance O(n*log(n)) * Best-case performance O(n*log(n)) * Average-case performance O(n*log(n)) * Worst-case space complexity O(1) (auxil...
62
Kotlin
369
1,221
e57a8888dec4454d39414082bbe6a672a9d27ad1
1,791
Kotlin
MIT License