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
day06/part2.kts
bmatcuk
726,103,418
false
{"Kotlin": 214659}
// --- 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 ...
0
Kotlin
0
0
a01c9000fb4da1a0cd2ea1a225be28ab11849ee7
1,881
adventofcode2023
MIT License
src/Day10.kt
catcutecat
572,816,768
false
{"Kotlin": 53001}
import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { Day10.run { solve1(13140) // 14760 solve2(0) // "EFGERURE" } }.let { println("Total: $it ms") } } object Day10 : Day.LineInput<List<Day10.Data>, Int>("10") { data class Data(val isAdd: Boolean,...
0
Kotlin
0
2
fd771ff0fddeb9dcd1f04611559c7f87ac048721
1,466
AdventOfCode2022
Apache License 2.0
src/main/kotlin/gal/usc/citius/processmining/dfgfiltering/filtering/TwoWaysEdmonds.kt
david-chapela
322,881,845
false
null
package gal.usc.citius.processmining.dfgfiltering.filtering import gal.usc.citius.processmining.dfgfiltering.graph.DirectedGraph import gal.usc.citius.processmining.dfgfiltering.graph.Edge import gal.usc.citius.processmining.dfgfiltering.graph.Vertex import java.util.Deque import java.util.LinkedList /** * Given a c...
0
Kotlin
0
0
d73d1f3f3462f9ef3d699d8fafb1435084b472ef
8,689
dfg-edge-filtering
MIT License
src/main/kotlin/cloud/dqn/leetcode/self/MyHeap.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode.self import java.util.Comparator class MyHeap<T> { private var heap: ArrayList<T> = ArrayList() private var comparator: Comparator<T> constructor(comparator: Comparator<T>) { this.comparator = comparator } // add to the end of the tree; heapUp fun push(t: T...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
2,764
cloud-dqn-leetcode
No Limit Public License
src/main/kotlin/ctci/chaptersixteen/EnglishInt.kt
amykv
538,632,477
false
{"Kotlin": 169929}
package ctci.chaptersixteen // 16.8 - page 182 // Given any integer, print an English phrase that describes the integer (e.g., "One Thousand, Two Hundred // Thirty Four"). fun main() { val num = 123456 println(numberToWords(num)) } fun numberToWords(num: Int): String { if (num == 0) return "Zero" val...
0
Kotlin
0
2
93365cddc95a2f5c8f2c136e5c18b438b38d915f
1,417
dsa-kotlin
MIT License
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem006.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems /** * Problem 6 * * The sum of the squares of the first ten natural numbers is, * * 1^2 + 2^2 + ... + 10^2 = 385 * * The square of the sum of the first ten natural numbers is, * (1 + 2 + ... + 10)^2 = 552 = 3025 * * Hence the difference between the sum of the squares of...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
824
project-euler
MIT License
src/org/prime/util/Converter.kt
bozhnyukAlex
429,572,343
false
{"Kotlin": 18468}
package org.prime.util import org.prime.util.machines.Direction import org.prime.util.machines.TapeMachine interface Converter { fun machineToGrammar(machine: TapeMachine): Grammar } object Constants { const val EPSILON = "epsilon" const val RIGHT = ">" const val COMMENT = "//" const val BLANK = ...
0
Kotlin
1
0
b1e4afe3b0d4292d202492f2271ffd7b378a371c
3,576
primary-numbers-grammar
MIT License
src/main/kotlin/org/vaccineimpact/api/models/expectations/CountryOutcomeExpectations.kt
vimc
88,746,413
false
{"Kotlin": 35433}
package org.vaccineimpact.api.models.expectations import org.vaccineimpact.api.models.* import org.vaccineimpact.api.models.helpers.FlexibleProperty data class CountryOutcomeExpectations( override val id: Int, override val description: String, override val years: IntRange, override val...
0
Kotlin
0
0
999369f9ad88f3141b208fe3308c8575fc8899b3
3,184
montagu-webmodels
MIT License
src/main/kotlin/day1/Day1.kt
Wicked7000
573,552,409
false
{"Kotlin": 106288}
package day1 import Day import checkWithMessage import parserCombinators.* import parserCombinators.newLine import readInput import readInputString import runTimedPart @Suppress("unused") class Day1(): Day() { private fun parseInput(input: String): List<List<Int>> { val parseTree = parseTillEnd(sequenceOf...
0
Kotlin
0
0
7919a8ad105f3b9b3a9fed048915b662d3cf482d
2,218
aoc-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem295/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem295 import java.util.* /** * LeetCode page: [295. Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/); */ class MedianFinder() { private val leftHalf = PriorityQueue<Int>(reverseOrder()) private val rightHalf = PriorityQueue<Int>()...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,705
hj-leetcode-kotlin
Apache License 2.0
leetcode2/src/leetcode/binary-tree-zigzag-level-order-traversal.kt
hewking
68,515,222
false
null
package leetcode import leetcode.structure.TreeNode import java.util.* /** * 103. 二叉树的锯齿形层次遍历 * https://leetcode-cn.com/problems/binary-tree-zigzag-level-order-traversal/ * @program: leetcode * @description: ${description} * @author: hewking * @create: 2019-10-22 10:43 * 给定一个二叉树,返回其节点值的锯齿形层次遍历。(即先从左往右,再从右往左进行下...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,766
leetcode
MIT License
app/src/main/kotlin/aoc2022/day03/Day03.kt
dbubenheim
574,231,602
false
{"Kotlin": 18742}
package aoc2022.day03 import aoc2022.toFile object Day03 { fun part1(): Int { return "input-day03.txt" .toFile() .readLines() .sumOf { it.calc() } } fun part2(): Int { return "input-day03.txt" .toFile() .readLines() ...
8
Kotlin
0
0
ee381bb9820b493d5e210accbe6d24383ae5b4dc
965
advent-of-code-2022
MIT License
src/main/kotlin/me/grison/aoc/y2020/Day11.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2020 import me.grison.aoc.* import kotlin.reflect.KFunction2 class Day11 : Day(11, 2020) { override fun title() = "Seating System" override fun partOne(): Int = evolve(4, this::adjacent) override fun partTwo(): Int = evolve(5, this::firstSeen) private fun evolve(tolerance: In...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
3,194
advent-of-code
Creative Commons Zero v1.0 Universal
implementation/src/main/kotlin/io/github/tomplum/aoc/game/QuantumDie.kt
TomPlum
431,391,240
false
{"Kotlin": 114607}
package io.github.tomplum.aoc.game /** * A quantum die has 3 sides numbered 1, 2 & 3. * Each time it is rolled, a new parallel universe is created for * each of the possible outcomes. */ class QuantumDie { /** * In a game of [DiracDice], the die is rolled 3 times per turn. * Rolling this quantum dice...
0
Kotlin
0
0
cccb15593378d0bb623117144f5b4eece264596d
1,650
advent-of-code-2021
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/CycleDetectionUnionFind.ws.kts
sjaindl
384,471,324
false
null
package com.sjaindl.kotlinalgsandroid.graph /* https://www.geeksforgeeks.org/union-find/ */ class CycleDetection { fun hasCycle(graph: Graph): Boolean { //val unionFind = Array(graph.vertices.size) { -1 } val unionFind: MutableMap<Int, Int> = mutableMapOf() val counts: MutableMap<Int,...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,591
KotlinAlgs
MIT License
calendar/day04/Day4.kt
polarene
572,886,399
false
{"Kotlin": 17947}
package day04 import Day import Lines class Day4 : Day() { override fun part1(input: Lines): Any { return input.map(::parseAssignments) .count { it.fullyOverlaps() } } override fun part2(input: Lines): Any { return input.map(::parseAssignments) .count { it.overlaps...
0
Kotlin
0
0
0b2c769174601b185227efbd5c0d47f3f78e95e7
1,145
advent-of-code-2022
Apache License 2.0
Problem Solving/Data Structures/Left Rotation.kt
MechaArms
525,331,223
false
{"Kotlin": 30017}
/* A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. Given an integer, d, rotate the array that many steps left and return the result. Example d=2 arr=[1,2,3,4,5] After 2 rotations, arr'=[3,4,5,1,2]. Function Description Complete the rotateLeft function in the ...
0
Kotlin
0
1
eda7f92fca21518f6ee57413138a0dadf023f596
2,264
My-HackerRank-Solutions
MIT License
src/main/kotlin/adventofcode/y2021/Day17.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.* fun main() { val testInput = """ target area: x=20..30, y=-10..-5 """.trimIndent() runDay( day = Day17::class, testInput = testInput, testAnswer1 = 45, testAnswer2 = 112 ) } open class Day17(staticInput: String? = null) : Y2021Day(17, stati...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
2,366
adventofcode2021
The Unlicense
src/test/kotlin/com/github/michaelbull/advent2021/day10/Day10Test.kt
michaelbull
433,565,311
false
{"Kotlin": 162839}
package com.github.michaelbull.advent2021.day10 import com.github.michaelbull.advent2021.day10.Day10.part1 import com.github.michaelbull.advent2021.day10.Day10.part2 import kotlin.test.Test import kotlin.test.assertEquals class Day10Test { @Test fun `example 1`() { val input = """ [({(<((...
0
Kotlin
0
4
7cec2ac03705da007f227306ceb0e87f302e2e54
1,440
advent-2021
ISC License
src/day17/Day17Alternative.kt
gautemo
317,316,447
false
null
package day17 import shared.DimensionMap import shared.getText fun cubeStateAlt(input: String, cycles: Int, dimension: Int = 3): Int{ var map = DimensionMap(input, dimension) for(i in 1..cycles) map = tickAlt(map) return map.countChar('#') } fun tickAlt(map: DimensionMap): DimensionMap{ val copyMap =...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
1,139
AdventOfCode2020
MIT License
src/main/kotlin/dev/sirch/aoc/y2022/days/Day01.kt
kristofferchr
573,549,785
false
{"Kotlin": 28399, "Mustache": 1231}
package dev.sirch.aoc.y2022.days import dev.sirch.aoc.Day class Day01(testing: Boolean = false): Day(2022, 1, testing) { override fun part1(): Int { val allElves = parseElves(inputLines) return allElves.maxBy { it.totalCalories }.totalCalories } override fun part2(): Int { val allElves = par...
0
Kotlin
0
0
867e19b0876a901228803215bed8e146d67dba3f
1,051
advent-of-code-kotlin
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day25.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.math.pow import kotlin.test.assertEquals class Day25 : AbstractDay() { @Test fun part1Test() { assertEquals("2=-1=0", compute1(testInput)) } @Test fun part1Puzzle() { asse...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
2,371
aoc
Apache License 2.0
2017/src/main/kotlin/Day25.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import grid.Turn import utils.splitNewlines import java.util.regex.Matcher import java.util.regex.Pattern object Day25 { fun part1(input: String): Int { val blueprint = parseBlueprint(input) val states = blueprint.states.associateBy { it.name } var tape = mutableSetOf<Int>() var position = 0 va...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
3,032
advent-of-code
MIT License
src/main/kotlin/io/undefined/FindAllAnagramsInAString.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.undefined import io.utils.runTests // https://leetcode.com/problems/find-all-anagrams-in-a-string/ class FindAllAnagramsInAString { fun execute(input: String, anagram: String): List<Int> { if (input.isEmpty() || anagram.length > input.length) return emptyList() val result = mutableListOf<Int>()...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,424
coding
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/AddOneRowToTree.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
4,798
kotlab
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day2/Day2.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day2 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInputLines import kotlin.math.abs object Day2 : Day { override val input: List<Move> = readInputLines(2).map { it.parseMove() } override fun part1() = input.fold(Position())...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
1,600
aoc2021
MIT License
src/main/kotlin/days/Day3.kt
couturierb
728,250,155
false
{"Kotlin": 27134}
package days import kotlin.math.log class Day3 : Day(3) { val lineLength = inputList[0].length + 1 val numbers: Sequence<MatchResult> = Regex("\\d+").findAll(inputString) val symbols: Sequence<MatchResult> = Regex("[^\\d.\\w\\s]").findAll(inputString) val gears: Sequence<MatchResult> = Regex("\\*").f...
0
Kotlin
0
0
eb48e810592beaf221b9a8620c8ebc19282ac059
1,588
adventofcode2023
Creative Commons Zero v1.0 Universal
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions80.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test80() { printlnResult(3, 2) } /** * Questions 80: Input integers n and k, find all sets that size is k and be combined by integers in 1...n */ private fun allSets(n: Int, k: Int): List<List<Int>> { require(n > 0) { "The n must grater than 0" } if (k == 0) ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
964
Algorithm
Apache License 2.0
cryptonote/src/test/kotlin/io/pnyx/bubu/cryptonote/boo/EcAlgebra.kt
pnyxio
133,630,013
false
null
package io.pnyx.bubu.cryptonote.boo import org.junit.Assert import org.junit.Test import java.math.BigInteger import java.math.BigInteger.ONE import java.math.BigInteger.ZERO class Test { @Test fun dotest() { val _29 = Fe(i(29), i(99)) val _87 = Fe(i(87), i(99)) val sum = _29 + _87 ...
0
Kotlin
0
0
2929362a2fabcc342aba450ebf9b5129eb6dfe17
3,148
bubu
Apache License 2.0
src/main/kotlin/day13.kt
p88h
317,362,882
false
null
internal fun inv(a0: Long, m0: Long): Long { var m = m0; var a = a0; var x0 = 0L; var x1 = 1L while (a > 1) { val q = a / m; val t0 = m; m = a % m; a = t0 val t1 = x0; x0 = x1 - q * x0; x1 = t1 } return if (x1 < 0) x1 + m0 else x1 } fun main(args: Array<String>) { val input ...
0
Kotlin
0
5
846ad4a978823563b2910c743056d44552a4b172
925
aoc2020
The Unlicense
src/main/kotlin/day6.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getText fun simulateLanternfishGrowth(input: String, times: Int = 80): Long{ val map = mutableMapOf( Pair(0, input.count { it == '0' }.toLong()), Pair(1, input.count { it == '1' }.toLong()), Pair(2, input.count { it == '2' }.toLong()), Pair(3, input.count { it == '3' }...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
1,136
AdventOfCode2021
MIT License
src/main/kotlin/com/psmay/exp/advent/y2021/Day12.kt
psmay
434,705,473
false
{"Kotlin": 242220}
@file:Suppress("unused") package com.psmay.exp.advent.y2021 import com.psmay.exp.advent.y2021.util.asSet object Day12 { data class CaveNode(val name: String, val isSmall: Boolean) { override fun toString() = "<$name>" } fun String.toCaveNode(): CaveNode { val name = this val isSm...
0
Kotlin
0
0
c7ca54612ec117d42ba6cf733c4c8fe60689d3a8
4,168
advent-2021-kotlin
Creative Commons Zero v1.0 Universal
kotlin/486.Predict the Winner(预测赢家).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 an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the next player. This continues until all the scores have been cho...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
5,010
leetcode
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1339/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1339 import com.hj.leetcode.kotlin.common.model.TreeNode /** * LeetCode page: [1339. Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/description/); */ class Solution { /* Complexity: * Time O(N) and Space O...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,140
hj-leetcode-kotlin
Apache License 2.0
domain/src/main/java/com/jacekpietras/zoo/domain/business/Dijkstra.kt
JacekPietrasSpotOn
472,234,427
true
{"Kotlin": 402237, "Java": 7306}
package com.jacekpietras.zoo.domain.business internal class Dijkstra( vertices: Set<Node>, private val start: Node, private val end: Node, technicalAllowed: Boolean = false, ) { private val previous: MutableMap<Node, Node?> = vertices.map { it to null }.toMutableMap() init { // shorte...
0
null
0
0
07474546a9dbfc0263126b59933086b38d41b7e1
1,919
ZOO
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year22/Day13.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year22 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.asList import com.grappenmaker.aoc.asPair import kotlinx.serialization.json.* import kotlin.math.min fun PuzzleSet.day13() = puzzle { val pairs = input.split("\n\n").map { p -> p.lines().map { parseValue(it) }.as...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,094
advent-of-code
The Unlicense
numbers/src/main/kotlin/mathtools/numbers/primes/PrimeCacheBase.kt
RishiKumarRay
467,793,819
true
{"Kotlin": 182604, "Java": 53276}
package mathtools.numbers.primes import mathtools.numbers.factors.BitFactoring.isProductOf2 /** Common to Prime Number Caches */ abstract class PrimeCacheBase( /** The highest index that this Cache can store */ val maxIndex: Int, /** The maximum value that small data type arrays can hold */ val maxValue: Int, ) ...
0
Kotlin
0
0
a7c4887a2ac37756b5a1c71265b6c006cf22ccb9
4,087
MathTools
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2020/Day8.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 8: Handheld Halting --- * https://adventofcode.com/2020/day/8 */ class Day8 : Solver { override fun solve(lines: List<String>): Result { val input = lines.map { it.split(" ") }.map { Instr(it[0], it[1].toInt()) }...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
1,918
euler
Apache License 2.0
src/main/kotlin/days/Day13.kt
sicruse
315,469,617
false
null
package days class Day13 : Day(13) { data class Bus(val departure: Int, val frequency: Long) private val earliestPossibleDeparture: Long by lazy { inputList[0].toLong() } private val busses: List<Bus> by lazy { inputList[1].split(",").mapIndexedNotNull { departure, fre...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
1,265
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/biz/koziolek/adventofcode/year2021/day16/day16.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day16 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val line = inputFile.bufferedReader().readLine() val packet = parseBitsPacket(line) println("Version numbers sum: ${sumAllVersions(packet)}") println("Packet value...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
5,978
advent-of-code
MIT License
src/main/kotlin/com/nlkprojects/neuralnet/math/rational/Rational.kt
leokash
264,928,399
false
null
package com.nlkprojects.neuralnet.math.rational import java.lang.RuntimeException data class Rational(val numerator: Long, val denominator: Long): Number(), Comparable<Rational> { constructor(num: Int): this(num, num) constructor(num: Long): this(num, num) constructor(num: Int, den: Int): this(num.toLong(...
0
Kotlin
0
0
d243588ef4f66e71294d486ffbfecfb88372a69e
3,889
neuralnet
Apache License 2.0
src/main/kotlin/math/Prime.kt
yx-z
106,589,674
false
null
package math import java.util.* fun main(args: Array<String>) { val LIMIT = 100000 println(time { sievePrime(LIMIT) }) println(time { listPrime(LIMIT) }) println(time { listByIsPrime(LIMIT) }) println(5.thPrime()) // 5th prime = 11 println(Arrays.toString(5.thPrimes())) // first 5 primes = [2, 3, 5, 7, 11] } ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,879
AlgoKt
MIT License
contest1907/src/main/kotlin/CFixed.kt
austin226
729,634,548
false
{"Kotlin": 23837}
import kotlin.streams.toList // https://codeforces.com/contest/1907/problem/C private fun readInt(): Int = readln().toInt() private fun <T> List<T>.counts(): Map<T, Int> = this.groupingBy { it }.eachCount() private fun solve(n: Int, s: String): Int { // https://codeforces.com/blog/entry/123012 // The final st...
0
Kotlin
0
0
4377021827ffcf8e920343adf61a93c88c56d8aa
1,428
codeforces-kt
MIT License
src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1073_adding_two_negabinary_numbers // #Medium #Array #Math #2023_05_31_Time_187_ms_(100.00%)_Space_40.9_MB_(100.00%) class Solution { fun addNegabinary(arr1: IntArray, arr2: IntArray): IntArray { val len1 = arr1.size val len2 = arr2.size val reverseArr1 = IntArray(len1)...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,508
LeetCode-in-Kotlin
MIT License
src/main/kotlin/org/kotrix/test.kt
JarnaChao09
285,169,397
false
{"Kotlin": 446442, "Jupyter Notebook": 26378}
package org.kotrix import kotlin.system.measureTimeMillis import kotlin.math.absoluteValue /* https://users.wpi.edu/~walker/MA510/HANDOUTS/w.gander,w.gautschi,Adaptive_Quadrature,BIT_40,2000,84-101.pdf chapter 3 adaptive simpsons */ fun integralScan(a: Double, b: Double, eps: Double, f: (Double) -> Double): Double /...
0
Kotlin
1
5
c5bb19457142ce1f3260e8fed5041a4d0c77fb14
3,964
Kotrix
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem7/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem7 /** * LeetCode page: [7. Reverse Integer](https://leetcode.com/problems/reverse-integer/); */ class Solution { private val digitsOfIntMax = intArrayOf(2, 1, 4, 7, 4, 8, 3, 6, 4, 7) /* Complexity: * Time O(LogN) and Space (LogN) where N equals x; */ fun r...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,282
hj-leetcode-kotlin
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/ReorderList.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import com.daily.algothrim.linked.LinkedNode /** * 143. 重排链表 * * 给定一个单链表 L:L0→L1→…→Ln-1→Ln , * 将其重新排列后变为: L0→Ln→L1→Ln-1→L2→Ln-2→… * * 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 * * 示例 1: * * 给定链表 1->2->3->4, 重新排列为 1->4->2->3. * 示例 2: * * 给定链表 1->2->3->4->5, 重新排列为 1->5->2->4->3....
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,207
daily_algorithm
Apache License 2.0
jvm_sandbox/projects/advent_of_code/src/main/kotlin/year2018/Day7.kt
jduan
166,515,850
false
{"Rust": 876461, "Kotlin": 257167, "Java": 139101, "Python": 114308, "Vim Script": 100117, "Shell": 96665, "C": 67784, "Starlark": 23497, "JavaScript": 20939, "HTML": 12920, "Ruby": 5087, "Thrift": 4518, "Nix": 2919, "HCL": 1069, "Lua": 926, "CSS": 826, "Assembly": 761, "Makefile": 591, "Haskell": 585, "Dockerfile": 50...
package year2018.day7 import java.io.File import java.lang.RuntimeException class Node(val name: String) { var nexts: MutableList<Node> = mutableListOf() private var incoming: Int = 0 fun addNext(next: Node) { nexts.add(next) next.incoming += 1 } fun decrement() { incomin...
58
Rust
1
0
d5143e89ce25d761eac67e9c357620231cab303e
4,302
cosmos
MIT License
src/Day02.kt
gischthoge
573,509,147
false
{"Kotlin": 5583}
fun main() { fun part1(input: List<String>): Int { return input.map { it.toCharArray().first().lowercaseChar() to it.toCharArray().last().lowercaseChar() } .sumOf { (a, b) -> b - 'x' + 1 + ((b + ('a' - 'x') - a + 1).mod(3)) * 3 } } fun part2(input: List<String>): Int { retur...
0
Kotlin
0
0
e403f738572360d4682f9edb6006d81ce350ff9d
570
aock
Apache License 2.0
hierarchy/src/commonMain/kotlin/io/data2viz/hierarchy/pack/Enclose.kt
data2viz
89,368,762
false
null
/* * Copyright (c) 2018-2021. data2viz sàrl. * * 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...
79
Kotlin
29
389
5640d3e8f1ce4cd4e5d651431726869e329520fc
4,953
data2viz
Apache License 2.0
src/main/kotlin/algorithms/CandyCount.kt
AgentKnopf
240,955,745
false
null
package algorithms /** * There are N children standing in a line. Each child is assigned a rating value. * You are giving candies to these children subjected to the following requirements: * * Each child must have at least one candy. * Children with a higher rating get more candies than their neighbors. * What ...
0
Kotlin
1
0
5367ce67e54633e53b2b951c2534bf7b2315c2d8
1,297
technical-interview
MIT License
src/main/kotlin/solver/model.kt
toukovk
256,759,841
false
null
package solver import java.lang.RuntimeException import kotlin.math.abs interface ExpressionItem enum class Operator : ExpressionItem { ADD { override fun apply(a1: Double, a2: Double) = a1 + a2 }, MINUS { override fun apply(a1: Double, a2: Double) = a1 - a2 }, TIMES { override fun apply(a1: Double, a2: ...
0
Kotlin
0
0
2c878978b6b9edbaac961dccb82418c504cec7f3
2,393
24-solver
Apache License 2.0
src/main/kotlin/days/Day3.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days class Day3 : Day(3) { override fun partOne(): Any { return p1(inputList) } override fun partTwo(): Any { return p2(inputList) } fun p1(l: List<String>): Int { val total = l.size val first = l[0] val amountOfBits = first.length val ones ...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
2,314
aoc2021
Creative Commons Zero v1.0 Universal
src/test/kotlin/Day5Test.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day5Test { @Test fun test_real_input() { println(getHighestSeatNumber(readFileAsLinesUsingUseLines("/Users/fredrikfolkesson/git/advent-of-code/src/test/kotlin/input-day5.txt"))) } @Test fun test_real_input_part_2() {...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
2,984
advent-of-code
MIT License
src/main/kotlin/me/grison/aoc/y2017/Day24.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2017 import me.grison.aoc.Day import me.grison.aoc.allInts import me.grison.aoc.pair import me.grison.aoc.sum class Day24 : Day(24, 2017) { override fun title() = "Electromagnetic Moat" val elements = inputList.map { it.allInts().pair() } // 1656 override fun partOne() = build...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,012
advent-of-code
Creative Commons Zero v1.0 Universal
js/js.translator/testFiles/webDemoExamples2/cases/maze.kt
chirino
3,596,099
true
null
/** * Let's Walk Through a Maze. * * Imagine there is a maze whose walls are the big 'O' letters. * Now, I stand where a big 'I' stands and some cool prize lies * somewhere marked with a '$' sign. Like this: * * OOOOOOOOOOOOOOOOO * O O * O$ O O * OOOOO O * O ...
0
Java
28
70
ac434d48525a0e5b57c66b9f61b388ccf3d898b5
5,423
kotlin
Apache License 2.0
src/Day01.kt
mertceyhan
573,013,476
false
{"Kotlin": 4804}
fun main() { fun getTotalCaloriesByOrder(input: List<String>): List<Int> { val totalCalories = mutableListOf<Int>() var currentTotalCalorie = 0 input.forEachIndexed { index, string -> if (string != "") { currentTotalCalorie += string.toInt() } else {...
0
Kotlin
0
1
e079082b70ae459fa1068653d11c54399265b8c8
978
aoc-2022-in-kotlin
Apache License 2.0
src/Day09.kt
mvmlisb
572,859,923
false
{"Kotlin": 14994}
private data class Coords(var x: Int, var y: Int) private class Rope { private var head = Coords(0, 0) private var tail = Coords(0, 0) val visitedCordsByTail = mutableSetOf<Coords>() init { visitedCordsByTail += tail.copy() } fun move(string: String) { val split = string.spli...
0
Kotlin
0
0
648d594ec0d3b2e41a435b4473b6e6eb26e81833
1,957
advent_of_code_2022
Apache License 2.0
src/aoc2022/day03/AoC03.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day03 import readLines fun main() { fun part1(list: List<String>): Int { return list.map { val len = it.length val a = it.substring(0, len / 2).toSet() val b = it.substring(len / 2).toSet() val x = (a intersect b).first() if (x.isLowerCase()) x - 'a' + 1 else x - 'A' + 2...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
625
aoc2022
Apache License 2.0
src/main/kotlin/dwt/Dwt33.kt
sssemil
268,084,789
false
null
package dwt import com.marcinmoskala.math.combinations import utils.Rational import kotlin.math.max import kotlin.math.min class Dwt33 { fun main() { val nodes = setOf(1, 2, 3, 4) val edges = mutableSetOf<Pair<Int, Int>>() nodes.forEach { a -> nodes.forEach { b -> ...
0
Kotlin
0
0
02d951b90e0225bb1fa36f706b19deee827e0d89
1,815
math_playground
MIT License
src/Day04.kt
daividssilverio
572,944,347
false
{"Kotlin": 10575}
private fun extractRange(stringRange: String): IntRange = stringRange.split("-").let { it[0].toInt()..it[1].toInt() } private fun IntRange.contains(other: IntRange) = this.first <= other.first && other.last <= this.last private fun IntRange.overlap(other: IntRange) = this.first in other || this.last in other || ot...
0
Kotlin
0
0
141236c67fe03692785e0f3ab90248064a1693da
804
advent-of-code-kotlin-2022
Apache License 2.0
app/src/main/kotlin/day05/Point.kt
StylianosGakis
434,004,245
false
{"Kotlin": 56380}
package day05 import kotlin.math.abs import kotlin.math.min data class Point(val x: Int, val y: Int) { operator fun rangeTo(end: Point): List<Point> { return if (x == end.x) { val startingIndex = min(y, end.y) val length = abs(y - end.y) val endingIndex = startingIndex ...
0
Kotlin
0
0
a2dad83d8c17a2e75dcd00651c5c6ae6691e881e
1,468
advent-of-code-2021
Apache License 2.0
src/commonMain/kotlin/eu/yeger/cyk/model/CYKModel.kt
DerYeger
302,742,119
false
null
package eu.yeger.cyk.model public data class CYKModel internal constructor( val word: Word, val grammar: Grammar, val grid: List<List<Set<NonTerminalSymbol>>>, ) { internal constructor( word: Word, grammar: Grammar, ) : this( word, grammar, List(word.size) { ...
0
Kotlin
0
2
76b895e3e8ea6b696b3ad6595493fda9ee3da067
3,052
cyk-algorithm
MIT License
src/main/kotlin/net/varionic/mcbinpack/BinPacking.kt
patonw
213,552,659
false
null
package net.varionic.mcbinpack import io.vavr.collection.List sealed class Node object Empty : Node() data class Item(val width: Int, val height: Int) : Node() { /** * Transpose item */ fun t() = Item(height, width) } data class HSplit(val pos: Int, val top: Node, val bottom: Node) : Node() data ...
0
Kotlin
1
0
b0fbaa526881c7f651dc6edac21f65de50d45c0b
3,218
mcbinpack
MIT License
src/main/kotlin/algorithms/sorting/heap_sort/Heapsort.kt
AANikolaev
273,465,105
false
{"Java": 179737, "Kotlin": 13961}
package algorithms.sorting.heap_sort import algorithms.sorting.InplaceSort import java.util.* class Heapsort : InplaceSort { override fun sort(values: IntArray) { heapsort(values) } private fun heapsort(ar: IntArray?) { if (ar == null) return val n = ar.size // Heapify, ...
0
Java
0
0
f9f0a14a5c450bd9efb712b28c95df9a0d7d589b
1,471
Algorithms
MIT License
app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt
nekomangaorg
182,704,531
false
{"Kotlin": 3454839}
package eu.kanade.tachiyomi.util import kotlin.math.floor import org.nekomanga.domain.chapter.ChapterItem data class MissingChapterHolder( val count: String? = null, val estimatedChapters: String? = null, ) fun List<ChapterItem>.getMissingChapters(): MissingChapterHolder { var count = 0 val estimateC...
85
Kotlin
111
1,985
4dc7daf0334499ca72c7f5cbc7833f38a9dfa2c3
2,683
Neko
Apache License 2.0
src/main/java/com/luckystar/advent2020/Advent4.kt
alexeymatveevp
48,393,486
false
{"Java": 199293, "Kotlin": 8971}
package com.luckystar.advent2020 fun main() { val file = object {}.javaClass.getResource("/2020/input_4.txt").readText() val passports = file.split("\r\n\r\n") val data = passports.map { p -> val split = p .split("\r\n") .reduce { acc, s -> "$acc $s" } ...
0
Java
0
1
d140ee8328003e79fbd2e0997cc7a8adf0e59ab2
2,872
adventofcode
Apache License 2.0
js/js.translator/testData/webDemoExamples/maze.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
// MAIN_ARGS: [] /** * Let's Walk Through a Maze. * * Imagine there is a maze whose walls are the big 'O' letters. * Now, I stand where a big 'I' stands and some cool prize lies * somewhere marked with a '$' sign. Like this: * * OOOOOOOOOOOOOOOOO * O O * O$ O O * OOOOO ...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
5,454
kotlin
Apache License 2.0
aoc21/day_20/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File data class Pixel(val r: Int, val c: Int) fun area(rows: IntRange, cols: IntRange): List<Pixel> = rows.flatMap { r -> cols.map { c -> Pixel(r, c) } } class Picture(var pixels: Set<Pixel>) { var min = Pixel(-1, -1) var max = Pixel( pixels.map { it.r }.maxOrNull()!! + 1, ...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,467
advent-of-code
MIT License
src/main/kotlin/com/adventofcode/Day.kt
reactivedevelopment
574,006,668
false
{"Kotlin": 2241, "Dockerfile": 379}
package com.adventofcode import com.adventofcode.Day.process import com.adventofcode.Day.solution import java.util.* object Day { private var script = false private val scheme = mutableListOf<String>() private val stackedColumns = mutableListOf<LinkedList<Char>>() fun process(line: String) { if (script)...
0
Kotlin
0
0
f9f78bc2fab16660c5e3602e09bc43b6da029e4f
1,754
aoc-2022-5
MIT License
day3/src/main/kotlin/aoc2015/day3/Day3.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.day3 /** * [https://adventofcode.com/2015/day/3] */ object Day3 { fun countHouses(): Int { val houses = HouseMap() val santa = Santa() input.forEach { direction -> santa.move(direction) houses.visitHouse(santa.position) } return h...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
1,896
aoc2015
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day25.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 25: Full of Hot Air * Problem Description: https://adventofcode.com/2022/day/26 */ package de.niemeyer.aoc2022 import de.niemeyer.aoc.utils.Resources.resourceAsList import de.niemeyer.aoc.utils.getClassName fun main() { fun Char.toSnafuDigit(): Int = when { t...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
1,171
AoC-2022
Apache License 2.0
src/main/java/dev/haenara/mailprogramming/solution/y2019/m12/d08/UseCase191208.kt
HaenaraShin
226,032,186
false
null
package dev.haenara.mailprogramming.solution.y2019.m12.d08 import Solution191208 import dev.haenara.mailprogramming.solution.UseCase class UseCase191208(args: Array<String>) : UseCase<Long, Long>(args) { override val solution = Solution191208() override val sampleInput = 12L override val description = " *...
0
Kotlin
0
7
b5e50907b8a7af5db2055a99461bff9cc0268293
1,438
MailProgramming
MIT License
src/main/kotlin/days/aoc2021/Day19.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.ndarray import org.jetbrains.kotlinx.multik.ndarray.data.* import org.jetbrains.kotlinx.multik.ndarray.operations.map import org.jetbrains.kotlinx.multik.ndarray.operations.minus import org.jetbrains...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
6,823
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day08.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
fun main() { class Calculator1(private val input: List<String>) { private val rows = input.size private val cols = input[0].length private val lefts: MutableList<Char?> = MutableList(rows) { null } private val rights: MutableList<Char?> = MutableList(rows) { null } private va...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
4,370
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day25.kt
dlew
75,886,947
false
null
import java.util.* class Day25 { sealed class Instruction { class CopyNum(val num: Int, val to: Char) : Instruction() class CopyRegister(val from: Char, val to: Char) : Instruction() class CopyInvalid(val num: Int, val invalid: Int) : Instruction() class CopyInvalid2(val invalid1: Char, val inval...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
7,518
aoc-2016
MIT License
kotlin/aoc2018/src/main/kotlin/Day12.kt
aochsner
160,386,044
false
null
import java.io.File class Day12 { fun part1(lines: List<String>): Int { val puzzle = Puzzle(lines) val pots = puzzle.generate(20) return pots.asSequence().mapIndexed { index, char -> if (char == '#') index-(4*20) else 0 }.sum()...
0
Kotlin
0
1
7c42ec9c20147c4be056d03e5a1492c137e63615
1,444
adventofcode2018
MIT License
leetcode2/src/leetcode/SearchInsertPosition.kt
hewking
68,515,222
false
null
package leetcode /**35.搜索插入位置 * https://leetcode-cn.com/problems/search-insert-position/ * Created by test * Date 2019/5/20 23:41 * Description * 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 示例 1: 输入: [1,3,5,6], 5 输出: 2 示例 2: 输入: [1,3,5,6], 2 输出: 1 示例 3: 输入: [1,3,5,6], 7 输出: 4 ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,535
leetcode
MIT License
src/main/kotlin/org/kalasim/misc/Histogram.kt
holgerbrandl
299,282,108
false
{"Kotlin": 3670626, "HTML": 818831, "Java": 56143, "R": 12761}
package org.kalasim.misc import org.apache.commons.math3.random.EmpiricalDistribution import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics import kotlin.math.roundToInt // Extensions to build histograms data class HistogramBin(val lowerBound: Double, val upperBound: Double, val value: Long) class ...
6
Kotlin
10
65
692f30b5154370702e621cfb9e7b5caa2c84b14a
2,058
kalasim
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day18.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 18 - Lavaduct Lagoon * Problem Description: http://adventofcode.com/2023/day/18 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day18/ */ package com.ginsberg.advent2023 import com.ginsberg.advent2023.Point2D.Companio...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
1,998
advent-2023-kotlin
Apache License 2.0
2021/src/main/kotlin/de/skyrising/aoc2021/day25/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day25 import de.skyrising.aoc.* import it.unimi.dsi.fastutil.objects.Object2CharMap import it.unimi.dsi.fastutil.objects.Object2CharOpenHashMap val test = TestInput(""" v...>>.vv> .vv>>.vv.. >>.>v>...v >>v>>.>.v. v>v.vv.v.. >.>>..v... .vv..>.>v. v.v..>>v.v ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,106
aoc
MIT License
day6/src/test/kotlin/be/swsb/aoc2020/Day6Test.kt
Sch3lp
318,098,967
false
null
package be.swsb.aoc2020 import be.swsb.aoc.common.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance @TestInstance(TestInstance.Lifecycle.PER_CLASS) class Day6Test { @Nested inner class Exercise1 ...
0
Kotlin
0
0
32630a7efa7893b4540fd91d52c2ff3588174c96
3,371
Advent-of-Code-2020
MIT License
src/main/kotlin/no/mortenaa/exercises/part1/01_Functions.kt
elisabethmarie
188,365,697
false
null
package no.mortenaa.exercises.part1 /** * * Kotlin Workshop Exercises Part 1 * */ /** * 1. Hello World. * * Make the function [helloWorld] return the [String] "Hello World!" */ fun helloWorld(): String { return "Hello World!" } /** * 2. Assignment. * * Assign a value to [a] such that the function ret...
1
Kotlin
0
0
67b1e6c8fc8e22cf5789165ae0007f4976fcc2eb
2,388
kotlin-workshop
MIT License
src/main/kotlin/tr/emreone/adventofcode/days/Day10.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import java.util.* class Day10 : Day(10, 2021, "Syntax Scoring") { private fun isStringCorrupted(input: String): Boolean { val stack = Stack<Char>() for (currentChar in input) { if (currentChar in arra...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
3,562
advent-of-code-2021
Apache License 2.0
app/src/main/java/com/tripletres/platformscience/domain/algorithm/AntColonyOptimizationAlgorithm.kt
daniel553
540,959,283
false
{"Kotlin": 95616}
package com.tripletres.platformscience.domain.algorithm import com.tripletres.platformscience.domain.ShipmentDriverAssignation.SuitabilityScore import com.tripletres.platformscience.domain.model.Driver /** * Ant colony optimization algorithm: AI meta heuristic for assignation problem: * * Algorithm: * 1. Repeat u...
0
Kotlin
0
0
2ea5962dc0ad349ae97b277ab4ecf9e9a0aee1e6
5,957
PlatformScience
FSF All Permissive License
src/main/kotlin/Day01.kt
alex859
573,174,372
false
{"Kotlin": 80552}
fun main() { val testInput = readInput("Day01_test.txt") check(testInput.maxTotalCalories() == 24000) check(testInput.topThreeTotalCalories() == 45000) val input = readInput("Day01.txt") println(input.maxTotalCalories()) println(input.topThreeTotalCalories()) } fun String.maxTotalCalories(): I...
0
Kotlin
0
0
fbbd1543b5c5d57885e620ede296b9103477f61d
642
advent-of-code-kotlin-2022
Apache License 2.0
src/8ExponentialTimeAlgorithms/MapColouring.kt
bejohi
136,087,641
false
{"Java": 63408, "Kotlin": 5933, "C++": 5711, "Python": 3670}
import java.util.* val resultList = mutableListOf<String>() var done = false // Solution for https://open.kattis.com/problems/mapcolouring // With help from https://github.com/amartop fun main(args: Array<String>){ val input = Scanner(System.`in`) val numberOfTestCases = input.nextInt() for(testCase in...
0
Java
0
0
7e346636786215dee4c681b80bc694c8e016e762
1,930
UiB_INF237
MIT License
src/main/kotlin/org/domnikl/algorithms/sorting/RadixSort.kt
domnikl
231,452,742
false
null
package org.domnikl.algorithms.sorting import kotlin.math.ceil import kotlin.math.log10 import kotlin.math.pow fun IntArray.radixSort(): IntArray { if (this.isEmpty()) return this require(this.min()!! >= 0) { "number smaller zero not allowed" } val base = ceil(log10(this.max()!!.toDouble())).toInt() ...
5
Kotlin
3
13
3b2c191876e58415d8221e511e6151a8747d15dc
883
algorithms-and-data-structures
Apache License 2.0
2021/src/main/kotlin/Day02.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day02(input: List<String>) { private val commands = input.map { Command.of(it) } fun solve1(): Int { var (depth1, horizontal) = arrayOf(0, 0) commands.forEach { when (it.name) { "forward" -> horizontal += it.amount "down" -> depth1 += it.amount...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
1,080
adventofcode-2021-2025
MIT License
src/Day08.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { fun part1(input: List<String>): Int { val matrix = input.map { it.toList() } return matrix.count { row, col -> matrix.visible(row, col) } } fun part2(input: List<String>): Int { val matrix = input.map { it.toList() } return matrix.maxOf { row, col -> matrix.sco...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
2,615
aoc-2022
Apache License 2.0
src/challenges/Day01.kt
paralleldynamic
572,256,326
false
{"Kotlin": 15982}
package challenges import utils.splitInput fun main() { fun countElfInventory(input: List<String>): List<Int> = input .map{ elf -> elf.trim().split("\n") } .map{ bundle -> bundle.map{ s -> s.toInt() } } .map{ bundle -> bundle.sum() } fun part1(elves: List<Int>): Int = elve...
0
Kotlin
0
0
ad32a9609b5ce51ac28225507f77618482710424
770
advent-of-code-kotlin-2022
Apache License 2.0
aoc-day6/src/Day6.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.nio.file.Files import java.nio.file.Path object Day6 { const val PART_1_MAX = 8 const val PART_1_RESET = 6 const val PART_1_DAYS = 80 const val PART_2_DAYS = 256 } fun main() { val path = Path.of("input") val ages = Files.readAllLines(path) .first() .split(",") ...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
1,217
adventofcode2021
MIT License
src/Day11.kt
TinusHeystek
574,474,118
false
{"Kotlin": 53071}
class Day11 : Day(11) { class Monkey(input: String) { var items = mutableListOf<Long>() var divisibleBy = 0 var divisibleTrueToMonkey = 0 var divisibleFalseToMonkey = 0 var numberOfItemsThrown : Int = 0 init { val lines = input.lines() items...
0
Kotlin
0
0
80b9ea6b25869a8267432c3a6f794fcaed2cf28b
3,889
aoc-2022-in-kotlin
Apache License 2.0
solutions/aockt/y2023/Y2023D14.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2023 import aockt.util.parse import aockt.util.spacial.Direction import aockt.util.spacial.Point import io.github.jadarma.aockt.core.Solution // TODO: Could use some more code cleanup. object Y2023D14 : Solution { /** The type of rock you can encounter on the dish. */ private enum class Rock {...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
5,598
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/days/Day12.kt
TheMrMilchmann
571,779,671
false
{"Kotlin": 56525}
/* * Copyright (c) 2022 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
2e01ab62e44d965a626198127699720563ed934b
3,054
AdventOfCode2022
MIT License
src/Day09_part1.kt
arisaksen
573,116,584
false
{"Kotlin": 42887}
import org.assertj.core.api.Assertions.assertThat fun main() { val startPos = 400 // val startPos = 1 open class Head( val signature: Char = 'H', var positionX: Int = startPos, var positionY: Int = startPos, var prevPositionX: Int = startPos, var prevPositionY: Int =...
0
Kotlin
0
0
85da7e06b3355f2aa92847280c6cb334578c2463
4,224
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/com/headlessideas/adventofcode/december13/PacketScanner.kt
Nandi
113,094,752
false
null
package com.headlessideas.adventofcode.december13 import com.headlessideas.adventofcode.utils.readFile fun crossFirewall(firewalls: Array<Firewall?>, delay: Int = 0): Pair<Int, Boolean> { var pos = -1 - delay var severity = 0 var detected = false while (pos < firewalls.lastIndex) { pos++ ...
0
Kotlin
0
0
2d8f72b785cf53ff374e9322a84c001e525b9ee6
1,851
adventofcode-2017
MIT License
src/main/kotlin/Day13.kt
chjaeggi
728,738,815
false
{"Kotlin": 87254}
import utils.Stack import utils.execFileByLineIndexed import utils.numberOfLinesPerFile import utils.stackOf class Day13 { fun solveFirst(): Int { // could have used kotlin.collections.ArrayDeque instead of my own Stack implementation :/ // with: // Stack.push = addLast() // Stack....
0
Kotlin
1
1
a6522b7b8dc55bfc03d8105086facde1e338086a
5,441
aoc2023
Apache License 2.0
2020/Day8/src/main/kotlin/main.kt
airstandley
225,475,112
false
{"Python": 104962, "Kotlin": 59337}
import java.io.File fun getInput(): List<String> { return File("Input").readLines() } data class Command(val name: String, val function: (Int) -> Unit, val value: Int) fun parseCommand(input:String): Command { val parts = input.split(" ") val command = parts[0] val sign = parts[1].drop(1) val val...
0
Python
0
0
86b7e289d67ba3ea31a78f4a4005253098f47254
3,214
AdventofCode
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day25.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 25 - Snowverload * Problem Description: http://adventofcode.com/2023/day/25 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day25/ */ package com.ginsberg.advent2023 class Day25(private val input: List<String>) { ...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
2,134
advent-2023-kotlin
Apache License 2.0