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
advent-of-code-2023/src/test/kotlin/Day7Test.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test /** --- Day 7: Camel Cards --- */ class Day7Test { private val testInput = """ 32T3K 765 T55J5 684 KK677 28 KTJJT 220 QQQJA 483 """ .trimIndent() private val silverComparator = co...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
6,346
advent-of-code
MIT License
src/day02/Day02.kt
Regiva
573,089,637
false
{"Kotlin": 29453}
package day02 import readText fun main() { fun readGuide(fileName: String): Sequence<List<String>> { return readText(fileName) .splitToSequence("\n") .map { it.split(" ") } } val scoresMatrix = arrayOf( intArrayOf(4, 8, 3), intArrayOf(1, 5, 9), int...
0
Kotlin
0
0
2d9de95ee18916327f28a3565e68999c061ba810
1,206
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day18/Day18.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day18 import com.tonnoz.adventofcode23.utils.println import com.tonnoz.adventofcode23.utils.readInput import kotlin.math.abs import kotlin.system.measureTimeMillis object Day18 { @JvmStatic fun main(args: Array<String>) { val input = "input18.txt".readInput() println("ti...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,116
adventofcode23
MIT License
src/Day15.kt
robinpokorny
572,434,148
false
{"Kotlin": 38009}
import kotlin.math.* private data class Sensor( val position: Point, val minBeacon: Point, val distance: Int ) private val lineRe = Regex("Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)") private fun parse(input: List<String>): List<Sensor> = input .map { line -> ...
0
Kotlin
0
2
56a108aaf90b98030a7d7165d55d74d2aff22ecc
3,190
advent-of-code-2022
MIT License
src/main/kotlin/TrenchMap_20.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
fun getTrenchMap(): TrenchMapInput { val lines = readFile("TrenchMap").split("\n") val enhancer = lines[0].map { if (it == '#') '1' else '0' } val image = Array(lines.size - 2) { CharArray(lines[2].length) { '0' } } lines.drop(2).forEachIndexed { index, line -> line.forEachIndexed { sIndex, char...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
2,178
advent-of-code-2021
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/AdajacenyList.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.graph import java.util.* fun main() { // val adjL = AdajacenyList(7) // adjL.accept(Scanner(System.`in`)) // adjL.display() val visited: BooleanArray = BooleanArray(7) { false } val adjacencyList = AdjacencyList() val graph = adjacencyList.buildGraph() ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
4,140
DS_Algo_Kotlin
MIT License
src/year2021/17/Day17.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
private data class TargetPoint( val x: Int, val y: Int ) { fun applySpeed(speed: TargetPoint): TargetPoint { return TargetPoint( x + speed.x, y + speed.y, ) } fun correctSpeed(): TargetPoint { return TargetPoint( x = (x - 1).coerceAtLeast...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
3,373
KotlinAdventOfCode
Apache License 2.0
src/Day18.kt
simonbirt
574,137,905
false
{"Kotlin": 45762}
fun main() { Day18.printSolutionIfTest(64, 58) } object Day18 : Day<Int, Int>(18) { override fun part1(lines: List<String>): Int { val cubes = build(lines).values.filter { !it.air } return cubes.flatMap { c -> c.faces.values }.count { it } } override fun part2(lines: List<String>): In...
0
Kotlin
0
0
962eccac0ab5fc11c86396fc5427e9a30c7cd5fd
4,688
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/Coord2D.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode import kotlin.math.abs data class Coord2D(val x: Int, val y: Int) { companion object { fun parse(input: String) = input.split(",").let { (x, y) -> Coord2D(x.toInt(), y.toInt()) } } override fun toString() = "[$x, $y]" val manhattanDist: Int g...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,669
advent-of-code
MIT License
y2015/src/main/kotlin/adventofcode/y2015/Day17.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2015 import adventofcode.io.AdventSolution object Day17 : AdventSolution(2015, 17, "No Such Thing as Too Much") { override fun solvePartOne(input: String) = input.lines() .map { it.toInt() } .let { partitions(it, 150) } override fun solvePartTwo(input: String) = input.lines() .map {...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
964
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CriticalConnections.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
5,429
kotlab
Apache License 2.0
src/day1/Code.kt
fcolasuonno
221,697,249
false
null
package day1 import java.io.File import kotlin.math.abs fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${p...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
2,228
AOC2016
MIT License
2019/day3/part_b.kt
sergeknystautas
226,467,020
false
null
package aoc2019.day3; import kotlin.math.abs; /* Takes a sequence like U7,R6,D4,L4 and creates a sequence of spots this goes thru like... []"1,0","2,0","3,0", etc...] */ fun followWire(instructions: String): List<String> { // Assume we start at 0,0 var pos = Pair(0,0); var path = mutableListOf<String>(...
0
Kotlin
0
0
38966bc742f70122681a8885e986ed69dd505243
1,940
adventofkotlin2019
Apache License 2.0
src/day03/Day03.kt
S-Flavius
573,063,719
false
{"Kotlin": 6843}
package day03 import readInput import kotlin.concurrent.fixedRateTimer fun main() { fun part1(input: List<String>): Int { var prioSum = 0 for (line in input) { var common = ' ' val compOne = line.substring(0, line.length / 2) val compTwo = line.substring(line....
0
Kotlin
0
0
47ce29125ff6071edbb07ae725ac0b9d672c5356
1,799
AoC-Kotlin-2022
Apache License 2.0
src/Day12.kt
a-glapinski
572,880,091
false
{"Kotlin": 26602}
import utils.Coordinate2D import utils.readInputAsLines fun main() { val input = readInputAsLines("day12_input") val heightmap = input.flatMapIndexed { i, row -> row.mapIndexed { j, height -> Coordinate2D(i, j) to height } }.toMap() fun reach(startElevation: Char, destinationElevation: Char): Int ...
0
Kotlin
0
0
c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8
1,729
advent-of-code-2022
Apache License 2.0
src/main/kotlin/nl/dirkgroot/adventofcode/year2020/Day18.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2020 import nl.dirkgroot.adventofcode.util.Input import nl.dirkgroot.adventofcode.util.Puzzle class Day18(input: Input) : Puzzle() { private val tokenRegex = "\\s*(\\d+|\\+|\\*|\\(|\\))".toRegex() abstract class Token object Plus : Token() object Star : Token() ...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
4,495
adventofcode-kotlin
MIT License
src/main/kotlin/solutions/Day07.kt
chutchinson
573,586,343
false
{"Kotlin": 21958}
class Day07 : Solver { open class Node (val parent: Node?, val children: MutableList<Node>) { open val size: Int get() = 0 fun iterator (): Sequence<Node> { val stack = ArrayDeque<Node>() stack.addLast(this) return sequence { while (s...
0
Kotlin
0
0
5076dcb5aab4adced40adbc64ab26b9b5fdd2a67
2,589
advent-of-code-2022
MIT License
ceria/04/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File val requiredFields = listOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid", "cid") val optionalField = "cid" val validUnits = mapOf<String, IntRange>("cm" to IntRange(150, 193), "in" to IntRange(59, 76)) val validEyeColors = listOf("amb", "blu", "brn", "gry", "grn", "hzl", "oth") fun main(args ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
4,126
advent-of-code-2020
MIT License
src/Lesson6Sorting/NumberOfDiscIntersections.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Arrays /** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { val N = A.size val higherEdges = LongArray(N) val lowerEdges = LongArray(N) for (i in 0 until N) { higherEdges[i] = i + A[i].toLong() lowerEdges[i] = i - A[i].toLong() } Arrays.s...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,544
Codility-Kotlin
Apache License 2.0
src/Day06.kt
jfiorato
573,233,200
false
null
fun main() { fun part1(input: List<String>): Array<Int> { var results: Array<Int> = arrayOf() input.forEach charLoop@{ val marker: ArrayList<Char> = arrayListOf() it.forEachIndexed { idx, char -> if (marker.size == 4) { marker.removeAt(0) ...
0
Kotlin
0
0
4455a5e9c15cd067d2661438c680b3d7b5879a56
1,691
kotlin-aoc-2022
Apache License 2.0
src/kickstart2022/c/AntsOnStick.kt
vubogovich
256,984,714
false
null
package kickstart2022.c // TODO test set 2 fun main() { val inputFileName = "src/kickstart2022/c/AntsOnStick.in" java.io.File(inputFileName).takeIf { it.exists() }?.also { System.setIn(it.inputStream()) } for (case in 1..readLine()!!.toInt()) { val (n, len) = readLine()!!.split(' ').map { it.toInt...
0
Kotlin
0
0
fc694f84bd313cc9e8fcaa629bafa1d16ca570fb
2,924
kickstart
MIT License
src/Day01.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { return input.fold(Pair(Int.MIN_VALUE, 0)) { bestSoFarAndCurrent, currCalAsStr -> if (currCalAsStr.isEmpty()) { Pair(max(bestSoFarAndCurrent.first, bestSoFarAndCurrent.second), 0) } else { ...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
1,154
aoc-2022
Apache License 2.0
src/Day01.kt
gnuphobia
578,967,785
false
{"Kotlin": 17559}
fun main() { fun part1(input: List<String>): Int { var largest = 0 var total = 0 for (row in input) { if (row.isBlank()) { if (total > largest) { largest = total } total = 0 } else { ...
0
Kotlin
0
0
a1b348ec33f85642534c46af8c4a69e7b78234ab
1,313
aoc2022kt
Apache License 2.0
src/Day3.kt
syncd010
324,790,559
false
null
import kotlin.math.min import kotlin.math.max import kotlin.system.exitProcess class Day3: Day { data class Line(val from: Position, val to: Position) { val isVertical: Boolean get() = from.x == to.x val isHorizontal: Boolean get() = from.y == to.y val isPosition: Boolean get() = isVertica...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
5,201
AoC2019
Apache License 2.0
Cinema.kt
hahaslav
453,238,848
false
{"Jupyter Notebook": 155781, "Kotlin": 82973}
package cinema const val SEATSLIMIT = 60 const val VIPRICE = 10 const val POORPRICE = 8 fun inputRoom(): String { println("Enter the number of rows:") val r = readLine()!! println("Enter the number of seats in each row:") val s = readLine()!! return "$r $s" } fun scheme(cinema: MutableList<Mutabl...
0
Jupyter Notebook
0
0
5ca7234db040f585167a774fcc66b3fc878e1ebc
3,084
Kotlin-Basics
MIT License
src/Day05.kt
gischthoge
573,509,147
false
{"Kotlin": 5583}
fun main() { fun moveCratesAndGetTop(input: List<String>, reverse: Boolean): String { val cratesInput = input .filter { it.contains("[") } .map { row -> row.chunked(4).map { it.replace(Regex("[\\s\\[\\]]"), "") }} val maxSize = cratesInput.maxOf { it.size } val stack...
0
Kotlin
0
0
e403f738572360d4682f9edb6006d81ce350ff9d
1,349
aock
Apache License 2.0
app/src/main/kotlin/kotlinadventofcode/2023/2023-02.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2023` import com.github.h0tk3y.betterParse.combinators.* import com.github.h0tk3y.betterParse.grammar.* import com.github.h0tk3y.betterParse.lexer.* import kotlinadventofcode.Day class `2023-02` : Day { override fun runPartOneNoUI(inp...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
13,326
kotlinadventofcode
MIT License
src/main/kotlin/codes/jakob/aoc/solution/Day13.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
package codes.jakob.aoc.solution import codes.jakob.aoc.shared.Coordinates import codes.jakob.aoc.shared.Grid object Day13 : Solution() { private val DEFAULT_CELL_VALUE: (Grid.Cell<Boolean>) -> Boolean = { false } override fun solvePart1(input: String): Any { val foldedGrid: Grid<Boolean> = foldOver(...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
3,821
advent-of-code-2021
MIT License
src/2022/Day03.kt
ttypic
572,859,357
false
{"Kotlin": 94821}
package `2022` import readInput fun main() { fun Iterable<Char>.priority(): Int { return this.sumOf { if (it in 'a'..'z') it - 'a' + 1 else it - 'A' + 27 } } fun part1(input: List<String>): Int { return input.sumOf { val firstCompartment = it.substring(0, it.length / 2) ...
0
Kotlin
0
0
b3e718d122e04a7322ed160b4c02029c33fbad78
1,162
aoc-2022-in-kotlin
Apache License 2.0
Problem Solving/Algorithms/Basic - Plus Minus.kt
MechaArms
525,331,223
false
{"Kotlin": 30017}
/* Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with places after the decimal. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with abso...
0
Kotlin
0
1
eda7f92fca21518f6ee57413138a0dadf023f596
3,046
My-HackerRank-Solutions
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day24/Day24.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day24 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day24 : Day { override val input = readInputLines(24).chunked(18).map { Variables.from(it) } override fun part1() = solve(Part1) override fun part2()...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
1,794
aoc2021
MIT License
leetcode/src/offer/middle/Offer56_1.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 56 - I. 数组中数字出现的次数 // https://leetcode.cn/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/ println(singleNumbers(intArrayOf(1,2,10,4,1,4,3,3)).contentToString()) } fun singleNumbers(nums: IntArray): IntArray { // [1,2,10,4,1,4,3,3],结果是2,10 // 设两个不...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,844
kotlin-study
MIT License
src/Day25.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
import kotlin.math.pow fun main() { fun String.fromSnafu(): Long = reversed() .mapIndexed { index, digit -> when (digit) { '=' -> -2 '-' -> -1 else -> digit.digitToInt() } * 5.0.pow(index) }...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
1,437
AdventOfCode2022
Apache License 2.0
advent-of-code-2021/src/code/day9/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day9 import java.io.File fun main() { doIt("Day 9 Part 1: Test Input", "src/code/day9/test.input", part1) doIt("Day 9 Part 1: Real Input", "src/code/day9/part1.input", part1) doIt("Day 9 Part 2: Test Input", "src/code/day9/test.input", part2); doIt("Day 9 Part 2: Real Input", "src/code/da...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
3,750
misc-dev
MIT License
year2022/src/cz/veleto/aoc/year2022/Day15.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.manhattanTo import kotlin.math.abs class Day15(config: Config) : AocDay(config) { private val inputLineRegex = Regex("""^.*x=(-?[0-9]+), y=(-?[0-9]+).+x=(-?[0-9]+), y=(-?[0-9]+).*$""") ove...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
2,462
advent-of-pavel
Apache License 2.0
src/day03/Day03.kt
jpveilleux
573,221,738
false
{"Kotlin": 42252}
package day03 import readInput fun main () { val testInputFileName = "./day03/Day03_test" val controlInputFileName = "./day03/Day03_part2_control" val inputFileName = "./day03/Day03" val testInput = readInput(testInputFileName) val controlInput = readInput(controlInputFileName) val input = rea...
0
Kotlin
0
0
5ece22f84f2373272b26d77f92c92cf9c9e5f4df
1,900
jpadventofcode2022
Apache License 2.0
src/Day03.kt
sungi55
574,867,031
false
{"Kotlin": 23985}
fun main() { val day = "Day03" fun part1(input: List<String>): Int = input.map { rucksack -> rucksack.chunked(rucksack.length / 2) } .sumOf { rucksack -> val compartment1 = rucksack.component1().toSet() val compartment2 = rucksack.component2().toSet() ...
0
Kotlin
0
0
2a9276b52ed42e0c80e85844c75c1e5e70b383ee
1,160
aoc-2022
Apache License 2.0
src/main/kotlin/Day009.kt
ruffCode
398,923,968
false
null
import PuzzleInput.toStingList object Day009 { private val target = 556543474L val testInput = """ 35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 ...
0
Kotlin
0
0
477510cd67dac9653fc61d6b3cb294ac424d2244
3,078
advent-of-code-2020-kt
MIT License
src/year2020/day04/Day04.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day04 import util.assertTrue import util.read2020DayInput fun main() { val input = formatInput(read2020DayInput("Day04")) assertTrue(task01(input) == 237) assertTrue(task02(input) == 172) } private fun task01(input: List<String>) = convertStringsToPassports(input) .map { it.lazyIsVal...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
3,147
advent-of-code-kotlin-template
Apache License 2.0
codeforces/vk2022/round1/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.vk2022.round1 const val M = 26 private fun solve() { readln() val s = readln().map { it - 'a' }.toIntArray() val count = IntArray(M) for (c in s) count[c]++ val byFreq = count.indices.sortedByDescending { count[it] } var answer = s.size + 1 var answerString = "" val a = IntArray(s.size) va...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,053
competitions
The Unlicense
src/main/kotlin/co/csadev/advent2020/Day12.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/* * Copyright (c) 2021 by <NAME> */ package co.csadev.advent2020 import co.csadev.adventOfCode.Point2D import kotlin.math.abs class Day12(input: List<String>) { private val directions = input.map { it[0] to it.substring(1).toInt() } enum class Direction { East, North, West, ...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
2,608
advent-of-kotlin
Apache License 2.0
src/day02/Day02.kt
spyroid
433,555,350
false
null
package day02 import readInput fun main() { data class Command(val op: String, val value: Int) fun part1(seq: Sequence<Command>): Int { var depth = 0 var horizontal = 0 seq.forEach { when (it.op) { "forward" -> horizontal += it.value "down"...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
1,370
Advent-of-Code-2021
Apache License 2.0
src/day14/fr/Day14_1.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
package day14.fr import java.io.File private fun readChars(): CharArray = readLn().toCharArray() private fun readLn() = readLine()!! // string line private fun readSb() = StringBuilder(readLn()) private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fu...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
2,378
Advent-of-Code-2021
Apache License 2.0
src/day23/Day23.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
package day23 import Direction import Edges import Position import readInput import set import kotlin.math.abs fun main() { fun parse(input: List<String>): ElfMap { return ElfMap( elfs = input.mapIndexed { y, row -> row.mapIndexedNotNull { x, cell -> if (cel...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
7,357
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/summarisation/SummariseSentenceScore.kt
rock3125
138,799,834
false
{"Kotlin": 30711, "Java": 939, "Shell": 774}
package summarisation import summarisation.parser.Sentence import java.util.ArrayList /** * sentence sorting by both index and scoring after algorithm completes * */ class SummariseSentenceScore(var sentence: Sentence // the sentence held , var sentenceIndex: Int // original index ...
0
Kotlin
0
4
24d8916dbecde35eaeb760eb4307ca32a4ecb768
2,432
ExtractiveSummarisation
MIT License
src/day04/Day04.kt
martindacos
572,700,466
false
{"Kotlin": 12412}
package day04 import readInput fun main() { fun part1(input: List<String>): Int { var fullyContained = 0 for (line in input) { val numbers = line.split(",") // [2, 4] val initialAndFinalNumber = numbers[0].split("-").map { number -> number.toInt() } ...
0
Kotlin
0
0
f288750fccf5fbc41e8ac03598aab6a2b2f6d58a
2,367
2022-advent-of-code-kotlin
Apache License 2.0
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day14.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 /** * https://adventofcode.com/2022/day/14 */ class Day14(override val input: String) : Day() { override fun part1(): String { val blockedPoints = initBlockedPoints() return dropSand(1, blockedPoints, blockedPoints.maxOf { it.y }).toString() } override fu...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
2,750
adventofcode2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumProductSubArray.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
1,869
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistanceLimitedPathsExist.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
4,136
kotlab
Apache License 2.0
neetcode/src/main/java/org/twopointers/TwoPointers.kt
gouthamhusky
682,822,938
false
{"Kotlin": 24242, "Java": 24233}
import kotlin.math.max import kotlin.math.min fun main() { trap(intArrayOf(0,1,0,2,1,0,1,3,2,1,2,1)) } fun isPalindrome(s: String): Boolean { val stringBuilder = StringBuilder() for (c in s){ if (!c.isLetterOrDigit()) continue else if (c.isUpperCase()) stringBuilder...
0
Kotlin
0
0
a0e158c8f9df8b2e1f84660d5b0721af97593920
3,057
leetcode-journey
MIT License
2015/Day06/src/main/kotlin/Main.kt
mcrispim
658,165,735
false
null
import java.io.File enum class Command { ON, OFF, TOGGLE } data class Rectangle(val x1: Int, val y1: Int, val x2: Int, val y2: Int) fun main() { fun readCommand(line: String): Pair<Command, Rectangle> { /* Command examples turn on 0,0 through 999,999 toggle 0,0 through 999,0 ...
0
Kotlin
0
0
2f4be35e78a8a56fd1e078858f4965886dfcd7fd
4,309
AdventOfCode
MIT License
src/main/kotlin/days/Day05.kt
julia-kim
435,257,054
false
{"Kotlin": 15771}
package days import readInput fun main() { fun mapCoordinates(x1: Int, y1: Int, map: MutableMap<Pair<Int, Int>, Int>) { if (map[x1 to y1] == null) { map[x1 to y1] = 1 } else map[x1 to y1] = map.getValue(x1 to y1) + 1 } fun part1(input: List<String>): Int { val map: Mut...
0
Kotlin
0
0
5febe0d5b9464738f9a7523c0e1d21bd992b9302
3,513
advent-of-code-2021
Apache License 2.0
src/main/kotlin/year2023/Day03.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 import utils.Direction typealias Coords = Pair<Int, Int> class Day03 { fun List<List<Char>>.findAllAdjacentNumbers(rowIdx: Int, colIdx: Int): Set<Coords> { val matrix = this return buildSet { Direction.entries.forEach { (dx, dy) -> val row = rowIdx + ...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,253
aoc-2022
Apache License 2.0
src/main/kotlin/dev/tasso/adventofcode/_2022/day11/Day11.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2022.day11 import dev.tasso.adventofcode.Solution import java.lang.IllegalArgumentException import kotlin.math.floor class Day11 : Solution<Int> { override fun part1(input: List<String>): Int { return input.asMonkeys() .let {monkeys -> ...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
4,696
advent-of-code
MIT License
src/Day02.kt
mkulak
573,910,880
false
{"Kotlin": 14860}
fun main() { fun part1(input: List<String>): Int = input.sumOf { line -> val their = line[0].code - 'A'.code val mine = line[2].code - 'X'.code when (their - mine) { 0 -> 3 -1, 2 -> 6 else -> 0 } + mine + 1 ...
0
Kotlin
0
0
3b4e9b32df24d8b379c60ddc3c007d4be3f17d28
753
AdventOfKo2022
Apache License 2.0
src/main/kotlin/days/Day13.kt
hughjdavey
572,954,098
false
{"Kotlin": 61752}
package days import days.Day13.Order.RIGHT import days.Day13.Order.SAME import days.Day13.Order.WRONG import xyz.hughjd.aocutils.Collections.takeWhileInclusive import java.util.Stack class Day13 : Day(13) { override fun partOne(): Any { return inputList.asSequence().filterNot { it.isEmpty() }.map { parse...
0
Kotlin
0
2
65014f2872e5eb84a15df8e80284e43795e4c700
3,025
aoc-2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/treesandgraphs/Question7.kt
jimmymorales
446,845,269
false
{"Kotlin": 46222}
package treesandgraphs fun main() { val orderBuild1 = findBuildOrder( projects = setOf("a", "b", "c", "d", "e", "f"), dependencies = setOf("a" to "d", "f" to "b", "b" to "d", "f" to "a", "d" to "c"), ) assert(orderBuild1 == listOf("e", "f", "b", "a", "d", "c")) val orderBuild2 = findBuildOrder( projects = s...
0
Kotlin
0
0
8a32d379d5f3a2e779f6594d949f63d2e02aad4c
2,122
algorithms
MIT License
src/main/kotlin/dev/paulshields/aoc/day2/PasswordPhilosophy.kt
Pkshields
318,658,287
false
null
package dev.paulshields.aoc.day2 import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 2: Password Philosophy ** \n") val passwordEntries = readFileAsStringList("/day2/PasswordsDatabase.txt") .mapNotNull(::parsePasswordEntry) val firstValidPasswordsCount = password...
0
Kotlin
0
0
a7bd42ee17fed44766cfdeb04d41459becd95803
1,886
AdventOfCode2020
MIT License
src/main/kotlin/dev/bogwalk/batch0/Problem3.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch0 import dev.bogwalk.util.maths.primeFactors import kotlin.math.max import kotlin.math.sqrt /** * Problem 3: Largest Prime Factor * * https://projecteuler.net/problem=3 * * Goal: Find the largest prime factor of N. * * Constraints: 10 <= N <= 1e12 * * Fundamental Theorem of Arithmeti...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,266
project-euler-kotlin
MIT License
src/main/kotlin/com/nibado/projects/advent/Point3D.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent import java.lang.Integer.max import java.lang.Integer.min data class Point3D(val x: Int, val y: Int, val z: Int) { constructor() : this(0, 0, 0) fun neighbors() = neighbors(this) operator fun plus(other: Point3D) = Point3D(x + other.x, y + other.y, z + other.z) op...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,638
adventofcode
MIT License
src/main/kotlin/name/valery1707/problem/leet/code/ConcatenationOfConsecutiveBinaryNumbersK.kt
valery1707
541,970,894
false
null
package name.valery1707.problem.leet.code import java.math.BigInteger /** * # 1680. Concatenation of Consecutive Binary Numbers * * Given an integer `n`, return the **decimal value** of the binary string formed by concatenating the binary representations of `1` to `n` in order, * **modulo** `10^9 + 7`. * * ### ...
3
Kotlin
0
0
76d175f36c7b968f3c674864f775257524f34414
3,593
problem-solving
MIT License
src/Day09.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.abs import kotlin.math.sign typealias Point = Pair<Int, Int> @OptIn(ExperimentalStdlibApi::class) fun main() { fun direction(main: Point, other: Point): Point { val dx = main.first - other.first val dy = main.second - other.second return when((abs(dx) - abs(dy)).sign) { ...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
3,323
aoc2022
Apache License 2.0
src/main/kotlin/aoc/utils/Geo.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package aoc.utils import java.lang.Long.max import java.lang.Long.min import kotlin.math.abs import kotlin.math.pow data class Point(val x: Long, val y: Long, val z: Long = 0) { fun distance(to: Point) = ((x.toDouble() - to.x).pow(2.0) + (y.toDouble() - to.y).pow(2.0) + (z...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
2,478
adventOfCode2022
Apache License 2.0
src/Day06.kt
dizney
572,581,781
false
{"Kotlin": 105380}
import kotlin.system.measureNanoTime object Day06 { const val EXPECTED_PART1_CHECK_ANSWER = 7 const val EXPECTED_PART2_CHECK_ANSWER = 19 const val MARKER_PACKET_LENGTH = 4 const val MARKER_MESSAGE_LENGTH = 14 } fun main() { fun String.findLengthUntilMarker(markerLength: Int): Int { var p...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
2,366
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
AleksanderBrzozowski
574,061,559
false
null
import Day09.Direction.D import Day09.Direction.L import Day09.Direction.R import Day09.Direction.U import java.lang.IllegalArgumentException import kotlin.math.abs import kotlin.math.sign class Day09 { enum class Direction { L, R, U, D } } fun main() { data class Point(val x: Int, val y: Int) { opera...
0
Kotlin
0
0
161c36e3bccdcbee6291c8d8bacf860cd9a96bee
3,682
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/Day09.kt
chutchinson
573,586,343
false
{"Kotlin": 21958}
import kotlin.math.* class Day09 : Solver { data class Vector2(var x: Int, var y: Int) data class Move(val direction: Char, val distance: Int) override fun solve (input: Sequence<String>) { fun parse (v: String) = Move(v[0], v.substring(2).toInt()) val moves = input.map(::parse).toList...
0
Kotlin
0
0
5076dcb5aab4adced40adbc64ab26b9b5fdd2a67
1,903
advent-of-code-2022
MIT License
src/day17/Day17.kt
daniilsjb
726,047,752
false
{"Kotlin": 66638, "Python": 1161}
package day17 import java.io.File import java.util.PriorityQueue fun main() { val data = parse("src/day17/Day17.txt") println("🎄 Day 17 🎄") println() println("[Part 1]") println("Answer: ${part1(data)}") println() println("[Part 2]") println("Answer: ${part2(data)}") } private ...
0
Kotlin
0
0
46a837603e739b8646a1f2e7966543e552eb0e20
4,758
advent-of-code-2023
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day03.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day03 : AbstractDay() { @Test fun part1() { assertEquals(4361, compute1(testInput)) assertEquals(544664, compute1(puzzleInput)) } @Test fun part2()...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,649
aoc
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day25/Day25.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day25 import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input25-test.txt" const val FILENAME = "input25.txt" const val DIGITS = "=-012" fun main() { runTests() part1() } fun runTests() { val testCases = listOf( Pair(1L, "1"), Pair(2L, "2"), Pair(3L, "1="), Pair(4L, "1-"...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,472
advent-of-code
Apache License 2.0
src/main/kotlin/aoc/day8/TreetopTreeHouse.kt
hofiisek
573,543,194
false
{"Kotlin": 17421}
package aoc.day8 import aoc.Matrix import aoc.Position import aoc.loadInput import aoc.nodesDown import aoc.nodesToTheLeft import aoc.nodesToTheRight import aoc.nodesUp import java.io.File /** * https://adventofcode.com/2022/day/8 * * @author <NAME> */ typealias Forest = Matrix<Tree> data class Tree(val height:...
0
Kotlin
0
2
5908a665db4ac9fc562c44d6907f81cd3cd8d647
1,858
Advent-of-code-2022
MIT License
src/main/kotlin/algorithmic_toolbox/week2/FibonnaciWarmup.kt
eniltonangelim
369,331,780
false
null
package algorithmic_toolbox.week2 import java.util.* fun calcFib(n: Long): Long { return if (n <= 1) n else calcFib(n - 1) + calcFib(n - 2) } fun power(n: Long, x: Int = 2): Long { if (x == 0) return n return power(n * n, x - 1) } fun lastDigitOfNumber(n: Long): Long { var fibAList = LongA...
0
Kotlin
0
0
031bccb323339bec05e8973af7832edc99426bc1
2,549
AlgorithmicToolbox
MIT License
src/main/kotlin/day4/GameCard.kt
remhiit
727,182,240
false
{"Kotlin": 12212}
package day4 class GameCard(input: List<String>) { val cards: List<Card> init { cards = input.withIndex().map { val splitted = it.value.split(":", "|") Card(it.index, getNumbers(splitted[1]), getNumbers(splitted[2])) } } private fun getNumbers(s: String): List<...
0
Kotlin
0
0
122ee235df1af8e3d0ea193b9a37162271bad7cb
1,320
aoc2023
Creative Commons Zero v1.0 Universal
src/main/java/challenges/educative_grokking_coding_interview/k_way_merge/_5/KthSmallest.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.k_way_merge._5 import java.util.* /** Find the kth smallest element in an (n×n) matrix, where each row and column of the matrix is sorted in ascending order. Although there can be repeating values in the matrix, each element is considered unique and, therefore, ...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,449
CodingChallenges
Apache License 2.0
src/Day06.kt
euphonie
571,665,044
false
{"Kotlin": 23344}
fun main() { fun findFirstUniqueSequence(input: String, windowSize: Int) : Int { var startIndex = 0 for (i in IntRange(0, input.length-windowSize-1) step 1) { val letters = input.substring(i, i+windowSize) if (letters.toSet().size == letters.toList().size) { ...
0
Kotlin
0
0
82e167e5a7e9f4b17f0fbdfd01854c071d3fd105
1,275
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CheckCompletenessOfBinaryTree.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
1,943
kotlab
Apache License 2.0
src/Day03.kts
Cicirifu
225,414,163
false
null
import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Bounds(val xMin: Int, val yMin: Int, val xMax: Int, val yMax: Int) data class Coord(val x: Int, val y: Int) data class LineSegment(val start: Coord, val end: Coord, val direction: Direction, val length: Int) data class...
0
Kotlin
0
0
bbeb2ee39fd13bd57cd6384d0a82f91227e4541f
3,762
AdventOfCode2019
Apache License 2.0
src/main/kotlin/com/groundsfam/advent/y2021/d12/Day12.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2021.d12 import com.groundsfam.advent.DATAPATH import com.groundsfam.advent.timed import kotlin.io.path.div import kotlin.io.path.useLines private const val START = "start" private const val END = "end" private data class Path(val currCave: String, val visitedCaves: Set<String>, val r...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
2,827
advent-of-code
MIT License
src/Day13.kt
arksap2002
576,679,233
false
{"Kotlin": 31030}
enum class Type { RIGHT, UNKNOWN, WRONG } fun main() { fun stringToArray(s: String): MutableList<String> { val arr = mutableListOf<String>() var bal = 0 var currentString = "" for (i in s.indices) { if (s[i] == ',' && bal == 0) { arr.add(currentString...
0
Kotlin
0
0
a24a20be5bda37003ef52c84deb8246cdcdb3d07
3,028
advent-of-code-kotlin
Apache License 2.0
yandex/y2022/finals/a_small.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2022.finals import java.util.* import kotlin.math.sign fun main() { readLn() val our = readInts() val their = readInts() val e = List(our.size) { i -> IntArray(their.size) { j -> -(our[i] - their[j]).sign } } val h = hungarian(e) println(-h) } fun hungarian(e: List<IntArray>): Int { val ans = ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,678
competitions
The Unlicense
src/Day01.kt
nielsz
573,185,386
false
{"Kotlin": 12807}
fun main() { fun part1(input: List<String>): Int { return getLargestStack(input) } fun part2(input: List<String>): Int { return getStacks(input) .sortedDescending() .take(3) .sum() } val input = readInput("Day01") println(part1(input)) pr...
0
Kotlin
0
0
05aa7540a950191a8ee32482d1848674a82a0c71
1,084
advent-of-code-2022
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day04.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay fun parseAssignment(input: String): Pair<IntRange, IntRange> { val (a, b) = input.split(",") return a.parsePair() to b.parsePair() } private fun String.parsePair(): IntRange { val (a, b) = split("-") return a.toInt() .. b.toInt() } infix fun IntRange.contains(other:...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,056
advent-of-code
Apache License 2.0
src/Day01.kt
dmarmelo
573,485,455
false
{"Kotlin": 28178}
fun main() { fun List<String>.parseInput(): List<List<Int>> { var rest = this return buildList { while (rest.isNotEmpty()) { val elfInventory = rest.takeWhile { it.isNotBlank() }.map { it.toInt() } add(elfInventory) rest = ...
0
Kotlin
0
0
5d3cbd227f950693b813d2a5dc3220463ea9f0e4
1,084
advent-of-code-2022
Apache License 2.0
src/Day25.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File import kotlin.math.pow // Advent of Code 2022, Day 25: Full of Hot Air class Day25(input: String) { private val lines: List<String> init { lines = input.split("\n").filter { it.isNotEmpty() } } private fun snafuToDec(input: String) : Long { return input.reversed()...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
2,366
AdventOfCode2022
Apache License 2.0
src/day25/Day25.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day25 import readInput import kotlin.math.pow // Only part 1 is done, as all previous stars are needed for part2 fun main() { fun convertToDecimal(lines: List<String>): Long { var total = 0L lines.forEach { var decimal = 0L it.forEachIndexed { index, c -> ...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
2,970
aoc-2022-kotlin
Apache License 2.0
src/test/kotlin/com/igorwojda/list/minsublistlength/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.list.minsublistlength // Time complexity: O(n) // Space complexity O(n) // Use sliding window private object Solution1 { fun minSubListLength(list: List<Int>, sum: Int): Int { var total = 0 var start = 0 var end = 0 var minLen: Int? = null while (start...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
2,887
kotlin-coding-challenges
MIT License
src/Day03.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File fun main() { fun commonChar(s1: String, s2: String): Char { for (i in s1.indices) { for (element in s2) { if (s1[i] == element) { return s1[i] } } } return ' ' } fun commonChar2(s1: Str...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
2,029
AoC2022
Apache License 2.0
src/Day09.kt
ty-garside
573,030,387
false
{"Kotlin": 75779}
// Day 09 - Rope Bridge // https://adventofcode.com/2022/day/9 import Direction.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.math.sign fun main() { var debug = true data class Position( val x: Int, val y: Int ) data class Move( val dir:...
0
Kotlin
0
0
49ea6e3ad385b592867676766dafc48625568867
16,885
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/org/sjoblomj/adventofcode/day2/Day2.kt
sjoblomj
225,241,573
false
null
package org.sjoblomj.adventofcode.day2 import org.sjoblomj.adventofcode.readFile private const val OPCODE_ADD = 1 private const val OPCODE_MUL = 2 private const val OPCODE_EXIT = 99 private const val WANTED_OUTPUT = 19690720 private const val inputFile = "src/main/resources/inputs/day2.txt" fun day2(): Pair<Int, In...
0
Kotlin
0
0
f8d03f7ef831bc7e26041bfe7b1feaaadcb40e68
2,046
adventofcode2019
MIT License
src/Day05.kt
jdpaton
578,869,545
false
{"Kotlin": 10658}
fun main() { fun part1(reversed: Boolean = false) { val testInput = readInput("Day05_test") val stacks = mapStacks(testInput) testInput.filter { it.startsWith("move") }.forEach { val moveSpl = it.split(" ") val numberOfCratesToMove = moveSpl[1].toInt() c...
0
Kotlin
0
0
f6738f72e2a6395815840a13dccf0f6516198d8e
2,300
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
NunoPontes
572,963,410
false
{"Kotlin": 7416}
fun main() { fun part1(input: List<String>): Int { return input.map { it -> it.split(",", "-").map { it.toInt() } }.count { val (first, second, third, fourth) = it (first in third..fourth && second in third..fourth) || (third in first..second && fourth in first..second) } ...
0
Kotlin
0
0
78b67b952e0bb51acf952a7b4b056040bab8b05f
794
advent-of-code-2022
Apache License 2.0
src/year_2021/day_07/Day07.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_07 import readInput import kotlin.math.abs object Day07 { /** * @return */ fun solutionOne(text: String): Int { val positions = parsePositions(text) val minPosition = positions.min() val maxPosition = positions.max() var minFuel = Integer.MAX_V...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
1,576
advent_of_code
Apache License 2.0
src/main/kotlin/days/Day10.kt
hughjdavey
159,955,618
false
null
package days import util.scan class Day10 : Day(10) { // move these here instead of in each part to save calculation time private val seq = (0..100000).asSequence().scan(0 to parsePoints(inputList)) { (_, points), i -> i + 1 to points.map { moveOneSecond(it) } } private val minDistPoints = se...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
2,762
aoc-2018
Creative Commons Zero v1.0 Universal
aoc-day5/src/Day5.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.nio.file.Files import java.nio.file.Path import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.streams.toList fun main() { val file = Path.of("input") val lines = Files.lines(file).map { line -> parseLine(line) }.toList() part1(lines) part2(lines) } fun part1(l...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
2,729
adventofcode2021
MIT License
src/Day01.kt
colmmurphyxyz
572,533,739
false
{"Kotlin": 19871}
import java.util.* fun main() { fun getInput(): List<Int> { val input = readInput("Day01") val elfCaloriesString = mutableListOf<List<String>>() var sliceStart = 0 for (i in input.indices) { if (i == input.lastIndex) { elfCaloriesString.add(input.slice(sl...
0
Kotlin
0
0
c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea
1,965
aoc-2022
Apache License 2.0
src/main/kotlin/io/dp/ExpressionAddOperator.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.dp import io.utils.runTests import java.util.* import java.util.function.Consumer // https://leetcode.com/problems/expression-add-operators/ class ExpressionAddOperator { fun execute(input: String, target: Int): List<String> = helperRecursion(input).filter { evaluate(it) == target } private fu...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
4,846
coding
MIT License
src/main/kotlin/g1201_1300/s1210_minimum_moves_to_reach_target_with_rotations/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1210_minimum_moves_to_reach_target_with_rotations // #Hard #Array #Breadth_First_Search #Matrix // #2023_06_09_Time_230_ms_(100.00%)_Space_44.8_MB_(100.00%) import java.util.LinkedList import java.util.Objects import java.util.Queue class Solution { fun minimumMoves(grid: Array<IntArray>): In...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,972
LeetCode-in-Kotlin
MIT License
src/main/aoc2016/Day20.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2016 class Day20(input: List<String>) { // Sorted list of ranges, ranges fully contained in another range are not included private val blacklist = parseInput(input) private fun parseInput(input: List<String>): List<LongRange> { val ranges = mutableListOf<LongRange>() for (line ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,673
aoc
MIT License
advent-of-code-2022/src/main/kotlin/year_2022/Day12.kt
rudii1410
575,662,325
false
{"Kotlin": 37749}
package year_2022 import util.Pos2 import util.Runner import util.wrap import java.util.LinkedList import java.util.Queue fun main() { fun <T> List<List<T>>.get(p: Pos2): T = this[p.x][p.y] fun <T> List<MutableList<T>>.set(p: Pos2, data: T) { this[p.x][p.y] = data } fun canClimb(tmpCurrentHei...
1
Kotlin
0
0
ab63e6cd53746e68713ddfffd65dd25408d5d488
2,235
advent-of-code
Apache License 2.0
style_transfer/app/src/main/java/org/tensorflow/lite/examples/styletransfer/camera/CameraSizes.kt
SunitRoy2703
405,389,854
false
{"Kotlin": 441677, "Java": 11281}
/* * Copyright 2019 Google LLC * * 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 * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to ...
3
Kotlin
11
37
c7628b3e58d9ae1ff902f4a9ff0142a051f91958
3,246
Tensorflow-lite-kotlin-samples
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day3/EngineSchematic.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day3 import com.github.michaelbull.advent2023.math.Vector2 import com.github.michaelbull.advent2023.math.toVector2CharMap fun Sequence<String>.toEngineSchematic(): EngineSchematic { val data = this.toVector2CharMap() val numbers = buildList { for (y in data.y...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
2,437
advent-2023
ISC License