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/day5/Day5.kt | calvin-laurenson | 572,736,307 | false | {"Kotlin": 16407} | package day5
import readInput
fun main() {
fun parseCrateColumns(row: String): List<Char?> {
return row.chunked(4).map { if (it.isBlank()) null else it[1] }
}
fun parseCrateColumns(rows: List<String>): Map<Int, MutableList<Char>> {
return buildMap {
for (row in rows) {
... | 0 | Kotlin | 0 | 0 | 155cfe358908bbe2a554306d44d031707900e15a | 2,990 | aoc2022 | Apache License 2.0 |
src/Day21.kt | ambrosil | 572,667,754 | false | {"Kotlin": 70967} | fun main() {
data class Monkey(val name: String, val expr: String)
fun Monkey.evaluateExpr(map: MutableMap<String, Long>): Long? {
val parts = this.expr.split(" ")
if (parts.size == 1) {
return parts[0].toLong()
}
val name1 = parts.first()
val name2 = parts.... | 0 | Kotlin | 0 | 0 | ebaacfc65877bb5387ba6b43e748898c15b1b80a | 2,844 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/day3/Day3.kt | mortenberg80 | 574,042,993 | false | {"Kotlin": 50107} | package day3
class Day3 {
fun getOrganizer(filename: String): RucksackOrganizer {
val readLines = this::class.java.getResourceAsStream(filename).bufferedReader().readLines()
return RucksackOrganizer(readLines)
}
}
data class RucksackOrganizer(val input: List<String>) {
val rucksacks = inp... | 0 | Kotlin | 0 | 0 | b21978e145dae120621e54403b14b81663f93cd8 | 2,326 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/io/tree/SmallestSubtreeWithAllDeepestNodes.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.tree
import io.models.TreeNode
import io.utils.runTests
// https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/
class SmallestSubtreeWithAllDeepestNodes {
fun execute(root: TreeNode?): TreeNode? = when (root) {
null -> null
else -> {
var stack = listOf(Route(root))
... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 2,731 | coding | MIT License |
src/Day14.kt | buczebar | 572,864,830 | false | {"Kotlin": 39213} | import java.lang.Integer.max
import java.lang.Integer.min
private typealias Path = List<Position>
private typealias MutableMatrix<T> = MutableList<MutableList<T>>
private val Pair<Int, Int>.depth: Int
get() = second
private fun List<Path>.getMaxValue(selector: (Position) -> Int) =
flatten().maxOf { selector(... | 0 | Kotlin | 0 | 0 | cdb6fe3996ab8216e7a005e766490a2181cd4101 | 3,170 | advent-of-code | Apache License 2.0 |
src/Day05.kt | hoppjan | 573,053,610 | false | {"Kotlin": 9256} | fun main() {
val testLines = readInput("Day05_test")
val testResult1 = part1(testLines)
println("test part 1: $testResult1")
check(testResult1 == "CMZ")
val testResult2 = part2(testLines)
println("test part 2: $testResult2")
check(testResult2 == "MCD")
val lines = readInput("Day05")
... | 0 | Kotlin | 0 | 0 | f83564f50ced1658b811139498d7d64ae8a44f7e | 2,417 | advent-of-code-2022 | Apache License 2.0 |
src/Day23.kt | simonbirt | 574,137,905 | false | {"Kotlin": 45762} | fun main() {
Day23.printSolutionIfTest(110, 20)
}
object Day23 : Day<Int, Int>(23) {
override fun part1(lines: List<String>): Int {
val map = lines.flatMapIndexed { y: Int, s: String -> s.chunked(1).mapIndexed { x, v -> Pair(Point(x, y), v) } }
.toMap().toMutableMap()
(1..10).forEa... | 0 | Kotlin | 0 | 0 | 962eccac0ab5fc11c86396fc5427e9a30c7cd5fd | 2,549 | advent-of-code-2022 | Apache License 2.0 |
src/Day23.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | fun main() {
data class P(val x: Int, val y: Int) {
operator fun plus(p: P) = P(x + p.x, y + p.y)
}
class Move(val check: List<P>, val move: P, val bit: Int)
val n = P(0, -1)
val s = P(0, 1)
val w = P(-1, 0)
val e = P(1, 0)
val allDirections = listOf(
n, n + e, e, s + ... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 5,199 | AdventOfCode2022 | Apache License 2.0 |
src/day16/puzzle16.kt | brendencapps | 572,821,792 | false | {"Kotlin": 70597} | package day16
import Puzzle
import PuzzleInput
import java.io.File
import kotlin.math.max
fun day16Puzzle() {
Day16PuzzleSolution().solve(Day16PuzzleInput("inputs/day16/example.txt",1651))
Day16PuzzleSolution().solve(Day16PuzzleInput("inputs/day16/input.txt", 1862))
Day16Puzzle2Solution().solve(Day16Puzzl... | 0 | Kotlin | 0 | 0 | 00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3 | 8,734 | aoc_2022 | Apache License 2.0 |
src/main/kotlin/y2023/day03/Day03.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2023.day03
import Coord
import Coordinated
import Matrix
import MatrixUtils
import MatrixUtils.filterMatrixElement
import MatrixUtils.move
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
part2 = { part2() }
)
}
data class Field(
val digit: Int?,
val isPa... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 3,007 | AdventOfCode | MIT License |
src/main/kotlin/Day13.kt | vw-anton | 574,945,231 | false | {"Kotlin": 33295} | import com.beust.klaxon.JsonArray
import com.beust.klaxon.Parser
import java.lang.StringBuilder
fun main() {
fun part1(input: List<String>) {
val packets = input
.splitBy { it.isEmpty() }
.map { it.toPair() }
.map { parse(it.first) to parse(it.second) }
val sum ... | 0 | Kotlin | 0 | 0 | a823cb9e1677b6285bc47fcf44f523e1483a0143 | 2,576 | aoc2022 | The Unlicense |
src/Day02.kt | Flame239 | 570,094,570 | false | {"Kotlin": 60685} | private fun games(): List<RPS> = readInput("Day02").map { RPS(it[0] - 'A', it[2] - 'X') }
private fun games2(): List<RPS2> = readInput("Day02").map { RPS2(it[0] - 'A', it[2] - 'X') }
private fun part1(games: List<RPS>): Int {
return games.sumOf { it.gamePts() + it.shapePts() }
}
private fun part2(games: List<RPS2... | 0 | Kotlin | 0 | 0 | 27f3133e4cd24b33767e18777187f09e1ed3c214 | 729 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | enum class Shape {
ROCK, PAPER, SCISSORS
}
enum class Outcome {
LOSE, DRAW, WIN
}
fun main() {
val shapes = mapOf(
"A" to Shape.ROCK,
"B" to Shape.PAPER,
"C" to Shape.SCISSORS,
"X" to Shape.ROCK,
"Y" to Shape.PAPER,
"Z" to Shape.SCISSORS)
val shapesList ... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 3,158 | AoC2022 | Apache License 2.0 |
aoc2023/day12.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2023
import utils.InputRetrieval
fun main() {
Day12.execute()
}
private object Day12 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
private fun part1(input: List<SpringStatus>): Long = input
... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 2,970 | Advent-Of-Code | MIT License |
src/main/kotlin/aoc/year2021/Day05.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2021
import aoc.Puzzle
import kotlin.math.max
import kotlin.math.min
/**
* [Day 5 - Advent of Code 2021](https://adventofcode.com/2021/day/5)
*/
object Day05 : Puzzle<Int, Int> {
override fun solvePartOne(input: String): Int {
val map = hashMapOf<Pair<Int, Int>, Int>()
input.lin... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 1,782 | advent-of-code | Apache License 2.0 |
src/Day02.kt | timlam9 | 573,013,707 | false | {"Kotlin": 9410} | fun main() {
fun parseStrategyGuide(input: List<String>) = input.map { line ->
line.split(" ")
.run {
this[0].first() to this[1].first()
}
}
fun part1(input: List<String>): Int = parseStrategyGuide(input)
.fold(0) { totalScore, (elf, player) ->
... | 0 | Kotlin | 0 | 0 | 7971bea39439b363f230a44e252c7b9f05a9b764 | 2,278 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day8.kt | ueneid | 575,213,613 | false | null | import kotlin.math.max
class Day8(inputs: List<String>) {
private val treeGrid = parse(inputs)
private fun parse(inputs: List<String>): List<List<Int>> {
return inputs.map { it.toList().map { height -> height.digitToInt() } }
}
private fun isVisible(input: List<List<Int>>, i: Int, j: Int): Bo... | 0 | Kotlin | 0 | 0 | 743c0a7adadf2d4cae13a0e873a7df16ddd1577c | 1,804 | adventcode2022 | MIT License |
2023/src/main/kotlin/Day07.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | object Day07 {
private enum class HandType {
FIVE_OF_A_KIND,
FOUR_OF_A_KIND,
FULL_HOUSE,
THREE_OF_A_KIND,
TWO_PAIR,
ONE_PAIR,
HIGH_CARD;
}
private val cardStrengths = listOf(
'A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'
).withIndex().associate { it.value to i... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 3,030 | advent-of-code | MIT License |
src/main/kotlin/Day12.kt | ueneid | 575,213,613 | false | null | import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.collections.set
typealias Cell = Pair<Int, Int>
class Day12(inputs: List<String>) {
companion object {
private val offsets = listOf<Pair<Int, Int>>(
Pair(0, 1), Pair(0, -1), Pair(1, 0), Pair(-1, 0)
)
private ... | 0 | Kotlin | 0 | 0 | 743c0a7adadf2d4cae13a0e873a7df16ddd1577c | 2,854 | adventcode2022 | MIT License |
src/Day04.kt | muellerml | 573,601,715 | false | {"Kotlin": 14872} | fun main() {
fun part1(input: List<String>): Int {
return input.count { line ->
val (leftRange, rightRange) = line.split(",").map { Range(it) }
if (leftRange.total() > rightRange.total()) {
leftRange.max >= rightRange.max && leftRange.min <= rightRange.min
... | 0 | Kotlin | 0 | 0 | 028ae0751d041491009ed361962962a64f18e7ab | 1,350 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | mborromeo | 571,999,097 | false | {"Kotlin": 10600} | fun main() {
val pointsPerShape = mapOf(
"X" to 1,
"Y" to 2,
"Z" to 3
)
fun part1(input: List<String>): Int {
val pointsPerOutcome = mapOf(
"AX" to 3,
"BY" to 3,
"CZ" to 3,
"AY" to 6,
"BZ" to 6,
"CX" to ... | 0 | Kotlin | 0 | 0 | d01860ecaff005aaf8e1e4ba3777a325a84c557c | 1,406 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Day14.kt | VictorWinberg | 433,748,855 | false | {"Kotlin": 26228} | package days
class Day14 : Day(14) {
override fun partOne(): Any {
var input = inputTestString.split("\n\n")[0]
val commands = inputTestString.split("\n\n")[1].split("\n").map { Pair(it.split(" -> ")[0], it.split(" -> ")[1]) }.toMap()
(0 until 10).forEach {
input = input.zipWi... | 0 | Kotlin | 0 | 0 | d61c76eb431fa7b7b66be5b8549d4685a8dd86da | 1,914 | advent-of-code-kotlin | Creative Commons Zero v1.0 Universal |
src/day_03/Day03.kt | BrumelisMartins | 572,847,918 | false | {"Kotlin": 32376} | package day_03
import readInput
fun main() {
fun findPriorityItem(bag: Bag): String {
val listOfDuplicates = bag.firstCompartment.intersect(bag.secondCompartment.toSet())
return listOfDuplicates.first()
}
fun findPriorityItemFromMultipleBags(listOfBags: List<MessyBag>): String {
v... | 0 | Kotlin | 0 | 0 | 3391b6df8f61d72272f07b89819c5b1c21d7806f | 1,598 | aoc-2022 | Apache License 2.0 |
src/day3/Day03.kt | armanaaquib | 572,849,507 | false | {"Kotlin": 34114} | package day3
import readInput
fun main() {
fun parseInput(input: List<String>) = input.map {
val size = it.length
val compartment1 = it.slice(0 until (size / 2)).split("").slice(1..size / 2)
val compartment2 = it.slice(size / 2 until size).split("").slice(1..size / 2)
listOf(compar... | 0 | Kotlin | 0 | 0 | 47c41ceddacb17e28bdbb9449bfde5881fa851b7 | 1,892 | aoc-2022 | Apache License 2.0 |
y2020/src/main/kotlin/adventofcode/y2020/Day07.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2020
import adventofcode.io.AdventSolution
fun main() = Day07.solve()
object Day07 : AdventSolution(2020, 7, "Handy Haversacks")
{
override fun solvePartOne(input: String): Int
{
val containedBy: Map<String, List<String>> =
input.lineSequence()
.map(:... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,582 | advent-of-code | MIT License |
src/Day09.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | import kotlin.math.absoluteValue
import kotlin.math.max
enum class Direction {
U, D, L, R
}
typealias Position = Pair<Int, Int>
typealias Motion = Pair<Direction, Int>
fun Position.move(direction: Direction): Position =
when (direction) {
Direction.U -> first - 1 to second
Direction.D -> firs... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 2,145 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day13.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2023
import AoCDay
import util.illegalInput
// https://adventofcode.com/2023/day/13
object Day13 : AoCDay<Int>(
title = "Point of Incidence",
part1ExampleAnswer = 405,
part1Answer = 37718,
part2ExampleAnswer = 400,
part2Answer = 40995,
) {
private class Pattern(private val pattern: ... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 2,705 | advent-of-code-kotlin | MIT License |
2021/src/main/kotlin/day3_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Solution
import utils.startsWith
fun main() {
Day3.run()
}
object Day3 : Solution<IntGrid>() {
override val name = "day3"
override val parser = IntGrid.singleDigits
override fun part1(input: IntGrid): Int {
val gamma = (0 until input.width).map { index ->
getPop(in... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,714 | aoc_kotlin | MIT License |
src/Day03.kt | romainbsl | 572,718,344 | false | {"Kotlin": 17019} | fun main() {
fun part1(input: List<String>): Int = input.sumOf { Rucksack.fromBatch(it).score }
fun part2(input: List<String>): Int = input.chunked(3).sumOf { chunkOfThree: List<String> ->
val rucksackBatch = chunkOfThree.map { rucksack -> rucksack.map { Item.fromChar(it) }.toSet() }
rucksackBa... | 0 | Kotlin | 0 | 0 | b72036968769fc67c222a66b97a11abfd610f6ce | 1,536 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | Miguel1235 | 726,260,839 | false | {"Kotlin": 21105} | private fun findCords(r: Int, c: Int, engine: List<List<Char>>): Map<String, Char?> {
return mapOf(
"bottom" to engine.getOrNull(r + 1)?.getOrNull(c),
"top" to engine.getOrNull(r - 1)?.getOrNull(c),
"left" to engine.getOrNull(r)?.getOrNull(c - 1),
"leftBottom" to engine.getOrNull(r +... | 0 | Kotlin | 0 | 0 | 69a80acdc8d7ba072e4789044ec2d84f84500e00 | 3,423 | advent-of-code-2023 | MIT License |
day12/src/Day12.kt | simonrules | 491,302,880 | false | {"Kotlin": 68645} | import java.io.File
class Day12(private val path: String) {
private val connection = mutableMapOf<String, MutableSet<String>>()
private val paths = mutableListOf<List<String>>()
init {
File(path).forEachLine {
val parts = it.split("-")
if (parts[0] != "end" && parts[1] != "... | 0 | Kotlin | 0 | 0 | d9e4ae66e546f174bcf66b8bf3e7145bfab2f498 | 3,547 | aoc2021 | Apache License 2.0 |
src/y2021/d06/Day06.kt | AndreaHu3299 | 725,905,780 | false | {"Kotlin": 31452} | package y2021.d03
import println
import readInput
fun main() {
val classPath = "y2021/d06"
fun part1(input: List<String>, days: Int): Int {
var fishes = input[0].split(",").map { it.toInt() }
var nextFishes: List<Int>
for (i in 1..days) {
nextFishes = fishes.map { if (it... | 0 | Kotlin | 0 | 0 | f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e | 1,833 | aoc | Apache License 2.0 |
src/main/kotlin/day3/Day3.kt | cyril265 | 433,772,262 | false | {"Kotlin": 39445, "Java": 4273} | package day3
import readToList
import kotlin.reflect.KFunction2
private val input = readToList("day3.txt")
.map { it.toCharArray() }.toTypedArray()
fun main() {
println(part1())
println(part2())
}
fun part1(): Int {
val transposed = transpose(input)
val gammaBits = transposed.map { column ->
... | 0 | Kotlin | 0 | 0 | 1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b | 1,841 | aoc2021 | Apache License 2.0 |
src/main/kotlin/_2022/Day7.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2022
import REGEX_LINE_SEPARATOR
import REGEX_WHITESPACE
import aoc
import format
fun main() {
aoc(2022, 7) {
aocRun { input ->
process(input).values.filter { it.size <= 100000 }.sumOf { it.size }
}
aocRun { input ->
val dirs = process(input)
val totalSize = dirs["/"]!!.size
val spac... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 2,231 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/day11/Day11.kt | commanderpepper | 574,647,779 | false | {"Kotlin": 44999} | package day11
import readInput
fun main (){
val day11Input = readInput("day11")
val monkeysListPartOne = parseInput(day11Input)
val monkeysListPartTwo = parseInput(day11Input)
println(monkeyBusiness(monkeys = monkeysListPartOne, rounds = 20, worryDivisor = 3L))
println(monkeyBusiness(monkeys = mon... | 0 | Kotlin | 0 | 0 | fef291c511408c1a6f34a24ed7070ceabc0894a1 | 5,134 | advent-of-code-kotlin-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/AoC_Day3.kt | sviams | 115,921,582 | false | null | object AoC_Day3 {
fun solvePt1(input: Int) : Int {
val bottomRights = (1..(Math.sqrt(input.toDouble()).toInt()+2)).filter { it % 2 != 0 }.map { it * it }.asReversed()
if (bottomRights.contains(input)) return (bottomRights.size-2)*2
val width = (bottomRights[0] - bottomRights[1]) / 4
... | 0 | Kotlin | 0 | 0 | 19a665bb469279b1e7138032a183937993021e36 | 1,957 | aoc17 | MIT License |
src/main/kotlin/aoc2022/Day18.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
import kotlin.math.abs
// https://adventofcode.com/2022/day/18
object Day18 : AoCDay<Int>(
title = "Boiling Boulders",
part1ExampleAnswer = 64,
part1Answer = 3396,
part2ExampleAnswer = 58,
part2Answer = 2044,
) {
private data class Cube(val x: Int, val y: Int, val... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,167 | advent-of-code-kotlin | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-08.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2021, "08-input")
val test1 = readInputLines(2021, "08-test1")
println("Part1:")
part1(test1).println()
p... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 3,248 | advent-of-code | MIT License |
src/questions/KDiffPairs.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.shouldBe
/**
* Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
* A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:
* * `0 <= i < j < nums.length`
* * `ab... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,802 | algorithms | MIT License |
src/main/kotlin/advent/of/code/day11/Solution.kt | brunorene | 160,263,437 | false | null | package advent.of.code.day11
const val id = 5535
val squareResults = mutableMapOf<Pair<Int, Int>, Pair<Int, Int>>()
fun powerLevel(x: Int, y: Int) = (((((x + 10) * y + id) * (x + 10)) / 100) % 10) - 5
fun part1(): String {
val result = (1..298).map { x ->
(1..298).map { y ->
val power = (0..... | 0 | Kotlin | 0 | 0 | 0cb6814b91038a1ab99c276a33bf248157a88939 | 1,872 | advent_of_code_2018 | The Unlicense |
Advent-of-Code-2023/src/Day18.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | import kotlin.math.abs
private const val AOC_DAY = "Day18"
private const val TEST_FILE = "${AOC_DAY}_test"
private const val INPUT_FILE = AOC_DAY
private val directions = mapOf(
"U" to Position(-1, 0),
"D" to Position(1, 0),
"L" to Position(0, -1),
"R" to Position(0, 1)
)
private fun part1(input: Lis... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 2,577 | Advent-of-Code-2023 | Apache License 2.0 |
src/Day08.kt | thiyagu06 | 572,818,472 | false | {"Kotlin": 17748} | import aoc22.printIt
import java.io.File
fun main() {
fun parseInput(): List<List<Int>> {
return File("input.txt/day07.txt").readLines().map { row -> row.map { it.digitToInt() } }
}
fun star1(input: List<List<Int>>): Int {
return input.mapIndexed { rowNum, row ->
List(row.size... | 0 | Kotlin | 0 | 0 | 55a7acdd25f1a101be5547e15e6c1512481c4e21 | 2,207 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | hijst | 572,885,261 | false | {"Kotlin": 26466} | private typealias Commands = List<List<String>>
fun main() {
data class File(val name: String, val size: Long)
class Directory(val name: String, val parent: Directory?) {
val children: MutableList<Directory> = mutableListOf()
val files: MutableList<File> = mutableListOf()
var size: Long... | 0 | Kotlin | 0 | 0 | 2258fd315b8933642964c3ca4848c0658174a0a5 | 2,816 | AoC-2022 | Apache License 2.0 |
src/Day05.kt | georgiizorabov | 573,050,504 | false | {"Kotlin": 10501} |
fun main() {
fun readStacks(input: List<String>): List<List<Char>> {
val stacks =
input.takeWhile { it != "" }.map { it.toList().filterIndexed { index, _ -> index % 4 == 1 } }.dropLast(1)
val stacksConv: MutableList<MutableList<Char>> =
Array(stacks.maxBy { it.size }.size) {... | 0 | Kotlin | 0 | 0 | bf84e55fe052c9c5f3121c245a7ae7c18a70c699 | 2,239 | aoc2022 | Apache License 2.0 |
src/day15/Main.kt | nikwotton | 572,814,041 | false | {"Kotlin": 77320} | package day15
import java.io.File
import kotlin.math.abs
const val workingDir = "src/day15"
fun main() {
val sample = File("$workingDir/sample.txt")
val input1 = File("$workingDir/input_1.txt")
println("Step 1a: ${runStep1(sample, 10)}") // 26
println("Step 1b: ${runStep1(input1, 2000000)}") // 51473... | 0 | Kotlin | 0 | 0 | dee6a1c34bfe3530ae6a8417db85ac590af16909 | 3,972 | advent-of-code-2022 | Apache License 2.0 |
src/Day04/Day04.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import java.lang.IllegalStateException
fun main() {
fun prepare(input: List<String>): Pair<List<Int>, List<List<List<Int>>>> {
val fst = input[0].split(',').map { it.toInt() }
val snd = arrayListOf<List<List<Int>>>()
val res = input.slice(2 until input.size)
var remainder = arrayLis... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 2,709 | advent-of-code-2021 | Apache License 2.0 |
src/day20/first/Solution.kt | verwoerd | 224,986,977 | false | null | package day20.first
import tools.Coordinate
import tools.adjacentCoordinates
import tools.origin
import tools.priorityQueueOf
import tools.timeSolution
const val START = "AA"
const val END = "ZZ"
fun main() = timeSolution {
val (maze, portals) = parseMaze()
println(maze.findPath(portals))
}
private fun Maze.fin... | 0 | Kotlin | 0 | 0 | 554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7 | 2,369 | AoC2019 | MIT License |
src/Day02.kt | sk0g | 572,854,602 | false | {"Kotlin": 7597} | import Move.*
import RoundResult.*
fun parseInput(input: List<String>): List<List<Char>> {
return input
.map {
it.toCharArray()
.toList()
.filter { it != ' ' }
}
}
enum class Move { Rock, Paper, Scissors }
fun getRoundResult(opponentInput: Char, playerI... | 0 | Kotlin | 0 | 0 | cd7e0da85f71d40bc7e3761f16ecfdce8164dae6 | 2,287 | advent-of-code-22 | Apache License 2.0 |
src/day05/Day05Answer1.kt | IThinkIGottaGo | 572,833,474 | false | {"Kotlin": 72162} | package day05
import readInput
/**
* Answers from [Advent of Code 2022 Day 5 | Kotlin](https://youtu.be/lKq6r5Nt8Yo)
*/
fun main() {
val lines = readInput("day05")
val day05 = Day05()
// Calculate number of stacks needed
val numberOfStacks = day05.numberOfStacks(lines)
val stacks = List(numberO... | 0 | Kotlin | 0 | 0 | 967812138a7ee110a63e1950cae9a799166a6ba8 | 2,560 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | mkulak | 573,910,880 | false | {"Kotlin": 14860} | fun main() {
fun part1(input: List<String>): Long {
val root = Dir("/", null)
var currentDir = root
input.forEach { line ->
when {
line == "\$ cd .." -> currentDir = currentDir.parent!!
line == "\$ cd /" -> currentDir = root
line.st... | 0 | Kotlin | 0 | 0 | 3b4e9b32df24d8b379c60ddc3c007d4be3f17d28 | 2,828 | AdventOfKo2022 | Apache License 2.0 |
src/Day05.kt | manuel-martos | 574,260,226 | false | {"Kotlin": 7235} | import java.util.*
fun main() {
println("part01 -> ${solveDay05Part01()}")
println("part02 -> ${solveDay05Part02()}")
}
private fun solveDay05Part01(): String = solver(::applyMovements)
private fun solveDay05Part02(): String = solver(::applyMultipleMovements)
private fun solver(block: (Map<Int, LinkedList<C... | 0 | Kotlin | 0 | 0 | 5836682fe0cd88b4feb9091d416af183f7f70317 | 2,689 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | ked4ma | 573,017,240 | false | {"Kotlin": 51348} | import java.lang.RuntimeException
/**
* [Day02](https://adventofcode.com/2022/day/2)
*/
fun main() {
fun judge(self: Shape, opponent: Shape): Int = when {
self.winTo() == opponent -> 6
self == opponent -> 3
else -> 0
}
fun part1(input: List<String>): Int {
fun convToStrat... | 1 | Kotlin | 0 | 0 | 6d4794d75b33c4ca7e83e45a85823e828c833c62 | 2,179 | aoc-in-kotlin-2022 | Apache License 2.0 |
src/Day04.kt | meierjan | 572,860,548 | false | {"Kotlin": 20066} | import Interval.Companion.parseLine
data class Interval(
val from: Int, val to: Int,
) {
fun fullyContains(other: Interval) : Boolean {
return this.from <= other.from && this.to >= other.to
}
fun overlap(other: Interval) : Boolean {
return if(this.from <= other.from) {
thi... | 0 | Kotlin | 0 | 0 | a7e52209da6427bce8770cc7f458e8ee9548cc14 | 1,540 | advent-of-code-kotlin-2022 | Apache License 2.0 |
advent-of-code-2023/src/Day11.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | import lib.matrix.Matrix
import lib.matrix.Position
import kotlin.math.abs
private typealias SpaceImage = Matrix<Char>
private const val DAY = "Day11"
fun main() {
fun testInput() = readInput("${DAY}_test")
fun input() = readInput(DAY)
"Part 1" {
part1(testInput()) shouldBe 374
measureAn... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 2,380 | advent-of-code | Apache License 2.0 |
src/main/kotlin/dp/WeaklyInc.kt | yx-z | 106,589,674 | false | null | package dp
import util.get
import util.max
import util.set
// longest weakly increasing subsequence
// X[1..n] is weakly increasing if 2 * X[i] > X[i - 1] + X[i - 2], for all i > 2
// find the length of longest weakly increasing subsequence of A[1..n]
fun main(args: Array<String>) {
val A = intArrayOf(1, 2, 3, 3,... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,424 | AlgoKt | MIT License |
aoc-2023/src/main/kotlin/aoc/aoc25.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocParser.Companion.parselines
import aoc.*
import aoc.util.getDayInput
import aoc.util.pairwise
import aoc.util.second
import aoc.util.triples
val testInput = """
jqt: rhn xhk nvd
rsh: frs pzl lsr
xhk: hfx
cmg: qnr nvd lhk bvb
rhn: xhk bvb hfx
bvb: xhk hfx
pzl: lsr hfx nvd
qnr: nvd
ntq: jqt hfx bvb xhk
nvd... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 6,244 | advent-of-code | Apache License 2.0 |
src/day11/Day11.kt | TheJosean | 573,113,380 | false | {"Kotlin": 20611} | package day11
import readInput
import splitList
fun main() {
data class Monkey(
val id: Int,
var items: MutableList<Int>,
val divisibleBy: Int,
val onTrue: Int,
val onFalse: Int,
val operation: (value: Long) -> Long,
var inspects: Long = 0
)
fun pa... | 0 | Kotlin | 0 | 0 | 798d5e9b1ce446ba3bac86f70b7888335e1a242b | 2,719 | advent-of-code | Apache License 2.0 |
src/Day08/Day08.kt | brhliluk | 572,914,305 | false | {"Kotlin": 16006} | fun main() {
fun List<Int>.takeWhileInclusive(pred: (Int) -> Boolean): List<Int> {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = pred(it)
result
}
}
fun List<Int>.takeLastWhileInclusive(pred: (Int) -> B... | 0 | Kotlin | 0 | 0 | 96ac4fe0c021edaead8595336aad73ef2f1e0d06 | 2,830 | kotlin-aoc | Apache License 2.0 |
src/main/kotlin/twentytwentytwo/Day14.kt | JanGroot | 317,476,637 | false | {"Kotlin": 80906} | package twentytwentytwo
import twentytwentytwo.Structures.Point2d
fun main() {
val input = {}.javaClass.getResource("input-14.txt")!!.readText().linesFiltered { it.isNotEmpty() };
val day = Day14(input)
println(day.part1())
println(day.part2())
}
class Day14(val input: List<String>) {
private v... | 0 | Kotlin | 0 | 0 | 04a9531285e22cc81e6478dc89708bcf6407910b | 2,670 | aoc202xkotlin | The Unlicense |
src/day02/Day02.kt | gagandeep-io | 573,585,563 | false | {"Kotlin": 9775} | package day02
import readInput
fun main() {
fun part1(input: List<String>): Int {
fun scoreForShape(shape: Char): Int = shape - 'X' + 1
fun scoreForRound(theirShape: Char, myShape: Char): Int = when(theirShape to myShape) {
'B' to 'X', 'C' to 'Y', 'A' to 'Z' -> 0
'A' to 'X'... | 0 | Kotlin | 0 | 0 | 952887dd94ccc81c6a8763abade862e2d73ef924 | 1,834 | aoc-2022-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/year2023/Day02.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
fun main() {
val input = readInput("Day02")
Day02.part1(input).println()
Day02.part2(input).println()
}
object Day02 {
private val gameIdPattern = "(Game) (\\d+)".toRegex().toPattern()
private val greenPattern = "(\\d+) (green)".toRegex().toPattern()
private val bluePattern = ... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 2,660 | advent-of-code | MIT License |
src/Day03.kt | AndreiShilov | 572,661,317 | false | {"Kotlin": 25181} | fun main() {
fun intersectSum(intersect: Set<Char>) = intersect
.map { charInIntersect: Char -> charInIntersect.code }
.map { code ->
println("Code ${code}")
val i = when (code) {
in 97..122 -> code - 96
in 65..90 -> code - 64 + 26
... | 0 | Kotlin | 0 | 0 | 852b38ab236ddf0b40a531f7e0cdb402450ffb9a | 1,725 | aoc-2022 | Apache License 2.0 |
src/Day12.kt | jinie | 572,223,871 | false | {"Kotlin": 76283} | class Day12 {
fun part1(input:List<String>): Int = parseMap(input)
.let { (map, start, end) ->
findShortestPath(mutableListOf(map[start]!!), map, end)
}
fun part2(input:List<String>): Int = parseMap(input)
.let { (map, _, end) ->
map.values
.filt... | 0 | Kotlin | 0 | 0 | 4b994515004705505ac63152835249b4bc7b601a | 2,287 | aoc-22-kotlin | Apache License 2.0 |
2021/src/day06/Day06.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day06
import readInput
fun part1(lines: List<String>) : Int {
val fishes = lines.first().split(",").map{ it.toInt() }.toMutableList()
val iterations = 80
for (i in 1..iterations) {
var numberAdded = 0
for (idx in fishes.indices) {
when (fishes[idx]) {
... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,346 | advent-of-code | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2021/day14/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2021.day14
import com.kingsleyadio.adventofcode.util.readInput
private fun solution(template: String, map: Map<String, Char>, steps: Int): Long {
val mem = hashMapOf<String, Map<Char, Long>>()
fun memo(a: Char, b: Char, step: Int, func: (Char, Char, Int) -> Map<Char, Lon... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,605 | adventofcode | Apache License 2.0 |
src/Day05.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | private class Solution05(val input: List<String>) {
private val moves = ArrayList<Triple<Int, Int, Int>>()
private var stacks = ArrayList<ArrayDeque<Char>>()
fun init() {
val separatorIndex = input.indexOfFirst { it.isBlank() }
val numberOfStacks = input[separatorIndex - 1].split(" ").cou... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 1,980 | aoc-2022 | Apache License 2.0 |
src/aoc2023/Day05.kt | dayanruben | 433,250,590 | false | {"Kotlin": 79134} | package aoc2023
import checkValue
import readInputText
fun main() {
val (year, day) = "2023" to "Day05"
fun fillMap(group: String): Map<Range, Long> {
val map = mutableMapOf<Range, Long>()
group.split("\n").drop(1).forEach { line ->
val (destination, source, length) = line.split("... | 1 | Kotlin | 2 | 30 | df1f04b90e81fbb9078a30f528d52295689f7de7 | 3,811 | aoc-kotlin | Apache License 2.0 |
src/day13/Day13.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day13
import java.io.File
import kotlin.math.min
fun main() {
val data = parse("src/day13/Day13.txt")
println("🎄 Day 13 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)}")
}
private typealia... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 2,071 | advent-of-code-2023 | MIT License |
src/main/kotlin/com/adventofcode/Day05.kt | keeferrourke | 434,321,094 | false | {"Kotlin": 15727, "Shell": 1301} | package com.adventofcode
import kotlin.math.roundToInt
data class Point(val x: Int, val y: Int) : Comparable<Point> {
override fun compareTo(other: Point): Int {
val xeq = x.compareTo(other.x)
return if (xeq != 0) xeq else y.compareTo(other.y)
}
}
data class Line(val start: Point, val end: Point) {
val... | 0 | Kotlin | 0 | 0 | 44677c6ae0ba1a8a8dc80dfa68c17b9c315af8e2 | 1,978 | aoc2021 | ISC License |
y2018/src/main/kotlin/adventofcode/y2018/Day13.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2018
import adventofcode.io.AdventSolution
import adventofcode.y2018.Day13.Direction.*
object Day13 : AdventSolution(2018, 13, "Mine Cart Madness") {
override fun solvePartOne(input: String): String {
val (track, carts) = parse(input)
while (true) {
for (cart in... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,798 | advent-of-code | MIT License |
src/Day04.kt | atsvetkov | 572,711,515 | false | {"Kotlin": 10892} | data class Assignment(val left: Int, val right: Int) {
companion object {
fun parse(input: String) = Assignment(input.split('-')[0].toInt(), input.split('-')[1].toInt())
}
fun contains(other: Assignment) = this.left <= other.left && this.right >= other.right
fun overlapsWith(other: Assignment):... | 0 | Kotlin | 0 | 0 | 01c3bb6afd658a2e30f0aee549b9a3ac4da69a91 | 1,300 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | msernheim | 573,937,826 | false | {"Kotlin": 32820} | fun main() {
fun getPriority(item: Char): Int {
return when {
item.isLowerCase() -> item.code - 96
item.isUpperCase() -> item.code - 38
else -> 0
}
}
fun getDuplicates(head: String, tail: String): String {
return head.filter { item -> tail.contai... | 0 | Kotlin | 0 | 3 | 54cfa08a65cc039a45a51696e11b22e94293cc5b | 1,329 | AoC2022 | Apache License 2.0 |
src/Day04.kt | tigerxy | 575,114,927 | false | {"Kotlin": 21255} | fun main() {
fun part1(input: List<String>): Int =
input
.parse()
.map { it.fullyContainsOther() }
.sum()
fun part2(input: List<String>): Int =
input
.parse()
.map { it.overlapsOther() }
.sum()
val day = "04"
// test ... | 0 | Kotlin | 0 | 1 | d516a3b8516a37fbb261a551cffe44b939f81146 | 1,485 | aoc-2022-in-kotlin | Apache License 2.0 |
src/aoc2022/Day09.kt | nguyen-anthony | 572,781,123 | false | null | package aoc2022
import utils.readInputAsList
import kotlin.math.abs
import kotlin.math.sign
fun main() {
data class Point(val x: Int, val y: Int)
fun Point.isNear(other: Point) : Boolean {
return (x == other.x && y == other.y) ||
(x == other.x + 1 && y == other.y) ||
... | 0 | Kotlin | 0 | 0 | 9336088f904e92d801d95abeb53396a2ff01166f | 3,428 | AOC-2022-Kotlin | Apache License 2.0 |
src/Day05.kt | frango9000 | 573,098,370 | false | {"Kotlin": 73317} | fun main() {
val input = readInput("Day05")
println(Day05.part1(input))
println(Day05.part2(input))
}
data class Move(val size: Int, val from: Int, val to: Int)
class Day05 {
companion object {
fun part1(input: List<String>): String {
val (initial, rawActions) = input.partitionOn... | 0 | Kotlin | 0 | 0 | 62e91dd429554853564484d93575b607a2d137a3 | 2,820 | advent-of-code-22 | Apache License 2.0 |
src/day3/Day3.kt | jorgensta | 573,824,365 | false | {"Kotlin": 31676} | package day3
import readInput
fun main() {
val day = "day3"
val filename = "Day03"
val alfabeth_lowercase = "abcdefghijklmnopqrstuvwxyz".lowercase()
val alfabeth_uppercase = "abcdefghijklmnopqrstuvwxyz".uppercase()
fun getCompartments(line: String) =
Pair(line.slice(0 until line.length /... | 0 | Kotlin | 0 | 0 | 7243e32351a926c3a269f1e37c1689dfaf9484de | 1,811 | AoC2022 | Apache License 2.0 |
src/main/kotlin/com/ab/advent/day01/Puzzle.kt | battagliandrea | 574,137,910 | false | {"Kotlin": 27923} | package com.ab.advent.day01
import com.ab.advent.utils.readLines
/*
PART 01
The Elves take turns writing down the number of Calories contained by the various meals,
snacks, rations, etc. thatthey've brought with them, one item per line.
Each Elf separates their own inventory from the previous Elf's inventory (if any)... | 0 | Kotlin | 0 | 0 | cb66735eea19a5f37dcd4a31ae64f5b450975005 | 3,165 | Advent-of-Kotlin | Apache License 2.0 |
src/2022/Day09.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | package `2022`
import readInput
fun main() {
fun part1(input: List<String>): Int {
val uniqueTailPoints = mutableSetOf(Point(0, 0))
var head = Point(0, 0)
var tail = Point(0, 0)
input.forEach {
val (direction, steps) = it.split(" ")
repeat(steps.toInt()) {
... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 2,192 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | timj11dude | 572,900,585 | false | {"Kotlin": 15953} | fun main() {
fun setup(input: Collection<String>): Pair<Collection<String>, List<ArrayDeque<Char>>> {
val crateRegex = "\\[(\\w)\\]".toRegex()
return (input.dropWhile { it.isNotBlank() }.drop(1)) to (
input
.takeWhile { it.isNotBlank() }
.reve... | 0 | Kotlin | 0 | 0 | 28aa4518ea861bd1b60463b23def22e70b1ed481 | 2,833 | advent-of-code-2022 | Apache License 2.0 |
src/y2021/Day17.kt | Yg0R2 | 433,731,745 | false | null | package y2021
import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
val targetArea = input[0].getTargetArea()
var maxHeight = 0
for (x in 0 until targetArea.second.first) {
for (y in targetArea.second.second until targetArea.second.second * -1) {
... | 0 | Kotlin | 0 | 0 | d88df7529665b65617334d84b87762bd3ead1323 | 3,634 | advent-of-code | Apache License 2.0 |
src/Day02.kt | Derrick-Mwendwa | 573,947,669 | false | {"Kotlin": 8707} | fun main() {
fun part1(input: List<String>): Int {
// Assuming that we trust the input
fun scoreOfShape(shape: Char) = when (shape) {
'X' -> 1
'Y' -> 2
else -> 3
}
fun score(opponent: Char, player: Char) = when (opponent to player) {
'... | 0 | Kotlin | 0 | 1 | 7870800afa54c831c143b5cec84af97e079612a3 | 1,383 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day05.kt | ka1eka | 574,248,838 | false | {"Kotlin": 36739} | fun main() {
fun Sequence<String>.chunkedOnNull(): Sequence<List<String>> = sequence {
val buffer = mutableListOf<String>()
for (element in this@chunkedOnNull) {
if (element.isEmpty()) {
yield(buffer.toList())
buffer.clear()
} else {
... | 0 | Kotlin | 0 | 0 | 4f7893448db92a313c48693b64b3b2998c744f3b | 3,231 | advent-of-code-2022 | Apache License 2.0 |
2021/src/main/kotlin/day4_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Parser
import utils.Solution
fun main() {
Day4Func.run()
}
object Day4Func : Solution<Pair<List<Int>, List<IntGrid>>>() {
override val name = "day4"
override val parser = Parser.compoundList(Parser.ints, IntGrid.table)
override fun part1(input: Pair<List<Int>, List<IntGrid>>... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,401 | aoc_kotlin | MIT License |
src/main/kotlin/Day07.kt | ripla | 573,901,460 | false | {"Kotlin": 19599} | object Day7 {
data class Directory(
val name: String,
val parent: Directory?,
var directories: List<Directory> = emptyList(),
var files: List<File> = emptyList()
) {
fun getRoot(): Directory = parent?.getRoot() ?: this
fun size(): Int = files.sumOf { it.size } + ... | 0 | Kotlin | 0 | 0 | e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8 | 2,574 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day04.kt | casslabath | 573,177,204 | false | {"Kotlin": 27085} | fun main() {
fun rangesContained(firstRange: ClosedRange<Int>, secondRange: ClosedRange<Int>): Boolean {
if(
// The first pair is contained in the second
firstRange.start >= secondRange.start && firstRange.endInclusive <= secondRange.endInclusive
// The first pair is containe... | 0 | Kotlin | 0 | 0 | 5f7305e45f41a6893b6e12c8d92db7607723425e | 1,852 | KotlinAdvent2022 | Apache License 2.0 |
src/Day04.kt | BionicCa | 574,904,899 | false | {"Kotlin": 20039} | fun main() {
fun part1(input: List<String>): Int {
val pairs = input.map { it.split(",") }
var foundFullyContainedNumbers = 0
for ((first, second) in pairs) {
val rangeFirst = first.split("-").let { it[0].toInt()..it[1].toInt() }
val rangeSecond = second.split("-").l... | 0 | Kotlin | 0 | 0 | ed8bda8067386b6cd86ad9704bda5eac81bf0163 | 1,297 | AdventOfCode2022 | Apache License 2.0 |
src/Day02.kt | handrodev | 577,884,162 | false | {"Kotlin": 7670} | fun main() {
// A: Rock, B: Paper, C: Scissors
// A < B < C < A
val scoreMap = mapOf("A" to 1, "B" to 2, "C" to 3)
val XYZ2ABC = mapOf("X" to "A", "Y" to "B", "Z" to "C")
fun part1(input: List<String>): Int {
var score = 0
for (line in input) {
var (opponent, myPlayer) =... | 0 | Kotlin | 0 | 0 | d95aeb85b4baf46821981bb0ebbcdf959c506b44 | 2,008 | aoc-2022-in-kotlin | Apache License 2.0 |
src/y2015/Day18.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2015
import util.getNeighbors
import util.printMatrix
import util.readInput
object Day18 {
private fun parse(input: List<String>): List<List<Boolean>> {
return input.map { line ->
line.map { it == '#' }
}
}
fun part1(input: List<String>, steps: Int): Int {
var... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,161 | advent-of-code | Apache License 2.0 |
codeforces/globalround7/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.globalround7
private fun solve() {
val s = readLn()
var i = 0
while (i < s.length - 1 - i && s[i] == s[s.length - 1 - i]) i++
println(s.take(i) + solve(s.drop(i).dropLast(i)) + s.takeLast(i))
}
private fun solve(s: String): String {
val n = s.length
val h = Hashing(s + s.reversed())
for (i i... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,059 | competitions | The Unlicense |
src/main/kotlin/day09/Day09.kt | daniilsjb | 434,765,082 | false | {"Kotlin": 77544} | package day09
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day09/Day09.txt")
val answer1 = part1(data.toHeightmap())
val answer2 = part2(data.toHeightmap())
println("🎄 Day 09 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
print... | 0 | Kotlin | 0 | 1 | bcdd709899fd04ec09f5c96c4b9b197364758aea | 2,999 | advent-of-code-2021 | MIT License |
src/Day23.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | fun main() {
class Direction(var dirs: List<Vec2>)
class Elf(var pos: Vec2) {
var nextPos: Vec2? = null
}
class Result(val stableRound: Int, val freeCells: Int)
fun solve(input: List<String>, rounds: Int?): Result {
val elves = mutableListOf<Elf>()
for (i in input.indices)... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 2,484 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day15.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2021
import se.saidaspen.aoc.util.*
import java.util.*
fun main() = Day15.run()
object Day15 : Day(2021, 15) {
var map = toMap(input).mapValues { it.value.toString().toInt() }.toMutableMap()
override fun part1(): Any {
val start = P(0, 0)
val end = P(map.entries.... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 2,634 | adventofkotlin | MIT License |
src/main/kotlin/aoc/solutions/day2/Day2Solution.kt | KenVanHoeylandt | 112,967,846 | false | null | package aoc.solutions.day2
import aoc.Solution
class Day2Solution : Solution(2) {
override fun solvePartOne(input: String): String {
return splitStringLines(input)
.map(::getRowNumbers)
.map(::calculateHashForRow)
.sum()
.toString()
}
override fun solvePartTwo(input: String): String {
return s... | 0 | Kotlin | 0 | 0 | 3e99b70d0b8b447c56cc15ee3621a65031e1cf6e | 2,026 | Advent-of-Code-2017 | Apache License 2.0 |
src/Day05.kt | SimoneStefani | 572,915,832 | false | {"Kotlin": 33918} | fun main() {
fun numberOfStacks(lines: List<String>) =
lines.dropWhile { it.contains("[") }.first().trim().split(" ").maxOf { it.toInt() }
fun loadStacks(input: List<String>): List<ArrayDeque<String>> {
val numberOfStacks = numberOfStacks(input)
val stacks = List(numberOfStacks) { Ar... | 0 | Kotlin | 0 | 0 | b3244a6dfb8a1f0f4b47db2788cbb3d55426d018 | 1,935 | aoc-2022 | Apache License 2.0 |
src/day13/puzzle13.kt | brendencapps | 572,821,792 | false | {"Kotlin": 70597} | package day13
import Puzzle
import PuzzleInput
import org.json.JSONArray
import java.io.File
import java.lang.Integer.min
fun day13Puzzle() {
Day13PuzzleSolution().solve(Day13PuzzleInput("inputs/day13/example.txt", 13))
Day13PuzzleSolution().solve(Day13PuzzleInput("inputs/day13/input.txt", 5675))
Day13Pu... | 0 | Kotlin | 0 | 0 | 00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3 | 3,085 | aoc_2022 | Apache License 2.0 |
src/main/kotlin/Day07.kt | uipko | 572,710,263 | false | {"Kotlin": 25828} | const val totalSpace = 70_000_000
const val neededFreeSpace = 30_000_000
fun main() {
val total = dirsSize("Day07.txt", 100_000)
println("Total size $total")
val freeUp = freeUpSpace("Day07.txt")
println("Total size $freeUp")
}
data class Folder(val name: String, val folders: MutableList<Folder> = Ar... | 0 | Kotlin | 0 | 0 | b2604043f387914b7f043e43dbcde574b7173462 | 1,785 | aoc2022 | Apache License 2.0 |
src/Day02.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | import kotlin.math.absoluteValue
import kotlin.math.sign
/**
* Rock, Paper, Scissors: extendable to any odd number
*/
private enum class Throw {
A, B, C; // Rock, Paper, Scissors
val value = ordinal + 1
/**
* This is similar to `compareTo`: Returns zero if this Throw
* draws the other Throw, ... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 1,773 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day14.kt | andrewrlee | 434,584,657 | false | {"Kotlin": 29493, "Clojure": 14117, "Shell": 398} | import java.io.File
import java.nio.charset.StandardCharsets.UTF_8
import kotlin.collections.Map.Entry
object Day14 {
object Part1 {
private fun toRule(s: String): Pair<List<Char>, Char> {
val (pair, value) = s.split(" -> ")
return pair.toCharArray().let { listOf(it[0], it[1]) } t... | 0 | Kotlin | 0 | 0 | aace0fccf9bb739d57f781b0b79f2f3a5d9d038e | 3,090 | adventOfCode2021 | MIT License |
src/day09/Day09.kt | treegem | 572,875,670 | false | {"Kotlin": 38876} | package day09
import common.readInput
fun main() {
fun part1(input: List<String>): Int {
val head = Head()
val tail = FollowingKnot(head)
input
.toDirections()
.forEach {
head.move(it)
tail.adjustToLeadingKnot()
}
... | 0 | Kotlin | 0 | 0 | 97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8 | 1,591 | advent_of_code_2022 | Apache License 2.0 |
src/Day04.kt | greg-burgoon | 573,074,283 | false | {"Kotlin": 120556} |
fun main() {
fun part1(input: String): Int {
return input.split("\n")
.map {
var rangeOne = it.split(",")[0].split("-")
var rangeTwo = it.split(",")[1].split("-")
val setOne =(rangeOne[0].toInt() .. rangeOne[1].toInt()).toMutableSet()
... | 0 | Kotlin | 0 | 1 | 74f10b93d3bad72fa0fc276b503bfa9f01ac0e35 | 1,735 | aoc-kotlin | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.