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/Day01.kt
lbilger
574,227,846
false
{"Kotlin": 5366}
fun main() { fun caloriesList(input: List<String>) = input.fold(listOf<Int>()) { acc, line -> if (line.isEmpty()) acc + 0 else acc.dropLast(1) + ((acc.lastOrNull() ?: 0) + line.toInt()) } fun part1(input: List<String>): Int { return caloriesList(input).max() } fun part2(input: List<Str...
0
Kotlin
0
0
40d94a4bb9621af822722d20675684555cbee877
725
aoc-2022-in-kotlin
Apache License 2.0
2015/src/main/kotlin/day5_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution fun main() { Day5Func.run() } object Day5Func : Solution<List<String>>() { override val name = "day5" override val parser = Parser.lines override fun part1(): Int { return input .filter { word -> word.toCharArray().filter { it in setOf('a', 'e', 'i', 'o', '...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,005
aoc_kotlin
MIT License
src/test/kotlin/com/winterbe/challenge/FindPairs.kt
winterbe
152,978,821
false
null
package com.winterbe.challenge import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test /** * Given an integer array and number k, output all unique pairs that sum up to k. * Example: for input [1, 3, 2, 5, 46, 6, 7, 4] and k = 4, output (1, 3). */ fun findPairs(k: Int, array: Array<I...
0
Kotlin
4
10
3a0a911e4f601261ddb544da86647530371c8ba9
2,051
challenge
MIT License
src/main/kotlin/adventofcode2018/Day12SubterraneanSustainability.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2018 class Day12SubterraneanSustainability data class PotRule(val input: String, val result: Char) { companion object { fun fromString(rule: String): PotRule { return PotRule(rule.substringBefore(" ="), rule.last()) } } } class RulesSet(val rules: List<PotRule>...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
2,464
kotlin-coding-challenges
MIT License
src/main/kotlin/g1101_1200/s1192_critical_connections_in_a_network/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1101_1200.s1192_critical_connections_in_a_network // #Hard #Depth_First_Search #Graph #Biconnected_Component // #2023_05_25_Time_1696_ms_(60.00%)_Space_237.1_MB_(40.00%) class Solution { fun criticalConnections(n: Int, connections: List<List<Int>>): List<List<Int>> { val graph: MutableList<Mutabl...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,113
LeetCode-in-Kotlin
MIT License
src/main/kotlin/algorithms/sorting/merge_sort/MergeSort.kt
AANikolaev
273,465,105
false
{"Java": 179737, "Kotlin": 13961}
package algorithms.sorting.merge_sort import algorithms.sorting.InplaceSort class MergeSort : InplaceSort { override fun sort(values: IntArray) { val sortedValues = mergeSort(values) for (i in values.indices) { values[i] = sortedValues[i] } } private fun mergeSort(ar...
0
Java
0
0
f9f0a14a5c450bd9efb712b28c95df9a0d7d589b
1,401
Algorithms
MIT License
kotest-mpp/src/commonMain/kotlin/io/kotest/mpp/reflection.kt
ca-r0-l
258,232,982
true
{"Kotlin": 2272378, "HTML": 423, "Java": 153}
package io.kotest.mpp import kotlin.reflect.KClass /** * Returns the longest possible name available for this class. * That is, in order, the FQN, the simple name, or toString. */ fun KClass<*>.bestName(): String = fqn() ?: simpleName ?: this.toString() /** * Returns the fully qualified name for this class, or n...
1
null
0
1
e176cc3e14364d74ee593533b50eb9b08df1f5d1
1,301
kotest
Apache License 2.0
ceria/18/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Long { var total = 0L for (line in input) { total += evalExpression(line, tr...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
2,404
advent-of-code-2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ScrambleString.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,993
kotlab
Apache License 2.0
src/main/kotlin/Day12.kt
i-redbyte
433,743,675
false
{"Kotlin": 49932}
import java.util.* const val START = "start" const val END = "end" val ALPHABET = 'a'..'z' fun makeGraph(data: List<String>): HashMap<String, HashSet<String>> { val graph = HashMap<String, HashSet<String>>() for (s in data) { val (x, y) = s.split("-") graph.getOrPut(x) { HashSet() }.add(y) ...
0
Kotlin
0
0
6d4f19df3b7cb1906052b80a4058fa394a12740f
1,881
AOC2021
Apache License 2.0
src/adventOfCode/day11Problem.kt
cunrein
159,861,371
false
null
package adventOfCode data class PowerGrid(val xMax: Int, val yMax: Int, val sn: Int) { val grid = Array(xMax) { Array(yMax) { 0 } } init { for (x in 0 until xMax) { for (y in 0 until yMax) { grid[x][y] = powerLevel(sn, x, y) } } } private fun po...
0
Kotlin
0
0
3488ccb200f993a84f1e9302eca3fe3977dbfcd9
1,896
ProblemOfTheDay
Apache License 2.0
Algorithm/HackerRank/src/OrganizingContainersOfBalls.kt
chaking
180,269,329
false
{"JavaScript": 118156, "HTML": 97206, "Jupyter Notebook": 93471, "C++": 19666, "Kotlin": 14457, "Java": 8536, "Python": 4928, "Swift": 3893, "Makefile": 2257, "Scala": 890, "Elm": 191, "CSS": 56}
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
JavaScript
0
0
a394f100155fa4eb1032c09cdc85816b7104804b
1,522
study
MIT License
src/main/kotlin/de/niemeyer/aoc2022/Day21.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 21: Monkey Math * Problem Description: https://adventofcode.com/2022/day/21 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { val root = "root" val human = "humn" abstract class Mo...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
5,587
AoC-2022
Apache License 2.0
src/datastructure/heap/StreamMax.kt
minielectron
332,678,510
false
{"Java": 127791, "Kotlin": 48336}
package datastructure.heap /** * <> Heap: Maximum Element in a Stream Implement a function named streamMax that processes a stream of integers and returns the maximum number encountered so far for each input number. This function should take in an array of integers and return a list of integers. Given an array of int...
0
Java
0
0
f2aaff0a995071d6e188ee19f72b78d07688a672
1,764
data-structure-and-coding-problems
Apache License 2.0
hacker-rank/sorting/FraudulentActivityNotifications.kt
piazentin
62,427,919
false
{"Python": 34824, "Jupyter Notebook": 29307, "Kotlin": 19570, "C++": 2465, "R": 2425, "C": 158}
// https://www.hackerrank.com/challenges/fraudulent-activity-notifications/problem fun main() { val (_, days) = readLine().orEmpty().trim().split(" ").map(String::toInt) val expenditures = readLine().orEmpty().trim().split(" ").map(String::toInt).toTypedArray() fraudulentActivityNotifications(days, expend...
0
Python
0
0
db490b1b2d41ed6913b4cacee1b4bb40e15186b7
1,560
programming-challenges
MIT License
src/Day07.kt
jsebasct
572,954,137
false
{"Kotlin": 29119}
import java.math.BigInteger data class FileDevice( val name: String, var size: Int = 0, val content: MutableMap<String, FileDevice>? = null, val isDirectory: Boolean = false, val parentDirectory: FileDevice? = null, ) { override fun equals(other: Any?): Boolean { if (this === other) ret...
0
Kotlin
0
0
c4a587d9d98d02b9520a9697d6fc269509b32220
5,530
aoc2022
Apache License 2.0
src/Day03.kt
topr
572,937,822
false
{"Kotlin": 9662}
fun main() { val allItems = (('a'..'z') + ('A'..'Z')).toSet() fun commonItem(compartments: Iterable<String>) = compartments .map(CharSequence::toSet) .fold(allItems) { acc, compartment -> acc.intersect(compartment) } .first() fun priority(item: Char): Int = item.code.inc()...
0
Kotlin
0
0
8c653385c9a325f5efa2895e94830c83427e5d87
915
advent-of-code-kotlin-2022
Apache License 2.0
src/Day23.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { val input = readInput("Day23") fun solve(part2: Boolean): Int { val map = input.map { it.toCharArray() } var res = 0 fun dfs(i: Int, j: Int, d: Int) { if (i !in map.indices || j !in map[i].indices || map[i][j] == '#' || map[i][j] == 'o') return if (i ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,389
advent-of-code-kotlin
Apache License 2.0
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day12.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput import kotlin.math.* class Day12 : Day<Long> { private sealed class Action { data class Add(val direction: Direction, val units: Int) : Action() data class TurnLeft(val angle: Int) :...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
4,720
adventofcode
Apache License 2.0
src/chapter5/section1/SpecificAlphabet.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section1 import chapter3.section4.LinearProbingHashST /** * 指定具体字母的字母表 */ class SpecificAlphabet(s: String) : Alphabet { private val st = LinearProbingHashST<Char, Int>() private val reverseST = LinearProbingHashST<Int, Char>() private var size = 0 init { for (i in s.indice...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,362
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/RepeatedNTimes.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,689
kotlab
Apache License 2.0
src/main/kotlin/g0901_1000/s0928_minimize_malware_spread_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0928_minimize_malware_spread_ii // #Hard #Array #Depth_First_Search #Breadth_First_Search #Matrix #Union_Find // #2023_04_26_Time_716_ms_(100.00%)_Space_63.5_MB_(100.00%) import java.util.LinkedList import java.util.Queue class Solution { private val adj: MutableMap<Int, ArrayList<Int>> = Has...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,929
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/leetcode/P37.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://github.com/antop-dev/algorithm/issues/459 class P37 { fun solveSudoku(board: Array<CharArray>) { solve(board, 0) } private fun solve(board: Array<CharArray>, pos: Int): Boolean { if (pos == 81) { return true } val y = pos / 9 ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,680
algorithm
MIT License
facebook/y2021/round1/a3.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package facebook.y2021.round1 private fun solve(M: Int = 1_000_000_007): Int { readLn() val s = readLn() var firstChar = 0.toChar() var lastChar = 0.toChar() var firstPos = -1 var lastPos = -1 var length = 0 var pairs = 0 var leftTicks = 0 var rightTicks = 0 var answer = 0 for (i in s.indices) { if (s[...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,817
competitions
The Unlicense
src/y2016/Day09.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.readInput object Day09 { fun part1(input: List<String>) { input.forEach { println("${decompressedLength(it)} $it") } } private fun decompressedLength(str: String): Int { val firstStart = str.indexOf('(') if (firstStart == -1) { ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,795
advent-of-code
Apache License 2.0
kotlin.kt
darian-catalin-cucer
598,114,020
false
null
class BTree<Key : Comparable<Key>, Value> { private val t = 2 // Minimum degree of the B-Tree node private var root: Node<Key, Value>? = null private class Node<Key : Comparable<Key>, Value>(var n: Int = 0, var leaf: Boolean = false) { var keys = arrayOfNulls<Key>(2 * t - 1) var values = ...
0
Kotlin
0
0
acd9827f1ebe29bca71ebf1254f47eb6f1ba6c57
2,514
b-tree
MIT License
src/main/kotlin/g2501_2600/s2581_count_number_of_possible_root_nodes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2581_count_number_of_possible_root_nodes // #Hard #Hash_Table #Dynamic_Programming #Depth_First_Search #Tree // #2023_07_11_Time_1352_ms_(100.00%)_Space_138.7_MB_(100.00%) import java.util.ArrayList import java.util.HashSet @Suppress("NAME_SHADOWING") class Solution { private lateinit var par...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,837
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day11/Day11.kt
mdenburger
317,466,663
false
null
import java.io.File import java.lang.Integer.max import kotlin.math.absoluteValue fun main() { val seatLayout = File("src/main/kotlin/day11/day11-input.txt").readLines().map { it.toCharArray() } var current = seatLayout var currentHashCode = current.contentHashCode() val found = mutableSetOf<Int>() ...
0
Kotlin
0
0
b965f465cad30f949874aeeacd8631ca405d567e
2,300
aoc-2020
MIT License
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/sorting/fraud/ActivityNotifications.kt
slobanov
200,526,003
false
null
package ru.amai.study.hackerrank.practice.interviewPreparationKit.sorting.fraud import java.util.* private const val MAX_EXPENDITURE = 201 fun activityNotifications(expenditure: IntArray, d: Int): Int { val counts = buildCounts(expenditure, d) return (d until expenditure.size).count { i -> val media...
0
Kotlin
0
0
2cfdf851e1a635b811af82d599681b316b5bde7c
1,506
kotlin-hackerrank
MIT License
src/main/kotlin/Day07.kt
SimonMarquis
570,868,366
false
{"Kotlin": 50263}
import java.nio.file.Path import java.nio.file.Paths import kotlin.io.path.div class Day07(input: List<String>) { private val fs = FileSystem(input) fun part1() = fs.dirsWithSize() .filter { (_, size) -> size <= 100_000 }.values .sum() fun part2() = fs.dirsWithSize().let { dirs -> ...
0
Kotlin
0
0
a2129cc558c610dfe338594d9f05df6501dff5e6
1,570
advent-of-code-2022
Apache License 2.0
src/leetcode_study_badge/data_structure/Day15.kt
faniabdullah
382,893,751
false
null
package leetcode_study_badge.data_structure import data_structure.tree.TreeNode import data_structure.tree.TreeTraversal class Day15 { fun sortedArrayToBST(nums: IntArray): TreeNode? { return partition(0, nums.size - 1, nums) } private fun partition(left: Int, right: Int, nums: IntArray): TreeNo...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,648
dsa-kotlin
MIT License
leetcode/src/offer/middle/Offer67.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 67. 把字符串转换成整数 // https://leetcode.cn/problems/ba-zi-fu-chuan-zhuan-huan-cheng-zheng-shu-lcof/ println(strToInt1("42")) } fun strToInt(str: String): Int { var result = 0 var index = 0 // 边界 val boundary = Int.MAX_VALUE / 10 while (index < s...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
3,042
kotlin-study
MIT License
src/aoc2022/Day25.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.checkEquals import kotlin.math.roundToLong fun main() { val system = mapOf('=' to -2L, '-' to -1L, '0' to 0L, '1' to 1L, '2' to 2L) val xSystem = system.map { it.value to it.key }.toMap() tailrec fun toSnafu(acc: String, n: Long): String { if (n < 1) return acc ...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,061
Kotlin-AOC-2023
Apache License 2.0
2021/src/main/kotlin/sh/weller/aoc/Day05.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc import kotlin.math.abs object Day05 : SomeDay<CoordinatePair, Int> { override fun partOne(input: List<CoordinatePair>): Int { val size = input.maxOf { it.maxOf() } val map: HeightMap = (0..size).map { (0..size).map { 0 }.toMutableList() }.toMutableList() for (coordin...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
4,534
AdventOfCode
MIT License
src/main/kotlin/com/staricka/adventofcode2022/Day8.kt
mathstar
569,952,400
false
{"Kotlin": 77567}
package com.staricka.adventofcode2022 import kotlin.math.max class Day8 : Day { override val id = 8 override fun part1(input: String): Any { val visible = HashSet<Pair<Int, Int>>() val grid = input.lines() for (i in grid.indices) { var maxHeight = -1 for (j in grid[i].indices) { i...
0
Kotlin
0
0
2fd07f21348a708109d06ea97ae8104eb8ee6a02
2,231
adventOfCode2022
MIT License
src/Day06.kt
zhiqiyu
573,221,845
false
{"Kotlin": 20644}
import java.util.Queue import java.util.Stack fun main() { fun part1(input: List<String>): List<Int> { var result = ArrayList<Int>() for (line in input) { var queue = ArrayDeque<Char>(0) for (i in line.indices) { if (queue.size < 4) { que...
0
Kotlin
0
0
d3aa03b2ba2a8def927b94c2b7731663041ffd1d
1,676
aoc-2022
Apache License 2.0
src/week4/LongestConsecutive.kt
anesabml
268,056,512
false
null
package week4 import kotlin.math.max class LongestConsecutive { /** Brute force * Time complexity : O(n3) * Space complexity : O(1) */ fun longestConsecutive(nums: IntArray): Int { var maxCount = 0 for (num in nums) { var currentNumber = num var currentC...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
1,975
leetCode
Apache License 2.0
src/Day2/December2.kt
Nandi
47,216,709
false
null
package Day2 import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Stream /** * 2.December challenge from www.adventofcode.com * * Part 1 * * The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the * dimensions (length l, width w...
0
Kotlin
0
0
34a4b4c0926b5ba7e9b32ca6eeedd530f6e95bdc
2,684
adventofcode
MIT License
day14/src/Day14.kt
simonrules
491,302,880
false
{"Kotlin": 68645}
import java.io.File class Day14(path: String) { private var template: String = "" private val rules = mutableMapOf<String, Char>() private var pairs = mutableMapOf<String, Long>() init { var line = 0 File(path).forEachLine { if (line == 0) { template = it ...
0
Kotlin
0
0
d9e4ae66e546f174bcf66b8bf3e7145bfab2f498
3,850
aoc2021
Apache License 2.0
src/main/kotlin/days/Day8.kt
broersma
574,686,709
false
{"Kotlin": 20754}
package days class Day8 : Day(8) { override fun partOne(): Int { val height = inputList.size val width = inputList[0].length val map = Array(height) { IntArray(width) } for (y in 0..height - 1) { for (x in 0..width - 1) { map[y][x] = inputList[y][x].dig...
0
Kotlin
0
0
cd3f87e89f7518eac07dafaaeb0f6adf3ecb44f5
2,417
advent-of-code-2022-kotlin
Creative Commons Zero v1.0 Universal
src/Day06.kt
lsimeonov
572,929,910
false
{"Kotlin": 66434}
fun main() { fun findAnswer(s: String, l: Int): Int? { val b = ArrayDeque<Char>() s.toList().forEachIndexed { i, c -> b.addFirst(c) if (b.toSet().count() == l) { return i+1 } if (b.count() == l) { b.removeLast() ...
0
Kotlin
0
0
9d41342f355b8ed05c56c3d7faf20f54adaa92f1
975
advent-of-code-2022
Apache License 2.0
src/_004/kotlin/Solution.kt
RichCodersAndMe
127,856,921
false
null
package _004.kotlin /** * @author relish * @since 2018/10/20 */ class Solution { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val len = nums1.size + nums2.size return if (len % 2 == 0) { (fix(nums1, 0, nums2, 0, len / 2) + fix(nums1, 0, nums2, 0, len / 2 + 1...
0
Java
4
22
96119bbc34d4655d017b57b19304890fbb142142
1,336
LeetCode-Solution
MIT License
src/main/kotlin/days/Day18.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days import days.Day14.Direction import xyz.hughjd.aocutils.Coords.Coord import kotlin.math.abs class Day18 : Day(18) { override fun partOne(): Any { val (perimeter, vertices) = getPerimeterAndVertices(parseInstructions()) return getInteriorPoints(perimeter, vertices) } override ...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
3,339
aoc-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Day8.kt
vovarova
572,952,098
false
{"Kotlin": 103799}
package days class Day8 : Day(8) { val treeMap = inputList.map { it.toCharArray().map { it.digitToInt() }.toList() } fun isVisible(rows: IntProgression, columns: IntProgression, compareValue: Int): Boolean { return rows.flatMap { row -> columns.map { row to it } } .all { treeMap[it.first]...
0
Kotlin
0
0
e34e353c7733549146653341e4b1a5e9195fece6
3,934
adventofcode_2022
Creative Commons Zero v1.0 Universal
src/commonMain/kotlin/sequences/MultiTransforms.kt
tomuvak
511,086,330
false
{"Kotlin": 92304, "Shell": 619}
package com.tomuvak.util.sequences /** * Returns a list of sequences, each of which is the result of running the corresponding transform (of the given * [transforms]) on a sequence equivalent to (that is comprising the same elements as) the receiver sequence [this]. * Iterating over (any or all of) the returned seq...
0
Kotlin
0
0
e20cfae9535fd9968542b901c698fdae1a24abc1
3,466
util
MIT License
src/main/kotlin/days/Day2.kt
mir47
433,536,325
false
{"Kotlin": 31075}
package days class Day2 : Day(2) { override fun partOne(): Int { val xy = inputList .fold(Pair(0, 0)) { sumPair, line -> val dir = line.split(" ")[0] val units = line.split(" ")[1].toInt() when (dir) { "forward" -> Pair(sumPai...
0
Kotlin
0
0
686fa5388d712bfdf3c2cc9dd4bab063bac632ce
1,067
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/Excercise06.kt
underwindfall
433,989,850
false
{"Kotlin": 55774}
import java.math.BigInteger private fun getSpawnCount( memo: MutableMap<Pair<Int, Int>, BigInteger>, timer: Int, days: Int ): BigInteger { val memoKey = Pair(timer, days) if (timer >= days) return BigInteger("1") if (memo.containsKey(memoKey)) return memo.getValue(memoKey) memo[memoKey] = getSpawnCo...
0
Kotlin
0
0
4fbee48352577f3356e9b9b57d215298cdfca1ed
1,005
advent-of-code-2021
MIT License
src/main/java/challenges/cracking_coding_interview/trees_graphs/route_between_nodes/Question.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.route_between_nodes import java.util.* /** * Given a directed graph, design an algorithm to find out * whether there is a route between two nodes. */ object Question { @JvmStatic fun main(a: Array<String>) { val g = createNewGraph() ...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,059
CodingChallenges
Apache License 2.0
src/main/kotlin/courseraWeek2/Funcional.kt
SebastianCerquera
587,973,890
false
null
package courseraWeek2 val heroes = listOf( Hero("The Captain", 60, Gender.MALE), Hero( "Frenchy", 42, Gender.MALE), Hero( "The kid", 9, null), Hero( "<NAME>", 29, Gender.FEMALE), Hero( "<NAME>", 29, Gender.MALE), Hero( "<NAME>", 37, Gender.MALE) ) fun main() { //encontrar el último nombre ...
0
Kotlin
0
0
46dedbff8e7e1c505d352bfb60909fc623585eef
1,975
from-java-to-kotlin
Apache License 2.0
src/Day01.kt
Aldas25
572,846,570
false
{"Kotlin": 106964}
fun main() { fun part1(input: List<String>): Int { var answer = 0 var currentElf = 0 for (s in input) { if (s.isBlank()) { currentElf = 0 } else { currentElf += s.toInt() } answer = maxOf(answer, currentElf) ...
0
Kotlin
0
0
80785e323369b204c1057f49f5162b8017adb55a
1,099
Advent-of-Code-2022
Apache License 2.0
kotlin/src/katas/kotlin/skiena/graphs/MinSpanningTree.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.WeightedGraphs.diamondGraph import katas.kotlin.skiena.graphs.WeightedGraphs.linearGraph import katas.kotlin.skiena.graphs.WeightedGraphs.exampleGraph import katas.kotlin.skiena.graphs.WeightedGraphs.triangleGraph import datsok.shouldEqual import org...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,910
katas
The Unlicense
src/main/kotlin/g0501_0600/s0556_next_greater_element_iii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0556_next_greater_element_iii // #Medium #String #Math #Two_Pointers #Programming_Skills_II_Day_10 // #2023_01_20_Time_137_ms_(80.00%)_Space_32.6_MB_(60.00%) @Suppress("NAME_SHADOWING") class Solution { /* - What this problem wants is finding the next permutation of n - Steps to find t...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,120
LeetCode-in-Kotlin
MIT License
src/year2023/18/Day18.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`18` import readInput import utils.printDebug import utils.printlnDebug import kotlin.math.absoluteValue private const val CURRENT_DAY = "18" private data class Point( val x: Int, val y: Int, ) { val left get() = Point(x - 1, y) val right get() = Point(x + 1, y) val top get() = P...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
6,267
KotlinAdventOfCode
Apache License 2.0
kotlin/src/main/java/com/samelody/samples/kotlin/algorithms/mergeSort.kt
belinwu
140,991,591
false
{"Kotlin": 70895, "Java": 1117}
package com.samelody.samples.kotlin.algorithms import com.samelody.samples.kotlin.example fun IntArray.mergeSort(low: Int, high: Int) { if (low >= high) return val mid = (low + high) / 2 mergeSort(low, mid) mergeSort(mid + 1, high) merge(low, mid, high) } fun IntArray.merge(low: Int, mid: Int, hi...
0
Kotlin
0
2
dce2b98cb031df6bbf04cfc576541a2d96134b5d
1,048
samples
Apache License 2.0
kotlin/src/main/kotlin/com/ximedes/aoc/day01/ReportRepair.kt
rolfchess
314,041,772
false
null
package com.ximedes.aoc.day01 import com.javamonitor.tools.Stopwatch import com.ximedes.aoc.util.getClasspathFile fun main() { val sw = Stopwatch("Day 1", "load input") val ints = mutableSetOf<Int>() getClasspathFile("/input-1.txt").forEachLine { ints.add(it.toInt()) } sw.aboutTo("find pa...
0
Kotlin
0
0
e666ef0358980656e1c52a3ec08482dd7f86e8a3
1,788
aoc-2020
The Unlicense
ceria/06/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; fun main(args : Array<String>) { val input = File(args.first()).readLines().first().split(",").map { it.toInt() } println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input: List<Int>) :Long { return copulate(80, input) } p...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
1,233
advent-of-code-2021
MIT License
src/Day02.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
fun main() { fun solvePart1(input: List<String>): Int { var res = 0 for (line in input) { val (a, b) = line.split(" ") res += (b[0] - 'X') + 1 when (((a[0] - 'A') - (b[0] - 'X') + 3) % 3) { 0 -> res += 3 2 -> res += 6 } ...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
854
AoC-2022-kotlin
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day02.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day02.run() object Day02 : Day(2022, 2) { override fun part1() : Any { return input.lines() .map { it.split(" ") } .map{(a,x) -> when(a to x) { "A" to "X" -> 3 + 1 ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,223
adventofkotlin
MIT License
src/main/java/Exercise19.kt
cortinico
317,667,457
false
null
fun main() { val input = object {}.javaClass.getResource("input-19.txt").readText().split("\n\n") val rules = input[0].split("\n").map { it.split(": ") }.associateBy({ it[0] }, { it[1] }) input[1].split("\n").count { matches(it.toCharArray(), 0, rules, listOf("0")) }.also(::println) } fun matches( in...
1
Kotlin
0
4
a0d980a6253ec210433e2688cfc6df35104aa9df
1,170
adventofcode-2020
MIT License
src/Day06.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.util.LinkedList import java.util.Queue fun main() { val testInputs = listOf<String>( "bvwbjplbgvbhsrlpgdmjqwftvncz", "nppdvjthqldpwncqszvftbrmjlhg", "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg", "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" ) val testOutputs = testInputs.map { part...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
1,742
advent-of-code-2022-kotlin
Apache License 2.0
classroom/src/main/kotlin/com/radix2/algorithms/week3/TraditionalQuickSort.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week3 import java.util.* fun less(lhs: Int, rhs: Int) = lhs < rhs fun exch(array: IntArray, i: Int, j: Int) { val temp = array[i] array[i] = array[j] array[j] = temp } fun shuffle(array: IntArray) { val rnd = Random() for (i in 1 until array.size) { val ran...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,232
coursera-algorithms-part1
Apache License 2.0
src/Day10.kt
phoenixli
574,035,552
false
{"Kotlin": 29419}
fun main() { fun part1(input: List<String>): Int { return sumSignalStrength(input) } fun part2(input: List<String>): Int { draw(input) return input.size } val input = readInput("Day10") println(part1(input)) println(part2(input)) } fun sumSignalStrength(input: List...
0
Kotlin
0
0
5f993c7b3c3f518d4ea926a792767a1381349d75
1,700
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/days/Day101.kt
mstar95
317,305,289
false
null
package days import intcode.IntCodeProgram class Day101 : Day(101) { override fun partOne(): Any { val programs = inputList val outputs = programs.map { compute(it) } return outputs.map { it.toString() } } fun compute(program: String): Int { val programInput = program.sp...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
1,232
aoc-2020
Creative Commons Zero v1.0 Universal
common/src/commonMain/kotlin/ticketToRide/scoreCalculation.kt
Kiryushin-Andrey
253,543,902
false
{"Kotlin": 278687, "Dockerfile": 845, "JavaScript": 191}
package ticketToRide import graph.* import kotlinx.collections.immutable.persistentMapOf // build a weighted graph of all segments occupied by the player fun buildSegmentsGraph(occupiedSegments: List<Segment>): Graph<String> { val segments = occupiedSegments.map { GraphSegment(it.from.value, it.to.value, it.lengt...
1
Kotlin
3
11
0ad7aa0b79f7d97cbac6bc4cd1b13b6a1d81e442
2,508
TicketToRide
MIT License
2021/src/day25/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day25 import java.nio.file.Files import java.nio.file.Paths import kotlin.system.measureTimeMillis fun main() { fun part1(input: Input): Int { val field = input.map { it.toCharArray() } var moves = 0 val herds = ">v" val di = intArrayOf(0, 1) val dj = intArrayOf(1, 0) val moved = arr...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
1,449
advent-of-code
Apache License 2.0
src/Day05.kt
paul-griffith
572,667,991
false
{"Kotlin": 17620}
private typealias SupplyStack = List<ArrayDeque<Char>> fun main() { fun SupplyStack.debug() { val maxStack = maxOf { it.size } for (i in maxStack downTo 0) { forEach { column -> val value = column.getOrNull(i) if (value != null) { prin...
0
Kotlin
0
0
100a50e280e383b784c3edcf65b74935a92fdfa6
2,699
aoc-2022
Apache License 2.0
src/Day01.kt
davidkna
572,439,882
false
{"Kotlin": 79526}
fun main() { fun part1(input: List<List<String>>): Int = input.maxOf { l -> l.sumOf { n -> n.toInt() } } fun part2(input: List<List<String>>): Int { val max = intArrayOf(0, 0, 0) input.map { l -> l.sumOf { n -> n.toInt() } }.forEach { n -> if (n > max[0]) { max[0] = ...
0
Kotlin
0
0
ccd666cc12312537fec6e0c7ca904f5d9ebf75a3
639
aoc-2022
Apache License 2.0
Hangman/safeUserInputFunction/src/main/kotlin/jetbrains/kotlin/course/hangman/Main.kt
jetbrains-academy
504,249,857
false
{"Kotlin": 1108971}
package jetbrains.kotlin.course.hangman // You will use this function later fun getGameRules(wordLength: Int, maxAttemptsCount: Int) = "Welcome to the game!$newLineSymbol$newLineSymbol" + "In this game, you need to guess the word made by the computer.$newLineSymbol" + "The hidden word will appear as a ...
14
Kotlin
1
6
bc82aaa180fbd589b98779009ca7d4439a72d5e5
2,564
kotlin-onboarding-introduction
MIT License
src/main/kotlin/exercise/easy/id121/Solution121.kt
kotler-dev
706,379,223
false
{"Kotlin": 63887}
package exercise.easy.id121 class Solution121 { fun maxProfit(prices: IntArray): Int { if (prices.size < 2) return 0 var profit = 0 var min = Int.MAX_VALUE var max = 0 for (i in 0..<prices.size) { if (prices[i] < min) { min = prices[i] ...
0
Kotlin
0
0
0659e72dbf28ce0ec30aa550b6a83c1927161b14
3,359
kotlin-leetcode
Apache License 2.0
src/day04/Day04.kt
xxfast
572,724,963
false
{"Kotlin": 32696}
package day04 import readLines fun main() { fun format(input: List<String>): List<List<IntRange>> = input.map { line -> line.split(",").map { it.split("-").let { (start, end) -> start.toInt()..end.toInt() } } } fun part1(input: List<String>): Int = format(input).count { (first, second) -> (first - second...
0
Kotlin
0
1
a8c40224ec25b7f3739da144cbbb25c505eab2e4
787
advent-of-code-22
Apache License 2.0
src/day23/Main.kt
nikwotton
572,814,041
false
{"Kotlin": 77320}
package day23 import day23.Direction.East import day23.Direction.North import day23.Direction.South import day23.Direction.West import java.io.File val workingDir = "src/${object {}.javaClass.`package`.name}" fun main() { val sample = File("$workingDir/sample.txt") val input1 = File("$workingDir/input_1.txt"...
0
Kotlin
0
0
dee6a1c34bfe3530ae6a8417db85ac590af16909
6,157
advent-of-code-2022
Apache License 2.0
src/Day06.kt
phamobic
572,925,492
false
{"Kotlin": 12697}
fun main() { fun part(input: List<String>, markerSize: Int): Int { val signal = input.first() val marker = mutableListOf<Char>() var count = 0 signal.forEach { character -> count++ marker.add(character) if (marker.size > markerSize) { ...
1
Kotlin
0
0
34b2603470c8325d7cdf80cd5182378a4e822616
1,240
aoc-2022
Apache License 2.0
kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/char.kt
kotest
47,071,082
false
{"Kotlin": 4460715, "CSS": 352, "Java": 145}
package io.kotest.property.arbitrary import io.kotest.property.Arb import io.kotest.property.Gen /** * Returns a [Arb] that generates randomly-chosen Chars. Custom characters can be generated by * providing CharRanges. Distribution will be even across the ranges of Chars. * For example: * Gen.char('A'..'C', 'D'.....
102
Kotlin
615
4,198
7fee2503fbbdc24df3c594ac6b240c11b265d03e
2,337
kotest
Apache License 2.0
src/main/kotlin/com/tonnoz/adventofcode23/day16/Day16.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day16 import com.tonnoz.adventofcode23.utils.println import com.tonnoz.adventofcode23.utils.readCharMatrix import kotlinx.coroutines.runBlocking import java.lang.IllegalArgumentException import kotlin.system.measureTimeMillis object Day16 { @JvmStatic fun main(args: Array<String...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
3,553
adventofcode23
MIT License
src/main/kotlin/days/Day13.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day13 : Day(13) { override fun partOne(): Any { return inputList.chunked(3).withIndex().mapNotNull { (index, lines) -> val (left, right) = parseLine(lines[0]) to parseLine(lines[1]) if (left < right) index + 1 else null }.sum() } override fun par...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
3,498
aoc-2022
Creative Commons Zero v1.0 Universal
kotlin/src/com/daily/algothrim/leetcode/hard/MaximalRectangle.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.hard import java.util.* /** * 85. 最大矩形 * * 给定一个仅包含 0 和 1 、大小为 rows x cols 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。 */ class MaximalRectangle { companion object { @JvmStatic fun main(args: Array<String>) { println(MaximalRectangle().maximalRectangle(array...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,313
daily_algorithm
Apache License 2.0
src/main/kotlin/Day003.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
class Day003 { fun part1(input: List<String>): Int { var prioritiesSum = 0 for (rucksack in input) { val firstHalf = rucksack.subSequence(0, rucksack.length / 2) val lastHalf = rucksack.subSequence(rucksack.length / 2, rucksack.length) for (char in lastHalf) { ...
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
1,263
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/dp/longestPalindromeSubseq/SolutionKt.kt
eleven-max
441,597,605
false
{"Java": 104251, "Kotlin": 41506}
package dp.longestPalindromeSubseq import com.evan.dynamicprogramming.Common.CommonUtil //https://leetcode-cn.com/problems/longest-palindromic-subsequence/ class SolutionKt { fun longestPalindromeSubseq(s: String): Int { val s2 = s.reversed() println(s2) return longestCommonSubsequence(s, ...
0
Java
0
0
2e9b234b052896c6b8be07044d2b0c6812133e66
1,078
Learn_Algorithm
Apache License 2.0
src/main/kotlin/Day01.kt
Mariyo
728,179,583
false
{"Kotlin": 10845}
class Day01 { fun sumCalibrationValuesFromInput(input: List<String>): Int { var result = 0 input.forEach { result += it.calibrate() } return result } fun sumNormalizedValuesFromInput(input: List<String>): Int { var result = 0 input.forEach { ...
0
Kotlin
0
0
da779852b808848a26145a81cbf4330f6af03d84
2,397
advent-of-code-kotlin-2023
Apache License 2.0
src/main/kotlin/adventofcode/PuzzleDay04.kt
MariusSchmidt
435,574,170
false
{"Kotlin": 28290}
package adventofcode import java.io.File class PuzzleDay04 { fun determineWinningBoardOrder(file: File): List<BingoBoard> { val pulls = readPulls(file) val boards = readBoards(file) return pulls.flatMap { pulledNumber -> boards.filter { !it.won } .onEa...
0
Kotlin
0
0
2b7099350fa612cb69c2a70d9e57a94747447790
2,326
adventofcode2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/me/grison/aoc/y2015/Day16.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2015 import me.grison.aoc.* // not parsing the input class Day16 : Day(16, 2015) { override fun title() = "Aunt Sue" private val known = mutableMapOf("children" to 3, "cats" to 7, "samoyeds" to 2, "pomeranians" to 3, "akitas" to 0, "vizslas" to 0, "goldfish" to ...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
2,169
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/g0601_0700/s0677_map_sum_pairs/MapSum.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0677_map_sum_pairs // #Medium #String #Hash_Table #Design #Trie #2023_02_15_Time_197_ms_(80.00%)_Space_36.1_MB_(55.00%) class MapSum { internal class Node { var `val`: Int = 0 var child: Array<Node?> = arrayOfNulls(26) } private val root: Node = Node() fun insert(...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,384
LeetCode-in-Kotlin
MIT License
src/aoc2022/Day11.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import println import readInput import java.util.function.UnaryOperator fun main() { class Monkey( val items: MutableList<Long>, val op: UnaryOperator<Long>, val test: Int, val trueConditionMonkey: Int, val falseConditionMonkey: Int, var itemsInspected: Long = 0, var modul...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
4,494
advent-of-code-kotlin
Apache License 2.0
Code/4Sum/Solution.kt
Guaidaodl
26,102,098
false
{"Java": 20880, "Kotlin": 6663, "C++": 4106, "Python": 1216}
class Solution { fun fourSum(nums: IntArray, target: Int): List<List<Int>> { nums.sort() val result: ArrayList<List<Int>> = ArrayList() var lastThreeResult: List<List<Int>>? = null for (i in 0 until nums.size - 3) { val r = threeSum(nums, i + 1, target - nums[i]) ...
0
Java
0
0
a5e9c36d34e603906c06df642231bfdeb0887088
2,601
leetcode
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountHiddenSequences.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,382
kotlab
Apache License 2.0
18/kotlin/src/main/kotlin/se/nyquist/SnailfishNumber.kt
erinyq712
437,223,266
false
{"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098}
package se.nyquist import java.lang.NumberFormatException interface SnailfishNumber { fun reduce() : SnailfishNumber fun findReducable(): SnailfishNumberPair? { return findReducable(4) } fun findReducable(depth: Int): SnailfishNumberPair? fun getDigits(): List<SnailfishDigit> { ...
0
Kotlin
0
0
b463e53f5cd503fe291df692618ef5a30673ac6f
2,657
adventofcode2021
Apache License 2.0
src/main/kotlin/days/aoc2022/Day20.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day class Day20 : Day(2022, 20) { override fun partOne(): Any { return calculateGroveCoordinateSum(inputList) } override fun partTwo(): Any { return calculateGroveCoordinateSumWithDecryptionKey(inputList) } fun calculateGroveCoordinateSumWithDecry...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
1,755
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/kr/co/programmers/P136797.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers // https://github.com/antop-dev/algorithm/issues/537 class P136797 { // 한 자판에서 다른 자판으로 가는 가중치 private val costs = arrayOf( intArrayOf(1, 7, 6, 7, 5, 4, 5, 3, 2, 3), // 자판 0 intArrayOf(7, 1, 2, 4, 2, 3, 5, 4, 5, 6), intArrayOf(6, 2, 1, 2, 3, 2, 3, 5, 4, 5), ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
2,512
algorithm
MIT License
src/SpeedChallenge.kt
Tandrial
47,354,790
false
null
import java.io.File import kotlin.system.measureTimeMillis fun measureTime(name: String, part1: () -> Unit, part2: () -> Unit, maxTime: Long): Long { val timeP1 = measureTimeMillis(part1) val timeP2 = measureTimeMillis(part2) print("$name \t") print("${"%4d".format(timeP1)} \t") if (timeP2 > 0L) print("...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
8,243
Advent_of_Code
MIT License
src/main/kotlin/days/Day6.kt
sicruse
315,469,617
false
null
package days import days.Day class Day6 : Day(6) { private val groups: List<List<String>> by lazy { inputString // split the input at blank lines to form record groups .split("\\n\\n".toRegex()) .map { group -> // for every record text block gather the ...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
1,555
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/day1/part1/Part1.kt
bagguley
329,976,670
false
null
package day1.part1 import day1.data fun main() { println(sequence {for(a in 0..data.size-2) { for (b in a+1 until data.size) { if (data[a] + data[b] == 2020) yield(data[a] * data[b])} } }.first()) println((0..data.size-2).asSequence().flatMap{a->(a until data.size).map{ b->data[a] to data[b]}}.find{(x,y)->x+...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
880
adventofcode2020
MIT License
2023/19/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File import java.util.* private const val FILENAME = "2023/19/input.txt" fun main() { partOne() } private fun partOne() { val (workflows, ratings) = File(FILENAME).readText().split("\r\n\r\n") .map { it.split("\r\n") } var result = 0 for (rating in ratings) { val map ...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
1,852
Advent-of-Code
MIT License
src/main/kotlin/algorithms/MostProbableKmer.kt
jimandreas
377,843,697
false
null
@file:Suppress("UNUSED_PARAMETER") package algorithms /** * Profile-most Probable k-mer Problem: Find a Profile-most probable k-mer in a string. Input: A string Text, an integer k, and a 4 × k matrix Profile. Output: A Profile-most probable k-mer in Text. */ fun mostProbableKmer(genome: String, kmerLength: Int,...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
3,109
stepikBioinformaticsCourse
Apache License 2.0
src/Day01.kt
simonitor
572,972,937
false
{"Kotlin": 8461}
fun main() { //part1 val elfs = readFile("inputDay1").split("\n\n").map { Elf(it) } val answer = getFattestElf(elfs).calories println("The most calories are $answer") //part2 val answerPart2 = getTopThreeElfs(elfs).sumOf { it.calories } println("The most calories are $answerPart2") } fun g...
0
Kotlin
0
0
11d567712dd3aaf3c7dee424a3442d0d0344e1fa
851
AOC2022
Apache License 2.0
src/Day10.kt
petoS6
573,018,212
false
{"Kotlin": 14258}
fun main() { fun part1(lines: List<String>): Int { var x = 1 var cycle = 1 var sum = 0 fun processCycle() { if (cycle % 40 == 20) sum += cycle * x cycle++ } lines.forEach { line -> if (line == "noop") { processCycle() } else { processCycle() pr...
0
Kotlin
0
0
40bd094155e664a89892400aaf8ba8505fdd1986
1,305
kotlin-aoc-2022
Apache License 2.0
2023/08/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File private const val FILENAME = "2023/08/input.txt" fun main() { partOne() partTwo() } private fun partOne() { val file = File(FILENAME).readLines() val instructions = file[0] var instructionIndex = 0 var steps = 0 val map: MutableMap<String, Pair<String, String>> = mut...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
2,616
Advent-of-Code
MIT License
src/main/kotlin/solutions/day04/Day4.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day04 import solutions.Solver class Day4 : Solver { private infix fun IntRange.contains(other: IntRange): Boolean = (this.contains(other.first) and this.contains(other.last)) or (other.contains(this.first) and other.contains(this.last)) private infix fun IntRange.o...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
1,280
Advent-of-Code-2022
MIT License
src/Day01.kt
defvs
572,381,346
false
{"Kotlin": 16089}
fun main() { // Returns a List of Ints containing the sum of calories for each elf. fun getAllElvesCalories(input: List<String>) = input.joinToString(separator = "\n") .split("\n\n").map { it.split("\n").sumOf { it.toInt() } } // Get the maximum value of getAllElvesCalories fun part1(input: List<String>) = getAl...
0
Kotlin
0
1
caa75c608d88baf9eb2861eccfd398287a520a8a
763
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day21/day21.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day21 import pl.mrugacz95.aoc.day16.HopcroftKarpSolver class Food(raw: String) { private val groups = raw.split(" (contains ") val ingredients = groups[0].split(" ").toSet() val allergens = groups[1].dropLast(1).split(", ") } fun solve(foodList: List<Food>): Map<String, String> {...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
1,228
advent-of-code-2020
Do What The F*ck You Want To Public License
advent2023/src/main/kotlin/year2023/Day01.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2023 import AdventDay private val additionalDigitMapping = mapOf( "one" to "1", "two" to "2", "three" to "3", "four" to "4", "five" to "5", "six" to "6", "seven" to "7", "eight" to "8", "nine" to "9" ) private val additionalDigits = additionalDigitMapping.keys object D...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,227
advent-of-code
Apache License 2.0