path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/day22.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.Point import shared.getText fun main() { val input = getText("day22.txt") println(day22A(input)) println(day22B(input)) } fun day22A(input: String): Int { val board = Board(input) board.followInstructions() return board.password() } fun day22B(input: String): Int { val board...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
4,876
AdventOfCode2022
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions34.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import kotlin.math.min fun test34() { printlnResult(arrayOf("offer", "is", "coming"), "abcdefghijklmnopqrstuvwxyz".reversed()) } /** * Questions 34: Judge if a group of words is sorted by a new alphabet */ private infix fun Array<String>.isSorted(alphabet: String): Boole...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,501
Algorithm
Apache License 2.0
year2023/day05/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day05/part2/Year2023Day05Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Everyone will starve if you only plant such a small number of seeds. Re-reading the almanac, it looks like the seeds: line actually describes ranges of seed numbers. The values on the initial seeds: line come in pairs. Within each pair, the first value is the start of the range and the second valu...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,145
AdventOfCode
MIT License
src/main/kotlin/year2022/Day24.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2022 import utils.Direction import utils.Direction.* import utils.Point2D import utils.lcm class Day24(contents: String) { data class Blizzard(val position: Point2D, val direction: Direction) data class State(val step: Int, val position: Point2D) private val lines = contents.lines() priv...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
3,278
aoc-2022
Apache License 2.0
2019/task_10/src/main/kotlin/task_10/App.kt
romanthekat
52,710,492
false
{"Go": 90415, "Kotlin": 74230, "Python": 57300, "Nim": 22698, "Ruby": 7404, "Rust": 1516, "Crystal": 967}
package task_10 import java.io.File import java.lang.Integer.max import java.lang.Integer.min class App { fun solveFirst(input: List<String>): Int { val map = Map(input) var (_, asteroids) = map.getBestLocation() return asteroids.size } fun solveSecond(input: List<String>): Int { ...
4
Go
0
0
f410f71c3ff3e1323f29898c1ab39ad6858589bb
3,273
advent_of_code
MIT License
src/jvmMain/kotlin/day15/initial/Day15.kt
liusbl
726,218,737
false
{"Kotlin": 109684}
package day15.initial import util.add import util.removeAt import util.set import java.io.File fun main() { // solvePart1() // Solution: 507769, time: 9:18 solvePart2() // Solution: 269747, time: 23:12 } fun solvePart2() { val input = File("src/jvmMain/kotlin/day15/input/input.txt") // val input = File...
0
Kotlin
0
0
1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1
5,166
advent-of-code
MIT License
src/2022/Day01.kt
bartee
575,357,037
false
{"Kotlin": 26727}
fun main() { fun groupCaloryListPerElf(input: List<String>): HashMap<Int, Int> { // Every line is an amount of calories carried by an elf // Every blank line indicates a new elf. var res = 0 var iterator = 0 var resultset = HashMap<Int, Int>() var counter = 0 ...
0
Kotlin
0
0
c7141d10deffe35675a8ca43297460a4cc16abba
1,322
adventofcode2022
Apache License 2.0
src/day07/Day07.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day07 import readInput import java.util.* fun main() { fun part1(input: List<String>): Int { val structure = parseInput(input) structure.accept(PrintlnContentVisitor()) println("——————————————————————————————————————") val sizeVisitor = TotalSizeVisitor() structure....
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
4,703
advent-of-code-2022
Apache License 2.0
day18/kotlin/corneil/src/main/kotlin/solution.kt
jensnerche
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271602, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "C": 3201, "Go": 2838, "Shell": 26...
package com.github.corneil.aoc2019.day18 import com.github.corneil.aoc2019.common.permutations import java.io.File import java.util.* fun BitSet.copy(extra: BitSet? = null): BitSet { val result = BitSet(this.size()) result.or(this) if (extra != null) { result.or(extra) } return result } d...
0
HTML
0
0
a84c00ddbeb7f9114291125e93871d54699da887
15,679
aoc-2019
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[14]最长公共前缀.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //编写一个函数来查找字符串数组中的最长公共前缀。 // // 如果不存在公共前缀,返回空字符串 ""。 // // // // 示例 1: // // //输入:strs = ["flower","flow","flight"] //输出:"fl" // // // 示例 2: // // //输入:strs = ["dog","racecar","car"] //输出:"" //解释:输入不存在公共前缀。 // // // // 提示: // // // 0 <= strs.length <= 200 // 0 <= strs[i].length <= 200 /...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,353
MyLeetCode
Apache License 2.0
src/puzzles/day01/Day01.kt
sferjanec
573,682,195
false
{"Kotlin": 1962}
package puzzles.day01 import puzzles.readInput import java.io.File import java.util.* fun main() { fun parseInput(input: String): List<List<Int>> = input.split("\r\n\r\n").map { elf: String -> elf.lines().map { it.toInt() } } // fun List<List<Int>>.topElves(n: Int): Int { // return map { it...
0
Kotlin
0
0
c4e928719f36d236534a92b059a66b61eef19717
1,297
advent-of-code-2022
Apache License 2.0
src/main/kotlin/util/Coord.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package util import kotlin.math.abs import kotlin.math.pow import kotlin.math.sqrt data class Coord( var x: Int, var y: Int ) { operator fun plus(c: Coord) = Coord(x = x + c.x, y = y + c.y) operator fun minus(c: Coord) = Coord(x = x - c.x, y = y - c.y) /** * Get adjacent neighbor [Coord] lis...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
2,382
advent-of-code-2021
MIT License
src/Day01.kt
hufman
573,586,479
false
{"Kotlin": 29792}
fun main() { fun parse(input: List<String>): List<List<Int>> { var elf = ArrayList<Int>() val elves = ArrayList<List<Int>>().apply { add(elf) } input.map { it.toIntOrNull() }.forEach { if (it != null) { elf.add(it) } else { elf = ArrayL...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
886
aoc2022-kt
Apache License 2.0
src/main/kotlin/day10/Day10.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day10 import readInput fun main() { fun toSequence(input: List<String>) = sequence { var register = 1 input.forEach { line -> if (line.startsWith("noop")) { yield(register) } else if (line.startsWith("addx ")) { val value = line.sub...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
1,484
aoc2022
Apache License 2.0
src/Day19/Day19.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day19 import readInput import java.util.Objects import java.util.PriorityQueue import kotlin.math.* data class CombinedCost(val oreCost: Int, val clayCost: Int, val obsidianCost: Int) data class Blueprint(val oreRobotCost: Int, val clayRobotCost: Int, val obsidianRobotCost: CombinedCost, val geodeRobotCost: Co...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
11,887
advent-of-code-2022
Apache License 2.0
src/main/kotlin/cc/stevenyin/algorithms/_02_sorts/_05_MergeSort_BottomUp.kt
StevenYinKop
269,945,740
false
{"Kotlin": 107894, "Java": 9565}
package cc.stevenyin.algorithms._02_sorts import cc.stevenyin.algorithms.RandomType import cc.stevenyin.algorithms.testSortAlgorithm import kotlin.math.min class _05_MergeSort_BottomUp: SortAlgorithm { override val name: String get() = "MergeSort_BottomUp" // 2,3,1,5,3,6,9,8 // override fun...
0
Kotlin
0
1
748812d291e5c2df64c8620c96189403b19e12dd
1,784
kotlin-demo-code
MIT License
day21/Kotlin/day21.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* import java.util.concurrent.atomic.AtomicInteger fun print_day_21() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 21" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
2,642
AOC2021
Apache License 2.0
src/Day03.kt
filipradon
573,512,032
false
{"Kotlin": 6146}
fun main() { fun String.intoHalves(): List<String> { return listOf(substring(0..length/2), substring(length/2)) } fun List<String>.findCommonCharacter(): Char { return this.map { it.toSet() } .reduce { left, right -> left intersect right } .first() } fun C...
0
Kotlin
0
0
dbac44fe421e29ab2ce0703e5827e4645b38548e
927
advent-of-code-kotlin-2022
Apache License 2.0
src/Day07.kt
kipwoker
572,884,607
false
null
import java.math.BigInteger enum class NodeType { File, Dir } class Node(val parent: Node?, val children: MutableMap<String, Node>, val alias: String, val size: BigInteger?, val type: NodeType) { var totalSize = BigInteger.ZERO fun getRoot(): Node { var currentNode = this while (currentNode.pa...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
4,293
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumAverageDifference.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <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,931
kotlab
Apache License 2.0
kotlin/src/main/kotlin/dev/egonr/leetcode/13_RomanToInt.kt
egon-r
575,970,173
false
null
package dev.egonr.leetcode /* Easy Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ...
0
Kotlin
0
0
b9c59e54ca2d1399d34d1ee844e03c16a580cbcb
3,067
leetcode
The Unlicense
day04/src/main/kotlin/Day04.kt
bzabor
160,240,195
false
null
class Day04(private val input: List<String>) { val guardMap = mutableMapOf<String, Guard>() val sorted = input.toTypedArray().sorted() fun part1(): Int { processInput() val maxGuard = guardMostAsleep() var maxIdx = 0 var minuteMax = 0 for ((idx, minute) in maxGua...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
2,439
AdventOfCode2018
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SubarraySumEqualsK.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,423
kotlab
Apache License 2.0
src/main/kotlin/days/Day25.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2021/day/25", date = Date(day = 25, year = 2021) ) class Day25(val input: List<String>) : Puzzle { private val seafloor = parseSeafloor() private val max = Point(input.first().lastIndex, input.lastIndex) overrid...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
2,422
advent-of-code-2021
Creative Commons Zero v1.0 Universal
day21/src/Day21.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.lang.StringBuilder object Day21 { const val TARGET_SCORE_PART_1 = 1000 const val TARGET_SCORE_PART_2 = 21 } fun main() { val positions = mapOf(Pair(Player.ONE, 6), Pair(Player.TWO, 8)) println(part1(Day21.TARGET_SCORE_PART_1, positions)) println(part2(Day21.TARGET_SCORE_PART_2, positi...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
2,723
adventofcode2021
MIT License
year2023/src/cz/veleto/aoc/year2023/Day12.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay class Day12(config: Config) : AocDay(config) { override fun part1(): String = solve(folds = 1) override fun part2(): String = solve(folds = 5) private fun solve(folds: Int): String = input .map { line -> line.parse(folds) } ...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
1,573
advent-of-pavel
Apache License 2.0
year2020/day07/baggage/src/main/kotlin/com/curtislb/adventofcode/year2020/day07/baggage/BagRules.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2020.day07.baggage /** * A set of rules indicating the number and type of bags (see [BagCount]) that must be contained in * other bags. * * @param rulesString A string representing all bag rules. Each line may end with a `.` and must * be a rule of the form `"$container bags...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,167
AdventOfCode
MIT License
src/adventofcode/blueschu/y2017/day10/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day10 import java.io.File import kotlin.test.assertEquals val input: String by lazy { File("resources/y2017/day10.txt") .bufferedReader() .use { it.readText() } .trim() } fun main(args: Array<String>) { assertEquals(12, part1("3,4,1,5", Knot(circleS...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
3,235
Advent-Of-Code
MIT License
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day05.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.intersect import eu.michalchomo.adventofcode.main import eu.michalchomo.adventofcode.removeIntersectWith import eu.michalchomo.adventofcode.split object Day05 : Day { override val number: Int = ...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
3,834
advent-of-code
Apache License 2.0
src/Day10.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
fun main() { open class Instruction(val cycles: Int) class NoOp : Instruction(1) class AddX(val amount: Int) : Instruction(2) fun List<String>.toInstructions(): List<Instruction> { return this.map { val i = it.split(" ") when (i[0]) { "noop" -> NoOp() ...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
1,868
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day22.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 /** * AoC 2017, Day 22 * * Problem Description: http://adventofcode.com/2017/day/22 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day22/ */ class Day22(input: List<String>) { private val grid = parseInput(inp...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
2,821
advent-2017-kotlin
MIT License
ceria/15/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; // Thanks to https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Algorithm and comments in // the slack that it uses this algorithm fun main(args : Array<String>) { val input = File(args.first()).readLines() .map { line -> line.map { it -> it.digitToInt() }.toMutableList() }.toMutable...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
4,059
advent-of-code-2021
MIT License
src/Day01.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day01_test") check(part1(testInput) == 24000) val input = readInput("Day01") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { var topElfCa...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
995
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfEnclaves.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <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,682
kotlab
Apache License 2.0
src/Day02.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
const val WIN = 6 const val LOSE = 0 const val DRAW = 3 const val ROCK = 1 const val PAPER = 2 const val SCISSORS = 3 fun main() { fun part1(input: List<String>) = input.sumOf { when (it) { "A X" -> DRAW + ROCK "A Y" -> WIN + PAPER "A Z" -> LOSE + SCISSORS "...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
1,346
aoc-2022
Apache License 2.0
src/net/sheltem/aoc/y2022/Day08.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 class Day08 : Day<Int>(21, 8) { override suspend fun part1(input: List<String>): Int = input.trees().countVisible() override suspend fun part2(input: List<String>): Int = input.trees().toScenicScores().max() } suspend fun main() { Day08().run() } private fun Array<Array<In...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,147
aoc
Apache License 2.0
src/Day01.kt
arturkowalczyk300
573,084,149
false
{"Kotlin": 31119}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currentCalories = 0 input.forEach { if (it != "") currentCalories += it.toIntOrNull() ?: 0 else { if (currentCalories > maxCalories) maxCalor...
0
Kotlin
0
0
69a51e6f0437f5bc2cdf909919c26276317b396d
1,090
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/treesandgraphs/MostStonesRemovedWithSameRowOrColumn.kt
e-freiman
471,473,372
false
{"Kotlin": 78010}
package treesandgraphs private var xIndex = mapOf<Int, List<Int>>() private var yIndex = mapOf<Int, List<Int>>() private var visited = booleanArrayOf() private fun dfs(stones: Array<IntArray>, index: Int): Int { visited[index] = true var sum = 0 for (i in xIndex[stones[index][0]]!!) { if (!visited...
0
Kotlin
0
0
fab7f275fbbafeeb79c520622995216f6c7d8642
1,081
LeetcodeGoogleInterview
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumMusicPlaylists.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
4,935
kotlab
Apache License 2.0
src/main/kotlin/days/Day9.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days class Day9 : Day(9) { override fun partOne(): Any { return inputList .map { line -> line.split(" ").map { it.toInt() } } .map { it.extrapolate() } .sumOf { it.last() } } override fun partTwo(): Any { return inputList .map { line...
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
1,182
AoC-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/leetcode/kotlin/tree/1305. All Elements in Two Binary Search Trees.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package leetcode.kotlin.tree import java.util.* import kotlin.collections.ArrayList // Taken from // https://leetcode.com/problems/all-elements-in-two-binary-search-trees/discuss/464368/Short-O(n)-Python // In Java also, time performance is almost O(n) when input is almost sorted, which is true in this case. // Seems...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
3,740
leetcode-kotlin
Apache License 2.0
src/Day16.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope suspend fun main() { val testInput = readInput("Day16_test") check(part1(testInput) == 1651) check(part2(testInput) == 1707) val input = readInput("Day16") measureAndPrintResult { pa...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
3,250
aoc-22
Apache License 2.0
src/main/kotlin/day8/Day8.kt
Arch-vile
317,641,541
false
null
package day8 import readFile enum class InstructionType { NOP, ACC, JMP } data class Instruction( val type: InstructionType, val value: Int, var isExecuted: Boolean = false) { fun execute(memory: Memory): Int { isExecuted = true when (type) { InstructionType.ACC -> memory.accumulator += valu...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
2,676
adventOfCode2020
Apache License 2.0
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day18Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import java.util.ArrayDeque private fun solution1(input: String) = parseCubes(input).allSurfaceSides()...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,074
adventofcode-kotlin
MIT License
kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/ints.kt
swanandvk
284,610,632
true
{"Kotlin": 2715433, "HTML": 423, "Java": 145}
package io.kotest.property.arbitrary import io.kotest.property.Arb import io.kotest.property.Shrinker import kotlin.math.abs import kotlin.random.nextInt fun Arb.Companion.int(min: Int, max: Int) = int(min..max) /** * Returns an [Arb] where each value is a randomly chosen [Int] in the given range. * The edgecases ...
5
Kotlin
0
1
6d7dcaa2c96db13c7e81ba76b9f8dd95b7113871
2,008
kotest
Apache License 2.0
day09/kotlin/RJPlog/day2309_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File import kotlin.math.* fun day09(in1: Int): Long { var result = 0L var lines = File("day2309_puzzle_input.txt").readLines() lines.forEach { var line = it.split(" ").map { it.toLong() }.toList() var interpolationValues = mutableListOf<Long>() var diffList = mutableListOf<Long>() if (in...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
1,610
aoc-2023
MIT License
src/main/kotlin/adventofcode2023/day18/day18.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day18 import adventofcode2023.Point import adventofcode2023.col import adventofcode2023.line import adventofcode2023.readInput import java.awt.geom.Point2D import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.time.measureTime data class Line( val start: Poin...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
5,760
adventofcode2023
MIT License
src/main/kotlin/com/mantono/lingress/Regression.kt
mantono
100,183,137
false
null
package com.mantono.lingress data class RegressionLine(val m: Double, val b: Double) { fun y(x: Double): Double = m*x+b fun x(y: Double): Double = (y-b)/m operator fun get(x: Double): Double = y(x) override fun toString(): String = "y = $m * x + $b" } data class Point(val x: Double, val y: Double) { constructor(...
0
Kotlin
0
0
0c7cb0ff9b8feb946aea0d57538da8bd0423aada
1,810
linear-regression
MIT License
src/main/kotlin/y2022/Day04.kt
jforatier
432,712,749
false
{"Kotlin": 44692}
package y2022 class Day04(private val data: List<String>) { data class Section(val start: Int, val end: Int) data class Assignment(val firstElf: Section, val secondElf: Section) { fun fullyContain(): Boolean { val firstElfRange = firstElf.start.rangeTo(firstElf.end) val secondE...
0
Kotlin
0
0
2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae
1,544
advent-of-code-kotlin
MIT License
math/SmallestIntegerDivisibleByK/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
import java.util.LinkedList /** * Given a positive integer K, you need to find the length of the smallest * positive integer N such that N is divisible by K, * and N only contains the digit 1. * Return the length of N. If there is no such N, return -1. * Note: N may not fit in a 64-bit signed integer. * <br> ...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,021
codility
MIT License
src/net/sheltem/aoc/y2015/Day07.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2015 suspend fun main() { Day07().run() } class Day07 : Day<Int>(72, 72) { override suspend fun part1(input: List<String>): Int = solve(input) override suspend fun part2(input: List<String>): Int = solve(input, 956) private fun solve(input:List<String>, overrideB: Int? = n...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,938
aoc
Apache License 2.0
src/com/mrxyx/algorithm/TreeNodeAlg.kt
Mrxyx
366,778,189
false
null
package com.mrxyx.algorithm import com.mrxyx.algorithm.model.TreeNode import java.util.* /** * 二叉树 */ class TreeNodeAlg { /** * 反转二叉树 * https://leetcode-cn.com/problems/invert-binary-tree/ */ fun invertTree(root: TreeNode?): TreeNode? { //base case if (root == null) return n...
0
Kotlin
0
0
b81b357440e3458bd065017d17d6f69320b025bf
11,249
algorithm-test
The Unlicense
src/main/kotlin/aoc2021/Day09.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2021 import aoc2022.product import utils.ArrayAsSurface import utils.Coordinates import utils.InputUtils class Surface(val input: List<String>): ArrayAsSurface(input) { fun basinAt(start: Coordinates): Sequence<Coordinates> { val queue = ArrayDeque<Coordinates>() queue.add(start) ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,630
aoc-2022-kotlin
Apache License 2.0
src/main/aoc2018/Day7.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 import java.util.* class Day7(input: List<String>) { // Letter is key, list of requirements is value private val steps = parseInput(input) private fun parseInput(input: List<String>): Map<String, MutableList<String>> { val ret = mutableMapOf<String, MutableList<String>>() ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,623
aoc
MIT License
aoc-2023/src/main/kotlin/aoc/aoc22.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.Loc3 import aoc.util.getDayInput val testInput = """ 1,0,1~1,2,1 0,0,2~2,0,2 0,2,3~2,2,3 0,0,4~0,2,4 2,0,5~2,2,5 0,1,6~2,1,6 1,1,8~1,1,9 """.parselines class Brick(val p1: Loc3, val p2: Loc3) { val locs = when { p1.x == p2.x && p1.y ==...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
4,413
advent-of-code
Apache License 2.0
src/Day03.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
class Day03 { fun part1(input: List<String>): Int { var sum = 0 for(rucksack in input) { var firstComp = rucksack.substring(0, rucksack.length / 2).toCharArray().toMutableSet() var secondComp = rucksack.substring(rucksack.length / 2).toCharArray().toMutableSet() f...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
1,048
advent-of-code
Apache License 2.0
src/Day03.kt
mborromeo
571,999,097
false
{"Kotlin": 10600}
fun main() { fun priority(el: Char): Int { return when (el) { in 'a'..'z' -> el - 'a' + 1 in 'A'..'Z' -> el - 'A' + 27 else -> 0 } } fun part1(input: List<String>): Int { return input.sumOf { rucksack -> priority((rucksack.take(rucksac...
0
Kotlin
0
0
d01860ecaff005aaf8e1e4ba3777a325a84c557c
820
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/adventofcode/year2021/day3/part2/App.kt
demidko
433,889,383
false
{"Kotlin": 7692, "Dockerfile": 264}
package com.adventofcode.year2021.day3.part2 import com.adventofcode.year2021.day import java.math.BigInteger fun List<String>.mostCommonBit(column: Int): Char { return when (count { it[column] == '1' } >= count { it[column] == '0' }) { true -> '1' else -> '0' } } fun List<String>.leastCommonBit(column: ...
0
Kotlin
0
0
2f42bede3ed0c4b17cb2575f6b61a1917a465bda
1,101
adventofcode
MIT License
src/commonMain/kotlin/advent2020/day23/Day23Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day23 fun part1(input: String): String { val circle = Circle(input.trim()) circle.makeNMoves(times = 100) return part1formatAnswer(circle) } fun part1formatAnswer(circle: Circle) = buildString { var n = circle.cups[1].next while (n.id != 1) { append(n.id) n = n.n...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
2,574
advent-of-code-2020
MIT License
year2022/src/main/kotlin/net/olegg/aoc/year2022/day3/Day3.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day3 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2022.DayOf2022 /** * See [Year 2022, Day 3](https://adventofcode.com/2022/day/3) */ object Day3 : DayOf2022(3) { private val ALPHABET = buildSet { addAll('a'..'z') addAll('A'..'Z') } override fun first()...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,122
adventofcode
MIT License
src/aoc2022/Day05.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* internal class Day05(val lines: List<String>) { init { lines.forEach { println(it) } } fun part1(): String { val (startingStacks, moves) = lines.splitBy { it == "" } val stacks = startingStacks.reversed()[0].last().digitToInt() * mutableListOf<Char>() startingStacks ...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
1,836
aoc2022
Apache License 2.0
src/me/anno/maths/EquationSolver.kt
AntonioNoack
456,513,348
false
{"Kotlin": 9845766, "C": 236481, "GLSL": 9454, "Java": 6754, "Lua": 4404}
package me.anno.maths import me.anno.maths.Maths.TAUf import me.anno.maths.Maths.pow import kotlin.math.abs import kotlin.math.acos import kotlin.math.cos import kotlin.math.sqrt object EquationSolver { private const val TOO_LARGE_RATIO = 1e9 // idk... fun solveQuadratic(dst: FloatArray, a: Float, b: Float,...
0
Kotlin
3
17
3d0d08566309a84e1e68585593b76844633132c4
2,500
RemsEngine
Apache License 2.0
src/Day01.kt
afranken
572,923,112
false
{"Kotlin": 15538}
fun main() { fun countCalories(input: List<String>): List<Int> { val caloryList: MutableList<Int> = mutableListOf() var caloryCounter = 0 for (it in input) { if (it.isBlank()) { caloryList.add(caloryCounter) caloryCounter = 0 } else { ...
0
Kotlin
0
0
f047d34dc2a22286134dc4705b5a7c2558bad9e7
1,143
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
class Day05 : Day(5) { class Instruction(val move: Int, val from: Int, val to: Int) // --- Part 1 --- private fun parseCrates(input: String, shouldReverseOrder: Boolean): String { val crateGroups = mutableMapOf<Int, MutableList<Char>>() val instructions = mutableListOf<Instruction>() ...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
2,380
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2020/day14/BitMask.kt
arnab
75,525,311
false
null
package aoc2020.day14 object BitMask { private val DEFAULT_MASK = Mask.from("X".repeat(36)) private val memoryLocationPattern = Regex("""mem\[(\d+)]""") data class Mask( val bits: List<Int?> ) { companion object { fun from(mask: String) = mask.split("") .fi...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,701
adventofcode
MIT License
src/day16/Day16.kt
Puju2496
576,611,911
false
{"Kotlin": 46156}
package day16 import println import readInput import java.util.* fun main() { // test if implementation meets criteria from the description, like: val input = readInput("src/day16", "Day16") println("Part1") part1(input) println("Part2") part2(input) } private fun part1(inputs: List<String>) ...
0
Kotlin
0
0
e04f89c67f6170441651a1fe2bd1f2448a2cf64e
2,332
advent-of-code-2022
Apache License 2.0
src/day14/Day14.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day14 import readLines import kotlin.math.max import kotlin.math.min private class Grid(var grid: Array<Array<String>>, val minX: Int, val maxX: Int, val minY: Int, val maxY: Int) { companion object { fun of(input: List<String>, part2: Boolean): Grid { // Parse 498,4 -> 498,6 -> 496,...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
4,440
aoc2022
Apache License 2.0
src/Day24.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.util.LinkedList private data class Position(val x: Int, val y: Int, val time: Int) private fun Position.toId() = "$x,$y,$time" private fun String.toPosition() = split(",").map { it.toInt() }.let { Position(it[0], it[1], it[2]) } fun main() { // up, down, left, right val dx = listOf(-1, 1, 0, 0) ...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
3,307
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/_0047_PermutationsII.kt
ryandyoon
664,493,186
false
null
// https://leetcode.com/problems/permutations-ii fun permuteUnique(nums: IntArray): List<List<Int>> { nums.sort() return mutableListOf<List<Int>>().also { buildPermutations(nums, 0, it) } } private fun buildPermutations(nums: IntArray, startIndex: Int, permutations: MutableList<List<Int>>) { if...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
989
leetcode-kotlin
MIT License
kotlin/src/_0005.kt
yunshuipiao
179,794,004
false
null
import org.testng.annotations.Test fun longestPalindrome(s: String): String { return longCommonSubString(s) } fun dp(s: String): String { if (s.isBlank()) { return s } var result = "" val map = Array(s.length) { Array(s.length) { 0 } } for (i in 0 until map.size) { for (j in 0 ...
29
Kotlin
0
2
6b188a8eb36e9930884c5fa310517be0db7f8922
2,629
rice-noodles
Apache License 2.0
src/main/kotlin/ca/kiaira/advent2023/day11/Day11.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day11 import ca.kiaira.advent2023.Puzzle import kotlin.math.abs /** * Solution object for Day 11 puzzle of Advent of Code 2023. * * @author <NAME> <<EMAIL>> * @since December 11th, 2023 */ object Day11 : Puzzle<List<List<Char>>>(11) { /** * Parses the raw input data into a List o...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
3,482
kAdvent-2023
Apache License 2.0
src/Day22.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import java.io.PrintWriter import java.lang.StringBuilder // This solution works only on my input fold type fun main() { fun part1(input: List<String>): Int { val map: Array<Array<Cell>> = readMap(input) val instructions = input.last() val board = Board(map, true) return board.execu...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
8,754
AdventOfCode2022
Apache License 2.0
src/Day01.kt
AlexeyVD
575,495,640
false
{"Kotlin": 11056}
fun main() { fun part1(input: List<String>): Int { return getMaxSum(input, 1) } fun part2(input: List<String>): Int { return getMaxSum(input, 3) } val testInput = readInput("Day01_test") check(part1(testInput) == 24000) check(part2(testInput) == 45000) val input = read...
0
Kotlin
0
0
ec217d9771baaef76fa75c4ce7cbb67c728014c0
898
advent-kotlin
Apache License 2.0
src/Day14.kt
sushovan86
573,586,806
false
{"Kotlin": 47064}
import kotlin.math.abs import kotlin.math.sign class RegolithReservoir private constructor(private val rocksCoordinates: Set<Coordinate>) { private val initialSandCoordinate = Coordinate(500, 0) private val restingSandCoordinates = mutableSetOf<Coordinate>() private val depth: Int = rocksCoordinates.maxOf...
0
Kotlin
0
0
d5f85b6a48e3505d06b4ae1027e734e66b324964
3,437
aoc-2022
Apache License 2.0
Kotlin/src/ThreeSumClosest.kt
TonnyL
106,459,115
false
null
/** * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. * Return the sum of the three integers. * You may assume that each input would have exactly one solution. * * For example, given array S = {-1 2 1 -4}, and target = 1. * * The sum that is closes...
1
Swift
22
189
39f85cdedaaf5b85f7ce842ecef975301fc974cf
1,132
Windary
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindUnsortedSubArray.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
4,922
kotlab
Apache License 2.0
src/main/kotlin/Day02.kt
robert-iits
573,124,643
false
{"Kotlin": 21047}
import org.junit.jupiter.api.Assertions.assertEquals // ROCK PAPER SCISSOR // A, B, C // X, Y, Z // 0 1 2 // win draw loss // PAPER (1) -> ROCK (0) // ROCK (0) -> SCISSOR (2) // SCISSOR (2) -> PAPER (1) fun main() { fun normalize(char: Char): Int { return if (char.code >= 'X'.code) { char...
0
Kotlin
0
0
223017895e483a762d8aa2cdde6d597ab9256b2d
1,620
aoc2022
Apache License 2.0
src/Day06.kt
andydenk
573,909,669
false
{"Kotlin": 24096}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day06_test") check(part1(testInput[0]) == 7) check(part1(testInput[1]) == 5) check(part1(testInput[2]) == 6) check(part1(testInput[3]) == 10) check(part1(testInput[4]) == 11) che...
0
Kotlin
0
0
1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1
966
advent-of-code-2022
Apache License 2.0
src/Day03.kt
DiamondMiner88
573,073,199
false
{"Kotlin": 26457, "Rust": 4093, "Shell": 188}
fun main() { d3part1() d3part2() } fun d3part1() { val input = readInput("input/day03.txt") .split("\n") .filter { it.isNotBlank() } .map { it.take(it.length / 2) to it.takeLast(it.length / 2) } var total = 0 for (rucksack in input) { val (comp1, comp2) = rucksack ...
0
Kotlin
0
0
55bb96af323cab3860ab6988f7d57d04f034c12c
1,060
advent-of-code-2022
Apache License 2.0
src/test/kotlin/com/igorwojda/string/issubstring/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.string.issubstring // Time complexity: O(n*m) // Space complexity: O(1) // // Optimal solution using double pointer. private object Solution1 { private fun isSubstring(str: String, subStr: String): Boolean { if (subStr.isEmpty()) return true if (str.length < subStr.length) ret...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
3,435
kotlin-coding-challenges
MIT License
src/Day10.kt
casslabath
573,177,204
false
{"Kotlin": 27085}
fun main() { fun part1(input: List<String>): Int { var cycleStop = 20 var cycle = 0 var x = 1 val signalStrengths = mutableListOf<Int>() input.map{ val splitStr = it.split(" ") val op = splitStr[0] if(op == "addx") { val nu...
0
Kotlin
0
0
5f7305e45f41a6893b6e12c8d92db7607723425e
2,449
KotlinAdvent2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/GetSumAbsoluteDifferences.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,255
kotlab
Apache License 2.0
src/main/kotlin/org/sjoblomj/adventofcode/day7/visualisation/Visualiser.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day7.visualisation import org.sjoblomj.adventofcode.Score import org.sjoblomj.adventofcode.day7.Node import org.sjoblomj.adventofcode.writeFile import java.io.File data class Coord(val col: Int, val row: Int) fun visualise(nodes: List<Node>, resultingOrder: String) { val preReqs ...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
5,909
adventofcode2018
MIT License
src/Day05.kt
arhor
572,349,244
false
{"Kotlin": 36845}
import java.util.* fun main() { val input = readInput {} println("Part 1: " + solvePuzzle(input, insertReversed = true)) println("Part 2: " + solvePuzzle(input, insertReversed = false)) } private val cratePattern = Regex("(\\[([A-Z])])| {3}") private val instrPattern = Regex("^move ([0-9]+) from ([0-9]+)...
0
Kotlin
0
0
047d4bdac687fd6719796eb69eab2dd8ebb5ba2f
1,325
aoc-2022-in-kotlin
Apache License 2.0
TwoSumEqualToTarget.kt
sysion
353,734,921
false
null
/** * https://leetcode.com/problems/two-sum/ * * Two Sum Less Than K * * Given an array of integers nums and an integer target, return indices of the * two numbers such that they add up to target. * * You may assume that each input would have exactly one solution, and you may * not use the same element twice. * * Yo...
0
Kotlin
0
0
6f9afda7f70264456c93a69184f37156abc49c5f
1,494
DataStructureAlgorithmKt
Apache License 2.0
src/Day04.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
fun main() { fun String.toRange() = this.split("-").map { it.toInt() }.let { it[0]..it[1] } fun part1(input: List<String>): Int { return input.count { line -> val r1 = line.split(",").first().toRange() val r2 = line.split(",").last().toRange() r1.all { it in r2 } ...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
793
aoc-2022-in-kotlin
Apache License 2.0
src/questions/SpiralMatrix.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.assertIterableSame /** * Given an `m x n` matrix, return all elements of the `matrix` in spiral order. * * [Source](https://leetcode.com/problems/spiral-matrix) – [Solution](https://leetcode.com/problems/spiral-matrix/discuss/20571/1-liner-in-P...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,254
algorithms
MIT License
src/Day01.kt
devheitt
573,207,407
false
{"Kotlin": 11944}
fun main() { fun part1(input: List<String>): Int { var maxAccumulated = 0 var accumulated = 0 for (calories in input) { if (calories.isEmpty()) { accumulated = 0 continue } val value = calories.toInt() accumula...
0
Kotlin
0
0
a9026a0253716d36294709a547eaddffc6387261
1,258
advent-of-code-2022-kotlin
Apache License 2.0
src/aoc2022/Day09.kt
Playacem
573,606,418
false
{"Kotlin": 44779}
package aoc2022 import utils.readInput import kotlin.math.abs private data class Pos(val x: Int, val y: Int) private data class Day09Command(val direction: String, val times: Int) private operator fun Pos.plus(pair: Pair<Int, Int>): Pos { val (plusX, plusY) = pair return this.copy(x = this.x + plusX, y = thi...
0
Kotlin
0
0
4ec3831b3d4f576e905076ff80aca035307ed522
4,570
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1401_1500/s1449_form_largest_integer_with_digits_that_add_up_to_target/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1449_form_largest_integer_with_digits_that_add_up_to_target // #Hard #Array #Dynamic_Programming #2023_06_07_Time_201_ms_(100.00%)_Space_38.8_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun largestNumber(cost: IntArray, target: Int): String { var target = target v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,881
LeetCode-in-Kotlin
MIT License
src/Day01.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
import java.util.* fun main() { fun part1(input: List<String>): Int { var maxCalories = -1 var currentCalories = 0 input.forEach { line -> if (line.isEmpty()) { if (currentCalories > maxCalories) { maxCalories = currentCalories ...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
1,390
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2022/day24/Day24.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day24 import com.jacobhyphenated.advent2022.Day import java.util.PriorityQueue import kotlin.math.absoluteValue /** * Day 24: <NAME> * * The puzzle input represents an area with open spaces and blizzards. * Each blizzard moves in a defined direction. When the blizzard reache...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
6,539
advent2022
The Unlicense
src/main/kotlin/com/colinodell/advent2023/Day18.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day18(input: List<String>) { private val regex = Regex("""([UDLR]) (\d+) \(#(\w+)\)""") private val originalDigPlan = input.map { val (dir, dist) = regex.matchEntire(it)!!.destructured getDirection(dir[0]).vector() * dist.toLong() } private val ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
1,371
advent-2023
MIT License
src/main/kotlin/kt/kotlinalgs/app/dynprog/Coins.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.dynprog Solution().test() /* 11: 10,1 5,5,1 5,1,1,1,1,1,1 1,1,1,1,1,1,1,1,1,1,1 10: 1 or 0 5: 0,1 or 2 1: 0,1,2,3,4,5,6 ways(1x10) + ways(0x10) ways(1x10) = ways(1x1) = 1 ways(1x1) = 1 ways(0x10) = ways(2x5) + ways(1x5) + ways(0x5) ways(2x5) = ways(1x1) ways(1x5) = ways(6x5) ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,827
KotlinAlgs
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/GarbageCollection.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
3,430
kotlab
Apache License 2.0
src/main/kotlin/day2.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
const val RED_MAX = 12 const val GREEN_MAX = 13 const val BLUE_MAX = 14 fun day2 (lines: List<String>) { var sum = 0 var powerSum = 0 lines.forEach { sum += getIdToSum(it) powerSum += getPowerOfSetToSum(it) } println("Day 2 part 1: $sum") println("Day 2 part 2: $...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
1,899
advent_of_code_2023
MIT License
src/Day07.kt
realpacific
573,561,400
false
{"Kotlin": 59236}
fun main() { open class Directory(open val name: String) { val children = mutableListOf<Directory>() var parentDir: Directory? = null override fun toString(): String { return "Directory(name=${name}, parentDir=${parentDir})" } } class File(override val name: St...
0
Kotlin
0
0
f365d78d381ac3d864cc402c6eb9c0017ce76b8d
4,660
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day19/Day19Puzzle1.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day19 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver class Day19Puzzle1 : PuzzleSolver { override fun solve(inputLines: Sequence<String>) = numberOfBeacons(inputLines).toString() private fun numberOfBeacons(scannerData: Sequence<Stri...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
4,261
AdventOfCode2021
Apache License 2.0
src/main/kotlin/days/Solution20.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution typealias FlipFlopState = MutableMap<String, Boolean> typealias ConjunctionState = MutableMap<String, MutableMap<String, Boolean>> typealias ModuleGraph = Map<String, Set<String>> object Solution20 : Solution<Triple<ModuleGraph, FlipFlopState...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
3,843
Advent-of-Code-2023
MIT License
src/main/kotlin/g2501_2600/s2561_rearranging_fruits/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2561_rearranging_fruits // #Hard #Array #Hash_Table #Greedy #2023_07_07_Time_746_ms_(100.00%)_Space_60.5_MB_(100.00%) class Solution { fun minCost(basket1: IntArray, basket2: IntArray): Long { val n = basket1.size val map1: MutableMap<Int, Int> = HashMap() val map2: Mut...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,035
LeetCode-in-Kotlin
MIT License