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/cn/leetcode/codes/offer/o42/Inter42.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.offer.o42 import cn.leetcode.codes.out import kotlin.math.max fun main() { val nums = intArrayOf(-2, 1, -3, 4, -1, 2, 1, -5, 4) // val nums = intArrayOf(1) out(maxSubArray(nums)) } /* 剑指 Offer 42. 连续子数组的最大和 输入一个整型数组,数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。 要求时间复杂度为O(n)。 示例1: 输入:...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,231
LeetCodeSimple
Apache License 2.0
src/Day07.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
fun main() { fun part1(input: List<String>): Int { val fileSystem = parseFileSystem(input) return fileSystem.findNodes { node -> node is Directory && node.size <= 100_000 }.sumOf { node -> node.size } } fun part2(input: List<String>): Int { val fileSystem = pars...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
3,037
advent-of-code-kotlin-2022
Apache License 2.0
src/aoc2022/day13/AoC13.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day13 import readLines fun main() { fun String.isAnInteger() = firstOrNull()?.isDigit() == true fun String.isAList() = firstOrNull() == '[' fun String.isEndOfList() = firstOrNull() == ']' fun String.firstElement() = split(",", "]", limit = 2)[0] fun String.dropFirstElement(): String { var i =...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
2,077
aoc2022
Apache License 2.0
src/Day19.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
import java.util.* import java.util.stream.Collectors import java.util.stream.Stream import kotlin.math.max private enum class Material { OBSIDIAN, CLAY, ORE; } fun main() { data class Blueprint( val id: Int, val costs: Map<Material, Map<Material, Int>>, val geodeCosts: Map<Material, I...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
4,474
advent-of-code-22
Apache License 2.0
src/com/ncorti/aoc2023/Day21.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 fun main() { fun parseInput(): Array<CharArray> { return getInputAsText("21") { split("\n").filter(String::isNotBlank).map { it.toCharArray() }.toTypedArray() } } fun parseInputTimes5(): Array<CharArray> { val worl...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
2,895
adventofcode-2023
MIT License
src/year2023/day14/Day14.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day14 import check import readInput fun main() { val testInput1 = readInput("2023", "Day14_test_part1") val testInput2 = readInput("2023", "Day14_test_part1") check(part1(testInput1), 136) check(part2(testInput2), 64) val input = readInput("2023", "Day14") println(part1(input...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
3,485
AdventOfCode
Apache License 2.0
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day19.kt
clechasseur
567,968,171
false
{"Kotlin": 493887}
package io.github.clechasseur.adventofcode.y2022 import io.github.clechasseur.adventofcode.y2022.data.Day19Data object Day19 { private val input = Day19Data.input private val blueprintRegex = """^Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Each obsidian robot costs (\d+)...
0
Kotlin
0
0
7ead7db6491d6fba2479cd604f684f0f8c1e450f
4,693
adventofcode2022
MIT License
src/Day09.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
import kotlin.math.abs fun main() { val dirs = mapOf( "U" to (0 to -1), "R" to (1 to 0), "D" to (0 to 1), "L" to (-1 to 0) ) fun visualize(rope: List<Pair<Int, Int>>) { for (y in -10 .. 10) { for (x in -10..10) { val knot = rope.indexOf(...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
3,184
2022-Advent-of-Code
Apache License 2.0
src/Day09.kt
jamie23
573,156,415
false
{"Kotlin": 19195}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun adjacent(head: Pair<Int, Int>, tail: Pair<Int, Int>) = (tail.first - head.first).absoluteValue <= 1 && (tail.second - head.second).absoluteValue <= 1 fun solve(points: Int, instructions: List<String>): Int { val pointLis...
0
Kotlin
0
0
cfd08064654baabea03f8bf31c3133214827289c
2,298
Aoc22
Apache License 2.0
src/main/kotlin/day02/day02.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package day02 import utils.readFile import utils.readLines enum class Rps(val identifiers: String, val shapeScore: Int) { ROCK("AX", 1), PAPER("BY", 2), SCISSORS("CZ", 3) } enum class Outcome(val identifier: String, val score: Int) { LOSE("X", 0), DRAW("Y", 3), WIN("Z", 6) } data class Hand(val them: Rps...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
3,167
aoc-2022-in-kotlin
Apache License 2.0
src/day22/Day22.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day22 import java.io.File import kotlin.math.max fun main() { val data = parse("src/day22/Day22.txt") val (supports, standsOn) = simulate(data) println("🎄 Day 22 🎄") println() println("[Part 1]") println("Answer: ${part1(data.size, supports, standsOn)}") println() printl...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
2,971
advent-of-code-2023
MIT License
src/Day06.kt
MisterTeatime
561,848,263
false
{"Kotlin": 20300}
fun main() { fun instructions2program(input: List<String>): List<Command> { val regex = """(\D+) (\d+,\d+) through (\d+,\d+)""".toRegex() return input .map { regex.find(it)!!.groupValues.drop(1) } .map { (instruction, start, end) -> Command(instruction, start, end) } ...
0
Kotlin
0
0
d684bd252a9c6e93106bdd8b6f95a45c9924aed6
3,940
AoC2015
Apache License 2.0
src/Day09.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { val seriesOfMotions = parseSeriesOfMotions(input) return simulateSeriesOfMotions(seriesOfMotions, Rope(2)) } fun part2(input: List<String>): Int { val seriesOfMotions = parseSeriesOfMotions(input) return simulateS...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
2,545
aoc2022
Apache License 2.0
src/main/kotlin/de/tek/adventofcode/y2022/day03/RucksackReorganization.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day03 import de.tek.adventofcode.y2022.util.readInputLines class ItemType(private val id: Char) { val priority: Int = when (id) { in CharRange('a', 'z') -> { 1 + (id.code - 'a'.code) } in CharRange('A', 'Z') -> { 27 + (id.code - '...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
2,316
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2021/Day05.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import Point import readInput import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign /** * Creates a new [Point] by moving this instance 1 step in the direction of the given [end] point * * @param end the destination in which direction to move the new point * @return a new...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
2,899
adventOfCode
Apache License 2.0
src/day05/Day05.kt
martinhrvn
724,678,473
false
{"Kotlin": 27307, "Jupyter Notebook": 1336}
package day05 import println import readInput data class Mapping(val source: Long, val destination: Long, val range: Long) { fun contains(seed: Long): Boolean { return seed in source ..< source + range } fun getDestination(seed: Long): Long { return destination + (seed - source) } } fun List<Mapping...
0
Kotlin
0
0
59119fba430700e7e2f8379a7f8ecd3d6a975ab8
4,519
advent-of-code-2023-kotlin
Apache License 2.0
archive/2022/Day16_dp.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import java.util.* import kotlin.time.ExperimentalTime import kotlin.time.measureTime private const val EXPECTED_1 = 1651 private const val EXPECTED_2 = 1707 /** * Reworked solution: DP by treating 1 minute at a time (ignoring useless valves) to find the * highest value path through the state space for part1. * *...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,752
advent-of-code-2022
Apache License 2.0
src/Day08.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
fun main() { fun List<String>.parseInput() = map { it.map { c -> c.digitToInt() } } fun <T> List<List<T>>.viewFrom(rowIndex: Int, columnIndex: Int): Sequence<List<T>> = sequence { yield((rowIndex - 1 downTo 0).map { this@viewFrom[it][columnIndex] }) // Top yield((columnIndex - 1 dow...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
2,390
advent-of-code-2022
Apache License 2.0
src/Day11.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private val template = """ Monkey (\d+): Starting items: (.*?) Operation: new = old (.) (.+) Test: divisible by (\d+) If true: throw to monkey (\d+) If false: throw to monkey (\d+) """.trim().toRegex() private data class MonkeyBusiness( val items: MutableList<ULong>, val op: (ULong, ULong) ->...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
2,322
advent-of-code-kotlin
Apache License 2.0
src/Day07.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day07 { fun parseInput(input: List<String>): Map<String, Int>{ val currentDir = StringBuilder() val dirTree: MutableMap<String, Int> = mutableMapOf() var i = 0 while(i < input.size){ val it = input[i] val cmd = it.removePrefix("$").trim() if...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
2,403
aoc-22-kotlin
Apache License 2.0
src/Day02.kt
lbilger
574,227,846
false
{"Kotlin": 5366}
enum class Shape { ROCK, PAPER, SCISSORS } enum class Outcome { LOSS, DRAW, WIN } fun main() { fun String.toShape() = when (this) { "A", "X" -> Shape.ROCK "B", "Y" -> Shape.PAPER "C", "Z" -> Shape.SCISSORS else -> error("Unexpected input $this") } fun String.toOutco...
0
Kotlin
0
0
40d94a4bb9621af822722d20675684555cbee877
1,970
aoc-2022-in-kotlin
Apache License 2.0
src/day17/Day17.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day17 import readInput fun main() { val testInput = readInput("day17/test") val windPattern = testInput[0].map { when (it) { '<' -> -1 '>' -> 1 else -> error("Invalid input") } } println(solve(windPattern, 2022)) println(solve(windPattern...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
4,095
advent-of-code-2022
Apache License 2.0
src/main/kotlin/mkuhn/aoc/Day16.kt
mtkuhn
572,236,871
false
{"Kotlin": 53161}
package mkuhn.aoc fun day16part1(input: List<String>): Int { val valves = input.map { Valve.fromString(it) } val mins = 30 val init = valves.find { it.name == "AA" }!! val you = ValveWalker(init, 0) val finder = ValvePathFinder(mins, valves) return finder.findOptimalPathValDFS(listOf(you), va...
0
Kotlin
0
1
89138e33bb269f8e0ef99a4be2c029065b69bc5c
4,160
advent-of-code-2022
Apache License 2.0
src/day09/Day09.kt
spyroid
433,555,350
false
null
package day09 import readInput import kotlin.system.measureTimeMillis fun main() { data class Point(val x: Int, val y: Int, val v: Int) class Area(input: List<String>) { val points = readPoints(input) val areaWidth = input.first().length fun readPoints(seq: List<String>) = mutableL...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
2,027
Advent-of-Code-2021
Apache License 2.0
src/Day15.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
import java.util.PriorityQueue fun main() { val neighbors = listOf( -1 to 0, 1 to 0, 0 to -1, 0 to 1, ) data class Node(val x: Int, val y: Int, val risk: Int) : Comparable<Node> { var distance = Int.MAX_VALUE fun neighbors(grid: List<List<Node>>) = neighbor...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
2,488
AdventOfCode2021
Apache License 2.0
src/Day02.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
private fun abcIndex(s: String) = s[0] - 'A' private fun xyzIndex(s: String) = s[0] - 'X' private fun xyzScore(s: String) = xyzIndex(s) + 1 private fun roundResult(opponentSymb: String, yourSymb: String): Int { return listOf( listOf(3, 6, 0), listOf(0, 3, 6), listOf(6, 0, 3), )[abcInde...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
1,419
advent-of-code-2022
Apache License 2.0
src/Day8.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): List<List<Tree>> { val grid = buildList { input.forEach { row -> add(row.map { Tree(it.digitToInt()) }) } } for (i in grid.indices) { for (j in grid[0].indices) { val tree = grid...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
1,655
advent-of-code-2022
Apache License 2.0
src/day04/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day04 import println import readInput fun main() { class Card (val id: Int, val winningNumbers: Set<Int>, val numbersYouHave: Set<Int>, var numberOfCopies: Int = 1) { fun matches(): Int { val overlap = winningNumbers.intersect(numbersYouHave) return overlap.size } ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
2,246
advent-of-code-2023
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day24.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day24(input: Input) : Puzzle() { private val flip by lazy { input.lines().map { parseRoute(it) } } private val directionRegex = "(e|se|sw|w|nw|ne)".toRegex() ...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,453
adventofcode-kotlin
MIT License
src/day7/Day07.kt
dinoolivo
573,723,263
false
null
package day7 import readInput fun main() { fun part1(tree: Tree): Long { return tree.getAllNodesByCondition { treeNode -> treeNode.metadata.isDir() && treeNode.metadata.size <= 100000} .sumOf { treeNode -> treeNode.metadata.size } } fun part2(tree: Tree): Long { val currentFree...
0
Kotlin
0
0
6e75b42c9849cdda682ac18c5a76afe4950e0c9c
2,232
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-16.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2015, "16-input") println("Part1:") println(part1(input)) println() println("Part2:") println(part2(input)) } private fun part1(input: List<String>...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,808
advent-of-code
MIT License
src/Day18.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import java.util.* import kotlin.math.abs private typealias Point = List<Int> fun main() { fun areConnected(a: Point, b: Point): Boolean { return a.withIndex().count { it.value != b[it.index] } == 1 && a.withIndex() .count { abs(it.value - b[it.index]) == 1 } == 1 } fun countOutsides(...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
3,176
advent-of-kotlin-2022
Apache License 2.0
test/exercism/SumOfMultiples.kt
andrej-dyck
340,964,799
false
null
package exercism import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.assertEquals /** * https://exercism.io/tracks/kotlin/exercises/sum-of-multiples * * Sum Of Multiples * [Medium] * * Given a number, find the sum of all the multiples of particular numbers up to but not including that number....
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
6,341
coding-challenges
MIT License
src/Day11.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
import java.math.BigDecimal fun main() { val input = readInput("Day11") val monkies = input.windowed(6, 7) { list -> list.fold(Monkey()) { monkey, s -> val trimmed = s.trim() when { trimmed.startsWith("Monkey") -> monkey.copy(idx = trimmed.split(" ").last().repla...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
4,234
aoc-kotlin-2022
Apache License 2.0
src/day07/Task.kt
dniHze
433,447,720
false
{"Kotlin": 35403}
package day07 import readInput import kotlin.math.max import kotlin.collections.sumOf import kotlin.math.abs import kotlin.math.min fun main() { val input = readInput("day07") println(solvePartOne(input)) println(solvePartTwo(input)) } fun solvePartOne(input: List<String>): Int = input.toInput() .min...
0
Kotlin
0
1
f81794bd57abf513d129e63787bdf2a7a21fa0d3
1,845
aoc-2021
Apache License 2.0
src/Day04.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
fun main() { fun part1(input: List<String>): Int { return input.map { it.split(",", limit = 2) .map { e -> e.split("-", limit = 2).map { e -> e.toInt() } } }.count { (it[0][0] <= it[1][0] && it[0][1] >= it[1][1]) || (it[1][0] <= it[0][0] &&...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
1,064
advent-of-code-2022
Apache License 2.0
src/Day12.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
fun main() { fun transformElevation(elevation: Char) = when(elevation) { 'S' -> 'a' 'E' -> 'z' else -> elevation } fun checkElevation(from: Char, to: Char) = transformElevation(to) - transformElevation(from) <= 1 fun adjacent(node: Pair<Int, Int>, grid: List<CharArray>): Set<P...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
4,214
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/Day05.kt
jorander
571,715,475
false
{"Kotlin": 28471}
import java.util.Stack fun main() { val day = "Day05" // Some utility functions for Pair fun <A, B, R> Pair<A, B>.mapFirst(operation: (A) -> R) = operation(first) to second fun <A, B, R> Pair<A, B>.mapSecond(operation: (B) -> R) = first to operation(second) fun <A, B, R> Pair<Iterable<A>, B>.fol...
0
Kotlin
0
0
1681218293cce611b2c0467924e4c0207f47e00c
3,043
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-07.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2022, "07-input") val testInput1 = readInputLines(2022, "07-test1") println("Part1:") part1(testInput1).print...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,010
advent-of-code
MIT License
src/day04/Day04.kt
pnavais
574,712,395
false
{"Kotlin": 54079}
package day04 import readInput private fun overlapsTotally( firstRangeDef: LongRange, secondStart: Long, secondEnd: Long, secondRangeDef: LongRange, firstStart: Long, firstEnd: Long ): Boolean { return (firstRangeDef.contains(secondStart) && firstRangeDef.contains(secondEnd)) || ...
0
Kotlin
0
0
ed5f521ef2124f84327d3f6c64fdfa0d35872095
2,051
advent-of-code-2k2
Apache License 2.0
src/day03/Day03.kt
zypus
573,178,215
false
{"Kotlin": 33417, "Shell": 3190}
package day03 import AoCTask // https://adventofcode.com/2022/day/3 fun Char.priority() = when { isLowerCase() -> code - 97 + 1 isUpperCase() -> code - 65 + 27 else -> throw Exception("Invalid char '$this' to get priority for") } fun testPriorities() { ('a'..'z').toList().plus(('A'..'Z')).forEachInd...
0
Kotlin
0
0
f37ed8e9ff028e736e4c205aef5ddace4dc73bfc
1,734
aoc-2022
Apache License 2.0
src/Day04.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { val pairDescPattern = Regex("(\\d+)-(\\d+),(\\d+)-(\\d+)") fun toPair(pairDesc: String): Pair<Pair<Int, Int>, Pair<Int, Int>> { val m = pairDescPattern.matchEntire(pairDesc)!! return Pair( Pair(m.groups[1]!!.value.toInt(), m.groups[2]!!.value.toInt()), Pair(m...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
1,571
advent_of_code_2022
Apache License 2.0
year2017/src/main/kotlin/net/olegg/aoc/year2017/day21/Day21.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day21 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2017.DayOf2017 /** * See [Year 2017, Day 21](https://adventofcode.com/2017/day/21) */ object Day21 : DayOf2017(21) { override fun first(): Any? { return countOn(5) } override fun second(): Any? { return...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,226
adventofcode
MIT License
src/Day09.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val initialHead = Knot() val headPath = input.toMotions() .fold(listOf(initialHead)) { acc, motion -> acc.plus(acc.last().move(motion)) } return headPath.follower() .distinct() .s...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
3,541
advent-of-code-2022
Apache License 2.0
src/Day05.kt
Nplu5
572,211,950
false
{"Kotlin": 15289}
import Operation.Companion.fromString import java.util.* fun main() { fun createInitialConfiguration(input: List<String>): MutableList<Stack<ContentCrate>> { val initialBoardGame = input.takeWhile { line -> line.isNotEmpty() } .map { configurationString -> configurationString.s...
0
Kotlin
0
0
a9d228029f31ca281bd7e4c7eab03e20b49b3b1c
4,636
advent-of-code-2022
Apache License 2.0
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day07.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2023 import eu.michalchomo.adventofcode.Day import eu.michalchomo.adventofcode.main object Day07 : Day { override val number: Int = 7 private val cardsOrder = listOf('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') private val cardsOrderJoker = car...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,862
advent-of-code
Apache License 2.0
src/Day08.kt
oleskrede
574,122,679
false
{"Kotlin": 24620}
fun main() { val maxTreeHeight = 9 data class Tree( val height: Int, var visible: Boolean = false, val viewingDistances: MutableList<Int> = mutableListOf(), ) class Forest(input: List<String>) { val trees = input.map { line -> line.map { height -> ...
0
Kotlin
0
0
a3484088e5a4200011335ac10a6c888adc2c1ad6
2,381
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day11.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
fun puzzleDayElevenPartOne() { val inputs = readInput(11) val octos = inputs.mapIndexed { y, octoList -> octoList.mapIndexed { x, octoChar -> Octopus( octoChar.toString().toInt(), x, y ) } } (1..100).forEach { step -> octos.forEach { octo...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
2,796
advent-of-kotlin-2021
Apache License 2.0
src/main/kotlin/dev/siller/aoc2022/Day05.kt
chearius
575,352,798
false
{"Kotlin": 41999}
package dev.siller.aoc2022 private val example = """ [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 """.trimIndent() private data class Instruction(val count: Int, val from: Int, val to: Int) private fun part1(input:...
0
Kotlin
0
0
e070c0254a658e36566cc9389831b60d9e811cc5
2,321
advent-of-code-2022
MIT License
src/Day02.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
import java.io.IOException import kotlin.math.abs fun main() { // R, P, S // P, S, R val ref = mapOf("A" to listOf(3, 1), "B" to listOf(1, 2), "C" to listOf(2, 3)) val ref2 = mapOf("X" to listOf(3, 1), "Y" to listOf(1, 2), "Z" to listOf(2, 3)) val winLoseMap = mapOf("X" to -1, "Y" to 0, "Z" to 1) ...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
2,605
advent-of-code-2022
Apache License 2.0
src/day09/Day09.kt
Volifter
572,720,551
false
{"Kotlin": 65483}
package day09 import utils.* import kotlin.math.sqrt data class Coords(var x: Int, var y: Int) { val delta: Float get() = sqrt((x * x + y * y) * 1f) operator fun plus(other: Coords): Coords = Coords(x + other.x, y + other.y) operator fun minus(other: Coords): Coords = Coords(x - other.x, y - other.y) } ...
0
Kotlin
0
0
c2c386844c09087c3eac4b66ee675d0a95bc8ccc
1,923
AOC-2022-Kotlin
Apache License 2.0
src/Day04.kt
janbina
157,854,025
false
null
import kotlin.test.assertEquals object Day04 { private fun createSleepStats(input: List<Event>): Map<Int, IntArray> { val map = mutableMapOf<Int, IntArray>() var currentGuardId = -1 var beginMinute = -1 input.forEach { when (it.type) { Event.Type.BEGIN_...
0
Kotlin
0
0
522d93baf9ff4191bc2fc416d95b06208be32325
2,331
advent-of-code-2018
MIT License
src/Day07.kt
inssein
573,116,957
false
{"Kotlin": 47333}
sealed class Node { abstract val name: String abstract val size: Int data class File(override val name: String, override val size: Int) : Node() data class Directory( override val name: String, val parent: Directory?, val children: MutableList<Node> = mutableListOf() ) : No...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
2,435
advent-of-code-2022
Apache License 2.0
solutions/src/Day07.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
import DirItem.Dir import DirItem.File fun main() { fun part1(input: List<String>): Int = getAllDirs(input).map { it.getDirSize() }.filter { it < 100_000 }.sum() fun part2(input: List<String>): Int { val totalDiskSpaceAvailable = 70_000_000 val spaceRequired = 30_000_000 val dirSizesAs...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
2,379
advent-of-code-22
Apache License 2.0
app/src/main/kotlin/com/engineerclark/advent2022/Day03.kt
engineerclark
577,449,596
false
{"Kotlin": 10394}
package com.engineerclark.advent2022 import com.engineerclark.advent2022.utils.readInput fun main() { val rucks = readRucksacks(readInput(3)) println("Day 3, challenge 1 -- Sum of priorities of common item types: ${rucks.sumOfCommonItemPriorities()}") val elfGroups = rucks.asElfGroups() println("Day ...
0
Kotlin
0
0
3d03ab2cc9c83b3691fede465a6e3936e7c091e9
1,712
advent-of-code-2022
MIT License
src/day03/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day03 import println import readInput fun main() { class Gear(val position: Pair<Int, Int>, val numbers: List<Int>) class EngineSchematic { val EMPTY_CHAR: Char = '.' var schema: List<List<Char>> var maxColumns = 0 var maxRows = 0 constructor(data: List<String...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
4,140
advent-of-code-2023
Apache License 2.0
scripts/Day16.kts
matthewm101
573,325,687
false
{"Kotlin": 63435}
import java.io.File import kotlin.math.max data class Valve(val name: String, val flow: Int, val neighbors: Set<String>) val allValves = File("../inputs/16.txt").readLines().map { val splits = it.split("Valve ", " has flow rate=", "; tunnels lead to valves ", "; tunnel leads to valve ").filter { s -> s.isNotEmpty...
0
Kotlin
0
0
bbd3cf6868936a9ee03c6783d8b2d02a08fbce85
2,913
adventofcode2022
MIT License
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day22/Day22.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day22 import nl.sanderp.aoc.common.* import kotlin.math.max import kotlin.math.min fun main() { val input = readResource("Day22.txt").lines().map { parse(it) } val (answer1, duration1) = measureDuration<Int> { partOne(input) } println("Part one: $answer1 (took ${duration1.p...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,794
advent-of-code
MIT License
src/main/day08/day08.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day08 import Point import readInput typealias Forest = List<Tree> fun main() { val input = readInput("main/day08/Day08") val forest = input.flatMapIndexed { y, line -> line.mapIndexed { x, height -> Tree(x, y, height.digitToInt()) } } println(part1(forest)) p...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,991
aoc-2022
Apache License 2.0
src/Day08.kt
imavroukakis
572,438,536
false
{"Kotlin": 12355}
fun main() { fun topVisible( outerIdx: Int, map: List<List<Int>>, innerIdx: Int, v: Int, ): Pair<Boolean, Int> { var l = outerIdx var score = 0 while (l >= 0) { val element = map[l--][innerIdx] score++ if (v <= elemen...
0
Kotlin
0
0
bb823d49058aa175d1e0e136187b24ef0032edcb
3,303
advent-of-code-kotlin
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day24.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.IState import adventofcode.util.algorithm.aStar import adventofcode.util.collections.permutations import kotlin.math.abs object Day24 : AdventSolution(2016, 24, "Air Duct Spelunking") { lateinit var maze: List<Boo...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,764
advent-of-code
MIT License
src/Day11.kt
wujingwe
574,096,169
false
null
object Day11 { class Monkey( val id: Int, val levels: MutableList<Long>, val op: Int, val operand: Int, val divider: Int, val pos: Int, val neg: Int, var count: Int = 0 ) private const val OP_ADD = 0 private const val OP_MUL = 1 priva...
0
Kotlin
0
0
a5777a67d234e33dde43589602dc248bc6411aee
3,211
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day15.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days import java.util.* class Day15 : Day(15) { private val di = listOf(-1, 0, 0, 1) private val dj = listOf(0, -1, 1, 0) override fun partOne(): Any { val map = inputList.map { it.map { Character.getNumericValue(it) } } return findPath(map) } override fun partTwo(): Any...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
2,223
aoc-2021
Creative Commons Zero v1.0 Universal
solutions/aockt/y2015/Y2015D15.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import io.github.jadarma.aockt.core.Solution object Y2015D15 : Solution { private val inputRegex = Regex("""(\w+): capacity (-?\d+), durability (-?\d+), flavor (-?\d+), texture (-?\d+), calories (-?\d+)""") /** Parses a single line of input and returns an [Ingredient] and its pro...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,319
advent-of-code-kotlin-solutions
The Unlicense
src/Day12.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File import java.util.* import kotlin.math.abs // Advent of Code 2022, Day 12, Hill Climbing Algorithm typealias Graph = List<List<Int>> typealias Cell = Pair<Int, Int> // Manhattan distance fun Cell.distance(other: Cell) = abs(this.first - other.first) + abs(this.second - other.second) fun Graph.nei...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
3,793
AdventOfCode2022
Apache License 2.0
src/Day02.kt
melo0187
576,962,981
false
{"Kotlin": 15984}
import Codes.elvenShapeCodes import Codes.outcomeByCode import Codes.shapeByCode sealed interface Shape { val score: Int val defeat: Shape object ROCK : Shape { override val score: Int = 1 override val defeat: Shape = SCISSORS } object PAPER : Shape { override val score: I...
0
Kotlin
0
0
97d47b84e5a2f97304a078c3ab76bea6672691c5
3,056
kotlin-aoc-2022
Apache License 2.0
src/day15/Day15.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day15 import lib.Point2D import lib.Vector2D import readInput import kotlin.math.abs fun main() { val day = 15 val testInput = readInput("day$day/testInput") // check(part1(testInput, 10) == 26) // val testRes = part2(testInput, 20) // check(testRes == 56000011) val input = readInput("d...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,751
advent-of-code-2022
Apache License 2.0
src/Day10.kt
rweekers
573,305,041
false
{"Kotlin": 38747}
import kotlin.math.absoluteValue fun main() { fun part1(signalStrengths: List<Int>): Int { val cycles = listOf(20, 60, 100, 140, 180, 220) return cycles.fold(mutableListOf<Int>()) { acc, curr -> acc.add(signalStrengths[curr - 1] * curr) acc }.sum() } fun p...
0
Kotlin
0
1
276eae0afbc4fd9da596466e06866ae8a66c1807
1,974
adventofcode-2022
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2020/Day17.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 17: Conway Cubes --- * https://adventofcode.com/2020/day/17 */ class Day17 : Solver { override fun solve(lines: List<String>): Result { val map = mutableMapOf<XYZW, Boolean>() for (y in lines.indices) { ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,221
euler
Apache License 2.0
src/day4.kt
SerggioC
573,171,085
false
{"Kotlin": 8824}
fun main() { val input: List<String> = readInput("day4") val map = input.map { sections -> val (pair1, pair2) = sections.split(",") val section1 = pair1.split("-").map(String::toInt) val section2 = pair2.split("-").map(String::toInt) val range1 = IntRange(section1.get(0), secti...
0
Kotlin
0
0
d56fb119196e2617868c248ae48dcde315e5a0b3
1,578
aoc-2022
Apache License 2.0
src/aoc2022/Day07.kt
miknatr
576,275,740
false
{"Kotlin": 413403}
package aoc2022 fun main() { data class File( val name: String, val size: Int ) data class Dir( val parent: Dir?, val name: String, val isDeleted: Boolean = false, val dirs: MutableList<Dir> = mutableListOf(), val files: MutableList<File> = mutableLi...
0
Kotlin
0
0
400038ce53ff46dc1ff72c92765ed4afdf860e52
2,825
aoc-in-kotlin
Apache License 2.0
advent-of-code-2023/src/Day01.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day01" fun main() { val input = readInput(DAY) val testInput1 = readInput("${DAY}_test1") val testInput2 = readInput("${DAY}_test2") "Part 1" { part1(testInput1) shouldBe 142 measureAnswer { part1(input) } } "Part 2 (Regex)" { part2Regex(testIn...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,510
advent-of-code
Apache License 2.0
src/main/kotlin/Day9.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
import java.util.* fun main() { val data = readInputFile("day9") fun getCandidates(i: Int, heights: List<List<Int>>, j: Int): Int { val candidates = mutableListOf<Int>() if (i > 0) candidates += heights[i - 1][j] if (j > 0) candidates += heights[i][j - 1] if (i < heights.size -...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
2,793
AOC2021
Apache License 2.0
src/main/kotlin/Problem24.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
/** * Lexicographic permutations * * A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, * 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The * lexicographic permutations of 0, 1 and 2 a...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
2,693
project-euler
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day11.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* import java.math.BigInteger fun main() = Day11.run() data class Monkey(val items: MutableList<BigInteger>, val op: (BigInteger) -> BigInteger, val divisor : BigInteger, val throwTo: (BigInteger) -> Int, var inspections: BigInteger = BigInteger.ZERO) ob...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,305
adventofkotlin
MIT License
y2020/src/main/kotlin/adventofcode/y2020/Day19.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution fun main() = Day19.solve() object Day19 : AdventSolution(2020, 19, "Monster Messages") { override fun solvePartOne(input: String): Int { val (rulesInput, messages) = input.split("\n\n") val rules: List<Rule> = parseRules(rulesI...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,050
advent-of-code
MIT License
Advent-of-Code-2023/src/Day01.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day01" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY private fun part1(input: List<String>): Int { return input.sumOf { line -> line.first { it.isDigit() }.digitToInt() * 10 + line.last { it.isDigit() }.digitToInt() } } private v...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
2,643
Advent-of-Code-2023
Apache License 2.0
src/main/kotlin/days/y22/Day07.kt
kezz
572,635,766
false
{"Kotlin": 20772}
package days.y22 import arrow.core.Either import arrow.core.Either.Left import arrow.core.Either.Right import util.Day public fun main() { Day07().run() } public class Day07 : Day(22, 7) { override fun part1(input: List<String>): Any = input .mapNotNull { line -> when { li...
0
Kotlin
0
0
1cef7fe0f72f77a3a409915baac3c674cc058228
3,571
aoc
Apache License 2.0
src/Day02.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
fun main() { fun List<String>.toGameRounds(myHandShapeMapping: (HandShape, String) -> HandShape): List<GameRound> = this.map { line -> val shapeInputs = line.split(" ") if (shapeInputs.size != 2) error("Each round/line needs exactly 2 hand shapes") val opponentHandShape = HandShape.fromValu...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
3,333
AdventOfCode2022
Apache License 2.0
src/main/kotlin/aoc2023/Day01.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import kotlin.math.min class Day01 { fun part1(input: List<String>): Int = input .map { line -> line.filter { it.isDigit() } } .sumOf { digits -> digits.first().digitToInt() * 10 + digits.last().digitToInt() } fun part2(input: List<String>): Int { val firstDigits = inp...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
1,798
advent-of-code-2023
MIT License
2023/src/main/kotlin/de/skyrising/aoc2023/day5/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day5 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.longs.LongArrayList import it.unimi.dsi.fastutil.longs.LongList val test = TestInput(""" seeds: 79 14 55 13 seed-to-soil map: 50 98 2 52 50 48 soil-to-fertilizer map: 0 15 37 37 52 2 39 0...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,536
aoc
MIT License
src/Day07.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private const val MAX_DIR_SIZE = 100_000 private const val DISK_SPACE = 70_000_000 private const val UPDATE_SIZE = 30_000_000 private data class FS( val name: String, val parent: FS?, // null for root dir only. ) { val files: MutableList<Int> = mutableListOf() val folders: MutableList<FS> = mutableList...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
2,904
advent-of-code-kotlin
Apache License 2.0
src/day16/Day16.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day16 import combinations import readInput import java.lang.Integer.max const val day = "16" data class Valve(val name: String, val rate: Int, var neighbors: List<Pair<Int, Valve>> = emptyList()) { override fun toString(): String { return "Valve(name='$name', rate=$rate, neighbors=${neighbors.ma...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
5,990
advent-of-code-22-kotlin
Apache License 2.0
src/Day11.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
private enum class MonkeyOp { ADD, MUL, SQUARE } fun main() { class Monkey( var items: ArrayDeque<Long>, var op: Pair<MonkeyOp, Long>, var test: Long, var decision: Pair<Long, Long>, ) { var count = 0 fun add(x: Long) { items.addLast(x) } ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
3,074
aoc-2022
Apache License 2.0
2023/src/day08/day08.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day08 import GREEN import LCM import RESET import printTimeMillis import readInput private fun List<String>.toMap(): Map<String, Pair<String, String>> = drop(1).let { buildMap { for (line in it) { val key = line.split(" = ")[0] val (left, right) = line.split(" = ")[1].drop(...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,173
advent-of-code
Apache License 2.0
src/Day05.kt
dannyrm
573,100,803
false
null
import java.util.Stack typealias MoveInstruction = Triple<Int, Int, Int> fun main() { fun part1(input: List<String>): List<String> { val (stackInput, moveInput) = obtainInputs(input) val stacks = obtainStacks(stackInput) parseMoves(moveInput).forEach { for (i in 0 until it.fir...
0
Kotlin
0
0
9c89b27614acd268d0d620ac62245858b85ba92e
2,213
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day16.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
fun main() { val input = readFileAsList("Day16") println(Day16.part1(input)) println(Day16.part2(input)) } object Day16 { fun part1(input: List<String>): Int { val valves = parseValves(input) val usefulValves = valves.values .filter { it.flowRate > 0 } .toSet() ...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
4,419
advent-of-code-2022
Apache License 2.0
src/Day02.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (a, transB) = it.split(" ") val b = when (transB) { "X" -> "A" "Y" -> "B" "Z" -> "C" else -> throw RuntimeException() } ...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
1,772
aoc2022
Apache License 2.0
src/Day04.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
private fun IntRange.encloses(other: IntRange): Boolean { return first <= other.first && last >= other.last } private fun IntRange.overlaps(other: IntRange): Boolean { return any { other.contains(it) } } fun main() { fun part1(input: List<String>): Int { return input .map { pair -> pai...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
1,379
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day17.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 import year2023.Day17.Direction.* import java.util.* fun main() { val input = readInput("Day17") Day17.part1(input).println() Day17.part2(input).println() } object Day17 { fun part1(input: List<String>): Int { val heatMap = input.map { row -> row.map { it.digitToI...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
6,192
advent-of-code
MIT License
y2016/src/main/kotlin/adventofcode/y2016/Day11.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.IState import adventofcode.util.algorithm.aStar object Day11 : AdventSolution(2016, 11, "Radioisotope Thermoelectric Generators") { override fun solvePartOne(input: String): String = aStar(FloorPlan(1, parseConfig...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
3,006
advent-of-code
MIT License
src/jvmTest/kotlin/ai/hypergraph/kaliningraph/rewriting/Isosequences.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.rewriting import ai.hypergraph.kaliningraph.types.* import info.debatty.java.stringsimilarity.Levenshtein // Experiment: probabilistic subgraph ismorphism as // substring matching on a random walk trace. E.g.: // // GUID: ... 1ef71 258xu 289xy 1ef71 2kfg1 258xu ... \ // ...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
3,689
galoisenne
Apache License 2.0
src/day04/day04.kt
tmikulsk1
573,165,106
false
{"Kotlin": 25281}
package day04 import readInput /** * Advent of Code 2022 - Day 4 * @author tmikulsk1 */ fun main() { val inputCleanupSections = readInput("day04/input.txt").readLines() val cleanupSectionsRanges = splitCleanupSectionsInputByRanges(inputCleanupSections) getPuzzle1TotalContainedInRanges(cleanupSections...
0
Kotlin
0
1
f5ad4e601776de24f9a118a0549ac38c63876dbe
2,142
AoC-22
Apache License 2.0
src/Day11.kt
inssein
573,116,957
false
{"Kotlin": 47333}
data class Operation(private val input: String) { private val suffix = input.substringAfter("new = old ") private val operator = suffix[0] private val rawAmount = suffix.substring(2) operator fun invoke(value: Long): Long { val amount = rawAmount.let { if (it == "old") value else it...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
2,750
advent-of-code-2022
Apache License 2.0
src/Utils.kt
kipwoker
572,884,607
false
null
import java.io.File import kotlin.math.max import kotlin.math.min fun readInput(name: String) = File("src", "$name.txt") .readLines() fun <T> assert(actual: T, expected: T) { if (actual == expected) { return } throw Exception("Actual $actual Expected $expected") } data class Interval(val sta...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
3,392
aoc2022
Apache License 2.0
src/Day02.kt
psy667
571,468,780
false
{"Kotlin": 23245}
enum class Fig(val score: Int) { Rock(1), Paper(2), Scissors(3) } enum class Outcome(val score: Int) { Lose(0), Draw(3), Win(6) } fun main() { val id = "02" fun String.toFig() = when(this) { "A", "X" -> Fig.Rock "B", "Y" -> Fig.Paper "C", "Z" -> Fig.Scissors else -> th...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
1,612
advent-of-code-2022
Apache License 2.0
src/Day04.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { return input .map { pair -> val ranges = pair.split(",").map { range -> range.split("-").let { it[0].toInt()..it[1].toInt() } } ranges[0] to ranges[1] } .map { if...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
1,397
aoc2022
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/18.kt
papey
225,420,936
false
{"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117}
package d18 import input.read import kotlin.math.absoluteValue fun main() { println("Part 1: ${part1(read("18.txt"))}") println("Part 2: ${part2(read("18.txt"))}") } fun part1(input: List<String>): Long { val instructions = input.map { line -> line.split(" ").let { val dir = when(it[0...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
2,210
aoc
The Unlicense
src/main/kotlin/day10/Day10.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day10 import readToList import java.util.* private val input = readToList("day10.txt") .map { it.toCharArray() } fun main() { println(part1()) println(part2()) } private fun part1(): Int { return input.sumOf { line -> calcInvalidLinePoints(line) } } private fun part2(): Long { val scor...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
2,133
aoc2021
Apache License 2.0
src/Day02.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
private enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSORS(3); fun beats(other: Shape): Boolean? = when { this == other -> null // this means draw this == PAPER && other == ROCK -> true this == SCISSORS && other == PAPER -> true this == ROCK && other == SCISSORS -> true else -> false } fun f...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
1,804
advent-of-code-2022
Apache License 2.0