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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
advent-of-code2015/src/main/kotlin/day1/Advent1.kt | REDNBLACK | 128,669,137 | false | null | package day1
import parseInput
/**
--- Day 1: Not Quite Lisp ---
Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December 25th.
Collect stars by helping Santa solve puzzles. Two puzzl... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 2,658 | courses | MIT License |
2021/src/day25/Day25.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day25
import readInput
import java.lang.IllegalStateException
import java.text.SimpleDateFormat
import java.util.*
typealias Table = Array<CharArray>
fun List<String>.toTable(): Table {
val ret = Array<CharArray>(this.size) { CharArray(0) }
for (y in indices) ret[y] = this[y].toCharArray()
return... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 2,881 | advent-of-code | Apache License 2.0 |
src/day2/Day02.kt | MatthewWaanders | 573,356,006 | false | null | package day2
import utils.readInput
const val rockValue = 1
const val paperValue = 2
const val scissorValue = 3
const val winValue = 6
const val drawValue = 3
const val lossValue = 0
val partOneChoiceValueMap = mapOf(
"X" to rockValue,
"Y" to paperValue,
"Z" to scissorValue
)
val partOneMatchResultsMat... | 0 | Kotlin | 0 | 0 | f58c9377edbe6fc5d777fba55d07873aa7775f9f | 1,637 | aoc-2022 | Apache License 2.0 |
src/Day20.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | fun main() {
infix fun Long.modulo(modulus: Long): Long {
val remainder = this % modulus
if (this >= modulus) return this % (modulus-1)
if ((kotlin.math.abs(this) >= modulus)&&(this < 0)) return (this % (modulus-1)) + modulus - 1
return if (remainder >= 0) remainder else remainder +... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 2,817 | aoc22 | Apache License 2.0 |
src/main/kotlin/com/eric/leetcode/SatisfiabilityOfEqualityEquations.kt | wanglikun7342 | 163,727,208 | false | {"Kotlin": 172132, "Java": 27019} | package com.eric.leetcode
class SatisfiabilityOfEqualityEquations {
private class UnionFind(n: Int) {
private val parent: Array<Int> = Array(n) {
it
}
fun find(input: Int): Int {
var x = input
while (x != parent[x]) {
parent[x] = parent[p... | 0 | Kotlin | 2 | 8 | d7fb5ff5a0a64d9ce0a5ecaed34c0400e7c2c89c | 1,750 | Leetcode-Kotlin | Apache License 2.0 |
src/Day02.kt | aeisele | 572,478,307 | false | {"Kotlin": 4468} | enum class Shape(val worth: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3)
}
fun main() {
fun charsFromLine(line: String): Pair<Char, Char> {
val tokens = line.split(' ')
return Pair(tokens[0][0], tokens[1][0])
}
fun toShape(c: Char): Shape {
return when (c) {
'A', ... | 0 | Kotlin | 0 | 0 | 40a867c599fda032660724b81b0c12070ac5ba87 | 2,531 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/day5/Day5.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day5
import Day
import ext.component6
fun main() {
Day5("Day05").solve()
}
class Day5(input: String) : Day<Pair<List<MutableList<Char>>, List<Day5.Action>>>(input) {
data class Action(val from: Int, val to: Int, val units: Int)
override fun parseInput(): Pair<List<MutableList<Char>>, List<Actio... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 1,752 | aoc-2022 | Apache License 2.0 |
src/Day09.kt | oleskrede | 574,122,679 | false | {"Kotlin": 24620} | import kotlin.math.abs
import kotlin.math.max
fun main() {
val toDirection = mapOf(
"R" to Direction.RIGHT,
"U" to Direction.UP,
"L" to Direction.LEFT,
"D" to Direction.DOWN,
)
fun isTouching(a: Position, b: Position): Boolean {
val dx = abs(a.x - b.x)
val ... | 0 | Kotlin | 0 | 0 | a3484088e5a4200011335ac10a6c888adc2c1ad6 | 2,166 | advent-of-code-2022 | Apache License 2.0 |
2022/main/day_15/Main.kt | Bluesy1 | 572,214,020 | false | {"Rust": 280861, "Kotlin": 94178, "Shell": 996} | package day_15_2022
import java.io.File
import kotlin.math.abs
import kotlin.math.absoluteValue
val inputRe = Regex("[\\w\\s]*x=(?<xPos>-?\\d+), y=(?<yPos>-?\\d+):[\\w\\s]*x=(?<xTarget>-?\\d+), y=(?<yTarget>-?\\d+)")
fun part1(input: List<String>) {
val parsed = input.mapNotNull(inputRe::find)
.map { it.... | 0 | Rust | 0 | 0 | 537497bdb2fc0c75f7281186abe52985b600cbfb | 2,512 | AdventofCode | MIT License |
src/Day05.kt | zhtk | 579,137,192 | false | {"Kotlin": 9893} | private data class CrateMove(val amount: Int, val from: Int, val to: Int)
fun main() {
val input = readInput("Day05")
val stackDescription = input.takeWhile { it.isNotEmpty() }.dropLast(1).map {
it.chunked(4).map { it[1] }
}
val crateMovement = input.dropWhile { it.isNotEmpty() }.drop(1).map {
... | 0 | Kotlin | 0 | 0 | bb498e93f9c1dd2cdd5699faa2736c2b359cc9f1 | 1,452 | aoc2022 | Apache License 2.0 |
src/Day08.kt | anisch | 573,147,806 | false | {"Kotlin": 38951} | typealias Forest = List<List<Tree>>
data class Tree(
val height: Int,
var isVisible: Boolean = false,
var score: Int = 0,
)
fun createForest(input: List<String>): Forest = input
.map { line ->
line.chunked(1).map { s -> Tree(s.toInt()) }
}
fun Forest.checkTreeVisibility() {
// from le... | 0 | Kotlin | 0 | 0 | 4f45d264d578661957800cb01d63b6c7c00f97b1 | 3,770 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day15.kt | thomasreader | 573,047,664 | false | {"Kotlin": 59975} | import java.io.Reader
import kotlin.math.abs
fun main() {
val testInput = """
Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10... | 0 | Kotlin | 0 | 0 | eff121af4aa65f33e05eb5e65c97d2ee464d18a6 | 4,009 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day02.kt | yalexaner | 573,141,113 | false | {"Kotlin": 4235} | @file:JvmName("Day2Kt")
import kotlin.math.max
fun main() {
runTests()
val input = readInput("Day02")
println(part1(input))
}
private fun runTests() {
val testInput = readInput("Day02_test")
val part1Result = part1(testInput)
check(part1Result == 15) { "part1 is $part1Result, but expected 1... | 0 | Kotlin | 0 | 0 | 58c2bf57543253db544fa8950aac4dc67896b808 | 1,543 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/de/jball/aoc2022/day14/Day14.kt | fibsifan | 573,189,295 | false | {"Kotlin": 43681} | package de.jball.aoc2022.day14
import de.jball.aoc2022.Day
import kotlin.math.abs
class Day14(test: Boolean = false): Day<Int>(test, 24, 93) {
private val rocks = input.map { rockFormation ->
rockFormation.split(" -> ")
.map { coordinate ->
val (x, y) = coordinate.split(",")
... | 0 | Kotlin | 0 | 3 | a6d01b73aca9b54add4546664831baf889e064fb | 2,887 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day13.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2023
import utils.InputUtils
fun columns(input: List<String>): List<String> =
input[0].indices.map { index -> String(input.map { it[index] }.toCharArray()) }
fun main() {
val testInput = """#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,065 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/day22/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day22
import java.io.File
fun main() {
val inputLineRegex = """(on|off) x=([-]?\d+)..([-]?\d+),y=([-]?\d+)..([-]?\d+),z=([-]?\d+)..([-]?\d+)""".toRegex()
val lines = File("src/main/kotlin/day22/input.txt").readLines()
val rebootSteps = lines.map { line ->
val (state, x0, x1, y0, y1, z0, z1... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 2,642 | aoc-2021 | MIT License |
2021/src/day15/day15.kt | scrubskip | 160,313,272 | false | {"Kotlin": 198319, "Python": 114888, "Dart": 86314} | package day15
import java.io.File
fun main() {
val board = Board.getBoard(File("src/day15", "day15input.txt").readLines(), true)
println("[${board.numRows} x ${board.numCols}]")
println(board.getLowestPathSum())
}
class Board(private val data: Array<IntArray>, val multiplied: Boolean = false) {
val... | 0 | Kotlin | 0 | 0 | a5b7f69b43ad02b9356d19c15ce478866e6c38a1 | 3,004 | adventofcode | Apache License 2.0 |
src/main/kotlin/Problem12.kt | jimmymorales | 496,703,114 | false | {"Kotlin": 67323} | /**
* Highly divisible triangular number
*
* The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be
* 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
*
* 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
*
* Let us list the factors of the first seve... | 0 | Kotlin | 0 | 0 | e881cadf85377374e544af0a75cb073c6b496998 | 1,651 | project-euler | MIT License |
year2019/src/main/kotlin/net/olegg/aoc/year2019/day12/Day12.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2019.day12
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Vector3D
import net.olegg.aoc.utils.lcf
import net.olegg.aoc.year2019.DayOf2019
import kotlin.math.sign
/**
* See [Year 2019, Day 12](https://adventofcode.com/2019/day/12)
*/
object Day12 : DayOf2019(12) {
private... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,380 | adventofcode | MIT License |
2020/kotlin/day-7/main.kt | waikontse | 330,900,073 | false | null | import util.FileUtils
fun main() {
val fileUtils = FileUtils("input.txt")
// Do some processing of the input for grokking later on.
val cleanLines = cleanInputLines(fileUtils.lines)
val mapOfBags = bagsToMap(cleanLines)
println (mapOfBags)
println (findTargetBags(mapOfBags, "shiny gold"))
... | 0 | Kotlin | 0 | 0 | abeb945e74536763a6c72cebb2b27f1d3a0e0ab5 | 2,911 | advent-of-code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/advent/day18/Snailfish.kt | hofiisek | 434,171,205 | false | {"Kotlin": 51627} | package advent.day18
import advent.loadInput
import java.io.File
/**
* @author <NAME>
*/
fun part1(input: File) = input.readLines()
// .first()
// .let { pairs -> buildTreeRecursively(RootNode(), pairs.drop(1))}
.map { snailfishNumber -> buildTreeRecursively(RootNode(), snailfishNumber.drop(1))}
.onE... | 0 | Kotlin | 0 | 2 | 3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb | 3,781 | Advent-of-code-2021 | MIT License |
src/Day07.kt | findusl | 574,694,775 | false | {"Kotlin": 6599} | import java.io.File
import java.util.Stack
private fun part1(input: File): Int {
val root = input.useLines {
PredictiveIterator(it.iterator()).parseFileSystem()
}
return root.allDirectories().filter { it.size < 100000 }.sumOf { it.size }
}
private fun part2(input: File): Int {
val root = input... | 0 | Kotlin | 0 | 0 | 035f0667c115b09dc36a475fde779d4b74cff362 | 3,271 | aoc-kotlin-2022 | Apache License 2.0 |
src/day07/Day07.kt | wickenico | 573,048,677 | false | {"Kotlin": 27144} | package day07
import day07.Directory.Companion.ROOT
import readInput
private class Directory(val parent: Directory?, val children: MutableList<Directory> = mutableListOf()) {
var size = 0L
fun getTotal(): Long = this.size + this.children.sumOf { it.getTotal() }
companion object {
val ROOT: Direc... | 0 | Kotlin | 1 | 0 | dbcb627e693339170ba344847b610f32429f93d1 | 1,997 | advent-of-code-kotlin-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/io/github/ocirne/aoc/year2023/Day5.kt | ocirne | 327,578,931 | false | {"Python": 323051, "Kotlin": 67246, "Sage": 5864, "JavaScript": 832, "Shell": 68} | package io.github.ocirne.aoc.year2023
import io.github.ocirne.aoc.AocChallenge
import kotlin.math.max
import kotlin.math.min
class Day5(val lines: List<String>) : AocChallenge(2023, 5) {
data class UseType(val start: Long, val end: Long, val delta: Long)
private val seeds = if (lines.isEmpty()) {
li... | 0 | Python | 0 | 1 | b8a06fa4911c5c3c7dff68206c85705e39373d6f | 3,376 | adventofcode | The Unlicense |
src/Day05.kt | DeltaSonic62 | 572,718,847 | false | {"Kotlin": 8676} | fun getData(input: List<String>): Pair<MutableList<MutableList<String>>, MutableList<List<Int>>> {
val crates = mutableListOf<MutableList<String>>(mutableListOf())
val instructions = mutableListOf<List<Int>>()
var isCratesDone = false;
for (line in input) {
if (line.isBlank()) continue
... | 0 | Kotlin | 0 | 0 | 7cdf94ad807933ab4769ce4995a43ed562edac83 | 2,557 | aoc-2022-kt | Apache License 2.0 |
src/main/kotlin/day09/Solution.kt | TestaDiRapa | 573,066,811 | false | {"Kotlin": 50405} | package day09
import java.io.File
import kotlin.math.abs
data class Position(
val x: Int = 0,
val y: Int = 0
) {
fun doAStep(direction: Direction): Position {
return when (direction) {
Direction.UP -> this.copy(y = y+1)
Direction.DOWN -> this.copy(y = y-1)
Dire... | 0 | Kotlin | 0 | 0 | b5b7ebff71cf55fcc26192628738862b6918c879 | 2,730 | advent-of-code-2022 | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day14.kt | clechasseur | 568,233,589 | false | {"Kotlin": 242914} | package io.github.clechasseur.adventofcode.y2015
import io.github.clechasseur.adventofcode.y2015.data.Day14Data
object Day14 {
private val input = Day14Data.input
private val reindeerRegex =
"""^(\w+) can fly (\d+) km/s for (\d+) seconds?, but then must rest for (\d+) seconds?\.$""".toRegex()
fu... | 0 | Kotlin | 0 | 0 | e5a83093156cd7cd4afa41c93967a5181fd6ab80 | 2,750 | adventofcode2015 | MIT License |
src/Day01.kt | aaronbush | 571,776,335 | false | {"Kotlin": 34359} | fun main() {
fun loadInventory(input: List<String>): Map<Int, List<Int>> {
val inventory = mutableMapOf<Int, MutableList<Int>>()
var elf = 1
input.forEach {
if (it.isEmpty()) {
elf++
} else {
val cals = inventory.getOrDefault(elf, mutab... | 0 | Kotlin | 0 | 0 | d76106244dc7894967cb8ded52387bc4fcadbcde | 1,407 | aoc-2022-kotlin | Apache License 2.0 |
src/Day11.kt | MerickBao | 572,842,983 | false | {"Kotlin": 28200} | import java.math.BigInteger
fun main() {
var LCM = 1L
fun gcd(a: Long, b: Long): Long {
if (b == 0L) return a
return gcd(b, a % b)
}
fun lcm(a: Long, b: Long): Long {
return a * b / gcd(a, b)
}
class Node {
var id: Int = 0
var items= arrayListOf<BigIn... | 0 | Kotlin | 0 | 0 | 70a4a52aa5164f541a8dd544c2e3231436410f4b | 2,895 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/dwt/Dwt23.kt | sssemil | 268,084,789 | false | null | package dwt
import utils.Rational
private val Int.isPrime: Boolean
get() {
if (this == 1) return false
for (i in 2..this / 2) {
if (this % i == 0) return false
}
return true
}
fun main() {
// generate boxes
val xs = (1..45).toList()
val boxes = mutableL... | 0 | Kotlin | 0 | 0 | 02d951b90e0225bb1fa36f706b19deee827e0d89 | 3,509 | math_playground | MIT License |
src/Day03.kt | BenD10 | 572,786,132 | false | {"Kotlin": 6791} |
val prio by lazy { ('a'..'z') + ('A'..'Z') }
fun Char.getPriority() = prio.indexOf(this) + 1
fun main() {
fun part1(input: List<String>): Int {
return input.map {
it.chunked(it.length / 2) {
it.map { it.getPriority() }
}
}.map {
(it.first().toSe... | 0 | Kotlin | 0 | 0 | e26cd35ef64fcedc4c6e40b97a63d7c1332bb61f | 909 | advent-of-code | Apache License 2.0 |
src/aoc2023/Day01.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
import java.math.BigDecimal
fun main() {
fun part1(input: List<String>): BigDecimal {
var sum = BigDecimal.ZERO
for (line in input) {
sum = sum.add((10 * line.find { it.isDigit() }?.digitToInt()!!).toBigDecimal())
sum = sum.add(line.findLast... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 1,707 | advent-of-code-kotlin | Apache License 2.0 |
src/Day05.kt | Allagash | 572,736,443 | false | {"Kotlin": 101198} | // Advent of Code 2022, Day 05, Supply Stacks
fun main() {
data class Day05(val stacks: MutableList<ArrayDeque<Char>>, val moves: List<List<Int>>)
fun part1(input: Day05): String {
val stacks = input.stacks
val moves = input.moves
moves.forEach {
for (i in 1..it[0]) {
... | 0 | Kotlin | 0 | 0 | 8d5fc0b93f6d600878ac0d47128140e70d7fc5d9 | 2,723 | AdventOfCode2022 | Apache License 2.0 |
src/Day4.kt | syncd010 | 324,790,559 | false | null | class Day4 : Day {
private fun convert(input: List<String>): Pair<Int, Int> {
val split = input[0].split("-")
return Pair(split[0].toInt(), split[1].toInt())
}
private fun countPasswords(minVal: Int, maxVal: Int, sequenceRule: (List<Int>) -> Boolean): Int {
val digits = minVal.toDig... | 0 | Kotlin | 0 | 0 | 11c7c7d6ccd2488186dfc7841078d9db66beb01a | 1,757 | AoC2019 | Apache License 2.0 |
jvm/src/main/kotlin/io/prfxn/aoc2021/day11.kt | prfxn | 435,386,161 | false | {"Kotlin": 72820, "Python": 362} | // Dumbo Octopus (https://adventofcode.com/2021/day/11)
package io.prfxn.aoc2021
fun main() {
val lines = textResourceReader("input/11.txt").readLines().map { it.map(Char::digitToInt) }
fun process(
grid: Array<IntArray>,
cells: List<Pair<Int, Int>>,
flashed: MutableSet<Pair<Int, In... | 0 | Kotlin | 0 | 0 | 148938cab8656d3fbfdfe6c68256fa5ba3b47b90 | 1,872 | aoc2021 | MIT License |
src/Day03.kt | paulbonugli | 574,065,510 | false | {"Kotlin": 13681} | fun main() {
fun determinePriority(c : Char) : Int {
return if (c > 'Z') {
c - 'a' + 1
} else {
c - 'A' + 26 + 1
}
}
fun part1(input : List<String>) : Int {
return input.map { line ->
val c1 = line.subSequence(0, line.length / 2)
... | 0 | Kotlin | 0 | 0 | d2d7952c75001632da6fd95b8463a1d8e5c34880 | 881 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch8/Problem89.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch8
/**
* Problem 89: Roman Numerals
*
* https://projecteuler.net/problem=89
*
* Goal: Given a string of Roman number symbols, output a valid (or more efficient) Roman number
* that represents it, by following the rules below.
*
* Constraints: 1 <= length of input string <= 1000
*
* Ro... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,770 | project-euler-kotlin | MIT License |
src/Day19/Day19.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import kotlin.math.absoluteValue
fun Triple<Int, Int, Int>.get(i: Int): Int = when (i) {
0 -> this.first
1 -> this.second
2 -> this.third
else -> throw IllegalArgumentException(i.toString())
}
fun Triple<Int, Int, Int>.rotate(d: Int): Triple<Int, Int, Int> {
val c0 = d % 3
val c0s = 1 - ((d / ... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 4,232 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2022/Day15.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2022
import ru.timakden.aoc.util.Point
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
import kotlin.math.abs
/**
* [Day 15: Beacon Exclusion Zone](https://adventofcode.com/2022/day/15).
*/
object Day15 {
@JvmStatic
fun main(args: Array<String>) {
... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 3,794 | advent-of-code | MIT License |
src/Day07.kt | armandmgt | 573,595,523 | false | {"Kotlin": 47774} | fun main() {
data class Node(val name: String, val size: Int, val leafs: List<Node>)
val cdPattern = Regex("\\$ cd ([/\\w]+)")
val filePattern = Regex("(\\d+) .*")
val exitPattern = Regex("\\$ cd \\.\\.")
var matchingDirSum = 0
fun enter(iterator: Iterator<String>): Int {
var currentDi... | 0 | Kotlin | 0 | 1 | 0d63a5974dd65a88e99a70e04243512a8f286145 | 2,981 | advent_of_code_2022 | Apache License 2.0 |
src/day20/Day20.kt | spyroid | 433,555,350 | false | null | package day20
import readInput
import kotlin.system.measureTimeMillis
data class Pixel(val x: Int, val y: Int, var color: Int)
data class Image(val width: Int, val height: Int, val bgColor: Int, val algo: List<Int>, val pixels: List<Pixel>) {
companion object {
private fun mapPixel(ch: Char) = if (ch ==... | 0 | Kotlin | 0 | 0 | 939c77c47e6337138a277b5e6e883a7a3a92f5c7 | 2,485 | Advent-of-Code-2021 | Apache License 2.0 |
src/Day03.kt | uberbinge | 572,972,800 | false | {"Kotlin": 7404} | val input = readInput("Day03").split("\n")
fun main() {
part1()
part2()
}
fun part1() {
input.map {
val first = it.substring(0, it.length / 2)
val second = it.substring(it.length / 2)
(first intersect second).single()
}.sumOf { it.score() }.also { check(8202 == it) }
}
fun par... | 0 | Kotlin | 0 | 0 | ef57861156ac4c1a097fabe03322edcfa4d2d714 | 840 | aoc-2022-kotlin | Apache License 2.0 |
src/main/java/io/github/lunarwatcher/aoc/day11/Day11.kt | LunarWatcher | 160,042,659 | false | null | package io.github.lunarwatcher.aoc.day11
import io.github.lunarwatcher.aoc.commons.Vector2i
import io.github.lunarwatcher.aoc.commons.readFile
import java.util.*
data class ElevenPart2(val coords: Vector2i, val size: Int, val sum: Int)
private fun parseData(serialNumber: Int) : SortedMap<Vector2i, Int>{
val powe... | 0 | Kotlin | 0 | 1 | 99f9b05521b270366c2f5ace2e28aa4d263594e4 | 2,503 | AoC-2018 | MIT License |
src/main/kotlin/solutions/day12/Day12.kt | Dr-Horv | 112,381,975 | false | null |
package solutions.day12
import solutions.Solver
data class Node(val id: Int, val neighbours: MutableSet<Node>) {
override fun hashCode(): Int {
return id.hashCode()
}
override fun equals(other: Any?): Boolean {
return when(other) {
is Node -> id == other.id
else -... | 0 | Kotlin | 0 | 2 | 975695cc49f19a42c0407f41355abbfe0cb3cc59 | 2,408 | Advent-of-Code-2017 | MIT License |
src/Day13.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | fun main() {
fun getNumber(list: MutableList<Char>): Int? {
if (!list[0].isDigit()) {
return null
}
if (list[1].isDigit()) {
val number = "" + list[0] + list[1]
return number.toInt()
}
return list[0].digitToInt()
}
fun bracket(arra... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 2,287 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | Flame239 | 570,094,570 | false | {"Kotlin": 60685} | import kotlin.math.min
private fun root(): Node {
val root = Node()
var cur = root
readInput("Day07").forEach { cmd ->
if (cmd.startsWith("$")) {
val cmdS = cmd.split(" ")
if (cmdS[1] == "cd") {
cur = when (cmdS[2]) {
"/" -> root
... | 0 | Kotlin | 0 | 0 | 27f3133e4cd24b33767e18777187f09e1ed3c214 | 2,173 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | Totwart123 | 573,119,178 | false | null | fun main() {
fun getCalsByElves(input: List<String>): List<Int> {
var numberInput = input.map { if (it.isEmpty()) -1 else it.toInt() }.toList()
val emptyLines = numberInput.mapIndexed { index, i -> if (i == -1) index + 1 else -1 }.filter { it != -1 }.toMutableList().dropLast(0).reversed().toMutable... | 0 | Kotlin | 0 | 0 | 33e912156d3dd4244c0a3dc9c328c26f1455b6fb | 1,107 | AoC | Apache License 2.0 |
src/Day11.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} | import kotlin.math.floor
import kotlin.math.pow
class Round(list: List<Monkey>) {
private val lookup: Map<Int, Monkey>
private val sharedModulus: Int
var adjust = true
init {
lookup = list.associateBy { it.id }
sharedModulus = lookup.values.map { it.modulus }.reduce { res, mod -> res *... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 4,097 | 2022-advent | Apache License 2.0 |
src/Day04.kt | tstellfe | 575,291,176 | false | {"Kotlin": 8536} | fun main() {
fun String.toSections() = this.split(",").map { pair ->
val sections = pair.split("-")
sections[0].toInt()..sections[1].toInt()
}
fun IntRange.isIn(other: IntRange): Boolean {
this.forEach {
if (!other.contains(it)) return false
}
return true
}
fun IntRange.hasAtLeastO... | 0 | Kotlin | 0 | 0 | e100ba705c8e2b83646b172d6407475c27f02eff | 1,095 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem5/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem5
/**
* LeetCode page: [5. Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/description/);
*
* Note: There is a linear time complexity algorithm called Manacher's algorithm, see [Ref.](https://en.wikipedia.org/wiki/Longest_palindromic_s... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,878 | hj-leetcode-kotlin | Apache License 2.0 |
app/src/main/kotlin/advent/of/code/twentytwenty/Day2.kt | obarcelonap | 320,300,753 | false | null | package advent.of.code.twentytwenty
fun main(args: Array<String>) {
val lines = getResourceAsLines("/day2-input")
val validPasswordsByOcurrencesRange = filterValidPasswords(lines, ::validatorByOccurrencesRange)
println("Part 1: found ${validPasswordsByOcurrencesRange.size} valid passwords")
val valid... | 0 | Kotlin | 0 | 0 | a721c8f26738fe31190911d96896f781afb795e1 | 2,124 | advent-of-code-2020 | MIT License |
year2022/src@jvm/cz/veleto/aoc/year2022/Day19.kt | haluzpav | 573,073,312 | false | {"Kotlin": 164348} | package cz.veleto.aoc.year2022
import cz.veleto.aoc.core.AocDay
class Day19(config: Config) : AocDay(config) {
private val inputRegex = Regex(
"""
^Blueprint ([0-9]+):
Each ore robot costs ([0-9]+) ore.
Each clay robot costs ([0-9]+) ore.
Each obsidian robo... | 0 | Kotlin | 0 | 1 | 32003edb726f7736f881edc263a85a404be6a5f0 | 7,986 | advent-of-pavel | Apache License 2.0 |
src/main/kotlin/dp/MaxSumRect.kt | yx-z | 106,589,674 | false | null | package dp
import util.*
/*
Suppose you are given an array M[1..n, 1..n] of numbers, which may be positive,
negative, or zero, and which are not necessarily integers.
Describe an algorithm to find the largest sum of elements in any rectangular
subarray of the form M[i..i', j..j'].
Try to solve it in O(n^3) time
*/
... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,707 | AlgoKt | MIT License |
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day11/Day11.kt | nerok | 572,862,875 | false | {"Kotlin": 113337} | package nerok.aoc.aoc2022.day11
import nerok.aoc.utils.Input
import kotlin.time.DurationUnit
import kotlin.time.measureTime
fun main() {
fun operateOnItem(item: ULong, operation: String): ULong {
val (first, operator, last) = operation
.trim()
.removePrefix("new = ")
.r... | 0 | Kotlin | 0 | 0 | 7553c28ac9053a70706c6af98b954fbdda6fb5d2 | 4,857 | AOC | Apache License 2.0 |
src/Day01.kt | zhiqiyu | 573,221,845 | false | {"Kotlin": 20644} | import kotlin.math.max
class SimpleHeap(var data: Array<Int> = arrayOf(0, 0, 0)) {
fun add(item: Int) {
data.set(2, max(data.get(2), item))
reorder()
return
}
fun reorder() {
var cur = 2
while (cur > 0 && data.get(cur) > data.get(cur - 1)) {
val temp = ... | 0 | Kotlin | 0 | 0 | d3aa03b2ba2a8def927b94c2b7731663041ffd1d | 1,538 | aoc-2022 | Apache License 2.0 |
src/test/kotlin/amb/aoc2020/day17.kt | andreasmuellerbluemlein | 318,221,589 | false | null | package amb.aoc2020
import org.junit.jupiter.api.Test
class Day17 : TestBase() {
fun getInput(file: String): HyperCube {
return getTestData(file).filter { it.isNotEmpty() }.flatMapIndexed { x, line ->
line.mapIndexed { y, value ->
Pair(Quadrupel(x, y, 0,0), value == '#')
... | 1 | Kotlin | 0 | 0 | dad1fa57c2b11bf05a51e5fa183775206cf055cf | 2,510 | aoc2020 | MIT License |
src/Day09.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | import java.io.File
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import kotlin.math.abs
import kotlin.math.sqrt
data class Position(val y: Int, val x: Int)
data class RopeSection(val head: Position, val tail: Position)
typealias Rope = Array<Position>
data class Direction(val dy:... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 3,933 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day15/Day15.kt | seastco | 574,758,881 | false | {"Kotlin": 72220} | package day15
import Point2D
import readLines
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
private class Sensor(val location: Point2D, val closestBeacon: Point2D) {
var distance: Int = location.distanceTo(closestBeacon)
}
private fun parseInput(input: List<String>): Set<Sensor> {
val ... | 0 | Kotlin | 0 | 0 | 2d8f796089cd53afc6b575d4b4279e70d99875f5 | 4,031 | aoc2022 | Apache License 2.0 |
src/main/kotlin/year2022/day-11.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2022
import lib.aoc.Day
import lib.aoc.Part
import java.math.BigInteger
fun main() {
Day(11, 2022, PartA11(20, 3), PartB11(10_000, 1)).run()
}
open class PartA11(private val rounds: Int, private val worryLevelFactor: Int) : Part() {
private lateinit var monkeys: List<Monkey>
sealed class Op... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 3,247 | Advent-Of-Code-Kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumIncompatibility.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,789 | kotlab | Apache License 2.0 |
src/Day10.kt | esteluk | 572,920,449 | false | {"Kotlin": 29185} | import kotlin.math.absoluteValue
fun main() {
fun part1(input: List<String>, duration: Int): Int {
var x = 1
var cycle = 1
fun checkCycle(): Boolean {
return cycle == duration
}
for (instruction in input) {
if (instruction.startsWith("addx")) {
... | 0 | Kotlin | 0 | 0 | 5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73 | 2,283 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/day03/day03.kt | corneil | 572,437,852 | false | {"Kotlin": 93311, "Shell": 595} | package main.day03
import utils.readFile
import utils.readLines
fun main() {
fun calcPriority(value: Char): Int = when (value) {
in 'a'..'z' -> value - 'a' + 1
in 'A'..'Z' -> value - 'A' + 27
else -> error("Invalid input $value")
}
fun calcRucksacks(input: List<String>): Int =
input.map { Pair... | 0 | Kotlin | 0 | 0 | dd79aed1ecc65654cdaa9bc419d44043aee244b2 | 1,672 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day23.kt | MarkTheHopeful | 572,552,660 | false | {"Kotlin": 75535} | private class ElvenField(map: List<String>) {
val elfAmount: Int
val elfPositions: MutableList<Pair<Int, Int>> = mutableListOf()
val positionsToElf: MutableMap<Pair<Int, Int>, Int> = mutableMapOf()
val directions = mutableListOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
init {
var counter = 0
... | 0 | Kotlin | 0 | 0 | 8218c60c141ea2d39984792fddd1e98d5775b418 | 2,990 | advent-of-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day03.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2021
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
import java.util.stream.Collectors
class Aoc2021Day03 {
companion object {
private const val ZERO = 0
private const val ONE = 1... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 3,865 | adventofcode | MIT License |
src/main/kotlin/com/ginsberg/advent2021/Day17.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 17 - Trick Shot
* Problem Description: http://adventofcode.com/2021/day/17
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day17/
*/
package com.ginsberg.advent2021
import kotlin.math.absoluteValue
class Day17(input... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 2,246 | advent-2021-kotlin | Apache License 2.0 |
src/day07/Day07.kt | pientaa | 572,927,825 | false | {"Kotlin": 19922} | package day07
import readLines
fun main() {
fun createFileSystem(input: List<String>): Directory {
val fileSystem = Directory("/")
val currentPath: MutableList<String> = mutableListOf()
input.drop(1).map {
when {
it.contains("dir") -> {
val... | 0 | Kotlin | 0 | 0 | 63094d8d1887d33b78e2dd73f917d46ca1cbaf9c | 3,347 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day11.kt | CrazyBene | 573,111,401 | false | {"Kotlin": 50149} | import java.lang.Exception
fun main() {
fun playRound(monkeys: List<Monkey>) {
for (monkey in monkeys) {
while (monkey.items.isNotEmpty()) {
var item = monkey.getFirstItem()
item = monkey.calculateNewValue(item)
item = item.div(3.toLong())
... | 0 | Kotlin | 0 | 0 | dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26 | 3,895 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/com/tonnoz/adventofcode23/day2/Two.kt | tonnoz | 725,970,505 | false | {"Kotlin": 78395} | package com.tonnoz.adventofcode23.day2
import com.tonnoz.adventofcode23.utils.readInput
typealias Color = String
const val SPACE = " "
const val SEMICOLON = ";"
const val COLON = ":"
const val COMMA = ","
object Two {
@JvmStatic
fun main(args: Array<String>) {
val input = "inputTwo.txt".readInput()
val ... | 0 | Kotlin | 0 | 0 | d573dfd010e2ffefcdcecc07d94c8225ad3bb38f | 1,995 | adventofcode23 | MIT License |
src/main/kotlin/adventofcode2023/day14/day14.kt | dzkoirn | 725,682,258 | false | {"Kotlin": 133478} | package adventofcode2023.day14
import adventofcode2023.readInput
import kotlin.time.measureTime
fun main() {
println("Day 14")
val input = readInput("day14")
println("Puzzle 1")
val time1 = measureTime {
println(calculateLoad(moveRocks(input.map { it.toCharArray() })))
}
println("puzzl... | 0 | Kotlin | 0 | 0 | 8f248fcdcd84176ab0875969822b3f2b02d8dea6 | 2,586 | adventofcode2023 | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2023/day2/Day2.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day2
import com.jacobhyphenated.advent2023.Day
import com.jacobhyphenated.advent2023.product
/**
* Day 2: Cube Conundrum
*
* Each line of input represents a game with a bag with an unknown number of red, green, and blue cubes
* Several times, reach into the bag for a sample ... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 2,650 | advent2023 | The Unlicense |
2023/src/day08/Day08.kt | scrubskip | 160,313,272 | false | {"Kotlin": 198319, "Python": 114888, "Dart": 86314} | package day08
import java.io.File
fun main() {
val input = File("src/day08/day08.txt").readLines()
val instructions = input[0]
val map = NodeMap(input.drop(2))
println(runInstructions(instructions, map))
println(runInstructionsAsGhost(instructions, map))
}
class Node(val id: String, val left: Str... | 0 | Kotlin | 0 | 0 | a5b7f69b43ad02b9356d19c15ce478866e6c38a1 | 3,081 | adventofcode | Apache License 2.0 |
src/main/kotlin/g1801_1900/s1857_largest_color_value_in_a_directed_graph/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1801_1900.s1857_largest_color_value_in_a_directed_graph
// #Hard #Hash_Table #Dynamic_Programming #Graph #Counting #Memoization #Topological_Sort
// #2023_10_02_Time_1005_ms_(60.00%)_Space_253.2_MB_(20.00%)
class Solution {
fun largestPathValue(colors: String, edges: Array<IntArray>): Int {
val l... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,494 | LeetCode-in-Kotlin | MIT License |
src/net/sheltem/aoc/y2023/Day12.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.aoc.y2023
suspend fun main() {
Day12().run()
}
class Day12 : Day<Long>(21, 525152) {
override suspend fun part1(input: List<String>): Long = input.map(SpringGroup::from).sumOf { it.possibleCombinations() }
override suspend fun part2(input: List<String>): Long = input.map { SpringGrou... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 1,939 | aoc | Apache License 2.0 |
src/Day01.kt | thorny-thorny | 573,065,588 | false | {"Kotlin": 57129} | import java.util.PriorityQueue
fun main() {
fun part1(input: List<String>): Int {
return input
.asSequence()
.map(String::toIntOrNull)
.sumGroups()
.maxOrNull() ?: throw Exception("There's no food D:")
}
fun part2(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 843869d19d5457dc972c98a9a4d48b690fa094a6 | 1,395 | aoc-2022 | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day08.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
import kotlin.math.max
class Day08 {
private val grid = inputFile("day08").readLines().map { it.map(Char::digitToInt) }
private val cols = grid.size
private val rows = grid.first().size
fun solvePart1(): Int {
var visible = 0
for (row in 0 until rows) {
... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 1,456 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/Day03.kt | josepatinob | 571,756,490 | false | {"Kotlin": 17374} | fun main() {
fun getAlphabetList(): List<Char> {
val alphabetList = mutableListOf<Char>()
var lowerChar = 'a'
while (lowerChar <= 'z') {
alphabetList.add(lowerChar)
++lowerChar
}
var capChar = 'A'
while (capChar <= 'Z') {
alphabet... | 0 | Kotlin | 0 | 0 | d429a5fff7ddc3f533d0854e515c2ba4b0d461b0 | 2,645 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/Day17.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | fun main() {
val up = Point(0, -1)
val left = Point(-1, 0)
val right = Point(1, 0)
val rocks = listOf(
(0..3).map { i -> Point(i, 0) }.toSet(),
setOf(Point(0, 1), Point(1, 1), Point(2, 1), Point(1, 2), Point(1, 0)),
setOf(Point(0, 0), Point(1, 0), Point(2, 0), Point(2, 1), Poin... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 5,455 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/com/richodemus/advent_of_code/two_thousand_sixteen/day1_taxicab/Main.kt | RichoDemus | 75,489,317 | false | null | package com.richodemus.advent_of_code.two_thousand_sixteen.day1_taxicab
import com.richodemus.advent_of_code.two_thousand_sixteen.toFile
fun main(args: Array<String>) {
val directions = readDirections()
var position = Position()
var direction = Direction.NORTH
val previousPositions = mutableSetOf(pos... | 0 | Kotlin | 0 | 0 | 32655174f45808eb1530f00c4c49692310036395 | 2,449 | advent-of-code | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/wildcard_matching/WildcardMatching.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.wildcard_matching
import datsok.shouldEqual
import org.junit.Test
/**
* https://leetcode.com/problems/wildcard-matching
*
* Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.
* '?' Matches any single character.
* '*' Matche... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 3,431 | katas | The Unlicense |
src/Year2022Day13.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | import java.util.IdentityHashMap
import kotlin.math.min
import kotlin.math.sign
fun main() {
fun parse(line: String): List<Any> {
val parentMap = IdentityHashMap<MutableList<Any>, MutableList<Any>?>()
var currentList: MutableList<Any>? = null
var index = 0
while(index < line.length)... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 2,366 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | konclave | 573,548,763 | false | {"Kotlin": 21601} | class Dir(
val name: String,
) {
var children: MutableList<Dir> = mutableListOf()
var parent: Dir? = null
var value: Int = 0
set(v) {
if (this.parent != null) {
this.parent!!.value = v
}
field += v
}
constructor(name: String, paren... | 0 | Kotlin | 0 | 0 | 337f8d60ed00007d3ace046eaed407df828dfc22 | 2,338 | advent-of-code-2022 | Apache License 2.0 |
src/Day07/Solution.kt | cweinberger | 572,873,688 | false | {"Kotlin": 42814} | package Day07
import readInput
import kotlin.math.max
enum class ItemType {
File, Directory
}
sealed class Item(
open val name: String,
open val parent: Item.Directory?,
val type: ItemType
) {
data class File(
override val name: String,
override val parent: Directory?,
val... | 0 | Kotlin | 0 | 0 | 883785d661d4886d8c9e43b7706e6a70935fb4f1 | 5,285 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day19/day19.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day19
import biz.koziolek.adventofcode.*
import kotlin.math.absoluteValue
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val scanners = parseScannerReport(lines)
val allBeacons = findAllBeaconsRelativeTo... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 7,017 | advent-of-code | MIT License |
src/Day09.kt | olezhabobrov | 572,687,414 | false | {"Kotlin": 27363} | import kotlin.math.abs
//enum class Move(val y: Int, val x: Int) {
// Left(0, -1),
// Right(0, 1),
// Up(1, 0),
// Down(-1, 0)
//}
class Coordinate(
var x: Int = 0,
var y: Int = 0) {
operator fun plus(increment: Coordinate): Coordinate = Coordinate(x + increment.x, y + increment.y)
oper... | 0 | Kotlin | 0 | 0 | 31f2419230c42f72137c6cd2c9a627492313d8fb | 2,703 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2023/Day10.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2023
import se.saidaspen.aoc.util.*
fun main() = Day10.run()
object Day10 : Day(2023, 10) {
private val map : MutableMap<P<Int, Int>, Char> = toMap(input)
private val startPos = map.entries.first { it.value == 'S' }.key
private var neighbours = mapOf(
'|' to listOf(P... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,906 | adventofkotlin | MIT License |
dcp_kotlin/src/test/kotlin/dcp/day307/day307.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day307
// day307.kt
// By <NAME>, 2020.
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.specs.StringSpec
// Find the floor of an element in a sorted list. We will use this in testing.
fun List<Int>.floor(x: Int): Int? = when {
isEmpty() || first() > x -... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,233 | daily-coding-problem | MIT License |
src/Day02.kt | nGoldi | 573,158,084 | false | {"Kotlin": 6839} | fun main() {
fun part1(input: List<String>): Int {
return input.fold(mutableListOf(0)) { acc, s ->
when (s) {
"A Y" -> acc[acc.lastIndex] = 6 + 2 + acc.last()
"A X" -> acc[acc.lastIndex] = 3 + 1 + acc.last()
"A Z" -> acc[acc.lastIndex] = 0 + 3 + a... | 0 | Kotlin | 0 | 0 | bc587f433aa38c4d745c09d82b7d231462f777c8 | 1,691 | advent-of-code | Apache License 2.0 |
classroom/src/main/kotlin/com/radix2/algorithms/week1/UnionFind.kt | rupeshsasne | 190,130,318 | false | {"Java": 66279, "Kotlin": 50290} | package com.radix2.algorithms.week1
interface UF {
fun union(p: Int, q: Int)
fun connected(p: Int, q: Int): Boolean
}
class QuickFindUF(size: Int) : UF {
private val ids: IntArray = IntArray(size) { it }
override fun connected(p: Int, q: Int): Boolean = ids[p] == ids[q]
override fun union(p: In... | 0 | Java | 0 | 1 | 341634c0da22e578d36f6b5c5f87443ba6e6b7bc | 2,014 | coursera-algorithms-part1 | Apache License 2.0 |
src/day16/Day16.kt | armanaaquib | 572,849,507 | false | {"Kotlin": 34114} | package day16
import readInput
import kotlin.math.max
data class Data(val valves: MutableMap<String, List<String>> = mutableMapOf(), val rates: MutableMap<String, Int> = mutableMapOf())
fun main() {
fun parseInput(input: List<String>) = input.fold(Data()) { data, line ->
val sl = line.split(" ")
... | 0 | Kotlin | 0 | 0 | 47c41ceddacb17e28bdbb9449bfde5881fa851b7 | 2,032 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/de/niemeyer/aoc2022/Day05.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | package de.niemeyer.aoc2022
/**
* Advent of Code 2022, Day 5: Supply Stacks
* Problem Description: https://adventofcode.com/2022/day/5
*/
import de.niemeyer.aoc.utils.Resources.resourceAsText
import de.niemeyer.aoc.utils.getClassName
typealias CrateStacks = List<ArrayDeque<Char>>
data class Move(val number: Int,... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 2,529 | AoC-2022 | Apache License 2.0 |
src/test/kotlin/icfp2019/TestUtils.kt | teemobean | 193,117,049 | true | {"JavaScript": 797310, "Kotlin": 129405, "CSS": 9434, "HTML": 5859, "Shell": 70} | package icfp2019
import com.google.common.base.CharMatcher
import com.google.common.base.Splitter
import icfp2019.model.*
import org.pcollections.PVector
import org.pcollections.TreePVector
import java.nio.file.Paths
fun String.toProblem(): Problem {
return parseTestMap(this)
}
fun GameState.toProblem(): Problem... | 0 | JavaScript | 0 | 0 | afcf5123ffb72ac10cfa6b0772574d9826f15e41 | 3,777 | icfp-2019 | The Unlicense |
day-06/src/main/kotlin/Lanternfish.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | fun main() {
println("Part One Solution: ${partOne()}")
println("Part Two Solution: ${partTwo()}")
}
private fun partOne(): Int {
val fishes = readFishes()
.toMutableList()
for (day in 1..80) {
val newFishes = mutableListOf<Fish>()
fishes.forEach { fish ->
fish.age... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 1,643 | aoc-2021 | MIT License |
src/Day05.kt | acunap | 573,116,784 | false | {"Kotlin": 23918} | import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
@OptIn(ExperimentalTime::class)
fun main() {
fun parseCrates(input: List<String>): MutableList<MutableList<String>> {
return input.map {
row -> row.chunked(4).map {
it.trim().replace("[\\[\\]]".toRegex(),... | 0 | Kotlin | 0 | 0 | f06f9b409885dd0df78f16dcc1e9a3e90151abe1 | 2,697 | advent-of-code-2022 | Apache License 2.0 |
src/day24/Day24.kt | easchner | 572,762,654 | false | {"Kotlin": 104604} | package day24
import readInputString
import java.lang.Math.abs
import java.util.PriorityQueue
import kotlin.system.measureNanoTime
enum class Direction { UP, DOWN, LEFT, RIGHT }
data class Blizzard(var x: Int, var y: Int, var dir: Direction)
data class Point(var x: Int, var y: Int)
fun main() {
var maxX = 0
... | 0 | Kotlin | 0 | 0 | 5966e1a1f385c77958de383f61209ff67ffaf6bf | 7,199 | Advent-Of-Code-2022 | Apache License 2.0 |
day13/src/main/kotlin/aoc2015/day13/Day13.kt | sihamark | 581,653,112 | false | {"Kotlin": 263428, "Shell": 467, "Batchfile": 383} | package aoc2015.day13
import aoc2015.utility.allPermutations
object Day13 {
private val effects by lazy { Effects(input.map { Parser.parse(it) }) }
fun calculateHighestEffectWithYou() = (effects.persons + Effects.YOU).calculateHighestHappiness()
fun calculateHighestEffectWithoutYou() = effects.persons.... | 0 | Kotlin | 0 | 0 | 6d10f4a52b8c7757c40af38d7d814509cf0b9bbb | 2,523 | aoc2015 | Apache License 2.0 |
advent-of-code-2022/src/main/kotlin/year_2022/Day15.kt | rudii1410 | 575,662,325 | false | {"Kotlin": 37749} | package year_2022
import util.Pos2
import util.Runner
import util.Triangle
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.sign
fun main() {
/* Part 1 */
fun part1(input: List<String>): Int {
var xRange = Pair(Int.MAX_VALUE, Int.MIN_VALUE)
val rowPos = 2... | 1 | Kotlin | 0 | 0 | ab63e6cd53746e68713ddfffd65dd25408d5d488 | 2,442 | advent-of-code | Apache License 2.0 |
src/main/kotlin/net/hiddevb/advent/advent2019/day02/main.kt | hidde-vb | 224,606,393 | false | null | package net.hiddevb.advent.advent2019.day02
import net.hiddevb.advent.advent2019.intcodeMachine.getDefaultInstructionList
import net.hiddevb.advent.common.initialize
import kotlin.math.floor
/**
* --- Day 2: 1202 Program Alarm ---
*
* REFACTORING
* -----------
*
* - Make a seperate class for the computer
*/
... | 0 | Kotlin | 0 | 0 | d2005b1bc8c536fe6800f0cbd05ac53c178db9d8 | 3,258 | advent-of-code-2019 | MIT License |
src/Day05.kt | graesj | 572,651,121 | false | {"Kotlin": 10264} | import kotlin.math.min
fun main() {
fun List<List<String>>.transpose(): MutableList<MutableList<String>> {
val colList = mutableListOf<MutableList<String>>()
(0..this.last().size).map { col ->
colList.add(col, mutableListOf())
this.indices.forEach { height ->
... | 0 | Kotlin | 0 | 0 | df7f855a14c532f3af7a8dc86bd159e349cf59a6 | 2,661 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | realpacific | 573,561,400 | false | {"Kotlin": 59236} | fun main() {
fun convertToRange(text: String): IntRange {
val range = text.split("-").map(String::toInt)
return range.first()..range.last()
}
fun splitInput(text: String): Pair<IntRange, IntRange> {
val input = text.split(",")
val firstElf = convertToRange(input.first())
... | 0 | Kotlin | 0 | 0 | f365d78d381ac3d864cc402c6eb9c0017ce76b8d | 1,399 | advent-of-code-2022 | Apache License 2.0 |
src/Day23.kt | janbina | 112,736,606 | false | null | package Day23
import getInput
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.roundToInt
import kotlin.math.sqrt
import kotlin.test.assertEquals
fun main(args: Array<String>) {
val input = getInput(23).readLines().map { Instruction.fromString(it) }
assertEquals(6241, part1(input))
ass... | 0 | Kotlin | 0 | 0 | 71b34484825e1ec3f1b3174325c16fee33a13a65 | 2,726 | advent-of-code-2017 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.