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/Day06.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
fun main() { fun findUnique(c: Char, queue: ArrayDeque<Char>, uniqueAmount: Int): Boolean { queue.add(c) if (queue.size >= uniqueAmount && queue.distinct().size == queue.size) { queue.clear() return false } if (queue.size >= uniqueAmount) queue.re...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
1,376
AdventOfCode2022
Apache License 2.0
src/main/kotlin/InputData.kt
cyprienroche
241,994,340
false
null
import java.util.Scanner class InputData(private val scanner: Scanner) { private val totalBooks: Int = scanner.nextInt() private val totalLibraries: Int = scanner.nextInt() val totalDaysGiven: Day = Day(scanner.nextInt()) private val scores: List<Int> = List(totalBooks) { scanner.nextInt() } val li...
0
Kotlin
0
0
519661283e7ff8509ff5895a89fbbd0ec6df3e1f
1,754
GoogleHashCode20
MIT License
04/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File private const val SIZE = 5 fun readInput() : Pair<List<Int>, List<Board>> { val lines = File("input.txt") .readLines() .map { it.split("\n") } .filter{ it[0] != "" } val numbers = lines[0][0].split(",").map{ it.toInt() } val boards = mutableListOf<B...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,611
advent-of-code-2021
MIT License
src/Day08.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
import kotlin.math.min fun main() { fun part1(input: List<List<Char>>): Int { var visible = 99 + 99 + 97 + 97 (1..97).forEach { y -> (1..97).forEach { x -> val cell = input[y][x] val visibleFromLeft = cell > input[y].take(x).max() val visi...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
1,866
aoc2022-kotlin
Apache License 2.0
src/Day05.kt
wgolyakov
572,463,468
false
null
fun main() { fun parse(input: List<String>): Pair<List<MutableList<Char>>, List<Triple<Int, Int, Int>>> { val sep = input.indexOf("") val n = input[sep - 1].substringAfterLast(' ').toInt() val stacks = List(n) { mutableListOf<Char>() } for (s in input.subList(0, sep).reversed()) { for (i in 0 until n) { ...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
1,501
advent-of-code-2022
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day04.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day04 : AdventSolution(2021, 4, "Giant Squid") { override fun solvePartOne(input: String): Int { val (drawnNumbers, cards) = parseInput(input) return drawnNumbers.firstNotNullOf { n -> cards.forEach { it.cross...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
2,091
advent-of-code
MIT License
src/Day04.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import kotlin.streams.toList fun main() { fun hasTotalOverlap(a: List<Int>, b: List<Int>): Boolean { return a[0] >= b[0] && a[1] <= b[1] } fun hasOverlap(a: List<Int>, b: List<Int>): Boolean { return a[0] in b[0]..b[1] || a[1] in b[0]..b[1] || b[0] in a[0]..a...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
1,584
advent-of-code-2022
Apache License 2.0
src/day3/Day03.kt
AhmedAshour
574,898,033
false
{"Kotlin": 4639}
package day3 import readInput fun main() { val input = readInput("src/day3", "input").toString() val formattedInput = input.trim { it == '[' || it == ']' }.split(",").map { it.trim() } println(partOne(formattedInput)) println(partTwo(formattedInput)) } fun partOne(input: List<String>): Int { var...
0
Kotlin
0
0
59b9e895649858de0b95fa2e6eef779bc0d8b45c
1,409
adventofcode-2022
Apache License 2.0
src/main/kotlin/solutions/Day7NoSpaceLeftOnDevice.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Input import utils.Solution import utils.popWhile import java.util.* // run only this day fun main() { Day7NoSpaceLeftOnDevice() } class Day7NoSpaceLeftOnDevice : Solution() { init { begin("Day 7 - No Space Left On Device") val input = Input.parseLines(filename...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
2,965
advent-of-code-2022
MIT License
src/Day11.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { class Monkey( val itemStack: MutableList<Int>, val operation: (Long) -> Long, val divisibilityTest: Int, val throwTargetTrue: Int, val throwTargetFalse: Int, ) { fun throwTargetOf(item: Int) = if (item % divisibilityTest == 0) throwTargetT...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
2,921
AdventOfCode2022
Apache License 2.0
src/main/kotlin/Day9.kt
amitdev
574,336,754
false
{"Kotlin": 21489}
import Direction.D import Direction.L import Direction.R import Direction.U import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.sign fun main() { val result = File("inputs/day_9.txt").useLines { tailPositions(it, 9) } println(result) } fun tailPositions(lines: Sequence<String>, ta...
0
Kotlin
0
0
b2cb4ecac94fdbf8f71547465b2d6543710adbb9
1,919
advent_2022
MIT License
src/year2023/11/Day11.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`11` import readInput import utils.printlnDebug import kotlin.math.abs private const val CURRENT_DAY = "11" private data class Point( val x: Long, val y: Long, ) private fun parseMap(input: List<String>): Set<Point> { val mutableMap = mutableSetOf<Point>() input.forEachIndexed { y,...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,767
KotlinAdventOfCode
Apache License 2.0
src/com/ajithkumar/aoc2022/Day09.kt
ajithkumar
574,372,025
false
{"Kotlin": 21950}
package com.ajithkumar.aoc2022 import com.ajithkumar.utils.* import kotlin.math.absoluteValue class Knot(var X: Int, var Y: Int) { fun moveAlone(direction: String) { when(direction) { "L" -> X-=1 "R" -> X+=1 "U" -> Y+=1 "D" -> Y-=1 } } fun m...
0
Kotlin
0
0
f95b8d1c3c8a67576eb76058a1df5b78af47a29c
2,774
advent-of-code-kotlin-template
Apache License 2.0
src/day5/main.kt
DonaldLika
434,183,449
false
{"Kotlin": 11805}
package day5 import readLines val NUMBER_EXTRACTOR = "\\d+".toRegex() fun main() { fun part1(segments: List<Segment>): Int { val filteredLines = segments.filter { it.from.x == it.to.x || it.from.y == it.to.y } return filteredLines.calculateIntersections() } fun part2(segments: List<Segm...
0
Kotlin
0
0
b288f16ee862c0a685a3f9e4db34d71b16c3e457
2,086
advent-of-code-2021
MIT License
src/Day09.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
data class Pos(val x: Int = 0, val y: Int = 0) { fun touches(other: Pos): Boolean { return kotlin.math.abs(this.x - other.x) < 2 && kotlin.math.abs(this.y - other.y) < 2 } } fun move(move: String, thing: Pos): List<Pos> { val (dir, cnt) = move.split(" ") return (0 until cnt.toI...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
2,733
aoc2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2020/Day21.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import com.chriswk.aoc.util.reportableString class Day21: AdventDay(2020, 21) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day21() report { ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,929
adventofcode
MIT License
src/main/kotlin/com/github/michaelbull/advent2021/day8/Entry.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day8 private val DIGITS = 0..9 private val SEGMENTS = 'a'..'g' private val REGEX = "([${SEGMENTS.first}-${SEGMENTS.last}]+)".toRegex() fun String.toEntry(): Entry { val results = requireNotNull(REGEX.findAll(this)) { "$this must match $REGEX" } val values...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
3,178
advent-2021
ISC License
src/Day04.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
fun main() { fun pairsList(input: List<String>): List<Pair<Pair<Int,Int>, Pair<Int,Int>>> { var pairs = mutableListOf<Pair<Pair<Int,Int>, Pair<Int,Int>>>() input.forEach { line -> line.splitTo(",") { a, b -> a.splitTo("-") { i, j -> b.splitTo("-") { k...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
1,968
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
rossilor95
573,177,479
false
{"Kotlin": 8837}
data class ProcedureStep(val cratesToMove: Int, val originStack: Int, val destinationStack: Int) { constructor(cratesToMove: String, originStack: String, destinationStack: String) : this( cratesToMove.toInt(), originStack.toInt() - 1, destinationStack.toInt() - 1 ) } fun main() { fun numberOfStacks...
0
Kotlin
0
0
0ed98d0ab5f44b2ccfc625ef091e736c5c748ff0
2,582
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day09/day9.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day09 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val report = parseOasisReport(inputFile.bufferedReader().readLines()) println("Sum of extrapolated values: ${report.readings.sumOf { predictNextValue(it) }}") p...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,910
advent-of-code
MIT License
day2/src/main/kotlin/Main.kt
joshuabrandes
726,066,005
false
{"Kotlin": 47373}
import java.io.File const val NUMBER_OF_RED = 12 const val NUMBER_OF_GREEN = 13 const val NUMBER_OF_BLUE = 14 fun main() { println("------ Advent of Code 2023 - Day 2 -----") val gamesFromInput = getPuzzleInput() .map { Game.fromString(it) } val possibleGames = gamesFromInput .filter { it...
0
Kotlin
0
1
de51fd9222f5438efe9a2c45e5edcb88fd9f2232
3,946
aoc-2023-kotlin
The Unlicense
src/main/kotlin/advent/of/code/day18/Solution.kt
brunorene
160,263,437
false
null
package advent.of.code.day18 import advent.of.code.day18.Acre.* import java.io.File data class Position(val x: Int, val y: Int) : Comparable<Position> { override fun compareTo(other: Position): Int { return compareBy<Position>({ it.y }, { it.x }).compare(this, other) } override fun toString(): St...
0
Kotlin
0
0
0cb6814b91038a1ab99c276a33bf248157a88939
3,523
advent_of_code_2018
The Unlicense
src/main/kotlin/g2701_2800/s2736_maximum_sum_queries/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2701_2800.s2736_maximum_sum_queries // #Hard #Array #Sorting #Binary_Search #Stack #Monotonic_Stack #Segment_Tree #Binary_Indexed_Tree // #2023_08_05_Time_1043_ms_(100.00%)_Space_126.2_MB_(9.09%) import java.util.TreeMap class Solution { private fun update(map: TreeMap<Int, Int>, num: Int, sum: Int) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,792
LeetCode-in-Kotlin
MIT License
src/day3/Day3.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day3 import readInput fun main() { val testInput = parse(readInput("day03/test")) val input = parse(readInput("day03/input")) println(solve1(testInput)) println(solve1(input)) println(solve2(testInput)) println(solve2(input)) } fun position(c: Char): Int { return if (c.isLowerC...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
1,214
aoc-2022
Apache License 2.0
archive/2022/Day14.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 24 private const val EXPECTED_2 = 93 private class Day14(isTest: Boolean) : Solver(isTest) { private val dirs = listOf(0 to 1, -1 to 1, 1 to 1) private fun parseField(): Pair<List<BooleanArray>, Int> { val field = (0..1000).map { BooleanArray(1000) { false } } va...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
2,270
advent-of-code-2022
Apache License 2.0
src/Day02.kt
josemarcilio
572,290,152
false
{"Kotlin": 5535}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (elf, me) = it.split(" ") mapOf( "A" to mapOf("X" to 4, "Y" to 8, "Z" to 3), "B" to mapOf("X" to 1, "Y" to 5, "Z" to 9), "C" to mapOf("X" to 7, "Y" to 2, "Z" t...
0
Kotlin
0
0
d628345afeb014adce189fddac53a1fcd98479fb
1,001
advent-of-code-2022
Apache License 2.0
src/day04/Day04.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day04 import readInput fun main() { fun part1(input: List<String>): Int { return input.map { it.toElfPair() }.count { it.doesEnvelop() } } fun part2(input: List<String>): Int { return input.map { it.toElfPair() }.count { it.doesOverlap() } } // test if implementation meet...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
1,372
advent-of-code-22
Apache License 2.0
src/Day21.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
fun main() { fun part1(input: List<String>): Long { val yellsMap: MutableMap<String, MonkeyYell> = readYellsMap(input) val calculation = MonkeyCalculation(yellsMap) return calculation.calculate("root") } fun part2(input: List<String>): Long { val yellsMap: MutableMap<String,...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
6,066
AdventOfCode2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch7/Problem71.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch7 import dev.bogwalk.util.maths.gcd import dev.bogwalk.util.maths.lcm /** * Problem 71: Ordered Fractions * * https://projecteuler.net/problem=71 * * Goal: By listing the set of reduced proper fractions for d <= N in ascending order of size, * find the numerator and denominator of the f...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
8,090
project-euler-kotlin
MIT License
src/aoc2022/day15/AoC15.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day15 import readLines import kotlin.math.abs import kotlin.math.max private data class P(val x: Int, val y: Int) { val tuningFrequency get() = x * 4000000L + y } private data class B(val p: P, val b: P) { val radius = p distance b override fun toString() = "(${p.x},${p.y})" fun rAtY(y: Int): In...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
1,817
aoc2022
Apache License 2.0
src/Day7.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>): Directory { var current = Directory("/") input.forEach { when { it.startsWith("$ cd /") -> {} it.startsWith("$ ls") -> {} it.startsWith("$ cd ..") -> { current = current.paren...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
2,382
advent-of-code-2022
Apache License 2.0
src/Day05.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day05 import patriker.utils.* import java.util.Deque fun main() { // test if implementation meets criteria from the description, like: /* val testInput = readInputText("Day05_test") val input = readInputText("Day05_input") println(solvePart1(input)) println(solvePart2(testInp...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
3,097
aoc2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Day12.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import java.util.PriorityQueue class Day12(input: List<String>) { private val grid = input.toGrid() private val start = grid.entries.find { it.value == 'S' }!!.key private val goal = grid.entries.find { it.value == 'E' }!!.key private enum class Direction { ...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
2,705
advent-2022
MIT License
src/Day03.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
fun main() { fun getEqualItems(rucksack: String): Char { val rucksackItems = rucksack.toList() val rucksackSize = rucksackItems.size val firstCompartment = rucksackItems.subList(0, (rucksackSize + 1) / 2) val secondCompartment = rucksackItems.subList((rucksackSize + 1) / 2, rucksack...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
1,255
aoc22
Apache License 2.0
src/main/kotlin/year2023/day-03.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2023 import lib.Grid2d import lib.Position import lib.aoc.Day import lib.aoc.Part import lib.math.Vector import lib.splitLines fun main() { Day(3, 2023, PartA3(), PartB3()).run() } open class PartA3 : Part() { data class Number(val position: Position, val value: Int, val neighbors: Set<Position>)...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
2,834
Advent-Of-Code-Kotlin
MIT License
src/main/kotlin/Day04.kt
rgawrys
572,698,359
false
{"Kotlin": 20855}
import utils.oneRangeFullyContainOther import utils.rangesOverlap import utils.readInput fun main() { fun part1(input: List<String>): Int = countPairsThatOneRangeFullyContainOther(input) fun part2(input: List<String>): Int = countPairsThatRangesOverlap(input) // test if implementation mee...
0
Kotlin
0
0
5102fab140d7194bc73701a6090702f2d46da5b4
2,070
advent-of-code-2022
Apache License 2.0
src/Day15.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
import kotlin.math.abs fun main() { val pairRegex = """x=(?<x>[\-0-9]+), y=(?<y>[\-0-9]+)""".toRegex() fun parseList(input: List<String>): List<Pair<Loc, Loc>> = input.map { pairRegex.findAll(it).toList().let { (first, second) -> val source = first.groups as MatchNamedGroup...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
4,186
aoc-2022-demo
Apache License 2.0
solutions/aockt/y2016/Y2016D01.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2016 import aockt.y2016.Y2016D01.Direction.* import io.github.jadarma.aockt.core.Solution import kotlin.math.absoluteValue object Y2016D01 : Solution { /** Parses the input and returns the sequence of turn and direction pairs. */ private fun parseInput(input: String): Sequence<Pair<Boolean, In...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,745
advent-of-code-kotlin-solutions
The Unlicense
src/Day18.kt
wgolyakov
572,463,468
false
null
fun main() { fun parse(input: List<String>) = input.map { it.split(',').map(String::toInt) }.toSet() val surfaces = listOf( listOf(1, 0, 0), listOf(-1, 0, 0), listOf(0, 1, 0), listOf(0, -1, 0), listOf(0, 0, 1), listOf(0, 0, -1), ) fun part1(input: List<String>): Int { val cubes = parse(input) var ...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
1,853
advent-of-code-2022
Apache License 2.0
src/Day05.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
fun main() { data class Rearrangement(val amount: Int, val from: Int, val to: Int) fun parseRearrangement(line: String): Rearrangement { val regex = """\D+(\d+)\D+(\d+)\D+(\d+)""".toRegex() val (amount, from, to) = regex.find(line)?.destructured ?: error("could not parse $line") return ...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
3,171
advent-of-code-2022
Apache License 2.0
src/Day03.kt
bin-wang
573,219,628
false
{"Kotlin": 4145}
fun main() { fun countTrees(input: List<String>, xSlope: Int, ySlope: Int): Int { val h = input.size val w = input.first().length val posSequence = generateSequence(Pair(0, 0)) { if (it.second + ySlope < h) Pair( it.first + xSlope, it.second + ySlo...
0
Kotlin
0
0
929f812efb37d5aea34e741510481ca3fab0c3da
1,033
aoc20-kt
Apache License 2.0
src/Day11.kt
coolcut69
572,865,721
false
{"Kotlin": 36853}
import java.math.BigInteger fun main() { fun extracted(inputs: List<String>, boredFactor: Int = 3): List<Monkey> { val monkeys: MutableList<Monkey> = ArrayList() for (i in 0..inputs.size / 7) { val monkeyId = i * 7 val numbers: List<String> = inputs[monkeyId + 1].substringA...
0
Kotlin
0
0
031301607c2e1c21a6d4658b1e96685c4135fd44
4,455
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
data class Section(private val lower: Int, private val upper: Int) { init { if (lower > upper) { error("Wrong input: $lower > $upper") } } fun fullyContains(other: Section): Boolean { return this.lower >= other.lower && this.upper <= other.upper } fun overla...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
1,465
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/co/csadev/advent2020/Day13.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/* * Copyright (c) 2021 by <NAME> */ package co.csadev.advent2020 class Day13(input: List<String>) { private val start = input.first().toInt() private val shuttles = input.last().split(",").mapNotNull { i -> i.toIntOrNull() } private val shuttleMinutes = input.last().split(",") .mapIndexedNotNul...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,173
advent-of-kotlin
Apache License 2.0
src/Day05.kt
ricardorlg-yml
573,098,872
false
{"Kotlin": 38331}
data class CrateStack(var data: String) { fun remove(howMany: Int): String { return data.takeLast(howMany) .also { data = data.dropLast(howMany) } } fun add(data: String, crateMover9001: Boolean = false) { if (crateMover9001) { this.data +...
0
Kotlin
0
0
d7cd903485f41fe8c7023c015e4e606af9e10315
2,249
advent_code_2022
Apache License 2.0
src/Day16.kt
MatthiasDruwe
571,730,990
false
{"Kotlin": 47864}
import kotlin.math.ceil fun main() { data class Valve(val name: String, val pressure: Int, var pipesTo: List<String>, var open: Boolean = false) fun parseInpunt(input: List<String>) = input.map { val line = it.split(";") val name = line[0].split(" ")[1] val pressure = line[0].split("...
0
Kotlin
0
0
f35f01cea5075cfe7b4a1ead9b6480ffa57b4989
6,135
Advent-of-code-2022
Apache License 2.0
src/y2023/Day23.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.Cardinal import util.Pos import util.neighborsManhattan import util.readInput import util.timingStatistics object Day23 { data class Tile( val pos: Pos, val slope: Cardinal? ) { fun neighbors(tiles: Map<Pos, Tile>, visited: Set<Pos>): List<Pair<Int, Int>> { ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
5,077
advent-of-code
Apache License 2.0
src/day20/day20.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day20 import readInput private fun parseInput(input: List<String>, multiplier: Long = 1L): List<Pair<Int, Long>> = input.mapIndexed { index, value -> Pair(index, multiplier * value.toLong()) } private fun decrypt(data: List<Pair<Int, Long>>): List<Pair<Int, Long>> { val result = data.toMutableList() ...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
1,323
aoc-2022
Apache License 2.0
src/day3/Day03.kt
behnawwm
572,034,416
false
{"Kotlin": 11987}
package day3 import readInput fun main() { // val fileLines = readInput("day04.txt-test", "day3") val fileLines = readInput("day04.txt", "day3") fun part1(fileLines: List<String>): Int { var sum = 0 fileLines.forEach { text -> val text1 = text.substring(0, text.length / 2) ...
0
Kotlin
0
2
9d1fee54837cfae38c965cc1a5b267d7d15f4b3a
1,574
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/tasso/adventofcode/_2021/day10/Day10.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day10 import dev.tasso.adventofcode.Solution import java.math.BigInteger import java.util.* class Day10 : Solution<BigInteger> { override fun part1(input: List<String>): BigInteger { val parsedInput = input.map { line -> line.toCharArray() } val syntaxErrorSco...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
2,525
advent-of-code
MIT License
src/main/kotlin/day14.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day14 : Solvable("14") { override fun solveA(input: List<String>): String { return solve(input, 10) } override fun solveB(input: List<String>): String { return solve(input, 40) } private fun solve(input: List<String>, iterations: Int): String { val template = input.f...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
2,037
AdventOfCode
Creative Commons Zero v1.0 Universal
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day13/Day13.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2021.day13 import nl.sanderp.aoc.common.* fun main() { val (points, folds) = parse(readResource("Day13.txt")) val (answer1, duration1) = measureDuration<Int> { partOne(points, folds) } println("Part one: $answer1 (took ${duration1.prettyPrint()})") println("Part two:") ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,735
advent-of-code
MIT License
src/Day24.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
object Day24 { private enum class Direction { UP, DOWN, LEFT, RIGHT; companion object { fun parse(char: Char): Direction = when (char) { '^' -> UP 'v' -> DOWN '<' -> LEFT '>' -> RIGHT else -> error("Unexpe...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
3,910
aoc2022
Apache License 2.0
src/Day05.kt
antonarhipov
574,851,183
false
{"Kotlin": 6403}
fun main() { val input = readInput("Day05") val split = input.indexOfFirst { it.isBlank() } val stackLines = input.take(split - 1) val moves = input.drop(split + 1) println("Stacks:") stackLines.forEach { println(it) } println("-----------") println("Moves:") moves.forEach { printl...
0
Kotlin
0
0
8dd56fdbe67d0af74fbe65ff204275338785cd4a
1,987
aoc2022
Apache License 2.0
src/Day04.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
fun main() { fun part1(input: List<String>): Int { val pairs = input.map { line -> line.splitAssignmentPair() } return pairs.count { (part1, part2) -> val sectionList1 = part1.getNumbersInRange() val sectionList2 = part2.getNumbersInRange() sectionList1.contains...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
1,157
Advent-Of-Code-2022
Apache License 2.0
src/Day03.kt
punx120
573,421,386
false
{"Kotlin": 30825}
fun main() { fun priority(c : Char): Int { return if (c.code >= 'a'.code) { c.code - 'a'.code + 1 } else { 26 + c.code - 'A'.code + 1 } } fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val first = mutableS...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
1,791
aoc-2022
Apache License 2.0
src/Day24.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
import java.math.BigInteger import java.math.BigInteger.ONE import java.math.BigInteger.ZERO import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min import kotlin.math.sign private const val EXPECTED_1 = 2L private const val EXPECTED_2 = 47L fun List<Pair<BigInteger, BigInteger>>.chineseRemaind...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
7,764
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day24.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
fun main() { fun simulate(original: List<String>, width: Int, height: Int, points: Set<Point>, end: Point, time: Int): Int = if (points.contains(end)) time else { val next = points.flatMap { it.neighbours() }.filter { it.valid(original, width, height, time + 1) }.toSet() simulate(or...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
2,020
KotlinAdventOfCode2022
Apache License 2.0
app/src/main/kotlin/codes/jakob/aoc/solution/Day06.kt
loehnertz
725,944,961
false
{"Kotlin": 59236}
package codes.jakob.aoc.solution import codes.jakob.aoc.shared.middle import codes.jakob.aoc.shared.multiply import codes.jakob.aoc.shared.splitByLines object Day06 : Solution() { override fun solvePart1(input: String): Any { /** * Parses the race records from the [input] string. * The [...
0
Kotlin
0
0
6f2bd7bdfc9719fda6432dd172bc53dce049730a
3,711
advent-of-code-2023
MIT License
src/main/kotlin/g1901_2000/s1906_minimum_absolute_difference_queries/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1906_minimum_absolute_difference_queries // #Medium #Array #Hash_Table #2023_06_19_Time_1069_ms_(50.00%)_Space_98.7_MB_(100.00%) import java.util.BitSet class Solution { private class SegmentTree(nums: IntArray, len: Int) { class Node { var bits: BitSet? = null ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,486
LeetCode-in-Kotlin
MIT License
src/main/kotlin/year2022/Day02.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils import AoCUtils.test import Type.* enum class Type(val score: Long) { ROCK(1L), PAPER(2L), SCISSOR(3L) } fun main() { val lost = 0L val draw = 3L val win = 6L fun isRock(a: String) = a == "A" || a == "X" fun isPaper(a: String) = a == "B" || a == "Y" fun win(a: String) = a == "...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
2,615
aoc-2022-kotlin
Apache License 2.0
src/Day07.kt
sebastian-heeschen
572,932,813
false
{"Kotlin": 17461}
fun main() { fun filetree(input: List<String>): Directory { var directories = mutableListOf<Directory>() directories.add(Directory("/")) input.forEach { line -> when { line == "$ ls" -> Unit line.startsWith("dir") -> Unit line == "...
0
Kotlin
0
0
4432581c8d9c27852ac217921896d19781f98947
2,138
advent-of-code-2022
Apache License 2.0
src/Day13/Solution.kt
cweinberger
572,873,688
false
{"Kotlin": 42814}
package Day13 import readInput import toInt import java.util.Scanner object Solution { fun getNextBrackets(line: String) : IntRange { var start = -1 var end = -1 for (idx in line.indices) { if (line[idx] == '[') { start = idx break }...
0
Kotlin
0
0
883785d661d4886d8c9e43b7706e6a70935fb4f1
2,901
aoc-2022
Apache License 2.0
src/Day03.kt
mkfsn
573,042,358
false
{"Kotlin": 29625}
fun main() { fun findCommonItem(vararg blocks: String): Char { return blocks.fold(mutableMapOf<Char, Int>()) { acc, block -> for (item in block.toCharArray().distinct()) { acc[item] = (acc[item] ?: 0) + 1 } acc }.filterValues { it == blocks.size }....
0
Kotlin
0
1
8c7bdd66f8550a82030127aa36c2a6a4262592cd
1,217
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
WaatzeG
573,594,703
false
{"Kotlin": 7476}
fun main() { val testInput = readInput("Day04_input") val solutionPart1 = part1(testInput) println("Solution part 1: $solutionPart1") val solutionPart2 = part2(testInput) println("Solution part 2: $solutionPart2") } /** * Count of fully overlapping schedules */ private fun part1(input: List<Str...
0
Kotlin
0
0
324a98c51580b86121b6962651f1ba9eaad8f468
1,073
advent_of_code_2022_kotlin
Apache License 2.0
src/main/kotlin/strategies.kt
rileynull
448,412,739
false
null
// Tuning parameters which control how heavily we value green matches vs yellow matches. const val EXACT_MATCH_POINTS = 28 const val ANAGRAM_MATCH_POINTS = 10 /** * Find a guess with letters that occur frequently in the same positions as in a lot of the remaining solutions. */ fun frequencyStrategy(last: String? = n...
0
Kotlin
0
0
9e92a16e9ad517b5afda7c70899bd0c67fd0e0a0
7,851
wordle-kot
Apache License 2.0
day7/src/main/kotlin/com/lillicoder/adventofcode2023/day7/Day7.kt
lillicoder
731,776,788
false
{"Kotlin": 98872}
package com.lillicoder.adventofcode2023.day7 fun main() { val day7 = Day7() val parser = HandParser() val (hands, jokerHands) = parser.parseFile("input.txt") println("[Normal] Total winnings for the given hands is ${day7.part1(hands)}.") println("[Jokers] Total winnings for the given hands is ${day...
0
Kotlin
0
0
390f804a3da7e9d2e5747ef29299a6ad42c8d877
9,655
advent-of-code-2023
Apache License 2.0
src/main/kotlin/com/ab/advent/day02/Models.kt
battagliandrea
574,137,910
false
{"Kotlin": 27923}
package com.ab.advent.day02 import java.lang.IllegalArgumentException // A. ROCK // B. PAPER // C. SCISSORS // X. ROCK // Y. PAPER // Z. SCISSORS // 1. Mappare l'input in un torneo che è una lista di round di shape // 2. Dare un punteggio a quella determinata HandShape // 3. Decretare il mio punteggio calcolandol...
0
Kotlin
0
0
cb66735eea19a5f37dcd4a31ae64f5b450975005
2,755
Advent-of-Kotlin
Apache License 2.0
src/Day02/Day02.kt
Trisiss
573,815,785
false
{"Kotlin": 16486}
fun main() { operator fun String.component1() = this[0] operator fun String.component2() = this[1] operator fun String.component3() = this[2] fun Char.toShape(): Shape = when (this) { 'A', 'X' -> Shape.Rock() 'B', 'Y' -> Shape.Paper() 'C', 'Z' -> Shape.Scissors() else -...
0
Kotlin
0
0
cb81a0b8d3aa81a3f47b62962812f25ba34b57db
2,960
AOC-2022
Apache License 2.0
src/Day03.kt
mcrispim
573,449,109
false
{"Kotlin": 46488}
fun main() { fun priority(item: Char): Int { return when (item) { in 'a'..'z' -> item - 'a' + 1 in 'A'..'Z' -> item - 'A' + 27 else -> 0 } } fun part1(input: List<String>): Int = input.sumOf { val partSize = it.length / 2 val compartment1...
0
Kotlin
0
0
5fcacc6316e1576a172a46ba5fc9f70bcb41f532
1,227
AoC2022
Apache License 2.0
src/day13/Day13.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day13 import readInput fun readToPacket(chars: String): BasePacket { if (chars.isEmpty()) { return PacketList(mutableListOf()) } if (chars.toIntOrNull() != null) { return Packet(chars.toInt()) } return PacketList(readNestedList(chars)) } fun readNestedList(chars: String)...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
3,670
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
winnerwinter
573,917,144
false
{"Kotlin": 20685}
fun main() { fun String.toElfPair(): Pair<IntRange, IntRange> { val (elfA, elfB) = this.split(",").map { sections -> val (low, high) = sections.split("-") low.toInt()..high.toInt() } return elfA to elfB } fun isOverlap(elfA: IntRange, elfB: IntRange): Boolea...
0
Kotlin
0
0
a019e5006998224748bcafc1c07011cc1f02aa50
1,517
advent-of-code-22
Apache License 2.0
src/Day11.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
private interface Item { infix fun divisibleBy(divisor: Int): Boolean } private interface ItemCompanion { fun createItem(s: String): Item fun add(one: Item, two: Item): Item fun multiply(one: Item, two: Item): Item } private class Monkey( val items: MutableList<Item>, val divisor: Int, val...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
4,852
aoc-2022
Apache License 2.0
src/Day08.kt
mihansweatpants
573,733,975
false
{"Kotlin": 31704}
fun main() { fun part1(grid: List<List<Int>>): Int { var visibleTreesCount = 0 for (rowIndex in grid.indices) { for (columnIndex in grid[rowIndex].indices) { if (isExteriorCell(rowIndex, columnIndex, grid)) { visibleTreesCount++ } else...
0
Kotlin
0
0
0de332053f6c8f44e94f857ba7fe2d7c5d0aae91
3,516
aoc-2022
Apache License 2.0
src/Day11.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
import java.math.BigInteger fun main() { fun parseInput(input: String): Pair<List<List<BigInteger>>, List<Inspection>> { val monkeyInputs = input.split("\n\n") val items = monkeyInputs.map { it -> val lines = it.lines().map { it.trim() } return@map lines[1].substringAfter("...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
4,156
advent-of-code-2022
Apache License 2.0
cz.wrent.advent/Day8.kt
Wrent
572,992,605
false
{"Kotlin": 206165}
package cz.wrent.advent fun main() { println(partOne(test)) val result = partOne(input) println("8a: $result") println(partTwo(test)) val resultTwo = partTwo(input) println("8b: $resultTwo") } private fun partOne(input: String): Long { val map = input.parse() val visible = mutableSetOf<Pair<Int, Int>>() p...
0
Kotlin
0
0
8230fce9a907343f11a2c042ebe0bf204775be3f
13,492
advent-of-code-2022
MIT License
src/main/kotlin/solutions/day08/Day8.kt
Dr-Horv
112,381,975
false
null
package solutions.day08 import solutions.Solver import utils.splitAtWhitespace enum class Operation { INC, DEC } fun String.toOperation(): Operation = when(this) { "inc" -> Operation.INC "dec" -> Operation.DEC else -> throw RuntimeException("Operation unparsable: $this") } fun String.toCondition...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
2,715
Advent-of-Code-2017
MIT License
aoc/src/main/kotlin/com/bloidonia/aoc2023/day03/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day03 import com.bloidonia.aoc2023.lines private data class Number(val x: IntRange, val y: Int, val value: String) private data class Symbol(val x: Int, val y: Int, val value: String) private data class Board(val numbers: List<Number>, val symbols: List<Symbol>) { constructor(input: ...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
1,944
aoc-2023
MIT License
src/year2023/day01/Day01.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2023.day01 import check import readInput fun main() { val testInput1 = readInput("2023", "Day01_test_part1") val testInput2 = readInput("2023", "Day01_test_part2") check(part1(testInput1), 142) check(part2(testInput2), 281) val input = readInput("2023", "Day01") println(part1(inpu...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,268
AdventOfCode
Apache License 2.0
solutions/src/Day16.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): Int { val pathTotalPressures = getTotalPressureForAllPaths(input, 30) return pathTotalPressures.maxOf { (_, totalPressure) -> totalPressure } } fun part2(input: List<String>): Int { val pathTotalPressures = getTotalPressureForAllPaths(inp...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
5,307
advent-of-code-22
Apache License 2.0
src/Day03.kt
razvn
573,166,955
false
{"Kotlin": 27208}
fun main() { val day = "Day03" fun part1(input: List<String>): Int = input.fold(emptyList<Char>()) { acc, line -> val commun = communChars(emptySet(), line.chunked(line.length/2)) acc + commun }.let { value(it)} fun part2(input: List<String>): Int = input.chunked(3).fold(0) { acc, gro...
0
Kotlin
0
0
73d1117b49111e5044273767a120142b5797a67b
1,469
aoc-2022-kotlin
Apache License 2.0
src/Day12.kt
xNakero
572,621,673
false
{"Kotlin": 23869}
object Day12 { fun part1(): Int { val graph = readGraph() val startAt = graph.first { it.value == 'S' } val queue = mutableListOf(startAt.coordinate) val visited = mutableSetOf(startAt.coordinate) val results = graph.map { it.coordinate }.associateWith { 0 }.toMutableMap() ...
0
Kotlin
0
0
c3eff4f4c52ded907f2af6352dd7b3532a2da8c5
3,922
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day07.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.extensions.times class Day07 : Day(7, 2023, "Camel Cards") { class Hand(val hand: String, val value: Int, val withJoker: Boolean = false) : Comparable<Hand> { val CARDS = buildList<String> { ...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
3,703
advent-of-code-2023
Apache License 2.0
src/Day07.kt
SimoneStefani
572,915,832
false
{"Kotlin": 33918}
fun main() { class Node( val name: String, val parent: Node?, val children: MutableSet<Node> = mutableSetOf(), ) { private var itemSize = 0L val totalSize: Long get() = itemSize + children.sumOf { it.totalSize } fun addNode(dir: Node): Node = this.also { children...
0
Kotlin
0
0
b3244a6dfb8a1f0f4b47db2788cbb3d55426d018
1,818
aoc-2022
Apache License 2.0
src/Day15.kt
sushovan86
573,586,806
false
{"Kotlin": 47064}
import kotlin.math.abs import kotlin.math.max import kotlin.math.min class BeaconExclusionZone private constructor( private val sensorBeaconDistances: List<SensorBeaconDistance> ) { fun getNoBeaconPositionCountAtRow(rowNum: Int): Int = getCoverageRangePairsAtRow(rowNum) .let { rangePairsAt...
0
Kotlin
0
0
d5f85b6a48e3505d06b4ae1027e734e66b324964
3,771
aoc-2022
Apache License 2.0
src/main/kotlin/days/y2023/day04/Day04.kt
jewell-lgtm
569,792,185
false
{"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123}
package days.y2023.day04 import util.InputReader class Day04(input: List<String>) { private val deck: List<Card> = input.map { Card(it) } fun partOne() = deck.sumOf { it.points } fun partTwo(): Int { val count = deck.associateWith { 1 }.toMutableMap() deck.forEachIndexed { index, card ->...
0
Kotlin
0
0
b274e43441b4ddb163c509ed14944902c2b011ab
1,756
AdventOfCode
Creative Commons Zero v1.0 Universal
src/Day07.kt
punx120
573,421,386
false
{"Kotlin": 30825}
class Node( val name: String, var files: Long = 0, val parent: Node? = null, val children: MutableMap<String, Node> = mutableMapOf() ) { fun totalSize(): Long { return files + children.values.sumOf { it.totalSize() } } override fun toString(): String { return "Node(name='$na...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
2,851
aoc-2022
Apache License 2.0
src/main/kotlin/Day16.kt
clechasseur
318,029,920
false
null
import org.clechasseur.adventofcode2020.Day16Data object Day16 { private val ticketRules = Day16Data.ticketRules private const val yourTicket = Day16Data.yourTicket private val nearbyTickets = Day16Data.nearbyTickets private val ticketRuleRegex = """^([a-z ]+): (\d+)-(\d+) or (\d+)-(\d+)$""".toRegex()...
0
Kotlin
0
0
6173c9da58e3118803ff6ec5b1f1fc1c134516cb
2,742
adventofcode2020
MIT License
src/Day07.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
/** * [Day07](https://adventofcode.com/2022/day/7) */ private class Day07 { sealed class Node { abstract val name: String data class File(override val name: String, val size: Int) : Node() { override fun toString(): String { return "File: $name" } ...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
3,744
aoc-in-kotlin-2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/Day9.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 9: Smoke Basin //https://adventofcode.com/2021/day/9 import java.io.File fun main() { val heightMaps = File("src/main/resources/Day9.txt").readLines() val totalHeight = heightMaps.size val totalWidth = heightMaps.first().length val array = Array(totalHeight) { Array(totalWidth) { 0 } } heig...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,404
advent-of-code
Apache License 2.0
src/aoc2022/day07/Day07.kt
svilen-ivanov
572,637,864
false
{"Kotlin": 53827}
package aoc2022.day07 import readInput sealed class Fs() { abstract val parent: Dir? abstract val name: String abstract fun size(): Int data class File(override val parent: Dir?, override val name: String, val size: Int) : Fs() { override fun size(): Int = size } data class Dir(overr...
0
Kotlin
0
0
456bedb4d1082890d78490d3b730b2bb45913fe9
2,929
aoc-2022
Apache License 2.0
leetcode2/src/leetcode/TwoSumIITnputArrayIsSorted.kt
hewking
68,515,222
false
null
package leetcode /** * https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted/ * 167. 两数之和 II - 输入有序数组 * Created by test * Date 2019/6/16 10:31 * Description * 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。 说明: 返回的下标值(index1 和 index2)不是从零开始的。 你可以假设每个输入只对应唯...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,185
leetcode
MIT License
src/Day09.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.math.abs import kotlin.math.max fun main() { data class Point(val x: Int, val y: Int) { fun dist(other: Point) = max(abs(x - other.x), abs(y - other.y)) } fun Point.move(dir: String): Point { return when (dir) { "R" -> Point(x + 1, y) "L" -> Point(x - ...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
1,810
Advent-of-Code-2022
Apache License 2.0
src/aoc2018/kot/Day23.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import diffBy import getNumbers import java.io.File import java.util.* import kotlin.math.abs object Day23 { data class State(val sender: Sender, val inRange: Int) : Comparable<State> { override fun compareTo(other: State) = if (other.inRange == inRange) sender.r.compareTo(other.sender.r) e...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
2,405
Advent_of_Code
MIT License
src/Day09.kt
Narmo
573,031,777
false
{"Kotlin": 34749}
import kotlin.math.abs fun main() { class Knot(var x: Int, var y: Int) { fun copy() = Knot(x, y) fun isAdjacentTo(other: Knot) = abs(x - other.x) < 2 && abs(y - other.y) < 2 override fun toString() = "($x, $y)" override fun equals(other: Any?) = other is Knot && x == other.x && y == other.y override fun has...
0
Kotlin
0
0
335641aa0a964692c31b15a0bedeb1cc5b2318e0
1,666
advent-of-code-2022
Apache License 2.0
src/aoc23/Day03.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day03 import aoc23.day03.PartNumber.Companion.findAllPartNumbers import aoc23.day03.Symbol.Companion.findAllSymbols import lib.Line import lib.Point import lib.Solution data class PartNumber(val value: Int, val location: Line) { companion object { fun St...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
2,883
aoc-kotlin
Apache License 2.0
src/Day09.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
import kotlin.math.abs import kotlin.math.sign fun main() { fun part1(input: List<String>) = RopeGrid().apply { move(input.parse9()) }.visited.size fun part2(input: List<String>) = RopeGrid(10).apply { move(input.parse9()) }.visited.size // test if implementation meets criteria from the description, like:...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
1,707
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/trie/AutocompleteSearch.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.trie // https://cheonhyangzhang.gitbooks.io/leetcode-solutions/642-design-search-autocomplete-system.html class AutocompleteSearch(historicalData: List<Suggestion>) { val historicalData: TreeNode = TreeNode(Suggestion("")).apply { historicalData.forEach { (word, weight) -> addWord(word, weight) } }...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
3,145
coding
MIT License
src/Day09.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import java.lang.Exception import kotlin.math.abs fun main() { data class Point(val x: Int, val y: Int) { override fun toString(): String { return "($x, $y)" } } class Rope(knotsCount: Int) { var knots = mutableListOf<Point>() init { for (i in 1..kno...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
2,791
advent-of-code-2022
Apache License 2.0
year2015/src/main/kotlin/net/olegg/aoc/year2015/day15/Day15.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day15 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 15](https://adventofcode.com/2015/day/15) */ object Day15 : DayOf2015(15) { private const val SPOONS = 100 private val PATTERN = ".* (-?\\d+)\\b.* (-?\\d+)\\b.* (-?\\d+)\\b...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,655
adventofcode
MIT License