path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/java/challenges/educative_grokking_coding_interview/top_k_elements/_3/ClosestPoints.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.top_k_elements._3
import challenges.util.PrintHyphens
import java.util.*
/**
Given a list of points on a plane, where the plane is a 2-D array with (x, y) coordinates, find the k closest
points to the origin (0, 0).
https://www.educative.io/courses/grokking-codi... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,983 | CodingChallenges | Apache License 2.0 |
src/day06/Day06.kt | lpleo | 572,702,403 | false | {"Kotlin": 30960} | package day06
import readInput
fun main() {
fun part1(input: List<String>): Int {
val string = input[0]
for (i in 0..string.length) {
val reduce = string.substring(i, i + 4).map { character -> string.substring(i, i + 4).count { internalChar -> internalChar == character } == 1 }.reduce... | 0 | Kotlin | 0 | 0 | 115aba36c004bf1a759b695445451d8569178269 | 1,378 | advent-of-code-2022 | Apache License 2.0 |
2022/Day16/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import kotlin.math.*
data class Valve(val label: String, val flow: Int, val tunnels: Set<String>)
class Solution(val valveMap: Map<String, Valve>) {
val paths = cachePaths(valveMap)
var closedValves = mutableMapOf<String, Valve>()
var memo = mutableMapOf<Triple<String, Pair<String, Int... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 4,020 | AdventOfCode | MIT License |
src/Day10.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | enum class Command(val cycles: Int) {
addx(2),
noop(1)
}
class Instruction(var cmd: Command, var arg: Int? = null) {
}
class Computer(private val instructions: List<Instruction>, var x: Int = 1) {
private var cc = 0
private var ip = 0
val screen = Screen(40, 6)
private var cycle = 0
fun t... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 2,090 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | CrazyBene | 573,111,401 | false | {"Kotlin": 50149} | import kotlin.math.abs
import kotlin.math.sign
fun main() {
fun List<String>.toMoveInstructions(): List<Pair<Int, Int>> {
return this.flatMap {
val (char, times) = it.split(" ")
val move = when (char.first()) {
'U' -> 0 to 1
'R' -> 1 to 0
... | 0 | Kotlin | 0 | 0 | dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26 | 3,009 | AdventOfCode2022 | Apache License 2.0 |
src/Day09.kt | RandomUserIK | 572,624,698 | false | {"Kotlin": 21278} | import kotlin.math.abs
private fun List<String>.toDirections(): List<Direction> =
joinToString("") {
val direction = it.substringBefore(" ")
val steps = it.substringAfter(" ").toInt()
direction.repeat(steps)
}.map {
when (it) {
'U' -> Direction.U
'D' -> Direction.D
'L' -> Direction.L
'R' -> Direc... | 0 | Kotlin | 0 | 0 | f22f10da922832d78dd444b5c9cc08fadc566b4b | 2,169 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | ManueruEd | 573,678,383 | false | {"Kotlin": 10647} | fun main() {
fun part1(input: List<String>): Int {
val a = input.map { it.toIntOrNull() }
.fold(mutableListOf()) { acc: MutableList<ArrayList<Int>>, s: Int? ->
if (s == null) {
acc.add(arrayListOf())
acc
} else {
... | 0 | Kotlin | 0 | 0 | 09f3357e059e31fda3dd2dfda5ce603c31614d77 | 1,502 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day14.kt | jmerle | 434,010,865 | false | {"Kotlin": 60581} | package com.jaspervanmerle.aoc2021.day
class Day14 : Day("2851", "10002813279337") {
private val template = input.split("\n\n")[0]
private val rules = input
.split("\n\n")[1]
.lines()
.map { it.replace(" -> ", "") }
.associate { (it[0] to it[1]) to it[2] }
override fun sol... | 0 | Kotlin | 0 | 0 | dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e | 1,797 | advent-of-code-2021 | MIT License |
src/Day11.kt | asm0dey | 572,860,747 | false | {"Kotlin": 61384} | import Monkey11.Op
fun main() {
fun parseMonkeys(input: List<String>): List<Monkey11> {
val digits = Regex("\\d+")
return buildList {
input.chunked(7) {
val (f, op, s) = it[2].split(':')[1]
.trim()
.replace("new = ", "")
... | 1 | Kotlin | 0 | 1 | f49aea1755c8b2d479d730d9653603421c355b60 | 3,169 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | mr3y-the-programmer | 572,001,640 | false | {"Kotlin": 8306} | @Suppress("USELESS_CAST")
fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { pair ->
val (firstRange, secondRange) = pair.toIntRanges()
if (firstRange containsAll secondRange || secondRange containsAll firstRange)
1
else
... | 0 | Kotlin | 0 | 0 | 96d1567f38e324aca0cb692be3dae720728a383d | 1,372 | advent-of-code-2022 | Apache License 2.0 |
src/day04/Day04.kt | pnavais | 727,416,570 | false | {"Kotlin": 17859} | package day04
import readInput
import java.util.Stack
import kotlin.math.pow
private fun getMatches(s: String): Int {
val (n, w) = s.split(":")[1].split("|").map { i -> i.trim().split("\\s+".toRegex()).map(String::toInt) }
val winning = w.toSet()
return n.map { i -> i to winning.contains(i) }.count { p ->... | 0 | Kotlin | 0 | 0 | f5b1f7ac50d5c0c896d00af83e94a423e984a6b1 | 1,372 | advent-of-code-2k3 | Apache License 2.0 |
src/day08/Day08.kt | easchner | 572,762,654 | false | {"Kotlin": 104604} | package day08
import readInputString
import java.lang.Integer.max
fun main() {
fun part1(input: List<String>): Int {
val trees = mutableListOf<MutableList<Int>>()
var totalVisible = 0
for (line in input) {
trees.add(mutableListOf())
for (i in line) {
... | 0 | Kotlin | 0 | 0 | 5966e1a1f385c77958de383f61209ff67ffaf6bf | 3,668 | Advent-Of-Code-2022 | Apache License 2.0 |
src/net/sheltem/aoc/y2022/Day16.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.aoc.y2022
suspend fun main() {
Day16().run()
}
class Day16 : Day<Int>(1651, 1707) {
override suspend fun part1(input: List<String>): Int {
val valves = input.map(Valve.Companion::from)
val valvesMap = valves.associateBy { it.name }
val paths = valves.associate {... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 3,433 | aoc | Apache License 2.0 |
src/test/kotlin/Day06.kt | christof-vollrath | 317,635,262 | false | null | import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
/*
--- Day 6: Custom Customs ---
See https://adventofcode.com/2020/day/6
*/
fun List<Set<Char>>.countYes(): Int = sumBy { it.size }
fun List<List<Set<Char>>>.anyPerGroup(): List<Set<Char>> = map { group ->
group.reduce { result, curr... | 1 | Kotlin | 0 | 0 | 8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8 | 3,249 | advent_of_code_2020 | Apache License 2.0 |
src/Day04.kt | punx120 | 573,421,386 | false | {"Kotlin": 30825} | fun main() {
fun getRange(s : String) : Pair<Int, Int> {
val parts = s.split("-")
return Pair(parts[0].toInt(), parts[1].toInt())
}
fun part1(input: List<String>): Int {
var count = 0
for (line in input) {
val split = line.split(',')
val (r1, r2) = g... | 0 | Kotlin | 0 | 0 | eda0e2d6455dd8daa58ffc7292fc41d7411e1693 | 1,181 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/year2022/Day21.kt | simpor | 572,200,851 | false | {"Kotlin": 80923} | import AoCUtils.test
import java.lang.Exception
enum class Operation { PLUS, MINUS, TIMES, DIVIDE }
fun main() {
open class Monkey
data class MonkeyValue(val name: String, val value: Long) : Monkey()
data class MonkeyOperation(val name: String, val first: String, val second: String, val operation: Operati... | 0 | Kotlin | 0 | 0 | 631cbd22ca7bdfc8a5218c306402c19efd65330b | 3,333 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2023/Day21.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import PointL
import readInput
import to2dCharArray
object Day21 {
private class GardenMap(private val map: Array<CharArray>) {
private val maxX = map.size - 1
private val maxY = map.first().size - 1
private val validGrid = PointL(0, 0) to PointL(maxX, maxY)
privat... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 11,293 | adventOfCode | Apache License 2.0 |
src/Day11.kt | sungi55 | 574,867,031 | false | {"Kotlin": 23985} | fun main() {
val day = "Day11"
fun getMonkey(index: Int, lines: List<String>, decreaseWorryStrategy: (Long) -> Long): Monkey {
val (sign, increaseBy) = lines[index + 2]
.substringAfter("old ")
.split(" ")
.let {
it.first() to if (it.last() == "old") ... | 0 | Kotlin | 0 | 0 | 2a9276b52ed42e0c80e85844c75c1e5e70b383ee | 4,238 | aoc-2022 | Apache License 2.0 |
src/day14/a/day14a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day14.a
import readInputLines
import shouldBe
import vec2
import util.IntVector
import java.lang.Integer.max
import java.lang.Integer.min
import kotlin.math.abs
typealias Grid = HashMap<IntVector, Char>
fun main() {
val grid = read()
val entry = vec2(500,0)
val bottom = grid.keys.map { it[1] }.re... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 1,679 | advent-of-code-2022 | Apache License 2.0 |
src/Day14/Solution.kt | cweinberger | 572,873,688 | false | {"Kotlin": 42814} | package Day14
import readInput
import toInt
import java.util.Scanner
import kotlin.math.abs
import kotlin.math.sign
object Solution {
fun parseLine(line: String) : List<Pair<Int, Int>> {
return line
.split(" -> ")
.map {
it.split(',')
.map { it.... | 0 | Kotlin | 0 | 0 | 883785d661d4886d8c9e43b7706e6a70935fb4f1 | 6,848 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/sherepenko/leetcode/solutions/LongestPalindromicSubstring.kt | asherepenko | 264,648,984 | false | null | package com.sherepenko.leetcode.solutions
import com.sherepenko.leetcode.Solution
import kotlin.math.max
class LongestPalindromicSubstring(
private val str: String
) : Solution {
companion object {
fun longestPalindrome(str: String): String? {
if (str.length <= 1) {
return... | 0 | Kotlin | 0 | 0 | 49e676f13bf58f16ba093f73a52d49f2d6d5ee1c | 2,259 | leetcode | The Unlicense |
day11/src/main/kotlin/Main.kt | rstockbridge | 159,586,951 | false | null | import java.lang.Double.NEGATIVE_INFINITY
fun main() {
val powerLevelGrid = fillPowerLevelGrid(3214)
println("Part I: the solution is ${solvePartI(powerLevelGrid)}.")
println("Part II: the solution is ${solvePartII(powerLevelGrid)}.")
}
fun solvePartI(powerLevelGrid: Array<IntArray>): String {
val si... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 2,306 | AdventOfCode2018 | MIT License |
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day13.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2022
import java.util.ArrayDeque as Deque
class Day13(private val input: List<String>) {
fun solvePart1(): Int {
return input.asSequence()
.filter { it.isNotEmpty() }
.map { line -> parseArray(Deque(line.toList())) }
.windowed(2, 2)
... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 3,082 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/uber/tagir/advent2018/day03/day03.kt | groz | 159,977,575 | false | null | package com.uber.tagir.advent2018.day03
import com.uber.tagir.advent2018.utils.resourceAsString
fun main(args: Array<String>) {
with(Day03()) {
overlaps()
single()
}
}
data class Claim(val id: Int, val left: Int, val top: Int, val width: Int, val height: Int)
fun parseClaim(s: String): Claim... | 0 | Kotlin | 0 | 0 | 19b5a5b86c9a3d2803192b8c6786a25151b5144f | 1,819 | advent2018 | MIT License |
src/main/kotlin/Day15.kt | bent-lorentzen | 727,619,283 | false | {"Kotlin": 68153} | import java.time.LocalDateTime
import java.time.ZoneOffset
fun main() {
fun hash(startValue: Int, instruction: String): Int {
return instruction.fold(startValue) { acc, c ->
((acc + c.code) * 17) % 256
}
}
fun part1(input: List<String>): Int {
val instructions = input.... | 0 | Kotlin | 0 | 0 | 41f376bd71a8449e05bbd5b9dd03b3019bde040b | 2,224 | aoc-2023-in-kotlin | Apache License 2.0 |
src/problems/day2/daytwo.kt | klnusbaum | 733,782,662 | false | {"Kotlin": 43060} | package problems.day2
import java.io.File
private const val gamesFile = "input/day2/games.txt"
fun main() {
part1()
part2()
}
private data class Round(val red: Int, val green: Int, val blue: Int)
private data class Game(val id: Int, val rounds: List<Round>) {
fun allRedUnder(max: Int) = rounds.all { it... | 0 | Kotlin | 0 | 0 | d30db2441acfc5b12b52b4d56f6dee9247a6f3ed | 1,946 | aoc2023 | MIT License |
src/main/kotlin/com/dmc/advent2022/Day03.kt | dorienmc | 576,916,728 | false | {"Kotlin": 86239} | //--- Day 3: Rucksack Reorganization ---
package com.dmc.advent2022
class Day03 : Day<Int> {
override val index = 3
override fun part1(input: List<String>): Int {
return input.sumOf { it.overlap().priority() }
}
override fun part2(input: List<String>): Int {
return input.chunked(3).su... | 0 | Kotlin | 0 | 0 | 207c47b47e743ec7849aea38ac6aab6c4a7d4e79 | 1,173 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/sk/topicWise/dp/322. Coin Change.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.topicWise.dp
/**
* f(n) : Function to return minimum no of coins required to make n, return -1 otherwise.
* f(n) = min{ 1 + f(n - arr[i]) }
* where 0 <= i < size and arr[i] <= n
*/
class Solution322 {
// dp, bottom-up
fun coinChange(coins: IntArray, amount: Int): Int {
if (amount ... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,714 | leetcode-kotlin | Apache License 2.0 |
src/Day03.kt | i-tatsenko | 575,595,840 | false | {"Kotlin": 90644} | fun Char.priority(): Int = if (code > 96) code - 96 else code - 64 + 26
fun main() {
fun part1(input: List<String>): Int {
var result = 0
for (line in input) {
val firstCompartment = IntArray(53)
for (i in 0 until line.length / 2) {
firstCompartment[line[i].p... | 0 | Kotlin | 0 | 0 | 0a9b360a5fb8052565728e03a665656d1e68c687 | 1,551 | advent-of-code-2022 | Apache License 2.0 |
dynamic_programming/UniquePathsII/kotlin/Solution.kt | YaroslavHavrylovych | 78,222,218 | false | {"Java": 284373, "Kotlin": 35978, "Shell": 2994} | /**
* A robot is located at the top-left corner of a m x n grid
* (marked 'Start' in the diagram below).
* The robot can only move either down or right at any point in time.
* The robot is trying to reach the bottom-right corner of the grid
* (marked 'Finish' in the diagram below).
* Now consider if some obsta... | 0 | Java | 0 | 2 | cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd | 1,313 | codility | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem516/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem516
/**
* LeetCode page: [516. Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence/);
*/
class Solution {
/* Complexity:
* Time O(N^2) and Space O(N^2) where N is the length of s;
*/
fun longestPalindromeSubseq(s: Stri... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,915 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/adventofcode/day7/Day7_2.kt | thelastnode | 160,586,229 | false | null | package adventofcode.day7
import java.io.File
import java.util.*
object Day7_2 {
data class Input(val step: String, val dependency: String)
private val LINE_REGEX = Regex("Step (\\w+) must be finished before step (\\w+) can begin")
fun parse(line: String): Input {
val match = LINE_REGEX.find(lin... | 0 | Kotlin | 0 | 0 | 8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa | 2,593 | adventofcode | MIT License |
2019/08 - Space Image Format/kotlin/src/app.kt | Adriel-M | 225,250,242 | false | null | import java.io.File
import java.nio.file.Path
fun main() {
val digits = extractDigits("../input")
println("===== Part 1 =====")
println(runPart1(digits))
println("===== Part 2 =====")
println(runPart2(digits))
}
fun runPart1(digits: List<Int>): Int {
val layers = partitionDigits(digits, 25 * ... | 0 | Kotlin | 0 | 0 | ceb1f27013835f13d99dd44b1cd8d073eade8d67 | 1,779 | advent-of-code | MIT License |
kotlin/src/katas/kotlin/eightQueen/EightQueen15.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.eightQueen
import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import org.junit.Test
import java.util.*
class EightQueen15 {
@Test fun `find queen positions on board`() {
(0..8).forEach { boardSize ->
val solutions = queenPositions(boardS... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 2,941 | katas | The Unlicense |
src/main/kotlin/aoc2023/day10/day10Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day10
import lib.*
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<Array<Array<Char>>> {
return setup {
day(10)
year(2023)
//input("example.txt")
parser {
it.readLines()
.get2DArrayOfColumns... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 3,532 | AoC-2023-DDJ | MIT License |
src/main/kotlin/com/ginsberg/advent2023/Day13.kt | tginsberg | 723,688,654 | false | {"Kotlin": 112398} | /*
* Copyright (c) 2023 by <NAME>
*/
/**
* Advent of Code 2023, Day 13 - Point of Incidence
* Problem Description: http://adventofcode.com/2023/day/13
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day13/
*/
package com.ginsberg.advent2023
import kotlin.math.absoluteValue
class Day1... | 0 | Kotlin | 0 | 12 | 0d5732508025a7e340366594c879b99fe6e7cbf0 | 2,197 | advent-2023-kotlin | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2020/Day07.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 7 - Handy Haversacks
* Problem Description: http://adventofcode.com/2020/day/7
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day7/
*/
package com.ginsberg.advent2020
class Day07(input: List<String>) {
private v... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 1,641 | advent-2020-kotlin | Apache License 2.0 |
src/main/kotlin/pl/jpodeszwik/aoc2023/Day15.kt | jpodeszwik | 729,812,099 | false | {"Kotlin": 55101} | package pl.jpodeszwik.aoc2023
import java.lang.Integer.parseInt
private fun hash(input: String): Int {
var current = 0
input.forEach { c ->
current += c.code
current *= 17
current %= 256
}
return current
}
private fun part1(input: String) {
val parts = input.split(",")
... | 0 | Kotlin | 0 | 0 | 2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63 | 1,744 | advent-of-code | MIT License |
src/Day11.kt | sitamshrijal | 574,036,004 | false | {"Kotlin": 34366} | fun main() {
fun parse(input: List<String>): List<Monkey> = input.chunked(7).map { Monkey.parse(it) }
fun part1(input: List<String>): Long {
val monkeys = parse(input)
val worryDecrease: (Item) -> (Item) = { Item(it.worryLevel / 3) }
repeat(20) {
monkeys.forEach { monkey ->... | 0 | Kotlin | 0 | 0 | fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d | 3,539 | advent-of-code-2022 | Apache License 2.0 |
src/day09/Code.kt | ldickmanns | 572,675,185 | false | {"Kotlin": 48227} | package day09
import readInput
import kotlin.math.abs
fun main() {
val input = readInput("day09/input")
// val input = readInput("day09/input_test")
// val input = readInput("day09/input_test_2")
println(part1(input))
println(part2(input))
}
data class Coordinates(
val x: Int,
val y: Int,... | 0 | Kotlin | 0 | 0 | 2654ca36ee6e5442a4235868db8174a2b0ac2523 | 3,599 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/tr/emreone/adventofcode/days/Day03.kt | EmRe-One | 726,902,443 | false | {"Kotlin": 95869, "Python": 18319} | package tr.emreone.adventofcode.days
import tr.emreone.kotlin_utils.automation.Day
class Day03 : Day(3, 2023, "Gear Ratios") {
class Part(val x: Int, val y: Int, val value: Int) {
fun getNeighbourFields(engine: Engine): List<Char> {
val neighbours = mutableListOf<Char>()
/*
... | 0 | Kotlin | 0 | 0 | c75d17635baffea50b6401dc653cc24f5c594a2b | 3,473 | advent-of-code-2023 | Apache License 2.0 |
src/day14/Day14.kt | MaxBeauchemin | 573,094,480 | false | {"Kotlin": 60619} | package day14
import readInput
import java.time.Instant
data class Coordinates(
val x: Int,
val y: Int
) {
fun plus(xChange: Int, yChange: Int) = Coordinates(x + xChange, y + yChange)
fun below() = plus(0, 1)
fun belowLeft() = plus(-1, 1)
fun belowRight() = plus(1, 1)
companion object {
... | 0 | Kotlin | 0 | 0 | 38018d252183bd6b64095a8c9f2920e900863a79 | 4,401 | advent-of-code-2022 | Apache License 2.0 |
src/Day02.kt | bin-wang | 573,219,628 | false | {"Kotlin": 4145} | fun main() {
fun occurrenceRule(minOccurrences: Int, maxOccurrences: Int, c: Char, password: String) =
password.count { it == c } in minOccurrences..maxOccurrences
fun positionRule(leftIndex: Int, rightIndex: Int, c: Char, password: String) =
(password[leftIndex - 1] == c) xor (password[rightIn... | 0 | Kotlin | 0 | 0 | 929f812efb37d5aea34e741510481ca3fab0c3da | 1,164 | aoc20-kt | Apache License 2.0 |
src/year2022/13/Day13.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`13`
import java.util.Stack
import readInput
sealed class Packet : Comparable<Packet> {
override fun compareTo(other: Packet): Int {
return when (compare(this, other)) {
true -> -1
false -> 1
null -> 0
}
}
data class Number(val value: ... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 4,586 | KotlinAdventOfCode | Apache License 2.0 |
src/Day01.kt | handrodev | 577,884,162 | false | {"Kotlin": 7670} | fun main() {
fun part1(input: List<String>): Int {
// Keep track of maximum calories carried by any elf
var maxCalories = 0
// Keep track of calories carried by current elf
var calories = 0
for (line in input) {
if (line.isBlank()) {
// Empty lin... | 0 | Kotlin | 0 | 0 | d95aeb85b4baf46821981bb0ebbcdf959c506b44 | 1,711 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day8.kt | amitdev | 574,336,754 | false | {"Kotlin": 21489} | import java.io.File
import java.lang.Integer.max
fun main() {
val result = File("inputs/day_8.txt").useLines { findScenicScore(it) }
println(result)
}
fun findVisible(lines: Sequence<String>) =
Grid(lines.map { line -> line.map { it.digitToInt()} }.toList())
.toVisbile()
fun findScenicScore(lines: Sequence... | 0 | Kotlin | 0 | 0 | b2cb4ecac94fdbf8f71547465b2d6543710adbb9 | 1,805 | advent_2022 | MIT License |
src/main/kotlin/y2022/day05/Day05.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2022.day05
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
part2 = { part2() }
)
}
data class Instruction (
val numberOfCrates: Int,
val from: Int,
val to: Int
)
fun input(): Pair<Map<Int, ArrayDeque<Char>>, List<Instruction>> {
val allTheLines ... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 2,376 | AdventOfCode | MIT License |
src/main/kotlin/_0079_WordSearch.kt | ryandyoon | 664,493,186 | false | null | // https://leetcode.com/problems/word-search
fun exist(board: Array<CharArray>, word: String): Boolean {
val visited = Array(board.size) { BooleanArray(board.first().size) }
for (row in board.indices) {
for (col in board.first().indices) {
if (dfs(row = row, col = col, index = 0, word = word... | 0 | Kotlin | 0 | 0 | 7f75078ddeb22983b2521d8ac80f5973f58fd123 | 1,343 | leetcode-kotlin | MIT License |
src/Day01.kt | andrikeev | 574,393,673 | false | {"Kotlin": 70541, "Python": 18310, "HTML": 5558} | fun main() {
fun part1(input: List<String>): Int {
var maxCals = 0
var curCal = 0
input.forEachIndexed { index, line ->
if (line.isNotBlank()) {
curCal += line.toInt()
}
if (line.isBlank() || index == line.lastIndex) {
if (c... | 0 | Kotlin | 0 | 1 | 1aedc6c61407a28e0abcad86e2fdfe0b41add139 | 1,666 | aoc-2022 | Apache License 2.0 |
src/day20/Day20.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day20
import readInput
import readTestInput
data class DataBuffer(
val originalIndex: Int,
val value: Long,
)
private fun List<String>.parseDataBuffers(): List<DataBuffer> =
mapIndexed { index, line -> DataBuffer(value = line.toLong(), originalIndex = index) }
private fun List<DataBuffer>.mixed(... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 2,234 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | ZiomaleQ | 573,349,910 | false | {"Kotlin": 49609} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0
for (line in input) {
val splitIndex = line.length / 2
val firstSection = line.substring(0, splitIndex)
val secondSection = line.substring(splitIndex)
val dupes = firstSection.filter { s... | 0 | Kotlin | 0 | 0 | b8811a6a9c03e80224e4655013879ac8a90e69b5 | 1,319 | aoc-2022 | Apache License 2.0 |
src/com/ncorti/aoc2023/Day22.kt | cortinico | 723,409,155 | false | {"Kotlin": 76642} | package com.ncorti.aoc2023
typealias CharCube = Array<Array<Array<Char>>>
data class Brick(
val name: Char,
val start: Triple<Int, Int, Int>,
val end: Triple<Int, Int, Int>,
var position: MutableList<Triple<Int, Int, Int>> = mutableListOf()
) {
fun getBricksAbove(world: CharCube, bricks: List<Bric... | 1 | Kotlin | 0 | 1 | 84e06f0cb0350a1eed17317a762359e9c9543ae5 | 4,869 | adventofcode-2023 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestStringChain.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 | 3,589 | kotlab | Apache License 2.0 |
src/Day05.kt | askeron | 572,955,924 | false | {"Kotlin": 24616} | class Day05 : Day<String>("CMZ", "MCD", "CNSZFDVLJ", "QNDWLMGNS") {
class State(initialCols: List<List<Char>>) {
private val cols = initialCols.map { it.toMutableList() }
fun movePart1(move: Move) {
repeat(move.count) { cols[move.to - 1] += cols[move.from - 1].removeLast() }
}
... | 0 | Kotlin | 0 | 1 | 6c7cf9cf12404b8451745c1e5b2f1827264dc3b8 | 1,860 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | Oktosha | 573,139,677 | false | {"Kotlin": 110908} | class MathVector(val x: Int, val y: Int) {
operator fun plus(other: MathVector): MathVector {
return MathVector(x + other.x, y + other.y)
}
}
val DIRECTION_OF_VIEW = listOf(MathVector(0, 1), MathVector(1, 0), MathVector(0, -1), MathVector(-1, 0))
@Suppress("BooleanMethodIsAlwaysInverted")
fun isWithin... | 0 | Kotlin | 0 | 0 | e53eea61440f7de4f2284eb811d355f2f4a25f8c | 2,878 | aoc-2022 | Apache License 2.0 |
src/Day18.kt | lsimeonov | 572,929,910 | false | {"Kotlin": 66434} | import java.math.BigInteger
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
data class Cube(val x: Int, val y: Int, val z: Int, val size: Int)
fun main() {
fun isNeighbor(cube1: Cube, cube2: Cube): Boolean {
// Check if the cubes are adjacent in the x, y, or z direction
retur... | 0 | Kotlin | 0 | 0 | 9d41342f355b8ed05c56c3d7faf20f54adaa92f1 | 6,896 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ClosestMeetingNode.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,407 | kotlab | Apache License 2.0 |
src/Day05.kt | b0n541 | 571,797,079 | false | {"Kotlin": 17810} | import java.util.*
fun main() {
fun String.parseLine(stacks: Int): List<Char> {
var result = ArrayList<Char>()
for (i in 0 until stacks) {
result.add(this[4 * i + 1])
}
return result
}
fun parseInitialStacks(input: List<String>): Map<Int, Deque<Char>> {
... | 0 | Kotlin | 0 | 0 | d451f1aee157fd4d47958dab8a0928a45beb10cf | 3,589 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/co/csadev/advent2022/Day08.kt | gtcompscientist | 577,439,489 | false | {"Kotlin": 252918} | /**
* Copyright (c) 2022 by <NAME>
* Advent of Code 2022, Day 8
* Problem Description: http://adventofcode.com/2021/day/8
*/
package co.csadev.advent2022
import co.csadev.adventOfCode.BaseDay
import co.csadev.adventOfCode.Resources.resourceAsList
import co.csadev.adventOfCode.asInt
import co.csadev.adventOfCode.in... | 0 | Kotlin | 0 | 1 | 43cbaac4e8b0a53e8aaae0f67dfc4395080e1383 | 2,086 | advent-of-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2015/Day21.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2015
import AoCDay
import util.match
// https://adventofcode.com/2015/day/21
object Day21 : AoCDay<Int>(
title = "RPG Simulator 20XX",
part1Answer = 91,
part2Answer = 158,
) {
private class Item(val cost: Int, val damage: Int, val armor: Int)
private val WEAPONS = listOf(
Item(... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,161 | advent-of-code-kotlin | MIT License |
src/Day02.kt | Tomcat88 | 572,566,485 | false | {"Kotlin": 52372} | fun main() {
fun part1(input: List<List<String>>): Int =
input.sumOf {
it[1].toRPS().round(it[0].toRPS()).total()
}
fun part2(input: List<List<String>>): Int =
input.sumOf {
it[0].toRPS().roundWithStrategy(it[1]).total()
}
val input = readInputAndSp... | 0 | Kotlin | 0 | 0 | 6d95882887128c322d46cbf975b283e4a985f74f | 1,642 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/net/wrony/aoc2023/a12/RiddleTake2.kt | kopernic-pl | 727,133,267 | false | {"Kotlin": 52043} | package net.wrony.aoc2023.a12
import kotlin.io.path.Path
import kotlin.io.path.readLines
fun txtToSprings2(s: String): Pair<String, List<Int>> {
return s.split(" ").let { (inp, desc) -> inp to desc.split(",").map { it.toInt() } }
}
val cache = mutableMapOf<Pair<String, List<Int>>, Long>()
fun scanput2(str: Str... | 0 | Kotlin | 0 | 0 | 1719de979ac3e8862264ac105eb038a51aa0ddfb | 1,563 | aoc-2023-kotlin | MIT License |
2021/src/day09/Solution.kt | vadimsemenov | 437,677,116 | false | {"Kotlin": 56211, "Rust": 37295} | package day09
import java.nio.file.Files
import java.nio.file.Paths
fun main() {
val dx = arrayOf(0, 1, 0, -1)
val dy = arrayOf(-1, 0, 1, 0)
fun part1(lines: Input): Int {
var answer = 0
for (x in lines.indices) {
outer@for (y in lines[x].indices) {
for (d in 0 until 4) {
val xx ... | 0 | Kotlin | 0 | 0 | 8f31d39d1a94c862f88278f22430e620b424bd68 | 2,230 | advent-of-code | Apache License 2.0 |
src/Dec8.kt | karlstjarne | 572,529,215 | false | {"Kotlin": 45095} | object Dec8 {
fun a(): Int {
val trees: List<List<Tree>> = getTreeMatrix()
trees.forEach {
updateTreeVisibility(it)
updateTreeVisibility(it.reversed())
}
transpose(trees).forEach {
updateTreeVisibility(it)
updateTreeVisibility(it.rev... | 0 | Kotlin | 0 | 0 | 9220750bf71f39f693d129d170679f3be4328576 | 3,285 | AoC_2022 | Apache License 2.0 |
src/Day02.kt | iamriajul | 573,026,906 | false | {"Kotlin": 3041} | fun main() {
fun part1(input: List<String>): Int {
fun shapeScore(shape: Char): Int {
return shape - 'X' + 1
}
fun resultScore(line: String): Int {
return when (line) {
"B X", "C Y", "A Z" -> 0
"A X", "B Y", "C Z" -> 3
... | 0 | Kotlin | 0 | 0 | 10c67022363478b37a7516e13a45552c7fd06097 | 1,346 | advent-of-code-kotlin-2022 | Apache License 2.0 |
rmq/SimpleSegmentTree.kt | wangchaohui | 737,511,233 | false | {"Kotlin": 36737} | class SimpleSegmentTree(private val n: Int) {
data class Interval(
val sum: Long = 0,
val maxPrefixSum: Long = sum,
val maxSuffixSum: Long = sum,
val maxSubArraySum: Long = sum,
) {
companion object {
fun combineNullable(l: Interval?, r: Interval?): Interval? ... | 0 | Kotlin | 0 | 0 | 241841f86fdefa9624e2fcae2af014899a959cbe | 1,835 | kotlin-lib | Apache License 2.0 |
src/year2021/Day10.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2021
import readLines
fun main() {
val input = readLines("2021", "day10")
val testInput = readLines("2021", "day10_test")
check(part1(testInput) == 26397)
println("Part 1:" + part1(input))
check(part2(testInput) == 288957L)
println("Part 2:" + part2(input))
}
private fun part1(i... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 2,276 | advent_of_code | MIT License |
advent2022/src/main/kotlin/year2022/Day02.kt | bulldog98 | 572,838,866 | false | {"Kotlin": 132847} | package year2022
import AdventDay
import year2022.Shape.*
import year2022.Outcome.*
private typealias Strategy = (String, String) -> Shape
private enum class Shape(val points: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3)
}
private enum class Outcome(val points: Int) {
LOSS(0),
DRAW(3),
WIN(6)
}
pr... | 0 | Kotlin | 0 | 0 | 02ce17f15aa78e953a480f1de7aa4821b55b8977 | 1,658 | advent-of-code | Apache License 2.0 |
src/main/kotlin/aoc2023/Day01.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import readInput
object Day01 {
fun part1(input: List<String>): Int {
return input.map { "${it.filter { c -> c.isDigit() }.take(1)}${it.filter { c -> c.isDigit() }.takeLast(1)}" }
.sumOf { it.toInt() }
}
fun part2(input: List<String>): Int {
val replacements = ... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 1,254 | adventOfCode | Apache License 2.0 |
src/main/kotlin/com/aoc2023/day2/Day2.kt | brookseakate | 729,329,997 | false | {"Kotlin": 8231} | package main.kotlin.com.aoc2023.day2
import main.kotlin.com.aoc2023.util.Utils.Companion.readFileAsMutableList
class Day2 {
companion object {
fun main() {
println("hello Day 2")
val bagContents = mapOf(
"red" to 12,
"green" to 13,
"blue" to 14,
)
// val input = r... | 0 | Kotlin | 0 | 0 | 885663f27a8d5f6e6c5eaf046df4234b49bc53b9 | 2,401 | advent-of-code-2023 | MIT License |
src/Day02.kt | sungi55 | 574,867,031 | false | {"Kotlin": 23985} | fun main() {
val day = "Day02"
val winCombination = setOf("A Y", "B Z", "C X")
val drawCombination = setOf("B X", "C Y", "A Z")
fun sumScore(moves: List<String>, isDefaultStrategy: Boolean) =
moves.map { move ->
move.takeIf { isDefaultStrategy } ?: move.swapToNewStrategy()
... | 0 | Kotlin | 0 | 0 | 2a9276b52ed42e0c80e85844c75c1e5e70b383ee | 1,597 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2017/Day16.kt | tginsberg | 112,672,087 | false | null | /*
* Copyright (c) 2017 by <NAME>
*/
package com.ginsberg.advent2017
/**
* AoC 2017, Day 16
*
* Problem Description: http://adventofcode.com/2017/day/16
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day16/
*/
class Day16(input: String, private val programNames: String = "abcdefghij... | 0 | Kotlin | 0 | 15 | a57219e75ff9412292319b71827b35023f709036 | 2,513 | advent-2017-kotlin | MIT License |
src/Day04.kt | F-bh | 579,719,291 | false | {"Kotlin": 5785} | fun main() {
val input = readDayInput(4)
val pairList = input.map { line ->
val pairList = line.split(",")
Pair(pairList[0], pairList[1])
}.map { pair ->
val split1 = pair.first.split("-")
val split2 = pair.second.split("-")
Pair(
split1[0].toInt()..split1... | 0 | Kotlin | 0 | 0 | 19fa2db8842f166daf3aaffd201544658f41d9e0 | 1,039 | Christmas2022 | Apache License 2.0 |
src/main/kotlin/y2016/day01/Day01.kt | TimWestmark | 571,510,211 | false | {"Kotlin": 97942, "Shell": 1067} | package y2016.day01
import java.lang.IllegalStateException
import kotlin.math.abs
fun main() {
AoCGenerics.printAndMeasureResults(
part1 = { part1() },
part2 = { part2() }
)
}
data class Instructions(
val turnDirection: TurnDirection,
val distance: Int
)
enum class TurnDirection {
... | 0 | Kotlin | 0 | 0 | 23b3edf887e31bef5eed3f00c1826261b9a4bd30 | 3,948 | AdventOfCode | MIT License |
2023/src/day09/day09.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day09
import GREEN
import RESET
import printTimeMillis
import readInput
private fun List<Int>.toDiffList(): List<List<Int>> {
val diffList = mutableListOf<List<Int>>().also { it.add(this) }
val diffs = toMutableList()
while (diffs.any { it != 0 }) {
val newDiffs = buildList {
... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 1,346 | advent-of-code | Apache License 2.0 |
src/day_02/Day02.kt | the-mgi | 573,126,158 | false | {"Kotlin": 5720} | package day_02
import readInput
fun main() {
fun obtainResult(myChoice: String, elfChoice: String): Int {
return when (myChoice) {
"X" -> if (elfChoice == "C") (1 + 6) else if (elfChoice == "A") (1 + 3) else 1
"Y" -> if (elfChoice == "A") (2 + 6) else if (elfChoice == "B") (2 + 3... | 0 | Kotlin | 0 | 0 | c7f9e9727ccdef9231f0cf125e678902e2d270f7 | 1,477 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/day8.kt | kevinrobayna | 436,414,545 | false | {"Ruby": 195446, "Kotlin": 42719, "Shell": 1288} | data class Instruction(
val operation: String,
val positive: Boolean,
val amount: Int
) {
companion object {
const val NOP = "nop"
const val ACC = "acc"
const val JUMP = "jmp"
}
}
fun day8ProblemReader(string: String): List<Instruction> {
val instructionRegex = """(\w+)\... | 0 | Ruby | 0 | 0 | 9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577 | 3,050 | adventofcode_2020 | MIT License |
libraries/mindiff/src/commonMain/kotlin/com/zegreatrob/mindiff/StringDiff.kt | robertfmurdock | 172,112,213 | false | {"Kotlin": 170915, "JavaScript": 796, "Batchfile": 697, "Dockerfile": 282} | package com.zegreatrob.mindiff
import kotlin.math.max
import kotlin.math.min
fun stringDiff(l: String, r: String): String {
val diff = diff(l, r)
val firstDiffIndex = diff.firstDiffIndex()
if (firstDiffIndex == -1) {
return ""
}
return differentSectionDescription(l, r, firstDiffIndex)
... | 0 | Kotlin | 2 | 6 | 9044806e7f09bb6365b1854a69a8cf67f2404587 | 2,488 | testmints | MIT License |
src/day20/Day20.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day20
import getWrapped
import readInput
const val day = "20"
fun <T> MutableList<T>.swap(idx1: Int, idx2: Int) {
val temp = this[idx1]
this[idx1] = this[idx2]
this[idx2] = temp
}
fun main() {
fun calculatePart1Score(input: List<String>): Int {
val numbers = input.map { it.toInt()... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 2,728 | advent-of-code-22-kotlin | Apache License 2.0 |
day-01/src/main/kotlin/SonarSweep.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | fun main() {
println("Part One Solution: ${partOne()}")
println("Part Two Solution: ${partTwo()}")
println("Part One Functional Solution: ${partOneFunctional()}")
println("Part Two Windowed Solution: ${partTwoWindowed()}")
}
fun partOne(): Int {
val lines = readInput()
var count = 0
for ... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 1,765 | aoc-2021 | MIT License |
src/main/kotlin/day8/Day8.kt | mortenberg80 | 574,042,993 | false | {"Kotlin": 50107} | package day8
class Day8(val input: List<String>) {
private val transposed = transpose(input)
val inputInts = input.map { it.toCharArray().map { it.digitToInt() } }
val transposedInts = transposed.map { it.toCharArray().map { it.digitToInt() } }
val visibleFromLeft = input.mapIndexed { rowNo, row ... | 0 | Kotlin | 0 | 0 | b21978e145dae120621e54403b14b81663f93cd8 | 6,188 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/aoc23/Day08.kt | tahlers | 725,424,936 | false | {"Kotlin": 65626} | package aoc23
object Day08 {
enum class Direction {
LEFT, RIGHT
}
data class Turn(val name: String, val leftName: String, val rightName: String) {
fun doTurn(direction: Direction) = if (direction == Direction.LEFT) leftName else rightName
}
data class PathStep(val stepCount: Int,... | 0 | Kotlin | 0 | 0 | 0cd9676a7d1fec01858ede1ab0adf254d17380b0 | 2,247 | advent-of-code-23 | Apache License 2.0 |
src/main/kotlin/Day13.kt | bent-lorentzen | 727,619,283 | false | {"Kotlin": 68153} | import java.time.LocalDateTime
import java.time.ZoneOffset
fun main() {
fun findReflectionPont(it: List<String>): Int {
it.forEachIndexed { index, s ->
if (index < it.lastIndex && s == it[index + 1]) {
if (index >= it.lastIndex / 2) {
val listAfterMirror = ... | 0 | Kotlin | 0 | 0 | 41f376bd71a8449e05bbd5b9dd03b3019bde040b | 4,205 | aoc-2023-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/sk/set3/373. Find K Pairs with Smallest Sums.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set3
import java.util.*
class Solution373 {
// TLE
fun kSmallestPairs(nums1: IntArray, nums2: IntArray, k: Int): List<List<Int>> {
val q = PriorityQueue<Pair<Int, List<Int>>> { p1, p2 -> p1.first - p2.first }
for (u in nums1) {
for (v in nums2) {
q.... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,192 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day20.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2016
import se.saidaspen.aoc.util.Day
fun main() = Day20.run()
object Day20 : Day(2016, 20) {
override fun part1(): Any {
var available = listOf(Pair(0L, 4294967295L))
for (l in input.lines()) {
val (a, b) = l.split("-")
val block = Pair(a.toLo... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,752 | adventofkotlin | MIT License |
src/main/kotlin/aoc2015/WizardSimulator.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2015
import utils.shortestPathWithCost
fun wizardSimulator(hard: Boolean = false): Int {
val initial = WizardSimulatorState(
bossHitPoints = 55,
wizardHitPoints = 50,
wizardMana = 500,
effects = emptyList(),
hard = hard
)
return shortes... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 3,053 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxValueBoundedArray.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,594 | kotlab | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/Day02.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | // Day 2: Cube Conundrum
// https://adventofcode.com/2023/day/2
import java.io.File
import kotlin.math.max
private const val RED = "red"
private const val GREEN = "green"
private const val BLUE = "blue"
private const val COLON = ":"
private const val COMMA = ","
private const val SEMI_COLON = ";"
fun main() {
v... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 1,956 | advent-of-code | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/combination_sum/CombinationSum.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.combination_sum
import datsok.shouldEqual
import org.junit.Test
class CombinationSumTests {
@Test fun `find all unique combinations where numbers sum up to target`() {
emptyList<Int>().combinations(target = 1) shouldEqual emptyList()
listOf(1).combinations(target = 0... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 1,583 | katas | The Unlicense |
src/main/kotlin/Day01.kt | rogierbom1 | 573,165,407 | false | {"Kotlin": 5253} | package main.kotlin
import readInput
data class Snack(var calories: Int)
data class Elf(var snacks: List<Snack>)
private fun Elf.totalCalories() = snacks.sumOf { it.calories }
private fun List<String>.toElves(): List<Elf> = this.flatMapIndexed { index, calories ->
when {
index == 0 || index == lastIndex... | 0 | Kotlin | 0 | 0 | b7a03e95785cb4a2ec0bfa170f4f667fc574c1d2 | 1,158 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day25.kt | MarkTheHopeful | 572,552,660 | false | {"Kotlin": 75535} | fun main() {
val digits = mapOf('2' to 2L, '1' to 1L, '0' to 0L, '-' to -1L, '=' to -2L)
val revDigits = mapOf(2L to '2', 1L to '1', 0L to '0', -1L to '-', -2L to '=')
fun fromFiveBalanced(line: String): Long {
var power = 1L
var value = 0L
line.reversed().forEach {
valu... | 0 | Kotlin | 0 | 0 | 8218c60c141ea2d39984792fddd1e98d5775b418 | 1,351 | advent-of-kotlin-2022 | Apache License 2.0 |
src/Day02.kt | KristianAN | 571,726,775 | false | {"Kotlin": 9011} | fun main() {
fun part1(input: List<String>): Int =
input.fold(0) { acc, s ->
val moves = s.split(" ")
acc + play(Move.fromInput(moves[0]), Move.fromInput(moves[1]))
}
fun part2(input: List<String>): Int =
input.fold(0) { acc, s ->
val moves = s.split(... | 0 | Kotlin | 0 | 0 | 3a3af6e99794259217bd31b3c4fd0538eb797941 | 1,852 | AoC2022Kt | Apache License 2.0 |
src/Day05.kt | uekemp | 575,483,293 | false | {"Kotlin": 69253} |
class Depot {
private val stacks = mutableListOf<ArrayDeque<Char>>()
private val moves = mutableListOf<Move>()
fun setup(stackCount: Int) {
repeat(stackCount) {
stacks.add(ArrayDeque())
}
}
fun add(stackNumber: Int, crate: Char) = stacks[stackNumber - 1].addLast(cra... | 0 | Kotlin | 0 | 0 | bc32522d49516f561fb8484c8958107c50819f49 | 3,000 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | Oli2861 | 572,895,182 | false | {"Kotlin": 16729} | fun getNumList(input: List<String>) = input.map { line ->
line.toCharArray().map { character ->
character.digitToInt()
}
}
fun getAmountOfVisibleTrees(input: List<String>): Int {
val numList = getNumList(input)
val isVisibleList: List<MutableList<Boolean>> = numList.map { it.map { false }.toMu... | 0 | Kotlin | 0 | 0 | 138b79001245ec221d8df2a6db0aaeb131725af2 | 2,480 | Advent-of-Code-2022 | Apache License 2.0 |
kotlin/combinatorics/BinomialCoefficients.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package combinatorics
import java.math.BigInteger
object BinomialCoefficients {
fun binomialTable(n: Int): Array<LongArray> {
val c = Array(n + 1) { LongArray(n + 1) }
for (i in 0..n) for (j in 0..i) c[i][j] = if (j == 0) 1 else c[i - 1][j - 1] + c[i - 1][j]
return c
}
fun binomia... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 1,764 | codelibrary | The Unlicense |
src/Day25.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | import kotlin.math.abs
import kotlin.math.pow
infix fun Long.`**`(exponent: Int): Long = toDouble().pow(exponent).toLong()
val powersOf5 = (0..20).map {
5L `**` it
}
val powersOf5Max = (0..20).map {
(0..it).sumOf { p -> 2 * powersOf5[p] }
}
fun main() {
fun parseSnafuToDecimal(snafu: String): Long {
... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 4,117 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/day08/Day08.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2022.day08
import check
import readInput
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("2022", "Day08_test")
check(part1(testInput), 21)
check(part2(testInput), 8)
val input = readInput("2022", "Day08")
println(part1(in... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 2,947 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/days/y2023/day21/Day21.kt | jewell-lgtm | 569,792,185 | false | {"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123} | package days.y2023.day21
import util.InputReader
typealias PuzzleLine = String
typealias PuzzleInput = List<PuzzleLine>
class Day21(val input: PuzzleInput) {
data class Position(
val y: Int,
val x: Int,
)
operator fun PuzzleInput.get(at: Position): Char {
return this[at.y][at.x]
... | 0 | Kotlin | 0 | 0 | b274e43441b4ddb163c509ed14944902c2b011ab | 3,523 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/main/kotlin/org/example/adventofcode/puzzle/Day03.kt | peterlambrechtDev | 573,146,803 | false | {"Kotlin": 39213} | package org.example.adventofcode.puzzle
import org.example.adventofcode.util.FileLoader
class Group {
private val elves : List<String>
constructor(elves: List<String>) {
this.elves = elves
}
fun intersect(): String {
var intersectSet = emptySet<Char>()
for (elf in elves) {
... | 0 | Kotlin | 0 | 0 | aa7621de90e551eccb64464940daf4be5ede235b | 2,426 | adventOfCode2022 | MIT License |
src/main/kotlin/hu/advent/of/code/year2022/day11/Puzzle11A.kt | sztojkatamas | 568,512,275 | false | {"Kotlin": 157914} | package hu.advent.of.code.year2022.day11
import hu.advent.of.code.AdventOfCodePuzzle
import hu.advent.of.code.BaseChallenge
import kotlin.math.floor
@AdventOfCodePuzzle
class Puzzle11A: BaseChallenge(2022) {
override fun run() {
printPuzzleName()
loadDataFromFile("data11.txt")
val monkeys... | 0 | Kotlin | 0 | 0 | 6aa9e53d06f8cd01d9bb2fcfb2dc14b7418368c9 | 2,728 | advent-of-code-universe | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.