path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/day20/solution.kt
bukajsytlos
433,979,778
false
{"Kotlin": 63913}
package day20 import java.io.File fun main() { val lines = File("src/main/kotlin/day20/input.txt").readLines() val imageEnhancementAlgorithm: BooleanArray = lines[0].map { it == '#' }.toBooleanArray() val imageYSize = lines.size + 2 val imageXSize = lines[2].length + 4 val image = InfiniteImage( ...
0
Kotlin
0
0
f47d092399c3e395381406b7a0048c0795d332b9
2,746
aoc-2021
MIT License
app/src/y2021/day20/Day20TrenchMap.kt
henningBunk
432,858,990
false
{"Kotlin": 124495}
package y2021.day20 import common.* import common.annotations.AoCPuzzle fun main(args: Array<String>) { Day20TrenchMap().solveThem() } @AoCPuzzle(2021, 20) class Day20TrenchMap : AocSolution { override val answers = Answers(samplePart1 = 35, samplePart2 = 3351, part1 = 5622) override fun solvePart1(inpu...
0
Kotlin
0
0
94235f97c436f434561a09272642911c5588560d
2,488
advent-of-code-2021
Apache License 2.0
src/Day25.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
fun main() { val base = 5 val digits = "012=-" fun snafuToDec(snafu: String): Long { return snafu.fold(0) { carry, digit -> (carry * base) + when(digit) { '=' -> -2 '-' -> -1 else -> digit.digitToInt() } } } fu...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
819
aoc-2022
Apache License 2.0
src/Day22.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
import com.sun.source.tree.LiteralTree fun main() { var dRow = listOf<Int>(0, 1, 0, -1) var dCol = listOf<Int>(1, 0, -1, 0) fun parseInstructions(line: String): MutableList<String> { var instructions = mutableListOf<String>() var lst = "" for (c in line) { if (c == 'L' ...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
10,339
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/aoc19/Day4.kt
tahlers
225,198,917
false
null
package aoc19 object Day4 { fun isValid(s: String): Boolean { val containsDouble = s.toSet().size != s.length val noDecrease = isNotDecreasing(s) return containsDouble && noDecrease } fun isValid2(s: String): Boolean { val hasAtLeastOneSingleDouble = hasAtLeastOneSingleDou...
0
Kotlin
0
0
dae62345fca42dd9d62faadf78784d230b080c6f
1,599
advent-of-code-19
MIT License
2019/02 - 1202 Program Alarm/kotlin/src/app.kt
Adriel-M
225,250,242
false
null
import java.io.File fun getProgram(path: String): List<Int> { val unparsedProgram = File(path).readLines() return unparsedProgram[0].split(",").map { it.toInt() } } fun executeAdd(program: MutableList<Int>, currentIndex: Int) { val indexA = program[currentIndex + 1] val indexB = program[currentIndex +...
0
Kotlin
0
0
ceb1f27013835f13d99dd44b1cd8d073eade8d67
2,061
advent-of-code
MIT License
src/main/kotlin/adventofcode/year2020/Day21AllergenAssessment.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day21AllergenAssessment(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val foods by lazy { input.lines().map(Food::invoke) } override fun partOne(): Int { val ingredientsToAllergens = foo...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,588
AdventOfCode
MIT License
src/Day01.kt
sms-system
572,903,655
false
{"Kotlin": 4632}
fun main() { fun getListOfCalories(input: List<String>): List<Int> { return input.fold(mutableListOf(0)) { acc, item -> if (item.isBlank()) acc.add(0) else acc[acc.size - 1] = acc.last() + item.toInt() acc } } fun part1(input: List<String>): Int { ...
0
Kotlin
0
0
266dd4e52f3b01912fbe2aa23d1ee70d1292827d
748
adventofcode-2022-kotlin
Apache License 2.0
KotlinAdvent2018/week1/src/main/kotlin/net/twisterrob/challenges/adventOfKotlin2018/week1/AStar.kt
TWiStErRob
136,539,340
false
{"Kotlin": 104880, "Java": 11319}
package net.twisterrob.challenges.adventOfKotlin2018.week1 import net.twisterrob.challenges.adventOfKotlin2018.week1.Map.Cell import net.twisterrob.challenges.adventOfKotlin2018.week1.Map.Cell.End import net.twisterrob.challenges.adventOfKotlin2018.week1.Map.Cell.Path import net.twisterrob.challenges.adventOfKotlin201...
1
Kotlin
1
2
5cf062322ddecd72d29f7682c3a104d687bd5cfc
4,472
TWiStErRob
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem1870/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1870 /** * LeetCode page: [1870. Minimum Speed to Arrive on Time](https://leetcode.com/problems/minimum-speed-to-arrive-on-time/); */ class Solution { private val minPossibleSpeed = 1 private val maxPossibleSpeed = 10_000_000 private val valueIfCanNotOnTime = -1 ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,441
hj-leetcode-kotlin
Apache License 2.0
algorithms_and_data_structure/with_kotlin/algoritms/LinearSearchAlgorithms.kt
ggsant
423,455,976
false
{"Dart": 27223, "Kotlin": 6516}
/** * Idea: Go through the vector, analyzing each position i. If A[i].key equals K, then it found the * position and returns i. If you went through the entire vector and no element equal to K exists, * then return -1. * * Linear search is an algorithm which finds the position of a target value within an array (Usu...
0
Dart
0
1
8ebed6dd46cdbdfada6f19610479191bcc37dd22
1,012
algorithms_analysis_and_data_structure
MIT License
Day3/spiral_memory.kt
fpeterek
155,423,059
false
null
import kotlin.math.abs import kotlin.math.ceil import kotlin.math.sqrt fun findNearestSquareRoot(num: Int): Int { val nearestRoot = ceil(sqrt(num.toDouble())).toInt() return if (nearestRoot % 2 == 0) { nearestRoot + 1 } else { nearestRoot } } fun main(args: Array<String>) { val...
0
Kotlin
0
0
d5bdf89e106cd84bb4ad997363a887c02cb6664b
1,533
Advent-Of-Code
MIT License
AOC2022/src/main/kotlin/AOC7.kt
bsautner
575,496,785
false
{"Kotlin": 16189, "Assembly": 496}
import java.io.File class AOC7 { private val input = File("/home/ben/aoc/input-7.txt") private val list = mutableListOf<String>() private var PWD = Node("root", null) //Present Working Directory var spaceNeeded = 0L var winner = 70000000L fun process() { input.forEachLine { list.add...
0
Kotlin
0
0
5f53cb1c4214c960f693c4f6a2b432b983b9cb53
3,443
Advent-of-Code-2022
The Unlicense
util/src/main/java/com/arcadan/util/math/QuadraticEquation.kt
ArcaDone
351,158,574
false
null
package com.arcadan.util.math import java.lang.Math.* import kotlin.math.pow data class QuadraticEquation(val a: Double, val b: Double, val c: Double) { data class Complex(val r: Double, val i: Double) { override fun toString() = when { i == 0.0 -> r.toString() r == 0.0 -> "${i}i" ...
0
Kotlin
0
2
24133757b19f2b2fea64542347b339f8621284f6
1,196
DodgeTheEnemies
MIT License
tonilopezmr/day6/MemoryBankPartTwo.kt
CloudCoders
112,667,277
false
{"Mathematica": 37090, "Python": 36924, "Scala": 26540, "Kotlin": 24988, "Ruby": 5084, "Java": 4495, "JavaScript": 3440, "MATLAB": 3013}
package day6 import kategory.combine import org.junit.Assert.assertEquals import org.junit.Test class MemoryBankPartTwo { private fun chooseBank(input: List<Int>): Pair<Int, Int> = input.foldRightIndexed(P(0, 0)) { idx, bank, (index, blocks) -> if (bank >= blocks) P(idx, bank) else P(index, blocks) ...
2
Mathematica
0
8
5a52d1e89076eccb55686e4af5848de289309813
2,151
AdventOfCode2017
MIT License
2021/src/test/kotlin/Day13.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.test.Test import kotlin.test.assertEquals class Day13 { data class Coord(var x: Int, var y: Int) enum class Axis { X, Y } data class Instruction(val axis: Axis, val value: Int) @Test fun `run part 01`() { val (coords, instructions) = getPaper() coords.foldAxis(instru...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
2,299
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountSubarrays.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,801
kotlab
Apache License 2.0
day3/src/main/kotlin/part2.kt
Lysoun
725,939,287
false
{"Kotlin": 16038, "OCaml": 224}
package day3 import java.io.File fun computeGearRatio(maybeGearPosition: Pair<Int, Int>, numbers: MutableMap<Pair<Int, Int>, Int>): Int { val neighbourNumbers = listOf( maybeGearPosition.first to maybeGearPosition.second -1, maybeGearPosition.first + 1 to maybeGearPosition.second -1, maybe...
0
Kotlin
0
0
96ecbcef1bd29a97f2230457f4e233ca6b1cc108
2,053
advent-of-code-2023
MIT License
src/main/kotlin/io/matrix/SnakesAndLadders.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.matrix class SnakesAndLadders { fun snakesAndLadders(board: Array<IntArray>): Int = executeRecursive(board) fun executeRecursive(board: Array<IntArray>): Int { val visited = mutableSetOf<Int>() var stack = listOf(0) var steps = 0 var found = false while (stack.isNotEmpty() && !foun...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
3,266
coding
MIT License
lite-math/src/commonMain/kotlin/ppanda/commons/bundle/math/constructs/Fraction.kt
pPanda-beta
305,866,321
false
null
package ppanda.commons.bundle.math.constructs import ppanda.commons.bundle.math.elements.ArithmeticElement import ppanda.commons.bundle.math.groups.Group data class Fraction private constructor( val numerator: Int, val denominator: Int, ) : ArithmeticElement<Fraction> { // TODO: Allow initializati...
0
Kotlin
0
0
f5b56f4bf3914c0fe32b2e0fc72917e91a06b2a4
1,967
commons-lite
MIT License
codeforces/ozon2020/f.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.ozon2020 import kotlin.random.Random val r = Random(566) fun main() { readLn() val a = readStrings().map { it.toLong() }.shuffled(r) val toCheck = List(1 shl 6) { a[it % a.size] + r.nextInt(3) - 1 }.toSet() val primes = toCheck.flatMap { primes(it) }.toSet().sorted() val ans = primes.fold(a.s...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
847
competitions
The Unlicense
src/main/kotlin/tr/emreone/adventofcode/days/Day14.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.Logger.logger import tr.emreone.kotlin_utils.automation.Day class Day14 : Day(14, 2021, "Extended Polymerization") { override fun part1(): Int { val template = inputAsList.first() val rules = inputAsList.drop(2).associate { ...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
2,510
advent-of-code-2021
Apache License 2.0
src/day02/Day02v2.kt
spyroid
433,555,350
false
null
package day02 import readInput fun main() { data class Command(val op: String, val value: Int) open class Engine { var depth = 0 var horizontal = 0 fun input(seq: Sequence<Command>): Engine { seq.forEach { when (it.op) { "forward" -> f...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
1,791
Advent-of-Code-2021
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CrackingTheSafe.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,167
kotlab
Apache License 2.0
base/sdk-common/src/main/java/com/android/ide/common/util/PathMap.kt
qiangxu1996
255,410,085
false
{"Java": 38854631, "Kotlin": 10438678, "C++": 1701601, "HTML": 795500, "FreeMarker": 695102, "Starlark": 542991, "C": 148853, "RenderScript": 58853, "Shell": 51803, "CSS": 36591, "Python": 32879, "XSLT": 23593, "Batchfile": 8747, "Dockerfile": 7341, "Emacs Lisp": 4737, "Makefile": 4067, "JavaScript": 3488, "CMake": 329...
/* * Copyright (C) 2018 The Android Open Source Project * * 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 app...
1
Java
1
1
3411c5436d0d34e6e2b84cbf0e9395ac8c55c9d4
1,907
vmtrace
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1239/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1239 /** * LeetCode page: [1239. Maximum Length of a Concatenated String with Unique Characters](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/); */ class Solution { /* Complexity: * Time O(2^N) and Space O(N) where N is th...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,658
hj-leetcode-kotlin
Apache License 2.0
practice-4/src/practice4e.kt
jomartigcal
266,662,951
false
null
// Special Permutation // https://codeforces.com/contest/1347/problem/E private fun readLn() = readLine()!! private fun readInt() = readLn().toInt() private fun readStrings() = readLn().split(" ") private fun readInts() = readStrings().map { it.toInt() } fun main() { val lines = readInt() for (line in 1..li...
0
Kotlin
0
0
ad1677940fa006e59e9b0f2ce6c6b26e7d76c6c3
894
kotlin-heroes
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day19.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import kotlin.math.log2 object Day19 : AdventSolution(2016, 19, "An Elephant Named Joseph") { //Jospehus problem override fun solvePartOne(input: String): String { val solved = 2 * (input.toInt() - (1 shl log2(input.toDouble()).toInt())...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,084
advent-of-code
MIT License
src/Day08.kt
sabercon
648,989,596
false
null
fun main() { tailrec fun run(instruction: List<Pair<String, Int>>, acc: Int, i: Int, visited: Set<Int>): Pair<Boolean, Int> { if (i in visited) return false to acc if (i == instruction.size) return true to acc val (op, arg) = instruction[i] val (newAcc, j) = when (op) { ...
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
1,173
advent-of-code-2020
MIT License
src/day07/Day07Answer1.kt
IThinkIGottaGo
572,833,474
false
{"Kotlin": 72162}
package day07 import readInput /** * Answers from [Advent of Code 2022 Day 7 | Kotlin](https://youtu.be/Q819VW8yxFo) */ fun main() { val day7 = Day7(readInput("day07")) println(day7.part1()) // 1723892 println(day7.part2()) // 8474158 } private val PATTERN = """[$] cd (.*)|(\d+).*""".toRegex() cl...
0
Kotlin
0
0
967812138a7ee110a63e1950cae9a799166a6ba8
1,360
advent-of-code-2022
Apache License 2.0
src/kotlin/_2022/Task07.kt
MuhammadSaadSiddique
567,431,330
false
{"Kotlin": 20410}
package _2022 import Task import readInput object Task07 : Task { private const val MAX_SPACE = 100_000 private const val NEEDED_SPACE = 30_000_000 private const val TOTAL_SPACE = 70_000_000 override fun partA() = buildFilesystem().root.flatten() .map { it.space() } .filter { space -...
0
Kotlin
0
0
3893ae1ac096c56e224e798d08d7fee60e299a84
2,180
AdventCode-Kotlin
Apache License 2.0
src/main/kotlin/aoc2020/RainRisk.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2020 import komu.adventofcode.utils.Dir import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Point fun rainRisk1(input: List<String>): Int { val instructions = input.map { ShipInstruction.parse(it) } var direction = Direction.RIGHT var ship = Point.ORIGIN ...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,503
advent-of-code
MIT License
src/main/kotlin/day14.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.Input import shared.Point import shared.XYMap fun main() { val input = Input.day(14) println(day14A(input)) println(day14B(input)) } fun day14A(input: Input): Int { val platform = Platform(input) platform.roll(0, -1) return platform.loadNorthSupportBeams() } fun day14B(input: In...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,690
AdventOfCode2023
MIT License
src/main/kotlin/g0501_0600/s0552_student_attendance_record_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0552_student_attendance_record_ii // #Hard #Dynamic_Programming #2023_01_17_Time_151_ms_(100.00%)_Space_33.3_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun checkRecord(n: Int): Int { if (n == 0 || n == 1 || n == 2) { return n * 3 + n * (n - 1) } ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,711
LeetCode-in-Kotlin
MIT License
src/Day10.kt
luiscobo
574,302,765
false
{"Kotlin": 19047}
import java.lang.StringBuilder enum class ProgramInstruction(val cycles: Int) { NOOP(1), ADDX(2) } fun parseInstruction(line: String): Pair<ProgramInstruction, Int> { val components = line.split(" ") if (components[0] == "noop") { return ProgramInstruction.NOOP to 0 } val num = compone...
0
Kotlin
0
0
c764e5abca0ea40bca0b434bdf1ee2ded6458087
2,055
advent-of-code-2022
Apache License 2.0
src/Day10.kt
zfz7
573,100,794
false
{"Kotlin": 53499}
fun main() { println(day10A(readFile("Day10"))) println(day10B(readFile("Day10"))) } fun day10B(input: String): String { val ops = input.trim().split("\n") var cycle = 1 var pos = 0 var reg = 1 var screen = "" ops.forEach { op -> if (op == "noop") { println("pos: $p...
0
Kotlin
0
0
c50a12b52127eba3f5706de775a350b1568127ae
1,860
AdventOfCode22
Apache License 2.0
src/main/kotlin/days/Day8.kt
hughjdavey
159,955,618
false
null
package days class Day8 : Day(8) { private val root = parseTree(inputString) override fun partOne(): Any { return metadataSum(root) } override fun partTwo(): Any { return nodeValue(root) } data class AocNode(val header: Pair<Int, Int>, val childNodes: List<AocNode>, val meta...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
1,418
aoc-2018
Creative Commons Zero v1.0 Universal
src/main/kotlin/g0901_1000/s0954_array_of_doubled_pairs/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0954_array_of_doubled_pairs // #Medium #Array #Hash_Table #Sorting #Greedy // #2023_05_02_Time_462_ms_(100.00%)_Space_92.1_MB_(50.00%) class Solution { fun canReorderDoubled(arr: IntArray): Boolean { val max = 0.coerceAtLeast(arr.max()) val min = 0.coerceAtMost(arr.min()) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,103
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g0301_0400/s0363_max_sum_of_rectangle_no_larger_than_k/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0363_max_sum_of_rectangle_no_larger_than_k // #Hard #Array #Dynamic_Programming #Binary_Search #Matrix #Ordered_Set // #2022_11_19_Time_243_ms_(100.00%)_Space_36.1_MB_(100.00%) class Solution { fun maxSumSubmatrix(matrix: Array<IntArray>, k: Int): Int { if (matrix.size == 0 || matrix[0...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,600
LeetCode-in-Kotlin
MIT License
src/main/kotlin/io/math/IntegerToEnglishWords.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.math import io.utils.runTests import java.lang.StringBuilder private val LESS_THAN_20 = arrayOf("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen") private val TENS = a...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,690
coding
MIT License
AdventOfCodeDay17/src/nativeMain/kotlin/Day17.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
import kotlin.math.absoluteValue import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt typealias Point = Pair<Int,Int> typealias TargetArea = Pair<IntRange, IntRange> typealias Velocity = Pair<Int, Int> typealias Path = List<Point> class Day17(private val lines:List<String>) { fun solvePart1()...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
4,277
AdventOfCode2021
The Unlicense
test/leetcode/LetterCombinationsOfAPhoneNumber.kt
andrej-dyck
340,964,799
false
null
package leetcode import lib.StringArrayArg import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.converter.ConvertWith import org.junit.jupiter.params.provider.CsvSource /** * https://leetcode.com/problems/letter-combinations-of-a-phone-nu...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
2,488
coding-challenges
MIT License
src/Day01.kt
roxanapirlea
572,665,040
false
{"Kotlin": 27613}
fun main() { fun getFoodByElf(input: String): List<Long> = input.split("${System.lineSeparator()}${System.lineSeparator()}") .map { foodByElf -> foodByElf.split(System.lineSeparator()) .map { foodItem -> foodItem.toLong() } .reduce { acc, i...
0
Kotlin
0
0
6c4ae6a70678ca361404edabd1e7d1ed11accf32
876
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MissingNumberInProgression.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
2,058
kotlab
Apache License 2.0
kotlin/0518-coin-change-ii.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}
/* * DP with O(n) memory */ class Solution { fun change(amount: Int, coins: IntArray): Int { val dp = IntArray(amount + 1) dp[0] = 1 for (coin in coins) { for (i in 1..amount) { if (i - coin >= 0) dp[i] += dp[i - coin] } } ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,503
leetcode
MIT License
src/Day01.kt
rmyhal
573,210,876
false
{"Kotlin": 17741}
import java.util.* import kotlin.math.max fun main() { fun part1(input: List<String>): Long { return maxCalories(input) } fun part2(input: List<String>): Long { return max3Calories(input) } val input = readInput("Day01") println(part1(input)) println(part2(input)) } private fun maxCalories(inp...
0
Kotlin
0
0
e08b65e632ace32b494716c7908ad4a0f5c6d7ef
1,177
AoC22
Apache License 2.0
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day10/Space.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day10 import com.github.jrhenderson1988.adventofcode2019.angle import com.github.jrhenderson1988.adventofcode2019.manhattanDistance import com.github.jrhenderson1988.adventofcode2019.pointsBetween class Space(map: String) { private val asteroids = parseAsteroidC...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
2,245
advent-of-code
Apache License 2.0
proyek-submission-mpk-2.0.2/src/main/kotlin/com/dicoding/exam/latihanopsional2/App.kt
gilarc
716,165,676
false
{"Kotlin": 77659, "JavaScript": 252}
/**************************************************************************************************** * Perhatian * * * * Ag...
0
Kotlin
0
0
c4e7af027d018681ae47bf7d176b6145581b1fdb
2,356
myDicodingSubmissions
MIT License
2020/day5/day5.kt
flwyd
426,866,266
false
{"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398}
/* * Copyright 2021 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. */ package day5 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input: 7 ...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
2,658
adventofcode
MIT License
src/main/kotlin/Day005.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
class Day005 { data class Instruction(val count: Int, val source: Int, val target: Int) fun part1(lines: List<String>): String { val numberOfContainers = lines.first { it.trim().startsWith("1") }.trim().last().digitToInt() val containers = List(numberOfContainers) { ArrayDeque<Char>() } ...
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
2,471
aoc-2022-kotlin
Apache License 2.0
app/src/main/java/com/tripletres/platformscience/domain/ShipmentDriverAssignation.kt
daniel553
540,959,283
false
{"Kotlin": 95616}
package com.tripletres.platformscience.domain import com.tripletres.platformscience.domain.algorithm.IAssignationAlgorithm import com.tripletres.platformscience.domain.model.Driver import com.tripletres.platformscience.domain.model.Shipment import com.tripletres.platformscience.util.commonFactors import com.tripletres...
0
Kotlin
0
0
2ea5962dc0ad349ae97b277ab4ecf9e9a0aee1e6
5,572
PlatformScience
FSF All Permissive License
src/Day06.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
fun main() { fun part1(input: String, windowSize: Int = 4): Int { input.windowed(windowSize) { window -> val set = mutableSetOf<Char>() set.addAll(window.asSequence()) set.size }.forEachIndexed { index, value -> if (value == windowSize) return inde...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
1,107
AdventOfCode
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day18.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.extensions.MutableMapGrid import tr.emreone.kotlin_utils.extensions.area import tr.emreone.kotlin_utils.extensions.formatted import tr.emreone.kotlin_utils.math.* import java.util.LinkedList import kotlin...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
3,188
advent-of-code-2023
Apache License 2.0
src/questions/FormatPhoneNumber.kt
realpacific
234,499,820
false
null
package questions /** * Given a phone number should format in the form of abc-def-ijk. Last two part can be of 2 digits */ fun main() { solution("00-44 48 5555 83612").also { println(it) } solution("00-44 48 5555 8361").also { println(it) } solution("00-44 48 5555 836122").also { println(it) } ...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,067
algorithms
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-18.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.BooleanGrid import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.toBooleanGrid import com.github.ferinagy.adventOfCode.contains import com.github.ferinagy.adventOfCode.get import com.github.ferin...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,499
advent-of-code
MIT License
algorithms/src/main/kotlin/io/nullables/api/playground/algorithms/QuickSort.kt
AlexRogalskiy
331,076,596
false
null
/* * Copyright (C) 2021. <NAME>. All Rights Reserved. * * 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 applic...
13
Kotlin
2
2
d7173ec1d9ef227308d926e71335b530c43c92a8
2,391
gradle-kotlin-sample
Apache License 2.0
src/net/sheltem/aoc/y2015/Day06.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2015 import net.sheltem.common.PositionInt import net.sheltem.aoc.y2015.Action.OFF import net.sheltem.aoc.y2015.Action.ON import net.sheltem.aoc.y2015.Action.TOGGLE import java.lang.Integer.max suspend fun main() { Day06().run() } class Day06 : Day<Int>(998996, 1001996) { override su...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,370
aoc
Apache License 2.0
src/main/kotlin/co/csadev/advent2022/Day05.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2022 by <NAME> * Advent of Code 2022, Day 5 * Problem Description: http://adventofcode.com/2021/day/5 */ package co.csadev.advent2022 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsText class Day05(override val input: String = resourceAsText("22day05.tx...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,733
advent-of-kotlin
Apache License 2.0
src/Day10.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
fun main() { fun part1(input: List<String>): Int { var x = 1 var cycle = 0 var ans = 0 fun checkCycle() { if ((cycle - 20) % 40 == 0) { ans += cycle * x } } input.forEach { line -> val splits = line.split(" ") ...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
1,670
aoc-2022-in-kotlin
Apache License 2.0
src/Day06.kt
RobvanderMost-TomTom
572,005,233
false
{"Kotlin": 47682}
fun main() { fun detectMarker(input: String, length: Int): Int { return input.windowed(size=length, step=1) .withIndex() .first { it.value.toSet().size == it.value.length }.index + length } fun part1(input: String): Int { return detectMark...
5
Kotlin
0
0
b7143bceddae5744d24590e2fe330f4e4ba6d81c
1,170
advent-of-code-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/Djikstra.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph import java.util.* println("Test") val verticeA = Vertice("A") val verticeB = Vertice("B") val verticeC = Vertice("C") val verticeD = Vertice("D") val verticeE = Vertice("E") val verticeF = Vertice("F") val graph = WeightedDirectedGraph( listOf( verticeA, verticeB, vertic...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
4,105
KotlinAlgs
MIT License
src/main/aoc2021/Day22.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2021 class Day22(input: List<String>) { data class Cuboid(val xr: IntRange, val yr: IntRange, val zr: IntRange) { // The ranges are continuous and fairly large, avoid using count() which iterates over the whole range. private fun IntRange.size(): Int = last - first + 1 fun size()...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
5,039
aoc
MIT License
src/main/kotlin/abc/187-e.kt
kirimin
197,707,422
false
null
package abc import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val ab = (0 until n - 1).map { sc.next().toInt() to sc.next().toInt() } val q = sc.nextInt() val tex = (0 until q).map { Triple(sc.next().toInt(), sc.next().toInt(), sc.next().toLong()...
0
Kotlin
1
5
23c9b35da486d98ab80cc56fad9adf609c41a446
2,147
AtCoderLog
The Unlicense
src/MergeTwoLinkedLists.kt
max-f
221,919,191
false
{"Python": 13459, "Kotlin": 8011}
import common.ListNode /** * https://leetcode.com/problems/merge-two-sorted-lists/ * Example: * var li = ListNode(5) * var v = li.`val` * Definition for singly-linked list. * class ListNode(var `val`: Int) { * var next: ListNode? = null * } * * Example: 1 -> 2 -> 4, 1 -> 3 -> 4 * Result: 1-> 1 -> 2 -> 3...
0
Python
0
0
3fc1888484531a1a23b880f9875614e56f846564
2,457
leetcode
MIT License
kotlin/1020-number-of-enclaves.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}
class Solution { fun numEnclaves(grid: Array<IntArray>): Int { val rows = grid.size val cols = grid[0].size val dirs = arrayOf( intArrayOf(1, 0), intArrayOf(-1, 0), intArrayOf(0, 1), intArrayOf(0, -1) ) val visited = Array(rows...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,329
leetcode
MIT License
src/main/kotlin/cn/awpaas/learn/day02/Learn-5.kt
afterloe
135,126,786
false
{"Kotlin": 28646}
package cn.awpaas.learn.day02 /** * 过滤是最常进行的操作,那么列举下可能用到的几种常规 过滤操作函数 */ fun toStr(list: List<Any>): String = list.reduce { total, any -> total.toString() + any.toString() }.toString() fun main(args: Array<String>) { var list = mutableListOf<Any>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) // 获取前几个元素 println("the 3 ...
0
Kotlin
1
3
e747b4d2b331aa92d97bd8a514d53c9f3c59af6e
1,512
learn-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortingSentence.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,970
kotlab
Apache License 2.0
src/Day06.kt
meierjan
572,860,548
false
{"Kotlin": 20066}
import java.util.* private class BufferScanner( val bufferSize: Int = 4 ) { private val queue: ArrayDeque<Char> = ArrayDeque(bufferSize) fun read(char: Char) { queue.addFirst(char) if(queue.size > bufferSize) { queue.removeLast() } } fun scanUniqueness() : Boolean = ...
0
Kotlin
0
0
a7e52209da6427bce8770cc7f458e8ee9548cc14
1,507
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/y2023/day07/Day07.kt
niedrist
726,105,019
false
{"Kotlin": 19919}
package y2023.day07 import BasicDay import util.FileReader val players = FileReader.asStrings("2023/day07.txt").map { val (hand, bid) = it.split(' ') Player(hand.toCharArray().toList(), bid.toInt()) } fun main() = Day07.run() object Day07 : BasicDay() { override fun part1() = solve(false) override ...
0
Kotlin
0
1
37e38176d0ee52bef05f093b73b74e47b9011e24
1,076
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day8.kt
tpepper0408
317,612,203
false
null
package days class Day8 : Day<Int>(8) { override fun partOne(): Int { return run(parseInstructions()).first } override fun partTwo(): Int { val instructions = parseInstructions() //if not do some swapping. val interestingIndexes = instructions.mapIndexed { index, instructi...
0
Kotlin
0
0
67c65a9e93e85eeb56b57d2588844e43241d9319
1,846
aoc2020
Creative Commons Zero v1.0 Universal
src/questions/IntegerToRoman.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * Given an integer, convert it to a roman numeral. * * [Source](https://leetcode.com/problems/integer-to-roman/) */ @UseCommentAsDocumentation private object IntToRoman { private val conversionRules = TreeMa...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,362
algorithms
MIT License
src/Day01.kt
dominik003
573,083,805
false
{"Kotlin": 9376}
import java.util.* fun main() { fun part1(input: List<String>): Int { var maxVal: Int = Int.MIN_VALUE var cur = 0 input.forEach { if (it == "") { maxVal = if (cur > maxVal) cur else maxVal cur = 0 } else { cur += Integ...
0
Kotlin
0
0
b64d1d4c96c3dd95235f604807030970a3f52bfa
1,195
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/tripletres/platformscience/domain/algorithm/BranchAndBoundAlgorithm.kt
daniel553
540,959,283
false
{"Kotlin": 95616}
package com.tripletres.platformscience.domain.algorithm import com.tripletres.platformscience.domain.ShipmentDriverAssignation.SuitabilityScore import com.tripletres.platformscience.domain.algorithm.BranchAndBoundAlgorithm.Node import com.tripletres.platformscience.domain.model.Driver import com.tripletres.platformsci...
0
Kotlin
0
0
2ea5962dc0ad349ae97b277ab4ecf9e9a0aee1e6
7,871
PlatformScience
FSF All Permissive License
kotlin/yacht/src/main/kotlin/Yacht.kt
ErikSchierboom
27,632,754
false
{"C++": 14523188, "C": 1712536, "C#": 843402, "JavaScript": 766003, "Java": 570202, "F#": 559855, "Elixir": 504471, "Haskell": 499200, "Shell": 393291, "TypeScript": 381035, "Kotlin": 326721, "Scala": 321830, "Clojure": 303772, "Nim": 283613, "Ruby": 233410, "Elm": 157678, "Crystal": 155384, "Go": 152557, "Gleam": 1500...
object Yacht { fun solve(category: YachtCategory, vararg dices: Int) = when(category) { YachtCategory.ONES -> dices.digitScore(1) YachtCategory.TWOS -> dices.digitScore(2) YachtCategory.THREES -> dices.digitScore(3) YachtCategory.FOURS -> dices.digitScore(4) YachtCategory.FIV...
0
C++
10
29
d84c9d48a2d3adb0c37d7bd93c9a759d172bdd8e
1,495
exercism
Apache License 2.0
src/Day17.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.max private const val ROCK_COUNT = 2022 private const val FIELD_WIDTH = 7 private const val ITERATION_COUNT_FOR_PART2 = 1000000000000 fun main() { val testInput = readLine("Day17_test") val testSimulation = RockSimulation(testInput) check(testSimulation.simulate(ROCK_COUNT) == 3068) ...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,640
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day20.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
import kotlin.random.Random fun day20 (lines: List<String>) { val connections = parseConnections(lines) val modules = parseModules(lines, connections) var lowPulses = 0L var highPulses = 0L val rxSource = connections.find { it.second == "rx" }!!.first val rxSourceSources = connections.filter ...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
4,397
advent_of_code_2023
MIT License
exercises/src/main/kotlin/solutions/chapter2/Solution.kt
rmolinamir
705,132,794
false
{"Kotlin": 690308, "HTML": 34654, "CSS": 1900, "Shell": 593}
package solutions.chapter2 // Exercise 2.1: Chain Functions typealias FUN<A, B> = (A) -> B infix fun <A, B, C> FUN<A, B>.andThen(c: FUN<B, C>): FUN<A, C> = fun(a: A): C { val b = this return c(b(a)) } // Exercise 2.2: A Functional Stack data class FunStack<T>(private val elements: List<T> = emptyList()) { ...
0
Kotlin
0
0
ccfed75476263e780c5a8c61e02178532cc9f3f4
1,423
fotf
MIT License
src/main/kotlin/no/nav/helsearbeidsgiver/domene/inntektsmelding/v1/BestemmendeFravaersdag.kt
navikt
692,072,545
false
{"Kotlin": 64915}
package no.nav.helsearbeidsgiver.domene.inntektsmelding.v1 import java.time.DayOfWeek import java.time.LocalDate import java.time.temporal.ChronoUnit fun bestemmendeFravaersdag( arbeidsgiverperioder: List<Periode>, egenmeldingsperioder: List<Periode>, sykmeldingsperioder: List<Periode>, ): LocalDate { ...
1
Kotlin
0
0
57eaaf90ff48a4a5936203bf365e5c56bbb3fb48
2,328
hag-domene-inntektsmelding
MIT License
src/main/kotlin/com/github/solairerove/algs4/leprosorium/arrays/TwoSumSorted.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.arrays /** * Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, * find two numbers such that they add up to a specific target number. * * Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,223
algs4-leprosorium
MIT License
bowlingkata/src/main/kotlin/com/ubertob/fotf/bowlingkata/BowlingGameFP.kt
uberto
654,026,766
false
{"Kotlin": 670097, "HTML": 34654, "CSS": 1900, "Shell": 593}
package com.ubertob.fotf.bowlingkata enum class Pins(val number: Int) { zero(0), one(1), two(2), three(3), four(4), five(5), six(6), seven(7), eight(8), nine(9), ten(10) } data class BowlingGameFP(val rolls: List<Pins>, val scoreFn: (List<Pins>) -> Int) { val score by ...
1
Kotlin
4
10
0e02c3a3025a6f10d13ae75475d6dae5b12d59bd
2,762
fotf
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2015/Y2015D16.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2015 import io.github.pshegger.aoc.common.BaseSolver class Y2015D16 : BaseSolver() { override val year = 2015 override val day = 16 private val equalityChecker: AnalysisResult.(Int) -> Boolean = { value == it } private val greaterChecker: AnalysisResult.(Int) -> Boolea...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,246
advent-of-code
MIT License
arrays/AntiDiagonals/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
typealias IntArray2d = Array<IntArray> /** * Give a N*N square matrix, return an array of its anti-diagonals. * <br /> * https://www.interviewbit.com/problems/anti-diagonals/ */ fun diagonal(a: IntArray2d): IntArray2d { val n = a.size val res: MutableList<IntArray> = ArrayList(2 * n - 1) var i = 0 ...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,101
codility
MIT License
src/main/kotlin/days/Day17.kt
hughjdavey
317,575,435
false
null
package days import Coord import Coord3 import Coord4 class Day17 : Day(17) { // 401 override fun partOne(): Any { val initialCoords = inputList.mapIndexed { y, s -> s.mapIndexedNotNull { x, c -> if (c == '#') Coord3(x, y, 0) else null } }.flatten() val dimension = PocketDimension(initialCoor...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
2,615
aoc-2020
Creative Commons Zero v1.0 Universal
src/Day04.kt
zodiia
573,067,225
false
{"Kotlin": 11268}
fun main() { fun getRanges(input: List<String>) = input.map { line -> line.split(',').map { range -> range.split('-').map(String::toInt).let { it[0]..it[1] } } } fun IntRange.containedIn(other: IntRange) = first >= other.first && last <= other.last fun part1(input: List<Str...
0
Kotlin
0
1
4f978c50bb7603adb9ff8a2f0280f8fdbc652bf2
599
aoc-2022
Apache License 2.0
src/day09/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day09 import java.io.File const val workingDir = "src/day09" fun main() { val sample = File("$workingDir/sample.txt") val sample2 = File("$workingDir/sample2.txt") val input1 = File("$workingDir/input_1.txt") println("Step 1a: ${runStep1(sample)}") // 13 println("Step 1b: ${runStep1(input...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
5,824
advent-of-code-2022
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[112]路径总和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //给你二叉树的根节点 root 和一个表示目标和的整数 targetSum ,判断该树中是否存在 根节点到叶子节点 的路径,这条路径上所有节点值相加等于目标和 // targetSum 。 // // 叶子节点 是指没有子节点的节点。 // // // // 示例 1: // // //输入:root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 //输出:true // // // 示例 2: // // //输入:root = [1,2,3], targetSum = 5 //输出:false // ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,719
MyLeetCode
Apache License 2.0
src/Day01.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
class Day01(input: List<String>) { private val data = parseInput(input) fun partOne() = data.maxOf { it.sum() } fun partTwo() = data.map { it.sum() } .sortedDescending() .take(3) .sum() private companion object { fun parseInput(i...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
1,084
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/com/leetcode/37_SudokuSolver.kt
programmerr47
248,502,040
false
null
package com.leetcode /** * Sort of a bitset but inverse and only 9 bits */ class SudokuUnit { //possible value. Just bit mask of where i-th bit is either i value is possible in this cell or not var posValue: Int = INITIAL_MASK private set var possibilities: Int = 9 private set val is...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
8,390
problemsolving
Apache License 2.0
src/main/kotlin/daySeven/DaySeven.kt
janreppien
573,041,132
false
{"Kotlin": 26432}
package daySeven import AocSolution import java.io.File class DaySeven : AocSolution(7) { private val input = readInput() /** * I am not pound of this */ private fun readInput(): RootDirectory { val file = File("src/main/resources/inputs/daySeven/input.txt") val root = RootDire...
0
Kotlin
0
0
b53f6c253966536a3edc8897d1420a5ceed59aa9
3,440
aoc2022
MIT License
src/main/kotlin/days/day9/Day9.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day9 import days.Day class Day9: Day(false) { override fun partOne(): Any { val inputs = readInput().map { it.split(" ").map { it.toInt() } } val result = mutableListOf<Int>() for (input in inputs) { val listsUnitZero: MutableList<MutableList<Int>> = mutableListO...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
1,790
advent-of-code_2023
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem567/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem567 /** * LeetCode page: [567. Permutation in String](https://leetcode.com/problems/permutation-in-string/); */ class Solution { /* Complexity: * Time O(|s2|) and Space O(1); */ fun checkInclusion(s1: String, s2: String): Boolean { if (s1.length > s2.le...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,581
hj-leetcode-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/medium/NextPermutation.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 31. 下一个排列 * * 实现获取 下一个排列 的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 * 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 * 必须 原地 修改,只允许使用额外常数空间。 */ class NextPermutation { companion object { @JvmStatic fun main(args: Array<String>) { val nums = intArray...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
3,376
daily_algorithm
Apache License 2.0
src/main/kotlin/leveinshtein.kt
mxrpr
155,521,178
false
null
package com.mxr.example import kotlin.system.measureNanoTime /** * For learning purposes * * Two solutions: * 1. create Leveinshtein class * 2. extend CharSequence functionality */ class Leveinshtein { fun leveinshteinDistance(lhs: String, rhs: String): Int { if (lhs === rhs) return 0 if (l...
0
Kotlin
0
0
0082d8bc92a587138c929f4b5b0d43cfcd2a1e6b
2,262
learning
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2022/Day05.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 5: Supply Stacks](https://adventofcode.com/2022/day/5). */ object Day05 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2022/Day05") ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,375
advent-of-code
MIT License
src/main/kotlin/aoc2022/day2.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2022 import utils.loadInput import utils.partitionWhen // A Rock // B Paper // C Scissors // X Rock // Y Paper // Z Scissors // 0 Lost // 3 Lost // 6 Won fun main() { val lines = loadInput("/2022/day2") .bufferedReader() .readLines() // Part One lines.sumOf { play(it) } ...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
1,627
aoc-kotlin
Apache License 2.0
src/main/kotlin/problems/Day12.kt
PedroDiogo
432,836,814
false
{"Kotlin": 128203}
package problems class Day12(override val input: String) : Problem { override val number: Int = 12 private val START = "start" private val END = "end" private val connections: Map<String, Set<String>> = input.lines() .map { line -> line.split("-") } .flatMap { (a, b) -> listOf(Pair(a, ...
0
Kotlin
0
0
93363faee195d5ef90344a4fb74646d2d26176de
1,778
AdventOfCode2021
MIT License
src/Day02.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
import java.lang.Exception import java.lang.RuntimeException fun main() { fun getScoreOfShape(round: String): Int = when (round.last()) { 'X' -> 1 'Y' -> 2 'Z' -> 3 else -> throw Exception("Error getScoreOfShape") } fun getScoreOfOutcome(round: ...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
1,506
aoc22
Apache License 2.0
src/Day01.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun calories(input: List<String>): Sequence<Int> { val it = input.iterator() return generateSequence { var sum: Int? = null while (it.hasNext()) { val next = it.next().takeUnless(String::isEmpty)?.toInt() ?: break sum = (sum ?: 0) ...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
815
aockt
Apache License 2.0
src/Day03.kt
A55enz10
573,364,112
false
{"Kotlin": 15119}
fun main() { fun charToValue(char: Char): Int { var charNum: Int = char.hashCode() - 96 if (char.isUpperCase()) charNum += 32 + 26 return charNum } fun part1(input: List<String>): Int { var sum = 0 input.forEach { for (i in 0..it.length/2) { ...
0
Kotlin
0
1
8627efc194d281a0e9c328eb6e0b5f401b759c6c
1,093
advent-of-code-2022
Apache License 2.0
src/main/kotlin/y2022/Day05.kt
jforatier
432,712,749
false
{"Kotlin": 44692}
package y2022 import common.Resources.splitOnEmpty import java.util.* class Day05(private val data: List<String>) { data class Move(val size: Int, val start: Int, val dest: Int) class Cargo(val data: List<String>) { val stacksInput = data.splitOnEmpty() .first() /** ...
0
Kotlin
0
0
2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae
2,497
advent-of-code-kotlin
MIT License