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
LeetCode/Largest Magic Square/main.kt
thedevelopersanjeev
112,687,950
false
null
class Solution { private fun isGood(grid: Array<IntArray>, x: Int, y: Int, len: Int): Boolean { val st = HashSet<Int>() for (i in x until x + len) { var curr = 0 for (j in y until y + len) curr += grid[i][j] st.add(curr) } for (j in y until y + len...
0
C++
58
146
610520cc396fb13a03c606b5fb6739cfd68cc444
1,729
Competitive-Programming
MIT License
src/day16/Day16pt2.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day16 import readInput import kotlin.math.max import kotlin.math.pow class StepData(val data: ShortArray, val totalValves: Int, val usefulValves: Int, val players: Int) { companion object { fun numberOfValveConfigurations(usefulValves: Int): Int { return (2).toDouble().pow(usefulValves...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
8,165
aoc-2022
Apache License 2.0
src/main/kotlin/name/valery1707/problem/leet/code/BinaryGapK.kt
valery1707
541,970,894
false
null
package name.valery1707.problem.leet.code import kotlin.math.max /** * # 868. Binary Gap * * Given a positive integer `n`, find and return the **longest distance** between any two **adjacent** `1`'s in the *binary representation* of `n`. * If there are no two adjacent `1`'s, return `0`. * * Two `1`'s are **adja...
3
Kotlin
0
0
76d175f36c7b968f3c674864f775257524f34414
1,417
problem-solving
MIT License
src/Day01.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
fun main() { fun parseElves(input: List<String>): List<Int> { return input.fold(mutableListOf(0)) { elves, line -> elves.apply { if (line.isBlank()) add(0) else this[size - 1] += line.toInt() } } } // find the highest-calorie elf fun part1(input: ...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
786
advent-of-code-2022
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2021/calendar/day09/Day09.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2021.calendar.day09 import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import javax.inject.Inject import kotlin.Int.Companion.MAX_VALUE typealias Topography = List<List<Int>> class Day09 @Inject constructor(private val generatorFactory: InputGeneratorFactory) { fun findLowPoi...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,584
advent-of-code
MIT License
src/2022/Day23.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import common.Linearizer import common.Offset import common.* import java.io.File import java.util.* fun main() { Day23().solve() } class Day23 { val input1 = """ ....#.. ..###.# #...#.# .#...## #.###.. ##.#.## .#..#.. """.trimInden...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
5,446
advent-of-code
Apache License 2.0
src/Day04.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
// Advent of Code 2022, Day 04, Camp Cleanup fun main() { fun part1(input: List<String>): Int { var total = 0 input.forEach { line -> val ass = line.split(",", "-").map { it.toInt() } if ((ass[0] <= ass[2] && ass[1] >= ass[3]) || (ass[0] >= ass[2] && ass[1] <= ass[3])) { ...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
959
AdventOfCode2022
Apache License 2.0
core/src/main/kotlin/edu/umontreal/kotlingrad/typelevel/TypeClassing.kt
ileasile
390,895,055
true
{"Kotlin": 134062, "Java": 21933}
@file:Suppress("NonAsciiCharacters") package edu.umontreal.kotlingrad.typelevel import kotlin.math.roundToInt /** Corecursive Fibonacci sequence of [Nat]s **/ tailrec fun <T> Nat<T>.fibonacci( n: T, seed: Pair<T, T> = nil to one, fib: (Pair<T, T>) -> Pair<T, T> = { (a, b) -> b to a + b }, i: T = nil, ): T = ...
0
null
0
0
56a6d4d03544db1bcaa93c31ffc7e075bc564e64
6,867
kotlingrad
Apache License 2.0
2022/src/main/kotlin/day25.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.Parser import utils.Solution import utils.Vec2i import utils.badInput import utils.mapParser fun main() { Day25.run(skipPart2 = true) } object Day25 : Solution<List<String>>() { override val name = "day25" override val parser = Parser.lines private fun parseSnafuNumber(s: Stri...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,130
aoc_kotlin
MIT License
kotlin/src/katas/kotlin/leetcode/longest_substring_palindrome/LongestPalindromeTests.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
@file:Suppress("DuplicatedCode", "unused") package katas.kotlin.leetcode.longest_substring_palindrome import nonstdlib.measureDuration import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/problems/longest-palindromic-substring */ class LongestPalindromeTests { @Test fun `trivial examples`...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,694
katas
The Unlicense
src/iii_conventions/MyDate.kt
edwardz10
136,737,762
false
{"Kotlin": 75614, "Java": 4952}
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int { val compareYears = year.compareTo(other.year) val compareMonths = month.compareTo(other.month) val compareDays = dayOfMonth.compa...
0
Kotlin
0
0
446d349a459b8624a7da9469b618eea7df3f5cba
2,933
kotlin-koans-completed
MIT License
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day17.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import com.dvdmunckhof.aoc.common.MutableBitSet import com.dvdmunckhof.aoc.common.Point class Day17(input: String, shapesInput: String) { private val directions = input.map { c -> Direction.values().first { it.c == c } } private val rocks = shapesInput.split("\n\n").map {...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
4,004
advent-of-code
Apache License 2.0
LeetCode/0435. Non overlapping Intervals/Solution.kt
InnoFang
86,413,001
false
{"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410}
/** * Created by <NAME> on 2018/1/31. */ class Interval( var start: Int = 0, var end: Int = 0 ) /** * Dynamic Programming 动态规划 * 将应该删去多少个区间,转化为最大的不重叠区间是几个 * 这样要求应该删去多少个区间,就可以用 区间个数 - 最大连续区间数 得到 * 类似于最长上升子序列问题 LIS * * 18 / 18 test cases passed. * Runtime: 1651 ms */ class Solution { fun e...
0
C++
8
20
2419a7d720bea1fd6ff3b75c38342a0ace18b205
3,178
algo-set
Apache License 2.0
advent_of_code/2018/solutions/day_12_b.kt
migafgarcia
63,630,233
false
{"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343}
import java.io.File // 2463 fun main(args: Array<String>) { assert(score(".#....##....#####...#######....#.#..##.", 3) == 325) val regex = Regex(".* => .*") val margin = 3 val lines = File(args[0]).readLines() var leftPots = 0 var state = StringBuilder(lines[0].split(":")[1].trim()) ...
0
C++
3
9
82f5e482c0c3c03fd39e46aa70cab79391ed2dc5
1,468
programming-challenges
MIT License
src/Day08.kt
diego09310
576,378,549
false
{"Kotlin": 28768}
fun main() { fun part1(input: List<String>): Int { val map: MutableList<List<Int>> = mutableListOf() input.forEach{ line -> map.add(line.toCharArray().map{it.digitToInt()})} var v = 0 for (i in map.indices) { for (j in map[0].indices) { if (i == 0 || j =...
0
Kotlin
0
0
644fee9237c01754fc1a04fef949a76b057a03fc
3,236
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2023/day2/day2Solver.kt
Advent-of-Code-Netcompany-Unions
726,531,711
false
{"Kotlin": 94973}
package aoc2023.day2 import lib.* suspend fun main() { setupChallenge().solveChallenge() } val baseCubeCount = mapOf(Pair("red", 0), Pair("green", 0), Pair("blue", 0)) fun setupChallenge(): Challenge<List<List<List<String>>>> { return setup { day(2) year(2023) parser { i...
0
Kotlin
0
0
a77584ee012d5b1b0d28501ae42d7b10d28bf070
1,752
AoC-2023-DDJ
MIT License
Aoe/src/Principal.kt
aranzabe
403,376,804
false
{"Kotlin": 57514, "Java": 269}
import Factoria.factoriaAldeano import Factoria.factoriaCivilizacion import kotlin.random.Random fun asignacionAldeano(): Int { var cod = 0 val alea = Random.nextInt(0, 100) if (alea < 40) { cod = 1 } else if (alea < 60) { cod = 2 } return cod } fun extraerRecursos(m: Mina, civ...
0
Kotlin
0
0
d287547ea6cacc644802713a3fd514fa333613a4
3,004
kotlin
MIT License
y2020/src/main/kotlin/adventofcode/y2020/Day02.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day02.solve() object Day02 : AdventSolution(2020, 2, "Password Philosophy") { override fun solvePartOne(input: String) = input .lineSequence() .map(::parse) .count { (ch, l, h, pwd) -> pwd.count { it == ch } in...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
876
advent-of-code
MIT License
src/adventofcode/blueschu/y2017/day16/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day16 import adventofcode.blueschu.y2017.day10.rotate import java.io.File import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day16.txt") .bufferedReader() .use { r -> r.readText().trim() } .split(',') } fun main(arg...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
3,209
Advent-Of-Code
MIT License
aoc-2015/src/main/kotlin/aoc/AocDay13.kt
triathematician
576,590,518
false
{"Kotlin": 615974}
package aoc import aoc.util.chunk import aoc.util.chunkint import aoc.util.permutations class AocDay13: AocDay(13) { companion object { @JvmStatic fun main(args: Array<String>) { AocDay13().run() } } override val testinput = """ Alice would gain 54 happiness units by sitting next to Bob. Alic...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
2,130
advent-of-code
Apache License 2.0
src/main/kotlin/g2901_3000/s2981_find_longest_special_substring_that_occurs_thrice_i/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2981_find_longest_special_substring_that_occurs_thrice_i // #Medium #String #Hash_Table #Binary_Search #Counting #Sliding_Window // #2024_01_19_Time_208_ms_(90.70%)_Space_39.1_MB_(23.26%) import java.util.Collections import java.util.TreeMap import kotlin.math.max class Solution { fun maximum...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,772
LeetCode-in-Kotlin
MIT License
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p02/Leet230.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p02 import java.util.* class Leet230 { class Solution { fun kthSmallest(root: TreeNode?, k: Int): Int { val list = LinkedList<TreeNode>() bTreeToLinkedList(root, list) return list.getOrNull(k - 1)?.`val` ?: 0 } private ...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
2,223
playground
MIT License
src/main/kotlin/g0301_0400/s0378_kth_smallest_element_in_a_sorted_matrix/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0378_kth_smallest_element_in_a_sorted_matrix // #Medium #Top_Interview_Questions #Array #Sorting #Binary_Search #Matrix #Heap_Priority_Queue // #2022_09_11_Time_522_ms_(59.78%)_Space_56.6_MB_(79.61%) class Solution { fun kthSmallest(matrix: Array<IntArray>?, k: Int): Int { if (matrix =...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,682
LeetCode-in-Kotlin
MIT License
kotlin/src/com/daily/algothrim/leetcode/CheckStraightLine.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 1232. 缀点成线 * * 在一个 XY 坐标系中有一些点,我们用数组 coordinates 来分别记录它们的坐标,其中 coordinates[i] = [x, y] 表示横坐标为 x、纵坐标为 y 的点。 * 请你来判断,这些点是否在该坐标系中属于同一条直线上,是则返回 true,否则请返回 false。 * * 输入:coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] * 输出:true * * 输入:coordinates = [[1,1],[2,2],[3,4],...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,144
daily_algorithm
Apache License 2.0
src/main/kotlin/com/leetcode/top100LikedQuestions/easy/symetric_binary_tree/Main.kt
frikit
254,842,734
false
null
package com.leetcode.top100LikedQuestions.easy.symetric_binary_tree fun main() { println("Test case 1:") val t1 = TreeNode(1) t1.left = TreeNode(2) t1.right = TreeNode(2) t1.left!!.left = TreeNode(3) t1.left!!.right = TreeNode(4) t1.right!!.left = TreeNode(4) t1.right!!.right = TreeN...
0
Kotlin
0
0
dda68313ba468163386239ab07f4d993f80783c7
1,474
leet-code-problems
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[103]二叉树的锯齿形层序遍历.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* import kotlin.collections.ArrayList //给定一个二叉树,返回其节点值的锯齿形层序遍历。(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行)。 // // 例如: //给定二叉树 [3,9,20,null,null,15,7], // // // 3 // / \ // 9 20 // / \ // 15 7 // // // 返回锯齿形层序遍历如下: // // //[ // [3], // [20,9], // [15,7] //] // // Related Topics 栈 树 广度...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,786
MyLeetCode
Apache License 2.0
src/main/kotlin/land/tbp/y2019/day_7_amplification_circuit/Problem1.kt
TheBestPessimist
124,364,980
false
{"Python": 111986, "Kotlin": 67608}
package land.tbp.y2019.day_7_amplification_circuit import land.tbp.y2019.intcode.computer.Computer import land.tbp.y2019.intcode.computer.Memory import loadResourceFile import stringToInt fun main() { val s = loadResourceFile("./land/tbp/y2019/day_7_amplification_circuit/in.txt") val maxThrusterSignal = solve...
0
Python
0
0
ee9c97f7d85b7f5ebc0bea285938ca75f2fdfddc
1,810
Advent-of-Code-Problems
Do What The F*ck You Want To Public License
src/Day06.kt
kedvinas
572,850,757
false
{"Kotlin": 15366}
fun main() { fun part1(input: List<String>): Int { val buffer = input[0] for (i in buffer.indices) { val differentChars = buffer.substring(i, i + 4) .toCharArray() .toSet() .size if (differentChars == 4) { retu...
0
Kotlin
0
0
04437e66eef8cf9388fd1aaea3c442dcb02ddb9e
1,394
adventofcode2022
Apache License 2.0
src/test/kotlin/adventofcode/common/PermutationsSpec.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.common import io.kotest.core.spec.style.FreeSpec import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder import io.kotest.matchers.shouldBe class PermutationsSpec : FreeSpec({ "Collection<T>.permutations()" - { "returns no permutations for an empty list" { emp...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,493
AdventOfCode
MIT License
src/main/kotlin/y2023/Day6.kt
juschmitt
725,529,913
false
{"Kotlin": 18866}
package y2023 import utils.Day class Day6 : Day(6, 2023, false) { override fun partOne(): Any { return inputString.split("\n").map { line -> line.split(":").last().trim().split(" ").mapNotNull { it.toIntOrNull() } }.zipWithNext { times, distances -> times.zip(distances) { time, distanc...
0
Kotlin
0
0
b1db7b8e9f1037d4c16e6b733145da7ad807b40a
964
adventofcode
MIT License
src/Day14.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
fun main() { data class Point(var x: Int, var y: Int) fun generateRocks(input: List<String>): MutableSet<Pair<Int, Int>> { return input.flatMap { line -> line.split(" -> ") .map { it.split(",").let { (x, y) -> x.toInt() to y.toInt() } } .windowed(2, 1) ...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
3,816
aoc-2022-kotlin
Apache License 2.0
src/Day01.kt
SerggioC
573,171,085
false
{"Kotlin": 8824}
fun main() { fun part1(input: List<String>): Int { return input.size } // test if implementation meets criteria from the description, like: val input: List<String> = readInput("Day01") val indexes = mutableListOf<Int>() indexes.add(0) input.forEachIndexed { index, s -> ...
0
Kotlin
0
0
d56fb119196e2617868c248ae48dcde315e5a0b3
1,076
aoc-2022
Apache License 2.0
src/Day08.kt
cagriyildirimR
572,811,424
false
{"Kotlin": 34697}
import kotlin.math.max fun day08Part1(){ val input = readInput("Day08") var result = input.first().length * 4 - 4 println(input) for (i in 1 until input.lastIndex){ for (j in 1 until input.lastIndex) { if (visible(input[i], j)) { result++ // println(...
0
Kotlin
0
0
343efa0fb8ee76b7b2530269bd986e6171d8bb68
2,066
AoC
Apache License 2.0
src/main/kotlin/monster/1-binary-search.kt
dzca
581,929,762
false
{"Kotlin": 75573}
package monster /** * utility */ class ArrayConverter<T,V> { /** * covert each item T in source into array Type V */ fun map(a: Array<T>, fn: (T) -> V): List<V>{ return a.map(fn) } } fun intsToBools(a: Array<Int>): Array<Boolean>{ val c = ArrayConverter<Int, Boolean>() val b = ...
0
Kotlin
0
0
b1e7d1cb739e21ed7e8b7484d6efcd576857830f
3,575
kotlin-algrithm
MIT License
src/main/kotlin/com/tonnoz/adventofcode23/day13/Day13.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day13 import com.tonnoz.adventofcode23.utils.* import kotlin.math.min import kotlin.system.measureTimeMillis object Day13 { @JvmStatic fun main(args: Array<String>) { val input = "input13.txt".readInputSpaceDelimited() val time = measureTimeMillis { input.map { Mir...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,730
adventofcode23
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-10.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2016 fun main() { println("Part1:") println(part1(testInput1, 2, 5)) println(part1(input, 17, 61)) } private fun part1(input: String, v1: Int, v2: Int): Pair<String, Int> { val bots = mutableMapOf<String, Bot>() val instructions = mutableMapOf<String, Bo...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
13,053
advent-of-code
MIT License
src/main/kotlin/dayfive/DayFive.kt
pauliancu97
619,525,509
false
null
package dayfive import getLines typealias State = MutableList<MutableList<Char>> private data class Instruction( val quantity: Int, val source: Int, val destination: Int ) { companion object { private val REGEX = """move (\d+) from (\d+) to (\d+)""".toRegex() fun fromString(string: S...
0
Kotlin
0
0
78af929252f094a34fe7989984a30724fdb81498
2,499
advent-of-code-2022
MIT License
src/main/kotlin/day01/day02.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day01 import readInput import java.util.PriorityQueue fun main() { fun part1(input: List<String>): Int { return input.fold(0 to 0) { acc, v -> if (v.isEmpty()) { maxOf(acc.first, acc.second) to 0 } else { acc.first to acc.second + v.toInt() ...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
1,080
aoc2022
Apache License 2.0
src/Day05.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File fun main() { fun maakAntwoordString(stapelLijst: List<ArrayDeque<Char>>): String { var eindString = "" for (stack in stapelLijst.asIterable()) { eindString += if (stack.isNotEmpty()) stack.last() else "" } return eindString } fun part1(file:...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
2,878
AoC2022
Apache License 2.0
src/Day10/Day10.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day10 import readInput fun main() { fun part1(input: List<String>): Int { val signals = mutableListOf<Int>() var x = 1 var cycle = 1 input.forEach { s -> if (s == "noop") { cycle++ } else { cycle++ if (...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
1,778
aoc-2022-in-kotlin
Apache License 2.0
bulb-switcher/Solution.kt
Javran
25,217,166
false
null
import java.lang.Math /* math problem in disguise. First we figure out what determines the end state of i-th bulb (1-based): take n = 5 as an example. 1st bulb is on because 1 has the only factor 1 2nd is off because 2 has two factors: 1,2 3rd is off because 3 has two factors: 1,3 4th: on, factors: 1,2,4 5th: off, f...
0
JavaScript
0
3
f3899fe1424d3cda72f44102bab6dd95a7c7a320
1,356
leetcode
MIT License
src/Day13.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.jsonArray fun main() { // ktlint-disable filename fun parseIntoQueue(line: String): JsonArray { val jsonArray = Json.decodeFromString(JsonArray.serializer(), line) return jsonArray ...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,175
KotlinAdventOfCode2022
Apache License 2.0
src/dynamicprogramming/LongestIncreasingSubsequence.kt
faniabdullah
382,893,751
false
null
package dynamicprogramming class LongestIncreasingSubsequence { fun lis(intArray: IntArray): Int { val sizeTable = intArray.size val lookupTable = IntArray(sizeTable) { 1 } for (i in 1 until intArray.size) { for (j in 0 until i) { if (intArray[i] > intArray[j] ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
3,436
dsa-kotlin
MIT License
src/days/Day01/Day01.kt
SimaoMata
573,172,347
false
{"Kotlin": 3659}
package days.Day01 import readInput fun main() { // test if implementation meets criteria from the description, like: val inputPart1 = readInput("Day01") println(part1(inputPart1)) val inputPart2 = readInput("Day01") println(part2(inputPart2)) } fun part1(input: String): Int { return getMaxC...
0
Kotlin
0
0
bc3ba76e725b02c893aacc033c99169d7a022614
935
advent-of-code-2022
Apache License 2.0
src/day_01/Day01.kt
BrumelisMartins
572,847,918
false
{"Kotlin": 32376}
package day_01 import readInput fun main() { fun getListOfCalories(input: List<String>): List<Int> { val listOfSums = arrayListOf<Int>() var sum = 0 input.forEach { if (it.isBlank()) { listOfSums.add(sum) sum = 0 return@forEach ...
0
Kotlin
0
0
3391b6df8f61d72272f07b89819c5b1c21d7806f
1,109
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CanBeValid.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,434
kotlab
Apache License 2.0
src/Lesson7StacksAndQueues/StoneWall.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Stack /** * 100/100 * @param H * @return */ fun solution(H: IntArray): Int { var blocks = 0 val stack: Stack<Int> = Stack<Int>() // main idea: need to use "stack" to check when we need a new block for (i in H.indices) { // step 1: "stack is not empty" AND "from high to ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,245
Codility-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CoinChange2.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,859
kotlab
Apache License 2.0
src/main/kotlin/org/sjoblomj/travellingantcolony/Bruteforcer.kt
sjoblomj
171,120,735
false
null
package org.sjoblomj.travellingantcolony import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.immutableListOf import kotlinx.collections.immutable.toImmutableList import org.sjoblomj.travellingantcolony.domain.Place import kotlin.math.sqrt typealias Places = ImmutableList<Place> fun...
0
Kotlin
0
0
ee8f36e3434f4076eebacfbab80a817b59e197ee
7,398
TravellingAntColony
MIT License
src/day1/Day01.kt
MatthewWaanders
573,356,006
false
null
package day1 import utils.readInput fun main() { val testInput = readInput("Day01_test", "day1") check(part1(testInput) == 24000) val input = readInput("Day01", "day1") println(part1(input)) println(part2(input)) } fun convertInputToCaloriesPerElf(input: List<String>) = input .fold(listOf(li...
0
Kotlin
0
0
f58c9377edbe6fc5d777fba55d07873aa7775f9f
772
aoc-2022
Apache License 2.0
kotlin/aoc2018/src/main/kotlin/Day11.kt
aochsner
160,386,044
false
null
class Day11 { fun part1(serialNumber: Int) : Pair<Int, Int> { val powerGrid = Array(300) { x -> Array(300) { y -> getPowerLevel(x+1, y+1, serialNumber) } } return findLargestSquare(powerGrid, 3).key } private fun findLargestSquare(powerGrid: A...
0
Kotlin
0
1
7c42ec9c20147c4be056d03e5a1492c137e63615
1,713
adventofcode2018
MIT License
leetcode/src/offer/middle/Offer56_2.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 56 - II. 数组中数字出现的次数 II // https://leetcode.cn/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/ println(singleNumber1(intArrayOf(1,1,1,-3,-2,-3,-3))) } fun singleNumber(nums: IntArray): Int { // 计算 nums 各个数字,在各个位上1的数量 // 如果某一位上1的数量,不能被3整除,说明这一位...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,352
kotlin-study
MIT License
src/day16/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day16 import java.io.File import java.lang.IllegalStateException import kotlin.math.max import kotlin.math.min data class Packet(val length: Int, val versionSum: Int, val value: Long) data class Literal(val length: Int, val value: Long) data class Bits(val input: String) { private var index = 0 priva...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
2,791
advent-of-code-2021
MIT License
advent2021/src/main/kotlin/year2021/day05/Line.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2021.day05 import kotlin.math.max import kotlin.math.min sealed class Line( val from: Point, val to: Point ) { constructor(string: String) : this(Point(string.split("->")[0]), Point(string.split("->")[1])) abstract val points: Set<Point> protected val minX get() = min(from.x, ...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,653
advent-of-code
Apache License 2.0
src/main/kotlin/coursera/algorithms1/week1/assignments/interview/UnionFindWithSpecificCanonicalElement.kt
rupeshsasne
359,696,544
false
null
package coursera.algorithms1.week1.assignments.interview class UnionFindWithSpecificCanonicalElement(n: Int) { private val ids = IntArray(n) { it } private val largestValueAt = IntArray(n) { it } private val size = IntArray(n) { 1 } private fun root(p: Int): Int { var trav = p while (...
0
Kotlin
0
0
e5a9b1f2d1c497ad7925fb38d9e4fc471688298b
1,213
algorithms-sedgewick-wayne
MIT License
Kotlin/src/main/kotlin/org/algorithm/problems/0023_redundant_connection.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
//Problem Statement // // In this problem, a tree is an undirected graph that is connected and has no cycles. // The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), // with one additional edge added. The added edge has two different vertices chosen // from 1 to N, and was...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
1,727
algorithms
MIT License
word-generator/src/main/kotlin/com/github/pjozsef/wordgenerator/WordGenerator.kt
pjozsef
248,344,539
false
null
package com.github.pjozsef.wordgenerator import com.github.pjozsef.wordgenerator.rule.* import java.util.Random fun generateWord( expression: String, mappings: Map<String, List<String>>, random: Random, rules: List<Rule> = listOf(SubstitutionRule(), InlineSubstitutionRule(), MarkovRule(), ReferenceRul...
23
Kotlin
0
0
10a40fd61b18b5baf1723fc3b28c6205b7af30cb
1,963
word-generator
MIT License
2022/src/main/kotlin/Day03.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day03 { fun part1(input: String): Int { return input .splitNewlines() .map { line -> line.chunked(line.length / 2) } .map { sacks -> sacks.findCommonItem() } .sumOf { it.priority } } fun part2(input: String): Int { return input .splitNewlines() .chunked(3) ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
664
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestVariance.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,692
kotlab
Apache License 2.0
src/Day06.kt
cgeesink
573,018,348
false
{"Kotlin": 10745}
fun main() { fun CharSequence.isUnique() = toSet().count() == length fun solve(input: String, windowSize: Int): Int { return input .windowedSequence(windowSize) { it.isUnique() }.indexOf(true) + windowSize } val testInput = readInput("Day06_test") c...
0
Kotlin
0
0
137fb9a9561f5cbc358b7cfbdaf5562c20d6b10d
821
aoc-2022-in-kotlin
Apache License 2.0
scout/measures/jvm-benchmarks/src/main/kotlin/scout/benchmark/platform/ResultComparer.kt
yandex
698,181,481
false
{"Kotlin": 369096, "Shell": 1596}
/* * Copyright 2023 Yandex LLC * * 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 wr...
2
Kotlin
4
87
4a49d143be5d92184bf4bfc540f1e192344914d6
2,822
scout
Apache License 2.0
src/day08/Rope.kt
Frank112
572,910,492
false
null
package day08 import kotlin.math.abs data class Rope(val length: Int) { private var knots: MutableList<Position> = (0 until length).map { Position(0, 0) }.toMutableList() var tailPositionHistory: Set<Position> = setOf(knots.last()) fun handle(command: MoveCommand) { (1..command.count).forEach { ...
0
Kotlin
0
0
1e927c95191a154efc0fe91a7b89d8ff526125eb
2,282
advent-of-code-2022
Apache License 2.0
src/y2016/Day12.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.readInput data class MachineState( val instructions: MutableList<Instruction>, var instructionIdx: Int = 0, val registers: MutableMap<Char, Int> = mutableMapOf('a' to 0, 'b' to 0, 'c' to 0, 'd' to 0) ) { fun step() { instructions[instructionIdx].executeOn(this) } ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,240
advent-of-code
Apache License 2.0
src/main/kotlin/Algo.kt
YaroslavGamayunov
321,353,612
false
null
import kotlinx.serialization.Serializable @Serializable data class EarleyRule(val leftPart: Char, val rightPart: String, val dotPosition: Int) { fun getNextSymbol() = rightPart.getOrNull(dotPosition) fun isComplete() = dotPosition == rightPart.length } @Serializable data class Situation(val rule: EarleyRule,...
0
Kotlin
0
0
15ca19370d0de9a060fc8881988900b25e126782
3,335
GrammarAnalyzer
MIT License
src/main/kotlin/dp/RingDing.kt
yx-z
106,589,674
false
null
package dp import util.* import kotlin.math.abs // given an array A[1..n], containing either < 0, 0, or > 0 ints, // you traverse A from 1 to n (left to right) // at each index i, you may decide to say either Ring or Ding // if you say Ring, you will earn A[i] points, and if A[i] is negative, you // actually lose -...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
3,302
AlgoKt
MIT License
src/main/java/aoc_2019/Day03.kt
frenchfrie
161,678,638
false
{"Java": 64581, "Kotlin": 12191}
package aoc_2019 import org.slf4j.LoggerFactory import java.lang.IllegalStateException import kotlin.math.max import kotlin.math.min class Day03 { private val log = LoggerFactory.getLogger(javaClass) fun distanceFromClosestIntersection(coordinates: String): Int { val lineRaw = coordinates.split("\n")...
2
Java
0
0
b21c991277ce8ae76338620c7002699fb8279f75
4,320
advent-of-code
Apache License 2.0
src/test/kotlin/com/winterbe/kotlin/sequences/AdvancedExamples.kt
winterbe
141,977,205
false
null
package com.winterbe.kotlin.sequences import org.junit.Test class AdvancedExamples { data class Person(val name: String, val age: Int) private val persons = listOf( Person("Peter", 16), Person("Anna", 28), Person("Anna", 23), Person("Sonya", 39) ) @Test fun `redu...
0
Kotlin
6
15
69a232febc1bddca0454e21cae5303f896b3a41d
3,406
kotlin-examples
MIT License
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day05.kt
triozer
573,964,813
false
{"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716}
package fr.triozer.aoc.y2022 import fr.triozer.aoc.utils.readInput // #region other-container private class Container { var stacks: MutableMap<Int, ArrayDeque<Char>> = mutableMapOf() fun add(index: Int, char: Char) { if (!stacks.containsKey(index)) stacks[index] = ArrayDeque() stacks[index]!!...
0
Kotlin
0
1
a9f47fa0f749a40e9667295ea8a4023045793ac1
2,929
advent-of-code
Apache License 2.0
src/main/aoc2015/Day16.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 class Day16(input: List<String>) { private val realSue = """ children: 3 cats: 7 samoyeds: 2 pomeranians: 3 akitas: 0 vizslas: 0 goldfish: 5 trees: 3 cars: 2 perfumes: 1 """.trimIndent().split("\n").associate { lin...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,703
aoc
MIT License
src/Day19.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
private enum class Mineral { ORE, CLAY, OBSIDIAN, GEODE } private enum class MiningRobot { ORE_ROBOT, CLAY_ROBOT, OBSIDIAN_ROBOT, GEODE_ROBOT } fun main() { data class Cost( val oreCount: Int = 0, val clayCount: Int = 0, val obsidianCount: Int = 0, val geodeCount: Int = 0, ...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
6,490
aoc2022
Apache License 2.0
aoc16/day_08/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File fun print_display(display: Array<Array<Boolean>>) = display.forEach { it.forEach { print(if (it) '#' else '.') }; println() } fun main() { val instructions = File("input").readLines() val display = Array(6) { Array(50) { false } } for (inst in instructions) { if (inst.star...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,496
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/dp/LCS.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,163
kotlab
Apache License 2.0
advent-of-code-2022/src/test/kotlin/Day 24 Blizzard Basin.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test class `Day 24 B<NAME>` { private fun Point.neighbors(): List<Point> = listOf(up(), down(), left(), right()) data class State( val steps: Int, val blizzards: List<Pair<Point, Char>>, val pos: Set<Point>, ) @Test fun silverT...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
3,378
advent-of-code
MIT License
src/main/kotlin/github/walkmansit/aoc2020/Day13.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 import kotlin.math.ceil class Day13(val input: List<String>) : DayAoc<Int, Long> { private class BusSchedule(val earliestTime: Int, val busTs: Collection<Int>) { fun findEarliest(): Int { var minDt = Int.MAX_VALUE var id = 0 for (ts...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
4,270
AdventOfCode2020
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day23.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import at.mpichler.aoc.lib.Vector2i import at.mpichler.aoc.lib.moves open class Part23A : PartSolution() { private lateinit var elves: MutableMap<Vector2i, Elf> var numRounds = 0 override fun...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
4,069
advent-of-code-kotlin
MIT License
src/main/kotlin/dev/claudio/adventofcode2022/Day2Part2.kt
ClaudioConsolmagno
572,915,041
false
{"Kotlin": 41573}
package dev.claudio.adventofcode2022 fun main() { Day2Part2().main() } private class Day2Part2 { fun main() { val inputList: List<String> = Support.readFileAsListString("2022/day2-input.txt") val sumOf = inputList.map { Round(it.split(" ")[0], it.split(" ")[1]) } .map { println(it....
0
Kotlin
0
0
43e3f1395073f579137441f41cd5a63316aa0df8
1,509
adventofcode-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-12.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.CharGrid import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.filterIn import com.github.ferinagy.adventOfCode.get import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adven...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,194
advent-of-code
MIT License
functional-kotlin-basics-solution/src/main/kotlin/ch/sbb/functionalkotlin/basics/Recursion.kt
burriad
299,246,489
false
null
package ch.sbb.functionalkotlin.basics // 2.1 Given the function prepend, write a recursive function concat that concatenates a list of chars to a string fun prepend(c: Char, s: String): String = "$c$s" fun concat(chars: List<Char>): String = if (chars.isEmpty()) "" else prepend(chars.first(), concat(chars.ta...
0
Kotlin
0
0
d27e471737c66bde80c15da29083654cf6c49a69
1,612
functional-kotlin
Apache License 2.0
src/Day03.kt
zhtk
579,137,192
false
{"Kotlin": 9893}
fun main() { val input = readInput("Day03") input.sumOf { val firstCompartment = it.substring(0, it.length / 2).toSet() val secondCompartment = it.substring(it.length / 2, it.length).toSet() val itemInBothCompartments = firstCompartment.find { secondCompartment.contains(it) }!! g...
0
Kotlin
0
0
bb498e93f9c1dd2cdd5699faa2736c2b359cc9f1
627
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestMerge.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,350
kotlab
Apache License 2.0
src/main/kotlin/sschr15/aocsolutions/Day16.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* /** * AOC 2023 [Day 16](https://adventofcode.com/2023/day/16) * Challenge: We got lasers! (and a sixth grid this year what the heck) but how much energy is it really? */ object Day16 : Challenge { @ReflectivelyUsed override fun solve() = chall...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
3,952
advent-of-code
MIT License
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day10/Day10.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * 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 wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,345
AdventOfCode
Apache License 2.0
module-tool/src/main/kotlin/de/twomartens/adventofcode/day10/graph/GraphWalker.kt
2martens
729,312,999
false
{"Kotlin": 89431}
package de.twomartens.adventofcode.day10.graph import de.twomartens.adventofcode.day10.node.* import mu.KotlinLogging class GraphWalker { fun findFurthestDistance(graph: Graph): Int { val startNode = findStartNode(graph) val (_, _, distance) = findLoop(startNode, graph) return distance ...
0
Kotlin
0
0
03a9f7a6c4e0bdf73f0c663ff54e01daf12a9762
6,651
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/Combinations.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
1,423
kotlab
Apache License 2.0
src/Day06.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
fun main() { fun _process(input: List<String>, distinctCount: Int): Int { val l = input.first().toList() l.forEachIndexed { i, c -> val mem = l.subList(i, i + distinctCount) if (mem.distinct().size == distinctCount) { return(i + distinctCount) } ...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
797
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/github/marcospereira/Day2.kt
marcospereira
50,556,652
false
null
package com.github.marcospereira /** * ## Day 2: I Was Told There Would Be No Math * * The elves are running low on wrapping paper, and so they need to submit an * order for more. They have a list of the dimensions (length `l`, width `w`, * and height `h`) of each present, and only want to order exactly as much a...
0
Kotlin
3
2
4fed029837d87d81c833f2ad0273656b366d42ae
3,393
AdventOfCodeKotlin
MIT License
src/main/kotlin/com/ginsberg/advent2022/Day17.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 17 - Pyroclastic Flow * Problem Description: http://adventofcode.com/2022/day/17 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day17/ */ package com.ginsberg.advent2022 import kotlin.math.absoluteValue class Day17(...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
4,225
advent-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/RegularExpressionMatching.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,187
kotlab
Apache License 2.0
src/2022/Day13.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2022` import java.io.File import java.lang.Math.min import java.util.* import kotlin.math.max fun main() { Day13().solve() } class Day13 { val input1 = """ [1,1,3,1,1] [1,1,5,1,1] [[1],[2,3,4]] [[1],4] [9] [[8,7,6]] [[4,4],4,4] [[4...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
3,200
advent-of-code
Apache License 2.0
src/Day05.kt
ChristianNavolskyi
573,154,881
false
{"Kotlin": 29804}
class Day05 : Challenge<String> { override val name: String get() = "Day 05" override fun inputName(): String = "Day05" override fun testInputName(): String = "Day05_test" override fun testResult1(): String = "CMZ" override fun testResult2(): String = "MCD" override fun part1(input:...
0
Kotlin
0
0
222e25771039bdc5b447bf90583214bf26ced417
3,099
advent-of-code-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/BullsAndCows.kt
faniabdullah
382,893,751
false
null
//You are playing the Bulls and Cows game with your friend. // // You write down a secret number and ask your friend to guess what the number //is. When your friend makes a guess, you provide a hint with the following info: // // // The number of "bulls", which are digits in the guess that are in the correct //posi...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,713
dsa-kotlin
MIT License
src/main/kotlin/pl/jpodeszwik/aoc2023/Day18.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Integer.parseInt import java.util.* import kotlin.math.max import kotlin.math.min private fun part1(input: List<String>) { val digCoords = mutableSetOf<MapCoord>() var position = MapCoord(0, 0) var minRow = 0 var maxRow = 0 var minCol = 0 var max...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
2,099
advent-of-code
MIT License
src/Day01.kt
SekthDroid
573,039,827
false
{"Kotlin": 1566}
fun main() { fun parseCarriers(input: List<String>): List<List<Int>> { var current = mutableListOf<Int>() var carriers = emptyList<List<Int>>() for (each in input) { if (each.isBlank()) { carriers = carriers.plusElement(current) current = mutableL...
0
Kotlin
0
0
830dd6b7c783759b4a7172e6f71b66e0554019b3
929
aoc-2022
Apache License 2.0
app/src/main/kotlin/play.kt
Henrique-Castro
376,186,163
false
null
package mastermind import models.Code import models.ColorsEnum import models.Pin val ALPHABET_PAIRS = ColorsEnum.values().map { it.initial to it.name } val ALPHABET = ColorsEnum.values().map { it.initial } const val CODE_LENGTH = 4 fun main() { playMastermind() } fun playMastermind( secret: Code = generateS...
0
Kotlin
0
0
2bed4671a91e1beed5dddee3638d29799bfa7313
1,950
mastermind
MIT License
src/Day02.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
fun main() { val testInput = readInput("Day02_test") check(part1(testInput) == 15) check(part2(testInput) == 12) val input = readInput("Day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.sumOf(String::toScore) } private fun par...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
1,000
AOC2022
Apache License 2.0
src/Day02.kt
riegersan
572,637,157
false
{"Kotlin": 4377}
import kotlin.Exception fun main() { fun getPoints(e: Int, i: Int): Int { if(e == i){ //draw return i + 3 } if(e == 3){ if(i == 1){ return 7 } } if(e == 1){ if(i == 3){ return 3 } ...
0
Kotlin
0
0
d89439eb4d4d736d783c77cec873ac6e697e6ee9
2,215
advent-of-code-22-kotlin
Apache License 2.0
AOC-2017/src/main/kotlin/Day08.kt
sagar-viradiya
117,343,471
false
{"Kotlin": 72737}
import utils.dec import utils.inc import utils.splitAtNewLines import utils.splitAtWhiteSpace object Day08 { fun part1(input: String, trackHighestValue: Boolean = false) : Int { val valueMap = mutableMapOf<String, Int>() var highestValue: Int? = null input.splitAtNewLines().forEach { ...
0
Kotlin
0
0
7f88418f4eb5bb59a69333595dffa19bee270064
2,080
advent-of-code
MIT License
src/main/kotlin/leetcode/problem0123/BestTimeToBuyAndSellStock3.kt
ayukatawago
456,312,186
false
{"Kotlin": 266300, "Python": 1842}
package leetcode.problem0123 import java.lang.IllegalArgumentException import kotlin.math.max class BestTimeToBuyAndSellStock3 { fun maxProfit(prices: IntArray): Int { val dp: Map<Boolean, Array<IntArray>> = mapOf( true to Array(prices.size) { IntArray(MAX_PURCHASE_COUNT) { -1 ...
0
Kotlin
0
0
f9602f2560a6c9102728ccbc5c1ff8fa421341b8
1,566
leetcode-kotlin
MIT License
yandex/y2023/qual/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2023.qual private fun solve(): String { val (n, m) = readInts() data class Edge(val from: Int, val to: Int, val weight: Int) val edges = List(m) { val tokens = readStrings() val a = tokens[0].toInt() - 1 val b = tokens[1].toInt() val greater = (tokens[2][0] == '>') val value = tokens[3].to...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
763
competitions
The Unlicense
aoc_2023/src/main/kotlin/problems/day21/Garden.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day21 import problems.utils.Utils.Companion.transpose class Garden(lines: List<String>) { lateinit var startPos: Pair<Int, Int> var originalSize = Pair(lines.size, lines[0].length) var cells: List<List<GardenCell>> = lines.mapIndexed { i, line -> line.mapIndexed { j, char -> ...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
4,778
advent-of-code-2023
MIT License