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/Day02.kt | bananer | 434,885,332 | false | {"Kotlin": 36979} | fun main() {
fun part1(input: List<String>): Int {
val result: Pair<Int, Int> = input
.fold(Pair(0, 0)) { (position, depth), step ->
val (direction, countStr) = step.split(" ")
val count = Integer.parseInt(countStr)
val pair = Pair(
... | 0 | Kotlin | 0 | 0 | 98f7d6b3dd9eefebef5fa3179ca331fef5ed975b | 2,109 | advent-of-code-2021 | Apache License 2.0 |
kotlin/src/com/leetcode/23_MergeKSortedLists.kt | programmerr47 | 248,502,040 | false | null | package com.leetcode
import com.leetcode.data.ListNode
import com.leetcode.data.listNodesOf
import kotlin.collections.ArrayList
/**
* Time: O(n^2 * k) - k - max size of lists. We have N lists with size at max K.
* We create a new list of sorted heads:
* To create we go through... | 0 | Kotlin | 0 | 0 | 0b5fbb3143ece02bb60d7c61fea56021fcc0f069 | 3,140 | problemsolving | Apache License 2.0 |
src/day12/a/day12a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day12.a
import readInputLines
import shouldBe
import util.IntGrid
import util.IntVector
import vec2
fun main() {
val map = readInput()
val dist = IntGrid(map.width, map.height)
dist.compute { Integer.MAX_VALUE }
val (start, end) = findStartAndEnd(map)
val modified = HashSet<IntVector>()
... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 1,832 | advent-of-code-2022 | Apache License 2.0 |
src/day01/Day01Answer.kt | IThinkIGottaGo | 572,833,474 | false | {"Kotlin": 72162} | package day01
import readString
import java.util.*
/**
* Answer basically from [Advent of Code 2022 Day 1 | Kotlin](https://youtu.be/ntbsbqLCKDs)
*/
fun main() {
fun part1(input: String): Int {
val data = parseInput(input)
return data.topNElvesLogN(1)
}
fun part2(input: String): Int {
... | 0 | Kotlin | 0 | 0 | 967812138a7ee110a63e1950cae9a799166a6ba8 | 1,885 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day07/part2/day07_2.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2023.day07.part2
import eu.janvdb.aoc2023.day07.TypeOfHand
import eu.janvdb.aocutil.kotlin.readLines
//const val FILENAME = "input07-test.txt"
const val FILENAME = "input07.txt"
fun main() {
val pairs = readLines(2023, FILENAME).map { CardBidPair.parse(it) }
val score = pairs
.sortedBy { it... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 2,497 | advent-of-code | Apache License 2.0 |
src/main/kotlin/wtf/log/xmas2021/day/day15/Day15.kt | damianw | 434,043,459 | false | {"Kotlin": 62890} | package wtf.log.xmas2021.day.day15
import wtf.log.xmas2021.Day
import wtf.log.xmas2021.util.collect.Grid
import wtf.log.xmas2021.util.collect.Grid.Coordinate
import wtf.log.xmas2021.util.collect.Grid.Entry
import wtf.log.xmas2021.util.collect.toGrid
import java.io.BufferedReader
import java.util.*
object Day15 : Day<... | 0 | Kotlin | 0 | 0 | 1c4c12546ea3de0e7298c2771dc93e578f11a9c6 | 2,979 | AdventOfKotlin2021 | BSD Source Code Attribution |
src/Day11.kt | sushovan86 | 573,586,806 | false | {"Kotlin": 47064} | typealias WorryLevelOperation = (Long) -> Long
class MonkeyProblem {
private data class Monkey(
val monkeyIndex: Int,
val items: List<Long>,
val operation: String,
val rightOperand: String,
val divisorPredicateOperand: Int,
val trueTargetMonkey: Int,
val fal... | 0 | Kotlin | 0 | 0 | d5f85b6a48e3505d06b4ae1027e734e66b324964 | 4,443 | aoc-2022 | Apache License 2.0 |
src/year2023/day06/Day06.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2023.day06
import check
import readInput
fun main() {
val testInput1 = readInput("2023", "Day06_test")
check(part1(testInput1), 288)
check(part2(testInput1), 71503)
val input = readInput("2023", "Day06")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 1,153 | AdventOfCode | Apache License 2.0 |
src/Day02.kt | ekgame | 573,100,811 | false | {"Kotlin": 20661} |
fun main() {
class GestureDefinition(
val winAgainst: Char,
val loseAgainst: Char,
val drawAgainst: Char,
val useScore: Int,
) {
fun isWin(against: Char) = winAgainst == against
fun isLoss(against: Char) = loseAgainst == against
fun isDraw(against: Char) ... | 0 | Kotlin | 0 | 2 | 0c2a68cedfa5a0579292248aba8c73ad779430cd | 1,839 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/nl/meine/aoc/_2023/Day4.kt | mtoonen | 158,697,380 | false | {"Kotlin": 201978, "Java": 138385} | package nl.meine.aoc._2023
import java.util.concurrent.ConcurrentHashMap
import kotlin.math.pow
class Day4 {
fun one(input: String): Int {
val lines = input.split("\n")
.map { it.substringAfter(": ") }
.map {
val lists = it.split(" | ")
Pair(createL... | 0 | Kotlin | 0 | 0 | a36addef07f61072cbf4c7c71adf2236a53959a5 | 26,242 | advent-code | MIT License |
AOC-2023/src/main/kotlin/Day04.kt | sagar-viradiya | 117,343,471 | false | {"Kotlin": 72737} | import utils.*
import kotlin.math.pow
object Day04 {
fun part01(input: String): Long {
return input
.splitAtNewLines()
.map { card ->
val numbers = card.splitAtColon()[1].trim().split("|")
val winningNumbers = numbers[0].trim().splitAtWhiteSpace().to... | 0 | Kotlin | 0 | 0 | 7f88418f4eb5bb59a69333595dffa19bee270064 | 2,455 | advent-of-code | MIT License |
src/main/kotlin/com/hopkins/aoc/day4/main.kt | edenrox | 726,934,488 | false | {"Kotlin": 88215} | package com.hopkins.aoc.day4
import java.io.File
const val debug = true
const val part = 2
val scores = buildScores(20)
/** Advent of Code 2023: Day 4 */
fun main() {
if (debug) {
println("Scores: $scores")
}
val inputFile = File("input/input4.txt")
val lines: List<String> = inputFile.readLi... | 0 | Kotlin | 0 | 0 | 45dce3d76bf3bf140d7336c4767e74971e827c35 | 2,456 | aoc2023 | MIT License |
src/Day22.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | import java.io.File
fun main() {
fun parseMap(input: List<String>): Pair<MutableSet<Pair<Int, Int>>, MutableSet<Pair<Int, Int>>> {
var groveMap = mutableSetOf<Pair<Int, Int>>()
var blockedTiles = mutableSetOf<Pair<Int, Int>>()
for ((row, line) in input.withIndex()){
for ((col,... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 10,356 | aoc22 | Apache License 2.0 |
src/array/LeetCode215.kt | Alex-Linrk | 180,918,573 | false | null | package array
/**
* 数组中的第K个最大元素
* 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。
*
*示例 1:
*
*输入: [3,2,1,5,6,4] 和 k = 2
*输出: 5
*示例 2:
*
*输入: [3,2,3,1,2,4,5,5,6] 和 k = 4
*输出: 4
*说明:
*
*你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。
*
*来源:力扣(LeetCode)
*链接:https://leetcode-cn.com/problems/kth-largest-elem... | 0 | Kotlin | 0 | 0 | 59f4ab02819b7782a6af19bc73307b93fdc5bf37 | 2,496 | LeetCode | Apache License 2.0 |
src/Day09.kt | MatthiasDruwe | 571,730,990 | false | {"Kotlin": 47864} | import java.lang.Error
import javax.swing.text.Position
import kotlin.math.abs
fun main() {
fun calcPositionT(positionH: Pair<Int,Int>, positionT: Pair<Int, Int>): Pair<Int,Int>{
if(abs(positionH.first - positionT.first) <= 1 && abs(positionT.second - positionH.second) <= 1){
return positionT
... | 0 | Kotlin | 0 | 0 | f35f01cea5075cfe7b4a1ead9b6480ffa57b4989 | 3,345 | Advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day-03.kt | warriorzz | 434,708,459 | true | {"Kotlin": 3651} | package com.github.warriorzz.aoc
import java.io.File
private fun main() {
println("Day 03:")
val lines = File("./input/day-03.txt").readLines()
val map = mutableMapOf<Int, Int>()
lines.map { it ->
it.toCharArray().map { it.digitToInt() }
}.forEach { ints ->
ints.forEachIndexed { i... | 0 | Kotlin | 1 | 0 | 3014509c222f5c8b41e6dcaea95f796bdfe82d61 | 1,607 | aoc-21 | MIT License |
src/twentythree/Day07.kt | mihainov | 573,105,304 | false | {"Kotlin": 42574} | package twentythree
import readInputTwentyThree
enum class Combination {
FIVE_OF_A_KIND,
FOUR_OF_A_KIND,
FULL_HOUSE,
THREE_OF_A_KIND,
TWO_PAIR,
PAIR,
HIGH;
}
// functionality is changed to solve p2
enum class PlayingCard(val code: String) {
ACE("A"),
KING("K"),
QUEEN("Q"),
... | 0 | Kotlin | 0 | 0 | a9aae753cf97a8909656b6137918ed176a84765e | 5,059 | kotlin-aoc-1 | Apache License 2.0 |
src/main/Day02.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day02
import utils.readInput
enum class Shape(val score: Int) {
Rock(1),
Paper(2),
Scissors(3);
val defeats: Shape
get() =
when (this) {
Rock -> Scissors
Paper -> Rock
Scissors -> Paper
}
val defeated: Shape
... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 2,279 | aoc-2022 | Apache License 2.0 |
src/Day11.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | // https://adventofcode.com/2022/day/11
fun main() {
fun parseInput(input: String): List<Monkey> =
input
.split("\n\n")
.map(Monkey::fromString)
fun solve(monkeys: List<Monkey>, rounds: Int, reliefFunction: (Long) -> Long): Long {
val monkeysMap = monkeys.associateBy(Mon... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 4,124 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day11.kt | thiyagu06 | 572,818,472 | false | {"Kotlin": 17748} | import aoc22.printIt
import java.io.File
fun main() {
fun parseInput() = File("input/day11.txt").readLines()
val input = parseInput().chunkedBy { it.isBlank() }.map { from(it) }
fun star1(): Long {
val monkeys = input.map { it.copy() }
return calculateMonkeyBusiness(monkeys, rounds = 20)... | 0 | Kotlin | 0 | 0 | 55a7acdd25f1a101be5547e15e6c1512481c4e21 | 3,082 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | askeron | 572,955,924 | false | {"Kotlin": 24616} | class Day07 : Day<Long>(95437L, 24933642L, 1543140L, 1117448L) {
data class File(val dirPath: String, val filename: String, val size: Long) {
val path = "$dirPath$filename"
}
private fun parseInput(input: List<String>): List<File> {
val files = mutableListOf<File>()
var currentPath... | 0 | Kotlin | 0 | 1 | 6c7cf9cf12404b8451745c1e5b2f1827264dc3b8 | 2,132 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day07.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Long {
val commands = parseCommands(input.drop(1))
val root = Directory("/")
Terminal(root).execute(commands)
return root.getAllDirectories().filter { it.size() < 100_000 }.sumOf { it.size() }
}
fun part2(input: List<... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 3,454 | aoc2022 | Apache License 2.0 |
src/Day04.kt | TheGreatJakester | 573,222,328 | false | {"Kotlin": 47612} | import utils.readInputAsLines
fun main() {
fun part1(input: List<String>): Int {
return input.map {
it.split(",")
}.filter { (elf1, elf2) ->
val (a, b) = elf1.split("-")
val (c, d) = elf2.split("-")
if (a.toInt() <= c.toInt() && b.toInt() >= d.toInt(... | 0 | Kotlin | 0 | 0 | c76c213006eb8dfb44b26822a44324b66600f933 | 1,431 | 2022-AOC-Kotlin | Apache License 2.0 |
app/src/main/kotlin/codes/jakob/aoc/solution/Day01.kt | loehnertz | 725,944,961 | false | {"Kotlin": 59236} | package codes.jakob.aoc.solution
import codes.jakob.aoc.shared.splitByCharacter
import codes.jakob.aoc.shared.splitByLines
object Day01 : Solution() {
private val digitsPattern = Regex("(?=(zero|one|two|three|four|five|six|seven|eight|nine|\\d))")
override fun solvePart1(input: String): Any {
return ... | 0 | Kotlin | 0 | 0 | 6f2bd7bdfc9719fda6432dd172bc53dce049730a | 2,459 | advent-of-code-2023 | MIT License |
kotlin/src/2023/Day02_2023.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | import kotlin.math.max
private fun parseItem(s: String): Pair<String, Int> {
val (cnt, typ) = s.trim().split(" ")
return typ to cnt.toInt()
}
private fun parseGame(s: String): List<Map<String, Int>> {
return s.split(";")
.map {
its -> its.split(",")
.associate {parseItem(it... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 1,352 | adventofcode | Apache License 2.0 |
src/main/kotlin/year2022/Day16.kt | forketyfork | 572,832,465 | false | {"Kotlin": 142196} | package year2022
import utils.powerSetSequence
class Day16(input: String) {
data class ValveNode(val name: String) {
var flowRate = 0
var neighbors = mutableListOf<ValveNode>()
val distanceMap: MutableMap<ValveNode, Int> = mutableMapOf()
}
private val regex = """Valve (..) has fl... | 0 | Kotlin | 0 | 0 | 5c5e6304b1758e04a119716b8de50a7525668112 | 2,656 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | PauliusRap | 573,434,850 | false | {"Kotlin": 20299} | private const val FIRST_CHAR_INDEX = 0
private const val SECOND_CHAR_INDEX = 2
private const val ERROR_MESSAGE = "Unknown character!"
fun main() {
fun getPoints(input: String): Int {
val opponentsSign = input.toCharArray()[FIRST_CHAR_INDEX].getSign()
val yourSign = input.toCharArray()[SECOND_CHAR_... | 0 | Kotlin | 0 | 0 | df510c3afb104c03add6cf2597c433b34b3f7dc7 | 2,425 | advent-of-coding-2022 | Apache License 2.0 |
src/Day15.kt | pavlo-dh | 572,882,309 | false | {"Kotlin": 39999} | import kotlin.math.abs
fun main() {
data class Point(val x: Int, val y: Int) {
fun manhattanDistance(other: Point) = abs(x - other.x) + abs(y - other.y)
}
fun parsePoint(s: String): Point {
val x = s.substring(s.indexOf('=') + 1, s.indexOf(',')).toInt()
val y = s.substring(s.lastIn... | 0 | Kotlin | 0 | 2 | c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992 | 3,589 | aoc-2022-in-kotlin | Apache License 2.0 |
src/heap/LeetCode239.kt | Alex-Linrk | 180,918,573 | false | null | package heap
/**
* 滑动窗口最大值
* 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口 k 内的数字。滑动窗口每次只向右移动一位。
*
*返回滑动窗口最大值。
*
*示例:
*
*输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3
*输出: [3,3,5,5,6,7]
*解释:
*
*滑动窗口的位置 最大值
*--------------- -----
*[1 3 -1] -3 5 3 6 7 3
*1 [3 -... | 0 | Kotlin | 0 | 0 | 59f4ab02819b7782a6af19bc73307b93fdc5bf37 | 2,346 | LeetCode | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch9/Problem95.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch9
import dev.bogwalk.util.maths.sumProperDivisors
/**
* Problem 95: Amicable Chains
*
* https://projecteuler.net/problem=95
*
* Goal: Find the smallest member of the longest amicable chain possible without any member
* exceeding N.
*
* Constraints: 6 <= N <= 1e6
*
* Perfect Number: ... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,802 | project-euler-kotlin | MIT License |
src/main/kotlin/aoc/Day09.kt | fluxxion82 | 573,716,300 | false | {"Kotlin": 39632} | package aoc
import aoc.model.Coordinate
import aoc.model.moveDown
import aoc.model.moveLeft
import aoc.model.moveRight
import aoc.model.moveUp
import aoc.utils.readInput
fun getDirectionFromValue(directionValue: String): Direction? {
return when (directionValue) {
"R" -> Direction.RIGHT
"L" -> Dir... | 0 | Kotlin | 0 | 0 | 3920d2c3adfa83c1549a9137ffea477a9734a467 | 3,177 | advent-of-code-kotlin-22 | Apache License 2.0 |
src/main/kotlin/day05/Day05.kt | vitalir2 | 572,865,549 | false | {"Kotlin": 89962} | package day05
import Challenge
import java.util.*
import map
object Day05 : Challenge(5) {
override fun part1(input: List<String>): String {
return solveStacksProblem(parse(input)) { command, fromStack, toStack ->
repeat(command.times) {
val item = fromStack.pop()
... | 0 | Kotlin | 0 | 0 | ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6 | 3,522 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day16.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2020
import com.dvdmunckhof.aoc.splitOnce
import com.dvdmunckhof.aoc.toRange
class Day16(input: String) {
private val rules: Map<String, List<IntRange>>
private val ticket: List<Int>
private val nearbyTickets: List<List<Int>>
init {
val sections = input.split(... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 2,054 | advent-of-code | Apache License 2.0 |
src/Day04.kt | greeshmaramya | 514,310,903 | false | {"Kotlin": 8307} | fun main() {
fun List<String>.modifyInput(): MutableList<String> {
val passports: MutableList<String> = mutableListOf()
var s = ""
forEach {
if (it.isBlank()) {
passports.add(s)
s = ""
} else {
s += " "
s... | 0 | Kotlin | 0 | 0 | 9e1128ee084145f5a70fe3ad4e71b05944260d6e | 2,422 | aoc2020 | Apache License 2.0 |
src/Day11.kt | DiamondMiner88 | 573,073,199 | false | {"Kotlin": 26457, "Rust": 4093, "Shell": 188} | import java.math.BigInteger
fun main() {
d11part1()
// d11part2()
}
val regex =
"Monkey (\\d):\\n Starting items: (.+?)\\n Operation: new = old (.+?)\\n Test: divisible by (\\d{1,2})\\n If true: throw to monkey (\\d)\\n If false: throw to monkey (\\d)".toRegex()
data class Monkey(
var items: ... | 0 | Kotlin | 0 | 0 | 55bb96af323cab3860ab6988f7d57d04f034c12c | 4,815 | advent-of-code-2022 | Apache License 2.0 |
app/src/main/kotlin/day03/Day03.kt | KingOfDog | 433,706,881 | false | {"Kotlin": 76907} | package day03
import common.InputRepo
import common.readSessionCookie
import common.solve
fun main(args: Array<String>) {
val day = 3
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay03Part1, ::solveDay03Part2)
}
fun solveDay03Part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 576e5599ada224e5cf21ccf20757673ca6f8310a | 1,862 | advent-of-code-kt | Apache License 2.0 |
src/Day10.kt | rafael-ribeiro1 | 572,657,838 | false | {"Kotlin": 15675} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
return input.toCycles()
.filter { it.cycle in 20..220 && it.cycle % 40 == 20 }
.sumOf { it.cycle * it.x }
}
fun part2(input: List<String>): String {
var crtPos = 0
var prevPos = 1
... | 0 | Kotlin | 0 | 0 | 5cae94a637567e8a1e911316e2adcc1b2a1ee4af | 1,479 | aoc-kotlin-2022 | Apache License 2.0 |
src/Day09.kt | jamOne- | 573,851,509 | false | {"Kotlin": 20355} | import kotlin.math.abs
import kotlin.math.max
fun main() {
fun move(position: Pair<Int, Int>, direction: Direction): Pair<Int, Int> {
val (x, y) = position
return when (direction) {
Direction.UP -> Pair(x, y - 1)
Direction.DOWN -> Pair(x, y + 1)
Direction.LEFT ->... | 0 | Kotlin | 0 | 0 | 77795045bc8e800190f00cd2051fe93eebad2aec | 2,520 | adventofcode2022 | Apache License 2.0 |
src/Day03.kt | melo0187 | 576,962,981 | false | {"Kotlin": 15984} | fun main() {
val priorityByItemType = (('a'..'z') + ('A'..'Z'))
.mapIndexed { index, itemType ->
val priority = index + 1
itemType to priority
}
.toMap()
fun part1(input: List<String>): Int = input
.map { rucksack ->
val (compartment1, compart... | 0 | Kotlin | 0 | 0 | 97d47b84e5a2f97304a078c3ab76bea6672691c5 | 1,330 | kotlin-aoc-2022 | Apache License 2.0 |
src/Day09.kt | fedochet | 573,033,793 | false | {"Kotlin": 77129} | import kotlin.math.abs
import kotlin.math.sign
private enum class Direction {
UP, DOWN, LEFT, RIGHT
}
fun main() {
data class Move(val direction: Direction, val steps: Int)
data class SnakeCell(private var row: Int, private var column: Int) {
fun move(direction: Direction) {
when (dir... | 0 | Kotlin | 0 | 1 | 975362ac7b1f1522818fc87cf2505aedc087738d | 2,502 | aoc2022 | Apache License 2.0 |
day-16/src/main/kotlin/PacketDecoder.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | import kotlin.system.measureTimeMillis
fun main() {
val partOneMillis = measureTimeMillis {
println("Part One Solution: ${partOne()}")
}
println("Part One Solved in: $partOneMillis ms")
val partTwoMillis = measureTimeMillis {
println("Part Two Solution: ${partTwo()}")
}
println... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 6,383 | aoc-2021 | MIT License |
src/main/kotlin/days/Day15.kt | butnotstupid | 571,247,661 | false | {"Kotlin": 90768} | package days
import kotlin.math.abs
class Day15 : Day(15) {
override fun partOne(): Any {
val targetRow = 2000000
val input = parseInput()
val sensors = input.mapValues { (s, b) -> manDistance(s, b) }
val beacons = input.values.distinct()
val events = intervalEvents(sensor... | 0 | Kotlin | 0 | 0 | 4760289e11d322b341141c1cde34cfbc7d0ed59b | 3,438 | aoc-2022 | Creative Commons Zero v1.0 Universal |
advent-of-code-2023/src/main/kotlin/Day15.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | // Day 15: Lens Library
// https://adventofcode.com/2023/day/15
import java.io.File
private const val DASH = "-"
private const val EQUALS = "="
fun main() {
val input = File("src/main/resources/Day15.txt").readText()
val initializationSequence = input.split(",")
val initializationSequenceSum = initializ... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 2,371 | advent-of-code | Apache License 2.0 |
src/main/kotlin/g2201_2300/s2203_minimum_weighted_subgraph_with_the_required_paths/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2201_2300.s2203_minimum_weighted_subgraph_with_the_required_paths
// #Hard #Graph #Shortest_Path #2023_06_27_Time_1126_ms_(100.00%)_Space_127.2_MB_(100.00%)
import java.util.PriorityQueue
import java.util.Queue
class Solution {
fun minimumWeight(n: Int, edges: Array<IntArray>, src1: Int, src2: Int, dest... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,263 | LeetCode-in-Kotlin | MIT License |
src/Day02.kt | ambrosil | 572,667,754 | false | {"Kotlin": 70967} | import Sign.*
import java.lang.RuntimeException
enum class Sign { ROCK, PAPER, SCISSORS }
data class Round(val opponent: Sign, val mine: Sign) {
private fun signPoints() =
when (mine) {
ROCK -> 1
PAPER -> 2
SCISSORS -> 3
}
private fun matchPoints() =
... | 0 | Kotlin | 0 | 0 | ebaacfc65877bb5387ba6b43e748898c15b1b80a | 2,281 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | Flexicon | 576,933,699 | false | {"Kotlin": 5474} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { line ->
(line[2] - Char(87)) + when (line) {
"A X", "B Y", "C Z" -> 3
"A Y", "B Z", "C X" -> 6
else -> 0
}
}
}
fun part2(input: List<String>): Int ... | 0 | Kotlin | 0 | 0 | 7109cf333c31999296e1990ce297aa2db3a622f2 | 1,178 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2021/day3/Day3.kt | arnab | 75,525,311 | false | null | package aoc2021.day3
object Day3 {
fun parse(data: String) = data.split("\n")
.map { readings -> readings.split("").filterNot { it.isBlank() } }
fun calculatePowerConsumption(readings: List<List<String>>): Int =
calculateGamma(readings) * calculateEpsilon(readings)
private fun calculateGa... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 2,101 | adventofcode | MIT License |
src/main/kotlin/io/steinh/aoc/day06/BoatRace.kt | daincredibleholg | 726,426,347 | false | {"Kotlin": 25396} | package io.steinh.aoc.day06
class BoatRace(private val input: BoatRaceStats) {
fun calculateWaysToBeatTheRecord(): Int {
val possibleWins = buildList {
input.timeToDistance.forEach { (time, distance) ->
add(
buildList {
for (i in 1..t... | 0 | Kotlin | 0 | 0 | 4aa7c684d0e337c257ae55a95b80f1cf388972a9 | 2,073 | AdventOfCode2023 | MIT License |
src/Day13/Day13.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import kotlin.math.max
fun main() {
fun Array<Array<Boolean>>.print() {
for (row in this) {
for (e in row) {
print("${if (e) "X" else "."} ")
}
println()
}
}
fun preprocess(input: List<String>): Pair<Array<Array<Boolean>>, List<Pair<Strin... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 3,540 | advent-of-code-2021 | Apache License 2.0 |
src/Day04.kt | haitekki | 572,959,197 | false | {"Kotlin": 24688} | fun main() {
fun part1(input: String): Int {
return input.lines().map {
Pair(it.substringBefore(',').trim(), it.substringAfter(',').trim()).let { pair ->
val fSet = (pair.first.substringBefore("-").toInt() .. pair.first.substringAfter("-").toInt()).toSet()
val sSe... | 0 | Kotlin | 0 | 0 | b7262133f9115f6456aa77d9c0a1e9d6c891ea0f | 1,166 | aoc2022 | Apache License 2.0 |
src/Day08.kt | MarkRunWu | 573,656,261 | false | {"Kotlin": 25971} | import java.lang.Integer.max
enum class Direction(val raw: Int) {
Left(0),
Top(1),
Right(2),
Bottom(3)
}
fun main() {
fun dumpMaxTreeMap(maxTreeMap: Array<Array<Array<Int>>>, direction: Direction) {
for (i in maxTreeMap.indices) {
for (j in maxTreeMap[i].indices) {
... | 0 | Kotlin | 0 | 0 | ced885dcd6b32e8d3c89a646dbdcf50b5665ba65 | 5,556 | AOC-2022 | Apache License 2.0 |
src/Day17/Day17.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | fun main() {
fun preprocess(input: List<String>): Pair<Pair<Int, Int>, Pair<Int, Int>> {
val split = input[0].split(" ")
val x = split[2].split("=")[1].split(",")[0].split("..")
val y = split[3].split("=")[1].split("..")
return Pair(Pair(x[0].toInt(), x[1].toInt()), Pair(y[0].toInt(... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 1,957 | advent-of-code-2021 | Apache License 2.0 |
src/Day14.kt | rod41732 | 572,917,438 | false | {"Kotlin": 85344} | private fun parsePath(input: String): List<Coord2D> {
return input.split(" -> ").map {
it.split(",").map { it.toInt() }.let { (x, y) -> Coord2D(x, y) }
}
}
private infix fun Int.smartRange(o: Int) = if (this < o) this .. o else o .. this
private fun Coord2D.lineTo(other: Coord2D): Sequence<Coord2D> {
... | 0 | Kotlin | 0 | 0 | 1d2d3d00e90b222085e0989d2b19e6164dfdb1ce | 2,860 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | allisonjoycarter | 574,207,005 | false | {"Kotlin": 22303} | import java.io.InputStream
import java.util.*
import kotlin.collections.ArrayList
enum class Direction(val horizontal: Int = 0, val vertical: Int = 0) {
Up(vertical = -1),
Down(vertical = 1),
Left(horizontal = -1),
Right(horizontal = 1)
}
fun main() {
fun traverseDirectionAndCheckVisible(input: L... | 0 | Kotlin | 0 | 0 | 86306ee6f4e90c1cab7c2743eb437fa86d4238e5 | 4,119 | adventofcode2022 | Apache License 2.0 |
src/Day05.kt | greg-burgoon | 573,074,283 | false | {"Kotlin": 120556} | fun main() {
fun parseStacks(input: String, numberOfStacks: Int): List<ArrayDeque<Char>> {
var stacks = ArrayList<ArrayDeque<Char>>()
repeat(numberOfStacks) {
stacks.add(ArrayDeque<Char>())
}
input
.split("\n")
.map {
it.toList()
... | 0 | Kotlin | 0 | 1 | 74f10b93d3bad72fa0fc276b503bfa9f01ac0e35 | 2,703 | aoc-kotlin | Apache License 2.0 |
src/year2023/day01/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2023.day01
import arrow.core.nonEmptyListOf
import utils.ProblemPart
import utils.readInputs
import utils.runAlgorithm
fun main() {
val (realInput, testInputs) = readInputs(2023, 1, "test_input_part2")
runAlgorithm(
realInput = realInput,
testInputs = testInputs,
part1 = P... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 1,678 | Advent-of-Code | Apache License 2.0 |
src/Day04.kt | MartinsCode | 572,817,581 | false | {"Kotlin": 77324} | fun main() {
fun part1(input: List<String>): Int {
var numberFullyContained = 0
input.forEach {
val strCleaning1 = it.split(",")[0]
val strCleaning2 = it.split(",")[1]
var clean1 = strCleaning1.split("-").map { it.toInt() }
var clean2 = strCleaning2.sp... | 0 | Kotlin | 0 | 0 | 1aedb69d80ae13553b913635fbf1df49c5ad58bd | 1,991 | AoC-2022-12-01 | Apache License 2.0 |
src/y2022/Day07.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.readInput
object Day07 {
data class File(
val size: Long?,
val parent: File? = null,
val children: MutableList<File> = mutableListOf(),
val name: String
) {
fun totalSize(): Long {
if (children.size == 0) {
return si... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 3,350 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2023/Day16.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
class Day16(input: List<String>) {
private val grid = input.toGrid()
private val region = grid.region()
private data class Beam(val pos: Vector2, val direction: Direction) {
private fun forward() = Beam(pos + direction.vector(), direction)
private fun left... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 2,359 | advent-2023 | MIT License |
src/day25/Day25.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day25
import readInput
import readTestInput
import kotlin.math.pow
private val snafuPlaceValues = mutableListOf<Long>()
private fun snafuToDecimal(snafu: String): Long {
var value = 0L
for (exponent in snafu.indices) {
val index = snafu.lastIndex - exponent
val digitValue = when(sna... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 2,187 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | brunojensen | 572,665,994 | false | {"Kotlin": 13161} | private operator fun String.component1() = this.substring(0, this.length / 2)
private operator fun String.component2() = this.substring(this.length / 2)
private fun Char.priority(): Int = when (this) {
in 'a'..'z' -> (this - 'a') + 1
in 'A'..'Z' -> (this - 'A') + 27
else -> error("out of the range: $this")
}
pr... | 0 | Kotlin | 0 | 0 | 2707e76f5abd96c9d59c782e7122427fc6fdaad1 | 1,335 | advent-of-code-kotlin-1 | Apache License 2.0 |
src/day05/Day05.kt | TimberBro | 567,240,136 | false | {"Kotlin": 11186} | package day05
import utils.readInput
fun main() {
val rowsMaxValue = 127
val columnMaxValue = 7
val splitRegex = "((?=([RL]){3}))"
fun binarySearchByPattern(minValue: Int = 0, maxValue: Int, patternChar: Char): Pair<Int, Int> {
var tempMax = maxValue
var tempMin = minValue
val ... | 0 | Kotlin | 0 | 0 | 1959383d2f422cc565560eefb1ed4f05bb87a386 | 1,984 | aoc2020 | Apache License 2.0 |
2021/src/main/kotlin/com/trikzon/aoc2021/Day15.kt | Trikzon | 317,622,840 | false | {"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397} | package com.trikzon.aoc2021
// Solved using Dijkstra's Shortest Path Algorithm https://www.youtube.com/watch?v=pVfj6mxhdMw
fun main() {
val input = getInputStringFromFile("/day15.txt")
benchmark(Part.One, ::day15Part1, input, 398, 5)
benchmark(Part.Two, ::day15Part2, input, 2817, 1)
}
fun day15Part1(inpu... | 0 | Kotlin | 1 | 0 | d4dea9f0c1b56dc698b716bb03fc2ad62619ca08 | 4,885 | advent-of-code | MIT License |
src/main/kotlin/day3.kt | nerok | 436,232,451 | false | {"Kotlin": 32118} | import java.io.File
fun main(args: Array<String>) {
day3part2()
}
fun day3part1() {
val countArray = IntArray(12) { 0 }
val input = File("day3input.txt").bufferedReader().readLines()
input.map { it.mapIndexed { index, value ->
if (value == '1') {
countArray[index] = (countArray[ind... | 0 | Kotlin | 0 | 0 | 4dee925c0f003fdeca6c6f17c9875dbc42106e1b | 2,297 | Advent-of-code-2021 | MIT License |
src/Day02.kt | MartinsCode | 572,817,581 | false | {"Kotlin": 77324} | fun scoreDraw(a: String): Int = when (a) {
"X" -> 1
"Y" -> 2
"Z" -> 3
else -> 0
}
fun scoreWin(a: String, b: String): Int {
return when {
a == "A" && b == "X" -> 3
a == "A" && b == "Y" -> 6
a == "A" && b == "Z" -> 0
a == "B" && b == "X" -> 0
a == "B" && b == ... | 0 | Kotlin | 0 | 0 | 1aedb69d80ae13553b913635fbf1df49c5ad58bd | 2,474 | AoC-2022-12-01 | Apache License 2.0 |
src/Day14.kt | fouksf | 572,530,146 | false | {"Kotlin": 43124} | import kotlin.math.max
import kotlin.math.min
fun main() {
fun parseTuple(tuple: List<List<Int>>, result: HashMap<Pair<Int, Int>, String>) {
val x1 = tuple[0][0]
val x2 = tuple[1][0]
val y1 = tuple[0][1]
val y2 = tuple[1][1]
for (i in min(x1, x2)..max(x1, x2)) {
... | 0 | Kotlin | 0 | 0 | 701bae4d350353e2c49845adcd5087f8f5409307 | 4,271 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day17/day17.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day17
import biz.koziolek.adventofcode.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
val inputFile = findInput(object {})
val line = inputFile.bufferedReader().readLine()
val targetArea = parseTargetArea(line)
val (bestV... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 4,679 | advent-of-code | MIT License |
src/Day05.kt | binaryannie | 573,120,071 | false | {"Kotlin": 10437} | private const val DAY = "05"
private const val PART_1_CHECK = "CMZ"
private const val PART_2_CHECK = "MCD"
fun inputToColumns(input: List<String>): MutableList<MutableList<String>> {
val separatorIndex = input.indexOf("")
val numberOfColumns = input[separatorIndex - 1].chunked(4).size
val boat = input
... | 0 | Kotlin | 0 | 0 | 511fc33f9dded71937b6bfb55a675beace84ca22 | 2,390 | advent-of-code-2022 | Apache License 2.0 |
src/day03/Day03.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day03
import java.io.File
fun main() {
val data = parse("src/day03/Day03.txt")
println("🎄 Day 03 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)}")
}
private data class Part(
val rx: In... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 2,108 | advent-of-code-2023 | MIT License |
src/main/kotlin/aoc2022/Day02.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import utils.InputUtils
enum class Action(val score : Int) { ROCK(1), PAPER(2), SCISSORS(3) }
private val parseLine = "(\\w) (\\w)".toRegex()
typealias Play = Pair<Action, Action>
fun main() {
val testInput = """A Y
B X
C Z""".split("\n")
fun Char.toAction() = when (this) {
'A','X' ... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,308 | aoc-2022-kotlin | Apache License 2.0 |
src/Day08.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 2
private const val EXPECTED_2 = 6L
private class Day08(isTest: Boolean) : Solver(isTest) {
fun part1(): Any {
val lines = readAsLines()
val instructions = lines[0].trim()
val edges = mutableMapOf<String, MutableList<String>>()
for (edge in lines.drop(... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 2,904 | advent-of-code-2022 | Apache License 2.0 |
2021/src/main/kotlin/day14_imp.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
import utils.mapItems
import utils.withLCounts
fun main() {
Day14Imp.run()
}
object Day14Imp : Solution<Pair<Day14Imp.Polymer, List<Pair<String, String>>>>() {
override val name = "day14"
override val parser = Parser { input ->
val (polymer, ruleLines) = input.split... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,972 | aoc_kotlin | MIT License |
calendar/day02/Day2.kt | polarene | 572,886,399 | false | {"Kotlin": 17947} | package day02
import Day
import Lines
class Day2 : Day() {
override fun part1(input: Lines): Any {
return Game().run {
input.forEach { play(it.toHandRound()) }
total()
}
}
override fun part2(input: Lines): Any {
return Game().run {
input.forEach... | 0 | Kotlin | 0 | 0 | 0b2c769174601b185227efbd5c0d47f3f78e95e7 | 2,385 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2023/Day22.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
class Day22(input: List<String>) {
private val bricks = input
.flatMap { it.split("~") }
.map { it.split(",").map { it.toInt() } }
.map { Vector3(it[0], it[1], it[2]) }
.chunked(2)
.map { (start, end) -> Cuboid(start, end) }
.let { m... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 1,605 | advent-2023 | MIT License |
src/Day14.kt | rbraeunlich | 573,282,138 | false | {"Kotlin": 63724} | fun main() {
fun parseLine(line: String): RockLines {
val map = line.split(" -> ")
.map { pair ->
val split = pair.split(",")
split[0].toInt() to split[1].toInt()
}
return RockLines(map)
}
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 1 | 3c7e46ddfb933281be34e58933b84870c6607acd | 6,767 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | k3vonk | 573,555,443 | false | {"Kotlin": 17347} | import kotlin.math.floor
import kotlin.math.pow
import kotlin.math.sqrt
data class Point(var x: Double, var y: Double) {
operator fun plus(other: Point) {
this.x += other.x
this.y += other.y
}
}
val directions = mapOf(
"R" to Point(1.0, 0.0),
"L" to Point(-1.0, 0.0),
"U" to Point(0... | 0 | Kotlin | 0 | 1 | 68a42c5b8d67442524b40c0ce2e132898683da61 | 3,452 | AOC-2022-in-Kotlin | Apache License 2.0 |
src/main/kotlin/days/Day23.kt | butnotstupid | 571,247,661 | false | {"Kotlin": 90768} | package days
class Day23 : Day(23) {
override fun partOne(): Any {
return elvesRounds()
.take(10).last()
.let(::countEmptyGround)
}
override fun partTwo(): Any {
return elvesRounds()
.zipWithNext()
.takeWhile { (prev, cur) -> prev != cur }
... | 0 | Kotlin | 0 | 0 | 4760289e11d322b341141c1cde34cfbc7d0ed59b | 3,169 | aoc-2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dev/tasso/adventofcode/_2015/day02/Day02.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2015.day02
import dev.tasso.adventofcode.Solution
class Day02 : Solution<Int> {
override fun part1(input: List<String>): Int {
val dimensions = input.map { dimension -> dimension.split("x").map { it.toInt() } }
return dimensions.sumOf { dimension ->
g... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 1,274 | advent-of-code | MIT License |
src/Day15.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 1320
private const val EXPECTED_2 = 145
private class Day15(isTest: Boolean) : Solver(isTest) {
fun String.hash(): Int {
var v = 0
for (ch in this) {
v += ch.code
v = (v * 17) % 256
}
return v
}
fun part1(): Any {
... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 1,741 | advent-of-code-2022 | Apache License 2.0 |
src/day13/Code.kt | fcolasuonno | 572,734,674 | false | {"Kotlin": 63451, "Dockerfile": 1340} | package day13
import day06.main
import readInput
fun main() {
abstract class Packet : Comparable<Packet>
data class ListPacket(val contents: List<Packet>) : Packet() {
override fun compareTo(other: Packet): Int =
if (other is ListPacket) contents
.zip(other.contents, Packet... | 0 | Kotlin | 0 | 0 | 9cb653bd6a5abb214a9310f7cac3d0a5a478a71a | 2,396 | AOC2022 | Apache License 2.0 |
AdventOfCodeDay22/src/nativeMain/kotlin/Day22.kt | bdlepla | 451,510,571 | false | {"Kotlin": 165771} | class Day22(input: List<String>) {
private val cubes: List<Cuboid> = input.map { Cuboid.of(it) }
private val part1Cube = Cuboid(true, -50..50, -50..50, -50..50)
fun solvePart1(): Long =
solve(cubes.filter { it.intersects(part1Cube) })
fun solvePart2(): Long =
solve()
private fun ... | 0 | Kotlin | 0 | 0 | 1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871 | 2,037 | AdventOfCode2021 | The Unlicense |
src/Day15.kt | realpacific | 573,561,400 | false | {"Kotlin": 59236} | import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger
import kotlin.math.abs
private fun solveForX(coordinate1: Coordinate, coordinate2: Coordinate): (Int) -> Int {
return { y: Int ->
val slope = (coordinate2.second - coordinate1.second)... | 0 | Kotlin | 0 | 0 | f365d78d381ac3d864cc402c6eb9c0017ce76b8d | 5,810 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | chasebleyl | 573,058,526 | false | {"Kotlin": 15274} |
enum class RPS {
ROCK, PAPER, SCISSORS, UNKNOWN
}
fun RPS.scoreValue(): Int = when (this) {
RPS.ROCK -> 1
RPS.PAPER -> 2
RPS.SCISSORS -> 3
RPS.UNKNOWN -> 0
}
fun String.toRPS(): RPS = when (this) {
"A", "X" -> RPS.ROCK
"B", "Y" -> RPS.PAPER
"C", "Z" -> RPS.SCISSORS
else -> RPS.UNKNO... | 0 | Kotlin | 0 | 1 | f2f5cb5fd50fb3e7fb9deeab2ae637d2e3605ea3 | 2,316 | aoc-2022 | Apache License 2.0 |
src/Day05.kt | KarinaCher | 572,657,240 | false | {"Kotlin": 21749} | fun main() {
fun parseData(input: List<String>): Pair<Map<Int, MutableList<Char>>, MutableList<Move>> {
var stacks: Map<Int, MutableList<Char>> = mutableMapOf()
var moves = mutableListOf<Move>()
var boxes = mutableListOf<String>()
var moveRegex = Regex("move (\\d{1,2}) from (\\d) ... | 0 | Kotlin | 0 | 0 | 17d5fc87e1bcb2a65764067610778141110284b6 | 2,873 | KotlinAdvent | Apache License 2.0 |
src/main/day19/day19.kt | rolf-rosenbaum | 572,864,107 | false | {"Kotlin": 80772} | package day19
import day19.Resource.CLAY
import day19.Resource.GEODE
import day19.Resource.NONE
import day19.Resource.OBSIDIAN
import day19.Resource.ORE
import kotlin.math.max
import readInput
val regex = """.+ (\d+).+ (\d+) .+ (\d+) .+ (\d+) .+ (\d+) .+ (\d+).+ (\d+) .*""".toRegex()
fun main() {
val input = rea... | 0 | Kotlin | 0 | 2 | 59cd4265646e1a011d2a1b744c7b8b2afe482265 | 4,996 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc2016/TwoStepsForward.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2016
import komu.adventofcode.utils.Direction
import komu.adventofcode.utils.hexEncodedMd5Hash
import utils.shortestPath
fun twoStepsForward1(passcode: String): String =
shortestPath(State.initial, State::isGoal) { it.transitions(passcode) }!!.last().path
fun twoStepsForward2(passcod... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,649 | advent-of-code | MIT License |
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/TopKElements.kt | betulnecanli | 568,477,911 | false | {"Kotlin": 167849} | /*
The "Top 'K' Elements" coding pattern is often used to efficiently find the K smallest or largest elements in a collection.
*/
//1. ‘K’ Closest Points to the Origin
import java.util.PriorityQueue
data class Point(val x: Int, val y: Int)
fun kClosest(points: Array<Point>, k: Int): Array<Point> {
val result = m... | 2 | Kotlin | 2 | 40 | 70a4a311f0c57928a32d7b4d795f98db3bdbeb02 | 2,907 | Kotlin-Data-Structures-Algorithms | Apache License 2.0 |
Day20/src/Pluto.kt | gautemo | 225,219,298 | false | null | import java.io.File
import java.lang.Exception
import kotlin.math.abs
import kotlin.math.hypot
fun main(){
val input = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText()
val result = shortest(input)
println(result)
val resultWithDigging = shortest(input, true... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 4,478 | AdventOfCode2019 | MIT License |
src/Day08.kt | floblaf | 572,892,347 | false | {"Kotlin": 28107} | import kotlin.math.max
fun main() {
data class Tree(
val height: Int,
val left: List<Int>,
val right: List<Int>,
val top: List<Int>,
val bottom: List<Int>
)
fun Tree.findDistance(list: List<Int>): Int {
return list.indexOfFirst { it >= this.height }
... | 0 | Kotlin | 0 | 0 | a541b14e8cb401390ebdf575a057e19c6caa7c2a | 1,823 | advent-of-code-2022 | Apache License 2.0 |
src/day12/day.kt | LostMekka | 574,697,945 | false | {"Kotlin": 92218} | package day12
import util.Grid
import util.PathFindingMove
import util.PathFindingState
import util.Point
import util.findPath
import util.readInput
import util.shouldBe
import util.toGrid
fun main() {
val testInput = readInput(Input::class, testInput = true).parseInput()
testInput.part1() shouldBe 31
tes... | 0 | Kotlin | 0 | 0 | 58d92387825cf6b3d6b7567a9e6578684963b578 | 2,934 | advent-of-code-2022 | Apache License 2.0 |
src/main/Day10.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day10
import utils.readInput
private const val filename = "Day10"
fun part1(filename: String): Int =
readInput(filename)
.readProgram()
.signalStrengths()
.filterIndexed { index, _ -> index in 20..220 step 40 }
.sum()
fun part2(filename: String): String = readInput(filena... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 1,983 | aoc-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day16.kt | jntakpe | 572,853,785 | false | {"Kotlin": 72329, "Rust": 15876} | package com.github.jntakpe.aoc2022.days
import com.github.jntakpe.aoc2022.shared.Day
import com.github.jntakpe.aoc2022.shared.readInputLines
object Day16 : Day {
override val input = Terrain.from(readInputLines(16))
override fun part1() = dfs(30)
override fun part2() = dfs(26, part2 = true)
privat... | 1 | Kotlin | 0 | 0 | 63f48d4790f17104311b3873f321368934060e06 | 2,902 | aoc2022 | MIT License |
src/day07/Day07.kt | robin-schoch | 572,718,550 | false | {"Kotlin": 26220} | package day07
import AdventOfCodeSolution
fun main() {
Day07.run()
}
interface CalucalteSize {
val size: Long
}
data class File(val name: String, override val size: Long) : CalucalteSize
data class Directory(val parent: Directory?, val childDirectories: MutableMap<String, Directory>, val files: MutableList<... | 0 | Kotlin | 0 | 0 | fa993787cbeee21ab103d2ce7a02033561e3fac3 | 3,035 | aoc-2022 | Apache License 2.0 |
08/src/commonMain/kotlin/Main.kt | daphil19 | 725,415,769 | false | {"Kotlin": 131380} | expect fun getLines(): List<String>
fun main() {
var lines = getLines()
// part 1 test input
// lines = """RL
//
//AAA = (BBB, CCC)
//BBB = (DDD, EEE)
//CCC = (ZZZ, GGG)
//DDD = (DDD, DDD)
//EEE = (EEE, EEE)
//GGG = (GGG, GGG)
//ZZZ = (ZZZ, ZZZ)""".lines()
// part 2 test input
// lines = """LR
//
//... | 0 | Kotlin | 0 | 0 | 70646b330cc1cea4828a10a6bb825212e2f0fb18 | 2,384 | advent-of-code-2023 | Apache License 2.0 |
src/Day03.kt | EnyediPeti | 573,882,116 | false | {"Kotlin": 8717} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf {
val rucksack = convertToRucksack(it)
val item = findSameItem(rucksack)
getItemPriority(item)
}
}
fun part2(input: List<String>): Int {
return createElfGroupList(input).sumOf {... | 0 | Kotlin | 0 | 0 | 845ef2275540a6454a97a9e4c71f239a5f2dc295 | 2,150 | AOC2022 | Apache License 2.0 |
src/Day02.kt | Nplu5 | 572,211,950 | false | {"Kotlin": 15289} | import GameResult.DRAW
import GameResult.LOOSE
import GameResult.WIN
import Sign.Companion.fromString
fun main() {
fun part1(input: List<String>): Int {
return input.map { line ->
line.split(" ").let { playPairs ->
Game(fromString(playPairs[0]), fromString(playPairs[1]))
... | 0 | Kotlin | 0 | 0 | a9d228029f31ca281bd7e4c7eab03e20b49b3b1c | 3,742 | advent-of-code-2022 | Apache License 2.0 |
src/aoc2022/Day24.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2022
import utils.Vertex
import utils.checkEquals
private enum class Dir { UP, DOWN, LEFT, RIGHT }
private typealias Tracking = Pair<Int, Vertex>
private val Tracking.minutes get() = first
private val Tracking.pos get() = second
private data class Blizzard(private var _pos: Vertex, val dir: Dir, val bou... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 3,819 | Kotlin-AOC-2023 | Apache License 2.0 |
src/main/kotlin/com/sk/set0/39. Combination Sum.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set0
import java.util.*
// https://leetcode.com/problems/combination-sum/discuss/16502/A-general-approach-to-backtracking-questions-in-Java-(Subsets-Permutations-Combination-Sum-Palindrome-Partitioning)
class Solution39 {
fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> {
... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,385 | leetcode-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/com/github/fstaudt/aoc2021/day3/Day3.kt | fstaudt | 433,733,254 | true | {"Kotlin": 9482, "Rust": 1574} | package com.github.fstaudt.aoc2021.day3
import com.github.fstaudt.aoc2021.day3.Day3.BinaryCounter.Companion.toBinaryCounter
import com.github.fstaudt.aoc2021.shared.Day
import com.github.fstaudt.aoc2021.shared.readInputLines
fun main() {
Day3().run()
}
class Day3 : Day {
override val input = readInputLines(3... | 0 | Kotlin | 0 | 0 | f2ee9bca82711bc9aae115400ecff6db5d683c9e | 2,258 | aoc2021 | MIT License |
src/com/kingsleyadio/adventofcode/y2023/Day08.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.lcm
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val (directions, network) = readInput(2023, 8).useLines { sequence ->
val lines = sequence.iterator()
val directions = lines.next()
lin... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,685 | adventofcode | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.