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/leetcode/Problem1514.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
import java.util.PriorityQueue
/**
* https://leetcode.com/problems/path-with-maximum-probability/
*/
class Problem1514 {
fun maxProbability(n: Int, edges: Array<IntArray>, succProb: DoubleArray, start: Int,
end: Int): Double {
val adjList = buildAdjList(n, edges, ... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 1,664 | leetcode | MIT License |
src/y2023/d03/Day03.kt | AndreaHu3299 | 725,905,780 | false | {"Kotlin": 31452} | package y2023.d03
import println
import readInput
class Num(val y: Int, val xMin: Int, val xMax: Int, val num: Int) {
var adjacentPos: List<Pair<Int, Int>> = getAdjacent(this)
override fun toString(): String {
return "Num(y=$y, xMin=$xMin, xMax=$xMax, num=$num)"
}
fun nextToGear(pos: Pair<In... | 0 | Kotlin | 0 | 0 | f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e | 4,179 | aoc | Apache License 2.0 |
jk/src/main/kotlin/leetcode/Solution_LeetCode_1_Two_Sum_Three_Sum.kt | lchang199x | 431,924,215 | false | {"Kotlin": 86230, "Java": 23581} | package leetcode
import java.util.*
/**
* 两数之和
*/
class Solution_LeetCode_1_Two_Sum_Three_Sum {
/**
* 无序数组:空间换时间
* [](https://leetcode-cn.com/problems/two-sum/)
*/
fun twoSum(nums: IntArray, target: Int): IntArray {
val map = hashMapOf<Int, Int>()
nums.forEachIndexed { index, ... | 0 | Kotlin | 0 | 0 | 52a008325dd54fed75679f3e43921fcaffd2fa31 | 2,527 | Codelabs | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2018/Day24.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 24 - Immune System Simulator 20XX
*
* Problem Description: http://adventofcode.com/2018/day/24
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day24/
*/
package com.ginsberg.advent2018
class Day24(immuneInput: List<... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 5,406 | advent-2018-kotlin | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day15/day15.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day15
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val riskMap = parseRiskMap(lines)
val lowestRiskPath = findLowestRiskPath(riskMap,
start = Coord(0, 0),
... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 2,791 | advent-of-code | MIT License |
aoc/src/main/kotlin/com/bloidonia/aoc2023/day17/Main.kt | timyates | 725,647,758 | false | {"Kotlin": 45518, "Groovy": 202} | package com.bloidonia.aoc2023.day17
import com.bloidonia.aoc2023.graph.End
import com.bloidonia.aoc2023.graph.Neighbours
import com.bloidonia.aoc2023.graph.shortestPath
import com.bloidonia.aoc2023.text
private const val example = """2413432311323
3215453535623
3255245654254
3446585845452
4546657867536
1438598798454
... | 0 | Kotlin | 0 | 0 | 158162b1034e3998445a4f5e3f476f3ebf1dc952 | 3,398 | aoc-2023 | MIT License |
src/Day04.kt | esteluk | 572,920,449 | false | {"Kotlin": 29185} | fun main() {
fun part1(input: List<String>): Int {
return input.map { elves ->
val split = elves.split(",").map { range ->
val rangeValues = range.split("-")
IntRange(rangeValues[0].toInt(), rangeValues[1].toInt())
}
val pair = Pair(split[... | 0 | Kotlin | 0 | 0 | 5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73 | 1,244 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/com/anahoret/aoc2022/day10/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day10
import java.io.File
fun main() {
val input = File("src/main/kotlin/com/anahoret/aoc2022/day10/input.txt")
.readText()
.trim()
val commandResults = input
.split("\n")
.map(Command.Companion::parse)
.fold(State()) { state, comm -> state... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 2,360 | advent-of-code-2022 | Apache License 2.0 |
src/year2023/09/Day09.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2023.`09`
import readInput
import utils.printlnDebug
private const val CURRENT_DAY = "09"
private fun parseLineInto(line: String): List<Long> {
return line.split(" ")
.map { it.toLong() }
}
fun process(initialList: List<Long>): List<List<Long>> {
val resList = mutableListOf(initialList)
... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 1,882 | KotlinAdventOfCode | Apache License 2.0 |
src/Day07.kt | allwise | 574,465,192 | false | null | fun main() {
fun part1(input:String): Int {
val processFiles = ProcessFiles(input)
return processFiles.process()
}
fun part2(input:String): Int {
val processFiles = ProcessFiles(input)
return processFiles.process2()
}
// test if implementation meets criteria from ... | 0 | Kotlin | 0 | 0 | 400fe1b693bc186d6f510236f121167f7cc1ab76 | 3,255 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | Reivax47 | 572,984,467 | false | {"Kotlin": 32685} | fun main() {
fun part1(input: List<String>): Int {
fun secontiennent(FirstElveDebut: Int, FirstElveFin: Int, SecondElveDebut: Int, SecondElveFin: Int): Boolean {
return ((FirstElveDebut >= SecondElveDebut && FirstElveFin <= SecondElveFin) || (FirstElveDebut <= SecondElveDebut && FirstElveFin >... | 0 | Kotlin | 0 | 0 | 0affd02997046d72f15d493a148f99f58f3b2fb9 | 1,899 | AD2022-01 | Apache License 2.0 |
src/Day19.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
fun parseInput(input: List<String>): MutableList<List<Int>> {
val output = mutableListOf<List<Int>>()
for (i in input) {
val regex = """Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Each obsidian robot costs (\d+) ore and (\d+) clay. Each ... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 2,546 | aoc-2022 | Apache License 2.0 |
2k23/aoc2k23/src/main/kotlin/14.kt | papey | 225,420,936 | false | {"Rust": 88237, "Kotlin": 63321, "Elixir": 54197, "Crystal": 47654, "Go": 44755, "Ruby": 24620, "Python": 23868, "TypeScript": 5612, "Scheme": 117} | package d14
fun main() {
println("Part 1: ${part1(input.read("14.txt"))}")
println("Part 2: ${part2(input.read("14.txt"))}")
}
fun part1(input: List<String>): Int {
val platform = Platform(input.map { it.toCharArray() })
platform.tilt(Platform.Direction.North)
return platform.load()
}
fun part2(... | 0 | Rust | 0 | 3 | cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5 | 2,796 | aoc | The Unlicense |
src/Day12.kt | fonglh | 573,269,990 | false | {"Kotlin": 48950, "Ruby": 1701} | import kotlin.math.absoluteValue
fun main() {
fun buildMap(input: List<String>): Array<CharArray> {
var map = Array(input.size) { CharArray(input[0].length) }
input.forEachIndexed { index, line ->
map[index] = line.toCharArray()
}
return map
}
fun findStartAndEnd... | 0 | Kotlin | 0 | 0 | ef41300d53c604fcd0f4d4c1783cc16916ef879b | 5,653 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | andydenk | 573,909,669 | false | {"Kotlin": 24096} | fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day04_test")
check(part1(testInput) == 2)
check(part2(testInput) == 4)
val input = readInput("Day04")
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
private... | 0 | Kotlin | 0 | 0 | 1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1 | 1,218 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | rickbijkerk | 572,911,701 | false | {"Kotlin": 31571} | fun main() {
class Node(
val value: Int,
val children: MutableList<Node> = mutableListOf(),
val name: String,
val parent: Node? = null,
var folderSize: Int = 0
) {
override fun toString(): String {
return "Node(name='$name', value=$value)"
}
... | 0 | Kotlin | 0 | 0 | 817a6348486c8865dbe2f1acf5e87e9403ef42fe | 3,827 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/days/Day4.kt | MisterJack49 | 729,926,959 | false | {"Kotlin": 31964} | package days
import kotlin.math.pow
class Day4 : Day(4) {
override fun partOne() =
inputList
.filterNot { it.isEmpty() }
.parseCards().sumOf { it.points }
override fun partTwo() =
Deck(inputList
.filterNot { it.isEmpty() }
.parseCards())
... | 0 | Kotlin | 0 | 0 | 807a6b2d3ec487232c58c7e5904138fc4f45f808 | 1,594 | AoC-2023 | Creative Commons Zero v1.0 Universal |
advent-of-code-2021/src/code/day7/Main.kt | Conor-Moran | 288,265,415 | false | {"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733} | package code.day7
import java.io.File
import kotlin.math.abs
fun main() {
doIt("Day 7 Part 1: Test Input", "src/code/day7/test.input", part1)
doIt("Day 7 Part 1: Real Input", "src/code/day7/part1.input", part1)
doIt("Day 7 Part 2: Test Input", "src/code/day7/test.input", part2);
doIt("Day 7 Part 2: Re... | 0 | Kotlin | 0 | 0 | ec8bcc6257a171afb2ff3a732704b3e7768483be | 1,887 | misc-dev | MIT License |
aoc2023/day17.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2023
import utils.InputRetrieval
import java.util.TreeSet
fun main() {
Day17.execute()
}
private object Day17 {
fun execute() {
INPUT = readInput()
println("Part 1: ${part1()}")
println("Part 2: ${part2()}")
}
private fun part1(): Int {
dijkstra { it.neigh... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 7,724 | Advent-Of-Code | MIT License |
advent-of-code2015/src/main/kotlin/day8/Advent8.kt | REDNBLACK | 128,669,137 | false | null | package day8
import parseInput
import splitToLines
/**
--- Day 8: Matchsticks ---
Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored.
It is common in many programming languages to provide a way to escape spe... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 3,723 | courses | MIT License |
src/Day08.kt | casslabath | 573,177,204 | false | {"Kotlin": 27085} | enum class Direction {UP, DOWN, LEFT, RIGHT}
fun main() {
fun treeVisibleInDir(grid: List<String>, x: Int, y: Int, treeHeight: Int, direction: Direction): Pair<Boolean, Int> {
when(direction) {
Direction.UP -> {
if(y-1 < 0) {
return true to 0
}... | 0 | Kotlin | 0 | 0 | 5f7305e45f41a6893b6e12c8d92db7607723425e | 3,185 | KotlinAdvent2022 | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2015/Day9.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2015
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.permutations
import com.chriswk.aoc.util.report
import org.apache.logging.log4j.LogManager
import kotlin.math.min
class Day9: AdventDay(2015, 9) {
companion object {
@JvmStatic
fun main(args: Array<Stri... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 2,558 | adventofcode | MIT License |
src/hard/_4MedianOfTwoSortedArrays.kt | ilinqh | 390,190,883 | false | {"Kotlin": 382147, "Java": 32712} | package hard
class _4MedianOfTwoSortedArrays {
class Solution {
fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {
val length1 = nums1.size
val length2 = nums2.size
val findNext = (length1 + length2) % 2 == 0
val middle = (length1 + length... | 0 | Kotlin | 0 | 0 | 8d2060888123915d2ef2ade293e5b12c66fb3a3f | 2,907 | AlgorithmsProject | Apache License 2.0 |
src/Day03.kt | ostersc | 570,327,086 | false | {"Kotlin": 9017} | fun main(){
fun part1(input: List<String>): Int {
//count the 0s in each column
val zeroSum=input.first().indices.map { charNum -> input.count{it[charNum]=='0'}}
//turn them into 0 or 1 based on being the majority
val digits=zeroSum.map { if(it <= input.size/2) '1' else '0' }
... | 0 | Kotlin | 0 | 0 | 836ff780252317ee28b289742396c74559dd2b6e | 1,871 | advent-of-code-2021 | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/FindMin.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
/**
* 154. 寻找旋转排序数组中的最小值 II
*
* 已知一个长度为 n 的数组,预先按照升序排列,经由 1 到 n 次 旋转 后,得到输入数组。例如,原数组 nums = [0,1,4,4,5,6,7] 在变化后可能得到:
* 若旋转 4 次,则可以得到 [4,5,6,7,0,1,4]
* 若旋转 7 次,则可以得到 [0,1,4,4,5,6,7]
* 注意,数组 [a[0], a[1], a[2], ..., a[n-1]] 旋转一次 的结果为数组 [a[n-1], a[0], a[1], a[2], ..., a[n-2]] 。
... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 2,255 | daily_algorithm | Apache License 2.0 |
src/Day03.kt | allisonjoycarter | 574,207,005 | false | {"Kotlin": 22303} |
fun main() {
fun part1(input: List<String>): Int {
val shared = arrayListOf<Char>()
input.forEach { line ->
val firstCompartmentItems = line.take(line.length / 2)
val secondCompartmentItems = line.takeLast(line.length / 2)
val commonItem = firstCompartmentItems.... | 0 | Kotlin | 0 | 0 | 86306ee6f4e90c1cab7c2743eb437fa86d4238e5 | 1,517 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2023/Day02.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
class Day02(input: List<String>) {
private data class Game(val id: Int, val colorSets: List<Colors>) {
fun isPossible(colors: Colors) = colorSets.all { it.red <= colors.red && it.green <= colors.green && it.blue <= colors.blue }
fun fewestColors() = Colors(colorSe... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 1,570 | advent-2023 | MIT License |
src/Day02.kt | Shykial | 572,927,053 | false | {"Kotlin": 29698} | fun main() {
fun part1(input: List<String>): Int = input
.map { it.cutExcluding(" ") }
.sumOf { calculateScore(Shape.forLetter(it.first), Shape.forLetter(it.second)) }
fun part2(input: List<String>) = input
.map { it.cutExcluding(" ") }
.map { Shape.forLetter(it.first) to Expect... | 0 | Kotlin | 0 | 0 | afa053c1753a58e2437f3fb019ad3532cb83b92e | 1,952 | advent-of-code-2022 | Apache License 2.0 |
facebook/y2020/round1/b.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2020.round1
private fun solve(): Int {
val (n, m, k, _) = readInts()
val (p, q) = listOf(n, m).map { size -> readInts().toMutableList().also { list ->
val (a, b, c, d) = readInts()
for (i in k until size) {
list.add(((a.toLong() * list[i - 2] + b.toLong() * list[i - 1] + c) % d + 1).toInt())... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,040 | competitions | The Unlicense |
src/main/kotlin/day15/Solution.kt | TestaDiRapa | 573,066,811 | false | {"Kotlin": 50405} | package day15
import java.io.File
import kotlin.math.abs
import kotlin.system.measureTimeMillis
fun manhattanDistance(x1: Long, y1: Long, x2: Long, y2: Long) = abs(x1-x2) + abs(y1-y2)
class LineScan(
initStart: Long,
initEnd: Long
) {
val start = minOf(initStart, initEnd)
val end = maxOf(initStart, i... | 0 | Kotlin | 0 | 0 | b5b7ebff71cf55fcc26192628738862b6918c879 | 3,975 | advent-of-code-2022 | MIT License |
src/main/kotlin/aoc2017/FractalArt.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2017
import komu.adventofcode.utils.nonEmptyLines
fun fractalArt(input: String, iterations: Int): Int {
val rules = RuleBook.parse(input)
var block = Block(listOf(".#.", "..#", "###"))
repeat(iterations) {
block = block.enhance(rules)
}
return block.pixelsOn... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 3,809 | advent-of-code | MIT License |
src/Day03.kt | iartemiev | 573,038,071 | false | {"Kotlin": 21075} | const val UpperNormalize = 38
const val LowerNormalize = 96
fun main() {
fun findCommonChar(input1: String, input2: String): Char {
val charSet: Set<Char> = input1.toCharArray().toSet()
return input2.find { charSet.contains(it) } ?: throw IllegalStateException("Invalid State")
}
fun findCommonChar(input... | 0 | Kotlin | 0 | 0 | 8d2b7a974c2736903a9def65282be91fbb104ffd | 1,535 | advent-of-code | Apache License 2.0 |
src/Day02.kt | rmyhal | 573,210,876 | false | {"Kotlin": 17741} | import java.util.stream.Collectors
import kotlin.IllegalArgumentException
fun main() {
fun part1(input: List<String>): Long {
return regularGame(input)
}
fun part2(input: List<String>): Long {
return strategyGame(input)
}
val input = readInput("Day02")
println(part1(input))
println(part2(input)... | 0 | Kotlin | 0 | 0 | e08b65e632ace32b494716c7908ad4a0f5c6d7ef | 2,483 | AoC22 | Apache License 2.0 |
src/day5/Day.kt | helbaroudy | 573,339,882 | false | null | package day5
import readInput
fun parseInput(input: List<String>): Pair<MutableList<String>, MutableList<Movement>> {
val instructions = mutableListOf<Movement>()
val stacks = MutableList((input[0].length + 1) / 4) { "" }
for (entry in input) {
if (entry.isNotEmpty() && !entry.startsWith("move")) ... | 0 | Kotlin | 0 | 0 | e9b98fc0eda739048e68f4e5472068d76ee50e89 | 3,042 | aoc22 | Apache License 2.0 |
src/Day04.kt | mkfsn | 573,042,358 | false | {"Kotlin": 29625} | fun main() {
fun IntRange.covers(other: IntRange): Boolean =
this.first <= other.first && this.last >= other.last
fun IntRange.overlaps(other: IntRange): Boolean =
other.contains(this.first) || other.contains(this.last)
fun pairToRange(pair: String): IntRange {
val (x, y) = pair.sp... | 0 | Kotlin | 0 | 1 | 8c7bdd66f8550a82030127aa36c2a6a4262592cd | 1,163 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day10.kt | djleeds | 572,720,298 | false | {"Kotlin": 43505} | sealed class Instruction(val cycles: Int, val operation: (previousX: Int) -> Int) {
class NoOp : Instruction(1, { it })
class AddX(private val amount: Int) : Instruction(2, { it + amount })
companion object {
fun parse(line: String) = when {
line == "noop" -> NoOp()
... | 0 | Kotlin | 0 | 4 | 98946a517c5ab8cbb337439565f9eb35e0ce1c72 | 2,131 | advent-of-code-in-kotlin-2022 | Apache License 2.0 |
src/Day02.kt | kedvinas | 572,850,757 | false | {"Kotlin": 15366} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf {
val (a, b) = it.split(" ")
val score: Int = when (a) {
"A" -> when (b) {
"X" -> 1 + 3
"Y" -> 2 + 6
else -> 3 + 0
}
... | 0 | Kotlin | 0 | 0 | 04437e66eef8cf9388fd1aaea3c442dcb02ddb9e | 1,561 | adventofcode2022 | Apache License 2.0 |
src/Day18.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | fun main() {
data class Point(val x: Long, val y: Long)
fun solve(dirs: List<Pair<Char, Long>>): Long {
var perimeter = 0L
val points = run {
val res = ArrayDeque<Point>()
res.add(Point(0,0))
for (dir in dirs) {
val cur = res.last()
... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 1,312 | advent-of-code-kotlin | Apache License 2.0 |
archive/2022/Day08.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | import kotlin.streams.toList
private const val EXPECTED_1 = 21
private const val EXPECTED_2 = 8
private inline fun <T> List<List<Int>>.map (action: (Int, Int, Int) -> T): List<T> {
val result = mutableListOf<T>()
for ((y, row) in this.withIndex()) {
for ((x, value) in row.withIndex()) {
re... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 2,368 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc23/Day15.kt | tahlers | 725,424,936 | false | {"Kotlin": 65626} | package aoc23
object Day15 {
data class Lens(val label: String, val focalLength: Int)
sealed class Operator(open val name: String) {
val box: Int
get() = hash(name)
data class Dash(override val name: String) : Operator(name)
data class Equal(override val name: String, val... | 0 | Kotlin | 0 | 0 | 0cd9676a7d1fec01858ede1ab0adf254d17380b0 | 2,375 | advent-of-code-23 | Apache License 2.0 |
src/Day02.kt | achugr | 573,234,224 | false | null | fun main() {
fun part1(input: List<String>): Int {
return input.map {
it.split(" ").map { str ->
when (str) {
"A", "X" -> 1
"B", "Y" -> 2
"C", "Z" -> 3
else -> throw IllegalArgumentException("Unsup... | 0 | Kotlin | 0 | 0 | d91bda244d7025488bff9fc51ca2653eb6a467ee | 1,792 | advent-of-code-kotlin-2022 | Apache License 2.0 |
day6/src/main/kotlin/com/lillicoder/adventofcode2023/day6/Day6.kt | lillicoder | 731,776,788 | false | {"Kotlin": 98872} | package com.lillicoder.adventofcode2023.day6
fun main() {
val day6 = Day6()
val races = RaceParser().parseFile("input.txt")
println("Total possible winning permutations is ${day6.part1(races)}.")
println("Total possible winning permutations as one race is ${day6.part2(races)}.")
}
class Day6 {
fun... | 0 | Kotlin | 0 | 0 | 390f804a3da7e9d2e5747ef29299a6ad42c8d877 | 3,802 | advent-of-code-2023 | Apache License 2.0 |
src/Day07.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import java.util.*
data class Directory(var totalSize: Long = 0, val children: MutableMap<String, Directory> = mutableMapOf())
fun buildFolder(commands: List<String>): Map<String, Long> {
val root = Directory()
val path = Stack<Directory>()
var currentDirectory = root
for (line in commands) {
... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 2,200 | Advent-Of-Code-2022 | Apache License 2.0 |
src/Day03.kt | sk0g | 572,854,602 | false | {"Kotlin": 7597} | fun findCommonItem(s: String): Char {
val (firstHalf, secondHalf) = s.chunked(s.length / 2)
return firstHalf.toHashSet()
.intersect(secondHalf.toHashSet())
.first()
}
fun Char.getPriority(): Int =
if (this.isUpperCase()) {
this.code + 27 - 'A'.code
} else {
this.code + 1... | 0 | Kotlin | 0 | 0 | cd7e0da85f71d40bc7e3761f16ecfdce8164dae6 | 2,040 | advent-of-code-22 | Apache License 2.0 |
src/Day04.kt | qmchenry | 572,682,663 | false | {"Kotlin": 22260} | fun main() {
fun rangeToSet(range: String): Set<Int> {
val (from, to) = range.split("-").map { it.toInt() }
return (from..to).toSet()
}
fun rangePairs(pair: String): Pair<Set<Int>, Set<Int>> {
val (left, right) = pair.split(",")
return Pair(rangeToSet(left), rangeToSet(righ... | 0 | Kotlin | 0 | 0 | 2813db929801bcb117445d8c72398e4424706241 | 1,290 | aoc-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/day2/Day2.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day2
import days.Day
class Day2: Day(false) {
override fun partOne(): Any {
val games = readInput().map{
val id = it.substringBefore(":").substringAfter(" ").toInt()
val values = it.substringAfter(": ").replace(";",",").split(", ").map{ it ->
val color... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 2,202 | advent-of-code_2023 | The Unlicense |
src/year2015/day06/Day06.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2015.day06
import readInput
fun main() {
val input = readInput("2015", "Day06")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
val grid = Array(1000) { Array(1000) { false } }
input.executeActionsOnGrid(grid) { action, value ->
when... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 1,809 | AdventOfCode | Apache License 2.0 |
app/src/main/kotlin/day07/Day07.kt | W3D3 | 433,748,408 | false | {"Kotlin": 72893} | package day07
import common.InputRepo
import common.readSessionCookie
import common.solve
import java.util.Collections.max
import java.util.Collections.min
import kotlin.math.abs
fun main(args: Array<String>) {
val day = 7
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, :... | 0 | Kotlin | 0 | 0 | df4f21cd99838150e703bcd0ffa4f8b5532c7b8c | 1,911 | AdventOfCode2021 | Apache License 2.0 |
src/day12/Day12.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day12
import Runner
import java.util.*
import kotlin.collections.HashSet
fun main() {
Day12Runner().solve()
}
class Day12Runner : Runner<Int>(
day = 12,
expectedPartOneTestAnswer = 31,
expectedPartTwoTestAnswer = 29
) {
override fun partOne(input: List<String>, test: Boolean): Int {
... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 3,362 | advent-of-code | Apache License 2.0 |
src/day09/day09.kt | LostMekka | 574,697,945 | false | {"Kotlin": 92218} | package day09
import util.Direction2NonDiagonal
import util.Direction2NonDiagonal.*
import util.Point
import util.plus
import util.readInput
import util.shouldBe
import kotlin.math.abs
import kotlin.math.sign
fun main() {
val day = 9
val testInput = readInput(day, testInput = true).parseInput()
part1(test... | 0 | Kotlin | 0 | 0 | 58d92387825cf6b3d6b7567a9e6578684963b578 | 1,940 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | mjossdev | 574,439,750 | false | {"Kotlin": 81859} | fun main() {
fun Char.getPriority(): Int = if (isLowerCase()) {
1 + (this - 'a')
} else {
27 + (this - 'A')
}
data class Rucksack(val compartment1: Set<Char>, val compartment2: Set<Char>) {
fun commonItem(): Char = compartment1.intersect(compartment2).single()
fun allIt... | 0 | Kotlin | 0 | 0 | afbcec6a05b8df34ebd8543ac04394baa10216f0 | 1,263 | advent-of-code-22 | Apache License 2.0 |
src/day12/Day12.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day12
import java.io.File
fun main() {
val data = parse("src/day12/Day12.txt")
println("🎄 Day 12 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)}")
}
private data class Row(
val springs... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 2,147 | advent-of-code-2023 | MIT License |
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day06.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2018.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.Point
class Day06 : Day(title = "Chronal Coordinates") {
companion object Configuration {
private const val MAX_DISTANCE_SUM = 10000
}
override fun first(inpu... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 3,098 | AdventOfCode | MIT License |
src/Day06.kt | FuKe | 433,722,611 | false | {"Kotlin": 19825} | fun main() {
test()
val puzzleInput: List<Int> = readInput("Day06.txt")[0]
.split(",")
.map { it.toInt() }
val partOneResult: Int = partOne(puzzleInput)
println("Part one result: $partOneResult")
val partTwoResult: Long = partTwo(puzzleInput)
println("Part two result: $partTw... | 0 | Kotlin | 0 | 0 | 1cfe66aedd83ea7df8a2bc26c453df257f349b0e | 1,868 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/day16/Day16.kt | Avataw | 572,709,044 | false | {"Kotlin": 99761} | package day16
import kotlin.math.ceil
fun solveA(input: List<String>): Int {
val valves = input.map(String::parseValve)
// valves.forEach { println(it) }
valves.calculateShortestPaths()
//
// valves.forEach {
// println("${it.name} : ${it.shortestPathTo.map { it.key.name to it.value }}")
// ... | 0 | Kotlin | 2 | 0 | 769c4bf06ee5b9ad3220e92067d617f07519d2b7 | 4,699 | advent-of-code-2022 | Apache License 2.0 |
src/Day11.kt | tomoki1207 | 572,815,543 | false | {"Kotlin": 28654} | import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
data class Monkey(val specs: List<String>) {
private val engine: ScriptEngine = ScriptEngineManager().getEngineByExtension("js")
val no: Int = "\\d+".toRegex().find(specs[0])!!.value.toInt()
val items: MutableList<Int> = specs[1].subs... | 0 | Kotlin | 0 | 0 | 2ecd45f48d9d2504874f7ff40d7c21975bc074ec | 2,527 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day04.kt | raneric | 573,109,642 | false | {"Kotlin": 13043} | fun main() {
fun part1(input: List<String>): Int {
return input.map { it.checkIfBetween() }.sum()
}
fun part2(input: List<String>): Int {
return input.map { it.checkIfOverlapp() }.sum()
}
val input = readInput("Day04")
println(part1(input))
println(part2(input))
}
fun Stri... | 0 | Kotlin | 0 | 0 | 9558d561b67b5df77c725bba7e0b33652c802d41 | 1,247 | aoc-kotlin-challenge | Apache License 2.0 |
src/main/kotlin/sk/mkiss/algorithms/dynamic/LongestIncreasingSubsequence.kt | marek-kiss | 430,858,906 | false | {"Kotlin": 85343} | package sk.mkiss.algorithms.dynamic
import kotlin.math.max
object LongestIncreasingSubsequence {
/**
* get the size of the longest increasing subsequence of the given sequence
* time complexity: Θ(n^2)
*
* @param sequence
* @return
*/
fun getSizeOfLIS(sequence: List<Int>): Int {... | 0 | Kotlin | 0 | 0 | 296cbd2e04a397597db223a5721b6c5722eb0c60 | 3,320 | algo-in-kotlin | MIT License |
src/Day03.kt | juliantoledo | 570,579,626 | false | {"Kotlin": 34375} | fun main() {
/*
A for Rock, B for Paper, and C for Scissors
X for Rock, Y for Paper, and Z for Scissors
1 for Rock, 2 for Paper, and 3 for Scissors) plus the score for the outcome of the round
(0 if you lost, 3 if the round was a draw, and 6 if you won).
X means you need to lose, Y means you need to end the round in ... | 0 | Kotlin | 0 | 0 | 0b9af1c79b4ef14c64e9a949508af53358335f43 | 2,162 | advent-of-code-kotlin-2022 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2023/Day7.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.resultFrom
/**
* --- Day 7: Camel Cards ---
* https://adventofcode.com/2023/day/7
*/
class Day7 : Solver {
override fun solve(lines: List<String>): Result {
return resultFrom(
CardScorer(false).cardSc... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 3,204 | euler | Apache License 2.0 |
src/main/kotlin/Day6.kt | cbrentharris | 712,962,396 | false | {"Kotlin": 171464} | import kotlin.String
import kotlin.collections.List
import kotlin.math.*
object Day6 {
fun part1(input: List<String>): String {
val parseNumbers: (String, String) -> List<Int> = { str: String, prefix: String ->
str.replace(prefix, "")
.trim()
.split("\\s+".toRege... | 0 | Kotlin | 0 | 1 | f689f8bbbf1a63fecf66e5e03b382becac5d0025 | 2,178 | kotlin-kringle | Apache License 2.0 |
src/Day03.kt | pavlo-dh | 572,882,309 | false | {"Kotlin": 39999} | fun main() {
fun List<Char>.sumPriorities() = this.sumOf { type ->
if (type.isLowerCase()) type - 'a' + 1
else type - 'A' + 27
}
fun part1(input: List<String>): Int {
val rucksacksCompartments = input.map { line ->
val middleIndex = line.length / 2
line.subst... | 0 | Kotlin | 0 | 2 | c10b0e1ce2c7c04fbb1ad34cbada104e3b99c992 | 1,188 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day08.kt | SimonMarquis | 570,868,366 | false | {"Kotlin": 50263} | class Day08(input: List<String>) {
private val forest = Forest(input)
fun part1() = with(forest) {
walk().count { it.isVisible() }
}
fun part2() = with(forest) {
walk().maxOf { it.scenicScore() }
}
}
private typealias Tree = Pair<Int, Int>
private class Forest(input: List<Strin... | 0 | Kotlin | 0 | 0 | a2129cc558c610dfe338594d9f05df6501dff5e6 | 1,652 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/jaspervanmerle/aoc2020/day/Day16.kt | jmerle | 317,518,472 | false | null | package com.jaspervanmerle.aoc2020.day
class Day16 : Day("30869", "4381476149273") {
private val inputParts = getInput().split("\n\n")
private val rangesByField = inputParts[0]
.lines()
.map { it.split(": ") }
.fold(mutableMapOf<String, List<IntRange>>()) { acc, lineParts ->
... | 0 | Kotlin | 0 | 0 | 81765a46df89533842162f3bfc90f25511b4913e | 2,280 | advent-of-code-2020 | MIT License |
kotlin/src/2022/Day11_2022.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | private val itemsRegex = Regex(".*items: (.*)")
private val opRegex = Regex("Operation: new = ([a-z0-9]+) ([+-/*]) ([a-z0-9]+)")
private val testRegex = Regex(".*divisible by (\\d+)")
private val decRegex = Regex(".*throw to monkey (\\d+)")
class Monkey(lines: List<String>) {
var items: MutableList<Long>
val o... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 2,958 | adventofcode | Apache License 2.0 |
src/Day07.kt | KarinaCher | 572,657,240 | false | {"Kotlin": 21749} | fun main() {
val MOST_SIZE = 100000
val TOTAL_SPACE = 70000000
val REQUIRED_FREE_SPACE = 30_000_000
fun changeDir(currentDir: Dir, command: List<String>, rootDir: Dir): Dir {
val dirName = command[2]
return when (dirName) {
"/" -> rootDir
".." -> currentDir.pare... | 0 | Kotlin | 0 | 0 | 17d5fc87e1bcb2a65764067610778141110284b6 | 4,482 | KotlinAdvent | Apache License 2.0 |
src/main/kotlin/days/Day9Data.kt | yigitozgumus | 572,855,908 | false | {"Kotlin": 26037} | package days
import utils.SolutionData
fun main() = with(Day9Data()) {
solvePart1()
solvePart2()
}
data class Vector(val x: Int = 0, val y: Int = 0) {
operator fun plus(v: Vector): Vector = Vector(this.x + v.x, this.y + v.y)
operator fun minus(v: Vector): Vector = Vector(this.x - v.x, this.y - v.y)
}... | 0 | Kotlin | 0 | 0 | 9a3654b6d1d455aed49d018d9aa02d37c57c8946 | 2,309 | AdventOfCode2022 | MIT License |
y2015/src/main/kotlin/adventofcode/y2015/Day06.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2015
import adventofcode.io.AdventSolution
import adventofcode.y2015.Day06.Action.*
object Day06 : AdventSolution(2015, 6, "Probably a Fire Hazard") {
override fun solvePartOne(input: String): Int =
execute(parse(input)) { v, a ->
when (a) {
O... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,967 | advent-of-code | MIT License |
src/Day14.kt | simonbirt | 574,137,905 | false | {"Kotlin": 45762} |
fun main() {
Day14.printSolutionIfTest(24,93)
}
object Day14: Day<Int, Int>(14) {
data class Point(val x:Int, val y:Int)
override fun part1(lines: List<String>, ) = countSand(lines, false)
override fun part2(lines: List<String>, ) = countSand(lines, true)
fun countSand(lines: List<String>, floor:... | 0 | Kotlin | 0 | 0 | 962eccac0ab5fc11c86396fc5427e9a30c7cd5fd | 1,887 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day18.kt | sicruse | 315,469,617 | false | null | package days
import java.util.*
fun Int.exclusiveRangeTo(other: Int): IntRange = IntRange(this + 1, other - 1)
class Day18 : Day(18) {
private val problems: List<Problem> by lazy {
inputList.map { problemText -> Problem(problemText) }
}
class Problem(private val expression: String) {
e... | 0 | Kotlin | 0 | 0 | 9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f | 3,272 | aoc-kotlin-2020 | Creative Commons Zero v1.0 Universal |
src/com/kingsleyadio/adventofcode/y2021/day17/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2021.day17
import com.kingsleyadio.adventofcode.util.readInput
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun part1(yRange: List<Int>): Int {
val (y1, y2) = yRange.map { y -> if (y >= 0) y else y.inv() }
val max = max(y1, y2)
return max * (m... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,374 | adventofcode | Apache License 2.0 |
gcj/y2022/round3/b_small.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package gcj.y2022.round3
private fun solve(): Long {
val (n, colors) = readInts()
val constraints = List(colors) { readInts() }
val hats = readInts().map { it - 1 }
val byColor = List(colors) { mutableListOf<Int>() }
val indexInColor = IntArray(colors)
for (i in hats.indices) {
byColor[hats[i]].add(i)
}
val ... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,797 | competitions | The Unlicense |
src/day4/Day4.kt | bartoszm | 572,719,007 | false | {"Kotlin": 39186} | package day4
import readInput
import toPair
fun main() {
val testInput = parse(readInput("day04/test"))
val input = parse(readInput("day04/input"))
println(solve1(testInput))
println(solve1(input))
println(solve2(testInput))
println(solve2(input))
}
fun solve1(input: List<Pair<IntRange, Int... | 0 | Kotlin | 0 | 0 | f1ac6838de23beb71a5636976d6c157a5be344ac | 1,158 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode/year2023/Day03GearRatios.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2023
import adventofcode.Puzzle
import adventofcode.PuzzleInput
import adventofcode.common.neighbors
import adventofcode.common.product
class Day03GearRatios(customInput: PuzzleInput? = null) : Puzzle(customInput) {
override fun partOne() = input
.parsePartNumbers()
.filte... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 2,311 | AdventOfCode | MIT License |
02/src/commonMain/kotlin/Main.kt | daphil19 | 725,415,769 | false | {"Kotlin": 131380} | expect fun getLines(inputOrPath: String): List<String>
fun main() {
val lines = getLines(INPUT_FILE)
// val lines = ("Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green\n" +
// "Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue\n" +
// "Game 3: 8 green, 6 blue, 20 red; 5... | 0 | Kotlin | 0 | 0 | 70646b330cc1cea4828a10a6bb825212e2f0fb18 | 2,734 | advent-of-code-2023 | Apache License 2.0 |
src/Day10.kt | hoppjan | 433,705,171 | false | {"Kotlin": 29015, "Shell": 338} | fun main() {
fun part1(input: List<String>) =
input.sumOf { line ->
line.lineScore()
}
fun part2(input: List<String>) =
input.filterNotCorrupted()
.map { it.completionScore() }
.median()
val day = "10"
val testInput = StringInputReader.read(... | 0 | Kotlin | 0 | 0 | 04f10e8add373884083af2a6de91e9776f9f17b8 | 2,434 | advent-of-code-2021 | Apache License 2.0 |
src/year2022/day21/Day21.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day21
import readInputFileByYearAndDay
import readTestFileByYearAndDay
import kotlin.math.abs
fun String.containsAny(of: List<String>): Boolean {
for (keyword in of)
if (this.contains(keyword, true)) return true
return false
}
fun main() {
fun resolvePart1(monkey: String, monkey... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 3,611 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2021/Day10.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2021
import readInput
import java.util.*
/**
* A character in a chunk.
* @property open the open symbol
* @property close the close symbol
* @property corruptScore the score this character gives, if it is the one corrupting the chunk
* @property missingScore the amount this character adds to the score... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,136 | adventOfCode | Apache License 2.0 |
src/Day20.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Long {
val numbers = input.mapIndexed { index, s -> Number(index, s.toLong()) }
val file = GroveCoordinateFile(numbers.toMutableList())
file.mix()
return file.sumGroveCoordinates()
}
fun part2(input: List<String>): Long... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 1,758 | aoc2022 | Apache License 2.0 |
src/Day02.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0
for (s in input) {
val (first, second) = s.split(" ")
val elf = first.first() - 'A' + 1
val me = second.first() - 'X' + 1
if (elf == 1 && me == 3) sum += 0
else if (elf == 3 && ... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 1,337 | AoC-2022 | Apache License 2.0 |
2022/Day13.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | private sealed interface Elem : Comparable<Elem> {
data class EInt(val v: Int) : Elem {
override fun toString() = v.toString()
}
data class EList(val lst: List<Elem>) : Elem {
override fun toString() = "[${lst.joinToString(",")}]"
}
override fun compareTo(other: Elem): Int {
... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 2,564 | advent-of-code-kotlin | Apache License 2.0 |
src/Day02.kt | paul-griffith | 572,667,991 | false | {"Kotlin": 17620} | import Outcome.Draw
import Outcome.Lose
import Outcome.Win
import Hand.Paper
import Hand.Rock
import Hand.Scissors
private enum class Hand(val score: Int) {
Rock(1),
Paper(2),
Scissors(3);
companion object {
fun fromChar(char: Char) = when (char) {
'A', 'X' -> Rock
'B',... | 0 | Kotlin | 0 | 0 | 100a50e280e383b784c3edcf65b74935a92fdfa6 | 3,033 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | ThijsBoehme | 572,628,902 | false | {"Kotlin": 16547} | fun main() {
fun scoreOfShape(shape: String): Int =
when (shape) {
"A", "X" -> 1
"B", "Y" -> 2
"C", "Z" -> 3
else -> error("Unknown shape")
}
fun scoreOfOutcome(outcome: String): Int =
when (outcome) {
"X" -> 0
"Y" ... | 0 | Kotlin | 0 | 0 | 707e96ec77972145fd050f5c6de352cb92c55937 | 1,532 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day02/Day02.kt | AllePilli | 572,859,920 | false | {"Kotlin": 47397} | package Day02
import checkAndPrint
import measureAndPrintTimeMillis
import readInput
fun main() {
fun prepareInput(input: List<String>) = input.map { line ->
line.split(" ").map(String::first)
}
fun part1(input: List<List<Char>>) = input.sumOf { (opponent, player) ->
matchScore(player.toH... | 0 | Kotlin | 0 | 0 | 614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643 | 1,863 | AdventOfCode2022 | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day15/day15.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2023.day15
import eu.janvdb.aocutil.kotlin.readLines
import kotlin.streams.asSequence
//const val FILENAME = "input15-test.txt"
const val FILENAME = "input15.txt"
fun main() {
val instructions = readLines(2023, FILENAME)[0].split(",")
part1(instructions)
part2(instructions)
}
privat... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,746 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day12/Day12.kt | Avataw | 572,709,044 | false | {"Kotlin": 99761} | package day12
import java.util.*
fun solveA(input: List<String>): Int {
val heightMap = createHeightMap(input).also { it.initialize() }
val start = heightMap.values.find { it.start } ?: throw Exception("No start exists!")
val end = heightMap.values.find { it.end } ?: throw Exception("No end exists!")
... | 0 | Kotlin | 2 | 0 | 769c4bf06ee5b9ad3220e92067d617f07519d2b7 | 5,954 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/net/wrony/aoc2023/a1/Main.kt | kopernic-pl | 727,133,267 | false | {"Kotlin": 52043} | package net.wrony.aoc2023.a1
import arrow.core.flatten
import kotlin.io.path.Path
import kotlin.io.path.readText
fun solution1a(input: String): Int {
val lines = arrayListOf<Int>()
fun findFirstDigit(s: String): Int = s.first { it.isDigit() }.digitToInt()
fun findLastDigit(s: String): Int = s.last { it.... | 0 | Kotlin | 0 | 0 | 1719de979ac3e8862264ac105eb038a51aa0ddfb | 1,530 | aoc-2023-kotlin | MIT License |
src/Day05.kt | peterfortuin | 573,120,586 | false | {"Kotlin": 22151} | import java.util.*
data class MoveInstruction(val amount: Int, val from: Int, val to: Int)
fun main() {
fun parseInput(input: List<String>): Pair<List<Stack<Char>>, List<MoveInstruction>> {
val stacks = listOf(
Stack<Char>(),
Stack<Char>(),
Stack<Char>(),
St... | 0 | Kotlin | 0 | 0 | c92a8260e0b124e4da55ac6622d4fe80138c5e64 | 3,234 | advent-of-code-2022 | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2020/Day24.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2020
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import com.s13g.aoc.XY
import com.s13g.aoc.addTo
/**
* --- Day 24: Lobby Layout ---
* https://adventofcode.com/2020/day/24
*/
class Day24 : Solver {
// Ordered from shortest to longest key!
private val directions = mapOf(
... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,689 | euler | Apache License 2.0 |
src/day_02/Day02.kt | BrumelisMartins | 572,847,918 | false | {"Kotlin": 32376} | package day_02
import readInput
fun main() {
fun getMatchScore(elfGesture: Gesture, myGesture: Gesture): Int {
return if (myGesture.betterThan == elfGesture.id) {
6
} else if (myGesture == elfGesture) {
3
} else {
0
}
}
fun getTotalScore... | 0 | Kotlin | 0 | 0 | 3391b6df8f61d72272f07b89819c5b1c21d7806f | 1,906 | aoc-2022 | Apache License 2.0 |
src/Day07/Day07.kt | Trisiss | 573,815,785 | false | {"Kotlin": 16486} | fun main() {
fun populateSizes(lines: List<String>): Map<String, Int> = buildMap {
put("", 0)
var cwd = ""
for (line in lines) {
val match = PATTERN.matchEntire(line) ?: continue
match.groups[1]?.value?.let { dir ->
cwd = when (dir) {
... | 0 | Kotlin | 0 | 0 | cb81a0b8d3aa81a3f47b62962812f25ba34b57db | 1,607 | AOC-2022 | Apache License 2.0 |
src/main/kotlin/08-aug.kt | aladine | 276,334,792 | false | {"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511} |
class Solution08Aug {
private var ans = 0
private fun pathSumHelper(root: TreeNode, sum: Int, s: MutableMap<Int,Int>){
val v = root.`val`
val newS = mutableMapOf<Int,Int>()
s.forEach {
newS[it.key+v] = it.value
}
newS[v] = newS.getOrDefault(v, 0)+ 1
... | 0 | C++ | 1 | 1 | 54b7f625f6c4828a72629068d78204514937b2a9 | 2,683 | awesome-leetcode | Apache License 2.0 |
src/year_2022/day_21/Day21.kt | scottschmitz | 572,656,097 | false | {"Kotlin": 240069} | package year_2022.day_21
import readInput
enum class Operation {
PLUS,
MINUS,
MULTIPLY,
DIVIDE,
;
companion object {
fun from(char: Char): Operation {
return when (char) {
'+' -> PLUS
'-' -> MINUS
'*' -> MULTIPLY
... | 0 | Kotlin | 0 | 0 | 70efc56e68771aa98eea6920eb35c8c17d0fc7ac | 7,894 | advent_of_code | Apache License 2.0 |
src/day03/Day03.kt | violabs | 576,367,139 | false | {"Kotlin": 10620} | package day03
import readInput
fun main() {
test1("day-03-test-input-01", 157)
test2("day-03-test-input-01", 70)
}
private fun test1(filename: String, expected: Int) {
val input = readInput("day03/$filename")
val actual: Int = checkRucksacksForDuplicateItems(input)
println("EXPECT: $expected")
... | 0 | Kotlin | 0 | 0 | be3d6bb2aef1ebd44bbd8e62d3194c608a5b3cc1 | 2,052 | AOC-2022 | Apache License 2.0 |
src/Day04.kt | Oli2861 | 572,895,182 | false | {"Kotlin": 16729} | fun getPairs(lines: List<String>): List<Pair<IntRange, IntRange>> = lines.map { getPairs(it) }
fun getPairs(line: String): Pair<IntRange, IntRange> {
val numbers: List<Int> = line.split(Regex("[^0-9]+")).map { Integer.parseInt(it) }
return Pair(IntRange(numbers[0], numbers[1]), IntRange(numbers[2], numbers[3])... | 0 | Kotlin | 0 | 0 | 138b79001245ec221d8df2a6db0aaeb131725af2 | 1,666 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/twentytwentytwo/Day16.kt | JanGroot | 317,476,637 | false | {"Kotlin": 80906} | package twentytwentytwo
import java.lang.Integer.max
import java.math.BigInteger
fun main() {
val input = {}.javaClass.getResource("input-16.txt")!!.readText().linesFiltered { it.isNotEmpty() };
val testInput = {}.javaClass.getResource("input-16-1.txt")!!.readText().linesFiltered { it.isNotEmpty() };
val ... | 0 | Kotlin | 0 | 0 | 04a9531285e22cc81e6478dc89708bcf6407910b | 2,700 | aoc202xkotlin | The Unlicense |
src/test/kotlin/de/tek/adventofcode/y2022/util/algorithms/SetAlgorithmsTest.kt | Thumas | 576,671,911 | false | {"Kotlin": 192328} | package de.tek.adventofcode.y2022.util.algorithms
import io.kotest.core.spec.style.StringSpec
import io.kotest.data.forAll
import io.kotest.data.row
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
class SubsetsTest : StringSpec({
"Given set of integers, combinations returns all subsets." {
... | 0 | Kotlin | 0 | 0 | 551069a21a45690c80c8d96bce3bb095b5982bf0 | 3,727 | advent-of-code-2022 | Apache License 2.0 |
2023/src/main/kotlin/day22.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Cuboid
import utils.MutableIntSpace
import utils.Parser
import utils.Point3i
import utils.Solution
import utils.Vec4i
import utils.bounds
import utils.cut
import utils.map
import utils.mapItems
fun main() {
Day22.run()
}
object Day22 : Solution<List<Cuboid>>() {
override val name = "day22"
override... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 2,707 | aoc_kotlin | MIT License |
src/Day02.kt | haraldsperre | 572,671,018 | false | {"Kotlin": 17302} | enum class Hand(val value: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3)
}
fun Hand.beats(): Hand {
return when (this) {
Hand.ROCK -> Hand.SCISSORS
Hand.PAPER -> Hand.ROCK
Hand.SCISSORS -> Hand.PAPER
}
}
fun Hand.beatenBy(): Hand {
return when (this) {
Hand.ROCK -> Hand... | 0 | Kotlin | 0 | 0 | c4224fd73a52a2c9b218556c169c129cf21ea415 | 1,706 | advent-of-code-2022 | Apache License 2.0 |
src/day07/Day07.kt | commanderpepper | 574,647,779 | false | {"Kotlin": 44999} | package day07
import readInput
fun main(){
val fileSystem = readInput("day07")
val directory = parseFileSystem(Directory(name = "root"), fileSystem)
println(partOne(directory))
val totalSpace = 70000000
val unusedSpaceNeeded = 30000000
println(partTwo(directory, totalSpace, unusedSpaceNeede... | 0 | Kotlin | 0 | 0 | fef291c511408c1a6f34a24ed7070ceabc0894a1 | 3,166 | advent-of-code-kotlin-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.