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/hj/leetcode/kotlin/problem653/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem653 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [653. Two Sum IV - Input is a BST](https://leetcode.com/problems/two-sum-iv-input-is-a-bst/); */ class Solution2 { /* Complexity: * Time O(N) and Space O(H) where N and H are the number of nod...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,251
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/day14.kt
bfrengley
318,716,410
false
null
package aoc2020.day14 import aoc2020.util.loadTextResource val toBinaryString = java.lang.Long::toBinaryString fun main(args: Array<String>) { val instrs = loadTextResource("/day14.txt").lines().map(Instr::parse) part1(instrs) part2(instrs) } fun part1(instrs: List<Instr>) { var mask = Bitmask.pars...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,964
aoc2020
ISC License
kotlin/src/com/s13g/aoc/aoc2022/Day22.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.add import com.s13g.aoc.addTo import com.s13g.aoc.aocRange import com.s13g.aoc.resultFrom /** * --- Day 22: Monkey Map --- * https://adventofcode.com/2022/day/22 */ class Day22 : Solver { ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
5,555
euler
Apache License 2.0
src/main/kotlin/tree/Trim.kt
yx-z
106,589,674
false
null
package tree import java.util.* // given a tree that can have any number of child nodes // trim the tree up to a given level // the trimmed level nodes now have the sum of all their child nodes fun main(args: Array<String>) { // 1. 5 // / | | \ // 2. 1 2 3 4 // / \ | / | \ // 3. 6 7 9...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,589
AlgoKt
MIT License
src/chapter4/section1/ex3.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter4.section1 import chapter3.section5.LinearProbingHashSET import chapter3.section5.SET import edu.princeton.cs.algs4.In /** * 为Graph添加一个赋值构造函数,它接受一副图G然后创建并初始化这幅图的一个副本 * G的用例对它作出的任何改动都不应该影响它的副本 * * 解:因为通过扩展函数实现,不能直接访问adj变量 * 遍历图所有顶点对应的边,再将边依次加入新创建的图中 * 因为一条边会被遍历两次,所以用一个新的数据结构对边去重 */ fun Graph.copy...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,762
Algorithms-4th-Edition-in-Kotlin
MIT License
src/day12/Terrain.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day12 open class Terrain (val input: String) { private val rows: List<String> = input.trim().split("\n") private val raw: String = input.replace("\n", "") val xs: Int = rows[0].length val ys: Int = rows.size val dimensions: Pair<Int, Int> = Pair(xs, ys) private val grid: Array<Int> = Ar...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
2,915
advent_of_code_2022
Apache License 2.0
src/main/kotlin/leetcode/problem0052/NQueens2.kt
ayukatawago
456,312,186
false
{"Kotlin": 266300, "Python": 1842}
package leetcode.problem0052 class NQueens2 { fun totalNQueens(n: Int): Int { val board = Array(n) { BooleanArray(n) { false } } return solve(board, 0) } private fun solve(board: Array<BooleanArray>, row: Int): Int { if (row == board.size) { return 1 } ...
0
Kotlin
0
0
f9602f2560a6c9102728ccbc5c1ff8fa421341b8
1,419
leetcode-kotlin
MIT License
src/main/java/Day7.kt
mattyb678
319,195,903
false
null
class Day7 : Day { companion object { private val parentRegex = "([a-z]+\\s[a-z]+)".toRegex() private val contentRegex = "((\\d)\\s([a-z]+\\s[a-z]+))+".toRegex() } override fun asInt(): Int = 7 override fun part1InputName(): String = "day7" override fun part1(input: List<String>)...
0
Kotlin
0
1
f677d61cfd88e18710aafe6038d8d59640448fb3
1,835
aoc-2020
MIT License
src/main/kotlin/endredeak/aoc2023/Day06.kt
edeak
725,919,562
false
{"Kotlin": 26575}
package endredeak.aoc2023 import endredeak.aoc2023.lib.utils.productOf import endredeak.aoc2023.lib.utils.transpose import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt fun main() { solve("Wait For It") { val input = lines.map { it.substringAfter(":") } part1(138915) { ...
0
Kotlin
0
0
92c684c42c8934e83ded7881da340222ff11e338
936
AdventOfCode2023
Do What The F*ck You Want To Public License
src/Day14.kt
spaikmos
573,196,976
false
{"Kotlin": 83036}
fun main() { fun parseInput(input: List<String>): MutableSet<Pair<Int, Int>> { // Parse the input into a set of points val m = mutableSetOf<Pair<Int, Int>>() for (i in input) { val parts = i.split(" -> ") val it = parts.iterator() var tmp = (it.next().spli...
0
Kotlin
0
0
6fee01bbab667f004c86024164c2acbb11566460
3,993
aoc-2022
Apache License 2.0
src/main/kotlin/Day04.kt
alex859
573,174,372
false
{"Kotlin": 80552}
fun main() { val testInput = readInput("Day04_test.txt") check(testInput.countFullyOverlappingAssignments() == 2) check(testInput.countPartialOverlappingAssignments() == 4) val input = readInput("Day04.txt") println(input.countFullyOverlappingAssignments()) println(input.countPartialOverlapping...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
1,361
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountPairs.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,418
kotlab
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/day11/SeatPredictor.kt
Pkshields
318,658,287
false
null
package dev.paulshields.aoc.day11 abstract class SeatPredictor(input: String, private val occupiedSeatTolerance: Int) { private var seatingLayout = input .lines() .filter { it.isNotEmpty() } .map { it.map(Seat::parseChar).toList() } .toList() protected val adjacentSeats = listO...
0
Kotlin
0
0
a7bd42ee17fed44766cfdeb04d41459becd95803
1,825
AdventOfCode2020
MIT License
src/main/kotlin/Dijkstra.kt
MatteoMartinelli97
403,882,570
false
{"Kotlin": 39512}
import java.util.* import kotlin.collections.ArrayDeque object Dijkstra { fun shortestPath(g: Graph<Int>, source: Int): Map<Int, Float> { //Pair<List<Int>, Float> { if (source !in g.V) { throw RuntimeException("Source is not in graph vertices, cannot compute path!") } val dist ...
0
Kotlin
0
0
f14d4ba7058be629b407e06eebe09fae63aa35c1
6,850
Dijkstra-and-AStar
Apache License 2.0
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day02/Day02.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2022.day02 import nerok.aoc.utils.Input import kotlin.time.DurationUnit import kotlin.time.measureTime enum class RockPaperScissor { ROCK, PAPER, SCISSOR } enum class Result { WIN, DRAW, LOSS } fun main() { val opponentAction = mapOf( "A" to RockPaperScissor.ROCK, "B...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
4,117
AOC
Apache License 2.0
src/main/kotlin/Day07.kt
AlmazKo
576,500,782
false
{"Kotlin": 26733}
object Day07 : Task { @JvmStatic fun main(args: Array<String>) = execute() override fun part1(input: Iterable<String>): Any { val fs = initFileSystem(input) return calculatePhase1(fs.root, 100_000) } override fun part2(input: Iterable<String>): Long { val fs = initFileSyst...
0
Kotlin
0
1
109cb10927328ce296a6b0a3600edbc6e7f0dc9f
3,470
advent2022
MIT License
src/main/kotlin/ru/glukhov/aoc/Day4.kt
cobaku
576,736,856
false
{"Kotlin": 25268}
package ru.glukhov.aoc import java.io.BufferedReader fun main() { Problem.forDay("day4").use { solveFirst(it) }.let { println("Result of the first problem is $it") } Problem.forDay("day4").use { solveSecond(it) }.let { println("Result of the first problem is $it") } } private fun solveFirst(reader: BufferedR...
0
Kotlin
0
0
a40975c1852db83a193c173067aba36b6fe11e7b
1,226
aoc2022
MIT License
kotlin/src/x2022/day10/day10.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package day10 import readInput enum class Instruction(val cycles: Int) { NOOP(1), ADDX(2); } data class Op(val instruction: Instruction, val data: Any?) { var cc: Int = 0 fun cycle(cpu: CPU, data: Any?): Boolean { if (cc < instruction.cycles) cc++ when (instruction) { Inst...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
3,463
adventOfCode
Apache License 2.0
src/main/kotlin/g2101_2200/s2134_minimum_swaps_to_group_all_1s_together_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2134_minimum_swaps_to_group_all_1s_together_ii // #Medium #Array #Sliding_Window #2023_06_25_Time_465_ms_(33.33%)_Space_51.3_MB_(100.00%) class Solution { fun minSwaps(nums: IntArray): Int { val l = nums.size val ones = IntArray(l) ones[0] = if (nums[0] == 1) 1 else 0 ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,175
LeetCode-in-Kotlin
MIT License
src/Day01.kt
samo1
573,449,853
false
{"Kotlin": 4045}
import java.util.PriorityQueue fun main() { fun inputToCaloriesPerElf(input: List<String>): List<Int> { val calories = mutableListOf<Int>() var value = 0 input.forEach { line -> if (line.trim() != "") { value += line.toInt() } else { c...
0
Kotlin
0
0
77e32453ba45bd4f9088f34be91939b94161cf13
1,276
adventofcode2022
Apache License 2.0
src/Day08.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { var visibleTreeCount = (input.size - 1) * 4 for (row in 1 until input.size - 1) { for (col in 1 until input.first().length - 1) { val currentTree = input[row][col].digitToInt() var isVisibleFromLeft = tru...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
3,157
aoc2022
Apache License 2.0
src/main/kotlin/com/exsilicium/scripture/shared/model/Location.kt
Ex-Silicium
103,700,839
false
null
package com.exsilicium.scripture.shared.model import com.exsilicium.scripture.shared.extensions.compareChapterRanges import com.exsilicium.scripture.shared.extensions.compareVerseRanges import com.exsilicium.scripture.shared.extensions.createJoinedString import com.exsilicium.scripture.shared.extensions.joinString imp...
14
Kotlin
1
1
4815f70f5736080d7533e0d1316f0aa2c31aa85a
2,533
scripture-core
Apache License 2.0
src/main/kotlin/com/pandarin/aoc2022/Day2.kt
PandarinDev
578,619,167
false
{"Kotlin": 6586}
package com.pandarin.aoc2022 import java.lang.IllegalArgumentException enum class Outcome(val score: Int, val shapeToChoose: (Shape) -> Shape) { LOSE(0, shapeToChoose = { when (it) { Shape.ROCK -> Shape.SCISSOR Shape.PAPER -> Shape.ROCK Shape.SCISSOR -> Shape.PAPER ...
0
Kotlin
0
0
42c35d23129cc9f827db5b29dd10342939da7c99
2,433
aoc2022
MIT License
2021/src/test/kotlin/Day02.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 Day02 { enum class Instruction { FORWARD, UP, DOWN } data class Command(val instruction: Instruction, val units: Int) data class Position(val position: Int, val depth: Int, val aim: Int) @Test fun `run part 01`() { val positionT...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,613
adventofcode
MIT License
src/main/kotlin/solutions/Day20GrovePositioningSystem.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Input import utils.Solution // run only this day fun main() { Day20GrovePositioningSystem() } class Day20GrovePositioningSystem : Solution() { init { begin("Day 20 - Grove Positioning System") val input = Input.parseLines(filename = "/d20_encrypted_file.txt") ...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
1,524
advent-of-code-2022
MIT License
src/Day10.kt
inssein
573,116,957
false
{"Kotlin": 47333}
fun main() { fun buildSignal(input: List<String>): List<Int> { return input.fold(listOf(1)) { acc, it -> val register = acc.last() when (it.take(4)) { "noop" -> acc.plus(register) "addx" -> acc.plus(listOf(register, register + it.substring(5).toInt())...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,473
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/Day19Github.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode import tr.emreone.kotlin_utils.product import kotlin.math.min class Day19Github : Day(19, 2022, "Not Enough Minerals") { val bps = input.map { it.extractAllIntegers() }.show() val id = 0 val ORE_ROBOT_COST_ORE = 1 val CLAY_ROBOT_COST_ORE = 2 val OBSIDIAN_ROBOT_COS...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
9,091
advent-of-code-2022
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector3D import net.olegg.aoc.utils.parseInts import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 22](https://adventofcode.com/2023/day/22) */ object Day22 : DayOf2023...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,542
adventofcode
MIT License
src/Day07.kt
ExpiredMinotaur
572,572,449
false
{"Kotlin": 11216}
fun main() { val pattern = "\\\$ cd (.*)|(\\d+).*".toRegex() var fs = emptyMap<String, Int>().toMutableMap() fun loadFileSystem(input: List<String>){ fs = emptyMap<String, Int>().toMutableMap() var dir = "" for(line in input) { val match = pattern.matchEntire(li...
0
Kotlin
0
0
7ded818577737b0d6aa93cccf28f07bcf60a9e8f
1,506
AOC2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day04.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import kotlin.math.pow class Day04 : Day(4, 2023, "Scratchcards") { private fun parseMatches(input: List<String>): Map<Int, Int> { return input.associate { line -> val (card, game) = line.split(":") ...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
1,569
advent-of-code-2023
Apache License 2.0
test/leetcode/RomanNumerals.kt
andrej-dyck
340,964,799
false
null
package leetcode import lib.* import net.jqwik.api.* import org.assertj.core.api.Assertions.* import org.junit.jupiter.api.* import org.junit.jupiter.params.* import org.junit.jupiter.params.provider.* import java.util.regex.* import kotlin.system.* import kotlin.time.* /** * https://leetcode.com/problems/integer-to...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
8,211
coding-challenges
MIT License
src/Day09.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
import kotlin.math.abs enum class MotionDirection { UP, DOWN, RIGHT, LEFT } data class Motion(val direction: MotionDirection, val numberOfSteps: Int) private val LINE_REGEX = "(?<direction>[UDRL])\\s+(?<steps>\\d+)".toRegex() private const val NUM_TAILS = 9 fun main() { fun isAdjacent(headPosition: Pair<I...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
4,153
Advent-of-Code-2022-Kotlin
Apache License 2.0
src/main/kotlin/Main.kt
nschulzke
571,330,516
false
{"Kotlin": 5085}
package com.nschulzke enum class Stars { One, Two, Three; } private val mancalaIndices = setOf(6, 13) data class Puzzle( private val board: List<Int>, private val turns: Int, private val targets: List<Pair<Stars, Int>>, val steps: List<Int> = emptyList(), ) { fun onBottom(pit: Int): Boolean =...
0
Kotlin
0
0
b130d3b1521b0a8cc9442b7afc97a951a01ced69
4,700
mancala-puzzle-solver
MIT License
src/Day22.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
import java.util.* const val RIGHT = 0 const val DOWN = 1 const val LEFT = 2 const val UP = 3 const val VOID = ' ' const val OPEN = '.' const val WALL = '#' fun transpose(side: Array<CharArray>): Array<CharArray> { for (i in 1..side.lastIndex) for (j in 0..i) { side[i][j] = side[j][i].also { side[j][i] =...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
8,313
AoC-2022
Apache License 2.0
src/main/kotlin/aoc2015/Day22.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2015 import AoCDay import util.match // https://adventofcode.com/2015/day/22 object Day22 : AoCDay<Int>( title = "Wizard Simulator 20XX", part1Answer = 1824, part2Answer = 1937, ) { private class Spell(val mana: Int, val effect: Effect? = null, val damage: Int = 0, val heal: Int = 0) pr...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
4,326
advent-of-code-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1296/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1296 import java.util.* /** * LeetCode page: [1296. Divide Array in Sets of K Consecutive Numbers](https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/); */ class Solution { /* Complexity: * Time O(NLogN) and Space O(N) where N is the size of nu...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,366
hj-leetcode-kotlin
Apache License 2.0
src/Day16.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.max import kotlin.math.min private class Valve(val flowRate: Int, val totalIndex: Int) { var open = false val tunnelsIndices = mutableListOf<Int>() var indexInNonZero = -1 } private var SHIFT = 58 fun calculateHorribleKey(currentValveInd: Int, elephantValveInd: Int, mask: Int): Int { ...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
8,448
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day3.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days import kotlin.math.pow class Day3 : Day(3) { override fun partOne(): Any { val a = inputList.map { it.map { Character.getNumericValue(it) }.toTypedArray() }.toTypedArray() val bitLen = inputList.first().length val n = inputList.size var gammaRate = 0 var epsil...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
2,373
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/day2/Day2.kt
tomaszobac
726,163,227
false
{"Kotlin": 15292}
package day2 import java.io.File fun part1(file: File) { var correctGames: Array<Int> = arrayOf() lineLoop@ for ((currentGame, line) in file.readLines().withIndex()) { val sets = (line.split(": ")[1]).split("; ") for (set in sets) { val cubes = set.split(", ") fo...
0
Kotlin
0
0
e0ce68fcf11e126c4680cff75ba959e46c5863aa
1,583
aoc2023
MIT License
src/main/kotlin/year2023/day02/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2023.day02 import IProblem class Problem : IProblem { private val games = mutableListOf<Game>() init { javaClass .getResourceAsStream("/2023/02.txt")!! .bufferedReader() .forEachLine(::parseGame) } private fun parseGame(s: String) { val...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
2,190
advent-of-code
The Unlicense
src/Utils.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
import java.io.File import java.math.BigInteger import java.security.MessageDigest import kotlin.system.measureNanoTime typealias Coord = Pair<Int, Int> /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() fun readInputRaw(name: String) = File(...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
2,046
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day15.kt
TheMrMilchmann
571,779,671
false
{"Kotlin": 56525}
/* * Copyright (c) 2022 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
2e01ab62e44d965a626198127699720563ed934b
4,219
AdventOfCode2022
MIT License
dcp_kotlin/src/main/kotlin/dcp/day279/day279.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day279 // day279.kt // By <NAME>, 2020. typealias Vertex = Int typealias AdjacencyList = Set<Vertex> typealias AdjacencyGraph = Map<Vertex, AdjacencyList> typealias TransitiveClosure = Set<Vertex> typealias TransitiveClosures = Set<TransitiveClosure> /** * Calculate the transitive closure groups of a dir...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
2,611
daily-coding-problem
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2022/Day21.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 class Day21 : AbstractDay() { @Test fun part1Test() { assertEquals(152, compute1(testInput)) } @Test fun part1Puzzle() { assertEquals(331319379445180, co...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
4,863
aoc
Apache License 2.0
2016/src/main/kotlin/com/koenv/adventofcode/Day13.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode import java.util.* object Day13 { fun getDistance(input: String, destination: Pair<Int, Int>): Int { val favoriteNumber = input.toInt() var currentState = State(null, 1 to 1) val moves: Queue<State> = ArrayDeque<State>() moves.add(currentState) ...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
3,603
AdventOfCode-Solutions-Kotlin
MIT License
src/main/kotlin/de/tek/adventofcode/y2022/day11/MonkeyInTheMiddle.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day11 import de.tek.adventofcode.y2022.util.readInputLines import de.tek.adventofcode.y2022.util.splitByBlankLines import java.math.BigInteger open class Item(initialWorryLevel: Int, modulus: Int) { private var worryLevel = initialWorryLevel.toBigInteger() private val modulus...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
10,630
advent-of-code-2022
Apache License 2.0
NiceString_TaxiPark/Taxi Park/Task/src/taxipark/TaxiParkTask.kt
EdmundoSanchezM
354,481,310
false
null
package taxipark /* * Task #1. Find all the drivers who performed no trips. */ fun TaxiPark.findFakeDrivers(): Set<Driver> = this.allDrivers - this.trips.map { it.driver }.toSet() /* * Task #2. Find all the clients who completed at least the given number of trips. */ fun TaxiPark.findFaithfulPassengers(minTri...
0
Kotlin
0
0
a671a9b35eeae1f56ee1ad448347d9df5e583c9d
2,469
Kotlin-for-Java-Developers
MIT License
leetcode/src/offer/middle/Offer66.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 66. 构建乘积数组 // https://leetcode.cn/problems/gou-jian-cheng-ji-shu-zu-lcof/ println(constructArr1(intArrayOf(1,2,3,4,5)).contentToString()) } fun constructArr(a: IntArray): IntArray { if (a.isEmpty()) { return IntArray(0) } // 对于一个索引i,可以用 i 左...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,078
kotlin-study
MIT License
src/main/kotlin/com/marcdenning/adventofcode/day12/Day12a.kt
marcdenning
317,730,735
false
{"Kotlin": 87536}
package com.marcdenning.adventofcode.day12 import java.io.File import java.util.regex.Pattern import kotlin.math.abs const val FORWARD = 'F' const val NORTH = 'N' const val SOUTH = 'S' const val EAST = 'E' const val WEST = 'W' const val RIGHT = 'R' const val LEFT = 'L' fun main(args: Array<String>) { var current...
0
Kotlin
0
0
b227acb3876726e5eed3dcdbf6c73475cc86cbc1
2,705
advent-of-code-2020
MIT License
hangman-service/src/main/kotlin/dulcinea/hangman/local/wordstore/WordStore.kt
wpitt3
167,178,716
false
null
package dulcinea.hangman.local.wordstore class WordCache(words: List<String>) { private val minBeforeDoubles = 40 private val minBeforeTriples = 20 private val allWords: List<Word> = words.map { Word(it) } fun allMatchingWords(with: List<Char?>, without: Set<Char>): List<Word> { val unique: Se...
10
Kotlin
0
0
34332d06830b4ff6ca2ad200e2785650a32d3f78
6,581
hangman
Apache License 2.0
src/Day04.kt
psy667
571,468,780
false
{"Kotlin": 23245}
fun main() { val id = "04" fun part1(input: List<String>): Int { return input.count { val (a,b,x,y) = it.replace(',', '-').split('-').map(String::toInt) a in x..y && b in x..y || x in a..b && y in a..b } } fun part2(input: List<String>): Int { return inp...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
721
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/lucaszeta/adventofcode2020/day22/day22.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day22 import com.lucaszeta.adventofcode2020.ext.getResourceAsText fun main() { val decks = getResourceAsText("/day22/decks.txt") .split("\n\n") .map(::parseDeck) val winnerDeck = playCombat(decks[0], decks[1]) println("Combat") println("Winner d...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
1,006
advent-of-code-2020
MIT License
src/main/kotlin/net/voldrich/aoc2021/Day15.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay import org.jheaps.AddressableHeap import org.jheaps.tree.FibonacciHeap import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashSet import kotlin.system.measureTimeMillis // https://adventofcode.com/2021/day/15 fun main() { Day1...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
6,887
advent-of-code
Apache License 2.0
src/main/kotlin/de/havemann/transformer/domain/sortkey/SortKey.kt
LukasHavemann
362,340,388
false
null
package de.havemann.transformer.domain.sortkey import java.util.* import java.util.Comparator.comparing import kotlin.reflect.KProperty1 /** * Sorting is determined through the use of the ‘sort’ query string parameter. The value of this parameter is a * comma-separated list of sort keys. Sort directions can optiona...
0
Kotlin
0
0
8638fe7c4037c93708cdaf05b9a8c23954e7d866
2,259
microservice-transformer
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem211/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem211 /** * LeetCode page: [211. Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure/); */ class WordDictionary() { private val root = Trie(wildcards = '.') fun addWord(word: String) { root.addWord(...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,794
hj-leetcode-kotlin
Apache License 2.0
2023/15/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File private const val FILENAME = "2023/15/input.txt" fun main() { partOne() partTwo() } private fun partOne() { val file = File(FILENAME).readLines().map { it.split(",") }.first() var result = 0 for (element in file) { result += hash(element) } println(result) }...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
2,449
Advent-of-Code
MIT License
src/Day04.kt
rossilor95
573,177,479
false
{"Kotlin": 8837}
fun main() { fun String.toIntRange(): IntRange = this.substringBefore('-').toInt()..this.substringAfter('-').toInt() fun String.toIntRangePair(): Pair<IntRange, IntRange> = this.substringBefore(',').toIntRange() to this.substringAfter(',').toIntRange() infix fun IntRange.enclose(other: IntRange): ...
0
Kotlin
0
0
0ed98d0ab5f44b2ccfc625ef091e736c5c748ff0
1,091
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/askrepps/advent2022/day03/Day03.kt
askrepps
726,566,200
false
{"Kotlin": 302802}
/* * MIT License * * Copyright (c) 2022-2023 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modi...
0
Kotlin
0
0
5ce2228b0951db49a5cf2a6d974112f57e70030c
2,564
advent-of-code-kotlin
MIT License
src/Day01.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
fun main() { fun part1(input: String): Int { return input .split("\n\n") .maxOf { calories -> calories .split("\n") .sumOf { it.toInt() } } } fun part2(input: String): Int { return input ...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
783
advent-of-code-2022
Apache License 2.0
Kotlin/src/LetterCombinationsOfAPhoneNumber.kt
TonnyL
106,459,115
false
null
/** * Given a digit string, return all possible letter combinations that the number could represent. * * A mapping of digit to letters (just like on the telephone buttons) is given below. * * Input:Digit string "23" * Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. * Note: * Although the above a...
1
Swift
22
189
39f85cdedaaf5b85f7ce842ecef975301fc974cf
1,362
Windary
MIT License
kotlin/720.Longest Word in Dictionary(词典中最长的单词).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p>Given a list of strings <code>words</code> representing an English Dictionary, find the longest word in <code>words</code> that can be built one character at a time by other words in <code>words</code>. If there is more than one possible answer, return the longest word with the smallest lexicographical order.</...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
3,989
leetcode
MIT License
src/main/kotlin/days/Day7.kt
hughjdavey
572,954,098
false
{"Kotlin": 61752}
package days import xyz.hughjd.aocutils.Collections.indicesOf class Day7 : Day(7) { private val commandIndices = inputList.indicesOf { it.startsWith("$") } private val commands = commandIndices.plus(inputList.size).windowed(2).map { inputList.subList(it[0], it[1]) } private val root = getFilesystem().f...
0
Kotlin
0
2
65014f2872e5eb84a15df8e80284e43795e4c700
3,124
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day22.kt
janbina
112,736,606
false
null
package Day22 import getInput import kotlin.test.assertEquals fun main(args: Array<String>) { val input = getInput(22).readLines() val gridSize = 1000 val grid = Array(gridSize) { CharArray(gridSize) { '.' } } val i = (gridSize - input.size) / 2 val j = (gridSize - input[0].length) / 2 val c...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
2,694
advent-of-code-2017
MIT License
src/net/sheltem/aoc/y2022/Day21.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 import net.sheltem.common.MathOperation import net.sheltem.common.MathOperation.ADD import net.sheltem.common.MathOperation.Companion.fromSign import net.sheltem.common.MathOperation.DIVIDE import net.sheltem.common.MathOperation.MULTIPLY import net.sheltem.common.MathOperation.SUBSTRACT...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,967
aoc
Apache License 2.0
src/Day24.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
import java.util.PriorityQueue fun main() { fun part1(input: List<String>): Long { // Set border val borderMin = Coordinates(0, 0) val borderMax = Coordinates(input.size-1, input[0].length-1) // Set start/end val start = borderMin.add(Coordinates(0, 1)) val end = bo...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
12,455
aoc2022
Apache License 2.0
utils/common/src/main/kotlin/Utils.kt
oss-review-toolkit
107,540,288
false
{"Kotlin": 4800742, "JavaScript": 307822, "Shell": 124731, "HTML": 81058, "Haskell": 30438, "CSS": 26585, "FreeMarker": 26475, "Python": 19161, "Dockerfile": 18312, "Swift": 11625, "Ruby": 9720, "Roff": 7665, "Vim Snippet": 7361, "Scala": 6656, "Go": 2816, "ANTLR": 1953, "Java": 559, "Rust": 280, "Emacs Lisp": 191}
/* * Copyright (C) 2017 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.a...
346
Kotlin
284
1,419
5c5eae44a5bd4934c4600a56ee08b79cb074f072
4,655
ort
Apache License 2.0
src/main/kotlin/day1.kt
danielfreer
297,196,924
false
null
import kotlin.time.ExperimentalTime @ExperimentalTime fun day1(input: List<String>): List<Solution> { val modulesMass = input.map(String::toInt) return listOf( solve(1, 1) { sumFuelRequired(modulesMass) }, solve(1, 2) { sumAllFuelRequired(modulesMass) } ) } fun fuelRequired(mass: Int) = m...
0
Kotlin
0
0
74371d15f95492dee1ac434f0bfab3f1160c5d3b
689
advent2019
The Unlicense
kotlin/src/katas/kotlin/leetcode/phone_number/PhoneNumber.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.phone_number import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/problems/letter-combinations-of-a-phone-number/ */ class PhoneNumberTests { @Test fun `find all possible letter combinations that a number could represent`() { "".letterCombinations() sh...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,114
katas
The Unlicense
src/main/kotlin/year2022/day15/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day15 import IProblem import java.util.regex.Pattern import kotlin.math.abs class Problem(private val y: Int, private val bounds: Int) : IProblem { private val beacons = mutableSetOf<Point>() private val distances = mutableMapOf<Point, Int>() init { val pattern = Pattern.compile(...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
2,316
advent-of-code
The Unlicense
src/main/kotlin/extensions/Tuple.kt
swantescholz
102,711,230
false
null
package extensions import java.util.* fun <A, B> fst(pair: Pair<A, B>): A = pair.first fun <A, B> snd(pair: Pair<A, B>): B = pair.second //fun <A,B,C> fst(triple: Triple<A,B,C>) : A = triple.first //fun <A,B,C> snd(triple: Triple<A,B,C>) : B = triple.second //fun <A,B,C> trd(triple: Triple<A,B,C>) : C = triple.third ...
0
Kotlin
0
0
20736acc7e6a004c29c328a923d058f85d29de91
5,727
ai
Do What The F*ck You Want To Public License
src/main/kotlin/dev/shtanko/algorithms/leetcode/PowerfulIntegers.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,847
kotlab
Apache License 2.0
day3/src/main/kotlin/com/nohex/aoc/day3/SubmarineMetrics.kt
mnohe
433,396,563
false
{"Kotlin": 105740}
package com.nohex.aoc.day3 internal class SubmarineMetrics { fun getPowerConsumption(diagnostics: Sequence<String>): Int { val iterator = diagnostics.iterator() if (!iterator.hasNext()) { return 0 } // Obtain the record size from the first record. val record = ...
0
Kotlin
0
0
4d7363c00252b5668c7e3002bb5d75145af91c23
3,272
advent_of_code_2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximalRectangle.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,120
kotlab
Apache License 2.0
src/main/kotlin/pub/edholm/aoc2017/day4/Passphrases.kt
Edholm
112,762,269
false
null
package pub.edholm.aoc2017.day4 import pub.edholm.aoc2017.utils.getInputForDay fun main(args: Array<String>) { val formattedInput = formatInput(getInputForDay(4)) val passphrases = Passphrases() println("Day 4:") println(" Part I: ${passphrases.countValid(formattedInput)}") println(" Part II: ${passphra...
0
Kotlin
0
3
1a087fa3dff79f7da293852a59b9a3daec38a6fb
1,311
aoc2017
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/CatAndMouse.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
5,228
kotlab
Apache License 2.0
Kotlin/problems/0015_koko_eating_bananas.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
//Problem Statement // Koko loves to eat bananas. // There are N piles of bananas, the i-th pile has piles[i] bananas. // The guards have gone and will come back in H hours. // // Koko can decide her bananas-per-hour eating speed of K. // Each hour, she chooses some pile of bananas, and eats K bananas from that pile. /...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,633
algorithms
MIT License
src/Day11.kt
mandoway
573,027,658
false
{"Kotlin": 22353}
import kotlin.properties.Delegates class Monkey(specification: List<String>) { private lateinit var items: MutableList<Int> private lateinit var operation: (old: Int) -> Int private var divisibleBy by Delegates.notNull<Int>() private var idIfTestIsTrue by Delegates.notNull<Int>() private var idIfTe...
0
Kotlin
0
0
0393a4a25ae4bbdb3a2e968e2b1a13795a31bfe2
3,221
advent-of-code-22
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2020/Day16.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2020 import arrow.core.extensions.list.foldable.exists import me.grison.aoc.* import java.lang.System.lineSeparator class Day16 : Day(16, 2020) { override fun title() = "Ticket Translation" override fun partOne(): Int { val validRanges = flattenedValidRanges() return ne...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
3,599
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/tools/graph/FloydWarshall.kt
wrabot
739,807,905
false
{"Kotlin": 19706}
package tools.graph class FloydWarshall(size: Int, weights: Map<Pair<Int, Int>, Double>) { val indices = 0 until size val dist = Array(size) { DoubleArray(size) { Double.POSITIVE_INFINITY } } val prev = Array(size) { Array<Int?>(size) { null } } override fun toString() = dist.toList().map { it.toList(...
0
Kotlin
0
0
fd2da26c0259349fbc9719e694d58549e7f040a0
1,125
competitive-tools
Apache License 2.0
src/Day06.kt
melo0187
576,962,981
false
{"Kotlin": 15984}
fun main() { fun String.charsToProcessUntilFirstMarkerDetected(markerSize: Int): Int = toCharArray() .toList() .windowed(markerSize) .indexOfFirst { markerSizedCharSequence -> markerSizedCharSequence.distinct().size == markerSize } + markerSize...
0
Kotlin
0
0
97d47b84e5a2f97304a078c3ab76bea6672691c5
945
kotlin-aoc-2022
Apache License 2.0
src/main/kotlin/com/leetcode/P79.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://github.com/antop-dev/algorithm/issues/316 class P79 { fun exist(board: Array<CharArray>, word: String): Boolean { for (i in board.indices) { for (j in board[i].indices) { if (dfs(board, i, j, word, 0)) { return true ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,272
algorithm
MIT License
kotlin/rail-fence-cipher/src/main/kotlin/RailFenceCipher.kt
fredyw
523,079,058
false
null
class RailFenceCipher(private val n: Int) { fun getEncryptedData(input: String): String { val matrix = Array(n) { Array(input.length) { '.' } } val zigZag = zigZag(n, input.length) input.toList().zip(zigZag).forEach { (char, rowCol) -> val (row, col) = rowCol matrix[r...
0
Kotlin
0
0
101a0c849678ebb7d2e15b896cfd9e5d82c56275
1,714
exercism
MIT License
src/Day01.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
fun main() { fun part1(input: List<String>): Int { var result = 0 var current = 0 input.map { if (it.isEmpty()) null else it.toInt() }.forEach { if (it == null) { result = maxOf(result, current) ...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
1,191
AdventOfCode
Apache License 2.0
src/Day10.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private fun part1(input: List<String>): Int { var x = 1 var currentCycle = 0 val measureCycle = ArrayDeque(listOf(20, 60, 100, 140, 180, 220)) var signalStrength = 0 for (line in input) { val instruction = line.split(" ") when (instruction[0]) { "noop" -> currentCycle++...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
1,991
advent-of-code-2022
Apache License 2.0
src/Day06.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
fun main() { fun part1(input: String): Int { input.forEachIndexed { index, _ -> if (index > 3) { val letterList = listOf(input[index-3], input[index-2], input[index-1], input[index]) if (letterList.groupingBy { it }.eachCount().filter { it.value > 1 }.isEmpty()) ...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
1,092
advent-of-code
Apache License 2.0
Kotlin/EdmundKarp.kt
lprimeroo
41,106,663
false
null
import java.util.* import java.io.* class EdmundKarp { private val MAX_V = 40 // enough for sample graph in Figure 4.24/4.25/4.26 private val INF = 1000000000 // we need these global variables private val res = arrayOfNulls<IntArray>(MAX_V) // define MAX_V appropriately private var mf: Int = 0 ...
56
C++
186
99
16367eb9796b6d4681c5ddf45248e2bcda72de80
2,970
DSA
MIT License
src/2021/Day16_1.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File import kotlin.math.min val hexMap = mapOf( '0' to "0000", '1' to "0001", '2' to "0010", '3' to "0011", '4' to "0100", '5' to "0101", '6' to "0110", '7' to "0111", '8' to "1000", '9' to "1001", 'A' to "1010", 'B' to "1011", 'C' to "1100", 'D' t...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
2,927
adventofcode
MIT License
src/day03/Day03_Part1.kt
m-jaekel
570,582,194
false
{"Kotlin": 13764}
package day03 import readInput fun main() { fun part1(input: List<String>): Int { val incorrectItems = input.map { getIncorrectItem(it) } return calculatePriorityScore(incorrectItems) } val testInput = readInput("day03/test_input") check(part1(testInput) == 157) ...
0
Kotlin
0
1
07e015c2680b5623a16121e5314017ddcb40c06c
1,287
AOC-2022
Apache License 2.0
2020/kotlin/src/main/kotlin/io/franmosteiro/aoc2020/Day09.kt
franmosteiro
433,734,642
false
{"Kotlin": 27170, "Ruby": 16611, "Shell": 389}
package io.franmosteiro.aoc2020 /** * Advent of Code 2020 - Day 9: Encoding Error - * Problem Description: http://adventofcode.com/2020/day/9 */ class Day09(input: List<String>) { private val seriesOfNumbers = input.map{ it.toLong() } private var invalidNumber = -1 private val requiredSum: Long = 13984...
0
Kotlin
0
0
dad555d9cd0c3060c4b1353c7c6f170aa340c285
1,451
advent-of-code
MIT License
src/main/kotlin/leetcode/uber/NumberofIslandsII.kt
Magdi
390,731,717
false
null
package leetcode.uber class NumberofIslandsII { private val di = listOf(1, -1, 0, 0) private val dj = listOf(0, 0, -1, 1) // o ( k * lon ( n*m ) ) fun numIslands2(m: Int, n: Int, positions: Array<IntArray>): List<Int> { val unionFind = UnionFind() val grid = MutableList(m) { MutableLis...
0
Kotlin
0
0
63bc711dc8756735f210a71454144dd033e8927d
2,031
ProblemSolving
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2020/Day12.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 12 - Rain Risk * Problem Description: http://adventofcode.com/2020/day/12 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day12/ */ package com.ginsberg.advent2020 class Day12(private val input: List<String>) { f...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
3,161
advent-2020-kotlin
Apache License 2.0
src/Day07.kt
paulbonugli
574,065,510
false
{"Kotlin": 13681}
fun main() { val inputLines = readInput("Day07") val root = ElfDir("/") // keep track of where we are with traversal val traversalPath = ArrayDeque<ElfDir>() inputLines.forEach { line -> if(line.startsWith("$")) { if(line != "$ ls") { val (name) = "\\$ cd (/|[a...
0
Kotlin
0
0
d2d7952c75001632da6fd95b8463a1d8e5c34880
2,829
aoc-2022-kotlin
Apache License 2.0
src/day01/Day01.kt
TimberBro
567,240,136
false
{"Kotlin": 11186}
package day01 import utils.readInput fun main() { fun part1(input: List<String>, desiredSum: Int): Int { val foundNumbers = HashSet<Int>() for (number in input) { val currentNumber = number.toInt() val numberToFind = desiredSum - currentNumber if (foundNumbers....
0
Kotlin
0
0
1959383d2f422cc565560eefb1ed4f05bb87a386
1,593
aoc2020
Apache License 2.0
src/day15/Code.kt
fcolasuonno
221,697,249
false
null
package day15 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2(parsed)}") } dat...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
1,148
AOC2016
MIT License
day06/src/main/kotlin/Main.kt
ickybodclay
159,694,344
false
null
import java.io.File import java.util.* import kotlin.math.abs import kotlin.math.tan data class Point(val x: Int, val y: Int) fun main() { val input = File(ClassLoader.getSystemResource("input.txt").file) // Write solution here! val points = ArrayList<Point>() input.readLines().map { line -> ...
0
Kotlin
0
0
9a055c79d261235cec3093f19f6828997b7a5fba
1,777
aoc2018
Apache License 2.0
2023/day04-25/src/main/kotlin/Day10.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import java.util.LinkedList import java.util.Queue class Day10 { fun solve1() { val grid = File("inputs/10.txt").inputStream().bufferedReader().lineSequence().map { it.toMutableList() } .toMutableList() var start = Pair(0, 0) grid.forEachIndexed { i, line ->...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
4,691
AdventOfCode
MIT License
_7Function/src/main/kotlin/practice/81 Letter Grade Printout.kt
Meus-Livros-Lidos
690,208,771
false
{"Kotlin": 166470}
package practice /** * Let's write a method to print a set of letter grades based on numeric scores. Create a method named printLetterGrades that accepts a DoubleArray. * If the array is empty, don't print anything. * * Otherwise, for each value in the array, print a line to the console in the following format: *...
0
Kotlin
0
1
2d05e5528b9dd2cf9ed8799bce47444246be6b42
2,575
LearnCsOnline-Kotlin
MIT License
src/main/kotlin/dev/bogwalk/batch6/Problem61.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch6 import kotlin.math.floor import kotlin.math.sqrt import dev.bogwalk.util.maths.isHexagonalNumber import dev.bogwalk.util.maths.isTriangularNumber import dev.bogwalk.util.maths.isPentagonalNumber /** * Problem 61: Cyclical Figurate Numbers * * https://projecteuler.net/problem=61 * * Goa...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
7,332
project-euler-kotlin
MIT License
src/net/sheltem/aoc/y2022/Day14.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 suspend fun main() { Day14().run() } class Day14 : Day<Int>(24, 93) { override suspend fun part1(input: List<String>): Int = input.toCave().countMaxSandDrops() override suspend fun part2(input: List<String>): Int = input.toCave().addFloor().countMaxSandDrops() } private ...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,012
aoc
Apache License 2.0
src/aoc2022/Day12.kt
FluxCapacitor2
573,641,929
false
{"Kotlin": 56956}
package aoc2022 import Day object Day12 : Day(2022, 12) { private const val printGrids = false // Set to true for a visualization of the final paths. override fun part1() { val grid = lines.map { it.split("").filter { line -> line.isNotBlank() } }.filter { it.isNotEmpty() } val start = findG...
0
Kotlin
0
0
a48d13763db7684ee9f9129ee84cb2f2f02a6ce4
4,482
advent-of-code-2022
Apache License 2.0