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
2020/src/year2021/day07/code.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2021.day07 import util.readAllLines import kotlin.math.abs import kotlin.math.min fun main() { run(false) run(true) } private fun run(incrementCost: Boolean) { val input = readAllLines("input.txt").first().split(",").map { it.toInt() }.sorted() var result = Int.MAX_VALUE (input.first(...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
1,084
adventofcode
MIT License
src/main/kotlin/days/Day3.kt
MisterJack49
574,081,723
false
{"Kotlin": 35586}
package days class Day3 : Day(3) { override fun partOne(): Any { return inputList.map { it.take(it.length / 2) to it.takeLast(it.length / 2) } .map { groups -> groups.first[groups.first.indexOfAny(groups.second.toCharArray())] } .sumOf { Alphabet.valueOf(it.toString()).ordinal + 1 ...
0
Kotlin
0
0
e82699a06156e560bded5465dc39596de67ea007
980
AoC-2022
Creative Commons Zero v1.0 Universal
2022/05 - Supply Stacks/src/Main.kt
jamesrweb
318,272,685
false
{"Rust": 53359, "Python": 47359, "Elm": 45736, "PHP": 29791, "C#": 23894, "TypeScript": 22904, "JavaScript": 12689, "F#": 6885, "C": 4658, "Haskell": 4028, "Ruby": 3540, "Kotlin": 3305, "EJS": 574, "HTML": 363}
import java.io.File import java.util.* data class Crate constructor(val value: String) data class Stacks constructor(val list: HashMap<Int, MutableList<Crate>>) { fun viewResult(): String { return this.list.tops().joinToString("") } companion object Static { fun fromCrates(crates: String):...
0
Rust
0
0
1180a7f55b2f46dba4e5d17b4b67229dfc9ed655
3,305
advent-of-code
MIT License
src/Day11.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
fun main() { class Monkey (startingItems: MutableList<Long>, operation: String, testDivisor: Int, testTruth: Int, testFalse: Int) { val operation = operation var items = startingItems val testDivisor = testDivisor val testTrueMonkeyNumber = testTruth val testFalseMonkeyNumbe...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
5,581
aoc-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SpecialPositionsInBinaryMatrix.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
3,143
kotlab
Apache License 2.0
102_-_Ecological_Bin_Packing/src/Packing.kt
JeanCarlosSC
274,552,136
false
null
import java.util.Scanner fun main() { val frame = Window() } fun calculate(num1: Int, num2: Int, num3: Int, num4: Int, num5: Int, num6: Int, num7: Int, num8: Int, num9: Int): String{ val packing1 = Packing(num1, num2, num3) val packing2 = Packing(num4, num5, num6) val packing3 = Packing(num7, num8, n...
0
Kotlin
0
0
82f43d45aa5c5bf570691f9c811a286e27b39a0e
2,632
problem-set-volume1
Apache License 2.0
src/main/kotlin/algorithms/GreedyMotifSearch.kt
jimandreas
377,843,697
false
null
@file:Suppress("UnnecessaryVariable", "unused", "KotlinConstantConditions") package algorithms /** Code Challenge: Implement GreedyMotifSearch. Input: Integers k and t, followed by a space-separated collection of strings Dna. Output: A collection of strings BestMotifs resulting from applying GreedyMotifSearch(Dna, k...
0
Kotlin
0
0
fa92b10ceca125dbe47e8961fa50242d33b2bb34
4,720
stepikBioinformaticsCourse
Apache License 2.0
kotlin/src/main/kotlin/dev/mikeburgess/euler/sequences/PrimeSequence.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.sequences import dev.mikeburgess.euler.common.isEven import kotlin.math.sqrt @OEIS("A000040") class PrimeSequence : Sequence<Long> { override fun iterator(): Iterator<Long> = object : Iterator<Long> { private var index = 0 override fun hasNext() = true ove...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
1,206
project-euler
MIT License
src/Day01.kt
alexdesi
575,352,526
false
{"Kotlin": 9824}
import java.io.File fun main() { fun sortedCalories(input: List<String>): List<Int> { val elvesCalories = mutableListOf( mutableListOf<Int>() ) input.forEach { if (it == "") elvesCalories.add(mutableListOf()) else elvesCal...
0
Kotlin
0
0
56a6345e0e005da09cb5e2c7f67c49f1379c720d
930
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2015/Day15.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2015 import me.grison.aoc.* // not parsing the input class Day15 : Day(15, 2015) { override fun title() = "Science for Hungry People" private val attributes = mutableMapOf("Sugar" to Attributes(3, 0, 0, -3, 2), "Sprinkles" to Attributes(-3, 3, 0, 0, 9), "Candy" ...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
2,168
advent-of-code
Creative Commons Zero v1.0 Universal
implementation/src/main/kotlin/io/github/tomplum/aoc/map/hill/HillHeightMap.kt
TomPlum
572,260,182
false
{"Kotlin": 224955}
package io.github.tomplum.aoc.map.hill import io.github.tomplum.libs.math.map.AdventMap2D import io.github.tomplum.libs.math.point.Point2D import java.util.PriorityQueue /** * The heightmap shows the local area from above broken into a grid; * the elevation of each square of the grid is given by a single lowercase ...
0
Kotlin
0
0
703db17fe02a24d809cc50f23a542d9a74f855fb
4,419
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g0801_0900/s0857_minimum_cost_to_hire_k_workers/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0857_minimum_cost_to_hire_k_workers // #Hard #Array #Sorting #Greedy #Heap_Priority_Queue // #2023_03_31_Time_302_ms_(100.00%)_Space_39.4_MB_(100.00%) import java.util.PriorityQueue class Solution { fun mincostToHireWorkers(quality: IntArray, wage: IntArray, k: Int): Double { val n = ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,275
LeetCode-in-Kotlin
MIT License
semestr.06/ТРСиПВ/bellman/src/main/kotlin/bellman/graph/util.kt
justnero
43,222,066
false
null
package bellman.graph val INFINITE = Int.MAX_VALUE val NO_EDGE = INFINITE typealias AdjacencyMatrix = Array<IntArray> typealias AdjacencyMatrix1D = IntArray typealias AdjacencyList = Array<Adjacency> typealias PlainAdjacencyList = IntArray typealias Adjacency = Triple<Int, Int, Int> data class InputGraph(val adjace...
0
Java
6
16
14f58f135e57475b98826c4128b2b880b6a2cb9a
1,991
university
MIT License
Problem Solving/Algorithms/Medium - The Time in Words.kt
MechaArms
525,331,223
false
{"Kotlin": 30017}
/* Given the time in numerals we may convert it into words, as shown below: 5:00 -> five o' clock 5:01 -> one minute past five 5:10 -> ten minutes past five 5:15 -> quarter past five 5:30 -> half past five 5:40 -> twenty minutes to six 5:45 -> quarter to six 5:47 -> thirteen minutes to six 5:28 -> twenty eight minutes...
0
Kotlin
0
1
eda7f92fca21518f6ee57413138a0dadf023f596
2,142
My-HackerRank-Solutions
MIT License
src/day03/Day03.kt
tiginamaria
573,173,440
false
{"Kotlin": 7901}
package day03 import readInput private fun priority(c: Char): Int { if (c.isLowerCase()) return c - 'a' + 1 return c - 'A' + 27 } fun main() { fun part1(input: List<String>) = input.sumOf { val n = it.length / 2 val firstComp = it.take(n).toSet() val lastComp = it.takeLast(n).toSe...
0
Kotlin
0
0
bf81cc9fbe11dce4cefcb80284e3b19c4be9640e
704
advent-of-code-kotlin
Apache License 2.0
src/Day06.kt
ktrom
573,216,321
false
{"Kotlin": 19490, "Rich Text Format": 2301}
fun main() { fun part1(input: List<String>): Int { return getStartWithDistinctMarker(input.get(0), 4) } fun part2(input: List<String>): Int { return getStartWithDistinctMarker(input.get(0), 14) } // test if implementation meets criteria from the description val testInput = read...
0
Kotlin
0
0
6940ff5a3a04a29cfa927d0bbc093cd5df15cbcd
941
kotlin-advent-of-code
Apache License 2.0
src/main/kotlin/days/aoc2023/Day6.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2023 import days.Day class Day6 : Day(2023, 6) { override fun partOne(): Any { return calculatePartOne(inputList) } fun calculatePartOne(inputList: List<String>): Int { val timesAndDistances = inputList[0].split("\\s+".toRegex()).drop(1).map { it.toInt() }.zip(...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
1,180
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/SplitArraySameAverage.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,408
kotlab
Apache License 2.0
src/main/kotlin/leetCode/40.kt
wenvelope
692,706,194
false
{"Kotlin": 11474, "Java": 7490}
package leetCode fun main() { val candidates = intArrayOf( 10, 1, 2, 7, 6, 1, 5 ) val result = combinationSum2(candidates, 8) println(result.toString()) } fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> { val resultList = arrayListOf<ArrayList<Int>>() val tempLis...
0
Kotlin
0
1
4a5b2581116944c5bf8cf5ab0ed0af410669b9b6
1,450
OnlineJudge
Apache License 2.0
src/main/kotlin/days/Day4.kt
felix-ebert
317,592,241
false
null
package days class Day4 : Day(4) { override fun partOne(): Any { val passwords = inputString.split("\n\n") return passwords.count { validatePolicyOne(it) } } override fun partTwo(): Any { val passwords = inputString.split("\n\n") return passwords.count { validatePolicyTwo(...
0
Kotlin
0
4
dba66bc2aba639bdc34463ec4e3ad5d301266cb1
2,056
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/Day02_part2.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part2(input: List<String>): Int { val rock = 1 val paper = 2 val scissors = 3 val lose = 0 val draw = 3 val win = 6 fun convertLeft(input: Char): Int { return when (input) { 'A' -> rock 'B' -> paper ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
1,310
advent-of-code-2022
Apache License 2.0
src/Day19.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
import kotlin.math.ceil import kotlin.math.min fun main() { data class Blueprint( val id: Int, val oreRobotCost: Int, val clayRobotCost: Int, val obsidianRobotCost: Pair<Int, Int>, val geodeRobotCost: Pair<Int, Int> ) data class Resources( var ore: Int = 0, ...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
7,029
aoc-2022
Apache License 2.0
src/main/kotlin/year2023/day22/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2023.day22 import IProblem import kotlin.math.max class Problem : IProblem { private val blocks = mutableListOf<Pair<Triple<Int, Int, Int>, Triple<Int, Int, Int>>>() private val coords: Array<Array<IntArray>> private val support: Array<BooleanArray> private val depth: Int private val w...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
4,317
advent-of-code
The Unlicense
Practice/Algorithms/Strings/WeightedUniformStrings.kts
kukaro
352,032,273
false
null
import kotlin.collections.* import kotlin.io.* import kotlin.ranges.* import kotlin.text.* /* * Complete the 'weightedUniformStrings' function below. * * The function is expected to return a STRING_ARRAY. * The function accepts following parameters: * 1. STRING s * 2. INTEGER_ARRAY queries */ fun weightedUni...
0
Kotlin
0
0
4f04ff7b605536398aecc696f644f25ee6d56637
1,310
hacker-rank-solved
MIT License
src/Day03.kt
skarlman
572,692,411
false
{"Kotlin": 4076}
import java.io.File // Problem: // https://adventofcode.com/2022/day/3 // More solutions: // https://www.competitivecoders.com/ProgrammingCompetitions/advent-of-code/advent-of-code/2022/day-3/ fun main() { fun part1(input: List<String>): Int { return input.map { row -> val parts = row.chun...
0
Kotlin
0
0
ef15752cfa6878ce2740a86c48b47597b8d5cabc
1,155
AdventOfCode2022_kotlin
Apache License 2.0
codeforces/globalround16/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.globalround16 private fun solve() { val n = readInt() val nei = List(n) { mutableListOf<Int>() } repeat(n - 1) { val (v, u) = readInts().map { it - 1 } nei[v].add(u) nei[u].add(v) } val kids = IntArray(n) val isLeaf = BooleanArray(n) val isBud = BooleanArray(n) var ans = 0 fun dfs(v: ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
929
competitions
The Unlicense
src/main/kotlin/problems/Koko.kt
amartya-maveriq
510,824,460
false
{"Kotlin": 42296}
/** Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k banana...
0
Kotlin
0
0
2f12e7d7510516de9fbab866a59f7d00e603188b
1,891
data-structures
MIT License
src/main/day02/Part2.kt
ollehagner
572,141,655
false
{"Kotlin": 80353}
package day02 import readInput; import java.lang.IllegalArgumentException fun main() { val testinput = readInput("day02/testinput.txt") val input = readInput("day02/input.txt") val movesForResult = buildMap<Pair<Move, Result>, Move>() { put(Pair(Move.ROCK, Result.WIN), Move.PAPER) put(Pa...
0
Kotlin
0
0
6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1
1,558
aoc2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions68.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import com.qiaoyuang.algorithm.round0.BinaryTreeNode fun test68() { printlnResult('F', 'I') printlnResult('H', 'I') printlnResult('B', 'C') printlnResult('H', 'I') printlnResult('F', 'G') printlnResult('D', 'E') printlnResult('D', 'I') printlnResu...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,904
Algorithm
Apache License 2.0
src/main/kotlin/aoc2016/NoTimeForATaxicab.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2016 import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Point import kotlin.math.absoluteValue fun taxicab(s: String): Int { val directions = s.trim().split(", ").map { TaxicabStep.parse(it) } var point = Point.ORIGIN var dir = Direction.UP for ((turn...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,443
advent-of-code
MIT License
src/main/kotlin/Day01.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.* fun main () { val input = readFileAsList("Day01") println(Day01.part1(input)) println(Day01.part2(input)) } object Day01 { fun part1(input: List<String>): Int { var mostCalories = 0 var currentCalories = 0 for (line in input) { if (line.isBlank()...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
1,231
advent-of-code-2022
Apache License 2.0
app/src/main/java/online/vapcom/codewars/algorithms/PlantsAndZombies.kt
vapcomm
503,057,535
false
{"Kotlin": 142486}
package online.vapcom.codewars.algorithms /** * #28 Plants and Zombies - 3 kyu * * https://www.codewars.com/kata/5a5db0f580eba84589000979 * * @param zombies [i,row,hp] - where i is the move number (0-based) when it appears, * row is the row the zombie walks down, and hp is the initial health point value of the ...
0
Kotlin
0
0
97b50e8e25211f43ccd49bcee2395c4bc942a37a
13,182
codewars
MIT License
src/Day17.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { fun nonEmpty(line: CharArray): Boolean { for (i in 1..line.size - 2) { if (line[i] != '.') { return true } } return false } fun part1(input: String): Int { val shapes = arrayOf( arrayOf( "####"...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
3,012
aoc-2022-in-kotlin
Apache License 2.0
day06/src/Day06.kt
simonrules
491,302,880
false
{"Kotlin": 68645}
import java.io.File class Day06(path: String) { private val ages = mutableListOf<Int>() private val counts = LongArray(9) { 0L } init { val lines = File(path).readLines() val items = lines[0].split(',') items.forEach { ages.add(it.toInt()) counts[it.toInt()]...
0
Kotlin
0
0
d9e4ae66e546f174bcf66b8bf3e7145bfab2f498
1,379
aoc2021
Apache License 2.0
Day14/src/Stoichiometry.kt
gautemo
225,219,298
false
null
import java.io.File fun main(){ val input = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText().trim() val ore = oreForFuel(input) println(ore) val fuelForTrillion = fuelForOre(input, 1000000000000) println(fuelForTrillion) } fun fuelForOre(input: String,...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
2,208
AdventOfCode2019
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day16.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2016 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.e fun main() = Day16.run() object Day16 : Day(2016, 16) { override fun part1(): Any { val len = 272 val cs = checksum(dataOf(len)) return cs.joinToString("") } private fun dataOf(len: ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,568
adventofkotlin
MIT License
src/main/kotlin/com/colinodell/advent2016/Day21.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day21(private val operations: List<String>) { fun solvePart1(password: String) = operations.fold(password) { text, operation -> perform(operation, text) } fun solvePart2(password: String) = operations.reversed().fold(password) { text, operation -> perform(operation, tex...
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
3,119
advent-2016
Apache License 2.0
src/main/kotlin/Day20.kt
cbrentharris
712,962,396
false
{"Kotlin": 171464}
object Day20 { enum class ModuleType { BROADCASTER, CONJUNCTION, FLIP_FLOP } enum class PulseType { HIGH, LOW } data class Pulse(val type: PulseType, val sender: String) data class Module( val id: String, val type: ModuleType, va...
0
Kotlin
0
1
f689f8bbbf1a63fecf66e5e03b382becac5d0025
6,052
kotlin-kringle
Apache License 2.0
src/Day06.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
fun main() { fun getIndexOfGroup(input: String, groupSize: Int): Int { val buffer = HashSet<Char>() var result = -1 run breaking@{ (groupSize-1 until input.length).forEach { index -> buffer.clear() (index - groupSize + 1..index).forEach { buffer.ad...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
990
aoc-2022
Apache License 2.0
src/iii_conventions/MyDate.kt
robyp1
132,624,740
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 el...
0
Kotlin
0
0
c792e7a4bca6fcb796332c69b68653fce0037a66
1,714
kotlin-koans-resolutions
MIT License
ParallelProgramming/possible-executions-analysis/src/PossibleExecutionsVerifier.kt
ShuffleZZZ
128,576,289
false
null
import java.io.* import java.util.* const val SOLUTION_FILE_NAME = "solution.txt" val STATE_REGEX = Regex("\\[P([1-4]),Q([1-4]),([01]),([01])]") fun main() { val transitions = mutableSetOf<Transition>() File(SOLUTION_FILE_NAME).readLines().forEachIndexed { index, line -> val trim = line.substringBefor...
103
Jupyter Notebook
2
10
29db54d96afef0558550471c58f695c962e1f747
3,569
ITMO
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/OpenLock.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
2,656
kotlab
Apache License 2.0
app/src/main/kotlin/com/github/ilikeyourhat/kudoku/solving/deduction/algorithm/RegionIntersectionAlgorithm.kt
ILikeYourHat
139,063,649
false
{"Kotlin": 166134}
package com.github.ilikeyourhat.kudoku.solving.deduction.algorithm import com.github.ilikeyourhat.kudoku.model.Region import com.github.ilikeyourhat.kudoku.model.hint.SudokuHintGrid import com.github.ilikeyourhat.kudoku.solving.deduction.combinations.CollectionCombinator class RegionIntersectionAlgorithm( regions...
1
Kotlin
0
0
b234b2de2edb753844c88ea3cd573444675fc1cf
2,410
Kudoku
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/NQueens.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 51. N 皇后 * * n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。 * 给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。 * * 每一种解法包含一个明确的 n 皇后问题的棋子放置方案,该方案中 'Q' 和 '.' 分别代表了皇后和空位。 * * 示例: * * 输入:4 * 输出:[ * [".Q..", // 解法 1 * "...Q", * "Q...", * "..Q."], * * ["..Q.", // 解法 2 * "Q...",...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
3,046
daily_algorithm
Apache License 2.0
src/Day03.kt
Arclights
574,085,358
false
{"Kotlin": 11490}
fun main() { fun itemValue(item: Char): Int = when { item >= 'a' -> item.code - 96 else -> item.code - 38 } fun part1(input: List<String>) = input .map { line -> line.take(line.length / 2) to line.drop(line.length / 2) } .flatMap { (compartment1, compartment2) -> compartmen...
0
Kotlin
0
0
121a81ba82ba0d921bd1b689241ffa8727bc806e
871
advent_of_code_2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDiffInBST.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,369
kotlab
Apache License 2.0
app/src/main/kotlin/kotlinadventofcode/2023/2023-04.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
// Originally generated by the template in CodeDAO package kotlinadventofcode.`2023` import com.github.h0tk3y.betterParse.combinators.* import com.github.h0tk3y.betterParse.grammar.* import com.github.h0tk3y.betterParse.lexer.* import kotlinadventofcode.Day import kotlin.math.pow class `2023-04` : Day { override...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
26,446
kotlinadventofcode
MIT License
src/day10/MinimumTimeDiff.kt
minielectron
332,678,510
false
{"Java": 127791, "Kotlin": 48336}
package day10 import kotlin.math.abs /* Given an datastructure.array of time datastructure.strings times, return the smallest difference between any two times in minutes. Example: Input: ["00:03", "23:59", "12:03"] Output: 4 Input: The closest 2 times are "00:03" and "23:59" (by wrap-around), and they differ by 4 mi...
0
Java
0
0
f2aaff0a995071d6e188ee19f72b78d07688a672
1,177
data-structure-and-coding-problems
Apache License 2.0
src/main/kotlin/at2020/day1/At2020Day1Part2.kt
JeanBarbosa27
575,328,729
false
{"Kotlin": 10872}
package at2020.day1 class At2020Day1Part2 : At2020Day1() { override var entriesToReachTargetSum = IntArray(3) { 0 } override val puzzleDescription: String = "Day1 part 2 description:\n" + "Find the three entries that sum to 2020; what do you get if you multiply them together?\n" private fun ca...
0
Kotlin
0
0
62c4e514cd9a306e6a4b5dbd0c146213f08e05f3
3,561
advent-of-code-solving-kotlin
MIT License
src/main/kotlin/dp/MaxProd.kt
yx-z
106,589,674
false
null
package dp import util.* // similar to `MaxSum`, // given an array of numbers, // find the largest product in any contiguous subarray. // note that two negative numbers produce a positive result, ex. (-2) * (-4) = 8 fun main(args: Array<String>) { val arr = intArrayOf(-6, 12, -7, 0, 14, -7, 5) // println(arr.maxProd...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
5,326
AlgoKt
MIT License
src/main/kotlin/me/giacomozama/adventofcode2022/days/Day09.kt
giacomozama
572,965,253
false
{"Kotlin": 75671}
package me.giacomozama.adventofcode2022.days import java.io.File import kotlin.math.abs import kotlin.math.sign class Day09 : Day() { private lateinit var input: List<IntArray> override fun parseInput(inputFile: File) { input = inputFile.useLines { lines -> lines.map { in...
0
Kotlin
0
0
c30f4a37dc9911f3e42bbf5088fe246aabbee239
2,400
aoc2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestSubarray.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,346
kotlab
Apache License 2.0
2020/day4/day4.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 day4 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input is ...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
3,272
adventofcode
MIT License
leetcode2/src/leetcode/move-zeroes.kt
hewking
68,515,222
false
null
package leetcode /** * 283. 移动零 * https://leetcode-cn.com/problems/move-zeroes/ * @program: leetcode * @description: ${description} * @author: hewking * @create: 2019-10-22 11:46 *给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数组上操作,不能拷贝额外的数组。 尽量减少操作次数。 来源:力扣(L...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,335
leetcode
MIT License
src/main/kotlin/day1/solver.kt
derekaspaulding
317,756,568
false
null
package day1 import java.io.File import java.lang.IllegalArgumentException fun solveForTwoNums(nums: List<Int>, target: Int = 2020): Pair<Int, Int> { for ((index, num1) in nums.withIndex()) { if (index != nums.lastIndex) { for (num2 in nums.subList(index + 1, nums.size)) { if (...
0
Kotlin
0
0
0e26fdbb3415fac413ea833bc7579c09561b49e5
1,506
advent-of-code-2020
MIT License
src/main/kotlin/com/sk/topicWise/dp/53. Maximum Subarray.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.dp /** * At any index i there are 3 possibilities, * (1) Max sub-array is found before i.e. maxSoFar * (2) Max sub-array is running and also include this element i.e. maxEndingHere * (3) Max sub-array start here and may contain only this element */ // Top-down approach using memoization ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,157
leetcode-kotlin
Apache License 2.0
src/shreckye/coursera/algorithms/Course 1 Programming Assignment #3.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.io.File import kotlin.test.assertEquals val filename = args[0] val integers = File(filename).useLines { it.map(String::toInt).toIntArray(10_000) } fun quickSortAndCountNumComparisons( integers: IntArray, left: Int = 0, right: Int = integers.size, swapPivot...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
3,154
coursera-stanford-algorithms-solutions-kotlin
MIT License
multi-functions/src/main/kotlin/io/multifunctions/MultiMap.kt
stupacki
78,018,935
false
{"Kotlin": 108548}
package io.multifunctions import io.multifunctions.models.Hepta import io.multifunctions.models.Hexa import io.multifunctions.models.Penta import io.multifunctions.models.Quad /** * Returns a list containing the results of applying the given [transform] function * to each element in the original collection. */ pub...
0
Kotlin
3
25
5e82fd8e0dd745b379c7f4d8c475a66467b71ae9
2,356
MultiFunctions
Apache License 2.0
src/main/kotlin/aoc2021/day2.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.loadInput fun main() { val pattern = Regex("""(\w+) (\d+)""") val coms = loadInput("/2021/day2") .bufferedReader() .readLines() .map { val (dir, units) = pattern.find(it)!!.destructured Pair(dir, units.toInt()) } ...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
1,313
aoc-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch4/Problem48.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch4 import java.math.BigInteger /** * Problem 48: Self Powers * * https://projecteuler.net/problem=48 * * Goal: Find the last 10 digits of the number generated by the series, * 1^1 + 2^2 + 3^3 + .. + N^N, without leading zeroes. * * Constraints: 1 <= N <= 2e6 * * e.g.: N = 10 * ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
1,744
project-euler-kotlin
MIT License
src/main/kotlin/g0601_0700/s0637_average_of_levels_in_binary_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0637_average_of_levels_in_binary_tree // #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree // #2023_02_10_Time_249_ms_(100.00%)_Space_39.5_MB_(72.73%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a binary tree no...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,209
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g2401_2500/s2477_minimum_fuel_cost_to_report_to_the_capital/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2477_minimum_fuel_cost_to_report_to_the_capital // #Medium #Depth_First_Search #Breadth_First_Search #Tree #Graph // #2023_07_05_Time_969_ms_(100.00%)_Space_106_MB_(100.00%) class Solution { private var ans = 0L fun minimumFuelCost(roads: Array<IntArray>, seats: Int): Long { val ad...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,021
LeetCode-in-Kotlin
MIT License
src/main/java/challenges/educative_grokking_coding_interview/sliding_window/_7/CharacterReplacement.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.sliding_window._7 /** * Given a string with lowercase letters only, if you are allowed to replace no more than k letters with * any letter, find the length of the longest substring having the same letters after replacement. * * https://www.educative.io/courses...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,190
CodingChallenges
Apache License 2.0
src/commonMain/kotlin/transform/Snub.kt
elizarov
337,522,862
false
null
package polyhedra.common.transform import polyhedra.common.poly.* import polyhedra.common.util.* import kotlin.math.* // a * x^2 + b * x + c = 0 private fun solve3(a: Double, b: Double, c: Double) = (-b + sqrt(sqr(b) - 4 * a * c)) / (2 * a) private fun snubComputeSA(ea: Double, da: Double, cr: Double): Double { ...
0
Kotlin
0
28
ac15c7fe326e472470562a42f9fd519b24dfb455
3,554
PolyhedraExplorer
Apache License 2.0
tree_data_structure/SymmetricBinaryTree/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Given a binary tree, check whether it is a mirror of itself * (ie, symmetric around its center). * <br/> * https://www.interviewbit.com/problems/symmetric-binary-tree/ */ fun isSymmetric(tree: TreeNode): Boolean = subSymmetry(tree.left, tree.right) fun subSymmetry(l: TreeNode?, r: TreeNode?): Boolean = (l =...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,322
codility
MIT License
LeetCode/Medium/merge-intervals/Solution.kt
GregoryHo
254,657,102
false
null
class Solution { fun merge(intervals: Array<IntArray>): Array<IntArray> { intervals.sortWith(Comparator<IntArray> { o1, o2 -> when { o1[0] < o2[0] -> -1 o1[0] == o2[0] -> 0 else -> 1 } }) var index = 0 val merged = mutableListOf<IntArray>() intervals.forEach {...
0
Kotlin
0
0
8f126ffdf75aa83a6d60689e0b6fcc966a173c70
962
coding-fun
MIT License
kotlin/app/bin/main/coverick/aoc/day12/hillClimbing.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day12 import java.util.PriorityQueue import readResourceFile val INPUT_FILE = "hillClimbing-input.txt" typealias Coordinate = Pair<Int,Int> data class Path(var current: Coordinate, val nodes:ArrayList<Coordinate>){} class Hill(val heightMap:List<CharArray>, val start: Char, val end:Char){ ...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
4,196
adventofcode2022
Apache License 2.0
src/y2021/d02/Day02.kt
AndreaHu3299
725,905,780
false
{"Kotlin": 31452}
package y2021.d02 import println import readInput fun main() { val classPath = "y2021/d02" fun part1(input: List<String>): Int { var x = 0 var depth = 0 input. map { it.split(" ") }. forEach { val (action, value) = it when (actio...
0
Kotlin
0
0
f883eb8f2f57f3f14b0d65dafffe4fb13a04db0e
1,641
aoc
Apache License 2.0
src/plain/LogisticRegression.kt
philips-software
98,185,601
false
null
package plain class LogisticRegression { fun hessian(matrix: MatrixType): MatrixType { return -0.25 * (matrix.transpose() * matrix) } fun choleskyDecomposition(matrix: MatrixType): LowerTriangularMatrix { val d = matrix.numberOfRows val a = Array(d, { row -> Array(d, { ...
0
Kotlin
2
0
3ae7aecd9383a9dd6a93666fb286b5480d5f6b67
4,031
Fresco-Logistic-Regression
MIT License
src/test/kotlin/org/jetbrains/research/ml/dataset/anonymizer/util/FileTestUtil.kt
JetBrains-Research
313,572,156
false
{"Kotlin": 49946, "Java": 6844}
package org.jetbrains.research.ml.dataset.anonymizer.util import java.io.File enum class Type { Input, Output } class TestFileFormat(private val prefix: String, private val extension: Extension, val type: Type) { data class TestFile(val file: File, val type: Type, val number: Number) fun check(file: Fil...
3
Kotlin
0
0
d738818867038cea70db998c138091fbaa14e875
2,346
dataset-anonymizer
Apache License 2.0
kotlin/2021/qualification-round/cheating-detection/src/main/kotlin/MaximumLikelyhoodEstimationSolution.kts
ShreckYe
345,946,821
false
null
import kotlin.math.exp import kotlin.math.ln fun main() { val t = readLine()!!.toInt() val p = readLine()!!.toInt() repeat(t, ::testCase) } val maxAlpha = 1 val minAlpha = 1e-2 fun testCase(ti: Int) { val results = List(100) { readLine()!!.map { when (it) { '1' -> ...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
4,890
google-code-jam
MIT License
src/Day11.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
import java.util.* private class Monkey( val operation: (Long) -> Long, val divisor: Long, val trueMonkey: Int, val falseMonkey: Int, vararg elements: Int ) { private val items = LinkedList(elements.map { it.toLong() }.toList()) var inspections = 0L fun test(x: Long) = x.mod(divisor) =...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
3,142
AOC2022
Apache License 2.0
src/Day01.kt
ig13
575,430,058
false
{"Kotlin": 1858}
import java.util.* /** * Day1 */ fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 val iter = input.iterator() while (iter.hasNext()) { val str = iter.next() if (str.isBlank()) { if (current > max) { ...
0
Kotlin
0
0
cbf618a43737228189629d2f00d67972393125fc
1,210
Advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2020/Day17.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.Point3D import com.chriswk.aoc.util.Point4D import com.chriswk.aoc.util.report class Day17: AdventDay(2020, 17) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day1...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,128
adventofcode
MIT License
src/ch6Arrays/6.2IncrementArbitraryPrecisionNumber.kt
codingstoic
138,465,452
false
{"Kotlin": 17019}
package ch6Arrays fun main(args: Array<String>) { println(addOne(mutableListOf(1, 2, 9))) // 111 // 11 //1010 println(variantSumTwoBinary("111", "11", ::sumTwoBinaryStringsBitwise)) } fun addOne(list: MutableList<Int>): MutableList<Int> { for (i in (list.size - 1).downTo(0)) { if ((...
0
Kotlin
0
2
fdec1aba315405e140f605aa00a9409746cb518a
2,689
elements-of-programming-interviews-solutions
MIT License
src/test/kotlin/dev/shtanko/algorithms/leetcode/NAryTreePreorderTraversalTest.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,375
kotlab
Apache License 2.0
src/commonMain/kotlin/org/mifek/wfc/utils/Formatters.kt
JakubMifek
326,496,922
false
null
package org.mifek.wfc.utils /** * Format waves * * @param waves * @return */ fun formatWaves(waves: Array<BooleanArray>): String { return " " + waves.indices.joinToString(" ") { idx -> val s = waves[idx].sumBy { when (it) { true -> 1 else -> 0 } ...
0
Kotlin
1
2
2e86233098bcf93ba506526e5ec8386da75eb2e5
2,212
WFC-Kotlin
MIT License
solutions/src/solutions/y21/day 3.kt
Kroppeb
225,582,260
false
null
@file:Suppress("PackageDirectoryMismatch", "UnusedImport") package solutions.y21.d3 import grid.Clock import helpers.Lines import helpers.e import helpers.getLines import helpers.transpose val xxxxx = Clock(6, 3); /* */ private fun part1(data: Data) { var transpose = data.e().transpose().map { it.map { i -> i ...
0
Kotlin
0
1
744b02b4acd5c6799654be998a98c9baeaa25a79
1,737
AdventOfCodeSolutions
MIT License
2020/Day13/src/main/kotlin/main.kt
airstandley
225,475,112
false
{"Python": 104962, "Kotlin": 59337}
import java.io.File fun getInput(filename: String): List<String> { return File(filename).readLines() } fun parseInput(input: List<String>): Pair<Int, List<Int?>> { assert(input.size == 2) val timestamp: Int = input[0].toInt() val busIds = mutableListOf<Int?>() val ids: List<String> = input[1].spli...
0
Python
0
0
86b7e289d67ba3ea31a78f4a4005253098f47254
5,577
AdventofCode
MIT License
modules/domain/src/main/kotlin/ru/astrainteractive/astrashop/domain/usecase/PriceCalculator.kt
Astra-Interactive
562,599,158
false
{"Kotlin": 93228}
package ru.astrainteractive.astrashop.domain.usecase import ru.astrainteractive.astrashop.api.model.ShopConfig import kotlin.math.sqrt object PriceCalculator { private fun sch(x: Double): Double { return 1 / kotlin.math.cosh(x) } /** * Calculated a median - threshold for item dynamic price ...
0
Kotlin
1
0
b73cddc06d6f1d6ca4eff26cd99ead1921b3ab08
2,623
AstraShop
MIT License
scripts/Day22.kts
matthewm101
573,325,687
false
{"Kotlin": 63435}
import java.io.File val raw = File("../inputs/22.txt").readLines() val blankLineIndex = raw.indexOf("") sealed class Inst { object Left: Inst() object Right: Inst() data class Move(val n: Int): Inst() } val instructions = raw[blankLineIndex+1].replace("L", " L ").replace("R", " R ").split(" ").map { w...
0
Kotlin
0
0
bbd3cf6868936a9ee03c6783d8b2d02a08fbce85
6,634
adventofcode2022
MIT License
y2021/src/main/kotlin/adventofcode/y2021/Day06.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution object Day06 : AdventSolution(2021, 6, "Lanternfish") { override fun solvePartOne(input: String) = solve(input, 80) override fun solvePartTwo(input: String) = solve(input, 256) private fun solve(input: String, days: Int): Long { val...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
841
advent-of-code
MIT License
src/com/crossbowffs/ccikotlin/chapter2/5-SumLists.kt
apsun
63,534,825
false
null
package com.crossbowffs.ccikotlin.chapter2 import com.crossbowffs.ccikotlin.utils.doAssert /** * Calculates the sum of a linked list of decimal digits. * The least significant digit comes first, i.e. 1->2->3 * is equal to 321. The result is returned in a new linked * list with the same format. If the result equal...
0
Kotlin
0
3
b72075c54277e8cefef4b491cee6383413cb28e0
3,450
CCIKotlin
MIT License
yandex/y2022/qual/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2022.qual import kotlin.random.Random fun main() { val (n, q) = readInts() val dsu = DisjointSetUnionRPS(n) val three = IntArray(n + 1) three[0] = 1 for (i in 1 until three.size) three[i] = (3 * three[i - 1].toModular()).x repeat(q) { val (uIn, vIn, resultIn) = readStrings() val u = uIn.toIn...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,345
competitions
The Unlicense
src/main/aoc2023/Day11.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2023 import AMap import Pos class Day11(input: List<String>) { private val universe = AMap.parse(input, listOf('.')) private fun expand(expansionFactor: Int): AMap { val expandedUniverse = AMap() var expandedX = 0 var expandedY = 0 val columnIsEmpty = universe.xRang...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
1,609
aoc
MIT License
src/main/kotlin/day3/Day3.kt
Mee42
433,459,856
false
{"Kotlin": 42703, "Java": 824}
package dev.mee42.day3 import dev.mee42.*; fun main() { val input = inputLines(day = 3, year = 2021,) fun findLevel(inverse: Boolean) = (0 until input[0].length).toList().foldr(input) { validNumbers, index -> val selection = (validNumbers.map { it[index] }.count { it == '1' } > (validNumbers.size - ...
0
Kotlin
0
0
db64748abc7ae6a92b4efa8ef864e9bb55a3b741
919
aoc-2021
MIT License
test/highlight/kotlin/Test.kt
HiPhish
661,447,423
false
{"Lua": 125127, "Scheme": 53074, "Janet": 5133, "SystemVerilog": 3912, "C#": 3595, "Rust": 3478, "Jsonnet": 2953, "TypeScript": 2768, "Shell": 2350, "Kotlin": 2276, "Vim Script": 2156, "Makefile": 2017, "Zig": 2017, "Go": 2012, "Fennel": 1912, "HCL": 1688, "JavaScript": 1650, "Java": 1576, "Elm": 1532, "Dart": 1437, "V...
// Define a simple class with a primary constructor class Person<T>(private val name: String, private val age: Int, private val t: T) { // Secondary constructor constructor(name: String) : this(name, 0) class Hello { class Goodbye { } } init { println("New person created wi...
9
Lua
24
328
ca8d5ee2b4ee1eec491040a7601d366ddc8a2e02
2,276
rainbow-delimiters.nvim
Apache License 2.0
src/main/kotlin/aoc2019/day04_secure_container/SecureContainer.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2019.day04_secure_container fun main() { util.solve(1716, ::partOne) util.solve(1163, ::partTwo) } internal fun Int.isValidPassword(): Boolean { if (this < 100_000 || this > 999_999) return false var next = mod(10) var n = div(10) var hasDouble = false for (i in 4 downTo 0) { ...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,466
aoc-2021
MIT License
src/main/kotlin/info/benjaminhill/fm/chopper/TimedEvent.kt
salamanders
469,162,795
false
{"Kotlin": 52730, "Shell": 1382}
package info.benjaminhill.fm.chopper import java.time.Duration import java.time.Instant /** * A timed event is a pair of "stuff (state) that happened at time (ts)" * The idea is to keep a collection (ArrayDeque?) of these to record when things first happened. */ data class InstantState<T>( val ts: Instant, ...
0
Kotlin
1
0
c19094a521cb7afb608e67d11657897dc74b79c4
2,170
nrsc5-chopper
MIT License
src/Day03.kt
timlam9
573,013,707
false
{"Kotlin": 9410}
fun main() { fun part1(input: List<String>): Int = input.fold(0) { sum: Int, rucksack: String -> sum + rucksack.getCommonItemPriority() } fun part2(input: List<String>): Int = input.chunked(3).fold(0) {sum: Int, group: List<String> -> sum + group.getGroupItemPriority() } val input...
0
Kotlin
0
0
1df3465966915590022981546659ee4f1cdeb33b
1,622
AdventOfCodeKotlin2022
Apache License 2.0
grind-75-kotlin/src/main/kotlin/ValidAnagram.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
/** * Given two strings s and t, return true if t is an anagram of s, and false otherwise. * * An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, * typically using all the original letters exactly once. * * * * Example 1: * * Input: s = "anagram", t = "nagaram" * ...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,184
grind-75
Apache License 2.0
src/Day01.kt
psy667
571,468,780
false
{"Kotlin": 23245}
fun main() { val id = "01" fun getElvesWeights(input: List<String>): List<Int> { return input .joinToString("\n") .split("\n\n") .map { it .split("\n") .map(String::toInt) .sum() } } fun part1(input...
0
Kotlin
0
0
73a795ed5e25bf99593c577cb77f3fcc31883d71
791
advent-of-code-2022
Apache License 2.0
leetcode2/src/leetcode/sum-of-two-integers.kt
hewking
68,515,222
false
null
package leetcode /** * 371. 两整数之和 * https://leetcode-cn.com/problems/sum-of-two-integers/ * Created by test * Date 2019/7/19 0:59 * Description * 不使用运算符 + 和 - ​​​​​​​,计算两整数 ​​​​​​​a 、b ​​​​​​​之和。 示例 1: 输入: a = 1, b = 2 输出: 3 示例 2: 输入: a = -2, b = 3 输出: 1 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/su...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,146
leetcode
MIT License
src/main/kotlin/space/d_lowl/kglsm/iterativeimprovement/strategy/IterativeImprovementStrategy.kt
d-lowl
300,622,439
false
null
package space.d_lowl.kglsm.iterativeimprovement.strategy import space.d_lowl.kglsm.general.memory.BasicSolution import space.d_lowl.kglsm.general.memory.Memory import space.d_lowl.kglsm.problem.CostFunction import space.d_lowl.kglsm.general.space.SearchSpace import space.d_lowl.kglsm.general.strategy.Strategy /** * ...
17
Kotlin
0
1
0886e814be75a77fa8f33faa867329aef19085a5
2,745
kGLSM
MIT License
backtracking/sudoku/kotlin/Sudoku.kt
ZoranPandovski
93,438,176
false
{"Jupyter Notebook": 21909905, "C++": 1692994, "Python": 1158220, "Java": 806066, "C": 560110, "JavaScript": 305918, "Go": 145277, "C#": 117882, "PHP": 85458, "Kotlin": 72238, "Rust": 53852, "Ruby": 43243, "MATLAB": 34672, "Swift": 31023, "Processing": 22089, "HTML": 18961, "Haskell": 14298, "Dart": 11842, "CSS": 10509...
/** * @author https://github.com/jeffament/ */ private const val EMPTY_CELL = 0 fun main(args: Array<String>) { val board = arrayOf( intArrayOf(8, 0, 0, 0, 0, 0, 0, 0, 0), intArrayOf(0, 0, 3, 6, 0, 0, 0, 0, 0), intArrayOf(0, 7, 0, 0, 9, 0, 2, 0, 0), ...
62
Jupyter Notebook
1,994
1,298
62a1a543b8f3e2ca1280bf50fc8a95896ef69d63
3,582
al-go-rithms
Creative Commons Zero v1.0 Universal
src/Day01.kt
dlfelps
576,047,868
false
{"Kotlin": 2821}
import java.io.File fun main() { fun parseInput(input: String) : List<Int> { fun getNext(rest: List<Int?>): Pair<Int,List<Int?>> { val next = rest.takeWhile {it != null} as List<Int> val temp = rest.dropWhile {it != null} val rest = if (temp.isEmpty()) { ...
0
Kotlin
0
0
3ebcc492735bf6b6e8b0ea085d071cf019001d79
1,102
aoc-2022
Apache License 2.0
src/pl/shockah/aoc/y2017/Day7.kt
Shockah
159,919,224
false
null
package pl.shockah.aoc.y2017 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import pl.shockah.aoc.AdventTask import java.util.* import java.util.regex.Pattern class Day7: AdventTask<List<Day7.Program>, String, Int>(2017, 7) { private val inputPattern: Pattern = Pattern.compile("(\\w+) \\((...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
3,338
Advent-of-Code
Apache License 2.0
app/src/main/kotlin/day06/Day06.kt
meli-w
433,710,859
false
{"Kotlin": 52501}
package day06 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 6 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay06Part1, ::solveDay06Part2) } fun solveDay06Part1(input: List<String>): Int = ...
0
Kotlin
0
1
f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1
1,604
AoC-2021
Apache License 2.0
src/test/kotlin/com/igorwojda/integer/fibonacci/basic/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.integer.fibonacci.basic // iterative solution private object Solution1 { private fun fibonacci(n: Int): Int { if (n < 2) { return n } var first = 0 var second = 1 var current = 0 (2..n).forEach { current = first + secon...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
1,141
kotlin-coding-challenges
MIT License
src/Day10.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
fun main() { fun part1(ops: List<String>): Int { var value = 1 var res = 0 var cycle = 0 for (s in ops) { ++cycle if (s.startsWith("noop")) { if ((cycle - 20) % 40 == 0) res += cycle * value } else { ...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
1,312
AOC-2022
Apache License 2.0