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/dev/shtanko/algorithms/leetcode/MaxProductOfTwoElementsInArray.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
2,002
kotlab
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day11/Day11.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day11 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.pairs import net.olegg.aoc.year2023.DayOf2023 /** * See [Year 2023, Day 11](https://adventofcode.com/2023/day/11) */ object Day11 : DayOf2023(11) { override fun first(): Any? { ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,328
adventofcode
MIT License
src/Day04.kt
KorneliuszBarwinski
572,677,168
false
{"Kotlin": 6042}
fun main() { fun calculateRanges(input: String) = input.split("\r\n").map { element -> element.split(",").map { pairs -> val (first, second) = pairs.split("-").map { it.toInt() } first..second } } fun part1(input: String): Int = calculateRanges(input).count ...
0
Kotlin
0
0
d90175134e0c6482986fcf3c144282f189abc875
865
AoC_2022
Apache License 2.0
src/Day05.kt
Advice-Dog
436,116,275
true
{"Kotlin": 25836}
import kotlin.math.abs fun main() { fun part1(input: List<String>, print: Boolean = false): Int { val map = input.flatMap { it.toPointsList(skipDiagonal = true) } val group = map.groupBy { it }.map { it.key to it.value.size } var find = map.filter { it.x == 466 && it...
0
Kotlin
0
0
2a2a4767e7f0976dba548d039be148074dce85ce
7,226
advent-of-code-kotlin-template
Apache License 2.0
src/Day03.kt
adamgaafar
572,629,287
false
{"Kotlin": 12429}
fun main() { var scoreMap = mapOf<Char,Int>( 'a' to 1, 'b' to 2, 'c' to 3, 'd' to 4, 'e' to 5, 'f' to 6, 'g' to 7, 'h' to 8, 'i' to 9, 'j' to 10, 'k' to 11, 'l' to 12, 'm' to 13, 'n' to 14, 'o' t...
0
Kotlin
0
0
5c7c9a2e819618b7f87c5d2c7bb6e6ce415ee41e
3,944
AOCK
Apache License 2.0
src/main/kotlin/Day20.kt
todynskyi
573,152,718
false
{"Kotlin": 47697}
fun main() { val positions = listOf(1000, 2000, 3000) fun decrypt(input: List<Int>, key: Long = 1, times: Int = 1): Long { val (initialPositions, encryptedData) = input.mapIndexed { index, i -> index to i * key } .let { it to it.toMutableList() } repeat(times) { initia...
0
Kotlin
0
0
5f9d9037544e0ac4d5f900f57458cc4155488f2a
1,161
KotlinAdventOfCode2022
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day02/Day02.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day02 import eu.janvdb.aocutil.kotlin.readLines const val FILENAME = "input02.txt" fun main() { runPart(Position1(0, 0)) runPart(Position2(0, 0, 0)) } private fun <T : Position<T>> runPart(start: T) { val result = readLines(2021, FILENAME) .map { Instruction.parse(it) } .fold(start)...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,869
advent-of-code
Apache License 2.0
app/src/main/kotlin/day21/Day21.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day21 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 21 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay21Part1, ::solveDay21Part2) } fun solveDay21Part1(input: List<String>): Long ...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
3,079
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day18.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
import java.util.* const val X_SIZE = 340 const val Y_SIZE = 270 fun day18 (lines: List<String>) { val instructions = parseDigInstructions(lines) val trenchMap: Array<Array<Char>> = Array(Y_SIZE) { Array(X_SIZE) {'.'} } digTrench(instructions, trenchMap) bfs(trenchMap) val trenchSiz...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
2,308
advent_of_code_2023
MIT License
advent-of-code-2021/src/code/day15/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day15 import code.common.twoDimIterate import java.io.File fun main() { doIt("Day 15 Part 1: Test Input", "src/code/day15/test.input", part1) doIt("Day 15 Part 1: Real Input", "src/code/day15/part1.input", part1) doIt("Day 15 Part 2: Test Input", "src/code/day15/test.input", part2) doIt("...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
4,709
misc-dev
MIT License
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day14/Day14Puzzle2.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day14 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver class Day14Puzzle2 : PuzzleSolver { override fun solve(inputLines: Sequence<String>) = highestMinusLowestQuantity(inputLines.toList()).toString() private fun highestMinusLowestQuan...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
1,655
AdventOfCode2021
Apache License 2.0
src/main/kotlin/aoc2021/day13/Foldception.kt
arnab
75,525,311
false
null
package aoc2021.day13 object Foldception { data class Loc(val x: Int, val y: Int) enum class FoldDirection() { X, Y, } data class Fold(val dir: FoldDirection, val amount: Int) fun parse(data: String): Pair<Set<Loc>, List<Fold>> { val (locationLines, foldLines) = data.split("\n\n").take(2) ...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,508
adventofcode
MIT License
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day15.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day import java.util.* class Day15 : Day("748", "3045") { private data class Node( val x: Int, val y: Int, val riskLevel: Int, val neighbors: MutableList<Node> = mutableListOf() ) { override fun equals(other: Any?): Boolean { ...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
3,638
advent-of-code-2021
MIT License
calendar/day16/Day16.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day16 import Day import Lines import tools.* import kotlin.math.min class Day16 : Day() { override fun part1(input: Lines): Any { val tunnelMap = parseMap(input) val openableValves = tunnelMap.values.filter { it.flowRate > 0 } val reducedTunnelMap = reduceMap(map = tunnelMap, toNo...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
6,824
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day07/Day07.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day07 import common.InputRepo import common.readSessionCookie import common.solve import util.selectRecursive import util.splitIntoPair fun main(args: Array<String>) { val day = 7 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay07Part1, ::solveDay07Part2...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
2,825
AdventOfCode2022
Apache License 2.0
src/main/kotlin/de/huddeldaddel/euler/Problem387.kt
huddeldaddel
171,357,298
false
null
package de.huddeldaddel.euler import de.huddeldaddel.euler.extensions.isPrime import de.huddeldaddel.euler.extensions.sumOfDigits import java.math.BigInteger import kotlin.system.measureTimeMillis /** * Solution for https://projecteuler.net/problem=387 */ class Problem387(private val upperBorder: BigInteger) { ...
0
Kotlin
1
0
df514adde8c62481d59e78a44060dc80703b8f9f
1,518
euler
MIT License
src/Day07.kt
karlwalsh
573,854,263
false
{"Kotlin": 32685}
fun main() { fun part1(input: List<String>): Long = input.toFileSystem() .allSubDirectories() .map { it.size() } .filter { it <= 100000 } .sum() fun part2(input: List<String>): Long { val fileSystem = input.toFileSystem() val totalDiskSize = 70_000_000 v...
0
Kotlin
0
0
f5ff9432f1908575cd23df192a7cb1afdd507cee
3,604
advent-of-code-2022
Apache License 2.0
src/day10/solution.kt
bohdandan
729,357,703
false
{"Kotlin": 80367}
package day10 import println import readInput import java.lang.Exception enum class Directions(val vector: Position) { UP(Position(-1, 0)), DOWN(Position(1, 0)), LEFT(Position(0, -1)), RIGHT(Position(0, 1)); } class Route(val from: Directions, val to: Directions, val region1: List<Directions>, val re...
0
Kotlin
0
0
92735c19035b87af79aba57ce5fae5d96dde3788
9,175
advent-of-code-2023
Apache License 2.0
src/main/kotlin/org/cafejojo/schaapi/miningpipeline/patterndetector/spam/Spam.kt
cafejojo
138,387,851
false
{"Kotlin": 7207}
package org.cafejojo.schaapi.miningpipeline.patterndetector.spam import org.cafejojo.schaapi.models.CustomEqualsHashSet import org.cafejojo.schaapi.models.GeneralizedNodeComparator import org.cafejojo.schaapi.models.Node import org.cafejojo.schaapi.models.NodeSequenceUtil /** * Finds frequent sequences of [Node]s in...
0
Kotlin
0
0
6e19a84cc67ed55a26aee30cf05aa75cfeb42592
2,845
spam-pattern-detector
MIT License
kotlin/src/2022/Day09_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.abs import kotlin.math.max private fun sign(a: Int, b: Int) = if (b > a) 1 else -1 private fun newPos(head: Pair<Int, Int>, tail: Pair<Int, Int>): Pair<Int, Int> { val (tx, ty) = tail val (xDiff, yDiff) = abs(head.first - tx) to abs(head.second - ty) if (max(xDiff, yDiff) <= 1) return t...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
1,644
adventofcode
Apache License 2.0
src/main/kotlin/days/Day02.kt
irmakcelebi
573,174,392
false
{"Kotlin": 6258}
import java.lang.Exception fun main() { val day = Day02() day.run() day.test1(15) day.test2(12) } class Day02: Day() { override fun solve1(lines: List<String>): Int = lines .map { it.split(" ") } .sumOf { (x,y) -> val me = Hand.fromCharacter(...
0
Kotlin
0
0
fe20c7fd574c505423a9d9be449a42427775ec76
1,835
AdventOfCode2022
Apache License 2.0
src/main/kotlin/leetcode/Problem1462.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/course-schedule-iv/ */ class Problem1462 { fun checkIfPrerequisite(numCourses: Int, prerequisites: Array<IntArray>, queries: Array<IntArray>): List<Boolean> { val adjList = buildAdjList(prerequisites) val dependencyM...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,562
leetcode
MIT License
day16.kt
anurudhp
433,699,953
false
{"Haskell": 8155, "PureScript": 7026, "Coq": 5078, "Rust": 4302, "Makefile": 2844, "Kotlin": 2509, "C#": 2506, "F#": 2402, "JavaScript": 2333, "Lean": 2085, "Pascal": 2028, "Zig": 2014, "C++": 1940, "Julia": 1558, "Java": 1384, "Scala": 1247, "MATLAB": 1227, "PHP": 1224, "D": 1193, "Clojure": 1101, "Go": 1075, "Brainfu...
package quick.start enum class Op(val i: Int) { Sum(0), Prod(1), Min(2), Max(3), Lit(4), Gt(5), Lt(6), Eq(7); companion object { fun fromInt(i: Int) = Op.values().first { it.i == i } } } class Packet(version: Int, op: Op, lit: Long, children: List<Packet>) { val version = version val op = ...
0
Haskell
0
2
ed497f854bbc57680126b5ef70e4cff6707a98e8
2,509
aoc2021
MIT License
src/Day02.kt
arnoutvw
572,860,930
false
{"Kotlin": 33036}
import java.lang.IllegalArgumentException fun main() { fun part1(input: List<String>): Int { var score = 0 input.forEach { val split = it.split(" ") val oppenent = Hand.getHand(split.get(0)) val own = Hand.getHand(split.get(1)) score += own.waarde + ...
0
Kotlin
0
0
0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4
2,408
aoc-2022-in-kotlin
Apache License 2.0
src/Day05.kt
KliminV
573,758,839
false
{"Kotlin": 19586}
import kotlin.collections.ArrayList fun main() { fun part1(input: String): String { val parsedSplit = input.split("\n") val splitIndex = parsedSplit.indexOfFirst(String::isBlank) val map = parsedSplit.filterIndexed { index, _ -> index < splitIndex }.toList() val steps = parsedSplit....
0
Kotlin
0
0
542991741cf37481515900894480304d52a989ae
4,329
AOC-2022-in-kotlin
Apache License 2.0
src/main/kotlin/days/Day7.kt
nuudles
316,314,995
false
null
package days class Day7 : Day(7) { data class Rule( val container: String, val contains: List<Pair<String, Int>> ) fun parseRules(): List<Rule> = inputList .map { line -> line .split("contain") .let { components ->...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
2,340
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/Day05.kt
dominiquejb
572,656,769
false
{"Kotlin": 10603}
fun main() { fun unpackLetter(boxedLetter: String): String { return boxedLetter.trim().removePrefix("[").removeSuffix("]") } fun part1(input: String): String { val (stacksSection, movesSection) = input.split("\n\n") // Part 1 - Parse stacks val stacksLines = stacks...
0
Kotlin
0
0
f4f75f9fc0b5c6c81759357e9dcccb8759486f3a
3,568
advent-of-code-2022
Apache License 2.0
src/day10/Day10.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day10 import readInput private const val DAY_ID = "10" fun main() { fun solve(input: List<String>, onCycle: (cycle: Int, x: Int) -> Boolean) { var x = 1 var cycle = 1 for (line in input) { // noop var delta = 0 var cycleToComplete = 1 ...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
2,334
aoc-2022-in-kotlin
Apache License 2.0
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day07/Day07.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day07 import nerok.aoc.utils.Input import kotlin.math.abs import kotlin.math.nextDown import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun calculateFuelCosts(positions: MutableList<Long>, selectedPosition: Long): Long { var cost = 0L positions.f...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
1,545
AOC
Apache License 2.0
src/main/kotlin/day7/Aoc.kt
widarlein
225,589,345
false
null
package day7 fun main(args: Array<String>) { if (args.size < 1) { println("Must provide input program") System.exit(0) } val inputProgram = args[0].split(",").map { it.toInt() }.toIntArray() val highestOutput = bruteForceThrusters(inputProgram) println("Highest part 1 output found...
0
Kotlin
0
0
b4977e4a97ad61177977b8eeb1dcf298067e8ab4
8,554
AdventOfCode2019
MIT License
2017/src/main/java/p10/Problem10.kt
ununhexium
113,359,669
false
null
package p10 import com.google.common.collect.Lists import more.CircularList import more.formattedHexadecimal class Assembly(val lengths: List<Int>, val chainLength: Int, val rounds: Int) val inputs = listOf( Assembly(listOf(3, 4, 1, 5), 5, 1), Assembly( listOf( 102, 255, ...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
1,663
adventofcode
The Unlicense
src/Day01.kt
xuejingao
573,076,407
false
null
import java.util.Collections import java.util.PriorityQueue import kotlin.math.max fun main() { fun part1(input: List<String>): Int { var mostCalories = 0 var currentCount = 0 for (calorie in input) { currentCount = if (calorie.isBlank()) 0 else currentCount + calorie.toInt() ...
0
Kotlin
0
0
e438c3527ff7c69c13985dcd7c55145336d4f9ca
1,265
aoc-kotlin-2022
Apache License 2.0
app/src/main/java/org/simple/clinic/patient/filter/SortByWeightedNameParts.kt
eco4ndly
244,967,563
true
{"Kotlin": 3192656, "Java": 8206, "Shell": 2340}
package org.simple.clinic.patient.filter import kotlin.math.max /** * This is a comparator that is used to sort [PatientSearchContext] objects by prioritizing matches * which have the same number of words as the search term while still providing good * results when the search term and the name do not have the same...
0
null
1
1
c0bb3139dada4f34206928ec81f1e5f6f056134b
2,126
simple-android
MIT License
src/Day06.kt
bananer
434,885,332
false
{"Kotlin": 36979}
fun main() { fun fishGrowth(input: List<String>, days: Int): Long { var state = mutableMapOf<Int, Long>() (0..8).forEach { state[it] = 0 } input[0].split(",") .map { it.toInt() } .forEach { state.compute(it) { _, count -> count!! + 1 } } ...
0
Kotlin
0
0
98f7d6b3dd9eefebef5fa3179ca331fef5ed975b
1,197
advent-of-code-2021
Apache License 2.0
src/com/kingsleyadio/adventofcode/y2023/Day01.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2023 import com.kingsleyadio.adventofcode.util.readInput fun main() { part1() part2() } private fun part1() { var sum = 0 readInput(2023, 1).forEachLine { line -> val first = line.first { it.isDigit() }.digitToInt() val last = line.last { it.isDi...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,131
adventofcode
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day15.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.math.abs import kotlin.math.max import kotlin.math.min import kotlin.test.assertEquals object Day15 : AbstractDay() { @Test fun part1Test() { assertEquals(26, compute1(testInput, 10)) } ...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
3,768
aoc
Apache License 2.0
src/main/kotlin/leetcode/kotlin/dp/63. Unique Paths II.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.dp fun main() { println( uniquePathsWithObstacles2( arrayOf( intArrayOf(0, 0, 0), intArrayOf(0, 1, 0), intArrayOf(0, 0, 0) ) ) ) } /** * dp, top-down * f(r,c) = f(r,c-1) + f(r-1, c) * f(r,c) = no...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
1,450
kotlinmaster
Apache License 2.0
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day13.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day class Day13 : Day("765", "RZKZLPGH") { private data class Dot(val x: Int, val y: Int) private enum class FoldDirection { UP, LEFT } private data class Fold(val direction: FoldDirection, val location: Int) private val dots = input .split("\n\n")[0] ...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
2,063
advent-of-code-2021
MIT License
day01.kt
kannix68
430,389,568
false
{"Jupyter Notebook": 82946, "Python": 17016, "Kotlin": 1365}
/** * Advent of Code 2021 Day 1 solution. * This is currently a fairly minimalistic code. */ import java.io.File val testin = """ 199 200 208 210 200 207 240 269 260 263 """.trimIndent() /** * Get diff of List "as series", first element will be null. */ private fun diff(ints: List<Int>): List<Int?> { val di...
0
Jupyter Notebook
0
0
fc9889457caaa2c3d1a7b32f5a6f69cc70293adb
1,365
advent_of_code_2021
MIT License
2022/src/Day15.kt
Saydemr
573,086,273
false
{"Kotlin": 35583, "Python": 3913}
package src import kotlin.math.abs val manhattanDistance = { x1 :Long, y1: Long, x2: Long, y2: Long -> abs(x1 - x2) + abs(y1 - y2) } fun main() { val row = 2_000_000L val banned = mutableSetOf<Pair<Long,Long>>() val beacons = mutableSetOf<Pair<Long,Long>>() val sensorBeaconList = readInput("in...
0
Kotlin
0
1
25b287d90d70951093391e7dcd148ab5174a6fbc
4,585
AoC
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day13/Day13.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day13 import com.jacobhyphenated.advent2023.Day import kotlin.math.min /** * Day 13: Point of Incidence * * The puzzle input is a grid of rocks and empty spaces. * But a mirror reflects the rocks. The reelection point can be * along a row or a column. If the reflection goes...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
3,521
advent2023
The Unlicense
src/main/kotlin/day10.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day10 import aoc.utils.* fun part1(): Int { val valueByCycle = valuesByCycle("day10-input.txt") return (20..220).step(40) .map { valueByCycle[it - 1] } .sumOf { value -> value.first * value.second } } fun part2(): String { val valuesByCycle = valuesByCycle("day10-input.txt") ...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
1,074
adventOfCode2022
Apache License 2.0
2021/src/day04/day04.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day04 import java.io.File fun main() { val input = File("src/day04","/day4input.txt").bufferedReader() // Numbers val numbers: List<Int> = input.readLine().split(",").map {it.toInt()} input.readLine() // Now get the boards var boards: List<BingoBoard> = input.readLines() .wind...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,294
adventofcode
Apache License 2.0
src/main/kotlin/org/example/adventofcode/puzzle/Day02.kt
wcchristian
712,668,434
false
{"Kotlin": 5484}
package org.example.adventofcode.puzzle import org.example.adventofcode.util.FileLoader object Day02 { /* ---------- PARTS ---------- */ fun part1(filePath: String): Int { val fileLines = FileLoader.loadFromFile<String>(filePath) return fileLines .map { parseGameFromString(it) } ...
0
Kotlin
0
0
8485b440dcd10b0399acbe9d6ae3ee9cf7f4d6ae
2,574
advent-of-code-2023
MIT License
howto-dapp/src/main/java/de/timolia/howto/rank/RankConversion.kt
TimoliaDE
579,343,701
false
{"Kotlin": 45480, "Dockerfile": 956}
package de.timolia.howto.rank import java.util.* import java.util.function.Function import java.util.stream.Collectors object RankConversion { fun getRank(text: String): Rank? { return Arrays.stream(Rank.values()) .collect(Collectors.toMap(Function.identity()) { rank -> getSimilarity(text,...
3
Kotlin
7
0
212eadc654159f6001c01ac2e1669346af9e86b2
2,187
HowTo
MIT License
leetcode/regular-expression-matching/main.kt
seirion
17,619,607
false
{"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294}
// https://leetcode.com/problems/regular-expression-matching class Solution { fun isMatch(s: String, p: String): Boolean { return isMatch(s, 0, p, 0) } private fun isMatch(s: String, sIndex: Int, p: String, pIndex: Int): Boolean { if (s.length == sIndex && p.length == pIndex) return true ...
0
C++
4
4
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
1,544
code
Apache License 2.0
2016/main/day_04/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_04_2016 import java.io.File fun part1(input: List<String>) { input.stream().mapToInt { val chars = it.substringBeforeLast("[") .split("-") .dropLast(1) .joinToString("") val sectorId = it.substringBeforeLast("[") .split("-") ....
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
2,484
AdventofCode
MIT License
src/net/sheltem/aoc/y2023/Day21.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.PositionInt import net.sheltem.common.neighbours suspend fun main() { Day21().run() } class Day21 : Day<Long>(2665, 394693535848011) { override suspend fun part1(input: List<String>): Long = input.steps(64) override suspend fun part2(input: List<S...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,242
aoc
Apache License 2.0
src/main/aoc2015/Day19.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2015 import MutableMultiMap class Day19(input: List<String>) { private val molecule = parseMolecule(input.last()) private val replacements = parseReplacements(input) private fun parseReplacements(input: List<String>) = input.dropLast(2) .map { line -> line.split(" ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,457
aoc
MIT License
src/utils/GpsUtils.kt
Arch-vile
162,448,942
false
null
package utils import model.Location import model.Route import model.SLEIGHT_CAPACITY fun km(value: Int) = value * 1000 /** * Distance in meters */ fun distance(location1: Location, location2: Location): Double { val lat1 = location1.lat val lng1 = location1.lon val lat2 = location2.lat val lng2 = l...
0
Kotlin
0
0
03160a5ea318082a0995b08ba1f70b8101215ed7
3,271
santasLittleHelper
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions7.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round0.quickSort fun test7() { printlnResult(intArrayOf(-1, 0, 1, 2, -1, -4)) printlnResult(intArrayOf(-2, 0, -2, 1, -1, 2, 3, 4)) } /** * Questions 7: Find all the three numbers in an IntArray that theirs sum is 0. */ private fun IntAr...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,055
Algorithm
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day04.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day04(input: List<String>) { private val scratchcards = input.map { Scratchcard.parse(it) } private data class Scratchcard(val id: Int, val winningNumbers: Set<Int>, val numbersYouHave: Set<Int>) { val matchingNumbers get() = winningNumbers.intersect(numbersYouH...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
1,495
advent-2023
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[111]二叉树的最小深度.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import kotlin.math.min //给定一个二叉树,找出其最小深度。 // // 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 // // 说明:叶子节点是指没有子节点的节点。 // // // // 示例 1: // // //输入:root = [3,9,20,null,null,15,7] //输出:2 // // // 示例 2: // // //输入:root = [2,null,3,null,4,null,5,null,6] //输出:5 // // // // // 提示: // // // 树中节点数的范围在 [0, 105] 内 // -1000 <= Node...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,610
MyLeetCode
Apache License 2.0
src/questions/SearchInsertPosition.kt
realpacific
234,499,820
false
null
package questions import algorithmdesignmanualbook.print import kotlin.math.max import kotlin.test.assertEquals /** * Given a sorted array of distinct integers and a target value, * return the index if the target is found. If not, return the index where it would be if it were inserted in order. * You must write an...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,489
algorithms
MIT License
leetcode/src/stack/Q496.kt
zhangweizhe
387,808,774
false
null
package stack import java.util.* import kotlin.collections.HashMap fun main() { // 496. 下一个更大元素 I // https://leetcode-cn.com/problems/next-greater-element-i/ println(nextGreaterElement1(intArrayOf(2,4), intArrayOf(1,2,3,4)).contentToString()) } fun nextGreaterElement(nums1: IntArray, nums2: IntArray): I...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,506
kotlin-study
MIT License
src/main/kotlin/day10/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day10 import util.readTestInput open class Command(val endCycle: Int) data class Add(val amount: Int, val startCycle: Int): Command(startCycle + 1) data class Noop(val startCycle: Int): Command(startCycle) fun parseCommands(inputLines: List<String>): List<Command> { val commands = mutableListOf<Command>(...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
2,520
advent-of-code-2022
MIT License
src/main/kotlin/dev/bogwalk/batch1/Problem17.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch1 /** * Problem 17: Number to Words * * https://projecteuler.net/problem=17 * * Goal #1: Print the given number N as capitalised words (with/without "And"). * * Goal #2: Count the total number of letters used when the first N positive numbers are * converted to words, with "And" used i...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,610
project-euler-kotlin
MIT License
kotlin.kt
darian-catalin-cucer
598,116,321
false
null
import java.util.ArrayList import java.util.LinkedList class MaximumFlow { private var V = 0 private var adj = ArrayList<LinkedList<IntArray>>() private var level = IntArray(0) private fun addEdge(u: Int, v: Int, w: Int) { adj[u].add(intArrayOf(v, w)) adj[v].add(intArrayOf(u, 0)) } private fun b...
0
Kotlin
0
0
a8cfbcc5ee2d8fc6d03a7f3442a932b76eacb955
1,791
maximum-flow
MIT License
src/Day06.kt
daletools
573,114,602
false
{"Kotlin": 8945}
fun main() { fun part1(input: List<String>): Int { var score = 0 val code = mutableSetOf<Char>() for (index in input[0].indices) { if (code.contains(input[0][index])) { code.clear() code += input[0][index] } else { code...
0
Kotlin
0
0
c955c5d0b5e19746e12fa6a569eb2b6c3bc4b355
1,945
adventOfCode2022
Apache License 2.0
src/Day10.kt
Reivax47
437,028,926
false
{"Kotlin": 3090}
fun main() { fun part1(input: List<String>): Int { var response = 0 val addition = mapOf(")" to 3, "]" to 57, "}" to 1197, ">" to 25137) input.forEach { val retour = test_line(it) if (retour.first) { response += addition[retour.second] ?: 0 ...
0
Kotlin
0
0
891dff770f8c3cf545bad3d0bcc544daa73e70a5
1,295
AOC_2021_Day10
Apache License 2.0
facebook/y2023/qual/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2023.qual private fun solve(): Int { readInt() val a = readInts().sorted() if (a.size == 1) return 1 val inf = Int.MAX_VALUE val ans = listOf(a[0] + a.last(), a[0] + a[a.size - 2], a[1] + a.last()).minOf { sum -> val pool = a.groupBy {it}.mapValues { it.value.size }.toMutableMap() fun remove...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,075
competitions
The Unlicense
kotlin/1035-uncrossed-lines.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
/* * Top down DP with optimized space */ class Solution { fun maxUncrossedLines(nums1: IntArray, nums2: IntArray): Int { var prev = IntArray(nums2.size + 1) for (i in 0 until nums1.size) { val dp = IntArray(nums2.size + 1) for (j in 0 until nums2.size) { if ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,593
leetcode
MIT License
advent-of-code2016/src/main/kotlin/day03/Advent3-1.kt
REDNBLACK
128,669,137
false
null
package day03 import chunk import parseInput import splitToLines /** --- Day 3: Squares With Three Sides --- --- Part Two --- Now that you've helpfully marked up their design documents, it occurs to you that triangles are specified in groups of three vertically. Each set of three numbers in a column specifies a tri...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
1,553
courses
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day22.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.math.Point3D import java.util.* import kotlin.collections.ArrayDeque import kotlin.math.max import kotlin.math.min class Day22 : Day(22, 2023, "Sand Slabs") { data class Brick(val id: Int, var a: Poi...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
3,416
advent-of-code-2023
Apache License 2.0
Day7/src/IntState.kt
gautemo
225,219,298
false
null
import java.io.File fun main(){ val state = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText() val arr = toArr(state) println(maxThrust(arr, listOf(0,1,2,3,4))) println(maxThrust(arr, listOf(5,6,7,8,9))) } fun maxThrust(start: List<Int>, settings: List<Int>):...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
1,513
AdventOfCode2019
MIT License
src/algorithmsinanutshell/spatialtree/KnapSack01.kt
realpacific
234,499,820
false
null
package algorithmsinanutshell.spatialtree import utils.PrintUtils import kotlin.math.max import kotlin.test.assertTrue /** * Knapsack Problem: Given total capacity [totalCapacity] of a bag, * how can you select subset of items of weight [weights] with profit [profits] such that the profit is maximized? * * [Video...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,947
algorithms
MIT License
2020/src/year2021/day04/code.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2021.day04 import util.readAllLines private data class Node(val value: Int, var marked: Boolean = false) private class Board(values: List<String>) { private val nodes = mutableMapOf<Int, Node>() private val rows = mutableListOf<MutableList<Node>>().apply { repeat(5) { ...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
2,819
adventofcode
MIT License
src/main/kotlin/g1401_1500/s1453_maximum_number_of_darts_inside_of_a_circular_dartboard/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1453_maximum_number_of_darts_inside_of_a_circular_dartboard // #Hard #Array #Math #Geometry #2023_06_13_Time_211_ms_(100.00%)_Space_37.3_MB_(100.00%) class Solution { private class Angle(var a: Double, var enter: Boolean) : Comparable<Angle> { override fun compareTo(other: Angle): Int ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,230
LeetCode-in-Kotlin
MIT License
2020/day-01/day01.kts
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.io.File import java.util.stream.Collectors fun readFile(fileName: String): String = File(fileName).readText(Charsets.UTF_8) fun parseProblem(content: String): List<Int> { content.split("\n").stream().map { it.toInt() }.collect(Collectors.toList()) } fun solve(content: String): Int { val values =...
0
Ruby
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
1,732
adventofcode
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day14.kt
clechasseur
567,968,171
false
{"Kotlin": 493887}
package io.github.clechasseur.adventofcode.y2022 import io.github.clechasseur.adventofcode.util.Pt import io.github.clechasseur.adventofcode.y2022.data.Day14Data import kotlin.math.sign object Day14 { private val input = Day14Data.input fun part1(): Int = generateSequence(input.toCave(hasFloor = false)) { ...
0
Kotlin
0
0
7ead7db6491d6fba2479cd604f684f0f8c1e450f
1,970
adventofcode2022
MIT License
src/main/kotlin/day21/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day21 import util.readInput sealed class Monkey(open val name: String) { abstract fun result(): ULong abstract fun resultPart2(humnPath: Set<Monkey>, expectedResult: ULong): ULong companion object { fun parse(str: String) = when { NumberMonkey.matches(str) -> NumberMonkey.of(s...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
5,115
advent-of-code-2022
MIT License
src/Day10.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
fun main() { fun printToCrt(crt: String, cycle: Int, x: Int): String { var cycleCount = (cycle % 40) if (cycleCount == 0) cycleCount = 40 val output = if ((cycleCount - x) in listOf(0, 1, 2)) "#" else "." return crt + output } fun _process(input: List<String>): Pair<Int, St...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
1,850
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumSidewayJumps.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,501
kotlab
Apache License 2.0
src/leetcode_problems/medium/PairWithGivenDifference.kt
MhmoudAlim
451,633,139
false
{"Kotlin": 31257, "Java": 586}
package leetcode_problems.medium import java.lang.Exception import kotlin.math.abs /* https://www.geeksforgeeks.org/find-a-pair-with-the-given-difference/ Given an unsorted array and a number n, find if there exists a pair of elements in the array whose difference is n. Examples: -Input: arr[] = {5, 20, 3, 2, 50,...
0
Kotlin
0
0
31f0b84ebb6e3947e971285c8c641173c2a60b68
2,010
Coding-challanges
MIT License
src/Day04.kt
samframpton
572,917,565
false
{"Kotlin": 6980}
fun main() { fun part1(input: List<String>) = getSectionAssignments(input).count { (it.first.first <= it.second.first && it.first.last >= it.second.last) || (it.second.first <= it.first.first && it.second.last >= it.first.last) } fun part2(input: List<String>) = getSectionAssignment...
0
Kotlin
0
0
e7f5220b6bd6f3c5a54396fa95f199ff3a8a24be
798
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day12.kt
hughjdavey
159,955,618
false
null
package days import com.google.common.collect.EvictingQueue class Day12 : Day(12) { private val initialState = parseInitialState(inputList.first()) private val rules = parseRules(inputList.drop(2)) override fun partOne(): Any { val twentyGenerations = doGenerations(initialState, rules, 20) ...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
3,676
aoc-2018
Creative Commons Zero v1.0 Universal
src/day05/Day05.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day05 import readInput typealias Crate = Char val commandLineRegex = """move (\d+) from (\d+) to (\d+)""".toRegex() data class CraneCommand( val cratesCount: Int, val sourceStack: ArrayDeque<Crate>, val destinationStack: ArrayDeque<Crate> ) fun main() { fun parseInput(input: List<String>): ...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
3,260
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/kodeinc/conway/algorithm/CellMap.kt
evanjpw
124,837,562
false
null
package com.kodeinc.conway.algorithm private fun emptyMapFun(x: Int, y: Int, map: CellMap? = null) = DEAD_CELL internal enum class CellDirection { NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST; } data class Coord(val x: Int, val y: Int) class CellMap(val w: Int, val h: Int, oldMap: CellMa...
0
Kotlin
0
0
bdfbcaf46955da8770188627c9472b78da34cc07
2,133
conway
MIT License
src/main/kotlin/Day03.kt
nmx
572,850,616
false
{"Kotlin": 18806}
fun main(args: Array<String>) { fun findCommonElement(strings: List<String>): Char { val sets = strings.map { it.toSet() } val intersection = sets.reduce { acc, set -> acc.intersect(set) } if (intersection.size != 1) { throw RuntimeException("expected exactly one match, found ${i...
0
Kotlin
0
0
33da2136649d08c32728fa7583ecb82cb1a39049
1,610
aoc2022
MIT License
src/Day02.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
fun main() { val lost = 0 val draw = 3 val win = 6 val rock = 1 val paper = 2 val scissors = 3 val map = mapOf( "A X" to rock + draw, "A Y" to paper + win, "A Z" to scissors + lost, "B X" to rock + lost, "B Y" to paper + draw, "B Z" to scisso...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
1,110
AdventOfCode-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/KthSmallestPath.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
3,188
kotlab
Apache License 2.0
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/kotlin/wakicode.kt
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
import kotlin.math.pow import kotlin.math.sqrt /* * Escribe un programa que, dado un número, compruebe y muestre si es primo, fibonacci y par. * Ejemplos: * - Con el número 2, nos dirá: "2 es primo, fibonacci y es par" * - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar" */ fun main(args: Arra...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
993
retos-programacion-2023
Apache License 2.0
mps-analyser/src/main/kotlin/nl/dslconsultancy/mps/analyser/usageAnalysis.kt
dslmeinte
131,405,227
false
null
package nl.dslconsultancy.mps.analyser import nl.dslconsultancy.mps.analyser.util.CountingMap import nl.dslconsultancy.mps.analyser.util.asCsvRow import nl.dslconsultancy.mps.analyser.util.combine import nl.dslconsultancy.mps.analyser.util.csvRowOf import nl.dslconsultancy.mps.analyser.xml.* /* * CountingMap is keye...
2
JetBrains MPS
2
10
17b3014ebb78cb299844d8b8c284557f30ee211b
3,759
mps-open-source
MIT License
src/Day10.kt
papichulo
572,669,466
false
{"Kotlin": 16864}
import kotlin.math.absoluteValue fun main() { val taps = intArrayOf(20, 60, 100, 140, 180, 220) fun convertToIntList(input: List<String>): List<Int> { return buildList { add(1) // starts with 1 input.forEach { line -> add(0) if (line.startsWith("...
0
Kotlin
0
0
e277ee5bca823ce3693e88df0700c021e9081948
1,273
aoc-2022-in-kotlin
Apache License 2.0
marathons/icpcchallenge/y2020_huaweiGraphMining/practice/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package marathons.icpcchallenge.y2020_huaweiGraphMining.practice import java.io.* import kotlin.random.Random private fun solve(edges: List<List<Int>>): BooleanArray { val n = edges.flatten().maxOrNull()!! + 1 val nei = List(n) { mutableListOf<Int>() } for ((u, v) in edges) { nei[u].add(v); nei[v].add(u) } val r ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,675
competitions
The Unlicense
src/main/kotlin/d10/d10.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d10 import readInput fun part1(input: List<String>): Int { var X = 1 var cycle = 0 var sum = 0 var counted = 0 for (line in input) { if (cycle> counted && ((cycle-20) % 40) == 0) { sum += cycle * X println("Signal $cycle = ${cycle * X}" ) counte...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
1,768
aoc2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Day24.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days import days.Point.Companion.EAST import days.Point.Companion.NORTH import days.Point.Companion.SOUTH import days.Point.Companion.WEST import java.util.concurrent.ConcurrentHashMap @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2022/day/2", date = Date(day = 24, year = 2...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,562
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/Day22.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { fun part1(input: String): Long { val data = input.split("\n\n") val path = data[1] val lines = data[0].lines() val rows = lines.size val columns = lines.maxOf { it.length } val map = lines.map { it.toCharArray() + CharArray(columns - it.length) { ' ' }...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
2,210
aoc-2022-in-kotlin
Apache License 2.0
solutions/aockt/y2023/Y2023D08.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.math.lcm import aockt.util.parse import io.github.jadarma.aockt.core.Solution object Y2023D08 : Solution { /** * A node in the desert map. * @property id The ID of this node. * @property leftId The ID of the node reached if navigating leftward. * @p...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
4,061
advent-of-code-kotlin-solutions
The Unlicense
src/day16.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import kotlin.system.exitProcess private const val DAY = 16 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: String -> x.toList() } val input = loadInput(DAY, false...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
2,709
aoc2023
MIT License
src/Day05.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
fun main() { fun part1(input: List<String>): String { val stacks = mutableListOf<ArrayDeque<Char>>() var totalIndex = 0 run collectStack@{ input.toList().forEach { totalIndex++ var stackIndex = 0 it.chunked(4).forEach { stackInput ...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
3,704
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day3.kt
andilau
726,429,411
false
{"Kotlin": 37060}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2023/day/3", date = Date(day = 3, year = 2023) ) class Day3(private val schematic: List<String>) : Puzzle { private val numberRegex = """\d+""".toRegex() override fun partOne(): Int = schematic.flatMapIndex...
3
Kotlin
0
0
9a1f13a9815ab42d7fd1d9e6048085038d26da90
1,728
advent-of-code-2023
Creative Commons Zero v1.0 Universal
kotlin/src/com/s13g/aoc/aoc2021/Day3.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 import com.s13g.aoc.resultFrom /** * --- Day 3: Binary Diagnostic --- * https://adventofcode.com/2021/day/3 */ class Day3 : Solver { override fun solve(lines: List<String>): Result { val ge = lines[0].indices.map { i -> lines....
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,507
euler
Apache License 2.0
src/week2/PalindromicSubstrings.kt
anesabml
268,056,512
false
null
package week2 import kotlin.math.min import kotlin.system.measureNanoTime class PalindromicSubstrings { /** Center expanding * Iterate over all the palindromic centers and expand * Time complexity : O(n2) * Space complexity : O(1) */ fun countSubstrings(s: String): Int { val lengt...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
3,102
leetCode
Apache License 2.0
src/day18/Day18.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day18 import logEnabled import readInput private const val DAY_NUMBER = 18 data class Position3D(val x: Int, val y: Int, val z: Int) { val neighbours: Sequence<Position3D> get() { return sequenceOf( Position3D(x + 1, y, z), Position3D(x - 1, y, z), ...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
5,204
advent-of-code-2022
Apache License 2.0
src/Day20.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.abs import kotlin.math.sign private fun nums(): List<Long> = readInput("Day20").map { it.toLong() } private fun decrypt(nums: List<Long>, mult: Long = 1, times: Int = 1): Long { val n = nums.size val order = nums.mapIndexed { i, v -> V(v * mult, i) } val a = order.toMutableList() re...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,149
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/easy/MaxAscendingSum.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.easy import kotlin.math.max /** * 1800.最大升序子数组和 * * 给你一个正整数组成的数组 nums ,返回 nums 中一个 升序 子数组的最大可能元素和。 * * 子数组是数组中的一个连续数字序列。 * * 已知子数组 [numsl, numsl+1, ..., numsr-1, numsr] ,若对所有 i(l <= i < r),numsi < numsi+1 都成立,则称这一子数组为 升序 子数组。注意,大小为 1 的子数组也视作 升序 子数组。 * * 示例 1: * 输入:nums =...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,285
daily_algorithm
Apache License 2.0
kotlin/src/katas/kotlin/hackerrank/roads_and_libraries/RoadsAndLibraries.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.hackerrank.roads_and_libraries import katas.kotlin.hackerrank.OutputRecorder import katas.kotlin.hackerrank.toReadLineFunction import nonstdlib.printed import datsok.shouldEqual import nonstdlib.sumByLong import org.junit.Test import java.io.BufferedReader import java.io.File import java.io.InputS...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
7,148
katas
The Unlicense
src/Day06.kt
greeshmaramya
514,310,903
false
{"Kotlin": 8307}
fun main() { fun day06(data: List<String>) { var part1 = 0 var part2 = 0 val h = HashMap<Char, Int>() val ans = data.joinToString(",").split(",,").map { it.split(',') } ans.forEach { group -> if (group.size == 1) { part1 += group.first().length ...
0
Kotlin
0
0
9e1128ee084145f5a70fe3ad4e71b05944260d6e
1,665
aoc2020
Apache License 2.0
2021/src/Day11.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/11 fun main() { class Table(cols: Int, rows: Int, numbers: Array<Int>) { val cols = cols val rows = rows var numbers = numbers var fired = mutableSetOf<Int>() var toFire = mutableSetOf<Int>() fun step() : Int { // 1. Increment a...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
3,704
advent-of-code
Apache License 2.0