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/day08/Day08.kt
commanderpepper
574,647,779
false
{"Kotlin": 44999}
package day08 import readInput fun main(){ val day08Input = readInput("day08") println(day08Input) val trees : List<List<Tree>> = day08Input.mapIndexed {rowIndex, row -> row.mapIndexed { colIndex, height -> Tree(height = height.toString().toInt(), row = rowIndex, col = colIndex) ...
0
Kotlin
0
0
fef291c511408c1a6f34a24ed7070ceabc0894a1
4,837
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BeautifulPartitions.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,940
kotlab
Apache License 2.0
src/Day09.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Point(val x: Int, val y: Int) { fun move(direction: String) = when (direction) { "U" -> Point(x, y + 1) "D" -> Point(x, y - 1) "L" -> Point(x - 1, y) "R" -> Point(x + 1, y) els...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
1,952
aoc22-kt
Apache License 2.0
kotlin/src/Day13.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val pairs = input.takeWhile { line -> line != "" }.map { line -> val (x, y) = line.split(",") parseInt(x) to parseInt(y) } val (type, value) = input ...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
2,968
aoc-2021
MIT License
src/day07/Day07.kt
felldo
572,762,654
false
{"Kotlin": 104604}
package day07 import readInputString data class File(val name: String, val size: Long) class Directory(val parent: Directory?) { val children = mutableMapOf<String, Directory>() val files = mutableListOf<File>() } fun main() { fun getDirectorySize(directory: Directory): Long { var totalSize = di...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
3,594
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/threesum/ThreeSum.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.threesum import com.google.common.collect.HashMultiset import com.google.common.collect.Multiset import datsok.shouldEqual import org.junit.Test import kotlin.random.Random import kotlin.random.nextInt // // https://leetcode.com/problems/3sum ✅ // https://en.wikipedia.org/wiki/3SUM // //...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
4,620
katas
The Unlicense
src/Day10/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day10 import readInput import kotlin.math.abs object Day10 { fun runInstructions(instructions: List<String>, registerValue: Int, maxCycles: Int) : List<Int> { val register = mutableListOf<Int>() var instructionIndex = 0 while (register.size <= maxCycles) { val lastValu...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
2,442
aoc-2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day11.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputSplitOnBlank object Day11 : Day { override val input: List<Input> = readInputSplitOnBlank(11).map { parse(it) } override fun part1() = solve(20) { it / 3 } override fun...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
3,471
aoc2022
MIT License
src/main/kotlin/y2022/day11/Day11.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2022.day11 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } data class Monkey( val items: MutableList<Long>, val inspectionOperation: String, val inspectionChangeValue: Int?, // null means old value val testDivision: Int, ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
3,689
AdventOfCode
MIT License
src/main/kotlin/org/sjoblomj/adventofcode/day7/Node.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day7 private val regex = "Step (?<dep>[A-Z]) must be finished before step (?<id>[A-Z]) can begin.".toRegex() data class Node(val id: String, val prerequisites: MutableList<Node>, val dependers: MutableList<Node>) { fun setAsDependency(otherNode: Node) { dependers.add(otherNod...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
2,232
adventofcode2018
MIT License
src/main/kotlin/Day2.kt
amitdev
574,336,754
false
{"Kotlin": 21489}
import RPS.PAPER import RPS.ROCK import RPS.SCISSORS import java.io.File import kotlin.IllegalArgumentException fun main() { val result = File("inputs/day_2.txt").useLines { computeScorePart2(it) } println(result) } // Part 1 fun computeScorePart1(lines: Sequence<String>) = lines.map { it.split(" ") } .map ...
0
Kotlin
0
0
b2cb4ecac94fdbf8f71547465b2d6543710adbb9
1,319
advent_2022
MIT License
src/main/kotlin/com/sk/topicWise/dp/medium/72. Edit Distance.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.dp.medium class Solution72 { // https://leetcode.com/problems/edit-distance/solutions/25895/step-by-step-explanation-of-how-to-optimize-the-solution-from-simple-recursion-to-dp /** * Top-down */ fun minDistance(word1: String, word2: String): Int { if (word1.isEm...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,833
leetcode-kotlin
Apache License 2.0
src/Day03.kt
bananer
434,885,332
false
{"Kotlin": 36979}
fun main() { fun countBits(input: Iterable<String>): IntArray { val setBitCounts = IntArray(input.first().length) for (line in input) { line.toCharArray().forEachIndexed { index, c -> if (c == '1') { setBitCounts[index]++ } ...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
2,410
advent-of-code-2021
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day19/Day19Part2.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day19 import com.tonnoz.adventofcode23.utils.println import com.tonnoz.adventofcode23.utils.readInput import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis object Day19Part2 { data class Workflow(val name: String, val rules: List<Rule>) data class ...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,706
adventofcode23
MIT License
src/Day04.kt
dmdrummond
573,289,191
false
{"Kotlin": 9084}
fun main() { fun toRanges(input: String): Pair<IntRange, IntRange> { val (range1Str, range2Str) = input.split(',') val (range1Start, range1End) = range1Str.split('-') val (range2Start, range2End) = range2Str.split('-') return Pair(range1Start.toInt()..range1End.toInt(), range2Start....
0
Kotlin
0
0
2493256124c341e9d4a5e3edfb688584e32f95ec
1,188
AoC2022
Apache License 2.0
src/Day01.kt
andydenk
573,909,669
false
{"Kotlin": 24096}
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day01_test") check(part1(testInput) == 24000) check(part2(testInput) == 45000) val input = readInput("Day01") println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } ...
0
Kotlin
0
0
1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1
1,439
advent-of-code-2022
Apache License 2.0
src/year2021/day4/Day.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2021.day4 import java.util.stream.IntStream import readInput fun main() { fun toCard(it: List<String>) { TODO("Not yet implemented") } fun part1(input: List<String>): Int { val possible = input[0].split(",").map { it.toInt() } val cards = input.drop(2).filterNot { it...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
2,271
adventOfCode
Apache License 2.0
src/Day03.kt
kuolemax
573,740,719
false
{"Kotlin": 21104}
fun main() { fun part1(input: List<String>): Int { // 将String变成char数组,均分后取交集,转成ascii相加 return input.sumOf { backpack -> val chunked = backpack.toCharArray().toList().chunked(backpack.length / 2) val chars = chunked[0].toSet() intersect chunked[1].toSet() if (char...
0
Kotlin
0
0
3045f307e24b6ca557b84dac18197334b8a8a9bf
1,355
aoc2022--kotlin
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day21.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day21 : AdventSolution(2021, 21, "<NAME>") { override fun solvePartOne(input: String): Int { var (p1, p2) = parse(input) p1-- p2-- var p1Score = 0 var p2Score = 0 var dice = 1 var rolls ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,141
advent-of-code
MIT License
src/Day07.kt
a2xchip
573,197,744
false
{"Kotlin": 37206}
class FilesystemNode( private val name: String, val parent: FilesystemNode?, ) { val children: MutableList<FilesystemNode> = mutableListOf() val fileSizes: MutableList<Int> = mutableListOf() fun getTotalSize(): Int { return fileSizes.fold(0) { acc, i -> acc + i } + getChildSize() } ...
0
Kotlin
0
2
19a97260db00f9e0c87cd06af515cb872d92f50b
3,620
kotlin-advent-of-code-22
Apache License 2.0
src/main/kotlin/day14/Day14.kt
daniilsjb
434,765,082
false
{"Kotlin": 77544}
package day14 import java.io.File fun main() { val (template, rules) = parse("src/main/kotlin/day14/Day14.txt") val answer1 = part1(template, rules) val answer2 = part2(template, rules) println("🎄 Day 14 🎄") println() println("[Part 1]") println("Answer: $answer1") println() ...
0
Kotlin
0
1
bcdd709899fd04ec09f5c96c4b9b197364758aea
2,026
advent-of-code-2021
MIT License
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p04/Leet435v2.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p04 import java.util.TreeMap private class Leet435v2 { val knownOverlaps = TreeMap<Int, Int>() val filteredOutKeys = HashSet<Int>() fun eraseOverlapIntervals(intervals: Array<IntArray>): Int { knownOverlaps.clear() filteredOutKeys.clear() for (i i...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
6,831
playground
MIT License
src/main/kotlin/graph/variation/PalindromicPath.kt
yx-z
106,589,674
false
null
package graph.variation import graph.core.* import util.OneArray import util.get import util.max import util.set // given a DAG G = (V, E), with each vertex associated with a character, // find the longest path from in V : the string composed of characters // from corresponding vertices in this path is palindromic /...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
2,518
AlgoKt
MIT License
src/day13/Code.kt
fcolasuonno
162,470,286
false
null
package day13 import MultiMap import permutations import java.io.File fun main(args: Array<String>) { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(par...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
1,393
AOC2015
MIT License
src/Day03.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
fun getCommonItems(line: String): Set<Char> { if (line.length % 2 != 0) { throw IllegalArgumentException("Input size must be even") } val (left, right) = line.chunked(line.length / 2) return left.toSet() intersect right.toSet() } fun Char.priority(): Int = when (this) { in 'a'..'z' -> this...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
1,204
aoc-2022
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day05.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 data class Range( val source: Long, val target: Long, val length: Long, ) data class Category( val name: String, val ranges: MutableList<Range>, ) fun findLocation(seed: Long, almanac: List<Category>): Long { var current = seed almanac.forEach { category -> ...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
2,069
advent-of-code
MIT License
2022/Day21.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import java.math.BigDecimal import java.math.RoundingMode fun main() { data class Poly( val coef: List<BigDecimal> ) { operator fun plus(o: Poly): Poly { val n = maxOf(coef.size, o.coef.size) return Poly(Array(n) { i -> coef.getOrElse(i) { BigDecimal.ZERO...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
3,215
advent-of-code-kotlin
Apache License 2.0
src/Day18.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
data class Point3D( val x: Int, val y: Int, val z: Int ) { val neighbors: Set<Point3D> by lazy { setOf( this.copy(x = x - 1), this.copy(x = x + 1), this.copy(y = y - 1), this.copy(y = y + 1), this.copy(z = z - 1), this.copy(...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,081
KotlinAdventOfCode2022
Apache License 2.0
src/main/kotlin/solutions/Day18BoilingBoulders.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import models.Coord3d import utils.Input import utils.Solution import java.util.* import kotlin.math.abs // run only this day fun main() { Day18BoilingBoulders() } class Day18BoilingBoulders : Solution() { init { begin("Day 18 - Boiling Boulders") val input = Input.parseToL...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
2,629
advent-of-code-2022
MIT License
day-04/src/main/kotlin/GiantSquid.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
fun main() { println("Part One Solution: ${partOne()}") println("Part Two Solution: ${partTwo()}") } private fun partOne(): Int { val numbersToDraw = readNumberToDraw() val bingoCards = readBingoCards() numbersToDraw.forEach { number -> bingoCards.forEach { card -> card.mark(n...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
3,068
aoc-2021
MIT License
src/y2016/Day04.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.readInput object Day04 { private fun parse(input: List<String>): List<Triple<String, Int, String>> { return input.map { Triple( it.substringBeforeLast('-'), it.substringAfterLast('-').substringBefore('[').toInt(), it.sub...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,962
advent-of-code
Apache License 2.0
src/main/kotlin/day1.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
private fun tests() { val measures = """ 199 200 208 210 200 207 240 269 260 263 """.trimIndent() val numbers = measures.lines().map { it.toInt() } assertEquals(numberOfIncreases(numbers), 7) assertEquals(numberOfMaskedI...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
2,407
AOC-2021
MIT License
src/main/kotlin/Day17.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset import java.util.PriorityQueue fun main() { data class CityBlock( val id: Pair<Int, Int>, val cost: Int ) { override fun toString(): String { return "Node(id=$id, cost=$cost)" } } fun getMap(lines:...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
3,215
aoc-2023-in-kotlin
Apache License 2.0
src/year2022/20/Day20.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`20` import readInput fun parseInput(input: List<String>): List<Long> { return input.map { it.toLong() } } fun mixList( repeat: Int, items: List<Pair<Int, Long>>, ): List<Pair<Int, Long>> { val mutableItems = items.toMutableList() repeat(repeat) { items.forEach { ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
2,312
KotlinAdventOfCode
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day13.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val grids = readInput(2023, 13).useLines { sequence -> val lines = sequence.iterator() buildList<List<String>> { var current = arrayListOf<String>() while (lines.has...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,027
adventofcode
Apache License 2.0
src/Day03.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
private val priorityList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun main() { // TODO: This is better fun priority(groups: List<String>): Int { val chars = groups.flatMap { it.toSet() } val sharedItem = chars.groupingBy { it }.eachCount().maxBy { it.value }.key return i...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
1,618
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day3.kt
hughjdavey
225,440,374
false
null
package days import kotlin.math.abs class Day3 : Day(3) { private val path1 = inputList[0] private val path2 = inputList[1] override fun partOne(): Any { return closestIntersectionSum(path1, path2) } override fun partTwo(): Any { return fewestSteps(path1, path2) } fun c...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
2,412
aoc-2019
Creative Commons Zero v1.0 Universal
src/Day05.kt
bjornchaudron
574,072,387
false
{"Kotlin": 18699}
fun main() { fun part1(input: List<String>): String { val (stacks, commands) = parseInput(input) val crane = Crane(stacks, moveMultiple = false) crane.executeCommands(commands) return joinTopCrates(stacks) } fun part2(input: List<String>): String { val (stacks, comm...
0
Kotlin
0
0
f714364698966450eff7983fb3fda3a300cfdef8
3,005
advent-of-code-2022
Apache License 2.0
src/year2022/day19/Day19.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day19 import check import readInput import kotlin.math.max import kotlin.system.measureTimeMillis import kotlin.time.Duration.Companion.milliseconds fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day19_test") check(part...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
7,199
AdventOfCode
Apache License 2.0
src/Day16.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private val lineFormat = """Valve (\w+) has flow rate=(\d+); tunnels? leads? to valves? (.*)""".toRegex() private data class Valve( val name: String, val flowRate: Int, val neighbours: List<String> ) private const val TOTAL_TIME = 30 private fun valves(input: List<String>): List<Valve> { return input...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
5,909
advent-of-code-2022
Apache License 2.0
src/Day15.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Sensor(val position: Pair<Int, Int>, val beacon: Pair<Int, Int>) fun main() { fun List<String>.parse(): List<Sensor> { val sensorRegex = "Sensor at x=(?<sx>-?\\d+), y=(?<sy>-?\\d+): closest beacon is at x=(?<bx>-?\...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
3,651
advent-of-code-2022
Apache License 2.0
kotlin/0014-longest-common-prefix.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}
/* * Solution as per the channel */ class Solution { fun longestCommonPrefix(strs: Array<String>): String { var len = 0 outerloop@ for(i in 0 until strs[0].length){ for(s in strs){ if(i == s.length || s[i] != strs[0][i]){ break@outerloop ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,135
leetcode
MIT License
src/Day11.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File // Advent of Code 2022, Day 11, Monkey in the Middle fun main() { fun readInputAsOneLine(name: String) = File("src", "$name.txt").readText().trim() data class Monkey( val items: MutableList<Long>, val operation: List<String>, val test: Int, val monkeyTrue:...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
2,654
AdventOfCode2022
Apache License 2.0
src/Day07.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import FilesystemStructure.Directory import FilesystemStructure.File import utils.readInputAsText fun main() { val input = readInputAsText("day07_input") val regex = Regex("""\$\s+(\w+)\s+([\s\S]+?)(?=\s+\$|\Z)""") val commands = regex.findAll(input) .map { it.groupValues } .map { (_, comma...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
2,952
advent-of-code-2022
Apache License 2.0
2022/src/test/kotlin/Day11.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe private data class Operation(val op: String, val other: String) { fun run(level: Long) = when (op) { "*" -> level * if (other == "old") level else other.toLong() "+" -> level + if (other == "old") level else other.toLong...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,105
adventofcode
MIT License
app/src/y2021/day14/Day14ExtendedPolymerization.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day14 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle typealias PolymerLut = Map<String, List<String>> typealias PolymerFrequency = Map<String, Long> fun main(args: Array<String>) { Day14ExtendedPolymerization().solveThem() } @AoCPuzzle(2021, 14) class Day14Exte...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
2,850
advent-of-code-2021
Apache License 2.0
src/Day11.kt
karloti
573,006,513
false
{"Kotlin": 25606}
import java.lang.IllegalArgumentException data class Monkey( val number: Int, val worryLevel: MutableList<Long>, val oppSign: Char, val oppNumber: Int?, val div: Int, val ifTrueMonkeyNum: Int, val ifFalseMonkeyNum: Int, var inspectCount: Long = 0, ) fun List<String>.toMonkey(): Monkey ...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
2,383
advent-of-code-2022-kotlin
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day14.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val input = readInput(2023, 14).readLines().map { it.toCharArray() } part1(input) part2(input) } private fun part1(input: List<CharArray>) { val sum = tiltVertical(input, north = true, modify ...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
2,695
adventofcode
Apache License 2.0
src/day11/Day11.kt
treegem
572,875,670
false
{"Kotlin": 38876}
package day11 import common.readInput fun main() { fun part1(input: List<String>) = solve(input.toSortedMonkeys(), repetitions = 20) { it.div(3) } fun part2(input: List<String>): Long { val monkeys = input.toSortedMonkeys() return solve(monkeys, repetitions = 10_000) { newWorry -> ...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
1,225
advent_of_code_2022
Apache License 2.0
src/day11.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import kotlin.math.abs import kotlin.system.exitProcess private const val DAY = 11 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: String -> x.toList() } val input...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
2,222
aoc2023
MIT License
src/y2023/Day01.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { val days: List<Pair<String, Char>> = mapOf( "one" to '1', "two" to '2', "three" to '3', "four" to '4', "five" to '5', "six" to '6', "seven" to '7', "eight" to '8', "nine" to '9', ).toList...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
1,570
advent-of-code-kotlin
Apache License 2.0
src/year2022/day14/Day14.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day14 import check import readInput import kotlin.math.max import kotlin.math.min fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day14_test") check(part1(testInput), 24) check(part2(testInput), 93) val input =...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,548
AdventOfCode
Apache License 2.0
src/Day02.kt
toninau
729,811,683
false
{"Kotlin": 8423}
fun main() { val redCubesMax = 12 val greenCubesMax = 13 val blueCubesMax = 14 data class CubeSet(val red: Int, val green: Int, val blue: Int) data class Game(val gameId: Int, val cubeSets: List<CubeSet>) fun lineToGame(input: List<String>): List<Game> { return input.map { line -> ...
0
Kotlin
0
0
b3ce2cf2b4184beb2342dd62233b54351646722b
1,548
advent-of-code-2023
Apache License 2.0
src/day05.kt
skuhtic
572,645,300
false
{"Kotlin": 36109}
fun main() { day05.execute(onlyTests = false, forceBothParts = true) } val day05 = object : Day<String>(5, "CMZ", "MCD") { override val testInput: InputData get() = """ [D] [N] [C] [Z] [M] [P] 1 2 3 ...
0
Kotlin
0
0
8de2933df90259cf53c9cb190624d1fb18566868
2,053
aoc-2022
Apache License 2.0
src/main/kotlin/Day13.kt
alex859
573,174,372
false
{"Kotlin": 80552}
fun main() { val testInput = readInput("Day13_test.txt") check(testInput.day13Part1() == 13) check(testInput.day13Part2() == 140) val input = readInput("Day13.txt") println(input.day13Part1()) println(input.day13Part2()) } internal fun String.day13Part1() = split("\n\n") .mapIndex...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
2,881
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/aoc2022/Day16.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day import kotlin.math.max class Day16 : Day(2022, 16) { override fun partOne(): Any { return calculateMaxPressureReliefOverTime(inputList, 30) } override fun partTwo(): Any { return calculateMaxPressureReliefOverTimeWithTwoParticipants(inputList, 26) ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,724
Advent-Of-Code
Creative Commons Zero v1.0 Universal
aoc/src/Soil.kt
aragos
726,211,893
false
{"Kotlin": 16232}
import java.io.File import java.lang.IllegalArgumentException data class Range(val sourceStart: Long, val destinationStart: Long, val rangeLength: Long) { val sources = LongRange(sourceStart, sourceStart + rangeLength - 1) override fun toString(): String { return "$sources -> ${LongRange(destinationStart, dest...
0
Kotlin
0
0
7bca0a857ea42d89435adc658c0ff55207ca374a
3,670
aoc2023
Apache License 2.0
src/main/kotlin/day11/day11.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package day11 import main.utils.* import utils.readFile import utils.separator inline operator fun <T> List<T>.component6(): T { return get(5) } fun main() { val test = readFile("day11_test") val input = readFile("day11") data class Monkey( val number: Int, val worriedLevel: Long, val items: Mu...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
4,615
aoc-2022-in-kotlin
Apache License 2.0
src/day02/Day02.kt
shiddarthbista
572,833,784
false
{"Kotlin": 9985}
package day02 import readInput fun main() { fun part1(input: List<String>): Int = input.sumOf { calculateScore(it.split(" ").first(), it.split(" ").last(),1) } fun part2(input: List<String>): Int = input.sumOf { calculateScore(it.split(" ").first(), it.split(" ...
0
Kotlin
0
0
ed1b6a132e201e98ab46c8df67d4e9dd074801fe
1,185
aoc-2022-kotlin
Apache License 2.0
src/Day04A.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
import kotlin.system.measureNanoTime data class SectionRangeB( val startSection : Int, val endSection: Int ) infix fun IntRange.contains(other: IntRange): Boolean { return other.first >= this.first && other.last <= this.last } infix fun SectionRangeB.isFullyContainedB(other: SectionRangeB): Boolean { ...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
1,727
aoc-2022
Apache License 2.0
src/Day05.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
fun main() { data class Operation(val amount: Int, val from: Int, val to: Int) fun parseStack(input: List<String>): List<ArrayDeque<Char>> { /* [D] [N] [C] [Z] [M] [P] 1 2 3 */ val reversed = input.reversed() val numberOf...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
2,452
advent-of-code-2022
Apache License 2.0
src/year2015/day20/Day20.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day20 import readInput import kotlin.math.sqrt fun main() { val input = readInput("2015", "Day20") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val minPresents = input.first().toInt() val pf = PrimeFactors(minPresents / 10) for (...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,908
AdventOfCode
Apache License 2.0
src/day15/puzzle15.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day15 import Puzzle import PuzzleInput import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import java.io.File import kotlin.math.abs fun day15Puzzle() { Day15PuzzleSolution().solve(Day15PuzzleInput("inputs/day15/example.txt",10, 26)) Day15PuzzleSolution().solve(Day15PuzzleInput("in...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
6,049
aoc_2022
Apache License 2.0
src/day20/a/day20a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day20.a import readInputLines import shouldBe fun main() { val input = read() val reordered = ArrayList(input) rotateOnce(input, reordered) val j = reordered.indexOfFirst { it.value == 0L } val answer = (1..3).sumOf { reordered[(j + it * 1000) % reordered.size].value } shouldBe(7225,...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
1,553
advent-of-code-2022
Apache License 2.0
src/Day04.kt
zirman
572,627,598
false
{"Kotlin": 89030}
fun main() { fun ranges(pair: String): List<IntRange> { return pair.split(',') .map { it.split('-') .let { (start, end) -> start.toInt()..end.toInt() } } } fun part1(input: List<String>): Long { return input.sumOf { pair -> ...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
1,157
aoc2022
Apache License 2.0
aoc2016/aoc2016-kotlin/src/main/kotlin/de/havox_design/aoc2016/day24/AirDuctSpelunking.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2016.day24 import de.havox_design.aoc.utils.kotlin.model.positions.Position2d import java.util.ArrayDeque class AirDuctSpelunking(private var filename: String) { fun solvePart1(): Int = shortestPath(parseInput(), false) fun solvePart2(): Int = shortestPath(parseInpu...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
3,189
advent-of-code
Apache License 2.0
src/main/kotlin/Day09.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
import kotlin.math.abs class Day09 { fun part1(input: List<String>): Int { val movement = input.map { it.split(" ") } .flatMap { (direction, step) -> (1..step.toInt()).map { direction.toDirection() } } return simulateMoves(movement, 2).size } fun part2(input: List<String>): In...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
2,226
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day19.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 19 - Beacon Scanner * Problem Description: http://adventofcode.com/2021/day/19 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day19/ */ package com.ginsberg.advent2021 class Day19(input: String) { private val s...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
2,462
advent-2021-kotlin
Apache License 2.0
src/day18/Day18.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day18 import day18.Cube.Companion.normals import readInput import kotlin.math.sqrt fun main() { val day = 18 val testInput = readInput("day$day/testInput") // check(part1(testInput) == 64) check(part2(testInput) == 58) val input = readInput("day$day/input") println(part1(input)) // ...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
4,303
advent-of-code-2022
Apache License 2.0
src/Day09.kt
kmakma
574,238,598
false
null
fun main() { val oneX = Coord2D(1, 0) val oneY = Coord2D(0, 1) data class Motion(val dir: Char, val count: Int) fun mapToMotions(input: List<String>): List<Motion> { return input.map { val (d, c) = it.split(" ") Motion(d.first(), c.toInt()) } } fun move...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
2,370
advent-of-kotlin-2022
Apache License 2.0
src/Day21.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
private sealed interface MonkeyJob { val name: String } private data class OperationMonkeyJob( override val name: String, val left: String, val operation: Char, val right: String ) : MonkeyJob { override fun toString() = "$name: $left $operation $right" } private data class ValueMonkeyJob( ...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
3,357
advent-of-code-2022
Apache License 2.0
src/Day04.kt
rafael-ribeiro1
572,657,838
false
{"Kotlin": 15675}
fun main() { fun part1(input: List<String>): Int { return input.toPairsWithRanges() .count { pair -> pair.first.intersect(pair.second).let { it.size == pair.first.size || it.size == pair.second.size } } } fun part2(input: L...
0
Kotlin
0
0
5cae94a637567e8a1e911316e2adcc1b2a1ee4af
1,021
aoc-kotlin-2022
Apache License 2.0
src/Day04.kt
BenHopeITC
573,352,155
false
null
fun main() { val day = "Day04" fun part1(input: List<String>): Int { return input.fold(0) { accFullyContains, elfPair -> val fullyContains = elfPair .split(",") .map { elfSectionsStr -> val nums = elfSectionsStr.split("-") ...
0
Kotlin
0
0
851b9522d3a64840494b21ff31d83bf8470c9a03
1,891
advent-of-code-2022-kotlin
Apache License 2.0
src/Day09.kt
hijst
572,885,261
false
{"Kotlin": 26466}
import Direction.EAST import Direction.NORTH import Direction.SOUTH import Direction.WEST import kotlin.math.abs fun main() { data class Move(val direction: Direction, val amount: Int) data class Position(val x: Int, val y: Int) fun String.toDirection() = when (this) { "U" -> NORTH "D" -> ...
0
Kotlin
0
0
2258fd315b8933642964c3ca4848c0658174a0a5
3,214
AoC-2022
Apache License 2.0
src/aoc2022/Day05.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 private typealias StacksMap = Map<Int, ArrayDeque<Char>> private data class RearrangementProcedure(val movesCount: Int, val sourceStackNo: Int, val desStackNo: Int) fun main() { fun List<String>.splitStacksFromProcedures(): Pair<List<String>, List<String>> { val stacksCrates = this.takeW...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
3,047
Kotlin-AOC-2023
Apache License 2.0
src/main/kotlin/days/Day14.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day14 : Day(14) { override fun partOne(): Any { return tilt(inputList, Direction.NORTH).reversed() .mapIndexed { index, s -> (index + 1) * s.count { it == 'O' } } .sum() } override fun partTwo(): Any { val (indexOfRepeated, indexOfRepeat) = gener...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
2,313
aoc-2023
Creative Commons Zero v1.0 Universal
src/challenges/Day04.kt
paralleldynamic
572,256,326
false
{"Kotlin": 15982}
package challenges import utils.readInput private const val LABEL = "Day04" fun checkContains(sections: List<String>): Boolean { val (first_lower, first_upper) = sections.first().split("-").map { bound -> bound.toInt() } val (second_lower, second_upper) = sections.last().split("-").map { bound -> bound.toInt...
0
Kotlin
0
0
ad32a9609b5ce51ac28225507f77618482710424
1,444
advent-of-code-kotlin-2022
Apache License 2.0
y2019/src/main/kotlin/adventofcode/y2019/Day17.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.language.intcode.IntCodeProgram import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 fun main() = Day17.solve() object Day17 : AdventSolution(2019, 17, "Set and Forget") { override fun solvePartOne(inp...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
4,229
advent-of-code
MIT License
src/day14/Day14_functional.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day14 import Point2D import readLines /** * Credit goes to tginsberg (https://github.com/tginsberg/advent-2022-kotlin) * I'm experimenting with his solutions to better learn functional programming in Kotlin. * Files without the _functional suffix are my original solutions. */ private fun Point2D.down(): ...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,994
aoc2022
Apache License 2.0
src/main/kotlin/day8/Day8.kt
gornovah
573,055,751
false
{"Kotlin": 20487}
package day8 import load fun main() { val loadedData = load("/day-8.txt") val grid = loadedData.map { line -> line.map { it.digitToInt() } } println("Solution to Day 7, Part 1 is '${solveDay8PartOne(grid)}'") println("Solution to Day 7, Part 2 is '${solveDay8PartTwo(grid)}'") } fun solveDay8PartOne(...
0
Kotlin
0
0
181d1094111bd137f70a580ca32a924b582adf70
2,255
advent_of_code_2022
MIT License
src/main/kotlin/com/jackchapman/codingchallenges/hackerrank/EmasSupercomputer.kt
crepppy
381,882,392
false
null
package com.jackchapman.codingchallenges.hackerrank typealias Plus = List<Pair<Int, Int>> /** * Problem: [Ema's Supercomputer](https://www.hackerrank.com/challenges/two-pluses/) * * Given a matrix of good (`G`) cells and bad (`B`) cells, find 2 pluses made of * good cells whose area has the greatest product * @p...
0
Kotlin
0
0
9bcfed84a9850c3977ccff229948cc31e319da1b
2,019
coding-challenges
The Unlicense
src/main/kotlin/aoc/year2023/Day04.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2023 import aoc.Puzzle import kotlin.math.pow /** * [Day 4 - Advent of Code 2023](https://adventofcode.com/2023/day/4) */ object Day04 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int = input.lineSequence().map { it.toCard() }.sumOf { it.points } override fun solvePartTwo(...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,473
advent-of-code
Apache License 2.0
src/Day03.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { fun Char.cost(): Int { if (isLowerCase()) { return code - 'a'.code + 1 } return code - 'A'.code + 27 } fun intersect(a: Iterable<Char>, b: Iterable<Char>): Collection<Char> { val res = mutableSetOf<Char>() for (c in a) { if (c in ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
1,343
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem18/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem18 /** * LeetCode page: [18. 4Sum](https://leetcode.com/problems/4sum/); */ class Solution { /* Complexity: * Time O(N^3), Aux_Space O(N) and Space O(N^3) where N is the size of nums; */ fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val so...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
4,230
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/Day3.kt
lanrete
244,431,253
false
null
import kotlin.math.abs data class Point(val x: Int, val y: Int) { override fun toString(): String { return "($x, $y)" } } data class Line(val start: Point, val end: Point) { override fun toString(): String { return "[$start -> $end]" } } typealias Wire = List<Line> fun Line.points():...
0
Kotlin
0
1
15125c807abe53230e8d0f0b2ca0e98ea72eb8fd
3,705
AoC2019-Kotlin
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year16/Day11.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year16 import com.grappenmaker.aoc.* fun PuzzleSet.day11() = puzzle(day = 11) { val elementsRegex = """(, (and )?)|( and )""".toRegex() data class Component(val element: String, val chip: Boolean) data class State(val floors: List<Set<Component>>, val elevator: Int = 0) ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,898
advent-of-code
The Unlicense
src/Day05.kt
jalex19100
574,686,993
false
{"Kotlin": 19795}
import java.util.* import kotlin.collections.ArrayList class StacksOfCrates() { private val stacks = HashMap<Int, LinkedList<Char>>() fun add(stackNumber: Int, crate: Char) { if (stacks.containsKey(stackNumber)) stacks?.get(stackNumber)?.add(crate) else { val stack = LinkedList<Cha...
0
Kotlin
0
0
a50639447a2ef3f6fc9548f0d89cc643266c1b74
3,310
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
data class Interval(var start: Int, var end: Int) fun parseInterval(s: String): Interval { val (start, end) = s.split('-') return Interval(start.toInt(), end.toInt()) } fun isFullyOverlap(int1: Interval, int2: Interval): Boolean { return int1.start <= int2.start && int1.end >= int2.end } fun isOverlap(in...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
1,551
aoc2022
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day284/day284.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day284 // day284.kt // By <NAME>, 2020. typealias Depth = Int typealias ParentChild = Pair<Int, Int> typealias Cousins = Pair<Int, Int> typealias DepthInfo = Map<Depth, List<ParentChild>> data class BinaryTree(val value: Int, val left: BinaryTree?, val right: BinaryTree?) { // Find all cousins: cousin...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,824
daily-coding-problem
MIT License
src/year2016/day02/Day02.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2016.day02 import check import readInput fun main() { val testInput = readInput("2016", "Day02_test") check(part1(testInput), 1985) check(part2(testInput), "5DB3") val input = readInput("2016", "Day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<S...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,842
AdventOfCode
Apache License 2.0
src/Day04.kt
3n3a-archive
573,389,832
false
{"Kotlin": 41221, "Shell": 534}
fun Day04() { fun preprocess(input: List<String>): List<List<Set<Int>>> { return input .map { it.split(",") } // to pair of elves .map { it.map { it2 -> it2.split("-") } } // each elf gets...
0
Kotlin
0
0
fd25137d2d2df0aa629e56981f18de52b25a2d28
1,684
aoc_kt
Apache License 2.0
src/Day05/Day05.kt
Trisiss
573,815,785
false
{"Kotlin": 16486}
fun main() { fun numbersOfStacks(lines: List<String>): Int = lines .dropWhile { it.contains("[") } .first() .split(" ") .filter { it.isNotBlank() } .maxOf { it.toInt() } fun populateStacks(lines: List<String>, onCharacterAdd: (numberOfStack: ...
0
Kotlin
0
0
cb81a0b8d3aa81a3f47b62962812f25ba34b57db
2,780
AOC-2022
Apache License 2.0
src/Day20.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { fun part1(input: List<String>): Int { val original = input.mapIndexed { idx, element -> Pair(idx, element.toInt()) } val numbers = original.toMutableList() val modulo = numbers.size for (number in original.indices) { val idx = numbers.indexOfFirst { it.first...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
1,901
aoc-2022-in-kotlin
Apache License 2.0
03/03.kt
Steve2608
433,779,296
false
{"Python": 34592, "Julia": 13999, "Kotlin": 11412, "Shell": 349, "Cython": 211}
import java.io.File private class Diagnostics(val data: Array<String>) { val lastIndex: Int get() = data[0].lastIndex private val andBitMask: Int get() = (1 shl (lastIndex + 1)) - 1 val gamma: Int get() { val counts = IntArray(data[0].length) data.forEach { it.forEachIndexed { i, _ -> counts[i] = coun...
0
Python
0
1
2dcad5ecdce5e166eb053593d40b40d3e8e3f9b6
2,419
AoC-2021
MIT License
src/main/kotlin/day5/Day5.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day5 import java.io.File typealias Coordinates = Pair<Int, Int> typealias Matrix = Map<Coordinates, Int> private val regex = """(\d+),(\d+) -> (\d+),(\d+)""".toRegex() fun parseLine(line: String): List<Int> = regex.matchEntire(line)!! .groupValues.drop(1) // dropping first item because it's the whole ...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
1,487
advent-of-code-2021
MIT License
src/Day07.kt
timhillgit
572,354,733
false
{"Kotlin": 69577}
import kotlin.math.max private sealed interface ElfFile private data class ElfRegularFile(val size: Int): ElfFile private class ElfPath(segments: List<String>): List<String> by segments { constructor(vararg segments: String) : this(segments.toList()) override fun toString() = joinToString(separator = SEPARA...
0
Kotlin
0
1
76c6e8dc7b206fb8bc07d8b85ff18606f5232039
3,255
advent-of-code-2022
Apache License 2.0
src/Day03/Day03.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day03 import readInput fun main() { fun score(char: Char): Int { if (char.isLowerCase()) { return char.code - 'a'.code + 1 } else { return char.code - 'A'.code + 27 } } fun part1(input: List<String>): Int { var score = 0 for (line ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
1,950
aoc-2022
Apache License 2.0
src/main/kotlin/day20.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day20 : Solvable("20") { override fun solveA(input: List<String>): String { val (enhancement, image) = getImageEnhancement(input) return solve(image, enhancement, 2).toString() } override fun solveB(input: List<String>): String { val (enhancement, image) = getImageEnhancemen...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
2,756
AdventOfCode
Creative Commons Zero v1.0 Universal
archive/src/main/kotlin/com/grappenmaker/aoc/year23/Day07.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year23 import com.grappenmaker.aoc.* fun PuzzleSet.day7() = puzzle(day = 7) { data class Hand(val l: List<Char>, val bid: Long) val hs = inputLines.map { l -> val (a, b) = l.split(" ") Hand(a.toList(), b.toLong()) } fun solve(partTwo: Boolean, order: Strin...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,438
advent-of-code
The Unlicense
src/Day16.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
import java.util.concurrent.atomic.AtomicInteger private data class Valve(val id: String, val rate: Int, val tunnels: List<String>) private val routes = mutableMapOf<Set<String>, Int>() private fun Map<String, Valve>.calcRouteCost(start: String, end: String): Int { val nodes = setOf(start, end) if (nodes in r...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
4,577
aoc22
Apache License 2.0