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/Day13.kt
HaydenMeloche
572,788,925
false
{"Kotlin": 25699}
import kotlinx.serialization.json.* import kotlinx.serialization.decodeFromString fun main() { val input = readInput("Day13") input.asSequence() .filter { it.isNotBlank() } .map { Json.decodeFromString<JsonArray>(it) } .windowed(size = 2, step = ...
0
Kotlin
0
1
1a7e13cb525bb19cc9ff4eba40d03669dc301fb9
2,112
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day04/Day04.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day04 import java.io.File fun main() { val data = parse("src/main/kotlin/day04/Day04.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 04 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
1,316
advent-of-code-2022
MIT License
src/main/kotlin/day1.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
fun day1 (lines: List<String>) { day1part1(lines) day1part2(lines) println() } fun day1part1(lines: List<String>) { var sum = 0 lines.forEach { line -> val digits = line.filter { it.isDigit() } sum += Integer.parseInt(digits.first().toString() + digits.last().toString()); ...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
1,461
advent_of_code_2023
MIT License
src/Year2022Day14.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
import kotlin.math.max import kotlin.math.min fun main() { val entrypoint = Point(0, 500) val directions = arrayOf( Point(+1, 0), Point(+1, -1), Point(+1, +1), ) fun pointFallDown(now: Point, G: Set<Point>, borderLine: Int): Point { return directions.asSequence() ...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
2,336
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/g1901_2000/s1942_the_number_of_the_smallest_unoccupied_chair/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1942_the_number_of_the_smallest_unoccupied_chair // #Medium #Array #Heap_Priority_Queue #Ordered_Set // #2023_06_20_Time_549_ms_(100.00%)_Space_63.6_MB_(100.00%) import java.util.Arrays import java.util.PriorityQueue class Solution { fun smallestChair(times: Array<IntArray>, targetFriend: Int...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,492
LeetCode-in-Kotlin
MIT License
src/Day10.kt
oleskrede
574,122,679
false
{"Kotlin": 24620}
fun main() { val part2Solution = """ ##..##..##..##..##..##..##..##..##..##.. ###...###...###...###...###...###...###. ####....####....####....####....####.... #####.....#####.....#####.....#####..... ######......######......######......#### #######.......#######.......
0
Kotlin
0
0
a3484088e5a4200011335ac10a6c888adc2c1ad6
2,613
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g2201_2300/s2232_minimize_result_by_adding_parentheses_to_expression/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2232_minimize_result_by_adding_parentheses_to_expression // #Medium #String #Enumeration #2023_06_27_Time_191_ms_(100.00%)_Space_34.4_MB_(100.00%) class Solution { // Variables for final solution, to avoid create combination Strings private var currentLeft = 0 private var currentRight ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,734
LeetCode-in-Kotlin
MIT License
src/main/kotlin/aoc2020/day7/LuggageProcessing.kt
arnab
75,525,311
false
null
package aoc2020.day7 object LuggageProcessing { fun parse(data: String): Map<String, List<Pair<String, Int>>> = data.split("\n").map { line -> val(type, specs) = line.split("bags contain ") val containedBags = specs.replace(".", "") .split(", ") .map...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,467
adventofcode
MIT License
src/Day18.kt
syncd010
324,790,559
false
null
class Day18: Day { // This represents a key found on the maze data class MapKey(val id: Char, val steps:Int, val requires: List<Char>) private val dirs = listOf(Position(0, -1), Position(1, 0), Position(0, 1), Position(-1, 0)) private fun List<String>.positionOf(c: Char): Position? { for (y i...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
5,601
AoC2019
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv02/Lv2_12939_최댓값과최솟값.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package programmers.lv02 /** * * no.12939 * 최댓값과 최솟값 * https://school.programmers.co.kr/learn/courses/30/lessons/12939 * * 문제 설명 * 문자열 s에는 공백으로 구분된 숫자들이 저장되어 있습니다. * str에 나타나는 숫자 중 최소값과 최대값을 찾아 이를 "(최소값) (최대값)"형태의 문자열을 반환하는 함수, solution을 완성하세요. * 예를들어 s가 "1 2 3 4"라면 "1 4"를 리턴하고, "-1 -2 -3 -4"라면 "-4 -1"을 리턴하면...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,061
HoOne
Apache License 2.0
ahp-base/src/main/kotlin/pl/poznan/put/ahp/MatrixMaker.kt
sbigaret
164,424,298
true
{"Kotlin": 93061, "R": 67629, "Shell": 24899, "Groovy": 24559}
package pl.poznan.put.ahp object MatrixMaker { fun matrix(matrix: Map<String, List<RelationValue>>, diagonalSup: (key: String) -> List<RelationValue>) = matrix.toMatrix(diagonalSup) private inline fun Map<String, List<RelationValue>>.toMatrix(diagonalSup: (key: String) -> List<RelationValue>) = ...
0
Kotlin
0
0
96c182d7e37b41207dc2da6eac9f9b82bd62d6d7
2,315
DecisionDeck
MIT License
day01/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- Part Two --- // Your calculation isn't quite right. It looks like some of the digits are // actually spelled out with letters: one, two, three, four, five, six, seven, // eight, and nine also count as valid "digits". // // Equipped with this new information, you now need to find the real first and // last digit ...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
1,393
adventofcode2023
MIT License
src/2023/Day03.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.util.* fun main() { Day03().solve() } class Day03 { val input1 = """ 467..114.. ...*...... ..35..633. ......#... 617*...... .....+.58. ..592..... ......755. ...$.*.... .664.598.. ...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
3,239
advent-of-code
Apache License 2.0
src/Day03.kt
janbina
112,736,606
false
null
package day03 import getInput import kotlin.coroutines.experimental.buildSequence import kotlin.math.abs import kotlin.math.ceil import kotlin.math.sqrt import kotlin.test.assertEquals enum class Direction { TOP, LEFT, BOTTOM, RIGHT } fun main(args: Array<String>) { val input = getInput(3).readLines().first().to...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
2,193
advent-of-code-2017
MIT License
yandex/y2023/qual/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2023.qual private fun solve() { val (n, m) = readInts() val a = readInts() val aSorted = a.sorted() val y = aSorted[m - 1] val yTake = aSorted.take(m).count { it == y } val xDefinitely = a.indices.filter { a[it] < y } val xY = a.indices.filter { a[it] == y } val xLeft = xDefinitely.firstOrNull(...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
688
competitions
The Unlicense
src/Day03.kt
shoebham
573,035,954
false
{"Kotlin": 9305}
fun main() { fun part1(input: List<String>): Int { var ans=0 for(word in input){ var common:Char? = null val freqMap1 = mutableMapOf<Char,Int>() val freqMap2 = mutableMapOf<Char,Int>() // lower case priority= 1-26 // upper 27-52 ...
0
Kotlin
0
0
f9f0e0540c599a8661bb2354ef27086c06a3c9ab
2,245
advent-of-code-2022
Apache License 2.0
src/Day08.kt
kmakma
574,238,598
false
null
import kotlin.math.max fun main() { fun part1(input: List<String>): Int { val visible = mutableSetOf<Coord2D>() val grid = input.map { line -> line.map { it.digitToInt() } } val lastX = grid.lastIndex val lastY = grid.first().lastIndex visible.addAll(grid.indices.map { Coor...
0
Kotlin
0
0
950ffbce2149df9a7df3aac9289c9a5b38e29135
3,593
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/com/askrepps/advent2021/day09/Day09.kt
askrepps
726,566,200
false
{"Kotlin": 302802}
/* * MIT License * * Copyright (c) 2021-2023 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modi...
0
Kotlin
0
0
89de848ddc43c5106dc6b3be290fef5bbaed2e5a
3,681
advent-of-code-kotlin
MIT License
2019/src/main/kotlin/day4.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut import utils.map fun main() { Day4.run() } object Day4 : Solution<Pair<Int, Int>>() { override val name = "day4" override val parser = Parser { input -> input.cut("-").map { it.toInt() } } fun fits(pwd: String, triplet: Boolean = false): Boolea...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,093
aoc_kotlin
MIT License
2017/src/main/kotlin/Day14.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import grid.Point object Day14 { fun part1(input: String): Int { return inputToDisk(input).sumBy { row -> row.sumBy { if (it) 1 else 0 } } } fun part2(input: String): Int { val disk = inputToDisk(input) val unvisited = mutableSetOf<Point>() disk.forEachIndexed { row, values -> ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,047
advent-of-code
MIT License
src/main/kotlin/g2301_2400/s2343_query_kth_smallest_trimmed_number/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2301_2400.s2343_query_kth_smallest_trimmed_number // #Medium #Array #String #Sorting #Heap_Priority_Queue #Divide_and_Conquer #Quickselect #Radix_Sort // #2023_07_01_Time_382_ms_(100.00%)_Space_38.7_MB_(100.00%) class Solution { fun smallestTrimmedNumbers(nums: Array<String>, queries: Array<IntArray>): I...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,894
LeetCode-in-Kotlin
MIT License
kotlin/src/com/daily/algothrim/leetcode/FairCandySwap.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 888. 公平的糖果棒交换 * 爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 根糖果棒的大小,B[j] 是鲍勃拥有的第 j 根糖果棒的大小。 * * 因为他们是朋友,所以他们想交换一根糖果棒,这样交换后,他们都有相同的糖果总量。(一个人拥有的糖果总量是他们拥有的糖果棒大小的总和。) * * 返回一个整数数组 ans,其中 ans[0] 是爱丽丝必须交换的糖果棒的大小,ans[1] 是 Bob 必须交换的糖果棒的大小。 * * 如果有多个答案,你可以返回其中任何一个。保证答案存在。 * */ class Fai...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,579
daily_algorithm
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day16.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.P fun main() = Day16.run() object Day16 : Day(2015, 16) { private val sender = mapOf( P("children", 3), P("cats", 7), P("samoyeds", 2), P("pomeranians", 3), P("akitas", 0), ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,562
adventofkotlin
MIT License
src/main/kotlin/de/startat/aoc2023/Day10.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 class Day10 { data class Maze(val pipes: Set<Pipe>) { val start: Pipe = pipes.first { it.char == 'S' } private fun getPipeAt(column: Int, row: Int): Pipe? = pipes.find { p -> p.column == column && p.row == row } fun findConnectedPipes(pipe: Pipe): Se...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
25,151
AOC2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/g2901_3000/s2959_number_of_possible_sets_of_closing_branches/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2959_number_of_possible_sets_of_closing_branches // #Hard #Bit_Manipulation #Heap_Priority_Queue #Graph #Enumeration #Shortest_Path // #2024_01_16_Time_231_ms_(87.50%)_Space_39.9_MB_(75.00%) import java.util.LinkedList import java.util.Queue class Solution { private fun get(n: Int, maxDis: In...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,393
LeetCode-in-Kotlin
MIT License
AddStrings.kt
ncschroeder
604,822,497
false
{"Kotlin": 19399}
/* https://leetcode.com/problems/add-strings/ Given two non-negative integers, `num1` and `num2` represented as string, return the sum of `num1` and `num2` as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs ...
0
Kotlin
0
0
c77d0c8bb0595e61960193fc9b0c7a31952e8e48
3,200
Coding-Challenges
MIT License
src/main/kotlin/g1901_2000/s1947_maximum_compatibility_score_sum/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1901_2000.s1947_maximum_compatibility_score_sum // #Medium #Array #Dynamic_Programming #Bit_Manipulation #Backtracking #Bitmask // #2023_06_20_Time_179_ms_(100.00%)_Space_37.5_MB_(100.00%) class Solution { private lateinit var dp: Array<IntArray> private var m = 0 private lateinit var memo: Array...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,378
LeetCode-in-Kotlin
MIT License
src/year2021/02/Day02.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2021.`02` import readInput private enum class Command { Forward, Down, Up; } private data class CommandWrapper( val command: Command, val amount: Int, ) fun main() { fun parse(input: List<String>): List<CommandWrapper> { return input .map { va...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
2,132
KotlinAdventOfCode
Apache License 2.0
src/Day05.kt
polbins
573,082,325
false
{"Kotlin": 9981}
fun main() { fun part1( input: List<String>, numberOfStacks: Int ): String { val stacks: MutableList<ArrayDeque<Char>> = buildList(numberOfStacks) { add(ArrayDeque<Char>()) }.toMutableList() val crateSize = 4 var i = 0 for (s in input) { // put on to stack while (s.ind...
0
Kotlin
0
0
fb9438d78fed7509a4a2cf6c9ea9e2eb9d059f14
2,661
AoC-2022
Apache License 2.0
src/Day05.kt
mcdimus
572,064,601
false
{"Kotlin": 32343}
import util.readInput @OptIn(ExperimentalStdlibApi::class) fun main() { fun part1(input: List<String>): String { val stacks = parseStacks(input) val commands = parseCommands(input) for (command in commands) { for (i in 0..<command.amount) { val c = stacks[comman...
0
Kotlin
0
0
dfa9cfda6626b0ee65014db73a388748b2319ed1
2,530
aoc-2022
Apache License 2.0
src/Day19.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import kotlin.math.max import kotlin.math.min fun main() { val testInput = readInput("Day19_test") val testBlueprints = testInput.map(Blueprint.Companion::fromString) check(part1(testBlueprints) == 33) val input = readInput("Day19") val blueprints = input.map(Blueprint.Companion::fromString) p...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
7,623
AOC2022
Apache License 2.0
src/test/kotlin/com/igorwojda/string/ispalindrome/tolerant/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.string.ispalindrome.tolerant // iterative solution private object Solution1 { private fun isTolerantPalindrome(str: String): Boolean { var characterRemoved = false var leftIndex = 0 var rightIndex = str.lastIndex while (leftIndex <= rightIndex) { if...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
2,738
kotlin-coding-challenges
MIT License
src/main/kotlin/com/jacobhyphenated/day12/Day12.kt
jacobhyphenated
572,119,677
false
{"Kotlin": 157591}
package com.jacobhyphenated.day12 import com.jacobhyphenated.Day import java.io.File import kotlin.math.absoluteValue // The N-Body Problem class Day12: Day<List<List<Int>>> { override fun getInput(): List<List<Int>> { return this.javaClass.classLoader.getResource("day12/input.txt")!! .readTex...
0
Kotlin
0
0
1a0b9cb6e9a11750c5b3b5a9e6b3d63649bf78e4
6,256
advent2019
The Unlicense
src/day04/Day04.kt
voom
573,037,586
false
{"Kotlin": 12156}
package day04 import readInput /** * --- Day 4: Camp Cleanup --- */ fun main() { fun toIntRanges(sections: String) = sections.split(',') .map { range -> val (left, right) = range .split('-') .map { it.toInt() } (left..right).toSet() } ...
0
Kotlin
0
1
a8eb7f7b881d6643116ab8a29177d738d6946a75
1,097
aoc2022
Apache License 2.0
src/main/kotlin/io/github/lawseff/aoc2023/range/NestedRangeMapProblemSolver.kt
lawseff
573,226,851
false
{"Kotlin": 37196}
package io.github.lawseff.aoc2023.range import io.github.lawseff.aoc2023.range.entity.AlmanacEntityMapping import io.github.lawseff.aoc2023.range.entity.Range import io.github.lawseff.aoc2023.range.entity.SourceDestinationRange import io.github.lawseff.aoclib.Day import io.github.lawseff.aoclib.PartOne import io.githu...
0
Kotlin
0
0
b60ab611aec7bb332b8aa918aa7c23a43a3e61c8
2,939
advent-of-code-2023
MIT License
kotlin/0051-n-queens.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 solveNQueens(n: Int): List<List<String>> { val cols = HashSet<Int>() //keep track of used columns, we iterate rows val posDia = HashSet<Int>() //...of positive diagonals R+C val negDia = HashSet<Int>() //...of negative diagonals R-C val temp: ArrayList<ArrayList<...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,974
leetcode
MIT License
kotlin/src/katas/kotlin/skiena/graphs/DFSApplications.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.skiena.graphs import katas.kotlin.skiena.graphs.UnweightedGraphs.diamondGraph import katas.kotlin.skiena.graphs.UnweightedGraphs.linearGraph import katas.kotlin.skiena.graphs.UnweightedGraphs.meshGraph import datsok.shouldEqual import org.junit.Test fun <T> Graph<T>.hasCycles(): Boolean { val...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,868
katas
The Unlicense
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day07Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith import java.util.* private fun solution1(input: String): Long { val directories = findDirectories(...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
2,796
adventofcode-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2369/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2369 /** * LeetCode page: [2369. Check if There is a Valid Partition For The Array](https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the size of nums; */ ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,228
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/day18/Day18.kt
dustinconrad
572,737,903
false
{"Kotlin": 100547}
package day18 import geometry.Coord3d import geometry.containedBy import geometry.neighbors import geometry.parseCoord3d import geometry.x import geometry.y import geometry.z import readResourceAsBufferedReader fun main() { println("part 1: ${part1(readResourceAsBufferedReader("18_1.txt").readLines())}") prin...
0
Kotlin
0
0
1dae6d2790d7605ac3643356b207b36a34ad38be
4,040
aoc-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day02.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2021 import com.dvdmunckhof.aoc.splitOnce class Day02(private val input: List<String>) { fun solvePart1(): Int = solve { state, direction, distance -> when (direction) { "forward" -> state.copy(position = state.position + distance) "up" -> state.co...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,291
advent-of-code
Apache License 2.0
src/main/kotlin/Day08.kt
AlmazKo
576,500,782
false
{"Kotlin": 26733}
typealias Map = Array<IntArray> object Day08 : Task { @JvmStatic fun main(args: Array<String>) = execute() override fun part1(input: Iterable<String>): Any { val map = parse(input) val copter = Copter(map) val visible = copter.launch() return visible.sumOf { it.count { it >...
0
Kotlin
0
1
109cb10927328ce296a6b0a3600edbc6e7f0dc9f
3,632
advent2022
MIT License
src/Day05_part1.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
class Stack { val input = readInput("Day05") private val rawList = mutableListOf<MutableList<Char>>() private val newList = mutableListOf<MutableList<Char>>() fun addStack(str: String) { var raw = "" for (i in 1 until str.length step 4) { raw += str[i].toString() } ...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
1,926
aoc2022
Apache License 2.0
src/day22/day22.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day22 import readInput private fun Direction.rotateRight(): Direction = when (this) { Direction.LEFT -> Direction.UP Direction.RIGHT -> Direction.DOWN Direction.UP -> Direction.RIGHT Direction.DOWN -> Direction.LEFT } private fun Direction.rotateLeft(): Direction = when (this) { Dire...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
11,788
aoc-2022
Apache License 2.0
src/exercises/Day05.kt
Njko
572,917,534
false
{"Kotlin": 53729}
// ktlint-disable filename package exercises import readInput data class Move(val quantity: Int, val from: Int, val to: Int) fun main() { fun extractStacks(lines: List<String>): List<MutableList<Char>> { val numberOfStacks = lines.last()[lines.last().length - 1].toString().toInt() val stacks = m...
0
Kotlin
0
2
68d0c8d0bcfb81c183786dfd7e02e6745024e396
4,141
advent-of-code-2022
Apache License 2.0
src/Day02.kt
ajspadial
573,864,089
false
{"Kotlin": 15457}
fun main() { fun scoreShape(shape: String): Int { return when (shape) { "X" -> 1 "Y" -> 2 "Z" -> 3 else -> 0 } } fun scoreRound(opponent: String, response: String): Int { if (opponent == "A") { return when (response) { ...
0
Kotlin
0
0
ed7a2010008be17fec1330b41adc7ee5861b956b
2,376
adventofcode2022
Apache License 2.0
src/main/kotlin/Excercise07.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
import kotlin.math.abs private fun part1() { getInputAsTest("07") { split(",") }.map { it.toInt() }.minFuel().let { println("Part 1 $it") } } private fun part2() { getInputAsTest("07") { split(",") }.map { it.toInt() }.maxFuel().let { println("Part 2 $it") } } private fun List<Int>.minFuel(): Int { val minValu...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
774
advent-of-code-2021
MIT License
src/main/kotlin/ru/spbstu/parse/Parsing.kt
belyaev-mikhail
192,383,116
false
null
package ru.spbstu.parse import ru.spbstu.map.* import ru.spbstu.sim.* data class Task(val name: String, val map: Shape, val initial: Point, val obstacles: List<Shape>, val boosters: List<Booster>) fun parsePoint(point: String): Point { val coordinates = point.replace('(', ' ').replace(')', ' ').split(',').map { ...
1
Kotlin
0
0
cd5c7d668bf6615fd7e639ddfce0c135c138de42
3,004
icfpc-2019
MIT License
src/Day05.kt
chrisjwirth
573,098,264
false
{"Kotlin": 28380}
fun main() { fun parsedInstructions(input: List<String>): MutableList<Map<String, Int>> { val parsedInstructions = mutableListOf<Map<String, Int>>() val instructions = input.subList( input.indexOfFirst { it.isEmpty() } + 1, input.size ) instructions.forEach {...
0
Kotlin
0
0
d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d
3,079
AdventOfCode2022
Apache License 2.0
src/day03/Day03.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day03 import readLines fun main() { fun Sequence<Set<Char>>.scored() = this .map { it.map { char -> if (char.isLowerCase()) char - 'a' else char - 'A' + 26 } + 1 } .flatten() .sum() fun part1(input: List<String>) = input.asSequence() .map { rucksack -> rucksack.chunked(rucksack.length / ...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
914
advent-of-code-22
Apache License 2.0
src/main/kotlin/io/github/kmakma/adventofcode/y2020/Y2020Day18.kt
kmakma
225,714,388
false
null
package io.github.kmakma.adventofcode.y2020 import io.github.kmakma.adventofcode.utils.Day import io.github.kmakma.adventofcode.utils.product fun main() { Y2020Day18().solveAndPrint() } private enum class Operation { ADDITION, MULTIPLICATION } class Y2020Day18 : Day(2020, 18, "Operation Order") { private l...
0
Kotlin
0
0
7e6241173959b9d838fa00f81fdeb39fdb3ef6fe
2,478
adventofcode-kotlin
MIT License
codeforces/kotlinheroes6/practice/g.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes6.practice fun main() { val (_, m) = readInts() val a = readLongs() val capital = a.withIndex().minByOrNull { it.value }!!.index data class Edge(val u: Int, val v: Int, val weight: Long) val edges = List(m) { val (uIn, vIn, weight) = readLongs() Edge((uIn - 1).toInt(), (vIn - 1)...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,091
competitions
The Unlicense
2017/src/main/kotlin/Day23.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import utils.splitNewlines import utils.splitWhitespace object Day23 { fun part1(input: String): Int { val instructions = input.splitNewlines().map(this::parseInstruction) var pointer = 0 val registers = mutableMapOf<Char, Long>().withDefault { 0 } var mulCount = 0 while (pointer < instructions...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
3,025
advent-of-code
MIT License
src/Day10.kt
vladislav-og
573,326,483
false
{"Kotlin": 27072}
fun main() { fun calculateSignalStrength(cycleCount: Int, signalStrength: Int, xValue: Int): Int { var signalStrength1 = signalStrength if (cycleCount % 40 == 20) { signalStrength1 += xValue * cycleCount } return signalStrength1 } fun part1(input: List<String>): Int { var cycleCount = ...
0
Kotlin
0
0
b230ebcb5705786af4c7867ef5f09ab2262297b6
1,204
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day08.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
@file:Suppress("DuplicatedCode") // I know... package aoc2022 import AoCDay import kotlin.math.max // https://adventofcode.com/2022/day/8 object Day08 : AoCDay<Int>( title = "Treetop Tree House", part1ExampleAnswer = 21, part1Answer = 1533, part2ExampleAnswer = 8, part2Answer = 345744, ) { pr...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,827
advent-of-code-kotlin
MIT License
src/main/kotlin/days/Day5.kt
teunw
573,164,590
false
{"Kotlin": 20073}
package days import chunkBy class Day5 : Day(5) { fun parseInput(): Pair<List<MutableList<Char>>, Array<Array<Int>>> { val (stackText, instructionText) = inputList.chunkBy { it.isBlank() } val stackIndexes = stackText .last() .mapIndexed { index, s -> if (s.isDigit()) ind...
0
Kotlin
0
0
149219285efdb1a4d2edc306cc449cce19250e85
2,090
advent-of-code-22
Creative Commons Zero v1.0 Universal
src/main/kotlin/ru/timakden/aoc/year2016/Day08.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2016 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 8: Two-Factor Authentication](https://adventofcode.com/2016/day/8). */ object Day08 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2016...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,554
advent-of-code
MIT License
src/Day04.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { fun part1(input: List<String>) = input .readRanges() .count { (first, second) -> first contains second || second contains first } fun part2(input: List<String>) = input .readRanges() .count { (first, secon...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
845
aoc-2022
Apache License 2.0
src/main/kotlin/solutions/day08/Day8.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day08 import solutions.Solver import utils.Coordinate import kotlin.math.max class Day8 : Solver { override fun solve(input: List<String>, partTwo: Boolean): String { val map = mutableMapOf<Coordinate, Int>() val WIDTH = input[0].length val HEIGHT = input.size ...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
3,835
Advent-of-Code-2022
MIT License
src/main/kotlin/Day10.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
import java.lang.StringBuilder class Day10 { fun part1(input: List<String>): Int { val cyclesToCheck = (20..220 step 40).toList() var result = 0 val instructions = listOf(1) + input.flatMap { it.toOperation() } instructions.reduceIndexed { cycle, acc, instruction -> if ...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
1,522
advent-of-code-2022
Apache License 2.0
src/day5/Day5.kt
quinlam
573,215,899
false
{"Kotlin": 31932}
package day5 import utils.Day import java.util.Stack /** * Actual answers after submitting; * part1: QGTHFZBHV * part2: MGDMPSZTM */ class Day5 : Day<String, StackInput>( testPart1Result = "CMZ", testPart2Result = "MCD" ) { override fun part1Answer(input: StackInput): String { return moveStack...
0
Kotlin
0
0
d304bff86dfecd0a99aed5536d4424e34973e7b1
3,127
advent-of-code-2022
Apache License 2.0
2022/src/day08/Day08.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day08 import java.io.File fun main() { val input = File("src/day08/day08input.txt").readLines() val grid = TreeGrid(input) println(grid.getVisibleCells().size) println(grid.getMaxScenicScore()) } typealias Cell = Pair<Int, Int> class TreeGrid { private var _values: List<List<Int>> pr...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,600
adventofcode
Apache License 2.0
src/main/kotlin/day11/GalaxyMap.kt
limelier
725,979,709
false
{"Kotlin": 48112}
package day11 import kotlin.math.max import kotlin.math.min internal class GalaxyMap( inputLines: Iterable<String> ) { private val galaxies = inputLines.flatMapIndexed { row, line -> line.mapIndexedNotNull { col, char -> if (char == '#') Galaxy(row, col) else null } } val ...
0
Kotlin
0
0
0edcde7c96440b0a59e23ec25677f44ae2cfd20c
1,782
advent-of-code-2023-kotlin
MIT License
src/Day04.kt
mr-cell
575,589,839
false
{"Kotlin": 17585}
fun main() { fun part1(input: List<String>): Int { return input .map { it.asRanges() } .count { it.first fullyOverlaps it.second || it.second fullyOverlaps it.first } } fun part2(input: List<String>): Int { return input .map { it.asRanges() } ...
0
Kotlin
0
0
2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9
1,107
advent-of-code-2022
Apache License 2.0
src/Day09/Day09.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day09 import Direction import checkAndPrint import directionsTo import measureAndPrintTimeMillis import move import readInput import touches import touchesDiagonally fun main() { fun List<String>.prepareInput() = map { line -> line.split(" ") .let { (first, second) -> v...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
2,156
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day03/Day03.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day03 import runDay fun main() { fun part1(input: List<String>): Int { return input.mapToRucksacks() .map { rucksack -> rucksack.first.find { rucksack.second.contains(it) }!! } .map(Char::priority) .sum() } fun part2(input: L...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
1,133
advent-of-code-2022
Apache License 2.0
src/questions/LengthOfLongestIncreasingSubSeq.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe /** * Given an integer array nums, return the length of the longest strictly increasing subsequence. * A subsequence is a sequence that can be derived from an array by deleting some or no elements * without changing the order of the re...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,562
algorithms
MIT License
kotlin/src/main/kotlin/Saddlepoint.kt
funfunStudy
93,757,087
false
null
fun main(args: Array<String>) { val test1 = listOf( listOf(9, 8, 7), listOf(5, 3, 2), listOf(6, 6, 7)) val test2 = listOf( listOf(1, 2, 3), listOf(3, 1, 2), listOf(2, 3, 1)) val test3 = listOf( listOf(4, 5, 4), ...
0
Kotlin
3
14
a207e4db320e8126169154aa1a7a96a58c71785f
1,363
algorithm
MIT License
src/test/kotlin/com/igorwojda/list/minsublistlength/solution.kt
handiism
455,862,994
true
{"Kotlin": 218721}
package com.igorwojda.list.minsublistlength // Time complexity: O(n) // Space complexity O(n) // Use sliding window private object Solution1 { fun minSubListLength(list: List<Int>, sum: Int): Int { var total = 0 var start = 0 var end = 0 var minLen: Int? = null while (start...
1
Kotlin
2
1
413316e0e9de2f237d9768cfa68db3893e72b48c
2,292
kotlin-coding-challenges
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day13.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputSplitOnBlank object Day13 : Day { override val input = parse() override fun part1(): Int { return input.mapIndexedNotNull { index, (a, b) -> index.takeIf { a <= b } ...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,474
aoc2022
MIT License
kotlin/saddle-points/src/main/kotlin/Matrix.kt
enolive
96,409,842
false
{"Haskell": 220732, "TypeScript": 92672, "Kotlin": 78063, "Java": 28701, "C#": 1346}
class Matrix(val points: List<List<Int>>) { val saddlePoints: Set<MatrixCoordinate> init { val allPoints = allPoints() saddlePoints = maxInRow(allPoints) intersect minInColumn(allPoints) } fun allPoints(): List<Pair<MatrixCoordinate, Int>> { return points.mapIndexed { ...
81
Haskell
0
0
61a64a04a257b02145310dc6ac2342f986ca0672
1,756
exercism
MIT License
year2023/day11/expansion/src/main/kotlin/com/curtislb/adventofcode/year2023/day11/expansion/ExpandedUniverse.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2023.day11.expansion import com.curtislb.adventofcode.common.collection.mapToSet import com.curtislb.adventofcode.common.geometry.Point import com.curtislb.adventofcode.common.io.forEachLineIndexed import com.curtislb.adventofcode.common.iteration.uniquePairs import java.io.File i...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
4,224
AdventOfCode
MIT License
src/Day11.kt
achugr
573,234,224
false
null
import java.math.BigInteger class ItemRouter(private val router: (BigInteger) -> Monkey) { fun send(item: BigInteger) { router.invoke(item).offer(item) } } class Monkey( private val items: MutableList<BigInteger>, private val operation: (BigInteger) -> BigInteger, private val stressReduces: Bo...
0
Kotlin
0
0
d91bda244d7025488bff9fc51ca2653eb6a467ee
4,300
advent-of-code-kotlin-2022
Apache License 2.0
app/src/test/java/com/terencepeh/leetcodepractice/RecursiveSum.kt
tieren1
560,012,707
false
{"Kotlin": 26346}
package com.terencepeh.leetcodepractice fun sum(arr: IntArray): Int { println("Size = ${arr.size}") return when { arr.isEmpty() -> 0 else -> arr[0] + sum(arr.copyOfRange(1, arr.size)) } } fun count(list: List<Any>): Int { return when { list.isEmpty() -> 0 else -> 1 + co...
0
Kotlin
0
0
427fa2855c01fbc1e85a840d0be381cbb4eec858
760
LeetCodePractice
MIT License
src/main/kotlin/day15/Day15.kt
Ostkontentitan
434,500,914
false
{"Kotlin": 73563}
package day15 import readInput fun puzzle() { val inputs = readInput(15).toRiskMap() // val bestPartOne = RecursivePathfinder().searchOptimalPath(inputs) // println("Best way found in runs: $bestPartOne") // 4246 val revealed = revealActualCave(inputs) val bestPartTwo = BacktrackingPathfinder...
0
Kotlin
0
0
e0e5022238747e4b934cac0f6235b92831ca8ac7
1,185
advent-of-kotlin-2021
Apache License 2.0
src/main/kotlin/asaad/DayFour.kt
Asaad27
573,138,684
false
{"Kotlin": 23483}
package asaad import java.io.File private fun IntRange.containsOneAnother(intRange: IntRange): Boolean { return this.intersect(intRange).size == minOf(intRange.size, this.size) } private fun IntRange.overlap(intRange: IntRange): Boolean { return this.intersect(intRange).isNotEmpty() } private val IntRange.s...
0
Kotlin
0
0
16f018731f39d1233ee22d3325c9933270d9976c
1,205
adventOfCode2022
MIT License
app/src/main/java/com/itscoder/ljuns/practise/algorithm/MergeSort.kt
ljuns
148,606,057
false
{"Java": 26841, "Kotlin": 25458}
package com.itscoder.ljuns.practise.algorithm /** * Created by ljuns at 2019/1/8. * I am just a developer. * 归并排序 * 1、先将数组中间分割,直到无法分割 * 3, 1, 1, 6, 2, 4, 19 * 3, 1, 1, 6 * ...
0
Java
0
0
365062b38a7ac55468b202ebeff1b760663fc676
2,515
Practise
Apache License 2.0
src/day05/Day05.kt
Klaus-Anderson
572,740,347
false
{"Kotlin": 13405}
package day05 import readInput import java.util.* import kotlin.NoSuchElementException import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList fun main() { fun part1(input: List<String>): String { val stacksIndexLine = input.first { line -> line.all { it.isDigi...
0
Kotlin
0
0
faddc2738011782841ec20475171909e9d4cee84
4,123
harry-advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BinaryGapStrategy.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,149
kotlab
Apache License 2.0
2021/src/main/kotlin/com/github/afranken/aoc/Day202103.kt
afranken
434,026,010
false
{"Kotlin": 28937}
package com.github.afranken.aoc import kotlin.math.pow object Day202103 { fun part1(inputs: Array<String>): Int { //every input is expected to have the same size. Take inputs[0] to initialize. val inputLength = inputs[0].length val zeroes = IntArray(inputLength) val ones = IntArra...
0
Kotlin
0
0
0140f68e60fa7b37eb7060ade689bb6634ba722b
4,054
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dp/MaxQuality.kt
yx-z
106,589,674
false
null
package dp import util.OneArray import util.get import util.toCharOneArray // given a method quality: T[1..k] -> Int that taking O(k) time and a string // S[1..n] find the max sum of qualities of each contiguous substring of S fun main(args: Array<String>) { val S = "acejfop".toCharOneArray() // sample method val ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,333
AlgoKt
MIT License
src/main/kotlin/PuzzleModels.kt
Kyle-Falconer
671,044,954
false
null
sealed class PuzzleSolutionResult(val words: List<String>) { fun print() { when (this) { is ValidPuzzleSolution -> { println("${words.stringify()} ✅ valid solution in ${words.size} words") } is IncompletePuzzleSolution -> { println("${word...
0
Kotlin
0
0
32f65f18067d686bb79cf84bdbb30bc880319124
2,038
LetterBoxedPuzzleSolver
Apache License 2.0
module-tool/src/main/kotlin/de/twomartens/adventofcode/day15/CustomHashMap.kt
2martens
729,312,999
false
{"Kotlin": 89431}
package de.twomartens.adventofcode.day15 import java.util.LinkedList data class Lens(val label: String, val focalLength: Int, val boxNumber: Int, val slotNumber: Int) enum class Operation { INSERT, REMOVAL } class CustomHashMap(private val hashAlgorithm: HashAlgorithm) { private val boxLensLabels: Mutab...
0
Kotlin
0
0
03a9f7a6c4e0bdf73f0c663ff54e01daf12a9762
3,343
advent-of-code
Apache License 2.0
domain/src/main/kotlin/com/seanshubin/condorcet/backend/domain/Ranking.kt
SeanShubin
238,518,165
false
null
package com.seanshubin.condorcet.backend.domain import kotlin.math.max import kotlin.random.Random data class Ranking(val candidateName: String, val rank: Int?) { companion object { fun List<Ranking>.prefers(a: String, b: String): Boolean = rankingFor(a) < rankingFor(b) private fun Li...
0
Kotlin
0
0
c6dd3e86d9f722829c57d215fcfa7cb18b7955cd
4,309
condorcet-backend
The Unlicense
src/main/kotlin/com/github/wakingrufus/aoc/Day2.kt
wakingrufus
159,674,364
false
null
package com.github.wakingrufus.aoc import mu.KLogging val letters = ('a'..'z') class Day2 { companion object : KLogging() fun processInput(): List<String> = inputFileToLines("input-day2.txt") fun checksum(boxIds: List<String>): Int { val twos = boxIds.count { id -> letters.any { let...
0
Kotlin
0
0
bdf846cb0e4d53bd8beda6fdb3e07bfce59d21ea
1,771
advent-of-code-2018
MIT License
src/Day04.kt
colund
573,040,201
false
{"Kotlin": 10244}
fun fullyContained(min1: Int, max1: Int, min2: Int, max2: Int): Boolean { return (min1 <= min2 && max1 >= max2) || (min2 <= min1 && max2 >= max1) } fun partiallyOverlap(min1: Int, max1: Int, min2: Int, max2: Int): Boolean { return (max1 in min2..max2) || (max2 in min1..max1) } fun main() { println("Day4 p...
0
Kotlin
0
0
49dcd2fccad0e54ee7b1a9cb99df2acdec146759
885
aoc-kotlin-2022
Apache License 2.0
src/Day01.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
fun main() { fun generateListOfSums(lines: List<String>): List<Int> { var currentSum: Int = 0 val sums : MutableList<Int> = ArrayList<Int>() lines.forEach{line -> if(line.isEmpty()){ sums.add(currentSum) currentSum = 0 } ...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
972
AoC2022
Apache License 2.0
instantsearch/src/commonMain/kotlin/com/algolia/instantsearch/filter/facet/dynamic/internal/FacetsOrder.kt
algolia
55,971,521
false
{"Kotlin": 689459}
package com.algolia.instantsearch.filter.facet.dynamic.internal import com.algolia.instantsearch.filter.facet.dynamic.AttributedFacets import com.algolia.search.model.Attribute import com.algolia.search.model.rule.FacetOrdering import com.algolia.search.model.rule.FacetValuesOrder import com.algolia.search.model.rule....
15
Kotlin
32
155
cb068acebbe2cd6607a6bbeab18ddafa582dd10b
1,895
instantsearch-android
Apache License 2.0
src/problems/day8/part1/part1.kt
klnusbaum
733,782,662
false
{"Kotlin": 43060}
package problems.day8.part1 import java.io.File //private const val test1file = "input/day8/test1.txt" //private const val test2file = "input/day8/test2.txt" private const val inputFile = "input/day8/input.txt" fun main() { val stepsCount = File(inputFile).bufferedReader().useLines { numSteps(it) } println("...
0
Kotlin
0
0
d30db2441acfc5b12b52b4d56f6dee9247a6f3ed
2,438
aoc2023
MIT License
src/main/kotlin/com/staricka/adventofcode2023/days/Day16.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day import com.staricka.adventofcode2023.util.Grid import com.staricka.adventofcode2023.util.GridCell import com.staricka.adventofcode2023.util.StandardGrid import java.util.LinkedList import kotlin.math.max class MirrorGridTile...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
3,780
adventOfCode2023
MIT License
src/Day05.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
import java.util.ArrayDeque import java.util.Deque fun main() { fun part1(input: List<String>): String { val stacks = parseStacks(input.takeWhile { it.isNotBlank() }) val instructions = input.dropWhile { it.isNotBlank() }.drop(1) applyInstructions(instructions) { howMany, from, to -> ...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
2,770
advent-of-code-2022-kotlin
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day16/Day16.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
3,858
AdventOfCode
Apache License 2.0
puzzles/kotlin/src/skynet-revolution2/skynet-revolution2.kt
charlesfranciscodev
179,561,845
false
{"Python": 141140, "Java": 34848, "Kotlin": 33981, "C++": 27526, "TypeScript": 22844, "C#": 22075, "Go": 12617, "JavaScript": 11282, "Ruby": 6255, "Swift": 3911, "Shell": 3090, "Haskell": 1375, "PHP": 1126, "Perl": 667, "C": 493}
import java.util.Scanner import java.util.ArrayDeque fun main(args : Array<String>) { val graph = Graph() graph.readInitInput() graph.gameLoop() } class Node(val index:Int) { val links = ArrayList<Node>() var isGateway = false var isMarked = false fun nbGatewayLinks() : Int { return links.count { i...
0
Python
19
45
3ec80602e58572a0b7baf3a2829a97e24ca3460c
3,989
codingame
MIT License
src/main/kotlin/tw/gasol/aoc/aoc2022/Day7.kt
Gasol
574,784,477
false
{"Kotlin": 70912, "Shell": 1291, "Makefile": 59}
package tw.gasol.aoc.aoc2022 import java.util.Scanner import kotlin.math.abs interface Filesystem { val name: String val size: Int } data class File( override val name: String, override val size: Int, val parent: Directory? = null ) : Filesystem data class Directory( override val name: Strin...
0
Kotlin
0
0
a14582ea15f1554803e63e5ba12e303be2879b8a
5,162
aoc2022
MIT License
src/Day22.kt
flex3r
572,653,526
false
{"Kotlin": 63192}
suspend fun main() { val testInput = readInput("Day22_test") check(part1(testInput) == 6032) check(part2(testInput) == 5031) val input = readInput("Day22") measureAndPrintResult { part1(input) } measureAndPrintResult { part2(input) } } private fun part1(input: List<Stri...
0
Kotlin
0
0
8604ce3c0c3b56e2e49df641d5bf1e498f445ff9
10,542
aoc-22
Apache License 2.0
day08/src/main/kotlin/Main.kt
rstockbridge
225,212,001
false
null
import extensions.charCounts fun main() { val input = resourceFile("input.txt") .readText() val image = parseInput(input, 25, 6) println("Part I: the solution is ${solvePartI(image)}.") println("Part II: the solution is:") solvePartII(image) } fun parseInput(input: String, width: Int, he...
0
Kotlin
0
0
bcd6daf81787ed9a1d90afaa9646b1c513505d75
2,185
AdventOfCode2019
MIT License
src/day08/Day08.kt
Longtainbin
573,466,419
false
{"Kotlin": 22711}
package day08 import readInput import kotlin.math.max fun main() { val input = readInput("inputDay08") val matrix = createMatrix(input) println(processPart1(matrix)) println(processPart2(matrix)) } private fun createMatrix(input: List<String>): Array<IntArray> { val row = input.size val ...
0
Kotlin
0
0
48ef88b2e131ba2a5b17ab80a0bf6a641e46891b
2,527
advent-of-code-2022
Apache License 2.0
codeforces/round773/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round773 private fun solve() { readInt() val a = readInts().toIntArray() val groups = a.groupBy { it } if (groups.values.any { it.size % 2 != 0 }) return println(-1) var start = 0 val insertions = mutableListOf<Pair<Int, Int>>() val tandems = mutableListOf<Int>() var x = 0 while (start < a....
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,104
competitions
The Unlicense
src/main/kotlin/g2201_2300/s2251_number_of_flowers_in_full_bloom/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2251_number_of_flowers_in_full_bloom // #Hard #Array #Hash_Table #Sorting #Binary_Search #Prefix_Sum #Ordered_Set // #2023_06_28_Time_973_ms_(100.00%)_Space_88.6_MB_(100.00%) import java.util.Arrays import java.util.PriorityQueue class Solution { fun fullBloomFlowers(flowers: Array<IntArray>,...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,547
LeetCode-in-Kotlin
MIT License
cz.wrent.advent/Day14.kt
Wrent
572,992,605
false
{"Kotlin": 206165}
package cz.wrent.advent fun main() { println(partOne(test)) val result = partOne(input) println("14a: $result") println(partTwo(test)) println("14b: ${partTwo(input)}") } private fun partOne(input: String): Int { return simulate(input, withFloor = false) } private fun simulate(input: String, withFloor: Boolean...
0
Kotlin
0
0
8230fce9a907343f11a2c042ebe0bf204775be3f
28,910
advent-of-code-2022
MIT License