path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/days/Day15.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days import util.MutableMatrix import util.Point import kotlin.math.abs class Day15 : Day(15) { override fun runPartOne(lines: List<String>): Any { val matrix = MutableMatrix.fromSingleDigits(lines) { c -> c.digitToInt() } val start = Point(0, 0) val optimal = aStar(matrix, start, ...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
3,966
aoc2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/_0072_EditDistance.kt
ryandyoon
664,493,186
false
null
// https://leetcode.com/problems/edit-distance fun minDistance(word1: String, word2: String): Int { return minDistance(word1, word2, 0, 0, Array(word1.length) { IntArray(word2.length) { -1 } }) } private fun minDistance(word1: String, word2: String, index1: Int, index2: Int, memo: Array<IntArray>): Int { if (w...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
996
leetcode-kotlin
MIT License
src/chapter4/section4/ex31_AllPairsShortestPathsOnALine.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter4.section4 /** * 线图中任意顶点对之间的最短路径 * 给定一幅加权线图(无向连通图,处理两个端点度数为1之外所有顶点的度数为2), * 给出一个算法在线性时间内对图进行预处理并在常数时间内返回任意两个顶点之间的最短路径。 * * 解:以一个端点为起点,遍历加权线图,计算每个顶点到起点的距离 * 顶点v到顶点w的距离为顶点w到起点的距离减去顶点v到起点的距离 */ class LineGraph(val V: Int) { init { // 线图至少有两个端点 require(V > 1) } // 两个点之间的权...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,654
Algorithms-4th-Edition-in-Kotlin
MIT License
app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/playground/challenges/PalindromicNew.kt
ahuamana
627,986,788
false
null
package com.lukaslechner.coroutineusecasesonandroid.playground.challenges //Have the function StringChallenge(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters //For example: if str is "abjchba" then you ...
0
Kotlin
0
0
931ce884b8c70355e38e007141aab58687ed1909
2,253
KotlinCorutinesExpert
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-07.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 import java.io.File fun main() { val input = File("src", "com.github.ferinagy.adventOfCode.aoc2015.com.github.ferinagy.adventOfCode.aoc2015.com.github.ferinagy.adventOfCode.aoc2015.com.github.ferinagy.adventOfCode.aoc2015.com.github.ferinagy.adventOfCode.aoc2015.co...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,122
advent-of-code
MIT License
src/main/kotlin/befaster/solutions/Item.kt
CX-Checkout
110,842,433
false
null
package befaster.solutions sealed abstract class Item(open val price: Price) object A : Item(50) object B : Item(30) object C : Item(20) object D : Item(15) object E : Item(40) object Invalid : Item(-1) typealias Basket = List<Item> typealias Price = Int interface Deal { val howManyYouNeedToBuy: Int } data clas...
0
Kotlin
0
0
9209c4182bee28509835759be2762ba62fb3f92b
3,018
rvpk01
Apache License 2.0
src/aoc2022/Day05.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import println import readInput import java.util.* fun main() { fun part1(input: List<String>): String { var firstLine = true var stacks: MutableList<LinkedList<Char>> = mutableListOf() var stacksNum = 0 var lineIt = input.iterator() var line = lineIt.next(...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
3,679
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2016/Day03.kt
tginsberg
74,924,040
false
null
/* * Copyright (c) 2016 by <NAME> */ package com.ginsberg.advent2016 /** * Advent of Code - Day 3: December 3, 2016 * * From http://adventofcode.com/2016/day/3 * */ class Day03(rawInput: String) { private val inputAsDigits = rawInput.trim().split(Regex("\\s+")).map(String::toInt) /** * In your ...
0
Kotlin
0
3
a486b60e1c0f76242b95dd37b51dfa1d50e6b321
1,778
advent-2016-kotlin
MIT License
advent-of-code-2022/src/test/kotlin/Day 15 Beacon Exclusion Zone.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import kotlin.math.abs import kotlin.math.max import kotlinx.collections.immutable.persistentListOf import org.junit.jupiter.api.Test class `Day 15 Beacon Exclusion Zone` { @Test fun silverTest() { amountOfDefinitelyNoBeaconPositions(testInput, 10, true) shouldBe 26 } @T...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
5,921
advent-of-code
MIT License
src/Day10.kt
janbina
112,736,606
false
null
package day10 import getInput import kotlin.test.assertEquals fun main(args: Array<String>) { val input = getInput(10).readLines().first() assertEquals(52070, part1(input)) assertEquals("7f94112db4e32e19cf6502073c66f9bb", part2(input)) } fun part1(input: String): Int { val lengths = input.split(",")...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
1,662
advent-of-code-2017
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D14.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2020 import io.github.pshegger.aoc.common.BaseSolver class Y2020D14 : BaseSolver() { override val year = 2020 override val day = 14 override fun part1(): Long = solve(true) override fun part2(): Long = solve(false) private fun solve(isPart1: Boolean): Long { ...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,481
advent-of-code
MIT License
src/main/kotlin/year2021/day-03.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.aoc.Day import lib.aoc.Part fun main() { Day(3, 2021, PartA3(), PartB3()).run() } open class PartA3 : Part() { protected lateinit var numbers: List<String> override fun parse(text: String) { numbers = text.split("\n") } override fun compute(): String { ...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
1,754
Advent-Of-Code-Kotlin
MIT License
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/middle/MaxArea.kt
scientificCommunity
352,868,267
false
{"Java": 154453, "Kotlin": 69817}
package org.baichuan.sample.algorithms.leetcode.middle /** * @author: tk (<EMAIL>) * @date: 2022/1/10 * * leetcode 11 盛最多水的容器 * https://leetcode-cn.com/problems/container-with-most-water/ */ class MaxArea { /** * 解题思路(双指针法思路浅析): * 题目要求找出盛水最多的容器,那么哪些因素会影响到盛水量呢?首先,盛水量完全取决于底*min(左高, 右高), * 所以,我们可...
1
Java
0
8
36e291c0135a06f3064e6ac0e573691ac70714b6
1,496
blog-sample
Apache License 2.0
src/main/kotlin/day16/Day16.kt
Jessevanbekkum
112,612,571
false
null
package day16 import util.readLines fun day16_1(input: String, p: Int): String { val choreo = readLines(input).joinToString("").split(",") val start = "abcdefghijklmnop".substring(0, p) return boogie(start, choreo).joinToString("") } fun boogie(start: String, choreo: List<String>): MutableList<Char> { ...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
1,887
aoc-2017
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2021/d11/Day11.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d11 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.grids.Grid import com.groundsfam.advent.grids.containsPoint import com.groundsfam.advent.grids.copy import com.groundsfam.advent.points.Point import com.groundsfam.advent.points.adjacents import com.groundsfam.ad...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,143
advent-of-code
MIT License
src/main/kotlin/adventofcode/day4.kt
Kvest
163,103,813
false
null
package adventofcode import java.io.File import java.text.SimpleDateFormat private val dateFormat = SimpleDateFormat("yyyyy-MM-dd hh:mm") fun main(args: Array<String>) { println(first4(File("./data/day4_1.txt").readLines())) println(second4(File("./data/day4_2.txt").readLines())) } fun first4(data: List<Str...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
2,750
aoc2018
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day14.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.P import se.saidaspen.aoc.util.ints fun main() = Day14.run() object Day14 : Day(2015, 14) { data class Reindeer(val name: String, val maxSpeed: Int, val stamina: Int, val rest: Int) { fun distAt(i: Int): Int {...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,152
adventofkotlin
MIT License
src/iii_conventions/MyDate.kt
baldore
80,958,181
false
null
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int { return when { year != other.year -> year - other.year month != other.month -> month - other.month else -> day...
0
Kotlin
0
0
087fb866e0af72c63d3d75148f68f8c1c864dd02
1,631
kotlin-koans
MIT License
src/day18/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day18 import util.Point3 import util.boundingCuboid import util.readInput import util.shouldBe import java.util.LinkedList fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 64 testInput.part2() shouldBe 58 val input = readInput(Inpu...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
1,632
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxBoxesInWarehouse.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,323
kotlab
Apache License 2.0
src/Day11.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import java.io.File import java.lang.Exception import java.util.LinkedList fun main() { class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val divisionTest: Long, val yesMonkey: Int, val noMonkey: Int ) { var inspected = 0L fun ca...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
4,330
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ConstructBinaryTree2.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,428
kotlab
Apache License 2.0
advent2021/src/main/kotlin/year2021/day09/HeightMap.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2021.day09 fun Pair<Int, Int>.neighbors(maxX: Int, maxY: Int) = listOf( first - 1 to second, first + 1 to second, first to second - 1, first to second + 1 ).filter { (x, y) -> x >= 0 && y >= 0 && x < maxX && y < maxY } fun Pair<Int, Int>.computeBasin(map...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,318
advent-of-code
Apache License 2.0
src/main/kotlin/be/swsb/aoc2021/day8/Day8.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day8 private const val amountOfSignalsToDisplay1 = 2 private const val amountOfSignalsToDisplay4 = 4 private const val amountOfSignalsToDisplay7 = 3 private const val amountOfSignalsToDisplay8 = 7 object Day8 { fun solve1(input: List<String>): Int { return input.sumOf { line -> ...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
4,265
Advent-of-Code-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/GetMaximumScore.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,794
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistributeRepeatingIntegers.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,312
kotlab
Apache License 2.0
advanced-algorithms/kotlin/src/lPIntreeP1LMax.kt
nothingelsematters
135,926,684
false
{"Jupyter Notebook": 7400788, "Java": 512017, "C++": 378834, "Haskell": 261217, "Kotlin": 251383, "CSS": 45551, "Vue": 37772, "Rust": 34636, "HTML": 22859, "Yacc": 14912, "PLpgSQL": 10573, "JavaScript": 9741, "Makefile": 8222, "TeX": 7166, "FreeMarker": 6855, "Python": 6708, "OCaml": 5977, "Nix": 5059, "ANTLR": 4802, "...
import java.io.File import java.util.Scanner fun schedulePIntreeP1LMax( deadlines: MutableList<Int>, m: Int, fromTo: Map<Int, Int>, toFrom: Map<Int, List<Int>>, ): Pair<Int, List<Int>> { val i = deadlines.indices.find { it !in fromTo }!! val deque = ArrayDeque<Int>() deque += i while ...
0
Jupyter Notebook
3
5
d442a3d25b579b96c6abda13ed3f7e60d1747b53
1,772
university
Do What The F*ck You Want To Public License
problems/2020adventofcode16b/submissions/accepted/Stefan.kt
stoman
47,287,900
false
{"C": 169266, "C++": 142801, "Kotlin": 115106, "Python": 76047, "Java": 68331, "Go": 46428, "TeX": 27545, "Shell": 3428, "Starlark": 2165, "Makefile": 1582, "SWIG": 722}
import java.math.BigInteger import java.util.* fun main() { val s = Scanner(System.`in`).useDelimiter("""\s\syour ticket:\s|\s\snearby tickets:\s""") // Read ranges. val sRanges = Scanner(s.next()).useDelimiter(""":\s|\sor\s|-|\n""") val ranges = mutableMapOf<String, Set<IntRange>>() while (sRanges.hasNext(...
0
C
1
3
ee214c95c1dc1d5e9510052ae425d2b19bf8e2d9
1,563
CompetitiveProgramming
MIT License
src/Day02.kt
Virendra115
573,122,699
false
{"Kotlin": 2427}
fun main() { fun part1(input: String): Int { val list = input.split("\r\n") var ans =0 for (s in list) { if (s[0] == 'C' && s[2] == 'X') ans += 6 else if (s[0]== 'B' && s[2] == 'Z') ans += 6 else if (s[0] == 'A' && s[2] == '...
0
Kotlin
0
0
44aff316ffe08d27d23f2f2d8ce7d027a0e64ff8
1,075
AdventOfCode-in-kotlin
Apache License 2.0
src/Day09.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
import kotlin.math.absoluteValue fun main() { operator fun Pair<Int, Int>.plus(other:Pair<Int, Int>): Pair<Int, Int> { return Pair(this.first + other.first, this.second + other.second) } operator fun Pair<Int, Int>.minus(other: Pair<Int, Int>): Pair<Int, Int> { return Pair(this.first - ot...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
4,381
2022-aoc-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year19/Day17.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year19 import com.grappenmaker.aoc.* fun PuzzleSet.day17() = puzzle(17) { val prog = input.split(",").map(String::toLong) val grid = prog.programResults() .joinToString("") { it.toInt().toChar().toString() }.trim().lines().asCharGrid() with(grid) { partOne = p...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,365
advent-of-code
The Unlicense
src/main/kotlin/leetcode/Problem834.kt
Magdi
390,731,717
false
null
package leetcode /** * https://leetcode.com/problems/sum-of-distances-in-tree/ */ class Problem834 { private val graph = HashMap<Int, HashSet<Int>>() fun sumOfDistancesInTree(n: Int, edges: Array<IntArray>): IntArray { edges.forEach { (x, y) -> graph.getOrPut(x) { hashSetOf(y) }.apply { ...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
1,280
ProblemSolving
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ArrayPairSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,168
kotlab
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day06.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints import se.saidaspen.aoc.util.rotate import java.util.* import java.util.Collections.rotate fun main() = Day06.run() object Day06 : Day(2021, 6) { private val fish = ints(input).toMutableList() override fun pa...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,445
adventofkotlin
MIT License
src/io/github/samfoy/aoc2022/day2/Day02.kt
samfoy
572,820,967
false
{"Kotlin": 7330}
package io.github.samfoy.aoc2022.day2 import io.github.samfoy.aoc2022.asLines import io.github.samfoy.aoc2022.getInputForDay suspend fun main() { fun part1(input: List<String>) = input .map { it.split(" ") } .sumOf { gameScore(it) + shapeScore(it.last()) } fun part2(input: List<String>) = inp...
0
Kotlin
0
0
521310dbeb802c6f259c6a5e7906778a94a48d29
1,406
kotlinAOC2022
Apache License 2.0
mantono-kotlin/src/main/kotlin/com/mantono/aoc/day04/Day4.kt
joelfak
433,981,631
true
{"Python": 390591, "C#": 189476, "Rust": 166608, "C++": 127941, "F#": 68551, "Haskell": 60413, "Nim": 46562, "Kotlin": 29504, "REXX": 13854, "OCaml": 12448, "Go": 11995, "C": 9751, "Swift": 8043, "JavaScript": 1750, "CMake": 1107, "PowerShell": 866, "AppleScript": 493, "Shell": 255}
package com.mantono.aoc.day04 import com.mantono.aoc.AoC import com.mantono.aoc.Part @AoC(4, Part.A) fun computePasswords1(input: String): Int { return createSequence(input) .filter(::isOnlyIncreasing) .filter(::hasRepeatedNumber) .filter { it.length == 6 } .count() } @AoC(4, Part...
0
Python
0
0
d5031078c53c181835b4bf86458b360542f0122e
1,356
advent_of_code_2019
Apache License 2.0
src/Day01.kt
Misano9699
572,108,457
false
null
fun main() { fun listOfCalories(listOfElves: List<List<String>>): List<Int> = listOfElves.map { elf -> elf.sumOf { it.toInt() } } fun part1(input: List<String>): Int { return listOfCalories(input.splitIntoSublists("")).maxOf { it } } fun part2(input: List<String>): Int { r...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
828
advent-of-code-2022
Apache License 2.0
src/day02/Day02.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day02 import readInput private enum class Selection(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); companion object { fun from(item: Char): Selection? = when (item) { 'A' -> ROCK 'B' -> PAPER 'C' -> SCISSORS else -> null } ...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
2,177
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/aoc2020/Day16.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2020 import days.Day class Day16: Day(2020, 16) { override fun partOne(): Any { val ranges = parseRanges(inputList.takeWhile { it.isNotBlank() }) val rawRanges = ranges.values return inputList.subList(inputList.indexOf("nearby tickets:")+1, inputList.size).map { ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,072
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day02.kt
sherviiin
575,114,981
false
{"Kotlin": 14948}
import java.lang.IllegalArgumentException import java.lang.UnsupportedOperationException fun main() { rockPaperScissors(listOf("A Y", "B X", "C Z"), false) rockPaperScissors(readInput("Day02"), false) rockPaperScissors(listOf("A Y", "B X", "C Z"), true) rockPaperScissors(readInput("Day02"), true) } ...
0
Kotlin
0
1
5e52c1b26ab0c8eca8d8d93ece96cd2c19cbc28a
3,318
advent-of-code
Apache License 2.0
2020/day24/day24.kt
flwyd
426,866,266
false
{"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398}
/* * Copyright 2021 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. */ package day24 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input: n...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
3,529
adventofcode
MIT License
src/main/kotlin/com/github/pjozsef/rumorsimulation/util/GraphUtils.kt
pjozsef
124,445,433
false
null
package com.github.pjozsef.rumorfx.util import com.github.pjozsef.rumorfx.datastructure.Graph import java.util.* val <T> Graph<T>.DELTA: Int get() = this.nodeNeighbourCounts().max() ?: 0 val <T> Graph<T>.delta: Int get() = this.nodeNeighbourCounts().min() ?: 0 fun <T> Graph<T>.conductance(): Double { va...
0
Kotlin
0
0
d83e474a8f8bbf745e7cde553cba1087f51d9c90
2,421
rumor-spread-simulation
MIT License
src/Day04.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
fun main() { val input = readInput("Day04") val rangePairs = input.map(::mapPairs) val fullOverlapping = rangePairs .filter { (r1, r2) -> hasFullOverlap(r1, r2) } .onEach { (r1, r2) -> println("$r1 and $r2 is fully overlapping") } println("There are ${fullOverlapping.size} overlaps") ...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
1,076
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2018/calendar/day06/Day06.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2018.calendar.day06 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import kotlin.Int.Companion.MAX_VALUE import kotlin.Int.Companion.MIN_VALUE import kotlin.math.abs class Day06 @Inject constructor(private val generatorFactory: InputGeneratorFacto...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,311
advent-of-code
MIT License
src/Day05.kt
mhuerster
572,728,068
false
{"Kotlin": 24302}
fun main() { // TODO: parse start state from file val sampleInitialState = mutableMapOf( 1 to "ZN", 2 to "MCD", 3 to "P", ) val initialState = mutableMapOf( 1 to "NRGP", 2 to "JTBLFGDC", 3 to "MSV", 4 to "LSRCZP", 5 to "PSLVCWDQ", 6 to "CTNWDMS", 7 to "HDGWP", 8 to "Z...
0
Kotlin
0
0
5f333beaafb8fe17ff7b9d69bac87d368fe6c7b6
3,196
2022-advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DiffWaysToCompute.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,332
kotlab
Apache License 2.0
src/main/kotlin/g2201_2300/s2242_maximum_score_of_a_node_sequence/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2242_maximum_score_of_a_node_sequence // #Hard #Array #Sorting #Graph #Enumeration // #2023_06_27_Time_844_ms_(100.00%)_Space_72.5_MB_(100.00%) class Solution { fun maximumScore(scores: IntArray, edges: Array<IntArray>): Int { // store only top 3 nodes (having highest scores) v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,338
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day03/Day03.kt
Malo-T
575,370,082
false
null
package day03 private val itemPriorities: Map<Char, Int> = (('a'..'z') + ('A'..'Z')).mapIndexed { i, c -> c to i + 1 }.toMap() private typealias RuckSack = Pair<Set<Char>, Set<Char>> class Day03 { fun parse(input: String): List<RuckSack> = input.lines().map { line -> RuckSack( ...
0
Kotlin
0
0
f4edefa30c568716e71a5379d0a02b0275199963
913
AoC-2022
Apache License 2.0
library/src/main/kotlin/io/github/tomplum/libs/extensions/CollectionExtensions.kt
TomPlum
317,517,927
false
{"Kotlin": 161096}
package io.github.tomplum.libs.extensions import kotlin.math.pow /** * Returns the product of all the integers in the given list. */ fun List<Int>.product(): Int = if (isNotEmpty()) reduce { product, next -> product * next } else 0 fun List<Long>.product(): Long = if (isNotEmpty()) reduce { product, next -> product...
2
Kotlin
0
0
c026ab7ae982c34db4f5fbebf3f79b0b8c717ee5
5,233
advent-of-code-libs
Apache License 2.0
2022/kotlin/src/Day01.kt
tomek0123456789
573,389,936
false
{"Kotlin": 5085}
fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 for (calories in input) { if (calories == "") { if (max < current) { max = current } current = 0 } else { ...
0
Kotlin
0
0
5ee55448242ec79475057f43d34f19ae05933eba
1,174
aoc
Apache License 2.0
src/day20/Day20.kt
gautemo
317,316,447
false
null
package day20 import shared.Point import shared.getText import shared.separateByBlankLine import kotlin.math.sqrt fun cornerTilesMultiplied(map: TileMap): Long{ return map.xy[Point(0,0)]!!.id * map.xy[Point(map.length-1,0)]!!.id * map.xy[Point(map.length-1,map.length-1)]!!.id * map.xy[Point(0,map.length-1)]!!.id ...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
5,716
AdventOfCode2020
MIT License
common/src/main/kotlin/combo/bandit/ga/BanditGeneticOperators.kt
rasros
148,620,275
false
null
package combo.bandit.ga import combo.ga.SelectionOperator import combo.math.normInvCdf import combo.math.permutation import kotlin.math.max import kotlin.math.min import kotlin.math.sqrt import kotlin.random.Random class EliminationChain(vararg val eliminators: SelectionOperator<BanditCandidates>) : SelectionOperator...
0
Kotlin
1
2
2f4aab86e1b274c37d0798081bc5500d77f8cd6f
3,252
combo
Apache License 2.0
src/main/kotlin/Day17.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import kotlin.reflect.KClass fun main() { val input = readFileAsList("Day17") println(Day17.part1(input)) println(Day17.part2(input)) } object Day17 { private const val chamberWidth = 7 private val downMovementVector = Vector2d(0, -1) fun part1(input: List<String>): Long { val jetMove...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
9,254
advent-of-code-2022
Apache License 2.0
src/Day09.kt
AndreiShilov
572,661,317
false
{"Kotlin": 25181}
import java.util.Stack fun main() { fun moveHead(head: Pair<Int, Int>, direction: String) = when (direction) { "R" -> Pair(head.first, head.second + 1) "L" -> Pair(head.first, head.second - 1) "U" -> Pair(head.first + 1, head.second) "D" -> Pair(head.first -...
0
Kotlin
0
0
852b38ab236ddf0b40a531f7e0cdb402450ffb9a
3,621
aoc-2022
Apache License 2.0
src/day17/Day17.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day17 import Runner import kotlin.math.max import kotlin.math.min fun main() { Day17Runner().solve() } class Day17Runner : Runner<Long>( day = 17, expectedPartOneTestAnswer = 3068, expectedPartTwoTestAnswer = 1514285714288 ) { override fun partOne(input: List<String>, test: Boolean): Lon...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
11,100
advent-of-code
Apache License 2.0
src/main/kotlin/g1901_2000/s1916_count_ways_to_build_rooms_in_an_ant_colony/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1916_count_ways_to_build_rooms_in_an_ant_colony // #Hard #Dynamic_Programming #Math #Tree #Graph #Topological_Sort #Combinatorics // #2023_06_20_Time_2564_ms_(100.00%)_Space_94.2_MB_(100.00%) import java.math.BigInteger class Solution { private lateinit var graph: Array<MutableList<Int>?> ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,936
LeetCode-in-Kotlin
MIT License
2022/src/test/kotlin/Day21.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import kotlin.reflect.KFunction private sealed interface Monkey21 { var monkeys: Map<String, Monkey21> val yell: Long } private data class NumMonkey21(val num: Long) : Monkey21 { override lateinit var monkeys: Map<String, Monke...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
3,119
adventofcode
MIT License
src/main/kotlin/de/nilsdruyen/aoc/Day04.kt
nilsjr
571,758,796
false
{"Kotlin": 15971}
package de.nilsdruyen.aoc fun main() { fun part1(input: List<String>): Int = input.toPairRanges().count { ranges -> val firstInSecond = ranges.first.all { it in ranges.second } val secondInFirst = ranges.second.all { it in ranges.first } firstInSecond || secondInFirst } fun part2(...
0
Kotlin
0
0
1b71664d18076210e54b60bab1afda92e975d9ff
1,080
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2020/Day21.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2020 import com.nibado.projects.advent.* object Day21 : Day { private val values = resourceRegex(2020, 21, "([a-z ]+) \\(contains ([a-z, ]+)\\)").map { (_, ing, all) -> ing.split(" ").toSet() to all.split(", ").toSet() } private val allergens : Map<String, Stri...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,315
adventofcode
MIT License
src/main/kotlin/net/voldrich/aoc2021/Day11.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay import kotlin.math.max import kotlin.math.min // link to task fun main() { Day11().run() } class Day11 : BaseDay() { override fun task1() : Int { val inputNums = input.lines().map { line -> line.trim().toCharArray().map { it.digitToInt() }.toMu...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
2,159
advent-of-code
Apache License 2.0
src/main/day2/Day02.kt
Derek52
572,850,008
false
{"Kotlin": 22102}
package main.day2 import main.readInput fun main() { val input = readInput("day2/day2") //testAlg() val firstHalf = false if (firstHalf) { println(part1(input)) } else { println(part2(input)) } } fun part1(input: List<String>) : Int { var opponent = Throw.ROCK var m...
0
Kotlin
0
0
c11d16f34589117f290e2b9e85f307665952ea76
3,260
2022AdventOfCodeKotlin
Apache License 2.0
src/year2022/23/Day23.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`23` import java.util.Collections import readInput data class Point( val x: Int, val y: Int ) enum class Direction { N, S, W, E, NE, NW, SE, SW } fun parseInput(input: List<String>): Set<Point> { return input.mapIndexed { y, line -> line.split("") .filter { ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
5,621
KotlinAdventOfCode
Apache License 2.0
src/main/kotlin/suggestions/KtSuggestions.kt
hermannhueck
46,933,495
false
{"Java": 53536, "Scala": 43388, "Kotlin": 4114}
@file:JvmName("KtSuggestions") package suggestions private val MAX_WORDS = 13 private data class Suggestion(val text: String) { override fun toString() = text } private val INPUT = listOf("The", "moon", "is", "not", "a", "planet", "and", "also", "not", "a", "star", ".", "But", ",", "I", "digress", "we"...
0
Java
0
0
4ff6af70ecec5847652fb593b9d70cde7db5256d
2,006
BrainTwisters
Apache License 2.0
src/main/kotlin/aoc2023/Day15.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay import util.illegalInput // https://adventofcode.com/2023/day/15 object Day15 : AoCDay<Int>( title = "Lens Library", part1ExampleAnswer = 1320, part1Answer = 495972, part2ExampleAnswer = 145, part2Answer = 245223, ) { private fun hash(string: String) = string.fold...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
1,699
advent-of-code-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem124/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem124 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [124. Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum/description/); */ class Solution { /* Complexity: * Time O(N) and Space O(H) where N and H are th...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,692
hj-leetcode-kotlin
Apache License 2.0
src/Day05.kt
timlam9
573,013,707
false
{"Kotlin": 9410}
import java.util.* fun main() { fun part1(input: List<String>): String { val stacks = List(9) { Stack<Char>() } input.take(8).reversed().map { line -> line.forEachIndexed { index, char -> if (char.isLetter()) { stacks[index / 4].p...
0
Kotlin
0
0
7971bea39439b363f230a44e252c7b9f05a9b764
1,683
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day15.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import utils.Bounds import utils.Coordinates import kotlin.math.absoluteValue import kotlin.system.measureTimeMillis val parseSensor = "Sensor at x=([-\\d]+), y=([-\\d]+): closest beacon is at x=([-\\d]+), y=([-\\d]+)".toRegex() class Sensor(val pos: Coordinates, val beacon: ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
3,965
aoc-2022-kotlin
Apache License 2.0
src/day03/Day03.kt
wickenico
573,048,677
false
{"Kotlin": 7731}
package day03 import readInput fun main() { println(part1(readInput("day03", "input"))) println(part2(readInput("day03", "input"))) } private fun calculatePriority(char: Char): Int { return if (char.code >= 92) { char.code - 96 } else { char.code - 38 } } private fun calculatePri...
0
Kotlin
0
0
00791dc0870048b08092e38338cd707ce0f9706f
734
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2018/calendar/day15/GameDijkstra.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2018.calendar.day15 import me.peckb.aoc._2018.calendar.day15.GameDijkstra.SpaceWithPath import me.peckb.aoc.pathing.Dijkstra import me.peckb.aoc.pathing.DijkstraNodeWithCost class GameDijkstra(val gameMap: List<List<Space>>) : Dijkstra<Space, Path, SpaceWithPath> { override fun Space.withCost(...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
1,917
advent-of-code
MIT License
y2016/src/main/kotlin/adventofcode/y2016/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution object Day16 : AdventSolution(2016, 16, "Dragon Checksum ") { override fun solvePartOne(input: String) = fillDisk(input, 272).checksum() override fun solvePartTwo(input: String) = fillDisk(input, 35651584).checksum() } private fun fillDisk(inpu...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,131
advent-of-code
MIT License
src/main/kotlin/days/Day10.kt
wmichaelshirk
315,495,224
false
null
package days import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.roundToLong class Day10 : Day(10) { private val inputData = inputList.map(String::toInt).sorted() private val fullList = listOf(0) + inputData + listOf(inputData.last() + 3) override fun partOne(): Int? { val f...
0
Kotlin
0
0
b36e5236f81e5368f9f6dbed09a9e4a8d3da8e30
1,545
2020-Advent-of-Code
Creative Commons Zero v1.0 Universal
2015/src/main/kotlin/com/koenv/adventofcode/Day21.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode object Day21 { public fun getMaxGoldSpentAndLose(input: String): Int { return getGoldSpent(input, 0, { lhs, rhs -> lhs > rhs}, { it <= 0}) } public fun getMinGoldSpent(input: String): Int { return getGoldSpent(input, Integer.MAX_VALUE, { lhs, rhs -> lhs < rhs...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
3,018
AdventOfCode-Solutions-Kotlin
MIT License
player/greedy.kt
arukuka
167,334,074
true
{"HTML": 96461, "C++": 41603, "JavaScript": 31527, "Python": 17524, "Kotlin": 6069, "CSS": 5843, "Makefile": 2251}
import java.util.* import java.io.* import kotlin.math.* const val SEARCHDEPTH = 7 const val SPEEDLIMIT = 1000 const val searchDepth = SEARCHDEPTH const val speedLimitSquared = SPEEDLIMIT * SPEEDLIMIT var nextSeq = 1 data class IntVec(val x : Int, val y : Int) { operator fun plus(v : IntVec) : IntVec { return I...
0
HTML
0
0
04db0dade2bb0ef9803fb473665b171a233a2748
6,069
software-for-SamurAI-Coding-2018-19
MIT License
2022/kotlin-lang/src/main/kotlin/mmxxii/days/Day3.kt
Delni
317,500,911
false
{"Kotlin": 66017, "Dart": 53066, "Go": 28200, "TypeScript": 7238, "Rust": 7104, "JavaScript": 2873}
package mmxxii.days class Day3 : Abstract2022<Int>("03", "Rucksack Reorganization") { override fun part1(input: List<String>): Int = input .map(String::toRucksack) .map { it.first.intersect(it.second.toSet()).single() } .sumByPriority() override fun part2(input: List<String>) = input ...
0
Kotlin
0
1
d8cce76d15117777740c839d2ac2e74a38b0cb58
1,049
advent-of-code
MIT License
src/Day01.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
fun main() { fun prepareInput(allInput: String): MutableList<Int> { val elfCalories = mutableListOf<Int>() allInput.split("\n\n").forEach { elf -> elfCalories.add(elf.split("\n").sumOf { cal -> cal.toInt() }) } return elfCalories } fun part1(input: List<String>)...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
1,010
advent-of-code-2022-kotlin
Apache License 2.0
src/main/aoc2022/Day7.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 class Day7(input: List<String>) { private val fileSizes = parseInput(input) /** * Returns list of sizes of files / directories in the file system. The file names are not needed * for anything so those are not included. */ private fun parseInput(input: List<String>): List<In...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,290
aoc
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/AmountOfTime.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,440
kotlab
Apache License 2.0
src/main/kotlin/day03_oop/day03_oop.kt
andrew-suprun
725,670,189
false
{"Kotlin": 18354, "Python": 17857, "Dart": 8224}
package day03_oop import java.io.File fun main() { Part1("input.data").run() Part2("input.data").run() } data class Number(val value: Int, val row: Int, val colStart: Int, var colEnd: Int) abstract class Day03(fileName: String) { private val lines = File(fileName).readLines() val numbers = parseEngi...
0
Kotlin
0
0
dd5f53e74e59ab0cab71ce7c53975695518cdbde
2,685
AoC-2023
The Unlicense
src/chapter3/section4/ex30_ChiSquareStatistic.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section4 import extensions.formatDouble import extensions.random import kotlin.math.sqrt /** * 卡方值(chi-square statistic) * 为SeparateChainingHashST添加一个方法来计算散列表的X² * 对于大小为M并含有N个元素的散列表,这个值的定义为: * X² = (M / N)((f₀ - N / M)² + (f₁ - N / M)² + ... + (f(m-1) - N / M)²) * 其中,f(i)为散列值为i的键的数量 * 这个统计数据是检测...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,196
Algorithms-4th-Edition-in-Kotlin
MIT License
src/day03/Day03.kt
Puju2496
576,611,911
false
{"Kotlin": 46156}
package day03 import readInput fun main() { // test if implementation meets criteria from the description, like: val input = readInput("src/day03", "Day03") println("Part1") part1(input) println("Part2") part2(input) } private fun part1(inputs: List<String>) { var sum = 0 inputs.forEa...
0
Kotlin
0
0
e04f89c67f6170441651a1fe2bd1f2448a2cf64e
1,162
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/day4/Day4.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day4 import days.Day import kotlin.math.pow class Day4: Day(false) { override fun partOne(): Any { //Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 val winningNumbers: List<List<Int>> = readInput().map{ it.substringAfter(":").substringBefore("|").trim().split(" ").filter...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
2,074
advent-of-code_2023
The Unlicense
src/main/kotlin/aoc2019/ManyWorldsInterpretation.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.Point import komu.adventofcode.utils.nonEmptyLines import utils.shortestPathBetween import utils.shortestPathWithCost private typealias LockType = Int private typealias CollectedKeys = Int fun manyWorldsInterpretation(input: String): Int = Vault.pa...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
4,607
advent-of-code
MIT License
src/main/java/com/barneyb/aoc/aoc2022/day18/BoilingBoulders.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day18 import com.barneyb.aoc.util.* import com.barneyb.util.HashSet import com.barneyb.util.Queue import com.barneyb.util.Vec3 fun main() { Solver.execute( ::parse, ::surfaceArea, // 3586 ::externalSurfaceArea, // 2072 ) } internal fun parse(input: Stri...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
1,811
aoc-2022
MIT License
src/main/kotlin/be/twofold/aoc2021/Day03.kt
jandk
433,510,612
false
{"Kotlin": 10227}
package be.twofold.aoc2021 object Day03 { fun part1(input: List<String>): Int { val count = input.size val width = input[0].length var result = 0 for (i in 0 until width) { val isOne = input.count { it[i] == '1' } >= (count / 2) result = (result shl 1) or (if...
0
Kotlin
0
0
2408fb594d6ce7eeb2098bc2e38d8fa2b90f39c3
1,190
aoc2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindMinArrowShots.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,730
kotlab
Apache License 2.0
monty-hall/src/main/kotlin/com/nickperov/stud/algorithms/montyhall/MontyHallSimulator.kt
nickperov
327,780,009
false
null
package com.nickperov.stud.algorithms.montyhall import kotlin.random.Random enum class Prize { GOAT, CAR } enum class Strategy { KEEP, CHANGE, GUESS } object MontyHallApp { @JvmStatic fun main(args: Array<String>) { println("Simulate monty hall game with different strategies") val ro...
0
Kotlin
0
0
6696f5d8bd73ce3a8dfd4200f902e2efe726cc5a
2,342
Algorithms
MIT License
src/main/kotlin/dev/siller/aoc2023/Day11.kt
chearius
725,594,554
false
{"Kotlin": 50795, "Shell": 299}
package dev.siller.aoc2023 import dev.siller.aoc2023.util.Point import kotlin.math.abs data object Day11 : AocDayTask<ULong, ULong>( day = 11, exampleInput = """ |...#...... |.......#.. |#......... |.......... |......#... |.#........ |.........# ...
0
Kotlin
0
0
fab1dd509607eab3c66576e3459df0c4f0f2fd94
2,617
advent-of-code-2023
MIT License
src/Day19.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.max private fun blueprints(): List<Blueprint> { return readInput("Day19").map { val bVals = Regex( "Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. " + "Each obsidian robot costs (\\d+) ore and (\\d+) clay. " + ...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
6,189
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindTheSmallestDivisorGivenThreshold.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,685
kotlab
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/ThreeSum.kt
faniabdullah
382,893,751
false
null
//Given an integer array nums, return all the triplets [nums[i], nums[j], nums[ //k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. // // Notice that the solution set must not contain duplicate triplets. // // // Example 1: // Input: nums = [-1,0,1,2,-1,-4] //Output: [[-1,-1,2],[-1,0,1...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,799
dsa-kotlin
MIT License
src/main/kotlin/com/psmay/exp/advent/y2021/Day03.kt
psmay
434,705,473
false
{"Kotlin": 242220}
package com.psmay.exp.advent.y2021 import com.psmay.exp.advent.y2021.util.transpose object Day03 { private fun gammaAndEpsilonBits(comparedCountsPerColumn: List<Int>): Pair<List<Boolean>, List<Boolean>> { val gammaBits = gammaBits(comparedCountsPerColumn) val epsilonBits = gammaBits.map { !it } ...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
3,799
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
src/Day04.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
fun main() { fun parse(input: List<String>) = input .map { line -> val (a1, a2) = line.substringBefore(',').split('-').map(String::toInt) val (b1, b2) = line.substringAfter(',').split('-').map(String::toInt) (a1..a2) to (b1..b2) } operator fun IntRange.conta...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
809
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/droidhats/mapprocessor/AStar.kt
RobertBeaudenon
232,313,026
false
null
package com.droidhats.mapprocessor /** * Main data structure that we use to hold the vertices in the graph */ class Vertex(circle: Circle, endPoint: Pair<Double, Double>) { val pos: Pair<Double, Double> = Pair(circle.cx, circle.cy) val heuristic: Double = getDistance(pos, endPoint) var prev: Vertex? = nu...
4
Kotlin
4
7
ea136a60a71f5d393f4a5688e86b9c56c6bea7b6
6,910
SOEN390-CampusGuideMap
MIT License
07/src/commonMain/kotlin/Main.kt
daphil19
725,415,769
false
{"Kotlin": 131380}
import Card.Companion.toCardOrdinal import Card.Companion.toCardOrdinalPart2 expect fun getLines(): List<String> fun main() { var lines = getLines() // lines = """32T3K 765 //T55J5 684 //KK677 28 //KTJJT 220 //QQQJA 483""".lines() part1(lines) part2(lines) } enum class Card(val ch: Char) { // ORD...
0
Kotlin
0
0
70646b330cc1cea4828a10a6bb825212e2f0fb18
4,062
advent-of-code-2023
Apache License 2.0
src/main/kotlin/com/rtarita/days/Day8.kt
RaphaelTarita
570,100,357
false
{"Kotlin": 79822}
package com.rtarita.days import com.rtarita.structure.AoCDay import com.rtarita.util.day import kotlinx.datetime.LocalDate object Day8 : AoCDay { override val day: LocalDate = day(8) private fun getGrid(input: String): List<List<Int>> { return input.lineSequence() .map { line -> ...
0
Kotlin
0
9
491923041fc7051f289775ac62ceadf50e2f0fbe
2,144
AoC-2022
Apache License 2.0
src/main/kotlin/g2801_2900/s2861_maximum_number_of_alloys/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2861_maximum_number_of_alloys // #Medium #Array #Binary_Search #2023_12_21_Time_289_ms_(100.00%)_Space_43.8_MB_(100.00%) import kotlin.math.max class Solution { fun maxNumberOfAlloys( n: Int, k: Int, budget: Int, composition: List<List<Int>>, stock: Lis...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,681
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/nibado/projects/advent/collect/SummedAreaTable.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.collect import com.nibado.projects.advent.Point // https://en.wikipedia.org/wiki/Summed-area_table class SummedAreaTable private constructor(private val table: List<IntArray>) { private fun get(p: Point) = get(p.x, p.y) private fun get(x: Int, y: Int) = if(x < 0 || y < 0) { ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,848
adventofcode
MIT License
day10/main.kt
LOZORD
441,007,912
false
{"Kotlin": 29367, "Python": 963}
import java.util.Scanner enum class LineStatus { VALID, INCOMPLETE, CORRUPTED } data class StatusWithData( val status: LineStatus, val corruption: Char? = null, val remaining: ArrayDeque<Char>? = null, ) fun main(args: Array<String>) { val input = Scanner(System.`in`) val statuses = A...
0
Kotlin
0
0
17dd266787acd492d92b5ed0d178ac2840fe4d57
2,909
aoc2021
MIT License
src/day-7/part-2/solution-day-7-part-2.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import `day-7`.Directory import `day-7`.File import `day-7`.FileSystemItem val root = Directory("/") var currentDirectory = root fun addFileSystemItem(string: String) { if (string.startsWith("dir")) { currentDirectory.content.add(Directory(string.substring(4), parent = currentDirectory)) } else { ...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
2,164
advent-of-code-22
MIT License
src/day24/Day24.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day24 import readInput enum class Direction(val symbol: Char, val vec: Position) { UP('^', Position(-1, 0)), RIGHT('>', Position(0, 1)), DOWN('v', Position(1, 0)), LEFT('<', Position(0, -1)); companion object { private val symbolMap = Direction.values().associateBy { it.symbol } ...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
5,439
aoc-2022
Apache License 2.0