path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/dev/shtanko/algorithms/leetcode/RangeSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,378
kotlab
Apache License 2.0
src/Day04.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
fun main() { fun part1(input: List<String>): Int { var pairs = 0 for (line: String in input) { val rawData = line.split(',').flatMap { it.split('-') }.map { it.toInt() } val firstPair = Pair(rawData[0], rawData[1]) val secondPair = Pair(rawData[2], rawData[3]) ...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
1,497
advent-of-code-2022
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2021/day18/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2021.day18 import com.kingsleyadio.adventofcode.util.readInput fun part1(input: List<String>): Int { return input.map(::parseMath).reduce { acc, math -> acc + math }.score() } fun part2(input: List<String>): Int { return sequence { for (i in input.indices) for (...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
3,879
adventofcode
Apache License 2.0
src/y2022/Day07.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2022 import utils.readInput import java.util.function.Predicate fun main() { fun parse(input: List<String>): Folder { val rootFolderName = input.first().split(" ")[2] var currentFolder = Folder(rootFolderName) val rootFolder = currentFolder input.drop(1).forEach { ...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
3,101
advent-of-code-kotlin
Apache License 2.0
src/day02/Day02.kt
Xlebo
572,928,568
false
{"Kotlin": 10125}
package day02 import getOrFetchInputData import readInput import kotlin.math.abs fun main() { val enemyInput = mapOf('A' to 1, 'B' to 2, 'C' to 3) val playerInput = mapOf('X' to 1, 'Y' to 2, 'Z' to 3) val incrementBasedOnResult = mapOf('X' to -1, 'Y' to 0, 'Z' to 1) fun determinePlayerInput(enemy: ...
0
Kotlin
0
0
cd718c2c7cb59528080d2aef599bd93e0919d2d9
1,772
aoc2022
Apache License 2.0
src/main/kotlin/adventofcode2023/day13/day13_2.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day13 import adventofcode2023.readInput import kotlin.math.min import kotlin.time.measureTime fun main() { println("Day 13") val input = readInput("day13") val puzzle2Duration = measureTime { println("Puzzle 2 ${puzzle2(input)}") } println("Puzzle 2 took $puzzle2D...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
4,632
adventofcode2023
MIT License
src/Day05.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
data class Move(val count: Int, val fromStack: Int, val toStack: Int) val stacks = listOf( listOf(), listOf('D', 'H', 'R', 'Z', 'S', 'P', 'W', 'Q'), listOf('F', 'H', 'Q', 'W', 'R', 'B', 'V'), listOf('H', 'S', 'V', 'C'), listOf('G', 'F', 'H'), listOf('Z', 'B', 'J', 'G', 'P'), listOf('L', 'F'...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
1,632
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/d2/d2.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d2 import readInput data class Res( val ABC : Char, val XYZ: Char) fun part1(input: List<String>): Int { var score = 0 val rules = mapOf( Res('A', 'X') to 3, Res('B', 'X') to 0, Res('C', 'X') to 6, Res('A', 'Y') to 6, Res('B', 'Y') to 3, Res('C', 'Y') t...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
1,682
aoc2022
Creative Commons Zero v1.0 Universal
src/Day05.kt
bendh
573,833,833
false
{"Kotlin": 11618}
fun main() { fun readInitialSupplyStackData(input: List<String>): List<ArrayDeque<String>> { // Create deque val supplyStackData = input.subList(0, input.indexOf("")) val lastStackNumber = supplyStackData.last().last().digitToInt() val supplyStacks = (1..lastStackNumber).map { Array...
0
Kotlin
0
0
e3ef574441b63a99a99a095086a0bf025b8fc475
3,122
advent-of-code-2022-kotlin
Apache License 2.0
day6/src/main/kotlin/Main.kt
joshuabrandes
726,066,005
false
{"Kotlin": 47373}
import java.io.File fun main() { println("------ Advent of Code 2023 - Day 6 -----") val puzzleInput = getPuzzleInput() val races = getRaces(puzzleInput) val waysToWin = races .map { it.numberOfWaysToWin() } .reduce { acc, i -> acc * i } println("Task 1: Number of ways to win all ...
0
Kotlin
0
1
de51fd9222f5438efe9a2c45e5edcb88fd9f2232
2,209
aoc-2023-kotlin
The Unlicense
src/days/day3/Day3.kt
Riven-Spell
113,698,657
false
{"Kotlin": 25729}
package days.day3 import kotlin.math.* fun day3p1(s: String) : String { val x = s.toInt() val upper = (1..x step 2).first { it * it >= x } val xdist = abs((x % upper) - ((upper / 2) + 1)) - if(sqrt(x.toFloat()).toInt().toFloat().pow(2).toInt() == x) 1 else 0 val ydist = upper / 2 return (xdist + y...
0
Kotlin
0
1
dbbdb390a0addee98c7876647106af208c3d9bc7
2,124
Kotlin-AdventOfCode-2017
MIT License
src/Day07.kt
ajspadial
573,864,089
false
{"Kotlin": 15457}
abstract class DirectoryElement(val name: String) { abstract fun getSize(): Int } class Directory(name: String, val parent: Directory?) : DirectoryElement(name) { val elements = mutableListOf<DirectoryElement>() override fun getSize(): Int { return elements.sumOf { it.getSize()} } } class File...
0
Kotlin
0
0
ed7a2010008be17fec1330b41adc7ee5861b956b
3,642
adventofcode2022
Apache License 2.0
day4/src/main/kotlin/day4/Main.kt
ErikHellman
433,722,039
false
{"Kotlin": 9432}
package day4 import java.io.File import java.util.regex.Pattern fun main(args: Array<String>) { val lines = loadFile("input.txt") val numbersDrawn = lines[0] val boards = lines.drop(1) .chunked(5) .map { board -> board.map { line -> line.map { it to false }.toMutableList() }.to...
0
Kotlin
0
1
37f54d52633fff5f6fdd9e66926c57421fc721d2
2,815
advent-of-code-2021
Apache License 2.0
src/Day02.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>): Int = input .map { (it.first() - 'A') to (it.last() - 'X') } .sumOf { (first, second) -> val move = second + 1 // [1, 3] val round = when (second - first) { 0 -> 3 // draw 1, -2 -> 6 // win ...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
1,109
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/sh/weller/aoc/Day07.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day07 : SomeDay<Pair<String, Int>, Int> { override fun partOne(input: List<Pair<String, Int>>): Int { return input .map { (handString, bet) -> Hand.fromString(handString) to bet } .sortedBy { it.first.handValue } ....
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
6,470
AdventOfCode
MIT License
src/_2022/Day02.kt
albertogarrido
572,874,945
false
{"Kotlin": 36434}
package _2022 import readInput import java.lang.IllegalArgumentException fun main() { val input = readInput("2022", "day02") println(part1(input)) println(part2(input)) } // part 1 private fun part1(input: List<String>): Int { var points = 0 input.forEach { round -> val (opponent, player)...
0
Kotlin
0
0
ef310c5375f67d66f4709b5ac410d3a6a4889ca6
2,970
AdventOfCode.kt
Apache License 2.0
src/Day05.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
typealias Stacks = Array<MutableList<Char>> data class Move(val count: Int, val from: Int, val to: Int) typealias Moves = List<Move> data class Input(val stacks: Stacks, val moves: Moves) { companion object { fun parse(input: List<String>): Input { val at = input.indexOf("") val co...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
2,116
aockt
Apache License 2.0
src/Day02.kt
niltsiar
572,887,970
false
{"Kotlin": 16548}
fun main() { fun part1(input: List<String>): Int { val game = mapOf( "A X" to 1 + 3, "A Y" to 2 + 6, "A Z" to 3 + 0, "B X" to 1 + 0, "B Y" to 2 + 3, "B Z" to 3 + 6, "C X" to 1 + 6, "C Y" to 2 + 0, "C ...
0
Kotlin
0
0
766b3e168fc481e4039fc41a90de4283133d3dd5
1,112
advent-of-code-kotlin-2022
Apache License 2.0
src/day18/Day18.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day18 import readInput import kotlin.math.abs fun main() { data class Cube( val x: Int, val y: Int, val z: Int, ) { fun getPosition(): List<Int> { return listOf(x, y, z) } } fun Cube.checkTouching(to: Cube): Boolean { return (this....
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
3,262
advent-of-code-kotlin-2022
Apache License 2.0
src/Day11.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
private data class Monkey( val id: Int, val items: MutableList<Long>, val op: (Long) -> Long, val testDivisibleBy: Long, val successReceiverIndex: Int, val failureReceiverIndex: Int, ) { var inspectedItemsCount: Long = 0 } private fun parseOperation(input: String): (Long) -> Long { val ...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
3,357
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day11.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days import xyz.hughjd.aocutils.Coords.Coord class Day11 : Day(11) { override fun partOne(): Any { return sumOfShortestPaths(2) } override fun partTwo(): Any { val factors = listOf( sumOfShortestPaths(1), sumOfShortestPaths(10), sumOfShortestPa...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
2,347
aoc-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day02.kt
alex859
573,174,372
false
{"Kotlin": 80552}
import Choice.* import FixedResult.* fun main() { val testInput = readInput("Day02_test.txt") check(testInput.total { it.toRound().myScore } == 15) check(testInput.total { it.toRoundFixing().toRound().myScore } == 12) val input = readInput("Day02.txt") println(input.total { it.toRound().myScore })...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
3,205
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Solution11.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf object Solution11 : Solution<List<CharArray>>(AOC_YEAR, 11) { override fun getInput(handler: InputHandler) = handler.getInput("\n").map(String::toCharArray) private fun getDistanceSum( galaxies:...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
1,840
Advent-of-Code-2023
MIT License
src/Day03.kt
dcbertelsen
573,210,061
false
{"Kotlin": 29052}
import java.io.File fun main() { fun part1(input: List<String>): Int { return input.map { sack -> sack.bisect() } .map { parts -> parts.first.intersect(parts.second).first() } .sumOf { it.toScore() } } fun part2(input: List<String>): Int { return input.chunked(3) ...
0
Kotlin
0
0
9d22341bd031ffbfb82e7349c5684bc461b3c5f7
1,395
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/mirecxp/aoc23/day08/Day08.kt
MirecXP
726,044,224
false
{"Kotlin": 42343}
package mirecxp.aoc23.day08 import mirecxp.aoc23.readInput //https://adventofcode.com/2023/day/8 class Day08(private val inputPath: String) { private var lines: List<String> = readInput(inputPath).toMutableList() val keys = lines[0] var keyIndex = 0 fun getNextKey(): Char { val key = keys[k...
0
Kotlin
0
0
6518fad9de6fb07f28375e46b50e971d99fce912
3,209
AoC-2023
MIT License
src/Day02.kt
atsvetkov
572,711,515
false
{"Kotlin": 10892}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { Shape.parse(it.split(' ')[0]).play(Shape.parse(it.split(' ')[1])) } } fun part2(input: List<String>): Int { return input.sumOf { Shape.parse(it.split(' ')[0]).play(Shape.parse(it.split(' ')[0]).counterpartByOutcome(Outc...
0
Kotlin
0
0
01c3bb6afd658a2e30f0aee549b9a3ac4da69a91
2,662
advent-of-code-2022
Apache License 2.0
src/aoc2022/day03/Day03.kt
svilen-ivanov
572,637,864
false
{"Kotlin": 53827}
package aoc2022.day03 import readInput fun priority(char: Char): Int { return when { ('a'..'z').contains(char) -> 1 + char.code - 'a'.code ('A'..'Z').contains(char) -> 27 + char.code - 'A'.code else -> error("") } } fun main() { fun part1(input: List<String>) { var sum = 0...
0
Kotlin
0
0
456bedb4d1082890d78490d3b730b2bb45913fe9
1,525
aoc-2022
Apache License 2.0
src/Day02.kt
dominik003
573,083,805
false
{"Kotlin": 9376}
fun main() { fun part1(input: List<String>): Int { val scoreMap = mapOf("X" to 1, "Y" to 2, "Z" to 3) val winMap = mapOf("X" to "C", "Y" to "A", "Z" to "B") val drawMap = mapOf("X" to "A", "Y" to "B", "Z" to "C") var score = 0 input.forEach { val parts = it.split...
0
Kotlin
0
0
b64d1d4c96c3dd95235f604807030970a3f52bfa
1,645
advent-of-code-2022
Apache License 2.0
src/Day11.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
fun solveDay11() { val input = readInputString("Day11") val monkeys = parseMonkeys(input) solve( monkeys = parseMonkeys(input), rounds = 20, message = "Solution for part 1: ", worryLevelOperation = { it / 3 }, ) val gcd = monkeys.map { it.testDivisibleBy }.reduce { ...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
3,335
AoC-2022
Apache License 2.0
src/Day05.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
fun main() { fun <T> List<List<T>>.rowToColumn(): List<List<T>> = first().indices .map { row -> indices.map { col -> this[col][row] } } fun List<List<Char>>.toTopStack(): String = map { it.last() }.joinToString("") fun parse(input: List<String>): Pair<List<MutableList<Char>>, ...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
3,547
AdventOfCode2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day04.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year21 import com.grappenmaker.aoc.PuzzleSet import kotlin.math.floor // 5x5 const val BOARD_SIZE = 5 val spacePattern = """\s+""".toRegex() fun PuzzleSet.day4() = puzzle(day = 4) { // Part one val lines = inputLines // Read numbers val numbers = lines.first().split(",")...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,894
advent-of-code
The Unlicense
src/main/kotlin/com/ginsberg/advent2019/Day12.kt
tginsberg
222,116,116
false
null
/* * Copyright (c) 2019 by <NAME> */ /** * Advent of Code 2019, Day 12 - The N-Body Problem * Problem Description: http://adventofcode.com/2019/day/12 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day12/ */ package com.ginsberg.advent2019 import org.apache.commons.math3.util.Arithme...
0
Kotlin
2
23
a83e2ecdb6057af509d1704ebd9f86a8e4206a55
2,451
advent-2019-kotlin
Apache License 2.0
src/Day01.kt
ChristianNavolskyi
573,154,881
false
{"Kotlin": 29804}
import kotlin.math.max import kotlin.time.ExperimentalTime import kotlin.time.measureTime @ExperimentalTime fun main() { fun part1(input: List<String>): Int { return input.toMutableList().apply { add("") }.fold(listOf(-1, 0)) { acc, calories -> if (calories.isEmpty()) { listOf(m...
0
Kotlin
0
0
222e25771039bdc5b447bf90583214bf26ced417
1,990
advent-of-code-2022
Apache License 2.0
src/exercises/Day15.kt
Njko
572,917,534
false
{"Kotlin": 53729}
// ktlint-disable filename package exercises import readInput import kotlin.math.abs data class Scan( val sensorAtX: Int, val sensorAtY: Int, val closestBeaconAtX: Int, val closestBeaconAtY: Int, val distance: Int ) fun main() { fun extractScans(data: List<String>): List<Scan> { val p...
0
Kotlin
0
2
68d0c8d0bcfb81c183786dfd7e02e6745024e396
3,933
advent-of-code-2022
Apache License 2.0
src/Day04.kt
asm0dey
572,860,747
false
{"Kotlin": 61384}
fun main() { fun rangeToSet(textRange: List<String>) = (textRange[0].toInt()..textRange[1].toInt()).toSet() fun part1(input: List<String>): Int { return input .asSequence() .map { it.split(',') } .filter { it.size == 2 } .map { it.map { range -> range.sp...
1
Kotlin
0
1
f49aea1755c8b2d479d730d9653603421c355b60
996
aoc-2022
Apache License 2.0
2023/src/main/kotlin/day10.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.MutableIntGrid import utils.Parser import utils.Solution import utils.Vec2i import utils.borderWith import utils.expand import utils.map import utils.toMutable fun main() { Day10.run() } private fun guessStart(g: Grid<Char>, s: Vec2i): List<Char> { val up = s.y > 2 && g[s.x][s.y - 2...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
4,056
aoc_kotlin
MIT License
y2021/src/main/kotlin/adventofcode/y2021/Day08.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day08 : AdventSolution(2021, 8, "Seven Segment Search") { override fun solvePartOne(input: String) = parseInput(input).flatMap(DecodingProblem::message).count { it.size in listOf(2, 3, 4, 7) } override fun solvePartTwo(input: St...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,844
advent-of-code
MIT License
y2023/src/main/kotlin/adventofcode/y2023/Day21.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import adventofcode.util.vector.neighbors fun main() { Day21.solve() } object Day21 : AdventSolution(2023, 21, "Step Counter") { override fun solvePartOne(input: String): Int { val path = parse(inpu...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
3,676
advent-of-code
MIT License
src/Day06.kt
paul-matthews
433,857,586
false
{"Kotlin": 18652}
fun List<String>.getLanternfish(): Shoal = fold(mutableListOf()) {acc, s -> acc.addAll(s.split(",").toInts()) acc } typealias GroupedShoal = Map<Int, Long> fun Shoal.toGroupedShoal(): GroupedShoal = fold(mutableMapOf()) { acc, fish -> acc[fish] = (acc.get(fish) ?: 0L) + 1 acc } fun GroupedShoal.newDa...
0
Kotlin
0
0
2f90856b9b03294bc279db81c00b4801cce08e0e
1,459
advent-of-code-kotlin-template
Apache License 2.0
src/Day04.kt
Akaneiro
572,883,913
false
null
fun main() { fun List<String>.makeIntervals() = this .map {// convert to list of intervals like listOf([2,3,4], [6,7,8]) it.split(",") .map { val values = it.split("-") val intRange = values.first().toInt()..val...
0
Kotlin
0
0
f987830a70a2a1d9b88696271ef668ba2445331f
1,343
aoc-2022
Apache License 2.0
src/aoc2022/day02/AoC02.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day02 import readLines enum class Hand { Rock, Paper, Scissors; val value = ordinal + 1 companion object { infix fun from(ch: Char) = when (ch) { 'A', 'X' -> Rock 'B', 'Y' -> Paper else -> Scissors } } fun circularNext() = values()[(ordinal + 1) % values().size] fun circula...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
1,347
aoc2022
Apache License 2.0
src/year_2022/day_05/Day05.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_05 import readInput data class Rearrangement( val quantity: Int, val from: Int, val to: Int ) object Day05 { /** * @return */ fun solutionOne(text: List<String>): String { val stacks = parseContainers(text) val rearrangements = parseRearrangements(...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
3,362
advent_of_code
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day264/day264.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day264 // day264.kt // By <NAME>, 2019. import kotlin.math.pow // Generate k-ary deBruijn sequences covering words of length n. // We don't bother using an alphabet: this can just be mapped back and forth if wanted, and we switched k for n. fun deBruijn(k: Int, n: Int): List<Int> { // Generate all the...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,481
daily-coding-problem
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[56]合并区间.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.lang.Integer.compare import java.util.* //以数组 intervals 表示若干个区间的集合,其中单个区间为 intervals[i] = [starti, endi] 。请你合并所有重叠的区间,并返 //回一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间。 // // // // 示例 1: // // //输入:intervals = [[1,3],[2,6],[8,10],[15,18]] //输出:[[1,6],[8,10],[15,18]] //解释:区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. // // // 示...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,756
MyLeetCode
Apache License 2.0
src/Day12.kt
szymon-kaczorowski
572,839,642
false
{"Kotlin": 45324}
fun main() { data class Node( val letter: Char, var visited: Boolean = false, var shortest: Int = Int.MAX_VALUE, ) fun canMove(current: Char, next: Char): Boolean { if (current == 'S' && next == 'a') return true if (current == 'z' && next == 'E') return true ...
0
Kotlin
0
0
1d7ab334f38a9e260c72725d3f583228acb6aa0e
6,881
advent-2022
Apache License 2.0
src/Day05.kt
mddanishansari
576,622,315
false
{"Kotlin": 11861}
import java.util.* fun main() { data class Move(val amount: Int, val from: Int, val to: Int) data class Input(val stacks: Map<Int, Stack<Char>>, val moves: List<Move>) fun MutableMap<Int, Stack<Char>>.insertCrate(stackNumber: Int, crate: Char) { if (crate == ' ') return if (this[stackNum...
0
Kotlin
0
0
e032e14b57f5e6c2321e2b02b2e09d256a27b2e2
2,831
advent-of-code-2022
Apache License 2.0
src/day7/newday.kt
mrm1st3r
573,163,888
false
{"Kotlin": 12713}
package day7 import Puzzle sealed class FilesystemEntry(val name: String) { abstract fun getSize(): Int } class File(name: String, private val size: Int) : FilesystemEntry(name) { override fun getSize(): Int = size } class Directory(name: String) : FilesystemEntry(name) { private val elements: MutableM...
0
Kotlin
0
0
d8eb5bb8a4ba4223331766530099cc35f6b34e5a
2,870
advent-of-code-22
Apache License 2.0
puzzles/src/main/kotlin/com/kotlinground/puzzles/arrays/maxnumberofksumpairs/maxNumberOfKSumPairs.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.puzzles.arrays.maxnumberofksumpairs /** * Finds the maximum number of operations that are required to find the 2 numbers that sum up to k. * * First the list is sorted in place(this is the assumption used, that it is allowed to sort the input list in place.). * Once the list is sorted, the...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,230
KotlinGround
MIT License
kotlin/src/2022/Day25_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
fun main() { val lines = readInput(25).trim().lines() val digitToSnafu = mapOf(-2 to '=', -1 to '-', 0 to '0', 1 to '1', 2 to '2') val snafuToDigit = digitToSnafu.entries.associate {it.value to it.key} // solution 1: sum the numbers by coordinates, then normalize the answer val N = lines.maxOf {i...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
2,024
adventofcode
Apache License 2.0
src/year2022/day25/Day25.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day25 import check import readInput import kotlin.math.abs import kotlin.math.pow fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("2022", "Day25_test") check(part1(testInput), "2=-1=0") val input = readInput("2022", "Day25")...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
2,064
AdventOfCode
Apache License 2.0
src/Day21.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
abstract class MonkeyFun { abstract val name: String abstract fun getValue(): Long open fun solveValue(ans: Long) = if (name == "humn") ans else getValue() fun isHuman(): Boolean { if (name == "humn") return true if (this is NumberMonkey) return false val nm = this as MathMon...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
3,602
aoc22
Apache License 2.0
src/Day09.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
class Position(var x: Int, var y: Int) class Knot(val name: String, val parent: Knot?){ val position = Position(0,0) fun followParent(){ if(parent == null) return if(parent.position.x !in this.position.x-1..this.position.x+1 || parent.position.y !in this.position.y-1..t...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
2,277
AoC2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/hard/MinDistance.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.hard /** * 72. 编辑距离 * * 给你两个单词 word1 和 word2,请你计算出将 word1 转换成 word2 所使用的最少操作数 。 * 你可以对一个单词进行如下三种操作: * * 插入一个字符 * 删除一个字符 * 替换一个字符 */ class MinDistance { companion object { @JvmStatic fun main(args: Array<String>) { println(MinDistance().minD...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,873
daily_algorithm
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2022/day07/day7.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day07 import biz.koziolek.adventofcode.findInput fun main() { val inputFile = findInput(object {}) val rootDir = parseTerminalOutput(inputFile.bufferedReader().readLines()) println(printTree(rootDir)) println("Total size of directories with a total size of a...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
5,054
advent-of-code
MIT License
src/main/kotlin/dev/tasso/adventofcode/_2022/day08/Day08.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2022.day08 import dev.tasso.adventofcode.Solution class Day08 : Solution<Int> { override fun part1(input: List<String>): Int = input.mapIndexed { yCoord, currRow -> currRow.mapIndexed{ xCoord, currHeight -> val coords = Pair(yCoord, xCoord) ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
2,618
advent-of-code
MIT License
src/days/Day04.kt
nicole-terc
574,130,441
false
{"Kotlin": 29131}
package days import readInput fun IntRange.contains(range: IntRange): Boolean { return this.contains(range.first) && this.contains(range.last) } fun IntRange.overlap(range: IntRange): Boolean { return this.contains(range.first) || this.contains(range.last) } fun main() { fun part1(input: List<String>) ...
0
Kotlin
0
2
9b0eb9b20e308e5fbfcb2eb7878ba21b45e7e815
1,171
AdventOfCode2022
Apache License 2.0
src/main/kotlin/y2023/day11/Day11.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2023.day11 import AoCGenerics import Coord import distance fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } private fun calculateGalaxyDistanceSum(expansionFactor: Int): Long { val galaxies = AoCGenerics.getInputLines("/y2023/day11/inp...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,396
AdventOfCode
MIT License
src/main/java/challenges/educative_grokking_coding_interview/merge_intervals/_3/Intersection.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.merge_intervals._3 import challenges.educative_grokking_coding_interview.merge_intervals.Interval import java.util.* object Intersection { private fun display(l1: List<Interval>): String { var resultStr = "[" for (i in 0 until l1.size - 1) { ...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,533
CodingChallenges
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/LongestCommonSubstring.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* The "Longest Common Substring" coding pattern is often used to solve problems where you need to find the longest common substring between two given strings. */ //1. Maximum Sum Increasing Subsequence fun maxSumIncreasingSubsequence(nums: IntArray): Int { val n = nums.size // Create an array to store the ma...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,409
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day5/Day5.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day5 import com.jacobhyphenated.advent2023.Day /** * Day 5: If You Give A Seed A Fertilizer * * The puzzle input is an almanac that describes the relationship between different gardening components * Seeds map to soil map to fertilizer etc until the end destination is locati...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
6,022
advent2023
The Unlicense
src/main/kotlin/days/Day8.kt
MisterJack49
729,926,959
false
{"Kotlin": 31964}
package days class Day8(alternate: Boolean = false) : Day(8, alternate) { override fun partOne() = inputList.let { val path = it.first().map { if (it == 'L') Direction.L else Direction.R } val network = it.drop(2).parseNetwork() for ((loc, step) in stepper("AAA", path,...
0
Kotlin
0
0
807a6b2d3ec487232c58c7e5904138fc4f45f808
2,118
AoC-2023
Creative Commons Zero v1.0 Universal
src/Day21.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
fun main() { data class Node(val name: String, var value: String? = null, var dependencies: MutableList<String> = mutableListOf<String>(), var operation: String = "") fun createNodeMap(input: String): MutableMap<String, Node> { var nodeMap = mutableMapOf<String, Node>() input.split("\n").forEac...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
3,633
aoc-kotlin
Apache License 2.0
src/Day12.kt
achugr
573,234,224
false
null
import java.util.* data class GridCell(val row: Int, val col: Int, val height: Int) data class PathNode(val cell: GridCell, var length: Int) : Comparable<PathNode> { override fun compareTo(other: PathNode): Int { return length.compareTo(other.length) } } class D12Grid(private val grid: List<List<I...
0
Kotlin
0
0
d91bda244d7025488bff9fc51ca2653eb6a467ee
3,222
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/headlessideas/adventofcode/december7/Balancer.kt
Nandi
113,094,752
false
null
package com.headlessideas.adventofcode.december7 import com.headlessideas.adventofcode.utils.readFile fun findBottom(programs: List<Program>): Program { val children = programs.flatMap { it.children } return programs.filter { it.children.isNotEmpty() && !children.contains(it) }[0] } fun findUnbalance(bottom:...
0
Kotlin
0
0
2d8f72b785cf53ff374e9322a84c001e525b9ee6
2,403
adventofcode-2017
MIT License
src/Day04.kt
Vincentvibe3
573,202,573
false
{"Kotlin": 8454}
fun main() { fun part1(input: List<String>): Int { var fullyContained = 0 for (line in input) { val pair = line.split(",").map { rangeString -> rangeString.split("-").map { it.toInt() } } if (pair[0][0]<=pair[1][...
0
Kotlin
0
0
246c8c43a416023343b3ef518ae3e21dd826ee81
1,313
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/mobiento/aoc/Day04.kt
markburk
572,970,459
false
{"Kotlin": 22252}
package com.mobiento.aoc fun Pair<Int, Int>.toSequence(): Set<Int> { val result = arrayListOf<Int>() for (x in first .. second) { result.add(x) } return result.toSet() } class Day04 { companion object { val regex = "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRegex() } fun part1(input...
0
Kotlin
0
0
d28656b4d54c506a01252caf6b493e4f7f97e896
2,150
potential-lamp
Apache License 2.0
src/main/kotlin/days/Extensions.kt
andilau
429,206,599
false
{"Kotlin": 113274}
package days import java.util.Collections.indexOfSubList fun String.toLongNumbers(): LongArray = split(",").map(String::toLong).toLongArray() fun lcm(x: Long, y: Long, vararg ints: Long): Long = ints.fold(x * y / gcd(x, y)) { acc, z -> lcm(acc, z) } fun gcd(a: Long, b: Long): Long { if (b == 0L) return ...
2
Kotlin
0
0
f51493490f9a0f5650d46bd6083a50d701ed1eb1
2,448
advent-of-code-2019
Creative Commons Zero v1.0 Universal
src/Day23.kt
RusticFlare
574,508,778
false
{"Kotlin": 78496}
private data class Pos(val row: Int, val col: Int) { val n get() = copy(row = row - 1) val ne get() = copy(row = row - 1, col = col + 1) val e get() = copy(col = col + 1) val se get() = copy(row = row + 1, col = col + 1) val s get() = copy(row = row + 1) val sw get() = copy(row = row + 1, col = ...
0
Kotlin
0
1
10df3955c4008261737f02a041fdd357756aa37f
4,324
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { fun contains(first: String, second: String): Boolean { val (aStart, aEnd) = first.split("-").map(String::toInt) val (bStart, bEnd) = second.split("-").map(String::toInt) return aStart <= bStart && aEnd >= bEnd || bStart <= aStart && bEnd >= aEnd } fun intersect(first:...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
1,197
aoc-2022
Apache License 2.0
src/main/kotlin/aoc23/Day15.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import common.Year23 import aoc23.Day15Domain.LensLibrary import aoc23.Day15Parser.toLensLibrary object Day15 : Year23 { fun List<String>.part1(): Int = toLensLibrary() .sumOfSteps() fun List<String>.part2(): Int = toLensLibrary() .apply { updateBoxes() }...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
2,535
aoc
Apache License 2.0
src/main/kotlin/com/github/pjozsef/WeightedRandom.kt
pjozsef
238,381,562
false
null
package com.github.pjozsef import java.util.Random class WeightedCoin(val trueProbability: Double, val random: Random = Random()) { init { require(trueProbability in 0.0..1.0) { "trueProbability must be between 0.0 and 1.0, but was: $trueProbability" } } fun flip(): Boolean {...
0
Kotlin
0
0
7337618c99095b103f858f4313e7e347a19e36f6
2,621
WeightedRandom
MIT License
src/Day04.kt
orirabi
574,124,632
false
{"Kotlin": 14153}
fun main() { fun parseSingleAssignment(str: String): Pair<Int, Int> { val assignment = str.split("-") check(assignment.size == 2) return assignment.first().toInt() to assignment.last().toInt() } fun parseToPairs(str: String): Pair<Pair<Int, Int>, Pair<Int, Int>> { val assig...
0
Kotlin
0
0
41cb10eac3234ae77ed7f3c7a1f39c2f9d8c777a
1,594
AoC-2022
Apache License 2.0
src/Day09.kt
karloti
573,006,513
false
{"Kotlin": 25606}
/* import kotlin.math.absoluteValue import kotlin.math.sign data class Point(val x: Int, val y: Int) { operator fun plus(other: Point): Point = Point(x + other.x, y + other.y) infix fun moveTo(d: Point): Point = takeIf { (x - d.x).absoluteValue <= 1 && (y - d.y).absoluteValue <= 1 } ?: Point(x + (d.x -...
0
Kotlin
1
2
39ac1df5542d9cb07a2f2d3448066e6e8896fdc1
1,382
advent-of-code-2022-kotlin
Apache License 2.0
src/Day02.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
enum class Hand(val score: Int) { ROCK(1), PAPER(2), SCISSOR(3); } enum class Result(val score: Int) { LOSE(0) { override fun playFor(other: Hand): Hand = when (other) { Hand.ROCK -> Hand.SCISSOR Hand.PAPER -> Hand.ROCK Hand.SCISSOR ->...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
2,307
advent-of-code-2022
Apache License 2.0
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day11/day11.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2023.day11 import eu.janvdb.aocutil.kotlin.point2d.Point2DLong import eu.janvdb.aocutil.kotlin.readLines //private const val FILENAME = "input11-test.txt" private const val FILENAME = "input11.txt" fun main() { runWithDrift(1) runWithDrift(999_999) } private fun runWithDrift(drift: Int) { v...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,766
advent-of-code
Apache License 2.0
src/Day18.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import kotlin.math.max fun main() { val testInput = readInput("Day18_test") check(part1(testInput) == 64) check(part2(testInput) == 58) val input = readInput("Day18") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val cubes = input.to3DMatrix()...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
3,277
AOC2022
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/repair/ContextualEdits.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.repair import ai.hypergraph.kaliningraph.parsing.* import kotlin.random.Random enum class EditType { INS, DEL, SUB } data class ContextEdit(val type: EditType, val context: Context, val newMid: String) { override fun toString(): String = context.run { "$type, (( " + when (type...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
6,874
galoisenne
Apache License 2.0
src/day08/Day08.kt
marcBrochu
573,884,748
false
{"Kotlin": 12896}
package day08 import readInput import java.lang.Integer.max fun main() { fun part1(input: List<String>): Int { val height = input.size val width = input.first().length val grid = input.map { it.map { it.digitToInt() } } var numVisible = 0 for (h in 0 until height) { ...
0
Kotlin
0
2
8d4796227dace8b012622c071a25385a9c7909d2
2,936
advent-of-code-kotlin
Apache License 2.0
src/Day11.kt
SergeiMikhailovskii
573,781,461
false
{"Kotlin": 32574}
fun main() { val input = readInput("Day11_test") val monkeys = mutableListOf<Monkey>() val divideOnList = mutableListOf<Int>() input.filter { it.isNotEmpty() }.chunked(6).forEach { val items = it[1].substringAfterLast("Starting items: ").split(", ").map(String::toInt) val operation = it[...
0
Kotlin
0
0
c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d
2,946
advent-of-code-kotlin
Apache License 2.0
src/day7/Day7.kt
bartoszm
572,719,007
false
{"Kotlin": 39186}
package day7 import readInput import java.util.* fun main() { val testInput = readInput("day07/test") val input = readInput("day07/input") println(solve1(testInput)) println(solve1(input)) println(solve2(testInput)) println(solve2(input)) } fun dirSizes(lines: List<String>) : Sequence<Int>...
0
Kotlin
0
0
f1ac6838de23beb71a5636976d6c157a5be344ac
1,675
aoc-2022
Apache License 2.0
src/day5/Day05.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day5 import readTextGroups import java.util.* fun main() { val (testStacksInput, testProcedureInput) = readTextGroups("day5/Day05_test") check(Day.part1(getStacks(testStacksInput), getProcedure(testProcedureInput)) == "CMZ") val (stackInput, procedureInput)= readTextGroups("day5/Day05") print...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,829
advent-of-code-2022
Apache License 2.0
02/02.kt
Steve2608
433,779,296
false
{"Python": 34592, "Julia": 13999, "Kotlin": 11412, "Shell": 349, "Cython": 211}
import java.io.File import kotlin.math.abs private data class Direction(val direction: String, val length: Int) { fun toVec2(): Vec2 = when (direction) { "forward" -> Vec2(length, 0) "down" -> Vec2(0, length) "up" -> Vec2(0, -length) else -> throw IllegalArgumentException(direction) } fun toVec3(): Vec3 = ...
0
Python
0
1
2dcad5ecdce5e166eb053593d40b40d3e8e3f9b6
1,567
AoC-2021
MIT License
src/2022/Day23.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun processRound(elfPositions: Set<Point>, directions: List<Direction>): Set<Point> { val currentToNext: MutableMap<Point, Point> = mutableMapOf() val proposeToCurrent: MutableMap<Point, Point> = mutableMapOf() elfPositions.forEach { point -> ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
3,963
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
fun main() { fun isFullOverlap(a: List<String>, b: List<String>): Boolean = (a.first().toInt() <= b.first().toInt() && a.last().toInt() >= b.last().toInt()) || (b.first() .toInt() <= a.first().toInt() && b.last().toInt() >= a.last().toInt()) fun isPartialOverlap(a: List<String>, b: List<Str...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
1,045
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
halirutan
575,809,118
false
{"Kotlin": 24802}
fun main() { val rules = mapOf( Pair("A", "X") to 1 + 3, Pair("A", "Y") to 2 + 6, Pair("A", "Z") to 3 + 0, Pair("B", "X") to 1 + 0, Pair("B", "Y") to 2 + 3, Pair("B", "Z") to 3 + 6, Pair("C", "X") to 1 + 6, Pair("C", "Y") to 2 + 0, Pair("C", "Z...
0
Kotlin
0
0
09de80723028f5f113e86351a5461c2634173168
1,852
AoC2022
Apache License 2.0
src/main/kotlin/com/oocode/CamelMap.kt
ivanmoore
725,978,325
false
{"Kotlin": 42155}
package com.oocode fun directionsFrom(input: String): CamelMap { val lines = input.split("\n") val instructions = lines[0] .map { if (it == 'L') Choice.Left else Choice.Right } val nodes = lines.drop(2).map { nodeFrom(it) } return CamelMap(instructions, nodes) } enum class Choice { Left, Right...
0
Kotlin
0
0
36ab66daf1241a607682e7f7a736411d7faa6277
2,330
advent-of-code-2023
MIT License
src/main/aoc2021/Day21.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2021 class Day21(input: List<String>) { private val p1start = input.first().last().digitToInt() private val p2start = input.last().last().digitToInt() class Player(var pos: Int, var score: Int) { // Move the player and return true if the player won fun move(howMuch: Int): Boole...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,308
aoc
MIT License
src/Day02.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
enum class Roshambo(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3) } val winningMap = mapOf( Roshambo.ROCK to Roshambo.PAPER, Roshambo.PAPER to Roshambo.SCISSORS, Roshambo.SCISSORS to Roshambo.ROCK ) fun main() { fun part1(input: List<String>): Int { val roshamboMap = mapOf( ...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
1,983
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc19/Day3.kt
tahlers
225,198,917
false
null
package aoc19 import kotlin.math.abs object Day3 { enum class Direction { UP, DOWN, LEFT, RIGHT } data class Step(val direction: Direction, val distance: Int) { fun positions(startPos: Pos): List<Pos> { return when (direction) { Direction.UP -> ((startPos.y + 1)..(startPo...
0
Kotlin
0
0
dae62345fca42dd9d62faadf78784d230b080c6f
3,023
advent-of-code-19
MIT License
2021/08-kt/main.kt
20Koen02
433,861,042
false
{"Rust": 84471, "TypeScript": 52261, "Python": 18461, "JavaScript": 2098, "Go": 1516, "Nim": 1501, "Kotlin": 1499, "Java": 1201, "C++": 853}
import java.io.File import kotlin.collections.listOf typealias Entry = List<List<String>> val DIGS = listOf("abcdeg", "ab", "acdfg", "abcdf", "abef", "bcdef", "bcdefg", "abd", "abcdefg", "abcdef") fun readLines(): List<Entry> { return File("in.txt").bufferedReader().readLines().map { l -> l.split(" | ").ma...
0
Rust
1
2
e260249e488b24f0fcf7b5df16cc65f126dd7425
1,499
AdventOfCode
MIT License
src/Day02.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
import MatchResult.* enum class HandSign( val opponentValue: String, val myValue: String, ) { Rock("A", "X"), Paper("B", "Y"), Scissors("C", "Z"); val score = ordinal + 1 val weakness: HandSign get() = when (this) { Rock -> Paper Paper -> Scissors ...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
2,458
advent-of-code-2022
Apache License 2.0
src/year_2022/day_12/Day12.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_12 import readInput import util.toAlphabetPosition data class Position( val row: Int, val column: Int ) data class Heatmap ( val startingPosition: Position, val endingPosition: Position, val locations: List<List<Int>> ) object Day12 { /** * @return */ fun...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
5,691
advent_of_code
Apache License 2.0
AOC-2023/src/main/kotlin/Day03.kt
sagar-viradiya
117,343,471
false
{"Kotlin": 72737}
import utils.splitAtNewLines import kotlin.math.pow enum class Move(val direction: Pair<Int, Int>) { LEFT(Pair(0, -1)), RIGHT(Pair(0, 1)), UP(Pair(-1, 0)), DOWN(Pair(1, 0)), TOP_LEFT(Pair(-1, -1)), TOP_RIGHT(Pair(-1, 1)), BOTTOM_LEFT(Pair(1, -1)), BOTTOM_RIGHT(Pair(1, 1)) } object Day0...
0
Kotlin
0
0
7f88418f4eb5bb59a69333595dffa19bee270064
5,124
advent-of-code
MIT License
src/Day03.kt
jaldhar
573,188,501
false
{"Kotlin": 14191}
class Score { companion object { private val scores = mutableMapOf<Char, Int>() init { var v = 1; for (k in (('a' .. 'z') + ('A' .. 'Z'))) { scores[k] = v++ } } fun get(v: Char): Int { return scores[v] ?: 0 } ...
0
Kotlin
0
0
b193df75071022cfb5e7172cc044dd6cff0f6fdf
1,361
aoc2022-kotlin
Apache License 2.0
kotlin/src/main/kotlin/AoC_Day19.kt
sviams
115,921,582
false
null
object AoC_Day19 { fun parseMap(lines: List<String>) : List<List<Char>> = lines.map { line -> line.toCharArray().toList() } data class Direction(val x: Int, val y: Int, val token: Char) data class State(val x: Int, val y: Int, val dir: Direction, val seen: List<Char>, val count: Int) val validChars =...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
1,904
aoc17
MIT License
kotlin/src/katas/kotlin/leetcode/compare_strings/CompareStrings.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.compare_strings import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/discuss/interview-question/352458/Google-or-OA-Fall-Internship-2019-or-Compare-Strings */ class CompareStringsTests { @Test fun `count smaller strings examples`() { countSmallerString...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,885
katas
The Unlicense
src/Day04.kt
psabata
573,777,105
false
{"Kotlin": 19953}
fun main() { fun part1(input: List<Entry>): Int { return input.count { it.range1.contains(it.range2) || it.range2.contains(it.range1) } } fun part2(input: List<Entry>): Int { return input.count { it.range1.overlaps(it.range2) || it.range2.overlaps(it.rang...
0
Kotlin
0
0
c0d2c21c5feb4ba2aeda4f421cb7b34ba3d97936
1,189
advent-of-code-2022
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day4/Day4.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day4 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 4](https://adventofcode.com/2021/day/4) */ object Day4 : DayOf2021(4) { override fun first(): Any? { val values = lines .first()...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,127
adventofcode
MIT License
src/main/kotlin/days/aoc2015/Day17.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2015 import days.Day class Day17: Day(2015, 17) { override fun partOne(): Any { return calculatePartOne(150) } override fun partTwo(): Any { return calculatePartTwo(150) } fun calculatePartTwo(target: Int): Int { val containers = inputList.map { it.toInt()...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,916
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/lucaszeta/adventofcode2020/day16/day16.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day16 import com.lucaszeta.adventofcode2020.ext.getResourceAsText fun main() { val input = getResourceAsText("/day16/ticket-notes.txt") val ticketFields = extractTicketFields(input) val nearbyTickets = extractNearbyTickets(input) val invalidValues = findInvalid...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
2,002
advent-of-code-2020
MIT License