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/Day12.kt
punx120
573,421,386
false
{"Kotlin": 30825}
fun main() { fun buildMap(input: List<String>): Array<CharArray> { val n = input[0].length val map = Array(n) { CharArray(n) } for (r in input.indices) { for (c in input[r].indices) map[r][c] = input[r][c] } return map } fun findStartAndE...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
3,065
aoc-2022
Apache License 2.0
src/Day08.kt
haraldsperre
572,671,018
false
{"Kotlin": 17302}
fun main() { fun isVisible(patch: List<List<Int>>, tree: Pair<Int, Int>): Boolean { val (x, y) = tree if (x == 0 || y == 0 || x == patch.size - 1 || y == patch[x].size - 1) { return true } val treeHeight = patch[x][y] return treeHeight > listOf( patch...
0
Kotlin
0
0
c4224fd73a52a2c9b218556c169c129cf21ea415
2,357
advent-of-code-2022
Apache License 2.0
src/Day09.kt
RusticFlare
575,453,997
false
{"Kotlin": 4655}
fun main() { fun part1(input: List<String>): Int { return input.size } fun MutableList<MutableSet<Pair<Int, Int>>>.addPoint(point: Pair<Int, Int>): MutableSet<Pair<Int, Int>>? { return if (none { basin -> point in basin }) { mutableSetOf(point).also { add(it) } } else { ...
0
Kotlin
0
0
6ad85c80f771be683517fab804e9a933a90d5b41
1,897
advent-of-code-kotlin-2021
Apache License 2.0
src/main/kotlin/aoc2023/Day17.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import java.util.* class Day17 { fun part1(input: String): Int { val (grid, rows, cols) = parseInput(input) return dijkstra(grid, Point(0, 0), Point(rows - 1, cols - 1), 1, 3) } fun part2(input: String): Int { val (grid, rows, cols) = parseInput(input) retu...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
3,422
advent-of-code-2023
MIT License
advent-of-code-2023/src/Day02.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
private const val DAY = "Day02" fun main() { val testInput = readInput("${DAY}_test") val input = readInput(DAY) "Part 1" { part1(testInput) shouldBe 8 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 2286 measureAnswer { part2(input) } } }...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
2,265
advent-of-code
Apache License 2.0
src/aoc2022/Day02.kt
Playacem
573,606,418
false
{"Kotlin": 44779}
package aoc2022 import utils.readInput private enum class RPS(val opponentLabel: String, val ourLabel: String, val selectionValue: Int) { ROCK("A", "X", 1), PAPER("B", "Y", 2), SCISSOR("C", "Z", 3); fun match(s: String): Boolean { return s == opponentLabel || s == ourLabel } } fun main()...
0
Kotlin
0
0
4ec3831b3d4f576e905076ff80aca035307ed522
2,325
advent-of-code-2022
Apache License 2.0
src/Day08.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { val d = arrayOf(1 to 0, 0 to 1, -1 to 0, 0 to -1) fun List<String>.visible(i: Int, j: Int, h: Char) = d.any { (di, dj) -> generateSequence(i + di to j + dj) { (i, j) -> i + di to j + dj } .takeWhile { (i, j) -> i in this.indices && j in this[i].indices } ...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
1,379
aockt
Apache License 2.0
src/Day18.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { data class Cube(val x: Int, val y: Int, val z: Int) fun Cube.adjacents(): List<Cube> { return listOf( Cube(x+1, y, z), Cube(x-1, y, z), Cube(x, y+1, z), Cube(x, y-1, z), Cube(x, y, z+1), Cube(x, y, z-1), ) } fun parse(input: List<String>...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
1,547
aoc-2022
Apache License 2.0
src/Day15.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
import kotlin.math.abs fun main() { val regex = Regex("Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)") fun Pair<Int, Int>.distanceTo(that: Pair<Int, Int>): Int { return abs(this.first - that.first) + abs(this.second - that.second) } fun String.parse(): Pair<Pair...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
2,094
aoc-2022
Apache License 2.0
src/Day12.kt
erikthered
572,804,470
false
{"Kotlin": 36722}
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { data class Graph<T>( val vertices: MutableSet<T> = mutableSetOf(), val edges: MutableMap<T, Set<T>> = mutableMapOf(), val weights: MutableMap<Pair<T, T>, Int> = mutableMapOf() ) fun Char.toElevation() = when(thi...
0
Kotlin
0
0
3946827754a449cbe2a9e3e249a0db06fdc3995d
4,341
aoc-2022-kotlin
Apache License 2.0
src/Day08.kt
LauwiMeara
572,498,129
false
{"Kotlin": 109923}
fun main() { fun calculateViewingDistance(range: IntProgression, isRowIndex: Boolean, input: List<List<Int>>, row: Int, col: Int): Int { var viewingDistance = 0 for (i in range) { viewingDistance++ if (isRowIndex && input[i][col] >= input[row][col] || !isRowIn...
0
Kotlin
0
1
34b4d4fa7e562551cb892c272fe7ad406a28fb69
2,539
AoC2022
Apache License 2.0
src/poyea/aoc/mmxxii/day11/Day11.kt
poyea
572,895,010
false
{"Kotlin": 68491}
package poyea.aoc.mmxxii.day11 import poyea.aoc.utils.readInput fun simulate(input: String, rounds: Int): Long { val monkeys = input.split("\n\n").map { it.split("\n") } val items = monkeys.map { it[1].split(":")[1].split(",").map { iy -> iy.trim().toLong() }.toMutableList() } val ops = monkey...
0
Kotlin
0
1
fd3c96e99e3e786d358d807368c2a4a6085edb2e
2,157
aoc-mmxxii
MIT License
src/Day08.kt
RandomUserIK
572,624,698
false
{"Kotlin": 21278}
fun List<String>.toIntMatrix(): Array<Array<Int>> = map { row -> row.map(Char::digitToInt).toTypedArray() }.toTypedArray() fun Array<Array<Int>>.neighborsFrom(row: Int, col: Int): List<List<Int>> = listOf( (0 until row).map { this[it][col] }.asReversed(), // north (row + 1..lastIndex).map { this[it][col] }, /...
0
Kotlin
0
0
f22f10da922832d78dd444b5c9cc08fadc566b4b
1,624
advent-of-code-2022
Apache License 2.0
src/Day02.kt
WilsonSunBritten
572,338,927
false
{"Kotlin": 40606}
fun main() { fun part1(input: List<String>): Int { return input.map { round -> val split = round.split(" ") val opponentPlay = opponentPlay[split.first()] ?: error("bad input") val myPlay = myPlay[split[1]] ?: error("bad input") gameScore(opponentPlay, myPlay)...
0
Kotlin
0
0
363252ffd64c6dbdbef7fd847518b642ec47afb8
1,992
advent-of-code-2022-kotlin
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/11.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 d11 import input.read import kotlin.math.abs import kotlin.math.min fun main() { println("Part 1: ${part1(read("11.txt"))}") println("Part 2: ${part2(read("11.txt"))}") } fun part1(input: List<String>): Long { val galaxy = Supercluster(input) return galaxy.eachGalaxyPair().sumOf(galaxy::dist...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
1,950
aoc
The Unlicense
src/Day07.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
sealed class Node(val name: String) { class File(name:String, val length: Int): Node(name) class Dir(name: String, val parent: Dir?, val children: MutableList<Node> = mutableListOf()): Node(name) { fun select(from: String): Dir { return if (from == "..") { parent!! ...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
2,859
aoc2022
Apache License 2.0
src/day13/Day13.kt
seastco
574,758,881
false
{"Kotlin": 72220}
package day13 import readText import org.json.JSONArray import readLines import kotlin.math.min class Packet(val packet: JSONArray) : Comparable<Packet> { override fun compareTo(other: Packet): Int { return compare(this.packet, other.packet) } /* The comparison algorithm is based on the foll...
0
Kotlin
0
0
2d8f796089cd53afc6b575d4b4279e70d99875f5
2,414
aoc2022
Apache License 2.0
src/day09/Day09.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day09 import readInput import kotlin.math.abs private const val DAY_ID = "09" private enum class Direction(val dx: Int, val dy: Int) { U(1, 0), D(-1, 0), L(0, -1), R(0, 1), UL(1, -1), UR(1, 1), DL(-1, -1), DR(-1, 1) } private data class Knot( var row: Int, var col: Int ) { fun move(d: Di...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
2,824
aoc-2022-in-kotlin
Apache License 2.0
src/Day08.kt
D000L
575,350,411
false
{"Kotlin": 23716}
fun main() { fun part1(input: List<String>): Int { val map = input.map { it.toCharArray().map { it.digitToInt() } } fun find(y: Int, x: Int): Boolean { val treeHeight = map[y][x] val dir = listOf(1 to 0, -1 to 0, 0 to 1, 0 to -1) dir.forEach { (dx, dy) -> ...
0
Kotlin
0
0
b733a4f16ebc7b71af5b08b947ae46afb62df05e
1,762
adventOfCode
Apache License 2.0
src/day18/Day18.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day18 import readInput import java.lang.Integer.max import java.util.ArrayDeque const val day = "18" operator fun Triple<Int, Int, Int>.plus(o: Triple<Int, Int, Int>) = Triple(first + o.first, second + o.second, third + o.third) operator fun Triple<Int, Int, Int>.plus(i: Int) = Triple(first + i, second + i, ...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
2,802
advent-of-code-22-kotlin
Apache License 2.0
codeforces/vk2021/qual/e12.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.vk2021.qual private fun permutation(comparisons: List<Boolean>, n: Int): Pair<Int, List<Int>> { var pos = 0 fun permutation(m: Int): List<Int> { if (m <= 1) return List(m) { 0 } val left = m / 2 val right = m - left val permutationLeft = permutation(left) val permutationRight = permutati...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,598
competitions
The Unlicense
src/Day14.kt
freszu
573,122,040
false
{"Kotlin": 32507}
fun main() { fun parse(lines: List<String>): Set<Position> = lines.map { line -> line.split(" -> ") .map { val (x, y) = it.split(",") x.toInt() to y.toInt() } .windowed(2) .map { (p1, p2) -> p1.walkHorizontallyOrVertically(p2).t...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
2,341
aoc2022
Apache License 2.0
src/main/kotlin/net/wrony/aoc2023/a3/Main.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a3 import kotlin.io.path.Path import kotlin.io.path.readText data class PartNumber(val row: Int, val range: IntRange, val value: Int) { fun partNeighbourhood(size: Int): Sequence<Pair<Int, Int>> { return sequence { yield(Pair(row, range.first - 1)) yield(P...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
2,488
aoc-2023-kotlin
MIT License
src/main/kotlin/de/nosswald/aoc/days/Day02.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day // https://adventofcode.com/2023/day/2 object Day02 : Day<Int>(2, "Cube Conundrum") { private data class Game(val id: Int, val sets: List<Set>) private data class Set(val cubes: MutableMap<Color, Int>) private enum class Color { RED, GREEN, BLUE } ...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
3,301
advent-of-code-2023
MIT License
day-15/src/main/kotlin/Chiton.kt
diogomr
433,940,168
false
{"Kotlin": 92651}
import kotlin.system.measureTimeMillis fun main() { val partOneMillis = measureTimeMillis { println("Part One Solution: ${partOne()}") } println("Part One Solved in: $partOneMillis ms") val partTwoMillis = measureTimeMillis { println("Part Two Solution: ${partTwo()}") } println...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
3,214
aoc-2021
MIT License
src/main/kotlin/day15/Day15.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day15 import kotlin.math.abs fun solveA(input: List<String>, targetRow: Long): Int { val sensors = input.parseSensors() val beaconPositions = sensors.map { it.closestBeacon }.filter { it.y == targetRow }.toSet() val noBeaconAtLeftest = sensors.mapNotNull { it.noBeaconsAt(targetRow)?.first }.min(...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
2,263
advent-of-code-2022
Apache License 2.0
src/Day14.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { return input.parse14().dropSand1() } fun part2(input: List<String>): Int { return input.parse14().dropSand2() } // test if implementation meets criteria from the description, like: ...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
2,324
advent-of-code-2022
Apache License 2.0
src/Day02.kt
aamielsan
572,653,361
false
{"Kotlin": 9363}
private fun String.splitToPair(): Pair<String, String> = Pair(substringBefore(" "), substringAfter(" ")) enum class Hand(val score: Int) { Rock(1), Paper(2), Scissor(3), Unknown(0); companion object { fun fromString(string: String): Hand = when (string) { "A...
0
Kotlin
0
0
9a522271bedb77496e572f5166c1884253cb635b
2,728
advent-of-code-kotlin-2022
Apache License 2.0
gcj/y2020/round2/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round2 private fun solve(): Int { val n = readInt() data class Point(val x: Int, val y: Int) val points = List(n) { val (x, y) = readInts(); Point(x, y) } val dirs = points.cartesianTriangle().map { (p, q) -> val (x, y) = dividedByGcd(p.x - q.x, p.y - q.y) if (x > 0 || (x == 0 && y > 0)) (x t...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,192
competitions
The Unlicense
src/Day12.kt
vjgarciag96
572,719,091
false
{"Kotlin": 44399}
import java.util.LinkedList import java.util.Queue fun main() { data class Node(val x: Int, val y: Int) fun buildGraph(input: List<String>): Map<Node, List<Node>> { val rowLength = input.first().length val adjacencyList = HashMap<Node, ArrayList<Node>>(rowLength * input.size) val ele...
0
Kotlin
0
0
ee53877877b21166b8f7dc63c15cc929c8c20430
3,889
advent-of-code-2022
Apache License 2.0
src/Day07.kt
hrach
572,585,537
false
{"Kotlin": 32838}
sealed interface Node { val name: String val size: Int data class Dir( override val name: String, val nodes: MutableList<Node>, val parent: Dir?, ) : Node { override val size: Int get() { return nodes.sumOf { it.size } } va...
0
Kotlin
0
1
40b341a527060c23ff44ebfe9a7e5443f76eadf3
2,394
aoc-2022
Apache License 2.0
src/day15/Day15.kt
spyroid
433,555,350
false
null
package day15 import com.github.ajalt.mordant.terminal.Terminal import readInput import java.util.* import kotlin.system.measureTimeMillis private fun solve(input: List<List<Int>>): Int { val start = Point(0, 0) val destination = Point(input.lastIndex, input.first().lastIndex) val seen = mutableSetOf(st...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
2,340
Advent-of-Code-2021
Apache License 2.0
src/Day02.kt
GunnarBernsteinHH
737,845,880
false
{"Kotlin": 10952}
/* * --- Day 2: Cube Conundrum --- * Source: https://adventofcode.com/2023/day/2 */ /** main function containing sub-functions like a class */ fun main() { data class CubeSet(val red: Int, val green: Int, val blue: Int) data class Game(val id: Int, val cubeSets: List<CubeSet>) /** Parse input and return...
0
Kotlin
0
0
bc66eef73bca2e64dfa5d83670266c8aaeae5b24
2,951
aoc-2023-in-kotlin
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/dynamicprogramming/mindistance/minDistance.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.dynamicprogramming.mindistance /** * Returns the minimum number of operations required to convert a string a into string b * * Edit distance is a classic DP problem. It is used to quantify the dissimilarity of two given strings by counting * the minimum possible number of opera...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,442
KotlinGround
MIT License
Advent-of-Code-2023/src/Day11.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
import kotlin.math.max import kotlin.math.min private const val AOC_DAY = "Day11" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY private const val EXPANDED_TWICE = 2 private const val EXPANDED_MILLION = 1_000_000 private data class Galaxy(val row: Int, val col: Int) /** * Fi...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
2,344
Advent-of-Code-2023
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day13.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.transposeString fun main() { Day13.solve() } object Day13 : AdventSolution(2023, 13, "Point of Incidence") { override fun solvePartOne(input: String) = solve(input, String::equals) override fun solvePart...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,308
advent-of-code
MIT License
src/Day05.kt
rxptr
572,717,765
false
{"Kotlin": 9737}
data class Instruction(val quantity: Int, val from: Int, val to: Int) fun main() { fun parsInstructions(input: String): List<Instruction> = input.lines().filter(String::isNotBlank).map { line -> val (a, b, c) = Regex("move (\\d+) from (\\d+) to (\\d+)").find(line)!!.destructured Instruction(a.toIn...
0
Kotlin
0
0
989ae08dd20e1018ef7fe5bf121008fa1c708f09
2,127
aoc2022
Apache License 2.0
src/Day03.kt
pmellaaho
573,136,030
false
{"Kotlin": 22024}
fun main() { /** * 16 (p), 38 (L), 42 (P), 22 (v), 20 (t), and 19 (s); the sum of these is 157. */ fun Char.priority(): Int { return when (this) { in 'a'..'z' -> code - 96 in 'A'..'Z' -> code - 38 else -> 0 } } fun splitIntoCompartments(ruc...
0
Kotlin
0
0
cd13824d9bbae3b9debee1a59d05a3ab66565727
2,041
AoC_22
Apache License 2.0
src/main/kotlin/aoc2022/Day18.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput private data class Point3(val x: Int, val y: Int, val z: Int) { companion object { fun fromString(input: String): Point3 { val split = input.split(",").map { it.toInt() } return Point3(split[0], split[1], split[2]) } } val neighbour...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,284
adventOfCode
Apache License 2.0
src/Day09.kt
qmchenry
572,682,663
false
{"Kotlin": 22260}
fun main() { data class Coordinate(val x: Int, val y: Int) { operator fun plus(other: Coordinate): Coordinate { return Coordinate(x + other.x, y + other.y) } operator fun minus(other: Coordinate): Coordinate { return Coordinate(x - other.x, y - other.y) } ...
0
Kotlin
0
0
2813db929801bcb117445d8c72398e4424706241
3,087
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/be/inniger/euler/problems11to20/Problem11.kt
bram-inniger
135,620,989
false
{"Kotlin": 20003}
package be.inniger.euler.problems11to20 private const val NR_ADJACENT = 4 /** * Largest product in a grid * * In the 20×20 grid below, four numbers along a diagonal line have been marked in red. * The product of these numbers is 26 × 63 × 78 × 14 = 1788696. * What is the greatest product of four adjacent numbers...
0
Kotlin
0
0
8fea594f1b5081a824d829d795ae53ef5531088c
3,518
euler-kotlin
MIT License
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day03/Day03.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day03 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun getMajority(input: List<List<Int>>, index: Int): Int { return input.map { it[index] }.let { if (it.sum()*2 == it.size) { 1 } ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
3,360
AOC
Apache License 2.0
src/year2021/Day5.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2021 import readFile import java.awt.Point private const val COORDINATE_SIZE = 1000 fun main() { val input = parseInput(readFile("2021", "day5")) val testInput = parseInput(readFile("2021", "day5_test")) println(part1(testInput)) check(part1(testInput) == 5) println("Part 1:" + part1...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
2,131
advent_of_code
MIT License
kotlin/src/test/kotlin/nl/dirkgroot/adventofcode/year2023/Day23Test.kt
dirkgroot
724,049,902
false
{"Kotlin": 203339, "Rust": 123129, "Clojure": 78288}
package nl.dirkgroot.adventofcode.year2023 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import java.util.* private fun solution1(input: String) = solution(parse(input, false)) private fun so...
1
Kotlin
0
0
ced913cd74378a856813973a45dd10fdd3570011
5,475
adventofcode
MIT License
src/Day07.kt
haraldsperre
572,671,018
false
{"Kotlin": 17302}
abstract class FilesystemEntity(val name: String, val parent: Directory? = null, var size: Long = 0L) class Directory(name: String, parent: Directory? = null) : FilesystemEntity(name, parent) { private val children = mutableListOf<FilesystemEntity>() fun add(entity: FilesystemEntity) { children.add(en...
0
Kotlin
0
0
c4224fd73a52a2c9b218556c169c129cf21ea415
3,123
advent-of-code-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day19.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { val (workflows, ratings) = buildModel() part1(workflows, ratings) part2(workflows) } private fun part1(workflows: Map<String, Workflow>, ratings: List<PartRating>) { val result = ratings.filte...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
4,630
adventofcode
Apache License 2.0
src/Day08.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
fun main() { fun part1(input: List<String>): Int { val stack = ArrayDeque<List<Int>>() var i = 0 input.forEach { stack.add(i, it.toList().map { c -> c.digitToInt() }) i++ } val trees = stack.mapIndexed { n, cur -> val nextRows = stack.fil...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
3,042
advent-of-code-2022
Apache License 2.0
src/Day11.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
data class Monkey( var items: List<Long>, val operation: (Long) -> Long, val divisibleBy: Long, val trueMonkey: Int, val falseMonkey: Int, var inspectCounter: Long = 0 ) { } class Game(val monkeys: List<Monkey>, val worryReductionEnabled: Boolean) { companion object { fun parse(inp...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
3,091
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/aoc2020/ex18.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
fun main() { tests() val input = readInputFile("aoc2020/input18") print(input.lines().associateWith { calc(it) }.toList() // .sortedBy { it.second } .sumOf { println("${it.first} = ${it.second}") it.second }) } private fun tests() { require(calc("1 + 2 * 3 + 4 * 5 + ...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
3,858
AOC-2021
MIT License
src/main/kotlin/day16/Day16.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day16 import runDay fun main() { fun part1(input: List<String>) = input.parse() .let { rooms -> val stack = listOf( RoomState(emptySet(), listOf("AA")) ) (1..30).fold(stack) { statesAtThisStep, i -> println(i) stat...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
2,793
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Excercise22.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
private data class ModInstruction( val on: Boolean, val x1: Int, val x2: Int, val y1: Int, val y2: Int, val z1: Int, val z2: Int ) private val input = parseInput(getInputAsTest("22")) private fun parseInput(input: List<String>): List<ModInstruction> { val regex = Regex("x=([-\\d]+)..([-\\d]+),y=([-\\d...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
1,794
advent-of-code-2021
MIT License
07.kts
pin2t
725,922,444
false
{"Kotlin": 48856, "Go": 48364, "Shell": 54}
val chars = arrayOf('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2') enum class Type { HIGH, ONE_PAIR, TWO_PAIR, THREE_OF_KIND, FULL_HOUSE, FOUR_OF_KIND, FIVE_OF_KIND } data class Hand(val cards: String): Comparable<Hand> { fun type(): Type { val counts = HashMap<Char, Int>(5) cards....
0
Kotlin
1
0
7575ab03cdadcd581acabd0b603a6f999119bbb6
2,639
aoc2023
MIT License
src/Day12.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
import java.util.PriorityQueue fun main() { fun part1(input: List<String>): Int { var start = Cords(0, 0) var end = Cords(0, 0) val heatmap = input.flatMapIndexed { y, row -> row.mapIndexed { x, elt -> val here = Cords(x, y) here to when (elt)...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
3,126
aoc-2022
Apache License 2.0
src/day3/puzzle03.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day3 import Puzzle import PuzzleInput import java.io.File fun day3Puzzle() { val inputDir = "inputs/day3" Day3Puzzle1Solution().solve(Day3PuzzleInput("$inputDir/example.txt", 157)) Day3Puzzle1Solution().solve(Day3PuzzleInput("$inputDir/input.txt", 8039)) Day3Puzzle2Solution().solve(Day3PuzzleI...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
1,874
aoc_2022
Apache License 2.0
src/y2022/Day12.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2022 import util.Direction import util.Pos import util.readInput object Day12 { private fun parse(input: List<String>): Triple<List<List<Int>>, Pos, Pos> { var start: Pos = 0 to 0 var end: Pos = 0 to 0 val grid = input.mapIndexed { rowIdx, row -> row.mapIndexed { colId...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,226
advent-of-code
Apache License 2.0
src/day08/Day08.kt
scottpeterson
573,109,888
false
{"Kotlin": 15611}
package day08 import readInput // take the input of lines of strings, put into lines, put into chars, convert to Ints private fun constructForest(input: List<String>): List<List<Int>> { return input.map { line -> line.toCharArray().map { Integer.parseInt("$it") } } } // for each "tree", calculate if ...
0
Kotlin
0
0
0d86213c5e0cd5403349366d0f71e0c09588ca70
2,733
advent-of-code-2022
Apache License 2.0
src/year2021/day12/Day12.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2021.day01.day12 import util.assertTrue import util.model.Counter import util.read2021DayInput fun main() { fun task01(input: List<String>): Int { val caves = createCaves(input) val startCave = caves.first { it.name == "start" } val counter = Counter() navigate(startCa...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
2,483
advent-of-code-kotlin-template
Apache License 2.0
src/Day02.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
private enum class Element(val score: Int) { Rock(1), Paper(2), Scissors(3); fun roundScore(other: Element): Int { if (this == other) return 3 if ((this.ordinal + 1) % 3 == other.ordinal) return 0 return 6 } } private enum class Result(val shift: Int) { Win(1), Draw(0), Lose(-1...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
1,429
AOC2022
Apache License 2.0
src/Day03.kt
binaryannie
573,120,071
false
{"Kotlin": 10437}
private const val DAY = "03" private const val PART_1_CHECK = 157 private const val PART_2_CHECK = 70 fun codeToPriority (code: Int): Int { return if (code <= 90) code - 65 + 27 else code - 96 } // a is worth 1, z is worth 26, A is worth 27, Z is worth 52 fun main() { fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
511fc33f9dded71937b6bfb55a675beace84ca22
1,540
advent-of-code-2022
Apache License 2.0
src/Day03.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
fun main() { val rucksacks = readInput("Day03").map { rucksack -> val (first, second) = rucksack .toList() .let { list -> list.subList(0, rucksack.length / 2) to list.subList(rucksack.length / 2, list.size) } Rucksack(Compartment(first.toSet()), Co...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
1,403
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/day5/Day5.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day5 import readToList val input = readToList("day5.txt") fun main() { println(part1()) println(part2()) } private fun part1() { val validLines = input .map { line -> val (first, second) = line.split(" -> ") Line(toPoint(first), toPoint(second)) } ...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
1,795
aoc2021
Apache License 2.0
src/Day08.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
private data class ViewingDistance( val left: Int, val top: Int, val right: Int, val bottom: Int, ) { fun score(): Int { return (left * top * right * bottom) } } private class Tree(val height: Int) { var left: Tree? = null var top: Tree? = null var right: Tree? = null va...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
4,918
aoc-2022
Apache License 2.0
src/Day03.kt
tblechmann
574,236,696
false
{"Kotlin": 5756}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val leftDistinct = rucksack.take(rucksack.length / 2).toCharArray().distinct() val rightDistinct = rucksack.takeLast(rucksack.length / 2).toCharArray().distinct() val merged = leftDistinc...
0
Kotlin
0
0
4a65f6468a0cddd8081f2f0e3c1a96935438755f
1,596
aoc2022
Apache License 2.0
src/main/kotlin/aoc22/Day02.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import readInput fun getScore(yourPick: Hands, opponentPick: Hands): Int { val roundScore = when (yourPick) { Hands.ROCK -> when (opponentPick) { Hands.ROCK -> Scores.DRAW Hands.SCISSOR -> Scores.WIN Hands.PAPER -> Scores.LOSS } Hands.PAPER...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
2,314
advent-of-code
Apache License 2.0
src/Day02.kt
binaryannie
573,120,071
false
{"Kotlin": 10437}
fun convertInputToGames(input: List<String>): List<List<Int>> { return input .map { it.split(' ') } .map { listOf(it[0].toCharArray()[0].code - 65, it[1].toCharArray()[0].code - 88) } } fun scoreGame (opponentPlays: Int, wePlay: Int): Int { val playerScore = wePlay + 1 return when (opponent...
0
Kotlin
0
0
511fc33f9dded71937b6bfb55a675beace84ca22
1,714
advent-of-code-2022
Apache License 2.0
src/Day12.kt
cagriyildirimR
572,811,424
false
{"Kotlin": 34697}
fun day12Part1() { val input = readInput("Day12") val visited = MutableList(input.size) { MutableList(input[0].length) { false } } val dist = MutableList(input.size) { MutableList(input[0].length) { 999_999 } } val prev = MutableList(input.size) { MutableList<Point?>(input[0].length) { null } } /...
0
Kotlin
0
0
343efa0fb8ee76b7b2530269bd986e6171d8bb68
5,417
AoC
Apache License 2.0
src/Day04.kt
MSchu160475
573,330,549
false
{"Kotlin": 5456}
fun main() { fun part1(input: List<String>): Int { return input.fold(0) { acc, cs -> val sections = cs.split(",") .map { section -> section.split("-").map { it.toInt() } } .map { Pair(it[0], it[1]) } .sortedByDescending { it.second - it.first } ...
0
Kotlin
0
0
c6f9a0892a28f0f03b95768b6611e520c85db75c
1,259
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/day15/Day15.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day15 import runDay import utils.Point import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { var minX: Int = Int.MAX_VALUE var maxX: Int = Int.MIN_VALUE val y = 2000000 return input .map { it.pars...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
3,997
advent-of-code-2022
Apache License 2.0
src/Day12.kt
RandomUserIK
572,624,698
false
{"Kotlin": 21278}
private const val START_SYMBOL = 'S' private const val END_SYMBOL = 'E' private class Heightmap( val start: Point2D, val end: Point2D, val heights: Map<Point2D, Int>, ) { fun shortestPath(from: Point2D, isGoal: (Point2D) -> Boolean, canMoveToward: (Int, Int) -> Boolean): Int { val visited = mutableSetOf<Point2D>...
0
Kotlin
0
0
f22f10da922832d78dd444b5c9cc08fadc566b4b
2,359
advent-of-code-2022
Apache License 2.0
src/day19/Day19.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day19 import java.io.File import java.lang.IllegalStateException import java.util.PriorityQueue import kotlin.math.ceil import kotlin.math.max fun main() { val regexp = Regex("\\d+") val blueprints = File("src/day19/input.txt").readLines() .map { regexp.findAll(it).drop(1).map { it...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
4,310
advent-of-code-2022
MIT License
src/Day08.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
import kotlin.math.max //1825 //235200 fun main() { fun isVisible(treeIndex: Int, treeLine: List<Int>): Boolean { val treeHeight = treeLine[treeIndex] return treeLine.slice(0 until treeIndex).all{it < treeHeight} || treeLine.slice(treeIndex + 1 .. treeLine.lastIndex).all{it < treeHeight} } ...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
2,434
aoc-2022
Apache License 2.0
src/Day02.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
import Result.* import Sign.* fun main() { fun part1(input: List<String>): Int { return input.map { it.split(" ") }.map { it[0].asSign() to it[1].asSign() } .sumOf { score(it.first, it.second) } } fun part2(input: List<String>): Int { return input.map { ...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
2,026
advent-of-code-2022
Apache License 2.0
src/Day12.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
fun main() { fun bfs(testInput: List<String>, sy: Int, sx: Int): Int { val input = testInput.map { it.replace('S', 'a').replace('E', 'z') } val dist = Array(input.size) { IntArray(input.first().length) { 100000 } } dist[sy][sx] = 0 val visited = mutableSetOf<Pair<Int, Int>>() ...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
1,864
advent-of-code-2022
Apache License 2.0
src/Day19.kt
er453r
572,440,270
false
{"Kotlin": 69456}
import java.lang.Integer.max fun main() { fun part1(input: List<String>): Int { val blueprints = input.map { line -> line.ints().let { listOf( VectorN(it[1], 0, 0, 0), VectorN(it[2], 0, 0, 0), VectorN(it[3], it[4], 0, 0...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
6,117
aoc2022
Apache License 2.0
src/Day15.kt
wgolyakov
572,463,468
false
null
import kotlin.math.absoluteValue fun main() { fun distance(p1: Pair<Int, Int>, p2: Pair<Int, Int>) = (p1.first - p2.first).absoluteValue + (p1.second - p2.second).absoluteValue fun parse(input: List<String>): Triple<List<Pair<Int, Int>>, Set<Pair<Int, Int>>, List<Int>> { val sensors = mutableListOf<Pair<Int, In...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
2,349
advent-of-code-2022
Apache License 2.0
src/main/kotlin/mkuhn/aoc/Day12.kt
mtkuhn
572,236,871
false
{"Kotlin": 53161}
package mkuhn.aoc import mkuhn.aoc.util.Grid import mkuhn.aoc.util.Point import mkuhn.aoc.util.readInput import mkuhn.aoc.util.transpose fun main() { val input = readInput("Day12") println(day12part1(input)) println(day12part2(input)) } fun day12part1(input: List<String>): Int = (ElevationGrid(input....
0
Kotlin
0
1
89138e33bb269f8e0ef99a4be2c029065b69bc5c
2,694
advent-of-code-2022
Apache License 2.0
src/Day16.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
import java.util.* fun main() { fun part1(input: List<String>): Int { val start = "AA" val maxTime = 30 val (rates, tunnels) = parseInput(input) val options = rates.filter { (name, rate) -> name == start || rate > 0 } .map { (name, _) -> name to calculateOptions(name, r...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
3,036
aoc-2022
Apache License 2.0
src/Day12.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
fun List<IntOffset>.getNextSteps( heightMap: Map<IntOffset, Char>, wayUp: Boolean ): List<List<IntOffset>> { val route = this val currentPosition = route.last() val currentHeight = heightMap[currentPosition]!! val possibleDirections = Direction.values() .map { currentPosition + it } ...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
3,718
advent-of-code-2022
Apache License 2.0
src/Day19.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.collections.HashSet fun main() { data class Resources(val ore: Int = 0, val clay: Int = 0, val obsidian: Int = 0, val geode: Int = 0) : Comparable<Resources> { fun isAtLeast(other: Resources) = ore >= other.ore && clay >= other.clay && obsidian >= other.obsidian && geode >...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
3,820
Advent-of-Code-2022
Apache License 2.0
src/2022/Day03.kt
bartee
575,357,037
false
{"Kotlin": 26727}
fun main() { val interpreter = Day03() fun testGetCharacterPriority(){ val testArray = mapOf("a" to 1, "b" to 2, "f" to 6, "A" to 27, "B" to 28, "F" to 32, "Z" to 52) for (entry in testArray.entries.iterator()) { val test = interpreter.getCharacterPriority(entry.key) check(test == entry.value) ...
0
Kotlin
0
0
c7141d10deffe35675a8ca43297460a4cc16abba
3,585
adventofcode2022
Apache License 2.0
src/main/kotlin/aoc2023/Day23.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 import kotlin.math.max class Day23 { fun part1(input: String): Int { val (grid, start, end) = parseInput(input) val graph = grid.convertToGraph().compactGraph() return dfs(graph, start, end) } fun part2(input: String): Int { val (grid, start, end) = parseIn...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
3,754
advent-of-code-2023
MIT License
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day08.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 import eu.michalchomo.adventofcode.toInt fun main() { fun part1(input: List<String>): Int = input.map { it.map { it.digitToInt() } } .let { rows -> rows.mapIndexed { rowIndex, cols -> cols.mapIndexed cols@{ colIndex, height -> ...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
2,272
advent-of-code
Apache License 2.0
src/main/kotlin/day15/Day15.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day15 import readToList import java.util.* private val input = readToList("day15.txt") fun main() { val weightMatrix = input.map { line -> line.chars().map { char -> Character.getNumericValue(char) }.toArray() }.toTypedArray() val distance = dijkstra(weightMatrix) ...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
2,039
aoc2021
Apache License 2.0
src/Day15.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import java.awt.font.NumericShaper.Range fun main() { fun readCoordinates(input: String): List<List<Int>> { val regex = "(-?\\d+)".toRegex() return regex.findAll(input).map { it.groups[1]?.value?.toInt() ?: 0 }.toList().chunked(2) } fun IntRange.myIntersect(other: IntRange): Boolean{ ...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
5,954
aoc22
Apache License 2.0
src/main/kotlin/Beacons.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
import kotlin.math.abs fun main() = Beacons.solve(0..4_000_000) private object Beacons { fun solve(possibleCoordinates: IntRange) { val sensors = readInput() val distress = findDistressBeacon(sensors, possibleCoordinates) println("Distress breacon at $distress, freq: ${distress.x.toBigInte...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
3,200
aoc2022
MIT License
15/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File import java.util.PriorityQueue fun readInput() : Grid { val input = File("input.txt") .readText() .split("\r\n") .filter { it.isNotEmpty() } .map { row -> row.map { it.digitToInt() }} return Grid(input) } class Grid(mat : List<List<Int>>) { companion o...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,485
advent-of-code-2021
MIT License
src/day8/puzzle08.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day8 import Puzzle import PuzzleInput import java.io.File import java.lang.Integer.max data class TreeProperties(val height: Int, val row: Int, val col: Int, private val initialScore: Int) { var top = initialScore var bottom = initialScore var left = initialScore var right = initialScore ...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
4,953
aoc_2022
Apache License 2.0
src/day20/d20_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val k = input.toInt() val ceil = Math.ceil(input.toDouble()).toInt() / 11 // sieve[i] == 0 iff i is prime // == k iff k is a prime divisor of i val sieve = sieve(ceil) val memo = Array<Map<Int, Int>?>(sieve.size) { null } for (i in 2 until sieve.size) { val s = e...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
1,542
aoc2015
MIT License
cz.wrent.advent/Day16.kt
Wrent
572,992,605
false
{"Kotlin": 206165}
package cz.wrent.advent import java.lang.Integer.max import java.util.Deque import java.util.LinkedList fun main() { // println(partOne(test)) // val result = partOne(input) // println("16a: $result") println(partTwo(test)) println("16b: ${partTwo(input)}") } private fun partOne(input: String): Int { val valves =...
0
Kotlin
0
0
8230fce9a907343f11a2c042ebe0bf204775be3f
9,177
advent-of-code-2022
MIT License
src/main/kotlin/Day08.kt
uipko
572,710,263
false
{"Kotlin": 25828}
fun main() { val visibleTrees = visibleTrees("Day08.txt") println("Visible trees $visibleTrees") val score = scenicScore("Day08.txt") println("Visible trees $score") } fun visibleTrees(fileName: String): Int { val forrest = readInput(fileName).map { line -> line.toCharArray().map { it.digitToInt(...
0
Kotlin
0
0
b2604043f387914b7f043e43dbcde574b7173462
2,445
aoc2022
Apache License 2.0
src/Day05.kt
davedupplaw
573,042,501
false
{"Kotlin": 29190}
fun main() { fun readCrateStack(input: List<String>, indexOfBlankLine: Int): MutableMap<Int, List<String>> { val stack = input .take(indexOfBlankLine) .map { it.chunked(4) .mapIndexed { index, crate -> ...
0
Kotlin
0
0
3b3efb1fb45bd7311565bcb284614e2604b75794
3,225
advent-of-code-2022
Apache License 2.0
2k23/aoc2k23/src/main/kotlin/12.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 d12 import input.read fun main() { println("Part 1: ${part1(read("12.txt"))}") println("Part 2: ${part2(read("12.txt"))}") } fun part1(input: List<String>): Long = input.sumOf { val (springs, sizes) = it.split(" ").let { parts -> val springs = parts.first().toCharArray().toList() ...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
2,730
aoc
The Unlicense
src/main/kotlin/y2016/day04/Day04.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2016.day04 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } fun input(): Rooms { return AoCGenerics.getInputLines("/y2016/day04/input.txt") .map { Room( checkSum = it.split("[")[1].dropLast(1), ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,716
AdventOfCode
MIT License
src/Day12.kt
oleksandrbalan
572,863,834
false
{"Kotlin": 27338}
import java.util.LinkedList fun main() { val input = readInput("Day12") .filterNot { it.isEmpty() } .map { it.toCharArray() } val rows = input.size val columns = input.first().size var s = Vertex(0, 0) var e = Vertex(0, 0) repeat(rows) { i -> repeat(columns) { j -> ...
0
Kotlin
0
2
1493b9752ea4e3db8164edc2dc899f73146eeb50
2,504
advent-of-code-2022
Apache License 2.0
src/Day09.kt
dragere
440,914,403
false
{"Kotlin": 62581}
import kotlin.streams.toList fun main() { fun part1(input: List<List<Int>>): Int { val lowPoints = mutableListOf<Int>() for (i in input.indices) { for (j in input[i].indices) { val v = input[i][j] if (j > 0 && input[i][j - 1] <= v) continue ...
0
Kotlin
0
0
3e33ab078f8f5413fa659ec6c169cd2f99d0b374
3,034
advent_of_code21_kotlin
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day15/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day15 import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Point(val x: Int, val y: Int) { fun manhattanDistanceTo(other: Point): Int { return abs(x - other.x) + abs(y - other.y) } } class Sensor(position: Point, val closestB...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
3,644
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/y2023/day11/Day11.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day11 import days.y2023.day10.PuzzleGrid import util.InputReader typealias PuzzleLine = List<Char> typealias PuzzleInput = List<PuzzleLine> class Day11(val input: PuzzleInput) { fun partOne(): Int { val galaxies = input.toGalaxyMap(2) val pairs = galaxies.pairwise() pri...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
4,329
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/day13/day13.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day13 import java.util.* import readInput import second sealed interface Packet : Comparable<Packet> { data class ListPacket(val packets: MutableList<Packet> = mutableListOf()) : Packet { override fun compareTo(other: Packet): Int { return when (other) { is IntPacket -...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
2,972
aoc-2022
Apache License 2.0
src/Day08.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
fun main() { fun part1(input: List<String>) { val matrix: List<List<Int>> = input.map { it.map { it.digitToInt() } } val lastIndex = matrix.size - 1 val visibleTrees = matrix.withIndex().sumOf { (rowIndex, row) -> when (rowIndex) { 0, lastIndex -> row.size ...
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
3,239
advent-of-code-kotlin-2022
Apache License 2.0
src/twentythree/Day01.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentythree import readInputTwentyThree enum class Numbers(val string: String, val number: Int) { ONE("one", 1), TWO("two", 2), THREE("three", 3), FOUR("four", 4), FIVE("five", 5), SIX("six", 6), SEVEN("seven", 7), EIGHT("eight", 8), NINE("nine", 9) } fun String.firstNumbe...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
2,551
kotlin-aoc-1
Apache License 2.0