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/AoC5.kt
Pi143
317,631,443
false
null
import java.io.File fun main() { //tests() println("Starting Day 5 A Test 1") calculateDay5PartA("Input/2020_Day5_A_Test1") println("Starting Day 5 A Real") calculateDay5PartA("Input/2020_Day5_A") println("Starting Day 5 B Test 1") calculateDay5PartB("Input/2020_Day5_A_Test1") println...
0
Kotlin
0
1
fa21b7f0bd284319e60f964a48a60e1611ccd2c3
2,078
AdventOfCode2020
MIT License
src/main/kotlin/y2022/day02/Day2.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2022.day02 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } enum class Option { ROCK, PAPER, SCISSOR } enum class Result { WIN, LOSS, DRAW } data class Match ( val myChoice: Option, val enemyChoice: Option...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
2,963
AdventOfCode
MIT License
src/main/kotlin/day13.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day13 : Solvable("13") { override fun solveA(input: List<String>): String { val (positions, foldInstrs) = getGridFolds(input) return doFold(positions.toSet(), foldInstrs.first()).size.toString() } override fun solveB(input: List<String>): String { val (positions, foldInstrs)...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,981
AdventOfCode
Creative Commons Zero v1.0 Universal
advent-of-code-2022/src/Day03.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { fun readInput(name: String) = readLines(name).asSequence() // Common function to solve both part one and two. // Time - O(N*M), Space - O(N*M) // where N - number of lines, M - number of chars in the lines fun Sequence<List<String>>.sumOfPriorities(): Int { // 1. Convert str...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
981
advent-of-code
Apache License 2.0
src/Day04.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
fun main() { fun getRanges(line: String): Pair<IntRange, IntRange>{ val nums = line.split(',', '-').map { Integer.parseInt(it) } return Pair((nums[0]..nums[1]), (nums[2]..nums[3])) } fun part1(input: List<String>): Int { var containCount: Int = 0 input.forEach { ...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
1,427
AoC2022
Apache License 2.0
src/main/kotlin/io/github/aarjavp/aoc/day14/Day14.kt
AarjavP
433,672,017
false
{"Kotlin": 73104}
package io.github.aarjavp.aoc.day14 import io.github.aarjavp.aoc.readFromClasspath class Day14 { data class Rule(val matchId: String, val addChar: Char) { init { check(matchId.length == 2) } val leftPair = "${matchId[0]}$addChar" val rightPair = "$addChar${matchId[1]}"...
0
Kotlin
0
0
3f5908fa4991f9b21bb7e3428a359b218fad2a35
2,802
advent-of-code-2021
MIT License
src/day04/day04.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day04 import util.readInput import util.shouldBe fun main() { val day = 4 val testInput = readInput(day, testInput = true).parseInput() part1(testInput) shouldBe 2 part2(testInput) shouldBe 4 val input = readInput(day).parseInput() println("output for part1: ${part1(input)}") prin...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
1,211
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2020/Day19.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 19 - Monster Messages * Problem Description: http://adventofcode.com/2020/day/19 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day19/ */ package com.ginsberg.advent2020 class Day19(input: List<String>) { privat...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
2,384
advent-2020-kotlin
Apache License 2.0
src/Day05.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
import java.util.* fun main() { fun part1(input: List<String>): String { val cargo = input.parse5() cargo.performOperations() return cargo.cratesOnTop.joinToString("") } fun part2(input: List<String>): String { val cargo = input.parse5() cargo.performOperations(true...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
1,919
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day06.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 6 - Chronal Coordinates * * Problem Description: http://adventofcode.com/2018/day/6 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day6/ */ package com.ginsberg.advent2018 class Day06(input: List<String>) { pri...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
1,631
advent-2018-kotlin
MIT License
src/Day04.kt
manuel-martos
574,260,226
false
{"Kotlin": 7235}
fun main() { println("part01 -> ${solveDay04Part01()}") println("part02 -> ${solveDay04Part02()}") } private fun solveDay04Part01() = solver { range1, range2 -> if ((range1.contains(range2.first) && range1.contains(range2.last)) || (range2.contains(range1.first) && range2.contains(range...
0
Kotlin
0
0
5836682fe0cd88b4feb9091d416af183f7f70317
1,005
advent-of-code-2022
Apache License 2.0
src/Day03.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
fun main() { fun Char.score(): Int { return when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> error("Invalid character: $this") } } fun part1(input: List<String>): Int { return input.map { case -> // S...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
1,041
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
purdyk
572,817,231
false
{"Kotlin": 19066}
fun main() { fun IntRange.contains(other: IntRange): Boolean { return other.first >= this.first && other.last <= this.last } fun IntRange.touches(other: IntRange): Boolean { return this.first <= other.first && this.last >= other.first } fun part1(input: List<String>): String { ...
0
Kotlin
0
0
02ac9118326b1deec7dcfbcc59db8c268d9df096
1,351
aoc2022
Apache License 2.0
src/day02/Day02.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day02 import readInput fun main() { val scoreMapPart1 = mapOf<Pair<String, String>, Int>( Pair("A", "X") to 4, Pair("A", "Y") to 8, Pair("A", "Z") to 3, Pair("B", "X") to 1, Pair("B", "Y") to 5, Pair("B", "Z") to 9, Pair("C", "X") to 7, Pa...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
1,358
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day14_extended_polymerization/ExtendedPolymerization.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day14_extended_polymerization import histogram.Histogram import histogram.count import histogram.histogramOf import histogram.mutableHistogramOf import util.extent import util.length /** * Chopping up strings and reassembling them is easy! A little parsing, a loop, * and done! Hopefully part two isn't like ...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,011
aoc-2021
MIT License
aoc-2023/src/main/kotlin/aoc/aoc5.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.getDayInput val testInput = """ seeds: 79 14 55 13 seed-to-soil map: 50 98 2 52 50 48 soil-to-fertilizer map: 0 15 37 37 52 2 39 0 15 fertilizer-to-water map: 49 53 8 0 11 42 42 0 7 57 7 4 water-to-light map: 88 18 7 18 25 70 light-to-temperat...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
5,125
advent-of-code
Apache License 2.0
src/main/kotlin/day16.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day16 import aoc.utils.findInts import aoc.utils.graphs.Node import aoc.utils.graphs.allNodes import aoc.utils.readInput import aoc.utils.splitOn import kotlin.math.max data class Valve(val name: String, val flow: Int) fun part1(): Int { val start = buildMap() val result = venture(allNodes(start), 30...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
4,357
adventOfCode2022
Apache License 2.0
2022/18/18.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
data class Point(var x: Int, var y: Int, var z: Int) { operator fun plus(o: Point): Point = Point(x+o.x, y+o.y, z+o.z) fun adjacent(): List<Point> = dirs.map { this+it }.toList() fun min(): Int = minOf(x, y, z) fun max(): Int = maxOf(x, y, z) } val dirs = listOf( Point(1, 0, 0), Point(0, 1, 0), Point(0, 0, 1), P...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
1,130
adventofcode
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day8.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser import nl.tiemenschut.aoc.lib.util.infiniterator data class Node(val id: String) { var left: Node? = null var right: Node? = null } data class Des...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
3,735
aoc-2023
The Unlicense
day5/day5_B.kts
jshap999
575,148,328
false
{"Kotlin": 19624, "Shell": 452, "Nim": 433, "JavaScript": 404}
#!/usr/bin/env kotlin import java.io.File data class Move(val count: Int, val fromIndex: Int, val toIndex: Int) if (args.size != 1) { println("Please provide the file containing the puzzle input.") } else { runCatching { val puzzleInput = readFile(args.first()) .splitInput() ...
0
Kotlin
0
0
1295c6dc1776b5e61bc774cd0d0649b0e31732f1
2,551
aoc2022
MIT License
src/Day06.kt
mlidal
572,869,919
false
{"Kotlin": 20582}
sealed class Entry(val name: String) { override fun toString(): String { return name } } class File(name: String, val size: Int) : Entry(name) { } class Directory(name: String, val parent: Directory? = null, val children: MutableList<Entry> = mutableListOf()) : Entry(name) { override fun toStr...
0
Kotlin
0
0
bea7801ed5398dcf86a82b633a011397a154a53d
4,054
AdventOfCode2022
Apache License 2.0
src/main/kotlin/adventofcode2022/solution/day_8.kt
dangerground
579,293,233
false
{"Kotlin": 51472}
package adventofcode2022.solution import adventofcode2022.util.readDay import kotlin.math.max fun main() { Day8("8").solve() } class Day8(private val num: String) { private val inputText = readDay(num) fun solve() { println("Day $num Solution") println("* Part 1: ${solution1()}") ...
0
Kotlin
0
0
f1094ba3ead165adaadce6cffd5f3e78d6505724
5,960
adventofcode-2022
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions50.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round0.BinaryTreeNode fun test50() { printlnResult(testCase(), 8) } /** * Questions 50: Given a binary tree and a sum number, find the count of paths that equals the sum */ private infix fun BinaryTreeNode<Int>.findPathCount(sum: Int): Int ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,634
Algorithm
Apache License 2.0
src/Day02.kt
timmiller17
577,546,596
false
{"Kotlin": 44667}
import NeededResult.* import Play.PAPER import Play.ROCK import Play.SCISSORS import kotlin.IllegalStateException fun main() { fun part1(input: List<String>): Int { return input.map { it.split(' ') } .sumOf { it.score() } } fun part2(input: List<String>): Int { return input.map...
0
Kotlin
0
0
b6d6b647c7bb0e6d9e5697c28d20e15bfa14406c
2,711
advent-of-code-2022
Apache License 2.0
src/Day04.kt
BenD10
572,786,132
false
{"Kotlin": 6791}
fun main() { fun part1(input: List<String>): Int { return input.map { it.split(",").map { it.split("-").let { (it.first().toInt()..it.last().toInt()) } }.let { ls -> if (ls.first().all { ls.last().contains(it) } ||...
0
Kotlin
0
0
e26cd35ef64fcedc4c6e40b97a63d7c1332bb61f
1,239
advent-of-code
Apache License 2.0
src/day13/day13.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day13 import day13.Package.Items import day13.Package.Value import readInput private fun parse(input: List<String>): List<Pair<Package, Package>> { val result = mutableListOf<Pair<Package, Package>>() var index = 0 while (index < input.size) { val first = parsePackage(input[index++]).secon...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
3,474
aoc-2022
Apache License 2.0
src/main/kotlin/com/sk/todo-revise/1235. Maximum Profit in Job Scheduling.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.`todo-revise` import java.util.* class Solution1235 { // TLE fun jobScheduling( startTime: IntArray, endTime: IntArray, profit: IntArray ): Int { val jobs = Array(startTime.size) { IntArray(3) } for (i in startTime.indices) { jobs[i][0] = startTime[i] ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
3,469
leetcode-kotlin
Apache License 2.0
src/Day07.kt
Kbzinho-66
572,299,619
false
{"Kotlin": 34500}
private fun addFile(map: MutableMap<String, Int>, cwd: String, size: Int) { // Se ele não existir no mapa ainda, inicializa ele map.putIfAbsent(cwd, 0) // Somar o tamanho passado tanto pros que já existiam quando os que foram inicializados agora map[cwd] = map[cwd]!! + size // Se aqui o cwd estiver...
0
Kotlin
0
0
e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b
2,689
advent_of_code_2022_kotlin
Apache License 2.0
advent-of-code-2021/src/code/day8/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day8 import java.io.File fun main() { doIt("Day 8 Part 1: Test Input", "src/code/day8/test.input", part1) doIt("Day 8 Part 1: Real Input", "src/code/day8/part1.input", part1) doIt("Day 8 Part 2: Test Input", "src/code/day8/test.input", part2); doIt("Day 8 Part 2: Real Input", "src/code/da...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
3,081
misc-dev
MIT License
src/main/kotlin/com/hopkins/aoc/day12/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day12 import java.io.File const val debug = true const val part = 2 /** Advent of Code 2023: Day 12 */ fun main() { val lines: List<String> = File("input/input12.txt").readLines() val lineInputs: List<LineInput> = lines.mapIndexed { index, line -> val max = if (pa...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
4,595
aoc2023
MIT License
2022/src/Day18.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src import java.util.* import kotlin.math.abs fun manhattanDistance(a: Triple<Int, Int, Int>, b: Triple<Int, Int, Int>): Int { return abs(a.first - b.first) + abs(a.second - b.second) + abs(a.third - b.third) } val directions = listOf( Triple(1, 0, 0), Triple(-1, 0, 0), Triple(0, 1, 0), T...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
1,953
AoC
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2022/Day13.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom import kotlin.math.min import kotlin.math.sign /** * --- Day 13: Distress Signal --- * https://adventofcode.com/2022/day/13 */ class Day13 : Solver { override fun solve(lines: List<String>): Result {...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,623
euler
Apache License 2.0
src/Day02.kt
afranken
572,923,112
false
{"Kotlin": 15538}
fun main() { fun part1(input: List<String>): Int { val scores: List<Int> = input.map { val shapeInput = it.split(" ") val theirShape = Shape.of(shapeInput[0]) val myShape = Shape.of(shapeInput[1]) myShape.score + myShape.outcomeAgainst(theirShape) ...
0
Kotlin
0
0
f047d34dc2a22286134dc4705b5a7c2558bad9e7
3,036
advent-of-code-kotlin-2022
Apache License 2.0
src/Day03.kt
sms-system
572,903,655
false
{"Kotlin": 4632}
fun main() { fun getItemPriority (item: String): Int = if (item.uppercase() == item) { item.first().toInt() - 38 } else { item.first().toInt() - 96 } fun part1(input: List<String>): Int = input .map { it.substring(0, it.length / 2).split("") .intersec...
0
Kotlin
0
0
266dd4e52f3b01912fbe2aa23d1ee70d1292827d
1,025
adventofcode-2022-kotlin
Apache License 2.0
2020/kotlin/src/main/kotlin/io/franmosteiro/aoc2020/Day07.kt
franmosteiro
433,734,642
false
{"Kotlin": 27170, "Ruby": 16611, "Shell": 389}
package io.franmosteiro.aoc2020 /** * Advent of Code 2020 - Day 7: Handy Haversacks - * Problem Description: http://adventofcode.com/2020/day/7 */ class Day07(input: List<String>) { private val allBags: List<Bag> private val MY_BAG = "shiny gold" companion object { private val bagPattern = """...
0
Kotlin
0
0
dad555d9cd0c3060c4b1353c7c6f170aa340c285
1,775
advent-of-code
MIT License
src/Day04.kt
Krzychuk9
573,127,179
false
null
fun main() { fun part1(input: List<String>): Int { return input.toRanges().count { val firstGroup = it[0] val secondGroup = it[1] firstGroup.subtract(secondGroup).isEmpty() || secondGroup.subtract(firstGroup).isEmpty() } } fun part2(input: List<String>): ...
0
Kotlin
0
0
ded55d03c9d4586166bf761c7d5f3f45ac968e81
1,037
adventOfCode2022
Apache License 2.0
src/day02/Day02.kt
devEyosiyas
576,863,541
false
null
package day02 import println import readInput const val ROCK = 1 const val PAPER = 2 const val SCISSORS = 3 const val WINNER_POINT = 6 fun main() { fun point(c: Char): Int = when (c) { 'A', 'X' -> ROCK 'B', 'Y' -> PAPER 'C', 'Z' -> SCISSORS else -> 0 } fun computeWinner(a...
0
Kotlin
0
0
91d94b50153bdab1a4d972f57108d6c0ea712b0e
1,734
advent_of_code_2022
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2021/Day8.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 8: Seven Segment Search --- * https://adventofcode.com/2021/day/8 */ class Day8 : Solver { override fun solve(lines: List<String>): Result { var partA = 0 for (line in lines) { val parsed = parseLine(li...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,047
euler
Apache License 2.0
src/Day07.kt
JIghtuse
572,807,913
false
{"Kotlin": 46764}
data class File(val size: Int) typealias Files = List<File> data class Directory( val path: String, val nestedDirectories: List<Directory>, val files: Files) typealias Directories = List<Directory> typealias FilesAndDirs = Pair<Files, Directories> fun joinPath(absolutePath: String, component: String) ...
0
Kotlin
0
0
8f33c74e14f30d476267ab3b046b5788a91c642b
4,443
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/2022/Day18_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.* fun main() { val pts = readInput(18).trim().lines() .map {it.split(",").map {x -> x.toInt()}}.toSet() fun neighbors(pt: List<Int>): List<List<Int>> { val (x, y, z) = pt return listOf(listOf(x-1, y, z), listOf(x+1, y, z), listOf(x, y-1, z), listOf(x, y+1, z), listOf(...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
1,264
adventofcode
Apache License 2.0
src/Day08.kt
hijst
572,885,261
false
{"Kotlin": 26466}
fun main() { fun IntGrid.isCellVisibleFromLeft(row: Int, col: Int) = rows[row].take(col) .all { value -> value < rows[row][col] } fun IntGrid.isCellVisibleFromRight(row: Int, col: Int) = rows[row].takeLast(cols.size - 1 - col) .all { value -> value < rows[row][col] } fun IntGrid.isCellVisi...
0
Kotlin
0
0
2258fd315b8933642964c3ca4848c0658174a0a5
2,623
AoC-2022
Apache License 2.0
2021/src/day21/Day21.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day21 import readInput data class Player(val name: String, var pos: Int, var score: Int) fun String.toPlayer(): Player { return Player(this.substringBefore(" starting"), this.split(" ").last().toInt(), 0) } fun getRolls(rollsNb: List<Int>): Int { return rollsNb.map { val nb = it % 100 ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
4,156
advent-of-code
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day11.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day11(input: Input) : Puzzle() { private val empty = 'L' private val occupied = '#' private val floor = '.' private val area by lazy { val area = input.lin...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,111
adventofcode-kotlin
MIT License
src/main/kotlin/day11/Day11ChronalCharge.kt
Zordid
160,908,640
false
null
package day11 import shared.Coordinate import shared.allCoordinates import shared.measureRuntime import shared.readPuzzle import kotlin.math.min private fun powerLevelOf(x: Int, y: Int, serialNumber: Int): Int { val rackId = x + 10 val powerLevel = ((rackId * y) + serialNumber) * rackId return ((powerLeve...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
1,814
adventofcode-kotlin-2018
Apache License 2.0
src/main/kotlin/roundC2021/smallerstrings.kt
kristofersokk
422,727,227
false
null
package roundC2021 import kotlin.math.max import kotlin.math.min fun main() { val cases = readLine()!!.toInt() (1..cases).forEach { caseIndex -> val (N, K) = readLine()!!.split(" ").map { it.toLong() } val S = readLine()!! if (N == 1L) { val y = max(min((S[0].letterNr).cod...
0
Kotlin
0
0
3ebd59df60ee425b7af86a147f49361dc56ee38d
2,032
Google-coding-competitions
MIT License
src/Day10.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
fun main() { fun part1(input: List<ValueCommand>): Int { var register = 1 var cycleCount = 0 var score = 0 for (valueCommand in input) { score += (cycleCount + 1..cycleCount + valueCommand.command.cycleCount) .firstOrNull { (it - 20).mod(40) == 0 }?.let {...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
1,599
AdventOfCode2022
Apache License 2.0
day11/Part2.kt
anthaas
317,622,929
false
null
import java.io.File private const val EMPTY = 'L' private const val OCCUPIED = '#' fun main(args: Array<String>) { var board = File("input.txt").readLines().map { it.toCharArray() } var nextIter = evolve(board) var same = areSame(board, nextIter) while (!same) { nextIter = evolve(board) ...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
2,001
Advent-of-Code-2020
MIT License
src/Day13.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import kotlin.math.max fun main() { val testInput = """ [1,1,3,1,1] [1,1,5,1,1] [[1],[2,3,4]] [[1],4] [9] [[8,7,6]] [[4,4],4,4] [[4,4],4,4,4] [7,7,7,7] [7,7,7] [] [3] [[[]]] [[]] [1,[2,[3,...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
6,368
advent-of-code-2022-kotlin
Apache License 2.0
src/Day05.kt
Totwart123
573,119,178
false
null
import java.util.Stack fun main() { fun part1(input: List<String>): String { val emptyLine = input.indexOfFirst{it.isEmpty()} val stacks = mutableMapOf<Int, ArrayDeque<String>>() val stackInfo = input.subList(0, emptyLine-1).reversed() //no need for the numbers val moveInfo = inpu...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
2,851
AoC
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinMatrixFlips.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,676
kotlab
Apache License 2.0
src/main/kotlin/aoc2023/Day03.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2023 import utils.* class EngineSchematic(val parts: List<String>): ArrayAsSurface(parts) { fun symbols() = indexed() .filter { it.second.isSymbol() } fun numbersTouching(c: Coordinates): Sequence<Int> = c.adjacentIncludeDiagonal() .filter { at(it).isDigit() } ...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,017
aoc-2022-kotlin
Apache License 2.0
solutions/aockt/y2021/Y2021D10.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import aockt.y2021.Y2021D10.SyntaxCheckResult.* import io.github.jadarma.aockt.core.Solution object Y2021D10 : Solution { /** The possible outcomes of syntax checking the submarine's navigation subsystem. */ private sealed interface SyntaxCheckResult { /** The syntax is valid. */ ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,267
advent-of-code-kotlin-solutions
The Unlicense
src/day03/Code.kt
ldickmanns
572,675,185
false
{"Kotlin": 48227}
package day03 import readInput fun main() { val input = readInput("day03/input") // val input = readInput("day03/input_test") println("asdfasdfasdf".toSet()) println(part1(input)) println(part2(input)) } val Char.priority: Int get() = if (isLowerCase()) { code - 'a'.code + 1 } el...
0
Kotlin
0
0
2654ca36ee6e5442a4235868db8174a2b0ac2523
1,209
aoc-kotlin-2022
Apache License 2.0
leetcode2/src/leetcode/longest-palindromic-substring.kt
hewking
68,515,222
false
null
package leetcode import kotlin.math.max /** * 5. 最长回文子串 * https://leetcode-cn.com/problems/longest-palindromic-substring/ * @program: leetcode * @description: ${description} * @author: hewking * @create: 2019-04-26 13:39 * * 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
3,495
leetcode
MIT License
src/main/kotlin/advent/of/code/day07/Solution.kt
brunorene
160,263,437
false
null
package advent.of.code.day07 import java.io.File import java.util.* val lineRegex = Regex("^Step ([A-Z]) must.+step ([A-Z]) can begin.$") fun part1(): String { val dependsOn = mutableMapOf<Char, String>() val steps = TreeSet<Char>() File("day07.txt").readLines().forEach { line -> val res = lineRe...
0
Kotlin
0
0
0cb6814b91038a1ab99c276a33bf248157a88939
2,893
advent_of_code_2018
The Unlicense
src/Day05.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
typealias Stack<T> = ArrayList<T> /** * [Day05](https://adventofcode.com/2022/day/5) */ fun main() { data class Operation(val num: Int, val from: Int, val to: Int) fun conv(input: List<String>): Pair<List<Stack<Char>>, List<Operation>> { val index = input.indexOfFirst(String::isEmpty) val le...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
2,175
aoc-in-kotlin-2022
Apache License 2.0
src/Day18.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
import java.util.* import kotlin.math.abs fun main() { val input = readInput("Day18") val cubes = input.map { s -> s.split(",").map { it.toInt() } } val cubeSet = cubes.toMutableSet() val max = cubes.flatten().max() + 1 val min = cubes.flatten().min() - 1 fun part1(): Int { var res = ...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
1,714
AOC-2022
Apache License 2.0
2017/src/main/java/p7/Problem7.kt
ununhexium
113,359,669
false
null
package p7 import com.google.common.io.Resources import more.Input fun main(args: Array<String>) { val input = Input.getFor("p7") val tree = buildTree(input) println("The root is $tree") println(tree.toTree()) println(tree.filter({ !it.isBalanced() })) } val arrow = " -> " val naming = Regex("(?<name>\\p{...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
3,809
adventofcode
The Unlicense
calendar/day12/Day12.kt
starkwan
573,066,100
false
{"Kotlin": 43097}
package day12 import Day import Lines import java.util.Comparator.comparingInt class Day12 : Day() { override fun part1(input: Lines): Any { val dijkstra = Dijkstra( input, cost = { node, other -> if (node.elevation - other.elevation >= -1) 1 else -10000 } ) val pro...
0
Kotlin
0
0
13fb66c6b98d452e0ebfc5440b0cd283f8b7c352
5,910
advent-of-kotlin-2022
Apache License 2.0
kotlin/src/x2022/day5/Day5.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day5 import readInput fun parseStackInput(stackInput: List<String>): List<ArrayDeque<Char>> { val stacks = stackInput[0].split(" ").mapNotNull { it.ifEmpty { null }?.toInt() }.map { ArrayDeque<Char>() } stackInput.drop(1).forEach { it.chunked(4).forEachIndexed { i, its -> ...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
2,137
adventOfCode
Apache License 2.0
src/main/kotlin/algorithms/sorting/quicksort/QuickSort.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package algorithms.sorting.quicksort fun main() { val numbers = intArrayOf(87, 34, 7, 12, 11, 54, 6, 42, 150, 15, 92, 69) val quickSort = QuickSort() quickSort.quickSort(numbers, 0, numbers.size - 1) quickSort.printArray(numbers) } //The QuickSort algorithm is a divide-and-conquer algorithm that sorts...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
1,936
dsa-kotlin
MIT License
src/Day07.kt
vonElfvin
572,857,181
false
{"Kotlin": 11658}
import kotlin.math.abs fun main() { data class Directory( val name: String, val parent: String, val childDirs: MutableSet<String> = mutableSetOf(), var filesSize: Long = 0, var totalSize: Long = 0, ) fun part1(input: List<String>): Long { val dirTree: Mutabl...
0
Kotlin
0
0
6210f23f871f646fcd370ec77deba17da4196efb
2,175
Advent-of-Code-2022
Apache License 2.0
yandex/y2022/qual/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2022.qual import kotlin.random.Random fun main() { val (n, _) = readInts() val s = List(n) { readLn().map { "ACGT".indexOf(it) }.toIntArray() } .let { it.plus(IntArray(it[0].size)) } data class Edge(val u: Int, val v: Int, val len: Int) val edges = mutableListOf<Edge>() for (i in s.indices) for...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,325
competitions
The Unlicense
src/main/kotlin/days/Pathfinding.kt
andilau
429,206,599
false
{"Kotlin": 113274}
package days import java.util.PriorityQueue fun Map<Point, Boolean>.findPath(from: Point, to: Point? = null): List<Point> { val queue = PriorityQueue<List<Point>>(Comparator.comparing { size }) .apply { add(listOf(from)) } val visited = mutableSetOf<Point>() var longestPath = emptyList<Point>() ...
2
Kotlin
0
0
f51493490f9a0f5650d46bd6083a50d701ed1eb1
2,225
advent-of-code-2019
Creative Commons Zero v1.0 Universal
src/main/kotlin/kt/kotlinalgs/app/graph/KruskalMST.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph println("Test") Solution().test() class Solution { fun test() { //https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/ val vertice0 = Vertice(0) val vertice1 = Vertice(1) val vertice2 = Vertice(2) val vertice...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
4,159
KotlinAlgs
MIT License
src/day04/Day04.kt
sanyarajan
572,663,282
false
{"Kotlin": 24016}
package day04 import readInput fun main() { fun part1(input: List<String>): Int { var fullyEnclosedRanges = 0 input.forEach { line -> val (rangeStringElf1, rangeStringElf2) = line.split(",") val (rangeStartElf1, rangeEndElf1) = rangeStringElf1.split("-").map { it.toInt() }...
0
Kotlin
0
0
e23413357b13b68ed80f903d659961843f2a1973
1,714
Kotlin-AOC-2022
Apache License 2.0
src/main/kotlin/com/hopkins/aoc/day19/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day19 import java.io.File const val debug = true const val part = 1 /** Advent of Code 2023: Day 19 */ fun main() { // Step 1: Read the file input val lines: List<String> = File("input/input19.txt").readLines() if (debug) { println("Step 1: Read file") println("===...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
3,077
aoc2023
MIT License
2021/src/main/kotlin/Day12.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day12(input: List<String>) { private val connections = input.map { it.split("-") }.flatMap { (begin, end) -> listOf(begin to end, end to begin) } .filterNot { (_, end) -> end == "start" }.groupBy({ it.first }, { it.second }) private fun countPaths( cave: String = "start", path: L...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,054
adventofcode-2021-2025
MIT License
src/main/kotlin/Probability.kt
fcruzel
183,215,777
false
{"Kotlin": 17006, "Java": 6293, "Assembly": 154}
import kotlin.math.ln fun calculateProbability(corpus: List<String>, vocabulary: List<String>): List<Word> { val freq = HashMap<String, Int>() val tokens = makeTokens(corpus).sorted() vocabulary.forEach { word -> freq[word] = appearances(word, tokens) } freq["<UNK>"] = 0 val wordFrec...
0
Kotlin
0
0
ecf073f58ff077064b6fc3e021d1f5b54db128b0
1,195
pln-iaa
MIT License
classroom/src/main/kotlin/com/radix2/algorithms/week3/CountingInversionsV2.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week3 import java.util.* // Counting inversions. An inversion in an array a[] is a pair of entries a[i] and a[j] such that i < j but a[i] > a[j]. // Given an array, design a linear arithmetic algorithm to count the number of inversions. fun sort(array: IntArray, aux: IntArray, lo: Int, ...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,584
coursera-algorithms-part1
Apache License 2.0
src/day04/Day04.kt
hamerlinski
572,951,914
false
{"Kotlin": 25910}
package day04 import readInput fun main() { val input = readInput("Day04", "day04") val inputIterator = input.iterator() var solution1 = 0 var solution2 = 0 fun part1and2(input: Iterator<String>) { input.forEach { val elvesAssignmentRanges = it.split(",") val elf0 =...
0
Kotlin
0
0
bbe47c5ae0577f72f8c220b49d4958ae625241b0
1,945
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2023/Day03.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2023 import se.saidaspen.aoc.util.* fun main() = Day03.run() object Day03 : Day(2023, 3) { private val map = toMap(input) private val ymax = map.keys.map { it.second }.max() private val xmax = map.keys.map { it.first }.max() override fun part1(): Any { val partIds...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,613
adventofkotlin
MIT License
2015/src/main/kotlin/day24.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.mapItems import utils.selections fun main() { Day24.run() } object Day24 : Solution<List<Long>>() { override val name = "day24" override val parser = Parser.intLines.mapItems { it.toLong() } override fun part1(): Long { val targetSize = input.sum() /...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,518
aoc_kotlin
MIT License
src/main/kotlin/github/walkmansit/aoc2020/Day19.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day19(val input: String) : DayAoc<Int, Int> { interface Component { val id: Int fun isTerminal(): Boolean } class Terminal(val value: Char, override val id: Int) : Component { override fun isTerminal() = true } class Reference(val p...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
3,492
AdventOfCode2020
MIT License
src/Day07.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
class Day07 { fun part1(input: List<String>): Int { val directoryFileSizes = mutableMapOf<String, Int>() var currentDirectoryTree = mutableListOf<String>() var currentDirectoryPath = "" for (line in input) { if (line == "$ cd ..") { currentDirectoryTree.re...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
3,380
advent-of-code
Apache License 2.0
src/Day07.kt
cvb941
572,639,732
false
{"Kotlin": 24794}
class FileSystem { sealed class FileOrDirectory(val name: String) { abstract val size: Int } class Directory(name: String, var files: Map<String, FileOrDirectory> = emptyMap()) : FileOrDirectory(name) { override val size: Int get() = files.values.sumOf { it.size } fun ...
0
Kotlin
0
0
fe145b3104535e8ce05d08f044cb2c54c8b17136
3,596
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
fun main() { val symbolValueMap: Map<Char, Int> = mapOf('A' to 1, 'B' to 2, 'C' to 3, 'X' to 1, 'Y' to 2, 'Z' to 3) fun calculateOutcomeScore(theirSymbol: Char, mySymbol: Char): Int { if(symbolValueMap[theirSymbol] == symbolValueMap[mySymbol]) return symbolValueMap[mySymbol]!! + 3 ...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
1,951
AoC2022
Apache License 2.0
src/Day04.kt
chrisjwirth
573,098,264
false
{"Kotlin": 28380}
fun main() { fun rangeAsLowHighInts(range: String): Pair<Int, Int> { val (rangeLow, rangeHigh) = range.split("-") return rangeLow.toInt() to rangeHigh.toInt() } fun rangeContainsOther(range1: String, range2: String): Boolean { val (range1Low, range1High) = rangeAsLowHighInts(range1)...
0
Kotlin
0
0
d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d
1,730
AdventOfCode2022
Apache License 2.0
src/adventofcode/blueschu/y2017/day11/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day11 import java.io.File import kotlin.math.max import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day11.txt") .bufferedReader() .use { r -> r.readText() } .trim() .split(",") } fun main(args: Array<String>)...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
2,548
Advent-Of-Code
MIT License
src/main/kotlin/kt/kotlinalgs/app/dynprog/StackOfBoxes.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.dynprog println("Test") val boxes = listOf( Box(5, 7, 5), Box(1, 3, 1), Box(2, 4, 3), // not include Box(3, 5, 3), // include Box(4, 6, 4) ) println(Solution().maxHeight(boxes)) // 7 + 3 + 5 + 6 = 21 // 1. Achung: Versuchen für memo arguments zu verringern // zb nur in...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,788
KotlinAlgs
MIT License
src/aoc2023/Day04.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { val regex = "Card[^:]+:([^|]+)\\|([^|]+)".toRegex() fun part1(lines: List<String>): Int { var sum = 0 for (line in lines) { val matches = regex.findAll(line) val winning = matches.first().groupValues[1].trim().split("\\s+"....
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
1,520
advent-of-code-kotlin
Apache License 2.0
kotlin/1162-as-far-from-land-as-possible.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
// BFS solution class Solution { fun maxDistance(grid: Array<IntArray>): Int { fun isValid(i: Int, j: Int) = i in (0..grid.lastIndex) && j in (0..grid[0].lastIndex) && grid[i][j] == 0 val q = ArrayDeque<Pair<Int, Int>>() var distance = -1 for (i in grid.indices) { for ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,081
leetcode
MIT License
src/2022/Day02.kt
bartee
575,357,037
false
{"Kotlin": 26727}
fun main() { val winning_combo_lookup = mapOf("rock" to "scissors", "scissors" to "paper", "paper" to "rock") val shape_score_lookup = mapOf("rock" to 1, "paper" to 2, "scissors" to 3) fun charToShape(input: String): String{ val rockArray = arrayOf("A", "X") val paperArray = arrayOf("B", "Y") val sc...
0
Kotlin
0
0
c7141d10deffe35675a8ca43297460a4cc16abba
2,906
adventofcode2022
Apache License 2.0
src/Day12.kt
fouksf
572,530,146
false
{"Kotlin": 43124}
import java.io.File import java.lang.Exception import kotlin.math.abs fun main() { fun parseInput(input: String): List<List<String>> { return input.split("\n") .filter { it != "" } .map { line -> line.split("").filter { it != "" } } } fun shouldVisit( p: Pair<Int, I...
0
Kotlin
0
0
701bae4d350353e2c49845adcd5087f8f5409307
4,522
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day007.kt
ruffCode
398,923,968
false
null
import kotlin.time.measureTimedValue object Day007 { internal val testInput = """ light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright white bags, 4 muted yellow bags. bright white bags contain 1 shiny gold bag. muted yellow bags contain ...
0
Kotlin
0
0
477510cd67dac9653fc61d6b3cb294ac424d2244
5,981
advent-of-code-2020-kt
MIT License
src/Day02.kt
robinpokorny
572,434,148
false
{"Kotlin": 38009}
/* Move - enum and utils */ private enum class Move { ROCK, PAPER, SCISSORS; } private fun scoreMove(mine: Move) = when (mine) { Move.ROCK -> 1 Move.PAPER -> 2 Move.SCISSORS -> 3 } private fun toMove(input: String) = when (input) { "A", "X" -> Move.ROCK "B", "Y" -> Move.PAPER "C", "Z" -> M...
0
Kotlin
0
2
56a108aaf90b98030a7d7165d55d74d2aff22ecc
2,595
advent-of-code-2022
MIT License
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day18.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty fun List<String>.day18Part1(): Long = this.map { it.split(" ").filter { it.isNotBlank() } } .map { it.calculateBasic() } .sum() private fun List<String>.calculateBasic(): Long { when { this.size == 1 -> { return this.first().toL...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
2,504
AdventOfCode
MIT License
src/main/kotlin/co/csadev/advent2022/Day13.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 13 * Problem Description: http://adventofcode.com/2021/day/13 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsText class Day13(override val input: String = resourceAsText("22day13....
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,615
advent-of-kotlin
Apache License 2.0
src/Day21.kt
anisch
573,147,806
false
{"Kotlin": 38951}
import kotlin.math.abs enum class Job { TIMES, PLUS, MINUS, DIV } open class MonkeyJob(val name: String) class MonkeyNumber( name: String, var number: Long, ) : MonkeyJob(name) class MonkeyOperation( name: String, val a: String, val b: String, val job: Job, ) : MonkeyJob(name) fun getMonkey...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
3,540
Advent-of-Code-2022
Apache License 2.0
src/Day03.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
fun main() { fun assignPoints(c: Char): Int { val lowercase = ('a'..'z').toList() val uppercase =('A'..'Z').toList() val i = if (lowercase.contains(c)) { lowercase.indexOf(c) + 1 } else { uppercase.indexOf(c) + 27 } // println(i) return...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
1,787
advent-of-code-2022
Apache License 2.0
src/day11/Day11.kt
molundb
573,623,136
false
{"Kotlin": 26868}
package day11 import readInput fun main() { val input = readInput(parent = "src/day11", name = "Day11_input") println(solvePartOne(input)) println(solvePartTwo(input)) } private fun solvePartTwo(input: List<String>): Long { val monkeys = mutableListOf<Monkey>() var divisibleMod = 1L var i =...
0
Kotlin
0
0
a4b279bf4190f028fe6bea395caadfbd571288d5
3,870
advent-of-code-2022
Apache License 2.0
src/day02/Day02.kt
TimberBro
572,681,059
false
{"Kotlin": 20536}
package day02 import readInput fun main() { fun part1(input: List<String>): Int { val result = input.stream() .map { it.split(" ") } .map { (a, b) -> when (a to b) { "A" to "X" -> 1 + 3 "A" to "Y" -> 2 + 6 ...
0
Kotlin
0
0
516a98e5067d11f0e6ff73ae19f256d8c1bfa905
1,615
AoC2022
Apache License 2.0
src/main/kotlin/day3/Day3.kt
Arch-vile
317,641,541
false
null
package day3 import readFile data class Terrain(val pattern: List<List<Char>>) { fun isThereATree(location: Coordinate): Boolean = pattern[location.y][location.x % pattern[0].size] == '#' fun isThisTheBottom(location: Coordinate): Boolean = location.y + 1 == pattern.size } data class Coordi...
0
Kotlin
0
0
12070ef9156b25f725820fc327c2e768af1167c0
1,738
adventOfCode2020
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year20/Day16.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year20 import com.grappenmaker.aoc.* import java.util.PriorityQueue fun PuzzleSet.day16() = puzzle(day = 16) { val (rulesPart, yourPart, othersPart) = input.doubleLines().map(String::lines) data class Rule(val name: String, val firstRange: IntRange, val secondRange: IntRange) ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,875
advent-of-code
The Unlicense
src/Day03.kt
alex-rieger
573,375,246
false
null
fun main() { fun splitIntoCompartment(s: String): Pair<String, String> { val half = s.length / 2 return Pair(s.substring(0, half), s.substring(half, s.length)) } fun toIterableChars(i: String): Iterable<Char> { return i.toCharArray().asIterable() } fun toPriority(i: Char): ...
0
Kotlin
0
0
77de0265ff76160e7ea49c9b9d31caa1cd966a46
1,216
aoc-2022-kt
Apache License 2.0
2021/src/main/kotlin/sh/weller/aoc/Day04.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day04 : SomeDay<String, Int> { override fun partOne(input: List<String>): Int { val drawnNumbers: List<Int> = input.first().getDrawnNumbers() var boards: List<List<List<Pair<Int, Boolean>>>> = input.drop(2).toBoards() for (drawnNumber in drawnNumbers) { ...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
3,072
AdventOfCode
MIT License
src/Day14.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
fun main() { data class Point(val x: Int, val y: Int) { operator fun rangeTo(other: Point) = buildList { val fromX = minOf(x, other.x) val toX = maxOf(x, other.x) val fromY = minOf(y, other.y) val toY = maxOf(y, other.y) for (newX in fromX..toX) { ...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
2,635
advent-of-code-2022
Apache License 2.0
src/Day11.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
fun main() { fun part1(input: String): Long { return simulateMonkeys(input, 20, true) } fun part2(input: String): Long { return simulateMonkeys(input, 10000, false) } val testInput = readInputAsString("Day11_test") check(part1(testInput) == 10605L) check(part2(testInput) == ...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
4,042
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/TopologicalSortAdjList.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.graph import java.util.* // Use Edge from {AdjacencyList.class} //data class Edge(val source: Int, val dest: Int, val weight: Int) fun dfs( i: Int, at: Int, visited: Array<Boolean>, ordering: Array<Int>, graph: MutableMap<Int, MutableList<Edge>> ): Int ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
2,687
DS_Algo_Kotlin
MIT License
src/main/kotlin/days/aoc2015/Day13.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2015 import days.Day // Bob would lose 31 happiness units by sitting next to David. class Day13: Day(2015, 13) { override fun partOne(): Any { val people = LinkedHashSet<Person>() val edges = LinkedHashSet<PreferenceEdge>() inputList.map { Regex("(\\w+) would (...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
3,789
Advent-Of-Code
Creative Commons Zero v1.0 Universal