path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/day24/Day24.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day24 import runDay import utils.Point import java.lang.RuntimeException fun main() { fun part1(input: List<String>) = input.parse().let { (bounds, blizzards) -> solve(bounds, blizzards, listOf(bounds.end)) } fun part2(input: List<String>) = input.parse().let { (bounds, blizzards) -> ...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
4,901
advent-of-code-2022
Apache License 2.0
src/main/kotlin/1.kt
torland-klev
730,585,319
false
{"Kotlin": 74157}
package klev object `1` : Day { override fun firstSolution(input: List<String>) = input.sumOf { line -> line.filter { c -> c.isDigit() }.let { number -> "${number.first()}${number.last()}" }.toInt() }.toString() override fun secondSol...
0
Kotlin
0
0
e18afa4a7c0c7b7e12744c38c1a57f42f055dcdf
25,866
advent-of-code-2023
MIT License
src/main/kotlin/aoc2023/Day17.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import Point import readInput import to2dIntArray import java.util.* object Day17 { private data class StraightCount(val horizontal: Int, val vertical: Int) { val nextHorizontal by lazy { StraightCount(horizontal + 1, 0) } val nextVertical by lazy { StraightCount(0, vertical + 1) ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,208
adventOfCode
Apache License 2.0
src/day13.kt
skuhtic
572,645,300
false
{"Kotlin": 36109}
fun main() { day13.execute(forceBothParts = true) } val day13 = object : Day<Int>(13, 13, 140) { override val testInput: InputData get() = """ [1,1,3,1,1] [1,1,5,1,1] [[1],[2,3,4]] [[1],4] [9] [[8,7,6]] [[4,4],4,4] ...
0
Kotlin
0
0
8de2933df90259cf53c9cb190624d1fb18566868
2,446
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2021/day4.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.loadInput data class Board(val marked: Set<Int>, val posMap: Map<String, Int>) data class Round(val justCalled: String?, val nums: List<String>, val boards: List<Board>) fun main() { val lines = loadInput("/2021/day4") .bufferedReader() .readLines() val n...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
2,456
aoc-kotlin
Apache License 2.0
src/Day15.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class PlanePos(val x: Int, val y: Int) fun PlanePos.distance(x: Int, y: Int) = abs(this.x - x) + abs(this.y - y) fun PlanePos.distance(pos: PlanePos) = distance(pos.x, pos.y) enum class PlaneItem { Sensor, Beacon, NoBeacon } fun PlaneItem?.sy...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
3,576
aoc2022
Apache License 2.0
src/Day07.kt
dannyrm
573,100,803
false
null
fun main() { fun part1(input: List<String>): Long { val tokens = input.map { parseLine(it) } val tree = buildDirectoryTree(tokens) return obtainDirectories(tree).filter { it.size() <= 100_000 }.sumOf { it.size() } } fun part2(input: List<String>): Long { val totalDiskSpace ...
0
Kotlin
0
0
9c89b27614acd268d0d620ac62245858b85ba92e
4,583
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/dangerground/aoc2020/Day16.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput fun main() { val process = Day16(DayInput.batchesOfStringList(16)) println("result part 1: ${process.part1()}") println("result part 2: ${process.part2()}") } class Day16(val batches: List<List<String>>) { ...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
3,155
adventofcode-2020
MIT License
src/Day09.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
import kotlin.math.abs private fun ropeOffset(headPosition: Int, tailPosition: Int): Int { return if (headPosition > tailPosition) { 1 } else if (headPosition < tailPosition) { -1 } else { 0 } } private fun ropeSimulation(input: List<String>, ropeLength: Int): Int { val vis...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
1,878
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc23/Day13.kt
tahlers
725,424,936
false
{"Kotlin": 65626}
package aoc23 import kotlin.math.max import kotlin.math.min object Day13 { data class Pos(val x: Int, val y: Int) data class Pattern(val stones: Set<Pos> = emptySet()) { fun vertical(index: Int): Set<Pos> = stones.filter { it.x == index }.toSet() fun transpose() = Pattern(stones.map { Pos(it....
0
Kotlin
0
0
0cd9676a7d1fec01858ede1ab0adf254d17380b0
2,273
advent-of-code-23
Apache License 2.0
src/main/kotlin/org/domnikl/algorithms/graphs/WeightedGraph.kt
domnikl
231,452,742
false
null
package org.domnikl.algorithms.graphs import org.domnikl.data_structures.LinkedList class WeightedGraph<T : Any> { private val graph = mutableMapOf<T, LinkedList<Edge<T>>>() fun addEdge(from: T, to: T, weight: Double) { graph.getOrPut(from) { LinkedList() }.addFirst(Edge(to, weight)) graph.ge...
5
Kotlin
3
13
3b2c191876e58415d8221e511e6151a8747d15dc
1,970
algorithms-and-data-structures
Apache License 2.0
src/main/kotlin/day18/Day18.kt
Arch-vile
317,641,541
false
null
package day18 import readFile fun main(args: Array<String>) { val computations = readFile("./src/main/resources/day18Input.txt") val sum = computations .map { calculate(it) } .sum() println(sum) } fun calculate(originalCalculation: String): Long { var calculation = originalCalculation.replace(" ", ...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
1,731
adventOfCode2020
Apache License 2.0
src/main/kotlin/Day2.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
import kotlin.String import kotlin.collections.List object Day2 { data class Cube( val color: String, val count: Int ) data class Game( val id: Int, val cubePulls: List<List<Cube>> ) { companion object { fun parseGame(s: String): Game { ...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
1,959
kotlin-kringle
Apache License 2.0
src/main/kotlin/year2022/Day11.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2022 class Day11 { data class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val divider: Long, val trueThrow: Int, val falseThrow: Int, var inspections: Long = 0 ) private fun parseMonkeys(input: String) = input.split("\n\...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,305
aoc-2022
Apache License 2.0
src/Day04.kt
toninau
729,811,683
false
{"Kotlin": 8423}
fun main() { data class Scratchcard(val index: Int, val winningNumbers: List<Int>, val guessedNumbers: List<Int>) fun parse(input: List<String>): List<Scratchcard> { return input.mapIndexed { index, line -> val scratchcardNumbers = line.substringAfter(':').split('|').map { numbers -> ...
0
Kotlin
0
0
b3ce2cf2b4184beb2342dd62233b54351646722b
1,457
advent-of-code-2023
Apache License 2.0
kotlin/src/main/kotlin/be/swsb/aoc2023/day3/Schematic.kt
Sch3lp
724,797,927
false
{"Kotlin": 44815, "Rust": 14075}
package be.swsb.aoc2023.day3 import be.swsb.aoc2023.Point fun String.parse() = Schematic(lines().flatMapIndexed { y, line -> line.mapIndexed { x, char -> Point(x, y) to char } }.toMap()) typealias Gear = Pair<Point, Set<Int>> val Gear.ratio get() = this.second.map { it.toLong() }....
0
Kotlin
0
1
dec9331d3c0976b4de09ce16fb8f3462e6f54f6e
2,596
Advent-of-Code-2023
MIT License
src/Day03.kt
camina-apps
572,935,546
false
{"Kotlin": 7782}
import kotlin.math.floor import kotlin.math.roundToInt fun main() { fun priorityOfItem(letter: Char): Int { val offset = if (letter.isUpperCase()) 38 else 96 return letter.code - offset } fun findDuplicate(rucksack: String): Char { val half = (rucksack.length / 2.0).roundToInt() ...
0
Kotlin
0
0
fb6c6176f8c127e9d36aa0b7ae1f0e32b5c31171
1,639
aoc_2022
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day15.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day15.solve() } object Day15 : AdventSolution(2023, 15, " Lens Library") { override fun solvePartOne(input: String) = input.splitToSequence(",").sumOf(::hash) override fun solvePartTwo(input: String): Int { val hashma...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,271
advent-of-code
MIT License
src/main/day04/Day04.kt
rolf-rosenbaum
543,501,223
false
{"Kotlin": 17211}
package day04 import readInput import second import java.time.LocalDateTime import java.time.format.DateTimeFormatter fun part1(input: List<String>): Int { val guards = input.guards() val mostAsleepGuard = guards.maxByOrNull { it.sleepIntervals.sumOf { range -> range.second - range.first } }!! ...
0
Kotlin
0
0
dfd7c57afa91dac42362683291c20e0c2784e38e
2,652
aoc-2018
Apache License 2.0
kotlin/src/main/kotlin/year2023/Day23.kt
adrisalas
725,641,735
false
{"Kotlin": 130217, "Python": 1548}
package year2023 fun main() { val input = readInput("Day23") Day23.part1(input).println() Day23.part2(input).println() } object Day23 { fun part1(trails: List<String>): Int { val visited = List(trails.size) { MutableList(trails[0].length) { false } ...
0
Kotlin
0
2
6733e3a270781ad0d0c383f7996be9f027c56c0e
5,004
advent-of-code
MIT License
src/algorithmdesignmanualbook/sorting/FastMedian.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.sorting import utils.shouldBe /** * NO need to sort all the items. * Just find the sort the items before the median index * Using quicksort, find the partition. * Then throw away the left partition if the median index lies in the right portion * while calibrating the new median ...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,063
algorithms
MIT License
solutions/aockt/y2023/Y2023D04.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import io.github.jadarma.aockt.core.Solution import kotlin.math.pow object Y2023D04 : Solution { /** * Information about an elven scratchcard. * * @property id The ID. * @property winningNumbers The winning numbers, written on the left of the pipe. ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,863
advent-of-code-kotlin-solutions
The Unlicense
src/Day22.kt
sabercon
648,989,596
false
null
typealias Deck = List<Int> typealias Decks = Pair<Deck, Deck> private fun win1(card1: Int, card2: Int, deck1: Deck, deck2: Deck): Boolean { return card1 > card2 } private fun win2(card1: Int, card2: Int, deck1: Deck, deck2: Deck): Boolean { return if (deck1.size < card1 || deck2.size < card2) card1 > card2 ...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
1,536
advent-of-code-2020
MIT License
src/day02/Day02.kt
skempy
572,602,725
false
{"Kotlin": 13581}
package day02 import day02.Result.DRAW import day02.Result.LOSE import day02.Result.WIN import day02.TournamentOptions.Paper import day02.TournamentOptions.Rock import day02.TournamentOptions.Scissors import readInputAsPairs enum class Result(val points: Int) { WIN(6), DRAW(3), LOSE(0) } sealed class Tou...
0
Kotlin
0
0
9b6997b976ea007735898083fdae7d48e0453d7f
3,712
AdventOfCode2022
Apache License 2.0
Advent-of-Code-2023/src/Day17.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
import java.util.PriorityQueue private const val AOC_DAY = "Day17" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY private data class Block(val row: Int, val col: Int, val dirRow: Int, val dirCol: Int, val heatLoss: Int, val dirCounter: Int, val path: List<Position> = listOf(Po...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
5,536
Advent-of-Code-2023
Apache License 2.0
src/Day23.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
private enum class MoveDirection { NORTH, SOUTH, WEST, EAST; } fun main() { data class Point(val row: Int, val col: Int) fun Point.next(direction: MoveDirection) = when (direction) { MoveDirection.NORTH -> copy(row = row - 1) MoveDirection.SOUTH -> copy(row = row + 1) MoveDirection...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
4,270
advent-of-code-22
Apache License 2.0
src/Day12.kt
rifkinni
573,123,064
false
{"Kotlin": 33155, "Shell": 125}
class Grid(val rows: List<List<Coordinate>>, val start: Coordinate, val end: Coordinate) { private val nodes: MutableSet<Coordinate> = mutableSetOf(start) fun run(): Int { start.distanceFromStart = 0 nodes.removeAll(nodes) nodes.add(start) while (end.dista...
0
Kotlin
0
0
c2f8ca8447c9663c0ce3efbec8e57070d90a8996
3,909
2022-advent
Apache License 2.0
src/main/kotlin/day16.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getText fun toBits(input: String): Bits{ return Bits(input.map { it.digitToInt(16).toString(2).padStart(4, '0') }.joinToString("")) } fun versionSum(packets: List<Packet>): Int{ return packets.sumOf { it.version + versionSum(it.subPackets) } } fun evaluatePackets(packet: Packet): Long{ retu...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
2,801
AdventOfCode2021
MIT License
src/main/kotlin/days/y2023/day17/Day17.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day17 import util.InputReader import java.util.PriorityQueue import kotlin.math.abs typealias PuzzleLine = String typealias PuzzleInput = List<PuzzleLine> class Day17(val input: PuzzleInput) { val grid = input.toGrid() fun partOne(): Int { val queue = makeQueue( ...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
4,772
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/day10/Day10.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day10 import java.io.File import java.util.LinkedList // Poor man's Either -> Pair<A?, B?> fun findMissingSequenceOrOffendingChar(line: String): Pair<Char?, String?> { val missingSequence = LinkedList<Char>() line.forEach { c -> when (c) { '(' -> missingSequence.addFirst(')') '[' -> missi...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
1,698
advent-of-code-2021
MIT License
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day09.kt
JamJaws
725,792,497
false
{"Kotlin": 30656}
package com.jamjaws.adventofcode.xxiii.day import com.jamjaws.adventofcode.xxiii.readInput class Day09 { fun part1(text: List<String>): Int = text.asSequence() .map { line -> line.split(' ').map(String::toInt) } .map { values -> getDifferenceSequences(values) } .map { ...
0
Kotlin
0
0
e2683305d762e3d96500d7268e617891fa397e9b
1,415
advent-of-code-2023
MIT License
2022/src/Day14.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src fun main() { val walls = mutableSetOf<Pair<Int,Int>>() val sands = mutableSetOf<Pair<Int,Int>>() readInput("input14") .map { it.trim().split("->") } .map { it.map { nane -> nane.trim().split(",") } .map { list -> list.map { str -> str.toInt() } } } .map { i...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
1,915
AoC
Apache License 2.0
src/Day5.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
import java.util.Stack fun main() { fun parse(input: List<String>): Pair<List<Stack<Char>>, List<CrateMove>> { val stacks = input.filterNot { it.startsWith("move") || it.isEmpty() } val map = mutableMapOf<Int, Stack<Char>>() (stacks.lastIndex - 1 downTo 0).forEach { ...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
2,392
advent-of-code-2022
Apache License 2.0
src/Day20.kt
mikrise2
573,939,318
false
{"Kotlin": 62406}
fun mix(list: List<Pair<Long, Long>>): List<Pair<Long, Long>> { val mixedList = list.toMutableList() val size = list.size repeat(size) { index -> val currentIndex = mixedList.indexOfFirst { it.first == index.toLong() } val elem = mixedList.removeAt(currentIndex) val newIndex = (curre...
0
Kotlin
0
0
d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8
1,437
Advent-of-code
Apache License 2.0
src/main/kotlin/de/pgebert/aoc/days/Day02.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day class Day02(input: String? = null) : Day(2, "Cube Conundrum", input) { override fun partOne() = inputList.mapNotNull(::getGameIdOfValidInputLine).sum() private fun parseGameId(game: String): Int { return game.filter { it.isDigit() }.toInt...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
1,833
advent-of-code-2023
MIT License
src/Day07.kt
Excape
572,551,865
false
{"Kotlin": 36421}
class Dir { var size = 0 val children = mutableSetOf<Dir>() fun parseLs(input: String) { this.size = input.split("\n").drop(1) .filterNot { it.startsWith("dir") } .fold(0) { totalSize, line -> totalSize + line.split(" ").first().toInt() } } fun addChild() = Dir().als...
0
Kotlin
0
0
a9d7fa1e463306ad9ea211f9c037c6637c168e2f
2,134
advent-of-code-2022
Apache License 2.0
src/main/kotlin/net/wrony/aoc2023/a5/Main.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a5 import kotlin.io.path.Path import kotlin.io.path.readText data class MappingRange(val destStart: Long, val sourceStart: Long, val length: Long) { fun mapsValue(l: Long): Boolean = l in sourceStart..<sourceStart + length fun mapSourceToDestVal(l: Long): Long { return destSt...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
3,671
aoc-2023-kotlin
MIT License
src/main/kotlin/day2/Day2.kt
stoerti
726,442,865
false
{"Kotlin": 19680}
package io.github.stoerti.aoc.day2 import io.github.stoerti.aoc.IOUtils fun main(args: Array<String>) { val redLimit = 12 val greenLimit = 13 val blueLimit = 14 val games = IOUtils.readInput("day_2_input") .map { Game.fromString(it) } val result1 = games .filter { it.maxRed() <= redLimit && ...
0
Kotlin
0
0
05668206293c4c51138bfa61ac64073de174e1b0
1,923
advent-of-code
Apache License 2.0
src/main/kotlin/aoc/year2023/Day07.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2023 import aoc.Puzzle /** * [Day 7 - Advent of Code 2023](https://adventofcode.com/2023/day/7) */ object Day07 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int = input.lineSequence() .map { it.split(' ').let { (a, b) -> a.toHand() to b.toInt() } } .sortedByDesc...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
2,214
advent-of-code
Apache License 2.0
src/2022/Day13.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput import splitBy fun main() { fun part1(input: List<String>): Int { return input.splitBy { it.isEmpty() }.mapIndexed { index, (left, right) -> val leftPacket = Packet.parsePacket(left) val rightPacket = Packet.parsePacket(right) if (leftPa...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,491
aoc-2022-in-kotlin
Apache License 2.0
src/Day03.kt
orirabi
574,124,632
false
{"Kotlin": 14153}
val priorities = generateSequence('a' to 1) { when (it.first) { 'z' -> 'A' to it.second + 1 'Z' -> null else -> it.first + 1 to it.second + 1 } } .toMap() fun main() { fun getDuplicate(pack: String): Char { val compartments = pack.chunked(pack.length / 2) check(...
0
Kotlin
0
0
41cb10eac3234ae77ed7f3c7a1f39c2f9d8c777a
1,360
AoC-2022
Apache License 2.0
src/aoc23/Day02.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day02 import java.lang.Integer.max import lib.Solution enum class Cube { RED, GREEN, BLUE; companion object { fun parse(cubeStr: String) = Cube.valueOf(cubeStr.uppercase()) } } data class Cubes(val cubes: Map<Cube, Int>) { fun isPossible(maxCubes...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,873
aoc-kotlin
Apache License 2.0
day07/kotlin/corneil/src/main/kotlin/solution.kt
timgrossmann
224,991,491
true
{"HTML": 2739009, "Python": 169603, "Java": 157274, "Jupyter Notebook": 116902, "TypeScript": 113866, "Kotlin": 89503, "Groovy": 73664, "Dart": 47763, "C++": 43677, "CSS": 34994, "Ruby": 27091, "Haskell": 26727, "Scala": 11409, "Dockerfile": 10370, "JavaScript": 6496, "PHP": 4152, "Go": 2838, "Shell": 2493, "Rust": 208...
package com.github.corneil.aoc2019.day7 import com.github.corneil.aoc2019.intcode.Program import com.github.corneil.aoc2019.intcode.readProgram import java.io.File fun phaseAmplifierTest(code: List<Long>, sequence: LongArray): Long { val program = Program(code) var amplifierInput = 0L sequence.forEach { p...
0
HTML
0
1
bb19fda33ac6e91a27dfaea27f9c77c7f1745b9b
2,174
aoc-2019
MIT License
src/hongwei/leetcode/playground/leetcode_2021/M39_CombinationSum.kt
hongwei-bai
201,601,468
false
{"Java": 143669, "Kotlin": 38875}
package hongwei.leetcode.playground.leetcode_2021 import hongwei.leetcode.playground.common.Log class M39_CombinationSum { fun test() { val listOfCandidates = listOf( listOf(2, 3, 6, 7), listOf(2, 3, 5), listOf(2), listOf(1), listOf(1), )...
0
Java
0
1
9d871de96e6b19292582b0df2d60bbba0c9a895c
3,866
leetcode-exercise-playground
Apache License 2.0
advent-of-code2015/src/main/kotlin/day2/Advent2.kt
REDNBLACK
128,669,137
false
null
package day2 import mul import parseInput import splitToLines /** --- Day 2: I Was Told There Would Be No Math --- The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order ex...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,568
courses
MIT License
2022/src/Day08.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src fun main() { val visibility = mutableListOf<MutableList<Boolean>>() val scenicScores = mutableListOf<Int>() val input = readInput("input8") .map { it.trim() } .map { it.chunked(1) .map { it2 -> it2.toInt() } } fun isVisibleFromDirection(x: Int, y: Int, directio...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
2,581
AoC
Apache License 2.0
src/day08/Day08.kt
shiddarthbista
572,833,784
false
{"Kotlin": 9985}
package day08 import readInput fun main() { fun part1(input: List<String>): Int { return input.indices.sumOf { i -> input[0].indices.count { j -> val left = (j - 1 downTo 0).map { i to it } val right = (j + 1 until input[0].length).map { i to it } ...
0
Kotlin
0
0
ed1b6a132e201e98ab46c8df67d4e9dd074801fe
1,432
aoc-2022-kotlin
Apache License 2.0
src/Day14.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
fun main() { fun part1(input: List<String>): Int { val parsedInput = input.parseToStone().map { it.points } val stones = parsedInput.flatten().toSet() val maxDepth = stones.maxByOrNull { it.y }!!.y println("Cave is $stones with max depth of $maxDepth") val sand = mutableSetOf...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
3,821
aoc-2022
Apache License 2.0
src/aoc2021/day03/Code.kt
ldickmanns
572,675,185
false
{"Kotlin": 48227}
package aoc2021.day03 import readInput fun main() { val input = readInput("aoc2021/day03/input") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val nColumns = input.first().length val oneCounters = IntArray(nColumns) input.forEach { line: String -> ...
0
Kotlin
0
0
2654ca36ee6e5442a4235868db8174a2b0ac2523
2,216
aoc-kotlin-2022
Apache License 2.0
solutions/qualifications/cheating-detection/src/main/kotlin/solutions.cheating.detection/CheatingDetectionSolution.kt
Lysoun
351,224,145
false
null
import kotlin.math.exp import kotlin.math.ln fun main(args: Array<String>) { val casesNumber = readLine()!!.toInt() // Ignore required percentage to success readLine() for (i in 1..casesNumber) { println("Case #$i: ${findCheater(List(100) { 0 }.map { readLine()!! })}") } } fun numberOfGo...
0
Kotlin
0
0
98d39fcab3c8898bfdc2c6875006edcf759feddd
2,707
google-code-jam-2021
MIT License
src/main/de/ddkfm/Day4.kt
DDKFM
433,861,159
false
{"Kotlin": 13522}
package de.ddkfm data class Board( val board : List<List<Int>> = emptyList(), val marked : List<MutableList<Boolean>> = board.map { it.map { false }.toMutableList() } ) { fun find(number : Int) : Int { var find = -1 board.indices.map { i -> board[i].indices.map { j -> ...
0
Kotlin
0
0
6e147b526414ab5d11732dc32c18ad760f97ff59
3,467
AdventOfCode21
MIT License
day9/src/Program.kt
DaveTCode
433,797,148
false
null
package org.davetcode.aoc2021.day9 import java.io.File fun main() { val testData = processFile("c:\\code\\home\\aoc2021day9\\test.txt") val inputData = processFile("c:\\code\\home\\aoc2021day9\\input.txt") println(part1(testData)) println(part1(inputData)) println(part2(testData)) println(part...
0
Rust
1
0
2e3132403133529ef5d13ac098599a0ee8c584f2
3,003
aoc2021
MIT License
src/day7/Day07.kt
MatthewWaanders
573,356,006
false
null
package day7 import day7.tree.Directory import day7.tree.File import day7.tree.Node import day7.tree.Root import utils.readInput const val part1Limit = 100000 const val requiredSpace = 30000000 const val totalSpace = 70000000 fun main() { val testInput = readInput("Day07_test", "day7") check(part1(testInput)...
0
Kotlin
0
0
f58c9377edbe6fc5d777fba55d07873aa7775f9f
2,272
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day19.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils private val bluePrintRegex = "Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. Each obsidian robot costs (\\d+) ore and (\\d+) clay. Each geode robot costs (\\d+) ore and (\\d+) obsidian.".toRegex() data class BluePrint( val id: Int, ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
4,138
aoc-2022-kotlin
Apache License 2.0
src/Day11/Day11.kt
tomashavlicek
571,148,715
false
{"Kotlin": 23780}
package Day11 import readInput import java.math.BigInteger import java.util.LinkedList import java.util.Queue fun main() { class Monkey( val items: Queue<Long>, val operation: (old: Long) -> Long, val testDivisible: Int, val ifTrue: Int, val ifFalse: Int, var inspe...
0
Kotlin
0
0
899d30e241070903fe6ef8c4bf03dbe678310267
4,040
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
euphonie
571,665,044
false
{"Kotlin": 23344}
interface OverlapValidator { fun checks(range: IntRange, otherRange: IntRange) : Boolean } class FullOverlapValidator: OverlapValidator { override fun checks(range: IntRange, otherRange: IntRange): Boolean { val firstInSecond = range.first in otherRange && range.last in ...
0
Kotlin
0
0
82e167e5a7e9f4b17f0fbdfd01854c071d3fd105
2,131
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
pmellaaho
573,136,030
false
{"Kotlin": 22024}
fun main() { fun stringToRanges(row: String): Pair<IntRange, IntRange> { return row.split(",").map { val nbrs = it.split("-") nbrs.first().toInt()..nbrs.last().toInt() }.let { Pair(it.first(), it.last()) } } fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
cd13824d9bbae3b9debee1a59d05a3ab66565727
1,175
AoC_22
Apache License 2.0
src/y2015/Day13.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput object Day13 { private fun parse(input: List<String>): Pair<Set<String>, Map<Pair<String, String>, Int>> { val names = mutableSetOf<String>() val happiness = input.associate { val elements = it.split(' ') val p1 = elements.first() ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
3,023
advent-of-code
Apache License 2.0
src/Day03.kt
rmyhal
573,210,876
false
{"Kotlin": 17741}
fun main() { fun part1(input: List<String>): Int { return priorities(input) } fun part2(input: List<String>): Int { return groupPriorities(input) } val input = readInput("Day03") println(part1(input)) println(part2(input)) } private fun priorities(input: List<String>) = input.sumOf { findPriori...
0
Kotlin
0
0
e08b65e632ace32b494716c7908ad4a0f5c6d7ef
925
AoC22
Apache License 2.0
src/Day05.kt
rod41732
728,131,475
false
{"Kotlin": 26028}
/** * You can edit, run, and share this code. * play.kotlinlang.org */ fun main() { val testInput = readInput("Day05_test") val input = readInput("Day05") data class MapRule(val destStart: Long, val srcStart: Long, val length: Long) { fun mapOrNull(number: Long): Long? { return if (s...
0
Kotlin
0
0
05a308a539c8a3f2683b11a3a0d97a7a78c4ffac
2,760
aoc-23
Apache License 2.0
src/main/kotlin/y2022/day13/Day13.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2022.day13 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } var index = 0 fun initParseData(line: String): List<Any> { index = 0 return parseData(line) } fun parseData(line: String): List<Any> { val list: MutableList<Any> = ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
3,248
AdventOfCode
MIT License
src/AoC1.kt
Pi143
317,631,443
false
null
import java.io.File fun main() { println("Starting Day 1 A Test 1") calculateDay1PartA(2020, "Input/2020_1_A_test1") println("Starting Day 1 A Real") calculateDay1PartA(2020, "Input/2020_1_A") println("Starting Day 1 B Test 1") calculateDay1PartB(2020, "Input/2020_1_A_test1") println("Star...
0
Kotlin
0
1
fa21b7f0bd284319e60f964a48a60e1611ccd2c3
2,484
AdventOfCode2020
MIT License
solutions/qualifications/reverse-sort-engineering/src/main/kotlin/solutions.reverse.sort.engineering/ReverseSortEngineeringSolution.kt
Lysoun
351,224,145
false
null
fun main(args: Array<String>) { val casesNumber = readLine()!!.toInt() for (i in 1..casesNumber) { val lineInput = readLine()!!.split(" ") println("Case #$i: ${findListMatchingConstraints(ProblemInput(lineInput[0].toInt(), lineInput[1].toInt()))}") } } const val IMPOSSIBLE = "IMPOSSIBLE" ...
0
Kotlin
0
0
98d39fcab3c8898bfdc2c6875006edcf759feddd
2,385
google-code-jam-2021
MIT License
src/Day09.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
import kotlin.math.abs class Vector(val x: Int, val y: Int) enum class Direction(val vector: Vector) { R(Vector(+1, 0)), L(Vector(-1, 0)), U(Vector(0, -1)), D(Vector(0, +1)) } class Knot(var x: Int, var y: Int) { val history = mutableSetOf<Pair<Int, Int>>() init { history.add(Pair(x, ...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
1,977
advent-of-code-2022
Apache License 2.0
src/day2/Day02.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day2 import day2.Chain.getFightPoints import day2.Chain.getSignForResult import readInput sealed class Result { companion object { fun fromSymbol(s: Char): Result { return when(s) { 'X' -> Lose 'Y' -> Draw else -> Win } ...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,953
advent-of-code-2022
Apache License 2.0
src/main/kotlin/year_2023/Day04.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2023 import Day import solve class Day04 : Day(day = 4, year = 2023, "Scratchcards") { private fun getCards(): List<Card> { val cards = mutableListOf<Card>() for (entry in input) { val data = entry.split(":") val id = data.first().split(" ").last().toInt() ...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
2,465
advent-of-code
Apache License 2.0
lib/src/main/kotlin/com/bloidonia/advent/day13/Day13.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day13 import com.bloidonia.advent.readText data class Point(val x: Int, val y: Int) { fun reflect(axis: String, pos: Int) = when (axis) { "x" -> if (x < pos) this else Point(pos - (x - pos), y) else -> if (y < pos) this else Point(x, pos - (y - pos)) } } class Fol...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,493
advent-of-kotlin-2021
MIT License
src/Day03.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
val Char.priority: Int get() { return when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> error("Unknown priority for $this") } } fun findDuplicatesIn(rucksack: String): Char { val half = rucksack.length / 2 for (index...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
1,489
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/lib/Vector.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.lib import kotlin.math.* abstract class VectorI(val data: List<Int>) { fun norm(ord: Order): Int { return when (ord) { Order.L1 -> data.sumOf { it.absoluteValue } Order.L2 -> sqrt(data.sumOf { it * it }.toDouble()).roundToInt() Order.Linf -> data...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,756
advent-of-code-kotlin
MIT License
src/main/kotlin/day11.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.chunks import shared.getText import shared.lcm fun main() { val input = getText("day11.txt") println(day11A(input)) println(day11B(input)) } fun day11A(input: String): Long { return findMonkeyBusiness(input, 20) } fun day11B(input: String): Long { return findMonkeyBusiness(input, 10...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
2,295
AdventOfCode2022
MIT License
src/day7/day7.kt
bienenjakob
573,125,960
false
{"Kotlin": 53763}
package day7 import inputTextOfDay import testTextOfDay fun part1(input: String): Int { val maxSize = 100_000 return scanDirectorySizes(input) .toList() .filter { it <= maxSize } .sumOf { it } } fun part2(input: String): Int { val dirSizes = scanDirectorySizes(input) val tot...
0
Kotlin
0
0
6ff34edab6f7b4b0630fb2760120725bed725daa
1,740
aoc-2022-in-kotlin
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/TwoHeaps.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
// The "Two Heaps" coding pattern involves using two heaps (usually a max heap and a min heap) to efficiently solve problems //where you need to find the median or maintain order statistics in a stream of numbers. /* Usage: In many problems, we are given a set of elements that can be divided into two parts. We are i...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
3,339
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/day05/day05.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day05 import util.extractIntGroups import util.readInput import util.shouldBe import java.util.LinkedList fun main() { val day = 5 val testInput = readInput(day, testInput = true).parseInput() part1(testInput) shouldBe "CMZ" part2(testInput) shouldBe "MCD" val input = readInput(day).parse...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
2,137
advent-of-code-2022
Apache License 2.0
src/Day14.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Int { val (grid, xRange) = parse(input) return simulate(grid, xRange.first, xRange.second) } fun part2(input: List<String>): Int { val (grid, x, maxY) = parse(input) grid[maxY + 2].ru...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
2,681
advent-of-code-2022
Apache License 2.0
src/Day14.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import kotlin.math.max import kotlin.math.min private fun List<List<Char>>.print() { println(joinToString("\n") { it.joinToString("") }) } fun main() { fun List<String>.parse(): Triple<MutableList<MutableList<Char>>, Pair<Int, Int>, Pair<Int, Int>> { val lines = map { it.split(" -> ").map ...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
3,183
advent-of-code-2022
Apache License 2.0
codeforces/kotlinheroes6/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes6 private fun solve() { readLn() val a = readInts() val st = SegmentsTreeMax(a.size) val seen = IntArray(a.size + 1) { -1 } for (i in a.indices) { val x = a[i] val prev = seen[x] if (prev == -1) { seen[x] = i continue } val best = maxOf(st.get(prev, i), if (prev + 1 ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,250
competitions
The Unlicense
src/main/kotlin/days/Day21.kt
sicruse
315,469,617
false
null
package days class Day21 : Day(21) { private val recipies: Map<Set<String>, Set<String>> by lazy { inputList.map { text -> val ingredients = text.split(" (").first().split(" ").toSet() val allergens = text.split("(contains ").last().dropLast(1).split(", ").toSet() ingre...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
3,284
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/timakden/aoc/year2022/Day02.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day02.Outcome.* import ru.timakden.aoc.year2022.Day02.Shape.Companion.canDefeat import ru.timakden.aoc.year2022.Day02.Shape.Companion.getShapeByCondition import ru.timakden.aoc.yea...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
3,016
advent-of-code
MIT License
src/Day07.kt
Sagolbah
573,032,320
false
{"Kotlin": 14528}
fun main() { fun buildTree(input: List<String>): Node { val root: Node.Dir = Node.Dir(mutableListOf(), null, "/") var curr = root for (line in input) { val arr = line.split(" ") if (arr.size == 3 && arr[1] == "cd") { curr = when (val dest = arr[2]) { ...
0
Kotlin
0
0
893c1797f3995c14e094b3baca66e23014e37d92
2,145
advent-of-code-kt
Apache License 2.0
src/main/kotlin/16.kts
reitzig
318,492,753
false
null
import java.io.File data class Rule(val name: String, val ranges: List<IntRange>) { fun admits(value: Int): Boolean = ranges.any { it.contains(value) } companion object { operator fun invoke(ruleLine: String): Rule { val (name, rangesString) = ruleLine.split(":") val ra...
0
Kotlin
0
0
f17184fe55dfe06ac8897c2ecfe329a1efbf6a09
3,194
advent-of-code-2020
The Unlicense
calendar/day15/Day15.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day15 import Day import Lines import tools.* import java.lang.Integer.max import kotlin.math.abs class Day15 : Day() { override fun part1(input: Lines): Any { val sensors = input.map { runParser(sensor(), it) } val mergedRanges = rowCoverage(sensors, 2_000_000) return mergedRange...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
2,784
advent-of-code-2022
Apache License 2.0
src/main/kotlin/be/tabs_spaces/advent2021/days/Day17.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import be.tabs_spaces.advent2021.util.sumToNFromOne import kotlin.math.abs class Day17 : Day(17) { private val trajectoryControl = TargetArea.from(inputString).let { targetArea -> TrajectoryControl(targetArea) } override fun partOne() = trajectoryControl.maxVerticalSpee...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
2,891
advent-2021
Creative Commons Zero v1.0 Universal
src/Day13.kt
oleksandrbalan
572,863,834
false
{"Kotlin": 27338}
fun main() { val input = readInput("Day13") .filterNot { it.isEmpty() } .map { it.parseRoot() } val part1 = input .chunked(2) .mapIndexed { index, (left, right) -> if (left < right) index + 1 else -0 } .sum() println("Part1: $part1") val divider1 = "[[2]]".pars...
0
Kotlin
0
2
1493b9752ea4e3db8164edc2dc899f73146eeb50
2,252
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day15.kt
jcornaz
573,137,552
false
{"Kotlin": 76776}
import kotlin.math.abs object Day15 { fun part1(input: String): Long = numberOfNonBeacon(input, 2000000).toLong() fun part2(input: String, searchScope: Int): Long { val scan = Scan.parse(input) val beacon = (0..searchScope) .asSequence() .map { y -> y to scan.uncovered...
1
Kotlin
0
0
979c00c4a51567b341d6936761bd43c39d314510
3,812
aoc-kotlin-2022
The Unlicense
src/Day04.kt
iartemiev
573,038,071
false
{"Kotlin": 21075}
class SectionRange(private val start: Int, private val end: Int) { fun partiallyOverlapsWith(range2: SectionRange): Boolean { return end >= range2.start && start <= range2.end } fun fullyOverlapsWith(range2: SectionRange): Boolean { return (start <= range2.start && end >= range2.end) || (range2.s...
0
Kotlin
0
0
8d2b7a974c2736903a9def65282be91fbb104ffd
1,212
advent-of-code
Apache License 2.0
src/Day03.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
fun main() { fun getPriority(input: Char): Int { return if (input.isUpperCase()) { input.code - 64 + 26 } else { input.code - 96 } } fun part1(input: List<String>): Int { var prioritySum = 0 input.forEach { val midIndex = it.length...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
1,583
advent-of-code-2022
Apache License 2.0
src/day-6.kt
drademacher
160,820,401
false
null
import java.io.File import kotlin.math.abs fun main(args: Array<String>) { println("part 1: " + partOne()) println("part 2: " + partTwo()) } private data class Point(val x: Int, val y: Int) { fun distance(other: Point): Int = abs(x - other.x) + abs(y - other.y) } private fun partOne(): Int? { val poi...
0
Kotlin
0
0
a7f04450406a08a5d9320271148e0ae226f34ac3
2,510
advent-of-code-2018
MIT License
src/year2022/day02/Day02.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day02 import io.kotest.matchers.shouldBe import utils.readInput fun main() { val testInput = readInput("02", "test_input") val realInput = readInput("02", "input") testInput.part1().also(::println) shouldBe 15 realInput.part1().let(::println) testInput.part2().also(::println) sh...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,836
Advent-of-Code
Apache License 2.0
src/day09/Day09.kt
schrami8
572,631,109
false
{"Kotlin": 18696}
package day09 import readInput import java.util.* import kotlin.collections.ArrayList import kotlin.math.abs data class Location(var x: Int, var y: Int) { fun isTouching(location: Location): Boolean { return abs(x - location.x) <= 1 && abs(y - location.y) <= 1 } } fun move(direction: String, location...
0
Kotlin
0
0
215f89d7cd894ce58244f27e8f756af28420fc94
2,252
advent-of-code-kotlin
Apache License 2.0
day-05/src/main/kotlin/HydrothermalVenture.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 field = Array(1000) { IntArray(1000) } readLines().forEach { val linePoints = it.getLinePoints(diagonals = false) linePoints.forEach { p ->...
0
Kotlin
0
0
17af21b269739e04480cc2595f706254bc455008
2,675
aoc-2021
MIT License
src/main/kotlin/de/pgebert/aoc/days/Day03.kt
pgebert
724,032,034
false
{"Kotlin": 65831}
package de.pgebert.aoc.days import de.pgebert.aoc.Day import kotlin.math.max import kotlin.math.min class Day03(input: String? = null) : Day(3, "Gear Ratios", input) { private val numberRegex = "\\d+".toRegex() private val specialCharacterRegex = "[^\\d.]".toRegex() private val gearRegex = "\\*".toRegex(...
0
Kotlin
1
0
a30d3987f1976889b8d143f0843bbf95ff51bad2
2,435
advent-of-code-2023
MIT License
src/Day18.kt
er453r
572,440,270
false
{"Kotlin": 69456}
fun main() { fun part1(input: List<String>): Int { val occupied = input.map { it.ints() }.map { (x, y, z) -> Vector3d(x, y, z) }.toSet() return occupied.sumOf { cube -> 6 - Vector3d.DIRECTIONS.count { dir -> cube + dir in occupied } } } fun part2(input: List<String>): Int { val occ...
0
Kotlin
0
0
9f98e24485cd7afda383c273ff2479ec4fa9c6dd
1,844
aoc2022
Apache License 2.0
src/Day03.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
val smallLetters = buildList { var character = 'a'.also(::add) while (character != 'z') add(++character) } val allLetters = smallLetters + smallLetters.map(Char::uppercaseChar) fun main() { fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val firstCompartme...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
1,283
advent-of-code-2022
Apache License 2.0
rl-algo/src/main/kotlin/wumo/sim/algorithm/drl/common/SegmentTree.kt
wumo
305,330,037
false
null
package wumo.sim.algorithm.drl.common open class SegmentTree<T>(val capacity: Int, inline val operation: (T, T) -> T, neutral_element: T) { init { assert(capacity > 0 && (capacity and (capacity - 1)) == 0) { "capacity must be positive and a power of 2....
0
null
0
0
2a3a5118239b27eeb268cd1e7bdbfe5f5604dab6
2,374
sim-world
MIT License
src/main/kotlin/be/seppevolkaerts/day7/Day7.kt
Cybermaxke
727,453,020
false
{"Kotlin": 35118}
package be.seppevolkaerts.day7 data class Hand( val cards: String, val bid: Int, ) fun parseHands(iterable: Iterable<String>) = iterable.map { line -> val split = line.split(' ') Hand(split[0], split[1].toInt()) } private fun Hand.type(jokerChar: Char? = null): Int { val groupsByChar = cards.groupB...
0
Kotlin
0
1
56ed086f8493b9f5ff1b688e2f128c69e3e1962c
2,869
advent-2023
MIT License
src/main/java/com/ncorti/aoc2021/Exercise15.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 import java.util.PriorityQueue object Exercise15 { private fun getInput() = getInputAsTest("15") { split("\n") } .map { line -> line.toCharArray().map { it.digitToInt() }.toTypedArray() } .toTypedArray() // Not the most elegant solution but it does ...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
2,529
adventofcode-2021
MIT License
src/main/kotlin/day18/Day18.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day18 import runDay import stackOf import kotlin.math.max import kotlin.math.min fun main() { fun part1(input: List<String>): Long { val grid = mutableSetOf<Point3D>() var sides = 0L input.map { it.toPoint() } .forEach { grid.add(it) sid...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
4,254
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day04.kt
michaeljwood
572,560,528
false
{"Kotlin": 5391}
fun main() { fun part1(input: List<String>) = inputLinesToRangePairs(input).count { it.first.overlapsFully(it.second) } fun part2(input: List<String>) = inputLinesToRangePairs(input).count { it.first.overlaps(it.second) } // test if implementation meets criteria from the description, like: val testInp...
0
Kotlin
0
0
8df2121f12a5a967b25ce34bce6678ab9afe4aa7
1,254
advent-of-code-2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions47.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import kotlin.math.max fun test47() { printlnResult(arrayOf( intArrayOf(1, 10, 3, 8), intArrayOf(12, 2, 9, 6), intArrayOf(5, 7, 4, 11), intArrayOf(3, 7, 16, 5), )) printlnResult(arrayOf( intArrayOf(1, 2, 3, 4, 5), )) pr...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,560
Algorithm
Apache License 2.0
src/main/kotlin/dp/SCS.kt
yx-z
106,589,674
false
null
package dp import util.* // shortest common supersequence // given A[1..m] and B[1..n], their common supersequence is a sequence that // contains both A and B as subsequences // find the minimum length of such supersequence fun main(args: Array<String>) { val A = intArrayOf(5, 6, 2) val B = intArrayOf(1, 5, 2, 5...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
4,988
AlgoKt
MIT License