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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
examples/src/main/kotlin/Coins.kt | alexbaryzhikov | 201,620,351 | false | null | import com.alexb.constraints.Problem
import com.alexb.constraints.core.constraints.ExactSumConstraint
import kotlin.system.measureTimeMillis
/*
100 coins must sum to $5.00
That's kind of a country-specific problem, since depending on the
country there are different values for coins. Here is presented
the solution for... | 0 | Kotlin | 0 | 0 | e67ae6b6be3e0012d0d03988afa22236fd62f122 | 1,709 | kotlin-constraints | Apache License 2.0 |
src/Day11.kt | jwalter | 573,111,342 | false | {"Kotlin": 19975} | import java.math.BigInteger
class Monkey(
val items: MutableList<BigInteger>,
val operation: (BigInteger) -> BigInteger,
val testValue: Int,
val router: (Boolean) -> Int
) {
var inspections: Long = 0
fun play() {
inspections += items.size
items.forEach {
println(" I... | 0 | Kotlin | 0 | 0 | 576aeabd297a7d7ee77eca9bb405ec5d2641b441 | 3,453 | adventofcode2022 | Apache License 2.0 |
src/day20/Day20.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day20
import readInput
fun main() {
fun simulate(input: List<Pair<Int, Long>>, factor: Long = 1L, iterations: Int = 1): Long {
val inputFactorized = input.map { it.first to it.second * factor }
val list = inputFactorized.toMutableList()
repeat(iterations) {
inputFactor... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 1,256 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | fun main() {
fun readAssignmentPairs(input: List<String>): List<Pair<IntRange, IntRange>> = input.map { line ->
line.split(',').map { range ->
val (from, to) = range.split('-').map { it.toInt() }
from..to
}.toPair()
}
fun IntRange.isFullyContainedWithin(other: IntRan... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 1,042 | advent-of-code-22 | Apache License 2.0 |
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day14.kt | dirkgroot | 317,968,017 | false | {"Kotlin": 187862} | package nl.dirkgroot.adventofcode.year2020
import nl.dirkgroot.adventofcode.util.Input
import nl.dirkgroot.adventofcode.util.Puzzle
class Day14(input: Input) : Puzzle() {
private interface Instruction
private class SetMask(val xMask: Long, val nMask: Long) : Instruction
private class SetMem(val address: L... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 2,318 | adventofcode-kotlin | MIT License |
datastructures/src/main/kotlin/com/kotlinground/datastructures/arrays/intersectionofarrays/intersectionOfArrays.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.datastructures.arrays.intersectionofarrays
fun setIntersection(setOne: Set<Int>, setTwo: Set<Int>): IntArray {
return setOne.intersect(setTwo).toIntArray()
}
/**
* Returns the intersection of two arrays. Uses a set to solve the problem in linear time. A set provides in/contains
* operat... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 1,292 | KotlinGround | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxUncrossedLines.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,374 | kotlab | Apache License 2.0 |
src/main/kotlin/org/example/adventofcode/puzzle/Day04.kt | peterlambrechtDev | 573,146,803 | false | {"Kotlin": 39213} | package org.example.adventofcode.puzzle
import org.example.adventofcode.util.FileLoader
class Range(private val beginning: Int, private val ending: Int) {
fun fullyOverlap(range: Range): Boolean {
return (beginning <= range.beginning && ending >= range.ending)
}
fun partialOverlap(range: Range)... | 0 | Kotlin | 0 | 0 | aa7621de90e551eccb64464940daf4be5ede235b | 2,048 | adventOfCode2022 | MIT License |
src/Day07.kt | OskarWalczak | 573,349,185 | false | {"Kotlin": 22486} |
class TreeNode(val name: String) {
var size: Int = 0
var parent: TreeNode? = null
val children: MutableList<TreeNode> = ArrayList()
val files: MutableMap<String, Int> = HashMap()
fun addToSize(num: Int){
size += num
parent?.addToSize(num)
}
}
fun main() {
var root = TreeN... | 0 | Kotlin | 0 | 0 | d34138860184b616771159984eb741dc37461705 | 2,919 | AoC2022 | Apache License 2.0 |
src/Day25.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | fun main() {
fun part1(input: List<String>): String {
return input.map { SnafuNumber(it) }.reduce{ num1, num2 -> num1.add(num2) }.toString()
}
// fun part2(input: List<String>): String {
// return input.size
// }
val testInput = readInput("Day25_test")
check(part1(testInput) == "2... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 2,609 | aoc2022 | Apache License 2.0 |
src/main/kotlin/Day23.kt | cbrentharris | 712,962,396 | false | {"Kotlin": 171464} | import kotlin.String
import kotlin.collections.List
import Day17.Coordinate
import java.util.*
import kotlin.math.max
object Day23 {
/**
* A more compact representation of a path than a list of coordinates.
*/
data class Segment(val steps: Int, val start: Coordinate, val end: Coordinate)
fun pa... | 0 | Kotlin | 0 | 1 | f689f8bbbf1a63fecf66e5e03b382becac5d0025 | 9,183 | kotlin-kringle | Apache License 2.0 |
src/main/kotlin/com/rtarita/days/Day13.kt | RaphaelTarita | 570,100,357 | false | {"Kotlin": 79822} | package com.rtarita.days
import com.rtarita.structure.AoCDay
import com.rtarita.util.day
import com.rtarita.util.splitTopLevel
import kotlinx.datetime.LocalDate
object Day13 : AoCDay {
override val day: LocalDate = day(13)
private fun parseList(list: String): List<*> {
if (list == "[]") return emptyL... | 0 | Kotlin | 0 | 9 | 491923041fc7051f289775ac62ceadf50e2f0fbe | 2,254 | AoC-2022 | Apache License 2.0 |
src/main/kotlin/solutions/constantTime/iteration6/RegionTaxCalculator.kt | daniel-rusu | 669,564,782 | false | {"Kotlin": 70755} | package solutions.constantTime.iteration6
import dataModel.v3.AccumulatedTaxBracketV2
import dataModel.v3.AccumulatedTaxBracketV2.Companion.toAccumulatedBracketsV2
import dataModel.base.Money
import dataModel.base.TaxBracket
import dataModel.base.TaxCalculator
import solutions.constantTime.iteration5.MinBracketTaxCalc... | 0 | Kotlin | 0 | 1 | 166d8bc05c355929ffc5b216755702a77bb05c54 | 4,406 | tax-calculator | MIT License |
src/Day05.kt | punx120 | 573,421,386 | false | {"Kotlin": 30825} | import java.lang.StringBuilder
fun main() {
fun parseMove(line: String) : Triple<Int, Int, Int> {
val regex = "move (\\d+) from (\\d+) to (\\d+)".toRegex()
val (cnt, from, to) = regex.find(line)!!.destructured
return Triple(cnt.toInt(), from.toInt(), to.toInt()
)
}
fun bui... | 0 | Kotlin | 0 | 0 | eda0e2d6455dd8daa58ffc7292fc41d7411e1693 | 2,438 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day12.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
// https://adventofcode.com/2022/day/12
object Day12 : AoCDay<Int>(
title = "Hill Climbing Algorithm",
part1ExampleAnswer = 31,
part1Answer = 462,
part2ExampleAnswer = 29,
part2Answer = 451,
) {
private class Position(val x: Int, val y: Int)
private class Hei... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,325 | advent-of-code-kotlin | MIT License |
src/year_2023/day_14/Day14.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2023.day_14
import readInput
import util.*
import javax.xml.transform.Source
data class TheField(
val verticalSize: Int,
val horizontalSize: Int,
val movableRocks: List<Point>,
val immovableRocks: List<Point>
)
object Day14 {
/**
*
*/
fun solutionOne(text: List<String... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 6,677 | advent_of_code | Apache License 2.0 |
src/Day13.kt | SergeiMikhailovskii | 573,781,461 | false | {"Kotlin": 32574} | fun main() {
abstract class Item
class Value(val value: Int) : Item()
class Sequence(val items: List<Item>) : Item()
fun findClosingBracket(index: Int, str: String): Int {
var count = 1
var i = index
while (i < str.length) {
i++
if (str[i] == '[') {
... | 0 | Kotlin | 0 | 0 | c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d | 3,766 | advent-of-code-kotlin | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2023/Day06.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
part1()
part2()
}
private fun part1() {
val sum = readInput(2023, 6, sample = false).useLines { sequence ->
val lines = sequence.iterator()
val times = lines.next().substringAfter(... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,055 | adventofcode | Apache License 2.0 |
kotlin/src/main/kotlin/year2023/Day03.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
fun main() {
val input = readInput("Day03")
Day03.part1(input).println()
Day03.part2(input).println()
}
object Day03 {
data class Point(val row: Int, val column: Int, val value: Int)
fun part1(input: List<String>): Int {
val matrix = encapsulateMatrixWithDots(input)
... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 3,737 | advent-of-code | MIT License |
src/2021/Day13_2.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
var switched = false
val points = ArrayList<Pair<Int, Int>>()
val instructions = ArrayList<Pair<String, Int>>()
File("input/2021/day13").forEachLine { line ->
if (line.isEmpty()) {
switched = true
} else {
if (!switched) {
val (x,y) = line.split(",").map { it.toI... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 1,793 | adventofcode | MIT License |
src/Day02.kt | chrisjwirth | 573,098,264 | false | {"Kotlin": 28380} | fun main() {
fun part1AsChoice(letter: Char): String? {
return when (letter) {
'A', 'X' -> "Rock"
'B', 'Y' -> "Paper"
'C', 'Z' -> "Scissors"
else -> null
}
}
fun part2AsChoice(ourLetter: Char, opponentChoice: String): String? {
val win... | 0 | Kotlin | 0 | 0 | d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d | 2,437 | AdventOfCode2022 | Apache License 2.0 |
y2021/src/main/kotlin/adventofcode/y2021/Day09.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
import adventofcode.util.vector.Vec2
import adventofcode.util.vector.neighbors
object Day09 : AdventSolution(2021, 9, "Smoke Basin") {
override fun solvePartOne(input: String): Int {
val grid = parseInput(input)
val lowPoints = grid.... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,594 | advent-of-code | MIT License |
src/day02/Day02.kt | Puju2496 | 576,611,911 | false | {"Kotlin": 46156} | package day02
import readInput
fun main() {
// test if implementation meets criteria from the description, like:
val input = readInput("src/day02", "Day02")
println("Part1")
part1(input)
println("Part2")
part2(input)
}
private fun part1(inputs: List<String>) {
var sum = 0
inputs.forEa... | 0 | Kotlin | 0 | 0 | e04f89c67f6170441651a1fe2bd1f2448a2cf64e | 2,217 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2019/Day12TheNbodyProblem.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2019
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt
class Day12TheNbodyProblem
data class MoonVelocity(var x: Int, var y: Int, var z: Int) {
val kineticEnergy: Int
get() = abs(x) + abs(y) + abs(z)
}
data class JupiterMoon(val id: Int, var x: Int, var y: Int, va... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 4,380 | kotlin-coding-challenges | MIT License |
src/main/kotlin/adventofcode/year2021/Day09SmokeBasin.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2021
import adventofcode.Puzzle
import adventofcode.PuzzleInput
import adventofcode.common.neighbors
import adventofcode.common.product
class Day09SmokeBasin(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val heightMap by lazy { input.lines().map { row -> row.map { col ... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 1,477 | AdventOfCode | MIT License |
src/Day07.kt | Narmo | 573,031,777 | false | {"Kotlin": 34749} | fun main() {
data class Entry(val name: String, var size: Int, val isDirectory: Boolean, val children: MutableList<Entry> = mutableListOf())
fun findEntries(start: Entry, maxSize: Int): List<Entry> {
val result = mutableListOf<Entry>()
if (start.isDirectory && start.size < maxSize) {
result.add(start)
}
... | 0 | Kotlin | 0 | 0 | 335641aa0a964692c31b15a0bedeb1cc5b2318e0 | 3,372 | advent-of-code-2022 | Apache License 2.0 |
y2019/src/main/kotlin/adventofcode/y2019/Day25.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2019
import adventofcode.io.AdventSolution
import adventofcode.language.intcode.IntCodeProgram
fun main() {
Day25.solve()
}
object Day25 : AdventSolution(2019, 25, "Cryostasis") {
override fun solvePartOne(input: String): String {
val foundItems = listOf("fixed point", "whirled... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 2,070 | advent-of-code | MIT License |
src/main/kotlin/days/Day11.kt | andilau | 399,220,768 | false | {"Kotlin": 85768} | package days
typealias Seat = Pair<Int, Int>
typealias Seats = Map<Seat, Day11.State>
typealias SeatsMapNeighbours = Map<Seat, Set<Seat>>
@AdventOfCodePuzzle(
name = "Seating System",
url = "https://adventofcode.com/2020/day/11",
date = Date(day = 11, year = 2020)
)
class Day11(input: List<String>) : Puzz... | 7 | Kotlin | 0 | 0 | 2809e686cac895482c03e9bbce8aa25821eab100 | 3,159 | advent-of-code-2020 | Creative Commons Zero v1.0 Universal |
Kotlin/problems/0055_spiral_matrix_i.kt | oxone-999 | 243,366,951 | true | {"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187} | // Problem Statement
// Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
// Input:
// [
// [ 1, 2, 3 ],
// [ 4, 5, 6 ],
// [ 7, 8, 9 ]
// ]
// Output: [1,2,3,6,9,8,7,4,5]
class Solution constructor(){
fun canWalk(row:Int,col:Int,limits:IntArray) : Boolean... | 0 | null | 0 | 0 | 52dc527111e7422923a0e25684d8f4837e81a09b | 1,726 | algorithms | MIT License |
src/day7/puzzle07.kt | brendencapps | 572,821,792 | false | {"Kotlin": 70597} | package day7
import Puzzle
import PuzzleInput
import java.io.File
class FileSystemEntry(val name: String, val parent: FileSystemEntry? = null, private var size: Long = 0) {
val children = mutableListOf<FileSystemEntry>()
val isDir = size == 0.toLong()
fun getEntrySize(): Long {
if(size == 0.toLong... | 0 | Kotlin | 0 | 0 | 00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3 | 6,207 | aoc_2022 | Apache License 2.0 |
src/Day15.kt | HylkeB | 573,815,567 | false | {"Kotlin": 83982} | import kotlin.math.absoluteValue
fun main() {
data class Sensor(
val x: Int,
val y: Int,
val beaconX: Int,
val beaconY: Int,
val rawData: String
) {
val range: Int = (x - beaconX).absoluteValue + (y - beaconY).absoluteValue
}
fun List<String>.parseSenso... | 0 | Kotlin | 0 | 0 | 8649209f4b1264f51b07212ef08fa8ca5c7d465b | 6,173 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day10.kt | jimmymorales | 572,156,554 | false | {"Kotlin": 33914} | fun main() {
fun List<String>.parseInstructions(operation: (Int, String) -> Unit) {
var x = 1
forEach { line ->
val (inst, n) = line.split(" ").let { it[0] to it.getOrNull(1)?.toInt() }
operation(x, inst)
n?.let { x += it }
}
}
fun part1(input: L... | 0 | Kotlin | 0 | 0 | fb72806e163055c2a562702d10a19028cab43188 | 1,879 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | TheGreatJakester | 573,222,328 | false | {"Kotlin": 47612} | package day12
import utils.forForEach
import utils.readInputAsText
import utils.runSolver
import utils.string.asLines
private typealias SolutionType = Int
private const val defaultSolution = 0
private const val dayNumber: String = "12"
private val testSolution1: SolutionType? = 31
private val testSolution2: Solutio... | 0 | Kotlin | 0 | 0 | c76c213006eb8dfb44b26822a44324b66600f933 | 3,984 | 2022-AOC-Kotlin | Apache License 2.0 |
src/main/kotlin/TrickShot_17.kt | Flame239 | 433,046,232 | false | {"Kotlin": 64209} | import kotlin.math.abs
private val area = Area(211, 232, -124, -69)
private val hittingV0xPerStep = findHittingV0xPerStep()
fun findHittingV0xPerStep(): Map<Int, List<Int>> {
val possibleXSteps = mutableListOf<AxisHit>()
for (Vx0 in 0..area.maxX) {
var curX = 0
for (step in 0..Vx0) {
... | 0 | Kotlin | 0 | 0 | ef4b05d39d70a204be2433d203e11c7ebed04cec | 2,481 | advent-of-code-2021 | Apache License 2.0 |
src/Day14.kt | janbina | 112,736,606 | false | null | package day14
import getInput
import java.util.*
import kotlin.test.assertEquals
fun main(args: Array<String>) {
val input = getInput(14).readLines().first()
assertEquals(8194, part1(input))
assertEquals(1141, part2(input))
}
fun part1(input: String): Int {
return makeMatrix(input).map {
it.... | 0 | Kotlin | 0 | 0 | 71b34484825e1ec3f1b3174325c16fee33a13a65 | 1,795 | advent-of-code-2017 | MIT License |
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day10.kt | Guruth | 328,467,380 | false | {"Kotlin": 188298, "Rust": 13289, "Elixir": 1833} | package sh.weller.adventofcode.twentytwenty
import org.jgrapht.Graph
import org.jgrapht.alg.shortestpath.AllDirectedPaths
import org.jgrapht.graph.DefaultDirectedGraph
import org.jgrapht.graph.DefaultEdge
import sh.weller.adventofcode.util.product
fun List<Int>.findPathsInGraph(): Int {
val sorted = (listOf(0) +... | 0 | Kotlin | 0 | 0 | 69ac07025ce520cdf285b0faa5131ee5962bd69b | 3,342 | AdventOfCode | MIT License |
src/main/kotlin/aoc2022/Day23.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2022
import Point
import readInput
object Day23 {
private enum class Direction {
NORTH, SOUTH, WEST, EAST;
fun getNext() = values()[(this.ordinal + 1) % values().size]
}
/**
* Moves this point into the given [Direction]
*/
private fun Point.moveTo(direction: Dir... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 5,393 | adventOfCode | Apache License 2.0 |
src/Day05.kt | thiyagu06 | 572,818,472 | false | {"Kotlin": 17748} | package aoc22.day05
import aoc22.printIt
import java.io.File
import java.util.TreeMap
fun main() {
fun parseInput(file: String): List<String> {
return File(file).readLines()
}
fun part1(): String {
val lines = parseInput("input/day05.txt")
val (stacks, commands) = parseStacksAndC... | 0 | Kotlin | 0 | 0 | 55a7acdd25f1a101be5547e15e6c1512481c4e21 | 3,514 | aoc-2022 | Apache License 2.0 |
day-03/src/main/kotlin/BinaryDiagnostic.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | fun main() {
println("Part One Solution: ${partOne()}")
println("Part Two Solution: ${partTwo()}")
}
private fun partOne(): Int {
val lines = readLines()
val columns = readColumns(lines)
val mostCommonBits = columns.map {
findMostCommonBit(it)
}.toCharArray().concatToString()
val ... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 2,162 | aoc-2021 | MIT License |
src/Day09.kt | Sasikuttan2163 | 647,296,570 | false | null | import java.awt.Point
import kotlin.math.sign
import kotlin.math.sqrt
fun main() {
val input = readInput("Day09")
val head = Point(0, 0)
val tail = Point(0, 0)
var visitedPoints = mutableListOf(Point(0, 0))
input.forEach { line ->
line.substringAfter(" ").toInt().let {
repeat(it... | 0 | Kotlin | 0 | 0 | fb2ade48707c2df7b0ace27250d5ee240b01a4d6 | 1,872 | AoC-2022-Solutions-In-Kotlin | MIT License |
src/day10/Day10.kt | Regiva | 573,089,637 | false | {"Kotlin": 29453} | package day10
import readLines
import kotlin.math.absoluteValue
fun main() {
val id = "10"
val testOutput = 13140
val testInput = readInput("day$id/Day${id}_test")
println(solve(testInput))
check(solve(testInput) == testOutput)
val input = readInput("day$id/Day$id")
println(solve(input)... | 0 | Kotlin | 0 | 0 | 2d9de95ee18916327f28a3565e68999c061ba810 | 1,465 | advent-of-code-2022 | Apache License 2.0 |
src/y2015/Day03.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2015
import util.Direction
import util.readInput
object Day03 {
private fun parse(input: List<String>): List<Direction> {
return input.first()
.replace('>', 'R')
.replace('<', 'L')
.replace('^', 'U')
.replace('v', 'D')
.map { Direction.f... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 1,450 | advent-of-code | Apache License 2.0 |
tonilopezmr/day 3/SpiralNeighbors.kt | CloudCoders | 112,667,277 | false | {"Mathematica": 37090, "Python": 36924, "Scala": 26540, "Kotlin": 24988, "Ruby": 5084, "Java": 4495, "JavaScript": 3440, "MATLAB": 3013} | package day3
import org.junit.Assert.*
import org.junit.Test
class SpiralNeighbors {
private fun sumNeighbors(spiral: Map<Dimens, Int>, dimen: Dimens): Int =
(spiral[Pair(dimen.first + 1, dimen.second)] ?: 0) +
(spiral[Pair(dimen.first + 1, dimen.second + 1)] ?: 0) +
(spiral[Pair(dimen.fi... | 2 | Mathematica | 0 | 8 | 5a52d1e89076eccb55686e4af5848de289309813 | 2,939 | AdventOfCode2017 | MIT License |
src/main/kotlin/Day14.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.nio.charset.Charset
fun main() {
val testDocs = File("test/day14").readLines(Charset.defaultCharset())
val puzzles = File("puzzles/day14").readLines(Charset.defaultCharset())
fun applyMask(mask: String, number: Long): Long {
val maskCommands = mask.mapIndexed { inde... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 3,636 | aoc2020 | Apache License 2.0 |
src/Day05.kt | PauliusRap | 573,434,850 | false | {"Kotlin": 20299} | private const val INDICATOR_BOX = '['
fun main() {
fun parseBoxConfig(input: List<String>): MutableList<MutableList<Char>> {
val boxes = input.takeWhile { it.contains(INDICATOR_BOX) }
val output = MutableList<MutableList<Char>>(
boxes.last().count { it == INDICATOR_BOX}
) { mut... | 0 | Kotlin | 0 | 0 | df510c3afb104c03add6cf2597c433b34b3f7dc7 | 2,945 | advent-of-coding-2022 | Apache License 2.0 |
src/main/kotlin/y2022/day12/Day12.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2022.day12
import Coord
import Coordinated
import Matrix
import MatrixUtils
import MatrixUtils.filterMatrixElement
import MatrixUtils.forEachMatrixElement
import MatrixUtils.move
import java.lang.IllegalStateException
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 3,081 | AdventOfCode | MIT License |
src/day01/Day01_01.kt | scottpeterson | 573,109,888 | false | {"Kotlin": 15611} | fun main() {
data class Elf(
val calories: List<Int>
) {
val totalCalories: Int get() = calories.sum()
}
fun constructElves(input: List<String>): List<Elf> {
val elves = mutableListOf<Elf>()
var dynamicCalorieList = mutableListOf<Int>()
input.forEach {string ->... | 0 | Kotlin | 0 | 0 | 0d86213c5e0cd5403349366d0f71e0c09588ca70 | 1,183 | advent-of-code-2022 | Apache License 2.0 |
src/2021/Day03.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2021`
import java.io.File
import java.util.*
fun main() {
Day03().solve()
}
data class Count(val i: Int, var all: Int = 0, var ones: Int = 0) {
fun apply(s: String): Count {
++all
if (s[i] == '1') {
++ones
}
return this
}
fun o2filter(ss: List<Stri... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 2,444 | advent-of-code | Apache License 2.0 |
src/main/kotlin/endredeak/aoc2023/Day02.kt | edeak | 725,919,562 | false | {"Kotlin": 26575} | package endredeak.aoc2023
fun main() {
data class GameSet(val r: Long, val g: Long, val b: Long)
data class Game(val id: Long, val sets: List<GameSet>) {
fun isPossible(r: Long, g: Long, b: Long) = sets.all { s -> s.r <= r && s.g <= g && s.b <= b }
fun fewestCubes() = Triple(sets.maxOf { it.r }... | 0 | Kotlin | 0 | 0 | 92c684c42c8934e83ded7881da340222ff11e338 | 1,792 | AdventOfCode2023 | Do What The F*ck You Want To Public License |
src/Day05.kt | SnyderConsulting | 573,040,913 | false | {"Kotlin": 46459} | import java.util.*
fun main() {
fun part1(input: List<String>): String {
val (crateRows, instructions) = input.separateFileSections()
val stackList = mutableListOf<Stack<String>>()
getCrateList(crateRows).forEach { crateList ->
crateList.forEachIndexed { index, string ->
... | 0 | Kotlin | 0 | 0 | ee8806b1b4916fe0b3d576b37269c7e76712a921 | 2,913 | Advent-Of-Code-2022 | Apache License 2.0 |
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day09/Day09.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2022.day09
import eu.janvdb.aocutil.kotlin.readLines
import kotlin.math.abs
//const val FILENAME = "input09-test.txt"
//const val FILENAME = "input09-test2.txt"
const val FILENAME = "input09.txt"
val ORIGIN = Location(0, 0)
fun main() {
runWithSize(2)
runWithSize(10)
}
private fun runWithSiz... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,857 | advent-of-code | Apache License 2.0 |
aoc-2022/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentytwo/Day07.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentytwo
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.head
import fr.outadoc.aoc.scaffold.readDayInput
class Day07 : Day<Int> {
private sealed class Node {
abstract val name: String
abstract val size: Int
data class Directory(
... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 4,826 | adventofcode | Apache License 2.0 |
src/Day01.kt | rod41732 | 572,917,438 | false | {"Kotlin": 85344} | import java.util.*
fun main() {
val elfCalories = readInputRaw("Day01").trim() // prevent trailing endline from causing problem
.split("\n\n")
.map { it.split("\n").sumOf { it.toInt() } }
fun part1(eachElfCalories: List<Int>) = eachElfCalories.max()
fun part2(eachElfCalories: List<Int>) =... | 0 | Kotlin | 0 | 0 | 1d2d3d00e90b222085e0989d2b19e6164dfdb1ce | 1,168 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day13.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2021
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readText
import se.brainleech.adventofcode.verify
class Aoc2021Day13 {
companion object {
private const val DOUBLE_LINE = "\n\n"
private const val NUMBER_SEPARATOR = ","
... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 4,341 | adventofcode | MIT License |
src/main/kotlin/day22.kt | Gitvert | 433,947,508 | false | {"Kotlin": 82286} | fun day22() {
val lines: List<String> = readFile("day22.txt")
day22part1(lines)
day22part2(lines)
}
fun day22part1(lines: List<String>) {
val rebootSteps = mutableListOf<RebootStep>()
lines.forEach {
rebootSteps.add(RebootStep(
it.split(" ")[0] == "on",
findRange(i... | 0 | Kotlin | 0 | 0 | 02484bd3bcb921094bc83368843773f7912fe757 | 2,436 | advent_of_code_2021 | MIT License |
src/main/kotlin/com/groundsfam/advent/y2023/d04/Day04.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d04
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.pow
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
import kotlin.math.min
data class Card(val winners: Set<Int>, val yourNumbers: List<Int>)
fun Card.numMatches() = ... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 1,699 | advent-of-code | MIT License |
src/Day02.kt | Kietyo | 573,293,671 | false | {"Kotlin": 147083} | enum class Result {
WIN,
LOSE,
DRAW
}
sealed interface Option {
object Rock : Option {
override val points: Int = 1
override fun battle(other: Option): Result {
return when (other) {
Paper -> Result.LOSE
Rock -> Result.DRAW
Sci... | 0 | Kotlin | 0 | 0 | dd5deef8fa48011aeb3834efec9a0a1826328f2e | 3,172 | advent-of-code-2022-kietyo | Apache License 2.0 |
src/Day05.kt | rmyhal | 573,210,876 | false | {"Kotlin": 17741} | fun main() {
fun part1(input: List<String>): String {
return crateMover9000(input)
}
fun part2(input: List<String>): String {
return crateMover9001(input)
}
val input = readInput("Day05")
println(part1(input))
println(part2(input))
}
private fun crateMover9000(input: List<String>): String {
v... | 0 | Kotlin | 0 | 0 | e08b65e632ace32b494716c7908ad4a0f5c6d7ef | 2,256 | AoC22 | Apache License 2.0 |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day13.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.y2022.data.Day13Data
object Day13 {
private val input = Day13Data.input
fun part1(): Int = input.toPairs().withIndex().filter { (_, pair) ->
pair.first <= pair.second
}.sumOf { it.index + 1 }
fun part2... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 3,060 | adventofcode2022 | MIT License |
src/Day09.kt | msernheim | 573,937,826 | false | {"Kotlin": 32820} | import kotlin.math.sign
fun main() {
fun moveTail(head: Coord, tail: Coord): Coord {
var tailX = tail.X
var tailY = tail.Y
val dx = (head.X - tail.X)
val dy = (head.Y - tail.Y)
if (dx * dx > 1 || dy * dy > 1) {
tailX += dx.sign
tailY += dy.sign
... | 0 | Kotlin | 0 | 3 | 54cfa08a65cc039a45a51696e11b22e94293cc5b | 2,431 | AoC2022 | Apache License 2.0 |
src/main/kotlin/Day004.kt | teodor-vasile | 573,434,400 | false | {"Kotlin": 41204} | class Day004 {
var counter = 0
fun part1(elfPairs: List<List<String>>): Int {
for (elfPair in elfPairs) {
val firstElf = elfPair[0].split('-').map { it.toInt() }
val secondElf = elfPair[1].split('-').map { it.toInt() }
countContainingRanges(firstElf, secondElf)
... | 0 | Kotlin | 0 | 0 | 2fcfe95a05de1d67eca62f34a1b456d88e8eb172 | 1,805 | aoc-2022-kotlin | Apache License 2.0 |
src/Day05.kt | Intex32 | 574,086,443 | false | {"Kotlin": 3973} | import kotlin.math.ceil
typealias Stack = List<Crate>
@JvmInline
value class Crate(val value: String) {
override fun toString() = "<$value>"
}
data class Instr(
val amount: Int,
val from: Int,
val to: Int,
)
fun main() {
val (rawStacks, rawInstructions) = readInput("Day05")
.filter { it.... | 0 | Kotlin | 0 | 0 | 6b6f12db6b970afc428787b55ba812ce3eeb85eb | 2,456 | aoc-kotlin-2022 | Apache License 2.0 |
src/year2022/day07/standardlibrary/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day07.standardlibrary
import io.kotest.matchers.shouldBe
import utils.readInput
fun main() {
val testInput = readInput("07", "test_input")
val realInput = readInput("07", "input")
val testFileSystem = buildFileSystem(testInput)
val realFileSystem = buildFileSystem(realInput)
tes... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 2,923 | Advent-of-Code | Apache License 2.0 |
src/twentytwo/Day03.kt | mihainov | 573,105,304 | false | {"Kotlin": 42574} | package twentytwo
import readInputTwentyTwo
// ext fun to get the priority of the char according to the task
fun Char.priority(): Int {
val ascii = this.code
return if (this.isUpperCase()) {
ascii - 38
} else {
ascii - 96
}
}
fun main() {
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | a9aae753cf97a8909656b6137918ed176a84765e | 1,265 | kotlin-aoc-1 | Apache License 2.0 |
src/Day02.kt | jamOne- | 573,851,509 | false | {"Kotlin": 20355} | enum class Shape(val value: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
companion object {
fun fromChar(inputChar: Char): Shape {
return when(inputChar) {
'A', 'X' -> ROCK
'B', 'Y' -> PAPER
'C', 'Z' -> SCISSORS
else -> throw Illegal... | 0 | Kotlin | 0 | 0 | 77795045bc8e800190f00cd2051fe93eebad2aec | 2,154 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDistance.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2021 <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 | 4,841 | kotlab | Apache License 2.0 |
src/Day10.kt | konclave | 573,548,763 | false | {"Kotlin": 21601} | fun main() {
fun solve1(input: List<String>): Int {
var total = 0
val ticks = listOf(20, 60, 100, 140, 180, 220)
input.flatMap { it.split(" ") }.foldIndexed(1) { i, acc, str ->
var res = acc
when (str) {
"noop", "addx" -> {}
else -> {
... | 0 | Kotlin | 0 | 0 | 337f8d60ed00007d3ace046eaed407df828dfc22 | 1,277 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/de/niemeyer/aoc2022/Day14.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | /**
* Advent of Code 2022, Day 14:
* Problem Description: https://adventofcode.com/2022/day/14
*/
package de.niemeyer.aoc2022
import de.niemeyer.aoc.points.Point2D
import de.niemeyer.aoc.utils.Resources.resourceAsList
import de.niemeyer.aoc.utils.getClassName
typealias ReservoirMap = Map<Point2D, Char>
fun main(... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 2,889 | AoC-2022 | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[124]二叉树中的最大路径和.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个非空二叉树,返回其最大路径和。
//
// 本题中,路径被定义为一条从树中任意节点出发,沿父节点-子节点连接,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。
//
//
//
// 示例 1:
//
// 输入:[1,2,3]
//
// 1
// / \
// 2 3
//
//输出:6
//
//
// 示例 2:
//
// 输入:[-10,9,20,null,null,15,7]
//
// -10
// / \
// 9 20
// / \
// 15 7
//
//输出:42
// Related Topics 树 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,701 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxNumOfSubstrings.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 | 6,142 | kotlab | Apache License 2.0 |
src/Day07_part1.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | fun main() {
fun part1(input: List<String>): Int {
data class Directory(
val name: String,
var size: Int = 0,
val subDirectories: MutableList<Directory> = mutableListOf()
)
fun changeDirectory(directory: Directory, name: String): Directory {
r... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 2,127 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day16/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day16
import java.io.File
fun main() {
val lines = File("src/main/kotlin/day16/input.txt").readLines()
val bitsIterator =
lines.first().map { hexToBinary(it) }.joinToString(separator = "").iterator()
val packet = Packet.parse(bitsIterator)
println(packet.versionAggregate())
prin... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 3,722 | aoc-2021 | MIT License |
src/main/kotlin/d20/d20.kt | LaurentJeanpierre1 | 573,454,829 | false | {"Kotlin": 118105} | package d20
import readInput
fun part1(input: List<String>): Int {
val numbers = input.map { it.toInt() }.toList()
val list = MutableList(numbers.size) { it }
println(numbers)
println(list)
for (number in numbers.withIndex()) {
val pos = list.indexOf(number.index)
var newPos = (pos... | 0 | Kotlin | 0 | 0 | 5cf6b2142df6082ddd7d94f2dbde037f1fe0508f | 2,536 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/Day14.kt | zirman | 572,627,598 | false | {"Kotlin": 89030} | import kotlin.math.max
import kotlin.math.min
sealed interface Mat {
object Air : Mat
object Rock : Mat
object Sand : Mat
}
fun main() {
fun part1(input: List<String>): Int {
val rockRanges = input
.map { line ->
line.split(" -> ").map { sqrStr ->
... | 0 | Kotlin | 0 | 1 | 2ec1c664f6d6c6e3da2641ff5769faa368fafa0f | 6,290 | aoc2022 | Apache License 2.0 |
src/day07/Day07.kt | molundb | 573,623,136 | false | {"Kotlin": 26868} | package day07
import readInput
fun main() {
val input = readInput(parent = "src/day07", name = "Day07_input")
println(solvePartOne(input))
println(solvePartTwo(input))
}
private fun solvePartOne(input: List<String>): Int {
val b = solve(input, calc1())
return b[0]
}
private fun solvePartTwo(inpu... | 0 | Kotlin | 0 | 0 | a4b279bf4190f028fe6bea395caadfbd571288d5 | 2,022 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/org/wow/learning/PlanetFeatures.kt | WonderBeat | 22,673,830 | false | null | package org.wow.learning
import com.epam.starwors.galaxy.Planet
fun Planet.enemiesNeighbours(): List<Planet> = this.getNeighbours()!!.filter { it.getOwner() != this.getOwner() && it
.getOwner().isNotEmpty() }
fun Planet.friendsNeighbours(): List<Planet> = this.getNeighbours()!!.filter { it.getOwner() == this... | 0 | Kotlin | 0 | 0 | 92625c1e4031ab4439f8d8a47cfeb107c5bd7e31 | 2,134 | suchmarines | MIT License |
src/main/kotlin/Day11.kt | brigham | 573,127,412 | false | {"Kotlin": 59675} | import java.math.BigInteger
val pattern = Regex(
"""Monkey (\d):
{2}Starting items: (.*)
{2}Operation: new = old ([+*]) (old|\d+)
{2}Test: divisible by (.*)
{4}If true: throw to monkey (.*)
{4}If false: throw to monkey (.*)"""
)
enum class Operator {
PLUS {
override fun apply(a: BigInteger, b: Bi... | 0 | Kotlin | 0 | 0 | b87ffc772e5bd9fd721d552913cf79c575062f19 | 4,382 | advent-of-code-2022 | Apache License 2.0 |
src/day04/day04.kt | Dr4kn | 575,092,295 | false | {"Kotlin": 12652} | package day04
import readInput
fun main() {
fun stringToIntArray(sections: String): Array<Int> {
return sections
.split(',', '-')
.map { section ->
section.toInt()
}
.toTypedArray()
}
fun findFullyContained(sectio... | 0 | Kotlin | 0 | 0 | 6de396cb4eeb27ff0dd9a98b56e68a13c2c90cd5 | 1,988 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/day17/Day17.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day17
import days.Day
import java.util.*
import kotlin.collections.HashMap
class Day17 : Day() {
private val heatMap = parseInput(readInput())
override fun partOne(): Any {
val size = readInput().size - 1
val start = Coordinate(0, 0)
//val result = findShortestPath(start,... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 7,510 | advent-of-code_2023 | The Unlicense |
src/main/kotlin/days/Day1.kt | MisterJack49 | 729,926,959 | false | {"Kotlin": 31964} | package days
class Day1(alternate: Boolean = false) : Day(1, alternate) {
override fun partOne(): Any {
return inputList
.map { "${it.findFirstDigit()}${it.findLastDigit()}" }
.sumOf { it.toInt() }
}
override fun partTwo(): Any {
return inputList
.map {
... | 0 | Kotlin | 0 | 0 | 807a6b2d3ec487232c58c7e5904138fc4f45f808 | 2,535 | AoC-2023 | Creative Commons Zero v1.0 Universal |
src/year2022/day22/Day22.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2022.day22
import check
import readInput
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("2022", "Day22_test")
check(part1(testInput), 6032)
check(part2(testInput), 5031)
val input = readInput("2022", "Day22")
println(par... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 10,129 | AdventOfCode | Apache License 2.0 |
src/Day10.kt | icoffiel | 572,651,851 | false | {"Kotlin": 29350} | import kotlin.math.ceil
private const val DAY = "Day10"
fun main() {
fun List<String>.parse() = map {
when {
it.startsWith("noop") -> Command.NoOp()
it.startsWith("addx") -> Command.AddX(it.split(" ")[1].toInt())
else -> error("Invalid command: $it")
... | 0 | Kotlin | 0 | 0 | 515f5681c385f22efab5c711dc983e24157fc84f | 4,238 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2022/day01/day1.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2022.day01
import biz.koziolek.adventofcode.findInput
fun main() {
val inputFile = findInput(object {})
val elves = parseElvesCalories(inputFile.bufferedReader().readLines())
println("Elf with most calories has: ${findElfWithMostCalories(elves)?.totalCalories}")
... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 1,271 | advent-of-code | MIT License |
2023/11/solve-1.kts | gugod | 48,180,404 | false | {"Raku": 170466, "Perl": 121272, "Kotlin": 58674, "Rust": 3189, "C": 2934, "Zig": 850, "Clojure": 734, "Janet": 703, "Go": 595} | import java.io.File
import kotlin.math.abs
class Cosmos (
val observation: List<String>,
) {
private fun String.allIndicesOf(c: Char) = indices.filter { this[it] == c }
val observedEmptyRows : List<Int> = observation.indices
.filter { j -> observation[j].all { it == '.' } }
val observedEmptyC... | 0 | Raku | 1 | 5 | ca0555efc60176938a857990b4d95a298e32f48a | 1,271 | advent-of-code | Creative Commons Zero v1.0 Universal |
src/poyea/aoc/mmxxii/day10/Day10.kt | poyea | 572,895,010 | false | {"Kotlin": 68491} | package poyea.aoc.mmxxii.day10
import poyea.aoc.utils.readInput
private const val WIDTH = 40
fun part1(input: String): Int {
var cycle = 1
var register = 1
var sum = 0
var flags = 0
input.split("\n").map { it.split(" ") }.forEach {
when (it[0]) {
"noop" -> cycle += 1
... | 0 | Kotlin | 0 | 1 | fd3c96e99e3e786d358d807368c2a4a6085edb2e | 1,780 | aoc-mmxxii | MIT License |
src/algorithmdesignmanualbook/sorting/KSum.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.sorting
import kotlin.test.assertTrue
/**
* Given a set S of n integers and an integer T,
* give an algorithm to test whether k of the integers in S add up to T.
*
* [Another way](https://www.geeksforgeeks.org/find-the-k-th-permutation-sequence-of-first-n-natural-numbers/)
*
* ... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 2,574 | algorithms | MIT License |
src/main/kotlin/ru/timakden/aoc/year2023/Day04.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2023
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
import kotlin.math.pow
/**
* [Day 4: Scratchcards](https://adventofcode.com/2023/day/4).
*/
object Day04 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val input = readInput... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 1,825 | advent-of-code | MIT License |
jvm/src/main/kotlin/io/prfxn/aoc2021/day05.kt | prfxn | 435,386,161 | false | {"Kotlin": 72820, "Python": 362} | // Hydrothermal Venture (https://adventofcode.com/2021/day/5)
package io.prfxn.aoc2021
import kotlin.math.min
import kotlin.math.max
import kotlin.math.abs
fun main() {
val lines = textResourceReader("input/05.txt").readLines()
fun part1() {
val visited = mutableSetOf<Pair<Int, Int>>()
val... | 0 | Kotlin | 0 | 0 | 148938cab8656d3fbfdfe6c68256fa5ba3b47b90 | 2,709 | aoc2021 | MIT License |
src/Day03.kt | georgiizorabov | 573,050,504 | false | {"Kotlin": 10501} | fun main() {
fun read(input: List<String>): List<Pair<String, String>> {
return input.map { str ->
Pair(
str.substring(0 until str.length / 2),
str.substring(str.length / 2 until str.length)
)
}
}
fun read1(input: List<String>): List<... | 0 | Kotlin | 0 | 0 | bf84e55fe052c9c5f3121c245a7ae7c18a70c699 | 1,160 | aoc2022 | Apache License 2.0 |
src/day09/Day09.kt | TheRishka | 573,352,778 | false | {"Kotlin": 29720} | package day09
import readInput
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt
fun main() {
val input = readInput("day09/Day09")
val movements = input.flatMap {
val movementAmount = it.drop(1).trim().toInt()
val movement = when (it.first()) {
'R' -> Mo... | 0 | Kotlin | 0 | 1 | 54c6abe68c4867207b37e9798e1fdcf264e38658 | 5,422 | AOC2022-Kotlin | Apache License 2.0 |
src/main/kotlin/divine/brothers/pizza/CandidateSetsApproach.kt | AarjavP | 450,892,849 | false | {"Kotlin": 28300} | package divine.brothers.pizza
import java.math.BigInteger
import java.util.*
class CandidateSetsApproach(input: Sequence<String>) : PizzaApproach(input) {
data class CandidateSetsSolution(
override val ingredients: BitSet,
val customersSatisfied: Int,
val customersSet: CustomersSet
): ... | 0 | Kotlin | 0 | 0 | 3aaaefc04d55b1e286dde0895fa32f9c34f5c945 | 2,425 | google-hash-code-2022 | MIT License |
src/Day04.kt | TrevorSStone | 573,205,379 | false | {"Kotlin": 9656} | fun main() {
fun part1(input: List<String>): Int =
input
.asSequence()
.flatMap { line -> line.split('-', ',') }
.chunked(2)
.map { (first, second) -> first.toInt()..second.toInt() }
.chunked(2)
.map { (first, second) ->
first.intersect(se... | 0 | Kotlin | 0 | 0 | 2a48776f8bc10fe1d7e2bbef171bf65be9939400 | 957 | advent-of-code-2022-kotlin | Apache License 2.0 |
2020/day19/day19.kt | flwyd | 426,866,266 | false | {"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398} | /*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package day19
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
import kotlin.time.measureTimedValue
/* Input: T... | 0 | Julia | 1 | 5 | f2d6dbb67d41f8f2898dbbc6a98477d05473888f | 4,258 | adventofcode | MIT License |
src/main/kotlin/Day02.kt | ripla | 573,901,460 | false | {"Kotlin": 19599} | object Day2 {
sealed interface Play {
val score: Int
val beats: Play
val loses: Play
}
object ROCK : Play {
override val score = 1
override val beats = SCISSORS
override val loses = PAPER
}
object PAPER : Play {
override val score = 2
... | 0 | Kotlin | 0 | 0 | e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8 | 2,316 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2023/day14/Day14.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day14
import com.jacobhyphenated.advent2023.Day
/**
* Day 14: Parabolic Reflector Dish
*
* A platform has a bunch of rocks on it. There are controls to tilt the platform in any direction.
* Round rocks ('O') will roll while square rocks ('#') will not move.
*
* The weight ... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 5,009 | advent2023 | The Unlicense |
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day13.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2021
import se.saidaspen.aoc.util.*
fun main() = Day13.run()
object Day13 : Day(2021, 13) {
override fun part1(): Any {
var dots = input.split("\n\n")[0].lines().map { P(ints(it)[0], ints(it)[1]) }.toSet()
val folds = input.split("\n\n")[1].lines()
val fold = ... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,480 | adventofkotlin | MIT License |
y2021/src/main/kotlin/adventofcode/y2021/Day15.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
import adventofcode.util.vector.Vec2
import adventofcode.util.vector.neighbors
import java.util.*
object Day15 : AdventSolution(2021, 15, "Chitons") {
override fun solvePartOne(input: String): Int {
val grid = parse(input)
return fin... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,917 | advent-of-code | MIT License |
src/day05/day05.kt | Dr4kn | 575,092,295 | false | {"Kotlin": 12652} | package day05
import readInputAsString
import java.util.NoSuchElementException
fun main() {
fun buildInstructionSet(instructions: String): List<List<Int>> {
return instructions
.replace("(move )|(from )|(to )".toRegex(), "")
.lines().map {
it.split(" ").... | 0 | Kotlin | 0 | 0 | 6de396cb4eeb27ff0dd9a98b56e68a13c2c90cd5 | 2,692 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2017/Day24.kt | tginsberg | 112,672,087 | false | null | /*
* Copyright (c) 2017 by <NAME>
*/
package com.ginsberg.advent2017
/**
* AoC 2017, Day 24
*
* Problem Description: http://adventofcode.com/2017/day/24
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day24/
*/
class Day24(input: List<String>) {
private val components = parseInp... | 0 | Kotlin | 0 | 15 | a57219e75ff9412292319b71827b35023f709036 | 1,684 | advent-2017-kotlin | MIT License |
src/Day03.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | fun main() {
val testInput = readInput("Day03_test")
check(part1(testInput) == 157)
check(part2(testInput) == 70)
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
return input.sumOf(::calculatePriority)
}
private fu... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 1,177 | AOC2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.