path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/dev/claudio/adventofcode2022/Day7Part2.kt | ClaudioConsolmagno | 572,915,041 | false | {"Kotlin": 41573} | package dev.claudio.adventofcode2022
fun main() {
Day7().main()
}
private class Day7 {
fun main() {
val input = Support.readFileAsListString("2022/day7-input.txt")
val tree : Directory = buildTree(input)
val sumedVal: Long = calcResult(tree)
println(sumedVal)
}
private... | 0 | Kotlin | 0 | 0 | 43e3f1395073f579137441f41cd5a63316aa0df8 | 2,641 | adventofcode-2022 | Apache License 2.0 |
src/Day05.kt | k3vonk | 573,555,443 | false | {"Kotlin": 17347} | import java.util.LinkedList
fun main() {
fun createStacks(crates: List<String>): List<LinkedList<Char>> {
val stacks: List<LinkedList<Char>> = List(9) { LinkedList<Char>() }
for (crate in crates) {
val arr = crate.toCharArray()
for (i in arr.indices) {
if (a... | 0 | Kotlin | 0 | 1 | 68a42c5b8d67442524b40c0ce2e132898683da61 | 1,803 | AOC-2022-in-Kotlin | Apache License 2.0 |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day20/DonutMaze.kt | jrhenderson1988 | 289,786,400 | false | {"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37} | package com.github.jrhenderson1988.adventofcode2019.day20
import com.github.jrhenderson1988.adventofcode2019.common.Direction
import com.github.jrhenderson1988.adventofcode2019.common.bfs
class DonutMaze(
private val map: Map<Pair<Int, Int>, Cell>,
private val innerPortals: Map<Pair<Int, Int>, Pair<Int, Int>>... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 7,541 | advent-of-code | Apache License 2.0 |
src/Day05.kt | azat-ismagilov | 573,217,326 | false | {"Kotlin": 75114} | fun main() {
class Crates(input: List<String>) {
private val data: MutableList<MutableList<Char>>
init {
val columns = input.last().length / 4 + 1
data = MutableList(columns) { mutableListOf() }
for (line in input.dropLast(1).reversed()) {
var col... | 0 | Kotlin | 0 | 0 | abdd1b8d93b8afb3372cfed23547ec5a8b8298aa | 2,488 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/g1201_1300/s1293_shortest_path_in_a_grid_with_obstacles_elimination/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1201_1300.s1293_shortest_path_in_a_grid_with_obstacles_elimination
// #Hard #Array #Breadth_First_Search #Matrix
// #2023_06_08_Time_189_ms_(100.00%)_Space_36.6_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
class Solution {
fun shortestPath(grid: Array<IntArray>, k: Int): Int {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,075 | LeetCode-in-Kotlin | MIT License |
project/src/problems/Initial.kt | informramiz | 173,284,942 | false | null | package problems
object Initial {
//val minDiff = minAbsoluteDifference(arrayOf(-2, -3, -4, -1).toIntArray())
// val minDiff = minAbsoluteDifference(arrayOf(1,1).toIntArray())
// val minDiff = minAbsoluteDifference(arrayOf(3, 1, 2, 4, 3).toIntArray())
// val minDiff = minAbsoluteDifference(arrayOf(-1000, ... | 0 | Kotlin | 0 | 0 | a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4 | 4,003 | codility-challenges-practice | Apache License 2.0 |
src/Day25.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import java.lang.StringBuilder
import kotlin.math.pow
import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): SNAFU {
return input.sumOf { SNAFU(it).toLong() }.toSNAFU()
}
val decimalSnafuPairs =
mapOf(
1 to "1",
2 to "2",
3 to "1=",
4 to "1... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 2,356 | aoc2022 | Apache License 2.0 |
2021/src/main/kotlin/Day05.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | import kotlin.math.sign
class Day05(private val input: List<String>) {
private fun List<String>.prepareInput(): List<List<Int>> = this.map {
"(\\d+),(\\d+) -> (\\d+),(\\d+)".toRegex().matchEntire(it)!!.destructured.toList().map { it.toInt() }
}
private fun countMatrix(input: List<List<Int>>, matr... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 1,400 | adventofcode-2021-2025 | MIT License |
src/aoc2021/Day08.kt | dayanruben | 433,250,590 | false | {"Kotlin": 79134} | package aoc2021
import readInput
fun main() {
val (year, day) = "2021" to "Day08"
fun part1(input: List<String>) = input.map {
it.split(" | ").last()
}.flatMap {
it.split(" ")
}.count {
it.length in listOf(2, 3, 4, 7)
}
fun part2(input: List<String>) = input.sumOf { l... | 1 | Kotlin | 2 | 30 | df1f04b90e81fbb9078a30f528d52295689f7de7 | 1,415 | aoc-kotlin | Apache License 2.0 |
2023/src/main/kotlin/Day18.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | object Day18 {
private enum class Direction { UP, DOWN, LEFT, RIGHT }
private data class Dig(val direction: Direction, val number: Long)
private sealed class Line {
data class Vertical(val x: Long, val yRange: LongRange) : Line()
data class Horizontal(val y: Long, val xRange: LongRange) : Line()
}
... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 4,677 | advent-of-code | MIT License |
src/Day07.kt | jalex19100 | 574,686,993 | false | {"Kotlin": 19795} | import com.sun.org.apache.xpath.internal.operations.Bool
class Node(name: String, parent: Node?) {
val name = name
val parent = parent
val children: MutableList<Node> = mutableListOf()
var size: Int = 0
fun addChild(child: Node): Boolean {
val existingChild = getChild(child.name) ?: return... | 0 | Kotlin | 0 | 0 | a50639447a2ef3f6fc9548f0d89cc643266c1b74 | 3,888 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/Day07.kt | lifeofchrome | 574,709,665 | false | {"Kotlin": 19233} | package main
import readInput
fun main() {
val input = readInput("Day07")
val day7 = Day07(input)
print("Part 1: ${day7.part1()}\n")
print("Part 2: ${day7.part2()}")
}
class Day07(input: List<String>) {
private val root = Node("/", false, 0, mutableListOf())
private var path = ArrayDeque<Node>... | 0 | Kotlin | 0 | 0 | 6c50ea2ed47ec6e4ff8f6f65690b261a37c00f1e | 2,777 | aoc2022 | Apache License 2.0 |
code/day_05/src/jvm8Main/kotlin/common.kt | dhakehurst | 725,945,024 | false | {"Kotlin": 105846} | package day_05
class Range(
val start: Long,
val length: Long
) : Iterable<Long> {
val max = start + length
var limit = length
override fun iterator(): Iterator<Long> = object : AbstractIterator<Long>() {
var i = 0
override fun computeNext() {
when {
i ... | 0 | Kotlin | 0 | 0 | be416bd89ac375d49649e7fce68c074f8c4e912e | 3,551 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/staricka/adventofcode2022/Day16.kt | mathstar | 569,952,400 | false | {"Kotlin": 77567} | package com.staricka.adventofcode2022
import kotlin.math.max
class Day16 : Day {
override val id = 16
data class Valve(val id: String, val flowRate: Int)
private val regex = Regex("""Valve ([A-Z]+) has flow rate=([0-9]+); tunnels? leads? to valves? ([A-Z]+(, [A-Z]+)*)""")
private fun parseInput(input: Strin... | 0 | Kotlin | 0 | 0 | 2fd07f21348a708109d06ea97ae8104eb8ee6a02 | 7,868 | adventOfCode2022 | MIT License |
src/Day05.kt | zuevmaxim | 572,255,617 | false | {"Kotlin": 17901} | private data class State(val stacks: List<MutableList<String>>)
private data class Command(val count: Int, val from: Int, val to: Int)
private fun parseInput(input: List<String>, commands: MutableList<Command>): State {
val stacksCount = (input[0].length + 1) / 4
val stacks = List(stacksCount) { mutableListOf<... | 0 | Kotlin | 0 | 0 | 34356dd1f6e27cc45c8b4f0d9849f89604af0dfd | 2,325 | AOC2022 | Apache License 2.0 |
src/Day10.kt | AndreiShilov | 572,661,317 | false | {"Kotlin": 25181} | import kotlin.math.abs
fun getCommandValue(command: String) = command.split(" ").last().toInt()
fun main() {
fun part1(input: List<String>): Int {
val computer = Computer()
input.forEach { computer.executeCommand(it) }
return computer.result()
}
fun part2(input: List<String>) {
... | 0 | Kotlin | 0 | 0 | 852b38ab236ddf0b40a531f7e0cdb402450ffb9a | 1,476 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2022/Day19.kt | tginsberg | 568,158,721 | false | {"Kotlin": 113322} | /*
* Copyright (c) 2022 by <NAME>
*/
/**
* Advent of Code 2022, Day 19 - Not Enough Minerals
* Problem Description: http://adventofcode.com/2022/day/19
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day19/
*/
package com.ginsberg.advent2022
import java.util.PriorityQueue
import kotli... | 0 | Kotlin | 2 | 26 | 2cd87bdb95b431e2c358ffaac65b472ab756515e | 5,765 | advent-2022-kotlin | Apache License 2.0 |
src/day4.kts | AfzalivE | 317,962,201 | false | null | println("Start")
val requiredFields = listOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid")
val input = readInput("day4.txt").readText()
val validNum = input.split("\n\n")
.asSequence()
.map { passport ->
val fullString = passport.replace("\n", " ")
return@map if (requiredFields.all {
... | 0 | Kotlin | 0 | 0 | cc5998bfcaadc99e933fb80961be9a20541e105d | 2,049 | AdventOfCode2020 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2023/Day11.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2023
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import com.s13g.aoc.XY
import com.s13g.aoc.resultFrom
import kotlin.math.max
import kotlin.math.min
typealias Universe = List<String>
/**
* --- Day 11: Cosmic Expansion ---
* https://adventofcode.com/2023/day/11
*/
class Day11 : S... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,945 | euler | Apache License 2.0 |
src/Day07.kt | HaydenMeloche | 572,788,925 | false | {"Kotlin": 25699} | fun main() {
val input = readInput("Day07")
.toMutableList()
input.removeAt(0) // hardcoded first node
var currentNode = Node("/", Type.DIR, null, 0, mutableListOf())
val root = currentNode
input.forEach { line ->
when {
line == "$ ls" -> {}
line.startsWith("... | 0 | Kotlin | 0 | 1 | 1a7e13cb525bb19cc9ff4eba40d03669dc301fb9 | 2,057 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/de/jball/aoc2022/day05/Day05.kt | fibsifan | 573,189,295 | false | {"Kotlin": 43681} | package de.jball.aoc2022.day05
import de.jball.aoc2022.Day
import java.util.Stack
class Day05(test: Boolean = false): Day<String>(test, "CMZ", "MCD") {
private val crates1: List<Stack<Char>>
private val crates2: List<Stack<Char>>
init {
val crateNumbers = input[input.indexOf("") - 1]
.... | 0 | Kotlin | 0 | 3 | a6d01b73aca9b54add4546664831baf889e064fb | 1,954 | aoc-2022 | Apache License 2.0 |
year2021/src/main/kotlin/net/olegg/aoc/year2021/day10/Day10.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2021.day10
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2021.DayOf2021
/**
* See [Year 2021, Day 10](https://adventofcode.com/2021/day/10)
*/
object Day10 : DayOf2021(10) {
override fun first(): Any? {
return lines
.sumOf { line ->
val queue = ArrayDequ... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,896 | adventofcode | MIT License |
src/aoc2022/Day08.kt | Playacem | 573,606,418 | false | {"Kotlin": 44779} | package aoc2022
import aoc2022.Day08.calculateScore
import aoc2022.Day08.isNotVisible
import utils.createDebug
import utils.readInput
object Day08 {
data class TreeView(
val value: Int,
val left: List<Int>,
val right: List<Int>,
val top: List<Int>,
val bottom: List<Int>,
... | 0 | Kotlin | 0 | 0 | 4ec3831b3d4f576e905076ff80aca035307ed522 | 4,141 | advent-of-code-2022 | Apache License 2.0 |
y2016/src/main/kotlin/adventofcode/y2016/Day22.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2016
import adventofcode.io.AdventSolution
object Day22 : AdventSolution(2016, 22, "Grid Computing") {
override fun solvePartOne(input: String): String {
val nodes = parseInput(input)
return nodes.sumOf { source ->
nodes.count { target ->
(source.x != target.x || source.y != targe... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,347 | advent-of-code | MIT License |
src/Day09.kt | zfz7 | 573,100,794 | false | {"Kotlin": 53499} | import kotlin.math.abs
fun main() {
println(day9A(readFile("Day09")))
println(day9B(readFile("Day09")))
}
fun isTouching(head: Pair<Int, Int>, tail: Pair<Int, Int>): Boolean =
abs(head.first - tail.first) <= 1 && abs(head.second - tail.second) <= 1
fun moveHead(head: Pair<Int, Int>, mv: String): Pair<Int... | 0 | Kotlin | 0 | 0 | c50a12b52127eba3f5706de775a350b1568127ae | 2,743 | AdventOfCode22 | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[1128]等价多米诺骨牌对的数量.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给你一个由一些多米诺骨牌组成的列表 dominoes。
//
// 如果其中某一张多米诺骨牌可以通过旋转 0 度或 180 度得到另一张多米诺骨牌,我们就认为这两张牌是等价的。
//
// 形式上,dominoes[i] = [a, b] 和 dominoes[j] = [c, d] 等价的前提是 a==c 且 b==d,或是 a==d 且
//b==c。
//
// 在 0 <= i < j < dominoes.length 的前提下,找出满足 dominoes[i] 和 dominoes[j] 等价的骨牌对 (i,
// j) 的数量。
//
//
//
// 示例:
//
// 输入:dominoes = ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,295 | MyLeetCode | Apache License 2.0 |
y2017/src/main/kotlin/adventofcode/y2017/Day14.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2017
import adventofcode.io.AdventSolution
fun main() =Day14.solve()
object Day14 : AdventSolution(2017, 14, "Disk Defragmentation") {
override fun solvePartOne(input: String): String = (0..127).asSequence()
.map { "$input-$it" }
.flatMap { knotHash(it).asSequence() }
.flatMap { it.t... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,164 | advent-of-code | MIT License |
src/main/kotlin/days/Day2.kt | MisterJack49 | 574,081,723 | false | {"Kotlin": 35586} | package days
private enum class Shape(val score: Int) {
Rock(1), Paper(2), Scissors(3)
}
private enum class Outcome(val score: Int) {
Lose(0), Draw(3), Win(6)
}
class Day2 : Day(2) {
override fun partOne(): Any {
return inputList.map { entry -> entry.first().toShape() to entry.last().toShape() }... | 0 | Kotlin | 0 | 0 | e82699a06156e560bded5465dc39596de67ea007 | 1,977 | AoC-2022 | Creative Commons Zero v1.0 Universal |
src/Day04.kt | CrazyBene | 573,111,401 | false | {"Kotlin": 50149} | fun main() {
data class SectionAssignment(val start: Int, val end: Int)
fun String.toSectionAssignment(): SectionAssignment {
return split("-")
.map { it.toInt() }
.zipWithNext()
.map { SectionAssignment(it.first, it.second) }
.also { if(it.size != 1) err... | 0 | Kotlin | 0 | 0 | dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26 | 1,671 | AdventOfCode2022 | Apache License 2.0 |
calendar/day08/Day8.kt | starkwan | 573,066,100 | false | {"Kotlin": 43097} | package day08
import Day
import Lines
class Day8 : Day() {
override fun part1(input: Lines): Any {
val rows: List<List<Int>> = input.map { it.toList().map { it.toString().toInt() } }
val columns: List<List<Int>> = buildList {
for (i in 0 until rows[0].size) {
add(build... | 0 | Kotlin | 0 | 0 | 13fb66c6b98d452e0ebfc5440b0cd283f8b7c352 | 2,422 | advent-of-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/day22/Day22.kt | daniilsjb | 434,765,082 | false | {"Kotlin": 77544} | package day22
import java.io.File
import kotlin.math.max
import kotlin.math.min
fun main() {
val data = parse("src/main/kotlin/day22/Day22.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 22 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
pr... | 0 | Kotlin | 0 | 1 | bcdd709899fd04ec09f5c96c4b9b197364758aea | 2,897 | advent-of-code-2021 | MIT License |
src/day08/Day08.kt | barbulescu | 572,834,428 | false | {"Kotlin": 17042} | package day08
import readInput
fun main() {
val lines: List<List<Int>> = readInput("day08/Day08")
.map { line -> line.toCharArray().map { it.toString().toInt() } }
.toList()
val grid = Grid(lines)
.markEdgeVisible()
.markFromLeft()
.markFromRight()
.markFromTo... | 0 | Kotlin | 0 | 0 | 89bccafb91b4494bfe4d6563f190d1b789cde7a4 | 3,885 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2020/d22/Day22.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2020.d22
import com.groundsfam.advent.DATAPATH
import kotlin.io.path.div
import kotlin.io.path.useLines
fun scoreDeck(deck: List<Int>): Int = deck.reversed()
.mapIndexed { i, card ->
card * (i + 1)
}.sum()
fun simulateCombat(deck1: List<Int>, deck2: List<Int>): Int {
... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,414 | advent-of-code | MIT License |
src/Day03.kt | k3vonk | 573,555,443 | false | {"Kotlin": 17347} | fun main() {
fun convertToPriority(item: Char): Int {
return if (item.isUpperCase()) {
item.code - 'A'.code + 27
} else {
item.code - 'a'.code + 1
}
}
fun part1(rucksacks: List<String>): Int {
var priority = 0
rucksacks.forEach { rucksack ->
... | 0 | Kotlin | 0 | 1 | 68a42c5b8d67442524b40c0ce2e132898683da61 | 1,341 | AOC-2022-in-Kotlin | Apache License 2.0 |
src/Day02.kt | pedroldk | 573,424,273 | false | {"Kotlin": 4625} | fun main() {
fun processRound1(theirPlay: Char, myPlay: Char): Int {
return when (theirPlay) {
'A' -> when(myPlay) {
'X' -> 1 + 3
'Y' -> 2 + 6
'Z' -> 3 + 0
else -> -1
}
'B' -> when(myPlay) {
... | 0 | Kotlin | 0 | 0 | 68348bbfc308d257b2d02fa87dd241f8f584b444 | 1,808 | aoc-2022-in-kotlin | Apache License 2.0 |
kotlin/src/main/kotlin/io/github/piszmog/aoc/Day3.kt | Piszmog | 433,651,411 | false | null | package io.github.piszmog.aoc
import java.time.Instant
import kotlin.math.pow
fun main(args: Array<String>) {
val start = Instant.now()
val parser = getCSVParser(args[0])
val report = parser.map { it -> it[0].toCharArray().map { it == '1' } }.toList()
val part1Solution = day3Part1(report)
println... | 0 | Rust | 0 | 0 | a155cb7644017863c703e97f22c8338ccb5ef544 | 2,255 | aoc-2021 | MIT License |
src/year2023/21/Day21.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2023.`21`
import readInput
import kotlin.math.pow
import kotlin.math.roundToLong
private const val CURRENT_DAY = "21"
private data class Point(
val x: Int,
val y: Int,
) {
override fun toString(): String {
return "[$x,$y]"
}
}
private fun Point.neighbours(): Set<Point> {
retu... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 7,226 | KotlinAdventOfCode | Apache License 2.0 |
codeforces/vk2021/round1/d.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.vk2021.round1
import kotlin.random.Random
import kotlin.system.exitProcess
private fun solveSmart(a: List<Int>): List<Int> {
val used = BooleanArray(a.size)
val ans = IntArray(a.size) { -1 }
for (i in a.indices) {
if (a[i] == i) continue
if (used[a[i]]) continue
used[a[i]] = true
ans[i] ... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,145 | competitions | The Unlicense |
src/Day03.kt | allwise | 574,465,192 | false | null | import java.io.File
fun main() {
fun part1(input: List<String>): Int {
val rucksacks = Rocksacks(input)
return rucksacks.process()
}
fun part2(input: List<String>): Int {
val rucksacks = Rocksacks(input)
return rucksacks.processGroups()
}
// test if implementation mee... | 0 | Kotlin | 0 | 0 | 400fe1b693bc186d6f510236f121167f7cc1ab76 | 1,998 | advent-of-code-2022 | Apache License 2.0 |
src/Day21.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | const val ROOT_MONKEY = "root"
const val HUMN_MONKEY = "humn"
data class Equation(val n1: String, val operation: Char, val n2: String)
fun main() {
fun getMonkeys(input: List<List<String>>): Pair<MutableMap<String, Long>, MutableMap<String, Equation>> {
val numberMonkeys = mutableMapOf<String, Long>()
... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 3,934 | AoC2022 | Apache License 2.0 |
src/main/kotlin/day13.kt | gautemo | 572,204,209 | false | {"Kotlin": 78294} | import shared.chunks
import shared.getText
fun main() {
val input = getText("day13.txt")
println(day13A(input))
println(day13B(input))
}
fun day13A(input: String): Int {
var sum = 0
input.chunks().forEachIndexed { index, s ->
val left = Packet(s.lines().first())
val right = Packet(... | 0 | Kotlin | 0 | 0 | bce9feec3923a1bac1843a6e34598c7b81679726 | 2,610 | AdventOfCode2022 | MIT License |
src/main/kotlin/cc/stevenyin/leetcode/_0026_RemoveDuplicatesfromSortedArray.kt | StevenYinKop | 269,945,740 | false | {"Kotlin": 107894, "Java": 9565} | package cc.stevenyin.leetcode
/**
* https://leetcode.com/problems/remove-duplicates-from-sorted-array/
* Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once.
* The relative order of the elements should be kept the same.
* Si... | 0 | Kotlin | 0 | 1 | 748812d291e5c2df64c8620c96189403b19e12dd | 2,647 | kotlin-demo-code | MIT License |
src/Day11.kt | SebastianHelzer | 573,026,636 | false | {"Kotlin": 27111} |
data class Monkey(
val items: MutableList<Long>,
val operation: (Long) -> Long,
val test: (Long) -> Boolean,
val testDivisor: Int,
val onTrueMonkeyIndex: Int,
val onFalseMonkeyIndex: Int,
)
object OperationFunctionParser {
fun parse(operation: String): Function1<Long, Long> {
val (... | 0 | Kotlin | 0 | 0 | e48757626eb2fb5286fa1c59960acd4582432700 | 4,388 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/24/Day24.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`24`
import java.util.PriorityQueue
import readInput
import utils.doWithPrintedTime
data class Point(
val x: Int,
val y: Int
)
enum class Direction { LEFT, RIGHT, BOTTOM, TOP }
/**
* Sealed class representing either Blizzard or Wall
*/
sealed class Structure {
abstract val position: P... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 10,228 | KotlinAdventOfCode | Apache License 2.0 |
src/main/kotlin/de/takeweiland/aoc2019/day3/Day3.kt | diesieben07 | 226,095,130 | false | null | package de.takeweiland.aoc2019.day3
import de.takeweiland.aoc2019.inputReader
import java.io.FileWriter
import java.util.*
import kotlin.Comparator
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.abs
private data class Position(val x: Int, val y: Int) {
companion object {... | 0 | Kotlin | 0 | 0 | 2b778201213941de7f37dbc18864a04ce3601f32 | 3,867 | advent-of-code-2019 | MIT License |
src/Day05.kt | 3n3a-archive | 573,389,832 | false | {"Kotlin": 41221, "Shell": 534} |
data class Instruction(val amount: Int, val from: Int, val to: Int)
data class Day05PreprocessResult(val containers: MutableList<MutableList<String>>, val instructions: List<Instruction>)
fun Day05() {
fun preprocess(input: String): Day05PreprocessResult {
val containersRegex = "\\[(.)\\]".toRegex()
... | 0 | Kotlin | 0 | 0 | fd25137d2d2df0aa629e56981f18de52b25a2d28 | 4,246 | aoc_kt | Apache License 2.0 |
src/Day13.kt | TheGreatJakester | 573,222,328 | false | {"Kotlin": 47612} | package day13
import utils.forForEach
import utils.readInputAsText
import utils.runSolver
import utils.string.asLines
import utils.string.asParts
private typealias SolutionType = Int
private const val defaultSolution = 0
private const val dayNumber: String = "13"
private val testSolution1: SolutionType? = 13
privat... | 0 | Kotlin | 0 | 0 | c76c213006eb8dfb44b26822a44324b66600f933 | 3,883 | 2022-AOC-Kotlin | Apache License 2.0 |
src/Day03.kt | pedroldk | 573,424,273 | false | {"Kotlin": 4625} | fun main() {
fun findCommonItem(rucksack: String): Char {
val compartments = rucksack.substring(0 until (rucksack.length / 2)) to rucksack.substring(rucksack.length / 2)
return compartments.first.toCharArray().first { compartments.second.contains(it) }
}
fun findBadgeItem(rucksack: List<Str... | 0 | Kotlin | 0 | 0 | 68348bbfc308d257b2d02fa87dd241f8f584b444 | 1,079 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | RandomUserIK | 572,624,698 | false | {"Kotlin": 21278} | data class Directory(
val name: String,
val children: MutableMap<String, Directory> = hashMapOf(),
var filesSize: Int = 0,
) {
val dirSize: Int
get() = filesSize + children.values.sumOf { it.dirSize }
}
fun List<String>.toFileSystem(): Directory {
val callStack = ArrayDeque<Directory>().also { it.add(Directory(... | 0 | Kotlin | 0 | 0 | f22f10da922832d78dd444b5c9cc08fadc566b4b | 1,704 | advent-of-code-2022 | Apache License 2.0 |
src/main/day10/day10.kt | rolf-rosenbaum | 572,864,107 | false | {"Kotlin": 80772} | package day10
import readInput
fun main() {
val input = readInput("main/day10/Day10")
println(part1(input))
part2(input)
}
fun part1(input: List<String>): Int {
val cycles = input.toCycles()
val interestingCycles = listOf(20, 60, 100, 140, 180, 220)
return interestingCycles.sumOf { cycles[i... | 0 | Kotlin | 0 | 2 | 59cd4265646e1a011d2a1b744c7b8b2afe482265 | 984 | aoc-2022 | Apache License 2.0 |
advent-of-code-2022/src/Day06.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
val testInput = readInput("Day06_test")
val input = readInput("Day06")
check(part1(testInput) == 7)
println("Part 1: " + part1(input))
check(part2(testInput) == 19)
println("Part 2: " + part2(input))
}
private fun part1(input: String): Int = findStartMessageMarker(input, windowSi... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 1,432 | advent-of-code | Apache License 2.0 |
src/main/kotlin/days/Solution18.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
import adventOfCode.util.Point2D
import adventOfCode.util.plus
import adventOfCode.util.times
import kotlin.math.abs
typealias LagoonInstruction = PairOf<Pair<Point2D, Int>>
object Solution18 : Solution<List<La... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 1,796 | Advent-of-Code-2023 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximalPathQuality.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 | 2,384 | kotlab | Apache License 2.0 |
2022/Day09/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
data class Point(val x: Int, val y: Int) {}
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
println(problem1(lines))
println(problem2(lines))
}
fun problem1(moves: List<String>): Int {
return solve(Array(2) { Point(0, 0) }, moves)
}
fun problem2(moves: List<... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 2,799 | AdventOfCode | MIT License |
src/Day02.kt | ben-dent | 572,931,260 | false | {"Kotlin": 10265} | fun main() {
fun getPairs(input: List<String>): List<List<String>> {
return input.map { it.split(" ") }
}
fun winScore(input: List<String>): Long {
val opponentMove = input[0]
val myMove = input[1]
val wins = HashMap<Pair<String, String>, Long>()
wins[Pair("A", "X")... | 0 | Kotlin | 0 | 0 | 2c3589047945f578b57ceab9b975aef8ddde4878 | 2,148 | AdventOfCode2022Kotlin | Apache License 2.0 |
src/codility/NailingFlanks.kt | faniabdullah | 382,893,751 | false | null | package codility
import java.util.*
class NailingFlanks {
fun solution(A: IntArray, B: IntArray, C: IntArray): Int {
// the main algorithm is that getting the minimal index of nails which
// is needed to nail every plank by using the binary search
val N = A.size
val M = C.size
... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,333 | dsa-kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxSumAfterPartitioning.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,503 | kotlab | Apache License 2.0 |
src/Day10.kt | robotfooder | 573,164,789 | false | {"Kotlin": 25811} | fun main() {
fun part1(input: List<String>): Int {
val signalStrengths = listOf(20, 60, 100, 140, 180, 220)
return input
.flatMap { it.toNumberList() }
.runningFold(1) { acc, num -> acc + num }
.filterIndexed { index, _ -> signalStrengths.contains(index + 1) ... | 0 | Kotlin | 0 | 0 | 9876a52ef9288353d64685f294a899a58b2de9b5 | 1,418 | aoc2022 | Apache License 2.0 |
FindInMountainArray.kt | prashantsinghpaliwal | 537,191,958 | false | {"Kotlin": 9473} | // Question link - https://leetcode.com/problems/find-in-mountain-array/
// Steps required :-
// 1.) Find peak element and divide array in one ascending and one descending order arrays.
// 2.) Apply binary search in asc part.
// 3.) If not found, then apply binary search in desc part.
fun main() {
val arr = arra... | 0 | Kotlin | 0 | 0 | e66599817508beb4e90de43305939d200a9e3964 | 2,482 | DsAlgo | Apache License 2.0 |
src/Day06.kt | hoppjan | 433,705,171 | false | {"Kotlin": 29015, "Shell": 338} | fun main() {
fun part1(input: IntArray) = countSimulatedFishPopulation(fish = input, days = 80)
fun part2(input: IntArray) = countSimulatedFishPopulation(fish = input, days = 256)
// test if implementation meets criteria from the description
val testInput = IntInputReader2.read("Day06_test")
// ... | 0 | Kotlin | 0 | 0 | 04f10e8add373884083af2a6de91e9776f9f17b8 | 1,697 | advent-of-code-2021 | Apache License 2.0 |
src/Utils.kt | rhavran | 250,959,542 | false | null | import kotlin.math.sqrt
/**
* https://www.youtube.com/watch?v=V08g_lkKj6Q
*/
class EratosthenesSieve(n: Int) {
val numbers: List<Boolean>
init {
val numbersArray = BooleanArray(n + 1)
numbersArray.fill(true)
var potentialPrime = 2
while (potentialPrime * potentialPrime <= n)... | 0 | Kotlin | 0 | 0 | 11156745ef0512ab8aee625ac98cb6b7d74c7e92 | 2,420 | ProjectEuler | MIT License |
src/Day04.kt | dcbertelsen | 573,210,061 | false | {"Kotlin": 29052} | import java.io.File
fun main() {
fun stringToPair(data: String) : IntRange {
val nums = data.split("-")
return IntRange(nums[0].toInt(), nums[1].toInt())
}
fun processInput(pair: String): Pair<IntRange, IntRange> {
val areas = pair.split(",")
.map { stringToPair(it) }
... | 0 | Kotlin | 0 | 0 | 9d22341bd031ffbfb82e7349c5684bc461b3c5f7 | 1,273 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions62.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
fun test62() {
val trieTree = TrieTree()
val boy = "boy"
trieTree.insert(boy)
val boss = "boss"
val cowboy = "cowboy"
trieTree.insert(boss)
trieTree.insert(cowboy)
println("Is this trie tree contain $boy: ${trieTree.search(boy)}")
println("Is ... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 3,732 | Algorithm | Apache License 2.0 |
src/main/kotlin/de/dikodam/calendar/Day10.kt | dikodam | 433,719,746 | false | {"Kotlin": 51383} | package de.dikodam.calendar
import de.dikodam.AbstractDay
import de.dikodam.executeTasks
import java.util.*
import kotlin.time.ExperimentalTime
@ExperimentalTime
fun main() {
Day10().executeTasks()
}
class Day10 : AbstractDay() {
val input = readInputLines()
// val input = """[({(<(())[]>[[{[]{<()<>>
//[... | 0 | Kotlin | 0 | 1 | 4934242280cebe5f56ca8d7dcf46a43f5f75a2a2 | 2,809 | aoc-2021 | MIT License |
src/Day01.kt | SebastianAigner | 573,086,864 | false | {"Kotlin": 2101} | import java.io.File
import java.util.PriorityQueue
fun main() {
fun parseInput(input: String) = input.split("\n\n").map { elf ->
elf.lines().map { it.toInt() }
}
// O(size * log size) -> O(size * log n) -> O(size)
fun List<List<Int>>.topNElves(n: Int): Int {
fun findTopN(n: Int, elemen... | 0 | Kotlin | 0 | 1 | 2b5033019a6710d41adf6e6960eac7c1b59679d7 | 1,457 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/day19_beacon_scanner/BeaconScanner.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day19_beacon_scanner
import geom.Vec
import histogram.count
import histogram.mutableHistogramOf
import java.util.*
/**
* Another graph walk, reminiscent of Jurassic Jigsaw (2020 day 20), but this
* time in three dimensions! Based on the example, assume scanner zero's coord
* system is The One True System, ... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 3,988 | aoc-2021 | MIT License |
Day 5/Part 1/src/Task.kt | marc-bouvier-katas | 434,007,210 | false | {"Kotlin": 46389} | fun overlaps(ventsLines: Array<String>): Int {
val lines = Lines()
return if (ventsLines.size >= 2) {
repeat(ventsLines.size){
lines.mergeWith(Line.fromLineOfVent(LineOfVent.fromString(ventsLines[it])))
}
return lines.overlaps()
} else 0
}
data class Lines(private val dat... | 0 | Kotlin | 0 | 1 | 12cf74ca5ac5985b00da89ffd43b750e105e0cec | 2,177 | Kotlin_EduTools_Advent_of_Code_2021 | MIT License |
src/Day13.kt | kipwoker | 572,884,607 | false | null | import java.util.Comparator
fun main() {
class TreeNode(
val value: Int?,
val parent: TreeNode?,
val str: String?,
var children: MutableList<TreeNode> = mutableListOf()
)
class TreeNodeComparator(val f: (o1: TreeNode?, o2: TreeNode?) -> Int) : Comparator<TreeNode> {
... | 0 | Kotlin | 0 | 0 | d8aeea88d1ab3dc4a07b2ff5b071df0715202af2 | 4,679 | aoc2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/BestTeamScore.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 | 1,707 | kotlab | Apache License 2.0 |
src/2021/Day9_2.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
class DepthMap(val input: List<String>) {
fun findBasins(): Collection<List<Pair<Int, Int>>> {
val coordsWithBasinLabels = mutableMapOf<Pair<Int, Int>, Int>()
var label = 0
val coords = input.indices.product(input[0].indices)
val depths = coords.associateWith { (... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 1,530 | adventofcode | MIT License |
src/Day14.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | import java.util.regex.Pattern
fun main() {
// 498,4 -> 498,6 -> 496,6
// 503,4 -> 502,4 -> 502,9 -> 494,9
data class Point(val x: Int, val y: Int)
fun sign(a: Int): Int =
if (a > 0) {
1
} else if (a < 0) {
-1
} else {
0
}
fun ... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 3,514 | aoc-2022-in-kotlin | Apache License 2.0 |
codeforces/round572/a2.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.round572
private fun solve() {
val n = readInt()
val nei = List(n) { mutableListOf<Edge>() }
repeat(n - 1) {
val (aInput, bInput, value) = readInts()
val a = aInput - 1
val b = bInput - 1
nei[a].add(Edge(a, b, value))
nei[b].add(Edge(b, a, value))
}
if (nei.any { it.size == 2 }) {
p... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,788 | competitions | The Unlicense |
kotlin/src/com/daily/algothrim/leetcode/medium/SearchRange.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.medium
/**
* 34. 在排序数组中查找元素的第一个和最后一个位置
*
* 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。
* 如果数组中不存在目标值 target,返回 [-1, -1]。
*
* 进阶:
*
* 你可以设计并实现时间复杂度为 O(log n) 的算法解决此问题吗?
*/
class SearchRange {
companion object {
@JvmStatic
fun main(args: Ar... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 2,069 | daily_algorithm | Apache License 2.0 |
src/2021-Day06.kt | frozbiz | 573,457,870 | false | {"Kotlin": 124645} | fun main() {
fun part1(input: List<String>): Int {
val counts = ArrayDeque(List(9) { 0 })
input[0].trim().split(',').map { it.toInt() }.forEach { ++counts[it] }
var days = 80
while (days > 0) {
val newFish = counts.removeFirst()
counts.add(newFish)
... | 0 | Kotlin | 0 | 0 | 4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388 | 1,146 | 2022-aoc-kotlin | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-13.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2016
import com.github.ferinagy.adventOfCode.Coord2D
import com.github.ferinagy.adventOfCode.searchGraph
import com.github.ferinagy.adventOfCode.singleStep
fun main() {
println("Part1:")
println(part1(testInput1, Coord2D(7, 4)))
println(part1(input, Coord2D(31, ... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,562 | advent-of-code | MIT License |
src/Day13.kt | maewCP | 579,203,172 | false | {"Kotlin": 59412} | fun main() {
fun parse(str: String): List<String> {
var output = str
var openBracketCount = 0
(str.indices).forEach { i ->
if (str[i] == '[') openBracketCount++
if (str[i] == ']') openBracketCount--
if (str[i] == ',' && openBracketCount == 0) output = outp... | 0 | Kotlin | 0 | 0 | 8924a6d913e2c15876c52acd2e1dc986cd162693 | 3,718 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDifference.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 | 1,904 | kotlab | Apache License 2.0 |
src/Day05.kt | JohannesPtaszyk | 573,129,811 | false | {"Kotlin": 20483} | import kotlin.math.min
fun main() {
data class MoveInstruction(val amount: Int, val fromIndex: Int, val toIndex: Int)
fun getStacks(stackInput: List<String>): MutableList<MutableList<String>> =
stackInput.fold(mutableListOf()) { stacks: MutableList<MutableList<String>>, line: String ->
li... | 0 | Kotlin | 0 | 1 | 6f6209cacaf93230bfb55df5d91cf92305e8cd26 | 2,981 | advent-of-code-2022 | Apache License 2.0 |
src/day25/solution.kt | bohdandan | 729,357,703 | false | {"Kotlin": 80367} | package day25
import println
import readInput
class Snowverload(input: List<String>) {
private val graph = buildMap {
input.forEach {row ->
val (key, values) = row.split(':')
put(key.trim(), values.split(' ').map(String::trim).filter { it.isNotEmpty() })
}
}
private... | 0 | Kotlin | 0 | 0 | 92735c19035b87af79aba57ce5fae5d96dde3788 | 2,384 | advent-of-code-2023 | Apache License 2.0 |
src/day13/Day13.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day13
import Runner
fun main() {
Day13Runner().solve()
}
class Day13Runner : Runner<Int>(
day = 13,
expectedPartOneTestAnswer = 13,
expectedPartTwoTestAnswer = 140
) {
override fun partOne(input: List<String>, test: Boolean): Int {
return packetPairs(input)
.map { (le... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 4,502 | advent-of-code | Apache License 2.0 |
src/main/kotlin/endredeak/aoc2022/Day21.kt | edeak | 571,891,076 | false | {"Kotlin": 44975} | package endredeak.aoc2022
private abstract class Expression(open val id: String) {
abstract fun eval(map: Map<String, Expression>): Long
fun print(map: Map<String, Expression>): String =
when(this) {
is Literal -> if (this.id == "humn") "x" else "${this.eval(emptyMap())}"
is Co... | 0 | Kotlin | 0 | 0 | e0b95e35c98b15d2b479b28f8548d8c8ac457e3a | 1,986 | AdventOfCode2022 | Do What The F*ck You Want To Public License |
src/main/kotlin/aoc23/Day08.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc23
import aoc23.Day08Domain.Network
import aoc23.Day08Parser.toNetwork
import aoc23.Day08Solution.part1Day08
import aoc23.Day08Solution.part2Day08
import common.Math.toLowestCommonMultiple
import common.Space3D.Parser.valuesFor
import common.Year23
object Day08 : Year23 {
fun List<String>.part1(): Long... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 2,486 | aoc | Apache License 2.0 |
2023/src/main/kotlin/day14.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Grid
import utils.MutableGrid
import utils.Parser
import utils.Solution
import utils.debugString
import utils.rotateCw
import utils.toMutable
fun main() {
Day14.run()
}
object Day14 : Solution<Grid<Char>>() {
override val name = "day14"
override val parser = Parser.charGrid
override fun part1():... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,666 | aoc_kotlin | MIT License |
src/UsefulStuff.kt | JaydenPease | 574,590,496 | false | {"Kotlin": 11645} | fun main() {
val input = readInput("numbers")
println("Sum: ${sumAllNums(input)}")
println("Min: ${findMin(input)}")
val wordInput = readInput("sentences")
println(countWords(wordInput))
println(countHWords(wordInput))
val hiWordInput = wordInput.map{
"hi $it"
}
}
fun sumAllN... | 0 | Kotlin | 0 | 0 | 0a5fa22b3653c4b44a716927e2293fc4b2ed9eb7 | 1,579 | AdventOfCode-2022 | Apache License 2.0 |
src/UsefulExample.kt | LucasDuBria | 574,598,208 | false | {"Kotlin": 2250} | fun main(){
val input = readInput("numbers")
println("Sum: ${sumAllNum(input)}")
println("Min: ${findMin(input)}")
println("Add2Smallest: ${addTwoSmallest(input)}")
val wordInput = readInput("sentences")
println("totalWords: ${countWords(wordInput)}")
println("totalHWords: ${countHWo... | 0 | Kotlin | 0 | 0 | d6d886fe589fb39f2b592851ae4c0a8fab728411 | 1,201 | LoginAndRegistration | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2022/Day08.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2022
import ru.timakden.aoc.util.Point
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 8: Treetop Tree House](https://adventofcode.com/2022/day/8).
*/
object Day08 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val ... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 4,996 | advent-of-code | MIT License |
year2018/src/main/kotlin/net/olegg/aoc/year2018/day7/Day7.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2018.day7
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2018.DayOf2018
import kotlin.math.max
/**
* See [Year 2018, Day 7](https://adventofcode.com/2018/day/7)
*/
object Day7 : DayOf2018(7) {
private val PATTERN = "Step (\\w) must be finished before step (\\w) can begin\\... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,488 | adventofcode | MIT License |
src/main/kotlin/day02/Day02.kt | qnox | 575,581,183 | false | {"Kotlin": 66677} | package day02
import readInput
fun main() {
fun part1(input: List<String>): Int {
return input.fold(0) { acc, line ->
val p1 = line[0] - 'A' + 1
val p2 = line[2] - 'X' + 1
acc + p2 + if (p1 == p2) {
3
} else if (p2 - p1 == 1 || (p1 == 3 && p2... | 0 | Kotlin | 0 | 0 | 727ca335d32000c3de2b750d23248a1364ba03e4 | 1,208 | aoc2022 | Apache License 2.0 |
src/day05/Day05.kt | tschens95 | 573,743,557 | false | {"Kotlin": 32775} | package day05
import readText
fun main() {
val crateMap = mutableMapOf<Int, MutableList<String>>()
fun initMap(length: Int) {
for(i in 0 until length) {
crateMap[i] = mutableListOf()
}
}
fun moveCrate(command: Command, reversePart2: Boolean) {
val cratesFrom = cr... | 0 | Kotlin | 0 | 2 | 9d78a9bcd69abc9f025a6a0bde923f53c2d8b301 | 2,961 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/dp/LBS.kt | yx-z | 106,589,674 | false | null | package dp
// longest bitonic subsequence
// X[1..n] is bitonic if there exists i: 1 < i < n, X[1..i] is inscreasing and X[i..n] is decreasing
// find the length of lbs of A[1..n]
fun main(args: Array<String>) {
val a = intArrayOf(1, 11, 2, 10, 4, 5, 2, 1)
println(a.lbs())
}
fun IntArray.lbs(): Int {
val A = thi... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,505 | AlgoKt | MIT License |
src/day04/src/main/kotlin/eu/gillespie/aoc2021/day04/Model.kt | TimothyGillespie | 433,972,043 | false | {"TypeScript": 8572, "Kotlin": 6335, "Dart": 4911, "JavaScript": 3018, "Shell": 1078} | package eu.gillespie.aoc2021.day04
import kotlin.math.roundToInt
import kotlin.math.sqrt
data class Game(
val boards: List<Board>,
) {
/**
* Marks a number in the board and returns a list of all boards
* which have now been won.
*/
fun drawNumber(number: Int): List<Int> {
val nowW... | 0 | TypeScript | 0 | 1 | 0357d97854699703e2628e315cec1b4c7f68a5e0 | 2,755 | AdventOfCode2021 | The Unlicense |
src/main/kotlin/cc/suffro/bpmanalyzer/Helpers.kt | xsoophx | 579,535,622 | false | {"Kotlin": 71055} | package cc.suffro.bpmanalyzer
import cc.suffro.bpmanalyzer.fft.data.FrequencyDomainWindow
import org.kotlinmath.Complex
import org.kotlinmath.sqrt
fun abs(n: Complex): Double = sqrt(n.re * n.re + n.im * n.im).re
fun getHighestPowerOfTwo(number: Int): Int {
var result = number
generateSequence(1) { (it * 2) }... | 0 | Kotlin | 0 | 0 | 85fbb14a2762b5051753de02fa3b796eeff7608c | 1,426 | BPM-Analyzer | MIT License |
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day08/Day08.kt | nerok | 572,862,875 | false | {"Kotlin": 113337} | package nerok.aoc.aoc2022.day08
import nerok.aoc.utils.Direction
import nerok.aoc.utils.Input
import nerok.aoc.utils.Point
import kotlin.time.DurationUnit
import kotlin.time.measureTime
fun main() {
fun part1(input: List<String>): Long {
val grid = Grid()
input
.filter { it.isNotEmpty... | 0 | Kotlin | 0 | 0 | 7553c28ac9053a70706c6af98b954fbdda6fb5d2 | 6,703 | AOC | Apache License 2.0 |
src/Day20.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | import kotlin.math.absoluteValue
fun main() {
data class Node(var number: Long) {
lateinit var prev: Node
lateinit var next: Node
fun remove() {
this.prev.next = this.next
this.next.prev = this.prev
}
fun insertAfter(a: Node) {
val b = a... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 2,765 | AdventOfCode2022 | Apache License 2.0 |
dcp_kotlin/src/main/kotlin/dcp/day226/day226.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day226
// day226.kt
// By <NAME>, 2019.
import java.util.LinkedList
/**
* Given a list of "words" sorted alphabetically (according to an arbitrary alphabet that does not necessarily
* correspond to a normal alphabet), find the underlying order of the alphabet.
*
* We want to find the rules governing t... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,890 | daily-coding-problem | MIT License |
src/main/kotlin/com/anahoret/aoc2022/day18/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day18
import java.io.File
import kotlin.system.measureTimeMillis
data class Point(val x: Long, val y: Long, val z: Long) {
fun neighbours(): List<Point> {
return listOf(
copy(x = x - 1),
copy(x = x + 1),
copy(y = y - 1),
copy(y ... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 3,309 | advent-of-code-2022 | Apache License 2.0 |
2021/src/main/kotlin/com/trikzon/aoc2021/Day8.kt | Trikzon | 317,622,840 | false | {"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397} | package com.trikzon.aoc2021
fun main() {
val input = getInputStringFromFile("/day8.txt")
benchmark(Part.One, ::day8Part1, input, 512, 50000)
benchmark(Part.Two, ::day8Part2, input, 1091165, 5000)
}
fun day8Part1(input: String): Int {
var instances = 0
input.lines().forEach { line ->
val ou... | 0 | Kotlin | 1 | 0 | d4dea9f0c1b56dc698b716bb03fc2ad62619ca08 | 3,536 | advent-of-code | MIT License |
src/main/kotlin/com/github/dangerground/aoc2020/Day21.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
fun main() {
val process = Day21(DayInput.asStringList(21))
println("result part 1: ${process.part1()}")
println("result part 2: ${process.part2()}")
}
class Day21(val input: List<String>) {
val ingredients... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 3,207 | adventofcode-2020 | MIT License |
src/main/kotlin/g0601_0700/s0630_course_schedule_iii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0601_0700.s0630_course_schedule_iii
// #Hard #Array #Greedy #Heap_Priority_Queue #2023_02_09_Time_536_ms_(100.00%)_Space_58_MB_(100.00%)
import java.util.PriorityQueue
class Solution {
fun scheduleCourse(courses: Array<IntArray>): Int {
// Sort the courses based on their deadline date.
c... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,351 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/sep_challenge2021/ShortestPathGridWithObstacles.kt | yvelianyk | 405,919,452 | false | {"Kotlin": 147854, "Java": 610} | package sep_challenge2021
import java.util.*
fun main() {
val grid = arrayOf(
intArrayOf(0, 0, 0),
intArrayOf(1, 1, 0),
intArrayOf(0, 0, 0),
intArrayOf(0, 1, 1),
intArrayOf(0, 0, 0),
)
val result = shortestPath(grid, 1)
assert(result == 6)
println(result)
}
... | 0 | Kotlin | 0 | 0 | 780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd | 1,597 | leetcode-kotlin | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.