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/leetcode/kotlin/array/easy/973. K Closest Points to Origin.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package leetcode.kotlin.array.easy import java.util.Arrays import kotlin.random.Random // O(nlogn),O(n) private fun kClosest1(points: Array<IntArray>, K: Int): Array<IntArray>? { fun distance(point: IntArray) = point[0] * point[0] + point[1] * point[1] val N = points.size val dists = IntArray(N) for (...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,714
leetcode-kotlin
Apache License 2.0
src/day12/Code.kt
fcolasuonno
225,219,560
false
null
package day12 import isDebug import java.io.File import kotlin.math.abs fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
2,077
AOC2019
MIT License
src/Day03.kt
bendh
573,833,833
false
{"Kotlin": 11618}
fun main() { fun charToValue(char: Char) = if (char.code >= 97) char.code - 96 else char.code - 38 fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val chunks = rucksack.chunked(rucksack.length / 2).map { it.toCharArray() }.toTypedArray() val compartment1 ...
0
Kotlin
0
0
e3ef574441b63a99a99a095086a0bf025b8fc475
1,121
advent-of-code-2022-kotlin
Apache License 2.0
src/Day14.kt
eo
574,058,285
false
{"Kotlin": 45178}
// https://adventofcode.com/2022/day/14 fun main() { fun part1(input: List<String>): Int { val sandSourcePoint = Point(500, 0) val blockedPoints = input.map(Path::fromString) .flatMap(Path::points) .toMutableSet() val maxOfPointY = blockedPoints.maxOf(Point::y) ...
0
Kotlin
0
0
8661e4c380b45c19e6ecd590d657c9c396f72a05
3,810
aoc-2022-in-kotlin
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/day08/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day08 import com.bloidonia.aoc2023.lcm import com.bloidonia.aoc2023.lines import com.bloidonia.aoc2023.repeat private const val example = """RL AAA = (BBB, CCC) BBB = (DDD, EEE) CCC = (ZZZ, GGG) DDD = (DDD, DDD) EEE = (EEE, EEE) GGG = (GGG, GGG) ZZZ = (ZZZ, ZZZ)""" private const val ex...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
2,271
aoc-2023
MIT License
src/Day21.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
fun main() { class Monkey(val children: List<String>, val operation: (List<Long>) -> Long) { fun getValue(tree: Map<String, Monkey>): Long { return operation(children.map { x -> tree[x]!!.getValue(tree) }) } } val operations: Map<String, (List<Long>) -> Long> = mapOf( "+...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
1,920
aoc-2022
Apache License 2.0
src/main/kotlin/aoc2015/ScienceForHungryPeople.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2015 fun scienceForHungryPeople1(ingredients: List<Ingredient>) = recipes(ingredients).maxOf { it.score() } fun scienceForHungryPeople2(ingredients: List<Ingredient>): Int = recipes(ingredients).filter { it.calories == 500 }.maxOf { it.score() } private fun recipes(ingredients: L...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,497
advent-of-code
MIT License
src/main/kotlin/Day05.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
fun main() { val movePattern = """move (?<amount>\d++) from (?<source>\d) to (?<target>\d)""".toPattern() fun part1(input: List<String>, rearrange: Boolean = true): String { val stackLines = input.takeWhile(String::isNotBlank).asReversed() val stackNumbersLine = stackLines[0] val stackN...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
2,029
aoc-2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day12/Day12.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day12 import eu.janvdb.aocutil.kotlin.readLines import java.util.* const val FILENAME = "input12.txt" fun main() { val connections = readLines(2021, FILENAME) .map { it.split('-').map(::Room) } .flatMap { rooms -> listOf(Connection(rooms[0], rooms[1]), Connection(rooms[1], rooms[0])) }...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,079
advent-of-code
Apache License 2.0
src/main/kotlin/Day23.kt
gijs-pennings
573,023,936
false
{"Kotlin": 20319}
import java.util.* private const val N_ROUNDS = 1000 // use N_ROUNDS=10 for part 1 private val NEIGHBORS_DELTA = listOf( Pos( 0, 1), Pos( 1, 1), Pos( 1, 0), Pos( 1, -1), Pos( 0, -1), Pos(-1, -1), Pos(-1, 0), Pos(-1, 1) ) fun main() { val lines = readInput(23) val w = line...
0
Kotlin
0
0
8ffbcae744b62e36150af7ea9115e351f10e71c1
2,778
aoc-2022
ISC License
2022/src/main/kotlin/com/github/akowal/aoc/Day17.kt
akowal
573,170,341
false
{"Kotlin": 36572}
package com.github.akowal.aoc import kotlin.math.min class Day17 { private val wind = inputFile("day17").readLines().single().map { when (it) { '>' -> 1 else -> -1 } } private val shapes = listOf( intArrayOf( 0b0011110, ), intArr...
0
Kotlin
0
0
02e52625c1c8bd00f8251eb9427828fb5c439fb5
3,004
advent-of-kode
Creative Commons Zero v1.0 Universal
src/main/kotlin/day12/Day12.kt
dustinconrad
572,737,903
false
{"Kotlin": 100547}
package day12 import geometry.Coord import geometry.plus import geometry.x import geometry.y import readResourceAsBufferedReader import java.util.function.Predicate fun main() { println("part 1: ${part1(readResourceAsBufferedReader("12_1.txt").readLines())}") println("part 2: ${part2(readResourceAsBufferedRea...
0
Kotlin
0
0
1dae6d2790d7605ac3643356b207b36a34ad38be
2,304
aoc-2022
Apache License 2.0
advent7/src/main/kotlin/Main.kt
thastreet
574,294,123
false
{"Kotlin": 29380}
import java.io.File interface IFile { val name: String val size: Int val parent: Directory? } data class SingleFile( override val name: String, override val size: Int, override val parent: Directory? ) : IFile data class Directory( override val name: String, override var parent: Direc...
0
Kotlin
0
0
e296de7db91dba0b44453601fa2b1696af9dbb15
3,752
advent-of-code-2022
Apache License 2.0
src/Day14.kt
fasfsfgs
573,562,215
false
{"Kotlin": 52546}
fun main() { fun part1(input: List<String>): Int { val verticalSlice = input.toLines().toVerticalSlice() return releaseSand(verticalSlice) } fun part2(input: List<String>): Int { val verticalSlice = input.toLines().toVerticalSlice() verticalSlice.addFloor() return r...
0
Kotlin
0
0
17cfd7ff4c1c48295021213e5a53cf09607b7144
3,217
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g1001_1100/s1031_maximum_sum_of_two_non_overlapping_subarrays/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1031_maximum_sum_of_two_non_overlapping_subarrays // #Medium #Array #Dynamic_Programming #Sliding_Window // #2023_05_24_Time_172_ms_(100.00%)_Space_36.7_MB_(100.00%) class Solution { fun maxSumTwoNoOverlap(nums: IntArray, firstLen: Int, secondLen: Int): Int { val firstLenSum = getFirst...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,255
LeetCode-in-Kotlin
MIT License
src/Day10.kt
xabgesagtx
572,139,500
false
{"Kotlin": 23192}
fun main() { val day = "Day10" fun calcCycleValues(input: List<String>): List<Pair<Int, Int>> { var x = 1 var cycle = 1 val cycleValues = input.flatMap { if (it == "noop") { listOf(++cycle to x) } else { val firstCycleValue = ++cy...
0
Kotlin
0
0
976d56bd723a7fc712074066949e03a770219b10
2,459
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2021/d04/Day04.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d04 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines typealias Board = MutableList<List<Int>> // if winningBoard = false, we want to find the board that wins last fun scoreBoard(nums: List<Int>, boar...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,421
advent-of-code
MIT License
y2019/src/main/kotlin/adventofcode/y2019/Day15.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2019 import adventofcode.io.AdventSolution import adventofcode.language.intcode.IntCodeProgram import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 import adventofcode.util.vector.neighbors import java.util.* fun main() = Day15.solve() object Day15 : AdventSolution(201...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,270
advent-of-code
MIT License
src/Day12.kt
HaydenMeloche
572,788,925
false
{"Kotlin": 25699}
fun main() { val lines = readInput("Day12") val graph = Graph(lines.mapIndexed { y, line -> line.mapIndexed { x, code -> Vertex(x, y, code) } }) println("answer one: ${graph.findShortestPath('S')}") println("answer two: ${graph.findShortestPath('a')}") } class Vertex(val x: Int, val y: Int, val code: ...
0
Kotlin
0
1
1a7e13cb525bb19cc9ff4eba40d03669dc301fb9
1,554
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
cjosan
573,106,026
false
{"Kotlin": 5721}
fun main() { fun Char.toPriority() = (if (isLowerCase()) this - 'a' else this - 'A' + 26) + 1 fun String.splitToSets() = Pair( this.substring(0, this.length / 2).toSet(), this.substring(this.length / 2).toSet() ) fun part1(input: List<String>): Int { return input.sumOf { rucksac...
0
Kotlin
0
0
a81f7fb9597361d45ff73ad2a705524cbc64008b
1,135
advent-of-code2022
Apache License 2.0
src/Day02.kt
dmdrummond
573,289,191
false
{"Kotlin": 9084}
fun main() { fun part1(input: List<String>): Int { fun calculateScore(input: String): Int { val choiceScore = when(input[2]) { 'X' -> 1 'Y' -> 2 'Z' -> 3 else -> throw Error("Unable to process $input") } val ...
0
Kotlin
0
0
2493256124c341e9d4a5e3edfb688584e32f95ec
1,536
AoC2022
Apache License 2.0
2021/src/Day13.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/13 fun main() { class Table(dots: List<Pair<Int, Int>>) { var dots = dots fun fold(direction: String, at: Int) { var newDots = mutableListOf<Pair<Int, Int>>() when (direction) { "x" -> { dots.forEach { if (it....
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
2,896
advent-of-code
Apache License 2.0
src/main/algorithms/sorting/QuickSort.kt
vamsitallapudi
119,534,182
false
{"Java": 24691, "Kotlin": 20452}
package main.algorithms.sorting fun main(args: Array<String>) { val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array quickSort(array, 0, array.size-1) for(i in array) println(i) } fun quickSort(array: IntArray, left: Int, right: Int) { val inde...
0
Java
1
1
9349fa7488fcabcb9c58ce5852d97996a9c4efd3
1,229
HackerEarth
Apache License 2.0
src/Day03.kt
euphonie
571,665,044
false
{"Kotlin": 23344}
fun main() { fun getCharValue(c: Char) : Int { return (if (c.isLowerCase()) c.code -'a'.code else c.code -'A'.code+26)+1 } fun countMatchingTypes(rucksack: String) : Int { val halfIndex = (rucksack.length/2) val firstCompartment = rucksack.substring(0, halfIndex) val secondC...
0
Kotlin
0
0
82e167e5a7e9f4b17f0fbdfd01854c071d3fd105
1,336
advent-of-code-kotlin
Apache License 2.0
solutions/aockt/y2015/Y2015D16.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import io.github.jadarma.aockt.core.Solution object Y2015D16 : Solution { private val propertyRegex = Regex("""([a-z]+): (\d+)""") private val sueIdRegex = Regex("""^Sue (\d+):.*$""") /** Parses a single line of input and returns what information you know about any [AuntSue]. */ ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,723
advent-of-code-kotlin-solutions
The Unlicense
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions51.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round0 import kotlin.math.* /** * 数组中的逆序对 */ fun test51() { val array = intArrayOf(7, 5, 6, 4) println("数组中的逆序对共有:${inversePairs1(array)}对") println("数组中的逆序对共有:${inversePairs2(array)}对") } //自顶向下的归并 fun inversePairs1(array: IntArray): Int { if (array.isEmpty()) return 0 val sub...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,677
Algorithm
Apache License 2.0
app/src/main/kotlin/day13/Day13.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day13 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 13 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay13Part1, ::solveDay13Part2) } data class Coord(val x: Int, val y: Int) data cl...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
2,334
AdventOfCode2021
Apache License 2.0
src/main/aoc2020/Day21.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 class Day21(input: List<String>) { private val products = input.map { line -> val ingredients = line.substringBefore(" (contains ").split(" ") val allergens = line.substringAfter("(contains ").dropLast(1).split(", ") ingredients to allergens } private fun examineIn...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,317
aoc
MIT License
src/Day20.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun normalise(size: Int, num: Long): Int { var number = num if (number >= size) { number %= size } while (number < 0) { number += size } return number.toInt() } fun calculateValues(numbers: List<Pair<Int, Long>>, zeroIdx: ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
2,867
advent-of-code-2022
Apache License 2.0
src/d08/Main.kt
cweckerl
572,838,803
false
{"Kotlin": 12921}
package d08 import java.io.File fun main() { fun part1(input: List<String>) { var trees = 0 val visited = mutableMapOf<Int, Char>() for (i in input.indices) { for (j in input[0].indices) { if (i == 0 || i == input.size - 1 || j == 0 || j == input[0].length - 1...
0
Kotlin
0
0
612badffbc42c3b4524f5d539c5cbbfe5abc15d3
2,087
aoc
Apache License 2.0
src/Day10.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
import kotlin.math.abs private sealed interface Command { object Noop : Command class Add(val value: Int) : Command } private fun parseCommand(input: String): Command = when (input.substringBefore(' ')) { "noop" -> Command.Noop "addx" -> Command.Add(input.substringAfter(' ').toInt()) else -> throw...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
1,826
aoc-2022
Apache License 2.0
src/Day08.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { fun part1(input: List<String>): Int { val trees = input.map { it.map { it.digitToInt() }.toIntArray() }.toTypedArray() val visible = Array(input.size) {BooleanArray(input.size)} for(i in 0 until input.size) { var max = -1 for (j in 0 .. input.size - 1) ...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
3,265
aoc-2022-in-kotlin
Apache License 2.0
src/Day13.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
import java.util.* fun main() { fun String.parse(): Item.Values { val stack = Stack<Item.Values>() var s = this val root = Item.Values(mutableListOf()) var current = root var num = "" while (s.isNotEmpty()) { when (s.first()) { '[' -> { ...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
2,167
AoC-2022
Apache License 2.0
src/main/aoc2018/Day24.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 import kotlin.math.min class Day24(input: List<String>) { data class Group(val team: String, val id: Int, val units: Int, val hp: Int, val attack: Int, val attackType: String, val initiative: Int, val weaknesses: Set<String>, val immunities: Set<String>) { var liveUni...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
6,148
aoc
MIT License
src/main/kotlin/aoc2023/Day14.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import print import readInput import to2dCharArray import kotlin.math.max private enum class Direction { NORTH, SOUTH, EAST, WEST } private class MirrorMap(private val input: List<String>) { private var currentMap = input.to2dCharArray() private val maxY = input.size private val maxX = cu...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
3,974
adventOfCode
Apache License 2.0
Advent-of-Code-2023/src/Day14.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day14" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY /** * Calculates the load caused by the rounded rocks in the platform. * The load is calculated by multiplying the number of rounded rocks in a column by the distance from the bottom. * Since ...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
3,435
Advent-of-Code-2023
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/MinimumWindowSubstring.kt
faniabdullah
382,893,751
false
null
//Given two strings s and t of lengths m and n respectively, return the minimum //window substring of s such that every character in t (including duplicates) is //included in the window. If there is no such substring, return the empty string //"". // // The testcases will be generated such that the answer is unique....
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
3,213
dsa-kotlin
MIT License
src/year2023/day12/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2023.day12 import arrow.core.nonEmptyListOf import utils.ProblemPart import utils.findAllWithOverlap import utils.readInputs import utils.runAlgorithm import utils.withMemoization fun main() { val (realInput, testInputs) = readInputs(2023, 12, transform = ::parse) runAlgorithm( realInput ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,989
Advent-of-Code
Apache License 2.0
src/main/kotlin/d19_BeaconScanner/BeaconScanner.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d19_BeaconScanner import util.Coord3d import util.Input import util.Output fun main() { val startTime = Output.startTime() Output.day(19, "Beacon Scanner") val scannerList = Input.parseLines(filename = "/input/d19_scanner_beacon_map.txt") .toScannerList() scannerList[0].hasShifted = ...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
7,688
advent-of-code-2021
MIT License
src/main/kotlin/EvaluateReversePolishNotation.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. * * Evaluate the expression. Return an integer that represents the value of the expression. * * Note that: * * The valid operators are '+', '-', '*', and '/'. * Each operand may be an integer or...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
2,113
kotlin-codes
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day08.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2022 import com.dvdmunckhof.aoc.toGrid class Day08(input: List<List<Int>>) { private val grid = input.map { row -> row.map(::Tree) }.toGrid() fun solvePart1(): Int { val visibleTrees = mutableSetOf<Tree>() for (row in grid.rows) { visibleTrees += ...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,881
advent-of-code
Apache License 2.0
src/main/kotlin/SortCharactersByFrequency.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given a string s, sort it in decreasing order based on the frequency of the characters. * The frequency of a character is the number of times it appears in the string. * * Return the sorted string. If there are multiple answers, return any of them. * * * * Example 1: * * Input: s = "tree" * Output: "ee...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
1,905
kotlin-codes
Apache License 2.0
src/Day12.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import java.util.* fun main() { val testInput = readInput("Day12_test") check(part1(testInput) == 31) check(part2(testInput) == 29) val input = readInput("Day12") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>, ): Int = solve(input, startMarkers = setOf('...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
2,415
AOC2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day16.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.splitInts import kotlin.math.max fun PuzzleSet.day16() = puzzle { val valves = inputLines.map { l -> val conns = l.substringAfter("valves ").substringAfter("valve ").split(", ") Valve(l.split(" ")...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,173
advent-of-code
The Unlicense
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day21/Day21.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day21 import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input21-test.txt" const val FILENAME = "input21.txt" val PATTERN_VARIABLE = Regex("[a-z]+") val PATTERN_OPERATION = Regex("\\((\\d+) ([+*/-]) (\\d+)\\)") val PATTERN_EQUATION_1 = Regex("\\((.*) ([+*/-]) (\\d+)\\) = (\\d...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
3,426
advent-of-code
Apache License 2.0
src/com/ajithkumar/aoc2022/Day08.kt
ajithkumar
574,372,025
false
{"Kotlin": 21950}
package com.ajithkumar.aoc2022 import com.ajithkumar.utils.* fun main() { fun inputTo2DArray(inputList: List<String>): Array<IntArray> { // Create a mutable list to hold the converted values val convertedValues = mutableListOf<IntArray>() // Loop through the input list for (input ...
0
Kotlin
0
0
f95b8d1c3c8a67576eb76058a1df5b78af47a29c
4,923
advent-of-code-kotlin-template
Apache License 2.0
leetcode/src/bytedance/Q53.kt
zhangweizhe
387,808,774
false
null
package bytedance fun main() { // 53. 最大子数组和 // https://leetcode.cn/problems/maximum-subarray/ println(maxSubArray1(intArrayOf(1))) } fun maxSubArray(nums: IntArray): Int { // 动态规划数组,dp[i] 表示以 nums[i] 结尾的子数组的和 val dp = IntArray(nums.size) dp[0] = nums[0] var max = dp[0] for (i in 1 unt...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,427
kotlin-study
MIT License
2015/src/main/kotlin/day19.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Graph import utils.Parse import utils.Parser import utils.Solution import utils.findAll import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicLong fun main() { Day19.run() } object Day19 : Solution<Day19.Input>() { override val name = "day19" override val parser ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
2,363
aoc_kotlin
MIT License
src/main/kotlin/Day20.kt
clechasseur
318,029,920
false
null
import org.clechasseur.adventofcode2020.Day20Data import org.clechasseur.adventofcode2020.Direction import org.clechasseur.adventofcode2020.Pt import org.clechasseur.adventofcode2020.move object Day20 { private val input = Day20Data.input private val idRegex = """^Tile (\d+):$""".toRegex() private val se...
0
Kotlin
0
0
6173c9da58e3118803ff6ec5b1f1fc1c134516cb
6,583
adventofcode2020
MIT License
src/Day04.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
import kotlin.math.max import kotlin.math.min fun main() { class Range(val begin: Int, val end: Int) { override operator fun equals(other: Any?): Boolean { if (other !is Range) { return false } return begin == other.begin && end == other.end } ...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
1,771
aoc-2022
Apache License 2.0
src/main/kotlin/day9.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.Point import shared.XYMap import shared.getLines fun findRiskLevelsSum(input: List<String>): Int{ val map = LavaTubes(input) return map.getLowPoints().sumOf { map.getValue(it) + 1 } } fun findLargestBasinsMultiplied(input: List<String>): Int{ val map = LavaTubes(input) val basinSizes = m...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
1,423
AdventOfCode2021
MIT License
src/main/kotlin/advent/day14/ExtendedPolymerization.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day14 import advent.loadInput import java.io.File /** * @author <NAME> */ typealias PairInsertionRules = Map<String, String> fun <K> MutableMap<K, Long>.putOrSumValue(key: K, count: Long) = compute(key) { _, currCount -> (currCount ?: 0) + count } fun <T, K> Grouping<T, K>.eachCountLong(): Map...
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
3,327
Advent-of-code-2021
MIT License
src/y2016/Day20.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.readInput enum class Indicator { START, STOP } object Day20 { private fun parse(input: List<String>): List<Pair<Long, Indicator>> { return input.flatMap { line -> val (start, stop) = line.split("-").map { it.toLong() } listOf(start to Indicator.START,...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,573
advent-of-code
Apache License 2.0
src/Day02/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day02 import readInput /** * Col 1 * A = Rock * B = Paper * C = Scissors * * Col 2 * X = Rock | Lose * Y = Paper | Draw * Z = Scissors | Win * * Lose = 0 pts * Draw = 3 pts * Win = 6 pts * Rock = 1 pts * Paper = 2 pts * Scissors = 3 pts */ enum class Hand(val value: Int) { RO...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
3,871
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistinctSubseq2.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,549
kotlab
Apache License 2.0
src/main/kotlin/co/csadev/advent2022/Day11.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 11 * Problem Description: http://adventofcode.com/2021/day/11 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsText class Day11(override val input: String = resourceAsText("22day11....
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,508
advent-of-kotlin
Apache License 2.0
src/Day04.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
fun main() { fun part1(input: List<String>): Int { var c = 0 input.forEach { val row = it.split(',') val input1 = row[0].split('-').map { s -> s.toInt() } val input2 = row[1].split('-').map { s -> s.toInt() } val r1 = input1[0]..input1[1] ...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
1,286
advent-of-code-2022
Apache License 2.0
src/Day04.kt
hoppjan
573,053,610
false
{"Kotlin": 9256}
fun main() { val testLines = readInput("Day04_test") val testResult1 = part1(testLines) println("test part 1: $testResult1") check(testResult1 == 2) val testResult2 = part2(testLines) println("test part 2: $testResult2") check(testResult2 == 4) val lines = readInput("Day04") pri...
0
Kotlin
0
0
f83564f50ced1658b811139498d7d64ae8a44f7e
1,173
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day2/Day2.kt
jksolbakken
317,995,724
false
null
package day2 import java.io.File fun main() { val input = File(object {}.javaClass.getResource("/day2/input.txt").toURI()).readLines() println("char count: ${matchingNrOfChars(input)}") println("char position: ${matchingPosition(input)}") } fun matchingNrOfChars(lines: List<String>) = prepare(lines) .map...
0
Kotlin
0
0
4c5e7a46c010c0155e930617a57cd6711f872edb
1,601
aoc_2020
MIT License
src/Day07.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
import kotlin.system.measureNanoTime fun main() { fun solve(input: List<String>, isPart1: Boolean): Long { val currentDirectoryTree = mutableListOf<String>() val directorySizes = hashMapOf<List<String>, Long>() input.forEach { val commandSplit = it.split(" ") val i...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
2,149
aoc-2022
Apache License 2.0
src/kotlin2023/Day03.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2023 import readInput fun main() { val lines = readInput("kotlin2023/Day03_test") println(sumNotPartNumbers(lines)) } fun sumNotPartNumbers(lines: List<String>): Int { return lines.mapIndexed { i, e -> extractNumbers(e).filter { isPartNumber(it, i, lines) }.sum()...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
2,185
advent-of-code-kotlin
Apache License 2.0
src/Day12.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
data class Spring( val data: String, val broken: List<Int> ) fun String.initSpring(factor: Int = 1): Spring { return this.split(" ").let { val data = it[0] val broken = it[1] Spring( data = (0..<factor).joinToString("?") { data }, broken = (0..<factor).joinTo...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
3,191
aoc-2023
Apache License 2.0
src/Day25.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
import kotlin.math.abs import kotlin.math.ln import kotlin.math.pow fun main() { val digits = mapOf( '2' to 2, '1' to 1, '0' to 0, '-' to -1, '=' to -2, ) fun snafuToInt(snafu: String) = snafu .reversed() .mapIndexed { i, c -> 5.0.pow(i.t...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
2,018
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/hopkins/aoc/day15/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day15 import java.io.File const val debug = true const val part = 2 val map: Map<Int, MutableList<Lens>> = (0 until 256).associateBy({ it }, { mutableListOf()}) /** Advent of Code 2023: Day 15 */ fun main() { // Read the file input val lines: List<String> = File("input/input15.tx...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
2,416
aoc2023
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day14.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 14 - Parabolic Reflector Dish * Problem Description: http://adventofcode.com/2023/day/14 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day14/ */ package com.ginsberg.advent2023 class Day14(input: List<String>) { ...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
2,786
advent-2023-kotlin
Apache License 2.0
src/main/kotlin/days/y2019/Day03/Day03.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2019 import days.Day import kotlin.math.abs public class Day03 : Day(2019, 3) { override fun partOne(input: String): Any { val (wireA, wireB) = input.split("\n").map { it.parseWire() } val pointsA = wireA.points() val pointsB = wireB.points() return pointsA.intersect...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
2,484
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/MinimumWindowSubstring.kt
Codextor
453,514,033
false
{"Kotlin": 26975}
/** * Given two strings s and t of lengths m and n respectively, return the minimum window * substring * of s such that every character in t (including duplicates) is included in the window. * If there is no such substring, return the empty string "". * * The testcases will be generated such that the answer is un...
0
Kotlin
1
0
68b75a7ef8338c805824dfc24d666ac204c5931f
2,619
kotlin-codes
Apache License 2.0
src/Day02.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
import java.util.* fun main() { val conclusionMap = mapOf( "A X" to 3, "A Y" to 6, "A Z" to 0, "B X" to 0, "B Y" to 3, "B Z" to 6, "C X" to 6, "C Y" to 0, "C Z" to 3 ) val winLoseDrawMap = mapOf( "A X" to "A Z", "A Y" ...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
1,499
aoc-kotlin
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-12.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputText fun main() { val input = readInputText(2015, "12-input") val test1 = readInputText(2015, "12-test1") val test2 = readInputText(2015, "12-test2") print...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,003
advent-of-code
MIT License
jvm/src/main/kotlin/io/prfxn/aoc2021/day20.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Trench Map (https://adventofcode.com/2021/day/20) package io.prfxn.aoc2021 fun main() { val lines = textResourceReader("input/20.txt").readLines() val ieAlgo = lines.take(1).first() val litMap = lines.drop(2).flatMapIndexed { r, line -> line.mapIndexed { c, char -> ...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
2,365
aoc2021
MIT License
src/pl/shockah/aoc/y2015/Day15.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2015 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.aoc.parse6 import java.util.regex.Pattern import kotlin.math.max class Day15: AdventTask<List<Day15.Ingredient>, Int, Int>(2015, 15) { private val inputPattern: Pa...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
3,061
Advent-of-Code
Apache License 2.0
src/Day07_alt2.kt
zodiia
573,067,225
false
{"Kotlin": 11268}
package day07alt2 import readInput fun main() { fun parseFiles(input: List<String>): List<Long> { val dirs = HashMap<String, Long>().also { it["/"] = 0L } var cwd = "/" input.forEach { line -> if (line.startsWith("$ cd ")) { cwd = when (line.substring(5)) { ...
0
Kotlin
0
1
4f978c50bb7603adb9ff8a2f0280f8fdbc652bf2
1,454
aoc-2022
Apache License 2.0
src/main/kotlin/day9.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
fun day9 (lines: List<String>) { val valueHistories = parseOasisInput(lines) var sum = 0L var sum2 = 0L valueHistories.forEach { sum += findExtrapolatedValue(it) sum2 += findBackwardsExtrapolatedValue(it) } println("Day 9 part 1: $sum") println("Day 9 part...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
1,655
advent_of_code_2023
MIT License
src/Day01.kt
martintomac
726,272,603
false
{"Kotlin": 19489}
fun main() { val valueToWords = mapOf( 1 to listOf("1", "one"), 2 to listOf("2", "two"), 3 to listOf("3", "three"), 4 to listOf("4", "four"), 5 to listOf("5", "five"), 6 to listOf("6", "six"), 7 to listOf("7", "seven"), 8 to listOf("8", "eight"), ...
0
Kotlin
0
0
dc97b23f8461ceb9eb5a53d33986fb1e26469964
1,148
advent-of-code-2023
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2018/Day07.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2018 import se.saidaspen.aoc.util.* fun main() { Day07.run() } object Day07 : Day(2018, 7) { override fun part1(): Any { val dependencies = input.lines().filter { it.isNotBlank() }.map { P(it.split(" ")[1], it.split(" ")[7]) }.toList() val map = dependencies.map {...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,166
adventofkotlin
MIT License
src/main/kotlin/dp/MaxWeightUnrootedTree.kt
yx-z
106,589,674
false
null
package dp import graph.core.* import util.max // given an unrooted tree T, that is, connected acyclic undirected graphs, // 1. let the edges in T be weighed (either > 0, 0, or < 0) // find a path with largest weight fun WeightedGraph<Int, Int>.maxWeight() = vertices.map { maxWeight(it, init()) }.max() ?: 0 fu...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,985
AlgoKt
MIT License
src/main/kotlin/com/ginsberg/advent2020/Day11.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 11 - Seating System * Problem Description: http://adventofcode.com/2020/day/11 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day11/ */ package com.ginsberg.advent2020 typealias Seats = Array<CharArray> typealias Sea...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
2,660
advent-2020-kotlin
Apache License 2.0
src/Day12.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
import java.util.* private class Graph constructor( private val width: Int, private val height: Int, private val startPos: Position, private val endPos: Position, private val heightArray: Array<IntArray> ) : Iterable<Int> { private val edges = hashMapOf<Int, MutableSet<Int>>() init { ...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
4,335
aoc-2022
Apache License 2.0
src/main/kotlin/day3/Day3.kt
Jessevanbekkum
112,612,571
false
null
package day3 import java.lang.Math.abs import java.lang.Math.sqrt fun ringSize(ring: Int): Int { if (ring == 0) { return 1; } return ((ring - 1) * 2 + 1) * 4 + 4 } fun middles(ring: Int): List<Int> { var diff = 2 * ring; val first = squareSize(ring - 1) + ring return listOf(first, ...
0
Kotlin
0
0
1340efd354c61cd070c621cdf1eadecfc23a7cc5
2,430
aoc-2017
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day16/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day16 import com.kingsleyadio.adventofcode.util.readInput fun main() { readInput(2021, 16).forEachLine { line -> val input = line.map { it.digitToInt(16).toString(2).padStart(4, '0') }.joinToString("") val packet = parse(input) println(packet.ver...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
3,212
adventofcode
Apache License 2.0
day-17/src/main/kotlin/TrickShot.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,256
aoc-2021
MIT License
Advent-of-Code-2023/src/Day15.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day15" private const val TEST_FILE = "${AOC_DAY}_test" private const val INPUT_FILE = AOC_DAY /** * Hash function. */ private fun hash(message: String): Int { return message.fold(0) { acc, c -> ((acc + c.code) * 17) % 256 } } /** * Calculates the hash of each step and sums them up....
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
2,218
Advent-of-Code-2023
Apache License 2.0
src/Day02.kt
vladislav-og
573,326,483
false
{"Kotlin": 27072}
fun main() { // key value match from left to right: lose, draw, win val winMapping = mapOf( Pair("A", "ZXY"), // rock -> scissors, rock, paper Pair("B", "XYZ"), // paper -> scissors Pair("C", "YZX"), // scissors -> rock ) val myMoveScoreMapping = mapOf( Pair("X", 1), Pair("Y", 2), Pair("Z", 3), ...
0
Kotlin
0
0
b230ebcb5705786af4c7867ef5f09ab2262297b6
1,434
advent-of-code-2022
Apache License 2.0
src/Day11.kt
msernheim
573,937,826
false
{"Kotlin": 32820}
import kotlin.math.floor fun main() { fun getOperation(operation: String): (ULong) -> ULong { val parts = operation.split(" ") if (parts.size == 3) { if (parts[2] == "old") { return when (parts[1]) { "*" -> { x: ULong -> x * x } "...
0
Kotlin
0
3
54cfa08a65cc039a45a51696e11b22e94293cc5b
5,200
AoC2022
Apache License 2.0
src/Day11.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
import java.math.BigInteger import kotlin.math.floor fun main() { fun createMonkeys(input: List<String>): List<monkeys> { val reponse = mutableListOf<monkeys>() var index = 0 while (index < input.size) { val listsDescription = mutableListOf<String>() for (i in 0..5...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
5,033
AD2022-01
Apache License 2.0
src/year_2023/day_01/Day01.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2023.day_01 import readInput object Day01 { /** * Calculate the sum of all the calibration values */ fun solutionOne(calibrationValues: List<String>): Int { val values = calibrationValues.map { calibration -> var first = '0' var last = '0' fo...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
1,732
advent_of_code
Apache License 2.0
src/main/kotlin/days/Day12.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days import kotlin.collections.ArrayDeque class Day12 : Day(12) { override fun partOne(): Any { val input = parseInput() val height = input.height val (s, e) = input.start to input.end return findClosestPath(s, e, height) ?: throw IllegalStateException("Couldn't find a wa...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
2,893
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day03.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { getDuplicateSum(it) } } fun part2(input: List<String>): Int { return input.chunked(3).sumOf { findBadgePriority(it) } } val testInput = readInput("Day03_test") check(part1(testInput) == 157) check(part2...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
1,318
advent-of-code-2022-kotlin
Apache License 2.0
src/year2022/day10/Solution.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package year2022.day10 import io.kotest.matchers.shouldBe import utils.plusOrMinus import utils.readInput fun main() { val testInput = readInput("10", "test_input") val realInput = readInput("10", "input") val cycleEnds = 20..220 step 40 val testRuntime = testInput.asSequence() .map(::toInstr...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
2,427
Advent-of-Code
Apache License 2.0
app/src/y2021/day08/Day08SevenSegmentSearch.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day08 import common.Answers import common.AocSolution import common.annotations.AoCPuzzle fun main(args: Array<String>) { Day08SevenSegmentSearch().solveThem() Day08WithoutAnalyzingIndividualSegments().solveThem() } @AoCPuzzle(2021, 8) class Day08SevenSegmentSearch : AocSolution { override ...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
7,054
advent-of-code-2021
Apache License 2.0
src/main/java/com/ncorti/aoc2021/Exercise12.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 import java.util.Stack object Exercise12 { private fun getInput(): HashMap<String, MutableList<String>> { val input = getInputAsTest("12") { split("\n") }.map { line -> line.split("-").let { it[0] to it[1] } } val world = ...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
2,562
adventofcode-2021
MIT License
src/org/aoc2021/Day22.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path import kotlin.math.max import kotlin.math.min private fun IntRange.size(): Int { return if (this.last >= this.first) { this.last - this.first + 1 } else { 0 } } object Day22 { data class Cube(val x: IntRange, val...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
4,636
advent-of-code-2021
The Unlicense
src/year2022/day11/Solution.kt
LewsTherinTelescope
573,240,975
false
{"Kotlin": 33565}
package year2022.day11 import utils.bigint import utils.extractTrailingInt import utils.isDivisibleBy import utils.productOf import utils.removeEach import utils.runIt import utils.splitOnBlankLines import utils.toLinkedList import utils.toLongList import java.math.BigInteger fun main() = runIt( testInput = """ Mo...
0
Kotlin
0
0
ee18157a24765cb129f9fe3f2644994f61bb1365
3,261
advent-of-code-kotlin
Do What The F*ck You Want To Public License
kotlin/1675-minimize-deviation-in-array.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
//another solution using a max Heap and a min Heap. class Solution { fun minimumDeviation(nums: IntArray): Int { val minHeap = PriorityQueue<Int>() var maxHeap = PriorityQueue<Int>(Collections.reverseOrder()) var res = Integer.MAX_VALUE // O(N) // For each number, we are ad...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,184
leetcode
MIT License
src/main/kotlin/year2023/Day05.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 class Day05 { data class RangeMap(val destStart: Long, val sourceStart: Long, val size: Long) { private val sourceRange = sourceStart..<sourceStart + size companion object { fun parse(input: String): RangeMap { val (destStart, sourceStart, size) = inp...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,348
aoc-2022
Apache License 2.0
src/adventofcode/blueschu/y2017/day12/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day12 import java.io.File import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day12.txt") .bufferedReader() .use { it.readLines() } } fun main(args: Array<String>) { val exampleNetwork = listOf( "0 <-> 2", ...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
2,846
Advent-Of-Code
MIT License
day14/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
fun main() { val input = "236021" val inputAsInt = input.toInt() val inputAsList = input .toList() .map { (it - 48).toInt() } println("Part I: the solution is ${solvePartI(inputAsInt)}.") println("Part II: the solution is ${solvePartII(inputAsList)}.") } fun solvePartI(numb...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
1,873
AdventOfCode2018
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day22.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 22 - Sand Slabs * Problem Description: http://adventofcode.com/2023/day/22 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day22/ */ package com.ginsberg.advent2023 import com.ginsberg.advent2023.Day22.Brick.Companion...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
3,508
advent-2023-kotlin
Apache License 2.0
src/day21/Day21.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day21 import readInput import java.lang.IllegalStateException enum class Operator(val repr: Char) { ADD('+'), SUB('-'), MULT('*'), DIV('/'); fun apply(fst: Long, snd: Long): Long = when (this) { ADD -> fst + snd SUB -> fst - snd MULT -> fst * snd DIV -> fst...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
3,467
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day24.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getLines class Alu(private val monad: List<String>){ private val variables = mutableMapOf( Pair('w', 0), Pair('x', 0), Pair('y', 0), Pair('z', 0), ) fun checkModelNumber(modelNumber: String): Boolean{ variables.keys.forEach { variables[it] = 0 } ...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
3,615
AdventOfCode2021
MIT License