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/AoC8.kt | Pi143 | 317,631,443 | false | null | import java.io.File
fun main() {
println("Starting Day 8 A Test 1")
calculateDay8PartA("Input/2020_Day8_A_Test1")
println("Starting Day 8 A Real")
calculateDay8PartA("Input/2020_Day8_A")
println("Starting Day 8 B Test 1")
calculateDay8PartB("Input/2020_Day8_A_Test1")
println("Starting Day... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 2,900 | AdventOfCode2020 | MIT License |
advent-of-code-2022/src/Day25.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | import kotlin.math.pow
fun main() {
val testInput = readLines("Day25_test")
val input = readLines("Day25")
"Part 1" {
part1(testInput) shouldBe "2=-1=0"
measureAnswer { part1(input) }
}
}
private fun part1(input: List<String>): String = input.sumOf { it.snafuToDecimal() }.decimalToSna... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 1,019 | advent-of-code | Apache License 2.0 |
year2023/src/cz/veleto/aoc/year2023/Day02.kt | haluzpav | 573,073,312 | false | {"Kotlin": 164348} | package cz.veleto.aoc.year2023
import cz.veleto.aoc.core.AocDay
class Day02(config: Config) : AocDay(config) {
private val availableCubes = mapOf(
Cube.Red to 12,
Cube.Green to 13,
Cube.Blue to 14,
)
override fun part1(): String = input
.parse()
.filter { (_, grab... | 0 | Kotlin | 0 | 1 | 32003edb726f7736f881edc263a85a404be6a5f0 | 1,778 | advent-of-pavel | Apache License 2.0 |
src/Day02.kt | joshpierce | 573,265,121 | false | {"Kotlin": 46425} | import java.io.File
fun main() {
// read the lines from the file
var lines: List<String> = File("Day02.txt").readLines()
// setup a new list of Games so we can calculate the outcome of each
var games: MutableList<Game> = lines.map {
var parts = it.split(" ")
return@map Game(par... | 0 | Kotlin | 0 | 1 | fd5414c3ab919913ed0cd961348c8644db0330f4 | 2,675 | advent-of-code-22 | Apache License 2.0 |
src/day04/Day04.kt | tschens95 | 573,743,557 | false | {"Kotlin": 32775} |
fun main() {
// check if r1 in r2 or r2 in r1
fun contains(r1: IntRange, r2: IntRange) : Boolean {
return (r2.first <= r1.first && r1.last <= r2.last)
|| (r1.first <= r2.first && r2.last <= r1.last)
}
// check borders of ranges for overlapping
fun overlap(r1: IntRange, r2:... | 0 | Kotlin | 0 | 2 | 9d78a9bcd69abc9f025a6a0bde923f53c2d8b301 | 1,820 | AdventOfCode2022 | Apache License 2.0 |
aoc-2015/src/main/kotlin/nl/jstege/adventofcode/aoc2015/days/Day16.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2015.days
import nl.jstege.adventofcode.aoccommon.days.Day
/**
*
* @author <NAME>
*/
class Day16 : Day(title = "Aunt Sue") {
private companion object Configuration {
private const val TARGET_AUNT_STRING = "Sue 0: " +
"children: 3, " +
"... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 2,408 | AdventOfCode | MIT License |
src/main/kotlin/dev/tasso/adventofcode/_2021/day12/Day12.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2021.day12
import dev.tasso.adventofcode.Solution
class Day12 : Solution<Int> {
override fun part1(input: List<String>): Int {
return getPathsSmallCavesOnce(parseCaveGraph(input)).size
}
override fun part2(input: List<String>): Int {
return getPathsSmall... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 2,717 | advent-of-code | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-21.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2022
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2022, "21-input")
val testInput1 = readInputLines(2022, "21-test1")
println("Part1:")
part1(testInput1).print... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 4,115 | advent-of-code | MIT License |
src/Day12.kt | MickyOR | 578,726,798 | false | {"Kotlin": 98785} | import java.util.Queue
fun main() {
fun getElevation(c: Char): Int {
if (c == 'S') return 0
if (c == 'E') return 'z' - 'a'
return c - 'a'
}
fun part1(input: List<String>): Int {
var n = input.size-1
var m = input[0].length
var r = 0
var c = 0
... | 0 | Kotlin | 0 | 0 | c24e763a1adaf0a35ed2fad8ccc4c315259827f0 | 2,825 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/iii_conventions/MyDate.kt | jerome-fosse | 149,761,327 | true | {"Kotlin": 75783, "Java": 4952} | package iii_conventions
import iii_conventions.TimeInterval.*
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) {
fun nextDay(): MyDate = this + DAY
operator fun compareTo(other: MyDate): Int {
if (this.year == other.year) {
if (this.month == other.month) {
... | 0 | Kotlin | 0 | 0 | e2029254a81d3de7c1ded41aa33a411e75a15dac | 2,942 | kotlin-koans | MIT License |
src/main/kotlin/Day16.kt | jcornaz | 573,137,552 | false | {"Kotlin": 76776} | import java.util.*
private typealias ValveId = String
object Day16 {
private val LINE_REGEX = Regex("Valve ([A-Z]+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)")
fun part1(input: String, time: Int = 30): Int {
val valves = input.lineSequence()
.map(::parseValve)
.to... | 1 | Kotlin | 0 | 0 | 979c00c4a51567b341d6936761bd43c39d314510 | 3,668 | aoc-kotlin-2022 | The Unlicense |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[剑指 Offer 53 - I]在排序数组中查找数字 I.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //统计一个数字在排序数组中出现的次数。
//
//
//
// 示例 1:
//
// 输入: nums = [5,7,7,8,8,10], target = 8
//输出: 2
//
// 示例 2:
//
// 输入: nums = [5,7,7,8,8,10], target = 6
//输出: 0
//
//
//
// 限制:
//
// 0 <= 数组长度 <= 50000
//
//
//
// 注意:本题与主站 34 题相同(仅返回值不同):https://leetcode-cn.com/problems/find-first-and-last-
//position-of-element-in-... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,248 | MyLeetCode | Apache License 2.0 |
2022/src/test/kotlin/Day20.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
class Day20 : StringSpec({
"puzzle part 01" {
val (file, mix) = getFile()
file.indices.forEach { mix.move(file[it]) }
mix.sumOfGroveCoordinates() shouldBe 9945
}
"puzzle part 02" {
val (file, m... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 1,772 | adventofcode | MIT License |
y2020/src/main/kotlin/adventofcode/y2020/Day14.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2020
import adventofcode.io.AdventSolution
import adventofcode.util.SimpleParser
fun main() = Day14.solve()
object Day14 : AdventSolution(2020, 14, "Docking Data")
{
override fun solvePartOne(input: String): Long
{
val mem = mutableMapOf<Long, Long>()
lateinit var mask:... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,918 | advent-of-code | MIT License |
src/test/kotlin/be/brammeerten/y2022/Day21Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2022
import be.brammeerten.extractRegexGroups
import be.brammeerten.readFile
import be.brammeerten.y2022.Day21Test.MonkeyOperation.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
class Day21Test {
@Test
fun `part 1a`() {
val monkeys = read... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 5,296 | Advent-of-Code | MIT License |
gcj/y2022/round2/b_wip.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package gcj.y2022.round2
import kotlin.math.floor
import kotlin.math.round
import kotlin.math.sqrt
private fun rFloor(x: Int, y: Int) = floor(sqrt(1.0 * x * x + 1.0 * y * y)).toInt()
private fun y(x: Int, r: Int): Int {
return round(sqrt(1.0 * r * r - 1.0 * x * x)).toInt()
}
private fun skips(rFloor: Int, x: Int, y:... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,127 | competitions | The Unlicense |
src/Day10.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | // https://adventofcode.com/2022/day/10
fun main() {
fun registerValuesAtEachCycle(input: List<String>): List<Int> {
var lastRegisterValue = 1
return buildList {
add(lastRegisterValue)
for (operation in input.map(Operation::fromString)) {
repeat(operation.cycl... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 2,008 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day04.kt | tomoki1207 | 572,815,543 | false | {"Kotlin": 28654} | fun main() {
fun toPairs(input: List<String>) = input.map { line ->
val pair = line.split(",")
val first = pair[0].split("-").let { Pair(it[0].toInt(), it[1].toInt()) }
val second = pair[1].split("-").let { Pair(it[0].toInt(), it[1].toInt()) }
Pair((first.first..first.second).map { ... | 0 | Kotlin | 0 | 0 | 2ecd45f48d9d2504874f7ff40d7c21975bc074ec | 906 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/hongwei/leetcode/playground/leetcodecba/M75SortColors.kt | hongwei-bai | 201,601,468 | false | {"Java": 143669, "Kotlin": 38875} | package hongwei.leetcode.playground.leetcodecba
import hongwei.leetcode.playground.common.print
class M75SortColors {
fun test() {
val testData = listOf(
arrayOf(
intArrayOf(2, 0, 2, 1, 1, 0),
intArrayOf(0, 0, 1, 1, 2, 2)
),
arrayOf(
... | 0 | Java | 0 | 1 | 9d871de96e6b19292582b0df2d60bbba0c9a895c | 2,760 | leetcode-exercise-playground | Apache License 2.0 |
tasks-3/lib/src/main/kotlin/flows/algo/Dinitz.kt | AzimMuradov | 472,473,231 | false | {"Kotlin": 127576} | package flows.algo
import flows.structures.Matrix
import flows.structures.Network
/**
* The Dinitz's Algorithm.
*/
public fun <V> Network<V>.calculateDinitzMaxflow(): UInt {
var maxflow = 0u
val verticesList = graph.vertices.toList()
val verticesIndexed = run {
var j = 0
graph.vertices.... | 0 | Kotlin | 0 | 0 | 01c0c46df9dc32c2cc6d3efc48b3a9ee880ce799 | 2,925 | discrete-math-spbu | Apache License 2.0 |
src/aoc2022/day05/Day05.kt | svilen-ivanov | 572,637,864 | false | {"Kotlin": 53827} | package aoc2022.day05
import readInput
fun parseConfig(input: List<String>): List<ArrayDeque<String>> {
val stacks = mutableListOf<ArrayDeque<String>>()
for ((index, line) in input.withIndex()) {
val chunks = line.chunked(4)
val stackEntries = chunks.map { it[1].toString().trim() }
if... | 0 | Kotlin | 0 | 0 | 456bedb4d1082890d78490d3b730b2bb45913fe9 | 2,466 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Sand.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | fun main() = Sand.solve()
private object Sand {
fun solve() {
val input = readInput()
val (grid, start) = inputToGrid(input)
drawGrid(grid)
println("Start: $start")
drawGrid(addSand(grid, start))
}
private fun addSand(grid: List<MutableList<Cell>>, start: Pos): List... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 4,436 | aoc2022 | MIT License |
src/Day10.kt | OskarWalczak | 573,349,185 | false | {"Kotlin": 22486} | fun main() {
fun readRegisterValues(input: List<String>): Map<Int, Int>{
val registerValues: MutableMap<Int, Int> = HashMap()
registerValues[0] = 1
var currentCycleNumber = 1
input.forEach { line ->
if (line.trim() == "noop"){
if(registerValues[currentCy... | 0 | Kotlin | 0 | 0 | d34138860184b616771159984eb741dc37461705 | 2,363 | AoC2022 | Apache License 2.0 |
src/2022/Day20.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | package `2022`
import readInput
fun main() {
fun mixing(coordinates: List<Long>, items: MutableList<IndexedValue<Long>>, iterations: Int) {
repeat(iterations) {
coordinates.forEachIndexed { coordIndex, coord ->
val index = items.indexOfFirst { it.index == coordIndex }
... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 2,363 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | paulbonugli | 574,065,510 | false | {"Kotlin": 13681} | typealias Stacks = Array<ArrayDeque<Char>>
val UPPERCASE_LETTERS = "([A-Z])".toRegex()
fun makeStacks(lines : List<String>) : Stacks {
var stackLines = lines.takeWhile { it.isNotBlank() }
val numStacks = stackLines.last().split(" ").last().toInt()
stackLines = stackLines.dropLast(1)
val stacks : Stack... | 0 | Kotlin | 0 | 0 | d2d7952c75001632da6fd95b8463a1d8e5c34880 | 1,959 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/be/seppevolkaerts/day8/Day8.kt | Cybermaxke | 727,453,020 | false | {"Kotlin": 35118} | package be.seppevolkaerts.day8
class Data(
val instructions: String,
val nodes: List<Node>
)
interface Node {
val key: String
val left: Node?
val right: Node?
}
fun parseData(iterable: Iterable<String>): Data {
val instructions = iterable.first()
data class NodeImpl(
override val key: String,
... | 0 | Kotlin | 0 | 1 | 56ed086f8493b9f5ff1b688e2f128c69e3e1962c | 2,494 | advent-2023 | MIT License |
codeforces/codeton6/e.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.codeton6
import java.util.BitSet
private fun solve(): Int {
readln()
val a = readInts()
val highMex = (a.size + 1).takeHighestOneBit() * 2
val mark = IntArray(a.size + 1) { -1 }
val memo = List(highMex) { BitSet() }
val dp = mutableListOf(BitSet())
val (dpMax, dpSum) = List(2) { IntArray(a.s... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,215 | competitions | The Unlicense |
src/main/kotlin/Day03.kt | uipko | 572,710,263 | false | {"Kotlin": 25828} | val characters = ('a'..'z') + ('A'..'Z')
fun main() {
val items = doubleItems("Day03.txt").sum()
println("The total sum of double items is: $items")
val badges = badges("Day03.txt").sum()
println("The total sum of double items is: $badges")
}
fun doubleItems(fileName: String): List<Int> {
return ... | 0 | Kotlin | 0 | 0 | b2604043f387914b7f043e43dbcde574b7173462 | 807 | aoc2022 | Apache License 2.0 |
src/Day02.kt | mddanishansari | 576,622,315 | false | {"Kotlin": 11861} | fun main() {
fun <T> List<T>.toPair(): Pair<T, T> {
if (this.size != 2) {
throw IllegalArgumentException("List is not of length 2!")
}
return Pair(this[0], this[1])
}
fun round(round: String): Pair<String, String> {
return round.replace("X", "A")
.rep... | 0 | Kotlin | 0 | 0 | e032e14b57f5e6c2321e2b02b2e09d256a27b2e2 | 2,927 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day16/part2.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day16
fun identifyFieldIndex(
nearbyTickets: List<List<Int>>,
ticketFields: Map<String, List<IntRange>>
): Map<String, Int> {
val possibilities = findPossibleIndexesForFields(nearbyTickets, ticketFields)
val resultMap = mutableMapOf<String, Int>()
while (res... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 2,098 | advent-of-code-2020 | MIT License |
src/day3/Day03.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | import java.math.BigInteger
private fun createResult(text: String): BigInteger {
var result = BigInteger.ZERO
for (item in text) {
val index = item - if (item.isUpperCase()) 'A' - 26 else 'a'
result = result or (BigInteger.ONE shl index)
}
return result
}
private fun findIndex(item: Bi... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 1,421 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/problems/Day8.kt | PedroDiogo | 432,836,814 | false | {"Kotlin": 128203} | package problems
class Day8(override val input: String) : Problem {
override val number: Int = 8
private val entries: List<Entry> = input.lines().map { Entry.fromString(it) }
override fun runPartOne(): String {
return entries
.flatMap { entry -> entry.outputValues }
.count ... | 0 | Kotlin | 0 | 0 | 93363faee195d5ef90344a4fb74646d2d26176de | 4,261 | AdventOfCode2021 | MIT License |
src/Day04.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | fun main() {
fun parseElfPairs(input: List<String>): List<Pair<InclusiveRange, InclusiveRange>> {
return input.map { line->
val points = line.split(',', '-').map { it.toInt() }
check(points.size == 4)
Pair(InclusiveRange(points[0], points[1]), InclusiveRange(points[2], po... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 906 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/RiverSize.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.algorithms.graph
import java.util.*
fun riverSizes(matrix: List<List<Int>>): List<Int> {
val visited = List(matrix.size) { MutableList(matrix[0].size) { false } }
val result = mutableListOf<Int>()
for (i in 0 until matrix.size) {
for (j in 0 until matrix[0].size) {... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 1,844 | DS_Algo_Kotlin | MIT License |
src/main/kotlin/adventofcode2023/day1/day1.kt | dzkoirn | 725,682,258 | false | {"Kotlin": 133478} | package adventofcode2023.day1
import adventofcode2023.readInput
fun main() {
val list = readInput("day1.txt")
println("Day 1")
println("Puzzle 1 : ${puzzle1(list)}")
println("Puzzle 2 : ${puzzle2(list)}")
}
fun puzzle1(input: List<String>): Int {
return input.sumOf { l -> l.first(Char::isDigit).d... | 0 | Kotlin | 0 | 0 | 8f248fcdcd84176ab0875969822b3f2b02d8dea6 | 1,684 | adventofcode2023 | MIT License |
src/Day02/Day02.kt | JamesKing95 | 574,470,043 | false | {"Kotlin": 7225} | package Day02
import readInput
fun main() {
val testInput = readInput("Day02/Day02_test")
check(part1(testInput) == 15)
check(part2(testInput) == 12)
val input = readInput("Day02/Day02")
println("Part 1: ".plus(part1(input)))
println("Part 2: ".plus(part2(input)))
}
fun part1(input: List<S... | 0 | Kotlin | 0 | 0 | cf7b6bd5ae6e13b83d871dfd6f0a75b6ae8f04cf | 2,078 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day7.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.nio.charset.Charset
fun main() {
fun countOptions(policyLines: List<String>): Int {
val policies = policyLines.associate { policy ->
val separators = policy.split("bags contain"); Pair(
separators[0].trim(),
separators[1].dropLast(1).rep... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 2,039 | aoc2020 | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2021/d13/Day13.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2021.d13
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.points.Point
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
import kotlin.math.min
// e.g. y=3 corresponds to Fold(along=3, isHorizontal=true)
private data class Fol... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,222 | advent-of-code | MIT License |
src/Day02.kt | daletools | 573,114,602 | false | {"Kotlin": 8945} | fun main() {
fun part1(input: List<String>): Int {
var score = 0
for (match in input) {
val elf = match.first()
val player = match.last()
when (player) {
'X' -> score += 1
'Y' -> score += 2
'Z' -> score += 3
... | 0 | Kotlin | 0 | 0 | c955c5d0b5e19746e12fa6a569eb2b6c3bc4b355 | 1,853 | adventOfCode2022 | Apache License 2.0 |
src/year2022/day10/Day.kt | tiagoabrito | 573,609,974 | false | {"Kotlin": 73752} | package year2022.day10
import kotlin.math.abs
import readInput
fun main() {
val day = "10"
val expectedTest1 = 13140
val expectedTest2 = """
##..##..##..##..##..##..##..##..##..##..
###...###...###...###...###...###...###.
####....####....####....####....####....
... | 0 | Kotlin | 0 | 0 | 1f9becde3cbf5dcb345659a23cf9ff52718bbaf9 | 1,780 | adventOfCode | Apache License 2.0 |
src/main/kotlin/aoc/year2023/Day05.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2023
import aoc.Puzzle
/**
* [Day 5 - Advent of Code 2023](https://adventofcode.com/2023/day/5)
*/
object Day05 : Puzzle<Long, Long> {
override fun solvePartOne(input: String): Long {
val sections = input.split(Regex("(\\r?\\n){2}"))
val seeds = sections.first().removePrefix("see... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 1,510 | advent-of-code | Apache License 2.0 |
src/day11/day11.kt | Eynnzerr | 576,874,345 | false | {"Kotlin": 23356} | package day11
import java.io.File
import kotlin.math.absoluteValue
fun main() {
val rounds = 10000
val monkeys = File("src/day11/input.txt")
.readLines()
.split("")
.map {
val (items, operation, test, b1, b2) = it.drop(1)
Monkey(
items = extract... | 0 | Kotlin | 0 | 0 | 92e85d65f62900d98284cbc9f6f9a3010efb21b7 | 2,315 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | Allagash | 572,736,443 | false | {"Kotlin": 101198} | import java.io.File
// Advent of Code 2022, Day 07, No Space Left On Device
fun main() {
fun readInputAsOneLine(name: String) = File("src", "$name.txt").readText().trim()
data class SubFile(val name: String, val size: Int)
data class Node(val name: String,
val parent: Node?,
... | 0 | Kotlin | 0 | 0 | 8d5fc0b93f6d600878ac0d47128140e70d7fc5d9 | 3,273 | AdventOfCode2022 | Apache License 2.0 |
src/Day11.kt | dizney | 572,581,781 | false | {"Kotlin": 105380} | object Day11 {
const val EXPECTED_PART1_CHECK_ANSWER = 10605L
const val EXPECTED_PART2_CHECK_ANSWER = 2713310158
const val PART1_RUNS = 20
const val PART2_RUNS = 10_000
const val WORRY_LEVEL_DIVISION_AMOUNT = 3
val MONKEY_LINE_ITEMS = Regex("\\s+Starting items: ([, \\d]+)")
val MONKEY_LIN... | 0 | Kotlin | 0 | 0 | f684a4e78adf77514717d64b2a0e22e9bea56b98 | 4,764 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | frungl | 573,598,286 | false | {"Kotlin": 86423} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf {
val (f, s) = it.split(' ')
val fVal = when(f) {
"A" -> 0
"B" -> 1
"C" -> 2
else -> -1
}
val sVal = when(s) {
... | 0 | Kotlin | 0 | 0 | d4cecfd5ee13de95f143407735e00c02baac7d5c | 1,377 | aoc2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/day13/day13Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day13
import lib.*
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<List<Area>> {
return setup {
day(13)
year(2023)
//input("example.txt")
parser {
it.getStringsGroupedByEmptyLine()
.map {
... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 2,988 | AoC-2023-DDJ | MIT License |
app/src/main/java/com/pryanik/mastermind/logic/Mastermind.kt | oQaris | 447,290,858 | false | {"Kotlin": 28432} | package com.pryanik.mastermind.logic
import com.google.common.collect.Collections2
import com.google.common.collect.Sets
import com.google.common.math.LongMath
import kotlin.math.min
data class ResultGuess(val guess: String, val isWin: Boolean)
data class BullsAndCows(val bulls: Int)
fun genPossibleAnswers(values: ... | 0 | Kotlin | 0 | 0 | 21c7a6874c1ca58c7c9cdf473e9d032a43002493 | 1,732 | MasterMind | MIT License |
src/day08/Day08.kt | martindacos | 572,700,466 | false | {"Kotlin": 12412} | package day08
import readInput
fun main() {
fun readMatrix(input: List<String>): List<List<Int>> {
val matrix: MutableList<List<Int>> = mutableListOf()
for (line in input) {
matrix.add(line.toCharArray().map { c -> c.digitToInt() })
}
return matrix
}
fun bigge... | 0 | Kotlin | 0 | 0 | f288750fccf5fbc41e8ac03598aab6a2b2f6d58a | 4,045 | 2022-advent-of-code-kotlin | Apache License 2.0 |
src/Day20.kt | anilkishore | 573,688,256 | false | {"Kotlin": 27023} | fun main() {
fun part1(nums: List<Long>, mult: Long = 1, times: Int = 1): Long {
val n = nums.size
val numList = mutableListOf<Pair<Long, Int>>()
for (i in nums.indices) {
numList.add(Pair(nums[i] * mult, i))
}
repeat(times) {
for (i in nums.indices)... | 0 | Kotlin | 0 | 0 | f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9 | 1,341 | AOC-2022 | Apache License 2.0 |
src/Day04.kt | mihansweatpants | 573,733,975 | false | {"Kotlin": 31704} | fun main() {
fun part1(input: List<String>): Int {
return input.stream()
.map { it.parseRegionPair() }
.filter { (first, second) -> first.fullyContains(second) || second.fullyContains(first) }
.count()
.toInt()
}
fun part2(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | 0de332053f6c8f44e94f857ba7fe2d7c5d0aae91 | 1,188 | aoc-2022 | Apache License 2.0 |
day04/kotlin/gysel/src/main/kotlin/Main.kt | rdmueller | 158,926,869 | false | null | import kotlin.system.measureTimeMillis
fun main() {
val millis = measureTimeMillis {
val data = openStream().reader().useLines { lines: Sequence<String> ->
lines.filter(String::isNotEmpty)
.sorted()
.map(::parse)
.toList()
}
... | 26 | HTML | 18 | 19 | 1a0e6d89d5594d4e6e132172abea78b41be3850b | 4,377 | aoc-2018 | MIT License |
src/main/kotlin/_2022/Day24.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2022
import readInput
fun main() {
val directions = listOf(
Pair(0, 1), //right
Pair(1, 0), // bottom
Pair(0, -1), // left
Pair(-1, 0), // top
Pair(0, 0), // current position
)
data class Blizzard(val position: Pair<Int, Int>, val direction: Pair<Int, In... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 5,409 | advent-of-code | Apache License 2.0 |
src/main/kotlin/io/github/ajoz/puzzles/Day01.kt | ajoz | 574,043,593 | false | {"Kotlin": 21275} | package io.github.ajoz.puzzles
import io.github.ajoz.utils.head
import io.github.ajoz.utils.readInput
import io.github.ajoz.utils.tail
/**
* --- Day 1: Calorie Counting ---
*
* The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition
* traditionally goes... | 0 | Kotlin | 0 | 0 | 6ccc37a4078325edbc4ac1faed81fab4427845b8 | 4,067 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/io/dp/LongestIncreasingSubsequence.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.dp
import io.utils.runTests
import java.util.*
// https://leetcode.com/problems/longest-increasing-subsequence/
class LongestIncreasingSubsequence {
fun execute(input: IntArray): Int {
val dp = IntArray(input.size)
var len = 0
for (value in input) {
val index = Arrays.binarySearch(dp,... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,667 | coding | MIT License |
src/day05/Day05.kt | EndzeitBegins | 573,569,126 | false | {"Kotlin": 111428} | package day05
import readInput
import readTestInput
private fun List<String>.parse(): Pair<List<String>, List<String>> {
val stackNumberLineIndex = this.indexOfFirst { line -> line.contains("""\d""".toRegex()) }
val stacksDefinitions = this.take(stackNumberLineIndex + 1)
val rawInstructions = this.drop(s... | 0 | Kotlin | 0 | 0 | ebebdf13cfe58ae3e01c52686f2a715ace069dab | 3,421 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dp/SubsetSum.kt | yx-z | 106,589,674 | false | null | package dp
import util.OneArray
import util.get
import util.set
import util.toOneArray
// given an array of positive integers and an integer, determine if any subset of the array can sum
// up to the integer
fun main(args: Array<String>) {
val arr = intArrayOf(1, 6, 4)
val ints = intArrayOf(7, // true
5, // true... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,787 | AlgoKt | MIT License |
src/Day05.kt | atsvetkov | 572,711,515 | false | {"Kotlin": 10892} | import java.util.Stack
typealias CrateStack = Stack<Char>
data class Crates(val crateStacks: List<CrateStack>) {
fun apply(move: Move) {
val fromStack = crateStacks[move.from-1]
val toStack = crateStacks[move.to-1]
move.take(fromStack).forEach(toStack::push)
}
override fun toStrin... | 0 | Kotlin | 0 | 0 | 01c3bb6afd658a2e30f0aee549b9a3ac4da69a91 | 3,536 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day4.kt | C06A | 435,034,782 | false | {"Kotlin": 20662} | package days
class Day4 : Day(4) {
override fun partOne(): Any {
val drowing = inputList[0].split(",").map { it.toInt() }
val cards = inputList.drop(1).fold(mutableListOf<Card>()) { cards, line ->
if (line.trim().length == 0) {
cards += Card()
} else {
... | 0 | Kotlin | 0 | 0 | afbe60427eddd2b6814815bf7937a67c20515642 | 2,629 | Aoc2021 | Creative Commons Zero v1.0 Universal |
src/leetcodeProblem/leetcode/editor/en/BestTimeToBuyAndSellStockWithTransactionFee.kt | faniabdullah | 382,893,751 | false | null | //You are given an array prices where prices[i] is the price of a given stock
//on the iᵗʰ day, and an integer fee representing a transaction fee.
//
// Find the maximum profit you can achieve. You may complete as many
//transactions as you like, but you need to pay the transaction fee for each transaction.
//
// No... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 1,835 | dsa-kotlin | MIT License |
src/main/kotlin/dp/LDIS.kt | yx-z | 106,589,674 | false | null | package dp
import util.get
import util.max
import util.set
// longest double increaasing subsequence
// X[1..n] is double increasing if X[i] > X[i - 2] for all i > 2
// intuitively, X is a perfect shuffle of two increasing sequences
// find the length of the ldis of A[1..n]
fun main(args: Array<String>) {
val A =... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,678 | AlgoKt | MIT License |
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day24/Day24.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2020.day24
import eu.janvdb.aocutil.kotlin.hexagonal.HexagonalCoordinate
import eu.janvdb.aocutil.kotlin.hexagonal.HexagonalDirection
import eu.janvdb.aocutil.kotlin.hexagonal.bottomRight
import eu.janvdb.aocutil.kotlin.hexagonal.topLeft
import eu.janvdb.aocutil.kotlin.readLines
const val NUMBER_... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 2,115 | advent-of-code | Apache License 2.0 |
src/Day03.kt | jordan-thirus | 573,476,470 | false | {"Kotlin": 41711} | fun main() {
fun getItemPriority(item: Char): Int{
val priority = if(item.isLowerCase()) {
item.minus('a') + 1
} else {
item.minus('A') + 27
}
return priority
}
fun part1(input: List<String>): Int {
fun findItemToRearrange(items: String): Char... | 0 | Kotlin | 0 | 0 | 59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e | 1,228 | advent-of-code-2022 | Apache License 2.0 |
neetcode/src/main/java/org/arrays/Arrays&Hashing.kt | gouthamhusky | 682,822,938 | false | {"Kotlin": 24242, "Java": 24233} | package org.arrays
import kotlin.math.max
fun containsDuplicate(nums: IntArray): Boolean = nums.size > nums.toSet().size
fun isAnagram(s: String, t: String): Boolean {
if (s.length != t.length)
return false
val list = MutableList(26){0}
for (i in s.indices){
val sPosition = s[i].toInt() -... | 0 | Kotlin | 0 | 0 | a0e158c8f9df8b2e1f84660d5b0721af97593920 | 3,910 | leetcode-journey | MIT License |
src/Day08.kt | Jintin | 573,640,224 | false | {"Kotlin": 30591} | import kotlin.math.max
fun main() {
fun buildMap(input: List<String>): Array<IntArray> {
val map: Array<IntArray> = Array(input.size) {
IntArray(input[0].length)
}
input.forEachIndexed { i, s ->
s.forEachIndexed { j, c ->
map[i][j] = c - '0'
... | 0 | Kotlin | 0 | 2 | 4aa00f0d258d55600a623f0118979a25d76b3ecb | 3,206 | AdventCode2022 | Apache License 2.0 |
src/day3/day3.kts | SebastianSiebert | 225,128,001 | false | null | import java.io.File
import kotlin.system.exitProcess
data class Point(val x: Int, val y: Int)
enum class Direction {
UP, DOWN, LEFT, RIGHT, INVALID
}
val wire1: ArrayList<Point> = ArrayList<Point>()
val wire2: ArrayList<Point> = ArrayList<Point>()
fun getDirection(direction: String) = when (direction.substring(0... | 0 | Kotlin | 0 | 0 | 69a734d8abf2dd93c62a6e0e5a7eedb76e0c13a3 | 2,214 | AdventOfCode2019 | MIT License |
src/Day03.kt | pydaoc | 573,843,750 | false | {"Kotlin": 8484} | fun main() {
fun generateAlphabet(): Set<Char> {
var lowercaseFirstCharacter = 'a'
val lowercaseAlphabet = generateSequence {
(lowercaseFirstCharacter++).takeIf { it <= 'z' }
}
var uppercaseFirstCharacter = 'A'
val uppercaseAlphabet = generateSequence {
... | 0 | Kotlin | 0 | 0 | 970dedbfaf09d12a29315c6b8631fa66eb394054 | 1,940 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | asm0dey | 572,860,747 | false | {"Kotlin": 61384} | fun main() {
fun letterToCode(it: Char) = if (it.isUpperCase()) it.code - 38 else it.code - 96
fun part1(input: List<String>): Int {
return input
.asSequence()
.filterNot(String::isBlank)
.map(String::toList)
.map { it.subList(0, it.size / 2).toSet().inte... | 1 | Kotlin | 0 | 1 | f49aea1755c8b2d479d730d9653603421c355b60 | 999 | aoc-2022 | Apache License 2.0 |
src/Day01.kt | alex-damico | 573,006,242 | false | {"Kotlin": 1664} | fun main() {
fun headAndTail(input: List<String>): Pair<List<String>, List<String>> {
val head = input.takeWhile { it.isNotBlank() }
val tail = input.dropWhile { it.isNotBlank() }.drop(1)
return head to tail
}
fun splitOnSpaces(input: List<String>): List<List<String>> {
val ... | 0 | Kotlin | 0 | 0 | 656c679139519ab4548a4c8457114e904399a83d | 1,023 | adventofcode | Apache License 2.0 |
src/main/kotlin/days/Solution21.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.Point2D
import adventOfCode.util.plus
private val directions = listOf(1 to 0, 0 to 1, -1 to 0, 0 to -1)
object Solution21 : Solution<Triple<Set<Point2D>, Point2D, Int>>(AOC_YEAR, 21) {
override fun getInput(handle... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 2,569 | Advent-of-Code-2023 | MIT License |
src/Day02.kt | imavroukakis | 572,438,536 | false | {"Kotlin": 12355} | fun main() {
val handLookup = mapOf(
"A" to Rock,
"B" to Paper,
"C" to Scissors,
"X" to Rock,
"Y" to Paper,
"Z" to Scissors,
)
fun String.toHand(): Hand = handLookup.getValue(this)
fun part1(input: List<String>): Int = input.sumOf {
val split... | 0 | Kotlin | 0 | 0 | bb823d49058aa175d1e0e136187b24ef0032edcb | 2,105 | advent-of-code-kotlin | Apache License 2.0 |
src/Day07.kt | tsschmidt | 572,649,729 | false | {"Kotlin": 24089} | import java.security.InvalidParameterException
fun main() {
data class File(val name: String, val size: Long)
class Directory(val name: String, val parent: Directory?) {
val files = mutableListOf<File>()
val dirs = mutableListOf<Directory>()
var size = 0L
}
fun a... | 0 | Kotlin | 0 | 0 | 7bb637364667d075509c1759858a4611c6fbb0c2 | 2,263 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | Aldas25 | 572,846,570 | false | {"Kotlin": 106964} | fun main() {
fun outcome(opponent: Int, me: Int): Int {
if (opponent == me) {
return 1
}
if ((opponent+1)%3 == me) {
return 2
}
return 0
}
fun charToNum(c: Char): Int {
if (c == 'A' || c == 'X')
return 0
if (c == '... | 0 | Kotlin | 0 | 0 | 80785e323369b204c1057f49f5162b8017adb55a | 2,226 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day02.kt | tbilou | 572,829,933 | false | {"Kotlin": 40925} | fun main() {
fun score(row: String): Int {
return when (row) {
"A X" -> 3 + 1
"A Y" -> 6 + 2
"A Z" -> 0 + 3
"B X" -> 0 + 1
"B Y" -> 3 + 2
"B Z" -> 6 + 3
"C X" -> 6 + 1
"C Y" -> 0 + 2
"C Z" -> 3 + 3
... | 0 | Kotlin | 0 | 0 | de480bb94785492a27f020a9e56f9ccf89f648b7 | 1,279 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | jaldhar | 573,188,501 | false | {"Kotlin": 14191} | fun main() {
fun String.parse(): Pair<IntRange, IntRange> {
val matches = """(\d+)\-(\d+)\,(\d+)\-(\d+)""".toRegex().find(this)
val (a1, a2, b1, b2) = matches!!.destructured
val first = IntRange(a1.toInt(), a2.toInt())
val second = IntRange(b1.toInt(), b2.toInt())
return Pa... | 0 | Kotlin | 0 | 0 | b193df75071022cfb5e7172cc044dd6cff0f6fdf | 1,209 | aoc2022-kotlin | Apache License 2.0 |
src/day05/Day05.kt | EdwinChang24 | 572,839,052 | false | {"Kotlin": 20838} | package day05
import readInput
fun main() {
part1()
part2()
}
fun part1() = common { input, stacks ->
for (line in input) if (line.startsWith("move")) {
val asList = line.removePrefix("move ").split(" from ", " to ").map { it.toInt() }
repeat(asList[0]) { stacks[asList[2] - 1] += stacks[a... | 0 | Kotlin | 0 | 0 | e9e187dff7f5aa342eb207dc2473610dd001add3 | 1,360 | advent-of-code-2022 | Apache License 2.0 |
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day04/Day04.kt | nerok | 572,862,875 | false | {"Kotlin": 113337} | package nerok.aoc.aoc2022.day04
import nerok.aoc.utils.Input
import kotlin.time.DurationUnit
import kotlin.time.measureTime
fun main() {
fun part1(input: List<String>): Long {
return input
.map { line ->
line.split(',')
.map { range ->
... | 0 | Kotlin | 0 | 0 | 7553c28ac9053a70706c6af98b954fbdda6fb5d2 | 1,751 | AOC | Apache License 2.0 |
kotlin/src/main/kotlin/de/p58i/advent-03.kt | mspoeri | 573,120,274 | false | {"Kotlin": 31279} | package de.p58i
import java.io.File
import java.util.LinkedList
class Backpack(
val items: List<Char>
) {
val firstCompartment: List<Char>
val secondCompartment: List<Char>
val sharedItem: Char
companion object{
fun separateCompartments(items: List<Char>): Pair<List<Char>,List<Char>... | 0 | Kotlin | 0 | 1 | 62d7f145702d9126a80dac6d820831eeb4104bd0 | 2,162 | Advent-of-Code-2022 | MIT License |
src/Day02.kt | andyludeveloper | 573,249,939 | false | {"Kotlin": 7818} | fun main() {
val map = mapOf(
"A Y" to 8,
"A X" to 4,
"A Z" to 3,
"B X" to 1,
"B Y" to 5,
"B Z" to 9,
"C X" to 7,
"C Y" to 2,
"C Z" to 6
)
val map2 = mapOf(
"A X" to "Z",
"A Y" to "X",
"A Z" to "Y",
"B X... | 0 | Kotlin | 0 | 1 | 684cf9ff315f15bf29914ca25b44cca87ceeeedf | 1,348 | Kotlin-in-Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2016/day3/Triangles.kt | arnab | 75,525,311 | false | null | package aoc2016.day3
data class Triangle(val a: Int, val b: Int, val c: Int) {
fun isValid(): Boolean = (a + b > c) && (b + c > a) && (c + a > b)
}
object Triangles {
fun countValid(data: String): Int {
return data.lines()
.map(String::trim)
.filter(String::isNotBlan... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 1,604 | adventofcode | MIT License |
src/Day11.kt | ajmfulcher | 573,611,837 | false | {"Kotlin": 24722} | import java.math.BigInteger
class Operation(private val op: (BigInteger, BigInteger) -> BigInteger) {
fun apply(operand: BigInteger, i: BigInteger) = op(operand, i)
}
fun operation(sign: String): Operation = when(sign) {
"+" -> Operation { a, b -> a.plus(b) }
"-" -> Operation { a, b -> a.minus(b) }
"/... | 0 | Kotlin | 0 | 0 | 981f6014b09e347241e64ba85e0c2c96de78ef8a | 3,893 | advent-of-code-2022-kotlin | Apache License 2.0 |
day10/src/Day10.kt | rnicoll | 438,043,402 | false | {"Kotlin": 90620, "Rust": 1313} | import java.nio.file.Files
import java.nio.file.Path
import java.util.*
object Day10 {
val PART1_SCORES: Map<Char, Int> = mapOf(
Pair(')', 3),
Pair(']', 57),
Pair('}', 1197),
Pair('>', 25137)
)
val PART2_SCORES: Map<Char, Int> = mapOf(
Pair(')', 1),
Pair(']',... | 0 | Kotlin | 0 | 0 | 8c3aa2a97cb7b71d76542f5aa7f81eedd4015661 | 2,755 | adventofcode2021 | MIT License |
src/Day02.kt | cornz | 572,867,092 | false | {"Kotlin": 35639} | fun main() {
fun toNum(alpha: String): Int {
val ret = when (alpha) {
"A", "X" -> 1
"B", "Y" -> 2
else -> 3
}
return ret
}
fun getDecidedOutcomeChar(alpha: String): String {
val ret = when (alpha) {
"X" -> "loss"
... | 0 | Kotlin | 0 | 0 | 2800416ddccabc45ba8940fbff998ec777168551 | 2,512 | aoc2022 | Apache License 2.0 |
src/Day06.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 288L
private const val EXPECTED_2 = 71503L
private class Day06(isTest: Boolean) : Solver(isTest) {
fun part1(): Any {
val lines = readAsLines()
val times = lines[0].splitInts()
val distance = lines[1].splitInts()
var sum = 1L
for (i in 0 until ... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 1,458 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2023/Day11.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2023
import ru.timakden.aoc.util.Point
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 11: Cosmic Expansion](https://adventofcode.com/2023/day/11).
*/
object Day11 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val ... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 2,175 | advent-of-code | MIT License |
src/main/kotlin/g2601_2700/s2646_minimize_the_total_price_of_the_trips/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2601_2700.s2646_minimize_the_total_price_of_the_trips
// #Hard #Array #Dynamic_Programming #Depth_First_Search #Tree #Graph
// #2023_07_19_Time_264_ms_(100.00%)_Space_39.6_MB_(100.00%)
class Solution {
fun minimumTotalPrice(n: Int, edges: Array<IntArray>, price: IntArray, trips: Array<IntArray>): Int {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,499 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/adventofcode2020/solution/Day4.kt | lhess | 320,667,380 | false | null | package adventofcode2020.solution
import adventofcode2020.Solution
import adventofcode2020.resource.PuzzleInput
import adventofcode2020.resource.asBlocks
import java.io.File
class Day4(puzzleInput: PuzzleInput<String>) : Solution<String, Int>(puzzleInput) {
private val blocks = puzzleInput.asBlocks().map { it.rep... | 0 | null | 0 | 1 | cfc3234f79c27d63315994f8e05990b5ddf6e8d4 | 2,057 | adventofcode2020 | The Unlicense |
src/main/kotlin/de/tek/adventofcode/y2022/day13/DistressSignal.kt | Thumas | 576,671,911 | false | {"Kotlin": 192328} | package de.tek.adventofcode.y2022.day13
import de.tek.adventofcode.y2022.util.readInputLines
import de.tek.adventofcode.y2022.util.splitByBlankLines
import kotlinx.serialization.json.*
sealed class PacketContent : Comparable<PacketContent>
class Integer(val value: Int) : PacketContent() {
override fun compareTo(... | 0 | Kotlin | 0 | 0 | 551069a21a45690c80c8d96bce3bb095b5982bf0 | 4,135 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc/Day04.kt | fluxxion82 | 573,716,300 | false | {"Kotlin": 39632} | package aoc
import java.io.File
fun List<String>.rangeValueStart() = this.first().toInt()
fun List<String>.rangeValueEnd() = this.last().toInt()
fun List<String>.getRange() = (this.rangeValueStart() .. this.rangeValueEnd())
fun main() {
val testInput = File("src/Day04_test.txt").readText()
val input = File("... | 0 | Kotlin | 0 | 0 | 3920d2c3adfa83c1549a9137ffea477a9734a467 | 1,918 | advent-of-code-kotlin-22 | Apache License 2.0 |
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day13/Day13.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,186 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch3/Problem36.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch3
import dev.bogwalk.util.strings.isPalindrome
/**
* Problem 36: Double-Base Palindromes
*
* https://projecteuler.net/problem=36
*
* Goal: Find the sum of all natural numbers (without leading zeroes) less than N that are
* palindromic in both base 10 and base K.
*
* Constraints: 10 <=... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 2,571 | project-euler-kotlin | MIT License |
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day22CrabCombat.kt | Scavi | 68,294,098 | false | {"Java": 1449516, "Kotlin": 59149} | package com.scavi.brainsqueeze.adventofcode
import java.util.*
class Day22CrabCombat {
private enum class Player { Unknown, Player1, Player2 }
fun solveA(input: List<String>): Int {
val playersCards = getCards(input)
val res = play(playersCards.first, playersCards.second, false)
retur... | 0 | Java | 0 | 1 | 79550cb8ce504295f762e9439e806b1acfa057c9 | 3,027 | BrainSqueeze | Apache License 2.0 |
src/Day16.kt | halirutan | 575,809,118 | false | {"Kotlin": 24802} | data class Valve(val neighbors: List<String>, val flow: Int, val pressureRelease: Int = 0)
data class Player(val currentValve: String, val remainingTime: Int)
// We use these for the stack where we store the search progression
data class OnePlayerGame(val g: GameState, val p1: Player)
data class TwoPlayerGame(val g: G... | 0 | Kotlin | 0 | 0 | 09de80723028f5f113e86351a5461c2634173168 | 7,247 | AoC2022 | Apache License 2.0 |
src/Day02.kt | ExpiredMinotaur | 572,572,449 | false | {"Kotlin": 11216} | fun main() {
//1 = Rock 2 = Paper 3 = Scissors
val opponentMap = mapOf("A" to 1, "B" to 2, "C" to 3) //Map opponent to value
val playerMap = mapOf("X" to 1, "Y" to 2, "Z" to 3) //Map player to value
val winMap = mapOf(1 to 3, 2 to 1, 3 to 2) //win conditions
val loseMap = mapOf(3 to 1, 1 to 2, 2 t... | 0 | Kotlin | 0 | 0 | 7ded818577737b0d6aa93cccf28f07bcf60a9e8f | 1,567 | AOC2022 | Apache License 2.0 |
kotlin/521.Longest Uncommon Subsequence I (最长特殊序列 Ⅰ).kt | learningtheory | 141,790,045 | false | {"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944} | /**
<p>
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings.
The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be <b>any</b> subsequence of the other strings.
</p>
<p>
A <b>subsequence<... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 3,134 | leetcode | MIT License |
src/Day03.kt | wujingwe | 574,096,169 | false | null | fun main() {
fun Char.toPriority(): Int = when (this) {
in 'a'..'z' -> this - 'a' + 1
in 'A'..'Z' -> this - 'A' + 27
else -> 0
}
fun part1(inputs: List<String>): Int {
return inputs.map { s ->
val (first, second) = s.chunked(s.length / 2)
(first.toSe... | 0 | Kotlin | 0 | 0 | a5777a67d234e33dde43589602dc248bc6411aee | 963 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/test/kotlin/be/brammeerten/y2022/Day2Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2022
import be.brammeerten.readFile
import be.brammeerten.y2022.Day2Test.Shape.*
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class Day2Test {
private val scores = mapOf(
ROCK to Score(SCISSORS, ROCK, PAPER),
PAPER to Scor... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 2,095 | Advent-of-Code | MIT License |
src/main/kotlin/aoc2022/Day13.kt | w8mr | 572,700,604 | false | {"Kotlin": 140954} | package aoc2022
import aoc.parser.*
import java.lang.IllegalStateException
class Day13 {
sealed class ElementOrList : Comparable<ElementOrList> {
class E(val value: Int) : ElementOrList()
class L(val list: List<ElementOrList>) : ElementOrList()
override fun compareTo(other: ElementOrLis... | 0 | Kotlin | 0 | 0 | e9bd07770ccf8949f718a02db8d09daf5804273d | 2,287 | aoc-kotlin | Apache License 2.0 |
src/Day07.kt | mpythonite | 572,671,910 | false | {"Kotlin": 29542} | fun main() {
data class File(val name: String, val size: Int)
class Directory(val name: String, val dirs: MutableList<Directory> = mutableListOf(), val files: MutableList<File> = mutableListOf(), val parent: Directory? = null) {
fun size(): Int {
var size = this.files.fold(0){ sum, element -... | 0 | Kotlin | 0 | 0 | cac94823f41f3db4b71deb1413239f6c8878c6e4 | 3,522 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2016/Day01.kt | tginsberg | 74,924,040 | false | null | /*
* Copyright (c) 2016 by <NAME>
*/
package com.ginsberg.advent2016
/**
* Advent of Code - Day 1: December 1, 2016
*
* From http://adventofcode.com/2016/day/1
*
*/
class Day01(instructionText: String) {
private val instructions = inputToInstructions(instructionText)
private data class Instruction(v... | 0 | Kotlin | 0 | 3 | a486b60e1c0f76242b95dd37b51dfa1d50e6b321 | 2,754 | advent-2016-kotlin | MIT License |
src/Day02.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | class Solution02(private val input: List<String>) {
private fun scorePart1(shapes: String): Int {
return when(shapes.trim()) {
"A X" -> 3 + 1
"A Y" -> 6 + 2
"A Z" -> 0 + 3
"B X" -> 0 + 1
"B Y" -> 3 + 2
"B Z" -> 6 + 3
"C X" ... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 1,216 | aoc-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.