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
2023/day04-25/src/main/kotlin/Day18.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import kotlin.math.abs class Day18 { fun solve1() { val input = File("inputs/18.txt").inputStream().bufferedReader().lineSequence().toList().map { val split = it.split(' ') val direction = when (split[0][0]) { 'R' -> Direction.RIGHT ...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
3,679
AdventOfCode
MIT License
src/Day23.kt
weberchu
573,107,187
false
{"Kotlin": 91366}
private val northOffset = listOf( Pair(1, -1), Pair(0, -1), Pair(-1, -1), ) private val eastOffset = listOf( Pair(1, -1), Pair(1, 0), Pair(1, 1), ) private val southOffset = listOf( Pair(1, 1), Pair(0, 1), Pair(-1, 1), ) private val westOffset = listOf( Pair(-1, -1), Pair(...
0
Kotlin
0
0
903ff33037e8dd6dd5504638a281cb4813763873
3,755
advent-of-code-2022
Apache License 2.0
src/Day02.kt
lonskiTomasz
573,032,074
false
{"Kotlin": 22055}
fun main() { fun totalScoreOfGivenStrategy(input: List<String>): Int { /** * A for Rock, B for Paper, and C for Scissors * X for Rock, Y for Paper, and Z for Scissors * * 1 for Rock, 2 for Paper, and 3 for Scissors * 0 if you lost, 3 if the round was a draw, and ...
0
Kotlin
0
0
9e758788759515049df48fb4b0bced424fb87a30
2,134
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2020/ex8.kt
noamfree
433,962,392
false
{"Kotlin": 93533}
fun main() { val input = readInputFile("aoc2020/input8") val instructions = parseInput(input.lines()) //for (i in instructions.indices) { println("$327") val hackedInstrctions = hackInstruction(327, instructions) val lines = mutableListOf<Int>() val computer = Computer() ...
0
Kotlin
0
0
566cbb2ef2caaf77c349822f42153badc36565b7
2,040
AOC-2021
MIT License
src/main/kotlin/Day20.kt
clechasseur
267,632,210
false
null
import org.clechasseur.adventofcode2016.Day20Data import kotlin.math.max import kotlin.math.min object Day20 { private val input = Day20Data.input fun part1(): Long = mergeBlockList(getBlockList()).sortedBy { it.first }[0].last + 1L fun part2(): Long = 4294967296L - mergeBlockList(getBlockList()).map { i...
0
Kotlin
0
0
120795d90c47e80bfa2346bd6ab19ab6b7054167
1,670
adventofcode2016
MIT License
src/Day13.kt
Totwart123
573,119,178
false
null
fun main() { fun getList(input: Iterator<Char>): List<Any> { val output = mutableListOf<Any>() var lastOneWasDiget = false while (input.hasNext()){ val next = input.next() if(next == ']'){ break } if(next == ','){ ...
0
Kotlin
0
0
33e912156d3dd4244c0a3dc9c328c26f1455b6fb
3,576
AoC
Apache License 2.0
src/main/kotlin/Day5.kt
noamfreeman
572,834,940
false
{"Kotlin": 30332}
private val part1ExampleInput = """ [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 """.trimIndent() fun main() { println("day5") println() println("part1") assertEquals(part1(part1ExampleInput), "CMZ") println(part1(rea...
0
Kotlin
0
0
1751869e237afa3b8466b213dd095f051ac49bef
2,786
advent_of_code_2022
MIT License
simple-tic-tac-toe/Main.kt
aesdeef
437,311,579
false
{"Kotlin": 3274}
package tictactoe import kotlin.math.abs typealias Board = List<List<Char>> enum class GameState { IMPOSSIBLE, X_WINS, O_WINS, DRAW, NOT_FINISHED, } fun main() { val input = "_________" var board = input.chunked(3).map { it.toList() } printBoard(board) for (player in "XOXOXOXOX"...
0
Kotlin
0
0
1475a200591397ca3daebe1d66fae0fe0ed34d24
3,274
kotlin-basics-projects
MIT License
advent-of-code-2022/src/test/kotlin/Day 11 Monkey in the Middle Gold.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import `Day 11 Monkey in the Middle Gold`.RNS.Companion.toRNS import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test /** 15:15 */ class `Day 11 Monkey in the Middle Gold` { data class RNS(val primes: List<Int>, val values: List<Int>) { fun divisibleBy(testDivisible: Int): Boolean { val primeI...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
5,289
advent-of-code
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day14.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day14: AdventDay(2021, 14) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day14() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
1,962
adventofcode
MIT License
src/main/kotlin/year2023/Day18.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2023 import utils.Direction import utils.Point2D class Day18 { data class Move(val direction: Direction, val length: Int, val color: Int) fun part1(input: String): Long { val moves = parse(input) val positions = moves.runningFold(Point2D.ORIGIN) { point, move -> poi...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,992
aoc-2022
Apache License 2.0
src/Day06.kt
sebokopter
570,715,585
false
{"Kotlin": 38263}
fun main() { fun findFirstUniqueChars(input: String, uniqueChars: Int): Int { for (i in (uniqueChars-1)..input.lastIndex) { val lastFourChars = input.substring(i - (uniqueChars-1)..i) fun areUnique(lastFourChars: String) = lastFourChars.toSet().size == uniqueChars if (ar...
0
Kotlin
0
0
bb2b689f48063d7a1b6892fc1807587f7050b9db
1,104
advent-of-code-2022
Apache License 2.0
src/Day14.kt
stevennoto
573,247,572
false
{"Kotlin": 18058}
import kotlin.math.* fun main() { val GRID_SIZE_X = 700 val GRID_SIZE_Y = 170 val SAND_ORIGIN = Pair(500, 0) // Return list of all points along line between 2 coordinate points fun getAllPointsBetween(x:Pair<Int, Int>, y:Pair<Int, Int>): List<Pair<Int, Int>> { if (x.first == y.first) retur...
0
Kotlin
0
0
42941fc84d50b75f9e3952bb40d17d4145a3036b
3,487
adventofcode2022
Apache License 2.0
src/main/kotlin/asaad/DayFive.kt
Asaad27
573,138,684
false
{"Kotlin": 23483}
package asaad import java.io.File class DayFive(filePath: String) { private val file = File(filePath) private val input = readInput(file) private fun readInput(file: File): Pair<List<String>, List<String>> { val lines = file.readLines() return lines.takeWhile { it.isNotBlank() } to lines...
0
Kotlin
0
0
16f018731f39d1233ee22d3325c9933270d9976c
2,348
adventOfCode2022
MIT License
src/Day06.kt
lukewalker128
573,611,809
false
{"Kotlin": 14077}
fun main() { val testInput = readInput("Day06_test") checkEquals(7, part1(testInput)) checkEquals(19, part2(testInput)) val input = readInput("Day06") println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } /** * Returns the position of the first start-of-packet marker in the ...
0
Kotlin
0
0
c1aa17de335bd5c2f5f555ecbdf39874c1fb2854
1,645
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day22.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 22 - Mode Maze * * Problem Description: http://adventofcode.com/2018/day/22 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day22/ */ package com.ginsberg.advent2018 import java.util.PriorityQueue class Day22(rawIn...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
4,841
advent-2018-kotlin
MIT License
src/Day03.kt
imavroukakis
572,438,536
false
{"Kotlin": 12355}
fun main() { fun Char.priority() = if (this.isUpperCase()) { this.code - 38 } else { this.code - 96 } fun common(input: List<Set<Char>>) = input.reduce { acc, chars -> if (acc.isEmpty()) { chars } else { chars.intersect(acc) } }.fir...
0
Kotlin
0
0
bb823d49058aa175d1e0e136187b24ef0032edcb
836
advent-of-code-kotlin
Apache License 2.0
src/Day04.kt
RandomUserIK
572,624,698
false
{"Kotlin": 21278}
private fun String.toRanges(): Pair<IntRange, IntRange> = substringBefore(",").toRange() to substringAfter(",").toRange() private fun String.toRange(): IntRange = substringBefore("-").toInt()..substringAfter("-").toInt() private infix fun IntRange.containsAll(other: IntRange): Boolean = first <= other.first && last...
0
Kotlin
0
0
f22f10da922832d78dd444b5c9cc08fadc566b4b
945
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day02.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 2: Rock Paper Scissors * Problem Description: https://adventofcode.com/2022/day/2 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { fun part1(input: List<Pair<String, String>>): Int = ...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,759
AoC-2022
Apache License 2.0
src/main/kotlin/day16/part2/Part2.kt
bagguley
329,976,670
false
null
package day16.part2 import day16.data fun main() { val input = data val rules = input[0].split("\n").map { parseRule(it) } val myTicket = input[1].split("\n")[1].split(",").map { it.toInt() } val nearBy = input[2].split("\n").drop(1).map{it.split(",").map { it.toInt() }} val validTickets = nearB...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
1,149
adventofcode2020
MIT License
src/Day04.kt
vi-quang
573,647,667
false
{"Kotlin": 49703}
fun main() { class Elf(range: String) { val sectionIdList = mutableSetOf<Int>() init { add(range) } fun add(range: String) { val token = range.split("-") val (rangeMin, rangeMax) = token[0].toInt() to token[1].toInt() for (i in rangeM...
0
Kotlin
0
2
ae153c99b58ba3749f16b3fe53f06a4b557105d3
1,988
aoc-2022
Apache License 2.0
src/Day09.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
import kotlin.math.abs fun main() { fun parseMoves(input: List<String>): List<Pair<Char, Int>> { val headMoves = input.map { val pair = it.split(" ").take(2) Pair(pair[0][0], pair[1].toInt()) } return headMoves } fun getLocationsVisitedFromMoves(headMoves: L...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
4,812
aoc-2022-kotlin
Apache License 2.0
src/Day08.kt
konclave
573,548,763
false
{"Kotlin": 21601}
fun main() { fun solve1(trees: List<String>): Int { return trees.foldIndexed(0) { rowIdx, total, row -> if (rowIdx == 0 || rowIdx == trees.size - 1) { total + row.length } else { total + row.foldIndexed(0) { colIdx, countCol...
0
Kotlin
0
0
337f8d60ed00007d3ace046eaed407df828dfc22
4,243
advent-of-code-2022
Apache License 2.0
AdventOfCode/Challenge2023Day12.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import java.io.File import kotlin.test.Test import kotlin.test.assertEquals class Challenge2023Day12 { private fun solve1(lines: List<String>): Int { var result = 0 lines.forEach { line -> val (springRow, controlRow) = line.split(" ") val controlNumbers = controlRow.split("...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
2,567
KotlinCodeJourney
MIT License
year2020/src/main/kotlin/net/olegg/aoc/year2020/day17/Day17.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2020.day17 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector3D import net.olegg.aoc.utils.Vector4D import net.olegg.aoc.year2020.DayOf2020 /** * See [Year 2020, Day 17](https://adventofcode.com/2020/day/17) */ object Day17 : DayOf2020(17) { private val NEIGHBORS_3D =...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,320
adventofcode
MIT License
src/main/kotlin/net/wrony/aoc2023/a2/Main.kt
kopernic-pl
727,133,267
false
{"Kotlin": 52043}
package net.wrony.aoc2023.a2 import kotlin.io.path.Path import kotlin.io.path.readText data class Draw(val reds: Int, val greens: Int, val blues: Int) { constructor(): this(0,0,0) operator fun plus(other: Draw): Draw = Draw(reds + other.reds, greens + other.greens, blues + other.blues) fun power(...
0
Kotlin
0
0
1719de979ac3e8862264ac105eb038a51aa0ddfb
2,055
aoc-2023-kotlin
MIT License
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day09.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import at.mpichler.aoc.lib.Vector2i import kotlin.math.absoluteValue import kotlin.math.sign open class Part9A : PartSolution() { private lateinit var commands: MutableList<Command> internal latei...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,041
advent-of-code-kotlin
MIT License
Retos/Reto #28 - EXPRESIÓN MATEMÁTICA [Media]/kotlin/IsTheMartin.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": ...
/* * Crea una función que reciba una expresión matemática (String) * y compruebe si es correcta. Retornará true o false. * - Para que una expresión matemática sea correcta debe poseer * un número, una operación y otro número separados por espacios. * Tantos números y operaciones como queramos. * - Números pos...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
2,274
retos-programacion-2023
Apache License 2.0
src/Day07.kt
SergeiMikhailovskii
573,781,461
false
{"Kotlin": 32574}
val suitableDirs = mutableListOf<NodeWithSize>() var needSpace = 0 fun main() { val inputList = readInput("Day07_test").filter { it != "\$ ls" && it != "\$ cd /" } val root = Node("/") var currentDir: Node? = root inputList.forEach { if (it.contains("dir")) { val dirName = it.split...
0
Kotlin
0
0
c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d
1,912
advent-of-code-kotlin
Apache License 2.0
src/Day03.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
fun main() { fun part1(input: List<String>): Int { // val letterScoreMap = getMap() // var sum = 0 // input.forEach { // val firstCompartment = it.substring(0, (it.length/2)).toSet() // val secondCompartment = it.substring((it.length/2), it.length).toSet() // v...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
1,280
advent22
Apache License 2.0
src/Day13.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
class Node(var value: Int?, var isList: Boolean = false, val list: MutableList<Node> = mutableListOf()) { fun withWrapper(op: ((Node) -> (Int))): Int { if (isList) { throw Exception("Can't wrap a list node") } isList = true list.add(Node(value)) value = null val result = op(t...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
3,866
advent-of-code-2022
Apache License 2.0
src/main/Day02.kt
lifeofchrome
574,709,665
false
{"Kotlin": 19233}
package main import readInput fun main() { val input = readInput("Day02") val day2 = Day02(input) day2.process() print("Part 1: ${day2.part1()}\n") print("Part 2: ${day2.part2()}") } class Day02(private val input: List<String>) { private val rounds = mutableListOf<Pair<Shape, Shape>>() fun...
0
Kotlin
0
0
6c50ea2ed47ec6e4ff8f6f65690b261a37c00f1e
2,623
aoc2022
Apache License 2.0
src/main/java/com/booknara/problem/stack/LargestRectangleHistogramKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.stack /** * 84. Largest Rectangle in Histogram (Hard) * https://leetcode.com/problems/largest-rectangle-in-histogram/ */ class LargestRectangleHistogramKt { var totalMax = 0 // TLE error because of T:O(nlogn), S:O(logn) fun largestRectangleArea1(heights: IntArray): Int { // i...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,569
playground
MIT License
src/2023/Day05.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.lang.RuntimeException import java.util.* import kotlin.math.max import kotlin.math.min fun main() { Day05().solve() } class Day05 { val input1 = """ seeds: 79 14 55 13 seed-to-soil map: 50 98 2 52 50 48 soil-to-fertil...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
4,647
advent-of-code
Apache License 2.0
src/day18/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day18 import java.io.File import java.lang.IllegalStateException interface Element class RegularNumber(val value: Int) : Element object Open : Element object Close : Element fun main() { val elements = File("src/day18/input.txt").readLines().map { line -> line.toList().map { ch -> wh...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
3,102
advent-of-code-2021
MIT License
src/main/kotlin/week2/HillClimbing.kt
waikontse
572,850,856
false
{"Kotlin": 63258}
package week2 import shared.Algorithms.Companion.dijkstra import shared.Algorithms.Edge import shared.Algorithms.Graph import shared.Algorithms.GraphSize import shared.Node import shared.Puzzle class HillClimbing : Puzzle(12) { override fun solveFirstPart(): Any { val input = puzzleInput val clean...
0
Kotlin
0
0
860792f79b59aedda19fb0360f9ce05a076b61fe
3,798
aoc-2022-in-kotllin
Creative Commons Zero v1.0 Universal
src/Day01.kt
mvanderblom
573,009,984
false
{"Kotlin": 25405}
fun main() { val dayName = 1.toDayName() fun List<Int?>.total(): Int = this.filterNotNull().sum() fun getCaloriesPerElf(input: List<Int?>) = input .mapIndexedNotNull { index, calories -> when { (index == 0 || calories == null) -> index (i...
0
Kotlin
0
0
ba36f31112ba3b49a45e080dfd6d1d0a2e2cd690
1,207
advent-of-code-kotlin-2022
Apache License 2.0
aoc21/day_04/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File data class Num(val n: Int, var marked: Boolean) class Board(val nums: Array<Array<Num>>) { var won = false fun fullRow(i: Int): Boolean = nums[i].all { it.marked } fun fullCol(i: Int): Boolean = nums.all { it[i].marked } fun mark(n: Int) { nums.forEach { it.forEach { if (i...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,295
advent-of-code
MIT License
src/main/kotlin/Day4.kt
lanrete
244,431,253
false
null
object Day4 : Solver() { override val day: Int = 4 override val inputs: List<String> = getInput() private fun getRange(): IntRange { val (start, end) = inputs[0] .split('-') .map { it.toInt() } return (start..end) } private val range = getRange() privat...
0
Kotlin
0
1
15125c807abe53230e8d0f0b2ca0e98ea72eb8fd
1,651
AoC2019-Kotlin
MIT License
ceria/09/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; lateinit var heights: Array<IntArray> fun main(args : Array<String>) { val input = File(args.first()).readLines() heights = Array<IntArray>(input.size) { IntArray(input.first().length) {0} } var i = 0 for (line in input) { var row = heights[i] for (idx in line.indi...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
4,524
advent-of-code-2021
MIT License
src/main/kotlin/ru/timakden/aoc/year2022/Day20.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 20: Grove Positioning System](https://adventofcode.com/2022/day/20). */ object Day20 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year202...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
1,752
advent-of-code
MIT License
kool-core/src/commonMain/kotlin/de/fabmax/kool/math/Partition.kt
fabmax
81,503,047
false
{"Kotlin": 5023245, "HTML": 1464, "JavaScript": 597}
package de.fabmax.kool.math import kotlin.math.* fun <T> MutableList<T>.partition(k: Int, cmp: (T, T) -> Int) = partition(indices, k, cmp) fun <T> MutableList<T>.partition(rng: IntRange, k: Int, cmp: (T, T) -> Int) { partition(this, rng.first, rng.last, k, { get(it) }, cmp, { a, b -> this[a] = this[b].also { th...
12
Kotlin
14
234
85fe1de1d690d5571a2c33a5fd4cf7e23a645437
2,340
kool
Apache License 2.0
src/Day12.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
fun main() { val directions = listOf((0 to 1), (1 to 0), (0 to -1), (-1 to 0)) fun solvePart1(input: List<String>): Int { val n = input.size val m = input[0].length var (startX, startY) = (0 to 0) for (i in 0 until n) { for (j in 0 until m) { if (inp...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
2,827
AoC-2022-kotlin
Apache License 2.0
solution/#56 Merge Intervals/Solution.kt
enihsyou
116,918,868
false
{"Java": 179666, "Python": 36379, "Kotlin": 32431, "Shell": 367}
package leetcode.q56.kotlin; import org.junit.jupiter.api.Assertions import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource /** * 56. Merge Intervals * * [LeetCode](https://leetcode-cn.com/problems/merge-intervals/)...
1
Java
0
0
230325d1dfd666ee53f304edf74c9c0f60f81d75
2,406
LeetCode
MIT License
src/main/kotlin/nl/kelpin/fleur/advent2018/Day13.kt
fdlk
159,925,533
false
null
package nl.kelpin.fleur.advent2018 sealed class Turn object TurnLeft : Turn() object TurnRight : Turn() object Straight : Turn() class Day13(input: List<String>, private val removeCrashedCarts: Boolean = false) { companion object { fun replaceCartWithTrack(cart: Char): Char = when (cart) { '>'...
0
Kotlin
0
3
a089dbae93ee520bf7a8861c9f90731eabd6eba3
3,699
advent-2018
MIT License
src/Day03.kt
mpylypovych
572,998,434
false
{"Kotlin": 6455}
fun main() { fun score(c: Char) = c - if (c.isUpperCase()) 'A' - 27 else 'a' - 1 fun part1(input: List<String>) = input .map { it.chunked(it.length / 2) } .sumOf { row -> ('A'..'z').sumOf { if (row.first().contains(it) && row.last().contains(it)) ...
0
Kotlin
0
0
733b35c3f4eea777a5f666c804f3c92d0cc9854b
968
aoc-2022-in-kotlin
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day4/Day4.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day4 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines object Day4 : Day { override val input = readInputLines(4).run { Game(first().parseNumbers(), drop(1).parseBoards()) } override fun part1() = input.first() o...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,341
aoc2021
MIT License
src/main/kotlin/com/polydus/aoc18/Day4.kt
Polydus
160,193,832
false
null
package com.polydus.aoc18 class Day4: Day(4){ //https://adventofcode.com/2018/day/4 init { //partOne() partTwo() } fun partOne(){ val lines = input.sortedBy { var min = it.substring(15, 17).toInt() min }.sortedBy { var hour = it.su...
0
Kotlin
0
0
e510e4a9801c228057cb107e3e7463d4a946bdae
5,887
advent-of-code-2018
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestPath.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,785
kotlab
Apache License 2.0
leetcode/src/linkedlist/Q24.kt
zhangweizhe
387,808,774
false
null
package linkedlist import linkedlist.kt.ListNode fun main() { // 24. 两两交换链表中的节点 // https://leetcode-cn.com/problems/swap-nodes-in-pairs/ val createList = LinkedListUtil.createList(intArrayOf(1,2,3,4)) LinkedListUtil.printLinkedList(swapPairs2(createList)) } /** * 递归 https://lyl0724.github.io/2020/01...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,188
kotlin-study
MIT License
src/Day21.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
import arrow.core.Either private enum class MathOp { ADD, MUL, SUB, DIV; fun calc(x: Long, y: Long): Long { return when (this) { ADD -> x + y MUL -> x * y SUB -> x - y DIV -> x / y } } } fun main() { class Monkey(val monkeyA: String, val monke...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
4,600
aoc-2022
Apache License 2.0
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day16/Day16.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2015.day16 import nl.sanderp.aoc.common.readResource fun parseLine(line: String): Map<String, Int> { val facts = line.split(": ", limit = 2)[1].split(", ") return buildMap { for (fact in facts) { val (key, value) = fact.split(": ") put(key, value.toInt...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,405
advent-of-code
MIT License
src/main/kotlin/io/array/CourseScheduleSolution.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.array import java.util.* // https://leetcode.com/problems/course-schedule-iii/solution/ class CourseScheduleSolution { fun execute(courses: Array<IntArray>): Int { fun tryToChangePreviousLongerCourse(courses: Array<IntArray>, index: Int, duration: Int): Int? { var longestCourse = index ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,682
coding
MIT License
day5/src/main/kotlin/Main.kt
joshuabrandes
726,066,005
false
{"Kotlin": 47373}
import java.io.File var seedToSoilMap: AlmanachMap? = null var soilToFertilizerMap: AlmanachMap? = null var fertilizerToWaterMap: AlmanachMap? = null var waterToLightMap: AlmanachMap? = null var lightToTemperatureMap: AlmanachMap? = null var temperatureToHumidityMap: AlmanachMap? = null var humidityToLocationMap: Alma...
0
Kotlin
0
1
de51fd9222f5438efe9a2c45e5edcb88fd9f2232
3,846
aoc-2023-kotlin
The Unlicense
src/Day08.kt
emersonf
572,870,317
false
{"Kotlin": 17689}
fun main() { fun List<String>.asGrid(): Array<IntArray> { val grid = Array(size) { IntArray(size) } forEachIndexed { row, line -> line.forEachIndexed { column, char -> grid[row][column] = char.digitToInt() } } return grid...
0
Kotlin
0
0
0e97351ec1954364648ec74c557e18ccce058ae6
4,634
advent-of-code-2022-kotlin
Apache License 2.0
2022/src/day06/day06.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day06 import GREEN import RESET import printTimeMillis import readInput fun findMarker(str: String, markerSize: Int): Int { for (i in 0..str.length - markerSize) { if (str.substring(i, i + markerSize).toSet().size == markerSize) { return i + markerSize } } throw Illegal...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,889
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumDifference.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,861
kotlab
Apache License 2.0
src/day9/Day09.kt
dinoolivo
573,723,263
false
null
package day9 import readInput fun main() { fun findNumVisitedByTail(input: List<String>, numRopeNodes:Int): Int { val ropeNodes = mutableListOf<Position>() for(i in 0 until numRopeNodes){ ropeNodes.add(Position(0,0)) } val visited = HashSet<Position>() for(dire...
0
Kotlin
0
0
6e75b42c9849cdda682ac18c5a76afe4950e0c9c
1,503
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountDifferentPalindromicSubsequences.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,351
kotlab
Apache License 2.0
src/main/kotlin/Day10.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
import java.util.* fun main() { val data = readInputFile("day10") fun part1(): Int { return data.sumOf { it.findSyntaxErrorScore() } } fun part2(): Long { return data .mapNotNull { it.findCompletionScore() } .filter { it != 0L } .sorted() ...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
2,263
AOC2021
Apache License 2.0
src/main/kotlin/leetcode/kotlin/misc/350. Intersection of Two Arrays II.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.misc private fun intersect5(nums1: IntArray, nums2: IntArray): IntArray { nums1.sort() nums2.sort() var ans = ArrayList<Int>() var i = 0 var j = 0 while (i < nums1.size && j < nums2.size) { when { nums1[i] > nums2[j] -> j++ nums1[i] < nums...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
1,804
kotlinmaster
Apache License 2.0
codeforces/round740/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round740 fun main() { val (n, m) = readInts() Modular.M = m val primeDivisors = primeDivisors(n) val a = Array(n + 1) { it.toModular() } for (i in 3..n) { a[i] = 1 + 2 * a[i - 1] for (r in divisorsOf(i, primeDivisors)) { if (r == 1 || r == i) continue a[i] += a[r] - a[r - 1] } } p...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,138
competitions
The Unlicense
ceria/15/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File import java.util.Collections fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Int { var nums = input.first().split(",").map{ ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
1,857
advent-of-code-2020
MIT License
src/Day07.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
fun main() { // for part 1 val sizeLimit = 100000 // for part 2 val totalSpace = 70000000 val needUnused = 30000000 class Node(val name: String, val isLeaf: Boolean, val parent: Node?) { var size: Int = 0 constructor(name: String, isLeaf: Boolean, parent: Node?, size: Int) : t...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
3,361
Advent-of-Code-2022
Apache License 2.0
kotlin/MaxBipartiteMatchingEV.kt
polydisc
351,544,331
true
{"Java": 541473, "C++": 265630, "Python": 59545, "Kotlin": 28417, "CMake": 571}
// https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs in O(V * E) fun maxMatching(graph: Array<out List<Int>>): Int { val n1 = graph.size val n2 = (graph.flatMap { it }.maxOrNull() ?: -1) + 1 val matching = IntArray(n2) { -1 } return (0 until n1).sumOf { findPath(graph,...
1
Java
0
0
be589a7d88250947a53ec07e6f74118857d2e65b
884
codelibrary
The Unlicense
src/main/kotlin/aoc2016/SquaresWithThreeSides.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 import komu.adventofcode.utils.nonEmptyLines fun squaresWithThreeSides1(input: String): Int { val triangles = input.nonEmptyLines().map { Triangle.parse(it) } return triangles.count { it.isPossible() } } fun squaresWithThreeSides2(input: String): Int { val triangles = i...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,085
advent-of-code
MIT License
kotlin/2306-naming-a-company.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
class Solution { fun distinctNames(ideas: Array<String>): Long { val firstToSuffix = Array(26) { hashSetOf<String>() } var res = 0L ideas.forEach { firstToSuffix[it[0] - 'a'].add(it.substring(1, it.length)) } for (i in 0 until 26) { for (j ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,376
leetcode
MIT License
src/main/kotlin/days/Day1.kt
vovarova
726,012,901
false
{"Kotlin": 48551}
package days import util.DayInput class Day1 : Day("1") { override fun partOne(dayInput: DayInput): Any { val digits = dayInput.inputList().map { line -> line.toCharArray().filter { it.isDigit() }.map { it.digitToInt() } } return digits.map { 10 * it.first() + it.last() }.sum(...
0
Kotlin
0
0
77df1de2a663def33b6f261c87238c17bbf0c1c3
1,754
adventofcode_2023
Creative Commons Zero v1.0 Universal
year2016/src/main/kotlin/net/olegg/aoc/year2016/day7/Day7.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day7 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2016.DayOf2016 /** * See [Year 2016, Day 7](https://adventofcode.com/2016/day/7) */ object Day7 : DayOf2016(7) { private val ABBA = ('a'..'z') .flatMap { a -> ('a'..'z').filter { b -> a != b }.map { b -> "$a$b$b$...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,267
adventofcode
MIT License
kotlin/graphs/matchings/MinBipartiteWeightedMatchingHungarian.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.matchings import java.util.Arrays // https://en.wikipedia.org/wiki/Hungarian_algorithm in O(n^2 * m) object MinBipartiteWeightedMatchingHungarian { // a[n][m], n <= m, sum(a[i][p[i]]) -> min fun minWeightPerfectMatching(a: Array<IntArray>): Int { val n = a.size val m: Int = a[0]...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,938
codelibrary
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxSumBST.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,865
kotlab
Apache License 2.0
src/main/kotlin/io/nozemi/aoc/solutions/year2021/day10/SyntaxScoring.kt
Nozemi
433,882,587
false
{"Kotlin": 92614, "Shell": 421}
package io.nozemi.aoc.solutions.year2021.day10 import io.nozemi.aoc.puzzle.ANSI_BOLD import io.nozemi.aoc.puzzle.ANSI_RED import io.nozemi.aoc.puzzle.ANSI_RESET import io.nozemi.aoc.puzzle.Puzzle import io.nozemi.aoc.utils.median import kotlin.reflect.KFunction0 fun main() { SyntaxScoring("").printAnswers() } cl...
0
Kotlin
0
0
fc7994829e4329e9a726154ffc19e5c0135f5442
4,079
advent-of-code
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day14.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year21 import com.grappenmaker.aoc.PuzzleSet fun PuzzleSet.day14() = puzzle(day = 14) { // Get the input val (template, rules) = input.split("\n\n") // Window (or count) pairs val polymer = template.windowed(2).groupingBy { it }.eachCount().mapValues { it.value.toLong() }...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,758
advent-of-code
The Unlicense
语言知识(Language knowledge)/Kotlin/Practice/src/Main.kt
shencang
83,188,062
false
null
//顶层变量: val Pi = 3.14159265358979 var temp = 0 fun main(){ //定义只读局部变量使⽤关键字 val 定义。只能为其赋值⼀次 val a: Int = 1 // ⽴即赋值 val b = 2 // ⾃动推断出 `Int` 类型 val c: Int // 如果没有初始值类型不能省略 c = 3 // 明确赋值 var edge = a*b*c println("S-P-D-B") println(sum(a,b)) edge*=2 println(sum1(b,c)) println(sum...
13
HTML
1
5
f321a2e35b50bb9383729ea56a15866c3c3ab93b
1,284
note
Apache License 2.0
src/main/kotlin/leetcode/kotlin/array/SortingAlgorithms/EfficientSort/QuickSort.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.array.SortingAlgorithms.EfficientSort // https://en.wikipedia.org/wiki/Sorting_algorithm#Quicksort /* => Quick Sort (Partition Exchange Sort) 1. Pick an element, called a pivot, from the array. 2. Partitioning: reorder the array so that all elements with values less than the pivot come bef...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
2,034
kotlinmaster
Apache License 2.0
src/Day01.kt
DeltaSonic62
572,718,847
false
{"Kotlin": 8676}
fun getCarriedCals(input: List<String>): List<Int> { val carriedCals: MutableList<Int> = mutableListOf() var total = 0 for (str in input) { if (str.isEmpty() || str.isBlank()) { carriedCals.add(total) total = 0 continue } total += str.toInt() ...
0
Kotlin
0
0
7cdf94ad807933ab4769ce4995a43ed562edac83
1,098
aoc-2022-kt
Apache License 2.0
src/Day15.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
import java.util.* fun main() { class Point (x: Long, y: Long) { val x = x val y = y fun getDistance(other: Point): Long { return Math.abs(other.x-this.x) + Math.abs(other.y-this.y) } override fun equals(other: Any?): Boolean { if (this === other) r...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
5,044
aoc-kotlin
Apache License 2.0
kotlin/747. Largest Number At Least Twice of Others .kt
bchadwic
372,917,249
false
null
class Solution { /* Approach 2: A max heap is not needed given that if the second highest number isn't equal or greater than the highest, the rest of the lower numbers aren't either. Use a data class to hold three numbers, two being the first and second max, the last being the index of the first max. ...
1
Java
5
13
29070c0250b7ea3f91db04076c8aff5504a9caec
1,677
BoardMasters-Question-Of-The-Day
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ProfitableSchemes.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
4,353
kotlab
Apache License 2.0
src/examples/kotlin/org/holo/kGrammar/LL1Example.kt
Holo314
343,512,707
false
null
package org.holo.kGrammar import org.holo.kGrammar.parsers.parse import kotlin.test.assertEquals /** * Defining the [org.holo.kGrammar.Symbol.NonTerminal] symbols */ val start = Symbol.NonTerminal.Start val addExp = Symbol.NonTerminal.generate() val startMult = Symbol.NonTerminal.generate() val multExp = Symbol.Non...
0
Kotlin
0
0
af5568fc4d1a56d98a93a645ca0ffbbf966a450b
5,278
KGrammar
MIT License
src/main/kotlin/com/frankandrobot/rapier/util/combinations.kt
frankandrobot
62,833,944
false
null
/* * Copyright 2016 <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 ...
1
Kotlin
1
1
ddbc0dab60ca595e63a701e2f8cd6694ff009adc
2,134
rapier
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day16/Day16.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day16 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInput object Day16 : Day { override var input = readInput(16) override fun part1() = PacketFactory(input).build().subVersions.sum() override fun part2() = PacketFactor...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
3,175
aoc2021
MIT License
src/main/java/Day2.kt
mattyb678
319,195,903
false
null
class Day2 : Day { override fun asInt(): Int = 2 override fun part1InputName(): String = "day2" override fun part1(input: List<String>): String { return input.map { it.split(":") } .map { it.map { s -> s.trim() } } .filter { validPasswordPart1(it[0], it[1]) } .c...
0
Kotlin
0
1
f677d61cfd88e18710aafe6038d8d59640448fb3
1,724
aoc-2020
MIT License
src/Day09.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import kotlin.math.abs fun main() { fun part1(input: List<Mvmt>) { val head = Point(0, 0) val tail = Point(0, 0) val positions = mutableSetOf(tail.copy()) input.forEach { mvmt -> head.move(mvmt) if (!tail.isAdjecent(head)) { tail.catchUp(head, m...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
4,326
advent-of-code-2022
Apache License 2.0
kotlin/0785-is-graph-bipartite.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}
/* * BFS */ class Solution { fun isBipartite(graph: Array<IntArray>): Boolean { if (graph.isEmpty()) return true val nodeColorMap = mutableMapOf<Int, Color>() fun bfs(startNode: Int): Boolean { // if the node is already colored, return true if (startNode in nodeColor...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
3,699
leetcode
MIT License
src/main/java/im/joshua/leetcode/topic/LeetCode_5.kt
JoshuaYin
239,452,799
false
{"Java": 13766, "Kotlin": 10698}
package im.joshua.leetcode.topic /** * @description: * @author: joshua * @E-mail: <EMAIL> * @date: 2020/8/5 16:10 */ fun main(args: Array<String>) { val topic = LeetCode_5("abacabbacad") println(topic.solve()) } class LeetCode_5(val s: String) : LeetCodeTopic<String>() { override fun formatParams()...
0
Java
0
0
03f5672551189bfd3fc396f1b34a30fb79749f5a
3,171
leet-code-java
Apache License 2.0
src/Day06.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
fun main() { fun part1(input: List<String>): Int { println(input) val potentialMarkers = input[0].windowed(4).map { it.windowed(1).sorted() } println(potentialMarkers) for(i in potentialMarkers.indices) { if(potentialMarkers[i][0] != potentialMarkers[i][1] && potentialMarkers[i][1] != ...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
1,082
AdventOfCode2022
Apache License 2.0
src/aoc_2023/Day01.kt
jakob-lj
573,335,157
false
{"Kotlin": 38689}
package aoc_2023 class Day01 { val testInput = """ two1nine eightwothree abcone2threexyz xtwone3four 4nineeightseven2 zoneight234 7pqrstsixteen """.trimIndent() val realInput = """""".trimIndent() val textToDigits = mapOf( "one" to 1, "two" to 2, "three...
0
Kotlin
0
0
3a7212dff9ef0644d9dce178e7cc9c3b4992c1ab
1,520
advent_of_code
Apache License 2.0
src/main/kotlin/day03/Day03.kt
tiefenauer
727,712,214
false
{"Kotlin": 11843}
/** * You and the Elf eventually reach a gondola lift station; he says the gondola lift will take you up to the water source, but this is as far as he can bring you. You go inside. * * It doesn't take long to find the gondolas, but there seems to be a problem: they're not moving. * * "Aaah!" * * You turn around ...
0
Kotlin
0
0
ffa90fbdaa779cfff956fab614c819274b793d04
2,576
adventofcode-2023
MIT License
src/main/java/com/ncorti/aoc2021/Exercise16.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 object Exercise16 { private fun getInput() = getInputAsTest("16") { toCharArray().joinToString("") { when (it) { '0' -> "0000" '1' -> "0001" '2' -> "0010" '3' -> "0011" ...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
3,522
adventofcode-2021
MIT License
src/main/kotlin/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2131_longest_palindrome_by_concatenating_two_letter_words // #Medium #Array #String #Hash_Table #Greedy #Counting #Level_2_Day_5_Greedy // #2023_06_25_Time_607_ms_(90.00%)_Space_55.2_MB_(100.00%) class Solution { fun longestPalindrome(words: Array<String>): Int { val counter: MutableMa...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,327
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g1201_1300/s1278_palindrome_partitioning_iii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1278_palindrome_partitioning_iii // #Hard #String #Dynamic_Programming #2023_06_08_Time_137_ms_(100.00%)_Space_35.4_MB_(50.00%) class Solution { fun palindromePartition(s: String, k: Int): Int { val n = s.length val pal = Array(n + 1) { IntArray(n + 1) } fillPal(s, n, p...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,874
LeetCode-in-Kotlin
MIT License
src/main/kotlin/io/string/MultiplyStrings.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.string import io.utils.runTests // https://leetcode.com/problems/multiply-strings/ class MultiplyStrings { fun execute(input0: String, input1: String): String = input0 * input1 fun multiply(input0: String, input1: String): String? { val map = IntArray(input0.length + input1.length) for (i in i...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
3,110
coding
MIT License
src/main/kotlin/days/aoc2023/Day8.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2023 import days.Day import util.lcm class Day8 : Day(2023, 8) { override fun partOne(): Any { return calculatePartOne(inputList) } override fun partTwo(): Any { return calculatePartTwo(inputList) } fun calculatePartOne(input: List<String>): Int { val dire...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,131
Advent-Of-Code
Creative Commons Zero v1.0 Universal
aoc2016/src/main/kotlin/io/github/ajoz/aoc16/Day1.kt
ajoz
116,427,939
false
null
package io.github.ajoz.aoc16 import io.github.ajoz.sequences.firstRepeated import io.github.ajoz.sequences.scan /** * Day 1: No Time for a Taxicab * * -------------------- Part 1 ----------------------- * * You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close a...
0
Kotlin
0
0
49ba07dd5fbc2949ed3c3ff245d6f8cd7af5bebe
9,426
challenges-kotlin
Apache License 2.0
src/main/kotlin/de/consuli/aoc/year2022/days/Day05.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2022.days import de.consuli.aoc.common.Day class Day05 : Day(5, 2022) { override fun partOne(testInput: Boolean): Any { return calculateFinalCrateOrder(testInput, false) } override fun partTwo(testInput: Boolean): Any { return calculateFinalCrateOrder(testInput,...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
1,859
advent-of-code
Apache License 2.0
src/main/kotlin/Day14.kt
brigham
573,127,412
false
{"Kotlin": 59675}
import kotlin.math.sign data class Position14(val right: Int, val down: Int) { fun to(end: Position14): Sequence<Position14> { var p = this return sequence { while (p != end) { yield(p) if (p.down == end.down) { p = Position14((end.ri...
0
Kotlin
0
0
b87ffc772e5bd9fd721d552913cf79c575062f19
3,826
advent-of-code-2022
Apache License 2.0
src/day8/Day8.kt
ZsemberiDaniel
159,921,870
false
null
package day8 import RunnablePuzzleSolver class Day8 : RunnablePuzzleSolver { private lateinit var rootNode: Node override fun readInput1(lines: Array<String>) { rootNode = getNodeStartingFrom(lines[0].split(" ").map { it.toInt() }.toTypedArray(), 0).first } private fun getNodeStartingFrom(nu...
0
Kotlin
0
0
bf34b93aff7f2561f25fa6bd60b7c2c2356b16ed
3,336
adventOfCode2018
MIT License
src/Day10.kt
sungi55
574,867,031
false
{"Kotlin": 23985}
fun main() { val day = "Day10" val oneCycleCommand = "noop" val twoCycleCommand = "addx" fun part1(lines: List<String>): Int { val commands = lines.iterator() var signalStrength = 1 var currentCycle = 0 return listOf(20, 60, 100, 140, 180, 220).sumOf { nextCycle -> ...
0
Kotlin
0
0
2a9276b52ed42e0c80e85844c75c1e5e70b383ee
2,052
aoc-2022
Apache License 2.0
kotlin/app/src/main/kotlin/coverick/aoc/day2/RockPaperScissors.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day2; import readResourceFile // https://adventofcode.com/2022/day/2 val INPUT_FILE = "rockPaperScissors-input.txt" // enumerate shapes and outcomes for rock,paper,scissors // according to text rules. enum class Shape(val score: Int) { ROCK(1), PAPER(2), SCISSOR(3) } enum class Out...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
3,154
adventofcode2022
Apache License 2.0