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/Day05.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader import java.util.* fun main() { val testInput = """ [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 """.trimIndent() val testResultStacks = par...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
3,916
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/year2022/day-04.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.aoc.Day import lib.aoc.Part fun main() { Day(4, 2022, PartA4(), PartB4()).run() } open class PartA4 : Part() { data class Section(val start1: Int, val end1: Int, val start2: Int, val end2: Int) internal lateinit var sections: List<Section> override fun parse(text: String...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
1,668
Advent-Of-Code-Kotlin
MIT License
src/array/LeetCode350.kt
Alex-Linrk
180,918,573
false
null
package array import java.util.* /** * 350. 两个数组的交集 II * 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2,2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [4,9] 说明: 输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。 我们可以不考虑输出结果的顺序。 进阶: 如果给定的数组已经排好序呢?你将如何优化你的算法? 如果 nums1 的大小比 nums2 小很多,哪种方法更优? 如果 nu...
0
Kotlin
0
0
59f4ab02819b7782a6af19bc73307b93fdc5bf37
1,976
LeetCode
Apache License 2.0
src/Day07.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") private const val DAY = "07" private const val PART1_CHECK = 95437 private const val PART2_CHECK = 24933642 abstract class FsEntry( open val name: String, val parent: Directory?, ) { abstract fun print(depth: Int = 0) abstract val size: Int open fun printLnIndented...
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
4,165
adventofcode2022
Apache License 2.0
src/main/kotlin/com/github/javadev/sort/MergeSort.kt
javadev
156,964,261
false
null
package com.github.javadev.sort import java.util.Arrays /* public class MergeSort { public void mergeSort(int[] array) { mergeSort(array, 0, array.length - 1); } void mergeSort(int[] array, int low, int high) { if (high - low < 2) { return; } if (low < high) { int mid = low + (hig...
0
Kotlin
0
5
3f71122f1d88ee1d83acc049f9f5d44179c34147
2,379
classic-cherries-kotlin
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/SwapNodesInPairs.kt
faniabdullah
382,893,751
false
null
//Given a linked list, swap every two adjacent nodes and return its head. You //must solve the problem without modifying the values in the list's nodes (i.e., //only nodes themselves may be changed.) // // // Example 1: // // //Input: head = [1,2,3,4] //Output: [2,1,4,3] // // // Example 2: // // //Input: head ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,638
dsa-kotlin
MIT License
kotlin/src/katas/kotlin/leetcode/generate_parens/GenerateParensTests.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.generate_parens import katas.kotlin.softFail import org.junit.jupiter.api.Test abstract class GenerateParensTests(val generate: (Int) -> List<String>) { @Test fun `it works`() = softFail { generate(1) shouldEqual listOf("()") generate(2) shouldEqual listOf("()()", "((...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,492
katas
The Unlicense
src/main/kotlin/github/walkmansit/aoc2020/Day18.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 import java.util.* class Day18(val input: List<String>) : DayAoc<Long, Long> { class Calculator private constructor(private val expressions: Array<String>) { private val operations = setOf('+', '*') fun calsEvalSums(): Long { var sum = 0L ...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
4,700
AdventOfCode2020
MIT License
src/main/java/com/barneyb/aoc/aoc2016/day18/LikeARogue.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2016.day18 import com.barneyb.aoc.util.Solver fun main() { Solver.execute( ::parse, { safeTileCount(it, 40) }, { safeTileCount(it, 400000) }, ) } internal fun parse(input: String) = input.trim().let { val arr = BooleanArray(it.length) for...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
1,329
aoc-2022
MIT License
src/main/kotlin/Day1/Day01.kt
fisherthewol
433,544,714
false
{"Kotlin": 8877}
package Day1 import readInput fun part1(lines: List<Int>): Int { var depthIncrease = 0 var prevMeasure: Int var currentMeasure = Int.MAX_VALUE for (line in lines) { prevMeasure = currentMeasure // Move along one. currentMeasure = line if (currentMeasure > prevMeasure) depthIncr...
0
Kotlin
0
0
d078aa647c666adf3d562fb1c67de6bef9956bcf
1,002
AoC2021
MIT License
app/src/main/java/com/cornellappdev/uplift/models/FacilityInfoModels.kt
cuappdev
596,747,757
false
{"Kotlin": 273937}
package com.cornellappdev.uplift.models /** * A facility representing one court at a fitness center. */ data class CourtFacility( /** The court's name (e.g. "Court 1") */ val name: String, /** Exactly 7 lists of [CourtTime] objects: Monday, Tuesday, etc. for this court. */ val hours: List<List<CourtT...
1
Kotlin
0
1
c5bc20ab8a0364c6620ff7adf48cfbaa7295100c
1,701
uplift-android
MIT License
src/main/kotlin/_0054_SpiralMatrix.kt
ryandyoon
664,493,186
false
null
// https://leetcode.com/problems/spiral-matrix fun spiralOrder(matrix: Array<IntArray>): List<Int> { val numIndices = matrix.size * matrix.first().size val spiral = mutableListOf<Int>() val viewed = Array(matrix.size) { BooleanArray(matrix.first().size) } var row = 0 var col = 0 var rowOffset = ...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
1,474
leetcode-kotlin
MIT License
src/main/kotlin/Matrix.kt
snikiforov4
485,917,499
false
{"Kotlin": 9895}
package processor import kotlin.math.pow class Matrix(private val matrix: Array<Array<Double>>) { companion object { fun empty(n: Int, m: Int = n): Matrix { require(n > 0) require(m > 0) return Matrix(Array(n) { Array(m) { 0.0 } }) } } val sizesOfDimen...
0
Kotlin
0
0
ace36ad30c0a2024966744792a45e98b3358e10d
4,302
numeric-matrix-processor
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1027/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1027 /** * LeetCode page: [1027. Longest Arithmetic Subsequence](https://leetcode.com/problems/longest-arithmetic-subsequence/); */ class Solution { /* Complexity: * Time O(N^2) and Space O(N^2) where N is the size of nums; */ fun longestArithSeqLength(nums: In...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,238
hj-leetcode-kotlin
Apache License 2.0
Retos/Reto #39 - TRIPLES PITAGÓRICOS [Media]/kotlin/pisanowp.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": ...
fun main() { /* * Reto #39 02/10/2023 TRIPLES PITAGÓRICOS * * Crea una función que encuentre todos los triples pitagóricos * (ternas) menores o iguales a un número dado. * - Debes buscar información sobre qué es un triple pitagórico. * - La función únicamente recibe el número máximo que pu...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
1,312
retos-programacion-2023
Apache License 2.0
src/main/kotlin/nl/jackploeg/aoc/_2022/calendar/day02/Day02.kt
jackploeg
736,755,380
false
{"Kotlin": 318734}
package nl.jackploeg.aoc._2022.calendar.day02 import javax.inject.Inject import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory import nl.jackploeg.aoc.utilities.readStringFile class Day02 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun partOne(fileName: String...
0
Kotlin
0
0
f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76
2,790
advent-of-code
MIT License
src/main/kotlin/days/Day4.kt
hughjdavey
225,440,374
false
null
package days class Day4 : Day(4) { private val range = inputString.split('-').map { it.trim().toInt() } override fun partOne(): Any { return (range[0]..range[1]).count { meetsPasswordCriteria(it.toString()) } } override fun partTwo(): Any { return (range[0]..range[1]).count { meetsEx...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
859
aoc-2019
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day12.kt
pavittr
317,532,861
false
null
import java.io.File import java.nio.charset.Charset import kotlin.math.absoluteValue import kotlin.streams.toList fun main() { val testDocs = File("test/day12").readLines(Charset.defaultCharset()) val puzzles = File("puzzles/day12").readLines(Charset.defaultCharset()) var initBoat = Triple(0, 0, "E") ...
0
Kotlin
0
0
3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04
4,585
aoc2020
Apache License 2.0
src/main/kotlin/Rucksack.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
import java.lang.RuntimeException fun main() { var result = 0 for (group in readRucksack()) { result += charScore(findGroupBadge(group)) } println("Total score: $result") } private typealias Group = MutableList<String> private fun readRucksack(): Iterable<Group> { val result = mutableList...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
1,183
aoc2022
MIT License
Kotlin/problems/0032_verify_preorder_serialization_binary_tree.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
// Problem Statement // One way to serialize a binary tree is to use pre-order traversal. // When we encounter a non-null node, we record the node's value. // If it is a null node, we record using a sentinel value such as #. // // _9_ // / \ // 3 2 // / \ / \ // 4 1 # 6 // / \ / \ / \ // # ...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
2,364
algorithms
MIT License
src/main/kotlin/arraysandstrings/MinimumCostToHireKWorkers.kt
e-freiman
471,473,372
false
{"Kotlin": 78010}
package arraysandstrings import java.util.PriorityQueue fun mincostToHireWorkers(quality: IntArray, wage: IntArray, k: Int): Double { val x = wage.indices.sortedWith {a, b -> val ra = wage[a].toDouble() / quality[a].toDouble() val rb = wage[b].toDouble() / quality[b].toDouble() ...
0
Kotlin
0
0
fab7f275fbbafeeb79c520622995216f6c7d8642
916
LeetcodeGoogleInterview
Apache License 2.0
lib_algorithms_sort_kotlin/src/main/java/net/chris/lib/algorithms/sort/kotlin/KTHeapSorter.kt
chrisfang6
105,401,243
false
{"Java": 68669, "Kotlin": 26275, "C++": 12503, "CMake": 2182, "C": 1403}
package net.chris.lib.algorithms.sort.kotlin /** * Heap sort. * * @param <T> </T> */ abstract class KTHeapSorter : KTSorter() { override fun subSort(array: IntArray) { if (array == null) { return } var heapsize = array.size buildheap(array) for (i in 0 until ...
0
Java
0
0
1f1c2206d5d9f0a3d6c070a7f6112f60c2714ec0
1,555
sort
Apache License 2.0
src/main/kotlin/com/github/amolkov/kotlin/algorithms/sorting/QuickSort.kt
amolkov
122,844,991
false
null
package com.github.amolkov.kotlin.algorithms.sorting import com.github.amolkov.kotlin.algorithms.extensions.swap class QuickSort { companion object { /** * Sorts the specified array into ascending order, according to the natural ordering of its elements, * using the quick sort algori...
0
Kotlin
0
0
acb6bc2e397087fec8432b3307d0c0ea0c6ba75b
1,205
kotlin-algorithms
Apache License 2.0
Kotlin101/11-flow-control/03_For.kt
ge47jaz
695,323,673
false
{"Kotlin": 77958}
import kotlin.text.toInt // different vaiations of for loops // ranges fun printOneToTen() { for (i in 1..10) { println(i) } } fun printTenToOne() { for (i in 10 downTo 1) { println(i) } } fun printOddsOneToTen() { for (i in 1..10 step 2) { println(i) } } fun printOd...
0
Kotlin
0
0
87dba8f8137c32d0ef6912efd5999675a2620ab4
3,936
kotlin-progress
MIT License
src/questions/ReverseWordsInStringIII.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.lang.StringBuilder /** * Given a string s, reverse the order of characters in each word within a sentence * while still preserving whitespace and initial word order. * * [Source](https://leetcode.com/problems/reverse-words...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,930
algorithms
MIT License
shared/src/commonMain/kotlin/com/aglushkov/wordteacher/shared/repository/dict/Trie.kt
soniccat
302,971,014
false
{"Kotlin": 1008121, "Go": 137919, "Swift": 38695, "TypeScript": 29600, "Dockerfile": 5486, "Makefile": 3673, "JavaScript": 3131, "Ruby": 1740, "HTML": 897, "Java": 872, "SCSS": 544, "C": 59, "Shell": 58}
package com.aglushkov.wordteacher.shared.repository.dict import com.aglushkov.wordteacher.shared.general.extensions.addElements abstract class Trie<T, D>: Iterable<T> { private val root = TrieNode<T>("", null) abstract fun createEntry(node: TrieNode<T>, data: D): T abstract fun setNodeForEntry(entry: T,...
0
Kotlin
1
10
b904cbee5072a15a4be51f2346d460aa662c1ea4
12,033
WordTeacher
MIT License
Hyperskill/Numeric-Matrix-Processor/Main.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
package processor import java.util.* val s = Scanner(System.`in`) fun main() { loop@ do { print(""" 1. Add matrices 2. Multiply matrix by a constant 3. Multiply matrices 4. Transpose matrix 5. Calculate a determinant 6. Inverse matri...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
6,344
Archive
MIT License
2023/src/main/kotlin/Day10.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
private typealias Grid = List<String> object Day10 { private data class Pos(val x: Int, val y: Int) fun part1(input: String) = findLoop(input.splitNewlines()).size / 2 fun part2(input: String): Int { val grid = input.splitNewlines() val loop = findLoop(grid).toSet() // Every time we hit a wall, s...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,726
advent-of-code
MIT License
src/iii_conventions/MyDate.kt
pwojnowski
123,978,024
true
{"Kotlin": 73188, "Java": 4952}
package iii_conventions data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(other: MyDate): Int { if (year != other.year) return year.compareTo(other.year) if (month != other.month) return month.compareTo(other.month) return da...
0
Kotlin
0
0
1e973bd2b787321a04e97dda0f077bbac7211911
1,648
kotlin-koans
MIT License
kotlin/13_sorts/BucketSort.kt
willpyshan13
225,825,279
true
{"Python": 148296, "C": 144551, "C++": 131943, "Java": 101378, "Scala": 97442, "Rust": 77415, "Go": 73304, "PHP": 69589, "JavaScript": 62356, "Kotlin": 56424, "C#": 41255, "TypeScript": 38704, "Objective-C": 27661, "Swift": 23431, "HTML": 1582, "Shell": 35}
/** * @Description:桶排序算法 * @Author: Hoda * @Date: Create in 2019-06-01 * @Modified By: * @Modified Date: */ object BucketSort { /** * 桶排序 * * @param arr 数组 * @param bucketSize 桶容量 */ fun bucketSort(arr: IntArray, bucketSize: Int) { if (arr.size < 2) { return ...
0
Python
0
1
40dd1d3c828ac8f8486beacd1777da88deaabb50
3,039
algo
Apache License 2.0
src/main/kotlin/adventOfCode2023/Day12.kt
TetraTsunami
726,140,343
false
{"Kotlin": 80024}
package adventOfCode2023 import util.* @Suppress("unused") class Day12(input: String, context: RunContext = RunContext.PROD) : Day(input, context) { val variationsMemo = mutableMapOf<Triple<List<Char>, List<Int>, Boolean>, Long>() override fun solve() { var s1 = 0L for (line in lines) { ...
0
Kotlin
0
0
78d1b5d1c17122fed4f4e0a25fdacf1e62c17bfd
2,344
AdventOfCode2023
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2016/Day13.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2016 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Point import com.nibado.projects.advent.collect.Maze import com.nibado.projects.advent.search.BreadthFirst object Day13 : Day { private val input = 1362 private val solution : Map<Point, Int> by la...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,209
adventofcode
MIT License
2023/day04-25/src/main/kotlin/Day11.kt
CakeOrRiot
317,423,901
false
{"Kotlin": 62169, "Python": 56994, "C#": 20675, "Rust": 10417}
import java.io.File import java.math.BigInteger import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day11 { fun solve1() { val grid = File("inputs/11.txt").inputStream().bufferedReader().lineSequence().map { it.toMutableList() } .toMutableList() ...
0
Kotlin
0
0
8fda713192b6278b69816cd413de062bb2d0e400
2,728
AdventOfCode
MIT License
dcp_kotlin/src/main/kotlin/dcp/day317/day317.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day317 // day317.kt // By <NAME>, 2020. /** * Brute force approach: O(N) time. */ fun andIntBF(x: Int, y: Int): Int { require(x <= y) tailrec fun aux(result: Int = x, i: Int = x + 1): Int = when (i) { y + 1 -> result else -> aux(result and i, i + 1) } return aux() } ...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,499
daily-coding-problem
MIT License
kotlin/strings/AhoCorasick.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package strings // https://en.wikipedia.org/wiki/Aho–Corasick_algorithm class AhoCorasick { val ALPHABET_SIZE = 26 val MAX_STATES = 200000 var transitions = Array(MAX_STATES) { IntArray(ALPHABET_SIZE) } var sufflink = IntArray(MAX_STATES) var escape = IntArray(MAX_STATES) var states = 1 fun...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
1,891
codelibrary
The Unlicense
src/main/java/challenges/cracking_coding_interview/bit_manipulation/next_number/QuestionB.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.bit_manipulation.next_number /** * Given a positive integer, print the next smallest and the next largest number that have * the same number of 1 bits in their binary representation. */ object QuestionB { fun getNext(n: Int): Int { var n = n var c = ...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,626
CodingChallenges
Apache License 2.0
src/main/kotlin/g1301_1400/s1371_find_the_longest_substring_containing_vowels_in_even_counts/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1371_find_the_longest_substring_containing_vowels_in_even_counts // #Medium #String #Hash_Table #Bit_Manipulation #Prefix_Sum // #2023_06_06_Time_317_ms_(100.00%)_Space_49.1_MB_(100.00%) class Solution { private var result: Int? = null fun findTheLongestSubstring(s: String): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,311
LeetCode-in-Kotlin
MIT License
constraints/src/main/kotlin/com/alexb/constraints/core/solvers/RecursiveBacktrackingSolver.kt
alexbaryzhikov
201,620,351
false
null
/* Copyright 2019 <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 writing, software distribut...
0
Kotlin
0
0
e67ae6b6be3e0012d0d03988afa22236fd62f122
4,016
kotlin-constraints
Apache License 2.0
src/chapter3/section5/ex30_DuplicatesRevisited.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section5 import chapter2.section5.ex31_Distinct import extensions.formatInt import extensions.random import extensions.spendTimeMillis import kotlin.math.pow /** * 重复元素(续) * 使用3.5.2.1节的dedup过滤器重新完成练习2.5.31,比较两种解决方法的运行时间 * 然后使用dedup运行实验,其中N=10⁷、10⁸和10⁹ * 使用随机的long值重新完成实验并讨论结果 * * 解:应该是统计不重复元素的数量...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,512
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/se/brainleech/adventofcode/aoc2022/Aoc2022Day07.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 class Aoc2022Day07 { interface FileOrDirectory { val name: String fun size() : Int } data class File(override val name:...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
3,931
adventofcode
MIT License
src/Day06.kt
wujingwe
574,096,169
false
null
fun main() { fun findMarker(input: String, size: Int): Int { return input.windowed(size).indexOfFirst { it.toSet().size == size } + size } fun part1(inputs: String): Int { return findMarker(inputs, 4) } fun part2(inputs: String): Int { return findMarker(inputs, 14) } ...
0
Kotlin
0
0
a5777a67d234e33dde43589602dc248bc6411aee
992
advent-of-code-kotlin-2022
Apache License 2.0
ast-transformations-core/src/test/kotlin/org/jetbrains/research/ml/ast/util/FileTestUtil.kt
JetBrains-Research
301,993,261
false
{"Kotlin": 148658, "Python": 27810}
package org.jetbrains.research.ml.ast.util import java.io.File enum class Extension(val value: String) { Py(".py"), Xml(".xml") } enum class Type { Input, Output } class TestFileFormat(private val prefix: String, private val extension: Extension, val type: Type) { data class TestFile(val file: File, val...
0
Kotlin
2
17
aff0459b2018f63c1295edc0022556b30113b9c5
2,908
bumblebee
MIT License
kotlin-math-2/src/main/kotlin/com/baeldung/math/sumofprimes/SumOfPrimes.kt
Baeldung
260,481,121
false
{"Kotlin": 1476024, "Java": 43013, "HTML": 4883}
package com.baeldung.math.sumofprimes fun checkPrimeUsingBruteForce(number: Int): Boolean { if (number <= 1) return false for (i in 2 until number) { if (number % i == 0) { return false } } return true } fun canBeExpressedAsSumOfTwoPrimesUsingBruteForceApproach(n: Int): Bo...
10
Kotlin
273
410
2b718f002ce5ea1cb09217937dc630ff31757693
1,079
kotlin-tutorials
MIT License
src/main/kotlin/me/peckb/aoc/_2019/calendar/day18/CaveDijkstra.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2019.calendar.day18 import me.peckb.aoc._2019.calendar.day18.Day18.* import me.peckb.aoc.pathing.Dijkstra import me.peckb.aoc.pathing.DijkstraNodeWithCost class CaveDijkstra( private val caves: Map<Area, Section>, private val result: MutableMap<Section.Source.Key, Route>, private val doors...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,560
advent-of-code
MIT License
Extra_primes/Kotlin/src/main/kotlin/ExtraPrimes.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}
private fun nextPrimeDigitNumber(n: Int): Int { return if (n == 0) { 2 } else when (n % 10) { 2 -> n + 1 3, 5 -> n + 2 else -> 2 + nextPrimeDigitNumber(n / 10) * 10 } } private fun isPrime(n: Int): Boolean { if (n < 2) { return false } if (n and 1 == 0) {...
0
D
0
4
c2a9f154a5ae77eea2b34bbe5e0cc2248333e421
1,201
rosetta
MIT License
src/main/kotlin/g0801_0900/s0805_split_array_with_same_average/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0805_split_array_with_same_average // #Hard #Array #Dynamic_Programming #Math #Bit_Manipulation #Bitmask // #2023_03_16_Time_142_ms_(100.00%)_Space_33.7_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { private lateinit var nums: IntArray private lateinit var sums: IntArray fu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,424
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/github/shmvanhouten/adventofcode/day8/Screen.kt
SHMvanHouten
109,886,692
false
{"Kotlin": 616528}
package com.github.shmvanhouten.adventofcode.day8 import com.github.shmvanhouten.adventofcode.day8.PixelState.OFF import com.github.shmvanhouten.adventofcode.day8.PixelState.ON class Screen(private val width: Int, private val height: Int) { private var grid: Map<Int, Map<Int, PixelState>> = initializeGrid() ...
0
Kotlin
0
0
a8abc74816edf7cd63aae81cb856feb776452786
2,225
adventOfCode2016
MIT License
src/main/kotlin/leetcode/Problem2257.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/count-unguarded-cells-in-the-grid/ */ class Problem2257 { fun countUnguarded(m: Int, n: Int, guards: Array<IntArray>, walls: Array<IntArray>): Int { val grid = Array(m) { IntArray(n) { UNGUARDED } } for ((r, c) in guards) { grid[r][...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,629
leetcode
MIT License
src/main/aoc2020/Day8.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2020 class Day8(input: List<String>) { private data class Instruction(val operation: String, val argument: Int) private class Computer(val program: List<Instruction>) { var accumulator = 0 private set /** * Runs the program. Returns true if successful or false ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,864
aoc
MIT License
special_shop.kt
drochecsp2017
416,443,867
false
{"C++": 3542, "Java": 2962, "Rust": 2396, "JavaScript": 1733, "Haskell": 1619, "C": 1590, "Kotlin": 1316, "Julia": 1237, "Lua": 1156, "Python": 1152}
import kotlin.math.round; class Parabola(potCount: Long, xMult: Long, yMult: Long) { private val coeffA = xMult + yMult; private val coeffB = -2 * yMult * potCount; private val coeffC = potCount * potCount * yMult; fun minXCoord(): Long { val numerator = -1.0 * coeffB; val denominator...
0
C++
0
0
20727ddecfc4e7b3c1c7a4024b8c1d4795cd2911
1,316
special_pots_shop
Creative Commons Zero v1.0 Universal
codechef/snackdown2021/qual/d_tl.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codechef.snackdown2021.qual private fun solve() { val (n, m) = readInts() val nei = List(n) { mutableListOf<Int>() } repeat(m) { val (u, v) = readInts().map { it - 1 } nei[u].add(v); nei[v].add(u) } val degree = IntArray(n) { nei[it].size } val byDegree = List(n) { mutableSetOf<Int>() } for (v in ne...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,225
competitions
The Unlicense
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12948_hide_number.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12948 * * 문제 설명 * 프로그래머스 모바일은 개인정보 보호를 위해 고지서를 보낼 때 고객들의 전화번호의 일부를 가립니다. * 전화번호가 문자열 phone_number로 주어졌을 때, 전화번호의 뒷 4자리를 제외한 나머지 숫자를 전부 *으로 가린 문자열을 리턴하는 함수, solution을 완성해주세요. * * 제한 조건 * phone_number는 길이 4 이상...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,164
HoOne
Apache License 2.0
src/main/kotlin/Day05.kt
SimonMarquis
434,880,335
false
{"Kotlin": 38178}
class Day05(raw: List<String>) { private val lines: List<Line> = raw.map(Line::parse) fun part1(): Int = lines .filter { it.isHorizontal() || it.isVertical() } .flatMap { it.points() } .groupingBy { it } .eachCount() .count { it.value >= 2 } fun part2(): Int = line...
0
Kotlin
0
0
8fd1d7aa27f92ba352e057721af8bbb58b8a40ea
1,523
advent-of-code-2021
Apache License 2.0
app/src/main/java/tk/pokatomnik/mrakopediareader2/screens/categories/SortingType.kt
pokatomnik
551,521,498
false
{"Kotlin": 187257}
package tk.pokatomnik.mrakopediareader2.screens.categories import tk.pokatomnik.mrakopediareader2.domain.Category import tk.pokatomnik.mrakopediareader2.ui.components.SortDirection internal enum class SortingType { ALPHA, RATING, VOTED, QUANTITY } internal abstract class Sorting { abstract val so...
7
Kotlin
0
0
16c4135887d08d5b966f1061cf4652b5523f09d7
3,629
MrakopediaReader2
MIT License
src/main/kotlin/kr/co/programmers/P161988.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers // https://github.com/antop-dev/algorithm/issues/531 class P161988 { fun solution(sequence: IntArray): Long { val pulse1 = max(sequence, 1) // [1, -1, 1, ...] val pulse2 = max(sequence, -1) // [-1, 1, -1, ...] return maxOf(pulse1, pulse2) } private fun ma...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
807
algorithm
MIT License
src/main/kotlin/_0063_UniquePathsII.kt
ryandyoon
664,493,186
false
null
// https://leetcode.com/problems/unique-paths-ii fun uniquePathsWithObstacles(obstacleGrid: Array<IntArray>): Int { val lastRowIndex = obstacleGrid.lastIndex val lastColIndex = obstacleGrid.first().lastIndex val hasObstacle = obstacleGrid[lastRowIndex][lastColIndex] == 1 obstacleGrid[lastRowIndex][lastC...
0
Kotlin
0
0
7f75078ddeb22983b2521d8ac80f5973f58fd123
1,301
leetcode-kotlin
MIT License
src/aoc23/Day01.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day01 import lib.Solution typealias Input = List<String> typealias Output = Int private val solution = object : Solution<Input, Output>(2023, "Day01") { override fun parse(input: String): Input = input.lines() override fun format(output: Output): String...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,539
aoc-kotlin
Apache License 2.0
src/test/kotlin/chapter3/exercises/ex28/listing.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter3.exercises.ex28 import chapter3.Branch import chapter3.Leaf import chapter3.Tree import io.kotest.matchers.shouldBe import io.kotest.core.spec.style.WordSpec import utils.SOLUTION_HERE // tag::init[] fun <A, B> fold(ta: Tree<A>, l: (A) -> B, b: (B, B) -> B): B = when(ta){ is Leaf -> l(ta.v...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
2,038
fp-kotlin
MIT License
src/Day01.kt
ben-dent
572,931,260
false
{"Kotlin": 10265}
fun main() { fun getGroups(input: List<String>): List<List<Int>> { val toReturn = ArrayList<ArrayList<Int>>() var current = ArrayList<Int>(); for (s in input) { if (s.isEmpty()) { toReturn.add(current) current = ArrayList(); } else { ...
0
Kotlin
0
0
2c3589047945f578b57ceab9b975aef8ddde4878
1,037
AdventOfCode2022Kotlin
Apache License 2.0
src/main/kotlin/com/askrepps/advent2021/day25/Day25.kt
askrepps
726,566,200
false
{"Kotlin": 191862}
/* * MIT License * * Copyright (c) 2021 <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, m...
0
Kotlin
0
0
89de848ddc43c5106dc6b3be290fef5bbaed2e5a
3,591
advent-of-code-kotlin
MIT License
parserkt-ext/src/commonMain/kotlin/org/parserkt/pat/ext/TriePatternMisc.kt
ParserKt
242,278,819
false
null
package org.parserkt.pat.ext import org.parserkt.* import org.parserkt.util.* import org.parserkt.pat.complex.TriePattern import org.parserkt.pat.complex.PairedTriePattern //// == BackTrie, DictTrie, LazyPairedTrie, GreedyPairedTrie == abstract class BackTrie<K, V>: PairedTriePattern<K, V>() { abstract fun split(va...
1
Kotlin
0
11
37599098dc9aafef7b509536e6d17ceca370d6cf
1,591
ParserKt
MIT License
kotlin/0046-permutations.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}
// solution based on the video class Solution { fun permute(nums: IntArray): List<MutableList<Int>> { val res = mutableListOf<MutableList<Int>>() val queue = ArrayDeque<Int>(nums.toList()) // base case if (queue.size == 1) { return listOf(queue.toMutableList()) // queue....
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,402
leetcode
MIT License
src/adventofcode/blueschu/y2017/day22/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day22 import java.io.File import kotlin.test.assertEquals val input: List<String> by lazy { File("resources/y2017/day22.txt") .bufferedReader() .use { it.readLines() } } fun main(args: Array<String>) { assertEquals( 5587, part1( listOf( ...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
4,226
Advent-Of-Code
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1582/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1582 /** * LeetCode page: [1582. Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix/); */ class Solution { /* Complexity: * Time O(MN) and Space O(N) where M and N are the number of rows * and columns of mat; ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,640
hj-leetcode-kotlin
Apache License 2.0
hackerrank/missing-numbers/Solution.kts
shengmin
5,972,157
false
null
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
Java
18
20
08e65546527436f4bd2a2014350b2f97ac1367e7
1,557
coding-problem
MIT License
src/main/kotlin/lesson2/OddOccurrencesInArray.kt
iafsilva
633,017,063
false
null
package lesson2 /** * A non-empty array A consisting of N integers is given. * The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. * * For example, in array A such that: * ``` * A[0...
0
Kotlin
0
0
5d86aefe70e9401d160c3d87c09a9bf98f6d7ab9
1,494
codility-lessons
Apache License 2.0
AdventOfCode/Challenge2023Day09.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.math.abs import kotlin.test.assertEquals class Challenge2023Day09 { private fun solve1(lines: List<String>): Int { val results = mutableListOf<Int>() lines.forEach { line -> // Generate the relevant lines val initialNu...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
6,575
KotlinCodeJourney
MIT License
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day11/Day11.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2015.day11 import nl.sanderp.aoc.common.allPairs const val input = "cqjxjnds" val String.isValid get(): Boolean { if (windowed(3, 1).all { Pair(it[1] - it[0], it[2] - it[1]) != Pair(1, 1) }) { return false } if (any { listOf('i', 'o', 'l').contains(i...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,175
advent-of-code
MIT License
src/main/kotlin/twentytwentytwo/Day20.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo fun main() { val input = {}.javaClass.getResource("input-20.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val tinput = {}.javaClass.getResource("input-20-1.txt")!!.readText().linesFiltered { it.isNotEmpty() }; val day = Day20(input) val test = Day20(tinput) println(t...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
1,844
aoc202xkotlin
The Unlicense
src/main/kotlin/com/yanicksenn/miniretrieval/language/LanguageDeterminer.kt
yanicksenn
512,225,699
false
{"Kotlin": 62130}
package com.yanicksenn.miniretrieval.language import com.yanicksenn.miniretrieval.to.Token import java.lang.Integer.max /** * Determines the language of a document by reading its tokens * and matching them to lexicons. */ class LanguageDeterminer(lexicons: Map<Language, Set<Token>>) { private val languageByTo...
2
Kotlin
0
0
f168ac3a51a30478b21b73e40488266ff8ae9320
2,496
mini-retrieval
MIT License
puzzles/kotlin/src/bender1.kt
hitszjsy
337,974,982
true
{"Python": 88057, "Java": 79734, "Kotlin": 52113, "C++": 33407, "TypeScript": 20480, "JavaScript": 17133, "PHP": 15544, "Go": 15296, "Ruby": 12722, "Haskell": 12635, "C#": 2600, "Scala": 1555, "Perl": 1250, "Shell": 1220, "Clojure": 753, "C": 598, "Makefile": 58}
import java.util.Scanner const val UNBREAKABLE_WALL = '#' const val BREAKABLE_WALL = 'X' const val START = '@' const val FINISH = '$' const val SOUTH = 'S' const val EAST = 'E' const val NORTH = 'N' const val WEST = 'W' const val BEER = 'B' const val INVERTER = 'I' const val TELEPORTER = 'T' const val EMPTY = ' ' fun...
0
null
0
1
59d9856e66b1c4a3d660c60bc26a19c4dfeca6e2
5,471
codingame
MIT License
kotlin/StalinSort.kt
nikitabobko
267,869,432
true
{"Coq": 189028, "Python": 7234, "C++": 7096, "TeX": 7094, "Scala": 5257, "Assembly": 4885, "C#": 4674, "Rust": 4076, "Agda": 2521, "REXX": 2241, "R": 2214, "Shell": 2069, "Java": 2010, "Go": 1655, "Julia": 1475, "Kotlin": 1311, "Crystal": 1306, "Perl": 1222, "Pascal": 1189, "APL": 1180, "Swift": 1084, "Scheme": 1043, "...
fun main(args: Array<String>) { val intComrades = listOf(0, 2, 1, 4, 3, 6, 5).sortComrades() val charComrades = listOf('A', 'C', 'B', 'E', 'D').sortComrades() val redArmyRanks = listOf( RedArmyRank.SOLDIER, RedArmyRank.ASSISTANT_PLATOON_LEADER, RedArmyRank.SQUAD_LEADER).sortC...
0
null
0
0
6098af3dbebdcbb8d23491a0be51775bddaee4a4
1,311
stalin-sort
MIT License
src/adventofcode/blueschu/y2017/day23/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day23 import adventofcode.blueschu.y2017.day18.RegisterRepository import java.io.File val input: List<String> by lazy { File("resources/y2017/day23.txt") .bufferedReader() .use { r -> r.readLines() } } fun main(args: Array<String>) { println("Part 1: ${part...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
3,501
Advent-Of-Code
MIT License
src/commonMain/kotlin/dev/achammer/tuwea/core/Core.kt
fachammer
354,805,674
false
null
package dev.achammer.tuwea.core import kotlin.random.Random data class StudentCheckmarksEntry( val firstName: String, val lastName: String, val idNumber: String, val checkmarks: Set<String> ) data class ParseConfiguration( val csvDelimiter: Char, val csvLineOffset: Int, val preCheckmarksF...
0
Kotlin
0
0
bc880bcfb78be90016ede48c9eaf99cc689905cc
3,457
tuwea
MIT License
app/src/main/java/edu/upf/aism/tfgroommeasurements/Utils.kt
guillemmr00
654,006,318
false
null
package edu.upf.aism.tfgroommeasurements import com.github.psambit9791.jdsp.transform.DiscreteFourier import com.github.psambit9791.jdsp.transform.FastFourier import java.io.* import java.lang.Math.pow import kotlin.math.* fun bit8_to16bit(bit8_low : Int, bit8_high : Int) : Short{ val lowByteDecimal = bit8_low a...
0
Kotlin
0
0
d75a40b8f150100b9700b0f289f598c2ddd74092
9,576
TFGRoomMeasurements
MIT License
mynlp/src/main/java/com/mayabot/nlp/fasttext/utils/TopMaxK.kt
mayabot
113,726,044
false
{"Java": 985672, "Kotlin": 575923, "Shell": 530}
package com.mayabot.nlp.fasttext.utils import java.util.* import kotlin.math.min /** * 求最大Top K * 内部是小顶堆 * * @author jimichan */ class TopMaxK<T>(private val k: Int=10 ) { private val heap: FloatArray = FloatArray(k) private val idIndex: MutableList<T?> = MutableList(k){null} var size = 0 fun p...
18
Java
90
658
b980da3a6f9cdcb83e0800f6cab50656df94a22a
2,409
mynlp
Apache License 2.0
src/Day03.kt
Derrick-Mwendwa
573,947,669
false
{"Kotlin": 8707}
fun main() { fun Char.getPriority() = this.code - if (this.isLowerCase()) 96 else 38 fun part1(input: List<String>) = input.sumOf { (it.substring(0, it.length / 2).toSet() intersect it.substring(it.length / 2).toSet()) .single() .getPriority() } fun part2(input: List<St...
0
Kotlin
0
1
7870800afa54c831c143b5cec84af97e079612a3
723
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/days/Day4.kt
MaciejLipinski
317,582,924
true
{"Kotlin": 60261}
package days class Day4 : Day(4) { override fun partOne(): Any { return splitIntoPassports(inputString) .map { Passport.from(it) } .count { it.isValid() } } override fun partTwo(): Any { return splitIntoPassports(inputString) .map { Passport....
0
Kotlin
0
0
1c3881e602e2f8b11999fa12b82204bc5c7c5b51
4,343
aoc-2020
Creative Commons Zero v1.0 Universal
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[203]移除链表元素.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。 // // // 示例 1: // // //输入:head = [1,2,6,3,4,5,6], val = 6 //输出:[1,2,3,4,5] // // // 示例 2: // // //输入:head = [], val = 1 //输出:[] // // // 示例 3: // // //输入:head = [7,7,7,7], val = 7 //输出:[] // // // // // 提示: // // // 列表中的节点在范围 [0, 104]...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,350
MyLeetCode
Apache License 2.0
src/aoc2018/kot/Day19.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import VM18 import getWords import java.io.File import kotlin.math.sqrt object Day19 { fun partOne(input: List<String>) = solve(input, listOf("0" to 0L, "1" to 0L, "2" to 0L, "3" to 0L, "4" to 0L, "5" to 0L)) fun partTwo(input: List<String>) = solve(input, listOf("0" to 1L, "1" to 0L, "2" to ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
844
Advent_of_Code
MIT License
src/main/kotlin/github/walkmansit/aoc2020/Day23.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day23(val input: String) : DayAoc<String, Long> { private class Game(input: String, extra: IntRange = 0..1) { private class Node(val value: Int, var left: Node?, var right: Node?) private var current: Node? = null private var nodesArr: Array<Node?...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
3,534
AdventOfCode2020
MIT License
src/main/kotlin/days/Day11.kt
sicruse
315,469,617
false
null
package days class Day11 : Day(11) { // landscape bitmap states // - floor : can never have person occupancy // - chair : can be empty or host a person // distribution states // - no-person // - person // I imagine that each map "frame" can be modelled as a sequence private val rows...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
4,706
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/Day07.kt
colmmurphyxyz
572,533,739
false
{"Kotlin": 19871}
import javax.swing.tree.TreeNode fun main() { class FileTreeNode(val name: String, val type: String, private val size: Int?, val parent: FileTreeNode?, val children: MutableList<FileTreeNode> = mutableListOf<FileTreeNode>()) { override fun toString(): String { return "$t...
0
Kotlin
0
0
c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea
6,682
aoc-2022
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day09.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day09.solve() } object Day09 : AdventSolution(2023, 9, "Mirage Maintenance") { override fun solvePartOne(input: String) = parse(input).sumOf { seq -> differences(seq).sumOf { it.last() } } override fun solvePartTw...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
718
advent-of-code
MIT License
src/org/aoc2021/Day25.kt
jsgroth
439,763,933
false
{"Kotlin": 86732}
package org.aoc2021 import java.nio.file.Files import java.nio.file.Path object Day25 { private fun solve(lines: List<String>): Int { var grid = parseInput(lines) var turns = 0 while (true) { turns++ val prevGrid = grid grid = simulateTurn(grid) ...
0
Kotlin
0
0
ba81fadf2a8106fae3e16ed825cc25bbb7a95409
2,385
advent-of-code-2021
The Unlicense
src/main/kotlin/com/adrielm/aoc2020/solutions/day11/SeatingSimulator.kt
Adriel-M
318,860,784
false
null
package com.adrielm.aoc2020.solutions.day11 private val DIRECTIONS = listOf( Pair(-1, -1), Pair(-1, 0), Pair(-1, 1), Pair(0, -1), Pair(0, 1), Pair(1, -1), Pair(1, 0), Pair(1, 1) ) class SeatingSimulator( private val seatingData: List<List<Char>> ) { fun simulate(): SeatingSimul...
0
Kotlin
0
0
8984378d0297f7bc75c5e41a80424d091ac08ad0
4,029
advent-of-code-2020
MIT License
src/d14.main.kts
cjfuller
317,725,797
false
null
import java.io.File data class Mask(val maskStr: String) { val orForm: Long = maskStr.replace(Regex("X"), "0").toLong(2) val andForm: Long = maskStr.replace(Regex("X"), "1").toLong(2) operator fun invoke(toValue: Long): Long { return (toValue and andForm) or orForm } fun addresses(baseAdd...
0
Kotlin
0
0
c3812868da97838653048e63b4d9cb076af58a3b
2,626
adventofcode2020
MIT License
scripts/Day17.kts
matthewm101
573,325,687
false
{"Kotlin": 63435}
import java.io.File import kotlin.math.max data class Pos(val x: Int, val y: Int) { operator fun plus(a: Pos) = Pos(x + a.x, y + a.y) fun inbounds() = x in 0..6 && y >= 0 } val RIGHT = Pos(1, 0) val LEFT = Pos(-1, 0) val DOWN = Pos(0, -1) data class Block(val blocks: List<Pos>) { val width = blocks.maxOf...
0
Kotlin
0
0
bbd3cf6868936a9ee03c6783d8b2d02a08fbce85
3,686
adventofcode2022
MIT License
00-code(源代码)/src/com/hi/dhl/algorithms/offer/_17/kotlin/Solution.kt
hi-dhl
256,677,224
false
null
package com.hi.dhl.algorithms.offer._17.kotlin /** * <pre> * author: dhl * date : 2020/8/5 * desc : * </pre> */ class Solution { // 方法一 fun printNumbers2(n: Int): IntArray { var max = 1; for (i in 1..n) { max = max * 10; } val result = IntArray(...
0
Kotlin
48
396
b5e34ac9d1da60adcd9fad61da4ec82e2cefc044
1,983
Leetcode-Solutions-with-Java-And-Kotlin
Apache License 2.0
src/questions/common/LeetTreeNode.kt
realpacific
234,499,820
false
null
package questions.common import _utils.SkipDocumentation import algorithmdesignmanualbook.padLeft import java.util.* import kotlin.test.assertFalse import kotlin.test.assertTrue @SkipDocumentation class TreeNode(var `val`: Int) { var left: TreeNode? = null var right: TreeNode? = null override fun toStri...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,450
algorithms
MIT License
src/aoc2017/kot/Day06.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import toIntList import java.io.File object Day06 { fun f(mem: List<Int>): List<Int> { val next = mem.toMutableList() var (idx, max) = mem.withIndex().maxBy { it.value }!! next[idx] = 0 while (max-- > 0) { next[++idx % mem.size]++ } return next.toList() } fun...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,008
Advent_of_Code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxProfitStock.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,411
kotlab
Apache License 2.0
src/Day02.kt
colmmurphyxyz
572,533,739
false
{"Kotlin": 19871}
fun main() { val pointsOnPlay: (Char) -> Int = { c: Char -> if (c.code !in 88..90) { throw IllegalArgumentException("input must be a character in (X, Y, Z)") } c.code - 87 } fun part1(): Int { val input = readInput("Day02") val keyLosesToVal = mapOf<Cha...
0
Kotlin
0
0
c5653691ca7e64a0ee7f8e90ab1b450bcdea3dea
2,325
aoc-2022
Apache License 2.0
src/main/kotlin/com/quakbo/euler/Euler4.kt
quincy
120,237,243
false
null
package com.quakbo.euler /* A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. */ internal fun isPalindrome(n: Int): Boolean { val s = n.toString() ret...
0
Kotlin
0
0
01d96f61bda6e87f1f58ddf7415d9bca8a4913de
1,751
euler-kotlin
The Unlicense
src/main/kotlin/adventofcode/year2015/Day16AuntSue.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2015 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day16AuntSue(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val aunts by lazy { input .lines() .map { aunt -> val id = aunt.split(": ").first().split(" ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
4,057
AdventOfCode
MIT License
year2019/day12/body/src/main/kotlin/com/curtislb/adventofcode/year2019/day12/body/NBodySystem.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2019.day12.body import com.curtislb.adventofcode.common.iteration.uniquePairs import com.curtislb.adventofcode.common.io.mapLines import com.curtislb.adventofcode.common.vector.IntVector import java.io.File /** * A system of multiple celestial bodies, which move and exert gravit...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,485
AdventOfCode
MIT License
src/main/App.kt
neelkamath
185,819,512
false
null
package com.neelkamath.life /** * Uses [seed] to create a [System] having the specified number of [columns]. * * [seed] should contain `A` for [Cell.ALIVE], and `D` for [Cell.DEAD]. For example, if [columns] is `4`, and [seed] is * `ADDDADDDDAAD`, the [System] returned will have three rows, and four columns. */ p...
0
Kotlin
0
0
24cdb2409cc25229db492344bba72a90c584292e
2,760
conways-game-of-life
MIT License
src/Day03.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day03(private val input: List<String>) { fun part1(): Int = input.sumOf { it.sharedItems().priority() } fun part2(): Int = input.chunked(3).sumOf { it.sharedItems().priority() } private fun Char.priority(): Int = when (this) { in 'a'..'z' -> (this - 'a') + 1 ...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
863
aoc-22-kotlin
Apache License 2.0
year2019/day15/part2/src/main/kotlin/com/curtislb/adventofcode/year2019/day15/part2/Year2019Day15Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- You quickly repair the oxygen system; oxygen gradually fills the area. Oxygen starts in the location containing the repaired oxygen system. It takes one minute for oxygen to spread to all open locations that are adjacent to a location that already contains oxygen. Diagonal locations are not adjace...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,245
AdventOfCode
MIT License
src/main/kotlin/me/giacomozama/adventofcode2022/days/Day12.kt
giacomozama
572,965,253
false
{"Kotlin": 75671}
package me.giacomozama.adventofcode2022.days import java.io.File import java.util.* class Day12 : Day() { private lateinit var input: List<CharArray> override fun parseInput(inputFile: File) { input = inputFile.useLines { lines -> lines.map { it.toCharArray() }.toList() } } // n = numbers o...
0
Kotlin
0
0
c30f4a37dc9911f3e42bbf5088fe246aabbee239
3,114
aoc2022
MIT License