path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-03.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2021, "03-input")
val test1 = readInputLines(2021, "03-test1")
println("Part1:")
part1(test1).println()
p... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,673 | advent-of-code | MIT License |
src/day14/Day14.kt | PoisonedYouth | 571,927,632 | false | {"Kotlin": 27144} | package day14
import readInput
import kotlin.math.max
import kotlin.math.min
private data class Point(val x: Int, val y: Int)
private val sandSource = Point(500, 0)
fun main() {
fun Point.to(other: Point) = if (x == other.x) {
(min(y, other.y)..max(y, other.y)).map { Point(x, it) }
} else {
... | 0 | Kotlin | 1 | 0 | dbcb627e693339170ba344847b610f32429f93d1 | 2,751 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day13.kt | makohn | 571,699,522 | false | {"Kotlin": 35992} | fun main() {
val day = "13"
fun eval(str: MutableList<Char>): List<Any> {
val list = mutableListOf<Any>()
var cs = ""
while (str.isNotEmpty()) {
when (val c = str.removeFirst()) {
in '0'..'9' -> cs+=c
'[' -> list.add(eval(str))
... | 0 | Kotlin | 0 | 0 | 2734d9ea429b0099b32c8a4ce3343599b522b321 | 2,352 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/day2.kt | Arch-vile | 572,557,390 | false | {"Kotlin": 132454} | package day2
import aoc.utils.decode
import aoc.utils.getLooping
import aoc.utils.readInput
// S = scissors
// R = rock
// P = paper
// wins suite before it on list and loses to suite after it
// loop if out of bounds
val suites = listOf("R", "P", "S")
val opponent = listOf("A", "B", "C")
val us = listOf("X", "Y", "Z... | 0 | Kotlin | 0 | 0 | e737bf3112e97b2221403fef6f77e994f331b7e9 | 1,531 | adventOfCode2022 | Apache License 2.0 |
src/main/kotlin/de/p58i/utils/tableoptimizer/solver/evolutionary/DefaultFunctions.kt | mspoeri | 529,728,917 | false | {"Kotlin": 30057} | package de.p58i.utils.tableoptimizer.solver.evolutionary
import de.p58i.utils.tableoptimizer.model.Group
import de.p58i.utils.tableoptimizer.model.Pairing
import de.p58i.utils.tableoptimizer.model.Problem
import de.p58i.utils.tableoptimizer.model.Solution
import de.p58i.utils.tableoptimizer.model.Table
import de.p58i.... | 4 | Kotlin | 0 | 2 | 7e8765be47352e79b45f6ff0f8e6396e3da9abc9 | 4,644 | table-optimizer | MIT License |
src/Day20.kt | jstapels | 572,982,488 | false | {"Kotlin": 74335} |
fun main() {
val day = 20
fun decrypt(data: List<Pair<Int, Long>>): List<Pair<Int, Long>> {
val nums = data.toMutableList()
debug(data)
nums.indices
.forEach { idx ->
val offset = nums.indexOfFirst { it.first == idx }
val s = nums[offset]
... | 0 | Kotlin | 0 | 0 | 0d71521039231c996e2c4e2d410960d34270e876 | 1,589 | aoc22 | Apache License 2.0 |
src/Day09.kt | andydenk | 573,909,669 | false | {"Kotlin": 24096} | import java.lang.IllegalStateException
import kotlin.math.abs
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day09_test")
val largerTestInput = readInput("Day09_test_larger")
val input = readInput("Day09")
val part1Test = part1(testInpu... | 0 | Kotlin | 0 | 0 | 1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1 | 4,047 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | ShuffleZZZ | 572,630,279 | false | {"Kotlin": 29686} | import java.util.*
private fun stackPeeks(input: List<List<String>>, move: (List<Stack<Char>>, Int, Int, Int) -> Unit): String {
val (towers, instructions) = input
val stacksSize = towers.last().split("\\s+".toRegex()).last().toInt()
val stacks = List(stacksSize) { Stack<Char>() }
for (i in (0 until t... | 0 | Kotlin | 0 | 0 | 5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e | 1,582 | advent-of-code-kotlin | Apache License 2.0 |
src/Day07.kt | AleksanderBrzozowski | 574,061,559 | false | null | import Day07.Back
import Day07.ChangeDirectory
import Day07.Directory
import Day07.File
import Day07.Instruction
import Day07.ListFiles
class Day07 {
sealed interface Instruction
object Back : Instruction
data class ChangeDirectory(val toDir: String) : Instruction
object ListFiles : Instruction
da... | 0 | Kotlin | 0 | 0 | 161c36e3bccdcbee6291c8d8bacf860cd9a96bee | 5,491 | kotlin-advent-of-code-2022 | Apache License 2.0 |
day16/src/main/kotlin/App.kt | ascheja | 317,918,055 | false | null | package net.sinceat.aoc2020.day16
import kotlin.properties.Delegates
fun main() {
run {
val parseResult = parseInput("testinput.txt")
println(parseResult.calculateScanningErrorRate())
}
run {
val parseResult = parseInput("input.txt")
println(parseResult.calculateScanningErr... | 0 | Kotlin | 0 | 0 | f115063875d4d79da32cbdd44ff688f9b418d25e | 3,857 | aoc2020 | MIT License |
src/Day05.kt | mvmlisb | 572,859,923 | false | {"Kotlin": 14994} | fun main() {
val part1 = solve(false)
val part2 = solve(true)
println(part1)
println(part2)
}
private fun solve(reverseFirstCrates: Boolean): String {
val input = readInput("Day05_test")
val lineIndexWithCrateStackNumbers = input.indexOfFirst { it.matches("^[\\s,1-9]*\$".toRegex()) }
val ... | 0 | Kotlin | 0 | 0 | 648d594ec0d3b2e41a435b4473b6e6eb26e81833 | 1,797 | advent_of_code_2022 | Apache License 2.0 |
src/Day09.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import kotlin.math.abs
fun main() {
val direction = mapOf(
"D" to (-1 to 0),
"U" to (1 to 0),
"L" to (0 to -1),
"R" to (0 to 1)
)
fun stepCloser(head: Int, tail: Int): Int = when {
head > tail -> tail + 1
head < tail -> tail - 1
else -> tail
}
... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 1,994 | Advent-Of-Code-2022 | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2023/d08/Day08.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d08
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.lcm
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.readLines
data class State(val node: String, val i: Int)
data class EndCondition(val solutions: Set<Int>, val modulo: Int, v... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 3,513 | advent-of-code | MIT License |
src/Day15.kt | er453r | 572,440,270 | false | {"Kotlin": 69456} | import kotlin.math.max
import kotlin.math.min
fun main() {
fun parseData(input: List<String>): List<Triple<Vector2d, Vector2d, Int>> = input.map { line ->
line.ints().let {
val sensor = Vector2d(it[0], it[1])
val beacon = Vector2d(it[2], it[3])
val range = (sensor - beac... | 0 | Kotlin | 0 | 0 | 9f98e24485cd7afda383c273ff2479ec4fa9c6dd | 2,538 | aoc2022 | Apache License 2.0 |
src/day16/Code.kt | fcolasuonno | 572,734,674 | false | {"Kotlin": 63451, "Dockerfile": 1340} | package day16
import day02.cartesian
import day06.main
import readInput
fun main() {
val format = """Valve ([A-Z]+) has flow rate=(\d+); tunnels? leads? to valves? ([A-Z, ]+)""".toRegex()
data class Valve(val id: String, val flow: Int, val conn: List<String>)
fun parse(input: List<String>) = input.map {... | 0 | Kotlin | 0 | 0 | 9cb653bd6a5abb214a9310f7cac3d0a5a478a71a | 5,768 | AOC2022 | Apache License 2.0 |
src/main/kotlin/g2801_2900/s2812_find_the_safest_path_in_a_grid/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2801_2900.s2812_find_the_safest_path_in_a_grid
// #Medium #Array #Breadth_First_Search #Binary_Search #Matrix #Union_Find
// #2023_12_06_Time_902_ms_(100.00%)_Space_89.4_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
import kotlin.math.min
class Solution {
fun maximumSafenessFactor(grid... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,939 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/days/Day13.kt | VictorWinberg | 433,748,855 | false | {"Kotlin": 26228} | package days
class Day13 : Day(13) {
private fun parseInput(): Pair<List<Pair<Int, Int>>, List<Pair<String, Int>>> {
var input =
inputString.split("\n\n")[0].split("\n").map { Pair(it.split(",")[0].toInt(), it.split(",")[1].toInt()) }
val instructions =
inputString.split("\... | 0 | Kotlin | 0 | 0 | d61c76eb431fa7b7b66be5b8549d4685a8dd86da | 1,857 | advent-of-code-kotlin | Creative Commons Zero v1.0 Universal |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions45.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import com.qiaoyuang.algorithm.round0.exchange
fun test45() {
printlnResult(intArrayOf(3, 32, 321))
printlnResult(intArrayOf(111, 123, 321))
}
/**
* Questions 45: Give an IntArray, append all integer and find the smallest number that appended
*/
private fun findSmalle... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 2,242 | Algorithm | Apache License 2.0 |
src/day04/Day04.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package day04
import readInput
class Day04 {
fun part1(): Int {
val readInput = readInput("day04/input")
return part1(readInput)
}
fun part2(): Int {
val readInput = readInput("day04/input")
return part2(readInput)
}
fun part1(input: List<String>): Int =
i... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 1,582 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/pl/mrugacz95/aoc/day24/day24.kt | mrugacz95 | 317,354,321 | false | null | package pl.mrugacz95.aoc.day24
import pl.mrugacz95.aoc.day19.first
operator fun Pair<Int, Int>.plus(other: Pair<Int, Int>): Pair<Int, Int> {
return Pair(first + other.first, second + other.second)
}
enum class Direction(val delta: Pair<Int, Int>) {
E(Pair(+1, 0)),
SE(Pair(0, 1)),
SW(Pair(-1, 1)),
... | 0 | Kotlin | 0 | 1 | a2f7674a8f81f16cd693854d9f564b52ce6aaaaf | 2,862 | advent-of-code-2020 | Do What The F*ck You Want To Public License |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day03/day3.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day03
import biz.koziolek.adventofcode.findInput
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val gammaRate = calculateGammaRate(lines)
val epsilonRate = calculateEpsilonRate(lines)
println("Gamma r... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,373 | advent-of-code | MIT License |
src/Day09.kt | buongarzoni | 572,991,996 | false | {"Kotlin": 26251} | import java.awt.Point
import kotlin.math.sign
fun solveDay09() {
val input = readInput("Day09")
val part1 = solve(input, (1 .. 2).map { Point(1, 1) })
println("Part 1 : $part1")
val part2 = solve(input, (1 .. 10).map { Point(1, 1) })
println("Part 2 : $part2")
}
private fun solve(input: List<Strin... | 0 | Kotlin | 0 | 0 | 96aadef37d79bcd9880dbc540e36984fb0f83ce0 | 1,557 | AoC-2022 | Apache License 2.0 |
src/day15/Day15.kt | palpfiction | 572,688,778 | false | {"Kotlin": 38770} | package day15
import readInput
import kotlin.math.abs
data class Coordinate(val x: Int, val y: Int) {
override fun toString() = "($x, $y)"
}
infix fun Coordinate.distanceTo(other: Coordinate) =
abs(this.x - other.x) + abs(this.y - other.y)
sealed class Object(val coordinate: Coordinate) {
infix fun dist... | 0 | Kotlin | 0 | 0 | 5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7 | 4,110 | advent-of-code | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/arrays_strings/PalindromePermutation.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.arrays_strings
/*
Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome.
A palindrome is a word or phrase that is the same forwards and backwards.
A permutation is a rearrangement of letters.
The palindrome does not need t... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 7,207 | CodingChallenges | Apache License 2.0 |
src/Day03.kt | a2xchip | 573,197,744 | false | {"Kotlin": 37206} | private fun String.toSetOfItemsInside() = this.toCharArray().toSet()
private fun List<Set<Char>>.findCommonItem() = this.fold(this.first()) { acc, chars -> acc.intersect(chars) }.first()
private fun Char.calculatePriority() = if (this.isUpperCase()) {
this - 'A' + 27
} else {
this - 'a' + 1
}
fun main() {
... | 0 | Kotlin | 0 | 2 | 19a97260db00f9e0c87cd06af515cb872d92f50b | 1,889 | kotlin-advent-of-code-22 | Apache License 2.0 |
2022/Day24/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import java.util.ArrayDeque
import kotlin.math.*
val EMPTY = 0
val WALL = 1
val UP = 2
val DOWN = 4
val LEFT = 8
val RIGHT = 16
data class State(val row: Int, val col: Int, val ticks: Int)
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
println(problem1(lines))
p... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 4,295 | AdventOfCode | MIT License |
src/Day13.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | data class Line(var s: String) {
var pos = 0
val c: Char
get() = s[pos]
fun isDigit() = c.isDigit()
fun closed() = pos == s.length
operator fun inc(): Line {
pos++
return this
}
fun addList() {
var end = pos
do {
end++
} while (s[en... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 3,013 | AoC-2022 | Apache License 2.0 |
2017-kotlin/src/main/kotlin/com/morninghacks/aoc2017/Day03.kt | whaley | 116,508,747 | false | null | package com.morninghacks.aoc2017
import kotlin.math.roundToInt
import kotlin.math.sqrt
// let x be the target number
// let y next highest perfect square derived from multiplying odd numbers after and including x //
// let max distance = (square root of y) - 1
// let f(x) = max - ((y - x) % max) <--- this fails f... | 0 | Kotlin | 0 | 0 | 16ce3c9d6310b5faec06ff580bccabc7270c53a8 | 3,258 | advent-of-code | MIT License |
src/Day09.kt | jorander | 571,715,475 | false | {"Kotlin": 28471} | import kotlin.math.abs
typealias Knot = Position2D
private fun Knot.isCloseTo(other: Knot) = (this - other).run { abs(dx) <= 1 && abs(dy) <= 1 }
fun main() {
val day = "Day09"
data class Simulation(
val numberOfExtraKnots: Int = 0,
val head: Knot = Knot(0, 0),
val knots: List<Knot> ... | 0 | Kotlin | 0 | 0 | 1681218293cce611b2c0467924e4c0207f47e00c | 2,963 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | Kaaveh | 572,838,356 | false | {"Kotlin": 13188} | val Char.priority
get(): Int = when (this) {
in 'a'..'z' -> this - 'a' + 1
in 'A'..'Z' -> this - 'A' + 27
else -> error("Wrong input! $this")
}
inline infix fun String.singleIntersect(other: String) = (toSet() intersect other.toSet()).single()
inline infix fun Char.singleIntersect(other... | 0 | Kotlin | 0 | 1 | 9022f1a275e9c058655898b64c196f7a0a494b48 | 1,059 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day24/Day24.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day24
import Coordinate
import bfs
import readInput
import java.util.*
const val day = "24"
data class Board(val board: List<List<List<Char>>>) {
val height = board.size
val width = board.first().size
fun print(location: Coordinate) {
board.forEachIndexed { y, line ->
line.fo... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 4,790 | advent-of-code-22-kotlin | Apache License 2.0 |
src/Day10.kt | cornz | 572,867,092 | false | {"Kotlin": 35639} | fun main() {
fun runInstruction(cycleRegister: Triple<String, Int, Int>): Triple<String, Int, Int> {
var input = cycleRegister.first
return if (input == "noop") {
cycleRegister.copy("", cycleRegister.second + 1, cycleRegister.third)
} else if (input.startsWith("addx ")) {
... | 0 | Kotlin | 0 | 0 | 2800416ddccabc45ba8940fbff998ec777168551 | 3,413 | aoc2022 | Apache License 2.0 |
src/Year2022Day12.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | fun main() {
data class Node(
val i: Int,
val j: Int,
val char: Char,
var distanceToEnd: Int = Int.MAX_VALUE,
) {
val value = when (char) {
'S' -> 0
'E' -> 'z' - 'a'
else -> char - 'a'
}
fun isCanMoveTo(other: Node) =
... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 1,994 | aoc-2022-in-kotlin | Apache License 2.0 |
2k23/aoc2k23/src/main/kotlin/09.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d09
import input.read
fun main() {
println("Part 1: ${part1(read("09.txt"))}")
println("Part 2: ${part2(read("09.txt"))}")
}
fun part1(input: List<String>): Int = input
.map { line ->
line.split(" ")
.map { it.toInt() }
}
.map { numbers ->
val history: List<Lis... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 1,722 | aoc | The Unlicense |
src/day12/Day12.kt | palpfiction | 572,688,778 | false | {"Kotlin": 38770} | package day12
import readInput
import java.lang.IllegalArgumentException
typealias Matrix<T> = MutableList<MutableList<T>>
fun emptyMatrix(x: Int, y: Int) = MutableList(x) { MutableList<Square>(y) { Start } }
fun <T> Matrix<T>.dimensions() = this.size to this[0].size
fun <T> Matrix<T>.print() {
val (rows, colu... | 0 | Kotlin | 0 | 0 | 5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7 | 3,899 | advent-of-code | Apache License 2.0 |
facebook/y2020/round2/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2020.round2
import java.util.*
private fun solve(MOD: Int = 1_000_000_007, maxWeight: Int = 1_000_000_000): Int {
val (n, m, events, k) = readInts()
val edges = n * m + n
val (x, y, ids, weights) = listOf(m to n, m to n, edges to events, maxWeight to events).map { (modulo, length) ->
val array ... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,660 | competitions | The Unlicense |
src/day19.kt | miiila | 725,271,087 | false | {"Kotlin": 77215} | import java.io.File
import kotlin.system.exitProcess
private const val DAY = 19
fun main() {
if (!File("./day${DAY}_input").exists()) {
downloadInput(DAY)
println("Input downloaded")
exitProcess(0)
}
val transformer = { x: String -> x }
val input = parseWorkflowsAndParts(loadIn... | 0 | Kotlin | 0 | 1 | 1cd45c2ce0822e60982c2c71cb4d8c75e37364a1 | 6,505 | aoc2023 | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2023/day07/day7.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2023.day07
import biz.koziolek.adventofcode.findInput
fun main() {
val inputFile = findInput(object {})
val bids = parseCamelBids(inputFile.bufferedReader().readLines())
println("Total winnings are: ${getTotalWinnings(bids)}")
}
data class CamelBid(val hand: CamelHan... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,890 | advent-of-code | MIT License |
day2/src/main/kotlin/day2/Diving.kt | snv | 434,384,799 | false | {"Kotlin": 99328} | package day2
fun main() {
val commands = input.lines()
.map(::parseCommand)
val lastPosition1 = commands
.fold(Position(), Position::execute)
println("""
first part:
Last position is $lastPosition1
Quizanswer is ${lastPosition1.horizontal * lastPosition1.dep... | 0 | Kotlin | 0 | 0 | 0a2d94f278defa13b52f37a938a156666314cd13 | 1,823 | adventOfCode21 | The Unlicense |
src/main/kotlin/days/model/CamelCards.kt | errob37 | 726,532,024 | false | {"Kotlin": 29748, "Shell": 408} | package days.model
enum class GameMode {
NORMAL,
WITH_JOKERS
}
class CamelCards(private val input: List<String>, private val gameMode: GameMode) {
fun totalWinnings() =
createHands()
.sorted()
.mapIndexed { index, hand -> (index + 1) * hand.bid }
.sum()
p... | 0 | Kotlin | 0 | 0 | 79db6f0f56d207b68fb89425ad6c91667a84d60f | 3,113 | adventofcode-2023 | Apache License 2.0 |
src/Day12.kt | 6234456 | 572,616,769 | false | {"Kotlin": 39979} | import java.util.Queue
fun main() {
fun part1(input: List<String>): Int {
val rows = input.size
val cols = input.first().length
val points = Array<IntArray>(rows){
IntArray(cols){0}
}
val ans = Array<IntArray>(rows){
IntArray(cols){Int.MAX_VALUE}
... | 0 | Kotlin | 0 | 0 | b6d683e0900ab2136537089e2392b96905652c4e | 4,031 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | Aldas25 | 572,846,570 | false | {"Kotlin": 106964} | fun main() {
fun part1(r: Int, c: Int, grid: Array<IntArray>): Int {
val visible = Array(r) { BooleanArray(c) { false } }
for (row in 0 until r) {
var highest = -1
for (col in 0 until c) {
if (grid[row][col] > highest) {
visible[row][col]... | 0 | Kotlin | 0 | 0 | 80785e323369b204c1057f49f5162b8017adb55a | 2,564 | Advent-of-Code-2022 | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2021/day10/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2021.day10
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
println(part1())
println(part2())
}
fun part1(): Int {
fun findInvalidChar(line: String): Char {
val stack = StringBuilder()
for (char in line) {
val complement =... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,808 | adventofcode | Apache License 2.0 |
src/day11/b/day11b.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day11.b
import readInputLines
import shouldBe
fun main() {
val monkeys = readInput()
fun doMonkey(m: Monkey) {
val it = m.items.iterator()
while(it.hasNext()) {
val item = it.next(); it.remove()
m.activity++
item.rem = m.operation(item.rem)
... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 2,858 | advent-of-code-2022 | Apache License 2.0 |
src/Day16.kt | jinie | 572,223,871 | false | {"Kotlin": 76283} | import java.util.*
data class Valve(val name: String, val flowRate: Int, val neighbours: MutableList<Valve>, var open: Boolean) {
companion object {
fun of(name: String, flowRate: Int): Valve {
return Valve(name, flowRate, mutableListOf(), false)
}
}
override fun toString(): St... | 0 | Kotlin | 0 | 0 | 4b994515004705505ac63152835249b4bc7b601a | 5,930 | aoc-22-kotlin | Apache License 2.0 |
kotlin/structures/MosAlgorithm.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package structures
// https://www.hackerearth.com/notes/mos-algorithm/
// Solution of http://www.spoj.com/problems/DQUERY/en/
object MosAlgorithm {
fun add(a: IntArray, cnt: IntArray, i: Int): Int {
return if (++cnt[a[i]] == 1) 1 else 0
}
fun remove(a: IntArray, cnt: IntArray, i: Int): Int {
... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 1,520 | codelibrary | The Unlicense |
src/main/kotlin/io/dmitrijs/aoc2022/Day15.kt | lakiboy | 578,268,213 | false | {"Kotlin": 76651} | package io.dmitrijs.aoc2022
import kotlin.math.max
class Day15(input: List<String>) {
private val pairs = input.map {
"""x=(-?\d+), y=(-?\d+)""".toRegex()
.findAll(it)
.toList()
.let { (match1, match2) -> Signal(match1.toPoint(), match2.toPoint()) }
}
fun puzzl... | 0 | Kotlin | 0 | 1 | bfce0f4cb924834d44b3aae14686d1c834621456 | 1,883 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day14.kt | robinpokorny | 572,434,148 | false | {"Kotlin": 38009} | import kotlin.math.max
import kotlin.math.min
private fun line(from: Point, to: Point): List<Point> =
if (from.x == to.x)
(min(from.y, to.y)..max(from.y, to.y)).map { Point(to.x, it) }
else if (from.y == to.y)
(min(from.x, to.x)..max(from.x, to.x)).map { Point(it, to.y) }
else
error... | 0 | Kotlin | 0 | 2 | 56a108aaf90b98030a7d7165d55d74d2aff22ecc | 2,150 | advent-of-code-2022 | MIT License |
src/day18/Day18.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day18
import java.io.File
fun main() {
val data = parse("src/day18/Day18.txt")
println("🎄 Day 18 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)}")
}
enum class Direction {
U, D, L, R
}... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 2,347 | advent-of-code-2023 | MIT License |
src/main/kotlin/days/y2023/day03/Day03.kt | jewell-lgtm | 569,792,185 | false | {"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123} | package days.y2023.day03
import util.InputReader
private class Day03(puzzleInput: String) {
val grid = puzzleInput.lines().filter { it.isNotEmpty() }.map { line -> line.toCharArray().toList() }.toList()
fun partOne(): Int {
val foundNumbers = mutableListOf<Int>()
val digits = mutableListOf<... | 0 | Kotlin | 0 | 0 | b274e43441b4ddb163c509ed14944902c2b011ab | 3,943 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/day03/Day03.kt | mherda64 | 512,106,270 | false | {"Kotlin": 10058} | package day03
import readInput
fun main() {
fun part1(input: List<String>): Int {
val epsilonRate = buildString {
for (column in input[0].indices) {
val (zeroes, ones) = input.countBitsInColumn(column)
append(if (zeroes > ones) '0' else '1')
}
... | 0 | Kotlin | 0 | 0 | d04e179f30ad6468b489d2f094d6973b3556de1d | 1,927 | AoC2021_kotlin | Apache License 2.0 |
src/main/kotlin/Solution.kt | tucuxi | 391,628,300 | false | {"Kotlin": 50486} | class Solution {
fun largestIsland(grid: Array<IntArray>): Int {
val n = grid.size
val firstLabel = 2
val sizes = mutableMapOf<Int, Int>()
fun label(row: Int, col: Int): Int =
if (row !in 0 until n || col !in 0 until n) 0 else grid[row][col]
fun conquerIsland(la... | 0 | Kotlin | 0 | 0 | b44a1d37c84711d98f497e557b5244152041eada | 2,161 | leetcode-make-a-large-island | MIT License |
2017/src/main/kotlin/Day07.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import utils.splitCommas
import utils.splitNewlines
import java.util.regex.Pattern
object Day07 {
private val PATTERN = Pattern.compile("(\\w+) \\((\\d+)\\)( -> (.*))?")
data class Program(val name: String, val weight: Int, val holding: List<String>)
data class BalanceInfo(val totalWeight: Int, val imbalanceN... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 2,672 | advent-of-code | MIT License |
src/main/kotlin/dev/bogwalk/batch4/Problem47.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch4
import dev.bogwalk.util.maths.isPrime
import dev.bogwalk.util.maths.primeFactors
/**
* Problem 47: Distinct Primes Factors
*
* https://projecteuler.net/problem=47
*
* Goal: Find the 1st integers (must be <= N) of K consecutive integers, that have exactly K
* distinct prime factors.
*... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,021 | project-euler-kotlin | MIT License |
src/aoc2022/Day10.kt | Playacem | 573,606,418 | false | {"Kotlin": 44779} | package aoc2022
import utils.readInput
import kotlin.math.abs
private sealed class Instruction {
object Noop : Instruction()
class Add(val modifier: Int): Instruction()
}
private fun createInstruction(input: String): Instruction {
return if (input == "noop") {
Instruction.Noop
} else {
... | 0 | Kotlin | 0 | 0 | 4ec3831b3d4f576e905076ff80aca035307ed522 | 2,332 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | catcutecat | 572,816,768 | false | {"Kotlin": 53001} | import kotlin.system.measureTimeMillis
fun main() {
measureTimeMillis {
Day18.run {
solve1(64) // 4192
solve2(58) // 2520
}
}.let { println("Total: $it ms") }
}
object Day18 : Day.LineInput<Day18.Data, Int>("18") {
class Data(val cubes: Array<Array<BooleanArray>>, ... | 0 | Kotlin | 0 | 2 | fd771ff0fddeb9dcd1f04611559c7f87ac048721 | 2,063 | AdventOfCode2022 | Apache License 2.0 |
2020/src/year2020/day13/Day13.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2020.day12
import util.readAllLines
private fun findFirstBus(filename: String) {
val input = readAllLines(filename)
val timestamp = input[0].toInt()
val buses = input[1].split(",").mapNotNull { it.toIntOrNull() }
var bestId = -1
var bestArrival = Int.MAX_VALUE
buses
.forEac... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 2,497 | adventofcode | MIT License |
src/main/kotlin/day23/Day23.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day23
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day23/Day23.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 23 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 3,169 | advent-of-code-2022 | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day291/day291.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day291
// day291.kt
// By <NAME>, 2020.
/**
* We want to know how many boats of given capacity it requires to carry people of weights given to safety,
* with a maximum of two people per boat.
*
* Strategy: sort the weights by nondecreasing order and proceed recursively.
* If the heaviest person remain... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,290 | daily-coding-problem | MIT License |
src/day02/Solve02.kt | NKorchagin | 572,397,799 | false | {"Kotlin": 9272} | package day02
import utils.*
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
import day02.RPS.*
enum class RPS(val score: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3)
}
fun RPS.customCompare(other: RPS): Int = when {
this == ROCK && other == SCISSORS -> 1
this == SCISSORS && oth... | 0 | Kotlin | 0 | 0 | ed401ab4de38b83cecbc4e3ac823e4d22a332885 | 3,208 | AOC-2022-Kotlin | Apache License 2.0 |
src/day21/Day21.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day21
import readInput
const val day = "21"
fun calculate(monkey: String, monkeyOperationsMap: Map<String, String>): Long {
val operation = monkeyOperationsMap.getValue(monkey)
val operationInt = operation.toLongOrNull()
if (operationInt != null) {
return operationInt
}
val (op... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 1,862 | advent-of-code-22-kotlin | Apache License 2.0 |
src/Day04.kt | Pixselve | 572,907,486 | false | {"Kotlin": 7404} | class SectionRange(range: String) {
private val start: Int
private val end: Int
init {
val split = range.split("-")
this.start = split[0].toInt()
this.end = split[1].toInt()
}
fun contains(value: SectionRange): Boolean {
return value.start >= start && value.end <= e... | 0 | Kotlin | 0 | 0 | 10e14393b8b6ee3f98dfd4c37e32ad81f9952533 | 1,530 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/commonMain/kotlin/advent2020/day18/Day18Puzzle.kt | jakubgwozdz | 312,526,719 | false | null | package advent2020.day18
fun part1(input: String): String {
val lines = input.trim().lineSequence()
// priority: parenthesis, rest
val result = lines
.map { shuntingYard(parse(it).toList()) { prev, _ -> prev != OpenParenthesis } }
.map { rpn(it) }
.sum()
return result.toString... | 0 | Kotlin | 0 | 2 | e233824109515fc4a667ad03e32de630d936838e | 2,724 | advent-of-code-2020 | MIT License |
src/main/kotlin/day15/Day15.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day15
import geometry.Coord
import geometry.combine
import geometry.fullyContains
import geometry.mdist
import geometry.overlaps
import geometry.x
import geometry.y
import readResourceAsBufferedReader
import kotlin.math.absoluteValue
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
@OptIn(Ex... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 3,406 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/dp/SPS.kt | yx-z | 106,589,674 | false | null | package dp
import util.*
// Shortest Palindromic Supersequence
// given a String S[1..n], find the shortest palindromic superseuqnce of S
fun main(args: Array<String>) {
val arr = "TWENTYONE".toCharArray().toList().toOneArray()
println(arr.sps()) // TWENToYOtNEwt -> 13 (inserted characters are lowercased)
}
fun On... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,679 | AlgoKt | MIT License |
Kotlin/QuickSort.kt | manan025 | 412,155,744 | false | null | import java.util.*
/*
Sample Input & Output :
---------------------
The first line of the input contains an integer 'n' denoting the size of the array
The second line of the input contains 'n' no integers
SAMPLE INPUT & OUTPUT 1
INPUT :
4
98 76 54 32
OUTPUT :
32 54 76 98
SAMPLE INPUT & OUTPUT 2
INPUT :
5
45 45 23 65 1... | 115 | Java | 89 | 26 | c185dcedc449c7e4f6aa5e0d8989589ef60b9565 | 2,105 | DS-Algo-Zone | MIT License |
src/main/kotlin/aoc2015/Day13.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2015
import AoCDay
import aoc2015.Day13.Subject.Guest
import aoc2015.Day13.Subject.Me
import util.illegalInput
import util.match
import util.permutations
// https://adventofcode.com/2015/day/13
object Day13 : AoCDay<Int>(
title = "Knights of the Dinner Table",
part1ExampleAnswer = 330,
part1Ans... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 2,564 | advent-of-code-kotlin | MIT License |
src/Day02.kt | paul-matthews | 433,857,586 | false | {"Kotlin": 18652} |
typealias Command = Pair<String, Int>
typealias DiveState = Triple< /* Horizontal */Int, /* Depth */ Int, /* Aim */ Int>
fun List<String>.toCommands() = map {
with(it.split(" ")) { Command(first(), this[1].toInt()) }
}
fun DiveState.add(firstAdd: Int = 0, secondAdd: Int = 0, thirdAdd: Int = 0) =
copy(first +... | 0 | Kotlin | 0 | 0 | 2f90856b9b03294bc279db81c00b4801cce08e0e | 1,814 | advent-of-code-kotlin-template | Apache License 2.0 |
2021/src/main/kotlin/com/github/afranken/aoc/Day202108.kt | afranken | 434,026,010 | false | {"Kotlin": 28937} | package com.github.afranken.aoc
object Day202108 {
fun part1(inputs: Array<String>): Int {
val input = convert(inputs)
var count = 0
input.forEach {
it.second.forEach {
when (it.length) {
2 -> count++ // 1
4 -> count++ //... | 0 | Kotlin | 0 | 0 | 0140f68e60fa7b37eb7060ade689bb6634ba722b | 2,409 | advent-of-code-kotlin | Apache License 2.0 |
src/aoc2022/Day01.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2022
private fun part1(input: List<String>): Int {
var maxRecordedCalorie = 0
var currentElvesCalorieSum = 0
for (line in input) {
when (val calorie = line.toIntOrNull()) {
null -> currentElvesCalorieSum = 0
else -> currentElvesCalorieSum += calorie
}
... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 1,396 | Kotlin-AOC-2023 | Apache License 2.0 |
src/main/kotlin/io/dmitrijs/aoc2022/Day11.kt | lakiboy | 578,268,213 | false | {"Kotlin": 76651} | package io.dmitrijs.aoc2022
class Day11(input: String) {
private val monkeys = createMonkeys(input)
fun puzzle1() = solve(20) { it / 3L }
fun puzzle2(): Long {
val maxLevel = monkeys.fold(1L) { acc, monkey -> acc * monkey.divisor }
return solve(10_000) { it % maxLevel }
}
privat... | 0 | Kotlin | 0 | 1 | bfce0f4cb924834d44b3aae14686d1c834621456 | 2,706 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day18.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | private fun neighbors(rock: Triple<Int, Int, Int>) = listOf(
rock.copy(first = rock.first + 1),
rock.copy(first = rock.first - 1),
rock.copy(second = rock.second + 1),
rock.copy(second = rock.second - 1),
rock.copy(third = rock.third + 1),
rock.copy(third = rock.third - 1),
)
fun main() {
v... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 1,554 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | nguyendanv | 573,066,311 | false | {"Kotlin": 18026} | fun main() {
fun part1(input: List<String>): Int {
return input
.flatMap {
val first = it.subSequence(0, it.length / 2).toSet()
val second = it.subSequence(it.length / 2, it.length).toSet()
first.intersect(second).toList()
}
... | 0 | Kotlin | 0 | 0 | 376512583af723b4035b170db1fa890eb32f2f0f | 1,084 | advent2022 | Apache License 2.0 |
src/Day08.kt | papichulo | 572,669,466 | false | {"Kotlin": 16864} | fun main() {
fun isVisible(x: Int, y: Int, matrix: List<String>): Boolean {
if (x == 0 || x == matrix[0].lastIndex || y == 0 || y == matrix.lastIndex) return true
val tree = matrix[x][y]
val yArray = matrix.map { it[x] }
return (0 until x).none { matrix[y][it] >= tree } ||
... | 0 | Kotlin | 0 | 0 | e277ee5bca823ce3693e88df0700c021e9081948 | 1,092 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day16/Day16.kt | Nathan-Molby | 572,771,729 | false | {"Kotlin": 95872, "Python": 13537, "Java": 3671} | package Day16
import readInput
import java.util.Dictionary
import java.util.PriorityQueue
import kotlin.math.*
class Valve (val id: String, val flowRate: Int) {
var connectedValves = mutableListOf<Valve>()
fun addConnectedValves(vararg valves: Valve) {
connectedValves.addAll(valves)
}
}
class No... | 0 | Kotlin | 0 | 0 | 750bde9b51b425cda232d99d11ce3d6a9dd8f801 | 9,964 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day01.kt | rgawrys | 572,698,359 | false | {"Kotlin": 20855} | import utils.chunkedBy
import utils.readInput
fun main() {
fun part1(input: List<String>): Int = maxCaloriesOfElves(input)
fun part2(input: List<String>): Int = sumCaloriesOfTopElves(input, 3)
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
... | 0 | Kotlin | 0 | 0 | 5102fab140d7194bc73701a6090702f2d46da5b4 | 1,184 | advent-of-code-2022 | Apache License 2.0 |
2021/src/day22/Day22.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day22
import readInput
import java.lang.IllegalStateException
enum class InstructionType { ON, OFF }
data class Bound(val min: Int, val max:Int) {
fun isSmall() = min >= -50 && max <= 50
}
data class Instruction(val type: InstructionType, val xBound: Bound, val yBound: Bound, val zBound: Bound) {
fun ... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 4,938 | advent-of-code | Apache License 2.0 |
src/Day03.kt | handrodev | 577,884,162 | false | {"Kotlin": 7670} | fun main() {
// Map each char to its priority (index 0-based)
val prioMap = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun part1(input: List<String>): Int {
var prioScore = 0
for (line in input) {
val halfLength: Int = line.length / 2
// Divide input int... | 0 | Kotlin | 0 | 0 | d95aeb85b4baf46821981bb0ebbcdf959c506b44 | 1,750 | aoc-2022-in-kotlin | Apache License 2.0 |
2021/src/main/kotlin/day12_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
import utils.mapItems
fun main() {
Day12Func.run()
}
object Day12Func : Solution<Map<String, List<String>>>() {
override val name = "day12"
override val parser = Parser.lines.mapItems {
val (start, end) = it.split('-', limit = 2)
start to end
}.map {
... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,366 | aoc_kotlin | MIT License |
src/Day01.kt | halirutan | 575,809,118 | false | {"Kotlin": 24802} | fun main() {
fun transformInputList(input: List<String>): List<List<Int>> {
val result = mutableListOf<List<Int>>()
var container = mutableListOf<Int>()
for (item in input) {
if (item.isEmpty()) {
result.add(container)
container = mutableListOf()
... | 0 | Kotlin | 0 | 0 | 09de80723028f5f113e86351a5461c2634173168 | 1,551 | AoC2022 | Apache License 2.0 |
src/main/kotlin/days/Day8Data.kt | yigitozgumus | 572,855,908 | false | {"Kotlin": 26037} | package days
import utils.SolutionData
fun main() = with(Day8Data()) {
solvePart1()
solvePart2()
}
class Day8Data : SolutionData(inputFile = "inputs/day8.txt") {
val grid = rawData.map { line -> line.map { it.toString().toInt() } }
val borders = rawData.first().length * 2 + (rawData.size - 2) * 2
fun proc... | 0 | Kotlin | 0 | 0 | 9a3654b6d1d455aed49d018d9aa02d37c57c8946 | 1,703 | AdventOfCode2022 | MIT License |
src/Day03.kt | mandoway | 573,027,658 | false | {"Kotlin": 22353} | fun main() {
fun String.partitionRucksack(): Pair<String, String> {
return substring(0, length / 2) to substring(length / 2)
}
fun intersectRucksack(first: String, second: String): Set<Char> {
return first.toSet() intersect second.toSet()
}
fun Char.toPriority() = if (isLowerCase()... | 0 | Kotlin | 0 | 0 | 0393a4a25ae4bbdb3a2e968e2b1a13795a31bfe2 | 1,163 | advent-of-code-22 | Apache License 2.0 |
src/Day04.kt | rosyish | 573,297,490 | false | {"Kotlin": 51693} | fun fullyContains(x: IntRange, y: IntRange): Boolean {
return (x.first <= y.first && x.last >= y.last) || (y.first <= x.first && y.last >= x.last)
// alternative below inefficient
// return x.all { y.contains(it) } || y.all { x.contains(it) }
}
fun overlaps(x: IntRange, y: IntRange): Boolean {
return ... | 0 | Kotlin | 0 | 2 | 43560f3e6a814bfd52ebadb939594290cd43549f | 1,409 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D19.kt | PsHegger | 325,498,299 | false | null | package io.github.pshegger.aoc.y2020
import io.github.pshegger.aoc.common.BaseSolver
class Y2020D19 : BaseSolver() {
override val year = 2020
override val day = 19
override fun part1(): Int {
val (rules, messages) = parseInput()
val validRegex = "^${calculateRule(rules, false)}$".toRegex(... | 0 | Kotlin | 0 | 0 | 346a8994246775023686c10f3bde90642d681474 | 2,514 | advent-of-code | MIT License |
src/Day14.kt | ShuffleZZZ | 572,630,279 | false | {"Kotlin": 29686} | private data class CurrentUnit(var pile: Int = 500, var height: Int = 0) {
fun diagonalMove(piles: Map<Int, Set<Int>>): Boolean {
if (piles[pile - 1] == null || !piles[pile - 1]!!.contains(height + 1)) {
pile--
height++
return true
}
if (piles[pile + 1] ... | 0 | Kotlin | 0 | 0 | 5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e | 2,862 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day08.kt | jmerle | 434,010,865 | false | {"Kotlin": 60581} | package com.jaspervanmerle.aoc2021.day
class Day08 : Day("321", "1028926") {
private data class Entry(val signalPatterns: List<String>, val outputPatterns: List<String>)
private val entries = input
.lines()
.map { it.split(" | ") }
.map { Entry(it[0].split(" "), it[1].split(" ")) }
... | 0 | Kotlin | 0 | 0 | dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e | 2,515 | advent-of-code-2021 | MIT License |
src/main/kotlin/adventofcode2017/Day24ElectromagneticMoat.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2017
class Day24ElectromagneticMoat
data class Port(val sideA: Int, val sideB: Int) {
val strength: Int
get() = sideA + sideB
}
class Bridge(val ports: List<Port> = listOf()) {
fun totalStrength(): Int = ports.sumOf { it.strength }
val totalLength: Int = ports.size
overr... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 2,342 | kotlin-coding-challenges | MIT License |
archive/2022/Day23.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 110
private const val EXPECTED_2 = 20
private class Day23(isTest: Boolean) : Solver(isTest) {
val dirs = listOf(0 to -1, 1 to -1, 1 to 0, 1 to 1, 0 to 1, -1 to 1, -1 to 0, -1 to -1)
val startCoords = readAsLines().withIndex().flatMap { (y, line) ->
line.withIndex().filter... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 3,196 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day13/day13.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day13
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
import java.lang.IllegalArgumentException
fun main() {
val input = getResourceAsText("/day13/notes.txt")
.split("\n")
.filter { it.isNotEmpty() }
val (earliestTimestamp, buses) = parseBusDa... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 2,419 | advent-of-code-2020 | MIT License |
src/main/kotlin/com/lucaszeta/adventofcode2020/day01/day01.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day01
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
fun findPair(
input: List<Int>,
sumGoal: Int
): Pair<Int, Int> {
val numbers = input.sorted()
for (index in 0 until numbers.size - 1) {
search@ for (secondIndex in (index + 1) until number... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 1,947 | advent-of-code-2020 | MIT License |
src/main/kotlin/g1901_2000/s1977_number_of_ways_to_separate_numbers/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1901_2000.s1977_number_of_ways_to_separate_numbers
// #Hard #String #Dynamic_Programming #Suffix_Array
// #2023_06_21_Time_199_ms_(100.00%)_Space_37.6_MB_(100.00%)
class Solution {
fun numberOfCombinations(str: String): Int {
if (str[0] == '1' && str[str.length - 1] == '1' && str.length > 2000) r... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,110 | LeetCode-in-Kotlin | MIT License |
facebook/y2019/round1/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2019.round1
private fun solve(): Int {
val (n, h, v) = readInts()
val (x, y) = List(2) {
val (x1, x2, ax, bx, cx, dx) = readInts()
val x = IntArray(n)
x[0] = x1
x[1] = x2
for (i in 2 until n) {
x[i] = ((ax * 1L * x[i - 2] + bx * 1L * x[i - 1] + cx) % dx + 1).toInt()
}
x
}
val sor... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,781 | competitions | The Unlicense |
src/Day08.kt | RichardLiba | 572,867,612 | false | {"Kotlin": 16347} | fun main() {
fun readGrid(input: List<String>): List<List<Int>> {
return input.map {
it.map { s -> s.digitToInt() }
}
}
fun visibleTrees(grid: List<List<Int>>): Int {
val n = grid.size
val m = grid[0].size
val visible = Array(n) { BooleanArray(m) }
... | 0 | Kotlin | 0 | 0 | 6a0b6b91b5fb25b8ae9309b8e819320ac70616ed | 1,746 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day16.kt | TinusHeystek | 574,474,118 | false | {"Kotlin": 53071} | import kotlin.math.ceil
class Day16 : Day(16) {
data class Node(val key: String, val rate: Int) {
val valves = mutableListOf<String>()
}
data class Snapshot(val keys: List<String>, val estimate: Int, val opened: Set<String>, val time: Int)
private fun parse(input: List<String>): Map<String, N... | 0 | Kotlin | 0 | 0 | 80b9ea6b25869a8267432c3a6f794fcaed2cf28b | 3,291 | aoc-2022-in-kotlin | Apache License 2.0 |
kotlin/zebra-puzzle/src/main/kotlin/ZebraPuzzle.kt | ErikSchierboom | 27,632,754 | false | {"C++": 14523188, "C": 1712536, "C#": 843402, "JavaScript": 766003, "Java": 570202, "F#": 559855, "Elixir": 504471, "Haskell": 499200, "Shell": 393291, "TypeScript": 381035, "Kotlin": 326721, "Scala": 321830, "Clojure": 303772, "Nim": 283613, "Ruby": 233410, "Elm": 157678, "Crystal": 155384, "Go": 152557, "Gleam": 1500... | import kotlin.math.absoluteValue
enum class Color { Red, Green, Ivory, Yellow, Blue }
enum class Resident { Englishman, Spaniard, Ukrainian, Norwegian, Japanese }
enum class Pet { Dog, Snails, Fox, Horse, Zebra }
enum class Drink { Coffee, Tea, Milk, OrangeJuice, Water }
enum class Smoke { OldGold, Kools, Chesterfield... | 0 | C++ | 10 | 29 | d84c9d48a2d3adb0c37d7bd93c9a759d172bdd8e | 3,318 | exercism | Apache License 2.0 |
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day23/Day23.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2022.day23
import eu.janvdb.aocutil.kotlin.point2d.Direction
import eu.janvdb.aocutil.kotlin.point2d.Point2D
import eu.janvdb.aocutil.kotlin.readLines
//const val FILENAME = "input23-test1.txt"
//const val FILENAME = "input23-test2.txt"
const val FILENAME = "input23.txt"
fun main() {
val elv... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 4,168 | advent-of-code | Apache License 2.0 |
src/Day03.kt | RickShaa | 572,623,247 | false | {"Kotlin": 34294} | fun main() {
val fileName = "day03.txt"
val testFileName = "day03_test.txt"
val input:List<String> = FileUtil.getListOfLines(fileName);
//Helper function for mapping chars to priority numbers
fun createPriorityMap(letters:List<Char>):Map<Char, Int>{
var map = mutableMapOf<Char, Int>()
... | 0 | Kotlin | 0 | 1 | 76257b971649e656c1be6436f8cb70b80d5c992b | 1,902 | aoc | Apache License 2.0 |
src/y2022/Day14.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.Direction
import util.Pos
import util.readInput
object Day14 {
private fun parse(input: List<String>): Set<Pos> {
return input.map { lineToCoordinates(it) }.flatten().toSet()
}
private fun lineToCoordinates(line: String): List<Pos> {
1..5
return line.spli... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 3,201 | advent-of-code | Apache License 2.0 |
src/Day03.kt | purdyk | 572,817,231 | false | {"Kotlin": 19066} | fun main() {
val lOffset = 'a'.code - 1
val uOffset = 'A'.code - 1
fun prio(c: Char): Int {
return if (c.isUpperCase()) {
(c.code - uOffset) + 26
} else {
c.code - lOffset
}
}
fun part1(input: List<String>): String {
val sacks = input.map { ... | 0 | Kotlin | 0 | 0 | 02ac9118326b1deec7dcfbcc59db8c268d9df096 | 1,485 | aoc2022 | Apache License 2.0 |
src/main/kotlin/at/mpichler/aoc/solutions/year2023/Day04.kt | mpichler94 | 656,873,940 | false | {"Kotlin": 196457} | package at.mpichler.aoc.solutions.year2023
import at.mpichler.aoc.lib.Day
import at.mpichler.aoc.lib.PartSolution
open class Part4A : PartSolution() {
internal lateinit var cards: List<Card>
override fun parseInput(text: String) {
val cards = mutableListOf<Card>()
val pattern = "Card +\\d+: +... | 0 | Kotlin | 0 | 0 | 69a0748ed640cf80301d8d93f25fb23cc367819c | 1,660 | advent-of-code-kotlin | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.