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/year2022/day03/Day03.kt
tiagoabrito
573,609,974
false
{"Kotlin": 73752}
package year2022.day03 import readInput fun main() { fun toValue(it: MutableList<Char>): Int { return it.distinct().sumOf { if (it > 'a') it - 'a' + 1 else it - 'A' + 27 } } fun repeated(a: Pair<CharSequence, CharSequence>): MutableList<Char> { val myList = a.first.toMutableList() ...
0
Kotlin
0
0
1f9becde3cbf5dcb345659a23cf9ff52718bbaf9
1,009
adventOfCode
Apache License 2.0
kotlin/src/main/kotlin/days/Day2.kt
ochronus
572,132,995
false
{"Kotlin": 9226, "C#": 3907, "Python": 2279}
package days class Day2 : Day(2) { enum class Shape( val sign: Char, val signPart1: Char, val score: Int ) { ROCK('A', 'X', 1), PAPER('B', 'Y', 2), SCISSORS('C', 'Z', 3) } enum class Result( val sign: Char, val score: Int ) { ...
0
Kotlin
0
1
93c5ef0afed730a2c0da748f2bf129e12f7f915c
1,608
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/day02/Day02.kt
mahan-ym
572,901,965
false
{"Kotlin": 4240}
package day02 import readInput fun main() { // A -> Rock, B -> Paper, C -> Scissors // X -> Rock, Y -> Paper, Z -> Scissors // you get 6 scores when you win, 3 scores when you draw and Rock = 1, Paper = 2, Scissors = 3 scores // second part: X -> need to lose, Y -> need to draw, Z -> need ...
0
Kotlin
0
0
d09acc419480bcc025d482afae9da9438b87e4eb
2,121
AOC-kotlin-2022
Apache License 2.0
src/main/kotlin/Day16.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
fun main() { val data = readInputFile("day16") fun part1(): Int { val (packetTree, _) = Packet.parse(data.first().hexToBinary(), 0) fun addUpVersions(packet: Packet): Int = when (packet) { is Packet.Literal -> packet.version is Packet.Operator -> pac...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
5,252
AOC2021
Apache License 2.0
aoc21/day_05/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File import kotlin.math.abs data class Pos(val x: Int, val y: Int) data class Line(val from: Pos, val to: Pos) fun parsePos(str: String) = str.split(",").let { Pos(it[0].toInt(), it[1].toInt()) } fun parseLine(str: String): Line = str.split("->").let { Line(parsePos(it[0].trim()), parsePos(it[1].tr...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,341
advent-of-code
MIT License
src/Day20.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
fun main() { fun List<String>.parse(): List<Int> { return map { it.toInt() } } fun <T> List<T>.circulateIndex(index: Int): Int { return ((index + 10 * (size - 1)) % (size - 1)) } fun <T> List<T>.circulateIndex(index: Long): Int { return (((index % (size - 1)).toInt()) + 10 ...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
2,955
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-14.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2022 import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines import kotlin.math.max import kotlin.math.min fun main() { val input = readInputLines(2022, "14-input") val te...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,700
advent-of-code
MIT License
src/main/kotlin/aoc/Day02.kt
fluxxion82
573,716,300
false
{"Kotlin": 39632}
package aoc import aoc.Result.Companion.getResultFromCode import aoc.State.Companion.getStateFromCode import java.io.File enum class State(val codeOne: String, val codeTwo: String) { Rock("A", "X"), Paper("B", "Y"), Scissors("C", "Z"); companion object { fun getStateFromCode(code: String): St...
0
Kotlin
0
0
3920d2c3adfa83c1549a9137ffea477a9734a467
3,288
advent-of-code-kotlin-22
Apache License 2.0
2021/src/day18/Day18.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day18 import readInput import java.util.* fun List<String>.toListOfTree() : List<Node> = this.map { it.toTree()!! } fun String.toTree(parent: Node? = null) : Node? { if (all { it.isDigit() }) return Node(parent = parent, value = toInt()) var delimitersCount = 0 val subStr = this.drop(1).dropLast(...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
5,968
advent-of-code
Apache License 2.0
src/day22/Day22.kt
andreas-eberle
573,039,929
false
{"Kotlin": 90908}
package day22 import Coordinate import readInput const val day = "22" sealed interface Command data class StepCommand(val steps: Int) : Command data class TurnCommand(val turn: Char) : Command data class Transform(val originDirection: Int, val origin: Coordinate, val target: Coordinate) fun transforms(direction: I...
0
Kotlin
0
0
e42802d7721ad25d60c4f73d438b5b0d0176f120
6,953
advent-of-code-22-kotlin
Apache License 2.0
src/year2015/day05/Day05.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day05 import check import readInput fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2015", "Day05_test") check(part1(testInput), 1) check(part2(testInput), 1) val input = readInput("2015", "Day05") println(part1(inp...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,145
AdventOfCode
Apache License 2.0
src/main/kotlin/_2022/Day19.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2022 import readInput fun main() { fun parseBlueprint(input: String): BlueprintPaper { var number = 0 val robotBlueprints = mutableListOf<RobotBlueprint>() val strings = input.split(".", ":") strings.forEachIndexed { index, str -> when (index) { ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
10,494
advent-of-code
Apache License 2.0
src/main/kotlin/day17/Day17.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day17 fun solveA(input: List<String>): Int { val jetStream = JetStream(input.first()) val shaper = Shaper() val blocked = mutableSetOf<Position>() var highestRock = 0 repeat(2022) { highestRock += blocked.nextStep(highestRock, shaper, jetStream) } return highestRock } f...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
4,474
advent-of-code-2022
Apache License 2.0
2020/day6/day6.kt
Deph0
225,142,801
false
null
class day6 { fun part1(input: List<String>): Int { val inputGroupsSets = input.map { it.split("\n").flatMap { group -> group.split("").filter { it.isNotBlank() // [, a, b,] because java is stupid }.toSet() }.toSet() } // println(inputGroupsSets) var res = inputGr...
0
Kotlin
0
0
42a4fce4526182737d9661fae66c011f0948e481
1,972
adventofcode
MIT License
src/Day12.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { fun solve1(pattern: String, arr: List<Int>): Long { val dp = Array(pattern.length+1) { LongArray(arr.size+1) } dp[0][0] = 1 for (i in dp.indices) { for (j in dp[i].indices) { if (dp[i][j] <= 0) continue if (i in pattern.indices && patt...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,278
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day21/Code.kt
fcolasuonno
317,324,330
false
null
package day21 import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/main/kotlin/$dir/$name").readLines() val parsed = parse(input) part1(parsed) part2(...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
1,946
AOC2020
MIT License
src/twentythree/Day08.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentythree import readInputTwentyThree fun main() { fun part1(input: List<String>): Int { val directions = input.first().map { it } val nodes = input.filter { it.contains('=') } .associate { Pair( it.substring(0, 3), Pai...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
2,267
kotlin-aoc-1
Apache License 2.0
src/main/kotlin/mirecxp/aoc23/day06/Day06.kt
MirecXP
726,044,224
false
{"Kotlin": 42343}
package mirecxp.aoc23.day06 import mirecxp.aoc23.day04.toNumList import mirecxp.aoc23.readInput import java.util.* //https://adventofcode.com/2023/day/6 class Day06(private val inputPath: String) { private var lines: List<String> = readInput(inputPath).toMutableList() fun solve(part2: Boolean): String { ...
0
Kotlin
0
0
6518fad9de6fb07f28375e46b50e971d99fce912
1,401
AoC-2023
MIT License
src/test/kotlin/com/igorwojda/list/sort/radixsort/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.list.sort.radixsort // Time complexity (Best): Ω(n^2) // Time complexity (Average): Θ(n^2) // Time complexity (Worst): O(n^2) // Space complexity: O(1) private object Solution1 { private fun radixSort(list: List<Int>): List<Number> { // create temp list val tempList = list.toM...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
1,774
kotlin-coding-challenges
MIT License
src/day08/Day08.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day08 import readInput import kotlin.math.abs fun main() { fun parseInput(input: List<String>): List<List<Int>> { return input.map { str -> str.toList().map { char -> char.digitToInt() } } } fun List<Int>.allSmallerThan(compare: Int) = this....
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
4,264
advent-of-code-2022
Apache License 2.0
kotlin-algorithm-sample/src/main/kotlin/yitian/study/algorithm/problem/ModProblem.kt
techstay
89,333,432
false
null
package yitian.study.algorithm.problem /** * 一筐鸡蛋: * 1个1个拿,正好拿完。 * 2个2个拿,还剩1个。 * 3个3个拿,正好拿完。 * 4个4个拿,还剩1个。 * 5个5个拿,还差1个。 * 6个6个拿,还剩3个。 * 7个7个拿,正好拿完。 * 8个8个拿,还剩1个。 * 9个9个拿,正好拿完。 * 问:筐里最少有几个鸡蛋? * */ class ModProblem /** * 直接暴力穷举 */ fun answer1() { var n = 0 while (true) { if (n % 2 == 1 &...
0
Kotlin
0
0
1380ce181b1c8d4fad4752a1d92348dcf5d1ed18
2,453
algorithm-study
MIT License
src/Day05.kt
ZiomaleQ
573,349,910
false
{"Kotlin": 49609}
import java.util.Scanner fun main() { fun part1(input: List<String>): String { val splitIndex = input.withIndex().first { it.value.isBlank() }.index val configuration = input.subList(0, splitIndex) val moves = input.subList(splitIndex + 1, input.size) val columns = mutableListOf<...
0
Kotlin
0
0
b8811a6a9c03e80224e4655013879ac8a90e69b5
3,837
aoc-2022
Apache License 2.0
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day07.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 object Day07 { private val CD_REGEX = "\\$ cd (.+)".toRegex() private val DIR_REGEX = "dir (.+)".toRegex() private val FILE_REGEX = "([0-9]+) (.+)".toRegex() fun sumOfAllDirectoriesWithTotalSizeLessThan100000(input: String) = rootDirectory(input) ....
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
3,058
advent-of-code
MIT License
jk/src/main/kotlin/leetcode/Solution_LeetCode_Dynamic_Planning.kt
lchang199x
431,924,215
false
{"Kotlin": 86230, "Java": 23581}
package leetcode import kotlin.math.max class Solution_LeetCode_Dynamic_Planning { fun fibonacci(n: Int): Int { return if (n <= 1) 1 else fibonacci(n - 1) + fibonacci(n - 2) } fun fibonacciDp(n: Int): Int { if (n <= 1) return 1 var pre1 = 1 var pre2 = 1 var result ...
0
Kotlin
0
0
52a008325dd54fed75679f3e43921fcaffd2fa31
2,323
Codelabs
Apache License 2.0
src/Day04.kt
filipradon
573,512,032
false
{"Kotlin": 6146}
fun main() { fun String.toSet(): Set<Int> { val (begin, end) = this.split("-") return (begin.toInt()..end.toInt()).toSet() } fun part1(input: List<String>): Int { return input .map { it.split(",") } // into two ranges .map { it[0].toSet() to it[1].toSet() } ...
0
Kotlin
0
0
dbac44fe421e29ab2ce0703e5827e4645b38548e
947
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/Day07Swag.kt
rileynull
437,153,864
false
null
package rileynull.aoc import kotlin.math.absoluteValue object Day07Swag { fun quickSelect(list: MutableList<Int>, k: Int, left: Int = 0, right: Int = list.size - 1): Int { if (left == right) return list[left] var dstIndex = left for (i in left..right) { if (list[i] < list[righ...
0
Kotlin
0
0
2ac42faa192767f00be5db18f4f1aade756c772b
1,477
adventofcode
Apache License 2.0
src/day14/Day14.kt
gautemo
317,316,447
false
null
package day14 import shared.getLines fun initProgram(input: List<String>, isV2: Boolean = false): Long{ val computer = if(isV2) ComputerV2() else ComputerV1() for(line in input){ if(line.contains("mask")){ val mask = line.split('=')[1].trim() computer.mask = mask }else{...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
2,409
AdventOfCode2020
MIT License
src/Day04.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
fun main() { fun part1(input: List<String>): Int { return input.count { line -> val (a, b, x, y) = line.split(',', '-').map { it.toInt() } (a <= x && y <= b) || (x <= a && b <= y) } } fun part2(input: List<String>): Int { return input.count { line -> ...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
800
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/Day08.kt
SimonMarquis
724,825,757
false
{"Kotlin": 30983}
class Day08(input: List<String>) { private val instructions = input.first() private val network = input.drop(2) .map { it.split("""\W+""".toRegex()) } .associateBy({ it.first() }, { (id, left, right) -> Node(id, left, right) }) data class Node(val id: String, val left: String, val right: S...
0
Kotlin
0
1
043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e
1,322
advent-of-code-2023
MIT License
src/main/kotlin/day07/Day07.kt
Malo-T
575,370,082
false
null
package day07 data class File( val name: String, val size: Int, ) data class Directory( val name: String, val directories: MutableList<Directory> = mutableListOf(), val files: MutableList<File> = mutableListOf(), ) { // must not be in the constructor lateinit var parent: Directory fu...
0
Kotlin
0
0
f4edefa30c568716e71a5379d0a02b0275199963
2,183
AoC-2022
Apache License 2.0
day19/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File import java.lang.IllegalStateException fun main() { val partIDevice = parseInput(readInputFilePartI()) println("Part I: the solution is ${solvePartI(partIDevice)}.") println("Part II: the solution is ${solvePartII(10551339)}.") } fun readInputFilePartI(): List<String> { return Fil...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
3,148
AdventOfCode2018
MIT License
src/Day03.kt
cak
573,455,947
false
{"Kotlin": 8236}
fun main() { val abc = "abcdefghijklmnopqrstuvwxyz" val chars = abc + abc.uppercase() fun part1(input: List<String>): Int { val result = input .map { it.trim().toCharArray().toList() } .map { Pair(it.subList(0, it.size / 2), it.subList(it.size / 2, it.size)...
0
Kotlin
0
1
cab2dffae8c1b78405ec7d85e328c514a71b21f1
1,065
advent-of-code-2022
Apache License 2.0
lib/src/main/kotlin/utils/Graph.kt
madisp
434,510,913
false
{"Kotlin": 388138}
package utils import java.util.ArrayDeque import java.util.PriorityQueue import java.util.concurrent.atomic.AtomicLong class Graph<Node : Any, Edge: Any>( val edgeFn: (Node) -> List<Pair<Edge, Node>>, val weightFn: (Edge) -> Int = { 1 }, val nodes: Set<Node>? = null, ) { fun dfs(start: Node, visit: (Node) ->...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,601
aoc_kotlin
MIT License
src/questions/RegionsCutBySlashes.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe private const val LEFT = '/' private const val RIGHT = '\\' /** * An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. * These characters divide the square into contiguous regio...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,027
algorithms
MIT License
src/main/kotlin/g2801_2900/s2801_count_stepping_numbers_in_range/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2801_2900.s2801_count_stepping_numbers_in_range // #Hard #String #Dynamic_Programming #2024_01_19_Time_288_ms_(100.00%)_Space_38.2_MB_(100.00%) import kotlin.math.abs class Solution { private lateinit var dp: Array<Array<Array<Array<Int?>>>> fun countSteppingNumbers(low: String, high: String): Int ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,012
LeetCode-in-Kotlin
MIT License
src/main/kotlin/advent/day8/SevenSegmentSearch.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day8 import advent.loadInput import java.io.File /** * @author <NAME> */ /* 0: 1: 2: 3: 4: aaaa .... aaaa aaaa .... b c . c . c . c b c b c . c . c . c b c .... .... dddd dddd dddd e f . f e . . f ....
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
7,243
Advent-of-code-2021
MIT License
src/Day08.kt
seana-zr
725,858,211
false
{"Kotlin": 28265}
fun main() { data class Branch( val left: String, val right: String ) fun part1(input: List<String>): Int { var result = 0 val directions = input[0] val mapInput = input.drop(2) val map = mutableMapOf<String, Branch>() mapInput.forEach { ...
0
Kotlin
0
0
da17a5de6e782e06accd3a3cbeeeeb4f1844e427
4,041
advent-of-code-kotlin-template
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12935.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12935 * * 문제 설명 * 정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. * 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. * 예를들어 arr이 [4,3,2,1]인 경우는 [4,3,2]를 리턴 하고, [10]면 [-1]을 리턴 합니다. * * 제한 조건 * arr은 길이...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,520
HoOne
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day05/Day05.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day05 import eu.janvdb.aocutil.kotlin.readGroupedLines //const val FILENAME = "input05-test.txt" const val FILENAME = "input05.txt" val INSTRUCTION_REGEX = Regex("move (\\d+) from (\\d+) to (\\d+)") fun main() { val lines = readGroupedLines(2022, FILENAME) val crates = Crates.pars...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,944
advent-of-code
Apache License 2.0
src/Day09.kt
zdenekobornik
572,882,216
false
null
import kotlin.math.abs import kotlin.math.sign fun main() { data class Point(var x: Int, var y: Int) fun printMap(points: List<Point>) { for (y in -5..0) { for (x in 0..6) { val index = points.indexOf(Point(x, y)) if (index == 0) { print...
0
Kotlin
0
0
f73e4a32802fa43b90c9d687d3c3247bf089e0e5
3,096
advent-of-code-2022
Apache License 2.0
2021/src/day13/day13.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day13 import java.io.File fun main() { val data = parseInput(File("src/day13", "day13input.txt").readLines()) var board = data.first for (instruction in data.second) { println("folding $instruction ${board.size}") board = foldAlong(board, instruction.first, instruction.second) ...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
2,174
adventofcode
Apache License 2.0
day17/Part2.kt
anthaas
317,622,929
false
null
import java.io.File private const val ALIVE = '#' fun main(args: Array<String>) { val input = File("input.txt").readLines() var aliveCells = input.mapIndexed { x, s -> s.toCharArray().mapIndexed { y, c -> if (c == ALIVE) listOf(x, y, 0, 0) else emptyList() } .filter { it.is...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
1,408
Advent-of-Code-2020
MIT License
src/day08/Forest.kt
treegem
572,875,670
false
{"Kotlin": 38876}
package day08 class Forest(input: List<String>) { private val treeHeights: Array<IntArray> = input.to2dArray() private val indices1d = treeHeights.indices private val trees = indices1d.map { row -> indices1d.map { column -> Tree( height = treeHeights[row][column], ...
0
Kotlin
0
0
97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8
3,477
advent_of_code_2022
Apache License 2.0
src/aoc2017/kot/Day08.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import java.io.File import java.util.regex.Pattern object Day08 { fun solve(input: List<String>): Pair<Int, Int> { val memory = mutableMapOf<String, Int>() val regex = Pattern.compile("(\\w+) (inc|dec) (-?\\d+) if (\\w+) (>|<|==|>=|<=|!=) (-?\\d+)") var maxCurr = -1 for (line in...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,372
Advent_of_Code
MIT License
src/adventofcode/blueschu/y2017/day15/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day15 import kotlin.test.assertEquals // puzzle input const val GEN_START_A = 722L const val GEN_START_B = 354L // Generator factors const val GEN_FACTOR_A = 16807 const val GEN_FACTOR_B = 48271 // Generator iterations considered by "the judge" const val PART_ONE_ITERATIONS = 4...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
1,973
Advent-Of-Code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxValueOfCoins.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
1,657
kotlab
Apache License 2.0
src/Day09.kt
makohn
571,699,522
false
{"Kotlin": 35992}
import kotlin.math.abs import kotlin.math.sign fun main() { data class Pos(var x: Int, var y: Int) infix fun Pos.dist(other: Pos) = (this.x - other.x) to (this.y - other.y) fun part1(input: List<String>): Int { val head = Pos(0, 0) val tail = Pos(0, 0) val tailPositions ...
0
Kotlin
0
0
2734d9ea429b0099b32c8a4ce3343599b522b321
2,202
aoc-2022
Apache License 2.0
2021/src/main/kotlin/Day18.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
import kotlin.math.floor import kotlin.math.ceil class Day18(val input: List<String>) { private fun magnitude(num: SnailFishNumber): Long { return when (num) { is SnailFishNumber.Regular -> num.value.toLong() is SnailFishNumber.Number -> magnitude(num.left) * 3 + magnitude(num.righ...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
6,201
adventofcode-2021-2025
MIT License
2021/src/day04/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day04 import java.io.BufferedReader import java.nio.file.Files import java.nio.file.Paths fun main() { fun solveBoard(board: Board, sequence: List<Int>): Pair<Int, Int> { val rows = IntArray(5) { 5 } val cols = IntArray(5) { 5 } var sum = board.sumOf { it.sum() } for ((index, number) in sequ...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
1,873
advent-of-code
Apache License 2.0
2021/src/day17/day17.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day17 import java.lang.Integer.max fun main() { // target area: x=56..76, y=-162..-134 val target = TargetArea(56..76, -162..-134) println(findMaxY(target)) } fun findMaxY(area: TargetArea): Int { var allMaxY = 0 for (x in 0..max(area.xRange.first, area.xRange.last)) { for (y in a...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,057
adventofcode
Apache License 2.0
puzzles/kotlin/src/bender3.kt
hitszjsy
337,974,982
true
{"Python": 88057, "Java": 79734, "Kotlin": 52113, "C++": 33407, "TypeScript": 20480, "JavaScript": 17133, "PHP": 15544, "Go": 15296, "Ruby": 12722, "Haskell": 12635, "C#": 2600, "Scala": 1555, "Perl": 1250, "Shell": 1220, "Clojure": 753, "C": 598, "Makefile": 58}
import java.util.Scanner // complexity names and functions val complexities = arrayListOf( Constant(), Logarithmic(), Linear(), LogLinear(), Quadratic(), LogQuadratic(), Cubic(), Exponential() ) fun main(args : Array<String>) { // read standard input val input = Scanner(System.`in`...
0
null
0
1
59d9856e66b1c4a3d660c60bc26a19c4dfeca6e2
2,500
codingame
MIT License
src/main/kotlin/Day3/Day03.kt
fisherthewol
433,544,714
false
{"Kotlin": 8877}
package Day3 import readInput fun List<String>.toCols(): List<MutableList<Char>> { val lineSize = this[0].length val cols : MutableList<MutableList<Char>> = mutableListOf() for (i in 0 until lineSize) { cols.add(mutableListOf()) } for (line in this) { for (i in 0 until lineSize) { ...
0
Kotlin
0
0
d078aa647c666adf3d562fb1c67de6bef9956bcf
2,048
AoC2021
MIT License
src/Day12.kt
arnoutvw
572,860,930
false
{"Kotlin": 33036}
import java.lang.Math.abs typealias GridPosition = Pair<Int, Int> typealias Barrier = Set<GridPosition> const val MAX_SCORE = 99999999 fun main() { abstract class Grid() { open fun heuristicDistance(start: GridPosition, finish: GridPosition): Int { val dx = abs(start.first - finish.first) ...
0
Kotlin
0
0
0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4
6,331
aoc-2022-in-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day17.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.* import com.grappenmaker.aoc.Direction.* import kotlin.math.abs fun PuzzleSet.day17() = puzzle { val instructions = input.map { when (it) { '<' -> LEFT '>' -> RIGHT else -> error("Invalid input") }...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,020
advent-of-code
The Unlicense
LeetCode/ThreeSum.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
class ThreeSum { fun threeSum(nums: IntArray): List<List<Int>> { val targetSum = 0 val resultsList = mutableListOf<List<Int>>() val numsList = nums.toMutableList() for (outerNum in numsList) { for (midNum in numsList.minus(outerNum)) { for (innerNum in nu...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
2,846
KotlinCodeJourney
MIT License
calendar/day11/Day11.kt
starkwan
573,066,100
false
{"Kotlin": 43097}
package day11 import Day import Lines class Day11 : Day() { override fun part1(input: Lines): Any { val monkeys = input.windowed(6, 7).map { Monkey(it) } for (round in 1..20) { monkeys.forEach { monkey -> monkey.items.forEach { item -> item.worryLeve...
0
Kotlin
0
0
13fb66c6b98d452e0ebfc5440b0cd283f8b7c352
5,058
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/heap/MergeKSortedArrays.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.heap fun main() { val arrays = listOf(listOf(1, 4, 5), listOf(1, 3, 4), listOf(2, 6)) print(mergeKSortedArrays(arrays)) // [1, 1, 2, 3, 4, 4, 5, 6] } // O(nlog(k) + k) time | O(n + k) space // n - total elements, k - number of arrays private fun mergeKSortedArr...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
2,220
algs4-leprosorium
MIT License
src/Day03.kt
zirman
572,627,598
false
{"Kotlin": 89030}
fun main() { fun score(char: Char): Long { return if (char.isLowerCase()) { char - 'a' + 1L } else { char - 'A' + 27L } } fun part1(input: List<String>): Long { return input.sumOf { pack -> pack.slice(0 until pack.length / 2).toSet() ...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
990
aoc2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2022/Day08.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 8 - Treetop Tree House * Problem Description: http://adventofcode.com/2022/day/8 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day8/ */ package com.ginsberg.advent2022 class Day08(input: List<String>) { private...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
1,658
advent-2022-kotlin
Apache License 2.0
src/Day10.kt
thiyagu06
572,818,472
false
{"Kotlin": 17748}
import aoc22.printIt import java.io.File fun main() { fun parseInput() = File("input/day10.txt").readLines() val keyCycles = listOf(20, 60, 100, 140, 180, 220) fun star1(input: List<StateRegister>): Int { val signals = keyCycles.map { keyCycle -> val count = input .tak...
0
Kotlin
0
0
55a7acdd25f1a101be5547e15e6c1512481c4e21
2,025
aoc-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day06.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 6: Probably a Fire Hazard](https://adventofcode.com/2015/day/6). */ object Day06 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2015/Da...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,605
advent-of-code
MIT License
src/Day01.kt
BjornstadThomas
572,616,128
false
{"Kotlin": 9666}
fun main() { fun groupCaloriesTogheter(input: String): List<Int> { // println(input) //Print input for å se opprinnelig liste val inputSplit = input.split("\r\n\r\n") .map{ it.lines() .map( String::toInt ).sum()} .sortedDescending() // println(inputS...
0
Kotlin
0
0
553e3381ca26e1e316ecc6c3831354928cf7463b
1,262
AdventOfCode-2022-Kotlin
Apache License 2.0
src/main/kotlin/days/aoc2022/Day18.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day import util.Point3d import kotlin.math.max import kotlin.math.min class Day18 : Day(2022, 18) { override fun partOne(): Any { return countExposedSidesOfCubes(inputList) } override fun partTwo(): Any { return countExposedExteriorSidesOfCubes(inputList) ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,403
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/day04/Day04.kt
devEyosiyas
576,863,541
false
null
package day04 import println import readInput fun main() { fun processSections(input: List<String>): MutableList<List<Pair<Int, Int>>> { val sections = mutableListOf<List<Pair<Int, Int>>>() input.forEach { pairs -> val pair = mutableListOf<Pair<Int, Int>>() pairs.split(",")...
0
Kotlin
0
0
91d94b50153bdab1a4d972f57108d6c0ea712b0e
1,628
advent_of_code_2022
Apache License 2.0
codeforces/round872/c_to_upsolve.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round872 import java.util.* fun main() { val n = readInt() val a = readInts() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (u, v) = readInts().map { it - 1 } nei[u].add(v); nei[v].add(u) } val price = IntArray(n) val niceXor = IntArray(n) val temp = TreeSet<Int>() val...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,890
competitions
The Unlicense
src/main/kotlin/days/Day6.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days class Day6 : Day(6) { override fun partOne() = inputList.map { entry -> entry.split(":")[1].split(" ").filter { it.isNotEmpty() }.map { it.toLong() } }.run { first().mapIndexed { index, i -> Race(i, last()[index]) } }.map { ra...
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
1,624
AoC-2023
Creative Commons Zero v1.0 Universal
src/day21/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day21 import java.io.File val workingDir = "src/${object {}.javaClass.`package`.name}" fun main() { val sample = File("$workingDir/sample.txt") val input1 = File("$workingDir/input_1.txt") println("Step 1a: ${runStep1(sample)}") // 152 println("Step 1b: ${runStep1(input1)}") // 78342931359552...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
5,395
advent-of-code-2022
Apache License 2.0
problems/2818/kotlin/Solution.kt
misut
678,196,869
false
{"Kotlin": 32683}
import java.util.* import kotlin.math.min class Solution { companion object { const val mod = 1000000007 } fun pow(x: Int, n: Int): Int { if (n == 0) return 1 var res = (pow(x, n / 2) % mod).toLong() res = (res * res) % mod return (if (n % 2 == 1) (res *...
0
Kotlin
0
0
52fac3038dd29cb8eefebbf4df04ccf1dda1e332
2,026
ps-leetcode
MIT License
src/main/java/challenges/educative_grokking_coding_interview/merge_intervals/_1/MergeInterval.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.merge_intervals._1 import challenges.educative_grokking_coding_interview.merge_intervals.Interval import java.util.* object MergeInterval { private fun mergeIntervals(intervals: List<Interval>): List<Interval> { // If the list is empty val re...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,175
CodingChallenges
Apache License 2.0
src/Day02.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
fun main() { val map = mapOf( 'A' to mapOf( 'X' to (3 + 1 to 3 + 0), 'Y' to (6 + 2 to 1 + 3), 'Z' to (0 + 3 to 2 + 6) ), 'B' to mapOf( 'X' to (0 + 1 to 1 + 0), 'Y' to (3 + 2 to 2 + 3), 'Z' to (6 + 3 to 3 + 6) ), ...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
943
advent-of-code-2022-kt
Apache License 2.0
src/year2021/day05/Day05.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2021.day05 import Point2D import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { fun countOverlappingPoints(input: List<String>, lineCondition: (Point2D, Point2D) -> Boolean): Int = input.asSequence() .map { it.split(" -> ") } .map { it[0].split(...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,268
advent-of-code-kotlin
Apache License 2.0
src/day23/Day23.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day23 import readInput private data class Position(val row: Int, val col: Int) private fun Position.north() = this.copy(row = this.row - 1) private fun Position.south() = this.copy(row = this.row + 1) private fun Position.west() = this.copy(col = this.col - 1) private fun Position.east() = this.copy(col = th...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
5,179
aoc-2022-kotlin
Apache License 2.0
src/Day01.kt
allwise
574,465,192
false
null
import java.io.File fun main() { fun part1(input: List<String>): Int { val calories = Calories(input).countCalories() return calories } fun part2(input: List<String>): Int { val calories = Calories(input).countTop3Calories() return calories } // test if implementa...
0
Kotlin
0
0
400fe1b693bc186d6f510236f121167f7cc1ab76
1,847
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/lucaszeta/adventofcode2020/day21/day21.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day21 import com.lucaszeta.adventofcode2020.ext.getResourceAsText fun main() { val foodList = getResourceAsText("/day21/food-list.txt") .split("\n") .filter { it.isNotEmpty() } .map(::Food) val riskyIngredients = findRiskyIngredients(foodList) ...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
2,350
advent-of-code-2020
MIT License
src/main/kotlin/days/Day7.kt
MaciejLipinski
317,582,924
true
{"Kotlin": 60261}
package days class Day7 : Day(7) { override fun partOne(): Any { val rules = inputList.map { BagRule.from(it) } return rules .filter { it.canContain("shiny gold", rules) } .count() } override fun partTwo(): Any { val rules = inputList.map { BagRule....
0
Kotlin
0
0
1c3881e602e2f8b11999fa12b82204bc5c7c5b51
1,969
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/ClosestBST.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,232
kotlab
Apache License 2.0
src/Day08.kt
vonElfvin
572,857,181
false
{"Kotlin": 11658}
fun main() { fun checkVisible(x: Int, y: Int, trees: List<String>): Boolean { val current = trees[y][x] for (left in 0 until x) { if (trees[y][left] >= current) break if (left == x - 1) return true } for (right in x + 1 until trees[0].length) { if...
0
Kotlin
0
0
6210f23f871f646fcd370ec77deba17da4196efb
2,283
Advent-of-Code-2022
Apache License 2.0
src/Day04.kt
Jaavv
571,865,629
false
{"Kotlin": 14896}
import kotlin.time.ExperimentalTime import kotlin.time.measureTimedValue // https://adventofcode.com/2022/day/4 @OptIn(ExperimentalTime::class) fun main() { val input = readInput("Day04") val testinput = readInput("Day04_test") println(day04Part1(testinput)) //2 println(day04Part1(input)) //542 pr...
0
Kotlin
0
0
5ef23a16d13218cb1169e969f1633f548fdf5b3b
1,747
advent-of-code-2022
Apache License 2.0
src/Day03.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { val elfRucksacks = readInput("Day03") fun part1(elfs: List<String>): Int { return elfs.map { it.chunked(it.length / 2) }.map(::commonChar).sumOf(::calculatePriority) } fun part2(elfs: List<String>): Int { return elfs.chunked(3).map(::commonChar).sumOf(::calculatePriority) ...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
824
advent-of-code-kotlin-2022
Apache License 2.0
src/Day18.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
// cubes // for N cubes, there are N * 6 faces maximum // for x, y, z location of a cube, there is a common face IFF i // any pair xy, yz, xz is the same AND the other coordinate is off by one // so for example Node(1, 1, 1) has a shared face with Node(1, 1, 2) // for each shared face, subtract 2 from the faces maximum...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
4,980
aoc2022
Apache License 2.0
src/day04/Day04.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day04 import readInput fun main() { fun String.toIntSetPair(): Pair<Set<Int>, Set<Int>>? { val splitInput = split(',') if (splitInput.size != 2) return null val firstInput = splitInput[0].split('-') val secondInput = splitInput[1].split('-') if (firstInput.size !=...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
1,395
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day17.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInput object Day17 : Day { override val input = readInput(17).map { Jet.from(it) } override fun part1() = solve(2022) override fun part2() = solve(1000000000000) privat...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
4,364
aoc2022
MIT License
src/aoc2023/Day10.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { data class Point(val x: Int, val y: Int) data class Move(val nextPoint: Point, val dir: Char) fun Point.isValid(maze: Array<Array<Char>>): Boolean { return x >= 0 && x < maze.size && y >= 0 && y < maze[0].size } fun Point.nextStep(symbol: Ch...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
7,242
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/advent/day15/Chiton.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day15 import advent.Matrix import advent.Position import advent.adjacents import advent.loadInput import java.io.File import java.util.* /** * @author <NAME> */ data class CavePoint(val riskLevel: Int, val position: Position) data class GraphNode( val cavePoint: CavePoint, val edgesTo: Set<...
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
4,338
Advent-of-code-2021
MIT License
leetcode2/src/leetcode/ShortestUnsortedContinuousSubarray.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * Created by test * Date 2019/6/18 0:20 * Description * https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray/ * 581. 最短无序连续子数组 * * 给定一个整数数组,你需要寻找一个连续的子数组,如果对这个子数组进行升序排序,那么整个数组都会变为升序排序。 你找到的子数组应是最短的,请输出它的长度。 示例 1: 输入: [2, 6, 4, 8, 10, 9, 15] 输出: 5 解释:...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,673
leetcode
MIT License
src/Day17.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
import kotlin.math.pow fun main() { fun simulation(input: String, steps: Long): Long { return Chamber(steps, GasJets(input)).simulate() } fun part1(input: String): Long = simulation(input, 2022L) fun part2(input: String): Long = simulation(input, 1_000_000_000_000) // test if implementat...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
6,363
aoc-2022
Apache License 2.0
day14/prob2.kts
rlei
435,244,189
false
{"Assembly": 7573, "C++": 6280, "C": 5787, "C#": 4212, "OCaml": 3872, "Elixir": 3744, "Ruby": 3675, "Dart": 3436, "Prolog": 3064, "JavaScript": 2938, "F#": 2713, "Kotlin": 2100, "D": 1883, "Python": 1686, "Go": 1657, "Julia": 1205, "Clojure": 444, "Awk": 187}
val template = readLine()!! // skip blank line readLine()!! val rules = generateSequence(::readLine) .map { val (elemPair, insertion) = it.split(" -> ") Pair(Pair(elemPair[0], elemPair[1]), insertion[0]) } .toMap() // prefix and suffix with something to make sure all c...
0
Assembly
0
5
7d7a29b5a8b045fd563dc6625b16714c8e8bd993
1,560
adventofcode2021
Apache License 2.0
src/main/kotlin/Day04.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day04.solvePart1()) println(Day04.solvePart2()) } object Day04 { private const val BOARD_SIZE = 5 private val numbers: IntArray private val boards: List<Board> init { val input = inputScanner("day04") numbers = input.nextLine().toIntArray() boards ...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
2,167
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
2k23/aoc2k23/src/main/kotlin/07.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 d07 import input.read fun main() { println("Part 1: ${part1(read("07.txt"))}") println("Part 2: ${part2(read("07.txt"))}") } class Hand(line: String) { // A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, or 2 enum class CardP1(val value: Char) { TWO('2'), THREE('3'), FOUR('4'), ...
0
Rust
0
3
cb0ea2fc043ebef75aff6795bf6ce8a350a21aa5
4,516
aoc
The Unlicense
kotlin/pig-latin/src/main/kotlin/PigLatin.kt
Javran
352,422,285
false
{"Haskell": 449574, "Scheme": 220116, "Kotlin": 151245, "Rust": 150637, "Racket": 93970, "Clojure": 26350, "Makefile": 7050}
object PigLatin { // List of char sequence that should be considered a single cluster of vowel / consonant. // Longer elements must appear first. private val clusters: List<Pair<String, Boolean>> = listOf( "sch" to false, "thr" to false, "xr" to true, "yt" to true, "ch" to false, "qu...
0
Haskell
0
0
15891b189864bf6fff1ef79f0521aa560dc41f5b
1,830
exercism-solutions
Apache License 2.0
src/main/kotlin/Day7.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
import utils.execFileByLine import java.lang.IllegalArgumentException private data class CamelCards(val hand: String, val bid: Int, val type: TYPES = TYPES.HighCard) private enum class TYPES { FiveOfAKind, FourOfAKind, FullHouse, ThreeOfAKind, TwoPair, OnePair, HighCard } class Day7 { private val myCards = m...
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
3,625
aoc2023
Apache License 2.0
src/main/kotlin/com/github/brpeterman/advent2022/HillClimber.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 import java.util.LinkedList class HillClimber(input: String) { data class HeightMap(val startPos: Coords, val endPos: Coords, val elevations: Map<Coords, Int>) data class Coords(val row: Int, val col: Int) { operator fun plus(other: Coords): Coords { ...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
3,066
advent2022
MIT License
src/main/kotlin/pl/jpodeszwik/aoc2023/Day19.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Integer.parseInt import java.util.* data class Condition(val variable: Char, val operation: Char, val value: Int) { fun isSatisfiedBy(systemPart: SystemPart): Boolean { val varValue = systemPart.values[variable]!! return when (operation) { ...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
5,457
advent-of-code
MIT License
src/main/kotlin/day05.kt
mgellert
572,594,052
false
{"Kotlin": 19842}
import java.util.* object SupplyStacks : Solution { fun moveStacks( supplyStack: SupplyStack, operations: List<Operation>, crateMover: (SupplyStack, Operation) -> Unit ): String { operations.forEach { crateMover(supplyStack, it) } val topCrates = StringBuilder() ...
0
Kotlin
0
0
4224c762ad4961b28e47cd3db35e5bc73587a118
1,823
advent-of-code-2022-kotlin
The Unlicense
src/main/kotlin/Day04.kt
nmx
572,850,616
false
{"Kotlin": 18806}
fun main(args: Array<String>) { fun toRange(str: String): IntRange { val (lo, hi) = str.split("-") return IntRange(lo.toInt(), hi.toInt()) } fun rangesFullyContained(a: IntRange, b: IntRange): Boolean { return (a.first <= b.first && a.last >= b.last) || (b.first <= a...
0
Kotlin
0
0
33da2136649d08c32728fa7583ecb82cb1a39049
1,347
aoc2022
MIT License
untitled/src/main/kotlin/Day11.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
typealias WorryFunction = (Long) -> Long class Day11(private val fileName: String) : AocSolution { override val description: String get() = "Day 11 - Monkey in the Middle ($fileName)" private val input = InputReader(fileName).lines private fun monkeyTroop() = input.chunked(7).map { config -> Monkey.parse...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
4,666
adventofcode2022-kotlin
The Unlicense
year2022/src/main/kotlin/net/olegg/aoc/year2022/day10/Day10.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day10 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2022.DayOf2022 import kotlin.math.abs /** * See [Year 2022, Day 10](https://adventofcode.com/2022/day/10) */ object Day10 : DayOf2022(10) { private val TIMES = listOf( 20, 60, 100, 140, 180, ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,712
adventofcode
MIT License
aoc21/day_09/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import pathutils.Pos import pathutils.fourNeighs import pathutils.reachable import java.io.File fun neighs(pos: Pos, map: Array<IntArray>): List<Pos> = fourNeighs(pos, 0, map.size - 1, 0, map[0].size - 1) fun basinNeighs(pos: Pos, map: Array<IntArray>): List<Pos> = neighs(pos, map).filter { map[it.x][it.y] !=...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,117
advent-of-code
MIT License
src/main/kotlin/com/adrielm/aoc2020/solutions/day10/Day10.kt
Adriel-M
318,860,784
false
null
package com.adrielm.aoc2020.solutions.day10 import com.adrielm.aoc2020.common.Solution import com.adrielm.aoc2020.common.sumByLong import org.koin.dsl.module private val POSSIBLE_JOLT_DIFFS = listOf(1, 2, 3) class Day10 : Solution<List<Int>, Long>(10) { override fun solveProblem1(input: List<Int>): Long { ...
0
Kotlin
0
0
8984378d0297f7bc75c5e41a80424d091ac08ad0
1,665
advent-of-code-2020
MIT License
src/main/kotlin/org/sjoblomj/adventofcode/day4/Day4.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day4 import org.sjoblomj.adventofcode.readFile import java.time.format.DateTimeFormatter import kotlin.system.measureTimeMillis private const val inputFile = "src/main/resources/inputs/day4.txt" fun day4() { println("== DAY 4 ==") val timeTaken = measureTimeMillis { calculateAn...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
3,988
adventofcode2018
MIT License