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/Day02.kt
Yasenia
575,276,480
false
{"Kotlin": 15232}
fun main() { fun part1(input: List<String>): Int { var totalScore = 0 for (line in input) { val columns = line.split(" ") val opponentValue = "ABC".indexOf(columns[0]) val myValue = "XYZ".indexOf(columns[1]) val shapeScore = listOf(1, 2, 3)[myValue] ...
0
Kotlin
0
0
9300236fa8697530a3c234e9cb39acfb81f913ba
1,367
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TotalCost.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
4,168
kotlab
Apache License 2.0
src/main/kotlin/com/marcdenning/adventofcode/day11/Day11a.kt
marcdenning
317,730,735
false
{"Kotlin": 87536}
package com.marcdenning.adventofcode.day11 import java.io.File import java.lang.Integer.max import java.lang.Integer.min private const val FLOOR = '.' private const val EMPTY = 'L' private const val OCCUPIED = '#' fun main(args: Array<String>) { val floorPlanMatrix = File(args[0]).readLines().map { it.toCharArra...
0
Kotlin
0
0
b227acb3876726e5eed3dcdbf6c73475cc86cbc1
2,909
advent-of-code-2020
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem106/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem106 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [106. Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/); */ class Solution { /* Complexity: ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,080
hj-leetcode-kotlin
Apache License 2.0
src/Day23.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { val directionsToConsider = arrayOf( arrayOf( Vector2d.UP, Vector2d.UP + Vector2d.LEFT, Vector2d.UP + Vector2d.RIGHT, ), arrayOf( Vector2d.DOWN, Vector2d.DOWN + Vector2d.LEFT, Vector2d.DOWN + Vector2d.RIGHT, ...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
3,566
aoc2022
Apache License 2.0
2022/kotlin/app/src/main/kotlin/day03/App.kt
jghoman
726,228,039
false
{"Kotlin": 15309, "Rust": 14555, "Scala": 1804, "Shell": 737}
package day03 fun readFileUsingGetResource(fileName: String): String = ClassLoader.getSystemClassLoader().getResource(fileName).readText(Charsets.UTF_8) fun day03Part1(lines: String): Int { return lines .split("\n") .map { l -> Triple(l, l.substring(0, l.length / 2), l.substring(l....
0
Kotlin
0
0
2eb856af5d696505742f7c77e6292bb83a6c126c
1,436
aoc
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day04.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 4 - Repose Record * * Problem Description: http://adventofcode.com/2018/day/4 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day4/ */ package com.ginsberg.advent2018 class Day04(rawInput: List<String>) { privat...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
1,785
advent-2018-kotlin
MIT License
src/Day02.kt
strindberg
572,685,170
false
{"Kotlin": 15804}
import Result.DRAW import Result.LOSS import Result.WIN sealed interface Move { val points: Int fun beats(other: Move): Result fun askedFor(result: Result): Move } enum class Result { WIN, DRAW, LOSS } object Rock : Move { override val points = 1 override fun beats(other: Move) = whe...
0
Kotlin
0
0
c5d26b5bdc320ca2aeb39eba8c776fcfc50ea6c8
2,899
aoc-2022
Apache License 2.0
2021/src/main/kotlin/alternative/Day20.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
package alternative class Day20(val input: List<String>) { private val algorithm = input[0].map { if (it == '#') '1' else '0' }.toTypedArray() private val originalImage = input[1].split("\n").map { row -> row.map { if (it == '#') '1' else '0' }.toTypedArray() }.toTypedArray() private fun enh...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,268
adventofcode-2021-2025
MIT License
src/2021-Day05.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { val board = Grid() for (line in input) { val (pt1, pt2) = line.split("->").map { Point.fromString(it) } when (pt1.relationshipTo(pt2)) { Point.Relationship.EQUAL -> ++board[...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
1,416
2022-aoc-kotlin
Apache License 2.0
src/main/kotlin/year2021/day-08.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2021 import lib.aoc.Day import lib.aoc.Part fun main() { Day(8, 2021, PartA8(), PartB8()).run() } open class PartA8 : Part() { data class Entry(val signal: List<String>, val output: List<String>) { companion object { fun parse(line: String): Entry { val (signal...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
4,855
Advent-Of-Code-Kotlin
MIT License
src/Day04.kt
freszu
573,122,040
false
{"Kotlin": 32507}
fun main() { fun part1(input: List<String>) = input.map { it.split('-', ',') } .map { it.map(String::toInt) } .map { (range1start, range1end, range2start, range2end) -> val range1 = range1start..range1end val range2 = range2start..range2end range1.contains(range2)...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
1,035
aoc2022
Apache License 2.0
src/main/kotlin/betman/PointCalculator.kt
ration
129,735,439
false
null
package betman import betman.pojos.Bet import betman.pojos.Game import betman.pojos.Group import betman.pojos.Match object PointCalculator { enum class Winner { HOME, TIE, AWAY; companion object { fun fromScore(home: Int, away: Int): Winner { val result = home - away...
2
Kotlin
0
1
140fae3b6623c6c57a8a9478fa88df41db9bd906
3,182
betman
MIT License
src/Day04/Day04.kt
emillourens
572,599,575
false
{"Kotlin": 32933}
fun main() { fun part1(input: List<String>): Int { var counter = 0 for (assignments in input) { val assignment1Lower = assignments.split(",")[0].split("-")[0].toInt() val assignment1Upper = assignments.split(",")[0].split("-")[1].toInt() val assignment2Low...
0
Kotlin
0
0
1f9739b73ef080b012e505e0a4dfe88f928e893d
1,979
AoC2022
Apache License 2.0
modules/fathom/src/main/kotlin/silentorb/mythic/fathom/surfacing/old/TraceSurfaceOld.kt
silentorb
227,508,449
false
null
package silentorb.mythic.fathom.surfacing.old import silentorb.mythic.spatial.Quaternion import silentorb.mythic.spatial.Vector2 import silentorb.mythic.spatial.Vector3 data class LongestLineCandidate( val distance: Float, val position: Vector3 ) // Used to precalculate the first half of the normal projectio...
0
Kotlin
0
2
74462fcba9e7805dddec1bfcb3431665df7d0dee
3,066
mythic-kotlin
MIT License
src/Day07.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
class Day07 : Day(7) { data class FileInfo(val size: Long, val name: String) data class Directory(val parent: Directory?, val name: String) { val directories = mutableListOf<Directory>() private val files = mutableListOf<FileInfo>() fun addDirectory(directoryName: String) { ...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
3,519
aoc-2022-in-kotlin
Apache License 2.0
2021/src/day16/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day16 import java.nio.file.Files import java.nio.file.Paths fun main() { fun part1(input: Input): Int { fun dfs(packet: Packet): Int { var sum = packet.version if (packet is Operation) { for (subPacket in packet.subPackets) { sum += dfs(subPacket) } } re...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
4,378
advent-of-code
Apache License 2.0
src/Day05.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
import java.util.* fun main() { val labelRegex = Regex("""\s+\d+""") val moveRegex = Regex("""move (\d+) from (\d+) to (\d+)""") fun part1(input: List<String>): String { val stacks = mutableListOf<Stack<Char>>() for (i in input.indices) { val line = input[i] val nu...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
2,862
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/me/giacomozama/adventofcode2022/days/Day08.kt
giacomozama
572,965,253
false
{"Kotlin": 75671}
package me.giacomozama.adventofcode2022.days import java.io.File class Day08 : Day() { private lateinit var input: List<IntArray> override fun parseInput(inputFile: File) { input = inputFile.useLines { lines -> lines.map { line -> IntArray(line.length) { line[it].digitToInt() } }.toList(...
0
Kotlin
0
0
c30f4a37dc9911f3e42bbf5088fe246aabbee239
3,324
aoc2022
MIT License
src/main/kotlin/Excercise18.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
sealed class SNum { class Reg(val x: Int) : SNum() { override fun toString(): String = x.toString() } class Pair(val l: SNum, val r: SNum) : SNum() { override fun toString(): String = "[$l,$r]" } } fun parseSNum(s: String): SNum { var i = 0 fun parse(): SNum { if (s[i] == '[') { i++ ...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
2,789
advent-of-code-2021
MIT License
tree_data_structure/PseudoPalindromicPathsInABinaryTree/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Given a binary tree where node values are digits from 1 to 9. * A path in the binary tree is said to be pseudo-palindromic * if at least one permutation of the node values in the path is a palindrome. * Return the number of pseudo-palindromic paths going * from the root node to leaf nodes. * <br/> * htt...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,807
codility
MIT License
src/main/kotlin/be/tabs_spaces/advent2021/days/Day11.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import kotlin.also as and import kotlin.let as then class Day11 : Day(11) { override fun partOne() = Cavern(inputList).iterate(100) override fun partTwo() = Cavern(inputList).optimalStep() class Cavern(rawInput: List<String>) { private val octopuses = rawI...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
2,361
advent-2021
Creative Commons Zero v1.0 Universal
src/Day08.kt
pavlo-dh
572,882,309
false
{"Kotlin": 39999}
fun main() { fun part1(input: List<String>): Int { val visibleGrid = input.map { BooleanArray(it.length) } for (i in 1 until input.size - 1) { var highest = input[i][0] for (j in 1 until input.size - 1) { if (input[i][j] > highest && input[i][j] > input[i][j ...
0
Kotlin
0
2
c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992
3,116
aoc-2022-in-kotlin
Apache License 2.0
src/aoc23/Day08.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day08 import lib.Maths.lcm import lib.Solution enum class Step(val symbol: Char) { LEFT('L'), RIGHT('R'); companion object { fun parse(symbol: Char): Step = values().find { it.symbol == symbol }!! } } data class Node(val label: String, val left: ...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,473
aoc-kotlin
Apache License 2.0
src/main/kotlin/g1301_1400/s1320_minimum_distance_to_type_a_word_using_two_fingers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1320_minimum_distance_to_type_a_word_using_two_fingers // #Hard #String #Dynamic_Programming #2023_06_05_Time_181_ms_(100.00%)_Space_37.7_MB_(100.00%) class Solution { private var word: String? = null private lateinit var dp: Array<Array<Array<Int?>>> fun minimumDistance(word: String)...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,454
LeetCode-in-Kotlin
MIT License
src/main/kotlin/dev/claudio/adventofcode2022/Day11Part2.kt
ClaudioConsolmagno
572,915,041
false
{"Kotlin": 41573}
package dev.claudio.adventofcode2022 fun main() { Day11Part2().main() } private class Day11Part2 { fun main() { // val input = Support.readFileAsListString("2022/day11-input.txt") // val monkeysSample = listOf( // Monkey(0, mutableListOf(79, 98), { it:Long -> it * 19}, 23, 2, 3), // ...
0
Kotlin
0
0
43e3f1395073f579137441f41cd5a63316aa0df8
2,398
adventofcode-2022
Apache License 2.0
src/DigitsRecognizer.kt
lasp91
70,458,490
false
null
import java.io.File import java.util.stream.IntStream import java.util.concurrent.atomic.AtomicInteger data class Observation (val label: String , val Pixels: IntArray) typealias Distance = (IntArray, IntArray) -> Int typealias Classifier = (IntArray) -> String typealias Observations = Array<Observation> fun observ...
0
Kotlin
0
0
4907cbb2c656c344f5c0a5175909e6cc3bedd67d
3,579
DigitsRecognizer_using_Kotlin
Apache License 2.0
src/Day22.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
import com.github.h0tk3y.betterParse.combinators.or import com.github.h0tk3y.betterParse.combinators.use import com.github.h0tk3y.betterParse.combinators.zeroOrMore import com.github.h0tk3y.betterParse.grammar.Grammar import com.github.h0tk3y.betterParse.grammar.parseToEnd import com.github.h0tk3y.betterParse.lexer.lit...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
4,575
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day09.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 private fun solve(line: String): Long { val numbers = line.split(" ").map { java.lang.Long.parseLong(it) } val diffs = ArrayList<List<Long>>() diffs.add(numbers) var currentNumbers = numbers while (!currentNumbers.all { it == 0L }) { val newDiffs = ArrayList<Lo...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
1,669
advent-of-code
MIT License
src/Day08.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
class Forest constructor(private val input: Array<IntArray>) { val size = input.size init { // check input is square assert(input.all { it.size == size }) } operator fun get(x: Int, y: Int): Int { return input[x][y] } } fun Forest.visibleTreeFromOutsideCount(): Int { ...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
3,349
aoc-2022
Apache License 2.0
Problems/Algorithms/79. Word Search/WordSearch.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun exist(board: Array<CharArray>, word: String): Boolean { val n = board.size val m = board[0].size val neighbors = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0)) val visited = Array(n) { BooleanArray(m) { false } } ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,312
leet-code
MIT License
parserkt-util/src/commonMain/kotlin/org/parserkt/util/Trie.kt
ParserKt
242,278,819
false
null
package org.parserkt.util //// == Trie Tree == open class Trie<K, V>(var value: V?) { constructor(): this(null) val routes: MutableMap<K, Trie<K, V>> by lazy(::mutableMapOf) operator fun get(key: Iterable<K>): V? = getPath(key).value open operator fun set(key: Iterable<K>, value: V) { getOrCreatePath(key).value...
1
Kotlin
0
11
37599098dc9aafef7b509536e6d17ceca370d6cf
2,504
ParserKt
MIT License
src/aoc23/Day10.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day10 import lib.Direction import lib.Direction.* import lib.Grid import lib.Point import lib.Solution enum class Tile(val symbol: Char, val connections: Set<Direction>) { GROUND('.', emptySet()), VERTICAL('|', setOf(UP, DOWN)), HORIZONTAL('-', setOf(LEF...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
5,397
aoc-kotlin
Apache License 2.0
src/Day05.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap fun main() { fun solvePart1(input: List<String>): String { val stacks = HashMap<Int, Deque<Char>>() var start = 0 for (idx in input.indices) { if (input[idx] == "") { start =...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
2,191
AoC-2022-kotlin
Apache License 2.0
src/main/kotlin/g2501_2600/s2547_minimum_cost_to_split_an_array/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2547_minimum_cost_to_split_an_array // #Hard #Array #Hash_Table #Dynamic_Programming #Counting // #2023_07_06_Time_400_ms_(100.00%)_Space_50.3_MB_(100.00%) class Solution { fun minCost(nums: IntArray, k: Int): Int { val n = nums.size val dp = IntArray(n) dp.fill(-1) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,203
LeetCode-in-Kotlin
MIT License
src/algorithms.kt
BenjaminEarley
151,190,621
false
null
import ConsList.Cons import ConsList.Nil import ZipperList.Cell import ZipperList.Empty fun binarySearch(a: Array<Int>, target: Int): Int { tailrec fun loop(min: Int, max: Int): Int = if (max < min) -1 else { val guess = listOf(min, max).average().toInt() when { ...
0
Kotlin
0
0
1a4278273f3d79d4e5bb7054d0e5fb91274e871c
3,082
Functional_Kotlin
MIT License
src/main/kotlin/com/rtarita/days/Day6.kt
RaphaelTarita
724,581,070
false
{"Kotlin": 64943}
package com.rtarita.days import com.rtarita.structure.AoCDay import com.rtarita.util.day import com.rtarita.util.sqr import kotlinx.datetime.LocalDate import kotlin.math.ceil import kotlin.math.floor import kotlin.math.roundToInt import kotlin.math.sqrt /** * The distances resulting in holding down the button for n ...
0
Kotlin
0
0
4691126d970ab0d5034239949bd399c8692f3bb1
2,225
AoC-2023
Apache License 2.0
src/commonMain/kotlin/io/github/offlinebrain/khexagon/algorythm/Pathfinding.kt
OfflineBrain
663,452,814
false
null
package io.github.offlinebrain.khexagon.algorythm import io.github.offlinebrain.khexagon.coordinates.AxisPoint /** * Represents a path tile with generic type `T`. * * @param T the type of objects that can be used for movement cost and heuristic calculations. */ interface PathTile<T> : AxisPoint, Walkable, Movemen...
0
Kotlin
0
1
1bf3b6f073fbad98eeb10ea83730e883cf8ed7d5
7,319
khexagon
MIT License
src/aoc2022/Day03.kt
miknatr
576,275,740
false
{"Kotlin": 413403}
package aoc2022 fun main() { println('A'.code) println('Z'.code) println('a'.code) println('z'.code) fun Char.getPriority(): Int = if (this.code >= 97) this.code - 96 else this.code - 65 + 27 fun part1(input: List<String>) = input .filter { it != "" } .map { line -> ...
0
Kotlin
0
0
400038ce53ff46dc1ff72c92765ed4afdf860e52
1,295
aoc-in-kotlin
Apache License 2.0
src/Day03.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
fun main() { fun prio(c: Char): Int { val priority = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" return priority.indexOf(c) + 1 } fun part1(input: List<String>): Int { return input.sumOf { val (firstHalf, secondHalf) = it.chunked(it.length / 2) pri...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
1,137
aoc-2022
Apache License 2.0
src/main/kotlin/g2401_2500/s2471_minimum_number_of_operations_to_sort_a_binary_tree_by_level/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2471_minimum_number_of_operations_to_sort_a_binary_tree_by_level // #Medium #Breadth_First_Search #Tree #Binary_Tree // #2023_07_05_Time_789_ms_(100.00%)_Space_63.6_MB_(100.00%) import com_github_leetcode.TreeNode import java.util.ArrayDeque /* * Example: * var ti = TreeNode(5) * var v = ti.`v...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,020
LeetCode-in-Kotlin
MIT License
src/Day01.kt
mhuerster
572,728,068
false
{"Kotlin": 24302}
fun main() { fun getElvesFromInput(input: List<String>): List<List<Int>> { val groupSeparator = ",\\s,\\s".toRegex() val itemSeparator = ",\\s+".toRegex() val groups = input.joinToString() val elves = groups.split(groupSeparator).map { it.split(itemSeparator).map { it.toInt() } }// ...
0
Kotlin
0
0
5f333beaafb8fe17ff7b9d69bac87d368fe6c7b6
1,030
2022-advent-of-code
Apache License 2.0
src/Day04.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
fun main() { fun solvePart1(input: List<String>): Int { var res = 0 for (line in input) { val (interval1, interval2) = line.split(",") val (a, b) = interval1.split("-").map(String::toInt) val (c, d) = interval2.split("-").map(String::toInt) if ((a <= c...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
1,074
AoC-2022-kotlin
Apache License 2.0
app/src/y2021/day06/Day06Lanternfish.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day06 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle fun main(args: Array<String>) { Day06Lanternfish().solveThem() } @AoCPuzzle(year = 2021, day = 6) class Day06Lanternfish : AocSolution { override val answers = Answers(samplePart1 = 5934, samplePart2 = 269...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
1,899
advent-of-code-2021
Apache License 2.0
src/main/kotlin/ctci/chaptereight/PermutationsWithoutDups.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chaptereight // 8.7 - page 135 // Write a method in Kotlin to compute all the permutations of a string of unique characters. fun main() { val permutations = permutations("abc") for (permutation in permutations) { println(permutation) } } //This implementation uses a recursive approac...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
1,903
dsa-kotlin
MIT License
src/y2017/3.kt
chesterm8
123,070,176
false
null
package y2017 import kotlin.math.* fun main(args: Array<String>) { val base = ceil(sqrt(input3.toDouble())).toInt() //Level of the loop we are on val stepsToThisLoop = base / 2 val total = (base + 1).toDouble().pow(2) //Highest number in this loop val offset = total - input3 //Distance of current numb...
0
Kotlin
0
0
bed839efa608f83cd32c52a95fc0f5634d64aa2b
2,239
advent
MIT License
src/main/kotlin/aoc2023/day1.kt
sodaplayer
726,524,478
false
{"Kotlin": 4129}
package aoc2023 import utils.loadInput fun main() { val lines = loadInput("/2023/day1") .bufferedReader() .readLines() // Part 1 val numerals = lines.map { line -> line.filter { it.isDigit() } } val pairs = numerals .map { "${it.first()}${it.last()}" } .map(String::toI...
0
Kotlin
0
0
c0937a8288f8466a28932c8cf8e3ba454ac8c4ac
1,490
aoc2023-kotlin
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2019/Day10.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2019 import com.s13g.aoc.Result import com.s13g.aoc.Solver import kotlin.math.abs import kotlin.math.atan2 import kotlin.math.sqrt /** https://adventofcode.com/2019/day/10 */ class Day10 : Solver { override fun solve(lines: List<String>): Result { // Parse Input val field = hashSetOf...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,140
euler
Apache License 2.0
solutions/src/PacificAtlanticWaterFlow.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/pacific-atlantic-water-flow/ */ class PacificAtlanticWaterFlow { fun pacificAtlantic(matrix: Array<IntArray>): List<List<Int>> { if (matrix.isEmpty()) { return listOf() } var pathToAtlanticFromPacific = mutableSetOf<Pair<Int,Int>>() ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
2,469
leetcode-solutions
MIT License
src/jvmMain/kotlin/day01/initial/Day01.kt
liusbl
726,218,737
false
{"Kotlin": 109684}
package day01.initial // Took 48 minutes to solve fun main() { // day1part1() // Solution: 55816 day1part2() // Solution: 54980 } fun day1part1() { val input = inputDay1 // val input = """ // 1abc2 // pqr3stu8vwx // a1b2c3d4e5f // treb7uchet // """.trimIndent() val ...
0
Kotlin
0
0
1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1
32,365
advent-of-code
MIT License
src/day17/Day17.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day17 import readInput enum class UnitType(val repr: Char) { FALLING('@'), STOPPED('#'), AIR('.') } enum class Direction(val repr: Char) { DOWN('|'), LEFT('<'), RIGHT('>'); companion object { fun fromRepr(repr: Char) = values().toList().first { it.repr == repr } } } ...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
5,688
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kr/co/programmers/P155651.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers import java.util.* // https://github.com/antop-dev/algorithm/issues/489 class P155651 { fun solution(bookTime: Array<Array<String>>): Int { // 입(퇴)실 시간으로 정렬 // 시간이 같다면 퇴실 시간이 먼저다. // first : 시간 // second : 1(입실), 0(퇴실) val pq = PriorityQueue<Pair<I...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,322
algorithm
MIT License
src/Day03.kt
RaspiKonk
572,875,045
false
{"Kotlin": 17390}
/** * Day 3: Doppelte Items in den Rücksäcken finden * * Part 1: Den Buchstaben finden der doppelt vorkommt und zu einem Score zusammenrechnen * Part 2: Den Buchstaben finden der in jeder 3er Gruppe von Rucksäcken (Zeilen) vorkommt */ fun main() { val start = System.currentTimeMillis() val DAY: String = "03" p...
0
Kotlin
0
1
7d47bea3a5e8be91abfe5a1f750838f2205a5e18
2,228
AoC_Kotlin_2022
Apache License 2.0
src/Day04.kt
bherbst
572,621,759
false
{"Kotlin": 8206}
import java.lang.IllegalArgumentException fun main() { fun getSections(line: String): Pair<IntRange, IntRange> { val elves = line.split(',') val (first, second) = elves.map { elf -> val (start, end) = elf.split('-').map { it.toInt() } start .. end } return Pa...
0
Kotlin
0
0
64ce532d7a0c9904db8c8d09ff64ad3ab726ec7e
1,301
2022-advent-of-code
Apache License 2.0
lib/src/main/kotlin/com/bloidonia/advent/day02/Day02.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day02 import com.bloidonia.advent.BaseDay import kotlinx.coroutines.flow.fold import kotlinx.coroutines.runBlocking enum class Direction { forward, down, up } data class Movement(val direction: Direction, val distance: Int) data class CurrentPosition(val horizontal: Int = 0, val dep...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
2,434
advent-of-kotlin-2021
MIT License
2021/src/main/kotlin/Day13.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day13(val input: List<String>) { private val dots = mutableSetOf<Dot>() private val actions = mutableListOf<DotAction>() init { input[0].split("\n").map { it.split(",") }.map { dots.add(Dot(it[0].toInt(), it[1].toInt())) } input[1].split("\n").map { it.split("=") } .map ...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,503
adventofcode-2021-2025
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D22.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2020 import io.github.pshegger.aoc.common.BaseSolver class Y2020D22 : BaseSolver() { override val year = 2020 override val day = 22 override fun part1(): Long { val input = parseInput() val p1 = input.first.toMutableList() val p2 = input.second.toMu...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,521
advent-of-code
MIT License
solutions/aockt/y2015/Y2015D06.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import aockt.y2015.Y2015D06.Action.* import io.github.jadarma.aockt.core.Solution import kotlin.math.abs object Y2015D06 : Solution { private enum class Action { TURN_ON, TOGGLE, TURN_OFF } private data class Rectangle(val x1: Int, val y1: Int, val x2: Int, val y2: Int) /** Regex th...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,682
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/RemoveCoveredIntervals.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,984
kotlab
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day13/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day13 import java.io.File import java.lang.StringBuilder private fun String.isListLiteral(): Boolean { return startsWith("[") && endsWith("]") } private fun String.unwrapListLiteral(): String { return drop(1).dropLast(1) } sealed class IntOrList : Comparable<IntOrList> { co...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
4,030
advent-of-code-2022
Apache License 2.0
2021/src/main/kotlin/utils/CharGrid.kt
dkhawk
433,915,140
false
{"Kotlin": 170350}
package utils import kotlin.math.abs import kotlin.math.sign import kotlin.math.sqrt data class Vector(val x: Int = 0, val y: Int = 0) : Comparable<Vector> { val sign: Vector get() = Vector(x.sign, y.sign) operator fun times(scale: Int): Vector { return Vector(x * scale, y * scale) } operator fun mi...
0
Kotlin
0
0
64870a6a42038acc777bee375110d2374e35d567
14,695
advent-of-code
MIT License
src/test/kotlin/Common.kt
christof-vollrath
317,635,262
false
null
import java.lang.IllegalArgumentException import kotlin.math.* fun readResource(name: String) = ClassLoader.getSystemClassLoader().getResource(name)?.readText() fun <T> List<List<T>>.transpose(): List<List<T>> { val result = mutableListOf<List<T>>() val n = get(0).size for (i in 0 until n) { val ...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
6,413
advent_of_code_2020
Apache License 2.0
strings/RegularExpressionMatching/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Given an input string (s) and a pattern (p), implement * regular expression matching with support for '.' and '*' where: * '.' Matches any single character.​​​​ * '*' Matches zero or more of the preceding element. * The matching should cover the entire input string (not partial). * <br> * https:/...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,356
codility
MIT License
src/Day11.kt
cagriyildirimR
572,811,424
false
{"Kotlin": 34697}
data class Monkey( val id: Int, var items: MutableList<Long> = mutableListOf(), var op: Operation = Operation("", 0), var test: Long = 0, var ifTrue: Int = 0, var ifFalse: Int = 0, var inspection: Long = 0 ) data class Operation(val type: String, val y: Long) { fun calculate(x: Long): L...
0
Kotlin
0
0
343efa0fb8ee76b7b2530269bd986e6171d8bb68
2,471
AoC
Apache License 2.0
src/Day05.kt
simonitor
572,972,937
false
{"Kotlin": 8461}
fun main() { // first val (startBoard, movelist) = readFile("inputDay5").split("\n\n").map { it.split("\n") } val boardState = setupBoard(startBoard.toMutableList()) val parsedMoveList = parseMoveList(movelist) applyMoves(boardState, parsedMoveList) println(getTopOfStacks(boardState)) val bo...
0
Kotlin
0
0
11d567712dd3aaf3c7dee424a3442d0d0344e1fa
2,235
AOC2022
Apache License 2.0
src/Day10.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
import kotlin.math.floor import kotlin.text.StringBuilder val openingChars = setOf('(', '[', '{', '<') val closingChars = setOf(')', ']', '}', '>') fun firstPart10(list : List<String>) { val errorsCount = mutableMapOf<Char, Int>() closingChars.map { errorsCount[it] = 0 } // val scopes = mutableListOf<Sco...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
3,956
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/main/kotlin/ru/glukhov/aoc/Day7.kt
cobaku
576,736,856
false
{"Kotlin": 25268}
package ru.glukhov.aoc fun main() { val shell = Problem.forDay("day7").use { val shell = Shell() it.forEachLine { val cmd = it.parseCommand() if (cmd != null) { shell.execute(cmd) } else { shell.appendOutput(it) } ...
0
Kotlin
0
0
a40975c1852db83a193c173067aba36b6fe11e7b
4,419
aoc2022
MIT License
src/Day03.kt
ochim
579,680,353
false
{"Kotlin": 3652}
fun main() { fun getScore(c: Char) = if (c.isLowerCase()) { c.code - 'a'.code + 1 } else { c.code - 'A'.code + 27 } fun part1(input: List<String>): Int { return input.sumOf { line -> val comp1 = line.substring(0, line.length / 2) val comp2 = line.substrin...
0
Kotlin
0
0
b5d34a8f0f3000c8ad4afd7726dd93171baee76e
804
advent-of-code-kotlin-2022
Apache License 2.0
21/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Game { val input = File("input.txt") .readLines() val posRegex = """Player (\d+) starting position: (\d+)""".toRegex() val (_, player1Pos) = posRegex.find(input[0])?.destructured!! val (_, player2Pos) = posRegex.find(input[1])?.destructured!! return ...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
3,882
advent-of-code-2021
MIT License
Kotlin/src/UniqueBinarySearchTrees.kt
TonnyL
106,459,115
false
null
/** * Given n, how many structurally unique BST's (binary search trees) that store values 1...n? * * For example, * Given n = 3, there are a total of 5 unique BST's. * * 1 3 3 2 1 * \ / / / \ \ * 3 2 1 1 3 2 * / / \ \ * 2 ...
1
Swift
22
189
39f85cdedaaf5b85f7ce842ecef975301fc974cf
954
Windary
MIT License
src/Day02.kt
allwise
574,465,192
false
null
import RockPaperScissors.Play.* import RockPaperScissors.Result.* import java.io.File fun main() { fun part1(input: List<String>): Int { val rpc = RockPaperScissors(input) return rpc.quick1() println(rpc.quick1()) } fun part2(input: List<String>): Int { val rpc = RockPaper...
0
Kotlin
0
0
400fe1b693bc186d6f510236f121167f7cc1ab76
4,641
advent-of-code-2022
Apache License 2.0
src/Day11.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
import java.util.function.Predicate data class Throw(val toMonkey: Int, val item: Long) class Monkey(instructions: List<String>) { var items = mutableListOf<Long>() var operation: (Long) -> Long = { old -> old } var test: Predicate<Long> = Predicate { item -> true } var trueTestMonkeyIndex = -1 va...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
4,789
advent-of-code-2022
Apache License 2.0
src/Day09.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
import kotlin.math.abs fun main() { fun getNumTailVisitedPositions(input: List<String>, ropeLength: Int): Int { val rope = MutableList(ropeLength) { Coordinates(0, 0) } val tailVisited = mutableSetOf<Coordinates>() tailVisited.add(rope.last()) for(line in input) { val ...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
2,085
aoc2022
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day278/day278.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day278 data class BinaryTree(val left: BinaryTree?, val right: BinaryTree?) { companion object { // Memoize for efficiency. private val cache: MutableMap<Int, List<BinaryTree>> = mutableMapOf() fun constructAllTrees(numNodes: Int): List<BinaryTree> { // Boundary cas...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,493
daily-coding-problem
MIT License
src/Day08.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
fun main() { fun visibleFromTop(tree: Tree, trees: MutableList<Tree>): Boolean { val filter = trees.filter { tree.x > it.x && tree.y == it.y } val maxOf = filter.maxOf { it.height } return tree.height > maxOf } fun visibleFromBottom(tree: Tree, trees: MutableList<Tree>): Boolean { ...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
5,696
aoc-2022-in-kotlin
Apache License 2.0
src/DayThree.kt
P-ter
572,781,029
false
{"Kotlin": 18422}
import kotlin.math.roundToInt fun main() { fun partOne(input: List<String>): Int { var total = 0 input.forEach { line -> val middle = (line.length / 2.0).roundToInt() val firstHalf = line.substring(0, middle) val secondHalf = line.substring(middle) ...
0
Kotlin
0
1
e28851ee38d6de5600b54fb884ad7199b44e8373
1,847
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/d3/d3.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d3 import readInput fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val comp1 = line.substring(0, line.length/2) val comp2 = line.substring(line.length/2) val set1 = comp1.toSet() for (elt in comp2) if (elt in set1) { ...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
1,079
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/de/niemeyer/aoc2022/Day03.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 3: Rucksack Reorganization * Problem Description: https://adventofcode.com/2022/day/3 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { fun part1(input: List<String>): Int = input.m...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
1,351
AoC-2022
Apache License 2.0
src/Day02.kt
semanticer
577,822,514
false
{"Kotlin": 9812}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val roundInputs = it.split(" ") val opponent = roundInputs[0].toOpponentWeapon() val me = roundInputs[1].toMyWeapon() clashOfWeapons(opponent, me) } } fun part2(input: Lis...
0
Kotlin
0
0
9013cb13f0489a5c77d4392f284191cceed75b92
3,103
Kotlin-Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day16/Day16.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day16 import com.jacobhyphenated.advent2023.Day /** * Day 16: The Floor Will Be Lava * * A beam of light gets reflected and split throughout the puzzle input. * The beam travels one space at a time in a specific direction. * '.' does nothing, the beam continues onward * ...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
4,996
advent2023
The Unlicense
src/Day18.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
typealias Cube = Triple<Int, Int, Int> fun main() { val cubes = readInput("Day18_input").map { val (x, y, z) = it.split(",").map { it.toInt() } Cube(x, y, z) }.toSet() val minDim = cubes.flatMap { it.toList() }.min() val maxDim = cubes.flatMap { it.toList() }.max() fun Cube.getAdjac...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,961
aoc-2022
Apache License 2.0
advent-of-code-2023/src/Day10.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import lib.matrix.* private typealias Maze = Matrix<Pipe> private typealias MazeRow = List<Pipe> private const val DAY = "Day10" fun main() { fun testInput(id: Int) = readInput("${DAY}_test$id") fun input() = readInput(DAY) "Part 1" { part1(testInput(0)) shouldBe 4 part1(testInput(1)) sh...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
5,097
advent-of-code
Apache License 2.0
src/Day04.kt
aemson
577,677,183
false
{"Kotlin": 7385}
fun main() { val inputData = readInput("Day04_input") val campOrder: List<Pair<List<Int>, List<Int>>> = inputData.map { input -> val sectionsMap = input.split(",").map { val split = it.split("-") val start = split[0].toInt() val end = split[1].toInt() var ...
0
Kotlin
0
0
ffec4b848ed5c2ba9b2f2bfc5b991a2019c8b3d4
1,291
advent-of-code-22
Apache License 2.0
src/Day02.kt
tstellfe
575,291,176
false
{"Kotlin": 8536}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val opponent = it.split(" ")[0] val mine = it.split(" ")[1] RockPaperScissor.from(opponent)!!.score(mine) } } fun part2(input: List<String>): Int { return input.sumOf { val opponent = it.split(" ")[0] ...
0
Kotlin
0
0
e100ba705c8e2b83646b172d6407475c27f02eff
1,866
adventofcode-2022
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/Subsets.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Use this technique when the problem asks to deal with permutations or combinations of a set of elements. The "Subsets" coding pattern is different from the "Two Heaps" pattern. The "Subsets" pattern is commonly used to generate all possible subsets of a set, while the "Two Heaps" pattern is used for efficiently sol...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,391
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/Day02.kt
AxelUser
572,845,434
false
{"Kotlin": 29744}
fun main() { val wins = hashMapOf( 1 to 3, 2 to 1, 3 to 2 ) fun List<String>.solve1(): Int { var score = 0 for (round in this) { val opponent = round[0] - 'A' + 1 val player = round[2] - 'X' + 1 if (opponent == player) { ...
0
Kotlin
0
1
042e559f80b33694afba08b8de320a7072e18c4e
1,358
aoc-2022
Apache License 2.0
src/Day05.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun main() { fun part1(input: List<String>): String { var i = 0 while (input[i].isNotBlank()) { i++ } var totalStacks = input[i - 1].last().toString().toInt() var crane = (1..totalStacks).map { mutableListOf<Char>() }.toMutableList() for (j in 0.until(i...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
3,075
advent-2022
Apache License 2.0
src/main/kotlin/days/Day14.kt
hughjdavey
225,440,374
false
null
package days import kotlin.math.ceil class Day14 : Day(14) { override fun partOne(): Any { return NanoFactory(inputList).minimumOreForOneFuel() } override fun partTwo(): Any { return NanoFactory(inputList).maxFuelForOre(ONE_TRILLION) } data class ChemicalQuantity(val chemical: S...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
3,007
aoc-2019
Creative Commons Zero v1.0 Universal
src/Day18.kt
zfz7
573,100,794
false
{"Kotlin": 53499}
fun main() { println(day18A(readFile("Day18"))) println(day18B(readFile("Day18"))) } fun day18A(input: String): Int { var count = 0 cords.forEach { cord -> if (!cords.contains(listOf(cord[0] + 1, cord[1], cord[2]))) { count++ } if (!cords.contains(listOf(cord[0] - 1...
0
Kotlin
0
0
c50a12b52127eba3f5706de775a350b1568127ae
3,543
AdventOfCode22
Apache License 2.0
src/Day04.kt
rdbatch02
575,174,840
false
{"Kotlin": 18925}
fun main() { fun parseInput(input: List<String>): List<List<IntRange>> { return input.map { inputLine -> val assignmentStrings = inputLine.split(",") assignmentStrings.map { val assignmentSections = it.split("-") IntRange(assignmentSections.first().toI...
0
Kotlin
0
1
330a112806536910bafe6b7083aa5de50165f017
1,003
advent-of-code-kt-22
Apache License 2.0
src/Day03.kt
andydenk
573,909,669
false
{"Kotlin": 24096}
import java.lang.IllegalStateException fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day03_test") check(part1(testInput) == 157) check(part2(testInput) == 70) val input = readInput("Day03") println("Part 1: ${part1(input)}") pr...
0
Kotlin
0
0
1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1
1,434
advent-of-code-2022
Apache License 2.0
ctci/arrays_and_strings/_02_check_permutation/CheckPermutation.kt
vishal-sehgal
730,172,606
false
{"Kotlin": 8936}
package ctci.arrays_and_strings._02_check_permutation /** * #1.2 * * Check Permutation: Given two strings, write a method to decide if one is a permutation * of the other. */ class CheckPermutation { /** * Determines whether two given strings are permutations of each other. * * Time Complexit...
0
Kotlin
0
0
f83e929dfef941fbd8150c3ebc7c7c6fee60148b
2,757
kotlin-coding-interview
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxPoints.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,975
kotlab
Apache License 2.0
src/main/kotlin/day03/Day03.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day03 import readInput fun main() { fun value(item: Char) = if (item in 'a'..'z') { item - 'a' + 1 } else { item - 'A' + 27 } fun part1(input: List<String>): Int { return input.sumOf {line -> val cmp1 = line.substring(0, line.length / 2) val cmp...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
1,058
aoc2022
Apache License 2.0
src/main/kotlin/io/intervals/MeetingRoomII.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.intervals import io.utils.runTests import java.util.* import kotlin.Comparator // https://leetcode.com/problems/meeting-rooms-ii/ class MeetingRoomII { fun execute(input: Array<IntArray>): Int { if (input.isEmpty()) return 0 val allocator = PriorityQueue(input.size, Comparator<Int> { a, b -> a...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,535
coding
MIT License
src/Day11.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
data class Monkey( val startingItems: List<Long>, val opExpr: String, val divisor: Long, val testTrueMonkey: Int, val testFalseMonkey: Int, ) { // do not count starting items var count = 0 val items = startingItems.toMutableList() fun round(item: Long, gcd: Long? = null): Pair<Int, ...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
3,995
advent-of-code-2022
Apache License 2.0
2023/5/solve-1.kts
gugod
48,180,404
false
{"Raku": 170466, "Perl": 121272, "Kotlin": 58674, "Rust": 3189, "C": 2934, "Zig": 850, "Clojure": 734, "Janet": 703, "Go": 595}
import java.io.File import kotlin.text.Regex class CategoryToCategoryMapper ( val name: String, val source: String, val destination: String, val howTo: List<Triple<Long,Long,Long>> ) { fun convert(src: Long): Long { val rule = howTo.firstOrNull { it.second <= src && src < (it.second + it.th...
0
Raku
1
5
ca0555efc60176938a857990b4d95a298e32f48a
1,568
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc2023/day14/day14Solver.kt
Advent-of-Code-Netcompany-Unions
726,531,711
false
{"Kotlin": 94973}
package aoc2023.day14 import lib.* suspend fun main() { setupChallenge().solveChallenge() } fun setupChallenge(): Challenge<Array<Array<Char>>> { return setup { day(14) year(2023) //input("example.txt") parser { it.readLines().get2DArrayOfColumns() } ...
0
Kotlin
0
0
a77584ee012d5b1b0d28501ae42d7b10d28bf070
3,026
AoC-2023-DDJ
MIT License
src/Day14.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
fun main() { val start = Pair(500,0) var maxX = 0 var maxY = 0 var minX = Int.MAX_VALUE var minY = Int.MAX_VALUE val widerForPart = 1000 fun printMatrix(matrix: MutableList<MutableList<String>>) { matrix.forEachIndexed{i, item -> println("$i ${item.subList(minX-200,maxX+...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
4,059
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day23.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.Point import shared.getText import kotlin.math.abs class AmphipodAStar(val input: String){ private fun heuristic(map: String) = AmphipodCave(map).heurestic() fun aStar(): Int{ val openSet = mutableSetOf(input) val cameFrom = mutableMapOf<String, String>() val gScore = mut...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
5,899
AdventOfCode2021
MIT License