path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/day02/Day02.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day02 import runDay private fun main() { fun part1(input: List<String>): Int { return input.mapToCombinations().toScores().also(::println).sum() } fun part2(input: List<String>): Int { return input.mapToCombinationsBasedOnResult().toScores().also(::println).sum() } (object {}).runDay( ...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
2,532
advent-of-code-2022
Apache License 2.0
src/Day22.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { data class Point(val x: Int, val y: Int) val mapChars = charArrayOf('.', '#') data class Direction(val dx: Int, val dy: Int, val value: Int) { fun next(x: Int, y: Int, map: List<String>): Point { var newX = x + dx var newY = y + dy if (dx == 1 && (...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
9,178
AdventOfCode2022
Apache License 2.0
src/day02/Day02Answer4.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day02 import day02.Gesture.* import day02.Outcome.* import readInput /** * Answers from [Advent of Code 2022 Day 2 | Kotlin](https://youtu.be/Fn0SY2yGDSA) */ fun main() { println(part1()) // 12586 println(part2()) // 13193 } enum class Gesture(val points: Int) { ROCK(1), PAPER(2), S...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
2,172
advent-of-code-2022
Apache License 2.0
src/Day11.kt
khongi
572,983,386
false
{"Kotlin": 24901}
class Monkey(chunk: List<String>) { val items = mutableListOf<Long>() val testNumber: Int var inspectCount = 0 private set private val left: String private val right: String private val operation: String private val testTrueMonkey: Int private val testFalseMonkey: Int init {...
0
Kotlin
0
0
9cc11bac157959f7934b031a941566d0daccdfbf
2,942
adventofcode2022
Apache License 2.0
2023/src/day05/day05.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day05 import GREEN import RESET import printTimeMillis import readInput val transforms = listOf( "soil", "fertilizer", "water", "light", "temperature", "humidity", "location" ) // 50 98 2 -> LongRange(98..99) offset = 50-98 = -48 // 52 50 48 -> LongRange(50..97) offset = 52-50 = 2...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,798
advent-of-code
Apache License 2.0
src/Day13.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
class Packet(var packetList: List<Packet> = mutableListOf<Packet>(), var intVal: Int = -1) : Comparable<Packet> { companion object { private fun Regex.splitWithDelimiter(input: CharSequence) = Regex("((?<=%1\$s)|(?=%1\$s))".format(this.pattern)).split(input) fun of(input: String): Packe...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
2,893
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/EulerCircuit.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph Solution().test() data class DirectedWeightedGraphWithAdjMatrix(val matrix: Array<IntArray>) class Solution { fun test() { println("Test") val graph = DirectedWeightedGraphWithAdjMatrix( arrayOf( intArrayOf(0, 1, 1, 1, 1), ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,937
KotlinAlgs
MIT License
numbertheory/ChineseRemainderTheorem.kt
wangchaohui
737,511,233
false
{"Kotlin": 36737}
/** * To solve ax + by = gcd(a, b) */ object ExtendedEuclidean { data class Answer( val gcd: Long, val x: Long, val y: Long, ) fun solve(a: Long, b: Long): Answer { if (b == 0L) return Answer(a, 1, 0) val (gcd, x, y) = solve(b, a % b) return Answer(gcd, y, ...
0
Kotlin
0
0
241841f86fdefa9624e2fcae2af014899a959cbe
1,490
kotlin-lib
Apache License 2.0
src/main/kotlin/days/Day14.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day14 : Day(14) { override fun partOne(): Any { val init = inputList[0] val to = inputList.drop(2).map { it.split(" -> ") }.associate { it[0] to it[1] } return (1..10).fold(init) { str, _ -> str[0] + str.zipWithNext().map { (c, next) -> ...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
1,771
aoc-2021
Creative Commons Zero v1.0 Universal
src/Day09.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
import kotlin.math.abs fun main() { fun buildSnack(input: List<String>, length: Int): Int { val list = mutableListOf<Pair<Int, Int>>() repeat(length) { list.add(Pair(0, 0)) } val visit = mutableSetOf<Pair<Int, Int>>() visit.add(Pair(0, 0)) input.forEach {...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
1,946
AdventCode2022
Apache License 2.0
src/Day02.kt
wgolyakov
572,463,468
false
null
fun main() { fun part1(input: List<String>): Int { return input.sumBy { when (it) { "A X" -> 1 + 3 // Rock, Rock, Draw "A Y" -> 2 + 6 // Rock, Paper, Won "A Z" -> 3 + 0 // Rock, Scissors, Lose "B X" -> 1 + 0 // Paper, Rock, Lose "B Y" -> 2 + 3 // Paper, Paper, Draw "B Z" -> 3 + 6 // Paper,...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
1,161
advent-of-code-2022
Apache License 2.0
src/Day02.kt
naturboy
572,742,689
false
{"Kotlin": 6452}
enum class Selection { ROCK, PAPER, SCISSOR; fun getSelectionScore(): Int { return this.ordinal + 1 } fun getWinningSelection(): Selection { return Selection.values()[(ordinal + 2) % 3] } fun getLoosingSelection(): Selection { return Selection.values()[(ordinal...
0
Kotlin
0
0
852871f58218d80702c3b49dd0fd453096e56a43
2,451
advent-of-code-kotlin-2022
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/PalindromicSubsequence.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Longest Palindromic Subsequence: The longestPalindromicSubsequence function calculates the length of the longest palindromic subsequence in a given string using a 2D array to store intermediate results. Minimum Deletions in a String to Make it a Palindrome: The minDeletionsToMakePalindrome function uses the result ...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,061
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/Day07/Day07.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day07 import checkAndPrint import measureAndPrintTimeMillis import readInput fun main() { val cdCommandRgx = """\$ cd (.*)""".toRegex() val fileRgx = """(\d+) (.*)""".toRegex() val dirRgx = """dir (.*)""".toRegex() fun prepareInput(input: List<String>): List<Directory> { val root = Di...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
3,472
AdventOfCode2022
Apache License 2.0
src/Day02.kt
sgc109
576,491,331
false
{"Kotlin": 8641}
fun main() { val fightScore = mapOf( "A" to mapOf( "X" to 3, "Y" to 6, "Z" to 0, ), "B" to mapOf( "X" to 0, "Y" to 3, "Z" to 6, ), "C" to mapOf( "X" to 6, "Y" to 0, "Z"...
0
Kotlin
0
0
03e4e85283d486430345c01d4c03419d95bd6daa
1,373
aoc-2022-in-kotlin
Apache License 2.0
gcj/y2020/round3/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round3 private fun solve(): String { val (s, t) = readStrings() val way = generateSequence(t) { x -> prev(s, x) }.toList() return way[way.size / 2] } private fun prev(s: String, t: String): String? { if (s == t) return null val d = List(s.length + 1) { IntArray(t.length + 1) } for (i in s.indi...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,262
competitions
The Unlicense
src/main/kotlin/com/briarshore/aoc2022/day08/TreeTopTreeHousePuzzle.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day08 import println import readInput @ExperimentalStdlibApi fun main() { fun scenicScore(trees: List<Int>): Int { var count = 0 for (height in trees.drop(1)) { if (height < trees.first()) { count++ } if (height >=...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
6,884
2022-AoC-Kotlin
Apache License 2.0
src/Day09.kt
psy667
571,468,780
false
{"Kotlin": 23245}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign fun main() { val id = "09" data class Pos(val y: Int, val x: Int) { operator fun plus(b: Pos): Pos { return Pos(this.y + b.y, this.x + b.x) } override fun toString(): String { retur...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
2,369
advent-of-code-2022
Apache License 2.0
src/Day02.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
enum class Throw { Rock, Paper, Scissor } val Throw.worth: Int get() = when (this) { Throw.Rock -> 1 Throw.Paper -> 2 Throw.Scissor -> 3 } val Throw.beats: Throw get() = when (this) { Throw.Rock -> Throw.Scissor Th...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
2,093
aoc2022
Apache License 2.0
src/Day04.kt
Xacalet
576,909,107
false
{"Kotlin": 18486}
/** * ADVENT OF CODE 2022 (https://adventofcode.com/2022/) * * Solution to day 4 (https://adventofcode.com/2022/day/4) * */ fun main() { fun part1(assignments: List<Pair<IntRange, IntRange>>): Int { return assignments.count { (elf1, elf2) -> (elf1.first >= elf2.first && elf1.last <= elf2...
0
Kotlin
0
0
5c9cb4650335e1852402c9cd1bf6f2ba96e197b2
1,045
advent-of-code-2022
Apache License 2.0
LeetCode/Range Sum Query - Mutable/main.kt
thedevelopersanjeev
112,687,950
false
null
class SegmentTree(nums: IntArray) { private var treeSize = 1 private var tree: LongArray init { while (this.treeSize < nums.size) { this.treeSize = this.treeSize.shl(1) } this.tree = LongArray(this.treeSize.shl(1)) this.build(nums, 0, 0, this.treeSize) } ...
0
C++
58
146
610520cc396fb13a03c606b5fb6739cfd68cc444
1,839
Competitive-Programming
MIT License
codeforces/round901/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round901 private fun precalc(n: Int = 5000): List<DoubleArray> { val p = List(n + 1) { DoubleArray(it) } for (i in 1..n) { p[i][0] = 1.0 / i for (j in 1 until i) { if (j >= 2) p[i][j] = (j - 1.0) / i * p[i - 2][j - 2] if (j < i - 1) p[i][j] += (i - j - 1.0) / i * p[i - 2][j - 1] } } ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
940
competitions
The Unlicense
src/main/kotlin/Day16.kt
akowal
434,506,777
false
{"Kotlin": 30540}
import Day16.Packet.Literal import Day16.Packet.Operator fun main() { println(Day16.solvePart1()) println(Day16.solvePart2()) } object Day16 { private val input = readInput("day16").single() fun solvePart1(): Int { fun Packet.sumVersions(): Int = when (this) { is Literal -> versio...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
3,352
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/Day08.kt
khongi
572,983,386
false
{"Kotlin": 24901}
fun main() { fun buildMatrix(input: List<String>): List<List<Int>> { val mtx: MutableList<MutableList<Int>> = mutableListOf() input.forEach { line -> val row = mutableListOf<Int>() line.forEach { row.add(it.digitToInt()) } mtx.add(row) } return mtx...
0
Kotlin
0
0
9cc11bac157959f7934b031a941566d0daccdfbf
3,061
adventofcode2022
Apache License 2.0
y2018/src/main/kotlin/adventofcode/y2018/Day18.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2018 import adventofcode.io.AdventSolution import adventofcode.util.collections.takeWhileDistinct object Day18 : AdventSolution(2018, 18, "Settlers of The North Pole") { override fun solvePartOne(input: String) = generateSequence(ConwayGrid(input), ConwayGrid::next) ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,059
advent-of-code
MIT License
src/main/kotlin/adventofcode2020/solution/Day7.kt
lhess
320,667,380
false
null
package adventofcode2020.solution import adventofcode2020.Solution import adventofcode2020.resource.PuzzleInput class Day7(puzzleInput: PuzzleInput<String>) : Solution<String, Int>(puzzleInput) { private val bags = puzzleInput.intoBags() override fun runPart1() = bags .findParents() ...
0
null
0
1
cfc3234f79c27d63315994f8e05990b5ddf6e8d4
1,634
adventofcode2020
The Unlicense
2023/src/day12/day12.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day12 import GREEN import RESET import printTimeMillis import readInput data class Arrangement( val str: String, val records: List<Int> ) { fun isValid() : Boolean { val chunks = str.split(".") .filter { it.contains("#") } .map { it.length } return chunks =...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,502
advent-of-code
Apache License 2.0
src/Day18.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
val normals = arrayOf ( Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(0, 0, 1), Vector3(-1, 0, 0), Vector3(0, -1, 0), Vector3(0, 0, -1), ) fun main() { fun parse(input: List<String>): List<Vector3> { val coords = input.map{ it -> val tmp = it.split(",").map{it.toInt()...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
3,676
aoc2022
Apache License 2.0
advent-of-code-2023/src/Day04.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day04" fun main() { fun testInput() = readInput("${DAY}_test") fun input() = readInput(DAY) "Part 1" { part1(testInput()) shouldBe 13 measureAnswer { part1(input()) } } "Part 2" { part2(testInput()) shouldBe 30 measureAnswer { part2(input()...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
1,090
advent-of-code
Apache License 2.0
src/day19/Day19.kt
gautemo
317,316,447
false
null
package day19 import shared.getText import shared.separateByBlankLine fun validMessages(input: String): Int{ val (rulesRead, messages) = separateByBlankLine(input).map { it.lines() } val rules = rulesRead.map { Rule(it) } val regex = toRegex(rules, "0") return messages.count { it.matches(Reg...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
1,533
AdventOfCode2020
MIT License
src/Day01CalorieCounting.kt
zizoh
573,932,084
false
{"Kotlin": 13370}
fun main() { val input: List<String> = readInput("input/day01") println("largest calorie: ${largestCalorie(input)}") println("sum of largest calories: ${sumOfLargestCalories(input, 3)}") } fun largestCalorie(input: List<String>): Int { var largest = 0 var currentSum = 0 input.forEach { calorie ...
0
Kotlin
0
0
817017369d257cca648974234f1e4137cdcd3138
1,338
aoc-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2023/Day09.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 ru.timakden.aoc.year2023.Day09.Direction.BACKWARDS import ru.timakden.aoc.year2023.Day09.Direction.FORWARDS /** * [Day 9: Mirage Maintenance](https://adventofcode.com/2023/day/9). */ object Day09 { ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,377
advent-of-code
MIT License
src/Day04.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
fun main() { fun part1(input: List<String>): Int { return input .map { it.split(",", "-") .map { s -> s.toInt() } } .map { Assignments(it[0], it[1]) to Assignments(it[2], it[3]) } .count { it.first.oneFullyOverlapsOther(it....
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
1,572
adventofcode-2022
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/NGram.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.max import kotlin.math.min /** * N-Gram Similarity as defined by Kondrak, "N-Gram Similarity and Distance", String Processing and Information * Retrieval, Lecture Notes in Computer Science Volume 3772, 2005, pp 115-126. * * The algorithm uses affixing with special...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
3,081
string-similarity-kotlin
MIT License
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day12.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day class Day12 : Day("5076", "145643") { private data class Node( val id: String, val isSmall: Boolean = id.lowercase() == id, val neighbors: MutableList<Node> = mutableListOf() ) private val caves = getCaves() override fun solvePartOne(): A...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
2,415
advent-of-code-2021
MIT License
src/main/kotlin/net/voldrich/aoc2023/Day02.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2023 import net.voldrich.BaseDay // https://adventofcode.com/2023/day/2 fun main() { Day02().run() } class Day02 : BaseDay() { override fun task1(): Int { val marbleCounts = mapOf( "red" to 12, "green" to 13, "blue" to 14 ) ...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
2,124
advent-of-code
Apache License 2.0
Graph.kt
Abijeet123
351,862,917
false
null
import java.util.* private fun readLn() = readLine()!! // string line private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fun readDouble() = readLn().toDouble() // single double private fun readStrings() = readLn().split(" ") // list of strings priva...
0
Kotlin
0
0
902adc3660caee6b69a13ac169bb8a7b51245163
2,376
KotlinAlgorithmsImplementations
MIT License
kotlin/src/2022/Day16_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.max private val r = Regex("Valve (..) has flow rate=([0-9]+); .* valves? (.*)") private typealias EdgeList = List<Pair<Int, String>> fun main() { val rates = mutableMapOf<String, Int>() val neighs = mutableMapOf<String, List<String>>() readInput(16).trim().lines() .forEach {s ->...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
3,473
adventofcode
Apache License 2.0
src/Day14.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
fun main() { val lines = readInput("day14_input") val (sandStart, cols) = 500 to 1000 var (ans1, ans2) = 0 to 0 // mapping each point p to an integer k where p_x = k%cols and p_y = k/cols val paths: List<List<Int>> = lines.map { it.split(" -> ").map { it.split(",").map { it.toInt() }.let { it.first...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
1,309
advent22
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch4/Problem43.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch4 import dev.bogwalk.util.combinatorics.permutations /** * Problem 43: Substring Divisibility * * https://projecteuler.net/problem=43 * * Goal: Find the sum of all 0 to N pandigital numbers that have their 3-digit substrings, * starting from d_2, being divisible by sequential primes. *...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,796
project-euler-kotlin
MIT License
src/main/kotlin/days/Day14.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils.toPair class Day14 : Day(14) { private val template = inputList.first() private val rules = inputList.drop(2).map { it.split(" -> ").toPair() } override fun partOne(): Any { val polymer = pairInsertion(10) return polymer.maxOf { polymer.count { c -> c == i...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
2,314
aoc-2021
Creative Commons Zero v1.0 Universal
src/Day02.kt
Ajimi
572,961,710
false
{"Kotlin": 11228}
fun main() { fun part1(input: List<Pair<Int, Int>>) = input.sumOf { (opponent, me) -> me + 1 + when (me) { (opponent + 1) % 3 -> 6 opponent -> 3 else -> 0 } } fun part2(input: List<Pair<Int, Int>>): Int = input.sumOf { (opponent, me) -> me * 3 + w...
0
Kotlin
0
0
8c2211694111ee622ebb48f52f36547fe247be42
869
adventofcode-2022
Apache License 2.0
advent-of-code-2022/src/main/kotlin/Day11.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 11: Monkey in the Middle //https://adventofcode.com/2022/day/11 import java.io.File import java.math.BigInteger data class Monkey( val id: Int, val items: MutableList<BigInteger>, val operation: (BigInteger) -> BigInteger, val test: (BigInteger) -> Boolean, val monkeyWhenTrue: () -> Int, ...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,856
advent-of-code
Apache License 2.0
src/main/aoc2022/Day16.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import Search /** * Main idea: * - Reduce the map to traverse by creating an optimized search graph where only the significant nodes * are included. Nodes without valves are not included * - Also include opening a valve in the action. That is each action is move to another valve and open it. ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
11,001
aoc
MIT License
src/day02/Day02.kt
Klaus-Anderson
572,740,347
false
{"Kotlin": 13405}
package day02 import readInput import java.rmi.UnexpectedException import java.util.* fun main() { fun part1(input: List<String>): Int { return input.sumOf { string -> returnHumanPlayerMatchOutCome(string[0].toRpsMove(), string[2].toRpsMove()) } } fun part2(input: List<String...
0
Kotlin
0
0
faddc2738011782841ec20475171909e9d4cee84
2,453
harry-advent-of-code-kotlin-template
Apache License 2.0
src/Day08.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
enum class Direction { LEFT, RIGHT, DOWN, UP } fun main() { fun getNextPosition(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) D...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
3,307
adventofcode2022
Apache License 2.0
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day15Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import kotlin.math.abs private const val LEFT = 'L' private const val RIGHT = 'R' private fun solutio...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,828
adventofcode-kotlin
MIT License
AdventOfCode/Challenge2023Day07.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.test.assertEquals class Challenge2023Day07 { private fun solve1(lines: List<String>): Int { val valueMap = mapOf( 'A' to 14, 'K' to 13, 'Q' to 12, 'J' to 11, '...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
3,703
KotlinCodeJourney
MIT License
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day06/Day06.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day06 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: String): Long { var fish = input.split(",").map { it.toInt() } val days = 80 for (i in 1 .. days) { val numberOfZeros = fish...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
1,691
AOC
Apache License 2.0
src/Day03.kt
paul-griffith
572,667,991
false
{"Kotlin": 17620}
private fun String.splitInHalf(): Pair<String, String> { return Pair(this.substring(0, length / 2), this.substring(length / 2)) } private val Char.score: Int get() { val base = this.lowercase().first().code - 96 return if (isUpperCase()) { base + 26 } else { base...
0
Kotlin
0
0
100a50e280e383b784c3edcf65b74935a92fdfa6
1,433
aoc-2022
Apache License 2.0
src/Day01.kt
kkaptur
573,511,972
false
{"Kotlin": 14524}
fun main() { fun part1(input: List<String>): Int { var sum = 0 var highestSum = 0 input.forEach { if (it.isNotBlank()) sum += it.toInt() if (sum > highestSum) highestSum = sum if (it.isBlank()) sum = 0 } return highestSum } fun par...
0
Kotlin
0
0
055073b7c073c8c1daabbfd293139fecf412632a
1,274
AdventOfCode2022Kotlin
Apache License 2.0
src/Day2/Day2.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day2 import CircularList import readInput val shapes = CircularList(listOf(Shape.ROCK, Shape.PAPER, Shape.SCISSORS)) enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); companion object { fun from(s: String): Shape { return when(s) { "A", "X...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
2,098
aoc-2022-in-kotlin
Apache License 2.0
src/Day07.kt
VadimB95
574,449,732
false
{"Kotlin": 19743}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day07_test") check(part1(testInput) == 95437) check(part2(testInput) == 24933642) val input = readInput("Day07") println(part1(input)) println(part2(input)) } private fun part1(inpu...
0
Kotlin
0
0
3634d1d95acd62b8688b20a74d0b19d516336629
3,760
aoc-2022
Apache License 2.0
src/main/kotlin/day15/Day15.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day15 import java.io.File import kotlin.math.abs fun main() { val data = parse("src/main/kotlin/day15/Day15.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 15 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
2,350
advent-of-code-2022
MIT License
src/Day02.kt
meierjan
572,860,548
false
{"Kotlin": 20066}
import java.lang.IllegalArgumentException private enum class Result( val points: Int ) { WIN(6), DRAW(3), LOSE(0); companion object { fun parse(char: Char) = when (char) { 'X' -> LOSE 'Y' -> DRAW 'Z' -> WIN else -> throw IllegalArgumentException("Unk...
0
Kotlin
0
0
a7e52209da6427bce8770cc7f458e8ee9548cc14
2,254
advent-of-code-kotlin-2022
Apache License 2.0
stepik/sportprogramming/ContuneousBagProblemGreedyAlgorithm.kt
grine4ka
183,575,046
false
{"Kotlin": 98723, "Java": 28857, "C++": 4529}
package stepik.sportprogramming private val things = mutableListOf<Thing>() fun main() { val (n, maxWeight) = readPair() repeat(n) { things.add(readThing()) } println("Maximum value of all things is ${solution(maxWeight)}") } private fun solution(maxWeight: Int): Int { val sortedByValue =...
0
Kotlin
0
0
c967e89058772ee2322cb05fb0d892bd39047f47
1,335
samokatas
MIT License
src/aoc2023/Day17.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInput import java.util.* fun main() { val (year, day) = "2023" to "Day17" fun minHeatLoss(map: List<String>, minSteps: Int, maxSteps: Int): Int { val input = map.map { line -> line.map { it.digitToInt() } } val rows = input.size val cols = ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
2,949
aoc-kotlin
Apache License 2.0
src/main/kotlin/day8/Day8.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day8 import execute import readAllText import kotlin.math.absoluteValue fun main() { val test = """ 30373 25512 65332 33549 35390 """.trimIndent() val input = readAllText("local/day8_input.txt") execute(::part1, test) execute(::part1, input) exec...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
1,625
advent-of-code-2022
MIT License
src/main/kotlin/com/sk/topicWise/monotonicStack/907. Sum of Subarray Minimums.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.monotonicStack import kotlin.math.abs class Solution907 { fun sumSubarrayMins(arr: IntArray): Int { val MAX = 1_000_000_007 val M = 3_000_1 var ans = 0 val dp = Array(arr.size) { IntArray(arr.size) { M } } for (i in arr.indices) { for ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,478
leetcode-kotlin
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2021/day06/day6.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day06 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val line = inputFile.bufferedReader().readLines().first() val initialFish = createFish(line) val fishAfter80Days = (1..80).fold(initialFish) { acc, _ -> si...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,587
advent-of-code
MIT License
src/Day03.kt
tigerxy
575,114,927
false
{"Kotlin": 21255}
fun main() { fun part1(input: List<String>): Int { return input .mapNotNull { backpack -> val chars = backpack.toCharArray().toList() val compartments = chars.chunked(chars.size / 2) compartments.first().find { compartments.last().contains(it) } ...
0
Kotlin
0
1
d516a3b8516a37fbb261a551cffe44b939f81146
1,343
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/MinCostConnectPoints.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import kotlin.math.abs /** * 1584. 连接所有点的最小费用 * * 给你一个points 数组,表示 2D 平面上的一些点,其中 points[i] = [xi, yi] 。 * * 连接点 [xi, yi] 和点 [xj, yj] 的费用为它们之间的 曼哈顿距离 :|xi - xj| + |yi - yj| ,其中 |val| 表示 val 的绝对值。 * * 请你返回将所有点连接的最小总费用。只有任意两点之间 有且仅有 一条简单路径时,才认为所有点都已连接。 * */ class MinCostConne...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
3,144
daily_algorithm
Apache License 2.0
src/Day09.kt
Kbzinho-66
572,299,619
false
{"Kotlin": 34500}
import kotlin.math.abs private operator fun String.component1() = when (this.substringBefore(' ')) { "U" -> Direction.UP "D" -> Direction.DOWN "L" -> Direction.LEFT else -> Direction.RIGHT } private operator fun String.component2() = this.substringAfter(' ').toInt() private enum class Direction { UP, D...
0
Kotlin
0
0
e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b
2,734
advent_of_code_2022_kotlin
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day03.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 import java.lang.Math.abs import kotlin.math.ceil import kotlin.math.sqrt /** * AoC 2017, Day 3 *s * Problem Description: http://adventofcode.com/2017/day/3 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day3/ */ ...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
3,318
advent-2017-kotlin
MIT License
src/main/kotlin/com/groundsfam/advent/y2020/d09/Day09.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2020.d09 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines private fun findInvalidNumber(nums: List<Long>, preamble: Int = 25): Long? { val counts = mutableMapOf<Long, Int>().apply { repeat(preamble) { i -> this[nums[i...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,891
advent-of-code
MIT License
kotlin/0352-data-stream-as-disjoint-intervals.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
// Using TreeSet and linear scan in getIntervals() method class SummaryRanges() { val ranges = TreeSet<Int>() fun addNum(value: Int) { ranges.add(value) } fun getIntervals(): Array<IntArray> { val res = LinkedList<IntArray>() ranges.forEach { if (res.isNotEmpty() &&...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,448
leetcode
MIT License
src/poyea/aoc/mmxxii/day20/Day20.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day20 import poyea.aoc.utils.readInput fun part1(input: String): Long { val original = input.split("\n") .map { it.toInt() } .mapIndexed { index, i -> Pair(index, i.toLong()) } val moved = original.toMutableList() original.forEach { ...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
1,306
aoc-mmxxii
MIT License
src/Day12.kt
a2xchip
573,197,744
false
{"Kotlin": 37206}
data class SquareNode(val c: Char, val value: Int, val pos: Pair<Int, Int>) { override fun toString(): String { return """position=$pos repr='$c' value=[$value]""" } } class EscalationGraph(val nodes: List<SquareNode>, val edges: Map<SquareNode, List<SquareNode>>) { fun shortestPath(fromEdge: Squar...
0
Kotlin
0
2
19a97260db00f9e0c87cd06af515cb872d92f50b
4,386
kotlin-advent-of-code-22
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day17/day17.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day17 import kotlin.math.abs fun <T> Iterable<Iterable<T>>.cartesianProduct(other: Iterable<Iterable<T>>): List<List<T>> { return this.flatMap { lhsElem -> other.map { rhsElem -> lhsElem + rhsElem } } } fun mixRanges(vararg ranges: IntRange): List<List<Int>> { if (ranges.isEmpty()) r...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
3,918
advent-of-code-2020
Do What The F*ck You Want To Public License
src/problems/day3/part2/part2.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day3.part2 import java.io.File //private const val testFile = "input/day3/test.txt" private const val part_numbers = "input/day3/part_numbers.txt" fun main() { val gearRatioSum = File(part_numbers).bufferedReader().useLines { sumGearRatios(it) } println("Part Number Sum: $gearRatioSum") } p...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
3,408
aoc2023
MIT License
src/Day04.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
fun main() { fun sumOfFullyContainedAssignments(input: List<String>): Int { val inputLineRegex = """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() return input.sumOf { line -> val (firstStart, firstEnd, secondStart, secondEnd) = inputLineRegex .matchEntire(line) ?....
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
1,670
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
Daan-Gunnink
572,614,830
false
{"Kotlin": 8595}
class Day03 : AdventOfCode(157, 70) { private val characterList = "abcdefghijklmnopqrstuvwxyz" private fun getScore(items: List<String>): Int { return items.map { it.toCharArray() }.map { it.sumOf {char -> if(char.isUpperCase()) (char.code - 38) else (char.code - 96) } }.sumOf { it ...
0
Kotlin
0
0
15a89224f332faaed34fc2d000c00fbefe1a3c08
1,681
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day08/Day08.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day08 import java.io.File fun main() { val data = parse("src/main/kotlin/day08/Day08.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 08 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
4,471
advent-of-code-2021
MIT License
src/year2023/Day1.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import readLines fun main() { val input = readLines("2023", "day1") val testInputPart1 = readLines("2023", "day1_test1") val testInputPart2 = readLines("2023", "day1_test2") check(part1(testInputPart1) == 142) println("Part 1:" + part1(input)) check(part2(testInputPart2) == ...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
1,509
advent_of_code
MIT License
src/Day23.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
enum class Day23Direction(val vector: Vector) { NORTH(Vector(0, -1)), SOUTH(Vector(0, 1)), EAST(Vector(1, 0)), WEST(Vector(-1, 0)), NORTHWEST(Vector(-1, -1)), NORTHEAST(Vector(1, -1)), SOUTHWEST(Vector(-1, 1)), SOUTHEAST(Vector(1, 1)) } val checks = mapOf( Day23Direction.NORTH to lis...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
5,207
advent-of-code-2022
Apache License 2.0
src/Day02.kt
arturkowalczyk300
573,084,149
false
{"Kotlin": 31119}
enum class Result { LOOSE, WIN, DRAW } fun moveStringToMoveScore(move: String, firstMoveCharacter: Char): Int { return move.toCharArray().first().code - firstMoveCharacter.code + 1 } fun stringToDesiredResult(desiredResultString: String): Result { return when (desiredResultString.toCharArray().first()) {...
0
Kotlin
0
0
69a51e6f0437f5bc2cdf909919c26276317b396d
2,838
aoc-2022-in-kotlin
Apache License 2.0
src/year2015/day16/Day16.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day16 import readInput fun main() { val input = readInput("2015", "Day16") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val mfcsam = mapOf( "children" to 3, "cats" to 7, "samoyeds" to 2, "pomeranians" to 3...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,559
AdventOfCode
Apache License 2.0
src/day5/newday.kt
mrm1st3r
573,163,888
false
{"Kotlin": 12713}
package day5 import Puzzle fun part1(input: List<String>): String { val separator = input.indexOf("") check(separator > 0) val stacks = parseStacks(input.subList(0, separator)) input.subList(separator + 1, input.size) .map(::parseOperation) .forEach { executeOperation1(it, stacks) } ...
0
Kotlin
0
0
d8eb5bb8a4ba4223331766530099cc35f6b34e5a
2,485
advent-of-code-22
Apache License 2.0
src/Day05.kt
nic-dgl-204-fall-2022
564,602,480
false
{"Kotlin": 2428}
fun main() { fun part1(input: List<String>): Int { // Extension functions to check for each of the criteria fun String.hasUnwantedStrings() = this.zipWithNext().any { it.first == 'a' && it.second == 'b' } || this.zipWithNext().any { it.first == 'c' && it.second == 'd' } || ...
1
Kotlin
0
0
25e14ff492cb9cbb86b98a97f1a05f956e4ac524
1,809
redjinator-aoc-2
Apache License 2.0
2022/Day11.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import java.math.BigInteger fun main() { val input = readInput("Day11") data class Monkey( val id: Int, val items: ArrayDeque<BigInteger>, val op: (BigInteger) -> BigInteger, val testDiv: BigInteger, val pass: (BigInteger) -> Int, var inspected: Long = 0, ) ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
2,642
advent-of-code-kotlin
Apache License 2.0
src/day19/Day19.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day19 import kotlin.math.max import kotlin.math.min import readInput enum class ResourceType { ORE, CLAY, OBSIDIAN, GEODE; companion object { fun buildingResourses(): List<ResourceType> { return listOf(ORE, CLAY, OBSIDIAN) } } } data class ResourceSet(val ore: Int, va...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
10,085
aoc-2022
Apache License 2.0
src/Day12.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
import kotlin.math.abs fun main() { val day = 12 fun Char.toHeight() = when (this) { in 'a'..'z' -> this - 'a' 'S' -> 0 'E' -> 'z' - 'a' else -> throw RuntimeException() } fun part1(input: List<String>): Int { val n = input.size val m = input.first().le...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
2,649
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
hnuttin
572,601,761
false
{"Kotlin": 5036}
enum class RPS(val score: Int) { A(1), X(1), B(2), Y(2), C(3), Z(3); fun fight(rps: RPS): Int { return when (this) { A -> if (rps == X) 3 else if (rps == Y) 6 else 0 B -> if (rps == X) 0 else if (rps == Y) 3 else 6 C -> if (rps == X) 6 else if (rps == Y) 0 el...
0
Kotlin
0
0
53975ed6acb42858be56c2150e573cdbf3deedc0
1,179
aoc-2022
Apache License 2.0
src/day11/Day11.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day11 import utils.* data class Monkey( val id: Int, var items: MutableList<Int>, val operation: Char, val operationValue: Int?, val divisor: Int ) { lateinit var divisibleTargetMonkey: Monkey lateinit var indivisibleTargetMonkey: Monkey var inspections: Int = 0 private f...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
3,301
AOC-2022-Kotlin
Apache License 2.0
src/y2022/Day02.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.readInput /** * A > Y * B > Z * C > X * X > B * Y > C * Z > A */ val oppMap = mapOf('A' to 0, 'B' to 1, 'C' to 2) val meMap = mapOf('X' to 0, 'Y' to 1, 'Z' to 2) fun part1(input: List<String>): Int { return input.sumOf { inputToScore(it) } } fun inputToNums(input: String): Pair...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,005
advent-of-code
Apache License 2.0
src/main/kotlin/de/nilsdruyen/aoc/Day05.kt
nilsjr
571,758,796
false
{"Kotlin": 15971}
package de.nilsdruyen.aoc fun main() { fun part1(input: List<String>): String { return with(input.crates()) { input.instructions(size).fold(stacks()) { s, i -> val movedCrates = s[i.from - 1].takeLast(i.move).reversed() s[i.from - 1] = s[i.from - 1].dropLast(i.m...
0
Kotlin
0
0
1b71664d18076210e54b60bab1afda92e975d9ff
1,938
advent-of-code-2022
Apache License 2.0
src/Day03.kt
achugr
573,234,224
false
null
import kotlin.math.log2 fun main() { fun part1(input: List<String>): Int { return input.map { line -> line.toList() .chunked(line.length / 2) .map { it.fold(0L) { acc, c -> acc or (1L shl (c - 'A')) ...
0
Kotlin
0
0
d91bda244d7025488bff9fc51ca2653eb6a467ee
1,797
advent-of-code-kotlin-2022
Apache License 2.0
src/Day11.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
enum class Operation { ADD, MULTIPLY, SQUARE } fun main() { data class Monkey( var items: ArrayDeque<Long> = ArrayDeque(), val operation: Operation = Operation.MULTIPLY, val operand: Long = 0, val divisibleBy: Long = 1, val onTrue: Int = 0, val onFalse: Int = 0, ...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
3,851
kotlin_aoc_22
Apache License 2.0
src/Day02.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
fun main() { fun checkRPSWin(input: List<String>): Boolean { return (input[0] == "A" && input[1] == "B") || (input[0] == "B" && input[1] == "C") || (input[0] == "C" && input[1] == "A") } fun String.mapXtoA(): String { return when (this) { "X" -> "...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
2,727
advent-of-code
Apache License 2.0
src/day05/day06.kt
maxmil
578,287,889
false
{"Kotlin": 32792}
package day05 import println import readInput import kotlin.math.abs import kotlin.math.max data class Point(val x: Int, val y: Int) data class Line(val start: Point, val end: Point) fun main() { fun String.toCoords() = this.split(",").let { coords -> Point(coords[0].toInt(), coords[1].toInt()) } fun Line....
0
Kotlin
0
0
246353788b1259ba11321d2b8079c044af2e211a
1,511
advent-of-code-2021
Apache License 2.0
src/aoc2015/kot/Day16.kt
Tandrial
47,354,790
false
null
package aoc2015.kot import itertools.intoPairs import java.nio.file.Files import java.nio.file.Paths object Day16 { data class Sue(val num: Int, val stats: HashMap<String, Int>) fun parseAunts(lines: List<String>): List<Sue> { return lines.map { val attrs = hashMapOf<String, Int>() var num = 0 ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,500
Advent_of_Code
MIT License
src/Day09.kt
freszu
573,122,040
false
{"Kotlin": 32507}
import kotlin.math.sign /** * All adjacent including diagonals + self */ private fun Position.adjacent() = sequenceOf( this, x - 1 to y, x + 1 to y, x to y - 1, x to y + 1, x - 1 to y - 1, x + 1 to y - 1, x - 1 to y + 1, x + 1 to y + 1 ) fun main() { fun headPositions(lines: List<String>): List<Pos...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
1,823
aoc2022
Apache License 2.0
2022/src/day14/day14.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day14 import GREEN import RESET import printTimeMillis import readInput import kotlin.math.* data class Point(val x: Int, val y: Int) { fun below() = copy(x = x, y = y + 1) fun leftDiago() = copy(x = x - 1, y = y + 1) fun rightDiago() = copy(x = x + 1, y = y + 1) } // "498,4 -> 498,6 -> 496,6" =>...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,180
advent-of-code
Apache License 2.0
src/Day05.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { data class Command(val amount: Int, val from: Int, val to: Int) data class Input(val stacks: List<MutableList<String>>, val commands: List<Command>) fun input(input: List<String>): Input { val stacks = mutableListOf<MutableList<String>>() var at = 0 while ('[' in input[...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
2,086
advent-of-code-2022
Apache License 2.0
src/aoc2022/Day11.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList data class Monkey( val items: MutableList<Long>, val op: String, val opVal: Long?, val test: Int, val ifTrue: Int, val ifFalse: Int, var inspections: Long = 0L ) fun main() { fun monkeys(input: List<String>): List<Monkey> { return...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
2,870
AOC-2022-Kotlin
Apache License 2.0
src/Day12.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.util.PriorityQueue import kotlin.math.min private data class Vertex( var height: Char, var steps: Int = Int.MAX_VALUE, val x: Int, val y: Int, ) : Comparable<Vertex> { var prev: Vertex? = null val neighbours: MutableList<Vertex> = mutableListOf() override fun compareTo(other: Ve...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
4,032
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day3/Diagnostics.kt
Arch-vile
433,381,878
false
{"Kotlin": 57129}
package day3 import utils.Binary import utils.read fun main() { solve().forEach { println(it) } } fun solve(): List<Long> { val data = read("./src/main/resources/day3Input.txt") .map { Binary.from(it) } var mostCommonBits = mostCommonBits(data) val gamma = mostCommonBits.asLong() val ep...
0
Kotlin
0
0
4cdafaa524a863e28067beb668a3f3e06edcef96
1,445
adventOfCode2021
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day21.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 21 - <NAME> * Problem Description: http://adventofcode.com/2021/day/21 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day21/ */ package com.ginsberg.advent2021 class Day21(input: List<String>) { private val pla...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
3,080
advent-2021-kotlin
Apache License 2.0
src/main/kotlin/net/dilius/daily/coding/problem/n00x/002.kt
diliuskh
298,020,928
false
null
package net.dilius.daily.coding.problem.n00x import net.dilius.daily.coding.problem.Problem /* Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], ...
0
Kotlin
0
0
7e5739f87dbce2b56d24e7bab63b6cee6bbc54bc
2,014
dailyCodingProblem
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day18.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 import adventofcode.util.vector.neighbors fun main() = Day18.solve() object Day18 : AdventSolution(2019, 18, "Many-Worlds Interpretation") { private val alphabet = 'a...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
5,454
advent-of-code
MIT License