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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
solutions/src/solutions/y21/day 9.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch", "UnusedImport")
package solutions.y21.d9
/*
import grid.Clock
import helpers.*
import itertools.*
import kotlin.math.*
*/
import grid.Clock
import helpers.digits
import helpers.getLines
import helpers.map2
import helpers.transpose
val xxxxx = Clock(6, 3);
/*
*/
private... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 2,506 | AdventOfCodeSolutions | MIT License |
src/Day06.kt | Migge | 572,695,764 | false | {"Kotlin": 9496} | private fun part1(input: List<String>): Int = markerIndex(input.first(), 4)
private fun part2(input: List<String>): Int = markerIndex(input.first(), 14)
private fun markerIndex(input: String, length: Int) = input
.toList()
.windowed(length)
.map { it.distinct() }
.first { it.size == length }
.join... | 0 | Kotlin | 0 | 0 | c7ca68b2ec6b836e73464d7f5d115af3e6592a21 | 578 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day6/Day6Puzzle.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day6
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
abstract class Day6Puzzle(private val days: Int) : PuzzleSolver {
companion object {
private const val BABY_TIMER = 8
}
final override fun solve(inputLines: Sequence<Str... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 1,872 | AdventOfCode2021 | Apache License 2.0 |
src/_2015/Day05.kt | albertogarrido | 572,874,945 | false | {"Kotlin": 36434} | package _2015
import readInput
fun main() {
runTests()
runScenario(readInput("2015", "day05"))
}
private fun runScenario(input: List<String>) {
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>) =
input.filter {
it.vowelsCount() >= 3 && it.hasNiceLetters... | 0 | Kotlin | 0 | 0 | ef310c5375f67d66f4709b5ac410d3a6a4889ca6 | 2,093 | AdventOfCode.kt | Apache License 2.0 |
src/main/kotlin/g2901_3000/s2913_subarrays_distinct_element_sum_of_squares_i/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2901_3000.s2913_subarrays_distinct_element_sum_of_squares_i
// #Easy #Array #Hash_Table #2023_12_27_Time_184_ms_(95.74%)_Space_36.9_MB_(97.87%)
class Solution {
fun sumCounts(nums: List<Int>): Int {
val n = nums.size
if (n == 1) {
return 1
}
val numsArr = IntAr... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,141 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/AdjacencyMatrix.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.algorithms.graph
import java.util.*
fun main() {
val adjM = AdjacencyMatrix(7)
adjM.accept(Scanner(System.`in`))
adjM.display()
// adjM.dfsTrav(0)
// adjM.dfsSpanningTree(0)
// adjM.bfsSpanningTree(0)
// println("${adjM.dfsIsConnected(0)}")
println("${adjM.bi... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 5,266 | DS_Algo_Kotlin | MIT License |
src/main/kotlin/days/Day18.kt | poqueque | 430,806,840 | false | {"Kotlin": 101024} | package days
class Day18 : Day(18) {
fun add(s1: String, s2: String): String {
var s3 = "[$s1,$s2]"
var s4 = reduce1("[$s1,$s2]")
// println("Reduced -> $s4")
while (s4 != s3) {
s3 = s4
s4 = reduce1(s4)
// println("Reduced -> $s4")
}
... | 0 | Kotlin | 0 | 0 | 4fa363be46ca5cfcfb271a37564af15233f2a141 | 4,875 | adventofcode2021 | MIT License |
Algorithms/src/main/kotlin/MaxSubArray.kt | ILIYANGERMANOV | 557,496,216 | false | {"Kotlin": 74485} | /**
* # Maximum Subarray
* Problem:
* https://leetcode.com/problems/maximum-subarray/
*/
class MaxSubArray {
fun maxSubArray(nums: IntArray): Int {
val size = nums.size
if (size == 1) return nums[0]
var sum = nums.first()
var localMax = sum
for (i in 1 until size) {
... | 0 | Kotlin | 0 | 1 | 4abe4b50b61c9d5fed252c40d361238de74e6f48 | 1,662 | algorithms | MIT License |
src/main/kotlin/leetcode/kotlin/dp/5. Longest Palindromic Substring.kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.dp
// dp, bottom-up
// Time:O(n^2)
private fun longestPalindrome(str: String): String {
var table = Array<BooleanArray>(str.length) { BooleanArray(str.length) }
var max = 0
var start = 0 // beginning index of max palindrome
for (k in 1..str.length) { // size of palindrome
... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 1,047 | kotlinmaster | Apache License 2.0 |
src/Day01.kt | cjosan | 573,106,026 | false | {"Kotlin": 5721} | fun main() {
fun part1(input: String): Int {
return input
.split("\n\n")
.maxOf { elfCalories ->
elfCalories.lines().sumOf { it.toInt() }
}
}
fun part2(input: String): Int {
return input
.split("\n\n")
.map { elfCal... | 0 | Kotlin | 0 | 0 | a81f7fb9597361d45ff73ad2a705524cbc64008b | 758 | advent-of-code2022 | Apache License 2.0 |
src/Day06.kt | OskarWalczak | 573,349,185 | false | {"Kotlin": 22486} | import java.util.*
fun main() {
fun allElementsUnique(col: Collection<Char>): Boolean {
for(i in col.indices){
for(j in i+1 until col.size){
if(col.elementAt(i) == col.elementAt(j)){
return false
}
}
}
return true... | 0 | Kotlin | 0 | 0 | d34138860184b616771159984eb741dc37461705 | 1,490 | AoC2022 | Apache License 2.0 |
kmath-core/src/commonMain/kotlin/scientifik/kmath/histogram/PhantomHistogram.kt | Zelenyy | 164,850,230 | true | {"Kotlin": 84961} | package scientifik.kmath.histogram
import scientifik.kmath.linear.Vector
import scientifik.kmath.operations.Space
import scientifik.kmath.structures.NDStructure
import scientifik.kmath.structures.asSequence
data class BinTemplate<T : Comparable<T>>(val center: Vector<T, *>, val sizes: Point<T>) {
fun contains(vec... | 0 | Kotlin | 0 | 0 | 9808b2800cb2c44e50e039373e028767385bd87e | 2,129 | kmath | Apache License 2.0 |
src/main/kotlin/Day9.kt | maldoinc | 726,264,110 | false | {"Kotlin": 14472} | import kotlin.io.path.Path
import kotlin.io.path.readLines
fun findScorePart1(records: List<List<Int>>): Int =
records.foldRight(0) { ints, acc -> acc + ints.last() }
fun findScorePart2(records: List<List<Int>>): Int =
records.foldRight(0) { ints, acc -> ints.first() - acc }
fun main(args: Array<String>) {
... | 0 | Kotlin | 0 | 1 | 47a1ab8185eb6cf16bc012f20af28a4a3fef2f47 | 999 | advent-2023 | MIT License |
nebulosa-watney/src/main/kotlin/nebulosa/watney/plate/solving/math/Equations.kt | tiagohm | 568,578,345 | false | {"Kotlin": 2031289, "TypeScript": 322187, "HTML": 164617, "SCSS": 10191, "Python": 2817, "JavaScript": 1119} | package nebulosa.watney.plate.solving.math
/**
* Solving least squares, for solving the plate constants.
*/
@Suppress("LocalVariableName")
fun solveLeastSquares(equationsOfCondition: List<DoubleArray>): DoubleArray {
// See: https://phys.libretexts.org/Bookshelves/Astronomy__Cosmology/Book%3A_Celestial_Mechanics... | 0 | Kotlin | 0 | 1 | de96a26e1a79c5b6f604d9af85311223cc28f264 | 1,767 | nebulosa | MIT License |
src/main/kotlin/com/groundsfam/advent/y2020/d04/Day04.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2020.d04
import com.groundsfam.advent.DATAPATH
import kotlin.io.path.div
import kotlin.io.path.useLines
private fun parsePassports(input: Sequence<String>): List<Map<String, String>> {
val ret: MutableList<Map<String, String>> = mutableListOf()
var curr: MutableMap<String, Stri... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,624 | advent-of-code | MIT License |
src/Day01.kt | burtz | 573,411,717 | false | {"Kotlin": 10999} | fun main() {
fun part1(input: List<String>): Int {
var current = 0
var max = 0
input.forEach{
if(it.isNotEmpty()) current += it.toInt()
else
{
if(current > max) max = current
current = 0
}
}
re... | 0 | Kotlin | 0 | 0 | daac7f91e1069d1490e905ffe7b7f11b5935af06 | 1,110 | adventOfCode2022 | Apache License 2.0 |
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day08/Day08.kt | jackploeg | 736,755,380 | false | {"Kotlin": 318734} | package nl.jackploeg.aoc._2023.calendar.day08
import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory
import nl.jackploeg.aoc.utilities.leastCommonMultiple
import nl.jackploeg.aoc.utilities.readStringFile
import java.math.BigInteger
import javax.inject.Inject
class Day08 @Inject constructor(
private... | 0 | Kotlin | 0 | 0 | f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76 | 2,169 | advent-of-code | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem46/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem46
/**
* LeetCode page: [46. Permutations](https://leetcode.com/problems/permutations/);
*/
class Solution {
/* Complexity:
* Time O(N * N!) and Space O(N * N!) where N is the size of nums;
*/
fun permute(nums: IntArray): List<List<Int>> {
val permutes ... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,418 | hj-leetcode-kotlin | Apache License 2.0 |
aoc2022/aoc2022-kotlin/src/main/kotlin/de/havox_design/aoc2022/day03/ItemValue.kt | Gentleman1983 | 737,309,232 | false | {"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319} | package de.havox_design.aoc2022.day03
import java.util.*
enum class ItemValue(val lowerCaseValue: Int, val upperCaseValue: Int, val symbol: String) {
A(1, 27, "A"),
B(2, 28, "B"),
C(3, 29, "C"),
D(4, 30, "D"),
E(5, 31, "E"),
F(6, 32, "F"),
G(7, 33, "G"),
H(8, 34, "H"),
I(9, 35, "I"... | 4 | Kotlin | 0 | 1 | b94716fbc95f18e68774eb99069c0b703875615c | 1,521 | aoc2022 | Apache License 2.0 |
Day11/Day11part2.kt | knivey | 317,575,424 | false | {"Java": 19457, "C++": 6082, "Kotlin": 5478, "C": 4107, "PHP": 2198} |
import java.io.File
enum class Tile(val c: String) {
FLOOR("."),
FILLED("#"),
EMPTY("L"),
UNKNOWN("?");
fun from(c: Char) : Tile {
when (c) {
'.' -> return FLOOR
'#' -> return FILLED
'L' -> return EMPTY
}
return UNKNOWN;
}
overri... | 0 | Java | 0 | 1 | 14a8a23c89b51dfb1dc9f160a046319cf3ca785c | 4,277 | adventofcode | MIT License |
src/Day01.kt | Moonpepperoni | 572,940,230 | false | {"Kotlin": 6305} | fun main() {
fun String.toCarriedCalories() = this.lines().sumOf { it.toInt() }
fun part1(input: List<String>): Int {
return input.maxOf(String::toCarriedCalories)
}
fun part2(input: List<String>): Int {
return input
.map(String::toCarriedCalories)
.sortedDescen... | 0 | Kotlin | 0 | 0 | 946073042a985a5ad09e16609ec797c075154a21 | 678 | moonpepperoni-aoc-2022 | Apache License 2.0 |
kotlin/src/main/kotlin/adventofcode/codeforces/KotlinHeroesPractice3.kt | 3ygun | 115,948,057 | false | null | package adventofcode.codeforces
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
object KotlinHeroesPractice3 {
// <editor-fold desc="Problem A - Restoring Three Numbers">
/*
fun main() {
val inputs = readLine()!!
.split(regex = " ".toRegex())
.map { it... | 0 | Kotlin | 0 | 0 | 69f95bca3d22032fba6ee7d9d6ec307d4d2163cf | 4,438 | adventofcode | MIT License |
src/Day01.kt | Jaavv | 571,865,629 | false | {"Kotlin": 14896} | // https://adventofcode.com/2022/day/1
fun main() {
fun part1(input: List<String>): Int {
val calories = mutableListOf<Int>()
var acc = 0
input.forEach {
if (it.isBlank()) {
calories.add(acc)
acc = 0
} else {
acc += it.... | 0 | Kotlin | 0 | 0 | 5ef23a16d13218cb1169e969f1633f548fdf5b3b | 1,322 | advent-of-code-2022 | Apache License 2.0 |
year2020/day23/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day23/part2/Year2020Day23Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
Due to what you can only assume is a mistranslation (you're not exactly fluent in Crab), you are
quite surprised when the crab starts arranging many cups in a circle on your raft - one million
(1000000) in total.
Your labeling is still correct for the first few cups; after that, the remaining cups... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,087 | AdventOfCode | MIT License |
Combination_Sum_II.kt | xiekch | 166,329,519 | false | {"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349} | class Solution {
fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> {
candidates.sort()
val res = ArrayList<MutableList<Int>>()
combinationSum(candidates, target, res, 0, mutableListOf())
return res
}
private fun combinationSum(candidates: IntArray, targ... | 0 | C++ | 0 | 0 | eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134 | 1,163 | leetcode | MIT License |
src/main/kotlin/days/Day17.kt | butnotstupid | 433,717,137 | false | {"Kotlin": 55124} | package days
class Day17 : Day(17) {
override fun partOne(): Any {
val (minX, maxX, minY, maxY) =
inputList.first().let {
Regex("""target area: x=(-?\d+)..(-?\d+), y=(-?\d+)..(-?\d+)""")
.find(it)!!.groupValues.drop(1).map { it.toInt() }
}
... | 0 | Kotlin | 0 | 0 | a06eaaff7e7c33df58157d8f29236675f9aa7b64 | 1,676 | aoc-2021 | Creative Commons Zero v1.0 Universal |
src/Day02.kt | Hotkeyyy | 573,026,685 | false | {"Kotlin": 7830} | import java.io.File
val meL = "XYZ".toList()
val opponentL = "ABC".toList()
fun main() {
fun part1(input: String) {
val rounds = input.split("\r")
var result = 0
rounds.forEach {
val me = it.split(" ").last()
val opponent = it.split(" ").first()
val p = g... | 0 | Kotlin | 0 | 0 | dfb20f1254127f99bc845e9e13631c53de8784f2 | 2,409 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day9/day9.kt | lavong | 317,978,236 | false | null | /*
--- Day 9: Encoding Error ---
With your neighbor happily enjoying their video game, you turn your attention to an open data port on the little screen in the seat in front of you.
Though the port is non-standard, you manage to connect it to your computer through the clever use of several paperclips. Upon connection... | 0 | Kotlin | 0 | 1 | a4ccec64a614d73edb4b9c4d4a72c55f04a4b77f | 4,247 | adventofcode-2020 | MIT License |
LeetCode/0198. House Robber/Solution.kt | InnoFang | 86,413,001 | false | {"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410} | /**
* Created by <NAME> on 2017/12/7.
*/
// 198
class Solution {
var memo: MutableList<Int> = MutableList(0) { -1 }
fun rob(nums: IntArray): Int {
memo.addAll(MutableList(nums.size) { -1 })
return tryRob(nums, 0)
}
private fun tryRob(nums: IntArray, index: Int): Int {
if (ind... | 0 | C++ | 8 | 20 | 2419a7d720bea1fd6ff3b75c38342a0ace18b205 | 1,661 | algo-set | Apache License 2.0 |
src/main/kotlin/days/aoc2023/Day18.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2023
import days.Day
import util.Point2d
import util.Point2dl
import util.isOdd
import util.toward
import kotlin.math.max
import kotlin.math.min
class Day18 : Day(2023, 18) {
override fun partOne(): Any {
return calculatePartOneShoelace(inputList)
}
override fun partTwo(): Any {
... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 7,821 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day14.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2018.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.extensions.head
import nl.jstege.adventofcode.aoccommon.utils.extensions.isEven
import nl.jstege.adventofcode.aoccommon.utils.extensions.scan
import java.util.*
class Day14 : Day(... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 2,265 | AdventOfCode | MIT License |
2022/src/test/kotlin/Day19.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import io.kotest.assertions.all
import io.kotest.common.ExperimentalKotest
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
private data class Blueprint(
val id: Int,
val oreRobotOreCosts: Int,
val clayRobotOreCosts: Int,
val obsidianRobotOreCosts: Int,
val obsidianRob... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 5,639 | adventofcode | MIT License |
src/main/kotlin/com/askrepps/advent2022/day15/Day15.kt | askrepps | 726,566,200 | false | {"Kotlin": 99712} | /*
* MIT License
*
* 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, m... | 0 | Kotlin | 0 | 0 | 5ce2228b0951db49a5cf2a6d974112f57e70030c | 4,691 | advent-of-code-kotlin | MIT License |
src/Day08.kt | kuangbin | 575,873,763 | false | {"Kotlin": 8252} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
val n = input.size
val m = input[0].length
val array = Array(n) { BooleanArray(m) }
for (i in 0 until n) {
for (j in 0 until m) {
array[i][j] = false
}
}
for (i in 0 until n) {
var maxValue = -... | 0 | Kotlin | 0 | 0 | ea0d89065b4d3cb4f6f78f768882d5b5473624d1 | 2,229 | advent-of-code-2022 | Apache License 2.0 |
src/graph/DijstraShortestPath.kt | agapeteo | 157,038,583 | false | null | package graph
import java.util.*
import kotlin.collections.HashSet
data class EdgeTo<V>(val to: V, val weight: Double)
class WeightedGraph<V> {
val edges: MutableMap<V, HashSet<EdgeTo<V>>> = mutableMapOf()
fun addEdge(from: V, to: V, weight: Double) {
edges.computeIfAbsent(from) { HashSet() }.add(E... | 0 | Kotlin | 0 | 1 | b5662c8fe416e277c593931caa1b29b7f017ef60 | 2,566 | kotlin-data-algo | MIT License |
src/chapter3/section5/ex1.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter3.section5
import chapter3.section3.RedBlackBST
import chapter3.section4.LinearProbingHashST
import edu.princeton.cs.algs4.In
/**
* 分别使用RedBlackBST和LinearProbingHashST来实现OrderedSET和SET(为键关联虚拟值并忽略它们)
*/
/**
* 基于RedBlackBST实现的有序集合
*/
class RedBlackOrderedSET<K : Comparable<K>> : OrderedSET<K> {
... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 2,769 | Algorithms-4th-Edition-in-Kotlin | MIT License |
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day17.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year18
import com.grappenmaker.aoc.*
import com.grappenmaker.aoc.Direction.*
fun PuzzleSet.day17() = puzzle(day = 17) {
// Increase the recursion limit for this one: -Xss10m
val lines = inputLines.map { l ->
val (a, b, c) = l.splitInts()
if (l.first() == 'x') Point... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 2,176 | advent-of-code | The Unlicense |
2015/16/kotlin/b.kt | shrivatsas | 583,681,989 | false | {"Kotlin": 17998, "Python": 9402, "Racket": 4669, "Clojure": 2953} | import java.io.File
fun main() {
val lines: List<String> = File("../16.input").useLines { it.toList() }
// Sue 410: trees: 1, akitas: 10, vizslas: 6
val pattern = Regex("""(\w+): (\d+)""")
val maps = lines.map { line ->
val matches = pattern.findAll(line)
val m: Map<String, Int> = matches.associate { ... | 0 | Kotlin | 0 | 1 | 529a72ff55f1d90af97f8e83b6c93a05afccb44c | 954 | AoC | MIT License |
src/main/java/com/booknara/problem/search/binary/RangeSumOfBSTKt.kt | booknara | 226,968,158 | false | {"Java": 1128390, "Kotlin": 177761} | package com.booknara.problem.search.binary
import java.util.*
/**
* 938. Range Sum of BST (Easy)
* https://leetcode.com/problems/range-sum-of-bst/
*/
class RangeSumOfBSTKt {
var res = 0
// T:O(n), S:O(h)
fun rangeSumBST(root: TreeNode?, low: Int, high: Int): Int {
helper(root, low, high)
return res
... | 0 | Java | 1 | 1 | 04dcf500ee9789cf10c488a25647f25359b37a53 | 1,374 | playground | MIT License |
src/Day04.kt | matheusfinatti | 572,935,471 | false | {"Kotlin": 12612} | fun main() {
val input = readInput("Day04").split("\n")
input
.map { assignment -> assignment.split(",") }
.map { assignment ->
assignment.map { it.split("-") }
}
.map { assignments ->
assignments
.map { it.map(String::toInt) }
... | 0 | Kotlin | 0 | 0 | a914994a19261d1d81c80e0ef8e196422e3cd508 | 1,149 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/g2901_3000/s2967_minimum_cost_to_make_array_equalindromic/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2901_3000.s2967_minimum_cost_to_make_array_equalindromic
// #Medium #Array #Math #Sorting #Greedy #2024_01_19_Time_363_ms_(100.00%)_Space_56_MB_(86.49%)
import kotlin.math.abs
import kotlin.math.min
@Suppress("NAME_SHADOWING")
class Solution {
fun minimumCost(nums: IntArray): Long {
nums.sort()
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,473 | LeetCode-in-Kotlin | MIT License |
word-generator/src/main/kotlin/com/github/pjozsef/wordgenerator/rule/ScrambleRule.kt | pjozsef | 248,344,539 | false | null | package com.github.pjozsef.wordgenerator.rule
import com.github.pjozsef.wordgenerator.util.Scrambler
import java.util.Random
class ScrambleRule(
prefix: String = "!",
val scrambler: Scrambler = Scrambler()
) : Rule {
private val vowels = listOf('a', 'i', 'e', 'o', 'u', 'y')
private val ruleRegexString... | 23 | Kotlin | 0 | 0 | 10a40fd61b18b5baf1723fc3b28c6205b7af30cb | 4,011 | word-generator | MIT License |
src/main/kotlin/smartcalc.kt | kevindcp | 424,878,655 | false | {"Kotlin": 8153} | package calculator
import java.math.BigInteger
fun defineOperator( operatorString: String ): String {
var isValid = operatorString.toIntOrNull()
when{
isValid != null -> return "-1"
}
when{
operatorString.length % 2 == 0 -> return "+"
operatorString == "=" -> return "-2"
... | 0 | Kotlin | 0 | 0 | e2efb902e22b098d9a1d60df0973157c1847e914 | 7,718 | smart--calc | MIT License |
src/Day10.kt | JonasDBB | 573,382,821 | false | {"Kotlin": 17550} | private fun part1(input: List<String>) {
var c = 0
var xreg = 1
var ret = 0
for (line in input) {
if (line == "noop") {
++c
if ((c + 20) % 40 == 0) {
ret += c * xreg
}
continue
}
val inc = line.split(" ")[1].toInt()
... | 0 | Kotlin | 0 | 0 | 199303ae86f294bdcb2f50b73e0f33dca3a3ac0a | 1,483 | AoC2022 | Apache License 2.0 |
aoc-2016/src/main/kotlin/nl/jstege/adventofcode/aoc2016/days/Day07.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2016.days
import nl.jstege.adventofcode.aoccommon.days.Day
import java.util.*
/**
*
* @author <NAME>
*/
class Day07 : Day(title = "Internet Protocol Version 7") {
override fun first(input: Sequence<String>): Any = input.asSequence()
.count { ipv7 ->
ipv7.ge... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 2,438 | AdventOfCode | MIT License |
src/main/kotlin/com/danielmichalski/algorithms/data_structures/_09_hash_table/HashTable.kt | DanielMichalski | 288,453,885 | false | {"Kotlin": 101963, "Groovy": 19141} | package com.danielmichalski.algorithms.data_structures._09_hash_table
import kotlin.math.min
class HashTable {
private val length = 17
private val elements = arrayOfNulls<ArrayList<HashPair>>(length)
init {
for (i in elements.indices) {
elements[i] = ArrayList(0)
}
}
... | 0 | Kotlin | 1 | 7 | c8eb4ddefbbe3fea69a172db1beb66df8fb66850 | 2,684 | algorithms-and-data-structures-in-kotlin | MIT License |
src/Day01.kt | semanticer | 577,822,514 | false | {"Kotlin": 9812} | fun main() {
fun part1(input: List<String>): Int {
val totals = caloriesByElf(input)
return totals.maxOrNull() ?: 0
}
fun part2(input: List<String>): Int {
val totals = caloriesByElf(input)
val sortedTotals = totals.sortedDescending()
return sortedTotals.take(3).sum(... | 0 | Kotlin | 0 | 0 | 9013cb13f0489a5c77d4392f284191cceed75b92 | 964 | Kotlin-Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day04/Day04.kt | jackploeg | 736,755,380 | false | {"Kotlin": 318734} | package nl.jackploeg.aoc._2023.calendar.day04
import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory
import nl.jackploeg.aoc.utilities.readStringFile
import javax.inject.Inject
import kotlin.math.pow
class Day04 @Inject constructor(
private val generatorFactory: InputGeneratorFactory,
) {
fun par... | 0 | Kotlin | 0 | 0 | f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76 | 2,165 | advent-of-code | MIT License |
src/main/java/challenges/educative_grokking_coding_interview/k_way_merge/_1/MergeSorted.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.k_way_merge._1
import challenges.util.PrintHyphens
/**
Given two sorted integer arrays, 1 nums1 and 2 nums2, and the number of data elements in each array, m and n ,
implement a function that merges the second array into the first one. You have to modify 1 nums1 ... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 5,191 | CodingChallenges | Apache License 2.0 |
src/Day03.kt | jpereyrol | 573,074,843 | false | {"Kotlin": 9016} | fun main() {
fun part1(input: List<String>): Int {
val chunkedInput = input.map { it.chunked(it.length / 2) }
val intersects = chunkedInput.map {
it.first().toCharArray() intersect it.last().toSet()
}
return intersects.sumOf { it.first().toPriority() }
}
fun p... | 0 | Kotlin | 0 | 0 | e17165afe973392a0cbbac227eb31d215bc8e07c | 865 | advent-of-code | Apache License 2.0 |
examples/nearestNeighbor/src/main/kotlin/NearestNeighbor.kt | p7nov | 235,310,936 | true | {"Kotlin": 380202, "C": 124672, "C++": 2372, "Python": 1766} | import org.jetbrains.numkt.*
import org.jetbrains.numkt.core.KtNDArray
import org.jetbrains.numkt.core.ravel
import org.jetbrains.numkt.math.*
import org.jetbrains.numkt.random.Random
fun generateRandomPoints(size: Int = 10, min: Int = 0, max: Int = 1): KtNDArray<Double> =
(max - min) * Random.randomSample(size, 2... | 0 | null | 0 | 0 | 30e2ad464f805dc310e2a54dcb5bc2ccca8f1496 | 4,131 | kotlin-numpy | Apache License 2.0 |
code-gen/src/main/kotlin/gen/CodeGen.kt | TimothyEarley | 202,394,163 | false | null | package gen
import java.io.File
import java.util.*
import kotlin.math.abs
fun main(args: Array<String>) {
require(args.size == 1) { "Please pass a file as the first argument" }
val source = File(args[0]).readText()
println(gen(source))
}
fun gen(input: String): String {
val ast = readAST(input.lineSequence().fil... | 0 | Kotlin | 0 | 0 | bb10aca0d2d3ca918bb272657aee5a26ce431560 | 4,988 | rosetta-code-compiler | MIT License |
Problems/Algorithms/847. Shortest Path Visiting All Nodes/ShortestPath.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun shortestPathLength(graph: Array<IntArray>): Int {
val n = graph.size
if (n == 1) return 0
val endingMask = (1 shl n) - 1
val visited = Array(n) { BooleanArray(endingMask+1) { false } }
val queue = ArrayDeque<IntArray>()
for (i in... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,206 | leet-code | MIT License |
src/advent/of/code/17thPuzzle.kt | 1nco | 725,911,911 | false | {"Kotlin": 112713, "Shell": 103} | package advent.of.code
import advent.of.code.types.Graph
import utils.Util
import java.util.*
object `17thPuzzle` {
private const val DAY = "17";
private var input: MutableList<String> = arrayListOf();
private var result = 0L;
private var resultSecond = 0L;
fun solve() {
val startingT... | 0 | Kotlin | 0 | 0 | 0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3 | 2,205 | advent-of-code | Apache License 2.0 |
src/Day03.kt | nZk-Frankie | 572,894,533 | false | {"Kotlin": 13625} | val FILE = readInput("Day03")
fun main()
{
Part02()
}
fun Part01(){
var score = 9
var TotalScore = 0
for (i in FILE)
{
var len = i.length - 1
var firstHalf = i.slice(0..len/2)
var secondHalf = i.slice((len/2)+1..len)
for(x in 0 until firstHalf.length step 1)
... | 0 | Kotlin | 0 | 0 | b8aac8aa1d7c236651c36da687939c716626f15b | 1,729 | advent-of-code-kotlin | Apache License 2.0 |
advent/src/test/kotlin/org/elwaxoro/advent/y2019/Dec12.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2019
import org.elwaxoro.advent.Coord3D
import org.elwaxoro.advent.PuzzleDayTester
import org.elwaxoro.advent.lcm
import java.math.BigInteger
import kotlin.math.abs
import kotlin.math.sign
/**
* Day 12: The N-Body Problem
*/
class Dec12 : PuzzleDayTester(12, 2019) {
/**
* Ok p... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 2,621 | advent-of-code | MIT License |
src/day01/Day01.kt | Regiva | 573,089,637 | false | {"Kotlin": 29453} | package day01
import readText
fun main() {
fun readElves(fileName: String): Sequence<Sequence<Int>> {
return readText(fileName)
.splitToSequence("\n\n")
.map { it.lineSequence().map(String::toInt) }
}
// Time — O(n), Memory — O(1)?
fun part1(input: Sequence<Sequence<I... | 0 | Kotlin | 0 | 0 | 2d9de95ee18916327f28a3565e68999c061ba810 | 753 | advent-of-code-2022 | Apache License 2.0 |
classroom/src/main/kotlin/com/radix2/algorithms/week2/Sorting.kt | rupeshsasne | 190,130,318 | false | {"Java": 66279, "Kotlin": 50290} | package com.radix2.algorithms.week2
fun IntArray.selectionSort() {
for (i in 0 until size) {
var j = i
var minIndex = j
while (j < size) {
if (this[minIndex] > this[j]) {
minIndex = j
}
j++
}
val temp = this[i]
t... | 0 | Java | 0 | 1 | 341634c0da22e578d36f6b5c5f87443ba6e6b7bc | 1,620 | coursera-algorithms-part1 | Apache License 2.0 |
src/Day01.kt | makohn | 571,699,522 | false | {"Kotlin": 35992} | fun main() {
fun part1(input: List<String>): Int {
val calories = mutableListOf<Int>()
var count = 0
for (s in input) {
if (s.isEmpty()) {
calories.add(count)
count = 0
} else {
count += s.toInt()
}
}... | 0 | Kotlin | 0 | 0 | 2734d9ea429b0099b32c8a4ce3343599b522b321 | 1,201 | aoc-2022 | Apache License 2.0 |
day7/src/main/kotlin/day7/CrabAlignment.kt | snv | 434,384,799 | false | {"Kotlin": 99328} | package day7
import kotlin.math.absoluteValue
fun main() {
// val input = rawInput.parse()
println("""
Part 1: ${CrabSwarm(rawInput().parse()).idealConstantFuelCost}
Part 2: ${CrabSwarm(rawInput().parse()).idealIncreasingConstantFuelCost}
""".trimIndent())
}
class CrabSwarm(private val ini... | 0 | Kotlin | 0 | 0 | 0a2d94f278defa13b52f37a938a156666314cd13 | 1,265 | adventOfCode21 | The Unlicense |
leetcode2/src/leetcode/BinarySearch.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* 704. 二分查找
* https://leetcode-cn.com/problems/binary-search/
* Created by test
* Date 2019/5/27 22:32
* Description
* 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函数搜索 nums 中的 target,如果目标值存在返回下标,否则返回 -1。
示例 1:
输入: nums = [-1,0,3,5,9,12], target = 9
输出: 4
解释: 9 出现在 nums 中并且下标为 4
示例 2:
输... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 1,278 | leetcode | MIT License |
src/main/kotlin/g1701_1800/s1765_map_of_highest_peak/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1701_1800.s1765_map_of_highest_peak
// #Medium #Array #Breadth_First_Search #Matrix
// #2023_06_18_Time_1087_ms_(100.00%)_Space_141.9_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
class Solution {
private val dir = intArrayOf(0, 1, 0, -1, 0)
fun highestPeak(isWater: Array<IntArray... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,315 | LeetCode-in-Kotlin | MIT License |
archive/src/main/kotlin/com/grappenmaker/aoc/year16/Day09.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year16
import com.grappenmaker.aoc.PuzzleSet
import com.grappenmaker.aoc.onceSplit
fun PuzzleSet.day09() = puzzle {
fun String.createParts(): List<ExplodePart> = buildList {
var left = this@createParts
while (left.isNotEmpty()) {
if ("(" !in left) {
... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 1,500 | advent-of-code | The Unlicense |
src/main/kotlin/days/Day1.kt | MaciejLipinski | 317,582,924 | true | {"Kotlin": 60261} | package days
class Day1 : Day(1) {
override fun partOne(): Any {
return inputList
.map { it.toInt() }
.mapNotNull { findMatchingFor((inputList.map { i -> i.toInt() } - it), it) }
.first()
.itMultipliedByMatching()
}
override fun part... | 0 | Kotlin | 0 | 0 | 1c3881e602e2f8b11999fa12b82204bc5c7c5b51 | 951 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/day17/Day17.kt | jakubgwozdz | 571,298,326 | false | {"Kotlin": 85100} | package day17
import execute
import readAllText
import wtf
val shapes = listOf(
"""
....
....
....
####
""".trimIndent(),
"""
....
.#..
###.
.#..
""".trimIndent(),
"""
....
..#.
..#.
###.
""".trimIn... | 0 | Kotlin | 0 | 0 | 7589942906f9f524018c130b0be8976c824c4c2a | 4,060 | advent-of-code-2022 | MIT License |
src/main/kotlin/homeworks/fifth/second/GaussQuadratureFormula.kt | Niksen111 | 689,743,548 | false | {"Kotlin": 112514} | package homeworks.fifth.second
import homeworks.first.Homework1
import homeworks.first.utils.vo.HomeworkData
import homeworks.utils.vo.Seq
import kotlin.math.pow
class GaussQuadratureFormula(
val seq: Seq,
val N: Int
) {
val polynomials = MutableList(N + 1) {
{ _: Double -> 1.0 }
}
val ro... | 0 | Kotlin | 0 | 0 | 15e8493468da8fa909f36f9e0b72e7d6ddd5c5cb | 2,230 | Calculation-Methods | Apache License 2.0 |
src/Day08.kt | wbars | 576,906,839 | false | {"Kotlin": 32565} | fun main() {
fun part1(input: List<String>): Int {
val m = input[0].length
val n = input.size
val a: Array<BooleanArray> = Array(n) { BooleanArray(m) }
fun checkMax(input: List<String>, i: Int, j: Int, max: Char): Char {
val c = input[i][j]
if (c > max) {
... | 0 | Kotlin | 0 | 0 | 344961d40f7fc1bb4e57f472c1f6c23dd29cb23f | 2,565 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/nl/tiemenschut/aoc/y2023/day1.kt | tschut | 723,391,380 | false | {"Kotlin": 61206} | package nl.tiemenschut.aoc.y2023
import nl.tiemenschut.aoc.lib.dsl.aoc
import nl.tiemenschut.aoc.lib.dsl.day
import nl.tiemenschut.aoc.lib.dsl.parser.AsListOfStrings
fun main() {
aoc(AsListOfStrings) {
puzzle { 2023 day 1 }
part1 { input ->
input.sumOf { line ->
val nu... | 0 | Kotlin | 0 | 1 | a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3 | 1,132 | aoc-2023 | The Unlicense |
src/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day04.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2021
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
class Aoc2021Day04 {
companion object {
private const val NUMBER_SEPARATOR = ","
private val ONE_OR_MORE_SPACE = Regex(pattern ... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 5,341 | adventofcode | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2022/day10/Day10.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day10
import com.jacobhyphenated.advent2022.Day
/**
* Day 10: Cathode-Ray Tube
*
* The input is a list of code instructions that are either:
* noop
* addx y
* There is 1 register and a cpu clock. The register starts at 1
* Noop takes 1 cpu cycle. Addx takes 2 cp... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 2,661 | advent2022 | The Unlicense |
src/Day20.kt | jinie | 572,223,871 | false | {"Kotlin": 76283} | import kotlin.math.abs
class Day20 {
private fun decrypt(input: List<Long>, decryptKey: Int = 1, mixTimes: Int = 1): Long {
val original = input.mapIndexed { index, i -> Pair(index, i *decryptKey)}
val moved = original.toMutableList()
for(i in 0 until mixTimes) {
original.forEa... | 0 | Kotlin | 0 | 0 | 4b994515004705505ac63152835249b4bc7b601a | 1,220 | aoc-22-kotlin | Apache License 2.0 |
src/day3/KotlinMain.kt | nick-bennett | 225,112,065 | false | {"Java": 58302, "Kotlin": 22625} | /*
* Copyright 2019 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | 0 | Java | 0 | 1 | 40004a851e09734b3aae730d3350a386f2418ec4 | 5,279 | advent-of-code-2019 | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day16.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 16: Packet Decoder
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.readFileAsString
fun main() {
println(" ** Day 16: Packet Decoder ** \n")
val packetTransmission = readFileAsString("/Day16BITSTransmission.txt")
val packetVersionsSum = sumAllVersionNumbersInBitsPackets(pac... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 5,955 | AdventOfCode2021 | MIT License |
mobile/src/main/java/ch/epfl/sdp/mobile/application/chess/parser/StringCombinators.kt | epfl-SDP | 462,385,783 | false | {"Kotlin": 1271815, "Shell": 359} | package ch.epfl.sdp.mobile.application.chess.parser
import ch.epfl.sdp.mobile.application.chess.parser.Combinators.filter
import ch.epfl.sdp.mobile.application.chess.parser.Combinators.map
typealias Token = String
/** An object which contains some convenience parser combinators for [String]. */
object StringCombinat... | 15 | Kotlin | 2 | 13 | 71f6e2a5978087205b35f82e89ed4005902d697e | 2,845 | android | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2136/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2136
/**
* LeetCode page: [2136. Earliest Possible Day of Full Bloom](https://leetcode.com/problems/earliest-possible-day-of-full-bloom/);
*/
class Solution {
/* Complexity:
* Time O(NLogN) and Space O(N) where N is the size of plantTime and growTime;
*/
fun ea... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,140 | hj-leetcode-kotlin | Apache License 2.0 |
src/chapter1/section1/binarySearch.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter1.section1
//课本中的二分查找原版
fun binarySearch(key: Int, array: IntArray): Int {
var low = 0
var high = array.size - 1
while (low <= high) {
val mid = (low + high) / 2
when {
key < array[mid] -> high = mid - 1
key > array[mid] -> low = mid + 1
el... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 1,843 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinTimeToVisitAllPoints.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,272 | kotlab | Apache License 2.0 |
algorithm/src/main/kotlin/com/seanshubin/condorcet/algorithm/CondorcetAlgorithm.kt | SeanShubin | 190,099,313 | false | null | package com.seanshubin.condorcet.algorithm
import com.seanshubin.condorcet.matrix.Matrix
import com.seanshubin.condorcet.matrix.Size
import com.seanshubin.condorcet.matrix.plus
import kotlin.math.max
import kotlin.math.min
object CondorcetAlgorithm {
fun tally(request: TallyElectionRequest): TallyElectionResponse... | 2 | Kotlin | 0 | 0 | 61219ae238b47792a5d347625f4963a1b2841d2d | 4,510 | condorcet5 | The Unlicense |
src/main/adventofcode/Day05Solver.kt | eduardofandrade | 317,942,586 | false | null | package adventofcode
import java.io.InputStream
import java.util.stream.Collectors
class Day05Solver(stream: InputStream) : Solver {
private val processedInput: List<Seat>
init {
processedInput = processInput(stream)
}
private fun processInput(stream: InputStream): List<Seat> {
retu... | 0 | Kotlin | 0 | 0 | 147553654412ae1da4b803328e9fc13700280c17 | 2,047 | adventofcode2020 | MIT License |
src/main/kotlin/Day02.kt | attilaTorok | 573,174,988 | false | {"Kotlin": 26454} | /**
* The shape what the opponent chooses.
*
* The value represents how much does the shape worth. The method score, calculates the points for the second part of
* the exercise.
*
* In part two, the second column says how the round needs to end: X means you need to lose, Y means you need to end the
* round in a ... | 0 | Kotlin | 0 | 0 | 1799cf8c470d7f47f2fdd4b61a874adcc0de1e73 | 4,717 | AOC2022 | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/sorting_and_searching/sparse_search/QuestionB.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.sorting_and_searching.sparse_search
object QuestionB {
fun searchI(strings: Array<String>, str: String?, first: Int, last: Int): Int {
var first = first
var last = last
while (first <= last) {
/* Move mid to the middle */
... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 3,464 | CodingChallenges | Apache License 2.0 |
src/main/kotlin/pl/jpodeszwik/aoc2023/Day03.kt | jpodeszwik | 729,812,099 | false | {"Kotlin": 55101} | package pl.jpodeszwik.aoc2023
import java.lang.Long.parseLong
fun isAdjacentToNonDigit(lines: List<String>, line: Int, begin: Int, end: Int): Boolean {
val isSymbol: (Char) -> Boolean = { c -> c != '.' }
for (i in begin - 1..end + 1) {
if (line - 1 >= 0) {
if (i >= 0 && i <= lines[line].le... | 0 | Kotlin | 0 | 0 | 2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63 | 4,079 | advent-of-code | MIT License |
src/test/java/quam/ComplexMatrixShould.kt | johnhearn | 149,781,062 | false | null | package quam
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
class ComplexMatrixShould {
private val a = 1.0 + 2.0 * i
private val b = 3.0 + 4.0 * i
private val c = 5.0 + 6.0 * i
private val d = 7.0 + 8.0 * i
@Test
fun `build from integers`() {
val lhs = ComplexMatr... | 1 | Kotlin | 0 | 1 | 4215d86e7afad97b803ce850745920b63f75a0f9 | 3,225 | quko | MIT License |
Kotlin/Solucionando problemas em Kotlin/PrimoRapido.kt | Pleiterson | 328,727,089 | false | null | // Primo Rápido
/*
Mariazinha sabe que um Número Primo é aquele que pode ser dividido somente por
1 (um) e por ele mesmo. Por exemplo, o número 7 é primo, pois pode ser dividido
apenas pelo número 1 e pelo número 7 sem que haja resto. Então ela pediu para
você fazer um programa que aceite diversos valores e diga se ca... | 3 | Java | 73 | 274 | 003eda61f88702e68670262d6c656f47a3f318b6 | 1,563 | desafios-bootcamps-dio | MIT License |
app/src/main/kotlin/com/resurtm/aoc2023/day18/Part1.kt | resurtm | 726,078,755 | false | {"Kotlin": 119665} | package com.resurtm.aoc2023.day18
import kotlin.math.abs
fun solvePart1(moves: List<Move>): Int {
val minMax = findMinMax(moves)
val size = Pos(
abs(minMax.min.row) + abs(minMax.max.row) + 1,
abs(minMax.min.col) + abs(minMax.max.col) + 1
)
val delta = Pos(-minMax.min.row, -minMax.min.... | 0 | Kotlin | 0 | 0 | fb8da6c246b0e2ffadb046401502f945a82cfed9 | 3,811 | advent-of-code-2023 | MIT License |
src/main/kotlin/com/jaspervanmerle/aoc2020/day/Day11.kt | jmerle | 317,518,472 | false | null | package com.jaspervanmerle.aoc2020.day
class Day11 : Day("2321", "2102") {
private val initialLayout = getInput()
.lines()
.map { it.toCharArray() }
.toTypedArray()
private val width = initialLayout[0].size
private val height = initialLayout.size
private val adjacentDirections... | 0 | Kotlin | 0 | 0 | 81765a46df89533842162f3bfc90f25511b4913e | 2,880 | advent-of-code-2020 | MIT License |
kotlin/0304-range-sum-query-2d-immutable.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | class NumMatrix(matrix: Array<IntArray>) {
val row = matrix.size
val col = matrix[0].size
val prefixSum = Array(row + 1){ IntArray(col + 1) }
init {
for(i in 0 until row) {
var prefix = 0
for(j in 0 until col) {
println("i: $i j: $j")
pre... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,018 | leetcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/StoneGame3.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,841 | kotlab | Apache License 2.0 |
src/main/java/com/squareup/tools/maven/resolution/MavenVersion.kt | square | 250,649,454 | false | null | /*
* Copyright 2020 Square Inc.
*
* 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 ... | 4 | Kotlin | 9 | 69 | 6f43ea77ea80602f663b54fce63c7a1bc1a5946f | 4,446 | maven-archeologist | Apache License 2.0 |
01-basics-of-oop/Final/main.kt | kodecocodes | 734,547,562 | false | {"Kotlin": 58443} | import java.util.UUID;
val lagos = Pair(6.465422, 3.406448)
val london = Pair(51.509865, -0.118092)
// Procedural programming function
// DONE: Add more inputs
fun computeTravelTime(from: Pair<Double, Double>,
to: Pair<Double, Double>,
averageSpeed: Double,
... | 0 | Kotlin | 0 | 0 | a0c5f2b61b3e5937d21a6f322ff8b19df3d89ada | 2,764 | m3-kioop-materials | Apache License 2.0 |
src/Day08.kt | olezhabobrov | 572,687,414 | false | {"Kotlin": 27363} | // Literally the most horrible code I've ever written
fun main() {
fun part1(input: List<String>): Int {
var counter = 0
val X = input[0].length
val Y = input.size
val field = Array(input.size, {index -> input[index].map { it.digitToInt() } })
field.forEachIndexed { y, xLine... | 0 | Kotlin | 0 | 0 | 31f2419230c42f72137c6cd2c9a627492313d8fb | 3,647 | AdventOfCode | Apache License 2.0 |
src/day20.kt | miiila | 725,271,087 | false | {"Kotlin": 77215} | import java.io.File
import kotlin.system.exitProcess
private const val DAY = 20
fun main() {
if (!File("./day${DAY}_input").exists()) {
downloadInput(DAY)
println("Input downloaded")
exitProcess(0)
}
val transformer = { x: String -> x }
val input = loadInput(DAY, false, transfo... | 0 | Kotlin | 0 | 1 | 1cd45c2ce0822e60982c2c71cb4d8c75e37364a1 | 4,161 | aoc2023 | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[61]旋转链表.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给你一个链表的头节点 head ,旋转链表,将链表每个节点向右移动 k 个位置。
//
//
//
// 示例 1:
//
//
//输入:head = [1,2,3,4,5], k = 2
//输出:[4,5,1,2,3]
//
//
// 示例 2:
//
//
//输入:head = [0,1,2], k = 4
//输出:[2,0,1]
//
//
//
//
// 提示:
//
//
// 链表中节点的数目在范围 [0, 500] 内
// -100 <= Node.val <= 100
// 0 <= k <= 2 * 109
//
// Related Topics 链表 双指针
/... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,584 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/dev/kosmx/aoc23/cubes/Cubes.kt | KosmX | 726,056,762 | false | {"Kotlin": 32011} | package dev.kosmx.aoc23.cubes
import java.io.File
import kotlin.math.max
fun main() {
val games = File("cubes.txt").readLines().map { Game.of(it) }
println(games)
games.sumOf { game ->
val r = game.rounds.fold(Round()) { acc, round ->
Round(max(acc.red, round.red), max(acc.green, roun... | 0 | Kotlin | 0 | 0 | ad01ab8e9b8782d15928a7475bbbc5f69b2416c2 | 1,484 | advent-of-code23 | MIT License |
year2021/day08/part2/src/main/kotlin/com/curtislb/adventofcode/year2021/day08/part2/Year2021Day08Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
Through a little deduction, you should now be able to determine the remaining digits. Consider again
the first example above:
```
acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab |
cdfeb fcadb cdfeb cdbaf
```
After some careful analysis, the mapping between signal wires and segments onl... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,058 | AdventOfCode | MIT License |
src/day06/Day06.kt | zoricbruno | 573,440,038 | false | {"Kotlin": 13739} | package day06
import readInput
fun findStartMarkerIndex(input: String, length: Int): Int {
val unique = HashSet<Char>()
var left = 0
var right = 0
while (right < input.length){
while (unique.contains(input[right])){
unique.remove(input[left])
left++
}
u... | 0 | Kotlin | 0 | 0 | 16afa06aff0b6e988cbea8081885236e4b7e0555 | 1,025 | kotlin_aoc_2022 | Apache License 2.0 |
src/Day10.kt | flexable777 | 571,712,576 | false | {"Kotlin": 38005} | fun main() {
fun part1(input: List<String>): Int {
var x = 1
var totalSignalStrength = 0
var cycle = 1
input.forEach { instruction ->
if (instruction == "noop") {
// println("start of cycle $cycle, x = $x")
// println("no operation")
... | 0 | Kotlin | 0 | 0 | d9a739eb203c535a3d83bc5da1b6a6a90a0c7bd6 | 3,723 | advent-of-code-2022 | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/sorting_and_searching/introduction/MergeSort.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.sorting_and_searching.introduction
import challenges.util.AssortedMethods.printIntArray
import challenges.util.AssortedMethods.randomArray
object MergeSort {
private fun mergesort(array: IntArray) {
val helper = IntArray(array.size)
mergesort(array, he... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,528 | CodingChallenges | Apache License 2.0 |
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day09.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwenty
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.max
import fr.outadoc.aoc.scaffold.min
import fr.outadoc.aoc.scaffold.readDayInput
class Day09 : Day<Long> {
companion object {
const val PREAMBLE_LENGTH = 25
}
private val input = readDayInput(... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 1,866 | adventofcode | Apache License 2.0 |
archive/631/solve.kt | daniellionel01 | 435,306,139 | false | null | /*
=== #631 Constrained Permutations - Project Euler ===
Let $(p_1 p_2 \ldots p_k)$ denote the permutation of the set ${1, ..., k}$ that maps $p_i\mapsto i$. Define the length of the permutation to be $k$; note that the empty permutation $()$ has length zero.
Define an occurrence of a permutation $p=(p_1 p_2 \ldots p_... | 0 | Kotlin | 0 | 1 | 1ad6a549a0a420ac04906cfa86d99d8c612056f6 | 1,246 | euler | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.