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/Day22.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | fun main() {
val testInput = readInput("Day22_test")
val testMap = testInput.subList(0, testInput.size - 2).toMap()
val testPath = testInput.last().parsePath()
check(part1(testMap, testPath) == 6032)
check(part2(testMap, testMap.buildTestCubeAdjacentMap(), testPath) == 5031)
val input = readInp... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 12,667 | AOC2022 | Apache License 2.0 |
src/day01/Day01.kt | sanyarajan | 572,663,282 | false | {"Kotlin": 24016} | package day01
import readInput
fun main() {
fun part1(input: List<String>): Pair<Int,Int> {
// get a list of sums of ranges in the list separated by blanks
val list = ArrayList<Int>()
var total=0
input
.asSequence()
.map { it.toIntOrNull() }
.for... | 0 | Kotlin | 0 | 0 | e23413357b13b68ed80f903d659961843f2a1973 | 2,097 | Kotlin-AOC-2022 | Apache License 2.0 |
src/Day01.kt | stevefranchak | 573,628,312 | false | {"Kotlin": 34220} | class CalorieTracker(val n: Int) {
private var topNMaxCalories = List(n) { 0 }
private var runningTotalCaloriesForCurrentElf = 0
init {
require(n >= 1)
}
fun sumTopNMaxCalories(input: List<String>) =
input.forEach(::processLine).run { topNMaxCalories.sum() }
private fun proces... | 0 | Kotlin | 0 | 0 | 22a0b0544773a6c84285d381d6c21b4b1efe6b8d | 1,708 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | dcbertelsen | 573,210,061 | false | {"Kotlin": 29052} | import java.io.File
fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { getScore(it) }
}
fun part2(input: List<String>): Int {
return input.sumOf { getScore(getGame(it)) }
}
val testInput = listOf(
"A Y",
"B X",
"C Z"
)
// test ... | 0 | Kotlin | 0 | 0 | 9d22341bd031ffbfb82e7349c5684bc461b3c5f7 | 1,071 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/staricka/adventofcode2022/Day9.kt | mathstar | 569,952,400 | false | {"Kotlin": 77567} | package com.staricka.adventofcode2022
import com.staricka.adventofcode2022.Day9.Move.Companion.toMove
import kotlin.math.abs
class Day9 : Day {
override val id = 9
private fun computeTailMovement(head: Pair<Int, Int>, tail: Pair<Int, Int>): Pair<Int, Int> {
val (hx, hy) = head
val (tx, ty) = tail
ret... | 0 | Kotlin | 0 | 0 | 2fd07f21348a708109d06ea97ae8104eb8ee6a02 | 2,250 | adventOfCode2022 | MIT License |
src/main/kotlin/days/Day09.kt | Kebaan | 573,069,009 | false | null | package days
import utils.Day
import utils.Direction
import utils.Point
typealias Instruction = Pair<Direction, Int>
fun main() {
Day09.solve()
}
object Day09 : Day<Int>(2022, 9) {
private fun parseInput(input: List<String>): List<Instruction> {
return input.map {
it.split(" ").let { (di... | 0 | Kotlin | 0 | 0 | ef8bba36fedbcc93698f3335fbb5a69074b40da2 | 2,006 | Advent-of-Code-2022 | Apache License 2.0 |
src/y2016/Day14.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2016
import util.md5
object Day14 {
fun part1(salt: String): Int {
val candidates = mutableSetOf<Pair<Int, Char>>()
var currentIdx = 0
val keyIdxs = mutableListOf<Int>()
while (keyIdxs.size < 100) {
candidates.removeIf {
it.first < currentIdx - ... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,621 | advent-of-code | Apache License 2.0 |
src/main/kotlin/aoc23/Day03.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc23
import aoc23.Day03Parser.toSchema
import aoc23.Day03Solution.part1Day03
import aoc23.Day03Solution.part2Day03
import common.Collections.product
import common.Space2D
import common.Space2D.Parser.toPointChars
import common.Space2D.Point
import common.Space2D.PointChar
import common.Space2D.getFor
import c... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 3,703 | aoc | Apache License 2.0 |
src/main/kotlin/aoc2023/Day21.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2023
import aoc2022.utils.MazeToTarget
import utils.*
private data class Pos(val loc: Coordinates, val steps: Int)
private class Garden(input: List<String>): ArrayAsSurface(input) {
fun startCoord(): Coordinates = indexed().firstOrNull { it.second == 'S' }?.first ?: throw IllegalStateException("Cant fi... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 3,553 | aoc-2022-kotlin | Apache License 2.0 |
src/Day23.kt | Tomcat88 | 572,566,485 | false | {"Kotlin": 52372} | import java.awt.geom.Point2D
object Day23 {
fun parseGrid(grid: List<String>): Map<IntPair, Boolean> {
return grid.flatMapIndexed { y, row ->
row.mapIndexedNotNull { x, c ->
if (c == '#') (x to y) to true
else null
}
}.toMap()
}
pri... | 0 | Kotlin | 0 | 0 | 6d95882887128c322d46cbf975b283e4a985f74f | 3,563 | advent-of-code-2022 | Apache License 2.0 |
src/Day17.kt | robinpokorny | 572,434,148 | false | {"Kotlin": 38009} | class CircularList<T>(private val list: List<T>) {
private var index = 0
fun next(): T =
list[index % list.size]
.also { index++ }
fun reset(): Unit {
index = 0
return
}
}
private fun parse(input: List<String>) = input
.single()
.toList()
.mapNotNull {
... | 0 | Kotlin | 0 | 2 | 56a108aaf90b98030a7d7165d55d74d2aff22ecc | 2,900 | advent-of-code-2022 | MIT License |
src/2022/Day12.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2022`
import common.Adj2D
import java.io.File
import java.util.*
fun main() {
Day12().solve()
}
class Day12 {
val input1 = """
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
""".trimIndent()
data class Square(
val height: Int,
var ix:... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 2,751 | advent-of-code | Apache License 2.0 |
src/Day04.kt | jimmymorales | 572,156,554 | false | {"Kotlin": 33914} | fun main() {
fun String.parsePairs(): Pair<IntRange, IntRange> = split(",").map { pair ->
pair.split("-").map(String::toInt).let { (l, h) -> l..h }
}.let { (p1, p2) -> p1 to p2 }
fun part1(input: List<String>): Int = input.map(String::parsePairs)
.count { (p1, p2) ->
p1.interse... | 0 | Kotlin | 0 | 0 | fb72806e163055c2a562702d10a19028cab43188 | 827 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/io/queue/KeysAndRooms.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.queue
import java.util.*
// https://leetcode.com/explore/learn/card/queue-stack/239/conclusion/1391/
class KeysAndRooms {
fun execute(rooms: List<List<Int>>): Boolean {
val stack = Stack<Int>()
val visited = BooleanArray(rooms.size)
stack.push(0)
while (stack.isNotEmpty()) {
stack... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,402 | coding | MIT License |
src/2022/Day02.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | package `2022`
import readInput
fun main() {
fun part1(input: List<String>): Int {
// A, X - Rock
// B, Y - Paper
// C, Z - Scissors
val costs = mapOf(
"A X" to 1 + 3,
"A Y" to 2 + 6,
"A Z" to 3 + 0,
"B X" to 1 + 0,
"B Y"... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 1,159 | aoc-2022-in-kotlin | Apache License 2.0 |
day24/src/main/kotlin/Main.kt | rstockbridge | 159,586,951 | false | null | import java.io.File
fun main() {
println("Part I: the solution is ${solvePartI(readImmuneSystemInputFile(), readInfectionInputFile())}.")
println("Part II: the solution is ${solvePartII(readImmuneSystemInputFile(), readInfectionInputFile())}.")
}
fun readImmuneSystemInputFile(): List<String> {
return File... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 9,760 | AdventOfCode2018 | MIT License |
src/Day08.kt | BrianEstrada | 572,700,177 | false | {"Kotlin": 22757} | fun main() {
// Test Case
val testInput = readInput("Day08_test")
val part1TestResult = Day08.part1(testInput)
println(part1TestResult)
check(part1TestResult == 21)
val part2TestResult = Day08.part2(testInput)
println(part2TestResult)
check(part2TestResult == 8)
// Actual Case
... | 1 | Kotlin | 0 | 1 | 032a4693aff514c9b30e979e63560dc48917411d | 5,002 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/day15.kt | Gitvert | 433,947,508 | false | {"Kotlin": 82286} | import java.util.*
fun day15() {
val lines: List<String> = readFile("day15.txt")
day15part1(lines)
day15part2(lines)
}
fun day15part1(lines: List<String>) {
val cave = getCave(lines)
val answer = findShortestPath(cave) - cave[0][0]
println("15a: $answer")
}
fun day15part2(lines: List<Strin... | 0 | Kotlin | 0 | 0 | 02484bd3bcb921094bc83368843773f7912fe757 | 3,223 | advent_of_code_2021 | MIT License |
src/day08/Day08.kt | Puju2496 | 576,611,911 | false | {"Kotlin": 46156} | package day08
import readInput
import java.util.*
fun main() {
// test if implementation meets criteria from the description, like:
val input = readInput("src/day08", "Day08")
println("Part1")
val treeHeightMatrix = part1(input)
println("Part2")
part2(treeHeightMatrix)
}
private fun part1(inp... | 0 | Kotlin | 0 | 0 | e04f89c67f6170441651a1fe2bd1f2448a2cf64e | 4,244 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2016/Day22.kt | tginsberg | 74,924,040 | false | null | /*
* Copyright (c) 2016 by <NAME>
*/
package com.ginsberg.advent2016
/**
* Advent of Code - Day 22: December 22, 2016
*
* From http://adventofcode.com/2016/day/22
*
*/
class Day22(dfRows: List<String>) {
companion object {
private val DF_ROW = Regex("""^/dev/grid/node-x(\d+)-y(\d+)\s+(\d+)T\s+(\d+... | 0 | Kotlin | 0 | 3 | a486b60e1c0f76242b95dd37b51dfa1d50e6b321 | 1,753 | advent-2016-kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxScoreWords.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 | 3,208 | kotlab | Apache License 2.0 |
LeetCode/0454. 4Sum II/Solution.kt | InnoFang | 86,413,001 | false | {"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410} | /**
* 48 / 48 test cases passed.
* Status: Accepted
* Runtime: 888 ms
*/
class Solution {
fun fourSumCount(A: IntArray, B: IntArray, C: IntArray, D: IntArray): Int {
val store = HashMap<Int, Int>()
C.forEach { i ->
D.forEach { j ->
// val v = store[i + j]
... | 0 | C++ | 8 | 20 | 2419a7d720bea1fd6ff3b75c38342a0ace18b205 | 1,444 | algo-set | Apache License 2.0 |
src/Day04.kt | pavlo-dh | 572,882,309 | false | {"Kotlin": 39999} | fun main() {
fun parseData(input: List<String>) = input.map { line ->
val (firstFrom, firstTo, secondFrom, secondTo) = line.split('-', ',').map(String::toInt)
firstFrom..firstTo to secondFrom..secondTo
}
fun part1(input: List<String>): Long {
val data = parseData(input)
retu... | 0 | Kotlin | 0 | 2 | c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992 | 1,088 | aoc-2022-in-kotlin | Apache License 2.0 |
advent-of-code-2021/src/code/day13/Main.kt | Conor-Moran | 288,265,415 | false | {"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733} | package code.day13
import java.io.File
import java.lang.Integer.max
import kotlin.math.min
val doDump = false
fun main() {
doIt("Day 13 Part 1: Test Input", "src/code/day13/test.input", part1)
doIt("Day 13 Part 1: Real Input", "src/code/day13/part1.input", part1)
doIt("Day 13 Part 2: Test Input", "src/cod... | 0 | Kotlin | 0 | 0 | ec8bcc6257a171afb2ff3a732704b3e7768483be | 4,950 | misc-dev | MIT License |
Kotlin/src/FourSum.kt | TonnyL | 106,459,115 | false | null | /**
* Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target?
* Find all unique quadruplets in the array which gives the sum of target.
*
* Note: The solution set must not contain duplicate quadruplets.
*
* For example, given array S = [1, 0, -1, 0, -2, 2], and tar... | 1 | Swift | 22 | 189 | 39f85cdedaaf5b85f7ce842ecef975301fc974cf | 2,399 | Windary | MIT License |
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day12.kt | jntakpe | 572,853,785 | false | {"Kotlin": 72329, "Rust": 15876} | package com.github.jntakpe.aoc2022.days
import com.github.jntakpe.aoc2022.shared.Day
import com.github.jntakpe.aoc2022.shared.readInputLines
import java.util.*
object Day12 : Day {
override val input = readInputLines(12).map { it.toCharArray() }.toTypedArray()
override fun part1() = solve(listOf(NodeDistanc... | 1 | Kotlin | 0 | 0 | 63f48d4790f17104311b3873f321368934060e06 | 2,011 | aoc2022 | MIT License |
src/day13/Day13.kt | gautemo | 317,316,447 | false | null | package day13
import shared.getText
fun waitTimesId(input: String): Int{
val (earliestString, idsString) = input.lines()
val earliest = earliestString.toInt()
val ids = idsString.split(",").filter { it != "x" }.map { it.toInt() }
var shortest = Int.MAX_VALUE
var shortestId = 0
for(id in ids){... | 0 | Kotlin | 0 | 0 | ce25b091366574a130fa3d6abd3e538a414cdc3b | 1,453 | AdventOfCode2020 | MIT License |
src/main/kotlin/Day02.kt | zychu312 | 573,345,747 | false | {"Kotlin": 15557} | enum class Result {
Win, Loss, Draw;
fun toPoints(): Int = when (this) {
Win -> 6
Draw -> 3
Loss -> 0
}
companion object {
fun fromCharacter(input: Char): Result = when (input) {
'X' -> Loss
'Y' -> Draw
'Z' -> Win
else -> ... | 0 | Kotlin | 0 | 0 | 3e49f2e3aafe53ca32dea5bce4c128d16472fee3 | 3,243 | advent-of-code-kt | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2023/iteration/Permutations.kt | michaelbull | 726,012,340 | false | {"Kotlin": 195941} | package com.github.michaelbull.advent2023.iteration
/* pair */
fun <T> List<T>.permutationPairs(): Sequence<Pair<T, T>> {
return permutations(
length = 2,
permutation = ::permutationPair
)
}
private fun <T> List<T>.permutationPair(indices: IntArray, count: Int): Pair<T, T> {
require(count... | 0 | Kotlin | 0 | 1 | ea0b10a9c6528d82ddb481b9cf627841f44184dd | 2,618 | advent-2023 | ISC License |
src/main/kotlin/day01/trebuchet.kt | cdome | 726,684,118 | false | {"Kotlin": 17211} | package day01
import java.io.File
val numericNumbers = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9")
val wordNumbers = arrayOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
val numbers = wordNumbers + numericNumbers
fun main() {
val instructions = File("src/main/resources/day01-t... | 0 | Kotlin | 0 | 0 | 459a6541af5839ce4437dba20019b7d75b626ecd | 1,299 | aoc23 | The Unlicense |
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day18/day18.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2023.day18
import eu.janvdb.aocutil.kotlin.point2d.Direction
import eu.janvdb.aocutil.kotlin.point2d.Point2D
import eu.janvdb.aocutil.kotlin.readLines
import java.util.*
import kotlin.math.max
import kotlin.math.min
//const val FILENAME = "input18-test.txt"
const val FILENAME = "input18.txt"
fun... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 5,421 | advent-of-code | Apache License 2.0 |
src/main/kotlin/kr/co/programmers/P172927.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/481
class P172927 {
fun solution(picks: IntArray, minerals: Array<String>): Int {
// 곡괭이의 수만큼 5칸마다 구간의 합(가중치)을 구한다.
val mines = mutableListOf<IntArray>()
var numOfPick = picks[0] + picks[1] + picks[2]
for (i... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,964 | algorithm | MIT License |
kotlin/src/katas/kotlin/leetcode/traping_rain_water/TrappingRainWater.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.traping_rain_water
import datsok.*
import org.junit.*
import java.util.*
/**
* https://leetcode.com/problems/trapping-rain-water
*
* Given n non-negative integers representing an elevation map where the width of each bar is 1,
* compute how much water it is able to trap after raining... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 2,220 | katas | The Unlicense |
src/test/kotlin/be/brammeerten/y2022/Day12Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2022
import be.brammeerten.Co
import be.brammeerten.readFile
import be.brammeerten.toAlphabetIndex
import be.brammeerten.toCharList
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.util.LinkedList
class Day12Test {
@Test
fun `part 1a`() {
v... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 6,011 | Advent-of-Code | MIT License |
src/day23/Day23.kt | gautemo | 317,316,447 | false | null | package day23
fun crabCupGame(cupsInput: List<Int>, moves: Int = 100): Map<Int, Cup>{
val max = cupsInput.max()!!
var current = Cup(cupsInput[0], null)
var last = current
val mapByLabel = mutableMapOf<Int, Cup>()
mapByLabel[current.label] = current
for(label in cupsInput){
if(current.la... | 0 | Kotlin | 0 | 0 | ce25b091366574a130fa3d6abd3e538a414cdc3b | 2,107 | AdventOfCode2020 | MIT License |
src/twentythree/Day01.kt | Monkey-Matt | 572,710,626 | false | {"Kotlin": 73188} | package twentythree
fun main() {
val day = "01"
// test if implementation meets criteria from the description:
println("Day$day Test Answers:")
val testInput = readInputLines("Day${day}_test_part1")
val part1 = part1(testInput)
part1.println()
check(part1 == 142)
val testPart2Input = re... | 1 | Kotlin | 0 | 0 | 600237b66b8cd3145f103b5fab1978e407b19e4c | 2,257 | advent-of-code-solutions | Apache License 2.0 |
src/main/kotlin/week3/BeaconExclusion.kt | waikontse | 572,850,856 | false | {"Kotlin": 63258} | package week3
import shared.Puzzle
import week2.Point
import java.math.BigInteger
import kotlin.math.abs
data class SensorBeacon(
val sensorX: Int,
val sensorY: Int,
val beaconX: Int,
val beaconY: Int
) {
val manhattanDistance = abs(sensorX - beaconX) + abs(sensorY - beaconY)
// Return set of... | 0 | Kotlin | 0 | 0 | 860792f79b59aedda19fb0360f9ce05a076b61fe | 4,286 | aoc-2022-in-kotllin | Creative Commons Zero v1.0 Universal |
src/main/kotlin/name/valery1707/problem/leet/code/IntegerToRomanK.kt | valery1707 | 541,970,894 | false | null | package name.valery1707.problem.leet.code
/**
* # 12. Integer to Roman
*
* Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`.
*
* | Symbol | Value |
* |--------|-------|
* | `I` | `1` |
* | `V` | `5` |
* | `X` | `10` |
* | `L` | `50` |
* | `C` | `100` |
* | `D`... | 3 | Kotlin | 0 | 0 | 76d175f36c7b968f3c674864f775257524f34414 | 3,748 | problem-solving | MIT License |
src/Day07.kt | yeung66 | 574,904,673 | false | {"Kotlin": 8143} | fun main() {
data class Directory(val path: String, var size: Int = 0, val children: MutableList<Directory> = mutableListOf())
class Path {
val levels = mutableListOf<String>()
fun toPath(): String {
return "/" + levels.joinToString("/")
}
fun genSub(sub: String): S... | 0 | Kotlin | 0 | 0 | 554217f83e81021229759bccc8b616a6b270902c | 2,735 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/fr/chezbazar/aoc21/day3/Day3.kt | chezbazar | 728,404,822 | false | {"Kotlin": 54427} | package fr.chezbazar.aoc21.day3
import fr.chezbazar.aoc21.computeFrom
import kotlin.math.pow
fun main() {
day3()
day3PartTwo()
}
fun day3() {
val ones = MutableList(12) {0}
val zeros = MutableList(12) {0}
computeFrom("day3/input.txt") {
it.forEachIndexed { index, c ->
when(c) ... | 0 | Kotlin | 0 | 0 | 223f19d3345ed7283f4e2671bda8ac094341061a | 1,943 | adventofcode | MIT License |
src/d17.main.kts | cjfuller | 317,725,797 | false | null | import java.io.File
import kotlin.math.min
import kotlin.math.max
data class Coord(val x: Int, val y: Int, val z: Int, val w: Int) {
fun isActiveNext3D(state: Set<Coord>): Boolean {
val neighbors = sequence {
(-1..1).map { xInc ->
(-1..1).map { yInc ->
(-1..... | 0 | Kotlin | 0 | 0 | c3812868da97838653048e63b4d9cb076af58a3b | 4,024 | adventofcode2020 | MIT License |
src/main/kotlin/com/hopkins/aoc/day11/main.kt | edenrox | 726,934,488 | false | {"Kotlin": 88215} | package com.hopkins.aoc.day11
import java.io.File
import kotlin.math.abs
const val debug = true
const val part = 2
/** Advent of Code 2023: Day 11 */
fun main() {
val lines: List<String> = File("input/input11.txt").readLines()
// Read the galaxies from file
var i = 0
val inputGalaxies: Set<Galaxy> =... | 0 | Kotlin | 0 | 0 | 45dce3d76bf3bf140d7336c4767e74971e827c35 | 2,379 | aoc2023 | MIT License |
src/Day10.kt | PascalHonegger | 573,052,507 | false | {"Kotlin": 66208} | private sealed interface CpuInstruction {
val cycles: Int
object Noop : CpuInstruction {
override val cycles = 1
}
data class AddX(val value: Int) : CpuInstruction {
override val cycles = 2
}
}
private data class RegisterState(val x: Int)
private class CpuSimulator {
private ... | 0 | Kotlin | 0 | 0 | 2215ea22a87912012cf2b3e2da600a65b2ad55fc | 2,515 | advent-of-code-2022 | Apache License 2.0 |
adventofcode/src/main/kotlin/day4.kt | jmfayard | 71,764,270 | false | null | import io.kotlintest.specs.StringSpec
data class Room(val number: Int, val encryped: String, val checksum: String)
class Day4 : StringSpec() { init {
"Parsing" {
val room = "aaaaa-bbb-z-y-x-123[abxyz]".asRoom()
room shouldBe Room(123, "aaaaa-bbb-z-y-x", "abxyz")
}
"Calculing checksum" {
... | 0 | Kotlin | 0 | 1 | 9e92090aa50127a470653f726b80335133dec38b | 2,627 | httplayground | ISC License |
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D17.kt | PsHegger | 325,498,299 | false | null | package io.github.pshegger.aoc.y2020
import io.github.pshegger.aoc.common.BaseSolver
import io.github.pshegger.aoc.common.getCartesianProduct
class Y2020D17 : BaseSolver() {
override val year = 2020
override val day = 17
override fun part1(): Int = solve(false)
override fun part2(): Int = solve(true)... | 0 | Kotlin | 0 | 0 | 346a8994246775023686c10f3bde90642d681474 | 3,243 | advent-of-code | MIT License |
year2020/src/main/kotlin/net/olegg/aoc/year2020/day24/Day24.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2020.day24
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Vector3D
import net.olegg.aoc.year2020.DayOf2020
/**
* See [Year 2020, Day 24](https://adventofcode.com/2020/day/24)
*/
object Day24 : DayOf2020(24) {
private val PATTERN = "(nw|ne|w|e|sw|se)".toRegex()
private ... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,599 | adventofcode | MIT License |
2021/src/main/kotlin/Day3.kt | osipxd | 388,214,845 | false | null | /**
* # Day 3: Binary Diagnostic
*
* The submarine has been making some odd creaking noises, so you ask it
* to produce a diagnostic report just in case.
*
* The diagnostic report (your puzzle input) consists of a list of binary
* numbers which, when decoded properly, can tell you many useful things about
* the... | 0 | Kotlin | 0 | 0 | 66553923d8d221bcd1bd108f701fceb41f4d1cbf | 2,774 | advent-of-code | MIT License |
src/main/kotlin/com/github/shmvanhouten/adventofcode/day13/PathFinder.kt | SHMvanHouten | 109,886,692 | false | {"Kotlin": 616528} | package com.github.shmvanhouten.adventofcode.day13
import com.github.shmvanhouten.adventofcode.day22gridcomputing.Coordinate
class PathFinder {
private val SOURCE_COORDINATE = Coordinate(1, 1)
fun getPathsToVisitedNodes(maze: Maze): Set<Node> {
var visitedNodes = setOf<Node>()
var unvisitedN... | 0 | Kotlin | 0 | 0 | a8abc74816edf7cd63aae81cb856feb776452786 | 2,420 | adventOfCode2016 | MIT License |
src/day22/Main.kt | nikwotton | 572,814,041 | false | {"Kotlin": 77320} | package day22
import day22.Direction.DOWN
import day22.Direction.LEFT
import day22.Direction.RIGHT
import day22.Direction.UP
import day22.Instruction.Move
import day22.Instruction.TURN_LEFT
import day22.Instruction.TURN_RIGHT
import java.io.File
val workingDir = "src/${object {}.javaClass.`package`.name}"
fun main()... | 0 | Kotlin | 0 | 0 | dee6a1c34bfe3530ae6a8417db85ac590af16909 | 12,864 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code2015/src/main/kotlin/day19/Advent19.kt | REDNBLACK | 128,669,137 | false | null | package day19
import indexOfAll
import parseInput
import splitToLines
/**
--- Day 19: Medicine for Rudolph ---
Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very brightly, and he needs medicine.
Red-Nosed Reindeer biology isn't similar to regular reindeer biology; Rudolph is going to need custom-ma... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 4,580 | courses | MIT License |
src/main/kotlin/dev/kosmx/aoc23/stars/StarField.kt | KosmX | 726,056,762 | false | {"Kotlin": 32011} | package dev.kosmx.aoc23.stars
import java.io.File
import java.math.BigInteger
import kotlin.math.abs
operator fun MutableList<MutableList<Char>>.get(x: Int, y: Int): Char {
return this[y][x]
}
fun <T> List<T>.allPairings() = sequence {
for (a in indices) {
for (b in a + 1 ..< size) {
yiel... | 0 | Kotlin | 0 | 0 | ad01ab8e9b8782d15928a7475bbbc5f69b2416c2 | 2,188 | advent-of-code23 | MIT License |
src/Day12.kt | Oktosha | 573,139,677 | false | {"Kotlin": 110908} | typealias Grid = MutableList<MutableList<Int>>
fun main() {
class Position(val h: Int, val w: Int)
operator fun Grid.get(pos: Position): Int {
return this[pos.h][pos.w]
}
operator fun Grid.set(pos: Position, value: Int) {
this[pos.h][pos.w] = value
}
// Same false positive fo... | 0 | Kotlin | 0 | 0 | e53eea61440f7de4f2284eb811d355f2f4a25f8c | 3,213 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/days/model/HauntedWasteland.kt | errob37 | 726,532,024 | false | {"Kotlin": 29748, "Shell": 408} | package days.model
class Network(private val input: List<String>) {
private val _network = createNetwork()
private val _directions = input.first().toList()
fun hopCount(fromNode: Regex, toNode: Regex): Long {
val from = _network.keys.filter { it.matches(fromNode) }
val to = _network.keys.... | 0 | Kotlin | 0 | 0 | 79db6f0f56d207b68fb89425ad6c91667a84d60f | 2,544 | adventofcode-2023 | Apache License 2.0 |
src/main/kotlin/Day02.kt | Vampire | 572,990,104 | false | {"Kotlin": 57326} | fun main() {
val moveScores = mapOf(
"X" to 1,
"Y" to 2,
"Z" to 3
)
val resultScores = mapOf(
"A X" to 3,
"A Y" to 6,
"A Z" to 0,
"B X" to 0,
"B Y" to 3,
"B Z" to 6,
"C X" to 6,
"C Y" to 0,
"C Z" to 3
)
... | 0 | Kotlin | 0 | 0 | 16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f | 978 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day3.kt | Filipe3xF | 433,908,642 | false | {"Kotlin": 30093} | import utils.Day
fun main() = Day(3, { it },
{ calculateSubmarinePowerConsumption(it) },
{ calculateSubmarineLifeSupportRating(it) }
).printResult()
fun calculateSubmarinePowerConsumption(diagnosticReport: List<String>): Int {
val gammaRate = diagnosticReport.stringWithMostCommonCharacters()
val epsil... | 0 | Kotlin | 0 | 1 | 7df9d17f0ac2b1c103b5618ca676b5a20eb43408 | 2,231 | advent-of-code-2021 | MIT License |
day4/src/main/kotlin/Main.kt | joshuabrandes | 726,066,005 | false | {"Kotlin": 47373} | import java.io.File
import kotlin.collections.HashMap
fun main() {
println("------ Advent of Code 2023 - Day 4 -----")
val puzzleInput = getPuzzleInput()
val cards = puzzleInput
.map(Card::fromString)
println("Task 1: Sum of points for all cards: ${cards.sumOf(Card::points)}")
val cardsW... | 0 | Kotlin | 0 | 1 | de51fd9222f5438efe9a2c45e5edcb88fd9f2232 | 2,575 | aoc-2023-kotlin | The Unlicense |
src/2023/2023Day01.kt | bartee | 575,357,037 | false | {"Kotlin": 26727} | fun calibrate_line_numerically(input: String): Int {
// get the numbers from the line
val chars = input.toCharArray()
val (digits, notDigits) = chars.partition { it.isDigit() }
val first = digits.first()
val last = digits.last()
return "$first$last".toInt()
}
fun calibrate_line_verbose(input: String): In... | 0 | Kotlin | 0 | 0 | c7141d10deffe35675a8ca43297460a4cc16abba | 2,036 | adventofcode2022 | Apache License 2.0 |
calendar/day08/Day8.kt | maartenh | 572,433,648 | false | {"Kotlin": 50914} | package day08
import Day
import Lines
import kotlin.math.min
class Day8 : Day() {
override fun part1(input: Lines): Any {
val treeHeights = readInput(input)
val trees = (input.indices).flatMap { x ->
(input.indices).map { y ->
Pair(x, y)
}
}
... | 0 | Kotlin | 0 | 0 | 4297aa0d7addcdc9077f86ad572f72d8e1f90fe8 | 2,734 | advent-of-code-2022 | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2023/Day15.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val input = readInput(2023, 15).readText().trim().split(",")
part1(input)
part2(input)
}
private fun part1(input: List<String>) {
val sum = input.sumOf { hash(it) }
println(sum)
}
private... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 963 | adventofcode | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2022/Day24.kt | colinodell | 572,710,708 | false | {"Kotlin": 105421} | package com.colinodell.advent2022
import java.util.PriorityQueue
class Day24(input: List<String>) {
private val grid = input.toGrid()
private val innerRegion = grid.region().contract(1)
private val start = grid.toList().first { it.first.y == 0 && it.second == '.' }.first
private val goal = grid.toList... | 0 | Kotlin | 0 | 1 | 32da24a888ddb8e8da122fa3e3a08fc2d4829180 | 4,235 | advent-2022 | MIT License |
java/app/src/main/kotlin/com/github/ggalmazor/aoc2021/day22/Day22Kt.kt | ggalmazor | 434,148,320 | false | {"JavaScript": 80092, "Java": 33594, "Kotlin": 14508, "C++": 3077, "CMake": 119} | package com.github.ggalmazor.aoc2021.day22
class Day22Kt(val lines: List<String>) {
fun solvePart1(): Long {
val stage = Cuboid((-50..50), (-50..50), (-50..50))
// val reactorCubes = ReactorCubes.empty()
// operations.filter { (cuboid, _) -> cuboid.within(stage) }.forEach { ... | 0 | JavaScript | 0 | 0 | 7a7ec831ca89de3f19d78f006fe95590cc533836 | 1,938 | aoc2021 | Apache License 2.0 |
src/Day04.kt | ThijsBoehme | 572,628,902 | false | {"Kotlin": 16547} | fun main() {
fun parse(line: String): Triple<IntRange, IntRange, Set<Int>> {
val (first, second) = line.split(',')
val (firstMin, firstMax) = first.split('-')
val (secondMin, secondMax) = second.split('-')
val firstRange = firstMin.toInt()..firstMax.toInt()
val secondRange = ... | 0 | Kotlin | 0 | 0 | 707e96ec77972145fd050f5c6de352cb92c55937 | 1,140 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/algorithms/sorting/MergeSort.kt | vamsitallapudi | 119,534,182 | false | {"Java": 24691, "Kotlin": 20452} | package main.algorithms.sorting
fun main(args: Array<String>) {
val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array
mergeSort(array)
for(i in array) println(i)
}
fun mergeSort(array : IntArray, helper:IntArray = IntArray(array.size), low:Int = 0, h... | 0 | Java | 1 | 1 | 9349fa7488fcabcb9c58ce5852d97996a9c4efd3 | 1,776 | HackerEarth | Apache License 2.0 |
src/Day22.kt | er453r | 572,440,270 | false | {"Kotlin": 69456} | fun main() {
val instructionLineRegex = """(\d+|\w)""".toRegex()
val rightTurns = arrayOf(Vector2d.RIGHT, Vector2d.DOWN, Vector2d.LEFT, Vector2d.UP)
val leftTurns = arrayOf(Vector2d.RIGHT, Vector2d.UP, Vector2d.LEFT, Vector2d.DOWN)
fun part1(input: List<String>): Int {
val instructions = instru... | 0 | Kotlin | 0 | 0 | 9f98e24485cd7afda383c273ff2479ec4fa9c6dd | 7,605 | aoc2022 | Apache License 2.0 |
src/main/kotlin/asaad/DayNine.kt | Asaad27 | 573,138,684 | false | {"Kotlin": 23483} | package asaad
import java.io.File
import kotlin.math.abs
class DayNine(filePath: String) {
private val file = File(filePath)
private val input = readInput(file)
private fun readInput(file: File) = file.bufferedReader().readLines()
fun result() {
println("\tpart1: ${solve(2)}")
println... | 0 | Kotlin | 0 | 0 | 16f018731f39d1233ee22d3325c9933270d9976c | 2,343 | adventOfCode2022 | MIT License |
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day11.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentyone
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.readDayInput
class Day11 : Day<Int> {
private companion object {
const val ENERGY_FLASH_THRESHOLD = 9
}
private data class Position(val x: Int, val y: Int)
private val Position.surroundi... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 3,393 | adventofcode | Apache License 2.0 |
src/Day16.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import kotlin.math.max
class Day16 {
data class CacheKey(val current: List<String>, val openedValve: Set<String>, val remainingTime: Int) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other ... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 4,824 | Advent-Of-Code-2022 | Apache License 2.0 |
src/Day04.kt | thorny-thorny | 573,065,588 | false | {"Kotlin": 57129} | fun main() {
fun decodeLine(line: String) = line
.split(',')
.map {
it
.split('-')
.map(String::toInt)
.let { (start, endInclusive) -> start..endInclusive }
}
.let { (first, second) -> first to second }
fun part1(input:... | 0 | Kotlin | 0 | 0 | 843869d19d5457dc972c98a9a4d48b690fa094a6 | 1,040 | aoc-2022 | Apache License 2.0 |
src/day2/Solution.kt | Zlate87 | 572,858,682 | false | {"Kotlin": 12960} | package day2
import readInput
fun main() {
fun score1(round: String): Int {
val elveHand = Hand.from(round[0])!!
val myHand = Hand.from(round[2])!!
if (elveHand == Hand.ELVE_ROCK && myHand == Hand.MY_ROCK) return 3 + myHand.scoreWhenWih
if (elveHand == Hand.ELVE_ROCK && myHand ==... | 0 | Kotlin | 0 | 0 | 57acf4ede18b72df129ea932258ad2d0e2f1b6c3 | 3,916 | advent-of-code-2022 | Apache License 2.0 |
src/Day15.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | package day15
import java.lang.IllegalArgumentException
import readInput
import kotlin.math.abs
data class Position(val x: Int, val y: Int)
data class Sensor(val position: Position, val closestBeacon: Position)
fun manhattanDistance(a: Position, b: Position) = abs(a.x - b.x) + abs(a.y - b.y)
fun Sensor.covers(p: P... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 3,878 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day09.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | import kotlin.math.abs
// https://adventofcode.com/2022/day/9
fun main() {
fun parseInput(input: List<String>): List<Motion> = input.map(Motion::fromString)
fun part1(input: List<String>): Int {
val motions = parseInput(input)
var rope = Rope()
val visitedPositions = mutableSetOf(rope... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 5,244 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day07/Day07Util.kt | Longtainbin | 573,466,419 | false | {"Kotlin": 22711} | package day07
/**
* 通过dfs重新计算每个目录节点的size
*/
fun calculateDirectorySize(root: Node): Long {
if (root.fileChildren == null && root.dirChildren == null) {
return root.size
}
val fileSum = root.fileChildren?.sumOf { it.size }
val dirSum = root.dirChildren?.sumOf { calculateDirectorySize(it) }
... | 0 | Kotlin | 0 | 0 | 48ef88b2e131ba2a5b17ab80a0bf6a641e46891b | 2,115 | advent-of-code-2022 | Apache License 2.0 |
codeforces/round901/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.round901
private fun solve(): Double {
val (n, m) = readInts()
val d = List(n + 1) { DoubleArray(m - n + 1) }
for (i in 1..n) {
var kPrevBest = 0
for (s in d[i].indices) {
val range = maxOf(kPrevBest - 56, 0)..minOf(kPrevBest + 1, s)
val (kBest, best) = range.minByAndValue { k -> (i + s... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 753 | competitions | The Unlicense |
calendar/day09/Day9.kt | maartenh | 572,433,648 | false | {"Kotlin": 50914} | package day09
import Day
import Lines
import day09.Move.*
import kotlin.math.abs
class Day9 : Day() {
override fun part1(input: Lines): Any {
val moves = readMoves(input)
val board = Board(arrayOf(0 to 0, 0 to 0))
val allTailPositions = moves.map { move ->
board.execute(move)... | 0 | Kotlin | 0 | 0 | 4297aa0d7addcdc9077f86ad572f72d8e1f90fe8 | 2,409 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | frozbiz | 573,457,870 | false | {"Kotlin": 124645} |
fun main() {
fun common_element_in_line(line: String): Char {
line.length
val compartments = Pair(line.take(line.length/2).toSet(), line.substring(line.length/2).toSet())
val intersection = compartments.first.intersect(compartments.second)
return intersection.first()
}
fun ... | 0 | Kotlin | 0 | 0 | 4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388 | 1,014 | 2022-aoc-kotlin | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions53.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
fun test53() {
val array1 = intArrayOf(1, 2, 3, 3, 3, 4, 5, 6)
val array2 = intArrayOf(1, 2, 3, 4, 5, 6, 6, 6)
val array3 = intArrayOf(1, 1, 1, 2, 3, 4, 5, 6)
println("数字3出现的次数为:${getNumberOfK(array1, 3)}")
println("数字6出现的次数为:${getNumberOfK(array2, 6)}")
println("数字1出现的次数为:... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 2,553 | Algorithm | Apache License 2.0 |
src/main/kotlin/aoc/Day08.kt | fluxxion82 | 573,716,300 | false | {"Kotlin": 39632} | package aoc
import aoc.utils.readInput
data class Tree(val value: Int, var scenicValue: Int = 0, var isVisible: Boolean? = null)
enum class Direction {
UP, RIGHT, LEFT, DOWN
}
fun main() {
val testInput = readInput("Day08_test.txt")
val input = readInput("Day08.txt")
fun part1(input: List<String>): ... | 0 | Kotlin | 0 | 0 | 3920d2c3adfa83c1549a9137ffea477a9734a467 | 5,558 | advent-of-code-kotlin-22 | Apache License 2.0 |
src/Day05.kt | shoresea | 576,381,520 | false | {"Kotlin": 29960} | import java.util.*
fun main() {
fun generateStacks(inputs: List<String>): ArrayList<Stack<Char>> {
val stacksCount = (inputs[0].length / 4) + 1
//println("StacksCount :: $stacksCount")
val stacks = ArrayList<Stack<Char>>()
for (i in 1..stacksCount) {
stacks.add(Stack<Ch... | 0 | Kotlin | 0 | 0 | e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e | 2,644 | AOC2022InKotlin | Apache License 2.0 |
src/Day04/Day04.kt | thmsbdr | 574,632,643 | false | {"Kotlin": 6603} | package Day04
import readInput
fun main() {
fun part1(input: List<String>): Int {
var total = 0
input.forEach {
val shifts = it.split(',')
val shiftOne = shifts[0].split('-')
val shiftTwo = shifts[1].split('-')
if (shiftOne[0].toInt() <= shiftTwo[0... | 0 | Kotlin | 0 | 0 | b9ac3ed8b52a95dcc542f4de79fb24163f3929a4 | 1,546 | AoC-2022 | Apache License 2.0 |
src/Day02.kt | rossilor95 | 573,177,479 | false | {"Kotlin": 8837} | fun main() {
// Opponent shapes: A Rock, B Paper, C Scissors
// My shapes: X Rock, Y Paper, Z Scissors
fun part1(input: List<String>): Int {
fun calculateShapeScore(myShape: Char) = when (myShape) {
'X' -> 1
'Y' -> 2
'Z' -> 3
else -> error("Check your ... | 0 | Kotlin | 0 | 0 | 0ed98d0ab5f44b2ccfc625ef091e736c5c748ff0 | 1,871 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day09.kt | djleeds | 572,720,298 | false | {"Kotlin": 43505} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sign
import kotlin.properties.Delegates.observable
data class Motion(val direction: String, val count: Int) {
companion object {
fun parse(line: String) = line.split(" ").let { (dir, count) -> Motion(dir, count.toInt()) }
}
}
data class ... | 0 | Kotlin | 0 | 4 | 98946a517c5ab8cbb337439565f9eb35e0ce1c72 | 2,160 | advent-of-code-in-kotlin-2022 | Apache License 2.0 |
src/Day05.kt | kenyee | 573,186,108 | false | {"Kotlin": 57550} |
fun main() { // ktlint-disable filename
fun calcTopCrates(input: List<String>, multiMove: Boolean = false): String {
var stackCountIndex = 0
var stackCount = 0
for (i in input.indices) {
if (input[i].startsWith(" 1 ")) {
stackCount = input[i].split("").filter { ... | 0 | Kotlin | 0 | 0 | 814f08b314ae0cbf8e5ae842a8ba82ca2171809d | 2,298 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/Day07.kt | jbotuck | 573,028,687 | false | {"Kotlin": 42401} | import java.math.BigInteger
fun main() {
val lines = readInput("Day07")
solve(lines)
}
private fun solve(lines: List<String>) {
@Suppress("NAME_SHADOWING")
val lines = ArrayDeque(lines)
val lastVisited = ArrayDeque<Directory>()
val root = Directory("root")
val allFiles = mutableListOf<Syst... | 0 | Kotlin | 0 | 0 | d5adefbcc04f37950143f384ff0efcd0bbb0d051 | 2,954 | aoc2022 | Apache License 2.0 |
src/main/aoc2020/Day23.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2020
class Day23(input: String) {
private val nineCups = input.map { it.toString().toInt() }
private val millionCups = (0 until 1_000_000).map {
if (it < 9) input[it].toString().toInt() else it + 1
}
// cups: (3) 8 9 1 2 5 4 6 7
// Index: 1, 2, 3, 4, 5, 6, 7, 8, 9
/... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,523 | aoc | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day11/day11.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day11
import biz.koziolek.adventofcode.*
import java.util.*
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val map = parseOctopusMap(lines)
println("Flashes after 100 steps: ${countFlashes(map, maxStep = ... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,104 | advent-of-code | MIT License |
src/main/kotlin/aoc2017/SpiralMemory.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2017
fun spiralMemorySteps(index: Int): Int =
distances().drop(index - 1).first()
private fun distances(): Sequence<Int> = sequence {
yield(0)
for (n in 1..Int.MAX_VALUE) {
repeat(4) {
for (v in n * 2 - 1 downTo n)
yield(v)
for... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 1,591 | advent-of-code | MIT License |
src/day17/a/day17a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day17.a
import readInputLines
import shouldBe
import util.IntVector
import vec2
import java.lang.Integer.max
import java.util.*
val shapes = listOf(
listOf(vec2(0,0),vec2(1,0),vec2(2,0),vec2(3,0)),
listOf(vec2(1,0),vec2(0,1),vec2(1,1),vec2(2,1), vec2(1,2)),
listOf(vec2(2,2),vec2(2,1),vec2(2,0),vec... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 2,216 | advent-of-code-2022 | Apache License 2.0 |
src/Day20.kt | MarkTheHopeful | 572,552,660 | false | {"Kotlin": 75535} | import kotlin.math.sign
private fun <T: Number> MutableList<IndexedValue<T>>.mixOn(number: IndexedValue<T>) {
var pos = this.indexOf(number) // O(n)
val n = this.size
var shift = (number.value.toLong() % (n - 1)).toInt()
while (shift != 0) { // O(n). Awful!
val newPos = ((pos + shift.sign) ... | 0 | Kotlin | 0 | 0 | 8218c60c141ea2d39984792fddd1e98d5775b418 | 1,684 | advent-of-kotlin-2022 | Apache License 2.0 |
src/Day09.kt | lassebe | 573,423,378 | false | {"Kotlin": 33148} | import kotlin.math.abs
import kotlin.math.min
fun main() {
val map = (0..40).map { i ->
(0..40).map { j -> j }
}
fun printMap(head: Pair<Int, Int>, tail: Pair<Int, Int>, visited: Map<Pair<Int, Int>, Boolean>) {
// return
map.indices.forEach { i ->
var symbol = " . "
... | 0 | Kotlin | 0 | 0 | c3157c2d66a098598a6b19fd3a2b18a6bae95f0c | 5,233 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/days/Day8.kt | hughjdavey | 725,972,063 | false | {"Kotlin": 76988} | package days
import kotlin.math.max
class Day8 : Day(8) {
private val instructions = getInstructions(inputString.takeWhile { it == 'L' || it == 'R' })
private val network = getNetwork(inputList.drop(2))
override fun partOne(): Any {
return navigateSteps()
}
override fun partTwo(): Any ... | 0 | Kotlin | 0 | 0 | 330f13d57ef8108f5c605f54b23d04621ed2b3de | 2,541 | aoc-2023 | Creative Commons Zero v1.0 Universal |
plugin/src/main/kotlin/com/jraska/module/graph/DependencyGraph.kt | eugene-krivobokov | 414,538,867 | true | {"Kotlin": 40462} | package com.jraska.module.graph
class DependencyGraph private constructor() {
private val nodes = mutableMapOf<String, Node>()
fun findRoot(): Node {
require(nodes.isNotEmpty()) { "Dependency Tree is empty" }
val rootCandidates = nodes().toMutableSet()
nodes().flatMap { it.dependsOn }
.forEach... | 0 | null | 0 | 0 | 22c81583fa04a77074b8cc1f50483273c6f3485d | 3,441 | modules-graph-assert | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-15.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.Coord2D
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
import java.util.*
fun main() {
val input = readInputLines(2021, "15-input")
val test1 = readInputLines(2021, ... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,876 | advent-of-code | MIT License |
2022/src/main/kotlin/Day16.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import Day16.Worker.Active
object Day16 {
fun part1(input: String) = bestRoute(input, 30, 1)
fun part2(input: String) = bestRoute(input, 26, 2)
private fun bestRoute(input: String, time: Int, numWorkers: Int): Int {
val valves = parseInput(input)
val distanceMap = generateDistanceMap(valves)
val u... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 4,559 | advent-of-code | MIT License |
src/day15/Solution.kt | chipnesh | 572,700,723 | false | {"Kotlin": 48016} | @file:OptIn(ExperimentalStdlibApi::class)
package day15
import Coords
import MAX
import length
import plus
import readInput
import kotlin.math.absoluteValue
fun main() {
fun part1(input: List<String>): Long {
val sensors = Sensors.ofInput(input)
return sensors
.scanRangesAt(2000000)
... | 0 | Kotlin | 0 | 1 | 2d0482102ccc3f0d8ec8e191adffcfe7475874f5 | 3,106 | AoC-2022 | Apache License 2.0 |
2021/src/main/kotlin/com/trikzon/aoc2021/Day3.kt | Trikzon | 317,622,840 | false | {"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397} | package com.trikzon.aoc2021
import kotlin.math.pow
fun main() {
val input = getInputStringFromFile("/day3.txt")
println(dayThreePartTwo(input))
}
fun dayThreePartOne(input: String): Int {
val lines = input.lines()
var gammaRate = 0
var epsilonRate = 0
for (i in 0 until lines[0].length) {
... | 0 | Kotlin | 1 | 0 | d4dea9f0c1b56dc698b716bb03fc2ad62619ca08 | 2,518 | advent-of-code | MIT License |
src/Day07.kt | underwindfall | 573,471,357 | false | {"Kotlin": 42718} | private const val CD = "$ cd "
fun main() {
val dayId = "07"
val input = readInput("Day${dayId}")
class Dir(val up: Dir? = null) {
val sd = HashMap<String, Dir>()
val fs = HashMap<String, Long>()
var sum = 0L
}
val root = Dir()
var cd = root
for (c in input) {
... | 0 | Kotlin | 0 | 0 | 0e7caf00319ce99c6772add017c6dd3c933b96f0 | 1,474 | aoc-2022 | Apache License 2.0 |
src/Day05.kt | kmakma | 574,238,598 | false | null | fun main() {
data class Move(val count: Int, val source: Int, val target: Int)
class CrateStacks(input: List<String>) {
val stacks = mutableMapOf<Int, ArrayDeque<Char>>()
val moves = mutableListOf<Move>()
init {
var parseMoves = false
input.forEach { line ->
... | 0 | Kotlin | 0 | 0 | 950ffbce2149df9a7df3aac9289c9a5b38e29135 | 2,523 | advent-of-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/KRadiusSubarrayAverages.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <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 | 3,363 | kotlab | Apache License 2.0 |
src/day08/Day08.kt | GrzegorzBaczek93 | 572,128,118 | false | {"Kotlin": 44027} | package day08
import readInput
import utils.withStopwatch
import kotlin.math.max
fun main() {
val testInput = readInput("input08_test")
withStopwatch { println(part1(testInput)) }
withStopwatch { println(part2(testInput)) }
val input = readInput("input08")
withStopwatch { println(part1(input)) }
... | 0 | Kotlin | 0 | 0 | 543e7cf0a2d706d23c3213d3737756b61ccbf94b | 2,971 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/schlaubi/aoc/days/Day8.kt | DRSchlaubi | 573,014,474 | false | {"Kotlin": 21541} | package dev.schlaubi.aoc.days
import dev.schlaubi.aoc.Day
import kotlin.io.path.readLines
object Day8 : Day<List<List<Int>>>() {
override val number: Int = 8
override fun prepare(): List<List<Int>> = input.readLines().map {
it.toCharArray().map(Char::digitToInt)
}.reversed()
override fun tas... | 1 | Kotlin | 0 | 4 | 4514e4ac86dd3ed480afa907d907e3ae26457bba | 2,365 | aoc-2022 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.