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/Day06.kt
inssein
573,116,957
false
{"Kotlin": 47333}
fun main() { fun naive(input: String, capacity: Int): Int { return input.windowedSequence(capacity).indexOfFirst { it.toSet().size == capacity } + capacity } fun trackDuplicate(input: String, capacity: Int): Int { val duplicateMap = IntArray(26) var lastDuplicate...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,533
advent-of-code-2022
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day07.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution import java.util.* object Day07 : AdventSolution(2018, 7, "The Sum of Its Parts") { override fun solvePartOne(input: String): String { val prerequisites = parse(input) val open = ('A'..'Z').toSortedSet() val completed = muta...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,149
advent-of-code
MIT License
src/Day05.kt
kprow
573,685,824
false
{"Kotlin": 23005}
fun main() { fun part1(input: List<String>, stackListLocation: Int): String { val stack = Stack(input[stackListLocation]) for (i in 0..stackListLocation - 1) { val row = input[i] for (x in 1..row.length step 4) { val stackNum = ((x - 1) / 4) + 1 ...
0
Kotlin
0
0
9a1f48d2a49aeac71fa948656ae8c0a32862334c
3,413
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordSearch2.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
2,526
kotlab
Apache License 2.0
src/Day21.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
import java.text.NumberFormat fun main() { fun part1(input: List<String>): Unit { val monkeyMathWorld = mutableMapOf<String, () -> Long>() input.forEach { line -> val (monkeyName, calcString) = line.split(": ") val calcSplit = calcString.split(" ") when (calcSpl...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
3,503
advent-of-code-2022-kietyo
Apache License 2.0
src/Day20.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import kotlin.math.abs fun main() { fun solve(input: List<String>, repeatTimes: Int, multiplier: Int): Long { val raw = input.map { it.toLong() * multiplier} val arr = raw.withIndex().map { "${it.value}_${it.index}" }.toTypedArray() val posMap = arr.withIndex().associate { it.value to it.index }.toMut...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
1,434
aoc-2022-in-kotlin
Apache License 2.0
src/utils/OutputFun.kt
ShMPMat
414,333,726
false
null
package shmp.utils import kotlin.math.max import kotlin.math.pow /** * Adds right text to the left text. right text will be lined up with * consideration to longest line from the left text. * * @param guarantiedLength if left fragment is already has equal length of lines. * @return left and right text merged in ...
0
Kotlin
0
0
c5368fa0c9786fe5c957b2e5edf706dd7ebf8014
3,495
GenerationUtils
MIT License
src/main/kotlin/g0901_1000/s0907_sum_of_subarray_minimums/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0907_sum_of_subarray_minimums // #Medium #Array #Dynamic_Programming #Stack #Monotonic_Stack // #2023_04_14_Time_341_ms_(100.00%)_Space_44.3_MB_(100.00%) class Solution { private fun calculateRight(i: Int, start: Int, right: IntArray, arr: IntArray, len: Int): Int { if (start >= len) {...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,573
LeetCode-in-Kotlin
MIT License
src/Day09.kt
pimtegelaar
572,939,409
false
{"Kotlin": 24985}
fun main() { data class Knot(var x: Int, var y: Int, val follower: Knot? = null) { val tail: Knot = follower?.tail ?: this fun move(direction: String) { when (direction) { "R" -> x++ "L" -> x-- "U" -> y-- "D" -> y++ ...
0
Kotlin
0
0
16ac3580cafa74140530667413900640b80dcf35
2,444
aoc-2022
Apache License 2.0
src/Day01.kt
winnerwinter
573,917,144
false
{"Kotlin": 20685}
fun main() { fun separateElves(input: List<String>): List<List<Int>> { val elfSeparators = input.mapIndexedNotNull { i, str -> i.takeIf { str.isEmpty() } } val elfSeparatorsWithEnds = listOf(0, *elfSeparators.toTypedArray(), input.size) val elfIndices = elfSeparatorsWithEnds.windowed(2) ...
0
Kotlin
0
0
a019e5006998224748bcafc1c07011cc1f02aa50
1,301
advent-of-code-22
Apache License 2.0
src/main/kotlin/dec23/Main.kt
dladukedev
318,188,745
false
null
package dec23 import kotlin.collections.HashMap class CupList<T>(input: List<T>) { val map = input.mapIndexed { index, self -> val next = if(index+1 == input.count()) { 0 } else { index+1 } self to input[next] }.toMap() as HashMap data class Node<...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
3,540
advent-of-code-2020
MIT License
src/day17/day17.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day17 import readInput private const val WIDTH = 7 private const val COL_INDEX = 2 private const val HEIGHT_OFFSET = 4 private enum class Rock(val field: Array<Pair<Int, Int>>) { HORIZONTAL_LINE(field = arrayOf(Pair(0, 0), Pair(0, 1), Pair(0, 2), Pair(0, 3))), CROSS(field = arrayOf(Pair(0, 1), Pair(1...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
4,853
aoc-2022
Apache License 2.0
src/Day18.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.util.LinkedList private val neighbours = listOf( Vec3(1, 0, 0), Vec3(-1, 0, 0), Vec3(0, 1, 0), Vec3(0, -1, 0), Vec3(0, 0, 1), Vec3(0, 0, -1), ) private fun vectorInRange(vector: Vec3, space: List<List<List<Boolean>>>): Boolean { return vector.z in space.indices && v...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
4,037
advent-of-code-2022
Apache License 2.0
src/Day10.kt
achugr
573,234,224
false
null
import kotlin.math.abs fun main() { fun getOperationPerCycle(input: List<String>) = input.flatMap { when { it.startsWith("noop") -> listOf(0) it.startsWith("addx") -> listOf(0, it.replace("addx", "").trim().toInt()) else -> throw IllegalArgumentException("Unexpected inpu...
0
Kotlin
0
0
d91bda244d7025488bff9fc51ca2653eb6a467ee
1,544
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2019/day03_crossed_wires/CrossedWires.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2019.day03_crossed_wires import geom2d.Dir import geom2d.Point import geom2d.toDir fun main() { util.solve(1084, ::partOne) util.solve(9240, ::partTwo) } data class Step(val dir: Dir, val n: Long) private fun String.toStep() = Step( this.first().toDir(), this.substring(1).toLo...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,489
aoc-2021
MIT License
src/main/kotlin/treesandgraphs/LongestIncreasingPathInMatrix.kt
e-freiman
471,473,372
false
{"Kotlin": 78010}
package treesandgraphs private var memo: Array<IntArray>? = null private fun dfs(matrix: Array<IntArray>, i: Int, j: Int): Int { if (memo!![i][j] != -1) { return memo!![i][j] } var maxLength = 0 if (i > 0 && matrix[i - 1][j] > matrix[i][j]) maxLength = maxOf(maxLength, dfs(matrix, i...
0
Kotlin
0
0
fab7f275fbbafeeb79c520622995216f6c7d8642
1,086
LeetcodeGoogleInterview
Apache License 2.0
src/main/kotlin/codes/jakob/aoc/solution/Day04.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
package codes.jakob.aoc.solution object Day04 : Solution() { override fun solvePart1(input: String): Any { val lines: List<String> = input.split("\n\n") val numberDrawer: ListIterator<Int> = lines.first().split(",").map { it.toInt() }.listIterator() val boards: Collection<BingoBoard> = par...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
4,584
advent-of-code-2021
MIT License
src/Day11.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun List<String>.parseMonkeys(): List<Monkey> { return plus("").chunked(7).map { strings -> Monkey( items = strings[1] .substringAfter("Starting items: ") .split(", ") .map(String::toLong) ...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
4,450
aoc-2022
Apache License 2.0
src/main/kotlin/g0301_0400/s0327_count_of_range_sum/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0327_count_of_range_sum // #Hard #Array #Binary_Search #Ordered_Set #Divide_and_Conquer #Segment_Tree #Binary_Indexed_Tree // #Merge_Sort #2022_11_12_Time_638_ms_(100.00%)_Space_63.6_MB_(25.00%) class Solution { fun countRangeSum(nums: IntArray, lower: Int, upper: Int): Int { val n = n...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,516
LeetCode-in-Kotlin
MIT License
dcp_kotlin/src/main/kotlin/dcp/day229/day229.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day229 // day229.kt // By <NAME>, 2019. import java.util.LinkedList import kotlin.math.min typealias ID = Int typealias Moves = Int typealias Edges = Map<ID, Moves> // Snakes and ladders are both just different forms of transporters. typealias Transporters = Map<ID, ID> data class Node(val id: ID, val e...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,409
daily-coding-problem
MIT License
gcj/y2022/kickstart_c/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2022.kickstart_c private fun solve(): String { val (n, len) = readInts() val ants = List(n) { readInts() } val falls = ants.map { ant -> (if (ant[1] == 0) ant[0] else len - ant[0]) to ant[1] }.sortedBy { it.first } val order = ants.withIndex().sortedBy { it.value[0] }.map { it.index } var low = 0 ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
878
competitions
The Unlicense
src/Day05.kt
makohn
571,699,522
false
{"Kotlin": 35992}
import java.util.Stack fun main() { fun part1(input: String): String { val stacks = mutableListOf<Stack<Char>>() val (vis, moves) = input.split("\n\n") vis.lines() .reversed() .drop(1) .forEach { it.filterIndexed { i, _ -> i % 4 == 1 ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
2,145
aoc-2022
Apache License 2.0
src/Day03.kt
Yasenia
575,276,480
false
{"Kotlin": 15232}
import java.util.BitSet fun main() { fun Char.priority(): Int = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(this) + 1 fun part1(input: List<String>): Int { var totalPriority = 0 for (rucksack in input) { val compartment1 = rucksack.substring(0, rucksack.length /...
0
Kotlin
0
0
9300236fa8697530a3c234e9cb39acfb81f913ba
1,914
advent-of-code-kotlin-2022
Apache License 2.0
src/Day07.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun List<String>.parse(): Map<String, Int> { val cwd = mutableListOf<String>() val result = hashMapOf<String, Int>() for (line in this) { val args = line.split(' ') when (args[0]) { "$" -> when (args[1]) { "cd" -> when...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
1,537
aockt
Apache License 2.0
src/Day06.kt
davedupplaw
573,042,501
false
{"Kotlin": 29190}
fun main() { fun findFirstPositionAndCharsOfN(input: String, n: Int): Pair<Int, String> { return input.windowed(n, 1).asSequence() .mapIndexed { i, s -> (i + n) to s } .first { it.second.toHashSet().size == it.second.length && it.second.length == n } } fun part1(inpu...
0
Kotlin
0
0
3b3efb1fb45bd7311565bcb284614e2604b75794
1,779
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2023/d14/Day14.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2023.d14 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.Direction import com.groundsfam.advent.Direction.DOWN import com.groundsfam.advent.Direction.LEFT import com.groundsfam.advent.Direction.RIGHT import com.groundsfam.advent.Direction.UP import com.groundsfam.adven...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,570
advent-of-code
MIT License
src/Day09.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { return getUniquePositionsVisitedByTailCount(input, 2) } fun part2(input: List<String>): Int { return getUniquePositionsVisitedByTailCount(input, 10) } val testInput = readInput("Day09_test") check(part1(...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
3,524
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day12_passage_pathing/PassagePathing.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day12_passage_pathing import java.util.* /** * Another graph, specified solely by the edges (the nodes are implied). The * right data structure is required, though it needn't be a fancy variant. A * simple adjacency list is plenty, and a symbol table isn't required. With the * right structure populated fr...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
4,167
aoc-2021
MIT License
src/Day08.kt
Kanialdo
573,165,497
false
{"Kotlin": 15615}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { val area = input.map { row -> row.toCharArray().map { it.digitToInt() } } val visibility = Array(area.size) { BooleanArray(area.first().size) { false } } val dimension = area.size for (y in 1 until dimensio...
0
Kotlin
0
0
10a8550a0a85bd0a928970f8c7c5aafca2321a4b
3,423
advent-of-code-2022
Apache License 2.0
src/Day10.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
import kotlin.math.abs data class State( val cycle: Int, val X: Int, val signalStrengths: MutableMap<Int, Int> ) class Day10 { fun part1(instructions: List<String>): Int { var state = State(1, 1, mutableMapOf()) for (instruction in instructions) { val commandWithOptionalPar...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
2,247
advent-of-code
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day08.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay typealias Forest = List<List<Int>> fun Forest.isVisible(x: Int, y: Int): Boolean { val ownHeight = this[x][y] val leftVisible = (0 until x).all { this[it][y] < ownHeight } val rightVisible = (x + 1 until this[x].size).all { this[it][y] < ownHeight } val topVisible =...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,142
advent-of-code
Apache License 2.0
src/main/kotlin/day5.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* fun main() { val input = Input.day(5) println(day5A(input)) println(day5B(input)) } fun day5A(input: Input): Long { val seeds = input.chunks[0].toLongs() val categories = input.chunks.drop(1).map(Category::from) val mapped = seeds.map { seed -> categories.fold(seed) { v...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,614
AdventOfCode2023
MIT License
src/com/aaron/helloalgorithm/algorithm/二叉树/_226_翻转二叉树.kt
aaronzzx
431,740,908
false
null
package com.aaron.helloalgorithm.algorithm.二叉树 import com.aaron.helloalgorithm.algorithm.LeetCode import com.aaron.helloalgorithm.algorithm.TreeNode import com.aaron.helloalgorithm.structure.tree.ktx.println import com.aaron.helloalgorithm.structure.tree.printer.BinaryTrees import java.util.* /** * # 226. 翻转一棵二叉树 *...
0
Kotlin
0
0
2d3d823b794fd0712990cbfef804ac2e138a9db3
4,175
HelloAlgorithm
Apache License 2.0
src/main/kotlin/com/sk/topicWise/binarysearch/33. Search in Rotated Sorted Array.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.binarysearch class Solution33 { fun search(nums: IntArray, target: Int): Int { if (nums.isEmpty()) return -1 // find smallest element, use it's index as rotation count var l = 0 var r = nums.lastIndex while (l < r) { val mid = l + (r - l...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,449
leetcode-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/SummaryRanges.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 228. 汇总区间 * 给定一个无重复元素的有序整数数组 nums 。 * * 返回 恰好覆盖数组中所有数字 的 最小有序 区间范围列表。也就是说,nums 的每个元素都恰好被某个区间范围所覆盖,并且不存在属于某个范围但不属于 nums 的数字 x 。 * * 列表中的每个区间范围 [a,b] 应该按如下格式输出: * * "a->b" ,如果 a != b * "a" ,如果 a == b * * 示例 1: * * 输入:nums = [0,1,2,4,5,7] * 输出:["0->2","4->5","7"] ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,589
daily_algorithm
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day09.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.main object Day09 : Day { override val number: Int = 9 override fun part1(input: List<String>): String = solve(input) { histories -> histories.foldRight(0) { ints, acc -> ints.last(...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
1,388
advent-of-code
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[561]数组拆分 I.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //给定长度为 2n 的整数数组 nums ,你的任务是将这些数分成 n 对, 例如 (a1, b1), (a2, b2), ..., (an, bn) ,使得 //从 1 到 n 的 min(ai, bi) 总和最大。 // // 返回该 最大总和 。 // // // // 示例 1: // // //输入:nums = [1,4,3,2] //输出:4 //解释:所有可能的分法(忽略元素顺序)为: //1. (1, 4), (2, 3) -> min(1, 4) + min(2, 3) = 1 + 2 = 3 //2. (1, 3), (2, 4) -> min(1, 3) +...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,371
MyLeetCode
Apache License 2.0
2021/src/main/kotlin/day9_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.Solution fun main() { Day9Imp.run() } object Day9Imp : Solution<IntGrid>() { override val name = "day9" override val parser = IntGrid.singleDigits.map { it.borderWith(9) } override fun part1(input: IntGrid): Int { var sum = 0 for (y in 1 until input.height - 1) { ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,406
aoc_kotlin
MIT License
src/Day03.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
import kotlin.IllegalArgumentException fun main() { fun valueForChar(char: Char): Int { return when (char) { 'a' -> 1 'b' -> 2 'c' -> 3 'd' -> 4 'e' -> 5 'f' -> 6 'g' -> 7 'h' -> 8 'i' -> 9 ...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
2,433
aoc-2022-in-kotlin
Apache License 2.0
src/day03/Day03_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day03 import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private fun Char.priority(): Int = whe...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
1,295
aoc2022
Apache License 2.0
src/Day04/Day04.kt
SelenaChen123
573,253,480
false
{"Kotlin": 14884}
import java.io.File fun main() { fun part1(input: List<String>): Int { var duplicates = 0 for (line in input) { val first = line.split(",")[0].split("-") val second = line.split(",")[1].split("-") if ((second[0].toInt() in first[0].toInt()..first[1].toInt() && ...
0
Kotlin
0
0
551af4f0efe11744f918d1ff5bb2259e34c5ecd3
1,667
AdventOfCode2022
Apache License 2.0
2021/03/07/jjeda/Sorting.kt
Road-of-CODEr
323,110,862
false
null
// https://app.codility.com/programmers/lessons/6-sorting/distinct/ fun distinct(A: IntArray): Int { return A.toSet().size } // https://app.codility.com/programmers/lessons/6-sorting/max_product_of_three/ fun maxProductOfThree(A: IntArray): Int { val indexWithA = A.withIndex().sortedBy { it.value } val length =...
1
Java
25
22
cae1df83ac110519a5f5d6b940fa3e90cebb48c1
1,566
stupid-week-2021
MIT License
2k23/aoc2k23/src/main/kotlin/06.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d06 import input.read import kotlin.math.* fun main() { println("Part 1: ${part1(read("06.txt"))}") println("Part 2: ${part2(read("06.txt"))}") } fun part1(input: List<String>): Long = input .map { line -> line.split(" ").mapNotNull { it.toLongOrNull() } } .let { (a, b) -> a.zip(b) } .fol...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
924
aoc
The Unlicense
day06/kotlin/corneil/src/main/kotlin/solution.kt
timgrossmann
224,991,491
true
{"HTML": 2739009, "Python": 169603, "Java": 157274, "Jupyter Notebook": 116902, "TypeScript": 113866, "Kotlin": 89503, "Groovy": 73664, "Dart": 47763, "C++": 43677, "CSS": 34994, "Ruby": 27091, "Haskell": 26727, "Scala": 11409, "Dockerfile": 10370, "JavaScript": 6496, "PHP": 4152, "Go": 2838, "Shell": 2493, "Rust": 208...
package com.github.corneil.aoc2019.day6 import java.io.File class OrbitData { fun addOrbit(obj: String, orbiting: String) { assert(orbits[orbiting] == null) orbits[orbiting] = Orbit( objects[obj] ?: createObj(obj), objects[orbiting] ?: createObj(orbiting) ) } ...
0
HTML
0
1
bb19fda33ac6e91a27dfaea27f9c77c7f1745b9b
2,671
aoc-2019
MIT License
src/main/java/challenges/leetcode/StringPermutation.kt
ShabanKamell
342,007,920
false
null
package challenges.leetcode /* Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example 1: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("b...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,493
CodingChallenges
Apache License 2.0
2016/main/day_07/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_07_2016 import java.io.File fun part1(input: List<String>) { input.filter { val hypernets = it.split('[').drop(1).map { it1 -> it1.split(']')[0] }.any { it1 -> it1.windowed(4).any { it2 -> it2[0] == it2[3] && it2[1] == it2[2] && it2[0] != it2[1] } } if (hypernets) f...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,609
AdventofCode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxSubarraySumCircular.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,239
kotlab
Apache License 2.0
src/Day02.kt
stcastle
573,145,217
false
{"Kotlin": 24899}
/** Beats is the option that the current one beats. */ enum class PlayOption() { ROCK, PAPER, SCISSORS, } fun String.toPlayOption(): PlayOption = when (this) { "A", "X" -> PlayOption.ROCK "B", "Y" -> PlayOption.PAPER "C", "Z" -> PlayOption.SCISSORS else -> throw Exce...
0
Kotlin
0
0
746809a72ea9262c6347f7bc8942924f179438d5
2,544
aoc2022
Apache License 2.0
src/Day03.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { val alphabet = "abcdefghijklmnopqrstuvwxyz" val score = (" " + alphabet + alphabet.uppercase()).toList() fun Char.priority() = score.indexOf(this) fun part1(input: List<String>): Int { return input.sumOf { val mid = it.length / 2 val first = it.substring(0 ...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
1,067
advent-of-code-kotlin-2022
Apache License 2.0
src/Day09.kt
carloxavier
574,841,315
false
{"Kotlin": 14082}
import kotlin.math.absoluteValue fun main() { check(simulateHeadTailMovements(readInput("Day09_test")).size == 13) // Part1 println(simulateHeadTailMovements(readInput("Day09")).size) } private fun simulateHeadTailMovements(inputMoves: List<String>): HashSet<Position> { val tailPositions = hashSetOf...
0
Kotlin
0
0
4e84433fe866ce1a8c073a7a1e352595f3ea8372
1,803
adventOfCode2022
Apache License 2.0
app/src/main/kotlin/com/bloidonia/advent2020/Day_07.kt
timyates
317,965,519
false
null
package com.bloidonia.advent2020 import com.bloidonia.linesFromResource class Day_07(input: List<String>) { data class Bag(val quantity: Int, val color: String) // Split the sentences into bag colours and numbers fun tokenize(input: String) = input.split("bag[s]?|contain|,|\\.|no other".toRegex(...
0
Kotlin
0
0
cab3c65ac33ac61aab63a1081c31a16ac54e4fcd
2,326
advent-of-code-2020-kotlin
Apache License 2.0
src/day14/Day14.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day14 import readInput const val day = "14" fun main() { fun calculatePart1Score(input: List<String>): Int { val allLines = input.map { line -> line.split(" -> ") .map { it.split(",") } .map { (x, y) -> Coordinate(x.toInt(), y.toInt()) } ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
5,552
advent-of-code-22-kotlin
Apache License 2.0
src/Day03.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
// Day 03, Advent of Code 2022, Rucksack Reorganization fun main() { fun getScore(input: Char) = when (input) { in 'a'..'z' -> input.code - 'a'.code + 1 in 'A'..'Z' -> input.code - 'A'.code + 27 else -> { check(false) -100000 ...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
1,519
AdventOfCode2022
Apache License 2.0
src/Day10.kt
wujingwe
574,096,169
false
null
object Day10 { private fun ops(inputs: List<String>): List<Int> { return inputs.flatMap { s -> val tokens = s.split(" ") when (tokens[0]) { "noop" -> listOf(0) "addx" -> listOf(0, tokens[1].toInt()) else -> emptyList() } ...
0
Kotlin
0
0
a5777a67d234e33dde43589602dc248bc6411aee
1,711
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02/Day02.kt
brhliluk
572,914,305
false
{"Kotlin": 16006}
fun main() { fun part1(input: List<String>) = input.map { MyMove.byLetter(it[2])!!.getFightResult(OponentMove.byLetter(it[0])!!) + MyMove.byLetter(it[2])!!.value }.reduce { acc, result -> acc + result } fun part2(input: List<String>) = input.map { val oponentMove = OponentMove.byLetter(it[0...
0
Kotlin
0
0
96ac4fe0c021edaead8595336aad73ef2f1e0d06
2,482
kotlin-aoc
Apache License 2.0
src/Day20.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
fun main() { val magicIndices = listOf(1000, 2000, 3000) fun solve(input: List<String>, key: Long = 1, iterations: Int = 1): Long { val sequence = input.map { it.toInt() * key }.withIndex().toMutableList() repeat (iterations) { for (originalIndex in sequence.indices) { ...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
1,088
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-25.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.time.measureTime fun main() { val input = readInputLines(2023, "25-input") val test1 = readInputLines(2023, "25-test1") println("Part1:") ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,770
advent-of-code
MIT License
src/main/kotlin/dec5/Main.kt
dladukedev
318,188,745
false
null
package dec5 import java.lang.Exception import kotlin.math.ceil import kotlin.math.floor data class BoardingPassDirections( val rowDirections: List<Direction>, val seatDirections: List<Direction> ) data class BoardingPass( val row: Int, val seat: Int ) enum class Direction { FRONT, BACK, ...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
2,729
advent-of-code-2020
MIT License
src/main/kotlin/com/jacobhyphenated/advent2022/day4/Day4.kt
jacobhyphenated
573,603,184
false
{"Kotlin": 144303}
package com.jacobhyphenated.advent2022.day4 import com.jacobhyphenated.advent2022.Day // Use type aliases to avoid repeatedly writing a bunch of Pair<> types typealias Section = Pair<Int,Int> typealias SectionGroup = Pair<Section, Section> /** * Day 4: Camp Cleanup * * Each group of two elves is assigned 2 sectio...
0
Kotlin
0
0
9f4527ee2655fedf159d91c3d7ff1fac7e9830f7
2,268
advent2022
The Unlicense
src/Day04.kt
rod41732
728,131,475
false
{"Kotlin": 26028}
/** * You can edit, run, and share this code. * play.kotlinlang.org */ fun main() { val testInput = readInput("Day04_test") val input = readInput("Day04") fun part1(input: List<String>): Int { return input .map { val (winnings, owned) = it.substringAfter(":").split("|...
0
Kotlin
0
0
05a308a539c8a3f2683b11a3a0d97a7a78c4ffac
1,438
aoc-23
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1235/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1235 import kotlin.math.max /** * LeetCode page: [1235. Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling/); */ class Solution { /* Complexity: * Time O(NLogN) and Space O(N) where N is the size of startTime/endTime/profit...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,816
hj-leetcode-kotlin
Apache License 2.0
src/Day10.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
fun main() { fun part1(input: List<String>): Int { val computation = sequence { var x = 1 var cycle = 1 for (instruction in input) { val splitInstruction = instruction.split(" ") val op = splitInstruction.first() val arg ...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
2,307
2022-Advent-of-Code
Apache License 2.0
src/aoc2022/Day19_.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.checkEquals import utils.sendAnswer // //private sealed class Goods{ // data class ORE(val oreCost: Int) : Goods() // data class CLAY(val oreCost: Int) : Goods() // data class OBSIDIAN(val oreCost: Int, val clayCost: Int) : Goods() // data class GEODE(val oreCost: Int, val ob...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
3,942
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/io/combination/CombinationSumII.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.combination import io.utils.runTests // https://leetcode.com/problems/combination-sum-ii/ class CombinationSumII { fun execute(input: IntArray, target: Int): List<List<Int>> { val validValues = input.filter { it <= target } if (validValues.isEmpty()) return emptyList() val result = mutableSe...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,703
coding
MIT License
src/day07/Day07.kt
palpfiction
572,688,778
false
{"Kotlin": 38770}
package day07 import readInput import java.lang.IllegalArgumentException sealed class File(val name: String, val parent: Directory?) { abstract val size: Int } class Directory( name: String, parent: Directory? = null, ) : File(name, parent) { var contents: MutableList<File> = mutableListOf() over...
0
Kotlin
0
0
5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7
4,366
advent-of-code
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/RussianDollEnvelopes.kt
faniabdullah
382,893,751
false
null
//You are given a 2D array of integers envelopes where envelopesintArrayOf(i) = intArrayOf(wi, hi) //represents the width and the height of an envelope. // // One envelope can fit into another if and only if both the width and height //of one envelope are greater than the other envelope's width and height. // // Ret...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,923
dsa-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem983/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem983 /** * LeetCode page: [983. Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the size of days; */ fun mincostTickets(days: IntArray, costs: IntArray):...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,843
hj-leetcode-kotlin
Apache License 2.0
src/Day02.kt
AleksanderBrzozowski
574,061,559
false
null
import java.lang.IllegalArgumentException class Part1 { fun run() { val testGame = game("Day02_test") println(testGame.sumOf { it.score() }) } private fun String.toShape() = when (this) { "A", "X" -> Shape.ROCK "B", "Y" -> Shape.PAPER "C", "Z" -> Shape.SCISSORS ...
0
Kotlin
0
0
161c36e3bccdcbee6291c8d8bacf860cd9a96bee
3,598
kotlin-advent-of-code-2022
Apache License 2.0
src/Day21.kt
Excape
572,551,865
false
{"Kotlin": 36421}
fun main() { data class Expression(var left: Any, var right: Any, val operand: Char) { fun evaluate(): ULong { assert(left is ULong) assert(right is ULong) val l = left as ULong val r = right as ULong val result = when (operand) { ...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
4,470
advent-of-code-2022
Apache License 2.0
src/Day20.kt
syncd010
324,790,559
false
null
import kotlin.math.min class Day20: Day { // This represents a leg of a path data class Leg(val to: String, val steps: Int, val level: Int) private val dirs = listOf(Position(0, -1), Position(1, 0), Position(0, 1), Position(-1, 0)) fun convert(input: List<String>) : Map<String, List<Leg>> { f...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
5,782
AoC2019
Apache License 2.0
src/main/kotlin/com/psmay/exp/advent/y2021/Day06.kt
psmay
434,705,473
false
{"Kotlin": 242220}
package com.psmay.exp.advent.y2021 object Day06 { data class LanternfishClock(val timeToNextRespawn: Int) { // Note that this model is equivalent to, but not the same as, the problem description, which // always puts the new fish at the end. fun ageOneDay(): List<LanternfishClock> { ...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
2,895
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
advent-of-code-2021/src/main/kotlin/Day5.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 5: Hydrothermal Venture //https://adventofcode.com/2021/day/5 import java.io.File val regex = Regex("""(\d+),(\d+) -> (\d+),(\d+)""") fun main() { val lines = File("src/main/resources/Day5.txt").readLines() val vents = lines.map { regex.matchEntire(it)!! .destructured .l...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,526
advent-of-code
Apache License 2.0
src/Day08.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
fun main() { val input = readInput("Day08") val nodes = (2..<input.size).associate { i -> val line = input[i].split("=") val node = line[0].trim() val steps = line[1].split(",").map { it.trim() }.let { it[0].substring(1) to it[1].dropLast(1) } node to steps ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
1,532
aoc-2023
Apache License 2.0
src/Day03.kt
JCofman
576,062,635
false
{"Kotlin": 6297}
fun parseInput(rawInput: String) = rawInput val alphabetScore = mapOf( 'a' to 1, 'b' to 2, 'c' to 3, 'd' to 4, 'e' to 5, 'f' to 6, 'g' to 7, 'h' to 8, 'i' to 9, 'j' to 10, 'k' to 11, 'l' to 12, 'm' to 13, 'n' to 14, 'o' to 15, 'p' to 16, 'q' to 17, ...
0
Kotlin
0
1
c25a54b03df77c1be46827642b6adc7644825c8c
3,076
aoc-2022-in-kotlin
Apache License 2.0
solutions/aockt/y2021/Y2021D13.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import aockt.util.OcrDecoder import io.github.jadarma.aockt.core.Solution object Y2021D13 : Solution { /** Represents a discrete point in 2D space. */ private data class Point(val x: UInt, val y: UInt) /** Represents a possible origami fold. */ private sealed interface Fold { ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,578
advent-of-code-kotlin-solutions
The Unlicense
kotlin/src/com/s13g/aoc/aoc2015/Day9.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2015 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom import kotlin.math.max import kotlin.math.min /** * --- Day 9: All in a Single Night --- * https://adventofcode.com/2015/day/9 */ class Day9 : Solver { override fun solve(lines: List<String>): Result...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,532
euler
Apache License 2.0
2023/src/main/kotlin/Day03.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day03 { data class Pos(val x: Int, val y: Int) data class PartWithSymbol(val number: Int, val symbol: Char, val symbolPos: Pos) fun part1(input: String): Int { return getPartsWithSymbols(input).sumOf { it.number } } fun part2(input: String): Int { return getPartsWithSymbols(input) .fi...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,911
advent-of-code
MIT License
src/Day04.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun part1(input: List<String>): Int = input.asInputForPart1AndPart2().count { it.assignmentsFullyContained() } fun part2(input: List<String>): Int = input.asInputForPart1AndPart2().count { it.assignmentsOverlap() } val input = readInput("Day04") with(::part1) { val exampleResult =...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
1,647
advent-of-code-2022
Apache License 2.0
src/Day11.kt
askeron
572,955,924
false
{"Kotlin": 24616}
class Day11 : Day<Long>(10605, 2713310158L, 58056, 15048718170L) { private class Monkey( private val items: MutableList<Long>, private val operation: (Long) -> Long, private val divisibleForTest: Int, private val monkeyIndexForTrue: Int, private val monkeyIndexForFalse: Int,...
0
Kotlin
0
1
6c7cf9cf12404b8451745c1e5b2f1827264dc3b8
2,318
advent-of-code-kotlin-2022
Apache License 2.0
Collections/Max min/src/TaskExtensionMaxMin.kt
Rosietesting
373,564,502
false
{"HTML": 178715, "JavaScript": 147056, "Kotlin": 113135, "CSS": 105840}
fun main () { val numbers = listOf(45,7,1,0,45,65,2,3) println("Count value ${numbers.count()}") println("Max value ${numbers.max()}") println("Min value ${numbers.min()}") println("Average value ${numbers.average()}") println("Sum value ${numbers.sum()}") println("Min value ${numbers.minB...
0
HTML
0
0
b0aa518d220bb43c9398dacc8a6d9b6c602912d5
2,438
KotlinKoans
MIT License
src/aoc2022/Day04.kt
miknatr
576,275,740
false
{"Kotlin": 413403}
package aoc2022 fun main() { fun IntRange.isFullyContain(range: IntRange) = (this.contains(range.first) && this.contains(range.last)) || (range.contains(this.first) && range.contains(this.last)) fun parseRange(strRange: String): IntRange { val numbers = strRange.split("-") return numbe...
0
Kotlin
0
0
400038ce53ff46dc1ff72c92765ed4afdf860e52
1,101
aoc-in-kotlin
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/dp/RoboticDelivery.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.dp import java.util.ArrayList fun main() { val markings = listOf(listOf(0, 3),listOf(0,5),listOf(0,7),listOf(1,6),listOf(1,8),listOf(1,9),listOf(2,3),listOf(2,5),listOf(2,6)) println(chooseAFlask(markings, 3, listOf(4,6,6,7))) } fun chooseAFlask(markings: List<List<Int>>, fl...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
2,564
DS_Algo_Kotlin
MIT License
src/main/kotlin/days/Solution22.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.Point2D import adventOfCode.util.ints import kotlin.math.max object Solution22 : Solution<Pair<Int, List<Set<Int>>>>(AOC_YEAR, 22) { private operator fun List<Int>.component6() = thi...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
2,191
Advent-of-Code-2023
MIT License
src/day03/day03.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day03 import util.readInput import util.shouldBe fun main() { val day = 3 val testInput = readInput(day, testInput = true).parseInput() part1(testInput) shouldBe 157 part2(testInput) shouldBe 70 val input = readInput(day).parseInput() println("output for part1: ${part1(input)}") p...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
1,150
advent-of-code-2022
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day16 : AdventSolution(2021, 16, "Packet Decoder") { override fun solvePartOne(input: String) = PacketDecoder(input).parsePacket().let(::sumOfVersions) override fun solvePartTwo(input: String) = PacketDecoder(input).parsePacket().let(::ev...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,371
advent-of-code
MIT License
src/Day04.kt
DeltaSonic62
572,718,847
false
{"Kotlin": 8676}
fun main() { fun part1(input: List<String>): Int { var count = 0 for (pair in input) { val first = pair.split(',')[0].split('-'); val second = pair.split(',')[1].split('-'); if ((first[0].toInt() <= second[0].toInt() && first[1].toInt() >= second[1].toInt()) || (...
0
Kotlin
0
0
7cdf94ad807933ab4769ce4995a43ed562edac83
1,218
aoc-2022-kt
Apache License 2.0
src/main/kotlin/days/Day17.kt
andilau
399,220,768
false
{"Kotlin": 85768}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2020/day/17", date = Date(day = 17, year = 2020) ) class Day17(val input: List<String>) : Puzzle { override fun partOne(): Int { return generateSequence( readInput { x, y -> Point3D(x, y, 0) }) { spac...
7
Kotlin
0
0
2809e686cac895482c03e9bbce8aa25821eab100
2,477
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/day5.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import java.math.BigInteger import kotlin.system.exitProcess import kotlin.time.measureTime private const val DAY = 5 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: S...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
4,386
aoc2023
MIT License
src/Day08.kt
jordanfarrer
573,120,618
false
{"Kotlin": 20954}
@file:Suppress("DuplicatedCode") fun main() { val day = "Day08" fun parseMap(input: List<String>): List<Tree> { val trees = mutableListOf<Tree>() input.forEachIndexed { row, line -> line.toCharArray().forEachIndexed { col, treeHeight -> trees.add(Tree(row, col, tree...
0
Kotlin
0
1
aea4bb23029f3b48c94aa742958727d71c3532ac
4,475
advent-of-code-2022-kotlin
Apache License 2.0
src/Day04.kt
elliaoster
573,666,162
false
{"Kotlin": 14556}
fun main() { fun part1(input: List<String>): Int { var counter = 0 for (line in input) { //find the first range val beforeComma = line.split(",").first() val firstP1 = beforeComma.split("-").first().toInt() val firstP2 = beforeComma.split("-").last()....
0
Kotlin
0
0
27e774b133f9d5013be9a951d15cefa8cb01a984
1,890
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day6.kt
EmRe-One
434,793,519
false
{"Kotlin": 44202}
package tr.emreone.adventofcode.days import kotlin.math.max object Day6 { enum class Command { ON, OFF, TOGGLE } fun part1(input: List<String>): Int { val regex = """^(turn on|turn off|toggle) (\d+),(\d+) through (\d+),(\d+)$""".toRegex() val lightsGrid = Array(10...
0
Kotlin
0
0
57f6dea222f4f3e97b697b3b0c7af58f01fc4f53
2,090
advent-of-code-2015
Apache License 2.0
kotlin/graphs/lca/Lca.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.lca import java.util.stream.Stream // Answering LCA queries in O(log(n)) with O(n) preprocessing class Lca(tree: Array<List<Integer>>, root: Int) { var depth: IntArray var dfs_order: IntArray var cnt: Int var first: IntArray var minPos: IntArray var n: Int fun dfs(tree: Arra...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,748
codelibrary
The Unlicense
src/Day25.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
fun main() { check(snafuToDecimal("1=0") == 15L) check(snafuToDecimal("1-0") == 20L) check(snafuToDecimal("1=11-2") == 2022L) check(snafuToDecimal("1-0---0") == 12345L) check(snafuToDecimal("1121-1110-1=0") == 314159265L) check(decimalToSnafu(15) == "1=0") check(decimalToSnafu(20) == "1-0")...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
1,812
AdventOfCode2022
Apache License 2.0
src/Day07.kt
adrianforsius
573,044,406
false
{"Kotlin": 68131}
import org.assertj.core.api.Assertions.assertThat //fun part1(path: Path): Int = path.useLines{ lines -> // lines // .count() data class Node(var children:List<Node>, val name: String, var size: Int = 0, val marked: Boolean=false) { var parent: Node? = null } fun cd(curr: Node, root: Node, cmd: String...
0
Kotlin
0
0
f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb
4,039
kotlin-2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year17/Day07.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year17 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.diff import kotlin.math.absoluteValue fun PuzzleSet.day7() = puzzle(day = 7) { val tree = inputLines.map { l -> val parts = l.split(" -> ") val (name, weightPart) = parts.first().split(" ") ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,772
advent-of-code
The Unlicense
2k23/aoc2k23/src/main/kotlin/01.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d01 import input.read fun main() { println("Part 1: ${part1(read("01.txt"))}") println("Part 2: ${part2(read("01.txt"))}") } fun part1(lines: List<String>): Int { return lines.map { line -> line.filter { it.isDigit() } } .map(::firstLastDigits) .sumOf { it.toInt() } } fun part2(l...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
1,126
aoc
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem1319/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1319 /** * LeetCode page: [1319. Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected/); */ class Solution2 { /* Complexity: * Time O(E) and Space O(n) where E is the size of connections; */ ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,005
hj-leetcode-kotlin
Apache License 2.0
leetcode-75-kotlin/src/main/kotlin/DetermineIfTwoStringsAreClose.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * Two strings are considered close if you can attain one from the other using the following operations: * * Operation 1: Swap any two existing characters. * For example, abcde -> aecdb * Operation 2: Transform every occurrence of one existing character into another existing character, * and do the same with t...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
2,801
leetcode-75
Apache License 2.0
year2021/day09/part1/src/main/kotlin/com/curtislb/adventofcode/year2021/day09/part1/Year2021Day09Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 9: Smoke Basin --- These caves seem to be lava tubes. Parts are even still volcanically active; small hydrothermal vents release smoke into the caves that slowly settles like rain. If you can model how the smoke flows through the caves, you might be able to avoid it and be that much safer. The submarine ge...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,185
AdventOfCode
MIT License
src/Day04.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
fun main() { fun parse(input: List<String>): List<List<IntRange>> = input .flatMap { it.split(",") } .map { it.split("-") } .map { (start, end) -> IntRange(start.toInt(), end.toInt()) } .chunked(2) fun part1(input: List<List<IntRange>>): Int = in...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
1,012
aoc-2022
Apache License 2.0