path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/endredeak/aoc2022/Day12.kt
edeak
571,891,076
false
{"Kotlin": 44975}
package endredeak.aoc2022 fun main() { solve("Hill Climbing Algorithm") { fun Char.value(): Int = when (this) { 'S' -> 0 'E' -> 25 else -> this - 'a' } val dirs = setOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1) data class P(v...
0
Kotlin
0
0
e0b95e35c98b15d2b479b28f8548d8c8ac457e3a
1,744
AdventOfCode2022
Do What The F*ck You Want To Public License
src/Day03.kt
jarmstrong
572,742,103
false
{"Kotlin": 5377}
fun main() { val scores = (('a'..'z') + ('A'..'Z')) .zip(1..52) .toMap() fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val firstCompartment = rucksack.substring(0, rucksack.length / 2).toSet() val secondCompartment = rucksack.substring(ru...
0
Kotlin
0
0
bba73a80dcd02fb4a76fe3938733cb4b73c365a6
943
aoc-2022
Apache License 2.0
src/Day03/Day03.kt
Trisiss
573,815,785
false
{"Kotlin": 16486}
fun main() { fun Char.getPriorities() = when { isUpperCase() -> code - 38 isLowerCase() -> code - 96 else -> error("Unknown char!!") } fun part1(input: List<String>): Int = input.sumOf { line -> line.chunked(line.length/2).map { it.toSet() }.reduce { acc, chars -> acc.inter...
0
Kotlin
0
0
cb81a0b8d3aa81a3f47b62962812f25ba34b57db
916
AOC-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinStoneSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,069
kotlab
Apache License 2.0
src/main/kotlin/day02/day02.kt
andrew-suprun
725,670,189
false
{"Kotlin": 18354, "Python": 17857, "Dart": 8224}
package day02 import java.io.File import kotlin.math.max data class Game(val id: Int, val colors: Colors) data class Colors(val red: Int, val green: Int, val blue: Int) fun main() { println(run(::part1)) println(run(::part2)) } fun run(score: (Game) -> Int): Int = File("input.data").readLines().sumOf { scor...
0
Kotlin
0
0
dd5f53e74e59ab0cab71ce7c53975695518cdbde
1,391
AoC-2023
The Unlicense
2021/src/main/kotlin/day5_imp.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Segment import utils.Solution import utils.Vec2i import utils.mapItems fun main() { Day5Imp.run() } object Day5Imp : Solution<List<Segment>>() { override val name = "day5" override val parser = Parser.lines .mapItems(Segment::parse) .mapItems { if (it.start.x > it.end.x)...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,368
aoc_kotlin
MIT License
src/Day05.kt
psabata
573,777,105
false
{"Kotlin": 19953}
fun main() { fun part1(stacks: MutableList<MutableList<Char>>, instructions: List<Instruction>): String { instructions.forEach { instruction -> instruction.execute1(stacks) } return stacks.fold("") { acc, stack -> acc + (stack.lastOrNull() ?: "") } } fun part2(stacks: ...
0
Kotlin
0
0
c0d2c21c5feb4ba2aeda4f421cb7b34ba3d97936
2,853
advent-of-code-2022
Apache License 2.0
src/Day05.kt
cornz
572,867,092
false
{"Kotlin": 35639}
fun main() { fun getStartIndexAndNumberOfStacks(input: List<String>): Pair<Int, Int>? { for ((index, value) in input.reversed().withIndex()) { if (value.startsWith(" 1")) { return Pair(index, value.split(" ").last().toInt()) } } return null } ...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
3,063
aoc2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/largest_subarray_length_k/LargestSubarrayLengthK.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.largest_subarray_length_k import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/352459/Google-or-OA-Fall-Internship-2019-or-Largest-Subarray-Length-K */ class LargestSubarrayLengthKTests { @Test fun examples() { largestSubarra...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,102
katas
The Unlicense
src/day01/Day01.kt
Mini-Stren
573,128,699
false
null
package day01 import readInputText fun main() { val day = 1 fun part1(input: String): Int { return input.elves.maxOf { it.foods.sumOf(Day01.Food::calories) } } fun part2(input: String): Int { return input.elves.map { it.foods.sumOf(Day01.Food::calories) } .sortedDescendi...
0
Kotlin
0
0
40cb18c29089783c9b475ba23c0e4861d040e25a
1,048
aoc-2022-kotlin
Apache License 2.0
src/Day02.kt
Inn0
573,532,249
false
{"Kotlin": 16938}
data class RPSAnswer( val name: String, val keys: List<String>, val value: Int ) fun main() { val Rock = RPSAnswer("rock", listOf("A", "X"), 1) val Paper = RPSAnswer("paper", listOf("B", "Y"), 2) val Scissors = RPSAnswer("scissors", listOf("C", "Z"), 3) fun inputToAnswer(input: String): RP...
0
Kotlin
0
0
f35b9caba5f0c76e6e32bc30196a2b462a70dbbe
3,556
aoc-2022
Apache License 2.0
src/aoc2018/kot/Day03.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import getNumbers import itertools.times import java.io.File object Day03 { data class Claim(val id: Int, val x: Int, val y: Int, val xsize: Int, val ysize: Int) fun partOne(input: List<String>): Int = putClaims(parse(input)).sumBy { it.count { it > 1 } } fun partTwo(input: List<Stri...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,225
Advent_of_Code
MIT License
src/main/kotlin/aoc08/Solution08.kt
rainer-gepardec
573,386,353
false
{"Kotlin": 13070}
package aoc08 import java.nio.file.Paths inline fun <T> Iterable<T>.takeWhileInclusive( predicate: (T) -> Boolean ): List<T> { var shouldContinue = true return takeWhile { val result = shouldContinue shouldContinue = predicate(it) result } } fun main() { val lines = Paths....
0
Kotlin
0
0
c920692d23e8c414a996e8c1f5faeee07d0f18f2
2,361
aoc2022
Apache License 2.0
src/main/kotlin/days/Solution14.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.Point2D import adventOfCode.util.plus typealias RockSet = Set<Point2D> typealias ReflectorMirror = Triple<RockSet, RockSet, PairOf<Int>> private class RockAndRoll( private val round...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
3,203
Advent-of-Code-2023
MIT License
src/Day01.kt
KliminV
573,758,839
false
{"Kotlin": 19586}
fun main() { fun part1(input: List<String>): Int { if (input.isEmpty()) return 0; var curIdx: Int = 1; var maxIdx: Int = 0; var curWeight: Int = 0 var maxTotalCalories: Int = 0; for (line in input) { when (line) { "" -> { ...
0
Kotlin
0
0
542991741cf37481515900894480304d52a989ae
3,123
AOC-2022-in-kotlin
Apache License 2.0
src/main/kotlin/adventofcode2018/Day18SettlersOfTheNorthPole.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2018 import adventofcode2018.AreaElement.* import java.lang.Math.min import java.util.* import kotlin.math.max class Day18SettlersOfTheNorthPole sealed class AreaElement(val sign: Char) { object Open : AreaElement('.') object Tree : AreaElement('|') object Lumberyard : AreaElement('#'...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
3,838
kotlin-coding-challenges
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[2]两数相加.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 // // 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 // // 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 // // 示例: // // 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) //输出:7 -> 0 -> 8 //原因:342 + 465 = 807 // // Related Topics 链表 数学 // 👍 5357 👎 0 //leetcode submit region begin(Prohi...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,406
MyLeetCode
Apache License 2.0
src/main/kotlin/aoc/year2022/Day08.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2022 import aoc.Puzzle private typealias Tree = Pair<Int, Int> /** * [Day 8 - Advent of Code 2022](https://adventofcode.com/2022/day/8) */ object Day08 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { val grid = input.lines().map { it.map(Char::digitToInt) } ...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,815
advent-of-code
Apache License 2.0
src/main/kotlin/d18/D18_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d18 import d16.Direction import input.Input import kotlin.math.abs val INT_TO_DIR = mapOf( Pair(0, Direction.RIGHT), Pair(2, Direction.LEFT), Pair(3, Direction.ABOVE), Pair(1, Direction.BELOW) ) data class BigInstruction( val dir: Direction, val count: Long ) fun parseRealInput(lines...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
1,824
aoc2023-kotlin
MIT License
2015/src/main/kotlin/day14.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.mapItems fun main() { Day14.run() } object Day14: Solution<List<Day14.Reindeer>>() { override val name = "day14" override val parser = Parser.lines.mapItems { parseReindeer(it) } private const val ROUNDS = 2503 @Parse("{name} can fl...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,253
aoc_kotlin
MIT License
src/main/kotlin/leetcode/google/Problem329.kt
Magdi
390,731,717
false
null
package leetcode.google import java.util.* class Problem329 { private val di = listOf(0, 0, -1, 1) private val dj = listOf(1, -1, 0, 0) fun longestIncreasingPath(matrix: Array<IntArray>): Int { if (matrix.isEmpty() || matrix[0].isEmpty()) return 0 val n = matrix.size val m = matri...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
1,307
ProblemSolving
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2021/Day25.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.Pos import com.chriswk.aoc.util.report class Day25 : AdventDay(2021, 25) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day25() report { ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,953
adventofcode
MIT License
src/Day07.kt
robotfooder
573,164,789
false
{"Kotlin": 25811}
class MyDir( val name: String, val subDirs: MutableList<MyDir> = mutableListOf(), val parent: MyDir?, private val files: MutableList<MyFile> = mutableListOf(), var dirSize: Int = 0, ) { fun addFile(size: Int, name: String) { files.add(MyFile(size, name)) dirSize += size v...
0
Kotlin
0
0
9876a52ef9288353d64685f294a899a58b2de9b5
2,986
aoc2022
Apache License 2.0
src/main/kotlin/days/Day9.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils class Day9 : Day(9) { private val points = inputList.flatMapIndexed { y, s -> s.mapIndexed { x, c -> Point(c.toString().toInt(), Utils.Coord(x, y)) } } override fun partOne(): Any { return points.filter { it.isLowPoint(points) }.map(Point::riskLevel).sum() } o...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
1,535
aoc-2021
Creative Commons Zero v1.0 Universal
src/Day07.kt
Ajimi
572,961,710
false
{"Kotlin": 11228}
typealias Path = String fun main() { fun part1(input: List<String>): Long { return input.toDirSizes().values.filter { it <= 100000 }.sum() } fun part2(input: List<String>): Long { val sizeMap = input.toDirSizes() val sizeNeeded = 30000000 - (70000000 - sizeMap[""]!!) return...
0
Kotlin
0
0
8c2211694111ee622ebb48f52f36547fe247be42
1,649
adventofcode-2022
Apache License 2.0
src/Day09/day09.kt
NST-d
573,224,214
false
null
package Day09 import utils.* import kotlin.math.abs import kotlin.math.sign fun main() { data class Point(var x: Int, var y: Int){ fun follow(other: Point){ if(abs(other.x-this.x) > 1){ //move in the right direction this.x += sign((other.x - this.x).toDouble()...
0
Kotlin
0
0
c4913b488b8a42c4d7dad94733d35711a9c98992
2,843
aoc22
Apache License 2.0
calendar/day08/Day8.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day08 import Day import Lines class Day8 : Day() { data class Position(val row: Int, val col: Int) class Grid(val matrix: List<List<Int>>) { fun Position.valueAt() = matrix[row][col] fun Position.leftOf() = matrix[row].subList(0, col) fun Position.rightOf() = matrix[row].slice((col + 1) unti...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
2,218
adventofcode-2022
Apache License 2.0
src/main/kotlin/days/Day16.kt
sicruse
315,469,617
false
null
package days import days.Day import kotlin.math.absoluteValue class Day16 : Day(16) { private val rules: List<Rule> by lazy { inputString .split("\\n\\n".toRegex()) .first() .split("\\n".toRegex()) .map{ ruleText -> Rule.deserialize(ruleText) } } p...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
4,481
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/Day07.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
fun main() { fun List<String>.parseFilesystem(): Directory { val structure = Directory("") var currentDirectory = "" for (line in this) { if (line.startsWith("$ ")) { val command = line.replace("$ ", "") if (command == "cd /") currentDirectory = ...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
3,327
advent-of-code
Apache License 2.0
src/aoc2023/Day15.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun hash(step: String): Int { var hash = 0 for (c in step) { hash += c.code hash *= 17 hash %= 256 } return hash } fun part1(lines: List<String>): Int { val steps = lines[0].split(','...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
1,867
advent-of-code-kotlin
Apache License 2.0
src/day-18.kt
drademacher
160,820,401
false
null
import Ground.* import java.io.File fun main(args: Array<String>) { println("part 1: " + partOne()) println("part 2: " + partTwo()) } private enum class Ground { OPEN, TREE, LUMBERYARD } private data class Area(val area: Array<Array<Ground>>) { fun getHeight() = area.size fun getWidth() = area[0].size...
0
Kotlin
0
0
a7f04450406a08a5d9320271148e0ae226f34ac3
4,081
advent-of-code-2018
MIT License
src/Day12.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader fun main() { val testInput = """ Sabqponm abcryxxl accszExk acctuvwj abdefghi """.trimIndent() val testCliff = getCliffNodes(testInput.reader()) val testGraph = testCliff.nodes.flatten() val testDj = djikstra(testGraph, testCliff.start)...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
4,193
advent-of-code-2022-kotlin
Apache License 2.0
src/day02/Day02.kt
apeinte
574,487,528
false
{"Kotlin": 47438}
package day02 import readDayInput const val OPPONENT_ROCK = "A" const val OPPONENT_PAPER = "B" const val OPPONENT_SCISSOR = "C" const val MY_ROCK = "X" const val MY_PAPER = "Y" const val MY_SCISSORS = "Z" enum class OpponentRockPaperScissors(val choice: String, val score: Int) { ROCK(OPPONENT_ROCK, 1), PAPE...
0
Kotlin
0
0
4bb3df5eb017eda769b29c03c6f090ca5cdef5bb
6,174
my-advent-of-code
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch9/Problem100.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch9 import java.math.BigInteger import kotlin.math.sqrt /** * Problem 100: Arranged Probability * * https://projecteuler.net/problem=100 * * Goal: Find the first arrangement (of blue and red discs) to contain > D total discs, where the * probability of taking 2 blue discs is exactly P/Q. ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
5,077
project-euler-kotlin
MIT License
src/Day12.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { val aCode = 'a'.code val (startCode, endCode) = arrayOf('S'.code - aCode, 'E'.code - aCode) fun neighbours(cell: GridCell<Int>, grid: Grid<Int>) = grid.crossNeighbours(cell.position).filter { it.value < cell.value + 2 } fun prepareData(input: List<String>): Triple<Grid<Int>, G...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
1,288
aoc2022
Apache License 2.0
src/main/kotlin/com/leonra/adventofcode/advent2023/day09/Day9.kt
LeonRa
726,688,446
false
{"Kotlin": 30456}
package com.leonra.adventofcode.advent2023.day09 import com.leonra.adventofcode.shared.readResource /** https://adventofcode.com/2023/day/9 */ private object Day9 { fun partOne(): Int { val histories = mutableListOf<List<Int>>() readResource("/2023/day09/part1.txt") { line -> val his...
0
Kotlin
0
0
46bdb5d54abf834b244ba9657d0d4c81a2d92487
2,407
AdventOfCode
Apache License 2.0
src/com/ncorti/aoc2022/Day02.kt
cortinico
571,724,497
false
{"Kotlin": 5773}
package com.ncorti.aoc2022 fun scoreForInput(input: String) = when(input) { "X" -> 1 "Y" -> 2 else -> 3 } fun playLose(input: String) = when(input) { "A" -> "Z" "B" -> "X" else -> "Y" } fun playDraw(input: String) = when(input) { "A" -> "X" "B" -> "Y" else -> "Z" } fun playWin(input: String) = whe...
4
Kotlin
0
1
cd9ad108a1ed1ea08f9313c4cad5e52a200a5951
1,375
adventofcode-2022
MIT License
src/main/kotlin/days/Day14.kt
andilau
429,206,599
false
{"Kotlin": 113274}
package days import kotlin.math.max @AdventOfCodePuzzle( name = "Space Stoichiometry", url = "https://adventofcode.com/2019/day/14", date = Date(day = 14, year = 2019) ) class Day14(input: List<String>) : Puzzle { private val reactions: Map<String, Pair<Long, List<Quantity>>> = input.parseReactions() ...
2
Kotlin
0
0
f51493490f9a0f5650d46bd6083a50d701ed1eb1
3,253
advent-of-code-2019
Creative Commons Zero v1.0 Universal
src/Day04.kt
undermark5
574,819,802
false
{"Kotlin": 67472}
fun main() { fun part1(input: List<String>): Int { val mapped: List<Boolean> = input.map { val ranges: List<IntRange> = it.split(",").map { it.toIntRange("-") } val first: IntRange = ranges.first() val second: IntRange = ranges.last() first in second || second...
0
Kotlin
0
0
e9cf715b922db05e1929f781dc29cf0c7fb62170
932
AoC_2022_Kotlin
Apache License 2.0
src/day02/Day02.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day02 import day02.FixedOutcome.* import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { it.toRound().score() } } fun part2(input: List<String>): Int { return input.sumOf { it.toFixedRound().score() } } // test if impl...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
4,716
advent-of-code-22
Apache License 2.0
src/Day06.kt
allwise
574,465,192
false
null
fun main() { fun part1(input: List<String>): Int { val signals = Signals(input) return signals.process() } fun part2(input: List<String>): Int { val signals = Signals(input) return signals.process2() } // test if implementation meets criteria from the description...
0
Kotlin
0
0
400fe1b693bc186d6f510236f121167f7cc1ab76
1,204
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordFilter.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,623
kotlab
Apache License 2.0
src/Day12.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
data class HeightMap(val destination: Point, val nodes: Array<MutableList<Node>>) { private val width = nodes[0].size private val height = nodes.size operator fun get(point: Point): Node { return nodes[point.y][point.x] } operator fun get(x: Int, y: Int): Node { return nodes[y][x...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
5,443
advent-of-code-kotlin-2022
Apache License 2.0
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day14.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty import kotlin.math.pow fun List<String>.day14Part2(): Long { val memory: MutableMap<Long, Long> = mutableMapOf() var mask: List<Char> = "".toCharArray().toList() this.forEach { instructionLine -> if (instructionLine.isMask()) { mask = instr...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
3,250
AdventOfCode
MIT License
2023/day04-25/src/main/kotlin/Day17.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import java.util.PriorityQueue class Day17 { fun solve1() { val grid = File("inputs/17.txt").inputStream().bufferedReader().lineSequence() .map { it.map { x -> x.digitToInt() }.toList() }.toList() val res = dijkstra1(grid, Point(0, 0)) println(res.filter { it...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
4,844
AdventOfCode
MIT License
src/Day11.kt
mihansweatpants
573,733,975
false
{"Kotlin": 31704}
import java.util.LinkedList fun main() { fun part1(monkeys: List<Monkey>): Long { repeat(20) { for (monkey in monkeys) { while (monkey.hasItems()) { val (item, throwTo) = monkey.inspectAndThrowAnItem() monkeys[throwTo].catchItem(item) ...
0
Kotlin
0
0
0de332053f6c8f44e94f857ba7fe2d7c5d0aae91
3,892
aoc-2022
Apache License 2.0
src/Day04.kt
gomercin
572,911,270
false
{"Kotlin": 25313}
/* * searches I needed to make: * kotlin tuple * */ fun main() { class Assignment(line: String) { var first: Pair<Int, Int> var second: Pair<Int, Int> init { val parts = line.split(",") val firstAsStr = parts[0].split("-") val secondAsStr = parts[1].spl...
0
Kotlin
0
0
30f75c4103ab9e971c7c668f03f279f96dbd72ab
1,808
adventofcode-2022
Apache License 2.0
topsis-distance-ranking/src/main/kotlin/pl/poznan/put/topsis/DistanceRankingCalculator.kt
sbigaret
164,424,298
true
{"Kotlin": 93061, "R": 67629, "Shell": 24899, "Groovy": 24559}
package pl.poznan.put.topsis import pl.poznan.put.xmcda.ranking.RankEntry import pl.poznan.put.xmcda.ranking.Ranking import kotlin.math.pow import kotlin.math.sqrt class DistanceRankingCalculator( alternatives: List<TopsisAlternative>, criteria: List<Criterion>, private val idealAlternatives: ...
0
Kotlin
0
0
96c182d7e37b41207dc2da6eac9f9b82bd62d6d7
2,301
DecisionDeck
MIT License
src/main/kotlin/cloud/dqn/leetcode/FourSum2Kt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/4sum-ii/description/ Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make problem a bit easier, all A, B, C, D have same length of N where 0...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
1,514
cloud-dqn-leetcode
No Limit Public License
src/day_03/Day03.kt
the-mgi
573,126,158
false
{"Kotlin": 5720}
package day_03 import readInput import java.io.File import java.util.* fun main() { fun getPriority(character: Char) = if (character.isLowerCase()) (character.code - 97) % 26 + 1 else (character.code - 65) % 26 + 1 + 26 fun characterTransform(character: Char, map: MutableMap<Char, Int>) { map...
0
Kotlin
0
0
c7f9e9727ccdef9231f0cf125e678902e2d270f7
2,200
aoc-2022-kotlin
Apache License 2.0
17/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Target { val input = File("input.txt") .readText() val xRegex = """x=(-?\d+)..(-?\d+)""".toRegex() val yRegex = """y=(-?\d+)..(-?\d+)""".toRegex() val (miniX, maxiX) = xRegex.find(input)?.destructured!! val (miniY, maxiY) = yRegex.find(input)?.destruc...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
1,682
advent-of-code-2021
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day03.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part3A : PartSolution() { lateinit var lines: List<String> override fun parseInput(text: String) { lines = text.trimEnd().split("\n") } override fun compute(): Int { ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,857
advent-of-code-kotlin
MIT License
src/Day02.kt
skarlman
572,692,411
false
{"Kotlin": 4076}
import java.io.File // Problem: // https://adventofcode.com/2022/day/2 // More solutions: // https://www.competitivecoders.com/ProgrammingCompetitions/advent-of-code/advent-of-code/2022/day-2/ fun main() { fun part1(input: List<String>): Int { val scores = mapOf( Pair("A", "X") to 1 + 3, ...
0
Kotlin
0
0
ef15752cfa6878ce2740a86c48b47597b8d5cabc
1,653
AdventOfCode2022_kotlin
Apache License 2.0
src/Day01.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import java.util.regex.Pattern fun main() { fun part1(input: List<String>): Int { return input.sumOf { it.replace("\\D".toRegex(), "").let { "${it.first()}${it.last()}".toInt() } } } fun replaceNumber(r:String): String { return when (r) { ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
1,375
aoc-2023
Apache License 2.0
2022/src/main/kotlin/Day11.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import Day11.Operand.Value object Day11 { fun part1(input: String): Long { val monkeys = parseMonkeys(input) repeat(20) { simulateRound(monkeys) { it / 3L } } return calculateMonkeyBusiness(monkeys) } fun part2(input: String): Long { val monkeys = parseMonkeys(input) val divisorPr...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,451
advent-of-code
MIT License
src/day03/Day03.kt
taer
573,051,280
false
{"Kotlin": 26121}
package day03 import readInput fun main() { val codeOfA = 'a'.code fun Set<Char>.priorityValue(): Int { val dupeChar = this.single() val upperCase = if (dupeChar.isUpperCase()) 26 else 0 return dupeChar.lowercaseChar().code - codeOfA + upperCase + 1 } fun part1(input: List<S...
0
Kotlin
0
0
1bd19df8949d4a56b881af28af21a2b35d800b22
1,183
aoc2022
Apache License 2.0
src/main/kotlin/g2301_2400/s2333_minimum_sum_of_squared_difference/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2301_2400.s2333_minimum_sum_of_squared_difference // #Medium #Array #Math #Sorting #Heap_Priority_Queue // #2023_07_01_Time_502_ms_(100.00%)_Space_50.6_MB_(100.00%) import kotlin.math.abs import kotlin.math.pow class Solution { fun minSumSquareDiff(nums1: IntArray, nums2: IntArray, k1: Int, k2: Int): Lo...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,261
LeetCode-in-Kotlin
MIT License
src/Day01.kt
WaatzeG
573,594,703
false
{"Kotlin": 7476}
fun main() { /** * Return sum of top elf */ fun part1(input: List<String>): Int { return split(input) .maxOf { it.sumOf(String::toInt) } } /** * Return sum of top 3 elves */ fun part2(input: List<String>): Int { return split(input) .map { ...
0
Kotlin
0
0
324a98c51580b86121b6962651f1ba9eaad8f468
1,231
advent_of_code_2022_kotlin
Apache License 2.0
src/Day03.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun change(symbol: Char) = if (symbol.isUpperCase()) symbol.lowercase().first().code - 70 else symbol.uppercase().first().code - 64 fun main() { fun part1(input: List<String>): Int { return input.sumOf { val strings = it.chunked(it.length / 2) val set = strings[0] va...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
825
Advent-of-code
Apache License 2.0
src/day01/Day01.kt
violabs
576,367,139
false
{"Kotlin": 10620}
package day01 import readInput fun main() { test1("day-01-test-input-01", 24000) test2("day-01-test-input-01", 45000) } private fun test1(filename: String, expected: Int) { val input = readInput("day01/$filename") val actual: Int = findHighestCalorieSet(input) println("EXPECT: $expected") p...
0
Kotlin
0
0
be3d6bb2aef1ebd44bbd8e62d3194c608a5b3cc1
1,770
AOC-2022
Apache License 2.0
src/day02/Day02.kt
benjaminknauer
574,102,077
false
{"Kotlin": 6414}
package day02 import java.io.File import java.lang.IllegalArgumentException enum class Move(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); companion object { fun fromShortcode(shortcode: String): Move { return when (shortcode) { "A", "X" -> ROCK "B", "Y"...
0
Kotlin
0
0
fcf41bed56884d777ff1f95eddbecc5d8ef731d1
4,466
advent-of-code-22-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortIntegersByThePowerValue.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,777
kotlab
Apache License 2.0
src/main/kotlin/g2401_2500/s2458_height_of_binary_tree_after_subtree_removal_queries/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2458_height_of_binary_tree_after_subtree_removal_queries // #Hard #Array #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #2023_07_05_Time_951_ms_(80.00%)_Space_118.6_MB_(80.00%) import com_github_leetcode.TreeNode class Solution { fun treeQueries(root: TreeNode?, queries: IntA...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,799
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-22.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.Coord3D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.math.max import kotlin.math.min fun main() { val input = readInputLines(2021, "22-input") val te...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
4,987
advent-of-code
MIT License
src/day11/Day11.kt
tobihein
569,448,315
false
{"Kotlin": 58721}
package day11 import readInput class Day11 { fun part1(): Long { val readInput = readInput("day11/input") return part1(readInput) } fun part2(): Long { val readInput = readInput("day11/input") return part2(readInput) } fun part1(input: List<String>): Long { ...
0
Kotlin
0
0
af8d851702e633eb8ff4020011f762156bfc136b
2,067
adventofcode-2022
Apache License 2.0
src/main/kotlin/org/sjoblomj/adventofcode/day9/Day9.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day9 import org.sjoblomj.adventofcode.readFile import kotlin.system.measureTimeMillis private const val inputFile = "src/main/resources/inputs/day9.txt" private const val marbleThatAddsToScore = 23 private const val positionThatGetsAdded = -7 private const val positionToPlaceAt = 1 ...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
2,114
adventofcode2018
MIT License
src/chapter1/section4/PermutationAndCombination.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter1.section4 /** * 计算从total数量数据中取select个数据的排列数 * 从n个数中取m个数排列的公式为 P(n,m)=n*(n-1)*(n-2)*...*(n-m+1)=n!/(n-m)! (规定0!=1) * n个数的全排列公式(m=n) P(n)=n*(n-1)*(n-2)*...*1=n! */ fun permutation(total: Int, select: Int): Long { require(select in 0..total) var count = 1L repeat(select) { coun...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
824
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/day04/Problem.kt
xfornesa
572,983,494
false
{"Kotlin": 18402}
package day04 fun solveProblem01(input: List<String>): Long { return input.stream() .map { it.split(",") } .map { val (left, right) = it val (left_l, left_h) = left.split("-").map { it.toInt() } val (right_l, right_h) = right.split("-").map { it.toInt() } ...
0
Kotlin
0
0
dc142923f8f5bc739564bc93b432616608a8b7cd
996
aoc2022
MIT License
src/main/kotlin/mirecxp/aoc23/day03/Day03.kt
MirecXP
726,044,224
false
{"Kotlin": 42343}
package mirecxp.aoc23.day03 import java.io.File //https://adventofcode.com/2023/day/3 class Day03(inputPath: String) { private val lines: List<String> = File(inputPath).readLines() data class Coord(val r: Int, val c: Int) data class Gear(val coord: Coord, val parts: MutableList<Long>) fun solve() ...
0
Kotlin
0
0
6518fad9de6fb07f28375e46b50e971d99fce912
3,869
AoC-2023
MIT License
src/cn/leetcode/codes/simple100/Simple100.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple100 import cn.leetcode.codes.common.TreeNode import cn.leetcode.codes.createTreeNode import cn.leetcode.codes.out fun main() { val p = createTreeNode(arrayOf(1,2)) val q = createTreeNode(arrayOf(1,null,3)) // val p = createTreeNode(arrayOf(1,2,3)) // val q = createTreeNo...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,135
LeetCodeSimple
Apache License 2.0
src/Day01.kt
riegersan
572,637,157
false
{"Kotlin": 4377}
fun main() { fun getElveCals( input: List<String>, ): List<Int> { val snackSeparator = mutableListOf<Int>() input.withIndex().forEach { if(it.value.isEmpty()){ snackSeparator.add(it.index) } } val elves = mutableListOf<Int>() ...
0
Kotlin
0
0
d89439eb4d4d736d783c77cec873ac6e697e6ee9
1,509
advent-of-code-22-kotlin
Apache License 2.0
src/main/kotlin/day24/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day24 import util.Coord import util.Direction import util.readTestInput import java.lang.IllegalArgumentException data class Blizzard(val coord: Coord, val direction: Direction) { fun move(lastFreeX: Int, lastFreeY: Int): Blizzard { var newCoord = this.coord.move(this.direction) when { ...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
4,681
advent-of-code-2022
MIT License
src/Day11.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.util.* import java.util.function.IntUnaryOperator import java.util.function.LongToIntFunction import java.util.function.LongUnaryOperator import kotlin.collections.HashMap fun main() { val testInput = """ Monkey 0: Starting items: 79, 98 Operation: new = old * 19 Test: divisible by 23 If true...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
4,624
advent-of-code-2022-kotlin
Apache License 2.0
src/Day11.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
class Remainder(divisors: List<Int>, value: Int) { val map: MutableMap<Int, Int> = divisors.associateWith { 0 }.toMutableMap() var full: Long = 0 init { add(value) } fun put(divisor: Int, value: Int) { if (map.containsKey(divisor)) map[divisor] = value else erro...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
6,486
AoC-2022
Apache License 2.0
calendar/day11/Day11.kt
rocketraman
573,845,375
false
{"Kotlin": 45660}
package day11 import Day import Lines class Day11 : Day() { data class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val test: MonkeyTest, var inspections: Long = 0, ) data class MonkeyTest( val testDivisibleBy: Long, val nextTrue: Int, val nextFalse: Int, )...
0
Kotlin
0
0
6bcce7614776a081179dcded7c7a1dcb17b8d212
3,247
adventofcode-2022
Apache License 2.0
src/main/kotlin/nl/meine/aoc/_2022/Day5.kt
mtoonen
158,697,380
false
{"Kotlin": 201978, "Java": 138385}
package nl.meine.aoc._2022 data class Instruction(val num: Int, val from: Int, val to : Int) class Day5 { fun one(start: String, instructions: String): String { val pos = parsePositions(start) var ins = instructions .split("\n") .map{parseProcedure(it)} .map { m...
0
Kotlin
0
0
a36addef07f61072cbf4c7c71adf2236a53959a5
12,621
advent-code
MIT License
src/Day04.kt
kedvinas
572,850,757
false
{"Kotlin": 15366}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { var sum = 0 for (i in input) { val (a, b) = i.split(",") val (ax, ay) = a.split("-").map { it.toInt() } val (bx, by) = b.split("-").map { it.toInt() } ...
0
Kotlin
0
0
04437e66eef8cf9388fd1aaea3c442dcb02ddb9e
1,012
adventofcode2022
Apache License 2.0
src/main/kotlin/day09/day09.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package main.day09 import utils.readFile import utils.readLines import utils.separator import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.sign fun main() { val test = """R 4 U 4 L 3 D 1 R 4 D 1 L 5 R 2""" val test2 = """R 5 U 8 L 8 D 3 R 17 D 10 L 25 U 20""" val input = re...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
5,519
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin2023/Day004.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
package main.kotlin2023 import kotlin.math.pow class Day004 { fun part1(lines: List<String>): Int { val objects = lines.map { line -> line.dropWhile { it != ':' } .split('|') .map { subString -> subString.split(' ') ....
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
1,520
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/Day11.kt
SimonMarquis
570,868,366
false
{"Kotlin": 50263}
class Day11(input: List<String>) { private val monkeys: List<Monkey> = input.windowed(size = 6, 7).map { Monkey( items = it[1].substringAfter("Starting items: ").split(", ") .map(String::toLong).let(::ArrayDeque), operation = it[2].run { val strings =...
0
Kotlin
0
0
a2129cc558c610dfe338594d9f05df6501dff5e6
2,699
advent-of-code-2022
Apache License 2.0
src/day02/kotlin/aoc2023-02/src/main/kotlin/Main.kt
JoubaMety
726,095,975
false
{"Kotlin": 17724}
/** * Loads input text-file from src/main/resources */ fun getResourceAsText(path: String): String? = object {}.javaClass.getResource(path)?.readText() fun main() { /* val input = "Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green\n" + "Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1...
0
Kotlin
0
0
1f883bbbbed64f285b0d3cf7f51f6fb3a1a0e966
3,563
AdventOfCode-2023
MIT License
src/main/kotlin/twenty/three/03.kt
itsabdelrahman
726,503,458
false
{"Kotlin": 8123}
package twenty.three import java.io.File import utilities.andThen fun main() { val characterMatrix: List<List<EngineSchematicCharacter>> = File("src/main/resources/twenty/three/03/1.txt") .readLines() .map { row -> row.toCharArray().map(EngineSchematicCharacter::from) } val symbolAdjacentIndi...
0
Kotlin
0
0
81765d658ca1dd77b5e5418167ee519460baa4a5
4,161
advent-of-code
Creative Commons Zero v1.0 Universal
17/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Target { val input = File("input.txt") .readText() val xRegex = """x=(-?\d+)..(-?\d+)""".toRegex() val yRegex = """y=(-?\d+)..(-?\d+)""".toRegex() val (miniX, maxiX) = xRegex.find(input)?.destructured!! val (miniY, maxiY) = yRegex.find(input)?.destruc...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
1,745
advent-of-code-2021
MIT License
src/main/kotlin/com/colinodell/advent2021/Day08.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 class Day08 (input: List<String>) { private val inputs = input.map { Entry(it) } private val uniqueSegmentLengths = setOf(2, 3, 4, 7) // 1, 7, 4, and 8 each have a unique segment length compared to other numbers fun solvePart1(): Int = inputs.sumOf { it.outputValues.coun...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
3,412
advent-2021
Apache License 2.0
src/main/java/com/ncorti/aoc2021/Exercise10.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 import java.util.Stack object Exercise10 { fun part1() = getInputAsTest("10") { split("\n") } .map { val stack = Stack<Char>() val chars = it.toCharArray().toMutableList() stack.push(chars.removeFirst()) ...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
2,575
adventofcode-2021
MIT License
src/Day10.kt
thelmstedt
572,818,960
false
{"Kotlin": 30245}
import java.io.File sealed class Instruction { object Noop : Instruction() data class Addx(val x: Int) : Instruction() } fun main() { fun part1(text: String) { val instructions = text.lineSequence() .filter { it.isNotBlank() } .map { when (it) { ...
0
Kotlin
0
0
e98cd2054c1fe5891494d8a042cf5504014078d3
3,298
advent2022
Apache License 2.0
src/main/kotlin/days/aoc2016/Day1.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2016 import days.Day import kotlin.math.absoluteValue class Day1 : Day(2016, 1) { override fun partOne(): Any { return calculateDistanceForDirections(inputString) } override fun partTwo(): Any { return findFirstLocationVisitedTwice(inputString) } fun calculateDist...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,958
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/aoc23/day04.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc23 import getIntegerListsSplitBy import pow import runTask import toOnlyInteger import toSets import utils.InputReader import kotlin.math.max fun day4part1(input: List<String>): Int = input.sumOf { getScratchCard(it).getScore() } fun day4part2(input: List<String>): Int { val scratchCar...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
1,697
advent-of-code
Apache License 2.0
src/main/kotlin/g2501_2600/s2503_maximum_number_of_points_from_grid_queries/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2503_maximum_number_of_points_from_grid_queries // #Hard #Array #Sorting #Breadth_First_Search #Heap_Priority_Queue #Union_Find // #2023_07_04_Time_581_ms_(100.00%)_Space_62.6_MB_(100.00%) import java.util.ArrayDeque import java.util.Arrays import java.util.PriorityQueue import java.util.Queue cl...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,054
LeetCode-in-Kotlin
MIT License
src/Day11.kt
jorander
571,715,475
false
{"Kotlin": 28471}
private data class Item(val worryLevel: Long) { fun relieved(): Item { return Item(worryLevel / 3L) } } private data class TestedItem(val item: Item, val action: (Item, Array<Monkey>) -> Unit) private data class Monkey( val items: List<Item>, val operation: (Item) -> Item, val testValue: L...
0
Kotlin
0
0
1681218293cce611b2c0467924e4c0207f47e00c
4,289
advent-of-code-2022
Apache License 2.0
src/day09/Day09.kt
PoisonedYouth
571,927,632
false
{"Kotlin": 27144}
package day09 import readInput import kotlin.math.sign private data class Point( val x: Int, val y: Int, ) { private fun move(x: Int = 0, y: Int = 0): Point { return this.copy( x = this.x + x, y = this.y + y ) } fun isNotTouching(other: Point): Boolean { ...
0
Kotlin
1
0
dbcb627e693339170ba344847b610f32429f93d1
2,499
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/sorts/QuickSort.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,941
kotlab
Apache License 2.0
src/Day02.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
private const val SCISSORS_RESP = "Z" private const val ROCK_RESP = "X" private const val PAPER__RESP = "Y" private const val PAPER = "B" private const val ROCK = "A" private const val SCISSORS = "C" private const val WIN = "Z" private const val LOSE = "X" private const val DRAW = "Y" fun main() { fun pa...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
2,069
advent-2022
Apache License 2.0
src/Day18.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
import javax.swing.JOptionPane fun main() { val input = readInput("Day18") printTime { print(Day18.part1(input)) } printTime { print(Day18.part1Bitwise(input)) } printTime { print(Day18.part2(input)) } } class Day18 { companion object { fun part1(input: List<String>): Int { v...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
5,410
advent-of-code-22
Apache License 2.0
src/main/kotlin/aoc2023/Day25.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import org.jgrapht.alg.clustering.GirvanNewmanClustering import org.jgrapht.graph.DefaultEdge import org.jgrapht.graph.DefaultUndirectedGraph import java.lang.IllegalStateException class Day25 { fun part1(input: List<String>): Int { val parsedGraph = parseInput(input) val vertices ...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
1,683
advent-of-code-2023
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumProduct.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,120
kotlab
Apache License 2.0
src/day12/Day12.kt
quinlam
573,215,899
false
{"Kotlin": 31932}
package day12 import utils.ArrayMovement import utils.Day /** * Actual answers after submitting; * part1: 420 * part2: 414 */ class Day12 : Day<Int, Array<Array<Char>>>( testPart1Result = 31, testPart2Result = 29, ) { override fun part1Answer(input: Array<Array<Char>>): Int { val endNode = fin...
0
Kotlin
0
0
d304bff86dfecd0a99aed5536d4424e34973e7b1
2,613
advent-of-code-2022
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day10/Day10.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day10 import eu.janvdb.aocutil.kotlin.readLines import kotlin.math.abs //const val FILENAME = "input10-test.txt" const val FILENAME = "input10.txt" const val WIDTH = 40 const val HEIGHT = 6 fun main() { val instructions = readLines(2022, FILENAME) .map(String::toInstruction) val comput...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,819
advent-of-code
Apache License 2.0
src/Day02.kt
Lonexera
573,177,106
false
null
fun main() { fun String.mapYourChoiceToRockPaperScissors(): RockPaperScissors { return when (this) { "X" -> RockPaperScissors.ROCK "Y" -> RockPaperScissors.PAPER "Z" -> RockPaperScissors.SCISSORS else -> error("This input is not allowed - $this!") } ...
0
Kotlin
0
0
c06d394cd98818ec66ba9c0311c815f620fafccb
3,560
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch6/Problem64.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch6 import kotlin.math.sqrt import kotlin.math.truncate /** * Problem 64: Odd Period Square Roots * * https://projecteuler.net/problem=64 * * Goal: Count how many continued fraction representations of irrational square roots of * numbers <= N have an odd-length period (repeated sequence)....
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,599
project-euler-kotlin
MIT License