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/Day10.kt
sabercon
648,989,596
false
null
fun main() { fun countArrangements(jolts: List<Int>): Long { val cache = mutableMapOf<Int, Long>() fun countArrangementsFrom(index: Int): Long { if (index == jolts.lastIndex) return 1 if (index in cache) return cache[index]!! return (index + 1..jolts.lastIndex) ...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
810
advent-of-code-2020
MIT License
src/aoc2022/Day12.kt
Playacem
573,606,418
false
{"Kotlin": 44779}
package aoc2022 import utils.readInput import java.util.* import kotlin.math.abs private object Day12 { data class Pos(val x: Int, val y: Int) data class ElevationMap(val elevation: Map<Pos, Int>, val startPos: Pos, val goalPos: Pos, val maxX: Int, val maxY: Int) fun reconstructPath(cameFrom: Map<Pos, ...
0
Kotlin
0
0
4ec3831b3d4f576e905076ff80aca035307ed522
6,067
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/array/MinimumSizeSubArraySum.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.array import io.utils.runTests // https://leetcode.com/explore/learn/card/array-and-string/205/array-two-pointer-technique/1299/ class MinimumSizeSubArraySum { fun execute(target: Int, input: IntArray): Int { var result = Int.MAX_VALUE var left = 0 var sum = 0 for (index in input.indices...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,302
coding
MIT License
src/main/kotlin/groupnet/util/Combinatorics.kt
AlmasB
174,802,362
false
{"Kotlin": 167480, "Java": 91450, "CSS": 110}
package groupnet.util import org.paukov.combinatorics3.Generator /** * * @author <NAME> (<EMAIL>) */ /** * There is a performance reason to represent a combination using a List, * rather than a Set. * However, all combinations are guranteed to be sets. */ typealias Combination<T> = List<T> /** * A k-combina...
3
Kotlin
0
0
4aaa9de60ecdba5b9402b809e1e6e62489a1d790
2,238
D2020
Apache License 2.0
extension/model/api/src/main/kotlin/data/DmnHitPolicy.kt
holunda-io
240,229,098
false
{"Kotlin": 182949}
package io.holunda.decision.model.api.data import io.holunda.decision.model.api.AggregatorName import io.holunda.decision.model.api.HitPolicyName import io.holunda.decision.model.api.data.ResultType.* /** * Tuple combining camundas HitPolicy and the Aggregator (optional, for collection operations). * * A hit poli...
18
Kotlin
0
6
dbbc98b35d95f53d1a3a78160308c5d955245fbd
2,705
camunda-decision
Apache License 2.0
src/day12/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day12 import java.io.File fun Map<String, List<String>>.partOne(path: List<String>) : List<List<String>> { if (path.last() == "end") { return listOf(path) } return this[path.last()]!! .filter { it.uppercase() == it || !path.contains(it) } .map{ partOne( path + it) } ...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,160
advent-of-code-2021
MIT License
Kotlin/problems/0054_sum_of_even_numbers_after_queries.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
// Problem Statement // We have an array A of integers, and an array queries of queries. // // For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. // Then, the answer to the i-th query is the sum of the even values of A. // // (Here, the given index = queries[i][1] is a 0-based index,...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,438
algorithms
MIT License
app/src/main/java/dev/zezula/books/util/StringExtensions.kt
zezulaon
589,699,261
false
{"Kotlin": 556103}
package dev.zezula.books.util import android.util.Patterns /** * List of articles in different languages. Used for sorting - if a book title contains an article, it should be * ignored (removed) when sorting. */ private val articles = listOf( "The", "A", "An", // English "Le", "La", "Les", "Un", "Une", // ...
1
Kotlin
0
6
84750e18ee62d57081096275936ded053b64e6f1
2,422
my-library
Apache License 2.0
kotlin/2018/src/main/kotlin/2018/Lib04.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
package aoc.kt.y2018; import java.time.LocalDateTime import java.util.Locale import java.time.format.DateTimeFormatter import java.time.temporal.ChronoUnit /** * Day 4. */ data class Message(val dateTime: LocalDateTime, val text: String) /** Part 1 */ fun processRepose1(input: String): String { val guardMap =...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
3,980
adventofcode
MIT License
src/main/kotlin/com/marcdenning/adventofcode/day21/Day21a.kt
marcdenning
317,730,735
false
{"Kotlin": 87536}
package com.marcdenning.adventofcode.day21 import java.io.File fun main(args: Array<String>) { val foods = File(args[0]).readLines().map { Food(getIngredients(it), getIdentifiedAllergens(it)) } val allIngredientsList = foods.flatMap { it.ingredients } val safeIngredients = getSafeIngredients(foods) va...
0
Kotlin
0
0
b227acb3876726e5eed3dcdbf6c73475cc86cbc1
1,685
advent-of-code-2020
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions11.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import kotlin.math.min fun test11() { fun IntArray.printlnResult() = println("Find the IntArray ${toList()}'s smallest number is ${findMinNumber()}") intArrayOf(1, 2, 3, 4, 5, 6).printlnResult() intArrayOf(4, 5, 6, 1, 2, 3).printlnResult() intArrayOf(3, 4, 5, 6, ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,607
Algorithm
Apache License 2.0
src/test/kotlin/be/brammeerten/y2022/Day18Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2022 import be.brammeerten.C3 import be.brammeerten.readFile import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class Day18Test { @Test fun `part 1a`() { val droplet = parseDroplet("2022/day18/exampleInput.txt") Assertions.assertEquals(64, drople...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
4,339
Advent-of-Code
MIT License
src/day05/Day05.kt
hamerlinski
572,951,914
false
{"Kotlin": 25910}
package day05 import readInput fun main() { fun part1(stacks: SupplyStacks) { stacks.executeInstructions() println("solution1:") stacks.printAllLastCrates() } fun part2(stacks: SupplyStacks) { stacks.executeInstructionsOnCrateMover9001() println("solution2:") ...
0
Kotlin
0
0
bbe47c5ae0577f72f8c220b49d4958ae625241b0
4,489
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2020/d13/Day13.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d13 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines // find lowest positive solution to the equations // x = i1 (mod n1) // x = i2 (mod n2) // ... // where input is a list of (n1, i1) pairs // assumes that (n1, n2, ...) are mutually co...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,645
advent-of-code
MIT License
src/main/kotlin/aoc/Utils.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc import java.io.File import java.math.BigInteger import java.security.MessageDigest fun readFile(year: Int, day: Int, test: Int? = null): File { fun Int.twoDigit() = String.format("%02d", this) val testSuffix = if (test != null) "_test${test.twoDigit()}" else "" val basePath = if (test != null)...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
5,795
aoc-kotlin
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day18/Day18.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day18 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day18 : Day { override val input = readInputLines(18) override fun part1() = input.map(::parseNode).reduce(Node::plus).magnitude() override fun part2...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
3,603
aoc2021
MIT License
kotlin/04.kt
NeonMika
433,743,141
false
{"Kotlin": 68645}
class Day4 : Day<Day4.Input>("04") { // Classes data class BingoNumber(val num: Int, var drawn: Boolean = false) class Board(d: List<List<BingoNumber>>) : TwoDimensionalArray<BingoNumber>(d) { val isSolved get() = isSolvedViaRow || isSolvedViaColumn val isSolvedViaRow ...
0
Kotlin
0
0
c625d684147395fc2b347f5bc82476668da98b31
2,360
advent-of-code-2021
MIT License
src/main/kotlin/ctci/chapterone/IsUnique.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chapterone //1.1 - page 90 //In Kotlin, implement an algorithm to determine if a string has all unique characters. fun main() { val testCases = listOf("abcdef", "abcdea", "aaa", "", "a") for (testCase in testCases) { println("hasUniqueCharacters($testCase) = ${hasUniqueCharacters(testCas...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
2,123
dsa-kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CircularPermutation.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,425
kotlab
Apache License 2.0
src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1101_1200.s1125_smallest_sufficient_team // #Hard #Array #Dynamic_Programming #Bit_Manipulation #Bitmask // #2023_05_31_Time_181_ms_(100.00%)_Space_35.8_MB_(100.00%) class Solution { private var ans: List<Int> = ArrayList() fun smallestSufficientTeam(skills: Array<String>, people: List<List<String>>)...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,079
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Day11.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
class Day11 { fun part1(input: String): Long { val monkeys = input.split("\n\n").map { it.toMonkey() }.toTypedArray() val rounds = 20 val stressReducerFormula: (Long) -> Long = { it / 3 } repeat(rounds) { round -> monkeys.forEach { it.handleItems(stressRe...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
3,707
advent-of-code-2022
Apache License 2.0
src/Day10.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun main() { fun part1(input: List<String>): Int { var x = 1 var result = 0 var tact = 1 val commands = input.map { if (it == "noop") Pair(1, 0) else Pair(2, it.split(" ")[1].toInt()) }.toMutableList() var cursor...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
1,937
Advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PutMarbles.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
1,575
kotlab
Apache License 2.0
Algorithms/23 - Merge k Sorted Lists/src/Solution.kt
mobeigi
202,966,767
false
null
class ListNode(var `val`: Int) { var next: ListNode? = null } class Solution { /** * Extension function to convert a List<Int> to ListNode */ fun List<Int>.toListNode(): ListNode? { if (isEmpty()) { return null } val rootNode = ListNode(first()) var cu...
0
Kotlin
0
0
e5e29d992b52e4e20ce14a3574d8c981628f38dc
2,658
LeetCode-Solutions
Academic Free License v1.1
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions40.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round0 /** * 找出数组中最小的k个数 */ fun test40() { val array = intArrayOf(4, 5, 1, 6, 2, 7, 3, 8) print("最小的4个数为:") (array getLeastNumbers2 4).forEach { print("$it ") } println() print("最小的4个数为:") (array getLeastNumbers1 4).forEach { print("$it ") } } /** * 解法一,需要修改输入数组,时间复杂度为O(n) *...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,217
Algorithm
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day03.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 3 - Binary Diagnostic * Problem Description: http://adventofcode.com/2021/day/3 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day3/ */ package com.ginsberg.advent2021 class Day03(private val input: List<String>) { ...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,368
advent-2021-kotlin
Apache License 2.0
src/main/kotlin/name/valery1707/problem/leet/code/FizzBuzzK.kt
valery1707
541,970,894
false
null
package name.valery1707.problem.leet.code /** * # 412. Fizz Buzz * * Given an integer `n`, return a string array answer (**1-indexed**) where: * * `answer[i] == "FizzBuzz"` if `i` is divisible by `3` and `5`. * * `answer[i] == "Fizz"` if `i` is divisible by `3`. * * `answer[i] == "Buzz"` if `i` is divisible by `...
3
Kotlin
0
0
76d175f36c7b968f3c674864f775257524f34414
1,644
problem-solving
MIT License
src/main/kotlin/g1701_1800/s1771_maximize_palindrome_length_from_subsequences/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1771_maximize_palindrome_length_from_subsequences // #Hard #String #Dynamic_Programming #2023_06_18_Time_248_ms_(100.00%)_Space_69.7_MB_(100.00%) class Solution { fun longestPalindrome(word1: String, word2: String): Int { val len1 = word1.length val len2 = word2.length ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,068
LeetCode-in-Kotlin
MIT License
day05/main.kt
LOZORD
441,007,912
false
{"Kotlin": 29367, "Python": 963}
import java.util.Scanner import java.util.stream.IntStream import java.util.stream.Stream import java.util.TreeMap fun main() { val isPart1 = false // Toggle between the two parts. data class Point(val row: Int, val col: Int) class Line(val from: Point, val to: Point) { fun isDiagonal(): Boolean ...
0
Kotlin
0
0
17dd266787acd492d92b5ed0d178ac2840fe4d57
3,328
aoc2021
MIT License
project_euler_kotlin/src/main/kotlin/Solution0011.kt
NekoGoddessAlyx
522,068,054
false
{"Kotlin": 44135, "Rust": 24687}
class Solution0011 : Solution() { // 2d grid implemented as a list within a list like so: grid[y][x] // NOTE THE [Y][X] val grid = """ 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 7...
0
Kotlin
0
0
f899b786d5ea5ffd79da51604dc18c16308d2a8a
3,100
Project-Euler
The Unlicense
project/src/problems/FibonacciNumbers.kt
informramiz
173,284,942
false
null
package problems import java.util.* /** * https://codility.com/media/train/11-Fibonacci.pdf */ object FibonacciNumbers { fun findNthFibonacciNumber(n: Int): Int { val fib = Array(n+1) {0} fib[0] = 0 fib[1] = 1 for (i in 2..n) { fib[i] = fib[i-1] + fib[i-2] } ...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
7,204
codility-challenges-practice
Apache License 2.0
src/main/kotlin/com/adrielm/aoc2020/solutions/day07/Day07.kt
Adriel-M
318,860,784
false
null
package com.adrielm.aoc2020.solutions.day07 import com.adrielm.aoc2020.common.Algorithms import com.adrielm.aoc2020.common.Solution import org.koin.dsl.module class Day07 : Solution<List<BaggageRule>, Int>(7) { override fun solveProblem1(input: List<BaggageRule>): Int { // build a graph from child to pare...
0
Kotlin
0
0
8984378d0297f7bc75c5e41a80424d091ac08ad0
1,637
advent-of-code-2020
MIT License
day03/src/main/kotlin/Main.kt
ickybodclay
159,694,344
false
null
import java.io.File data class Claim( val claimNum: Int, val offsetX: Int, val offsetY: Int, val width: Int, val height: Int) fun main() { val input = File(ClassLoader.getSystemResource("input.txt").file) // Write solution here! val claimList = ArrayList<Claim>() ...
0
Kotlin
0
0
9a055c79d261235cec3093f19f6828997b7a5fba
2,517
aoc2018
Apache License 2.0
src/main/kotlin/y2022/day15/Day15.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2022.day15 import Coord import kotlin.math.abs fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } fun input(): List<Pair<Coord, Coord>> { return AoCGenerics.getInputLines("/y2022/day15/test-input.txt").map { line -> Pair( ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
2,038
AdventOfCode
MIT License
src/day02/Day02.kt
commanderpepper
574,647,779
false
{"Kotlin": 44999}
package day02 import readInput fun main() { val rockPaperScissors = readInput("day02") val split = rockPaperScissors.map { val split = it.split(" ") split.last() to split.first() } println(split.sumOf { it.determinePoints() }) println(split.sumOf { it.determinePointsFromOutcome() }...
0
Kotlin
0
0
fef291c511408c1a6f34a24ed7070ceabc0894a1
1,561
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem547/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem547 /** * LeetCode page: [547. Number of Provinces](https://leetcode.com/problems/number-of-provinces/); */ class Solution { /* Complexity: * Time O(N^2) and Space O(N) where N is the size of isConnected; */ fun findCircleNum(isConnected: Array<IntArray>): Int ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,546
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TwoSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,100
kotlab
Apache License 2.0
src/day10/second/Solution.kt
verwoerd
224,986,977
false
null
package day10.second import day10.first.bestStationLocation import day10.first.readAsteroidsMap import tools.Coordinate import tools.timeSolution import java.util.concurrent.LinkedBlockingDeque import kotlin.math.PI import kotlin.math.abs import kotlin.math.atan2 fun main() = timeSolution { val map = readAsteroidsM...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
2,012
AoC2019
MIT License
src/main/kotlin/aoc2022/Day21.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import aoc2022.Job.YellNumber import aoc2022.Job.YellOperation import util.illegalInput private typealias Monkey = String private sealed interface Job { class YellNumber(val number: Long) : Job sealed class YellOperation(val left: Monkey, val right: Monkey) : Job { opera...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
3,635
advent-of-code-kotlin
MIT License
TwoSumLessThanTarget.kt
sysion
353,734,921
false
null
/** * https://leetcode.com/problems/two-sum-less-than-k/ * * 1. Two Sum Less Than K * * Given an array A of integers and integer K, return the maximum S such that * there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying * this equation, return -1. * * Example 1: * Input: A = [34,23,1,24,75,33...
0
Kotlin
0
0
6f9afda7f70264456c93a69184f37156abc49c5f
993
DataStructureAlgorithmKt
Apache License 2.0
src/main/kotlin/com/leetcode/P994.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode import java.util.* // https://github.com/antop-dev/algorithm/issues/487 class P994 { fun orangesRotting(grid: Array<IntArray>): Int { val queue = LinkedList<Pair<Int, Int>>() val fresh = intArrayOf(0) // 함수에 값을 넘기기위해 참조로 씀 for (y in grid.indices) { for (x i...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,374
algorithm
MIT License
src/y2023/Day16.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Cardinal import util.Pos import util.readInput import util.timingStatistics import y2023.Day14.coerce object Day16 { data class Tile( val pos: Pos, val type: Type, ) enum class Type(val c: Char) { SPLITTER_UP('|'), SPLITTER_FLAT('-'), MIRROR_BACK('\\'), M...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
5,171
advent-of-code
Apache License 2.0
src/day3/p2.kt
TimCastelijns
113,205,922
false
null
package day3 enum class Direction { RIGHT, UP, LEFT, DOWN } var n = 100 val grid = Array(n) { Array(n, { "" }) } fun surroundingsSum(x: Int, y: Int): Int { var sum = 0 if (y > 0 && x > 0) { if (grid[y - 1][x - 1] != "") { val add = grid[y - 1][x - 1].trim().toInt() sum += add...
0
Kotlin
0
0
656f2a424b323175cd14d309bc25430ac7f7250f
2,610
aoc2017
MIT License
src/main/kotlin/aoc2020/day01_report_repair/ReportRepair.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2020.day01_report_repair fun main() { util.solve(73371, ::partOne) util.solve(127642310, ::partTwo) } private const val TARGET = 2020 private fun List<Int>.findAddends(total: Int): Pair<Int, Int>? { val set = hashSetOf<Int>() this.forEach { if (it >= total) return@forEach v...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
971
aoc-2021
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day10.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 10 - Pipe Maze * Problem Description: http://adventofcode.com/2023/day/10 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day10/ */ package com.ginsberg.advent2023 import com.ginsberg.advent2023.Point2D.Companion.EAST...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
3,705
advent-2023-kotlin
Apache License 2.0
kotlin/2018/qualification-round/cubic-ufo/src/main/kotlin/AnalysisSolution.kt
ShreckYe
345,946,821
false
null
import kotlin.math.acos import kotlin.math.cos import kotlin.math.sin import kotlin.math.sqrt fun main() { val t = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val a = readLine()!!.toFloat() // `op` stands for "original point" and `hp` stands for "highest point". val op = ...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,159
google-code-jam
MIT License
src/array/LeetCode334.kt
Alex-Linrk
180,918,573
false
null
package array /** * 给定一个未排序的数组,判断这个数组中是否存在长度为 3 的递增子序列。 *数学表达式如下: * *如果存在这样的 i, j, k,  且满足 0 ≤ i < j < k ≤ n-1, *使得 arr[i] < arr[j] < arr[k] ,返回 true ; 否则返回 false 。 *说明: 要求算法的时间复杂度为 O(n),空间复杂度为 O(1) 。 * *示例 1: * *输入: [1,2,3,4,5] *输出: true *示例 2: * *输入: [5,4,3,2,1] *输出: false * *来源:力扣(LeetCode) *链接:h...
0
Kotlin
0
0
59f4ab02819b7782a6af19bc73307b93fdc5bf37
1,283
LeetCode
Apache License 2.0
src/main/kotlin/days/Day2.kt
broersma
574,686,709
false
{"Kotlin": 20754}
package days class Day2 : Day(2) { override fun partOne(): Any { val scores = mapOf("A" to 0, "B" to 1, "C" to 2, "X" to 0, "Y" to 1, "Z" to 2) return inputList .filter { it.isNotEmpty() } .map { val (a, b) = it.split(" ") sc...
0
Kotlin
0
0
cd3f87e89f7518eac07dafaaeb0f6adf3ecb44f5
1,583
advent-of-code-2022-kotlin
Creative Commons Zero v1.0 Universal
src/main/kotlin/problems/Day19.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems import java.util.* import kotlin.math.* typealias Point = Triple<Int, Int, Int> typealias Distance = Triple<Int, Int, Int> typealias RotationFunction = (Triple<Int, Int, Int>) -> Triple<Int, Int, Int> class Day19(override val input: String) : Problem { override val number: Int = 19 private v...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
8,859
AdventOfCode2021
MIT License
src/main/kotlin/day9/Day9.kt
mortenberg80
574,042,993
false
{"Kotlin": 50107}
package day9 import java.lang.IllegalArgumentException class Day9(val input: List<String>) { private val board = Board(Point(0, 0), Point(0, 0), Point(0, 0), mapOf()) private val rope = (1..10).map { Point(0, 0) }.toMutableList() private val board2 = Board2(Point(0, 0), rope, mutableMapOf()) private...
0
Kotlin
0
0
b21978e145dae120621e54403b14b81663f93cd8
7,579
adventofcode2022
Apache License 2.0
src/Day07.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun part1(input: List<String>): Int { val dirs = mutableListOf<Directory>() val topLevelDir = Directory("/") dirs.add(topLevelDir) var currentDir = topLevelDir var currlevel = 0 for(line in input) { if(line == "$ cd /") { currentDir = topLevelDir currlevel++...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
4,464
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/PseudoPalindromicPaths.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,713
kotlab
Apache License 2.0
src/Day03.kt
askeron
572,955,924
false
{"Kotlin": 24616}
class Day03 : Day<Int>(157, 70, 7428, 2650) { private val priorities: Map<Char, Int> = (('a'..'z')+('A'..'Z')).mapIndexed { i, c -> c to i+1 }.toMap() override fun part1(input: List<String>): Int { return input.map { it.toCharArray().toList().splitInHalf() } .map { (a, b) -> a.intersect(b) ...
0
Kotlin
0
1
6c7cf9cf12404b8451745c1e5b2f1827264dc3b8
706
advent-of-code-kotlin-2022
Apache License 2.0
src/net/sheltem/aoc/y2023/Day03.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.numericRegex import net.sheltem.common.toListLong import kotlin.math.max import kotlin.math.min suspend fun main() { Day03().run() } class Day03 : Day<Long>(4361, 467835) { override suspend fun part1(input: List<String>): Long = input .toEngine...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,178
aoc
Apache License 2.0
src/Day01.kt
shoresea
576,381,520
false
{"Kotlin": 29960}
fun main() { fun part1(inputs: List<String>): Int { var max = 0 var sum = 0 for (input in inputs) { if (input == "") { max = maxOf(max, sum) sum = 0 } else { sum += input.toInt() } } return ma...
0
Kotlin
0
0
e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e
941
AOC2022InKotlin
Apache License 2.0
src/test/kotlin/com/onegravity/sudoku/Util.kt
1gravity
407,597,760
false
{"Kotlin": 148326}
package com.onegravity.sudoku import com.onegravity.sudoku.SudokuMatrix.Companion.getIndexValue import com.onegravity.sudoku.SudokuMatrix.Companion.toSudokuMatrix import com.onegravity.sudoku.model.Grid import com.onegravity.sudoku.model.Puzzle import org.junit.jupiter.api.Assertions import java.io.File import java.te...
0
Kotlin
0
1
4e8bfb119a57a101db4d873bf86cd5722105ebb3
4,177
Dancing-Links-Kotlin
Apache License 2.0
day01/src/main/kotlin/com/shifteleven/adventofcode2023/day01/App.kt
pope
733,715,471
false
{"Kotlin": 3950, "Nix": 1630}
package com.shifteleven.adventofcode2023.day01 import kotlin.math.min fun main() { part1() part2() } fun part1() { val lines = object {}.javaClass.getResourceAsStream("/input.txt")!!.bufferedReader().readLines() val sum = lines .stream() .mapToInt({ line -> var tens: Int? = null var ones = 0 ...
0
Kotlin
0
0
cb2862a657d307b5ecd74ebb9c167548b67ba6fc
1,940
advent-of-code-2023-kotlin
The Unlicense
src/main/kotlin/days/Day13.kt
poqueque
430,806,840
false
{"Kotlin": 101024}
package days import util.Coor class Day13 : Day(13) { override fun partOne(): Any { val map = mutableListOf<Coor>() inputList.forEach { data -> if (data.contains(",")) { val (x, y) = data.split(",").map { it.toInt() } map.add(Coor(x, y)) } e...
0
Kotlin
0
0
4fa363be46ca5cfcfb271a37564af15233f2a141
2,234
adventofcode2021
MIT License
project-euler/kotlin/src/main/kotlin/dev/mikeburgess/euler/extensions/Long.kt
mddburgess
469,258,868
false
{"Kotlin": 47737}
package dev.mikeburgess.euler.extensions import dev.mikeburgess.euler.sequences.primeSequence import kotlin.math.sqrt fun Long.countDivisors() = when (this) { 1L -> 1 2L, 3L -> 2 else -> primeSequence() .takeWhile { it <= sqrt(toDouble()) } .map { countFactors(it) + 1 } .reduce { a...
0
Kotlin
0
0
9ad8f26583b204e875b07782c8d09d9d8b404b00
1,133
code-kata
MIT License
2021/06/main.kt
chylex
433,239,393
false
null
import java.io.File import java.math.BigInteger import kotlin.system.measureTimeMillis fun main() { val initialConfiguration = File("input.txt").readLines() .single() .split(',') .map(String::toInt) println("(Took ${measureTimeMillis { part1(initialConfiguration) }} ms)") println("(Took ${measureTimeMillis ...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
1,319
Advent-of-Code
The Unlicense
src/main/kotlin/20/20.kt
Wrent
225,133,563
false
null
import java.lang.RuntimeException fun main() { val maze = mutableMapOf<Coord, Maze>() val input = mutableMapOf<Coord, String>() INPUT20.split("\n") .forEachIndexed { i, row -> row.split("").filter { it != "" }.forEachIndexed { j, cell -> val coord = Coord(j, i) ...
0
Kotlin
0
0
0a783ed8b137c31cd0ce2e56e451c6777465af5d
23,060
advent-of-code-2019
MIT License
src/Day11/Day11.kt
martin3398
436,014,815
false
{"Kotlin": 63436, "Python": 5921}
import java.util.* fun main() { fun preprocess(input: List<String>) = input.map { it.map { x -> x.toString().toInt() }.toTypedArray() }.toTypedArray() fun simulateStep(input: Array<Array<Int>>): Int { var lights = 0 val queue = LinkedList<Pair<Int, Int>>() for (x in input.indic...
0
Kotlin
0
0
085b1f2995e13233ade9cbde9cd506cafe64e1b5
2,224
advent-of-code-2021
Apache License 2.0
src/Day25.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { val charToDigit = mapOf('=' to -2, '-' to -1, '0' to 0, '1' to 1, '2' to 2) val digitToChar = charToDigit.map { (char, digit) -> digit.toLong() to char }.toMap() fun toDecimal(snafu: String) = snafu.toCharArray().reversed().mapIndexed { index, char -> charToDigit[char]!! * 5.pow(index) }.sum()...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
940
aoc2022
Apache License 2.0
src/main/kotlin/g1901_2000/s1994_the_number_of_good_subsets/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1994_the_number_of_good_subsets // #Hard #Array #Dynamic_Programming #Math #Bit_Manipulation #Bitmask // #2023_06_21_Time_737_ms_(100.00%)_Space_54.2_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { private fun add(a: Long, b: Long): Long { var a = a a += b ret...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,118
LeetCode-in-Kotlin
MIT License
src/day08/Day08.kt
tschens95
573,743,557
false
{"Kotlin": 32775}
package day08 import readInput fun main() { fun isVisible(i: Int, array: Array<IntArray>, column: Int, row: Int): Boolean { var aboveTrees = listOf<Int>() var leftTrees = listOf<Int>() var belowTrees = listOf<Int>() var rightTrees = listOf<Int>() for (k in 0 until row) { ...
0
Kotlin
0
2
9d78a9bcd69abc9f025a6a0bde923f53c2d8b301
5,088
AdventOfCode2022
Apache License 2.0
grind-75-kotlin/src/main/kotlin/LinkedListCycle.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
import commonclasses.ListNode /** * Given head, the head of a linked list, determine if the linked list has a cycle in it. * * There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. * Internally, pos is used to denote the index of t...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,813
grind-75
Apache License 2.0
solutions/src/SearchRotatedSortedArray.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import kotlin.math.roundToInt //https://leetcode.com/problems/search-in-rotated-sorted-array/ class SearchRotatedSortedArray { fun search(nums: IntArray, target: Int) : Int { val pivot = findPivot(nums, 0, nums.lastIndex) if (pivot == -1) return Math.max(nums.binarySearch(target),-1...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,015
leetcode-solutions
MIT License
app/src/main/kotlin/solution/Solution2104.kt
likexx
559,794,763
false
{"Kotlin": 136661}
package solution import solution.annotation.Leetcode class Solution2104 { @Leetcode(2104) class Solution { fun subArrayRanges(nums: IntArray): Long { // monolithic stacks // sum = sum(all maxes) - sum(all mins) val N = nums.size var sum: Long = 0 ...
0
Kotlin
0
0
376352562faf8131172e7630ab4e6501fabb3002
2,435
leetcode-kotlin
MIT License
src/Day05.kt
wbars
576,906,839
false
{"Kotlin": 32565}
private fun getStacks() = listOf( ArrayDeque(listOf('R', 'Q', 'G', 'P', 'C', 'F')), ArrayDeque(listOf('P', 'C', 'T', 'W')), ArrayDeque(listOf('C', 'M', 'P', 'H', 'B')), ArrayDeque(listOf('R', 'P', 'M', 'S', 'Q', 'T', 'L')), ArrayDeque(listOf('N', 'G', 'V', 'Z', 'J', 'H', 'P')),...
0
Kotlin
0
0
344961d40f7fc1bb4e57f472c1f6c23dd29cb23f
1,940
advent-of-code-2022
Apache License 2.0
Kotlin/days/src/day12.kt
dukemarty
224,307,841
false
null
import java.io.BufferedReader import java.io.FileReader import java.lang.StringBuilder import kotlin.math.abs import kotlin.math.sign //<x=1, y=-4, z=3> //<x=-14, y=9, z=-4> //<x=-4, y=-6, z=7> //<x=6, y=-9, z=-11> data class Vector3d(var x: Int = 0, var y: Int = 0, var z: Int = 0) { operator fun plusAssign(othe...
0
Kotlin
0
0
6af89b0440cc1d0cc3f07d5a62559aeb68e4511a
3,126
dukesaoc2019
MIT License
src/main/kotlin/dev/shtanko/algorithms/sorts/BinarySort.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,335
kotlab
Apache License 2.0
src/main/kotlin/co/csadev/advent2022/Day18.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 18 * Problem Description: http://adventofcode.com/2021/day/18 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point3D import co.csadev.adventOfCode.Resources.resourceAsList class Day18(override val in...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,751
advent-of-kotlin
Apache License 2.0
src/Day03.kt
peterphmikkelsen
573,069,935
false
{"Kotlin": 7834}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (item in input) { val (first, second) = item.chunked(item.length/2) sum += first.first(second::contains).alphabetPosition() } return sum } fun part2(input: List<String>): Int { ...
0
Kotlin
0
0
374c421ff8d867a0bdb7e8da2980217c3455ecfd
977
aoc-2022
Apache License 2.0
src/com/company/AStar.kt
Chopinsky
102,678,276
false
{"Java": 16873, "Kotlin": 16695}
package com.company import java.util.* import kotlin.collections.ArrayList val D1 = 1.0 val D2 = Math.sqrt(2.0) val p = 1/1000 fun aStarSearch(start: Pair<Int, Int>, goal: Pair<Int, Int>, map: HashMap<Pair<Int, Int>, Int>): ArrayList<Pair<Int, Int>> { val failure = ArrayList<Pair<Int, Int>>() // set of node...
0
Java
0
0
2274ef85ee6af7c4145adcb7e45c36bf723db9c8
7,094
-Exercises--Kotlin_with_Java
MIT License
src/day14/Day14.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day14 import readInput private const val DAY_ID = "14" private data class Point( val x: Int, val y: Int ) private data class Cave( val rocks: Set<Point>, val minX: Int, val maxY: Int ) fun main() { fun parseInput(input: List<String>): List<List<Point>> = input.map { line -> ...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
3,663
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SmallestInfiniteSet.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,731
kotlab
Apache License 2.0
src/Day01.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
fun main() { fun foldInput(input: List<String>) = input .foldRight(mutableListOf<Int>() to 0) { new, (currentList, currentCount) -> if (new.isNotBlank()) { // new input is not a blank line increase current count currentList to currentCount + new.toInt() ...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
1,992
advent-of-code-2022
Apache License 2.0
kafka-reference-impl/judge/src/main/kotlin/Capturing.kt
Terkwood
191,042,808
false
null
/** Return all open spaces connected to the target piece's formation */ fun liberties(target: Coord, board: Board): Set<Coord> = connected(target, board).flatMap { neighborSpaces(it, board) }.toSet() fun neighbors(target: Coord, board: Board): Set<Pair<Coord, Player?>> = listOf( Pair(-1, 0), P...
83
Rust
7
65
ec01dc3dae54e1e248d540d442caa1731f2822e4
3,024
BUGOUT
MIT License
lc004/src/main/kotlin/misc/Solution.kt
warmthdawn
467,419,502
false
{"Kotlin": 28653, "Java": 8222}
package misc; import kotlin.math.max import kotlin.system.measureTimeMillis import kotlin.time.ExperimentalTime import kotlin.time.measureTime data class State( val rank: Int, val star: Int, val continuousWin: Int, val preserveStars: Int ) class Solution { fun calc(starPerRank: Int, winPerPrese...
0
Kotlin
0
0
40dc158a934f0fc4a3c6076bf1b5babf8413e190
3,349
LeetCode
MIT License
src/Day03.kt
icoffiel
572,651,851
false
{"Kotlin": 29350}
private const val UPPERCASE_ASCII_RESET = 38 private const val LOWERCASE_ASCII_RESET = 96 fun main() { fun Char.toPriority() = when { isUpperCase() -> code - UPPERCASE_ASCII_RESET isLowerCase() -> code - LOWERCASE_ASCII_RESET else -> error("Unexpected condition") } fun part1(input...
0
Kotlin
0
0
515f5681c385f22efab5c711dc983e24157fc84f
1,053
advent-of-code-2022
Apache License 2.0
2023/07/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File private const val FILENAME = "2023/07/input.txt" private val numericToRank = mapOf( "5" to 6, "41" to 5, "32" to 4, "311" to 3, "221" to 2, "2111" to 1, ) fun main() { partOne() partTwo() } private fun partOne() { val file = File(FILENAME).readLines() val...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
1,934
Advent-of-Code
MIT License
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem029.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems import java.math.BigInteger /** * Problem 29 * * Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5: * * 2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32 * 3^2 = 9, 3^3 = 27, 3^4 = 81, 3^5 = 243 * 4^2 = 16, 4^3 = 64, 4^4 = 256, 4^5 = 1024 * 5^2 = 25, 5^3...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
901
project-euler
MIT License
src/day03/Day03.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day03 import readInput fun main() { fun Char.getScore(): Int = when { this.isLowerCase() -> this - 'a' + 1 this.isUpperCase() -> this - 'A' + 27 else -> 0 } fun part1(input: List<String>): Int { var scoreSum = 0 input.map { it.chunke...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
1,305
advent-of-code-2022
Apache License 2.0
src/Day06.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
fun main() { fun detectMarker(input: List<String>, size: Int) = input .first() .toCharArray() .asSequence() .windowed(size) .indexOfFirst { it.distinct().size == size } + size fun part1(input: List<String>): Int = detectMarker(input, 4) fun part2...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
894
advent-of-code-2022
Apache License 2.0
src/Day17.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
private fun simulateFall(rockGroup: Chunk, jets: Iterator<Int>, chamber: Chamber) { while (true) { val jet = jets.next() if (!chamber.rocksWillCollide(rockGroup.rocks, dx = jet, dy = 0)) { rockGroup.move(dx = jet, dy = 0) } // fall if (!chamber.rocksWillCollide(ro...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
6,536
advent-of-code-kotlin-2022
Apache License 2.0
src/day05/Day05.kt
molundb
573,623,136
false
{"Kotlin": 26868}
package day05 import readInput import java.util.LinkedList fun main() { val input = readInput(parent = "src/day05", name = "Day05_input") println(solvePartOne(input)) println(solvePartTwo(input)) } private fun solvePartOne(input: List<String>) = solve(input, false) private fun solvePartTwo(input: List<S...
0
Kotlin
0
0
a4b279bf4190f028fe6bea395caadfbd571288d5
1,871
advent-of-code-2022
Apache License 2.0
project_euler_kotlin/src/main/kotlin/Utils.kt
NekoGoddessAlyx
522,068,054
false
{"Kotlin": 44135, "Rust": 24687}
import java.math.BigInteger import kotlin.math.ceil import kotlin.math.sqrt /** Fibonacci sequence generator starting with 1 and 1 */ fun fibGenerator() = sequence { yield(1) // seed values (will result in the first number being 1 and the second number being 2 var a = 0 var b = 1 while (true) { ...
0
Kotlin
0
0
f899b786d5ea5ffd79da51604dc18c16308d2a8a
8,475
Project-Euler
The Unlicense
src/main/kotlin/GroupAnagrams.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given an array of strings strs, group the anagrams together. You can return the answer in any order. * * An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, * typically using all the original letters exactly once. * * * * Example 1: * * Input: strs = ["eat","t...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,361
kotlin-codes
Apache License 2.0
src/Day25.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.abs fun main() { fun Char.snafuCharToInt(): Int { return when (this) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else -> throw IllegalArgumentException("$this is not a snafu char") } } fun Int.s...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,901
aoc-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem103/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem103 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [103. Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,053
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/AverageSalary.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,543
kotlab
Apache License 2.0
src/Day01.kt
binaryannie
573,120,071
false
{"Kotlin": 10437}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currentCalories = 0 input.forEach { if (it.isBlank()) { if(currentCalories > maxCalories) maxCalories = currentCalories currentCalories = 0 } else { ...
0
Kotlin
0
0
511fc33f9dded71937b6bfb55a675beace84ca22
1,249
advent-of-code-2022
Apache License 2.0
2020/Day10/src/main/kotlin/main.kt
airstandley
225,475,112
false
{"Python": 104962, "Kotlin": 59337}
import java.io.File fun getInput(file: String): List<String> { return File(file).readLines() } fun parseInput(input: List<String>): List<Int> { val output: MutableList<Int> = mutableListOf() for (line in input) { output.add(line.toInt()) } return output } fun countAdapterGaps(adapters: L...
0
Python
0
0
86b7e289d67ba3ea31a78f4a4005253098f47254
2,292
AdventofCode
MIT License
src/year2022/day13/Day13.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day13 import readInputFileByYearAndDay import readTestFileByYearAndDay fun String.startsWithList(): Boolean = this.startsWith("[") fun String.extractFirstInt(): Int = this.split(",").first().toInt() infix fun String.extractListIndicesStartingFrom(start: Int): Pair<Int, Int> { if (this[start] != '...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
4,709
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/days/Day3.kt
mir47
433,536,325
false
{"Kotlin": 31075}
package days class Day3 : Day(3) { override fun partOne(): Int { var gamma = "" var epsilon = "" for (bitIndex in 0.until(inputList[0].length)) { val counts = inputList.groupingBy { it[bitIndex] }.eachCount() gamma += if ((counts['0'] ?: 0) > (counts['1'] ?: 0)) '0'...
0
Kotlin
0
0
686fa5388d712bfdf3c2cc9dd4bab063bac632ce
1,420
aoc-2021
Creative Commons Zero v1.0 Universal
kotlin/src/com/s13g/aoc/aoc2020/Day22.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver import java.util.* /** * --- Day 22: Crab Combat --- * https://adventofcode.com/2020/day/22 */ class Day22 : Solver { override fun solve(lines: List<String>): Result { val playersA = parse(lines) // Make copy for Part B wh...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,882
euler
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2016/Day07.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2016 import me.grison.aoc.* class Day07 : Day(7, 2016) { override fun title() = "Internet Protocol Version 7" private val addresses = inputList.map { it.trim().split("""\[|\]""".regex()) } private val supernet = addresses.map { it.filterIndexed { i, _ -> i % 2 == 0 }.joinToString("...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,196
advent-of-code
Creative Commons Zero v1.0 Universal
Day6/src/Orbit.kt
gautemo
225,219,298
false
null
import java.io.File fun readLines() = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readLines() fun main(){ val spaceObjects = mapSpace(readLines()) val orbits = findNrOrbits(spaceObjects) println(orbits) val toSanta = findNrOrbitsToSanta(spaceObjects) println...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
1,969
AdventOfCode2019
MIT License
src/day11/Day11.kt
quinlam
573,215,899
false
{"Kotlin": 31932}
package day11 import utils.Day /** * Actual answers after submitting; * part1: 111210 * part2: 15447387620 */ class Day11 : Day<Long, Map<Int, Monkey>>( testPart1Result = 10605, testPart2Result = 2713310158, ) { override fun part1Answer(input: Map<Int, Monkey>): Long { val relief = 3 v...
0
Kotlin
0
0
d304bff86dfecd0a99aed5536d4424e34973e7b1
1,580
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/io/github/ocirne/aoc/year2022/Day2.kt
ocirne
327,578,931
false
{"Python": 323051, "Kotlin": 67246, "Sage": 5864, "JavaScript": 832, "Shell": 68}
package io.github.ocirne.aoc.year2022 import io.github.ocirne.aoc.AocChallenge typealias ScoringFunction = (Day2.Shape, Char) -> Pair<Day2.Shape, Day2.Score> class Day2(val lines: List<String>) : AocChallenge(2022, 2) { enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSOR(3), ...
0
Python
0
1
b8a06fa4911c5c3c7dff68206c85705e39373d6f
2,447
adventofcode
The Unlicense