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/main/kotlin/g0601_0700/s0699_falling_squares/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0601_0700.s0699_falling_squares
// #Hard #Array #Ordered_Set #Segment_Tree #2023_02_22_Time_293_ms_(100.00%)_Space_48.8_MB_(50.00%)
import java.util.Collections
import java.util.TreeSet
class Solution {
fun fallingSquares(positions: Array<IntArray>): List<Int> {
// Coordinate compression using T... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,633 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/alg03sorting/S5QuickSort.kt | deemson | 349,702,470 | false | null | package alg03sorting
import alg03indexable.Indexable
import alg03indexable.swap
import kotlin.random.Random
object S5QuickSort : Sort {
/**
* This function is the core of quicksort. It ensures that an arbitrary item from the part of the array
* from left to right is in place, i.e. smaller than all of th... | 0 | Kotlin | 0 | 0 | a4bba4dfa962302114065032facefdf98585cfd7 | 2,631 | algorithms | MIT License |
src/test/kotlin/amb/aoc2020/day4.kt | andreasmuellerbluemlein | 318,221,589 | false | null | package amb.aoc2020
import org.junit.jupiter.api.Test
class Day4 : TestBase() {
private fun getInput(): List<String> {
val passportCandidates = emptyList<String>().toMutableList()
var input = ""
getTestData("input4").forEach {
if (it.isEmpty()) {
passportCandid... | 1 | Kotlin | 0 | 0 | dad1fa57c2b11bf05a51e5fa183775206cf055cf | 3,190 | aoc2020 | MIT License |
src/main/kotlin/com/groundsfam/advent/y2023/d09/Day09.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d09
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
fun extrapolate(history: List<Long>, backward: Boolean): Long {
if (history.all { it == 0L }) {
return 0
}
val diffs = (1 until... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 1,052 | advent-of-code | MIT License |
src/main/java/com/marcinmoskala/math/CombinationsExt.kt | MarcinMoskala | 87,302,297 | false | null | @file:JvmName("DiscreteMath")
@file:JvmMultifileClass
package com.marcinmoskala.math
/**
* In mathematics, a combination is a way of selecting items from a collection, such that (unlike permutations) the
* order of selection does not matter.
*
* For set {1, 2, 3}, 2 elements combinations are {1, 2}, {2, 3}, {1, 3}... | 4 | Kotlin | 17 | 178 | 17a7329af042c5de232051027ec1155011d57da8 | 1,944 | KotlinDiscreteMathToolkit | Apache License 2.0 |
aoc-2016/src/main/kotlin/nl/jstege/adventofcode/aoc2016/days/Day01.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2016.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.Direction
import nl.jstege.adventofcode.aoccommon.utils.Point
import nl.jstege.adventofcode.aoccommon.utils.extensions.scan
import kotlin.reflect.KProperty1
/**
*
* @author <NA... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 2,131 | AdventOfCode | MIT License |
src/main/kotlin/ru/timakden/aoc/year2016/Day12.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2016
import ru.timakden.aoc.util.isNumber
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
import ru.timakden.aoc.year2016.Day12.Command.*
import ru.timakden.aoc.year2016.Day12.Command.Companion.toCommand
/**
* [Day 12: Leonardo's Monorail](https://adventofcode.co... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 4,141 | advent-of-code | MIT License |
app/src/main/java/es/upm/bienestaremocional/data/questionnaire/daily/DailyScoredQuestionnaire.kt | Emotional-Wellbeing | 531,973,820 | false | {"Kotlin": 848055} | package es.upm.bienestaremocional.data.questionnaire.daily
import es.upm.bienestaremocional.data.Measure
import es.upm.bienestaremocional.data.questionnaire.Level
import es.upm.bienestaremocional.data.questionnaire.Questionnaire
import es.upm.bienestaremocional.data.questionnaire.QuestionnaireScored
import es.upm.bien... | 0 | Kotlin | 0 | 2 | 55c24943d57d1c0cb91ddce569f27d7e5cd6ed8d | 2,720 | App | Apache License 2.0 |
src/main/kotlin/exercises/quicksort/QuicksortQB.kt | amykv | 538,632,477 | false | {"Kotlin": 169929} | package exercises.quicksort
//Example that uses a custom quicksort to sort NFL QBs and passing yards.
data class Quarterback(val name: String, val passingYards: Int)
fun main() {
// Define a list of Quarterback objects with their names and passing yards
val quarterbacks = listOf(
Quarterback("<NAME>"... | 0 | Kotlin | 0 | 2 | 93365cddc95a2f5c8f2c136e5c18b438b38d915f | 2,577 | dsa-kotlin | MIT License |
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day13.kt | mpichler94 | 656,873,940 | false | {"Kotlin": 196457} | package at.mpichler.aoc.solutions.year2022
import at.mpichler.aoc.lib.Day
import at.mpichler.aoc.lib.PartSolution
open class Part13A : PartSolution() {
lateinit var pairs: List<Pair<List<Any>, List<Any>>>
override fun parseInput(text: String) {
val lines = text.trim().split("\n")
val pairs: M... | 0 | Kotlin | 0 | 0 | 69a0748ed640cf80301d8d93f25fb23cc367819c | 5,043 | advent-of-code-kotlin | MIT License |
src/main/kotlin/dev/patbeagan/days/Day01.kt | patbeagan1 | 576,401,502 | false | {"Kotlin": 57404} | package dev.patbeagan.days
/**
* [Day 1](https://adventofcode.com/2022/day/1)
*/
class Day01 : AdventDay<Int> {
/**
* Prints out the calorie value
* of the elf that is holding the most calories.
*/
override fun part1(input: String): Int =
parseForElves(input)
.maxBy { it.to... | 0 | Kotlin | 0 | 0 | 4e25b38226bcd0dbd9c2ea18553c876bf2ec1722 | 1,019 | AOC-2022-in-Kotlin | Apache License 2.0 |
src/main/kotlin/leetcode/kotlin/tree/285. Inorder Successor in BST.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package leetcode.kotlin.tree
// solution not verified, as env. not available
private fun inorderSuccessor(root: TreeNode?, p: TreeNode): TreeNode? {
var seen = false
var ans: TreeNode? = null
fun dfs(root: TreeNode?) {
if (root != null && ans == null) {
dfs(root.left)
if (se... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 1,859 | leetcode-kotlin | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day10.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
import com.github.akowal.aoc.Day10.Cmd.Add
import com.github.akowal.aoc.Day10.Cmd.Noop
import kotlin.math.abs
class Day10 {
private val cmds = inputFile("day10").readLines().map { line ->
when (line) {
"noop" -> Noop
else -> Add(line.substringAfter(' '... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 1,708 | advent-of-kode | Creative Commons Zero v1.0 Universal |
year2023/day06/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day06/part2/Year2023Day06Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
As the race is about to start, you realize the piece of paper with race times and record distances
you got earlier actually just has very bad kerning. There's really only one race - ignore the spaces
between the numbers on each line.
So, the example from before:
```
Time: 7 15 30
Distance... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 1,696 | AdventOfCode | MIT License |
year2022/src/cz/veleto/aoc/year2022/Day21.kt | haluzpav | 573,073,312 | false | {"Kotlin": 164348} | package cz.veleto.aoc.year2022
import cz.veleto.aoc.core.AocDay
class Day21(config: Config) : AocDay(config) {
companion object {
private const val RootMonkey = "root"
private const val HumnMonkey = "humn"
}
override fun part1(): String {
val monkeyYells = parseMonkeys().toMutabl... | 0 | Kotlin | 0 | 1 | 32003edb726f7736f881edc263a85a404be6a5f0 | 4,187 | advent-of-pavel | Apache License 2.0 |
src/main/kotlin/g1501_1600/s1547_minimum_cost_to_cut_a_stick/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1547_minimum_cost_to_cut_a_stick
// #Hard #Array #Dynamic_Programming #2023_06_12_Time_187_ms_(92.00%)_Space_37.5_MB_(95.00%)
class Solution {
fun minCost(n: Int, cuts: IntArray): Int {
cuts.sort()
val m = cuts.size
val dp = Array(m + 1) { IntArray(m + 1) }
for ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 741 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/days/Day13.kt | nuudles | 316,314,995 | false | null | package days
import kotlin.math.ceil
class Day13 : Day(13) {
override fun partOne(): Any {
val target = inputList.first().toFloat()
return inputList
.last()
.split(",")
.filter { it != "x" }
.map { it.toInt() }
.minByOrNull { multiplier -... | 0 | Kotlin | 0 | 0 | 5ac4aac0b6c1e79392701b588b07f57079af4b03 | 2,024 | advent-of-code-2020 | Creative Commons Zero v1.0 Universal |
2020/day20/day20.kt | flwyd | 426,866,266 | false | {"Julia": 207516, "Elixir": 120623, "Raku": 119287, "Kotlin": 89230, "Go": 37074, "Shell": 24820, "Makefile": 16393, "sed": 2310, "Jsonnet": 1104, "HTML": 398} | /*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package day20
import kotlin.math.sqrt
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
import kotlin.time.measur... | 0 | Julia | 1 | 5 | f2d6dbb67d41f8f2898dbbc6a98477d05473888f | 12,367 | adventofcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindPivotIndex.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,195 | kotlab | Apache License 2.0 |
subprojects/common/graph/src/test/kotlin/com/avito/grapth/ShortestPathTest.kt | avito-tech | 230,265,582 | false | {"Kotlin": 3574228, "Java": 67252, "Shell": 27656, "Dockerfile": 12799, "Makefile": 7970} | package com.avito.grapth
import com.avito.graph.Operation
import com.avito.graph.ShortestPath
import com.avito.graph.SimpleOperation
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
class ShortestPathTest {
@Test
fun `zero operations - empty path`() {
val path = short... | 10 | Kotlin | 48 | 390 | 9d60abdd26fc779dd57aa4f1ad51658b6a245d1e | 2,486 | avito-android | MIT License |
string-similarity/src/commonMain/kotlin/com/aallam/similarity/SorensenDice.kt | aallam | 597,692,521 | false | null | package com.aallam.similarity
import com.aallam.similarity.internal.Shingle
/**
* Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index.
*
* The strings are first converted to boolean sets of k-shingles (sequences of k characters), then the similarity is... | 0 | Kotlin | 0 | 1 | 40cd4eb7543b776c283147e05d12bb840202b6f7 | 1,470 | string-similarity-kotlin | MIT License |
src/Day02.kt | gnuphobia | 578,967,785 | false | {"Kotlin": 17559} | import kotlin.Exception as KotlinException
fun main() {
fun part1(input: List<String>): Int {
val rps = RockPaperScissors()
rps.playGame(input)
return rps.gameScore
}
fun part2(input: List<String>): Int {
val rps = RockPaperScissors()
rps.playGameV2(input)
... | 0 | Kotlin | 0 | 0 | a1b348ec33f85642534c46af8c4a69e7b78234ab | 3,394 | aoc2022kt | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/moderate/q3_intersection/Tester.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.moderate.q3_intersection
object Tester {
fun equalish(a: Double, b: Double): Boolean {
return Math.abs(a - b) < .001
}
fun checkIfPointOnLineSegments(start: Point, middle: Point, end: Point): Boolean {
if (equalish(start.x, middle.x) && equalish... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,780 | CodingChallenges | Apache License 2.0 |
src/chapter2/section2/ex16_NaturalMergesort.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter2.section2
import chapter2.ArrayInitialState
import chapter2.getDoubleArray
import chapter2.section1.checkAscOrder
import chapter2.sortMethodsCompare
/**
* 自然的归并排序
* 编写一个自底向上的归并排序,当需要将两个子数组排序时,能够利用数组中已经有序的部分
* 首先找到一个有序的子数组(移动指针直到当前元素比上一个元素小为止),然后找出另一个并将它们归并
* 根据数组大小和数组中递增子数组的最大长度分析算法的运行时间
*/
fun <... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 1,870 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/test/kotlin/io/noobymatze/aoc/y2022/Day8.kt | noobymatze | 572,677,383 | false | {"Kotlin": 90710} | package io.noobymatze.aoc.y2022
import io.noobymatze.aoc.Aoc
import kotlin.test.Test
class Day8 {
data class Pos(val row: Int, val col: Int)
@Test
fun test() {
val data = Aoc.getInput(8).lines()
.flatMapIndexed { row, line -> line.mapIndexed { col, c -> (Pos(row, col)) to c.digitToIn... | 0 | Kotlin | 0 | 0 | da4b9d894acf04eb653dafb81a5ed3802a305901 | 2,130 | aoc | MIT License |
app/src/main/java/aquodev/textopalindromo/PalindromoFuns.kt | W3SS | 121,782,931 | false | null | package aquodev.textopalindromo
/**
* Devuelve un resultado booleano indicando si la palabra introducida
* por parámetro es un palíndromo (palabra que se escribe igual en ambas
* direcciones).
*
* /!\ El principal método (el que se debe usar con un sólo parámetro) depende de este.
*
* @param palabra Palabra la ... | 0 | Kotlin | 0 | 0 | 290b9f6d09b5d13c0e2d07a2e07d6234869d16d2 | 1,918 | Palindromo-Kotlin-Android | MIT License |
src/main/kotlin/dev/shtanko/algorithms/learn/Array.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,912 | kotlab | Apache License 2.0 |
kotlin/app/src/main/kotlin/coverick/aoc/day13/DistressSignal.kt | RyTheTurtle | 574,328,652 | false | {"Kotlin": 82616} | package coverick.aoc.day13
import readResourceFile
import splitOn
var INPUT_FILE = "distressSignal-input.txt"
enum class DatumType { NUMBER, LIST}
data class Datum(val type: DatumType, val value:List<Int>)
data class Packet(val data: ArrayList<Datum>)
class DatumComparator {
companion object : Comparator<Datum>... | 0 | Kotlin | 0 | 0 | 35a8021fdfb700ce926fcf7958bea45ee530e359 | 3,601 | adventofcode2022 | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions32.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import com.qiaoyuang.algorithm.round0.BinaryTreeNode
import com.qiaoyuang.algorithm.round0.Queue
fun test32() {
testCase1().run {
println("Print top to bottom: ")
printlnBinaryTreeFromTop2Bottom()
println("Print line by line: ")
printlnBinaryT... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,872 | Algorithm | Apache License 2.0 |
Chapter07/BubbleSort.kt | PacktPublishing | 125,371,513 | false | null | import java.util.*
fun <E: Comparable<E>> Array<E>.sort() {
val len = size
for (i in 0 until (len - 1)) {
for (j in 0 until (len - i - 1)) {
if (this[j].compareTo(this[j + 1]) > 0) {
val temp = this[j]
this[j] = this[j + 1]
this[j + 1] = temp
... | 0 | Kotlin | 62 | 162 | f125372a286a3bf4f0248db109a7427f6bc643a7 | 2,011 | Hands-On-Data-Structures-and-Algorithms-with-Kotlin | MIT License |
src/Day03.kt | laricchia | 434,141,174 | false | {"Kotlin": 38143} | import org.jetbrains.kotlinx.multik.api.mk
import org.jetbrains.kotlinx.multik.api.toNDArray
import org.jetbrains.kotlinx.multik.api.zeros
import org.jetbrains.kotlinx.multik.ndarray.data.get
import org.jetbrains.kotlinx.multik.ndarray.data.set
import org.jetbrains.kotlinx.multik.ndarray.operations.count
import org.jet... | 0 | Kotlin | 0 | 0 | 7041d15fafa7256628df5c52fea2a137bdc60727 | 2,761 | Advent_of_Code_2021_Kotlin | Apache License 2.0 |
resolutions/leet-code/problem-2/src/main/kotlin/br/com/gmfonseca/resolutions/leetcode/problem2/solutions/FasterSolution.kt | gmfonseca | 420,417,142 | false | {"Kotlin": 12932} | package br.com.gmfonseca.resolutions.leetcode.problem2.solutions
import br.com.gmfonseca.resolutions.leetcode.problem2.AddTwoNumbersSolution
import br.com.gmfonseca.resolutions.leetcode.problem2.model.ListNode
class FasterSolution : AddTwoNumbersSolution {
override fun addTwoNumbers(firstNode: ListNode, secondNod... | 0 | Kotlin | 0 | 0 | 7580bfa7b30ac7d435ffaf465dfaf5be983cdc07 | 1,722 | problems | MIT License |
kotlin/697.Degree of an Array(数组的度).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 array of non-negative integers <code>nums</code>, the <b>degree</b> of this array is defined as the maximum frequency of any one of its elements.</p>
<p>Your task is to find the smallest possible length of a (contiguous) subarray of <code>nums</code>, that has the same degree as <code>nums</cod... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 3,044 | leetcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindPermutation.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,796 | kotlab | Apache License 2.0 |
src/test/aoc2019/Day7Test.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package test.aoc2019
import aoc2019.Day7
import org.junit.Assert.assertEquals
import org.junit.Test
import resourceAsList
class Day7Test {
@Test
fun testPermutationsOf() {
val d7 = Day7(listOf())
assertEquals(listOf(listOf(0L, 1L), listOf(1L, 0L)), d7.allPermutationsOf(0..1))
d7.allPer... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,936 | aoc | MIT License |
Week1/src/BlackJack.kt | em4n0101 | 268,436,903 | false | null | /**
* Assignment 1
*
* Program that creates a deck of cards,
* deals two cards from that deck into a hand
* and evaluates that hand of cards by finding
* the sum of the pips. Display the cards in the
* hand and the total of the pips in the hand.
*
* @author <NAME> (<EMAIL>)
*/
fun main() {
// Get the deck... | 0 | Kotlin | 0 | 1 | 4f1ebb9d68091ef741ac69f2f46e16f512401de2 | 4,863 | AndroidBootcampSummer2020 | Apache License 2.0 |
src/day15.kt | miiila | 725,271,087 | false | {"Kotlin": 77215} | import java.io.File
import kotlin.math.max
import kotlin.system.exitProcess
private const val DAY = 15
fun main() {
if (!File("./day${DAY}_input").exists()) {
downloadInput(DAY)
println("Input downloaded")
exitProcess(0)
}
val transformer = { x: String -> x.split(",") }
val inp... | 0 | Kotlin | 0 | 1 | 1cd45c2ce0822e60982c2c71cb4d8c75e37364a1 | 1,381 | aoc2023 | MIT License |
src/main/kotlin/g0501_0600/s0593_valid_square/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0501_0600.s0593_valid_square
// #Medium #Math #Geometry #2023_02_01_Time_161_ms_(83.33%)_Space_35_MB_(66.67%)
class Solution {
fun validSquare(p1: IntArray, p2: IntArray, p3: IntArray, p4: IntArray): Boolean {
val distancesSquared = IntArray(6)
distancesSquared[0] = getDistanceSquared(p1,... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,159 | LeetCode-in-Kotlin | MIT License |
src/Day01.kt | pejema | 576,456,995 | false | {"Kotlin": 7994} | fun main() {
fun getCaloriesByElf(input: List<String>) : MutableList<Int> {
val mutableList = mutableListOf<Int>()
var totalCalories = 0
for (cal in input) {
if (cal == "") {
mutableList.add(totalCalories)
totalCalories = 0
} else {
... | 0 | Kotlin | 0 | 0 | b2a06318f0fcf5c6067058755a44e5567e345e0c | 1,024 | advent-of-code | Apache License 2.0 |
src/Day10.kt | pimtegelaar | 572,939,409 | false | {"Kotlin": 24985} | fun main() {
fun part1(input: List<String>): Int {
var x = 1
var result = 0
var cycle = 1
input.forEach { line ->
if (cycle % 40 == 20) {
result += cycle * x
}
if (line.startsWith("addx")) {
cycle++
... | 0 | Kotlin | 0 | 0 | 16ac3580cafa74140530667413900640b80dcf35 | 1,865 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/structures/Graph.kt | DmitryTsyvtsyn | 418,166,620 | false | {"Kotlin": 223256} | package structures
import java.util.LinkedList
import kotlin.collections.LinkedHashSet
/**
*
* data structure: undirected graph without weights
*
* description: made up of vertices connected by edges
*
*/
class Graph<T> {
private val data = mutableMapOf<Vertex<T>, MutableList<Vertex<T>>>()
/**
*... | 0 | Kotlin | 135 | 767 | 7ec0bf4f7b3767e10b9863499be3b622a8f47a5f | 2,834 | Kotlin-Algorithms-and-Design-Patterns | MIT License |
src/Day02.kt | kuolemax | 573,740,719 | false | {"Kotlin": 21104} | // --- Day 2: Rock Paper Scissors ---
// The Elves begin to set up camp on the beach. To decide whose tent gets to be closest to the snack storage, a giant Rock Paper Scissors tournament is already in progress.
//
// Rock Paper Scissors is a game between two players. Each game contains many rounds; in each round, the p... | 0 | Kotlin | 0 | 0 | 3045f307e24b6ca557b84dac18197334b8a8a9bf | 4,710 | aoc2022--kotlin | Apache License 2.0 |
src/main/kotlin/com/resnik/math/Helper.kt | mtresnik | 348,187,516 | false | null | package com.resnik.math
import com.resnik.math.graph.objects.Edge
import com.resnik.math.graph.objects.Vertex
import kotlin.math.pow
fun <T> permuteRecursive(set: Set<T>): Set<List<T>> {
if (set.isEmpty()) return emptySet()
fun <T> _permuteRecursive(list: List<T>): Set<List<T>> {
if (list.isEmpty()) r... | 0 | Kotlin | 0 | 0 | d2d589306d34ca4b2026448078617bf2f62a3f76 | 1,509 | graph | Apache License 2.0 |
src/Day02.kt | ianredman26 | 572,914,381 | false | {"Kotlin": 3237} | fun main() {
fun part1(input: List<String>): Int {
val strategyGuide: MutableMap<String, String> = mutableMapOf()
val total = 0
input.map {
strategyGuide.put(it.first().lowercase(), it.last().lowercase())
}
strategyGuide.map { round ->
when (round.key)... | 0 | Kotlin | 0 | 0 | dcd9fae4531622cc974d2eb3d5ded94bf268ad1e | 1,725 | advent-of-code-2022 | Apache License 2.0 |
src/day07/FileSystem.kt | treegem | 572,875,670 | false | {"Kotlin": 38876} | package day07
import day07.CommandLineConstants.COMMAND_CD
import day07.CommandLineConstants.COMMAND_LS
import day07.CommandLineConstants.DIR
import day07.CommandLineConstants.PARENT_DIR
import day07.LineType.*
class FileSystem(input: List<String>) {
private var currentDirectoryName: String = "/"
private va... | 0 | Kotlin | 0 | 0 | 97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8 | 2,689 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/io/queue/OpenTheLock.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.queue
import java.util.*
import kotlin.collections.HashSet
//https://leetcode.com/explore/learn/card/queue-stack/231/practical-application-queue/1375/
class OpenTheLock {
private val initial = listOf(0, 0, 0, 0)
private val error = -1
fun execute(deadEnds: Array<String>, goal: String): Int {
va... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 2,078 | coding | MIT License |
src/commonMain/kotlin/Graph.kt | GHvW | 322,429,575 | false | null | package ghvw.graph
import kotlinx.collections.immutable.*
// G = (V, E)
data class Graph<A>(
val vertices: PersistentSet<A>,
val edges: PersistentSet<Edge<A>>
)
data class UnweightedGraph<A>(
val vertices: PersistentSet<A>,
val edges: PersistentSet<UnweightedEdge<A>>
)
data class WeightedGraph<A>(
... | 0 | Kotlin | 0 | 0 | a9e900e43f08598ee839b494a4dea41a7fb02789 | 4,404 | venice | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/AsteroidCollision.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,222 | kotlab | Apache License 2.0 |
day11/Kotlin/day11.kt | Ad0lphus | 353,610,043 | false | {"C++": 195638, "Python": 139359, "Kotlin": 80248} | import java.io.*
fun print_day_11() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 11" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Dumbo Octopus -c -f small")
va... | 0 | C++ | 0 | 0 | 02f219ea278d85c7799d739294c664aa5a47719a | 3,489 | AOC2021 | Apache License 2.0 |
day5/src/main/kotlin/day5/Main.kt | ErikHellman | 433,722,039 | false | {"Kotlin": 9432} | package day5
import java.io.File
import kotlin.math.absoluteValue
data class Point(val x: Int, val y: Int)
fun main(args: Array<String>) {
val diagram = HashMap<Point, Int>()
File("input.txt").readLines().forEach { line ->
val (start, end) = line
.split("->")
.map { pair ->
... | 0 | Kotlin | 0 | 1 | 37f54d52633fff5f6fdd9e66926c57421fc721d2 | 1,844 | advent-of-code-2021 | Apache License 2.0 |
src/test/kotlin/io/noobymatze/aoc/y2022/Day9.kt | noobymatze | 572,677,383 | false | {"Kotlin": 90710} | package io.noobymatze.aoc.y2022
import io.noobymatze.aoc.Aoc
import kotlin.math.abs
import kotlin.test.Test
class Day9 {
data class Pos(var row: Int, var col: Int)
@Test
fun test() {
val data = Aoc.getInput(9)
.lineSequence().map { it.split(" ").let { (d, n) -> d to n.toInt() } }
... | 0 | Kotlin | 0 | 0 | da4b9d894acf04eb653dafb81a5ed3802a305901 | 2,209 | aoc | MIT License |
src/main/kotlin/icfp2019/analyzers/ConservativeDistanceAnalyzer.kt | randomsamples | 189,507,360 | true | {"JavaScript": 797310, "Kotlin": 89529, "CSS": 9434, "HTML": 5859} | package icfp2019.analyzers
import icfp2019.core.Analyzer
import icfp2019.core.DistanceEstimate
import icfp2019.model.GameState
import icfp2019.model.Node
import icfp2019.model.Point
import icfp2019.model.RobotId
import org.jgrapht.alg.connectivity.ConnectivityInspector
import org.jgrapht.alg.spanning.PrimMinimumSpanni... | 0 | JavaScript | 0 | 0 | afcf5123ffb72ac10cfa6b0772574d9826f15e41 | 2,292 | icfp-2019 | The Unlicense |
aoc-kotlin/src/main/kotlin/day03/Day03.kt | mahpgnaohhnim | 573,579,334 | false | {"Kotlin": 29246, "TypeScript": 1975, "Go": 1693, "Rust": 1520, "JavaScript": 123} | package day03
import java.io.File
class Day03 {
companion object {
fun getPrioritySum(inputText: String): Int {
return inputText.lines().map { splitStringInHalf(it) }
.sumOf { getItemPriority(it[0], it[1]) }
}
fun splitStringInHalf(text: String): List<Strin... | 0 | Kotlin | 0 | 0 | c514152e9e2f0047514383fe536f7610a66aff70 | 1,631 | aoc-2022 | MIT License |
src/iii_conventions/MyDate.kt | gallko | 125,965,117 | false | null | package iii_conventions
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
override fun compareTo(other: MyDate): Int = when {
year != other.year -> year - other.year
month != other.month -> month - other.month
else -> dayOfMonth - other.dayOfMonth
... | 0 | Kotlin | 0 | 0 | c1290d56daf6276bfb5f82c1b0e3799262cf553c | 1,401 | kotlin-koans | MIT License |
week11familytravel/FamilyTravel.kt | laitingsheng | 341,616,623 | false | null | import java.util.PriorityQueue
class FamilyTravel {
data class Stop(@JvmField val dist: Int, @JvmField val prevDist: Int, @JvmField val src: Int) : Comparable<Stop> {
override fun compareTo(other: Stop): Int = dist - other.dist
}
fun shortest(edges: Array<String>): Int {
val m = edges.firs... | 0 | Kotlin | 0 | 0 | 2fc3e7a23d37d5e81cdf19a9ea19901b25941a49 | 1,340 | 2020S1-COMP-SCI-7007 | ISC License |
src/main/kotlin/day06/solution.kt | bukajsytlos | 433,979,778 | false | {"Kotlin": 63913} | package day06
import java.io.File
private const val REPRODUCTION_INTERVAL = 7
fun main() {
val fishReproductionTimers = File("src/main/kotlin/day06/input.txt").readLines().first().split(",").map { it.toInt() }
val fishCountByTimer = fishReproductionTimers.fold(Array(9) { 0L }) { acc, fishReproductionTimer ->... | 0 | Kotlin | 0 | 0 | f47d092399c3e395381406b7a0048c0795d332b9 | 1,005 | aoc-2021 | MIT License |
src/main/kotlin/days/Day23.kt | mstar95 | 317,305,289 | false | null | package days
import java.util.*
data class LLNode(val value: Int, var next: LLNode?)
class Day23 : Day(23) {
override fun partOne(): Any {
val cups = inputString.split("").mapNotNull { if (it == "") null else LLNode(it.toInt(), null) }
for (i in cups.indices) {
cups[i].next = cups[(i+... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 2,705 | aoc-2020 | Creative Commons Zero v1.0 Universal |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[22]括号生成.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。
//
//
//
// 示例 1:
//
//
//输入:n = 3
//输出:["((()))","(()())","(())()","()(())","()()()"]
//
//
// 示例 2:
//
//
//输入:n = 1
//输出:["()"]
//
//
//
//
// 提示:
//
//
// 1 <= n <= 8
//
// Related Topics 字符串 回溯算法
// 👍 1815 👎 0
//leetcode submit region begin(Prohib... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,239 | MyLeetCode | Apache License 2.0 |
src/iii_conventions/MyDate.kt | zerezhka | 67,052,442 | true | {"Kotlin": 83308, "Java": 4952} | package iii_conventions
import java.util.*
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
private val value: Int = year * 365 + month * 30 + dayOfMonth
override fun compareTo(other: MyDate): Int {
return this.value - other.value
}
infix operator ... | 0 | Kotlin | 0 | 0 | 4cb3dba98b96ba6b250f898b4b0a5ab2b07c9e3c | 1,935 | kotlin-koans | MIT License |
datastructures/src/main/kotlin/com/kotlinground/datastructures/linkedlists/singly/utils.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.datastructures.linkedlists.singly
import java.util.Stack
/**
* Returns the maximum twin sum of a node and its twin, where a node's twin is at the index (n-1-i) where n is the
* number of nodes in the linked list.
* For example, if n = 4, then node 0 is the twin of node 3, and node 1 is th... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 2,196 | KotlinGround | MIT License |
day9/src/main/kotlin/App.kt | ascheja | 317,918,055 | false | null | package net.sinceat.aoc2020.day9
import java.util.LinkedList
fun main() {
val testInput = parseInput("testinput.txt")
val testBuffer = RingBuffer.fromSequence(testInput, 5)
println(lookForFirstInvalidNumber(testBuffer, testInput))
val input = parseInput("input.txt")
val invalidNumber = run {
... | 0 | Kotlin | 0 | 0 | f115063875d4d79da32cbdd44ff688f9b418d25e | 2,016 | aoc2020 | MIT License |
src/main/kotlin/g0801_0900/s0875_koko_eating_bananas/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0801_0900.s0875_koko_eating_bananas
// #Medium #Array #Binary_Search #Binary_Search_II_Day_4
// #2023_04_08_Time_267_ms_(93.85%)_Space_37.7_MB_(96.62%)
class Solution {
fun minEatingSpeed(piles: IntArray, h: Int): Int {
var maxP = piles[0]
var sumP = 0L
for (pile in piles) {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 947 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/hu/advent/of/code/year2022/day8/Puzzle8B.kt | sztojkatamas | 568,512,275 | false | {"Kotlin": 157914} | package hu.advent.of.code.year2022.day8
import hu.advent.of.code.AdventOfCodePuzzle
import hu.advent.of.code.BaseChallenge
@AdventOfCodePuzzle
class Puzzle8B: BaseChallenge(2022) {
override fun run() {
printPuzzleName()
loadDataFromFile("data8.txt")
val rows = data.makeRows()
val ... | 0 | Kotlin | 0 | 0 | 6aa9e53d06f8cd01d9bb2fcfb2dc14b7418368c9 | 1,607 | advent-of-code-universe | MIT License |
app/src/main/java/eu/kanade/tachiyomi/data/animelib/AnimelibUpdateRanker.kt | terabyte25 | 432,093,270 | true | {"Kotlin": 3156741} | package eu.kanade.tachiyomi.data.animelib
import eu.kanade.tachiyomi.data.database.models.Anime
import java.util.Collections
import kotlin.math.abs
/**
* This class will provide various functions to rank manga to efficiently schedule manga to update.
*/
object AnimelibUpdateRanker {
val rankingScheme = listOf(... | 0 | Kotlin | 0 | 1 | e793c6cd156ba4185d3ce23be976b61e12924ed3 | 2,001 | aniyomi | Apache License 2.0 |
src/main/kotlin/com/dragbone/pizzabot/PizzaVoteParser.kt | dragbone | 68,312,794 | false | null | package com.dragbone.pizzabot
import java.text.ParseException
class PizzaVoteParser {
companion object {
private val dayMap: Map<String, DayOfWeek> = mapOf(
"mo" to DayOfWeek.MONDAY,
"di" to DayOfWeek.TUESDAY,
"tu" to DayOfWeek.TUESDAY,
"mi" ... | 0 | Kotlin | 3 | 2 | 9d5757a5f74e627cc8db74202c9d7f7a959c8d7a | 2,237 | slacking-pizzabot | Apache License 2.0 |
src/iii_conventions/MyDate.kt | JeffreyRuder | 75,589,618 | false | null | package iii_conventions
import java.util.*
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
override fun compareTo(other: MyDate): Int {
if (this.year == other.year && this.month == other.month && this.dayOfMonth == other.dayOfMonth) {
return 0
... | 0 | Kotlin | 0 | 0 | be230f075332880560ccf689152681cbd1778fac | 1,904 | kotlin-koans | MIT License |
src/main/kotlin/com/dambra/adventofcode2018/day4/GuardPost.kt | pauldambra | 159,939,178 | false | null | package com.dambra.adventofcode2018.day4
import java.time.LocalDateTime
class GuardPost(guardEvents: List<GuardEvent>) {
var bestGuardStrategyOne: Int = 0
private set
var bestGuardStrategyTwo: Int = 0
private set
private val guards = mutableMapOf<String, MutableList<Int>>()
init {
... | 0 | Kotlin | 0 | 1 | 7d11bb8a07fb156dc92322e06e76e4ecf8402d1d | 2,729 | adventofcode2018 | The Unlicense |
src/main/kotlin/cn/noisyfox/kotlin/itertools/Combination.kt | Noisyfox | 90,817,761 | false | null | /*
* Copyright 2017 Noisyfox.
*
* 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... | 0 | Kotlin | 1 | 0 | 6efbba6c4126f45ba4cd23ef8d22e7871fdaef65 | 3,335 | itertools-kotlin | Apache License 2.0 |
aoc2022/app/src/main/kotlin/aoc2022/Day15.kt | resurtm | 574,518,237 | false | null | // MIT License
//
// Copyright (c) 2022 <EMAIL>
//
// 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, mer... | 0 | Kotlin | 0 | 0 | 145ad55e3c5b475ab343ea95c68f7b9d683e4f87 | 5,479 | AdventOfCode | MIT License |
src/com/ncorti/aoc2022/Day04.kt | cortinico | 571,724,497 | false | {"Kotlin": 5773} | package com.ncorti.aoc2022
private fun String.processInput() = split("\n")
.map { it.split(",") }
.map { (p1, p2) ->
val pair1 = p1.split("-")
val pair2 = p2.split("-")
listOf(pair1[0].toInt(), pair1[1].toInt(), pair2[0].toInt(), pair2[1].toInt())
}
fun main() {
fun part1() = getInputAsText("04", ... | 4 | Kotlin | 0 | 1 | cd9ad108a1ed1ea08f9313c4cad5e52a200a5951 | 644 | adventofcode-2022 | MIT License |
src/main/kotlin/aoc2021/Day07.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2021
import utils.InputUtils
import kotlin.math.absoluteValue
fun main() {
val testInput = """16,1,2,0,4,2,7,1,2,14""".split("\n")
fun part1(input: List<String>): Int {
val items = input[0].split(",").map { it.toInt() }
return (items.min()..items.max()).minOf { pivot -> items.sum... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 947 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/homework5/hashTable/HashTable.kt | samorojy | 340,891,499 | false | null | package homework5.hashTable
class HashTable<K, V>(private var hashFunction: HashFunction<K>) {
companion object {
const val MAX_LOAD_FACTOR = 0.7
}
data class HashElement<K, V>(val key: K, var value: V)
private var elementCount = 0
private var bucketCount = 1
private val loadFactor: D... | 0 | Kotlin | 0 | 0 | d77c0af26cb55c74ae463f59244de233133b2320 | 2,926 | spbu_kotlin_course | Apache License 2.0 |
subprojects/gradle/performance/src/main/kotlin/com/avito/performance/PerformanceTestComparator.kt | sundetova | 287,793,131 | true | {"Kotlin": 2450349, "Shell": 16022, "Python": 14063, "Dockerfile": 7151, "Makefile": 2131} | package com.avito.performance
import com.avito.performance.stats.Stats
import com.avito.performance.stats.compare.TestForComparing
import com.avito.performance.stats.comparison.ComparedTest
import com.avito.report.model.PerformanceTest
import java.util.Collections.singletonList
internal class PerformanceTestComparato... | 0 | Kotlin | 1 | 0 | eec301953e12f7e7b93b3ce09965b58f26373bbd | 2,199 | avito-android | MIT License |
src/main/kotlin/com/dvdmunckhof/aoc/event2022/Day04.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2022
import com.dvdmunckhof.aoc.splitOnce
import com.dvdmunckhof.aoc.toRange
class Day04(private val input: List<String>) {
fun solvePart1(): Int {
return solve().count { (rangeA, rangeB) -> rangeA.contains(rangeB) || rangeB.contains(rangeA) }
}
fun solvePart2():... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 886 | advent-of-code | Apache License 2.0 |
src/main/kotlin/Puzzle14.kt | namyxc | 317,466,668 | false | null | import java.math.BigInteger
import kotlin.math.pow
object Puzzle14 {
@JvmStatic
fun main(args: Array<String>) {
val input = Puzzle14::class.java.getResource("puzzle14.txt").readText()
val program1 = Program(input)
program1.run()
println(program1.sumOfUsedMemoryAddresses())
... | 0 | Kotlin | 0 | 0 | 60fa6991ac204de6a756456406e1f87c3784f0af | 4,651 | adventOfCode2020 | MIT License |
Round 2 - A. Fresh Chocolate/src/app.kt | amirkhanyana | 110,548,909 | false | {"Kotlin": 20514} | import java.util.*
fun main(args: Array<String>) {
val input = Scanner(System.`in`)
val T = input.nextInt()
var Ti = 1
while (Ti <= T) {
val N = input.nextInt()
val P = input.nextInt()
val groups = IntArray(N, { input.nextInt() % P })
val modedGroups = IntArray(P)
... | 0 | Kotlin | 0 | 0 | 25a8e6dbd5843e9d4a054d316acc9d726995fffe | 1,576 | Google-Code-Jam-2017-Problem-Kotlin-Solutions | The Unlicense |
src/Day01.kt | 0xBuro | 572,308,139 | false | {"Kotlin": 4929} | fun main() {
fun elfNotes(input: String): List<List<Int>> {
return input.split("\n\n")
.map { singleElf -> singleElf.lines()
.map { it.toInt() } }
}
fun part1(input: String): Int {
val elvesCarry = elfNotes(input)
return elvesCarry.maxOf { it.sum() }
... | 0 | Kotlin | 0 | 0 | c05c4db78e24fc36f6f112bc1e8cf24ad5fd7698 | 707 | Advent-of-Kotlin | Apache License 2.0 |
2018/kotlin/day22p2/src/main.kt | sgravrock | 47,810,570 | false | {"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "... | import java.lang.Exception
import kotlin.math.min
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
val millis = measureTimeMillis {
println(Cave(9171, 7, 721).fewestMinutesToTarget())
}
println("in ${millis}ms")
}
data class Coord(val x: Int, val y: Int)
enum class Region { R... | 0 | Rust | 0 | 0 | ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3 | 3,681 | adventofcode | MIT License |
src/main/kotlin/aoc2023/Day16.kt | Ceridan | 725,711,266 | false | {"Kotlin": 110767, "Shell": 1955} | package aoc2023
import kotlin.math.max
class Day16 {
fun part1(input: String): Int {
val grid = parseInput(input)
return calculateConfiguration(grid, DirectedPoint(0 to 0, 'E'))
}
fun part2(input: String): Int {
val grid = parseInput(input)
val maxY = grid.keys.maxOf { it.... | 0 | Kotlin | 0 | 0 | 18b97d650f4a90219bd6a81a8cf4d445d56ea9e8 | 4,856 | advent-of-code-2023 | MIT License |
solutions/src/SumOfAbsoluteDifferences.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | /**
* https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array/
*/
class SumOfAbsoluteDifferences {
fun getSumAbsoluteDifferences(nums: IntArray): IntArray {
val returnArray = IntArray(nums.size)
val numsSolutions = mutableMapOf<Int,Int>()
val numsSorted = nums.sorted... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,094 | leetcode-solutions | MIT License |
src/Day06.kt | hrach | 572,585,537 | false | {"Kotlin": 32838} | fun main() {
fun part1(input: List<String>): Int {
val m = input.first()
m.windowedSequence(4, 1).forEachIndexed { index, s ->
if (s.toSet().size == 4) return index + 4
}
error("e")
}
fun part2(input: List<String>): Int {
val m = input.first()
m.w... | 0 | Kotlin | 0 | 1 | 40b341a527060c23ff44ebfe9a7e5443f76eadf3 | 720 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumWindowSubstring.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,915 | kotlab | Apache License 2.0 |
advent-of-code-2018/src/test/java/aoc/Advent1.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | package aoc
import extensions.kotlin.cycle
import extensions.kotlin.scan
import io.vavr.collection.HashMap
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class Advent1 {
@Test
fun `Frequency should be 425`() {
val sum = advent1Input1.lines()
.map { it.toLong() }
... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 10,812 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/Tribonacci.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 | 2,395 | kotlab | Apache License 2.0 |
src/main/kotlin/tree/bintree/CentralNode.kt | yx-z | 106,589,674 | false | null | package tree.bintree
import util.Tuple2
import util.prettyPrintTree
import util.tu
import kotlin.collections.set
// given a binary tree, a central node n is a node : after deleting the node,
// the tree is split into three parts: left child of n (and its subtree), right
// child of n (and its subtree), and parent of ... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,563 | AlgoKt | MIT License |
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/SortingAlgorithms/OnSortingAlgorithms/SelectionSort.kt | betulnecanli | 568,477,911 | false | {"Kotlin": 167849} | package com.betulnecanli.kotlindatastructuresalgorithms.SortingAlgorithms.OnSortingAlgorithms
/*Selection sort follows the basic idea of bubble sort but improves upon this
algorithm by reducing the number of swapAt operations. Selection sort only swaps at
the end of each pass.*/
/*Lik... | 2 | Kotlin | 2 | 40 | 70a4a311f0c57928a32d7b4d795f98db3bdbeb02 | 1,986 | Kotlin-Data-Structures-Algorithms | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2023/d21/Day21.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d21
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.grids.Grid
import com.groundsfam.advent.grids.maybeGet
import com.groundsfam.advent.grids.pointOfFirst
import com.groundsfam.advent.grids.readGrid
import com.groundsfam.advent.points.Point
import com.groundsfam.a... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 6,636 | advent-of-code | MIT License |
src/main/kotlin/stlutils/optimization/stlReducer/SupportVerticesComputer.kt | ivan-osipov | 199,982,728 | false | null | package stlutils.optimization.stlReducer
import stlutils.common.*
import kotlin.math.max
import kotlin.math.min
internal class SupportVerticesComputer(private val data: GraphData) {
fun compute(
accuracyCoefX: Int = 1,
accuracyCoefY: Int = 1,
accuracyCoefZ: Int = 1
): Set<VertexIdx> {
... | 1 | Kotlin | 0 | 0 | c7c36c71e9990e28529b874c7522a38411a3913e | 3,978 | stl-utls | Apache License 2.0 |
src/main/kotlin/com/askrepps/advent2021/day02/Day02.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,431 | advent-of-code-kotlin | MIT License |
src/main/kotlin/nl/kelpin/fleur/advent2018/Day04.kt | fdlk | 159,925,533 | false | null | package nl.kelpin.fleur.advent2018
typealias GuardID = Int
typealias Minute = Int
class Day04(input: List<String>) {
data class Nap(val guard: GuardID, val minutes: IntRange)
data class State(val guard: GuardID? = null, val napStarted: Int? = null, val naps: List<Nap> = listOf()) {
fun beginShift(new... | 0 | Kotlin | 0 | 3 | a089dbae93ee520bf7a8861c9f90731eabd6eba3 | 2,022 | advent-2018 | MIT License |
aoc-2015/src/main/kotlin/aoc/AocDay20.kt | triathematician | 576,590,518 | false | {"Kotlin": 615974} | package aoc
class AocDay20: AocDay(20) {
companion object { @JvmStatic fun main(args: Array<String>) { AocDay20().run() } }
override val testinput = """
200
""".trimIndent().lines()
/** All divisors, including 1 and self. */
private fun Int.divisors(): List<Int> {
val res = mutabl... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 1,842 | advent-of-code | Apache License 2.0 |
src/main/kotlin/year2023/day11/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2023.day11
import IProblem
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
class Problem : IProblem {
private val size: Int
private val space: Array<IntArray>
private val emptyRows: BooleanArray
private val emptyCols: BooleanArray
private val galaxies = mutableList... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 1,958 | advent-of-code | The Unlicense |
src/day06/Day06.kt | apeinte | 574,487,528 | false | {"Kotlin": 47438} | package day06
import readDayInput
//Don't forget to fill this constant.
const val RESULT_EXAMPLE_PART_ONE_1 = 7
const val RESULT_EXAMPLE_PART_ONE_2 = 5
const val RESULT_EXAMPLE_PART_ONE_3 = 6
const val RESULT_EXAMPLE_PART_ONE_4 = 10
const val RESULT_EXAMPLE_PART_ONE_5 = 11
const val RESULT_EXAMPLE_PART_TWO_1 = 19
con... | 0 | Kotlin | 0 | 0 | 4bb3df5eb017eda769b29c03c6f090ca5cdef5bb | 3,235 | my-advent-of-code | Apache License 2.0 |
atcoder/agc044/b.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package atcoder.agc044
fun main() {
val n = readInt()
val p = readInts().map { it - 1 }
val dist = List(n) { x -> IntArray(n) { y -> sequenceOf(x, y, n - 1 - x, n - 1 - y).minOrNull()!! + 1 } }
val on = List(n) { x -> BooleanArray(n) { true } }
var ans = 0
val stack = IntArray(n * n)
for (r in p) {
val rx = r... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,148 | competitions | The Unlicense |
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day3/Day3.kt | jntakpe | 433,584,164 | false | {"Kotlin": 64657, "Rust": 51491} | package com.github.jntakpe.aoc2021.days.day3
import com.github.jntakpe.aoc2021.shared.Day
import com.github.jntakpe.aoc2021.shared.readInputLines
object Day3 : Day {
private const val ZERO = '0'
private const val ONE = '1'
override val input = readInputLines(3)
override fun part1(): Int {
re... | 0 | Kotlin | 1 | 5 | 230b957cd18e44719fd581c7e380b5bcd46ea615 | 1,150 | aoc2021 | MIT License |
kotlin/src/katas/kotlin/permutation/AllPermutationTypes.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.permutation
import nonstdlib.*
import datsok.*
import org.junit.*
import java.util.*
class AllPermutationTypes {
@Test fun `permutations by removal`() {
listOf(1, 2, 3).permutations_remove() shouldEqual listOf(
listOf(3, 2, 1),
listOf(2, 3, 1),
lis... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 6,684 | katas | The Unlicense |
src/Day02.kt | maxonof | 572,454,805 | false | {"Kotlin": 5967} | fun main() {
val input = readInput("input2")
val res = input.sumOf {
val s = it.split(" ")
val ss = getActualScore(s.last(), s.first())
println(ss)
ss
}
println(res)
}
fun getScore(mine: String, theirs: String): Int {
return when (mine) {
"Y" -> {
... | 0 | Kotlin | 0 | 0 | ef03fc65dcd429d919eb12d054ce7c052780d7d7 | 1,263 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day02/Day02.kt | TimberBro | 567,240,136 | false | {"Kotlin": 11186} | package day02
import utils.readInput
fun main() {
fun part1(input: List<String>): Int {
var result = 0
for (line in input) {
val splitLine = line.split(":", "-", " ")
val minValue = splitLine[0].toInt()
val maxValue = splitLine[1].toInt()
val charact... | 0 | Kotlin | 0 | 0 | 1959383d2f422cc565560eefb1ed4f05bb87a386 | 1,309 | aoc2020 | Apache License 2.0 |
intellidiff/src/main/java/com/target/diff/writer/Hints.kt | target | 393,172,530 | false | null | package com.target.diff.writer
import com.target.diff.differ.Change
internal data class Hint(val expected: String, val actual: String)
internal class Hints(val writer: HintWriter = HintWriter()) {
fun generate(change: Change): Hint {
return when (change) {
is Change.DifferentContainerSize ->
wri... | 1 | Kotlin | 1 | 8 | 4f6c91231bf3c1792c9774f710812e6e2a91d330 | 3,193 | intellidiff | Apache License 2.0 |
src/main/kotlin/year2022/day-14.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2022
import lib.aoc.Day
import lib.aoc.Part
import lib.math.Vector
import lib.math.minus
import lib.math.plus
import kotlin.math.max
import kotlin.math.min
fun main() {
Day(14, 2022, PartA14(), PartB14()).run()
}
open class PartA14 : Part() {
internal lateinit var cave: MutableSet<Vector>
in... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 2,812 | Advent-Of-Code-Kotlin | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.