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/day8.kt | gautemo | 572,204,209 | false | {"Kotlin": 78294} | import shared.getText
import shared.takeWhileInclusive
fun main(){
val input = getText("day8.txt")
println(day8A(input))
println(day8B(input))
}
fun day8A(input: String): Int {
val trees = toTrees(input)
var count = 0
for(y in trees.indices) {
for((x, tree) in trees[y].withIndex()) {
... | 0 | Kotlin | 0 | 0 | bce9feec3923a1bac1843a6e34598c7b81679726 | 2,613 | AdventOfCode2022 | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-13.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2022
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputText
fun main() {
val input = readInputText(2022, "13-input")
val testInput1 = readInputText(2022, "13-test1")
println("Part1:")
part1(testInput1).println(... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,888 | advent-of-code | MIT License |
src/Day02.kt | PascalHonegger | 573,052,507 | false | {"Kotlin": 66208} | private enum class Hand(val score: Int) {
Rock(score = 1),
Paper(score = 2),
Scissor(score = 3),
}
private enum class RoundResult(val score: Int) {
Win(score = 6),
Draw(score = 3),
Lose(score = 0),
}
fun main() {
fun String.toHand() = when(this) {
"A" -> Hand.Rock
"B"-> Han... | 0 | Kotlin | 0 | 0 | 2215ea22a87912012cf2b3e2da600a65b2ad55fc | 2,097 | advent-of-code-2022 | Apache License 2.0 |
src/Day14.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} |
fun main() {
val sandDirections = listOf(Pair(0, 1), Pair(-1, 1), Pair(1, 1))
fun createWall(points: List<Point>) = points.windowed(2)
.flatMap { (first, second) ->
(if (first.x > second.x) first.x downTo second.x else first.x..second.x).flatMap { x ->
(if (first.y > second.y) firs... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 2,681 | advent-of-code-2022 | Apache License 2.0 |
src/year2023/day03/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day03
import year2023.solveIt
fun main() {
val day = "03"
val expectedTest1 = 4361L
val expectedTest2 = 467835L
data class Piece(val l:Int, val c:Int, val len:Int, val id:Int)
fun getParts(input: List<String>) = input.flatMapIndexed { lNumber, line ->
line.mapIndexedNo... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,800 | adventOfCode | Apache License 2.0 |
src/year2023/day15/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day15
import year2023.solveIt
fun main() {
val day = "15"
val expectedTest1 = 1320L
val expectedTest2 = 145L
fun hash(s: String): Int {
return s.asSequence().fold(0) { acc, c ->
((acc + c.code) * 17) % 256
}
}
fun part1(input: List<String>): Lon... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,758 | adventOfCode | Apache License 2.0 |
src/Day08.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} | data class Coords(val y: Int, val x: Int)
fun main() {
val directions = listOf(Pair(-1, 0), Pair(1, 0), Pair(0, -1), Pair(0, 1))
fun isInBounds(grid: List<List<Int>>, coords: Coords) =
coords.x >= 0 && coords.y >= 0 && coords.y < grid.size && coords.x < grid[coords.y].size
fun applyDirection(coor... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 2,899 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day02.kt | michaeljwood | 572,560,528 | false | {"Kotlin": 5391} | fun main() {
fun part1(input: List<String>) = input.filter { it.isNotBlank() }
.map { it.split(" ") }
.map { Pair(RockPaperScissors.fromString(it.first()), RockPaperScissors.fromString(it[1])) }
.sumOf { it.first.score(it.second) }
fun part2(input: List<String>) = input.filter { it.isNo... | 0 | Kotlin | 0 | 0 | 8df2121f12a5a967b25ce34bce6678ab9afe4aa7 | 1,758 | advent-of-code-2022 | Apache License 2.0 |
src/day07/Code.kt | ldickmanns | 572,675,185 | false | {"Kotlin": 48227} | package day07
import readInput
fun main() {
val input = readInput("day07/input")
// val input = readInput("day07/input_test")
println(part1(input))
println(part2(input))
}
fun part1(input: List<String>): Int {
val fileTree = parseToTree(input)
return sumSizes(fileTree, 0)
}
sealed interface ... | 0 | Kotlin | 0 | 0 | 2654ca36ee6e5442a4235868db8174a2b0ac2523 | 3,234 | aoc-kotlin-2022 | Apache License 2.0 |
src/DaySix.kt | P-ter | 573,301,805 | false | {"Kotlin": 9464} | fun main() {
val map = buildMap<Int, MutableList<Boolean>> {
(0 .. 999).forEach {row ->
this[row] = (0 .. 999).map { false }.toMutableList()
}
}
fun part1(input: List<String>): Int {
var total = 0
val firstMap = map.toMap().toMutableMap()
input.forEach {... | 0 | Kotlin | 0 | 0 | fc46b19451145e0c41b1a50f62c77693865f9894 | 2,538 | aoc-2015 | Apache License 2.0 |
src/day14/Day14.kt | Volifter | 572,720,551 | false | {"Kotlin": 65483} | package day14
import utils.*
val SAND_SOURCE_COORDS = Coords(500, 0)
data class Coords(var x: Int, var y: Int) {
fun coerceIn(range: IntRange): Coords =
Coords(x.coerceIn(range), y.coerceIn(range))
operator fun plus(other: Coords): Coords = Coords(x + other.x, y + other.y)
operator fun minus(ot... | 0 | Kotlin | 0 | 0 | c2c386844c09087c3eac4b66ee675d0a95bc8ccc | 2,430 | AOC-2022-Kotlin | Apache License 2.0 |
2022/Day15/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import kotlin.math.*
data class Position(val x: Int, val y: Int) {}
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
val regex = """x=(-?\d+).*y=(-?\d+).*x=(-?\d+).*y=(-?\d+)""".toRegex()
val input =
lines.map {
regex.find(it)!!.destruct... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 2,429 | AdventOfCode | MIT License |
src/Day07.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | fun main() {
fun part1(input: List<String>): Int {
val state = DeviceState().also { it.processInput(input) }
return state.root.recursiveDirectories()
.map { it.size() }
.filter { it <= 100_000 }
.sum()
}
fun part2(input: List<String>): Int {
val ... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 2,332 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | dmarcato | 576,511,169 | false | {"Kotlin": 36664} | import kotlin.math.min
sealed interface Node
data class Dir(
val name: String,
val parent: Dir? = null,
var children: MutableList<Node> = mutableListOf()
) : Node
data class File(
val name: String,
val size: Int
) : Node
fun Node.totalSize(): Int = when (this) {
is File -> size
is Dir ->... | 0 | Kotlin | 0 | 0 | 6abd8ca89a1acce49ecc0ca8a51acd3969979464 | 3,257 | aoc2022 | Apache License 2.0 |
src/main/kotlin/endredeak/aoc2023/Day07.kt | edeak | 725,919,562 | false | {"Kotlin": 26575} | package endredeak.aoc2023
val cardList = "AKQJT98765432".map { it.toString() }.reversed()
val jokerCardList = "AKQT98765432J".map { it.toString() }.reversed()
fun Char.r(jokers: Boolean = false) = (if (jokers) jokerCardList else cardList).indexOf(toString())
fun String.withJokers() =
when {
this.all { it ... | 0 | Kotlin | 0 | 0 | 92c684c42c8934e83ded7881da340222ff11e338 | 2,582 | AdventOfCode2023 | Do What The F*ck You Want To Public License |
src/Day08.kt | bjornchaudron | 574,072,387 | false | {"Kotlin": 18699} | fun main() {
fun part1(input: List<String>): Int {
val treeGrid = toGrid(input)
return countVisibleTrees(treeGrid)
}
fun part2(input: List<String>): Int {
val treeGrid = toGrid(input)
return findBestScenicScore(treeGrid)
}
// test if implementation meets criteria fr... | 0 | Kotlin | 0 | 0 | f714364698966450eff7983fb3fda3a300cfdef8 | 3,648 | advent-of-code-2022 | Apache License 2.0 |
y2018/src/main/kotlin/adventofcode/y2018/Day17.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2018
import adventofcode.io.AdventSolution
object Day17 : AdventSolution(2018, 17, "Reservoir Research") {
override fun solvePartOne(input: String) = Reservoirs(input)
.apply { flow(Point(500, 0)) }
.count { it in "|~" }
override fun solvePartTwo(input: String) ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,858 | advent-of-code | MIT License |
src/main/kotlin/Day05.kt | akowal | 434,506,777 | false | {"Kotlin": 30540} | import Day05.Orientation.*
fun main() {
println(Day05.solvePart1())
println(Day05.solvePart2())
}
object Day05 {
private val allLines = readInput("day05")
.asSequence()
.map { it.replace(" -> ", ",") }
.map { it.toIntArray() }
.map { (x1, y1, x2, y2) -> Line(x1, y1, x2, y2)... | 0 | Kotlin | 0 | 0 | 08d4a07db82d2b6bac90affb52c639d0857dacd7 | 1,505 | advent-of-kode-2021 | Creative Commons Zero v1.0 Universal |
kotlin/src/Day08.kt | ekureina | 433,709,362 | false | {"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386} | import java.lang.IllegalStateException
fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { line ->
line.split("|").last().trim().split(" ").count { output ->
val segments = output.length
output.length == 2 || output.length == 3 || output.leng... | 0 | Kotlin | 0 | 1 | 391d0017ba9c2494092d27d22d5fd9f73d0c8ded | 4,033 | aoc-2021 | MIT License |
src/Day08.kt | mvanderblom | 573,009,984 | false | {"Kotlin": 25405} | fun List<Int>.takeUntilIncluding(predicate: (Int) -> Boolean): List<Int> {
val toIndex = this.indexOfFirst(predicate)
return when {
toIndex == -1 || (toIndex == 0 && this.size == 1) -> this
toIndex == 0 -> emptyList()
else -> this.subList(0, toIndex+1)
}
}
class Forest(val input: L... | 0 | Kotlin | 0 | 0 | ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690 | 2,952 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/day12/Part1.kt | ollehagner | 572,141,655 | false | {"Kotlin": 80353} | package day12
import common.Direction.*
import common.Grid
import common.Point
import dequeOf
import readInput
import java.util.*
typealias Path = Deque<Point>
fun main() {
val (start, goal, grid) = parseInput(readInput("day12/input.txt"))
val shortestPath = shortestPath(start, goal, grid)
println("Day 1... | 0 | Kotlin | 0 | 0 | 6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1 | 2,403 | aoc2022 | Apache License 2.0 |
src/Day07.kt | MatthiasDruwe | 571,730,990 | false | {"Kotlin": 47864} | import java.lang.Error
fun main() {
fun createStructure(input: List<String>): Directory {
val structure = Directory("root")
var currentItem: Directory? = null
val parents = mutableMapOf<String, Directory>()
input.forEach { line ->
val items = line.split(" ")
... | 0 | Kotlin | 0 | 0 | f35f01cea5075cfe7b4a1ead9b6480ffa57b4989 | 2,753 | Advent-of-code-2022 | Apache License 2.0 |
kotlin-practice/src/main/kotlin/algorithms/new/CubeConundrum.kt | nicolegeorgieva | 590,020,790 | false | {"Kotlin": 120359} | package algorithms.new
import java.io.File
fun main() {
val input = File("cubes.txt").readText()
val sets =
parseSets("Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green")
println(sumOfGamePowers(input))
}
val bag = Set(
redCubesCount = 12,
greenCubesCount = 13,
blueCubesCount = ... | 0 | Kotlin | 0 | 1 | c96a0234cc467dfaee258bdea8ddc743627e2e20 | 3,232 | kotlin-practice | MIT License |
src/Day09.kt | asm0dey | 572,860,747 | false | {"Kotlin": 61384} | import kotlin.math.abs
import kotlin.math.sign
data class Point09(val x: Int, val y: Int) {
infix fun notTouches(other: Point09): Boolean = !(abs(this.x - other.x) <= 1 && abs(this.y - other.y) <= 1)
operator fun plus(other: Point09): Point09 = copy(x = x + other.x, y = y + other.y)
}
fun main() {
infix ... | 1 | Kotlin | 0 | 1 | f49aea1755c8b2d479d730d9653603421c355b60 | 2,138 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | lukewalker128 | 573,611,809 | false | {"Kotlin": 14077} | fun main() {
val testInput = readInput("Day02_test")
check(part1(testInput) == 15)
check(part2(testInput) == 12)
val input = readInput("Day02")
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
/**
* Determines the score that the second player would achieve following the... | 0 | Kotlin | 0 | 0 | c1aa17de335bd5c2f5f555ecbdf39874c1fb2854 | 3,230 | advent-of-code-2022 | Apache License 2.0 |
src/y2022/Day20.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.readInput
object Day20 {
class Node(
val value: Long,
var prev: Node?,
var next: Node?,
) {
fun move(mod: Int? = null) {
prev?.next = next
next?.prev = prev
var remainingDist = value
if (mod != null) rema... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 3,038 | advent-of-code | Apache License 2.0 |
2023/src/main/kotlin/Day22.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | object Day22 {
fun part1(input: String): Int {
val bricks = parse(input).sortedBy { it.zRange.first }
val (settled) = dropBricks(bricks)
return settled.count { brick ->
val bricksWithDisintegration = settled.filter { it != brick }
val (_, numBricksFallen) = dropBricks(bricksWithDisintegration... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 2,728 | advent-of-code | MIT License |
src/main/kotlin/ru/timakden/aoc/year2015/Day13.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2015
import ru.timakden.aoc.util.Permutations
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 13: Knights of the Dinner Table](https://adventofcode.com/2015/day/13).
*/
object Day13 {
@JvmStatic
fun main(args: Array<String>) {
measure ... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 3,098 | advent-of-code | MIT License |
src/Day03.kt | stcastle | 573,145,217 | false | {"Kotlin": 24899} | /** Finds the common character in the two strings. */
fun findCommon(a: String, b: String): Char {
a.forEach { if (b.contains(it)) return it }
throw Exception("No common character found between the two strings.\n\tFirst: $a\n\tSecond: $b")
}
/** Finds the common character among all the strings. */
fun findCommon(s... | 0 | Kotlin | 0 | 0 | 746809a72ea9262c6347f7bc8942924f179438d5 | 1,804 | aoc2022 | Apache License 2.0 |
2015/src/main/kotlin/day6_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Parser
import utils.Solution
import utils.Vec2i
import utils.cut
import utils.map
import utils.mapItems
fun main() {
Day6Func.run()
}
object Day6Func : Solution<List<Day6Func.Opcode>>() {
override val name = "day6"
override val parser = Parser.lines.mapItems(Opcode::parse)
e... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,898 | aoc_kotlin | MIT License |
src/Day12.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | import java.util.PriorityQueue
fun main() {
fun findAndReplace(table: List<CharArray>, ch: Char, replacement: Char) = buildList {
for (i in table.indices) {
for (j in table[0].indices) {
if (table[i][j] == ch) {
table[i][j] = replacement
a... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 2,232 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day15.kt | zfz7 | 573,100,794 | false | {"Kotlin": 53499} | fun main() {
println(day15A(readFile("Day15")))
println(day15B(readFile("Day15")))
}
fun parseInput(input: String): List<Pair<Pair<Int, Int>, Pair<Int, Int>>> {
val sensorBeaconPair = input.trim().split("\n").map { line ->
val ints = line.split("Sensor at x=", ", y=", ": closest beacon is at x=", "... | 0 | Kotlin | 0 | 0 | c50a12b52127eba3f5706de775a350b1568127ae | 2,687 | AdventOfCode22 | Apache License 2.0 |
src/Day12.kt | simonbirt | 574,137,905 | false | {"Kotlin": 45762} | fun main() {
Day12.printSolutionIfTest(31, 29)
}
object Day12 : Day<Int, Int>(12) {
override fun part1(lines: List<String>): Int {
val map = Map2(lines)
val start = map.select { it.label == 'S' }.first()
val end = map.select { it.label == 'E' }
return map.explore(start, end) { c... | 0 | Kotlin | 0 | 0 | 962eccac0ab5fc11c86396fc5427e9a30c7cd5fd | 2,972 | advent-of-code-2022 | Apache License 2.0 |
day-06-kotlin/src/Main.kt | jakoberzar | 159,959,049 | false | {"JavaScript": 23733, "TypeScript": 11163, "Scala": 8193, "Rust": 7557, "Kotlin": 4451, "C#": 4250, "HTML": 2059} | import java.io.File
typealias Coordinates = List<Pair<Int, Int>>;
fun main() {
val input = getInput()
val coords = parseInput(input)
star1(coords)
star2(coords)
}
fun star1(coords: Coordinates) {
val (xBound, yBound) = getSmallestArea(coords)
val amounts = getAmountClosestInArea(coords, (2..x... | 0 | JavaScript | 0 | 1 | 8779f71cebff6711e8b6613705bcba9714b4e33f | 2,981 | advent-of-code-2018 | MIT License |
src/Day02.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | fun main() {
fun part1(input: List<String>): Int {
return input.mapIndexed { index, game ->
val reveals = game.split(";").map {
val reds = "(\\d+) red".toRegex().find(it)?.groupValues?.get(1)?.toInt() ?: 0
val greens = "(\\d+) green".toRegex().find(it)?.groupValu... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 1,840 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | SeanDijk | 575,314,390 | false | {"Kotlin": 29164} | enum class Tool(val score: Int) {
ROCK(1), PAPER(2), SCISSORS(3)
}
enum class MatchResult(val score: Int) {
WIN(6), DRAW(3), LOSS(0)
}
data class Line(val abc: Char, val xyz: Char)
val WIN_TABLE = mapOf(
// x wins against y
Tool.ROCK to Tool.SCISSORS,
Tool.PAPER to Tool.ROCK,
Tool.SCISSORS to T... | 0 | Kotlin | 0 | 0 | 363747c25efb002fe118e362fb0c7fecb02e3708 | 2,125 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | import kotlin.math.abs
fun main() {
data class Point(val x: Int, val y: Int)
fun distance(sx: Int, sy: Int, bx: Int, by: Int): Int = abs(sx - bx) + abs(sy - by)
fun pairs(input: List<String>) = input.map { line ->
val sx = line
.substringBefore(":")
.substringAfter("x=")
... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 3,099 | aoc-2022-in-kotlin | Apache License 2.0 |
src/year2023/Day8.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2023
import readLines
fun main() {
val input = parseInput(readLines("2023", "day8"))
val testInputPart1 = parseInput(readLines("2023", "day8_test1"))
val testInputPart2 = parseInput(readLines("2023", "day8_test2"))
check(part1(testInputPart1) == 2)
println("Part 1:" + part1(input))
... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 2,581 | advent_of_code | MIT License |
src/Day05.kt | semanticer | 577,822,514 | false | {"Kotlin": 9812} | fun main() {
fun part1(input: List<String>): String {
val crateMover9000: CrateMover = { move ->
val from: ArrayDeque<Char> = this[move.from - 1]
val to = this[move.to - 1]
repeat(move.quantity) {
val movingPiece = from.last()
from.removeLa... | 0 | Kotlin | 0 | 0 | 9013cb13f0489a5c77d4392f284191cceed75b92 | 2,350 | Kotlin-Advent-of-Code-2022 | Apache License 2.0 |
src/day14/Day14.kt | davidcurrie | 579,636,994 | false | {"Kotlin": 52697} | package day14
import java.io.File
import kotlin.math.max
import kotlin.math.min
fun main() {
val rocks = File("src/day14/input.txt").readLines().map { line ->
Rock(line.split(" -> ").map { coord -> coord.split(",").let { Pair(it[0].toInt(), it[1].toInt()) } })
}
println(solve(rocks, false))
p... | 0 | Kotlin | 0 | 0 | 0e0cae3b9a97c6019c219563621b43b0eb0fc9db | 2,416 | advent-of-code-2022 | MIT License |
src/Day02.kt | jdappel | 575,879,747 | false | {"Kotlin": 10062} | enum class Values(val pts: Int) {
ROCK(1), PAPER(2), SCISSORS(3)
}
val resultMap: Map<String, Map<String, Int>> = mapOf(
"A" to mapOf("X" to 3, "Y" to 6, "Z" to 0),
"B" to mapOf("X" to 0, "Y" to 3, "Z" to 6),
"C" to mapOf("X" to 6, "Y" to 0, "Z" to 3)
)
val reverseMap = mapOf("X" to Values.ROCK, "Y" to... | 0 | Kotlin | 0 | 0 | ddcf4f0be47ccbe4409605b37f43534125ee859d | 1,329 | AdventOfCodeKotlin | Apache License 2.0 |
src/Day16.kt | ked4ma | 573,017,240 | false | {"Kotlin": 51348} | import kotlin.math.ceil
/**
* [Day16](https://adventofcode.com/2022/day/16)
*/
private class Day16 {
data class Node(val key: String, val rate: Int) {
val valves = mutableListOf<String>()
}
data class Snapshot(val keys: List<String>, val estimate: Int, val opened: Set<String>, val time: Int)
}
... | 1 | Kotlin | 0 | 0 | 6d4794d75b33c4ca7e83e45a85823e828c833c62 | 3,536 | aoc-in-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-17.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2015
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2015, "17-input")
val test1 = readInputLines(2015, "17-test1")
println("Part1:")
part1(test1, 25).println()
... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,523 | advent-of-code | MIT License |
src/Day04.kt | makobernal | 573,037,099 | false | {"Kotlin": 16467} | fun main() {
fun parseToRange(z:String) : IntRange = z.substringBefore("-").toInt()..z.substringAfter("-").toInt()
fun isEitherRangeContainingTheOther(ranges: Pair<IntRange, IntRange>): Boolean =
ranges.first.toList().containsAll(ranges.second.toList()) ||
ranges.second.toList().contai... | 0 | Kotlin | 0 | 0 | 63841809f7932901e97465b2dcceb7cec10773b9 | 1,695 | kotlin-advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | martintomac | 726,272,603 | false | {"Kotlin": 19489} | import kotlin.math.pow
data class Scratchcard(
val id: Int,
val winningNumbers: Set<Int>,
val myNumbers: Set<Int>,
)
val Scratchcard.winCount: Int get() = myNumbers.count { it in winningNumbers }
fun main() {
fun parseScratchcard(line: String): Scratchcard {
val (_, cardNumber, winningNumsP... | 0 | Kotlin | 0 | 0 | dc97b23f8461ceb9eb5a53d33986fb1e26469964 | 2,086 | advent-of-code-2023 | Apache License 2.0 |
src/Day05.kt | epishkin | 572,788,077 | false | {"Kotlin": 6572} | fun main() {
fun parseInput(input: List<String>): Pair<MutableList<MutableList<Char>>, List<CraneCommand>> {
val (first, last) = input.partition { !it.startsWith("move") }
val stackCount = first
.first { it.isNotEmpty() && !it.contains("[") }
.split(" ")
.filter ... | 0 | Kotlin | 0 | 0 | e5e5755c2d77f75750bde01ec5aad70652ef4dbf | 2,281 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | fun main(){
fun List<Int>.isAdjacent(other: List<Int>):Boolean{
val diff = this.mapIndexed { index, i -> kotlin.math.abs(this[index] - other[index]) }.toList()
return (diff.count{it==0} == 2)&&(diff.count{it==1} == 1)
}
fun part1(input: List<String>){
val cubes = input.map { it.sp... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 4,307 | aoc22 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day06.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import multiplyOf
import readInput
private data class Race(val time: Long, val recordDistance: Long) {
companion object {
fun fromStrings(input: List<String>): List<Race> {
val times =
input.first().replace("Time: ", "").split("\\s+".toRegex()).filter { it.isNot... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 1,757 | adventOfCode | Apache License 2.0 |
src/Day09.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | import kotlin.math.absoluteValue
import kotlin.math.sign
fun main() {
fun solveForTailLength(tailLength: Int, input: List<String>): Int {
val tail = List(tailLength) { origin }
return input.asSequence()
.flatMap { it.toMoves() }
.fold(KnotState(origin, tail)) { state, move ... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 2,017 | aoc-2022 | Apache License 2.0 |
src/main/Day12.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day12
import geometry.Direction
import geometry.Position
import geometry.move
import utils.characterPositions
import utils.readInput
import java.util.*
typealias Height = UByte
data class HeightMap(
private val heights: Map<Position, Height>,
private val start: Position,
private val target: Posit... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 2,422 | aoc-2022 | Apache License 2.0 |
y2022/src/main/kotlin/adventofcode/y2022/Day19.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
import kotlin.math.ceil
object Day19 : AdventSolution(2022, 19, "Not Enough Minerals") {
override fun solvePartOne(input: String) = parse(input)
.map { bp -> solveWithBlueprint(bp, 24) }
.sumOf { (i, v) -> i * v }
override fun ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 5,350 | advent-of-code | MIT License |
src/Day05.kt | rod41732 | 572,917,438 | false | {"Kotlin": 85344} | typealias Stack = MutableList<Char>
fun main() {
val lines = readInput("Day05")
fun part1(lines: List<String>): String {
val (stacks, operations) = parseInput(lines)
operations.forEach { (num, src, dst) ->
repeat(num) { stacks[dst].add(stacks[src].removeLast()) }
}
... | 0 | Kotlin | 0 | 0 | 1d2d3d00e90b222085e0989d2b19e6164dfdb1ce | 2,212 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day16.kt | akijowski | 574,262,746 | false | {"Kotlin": 56887, "Shell": 101} | data class Valve(val flow: Int, val next: List<String>)
data class Path(val valves: List<Valve>, val opened: Map<Valve, Int>) {
fun total(): Int = opened.map { (v, t) -> (30 - t) * v.flow }.sum()
}
fun main() {
val fre = """^Valve (\w+) has flow rate=(\d+)$""".toRegex()
val lre = """^[a-z\s]+([A-Z,\s]+)$... | 0 | Kotlin | 1 | 0 | 84d86a4bbaee40de72243c25b57e8eaf1d88e6d1 | 3,049 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/io/github/aarjavp/aoc/day05/Day05.kt | AarjavP | 433,672,017 | false | {"Kotlin": 73104} | package io.github.aarjavp.aoc.day05
import io.github.aarjavp.aoc.readFromClasspath
infix fun Int.towards(end: Int): IntProgression {
val step = if (this > end) -1 else 1
return IntProgression.fromClosedRange(this, end, step)
}
class Day05 {
data class Point(val x: Int, val y: Int)
data class Line(val... | 0 | Kotlin | 0 | 0 | 3f5908fa4991f9b21bb7e3428a359b218fad2a35 | 2,740 | advent-of-code-2021 | MIT License |
src/Day09.kt | cagriyildirimR | 572,811,424 | false | {"Kotlin": 34697} | import kotlin.math.abs
fun day09Part1() {
val input = readInput("Day09")
var Head = Pair(0, 0)
var Tail = Pair(0, 0)
val visited = mutableSetOf<Pair<Int, Int>>()
for (i in input) {
val m = i.split(" ")
var c = m.last().toInt()
val dir = m.first()
while (c > 0) {
... | 0 | Kotlin | 0 | 0 | 343efa0fb8ee76b7b2530269bd986e6171d8bb68 | 2,187 | AoC | Apache License 2.0 |
src/aoc2022/Day08.kt | NoMoor | 571,730,615 | false | {"Kotlin": 101800} | package aoc2022
import utils.*
internal class Day08(lines: List<String>) {
private val grid: List<List<Int>>
init {
lines.forEach { println(it) }
grid = lines.map { it.map { it.digitToInt() } }
}
fun part1(): Any {
return grid.indices.sumOf { r ->
grid[r].indices.count { c ->
isV... | 0 | Kotlin | 1 | 2 | d561db73c98d2d82e7e4bc6ef35b599f98b3e333 | 2,088 | aoc2022 | Apache License 2.0 |
src/main/kotlin/Day14.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | import kotlin.math.abs
import kotlin.math.sign
fun main() {
fun part1(input: Set<Point>): Int {
val units = mutableSetOf<Point>()
val start = Point(500, 0)
val last = input.maxOf { it.y }
var current = start
while (current.y != last) {
current = current.move(in... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 1,904 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/year2022/day02/Day02.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2022.day02
import check
import readInput
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("2022", "Day02_test")
check(part1(testInput), 15)
check(part2(testInput), 12)
val input = readInput("2022", "Day02")
println(part1(i... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,919 | AdventOfCode | Apache License 2.0 |
tree_data_structure/WordLadder/kotlin/Solution.kt | YaroslavHavrylovych | 78,222,218 | false | {"Java": 284373, "Kotlin": 35978, "Shell": 2994} | import java.util.LinkedList
/**
* 127. Word Ladder.
* <br/>
* Given two words (beginWord and endWord), and a dictionary's word list,
* find the length of shortest transformation sequence
* from beginWord to endWord, such that:
* Only one letter can be changed at a time.
* Each transformed word must exis... | 0 | Java | 0 | 2 | cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd | 2,858 | codility | MIT License |
src/Day12.kt | WilsonSunBritten | 572,338,927 | false | {"Kotlin": 40606} | fun Position2.neighbors(maxRow: Int, maxColumn: Int, elevationMap: List<List<Int>>): Set<Position2> {
return setOf(
// up a position
Position2((this.row - 1).coerceAtLeast(0), this.column),
// down a position
Position2((this.row + 1).coerceAtMost(maxRow), this.column),
// lef... | 0 | Kotlin | 0 | 0 | 363252ffd64c6dbdbef7fd847518b642ec47afb8 | 4,530 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2023/Day05.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2023
import AoCDay
import kotlin.math.max
import kotlin.math.min
// https://adventofcode.com/2023/day/5
object Day05 : AoCDay<Long>(
title = "If You Give A Seed A Fertilizer",
part1ExampleAnswer = 35,
part1Answer = 218513636,
part2ExampleAnswer = 46,
part2Answer = 81956384,
) {
priv... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,318 | advent-of-code-kotlin | MIT License |
src/day10/Day10.kt | maxmil | 578,287,889 | false | {"Kotlin": 32792} | package day10
import println
import readInput
val brackets = mapOf(Pair('(', ')'), Pair('[', ']'), Pair('{', '}'), Pair('<', '>'))
val scores: Map<Char, Int> = mapOf(Pair(')', 3), Pair(']', 57), Pair('}', 1197), Pair('>', 25137))
val autoCompleteScore: Map<Char, Int> = scores.mapValues { scores.keys.indexOf(it.key) +... | 0 | Kotlin | 0 | 0 | 246353788b1259ba11321d2b8079c044af2e211a | 1,331 | advent-of-code-2021 | Apache License 2.0 |
src/Day13.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | fun main() {
val testInput = readInput("Day13_test")
check(part1(testInput) == 13)
check(part2(testInput) == 140)
val input = readInput("Day13")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
return input.windowed(size = 2, step = 3)
.ma... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 3,299 | AOC2022 | Apache License 2.0 |
y2021/src/main/kotlin/adventofcode/y2021/Day14.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
object Day14 : AdventSolution(2021, 14, "Extended Polymerization") {
override fun solvePartOne(input: String): Int {
val (initial, rules) = parse(input)
fun step(str: String) = str.windowed(2).joinToString("") { s -> s[0] + rules[s... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,610 | advent-of-code | MIT License |
src/Day08.kt | Fedannie | 572,872,414 | false | {"Kotlin": 64631} | fun main() {
fun parseInput(input: List<String>): List<List<Int>> = input.map { it.toCharArray().toList().map { it.toString().toInt() } }
fun List<List<Int>>.up(i: Int, j: Int) = map { it[j] }.subList(0, i)
fun List<List<Int>>.down(i: Int, j: Int) = map { it[j] }.subList(i + 1, size)
fun List<List<Int>>.left(i... | 0 | Kotlin | 0 | 0 | 1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f | 1,853 | Advent-of-Code-2022-in-Kotlin | Apache License 2.0 |
src/Day14.kt | RusticFlare | 575,453,997 | false | {"Kotlin": 4655} | fun main() {
fun part1(input: List<String>): Long {
return input.size.toLong()
}
fun part2(input: String): Long {
val (initial, transforms) = input.split("\n\n")
val mappings = transforms.lines().associate { (it[0] to it[1]) to ((it[0] to it[6]) to (it[6] to it[1])) }
fun M... | 0 | Kotlin | 0 | 0 | 6ad85c80f771be683517fab804e9a933a90d5b41 | 1,629 | advent-of-code-kotlin-2021 | Apache License 2.0 |
y2015/src/main/kotlin/adventofcode/y2015/Day21.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2015
import adventofcode.io.AdventSolution
object Day21 : AdventSolution(2015, 21, "RPG Simulator 20XX") {
override fun solvePartOne(input: String): Int {
val bossMonster = parseInput(input)
return itemSets()
.first { equipment -> defeats(Character(100, equipmen... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,416 | advent-of-code | MIT License |
src/Day04.kt | dustinlewis | 572,792,391 | false | {"Kotlin": 29162} | fun main() {
fun part1_original(input: List<String>): Int {
val assignments = input.map { assignmentString ->
val (firstStart, firstEnd, secondStart, secondEnd) =
assignmentString.split(*"-,".toCharArray()).map { it.toInt() }
listOf(
Pair(firstStart, f... | 0 | Kotlin | 0 | 0 | c8d1c9f374c2013c49b449f41c7ee60c64ef6cff | 1,733 | aoc-2022-in-kotlin | Apache License 2.0 |
src/year2023/day19/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day19
import java.util.LinkedList
import java.util.Queue
import year2023.solveIt
fun main() {
val day = "19"
val expectedTest1 = 19114L
val expectedTest2 = 167409079868000L
fun toRuleFunction(line: String): Pair<String, List<(Map<Char, Long>) -> String?>> {
val (name, rules... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 3,939 | adventOfCode | Apache License 2.0 |
src/Day15.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | import kotlin.math.abs
fun main() {
data class Coordinate(val x: Int, val y: Int)
fun Coordinate.distanceTo(other: Coordinate): Int = abs(x - other.x) + abs(y - other.y)
data class Reading(val sensorPosition: Coordinate, val beaconPosition: Coordinate) {
val distance = sensorPosition.distanceTo(b... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 2,497 | advent-of-code-22 | Apache License 2.0 |
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day11.kt | MichalChomo | 572,214,942 | false | {"Kotlin": 56758} | package eu.michalchomo.adventofcode.year2022
data class Monkey(
private val items: MutableList<Long>,
private val operation: (Long) -> Long,
private val modulus: Long,
private val monkeyIfTrue: Int,
private val monkeyIfFalse: Int
) {
var itemsInspected: Long = 0
fun turn(monkeys: List<Mo... | 0 | Kotlin | 0 | 0 | a95d478aee72034321fdf37930722c23b246dd6b | 2,847 | advent-of-code | Apache License 2.0 |
src/Day02.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | enum class Rps(val score: Int) {
Rock(1), Paper(2), Scissors(3)
}
fun main() {
val theirRps = mapOf("A" to Rps.Rock, "B" to Rps.Paper, "C" to Rps.Scissors)
val mineRps = mapOf("X" to Rps.Rock, "Y" to Rps.Paper, "Z" to Rps.Scissors)
val dominators =
mapOf(Rps.Rock to Rps.Scissors, Rps.Paper to R... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 1,554 | AdventOfCode2022 | Apache License 2.0 |
src/Day11.kt | floblaf | 572,892,347 | false | {"Kotlin": 28107} | fun main() {
data class Test(val division: Long, val targetSuccess: Int, val targetFail: Int) {
fun run(x: Long): Int {
return if (x % division == 0L) targetSuccess else targetFail
}
}
data class Monkey(
val items: MutableList<Long> = mutableListOf(),
val operati... | 0 | Kotlin | 0 | 0 | a541b14e8cb401390ebdf575a057e19c6caa7c2a | 2,558 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day13/Day13.kt | qnox | 575,581,183 | false | {"Kotlin": 66677} | package day13
import readInput
fun main() {
fun parseList(str: String, p: Int): Pair<List<Any>, Int> {
val result = mutableListOf<Any>()
var cur = p
check(str[cur] == '[')
cur += 1
while (str[cur] != ']') {
if (str[cur] == ',') {
cur += 1
... | 0 | Kotlin | 0 | 0 | 727ca335d32000c3de2b750d23248a1364ba03e4 | 2,414 | aoc2022 | Apache License 2.0 |
src/Day11.kt | Fedannie | 572,872,414 | false | {"Kotlin": 64631} | fun main() {
class Algorithm(val divisibleBy: Int, val ifTrue: Int, val ifFalse: Int) {
fun next(x: Long): Int = if (x % divisibleBy == 0L) ifTrue else ifFalse
}
class Monkey(items: Collection<Long>, val operation: (Long) -> Long, val algorithm: Algorithm) {
val items = MutableList(0) { 0L }
var insp... | 0 | Kotlin | 0 | 0 | 1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f | 2,521 | Advent-of-Code-2022-in-Kotlin | Apache License 2.0 |
src/day23/Day23.kt | davidcurrie | 579,636,994 | false | {"Kotlin": 52697} | package day23
import java.io.File
import java.util.*
import kotlin.math.max
import kotlin.math.min
fun main() {
var elves = File("src/day23/input.txt").readLines().mapIndexed { row, line ->
line.toList().mapIndexed { column, char ->
if (char == '#') Pair(column, row) else null
}.filte... | 0 | Kotlin | 0 | 0 | 0e0cae3b9a97c6019c219563621b43b0eb0fc9db | 2,623 | advent-of-code-2022 | MIT License |
src/Day13.kt | jbotuck | 573,028,687 | false | {"Kotlin": 42401} | fun main() {
val lines = readInput("Day13")
//part 1
lines.asSequence()
.chunked(3)
.map { it.take(2) }
.withIndex().map { it.copy(index = it.index.inc()) }
.filter { isValid(it.value) }
.sumOf { it.index }
.let { println(it) }
//part 2
val dividers =... | 0 | Kotlin | 0 | 0 | d5adefbcc04f37950143f384ff0efcd0bbb0d051 | 3,072 | aoc2022 | Apache License 2.0 |
dcp_kotlin/src/main/kotlin/dcp/day313/day313.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day313
import java.util.LinkedList
import java.util.Queue
import kotlin.math.max
/**
* We formulate the problem as a shortest path over a simple graph.
* For every one of the 1000 permissible states, we have a vertex, with edges between vertices if they differ by
* 1 in one place, e.g. 123 is adjacent ... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 3,339 | daily-coding-problem | MIT License |
src/Day12.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | // https://adventofcode.com/2022/day/12
fun main() {
fun shortestPathLength(
grid: ElevationGrid,
sourceCell: Cell,
isDestination: (Cell) -> Boolean,
canReachToCell: (Cell, Cell) -> Boolean
): Int {
val queue = ArrayDeque<Cell>()
val visited = HashSet<Cell>()
... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 3,091 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/day8.kt | Arch-vile | 572,557,390 | false | {"Kotlin": 132454} | package day8
import aoc.utils.*
fun part1(): Int {
val input = readInput("day8-input.txt")
.map { it.toList().map { it.toInt() } }
val matrix = Matrix(input)
return matrix.allInColumnOrder()
.filter {
val lineUp = matrix.trace(it.cursor) { p -> Cursor(p.x, p.y - 1) }
... | 0 | Kotlin | 0 | 0 | e737bf3112e97b2221403fef6f77e994f331b7e9 | 2,054 | adventOfCode2022 | Apache License 2.0 |
workshops/moscow_prefinals2020/day3/l.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package workshops.moscow_prefinals2020.day3
private fun solve() {
val a = mutableMapOf<Int, MutableMap<Int, Int>>()
var ans = 0
repeat(readInt()) {
val (s, vIn) = readStrings()
val v = vIn.toInt()
if (v <= 0) return@repeat
val hashing = Hashing(s)
var maxSeen = 0
for (len in a.keys) if (len < s.length) ... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,365 | competitions | The Unlicense |
src/day4/Day04.kt | blundell | 572,916,256 | false | {"Kotlin": 38491} | package day4
import readInput
fun main() {
fun IntRange.contains(other: IntRange): Boolean {
return this.first >= other.first && this.last <= other.last
}
fun IntRange.overlaps(other: IntRange): Boolean {
return this.first >= other.first && this.first <= other.last
|| this... | 0 | Kotlin | 0 | 0 | f41982912e3eb10b270061db1f7fe3dcc1931902 | 2,143 | kotlin-advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | MisterTeatime | 560,956,854 | false | {"Kotlin": 37980} | import java.math.BigInteger
fun main() {
fun part1(input: List<String>, y: Int): Int {
val beacons = mutableListOf<Point2D>()
val sensors = getSensors(input, beacons)
var covered = 0
// Die Grenzen der Ausdehnung bestimmen.
// Es kann kein Punkt jenseits der niedrigsten X-... | 0 | Kotlin | 0 | 0 | 8ba0c36992921e1623d9b2ed3585c8eb8d88718e | 2,962 | AoC2022 | Apache License 2.0 |
src/year2022/18/Day18.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`18`
import java.util.LinkedList
import readInput
/**
* Data Class Representing Cube of 1x1x1 in 3D Grid
*/
data class Cube(
val x: Int,
val y: Int,
val z: Int
) {
fun inRange(range: IntRange): Boolean {
return x in range && y in range && z in range
}
}
/**
* Parse inp... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 2,524 | KotlinAdventOfCode | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day16.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
class Day16 {
private val pattern = """Valve (\S+) has flow rate=(\d+); tunnels? leads? to valves? (.+)""".toRegex()
private val flows = mutableMapOf<String, Int>()
private val dists: Map<String, Map<St... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 3,022 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/Day19.kt | AlaricLightin | 572,897,551 | false | {"Kotlin": 87366} | fun main() {
fun part1(blueprints: List<RobotBlueprint>): Int {
return blueprints.sumOf {
it.id * getMaxGeodes(it, 24)
}
}
fun part2(blueprints: List<RobotBlueprint>): Int {
return blueprints.fold(1) { acc, robotBlueprint ->
acc * getMaxGeodes(robotBlueprint,... | 0 | Kotlin | 0 | 0 | ee991f6932b038ce5e96739855df7807c6e06258 | 6,533 | AdventOfCode2022 | Apache License 2.0 |
src/Day07.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | import java.util.ArrayList
sealed interface Node {}
data class Directory(val name: String, val nodes: MutableList<Node>, val parent: Directory?, var size : Int) : Node
data class File(val name: String, val size: Int) : Node
fun main() {
fun calculate(directory: Directory): Int {
var size = 0
for... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 3,013 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/day13/Day13.kt | cyril265 | 433,772,262 | false | {"Kotlin": 39445, "Java": 4273} | package day13
import readToList
private val input = readToList("day13.txt")
fun main() {
println(part1())
println(part2())
}
private fun part1(): Int {
val (foldInstructions, dots) = mapInput()
val foldInstruction = foldInstructions.first()
dots.forEach { dot ->
dot.fold(foldInstruction)... | 0 | Kotlin | 0 | 0 | 1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b | 2,310 | aoc2021 | Apache License 2.0 |
src/Day15.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | import kotlin.math.abs
fun main() {
val testInput = readInput("Day15_test")
check(part1(testInput, rowToCheck = 10) == 26)
check(part2(testInput, maxY = 20) == 56000011L)
val input = readInput("Day15")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>, rowToC... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 2,200 | aoc-22 | Apache License 2.0 |
src/Day15.kt | mcrispim | 573,449,109 | false | {"Kotlin": 46488} | import kotlin.math.abs
data class PositionDay15(val x: Int, val y: Int)
class CaveDay15(input: List<String>) {
val area = mutableMapOf<PositionDay15, Char>()
val covertAreas = mutableMapOf<PositionDay15, Int>()
init {
input.forEach {
// Format = "Sensor at x=2, y=18: closest beacon is... | 0 | Kotlin | 0 | 0 | 5fcacc6316e1576a172a46ba5fc9f70bcb41f532 | 2,980 | AoC2022 | Apache License 2.0 |
src/Day07.kt | sabercon | 648,989,596 | false | null | fun main() {
fun parse(line: String): Pair<String, List<Pair<Int, String>>> {
val (outer, inner) = """([a-z ]+) bags contain ([0-9a-z, ]+)\.""".toRegex().destructureGroups(line)
val inners = inner.split(", ").mapNotNull {
if (it == "no other bags") return@mapNotNull null
val... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 1,339 | advent-of-code-2020 | MIT License |
src/Day05.kt | Xacalet | 576,909,107 | false | {"Kotlin": 18486} | /**
* ADVENT OF CODE 2022 (https://adventofcode.com/2022/)
*
* Solution to day 5 (https://adventofcode.com/2022/day/5)
*
*/
fun main() {
data class StackRearrangement(
val count: Int,
val fromIndex: Int,
val toIndex: Int,
)
fun part1(stacks: List<MutableList<String>>, rearra... | 0 | Kotlin | 0 | 0 | 5c9cb4650335e1852402c9cd1bf6f2ba96e197b2 | 2,299 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | fasfsfgs | 573,562,215 | false | {"Kotlin": 52546} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>, desiredY: Int): Int {
val report = input.toReport()
val scannedXAtY = report
.map { it.sensor }
.flatMap { it.xScannedAtY(desiredY) }
.distinct()
val xWithBeaconAtY = report
... | 0 | Kotlin | 0 | 0 | 17cfd7ff4c1c48295021213e5a53cf09607b7144 | 3,420 | advent-of-code-2022 | Apache License 2.0 |
src/year2023/day13/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2023.day13
import year2023.solveIt
fun main() {
val day = "13"
val expectedTest1 = 709L
val expectedTest2 = 1400L
fun getReflections(lines: List<String>): List<Int> {
val repeated = lines.zipWithNext().mapIndexedNotNull { index, pair -> if (pair.first == pair.second) index else ... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 3,093 | adventOfCode | Apache License 2.0 |
src/main/kotlin/net/navatwo/adventofcode2023/day2/Day2Solution.kt | Nava2 | 726,034,626 | false | {"Kotlin": 100705, "Python": 2640, "Shell": 28} | package net.navatwo.adventofcode2023.day2
import net.navatwo.adventofcode2023.framework.ComputedResult
import net.navatwo.adventofcode2023.framework.Solution
sealed class Day2Solution : Solution<List<Day2Solution.Game>> {
data object Part1 : Day2Solution() {
override fun solve(input: List<Game>): ComputedResult... | 0 | Kotlin | 0 | 0 | 4b45e663120ad7beabdd1a0f304023cc0b236255 | 2,999 | advent-of-code-2023 | MIT License |
src/Day02.kt | F-bh | 579,719,291 | false | {"Kotlin": 5785} | enum class Result (val points: Int) {
Win(6),
Draw(3),
Lose(0);
companion object {
fun parse(input: Char): Result {
return mapOf(
'X' to Lose,
'Y' to Draw,
'Z' to Win
)[input]!!
}
}
}
enum class Choice(val poin... | 0 | Kotlin | 0 | 0 | 19fa2db8842f166daf3aaffd201544658f41d9e0 | 2,195 | Christmas2022 | Apache License 2.0 |
y2015/src/main/kotlin/adventofcode/y2015/Day14.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2015
import adventofcode.io.AdventSolution
object Day14 : AdventSolution(2015, 14, "Reindeer Olympics") {
override fun solvePartOne(input: String) = parseInput(input)
.maxOfOrNull { it.raceFor(2503) }
override fun solvePartTwo(input: String) = parseInput(input).let { r ->
... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,561 | advent-of-code | MIT License |
src/Day08.kt | chbirmes | 572,675,727 | false | {"Kotlin": 32114} | fun main() {
fun part1(input: List<String>): Int {
val grid = parseGrid(input)
val rowScanResult = grid.indices
.fold(emptySet<Pair<Int, Int>>()) { acc, i -> acc + grid.scanRow(i) }
val columnScanResult = grid.first().indices
.fold(emptySet<Pair<Int, Int>>()) { acc... | 0 | Kotlin | 0 | 0 | db82954ee965238e19c9c917d5c278a274975f26 | 2,947 | aoc-2022 | Apache License 2.0 |
src/Day05.kt | cypressious | 572,916,585 | false | {"Kotlin": 40281} | fun main() {
class Coordinate(val x: Int, val y: Int)
fun List<Coordinate>.isHorizontal() = this[0].y == this[1].y
fun List<Coordinate>.isVertical() = this[0].x == this[1].x
fun sign(n: Int) = if (n > 0) 1 else -1
fun handle(input: List<String>, countDiagonal: Boolean): Int {
val lines = ... | 0 | Kotlin | 0 | 0 | 169fb9307a34b56c39578e3ee2cca038802bc046 | 2,259 | AdventOfCode2021 | Apache License 2.0 |
src/main/kotlin/day13.kt | Arch-vile | 572,557,390 | false | {"Kotlin": 132454} | package day13
import aoc.utils.*
fun part2() {
val result = readInput("day13-input.txt")
.plus("[[2]]")
.plus("[[6]]")
.filter { it != "" }
.map { readList(it) }
.sortedWith { a, b -> compareList(a, b) }
.reversed()
.mapIndexed { index, listing ->
... | 0 | Kotlin | 0 | 0 | e737bf3112e97b2221403fef6f77e994f331b7e9 | 4,171 | adventOfCode2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.