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/Day07.kt | Sasikuttan2163 | 647,296,570 | false | null | fun main() {
val input = readInput("Day07")
val root = Node(
type = "dir",
name = "/",
parent = null
)
var current = root
var inls = false
input.withIndex()
.forEach { line ->
if (line.value.startsWith("$ ls")) {
inls = true
... | 0 | Kotlin | 0 | 0 | fb2ade48707c2df7b0ace27250d5ee240b01a4d6 | 2,768 | AoC-2022-Solutions-In-Kotlin | MIT License |
2023/src/day01/day01.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day01
import GREEN
import RESET
import printTimeMillis
import readInput
fun part1(input: List<String>): Int {
return input.map<String, Int> {
val one = it.first { it.isDigit() }.digitToInt()
val two = it.last { it.isDigit() }.digitToInt()
one * 10 + two
}.sum()
}
val replace... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 2,492 | advent-of-code | Apache License 2.0 |
src/Day13.kt | allwise | 574,465,192 | false | null |
fun main() {
fun part1(input: List<String>): Int {
val distress = Distress(input)
val res= distress.process()
println("res=$res")
return res
}
fun part2(input: List<String>): Int {
val distress = Distress(input)
val res= distress.process2()
println(... | 0 | Kotlin | 0 | 0 | 400fe1b693bc186d6f510236f121167f7cc1ab76 | 5,089 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | zdenekobornik | 572,882,216 | false | null | enum class Move(val score: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
companion object {
fun parse(value: String): Move {
return when (value) {
"A", "X" -> ROCK
"B", "Y" -> PAPER
"C", "Z" -> SCISSORS
else -> throw IllegalStateExcep... | 0 | Kotlin | 0 | 0 | f73e4a32802fa43b90c9d687d3c3247bf089e0e5 | 3,369 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | izyaboi | 572,898,317 | false | {"Kotlin": 4047} | fun main() {
fun part1(input: List<String>): Int {
var totalScore = 0
input.forEach {
val opponent = it.substringBefore(" ").mapToShape()
val response = it.substringAfter(" ").mapToShape()
totalScore += getPoints(opponent, response) + response.ordinal
}
... | 0 | Kotlin | 0 | 1 | b0c8cafc5fe610b088d7ca4d10e2deef8d418f96 | 2,322 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/be/tabs_spaces/advent2021/days/Day14.kt | janvryck | 433,393,768 | false | {"Kotlin": 58803} | package be.tabs_spaces.advent2021.days
class Day14 : Day(14) {
private val polymerizationEquipment = PolymerizationEquipment(inputList)
override fun partOne() = polymerizationEquipment.diffPolymerizedOccurrences()
override fun partTwo() = polymerizationEquipment.diffPolymerizedOccurrences(times = 40)
... | 0 | Kotlin | 0 | 0 | f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9 | 2,371 | advent-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day11.kt | jgrgt | 575,475,683 | false | {"Kotlin": 94368} | package days
import java.lang.IllegalStateException
import kotlin.math.sqrt
class Day11 : Day(11) {
override fun partOne(): Any {
// return 0
val monkeys = inputList.windowed(7, 7, true)
.map { monkeyLines -> Day11Monkey.parse(monkeyLines) }
val game = Day11Game(monkeys)
... | 0 | Kotlin | 0 | 0 | 5174262b5a9fc0ee4c1da9f8fca6fb86860188f4 | 6,299 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/Day02.kt | jarmstrong | 572,742,103 | false | {"Kotlin": 5377} | fun main() {
fun splitInput(input: List<String>): List<String> {
return input.map { "${it.first()}${it.last()}" }
}
fun List<String>.sumScores(): Int {
val choiceScoreTable = mapOf(
'X' to 1,
'Y' to 2,
'Z' to 3
)
val resultScores = mapOf(... | 0 | Kotlin | 0 | 0 | bba73a80dcd02fb4a76fe3938733cb4b73c365a6 | 1,380 | aoc-2022 | Apache License 2.0 |
src/Day14.kt | esp-er | 573,196,902 | false | {"Kotlin": 29675} | package patriker.day14
import patriker.utils.*
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day14_test")
val input = readInput("Day14_input")
check(solvePart1(testInput) == 24)
println(solvePart1(input))
check(solvePart2(testInp... | 0 | Kotlin | 0 | 0 | f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362 | 3,805 | aoc2022 | Apache License 2.0 |
src/Day12.kt | maewCP | 579,203,172 | false | {"Kotlin": 59412} | fun main() {
val verbose = false
val shortestPath = mutableMapOf<Pair<Int, Int>, Day12Solution>()
val queue = mutableListOf<Day12Solution>()
val map = mutableMapOf<Pair<Int, Int>, Char>()
val aPositions = mutableListOf<Pair<Int, Int>>()
lateinit var start: Pair<Int, Int>
lateinit var goal: P... | 0 | Kotlin | 0 | 0 | 8924a6d913e2c15876c52acd2e1dc986cd162693 | 4,513 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day19.kt | clechasseur | 568,233,589 | false | {"Kotlin": 242914} | package io.github.clechasseur.adventofcode.y2015
import io.github.clechasseur.adventofcode.y2015.data.Day19Data
import kotlin.math.min
object Day19 {
private val transforms = Day19Data.transforms
private const val molecule = Day19Data.molecule
private val transformRegex = """^(\w+) => (\w+)$""".toRegex()... | 0 | Kotlin | 0 | 0 | e5a83093156cd7cd4afa41c93967a5181fd6ab80 | 3,056 | adventofcode2015 | MIT License |
src/main/kotlin/day02/Solution.kt | TestaDiRapa | 573,066,811 | false | {"Kotlin": 50405} | package day02
import java.io.File
import java.lang.Exception
enum class MoveTypes {
ROCK,
PAPER,
SCISSORS
}
fun getWinningMove(move: Move) = when(move.type) {
MoveTypes.ROCK -> Move("B")
MoveTypes.PAPER -> Move("C")
MoveTypes.SCISSORS -> Move("A")
}
fun getLosingMove(move: Move) = when(move.... | 0 | Kotlin | 0 | 0 | b5b7ebff71cf55fcc26192628738862b6918c879 | 2,781 | advent-of-code-2022 | MIT License |
src/Day05.kt | Ajimi | 572,961,710 | false | {"Kotlin": 11228} | data class Action(val amount: Int, val from: Int, val to: Int)
fun main() {
fun performOperations(
actions: List<Action>,
stacks: List<MutableList<Char>>,
shouldReverse: Boolean = true,
) {
actions.forEach { (amount, from, to) ->
val toAdd = stacks[from].take(amount)... | 0 | Kotlin | 0 | 0 | 8c2211694111ee622ebb48f52f36547fe247be42 | 2,012 | adventofcode-2022 | Apache License 2.0 |
src/Day04.kt | Tiebe | 579,377,778 | false | {"Kotlin": 17146} | fun main() {
fun part1(input: List<String>): Int {
return input.count { sectionList ->
val sections = sectionList.split(',')
val section1 = sections[0].split('-').map { it.toInt() }
val section2 = sections[1].split('-').map { it.toInt() }
((section1[0] >= se... | 1 | Kotlin | 0 | 0 | afe9ac46b38e45bd400e66d6afd4314f435793b3 | 1,326 | advent-of-code | Apache License 2.0 |
aoc2022/day15.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import utils.InputRetrieval
import kotlin.math.abs
fun main() {
Day15.execute()
}
object Day15 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
private fun part1(input: List<Sensor>, row: Int = ... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 4,231 | Advent-Of-Code | MIT License |
src/Day04.kt | ajesh-n | 573,125,760 | false | {"Kotlin": 8882} | fun main() {
fun part1(input: List<String>): Int {
val sections: List<List<List<Int>>> = input.map { sectionPairs ->
sectionPairs.split(",").map { it.split("-").map { section -> section.toInt() } }
.map { (it.first()..it.last()).toList() }
}
return sections.count ... | 0 | Kotlin | 0 | 0 | 2545773d7118da20abbc4243c4ccbf9330c4a187 | 1,013 | kotlin-aoc-2022 | Apache License 2.0 |
src/main/kotlin/dec20/Main.kt | dladukedev | 318,188,745 | false | null | package dec20
import java.lang.IndexOutOfBoundsException
fun <T> List<List<T>>.rotate90(): List<List<T>> {
return this.mapIndexed { rowIndex, row ->
row.mapIndexed { colIndex, _ ->
this[row.count() - colIndex - 1][rowIndex]
}
}
}
fun <T> List<List<T>>.rotate180(): List<List<T>> {... | 0 | Kotlin | 0 | 0 | d4591312ddd1586dec6acecd285ac311db176f45 | 6,822 | advent-of-code-2020 | MIT License |
src/main/kotlin/dev/tasso/adventofcode/_2022/day09/Day09.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2022.day09
import dev.tasso.adventofcode.Solution
import kotlin.math.abs
class Day09 : Solution<Int> {
override fun part1(input: List<String>): Int =
input.map { inputLine -> inputLine.split(" ") }
//Break each larger step of multiple moves in a specific direc... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 3,975 | advent-of-code | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem1680/Solution2.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1680
/**
* LeetCode page: [1680. Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers/);
*
* Note: There is a solution posted by leetCode staff and claims to have time O((LogN)^2), see [HERE](https://leetcode.com... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 3,160 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day05.kt | gsalinaslopez | 572,839,981 | false | {"Kotlin": 21439} | fun main() {
fun getCrates(input: List<String>): Array<ArrayDeque<Char>> {
val reversedCratesString = input.filter { it.contains('[') }.reversed()
val numOfCrates = reversedCratesString.first().count { it == '[' }
val crates = Array<ArrayDeque<Char>>(numOfCrates) { ArrayDeque() }
re... | 0 | Kotlin | 0 | 0 | 041c7c3716bfdfdf4cc89975937fa297ea061830 | 2,820 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day5.kt | amitdev | 574,336,754 | false | {"Kotlin": 21489} | fun solve(lines: Sequence<String>, part1: Boolean) =
lines.fold(Input()) { acc, line -> acc.merge(acc.parse(line)) }
.arrangeCrates()
.rearrange(part1)
.top()
data class Input(
val crates: Map<Int, List<String>> = mapOf(),
val instructions: List<Instruction> = listOf(),
private val parsedCrates: B... | 0 | Kotlin | 0 | 0 | b2cb4ecac94fdbf8f71547465b2d6543710adbb9 | 1,822 | advent_2022 | MIT License |
src/Day05.kt | brunojensen | 572,665,994 | false | {"Kotlin": 13161} | private data class Move(val amount: Int, val from: Int, val to: Int) {
fun execute1(stacks: List<MutableList<Char>>) {
repeat(amount) { stacks[to].add(stacks[from].removeLast()) }
}
fun execute2(stacks: List<MutableList<Char>>) {
repeat(amount) { stacks[to].add(stacks[from].removeMiddleTop(amount - it))... | 0 | Kotlin | 0 | 0 | 2707e76f5abd96c9d59c782e7122427fc6fdaad1 | 1,806 | advent-of-code-kotlin-1 | Apache License 2.0 |
src/main/kotlin/com/github/davio/aoc/y2022/Day8.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2022
import com.github.davio.aoc.general.*
import kotlin.system.measureTimeMillis
fun main() {
println(Day8.getResultPart1())
measureTimeMillis {
println(Day8.getResultPart2())
}.call { println("Took $it ms") }
}
/**
* See [Advent of Code 2022 Day 8](https://advento... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 2,999 | advent-of-code | MIT License |
src/main/kotlin/Day02.kt | dliszewski | 573,836,961 | false | {"Kotlin": 57757} | class Day02 {
fun part1(input: List<String>): Int {
return input.map { it.split(" ") }
.map { (opponentCode, myCode) -> HandShape.fromOpponentCode(opponentCode) to HandShape.fromElfCode(myCode) }
.sumOf { (opponentHandShape, myHandShape) -> HandScorer.score(opponentHandShape, myHandS... | 0 | Kotlin | 0 | 0 | 76d5eea8ff0c96392f49f450660220c07a264671 | 2,141 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/day04/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2022.day04
import readInput
private const val MIN_1 = 0
private const val MAX_1 = 1
private const val MIN_2 = 2
private const val MAX_2 = 3
fun main() {
fun isInside(line: List<Int>) = ((line[MIN_1] <= line[MIN_2] && line[MAX_2] <= line[MAX_1]) ||
(line[MIN_2] <... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,470 | adventOfCode | Apache License 2.0 |
src/Day02.kt | josepatinob | 571,756,490 | false | {"Kotlin": 17374} | fun main() {
fun part1(input: List<String>): Int {
val firstRowMap = mapOf("A" to "rock", "B" to "paper", "C" to "scissors")
val secondRowMap = mapOf("X" to "rock", "Y" to "paper", "Z" to "scissors")
val winningMap = mapOf("scissors" to "rock", "rock" to "paper", "paper" to "scissors")
... | 0 | Kotlin | 0 | 0 | d429a5fff7ddc3f533d0854e515c2ba4b0d461b0 | 2,920 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/day08.kt | josergdev | 573,178,933 | false | {"Kotlin": 20792} | package days
import java.io.File
fun <T> List<List<T>>.transpose(): List<List<T>> = when {
this.first().isEmpty() -> listOf()
else -> listOf(this.map { it.first() }) + this.map { it.drop(1) }.transpose()
}
fun day8part1() = File("input/08.txt").readLines()
.mapIndexed { i, e1 -> e1.mapIndexed { j, e... | 0 | Kotlin | 0 | 0 | ea17b3f2a308618883caa7406295d80be2406260 | 1,880 | aoc-2022 | MIT License |
src/year2022/Day07.kt | Maetthu24 | 572,844,320 | false | {"Kotlin": 41016} | package year2022
fun main() {
class Dir(val name: String,
val path: List<String>,
val files: MutableList<Pair<String, Int>> = mutableListOf(),
val subDirs: MutableList<Dir> = mutableListOf()) {
val totalSize: Int
get() = files.sumOf { it.second } + subDirs... | 0 | Kotlin | 0 | 1 | 3b3b2984ab718899fbba591c14c991d76c34f28c | 2,972 | adventofcode-kotlin | Apache License 2.0 |
src/main/kotlin/y2023/day09/Day09.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2023.day09
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
part2 = { part2() }
)
}
fun input(): List<List<Int>> {
return AoCGenerics.getInputLines("/y2023/day09/input.txt").map { line ->
line.split(" ").map { it.toInt() }
}
}
fun getSubSequence(s... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 2,575 | AdventOfCode | MIT License |
2018/src/five/GuardChallenge.kt | Mattias1 | 116,139,424 | false | null | package five
import parse
import java.lang.Exception
// Day 4
class GuardChallenge {
fun longestAsleep(input: List<String>): Int {
val sleepIntervals = buildSleepIntervals(input)
val biggusDickus: GuardSleepIntervals = sleepIntervals.maxBy { it.totalSleepTime }!!
val minute = biggusDickus... | 0 | Kotlin | 0 | 0 | 6bcd889c6652681e243d493363eef1c2e57d35ef | 2,718 | advent-of-code | MIT License |
src/day2/Day02.kt | rafagalan | 573,145,902 | false | {"Kotlin": 5674} | package day2
import readInput
import kotlin.math.abs
import kotlin.math.max
interface Move {
fun toScore(): Int
}
object Rock : Move {
override fun toScore() = 0
}
object Paper : Move {
override fun toScore() = 1
}
object Scissors : Move {
override fun toScore() = 2
}
fun String.toMove() = when(this... | 0 | Kotlin | 0 | 0 | 8e7d3f25fe52a4153479adb56c5924b50f6c0be9 | 1,758 | AdventOfCode2022 | Apache License 2.0 |
src/y2021/Day11.kt | Yg0R2 | 433,731,745 | false | null | package y2021
fun main() {
fun part1(input: List<String>): Int {
val grid: Array<Array<Int>> = input.toGrid()
var flashCounter = 0
for (step in 0 until 100) {
grid.increaseEnergyLevel()
while (grid.hasChargedOctopus()) {
grid.flash()
}
... | 0 | Kotlin | 0 | 0 | d88df7529665b65617334d84b87762bd3ead1323 | 2,629 | advent-of-code | Apache License 2.0 |
2023/src/day06/day06.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day06
import GREEN
import RESET
import printTimeMillis
import readInput
fun part1(input: List<String>): Int {
val times = input.first().split(":")[1].split(" ").map { it.trim().toIntOrNull() }.filterNotNull()
val distances = input[1].split(":")[1].split(" ").map { it.trim().toIntOrNull() }.filterNotNu... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,376 | advent-of-code | Apache License 2.0 |
src/main/kotlin/io/trie/WordSearchInMatrix.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.trie
// https://leetcode.com/explore/learn/card/trie/149/practical-application-ii/1056/
class WordSearchInMatrix {
fun execute(board: Array<CharArray>, words: Array<String>): List<String> {
val root = TrieNodeW.root().also { it.addWords(words) }
val result = mutableListOf<String>()
val wordsL... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 3,096 | coding | MIT License |
src/Day02.kt | pavlo-dh | 572,882,309 | false | {"Kotlin": 39999} | fun main() {
fun parseInput(input: List<String>) = input.map { line ->
line.split(' ', limit = 2).map(String::first)
}
fun part1(input: List<String>): Int {
fun shapeScore(shape: Char) = when (shape) {
'X' -> 1
'Y' -> 2
else -> 3
}
fun ro... | 0 | Kotlin | 0 | 2 | c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992 | 2,033 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | shoresea | 576,381,520 | false | {"Kotlin": 29960} | import java.util.*
fun main() {
fun getDirectories(root: Directory): List<Directory> {
val directories = ArrayList<Directory>()
val queue = Stack<Directory>()
queue.add(root)
while (queue.isNotEmpty()) {
val current = queue.pop()
directories.add(current)
... | 0 | Kotlin | 0 | 0 | e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e | 2,909 | AOC2022InKotlin | Apache License 2.0 |
src/main/kotlin/adventofcode2017/potasz/P07TowerOfDiscs.kt | potasz | 113,064,245 | false | null | package adventofcode2017.potasz
import kotlin.math.abs
object P07TowerOfDiscs {
data class Disc(val name: String, var weight: Int = 0, var totalWeight: Int = 0, var children: List<Disc> = emptyList(),
var parent: Disc? = null) {
override fun toString(): String {
return "Di... | 0 | Kotlin | 0 | 1 | f787d9deb1f313febff158a38466ee7ddcea10ab | 2,803 | adventofcode2017 | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/candy/Candy.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.candy
import datsok.shouldEqual
import org.junit.jupiter.api.Test
//
// https://leetcode.com/problems/candy ✅
//
// There are N children standing in a line. Each child is assigned a rating value.
// You are giving candies to these children subjected to the following requirements:
// -... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 3,465 | katas | The Unlicense |
src/main/kotlin/Day16.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.nio.charset.Charset
fun main() {
val testDocs = File("test/day16").readText(Charset.defaultCharset())
val puzzles = File("puzzles/day16").readText(Charset.defaultCharset())
fun part1(input: String) {
val ranges = input.split("\n\n")[0].split("\n").flatMap { policyLi... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 3,964 | aoc2020 | Apache License 2.0 |
src/Day04.kt | rickbijkerk | 572,911,701 | false | {"Kotlin": 31571} | fun main() {
fun part1(input: List<String>): Int {
val elves = input.filter { line ->
val elfOne = line.split(",")[0].let { it.split("-")[0].toInt() to it.split("-")[1].toInt() }
val elfTwo = line.split(",")[1].let { it.split("-")[0].toInt() to it.split("-")[1].toInt() }
... | 0 | Kotlin | 0 | 0 | 817a6348486c8865dbe2f1acf5e87e9403ef42fe | 1,732 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | korsik | 573,366,257 | false | {"Kotlin": 5186} | fun main() {
fun part1(input: List<String>): Int {
fun calculateOutcome(line: String): Int {
return when(line) {
"A Z", "B X", "C Y" -> 0
"A X", "B Y", "C Z" -> 3
"C X", "A Y", "B Z" -> 6
else -> error("Wrong Input!")
}
... | 0 | Kotlin | 0 | 0 | 1a576c51fc8233b1a2d64e44e9301c7f4f2b6b01 | 1,884 | aoc-2022-in-kotlin | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day11.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
import com.github.akowal.aoc.Day11.Op
class Day11 {
fun solvePart1(): Long {
return monkeyBusiness(20, 3)
}
fun solvePart2(): Long {
return monkeyBusiness(10000, 1)
}
private fun monkeyBusiness(rounds: Int, relief: Long): Long {
val monkeys =... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 2,969 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/Day02.kt | SnyderConsulting | 573,040,913 | false | {"Kotlin": 46459} | sealed class Choice {
abstract val points: Int
companion object {
fun parseChoice(value: String): Choice {
return when (value) {
"A", "X" -> Rock
"B", "Y" -> Paper
"C", "Z" -> Scissors
else -> Rock
}
}
... | 0 | Kotlin | 0 | 0 | ee8806b1b4916fe0b3d576b37269c7e76712a921 | 3,699 | Advent-Of-Code-2022 | Apache License 2.0 |
src/Day13.kt | ricardorlg-yml | 573,098,872 | false | {"Kotlin": 38331} | private sealed interface Packet : Comparable<Packet> {
fun add(packet: Packet) {
throw UnsupportedOperationException()
}
companion object {
fun parse(input: String): Packet {
val stack = ArrayDeque<Packet>()
var current: Packet? = null
var continueOnInde... | 0 | Kotlin | 0 | 0 | d7cd903485f41fe8c7023c015e4e606af9e10315 | 3,704 | advent_code_2022 | Apache License 2.0 |
src/main/kotlin/day5.kt | noamfree | 433,962,392 | false | {"Kotlin": 93533} | import kotlin.math.abs
import kotlin.math.max
private val testInput1 = """
0,9 -> 5,9
8,0 -> 0,8
9,4 -> 3,4
2,2 -> 2,1
7,0 -> 7,4
6,4 -> 2,0
0,9 -> 2,9
3,4 -> 1,4
0,0 -> 8,8
5,5 -> 8,2
""".trimIndent()
private fun tests() {
val testLines = parseInput(testInput1)
assertE... | 0 | Kotlin | 0 | 0 | 566cbb2ef2caaf77c349822f42153badc36565b7 | 2,784 | AOC-2021 | MIT License |
src/main/kotlin/aoc/Day11.kt | dtsaryov | 573,392,550 | false | {"Kotlin": 28947} | package aoc
import java.math.BigInteger
import java.util.*
private val operationRegex = Regex("\\s*Operation: new = (old|\\d+) ([+\\-*/]) (old|\\d+)")
private const val ROUNDS = 10_000
fun main() {
val input = readInput("day11.txt") ?: return
val monkeys = parseMonkeys(input)
println(sumOfTwoMostActiveM... | 0 | Kotlin | 0 | 0 | 549f255f18b35e5f52ebcd030476993e31185ad3 | 3,306 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-03.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2023
import com.github.ferinagy.adventOfCode.Coord2D
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2023, "03-input")
val test1 = readInputLines(2023, "03-test1")
pr... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,031 | advent-of-code | MIT License |
src/main/kotlin/days/Day9.kt | butnotstupid | 571,247,661 | false | {"Kotlin": 90768} | package days
import kotlin.math.sign
class Day9 : Day(9) {
override fun partOne(): Any = calculateNextKnotVisits(inputList.map { it.split(" ") }
.map { Configuration.fromCode(it[0]) to it[1].toInt() }).toSet().size
override fun partTwo(): Any =
generateSequence(inputList.map { it.split(" ") ... | 0 | Kotlin | 0 | 0 | 4760289e11d322b341141c1cde34cfbc7d0ed59b | 2,892 | aoc-2022 | Creative Commons Zero v1.0 Universal |
kotlin/src/main/kotlin/year2023/Day11.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
import kotlin.math.abs
fun main() {
val input = readInput("Day11")
Day11.part1(input).println()
Day11.part2(input).println()
}
object Day11 {
fun part1(input: List<String>): Long {
val expandedGalaxy = expandGalaxy(input)
val galaxies = findGalaxies(expandedGalaxy)
... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 3,858 | advent-of-code | MIT License |
src/Day02.kt | MisterTeatime | 560,956,854 | false | {"Kotlin": 37980} | fun main() {
/*
A, X = Rock
B, Y = Paper
C, Z = Scissors
*/
fun part1(input: List<String>): Int {
val duelPoints = mapOf(
"AX" to 3 + 1, //Rock, Rock, Draw
"AY" to 6 + 2, //Rock, Paper, Win
"AZ" to 0 + 3, //Rock, Scissors, Loss
... | 0 | Kotlin | 0 | 0 | 8ba0c36992921e1623d9b2ed3585c8eb8d88718e | 1,672 | AoC2022 | Apache License 2.0 |
src/Day18.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | class Droplet(val points: Set<Triple<Int,Int,Int>>) {
val minZ = points.minOf { it.third }
val maxZ = points.maxOf { it.third }
val minY = points.minOf { it.second }
val maxY = points.maxOf { it.second }
val minX = points.minOf { it.first }
val maxX = points.maxOf { it.first }
val wormholes... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 3,801 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/org/hydev/lcci/lcci_05.kt | VergeDX | 334,298,924 | false | null | import kotlin.math.max
// https://leetcode-cn.com/problems/insert-into-bits-lcci/
fun insertBits(N: Int, M: Int, i: Int, j: Int): Int {
// https://stackoverflow.com/questions/50173028/how-to-get-binary-representation-of-int-in-kotlin
var rawNReversed = Integer.toBinaryString(N).reversed()
val insertM = Int... | 0 | Kotlin | 0 | 0 | 9a26ac2e24b0a0bdf4ec5c491523fe9721c6c406 | 2,898 | LeetCode_Practice | MIT License |
src/main/kotlin/RPS.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | import java.lang.RuntimeException
fun main() {
RPS.solve()
}
private object RPS {
// Day 2
fun solve() {
val input = readInput()
var result = 0
for (pair in input) {
val myMove = when(pair.second) {
Result.Draw -> pair.first
Result.Win ->... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 2,338 | aoc2022 | MIT License |
src/Day04.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | fun main() {
fun part1(input: List<String>): Int =
input
.map { it.toRangePair() }
.count { it.first.contains(it.second) || it.second.contains(it.first) }
fun part2(input: List<String>): Int =
input
.map { it.toRangePair() }
.count { it.containsO... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 976 | aoc-2022 | Apache License 2.0 |
src/Day21.kt | Riari | 574,587,661 | false | {"Kotlin": 83546, "Python": 1054} | fun main() {
class OperationMonkey(val leftId: String, val rightId: String, val operation: Char)
fun processInput(input: List<String>): Pair<MutableMap<String, Long>, MutableMap<String, OperationMonkey>> {
val yellers = mutableMapOf<String, Long>()
val operators = mutableMapOf<String, Operation... | 0 | Kotlin | 0 | 0 | 8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d | 4,190 | aoc-2022 | Apache License 2.0 |
04/part_one.kt | ivanilos | 433,620,308 | false | {"Kotlin": 97993} | import java.io.File
private const val SIZE = 5
fun readInput() : Pair<List<Int>, List<Board>> {
val lines = File("input.txt")
.readLines()
.map { it.split("\n") }
.filter{ it[0] != "" }
val numbers = lines[0][0].split(",").map{ it.toInt() }
val boards = mutableListOf<B... | 0 | Kotlin | 0 | 3 | a24b6f7e8968e513767dfd7e21b935f9fdfb6d72 | 2,153 | advent-of-code-2021 | MIT License |
src/main/kotlin/_2019/Day10.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2019
import aocRun
import between
import kotlin.math.abs
import kotlin.math.atan2
fun main() {
aocRun(puzzleInput) { calcBestAsteroid(parseAsteroidGrid(it)) }
aocRun(puzzleInput) { input ->
val asteroidGrid = parseAsteroidGrid(input)
val gunPos = calcBestAsteroid(asteroidGrid)
... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 6,346 | AdventOfCode | Creative Commons Zero v1.0 Universal |
2020/src/year2020/day10/Day10.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2020.day10
import util.readAllLinesAsInt
private fun readInput(filename: String) =
readAllLinesAsInt(filename).sorted().toMutableList().apply {
add(0, 0)
add(checkNotNull(maxOrNull()) + 3)
}
private fun findOnesAndThrees(filename: String) {
val input = readInput(filename)
... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 1,802 | adventofcode | MIT License |
src/Day03.kt | SimoneStefani | 572,915,832 | false | {"Kotlin": 33918} | fun main() {
fun letterToPriority(letter: Char): Int = when (letter) {
in 'A'..'Z' -> letter.code - 38 // ASCII code of "A" starts at 65
in 'a'..'z' -> letter.code - 96 // ASCII code of "a" starts at 97
else -> throw IllegalStateException("Invalid character!")
}
fun part1(input: Lis... | 0 | Kotlin | 0 | 0 | b3244a6dfb8a1f0f4b47db2788cbb3d55426d018 | 1,385 | aoc-2022 | Apache License 2.0 |
src/poyea/aoc/mmxxii/day09/Day09.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day09
import poyea.aoc.utils.readInput
import kotlin.math.abs
import kotlin.math.sign
data class Point(val x: Int, val y: Int) {
fun moveTowards(other: Point) = this + Point((other.x - x).sign, (other.y - y).sign)
fun isNear(other: Point) = abs(other.x - x) < 2 && abs(other.y - y) < ... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 2,022 | aoc-mmxxii | MIT License |
src/y2023/Day15.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2023
import util.readInput
import util.timingStatistics
object Day15 {
private fun parse(input: List<String>): List<String> {
return input.first().split(",")
}
fun part1(input: List<String>): Int {
val parsed = parse(input)
return parsed.sumOf { hash(it) }
}
fun ... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,484 | advent-of-code | Apache License 2.0 |
day23/src/main/kotlin/Main.kt | rstockbridge | 159,586,951 | false | null | import java.io.File
fun main() {
val nanobots = parseInput(readInputFile())
println("Part I: the solution is ${solvePartI(nanobots)}.")
println("Part II: not solved; no general algorithm apparently available.")
}
fun readInputFile(): List<String> {
return File(ClassLoader.getSystemResource("input.txt... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 1,671 | AdventOfCode2018 | MIT License |
cz.wrent.advent/Day9.kt | Wrent | 572,992,605 | false | {"Kotlin": 206165} | package cz.wrent.advent
fun main() {
println(partOne(test))
val result = partOne(input)
println("9a: $result")
println(partTwo(test))
println(partTwo(test2))
val resultTwo = partTwo(input)
println("9b: $resultTwo")
}
private fun partOne(input: String): Long {
val commands = input.split("\n")
.map { it.spl... | 0 | Kotlin | 0 | 0 | 8230fce9a907343f11a2c042ebe0bf204775be3f | 10,785 | advent-of-code-2022 | MIT License |
src/day13/Day13.kt | ayukatawago | 572,742,437 | false | {"Kotlin": 58880} | package day13
import readInput
fun main() {
val testInput = readInput("day13/test")
val packets = testInput.filter { it.isNotBlank() }.map { Packet.from(it) }
part1(packets)
part2(packets)
}
private fun part1(packets: List<Packet>) {
val answer = packets.chunked(2).mapIndexed { index, pair ->
... | 0 | Kotlin | 0 | 0 | 923f08f3de3cdd7baae3cb19b5e9cf3e46745b51 | 2,314 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | KliminV | 573,758,839 | false | {"Kotlin": 19586} | fun main() {
fun part1(input: List<String>): Int {
return input.asSequence().map {
it.split(",", "-")
}
.flatten().map {
it.toInt()
}.chunked(4).map { (a, b, c, d) ->
if (a == c) 1
else if (a < c) {
... | 0 | Kotlin | 0 | 0 | 542991741cf37481515900894480304d52a989ae | 1,001 | AOC-2022-in-kotlin | Apache License 2.0 |
2021/src/day24/Solution.kt | vadimsemenov | 437,677,116 | false | {"Kotlin": 56211, "Rust": 37295} | package day24
import java.nio.file.Files
import java.nio.file.Paths
import java.util.TreeMap
import kotlin.system.measureTimeMillis
fun main() {
fun Char.registerId() = code - 'w'.code
val alu = longArrayOf(0, 0, 0, 0)
var nextInput = -1
fun String.parseCommand(): Command {
return if (startsWith("inp ")... | 0 | Kotlin | 0 | 0 | 8f31d39d1a94c862f88278f22430e620b424bd68 | 2,776 | advent-of-code | Apache License 2.0 |
src/Day02.kt | robotfooder | 573,164,789 | false | {"Kotlin": 25811} | import Shape.*
import Result.*
import java.lang.IllegalArgumentException
enum class Shape(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3) }
enum class Result(val points: Int) { WIN(6), DRAW(3), LOOSE(0) }
fun main() {
fun mapToShape(shape: String): Shape {
return when (shape) {
"X", "A" ->... | 0 | Kotlin | 0 | 0 | 9876a52ef9288353d64685f294a899a58b2de9b5 | 2,711 | aoc2022 | Apache License 2.0 |
src/main/kotlin/day15/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day15
import java.io.File
import java.util.*
fun main() {
val lines = File("src/main/kotlin/day15/input.txt").readLines()
val mapSize = lines.size
val riskLevelGrid: Array<IntArray> = Array(mapSize) { i -> lines[i].map { it.digitToInt() }.toIntArray() }
val minimumRiskLevelGrid: Array<IntArra... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 2,620 | aoc-2021 | MIT License |
src/Day05.kt | SebastianHelzer | 573,026,636 | false | {"Kotlin": 27111} |
fun main() {
val day = "05"
fun List<String>.toState(): List<String> {
val numCols = last().split(" ").filterNot { it.isBlank() }.size
val mutableList = MutableList(numCols) { "" }
dropLast(1).forEach {
it.chunked(4)
.mapIndexed { index, s -> index to s[1] }... | 0 | Kotlin | 0 | 0 | e48757626eb2fb5286fa1c59960acd4582432700 | 2,240 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | strindberg | 572,685,170 | false | {"Kotlin": 15804} | sealed class File {
abstract fun size(): Int
}
class TextFile(private val size: Int) : File() {
override fun size(): Int = size
}
class Dir(private val parent: Dir?) : File() {
private val children: MutableMap<String, File> = mutableMapOf()
override fun size(): Int = children.values.sumOf { it.size()... | 0 | Kotlin | 0 | 0 | c5d26b5bdc320ca2aeb39eba8c776fcfc50ea6c8 | 2,030 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day04.kt | brigham | 573,127,412 | false | {"Kotlin": 59675} | fun toRange(s: String): IntRange {
val (start, end) = s.split(',')
return (start.toInt())..(end.toInt())
}
fun toRange(l: List<String>): IntRange {
return (l[0].toInt())..(l[1].toInt())
}
fun main() {
fun parse(input: List<String>) = input.map { it.split(',') }
.map { it[0] to it[1] }
... | 0 | Kotlin | 0 | 0 | b87ffc772e5bd9fd721d552913cf79c575062f19 | 970 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g2101_2200/s2188_minimum_time_to_finish_the_race/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2101_2200.s2188_minimum_time_to_finish_the_race
// #Hard #Array #Dynamic_Programming #2023_06_26_Time_1220_ms_(100.00%)_Space_117_MB_(100.00%)
class Solution {
fun minimumFinishTime(tires: Array<IntArray>, changeTime: Int, numLaps: Int): Int {
var minf = Int.MAX_VALUE
// find the minimum ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,108 | LeetCode-in-Kotlin | MIT License |
codeforces/round576/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.round576
fun main() {
val n = readInt()
val f = Array(n) { readLn().map { if (it == '#') 1 else 0 } }
val cum = Array(n + 1) { IntArray(n + 1) }
for (i in 0 until n) {
for (j in 0 until n) {
cum[i + 1][j + 1] = cum[i][j + 1] + cum[i + 1][j] - cum[i][j] + f[i][j]
}
}
val dp = Array(n + 1... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,174 | competitions | The Unlicense |
src/Day13.kt | Cryosleeper | 572,977,188 | false | {"Kotlin": 43613} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
val pairs = input.parse()
val indexes = mutableListOf<Int>()
pairs.forEachIndexed { pairIndex, pair ->
if (pair.first precedes pair.second) indexes.add(pairIndex)
}
return indexes.sumOf { ... | 0 | Kotlin | 0 | 0 | a638356cda864b9e1799d72fa07d3482a5f2128e | 4,541 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day13.kt | cbrentharris | 712,962,396 | false | {"Kotlin": 171464} | import kotlin.String
import kotlin.collections.List
object Day13 {
private const val NORMAL_MULTIPLIER = 100
private const val TRANSPOSED_MULTIPLIER = 1
fun part1(input: List<String>): String {
val grids = parseGrids(input)
return grids.sumOf { grid ->
// Transposed is actuall... | 0 | Kotlin | 0 | 1 | f689f8bbbf1a63fecf66e5e03b382becac5d0025 | 3,784 | kotlin-kringle | Apache License 2.0 |
src/Day09.kt | dmarmelo | 573,485,455 | false | {"Kotlin": 28178} | import kotlin.math.absoluteValue
private typealias Rope = List<Point2D>
private enum class Direction {
UP, DOWN, LEFT, RIGHT
}
fun main() {
fun String.toDirection() = when (this) {
"U" -> Direction.UP
"D" -> Direction.DOWN
"L" -> Direction.LEFT
"R" -> Direction.RIGHT
e... | 0 | Kotlin | 0 | 0 | 5d3cbd227f950693b813d2a5dc3220463ea9f0e4 | 2,135 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem542/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem542
/**
* LeetCode page: [542. 01 Matrix](https://leetcode.com/problems/01-matrix/);
*/
class Solution {
/* Complexity:
* Time O(MN) and Space O(MN) where M and N are the number of rows and columns in mat;
*/
fun updateMatrix(mat: Array<IntArray>): Array<IntArr... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,382 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/io/steinh/aoc/day04/Scratchcard.kt | daincredibleholg | 726,426,347 | false | {"Kotlin": 25396} | package io.steinh.aoc.day04
class Scratchcard {
fun calculatePoints(lines: List<String>) = getMatchingNumbers(lines).sum()
fun calculateNumberOfCardsWon(lines: List<String>): Int {
val givenNumberOfCards = lines.size
val numberOfCards = initCardStack(givenNumberOfCards)
for (line in l... | 0 | Kotlin | 0 | 0 | 4aa7c684d0e337c257ae55a95b80f1cf388972a9 | 3,303 | AdventOfCode2023 | MIT License |
src/year2022/day07/Solution.kt | LewsTherinTelescope | 573,240,975 | false | {"Kotlin": 33565} | package year2022.day07
import utils.runIt
import java.util.LinkedList
fun main() = runIt(
testInput = """
$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
... | 0 | Kotlin | 0 | 0 | ee18157a24765cb129f9fe3f2644994f61bb1365 | 2,225 | advent-of-code-kotlin | Do What The F*ck You Want To Public License |
src/Day05.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | import java.io.File
fun main() {
class MyStack {
var crates = mutableListOf<Char>()
}
fun MyStack.remove(n: Int): MutableList<Char>{
val removedCrates = this.crates.subList(this.crates.size-n, this.crates.size)
this.crates = this.crates.subList(0, this.crates.size-n)
... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 2,661 | aoc22 | Apache License 2.0 |
src/main/kotlin/day04_squid_bingo/SquidBingo.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day04_squid_bingo
/**
* Our first non-homogenous input: the first line is the called balls while the
* rest is a series of multi-line segments. We also have a bunch of parallel
* compound states (the boards) to manage as we iterate through an "unrelated"
* series of items (the balls). And, of course, the f... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 2,802 | aoc-2021 | MIT License |
src/day04/Day04.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day04
import readInput
typealias Day04InputType1 = List<Pair<Pair<Int, Int>, Pair<Int, Int>>>
fun main() {
fun fullyOverlaps(fst: Pair<Int, Int>, snd: Pair<Int, Int>): Boolean =
(fst.first <= snd.first && fst.second >= snd.second) || (fst.first >= snd.first && fst.second <= snd.second)
fun ... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 1,414 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day21.kt | w8mr | 572,700,604 | false | {"Kotlin": 140954} | package aoc2022
import aoc.parser.*
class Day21() {
enum class Operation(val text: String, val function: (Double, Double) -> Double){
PLUS("+", Double::plus),
MINUS("-", Double::minus),
TIMES("*", Double::times),
DIV("/", Double::div)
}
sealed interface Monkey{
val... | 0 | Kotlin | 0 | 0 | e9bd07770ccf8949f718a02db8d09daf5804273d | 3,461 | aoc-kotlin | Apache License 2.0 |
src/main/kotlin/day18/day18.kt | corneil | 572,437,852 | false | {"Kotlin": 93311, "Shell": 595} | package day18
import main.utils.filterUnique
import main.utils.scanInts
import utils.checkNumber
import utils.readFile
import utils.readLines
import utils.separator
import kotlin.math.round
import kotlin.math.sqrt
fun main() {
val test = readLines(
"""2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5... | 0 | Kotlin | 0 | 0 | dd79aed1ecc65654cdaa9bc419d44043aee244b2 | 6,012 | aoc-2022-in-kotlin | Apache License 2.0 |
2021/src/main/kotlin/day18.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
import utils.mapItems
fun main() {
Day18Func.run()
}
object Day18Func : Solution<List<Day18Func.Tree>>() {
override val name = "day18"
override val parser = Parser.lines.mapItems { Tree.from(it).first }
override fun part1(input: List<Tree>): Int {
val sum = input... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 4,810 | aoc_kotlin | MIT License |
src/main/kotlin/day8.kt | gautemo | 433,582,833 | false | {"Kotlin": 91784} | import shared.getLines
fun findNumbers(input: List<String>): Int{
var one = 0
var four = 0
var seven = 0
var eight = 0
for(line in input){
val output = line.split("|").last().trim().split(" ")
one += output.count { it.length == 2 }
four += output.count { it.length == 4 }
... | 0 | Kotlin | 0 | 0 | c50d872601ba52474fcf9451a78e3e1bcfa476f7 | 4,543 | AdventOfCode2021 | MIT License |
advent-of-code2015/src/main/kotlin/day17/Advent17.kt | REDNBLACK | 128,669,137 | false | null | package day17
import combinations
import parseInput
import splitToLines
/**
--- Day 17: No Such Thing as Too Much ---
The elves bought too much eggnog again - 150 liters this time. To fit it all into your refrigerator, you'll need to move it into smaller containers. You take an inventory of the capacities of the ava... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 1,965 | courses | MIT License |
src/Day13.kt | wgolyakov | 572,463,468 | false | null | import kotlin.math.max
fun main() {
var index = 0
fun parseList(input: String): List<Any> {
if (input[index] != '[') error("Wrong input: $index")
index++
val list = mutableListOf<Any>()
while (index < input.length) {
val c = input[index]
if (c == '[') {
list.add(parseList(input))
} else if (c =... | 0 | Kotlin | 0 | 0 | 789a2a027ea57954301d7267a14e26e39bfbc3c7 | 2,432 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2023/Day23.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
class Day23(input: List<String>) {
private val trails = input.toGrid()
private val region = trails.region()
private val start = trails.region().topLeft + Vector2(1, 0)
private val end = trails.region().bottomRight - Vector2(1, 0)
private fun getNeighborsConsiderin... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 3,031 | advent-2023 | MIT License |
src/Day05.kt | mpylypovych | 572,998,434 | false | {"Kotlin": 6455} | fun main() {
fun solve(input: List<String>, pred : (MutableList<ArrayDeque<Char>>, Int, Int, Int) -> Unit) : String {
val numLine = input.indexOfFirst { it.contains('1') }
val stacksCount = input[numLine].split(' ').last { it.isNotEmpty() }.toInt()
// assuming the stacks count is single-di... | 0 | Kotlin | 0 | 0 | 733b35c3f4eea777a5f666c804f3c92d0cc9854b | 1,642 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/de/nosswald/aoc/days/Day08.kt | 7rebux | 722,943,964 | false | {"Kotlin": 34890} | package de.nosswald.aoc.days
import de.nosswald.aoc.Day
// https://adventofcode.com/2023/day/8
object Day08 : Day<Long>(8, "<NAME>") {
private enum class Direction { LEFT, RIGHT }
private fun parseInput(input: List<String>): Pair<List<Direction>, Map<String, Pair<String, String>>> {
val directions = ... | 0 | Kotlin | 0 | 1 | 398fb9873cceecb2496c79c7adf792bb41ea85d7 | 2,839 | advent-of-code-2023 | MIT License |
src/ad/kata/aoc2021/day12/Graph.kt | andrej-dyck | 433,401,789 | false | {"Kotlin": 161613} | package ad.kata.aoc2021.day12
import ad.kata.aoc2021.extensions.toMapMerging
data class Graph<T>(private val edges: Map<T, Set<T>>) {
fun distinctPaths(from: T, to: T, canRevisit: (T, Path<T>) -> Boolean = { _, _ -> false }) =
findPaths(from, to, canRevisit = { n, p -> canRevisit(n, p) && n != from })
... | 0 | Kotlin | 0 | 0 | 28d374fee4178e5944cb51114c1804d0c55d1052 | 1,392 | advent-of-code-2021 | MIT License |
src/Day21/Day21.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | class Dice(private val sides: Int) {
var counter: Int = 0
private set
fun roll(): Int {
var res = 0
for (i in 1..3) {
res += counter % sides + 1
counter++
}
return res
}
}
data class Position(val pos0: Int, val score0: Int, val pos1: Int, val... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 2,409 | advent-of-code-2021 | Apache License 2.0 |
src/day05/Day05.kt | palpfiction | 572,688,778 | false | {"Kotlin": 38770} | package day05
import readInput
import java.util.Stack
typealias CrateStack = Stack<Char>
typealias Arrangement = List<CrateStack>
typealias Command = Triple<Int, Int, Int>
inline fun <reified T> transpose(matrix: List<List<T>>): List<List<T>> {
return List(matrix[0].size) { col ->
List(matrix.size) { row... | 0 | Kotlin | 0 | 0 | 5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7 | 3,117 | advent-of-code | Apache License 2.0 |
src/year2022/day15/Day15.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day15
import Point2D
import readInputFileByYearAndDay
import readTestFileByYearAndDay
import kotlin.math.abs
data class Reading(val signal: Point2D, val closestBeacon: Point2D) {
private fun reach(): Int = signal manhattanDistance closestBeacon
private fun minReachableY(): Int = signal.y - re... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 3,731 | advent-of-code-kotlin | Apache License 2.0 |
ceria/03/src/main/kotlin/Solution.kt | VisionistInc | 317,503,410 | false | null | import java.io.File;
val tree :Char = '#'
fun main(args : Array<String>) {
val input = File(args.first()).readLines()
println("Solution 1: ${solution1(input)}")
println("Solution 2: ${solution2(input)}")
}
private fun solution1(input :List<String>) :Int {
return checkSlope(findTrees(input, 3), input.... | 0 | Rust | 0 | 0 | 002734670384aa02ca122086035f45dfb2ea9949 | 1,650 | advent-of-code-2020 | MIT License |
day12/src/main/kotlin/com/lillicoder/adventofcode2023/day12/Day12.kt | lillicoder | 731,776,788 | false | {"Kotlin": 98872} | package com.lillicoder.adventofcode2023.day12
import kotlin.math.min
fun main() {
val day12 = Day12()
val springs = SpringsParser().parse("input.txt")
println("The number of valid arrangements for factor 1 is ${day12.part1(springs)}.")
println("The number of valid arrangements for factor 5 is ${day12.... | 0 | Kotlin | 0 | 0 | 390f804a3da7e9d2e5747ef29299a6ad42c8d877 | 4,454 | advent-of-code-2023 | Apache License 2.0 |
solutions/src/Day15.kt | khouari1 | 573,893,634 | false | {"Kotlin": 132605, "HTML": 175} | import kotlin.math.abs
typealias Coord = Pair<Int, Int>
fun main() {
fun part1(input: List<String>, targetLineY: Int): Int {
// find sensors close to the target line
val allBeaconCoords = getBeaconCoords(input)
val intersectedCoords = mutableSetOf<Coord>()
input.forEach { line ->
... | 0 | Kotlin | 0 | 1 | b00ece4a569561eb7c3ca55edee2496505c0e465 | 5,711 | advent-of-code-22 | Apache License 2.0 |
src/Day04.kt | simonitor | 572,972,937 | false | {"Kotlin": 8461} | import kotlin.math.max
import kotlin.math.min
fun main() {
// first
val input = readInput("inputDay4")
val ranges = input.map { it.split(",") }
println(findNumberOfFullyContainedRanges(ranges))
// second
println(findNumberOfOverlappingRanges(ranges))
}
fun findNumberOfFullyContainedRanges(inpu... | 0 | Kotlin | 0 | 0 | 11d567712dd3aaf3c7dee424a3442d0d0344e1fa | 1,359 | AOC2022 | Apache License 2.0 |
src/Day05.kt | robinpokorny | 572,434,148 | false | {"Kotlin": 38009} | typealias Stacks = List<ArrayDeque<Char>>
typealias Steps = List<Triple<Int, Int, Int>>
private fun parse(input: List<String>): Pair<Stacks, Steps> {
val (rawStacks, rawSteps) = input
.joinToString("\n")
.split("\n\n")
.map { it.lines() }
val stacksPrepared = rawStacks
.reverse... | 0 | Kotlin | 0 | 2 | 56a108aaf90b98030a7d7165d55d74d2aff22ecc | 2,104 | advent-of-code-2022 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.