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/Day03.kt | vjgarciag96 | 572,719,091 | false | {"Kotlin": 44399} | private val A_TO_Z_UPPERCASE = 65..90
private val A_TO_Z_LOWERCASE = 97..122
private fun calculatePriority(char: Char): Int {
return when (val charCode = char.code) {
in A_TO_Z_LOWERCASE -> charCode % (A_TO_Z_LOWERCASE.first - 1)
in A_TO_Z_UPPERCASE -> A_TO_Z_LOWERCASE.count() + (charCode % (A_TO_Z... | 0 | Kotlin | 0 | 0 | ee53877877b21166b8f7dc63c15cc929c8c20430 | 1,510 | advent-of-code-2022 | Apache License 2.0 |
src/Day23.kt | davidkna | 572,439,882 | false | {"Kotlin": 79526} | fun main() {
fun parseInput(input: List<String>): Set<Pair<Int, Int>> {
return input.mapIndexed { y, line ->
line.withIndex().filter { x -> x.value == '#' }.map { x ->
Pair(y, x.index)
}
}.flatten().toSet()
}
fun neighbors(p: Pair<Int, Int>): List<Pai... | 0 | Kotlin | 0 | 0 | ccd666cc12312537fec6e0c7ca904f5d9ebf75a3 | 4,056 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day11.kt | cbrentharris | 712,962,396 | false | {"Kotlin": 171464} | import kotlin.String
import kotlin.collections.List
object Day11 {
fun part1(input: List<String>): String {
val pairs = generatePairs(input)
val emptyRows = generateEmptyRows(input)
val emptyColumns = generateEmptyColumns(input)
return pairs.sumOf { (a, b) ->
manhattanD... | 0 | Kotlin | 0 | 1 | f689f8bbbf1a63fecf66e5e03b382becac5d0025 | 2,454 | kotlin-kringle | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day15.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
class Day15 {
private val sensor2beacon: Map<Point, Point>
init {
val pattern = """Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at x=(-?\d+), y=(-?\d+)""".toRegex()
sensor2beacon = inputFil... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 2,394 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/Day13.kt | joy32812 | 573,132,774 | false | {"Kotlin": 62766} | import java.util.Stack
data class Node(val num: Int?, val list: List<Node>?)
fun main() {
fun String.toNode(): Node {
fun getPairMap(): Map<Int, Int> {
val pairMap = mutableMapOf<Int, Int>()
val stack = Stack<Int>()
for (i in indices) {
if (this[i] == '[') {
stack.push(i)
... | 0 | Kotlin | 0 | 0 | 5e87958ebb415083801b4d03ceb6465f7ae56002 | 2,570 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day15.kt | cagriyildirimR | 572,811,424 | false | {"Kotlin": 34697} | import kotlin.math.abs
fun day15() {
val input = readInput("Day15").map {
it.split("Sensor at x=", ": closest beacon is at x=", ", y=").filter { x -> x != "" }.map { s -> s.toInt() }
}
val Y = 2_000_000
val abc = mutableListOf<List<List<Int>>>()
for (j in 0..4_000_000) {
val l = ... | 0 | Kotlin | 0 | 0 | 343efa0fb8ee76b7b2530269bd986e6171d8bb68 | 1,712 | AoC | Apache License 2.0 |
src/Day04.kt | benwicks | 572,726,620 | false | {"Kotlin": 29712} | fun main() {
fun extracted(pair: String): Pair<IntRange, IntRange> {
val split = pair.split(',')
val firstRange = split[0].split('-')
val secondRange = split[1].split('-')
val firstRangeStart = firstRange.first().toInt()
val secondRangeStart = secondRange.first().toInt()
... | 0 | Kotlin | 0 | 0 | fbec04e056bc0933a906fd1383c191051a17c17b | 2,134 | aoc-2022-kotlin | Apache License 2.0 |
src/Day07.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} | class Parser(root: Directory) {
private var pwd: Directory = root
fun parse(line: String) {
if (line.startsWith("$ cd ")) {
val name = line.replace("$ cd ", "")
pwd = when(name) {
"/" -> pwd //no-op, already set
".." -> pwd.parent!!
... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 2,556 | 2022-advent | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day18.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 18: Snailfish
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.readFileAsStringList
import kotlin.math.ceil
fun main() {
println(" ** Day 18: Snailfish ** \n")
val mathsHomework = readFileAsStringList("/Day18SnailfishMathsHomework.txt")
val completedHomeworkNumber = complete... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 5,406 | AdventOfCode2021 | MIT License |
src/main/kotlin/aoc2022/Day05.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import utils.InputUtils
object Day05 {
data class Command(val n: Int, val from: Int, val to: Int)
data class Stacks(private val state: List<String>) {
override fun toString(): String {
val seq = sequence<List<String>> {
yield(state.indices.map { " ${it + 1}... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 3,156 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch6/Problem69.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch6
import dev.bogwalk.util.maths.primeFactors
import dev.bogwalk.util.maths.primeNumbers
import kotlin.math.pow
/**
* Problem 69: Totient Maximum
*
* https://projecteuler.net/problem=69
*
* Goal: Find the smallest value of n < N for which n / Phi(n) is maximum.
*
* Constraints: 3 <= N <... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,744 | project-euler-kotlin | MIT License |
src/main/kotlin/days/Day9.kt | VictorWinberg | 433,748,855 | false | {"Kotlin": 26228} | package days
class Day9 : Day(9) {
private fun parseInput() = inputList.map { it.toList().map { it.toString().toInt() } }
override fun partOne(): Any {
val input = parseInput()
return locations(input).sumOf { (x, y) -> input[y][x] + 1 }
}
override fun partTwo(): Any {
val inp... | 0 | Kotlin | 0 | 0 | d61c76eb431fa7b7b66be5b8549d4685a8dd86da | 1,660 | advent-of-code-kotlin | Creative Commons Zero v1.0 Universal |
src/main/kotlin/adventofcode2018/Day06ChronalCoordinates.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2018
class Day06ChronalCoordinates
data class Coordinate(val id: Int, val x: Int, val y: Int) {
fun manhattanDistance(fromX: Int, fromY: Int): Int {
val xDist = if (fromX > x) (fromX - x) else (x - fromX)
val yDist = if (fromY > y) (fromY - y) else (y - fromY)
return x... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 3,145 | kotlin-coding-challenges | MIT License |
src/main/kotlin/com/anahoret/aoc2022/day25/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day25
import java.io.File
import kotlin.math.pow
import kotlin.system.measureTimeMillis
private val snafuCoding = mapOf(
'2' to 2,
'1' to 1,
'0' to 0,
'-' to -1,
'=' to -2
)
private val reverseSnafuCoding = snafuCoding.map { (key, value) -> value to key }.toMap()
fun... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 2,098 | advent-of-code-2022 | Apache License 2.0 |
workshops/moscow_prefinals2020/day4/k.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package workshops.moscow_prefinals2020.day4
fun main() {
val (n, m) = readInts()
val g = MutableList(n) { DoubleArray(n) }
repeat(m) {
val (uIn, vIn, resistance) = readInts()
for ((u, v) in listOf(uIn, vIn).map { it - 1 }.withReversed()) {
g[u][v] += 1.0 / resistance
g[u][u] -= 1.0 / resistance
}
}
va... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,972 | competitions | The Unlicense |
src/main/kotlin/aoc2021/Day14.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2021
import readInput
/**
* @param input the input polymer string
* @param rules a map of polymer transformation rules. Key=Input elements, Value=Element to be inserted between the input elements
* @return a polymer string constructed by taking the [input] string an applying all the [rules] simultaneous... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,755 | adventOfCode | Apache License 2.0 |
y2018/src/main/kotlin/adventofcode/y2018/Day25.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2018
import adventofcode.io.AdventSolution
import kotlin.math.abs
fun main() = Day25.solve()
object Day25 : AdventSolution(2018, 25, "Four-Dimensional Adventure") {
override fun solvePartOne(input: String): Int {
val constellations = input.splitToSequence('\n', ',')
... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,620 | advent-of-code | MIT License |
src/Day07.kt | paul-griffith | 572,667,991 | false | {"Kotlin": 17620} | private sealed interface Node {
val name: String
val size: Int
}
private data class File(
override val name: String,
override val size: Int
) : Node
private data class Directory(
override val name: String,
val children: MutableMap<String, Node> = mutableMapOf()
) : Node, MutableMap<String, Nod... | 0 | Kotlin | 0 | 0 | 100a50e280e383b784c3edcf65b74935a92fdfa6 | 3,416 | aoc-2022 | Apache License 2.0 |
src/Day16.kt | robinpokorny | 572,434,148 | false | {"Kotlin": 38009} | import kotlin.math.*
private data class Valve(
val name: String,
val flow: Int,
val nearby: List<String>
)
private val lineRe =
Regex("Valve (\\w+) has flow rate=(\\d+); tunnels? leads? to valves? (.*)")
private fun parse(input: List<String>): List<Valve> = input
.map { line ->
val (name,... | 0 | Kotlin | 0 | 2 | 56a108aaf90b98030a7d7165d55d74d2aff22ecc | 3,187 | advent-of-code-2022 | MIT License |
2k23/aoc2k23/src/main/kotlin/17.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d17
import java.util.*
fun main() {
println("Part 1: ${part1(input.read("17.txt"))}")
println("Part 2: ${part2(input.read("17.txt"))}")
}
fun part1(input: List<String>): Int =
FactoryCity(input).minimizeHeatLoss(1, 3)
fun part2(input: List<String>): Int =
FactoryCity(input).minimizeHeatLoss(... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 3,395 | aoc | The Unlicense |
src/Day11.kt | lsimeonov | 572,929,910 | false | {"Kotlin": 66434} |
fun main() {
class Monkey(
val id: Int,
val operation: (Long) -> Long,
val test: (Long) -> Int,
var Items: ArrayDeque<Long>,
var div: Long,
var activity: Long
)
fun part1(input: List<String>): Long {
return 0.toLong()
}
fun part2(input: ... | 0 | Kotlin | 0 | 0 | 9d41342f355b8ed05c56c3d7faf20f54adaa92f1 | 2,599 | advent-of-code-2022 | Apache License 2.0 |
src/Day13.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | fun main() {
fun part1(input: List<String>): Int =
input.asSequence()
.filter { it.isNotEmpty() }
.map { PacketElement.ElementList.parse(it) }
.chunked(2)
.map { Pair(it[0], it[1]) }
.mapIndexed { index, pair -> if (pair.first < pair.second) index... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 3,165 | aoc-2022 | Apache License 2.0 |
2021/src/day03/Day03.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day03
import readInput
fun part1(lines: List<String>) : Int {
val counts = MutableList(lines[0].length) { 0 }
lines.forEach { line ->
counts.forEachIndexed { idx, _ ->
counts[idx] = if (line[idx] == '1') {
counts[idx] + 1
} else {
counts... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,873 | advent-of-code | Apache License 2.0 |
Advent-of-Code-2023/src/Day19.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | private const val AOC_DAY = "Day19"
private const val TEST_FILE = "${AOC_DAY}_test"
private const val INPUT_FILE = AOC_DAY
private data class Rule(val name: Char? = null, val signal: Char? = null, val comparingNum: Int? = null, val destiny: String)
private fun part1(input: List<String>): Int {
val (part1, part2) ... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 4,731 | Advent-of-Code-2023 | Apache License 2.0 |
src/day8/Day08.kt | MatthewWaanders | 573,356,006 | false | null | package day8
import utils.readInput
typealias Direction = String
const val up: Direction = "UP"
const val down: Direction = "DOWN"
const val left: Direction = "LEFT"
const val right: Direction = "RIGHT"
fun main() {
val testInput = readInput("Day08_test", "day8")
check(part1(testInput) == 21)
check(part... | 0 | Kotlin | 0 | 0 | f58c9377edbe6fc5d777fba55d07873aa7775f9f | 2,797 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/DirWalk.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | fun main() {
DirWalk.solve()
}
private object DirWalk {
fun solve() {
val tree = buildTree(readInput())
val sizes = getDirSizes(tree)
// for (size in sizes) {
// println("${size.key.name} ${size.value}")
// }
val smallDirsTotal = sizes.filter { it.value <= 100_0... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 3,333 | aoc2022 | MIT License |
src/Day03.kt | Loahrs | 574,175,046 | false | {"Kotlin": 7516} | fun main() {
fun part1(input: List<String>): Int {
val letters : List<Char> = listOf('a'..'z','A'..'Z').flatten()
return input.asSequence().map {
val (leftPocket, rightPocket) = it.chunked(it.length / 2)
val leftPocketSet : HashSet<Char> = hashSetOf()
leftPocket... | 0 | Kotlin | 0 | 0 | b1ff8a704695fc6ba8c32a227eafbada6ddc0d62 | 1,330 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | sebokopter | 570,715,585 | false | {"Kotlin": 38263} | import Outcome.*
import Shape.*
enum class Shape(val value: Int) {
Rock(1), Paper(2), Scissors(3);
}
enum class Outcome(val score: Int) {
Win(6), Lose(0), Draw(3);
}
val outcomeMap = mapOf(
(Rock to Paper) to Win,
(Paper to Scissors) to Win,
(Scissors to Rock) to Win,
(Paper to Rock) to Lose,... | 0 | Kotlin | 0 | 0 | bb2b689f48063d7a1b6892fc1807587f7050b9db | 2,167 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | kmes055 | 577,555,032 | false | {"Kotlin": 35314} | import kotlin.math.min
fun main() {
class Node(
val id: String,
val parent: Node?,
val children: MutableMap<String, Node>,
val isDir: Boolean,
var size: Int? = null
) {
fun getSize(): Int {
return size ?: fetchSize().also { this.size = it }
}
... | 0 | Kotlin | 0 | 0 | 84c2107fd70305353d953e9d8ba86a1a3d12fe49 | 2,851 | advent-of-code-kotlin | Apache License 2.0 |
src/day02/Day02.kt | Ciel-MC | 572,868,010 | false | {"Kotlin": 55885} | package day02
import day02.Move.*
import day02.Result.*
import readInput
enum class Move(val score: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
fun beats(other: Move): Result {
return when (this to other) {
ROCK to SCISSORS, PAPER to ROCK, SCISSORS to PAPER -> WIN
ROCK to PAPER, PA... | 0 | Kotlin | 0 | 0 | 7eb57c9bced945dcad4750a7cc4835e56d20cbc8 | 2,253 | Advent-Of-Code | Apache License 2.0 |
src/commonMain/kotlin/advent2020/day19/Day19Puzzle.kt | jakubgwozdz | 312,526,719 | false | null | package advent2020.day19
val inputRegex by lazy { """(\d+):(( "a")|( "b")|(((\s\d+)+)( \|((\s\d+)+))?))""".toRegex() }
sealed class Rule
//data class CharRule(val c: Char) : Rule()
data class StringRule(val s: String) : Rule()
data class ConcatRawRule(val ids: List<Int>) : Rule()
data class ConcatRule(val rules: Lis... | 0 | Kotlin | 0 | 2 | e233824109515fc4a667ad03e32de630d936838e | 5,340 | advent-of-code-2020 | MIT License |
src/main/kotlin/aoc2023/Day02.kt | Ceridan | 725,711,266 | false | {"Kotlin": 110767, "Shell": 1955} | package aoc2023
class Day02 {
fun part1(input: List<String>, redCap: Int, greenCap: Int, blueCap: Int): Int = input
.map { line -> CubeGame.fromString(line) }
.filter { game -> game.red.all { it <= redCap } && game.green.all { it <= greenCap } && game.blue.all { it <= blueCap } }
.sumOf { g... | 0 | Kotlin | 0 | 0 | 18b97d650f4a90219bd6a81a8cf4d445d56ea9e8 | 1,922 | advent-of-code-2023 | MIT License |
src/main/kotlin/ru/timakden/aoc/year2023/Day12.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2023
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 12: Hot Springs](https://adventofcode.com/2023/day/12).
*/
object Day12 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val input = readInput("year2023/Day12")
... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 2,657 | advent-of-code | MIT License |
src/main/kotlin/aoc2021/Day08.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2021
import readInput
private fun part1(input: List<String>) =
input.map { it.split("|").last().trim().split(" ") }.flatten().map { it.length }.filter {
when (it) {
2, 4, 3, 7 -> true
else -> false
}
}.size
private enum class Digit(vararg chars: Char) {
... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,985 | adventOfCode | Apache License 2.0 |
y2018/src/main/kotlin/adventofcode/y2018/Day06.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2018
import adventofcode.io.AdventSolution
import kotlin.math.abs
object Day06 : AdventSolution(2018, 6, "Chronal Coordinates") {
override fun solvePartOne(input: String): Int? {
val points = parse(input)
val counts = mutableMapOf<Point, Int>()
val disqualified = mu... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,321 | advent-of-code | MIT License |
day-20/src/main/kotlin/TrenchMap.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | import kotlin.system.measureTimeMillis
fun main() {
val partOneMillis = measureTimeMillis {
println("Part One Solution: ${partOne()}")
}
println("Part One Solved in: $partOneMillis ms")
val partTwoMillis = measureTimeMillis {
println("Part Two Solution: ${partTwo()}")
}
println... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 3,026 | aoc-2021 | MIT License |
09/part_two.kt | ivanilos | 433,620,308 | false | {"Kotlin": 97993} | import java.io.File
fun readInput() : HeightMap {
val inputLines = File("input.txt")
.readLines()
.map { line -> line.split("")
.filter { it.isNotEmpty() }
.map{ it.toInt() }}
return HeightMap(inputLines)
}
class HeightMap(inputLines : List<List<Int>>) {
companion... | 0 | Kotlin | 0 | 3 | a24b6f7e8968e513767dfd7e21b935f9fdfb6d72 | 2,702 | advent-of-code-2021 | MIT License |
src/day15.kts | miedzinski | 434,902,353 | false | {"Kotlin": 22560, "Shell": 113} | import java.util.PriorityQueue
import kotlin.math.max
import kotlin.math.min
data class Point(val x: Int, val y: Int)
fun Point.neighboursIn(cave: List<List<Int>>): Sequence<Point> = sequenceOf(
copy(x - 1, y),
copy(x + 1, y),
copy(x, y - 1),
copy(x, y + 1),
).filter {
with(it) {
y in 0 un... | 0 | Kotlin | 0 | 0 | 6f32adaba058460f1a9bb6a866ff424912aece2e | 1,989 | aoc2021 | The Unlicense |
src/Day03.kt | zoidfirz | 572,839,149 | false | {"Kotlin": 15878} | fun main() {
firstHalfSolution()
secondHalfSolution()
}
private fun secondHalfSolution() {
val data = readInput("main/resources/Day03_Input")
val groupedData = data.chunked(3)
var sum = 0
groupedData.forEach { chunk ->
var badge: Char = ' '
chunk[0].forEach { charChunk ->
... | 0 | Kotlin | 0 | 0 | e955c1c08696f15929aaf53731f2ae926c585ff3 | 2,648 | kotlin-advent-2022 | Apache License 2.0 |
src/Day15.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | import kotlin.math.abs
data class Reading(val sensor: Point, val beacon: Point)
fun makeReadings(input: List<String>): List<Reading> {
val pointList = input.map {
it.replace("Sensor at ", "").replace(" closest beacon is at ", "").replace(":", ", ").split(", ")
}
return pointList.map {
Read... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 2,158 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day08.kt | sungi55 | 574,867,031 | false | {"Kotlin": 23985} | fun main() {
val day = "Day08"
fun getTreeGrid(input: List<String>): Grid =
Grid().apply {
input.forEachIndexed { rowIndex, row ->
val treesInRow = row.map { it.digitToInt() }
rows[rowIndex] = treesInRow
treesInRow.forEachIndexed { columnInde... | 0 | Kotlin | 0 | 0 | 2a9276b52ed42e0c80e85844c75c1e5e70b383ee | 2,945 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | proggler23 | 573,129,757 | false | {"Kotlin": 27990} | import java.util.*
fun main() {
fun part1(input: List<String>): Long {
val dir = input.parse7()
return dir.getAllDirs { it.size < 100000 }.sumOf { it.size }
}
fun part2(input: List<String>): Long {
val dir = input.parse7()
val freeSpace = 70000000L - dir.size
val si... | 0 | Kotlin | 0 | 0 | 584fa4d73f8589bc17ef56c8e1864d64a23483c8 | 2,462 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | ostersc | 572,991,552 | false | {"Kotlin": 46059} | const val MAX_SIZE = 70_000_000
const val FREE_SIZE = 30_000_000
data class File(val dir:Dir, val name:String, val size:Int)
class Dir(var name: String, var parent: Dir?) {
//name->size
var files = mutableMapOf<String, File>()
//name->Dir
var dirs = mutableMapOf<String, Dir>()
fun calcTotals(siz... | 0 | Kotlin | 0 | 1 | 3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9 | 2,862 | advent-of-code-2022 | Apache License 2.0 |
src/Day24.kt | azat-ismagilov | 573,217,326 | false | {"Kotlin": 75114} | fun main() {
val day = 24
fun Char.toDirection() = when (this) {
'>' -> 0
'v' -> 1
'<' -> 2
else -> 3
}
data class Position(val x: Int, val y: Int) {
fun move(steps: Int, direction: Int) = when (direction) {
0 -> copy(y = y + steps)
1 -> ... | 0 | Kotlin | 0 | 0 | abdd1b8d93b8afb3372cfed23547ec5a8b8298aa | 3,196 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2020/d21/Day21.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2020.d21
import com.groundsfam.advent.DATAPATH
import kotlin.io.path.div
import kotlin.io.path.useLines
data class Ingredients(val ingredients: List<String>, val allergens: List<String>)
fun parseLine(line: String): Ingredients =
line.split(" (contains ").let { (a, b) ->
Ing... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,673 | advent-of-code | MIT License |
2021/src/main/kotlin/Day04.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | class Day04(private val input: List<String>) {
private fun parseInput(input: List<String>): Set<Grid> =
input.asSequence().drop(1).filter { it.isNotEmpty() }.chunked(5).map { parseSingleBoard(it) }.toSet()
private fun parseSingleBoard(input: List<String>): Grid = input.map { row ->
row.split("... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 1,778 | adventofcode-2021-2025 | MIT License |
src/Day04.kt | weberchu | 573,107,187 | false | {"Kotlin": 91366} | private fun part1(input: List<String>): Int {
return input.count { line ->
val assignment = line.split(",").map { it.split("-").map { section -> section.toInt() } }
(assignment[0][0] <= assignment[1][0] && assignment[0][1] >= assignment[1][1])
|| (assignment[1][0] <= assignment[0][0] && ... | 0 | Kotlin | 0 | 0 | 903ff33037e8dd6dd5504638a281cb4813763873 | 1,087 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | D000L | 575,350,411 | false | {"Kotlin": 23716} | sealed interface Component
data class File(val size: Long, val name: String) : Component
data class Directory(
val name: String,
val parent: Directory? = null
) : Component {
private val children: MutableList<Component> = mutableListOf()
fun addChild(component: Component) {
children.add(compon... | 0 | Kotlin | 0 | 0 | b733a4f16ebc7b71af5b08b947ae46afb62df05e | 2,742 | adventOfCode | Apache License 2.0 |
Kotlin/src/dev/aspid812/leetcode/problem1854/Solution.kt | Const-Grigoryev | 367,924,342 | false | {"Python": 35682, "Kotlin": 11162, "C++": 2688, "Java": 2168, "C": 1076} | package dev.aspid812.leetcode.problem1854
import java.time.Year
/* 1854. Maximum Population Year
* -----------------------------
*
* You are given a 2D integer array `logs` where each `logs[i] = [birth_i, death_i]` indicates the birth and death
* years of the `i`-th person.
*
* The **population** of some year `... | 0 | Python | 0 | 0 | cea8e762ff79878e2d5622c937f34cf20f0b385e | 2,720 | LeetCode | MIT License |
src/main/kotlin/aoc2022/Day13.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2022
import readInput
import separateBy
import java.util.*
private object PacketComparator : Comparator<PacketData> {
override fun compare(left: PacketData, right: PacketData): Int {
//println("compare $left vs $right")
if (left is IntData) {
return if (right is IntData) {
... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,619 | adventOfCode | Apache License 2.0 |
2022/Day24.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | fun main() {
val map = readInput("Day24")
val dirx = arrayOf(1, 0, -1, 0)
val diry = arrayOf(0, 1, 0, -1)
data class Wind(
val x: Int,
val y: Int,
val dir: Int
) {
fun next() = Wind(1 + (x - 1 + map[0].length-2 + dirx[dir]) % (map[0].length-2), 1 + (y - 1 + map.size-2... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 1,741 | advent-of-code-kotlin | Apache License 2.0 |
src/Day08.kt | Xacalet | 576,909,107 | false | {"Kotlin": 18486} | /**
* ADVENT OF CODE 2022 (https://adventofcode.com/2022/)
*
* Solution to day 8 (https://adventofcode.com/2022/day/8)
*
*/
import java.lang.Integer.max
fun main() {
fun part1(trees: List<List<Int>>): Int {
fun isVisibleFromTop(i: Int, j: Int): Boolean =
!(i - 1).downTo(0).any { trees[... | 0 | Kotlin | 0 | 0 | 5c9cb4650335e1852402c9cd1bf6f2ba96e197b2 | 2,284 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | hrach | 572,585,537 | false | {"Kotlin": 32838} | fun main() {
fun isAdjacent(hx: Int, hy: Int, tx: Int, ty: Int): Boolean =
tx in (hx - 1..hx + 1) && ty in (hy - 1..hy + 1)
fun newPos(hx: Int, hy: Int, tx: Int, ty: Int): Pair<Int, Int> {
if (isAdjacent(hx, hy, tx, ty)) return tx to ty
val dx = if (hx > tx) 1 else if (hx == tx) 0 else ... | 0 | Kotlin | 0 | 1 | 40b341a527060c23ff44ebfe9a7e5443f76eadf3 | 2,484 | aoc-2022 | Apache License 2.0 |
src/Day05.kt | HylkeB | 573,815,567 | false | {"Kotlin": 83982} |
private class Stack(val index: Int, val items: ArrayDeque<Char>) {
override fun toString() = "$index: ${items.reversed()}"
}
private class MoveInstruction(val amount: Int, val fromIndex: Int, val toIndex: Int) {
override fun toString(): String = "move $amount from $fromIndex to $toIndex"
}
private fun parseD... | 0 | Kotlin | 0 | 0 | 8649209f4b1264f51b07212ef08fa8ca5c7d465b | 2,658 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day13.kt | f1qwase | 572,888,869 | false | {"Kotlin": 33268} | import java.lang.Character.isDigit
private sealed interface PacketElement: Comparable<PacketElement> {
data class Dgt(val value: Int) : PacketElement {
override fun compareTo(other: PacketElement): Int = when (other) {
is Dgt -> value.compareTo(other.value)
is Lst -> Lst(listOf(this... | 0 | Kotlin | 0 | 0 | 3fc7b74df8b6595d7cd48915c717905c4d124729 | 3,879 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/advent/of/code/hjk/Day24.kt | h-j-k | 427,964,167 | false | {"Java": 46088, "Kotlin": 26804} | package com.advent.of.code.hjk
import java.util.ArrayDeque
object Day24 {
private fun parse(input: List<String>): List<List<Position>> = input.indices.map { y ->
input[0].indices.map { x -> Position(x = x, y = y, value = input[y][x].toString()) }
}
private fun Position.from(other: Position, boar... | 0 | Java | 0 | 0 | 5ffa381e97cbcfe234c49b5a5f8373641166db6c | 2,607 | advent16 | Apache License 2.0 |
src/Day18.kt | matusekma | 572,617,724 | false | {"Kotlin": 119912, "JavaScript": 2024} | import java.util.*
class Cube(val x: Int, val y: Int, val z: Int) {
val coordKey: String
get() = "${this.x},${this.y},${this.z}"
fun add(vector: Cube): Cube {
return Cube(this.x + vector.x, this.y + vector.y, this.z + vector.z)
}
}
class Day18 {
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 744392a4d262112fe2d7819ffb6d5bde70b6d16a | 4,298 | advent-of-code | Apache License 2.0 |
src/day5/Day5.kt | pocmo | 433,766,909 | false | {"Kotlin": 134886} | package day5
import java.io.File
data class Line(
val x1: Int,
val y1: Int,
val x2: Int,
val y2: Int
) {
private fun isHorizontal(): Boolean = y1 == y2
private fun isVertical(): Boolean = x1 == x2
private fun isDiagonal(): Boolean = !isHorizontal() && !isVertical()
fun isHorizontalOrVe... | 0 | Kotlin | 1 | 2 | 73bbb6a41229e5863e52388a19108041339a864e | 2,807 | AdventOfCode2021 | Apache License 2.0 |
src/main/kotlin/dp/DisplayWords.kt | yx-z | 106,589,674 | false | null | package dp
import util.*
import kotlin.math.pow
// given a sequence of n words and their corresponding length stored in l[1..n]
// we want to break it into L lines
// in each line, the first char starts at the left and except the last line,
// the last character ends in the right
// define the slop as the sum over li... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,198 | AlgoKt | MIT License |
src/Day12.kt | frango9000 | 573,098,370 | false | {"Kotlin": 73317} | fun main() {
val input = readInput("Day12")
printTime { println(Day12.part1(input)) }
printTime { println(Day12.part2(input)) }
}
class Day12 {
companion object {
fun part1(input: List<String>): Int {
val (end, start) = input.toHeightGraph()
return end.getShortestPathBfs... | 0 | Kotlin | 0 | 0 | 62e91dd429554853564484d93575b607a2d137a3 | 2,759 | advent-of-code-22 | Apache License 2.0 |
src/year2023/04/Day04.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2023.`04`
import readInput
import utils.printlnDebug
import kotlin.math.pow
import kotlin.math.roundToInt
private const val CURRENT_DAY = "04"
private fun parseLineIntoCardValues(
line: String,
): Set<String> {
val winningNumbers = line.split("|")
.first()
.split(":")[1]
.... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 2,598 | KotlinAdventOfCode | Apache License 2.0 |
src/year2023/day22/Day22.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2023.day22
import check
import parallelMap
import readInput
fun main() {
val testInput = readInput("2023", "Day22_test")
check(part1(testInput), 5)
check(part2(testInput), 7)
val input = readInput("2023", "Day22")
println(part1(input))
println(part2(input))
}
private fun part1(in... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,560 | AdventOfCode | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2023/Day12.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val input = readInput(2023, 12, false).readLines().map { line ->
val (spread, compact) = line.split(" ")
spread to compact.split(",").map { it.toInt() }
}
part1(input)
part2(inp... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,948 | adventofcode | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2020/Day16.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 16 - Ticket Translation
* Problem Description: http://adventofcode.com/2020/day/16
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day16/
*/
package com.ginsberg.advent2020
class Day16(input: List<String>) {
priv... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 3,313 | advent-2020-kotlin | Apache License 2.0 |
year2017/src/main/kotlin/net/olegg/aoc/year2017/day7/Day7.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2017.day7
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2017.DayOf2017
/**
* See [Year 2017, Day 7](https://adventofcode.com/2017/day/7)
*/
object Day7 : DayOf2017(7) {
override fun first(): Any? {
return lines
.map { line -> line.split(" ").map { it.replace(","... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,057 | adventofcode | MIT License |
src/Day13.kt | dmstocking | 575,012,721 | false | {"Kotlin": 40350} |
sealed class Item : Comparable<Item> {
override fun compareTo(other: Item): Int {
return this.compare(other)
}
}
data class ItemList(val items: List<Item>): Item()
data class Value(val value: Int): Item()
fun Item.compare(right: Item): Int {
val left = this
return when {
left is ItemL... | 0 | Kotlin | 0 | 0 | e49d9247340037e4e70f55b0c201b3a39edd0a0f | 3,685 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/y2023/Day06.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2023
import util.product
import util.readInput
import util.timingStatistics
import kotlin.math.sqrt
object Day06 {
private fun parse(input: List<String>): Pair<List<Int>, List<Int>> {
val time = input[0].split(Regex("\\s+")).drop(1).map { it.toInt() }
val distance = input[1].split(Regex("... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,766 | advent-of-code | Apache License 2.0 |
src/day6/d6_2.kt | svorcmar | 720,683,913 | false | {"Kotlin": 49110} | fun main() {
val input = ""
val grid = Array(1000) { Array(1000) { 0 } }
val instructions = parseInstructions(input)
instructions.forEach {
for (i in Math.min(it.p0.first, it.p1.first) .. Math.max(it.p0.first, it.p1.first)) {
for (j in Math.min(it.p0.second, it.p1.second) .. Math.max(it.p0.second, it.... | 0 | Kotlin | 0 | 0 | cb097b59295b2ec76cc0845ee6674f1683c3c91f | 1,330 | aoc2015 | MIT License |
src/Day05.kt | yalematta | 572,668,122 | false | {"Kotlin": 8442} | fun main() {
fun part1(input: List<String>): String {
val parse = input.map { it.split("\n") }.flatten()
val emptySpaceIndex = parse.indexOfFirst { it.isBlank() }
val padding = parse[emptySpaceIndex - 1].length + 1
val crates = parse.slice(0 until emptySpaceIndex - 1)
val pa... | 0 | Kotlin | 0 | 0 | 2b43681cc2bd02e4838b7ad1ba04ff73c0422a73 | 2,098 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/graph/core/AllPairsShortestPath.kt | yx-z | 106,589,674 | false | null | package graph.core
import util.*
import java.lang.Math.ceil
import kotlin.math.log
// given a weighted graph with either negative, zero, or positive edges G = (V, E)
// report a table dist[u, v]: the shortest distance between u and v in G
// our first solution is just run Bellman-Ford's Algorithm for every vertex
fu... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 4,217 | AlgoKt | MIT License |
src/Day07/day07.kt | NST-d | 573,224,214 | false | null | import utils.*
fun main() {
data class FileTree(val name: String,
var size: Int = 0,
val children: MutableList<FileTree> = emptyList<FileTree>().toMutableList(),
val parent: FileTree? = null,
val directory : Boolean= tr... | 0 | Kotlin | 0 | 0 | c4913b488b8a42c4d7dad94733d35711a9c98992 | 3,876 | aoc22 | Apache License 2.0 |
2022/main/day_16/Main.kt | Bluesy1 | 572,214,020 | false | {"Rust": 280861, "Kotlin": 94178, "Shell": 996} | package day_16_2022
import java.io.File
val parsed = File("2022/inputs/Day_16.txt").readLines().map(Valve::from)
val valves = parsed.associateBy { it.id }
val shortestPaths =
floydWarshall(parsed.associate { it.id to it.neighborIds.associateWith { 1 }.toMutableMap() }.toMutableMap())
var score = 0
var totalTime =... | 0 | Rust | 0 | 0 | 537497bdb2fc0c75f7281186abe52985b600cbfb | 2,562 | AdventofCode | MIT License |
src/main/kotlin/be/seppevolkaerts/day11/Day11.kt | Cybermaxke | 727,453,020 | false | {"Kotlin": 35118} | package be.seppevolkaerts.day11
import kotlin.math.max
import kotlin.math.min
enum class Tile {
Galaxy,
Empty,
}
data class Pos(val x: Int, val y: Int)
class Universe(
private val values: List<List<Tile>>,
private val rowScales: List<Long> = List(values.size) { 1 },
private val colScales: List<Long> = Lis... | 0 | Kotlin | 0 | 1 | 56ed086f8493b9f5ff1b688e2f128c69e3e1962c | 1,698 | advent-2023 | MIT License |
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day12.kt | MichalChomo | 572,214,942 | false | {"Kotlin": 56758} | package eu.michalchomo.adventofcode.year2022
import java.util.PriorityQueue
import kotlin.math.abs
data class Point(
val row: Int,
val col: Int,
)
data class Graph(val edges: Map<Point, List<Point>>) {
fun shortestPath(start: Point, destination: Point): Int {
val costSoFar = mutableMapOf(start ... | 0 | Kotlin | 0 | 0 | a95d478aee72034321fdf37930722c23b246dd6b | 4,035 | advent-of-code | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day13.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
class Day13 {
private val messages = inputFile("day13").readLines()
.filter { it.isNotEmpty() }
.map { decode(it) }
fun solvePart1(): Int {
return messages
.windowed(2, 2)
.map { it[0] to it[1] }
.mapIndexed { i, (left, ... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 1,947 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/day09/Day09.kt | ayukatawago | 572,742,437 | false | {"Kotlin": 58880} | package day09
import day09.Direction.Companion.toDirection
import readInput
import kotlin.math.abs
fun main() {
val testInput = readInput("day09/test")
val motions = testInput.mapNotNull {
val direction = it.split(" ")[0].toDirection() ?: return@mapNotNull null
val count = it.split(" ")[1].toI... | 0 | Kotlin | 0 | 0 | 923f08f3de3cdd7baae3cb19b5e9cf3e46745b51 | 2,994 | advent-of-code-2022 | Apache License 2.0 |
2022/src/day11/day11.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day11
import GREEN
import RESET
import printTimeMillis
import readInput
data class Monkey(
val items: MutableList<Long>,
val operation: (Long) -> Long,
val test: (Long) -> Boolean,
val trueMonkey: Int,
val falseMonkey: Int,
val divisor: Long,
var inspect: Int = 0
) {
fun add(ne... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 2,992 | advent-of-code | Apache License 2.0 |
src/day08/Day08.kt | martinhrvn | 724,678,473 | false | {"Kotlin": 27307, "Jupyter Notebook": 1336} | package day08
import AdventDay
import findLCM
import readInput
data class HauntedWasteland(
val path: Map<String, Pair<String, String>>,
val instructions: List<String>
) {
private fun getInstructions() = generateSequence { instructions }.flatten()
fun getPathLength(start: String, endCondition: (str: Str... | 0 | Kotlin | 0 | 0 | 59119fba430700e7e2f8379a7f8ecd3d6a975ab8 | 1,879 | advent-of-code-2023-kotlin | Apache License 2.0 |
src/Day04.kt | alexaldev | 573,318,666 | false | {"Kotlin": 10807} | fun main() {
fun part1(input: List<String>): Int {
return input
.map { it.split(",")
.map { range -> range.split("-") } }
.map { it.hasARangeIncludedInOther() }
.count { it }
}
fun part2(input: List<String>): Int {
return input
.... | 0 | Kotlin | 0 | 0 | 5abf10b2947e1c6379d179a48f1bdcc719e7062b | 1,406 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day02.kt | akijowski | 574,262,746 | false | {"Kotlin": 56887, "Shell": 101} | data class Round(val opponent: String, val you: String) {
// A, X => Rock
// B, Y => Paper
// C, Z => Scissors
// value = winner
private val defeats = mapOf(
"A" to "Y",
"B" to "Z",
"C" to "X"
)
private val draws = mapOf(
"A" to "X",
"B" to "Y",
... | 0 | Kotlin | 1 | 0 | 84d86a4bbaee40de72243c25b57e8eaf1d88e6d1 | 1,977 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | tigerxy | 575,114,927 | false | {"Kotlin": 21255} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { round ->
val other = round.first().map()
val me = round.last().map()
val result = when {
other == me -> 3
me == Rock && other == Scissors -> 6
me == Sc... | 0 | Kotlin | 0 | 1 | d516a3b8516a37fbb261a551cffe44b939f81146 | 1,848 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day08.kt | fercarcedo | 573,142,185 | false | {"Kotlin": 60181} | data class VisibilityStatus(
val visible: Boolean,
val viewingDistance: Int
)
fun main() {
fun calculateVisibilityStatus(treeHeight: Int, rowRange: Iterable<Int>, colRange: Iterable<Int>, grid: List<List<Int>>): VisibilityStatus {
var viewingDistance = 0
for (i in rowRange) {
f... | 0 | Kotlin | 0 | 0 | e34bc66389cd8f261ef4f1e2b7f7b664fa13f778 | 2,760 | Advent-of-Code-2022-Kotlin | Apache License 2.0 |
src/Day12.kt | fasfsfgs | 573,562,215 | false | {"Kotlin": 52546} | fun main() {
fun part1(input: List<String>): Int {
val heightMap = HeightMap.fromInput(input)
val result = findPath(heightMap) { it == heightMap.start }
return result.getLength()
}
fun part2(input: List<String>): Int {
val heightMap = HeightMap.fromInput(input)
val r... | 0 | Kotlin | 0 | 0 | 17cfd7ff4c1c48295021213e5a53cf09607b7144 | 3,455 | advent-of-code-2022 | Apache License 2.0 |
src/day05/Day05.kt | emartynov | 572,129,354 | false | {"Kotlin": 11347} | package day05
import readInput
private class Schema(
numberOfStacks: Int
) {
private val stacks: MutableList<List<Char>> = MutableList(numberOfStacks) { emptyList() }
operator fun get(indexFromOne: Int): List<Char> = stacks[indexFromOne - 1]
fun add(indexFromOne: Int, value: Char): Schema {
v... | 0 | Kotlin | 0 | 1 | 8f3598cf29948fbf55feda585f613591c1ea4b42 | 3,375 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day07.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | fun main() {
fun cd(root: Folder, current: Folder, name: String): Folder = when (name) {
"/" -> root
".." -> {
if (current.name == "/") {
current
} else {
val parent = requireNotNull(current.parent)
parent.copy(child = parent.c... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 3,669 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/Day13/Day13.kt | AllePilli | 572,859,920 | false | {"Kotlin": 47397} | package Day13
import checkAndPrint
import measureAndPrintTimeMillis
import readInput
fun main() {
val printComparisons = false
val parser = Parser()
fun List<String>.prepareInputPart1() = (this + "").chunked(3)
.map { it.dropLast(1) }
.map { (left, right) -> left to right }
fun compa... | 0 | Kotlin | 0 | 0 | 614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643 | 4,489 | AdventOfCode2022 | Apache License 2.0 |
src/Day13.kt | kmes055 | 577,555,032 | false | {"Kotlin": 35314} | class Signal private constructor(type: String, private val number: Int?, val list: List<Signal>?): Comparable<Signal> {
private val isNumber = type == "NUMBER"
private val isList = type == "LIST"
fun box() = ofList(listOf(this))
override fun toString(): String {
return if (isList) list.toStrin... | 0 | Kotlin | 0 | 0 | 84c2107fd70305353d953e9d8ba86a1a3d12fe49 | 3,317 | advent-of-code-kotlin | Apache License 2.0 |
src/Day01.kt | GunnarBernsteinHH | 737,845,880 | false | {"Kotlin": 10952} | /*
* --- Day 1: Trebuchet?! ---
* Source: https://adventofcode.com/2023/day/1
*
*/
fun main() {
// val numbersAsString = listOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
val numberMap = mapOf("one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7... | 0 | Kotlin | 0 | 0 | bc66eef73bca2e64dfa5d83670266c8aaeae5b24 | 2,249 | aoc-2023-in-kotlin | MIT License |
src/main/kotlin/days/Day16.kt | MaciejLipinski | 317,582,924 | true | {"Kotlin": 60261} | package days
class Day16 : Day(16) {
override fun partOne(): Any {
val rules = inputString
.split("your ticket:")[0]
.split("\n")
.filter { it.isNotBlank() }
.map { it.split(": ")[1] }
.map { it.split(" or ") }
... | 0 | Kotlin | 0 | 0 | 1c3881e602e2f8b11999fa12b82204bc5c7c5b51 | 3,754 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/Day04.kt | iownthegame | 573,926,504 | false | {"Kotlin": 68002} | class Pair(private val line: String) {
private val assignmentOfFirstElf: Assignment
private val assignmentOfSecondElf: Assignment
init {
val parts = line.split(",")
assignmentOfFirstElf = Assignment(parts.first().split("-").map { it.toInt() })
assignmentOfSecondElf = Assignment(part... | 0 | Kotlin | 0 | 0 | 4e3d0d698669b598c639ca504d43cf8a62e30b5c | 2,090 | advent-of-code-2022 | Apache License 2.0 |
src/Day11.kt | MatthiasDruwe | 571,730,990 | false | {"Kotlin": 47864} | import kotlin.math.floor
fun main() {
fun part1(input: List<String>): Long {
val monkeys = input.splitOnEmptyString().map { Monkey(it.drop(1)) }
repeat(20){
monkeys.forEach { monkey->
repeat(monkey.numbers.size) {
monkey.inspect()
... | 0 | Kotlin | 0 | 0 | f35f01cea5075cfe7b4a1ead9b6480ffa57b4989 | 3,268 | Advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | aneroid | 572,802,061 | false | {"Kotlin": 27313} | enum class RockPaperScissors(val theirLetter: String, val myLetter: String, val choiceScore: Int) {
ROCK("A", "X", 1),
PAPER("B", "Y", 2),
SCISSORS("C", "Z", 3),
;
private fun beats(other: RockPaperScissors) =
when (this) {
ROCK -> SCISSORS
PAPER -> ROCK
... | 0 | Kotlin | 0 | 0 | cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd | 2,196 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day02.kt | ka1eka | 574,248,838 | false | {"Kotlin": 36739} | fun main() {
val rules1 = mapOf(
Pair('A', 'A') to 3,
Pair('A', 'B') to 6,
Pair('A', 'C') to 0,
Pair('B', 'A') to 0,
Pair('B', 'B') to 3,
Pair('B', 'C') to 6,
Pair('C', 'A') to 6,
Pair('C', 'B') to 0,
Pair('C', 'C') to 3,
)
val rules2 ... | 0 | Kotlin | 0 | 0 | 4f7893448db92a313c48693b64b3b2998c744f3b | 1,471 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | muellerml | 573,601,715 | false | {"Kotlin": 14872} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf {
val splitted = it.split(" ")
calculateResult(OpponentSymbol.valueOf(splitted[0]).translate(), OwnSymbol.valueOf(splitted[1]))
}
}
fun part2(input: List<String>): Int {
return input.sumO... | 0 | Kotlin | 0 | 0 | 028ae0751d041491009ed361962962a64f18e7ab | 2,810 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day09/day9.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day09
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val smokeMap = parseSmokeMap(lines)
println("Low points risk sum is: ${getLowPointsRiskSum(smokeMap)}")
val bas... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 2,469 | advent-of-code | MIT License |
src/Day07.kt | sbaumeister | 572,855,566 | false | {"Kotlin": 38905} | data class Directory(
val name: String,
val parentNode: Directory?,
val files: MutableSet<File>,
val dirs: MutableSet<Directory>,
var size: Int = 0,
) {
override fun toString(): String = "$parentNode -> $name"
override fun hashCode(): Int = parentNode.hashCode() + name.hashCode()
}
data cla... | 0 | Kotlin | 0 | 0 | e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84 | 2,804 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | jstapels | 572,982,488 | false | {"Kotlin": 74335} | typealias Dirs = Map<String, Long>
fun main() {
fun dirSizes(path: String, data: Dirs) =
data.filterKeys { it.startsWith(path) }
.values
.sum()
fun dirSizes(data: Dirs) =
data.keys
.associateWith { dirSizes(it, data) }
fun makePath(path: List<String>) ... | 0 | Kotlin | 0 | 0 | 0d71521039231c996e2c4e2d410960d34270e876 | 1,872 | aoc22 | Apache License 2.0 |
src/main/kotlin/net/wrony/aoc2023/a12/Riddle.kt | kopernic-pl | 727,133,267 | false | {"Kotlin": 52043} | package net.wrony.aoc2023.a12
import kotlin.io.path.Path
import kotlin.io.path.readLines
fun txtToSprings(s: String): Pair<String, List<Int>> {
return s.split(" ").let { (inp, desc) -> inp to desc.split(",").map { it.toInt() } }
}
fun isPossible(s: Pair<String, List<Int>>): Boolean {
val (inp, desc) = s
... | 0 | Kotlin | 0 | 0 | 1719de979ac3e8862264ac105eb038a51aa0ddfb | 1,684 | aoc-2023-kotlin | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day287/day287.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day287
// day287.kt
// By <NAME>, 2020.
import java.util.PriorityQueue
typealias UserId = Int
typealias Watcher<T> = Pair<T, UserId>
typealias WatcherInfoList<T> = List<Pair<T, Set<UserId>>>
typealias Similarity<T> = Pair<T, T>
/**
* The similarity score between two Ts (assumed to be TV shows, but could... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,872 | daily-coding-problem | MIT License |
src/Day03.kt | dmarmelo | 573,485,455 | false | {"Kotlin": 28178} | fun main() {
fun calculatePriority(char: Char) = when (char.code) {
in ('a'.code..'z'.code) -> char - 'a' + 1
in ('A'.code..'Z'.code) -> char - 'A' + 27
else -> error("Unknown input $char")
}
infix fun String.intersect(other: String): Set<Char> = toSet() intersect other.toSet()
... | 0 | Kotlin | 0 | 0 | 5d3cbd227f950693b813d2a5dc3220463ea9f0e4 | 1,672 | advent-of-code-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.