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/Day13.kt | asm0dey | 572,860,747 | false | {"Kotlin": 61384} | import Node13.Leaf
import Node13.NodeList
fun main() {
fun parse(tokens: ArrayDeque<String>): Node13 {
val mutable = arrayListOf<Node13>()
while (tokens.isNotEmpty()) {
when (val token = tokens.removeFirst()) {
"]" -> return NodeList(mutable)
"[" -> mut... | 1 | Kotlin | 0 | 1 | f49aea1755c8b2d479d730d9653603421c355b60 | 3,520 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/day21.kt | tobiasae | 434,034,540 | false | {"Kotlin": 72901} | class Day21 : Solvable("21") {
override fun solveA(input: List<String>): String {
val (player1, player2) = getPlayers(input)
val dice = DeterministicDie()
var count = 0
while (true) {
player1.play(dice.roll() + dice.roll() + dice.roll())
if (player1.score >= ... | 0 | Kotlin | 0 | 0 | 16233aa7c4820db072f35e7b08213d0bd3a5be69 | 2,385 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/Day02.kt | ty-garside | 573,030,387 | false | {"Kotlin": 75779} | // Rock Paper Scissors
// https://adventofcode.com/2022/day/2
// * Enhanced to support Lizard and Spock
object Rock : Shape({
it("breaks", Scissors)
it("crushes", Lizard)
})
object Paper : Shape({
it("covers", Rock)
it("disproves", Spock)
})
object Scissors : Shape({
it("cuts", Paper)
it("dec... | 0 | Kotlin | 0 | 0 | 49ea6e3ad385b592867676766dafc48625568867 | 7,078 | aoc-2022-in-kotlin | Apache License 2.0 |
advent-of-code/src/main/kotlin/DayNine.kt | pauliancu97 | 518,083,754 | false | {"Kotlin": 36950} | import kotlin.math.max
import kotlin.math.min
private typealias Graph = Map<String, DayNine.Node>
private fun getPermutationsHelper(
currentPermutation: List<String>,
availableElements: List<String>,
permutations: MutableList<List<String>>
) {
if (availableElements.isEmpty()) {
permutations.ad... | 0 | Kotlin | 0 | 0 | 3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6 | 4,865 | advent-of-code-2015 | MIT License |
dsalgo/src/commonMain/kotlin/com/nalin/datastructurealgorithm/problems/AE_List.kt | nalinchhajer2 | 481,901,695 | false | {"Kotlin": 25247, "Ruby": 1605} | package com.nalin.datastructurealgorithm.problems
import com.nalin.datastructurealgorithm.ds.LinkedListNode
import kotlin.math.max
import kotlin.math.min
/**
* Merge overlapping intervals. They are not likely to be in order
*/
fun mergeOverlappingIntervals(intervals: List<List<Int>>): List<List<Int>> {
val sort... | 0 | Kotlin | 0 | 0 | 84a071cd15f8eab1ec8425060570691315c103f9 | 3,505 | kotlin-ds-algo | MIT License |
Advent-of-Code-2023/src/Day09.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | private const val AOC_DAY = "Day09"
private const val TEST_FILE = "${AOC_DAY}_test"
private const val INPUT_FILE = AOC_DAY
/**
* Gets the next backwards or forwards value in the sequence. First is calculated the difference between each number in
* the sequence, then the next value is calculated recursively.
*/
pri... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 1,983 | Advent-of-Code-2023 | Apache License 2.0 |
src/Day04.kt | jgodort | 573,181,128 | false | null | fun main() {
val inputData = readInput("Day4_input")
println(day4Part1(inputData))
println(day4Part2(inputData))
}
private fun convertToRange(value: String): IntRange {
val elements = value.split("-")
.map { it.toInt() }
.sorted()
return IntRange(elements.component1(), elements.comp... | 0 | Kotlin | 0 | 0 | 355f476765948c79bfc61367c1afe446fe9f6083 | 1,235 | aoc2022Kotlin | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2023/day23/day23.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2023.day23
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val hikingTrails = parseHikingTrails(lines)
println("Longest path has ${findLongestPathLen(hikingTrails)} steps")
... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,272 | advent-of-code | MIT License |
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day21/Day21.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.aoc2021.day21
import nl.sanderp.aoc.common.increaseBy
import nl.sanderp.aoc.common.measureDuration
import nl.sanderp.aoc.common.prettyPrint
import kotlin.math.min
fun main() {
val initialGame = Game(8, 0, 7, 0)
val (answer1, duration1) = measureDuration<Int> { partOne(initialGame) }
... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 3,081 | advent-of-code | MIT License |
src/Day02.kt | D000L | 575,350,411 | false | {"Kotlin": 23716} | enum class RPS(val point: Int) {
Rock(1), Paper(2), Scissors(3);
companion object {
fun from(word: String): RPS {
return when (word) {
"A", "X" -> Rock
"B", "Y" -> Paper
else -> Scissors
}
}
}
}
enum class Result(val p... | 0 | Kotlin | 0 | 0 | b733a4f16ebc7b71af5b08b947ae46afb62df05e | 2,089 | adventOfCode | Apache License 2.0 |
src/main/kotlin/aoc2023/day17/day17Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day17
import lib.*
import lib.graph.Graph
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<Array<Array<Int>>> {
return setup {
day(17)
year(2023)
//input("example.txt")
parser {
it.readLines().get2DArrayOfCo... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 4,524 | AoC-2023-DDJ | MIT License |
src/day11/Day11.kt | spyroid | 433,555,350 | false | null | package day11
import readInput
import kotlin.system.measureTimeMillis
fun main() {
data class Point(val x: Int, val y: Int, var v: Int) {
fun inc(): Int {
if (v == 9) v = 0 else v++
return v
}
}
class Area(input: List<String>) {
val points = readPoints(in... | 0 | Kotlin | 0 | 0 | 939c77c47e6337138a277b5e6e883a7a3a92f5c7 | 3,010 | Advent-of-Code-2021 | Apache License 2.0 |
src/Day02.kt | Totwart123 | 573,119,178 | false | null | fun main() {
val duells = mutableListOf(
0 to listOf(Pair('A', 'Z'), Pair('B', 'X'), Pair('C', 'Y')),
3 to listOf(Pair('A', 'X'), Pair('B', 'Y'), Pair('C', 'Z')),
6 to listOf(Pair('A', 'Y'), Pair('B', 'Z'), Pair('C', 'X')),
)
fun part1(input: List<String>): Int {
return inpu... | 0 | Kotlin | 0 | 0 | 33e912156d3dd4244c0a3dc9c328c26f1455b6fb | 1,816 | AoC | Apache License 2.0 |
src/day11/day11.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day11
import readInput
import java.util.*
private fun parse(input: List<String>): List<Monkey> {
fun parseItems(line: String): MutableList<Long> {
val result = mutableListOf<Long>()
val parts = line.split(":")
val items = parts[1].split(",")
for (part in items) {
... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 3,385 | aoc-2022 | Apache License 2.0 |
src/y2023/Day07.kt | a3nv | 574,208,224 | false | {"Kotlin": 34115, "Java": 1914} | package y2023
import utils.readInput
val WEIGHTS = "23456789TJQKA".mapIndexed { index, it -> it to index + 2 }.toMap()
class Hand(private val hand: String, val bid: Long) {
fun handStrength(): Int {
val cardWeights = hand.map { WEIGHTS[it] }
val combos = cardWeights.groupingBy { it }.eachCount()... | 0 | Kotlin | 0 | 0 | ab2206ab5030ace967e08c7051becb4ae44aea39 | 1,922 | advent-of-code-kotlin | Apache License 2.0 |
Advent-of-Code-2023/src/Day07.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | private const val AOC_DAY = "Day07"
private const val TEST_FILE = "${AOC_DAY}_test"
private const val INPUT_FILE = AOC_DAY
private data class Hand(val cards: String, val bid: Int, val typeStrength: Int)
private fun relativeStrengthMap(withJokers: Boolean = false) = mapOf(
'A' to 13,
'K' to 12,
'Q' to 11,
... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 4,546 | Advent-of-Code-2023 | Apache License 2.0 |
src/y2021/Day03.kt | Yg0R2 | 433,731,745 | false | null | package y2021
fun main() {
fun part1(input: List<String>): Int {
val gammaRate = input[0]
.mapIndexed { index, _ -> input.getMostCommonBit(index) }
.joinToString("")
.toInt(2)
val epsilonRate = input[0]
.mapIndexed { index, _ -> input.getLeastCommonB... | 0 | Kotlin | 0 | 0 | d88df7529665b65617334d84b87762bd3ead1323 | 2,617 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day9/Day9.kt | jakubgwozdz | 571,298,326 | false | {"Kotlin": 85100} | package day9
import execute
import readAllText
import wtf
import kotlin.math.sign
enum class Direction { U, D, L, R }
data class Pos(val r: Int, val c: Int) {
fun isAdjacent(other: Pos) = (r - other.r) in (-1..1) && (c - other.c) in (-1..1)
fun moveTowards(other: Pos) = Pos(r + (other.r - r).sign, c + (other.... | 0 | Kotlin | 0 | 0 | 7589942906f9f524018c130b0be8976c824c4c2a | 2,213 | advent-of-code-2022 | MIT License |
src/Day02.kt | dizney | 572,581,781 | false | {"Kotlin": 105380} |
const val SCORE_ROCK = 1
const val SCORE_PAPER = 2
const val SCORE_SCISSORS = 3
const val DRAW = 'Y'
const val LOSE = 'X'
const val WIN = 'Z'
const val EXPECTED_PART1_CHECK_ANSWER = 15
const val EXPECTED_PART2_CHECK_ANSWER = 12
const val POS_THEIR_CHOICE = 0
const val POS_OUR_CHOICE = 2
const val SCORE_WIN = 6
con... | 0 | Kotlin | 0 | 0 | f684a4e78adf77514717d64b2a0e22e9bea56b98 | 2,201 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | hanmet | 573,490,488 | false | {"Kotlin": 9896} | fun main() {
fun calcPoints2(opponentsShape: String, game: String): Int {
return when {
opponentsShape == "A" && game == "X" -> 3 + 0
opponentsShape == "A" && game == "Y" -> 1 + 3
opponentsShape == "A" && game == "Z" -> 2 + 6
opponentsShape == "B" && game == ... | 0 | Kotlin | 0 | 0 | e4e1722726587639776df86de8d4e325d1defa02 | 1,932 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/day18/Day18.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2022.day18
import check
import readInput
import kotlin.math.abs
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("2022", "Day18_test")
check(part1(testInput), 64)
check(part2(testInput), 58)
val input = readInput("2022", "Day1... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 3,140 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/aoc2023/Day06.kt | Ceridan | 725,711,266 | false | {"Kotlin": 110767, "Shell": 1955} | package aoc2023
class Day06 {
fun part1(input: List<String>): Long = parseRaces(input)
.map { race -> (1L..race.time).map { t -> (race.time - t) * t }.count { it > race.distance } }
.fold(1L) { acc, r -> acc * r }
fun part2(input: List<String>): Long {
val (time, distance) = parseRace(... | 0 | Kotlin | 0 | 0 | 18b97d650f4a90219bd6a81a8cf4d445d56ea9e8 | 1,568 | advent-of-code-2023 | MIT License |
src/Day12.kt | wujingwe | 574,096,169 | false | null | typealias Point = Pair<Int, Int>
object Day12 {
private val DIRS = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
private fun bfs(map: List<List<Char>>, start: Point, end: Point): Int {
val m = map.size
val n = map[0].size
val visited = MutableList(m) { MutableList(n) { false } }
va... | 0 | Kotlin | 0 | 0 | a5777a67d234e33dde43589602dc248bc6411aee | 3,060 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day14.kt | bananer | 434,885,332 | false | {"Kotlin": 36979} | typealias Rules = Map<Pair<Char, Char>, Char>
fun Rules.get(c1: Char, c2: Char): Char? = get(Pair(c1, c2))
fun main() {
fun parseInput(input: List<String>): Pair<String, Rules> {
check(input[1].isEmpty())
val rules = mutableMapOf<Pair<Char, Char>, Char>()
input.subList(2, input.size).forE... | 0 | Kotlin | 0 | 0 | 98f7d6b3dd9eefebef5fa3179ca331fef5ed975b | 1,983 | advent-of-code-2021 | Apache License 2.0 |
src/Day06.kt | Miguel1235 | 726,260,839 | false | {"Kotlin": 21105} | private class Race(val time: Long, val record: Long)
private fun parseInput(input: List<String>): List<Race> {
val dRegex = Regex("""\d+""")
val times = dRegex.findAll(input[0]).map { it.value.toLong() }.toList()
val records = dRegex.findAll(input[1]).map { it.value.toLong() }.toList()
val races: Muta... | 0 | Kotlin | 0 | 0 | 69a80acdc8d7ba072e4789044ec2d84f84500e00 | 1,420 | advent-of-code-2023 | MIT License |
src/Day16.kt | rod41732 | 572,917,438 | false | {"Kotlin": 85344} | import kotlin.math.max
import kotlin.math.pow
data class Day16State(val myPos: Int, val elephantPos: Int, val valveStates: Int) {
fun nextPossibleStates(adj: List<List<Int>>, nonEmptyCount: Int) = sequence<Day16State> {
if (myPos < nonEmptyCount) {
yield(copy(valveStates = valveStates or (1 shl... | 0 | Kotlin | 0 | 0 | 1d2d3d00e90b222085e0989d2b19e6164dfdb1ce | 6,280 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day07_alt1.kt | zodiia | 573,067,225 | false | {"Kotlin": 11268} | package day07alt1
import readInput
enum class FsNodeType { FILE, DIR }
data class FsNode(
var size: Long,
val type: FsNodeType,
val childNodes: HashMap<String, FsNode> = HashMap(),
) {
private val childDirs: Collection<FsNode> get() = childNodes.filter { it.value.type == FsNodeType.DIR }.map { it.val... | 0 | Kotlin | 0 | 1 | 4f978c50bb7603adb9ff8a2f0280f8fdbc652bf2 | 2,178 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | mvmlisb | 572,859,923 | false | {"Kotlin": 14994} | private data class Directory(val parent: Directory?, val name: String) {
private var directories = mutableListOf<Directory>()
private var sizeOnCurrentLevel = 0L
companion object {
fun createFromCdCommand(string: String, rootDirectory: Directory, currentDirectory: Directory): Directory {
... | 0 | Kotlin | 0 | 0 | 648d594ec0d3b2e41a435b4473b6e6eb26e81833 | 2,036 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day07.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import utils.InputUtils
sealed class Day07 {
abstract fun size(): Int
data class Directory(val name: String, val parent: Directory?, val contents: MutableList<Day07> = mutableListOf()) :
Day07() {
override fun size(): Int = contents.sumOf { it.size() }
fun dirs() = cont... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,797 | aoc-2022-kotlin | Apache License 2.0 |
lib/src/main/kotlin/com/bloidonia/advent/day15/Day15.kt | timyates | 433,372,884 | false | {"Kotlin": 48604, "Groovy": 33934} | package com.bloidonia.advent.day15
import com.bloidonia.advent.readList
import java.util.PriorityQueue
import kotlin.math.abs
typealias Position = Pair<Int, Int>
operator fun Position.plus(pos: Position) = Position(this.first + pos.first, this.second + pos.second)
class Cave(private val width: Int, private val cost... | 0 | Kotlin | 0 | 1 | 9714e5b2c6a57db1b06e5ee6526eb30d587b94b4 | 2,767 | advent-of-kotlin-2021 | MIT License |
src/Day15.kt | frango9000 | 573,098,370 | false | {"Kotlin": 73317} | import kotlin.math.absoluteValue
fun main() {
val input = readInput("Day15")
printTime { print(Day15.part1(input, 2_000_000)) }
printTime { print(Day15.part2(input, 4_000_000)) }
}
class Day15 {
companion object {
fun part1(input: List<String>, targetY: Int): Int {
val sensorsAndBe... | 0 | Kotlin | 0 | 0 | 62e91dd429554853564484d93575b607a2d137a3 | 5,142 | advent-of-code-22 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2020/Day11.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2020
import com.s13g.aoc.*
/**
* --- Day 11: Seating System ---
* https://adventofcode.com/2020/day/11
*/
class Day11 : Solver {
override fun solve(lines: List<String>): Result {
val dim = XY(lines[0].length, lines.size)
val map = mutableMapOf<XY, Char>()
lines.indices.forEach... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,658 | euler | Apache License 2.0 |
src/Day12.kt | jimmymorales | 572,156,554 | false | {"Kotlin": 33914} | import kotlin.collections.ArrayDeque
fun main() {
fun Pair<Int, Int>.neighbors(): List<Pair<Int, Int>> = buildList {
add(first + 1 to second)
add(first to second + 1)
add(first - 1 to second)
add(first to second - 1)
}
fun Array<IntArray>.search(start: Pair<Int, Int>, end: ... | 0 | Kotlin | 0 | 0 | fb72806e163055c2a562702d10a19028cab43188 | 2,766 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | a2xchip | 573,197,744 | false | {"Kotlin": 37206} | private fun String.toRange(): IntRange {
val (from, to) = this.split("-").map { it.toInt() }
return from..to
}
fun toRangePairs(line: String): Pair<IntRange, IntRange> {
val (a, b) = line.split(",")
return a.toRange() to b.toRange()
}
fun fullyOverlaps(pair: Pair<IntRange, IntRange>): Boolean {
va... | 0 | Kotlin | 0 | 2 | 19a97260db00f9e0c87cd06af515cb872d92f50b | 1,221 | kotlin-advent-of-code-22 | Apache License 2.0 |
src/year2021/14/Day14.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2021.`14`
import readInput
// region Parsing
private fun parseInput(input: List<String>): String = input.first()
private fun parseMapper(input: List<String>): Transformations {
val transformations = input.drop(2)
return transformations.associate { transformationString ->
val (left, righ... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 2,848 | KotlinAdventOfCode | Apache License 2.0 |
src/day05/day06.kt | barbulescu | 572,834,428 | false | {"Kotlin": 17042} | package day05
import readInput
import java.lang.IllegalArgumentException
fun main() {
val lines = readInput("day05/Day05")
val (stackLines, operationLines) = splitLines(lines)
val stacks = buildStacks(stackLines)
buildOperations(operationLines, stacks.size())
.forEach(stacks::operate)
p... | 0 | Kotlin | 0 | 0 | 89bccafb91b4494bfe4d6563f190d1b789cde7a4 | 2,555 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day07/Day07.kt | skokovic | 573,361,100 | false | {"Kotlin": 12166} | package day07
import readInput
data class FileNode(val name: String, val parent: FileNode? = null, val children: MutableList<FileNode> = mutableListOf(), var size: Int = 0)
fun createFileTree(lines: List<String>): List<FileNode> {
val root = FileNode("/")
val nodes = mutableListOf(root)
var current = roo... | 0 | Kotlin | 0 | 0 | fa9aee3b5dd09b06bfd5c232272682ede9263970 | 1,862 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2023/Day05.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
import kotlin.math.max
import kotlin.math.min
class Day05(input: List<String>) {
private data class Map(val ranges: List<Range>) {
fun apply(input: List<LongRange>): List<LongRange> {
val rangesToMap = input.toMutableList()
// Map each source rang... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 3,205 | advent-2023 | MIT License |
src/main/kotlin/solutions/Day8TreetopTreeHouse.kt | aormsby | 571,002,889 | false | {"Kotlin": 80084} | package solutions
import models.Coord2d
import utils.Collections
import utils.Input
import utils.Solution
// run only this day
fun main() {
Day8TreetopTreeHouse()
}
class Day8TreetopTreeHouse : Solution() {
init {
begin("Day 8 - Treetop Tree House")
val rows = Input.parseTo2dList<Int>(filena... | 0 | Kotlin | 0 | 0 | 1bef4812a65396c5768f12c442d73160c9cfa189 | 2,961 | advent-of-code-2022 | MIT License |
src/Day02.kt | jordan-thirus | 573,476,470 | false | {"Kotlin": 41711} | fun main() {
fun part1(input: List<String>): Int {
val scores = buildMap {
put(OpponentPlay.ROCK,
mapOf(
Play.ROCK to Play.ROCK.score + Outcome.DRAW.score,
Play.PAPER to Play.PAPER.score + Outcome.WIN.score,
Play.SCISSO... | 0 | Kotlin | 0 | 0 | 59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e | 3,899 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | andrikeev | 574,393,673 | false | {"Kotlin": 70541, "Python": 18310, "HTML": 5558} | fun main() {
fun part1(input: List<String>): Int {
return HeightsGrid.parse(input).countMinStepsFromS()
}
fun part2(input: List<String>): Int {
return HeightsGrid.parse(input).countMinStepsFromA()
}
// test if implementation meets criteria from the description, like:
val testIn... | 0 | Kotlin | 0 | 1 | 1aedc6c61407a28e0abcad86e2fdfe0b41add139 | 3,207 | aoc-2022 | Apache License 2.0 |
src/Day03.kt | lonskiTomasz | 573,032,074 | false | {"Kotlin": 22055} | fun main() {
/**
* The ASCII value of lowercase alphabets are from 97 to 122. 'a' (97) to 'z' (122)
* And, the ASCII value of uppercase alphabets are from 65 to 90. 'A' (65) to 'Z' (90)
*
* Lowercase item types a through z have priorities 1 through 26.
* Uppercase item types A through Z ha... | 0 | Kotlin | 0 | 0 | 9e758788759515049df48fb4b0bced424fb87a30 | 1,627 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/Day15.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day15
import geometry.Position
import geometry.manhattenDistance
import geometry.x
import geometry.y
import utils.readInput
import kotlin.math.absoluteValue
data class Sensor(val position: Position, val beacon: Position) {
private val radius = beacon.manhattenDistance(position)
fun slice(y: Int): Int... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 2,304 | aoc-2022 | Apache License 2.0 |
src/main/Day22.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day22
import geometry.Direction
import geometry.Position
import geometry.x
import geometry.y
import utils.readInput
enum class Tile {
OPEN,
WALL
}
typealias Board = Map<Position, Tile>
fun Iterable<String>.readBoard(): Board =
withIndex()
.flatMap { (i, row) ->
row.withIndex(... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 3,807 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | mcdimus | 572,064,601 | false | {"Kotlin": 32343} | import util.readInput
fun main() {
fun part1(input: List<String>): Long {
val root = parse(input)
return root.findRecursiveFoldersNotLargerThan(100000).sumOf(Node.Folder::getSize)
}
fun part2(input: List<String>): Long {
val root = parse(input)
val needToFree = root.getSize... | 0 | Kotlin | 0 | 0 | dfa9cfda6626b0ee65014db73a388748b2319ed1 | 3,890 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | Miguel1235 | 726,260,839 | false | {"Kotlin": 21105} | private class Card(val id: Int, val winningNumbers: List<Int>, val ownNumbers: List<Int>) {
val ownWinnerNumbers = winningNumbers.filter { w -> ownNumbers.contains(w) }
val points = calculatePoints(ownWinnerNumbers.size)
private fun calculatePoints(size: Int): Int {
if (size <= 2) return size
... | 0 | Kotlin | 0 | 0 | 69a80acdc8d7ba072e4789044ec2d84f84500e00 | 1,870 | advent-of-code-2023 | MIT License |
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day05.kt | loehnertz | 573,145,141 | false | {"Kotlin": 53239} | package codes.jakob.aoc
import codes.jakob.aoc.shared.*
import java.util.*
class Day05 : Solution() {
override fun solvePart1(input: String): Any {
val (stacksById: Map<CrateStack, Stack<Crate>>, instructions: List<Instruction>) = parseInput(input)
for (instruction: Instruction in instructions) {... | 0 | Kotlin | 0 | 0 | ddad8456dc697c0ca67255a26c34c1a004ac5039 | 2,903 | advent-of-code-2022 | MIT License |
app/src/main/kotlin/codes/jakob/aoc/solution/Day03.kt | loehnertz | 725,944,961 | false | {"Kotlin": 59236} | package codes.jakob.aoc.solution
import codes.jakob.aoc.shared.*
object Day03 : Solution() {
private val symbolPattern = Regex("[^.\\d]")
private val gearPattern = Regex("\\*")
override fun solvePart1(input: String): Any {
return input
.parseGrid { it }
.cells
... | 0 | Kotlin | 0 | 0 | 6f2bd7bdfc9719fda6432dd172bc53dce049730a | 4,632 | advent-of-code-2023 | MIT License |
src/Day02.kt | devheitt | 573,207,407 | false | {"Kotlin": 11944} | enum class Options(val score: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
companion object {
private val winConditions = mapOf(
Pair(ROCK, PAPER),
Pair(SCISSORS, ROCK),
Pair(PAPER, SCISSORS)
)
private val loseConditions = mapOf(
Pair(PAPER, ROC... | 0 | Kotlin | 0 | 0 | a9026a0253716d36294709a547eaddffc6387261 | 2,478 | advent-of-code-2022-kotlin | Apache License 2.0 |
2021/src/day08/Solution.kt | vadimsemenov | 437,677,116 | false | {"Kotlin": 56211, "Rust": 37295} | package day08
import java.nio.file.Files
import java.nio.file.Paths
fun main() {
fun part1(lines: Input): Int {
return lines.sumOf { entry ->
val (_, reading) = entry.split("|")
reading.split(" ")
.filter { it.isNotBlank() }
.count { it.length in setOf(2, 3, 4, 7) }
}
}
fun ... | 0 | Kotlin | 0 | 0 | 8f31d39d1a94c862f88278f22430e620b424bd68 | 2,091 | advent-of-code | Apache License 2.0 |
2022/Day19/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import kotlin.math.*
data class Resources(val ore: Int, val clay: Int, val obsidian: Int) {
operator fun plus(r: Resources): Resources {
return Resources(ore + r.ore, clay + r.clay, obsidian + r.obsidian)
}
operator fun minus(r: Resources): Resources {
return Resources(... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 6,076 | AdventOfCode | MIT License |
src/main/kotlin/solutions/day16/Day16.kt | Dr-Horv | 570,666,285 | false | {"Kotlin": 115643} | package solutions.day16
import solutions.Solver
import utils.searchBreathFirst
data class Valve(val name: String, val flowRate: Int, val neighbourValves: MutableList<Valve>) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return fals... | 0 | Kotlin | 0 | 2 | 6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e | 4,843 | Advent-of-Code-2022 | MIT License |
aoc21/day_19/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
import kotlin.math.abs
enum class Axe {
X, Y, Z;
companion object {
fun allRotations(): List<List<Axe>> = listOf(
// facing
listOf(), // x
listOf(Axe.Y, Axe.Y), // -x
listOf(Axe.Z), // y
listOf(Axe.Z, Axe.Z, Axe.Z), // -y
... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 3,280 | advent-of-code | MIT License |
src/Day04.kt | rbraeunlich | 573,282,138 | false | {"Kotlin": 63724} | fun main() {
fun part1(input: List<String>): Int {
var overlaps = 0
input.forEach { line ->
val pair = line.split(",").let { it[0] to it[1] }
val firstRange = pair.first.split("-").let {
it[0].toInt()..it[1].toInt()
}
val secondRange = ... | 0 | Kotlin | 0 | 1 | 3c7e46ddfb933281be34e58933b84870c6607acd | 1,798 | advent-of-code-2022 | Apache License 2.0 |
src/y2023/Day07.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2023
import util.readInput
import util.timingStatistics
object Day07 {
private val nonNumbers = mapOf(
'T' to 10,
'J' to 11,
'Q' to 12,
'K' to 13,
'A' to 14
)
private val nonNumbers2 = mapOf(
'J' to 1,
'T' to 10,
'Q' to 11,
... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,443 | advent-of-code | Apache License 2.0 |
src/Day07.kt | benwicks | 572,726,620 | false | {"Kotlin": 29712} | fun main() {
fun buildFilesystemTree(input: List<String>): FilesystemNode.Directory {
val filesystemTree: FilesystemNode.Directory = FilesystemNode.Directory(null, "/")
var currentDirectory = filesystemTree
for (line in input) {
if (line.startsWith("$ cd ")) {
va... | 0 | Kotlin | 0 | 0 | fbec04e056bc0933a906fd1383c191051a17c17b | 4,311 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2022/Day20.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2022
import readInput
// input contains duplicates, so keep the original index
data class MixedNumber(val value: Long, val originalIndex: Int)
private fun mixNumbers(original: LongArray, rounds: Int): List<Long> {
val list = original.withIndex().map { MixedNumber(it.value, it.index) }.toMutableList()
... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 1,618 | adventOfCode | Apache License 2.0 |
2015/src/main/kotlin/day13.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parse
import utils.Parser
import utils.Solution
import utils.mapItems
import utils.permutations
fun main() {
Day13.run()
}
object Day13 : Solution<List<Day13.Rule>>() {
override val name = "day13"
override val parser = Parser.lines.mapItems { parseRule(it) }
@Parse("{person} would {direction} {a... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,593 | aoc_kotlin | MIT License |
src/Day13.kt | dragere | 440,914,403 | false | {"Kotlin": 62581} | import kotlin.streams.toList
fun main() {
fun fold(vec: Pair<Int, Int>, folder: Pair<Int, Int>): Pair<Int, Int> {
var tmp = vec * folder.normalize()
if (tmp.total() < folder.total()) return vec
tmp = folder - (vec - folder)
return if (folder.first == 0) {
Pair(vec.first... | 0 | Kotlin | 0 | 0 | 3e33ab078f8f5413fa659ec6c169cd2f99d0b374 | 2,318 | advent_of_code21_kotlin | Apache License 2.0 |
src/day05/Day05.kt | Volifter | 572,720,551 | false | {"Kotlin": 65483} | package day05
import utils.*
data class Instruction(val amount: Int, val from: Int, val to: Int)
fun parseCrates(input: List<String>): List<List<Char>> {
val count = (input.first().length + 1) / 4
return (0 until count).map { i ->
input.mapNotNull { line -> line[1 + i * 4].takeIf { it != ' ' } }
... | 0 | Kotlin | 0 | 0 | c2c386844c09087c3eac4b66ee675d0a95bc8ccc | 1,966 | AOC-2022-Kotlin | Apache License 2.0 |
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day08/Day08.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2021.day08
import eu.janvdb.aocutil.kotlin.readLines
private const val FILENAME = "input08.txt"
fun main() {
val digits = readLines(2021, FILENAME)
.map(::parseLine)
.map { getDigits(it.first, it.second) }
val result1 = digits.flatten().count { it == 1 || it == 4 || it == 7 || it == 8 }
... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 2,148 | advent-of-code | Apache License 2.0 |
src/Day09.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} | import kotlin.math.abs
private data class Position(val x: Int, val y: Int)
private enum class Direction(val dx: Int, val dy: Int){
LEFT(-1,0), RIGHT(+1,0), UP(0,+1), DOWN(0,-1)
}
private fun Char.toDir() = Direction.values().first{ this == it.name[0] }
private operator fun Position.plus(d: Direction) = Position(... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 1,708 | aoc2022 | Apache License 2.0 |
src/day9/day9.kt | bienenjakob | 573,125,960 | false | {"Kotlin": 53763} | package day9
import inputTextOfDay
import testTextOfDay
import kotlin.math.abs
fun parseInput(input: String): List<Pair<Direction, Int>> =
input.lines().map { line ->
line.split(" ").let { (d, n) -> Direction.valueOf(d) to n.toInt() }
}
fun part1(input: String) = visit(2, input).size
fun part2(input:... | 0 | Kotlin | 0 | 0 | 6ff34edab6f7b4b0630fb2760120725bed725daa | 1,940 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day13/Day13.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day13
import org.json.JSONArray
import readInput
import java.lang.Integer.min
fun main() {
fun compare(arr1: JSONArray, arr2: JSONArray): Int {
for (i in 0 until min(arr1.length(), arr2.length())) {
val e1 = arr1.get(i)
val e2 = arr2.get(i)
if (e1 is Int && e2... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 2,759 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | haraldsperre | 572,671,018 | false | {"Kotlin": 17302} | fun main() {
fun getPriority(input: Char): Int {
return when (input) {
in 'a'..'z' -> input - 'a' + 1
in 'A'..'Z' -> input - 'A' + 27
else -> throw Exception("Invalid input")
}
}
fun getCompartments(rucksack: String): Pair<String, String> {
val c... | 0 | Kotlin | 0 | 0 | c4224fd73a52a2c9b218556c169c129cf21ea415 | 1,448 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | dizney | 572,581,781 | false | {"Kotlin": 105380} | object Day03 {
const val EXPECTED_PART1_CHECK_ANSWER = 157
const val EXPECTED_PART2_CHECK_ANSWER = 70
const val ELF_GROUP_SIZE = 3
}
fun main() {
fun Char.mapToItemValue() = if (this.isUpperCase()) (this.minus('A') + 27) else (this.minus('a') + 1)
fun part1(input: List<String>): Int {
re... | 0 | Kotlin | 0 | 0 | f684a4e78adf77514717d64b2a0e22e9bea56b98 | 1,558 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Excercise14.kt | underwindfall | 433,989,850 | false | {"Kotlin": 55774} | private fun part1() {
val input = getInputAsTest("14")
val map = input.drop(2).map { it.split("->") }.associate { it[0].trim() to it[1].trim() }
var pairFreq = mutableMapOf<String, Long>()
input[0].windowed(2).forEach { key -> pairFreq[key] = pairFreq.getOrDefault(key, 0) + 1 }
repeat(10) {
val newMap = ... | 0 | Kotlin | 0 | 0 | 4fbee48352577f3356e9b9b57d215298cdfca1ed | 1,773 | advent-of-code-2021 | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-04.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2023
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
import kotlin.math.pow
fun main() {
val input = readInputLines(2023, "04-input")
val test1 = readInputLines(2023, "04-test1")
println("Part1:")
part1... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,698 | advent-of-code | MIT License |
src/main/kotlin/day7/Day7.kt | jakubgwozdz | 571,298,326 | false | {"Kotlin": 85100} | package day7
import execute
import readAllText
import wtf
fun main() {
val example = """
${'$'} cd /
${'$'} ls
dir a
14848514 b.txt
8504156 c.dat
dir d
${'$'} cd a
${'$'} ls
dir e
29116 f
2557 g
62596 h.lst
${'... | 0 | Kotlin | 0 | 0 | 7589942906f9f524018c130b0be8976c824c4c2a | 2,690 | advent-of-code-2022 | MIT License |
src/Day12.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | fun main() {
val lookup = "_abcdefghijklmnopqrstuvwxyz"
val neighborFilterFn: (other: Node<Int>, self: Node<Int>) -> Boolean =
{ other, self -> other.isNeighborOf(self) && other.value <= self.value + 1 }
fun convertToNrs(inputAsStrings: List<List<String>>): List<List<Int>> =
inputAsStrings... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 2,036 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/ryanmoelter/advent/day04/Cleanup.kt | ryanmoelter | 573,615,605 | false | {"Kotlin": 84397} | package com.ryanmoelter.advent.day04
fun main() {
println(findOverlapping(day04input))
}
fun findOverlapping(input: String): Int = input.lines()
.toSectionRanges()
.map { it.isOverlapping() }
.sumOf { if (it) 1 else 0 as Int }
fun findFullyContained(input: String): Int = input.lines()
.toSectionRanges()
... | 0 | Kotlin | 0 | 0 | aba1b98a1753fa3f217b70bf55b1f2ff3f69b769 | 1,329 | advent-of-code-2022 | Apache License 2.0 |
src/main/aoc2018/Day6.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2018
import increase
import kotlin.math.abs
class Day6(input: List<String>) {
data class Location(val x: Int, val y: Int) {
fun distanceTo(other: Location) = abs(x - other.x) + abs(y - other.y)
fun withinFovUp(other: Location): Boolean {
return other.y < y // above
... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 3,573 | aoc | MIT License |
2022/src/main/kotlin/org/suggs/adventofcode/Day07NoSpaceLeftOnDevice.kt | suggitpe | 321,028,552 | false | {"Kotlin": 156836} | package org.suggs.adventofcode
object Day07NoSpaceLeftOnDevice {
fun sumDirectoriesOver100KFrom(commands: List<String>): Long =
findAllDirectorySizes(buildTreeFrom(commands)).filter { it < 100000 }.sum()
fun findDirectoryThatFreesUpSpaceForUpdateFrom(commands: List<String>): Long {
val root =... | 0 | Kotlin | 0 | 0 | 9485010cc0ca6e9dff447006d3414cf1709e279e | 3,192 | advent-of-code | Apache License 2.0 |
src/day18/day18.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day18
import readInput
private fun parseInput(input: List<String>): List<IntArray> =
input.map { line ->
val parts = line.split(",")
val result = IntArray(3)
repeat(3) { result[it] = parts[it].toInt().coerceAtLeast(result[it]) }
result
}
private fun getMaxes(input: Lis... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 3,951 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2018/Day23ExperimentalEmergencyTeleportation.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2018
import kotlin.math.abs
class Day23ExperimentalEmergencyTeleportation
data class TeleportCoordinate(val x: Int, val y: Int, val z: Int)
data class Nanobot(val x: Int, val y: Int, val z: Int, val radius: Int) {
fun inRange(otherBot: Nanobot): Boolean {
val manhattanDistance = dis... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 3,347 | kotlin-coding-challenges | MIT License |
src/Day07.kt | antonarhipov | 574,851,183 | false | {"Kotlin": 6403} | fun main() {
fun String.isCd() = startsWith("$ cd")
fun buildDirectoryTree(input: List<String>): Directory {
val root = Directory("/", null)
var currentDirectory = root
input.drop(1).forEach { line ->
if (line.isCd()) {
val (_, _, name) = line.split(" ")
... | 0 | Kotlin | 0 | 0 | 8dd56fdbe67d0af74fbe65ff204275338785cd4a | 2,736 | aoc2022 | Apache License 2.0 |
src/Day14.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | import java.util.*
const val air = ' '
const val rock = '#'
const val sand = '*'
fun placeRocks(cave: Array<CharArray>, line: String): Int {
var maxRow = 0
val pairs = line.split(" -> ")
var (prevCol, prevRow) = listOf(-1, -1)
pairs.forEach { pair ->
val scanner = Scanner(pair)
var (col... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 3,389 | AoC-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2020/Day21.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 21 - Allergen Assessment
* Problem Description: http://adventofcode.com/2020/day/21
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day21/
*/
package com.ginsberg.advent2020
class Day21(input: List<String>) {
pri... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 2,471 | advent-2020-kotlin | Apache License 2.0 |
src/main/kotlin/Day15.kt | dliszewski | 573,836,961 | false | {"Kotlin": 57757} | import kotlin.math.abs
class Day15 {
fun part1(input: List<String>, lookupRow: Int): Int {
val sensors = mapToSensors(input)
val minRange = sensors.minOf { sensor ->
minOf(
sensor.position.x,
sensor.beacon.x,
sensor.position.x - sensor.d... | 0 | Kotlin | 0 | 0 | 76d5eea8ff0c96392f49f450660220c07a264671 | 2,947 | advent-of-code-2022 | Apache License 2.0 |
src/Day11.kt | freszu | 573,122,040 | false | {"Kotlin": 32507} | private val monkeyRegex = Regex(
"Monkey (\\d):\\n" +
" Starting items: ([\\d+, ]*)\\n" +
" Operation: new = old ([^\\n]*)\\n" +
" Test: divisible by (\\d+)\\n" +
" If true: throw to monkey (\\d+)\\n" +
" If false: throw to monkey (\\d+)"
)
priva... | 0 | Kotlin | 0 | 0 | 2f50262ce2dc5024c6da5e470c0214c584992ddb | 2,916 | aoc2022 | Apache License 2.0 |
kotlin/2021/round-1a/prime-time/src/main/kotlin/Solution.kt | ShreckYe | 345,946,821 | false | null | import kotlin.math.E
import kotlin.math.exp
import kotlin.math.pow
import kotlin.math.sqrt
fun main() {
val t = readLine()!!.toInt()
repeat(t, ::testCase)
}
fun testCase(ti: Int) {
val m = readLine()!!.toInt()
val pns = List(m) {
val lineInputs = readLine()!!.split(' ')
Pn(lineInputs[0... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 3,561 | google-code-jam | MIT License |
src/day/_5/Day05.kt | Tchorzyksen37 | 572,924,533 | false | {"Kotlin": 42709} | package day._5
import readInput
class Day05(filePath: String) {
private val inputAsStringParts = readInput(filePath).joinToString("\n").split("\n\n")
private val numberOfStacks = inputAsStringParts[0].lines()
.last()
.split(" ")
.mapNotNull { if (it.isBlank()) null else it.toInt() }
.last()
private val... | 0 | Kotlin | 0 | 0 | 27d4f1a6efee1c79d8ae601872cd3fa91145a3bd | 2,017 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day12.kt | brigham | 573,127,412 | false | {"Kotlin": 59675} | data class Position12(val r: Int, val c: Int)
data class HeightMap(val map: List<List<Char>>, val start: Position12, val end: Position12)
fun main() {
fun parse(input: List<String>): HeightMap {
var start: Position12? = null
var end: Position12? = null
for (rowIdx in input.indices) {
... | 0 | Kotlin | 0 | 0 | b87ffc772e5bd9fd721d552913cf79c575062f19 | 2,958 | advent-of-code-2022 | Apache License 2.0 |
src/day21/Day21.kt | spyroid | 433,555,350 | false | null | package day21
import kotlin.system.measureTimeMillis
data class Die(var rolls: Int = 0) {
private fun roll() = ++rolls % 100
fun rolls(times: Int) = generateSequence { roll() }.take(times).sum()
}
data class Player(var space: Int, var score: Int = 0) {
fun move(steps: Int) {
space = (space + step... | 0 | Kotlin | 0 | 0 | 939c77c47e6337138a277b5e6e883a7a3a92f5c7 | 1,917 | Advent-of-Code-2021 | Apache License 2.0 |
src/Day03.kt | maciekbartczak | 573,160,363 | false | {"Kotlin": 41932} | fun main() {
fun part1(input: List<String>): Int {
return input
.map {
val compartments = it.chunked(it.length / 2)
findDuplicateCharacter(compartments[0] to compartments[1])
}
.sumOf { calculatePriority(it) }
}
fun part2(input: Li... | 0 | Kotlin | 0 | 0 | 53c83d9eb49d126e91f3768140476a52ba4cd4f8 | 1,679 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day07/day07.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day07
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
fun main() {
val bags = parseData(getResourceAsText("/day07/rules-list.txt"))
val bagsThatContainShinyGold = countBagsThatCanContain(bags, "shiny gold")
val bagsInsideShinyGold = countIndividualBagsIn... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 2,344 | advent-of-code-2020 | MIT License |
src/day15/Day15.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day15
import Runner
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
Day15Runner().solve()
}
class Day15Runner : Runner<Long>(
day = 15,
expectedPartOneTestAnswer = 26,
expectedPartTwoTestAnswer = 56000011
) {
override fun partOne(input: List<String>, tes... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 4,577 | advent-of-code | Apache License 2.0 |
src/Day05.kt | TheOnlyTails | 573,028,916 | false | {"Kotlin": 9156} | fun getStackStringIndex(stackIndex: Int) = 4 * stackIndex + 1
fun parsing(input: List<String>): Pair<List<List<Int>>, MutableList<MutableList<Char>>> {
val (instructions, rawStacks) = input
.filter(String::isNotBlank)
.partition { it.startsWith("move") }
val stackCount = rawStacks.last().last(... | 0 | Kotlin | 0 | 0 | 685ce47586b6d5cea30dc92f4a8e55e688005d7c | 1,918 | advent-of-code-2022 | Apache License 2.0 |
src/Day14.kt | sabercon | 648,989,596 | false | null | fun main() {
fun modification1(mask: String, address: String, value: String): Map<String, String> {
return value.zip(mask) { v, m -> if (m == 'X') v else m }
.joinToString("")
.let { mapOf(address to it) }
}
fun modification2(mask: String, address: String, value: String): Ma... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 1,874 | advent-of-code-2020 | MIT License |
08/part_two.kt | ivanilos | 433,620,308 | false | {"Kotlin": 97993} | import java.io.File
import java.lang.Exception
fun readInput() : List<Display> {
return File("input.txt")
.readLines()
.map { Display(it) }
}
class Display(inputLine : String) {
companion object {
val UNIQUE_OUTPUT_SIZES = listOf(2, 3, 4, 7)
val INPUT_TO_OUTPUT_MAP = mapOf("ab... | 0 | Kotlin | 0 | 3 | a24b6f7e8968e513767dfd7e21b935f9fdfb6d72 | 3,128 | advent-of-code-2021 | MIT License |
src/Day09.kt | xabgesagtx | 572,139,500 | false | {"Kotlin": 23192} | import kotlin.math.absoluteValue
fun main() {
val day = "Day09"
fun simulateRopeMovement(input: List<String>, numberOfTailElements: Int): Int {
return buildSet {
add(0 to 0)
var rope = List(numberOfTailElements + 1) { 0 to 0 }
for (command in input) {
... | 0 | Kotlin | 0 | 0 | 976d56bd723a7fc712074066949e03a770219b10 | 2,268 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | thorny-thorny | 573,065,588 | false | {"Kotlin": 57129} | import kotlin.math.abs
data class Cube(val x: Int, val y: Int, val z: Int) {
infix fun touches(other: Cube): Boolean {
val touchesX = abs(x - other.x) == 1 && y == other.y && z == other.z
val touchesY = abs(y - other.y) == 1 && x == other.x && z == other.z
val touchesZ = abs(z - other.z) ==... | 0 | Kotlin | 0 | 0 | 843869d19d5457dc972c98a9a4d48b690fa094a6 | 5,146 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/nekomatic/types/graph/Sort.kt | nekomatic | 124,664,292 | false | null | package com.nekomatic.types.graph
import com.nekomatic.types.Option
import com.nekomatic.types.map
fun <V : Any> IGraph<V>.khanSort(): List<V> {
val zeroMap =
this.vertices.map { it to 0 }.toMap()
val inDegreeMap: Map<V, Int> = zeroMap + this.edges.asSequence().groupBy { it.second }.map { (n, l) ... | 1 | Kotlin | 0 | 1 | 05be9f022339619878bb5a8fe0719c7540f97b0a | 1,581 | types | MIT License |
src/Day09.kt | joy32812 | 573,132,774 | false | {"Kotlin": 62766} | import kotlin.math.abs
fun main() {
fun solve(input: List<String>, knotCnt: Int): Int {
val dirMap = mapOf(
"L" to (0 to -1),
"R" to (0 to 1),
"U" to (-1 to 0),
"D" to (1 to 0)
)
val tailPosSet = mutableSetOf("0_0")
val positions = Array(knotCnt) { Array(2) { 0 } }
fun... | 0 | Kotlin | 0 | 0 | 5e87958ebb415083801b4d03ceb6465f7ae56002 | 1,626 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem1201/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1201
/**
* LeetCode page: [1201. Ugly Number III](https://leetcode.com/problems/ugly-number-iii/);
*/
class Solution {
/* Complexity:
* Time O(Log(NMK)) and Space O(1) where N, M, K equal a, b and c;
*/
fun nthUglyNumber(n: Int, a: Int, b: Int, c: Int): Int {
... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,848 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day08B.kt | zsmb13 | 572,719,881 | false | {"Kotlin": 32865} | @Suppress("DuplicatedCode")
fun main() {
fun left(x: Int, y: Int) = (x - 1 downTo 0).asSequence().map { x -> x to y }
fun right(x: Int, y: Int, xMax: Int) = (x + 1..xMax).asSequence().map { x -> x to y }
fun top(x: Int, y: Int) = (y - 1 downTo 0).asSequence().map { y -> x to y }
fun bottom(x: Int, y: In... | 0 | Kotlin | 0 | 6 | 32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35 | 2,161 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | schoi80 | 726,076,340 | false | {"Kotlin": 83778} | fun main() {
val input = readInput("Day03")
fun RowCol.isOutOfBounds(): Boolean {
val inRange = first >= 0 && first < input.size && second >= 0 && second < input[first].length
return !inRange
}
fun RowCol.isSymbol(): Boolean {
if (!isOutOfBounds()) {
val c = input[... | 0 | Kotlin | 0 | 0 | ee9fb20d0ed2471496185b6f5f2ee665803b7393 | 2,506 | aoc-2023 | Apache License 2.0 |
src/Day13.kt | RandomUserIK | 572,624,698 | false | {"Kotlin": 21278} | private object Parser {
fun from(input: String): Node =
from(
input
.split("""((?<=[\[\],])|(?=[\[\],]))""".toRegex())
.filter { it != "," && it.isNotBlank() }
.iterator()
)
fun from(input: Iterator<String>): Node {
val nodes = mutableListOf<Node>()
while (input.hasNext()) {
when (val token... | 0 | Kotlin | 0 | 0 | f22f10da922832d78dd444b5c9cc08fadc566b4b | 2,063 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/y2023/day06/Day06.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2023.day06
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
part2 = { part2() }
)
}
data class Race(
val duration: Int,
val distance: Long
)
fun input1(): List<Race> {
val inputLines = AoCGenerics.getInputLines("/y2023/day06/input.txt")
val timeLi... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 1,753 | AdventOfCode | MIT License |
src/year2016/day01/Day01.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2016.day01
import check
import readInput
import kotlin.math.abs
fun main() {
check(part1(listOf("R2, L3")), 5)
check(part1(listOf("R2, R2, R2")), 2)
check(part1(listOf("R5, L5, R5, R3")), 12)
check(part2(listOf("R8, R4, R4, R8")), 4)
val input = readInput("2016", "Day01")
println(... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,167 | AdventOfCode | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.