path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/Day03.kt
arturradiuk
571,954,377
false
{"Kotlin": 6340}
fun findRepeatedChar(first: String, second: String): Int { first.toCharArray().map { char -> if (second.find { it == char } != null) return char.mapToPoints() } throw Error() } fun findRepeatedChar(first: String, second: String, third: String): Int { first.toCharArray().map { char -> va...
0
Kotlin
0
0
85ef357643e5e4bd2ba0d9a09f4a2d45653a8e28
1,114
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2023/Day01.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2023 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part1A : PartSolution() { internal lateinit var texts: List<String> override fun parseInput(text: String) { texts = text.trim().split("\n") } override fun getExampleAn...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,117
advent-of-code-kotlin
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2017/2017-07.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2017 fun main() { println("Part1+2:") println(solve(testInput1)) println(solve(input)) } private fun solve(input: String): Pair<String, Int> { val programs = input.lines().map { val (name, weight, above) = regex.matchEntire(it)!!.destructured ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
25,297
advent-of-code
MIT License
2021/src/day18/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day18 import java.nio.file.Files import java.nio.file.Paths fun main() { fun part1(input: Input): Int { return input.reduce { acc, snailfish -> SnailfishPair(acc, snailfish).reduce() }.magnitude() } fun part2(input: Input): Int { return input.maxOf { lhs -> input.maxOf { rhs -> ...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
3,633
advent-of-code
Apache License 2.0
src/Day09.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
import kotlin.math.sign fun main() { fun Point.isAdjacent(other: Point): Boolean = x - other.x in -1..1 && y - other.y in -1..1 fun Point.move(direction: String): Point = when (direction) { "L" -> left() "R" -> right() "U" -> up() "D" -> down() else -> throw I...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
2,036
advent-of-code-2022
Apache License 2.0
src/Day05.kt
ajesh-n
573,125,760
false
{"Kotlin": 8882}
fun main() { fun stakes(stakesString: String): MutableList<MutableList<String>> { val stakes = mutableListOf<MutableList<String>>() val crates = stakesString.lines().map { it.windowed(3, 4).map { line -> line.filter { char -> char.isLetter() } } }.dropLast(1).reversed() f...
0
Kotlin
0
0
2545773d7118da20abbc4243c4ccbf9330c4a187
2,111
kotlin-aoc-2022
Apache License 2.0
2021/src/Day12.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/12 fun main() { class Graph(vertexes: Set<String>, edges: List<Pair<String, String>>) { val edges = edges val bigCaves = vertexes.filter { isBigCave(it) } val smallCaves = vertexes.filter { !isBigCave(it) } val START = "start" val END = "en...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
2,244
advent-of-code
Apache License 2.0
src/Day03.kt
ben-dent
572,931,260
false
{"Kotlin": 10265}
fun getIntersection(input: String): Set<Char> { val mid = input.length / 2 val first = input.substring(0, mid).toSet() val second = input.substring(mid).toSet() return first.intersect(second) } fun getIntersection(input: List<String>): Set<Char> { val first = input[0].toSet() val second = inp...
0
Kotlin
0
0
2c3589047945f578b57ceab9b975aef8ddde4878
1,539
AdventOfCode2022Kotlin
Apache License 2.0
leetcode2/src/leetcode/palindrome-partitioning.kt
hewking
68,515,222
false
null
package leetcode /** * 131. 分割回文串 * https://leetcode-cn.com/problems/palindrome-partitioning/ * 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回 s 所有可能的分割方案。 示例: 输入: "aab" 输出: [ ["aa","b"], ["a","a","b"] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/palindrome-partitioning 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,463
leetcode
MIT License
src/main/kotlin/com/ginsberg/advent2018/Day15.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 15 - Beverage Bandits * * Problem Description: http://adventofcode.com/2018/day/15 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day15/ */ package com.ginsberg.advent2018 import java.util.ArrayDeque import java.uti...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
6,658
advent-2018-kotlin
MIT License
src/Day02.kt
jimmymorales
572,156,554
false
{"Kotlin": 33914}
fun main() { fun part1(input: List<String>): Int = input.sumOf { val s1 = it.first() - 'A' + 1 val s2 = it.last() - 'X' + 1 when { s2 == s1 -> 3 + s2 (s2 == 3 && s1 == 2) || (s2 == 2 && s1 == 1) || (s2 == 1 && s1 == 3) -> 6 + s2 el...
0
Kotlin
0
0
fb72806e163055c2a562702d10a19028cab43188
938
advent-of-code-2022
Apache License 2.0
src/Day05.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
data class Move( val numCrates: Int, val fromStack: Int, val toStack: Int ) fun main() { fun parseStacks(input: List<String>): List<ArrayDeque<Char>> { val stackNumbersLineRegex = "(\\d|\\s)+".toRegex() val stackNumbersLineIndex = input.indexOfFirst { stackNumbersLineRegex.matches(it) }...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
3,075
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/main/kotlin/day14/Day14.kt
Arch-vile
317,641,541
false
null
package day14 import readFile import utils.subsets import java.lang.Long.parseLong import kotlin.math.pow interface Command data class MaskCommand(val mask: String) : Command data class MemoryCommand(val address: Long, val value: Long) : Command data class Memory(val data: MutableMap<Long, Long> = mutableMapOf()) { ...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
2,269
adventOfCode2020
Apache License 2.0
src/Day04.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
import kotlin.system.measureNanoTime data class SectionRange( val startSection : Int, val endSection: Int ) fun SectionRange.isFullyContained(other: SectionRange): Boolean { return (this.startSection >= other.startSection && this.endSection <= other.endSection) || (this.startSection <= other.s...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
1,421
aoc-2022
Apache License 2.0
src/main/kotlin/days/Solution10.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.Point2D import adventOfCode.util.plus import kotlin.math.abs typealias CharGrid = Array<CharArray> private operator fun CharGrid.get(point: Point2D) = this[point.first][point.second] pr...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
3,067
Advent-of-Code-2023
MIT License
src/Day03.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
import utils.readInputAsLines fun String.firstHalf(): String { return this.substring(0, this.length / 2) } fun String.secondHalf(): String { return this.substring(this.length / 2, this.length) } fun scoreLetter(letter: Char): Int { if (letter in 'A'..'Z') { return letter.code - 'A'.code + 27 ...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
1,550
2022-AOC-Kotlin
Apache License 2.0
src/Day12.kt
freszu
573,122,040
false
{"Kotlin": 32507}
import java.util.* private const val START = 'S' private const val END = 'E' fun main() { fun Matrix<Char>.dijkstraShortestPathLength( start: Position, end: Position ): Int? { val toBeEvaluated = PriorityQueue<Pair<Position, Int>>(compareBy { (_, distance) -> distance }) toBeE...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
1,962
aoc2022
Apache License 2.0
src/Day18.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.util.* import kotlin.math.abs data class Cube(val x: Int, val y: Int, val z: Int) fun main() { fun String.toCube(): Cube { val (x, y, z) = this.split(",").map { it.toInt() } return Cube(x + 1, y + 1, z + 1) } fun nextTo(a: Cube, b: Cube): Boolean { return abs(a.x - b.x...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
3,293
aoc-2022-in-kotlin
Apache License 2.0
src/day09/Day09.kt
TheJosean
573,113,380
false
{"Kotlin": 20611}
package day09 import readInput import kotlin.math.absoluteValue import kotlin.math.min fun main() { data class Coordinate(var x: Int, var y: Int) fun getMotions(direction: String, amount: Int): List<Coordinate> { val motions = when (direction) { "R" -> (1..amount).map { Coordinate(1, 0) ...
0
Kotlin
0
0
798d5e9b1ce446ba3bac86f70b7888335e1a242b
2,200
advent-of-code
Apache License 2.0
src/main/kotlin/Day03.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
fun main() { fun findCommonChar(firstCompartment: CharSequence, secondCompartment: CharSequence): Char { for (cFirst in firstCompartment) { for (cSecond in secondCompartment) { if (cFirst == cSecond) { return cFirst } } } ...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
1,989
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Solution12.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf import adventOfCode.util.TripleOf import adventOfCode.util.ints typealias Hotspring = Pair<String, List<Int>> object Solution12 : Solution<List<Hotspring>>(AOC_YEAR, 12) { override fun getInput(handler: Inp...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
1,964
Advent-of-Code-2023
MIT License
src/main/kotlin/days/model/Almanac.kt
errob37
726,532,024
false
{"Kotlin": 29748, "Shell": 408}
package days.model data class Almanac( val input: List<String>, val seedMode: SeedMode, ) { private val seeds = extractSeed() private val resourceMaps = extractResourceMaps() private var chainMap: List<ResourceMap>? = null fun getMinimumLocation(): Long { ensureChainMap() retu...
0
Kotlin
0
0
79db6f0f56d207b68fb89425ad6c91667a84d60f
3,976
adventofcode-2023
Apache License 2.0
src/main/kotlin/day20/Day20.kt
Jessevanbekkum
112,612,571
false
null
package day20 import util.readLines import java.lang.Math.abs fun day20_1(input: String): Int { val particles = readLines(input).mapIndexed { i, s -> Particle(i, s) }.toMutableList() (0..1_000).forEach { particles.forEach { it.step() } } return particles.minBy { p -> p.sum() }!!.nr } fun da...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
2,432
aoc-2017
Apache License 2.0
2022/src/main/kotlin/com/github/akowal/aoc/Day09.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc import com.github.akowal.aoc.Direction.D import com.github.akowal.aoc.Direction.L import com.github.akowal.aoc.Direction.R import com.github.akowal.aoc.Direction.U import kotlin.math.abs import kotlin.math.sign class Day09 { private val headRoute = inputFile("day09").readLines().flat...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
1,657
advent-of-kode
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/timakden/aoc/year2022/Day18.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day18.VoxelWorld.Voxel /** * [Day 18: Boiling Boulders](https://adventofcode.com/2022/day/18). */ object Day18 { @JvmStatic fun main(args: Array<String>) { measu...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
3,709
advent-of-code
MIT License
src/main/kotlin/dp/LBSubstring.kt
yx-z
106,589,674
false
null
package dp import util.* // given A[1..n] composed of '[', ']', '(', ')', ex. A = ([]])() // find the length of // longest balanced subsequence of A, i.e. matching parenthesis/brackets // ex. ([] )() -> 6 in the example above fun main(args: Array<String>) { val A = "([]])()".toCharOneArray() println(A.lbs()) // 6 }...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,555
AlgoKt
MIT License
src/main/kotlin/dev/bogwalk/batch0/Problem1.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch0 import dev.bogwalk.util.maths.gaussSum import dev.bogwalk.util.maths.lcm /** * Problem 1: Multiples of 3 or 5 * * https://projecteuler.net/problem=1 * * Goal: Find the sum of all natural numbers less than N that are multiples of either of the * provided factors K1 or K2. * * Constra...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,879
project-euler-kotlin
MIT License
src/Day03.kt
atsvetkov
572,711,515
false
{"Kotlin": 10892}
fun main() { fun Char.priority() = when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> 0 } fun part1(input: List<String>): Int { return input.sumOf { line -> val size = line.length val wrongItems = line.substring(0, size...
0
Kotlin
0
0
01c3bb6afd658a2e30f0aee549b9a3ac4da69a91
1,019
advent-of-code-2022
Apache License 2.0
Array/huangxinyu/kotlin/src/MergeSortedArray.kt
JessonYue
268,215,243
false
null
package com.ryujin.algorithm /** * 给定两个排序后的数组 A 和 B,其中 A 的末端有足够的缓冲空间容纳 B。 编写一个方法,将 B 合并入 A 并排序。 初始化 A 和 B 的元素数量分别为 m 和 n。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/sorted-merge-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 */ class MergeSortedArray { companion object { /** * a[0]<b[0] ...
0
C
19
39
3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79
3,044
LeetCodeLearning
MIT License
src/aoc22/Day02.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc22.day02 import aoc22.day02.GameResult.DRAW import aoc22.day02.GameResult.LOSS import aoc22.day02.GameResult.WIN import aoc22.day02.Hand.PAPER import aoc22.day02.Hand.ROCK import aoc22.day02.Hand.SCISSOR import lib.Solution import lib.Solution.Part import lib.Solu...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,447
aoc-kotlin
Apache License 2.0
day-18/src/main/kotlin/Snailfish.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
8,695
aoc-2021
MIT License
src/main/kotlin/Day02.kt
jcornaz
573,137,552
false
{"Kotlin": 76776}
object Day02 { private val plays = Play.values().asSequence() private val results = Result.values().asSequence() enum class Play(val symbol: String, val score: Int) { Rock("A", 1), Paper("B", 2), Scissors("C", 3), } enum class Result(val symbol: String, val score: Int) { ...
1
Kotlin
0
0
979c00c4a51567b341d6936761bd43c39d314510
1,903
aoc-kotlin-2022
The Unlicense
src/ad/kata/aoc2021/day11/Octopuses.kt
andrej-dyck
433,401,789
false
{"Kotlin": 161613}
package ad.kata.aoc2021.day11 import ad.kata.aoc2021.PuzzleInput import ad.kata.aoc2021.types.* class Octopuses(val energyLevels: Matrix<EnergyLevel>) { fun countFlashes() = energyLevels.flatten().count(EnergyLevel::hasFlashed) fun timeProjection() = generateSequence(this) { it.increaseEnerg...
0
Kotlin
0
0
28d374fee4178e5944cb51114c1804d0c55d1052
1,729
advent-of-code-2021
MIT License
src/Day05.kt
eo
574,058,285
false
{"Kotlin": 45178}
// https://adventofcode.com/2022/day/5 fun main() { fun parseInput(input: String): Pair<CrateStacks, List<Move>> { val (drawingStr, movesStr) = input.split("\n\n") val crateStacks = CrateStacks.fromDrawing(drawingStr) val moves = movesStr.lines().map(Move::fromString) return crateSt...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
2,885
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
remidu
573,452,090
false
{"Kotlin": 22113}
import Result.* import Shape.* enum class Shape(val code1: String, val code2: String, val points: Int) { ROCK("A", "X", 1), PAPER("B", "Y", 2), SCISSORS("C", "Z", 3); companion object { infix fun of(code: String): Shape { return values().first { it.code1 == code || it.code2 == code...
0
Kotlin
0
0
ecda4e162ab8f1d46be1ce4b1b9a75bb901bc106
2,451
advent-of-code-2022
Apache License 2.0
src/Day09.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
import kotlin.math.abs fun main() { data class Point(val x: Int, val y: Int) { fun isTouching(other: Point) = other.x in (x-1)..(x+1) && other.y in (y-1)..(y+1) fun add(other: Point) = Point(other.x + x, other.y + y) } data class MoveInstruction(val vector: Point, val magnitude: Int) ...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
3,417
advent-of-code-2022
Apache License 2.0
kotlin/strings/SuffixArray.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package strings import java.util.stream.IntStream // https://en.wikipedia.org/wiki/Suffix_array object SuffixArray { // build suffix array in O(n*log(n)) fun suffixArray(S: CharSequence): IntArray { val n: Int = S.length() // Stable sort of characters. // Same characters are sorted by...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
4,985
codelibrary
The Unlicense
src/year2022/day20/Day20.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day20 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { data class Node(var value: Long, var previous: Node? = null, var next: Node? = null) { override fun toString(): String = "$value, previous:${previous?.value}, next:${next?.value}" } fun mix(node...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
2,424
advent-of-code-kotlin
Apache License 2.0
src/UselessStuff.kt
isaiahhyun
574,590,804
false
{"Kotlin": 11744}
fun main() { val input = readInput("sentences") println("Pairs: ${findThingy(input)}") } fun sumAllNums(input: List<String>): Int { // var total = 0 // for(num in input){ // total+= num.toInt() // } // return total return input.map { it.toInt() }.sum() } fun findMin(input: L...
0
Kotlin
0
0
b6092180cd202f5bf24efb0fa97c7a20b1b934c3
10,663
AdventOfCode2022IH
Apache License 2.0
src/main/kotlin/day16/Code.kt
fcolasuonno
317,324,330
false
null
package day16 import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/main/kotlin/$dir/$name").readLines() val parsed = parse(input) part1(parsed) part2(...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
2,286
AOC2020
MIT License
src/day07/Day07.kt
Harvindsokhal
572,911,840
false
{"Kotlin": 11823}
package day07 import readInput private data class Directory( val name: String, val parent: Directory? = null, val dirs: MutableList<Directory> = mutableListOf(), val files: MutableList<File> = mutableListOf() ) { fun allDirs(): List<Directory> = dirs + dirs.flatMap { it.allDirs() } fun size():...
0
Kotlin
0
0
7ebaee4887ea41aca4663390d4eadff9dc604f69
1,503
aoc-2022-kotlin
Apache License 2.0
leetcode/src/daily/hard/Q927.kt
zhangweizhe
387,808,774
false
null
package daily.hard fun main() { // 927. 三等分 // https://leetcode.cn/problems/three-equal-parts/ println(threeEqualParts(intArrayOf(0,0,0,0,0)).contentToString()) } fun threeEqualParts(arr: IntArray): IntArray { // 一个满足题意的数组,1 的数量应该是 3 的整数倍,且每一份中,1的数量是一样的 // 所以可以先计算数组的和,如果不能被 3 整数,那肯定不符合题意 val ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,125
kotlin-study
MIT License
src/Day18.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day18 { fun part1(input: Set<Point3D>): Int { return input.sumOf { 6 - it.neighbors().count { neighbor -> neighbor in input } } } private fun Set<Point3D>.rangeOf(function: (Point3D) -> Int): IntRange = this.minOf(function) - 1..this.max...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
1,611
aoc-22-kotlin
Apache License 2.0
app/src/main/java/com/example/arknightsautoclicker/processing/tasks/recruitment/TagAnalyzer.kt
qwerttyuiiop1
684,537,002
false
{"Kotlin": 142059}
package com.example.arknightsautoclicker.processing.tasks.recruitment import com.example.arknightsautoclicker.processing.ext.norm class TagAnalyzer( private val data: Set<CharTag> = TagData().characters ) { val availableTagsNorm: Set<String> = data.flatMapTo(mutableSetOf()) { it.tags_norm } data c...
1
Kotlin
0
1
4c7ca55be02c08d1784bac57b3eff15decd07389
2,510
Arknights-Autoclicker
MIT License
src/Day03.kt
eps90
574,098,235
false
{"Kotlin": 9738}
import kotlin.math.ceil fun String.splitInHalf(): List<String> = chunked(ceil(length.toDouble() / 2).toInt()) private val priorities = (('a'..'z') + ('A'..'Z')).withIndex().associateBy({ it.value }) { it.index + 1 } fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> ...
0
Kotlin
0
0
bbf58c512fddc0ef1112c3bee5e5c6d43f5aabc0
985
advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/constantTime/iteration5/MinBracketTaxCalculator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package solutions.constantTime.iteration5 import dataModel.v3.AccumulatedTaxBracketV2 import dataModel.v3.AccumulatedTaxBracketV2.Companion.toAccumulatedBracketsV2 import dataModel.base.Money import dataModel.base.Money.Companion.cents import dataModel.base.TaxBracket import dataModel.base.TaxCalculator import solutio...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
2,801
tax-calculator
MIT License
src/main/kotlin/it/battagliandrea/advent/of/code/day3/models.kt
battagliandrea
726,559,484
false
{"Kotlin": 20889}
package it.battagliandrea.advent.of.code.day3 import it.battagliandrea.advent.of.code.utils.readLines import kotlin.math.abs data class Cell(val x: Int, val y: Int) fun Cell.neighbours(other: Cell) = abs(x - other.x) <= 1 && abs(y - other.y) <= 1 sealed class Entity(val cells: List<Cell>) fun Entity.neighbours...
0
Kotlin
0
0
588e3da810e2b0ff62a70cbb4c33604e37a18b88
2,361
AdventOfCode2023
Apache License 2.0
2015/src/main/kotlin/day16.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parse import utils.Parser import utils.Solution import utils.mapItems fun main() { Day16.run() } object Day16 : Solution<List<Day16.Sue>>() { override val name = "day16" override val parser = Parser.lines.mapItems { parseSue(it) } @Parse("Sue {id}: {r ', ' items}") data class Sue( val id: ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,730
aoc_kotlin
MIT License
src/day23/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day23 import util.Point import util.boundingRect import util.readInput import util.shouldBe import java.util.LinkedList fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe 110 testInput.part2() shouldBe 20 val input = readInput(Input:...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
2,542
advent-of-code-2022
Apache License 2.0
src/Day03.kt
roxspring
573,123,316
false
{"Kotlin": 9291}
fun main() { fun Char.priority(): Int = when (this) { in 'a'..'z' -> code - 'a'.code + 1 in 'A'..'Z' -> code - 'A'.code + 26 + 1 else -> throw Exception("WTF? $this") } fun String.uniqueCharactersInCommonWith(other: String): String = toCharArray().filter { other.contains(it...
0
Kotlin
0
0
535beea93bf84e650d8640f1c635a430b38c169b
1,166
advent-of-code-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2023/Day13.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import kotlin.math.absoluteValue /** * [Day 13: Point of Incidence](https://adventofcode.com/2023/day/13). */ object Day13 { @JvmStatic fun main(args: Array<String>) { measure { val...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,266
advent-of-code
MIT License
src/Day07.kt
robinpokorny
572,434,148
false
{"Kotlin": 38009}
data class Directory( val name: String, val parent: Directory?, var size: Int? = null, val dirs: MutableList<Directory> = mutableListOf(), val files: MutableMap<String, Int> = mutableMapOf() ) sealed class TerminalOutput { class CD(val path: String) : TerminalOutput() class File(val name: ...
0
Kotlin
0
2
56a108aaf90b98030a7d7165d55d74d2aff22ecc
2,885
advent-of-code-2022
MIT License
src/day16/Day16.kt
spyroid
433,555,350
false
null
package day16 import com.github.ajalt.mordant.terminal.Terminal import readInput import kotlin.system.measureTimeMillis class Decoder(input: String) { data class Packet(val version: Int, val type: Int) { val packets = mutableListOf<Packet>() var value = 0L fun getAllVersions(): List<Int...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
3,505
Advent-of-Code-2021
Apache License 2.0
src/main/kotlin/PartitionArrayForMaximumSum.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. * After partitioning, each subarray has their values changed to become the maximum value of that subarray. * * Return the largest sum of the given array after partitioning. * Test cases are generated so that the ...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,487
kotlin-codes
Apache License 2.0
src/Day08.kt
jmorozov
573,077,620
false
{"Kotlin": 31919}
fun main() { val inputData = readInput("Day08") part1(inputData) part2(inputData) } private fun part1(inputData: List<String>) { var visibleTrees = 0 val (rows, cols) = buildGrid(inputData) for ((rowIdx, row) in rows.withIndex()) { if (rowIdx == 0 || rowIdx == rows.lastIndex) { ...
0
Kotlin
0
0
480a98838949dbc7b5b7e84acf24f30db644f7b7
3,219
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/day20/Day20.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day20 import execute import readAllText private class Elem(val v: Long) { override fun toString() = v.toString() } private fun List<Elem>.process(e: Elem): List<Elem> { val oldIdx = withIndex().single { it.value == e }.index val newResult = subList(oldIdx + 1, size) + subList(0, oldIdx) + subList...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
1,429
advent-of-code-2022
MIT License
kotlin/src/com/leetcode/222_CountCompleteTreeNodes.kt
programmerr47
248,502,040
false
null
package com.leetcode import com.leetcode.data.TreeNode import com.leetcode.data.treeNode import com.sun.source.tree.Tree import java.util.* /** * In leetcode there is much more concise and elegant solution. * So beware of my big, but still fast one :) * * The algorithm is next: * * 1. find the max possible dept...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
5,294
problemsolving
Apache License 2.0
src/Day03.kt
epishkin
572,788,077
false
{"Kotlin": 6572}
fun main() { fun priority(element: Char): Int { val offset = if (element.isUpperCase()) 'A'.code - 27 else 'a'.code - 1 return element.code - offset } fun part1(input: List<String>): Int { return input .map { val h...
0
Kotlin
0
0
e5e5755c2d77f75750bde01ec5aad70652ef4dbf
1,228
advent-of-code-2022
Apache License 2.0
src/Day21.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
data class YellingMonkey( val name: String, val number: Long?, val operator: Operator?, val waitingForMonkeys: List<String>, ) enum class Operator(val value: Char) { Add('+'), Substract('-'), Multiply('*'), Divide('/'), } fun main() { fun List<String>.toYellingMonkeys(): List<Yell...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
2,993
AdventOfCode2022
Apache License 2.0
src/Day14.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
data class Position(val x: Int, val y: Int) fun Position.below() = Position(x, y + 1) fun Position.left() = Position(x - 1, y + 1) fun Position.right() = Position(x + 1, y + 1) fun createOccupiedSet(paths: List<List<Position>>): MutableSet<Position> { return buildSet { paths.forEach { path -> ...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
2,881
advent-of-code-2022
Apache License 2.0
src/year2022/day07/Day07.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day07 import readInputFileByYearAndDay import readTestFileByYearAndDay import java.util.* operator fun Regex.contains(text: CharSequence): Boolean = this.matches(text) fun main() { data class File(val name: String, val size: Int) class Folder(val name: String = "/", val parent: Folder? = ...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
2,885
advent-of-code-kotlin
Apache License 2.0
src/Day12.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
import java.util.* import kotlin.time.ExperimentalTime data class StepPos(val x: Int, val y: Int) fun StepPos.linearPos(input: List<String>): Int = y * input.first().length + x data class StepAndCost(val step: StepPos, val cost: Long) : Comparable<StepAndCost> { override fun compareTo(other: StepAndCost): Int { ...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
4,155
aoc2022
Apache License 2.0
src/main/kotlin/aoc2019/TheNBodyProblem.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.choosePairs import komu.adventofcode.utils.lcm3 import kotlin.math.abs fun nBodyProblem(moons: List<Moon>, steps: Int): Int { val pairs = moons.choosePairs() repeat(steps) { for ((m1, m2) in pairs) { m1.applyGravity(m2) ...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,950
advent-of-code
MIT License
src/day_11/kotlin/Day11.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
data class Monkey( val itemWrorryLevels: MutableList<Long>, val wrorryOperation: (Long) -> Long, val testDivisor: Int, val throwToTestSuccess: Int, val throwToTestFailed: Int ) { fun inspectItem() { itemWrorryLevels[0] = wrorryOperation(itemWrorryLevels[0]) } fun throwItem(monke...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
3,693
AdventOfCode2022
MIT License
src/Day25.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.math.BigInteger fun snafuToDecimal(snafu: String): BigInteger { var base = 1.toBigInteger() var sum = 0.toBigInteger() for (digit in snafu.reversed()) { val number = when (digit) { '=' -> -2 '-' -> -1 '1' -> 1 '0' -> 0 '2' -> 2...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
2,341
advent-of-code-2022
Apache License 2.0
gcj/y2020/round1a/c_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1a private fun solve(): Long { val (hei, wid) = readInts() val a = List(hei) { readInts().toIntArray() } var ans = 0L while (true) { val eliminated = mutableListOf<Pair<Int, Int>>() for (x in 0 until hei) for (y in 0 until wid) if (a[x][y] > 0) { fun nei(d: Int): Int? { var xx = x...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,077
competitions
The Unlicense
src/poyea/aoc/mmxxii/day19/Day19.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day19 import java.util.PriorityQueue import kotlin.math.ceil import kotlin.math.max import poyea.aoc.utils.readInput class Factory(val blueprint: Blueprint, val minutes: Int) { fun search(): Int { var max = 0 val queue = PriorityQueue<State>() queue.add(State(minut...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
4,536
aoc-mmxxii
MIT License
src/Day04/Day04.kt
rooksoto
573,602,435
false
{"Kotlin": 16098}
package Day04 import profile import readInputActual import readInputTest private const val DAY = "Day04" fun main() { fun part1(input: List<String>): Int = toFormattedSectionLists(input) .count { it.first.containsAll(it.second) || it.second.containsAll(it.first) } ...
0
Kotlin
0
1
52093dbf0dc2f5f62f44a57aa3064d9b0b458583
1,772
AoC-2022
Apache License 2.0
src/Day02.kt
JIghtuse
572,807,913
false
{"Kotlin": 46764}
import java.lang.IllegalStateException enum class Shape { Rock, Paper, Scissors } fun opponentInputToShape(s: String): Shape = when (s) { "A" -> Shape.Rock "B" -> Shape.Paper "C" -> Shape.Scissors else -> throw IllegalStateException("invalid opponent input $s") } f...
0
Kotlin
0
0
8f33c74e14f30d476267ab3b046b5788a91c642b
2,358
aoc-2022-in-kotlin
Apache License 2.0
leetcode/src/offer/Offer61.kt
zhangweizhe
387,808,774
false
null
package offer fun main() { // 剑指 Offer 61. 扑克牌中的顺子 // https://leetcode-cn.com/problems/bu-ke-pai-zhong-de-shun-zi-lcof/ println(isStraight2(intArrayOf(1,2,5,0,3))) } /** * 排序,遍历排序后的数组 * 计算 0 的数量 zeroCount * 遍历到非0元素时:1)如果 nums[i] == nums[i+1],则 return false * 2)如果 nums[i+1] - nums[i] > 1, * 说明相邻的两个数不...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,073
kotlin-study
MIT License
src/main/kotlin/io/github/mikaojk/day3/part2/day3Part2.kt
MikAoJk
573,000,620
false
{"Kotlin": 15562}
package io.github.mikaojk.day3.part2 import io.github.mikaojk.common.getFileAsString import java.util.Locale fun day3Part2(): Int { val rucksacksItems = getFileAsString("src/main/resources/day3/rucksacksItems.txt") val rucksacks = rucksacksItems.split("\\n".toRegex()).mapIndexed { index, rucksacksItems -> ...
0
Kotlin
0
0
eaa90abc6f64fd42291ab42a03478a3758568ecf
2,297
aoc2022
MIT License
src/main/kotlin/days/Day8Solution.kt
yigitozgumus
434,108,608
false
{"Kotlin": 17835}
package days import BaseSolution class Day8Solution(inputList: List<String>) : BaseSolution(inputList) { val signals = inputList.map { it.split("|").first().split(" ").filterNot { it == "" }.map { it.trim() } } private val output = inputList.map { it.split("|")[1].split(" ").filterNot { it == "" }.map...
0
Kotlin
0
0
c0f6fc83fd4dac8f24dbd0d581563daf88fe166a
2,501
AdventOfCode2021
MIT License
src/Day09.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
import kotlin.math.abs import kotlin.math.max import kotlin.math.sign fun main() { fun follow(t: Pair<Int, Int>, h: Pair<Int, Int>) = t.first + (h.first - t.first).sign to t.second + (h.second - t.second).sign fun List<String>.simulate(n: Int): Int { val rope = Array(n) { 0 to 0 } val...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
1,575
aockt
Apache License 2.0
src/main/kotlin/aoc2023/Day19.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.InputUtils val parseRule = "(([xmas])([><])(\\d+):)?([a-zAR]+)".toRegex() val parseWorkflow = "([a-z]+)\\{(($parseRule,?)+)}".toRegex() val parsePresent = "\\{x=(\\d+),m=(\\d+),a=(\\d+),s=(\\d+)}".toRegex() private data class Rule(val field: Char?, val test: Char?, val comparison: Int?, ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
5,062
aoc-2022-kotlin
Apache License 2.0
src/day03/Day03.kt
tobihein
569,448,315
false
{"Kotlin": 58721}
package day03 import readInput class Day03 { fun part1(): Int { val readInput = readInput("day03/input") return part1(readInput) } fun part2(): Int { val readInput = readInput("day03/input") return part2(readInput) } fun part1(input: List<String>): Int = input.map...
0
Kotlin
0
0
af8d851702e633eb8ff4020011f762156bfc136b
1,586
adventofcode-2022
Apache License 2.0
src/Day09.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 114 private const val EXPECTED_2 = 2 private class Day09(isTest: Boolean) : Solver(isTest) { fun part1() = readAsLines().sumOf { line -> val numbers = line.splitInts() val lineLists = mutableListOf(numbers) while (true) { val newLine = lineLists.la...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,523
advent-of-code-2022
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day11.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.main import eu.michalchomo.adventofcode.toCharMatrix import kotlin.math.max import kotlin.math.min object Day11 : Day { override val number: Int = 11 override fun part1(input: List<String>)...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,062
advent-of-code
Apache License 2.0
src/main/kotlin/Day07.kt
goblindegook
319,372,062
false
null
package com.goblindegook.adventofcode2020 import com.goblindegook.adventofcode2020.extension.toIntOr import com.goblindegook.adventofcode2020.input.load fun main() { val rules = load("/day07-input.txt") println(containerTypeCount(rules, "shiny gold")) println(bagCount(rules, "shiny gold")) } fun containe...
0
Kotlin
0
0
85a2ff73899dbb0e563029754e336cbac33cb69b
1,659
adventofcode2020
MIT License
src/main/kotlin/be/tabs_spaces/advent2021/days/Day08.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import be.tabs_spaces.advent2021.days.Day08.SevenSegmentNumber.* class Day08 : Day(8) { companion object { val uniqueSegments = listOf(ONE, FOUR, SEVEN, EIGHT) val uniqueSegmentLengths = uniqueSegments.map { it.segments } } override fun partOne() = ...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
3,347
advent-2021
Creative Commons Zero v1.0 Universal
src/Day09.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
import Direction.* fun main() { fun part1(input: List<String>): Int { val motions = input.toMotions() var head = Position(0, 0) var tail = head //Unique positions, containing the starting position val uniquePositions: MutableSet<Position> = mutableSetOf(tail) moti...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
3,987
advent-of-code-2022
Apache License 2.0
src/day7/Day07.kt
dean95
571,923,107
false
{"Kotlin": 21240}
package day7 import readInput import kotlin.math.min private fun main() { fun extractDirectories(input: List<String>): Directory { val rootDir = Directory("/") val dirs = ArrayDeque<Directory>() input.forEach { line -> if (line.first() == '$') { val parts = lin...
0
Kotlin
0
0
0ddf1bdaf9bcbb45116c70d7328b606c2a75e5a5
3,623
advent-of-code-2022
Apache License 2.0
src/Day02.kt
maquirag
576,698,073
false
{"Kotlin": 3883}
fun main() { val day = "02" fun moveScore(move: Char): Int = mapOf('A' to 1, 'B' to 2, 'C' to 3)[move]!! fun gameScore(p1: Char, p2: Char) = when (p2 - p1) { 0 -> 3 1, -2 -> 6 else -> 0 } fun determineMove(p1: Char, strategy: Char): Char = when (strategy) { ...
0
Kotlin
0
0
23403172e909f8fb0c87e953d06fc0921c75fc32
1,371
aoc2022-kotlin
Apache License 2.0
src/Day09.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
import kotlin.math.abs fun main() { val dx = mapOf( 'U' to 0, 'D' to 0, 'L' to -1, 'R' to 1 ) val dy = mapOf( 'U' to 1, 'D' to -1, 'L' to 0, 'R' to 0 ) fun part1(input: List<String>): Int { var curHead = 0 to 0 var cur...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
2,626
advent-of-code-2022
Apache License 2.0
src/day05/Day05.kt
zoricbruno
573,440,038
false
{"Kotlin": 13739}
package day05 import readInput import java.util.* import kotlin.collections.HashMap fun findSpacer(input: List<String>): Int { var blank_index = 0 while (input[blank_index] != "") blank_index++ return blank_index } fun extractNumbersFromString(input: String): List<Int> { return Regex("[0-9]+"...
0
Kotlin
0
0
16afa06aff0b6e988cbea8081885236e4b7e0555
2,766
kotlin_aoc_2022
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day11/MonkeyInTheMiddle.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day11 import com.barneyb.aoc.util.* import com.barneyb.util.IntPair import com.barneyb.util.Queue import kotlin.text.toLong fun main() { Solver.execute( ::parse, ::partOne, ::partTwo, // 15310845153 ) } data class Monkey( val items: Queue<Long>, ...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
2,894
aoc-2022
MIT License
advent-of-code-2023/src/Day21.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
import lib.matrix.Matrix import lib.matrix.Position import lib.matrix.contains import lib.matrix.get private const val DAY = "Day21" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput(), steps = 6) shouldBe 16 measureAnswer { pa...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,350
advent-of-code
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2023/Day03.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2023 import com.dvdmunckhof.aoc.size import java.util.ArrayList import kotlin.math.max import kotlin.math.min class Day03(private val input: List<String>) { fun solvePart1(): Int { val regex = Regex("\\d+") return input.withIndex().sumOf { (index, line) -> ...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
2,040
advent-of-code
Apache License 2.0
src/day06/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day06 import readInput fun main() { val input = readInput("day06") println(solvePartOne(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Long = input.createFishColony() .processDays(80) .count() fun solvePartTwo(input: List<String>): Long = input.createFishCo...
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
1,129
aoc-2021
Apache License 2.0
src/day24/Day24.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day24 import Direction import Position import readInput fun main() { fun simulate(valley: Valley, startPosition: Position, endPos: Position): Int { var i = 0 var possiblePositions = setOf(startPosition) while (!possiblePositions.contains(endPos)) { valley.step() ...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
4,496
advent-of-code-kotlin-2022
Apache License 2.0
src/Day12.kt
allwise
574,465,192
false
null
import Direction.* import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val hillClimb = HillClimb(input) val res = hillClimb.process() println("res1: $res") return res } fun part2(input: List<String>): Int { val hillClimb = HillClimb(input) ...
0
Kotlin
0
0
400fe1b693bc186d6f510236f121167f7cc1ab76
6,511
advent-of-code-2022
Apache License 2.0
src/Day04.kt
jandryml
573,188,876
false
{"Kotlin": 6130}
private infix fun IntRange.isSubrange(other: IntRange) = (this - other).isEmpty() private infix fun IntRange.isOverlapping(other: IntRange) = this.intersect(other).isNotEmpty() private fun part1(input: List<String>): Int { return transferToRanges(input) .map { (a, b) -> a isSubrange b || b isSubrange a } ...
0
Kotlin
0
0
90c5c24334c1f26ee1ae5795b63953b22c7298e2
1,027
Aoc-2022
Apache License 2.0
2021/src/day19/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day19 import java.nio.file.Files import java.nio.file.Paths import kotlin.math.absoluteValue import kotlin.system.measureTimeMillis fun main() { val rotations = createRotations() fun fullMap(input: Input): MutableList<Pair<Point, List<Point>>> { val fixed = mutableListOf(Point(0, 0, 0) to input.first...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
3,824
advent-of-code
Apache License 2.0
src/Day09.kt
khongi
572,983,386
false
{"Kotlin": 24901}
import kotlin.math.abs data class Position(val x: Int, val y: Int) enum class Direction { UP, DOWN, LEFT, RIGHT } fun Char.toDirection(): Direction = when (this) { 'U' -> Direction.UP 'D' -> Direction.DOWN 'L' -> Direction.LEFT 'R' -> Direction.RIGHT else -> error("$this is not a ...
0
Kotlin
0
0
9cc11bac157959f7934b031a941566d0daccdfbf
3,159
adventofcode2022
Apache License 2.0
untitled/src/main/kotlin/Day3.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
class Day3(private val fileName: String) : AocSolution { override val description: String get() = "Day 3 - Rucksack Reorg ($fileName)" private val input = InputReader(fileName).lines override fun part1() = input.sumOf { ruckPriority(it) } override fun part2() = input.chunked(3).sumOf { groupBadgePriori...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
1,537
adventofcode2022-kotlin
The Unlicense
src/Day02.kt
akleemans
574,937,934
false
{"Kotlin": 5797}
fun main() { val shapeValues = mapOf("X" to 1, "Y" to 2, "Z" to 3, "A" to 1, "B" to 2, "C" to 3) fun part1(input: List<String>): Int { var score = 0 for (line in input) { val (opponent, mine) = line.split(" ") score += shapeValues.getOrDefault(mine, 0) val p...
0
Kotlin
0
0
fa4281772d89a6d1cda071db4b6fb92fff5b42f5
1,692
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/de/dikodam/calendar/Day05.kt
dikodam
433,719,746
false
{"Kotlin": 51383}
package de.dikodam.calendar import de.dikodam.AbstractDay import de.dikodam.executeTasks import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { Day05().executeTasks() } class Day05 : AbstractDay() { val input = readInputLines() // val input = """0,9 -> 5,9 //8,0 -> 0,8 //9,4 -> 3,4 //2,2 ...
0
Kotlin
0
1
4934242280cebe5f56ca8d7dcf46a43f5f75a2a2
2,600
aoc-2021
MIT License
src/Day14.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.sign import kotlin.math.min import kotlin.math.max private const val EMPTY = 0 private const val BLOCKED = 1 private val MOVES_SAND = listOf(0 to 1, -1 to 1, 1 to 1) private class Field(walls: List<List<Pair<Int, Int>>>, blockVoid: Boolean = false) { enum class MoveResultState { MOVED, BLOCKED...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
3,682
advent-of-kotlin-2022
Apache License 2.0
src/Day19.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { val ore = 0 val clay = 1 val obsidian = 2 val geode = 3 var best = 0 fun parseInput(input: String): List<List<Int>> { val robots = input.substringAfter(": ") val inputLineRegex = """Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Each o...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
4,492
advent-of-code-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day16/Day16.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day16 import nl.sanderp.aoc.common.readResource fun main() { val input = readResource("Day16.txt") .map { it.toString().toInt(16) } .joinToString("") { it.toString(2).padStart(4, '0') } val packets = Reader(input).next() println("Part one: ${packets.version...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
3,381
advent-of-code
MIT License
src/Day20.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import java.util.* fun main() { fun part1(input: List<String>): Int { val numbers = input.map { it.toInt() } val positions = IntArray(input.size) { it } val lastIndex = input.lastIndex fun move(from: Int, to: Int) { // 2 5 3 7 1 - from 1 to 3 - // 2 3 7 5 1 ...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
4,076
AoC-2022
Apache License 2.0