path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/mirecxp/aoc23/day04/Day04.kt | MirecXP | 726,044,224 | false | {"Kotlin": 42343} | package mirecxp.aoc23.day04
import mirecxp.aoc23.readInput
//https://adventofcode.com/2023/day/4
class Day04(private val inputPath: String) {
private val lines: List<String> = readInput(inputPath)
class Card(val id: Int, val wins: Int)
val allCards = mutableMapOf<Int, MutableList<Card>>()
fun solv... | 0 | Kotlin | 0 | 0 | 6518fad9de6fb07f28375e46b50e971d99fce912 | 2,075 | AoC-2023 | MIT License |
y2022/src/main/kotlin/adventofcode/y2022/Day23.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
import adventofcode.util.collections.cycle
import adventofcode.util.vector.Direction
import adventofcode.util.vector.Vec2
object Day23 : AdventSolution(2022, 23, "Unstable Diffusion") {
override fun solvePartOne(input: String): Int {
val e... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,068 | advent-of-code | MIT License |
src/main/kotlin/Day16.kt | lanrete | 244,431,253 | false | null | data class Interval(val start: Int, val end: Int) {
override fun toString() = "$start ~ $end"
}
object Day16 : Solver() {
data class IntervalTreeNode(
val start: Int, val end: Int, var sum: Int = 0,
var leftChild: IntervalTreeNode? = null, var rightChild: IntervalTreeNode? = null
)
da... | 0 | Kotlin | 0 | 1 | 15125c807abe53230e8d0f0b2ca0e98ea72eb8fd | 4,615 | AoC2019-Kotlin | MIT License |
y2019/src/main/kotlin/adventofcode/y2019/Day24.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2019
import adventofcode.io.AdventSolution
import adventofcode.util.collections.firstDuplicate
import adventofcode.util.vector.Vec3
fun main() = Day24.solve()
object Day24 : AdventSolution(2019, 24, "Planet of Discord") {
override fun solvePartOne(input: String) =
generateSeque... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 3,535 | advent-of-code | MIT License |
src/main/kotlin/_2018/Day8.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2018
import aocRun
import java.util.concurrent.atomic.AtomicInteger
fun main() {
aocRun(puzzleInput) {
return@aocRun sumMetadata(parseTree(it))
}
aocRun(puzzleInput) {
return@aocRun calcNodeValue(parseTree(it))
}
}
private fun parseTree(input: String): Node {
val iterato... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 35,641 | AdventOfCode | Creative Commons Zero v1.0 Universal |
y2021/src/main/kotlin/adventofcode/y2021/Day22.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
object Day22 : AdventSolution(2021, 22, "Reactor Reboot") {
override fun solvePartOne(input: String) = parse(input).take(20).let(::solve)
override fun solvePartTwo(input: String) = parse(input).let(::solve)
private fun solve(input: Sequence... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,596 | advent-of-code | MIT License |
src/Day02.kt | graesj | 572,651,121 | false | {"Kotlin": 10264} | sealed class Move(val points: Int)
object Rock : Move(points = 1)
object Paper : Move(points = 2)
object Scissor : Move(points = 3)
sealed class GameResult(val points: Int)
object Victory : GameResult(points = 6)
object Draw : GameResult(points = 3)
object Loss : GameResult(points = 0)
fun charToMove(char: Char): Mov... | 0 | Kotlin | 0 | 0 | df7f855a14c532f3af7a8dc86bd159e349cf59a6 | 2,568 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/y2023/Day8.kt | juschmitt | 725,529,913 | false | {"Kotlin": 18866} | package y2023
import utils.Day
import kotlin.math.max
class Day8 : Day(8, 2023, false) {
override fun partOne(): Any {
val (directions, map) = inputString.parseDirectionsAndMap()
return map.findStepsToEnd(directions.toCharArray())
}
override fun partTwo(): Any {
val (directions, ... | 0 | Kotlin | 0 | 0 | b1db7b8e9f1037d4c16e6b733145da7ad807b40a | 2,814 | adventofcode | MIT License |
src/Day14.kt | djleeds | 572,720,298 | false | {"Kotlin": 43505} | import lib.Coordinates
import lib.Direction
import lib.get
enum class Material { AIR, ROCK, SAND }
private fun printGrid(grid: List<List<Material>>) {
for (y in grid.indices) {
println("")
for (x in grid[y].indices) {
when (grid[y][x]) {
Material.AIR -> print(".")
... | 0 | Kotlin | 0 | 4 | 98946a517c5ab8cbb337439565f9eb35e0ce1c72 | 2,765 | advent-of-code-in-kotlin-2022 | Apache License 2.0 |
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day06.kt | JamJaws | 725,792,497 | false | {"Kotlin": 30656} | package com.jamjaws.adventofcode.xxiii.day
import com.jamjaws.adventofcode.xxiii.readInput
class Day06 {
fun part1(text: List<String>): Long {
val races = text.fold(listOf<Race>()) { acc, line ->
line.substringAfter(":")
.split(' ')
.filter(String::isNotBlank)
... | 0 | Kotlin | 0 | 0 | e2683305d762e3d96500d7268e617891fa397e9b | 1,634 | advent-of-code-2023 | MIT License |
src/main/kotlin/pl/mrugacz95/aoc/day18/day18.kt | mrugacz95 | 317,354,321 | false | null | import pl.mrugacz95.aoc.day13.sumByLong
import java.lang.RuntimeException
import java.util.Stack
const val MUL = "*"
const val ADD = "+"
const val LBR = "("
const val RBR = ")"
fun evaluateRPN(expression: List<String>): Long {
val stack = Stack<String>()
for (term in expression) {
when (term) {
... | 0 | Kotlin | 0 | 1 | a2f7674a8f81f16cd693854d9f564b52ce6aaaaf | 2,293 | advent-of-code-2020 | Do What The F*ck You Want To Public License |
src/Day13.kt | MatthiasDruwe | 571,730,990 | false | {"Kotlin": 47864} | import kotlin.math.abs
fun eq(item1: MutableList<Any>, item2: MutableList<Any>): Int {
repeat(item1.size) { x ->
if (x == item2.size) {
return -1
}
if (item1[x] is MutableList<*> && item2[x] is MutableList<*>) {
val result = eq(item1[x] as MutableList<Any>, item2[x... | 0 | Kotlin | 0 | 0 | f35f01cea5075cfe7b4a1ead9b6480ffa57b4989 | 3,626 | Advent-of-code-2022 | Apache License 2.0 |
src/year2023/01/Day01.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2023.`01`
import readInput
import utils.printDebug
private const val CURRENT_DAY = "01"
private val mapOfValues = mapOf(
"one" to 1,
"two" to 2,
"three" to 3,
"four" to 4,
"five" to 5,
"six" to 6,
"seven" to 7,
"eight" to 8,
"nine" to 9,
"1" to 1,
"2" to 2,
... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 1,987 | KotlinAdventOfCode | Apache License 2.0 |
src/Day07.kt | vladislav-og | 573,326,483 | false | {"Kotlin": 27072} | fun main() {
var dirChildrenConnect = hashMapOf<String, HashSet<String>>()
var dirFileSizes = hashMapOf<String, Int>()
fun calculateDirTotalSize(dir: String): Int {
var children = dirChildrenConnect[dir]!!.toList()
var totalSize = 0
while (children.isNotEmpty()) {
val ... | 0 | Kotlin | 0 | 0 | b230ebcb5705786af4c7867ef5f09ab2262297b6 | 3,543 | advent-of-code-2022 | Apache License 2.0 |
src/Day14.kt | arhor | 572,349,244 | false | {"Kotlin": 36845} | fun main() {
val input = readInput {}
println("Part 1: ${solvePuzzle1(input)}")
println("Part 2: ${solvePuzzle2(input)}")
}
private fun solvePuzzle1(input: List<String>): Int {
val model = Model.parse(input)
val xIndicies = 0..(model.xMax - model.xMin)
val yIndicies = 0..model.yMax
val s... | 0 | Kotlin | 0 | 0 | 047d4bdac687fd6719796eb69eab2dd8ebb5ba2f | 3,318 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/advent/y2018/day2.kt | IgorPerikov | 134,053,571 | false | {"Kotlin": 29606} | package advent.y2018
import misc.readAdventInput
/**
* https://adventofcode.com/2018/day/2
*/
fun main(args: Array<String>) {
val ids = readAdventInput(2, 2018)
calculateChecksum(ids).also { println(it) }
commonCharactersOfBoxes(ids).also { println(it) }
}
private fun calculateChecksum(ids: List<String... | 0 | Kotlin | 0 | 0 | b30cf179f7b7ae534ee55d432b13859b77bbc4b7 | 1,964 | kotlin-solutions | MIT License |
src/Day03.kt | Longtainbin | 573,466,419 | false | {"Kotlin": 22711} | fun main() {
val input = readInput("inputDay03")
fun part1(input: List<String>): Int {
return input.sumOf { processPart1(it) }
}
fun part2(input: List<String>): Int {
val n = 3
val groups = input.size / n
var sum = 0
for (group in 1..groups) {
val s... | 0 | Kotlin | 0 | 0 | 48ef88b2e131ba2a5b17ab80a0bf6a641e46891b | 1,542 | advent-of-code-2022 | Apache License 2.0 |
2021/src/main/kotlin/days/Day4.kt | pgrosslicht | 160,153,674 | false | null | package days
import Day
import com.google.common.collect.HashBasedTable
class Day4 : Day(4) {
override fun partOne(): Int {
val values = dataList.take(1).single().split(",")
val boards = dataList.drop(2).chunked(6).map { Bingo(it) }
for (v in values) {
boards.singleOrNull { it.... | 0 | Kotlin | 0 | 0 | 1f27fd65651e7860db871ede52a139aebd8c82b2 | 2,211 | advent-of-code | MIT License |
src/Day03.kt | Moonpepperoni | 572,940,230 | false | {"Kotlin": 6305} | fun main() {
fun String.toRuckSack() : RuckSack {
val leftPocket = this.substring(0 until this.length/2).toSet()
val rightPocket = this.substring(this.length/2..this.lastIndex).toSet()
return RuckSack(leftPocket, rightPocket)
}
fun RuckSack.getCommonChar() : Char {
return (... | 0 | Kotlin | 0 | 0 | 946073042a985a5ad09e16609ec797c075154a21 | 1,667 | moonpepperoni-aoc-2022 | Apache License 2.0 |
src/main/kotlin/day21_dirac_dice/DiracDice.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day21_dirac_dice
import histogram.Histogram
import histogram.count
import histogram.histogramOf
import histogram.mutableHistogramOf
import kotlin.math.max
/**
* A simple rules engine is needed: modular arithmetic, a little bookkeeping,
* and careful attention to boundary conditions in a two-phase loop. Not ... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 3,117 | aoc-2021 | MIT License |
2020/src/year2021/day11/code.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2021.day11
import util.readAllLines
private fun countFlashes(grid: List<List<Octopus>>, iteration: Int, maxIterations: Int): Int {
if (iteration > maxIterations) return 0
var numFlashed = 0
var justFlashed = initialStep(grid)
while (justFlashed.isNotEmpty()) {
numFlashed += justFl... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 2,903 | adventofcode | MIT License |
src/Day02.kt | kmes055 | 577,555,032 | false | {"Kotlin": 35314} | import java.lang.IllegalArgumentException
import java.util.Collections.shuffle
fun main() {
fun calcScore(round: String): Int {
val opponent = round.first() - 'A'
val player = round.last() - 'A'
val outcomeScore = when ((opponent - player).mod(3)) {
0 -> 3
1 -> 0
... | 0 | Kotlin | 0 | 0 | 84c2107fd70305353d953e9d8ba86a1a3d12fe49 | 2,022 | advent-of-code-kotlin | Apache License 2.0 |
src/Day05.kt | Jessenw | 575,278,448 | false | {"Kotlin": 13488} | fun main() {
fun part1(input: List<String>): String {
val stacks: List<ArrayDeque<String>> = buildStacks(input[0].lines())
val moves: List<List<Int>> = buildMoves(input[1].lines())
moves.forEach {
for (i in 0 until it[0])
stacks[it[2] - 1].addLast(stacks[it[1] - ... | 0 | Kotlin | 0 | 0 | 05c1e9331b38cfdfb32beaf6a9daa3b9ed8220a3 | 2,393 | aoc-22-kotlin | Apache License 2.0 |
src/Day03.kt | jwalter | 573,111,342 | false | {"Kotlin": 19975} | fun main() {
fun codeScore(code: Int): Int {
return if (code >= 98) {
code - 96
} else {
code - 38
}
}
fun score(rucksackContents: List<String>): Int {
val common = rucksackContents.drop(1).fold(rucksackContents.first()) { acc, s ->
s.fil... | 0 | Kotlin | 0 | 0 | 576aeabd297a7d7ee77eca9bb405ec5d2641b441 | 1,335 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day08.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2023
import utils.InputUtils
private enum class Direction{
LEFT, RIGHT;
}
private fun parseDirection(c: Char) = when(c) {
'L' -> Direction.LEFT
'R' -> Direction.RIGHT
else -> throw IllegalArgumentException("Wrong char $c")
}
data class Position(val index: Int, val loc: String)
private cla... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 3,171 | aoc-2022-kotlin | Apache License 2.0 |
src/Day16.kt | kenyee | 573,186,108 | false | {"Kotlin": 57550} | data class Valve(
val name: String,
val rate: Int,
val connections: List<String>
)
val valveLookup = mutableMapOf<String, Valve>()
fun main() { // ktlint-disable filename
val regex = "Valve ([A-Z]+) has flow rate=([0-9]+); tunnel[s]* lead[s]* to valve[s]* ([A-Z, ]+)".toRegex()
fun searchMax(
... | 0 | Kotlin | 0 | 0 | 814f08b314ae0cbf8e5ae842a8ba82ca2171809d | 2,254 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2023/day04/day4.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2023.day04
import biz.koziolek.adventofcode.findInput
import kotlin.math.pow
fun main() {
val inputFile = findInput(object {})
val scratchCards = parseScratchCards(inputFile.bufferedReader().readLines())
println("Total points: ${scratchCards.sumOf { it.points }}")
... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 2,123 | advent-of-code | MIT License |
src/Day03.kt | 3n3a-archive | 573,389,832 | false | {"Kotlin": 41221, "Shell": 534} | fun Day03() {
fun preprocess(input: List<String>): List<List<CharArray>> {
val charArrays = input
.map { it.toCharArray() }
.map {
val size = it.size
listOf(
it.copyOfRange(0, (size + 1) / 2),
it.copyOfRange((siz... | 0 | Kotlin | 0 | 0 | fd25137d2d2df0aa629e56981f18de52b25a2d28 | 2,410 | aoc_kt | Apache License 2.0 |
src/Day02.kt | adamgaafar | 572,629,287 | false | {"Kotlin": 12429} | var score = mutableListOf<Int>()
var secScore = mutableListOf<Int>()
fun main() {
fun part1(input: List<String>): Int {
for (i in input.indices){
determineWinner(input[i].last(),input[i].first())
}
return score.sum()
}
fun part2(input: List<String>): Int {
for (i... | 0 | Kotlin | 0 | 0 | 5c7c9a2e819618b7f87c5d2c7bb6e6ce415ee41e | 2,549 | AOCK | Apache License 2.0 |
src/Day05.kt | undermark5 | 574,819,802 | false | {"Kotlin": 67472} |
fun main() {
val numberRegex = Regex("\\d+")
val crateRegex = Regex("\\[[A-Z]]")
fun part1(input: List<String>): String {
val stacksText = input.takeWhile { it.isNotBlank() }
val steps = input.slice(input.indexOf("")..input.lastIndex).filterNot { it.isBlank() }.map {
val number... | 0 | Kotlin | 0 | 0 | e9cf715b922db05e1929f781dc29cf0c7fb62170 | 2,817 | AoC_2022_Kotlin | Apache License 2.0 |
src/Day07.kt | ekgame | 573,100,811 | false | {"Kotlin": 20661} | fun main() {
fun String.addIndent(indent: Int) = lines().joinToString("\n") { " ".repeat(indent) + it }
abstract class FileSystemEntry(val name: String) {
abstract val size: Int
}
class Directory(name: String, val parent: Directory? = null) : FileSystemEntry(name) {
override val size: ... | 0 | Kotlin | 0 | 2 | 0c2a68cedfa5a0579292248aba8c73ad779430cd | 3,838 | advent-of-code-2022 | Apache License 2.0 |
2022/src/day16/day16.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day16
import GREEN
import RESET
import printTimeMillis
import readInput
data class Valve(
val name: String,
val flowRate: Int,
val links: List<String> = mutableListOf(),
var isOpened: Boolean = false,
) {
fun shouldOpen() = flowRate > 0 && !isOpened
fun open() { isOpened = true }
f... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 4,032 | advent-of-code | Apache License 2.0 |
src/Day05.kt | dcbertelsen | 573,210,061 | false | {"Kotlin": 29052} | import java.io.File
fun main() {
fun dataToParts(input: String): Pair<String, String> {
val parts = input.split("\n\n")
return parts[0] to parts[1]
}
fun initStacks(input: String): Map<Int, MutableList<Char>>{
val lines = input.split("\n").reversed()
val stacks = lines[0].f... | 0 | Kotlin | 0 | 0 | 9d22341bd031ffbfb82e7349c5684bc461b3c5f7 | 2,282 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day04.kt | arturkowalczyk300 | 573,084,149 | false | {"Kotlin": 31119} | fun main() {
fun part1(input: List<String>): Int {
//divide lines to ranges per elf
var countRangeFullyContainsAnotherRange = 0
input.forEach { line ->
val ranges = line.split(',')
val rangeStringElf1 = ranges[0].split('-')
val rangeStringElf2 = ranges[1]... | 0 | Kotlin | 0 | 0 | 69a51e6f0437f5bc2cdf909919c26276317b396d | 1,794 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day12/Code.kt | ldickmanns | 572,675,185 | false | {"Kotlin": 48227} | package day12
import readInput
typealias Grid = Array<IntArray>
val Grid.nRows get() = size
val Grid.nColumns get() = first().size
operator fun Grid.get(coordinates: Coordinates) = this[coordinates.y][coordinates.x]
operator fun Grid.set(coordinates: Coordinates, int: Int) {
this[coordinates.y][coordinates.x] =... | 0 | Kotlin | 0 | 0 | 2654ca36ee6e5442a4235868db8174a2b0ac2523 | 4,158 | aoc-kotlin-2022 | Apache License 2.0 |
src/Day05.kt | Cryosleeper | 572,977,188 | false | {"Kotlin": 43613} | import java.util.Deque
import java.util.LinkedList
fun main() {
fun part1(input: List<String>): String {
val (stacks, moves) = input.parseInput()
for (move in moves) {
for (x in 0 until move.number) {
stacks[move.to].addFirst(stacks[move.from].pop())
}
... | 0 | Kotlin | 0 | 0 | a638356cda864b9e1799d72fa07d3482a5f2128e | 2,445 | aoc-2022 | Apache License 2.0 |
src/day23/Day23.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day23
import java.io.File
import kotlin.math.max
fun main() {
val data = parse("src/day23/Day23.txt")
println("🎄 Day 23 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)}")
}
private fun pars... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 3,293 | advent-of-code-2023 | MIT License |
src/Day11.kt | kipwoker | 572,884,607 | false | null | import kotlin.math.pow
data class Modifier(val op: Char, val value: Int)
data class Condition(val divisibleBy: Int, val ifTrue: Int, val ifFalse: Int)
data class Monkey(
val index: Int,
val queue: MutableList<Long>,
val modifier: Modifier,
val condition: Condition,
var inspectionCount: Long
)
fun ... | 0 | Kotlin | 0 | 0 | d8aeea88d1ab3dc4a07b2ff5b071df0715202af2 | 3,436 | aoc2022 | Apache License 2.0 |
src/Day02.kt | rod41732 | 728,131,475 | false | {"Kotlin": 26028} | import kotlin.math.max
fun main() {
fun parseShow(show: String): List<Int> {
val counts = mutableListOf(0, 0, 0)
val colors = show.split(',').map { it.trim() }
colors.forEach {
val (num, name) = it.split(' ')
val numInt = num.toInt()
when (name) {
... | 0 | Kotlin | 0 | 0 | 05a308a539c8a3f2683b11a3a0d97a7a78c4ffac | 2,170 | aoc-23 | Apache License 2.0 |
src/Day15.kt | schoi80 | 726,076,340 | false | {"Kotlin": 83778} | fun Char.convert(curr: Long = 0): Long {
return (curr + this.code) * 17 % 256
}
fun String.convert(): Long {
return fold(0L) { acc, c -> c.convert(acc) }
}
data class Box(
val set: MutableSet<String>,
val list: MutableList<String>,
val label: MutableMap<String, Int>
) {
fun remove(lens: String... | 0 | Kotlin | 0 | 0 | ee9fb20d0ed2471496185b6f5f2ee665803b7393 | 1,753 | aoc-2023 | Apache License 2.0 |
src/main/kotlin/fijb/leetcode/algorithms/A5LongestPalindromicSubstring.kt | fi-jb | 552,324,917 | false | {"Kotlin": 22836} | package fijb.leetcode.algorithms
// https://leetcode.com/problems/longest-palindromic-substring/
object A5LongestPalindromicSubstring {
fun longestPalindrome(s: String): String {
var max = Pair(0, 0)
for (i in s.indices) max = maxPairOf(max, maxPairOf(getOddPair(s, i), getEvenPair(s, i)))
r... | 0 | Kotlin | 0 | 0 | f0d59da5bcffaa7a008fe6b83853306d40ac4b90 | 1,205 | leetcode | MIT License |
src/Day03.kt | uzorov | 576,933,382 | false | {"Kotlin": 6068} | import java.io.File
fun main() {
fun parseInput(input: String): List<String> {
return input.split("\n").map { it }
}
fun getCodeNumber(i: Char): Int {
return if (i.code > 96) i.code - 96
else i.code - 38
}
fun compareAndReturnNextSum(sortedstringsPart1: String, sortedstr... | 0 | Kotlin | 0 | 0 | be4ec026f6114f2fa7ae7ebd9b55af9215de8e7b | 2,041 | aoc-2022-in-kotlin | Apache License 2.0 |
src/adventofcode/day08/Day08.kt | bstoney | 574,187,310 | false | {"Kotlin": 27851} | package adventofcode.day08
import adventofcode.AdventOfCodeSolution
import adventofcode.peek
fun main() {
Solution.solve()
}
object Solution : AdventOfCodeSolution<Int>() {
override fun solve() {
solve(8, 21, 8)
}
override fun part1(input: List<String>): Int {
return getTrees(input).... | 0 | Kotlin | 0 | 0 | 81ac98b533f5057fdf59f08940add73c8d5df190 | 3,564 | fantastic-chainsaw | Apache License 2.0 |
src/year2021/day2/Day02.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2021.day2
import readInput
fun main() {
fun aaa(a: List<String>?): Int {
return (a ?: emptyList()).map { it.split(" ") }.map {
when (it[0]) {
"up" -> -1
else -> 1
} * it[1].toInt()
}.sum()
}
fun part1(input: List<String>)... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,292 | adventOfCode | Apache License 2.0 |
src/Day09.kt | jstapels | 572,982,488 | false | {"Kotlin": 74335} | import kotlin.math.absoluteValue
// fun dumpKnots(knots: List<Pos>, locs: Set<Pos>): String {
// val dump = StringBuilder()
// val maxX = 20//knots.maxOf { it.x }
// val maxY = 20//knots.maxOf { it.y }
// (maxY downTo 0).forEach { y ->
// (0..maxX).map { Pos(it, y) }
// ... | 0 | Kotlin | 0 | 0 | 0d71521039231c996e2c4e2d410960d34270e876 | 2,805 | aoc22 | Apache License 2.0 |
src/main/kotlin/net/navatwo/adventofcode2023/day6/Day6Solution.kt | Nava2 | 726,034,626 | false | {"Kotlin": 100705, "Python": 2640, "Shell": 28} | package net.navatwo.adventofcode2023.day6
import net.navatwo.adventofcode2023.framework.ComputedResult
import net.navatwo.adventofcode2023.framework.Solution
import kotlin.math.ceil
import kotlin.math.floor
sealed class Day6Solution : Solution<Day6Solution.Races> {
data object Part1 : Day6Solution() {
override ... | 0 | Kotlin | 0 | 0 | 4b45e663120ad7beabdd1a0f304023cc0b236255 | 2,738 | advent-of-code-2023 | MIT License |
src/main/kotlin/aoc2022/Day08.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import utils.InputUtils
fun main() {
val testInput = """30373
25512
65332
33549
35390""".split("\n")
fun countTrue(it: BooleanArray) = it.count { b -> b }
fun extracted(values: Iterable<IndexedValue<Char>>): Sequence<Int> {
return sequence {
var max: Char = 0.toChar(... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,776 | aoc-2022-kotlin | Apache License 2.0 |
src/Day09.kt | azat-ismagilov | 573,217,326 | false | {"Kotlin": 75114} | import java.lang.RuntimeException
import kotlin.math.*
object Day09 {
data class Position(val x: Int = 0, val y: Int = 0) {
fun distance(other: Position) = max(abs(x - other.x), abs(y - other.y))
fun differenceVector(other: Position) = Position((other.x - x).sign, (other.y - y).sign)
operat... | 0 | Kotlin | 0 | 0 | abdd1b8d93b8afb3372cfed23547ec5a8b8298aa | 2,835 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day23/result.kt | davidcurrie | 437,645,413 | false | {"Kotlin": 37294} | package day23
import java.io.File
import java.util.*
import kotlin.math.abs
fun main() {
println(solve("src/day23/input.txt"))
println(solve("src/day23/input-part2.txt"))
}
enum class Amphipod(val stepEnergy: Int) { A(1), B(10), C(100), D(1000) }
data class Room(val natives: Amphipod, val size: Int, val ent... | 0 | Kotlin | 0 | 0 | dd37372420dc4b80066efd7250dd3711bc677f4c | 4,914 | advent-of-code-2021 | MIT License |
src/Day09.kt | shepard8 | 573,449,602 | false | {"Kotlin": 73637} | import kotlin.math.abs
open class Node {
protected var x = 0
protected var y = 0
fun move(dx: Int, dy: Int) {
x += dx
y += dy
}
open fun follow(other: Node) {
val dx = abs(other.x - x)
val dy = abs(other.y - y)
if (dx > 1 && dy > 1) {
x = (x + o... | 0 | Kotlin | 0 | 1 | 81382d722718efcffdda9b76df1a4ea4e1491b3c | 2,015 | aoc2022-kotlin | Apache License 2.0 |
src/Day9.kt | michaelYuenAE | 573,094,416 | false | {"Kotlin": 74685} |
import kotlin.math.abs
import kotlin.math.sign
class Day9(private val input: List<String>) {
private val motions = input.map { it.substringBefore(" ") to it.substringAfter(" ").toInt() }
private val directions = mapOf(
"R" to Point(1, 0),
"U" to Point(0, 1),
"L" to Point(-1, 0),
... | 0 | Kotlin | 0 | 0 | ee521263dee60dd3462bea9302476c456bfebdf8 | 1,539 | advent22 | Apache License 2.0 |
src/Day09.kt | mrugacz95 | 572,881,300 | false | {"Kotlin": 102751} | import kotlin.math.abs
operator fun Pair<Int, Int>.plus(other: Pair<Int, Int>): Pair<Int, Int> {
return Pair(this.first + other.first, this.second + other.second)
}
fun Pair<Int, Int>.adjacent(other: Pair<Int, Int>): Boolean {
return abs(this.first - other.first) <= 1 &&
abs(this.second - other.se... | 0 | Kotlin | 0 | 0 | 29aa4f978f6507b182cb6697a0a2896292c83584 | 3,588 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/solutions/day13/Day13.kt | Dr-Horv | 570,666,285 | false | {"Kotlin": 115643} | package solutions.day13
import solutions.Solver
sealed class Package
class ListPackage(val list: List<Package>) : Package() {
override fun toString(): String = "[${list.joinToString(",")}]"
companion object
}
fun ListPackage.Companion.of(p: IntegerPackage): Package = ListPackage(listOf(p))
class IntegerP... | 0 | Kotlin | 0 | 2 | 6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e | 3,836 | Advent-of-Code-2022 | MIT License |
src/Day03.kt | StephenVinouze | 572,377,941 | false | {"Kotlin": 55719} | fun main() {
fun itemPriority(item: Char): Int {
// char ascii code starts at 65 for uppercase letters and 97 for lowercases
// Shifting uppercases for additional 26 to count after lowercases letters
val offset = if (Character.isUpperCase(item)) 65 - 26 else 97
return item.code - of... | 0 | Kotlin | 0 | 0 | 11b9c8816ded366aed1a5282a0eb30af20fff0c5 | 1,996 | AdventOfCode2022 | Apache License 2.0 |
src/Day12.kt | iam-afk | 572,941,009 | false | {"Kotlin": 33272} | fun main() {
fun List<ByteArray>.steps(start: List<ByteArray>.() -> Sequence<Pair<Int, Int>>): Int? {
val queue = ArrayDeque<Triple<Int, Int, Int>>()
val visited = Array(this.size) { BooleanArray(this[it].size) }
for ((i, j) in this.start()) {
queue.add(Triple(i, j, 0))
... | 0 | Kotlin | 0 | 0 | b30c48f7941eedd4a820d8e1ee5f83598789667b | 2,253 | aockt | Apache License 2.0 |
src/main/kotlin/Day10.kt | akowal | 434,506,777 | false | {"Kotlin": 30540} | fun main() {
println(Day10.solvePart1())
println(Day10.solvePart2())
}
object Day10 {
private val input = readInput("day10")
private val closing = mapOf(
'(' to ')',
'[' to ']',
'{' to '}',
'<' to '>'
)
private val errorScores = mapOf(
')' to 3,
'... | 0 | Kotlin | 0 | 0 | 08d4a07db82d2b6bac90affb52c639d0857dacd7 | 1,450 | advent-of-kode-2021 | Creative Commons Zero v1.0 Universal |
src/Day9_Michael.kt | michaelYuenAE | 573,094,416 | false | {"Kotlin": 74685} |
import kotlin.math.abs
import kotlin.math.sign
class Day9_Michael(private val input: List<String>) {
private val motions = input.map { it.substringBefore(" ") to it.substringAfter(" ").toInt() }
private val directions = mapOf(
"U" to Point(0,1),
"D" to Point(0,-1),
"L" to Point(-1, 0)... | 0 | Kotlin | 0 | 0 | ee521263dee60dd3462bea9302476c456bfebdf8 | 1,586 | advent22 | Apache License 2.0 |
src/Day06.kt | martintomac | 726,272,603 | false | {"Kotlin": 19489} | fun main() {
fun findLargerDistanceConfigurations(time: Long, record: Long) = (1..<time).asSequence()
.map { it to it * (time - it) }
.dropWhile { it.second <= record }
.takeWhile { it.second > record }
.toList()
fun part1(lines: List<String>): Int {
val times = lines[0... | 0 | Kotlin | 0 | 0 | dc97b23f8461ceb9eb5a53d33986fb1e26469964 | 1,186 | advent-of-code-2023 | Apache License 2.0 |
src/year2022/day18/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day18
import io.kotest.matchers.shouldBe
import utils.Point3d
import utils.cartesianProduct
import utils.manhattanDistanceTo
import utils.minMaxOf
import utils.neighbors
import utils.readInput
fun main() {
val testInput = readInput("18", "test_input").mapTo(mutableSetOf(), String::toPoint)
va... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 2,570 | Advent-of-Code | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch6/Problem70.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch6
import dev.bogwalk.util.combinatorics.permutationID
import dev.bogwalk.util.maths.primeNumbers
/**
* Problem 70: Totient Permutation
*
* https://projecteuler.net/problem=70
*
* Goal: Find the value of n, with 1 < n < N, for which Phi(n) is a permutation of n and the
* ratio n/Phi(n) p... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 4,632 | project-euler-kotlin | MIT License |
src/Day15.kt | floblaf | 572,892,347 | false | {"Kotlin": 28107} | import kotlin.math.abs
fun main() {
data class Sensor(
val x: Int,
val y: Int,
val distanceScanned: Int
)
data class Beacon(
val x: Int,
val y: Int
)
val sensors = mutableListOf<Sensor>()
val beacons = mutableListOf<Beacon>()
readInput("Day15")
... | 0 | Kotlin | 0 | 0 | a541b14e8cb401390ebdf575a057e19c6caa7c2a | 2,818 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | maewCP | 579,203,172 | false | {"Kotlin": 59412} | import kotlin.math.abs
fun main() {
val testingPoints = mutableListOf<Pair<Int, Int>>()
val data = mutableMapOf<Pair<Int, Int>, Pair<Int, Int>>()
val distances = mutableMapOf<Pair<Int, Int>, Int>()
fun getDistance(a: Pair<Int, Int>, b: Pair<Int, Int>): Int {
return abs(a.first - b.first) + abs... | 0 | Kotlin | 0 | 0 | 8924a6d913e2c15876c52acd2e1dc986cd162693 | 4,229 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day07.kt | arnoutvw | 572,860,930 | false | {"Kotlin": 33036} | import kotlin.collections.ArrayList
fun main() {
data class Dir(val prevDir: Dir?, val subdirs : ArrayList<Dir>, var size: Int, val name: String) {
fun calculateSize() :Int {
return subdirs.sumOf { it.calculateSize() } + size
}
fun getSubDir(name: String) :Dir? {
r... | 0 | Kotlin | 0 | 0 | 0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4 | 3,094 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/ryanmoelter/advent/day05/Stacks.kt | ryanmoelter | 573,615,605 | false | {"Kotlin": 84397} | package com.ryanmoelter.advent.day05
fun main() {
println(findTopsMovingMultiple(day05Stacks, day05Instructions))
}
fun findTopsMovingMultiple(stacksInput: String, instructionsInput: String): String {
val stacks = parseStacks(stacksInput)
val instructions = parseInstructions(instructionsInput)
instructions.fo... | 0 | Kotlin | 0 | 0 | aba1b98a1753fa3f217b70bf55b1f2ff3f69b769 | 2,403 | advent-of-code-2022 | Apache License 2.0 |
src/day/_3/Day03.kt | Tchorzyksen37 | 572,924,533 | false | {"Kotlin": 42709} | package day._3
import readInput
import java.util.stream.Collectors
fun main() {
fun stringToCharacterList(str: String): List<String> {
return str.chars().mapToObj(Character::toString).collect(Collectors.toList())
}
fun mapElementToIntValue(element: String): Int {
return if (element[0].isLowerCase()) (element... | 0 | Kotlin | 0 | 0 | 27d4f1a6efee1c79d8ae601872cd3fa91145a3bd | 2,026 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | fun main() {
fun abs(a: Int, b: Int): Int{
return maxOf(a, b) - minOf(a, b)
}
fun sign(a: Int): Int{
if (a > 0) return 1
else if (a < 0) return -1
return 0
}
fun Pair<Int, Int>.move(moveDir: String):Pair<Int, Int>{
return when (moveDir){
"R" -> P... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 2,307 | aoc22 | Apache License 2.0 |
src/day3/Day03.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day3
import readInput
fun main() {
val alphabet = ('a'..'z').toMutableList() + ('A'..'Z').toMutableList()
fun sacks(input: List<String>) : List<Rucksack> {
return input.map { line ->
Rucksack(
one = line.substring(0, line.length / 2),
two = line.su... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 1,574 | advent-of-code | Apache License 2.0 |
src/Day04.kt | gsalinaslopez | 572,839,981 | false | {"Kotlin": 21439} | fun main() {
fun getRanges(input: List<String>): List<Pair<IntRange, IntRange>> = input
.map { entry ->
val sections = entry.split(",")
val firstSection = sections.first().split("-").map { it.toInt() }
val secondSection = sections.last().split("-").map { it.toInt() }
... | 0 | Kotlin | 0 | 0 | 041c7c3716bfdfdf4cc89975937fa297ea061830 | 1,672 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day13.kt | RobvanderMost-TomTom | 572,005,233 | false | {"Kotlin": 47682} | import org.json.JSONArray
fun main() {
fun isInOrder(left:JSONArray, right: JSONArray): Order {
for (i in 0 until left.length()) {
if (i >= right.length()) {
return Order.OutOfOrder
}
val leftArray = left.optJSONArray(i)
val rightArray = right... | 5 | Kotlin | 0 | 0 | b7143bceddae5744d24590e2fe330f4e4ba6d81c | 2,954 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/co/csadev/advent2021/Day20.kt | gtcompscientist | 577,439,489 | false | {"Kotlin": 252918} | /**
* Copyright (c) 2021 by <NAME>
* Advent of Code 2021, Day 20
* Problem Description: http://adventofcode.com/2021/day/20
*/
package co.csadev.advent2021
import co.csadev.adventOfCode.BaseDay
import co.csadev.adventOfCode.Point2D
import co.csadev.adventOfCode.Resources.resourceAsText
import kotlin.system.measure... | 0 | Kotlin | 0 | 1 | 43cbaac4e8b0a53e8aaae0f67dfc4395080e1383 | 2,871 | advent-of-kotlin | Apache License 2.0 |
src/Day07.kt | aneroid | 572,802,061 | false | {"Kotlin": 27313} | class Day07(input: List<String>) {
private val allPaths = parseInput(input)
private fun parseInput(input: List<String>): Map<String, Int> =
buildMap {
var index = 0
var currDir = ""
while (index < input.size) {
val line = input[index++]
... | 0 | Kotlin | 0 | 0 | cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd | 2,454 | advent-of-code-2022-kotlin | Apache License 2.0 |
app/src/main/java/online/vapcom/codewars/strings/StringsKatas.kt | vapcomm | 503,057,535 | false | {"Kotlin": 142486} | package online.vapcom.codewars.strings
/**
* Two to One
* https://www.codewars.com/kata/5656b6906de340bd1b0000ac/train/kotlin
*/
fun longest(s1: String, s2: String): String {
val set = (s1 + s2).toSortedSet()
val sb = StringBuilder(set.size)
set.forEach {
sb.append(it)
}
return sb.toS... | 0 | Kotlin | 0 | 0 | 97b50e8e25211f43ccd49bcee2395c4bc942a37a | 5,067 | codewars | MIT License |
app/src/main/kotlin/day07/Day07.kt | KingOfDog | 433,706,881 | false | {"Kotlin": 76907} | package day07
import common.InputRepo
import common.readSessionCookie
import common.solve
import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.roundToInt
fun main(args: Array<String>) {
val day = 7
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(... | 0 | Kotlin | 0 | 0 | 576e5599ada224e5cf21ccf20757673ca6f8310a | 1,857 | advent-of-code-kt | Apache License 2.0 |
src/Day04.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} |
class PairRange(private val range1: Set<Int>, private val range2: Set<Int>) {
fun fullyContains(): Boolean {
return if (range1.size > range2.size) {
range1.containsAll(range2)
} else {
range2.containsAll(range1)
}
}
fun containsAny(): Boolean {
retu... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 1,525 | 2022-advent | Apache License 2.0 |
src/Day12.kt | maciekbartczak | 573,160,363 | false | {"Kotlin": 41932} | import java.util.LinkedList
import java.util.Queue
fun main() {
fun part1(input: List<String>): Int {
val grid = makeGrid(input)
val startingPosition = grid.findRootNode()
val endPosition = bfs(grid, startingPosition)!!
return endPosition.distance
}
fun part2(input: List<St... | 0 | Kotlin | 0 | 0 | 53c83d9eb49d126e91f3768140476a52ba4cd4f8 | 3,477 | advent-of-code-2022 | Apache License 2.0 |
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day07.kt | JamJaws | 725,792,497 | false | {"Kotlin": 30656} | package com.jamjaws.adventofcode.xxiii.day
import com.jamjaws.adventofcode.xxiii.readInput
class Day07 {
companion object {
private val CARD_OPTIONS = listOf('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2')
private val CARD_OPTIONS_JOKER = listOf('A', 'K', 'Q', 'T', '9', '8', '7',... | 0 | Kotlin | 0 | 0 | e2683305d762e3d96500d7268e617891fa397e9b | 3,802 | advent-of-code-2023 | MIT License |
src/main/kotlin/de/nosswald/aoc/days/Day03.kt | 7rebux | 722,943,964 | false | {"Kotlin": 34890} | package de.nosswald.aoc.days
import de.nosswald.aoc.Day
// https://adventofcode.com/2023/day/3
object Day03 : Day<Int>(3, "Gear Ratios") {
private data class Point(val x: Int, val y: Int)
override fun partOne(input: List<String>): Int {
return combined(input, { it.isSymbol() }, List<Int>::sum)
}
... | 0 | Kotlin | 0 | 1 | 398fb9873cceecb2496c79c7adf792bb41ea85d7 | 3,150 | advent-of-code-2023 | MIT License |
src/Day10.kt | razvn | 573,166,955 | false | {"Kotlin": 27208} | import java.lang.Exception
fun main() {
val day = "Day10"
fun part1(input: List<String>): Int {
val values = loadValues(input)
val keep = valuesToKeep(values, 20, 60, 100, 140, 180, 220)
// println(keep)
return keep.map { (k, v) -> k * v }.sum()
}
fun part2(input: List<... | 0 | Kotlin | 0 | 0 | 73d1117b49111e5044273767a120142b5797a67b | 2,473 | aoc-2022-kotlin | Apache License 2.0 |
src/Day15.kt | HaydenMeloche | 572,788,925 | false | {"Kotlin": 25699} |
fun manhattanDistance(x1: Int, y1: Int, x2: Int, y2: Int) = kotlin.math.abs(x1 - x2) + kotlin.math.abs(y1 - y2)
data class Point(val x: Int, val y: Int)
data class Sensor(val loc: Point, val beacon: Point) {
val distance = manhattanDistance(loc.x, loc.y, beacon.x, beacon.y)
fun inRange(x: Int, y: Int) = manha... | 0 | Kotlin | 0 | 1 | 1a7e13cb525bb19cc9ff4eba40d03669dc301fb9 | 1,669 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day18/Day18.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day18
import readInput
import readTestInput
private data class Coordinate(val x: Int, val y: Int, val z: Int)
private typealias LavaCube = Coordinate
private typealias LavaDroplet = Set<LavaCube>
private fun List<String>.toLavaDroplet(): LavaDroplet = this
.map { line ->
val (x, y, z) = line.spli... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 2,802 | advent-of-code-kotlin-2022 | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/Day19.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | // Day 19: Aplenty
// https://adventofcode.com/2023/day/19
import java.io.File
private const val COLON = ":"
private const val GREATER_THAN = ">"
private const val LESS_THAN = "<"
data class Workflow(val name: String, val rules: List<String>)
data class Part(val x: Int, val m: Int, val a: Int, val s: Int) {
fun... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 3,026 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-19.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.Coord3D
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputText
import com.github.ferinagy.adventOfCode.transpose
import kotlin.math.abs
fun main() {
val input = readInputText(202... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 5,749 | advent-of-code | MIT License |
mantono-kotlin/src/main/kotlin/com/mantono/aoc/day03/Day3.kt | joelfak | 433,981,631 | true | {"Python": 234827, "Rust": 135681, "C#": 107607, "C++": 97151, "F#": 68551, "Haskell": 36120, "Nim": 30557, "Kotlin": 14600, "REXX": 13854, "OCaml": 12448, "Go": 11995, "C": 9751, "Swift": 8043, "JavaScript": 1750, "PowerShell": 866, "CMake": 851, "AppleScript": 493, "Shell": 255} | package com.mantono.aoc.day03
import com.mantono.aoc.AoC
import com.mantono.aoc.Part
import java.lang.Integer.max
import java.lang.Integer.min
import kotlin.math.abs
private val startPosition = Position(0, 0)
private typealias Path = List<Position>
private typealias MutablePath = MutableList<Position>
@AoC(3, Part.A... | 0 | Python | 0 | 0 | d5031078c53c181835b4bf86458b360542f0122e | 4,548 | advent_of_code_2019 | Apache License 2.0 |
src/Day19.kt | illarionov | 572,508,428 | false | {"Kotlin": 108577} | import kotlin.system.measureTimeMillis
fun main() {
val testInput = readInput("Day19_test")
.map(String::parseBlueprint)
val input = readInput("Day19")
.map(String::parseBlueprint)
part1(testInput).also {
println("Part 1, test input: $it")
check(it == 33)
}
part1(i... | 0 | Kotlin | 0 | 0 | 3c6bffd9ac60729f7e26c50f504fb4e08a395a97 | 7,159 | aoc22-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem027.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
import dev.mikeburgess.euler.sequences.PrimeSequence
import dev.mikeburgess.euler.sequences.isPrime
/**
* Problem 27
*
* Euler discovered the remarkable quadratic formula:
*
* n^2 + n + 41
*
* It turns out that the formula will produce 40 primes for the consecutive intege... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 1,622 | project-euler | MIT License |
src/Day08.kt | mborromeo | 571,999,097 | false | {"Kotlin": 10600} | import kotlin.math.max
fun main() {
data class Mtx(
val l: List<Int>,
val r: List<Int>,
val t: List<Int>,
val b: List<Int>,
) {
val dir = listOf(l, r, t, b)
}
fun List<List<Int>>.build(i: Int, j: Int) = Mtx(
l = this[i].subList(0, j).reversed(),
... | 0 | Kotlin | 0 | 0 | d01860ecaff005aaf8e1e4ba3777a325a84c557c | 1,697 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day11.kt | razvn | 573,166,955 | false | {"Kotlin": 27208} | fun main() {
val day = "Day11"
fun part1(input: List<String>): Int {
val monkeys = loadValues(input)
// println("Start --->")
// monkeys.forEach(::println)
(1..20).forEach {
monkeys.forEach { (_, m) ->
m.items.forEach { item ->
m.in... | 0 | Kotlin | 0 | 0 | 73d1117b49111e5044273767a120142b5797a67b | 3,670 | aoc-2022-kotlin | Apache License 2.0 |
src/test/kotlin/Day07.kt | christof-vollrath | 317,635,262 | false | null | import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
/*
--- Day 7: Handy Haversacks ---
See https://adventofcode.com/2020/day/7
*/
fun Collection<Bag>.findAllBagsContaining(color: String): Set<Bag> {
val containingMap = this.flatMap {bag ->
bag.content.map { bagQuantity ->
... | 1 | Kotlin | 0 | 0 | 8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8 | 9,511 | advent_of_code_2020 | Apache License 2.0 |
advent-of-code-2021/src/code/day3/Main.kt | Conor-Moran | 288,265,415 | false | {"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733} | package code.day3
import code.common.BinDigit
import code.common.flipBits
import java.io.File
fun main() {
doIt("Day 3 Part 1: Test Input", "src/code/day3/test.input", part1)
doIt("Day 3 Part 1: Real Input", "src/code/day3/part1.input", part1)
doIt("Day 3 Part 2: Test Input", "src/code/day3/test.input", p... | 0 | Kotlin | 0 | 0 | ec8bcc6257a171afb2ff3a732704b3e7768483be | 2,407 | misc-dev | MIT License |
src/Day15.kt | akijowski | 574,262,746 | false | {"Kotlin": 56887, "Shell": 101} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
data class SensorBeacon(val x: Int, val y: Int, val isBeacon: Boolean = false) {
fun dist(other: SensorBeacon): Int {
// manhattan distance
return abs(x - other.x) + abs(y - other.y)
}
fun contains(a: Int, b: Int, other:... | 0 | Kotlin | 1 | 0 | 84d86a4bbaee40de72243c25b57e8eaf1d88e6d1 | 5,520 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day07/Day07.kt | qnox | 575,581,183 | false | {"Kotlin": 66677} | package day07
import readInput
sealed interface FSNode {
val name: String
}
class Dir(override val name: String, val parent: Dir? = null) : FSNode {
private val _children: MutableMap<String, FSNode> = mutableMapOf()
val children: Map<String, FSNode>
get() = _children
operator fun get(name: ... | 0 | Kotlin | 0 | 0 | 727ca335d32000c3de2b750d23248a1364ba03e4 | 3,798 | aoc2022 | Apache License 2.0 |
src/y2022/Day09.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.readInput
import kotlin.math.abs
object Day09 {
enum class Direction {
UP, DOWN, LEFT, RIGHT;
companion object {
fun fromChar(c: Char): Direction {
return when (c) {
'R' -> RIGHT
'U' -> UP
... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 3,537 | advent-of-code | Apache License 2.0 |
src/day07/a/day07a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day07.a
import readInputLines
import shouldBe
fun main() {
val root = readInput()
var acc = 0
root.treeReduce(0, Integer::sum) { dir, subTreeSize ->
val size = subTreeSize + dir.sumFileSize()
if (size <= 100000) acc += size
size
}
shouldBe(1513699, acc)
}
class Dir... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 1,722 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | xNakero | 572,621,673 | false | {"Kotlin": 23869} | import kotlin.math.pow
import kotlin.math.sign
import kotlin.math.sqrt
object Day09 {
fun part1() = process(1)
fun part2() = process(9)
private fun process(tailSize: Int) = readCommands()
.fold(Rope(tailSize)) { rope, cmd -> processCommand(cmd, rope) }
.visitedCoordinates.size
priva... | 0 | Kotlin | 0 | 0 | c3eff4f4c52ded907f2af6352dd7b3532a2da8c5 | 2,767 | advent-of-code-2022 | Apache License 2.0 |
src/Day13.kt | arhor | 572,349,244 | false | {"Kotlin": 36845} | import java.util.*
fun main() {
val input = readInput {}
println("Part 1: ${solvePuzzle1(input)}")
println("Part 2: ${solvePuzzle2(input)}")
}
private fun solvePuzzle1(input: List<String>): Int {
var sum = 0
for ((index, packets) in input.split("").map { it.map(::parse) }.withIndex()) {
c... | 0 | Kotlin | 0 | 0 | 047d4bdac687fd6719796eb69eab2dd8ebb5ba2f | 2,462 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2016/Aoc2016Day01.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2016
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
import kotlin.math.abs
class Aoc2016Day01 {
enum class Facing {
NORTH, EAST, SOUTH, WEST;
fun turn(direction: Char) : Facing {... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 3,369 | adventofcode | MIT License |
src/main/kotlin/Day11.kt | ueneid | 575,213,613 | false | null | class Day11(inputs: List<String>) {
private val monkeys = parse(inputs)
class Monkey(
var itemList: ArrayDeque<Long>,
private var operationPair: Pair<String, String>,
var divisible: Long,
private var destMonkeys: List<Int>,
) {
var inspectCount = 0L
fun calc... | 0 | Kotlin | 0 | 0 | 743c0a7adadf2d4cae13a0e873a7df16ddd1577c | 3,303 | adventcode2022 | MIT License |
src/Day07.kt | brigittb | 572,958,287 | false | {"Kotlin": 46744} | fun main() {
fun findDirs(input: List<String>): MutableMap<String, Long> {
val stack = ArrayDeque<String>()
val dirSizes = mutableMapOf<String, Long>()
input.forEach {
when {
it.contains(Regex("cd /")) -> stack.addLast(it.substringAfter("cd "))
it... | 0 | Kotlin | 0 | 0 | 470f026f2632d1a5147919c25dbd4eb4c08091d6 | 2,703 | aoc-2022 | Apache License 2.0 |
2023/src/main/kotlin/day15.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
fun main() {
Day15.run()
}
object Day15 : Solution<List<String>>() {
override val name = "day15"
override val parser = Parser { it.trim().split(",") }
private fun hash(str: String): Int {
var reg = 0
for (c in str) {
reg += c.code
reg += (reg shl ... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,733 | aoc_kotlin | MIT License |
src/Day09.kt | D000L | 575,350,411 | false | {"Kotlin": 23716} | import kotlin.math.pow
data class Position(val x: Int = 0, val y: Int = 0) {
private fun isNear(position: Position): Boolean = distance(position) <= 2.0
private fun distance(position: Position) =
(x - position.x.toDouble()).pow(2.0) + (y - position.y.toDouble()).pow(2.0)
fun moved(dx: Int, dy: Int... | 0 | Kotlin | 0 | 0 | b733a4f16ebc7b71af5b08b947ae46afb62df05e | 2,001 | 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.