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/day25/Day25.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day25
import readInput
import kotlin.math.pow
import kotlin.math.roundToLong
const val day = "25"
fun Int.pow(p: Int): Long = this.toDouble().pow(p.toDouble()).roundToLong()
fun String.snafuToLong(): Long {
return reversed()
.mapIndexed { index, c ->
val digit = when (c) {
... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 1,834 | advent-of-code-22-kotlin | Apache License 2.0 |
src/day02/Day02.kt | TheJosean | 573,113,380 | false | {"Kotlin": 20611} | package day02
import readInput
fun main() {
fun calculateScore(round: Pair<Int, Int>) = when {
round.second - 1 == round.first || round.second + 1 < round.first -> round.second + 6 + 1
round.first == round.second -> round.second + 3 + 1
else -> round.second + 1
}
fun part1(input:... | 0 | Kotlin | 0 | 0 | 798d5e9b1ce446ba3bac86f70b7888335e1a242b | 1,193 | advent-of-code | Apache License 2.0 |
src/Day05.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | import java.util.Stack
typealias CargoStack = List<Stack<String>>
fun main() {
fun elementsToStack(elements: List<String>): Stack<String> {
val stack = Stack<String>()
stack.addAll(elements)
return stack
}
fun makeElements(initialStackList: List<String>): MutableList<MutableList<... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 2,778 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | ranveeraggarwal | 573,754,764 | false | {"Kotlin": 12574} | import kotlin.math.min
enum class FileType {
FILE, DIRECTORY
}
class TreeNode {
private val fileType: FileType
private var size: Long = 0
private val children: HashMap<String, TreeNode> = HashMap()
private var parent: TreeNode? = null
private var isDirty = false
constructor(size: Long) {... | 0 | Kotlin | 0 | 0 | c8df23daf979404f3891cdc44f7899725b041863 | 3,019 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day03.kt | colund | 573,040,201 | false | {"Kotlin": 10244} | fun main() {
val testInput = readInput("Day03")
val day3Part1 = day3Part1(testInput)
println("Day3 part 1: $day3Part1")
val day3Part2 = day3Part2(testInput)
println("Day3 part 2: $day3Part2")
}
private fun day3Part1(
testInput: List<String>
): Int {
val priorities = priorityChars()
ret... | 0 | Kotlin | 0 | 0 | 49dcd2fccad0e54ee7b1a9cb99df2acdec146759 | 1,404 | aoc-kotlin-2022 | Apache License 2.0 |
src/Day13.kt | frungl | 573,598,286 | false | {"Kotlin": 86423} | class Block : Comparable<Block> {
private var value: Int? = null
private val inside = mutableListOf<Block>()
private fun isLast() = value != null
fun set(x: Int) {
value = x
}
fun add(x: Block) {
inside.add(x)
}
override fun compareTo(other: Block): Int {
if (is... | 0 | Kotlin | 0 | 0 | d4cecfd5ee13de95f143407735e00c02baac7d5c | 2,801 | aoc2022 | Apache License 2.0 |
src/Day13.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | fun main() {
fun solve(map: List<CharArray>): MutableList<Int> {
val n = map.size
val res = mutableListOf<Int>()
for (i in 0 until n-1) {
val ok = (0 .. i).all { i1 ->
val i2 = i + 1 + (i-i1)
i2 !in map.indices || map[i1].contentEquals(map[i2])
... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 1,802 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/cloud/dqn/leetcode/TrappingRainWater2Kt.kt | aviuswen | 112,305,062 | false | null | package cloud.dqn.leetcode
import java.util.Comparator
import java.util.PriorityQueue
/**
* https://leetcode.com/problems/trapping-rain-water-ii/description/
Given an m x n matrix of positive integers representing the height
of each unit cell in a 2D elevation map, compute the volume of water
it is abl... | 0 | Kotlin | 0 | 0 | 23458b98104fa5d32efe811c3d2d4c1578b67f4b | 4,307 | cloud-dqn-leetcode | No Limit Public License |
advent-of-code-2022/src/Day01.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
fun readInput(name: String) = readText(name).splitToSequence("\n\n")
.map { it.lineSequence().map(String::toInt) }
// Time - O(N), Space - O(1)
// where N is number of Elves
fun part1(elves: Sequence<Sequence<Int>>): Int = elves.maxOf { it.sum() }
// Time - O(N*log(N)), Spa... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 1,412 | advent-of-code | Apache License 2.0 |
aoc-2023/src/main/kotlin/aoc/aoc12a.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocParser.Companion.parselines
import aoc.*
import aoc.util.getDayInput
val testInput = """
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
""".parselines
class Springs(_line: String, val nums: List<Int>) {
val max = nums.maxOr... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 1,600 | advent-of-code | Apache License 2.0 |
aoc2023/day7.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2023
import utils.InputRetrieval
fun main() {
Day7.execute()
}
private object Day7 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
private fun part1(input: List<Hand>): Long = input
.sortedWi... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 3,927 | Advent-Of-Code | MIT License |
src/Day07.kt | MisterTeatime | 560,956,854 | false | {"Kotlin": 37980} | fun main() {
val totalSpace = 70_000_000
val updateSpace = 30_000_000
fun part1(input: List<String>): Int {
val nodes = mutableSetOf<TreeNode>()
val root = TreeNode("/")
var currentNode = root
nodes.add(root)
//Verzeichnisbaum erstellen
input.drop(2).map {... | 0 | Kotlin | 0 | 0 | 8ba0c36992921e1623d9b2ed3585c8eb8d88718e | 3,071 | AoC2022 | Apache License 2.0 |
src/main/kotlin/day7/Day7.kt | Arch-vile | 317,641,541 | false | null | package day7
import readFile
data class Row(val color: String, val capacity: List<Pair<String, Int>>)
data class Capacity(val bag: Bag, val amount: Int)
data class Bag(val color: String, var capacity: MutableList<Capacity>) {
fun getContainedBagCount(): Int {
return capacity
.map { it.amount + it.amount *... | 0 | Kotlin | 0 | 0 | 12070ef9156b25f725820fc327c2e768af1167c0 | 1,604 | adventOfCode2020 | Apache License 2.0 |
src/Day12.kt | joy32812 | 573,132,774 | false | {"Kotlin": 62766} | import java.util.LinkedList
fun main() {
fun toKey(x: Int, y: Int) = x * 10000 + y
fun toCord(key: Int) = key / 10000 to key % 10000
fun shortestPath(grid: Array<CharArray>, edgeMap: Map<Int, MutableSet<Int>>, sx: Int, sy: Int, tx: Int, ty: Int): Int {
val m = grid.size
val n = grid[0].size
val an... | 0 | Kotlin | 0 | 0 | 5e87958ebb415083801b4d03ceb6465f7ae56002 | 2,888 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | GreyWolf2020 | 573,580,087 | false | {"Kotlin": 32400} | const val TOTALDISKSPACE = 70000000
const val NEEDEDUNUSEDSPACE = 30000000
fun main() {
fun part1(input: String): Int = FileSystem().run {
parseInstructions(input)
getListOfDirNSizes()
.map { it.second }
.filter { it < 100000 }
.sum()
}
fun part2(input:... | 0 | Kotlin | 0 | 0 | 498da8861d88f588bfef0831c26c458467564c59 | 3,909 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day04.kt | handrodev | 577,884,162 | false | {"Kotlin": 7670} | fun main() {
fun part1(input: List<String>): Int {
var overlapping = 0
for (line in input) {
// Get sections covered by each elf
val (elf1, elf2) = line.split(",")
// Get first and last section covered by each elf
val (x1, x2) = elf1.split("-").map { s... | 0 | Kotlin | 0 | 0 | d95aeb85b4baf46821981bb0ebbcdf959c506b44 | 1,464 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/se/brainleech/adventofcode/aoc2022/Aoc2022Day05.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2022
import se.brainleech.adventofcode.aoc2022.Aoc2022Day05.CraneModel.CRATE_MOVER_9000
import se.brainleech.adventofcode.aoc2022.Aoc2022Day05.CraneModel.CRATE_MOVER_9001
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adv... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 3,053 | adventofcode | MIT License |
src/Day04.kt | sk0g | 572,854,602 | false | {"Kotlin": 7597} | fun sectionsOverlapCompletely(s: String): Boolean {
val (assignment1, assignment2) = s.split(",")
val bounds1 = assignment1.toBounds()
val bounds2 = assignment2.toBounds()
var overlaps = bounds1.first <= bounds2.first && bounds1.second >= bounds2.second
overlaps = overlaps || bounds2.first <= bound... | 0 | Kotlin | 0 | 0 | cd7e0da85f71d40bc7e3761f16ecfdce8164dae6 | 1,759 | advent-of-code-22 | Apache License 2.0 |
src/Day11.kt | StephenVinouze | 572,377,941 | false | {"Kotlin": 55719} | import java.lang.IllegalArgumentException
import kotlin.math.floor
data class Monkey(
val id: Int,
val items: MutableList<Long>,
val operation: (Long) -> Long,
val throwToMonkey: (Long) -> Unit,
val divider: Int,
)
fun main() {
fun List<String>.toMonkeys(): List<Monkey> {
val monkeys ... | 0 | Kotlin | 0 | 0 | 11b9c8816ded366aed1a5282a0eb30af20fff0c5 | 4,276 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/executeTermCmds.kt | sam-hoodie | 534,831,633 | false | {"Kotlin": 43732} | import java.time.Duration
import java.time.LocalDateTime
fun interpretTermCmds(command: String, data: List<Person>) {
val commandParameters = command.split('.')
if (commandParameters[3] == "pop") {
if (commandParameters[4] == "state") {
println(getMostPopularState(data))
return
... | 0 | Kotlin | 0 | 0 | 9efea9f9eec55c1e61ac1cb11d3e3460f825994b | 6,871 | congress-challenge | Apache License 2.0 |
src/Day04.kt | Svikleren | 572,637,234 | false | {"Kotlin": 11180} | fun main() {
fun isPairContains(pairToContain: List<String>, pairToCheckInto: List<String>): Boolean {
val firstPairStart = pairToContain[0].toInt()
val firstPairEnd = pairToContain[1].toInt()
val secondPairStart = pairToCheckInto[0].toInt()
val secondPairEnd = pairToCheckInto[1].to... | 0 | Kotlin | 0 | 0 | e63be3f83b96a73543bf9bc00c22dc71b6aa0f57 | 1,964 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2022/day10/day10.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2022.day10
import biz.koziolek.adventofcode.findInput
fun main() {
val inputFile = findInput(object {})
val commands = parseCPUCommands(inputFile.bufferedReader().lineSequence()).toList()
val cpu = CPU(cycle = 1, registers = Registers(x = 1))
val cpuStates = runPr... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,072 | advent-of-code | MIT License |
src/Day08.kt | haitekki | 572,959,197 | false | {"Kotlin": 24688} | fun main() {
fun part1(input: String): Int {
val grid = input.lines()
val seeableTrees = mutableSetOf<String>()
for (i in grid.indices) {
for (j in grid[i].indices) {
if (i <= 0 ||
i == grid.lastIndex ||
j <= 0 ||
... | 0 | Kotlin | 0 | 0 | b7262133f9115f6456aa77d9c0a1e9d6c891ea0f | 2,775 | aoc2022 | Apache License 2.0 |
2021/src/main/kotlin/Day19.kt | eduellery | 433,983,584 | false | {"Kotlin": 97092} | import kotlin.math.abs
class Day19(input: String) {
private val scanners = input.split("""--- scanner \d+ ---""".toRegex()).filterNot { it.isEmpty() }.map { s ->
Scanner(s.trim().lines().map { it.split(",") }.map { (x, y, z) -> Point3D(x.toInt(), y.toInt(), z.toInt()) }
.toSet())
}
fu... | 0 | Kotlin | 0 | 1 | 3e279dd04bbcaa9fd4b3c226d39700ef70b031fc | 4,140 | adventofcode-2021-2025 | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day250/bf.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day250
import java.util.LinkedList
interface Circular<T> : Iterable<T> {
fun state(): T
fun inc()
fun isZero(): Boolean // `true` in exactly one state
fun hasNext(): Boolean // `false` if the next state `isZero()`
override fun iterator() : Iterator<T> {
return object : Iter... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,753 | daily-coding-problem | MIT License |
src/main/kotlin/com/github/dangerground/aoc2020/Day19.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
import com.github.dangerground.aoc2020.util.World
import kotlin.math.max
fun main() {
val process = Day19(DayInput.batchesOfStringList(19))
println("result part 1: ${process.part1()}")
println("result part 2: ${p... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 2,502 | adventofcode-2020 | MIT License |
src/Day15.kt | fedochet | 573,033,793 | false | {"Kotlin": 77129} | import kotlin.math.abs
fun main() {
data class Pos(val x: Int, val y: Int)
fun distance(from: Pos, to: Pos): Int =
abs(from.x - to.x) + abs(from.y - to.y)
fun parsePos(posStr: String): Pos {
val (x, y) = posStr.split(", ", limit = 2)
return Pos(
x.removePrefix("x=").... | 0 | Kotlin | 0 | 1 | 975362ac7b1f1522818fc87cf2505aedc087738d | 3,267 | aoc2022 | Apache License 2.0 |
src/Day05.kt | rickbijkerk | 572,911,701 | false | {"Kotlin": 31571} | fun main() {
fun test_startContainers(): Map<Int, ArrayDeque<String>> = mapOf(
1 to ArrayDeque(listOf("z", "n")),
2 to ArrayDeque(listOf("m", "c", "d")),
3 to ArrayDeque(listOf("p"))
)
fun startContainers() = mapOf(
1 to ArrayDeque(listOf("b", "w", "n")),
2 to Array... | 0 | Kotlin | 0 | 0 | 817a6348486c8865dbe2f1acf5e87e9403ef42fe | 2,862 | aoc-2022 | Apache License 2.0 |
src/Day13.kt | sbaumeister | 572,855,566 | false | {"Kotlin": 38905} | import kotlinx.serialization.json.*
fun listsInRightOrder(leftList: JsonArray, rightList: JsonArray): Boolean? {
var i = 0
while (true) {
if (leftList.getOrNull(i) == null && rightList.getOrNull(i) == null) {
return null
}
if (leftList.getOrNull(i) == null && rightList.getOr... | 0 | Kotlin | 0 | 0 | e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84 | 2,765 | advent-of-code-2022 | Apache License 2.0 |
day03/src/main/kotlin/Main.kt | rstockbridge | 159,586,951 | false | null | import java.io.File
fun main() {
val claims = parseInput(readInputFile())
println("Part I: the solution is ${solvePartI(claims)}.")
println("Part II: the solution is ${solvePartII(claims)}.")
}
fun readInputFile(): List<String> {
return File(ClassLoader.getSystemResource("input.txt").file).readLines(... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 2,011 | AdventOfCode2018 | MIT License |
src/main/kotlin/me/grison/aoc/y2022/Day11.kt | agrison | 315,292,447 | false | {"Kotlin": 267552} | package me.grison.aoc.y2022
import me.grison.aoc.*
import java.math.BigInteger.ONE
class Monkey(
var id: Int,
var items: MutableList<Long>,
var operation: (Long) -> Long,
var divisible: Long,
var destinations: Pair<Int, Int>
)
class Day11 : Day(11, 2022) {
override fun title() = "Monkey in th... | 0 | Kotlin | 3 | 18 | ea6899817458f7ee76d4ba24d36d33f8b58ce9e8 | 2,414 | advent-of-code | Creative Commons Zero v1.0 Universal |
src/Day02.kt | makohn | 571,699,522 | false | {"Kotlin": 35992} | import java.lang.IllegalArgumentException
fun main() {
fun toScore(c: Char) = when(c) {
'X',
'A' -> 1
'Y',
'B' -> 2
'Z',
'C' -> 3
else -> throw IllegalArgumentException()
}
fun calcScore(o: Char, m: Char): Int {
val sm = toScore(m)
... | 0 | Kotlin | 0 | 0 | 2734d9ea429b0099b32c8a4ce3343599b522b321 | 2,012 | aoc-2022 | Apache License 2.0 |
aoc-2023/src/main/kotlin/aoc/aoc3.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocParser.Companion.parselines
import aoc.*
import aoc.util.*
val testInput = """
467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..
""".parselines
fun CharGrid.symbols() = findCoords2 { it != '.' && !it.isDigit() }
fun CharGrid.numLocs() = indice... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 1,676 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day12/Day12.kt | qnox | 575,581,183 | false | {"Kotlin": 66677} | package day12
import readInput
import java.util.LinkedList
fun main() {
data class Location(val x: Int, val y: Int)
fun findEnd(input: List<String>): Location {
for (x in input.indices) {
for (y in input[x].indices) {
if (input[x][y] == 'E') {
return ... | 0 | Kotlin | 0 | 0 | 727ca335d32000c3de2b750d23248a1364ba03e4 | 2,099 | aoc2022 | Apache License 2.0 |
src/main/kotlin/day7/Day7.kt | mortenberg80 | 574,042,993 | false | {"Kotlin": 50107} | package day7
import day6.Day6
class Day7(input: List<String>) {
val commands = parseCommands(listOf(), input)
private val pathMap = buildMap()
private fun parseCommands(initial: List<Command>, input: List<String>): List<Command> {
if (input.isEmpty()) return initial
val line = in... | 0 | Kotlin | 0 | 0 | b21978e145dae120621e54403b14b81663f93cd8 | 3,905 | adventofcode2022 | Apache License 2.0 |
src/Day05.kt | Soykaa | 576,055,206 | false | {"Kotlin": 14045} | private fun parseStacks(processedInput: MutableList<List<String>>): List<MutableList<Char>> {
val stacksNumber = processedInput.last().last().last().code
val stacks: List<MutableList<Char>> = List(stacksNumber) { mutableListOf() }
processedInput.forEach { line ->
line.forEachIndexed { i, chunk ->
... | 0 | Kotlin | 0 | 0 | 1e30571c475da4db99e5643933c5341aa6c72c59 | 2,235 | advent-of-kotlin-2022 | Apache License 2.0 |
src/Day12.kt | Kietyo | 573,293,671 | false | {"Kotlin": 147083} | fun main() {
val fn = fun Grid<Char>.(point: MutableIntPoint): List<MutableIntPoint> {
val currChar = get(point)
val nextChar = when (currChar) {
'S' -> 'a'
'z' -> 'E'
else -> currChar + 1
}
val nextRange = when (currChar) {
'S' -> 'a'.... | 0 | Kotlin | 0 | 0 | dd5deef8fa48011aeb3834efec9a0a1826328f2e | 2,702 | advent-of-code-2022-kietyo | Apache License 2.0 |
src/day01/Day01.kt | mahan-ym | 572,901,965 | false | {"Kotlin": 4240} | package day01
import readInput
fun main() {
fun getEachElfWithMostCal(input: List<String>): ArrayList<Int> {
var recordIndex = 0
val summedCals = arrayListOf<Int>()
input.forEachIndexed { index ,record ->
if (record == "") {
summedCals.add(input.subList(recordI... | 0 | Kotlin | 0 | 0 | d09acc419480bcc025d482afae9da9438b87e4eb | 1,475 | AOC-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/aoc22/Day12.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import aoc22.Day12Domain.HeightMap
import aoc22.Day12Parser.toHeightMap
import aoc22.Day12Solution.part1Day12
import aoc22.Day12Solution.part2Day12
import common.Monitoring
import common.Space2D.Point
import common.Space2D.Parser.toPointToChars
import common.Year22
import common.graph.Dijkstra
import com... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 3,099 | aoc | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day4.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 4: Giant Squid
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.readFileAsString
fun main() {
println(" ** Day 4: Giant Squid ** \n")
val splitFile = readFileAsString("/Day4BingoBoards.txt")
.trim()
.split("\n\n")
val drawnNumbers = splitFile[0]
.spli... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 2,308 | AdventOfCode2021 | MIT License |
src/AoC10.kt | Pi143 | 317,631,443 | false | null | import java.io.File
fun main() {
println("Starting Day 10 A Test 1")
calculateDay10PartA("Input/2020_Day10_A_Test1")
println("Starting Day 10 A Real")
calculateDay10PartA("Input/2020_Day10_A")
println("Starting Day 10 B Test 1")
calculateDay10PartB("Input/2020_Day10_A_Test1")
println("Sta... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 4,111 | AdventOfCode2020 | MIT License |
src/day05/Day05.kt | zypus | 573,178,215 | false | {"Kotlin": 33417, "Shell": 3190} | package day05
import AoCTask
import java.util.Stack
// https://adventofcode.com/2022/day/5
data class Instruction(val from: Int, val to: Int, val count: Int) {
companion object {
fun fromString(string: String): Instruction {
val split = string.split(" ")
return Instruction(
... | 0 | Kotlin | 0 | 0 | f37ed8e9ff028e736e4c205aef5ddace4dc73bfc | 2,831 | aoc-2022 | Apache License 2.0 |
src/Day12.kt | karloti | 573,006,513 | false | {"Kotlin": 25606} | import java.util.ArrayDeque
val valueByChar: Map<Char, Int> = "SabcdefghijklmnopqrstuvwxyzE".withIndex().associate { (k, v) -> v to k }
val directions = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to +1)
data class Point(val h: Int, val v: Int, val c: Char, var d: Int? = null)
fun List<String>.toPoints(): List<List<Point>> =... | 0 | Kotlin | 1 | 2 | 39ac1df5542d9cb07a2f2d3448066e6e8896fdc1 | 1,338 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day02.kt | markhor1999 | 574,354,173 | false | {"Kotlin": 4937} | fun main() {
fun Pair<String, String>.getRoundScore(): Int {
return when {
//Rock & Rock -> Draw
first == "A" && second == "X" -> 1 + 3
//Rock & Paper -> Win
first == "A" && second == "Y" -> 2 + 6
//Rock & Scissors -> Loss
first == "A" ... | 0 | Kotlin | 0 | 0 | 800f218ff12908ebd885c3f475793c6be2d7fd7d | 2,110 | kotlin-advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumEffortPath.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,833 | kotlab | Apache License 2.0 |
src/Day07.kt | ThijsBoehme | 572,628,902 | false | {"Kotlin": 16547} | /*
Followed along with the Kotlin by JetBrains livestream, with some personal adjustments
*/
fun main() {
lateinit var sizes: MutableList<Int>
data class Tree(val name: String, var parent: Tree? = null) {
var size: Int = 0
val children: MutableList<Tree> = mutableListOf()
}
fun recur... | 0 | Kotlin | 0 | 0 | 707e96ec77972145fd050f5c6de352cb92c55937 | 2,036 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day10.kt | sebokopter | 570,715,585 | false | {"Kotlin": 38263} | fun main() {
fun callStack(inputs: List<String>): List<Pair<String, Int>> = inputs.map { input ->
val line = input.split(" ")
line[0] to line.getOrElse(1) { "0" }.toInt()
}
fun execute(callStack: List<Pair<String, Int>>): List<Pair<Int, Int>> =
callStack.fold(mutableListOf(1 to 1))... | 0 | Kotlin | 0 | 0 | bb2b689f48063d7a1b6892fc1807587f7050b9db | 2,031 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2022/src/Day14.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
val testInput = readInput("Day14_test")
val input = readInput("Day14")
"Part 1" {
part1(testInput) shouldBe 24
answer(part1(input))
}
"Part 2" {
part2(testInput) shouldBe 93
answer(part2(input))
}
}
private fun part1(input: List<List<List<Int>>>) =... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 2,882 | advent-of-code | Apache License 2.0 |
src/Day12.kt | PascalHonegger | 573,052,507 | false | {"Kotlin": 66208} | fun main() {
class Node(val character: Char, val index: Int, val neighbors: MutableList<Node> = mutableListOf()) {
val height = when (character) {
'S' -> 'a' - 'a'
'E' -> 'z' - 'a'
else -> character - 'a'
}
override fun toString() = "[$index]: $character"... | 0 | Kotlin | 0 | 0 | 2215ea22a87912012cf2b3e2da600a65b2ad55fc | 2,920 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Packets.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | fun main() = Packets.solve()
private object Packets {
fun solve() {
val input = readInput().toMutableList()
val dividers = setOf(
Lst(listOf(Lst(listOf(Num(2))))),
Lst(listOf(Lst(listOf(Num(6)))))
)
input.addAll(dividers)
val sorted = input.sorted()
... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 3,569 | aoc2022 | MIT License |
src/questions/InsertInterval.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.assertIterableSame
import java.util.*
/**
* You are given an array of non-overlapping intervals `intervals` where `intervals[i] = [starti, endi]`
* represent the start and the end of the ith interval and intervals is sorted in ascending order b... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 6,866 | algorithms | MIT License |
src/Day04.kt | EnyediPeti | 573,882,116 | false | {"Kotlin": 8717} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { pairString ->
val assignment = getAssignments(pairString)
val first = assignment[0]
val second = assignment[1]
val firstRange = getRange(first)
val secondRange = getRange(seco... | 0 | Kotlin | 0 | 0 | 845ef2275540a6454a97a9e4c71f239a5f2dc295 | 1,756 | AOC2022 | Apache License 2.0 |
src/main/kotlin/aoc23/Day14.kt | tahlers | 725,424,936 | false | {"Kotlin": 65626} | package aoc23
import io.vavr.collection.LinkedHashMap
import kotlin.math.min
object Day14 {
data class Pos(val x: Int, val y: Int)
data class MirrorMap(val maxX: Int, val maxY: Int, val rocks: Set<Pos>, val cubes: Set<Pos>) {
fun turn(): MirrorMap {
val turnedRocks = rocks.map { Pos(it.y... | 0 | Kotlin | 0 | 0 | 0cd9676a7d1fec01858ede1ab0adf254d17380b0 | 4,293 | advent-of-code-23 | Apache License 2.0 |
src/Day23.kt | Fedannie | 572,872,414 | false | {"Kotlin": 64631} | enum class Direction(val xRange: IntRange, val yRange: IntRange) {
N(-1 .. -1, -1 .. 1), S(1 .. 1, -1 .. 1), W(-1 .. 1, -1 .. -1), E(-1 .. 1, 1 .. 1);
fun next(coordinate: Coordinate): Coordinate {
return when (this) {
N -> Coordinate(coordinate.x - 1, coordinate.y)
S -> Coordinate(coordinate.x + 1... | 0 | Kotlin | 0 | 0 | 1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f | 3,750 | Advent-of-Code-2022-in-Kotlin | Apache License 2.0 |
src/main/kotlin/days/aoc2023/Day7.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2023
import days.Day
class Day7 : Day(2023, 7) {
override fun partOne(): Any {
return calculatePartOne(inputList)
}
override fun partTwo(): Any {
return calculatePartTwo(inputList)
}
fun calculatePartOne(input: List<String>): Int {
val hands = input.map { ... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 4,186 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-08.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2023
import com.github.ferinagy.adventOfCode.lcm
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2023, "08-input")
val test1 = readInputLines(2023, "08-test1")
val tes... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,628 | advent-of-code | MIT License |
src/Day01.kt | lsimeonov | 572,929,910 | false | {"Kotlin": 66434} | class Calorie(val calorie: Int) {
}
class Dwarf {
private var calories: MutableList<Calorie> = mutableListOf()
fun addCalorie(calorie: Calorie) {
calories.add(calorie)
}
fun totalCalories(): Int {
return calories.sumOf { it.calorie }
}
}
fun main() {
fun prepareDwarfs(input: ... | 0 | Kotlin | 0 | 0 | 9d41342f355b8ed05c56c3d7faf20f54adaa92f1 | 1,688 | advent-of-code-2022 | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions51.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import kotlin.math.min
fun test51() {
printlnResult(intArrayOf(7, 5, 6, 4))
printlnResult(intArrayOf(7, 5, 6, 4, 1))
printlnResult(intArrayOf(0, 7, 5, 6, 4, 1))
printlnResult(intArrayOf(1))
}
/**
* Questions 51: Find the count of reverse-order-pair in an IntArr... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,893 | Algorithm | Apache License 2.0 |
src/main/kotlin/day15.kt | gautemo | 572,204,209 | false | {"Kotlin": 78294} | import shared.Point
import shared.getText
import kotlin.math.abs
fun main() {
val input = getText("day15.txt")
println(day15A(input, 2000000))
println(day15B(input, 4000000))
}
fun day15A(input: String, rowToCheck: Int): Int {
val pairs = input.lines().map { positions(it) }
val mostLeft = pairs.mi... | 0 | Kotlin | 0 | 0 | bce9feec3923a1bac1843a6e34598c7b81679726 | 1,814 | AdventOfCode2022 | MIT License |
math/MaxPointsOnALine/kotlin/Solution.kt | YaroslavHavrylovych | 78,222,218 | false | {"Java": 284373, "Kotlin": 35978, "Shell": 2994} | import kotlin.math.sign
/**
* Given n points on a 2D plane, find the maximum number of points that
* lie on the same straight line.
* <br>
* https://leetcode.com/problems/max-points-on-a-line/
*/
class Solution {
fun maxPoints(points: Array<IntArray>): Int {
if (points.size < 2) return points.size
... | 0 | Java | 0 | 2 | cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd | 1,927 | codility | MIT License |
src/Day04.kt | seana-zr | 725,858,211 | false | {"Kotlin": 28265} | import java.util.LinkedList
import java.util.regex.Pattern
import kotlin.math.max
import kotlin.math.min
import kotlin.math.pow
fun main() {
data class Card(
val id: Int,
val winning: Set<Int>,
val hand: Set<Int>
)
fun parseCard(card: String): Card {
val combos = card
... | 0 | Kotlin | 0 | 0 | da17a5de6e782e06accd3a3cbeeeeb4f1844e427 | 1,963 | advent-of-code-kotlin-template | Apache License 2.0 |
src/main/kotlin/com/sk/set2/212. Word Search II.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set2
class Solution212 {
fun findWords(board: Array<CharArray>, words: Array<String>): List<String> {
val res = mutableListOf<String>()
outerLoop@ for (word in words) {
for (r in board.indices) {
for (c in board[0].indices) {
val seen ... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 3,062 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/days/day12/Day12.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day12
import days.Day
class Day12 : Day() {
override fun partOne(): Any {
val springs: MutableList<Pair<List<Char>, List<Int>>> = mutableListOf()
val rawInput = readInput()
rawInput.forEach {
val input = it.split(" ")
val spring = input[0].toCharArray()... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 4,009 | advent-of-code_2023 | The Unlicense |
advent2022/src/main/kotlin/year2022/Day11.kt | bulldog98 | 572,838,866 | false | {"Kotlin": 132847} | package year2022
import AdventDay
import lcm
class Day11 : AdventDay(2022, 11) {
data class Monkey(
val monkeyNumber: Int,
val items: List<Int>,
val operation: (Long) -> Long,
val throwToMonkey: (Int) -> Int
)
private fun List<String>.parseSingleMonkey(): Monkey {
... | 0 | Kotlin | 0 | 0 | 02ce17f15aa78e953a480f1de7aa4821b55b8977 | 3,440 | advent-of-code | Apache License 2.0 |
src/Day18.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | suspend fun main() {
val testInput = readInput("Day18_test")
check(part1(testInput) == 64)
check(part2(testInput) == 58)
val input = readInput("Day18")
measureAndPrintResult {
part1(input)
}
measureAndPrintResult {
part2(input)
}
}
private fun part1(input: List<String>)... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 1,723 | aoc-22 | Apache License 2.0 |
src/day_12/kotlin/Day12.kt | Nxllpointer | 573,051,992 | false | {"Kotlin": 41751} | // AOC Day 12
operator fun Array<IntArray>.get(position: Vector2D) = this[position.y][position.x]
operator fun Array<IntArray>.set(position: Vector2D, value: Int) = this[position.y].set(position.x, value)
val Array<IntArray>.verticalSize get() = this.size
val Array<IntArray>.horizontalSize get() = this.first().size
f... | 0 | Kotlin | 0 | 0 | b6d7ef06de41ad01a8d64ef19ca7ca2610754151 | 3,569 | AdventOfCode2022 | MIT License |
src/main/kotlin/com/sk/set1/149. Max Points on a Line.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.set1
class Solution149 {
// ???
fun maxPoints(points: Array<IntArray>): Int {
fun slope(a: IntArray, b: IntArray): Double {
return (b[1].toDouble() - a[1]) / (b[0] - a[0])
}
val map = HashMap<Double, MutableSet<Pair<Int, Int>>>()
for (i in points.i... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 3,264 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/year2023/day-04.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2023
import lib.aoc.Day
import lib.aoc.Part
import lib.memoize
import lib.splitLines
import kotlin.math.pow
fun main() {
Day(4, 2023, PartA4(), PartB4()).run()
}
open class PartA4 : Part() {
protected data class Card(val id: Int, val winningNumbers: List<Int>, val yourNumbers: List<Int>) {
... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 2,275 | Advent-Of-Code-Kotlin | MIT License |
src/Day14.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | private enum class Unit {
ROCK, SAND
}
fun main() {
data class Coordinate(val x: Int, val y: Int) {
override fun toString() = "$x,$y"
}
operator fun Coordinate.rangeTo(other: Coordinate) = when {
this == other -> sequenceOf(this)
x == other.x -> (if (y < other.y) y..other.y els... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 3,140 | advent-of-code-22 | Apache License 2.0 |
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Collections.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.common
import java.util.*
/**
* Generates all permutations of a list.
* @see <a href="https://rosettacode.org/wiki/Permutations#Kotlin">Source on RosettaCode</a>
*/
fun <T> List<T>.permutations(): List<List<T>> {
if (this.size == 1) return listOf(this)
val perms = mutableListOf<List<... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 2,522 | advent-of-code | MIT License |
src/leetcodeProblem/leetcode/editor/en/SearchInRotatedSortedArray.kt | faniabdullah | 382,893,751 | false | null | //There is an integer array nums sorted in ascending order (with distinct
//values).
//
// Prior to being passed to your function, nums is possibly rotated at an
//unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k]
//, nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,202 | dsa-kotlin | MIT License |
jk/src/main/kotlin/leetcode/Solution_LeetCode_912_21_Merge_Sort_Related.kt | lchang199x | 431,924,215 | false | {"Kotlin": 86230, "Java": 23581} | package leetcode
import common.ListNode
import common.buildLinkedList
import common.printPretty
class Solution_LeetCode_912_21_Merge_Sort_Related {
/**
* 归并排序
* [](https://leetcode-cn.com/problems/sort-an-array/)
*/
fun mergeSort(nums: IntArray): IntArray {
// 归并排序需要一个临时数组保存左右两子数组合并后的结果... | 0 | Kotlin | 0 | 0 | 52a008325dd54fed75679f3e43921fcaffd2fa31 | 5,095 | Codelabs | Apache License 2.0 |
src/Day19.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | import kotlin.math.max
import kotlin.math.min
private const val EXPECTED_1 = 19114
private const val EXPECTED_2 = 167409079868000L
typealias XmasRange = List<Pair<Int, Int>>
private class Day19(isTest: Boolean) : Solver(isTest) {
val desc: String
val parts: String
val indexStr = "xmas"
init {
... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 4,114 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/io/dp/PowerSetsII.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/subsets-ii/
class PowerSetsII {
fun execute(input: IntArray, size: Int = 0): List<List<Int>> = when (size) {
!in input.indices -> listOf(listOf())
else -> {
execute(input, size + 1).let { previousSubsets ->
... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,382 | coding | MIT License |
advent-of-code-2022/src/Day07.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
val testInput = readLines("Day07_test")
val input = readLines("Day07")
"Part 1" {
part1(testInput) shouldBe 95437
measureAnswer { part1(input) }
}
"Part 2" {
part2(testInput) shouldBe 24933642
measureAnswer { part2(input) }
}
}
private fun part1(in... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 1,956 | advent-of-code | Apache License 2.0 |
day12/kotlin/corneil/src/main/kotlin/solution.kt | timgrossmann | 224,991,491 | true | {"HTML": 2739009, "Python": 169603, "Java": 157274, "Jupyter Notebook": 116902, "TypeScript": 113866, "Kotlin": 89503, "Groovy": 73664, "Dart": 47763, "C++": 43677, "CSS": 34994, "Ruby": 27091, "Haskell": 26727, "Scala": 11409, "Dockerfile": 10370, "JavaScript": 6496, "PHP": 4152, "Go": 2838, "Shell": 2493, "Rust": 208... | package com.github.corneil.aoc2019.day12
import java.math.BigInteger
import java.util.*
import kotlin.math.abs
typealias Axis = IntArray
fun Axis.energy(): Int = this.sumBy { abs(it) }
fun Axis.copy() = this.toList().toIntArray()
class Moon(
val id: Int,
val pos: Axis,
val vel: Axis
) {
init {
... | 0 | HTML | 0 | 1 | bb19fda33ac6e91a27dfaea27f9c77c7f1745b9b | 5,328 | aoc-2019 | MIT License |
src/Day05.kt | Kbzinho-66 | 572,299,619 | false | {"Kotlin": 34500} | private fun String.getValues() = this
.split(" ")
.filter { parts -> parts.all { it.isDigit() } }
.map { it.toInt() }
private fun Array<ArrayDeque<Char>>.move(from: Int, to: Int) {
this[to].add(this[from].removeLastOrNull() ?: ' ')
}
private fun Array<ArrayDeque<Char>>.move(n: Int, from: Int, to: Int)... | 0 | Kotlin | 0 | 0 | e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b | 2,537 | advent_of_code_2022_kotlin | Apache License 2.0 |
src/main/kotlin/advent2019/day10/day10.kt | davidpricedev | 225,621,794 | false | null | package advent2019.day10
import kotlin.math.PI
import kotlin.math.atan2
import kotlin.math.pow
import kotlin.math.sqrt
/**
* Part1 Notes:
* 1st translate dots and hashes into a list of asteroids w/ coordinates
* 2nd for each asteroid calculate how many asteroids it can "see"
* - this means finding ray collisions... | 0 | Kotlin | 0 | 0 | 2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9 | 6,423 | adventOfCode2019 | Apache License 2.0 |
src/Day02.kt | freszu | 573,122,040 | false | {"Kotlin": 32507} | private enum class Move {
ROCK, PAPER, SCISSORS;
fun score(against: Move) = when {
this == against -> 3
this.losingAgainst() == against -> 0
this.winsAgainst() == against -> 6
else -> throw IllegalStateException("Invalid move combination: $this vs $against")
}
fun losin... | 0 | Kotlin | 0 | 0 | 2f50262ce2dc5024c6da5e470c0214c584992ddb | 1,814 | aoc2022 | Apache License 2.0 |
src/main/kotlin/Day02.kt | Mariyo | 728,179,583 | false | {"Kotlin": 10845} | class Day02(private val bag: Bag) {
fun puzzle1IsPossible(game: Game): Boolean {
return bag.hasEnoughColoredCubes(game)
}
fun puzzle1SumAllPossibleGameIds(games: List<Game>): Int {
return games.filter { game ->
bag.hasEnoughColoredCubes(game)
}.sumOf { game ->
... | 0 | Kotlin | 0 | 0 | da779852b808848a26145a81cbf4330f6af03d84 | 2,237 | advent-of-code-kotlin-2023 | Apache License 2.0 |
src/Day03.kt | MSchu160475 | 573,330,549 | false | {"Kotlin": 5456} | fun main() {
fun part1(input: List<String>): Int {
//ASCII A-Z 65-90 -38
//ASCII a-z 97-122 -96
return input.sumOf {
val firstHalf = it.substring(0, (it.length / 2)).toCharArray()
val secondHalf = it.substring(it.length / 2).toSet()
firstHalf.intersect(s... | 0 | Kotlin | 0 | 0 | c6f9a0892a28f0f03b95768b6611e520c85db75c | 1,084 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/day03/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day03
import java.io.File
fun main() {
val lines = File("src/main/kotlin/day03/input.txt").readLines()
val binaryCodeCounts = IntArray(12) { 0 }
val reportDatBitsHistogram = lines
.map { it.toCharArray() }
.fold(binaryCodeCounts) { counter, reportLine ->
for (i in count... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 2,832 | aoc-2021 | MIT License |
2019/03 - Crossed Wires/kotlin/src/app.kt | Adriel-M | 225,250,242 | false | null | import java.io.File
import kotlin.math.absoluteValue
enum class Direction(val dx: Int, val dy: Int) {
UP(0, -1),
DOWN(0, 1),
LEFT(-1, 0),
RIGHT(1, 0)
}
data class Move(val direction: Direction, val magnitude: Int)
fun extractMovesFromString(moveString: String): List<Move> {
return moveString.spli... | 0 | Kotlin | 0 | 0 | ceb1f27013835f13d99dd44b1cd8d073eade8d67 | 3,300 | advent-of-code | MIT License |
src/day02/day03.kt | zoricbruno | 573,440,038 | false | {"Kotlin": 13739} | package day02
import readInput
fun getSignPoints(sign: Char): Int {
val points = hashMapOf<Char, Int>('A' to 1, 'B' to 2, 'C' to 3)
return points[sign]!!
}
fun mapToOutcome(sign: Char): Char {
val mapping = hashMapOf<Char, Char>('X' to 'A', 'Y' to 'B', 'Z' to 'C')
return mapping[sign]!!
}
fun mapToA... | 0 | Kotlin | 0 | 0 | 16afa06aff0b6e988cbea8081885236e4b7e0555 | 1,786 | kotlin_aoc_2022 | Apache License 2.0 |
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec16.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2020
import org.elwaxoro.advent.PuzzleDayTester
class Dec16 : PuzzleDayTester(16, 2020) {
override fun part1(): Any = parse().let { shebang ->
shebang.rules.map { it.range }.flatten().toSet().let { validNums ->
shebang.otherTickets.map { it.numbers.filterNot { vali... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 4,074 | advent-of-code | MIT License |
src/Day05.kt | pavlo-dh | 572,882,309 | false | {"Kotlin": 39999} | fun main() {
fun String.getCrate(stackIndex: Int): Char? {
val crateIndex = 4 * stackIndex + 1
if (crateIndex > this.length) return null
val crate = this[crateIndex]
return if (crate.isWhitespace()) null else crate
}
fun createStacks(input: List<String>, inputDelimiterIndex:... | 0 | Kotlin | 0 | 2 | c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992 | 2,234 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | jfiorato | 573,233,200 | false | null | import java.util.*
fun main() {
fun part1(input: List<String>): String {
val stacks: MutableMap<Int, Stack<String>> = mutableMapOf()
for (line in input) {
if (line.take(4) == "move") {
val moveRegex = """move (\d*) from (\d*) to (\d*)""".toRegex()
val mov... | 0 | Kotlin | 0 | 0 | 4455a5e9c15cd067d2661438c680b3d7b5879a56 | 2,668 | kotlin-aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc2021/Day11.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2021
import utils.InputUtils
typealias Int2d = Array<IntArray>
fun Int2d.copy() = map { it.clone() }.toTypedArray()
fun Int2d.countZeros() = sumOf { it.count { i -> i == 0 } }
fun Int2d.allZeros() = all { it.all { it == 0 } }
class Cave(val energy: Int2d) {
fun step(): Cave {
val copy = energ... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 2,304 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/solutions/Day13DistressSignal.kt | aormsby | 571,002,889 | false | {"Kotlin": 80084} | package solutions
import utils.Input
import utils.Solution
import java.util.*
// run only this day
fun main() {
Day13DistressSignal()
}
class Day13DistressSignal : Solution() {
private val ten = ':'
init {
begin("Day 13 - Distress Signal")
// remove blank lines, replace 10s with colon -... | 0 | Kotlin | 0 | 0 | 1bef4812a65396c5768f12c442d73160c9cfa189 | 3,949 | advent-of-code-2022 | MIT License |
lib/src/main/kotlin/com/bloidonia/advent/day16/Day16.kt | timyates | 433,372,884 | false | {"Kotlin": 48604, "Groovy": 33934} | package com.bloidonia.advent.day16
import com.bloidonia.advent.readText
sealed class Packet(val version: Int, val type: Int) {
abstract fun versionSum(): Long
abstract fun run(): Long
}
class Literal(version: Int, type: Int, private val value: Long) : Packet(version, type) {
override fun versionSum() = v... | 0 | Kotlin | 0 | 1 | 9714e5b2c6a57db1b06e5ee6526eb30d587b94b4 | 2,806 | advent-of-kotlin-2021 | MIT License |
src/Day08.kt | Kietyo | 573,293,671 | false | {"Kotlin": 147083} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Unit {
val height = input.size
val width = input.first().length
val grid = input.map { it.map { it.digitToInt() } }
var numVisible = 0
for (h in 0 until height) {
for (w in 0 until width) {
... | 0 | Kotlin | 0 | 0 | dd5deef8fa48011aeb3834efec9a0a1826328f2e | 3,197 | advent-of-code-2022-kietyo | Apache License 2.0 |
src/main/kotlin/Day09.kt | N-Silbernagel | 573,145,327 | false | {"Kotlin": 118156} | import kotlin.math.abs
import kotlin.math.sign
fun main() {
val input = readFileAsList("Day09")
println(Day09.part1(input))
println(Day09.part2(input))
}
object Day09 {
fun part1(input: List<String>): Int {
return solve(input, 2)
}
fun part2(input: List<String>): Int {
return ... | 0 | Kotlin | 0 | 0 | b0d61ba950a4278a69ac1751d33bdc1263233d81 | 2,024 | advent-of-code-2022 | Apache License 2.0 |
src/day05/day05.kt | mahmoud-abdallah863 | 572,935,594 | false | {"Kotlin": 16377} | package day05
import assertEquals
import readInput
import readTestInput
data class Instruction(
val moveCount: Int,
val fromStackIndex: Int,
val toStackIndex: Int
)
fun main() {
fun readStacks(input: List<String>): MutableList<MutableList<String>> {
val output = mutableListOf<MutableList<Str... | 0 | Kotlin | 0 | 0 | f6d1a1583267e9813e2846f0ab826a60d2d1b1c9 | 3,136 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day08.kt | robfletcher | 724,814,488 | false | {"Kotlin": 18682} | import kotlin.math.max
import kotlin.math.min
class Day08 : Puzzle {
override fun test() {
val input1 = """
RL
AAA = (BBB, CCC)
BBB = (DDD, EEE)
CCC = (ZZZ, GGG)
DDD = (DDD, DDD)
EEE = (EEE, EEE)
GGG = (GGG, GGG)
ZZZ = (ZZZ, ZZZ)""".trimIndent()
assert(part1(... | 0 | Kotlin | 0 | 0 | cf10b596c00322ea004712e34e6a0793ba1029ed | 2,435 | aoc2023 | The Unlicense |
src/aoc2018/kot/Day11.kt | Tandrial | 47,354,790 | false | null | package aoc2018.kot
object Day11 {
data class Result(val x: Int = 0, val y: Int = 0, val power: Int = Int.MIN_VALUE, val size: Int = 0) {
override fun toString() = "$x,$y,$size"
}
fun partOne(gId: Int) = solve(3, calcSumGrid(gId, 300)).toString().dropLast(2)
fun partTwo(gId: Int): String {
val grid =... | 0 | Kotlin | 1 | 1 | 9294b2cbbb13944d586449f6a20d49f03391991e | 1,393 | Advent_of_Code | MIT License |
src/Day13.kt | meierjan | 572,860,548 | false | {"Kotlin": 20066} | import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
sealed class NestedIntList {
data class List(
val list: kotlin.collections.List<NestedIntList>
) ... | 0 | Kotlin | 0 | 0 | a7e52209da6427bce8770cc7f458e8ee9548cc14 | 2,743 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/day4/Day4.kt | Arch-vile | 317,641,541 | false | null | package day4
import day4.FieldType.byr
import day4.FieldType.cid
import day4.FieldType.ecl
import day4.FieldType.eyr
import day4.FieldType.hcl
import day4.FieldType.hgtCm
import day4.FieldType.hgtIn
import day4.FieldType.iyr
import day4.FieldType.pid
import java.io.File
enum class FieldType {
byr, iyr, eyr, hgtCm... | 0 | Kotlin | 0 | 0 | 12070ef9156b25f725820fc327c2e768af1167c0 | 2,264 | adventOfCode2020 | Apache License 2.0 |
src/day05/Day05.kt | TheRishka | 573,352,778 | false | {"Kotlin": 29720} | package day05
import readInput
import java.util.Stack
import kotlin.math.max
import kotlin.math.min
fun main() {
val startStacksField = mutableMapOf(
1 to Stack<Char>().apply {
addAll(listOf('D', 'H', 'R', 'Z', 'S', 'P', 'W', 'Q').reversed())
},
2 to Stack<Char>().apply {
... | 0 | Kotlin | 0 | 1 | 54c6abe68c4867207b37e9798e1fdcf264e38658 | 3,012 | AOC2022-Kotlin | Apache License 2.0 |
src/day07/Day07.kt | armanaaquib | 572,849,507 | false | {"Kotlin": 34114} | package day07
import readInputAsText
data class File(val name: String, val size: Int)
data class Directory(
val name: String,
val files: MutableList<File> = mutableListOf(),
val directories: MutableList<Directory> = mutableListOf(),
val parent: Directory?
)
fun main() {
fun parseFiles(list: List<... | 0 | Kotlin | 0 | 0 | 47c41ceddacb17e28bdbb9449bfde5881fa851b7 | 3,015 | aoc-2022 | Apache License 2.0 |
2023/7/solve-2.kts | gugod | 48,180,404 | false | {"Raku": 170466, "Perl": 121272, "Kotlin": 58674, "Rust": 3189, "C": 2934, "Zig": 850, "Clojure": 734, "Janet": 703, "Go": 595} | import java.io.File
import kotlin.math.pow
enum class HandType(val strongness: Int) {
FiveOfAKind(7),
FourOfAKind(6),
FullHouse(5),
ThreeOfAKind(4),
TwoPair(3),
OnePair(2),
HighCard(1);
companion object {
fun fromFreq (freq: Map<Char,Int>): HandType =
when(freq.keys... | 0 | Raku | 1 | 5 | ca0555efc60176938a857990b4d95a298e32f48a | 1,688 | advent-of-code | Creative Commons Zero v1.0 Universal |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.