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/Day20.kt | andrikeev | 574,393,673 | false | {"Kotlin": 70541, "Python": 18310, "HTML": 5558} | import java.util.LinkedList
fun main() {
fun part1(input: List<String>): Long {
val nodes = input.map(String::toLong).mapIndexed(::Node)
return InfiniteList(nodes).apply { mix() }.result()
}
fun part2(input: List<String>): Long {
val nodes = input.map(String::toLong).map { it * 81... | 0 | Kotlin | 0 | 1 | 1aedc6c61407a28e0abcad86e2fdfe0b41add139 | 1,709 | aoc-2022 | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/EqualRowAndColumnPairs.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given a 0-indexed n x n integer matrix grid,
* return the number of pairs (ri, cj) such that row ri and column cj are equal.
*
* A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).
*
*
*
* Example 1:
*
*
* Input: grid = [[3,2,1],[1,7,6],... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,723 | leetcode-75 | Apache License 2.0 |
2022/src/day03/day03.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day03
import GREEN
import RESET
import printTimeMillis
import readInput
fun Char.score() = when (this) {
in 'a'..'z' -> this - 'a' + 1
in 'A'..'Z' -> this - 'A' + 27
else -> throw IllegalStateException("Not a letter")
}
fun part1(input: List<String>) = input.fold(0) { acc, line ->
val secondH... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,310 | advent-of-code | Apache License 2.0 |
src/day14/Code.kt | fcolasuonno | 225,219,560 | false | null | package day14
import isDebug
import java.io.File
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val (parsed, ranks) = parse(input)
println("Part 1 = ${part1(p... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 2,358 | AOC2019 | MIT License |
src/main/kotlin/com/github/davio/aoc/y2023/Day4.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2023
import com.github.davio.aoc.general.Day
import com.github.davio.aoc.general.getInputAsList
/**
* See [Advent of Code 2023 Day 4](https://adventofcode.com/2023/day/4#part2])
*/
object Day4 : Day() {
private val cards = getInputAsList()
.map { Card.parse(it) }
over... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 1,888 | advent-of-code | MIT License |
src/main/kotlin/com/leonra/adventofcode/advent2023/day08/Day8.kt | LeonRa | 726,688,446 | false | {"Kotlin": 30456} | package com.leonra.adventofcode.advent2023.day08
import com.leonra.adventofcode.shared.readResource
/** https://adventofcode.com/2023/day/8 */
private object Day8 {
data class Node(val left: String, val right: String)
enum class Direction {
LEFT,
RIGHT
}
fun partOne(): Int {
... | 0 | Kotlin | 0 | 0 | 46bdb5d54abf834b244ba9657d0d4c81a2d92487 | 3,951 | AdventOfCode | Apache License 2.0 |
src/Day02.kt | ranveeraggarwal | 573,754,764 | false | {"Kotlin": 12574} | // Ugh.
fun main() {
fun convert(move: String): Int {
return when (move) {
"X" -> 0
"Y" -> 1
"Z" -> 2
"A" -> 0
"B" -> 1
else -> 2
}
}
fun part1(input: List<String>): Int {
fun getScore(opp: Int, you: Int): Int {... | 0 | Kotlin | 0 | 0 | c8df23daf979404f3891cdc44f7899725b041863 | 1,935 | advent-of-code-2022-kotlin | Apache License 2.0 |
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day05.kt | akikanellis | 600,872,090 | false | {"Kotlin": 142932, "Just": 977} | package com.akikanellis.adventofcode.year2022
object Day05 {
fun cratesOnTheTopOfEachStack(
input: String,
craneMovesMultipleCratesAtOnce: Boolean
): String {
val stacks = stacks(input)
val moves = moves(input)
val stacksAfterMoves = stacksAfterMoves(
stacks... | 8 | Kotlin | 0 | 0 | 036cbcb79d4dac96df2e478938de862a20549dce | 2,251 | advent-of-code | MIT License |
src/main/kotlin/men/zhangfei/leetcode/medium/Problem0139.kt | fitzf | 257,562,586 | false | {"Kotlin": 9251} | package men.zhangfei.leetcode.medium
import java.util.LinkedList
import java.util.Queue
/**
* 139. 单词拆分
* https://leetcode-cn.com/problems/word-break/
*/
class Problem0139 {
companion object {
/**
* 动态规划
* 字符串 s 可以被拆分成子字符串 s1 和 s2
* 如果这些子字符串都可以独立地被拆分成符合要求的子字符串,那么整个字符串 s 也可... | 1 | Kotlin | 0 | 0 | a2ea7df7c1e4857808ab054d253dea567049658a | 2,323 | leetcode | Apache License 2.0 |
kotlin/src/2022/Day21_2022.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | fun main() {
val ops = mapOf<Char, (Long, Long) -> Long>(
'/' to {x, y -> x / y},
'*' to {x, y -> x * y},
'-' to {x, y -> x - y},
'+' to {x, y -> x + y}
)
abstract class Node {
abstract fun value(): Long?
}
data class Value(val x: Long?) :Node() {
over... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 2,472 | adventofcode | Apache License 2.0 |
src/day02/Day02Answer1.kt | IThinkIGottaGo | 572,833,474 | false | {"Kotlin": 72162} | package day02
import readInput
/**
* Answers from [Advent of Code 2022 Day 2 | Kotlin](https://youtu.be/Fn0SY2yGDSA)
*/
fun main() {
operator fun String.component1() = this[0]
operator fun String.component2() = this[1]
operator fun String.component3() = this[2]
fun part1(input: List<String>): Int {... | 0 | Kotlin | 0 | 0 | 967812138a7ee110a63e1950cae9a799166a6ba8 | 1,912 | advent-of-code-2022 | Apache License 2.0 |
Retos/Reto #19 - ANÁLISIS DE TEXTO [Media]/kotlin/mjordanaam.kt | mouredev | 581,049,695 | false | {"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ... | /*
* Crea un programa que analice texto y obtenga:
* - Número total de palabras.
* - Longitud media de las palabras.
* - Número de oraciones del texto (cada vez que aparecen un punto).
* - Encuentre la palabra más larga.
*
* Todo esto utilizando un único bucle.
*/
fun analyzeText(text: String) {
var senten... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 3,089 | retos-programacion-2023 | Apache License 2.0 |
src/Day09.kt | Kietyo | 573,293,671 | false | {"Kotlin": 147083} | import kotlin.math.absoluteValue
import kotlin.math.min
import kotlin.math.pow
import kotlin.math.sign
import kotlin.math.sqrt
fun main() {
data class Point(var x: Int, var y: Int)
class Game(
numPoints: Int
) {
val sqrt2 = sqrt(2.0)
val tolerance = 0.0001
val knots: List<P... | 0 | Kotlin | 0 | 0 | dd5deef8fa48011aeb3834efec9a0a1826328f2e | 2,579 | advent-of-code-2022-kietyo | Apache License 2.0 |
2021/src/main/kotlin/Day21.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | class Day21(val input: List<String>) {
private val positionPlayerOne: Int = input[0].removePrefix("Player 1 starting position: ").toInt()
private val positionPlayerTwo: Int = input[1].removePrefix("Player 2 starting position: ").toInt()
private fun HashMap<Game, Long>.addCount(game: Game, count: Long) {
... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 3,992 | adventofcode-2021-2025 | MIT License |
src/main/kotlin/aoc2023/day5/day5Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day5
import lib.*
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<Pair<List<Long>, Map<MapTypes, List<Pair<LongRange, Long>>>>> {
return setup {
day(5)
year(2023)
//input("example.txt")
parser {
val groups ... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 6,404 | AoC-2023-DDJ | MIT License |
src/main/kotlin/days/Day5.kt | hughjdavey | 433,597,582 | false | {"Kotlin": 53042} | package days
import util.Utils
import kotlin.math.max
import kotlin.math.min
class Day5 : Day(5) {
private val vents = inputList.flatMap { it.split(" -> ") }.flatMap { it.split(",") }
.map { it.toInt() }.chunked(4).map { Vent(Utils.Coord(it[0], it[1]), Utils.Coord(it[2], it[3])) }
override fun partO... | 0 | Kotlin | 0 | 0 | a3c2fe866f6b1811782d774a4317457f0882f5ef | 1,642 | aoc-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/Day03.kt | robert-iits | 573,124,643 | false | {"Kotlin": 21047} | import java.lang.IllegalArgumentException
class Day03 {
private fun splitRucksackInHalf(rucksack: String): Pair<String, String> {
return Pair(rucksack.take(rucksack.length/2), rucksack.takeLast(rucksack.length/2))
}
fun getPriority(item: Char): Int {
return if (item.code >= 'a'.code) {
... | 0 | Kotlin | 0 | 0 | 223017895e483a762d8aa2cdde6d597ab9256b2d | 1,650 | aoc2022 | Apache License 2.0 |
src/day11/Day11.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day11
import java.io.File
import kotlin.math.max
import kotlin.math.min
fun main() {
val data = parse("src/day11/Day11.txt")
println("🎄 Day 11 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 1,753 | advent-of-code-2023 | MIT License |
src/day18/Day18.kt | dkoval | 572,138,985 | false | {"Kotlin": 86889} | package day18
import readInput
import java.util.*
import kotlin.math.abs
private const val DAY_ID = "18"
private data class Rock(
val x: Int,
val y: Int,
val z: Int
)
private data class Delta(
val dx: Int,
val dy: Int,
val dz: Int
)
private data class Range(
var min: Int = Int.MAX_VALUE... | 0 | Kotlin | 1 | 0 | 791dd54a4e23f937d5fc16d46d85577d91b1507a | 3,403 | aoc-2022-in-kotlin | Apache License 2.0 |
src/test/kotlin/days/y2022/Day12Test.kt | jewell-lgtm | 569,792,185 | false | {"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123} | package days.y2022
import days.Day
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.core.Is.`is`
import org.junit.jupiter.api.Test
class Day12 : Day(2022, 12) {
override fun partOne(input: String): Any {
val (map, startPos, endPos) = parseInput(input)
return findPath(map, startPo... | 0 | Kotlin | 0 | 0 | b274e43441b4ddb163c509ed14944902c2b011ab | 3,738 | AdventOfCode | Creative Commons Zero v1.0 Universal |
2021/src/main/kotlin/day11_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Solution
import utils.Vec2i
import utils.withCounts
fun main() {
Day11Func.run()
}
object Day11Func : Solution<IntGrid>() {
override val name = "day11"
override val parser = IntGrid.singleDigits
private tailrec fun flash(alreadyFlashed: Set<Vec2i>, grid: IntGrid): IntGrid {
... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,460 | aoc_kotlin | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem1074/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1074
/**
* LeetCode page: [1074. Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/);
*/
class Solution {
/* Complexity:
* Time O(M^2 * N) and Space O(MN) where M and N are the number of rows and
* colu... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,031 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/Day09.kt | ssiegler | 572,678,606 | false | {"Kotlin": 76434} | package day09
import geometry.*
import utils.readInput
data class Rope(val knots: List<Position>) {
fun move(direction: Direction) =
Rope(
knots.subList(1, knots.size).scan(knots[0].move(direction)) { lead, tail ->
tail.follow(lead)
}
)
private fun Posi... | 0 | Kotlin | 0 | 0 | 9133485ca742ec16ee4c7f7f2a78410e66f51d80 | 2,181 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/g1801_1900/s1889_minimum_space_wasted_from_packaging/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1801_1900.s1889_minimum_space_wasted_from_packaging
// #Hard #Array #Sorting #Binary_Search #Prefix_Sum
// #2023_06_22_Time_910_ms_(100.00%)_Space_67.5_MB_(100.00%)
class Solution {
fun minWastedSpace(packages: IntArray, boxes: Array<IntArray>): Int {
val numPackages = packages.size
packa... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,290 | LeetCode-in-Kotlin | MIT License |
src/Day02.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | import Play.*
import Outcome.*
fun main() {
fun part1(input: List<String>): Int {
val scores = input.map {
Game(it[0].toPlay(), it[2].toPlay())
}.map { it.score() }
//scores.forEach{println(it)}
return scores.sum()
}
fun part2(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 2,333 | aoc2022 | Apache License 2.0 |
2022/src/test/kotlin/Day02.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
private enum class Outcome {
WIN, LOOSE, DRAW;
companion object {
fun from(input: String) =
when (input) {
"X" -> LOOSE
"Y" -> DRAW
"Z" -> WIN
else... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 2,594 | adventofcode | MIT License |
src/main/kotlin/final_450/arrays/exam.kt | ch8n | 312,467,034 | false | null | package final_450.arrays
fun main() {
val input = "23"
val numbers = arrayOf<String>("123", "234", "567")
val names = arrayOf<String>("chetan", "pokemon", "sokemon")
val result = numbers
.zip(names)
.sortedBy { it.second }
.firstOrNull {
it.first.contains(input)
... | 3 | Kotlin | 0 | 1 | e0619ebae131a500cacfacb7523fea5a9e44733d | 2,934 | Big-Brain-Kotlin | Apache License 2.0 |
advent-of-code-2022/src/main/kotlin/year_2022/Day08.kt | rudii1410 | 575,662,325 | false | {"Kotlin": 37749} | package year_2022
import util.Runner
fun main() {
val LEFT = 0
val TOP = 1
val RIGHT = 2
val BOTTOM = 3
/* Part 1 */
fun findTallerTree(tree: List<String>, part: Int, currentTree: Int, v: Int, h: Int, maxV: Int, maxH: Int): Boolean {
if (v == 0 || h == 0 || v == maxV - 1 || h == maxH ... | 1 | Kotlin | 0 | 0 | ab63e6cd53746e68713ddfffd65dd25408d5d488 | 3,487 | advent-of-code | Apache License 2.0 |
src/day11/Day11.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day11
import Runner
import day11.Operator.*
fun main() {
Day11Runner().solve()
}
class Day11Runner : Runner<Long>(
day = 11,
expectedPartOneTestAnswer = 10605,
expectedPartTwoTestAnswer = 2713310158
) {
override fun partOne(input: List<String>, test: Boolean): Long {
return solve... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 4,060 | advent-of-code | Apache License 2.0 |
src/com/akshay/adventofcode/Day05.kt | AkshayChordiya | 574,736,798 | false | {"Kotlin": 3303} | package com.akshay.adventofcode
import java.io.File
data class Move(val quantity: Int, val source: Int, val target: Int) {
companion object {
fun of(line: String): Move {
return line
.split(" ")
.filterIndexed { index, _ -> index % 2 == 1 }
.map... | 0 | Kotlin | 0 | 0 | ad60a71bd00e260a11b2546f67c4d8c135cb88b6 | 2,245 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Day02.kt | Kebaan | 573,069,009 | false | null | package days
import days.Day02.HandShape.*
import utils.Day
import utils.GameResult
import utils.GameResult.*
import utils.toPair
fun main() {
Day02.solve()
}
object Day02 : Day<Int>(2022, 2) {
private fun calculateScoreForRound(round: RockPaperScissorsGame): Int {
val outcomeScore = when (round.play... | 0 | Kotlin | 0 | 0 | ef8bba36fedbcc93698f3335fbb5a69074b40da2 | 3,383 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/day11/SolutionPart2.kt | TestaDiRapa | 573,066,811 | false | {"Kotlin": 50405} | package day11
import java.io.File
import java.lang.Exception
class IntModule(
initial: Int = 0,
oldModuleMap: Map<Int, Int>? = null
) {
private val moduleMap = oldModuleMap ?: listOf(2,3,5,7,11,13,17,19,23).fold(emptyMap()) { acc, it -> acc + (it to initial%it)}
operator fun plus(increment: Int): Int... | 0 | Kotlin | 0 | 0 | b5b7ebff71cf55fcc26192628738862b6918c879 | 4,942 | advent-of-code-2022 | MIT License |
src/main/kotlin/g1701_1800/s1786_number_of_restricted_paths_from_first_to_last_node/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1701_1800.s1786_number_of_restricted_paths_from_first_to_last_node
// #Medium #Dynamic_Programming #Heap_Priority_Queue #Graph #Topological_Sort #Shortest_Path
// #2023_06_18_Time_977_ms_(100.00%)_Space_75.1_MB_(100.00%)
import java.util.PriorityQueue
class Solution {
private class Pair(var v: Int, var ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,392 | LeetCode-in-Kotlin | MIT License |
src/day03/Day03.kt | TheJosean | 573,113,380 | false | {"Kotlin": 20611} | package day03
import readInput
fun main() {
fun getCharValue(char: Char) =
if (char.isLowerCase()) char - 'a' + 1 else char - 'A' + 27
fun part1(input: List<String>) =
input.sumOf {
val set = HashSet<Char>()
it.forEachIndexed { index, c ->
if (index < ... | 0 | Kotlin | 0 | 0 | 798d5e9b1ce446ba3bac86f70b7888335e1a242b | 1,562 | advent-of-code | Apache License 2.0 |
TwoSum.kt | ncschroeder | 604,822,497 | false | {"Kotlin": 19399} | /*
https://leetcode.com/problems/two-sum/
Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.... | 0 | Kotlin | 0 | 0 | c77d0c8bb0595e61960193fc9b0c7a31952e8e48 | 2,624 | Coding-Challenges | MIT License |
src/main/kotlin/day13/Day13.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day13
import byEmptyLines
import readResourceAsBufferedReader
fun main() {
println("part 1: ${part1(readResourceAsBufferedReader("13_1.txt").readLines())}")
println("part 2: ${part2(readResourceAsBufferedReader("13_1.txt").readLines())}")
}
fun part1(input: List<String>): Int {
val pairs = input.... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 3,677 | aoc-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/year2023/Day15.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2023
fun main() {
val input = readInput2("Day15")
Day15.part1(input).println()
Day15.part2(input).println()
}
object Day15 {
fun part1(input: String): Int {
return input
.split(",")
.sumOf { it.customHash() }
}
fun part2(input: String): Int {
... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 1,226 | advent-of-code | MIT License |
src/main/kotlin/day8/Day8.kt | stoerti | 726,442,865 | false | {"Kotlin": 19680} | package io.github.stoerti.aoc.day8
import io.github.stoerti.aoc.IOUtils
import io.github.stoerti.aoc.MathUtils
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.sqrt
fun main(args: Array<String>) {
val lines = IOUtils.readInput("day_8_input")
val directions = lines[0]
val mapLines = lines.sub... | 0 | Kotlin | 0 | 0 | 05668206293c4c51138bfa61ac64073de174e1b0 | 1,683 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2016/Day04.kt | tginsberg | 74,924,040 | false | null | /*
* Copyright (c) 2016 by <NAME>
*/
package com.ginsberg.advent2016
import kotlin.comparisons.compareBy
/**
* Advent of Code - Day 4: December 4, 2016
*
* From http://adventofcode.com/2016/day/4
*
*/
class Day04(rawInput: String) {
val rooms = rawInput.split("\n").map(::Room)
/**
* What is th... | 0 | Kotlin | 0 | 3 | a486b60e1c0f76242b95dd37b51dfa1d50e6b321 | 1,885 | advent-2016-kotlin | MIT License |
leetcode/kotlin/course-schedule-ii.kt | PaiZuZe | 629,690,446 | false | null | class Solution {
fun findOrder(numCourses: Int, prerequisites: Array<IntArray>): IntArray {
val toFrom = prerequisitesToToFrom(prerequisites, numCourses)
val formatedPrerequisites = formatPrerequisites(prerequisites, numCourses)
val path = dfs(toFrom, formatedPrerequisites)
return if... | 0 | Kotlin | 0 | 0 | 175a5cd88959a34bcb4703d8dfe4d895e37463f0 | 2,521 | interprep | MIT License |
kotlin/2020/qualification-round/indicium/src/main/kotlin/Solution.kt | ShreckYe | 345,946,821 | false | null | fun main() {
val T = readLine()!!.toInt()
repeat(T) { t ->
val (N, K) = readLine()!!.splitToSequence(' ').map(String::toInt).toList()
val answerMatrix = latinMatrices(N).find { it.trace() == K }
println("Case #${t + 1}: ${if (answerMatrix == null) "IMPOSSIBLE" else "POSSIBLE\n${answerM... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 1,843 | google-code-jam | MIT License |
src/main/kotlin/day04.kt | tobiasae | 434,034,540 | false | {"Kotlin": 72901} | class Day04 : Solvable("04") {
override fun solveA(input: List<String>): String {
val (drawnNumbers, boards) = readInput(input)
for (i in drawnNumbers) {
boards.forEach {
val result = it.drawNumber(i)
if (result >= 0) {
return (result... | 0 | Kotlin | 0 | 0 | 16233aa7c4820db072f35e7b08213d0bd3a5be69 | 2,435 | AdventOfCode | Creative Commons Zero v1.0 Universal |
kotlin/src/main/kotlin/AoC_Day24.kt | sviams | 115,921,582 | false | null | object AoC_Day24 {
data class Link(val a: Int, val b: Int) {
fun matches(output: Int) : Boolean = a == output || b == output
fun opposite(input: Int) : Int = if (a == input) b else a
}
fun parseInput(input: List<String>) : List<Link> =
input.map { line ->
val split = li... | 0 | Kotlin | 0 | 0 | 19a665bb469279b1e7138032a183937993021e36 | 1,467 | aoc17 | MIT License |
facebook/y2019/round1/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2019.round1
private fun solve(): Int {
val (n, hei) = readInts()
data class Ladder(val id: Int, val x: Int, val yFrom: Int, val yTo: Int)
val ladders = List(n) { val (x, yFrom, yTo) = readInts(); Ladder(it, x, yFrom, yTo) }
val e = Array(n + 2) { IntArray(n + 2) }
val ys = ladders.flatMap { lis... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,125 | competitions | The Unlicense |
src/Day03.kt | fdorssers | 575,986,737 | false | null | fun main() {
fun part1(input: List<String>): Int = input
.asSequence()
.map { it.chunked(it.length / 2) }
.map { Pair(it[0].toSet(), it[1].toSet()) }
.map { it.first.intersect(it.second) }
.map { it.first() }
.sumOf { if (it.isUpperCase()) it.code - 38 else it.code - ... | 0 | Kotlin | 0 | 0 | bdd1300b8fd6a1b8bce38aa6851e68d05193c636 | 833 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinScore.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 | 2,676 | kotlab | Apache License 2.0 |
src/main/kotlin/days/Day11.kt | hughjdavey | 572,954,098 | false | {"Kotlin": 61752} | package days
import xyz.hughjd.aocutils.Collections.split
class Day11 : Day(11) {
override fun partOne(): Any {
return play(getMonkeys(), 20).map { it.inspections }
.sortedDescending().take(2)
.let { it[0] * it[1] }
}
override fun partTwo(): Any {
return play(getM... | 0 | Kotlin | 0 | 2 | 65014f2872e5eb84a15df8e80284e43795e4c700 | 2,674 | aoc-2022 | Creative Commons Zero v1.0 Universal |
src/Day14.kt | jimmymorales | 572,156,554 | false | {"Kotlin": 33914} | fun main() {
fun List<String>.parseCave(): MutableSet<Pair<Int, Int>> = map { line ->
line.split(" -> ")
.map { path -> path.split(",").let { (x, y) -> x.toInt() to y.toInt() } }
.zipWithNext { (x1, y1), (x2, y2) ->
if (y1 == y2) {
val range = if (... | 0 | Kotlin | 0 | 0 | fb72806e163055c2a562702d10a19028cab43188 | 3,408 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/leonra/adventofcode/advent2023/day07/Day7.kt | LeonRa | 726,688,446 | false | {"Kotlin": 30456} | package com.leonra.adventofcode.advent2023.day07
import com.leonra.adventofcode.shared.readResource
/** https://adventofcode.com/2023/day/7 */
private object Day7 {
data class Game(val hand: String, val bid: Int)
fun partOne(): Int {
class CardComparator: Comparator<Char> {
val valueMap... | 0 | Kotlin | 0 | 0 | 46bdb5d54abf834b244ba9657d0d4c81a2d92487 | 6,627 | AdventOfCode | Apache License 2.0 |
src/main/aoc2015/Day13.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2015
import com.marcinmoskala.math.permutations
class Day13(input: List<String>) {
private val parsedInput = parseInput(input)
private val persons = parsedInput.map { it.key.first }.distinct().toSet()
private fun parseInput(input: List<String>): Map<Pair<String, String>, Int> {
return... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,182 | aoc | MIT License |
src/main/kotlin/twentytwentytwo/Day12.kt | JanGroot | 317,476,637 | false | {"Kotlin": 80906} | package twentytwentytwo
import twentytwentytwo.Structures.Point2d
typealias Land = Point2d
fun main() {
val input = {}.javaClass.getResource("input-12.txt")!!.readText().linesFiltered { it.isNotEmpty() };
val day = Day12(input)
println(day.part1())
println(day.part2())
//
}
class Day12(private v... | 0 | Kotlin | 0 | 0 | 04a9531285e22cc81e6478dc89708bcf6407910b | 1,560 | aoc202xkotlin | The Unlicense |
src/Day07.kt | mborromeo | 571,999,097 | false | {"Kotlin": 10600} | fun main() {
class File(val size: Int)
class Directory(val name: String) {
private val directories: MutableList<Directory> = mutableListOf()
private val files: MutableList<File> = mutableListOf()
fun size(): Int = files.sumOf { it.size } + directories.sumOf { it.size() }
fun ad... | 0 | Kotlin | 0 | 0 | d01860ecaff005aaf8e1e4ba3777a325a84c557c | 2,088 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/year2022/day19/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2022.day19
import IProblem
import java.util.regex.Pattern
import kotlin.math.max
import kotlin.math.min
class Problem : IProblem {
private val blueprints = mutableListOf<Array<IntArray>>()
init {
val pattern = Pattern.compile("\\d+")
javaClass
.getResourceAsStream("/2... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 2,630 | advent-of-code | The Unlicense |
src/main/kotlin/mat/ShortestPath.kt | yx-z | 106,589,674 | false | null | package mat
import util.*
import java.lang.Math.abs
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.HashSet
// given a grid G[1..n, 1..n], where G[i, j] = 1 represents an obstacle and 0
// o/w, and a starting point s = (u, v), and finally an ending point t = (p, q)
// find the shortest ... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 3,103 | AlgoKt | MIT License |
src/main/kotlin/com/ginsberg/advent2023/Day23.kt | tginsberg | 723,688,654 | false | {"Kotlin": 112398} | /*
* Copyright (c) 2023 by <NAME>
*/
/**
* Advent of Code 2023, Day 23 - A Long Walk
* Problem Description: http://adventofcode.com/2023/day/23
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day23/
*/
package com.ginsberg.advent2023
import kotlin.math.max
class Day23(input: List<Str... | 0 | Kotlin | 0 | 12 | 0d5732508025a7e340366594c879b99fe6e7cbf0 | 3,847 | advent-2023-kotlin | Apache License 2.0 |
src/main/kotlin/week2/TreeHouse.kt | waikontse | 572,850,856 | false | {"Kotlin": 63258} | package week2
import shared.Puzzle
import shared.ReadUtils.Companion.toIntList
import shared.ReadUtils.Companion.transpose
typealias Pos = Pair<Int, Int>
class Trees(val treesMap: List<List<Int>>) {
val maxX: Int = treesMap[0].size
val maxY: Int = treesMap.size
val transposed: List<List<Int>> = treesMap.t... | 0 | Kotlin | 0 | 0 | 860792f79b59aedda19fb0360f9ce05a076b61fe | 4,545 | aoc-2022-in-kotllin | Creative Commons Zero v1.0 Universal |
src/chapter3/section2/ex7.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter3.section2
import chapter3.section1.testOrderedST
/**
* 为二叉查找树添加一个方法avgCompares()来计算一颗给定的树中的一次随机命中查找平均所需要的比较次数
* (即树的各结点路径长度之和除以树的大小再加1)
* 实现两种方案:一种使用递归(用时为线性级别,所需空间和树高成正比)
* 一种模仿size()在每个结点中添加一个变量(所需空间为线性级别,查询耗时为常数)
*/
fun <K : Comparable<K>, V : Any> BinarySearchTree<K, V>.avgCompares(): Int {
... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 4,368 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/Day08.kt | bananer | 434,885,332 | false | {"Kotlin": 36979} | fun main() {
/*
digit abcdefg num num-unique
0 xxx xxx 6
1 x x 2 x
2 x xxx x 5
3 x xx xx 5
4 xxx x 4 x
5 xx x xx 5
6 xx xxxx 6
7 x x x 3 x
8 xxxxxxx 7 x
9 xxxx xx 6
*/
fun parseInput... | 0 | Kotlin | 0 | 0 | 98f7d6b3dd9eefebef5fa3179ca331fef5ed975b | 1,383 | advent-of-code-2021 | Apache License 2.0 |
src/Day04.kt | b0n541 | 571,797,079 | false | {"Kotlin": 17810} | fun main() {
infix fun IntRange.fullyContains(other: IntRange): Boolean {
for (value in other) {
if (value !in this) {
return false
}
}
return true
}
infix fun IntRange.overlaps(other: IntRange): Boolean {
for (value in other) {
... | 0 | Kotlin | 0 | 0 | d451f1aee157fd4d47958dab8a0928a45beb10cf | 1,563 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | Narmo | 573,031,777 | false | {"Kotlin": 34749} | fun main() {
data class Food(val calories: Int)
class Elf {
private val inventory = mutableListOf<Food>()
fun add(food: Food) = inventory.add(food)
fun getInventory() = inventory.toList()
fun getTotalEnergy() = inventory.sumOf { it.calories }
}
fun getElves(input: List<String>): List<Elf> {
val elves =... | 0 | Kotlin | 0 | 0 | 335641aa0a964692c31b15a0bedeb1cc5b2318e0 | 1,149 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2019/day22_slam_shuffle/SlamShuffle.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package aoc2019.day22_slam_shuffle
import java.util.*
fun main() {
util.solve(3036, ::partOne)
util.solve(2019, ::partOneReverse)
util.solve(70618172909245, ::partTwoReverse)
}
internal fun String.words() =
this.split(" ")
internal fun List<Op>.forward(card: Long) =
this.fold(card) { c, op ->
... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 2,005 | aoc-2021 | MIT License |
src/day22/a/day22a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day22.a
import readInputLines
import shouldBe
import util.IntVector
import vec
import java.util.regex.Pattern
import kotlin.math.max
fun main() {
val input = read()
val top = input.map.keys.minOfOrNull { it[1] }!!
val left = input.map.keys.filter { it[1] == top }.minOfOrNull { it[0] }!!
var ... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 3,186 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | JohannesPtaszyk | 573,129,811 | false | {"Kotlin": 20483} | fun main() {
fun part1(input: List<String>): Int = input.map { line ->
val ranges = line.split(",").map { rangeString ->
val (first, second) = rangeString.split("-")
first.toInt()..second.toInt()
}
val (first, second) = ranges
first to second
}.count {
... | 0 | Kotlin | 0 | 1 | 6f6209cacaf93230bfb55df5d91cf92305e8cd26 | 1,172 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | zirman | 572,627,598 | false | {"Kotlin": 89030} | fun main() {
fun splitOn(separator: String, input: List<String>): List<List<String>> {
tailrec fun splitOn(acc: List<List<String>>, input: List<String>): List<List<String>> {
val index = input.indexOf(separator)
return if (index == -1) {
acc.plusElement(input)
... | 0 | Kotlin | 0 | 1 | 2ec1c664f6d6c6e3da2641ff5769faa368fafa0f | 1,227 | aoc2022 | Apache License 2.0 |
src/Day08.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
// Dimension of row
val DIM = 99
fun part1(input: List<String>): Int {
// Create a 2D array of the same size as the input
//var seenTrees = mutableSetOf(Pair(0, 0))
var seenTrees = Array(DIM) {Array(DIM) {0} }
for (i in 0..(DIM-1)) {
val nums = input... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 3,601 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | BHFDev | 572,832,641 | false | null | fun main() {
fun part1(input: List<String>): Int {
return input.count { pair ->
val elves = pair
.split(',')
.map {elf ->
elf.split('-').map { it.toInt() }
}
val elf1 = Pair(elves[0][0], elves[0][1])
val elf2... | 0 | Kotlin | 0 | 0 | b158069483fa02636804450d9ea2dceab6cf9dd7 | 1,267 | aoc-2022-in-kotlin | Apache License 2.0 |
aoc21/day_12/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
fun String.small(): Boolean = all { it.isLowerCase() }
fun List<String>.hasDuplicate() = size != distinct().size
fun countPaths(
neighs: MutableMap<String, Set<String>>,
mayVisit: (node: String, path: List<String>) -> Boolean,
): Int {
val openPaths = mutableListOf(listOf("start"))
... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 1,347 | advent-of-code | MIT License |
kotlin/src/main/kotlin/year2021/Day05.kt | adrisalas | 725,641,735 | false | {"Kotlin": 130217, "Python": 1548} | package year2021
private data class Point(val x: Int, val y: Int)
private data class Line(val pointA: Point, val pointB: Point)
private fun part1(input: List<String>): Int {
val points: MutableMap<Point, Int> = HashMap()
val lines = readLines(input)
lines
.map { toPointsPart1(it) }
.flatt... | 0 | Kotlin | 0 | 2 | 6733e3a270781ad0d0c383f7996be9f027c56c0e | 3,091 | advent-of-code | MIT License |
src/main/kotlin/adventofcode/year2021/Day11DumboOctopus.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2021
import adventofcode.Puzzle
import adventofcode.PuzzleInput
import adventofcode.common.neighbors
class Day11DumboOctopus(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val grid by lazy { input.lines().map { it.map { it.toString().toInt() } } }
private fun List<... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 1,972 | AdventOfCode | MIT License |
src/advent/of/code/Dijkstra.kt | 1nco | 725,911,911 | false | {"Kotlin": 112713, "Shell": 103} | package advent.of.code
import advent.of.code.types.Graph
fun dijkstra(graph: Graph<String>, start: String, map: MutableList<MutableList<Int>>): Map<String, String?> {
var S: MutableSet<String> = mutableSetOf() // a subset of vertices, for which we know the true distance
/*
* delta represents the length ... | 0 | Kotlin | 0 | 0 | 0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3 | 6,836 | advent-of-code | Apache License 2.0 |
src/day04/Day04.kt | wickenico | 573,048,677 | false | {"Kotlin": 7731} | package day04
import readInput
fun main() {
println(part1(readInput("day04", "input")))
println(part2(readInput("day04", "input")))
}
fun part1(input: List<String>): Int {
var result = 0
input.forEach { line ->
val ranges = line.split(",")
val first = ranges[0].split("-").map { it.toI... | 0 | Kotlin | 0 | 0 | 00791dc0870048b08092e38338cd707ce0f9706f | 999 | advent-of-code-kotlin | Apache License 2.0 |
src/Day13.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | import kotlin.math.min
sealed interface Message {
data class Number(val value: Int) : Message
data class Messages(val messages: MutableList<Message>, val parent: Messages?) : Message
}
enum class Ordered {
YES, NO, MAYBE
}
fun main() {
fun decode(input: String): Message {
val parent = Messag... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 4,072 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/days/Day4.kt | nicopico-dev | 726,255,944 | false | {"Kotlin": 37616} | package days
import kotlin.math.pow
class Day4 : Day(4) {
private val cards: List<Card> by lazy {
inputList.map { parseCard(it) }
}
override fun partOne(): Any {
return cards
.map { it.winningNumbersYouHave.size }
.sumOf { computePoints(winCount = it) }
}
... | 0 | Kotlin | 0 | 0 | 1a13c8bd3b837c1ce5b13f90f326f0277249d23e | 3,091 | aoc-2023 | Creative Commons Zero v1.0 Universal |
problems/2850/kotlin/Solution.kt | misut | 678,196,869 | false | {"Kotlin": 32683} | class Solution {
fun minimumMoves(grid: Array<IntArray>): Int {
val queue = mutableListOf(grid to 0)
val visited = mutableSetOf(grid.stringify())
while(true) {
val (board, moves) = queue.removeFirst()
if (board.isCoveredAll()) {
return moves
... | 0 | Kotlin | 0 | 0 | 52fac3038dd29cb8eefebbf4df04ccf1dda1e332 | 2,048 | ps-leetcode | MIT License |
src/Day14.kt | maciekbartczak | 573,160,363 | false | {"Kotlin": 41932} | import kotlin.math.max
import kotlin.math.min
fun main() {
fun part1(input: List<String>): Int {
val grid = parseInput(input, false)
return getGrainsWithinBoundsCount(grid)
}
fun part2(input: List<String>): Int {
val grid = parseInput(input, true)
return getGrainsWithinBou... | 0 | Kotlin | 0 | 0 | 53c83d9eb49d126e91f3768140476a52ba4cd4f8 | 4,799 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/anahoret/aoc2022/day05/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day05
import java.io.File
import kotlin.collections.ArrayDeque
private fun <E> ArrayDeque<E>.removeFirst(count: Int): List<E> {
val result = mutableListOf<E>()
repeat(count) {
result.add(removeFirst())
}
return result
}
data class Move(val from: Int, val to: Int, ... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 2,905 | advent-of-code-2022 | Apache License 2.0 |
src/year2023/day13/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2023.day13
import arrow.core.Either
import arrow.core.identity
import arrow.core.left
import arrow.core.nonEmptyListOf
import arrow.core.right
import utils.ProblemPart
import utils.readInputs
import utils.runAlgorithm
import utils.transpose
fun main() {
val (realInput, testInputs) = readInputs(2023, 1... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 2,087 | Advent-of-Code | Apache License 2.0 |
src/commonMain/kotlin/advent2020/day14/Day14Puzzle.kt | jakubgwozdz | 312,526,719 | false | null | package advent2020.day14
fun part1(input: String): String {
val lines = input.trim().lineSequence()
val memory = mutableMapOf<Long, Long>()
var andMask = "111111111111111111111111111111111111".toLong(2)
var orMask = "000000000000000000000000000000000000".toLong(2)
lines.forEach { line ->
... | 0 | Kotlin | 0 | 2 | e233824109515fc4a667ad03e32de630d936838e | 2,371 | advent-of-code-2020 | MIT License |
src/main/kotlin/com/ginsberg/advent2018/Day13.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 13 - Mine Cart Madness
*
* Problem Description: http://adventofcode.com/2018/day/13
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day13/
*/
package com.ginsberg.advent2018
import java.util.TreeSet
typealias Track ... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 5,312 | advent-2018-kotlin | MIT License |
src/day04/Day04.kt | zypus | 573,178,215 | false | {"Kotlin": 33417, "Shell": 3190} | package day04
import AoCTask
// https://adventofcode.com/2022/day/4
operator fun IntRange.contains(other: IntRange): Boolean {
return other.first in this && other.last in this
}
private fun parseRangePairs(input: List<String>) = input.map { line ->
line
.split(",", limit = 2)
.map { ranges -... | 0 | Kotlin | 0 | 0 | f37ed8e9ff028e736e4c205aef5ddace4dc73bfc | 1,092 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2023/day8/Day8.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day8
import com.jacobhyphenated.advent2023.Day
typealias Direction = Map<String, Pair<String,String>>
/**
* Day 8: <NAME>
*
* The puzzle input consists of two parts. The first part is a set of instructions indicating which
* direction to take (R = right, L = left). Those in... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 3,398 | advent2023 | The Unlicense |
src/main/kotlin/com/ginsberg/advent2020/Day20.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 20 - Jurassic Jigsaw
* Problem Description: http://adventofcode.com/2020/day/20
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day20/
*/
package com.ginsberg.advent2020
import kotlin.math.sqrt
class Day20(input: Str... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 6,346 | advent-2020-kotlin | Apache License 2.0 |
src/main/kotlin/day15.kt | Gitvert | 725,292,325 | false | {"Kotlin": 97000} | fun day15 (lines: List<String>) {
val initializationSequence = parseInitializationSequence(lines)
val sum = initializationSequence.sumOf { calculateHashValue(it) }
println("Day 15 part 1: $sum")
val lenses = parseLenses(lines)
val boxes = mutableListOf<MutableList<Lens>>()
for (i in 0.... | 0 | Kotlin | 0 | 0 | f204f09c94528f5cd83ce0149a254c4b0ca3bc91 | 2,236 | advent_of_code_2023 | MIT License |
src/main/kotlin/adventofcode2022/solution/day_2.kt | dangerground | 579,293,233 | false | {"Kotlin": 51472} | package adventofcode2022.solution
import adventofcode2022.util.readDay
import java.lang.RuntimeException
private const val DAY_NUM = 2
fun main() {
Day2(DAY_NUM.toString()).solve()
}
class Day2(private val num: String) {
private val inputText = readDay(num)
fun solve() {
println("Day $num Solu... | 0 | Kotlin | 0 | 0 | f1094ba3ead165adaadce6cffd5f3e78d6505724 | 2,152 | adventofcode-2022 | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions7.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import com.qiaoyuang.algorithm.round0.BinaryTreeNode
fun test7() {
fun printlnResults(preOrder: IntArray, inOrder: IntArray) {
val tree = rebuildBinaryTree(preOrder, inOrder)
val preOrderList = preOrder.toList()
val inOrderList = inOrder.toList()
... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 2,864 | Algorithm | Apache License 2.0 |
src/Day01.kt | AndreiShilov | 572,661,317 | false | {"Kotlin": 25181} | fun main() {
fun getCalMap(input: List<String>): MutableMap<Int, Int> {
val calMap = mutableMapOf<Int, Int>()
var counter = 0
var acc = 0
input.forEach { it ->
if (it.isBlank()) {
calMap[counter] = acc
counter++
acc = 0
... | 0 | Kotlin | 0 | 0 | 852b38ab236ddf0b40a531f7e0cdb402450ffb9a | 1,519 | aoc-2022 | Apache License 2.0 |
src/day23/Code.kt | fcolasuonno | 572,734,674 | false | {"Kotlin": 63451, "Dockerfile": 1340} | package day23
import Coord
import day06.main
import neighbours
import readInput
fun main() {
val directionCheck = listOf<(Set<Coord>, Coord) -> Coord?>(
{ s, c ->
c.copy(second = c.second - 1)
.takeIf {
listOf(it, it.copy(first = it.first - 1), it.copy(firs... | 0 | Kotlin | 0 | 0 | 9cb653bd6a5abb214a9310f7cac3d0a5a478a71a | 2,379 | AOC2022 | Apache License 2.0 |
src/Day01.kt | hiteshchalise | 572,795,242 | false | {"Kotlin": 10694} | fun main() {
fun part1(input: List<String>): Int {
val caloriesList = input.map { if (it.isNotEmpty()) it.toInt() else 0 }
val listOfTotalCalories = mutableListOf<Int>()
caloriesList.reduce { acc: Int, calories: Int ->
if (calories > 0) acc + calories
else {
... | 0 | Kotlin | 0 | 0 | e4d66d8d1f686570355b63fce29c0ecae7a3e915 | 1,156 | aoc-2022-kotlin | Apache License 2.0 |
src/Day19.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | class Day19 {
private val pattern =
"Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. Each obsidian robot costs (\\d+) ore and (\\d+) clay. Each geode robot costs (\\d+) ore and (\\d+) obsidian."
private val maxCapacity = 100
data class Material(val ore: Int, val... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 5,340 | Advent-Of-Code-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day02/day2.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day02
import biz.koziolek.adventofcode.findInput
fun main() {
val inputFile = findInput(object {})
val position = calculatePosition(inputFile.bufferedReader().lineSequence())
println("Position: $position")
println("Answer 1: ${position.horizontal * position.d... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 2,333 | advent-of-code | MIT License |
src/main/kotlin/dev/bogwalk/batch2/Problem29.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch2
import java.math.BigInteger
import kotlin.math.pow
/**
* Problem 29: Distinct Powers
*
* https://projecteuler.net/problem=29
*
* Goal: Count the distinct terms in a sequence generated by a^b when 2 <= a <= N and 2 <= b <= N.
*
* Constraints: 2 <= N <= 1e5
*
* e.g.: N = 4
* t... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 2,652 | project-euler-kotlin | MIT License |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem012.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
import dev.mikeburgess.euler.sequences.PrimeSequence
import dev.mikeburgess.euler.sequences.triangleNumbers
import kotlin.math.sqrt
/**
* Problem 12
*
* The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle
* number would be 1 + 2 +... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 1,453 | project-euler | MIT License |
src/main/kotlin/com/ginsberg/advent2018/Day23.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 23 - Experimental Emergency Teleportation
*
* Problem Description: http://adventofcode.com/2018/day/23
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day23/
*/
package com.ginsberg.advent2018
import kotlin.math.abs
... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 2,012 | advent-2018-kotlin | MIT License |
2023/src/day03/Day03.kt | scrubskip | 160,313,272 | false | {"Kotlin": 198319, "Python": 114888, "Dart": 86314} | package day03
import java.io.File
fun main() {
val input = File("src/day03/Day03.txt").readLines()
val schematic = Schematic(input)
println(schematic.getPartNumbers().sum())
println(schematic.getGearRatios().sum())
}
typealias Coordinate = Pair<Int, Int>
data class Rectangle(val top: Int, val left:... | 0 | Kotlin | 0 | 0 | a5b7f69b43ad02b9356d19c15ce478866e6c38a1 | 3,190 | adventofcode | Apache License 2.0 |
src/main/kotlin/kt/kotlinalgs/app/graph/PathsWithSum.ws.kts | sjaindl | 384,471,324 | false | null | package kt.kotlinalgs.app.graph
import java.util.*
/*
Achtung: Immer map etc. zurücksetzen!!
BC: from root, cur element .. test cases!
*/
Solution().test()
/*
10
15,5
17,7,2
18,8,3,1
alt.. store complete sum in set<Int>
10, 15, 17, 18
.. check at each node if (set.contains(runningSum - k)) -> incr. co... | 0 | Java | 0 | 0 | e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0 | 3,132 | KotlinAlgs | MIT License |
src/main/kotlin/day19.kt | tobiasae | 434,034,540 | false | {"Kotlin": 72901} | class Day19 : Solvable("19") {
val cache = HashMap<List<String>, Pair<Set<Point>, List<Point>>>()
override fun solveA(input: List<String>): String {
val result = getPoints(input)
cache[input] = result
return result.first.size.toString()
}
override fun solveB(input: List<String... | 0 | Kotlin | 0 | 0 | 16233aa7c4820db072f35e7b08213d0bd3a5be69 | 4,050 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/Day07.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | fun main() {
class Directory(
var size: Int = 0,
val root: Directory? = null,
var listdir: MutableMap<String, Directory>? = null
){
constructor(root: Directory): this(0, root, mutableMapOf<String, Directory>())
constructor(size: Int, root: Directory): this(size, root, nul... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 2,243 | aoc22 | Apache License 2.0 |
grind-75-kotlin/src/main/kotlin/LongestPalindrome.kt | Codextor | 484,602,390 | false | {"Kotlin": 27206} | /**
* Given a string s which consists of lowercase or uppercase letters,
* return the length of the longest palindrome that can be built with those letters.
*
* Letters are case sensitive, for example, "Aa" is not considered a palindrome here.
*
*
*
* Example 1:
*
* Input: s = "abccccdd"
* Output: 7
* Expla... | 0 | Kotlin | 0 | 0 | 87aa60c2bf5f6a672de5a9e6800452321172b289 | 1,454 | grind-75 | Apache License 2.0 |
src/main/kotlin/dev/tasso/adventofcode/_2021/day03/Day03.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2021.day03
import dev.tasso.adventofcode.Solution
class Day03 : Solution<Int> {
override fun part1(input: List<String>): Int {
var gammaString = ""
var epsilonString = ""
for(i in 0 until input[0].length) {
val (zeros, ones) = input.map{c -> ... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 1,886 | advent-of-code | MIT License |
src/main/kotlin/se/brainleech/adventofcode/aoc2015/Aoc2015Day02.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2015
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readText
import se.brainleech.adventofcode.verify
class Aoc2015Day02 {
data class Box(val l: Long, val w: Long, val h: Long) {
private fun surfaceArea(): Long = 0
.plus(2.tim... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 1,859 | adventofcode | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.