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/Day10.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
sealed class Instruction(private val cycles: Int) { abstract fun apply(reg: Int): Int fun expanded(): List<Instruction> = ((1 until cycles).map { NoOp() }) + this } class NoOp: Instruction(1) { override fun apply(reg: Int) = reg } class AddX(private val arg: Int): Instruction(2) { override ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
1,724
aoc22
Apache License 2.0
src/main/kotlin/day05/day05.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package day05 import main.utils.Stack import utils.readFileGroup import utils.readLinesGroup data class Instruction(val count: Int, val from: Int, val to: Int) fun main() { fun readStack(lines: List<String>, stack: Int): Stack<Char> { val result = mutableListOf<Char>() val offset = stack * 4 + 1 for (l...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
3,396
aoc-2022-in-kotlin
Apache License 2.0
src/Day07.kt
Advice-Dog
436,116,275
true
{"Kotlin": 25836}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val positions = input.first().split(",").map { it.toInt() } val min = positions.minOf { it } val max = positions.maxOf { it } var best = -1 for (target in min..max) { val sum = position...
0
Kotlin
0
0
2a2a4767e7f0976dba548d039be148074dce85ce
1,291
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch2/Problem24.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import dev.bogwalk.util.maths.factorial /** * Problem 24: Lexicographic Permutations * * https://projecteuler.net/problem=24 * * Goal: Return the Nth lexicographic permutation of "abcdefghijklm". * * Constraints: 1 <= N <= 13! * * Lexicographic Permutation: The alphabetically/numer...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,703
project-euler-kotlin
MIT License
src/aoc2017/kot/Day20.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import getNumbers import java.io.File object Day20 { data class Vec3d(var x: Int, var y: Int, var z: Int) { operator fun plus(other: Vec3d) = Vec3d(this.x + other.x, this.y + other.y, this.z + other.z) } class Particle(val id: Int, s: String) { val values = s.getNumbers() var po...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,457
Advent_of_Code
MIT License
src/main/kotlin/be/swsb/aoc2021/day10/Day10.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day10 import be.swsb.aoc2021.day10.SyntaxError.AutoCompletion import be.swsb.aoc2021.day10.SyntaxError.Corruption object Day10 { fun solve1(input: List<String>): Int { return input.mapNotNull { it.compile() }.filterIsInstance<Corruption>() .sumOf { corruption -> corrupt...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
1,874
Advent-of-Code-2021
MIT License
y2016/src/main/kotlin/adventofcode/y2016/Day02.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 import java.lang.IllegalArgumentException object Day02 : AdventSolution(2016, 2, "Bathroom Security") { override fun solvePartOne(input: String): String { val s...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,666
advent-of-code
MIT License
src/Day07.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
import kotlin.math.min sealed class Node { data class DirectoryNode( val parentDirectoryNode: DirectoryNode?, val directoryName: String, // Directory Name -> Directory Node val folderNodes: MutableMap<String, DirectoryNode> = mutableMapOf(), // File Name -> File Node ...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
5,627
advent-of-code-2022-kietyo
Apache License 2.0
src/day6/Code.kt
fcolasuonno
162,470,286
false
null
package day6 import java.io.File import kotlin.math.max fun main(args: Array<String>) { 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)}") pr...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
2,067
AOC2015
MIT License
day-02-kotlin/src/Main.kt
jakoberzar
159,959,049
false
{"JavaScript": 23733, "TypeScript": 11163, "Scala": 8193, "Rust": 7557, "Kotlin": 4451, "C#": 4250, "HTML": 2059}
import java.io.File fun main(args: Array<String>) { val input = getInput() star1(input) star2(input) } fun star1(input: List<String>) { val frequencies = input.map { countLetters(it) } val have2 = frequencies.filter { it.contains(2) }.count() val have3 = frequencies.filter { it.contains(3) }.c...
0
JavaScript
0
1
8779f71cebff6711e8b6613705bcba9714b4e33f
1,470
advent-of-code-2018
MIT License
src/main/kotlin/day07/Code.kt
fcolasuonno
317,324,330
false
null
package day07 import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/main/kotlin/$dir/$name").readLines() val parsed = parse(input) part1(parsed) part2(...
0
Kotlin
0
0
e7408e9d513315ea3b48dbcd31209d3dc068462d
1,827
AOC2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfGoodPaths.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,975
kotlab
Apache License 2.0
src/main/kotlin/com/github/dangerground/Day3.kt
dangerground
226,153,955
false
null
package com.github.dangerground import java.lang.Integer.max import java.lang.Integer.min import kotlin.math.absoluteValue class Day3(line1input: Array<String>, line2input: Array<String>) { val line1 = ArrayList<Line>() val line2 = ArrayList<Line>() init { convertToLine(line1input, line1) ...
0
Kotlin
0
1
125d57d20f1fa26a0791ab196d2b94ba45480e41
3,971
adventofcode
MIT License
src/day04/Day04.kt
Harvindsokhal
572,911,840
false
{"Kotlin": 11823}
package day04 import readInput fun main() { val data = readInput("day04/day04_data") fun pairFullOverlap(list: List<String>): Int { var count = 0 list.forEach { pair -> val pairOne = pair.split(',')[0].split('-') val pairTwo = pair.split(',')[1].split('-') ...
0
Kotlin
0
0
7ebaee4887ea41aca4663390d4eadff9dc604f69
1,349
aoc-2022-kotlin
Apache License 2.0
2022/src/test/kotlin/Day09.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import kotlin.math.absoluteValue private data class Position9(val x: Int, val y: Int) class Day09 : StringSpec({ "puzzle part 01" { val countOfPositions = getHeadPositions() .runningReduce { acc, head -> acc.follow(...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,254
adventofcode
MIT License
src/main/kotlin/ru/timakden/aoc/year2015/Day19.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import java.util.* /** * [Day 19: Medicine for Rudolph](https://adventofcode.com/2015/day/19). */ object Day19 { @JvmStatic fun main(args: Array<String>) { measure { val input = rea...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,520
advent-of-code
MIT License
src/Day02.kt
bunjix
573,915,819
false
{"Kotlin": 9977}
import java.io.File fun main() { val input = File("src/Day02_input.txt").readLines() val fomattedInput = input.map { line -> line.split(" ").let { players -> players.first().first() to players.last().first() } } println(part1(fomattedInput)) println(part2(fomattedInput)) } private fun part1(input: Lis...
0
Kotlin
0
0
ee2a344f6c0bb2563cdb828485e9a56f2ff08fcc
2,081
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc23/Day17.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day17Domain.City import aoc23.Day17Domain.City.BlockNode import aoc23.Day17Parser.toCity import aoc23.Day17Solution.fourToTenStepsDirectionPredicate import aoc23.Day17Solution.threeStepsDirectionPredicate import common.Monitoring import common.Space2D import common.Space2D.Direction import c...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
4,278
aoc
Apache License 2.0
src/main/kotlin/days/Common.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days import kotlin.math.sign fun lcm(x: Long, y: Long, vararg ints: Long): Long = ints.fold(x * y / gcd(x, y)) { acc, z -> lcm(acc, z) } fun lcm(x: Long, y: Long, ints: List<Long>): Long = ints.fold(x * y / gcd(x, y)) { acc, z -> lcm(acc, z) } fun gcd(a: Long, b: Long): Long { if (b == 0L) retur...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,837
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/d19.main.kts
cjfuller
317,725,797
false
null
import java.io.File sealed class Rule { abstract fun match(s: String): List<Pair<Boolean, Int>> data class Literal(val c: Char) : Rule() { override fun match(s: String) = if (s.firstOrNull() == c) { listOf(true to 1) } else { listOf(false to 0) } } data ...
0
Kotlin
0
0
c3812868da97838653048e63b4d9cb076af58a3b
3,108
adventofcode2020
MIT License
src/day22/Day22.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day22 import day22.Direction.* import readInput import readTestInput import kotlin.math.sqrt private sealed interface Instruction { data class Move(val steps: Int) : Instruction object TurnLeft : Instruction object TurnRight : Instruction } private typealias Instructions = Sequence<Instruction> p...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
18,973
advent-of-code-kotlin-2022
Apache License 2.0
src/Day20.kt
sitamshrijal
574,036,004
false
{"Kotlin": 34366}
fun main() { fun parse(input: List<String>, decryptionKey: Long = 1L): MutableList<Number> = input.mapIndexed { index, s -> Number(s.toLong() * decryptionKey, index) }.toMutableList() fun part1(input: List<String>): Long { val numbers = parse(input) numbers.indices.forEach { originalIn...
0
Kotlin
0
0
fd55a6aa31ba5e3340be3ea0c9ef57d3fe9fd72d
1,530
advent-of-code-2022
Apache License 2.0
src/main/kotlin/advent/day13/TransparentOrigami.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day13 import advent.Matrix import advent.Position import advent.loadInput import java.io.File /** * @author <NAME> */ typealias Paper = Matrix<PaperPosition> fun Paper.foldUp(foldRowIdx: Int): Paper { return (0 until foldRowIdx).map { row -> (0 until cols).map { col -> val p...
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
3,836
Advent-of-code-2021
MIT License
src/day02/Day02.kt
cmargonis
573,161,233
false
{"Kotlin": 15730}
package day02 import readInput private const val DIRECTORY = "./day02" fun main() { fun calculateScoreForRound(elfPlay: ElfHand, playerResponse: PlayerResponse): Int { val outcome = playerResponse.playAgainst(elfPlay) return outcome.score + playerResponse.score } fun toPair(it: String) ...
0
Kotlin
0
0
bd243c61bf8aae81daf9e50b2117450c4f39e18c
3,078
kotlin-advent-2022
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day18.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay import kotlin.math.max // https://adventofcode.com/2021/day/18 fun main() { Day18().run() } class Day18 : BaseDay() { override fun task1() : Int { val finalSnailNumber = input.lines().map(::SnailNumber).reduce { a, b -> a.add(b) } retu...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
7,528
advent-of-code
Apache License 2.0
13/part_one.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Paper { val lines = File("input.txt") .readLines() val dots = mutableListOf<Pair<Int, Int>>() val instructions = mutableListOf<Pair<Char, Int>>() parseInput(lines, dots, instructions) return Paper(dots, instructions) } fun parseInput(inputLines : Lis...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,201
advent-of-code-2021
MIT License
src/main/kotlin/aoc2022/Day08.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.digit import aoc.parser.followedBy import aoc.parser.oneOrMore class Day08 { val row = oneOrMore(digit()) followedBy "\n" val parser = oneOrMore(row) fun part1(input: String): Int { val grid = parser.parse(input) val height = grid.size ...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
2,343
aoc-kotlin
Apache License 2.0
src/Day10.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
data class Signal(var cycle: Int = 1, var x: Int = 1) { var sum = 0 val screen = MutableList(6) { MutableList(40) { "." } } fun process() { if (isComputeTime()) { sum += cycle * x } cycle++ } fun processDraw() { val hPos = (cycle - 1) % 40 val vPo...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
1,460
advent-of-code-2022
Apache License 2.0
Kotlin/src/main/kotlin/org/algorithm/structures/SegTree.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
package org.algorithm.structures class SegTree(val array: IntArray) { private var treeArray: MutableList<Int> private var arrSize: Int init { treeArray = MutableList<Int>(4 * array.size) { 0 } initSegTree(array, 0, 0, array.size - 1) arrSize = array.size println(treeArray) ...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
2,489
algorithms
MIT License
kotlin/src/x2022/day12/day12.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day12 import readInput typealias Point = Pair<Int, Int> fun Point.neighbours() = sequenceOf( first - 1 to second, first to second + 1, first + 1 to second, first to second - 1 ) fun main() { fun parseInput(input: List<String>): Triple<Point, Point, Map<Point, Char>> { lateinit va...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
2,412
adventOfCode
Apache License 2.0
advent-of-code-2020/src/test/java/aoc/Day16TicketTranslation.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
package aoc import org.assertj.core.api.Assertions.assertThat import org.junit.Test class Day16TicketTranslation { @Test fun silverTest() { assertThat(ticketScanningErrorRate(testInput)).isEqualTo(71) } data class Rule( val name: String, val ranges: List<IntRange> ) { ...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
24,844
advent-of-code
MIT License
leetcode2/src/leetcode/longest-increasing-subsequence.kt
hewking
68,515,222
false
null
package leetcode import kotlin.math.max /** * 300. 最长上升子序列 https://leetcode-cn.com/problems/longest-increasing-subsequence/ 给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n2) 。 进阶: 你能将算法的时间复杂度降低到 O(n log n) 吗? ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
3,334
leetcode
MIT License
src/Day03.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
fun main() { fun MutableList<Char>.overallValue() = sumOf { if (it in 'a'..'z') { it - 'a' + 1 } else { it - 'A' + 27 } } fun part1(input: List<String>): Int { val misplacedItems = mutableListOf<Char>() for (line in input) { val le...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
1,461
aoc-2022
Apache License 2.0
src/Day07.kt
bananer
434,885,332
false
{"Kotlin": 36979}
import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { val numbers = input[0].split(",") .map { it.toInt() } .sorted() // median val target = numbers[numbers.size / 2] return numbers.sumOf { (it - target).absoluteValue } } ...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
1,177
advent-of-code-2021
Apache License 2.0
src/cn/leetcode/codes/simple239/Simple239.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple239 import cn.leetcode.codes.out import java.util.* fun main() { val nums = intArrayOf(1, 3, -1, -3, 5, 3, 6, 7) out(maxSlidingWindow(nums, 3).contentToString()) } /* 239. 滑动窗口最大值 给你一个整数数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。 ...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,766
LeetCodeSimple
Apache License 2.0
src/Day04.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
fun String.parseAssignmentRanges() = split(",") .map { section -> val (startNumber, endNumber) = section.split("-") (startNumber.toInt()..endNumber.toInt()) }.let { (first, second) -> first to second } fun main() { fun part1(input: List<String>): Int { var count = 0 for (li...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
984
advent-of-code-2022
Apache License 2.0
src/Day09.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import kotlin.math.abs private enum class Direction { LEFT, UP, RIGHT, DOWN, } private fun String.toDirection(): Direction = when (this) { "L" -> Direction.LEFT "R" -> Direction.RIGHT "U" -> Direction.UP "D" -> Direction.DOWN else -> error("Unknown direction $this") } private data class RopeM...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
3,270
aoc22-kotlin
Apache License 2.0
src/2021/Day21.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
import java.io.File import java.math.BigInteger import java.util.* import kotlin.Comparator fun main() { Day21().solve() } class Day21 { val input = """ Player 1 starting position: 4 Player 2 starting position: 8 """.trimIndent() val input2 = """ Player 1 starting position: 8 Player 2 starting posi...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
5,628
advent-of-code
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day5/Five.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day5 import com.tonnoz.adventofcode23.utils.readInput import kotlin.system.measureTimeMillis object Five { @JvmStatic fun main(args: Array<String>) { val time = measureTimeMillis { val input = "input5.txt".readInput() val seeds = input[0].parseSeeds() // I ...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
2,814
adventofcode23
MIT License
src/day03/Day03.kt
palpfiction
572,688,778
false
{"Kotlin": 38770}
package day03 import readInput fun main() { val priorities = (('a'..'z') .mapIndexed { index, it -> it to index + 1 } + ('A'..'Z') .mapIndexed { index, it -> it to index + 27 }).toMap() fun part1(input: List<String>): Int = input ....
0
Kotlin
0
0
5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7
1,105
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day03.kt
Kebaan
573,069,009
false
null
package days import utils.Day fun main() { Day03.solve() } object Day03 : Day<Int>(2022, 3) { private fun Char.priority() = when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> error("invalid input") } override fun part1(input: List<String>): Int...
0
Kotlin
0
0
ef8bba36fedbcc93698f3335fbb5a69074b40da2
1,438
Advent-of-Code-2022
Apache License 2.0
src/Day04.kt
carloxavier
574,841,315
false
{"Kotlin": 14082}
fun main() { check(getContainedPairsCount("Day04_test", ::isPairFullyContained) == 2) check(getContainedPairsCount("Day04_test", ::isPairOverlapped) == 4) // Part1 println(getContainedPairsCount("Day04", ::isPairFullyContained)) // Part2 println(getContainedPairsCount("Day04", ::isPairOverlapp...
0
Kotlin
0
0
4e84433fe866ce1a8c073a7a1e352595f3ea8372
837
adventOfCode2022
Apache License 2.0
src/y2023/Day09.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2023 import util.readInput import util.timingStatistics object Day09 { private fun parse(input: List<String>): List<List<Long>> { return input.map { line -> line.split(" ").map { it.toLong() } } } fun part1(input: List<String>): Long { val parsed = parse(input...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,621
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TargetSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
4,108
kotlab
Apache License 2.0
kotlin/1269-number-of-ways-to-stay-in-the-same-place-after-some-steps.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
// Optimized DP solution Time O(minOf(steps, arrLen)^2, and space optimized down from O(minOf(steps, arrLen)^2) to O(minOf(steps, arrLen)) class Solution { fun numWays(steps: Int, _arrLen: Int): Int { val mod = 1_000_000_000 + 7 val arrLen = minOf(steps, _arrLen) var dp = IntArray (arrLen) ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,973
leetcode
MIT License
src/main/kotlin/com/tonnoz/adventofcode23/day3/Three.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day3 import com.tonnoz.adventofcode23.utils.readInput object Three { @JvmStatic fun main(args: Array<String>) { val input = "inputThree.txt".readInput() problemOne(input) problemTwo(input) } //****************************** PROBLEM ONE ***************************...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
5,401
adventofcode23
MIT License
src/Day04.kt
Kbzinho-66
572,299,619
false
{"Kotlin": 34500}
fun main() { infix fun IntRange.fullyOverlaps(other: IntRange): Boolean = first < other.first && last >= other.last infix fun IntRange.overlaps(other: IntRange): Boolean = first <= other.last && last >= other.first fun getSections(pair: String): Pair<IntRange, IntRange> { val (fir...
0
Kotlin
0
0
e7ce3ba9b56c44aa4404229b94a422fc62ca2a2b
1,188
advent_of_code_2022_kotlin
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day1/Day1.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day1 import com.github.michaelbull.advent2023.Puzzle private val STRING_TO_DIGIT = mapOf( "one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7, "eight" to 8, "nine" to 9, ) private val NUMERICAL_WORD = S...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,912
advent-2023
ISC License
src/Day04.kt
semanticer
577,822,514
false
{"Kotlin": 9812}
import java.lang.Character.isUpperCase fun main() { fun part1(input: List<String>): Int { return input.count { val (first, second) = it.toRanges() first.minus(second).isEmpty() || second.minus(first).isEmpty() } } fun part2(input: List<String>): Int { return...
0
Kotlin
0
0
9013cb13f0489a5c77d4392f284191cceed75b92
994
Kotlin-Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/year2022/Day04.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils import AoCUtils.test fun main() { fun part1(input: String, debug: Boolean = false): Long { return input.lines().map { line -> line.split(",").map { val x = it.split("-") IntRange(x[0].toInt(), x[1].toInt()) } }.map { elves ->...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
1,485
aoc-2022-kotlin
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year19/Day14.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year19 import com.grappenmaker.aoc.PuzzleSet import kotlin.math.ceil fun PuzzleSet.day14() = puzzle(day = 14) { data class Ratio(val amount: Long, val of: String) data class Recipe(val inputs: List<Ratio>, val output: Ratio) operator fun Ratio.times(n: Long) = copy(amount = a...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,958
advent-of-code
The Unlicense
src/main/kotlin/aoc2023/Day05.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 typealias Transform = Map<Pair<String, String>, List<Day05.TransformEntry>> class Day05 { fun part1(input: String): Long { val almanac = parseAlmanac(input) var key = "seed" val items = almanac.seeds.toLongArray() while (key in almanac.keys) { val keyPa...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
4,825
advent-of-code-2023
MIT License
Problem Solving/Algorithms/Basic - Mini-Max Sum.kt
MechaArms
525,331,223
false
{"Kotlin": 30017}
/* Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Example arr = [1,3,5,7,9] The minimum sum is 1+3+5+7=16 and the maximum...
0
Kotlin
0
1
eda7f92fca21518f6ee57413138a0dadf023f596
1,760
My-HackerRank-Solutions
MIT License
src/Day05.kt
gylee2011
573,544,473
false
{"Kotlin": 9419}
import java.util.* /** 012345678901234567890 [D] [N] [C] [Z] [M] [P] 1 2 3 1 + 4 * (n - 1) 1: 1 2: 5 3: 9 */ fun Int.times(block: () -> Unit) { for (i in 0 until this) { block() } } fun main() { fun readStackLine(line: String, stacks: List<Stack<Char>>) { var stackIndex = 0 ...
0
Kotlin
0
0
339e0895fd2484b7f712b966a0dae8a4cfebc2fa
2,931
aoc2022-kotlin
Apache License 2.0
src/Day10.kt
zsmb13
572,719,881
false
{"Kotlin": 32865}
fun main() { fun getXValues(testInput: List<String>) = testInput .flatMap { line -> when (line) { "noop" -> listOf(0) else -> listOf(0, line.substring(5).toInt()) } }.runningFold(1) { x, op -> x + op } fun part1(testInput: List<String>): I...
0
Kotlin
0
6
32f79b3998d4dfeb4d5ea59f1f7f40f7bf0c1f35
1,045
advent-of-code-2022
Apache License 2.0
src/Day03.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
fun main() { fun Char.priority() = if (isLowerCase()) 1 + (this - 'a') else 27 + (this - 'A') fun part1(input: List<String>): Int { return input.sumOf { rucksack -> val (firstCompartment, secondCompartment) = rucksack.chunked(rucksack.length / 2) val overlap = firstCompartment....
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
874
advent-of-code-2022
Apache License 2.0
src/Day06.kt
peterfortuin
573,120,586
false
{"Kotlin": 22151}
fun main() { fun uniqueValuesFinder(input: String, length: Int): Int { var index = length input.toCharArray().toList().windowed(length).forEach { possibleStartOfPacketMarker -> val pSOPMList = possibleStartOfPacketMarker.toCharArray().toList() if (pSOPMList.distinct() == pSOP...
0
Kotlin
0
0
c92a8260e0b124e4da55ac6622d4fe80138c5e64
1,315
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day12.kt
akowal
434,506,777
false
{"Kotlin": 30540}
fun main() { println(Day12.solvePart1()) println(Day12.solvePart2()) } object Day12 { private val connections = readInput("day12") .map { it.split('-') } .flatMap { (a, b) -> listOf(a to b, b to a) } .groupBy({ it.first }, { it.second }) fun solvePart1() = traverse("start", emp...
0
Kotlin
0
0
08d4a07db82d2b6bac90affb52c639d0857dacd7
950
advent-of-kode-2021
Creative Commons Zero v1.0 Universal
src/day06/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day06 import println import readInput import kotlin.math.sqrt fun main() { class Race(val time: Long, val distance: Long) { fun getNumberOfWaysYouCanWin(): Long { // d = t*th - th^2 // th^2 - t*th + d = 0 // D= t^2 – 4d // x1 = t - sqrt(D) / 2 // ...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
2,119
advent-of-code-2023
Apache License 2.0
src/Day05.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
import java.util.* fun main() { data class Move(val count: Int, val from: Int, val to: Int) fun parseStacks(input: List<String>): List<Stack<String>> { val lastLine = input.last() val stackCount = (lastLine.length + 2) / 4 val stacks = mutableListOf<Stack<String>>() repeat(st...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
3,039
AdventOfCode-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day21.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part21A : PartSolution() { lateinit var monkeys: Map<String, Monkey> override fun parseInput(text: String) { val monkeys = mutableListOf<Monkey>() val pattern = Regex("...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,719
advent-of-code-kotlin
MIT License
2022/src/main/kotlin/de/skyrising/aoc2022/day8/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day8 import de.skyrising.aoc.* import java.util.* private fun parseInput(input: PuzzleInput): Array<IntArray> { val rows = mutableListOf<IntArray>() for (line in input.byteLines) { val row = IntArray(line.remaining()) for (i in 0 until line.remaining()) { ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,735
aoc
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day19.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.math.max import kotlin.math.min import kotlin.test.assertEquals class Day19 : AbstractDay() { @Test fun part1Test() { assertEquals(19114, compute1(testInput)) } @Test fun part1Puz...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
10,431
aoc
Apache License 2.0
kotlin/src/main/kotlin/adventofcode/day10/Day10.kt
thelastnode
160,586,229
false
null
package adventofcode.day10 import java.io.File import java.util.* object Day10 { data class Vector(val x: Int, val y: Int) { operator fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) fun neighbors(): List<Vector> { val offsets = listOf( Vector( 0,...
0
Kotlin
0
0
8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa
3,285
adventofcode
MIT License
src/Day05.kt
WilsonSunBritten
572,338,927
false
{"Kotlin": 40606}
fun main() { fun part1(input: List<String>): String { val splitIndex = input.indexOf("") val rawGridDefinition = input.subList(0, splitIndex) val rawInstructions = input.subList(splitIndex + 1, input.size) val stacks = mutableMapOf<Int, MutableList<Char>>() println(rawGridDe...
0
Kotlin
0
0
363252ffd64c6dbdbef7fd847518b642ec47afb8
4,441
advent-of-code-2022-kotlin
Apache License 2.0
src/Day02.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File //rock a en x paper b en y scissor c en z fun main() { fun isElfWinner(opponent: String, elf: String): Boolean { return opponent == "A" && elf == "Y" || opponent == "B" && elf == "Z" || opponent == "C" && elf == "X" } fun isDraw(opponent: String, elf: String): Boolean { ...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
2,562
AoC2022
Apache License 2.0
src/solutions/week1/CombinationSum.kt
yashovardhan99
300,555,774
false
null
package solutions.week1 import kotlin.test.assertTrue class CombinationSum { private val sums = mutableListOf<List<Int>>() /** * A simple backtracking algorithm is used. If target == 0 -> we have the sum => add the current list to output * If target<0 => Backtrack * Else => Iterate through each...
0
Kotlin
1
0
b2324e23631f29b61cda3b315d4ce7557070f1e4
2,804
October-LeetCoding-Challenge
MIT License
kotlin/src/com/daily/algothrim/leetcode/medium/CombinationSum.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 39. 组合总和 * * 给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 * candidates 中的数字可以无限制重复被选取。 * * 说明: * * 所有数字(包括 target)都是正整数。 * 解集不能包含重复的组合。  */ class CombinationSum { companion object { @JvmStatic fun main(args:...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,018
daily_algorithm
Apache License 2.0
src/Day02.kt
tsschmidt
572,649,729
false
{"Kotlin": 24089}
const val ROCK = "A" const val PAPER = "B" const val SCISSORS = "C" const val LOSE = "X" const val DRAW = "Y" const val WIN = "Z" fun main() { fun outcome(a: String, b: String): Int { return when (a+b) { "AA", "BB", "CC" -> 3 "AB", "BC", "CA" -> 6 "AC", "BA", "CB" -> 0...
0
Kotlin
0
0
7bb637364667d075509c1759858a4611c6fbb0c2
1,754
aoc-2022
Apache License 2.0
src/main/kotlin/g2401_2500/s2463_minimum_total_distance_traveled/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2463_minimum_total_distance_traveled // #Hard #Array #Dynamic_Programming #Sorting // #2023_07_05_Time_153_ms_(100.00%)_Space_37_MB_(100.00%) import java.util.Arrays class Solution { fun minimumTotalDistance(robot: List<Int>, f: Array<IntArray>): Long { // sort factories : // ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,074
LeetCode-in-Kotlin
MIT License
jvm/src/main/kotlin/io/prfxn/aoc2021/day18.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Snailfish (https://adventofcode.com/2021/day/18) package io.prfxn.aoc2021 private object Day18 { interface SFNum { operator fun plus(other: SFNum): SFNum = SFNumPair(this, other) fun traverseInPostOrder(depth: Int = 0, parent: SFNumPair? = null): Sequence<Triple<SFNum, Int, SFNumPair?>> = ...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
4,236
aoc2021
MIT License
src/main/kotlin/day08.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day08 : Solvable("08") { override fun solveA(input: List<String>): String { return input .map { it.split("|").last().trim().split(" ") } .map { it.filter { listOf(2, 3, 4, 7).contains(it.length) }.size } .sum() .toString() } ove...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
1,650
AdventOfCode
Creative Commons Zero v1.0 Universal
src/main/kotlin/g0901_1000/s0943_find_the_shortest_superstring/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0943_find_the_shortest_superstring // #Hard #Array #String #Dynamic_Programming #Bit_Manipulation #Bitmask // #2023_04_29_Time_1290_ms_(100.00%)_Space_309.3_MB_(100.00%) class Solution { fun shortestSuperstring(words: Array<String>): String? { val l = words.size var state = 0 ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,085
LeetCode-in-Kotlin
MIT License
src/questions/NextGreaterElementII.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), * return the next greater number for every element in nums. * The next greater number of a number x is the firs...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,582
algorithms
MIT License
src/commonMain/kotlin/advent2020/day25/Day25Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day25 fun part1(input: String): String { val lines = input.trim().lines() val cardPK = lines[0].toLong() val doorPK = lines[1].toLong() val enc = calcEnc(cardPK, doorPK) return enc.toString() } fun calcEnc(cardPK: Long, doorPK: Long): Long { val m = 20201227L var acc = ...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
1,034
advent-of-code-2020
MIT License
src/main/kotlin/g0601_0700/s0675_cut_off_trees_for_golf_event/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0675_cut_off_trees_for_golf_event // #Hard #Array #Breadth_First_Search #Matrix #Heap_Priority_Queue // #2023_02_15_Time_777_ms_(100.00%)_Space_43.4_MB_(100.00%) import java.util.LinkedList import java.util.Objects import java.util.PriorityQueue import java.util.Queue class Solution { private...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,190
LeetCode-in-Kotlin
MIT License
src/Day04.kt
ShuffleZZZ
572,630,279
false
{"Kotlin": 29686}
private fun rangesPairList(input: List<String>) = input.map { "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRegex().find(it)!!.destructured } .map { (l1, l2, r1, r2) -> (l1.toInt() to l2.toInt()) to (r1.toInt() to r2.toInt()) } fun main() { fun part1(input: List<String>) = rangesPairList(input).sumOf { (first, second) -> fi...
0
Kotlin
0
0
5a3cff1b7cfb1497a65bdfb41a2fe384ae4cf82e
745
advent-of-code-kotlin
Apache License 2.0
src/Day02.kt
mythicaleinhorn
572,689,424
false
{"Kotlin": 11494}
import GameObject.* enum class GameObject(val points: Int) { ROCK(1), PAPER(2), SCISSORS(3) } enum class Move(val gameObject: GameObject) { A(ROCK), X(ROCK), B(PAPER), Y(PAPER), C(SCISSORS), Z( SCISSORS ) } enum class Outcome(val points: Int) { LOSE(0), DRAW(3), WIN(6) } enum class Outcome2(val outco...
0
Kotlin
0
0
959dc9f82c14f59d8e3f182043c59aa35e059381
2,965
advent-of-code-2022
Apache License 2.0
src/Day09.kt
TheGreatJakester
573,222,328
false
{"Kotlin": 47612}
package day09 import utils.string.asLines import utils.numbers.justOne import utils.readInputAsText import utils.runSolver import java.lang.IllegalArgumentException import kotlin.math.absoluteValue private typealias SolutionType = Int private const val defaultSolution = 0 private const val dayNumber: String = "09" ...
0
Kotlin
0
0
c76c213006eb8dfb44b26822a44324b66600f933
2,803
2022-AOC-Kotlin
Apache License 2.0
src/main/kotlin/se/brainleech/adventofcode/aoc2020/Aoc2020Day04.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2020 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readText import se.brainleech.adventofcode.verify class Aoc2020Day04 { companion object { private const val LINE_FEED = "\n" private const val PAIR_SEPARATOR = " " privat...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
3,512
adventofcode
MIT License
Day_03/Solution_Part2.kts
0800LTT
317,590,451
false
null
import java.io.File data class Grid(val width: Int, val height: Int, val cells: Array<Array<Boolean>>) { fun isTree(row: Int, column: Int) = cells[row][column] fun countTrees(verticalStep: Int, horizontalStep: Int) : Int { var currentRow = 0 var currentColumn = 0 var trees = 0 while (currentRow < height ...
0
Kotlin
0
0
191c8c307676fb0e7352f7a5444689fc79cc5b54
1,272
advent-of-code-2020
The Unlicense
kotlin/src/x2023/Day01.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package x2023 open class Day01AExample { open val inputLines: List<String> = read2023Input("day01a-example") open val expected = 142 open var answer: Int = 0 fun run() { println(this.javaClass.name) answer = inputLines.sumOf { line -> val digits = line.filter { c -> ...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
2,514
adventOfCode
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2023/Day04.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.math.pow import kotlin.test.assertEquals class Day04 : AbstractDay() { @Test fun part1() { assertEquals(13, compute1(testInput)) assertEquals(26218, compute1(puzzleInput)) } @...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,326
aoc
Apache License 2.0
src/Day16.kt
LauwiMeara
572,498,129
false
{"Kotlin": 109923}
const val startValve = "AA" const val startMinutesPart1 = 30 const val startMinutesPart2 = 26 data class ValveInfo (val flowRate: Int, val tunnelsTo: List<String>) data class ValvePath (val pressure: Int, val minutes: Int, val openedValves: List<String>, val path1: List<String>, val path2: List<String> = listOf("")) ...
0
Kotlin
0
1
34b4d4fa7e562551cb892c272fe7ad406a28fb69
5,663
AoC2022
Apache License 2.0
src/main/aoc2022/Day11.kt
Clausr
575,584,811
false
{"Kotlin": 65961}
package aoc2022 class Day11(input: List<String>) { private val monkeys = input.parseMonkeys() fun solvePart1(): Long { rounds(numRounds = 20) { it / 3 } return monkeys.business() } fun solvePart2(): Long { val testProduct = monkeys.map { it.test }.reduce(Long::times) r...
1
Kotlin
0
0
dd33c886c4a9b93a00b5724f7ce126901c5fb3ea
2,156
advent_of_code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/KeysAndRooms.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,402
kotlab
Apache License 2.0
src/main/kotlin/kr/co/programmers/P150369.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers import java.util.* // https://github.com/antop-dev/algorithm/issues/491 class P150369 { fun solution(cap: Int, n: Int, deliveries: IntArray, pickups: IntArray): Long { val d = Stack<Int>() val p = Stack<Int>() var move = 0L // 총 이동거리 for (i in 0 until n) ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,593
algorithm
MIT License
src/main/kotlin/days/Day7.kt
hughjdavey
317,575,435
false
null
package days class Day7 : Day(7) { private val bags = Bag.createBags(inputList) private val bagColour = "shiny gold" // 289 override fun partOne(): Any { return bags.count { Bag.canContain(it, bagColour) } } // 30055 override fun partTwo(): Any { return Bag.mustContain(Ba...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
2,202
aoc-2020
Creative Commons Zero v1.0 Universal
kotlin/src/com/s13g/aoc/aoc2020/Day12.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.* /** * --- Day 12: Rain Risk --- * https://adventofcode.com/2020/day/12 */ class Day12 : Solver { private val dirVec = hashMapOf('N' to XY(0, 1), 'S' to XY(0, -1), 'W' to XY(-1, 0), 'E' to XY(1, 0)) private var dirs = listOf('N', 'E', 'S', 'W') override fun s...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,503
euler
Apache License 2.0
kotlin/SuffixArray.kt
indy256
1,493,359
false
{"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571}
fun suffixArray(S: CharSequence): IntArray { val n = S.length // Stable sort of characters. // Same characters are sorted by their position in descending order. // E.g. last character which represents suffix of length 1 should be ordered first among same characters. val sa = S.indices.reversed().so...
97
Java
561
1,806
405552617ba1cd4a74010da38470d44f1c2e4ae3
1,957
codelibrary
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem2131/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2131 /** * LeetCode page: [2131. Longest Palindrome by Concatenating Two Letter Words](https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) where N is the size of words. Space...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,082
hj-leetcode-kotlin
Apache License 2.0
src/Day02.kt
iartemiev
573,038,071
false
{"Kotlin": 21075}
import java.lang.IllegalArgumentException // Super verbose solution - wanted to play with enums with anonymous classes enum class PlayerMove(val move: RockPaperScissors) { X(RockPaperScissors.ROCK), Y(RockPaperScissors.PAPER), Z(RockPaperScissors.SCISSORS) } enum class OpponentMove(val move: RockPaperScissors) { ...
0
Kotlin
0
0
8d2b7a974c2736903a9def65282be91fbb104ffd
3,587
advent-of-code
Apache License 2.0
src/day10/Day10.kt
blundell
572,916,256
false
{"Kotlin": 38491}
package day10 import readInput fun main() { data class Instruction(val op: String, val value: Int) { override fun toString(): String { return "$op $value" } } fun part1(input: List<String>): Int { val instructions = input.map { val op = it.substring(0..3) ...
0
Kotlin
0
0
f41982912e3eb10b270061db1f7fe3dcc1931902
2,441
kotlin-advent-of-code-2022
Apache License 2.0
src/Day02.kt
touchman
574,559,057
false
{"Kotlin": 16512}
import java.lang.Exception fun main() { val input = readInput("Day02") fun part1(input: List<String>) = input.map { it.split(" ") .let { parseItem(it[0]) to parseItem(it[1]) }.let { pair -> getResult(pair.second, pair....
0
Kotlin
0
0
4f7402063a4a7651884be77bb9e97828a31459a7
2,202
advent-of-code-2022
Apache License 2.0
src/main/kotlin/mytechtoday/aoc/year2022/Day3.kt
mytechtoday
572,836,399
false
{"Kotlin": 15268, "Java": 1717}
package mytechtoday.aoc.year2022 import mytechtoday.aoc.util.readInput fun main() { fun getPriority(charItem: Char): Int { if(charItem.toInt() in 97..122) { return charItem.toInt() - 96; } if(charItem.toInt() in 65..90) { return charItem.toInt() - 38; } ...
0
Kotlin
0
0
3f25cb010e6367af20acaa2906aff17a80f4e623
1,676
aoc2022
Apache License 2.0
kotlin/graphs/shortestpaths/DijkstraSlow.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.shortestpaths import java.util.stream.Stream // https://en.wikipedia.org/wiki/Dijkstra's_algorithm object DijkstraSlow { // calculate shortest paths in O(V^2) fun shortestPaths(graph: Array<List<Edge>>, s: Int, prio: IntArray, pred: IntArray) { val n = graph.size Arrays.fill(pre...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,844
codelibrary
The Unlicense
app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/playground/challenges/SearchingChallenge.kt
ahuamana
627,986,788
false
null
package com.lukaslechner.coroutineusecasesonandroid.playground.challenges //find the longest substring that contains k unique characters //The input string str must have at least length 2. //The first character of str must be a digit between 1 and 6 (inclusive), representing the number of unique characters in the long...
0
Kotlin
0
0
931ce884b8c70355e38e007141aab58687ed1909
2,377
KotlinCorutinesExpert
Apache License 2.0
src/main/kotlin/com/rubengees/pathfinder/PathFinder.kt
rubengees
159,884,211
false
null
package com.rubengees.pathfinder import java.util.PriorityQueue /** * Entry point for path calculation. * The A* algorithm is used to find an optimal way between a [CoordinateType.START] coordinate and an * [CoordinateType.END] coordinate on the given input. * * @author <NAME> */ class PathFinder( private v...
0
Kotlin
0
0
c8499cc51e08b8196738c0990a75f6be85f514be
2,571
advent-of-kotlin-2018-week-1
MIT License
src/Day20.kt
mjossdev
574,439,750
false
{"Kotlin": 81859}
fun main() { // used to allow finding the right instance of a number with instanceOf class IdentityLong(val value: Long) { override fun toString(): String = value.toString() } fun decrypt(numbers: List<IdentityLong>, times: Int): Long { val workingNumbers = numbers.toMutableList() ...
0
Kotlin
0
0
afbcec6a05b8df34ebd8543ac04394baa10216f0
1,482
advent-of-code-22
Apache License 2.0
src/Day02.kt
dyomin-ea
572,996,238
false
{"Kotlin": 21309}
fun main() { /* * A X rock * B Y paper * C Z scissors * */ fun pointsOf(value: String): Int = when (value) { "A", "X" -> 1 "B", "Y" -> 2 "C", "Z" -> 3 else -> error("unknown value") } fun getScore(l: String, r: String): Int...
0
Kotlin
0
0
8aaf3f063ce432207dee5f4ad4e597030cfded6d
1,879
advent-of-code-2022
Apache License 2.0