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/Day07.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
import java.util.* fun main() { val testInput = readInput("Day07_test") val testRoot = buildFileSystem(testInput) val testSizeCache = mutableMapOf<Node, Long>() check(part1(testRoot, testSizeCache) == 95437L) check(part2(testRoot, testSizeCache) == 24933642L) val input = readInput("Day07") ...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
4,203
AOC2022
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/sampling/Bijections.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.sampling import ai.hypergraph.kaliningraph.choose import ai.hypergraph.kaliningraph.types.to import kotlin.math.* // Bijection between k-combinations and integers // https://en.wikipedia.org/wiki/Combinatorial_number_system fun Set<Int>.encode(): Int { var (k, i, total) = size to...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
2,917
galoisenne
Apache License 2.0
solution/#2 Add Two Numbers/Solution.kt
enihsyou
116,918,868
false
{"Java": 179666, "Python": 36379, "Kotlin": 32431, "Shell": 367}
package leetcode.q2.kotlin; import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource /** * Definition for singly-linked list. * class ListNode(var `val`: Int = 0) { * ...
1
Java
0
0
230325d1dfd666ee53f304edf74c9c0f60f81d75
2,563
LeetCode
MIT License
app/src/main/kotlin/codes/jakob/aoc/shared/Extensions.kt
loehnertz
725,944,961
false
{"Kotlin": 59236}
package codes.jakob.aoc.shared import java.util.* fun String.splitByLines(): List<String> = split("\n") fun String.splitByCharacter(): List<Char> = split("").filterNot { it.isBlank() }.map { it.toSingleChar() } fun String.splitBySpace(): List<String> = split(" ") fun Int.isEven(): Boolean = this % 2 == 0 fun Int...
0
Kotlin
0
0
6f2bd7bdfc9719fda6432dd172bc53dce049730a
6,426
advent-of-code-2023
MIT License
archive/103/solve.kt
daniellionel01
435,306,139
false
null
/* === #103 Special subset sums: optimum - Project Euler === Let S(A) represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true: S(B) ≠ S(C); that is, sums of subsets cannot be equal. If B contains more ele...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
1,374
euler
MIT License
kotlin/structures/QuadTree.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures // https://en.wikipedia.org/wiki/Quadtree class QuadTree { class Node { var count = 0 var topLeft: Node? = null var topRight: Node? = null var bottomLeft: Node? = null var bottomRight: Node? = null } var root: Node? = null // insert point (x,...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
2,302
codelibrary
The Unlicense
app/src/main/kotlin/me/mataha/misaki/solutions/adventofcode/aoc2015/d06/Day.kt
mataha
302,513,601
false
{"Kotlin": 92734, "Gosu": 702, "Batchfile": 104, "Shell": 90}
package me.mataha.misaki.solutions.adventofcode.aoc2015.d06 import com.github.h0tk3y.betterParse.grammar.parseToEnd import me.mataha.misaki.domain.adventofcode.AdventOfCode import me.mataha.misaki.domain.adventofcode.AdventOfCodeDay /** See the puzzle's full description [here](https://adventofcode.com/2015/day/6). */...
0
Kotlin
0
0
748a5b25a39d01b2ffdcc94f1a99a6fbc8a02685
1,534
misaki
MIT License
src/test/kotlin/adventofcode/day13/Day13.kt
jwcarman
573,183,719
false
{"Kotlin": 183494}
/* * Copyright (c) 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 i...
0
Kotlin
0
0
d6be890aa20c4b9478a23fced3bcbabbc60c32e0
3,662
adventofcode2022
Apache License 2.0
algorithms_and_data_structure/with_kotlin/algoritms/BinarySearch.kt
ggsant
423,455,976
false
{"Dart": 27223, "Kotlin": 6516}
class BinarySearchSolution fun main() { print(binarySearch(arrayOf(12, 3, 24, 5, 10, 23, 9), 23)) } /** * @param array is an array where the element should be found * @param key is an element which should be found * @return index of the element */ fun <T : Comparable<T>> binarySearch(array: Array<T>, key: T): ...
0
Dart
0
1
8ebed6dd46cdbdfada6f19610479191bcc37dd22
1,068
algorithms_analysis_and_data_structure
MIT License
library/src/main/kotlin/com/benmanwaring/permutations/ArrayPermutations.kt
BenManwaring
254,948,525
false
null
package com.benmanwaring.permutations import com.benmanwaring.permutations.iterables.PermutationsIterable import com.benmanwaring.permutations.iterators.ArrayPermutationsIterator import com.benmanwaring.permutations.iterators.IncrementalLengthIterator inline fun <reified T> Array<T>.permutations(length: Int): Iterabl...
1
Kotlin
0
0
a03117de045622723b162c378201bc2705fa7d22
1,444
Permutations
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2023/Day02.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 2 - Cube Conundrum * Problem Description: http://adventofcode.com/2023/day/2 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day2/ */ package com.ginsberg.advent2023 class Day02(input: List<String>) { private val...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
1,559
advent-2023-kotlin
Apache License 2.0
src/main/kotlin/be/tabs_spaces/advent2021/days/Day03.kt
janvryck
433,393,768
false
{"Kotlin": 58803}
package be.tabs_spaces.advent2021.days import kotlin.math.pow class Day03 : Day(3) { override fun partOne(): Any { val diagnostics = Diagnostics.fromInput(inputList) return diagnostics.gammaRate * diagnostics.epsilonRate } override fun partTwo(): Any { val diagnostics = Diagnosti...
0
Kotlin
0
0
f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9
2,708
advent-2021
Creative Commons Zero v1.0 Universal
src/Day06.kt
BenHopeITC
573,352,155
false
null
fun List<Char>.areUnique(): Boolean { return this.size == this.toSet().size } fun String.firstUniqueSequenceOf(length: Int) = String(this.toCharArray().toList() .windowed(length) .first { it.areUnique() } .toCharArray()) fun main() { val day = "Day06" fun part1(input: String) = in...
0
Kotlin
0
0
851b9522d3a64840494b21ff31d83bf8470c9a03
1,000
advent-of-code-2022-kotlin
Apache License 2.0
kotlin/src/2022/Day14_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.sign private data class Point(val x: Int, val y: Int) private fun next(p: Point, m: Map<Point, Int>, yMax: Int) : Point? { if (p.y + 1 >= yMax) return null for (pt in listOf(Point(p.x, p.y + 1), Point(p.x - 1, p.y + 1), Point(p.x + 1, p.y + 1))) if (pt !in m) return pt return nu...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
1,667
adventofcode
Apache License 2.0
atcoder/arc156/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package atcoder.arc156 fun main() { var (_, k) = readInts() val a = readInts().toSet() val f = (0..a.size).first { it !in a } var ans = if (f > 0) take(k, f) else 0.toModularUnsafe() for (x in f..Int.MAX_VALUE) { ans += take(k - 1, x + 1) if (x !in a && --k == 0) break } println(ans) } private fun take(n: ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,478
competitions
The Unlicense
src/main/kotlin/leetcode/kotlin/tree/257. Binary Tree Paths.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.tree private fun binaryTreePaths(root: TreeNode?): List<String> { fun dfs(root: TreeNode?): List<String> { root?.let { if (it.left == null && it.right == null) return mutableListOf("" + it.`val`) var l = dfs(it.left).map { "" + root.`val` + "->" + it } ...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
1,662
kotlinmaster
Apache License 2.0
src/Day01.kt
bendh
573,833,833
false
{"Kotlin": 11618}
fun main() { fun part1(input: List<String>): Int { var max = 0 var temp = 0 input.forEach { if(it.isNotEmpty()) { temp += it.toInt() } else { max = if (temp > max) temp else max temp = 0 } } r...
0
Kotlin
0
0
e3ef574441b63a99a99a095086a0bf025b8fc475
968
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/leetcode/P235.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ class P235 { fun lowestCommonAncestor(root: TreeNode?, p: TreeNode?, q: TreeNode?): TreeNode? { val path1 = path(root!!, p!!) val path2 = path(root, q!!) println() println("path1 = ...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,634
algorithm
MIT License
src/day19/Day19.kt
ritesh-singh
572,210,598
false
{"Kotlin": 99540}
package day19 import readInput private class RobotFactory(lines: List<String>) { private data class BluePrint( val id: Int, val oreRReq: Int, // ore val clayRReq: Int, // ore val obsidianRReq: Pair<Int, Int>, // ore and clay val geodeRReq: Pair<Int, Int> // ore and obsidia...
0
Kotlin
0
0
17fd65a8fac7fa0c6f4718d218a91a7b7d535eab
8,498
aoc-2022-kotlin
Apache License 2.0
src/main/java/com/booknara/problem/search/binary/KthSmallestElementInSortedMatrixKt.kt
booknara
226,968,158
false
{"Java": 1128390, "Kotlin": 177761}
package com.booknara.problem.search.binary /** * 378. Kth Smallest Element in a Sorted Matrix (Medium) * https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/ */ class KthSmallestElementInSortedMatrixKt { // T:O((m + n) * log(max value - min value), S:O(1) fun kthSmallest(matrix: Array<IntArray...
0
Java
1
1
04dcf500ee9789cf10c488a25647f25359b37a53
1,015
playground
MIT License
src/Day01.kt
meierjan
572,860,548
false
{"Kotlin": 20066}
private fun createCaloriesSumArray(input: List<String>) : List<Int> { val calorieGroups = mutableListOf(mutableListOf<Int>()) for(item in input) { if (item.isEmpty()) { calorieGroups.add(mutableListOf()) } else { calorieGroups.last().add(item.toInt()) } } ...
0
Kotlin
0
0
a7e52209da6427bce8770cc7f458e8ee9548cc14
858
advent-of-code-kotlin-2022
Apache License 2.0
day-4/src/both/Both.kt
woojiahao
225,170,972
false
null
package both import timeAndAnswer // Part 1 fun pairInput(i: Int, predicate: (Int, Int) -> Boolean) = i.toString().zipWithNext { a, b -> predicate(a.toInt(), b.toInt()) } fun hasRepeating(i: Int) = pairInput(i) { a, b -> a == b }.any { it } fun isAscending(i: Int) = pairInput(i) { a, b -> a <= b }.all { it } fun...
0
Kotlin
0
2
4c9220a49dbc093fbe7f0d6692fa0390a63e702a
779
aoc-19
MIT License
app/src/main/kotlin/kotlinadventofcode/2016/2016-01.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2016` import com.github.h0tk3y.betterParse.combinators.* import com.github.h0tk3y.betterParse.grammar.* import com.github.h0tk3y.betterParse.lexer.* import kotlinadventofcode.Day import kotlin.math.abs class `2016-01` : Day { /** ...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
5,012
kotlinadventofcode
MIT License
kotlin/src/katas/kotlin/leetcode/merge_k_sorted_lists/MergeSortedLists.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.leetcode.merge_k_sorted_lists import katas.kotlin.leetcode.ListNode import katas.kotlin.leetcode.listNodes import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/problems/merge-k-sorted-lists */ class MergeSortedListsTests { @Test fun `merge k sorted linked lists`() { ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,641
katas
The Unlicense
src/main/kotlin/se/brainleech/adventofcode/aoc2022/Aoc2022Day09.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2022 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readLines import se.brainleech.adventofcode.verify import kotlin.math.max import kotlin.math.min import kotlin.math.sign class Aoc2022Day09 { companion object { const val DEBUG = false ...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
5,027
adventofcode
MIT License
src/main/kotlin/de/tek/adventofcode/y2022/day07/NoSpaceLeftOnDevice.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day07 import de.tek.adventofcode.y2022.util.readInputLines abstract class FileSystemElement(val name: String) { abstract fun getSize(): Int override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is FileSystemElement) return fals...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
6,851
advent-of-code-2022
Apache License 2.0
src/chapter3/section2/ex9.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section2 import chapter1.section4.factorial import chapter2.sleep import chapter2.swap /** * 对于N=2、3、4、5和6,画出用N个键可能构造出的所有不同形状的二叉查找树 * * 解:对于N个不同的键,有N!种插入顺序,可以构造出N!个二叉查找树, * 但是构造的二叉查找树中会有结构相同的树,需要剔除结构相同的树 * 自定义二叉查找树的比较器,从根节点开始依次比较每个结点,只有当结点结构相同、键相同时才认为二叉查找树相同, * 对二叉查找树组成的数组排序,然后去除重复的二叉查找树 * 数组中...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
4,036
Algorithms-4th-Edition-in-Kotlin
MIT License
year2019/src/main/kotlin/net/olegg/aoc/year2019/day18/Day18.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day18 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.find import net.olegg.aoc.utils.get import net.olegg.aoc.utils.set import net.olegg.aoc.year2019.DayOf2019 import java.util.Bit...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
6,130
adventofcode
MIT License
src/test/kotlin/dev/shtanko/algorithms/leetcode/BinaryTreePathsTest.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,933
kotlab
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions58.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 fun test58() { printlnResult1("I am a student.") printlnResult1("I am a student. ") printlnResult2(charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g'), 2) printlnResult2(charArrayOf('H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'), 6) } /** * Questions 58-1:...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,835
Algorithm
Apache License 2.0
kotlin/src/main/kotlin/io/github/ocirne/aoc/year2015/Day7.kt
ocirne
327,578,931
false
{"Python": 323051, "Kotlin": 67246, "Sage": 5864, "JavaScript": 832, "Shell": 68}
package io.github.ocirne.aoc.year2015 import io.github.ocirne.aoc.AocChallenge class Day7(val lines: List<String>) : AocChallenge(2015, 7) { override fun part1(): Int { return run("a") } override fun part2(): Int { val answer1 = part1() return run("a", answer1.toString()) } ...
0
Python
0
1
b8a06fa4911c5c3c7dff68206c85705e39373d6f
2,148
adventofcode
The Unlicense
src/leetcodeProblem/leetcode/editor/en/MultiplyStrings.kt
faniabdullah
382,893,751
false
null
//Given two non-negative integers num1 and num2 represented as strings, return //the product of num1 and num2, also represented as a string. // // Note: You must not use any built-in BigInteger library or convert the inputs //to integer directly. // // // Example 1: // Input: num1 = "2", num2 = "3" //Output: "6" /...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,726
dsa-kotlin
MIT License
src/Day01.kt
krzysztof-wydrzynski
572,895,885
false
{"Kotlin": 1492}
fun main() { fun sumValuesSeparatedByEnter(input: List<String>): List<Int> = input.fold(mutableListOf(0)) { resultList, next -> if (next == "\n" || next.isBlank()) { resultList.add(0) resultList } else { val last: Int = resultList.remo...
0
Kotlin
0
0
f78f576d6334026b66a1e4040149928f7878b5f8
844
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day4.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day4 import aoc.utils.closedRange import aoc.utils.containsFully import aoc.utils.hasOverlap import aoc.utils.readInput fun part1(): Int { return readInput("day4-input.txt") .map { it.split(",") } .map { Pair( toRange(it[0]), toRange(it[1]) ...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
994
adventOfCode2022
Apache License 2.0
src/day20/Day20.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day20 import readInputString import java.lang.Exception import kotlin.system.measureNanoTime data class WorkingNumber(val original: Int, val number: Long) fun main() { fun moveItem(coords: MutableList<WorkingNumber>, index: Int) { val item = coords.find { it.original == index } ?: throw Exception...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
2,084
Advent-Of-Code-2022
Apache License 2.0
algorithms/Kotlin/QuickSort/QuickSort.kt
thuva4
105,735,897
false
{"C++": 165979, "Java": 105820, "Python": 78620, "JavaScript": 50450, "C": 35635, "Swift": 22216, "Go": 20412, "C#": 19569, "Ruby": 10966, "Haskell": 6158, "Kotlin": 5787, "Rust": 4612, "Scala": 4198, "Perl": 1926, "Crystal": 1760, "HTML": 1752, "Makefile": 727, "Racket": 406, "Brainfuck": 308, "CSS": 47}
fun printArray(x: IntArray) { for (i in x.indices) print(x[i].toString() + " ") } fun IntArray.sort(low: Int = 0, high: Int = this.size - 1) { if (low >= high) return val middle = partition(low, high) sort(low, middle - 1) sort(middle + 1, high) } fun IntArray.partition(low: Int, high: I...
9
C++
571
472
7da835fe429c30dfb62fcf412ad397d9dd6407b2
1,096
Algorithms
Apache License 2.0
kotlin/src/2022/Day10_2022.kt
regob
575,917,627
false
{"Kotlin": 50757, "Python": 46520, "Shell": 430}
import kotlin.math.abs private fun part1(input: List<String>): Int { var total = 0 var (bound, boundMx) = 20 to 220 var (x, cycle) = 1 to 0 for (s in input) { val y = if (s == "noop") { cycle += 1 0 } else { cycle += 2 s.split(" ")[1].toIn...
0
Kotlin
0
0
cf49abe24c1242e23e96719cc71ed471e77b3154
1,274
adventofcode
Apache License 2.0
src/main/kotlin/com/github/dangerground/aoc2020/Day17.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput import com.github.dangerground.aoc2020.util.World import kotlin.math.max fun main() { val process = Day17(DayInput.asWorld(17)) println("result part 1: ${process.part1()}") println("result part 2: ${process.part2...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
6,184
adventofcode-2020
MIT License
src/main/kotlin/com/github/dangerground/aoc2020/Day9.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput class Day9(val input: List<Long>, val checkLast: Int) { fun isSumOfLast(ptr: Int): Boolean { val check = input[ptr] val subList = input.subList(ptr - checkLast, ptr) subList.forEach { it1 -> ...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
1,643
adventofcode-2020
MIT License
AOC-2023/src/main/kotlin/Day01.kt
sagar-viradiya
117,343,471
false
{"Kotlin": 72737}
import utils.splitAtNewLines object Day01 { fun day01Part01(input: String): Int { return input.splitAtNewLines().sumOf { val firstDigit = it.first(Char::isDigit) val lastDigit = it.reversed().first(Char::isDigit) "$firstDigit$lastDigit".toInt() } } fun ...
0
Kotlin
0
0
7f88418f4eb5bb59a69333595dffa19bee270064
1,129
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinOneBitOperations.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,855
kotlab
Apache License 2.0
Abundant_odd_numbers/Kotlin/src/Abundant.kt
ncoe
108,064,933
false
{"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409}
fun divisors(n: Int): List<Int> { val divs = mutableListOf(1) val divs2 = mutableListOf<Int>() var i = 2 while (i * i <= n) { if (n % i == 0) { val j = n / i divs.add(i) if (i != j) { divs2.add(j) } } i++ } ...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
1,338
rosetta
MIT License
src/main/kotlin/days/Day3.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils.map import util.Utils.mul class Day3 : Day(3) { private val bitLists = inputList.map { it.toCharArray().map { it.toString().toInt() } } override fun partOne(): Any { return bitLists .reduce { sums, list -> sums.mapIndexed { index, i -> i + list[index] } } ...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
1,366
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/solutions/day02/Day2.kt
Dr-Horv
112,381,975
false
null
package solutions.day02 import solutions.Solver class Day2: Solver { override fun solve(input: List<String>, partTwo: Boolean): String { val rowMapper = if(partTwo) { this::evenlyDivisible } else { this::largestDifference } return input .map...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
1,538
Advent-of-Code-2017
MIT License
UniformCostSearch.kt
malikdawar
356,954,800
false
null
package com.example.academy import org.junit.Test import java.util.* class UniformCostSearch(private val numberOfNodes: Int) { private val priorityQueue: PriorityQueue<Node> private val settled: MutableSet<Int> private val distances: IntArray private val adjacencyMatrix: Array<IntArray> private v...
0
Kotlin
0
0
a13dd335d06bc96d9fb19eed4b89897b8bb181f0
5,873
ArtificialIntelligenceAlgorithms
Apache License 2.0
src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1101_1200.s1139_largest_1_bordered_square // #Medium #Array #Dynamic_Programming #Matrix // #2023_05_31_Time_224_ms_(100.00%)_Space_49.8_MB_(100.00%) class Solution { fun largest1BorderedSquare(grid: Array<IntArray>): Int { val rightToLeft = arrayOfNulls<IntArray>(grid.size) val bottomToU...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,579
LeetCode-in-Kotlin
MIT License
Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [Fácil]/kotlin/juant351.kt
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
package Reto_09 private val allLetters = listOf<Char>( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ) fun main(args: Array<String>...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
1,860
retos-programacion-2023
Apache License 2.0
gcj/y2020/round1b/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2020.round1b private fun solve(): String { var (x, y) = readInts() val steps = (x.abs() + y.abs()).countSignificantBits() return (steps - 1 downTo 0).map { i -> val dir = DX.indices.maxByOrNull { x * DX[it] + y * DY[it] }!! x -= DX[dir] shl i; y -= DY[dir] shl i DIR_ROSE[dir] }.joinToString("")....
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
893
competitions
The Unlicense
src/main/kotlin/com/hj/leetcode/kotlin/problem785/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem785 /** * LeetCode page: [785. Is Graph Bipartite?](https://leetcode.com/problems/is-graph-bipartite/); */ class Solution { /* Complexity: * Time O(N+E) and Space O(N) where N is the size of graph and E is the size of flattened graph; */ fun isBipartite(graph: ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,234
hj-leetcode-kotlin
Apache License 2.0
code/number_theory/GCD.kt
hakiobo
397,069,173
false
null
private fun gcd(p: Int, q: Int): Int { return if (p < 0) gcd(-p, q) else if (q < 0) gcd(p, -q) else if (p == 0) q else if (q == 0) p else if (p and 1 == 0 && q and 1 == 0) gcd(p shr 1, q shr 1) shl 1 else if (p and 1 == 0) gcd(p shr 1, q) else if (q and 1 == 0) gcd(p, q shr 1) else if (p...
0
Kotlin
1
2
f862cc5e7fb6a81715d6ea8ccf7fb08833a58173
778
Kotlinaughts
MIT License
src/main/kotlin/dev/shtanko/algorithms/extensions/Int.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,831
kotlab
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day4/Scratchcard.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day4 import kotlin.math.pow private val WHITESPACE_REGEX = "\\s+".toRegex() private val CARD_REGEX = "Card$WHITESPACE_REGEX(\\d+): (.*) \\| (.*)".toRegex() private fun String.toNumberSet(): Set<Int> { return trim() .split(WHITESPACE_REGEX) .map(String::to...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,438
advent-2023
ISC License
src/Day06.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
fun main() { fun solve(input: String, size: Int) = input .windowed(size) .mapIndexed { index, sequence -> index to sequence } .first { it.second.toCharArray().toSet().size == size } .first + size fun part1(input: String): Int = solve(input, 4) fun part2(...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
787
advent-of-code-2022
Apache License 2.0
Kotlin/sort/RadixSort/src/RadixSort.kt
HarshCasper
274,711,817
false
{"C++": 1488046, "Java": 948670, "Python": 703942, "C": 615475, "JavaScript": 228879, "Go": 166382, "Dart": 107821, "Julia": 82766, "C#": 76519, "Kotlin": 40240, "PHP": 5465}
// Function to Implement Radix Sort // The radix sorting algorithm is an integer sorting algorithm, // that sorts by grouping numbers by their individual digits (or by their radix). // It uses each radix/digit as a key, and implements counting sort or // bucket sort under the hood in order to do the work of sorting. ...
2
C++
1,086
877
4f1e5bdd6d9d899fa354de94740e0aecf5ecd2be
1,917
NeoAlgo
MIT License
src/main/kotlin/g2501_2600/s2559_count_vowel_strings_in_ranges/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2559_count_vowel_strings_in_ranges // #Medium #Array #String #Prefix_Sum #2023_07_07_Time_638_ms_(100.00%)_Space_111.2_MB_(25.00%) class Solution { fun vowelStrings(words: Array<String>, queries: Array<IntArray>): IntArray { val vowels = HashSet(listOf('a', 'e', 'i', 'o', 'u')) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,057
LeetCode-in-Kotlin
MIT License
year2023/day08/part1/src/main/kotlin/com/curtislb/adventofcode/year2023/day08/part1/Year2023Day08Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 8: Haunted Wasteland --- You're still riding a camel across Desert Island when you spot a sandstorm quickly approaching. When you turn to warn the Elf, she disappears before your eyes! To be fair, she had just finished warning you about ghosts a few minutes ago. One of the camel's pouches is labeled "maps"...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,750
AdventOfCode
MIT License
2021/src/main/kotlin/aoc2021/day18/Day18.kt
dkhawk
433,915,140
false
{"Kotlin": 170350}
package aoc2021.day18 import java.util.LinkedList import java.util.Queue import kotlin.math.ceil import kotlin.math.floor import kotlin.system.measureTimeMillis import utils.COLORS import utils.Input import utils.NO_COLOR @OptIn(ExperimentalStdlibApi::class) class Day18 { companion object { fun run() { va...
0
Kotlin
0
0
64870a6a42038acc777bee375110d2374e35d567
10,970
advent-of-code
MIT License
src/main/kotlin/Day008Idiomatic.kt
ruffCode
398,923,968
false
null
import kotlin.time.measureTimedValue // all credit to @SebastianAigner object Day008Idiomatic { val input = PuzzleInput("day008.txt").readText().split(newLine) @JvmStatic fun main(args: Array<String>) { val inst = input.toInstr() println( measureTimedValue { exe...
0
Kotlin
0
0
477510cd67dac9653fc61d6b3cb294ac424d2244
3,753
advent-of-code-2020-kt
MIT License
src/main/kotlin/segtree.kt
AlBovo
574,593,169
false
{"Kotlin": 75843}
import kotlin.math.* class SegmentTree(array: Array<Int>){ private var segment = Array<Int>(0){ 0 } private var size = 0 private var sizeOfInitialArray = 0 init{ size = 1 shl ceil(log2(array.size.toFloat())).toInt() sizeOfInitialArray = array.size segment = Array(size * 2){ 0 }...
0
Kotlin
0
0
56a31313c53cc3525d2aa3c29b3a2085b1b1b506
2,646
Compiti
MIT License
src/main/kotlin/day25.kt
Gitvert
433,947,508
false
{"Kotlin": 82286}
fun day25() { val lines: List<String> = readFile("day25.txt") day25part1(lines) day25part2(lines) } fun day25part1(lines: List<String>) { val seaFloor = getSeaFloor(lines) var noOfMovers: Int var steps = 0 do { steps++ noOfMovers = 0 noOfMovers += moveEast(seaFloo...
0
Kotlin
0
0
02484bd3bcb921094bc83368843773f7912fe757
2,368
advent_of_code_2021
MIT License
src/main/kotlin/com/github/brpeterman/advent2022/RpsSim.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 class RpsSim { fun simulateAndScore(plays: List<Pair<String, String>>): Int { return plays.fold(0, { total, play -> total + scorePlay(play.first, toPlay(play.second)) }) } fun strategizeAndScore(plays: List<Pair<String, String>>): Int { ...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
2,447
advent2022
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[剑指 Offer 03]数组中重复的数字.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//找出数组中重复的数字。 // // //在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请 //找出数组中任意一个重复的数字。 // // 示例 1: // // 输入: //[2, 3, 1, 0, 2, 5, 3] //输出:2 或 3 // // // // // 限制: // // 2 <= n <= 100000 // Related Topics 数组 哈希表 // 👍 237 👎 0 //leetcode submit region begin(Prohibit modificati...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
944
MyLeetCode
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec12.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester import kotlin.math.abs class Dec12 : PuzzleDayTester(12, 2020) { override fun part1(): Int = parse().sail(1 to 0, true) override fun part2(): Int = parse().sail(10 to 1, false) private fun List<Pair<Char, Int>>.sail(initialVec...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,319
advent-of-code
MIT License
src/main/kotlin/biz/koziolek/adventofcode/year2022/day21/day21.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2022.day21 import biz.koziolek.adventofcode.* import java.util.* fun main() { val inputFile = findInput(object {}) val yellingMonkeys = parseYellingMonkeys(inputFile.bufferedReader().readLines()) println("'root' monkey yells: ${findYelledNumber("root", yellingMonkeys)...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
5,651
advent-of-code
MIT License
2020/kotlin/day-2/main.kt
waikontse
330,900,073
false
null
import util.FileUtils fun main() { println ("This is day #2") val fileUtils = FileUtils("input.txt") val validPasswordCount = fileUtils.lines .map {fullLine -> fullLine.split(' ')} .filter(::isPasswordValid2) .count() println ("The total number of correct passwords: $validPas...
0
Kotlin
0
0
abeb945e74536763a6c72cebb2b27f1d3a0e0ab5
1,522
advent-of-code
Creative Commons Zero v1.0 Universal
src/day08/Day08.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day08 import readInput fun main() { fun visibilityHorizontally(input: List<List<Int>>, xRange: IntProgression, startVisibility: Int = -1): Array<BooleanArray> { val mask = Array(input.size) { BooleanArray(input[0].size) { false } } for (y in 0..input.lastIndex) { var previousT...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
4,996
advent-of-code-2022
Apache License 2.0
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/SortingAlgorithms/OnSortingAlgorithms/BubbleSort.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
package com.betulnecanli.kotlindatastructuresalgorithms.SortingAlgorithms.OnSortingAlgorithms /*One of the simplest sorts is the bubble sort. The bubble sort repeatedly compares adjacent values and swaps them, if needed, to perform the sort. The larger values in the set will, therefore, bubble...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,360
Kotlin-Data-Structures-Algorithms
Apache License 2.0
src/main/kotlin/Day15.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
import utils.execFileByLine private enum class Operation(value: String) { ADD("="), REMOVE("-") } private data class Lens( val label: String, val focalLength: Int, ) private data class LensOperation( val lens: Lens, val operation: Operation, val boxNo: Int ) class Day15 { private val bo...
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
2,659
aoc2023
Apache License 2.0
kotlin/692.Top K Frequent Words(前K个高频单词).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p>Given a non-empty list of words, return the <i>k</i> most frequent elements.</p> <p>Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first.</p> <p><b>Example 1:</b><br /> <pre> <b>Input:</b> ["i", "love"...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
4,593
leetcode
MIT License
src/Day16.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
import java.util.StringJoiner import kotlin.math.max class RatedVertex( val name: String, val rate: Int, var edges: Set<RatedVertex> = setOf() ) class Edge(val v1: RatedVertex, val v2: RatedVertex, val weight: Int) class ParseResult(val vertex: RatedVertex, val neighbors: Set<String>) class Day16 { ...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
5,661
advent-of-code
Apache License 2.0
src/main/kotlin/day9.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* fun main() { val input = Input.day(9) println(day9A(input)) println(day9B(input)) } fun day9A(input: Input): Long { val sequences = input.lines.map { Sequence(it.toLongs().toMutableList()) } sequences.forEach { it.addNextValue() } return sequences.sumOf { it.values.last() } } ...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
1,248
AdventOfCode2023
MIT License
src/main/java/com/barneyb/aoc/aoc2021/day06/Lanternfish.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2021.day06 import com.barneyb.aoc.util.Solver fun main() { Solver.execute( ::parse, { nDays(it, 80) }, { nDays(it, 256) }, ) } fun parse(input: String): LongArray { val hist = LongArray(9) input.trim() .split(',') .map(String::toInt) ...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
817
aoc-2022
MIT License
src/main/java/challenges/cracking_coding_interview/bit_manipulation/flip_bit_to_win/QuestionD.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.bit_manipulation.flip_bit_to_win /** * You have an integer, and you can flip exactly one bit from a 0 to a 1. * Write code to find the length of the longest sequence of ls you could create. * EXAMPLE * Input: 1775 (or: 11011101111) Output: 8 */ object QuestionD { ...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
1,614
CodingChallenges
Apache License 2.0
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day10.kt
JamJaws
725,792,497
false
{"Kotlin": 30656}
package com.jamjaws.adventofcode.xxiii.day import com.jamjaws.adventofcode.xxiii.readInput import java.awt.Polygon class Day10 { fun part1(text: List<String>): Int { val (xStart, yStart) = getStartCoordinate(text) val start = Pipe(xStart, yStart, PipeType.START) val loop = getPipeLoop(st...
0
Kotlin
0
0
e2683305d762e3d96500d7268e617891fa397e9b
3,976
advent-of-code-2023
MIT License
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day03Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.* private fun solution1(input: String) = input.lineSequence() .splitCompartments() .totalPriorityOfOverlappingItems() private fun Sequence<String>.sp...
1
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
1,676
adventofcode-kotlin
MIT License
src/Day01.kt
patrickwilmes
572,922,721
false
{"Kotlin": 6337}
typealias ElvesWithTotalCalories = List<List<Int>> fun main() { val calculateCaloriesCarriedByAllElves: (List<String>) -> ElvesWithTotalCalories = { it.fold(mutableListOf(mutableListOf<Int>())) { acc, item -> if (item.isBlank()) { acc.add(mutableListOf()) } else { ...
0
Kotlin
0
0
162c8f1b814805285e10ea4e3ab944c21e8be4c5
910
advent-of-code-2022
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day282/day282.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day282 // day282.kt // By <NAME>, 2020. typealias Triplet = Triple<Int, Int, Int> /** * Find the first Pythagorean triplet (in lexicographic order) in a collection of integers. * This is a triple (a, b, c) such that: * 1. a, b, c > 0 and a < b * 2. a^2 + b^2 = c^2. */ fun Collection<Int>.findPythagor...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,112
daily-coding-problem
MIT License
src/Day03.kt
arhor
572,349,244
false
{"Kotlin": 36845}
fun main() { val input = readInput {} println("Part 1: " + solvePuzzle1(input)) println("Part 2: " + solvePuzzle2(input)) } private fun solvePuzzle1(input: List<String>): Int { return input.sumOf { line -> val l = line.substring(0, line.length / 2) val r = line.substring(line.length / ...
0
Kotlin
0
0
047d4bdac687fd6719796eb69eab2dd8ebb5ba2f
564
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2022/Day21.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 21 - Monkey Math * Problem Description: http://adventofcode.com/2022/day/21 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day21/ */ package com.ginsberg.advent2022 class Day21(input: List<String>) { private val...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
3,971
advent-2022-kotlin
Apache License 2.0
src/graphs/weighted/DirectedWeightedGraph.kt
ArtemBotnev
136,745,749
false
{"Kotlin": 79256, "Shell": 292}
package graphs.weighted /** * Model of directed weighted graph */ class DirectedWeightedGraph<T>(maxVertexCount: Int, infinity: Long) : WeightedGraph<T>(maxVertexCount, infinity) { override fun addEdge(first: T, second: T, weight: Long): Boolean { val values = vertexList.map { it.value } val...
0
Kotlin
0
0
530c02e5d769ab0a49e7c3a66647dd286e18eb9d
6,113
Algorithms-and-Data-Structures
MIT License
src/main/kotlin/com/eric/leetcode/MaxAreaOfIsland.kt
wanglikun7342
163,727,208
false
{"Kotlin": 172132, "Java": 27019}
package com.eric.leetcode class MaxAreaOfIsland { private lateinit var grid: Array<IntArray> private lateinit var seen: Array<BooleanArray> private var count = 0 var dr = intArrayOf(1, -1, 0, 0) var dc = intArrayOf(0, 0, 1, -1) private fun getArea(r: Int, c: Int): Int { count++ ...
0
Kotlin
2
8
d7fb5ff5a0a64d9ce0a5ecaed34c0400e7c2c89c
3,096
Leetcode-Kotlin
Apache License 2.0
src/year2022/day22/Day22.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day22 import Point2D import readInputFileByYearAndDay import readTestFileByYearAndDay import year2022.day22.Orientation.* import kotlin.math.max import kotlin.math.min enum class Orientation(val direction: Point2D, val facing: Int) { UP(Point2D(0, -1), 3), DOWN(Point2D(0, 1), 1), LEFT(Poi...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
11,789
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem706/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem706 import java.util.* /** * LeetCode page: [706. Design HashMap](https://leetcode.com/problems/design-hashmap/); */ class MyHashMap() { private var buckets = Array(8) { LinkedList<Pair<Int, Int>>() } private var totalEntries = 0 fun get(key: Int): Int { r...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,831
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem718/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem718 /** * LeetCode page: [718. Maximum Length of Repeated Subarray](https://leetcode.com/problems/maximum-length-of-repeated-subarray/); */ class Solution { /* Complexity: * Time O(MN) and Space O(1) where M and N are the size of nums1 and nums2; */ fun findLen...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,804
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/io/dp/MinimumAsciiDeleteTwoStrings.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.dp import io.utils.runTests // https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/ class MinimumAsciiDeleteTwoStrings { fun execute(initial: String, goal: String): Int { val dp = Array(initial.length + 1) { row -> IntArray(goal.length + 1) { col -> when { ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,165
coding
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/Permutations.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,829
kotlab
Apache License 2.0
src/Day06.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
private fun solve(input: List<String>, k: Int): Int { val s = input[0] for (i in 0 until s.length - k) { if (s.substring(i, i + k).toSet().size == k) { return i + k } } return -1 } private fun part1(input: List<String>) = solve(input, 4) private fun part2(input: List<String...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
557
AOC2022
Apache License 2.0
src/Day01.kt
KyleMcB
573,097,895
false
{"Kotlin": 1762}
import kotlin.math.max fun main() { val input = readInput("Day01") println("solution to puzzle 1 ${solution1(input)}") println("solution to puzzle 2 ${solution2(input)}") } // list of numbers with an extra new line to seperate groups // I need to sum the groups and find the greatest fun solution1(input: L...
0
Kotlin
0
0
d3ad4cf2940507207276f5e5ed2eb1149300802f
1,125
2022-AOC
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[100]相同的树.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定两个二叉树,编写一个函数来检验它们是否相同。 // // 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 // // 示例 1: // // 输入: 1 1 // / \ / \ // 2 3 2 3 // // [1,2,3], [1,2,3] // //输出: true // // 示例 2: // // 输入: 1 1 // / \ // 2 2 // // [1,...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,559
MyLeetCode
Apache License 2.0
src/main/kotlin/Day20.kt
dlew
75,886,947
false
null
import java.util.* class Day20 { companion object { fun findLowest(input: String) = merge(parse(input))[0].endInclusive + 1 fun count(input: String, max: Long): Long { val merged = merge(parse(input)) val betweenRanges = merged.slidingWindow(2).fold(0L, { count, ranges -> count + (ranges...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
1,261
aoc-2016
MIT License
src/test/kotlin/de/tek/adventofcode/y2022/day02/RockPaperScissorsTest.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day02 import de.tek.adventofcode.y2022.day02.Choice.Rock as Rock import de.tek.adventofcode.y2022.day02.Choice.Paper as Paper import de.tek.adventofcode.y2022.day02.Choice.Scissors as Scissors import de.tek.adventofcode.y2022.day02.Result.Win as Win import de.tek.adventofcode.y2022.da...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
2,861
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day10/Day10.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day10 import common.InputRepo import common.readSessionCookie import common.solve import util.splitIntoPair data class AddExecution(var cycles: Int, val arg: Int) { fun cycle() { cycles-- } } fun main(args: Array<String>) { val day = 10 val input = InputRepo(args.readSessionCookie())....
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
2,412
AdventOfCode2022
Apache License 2.0
src/main/java/Exercise11.kt
cortinico
317,667,457
false
null
fun main() { val input: List<CharArray> = object {} .javaClass .getResource("input-11.txt") .readText() .split("\n") .map(String::toCharArray) var array1 = Array(input.size) { i -> CharArray(input[i].size) { j -> input[i][j] } } var array2...
1
Kotlin
0
4
a0d980a6253ec210433e2688cfc6df35104aa9df
2,150
adventofcode-2020
MIT License
src/Day10.kt
anisch
573,147,806
false
{"Kotlin": 38951}
fun getSignalStrength(cycles: Int, registerX: Int) = if (cycles % 40 == 20) cycles * registerX else 0 fun main() { fun part1(input: List<String>): Int { var cycles = 0 var regX = 1 var signalSum = 0 input.forEach { ins -> if (ins == "noop") { si...
0
Kotlin
0
0
4f45d264d578661957800cb01d63b6c7c00f97b1
1,916
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/co/csadev/advent2020/Day08.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/* * Copyright (c) 2021 by <NAME> */ package co.csadev.advent2020 class Day08(input: List<String>) { data class Instruction(var instr: String, val movement: Int, var count: Int = 0) { val inc: Int get() = when (instr) { "acc" -> movement else -> 0 ...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,954
advent-of-kotlin
Apache License 2.0
src/main/kotlin/dp/AlphaCombin.kt
yx-z
106,589,674
false
null
package dp import util.get // given a = 1, b = 2, c = 3, ..., z = 26 // and a number (as a string), determine the number of ways to interpret this number into alphabets // ex. 123 == [12, 3] -> lc // == [1, 2, 3] -> abc // == [1, 23] -> aw // so we should return 3 // note that no leading 0s are allo...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,615
AlgoKt
MIT License
src/main/kotlin/com/kishor/kotlin/algo/algorithms/dynamicprogramming/Fibbonacci.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.dynamicprogramming fun main() { val table = mutableMapOf<Int, Long>() table.put(0, 1) table.put(1, 1) println("Fibbo recursion ${fibbonacciRecursion(30)}") println("Fibbo Memoization ${fibonacciMemoization(100, table)}") println("Fibbo Tabbulation ${fib...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,035
DS_Algo_Kotlin
MIT License
day11/kotlin/RJPlog/day2311_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File import kotlin.math.* fun day11(in1: Int): Long { var expansionValue = 1 if (in1 == 2) { expansionValue = 1000000 - 1 } var universe: String = "" var xDim = 0 var yDim = 0 var galaxyMap = mutableMapOf<Int, Pair<Int, Int>>() var galaxyCount = 1 File("day2311_puzzle_input.txt").forEachLin...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
1,913
aoc-2023
MIT License
src/main/kotlin/net/devromik/poly/Polynomial.kt
devromik
53,753,715
false
null
package net.devromik.poly import net.devromik.poly.utils.COMPLEX_ZERO import net.devromik.poly.utils.Complex import net.devromik.poly.utils.times import java.lang.Math.max /** * @author <NAME> */ class Polynomial(val coeffs: DoubleArray) { init { require(coeffs.size > 0) } // ******************...
0
Kotlin
0
0
ff340e0284d1756502d66e84106853416521aa6f
3,287
poly
MIT License
src/Day11.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
import javax.script.ScriptEngineManager class Monkey ( var items: MutableList<Long> = mutableListOf(), val operation: (Long) -> Long, val testNum: Int, private val throwToMonkey: Pair<Int,Int> ) { var itemsExamined = 0 var manageWorry = {worry: Long -> worry/3} fun examineItems(monkeyList: ...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
5,377
2022-aoc-kotlin
Apache License 2.0