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/Day04.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
fun main() { val input = readInput("day4_input") println(part2(input)) } fun part1(input: List<String>): Int { return input.map { it.split(",", "-").map { it.toInt() } }.count { val (first, second, third, fourth) = it println("first $first second $second third $third fourth $fourth") ...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
1,724
advent22
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day19.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.automation.extractAllIntegers enum class Category(name: String) { X("Extremely cool looking"), M("Musical"), A("Aerodynamic"), S("Shiny") } typealias PotentialPart = Map<Category, IntRang...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
5,385
advent-of-code-2023
Apache License 2.0
src/day09/Day09.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day09 import readInput import kotlin.math.absoluteValue import kotlin.math.sign data class Position(val x: Int, val y: Int) { fun move(direction: Char): Position { return when (direction) { 'U' -> Position(x, y + 1) 'D' -> Position(x, y - 1) 'R' -> Position(x + ...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
2,268
advent-of-code-2022
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day08.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.parser object Day08 : AdventSolution(2016, 8, "Two-Factor Authentication") { override fun solvePartOne(input: String) = solve(input).let { screen -> screen.screen.sumOf { row -> row.count { it } }.toString() } override f...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,822
advent-of-code
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day13.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode.days import tr.emreone.adventofcode.readTextGroups import java.util.* object Day13 { private const val OPENING_BRACKET = '[' private const val CLOSING_BRACKET = ']' private fun String.getCommaIndices(): List<Int> { val bracketStack = Stack<Int>() val comma...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
4,215
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode2022/solution/day_9.kt
dangerground
579,293,233
false
{"Kotlin": 51472}
package adventofcode2022.solution import adventofcode2022.util.readDay import kotlin.math.abs fun main() { Day9("9").solve() } class Day9(private val num: String) { private val inputText = readDay(num) fun solve() { println("Day $num Solution") println("* Part 1: ${solution1()}") ...
0
Kotlin
0
0
f1094ba3ead165adaadce6cffd5f3e78d6505724
4,960
adventofcode-2022
MIT License
src/Day02.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
fun main() { fun part1(input: List<String>): Int { fun shapeScore(shape: Char) = (shape - 'X' + 1) fun resultScore(line: String): Int { return when (line) { "B X", "C Y", "A Z" -> 0 "A X", "B Y", "C Z" -> 3 "C X", "A Y", "B Z" -> 6 ...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
1,195
advent-of-code-2022
Apache License 2.0
src/Day03.kt
george-theocharis
573,013,076
false
{"Kotlin": 10656}
fun main() { fun part1(input: List<String>): Int = input .splitByElf() .findCommonItem() .sumOfPriorities() fun part2(input: List<String>): Int = input .splitByGroupOfElves() .findGroupBadge() .sumOfPriorities() val input = readInput("Day03") println(par...
0
Kotlin
0
0
7971bea39439b363f230a44e252c7b9f05a9b764
1,339
aoc-2022
Apache License 2.0
leetcode/src/daily/hard/Q1235.kt
zhangweizhe
387,808,774
false
null
package daily.hard import java.util.* import kotlin.Comparator import kotlin.math.max fun main() { // 1235. 规划兼职工作 // https://leetcode.cn/problems/maximum-profit-in-job-scheduling/ println(jobScheduling1(intArrayOf(1,2,3,3), intArrayOf(3,4,5,6), intArrayOf(50,10,40,70))) println(jobScheduling1(intArra...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
4,550
kotlin-study
MIT License
src/day12/Day12.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day12 import readInput import java.util.* const val day = "12" fun main() { fun findDijkstraPath(start: Pos, end: Pos, heightMap: List<List<Int>>): MutableList<Pos>? { val height = heightMap.size val width = heightMap[0].size val backPointers = List(height) { MutableList<Pos?>...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
3,811
advent-of-code-22-kotlin
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2021/d14/Day14.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d14 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines // Note about this problem: I verified that there are // exactly 10 letters that occur in the (non-example) input, // and there are 100 pair insert...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,363
advent-of-code
MIT License
src/Day02.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
import Outcome.* import RPS.* private enum class Outcome(val value: Int) { WIN(6), LOSE(0), DRAW(3); } private enum class RPS(val value:Int) { ROCK(1) { override fun outcome(m: RPS): Outcome = when (m) { ROCK -> DRAW PAPER -> WIN SCISSORS -> LOSE } ...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
2,674
aoc-2022
Apache License 2.0
adventofcode/src/main/kotlin/day3.kt
jmfayard
71,764,270
false
null
import io.kotlintest.specs.StringSpec import java.io.File /* Now that you can think clearly, you move deeper into the labyrinth of hallways and office furniture that makes up this part of Easter Bunny HQ. This must be a graphic design department; the walls are covered in specifications for triangles. Or are they? T...
0
Kotlin
0
1
9e92090aa50127a470653f726b80335133dec38b
3,144
httplayground
ISC License
src/main/kotlin/day11/part1/Part1.kt
bagguley
329,976,670
false
null
package day11.part1 import day11.data fun main() { var seats = data.map { it.toCharArray() } while (true) { val x = process(seats) if (compare(x, seats)) break seats = x } val z = seats.map { it.count { it == '#' } }.sum() println(z) } fun process(seats: List<CharArray>):...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
1,431
adventofcode2020
MIT License
leetcode2/src/leetcode/merge-intervals.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 56. 合并区间 * https://leetcode-cn.com/problems/merge-intervals/ * Created by test * Date 2019/9/30 18:12 * Description * 给出一个区间的集合,请合并所有重叠的区间。 示例 1: 输入: [[1,3],[2,6],[8,10],[15,18]] 输出: [[1,6],[8,10],[15,18]] 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. 示例 2: 输入: [[1,4],[4,5]...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,844
leetcode
MIT License
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day19.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day19(input: Input) : Puzzle() { interface Rule data class Terminal(val value: Char) : Rule data class Sequence(val rules: List<Int>) : Rule data class EitherOr(val...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
2,896
adventofcode-kotlin
MIT License
src/main/aoc2015/Day21.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 import com.marcinmoskala.math.combinations import kotlin.math.max class Day21(input: List<String>) { data class Item(val name: String, val cost: Int, val damage: Int, val armor: Int) data class Character(val name: String, val baseDamage: Int = 0, val baseArmor: Int = 0, ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,979
aoc
MIT License
src/Day04.kt
Loahrs
574,175,046
false
{"Kotlin": 7516}
import java.awt.font.NumericShaper fun main() { infix fun<T : Comparable<T>> ClosedRange<T>.fullyContains(otherRange : ClosedRange<T>) : Boolean { return (this.start <= otherRange.start) && (this.endInclusive >= otherRange.endInclusive) } infix fun<T : Comparable<T>> ClosedRange<T>.partiallyOverlap...
0
Kotlin
0
0
b1ff8a704695fc6ba8c32a227eafbada6ddc0d62
1,925
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun part1(input: List<String>): Int { var count = 0 for(jobs in input) { val jobPair = jobs.split(",") var range1 = extractRange(jobPair[0]) var range2 = extractRange(jobPair[1]) if(isRangeContained(range1, range2)) { count++ } } return count } ...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
1,380
AdventOfCode2022
Apache License 2.0
src/day08/Day08.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day08 import java.io.File fun main() { val data = parse("src/day08/Day08.txt") println("🎄 Day 08 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private data class Instructions( va...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
2,452
advent-of-code-2023
MIT License
leetcode-75-kotlin/src/main/kotlin/MaxNumberOfKSumPairs.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
/** * You are given an integer array nums and an integer k. * * In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array. * * Return the maximum number of operations you can perform on the array. * * * * Example 1: * * Input: nums = [1,2,3,4], k = 5 * Outpu...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
1,397
leetcode-75
Apache License 2.0
src/day07/Day07.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day07 import readInput interface FSNode { val size: Int val name: String } class File(override val size: Int, override val name: String) : FSNode { override fun toString(): String { return "File '$name' ($size size)" } } class Directory(override val name: String) : FSNode { const...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
4,713
advent-of-code-2022
Apache License 2.0
src/year2023/day09/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day09 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.readInputs import utils.runAlgorithm fun main() { val (realInput, testInputs) = readInputs(2023, 9, transform = ::parse) runAlgorithm( realInput = realInput, testInputs = testInputs, part1 = ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
1,592
Advent-of-Code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestPalindromicSubsequence.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,906
kotlab
Apache License 2.0
src/Day05/Day05.kt
rooksoto
573,602,435
false
{"Kotlin": 16098}
package Day05 import profile import readInputActual import readInputTest import java.util.* private typealias Board = List<Stack<Char>> private typealias Instruction = Triple<Int, Int, Int> private const val DAY = "Day05" fun main() { fun part1(input: List<String>): String { input.toRawGameComponents() ...
0
Kotlin
0
1
52093dbf0dc2f5f62f44a57aa3064d9b0b458583
2,938
AoC-2022
Apache License 2.0
src/Day05.kt
EnyediPeti
573,882,116
false
{"Kotlin": 8717}
fun main() { class Move(val count: Int, val fromStack: Int, val toStack: Int) fun part1(input: List<String>): String { val blankLineIndex = input.indexOfFirst { it.isBlank() } val crates = input.subList(0, blankLineIndex - 1) val moves = input.subList(blankLineIndex + 1, input.size) ...
0
Kotlin
0
0
845ef2275540a6454a97a9e4c71f239a5f2dc295
2,816
AOC2022
Apache License 2.0
src/Day03.kt
kedvinas
572,850,757
false
{"Kotlin": 15366}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (i in input) { val firstHalf = i.substring(0, i.length / 2).toCharArray().toSet() val secondHalf = i.substring(i.length / 2).toCharArray().toSet() val intersection = firstHalf.intersect(secondHal...
0
Kotlin
0
0
04437e66eef8cf9388fd1aaea3c442dcb02ddb9e
1,269
adventofcode2022
Apache License 2.0
src/Day08.kt
vladislav-og
573,326,483
false
{"Kotlin": 27072}
fun main() { fun createForestMap(input: List<String>): ArrayList<ArrayDeque<Int>> { val forestMap = arrayListOf<ArrayDeque<Int>>() for (row in input) { forestMap.add(ArrayDeque(row.map { it.digitToInt() })) } return forestMap } fun isSeen(treePosX: Int, treesPosY: Int, forestMap: ArrayList...
0
Kotlin
0
0
b230ebcb5705786af4c7867ef5f09ab2262297b6
2,866
advent-of-code-2022
Apache License 2.0
src/Day12.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day12.run { solve1(31) // 330 solve2(29) // 321 } }.let { println("Total: $it ms") } } object Day12 : Day.LineInput<Day12.Data, Int>("12") { data class Data(val map: List<String>, val start: Pa...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
3,586
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day-04.kt
warriorzz
434,696,820
false
{"Kotlin": 16719}
package com.github.warriorzz.aoc import java.nio.file.Files import java.nio.file.Path private fun main() { println("Day 04:") val lines = Files.readAllLines(Path.of("./input/day-04.txt")) val pickedNumbers = lines[0].split(",").map { it.toInt() } val boards = lines.subList(fromIndex = 2, lines.size...
0
Kotlin
1
0
0143f59aeb8212d4ff9d65ad30c7d6456bf28513
2,214
aoc-21
MIT License
src/Day05.kt
chbirmes
572,675,727
false
{"Kotlin": 32114}
import java.util.Stack fun main() { fun part1(input: String): String { val split = input.split("\n\n") val cargoBay = CargoBay.parse(split[0]) split[1].lines() .map { parseInstruction(it) } .forEach { cargoBay.moveSingleCrates(it.first, it.second, it...
0
Kotlin
0
0
db82954ee965238e19c9c917d5c278a274975f26
2,579
aoc-2022
Apache License 2.0
src/Day07/Day07.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day07 import readInput fun main() { fun buildRoot(root: NTree<String>, input: List<String>) { var cwd = root var previousCommand = "" for (line in input) { val split = line.split(" ") if (split[0] == "$") { when (split[1]) { ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
3,877
aoc-2022
Apache License 2.0
src/Day03.kt
timmiller17
577,546,596
false
{"Kotlin": 44667}
fun main() { fun part1(input: List<String>): Int { val rucksacks = input.map { listOf(it.substring(0, it.length / 2), it.substring(it.length/2, it.length))} val commonItems = mutableListOf<String>() val itemPriorityMap = mutableMapOf<String, Int>() val lowers = CharProgression.fro...
0
Kotlin
0
0
b6d6b647c7bb0e6d9e5697c28d20e15bfa14406c
2,172
advent-of-code-2022
Apache License 2.0
03.kts
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
import java.util.* import java.util.Collections.singleton data class PartNumber(val start: Pair<Int, Int>, val end: Pair<Int, Int>, val value: Int) val scanner = Scanner(System.`in`) val numbers = HashSet<PartNumber>() val symbols = HashSet<Pair<Int, Int>>() val stars = HashSet<Pair<Int, Int>>() var y = 0 while (scan...
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
1,564
aoc2023
MIT License
day3/day3/src/main/kotlin/Day5.kt
teemu-rossi
437,894,529
false
{"Kotlin": 28815, "Rust": 4678}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Point(val x: Int, val y: Int) { companion object { fun from(string: String): Point { val s = string.split(",").mapNotNull { it.trim().takeUnless { it.isEmpty() } } require(s.size == 2) return...
0
Kotlin
0
0
16fe605f26632ac2e134ad4bcf42f4ed13b9cf03
2,466
AdventOfCode
MIT License
src/poyea/aoc/mmxxii/day05/Day05.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day05 import poyea.aoc.utils.readInput typealias Stack = ArrayDeque<Char> data class InputData(val parts: List<String>, val allStacks: List<Stack>) fun processInput(input: String): InputData { return input.let { val parts = input.split("\n\n") val stacks = parts[0].split...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
1,870
aoc-mmxxii
MIT License
src/Day08.kt
bkosm
572,912,735
false
{"Kotlin": 17839}
typealias Id = Int typealias Height = Int typealias Tree = Pair<Height, Id> typealias TreeRow = List<Tree> fun toTreeMatrixFlat(input: List<String>): List<TreeRow> { var lastId = Int.MAX_VALUE val horizontal = input.map { line -> line.split("").filter(String::isNotBlank).map { Tree(it.toInt(), lastId-...
0
Kotlin
0
1
3f9cccad1e5b6ba3e92cbd836a40207a2f3415a4
2,518
aoc22
Apache License 2.0
src/Day07.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day07 import patriker.utils.* import kotlin.collections.ArrayDeque data class Directory(val name: String, var size: Int = 0 , var subDirs: List<Directory> = emptyList()) fun main() { val testInput = readInput("Day07_test") //val input = readInput("Day07_input") println(solvePart1(testIn...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
4,096
aoc2022
Apache License 2.0
src/day11/Day11.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day11 import readInputAsString import java.util.* private const val DAY_ID = "11" private data class Monkey( val id: Int, val items: List<Int>, val operator: Operator, val v: Value, val divisor: Int, val throwToIfTrue: Int, val throwToIfFalse: Int ) private enum class Operator : ...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
5,099
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/g0301_0400/s0329_longest_increasing_path_in_a_matrix/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0329_longest_increasing_path_in_a_matrix // #Hard #Top_Interview_Questions #Dynamic_Programming #Depth_First_Search #Breadth_First_Search // #Graph #Memoization #Topological_Sort #2022_11_12_Time_322_ms_(92.65%)_Space_39.2_MB_(100.00%) class Solution { fun longestIncreasingPath(matrix: Array<I...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,812
LeetCode-in-Kotlin
MIT License
src/main/kotlin/aoc23/day05.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc23 import getLongList import runTask import utils.InputReader fun day5part1(input: List<List<String>>): Long { val seedMapRoute = getSeedMapRoute(input) seedMapRoute.traverse() return seedMapRoute.seeds.minOf { it.currentValue } } fun day5part2(input: List<List<String>>): Long { val seedMa...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
4,636
advent-of-code
Apache License 2.0
src/year2022/07/Day07.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`07` import readInput sealed class Record { abstract val title: String abstract var size: Long data class File( override val title: String, override var size: Long, val parent: Dir, ) : Record() data class Dir( override val title: String, ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
4,225
KotlinAdventOfCode
Apache License 2.0
src/aoc22/Day18.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day18 import lib.Solution data class Cube(val x: Int, val y: Int, val z: Int) { fun adjacentCubes(): Set<Cube> = setOf( Cube(x - 1, y, z), Cube(x + 1, y, z), Cube(x, y - 1, z), Cube(x, y + 1, z), Cube(x, y, z - 1), Cube(x, y, z + 1) ...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,751
aoc-kotlin
Apache License 2.0
src/Day07.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
fun main() { data class Directory(val name: String) { val directories = mutableMapOf<String, Directory>() val files = mutableMapOf<String, Long>() fun addDirectory(directory: Directory) { directories[directory.name] = directory } fun addFile(name: String, size:...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
3,693
AdventOfCode2022
Apache License 2.0
src/main/kotlin/shared/Algorithms.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package shared import java.util.* typealias AdjacencyMatrix = Array<IntArray> typealias Node = Int class Algorithms { data class Edge(val endPoint: Node, val cost: Int) data class GraphSize(val width: Int, val height: Int) class Graph(val size: GraphSize) { private val graph: MutableMap<Node, Mu...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
2,908
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc2023/Day22.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import kotlin.math.max import kotlin.math.min class Day22 { fun part1(input: List<String>): Int { val bricks = parseInput(input) val (landed, supportedBy, _) = fall(bricks) val onlySupporterIds = getOnlySupporters(supportedBy) return landed.size - onlySupporterIds.s...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
3,445
advent-of-code-2023
MIT License
src/main/kotlin/com/colinodell/advent2023/Day15.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day15(input: String) { private val steps = input.split(",") private fun hash(step: String) = step.fold(0) { acc, c -> (acc + c.code) * 17 % 256 } private data class Step(val lens: String, val op: Char, val focalLength: Int?) { companion object { ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
1,866
advent-2023
MIT License
src/main/kotlin/Day12.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset import kotlin.math.min fun main() { fun getValues(input: List<String>) = input.map { val list = it.split(" ") list.first() to list[1] }.map { it.first to it.second.split(",").map { s -> s.toInt() } ...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
4,277
aoc-2023-in-kotlin
Apache License 2.0
aoc16/day_04/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 data class Room(val name: String, val id: Int, val checksum: String) fun parseRoom(line: String): Room { val regex = "(.*)-(\\d+)\\[(.*)\\]".toRegex() val match = regex.find(line) val name = match?.groupValues?.get(1) val id = match?.groupValues?.get(2)?.toInt() val checksum =...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,364
advent-of-code
MIT License
src/day24/Code.kt
fcolasuonno
221,697,249
false
null
package day24 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val (parsed, points) = parse(input) println("Part 1 = ${part1(parsed, points)}") println("Part 2 = ${part2...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
2,975
AOC2016
MIT License
src/main/kotlin/net/wrony/aoc2023/a13/thirteen.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a13 import kotlin.io.path.Path import kotlin.io.path.readLines fun gradeSymmetry(r: List<String>, pos: Int, len: Int): Int { return r.subList(pos - len + 1, pos + 1).zip(r.subList(pos + 1, pos + len + 1).reversed()) .sumOf { (str1, str2) -> str1.zip(str2).count { (c1, c2) -> c1 ...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
1,781
aoc-2023-kotlin
MIT License
src/day09/Day09.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day09 import readLines fun main() { val id = "09" val testOutput = 13 val testOutputTwo = 36 val testInput = readInput("day$id/Day${id}_test") val testInputTwo = readInput("day$id/Day${id}_test_two") println(part1(testInput)) println(part2(testInputTwo)) check(part1(testInput...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
2,505
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day16.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode.days import java.util.* import kotlin.collections.HashMap object Day16 { // Regex to match comma seperated words val VALVE_PATTERN = """^Valve (?<name>\w+) has flow rate=(?<flowRate>\d+); tunnel(s)? lead(s)? to valve(s)? (?<adj>[\w\s,]+)$""".toRegex() data class State( ...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
4,520
advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day17.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle import kotlin.math.max import kotlin.math.min class Day17(input: Input) : Puzzle() { class Slice(val cubes: List<List<Boolean>>) private val dimension by lazy { val inpu...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
4,078
adventofcode-kotlin
MIT License
src/Day05.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun parseInput(input: List<String>): Pair<Map<Int, ArrayDeque<Char>>, List<Instruction>> { val inputSplitIndex = input.indexOf("") // Allocate stacks val stacksInput = input.subList(0, inputSplitIndex) val stackNumToIndex: Map<Int, Int> = stacksInput[stacksInput.size -...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
3,163
aoc2022
Apache License 2.0
src/year2022/day16/Day16.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day16 import check import readInput import java.util.concurrent.ConcurrentHashMap import kotlin.math.max import kotlin.system.measureTimeMillis import kotlin.time.Duration.Companion.milliseconds fun main() { // test if implementation meets criteria from the description, like: val testInput = ...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
9,836
AdventOfCode
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[剑指 Offer 42]连续子数组的最大和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//输入一个整型数组,数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。 // // 要求时间复杂度为O(n)。 // // // // 示例1: // // 输入: nums = [-2,1,-3,4,-1,2,1,-5,4] //输出: 6 //解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。 // // // // 提示: // // // 1 <= arr.length <= 10^5 // -100 <= arr[i] <= 100 // // // 注意:本题与主站 53 题相同:https://leetcode-cn.com/problems/maximum-suba...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,196
MyLeetCode
Apache License 2.0
src/main/kotlin/day12/Day12.kt
afTrolle
572,960,379
false
{"Kotlin": 33530}
package day12 import Day import ext.findInMatrix import kotlinx.coroutines.* import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import kotlin.math.absoluteValue fun main() { Day12("Day12").solve() } data class Vertex( val y: Int, val x: Int, val encodedAltitude: Cha...
0
Kotlin
0
0
4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545
3,400
aoc-2022
Apache License 2.0
src/adventofcode/blueschu/y2017/day08/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day08 import java.io.File import kotlin.math.max import kotlin.test.assertEquals fun input() = File("resources/y2017/day08.txt").useLines { it.toList() } fun main(args: Array<String>) { val exampleInstructions = listOf( "b inc 5 if a > 1", "a inc 1 if b < 5", ...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
5,311
Advent-Of-Code
MIT License
src/Day06.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
fun main() { fun part1(input: List<String>): Int { val fish = input[0].split(',').mapTo(mutableListOf(), String::toInt) repeat(80) { for (i in fish.indices) { fish[i]-- if (fish[i] < 0) { fish.add(8) fish[i] = 6 ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
1,241
AdventOfCode2021
Apache License 2.0
src/Day05.kt
Migge
572,695,764
false
{"Kotlin": 9496}
private fun part1(input: List<String>): String { val (stacksStr, instrs) = input.splitOnEmpty() val stacks = initStacks(stacksStr) for ((nr, from, to) in instrs.ints()) { repeat (nr) { stacks[to-1].addLast(stacks[from-1].removeLast()) } } return stacks.toList().map { it....
0
Kotlin
0
0
c7ca68b2ec6b836e73464d7f5d115af3e6592a21
1,377
adventofcode2022
Apache License 2.0
src/Day05.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
class Cargo(stacksAmount: Int) { private val stacks = MutableList(stacksAmount) { listOf<Char>() } fun pushItem(item: Char, index: Int) { stacks[index] = stacks[index] + item } fun runInstruction(instruction: CargoInstruction, oneItemAtTime: Boolean) { when (instruction) { ...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
2,969
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumWidthOfBinaryTree.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,527
kotlab
Apache License 2.0
src/main/kotlin/Day04.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
fun main() { fun getRange(s: String): Set<Int> { val split = s.split("-") return IntRange(split.first().toInt(), split.last().toInt()).toSet() } fun part1(input: String): Int { return input.lines() .map { val split = it.split(",") split.f...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
1,351
advent-of-code-Kotlin-2022
Apache License 2.0
kotlin/MaxFlowDinic.kt
indy256
1,493,359
false
{"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571}
// https://en.wikipedia.org/wiki/Dinic%27s_algorithm in O(V^2 * E) class MaxFlowDinic(nodes: Int) { data class Edge(val t: Int, val rev: Int, val cap: Int, var f: Int = 0) val graph = (1..nodes).map { arrayListOf<Edge>() }.toTypedArray() val dist = IntArray(nodes) fun addBidiEdge(s: Int, t: Int, cap:...
97
Java
561
1,806
405552617ba1cd4a74010da38470d44f1c2e4ae3
2,290
codelibrary
The Unlicense
src/Day04.kt
naturboy
572,742,689
false
{"Kotlin": 6452}
fun main() { data class Entry(val rangeOne: IntProgression, val rangeTwo: IntProgression) fun String.toRange(): IntProgression { val (start, stop) = this.split("-") return start.toInt()..stop.toInt() } fun parseInput(input: List<String>) = input.map { val (rangeInputOne, rangeI...
0
Kotlin
0
0
852871f58218d80702c3b49dd0fd453096e56a43
1,334
advent-of-code-kotlin-2022
Apache License 2.0
Kotlin/problems/0011_evaluate_division.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
//Problem Statement // Equations are given in the format A / B = k, where A and B are variables // represented as strings, and k is a real number (floating point number). // Given some queries, return the answers. If the answer does not exist, return -1.0. // // Example: // Given a / b = 2.0, b / c = 3.0. // queries a...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
3,296
algorithms
MIT License
src/Day21.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun parseInput(input: List<String>): Map<String, String> { return input.associate { line -> val split = line.split(": ") Pair(split[0], split[1]) } } fun getMonkeyValue(monkeyName: String, monkeys: Map<String, String>): Long { val monkey = monkey...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
2,213
aoc2022
Apache License 2.0
src/main/kotlin/advent/y2018/day4.kt
IgorPerikov
134,053,571
false
{"Kotlin": 29606}
package advent.y2018 import misc.readAdventInput import java.time.LocalDateTime import java.time.format.DateTimeFormatter /** * https://adventofcode.com/2018/day/3 */ private typealias GuardId = Int private typealias Minute = Int private typealias Count = Int fun main(args: Array<String>) { val guardToInterva...
0
Kotlin
0
0
b30cf179f7b7ae534ee55d432b13859b77bbc4b7
3,825
kotlin-solutions
MIT License
kotlin/2369-check-if-there-is-a-valid-partition-for-the-array.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
// rolling dp O(1) space class Solution { fun validPartition(nums: IntArray): Boolean { val n = nums.size val dp = booleanArrayOf(false, false, false, true) for (i in 0 until n) { dp[i % 4] = false if (i > 0 && nums[i - 1] == nums[i]) dp[i % 4] = dp[...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,911
leetcode
MIT License
src/main/kotlin/Day05.kt
jcornaz
573,137,552
false
{"Kotlin": 76776}
import java.util.* object Day05 { fun part1(input: String): String { val stacks = input.initialState() input.instructions().forEach { instruction -> repeat(instruction.count) { stacks[instruction.to].push(stacks[instruction.from].pop()) } } r...
1
Kotlin
0
0
979c00c4a51567b341d6936761bd43c39d314510
1,862
aoc-kotlin-2022
The Unlicense
src/day07/Day07.kt
zoricbruno
573,440,038
false
{"Kotlin": 13739}
package day07 import readInput abstract class FileAbstraction( private val name: String, private val parent: FileAbstraction? ) { fun getParent(): FileAbstraction? = parent fun getName(): String = name abstract fun getTotalSize(): Int abstract fun add(file: FileAbstraction) abstract fun ge...
0
Kotlin
0
0
16afa06aff0b6e988cbea8081885236e4b7e0555
3,719
kotlin_aoc_2022
Apache License 2.0
src/Lesson5PrefixSums/GenomicRangeQuery.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * @param S * @param P * @param Q * @return */ fun solution(S: String, P: IntArray, Q: IntArray): IntArray? { val genomePrefixSums = formGenomePrefixSums(S) val result = IntArray(P.size) for (i in P.indices) { val fromIndex = P[i] val toIndex = Q[i] + 1 if (genomeP...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
3,791
Codility-Kotlin
Apache License 2.0
src/main/kotlin/day3/Aoc.kt
widarlein
225,589,345
false
null
package day3 import java.io.File import kotlin.IllegalArgumentException fun main(args: Array<String>) { if (args.size < 1) { println("Must provide input data") System.exit(0) } val inputLines = File("src/main/kotlin/day3/${args[0]}").readLines() val wiresDirections = inputLines.map { ...
0
Kotlin
0
0
b4977e4a97ad61177977b8eeb1dcf298067e8ab4
3,407
AdventOfCode2019
MIT License
src/main/kotlin/com/anahoret/aoc2022/day21/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day21 import java.io.File import kotlin.system.measureTimeMillis enum class Operation { PLUS, MINUS, TIMES, DIVIDE; } sealed class Creature(val name: String) { abstract fun calculate(): Long } sealed class NumberCreature(name: String, val number: Long) : Creature(name) { ove...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
4,575
advent-of-code-2022
Apache License 2.0
src/day11/Day11.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day11 import day10.Coord import elementPairs import println import readInput import kotlin.math.abs data class Point(val x: Long, val y: Long) data class GalaxyMap(val input: List<String>, val expansion: Long) { val colsToMultipy = getEmptyCols() val rowsToMultipy = getEmptyRows() fun getEmptyRo...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
1,715
advent-of-code-2023-kotlin
Apache License 2.0
src/main/kotlin/day11/Day11.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day11 import java.io.File fun main() { val data = parse("src/main/kotlin/day11/Day11.txt") val answer1 = part1(data.toMutableList()) val answer2 = part2(data.toMutableList()) println("🎄 Day 11 🎄") println() println("[Part 1]") println("Answer: $answer1") println() p...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
2,083
advent-of-code-2021
MIT License
src/day1/Day01.kt
TP1cks
573,328,994
false
{"Kotlin": 5377}
fun main() { part1() part2() } fun part1() { println("Part 1: Highest calorie count: ${highestCalorieCount(getElfEntries())}") } fun part2() { println("Part 2: Top three calorie count sum: ${topNHighestCalorieCount(getElfEntries(), 3)}") } fun highestCalorieCount(elfEntries: List<List<String>>) : Int...
0
Kotlin
0
0
52f79a4593384fe651d905ddaea379f49ddfe513
916
advent-of-code-2022
Apache License 2.0
src/Day18.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
data class Cube( val x: Int, val y: Int, val z: Int, ) fun main() { fun List<String>.toCubes(): List<Cube> = map { val split = it.split(",") Cube(split[0].toInt(), split[1].toInt(), split[2].toInt()) } fun computeUncoveredSides(cubes: List<Cube>): Int = ...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
1,712
AdventOfCode2022
Apache License 2.0
src/day12/Day12.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day12 import readInput fun generateCombinations(n: Int, maxHash: Int): List<String> { return sequence { val range = 0 until (1 shl n) for (num in range) { val binaryString = num.toString(2).padStart(n, '0') val combination = binaryString.map { if (it == '0') '.' el...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
1,383
advent-of-code-2023-kotlin
Apache License 2.0
src/main/kotlin/aoc2021/Day02.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput private enum class Direction { FORWARD, DOWN, UP } private data class Movement(val direction: Direction, val distance: Int) { companion object { fun fromString(str: String): Movement { val split = str.split(" ") return Movement(Direction.valueOf(sp...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,436
adventOfCode
Apache License 2.0
day-21/src/main/kotlin/DiracDice.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
import kotlin.system.measureTimeMillis fun main() { val partOneMillis = measureTimeMillis { println("Part One Solution: ${partOne()}") } println("Part One Solved in: $partOneMillis ms") val partTwoMillis = measureTimeMillis { println("Part Two Solution: ${partTwo()}") } println...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
4,360
aoc-2021
MIT License
src/main/java/com/booknara/problem/array/RemoveIntervalKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.array /** * 1272. Remove Interval (Medium) * https://leetcode.com/problems/remove-interval/ */ class RemoveIntervalKt { // T:O(n), S:O(n) fun removeInterval(intervals: Array<IntArray>, toBeRemoved: IntArray): List<List<Int>> { // input check, intervals.length >= 1 ...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,534
playground
MIT License
src/main/kotlin/Forest.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
fun main() { Forest.solve() } private object Forest { fun solve() { val grid = readInput() println("Visible trees: ${countVisible(grid)}") println("Max scenic score: ${maxScenicScore(grid)}") } private fun readInput(): Grid { return generateSequence(::readLine).map { ...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
2,652
aoc2022
MIT License
codeforces/round783/b_wrong.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round783 import kotlin.math.sign fun solve(a: List<Int>): Int { val pref = mutableListOf(0L) val prefIndex = mutableListOf(0) val prefIndexRight = mutableListOf(0) var prefSum = 0L val dp = IntArray(a.size + 1) for (i in a.indices) { prefSum -= a[i] dp[i + 1] = dp[i] + a[i].sign if (pre...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,754
competitions
The Unlicense
src/main/kotlin/_2023/Day12.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2023 import Day import InputReader class Day12 : Day(2023, 12) { data class Hash( val schema: String, val groups: String ) override val firstTestAnswer = 21L override val secondTestAnswer = 525152L private fun solve( schema: String, neededGroups: List<In...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
2,930
advent-of-code
Apache License 2.0
src/Day12.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
import utils.aStar import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Path(val start: Pair<Int, Int>, val end: Pair<Int, Int>, val grid: Array<IntArray>) { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) re...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
3,198
Advent-Of-Code-2022
Apache License 2.0
src/main/kotlin/days/day23/Day23.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day23 import days.Day import java.util.* import kotlin.collections.HashMap //Note: Increase your stack size -Xss10m //Part 1: I implemented dijkstra algorithm wich worked amazing for p //Part 2: I couldn't get dijkstra to work, so i redid everything with a recursive solution class Day23 : Day() { ove...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
5,626
advent-of-code_2023
The Unlicense
src/Day02.kt
kaeaton
572,831,118
false
{"Kotlin": 7766}
fun main() { fun part1(input: List<String>): Int { var score = 0 // val A = "Rock" // val B = "Paper" // val C = "Scissors" // Rock = X for 1 point // Paper = Y for 2 points // Scissors = Z for 3 points val responseValues = mapOf("X" to 1, "Y" to 2, "Z" to 3) ...
0
Kotlin
0
0
c2a92c68bd5822c72c1075f055fc2163762d6deb
1,780
AoC-2022
Apache License 2.0
calendar/day02/Day2.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day02 import Day import Lines import day02.Move.* class Day2 : Day() { val inputMap = mapOf( "A" to ROCK, "X" to ROCK, "B" to PAPER, "Y" to PAPER, "C" to SCISSORS, "Z" to SCISSORS, ) val part2InputMap = mapOf( "X" to 0, "Y" to 3, "Z" to 6, ) val scoreTable = map...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
1,803
adventofcode-2022
Apache License 2.0
src/Day02.kt
bjornchaudron
574,072,387
false
{"Kotlin": 18699}
fun main() { fun part1(input: List<String>): Int { return input .map { it.uppercase().split(" ") } .map { val opponent = parseChoice(it[0]) val player = parseChoice(it[1]) getScore(player) + getMatchBonus(player, opponent) ...
0
Kotlin
0
0
f714364698966450eff7983fb3fda3a300cfdef8
2,352
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day03.kt
margaret-lin
575,169,915
false
{"Kotlin": 9536}
package main.kotlin// https://adventofcode.com/2022/day/3 private val input = readInput("day03_input") private fun part1(input: List<String>): Int { return input.map { it.take(it.length / 2) to it.substring(it.length / 2) } .map { (it.first.toSet() intersect it.second.toSet()).single() } .sumOf(Ch...
0
Kotlin
0
0
7ef7606a04651ef88f7ca96f4407bae7e5de8a45
1,783
advent-of-code-kotlin-22
Apache License 2.0
src/Day25.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import java.lang.IllegalArgumentException val snafuDigits = listOf('=', '-', '0', '1', '2') fun indexOffset(snufDigit: Char): Int { return when (snufDigit) { '2', '1', '0' -> snufDigit.digitToInt() '-' -> -1 else -> -2 } } val sumSnafu = { left: String, right: String -> var (first,...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
1,822
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day6.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DayInput class Day6 : Day("6") { /* Time: 7 15 30 Distance: 9 40 200 */ class RecordTime(val time: Long, val record: Long) { } override fun partOne(dayInput: DayInput): Any { val inputList = dayInput.inputList() val time = i...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
2,269
adventofcode_2023
Creative Commons Zero v1.0 Universal
src/Day02.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
fun main() { fun part1(input: List<String>): Int { val strategies = mapOf( "A" to mapOf( "X" to 4, "Y" to 8, "Z" to 3 ), "B" to mapOf( "X" to 1, "Y" to 5, "Z" to 9 ...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
1,684
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc23/Day06.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day06Domain.DesertIsland import aoc23.Day06Parser.toDesertIsland import aoc23.Day06Solution.part1Day06 import aoc23.Day06Solution.part2Day06 import common.Collections.product import common.Year23 object Day06 : Year23 { fun List<String>.part1(): Long = part1Day06() fun List<String>...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
1,889
aoc
Apache License 2.0
src/main/kotlin/g0001_0100/s0084_largest_rectangle_in_histogram/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0084_largest_rectangle_in_histogram // #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Stack #Monotonic_Stack // #Big_O_Time_O(n_log_n)_Space_O(log_n) #2023_07_10_Time_476_ms_(90.79%)_Space_51.8_MB_(84.21%) import kotlin.math.max class Solution { fun largestRectangleArea(heigh...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,138
LeetCode-in-Kotlin
MIT License
src/main/kotlin/pl/jpodeszwik/aoc2023/Day02.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Long.parseLong private val totalAmounts = mapOf( "red" to 12L, "green" to 13L, "blue" to 14L, ) private fun parseGame(line: String): Pair<Long, Boolean> { val parts = line.substring(5).split(": ") val gameNumber = parseLong(parts[0]) val sets = p...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
2,134
advent-of-code
MIT License
aoc_2023/src/main/kotlin/problems/day18/LavaTrench.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day18 open class LavaTrench(lines: List<String>) { val digList: List<DigData> = lines.map { line -> val (dir, amount) = line.split(" ") DigData( when (dir) { "R" -> { EastTrenchDir.getInstance() } "D...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
4,778
advent-of-code-2023
MIT License
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Circle_Sort/Circle_Sort.kts
rajatenzyme
325,100,742
false
{"C++": 709855, "Java": 559443, "Python": 397216, "C": 381274, "Jupyter Notebook": 127469, "Go": 123745, "Dart": 118962, "JavaScript": 109884, "C#": 109817, "Ruby": 86344, "PHP": 63402, "Kotlin": 52237, "TypeScript": 21623, "Rust": 20123, "CoffeeScript": 13585, "Julia": 2385, "Shell": 506, "Erlang": 385, "Scala": 310, ...
fun<T: Comparable<T>> circleSort(array: Array<T>, lo: Int, hi: Int, nSwaps: Int): Int { if (lo == hi) return nSwaps fun swap(array: Array<T>, i: Int, j: Int) { val temp = array[i] array[i] = array[j] array[j] = temp } var high = hi var low = lo val mid = (hi - lo) /...
0
C++
0
0
65a0570153b7e3393d78352e78fb2111223049f3
1,630
Coding-Journey
MIT License