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
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day14/NanoFactory.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day14 import kotlin.math.max class NanoFactory(private val recipes: Map<String, Pair<Long, List<Chemical>>>) { fun calculateTotalOresRequiredToMakeFuel() = requiredOre(Chemical("FUEL", 1), mutableMapOf()) fun calculateFuelGeneratedByOneTrillionOres(): Long ...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
2,205
advent-of-code
Apache License 2.0
src/main/kotlin/days/Day11.kt
TheMrMilchmann
571,779,671
false
{"Kotlin": 56525}
/* * Copyright (c) 2022 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
2e01ab62e44d965a626198127699720563ed934b
3,668
AdventOfCode2022
MIT License
src/Day06.kt
kuolemax
573,740,719
false
{"Kotlin": 21104}
fun main() { fun part1(input: List<String>): Int { return findFourDifferentCharactersInARow(input[0], 4) } fun part2(input: List<String>): Int { return findFourDifferentCharactersInARow(input[0], 14) } // test if implementation meets criteria from the description, like: val te...
0
Kotlin
0
0
3045f307e24b6ca557b84dac18197334b8a8a9bf
1,065
aoc2022--kotlin
Apache License 2.0
src/main/kotlin/aoc22/Day11.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import common.Collections.partitionedBy import common.Collections.product import aoc22.Day11Solution.part1Day11 import aoc22.Day11Solution.part2Day11 import aoc22.Day11Domain.Item import aoc22.Day11Domain.Monkey import aoc22.Day11Parser.toMonkeys import aoc22.Day11Runner.doRounds import common.Year22 ob...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
4,660
aoc
Apache License 2.0
src/Day03.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") private const val DAY = "03" private const val PART1_CHECK = 157 private const val PART2_CHECK = 70 fun String.toCompartments(): List<String> = (length / 2).let { listOf(take(it), drop(it)) } fun itemPriority(item: Char): Int = when (item) { in 'a'..'z' -> i...
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
1,450
adventofcode2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day05.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import at.mpichler.aoc.lib.Vector2i import at.mpichler.aoc.lib.max import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.zeros import org.jetbrains.kotlinx.multik.ndarray.data....
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,402
advent-of-code-kotlin
MIT License
calendar/day04/Day4.kt
divgup92
726,169,029
false
{"Kotlin": 16931}
package day04 import Day import Lines import kotlin.math.max import kotlin.math.min import kotlin.math.pow class Day4 : Day() { override fun part1(input: Lines): Any { var sum = 0 for(line in input) { val lineSplit = line.split(":", "|") val winningNums = lineSplit[1].split...
0
Kotlin
0
0
38dbf3b6eceea8d5b0eeab82b384acdd0c205852
1,941
advent-of-code-2023
Apache License 2.0
src/main/kotlin/io/undefined/BestTimeToBuyAndSellStock.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.undefined import io.utils.runTests // https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ class BestTimeToBuyAndSellStock { fun execute(input: IntArray): Int { if (input.isEmpty()) return 0 val maximums = run { var max = Int.MIN_VALUE input.indices.map { index -> maxOf(inp...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,203
coding
MIT License
TwoSum.kt
sammyHa
188,499,821
false
null
/** @author <NAME> 5/24/2019 4:36 AM */ /** * This problem was recently asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true or print the indices of the two values in the list since 10 + 7 is 17. ...
0
Java
0
0
29e74c19e03fb1e4af5048ed5463f0edcc2f7070
2,585
Coding-Problems
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day14.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day14(input: List<String>) { private val platform = Platform(input.toGrid(ignore = '.')) private class Platform(originalGrid: Grid<Char>) { private val region = originalGrid.region() private var roundRockPositions = originalGrid.filterValues { it == 'O' ...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
2,890
advent-2023
MIT License
algorithms/src/main/kotlin/org/baichuan/sample/algorithms/leetcode/middle/ReverseBetween.kt
scientificCommunity
352,868,267
false
{"Java": 154453, "Kotlin": 69817}
package org.baichuan.sample.algorithms.leetcode.middle /** * @author: kuntang (<EMAIL>) * @date: 2022/4/12 * https://leetcode-cn.com/problems/reverse-linked-list-ii/ * * 执行用时:136 ms, 在所有 Kotlin 提交中击败了97.62%的用户 * 内存消耗:32.7 MB, 在所有 Kotlin 提交中击败了100.00%的用户 */ class ReverseBetween { fun reverseBetween(head: Lis...
1
Java
0
8
36e291c0135a06f3064e6ac0e573691ac70714b6
2,611
blog-sample
Apache License 2.0
src/Day01.kt
kipwoker
572,884,607
false
null
fun main() { fun getStructure(input: List<String>): MutableList<List<Int>> { val result = mutableListOf<List<Int>>() var bucket = mutableListOf<Int>() result.add(bucket) input.forEach { line -> run { if (line.isBlank()) { bucket = muta...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
1,056
aoc2022
Apache License 2.0
src/oop/algorithm/ProgressionNextNumber.kt
jjeda
517,337,782
false
{"Kotlin": 27953}
package oop.algorithm class ProgressionNextNumber { fun solution(common: IntArray): Int { return ProgressionHelper(progression = common.toList()).nextInt() } } class ProgressionHelper( private val progression: List<Int> ) { fun nextInt(): Int { val metadata = getMetadata() val nextNumberGenerator ...
0
Kotlin
0
0
5d1ee6c2635fd8c1443cfe2b5d56be110dea9c10
1,697
playground
MIT License
src/main/kotlin/tw/gasol/aoc/aoc2022/Day15.kt
Gasol
574,784,477
false
{"Kotlin": 70912, "Shell": 1291, "Makefile": 59}
package tw.gasol.aoc.aoc2022 import java.awt.Point import java.awt.geom.Path2D import kotlin.math.abs import kotlin.math.absoluteValue class Day15 { private fun getPairPointList(input: String): List<Pair<Point, Point>> { val numbersPattern = "[\\d\\-]+" val regex = Regex("Sensor at x=(...
0
Kotlin
0
0
a14582ea15f1554803e63e5ba12e303be2879b8a
3,495
aoc2022
MIT License
advent-of-code/aoc-2023/src/test/kotlin/dev/mikeburgess/adventofcode/Day03.kt
mddburgess
469,258,868
false
{"Kotlin": 47737}
package dev.mikeburgess.adventofcode import dev.mikeburgess.adventofcode.day03.PartNumber import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals class Day03 { private val input = readInput(3) private val schematic = LinkedHashMap<Pair<Int, Int>, PartNumber>() @BeforeTest ...
0
Kotlin
0
0
9ad8f26583b204e875b07782c8d09d9d8b404b00
2,499
code-kata
MIT License
contest1904/src/main/kotlin/D1.kt
austin226
729,634,548
false
{"Kotlin": 23837}
// https://codeforces.com/contest/1904/problem/D1 private fun String.splitWhitespace() = split("\\s+".toRegex()) private fun readInt(): Int = readln().toInt() private fun readInts(): List<Int> = readln().splitWhitespace().map { it.toInt() } fun canABecomeB(n: Int, a: MutableList<Int>, b: List<Int>): Boolean { // ...
0
Kotlin
0
0
4377021827ffcf8e920343adf61a93c88c56d8aa
1,606
codeforces-kt
MIT License
src/day2/Day02.kt
behnawwm
572,034,416
false
{"Kotlin": 11987}
package day2 import day2.Move.* import day2.WinStatus.* import readInput fun main() { // val fileLines = readInput("day02-test", "day2") val fileLines = readInput("day02", "day2") var score = 0 fun parseInput(text: String): Pair<String, String> { text.split(" ").apply { return Pa...
0
Kotlin
0
2
9d1fee54837cfae38c965cc1a5b267d7d15f4b3a
3,340
advent-of-code-kotlin-2022
Apache License 2.0
src/Day01.kt
yalexaner
573,141,113
false
{"Kotlin": 4235}
@file:JvmName("Day1Kt") import kotlin.math.max fun main() { runTests() val input = readInput("Day01") println(part1(input)) println(part2(input)) } private fun runTests() { val testInput = readInput("Day01_test") val part1Result = part1(testInput) check(part1Result == 24000) { "part1 is ...
0
Kotlin
0
0
58c2bf57543253db544fa8950aac4dc67896b808
1,789
advent-of-code-2022
Apache License 2.0
compiler/src/main/kotlin/edu/cornell/cs/apl/viaduct/util/Lists.kt
s-ren
386,161,765
true
{"Kotlin": 878757, "Java": 43761, "C++": 13898, "Python": 11991, "Lex": 6620, "Dockerfile": 1844, "Makefile": 1785, "SWIG": 1212, "Shell": 698}
package edu.cornell.cs.apl.viaduct.util /** * Returns the list of all pairs where the first element is from [this] list, * and the second element is from [other]. */ internal fun <A, B> List<A>.pairedWith(other: List<B>): List<Pair<A, B>> { val result = mutableListOf<Pair<A, B>>() for (a in this) { ...
0
null
0
0
337b3873e10f642706b195b10f939e9c1c7832ef
1,258
viaduct
MIT License
leetcode/src/offer/middle/Offer46.kt
zhangweizhe
387,808,774
false
null
package offer.middle import kotlin.math.sign fun main() { // 剑指 Offer 46. 把数字翻译成字符串 // https://leetcode.cn/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/ println(translateNum3(12258)) } fun translateNum3(num: Int): Int { if (num in 0..9) { return 1 } if (num in 10..25) { r...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
4,848
kotlin-study
MIT License
src/Day11.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
fun main() { class Monkey(var items: MutableList<Int>, val operation: Pair<String, String>, val test: List<Int>) { val monkeyMailbox: MutableList<Pair<Int, Int>> = mutableListOf() var totalNumberOfItemsInspected = 0L fun inspect() { val increaseBy = operation.second.toIntOrNull...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
7,864
advent_of_code_2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem223/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem223 /** * LeetCode page: [223. Rectangle Area](https://leetcode.com/problems/rectangle-area/); */ class Solution { /* Complexity: * Time O(1) and Space O(1); */ fun computeArea(ax1: Int, ay1: Int, ax2: Int, ay2: Int, bx1: Int, by1: Int, bx2: Int, by2: Int): Int...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,372
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/adventofcode/day12.kt
Kvest
163,103,813
false
null
package adventofcode import java.io.File import java.math.BigInteger fun main(args: Array<String>) { println(first12("##.#..#.#..#.####.#########.#...#.#.#......##.#.#...##.....#...#...#.##.#...##...#.####.##..#.#..#.", File("./data/day12_1.txt").readLines(), 20)) println(second12()) } fun second12(): BigInt...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
1,657
aoc2018
Apache License 2.0
src/main/kotlin/g1201_1300/s1262_greatest_sum_divisible_by_three/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1201_1300.s1262_greatest_sum_divisible_by_three // #Medium #Array #Dynamic_Programming #Greedy // #2023_06_08_Time_263_ms_(100.00%)_Space_39.9_MB_(33.33%) class Solution { fun maxSumDivThree(nums: IntArray): Int { var sum = 0 var smallestNumWithMod1 = 10001 var secondSmallestNumWi...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,632
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2616/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2616 /** * LeetCode page: [2616. Minimize the Maximum Difference of Pairs](https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/); */ class Solution { /* Complexity: * Time O(NLogN+NLogV) and Space O(N) where N is the size of nums, V is the (maxValue -...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,398
hj-leetcode-kotlin
Apache License 2.0
src/Day01.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>): Int { return computeCalories(input).max() } fun part2(input: List<String>): Int { return computeCalories(input).sortedDescending().take(3).sum() } // test if implementation meets criteria from the description, like: val testInput = r...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
665
advent-of-code-2022
Apache License 2.0
src/main/kotlin/year2022/day08/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day08 import IProblem import java.util.* import kotlin.math.max class Problem : IProblem { private val matrix = javaClass .getResource("/2022/08.txt")!! .readText() .lines() .filter(String::isNotEmpty) .map { it.map(Char::digitToInt).toIntArray() } ...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
3,896
advent-of-code
The Unlicense
src/Day14.kt
CrazyBene
573,111,401
false
{"Kotlin": 50149}
import java.lang.Integer.max import java.lang.Integer.min fun main() { fun List<String>.toRocks(): Set<Pair<Int, Int>> { return this.flatMap { line -> line .split(" -> ") .map { it.split(",").map { it.toInt() } } ...
0
Kotlin
0
0
dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26
5,094
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/sherepenko/leetcode/solutions/MinPathSum.kt
asherepenko
264,648,984
false
null
package com.sherepenko.leetcode.solutions import com.sherepenko.leetcode.Solution import kotlin.math.min class MinPathSum( private val grid: Array<IntArray> ) : Solution { companion object { fun minPathSum(grid: Array<IntArray>): Int { val m = grid.size val n = grid[0].size ...
0
Kotlin
0
0
49e676f13bf58f16ba093f73a52d49f2d6d5ee1c
1,450
leetcode
The Unlicense
src/main/kotlin/Day2.kt
d1snin
726,126,205
false
{"Kotlin": 14602}
/* * 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 wr...
0
Kotlin
0
0
8b5b34c4574627bb3c6b1a12664cc6b4c9263e30
3,105
aoc-2023
Apache License 2.0
src/day17/Day17.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day17 import readInput import readTestInput import kotlin.math.min private data class Position(val x: Int, val y: Int) private fun p(x: Int, y: Int) = Position(x = x, y = y) private sealed interface Shape { val partPositions: List<Position> fun fitsInto(chamber: Chamber, at: Position): Boolean { ...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
10,078
advent-of-code-kotlin-2022
Apache License 2.0
app/src/main/kotlin/me/leon/ext/math/Matrix.kt
Leon406
381,644,086
false
{"Kotlin": 1392660, "JavaScript": 96128, "Java": 16541, "Batchfile": 4706, "Shell": 259, "CSS": 169}
package me.leon.ext.math import kotlin.math.pow import kotlin.math.sqrt fun Array<IntArray>.determinant(n: Int): Int { var res: Int if (n == 1) { res = this[0][0] } else if (n == 2) { res = this[0][0] * this[1][1] - this[1][0] * this[0][1] } else { res = 0 for (j1 in 0 ...
4
Kotlin
236
1,218
dde1cc6e8e589f4a46b89e2e22918e8b789773e4
4,045
ToolsFx
ISC License
src/Day05.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
import java.util.* class Cargo(private val stacks: List<Deque<Char>>) { companion object Factory { fun create(description: List<String>): Cargo { val cargo = Cargo(List<Deque<Char>>(9) { _ -> ArrayDeque() }) // yep, hardcoded amount of stacks description.reversed().forEach { s -> c...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
2,742
aoc-2022
Apache License 2.0
src/Day03.kt
YunxiangHuang
572,333,905
false
{"Kotlin": 20157}
import java.util.ArrayList fun main() { val input = readInput("Day03") fun cal(c: Char): Int { if (c in 'a'..'z') { return c.code - 'a'.code + 1 } if (c in 'A'..'Z') { return c.code - 'A'.code + 27 } return 0 } fun partOne() { ...
0
Kotlin
0
0
f62cc39dd4881f4fcf3d7493f23d4d65a7eb6d66
1,995
AoC_2022
Apache License 2.0
src/Day10.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
import kotlin.math.abs fun main() { fun checkSignalStrength( cycle: Int, register: Int, signalStrengths: MutableList<Int>, ) { if (cycle in listOf(20, 60, 100, 140, 180, 220)) { signalStrengths.add(register * cycle) } } fun part1(input: List<String>...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
2,007
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ArithmeticSubarrays.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,763
kotlab
Apache License 2.0
src/Day06.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
fun main() { fun solve(input: String, distLength: Int) = input.indexOf(input.windowed(distLength).first { it.toList().allDistinct()}) + distLength fun part1(input: String) = solve(input, 4) fun part2(input: String) = solve(input, 14) val testInput = readInput("Day06_test") val testResults ...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
849
advent-of-code
Apache License 2.0
calendar/day05/Day5.kt
mpetuska
571,764,215
false
{"Kotlin": 18073}
package day05 import Day import Lines class Day5 : Day() { override fun part1(input: Lines): Any { val (rows, stackIds) = input.takeWhile(String::isNotBlank).let { it.dropLast(1) .map { row -> row.chunked(4).map(String::trim).map { item -> item.removeSurrounding("[", "]") } } to ...
0
Kotlin
0
0
be876f0a565f8c14ffa8d30e4516e1f51bc3c0c5
2,301
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/leetcode/UniquePaths.kt
ykrytsyn
424,099,758
false
{"Kotlin": 8270}
package leetcode /** * # 62. Unique Paths * [https://leetcode.com/problems/unique-paths/](https://leetcode.com/problems/unique-paths/) * * ### A robot is located at the top-left corner of 'm x n' grid (marked 'Start' in the diagram below). * ### The robot can only move either down or right at any point in time. ...
0
Kotlin
0
0
0acf2a677f8b4a1777b12688cf48bf420353e040
1,119
leetcode-in-kotlin
Apache License 2.0
src/hongwei/leetcode/playground/leetcodecba/M1466ReorderRoutes2MakeAllPathsLead2theCityZero.kt
hongwei-bai
201,601,468
false
{"Java": 143669, "Kotlin": 38875}
package hongwei.leetcode.playground.leetcodecba import hongwei.leetcode.playground.common.print class M1466ReorderRoutes2MakeAllPathsLead2theCityZero { fun test() { val testData = listOf( arrayOf( 6, arrayOf(intArrayOf(0, 1), intArrayOf(1, 3), intArrayOf(2, 3), ...
0
Java
0
1
9d871de96e6b19292582b0df2d60bbba0c9a895c
2,597
leetcode-exercise-playground
Apache License 2.0
kotlin/src/_0018_0.kt
yunshuipiao
179,794,004
false
null
import org.testng.annotations.Test /** * 常规解法 */ fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val result = arrayListOf<ArrayList<Int>>() if (nums.size < 4) { return result } nums.sort() var index = 0 while (index < nums.size) { if (index > 0 && nums[index] == n...
29
Kotlin
0
2
6b188a8eb36e9930884c5fa310517be0db7f8922
3,620
rice-noodles
Apache License 2.0
src/day21/Day21.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day21 import readInput import kotlin.math.abs private const val DAY_ID = "21" private enum class Operator : (Long, Long) -> Long { ADD { override fun invoke(a: Long, b: Long): Long = a + b }, SUBS { override fun invoke(a: Long, b: Long): Long = a - b }, MULT { over...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
5,680
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/Day24.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.UUID import kotlin.collections.ArrayDeque fun main() { val input = readFileAsList("Day24") println(Day24.part1(input)) println(Day24.part2(input)) } object Day24 { private val start = Vector2d(2, 1) fun part1(input: List<String>): Long { val (maxXBlizzard, maxYBlizzard, g...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
7,440
advent-of-code-2022
Apache License 2.0
src/Day10.kt
wooodenleg
572,658,318
false
{"Kotlin": 30668}
object Day10 { const val xKey = "x" sealed interface Instruction { fun Processor.onTick(): Boolean class AddX(private val number: Int) : Instruction { private var initialTick = true override fun Processor.onTick(): Boolean = if (initialTick) { ...
0
Kotlin
0
1
ff1f3198f42d1880e067e97f884c66c515c8eb87
3,109
advent-of-code-2022
Apache License 2.0
src/main/kotlin/juuxel/basiks/iterable/CombinedIterable.kt
Juuxel
143,861,676
false
null
package juuxel.basiks.iterable /** * A combined iterable of types [A] and [B]. * * @param outer the outer iterable of type [A] * @param inner the inner iterable of type [B] */ private class CombinedIterable<A, B>( private val outer: Iterable<A>, private val inner: Iterable<B> ): Iterable<Pair<A, B>> { ...
0
Kotlin
0
0
411506cb2f357bed0e937e11fc74a9f184de74f1
1,141
Basiks
MIT License
app/src/test/java/com/zwq65/unity/algorithm/unionfind/LeetCode990.kt
Izzamuzzic
95,655,850
false
{"Kotlin": 449365, "Java": 17918}
package com.zwq65.unity.algorithm.unionfind import org.junit.Test /** * ================================================ * <p> * <a href="https://leetcode-cn.com/problems/satisfiability-of-equality-equations/">990. 等式方程的可满足性</a>. * Created by NIRVANA on 2019/7/15. * Contact with <<EMAIL>> * ====================...
0
Kotlin
0
0
98a9ad7bb298d0b0cfd314825918a683d89bb9e8
1,554
Unity
Apache License 2.0
src/main/kotlin/com/github/leandroborgesferreira/dagcommand/logic/NodeList.kt
krgauthi
356,499,213
true
{"Kotlin": 30804}
package com.github.leandroborgesferreira.dagcommand.logic import com.github.leandroborgesferreira.dagcommand.domain.AdjacencyList import com.github.leandroborgesferreira.dagcommand.domain.Node import java.util.* fun findRootNodes(adjacencyList: AdjacencyList) = adjacencyList.keys - adjacencyList.values.flatten() fun...
0
Kotlin
0
0
9c603e3d36b863bdd5740b70fb4a3cd8463f1116
1,628
dag-command
Apache License 2.0
year2022/src/main/kotlin/net/olegg/aoc/year2022/day9/Day9.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day9 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions import net.olegg.aoc.utils.Directions.DL import net.olegg.aoc.utils.Directions.DR import net.olegg.aoc.utils.Directions.UL import net.olegg.aoc.utils.Directions.UR import net.olegg.aoc.utils.Vector2D import n...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,501
adventofcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxVowels.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,695
kotlab
Apache License 2.0
src/main/kotlin/grappolo/SimilarityMatrix.kt
xrrocha
264,292,094
false
null
package grappolo class SimilarityMatrix(val size: Int) { private val similarities = mutableSetOf<Double>() inner class Vector(private val parentIndex: Int) { private val elements = mutableMapOf(parentIndex to 1.0) operator fun get(index: Int): Double { validateIndex(index) ...
0
Kotlin
0
0
93a065ab98d5551bc2f2e39ff4b069d524e04870
2,139
grappolo-kotlin
Apache License 2.0
src/Day09.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
import kotlin.math.abs fun main() { fun moveTail(frontX: Int, frontY: Int, tail: Pair<Int, Int>) : Pair<Int, Int> { var (tailX, tailY) = tail // diagonal move if(frontX != tailX && frontY != tailY) { if(abs(frontX - tailX) == 2 || abs(frontY - tailY) == 2) { if(frontX < tailX) { ...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
4,170
AdventOfCode2022
Apache License 2.0
src/main/kotlin/me/peckb/aoc/_2019/calendar/day18/SearchDijkstra.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2019.calendar.day18 import me.peckb.aoc.pathing.Dijkstra import me.peckb.aoc.pathing.DijkstraNodeWithCost data class SearchArea(val sources: List<Day18.Section.Source>, val foundKeys: Set<Day18.Section.Source.Key>) class SearchDijkstra( private val allKeys: Set<Day18.Section.Source.Key>, pr...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,283
advent-of-code
MIT License
src/twentytwo/Day07.kt
mihainov
573,105,304
false
{"Kotlin": 42574}
package twentytwo import readInputTwentyTwo data class File(val size: Int, val name: String) typealias FileSystem = MutableMap<String, MutableList<File>> fun handleCommandCd(arg: String, currentDir: MutableList<String>) { when (arg) { "/" -> { currentDir.removeAll { true } curren...
0
Kotlin
0
0
a9aae753cf97a8909656b6137918ed176a84765e
3,831
kotlin-aoc-1
Apache License 2.0
src/Day06.kt
binaryannie
573,120,071
false
{"Kotlin": 10437}
private const val DAY = "06" private const val PART_1_CHECK = 7 private const val PART_2_CHECK = 19 fun messageSeeker(input: String, windowSize: Int): Int { return input.windowed(windowSize).map { it.toSet() }.indexOfFirst { it.size == windowSize } + windowSize } fun main() { fun part1(input: List<String>): I...
0
Kotlin
0
0
511fc33f9dded71937b6bfb55a675beace84ca22
890
advent-of-code-2022
Apache License 2.0
day03/kotlin/corneil/src/main/kotlin/solution.kt
mehalter
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271053, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust":...
package com.github.corneil.aoc2019.day3 import java.io.BufferedReader import java.io.File import java.io.FileReader import kotlin.math.abs import kotlin.math.max import kotlin.math.min data class Coord(val x: Int, val y: Int) { fun distance(target: Coord): Int { return abs(x - target.x) + abs(y - target.y...
0
HTML
0
0
afcaede5326b69fedb7588b1fe771fd0c0b3f6e6
5,457
docToolchain-aoc-2019
MIT License
src/Day01.kt
daividssilverio
572,944,347
false
{"Kotlin": 10575}
fun main() { val inventory = readInput("Day01_test") val highestInventoryInCalories = findTopSumsOfCaloriesInventories(inventory, 1) val sumOfTopThreeInventories = findTopSumsOfCaloriesInventories(inventory, 3) println(highestInventoryInCalories) println(sumOfTopThreeInventories) } fun findTopSumsO...
0
Kotlin
0
0
141236c67fe03692785e0f3ab90248064a1693da
896
advent-of-code-kotlin-2022
Apache License 2.0
Kotlin/src/main/kotlin/org/algorithm/problems/0182_n_queens.kt
raulhsant
213,479,201
true
{"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187}
package org.algorithm.problems // Problem Statement // The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. // Given an integer n, return all distinct solutions to the n-queens puzzle. // Each solution contains a distinct board configuration of the n...
0
C++
0
0
1578a0dc0a34d63c74c28dd87b0873e0b725a0bd
2,108
algorithms
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year15/Day21.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year15 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.permPairsExclusive import com.grappenmaker.aoc.splitInts fun PuzzleSet.day21() = puzzle(21) { data class SpecialItem(val cost: Int, val dmg: Int, val arm: Int) operator fun SpecialItem.plus(other: SpecialItem...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,761
advent-of-code
The Unlicense
2018/kotlin/day13p2/src/main.kt
sgravrock
47,810,570
false
{"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "...
import java.util.* fun main(args: Array<String>) { val start = Date() val classLoader = Coord::class.java.classLoader val input = classLoader.getResource("input.txt").readText() val rr = MineRailroad.parse(input) rr.advanceUntilOneCart() println(rr.remainingCartCoord()) println("in ${Date()...
0
Rust
0
0
ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3
5,187
adventofcode
MIT License
src/test/kotlin/com/igorwojda/list/sumzero/challenge.kt
ExpensiveBelly
308,111,738
true
{"Kotlin": 244479}
package com.igorwojda.list.sumzero import org.amshove.kluent.shouldBeEqualTo import org.junit.jupiter.api.Test private fun sumZero(list: List<Int>): Pair<Int, Int>? { if (list.isEmpty()) return null return list.toSet().combinations(2).map { Pair(it.first(), it.elementAt(1)) }.filter { it.first + it.second == ...
1
Kotlin
0
0
f08e5bc1ccf5e1c686e228c7377edff12fd1b35f
1,821
kotlin-coding-puzzle-1
MIT License
src/Day06.kt
cisimon7
573,872,773
false
{"Kotlin": 41406}
fun main() { fun posUniqueSequence(signal: String, count: Int): Int { val idx = signal.windowedSequence(count, 1).indexOfFirst { it.toSet().size == count } return idx + count } fun part1(signals: List<String>): List<Int> { return signals.map { signal -> posUniqueSequence(signal, 4) ...
0
Kotlin
0
0
29f9cb46955c0f371908996cc729742dc0387017
820
aoc-2022
Apache License 2.0
src/Day01.kt
fonglh
573,269,990
false
{"Kotlin": 48950, "Ruby": 1701}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var elfCalories = 0 input.forEach { if(it.isNotBlank()) { elfCalories += it.toInt() } else { if (elfCalories > maxCalories) { maxCalories = elfC...
0
Kotlin
0
0
ef41300d53c604fcd0f4d4c1783cc16916ef879b
1,101
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc22/Day14.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import aoc22.Day14Domain.Cave import aoc22.Day14Parser.toCave import aoc22.Day14Solution.part1Day14 import aoc22.Day14Solution.part2Day14 import common.Space2D.Direction.* import common.Space2D.Point import common.Year22 import common.Monitoring object Day14: Year22 { fun List<String>.part1(): Int =...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
3,115
aoc
Apache License 2.0
Essays/Testability/REPL/src/main/kotlin/palbp/laboratory/essays/testability/repl/Parser.kt
palbp
463,200,783
false
{"Kotlin": 722657, "C": 16710, "Assembly": 891, "Dockerfile": 610, "Swift": 594, "Makefile": 383}
package palbp.laboratory.essays.testability.repl /* * Parser implementation for the following grammar: * * expression = operation | constant * operation = operator , expression , expression * operator = '-' | '+' | '*' | '/' * constant = [sign] , {digit} * sign = '-' | '+' * digit =...
1
Kotlin
0
4
66fb17fcd9d7b1690492def0bf671cfb408eb6db
1,746
laboratory
MIT License
src/day22/Day22.kt
gr4cza
572,863,297
false
{"Kotlin": 93944}
@file:Suppress("MagicNumber") package day22 import Direction import Position import readInput fun main() { fun parseInstructions(instructions: String): List<Inst> { val alteredInstr = instructions.replace("""([RL])""".toRegex(), " $0 ") return alteredInstr.split(" ") .windowed(2, 2, ...
0
Kotlin
0
0
ceca4b99e562b4d8d3179c0a4b3856800fc6fe27
12,384
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2023/Day03.kt
colinodell
726,073,391
false
{"Kotlin": 114923}
package com.colinodell.advent2023 class Day03(schematic: List<String>) { private val symbols = mutableSetOf<Symbol>() private val numbers = mutableSetOf<Number>() private data class Digit(val value: Int, val position: Vector2) private class Number(digits: List<Digit>) { val value = digits.red...
0
Kotlin
0
0
97e36330a24b30ef750b16f3887d30c92f3a0e83
2,288
advent-2023
MIT License
src/main/kotlin/aoc/year2021/Day02.kt
SackCastellon
573,157,155
false
{"Kotlin": 62581}
package aoc.year2021 import aoc.Puzzle /** * [Day 2 - Advent of Code 2021](https://adventofcode.com/2021/day/2) */ object Day02 : Puzzle<Int, Int> { override fun solvePartOne(input: String): Int { class Submarine1 : Submarine() { override fun down(x: Int) { depth += x ...
0
Kotlin
0
0
75b0430f14d62bb99c7251a642db61f3c6874a9e
1,784
advent-of-code
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem279/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem279 import kotlin.math.sqrt /** * LeetCode page: [279. Perfect Squares](https://leetcode.com/problems/perfect-squares/); */ class Solution2 { /* Complexity: * Time O(sqrt(n)) and Space O(1); */ fun numSquares(n: Int): Int { return when { n....
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,357
hj-leetcode-kotlin
Apache License 2.0
classroom/src/main/kotlin/com/radix2/algorithms/week5/LLRBTree.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week5 import com.radix2.algorithms.week4.SymbolTable import com.radix2.algorithms.week4.put import java.lang.StringBuilder import java.util.* class LLRBTree<K : Comparable<K>, V> : SymbolTable<K, V> { private var root: Node<K, V>? = null private enum class Color { RED, BLACK } ...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
6,493
coursera-algorithms-part1
Apache License 2.0
src/main/kotlin/sschr15/aocsolutions/Day2.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.Challenge import sschr15.aocsolutions.util.ReflectivelyUsed import sschr15.aocsolutions.util.challenge import sschr15.aocsolutions.util.ints import sschr15.aocsolutions.util.watched.sum import sschr15.aocsolutions.util.watched.watched /** * AOC 2023 [Day ...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
2,465
advent-of-code
MIT License
src/Day05.kt
matheusfinatti
572,935,471
false
{"Kotlin": 12612}
val stacks = listOf( stackOf('W', 'R', 'F'), stackOf('T', 'H', 'M', 'C', 'D', 'V', 'W', 'P'), stackOf('P', 'M', 'Z', 'N', 'L'), stackOf('J', 'C', 'H', 'R'), stackOf('C', 'P', 'G', 'H', 'Q', 'T', 'B'), stackOf('G', 'C', 'W', 'L', 'F', 'Z'), stackOf('W', 'V', 'L', 'Q', 'Z', 'J', 'G', 'C'), ...
0
Kotlin
0
0
a914994a19261d1d81c80e0ef8e196422e3cd508
1,756
adventofcode2022
Apache License 2.0
src/main/kotlin/com/github/xetra11/ck3workbench/app/validation/grammar/GrammarValidator.kt
xetra11
315,437,408
false
null
package com.github.xetra11.ck3workbench.app.validation.grammar import com.github.xetra11.ck3workbench.app.validation.grammar.GrammarParser.Grammar /** * The grammar parser takes a grammar definition and a list of [Token] * and searches in that for a match. The match is returned as a subset of [Token] * * @author ...
20
Kotlin
1
8
dc10ec20c8794216bb641f93b7b3c1196063dd24
4,149
CK3-Workbench
MIT License
src/Day10.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
fun main() { fun part1(input: List<Cmd>) { var x = 1 input.mapIndexedNotNull { i, cmd -> var ret: Int? = null if (i + 1 in listOf(20, 60, 100, 140, 180, 220)) { ret = x * (i + 1) } when (cmd) { is Addx -> x += cmd.value...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
1,478
advent-of-code-2022
Apache License 2.0
kotlin/0063-unique-paths-ii.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}
// If we can't do inplace, space O(N) class Solution { fun uniquePathsWithObstacles(grid: Array<IntArray>): Int { val m = grid.lastIndex val n = grid[0].lastIndex if (grid[m][n] == 1 || grid[0][0] == 1) return 0 val dp = IntArray(n+1) dp[n] = 1 for (i in m...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,391
leetcode
MIT License
app/src/main/java/online/vapcom/codewars/numbers/Numbers.kt
vapcomm
503,057,535
false
{"Kotlin": 142486}
package online.vapcom.codewars.numbers import kotlin.math.truncate // https://www.codewars.com/kata/5aba780a6a176b029800041c/train/kotlin fun maxMultiple(divisor: Int, bound: Int): Int { if (divisor <= 0 || bound <= 0 || divisor > bound) return 0 if (bound % divisor == 0) return bound v...
0
Kotlin
0
0
97b50e8e25211f43ccd49bcee2395c4bc942a37a
3,084
codewars
MIT License
src/main/kotlin/dev/shtanko/algorithms/dp/MinCoins.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,222
kotlab
Apache License 2.0
common/number/src/main/kotlin/com/curtislb/adventofcode/common/number/Sequences.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.common.number import java.math.BigInteger import kotlin.math.floor import kotlin.math.sqrt /** * Returns the [n]th triangular number, defined as the sum of integers 0..[n]. * * If [n] < 0, this function instead returns `triangleNumber(abs(n) - 1)`. */ fun triangleNumber(n: Int): ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,779
AdventOfCode
MIT License
src/Day13_2.kt
jrmacgill
573,065,109
false
{"Kotlin": 76362}
import utils.splitBy class Day13 { // giberish fun parse(line : String, nest : MutableList<Any>) : Int { var i = 0 var digit = "" while (i < line.length) { i++ if (line[i].isDigit()) { digit += line[i]; continue} when (line[i]) { ...
0
Kotlin
0
1
3dcd590f971b6e9c064b444139d6442df034355b
2,910
aoc-2022-kotlin
Apache License 2.0
src/Day10.kt
tomoki1207
572,815,543
false
{"Kotlin": 28654}
data class Cpu( var x: Int = 1, var cycle: Int = 0 ) { val signalStrengths = mutableListOf<Int>() fun exec(instruction: String, arg: Int?) { when (instruction) { "noop" -> { cycle++ signalStrengths.add(x * cycle) draw() } ...
0
Kotlin
0
0
2ecd45f48d9d2504874f7ff40d7c21975bc074ec
1,392
advent-of-code-kotlin-2022
Apache License 2.0
src/main.kt
BenjaminEarley
151,190,621
false
null
fun main(args: Array<String>) { //Data val primes = arrayOf(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97) val numbers = arrayOf(70, 46, 51, 66, 9, 75, 43) val tree = Branch( Branch(Leaf(4), Leaf(9)), Branch( ...
0
Kotlin
0
0
1a4278273f3d79d4e5bb7054d0e5fb91274e871c
2,599
Functional_Kotlin
MIT License
2019/src/test/kotlin/com/github/jrhenderson1988/adventofcode2019/day22/DeckTest.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day22 import org.junit.Assert.assertEquals import org.junit.Test class DeckTest { @Test fun cut() = mapOf( Pair(Deck.create(0..9), 3) to Deck(listOf(3, 4, 5, 6, 7, 8, 9, 0, 1, 2)), Pair(Deck.create(0..9), -4) to Deck(listOf(6,...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
3,239
advent-of-code
Apache License 2.0
src/main/kotlin/com/staricka/adventofcode2023/days/Day3.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day import com.staricka.adventofcode2023.util.BasicCell import com.staricka.adventofcode2023.util.Grid import com.staricka.adventofcode2023.util.StandardGrid class Day3: Day { /** * Given the start coordinate of a numbe...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
2,596
adventOfCode2023
MIT License
kotlin/app/src/main/kotlin/coverick/aoc/day11/MonkeyInTheMiddle.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day11 import readResourceFile val INPUT_FILE = "monkeyInTheMiddle-input.txt" class Monkey(startingItems: ArrayList<Long>, op: (Long) -> Long, test: (Long)-> Int) { val items = startingItems val op = op val test = test var inspections = 0L fun inspe...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
3,934
adventofcode2022
Apache License 2.0
src/day3.kts
AfzalivE
317,962,201
false
null
println("Start") val input = readInput("day3.txt").readLines().map { it.repeat(500) } val slopes = listOf( Slope(1, 1), Slope(3, 1), Slope(5, 1), Slope(7, 1), Slope(1, 2) ) val treesHit = slopes.map { val treesHit1 = treesHit(it) println("Hit $treesHit1 for $it") treesHit1 } val pr...
0
Kotlin
0
0
cc5998bfcaadc99e933fb80961be9a20541e105d
773
AdventOfCode2020
Apache License 2.0
src/chapter4/section1/ex14.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter4.section1 import edu.princeton.cs.algs4.In import edu.princeton.cs.algs4.Stack /** * 如果用栈代替队列来实现广度优先搜索,我们还能得到最短路径吗? * * 解:能,用两个栈而不是一个栈 * 遍历时,从一个栈中取顶点信息,将顶点的相邻顶点加入另一个栈中,当第一个栈为空时,交换两个栈 * 当两个栈都为空时,遍历结束 * 和用队列实现的广度优先搜索对比,空间复杂度增加了常数值,时间复杂度不变 */ class StackBreadthFirstPath(graph: Graph, val s: Int) :...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,148
Algorithms-4th-Edition-in-Kotlin
MIT License
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day22/Day22.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,495
AdventOfCode
Apache License 2.0
src/com/mrxyx/algorithm/SlidingWindow.kt
Mrxyx
366,778,189
false
null
package com.mrxyx.algorithm /** * 滑动窗口 */ class SlidingWindow { /** * 最小覆盖字串 * https://leetcode-cn.com/problems/minimum-window-substring */ fun minWindow(s: String, t: String): String { val need = HashMap<Char, Int>() val window = HashMap<Char, Int>() //初始化 for...
0
Kotlin
0
0
b81b357440e3458bd065017d17d6f69320b025bf
2,434
algorithm-test
The Unlicense
kotlin/Gauss.kt
indy256
1,493,359
false
{"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571}
import kotlin.math.abs import java.util.Random // https://en.wikipedia.org/wiki/Gauss–Jordan_elimination // returns x such that A * x = b. requires |A| > 0 fun gauss(A: Array<DoubleArray>, b: DoubleArray): DoubleArray { val a = A.mapIndexed { i, Ai -> Ai + b[i] }.toTypedArray() val n = a.size for (i in 0 u...
97
Java
561
1,806
405552617ba1cd4a74010da38470d44f1c2e4ae3
1,323
codelibrary
The Unlicense
src/Day07.kt
RickShaa
572,623,247
false
{"Kotlin": 34294}
import java.util.* fun main() { val fileName = "day07.txt" val testFileName = "day07_test.txt" val input = FileUtil.getListOfLines(fileName); val rootDirectory = Directory("/", null) var currentDirectory = rootDirectory fun String.toChar(): Char { return this.toCharArray()[0] } ...
0
Kotlin
0
1
76257b971649e656c1be6436f8cb70b80d5c992b
3,569
aoc
Apache License 2.0
src/Day13.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
import kotlin.math.max sealed class Packet : Comparable<Packet> { data class Integer(val value: Int) : Packet() data class PacketList(val value: List<Packet>) : Packet() override fun compareTo(other: Packet): Int { when { (this is Integer && other is Integer) -> { retur...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
5,213
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day9.kt
broersma
574,686,709
false
{"Kotlin": 20754}
package days import kotlin.math.absoluteValue import kotlin.math.sign class Day9 : Day(9) { private fun move(tail: Pair<Int, Int>, head: Pair<Int, Int>): Pair<Int, Int> { val dx = head.first - tail.first val dy = head.second - tail.second if (dx.absoluteValue > 1 || dy.absoluteValue > 1) ...
0
Kotlin
0
0
cd3f87e89f7518eac07dafaaeb0f6adf3ecb44f5
2,604
advent-of-code-2022-kotlin
Creative Commons Zero v1.0 Universal
advent-of-code-2022/src/main/kotlin/year_2022/Day04.kt
rudii1410
575,662,325
false
{"Kotlin": 37749}
package year_2022 import util.Runner fun main() { fun Int.inRange(range: List<Int>): Boolean = this in range[0]..range[1] fun List<Int>.withinRange(other: List<Int>): Boolean = get(0).inRange(other) && get(1).inRange(other) fun List<Int>.isOverlapping(other: List<Int>): Boolean = get(0).inRange(ot...
1
Kotlin
0
0
ab63e6cd53746e68713ddfffd65dd25408d5d488
1,048
advent-of-code
Apache License 2.0
kotlin/graphs/matchings/MaxGeneralMatchingRandomized.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package graphs.matchings import java.util.Random object MaxGeneralMatchingRandomized { const val MOD = 29989 fun pow(a: Int, b: Int): Int { var a = a var b = b var res = 1 while (b > 0) { if (b and 1 != 0) res = res * a % MOD a = a * a % MOD ...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,595
codelibrary
The Unlicense
src/main/java/challenges/cracking_coding_interview/trees_graphs/first_common_ancestor/QuestionE.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.first_common_ancestor import challenges.util.TreeNode /** * Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. * Avoid storing additional nodes in a data structure. * NOTE: This is not necessarily a binary se...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,322
CodingChallenges
Apache License 2.0
4/a.kt
DarkoKukovec
159,875,185
false
{"JavaScript": 38238, "Kotlin": 9620}
import java.io.File; data class MostAsleep(val time: Int, val id: String) fun main4A() { var lastGuard: String = ""; var guards: MutableMap<String, MutableMap<Int, Int>> = mutableMapOf(); File("input.txt") .readText(Charsets.UTF_8) .split("\n") .sorted() .map({ line: String -> run { var ma...
0
JavaScript
0
0
58a46dcb9c3e493f91d773ccc0440db9bd3b24b5
1,674
adventofcode2018
MIT License
kotlin/src/main/kotlin/adventofcode/day7/Day7_1.kt
thelastnode
160,586,229
false
null
package adventofcode.day7 import java.io.File data class Input(val step: String, val dependency: String) val LINE_REGEX = Regex("Step (\\w+) must be finished before step (\\w+) can begin") fun parse(line: String): Input { val match = LINE_REGEX.find(line) val (_, dependency, step) = match!!.groupValues ...
0
Kotlin
0
0
8c9a3e5a9c8b9dd49eedf274075c28d1ebe9f6fa
1,301
adventofcode
MIT License
src/main/kotlin/day22/Day22ModeMaze.kt
Zordid
160,908,640
false
null
package day22 import shared.* enum class Type(val c: Char) { Rock('.'), Wet('='), Narrow('|'), Solid('#'); override fun toString() = c.toString() } enum class Equipment { Neither, Torch, ClimbingGear } data class State(val equipment: Equipment, val c: Coordinate) class CaveMap(puzzle: List<String>) { ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
4,610
adventofcode-kotlin-2018
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[746]使用最小花费爬楼梯.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//数组的每个索引作为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。 // // 每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。 // // 您需要找到达到楼层顶部的最低花费。在开始时,你可以选择从索引为 0 或 1 的元素作为初始阶梯。 // // 示例 1: // // 输入: cost = [10, 15, 20] //输出: 15 //解释: 最低花费是从cost[1]开始,然后走两步即可到阶梯顶,一共花费15。 // // // 示例 2: // // 输入: cost = [1, 100, 1, 1, 1, 100, 1, 1, ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,521
MyLeetCode
Apache License 2.0
src/y2022/day05.kt
sapuglha
573,238,440
false
{"Kotlin": 33695}
package y2022 import readFileAsLines fun main() { /* [M] [N] [Z] [F] [R] [Z] [C] [C] [C] [V] [L] [N] [G] [V] [W] [L] [T] [H] [V] [F] [H] [T] [T] [W] [F] [B] [P] [J] [L] [D] [L] [H] [J] [C] [G] [S] [R] [M] [L] [B] [C] [P] [S] [D] [M] ...
0
Kotlin
0
0
82a96ccc8dcf38ae4974e6726e27ddcc164e4b54
2,945
adventOfCode2022
Apache License 2.0
src/Day08.kt
juliantoledo
570,579,626
false
{"Kotlin": 34375}
fun main() { fun isVisible(matrix: MutableList<Array<Int>>, x: Int, y: Int): Boolean { val value = matrix[x][y] if ( y == 0 || x == 0 || y == matrix[x].lastIndex || x == matrix.lastIndex) { return true } else { var left = true var right = true ...
0
Kotlin
0
0
0b9af1c79b4ef14c64e9a949508af53358335f43
3,401
advent-of-code-kotlin-2022
Apache License 2.0