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/Day02.kt | benwicks | 572,726,620 | false | {"Kotlin": 29712} | import kotlin.IllegalArgumentException
fun main() {
fun calculateTotalScore(input: List<String>, selfPlayInterpretationMethod: SelfPlayInterpretationMethod): Int {
var totalScore = 0
for (round in input) {
// parse plays in each round
val opponentPlay = Play.from(round[0])
... | 0 | Kotlin | 0 | 0 | fbec04e056bc0933a906fd1383c191051a17c17b | 3,193 | aoc-2022-kotlin | Apache License 2.0 |
src/day3/Day3.kt | calvin-laurenson | 572,736,307 | false | {"Kotlin": 16407} | package day2
import readInput
import java.lang.Exception
fun main() {
val priority = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toList()
fun commonChars(first: String, second: String): List<Char> {
val chars = mutableListOf<Char>()
for (char in first) {
if (second.cont... | 0 | Kotlin | 0 | 0 | 155cfe358908bbe2a554306d44d031707900e15a | 1,623 | aoc2022 | Apache License 2.0 |
leetcode2/src/leetcode/subsets.kt | hewking | 68,515,222 | false | null | package leetcode
import java.util.ArrayList
/**
* 78. 子集
*https://leetcode-cn.com/problems/subsets/
*
*给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。
说明:解集不能包含重复的子集。
示例:
输入: nums = [1,2,3]
输出:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/subse... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 2,030 | leetcode | MIT License |
src/Day13.kt | mihansweatpants | 573,733,975 | false | {"Kotlin": 31704} | import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.*
fun main() {
fun part1(input: String): Int {
val packetPairs = input
.split("\n\n")
.map { it.split("\n") }
.map { (left, right) -> Packet(Json.decodeFromString(left)) to Packet(Json.decode... | 0 | Kotlin | 0 | 0 | 0de332053f6c8f44e94f857ba7fe2d7c5d0aae91 | 2,478 | aoc-2022 | Apache License 2.0 |
src/day13/day13.kt | diesieben07 | 572,879,498 | false | {"Kotlin": 44432} | package day13
import streamInput
import java.io.IOException
import java.util.Comparator
import kotlin.text.StringBuilder
private val file = "Day13"
//private val file = "Day13Example"
sealed interface PacketElement {
fun toList(): L
data class C(val value: Int) : PacketElement {
override fun toList... | 0 | Kotlin | 0 | 0 | 0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6 | 3,620 | aoc-2022 | Apache License 2.0 |
leetcode2/src/leetcode/coin-change.kt | hewking | 68,515,222 | false | null | package leetcode
/**
*
322. 零钱兑换
* https://leetcode-cn.com/problems/coin-change/
* Created by test
* Date 2019/12/1 12:01
* Description
* 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。
* 如果没有任何一种硬币组合能组成总金额,返回 -1。
示例 1:
输入: coins = [1, 2, 5], amount = 11
输出: 3
解释: 11 = 5 + 5 + 1
示例 2:
输入: coins = [... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 3,977 | leetcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ImageOverlap.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 4,693 | kotlab | Apache License 2.0 |
src/day03/Day03.kt | shiddarthbista | 572,833,784 | false | {"Kotlin": 9985} | package day03
import readInput
fun main() {
fun priorityScore(commonChar: Char): Int =
when {
commonChar.isLowerCase() -> {
commonChar.code - 'a'.code + 1
}
commonChar.isUpperCase() -> {
commonChar.code - 'A'.code + 27
}
... | 0 | Kotlin | 0 | 0 | ed1b6a132e201e98ab46c8df67d4e9dd074801fe | 1,295 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/Day21.kt | Yeah69 | 317,335,309 | false | {"Kotlin": 73241} | class Day21 : Day() {
override val label: String get() = "21"
data class Food(val ingredients: List<String>, val allergens: List<String>)
private val foodRegex = """(.+) \(contains (.+)\)""".toRegex()
private val foods by lazy { input
.lineSequence()
.map {
val (ingredient... | 0 | Kotlin | 0 | 0 | 23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec | 2,750 | AdventOfCodeKotlin | The Unlicense |
archive/2022/Day19.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 33
private const val EXPECTED_2 = 62 * 56
private class Day19(isTest: Boolean) : Solver(isTest) {
// State: 8 ints
// 0,1,2,3 = produced good
// 4,5,6,7 = robots
private fun MutableList<Int>.produceGoods() {
(0..3).forEach { this[it] += this[it + 4] }
}
f... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 3,810 | advent-of-code-2022 | Apache License 2.0 |
src/Day09.kt | IvanChadin | 576,061,081 | false | {"Kotlin": 26282} | import kotlin.math.abs
import kotlin.math.sign
fun main() {
val inputName = "Day09_test"
val commands = readInput(inputName).map { s -> s.split(" ") }
data class Pt(var x: Int, var y: Int)
fun part1(commands: List<List<String>>): Int {
val visited = HashSet<Pt>()
val head = Pt(0, 0)
... | 0 | Kotlin | 0 | 0 | 2241437e6c3a20de70306a0cb37b6fe2ed8f9e3a | 2,716 | aoc-2022 | Apache License 2.0 |
src/Day20.kt | azat-ismagilov | 573,217,326 | false | {"Kotlin": 75114} | fun main() {
val day = 20
data class IndexedNumber(val index: Int, val number: Long)
fun part1(input: List<String>): Long {
val array = input.mapIndexed { index, c -> IndexedNumber(index, c.toLong()) }
val interestingPoints = listOf(1000, 2000, 3000)
val mutableArray = array.toM... | 0 | Kotlin | 0 | 0 | abdd1b8d93b8afb3372cfed23547ec5a8b8298aa | 1,816 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day03/Day03.kt | skempy | 572,602,725 | false | {"Kotlin": 13581} | package day03
import readInputAsList
fun main() {
var priority = 1
val priorities: Map<Char, Int> = (('a'..'z') + ('A'..'Z')).associateWith { priority++ }
fun part1(input: List<String>): Int {
return input
.map { it.chunked(it.length / 2) }
.map { Pair(it[0].toSet(), it[1... | 0 | Kotlin | 0 | 0 | 9b6997b976ea007735898083fdae7d48e0453d7f | 1,119 | AdventOfCode2022 | Apache License 2.0 |
src/Day03.kt | RogozhinRoman | 572,915,906 | false | {"Kotlin": 28985} | fun main() {
fun getPriority(c: Char): Int {
return if (c.isLowerCase()) c.code - 'a'.code + 1
else c.code - 'A'.code + 27
}
fun part1(input: List<String>) = input.sumOf { it ->
it.subSequence(0 until it.length / 2)
.toSet()
.intersect(it.subSequence(it.lengt... | 0 | Kotlin | 0 | 1 | 6375cf6275f6d78661e9d4baed84d1db8c1025de | 921 | AoC2022 | Apache License 2.0 |
src/Day16.kt | zfz7 | 573,100,794 | false | {"Kotlin": 53499} | fun main() {
println(day16A(readFile("Day16")))
println(day16B(readFile("Day16")))
}
fun parse16Input(input: String): Map<String, Valve> {
val list = input.trim().split("\n").map { line ->
val splitLine = line
.replace("valves", "valve")
.replace("leads", "lead")
... | 0 | Kotlin | 0 | 0 | c50a12b52127eba3f5706de775a350b1568127ae | 8,319 | AdventOfCode22 | Apache License 2.0 |
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day04.kt | jmerle | 434,010,865 | false | {"Kotlin": 60581} | package com.jaspervanmerle.aoc2021.day
class Day04 : Day("25410", "2730") {
private val markedNumbers = input
.lines()[0]
.split(",")
.map { it.toInt() }
private val boards = input.split("\n\n").drop(1).map { board ->
board.split("\n").map { row ->
row.split(" ").fi... | 0 | Kotlin | 0 | 0 | dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e | 1,674 | advent-of-code-2021 | MIT License |
src/main/kotlin/de/dikodam/calendar/Day02.kt | dikodam | 573,126,346 | false | {"Kotlin": 26584} | package de.dikodam.calendar
import de.dikodam.AbstractDay
import de.dikodam.calendar.MatchResult.*
import de.dikodam.calendar.RPS.*
import de.dikodam.executeTasks
import kotlin.time.ExperimentalTime
@ExperimentalTime
fun main() {
Day02().executeTasks()
}
class Day02 : AbstractDay() {
val inputLines = readInp... | 0 | Kotlin | 0 | 1 | 3eb9fc6f1b125565d6d999ebd0e0b1043539d192 | 2,914 | aoc2022 | MIT License |
src/Day25.kt | sitamshrijal | 574,036,004 | false | {"Kotlin": 34366} | fun main() {
fun parse(input: List<String>): List<Long> = input.map { it.toDecimal() }
fun part1(input: List<String>): String {
val numbers = parse(input)
return numbers.sum().toSnafu()
}
fun part2(input: List<String>): Int {
return input.size
}
val input = readInput("... | 0 | Kotlin | 0 | 0 | fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d | 1,329 | advent-of-code-2022 | Apache License 2.0 |
src/day05/Day05.kt | jacobprudhomme | 573,057,457 | false | {"Kotlin": 29699} | import java.io.File
typealias CrateStacks = Array<ArrayDeque<Char>>
typealias CraneProcedure = List<Triple<Int, Int, Int>>
fun main() {
fun readInput(name: String) = File("src/day05", name)
.readLines()
fun processInput(input: List<String>): Pair<CrateStacks, CraneProcedure> {
val craneProced... | 0 | Kotlin | 0 | 1 | 9c2b080aea8b069d2796d58bcfc90ce4651c215b | 2,300 | advent-of-code-2022 | Apache License 2.0 |
day04/kotlin/RJPlog/day2304_1_2.kt | mr-kaffee | 720,687,812 | false | {"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314} | import java.io.File
import kotlin.math.*
fun scratchCard(): Int {
var result = 0
val pattern = """(\d)+""".toRegex()
File("day2304_puzzle_input.txt").forEachLine {
var winningNumbers = pattern.findAll(it.substringAfter(": ").split(" | ")[0]).map { it.value }.toList()
var numbersYouHave = pattern.findAll(it.subs... | 0 | Rust | 2 | 0 | 5cbd13d6bdcb2c8439879818a33867a99d58b02f | 2,085 | aoc-2023 | MIT License |
src/Day08.kt | phoenixli | 574,035,552 | false | {"Kotlin": 29419} | fun main() {
fun part1(input: List<String>): Int {
val rows: MutableList<MutableList<Int>> = mutableListOf()
input.forEach{
val row = mutableListOf<Int>()
for(c in it.toCharArray()) {
row.add(c.toString().toInt())
}
rows.add(row)
... | 0 | Kotlin | 0 | 0 | 5f993c7b3c3f518d4ea926a792767a1381349d75 | 3,535 | Advent-of-Code-2022 | Apache License 2.0 |
src/aoc2022/Day23.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2022
import utils.Vertex
import utils.checkEquals
private typealias Elf = Vertex
fun main() {
fun part1(input: List<String>): Int {
return input.locateElvas().spreadOut(rounds = 10)
}
fun part2(input: List<String>): Int {
var firstNoMoveRound = 0
input.locateElva... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 2,963 | Kotlin-AOC-2023 | Apache License 2.0 |
src/Day12.kt | i-tatsenko | 575,595,840 | false | {"Kotlin": 90644} | typealias Board = List<String>
fun Point.toUp(): Point = Point(this.x - 1, y)
fun Point.toDown(): Point = Point(this.x + 1, y)
fun Point.toRight(): Point = Point(this.x, y + 1)
fun Point.toLeft(): Point = Point(this.x, y - 1)
fun Board.get(p: Point): Char = this[p.x][p.y]
fun Board.height(p: Point): Int {
return ... | 0 | Kotlin | 0 | 0 | 0a9b360a5fb8052565728e03a665656d1e68c687 | 3,871 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode2023/day15/day15.kt | dzkoirn | 725,682,258 | false | {"Kotlin": 133478} | package adventofcode2023.day15
import adventofcode2023.readInput
import kotlin.time.measureTime
fun main() {
println("Day 15")
val input = readInput("day15")
val time1 = measureTime {
println("Puzzle 1 ${handleSequence(input.first)}")
}
println("Puzzle 1 took $time1")
val time2 = meas... | 0 | Kotlin | 0 | 0 | 8f248fcdcd84176ab0875969822b3f2b02d8dea6 | 1,580 | adventofcode2023 | MIT License |
src/main/kotlin/adventofcode/year2021/Day13TransparentOrigami.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2021
import adventofcode.Puzzle
import adventofcode.PuzzleInput
class Day13TransparentOrigami(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val paper by lazy {
val dots = input.split("\n\n").first().lines().map { it.split(",").first().toInt() to it.split(",").l... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 2,020 | AdventOfCode | MIT License |
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day21.kt | jntakpe | 572,853,785 | false | {"Kotlin": 72329, "Rust": 15876} | package com.github.jntakpe.aoc2022.days
import com.github.jntakpe.aoc2022.shared.Day
import com.github.jntakpe.aoc2022.shared.readInputLines
object Day21 : Day {
override val input = readInputLines(21).associate { parse(it) }
private val results = input.mapNotNull { (k, v) -> (v as? Operation.Result)?.let {... | 1 | Kotlin | 0 | 0 | 63f48d4790f17104311b3873f321368934060e06 | 2,946 | aoc2022 | MIT License |
src/Day04.kt | stevennoto | 573,247,572 | false | {"Kotlin": 18058} | fun main() {
fun part1(input: List<String>): Int {
// Parse input ranges, check whether one contains another, count number that do
val regex = Regex("(\\d+)-(\\d+),(\\d+)-(\\d+)")
return input.count {
val (i, j, m, n) = regex.find(it)!!.destructured.toList().map { it.toInt() }
... | 0 | Kotlin | 0 | 0 | 42941fc84d50b75f9e3952bb40d17d4145a3036b | 1,047 | adventofcode2022 | Apache License 2.0 |
src/aoc2023/Day02.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
fun main() {
val MAX_RED = 12
val MAX_GREEN = 13
val MAX_BLUE = 14
val RED_REGEX = " (\\d+) red".toRegex()
val GREEN_REGEX = " (\\d+) green".toRegex()
val BLUE_REGEX = " (\\d+) blue".toRegex()
fun part1(input: List<String>): Long {
var sumOfIds = 0... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 2,341 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/com/txq/sort/Sort.kt | flyingyizi | 124,735,014 | false | null | package com.txq.com.txq.sort
//https://rosettacode.org/wiki/Category:Sorting_Algorithms
import java.util.Comparator
import java.util.Arrays
private val COMPARATOR = Comparator<Int> { o1, o2 ->
when {
o1 < o2 -> -1
o1 > o2 -> 1
else -> 0
}
}
fun main(args: Array<String>) {
val... | 0 | Kotlin | 0 | 0 | f4ace2d018ae8a93becaee85b7db882098074b7a | 4,319 | helloworldprovider | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindCheapestPrice.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,757 | kotlab | Apache License 2.0 |
src/Day07.kt | timlam9 | 573,013,707 | false | {"Kotlin": 9410} | fun main() {
class Node(
val name: String,
val parent: Node?,
var children: List<Node> = emptyList()
) {
var size: Long = 0L
val totalSize: Long
get() = size + children.sumOf { it.totalSize }
}
fun List<String>.createTree(): Pair<Node, MutableList<No... | 0 | Kotlin | 0 | 0 | 1df3465966915590022981546659ee4f1cdeb33b | 1,734 | AdventOfCodeKotlin2022 | Apache License 2.0 |
src/day03/Day03.kt | iulianpopescu | 572,832,973 | false | {"Kotlin": 30777} | package day03
import readInput
private const val DAY = "03"
private const val DAY_TEST = "day${DAY}/Day${DAY}_test"
private const val DAY_INPUT = "day${DAY}/Day${DAY}"
fun main() {
fun countCommonItems(value: String): Int {
val halfIndex = value.length / 2
val left = value.substring(0, halfIndex).... | 0 | Kotlin | 0 | 0 | 4ff5afb730d8bc074eb57650521a03961f86bc95 | 1,454 | AOC2022 | Apache License 2.0 |
src/day10/Day10.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package day10
import readInput
class Day10 {
fun part1(): Int {
val readInput = readInput("day10/input")
return part1(readInput)
}
fun part2(): List<String> {
val readInput = readInput("day10/input")
return part2(readInput)
}
fun part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 1,931 | adventofcode-2022 | Apache License 2.0 |
src/Day07.kt | DiamondMiner88 | 573,073,199 | false | {"Kotlin": 26457, "Rust": 4093, "Shell": 188} | import kotlin.math.abs
import kotlin.math.max
fun main() {
val input = readInput("input/day07.txt")
.split("\n")
.filter { it.isNotBlank() }
var cd = ""
val files = mutableMapOf<String, Int>()
var curCmd: String? = null
for (line in input) {
if (line[0] == '$') {
... | 0 | Kotlin | 0 | 0 | 55bb96af323cab3860ab6988f7d57d04f034c12c | 2,362 | advent-of-code-2022 | Apache License 2.0 |
src/Day01.kt | timj11dude | 572,900,585 | false | {"Kotlin": 15953} | fun main() {
fun Collection<String>.groupByBlankLine() = buildMap<Int, List<String>> {
var i = 0
this@groupByBlankLine.forEach {
if (it.isBlank()) i++
else this.compute(i) { _, e ->
if (e == null) listOf(it)
else (e + it)
}
... | 0 | Kotlin | 0 | 0 | 28aa4518ea861bd1b60463b23def22e70b1ed481 | 1,065 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | lbilger | 574,227,846 | false | {"Kotlin": 5366} | fun main() {
fun <T: Comparable<T>> ClosedRange<T>.containsAll(other: ClosedRange<T>) = start <= other.start && endInclusive >= other.endInclusive
fun String.toRange(): IntRange {
val parts = split("-")
return parts[0].toInt()..parts[1].toInt()
}
fun ranges(input: List<String>) = input... | 0 | Kotlin | 0 | 0 | 40d94a4bb9621af822722d20675684555cbee877 | 965 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | kkaptur | 573,511,972 | false | {"Kotlin": 14524} | fun main() {
val winningPairs = listOf(listOf("A", "B"), listOf("B", "C"), listOf("C", "A"))
fun part1(input: List<String>): Int {
var totalScore = 0
var myShapeTranslated = ""
var round = emptyList<String>()
var roundTranslated = emptyList<String>()
input.forEach {
... | 0 | Kotlin | 0 | 0 | 055073b7c073c8c1daabbfd293139fecf412632a | 2,151 | AdventOfCode2022Kotlin | Apache License 2.0 |
src/main/kotlin/solutions/day21/Day21.kt | Dr-Horv | 570,666,285 | false | {"Kotlin": 115643} | package solutions.day21
import solutions.Solver
enum class Operator {
TIMES,
PLUS,
DIV,
MINUS
}
sealed class MathMonkey {
abstract val name: String
abstract var value: Long?
data class ConstantMonkey(
override val name: String,
override var value: Long?
) : MathMonkey... | 0 | Kotlin | 0 | 2 | 6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e | 5,206 | Advent-of-Code-2022 | MIT License |
src/Day03.kt | hrach | 572,585,537 | false | {"Kotlin": 32838} | fun main() {
fun part1(input: List<String>): Int {
return input
.sumOf {
val l = it.length / 2
val a = it.substring(0, l).toSet()
val b = it.substring(l).toSet()
val shared = a.intersect(b).first()
if (shared.isLowerCase()) {
shared.code - 96
} else {
shared.code - 64 + 26
}
... | 0 | Kotlin | 0 | 1 | 40b341a527060c23ff44ebfe9a7e5443f76eadf3 | 777 | aoc-2022 | Apache License 2.0 |
src/Day06.kt | strindberg | 572,685,170 | false | {"Kotlin": 15804} | fun main() {
fun distinct(chars: List<Char>): Boolean {
for ((index, c) in chars.withIndex()) {
if (index + 1 <= chars.size) {
for (d in chars.subList(index + 1, chars.size)) {
if (c == d) return false
}
}
}
return t... | 0 | Kotlin | 0 | 0 | c5d26b5bdc320ca2aeb39eba8c776fcfc50ea6c8 | 1,189 | aoc-2022 | Apache License 2.0 |
kotlin/graphs/matchings/MaxBipartiteMatchingHopcroftKarpEsqrtV.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package graphs.matchings
import java.util.stream.Stream
// https://en.wikipedia.org/wiki/Hopcroft–Karp_algorithm
// time complexity: O(E * sqrt(V))
object MaxBipartiteMatchingHopcroftKarpEsqrtV {
fun maxMatching(graph: Array<List<Integer>>): Int {
val n1 = graph.size
val n2: Int = Arrays.stream(gr... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 2,359 | codelibrary | The Unlicense |
src/main/kotlin/com/hj/leetcode/kotlin/problem1926/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1926
/**
* LeetCode page: [1926. Nearest Exit from Entrance in Maze](https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/);
*/
class Solution {
/* Complexity:
* Time O(|maze|) and Space O(|maze|);
*/
fun nearestExit(maze: Array<CharArray>, entrance... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,513 | hj-leetcode-kotlin | Apache License 2.0 |
src/Year2022Day15.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | import kotlin.math.abs
fun main() {
val re = Regex("Sensor at x=(.*), y=(.*): closest beacon is at x=(.*), y=(.*)")
data class Sensor(
val x: Int,
val y: Int,
val r: Int, // scanningDistance
) {
fun canDiscover(x: Int, y: Int): Boolean =
abs(this.x - x) + abs(th... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 2,388 | aoc-2022-in-kotlin | Apache License 2.0 |
src/year2021/05/Day05.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2021.`05`
import readInput
private data class AdventPoint(
val x: Int,
val y: Int
) {
override fun toString(): String = "($x,$y)"
operator fun plus(other: AdventPoint): AdventPoint {
return this.copy(
x = x + other.x,
y = y + other.y
)
}
}
priv... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 3,563 | KotlinAdventOfCode | Apache License 2.0 |
src/Day16.kt | mrugacz95 | 572,881,300 | false | {"Kotlin": 102751} | import kotlin.math.max
import kotlin.math.min
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
private const val START = "AA"
private const val DEBUG = true
private data class Valve(val id: Int, val name: String, val rate: Int, val neighbours: List<String>, var open: Boolean = false) {
fun canOp... | 0 | Kotlin | 0 | 0 | 29aa4f978f6507b182cb6697a0a2896292c83584 | 4,645 | advent-of-code-2022 | Apache License 2.0 |
solutions/aockt/y2021/Y2021D02.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2021
import aockt.y2021.Y2021D02.SubmarineCommand.*
import io.github.jadarma.aockt.core.Solution
object Y2021D02 : Solution {
/** The valid submarine commands, they might do different things depending on how you read the manual. */
private sealed interface SubmarineCommand {
val amount... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 2,836 | advent-of-code-kotlin-solutions | The Unlicense |
advent/src/main/kotlin/org/elwaxoro/advent/Extensions.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent
import java.math.BigInteger
/**
* Nullable Long plusser, null defaults to 0
*/
fun Long.plusNull(that: Long?): Long = (that ?: 0L) + this
/**
* Split a string into a list of integers
* Ex: "01234" becomes [0, 1, 2, 3, 4]
*/
fun String.splitToInt(): List<Int> = map(Character::getNumer... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 3,302 | advent-of-code | MIT License |
advent-of-code2015/src/main/kotlin/day14/Advent14.kt | REDNBLACK | 128,669,137 | false | null | package day14
import parseInput
import splitToLines
import java.lang.Math.min
import java.util.*
/**
--- Day 14: Reindeer Olympics ---
This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally to recover their energy. Santa would like to know which of his reindeer is fastest, an... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 4,564 | courses | MIT License |
src/main/kotlin/aoc2022/Day15.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
import util.match
import kotlin.math.abs
import kotlin.math.max
// https://adventofcode.com/2022/day/15
object Day15 : AoCDay<Long>(
title = "Beacon Exclusion Zone",
part1Answer = 5832528,
part2Answer = 13360899249595,
) {
private fun manhattanDistance(x1: Int, y1: Int, x... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,989 | advent-of-code-kotlin | MIT License |
src/main/kotlin/day6/day6.kt | lavong | 317,978,236 | false | null | /*
--- Day 6: Custom Customs ---
As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers.
The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone in... | 0 | Kotlin | 0 | 1 | a4ccec64a614d73edb4b9c4d4a72c55f04a4b77f | 4,041 | adventofcode-2020 | MIT License |
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day08/Day08.kt | pfmaggi | 438,378,048 | false | {"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184} | /*
* 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 wr... | 0 | Kotlin | 0 | 0 | 7c4946b6a161fb08a02e10e99055a7168a3a795e | 3,531 | AdventOfCode | Apache License 2.0 |
src/main/java/com/barneyb/aoc/aoc2022/day20/GrovePositioningSystem.kt | barneyb | 553,291,150 | false | {"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020} | package com.barneyb.aoc.aoc2022.day20
import com.barneyb.aoc.util.Slice
import com.barneyb.aoc.util.Solver
import com.barneyb.aoc.util.toLong
import com.barneyb.aoc.util.toSlice
fun main() {
Solver.execute(
::parse,
::sumOfCoords_ptr, // 14888
::fullDecryption_ptr, // 3760092545849
)
... | 0 | Kotlin | 0 | 0 | 8b5956164ff0be79a27f68ef09a9e7171cc91995 | 3,795 | aoc-2022 | MIT License |
src/Day10.kt | valerakostin | 574,165,845 | false | {"Kotlin": 21086} | fun main() {
fun isCheckPoint(cycle: Int): Boolean {
return cycle == 20 || cycle == 60 || cycle == 100 ||
cycle == 140 || cycle == 180 || cycle == 220
}
fun part1(input: List<String>): Int {
var x = 1
var sum = 0
var cycles = 0
for (line in input) {... | 0 | Kotlin | 0 | 0 | e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1 | 2,034 | AdventOfCode-2022 | Apache License 2.0 |
2019/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2019/day06/day06.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.aoc2019.day06
import nl.sanderp.aoc.aoc2019.IO
import java.util.*
fun checksum(data: List<Pair<String, String>>): Int {
var checksum = 0
val visited = mutableSetOf<String>()
val queue = LinkedList<Pair<String, Int>>()
queue.add("COM" to 0)
while (queue.isNotEmpty()) {
... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 1,648 | advent-of-code | MIT License |
advent-of-code-2021/src/main/kotlin/Day10.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | //Day 10: Syntax Scoring
//https://adventofcode.com/2021/day/10
import java.io.File
fun main() {
val lines = File("src/main/resources/Day10.txt").readLines()
countSyntaxErrorScore(lines)
countIncompleteScore(lines)
}
fun countSyntaxErrorScore(lines: List<String>) {
val syntaxScore = lines.sumOf { lin... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 2,097 | advent-of-code | Apache License 2.0 |
src/day14/Day14.kt | gr4cza | 572,863,297 | false | {"Kotlin": 93944} | package day14
import Direction.*
import Edges
import Position
import readInput
val sandStartPos = Position(500, 0)
fun main() {
fun parseLines(input: List<String>): List<RockLine> {
return input.map { line ->
RockLine(line.split(" -> ").map { coords ->
val (x, y) = coords.split... | 0 | Kotlin | 0 | 0 | ceca4b99e562b4d8d3179c0a4b3856800fc6fe27 | 4,793 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Day18.kt | hughjdavey | 159,955,618 | false | null | package days
class Day18 : Day(18) {
override fun partOne(): Any {
var parsed = Day18.parseArea(inputList)
(1..10).forEach { parsed = Day18.doMinute(parsed) }
return parsed.flatten().count { it.isTrees() } * parsed.flatten().count { it.isYard() }
}
override fun partTwo(): Any {
... | 0 | Kotlin | 0 | 0 | 4f163752c67333aa6c42cdc27abe07be094961a7 | 4,029 | aoc-2018 | Creative Commons Zero v1.0 Universal |
2022/kotlin/app/src/main/kotlin/doy08/Day08.kt | jghoman | 726,228,039 | false | {"Kotlin": 15309, "Rust": 14555, "Scala": 1804, "Shell": 737} | package doy08
fun part1(input:String): Int {
val inputSplit = input
.split("\n")
.map { it -> it.map { it.digitToInt() } }
println("numRows = ${inputSplit.size}")
println("numCols = ${inputSplit[0].size}")
val z= (1 until inputSplit[0].size - 1)
.map{ i -> (1 until inputSplit... | 0 | Kotlin | 0 | 0 | 2eb856af5d696505742f7c77e6292bb83a6c126c | 3,986 | aoc | Apache License 2.0 |
src/day20/Code.kt | fcolasuonno | 225,219,560 | false | null | package day20
import isDebug
import java.io.File
import kotlin.math.abs
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 (paths, portals) = parse(input)
pri... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 4,535 | AOC2019 | MIT License |
src/day05/Day05.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package day05
import readInput
import java.util.*
class Day05 {
fun part1(): String {
val readInput = readInput("day05/input")
return part1(readInput)
}
fun part2(): String {
val readInput = readInput("day05/input")
return part2(readInput)
}
fun part1(input: List<... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 2,400 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/sorts/BubbleSorts.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,263 | kotlab | Apache License 2.0 |
src/test/kotlin/Day01.kt | christof-vollrath | 317,635,262 | false | null | import io.kotest.core.spec.style.DescribeSpec
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import java.lang.IllegalArgumentException
/*
--- Day 1: Report Repair ---
See https://adventofcode.com/2020/day/1
*/
fun findMatchingEntries(stars: List<Int>): Set<Int> {
stars.forEach { sta... | 1 | Kotlin | 0 | 0 | 8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8 | 2,918 | advent_of_code_2020 | Apache License 2.0 |
src/Day04-2.kt | casslabath | 573,177,204 | false | {"Kotlin": 27085} | fun main() {
operator fun IntRange.contains(other: IntRange): Boolean {
if(this.first >= other.first && this.last <= other.last) {
return true
}
return false
}
fun part1(input: List<String>): Int {
var containedPairs = 0
input.map {line ->
va... | 0 | Kotlin | 0 | 0 | 5f7305e45f41a6893b6e12c8d92db7607723425e | 1,279 | KotlinAdvent2022 | Apache License 2.0 |
src/day14.kts | miedzinski | 434,902,353 | false | {"Kotlin": 22560, "Shell": 113} | data class Rule(val pair: Pair<Char, Char>, val insertion: Char)
fun <K> MutableMap<K, Long>.increment(key: K, count: Long = 1) {
set(key, getOrDefault(key, 0) + count)
}
val elements = mutableMapOf<Char, Long>()
val pairs = readLine()!!.asSequence()
.onEach { elements.increment(it) }
.windowed(2) { (firs... | 0 | Kotlin | 0 | 0 | 6f32adaba058460f1a9bb6a866ff424912aece2e | 1,525 | aoc2021 | The Unlicense |
src/Day04.kt | petoS6 | 573,018,212 | false | {"Kotlin": 14258} | fun main() {
fun part1(input: List<String>): Int {
return input.filter { it.doesContainEachOther() }.size
}
fun part2(input: List<String>): Int {
return input.filter { it.hasOverlap() }.size
}
val testInput = readInput("Day04.txt")
println(part1(testInput))
println(part2(testInput))
}
private f... | 0 | Kotlin | 0 | 0 | 40bd094155e664a89892400aaf8ba8505fdd1986 | 1,022 | kotlin-aoc-2022 | Apache License 2.0 |
src/Day07.kt | mnajborowski | 573,619,699 | false | {"Kotlin": 7975} | fun main() {
fun prepareTree(input: List<String>): Map<String, Int> {
var cwd = ""
return buildMap {
(input + "\$ cd ..").forEach { command ->
when {
command.any { it.isDigit() } ->
putAll(mapOf(cwd to getOrElse(cwd) { 0 } + com... | 0 | Kotlin | 0 | 0 | e54c13bc5229c6cb1504db7e3be29fc9b9c4d386 | 1,401 | advent-of-code-2022 | Apache License 2.0 |
app/src/main/kotlin/day13/Day13.kt | W3D3 | 572,447,546 | false | {"Kotlin": 159335} | package day13
import com.beust.klaxon.JsonArray
import com.beust.klaxon.Parser
import common.InputRepo
import common.readSessionCookie
import common.solve
import util.split
fun main(args: Array<String>) {
val day = 13
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solv... | 0 | Kotlin | 0 | 0 | 34437876bf5c391aa064e42f5c984c7014a9f46d | 3,362 | AdventOfCode2022 | Apache License 2.0 |
kotlin/2020/round-1a/pascal-walk/src/main/kotlin/Solution.kt | ShreckYe | 345,946,821 | false | null | import java.util.*
fun main() {
val T = readLine()!!.toInt()
repeat(T) { t ->
val N = readLine()!!.toInt()
println("Case #${t + 1}:\n${case(N).joinToString("\n")}}")
}
}
data class Position(val r: Int, val k: Int) {
fun isValid() = r >= 0 && k >= 0 && k <= r
}
fun case(N: Int): List<P... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 1,911 | google-code-jam | MIT License |
src/day23/Day23.kt | felldo | 572,233,925 | false | {"Kotlin": 86889} | package day23
import readInput
private const val DAY_ID = "23"
private enum class Direction(val dx: Int, val dy: Int) {
N(-1, 0),
S(1, 0),
W(0, -1),
E(0, 1),
NW(-1, -1),
NE(-1, 1),
SW(1, -1),
SE(1, 1)
}
private data class Position(val row: Int, val col: Int) {
fun next(d: Directi... | 0 | Kotlin | 1 | 0 | 791dd54a4e23f937d5fc16d46d85577d91b1507a | 4,774 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | nic-dgl-204-fall-2022 | 552,171,003 | false | {"Kotlin": 6125} | fun main() {
fun remove(arr: IntArray, index: Int): IntArray {
if (index < 0 || index >= arr.size) {
return arr
}
val result = arr.toMutableList()
result.removeAt(index)
return result.toIntArray()
}
fun getSurfaceArea(l: Int, w: Int, h: Int): Int ... | 1 | Kotlin | 0 | 0 | 9abea167f1f43668eb7d4ddb445a45f501d4c4e1 | 2,164 | redjinator-aoc-1 | Apache License 2.0 |
src/main/kotlin/io/github/aarjavp/aoc/day10/Day10.kt | AarjavP | 433,672,017 | false | {"Kotlin": 73104} | package io.github.aarjavp.aoc.day10
import io.github.aarjavp.aoc.readFromClasspath
class Day10 {
enum class Brackets(val openingChar: Char, val closingChar: Char, val syntaxScore: Int, val autocompleteScore: Int) {
ROUND('(', ')', 3, 1),
SQUARE('[', ']', 57, 2),
CURLY('{', '}', 1197, 3),
... | 0 | Kotlin | 0 | 0 | 3f5908fa4991f9b21bb7e3428a359b218fad2a35 | 2,279 | advent-of-code-2021 | MIT License |
src/day15/a/day15a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day15.a
import readInputLines
import shouldBe
import util.IntRange
import util.IntRangeSet
import util.IntVector
import vec2
import java.util.regex.Pattern
import kotlin.math.abs
typealias Input = ArrayList<Pair<IntVector, IntVector>>
fun main() {
val input = read()
val row = 2000000
val e = IntR... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 1,305 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/fr/chezbazar/aoc21/day5/Day5.kt | chezbazar | 728,404,822 | false | {"Kotlin": 54427} | package fr.chezbazar.aoc21.day5
import fr.chezbazar.aoc21.Point
import fr.chezbazar.aoc21.computeFrom
const val arraySize = 1000
fun main() {
val ranges = mutableListOf<Pair<Point, Point>>()
computeFrom("day5/input.txt") {line ->
val (p1, p2) = line.split(" -> ")
ranges.add(p1.toPoint() to p2... | 0 | Kotlin | 0 | 0 | 223f19d3345ed7283f4e2671bda8ac094341061a | 1,227 | adventofcode | MIT License |
src/main/kotlin/dev/tasso/adventofcode/_2015/day03/Day03.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2015.day03
import dev.tasso.adventofcode.Solution
class Day02 : Solution<Int> {
override fun part1(input: List<String>): Int =
input.first()
.fold(listOf(Pair(0,0))) { visitedHouses, direction ->
visitedHouses.plus(
when(d... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 2,035 | advent-of-code | MIT License |
lib/src/main/kotlin/com/bloidonia/advent/day22/Day22.kt | timyates | 433,372,884 | false | {"Kotlin": 48604, "Groovy": 33934} | package com.bloidonia.advent.day22
import com.bloidonia.advent.readList
data class Cube(val on: Boolean, val x: IntRange, val y: IntRange, val z: IntRange)
fun String.toCube() = this.split(" ", limit = 2).let { (type, ranges) ->
ranges.split(",", limit = 3).let { (x, y, z) ->
val xs = x.split("=", limit ... | 0 | Kotlin | 0 | 1 | 9714e5b2c6a57db1b06e5ee6526eb30d587b94b4 | 1,183 | advent-of-kotlin-2021 | MIT License |
src/main/kotlin/com/groundsfam/advent/y2022/d02/Day02.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2022.d02
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
fun scorePartOne(opponentChoice: String, playerChoice: String): Int {
val opponentN = when (opponentChoice) {
"A" -> 1 // rock
... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,076 | advent-of-code | MIT License |
src/Day05.kt | cnietoc | 572,880,374 | false | {"Kotlin": 15990} | fun main() {
fun createCratesStack(inputIterator: Iterator<String>): CratesStack {
var line: String = inputIterator.next()
val cratesRaw: ArrayDeque<String> = ArrayDeque()
while (line.isNotBlank()) {
cratesRaw.addFirst(line)
line = inputIterator.next()
}
... | 0 | Kotlin | 0 | 0 | bbd8e81751b96b37d9fe48a54e5f4b3a0bab5da3 | 3,042 | aoc-2022 | Apache License 2.0 |
src/main/aoc2020/Day18.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2020
import java.lang.Integer.max
class Day18(input: List<String>) {
private val problems = input
.map { line -> line.mapNotNull { ch -> ch.takeUnless { it == ' ' } } }
.map { parseInput(it) }
sealed class Expression {
data class Operator(private val op: Char) : Exp... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 4,165 | aoc | MIT License |
src/main/kotlin/com/colinodell/advent2022/Day22.kt | colinodell | 572,710,708 | false | {"Kotlin": 105421} | package com.colinodell.advent2022
import kotlin.math.sqrt
class Day22(input: List<String>) {
private val grid = input.dropLast(2).toGrid().filter { it.value != ' ' }.toMutableMap()
private val pathToFollow = input.last().split("(?<=[A-Z])|(?=[A-Z])".toRegex())
private val startingPosition = grid.minOf { ... | 0 | Kotlin | 0 | 1 | 32da24a888ddb8e8da122fa3e3a08fc2d4829180 | 5,061 | advent-2022 | MIT License |
src/main/kotlin/day20/Day20ARegularMap.kt | Zordid | 160,908,640 | false | null | package day20
import shared.*
class NorthPoleMap(puzzle: String) {
private val rooms = mutableMapOf(0 toY 0 to BooleanArray(4))
private val searchEngine = SearchEngineWithNodes<Coordinate> {
it.manhattanNeighbors.filterIndexed { index, _ ->
rooms[it]?.get(index) ?: false
}
}
... | 0 | Kotlin | 0 | 0 | f246234df868eabecb25387d75e9df7040fab4f7 | 3,982 | adventofcode-kotlin-2018 | Apache License 2.0 |
src/year2022/day04/Day04.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day04
import io.kotest.matchers.shouldBe
import utils.readInput
fun main() {
val testInput = readInput("04", "test_input")
val realInput = readInput("04", "input")
parseInput(testInput)
.count { (firstRange, secondRange) -> fullyContains(firstRange, secondRange) }
.also(:... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 1,765 | Advent-of-Code | Apache License 2.0 |
src/main/kotlin/problems/Day23.kt | PedroDiogo | 432,836,814 | false | {"Kotlin": 128203} | package problems
import kotlin.math.abs
class Day23(override val input: String) : Problem {
override val number: Int = 23
override fun runPartOne(): String {
val burrow = Burrow.fromString(input)
return findMinimumComplete(burrow)
.toString()
}
override fun runPartTwo(): ... | 0 | Kotlin | 0 | 0 | 93363faee195d5ef90344a4fb74646d2d26176de | 9,954 | AdventOfCode2021 | MIT License |
src/main/kotlin/com/sk/set0/64. Minimum Path Sum.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set0
import kotlin.math.min
private fun minPathSum2(grid: Array<IntArray>): Int {
val r = grid.size
val c = grid[0].size
for (i in 1 until c) {
grid[0][i] += grid[0][i - 1]
}
for (i in 1 until r) {
grid[i][0] += grid[i - 1][0]
}
for (i in 1 until r) {
... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 1,572 | leetcode-kotlin | Apache License 2.0 |
src/Day01.kt | rickbijkerk | 572,911,701 | false | {"Kotlin": 31571} | fun main() {
fun getCalories(input: List<String>): MutableList<Int> {
val calories = mutableListOf<Int>()
val newLines = input.withIndex().filter { x -> x.value.isEmpty() }.map { it.index }.toMutableList()
newLines.add(input.size)
var start = 0
newLines.map { index ->
... | 0 | Kotlin | 0 | 0 | 817a6348486c8865dbe2f1acf5e87e9403ef42fe | 1,292 | aoc-2022 | Apache License 2.0 |
src/Day09.kt | WhatDo | 572,393,865 | false | {"Kotlin": 24776} | fun main() {
val input = readInput("Day09")
val rope2 = moveRope(RopeState.create(2), input)
println(rope2.tailHistory.size)
val rope10 = moveRope(RopeState.create(10), input)
println(rope10.tailHistory.size)
//10553 high
}
private fun moveRope(state: RopeState, input: List<String>): RopeSta... | 0 | Kotlin | 0 | 0 | 94abea885a59d0aa3873645d4c5cefc2d36d27cf | 1,954 | aoc-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | import java.lang.IllegalStateException
fun main() {
fun toPriority(c: Char): Int =
when (c) {
in 'a'..'z' -> c.code - 'a'.code + 1
in 'A'..'Z' -> c.code - 'A'.code + 27
else -> throw IllegalStateException("unexpected input $c")
}
fun part1(input: List<String... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 1,321 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day04.kt | illarionov | 572,508,428 | false | {"Kotlin": 108577} | val pairPattern: Regex = Regex("""(\d+)-(\d+),(\d+)-(\d+)""")
data class SectionAssignment(
val first: IntRange,
val second: IntRange
)
fun String.parseSectionAssignment(): SectionAssignment {
val result = pairPattern.matchEntire(this)?.groupValues ?:
error ("Can not parse `$this`")
return Sec... | 0 | Kotlin | 0 | 0 | 3c6bffd9ac60729f7e26c50f504fb4e08a395a97 | 1,168 | aoc22-kotlin | Apache License 2.0 |
src/questions/ThreeSumClosest.kt | realpacific | 234,499,820 | false | null | package questions
import algorithmdesignmanualbook.print
import kotlin.math.abs
import kotlin.test.assertEquals
/**
* Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.
* Return the sum of the three integers.
*
* [Source](https://leet... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,912 | algorithms | MIT License |
2020/src/year2020/day05/Day05.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2020.day05
import util.readAllLines
private fun findHighestSeat(seats: Set<Int>): Int {
return seats.maxOrNull() ?: -1
}
private fun findMySeat(seats: Set<Int>): Int {
for (i in 0 until 8*128) {
if (!seats.contains(i) && seats.contains(i - 1) && seats.contains(i + 1)) {
return... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 1,204 | adventofcode | MIT License |
src/main/kotlin/day11/Day11.kt | mortenberg80 | 574,042,993 | false | {"Kotlin": 50107} | package day11
import java.lang.IllegalArgumentException
class Day11(val input: List<String>) {
fun part1(): Long {
val monkies = parseInput(input, true)
println(monkies)
val game = Game(monkies)
(0 until 20).forEach { _ ->
game.performRound(1)
}
... | 0 | Kotlin | 0 | 0 | b21978e145dae120621e54403b14b81663f93cd8 | 5,243 | adventofcode2022 | Apache License 2.0 |
src/Day20.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import java.math.BigInteger
import java.util.*
import kotlin.math.max
import kotlin.math.min
class Day20 {
fun readInput(input: List<String>): List<Long> {
return input.map { it.toLong() }
}
fun decrypt(input: List<Long>, loop: Int = 1): List<Long> {
val result = input.mapIndexed { i, valu... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 2,365 | Advent-Of-Code-2022 | Apache License 2.0 |
src/main/kotlin/net/rafaeltoledo/kotlin/advent/Day04.kt | rafaeltoledo | 726,542,427 | false | {"Kotlin": 11895} | package net.rafaeltoledo.kotlin.advent
import kotlin.math.pow
class Day04 {
fun invoke(input: List<String>): Int {
val cards = input.map { it.toScratchCard() }
return cards
.map { card -> card.numbers.filter { card.winningNumbers.contains(it) } }
.sumOf { it.size.calculateCardValue() }
}
... | 0 | Kotlin | 0 | 0 | 7bee985147466cd796e0183d7c719ca6d01b5908 | 1,619 | aoc2023 | Apache License 2.0 |
src/main/kotlin/dev/claudio/adventofcode2021/Day16Part2.kt | ClaudioConsolmagno | 434,559,159 | false | {"Kotlin": 78336} | package dev.claudio.adventofcode2021
import org.apache.commons.lang3.StringUtils
import java.math.BigInteger
fun main() {
Day16Part2().main()
}
private class Day16Part2 {
fun main() {
tests()
val input: List<String> = Support.readFileAsListString("day16-input.txt")
val inputBinary = p... | 0 | Kotlin | 0 | 0 | 5f1aff1887ad0a7e5a3af9aca7793f1c719e7f1c | 5,231 | adventofcode-2021 | Apache License 2.0 |
2022/src/main/kotlin/day23.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Grid
import utils.Parser
import utils.Solution
import utils.Vec2i
import utils.borderWith
import utils.createGrid
import utils.mapParser
import java.util.Collections
import kotlin.math.absoluteValue
fun main() {
Day23.run()
}
object Day23 : Solution<Grid<Char>>() {
override val name = "day23"
overr... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 3,303 | aoc_kotlin | MIT License |
src/main/kotlin/com/groundsfam/advent/points/Points.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.points
import com.groundsfam.advent.Direction
import com.groundsfam.advent.asPoint
data class Point(val x: Int, val y: Int) {
operator fun plus(other: Point) = Point(x + other.x, y + other.y)
operator fun minus(other: Point) = Point(x - other.x, y - other.y)
operator fun time... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 1,536 | advent-of-code | MIT License |
src/main/kotlin/dev/paulshields/aoc/Day11.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 11: Dumbo Octopus
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.Point
import dev.paulshields.aoc.common.readFileAsString
fun main() {
println(" ** Day 11: Dumbo Octopus ** \n")
val dumboOctopuses = readFileAsString("/Day11DumboOctopuses.txt")
val numberOfFlashes = countNu... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 3,017 | AdventOfCode2021 | MIT License |
src/Day10.kt | bigtlb | 573,081,626 | false | {"Kotlin": 38940} | import java.lang.Math.abs
fun main() {
fun generateValues(input: List<String>): List<Int> {
val values = mutableListOf<Int>()
input.fold(1) { acc, cur ->
when (cur.substring(0..3)) {
"noop" -> {
values.add(acc)
acc
... | 0 | Kotlin | 0 | 0 | d8f76d3c75a30ae00c563c997ed2fb54827ea94a | 1,254 | aoc-2022-demo | Apache License 2.0 |
src/Day14.kt | lsimeonov | 572,929,910 | false | {"Kotlin": 66434} | import kotlin.math.abs
import kotlin.math.max
typealias Dot = Pair<Int, Int>
fun main() {
fun moveDot(a: Dot, b: Dot): Dot {
return Dot(a.first + b.first, a.second + b.second)
}
fun dotEquals(a: Dot, b: Dot): Boolean {
return a.first == b.first && a.second == b.second
}
fun part1... | 0 | Kotlin | 0 | 0 | 9d41342f355b8ed05c56c3d7faf20f54adaa92f1 | 5,781 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SimilarStringGroups.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 6,224 | kotlab | Apache License 2.0 |
src/main/kotlin/Day22.kt | clechasseur | 267,632,210 | false | null | import org.clechasseur.adventofcode2016.Day22Data
import org.clechasseur.adventofcode2016.Pt
object Day22 {
private val input = Day22Data.input
private val dfRegex = """^/dev/grid/node-x(\d+)-y(\d+)\s+(\d+)T\s+(\d+)T\s+(\d+)T\s+(\d+)%$""".toRegex()
fun part1(): Int {
val nodes = input.lines().ass... | 0 | Kotlin | 0 | 0 | 120795d90c47e80bfa2346bd6ab19ab6b7054167 | 1,770 | adventofcode2016 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.