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/structures/BinaryTree.kt
DmitryTsyvtsyn
418,166,620
false
{"Kotlin": 223256}
package structures /** * * data structure: binary tree * * description: consists of nodes, each of which has a maximum of two children, * child nodes satisfy the following requirements: * - the left child is less than the parent; * - right child is larger than parent; * * average search time: log(n) * wors...
0
Kotlin
135
767
7ec0bf4f7b3767e10b9863499be3b622a8f47a5f
6,792
Kotlin-Algorithms-and-Design-Patterns
MIT License
src/day21/Parser.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day21 import readInput import java.lang.IllegalArgumentException import java.util.regex.Pattern enum class Operation (val symbol: Char, val calc: (Long, Long) -> Long){ PLUS ('+', { a, b -> a + b}), MINUS ('-', { a, b -> a - b}), MULTIPLY ('*', { a, b -> a * b }), DIVIDE ('/', { a, b -> a / b}...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,270
advent_of_code_2022
Apache License 2.0
year2017/src/main/kotlin/net/olegg/aoc/year2017/day10/Day10.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day10 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2017.DayOf2017 /** * See [Year 2017, Day 10](https://adventofcode.com/2017/day/10) */ object Day10 : DayOf2017(10) { override fun first(): Any? { return data .parseInts...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,772
adventofcode
MIT License
src/day02/Day02.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day02 import readInput import utils.withStopwatch fun main() { val testInput = readInput("input02_test") withStopwatch { println(part1(testInput)) } withStopwatch { println(part2(testInput)) } val input = readInput("input02") withStopwatch { println(part1(input)) } withStopwatch { pri...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
1,122
advent-of-code-kotlin-2022
Apache License 2.0
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day25/Command.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day25 sealed class Command(val command: String) { val ascii = (command.trim() + "\n").map { it.toLong() } override fun toString() = command } sealed class Direction(val direction: String) : Command(direction) { abstract fun delta(): Pair<Int, Int> a...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
1,308
advent-of-code
Apache License 2.0
Kotlin for Java Developers. Week 4/Rationals/Task/src/rationals/Rational.kt
obarcelonap
374,972,699
false
null
package rationals import java.math.BigInteger data class Rational(val numerator: BigInteger, val denominator: BigInteger) : Comparable<Rational> { init { require(denominator != 0.toBigInteger()) { "Denominator can't be 0." } } companion object { fun sameDenominator(first: Rational, second...
0
Kotlin
0
0
d79103eeebcb4f1a7b345d29c0883b1eebe1d241
4,296
coursera-kotlin-for-java-developers
MIT License
2021/src/main/kotlin/day11_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.IntGrid import utils.Solution fun main() { Day11Fast.run() } object Day11All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day11Func, "imp" to Day11Imp, "fast" to Day11Fast).forEach { (header, solution) -> solution.run(header = header, skipPart1 = false, skipTest = false, pri...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,943
aoc_kotlin
MIT License
day22/Kotlin/day22.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* fun print_day_22() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 22" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime().exec("figlet Reactor Reboot -c -f small") v...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
4,382
AOC2021
Apache License 2.0
app/src/main/kotlin/de/tobiasdoetzer/aoc2021/Day4.kt
dobbsy
433,868,809
false
{"Kotlin": 13636}
package de.tobiasdoetzer.aoc2021 import java.lang.IllegalArgumentException import java.lang.IllegalStateException private fun main() { val input = readInput("day4_input.txt") val drawnNumbers = input[0].split(',').map(String::toInt) val boardsPart1 = mutableListOf<BingoBoard>() val boardsPart2 = muta...
0
Kotlin
0
0
28f57accccb98d8c2949171cd393669e67789d32
3,416
AdventOfCode2021
Apache License 2.0
shared/src/mobileMain/kotlin/org/jetbrains/kotlinconf/View.kt
JetBrains
108,403,211
false
{"Kotlin": 248479, "Ruby": 1705, "Swift": 783, "Shell": 226, "Procfile": 58}
package org.jetbrains.kotlinconf import io.ktor.util.date.GMTDate import org.jetbrains.kotlinconf.utils.dayAndMonth import org.jetbrains.kotlinconf.utils.time data class Agenda( val days: List<Day> = emptyList() ) data class Speakers( val all: List<Speaker> = emptyList() ) { private val dictById = all.as...
22
Kotlin
308
2,819
69909438506522b279d0771c8f47bdd69baf6c3c
3,221
kotlinconf-app
Apache License 2.0
src/main/kotlin/y2022/day04/Day04.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2022.day04 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } fun input(): List<Pair<IntRange, IntRange>> { return AoCGenerics.getInputLines("/y2022/day04/input.txt").map { line -> Pair( IntRange( line...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,214
AdventOfCode
MIT License
year2020/src/main/kotlin/net/olegg/aoc/year2020/day20/Day20.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day20 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 20](https://adventofcode.com/2020/day/20) */ object Day20 : DayOf2020(20) { private val NUMBER = "\\d+".toRegex() private const val SIZE = 12 private val MONSTER = """ ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
7,382
adventofcode
MIT License
src/Day01.kt
stephenkao
572,205,897
false
{"Kotlin": 14623}
fun main() { fun part1(input: List<String>): Int { var sum = 0 var max = 0 for (line in input) { if (line == "") { if (max < sum) { max = sum; } sum = 0; } else { sum += line.toInt()...
0
Kotlin
0
0
7a1156f10c1fef475320ca985badb4167f4116f1
1,151
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day05.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 open class Part5A : PartSolution() { protected lateinit var commands: List<Command> internal lateinit var towers: List<MutableList<Char>> override fun parseInput(text: String) { val ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,352
advent-of-code-kotlin
MIT License
src/Day01.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun List<String>.windowedSumCalories(): List<Int> = buildList { var sum = 0 for (calories in this@windowedSumCalories) { val cal = calories.toIntOrNull() if (cal != null) { sum += cal } else { add(sum) s...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
899
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day20_trench_map/TrenchMap.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day20_trench_map import geom2d.Point import geom2d.Rect import geom2d.asLinearOffset import geom2d.bounds /** * Image processing! Just as described. Sharpening, blurring, edge detection, et * all are all based on this sort of algorithm. Take a kernel from the input, do * a thing to create an output pixel, ...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,658
aoc-2021
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2187/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2187 /** * LeetCode page: [2187. Minimum Time to Complete Trips](https://leetcode.com/problems/minimum-time-to-complete-trips/); */ class Solution { /* Complexity: * Time O(N * Log(MK)) and Space O(1) where N is the size of time, M is totalTrips, * and K is the min...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,324
hj-leetcode-kotlin
Apache License 2.0
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day07.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-file private class File { val parent: File? val name: String val size: Int val isFolder: Boolean val children: MutableList<File> = mutableListOf() constructor(parent: File?, name: String, size: Int) { ...
0
Kotlin
0
1
a9f47fa0f749a40e9667295ea8a4023045793ac1
3,462
advent-of-code
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/collect/Lists.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.collect fun <T> List<T>.reverse(index: Int, length: Int) : List<T> { val copy = toMutableList() reverseMutable(copy, index, length); return copy } fun <T> List<T>.swap(a: Int, b: Int) : List<T> { val copy = toMutableList() swap(copy, a, b) return copy } ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,029
adventofcode
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem5/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem5 /** * LeetCode page: [5. Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/description/); */ class Solution2 { /* Complexity: * Time O(L^2) and Space O(L^2) where L is the length of s; */ fun longestPalindrome(s: Strin...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,213
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/io/github/raphaeltarita/days/Day14.kt
RaphaelTarita
433,468,222
false
{"Kotlin": 89687}
package io.github.raphaeltarita.days import io.github.raphaeltarita.structure.AoCDay import io.github.raphaeltarita.util.day import io.github.raphaeltarita.util.inputPath import io.github.raphaeltarita.util.splitAt import kotlinx.datetime.LocalDate import kotlin.io.path.readLines object Day14 : AoCDay { override ...
0
Kotlin
0
3
94ebe1428d8882d61b0463d1f2690348a047e9a1
2,786
AoC-2021
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12926.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12926 * * 시저 암호 * 문제 설명 * 어떤 문장의 각 알파벳을 일정한 거리만큼 밀어서 다른 알파벳으로 바꾸는 암호화 방식을 시저 암호라고 합니다. * 예를 들어 "AB"는 1만큼 밀면 "BC"가 되고, 3만큼 밀면 "DE"가 됩니다. * "z"는 1만큼 밀면 "a"가 됩니다. * 문자열 s와 거리 n을 입력받아 s를 n만큼 민 암호문을 만드는 함수, solut...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
2,702
HoOne
Apache License 2.0
src/Day01.kt
tigerxy
575,114,927
false
{"Kotlin": 21255}
fun main() { fun part1(input: List<String>): Int { var max = 0 var p = 0 input.forEach { val num = it.toIntOrNull() if (num == null) { if (p > max) { max = p } p = 0 } else { ...
0
Kotlin
0
1
d516a3b8516a37fbb261a551cffe44b939f81146
1,029
aoc-2022-in-kotlin
Apache License 2.0
src/main/java/io/github/lunarwatcher/aoc/day12/Day12.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day12 import io.github.lunarwatcher.aoc.commons.readFile import io.github.lunarwatcher.aoc.framework.Challenge import java.lang.UnsupportedOperationException data class Day12Data (val initialState: String, val modifiers: Map<String, Boolean>) class Day12 : Challenge<List<String>, D...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
2,401
AoC-2018
MIT License
src/week1/ContainsDuplicate.kt
anesabml
268,056,512
false
null
package week1 import kotlin.system.measureNanoTime class ContainsDuplicate { /** Brute force Linear search * Time complexity O(n2) * Space complexity O(1) */ fun containsDuplicate(nums: IntArray): Boolean { for (i in nums.indices) { for (j in 0 until i) { if...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
2,173
leetCode
Apache License 2.0
src/main/kotlin/wtf/log/xmas2021/day/day09/Day09.kt
damianw
434,043,459
false
{"Kotlin": 62890}
package wtf.log.xmas2021.day.day09 import wtf.log.xmas2021.Day import wtf.log.xmas2021.util.collect.Grid import wtf.log.xmas2021.util.collect.toGrid import java.io.BufferedReader object Day09 : Day<Grid<Int>, Int, Int> { override fun parseInput(reader: BufferedReader): Grid<Int> = reader .lineSequence() ...
0
Kotlin
0
0
1c4c12546ea3de0e7298c2771dc93e578f11a9c6
1,892
AdventOfKotlin2021
BSD Source Code Attribution
year2023/day03/part1/src/main/kotlin/com/curtislb/adventofcode/year2023/day03/part1/Year2023Day03Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 3: Gear Ratios --- You and the Elf eventually reach a gondola lift station; he says the gondola lift will take you up to the water source, but this is as far as he can bring you. You go inside. It doesn't take long to find the gondolas, but there seems to be a problem: they're not moving. "Aaah!" You tur...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,136
AdventOfCode
MIT License
src/main/kotlin/de/jball/aoc2022/day16/Day16.kt
fibsifan
573,189,295
false
{"Kotlin": 43681}
package de.jball.aoc2022.day16 import de.jball.aoc2022.Day class Day16(test: Boolean = false): Day<Int>(test, 1651, 1707) { private val valveRegex = "Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (\\w+(, \\w+)*)".toRegex() private val valves = input .map { line -> parseValve(line) } ...
0
Kotlin
0
3
a6d01b73aca9b54add4546664831baf889e064fb
7,438
aoc-2022
Apache License 2.0
src/main/kotlin/g2501_2600/s2542_maximum_subsequence_score/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2542_maximum_subsequence_score // #Medium #Array #Sorting #Greedy #Heap_Priority_Queue // #2023_07_04_Time_780_ms_(81.97%)_Space_56.7_MB_(99.45%) import java.util.Arrays import java.util.PriorityQueue class Solution { private class PairInfo(var val1: Int, var val2: Int) fun maxScore(nums...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,217
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/adventofcode/Day03.kt
keeferrourke
434,321,094
false
{"Kotlin": 15727, "Shell": 1301}
package com.adventofcode data class Diagnostic(val rowView: List<String>) { private val colView: List<String> by lazy { readColumns(rowView) } private fun readColumns(rows: List<String>): List<String> { val columns = mutableMapOf<Int, String>() for (row in rows) { for (j in row.indices) { co...
0
Kotlin
0
0
44677c6ae0ba1a8a8dc80dfa68c17b9c315af8e2
2,079
aoc2021
ISC License
src/Day03.kt
revseev
573,354,544
false
{"Kotlin": 9868}
fun main() { println(day3task1()) println(day3task2()) } fun day3task1(): Int { var sum = 0 readInputAsSequence("Day03") { sum = sumOf { findCommonCharCode(it) } } return sum } fun day3task2(): Int { var sum = 0 readInputAsSequence("Day03") { sum = chunked(3) { ...
0
Kotlin
0
0
df2e12287a30a3a7bd5a026a963bcac41a730232
1,552
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SpiralMatrix2.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,622
kotlab
Apache License 2.0
src/main/kotlin/days/aoc2015/Day18.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2015 import days.Day class Day18: Day(2015, 18) { override fun partOne(): Any { return performLife(inputList, 100).map { string -> string.count { it == '#' } }.sum() } fun performLife(inputList: List<String>, steps: Int): List<String> { var result = mut...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,573
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/2021/Day4.kt
mstar95
317,305,289
false
null
package `2021` import days.Day class Day4 : Day(4) { override fun partOne(): Any { val numbers: List<Int> = inputList.first().split(",").map { it.toInt() } val boards: List<Board> = createBoards(inputList.drop(2)) val bingo = mutableSetOf<Int>() val (wonBoard, wonNumber) = playBin...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
3,086
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day01.kt
icoffiel
572,651,851
false
{"Kotlin": 29350}
fun main() { fun parseToSums(input: String) = input .split("${System.lineSeparator()}${System.lineSeparator()}") .map { elf -> elf .lines() .sumOf { it.toInt() } } .sorted() fun part1(input: String): Int { return parseToSums(in...
0
Kotlin
0
0
515f5681c385f22efab5c711dc983e24157fc84f
859
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/sorting/crack/StreamRank.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.sorting val streamRank = StreamRank() for (value in intArrayOf(5, 1, 4, 4, 5, 9, 7, 13, 3)) { streamRank.track(value) } /* Tree: 5(5) 1(0) 9(1) 4(2) 7(0) 13(0) ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
3,018
KotlinAlgs
MIT License
data_structures/Graphs/graph/Kotlin/DjikstraAlgorithm.kt
ZoranPandovski
93,438,176
false
{"Jupyter Notebook": 21909905, "C++": 1692994, "Python": 1158220, "Java": 806066, "C": 560110, "JavaScript": 305918, "Go": 145277, "C#": 117882, "PHP": 85458, "Kotlin": 72238, "Rust": 53852, "Ruby": 43243, "MATLAB": 34672, "Swift": 31023, "Processing": 22089, "HTML": 18961, "Haskell": 14298, "Dart": 11842, "CSS": 10509...
import java.util.ArrayList import java.util.Collections import java.util.HashMap import java.util.HashSet import java.util.LinkedList import kotlin.test.assertNotNull import kotlin.test.assertTrue class DijkstraAlgorithm(graph: Graph) { private val nodes: List<Vertex> private val edges: List<Edge> private...
62
Jupyter Notebook
1,994
1,298
62a1a543b8f3e2ca1280bf50fc8a95896ef69d63
6,114
al-go-rithms
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/github/asher_stern/parser/cyk/CykAlgorithmWithHack.kt
asher-stern
109,838,279
false
null
package com.github.asher_stern.parser.cyk import com.github.asher_stern.parser.grammar.ChomskyNormalFormGrammar import com.github.asher_stern.parser.grammar.SyntacticItem import com.github.asher_stern.parser.tree.TreeNode import com.github.asher_stern.parser.utils.Array1 /** * Created by <NAME> on November-05 2017. ...
0
Kotlin
0
0
4d54f49eae47260a299ca375fc5442f002032116
3,178
parser
MIT License
src/day01/Day01.kt
RegBl
573,086,350
false
{"Kotlin": 11359}
package day01 import readInput fun main() { fun part1(input: List<Int>): Int { return input.last() } fun part2(input: List<Int>): Int { return input.sum() } fun splitByEmptyLine(input: List<String>): List<List<String>> { return input.fold(mutableListOf(mutableListOf<Strin...
0
Kotlin
0
0
bd45eb4378d057267823dcc72ad958492f7056ff
1,009
aoc-2022
Apache License 2.0
src/main/kotlin/org/wow/evaluation/transition/BestTransitionsFinder.kt
WonderBeat
22,673,830
false
null
package org.wow.evaluation.transition import org.wow.logger.GameTurn import org.wow.evaluation.Evaluator public data class PlayerGameTurn(val from: GameTurn, val to: GameTurn, val playerName: String) public class BestTransitionsFinder(val evaluator: ...
0
Kotlin
0
0
92625c1e4031ab4439f8d8a47cfeb107c5bd7e31
1,474
suchmarines
MIT License
src/main/kotlin/Day3_1.kt
vincent-mercier
726,287,758
false
{"Kotlin": 37963}
import java.io.File import java.io.InputStream import kotlin.streams.asSequence fun validInts(rowNb: Int, index: Int, matchResults: List<MatchResult>): List<Pair<Pair<Int, Int>, Int>> = matchResults .asSequence() .filter { it.range.contains(index) || index == it.rang...
0
Kotlin
0
0
53b5d0a0bb65a77deb5153c8a912d292c628e048
2,224
advent-of-code-2023
MIT License
src/twentytwentytwo/day10/Day10.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day10 import readInput import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { var cycleCount = 1 var x = 1 var total = 0 val specialCycles = mutableSetOf(20, 60, 100, 140, 180, 220) input.forEach { line -> var delta = 0...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,809
advent-of-code
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day12.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.* import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.zeros import org.jetbrains.kotlinx.multik.ndarray.data.D2Array import org.jetbrains.kotlinx.multik.ndarray.data.set open class Part12A : PartSolution() { priv...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,045
advent-of-code-kotlin
MIT License
src/Day01.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day01 : Runner<Int, Int>(1, 24000, 45000) { override fun part1(input: List<String>): Int = toCalorieMap(input).values.maxOf { it.sum() } override fun part2(input: List<String>): Int { val calories = toCalorieMap(input).values.map { it.sum() } .sortedByDescending { it } .t...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
879
advent-of-code-2022-kotlin
Apache License 2.0
src/Day05.kt
becsegal
573,649,289
false
{"Kotlin": 9779}
import java.io.File fun main() { var stacks: ArrayList<ArrayList<String?>> = ArrayList() var instructions: ArrayList<List<Int>> = ArrayList() fun initializeStackLine(row: List<String?>) { row.forEachIndexed { index, value -> if (stacks.size <= index) { stacks.add(Array...
0
Kotlin
0
0
a4b744a3e3c940c382aaa1d5f5c93ae0df124179
2,287
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Algorithm.kt
nkkarpov
605,326,618
false
null
import java.lang.Math.ceil import kotlin.math.floor import kotlin.math.max import kotlin.random.Random fun batchedSAR(env: Environment, m: Int, K: Int, budget: Int): List<Int> { val n = emptyList<Int>().toMutableList() val Q = mutableListOf<Int>() var I = (0 until env.n).toMutableList() val est = Doubl...
0
Kotlin
0
0
f0dd06b07bf9ebc5bc199c5280e63103189f5397
9,819
collab-comm
MIT License
year2022/src/cz/veleto/aoc/year2022/Day18.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos3 import cz.veleto.aoc.core.manhattanTo class Day18(config: Config) : AocDay(config) { override fun part1(): String { val cubes = parseCubes() return countExposedSides(cubes).toString() } overrid...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
3,742
advent-of-pavel
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2020/Day13.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.* import java.math.BigInteger /** * --- Day 13: --- * https://adventofcode.com/2020/day/13 */ class Day13 : Solver { override fun solve(lines: List<String>): Result { val earliestTime = lines[0].toLong() val busIds = lines[1].split(',').filter { it != "x" ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,178
euler
Apache License 2.0
complex-numbers/src/main/kotlin/ComplexNumbers.kt
3mtee
98,672,009
false
null
import kotlin.math.* data class ComplexNumber(val real: Double = 0.0, val imag: Double = 0.0) { val abs = sqrt(real * real + imag * imag) operator fun plus(other: ComplexNumber): ComplexNumber { return ComplexNumber(this.real + other.real, this.imag + other.imag) } operator fun minus(other: C...
0
Kotlin
0
0
6e3eb88cf58d7f01af2236e8d4727f3cd5840065
1,338
exercism-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem609/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem609 /** * LeetCode page: [609. Find Duplicate File in System](https://leetcode.com/problems/find-duplicate-file-in-system/); */ class Solution { /* Complexity: * Time O(NM) and Aux_Space O(NM) where N is size of paths and M is the average length of path; */ fun...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
3,939
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day21.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.ints import se.saidaspen.aoc.util.words fun main() { Day21.run() } object Day21 : Day(2015, 21) { data class Player(var hp: Int, val dmg : Int, val armor: Int) data class Object(val name: String, val cost: Int...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
3,794
adventofkotlin
MIT License
day02/kotlin/RJPlog/day02_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File fun cube(in1: Int): Int { var result = 0 File("day2302_puzzle_input.txt").forEachLine { var gamePossible = true var maxRed = 0 var maxGreen = 0 var maxBlue = 0 var instruction = it.split(": ") var game = instruction[0].substringAfter("Game ").toInt() var results = instruction[1].s...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
1,743
aoc-2023
MIT License
Kotlin/src/main/kotlin/StalinSort.kt
MeilCli
199,483,286
false
{"C#": 3661, "Kotlin": 1651, "Crystal": 1306}
fun main(args: Array<String>) { println("Hello Stalin!") writeStalinSort(intArrayOf(4)) writeStalinSort(intArrayOf(6, 2, 5, 7, 3, 8, 8, 4)) writeStalinSort(intArrayOf(5, 3, 7, 8, 9, 5, 3, 5, 7)) /** * Hello Stalin! * Input: 4 * StalinBy: 4 * StalinByDescending: 4 * Input: 6,...
0
C#
0
0
b245390a856850ca79470a6ad1b31c980465a68a
1,651
StalinSort
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/PerfectSquares.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
4,389
kotlab
Apache License 2.0
src/main/kotlin/me/circuitrcay/euler/challenges/oneToTwentyFive/Problem11.kt
adamint
134,989,381
false
null
package me.circuitrcay.euler.challenges.oneToTwentyFive import me.circuitrcay.euler.Problem class Problem11 : Problem<String>() { override fun calculate(): Any { val prompt = """08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31...
0
Kotlin
0
0
cebe96422207000718dbee46dce92fb332118665
3,366
project-euler-kotlin
Apache License 2.0
src/Day16.kt
dragere
440,914,403
false
{"Kotlin": 62581}
fun main() { class Packet(val s: String) { val version: Int = s.substring(0, 3).toInt(2) val type: Int = s.substring(3, 6).toInt(2) val subPackets: List<Packet> val value: Long val leftOver: String init { if (type != 4) { value = 0 ...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
4,400
advent_of_code21_kotlin
Apache License 2.0
src/main/kotlin/dev/schlaubi/aoc/days/Day2.kt
DRSchlaubi
573,014,474
false
{"Kotlin": 21541}
package dev.schlaubi.aoc.days import dev.schlaubi.aoc.SeparateDay import kotlin.io.path.readLines object Day2 : SeparateDay() { override val number: Int = 2 override fun task1(): Any { return input.readLines() .map { val (opponent, you) = it.split(" ") ...
1
Kotlin
0
4
4514e4ac86dd3ed480afa907d907e3ae26457bba
2,153
aoc-2022
MIT License
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day01/Trebuchet.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day01 class Trebuchet(private var filename: String) { private val words = listOf( Digit("zero", "0"), Digit("one", "1"), Digit("two", "2"), Digit("three", "3"), Digit("four", "4"), Digit("five", "5"), Digit("six", "6"), ...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
2,747
advent-of-code
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day16/Day16Puzzle.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day16 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver abstract class Day16Puzzle : PuzzleSolver { companion object { private val hexToBits = mapOf( '0' to "0000", '1' to "0001", '2' to "0010", ...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
3,426
AdventOfCode2021
Apache License 2.0
kotlin/2022/round-1b/3/src/main/kotlin/Solution.kt
ShreckYe
345,946,821
false
null
import kotlin.experimental.xor import kotlin.system.exitProcess fun main() { val equivalentClasses = findEquivalentClasses() val graph = buildGraph(equivalentClasses, getECIndexArray(equivalentClasses)) println(graph) val bests = computeBests(equivalentClasses, graph) println(bests) /*val t = ...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
2,947
google-code-jam
MIT License
kotlin/structures/HeavyLight.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures import java.util.ArrayList // Heavy-light decomposition with path queries. Query complexity is O(log^2(n)). // Based on the code from http://codeforces.com/blog/entry/22072 class HeavyLight(tree: Array<List<Integer>>, valuesOnVertices: Boolean) { var tree: Array<List<Integer>> var valuesOnV...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,434
codelibrary
The Unlicense
src/main/kotlin/Day11.kt
dlew
75,886,947
false
null
import java.util.* class Day11 { enum class Type { GENERATOR, MICROCHIP } enum class Element { HYDROGEN, LITHIUM, STRONTIUM, PLUTONIUM, THULIUM, RUTHENIUM, CURIUM, ELERIUM, DILITHIUM } data class Item(val type: Type, val element: Element) { override fun toSt...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
5,215
aoc-2016
MIT License
src/main/kotlin/com/rtarita/days/Day2.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 Day2 : AoCDay { private enum class Play(val opponentLetter: Char, val ownLetter: Char, val value: Int) { ROCK('X', 'A', 1), PAPER('Y', 'B', 2), SCISSORS('Z', 'C...
0
Kotlin
0
9
491923041fc7051f289775ac62ceadf50e2f0fbe
2,741
AoC-2022
Apache License 2.0
src/Day15.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
import kotlin.math.absoluteValue import kotlin.math.sign fun Point.manhattanDistance(other: Point) = (x - other.x).absoluteValue + (y - other.y).absoluteValue class Beacon(val location: Point) { val tuningFrequency = 4000000L * location.x + location.y override fun toString() = "Beacon(x=${location.x}, y=${lo...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
4,148
advent-of-code-2022
Apache License 2.0
src/main/kotlin/ca/kiaira/advent2023/day1/Day1.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day1 import ca.kiaira.advent2023.Puzzle /** * Day1 object represents the puzzle for Advent of Code Day 1. * It extends the Puzzle class with a list of strings as input data. * * @constructor Creates a Day1 object with the puzzle number 1. * * @author <NAME> * @since December 10th, ...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
1,895
kAdvent-2023
Apache License 2.0
src/main/kotlin/g1201_1300/s1219_path_with_maximum_gold/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1219_path_with_maximum_gold // #Medium #Array #Matrix #Backtracking #2023_06_09_Time_238_ms_(100.00%)_Space_34.3_MB_(100.00%) class Solution { private var maxGold = 0 fun getMaximumGold(grid: Array<IntArray>): Int { for (i in grid.indices) { for (j in grid[0].indices) {...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,735
LeetCode-in-Kotlin
MIT License
app/src/main/kotlin/com/resurtm/aoc2023/day15/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day15 fun launchDay15(testCase: String) { val input = readInput(testCase) println("Day 15, part 1: ${input.sumOf { calcHash(it) }}") println("Day 15, part 2: ${calcPart2(input)}") } private fun calcPart2(items: List<String>): Int { val boxes = mutableMapOf<Int, MutableList<...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
2,004
advent-of-code-2023
MIT License
src/main/kotlin/days/Day8.kt
mstar95
317,305,289
false
null
package days import arrow.core.Either import arrow.core.flatMap class Day8 : Day(8) { override fun partOne(): Any { // val instructions = inputList.map { it.split(" ") }.map { it[0] to it[1].toInt() } // println(instructions) // return Program(instructions).run() return 0; } ...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,427
aoc-2020
Creative Commons Zero v1.0 Universal
src/dynamicprogramming/MinimumPathSum.kt
faniabdullah
382,893,751
false
null
package dynamicprogramming class MinimumPathSum { fun minPathSum(grid: Array<IntArray>): Int { val m = grid.size val n = grid[0].size val dp = Array(m) { Array(n) { 0 } } for (i in 0 until m) { for (j in 0 until n) { if (i == 0 && j == 0) { ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
966
dsa-kotlin
MIT License
src/day02/Day02.kt
molundb
573,623,136
false
{"Kotlin": 26868}
package day02 import readInput fun main () { val input = readInput(parent = "src/Day02", name = "Day02_input") println(solvePartOne(input)) println(solvePartTwo(input)) } private fun solvePartOne(input: List<String>): Int { val combinations = mapOf( Pair("A X", 4), Pair("A Y", 8), ...
0
Kotlin
0
0
a4b279bf4190f028fe6bea395caadfbd571288d5
1,033
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/medium/UniquePaths.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 62. 不同路径 * * 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。 * * 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。 * 问总共有多少条不同的路径? */ class UniquePaths { companion object { @JvmStatic fun main(args: Array<String>) { println(Uniqu...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,330
daily_algorithm
Apache License 2.0
03/kotlin.kts
mwangel
439,392,005
false
{"Groovy": 84890, "Kotlin": 4809, "Python": 764}
var map:List<BooleanArray> = mutableListOf() // START: Load the data. java.io.File("data.txt").forEachLine { line:String -> if( line.length > 0 ) { //var row = BooleanArray( line.length ) { i:Int -> (line.getAt(i) == '#' ? 1 : 0) } // TRUE for TREES! val row = line.map { it == '#' } map.add( row ) } } /**...
0
Groovy
0
0
2ba859eda97bdf8ff16fd20afdc4ec2c253eab04
1,336
advent-of-code-2021
The Unlicense
aoc_2023/src/main/kotlin/problems/day17/CrucibleSearch.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day17 import java.util.* open class CrucibleSearch(val city: CrucibleCity) { fun minimumHeastLoss(): Int { val node1 = CrucibleNode(0, 1, city.grid[0][1], hCost(0, 1), EastCrucibleDir.getInstance(), null) val node2 = CrucibleNode(1, 0, city.grid[1][0], hCost(1, 0), SouthCrucible...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
2,274
advent-of-code-2023
MIT License
2023/src/main/kotlin/org/suggs/adventofcode/Day07CamelCards.kt
suggitpe
321,028,552
false
{"Kotlin": 156836}
package org.suggs.adventofcode import org.slf4j.LoggerFactory object Day07CamelCards { private val log = LoggerFactory.getLogger(this::class.java) private val typeValues = Type.entries.reversed().mapIndexed { idx, type -> Pair(type, idx) }.toMap() private val cardValues = "AKQJT98765432".reversed().mapIn...
0
Kotlin
0
0
9485010cc0ca6e9dff447006d3414cf1709e279e
4,442
advent-of-code
Apache License 2.0
2022/05/05.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
fun solve(input: String, moveTogether: Boolean) { val (raw_towers, moves) = input.split("\n\n") val towers = raw_towers.split("\n").dropLast(1).asReversed() val stacks: MutableList<MutableList<Char>> = mutableListOf() for (j in 1 until towers[0].length step 4) { stacks.add(mutableListOf()) ...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
1,202
adventofcode
Apache License 2.0
src/week1/ProductExceptSelf.kt
anesabml
268,056,512
false
null
package week1 import kotlin.system.measureNanoTime class ProductExceptSelf { /** Brute force * Iterate over the array and calculate the multiply result * Time complexity : O(n2) * Space complexity : O(n) */ fun productExceptSelf(nums: IntArray): IntArray { val output = IntArray(nu...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
2,871
leetCode
Apache License 2.0
src/main/kotlin/aoc2023/Day16.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import Point import readInput import to2dCharArray import java.util.* import kotlin.math.max object Day16 { private enum class Direction { TOP, BOTTOM, LEFT, RIGHT } private data class Movement(val comingFrom: Direction, val position: Point) private class ContraptionGrid(input: List<Stri...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,283
adventOfCode
Apache License 2.0
kotlin-practice/src/main/kotlin/algorithms/old/WordsCount.kt
nicolegeorgieva
590,020,790
false
{"Kotlin": 120359}
package algorithms.old fun main() { val text = "Hi, I'm Nicole. I've been diving deep into Software Development for about 2 years, particularly into " + "Android Development with Kotlin and Jetpack Compose. I'm proficient in mobile UI/UX and have worked on " + "projects related to productiv...
0
Kotlin
0
1
c96a0234cc467dfaee258bdea8ddc743627e2e20
1,892
kotlin-practice
MIT License
src/commonMain/kotlin/net/dinkla/raytracer/math/Polynomials.kt
jdinkla
38,753,756
false
{"Kotlin": 467610, "Shell": 457}
package net.dinkla.raytracer.math import kotlin.math.acos import kotlin.math.cos import kotlin.math.pow import kotlin.math.sqrt object Polynomials { private fun cbrt(d: Double) = if (d < 0.0) { -(-d).pow(1.0 / 3.0) } else { d.pow(1.0 / 3.0) } fun solveCubic(c: DoubleArray, s: DoubleA...
0
Kotlin
2
5
72ca9b79eb22d9e4f6b7ccfb896427966c20e934
5,340
from-the-ground-up-ray-tracer
Apache License 2.0
src/main/kotlin/Day07.kt
akowal
434,506,777
false
{"Kotlin": 30540}
import kotlin.math.abs fun main() { println(Day07.solvePart1()) println(Day07.solvePart2()) } object Day07 { private val positions = readInput("day07") .single() .toIntArray() .sorted() fun solvePart1(): Int { val median = positions.run { (get(size / 2) + get(size / 2 ...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
696
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
2021/src/day23/Day23.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day23 import readInput import java.text.SimpleDateFormat import java.util.* import kotlin.IllegalStateException import kotlin.math.abs fun List<String>.toAmphipods() : List<Amphipod> { val amphipods = mutableListOf<Amphipod>() for (y in this.indices) { for (x in this[y].indices) { ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
7,101
advent-of-code
Apache License 2.0
src/Day01.kt
driuft
575,221,823
false
{"Kotlin": 1745}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { val inputList = input.map { it.toIntOrNull() } var currMax = 0 var result = 0 for (calories in inputList) { if (calories == null) { currMax = 0 } else { ...
0
Kotlin
0
0
29ec6bf674834dbd0e3b80eb7e439e541a274ec6
1,090
2022-advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day03.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 fun main() { val itemTypeToPriority = CharRange('a', 'z').toList().plus(CharRange('A', 'Z')).zip(IntRange(1, 52).toList()).toMap() fun part1(input: List<String>): Int = input.sumOf { itemTypeToPriority[ it.slice(0 until it.length / 2).toSe...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
925
advent-of-code
Apache License 2.0
kotlin/2022/day05/Day05.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
class Day05 { interface Rule {} interface Location: Rule { val marker: Char } data class Empty( override val marker: Char = ' ' ): Location data class Crate( override val marker: Char ): Location data class Row( val locations: List<Location> ): Rule data class Move( val cou...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
3,947
adventofcode
MIT License
kotlin/src/main/kotlin/adventofcode/day9/Day9_2.kt
thelastnode
160,586,229
false
null
package adventofcode.day8 object Day9_2 { data class Marble(val value: Int, var prev: Marble?, var next: Marble?) { fun insertAfter(n: Int) { if (this.prev == this) { val newMarble = Marble(n, this, this) this.prev = newMarble this.next = newMarb...
0
Kotlin
0
0
8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa
2,946
adventofcode
MIT License
src/main/kotlin/tree/bintree/MinAwkward.kt
yx-z
106,589,674
false
null
package tree.bintree import util.* // given a binary tree representing company hierarchy, with each edge containing // a number, either positive, 0, or negative, also remembering that // there is an edge between two nodes iff. one is a direct parent of the other // find a subset of exactly k nodes with the smallest ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,885
AlgoKt
MIT License
src/test/kotlin/io/noobymatze/aoc/y2022/Day17.kt
noobymatze
572,677,383
false
{"Kotlin": 90710}
package io.noobymatze.aoc.y2022 import io.noobymatze.aoc.Aoc import kotlin.math.abs import kotlin.test.Test class Day17 { data class Pos(val row: Int, val col: Int) { val up get() = Pos(row - 1, col) val down get() = Pos(row + 1, col) // I know, this is a bit dirty operator fun p...
0
Kotlin
0
0
da4b9d894acf04eb653dafb81a5ed3802a305901
4,664
aoc
MIT License
src/aoc22/Day21.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day21 import kotlin.math.sign import lib.Solution import lib.Strings.isLong enum class Operation(val symbol: String, val op: (Long, Long) -> Long) { ADD("+", Long::plus), SUBTRACT("-", Long::minus), MULTIPLY("*", Long::times), DIVIDE("/", Long::div), ...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
3,886
aoc-kotlin
Apache License 2.0
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day03/EngineSchematic.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day03 import de.havox_design.aoc.utils.kotlin.model.positions.Position2d import java.lang.IllegalArgumentException class EngineSchematic(input: List<String>) { private val schematic = ArrayList<List<Point>>() private val partNumbers = HashSet<PartNumber>() private val gears...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
4,732
advent-of-code
Apache License 2.0
src/main/kotlin/Problem17.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.floor /** * Number letter counts * * If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 * letters used in total. * * If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be u...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
2,159
project-euler
MIT License
src/main/kotlin/day18/CoolPair.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day18 import kotlin.math.ceil import kotlin.math.floor data class CoolPair(var left: PairComponent, var right: PairComponent) : PairComponent { operator fun plus(other: CoolPair): CoolPair { val newPair = CoolPair(this, other) reduce(newPair) return newPair } fun explode...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
3,735
aoc2021
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfCommonFactors.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,065
kotlab
Apache License 2.0
src/main/kotlin/hm/binkley/dice/rolling/KeepCount.kt
binkley
259,950,798
false
{"Kotlin": 89213, "Shell": 15649, "Batchfile": 9453}
package hm.binkley.dice.rolling import java.util.Objects.hash sealed class KeepCount(protected val value: Int) { override fun toString() = "${this::class.simpleName}($value)" override fun equals(other: Any?) = this === other || other is KeepCount && javaClass == other.javaClass && val...
12
Kotlin
0
0
072d4cb675862a79616d2dea3149a2b3794d2737
3,352
kotlin-dice
The Unlicense
leetcode/src/offer/middle/Offer12.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { val i:Int i=30 println(i) // 剑指 Offer 12. 矩阵中的路径 // https://leetcode.cn/problems/ju-zhen-zhong-de-lu-jing-lcof/ val ca1 = charArrayOf('A', 'B', 'C', 'E') val ca2 = charArrayOf('S', 'F', 'C', 'S') val ca3 = charArrayOf('A', 'D', 'E', 'E') val board =...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,257
kotlin-study
MIT License
src/net/sheltem/aoc/y2022/Day15.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 import kotlin.math.absoluteValue suspend fun main() { Day15().run() } class Day15 : Day<Long>(0, 24) { override suspend fun part1(input: List<String>): Long = input.map { it.toSensorAndBeacon() }.toCaveMap(2000000).countInRow(2000000).toLong() override suspend fun part2(i...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
3,455
aoc
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2022/Day23.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.Point import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day23.Direction.* import ru.timakden.aoc.year2022.Day23.Elf.Companion.fillProposedPositions import ru.timakden.aoc.year2022.Day23.Elf.Companion.mo...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
5,332
advent-of-code
MIT License
kotlin/src/com/daily/algothrim/leetcode/CountNodes.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import java.util.* /** * 222. 完全二叉树的节点个数 * * 给出一个完全二叉树,求出该树的节点个数。 * * 说明: * 完全二叉树的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层,则该层包含 1~ 2h 个节点。 * */ class CountNodes { companion object { @JvmStatic fun main(args: Array<St...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,999
daily_algorithm
Apache License 2.0
src/Day17_2.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import java.io.File import kotlin.math.max fun main() { fun Pair<Long, Long>.x(): Long{ return this.first } fun Pair<Long, Long>.y(): Long{ return this.second } class Shape(var points: MutableList<Pair<Long, Long>>){} fun Shape.rightmost(): Long{ return this.points.m...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
10,074
aoc22
Apache License 2.0
src/Day08.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun part1(input: List<String>): Int { val forest = input.map { it.chunked(1).map { it.toInt() } } // val forest2 = input.map { it.map { it.digitToInt() } } println(forest) val visible = mutableSetOf<Pair<Int, Int>>() val width = forest[0].size val height = forest.size //outsi...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
3,256
AdventOfCode2022
Apache License 2.0
advent-of-code-2022/src/test/kotlin/Day 11 Monkey in the Middle.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.collections.shouldStartWith import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test /** 15:15 */ class `Day 11 Monkey in the Middle` { @Test fun parsing() { parse(testInput) shouldStartWith Monkey( items = listOf(79.toLong(), 98.toLong()), ...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
5,338
advent-of-code
MIT License