path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/g2001_2100/s2092_find_all_people_with_secret/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2092_find_all_people_with_secret // #Hard #Sorting #Depth_First_Search #Breadth_First_Search #Graph #Union_Find // #2023_06_28_Time_1086_ms_(100.00%)_Space_104.2_MB_(100.00%) import java.util.Arrays @Suppress("NAME_SHADOWING") class Solution { fun findAllPeople(n: Int, meetings: Array<IntArra...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,713
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/askrepps/advent/advent2023/day02/Advent2023Day02.kt
askrepps
726,566,200
false
{"Kotlin": 302802}
/* * MIT License * * Copyright (c) 2023 <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
2,728
advent-of-code-kotlin
MIT License
src/main/kotlin/tr/emreone/adventofcode/Day22Github.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode import tr.emreone.kotlin_utils.Direction4.Companion.DOWN import tr.emreone.kotlin_utils.Direction4.Companion.LEFT import tr.emreone.kotlin_utils.Direction4.Companion.RIGHT import tr.emreone.kotlin_utils.Direction4.Companion.UP import tr.emreone.kotlin_utils.* import tr.emreone.kotlin_ut...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
8,432
advent-of-code-2022
Apache License 2.0
sublist/src/main/kotlin/Relationship.kt
sirech
189,113,734
false
null
enum class Relationship { EQUAL, SUBLIST, SUPERLIST, UNEQUAL } private enum class Case { EMPTY_CASE, FIRST_BIGGER_OR_EQUAL, FIRST_SMALLER } fun <T> List<T>.relationshipTo(other: List<T>): Relationship { return when (case(this, other)) { Case.EMPTY_CASE -> emptyCase(this, other) C...
1
Kotlin
0
0
253f4636f16f83f6b96f21532a3ca8fa16dace46
1,426
exercism-kotlin
MIT License
y2015/src/main/kotlin/adventofcode/y2015/Day16.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2015 import adventofcode.io.AdventSolution object Day16 : AdventSolution(2015, 16, "<NAME>") { override fun solvePartOne(input: String) = parseInput(input) .indexOfFirst { candidate -> candidate.all { (k, v) -> actualAunt[k] == v } } + 1 override fun solveP...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,282
advent-of-code
MIT License
src/Day01.kt
vlsolodilov
573,277,339
false
{"Kotlin": 19518}
fun main() { fun getElfCaloriesList(input: List<String>): List<Int> { var currentSumCalories = 0 val calorieList = mutableListOf<Int>() input.forEach { if (it.isNotBlank()) { currentSumCalories += it.toInt() } else { calorieList.add(cur...
0
Kotlin
0
0
b75427b90b64b21fcb72c16452c3683486b48d76
909
aoc22
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day004/day004.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day004 // day004.kt // By <NAME>, 2020. import kotlin.math.abs // Unfortunately, to make this code as efficient as possible and have it run in linear time and constant space, // we must use an imperative approach and mutability, along with an array to avoid linked list access times. // This is a very fini...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
3,298
daily-coding-problem
MIT License
archive/315/solve.kt
daniellionel01
435,306,139
false
null
/* === #315 Digital root clocks - Project Euler === Sam and Max are asked to transform two digital clocks into two "digital root" clocks. A digital root clock is a digital clock that calculates digital roots step by step. When a clock is fed a number, it will show it and then it will start the calculation, showing all...
0
Kotlin
0
1
1ad6a549a0a420ac04906cfa86d99d8c612056f6
2,583
euler
MIT License
src/main/kotlin/aoc2017/HeardYouLikeRegisters.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import komu.adventofcode.utils.nonEmptyLines fun heardYouLikeRegisters(input: String): Pair<Int, Int> { val ops = input.nonEmptyLines().map(Operation.Companion::parse) val registers = mutableMapOf<String, Int>() var max = 0 for (op in ops) { val conditionValu...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,157
advent-of-code
MIT License
implementation/src/main/kotlin/io/github/tomplum/aoc/ferry/docking/program/BitMask.kt
TomPlum
317,142,882
false
null
package io.github.tomplum.aoc.ferry.docking.program /** * A bit-mask consisting of either 0, 1 or X. * * An X indicates a 'Floating Bit' that is in a state of super-position and is therefore * simultaneously a 0 and a 1. This means that every [mask] with a floating-bit has * 2^N permutations wheres N is the numbe...
1
Kotlin
0
0
73b3eacb7cb8a7382f8891d3866eda983b6ea7a9
3,867
advent-of-code-2020
Apache License 2.0
src/main/kotlin/day3.kt
mattianeroni
725,705,827
false
{"Kotlin": 7277}
package day3 import java.io.File import java.util.PriorityQueue val nums = Array<String>(10){ it.toString() }.toSet() fun exercise1 () { val filename = "./inputs/day3ex1.txt" var total: Int = 0 val allLines = File(filename).readLines().toList() for ((row, line) in allLines.withIndex()) { ...
0
Kotlin
0
0
cbbe6f80325931936a36157669ab161f968af659
3,771
aoc
Apache License 2.0
src/main/kotlin/net/mguenther/adventofcode/day10/Day10.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day10 /** * @author <NAME> (<EMAIL>) */ class KnotHash(val size: Int) { private val suffix: IntArray = intArrayOf(17, 31, 73, 47, 23) private var knot: IntArray = IntArray(size) private var offset: Int = 0 private var skip: Int = 0 init { for (i in 0 ...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
2,722
advent-of-code-2017
MIT License
Algorithms/src/main/kotlin/Search2DMatrix.kt
ILIYANGERMANOV
557,496,216
false
{"Kotlin": 74485}
/** * # Search a 2D Matrix * Problem: * https://leetcode.com/problems/search-a-2d-matrix/ */ class Search2DMatrix { fun searchMatrix(matrix: Array<IntArray>, target: Int): Boolean { val rowsCount = matrix.size if (rowsCount == 1) return binarySearchRow(matrix[0], target) return binarySea...
0
Kotlin
0
1
4abe4b50b61c9d5fed252c40d361238de74e6f48
2,208
algorithms
MIT License
src/main/kotlin/Cleanup.kt
alebedev
573,733,821
false
{"Kotlin": 82424}
// Day4 fun main() { val sections = readInput() val fullyContained = sections.count { fullyContains(it.first, it.second) || fullyContains(it.second, it.first) } val overlapping = sections.count { overlaps(it.first, it.second) } println("# of fully contained ${fullyContained}") println("# of overlapp...
0
Kotlin
0
0
d6ba46bc414c6a55a1093f46a6f97510df399cd1
1,084
aoc2022
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfWaysToStay.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,663
kotlab
Apache License 2.0
day3/src/main/kotlin/day3/LifeSupport.kt
snv
434,384,799
false
{"Kotlin": 99328}
package day3 import kotlin.math.roundToInt fun lifeSupportRating(diagnosticReport : List<List<Int>>) :Int = oxygenRating(diagnosticReport) * co2ScrubberRating(diagnosticReport) fun co2ScrubberRating(diagnosticReport: List<List<Int>>): Int = binaryCo2Rating(diagnosticReport).toInt(2) fun binaryCo2Rating(diagnosticRe...
0
Kotlin
0
0
0a2d94f278defa13b52f37a938a156666314cd13
1,647
adventOfCode21
The Unlicense
src/test/kotlin/aoc/Day5.kt
Lea369
728,236,141
false
{"Kotlin": 36118}
package aoc import org.junit.jupiter.api.Nested import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Collectors import kotlin.test.Test import kotlin.test.assertEquals class Day5 { data class Conversion(val range: LongRange, val diff: Long) @Nested internal inner class Day5Test ...
0
Kotlin
0
0
1874184df87d7e494c0ff787ea187ea3566fbfbb
4,355
AoC
Apache License 2.0
src/main/java/Exercise11-part2.kt
cortinico
317,667,457
false
null
fun main() { val input: List<CharArray> = object {} .javaClass .getResource("input-11.txt") .readText() .split("\n") .map(String::toCharArray) var array1 = Array(input.size) { i -> CharArray(input[i].size) { j -> input[i][j] } } var array2...
1
Kotlin
0
4
a0d980a6253ec210433e2688cfc6df35104aa9df
2,326
adventofcode-2020
MIT License
calendar/day04/Day4.kt
mpetuska
571,764,215
false
{"Kotlin": 18073}
package day04 import Day import Lines import kotlin.math.max import kotlin.math.min class Day4 : Day() { override fun part1(input: Lines): Any { return input.map { it.split(",") } .map { (a, b) -> a.split("-") to b.split("-") } .map { (a, b) -> a.let { (s, f) -> s.toInt()..f.toInt() } to b.let { (s,...
0
Kotlin
0
0
be876f0a565f8c14ffa8d30e4516e1f51bc3c0c5
791
advent-of-kotlin-2022
Apache License 2.0
year2016/src/main/kotlin/net/olegg/aoc/year2016/day14/Day14.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day14 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.md5 import net.olegg.aoc.year2016.DayOf2016 /** * See [Year 2016, Day 14](https://adventofcode.com/2016/day/14) */ object Day14 : DayOf2016(14) { private val MATCH_3 = "(.)(\\1)(\\1)".toRegex() override fun fir...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,253
adventofcode
MIT License
src/main/kotlin/aoc08/aoc08.kt
dnene
317,653,484
false
null
package aoc08 import arrow.core.Either import arrow.core.flatMap import arrow.core.left import arrow.core.right import java.io.File enum class Operation(val str: String, val accFunc: (Int, Int, Int) -> Pair<Int, Int>) { Accumulate("acc", { index, acc, offset -> index + 1 to acc + offset }), Jump("jmp", { inde...
0
Kotlin
0
0
db0a2f8b484575fc3f02dc9617a433b1d3e900f1
2,542
aoc2020
MIT License
src/main/kotlin/charizard/WinningCombinations.kt
mohakapt
677,036,849
false
null
package charizard /** * Stores the winning combinations for a given board size. */ object WinningCombinations { private fun generate(boardSize: Int): List<Long> { val wins = mutableListOf<Long>() val cellCount = boardSize * boardSize for (i in 0..<cellCount) { val row = i / b...
0
Kotlin
0
2
fd67f349b9bb33c15b4bdd48d9d1fef76dd35ed8
1,570
Minimax
MIT License
src/Day14.kt
IvanChadin
576,061,081
false
{"Kotlin": 26282}
import kotlin.math.max import kotlin.math.sign fun main() { val inputName = "Day14_test" fun part1(): Int { val a = Array(1000) { BooleanArray(1000) { false } } var maxRow = -1 for (s in readInput(inputName)) { val points = s.split(" -> ").map { it.split(","...
0
Kotlin
0
0
2241437e6c3a20de70306a0cb37b6fe2ed8f9e3a
3,704
aoc-2022
Apache License 2.0
src/pl/shockah/aoc/y2017/Day8.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.regex.Pattern import kotlin.math.max class Day8: AdventTask<List<Day8.Instruction>, Int, Int>(2017, 8) { private val inputPattern: Pattern = Pattern.compile("(\\w+)...
0
Kotlin
0
0
9abb1e3db1cad329cfe1e3d6deae2d6b7456c785
2,898
Advent-of-Code
Apache License 2.0
examples/bowlingKata/FunctionalBowling.kt
uberto
624,365,748
false
null
data class GameState(val rolls: List<Int> = listOf()) fun roll(gameState: GameState, pins: Int): GameState = GameState(gameState.rolls + pins) fun score(gameState: GameState): Int = calculateScore(gameState.rolls, 0, 0) private tailrec fun calculateScore(rolls: List<Int>, frameIndex: Int, frame: Int): Int = if (...
0
Kotlin
0
2
4f41f9f23bd1d0db9267ca19561263ece0d4022e
2,455
prompts
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/EvalRPN.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,525
kotlab
Apache License 2.0
src/main/kotlin/adventofcode2017/Day03SpiralMemory.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2017 import adventofcode2017.Direction.* import kotlin.math.absoluteValue class Day03SpiralMemory data class Coordinate(val x: Int, val y: Int) enum class Direction { RIGHT, LEFT, UP, DOWN } class SpiralMemory(private val input: Int = 1) { private val memory = mutableMapOf<I...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
3,965
kotlin-coding-challenges
MIT License
src/main/kotlin/com/leetcode/P131.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://github.com/antop-dev/algorithm/issues/297 class P131 { fun partition(s: String): List<List<String>> { // dynamic programming val dp = Array(s.length) { IntArray(s.length) }.apply { for (i in s.indices) this[i][i] = 1 for (i in 1 until s.length...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,488
algorithm
MIT License
codeforces/round637/b.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round637 private val digits = listOf("1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011").map { it.toInt(2) } fun main() { val (n, k) = readInts() val a = List(n) { val shown = readLn().toInt(2) digits.mapIndexedNotNull { d, digit -> ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,012
competitions
The Unlicense
src/main/kotlin/g0601_0700/s0640_solve_the_equation/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0601_0700.s0640_solve_the_equation // #Medium #String #Math #Simulation #2023_02_10_Time_170_ms_(66.67%)_Space_35.3_MB_(66.67%) class Solution { fun solveEquation(equation: String): String { val eqs = equation.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() val arr1 = e...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,901
LeetCode-in-Kotlin
MIT License
src/Day01.kt
jdpaton
578,869,545
false
{"Kotlin": 10658}
fun main() { fun part1() { val testInput = readInput("Day01_test") var elfIndex = 1 var currentTotal = 0 val elfMap = mutableMapOf<Int, Int>() testInput.forEach { line -> if (line.isNotEmpty()) { currentTotal += line.toInt() } else { ...
0
Kotlin
0
0
f6738f72e2a6395815840a13dccf0f6516198d8e
1,278
aoc-2022-in-kotlin
Apache License 2.0
solutions/aockt/y2021/Y2021D06.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import io.github.jadarma.aockt.core.Solution object Y2021D06 : Solution { /** * A simulation model of a population of lantern fish. * @constructor Initializes this population based on the days left of each fish's reproductive cycle. */ private class LanternFishPopulation(se...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
1,688
advent-of-code-kotlin-solutions
The Unlicense
src/day-3/part-2/solution-day-3-part-2.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File fun groupElves(rucksacks: List<String>): List<Triple<String, String, String>> { val elfGroups = mutableListOf<Triple<String, String, String>>() for (i in 0..rucksacks.size - 1 step 3) { elfGroups.add(Triple(rucksacks[i], rucksacks[i + 1], rucksacks[i + 2])) } return elfGroup...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
829
advent-of-code-22
MIT License
src/day-2/part-2/solution-day-2-part-2.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File fun convertToPair(string: String): Pair<Char, Char> { val split = string.split(" ") return Pair(split.get(0).first(), split.get(1).first()) } fun letterValue(char: Char): Int { return mapOf('A' to 1, 'B' to 2, 'C' to 3, 'X' to 1, 'Y' to 2, 'Z' to 3).getOrDefault(char, 0) } fun calcula...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
795
advent-of-code-22
MIT License
src/Day05/Day05.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day05 import checkAndPrint import measureAndPrintTimeMillis import readInput import java.util.ArrayDeque @ExperimentalStdlibApi fun main() { val moveRgx = """move (\d+) from (\d) to (\d)""".toRegex() fun getStartingConfig(input: List<String>): List<ArrayDeque<Char>> { val digitLineIdx = input...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
2,519
AdventOfCode2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day10.kt
EmRe-One
726,902,443
false
{"Kotlin": 95869, "Python": 18319}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.automation.Day import java.util.* class Day10 : Day(10, 2023, "Pipe Maze") { class Maze(input: List<List<Char>>) { val NORTH_EAST = '└' // oder 'L' val NORTH_WEST = '┘' // oder 'J' val SOUTH_EAST = '┌' // oder 'F' ...
0
Kotlin
0
0
c75d17635baffea50b6401dc653cc24f5c594a2b
6,310
advent-of-code-2023
Apache License 2.0
src/test/kotlin/adventofcode/day08/Day08.kt
jwcarman
573,183,719
false
{"Kotlin": 183494}
/* * Copyright (c) 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 i...
0
Kotlin
0
0
d6be890aa20c4b9478a23fced3bcbabbc60c32e0
2,370
adventofcode2022
Apache License 2.0
kotlin/1091-shortest-path-in-binary-matrix.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 Solution { fun shortestPathBinaryMatrix(grid: Array<IntArray>): Int { if(grid[0][0] == 1 || grid[grid.lastIndex][grid.lastIndex] == 1) return -1 fun isValid(i: Int, j: Int) = i in (0..grid.lastIndex) && j in (0..grid.lastIndex) && grid[i][j] == 0 val q = ArrayDeque<Pair<Int, Int>>()...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,296
leetcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MatrixDiagonalSum.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,418
kotlab
Apache License 2.0
baparker/05/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File import kotlin.math.abs fun getOverlapCount() { var coordinateCount: MutableMap<String, Int> = mutableMapOf() File("input.txt").forEachLine { val line = it.split(" -> ") val start = line[0].split(",") val end = line[1].split(",") if (start[0].equals(end[0])) {...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
2,611
advent-of-code-2021
MIT License
year2023/src/cz/veleto/aoc/year2023/Day06.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2023 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.solveQuadratic import kotlin.math.ceil import kotlin.math.floor class Day06(config: Config) : AocDay(config) { override fun part1(): String = cachedInput .parsePart1() .map { (t, d) -> countWaysToWin(t, d) }...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
1,392
advent-of-pavel
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Day20.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day20(private val input: List<Int>) { fun solvePart1() = solve() fun solvePart2() = solve(10, 811589153) private fun solve(mixCount: Int = 1, decryptionKey: Int = 1) = input .map { it.toLong() * decryptionKey } .mapIndexed { index, value -> Number(i...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,374
advent-2022
MIT License
src/main/kotlin/hu/advent/of/code/year2019/day3/Puzzle3A.kt
sztojkatamas
568,512,275
false
{"Kotlin": 157914}
package hu.advent.of.code.year2019.day3 import hu.advent.of.code.AdventOfCodePuzzle import hu.advent.of.code.BaseChallenge import kotlin.math.abs @AdventOfCodePuzzle class Puzzle3A: BaseChallenge(2019) { override fun run() { printPuzzleName() loadDataFromFile("data3.txt") println("Minimum...
0
Kotlin
0
0
6aa9e53d06f8cd01d9bb2fcfb2dc14b7418368c9
4,234
advent-of-code-universe
MIT License
kotlin-native/performance/numerical/src/main/kotlin/pi.kt
JetBrains
3,432,266
false
{"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513...
/* * Computation of the n'th decimal digit of \pi with very little memory. * Written by <NAME> on January 8, 1997. * * We use a slightly modified version of the method described by Simon * Plouffe in "On the Computation of the n'th decimal digit of various * transcendental numbers" (November 1996). We have modifi...
166
Kotlin
5,771
46,772
bef0946ab7e5acd5b24b971eca532c43c8eba750
3,337
kotlin
Apache License 2.0
src/test/kotlin/be/brammeerten/y2022/Day20Test.kt
BramMeerten
572,879,653
false
{"Kotlin": 170522}
package be.brammeerten.y2022 import be.brammeerten.readFile import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class Day20Test { @Test fun `part 1a`() { val coordinates = readInput("2022/day20/exampleInput.txt") val mix = mix(coordinates.mapIndexed { i, c -> i...
0
Kotlin
0
0
1defe58b8cbaaca17e41b87979c3107c3cb76de0
2,235
Advent-of-Code
MIT License
app/src/main/java/com/itscoder/ljuns/practise/algorithm/HeadSort.kt
ljuns
148,606,057
false
{"Java": 26841, "Kotlin": 25458}
package com.itscoder.ljuns.practise.algorithm import java.util.Collections.swap /** * Created by ljuns at 2019/1/7. * I am just a developer. * 堆排序 * 大顶堆:根节点 >= 左子节点 && 根节点 >= 右子节点 * 小顶堆:根节点 <= 左子节点 && 根节点 <= 右子节点 * 1、升序构建大顶堆,降序构建小顶堆 * 2、交换根节点和最后一个子节点,此时的最后一个子节点不再参与排序 * 3、重复 1、2 */ fun main(args: Array<Strin...
0
Java
0
0
365062b38a7ac55468b202ebeff1b760663fc676
2,515
Practise
Apache License 2.0
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day15/Day15.kt
jackploeg
736,755,380
false
{"Kotlin": 318734}
package nl.jackploeg.aoc._2023.calendar.day15 import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory import nl.jackploeg.aoc.utilities.readStringFile import javax.inject.Inject import kotlin.math.max class Day15 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { // sum ...
0
Kotlin
0
0
f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76
1,947
advent-of-code
MIT License
src/main/kotlin/pl/jpodeszwik/aoc2023/Day01.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.lang.Long.parseLong private val numbers = mapOf( "one" to '1', "two" to '2', "three" to '3', "four" to '4', "five" to '5', "six" to '6', "seven" to '7', "eight" to '8', "nine" to '9', ) private fun part1(lines: List<String>) { var sum ...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
1,587
advent-of-code
MIT License
src/main/kotlin/org/wagham/utils/CraftUtils.kt
kaironbot
566,988,243
false
{"Kotlin": 590249, "Dockerfile": 253}
package org.wagham.utils import org.wagham.db.models.Character import org.wagham.db.models.Item import org.wagham.db.models.embed.CraftRequirement fun CraftRequirement.quantityIsValid(amount: Int): Boolean = (minQuantity == null || amount >= minQuantity!!) && (maxQuantity == null || amount <= maxQuantity!!) fun ...
4
Kotlin
0
0
6d5217b5bbfcc2e1a30bf100a55c86bf3480a753
5,278
kairon-bot
MIT License
src/main/kotlin/Day04.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset import kotlin.math.max fun main() { fun winningNumbers(line: String) = line.substringBefore("|").substringAfter(":").split(Regex(" +")).filterNot { it.isEmpty() } fun personalNumbers(line: String) = line.substringAfter("|").split(Regex(" +")).filterNo...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
1,334
aoc-2023-in-kotlin
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day20/day20.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day20 import java.lang.RuntimeException import kotlin.math.sqrt data class Tile(val id: Int, val sides: Map<Side, String>, val raw: List<String>) { companion object { const val EMPTY = '.' const val FULL = '#' fun fromRaw(definition: String): Tile { v...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
9,624
advent-of-code-2020
Do What The F*ck You Want To Public License
day02/src/main/kotlin/Main.kt
rstockbridge
225,212,001
false
null
fun main() { val input = resourceFile("input.txt") .readLines()[0] .split(',') .map(String::toInt) val ioProcessor = object : IOProcessor { override fun setInput(state: List<Int>, noun: Int, verb: Int): List<Int> { val result = state.toMutableList() resu...
0
Kotlin
0
0
bcd6daf81787ed9a1d90afaa9646b1c513505d75
2,781
AdventOfCode2019
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[85]最大矩形.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //给定一个仅包含 0 和 1 、大小为 rows x cols 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。 // // // // 示例 1: // // //输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"] //,["1","0","0","1","0"]] //输出:6 //解释:最大矩形如上图所示。 // // // 示例 2: // // //输入:matrix = [] //输出:0 // // // 示例 3: // // //输入:m...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,343
MyLeetCode
Apache License 2.0
src/main/kotlin/pl/jpodeszwik/aoc2023/Day16.kt
jpodeszwik
729,812,099
false
{"Kotlin": 55101}
package pl.jpodeszwik.aoc2023 import java.util.* import kotlin.math.max enum class Direction { UP, DOWN, LEFT, RIGHT, } data class NodeWithDirection(val node: MapCoord, val direction: Direction) { val row get() = node.row val col get() = node.col fun up() = NodeWithDirection(node.up(), ...
0
Kotlin
0
0
2b90aa48cafa884fc3e85a1baf7eb2bd5b131a63
4,567
advent-of-code
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem1601/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1601 /** * LeetCode page: [1601. Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests/); */ class Solution { /* Complexity: * Time O(n * 2^M) and Space O(n+M) where M is the size of requests; *...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,726
hj-leetcode-kotlin
Apache License 2.0
src/Day05.kt
bkosm
572,912,735
false
{"Kotlin": 17839}
typealias StackOfCrates = MutableList<Char> class Ship(private val stacks: List<StackOfCrates>) { data class MoveCommand( val from: Int, val to: Int, val amount: Int, ) fun move(command: MoveCommand, moveMultiple: Boolean = false) { if (moveMultiple) { stacks[co...
0
Kotlin
0
1
3f9cccad1e5b6ba3e92cbd836a40207a2f3415a4
2,907
aoc22
Apache License 2.0
src/Day05.kt
Qdelix
574,590,362
false
null
fun main() { fun initMap() = mutableMapOf<Int, MutableList<String>>( 1 to mutableListOf(), 2 to mutableListOf(), 3 to mutableListOf(), 4 to mutableListOf(), 5 to mutableListOf(), 6 to mutableListOf(), 7 to mutableListOf(), 8 to mutableListOf(), ...
0
Kotlin
0
0
8e5c599d5071d9363c8f33b800b008875eb0b5f5
2,225
aoc22
Apache License 2.0
src/day09/Day09.kt
Ciel-MC
572,868,010
false
{"Kotlin": 55885}
package day09 import readInput import kotlin.math.absoluteValue import kotlin.reflect.KMutableProperty enum class Direction { UP, DOWN, LEFT, RIGHT; companion object { fun fromChar(char: Char): Direction = when (char) { 'U' -> UP 'D' -> DOWN 'L' -> LEFT ...
0
Kotlin
0
0
7eb57c9bced945dcad4750a7cc4835e56d20cbc8
8,205
Advent-Of-Code
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2017/Day20.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2017 import com.nibado.projects.advent.Day import com.nibado.projects.advent.resourceRegex import java.lang.Math.abs object Day20 : Day { private val input = resourceRegex(2017, 20, Regex("p=<(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)>, v=<(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)>, a=<(-?[0-9]+)...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,648
adventofcode
MIT License
src/algorithmdesignmanualbook/datastructures/NoInitializationArray.kt
realpacific
234,499,820
false
null
package algorithmdesignmanualbook.datastructures import algorithmdesignmanualbook.print import java.util.* import kotlin.random.Random import kotlin.test.assertFalse import kotlin.test.assertTrue /** * Design a data structure that allows one to search, insert, and delete an integer * X in O(1) time (i.e. , constant...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,991
algorithms
MIT License
src/Day11.kt
diego09310
576,378,549
false
{"Kotlin": 28768}
fun main() { val DIVIDERS_MULTIPIED = (2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23) data class Monkey (val id: Int) { val items: MutableList<Long> = mutableListOf() var op = ' ' lateinit var n: String var test = 0L var trueTest = 0 var falseTest = 0 var inspe...
0
Kotlin
0
0
644fee9237c01754fc1a04fef949a76b057a03fc
5,100
aoc-2022-kotlin
Apache License 2.0
src/Day04.kt
jamie23
573,156,415
false
{"Kotlin": 19195}
fun main() { data class Time( val start: Int, val end: Int ) infix fun Time.overlaps(b: Time) = start <= b.start && end >= b.end infix fun Time.singleOverlap(b: Time) = b.start in start..end || b.end in start..end fun List<String>.mapToTimes() = this.map { line -> line.spli...
0
Kotlin
0
0
cfd08064654baabea03f8bf31c3133214827289c
946
Aoc22
Apache License 2.0
src/main/algorithms/Quicksort.kt
dremme
162,006,465
false
{"Kotlin": 24254}
package algorithms /** * Sorts the array using quicksort. Elements must be greater than zero. */ fun IntArray.quicksort() { require(all { it > 0 }) quicksort(0, size - 1) } /** * Quicksort algorithm picking the highest element as pivot, * so elements are only shifted to the right if they are */ private f...
0
Kotlin
0
0
1bdd6639502e3a5317a76bb5c0c116f04123f047
743
coding-kotlin
MIT License
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day7/AmplifierController.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day7 class AmplifierController(private val program: String) { fun calculateOutputSignal(phaseSequence: List<Int>, initialSignal: Int) = phaseSequence.fold(initialSignal) { signal, input -> Amplifier(program, input).execute(signal) } ...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
2,200
advent-of-code
Apache License 2.0
src/day11/Day11.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
package day11 import readInput import java.util.regex.Pattern data class Item(var worryLevel: Long) { var ownershipHistory = mutableListOf<Int>() } class Monkey(startingItems: List<Item>, monkeyNumber: Int, val inspectEffectOperation: (Long) -> Long, val testFactor: Long, ...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
5,353
AdventOfCode2022
Apache License 2.0
codeforces/round752/c.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round752 const val M = 998244353 private fun solve(): Long { readLn() val a = readInts() val memoNext = IntArray(a.size) val memoValue = LongArray(a.size) fun solve(i: Int, next: Int): Long { if (i == -1) return 0 if (memoNext[i] == next) return memoValue[i] val countHere = (a[i] + next...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
760
competitions
The Unlicense
kotlin/src/katas/kotlin/leetcode/min_moves_to_obtain_string/MinMoves.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.min_moves_to_obtain_string import datsok.shouldEqual import org.junit.jupiter.api.Test /** * https://leetcode.com/discuss/interview-question/398026 * * You're given a string S consisting of N letters 'a' and/or 'b'. * In one move, you can swap one letter for the other ('a' for 'b' or...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,464
katas
The Unlicense
Minimum_Operations_to_Reduce_X_to_Zero_v1.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}
import java.util.* import kotlin.collections.HashSet // Time Limit Exceeded class Node(val left: Int, val right: Int, val x: Int, val level: Int) class Solution { fun minOperations(nums: IntArray, x: Int): Int { val queue = LinkedList<Node>() val visited = HashSet<Pair<Int, Int>>() queue.pu...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,474
leetcode
MIT License
src/main/kotlin/net/voldrich/aoc2022/Day04.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2022 import net.voldrich.BaseDay // https://adventofcode.com/2022/day/4 fun main() { Day04().run() } class Day04 : BaseDay() { override fun task1() : Int { return input.lines().map(::parse).map { (a,b) -> contains(a, b) || contains(b, a) }.map { if (it) ...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
1,050
advent-of-code
Apache License 2.0
src/main/kotlin/g1601_1700/s1659_maximize_grid_happiness/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1601_1700.s1659_maximize_grid_happiness // #Hard #Dynamic_Programming #Bit_Manipulation #Bitmask #Memoization // #2023_06_15_Time_181_ms_(100.00%)_Space_36.9_MB_(100.00%) class Solution { private var m = 0 private var n = 0 private lateinit var dp: Array<Array<Array<Array<IntArray>>>> private...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,541
LeetCode-in-Kotlin
MIT License
src/main/kotlin/daythirteen/DayTHirteen.kt
pauliancu97
619,525,509
false
null
package daythirteen import getLines private sealed class Token { object LeftBracket : Token() { const val CHAR = '[' } object RightBracket : Token() { const val CHAR = ']' } data class Number(val value: Int) : Token() object Separator : Token() { const val CHAR = ',' ...
0
Kotlin
0
0
78af929252f094a34fe7989984a30724fdb81498
6,956
advent-of-code-2022
MIT License
src/test/kotlin/Day18.kt
FredrikFolkesson
320,692,155
false
null
import Day18.Operator.* import org.junit.jupiter.api.Test import java.lang.IllegalArgumentException import kotlin.test.assertEquals class Day18 { @Test fun `test demo input`() { println(evaluateExpressionAdditionPrecidence("((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2")) } enum class Oper...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
6,552
advent-of-code
MIT License
plot-base-portable/src/commonMain/kotlin/jetbrains/datalore/plot/base/stat/regression/RegressionUtil.kt
randomnetcat
476,483,866
true
{"Kotlin": 5699185, "Python": 781105, "C": 2832, "CSS": 1923, "Shell": 1759, "JavaScript": 1121}
/* * Copyright (c) 2019. JetBrains s.r.o. * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ package jetbrains.datalore.plot.base.stat.regression import jetbrains.datalore.plot.base.stat.math3.Percentile import jetbrains.datalore.plot.common.data.SeriesUtil import ko...
1
Kotlin
1
0
fe960f43d39844d04a89bd12490cd2dd4dbeaa51
2,893
lets-plot
MIT License
q2/question2.kt
engividal
254,778,920
false
null
// 2. Check words with jumbled letters : // Our brain can read texts even if letters are jumbled, like the following sentence: “Yuo // cna porbalby raed tihs esaliy desptie teh msispeillgns.” Given two strings, write a // method to decide if one is a partial­permutation of the other. Consider a // partial­permutation o...
0
Kotlin
0
0
930a76acd5e87c7083785772762be829b92bb917
1,795
code-challenge
MIT License
src/main/kotlin/com/eric/leetcode/MinimumPathSum.kt
wanglikun7342
163,727,208
false
{"Kotlin": 172132, "Java": 27019}
package com.eric.leetcode class MinimumPathSum { fun minPathSum(grid: Array<IntArray>): Int { val dp = Array(grid.size) { Array(grid[0].size) { 0 } } for (i in grid.indices) { for (j in grid[0].indices) { if (i == 0 && j == 0) { dp[0][0] = grid[0][0] ...
0
Kotlin
2
8
d7fb5ff5a0a64d9ce0a5ecaed34c0400e7c2c89c
932
Leetcode-Kotlin
Apache License 2.0
src/main/kotlin/day4.kt
bfrengley
318,716,410
false
null
package aoc2020.day4 import aoc2020.util.asBlocks import aoc2020.util.loadTextResource data class Passport( val byr: String, val iyr: String, val eyr: String, val hgt: String, val hcl: String, val ecl: String, val pid: String, val cid: String?, ) { companion object { // is ...
0
Kotlin
0
0
088628f585dc3315e51e6a671a7e662d4cb81af6
2,585
aoc2020
ISC License
kotlin/src/main/kotlin/be/swsb/aoc2023/day10/PipeMap.kt
Sch3lp
724,797,927
false
{"Kotlin": 44815, "Rust": 14075}
package be.swsb.aoc2023.day10 import be.swsb.aoc2023.Debugging.debug import be.swsb.aoc2023.Point import be.swsb.aoc2023.Point.Companion.at fun solve1(input: String) = PipeMap.fromString(input).countSegments() / 2 fun solve2(input: String) = PipeMap.fromString(input).enhance().containedPoints().size data class PipeM...
0
Kotlin
0
1
dec9331d3c0976b4de09ce16fb8f3462e6f54f6e
5,808
Advent-of-Code-2023
MIT License
2021/src/day16/day16.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day16 import java.io.File fun main() { val input = File("src/day16", "day16input.txt").readLines().first() val packet = parsePacket(input) println(packet.getVersionSum()) println(packet.getValue()) } fun String.toBinaryString(): String { return this.toCharArray().joinToString("", "", "") ...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
4,207
adventofcode
Apache License 2.0
src/main/kotlin/d5/d5.kt
LaurentJeanpierre1
573,454,829
false
{"Kotlin": 118105}
package d5 import readInput import java.util.Scanner import java.util.Stack fun part1(input: List<String>): String { val (stacks, lineIte) = readStacks(input) while (lineIte.hasNext()) { val scanner = Scanner(lineIte.next()) scanner.next() // move val qte = scanner.nextInt() ...
0
Kotlin
0
0
5cf6b2142df6082ddd7d94f2dbde037f1fe0508f
2,204
aoc2022
Creative Commons Zero v1.0 Universal
src/chapter5/section3/ex32_UniqueSubstrings.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section3 import chapter3.section5.LinearProbingHashSET import edu.princeton.cs.algs4.Queue import java.math.BigInteger import java.util.* /** * 不同的子字符串 * 使用Rabin-Karp算法的思想完成练习5.2.14 * * 解:5.2.14中使用了一个字符串符号表存储子字符串,这里使用存储子字符串hash值的符号表判断 */ fun ex32_UniqueSubstrings(string: String, L: Int): Iterabl...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,307
Algorithms-4th-Edition-in-Kotlin
MIT License
2015/src/main/kotlin/day7_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut import utils.mapItems fun main() { Day7Func.run() } object Day7Func : Solution<List<Day7Func.Opcode>>() { override val name = "day7" override val parser = Parser.lines.mapItems(Opcode::parse) private fun value(name: String, ops: Map<String, Opcode>, ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
3,813
aoc_kotlin
MIT License
src/day12/Code.kt
fcolasuonno
162,470,286
false
null
package day12 import java.io.File fun main(args: Array<String>) { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
3,554
AOC2015
MIT License
src/main/kotlin/g2401_2500/s2430_maximum_deletions_on_a_string/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2430_maximum_deletions_on_a_string // #Hard #String #Dynamic_Programming #Hash_Function #String_Matching #Rolling_Hash // #2023_07_05_Time_280_ms_(100.00%)_Space_38.5_MB_(50.00%) @Suppress("NAME_SHADOWING") class Solution { private var s: String? = null private lateinit var hash: IntArray ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,952
LeetCode-in-Kotlin
MIT License
lib_algorithms_sort_kotlin/src/main/java/net/chris/lib/algorithms/sort/kotlin/KTQuickSorter.kt
chrisfang6
105,401,243
false
{"Java": 68669, "Kotlin": 26275, "C++": 12503, "CMake": 2182, "C": 1403}
package net.chris.lib.algorithms.sort.kotlin /** * Quick sort. * * @param <T> </T> */ abstract class KTQuickSorter : KTSorter() { override fun subSort(list: IntArray) { subQuickSort(list, 0, list.size - 1) } private fun subQuickSort(array: IntArray, start: Int, end: Int) { if (array ==...
0
Java
0
0
1f1c2206d5d9f0a3d6c070a7f6112f60c2714ec0
1,578
sort
Apache License 2.0
src/main/kotlin/com/askrepps/advent2021/day05/Day05.kt
askrepps
726,566,200
false
{"Kotlin": 302802}
/* * MIT License * * Copyright (c) 2021-2023 <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, modi...
0
Kotlin
0
0
89de848ddc43c5106dc6b3be290fef5bbaed2e5a
3,547
advent-of-code-kotlin
MIT License
src/day18/Day18.kt
crmitchelmore
576,065,911
false
{"Kotlin": 115199}
package day18 import helpers.ReadFile import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day18 { val rlines = ReadFile.named("src/day18/input.txt") val tlines = listOf( "2,2,2", "1,2,2", "3,2,2", "2,1,2", "2,3,2", "2,2,1",// "2,2,...
0
Kotlin
0
0
fd644d442b5ff0d2f05fbf6317c61ee9ce7b4470
12,410
adventofcode2022
MIT License
src/main/kotlin/tr/emreone/kotlin_utils/extensions/Ranges.kt
EmRe-One
442,916,831
false
{"Kotlin": 173543}
package tr.emreone.kotlin_utils.extensions val IntRange.size get() = (last - first + 1).coerceAtLeast(0) val LongRange.size get() = (last - first + 1).coerceAtLeast(0) /** * Tests whether the two [ClosedRange]s overlap or contain one another. */ infix fun <T : Comparable<T>> ClosedRange<T>.overlaps(other: ClosedRa...
0
Kotlin
0
0
aee38364ca1827666949557acb15ae3ea21881a1
4,630
kotlin-utils
Apache License 2.0
src/Day01.kt
JonahBreslow
578,314,149
false
{"Kotlin": 6978}
import java.io.File fun main() { fun readFile(file_path: String) : List<String> { val text = File(file_path).readLines() return text } fun create_elves_calories(input: List<String>): List<Int>{ var calories = mutableListOf<Int>() var counter:Int = 0 for (food in i...
0
Kotlin
0
1
c307ff29616f613473768168cc831a7a3fa346c2
1,361
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/day20/Day20.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day20 import runDay fun main() { fun part1(input: List<String>) = input.toCoordinates( decryptionKey = 1, mixCount = 1, ) fun part2(input: List<String>) = input.toCoordinates( decryptionKey = 811589153, mixCount = 10, ) (object {}).runDay( part1 = ::part1, part1Check = 3L, ...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
2,759
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/linked_list/IntersectionOfTwoLinkedLists.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.linked_list /** * Given the heads of two singly linked-lists headA and headB, * return the node at which the two lists intersect. * If the two linked lists have no intersection at all, return null. * * Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,786
algs4-leprosorium
MIT License
src/test/kotlin/dev/bogwalk/batch3/Problem33Test.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch3 import dev.bogwalk.util.tests.Benchmark import dev.bogwalk.util.tests.compareSpeed import dev.bogwalk.util.tests.getSpeed import kotlin.test.* internal class DigitCancellingFractionsTest { private val tool = DigitCancellingFractions() @Test fun `isReducedEquivalent returns true...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
5,240
project-euler-kotlin
MIT License
src/main/aoc2022/Day23.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import AMap import Pos import size class Day23(input: List<String>) { enum class Direction(private val adjacent: Pos) { North(Pos(0, -1)), South(Pos(0, 1)), West(Pos(-1, 0)), East(Pos(1, 0)); fun neighboursAreAdjacentInThisDirection(from: Pos, to: Pos): Boolean { retu...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,226
aoc
MIT License
src/main/kotlin/com/briarshore/aoc2022/day10/CathodeRayTubePuzzle.kt
steveswing
579,243,154
false
{"Kotlin": 47151}
package com.briarshore.aoc2022.day10 import com.briarshore.aoc2022.day10.Instruction.* import println import readInput import java.util.Optional enum class Instruction(val cycles: Int) { NOOP(1), ADDX(2) } data class Operation(val instruction: Instruction, val argument: Optional<Int>) fun String.toInstructions(...
0
Kotlin
0
0
a0d19d38dae3e0a24bb163f5f98a6a31caae6c05
4,016
2022-AoC-Kotlin
Apache License 2.0
src/Day04.kt
Hotkeyyy
573,026,685
false
{"Kotlin": 7830}
import java.io.File fun main() { fun part1(input: String) { val pairs = input.split("\n").map { val parts = it.split(",") Pair(parts[0].split("-").map { it.toInt() }, parts[1].split("-").map { it.toInt() }) } val count = pairs.count { val (a, b) = it ...
0
Kotlin
0
0
dfb20f1254127f99bc845e9e13631c53de8784f2
916
advent-of-code-2022
Apache License 2.0
2020/day13/day13.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 day13 import java.lang.Math.floorMod import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
3,677
adventofcode
MIT License
src/main/kotlin/com/chriswk/aoc/advent2020/Day9.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day9: AdventDay(2020, 9) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day9() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,197
adventofcode
MIT License
src/Day01.kt
punx120
573,421,386
false
{"Kotlin": 30825}
fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 for (row: String in input) { if (row.isEmpty()) { if (current > max) { max = current } current = 0 } else { ...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
1,108
aoc-2022
Apache License 2.0
src/Day09.kt
haitekki
572,959,197
false
{"Kotlin": 24688}
import kotlin.math.absoluteValue fun main() { fun calculateLocation(hLocation: Pair<Int, Int>, tLocation: Pair<Int, Int>): Pair<Int, Int> { val relativePosition = Pair(hLocation.first-tLocation.first, hLocation.second-tLocation.second) return if (relativePosition.first == 0 && relativ...
0
Kotlin
0
0
b7262133f9115f6456aa77d9c0a1e9d6c891ea0f
4,505
aoc2022
Apache License 2.0
src/cn/ancono/math/discrete/Graph.kt
140378476
105,762,795
false
{"Java": 1912158, "Kotlin": 1243514}
package cn.ancono.math.discrete typealias Node = Int typealias Edge = Pair<Node, Node> //Created by lyc at 2021-03-02 /** * Describes a general (undirected) graph that has no multiple edges. * Generally speaking, in mathematics, the graph can be * represented by a tuple of nodes(vertices) and edges(arcs): `G = (V,E...
0
Java
0
6
02c2984c10a95fcf60adcb510b4bf111c3a773bc
2,612
Ancono
MIT License
untitled/src/main/kotlin/Day6.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
class Day6(private val fileName: String) : AocSolution { override val description get() = "Day 6 - Tuning Trouble ($fileName)" private val input = InputReader(fileName).text override fun part1() = solve(input, 4) override fun part2() = solve(input, 14) } private fun solve(dataStream: String, packetSiz...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
1,755
adventofcode2022-kotlin
The Unlicense