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
Kotlin/src/main/kotlin/org/algorithm/problems/0022_partition_labels.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
package org.algorithm.problems class `0022_partition_labels` { fun partitionLabels(S: String): List<Int> { val lettersIntervals = MutableList<Pair<Int, Int>>(26) { _ -> Pair(Int.MAX_VALUE, Int.MIN_VALUE) } val result = mutableListOf<Int>() for (i in 0 until S.length) { val inde...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
1,728
algorithms
MIT License
src/main/kotlin/com/staricka/adventofcode2022/Day14.kt
mathstar
569,952,400
false
{"Kotlin": 77567}
package com.staricka.adventofcode2022 import kotlin.math.max import kotlin.math.min class Day14 : Day { override val id = 14 enum class Tile { AIR, ROCK, SAND } class Grid { val map = HashMap<Int, MutableMap<Int, Tile>>() private var maxRockY = Int.MIN_VALUE fun get(x: Int, y: Int): Tile = ...
0
Kotlin
0
0
2fd07f21348a708109d06ea97ae8104eb8ee6a02
2,823
adventOfCode2022
MIT License
src/main/kotlin/Puzzle12.kt
namyxc
317,466,668
false
null
import kotlin.math.absoluteValue object Puzzle12 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle12::class.java.getResource("puzzle12.txt").readText() val calculatedDistance = calculateDistance(input) println(calculatedDistance) val calculateDistanceWithWaypoint ...
0
Kotlin
0
0
60fa6991ac204de6a756456406e1f87c3784f0af
4,583
adventOfCode2020
MIT License
src/main/kotlin/net/rafaeltoledo/kotlin/advent/Day01.kt
rafaeltoledo
726,542,427
false
{"Kotlin": 11895}
package net.rafaeltoledo.kotlin.advent private val numbers = mapOf( "one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7, "eight" to 8, "nine" to 9, ) class Day01 { fun invoke(rawInput: String): Int { val lines = rawInput.split("\n").filter { it.isNotEmpty(...
0
Kotlin
0
0
7bee985147466cd796e0183d7c719ca6d01b5908
1,370
aoc2023
Apache License 2.0
src/main/kotlin/g1801_1900/s1824_minimum_sideway_jumps/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1824_minimum_sideway_jumps // #Medium #Array #Dynamic_Programming #Greedy // #2023_06_20_Time_726_ms_(100.00%)_Space_98.6_MB_(100.00%) class Solution { fun minSideJumps(obstacles: IntArray): Int { var sideJumps = 0 var currLane = 2 var i = 0 while (i < obstacles...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,495
LeetCode-in-Kotlin
MIT License
advent-of-code/src/main/kotlin/DayFive.kt
pauliancu97
518,083,754
false
{"Kotlin": 36950}
class DayFive { companion object { private val VOWELS = setOf('a', 'e', 'i', 'o', 'u') private val FORBIDDEN_STRINGS = setOf("ab", "cd", "pq", "xy") } private fun isStringNice(string: String): Boolean { val hasSufficientVowels = string.count { it in VOWELS } >= 3 val hasRepe...
0
Kotlin
0
0
3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6
1,812
advent-of-code-2015
MIT License
src/main/java/com/kotlinspirit/ext/RangeExtensions.kt
tiksem
494,746,133
false
{"Kotlin": 411301, "HTML": 2017}
package com.kotlinspirit.ext import java.util.StringJoiner internal operator fun CharRange.minus(range: CharRange): List<CharRange> { if (range.first <= this.first && range.last >= this.last) { return emptyList() } return if (range.first > this.first && range.last < this.last) { listOf( ...
0
Kotlin
0
1
8c2001f632f4a8a13b97a32f38ec327695b8bc75
2,633
KotlinSpirit
MIT License
src/main/kotlin/com/github/aoc/AOCD7P2.kt
frikit
317,914,710
false
null
package com.github.aoc import com.github.aoc.utils.* fun main() { val input = InputParser.parseInput(InputDay7Problem2) .map { it.replace(".", "") } .map { it.replace("bags", "") } .map { it.replace("bag", "") } val bagType = "shiny gold" val res = findOtherColors(input, 1, bagTyp...
0
Kotlin
0
0
2fca82225a19144bbbca39247ba57c42a30ef459
1,075
aoc2020
Apache License 2.0
src/Day10.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
private fun List<String>.toSignals(): Sequence<Int> { var value = 1 return sequence { for (line in this@toSignals) { yield(value) if (line != "noop") { yield(value) value += line.substring(5).toInt() } } } } private fun par...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
1,422
AOC2022
Apache License 2.0
src/Day20.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File // Advent of Code 2022, Day 20: Grove Positioning System // Keep the original index in order to make each value unique // In input, there are duplicate values. data class Day20(val num: Long, val origIdx: Int) { override fun toString(): String = num.toString() } fun main() { fun readInput...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
1,507
AdventOfCode2022
Apache License 2.0
src/test/kotlin/chapter5/solutions/ex13/listing.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter5.solutions.ex13 import chapter3.List import chapter3.Nil import chapter4.None import chapter4.Option import chapter4.Some import chapter5.Cons import chapter5.Stream import chapter5.toList import io.kotest.matchers.shouldBe import io.kotest.core.spec.style.WordSpec //tag::map[] fun <A, B> Stream<A>.ma...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
5,763
fp-kotlin
MIT License
src/main/kotlin/kr/co/programmers/P67257.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers import java.util.* // https://github.com/antop-dev/algorithm/issues/415 class P67257 { // 문자열이 숫자인지 판단하는 정규표현식 val number = Regex("^[0-9]*$") // 연산자 우선 순위 경우의 수 private val ops = listOf( arrayOf('*', '+', '-'), arrayOf('*', '-', '+'), arrayOf('+', '*',...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
2,171
algorithm
MIT License
src/main/kotlin/com/lucaszeta/adventofcode2020/day24/day24.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day24 import com.lucaszeta.adventofcode2020.ext.getResourceAsText const val BLACK = '#' const val WHITE = '.' fun main() { val directionsList = getResourceAsText("/day24/directions-list.txt") .split("\n") .filter { it.isNotEmpty() } .map(::parseToDir...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
1,840
advent-of-code-2020
MIT License
kotlin/src/com/s13g/aoc/aoc2021/Day24.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2021 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 24: Arithmetic Logic Unit --- * https://adventofcode.com/2021/day/24 */ class Day24 : Solver { override fun solve(lines: List<String>): Result { val partA = OptimizedALU(9 downTo 1).solve(-1, 0, 0, 0, 0).second ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,628
euler
Apache License 2.0
src/day11/Day11.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day11 import logEnabled import readInput private const val DAY_NUMBER = 11 typealias WorryLevel = Long typealias MonkeyId = Int class Monkey( val id: MonkeyId, startingItems: List<WorryLevel>, private val operation: Operation, val test: TestOperation, private val successTarget: MonkeyId,...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
5,189
advent-of-code-2022
Apache License 2.0
core-kotlin-modules/core-kotlin-strings-4/src/main/kotlin/com/baeldung/countvowelconsonant/CountVowelConsonant.kt
Baeldung
260,481,121
false
{"Kotlin": 1476024, "Java": 43013, "HTML": 4883}
package com.baeldung.countvowelconsonant val VOWELS = "aAeEiIoOuU" fun countUsingLoopAndIfCondition(sentence: String): Pair<Int, Int> { var vowelCount = 0 var consonantCount = 0 for (char in sentence) { if (char.isLetter()) { if (char in VOWELS) { vowelCount++ ...
10
Kotlin
273
410
2b718f002ce5ea1cb09217937dc630ff31757693
2,201
kotlin-tutorials
MIT License
src/Day08.kt
frungl
573,598,286
false
{"Kotlin": 86423}
@OptIn(ExperimentalStdlibApi::class) fun main() { fun List<String>.getRow(i: Int): String = this[i] fun List<String>.getCol(j: Int): String = joinToString("") { it[j].toString() } fun isCovered(s: String, pos: Int): Boolean { val list = s.toCharArray().map { it.digitToInt() } ...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
1,649
aoc2022
Apache License 2.0
src/main/kotlin/day15.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.Input fun main() { val input = Input.day(15) println(day15A(input)) println(day15B(input)) } fun day15A(input: Input): Int { return input.text.split(',').sumOf(::hash) } fun day15B(input: Input): Int { val hashMap = MyHashMap() input.text.split(',').forEach { if(it.conta...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,507
AdventOfCode2023
MIT License
listFunctions.kt
InertExpert2911
348,750,125
false
null
// GATHERING A LIST OF VALUES fun getListOfNumbers() : List<Int> { var myList = mutableListOf <Int> () for(i in 1..7){ println("Enter a number:") var Number = Integer.valueOf(readLine()) myList.add(Number) } return myList } // FINDING THE MAX VALUE fun findMax(maxList : List<Int>) : Int { var ...
0
Kotlin
0
0
9ec619b2dc2eae4f2b10aed70fb0f9fd33db0951
3,383
Kotlin-Projects
MIT License
src/Day06.kt
mr3y-the-programmer
572,001,640
false
{"Kotlin": 8306}
fun main() { fun part1(input: List<String>): Int { return firstDistinctCharsWindow(input, 4) } fun part2(input: List<String>): Int { return firstDistinctCharsWindow(input, 14) } check(part1(readInput("Day06_sample")) == 10) println(part1(readInput("Day06_input"))) check(pa...
0
Kotlin
0
0
96d1567f38e324aca0cb692be3dae720728a383d
780
advent-of-code-2022
Apache License 2.0
advent-of-code2016/src/main/kotlin/day12/Advent12.kt
REDNBLACK
128,669,137
false
null
package day12 import day12.Operation.Type.* import parseInput import splitToLines /** --- Day 12: Leonardo's Monorail --- You finally reach the top floor of this building: a garden with a slanted glass ceiling. Looks like there are no more stars to be had. While sitting on a nearby bench amidst some tiger lilies, y...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
4,846
courses
MIT License
src/day11/Code.kt
fcolasuonno
225,219,560
false
null
package day11 import IntCode import IntCodeComputer import isDebug import java.io.File fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) ...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
2,706
AOC2019
MIT License
src/Day10.kt
D000L
575,350,411
false
{"Kotlin": 23716}
fun main() { fun getSignals(input: List<String>): List<Int> { val signals = mutableListOf(0) var signal = 1 input.forEach { when { it.startsWith("noop") -> { signals.add(signal) } it.startsWith("addx") -> { ...
0
Kotlin
0
0
b733a4f16ebc7b71af5b08b947ae46afb62df05e
1,274
adventOfCode
Apache License 2.0
ceria/03/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input: List<String>) :Long { val threshold = input.size / 2 var zerosMap = mutableMapOf<Int...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
1,804
advent-of-code-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/BraceExpansion2.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,029
kotlab
Apache License 2.0
src/main/kotlin/CalculateAperture.kt
guilhermealbm
568,980,166
false
{"Kotlin": 4088}
import java.lang.NumberFormatException import kotlin.math.abs val distances = listOf(1.2, 1.8, 2.5, 3.5, 5.0, 7.0) val apertures = listOf(1.2, 1.4, 2, 2.8, 4, 5.6, 8, 11, 16, 22, 32, 45) fun calculateAperture(iso_: String?, distance_: String?) : String { val iso = convertIso(iso_) val distance = convertDistan...
0
Kotlin
0
0
74f049d5ddb05d9ee1eb5b2e4399187f08c2a468
1,332
ManualFlashSettingsCalculator
MIT License
src/primitives/WeightDiagram.kt
sxhya
31,016,248
false
null
class WeightDiagram(val brs: BasedRootSystem, i: Int) { val myWeights: Set<Vector> = brs.weightOrbit(Vector(brs.myFundamentalWeights.myCoo[i])) val myEdges: MutableMap<Pair<Vector, Vector>, Int> = HashMap() val myWeightsNumbers: MutableMap<Vector, Int> = HashMap() val myWeightsOrdered: MutableList<Vecto...
0
Kotlin
0
0
ac5aebc8af88ed1ff7c9056e54cd7e0bb568f47a
7,057
roots
Apache License 2.0
src/Day02.kt
Sasikuttan2163
647,296,570
false
null
fun main() { val input = readInput("Day02") val part1 = input.fold(0) { sum, l -> sum + when ((l[2] - 'X') - (l[0] - 'A')) { 0 -> 3 1, -2 -> 6 else -> 0 } + (l[2] - 'W') } val part2 = input.fold(0) { sum, l -> val res = l[2] - 'X' sum +...
0
Kotlin
0
0
fb2ade48707c2df7b0ace27250d5ee240b01a4d6
564
AoC-2022-Solutions-In-Kotlin
MIT License
kotlin/src/katas/kotlin/leetcode/wildcard_matching/v3/WildcardMatching3.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.wildcard_matching.v3 import datsok.* import org.junit.* class WildcardMatching3 { @Test fun `some examples`() { match("", "") shouldEqual true match("", "a") shouldEqual false match("a", "") shouldEqual false match("a", "a") shouldEqual true m...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,878
katas
The Unlicense
src/main/java/challenges/educative_grokking_coding_interview/two_heaps/_3/SlidingWindow.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.two_heaps._3 import challenges.util.PrintHyphens import java.util.* /** Given an integer array, nums, and an integer, k, there is a sliding window of size k, which is moving from the very left to the very right of the array. We can only see the k numbers in the w...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
4,183
CodingChallenges
Apache License 2.0
src/main/kotlin/_0046_Permutations.kt
ryandyoon
664,493,186
false
null
// https://leetcode.com/problems/permutations fun permute(nums: IntArray): List<List<Int>> { return mutableListOf<List<Int>>().also { buildPermutations( nums = nums, usedNums = BooleanArray(nums.size), permutation = mutableListOf(), permutations = it )...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
929
leetcode-kotlin
MIT License
src/main/kotlin/util/Point2d.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package util import kotlin.math.abs data class Point2d(val x: Int, val y: Int) { fun distanceTo(other: Point2d): Int { return abs(other.x - x) + abs(other.y - y) } operator fun plus(other: Point2d): Point2d { return Point2d(x + other.x, y + other.y) } operator fun minus(other: Po...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,530
Advent-Of-Code
Creative Commons Zero v1.0 Universal
codechef/snackdown2021/preelim/slippers.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codechef.snackdown2021.preelim private const val MAX_S = 200_000 @Suppress("UNUSED_PARAMETER") // Kotlin 1.2 fun main(args: Array<String>) { readLn() val a = readInts() val fenwickTree = FenwickTree(MAX_S + 1) var ans = 1.toModular() for (x in a) { val added = 1 + fenwickTree.sum(x).toModular() fenwi...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,205
competitions
The Unlicense
src/day06/day06.kt
Klaus-Anderson
572,740,347
false
{"Kotlin": 13405}
package day06 import readInput fun main() { fun part1(input: List<String>): Int { input.first().let { inputString -> inputString.forEachIndexed { index, char -> val list = List(4) { inputString[index + it] } if (list.all { ...
0
Kotlin
0
0
faddc2738011782841ec20475171909e9d4cee84
1,295
harry-advent-of-code-kotlin-template
Apache License 2.0
src/pl/shockah/aoc/y2018/Day12.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2018 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import pl.shockah.aoc.parse2 import java.util.* import java.util.regex.Pattern class Day12: AdventTask<Day12.Input, Long, Long>(2018, 12) { private val replacementInputPattern: Patt...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
3,812
Advent-of-Code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindOriginalArray.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,662
kotlab
Apache License 2.0
2022/main/day_18/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_18_2022 import java.io.File fun Triple<Int, Int, Int>.adjacent(): List<Triple<Int, Int, Int>> { val (a,b,c) = this val res = mutableListOf<Triple<Int, Int, Int>>() res.add(Triple(a+1,b,c)) res.add(Triple(a-1,b,c)) res.add(Triple(a,b+1,c)) res.add(Triple(a,b-1,c)) res.add(Triple...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
2,255
AdventofCode
MIT License
src/leetcodeProblem/leetcode/editor/en/MinimumRemoveToMakeValidParentheses.kt
faniabdullah
382,893,751
false
null
//Given a string s of '(' , ')' and lowercase English characters. // // Your task is to remove the minimum number of parentheses ( '(' or ')', in //any positions ) so that the resulting parentheses string is valid and return any //valid string. // // Formally, a parentheses string is valid if and only if: // // //...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,238
dsa-kotlin
MIT License
src/Dec20.kt
karlstjarne
572,529,215
false
{"Kotlin": 45095}
import java.util.Collections.swap import kotlin.math.abs object Dec20 { fun a(): Long { val input = readInput("dec20") val nodes = mutableListOf<Node>() for (i in input.indices) { nodes.add(Node(i, input[i].toLong())) } val output = mixList(nodes, 1) re...
0
Kotlin
0
0
9220750bf71f39f693d129d170679f3be4328576
1,901
AoC_2022
Apache License 2.0
src/Day04.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
fun main() { fun part1(input: List<String>): Int { fun IntRange.fullyContains(other: IntRange): Boolean = this.contains(other.first) && this.contains(other.last) return input.count { val ranges = it.split(",").map { s -> val ss = s.split("-") ...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
884
AOC-2022
Apache License 2.0
2021/src/test/kotlin/Day03.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 Day03 { enum class RateType { GAMMA, EPSILON, OXYGEN, CO2 } @Test fun `run part 01`() { val report = Util.getInputAsListOfString("day03-input.txt") val powerConsumption = report .let { it.getPowerRating(RateType.GAM...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,840
adventofcode
MIT License
year2015/src/main/kotlin/net/olegg/aoc/year2015/day18/Day18.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2015.day18 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_8 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.fit import net.olegg.aoc.year2015.DayOf2015 /** * See [Year 2015, Day 18](https://adventofcode.com/2015/day/18) */ object Da...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,387
adventofcode
MIT License
src/main/kotlin/aoc/year2021/Day06.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2021 import aoc.Puzzle /** * [Day 6 - Advent of Code 2021](https://adventofcode.com/2021/day/6) */ object Day06 : Puzzle<Long, Long> { override fun solvePartOne(input: String): Long = solve(input, 80) override fun solvePartTwo(input: String): Long = solve(input, 256) private fun solve(...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,160
advent-of-code
Apache License 2.0
day23/kotlin/corneil/src/main/kotlin/solution.kt
jensnerche
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271602, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "C": 3201, "Go": 2838, "Shell": 26...
package com.github.corneil.aoc2019.day23 import com.github.corneil.aoc2019.intcode.Program import com.github.corneil.aoc2019.intcode.ProgramState import com.github.corneil.aoc2019.intcode.readProgram import java.io.File data class Packet(val x: Long, val y: Long) class NetWorkController(val address: Long) { val ...
0
HTML
0
0
a84c00ddbeb7f9114291125e93871d54699da887
3,917
aoc-2019
MIT License
src/main/kotlin/g0701_0800/s0770_basic_calculator_iv/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0770_basic_calculator_iv // #Hard #String #Hash_Table #Math #Stack #Recursion // #2023_03_10_Time_222_ms_(100.00%)_Space_39.2_MB_(100.00%) import java.util.Collections class Solution { internal inner class Node { var mem: MutableMap<List<String>, Int> = HashMap() fun update(cu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
5,547
LeetCode-in-Kotlin
MIT License
src/day20/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day20 import java.io.File fun Array<Array<Boolean>>.count() = sumOf { row -> row.count { it } } fun Array<Array<Boolean>>.enhance(algo: List<Boolean>, infinity: Boolean) = (-1..size).map { y -> (-1..this[0].size).map { x -> algo[index(x, y, infinity)] }.toTypedArray() }.to...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,165
advent-of-code-2021
MIT License
src/main/kotlin/text/EditDistance.kt
komu
104,990,960
false
null
package text import utils.readResourceLines fun levenshtein(lhs: String, rhs: String): Int { var cost = Array(lhs.length) { it } var newCost = Array(lhs.length) { 0 } for (i in 1 until rhs.length) { newCost[0] = i for (j in 1 until lhs.length) { val match = if (lhs[j - 1] == ...
0
Kotlin
0
0
da1b0111a7ef7b214393ad9b135b4b83cb47de05
1,267
scratch
MIT License
code/day_14/src/jvm8Main/kotlin/task1.kt
dhakehurst
725,945,024
false
{"Kotlin": 105846}
package day_14 import kotlin.math.pow class GridAsLongs( /** * list of rows */ val lines: List<Long>, val size:Size ) { val columns = IntRange(0, size.cols - 1).map { col -> val colMask = 2L.pow(size.cols - col) lines.foldIndexed(0L) { x, a, i -> when (i and colMa...
0
Kotlin
0
0
be416bd89ac375d49649e7fce68c074f8c4e912e
2,280
advent-of-code
Apache License 2.0
kt.kt
darian-catalin-cucer
598,116,446
false
null
import java.util.* fun maxMatching(n: Int, graph: Array<MutableList<Int>>): Int { val matching = IntArray(n) { -1 } val seen = BooleanArray(n) fun dfs(i: Int): Boolean { seen[i].also { seen[i] = true } graph[i].forEach { j -> if (matching[j] == -1 || (!seen[matching[j]] && dfs(m...
0
Kotlin
0
0
db6b2b89e57acef0ad9d1f23999b92e933120376
1,289
maximum-matching
MIT License
src/main/kotlin/com/ginsberg/advent2021/Day10.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 10 - Syntax Scoring * Problem Description: http://adventofcode.com/2021/day/10 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day10/ */ package com.ginsberg.advent2021 class Day10(private val input: List<String>) { ...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,890
advent-2021-kotlin
Apache License 2.0
app/src/main/java/io/github/pshegger/gamedevexperiments/algorithms/Graph.kt
PsHegger
99,228,633
false
null
package io.github.pshegger.gamedevexperiments.algorithms /** * @author <EMAIL> */ data class Graph<T>(val nodes: List<T>, val edges: List<Edge<T>>) { fun shortestPath(start: T, end: T): List<T>? { val distances = nodes.associate { it to Float.POSITIVE_INFINITY }.toMutableMap() val previouses = no...
0
Kotlin
0
0
694d273a6d3dff49cf314cbe16e17b5f77c7738e
1,602
GameDevExperiments
MIT License
src/twentytwentytwo/day9/Day09.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day9 import readInput import kotlin.math.abs import kotlin.math.sign fun main() { val tailList = mutableListOf( Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0), Pair(0, 0)...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
5,307
advent-of-code
Apache License 2.0
src/main/kotlin/solutions/Day9RopeBridge.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import models.Coord2d import utils.Input import utils.Solution // run only this day fun main() { Day9RopeBridge() } class Day9RopeBridge : Solution() { init { begin("Day 9 - Rope Bridge") val input = Input.parseToPairList<Char, Int>( filename = "/d9_rope_motion....
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
2,355
advent-of-code-2022
MIT License
algorithms-kotlin/src/main/kotlin/io/github/brunogabriel/math/MatrixOperations.kt
brunogabriel
294,995,479
false
null
package io.github.brunogabriel.math fun matrixMultiplication( matrixA: List<List<Long>>, matrixB: List<List<Long>> ): List<List<Long>> { if (matrixA.first().size != matrixB.size) { return emptyList() } val result = Array(matrixA.size) { Array(matrixB.first().size) { 0L } } for (i in ...
0
Kotlin
0
3
050a7093c0f2cf3864157c74adb84a969dea8882
1,402
algorithms
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2023/Day06.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2023 import ch.ranil.aoc.AbstractDay import ch.ranil.aoc.product import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day06 : AbstractDay() { @Test fun part1Test() { assertEquals(288, compute1(testInput)) } @Test fun part1Puzzle() { asse...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
1,992
aoc
Apache License 2.0
src/main/kotlin/Day04.kt
SimonMarquis
724,825,757
false
{"Kotlin": 30983}
import kotlin.math.pow class Day04(private val input: List<String>) { data class Card(val win: Set<Int>, val hand: Set<Int>) private val cards = input.asSequence().map { card -> card.substringAfter(":") .split("|") .map { it.split(" ").mapNotNull(String::toIntOrNull).toSet() }...
0
Kotlin
0
1
043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e
1,054
advent-of-code-2023
MIT License
src/Day01.kt
aamielsan
572,653,361
false
{"Kotlin": 9363}
private class Elf( val calories: List<Int>, ) { val totalCalories: Int get() = calories.sum() companion object { fun fromCalories(string: String): Elf = Elf(calories = string.lines().map(String::toInt)) } } fun main() { // Get the total calories from the elf carrying th...
0
Kotlin
0
0
9a522271bedb77496e572f5166c1884253cb635b
930
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2021/Vector2.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 import kotlin.math.abs import kotlin.math.max data class Vector2 (val x: Int, val y: Int) { operator fun plus(other: Vector2) = Vector2(x + other.x, y + other.y) operator fun minus(other: Vector2) = Vector2(x - other.x, y - other.y) override fun toString() = "($x, $y)" ...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
4,169
advent-2021
Apache License 2.0
day3/day3/src/main/kotlin/Main.kt
teemu-rossi
437,894,529
false
{"Kotlin": 28815, "Rust": 4678}
fun main(args: Array<String>) { println("Hello World!") val values = generateSequence(::readLine) .mapNotNull { line -> line.trim().takeUnless { trimmed -> trimmed.isBlank() } } .toList() values.forEach { println(it) } val bits = values.maxOf { it.length } val gamma = buildString ...
0
Kotlin
0
0
16fe605f26632ac2e134ad4bcf42f4ed13b9cf03
1,878
AdventOfCode
MIT License
src/main/kotlin/days/Day10.kt
vovarova
572,952,098
false
{"Kotlin": 103799}
package days class Day10 : Day(10) { val commands = inputList.map { when (it) { "noop" -> Command.Noop else -> Command.AddX(it.split(" ")[1].toInt()) } } class InstructionExecutor(commandsInput: List<Command>) { private val operations: List<Operation> = com...
0
Kotlin
0
0
e34e353c7733549146653341e4b1a5e9195fece6
2,484
adventofcode_2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/CherryPickup2.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,786
kotlab
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LargestUniqueNumber.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
1,770
kotlab
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day05.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.test.assertEquals object Day05 : AbstractDay() { @Test fun tests() { assertEquals("CMZ", compute1(testInput)) assertEquals("VJSFHWGFT", compute1(puzzleInput)) assertEquals("MCD...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,673
aoc
Apache License 2.0
src/Day06.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
fun main() { fun solve(input: String, numDistinct: Int): Int { val windowed = input.windowed(numDistinct) for ((index, window) in windowed.withIndex()) { if (window.toList().distinct().size == numDistinct) { return index + numDistinct } } retu...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
700
aoc-2022
Apache License 2.0
libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/buckets.kt
apollographql
69,469,299
false
{"Kotlin": 3427995, "Java": 244871, "CSS": 34435, "HTML": 4780, "JavaScript": 1191}
package com.apollographql.apollo3.compiler.ir import com.apollographql.apollo3.ast.Schema import com.apollographql.apollo3.ast.possibleTypes internal data class Bucket(val typeSet: TypeSet, val possibleTypes: PossibleTypes) /** * This function distributes [incomingTypes] into different buckets. */ internal fun buc...
174
Kotlin
659
3,628
42f3208e23d97bd3b6cc62bfc4f135523786365d
2,765
apollo-kotlin
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day16.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day16.run() object Day16: Day(2022, 16) { data class Valve(val rate: Int, val valves: List<String>) private val state = input.lines().associate { l -> val name = l.split(" ")[1] val rate = ints(l)[0] val va...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
2,562
adventofkotlin
MIT License
leetcode2/src/leetcode/IntersectionOfTwoArrays.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 两个数组的交集 * https://leetcode-cn.com/problems/intersection-of-two-arrays/ * Created by test * Date 2019/5/20 23:28 * Description * 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [9,4] 说明: 输出结...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,183
leetcode
MIT License
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day03.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2018.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.extractValues import nl.jstege.adventofcode.aoccommon.utils.extensions.transformTo class Day03 : Day(title = "No Matter How You Slice It") { private companion objec...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
2,685
AdventOfCode
MIT License
src/leetcodeProblem/leetcode/editor/en/SetMatrixZeroes.kt
faniabdullah
382,893,751
false
null
//Given an m x n integer matrix matrix, if an element is 0, set its entire row //and column to 0's, and return the matrix. // // You must do it in place. // // // Example 1: // // //Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] //Output: [[1,0,1],[0,0,0],[1,0,1]] // // // Example 2: // // //Input: matrix = [[0,1,2,...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,930
dsa-kotlin
MIT License
src/cn/ancono/math/discrete/UndirectedGraph.kt
140378476
105,762,795
false
{"Java": 1912158, "Kotlin": 1243514}
package cn.ancono.math.discrete //Created by lyc at 2021-03-28 19:32 interface UndirectedGraph : Graph { override fun degIn(a: Node): Int { return deg(a) } override fun degOut(a: Node): Int { return deg(a) } /** * Returns the nodes that are adjacent to `a`. */ fun nei...
0
Java
0
6
02c2984c10a95fcf60adcb510b4bf111c3a773bc
5,274
Ancono
MIT License
src/net/sheltem/aoc/y2016/Day03.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2016 suspend fun main() { Day03().run() } class Day03 : Day<Int>(3, 4) { override suspend fun part1(input: List<String>): Int { return input.map { it.toTriangleStringList() }.map { Triangle.from(it) }.count { it.isValid() } } override suspend fun part2(input: List<St...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,385
aoc
Apache License 2.0
kotlin/src/main/kotlin/de/p58i/advent-09.kt
mspoeri
573,120,274
false
{"Kotlin": 31279}
package de.p58i import de.p58i.RopeMove.Companion.toRopeMove import java.io.File import java.util.LinkedList import kotlin.math.abs import kotlin.math.sign enum class RopeMove { UP, DOWN, LEFT, RIGHT; companion object { fun Char.toRopeMove(): RopeMove = when (this.lowercas...
0
Kotlin
0
1
62d7f145702d9126a80dac6d820831eeb4104bd0
2,937
Advent-of-Code-2022
MIT License
src/Day08.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
@file:Suppress("DuplicatedCode") fun main() { fun List<String>.toMatrix(): Array<IntArray> = this.map { line -> line.map { it.digitToInt() }.toIntArray() }.toTypedArray() fun Array<IntArray>.getTopVisibility(x: Int, y: Int): Pair<Boolean, Int> { val pointValue = this[y][x] for (i in y-1 downT...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
2,887
advent-of-code
Apache License 2.0
advent-of-code-2022/src/main/kotlin/Day10.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
//Day 10: Cathode-Ray Tube //https://adventofcode.com/2022/day/10 import java.io.File data class Instruction(val registerInc: Int) { val noop = registerInc == 0 companion object { private val ADD = "addx " fun fromString(string: String): Instruction { return if (string.startsWith...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
2,205
advent-of-code
Apache License 2.0
src/day1/Day01.kt
rafagalan
573,145,902
false
{"Kotlin": 5674}
package day1 import readInput import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var maxCaloriesCarriedPerElf = 0 var elfCaloriesCounter = 0; input.forEach { if(it == "") { maxCaloriesCarriedPerElf = max(maxCaloriesCarriedPerElf, elfCalor...
0
Kotlin
0
0
8e7d3f25fe52a4153479adb56c5924b50f6c0be9
1,167
AdventOfCode2022
Apache License 2.0
src/main/kotlin/katas/4.HighAndLow.kt
ch8n
312,467,034
false
null
//? https://www.codewars.com/kata/554b4ac871d6813a03000035/train/kotlin ? // return the highest and lowest number. @file:Suppress("PackageDirectoryMismatch") package katas.highlow import kotlin.system.measureNanoTime fun main() { val input = "8 3 -5 42 -1 0 0 -9 4 7 4 -4" measure("Chetan-1") { hig...
3
Kotlin
0
1
e0619ebae131a500cacfacb7523fea5a9e44733d
3,037
Big-Brain-Kotlin
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day09.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* import kotlin.math.absoluteValue import kotlin.math.sign fun main() = Day09.run() object Day09 : Day(2022, 9) { override fun part1(): Any { var h = P(0, 0) var t = P(0, 0) val visited = mutableSetOf<P<Int, Int>>() fo...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,214
adventofkotlin
MIT License
google/2019/round1_a/2/main.kt
seirion
17,619,607
false
{"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294}
import java.util.* fun main(args: Array<String>) { val (T, N, M) = readLine()!!.split("\\s".toRegex()).map { s -> s.toInt() } repeat(T) { solve(N, M) } } val prime = arrayListOf(5, 7, 9, 11, 13, 16, 17) fun solve(night: Int, max: Int) { val response = ArrayList<Int>() repeat(prime.size) { index -> ...
0
C++
4
4
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
744
code
Apache License 2.0
src/main/kotlin/pl/poznan/put/omw/GameFilter.kt
Azbesciak
227,870,505
false
{"Kotlin": 41507, "Java": 18293, "Shell": 803}
package pl.poznan.put.omw import pl.poznan.put.omw.filters.MoveFilter import kotlin.math.abs class GameFilter(private val engineResult: List<EngineResult>, private val filters: List<MoveFilter>) { init { //the best move (the biggest number of CP) at the beginning engineResult.sort...
0
Kotlin
0
0
d788cd791d5b9b695c9501ca395ed1b3bd273279
3,951
ChessStrongMovesExtractor
Apache License 2.0
aoc-2015/src/main/kotlin/nl/jstege/adventofcode/aoc2015/days/Day14.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2015.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.extractValues import nl.jstege.adventofcode.aoccommon.utils.extensions.transformTo /** * * @author <NAME> */ class Day14 : Day(title = "Reindeer Olympics") { pri...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
2,106
AdventOfCode
MIT License
Day2/src/main/kotlin/de/zweistein2/Main.kt
Zweistein2
575,020,168
false
{"Kotlin": 15154}
package de.zweistein2 import de.zweistein2.MatchOutcome.Companion.leadsTo import de.zweistein2.Shape.Companion.against import mu.KotlinLogging private val logger = KotlinLogging.logger {} private val monitoring = LoggerMonitoring() fun main() { val content = InputHandler.readInput("/input.txt") monitoring.w...
0
Kotlin
0
2
baf40d39806fd5dde0a63f5075c581a6c8f56a62
2,598
AoC22
Apache License 2.0
src/day02/Day02.kt
PoisonedYouth
571,927,632
false
{"Kotlin": 27144}
package day02 import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { when (it) { "A X" -> 1 + 3 "A Y" -> 2 + 6 "A Z" -> 3 + 0 "B X" -> 1 + 0 "B Y" -> 2 + 3 "B Z" -...
0
Kotlin
1
0
dbcb627e693339170ba344847b610f32429f93d1
1,063
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/ctci/chapterone/CheckPermutation.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chapterone // 1.2 - page 90 // In Kotlin given two strings, write a method to decide if one is a permutation of the other. //To decide if one string is a permutation of another using a hash table in Kotlin, you can create a mutable map to // store the number of occurrences of each character in the first s...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
1,954
dsa-kotlin
MIT License
src/main/kotlin/leetcode/uber/SlidingPuzzle.kt
Magdi
390,731,717
false
null
package leetcode.uber import java.util.* /** * https://leetcode.com/problems/sliding-puzzle/ * * *BFS O(N) N = number of valid states to the puzzle */ class SlidingPuzzle { fun slidingPuzzle(board: Array<IntArray>): Int { val initBoard = Board(listOf(1, 2, 3, 4, 5, 0)) val q: Queue<Board> = L...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
1,794
ProblemSolving
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day10.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 /** * AoC 2017, Day 10 * * Problem Description: http://adventofcode.com/2017/day/10 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day10/ */ class Day10(input: String, part1: Boolean, ringSize: Int = 256) { pr...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
1,724
advent-2017-kotlin
MIT License
src/main/kotlin/g2401_2500/s2449_minimum_number_of_operations_to_make_arrays_similar/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2449_minimum_number_of_operations_to_make_arrays_similar // #Hard #Array #Sorting #Greedy #2023_07_05_Time_791_ms_(100.00%)_Space_61.9_MB_(100.00%) class Solution { fun makeSimilar(nums: IntArray, target: IntArray): Long { val evenNums = ArrayList<Int>() val oddNums = ArrayList...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,851
LeetCode-in-Kotlin
MIT License
src/Day10.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
import kotlin.math.abs fun main() { fun run(input: List<String>) = buildList { var x = 1 add(x) input.forEach { if (it == "noop") { add(x) } else { add(x) val change = it.split(" ")[1].toInt() x += chang...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
1,178
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2016/calendar/day04/Day04.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2016.calendar.day04 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory class Day04 @Inject constructor(private val generatorFactory: InputGeneratorFactory) { fun partOne(filename: String) = generatorFactory.forFile(filename).readAs(::room) { input -...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,116
advent-of-code
MIT License
src/main/kotlin/adventofcode/day23.kt
Kvest
163,103,813
false
null
package adventofcode import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min fun main(args: Array<String>) { first23(File("./data/day23.txt").readLines()) second23(File("./data/day23.txt").readLines() ) } private val nanobotRegex = Regex("pos=<(-?\\d+),(-?\\d+),(-?\\d+)>, r=(...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
2,896
aoc2018
Apache License 2.0
Problems/Algorithms/1129. Shortest Path with Alternating Colors/ShortestAlternatingPath.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun shortestAlternatingPaths(n: Int, redEdges: Array<IntArray>, blueEdges: Array<IntArray>): IntArray { val redGraph: MutableMap<Int, MutableList<Int>> = mutableMapOf() for (edge in redEdges) { if (!redGraph.containsKey(edge[0])) { redGraph[edge[0]] = mut...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
2,177
leet-code
MIT License
src/main/kotlin/com/hopkins/aoc/day21/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day21 import com.hopkins.aoc.day17.Point import java.io.File const val debug = true const val part = 1 /** Advent of Code 2023: Day 21 */ fun main() { // Step 1: Read the file input val lines: List<String> = File("input/input21-ex1.txt").readLines() if (debug) { println("S...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
2,741
aoc2023
MIT License
algorithms/ciphers/AffineCipher.kt
AllAlgorithms
149,472,181
false
null
import kotlin.math.max import kotlin.test.assertEquals import kotlin.test.assertNotEquals import kotlin.test.assertTrue fun main(args: Array<String>) { val alphabet = List('z' - 'a' + 1) { 'a' + it }.toSet() val input = "lorem ipsum dolor sit amet, consectetur adipiscing elit." val expected = ...
1
Kotlin
5
8
210738a3a79473a65048e339223f012faca46d19
1,725
kotlin
MIT License
simpleCykParser/src/main/kotlin/org/michaeldadams/simpleCykParser/grammar/Properties.kt
adamsmd
668,129,808
false
null
/** * Properties that can be computed about lex rules, parse rules and grammars. * * Note that not everything here is actually used for parsing. For example, * some things like [undefinedSymbols] are used for checking if a grammar is * valid. */ package org.michaeldadams.simpleCykParser.grammar /** * Get the ...
0
Kotlin
0
0
23f1485bc0e56c9f6fa438053fc526066cf5a7f4
2,970
simpleCykParser
MIT License
src/main/kotlin/io/github/pshegger/aoc/y2015/Y2015D13.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2015 import io.github.pshegger.aoc.common.BaseSolver import io.github.pshegger.aoc.common.extractAll import io.github.pshegger.aoc.common.permutations import io.github.pshegger.aoc.common.toExtractor class Y2015D13 : BaseSolver() { override val year = 2015 override val day = 13...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
1,994
advent-of-code
MIT License
src/main/kotlin/me/peckb/aoc/_2018/calendar/day10/Day10.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2018.calendar.day10 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import kotlin.Int.Companion.MAX_VALUE import kotlin.Int.Companion.MIN_VALUE import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day10 @Inject constructor(pri...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,536
advent-of-code
MIT License
src/y2021/d01/Day01.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2021.d01 import println import readInput fun main() { fun part1(input: List<String>): Int { // take 2 elements in input at a time return input.windowed(2, 1, false).map { val (a, b) = it if (b.toInt() > a.toInt()) 1 else 0 }.sum() } fun part2(input...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
915
aoc
Apache License 2.0
src/Day01.kt
gutyoh
433,854,926
false
null
fun main() { fun part1(input: List<String>): Int { // return input.size var counter = 0 val numberList = input.map { it.toInt() } for (i in numberList.indices) { // if it's the last number end the loop if (i == numberList.size - 1) { break ...
0
Kotlin
0
0
3d27c7aa6bf4d07f10d20d6dd05d7fb87f6cae4e
1,229
advent-of-code-kotlin-template
Apache License 2.0
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p09/Leet909.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p09 import com.artemkaxboy.leetcode.LeetUtils import java.util.LinkedList /** * Accepted * * Runtime: 335ms Beat: 33.33% * Memory: 39.5MB Beat: 33.33% */ class Leet909 { private lateinit var board: Array<IntArray> private val explored = HashSet<Sq...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
3,956
playground
MIT License
src/day15/fr/Day15_2.kt
BrunoKrantzy
433,844,189
false
{"Kotlin": 63580}
package day15.fr import java.io.File private fun readChars(): CharArray = readLn().toCharArray() private fun readLn() = readLine()!! // string line private fun readSb() = StringBuilder(readLn()) private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fu...
0
Kotlin
0
0
0d460afc81fddb9875e6634ee08165e63c76cf3a
6,010
Advent-of-Code-2021
Apache License 2.0
src/Day01.kt
dannyrm
573,100,803
false
null
fun main() { fun part1(input: List<String>): Int { return splitByElf(input).max() } fun part2(input: List<String>): Int { return splitByElf(input).sortedDescending().take(3).sum() } val input = readInput("Day01") println(part1(input)) println(part2(input)) } fun splitByElf...
0
Kotlin
0
0
9c89b27614acd268d0d620ac62245858b85ba92e
709
advent-of-code-2022
Apache License 2.0