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/com/ginsberg/advent2019/Day16.kt
tginsberg
222,116,116
false
null
/* * Copyright (c) 2019 by <NAME> */ /** * Advent of Code 2019, Day 16 - Flawed Frequency Transmission * Problem Description: http://adventofcode.com/2019/day/16 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day16/ */ package com.ginsberg.advent2019 import kotlin.math.absoluteValue ...
0
Kotlin
2
23
a83e2ecdb6057af509d1704ebd9f86a8e4206a55
1,749
advent-2019-kotlin
Apache License 2.0
src/Day08.kt
HylkeB
573,815,567
false
{"Kotlin": 83982}
fun main() { tailrec fun isVisible( grid: Array<Array<Int>>, rowIndex: Int, columnIndex: Int, treeHeight: Int, xDirection: Int, yDirection: Int ): Boolean { require(xDirection != 0 || yDirection != 0) { "Only one direction can be us...
0
Kotlin
0
0
8649209f4b1264f51b07212ef08fa8ca5c7d465b
4,655
advent-of-code-2022-kotlin
Apache License 2.0
src/Tasks.kt
DmitrySwan
360,247,950
false
null
fun main() { println( repeatedIntersection(intArrayOf(3, 6, 7, 8, 7, 9), mutableListOf(12, 6, 7, 6, 7, 565)) ) println(countLetters("AAGGDDDFBBBAAABB")) println(groupWords(arrayOf("ate", "tdb", "eat", "ref", "fer", "test"))) } fun repeatedIntersection(array1: IntArray, array2: MutableList<Int>)...
0
Kotlin
0
0
83dbf8b060b34b5286fc9b0a013725a98ae36960
1,066
KotlinEducation
MIT License
src/main/kotlin/net/rafaeltoledo/kotlin/advent/Day03.kt
rafaeltoledo
726,542,427
false
{"Kotlin": 11895}
package net.rafaeltoledo.kotlin.advent class Day03 { fun invoke(input: List<String>): Int { val positioning = input.toPositioning() return positioning.filter { it.checkBoundaries(input) }.sumOf { it.number } } fun invoke2(input: List<String>): Int { val positioning = input.toPositioning() ret...
0
Kotlin
0
0
7bee985147466cd796e0183d7c719ca6d01b5908
3,215
aoc2023
Apache License 2.0
src/main/kotlin/dk/lessor/Day5.kt
aoc-team-1
317,571,356
false
{"Java": 70687, "Kotlin": 34171}
package dk.lessor fun main() { val lines = readFile("day_5.txt") val b = lines.map(BoardingPass.Companion::parse).sortedBy { it.id } println(b.last().id) println(findId(b)) } fun findId(boardingPasses: List<BoardingPass>): Int { for ((index, bp) in boardingPasses.withIndex()) { if (index =...
0
Java
0
0
48ea750b60a6a2a92f9048c04971b1dc340780d5
1,535
lessor-aoc-comp-2020
MIT License
app/src/main/kotlin/com/resurtm/aoc2023/day05/Solution.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day05 /** * See the README.md file for more details on this one. */ fun launchDay05(testCase: String) { val env = readEnv(testCase) println("Day 05, part 01: ${solvePart1(env)}") println("Day 05, part 02: ${solvePart2(env)}") } /** * See the README.md file for more details o...
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
2,836
advent-of-code-2023
MIT License
src/Day07.kt
ty-garside
573,030,387
false
{"Kotlin": 75779}
// Day 07 - No Space Left On Device // https://adventofcode.com/2022/day/7 fun main() { class File( val name: String, val size: Int ) class Directory( val name: String = "", val root: Directory? = null, val parent: Directory? = null, val dirs: MutableMap<St...
0
Kotlin
0
0
49ea6e3ad385b592867676766dafc48625568867
7,588
aoc-2022-in-kotlin
Apache License 2.0
kotlin/misc/TernarySearch.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package misc import java.util.Random // https://en.wikipedia.org/wiki/Ternary_search // Finds the smallest i in [a, b] that maximizes f(i), assuming that f(a) < ... < f(i) ≥ ··· ≥ f(b) object TernarySearch { fun ternarySearch(f: IntUnaryOperator, fromInclusive: Int, toInclusive: Int): Int { var lo = fromI...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,262
codelibrary
The Unlicense
src/main/kotlin/days/Day4.kt
jgrgt
575,475,683
false
{"Kotlin": 94368}
package days import days.Day4Util.toRange class Day4 : Day(4) { override fun partOne(): Any { return inputList .map { line -> val (firstRangeString, secondRangeString) = line.split(",") val firstRange = toRange(firstRangeString) val secondRange ...
0
Kotlin
0
0
5174262b5a9fc0ee4c1da9f8fca6fb86860188f4
1,529
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day2.kt
maldoinc
726,264,110
false
{"Kotlin": 14472}
import java.io.File data class DeckSize(val red: Int, val green: Int, val blue: Int) fun getColorValues(draw: String, color: String): Sequence<Int> = Regex("(\\d+) $color").findAll(draw).map { it.groupValues[1].toInt() } fun getColorSum(draw: String, color: String): Int = getColorValues(draw, color).sum() f...
0
Kotlin
0
1
47a1ab8185eb6cf16bc012f20af28a4a3fef2f47
1,439
advent-2023
MIT License
archive/328/solve.kt
daniellionel01
435,306,139
false
null
/* === #328 Lowest-cost Search - Project Euler === We are trying to find a hidden number selected from the set of integers {1, 2, ..., n} by asking questions. Each number (question) we ask, has a cost equal to the number asked and we get one of three possible answers: "Your guess is lower than the hidden number", or ...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
2,230
euler
MIT License
src/Day13.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import java.io.File fun main() { fun parseInput(input: String): List<Pair<String, String>> { return input.split("\n\n").map { Pair(it.split("\n")[0], it.split("\n")[1]) } } fun parseSomething(input:MutableList<String>): Pair<MutableList<Any>, Int> { var res = mutableListOf<Any>() v...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
4,387
aoc22
Apache License 2.0
src/commonMain/kotlin/search/analysis.kt
jillesvangurp
271,782,317
false
null
package search import kotlin.math.min interface TextFilter { fun filter(text: String): String } class LowerCaseTextFilter : TextFilter { override fun filter(text: String): String { return text.lowercase() } } interface Tokenizer { fun tokenize(text: String): List<String> } class SplittingT...
0
Kotlin
1
4
0f4236bf891faa841c6e32fe37c9ab9d2e6ce7c5
2,468
querylight
MIT License
src/main/kotlin/days/Day02.kt
julia-kim
435,257,054
false
{"Kotlin": 15771}
package days import readInput fun main() { fun part1(input: List<String>): Int { // - forward X increases the horizontal position by X units. // - down X increases the depth by X units. // - up X decreases the depth by X units. var horizontalPosition = 0 var depth = 0 ...
0
Kotlin
0
0
5febe0d5b9464738f9a7523c0e1d21bd992b9302
1,833
advent-of-code-2021
Apache License 2.0
src/Day01.kt
petoS6
573,018,212
false
{"Kotlin": 14258}
fun main() { fun part1(input: List<String>): Int { return getSnackSum(input).max() } fun part2(input: List<String>): Int { return getSnackSum(input).sortedDescending().take(3).sum() } val testInput = readInput("Day01.txt") println(part1(testInput)) println(part2(testInput)) } private fun getSna...
0
Kotlin
0
0
40bd094155e664a89892400aaf8ba8505fdd1986
697
kotlin-aoc-2022
Apache License 2.0
src/main/kotlin/dfsbfs/특정_거리의_도시_찾기.kt
CokeLee777
614,704,937
false
null
package dfsbfs import java.util.* import kotlin.math.* fun main(){ val sc = Scanner(System.`in`) val n = sc.nextInt() //도시의 개수 val m = sc.nextInt() //도로의 개수 val k = sc.nextInt() //거리 정보 val x = sc.nextInt() //출발 도시의 번호 //최단거리 테이블 초기화 val distances = IntArray(n + 1) { 1e9.toInt...
0
Kotlin
0
0
919d6231c87fe4ee7fda6c700099e212e8da833f
1,935
algorithm
MIT License
day03/src/Day03.kt
simonrules
491,302,880
false
{"Kotlin": 68645}
import java.io.File import javax.xml.stream.events.Characters class Day03(path: String) { private val numbers = mutableListOf<String>() init { File(path).forEachLine { numbers.add(it) } } fun part1(): Int { var gamma = 0 var epsilon = 0 val sum = In...
0
Kotlin
0
0
d9e4ae66e546f174bcf66b8bf3e7145bfab2f498
2,274
aoc2021
Apache License 2.0
src/main/kotlin/days/Day4.kt
mstar95
317,305,289
false
null
package days import util.groupByEmpty class Day4 : Day(4) { override fun partOne(): Any { val props = getProps() val valid = props.filter { isValid(it.keys) } return valid.size } private fun getProps(): List<Map<Key, String>> { val groups = groupByEmpty(inputList) ...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
3,574
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/timakden/aoc/year2022/Day22.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.Point import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import ru.timakden.aoc.year2022.Day22.Facing.* import ru.timakden.aoc.year2022.Day22.Side.* import ru.timakden.aoc.year2022.Day22.Side.Companion.toSide /** * [Day 22: Monkey Ma...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
10,149
advent-of-code
MIT License
src/main/kotlin/days/Solution15.kt
Verulean
725,878,707
false
{"Kotlin": 62395}
package days import adventOfCode.InputHandler import adventOfCode.Solution import adventOfCode.util.PairOf private val String.hash get() = this.fold(0) { acc, c -> 17 * (acc + c.code) % 256 } private class HashMap { val boxes = List(256) { linkedMapOf<String, Int>() } fun execute(operation: String) { ...
0
Kotlin
0
1
99d95ec6810f5a8574afd4df64eee8d6bfe7c78b
1,316
Advent-of-Code-2023
MIT License
src/main/kotlin/adventofcode/year2022/Day09RopeBridge.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2022 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.Tuple.minus import adventofcode.common.Tuple.plus import adventofcode.year2022.Day09RopeBridge.Companion.Direction.D import adventofcode.year2022.Day09RopeBridge.Companion.Direction.L import adventofcode...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,112
AdventOfCode
MIT License
src/Day06.kt
chasebleyl
573,058,526
false
{"Kotlin": 15274}
fun String.allCharsUnique(): Boolean { val uniques = mutableSetOf<Char>() this.forEach { char -> uniques.add(char) } return uniques.size == this.length } fun main() { fun part1(input: List<String>): Int { val datastream = input[0] if (datastream.length < 4) return 0 ...
0
Kotlin
0
1
f2f5cb5fd50fb3e7fb9deeab2ae637d2e3605ea3
1,120
aoc-2022
Apache License 2.0
code/graph/Hungarian.kt
hakiobo
397,069,173
false
null
// https://open.kattis.com/problems/cordonbleu // https://open.kattis.com/problems/toursdesalesforce // Min Cost Match Matching private class Hungarian(val costs: Array<IntArray>) { // assuming a square matrix of costs val n = costs.size var adjustment = 0 val adjustmentByRow = IntArray(n) val adjustmen...
0
Kotlin
1
2
f862cc5e7fb6a81715d6ea8ccf7fb08833a58173
4,414
Kotlinaughts
MIT License
src/main/kotlin/g0601_0700/s0655_print_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0655_print_binary_tree // #Medium #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #2023_02_13_Time_176_ms_(100.00%)_Space_36_MB_(80.00%) import com_github_leetcode.TreeNode import java.util.LinkedList import kotlin.math.pow /* * Example: * var ti = TreeNode(5) * var v = ti.`val...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,719
LeetCode-in-Kotlin
MIT License
src/main/kotlin/days/Day8.kt
hughjdavey
572,954,098
false
{"Kotlin": 61752}
package days import xyz.hughjd.aocutils.Collections.takeWhileInclusive import xyz.hughjd.aocutils.Coords.Coord class Day8 : Day(8) { private val trees = Trees(inputList) private val treeCoords = trees.trees.indices.flatMap { y -> trees.trees[0].indices.map { x -> Coord(x, y) } ...
0
Kotlin
0
2
65014f2872e5eb84a15df8e80284e43795e4c700
2,257
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day04.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
fun main() { fun parseInput(input: List<String>) = input.map { elfPair -> elfPair.split(",", "-") .chunked(2) .map { it[0].toInt()..it[1].toInt() } } fun part1(input: List<String>): Int { return parseInput(input) .filter { it[0].all { sect...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
970
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CoinPath.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
3,090
kotlab
Apache License 2.0
src/main/kotlin/io/trie/MaximumXORInArray.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.trie import kotlin.math.pow // https://leetcode.com/explore/learn/card/trie/149/practical-application-ii/1057/ class MaximumXORInArray { fun executeInefficient(nums: IntArray): Int = nums.foldIndexed(0) { index, acc, value -> maxOf(acc, (index + 1 until nums.size).map { j -> nums[j].xor(v...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,749
coding
MIT License
src/com/wd/algorithm/leetcode/ALGO0002.kt
WalkerDenial
327,944,547
false
null
package com.wd.algorithm.leetcode import com.wd.algorithm.test class ListNode(var `val`: Int) { var next: ListNode? = null } /** * 2. 两数相加 * * 给你两个非空的链表,表示两个非负的整数。它们每位数字都是按照逆序的方式存储的,并且每个节点只能存储一位数字。 * 请你将两个数相加,并以相同形式返回一个表示和的链表。 * 你可以假设除了数字 0 之外,这两个数都不会以 0 开头。 * */ class ALGO0002 { /** * 方式一 ...
0
Kotlin
0
0
245ab89bd8bf467625901034dc1139f0a626887b
2,951
AlgorithmAnalyze
Apache License 2.0
src/Day07.kt
esteluk
572,920,449
false
{"Kotlin": 29185}
interface Node { val name: String fun size(): Int } data class File(override val name: String, val size: Int): Node { override fun size(): Int { return this.size } override fun toString(): String { return "- $name (file, size=$size)" } } data class Directory(override val name:...
0
Kotlin
0
0
5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73
4,953
adventofcode-2022
Apache License 2.0
src/shreckye/coursera/algorithms/Course 3 Programming Assignment #3 Question 3.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.io.File import java.util.* import kotlin.test.assertEquals val filename = args[0] val INDEX_LABEL_OFFSET = 1 val questionVertexLabels = intArrayOf(1, 2, 3, 4, 17, 117, 517, 997) val (numVertices, vertexWeights) = File(filename).bufferedReader().use { val numVertice...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
1,930
coursera-stanford-algorithms-solutions-kotlin
MIT License
advent-of-code-2022/src/test/kotlin/Day 9 Rope Bridge.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import kotlin.math.abs import org.junit.jupiter.api.Test class `Day 9 Rope Bridge` { @Test fun silverTest() { amountOfVisitedPoints(parseInput(testInput), true) shouldBe 13 } @Test fun silver() { amountOfVisitedPoints(parseInput(loadResource("day9"))) shouldBe 6197...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,827
advent-of-code
MIT License
src/main/kotlin/org/hydev/lcci/lcci_02.kt
VergeDX
334,298,924
false
null
package org.hydev.lcci import ListNode.Companion.joinNode import java.math.BigInteger // https://leetcode-cn.com/problems/remove-duplicate-node-lcci/ class ListNode(var `val`: Int) { var next: ListNode? = null companion object { fun removeDuplicateNodes(head: ListNode?): ListNode? { if (h...
0
Kotlin
0
0
9a26ac2e24b0a0bdf4ec5c491523fe9721c6c406
6,125
LeetCode_Practice
MIT License
2022/src/day23/day23.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day23 import GREEN import RESET import printTimeMillis import readInput data class Elf(val x: Int, val y: Int) { fun nextPos(elves: Set<Elf>, round: Int): Elf { val POS = listOf(north(), south(), west(), east()) val CHOSEN = listOf( Elf(x, y - 1), // up Elf(x, y + ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
4,267
advent-of-code
Apache License 2.0
src/main/kotlin/day14/Day14ChocolateCharts.kt
Zordid
160,908,640
false
null
package day14 import shared.readPuzzle fun recipeSequencer() = sequence { val scores = mutableListOf(3, 7) var (elf1, elf2) = 0 to 1 yieldAll(scores) while (true) { val newScore = scores[elf1] + scores[elf2] if (newScore >= 10) yield((newScore / 10).also { scores.add(it) })...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
893
adventofcode-kotlin-2018
Apache License 2.0
src/day06/Day06.kt
banshay
572,450,866
false
{"Kotlin": 33644}
package day06 import readInput fun main() { fun part1(input: List<String>): Int { return input.map { it.toSignal().indexOfStartSignal() }[0] } fun part2(input: List<String>): Int { return input.map { it.toSignal().indexOfMessageStart() }.also { println(it) }[0] } // test if imple...
0
Kotlin
0
0
c3de3641c20c8c2598359e7aae3051d6d7582e7e
1,220
advent-of-code-22
Apache License 2.0
src/Day06.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import java.math.BigInteger import java.util.regex.Pattern import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun main() { val input = readInput("Day06") var times = input[0].removePrefix("Time:").trim().split(Pattern.compile("\\W+")).map { it.toLong() } var distances = input[1].remov...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,138
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/day2/Day2.kt
mortenberg80
574,042,993
false
{"Kotlin": 50107}
package day2 import java.lang.IllegalArgumentException class Day2 { fun getGameStore(filename: String): GameStore { val readLines = this::class.java.getResourceAsStream(filename).bufferedReader().readLines() return GameStore( readLines.map { Round(Shape.fromString(it[0]), Shape.fromSt...
0
Kotlin
0
0
b21978e145dae120621e54403b14b81663f93cd8
3,268
adventofcode2022
Apache License 2.0
src/main/kotlin/io/github/kmakma/adventofcode/y2019/utils/Vector2D.kt
kmakma
225,714,388
false
null
package io.github.kmakma.adventofcode.y2019.utils import io.github.kmakma.adventofcode.utils.gcd import kotlin.math.* /** * integer vector, careful using [rotated] */ internal data class Vector2D(val x: Int, val y: Int) : Comparable<Vector2D> { // TODO rename to simpleVector val length = sqrt((x * x + y * y).to...
0
Kotlin
0
0
7e6241173959b9d838fa00f81fdeb39fdb3ef6fe
4,563
adventofcode-kotlin
MIT License
src/day01/Day01.kt
molundb
573,623,136
false
{"Kotlin": 26868}
package day01 import readInput import kotlin.math.max fun main() { val input = readInput(parent = "src/Day01", name = "Day01_input") println(solvePartOne(input)) println(solvePartTwo(input)) } private fun solvePartOne(input: List<String>): Int { var max = 0 var curr = 0 input.forEach { foodI...
0
Kotlin
0
0
a4b279bf4190f028fe6bea395caadfbd571288d5
1,284
advent-of-code-2022
Apache License 2.0
src/adventOfCode/day7Problem.kt
cunrein
159,861,371
false
null
package adventOfCode class CharGraph { var grid = arrayOf<Array<Int>>() var charMap = mutableMapOf<Char, Int>() init { var k = 0 for (i in 'A'..'Z') { var array = arrayOf<Int>() charMap.put(i, k) for (j in 'A'..'Z') { array += 0 ...
0
Kotlin
0
0
3488ccb200f993a84f1e9302eca3fe3977dbfcd9
2,798
ProblemOfTheDay
Apache License 2.0
src/main/kotlin/day14.kt
p88h
317,362,882
false
null
internal var counter = 0L internal data class FuzzyTree(var left: FuzzyTree?, var right: FuzzyTree?, var fuzzy: Boolean, var value: Long) { constructor(bits: Int = 36, data: Long = 0) : this(null, null, false, data) { if (bits > 0) { left = FuzzyTree(bits - 1, data) fuzzy = true ...
0
Kotlin
0
5
846ad4a978823563b2910c743056d44552a4b172
3,282
aoc2020
The Unlicense
src/Day08.kt
chasegn
573,224,944
false
{"Kotlin": 29978}
/** * Day 08 for Advent of Code 2022 * https://adventofcode.com/2022/day/8 */ class Day08 : Day { override val inputFileName: String = "Day08" // override val test1Expected: Int? = null override val test1Expected: Int = 21 // override val test2Expected: Int? = null override val test2Expected: Int ...
0
Kotlin
0
0
2b9a91f083a83aa474fad64f73758b363e8a7ad6
4,044
advent-of-code-2022
Apache License 2.0
Collections/Sequences/src/Task.kt
diskostu
554,658,487
false
{"Kotlin": 36179}
// Find the most expensive product among all the delivered products // ordered by the customer. Use `Order.isDelivered` flag. fun findMostExpensiveProductBy(customer: Customer): Product? { val ordersAsSequence = customer.orders.asSequence() return ordersAsSequence .filter { it.isDelivered } .fla...
0
Kotlin
0
0
3cad6559e1add8d202e15501165e2aca0ee82168
2,047
Kotlin_Koans
MIT License
src/main/kotlin/d24/d24.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d24 import readInput import java.lang.IllegalArgumentException data class State(val x:Int, val y:Int, val time:Int) { var prev : State? = null } fun printValley(valley : List<Array<Square>>) { for (line in valley) { for (sq in line) print(sq.char) println() } } fun pri...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
5,589
aoc2022
Creative Commons Zero v1.0 Universal
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[120]三角形最小路径和.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个三角形 triangle ,找出自顶向下的最小路径和。 // // 每一步只能移动到下一行中相邻的结点上。相邻的结点 在这里指的是 下标 与 上一层结点下标 相同或者等于 上一层结点下标 + 1 的两个结点。也就是说,如果 //正位于当前行的下标 i ,那么下一步可以移动到下一行的下标 i 或 i + 1 。 // // // // 示例 1: // // //输入:triangle = [[2],[3,4],[6,5,7],[4,1,8,3]] //输出:11 //解释:如下面简图所示: // 2 // 3 4 // 6 5 7 //4 1 8 3 //自顶向下的最小路径和为 11(即,2 + 3 + ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,629
MyLeetCode
Apache License 2.0
src/main/kotlin/days/Day1.kt
andilau
726,429,411
false
{"Kotlin": 37060}
package days @AdventOfCodePuzzle( name = "Trebuchet?!", url = "https://adventofcode.com/2023/day/1", date = Date(day = 1, year = 2023) ) class Day1(private val input: List<String>) : Puzzle { override fun partOne(): Int = input .map { line -> Pair(line.firstDigit, line.lastDigit) } .sum...
3
Kotlin
0
0
9a1f13a9815ab42d7fd1d9e6048085038d26da90
1,824
advent-of-code-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/org/domnikl/algorithms/select/QuickSelect.kt
domnikl
231,452,742
false
null
package org.domnikl.algorithms.select import kotlin.random.Random fun <T : Comparable<T>> Array<T>.quickSelect(select: Int): T { return this.quickSelect(0, this.size - 1, select) } private fun <T : Comparable<T>> Array<T>.quickSelect(low: Int, high: Int, select: Int): T { require(low <= high) { "low:...
5
Kotlin
3
13
3b2c191876e58415d8221e511e6151a8747d15dc
1,377
algorithms-and-data-structures
Apache License 2.0
src/Day04/Day04.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day04 import checkAndPrint import measureAndPrintTimeMillis import readInput fun main() { fun List<String>.prepareInput(): List<Pair<IntRange, IntRange>> = map { line -> line.split(",") .map { part -> part.split("-") .let { (first, second) -> first.t...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
1,281
AdventOfCode2022
Apache License 2.0
2022/src/Day04.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src fun main() { fun part1(input: List<String>): Int { return input.flatMap { it.split(",") } .asSequence() .map { it.split("-") } .map { it[0].toInt()..it[1].toInt() } .chunked(2) .map { (it[0] intersect it[1]).containsAll(it[0].toList(...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
901
AoC
Apache License 2.0
src/main/kotlin/g1501_1600/s1591_strange_printer_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1591_strange_printer_ii // #Hard #Array #Matrix #Graph #Topological_Sort // #2023_06_14_Time_321_ms_(100.00%)_Space_38.7_MB_(100.00%) class Solution { fun isPrintable(targetGrid: Array<IntArray>): Boolean { val colorBound = Array(61) { IntArray(4) } val colors: MutableSet<Int> ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,979
LeetCode-in-Kotlin
MIT License
kotlin/graphs/matchings/MaxGeneralMatchingV3.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.matchings import java.util.stream.IntStream // https://en.wikipedia.org/wiki/Blossom_algorithm in O(V^3) object MaxGeneralMatchingV3 { fun maxMatching(graph: Array<List<Integer>>): Int { val n = graph.size val match = IntArray(n) Arrays.fill(match, -1) val p = IntArr...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,418
codelibrary
The Unlicense
advent-of-code2015/src/main/kotlin/day11/Advent11.kt
REDNBLACK
128,669,137
false
null
package day11 import split /** --- Day 11: Corporate Policy --- Santa's previous password expired, and he needs help choosing a new one. To help him remember his new password after the old one expires, Santa has devised a method of coming up with a password based on the previous one. Corporate policy dictates that ...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
3,082
courses
MIT License
src/main/kotlin/aoc2022/Day17.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import Point import readInput import kotlin.math.max private enum class RockShape(val points: Collection<Point>) { Minus(setOf(Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0))), Plus(setOf(Point(1, 0), Point(0, 1), Point(1, 1), Point(2, 1), Point(1, 2))), L(setOf(Point(0, 0), Point(1, 0...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,329
adventOfCode
Apache License 2.0
day05/src/main/kotlin/Main.kt
ickybodclay
159,694,344
false
null
import java.io.File fun main() { val input = File(ClassLoader.getSystemResource("input.txt").file) // Write solution here! input.readLines().map { line -> val polymerStr = getReactingPolymer(line) println("polymer string = $polymerStr") println("[part1] polymer count = ${polymerStr...
0
Kotlin
0
0
9a055c79d261235cec3093f19f6828997b7a5fba
1,477
aoc2018
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2021/day18/Day18.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day18 import com.github.michaelbull.advent2021.Puzzle object Day18 : Puzzle<Sequence<SnailfishNumber>, Int>(day = 18) { override fun parse(input: Sequence<String>): Sequence<SnailfishNumber> { return input.map(String::toSnailfishNumber) } override fun so...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
1,167
advent-2021
ISC License
src/Day18.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private data class Cube( val x: Int, val y: Int, val z: Int ) private fun droplet(input: List<String>): Set<Cube> { return input.map { line -> line.split(",") .map { it.toInt() } }.map { Cube(it[0], it[1], it[2]) }.toSet() } private fun surfaceArea(droplet: Set<Cube...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
4,115
advent-of-code-2022
Apache License 2.0
src/main/kotlin/logic.kt
Shpota
283,824,850
false
null
package com.sashashpota import com.sashashpota.H.* import java.math.BigDecimal import java.math.MathContext import java.math.RoundingMode import java.math.RoundingMode.HALF_UP val basePredicates = listOf<Pair<(Input) -> Boolean, H>>( { i: Input -> i.a && i.b && !i.c } to M, { i: Input -> i.a && i.b && i.c } t...
0
Kotlin
0
0
984a3b6a4f69df59bb5792a20da03cbb593af509
1,712
abcdator
Apache License 2.0
src/day7/day07.kt
mmilenkov
573,101,780
false
{"Kotlin": 9427}
package day7 import readLines fun main() { val pattern = Regex("""[$] cd (.*)|(\d+).*""") fun directorySizes(data: List<String>) = buildMap { put("", 0) var currentDirectory = "" for (line in data) { val result = pattern.matchEntire(line) ?: continue // Nothing matches ski...
0
Kotlin
0
0
991df03f2dcffc9fa4596f6dbbc4953c95fcd17c
1,769
AdventOfCode2022
Apache License 2.0
src/main/kotlin/days/Day4.kt
nuudles
316,314,995
false
null
package days class Day4 : Day(4) { private fun getPassports(): List<Map<String, String>> = inputString .split("\n\n") .map { passport -> passport .split(" ", "\n") .fold(mutableMapOf()) { map, components -> ...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
2,400
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/Day25.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import kotlin.math.log import kotlin.math.pow fun main() { val mapSNAFU = mapOf<Char, Int>('2' to 2, '1' to 1, '0' to 0, '-' to -1, '=' to -2) val SNAFUback = "=-012" fun SNAFU2Dec(input: String): Long{ var res: Long = 0 for ((place, elem) in input.reversed().withIndex()){ res...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
1,328
aoc22
Apache License 2.0
src/Day02.kt
k3vonk
573,555,443
false
{"Kotlin": 17347}
fun main() { val gameResponseScore = mapOf( "R" to 1, "P" to 2, "S" to 3 ) val gameResult = mapOf( "R" to "R" to 3, "R" to "P" to 6, "R" to "S" to 0, "P" to "R" to 0, "P" to "P" to 3, "P" to "S" to 6, "S" to "R" to 6, "...
0
Kotlin
0
1
68a42c5b8d67442524b40c0ce2e132898683da61
1,766
AOC-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/HappyString.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,239
kotlab
Apache License 2.0
src/main/kotlin/com/github/mpe85/grampa/rule/TrieRule.kt
mpe85
138,511,038
false
{"Kotlin": 269689, "Java": 1073}
package com.github.mpe85.grampa.rule import com.github.mpe85.grampa.context.ParserContext import com.github.mpe85.grampa.util.checkEquality import com.github.mpe85.grampa.util.stringify import com.ibm.icu.lang.UCharacter import com.ibm.icu.lang.UCharacter.charCount import com.ibm.icu.lang.UCharacter.toString import co...
0
Kotlin
1
11
b3638090a700d2f6213b0f4e10d525c0e4444d94
3,126
grampa
MIT License
src/Day01.kt
melo0187
576,962,981
false
{"Kotlin": 15984}
fun main() { fun <T> List<String>.chunkedByBlank(transform: ((String) -> T)) = fold(mutableListOf(mutableListOf<T>())) { acc, line -> when { line.isNotBlank() -> acc.last().add(transform(line)) else -> acc.add(mutableListOf()) } acc ...
0
Kotlin
0
0
97d47b84e5a2f97304a078c3ab76bea6672691c5
1,011
kotlin-aoc-2022
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/internal/Shingle.kt
aallam
597,692,521
false
null
package com.aallam.similarity.internal /** * Similarities that rely on set operations (like cosine similarity or jaccard index). */ internal interface Shingle { /** * Compute and return the profile of string as defined by [Ukkonen](https://www.cs.helsinki.fi/u/ukkonen/TCS92.pdf). * * The profile ...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
1,848
string-similarity-kotlin
MIT License
src/Lesson4CountingElements/MissingInteger.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Arrays /** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { var smallest = 1 Arrays.sort(A) for (i in A.indices) { if (A[i] > 0 && A[i] == smallest) { smallest++ } else if (A[i] > smallest) { return smallest } } ...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
891
Codility-Kotlin
Apache License 2.0
src/main/kotlin/days/Day14.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day14 : Day(14) { private val margin = 1000 private val mapSize = 3 * margin private val sandPoint = Point(0, 500).withMargin(margin) override fun partOne(): Any { val map = Array(mapSize) { CharArray(mapSize) { '.' } } .also { it[sandPoint.row][sandPoint.col] = ...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
3,903
aoc-2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/day13/Day13.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day13 import java.io.File fun main() { val data = parse("src/main/kotlin/day13/Day13.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 13 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
3,265
advent-of-code-2022
MIT License
src/Day08.kt
Kaaveh
572,838,356
false
{"Kotlin": 13188}
private fun parse(input: List<String>, size: Int): MutableList<MutableList<Int>> { val array = MutableList(size) { MutableList(size) { 0 } } input.forEachIndexed { indexX: Int, row: String -> row.forEachIndexed { indexY, element -> array[indexX][indexY] = element.digitToInt() } ...
0
Kotlin
0
1
9022f1a275e9c058655898b64c196f7a0a494b48
3,459
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/sorting/RadixSort.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.sorting import kotlin.math.pow fun main() { val arr = mutableListOf( 634, 472, 977, 756, 770, 966, 993, 191, 52, 49, 475, 564, 491, 722, 284, 45, 614, 273, 332, 744, 629, 304, 822, 548, 864, 45, 971, 352, 3, 687 ) radixSort(arr) ...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,259
algs4-leprosorium
MIT License
src/Day01/Day01.kt
rooksoto
573,602,435
false
{"Kotlin": 16098}
package Day01 import profile import readInputActual import readInputTest private const val DAY = "Day01" private const val NEWLINE = "\n" fun main() { fun part1(input: List<String>): Int = toCalorieValues(input) .max() fun part2(input: List<String>): Int = toCalorieValues(input)...
0
Kotlin
0
1
52093dbf0dc2f5f62f44a57aa3064d9b0b458583
1,105
AoC-2022
Apache License 2.0
year2020/day19/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day19/part1/Year2020Day19Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 19: Monster Messages --- You land in an airport surrounded by dense forest. As you walk to your high-speed train, the Elves at the Mythical Information Bureau contact you again. They think their satellite has collected an image of a sea monster! Unfortunately, the connection to the satellite is having probl...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
4,176
AdventOfCode
MIT License
src/day02/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day02 import java.io.File const val workingDir = "src/day02" fun main() { val sample = File("$workingDir/sample.txt") val input1 = File("$workingDir/input_1.txt") println("Step 1a: ${runStep1(sample)}") println("Step 1b: ${runStep1(input1)}") println("Step 2a: ${runStep2(sample)}") pr...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
1,948
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Tetris.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
import kotlin.streams.toList fun main() = Tetris.solve() private object Tetris { private const val width = 7 private val winds = mutableListOf<Int>() private var fallingRock: FallingRock? = null private val cells = mutableListOf( // Floor MutableList(width) { i -> Cell.StableRock } ...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
5,463
aoc2022
MIT License
src/Day14_p2.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
fun main() { var maxYCntr = 0 /** * Model of the falling sand part 2 * 1) If it can fall straight dawn it falls down until it encounters sand or rock, if no cell or rock it stops at the bottom (maxY) * 2) If it can fall left dawn it falls down left until it encounters sand or rock, if no cell or ...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
3,601
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
cypressious
572,916,585
false
{"Kotlin": 40281}
fun main() { fun part1(input: List<String>): Int { var depth = 0 var position = 0 for (line in input) { val split = line.split(" ") val command = split[0] val value = split[1].toInt() when (command) { "forward" -> position += ...
0
Kotlin
0
0
169fb9307a34b56c39578e3ee2cca038802bc046
1,301
AdventOfCode2021
Apache License 2.0
Codeforces/1519/B.kt
thedevelopersanjeev
112,687,950
false
null
private fun readLine() = kotlin.io.readLine()!! private fun readInt() = readLine().toInt() private fun readInts() = readLine().split(" ").map { it.toInt() } lateinit var dp: Array<IntArray> fun solve(i: Int, j: Int, n: Int, m: Int, curr: Int): Boolean { if (i <= 0 || j <= 0 || i > n || j > m) return false if ...
0
C++
58
146
610520cc396fb13a03c606b5fb6739cfd68cc444
873
Competitive-Programming
MIT License
src/Day04.kt
nZk-Frankie
572,894,533
false
{"Kotlin": 13625}
val FILEDAY04 = readInput("Day04") fun main(){ Part02() } private fun Part01() { var overlapScore = 0 for(i in FILEDAY04) { var SPLITTED = i.split(",") if (checkWithin(SPLITTED.get(0),SPLITTED.get(1))) { overlapScore++ } } println("Total Overlap: "...
0
Kotlin
0
0
b8aac8aa1d7c236651c36da687939c716626f15b
2,502
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/aoc2022/Day14.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.IntNode import utils.Coordinates import utils.boundingBox import utils.toCoordinates class Cave(initialState: Map<Coordinates, Char>) {...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
2,892
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/Day13.kt
jcornaz
573,137,552
false
{"Kotlin": 76776}
import java.lang.StringBuilder object Day13 { fun part1(input: String): Int = input.split("\n\n").withIndex() .filter { (_, both) -> isInCorrectOrder(both.lines().first(), both.lines().last())!! } .sumOf { it.index + 1 } @Suppress("UNUSED_PARAMETER"...
1
Kotlin
0
0
979c00c4a51567b341d6936761bd43c39d314510
2,194
aoc-kotlin-2022
The Unlicense
src/main/kotlin/day22/Day22.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day22 import execute import readAllText import wtf typealias Point = Pair<Int, Int> // (row, column) 1-based indexes data class Board(val rows: Map<Int, IntRange>, val cols: Map<Int, IntRange>, val walls: Set<Point>) { val faceSize by lazy { if (rows.keys.any { it > 50 }) 50 else 4 } } sealed interface ...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
8,441
advent-of-code-2022
MIT License
src/main/kotlin/com/adrielm/aoc2020/solutions/day09/Day09.kt
Adriel-M
318,860,784
false
null
package com.adrielm.aoc2020.solutions.day09 import com.adrielm.aoc2020.common.Algorithms import com.adrielm.aoc2020.common.Solution import org.koin.dsl.module class Day09 : Solution<Day09.Input, Long>(9) { override fun solveProblem1(input: Input): Long { return getInvalidNumber(input) } override ...
0
Kotlin
0
0
8984378d0297f7bc75c5e41a80424d091ac08ad0
1,614
advent-of-code-2020
MIT License
puzzles/src/main/kotlin/com/kotlinground/puzzles/search/binarysearch/platesbetweencandles/platesBetweenCandles.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.puzzles.search.binarysearch.platesbetweencandles fun platesBetweenCandles(platesAndCandles: String, queries: Array<IntArray>): IntArray { // This will hold the indices of candles in the plates and candles // This allows us to do basic arithmetic on the indices to find the number of pla...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
3,223
KotlinGround
MIT License
src/Day01.kt
Svikleren
572,637,234
false
{"Kotlin": 11180}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var caloriesSum = 0 for (oneInput: String in input) { when (oneInput) { "" -> { maxCalories = if (caloriesSum > maxCalories) caloriesSum else maxCalories ...
0
Kotlin
0
0
e63be3f83b96a73543bf9bc00c22dc71b6aa0f57
1,033
advent-of-code-2022
Apache License 2.0
src/main/kotlin/leetcode/ArrangingCoins.kt
ykrytsyn
424,099,758
false
{"Kotlin": 8270}
package leetcode /** * # 441. Arranging Coins * [https://leetcode.com/problems/arranging-coins/](https://leetcode.com/problems/arranging-coins/) * * ### You have n coins and you want to build a staircase with these coins. * ### The staircase consists of k rows where the ith row has exactly i coins. * ### The las...
0
Kotlin
0
0
0acf2a677f8b4a1777b12688cf48bf420353e040
1,629
leetcode-in-kotlin
Apache License 2.0
src/d04/Day04.kt
Ezike
573,181,935
false
{"Kotlin": 7967}
package d04 import readInput fun main() { fun run(m1: String, m2: String, s1: String, s2: String) = s1.toInt() >= m1.toInt() && s2.toInt() <= m2.toInt() || m1.toInt() >= s1.toInt() && m2.toInt() <= s2.toInt() fun run2(m1: String, m2: String, s1: String, s2: String) = (m1.toInt...
0
Kotlin
0
0
07ed8acc2dcee09cc4f5868299a8eb5efefeef6d
1,643
advent-of-code
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2022/Day9.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.XY import com.s13g.aoc.addTo import com.s13g.aoc.resultFrom import kotlin.math.abs import kotlin.math.sign /** * --- Day 9: Rope Bridge --- * https://adventofcode.com/2022/day/9 */ class Day9 : Solver { overrid...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,320
euler
Apache License 2.0
src/main/kotlin/leetcode/TwoSum.kt
ykrytsyn
424,099,758
false
{"Kotlin": 8270}
package leetcode /** * # 1. Two Sum * [https://leetcode.com/problems/two-sum/](https://leetcode.com/problems/two-sum/) * * ### Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. * ### You may assume that each input would have exactly one solu...
0
Kotlin
0
0
0acf2a677f8b4a1777b12688cf48bf420353e040
1,889
leetcode-in-kotlin
Apache License 2.0
src/main/kotlin/day19.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
var distinctCombinations = 0L fun day19 (lines: List<String>) { val workflows = parseWorkFlows(lines.filter { it.isNotEmpty() }) val parts = parsePartRatings(lines.filter { it.isNotEmpty() }) val acceptedPartsRating = parts.filter { isPartAccepted(workflows, it) }. map { it.xRating + it.mRating + it.a...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
6,915
advent_of_code_2023
MIT License
src/main/kotlin/com/pandarin/aoc2022/Day3.kt
PandarinDev
578,619,167
false
{"Kotlin": 6586}
package com.pandarin.aoc2022 import java.util.stream.Collectors fun main() { val inputLines = Common.readInput("/day3.txt").split("\n").filter { it.isNotEmpty() } val itemPriorities = generateItemPriorities() // First part var totalPriority = 0 for (line in inputLines) { val halfLength = ...
0
Kotlin
0
0
42c35d23129cc9f827db5b29dd10342939da7c99
1,569
aoc2022
MIT License
BackEnd/src/main/kotlin/com/sorbonne/daar/algorithms/kmp/KMPAlgorithm.kt
MalickLSy
622,912,085
false
null
package com.sorbonne.daar.algorithms.kmp import java.util.* /** * Author <NAME> */ class KMPAlgorithm { fun search(pattern: String, text: String) : Int { val textLen = text.length val factorLen : Int = pattern.length val carryOver = computeCarryOverArray(pattern) var i = 0 ...
0
Kotlin
0
0
b22e9e4f1410a63cf689ed66fa88e0a84a20f2a0
1,873
search-engine-book
MIT License
src/Utils.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
import java.io.File /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() fun String.allInts() = allIntsInString(this) fun allIntsInString(line: String): List<Int> { return """-?\d+""".toRegex().findAll(line) .map { it.value.toInt() }...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
1,805
aoc-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day25.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 25 - Four-Dimensional Adventure * * Problem Description: http://adventofcode.com/2018/day/25 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day25/ */ package com.ginsberg.advent2018 import java.lang.Math.abs import ...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
2,233
advent-2018-kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountBalls.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,143
kotlab
Apache License 2.0
src/Day06.kt
mzlnk
573,124,510
false
{"Kotlin": 14876}
fun main() { fun part1(input: List<String>): Int { val line = input.first() val checker = HashSet<Char>() for (i in 0 until (line.length - 3)) { for (j in 0..3) { checker.add(line[i + j]) } if (checker.size == 4) { return ...
0
Kotlin
0
0
3a8ec82e9a8b4640e33fdd801b1ef87a06fa5cd5
1,428
advent-of-code-2022
Apache License 2.0
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Quick_Sort/Quick_Sort.kt
rajatenzyme
325,100,742
false
{"C++": 709855, "Java": 559443, "Python": 397216, "C": 381274, "Jupyter Notebook": 127469, "Go": 123745, "Dart": 118962, "JavaScript": 109884, "C#": 109817, "Ruby": 86344, "PHP": 63402, "Kotlin": 52237, "TypeScript": 21623, "Rust": 20123, "CoffeeScript": 13585, "Julia": 2385, "Shell": 506, "Erlang": 385, "Scala": 310, ...
/* QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.It's Best case complexity is n*log(n) & Worst case complexity is n^2. */ //partition array fun quick_sort(A: Array<Int>, p: Int, r: Int) { if (p < r) { var q: Int = partition...
0
C++
0
0
65a0570153b7e3393d78352e78fb2111223049f3
1,259
Coding-Journey
MIT License
src/questions/AssignCookies.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import kotlin.test.assertEquals /** * Assume you are an awesome parent and want to give your children some cookies. * But, you should give each child at most one cookie. * Each child i has a greed factor g[i], which is the minimum size of a cookie that the...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,073
algorithms
MIT License
app/src/main/kotlin/day07/Day07.kt
meli-w
433,710,859
false
{"Kotlin": 52501}
package day07 import common.InputRepo import common.readSessionCookie import common.solve import kotlin.math.abs fun main(args: Array<String>) { val day = 7 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay07Part1, ::solveDay07Part2) } fun solveDay07Part1(input...
0
Kotlin
0
1
f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1
1,811
AoC-2021
Apache License 2.0
AdventOfCode2018/src/main/kotlin/net/twisterrob/challenges/adventOfCode2018/day7/Solution.kt
TWiStErRob
136,539,340
false
{"Kotlin": 104880, "Java": 11319}
@file:Suppress("SpreadOperator") package net.twisterrob.challenges.adventOfCode2018.day7 import java.io.File fun main(vararg args: String) { val file = args.first() val fileContents = File(file).readText() solve(fileContents) } fun solve(input: String): String { val linePattern = Regex("""^Step ([A-...
1
Kotlin
1
2
5cf062322ddecd72d29f7682c3a104d687bd5cfc
2,370
TWiStErRob
The Unlicense