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/aoc2023/Day16.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2023
import utils.Vertex
import utils.checkEquals
import utils.readInputAs2DCharArray
fun main(): Unit = with(Day16) {
part1(testInput)
.checkEquals(46)
part1(input)
.checkEquals(6816)
// .sendAnswer(part = 1, day = "16", year = 2023)
part2(testInput).checkEquals(51)
... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 4,755 | Kotlin-AOC-2023 | Apache License 2.0 |
src/main/kotlin/adventOfCode2023/Day05.kt | TetraTsunami | 726,140,343 | false | {"Kotlin": 80024} | package adventOfCode2023
import util.*
@Suppress("unused")
class Day05(input: String, context: RunContext = RunContext.PROD) : Day(input, context) {
data class RangeMap(val destStart: Long, val srcStart: Long, val rangeLen: Long) {
val srcEnd = srcStart + rangeLen
val destEnd = destStart + rangeLen... | 0 | Kotlin | 0 | 0 | 78d1b5d1c17122fed4f4e0a25fdacf1e62c17bfd | 4,982 | AdventOfCode2023 | Apache License 2.0 |
src/main/kotlin/org/dreambroke/Day2.kt | DreamBroke | 729,562,380 | false | {"Kotlin": 5424} | package org.dreambroke
object Day2 : BaseProblem() {
data class CubeCounts(val red: Int, val green: Int, val blue: Int)
private fun handleLine(line: String, action: (CubeCounts) -> Unit) {
val cubesGroupStr = line.substringAfter(":").trim()
val cubesGroup = cubesGroupStr.split(";")
va... | 0 | Kotlin | 0 | 0 | 5269cf089d4d367e69cf240c0acda568db6e4b22 | 2,184 | AdventOfCode2023 | Apache License 2.0 |
src/test/kotlin/com/igorwojda/integer/pyramidgenerator/Solution.kt | igorwojda | 159,511,104 | false | {"Kotlin": 254856} | package com.igorwojda.integer.pyramidgenerator
// iterative solution
private object Solution1 {
private fun generatePyramid(n: Int): List<String> {
val list = mutableListOf<String>()
val numColumns = (n * 2) - 1
(0 until n).forEach { row ->
val numHashes = (row * 2) + 1
... | 9 | Kotlin | 225 | 895 | b09b738846e9f30ad2e9716e4e1401e2724aeaec | 1,735 | kotlin-coding-challenges | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem1319/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1319
/**
* LeetCode page: [1319. Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected/);
*/
class Solution {
/* Complexity:
* Time O(E) and Space O(E) where E is the size of connections;
*/
... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,802 | hj-leetcode-kotlin | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions49.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
/**
* 求第n个丑数
*/
fun test49() {
val number = 1500
println("第${number}个丑数是:${getUglyNumber1(number)}")
println("第${number}个丑数是:${getUglyNumber2(number)}")
}
// 逐个判断法
fun getUglyNumber1(n: Int): Int {
require(n > 0) { "输入的数字必须是正整数" }
var i = 1
var number = 1
while (i <= n... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,406 | Algorithm | Apache License 2.0 |
src/main/kotlin/g0901_1000/s0918_maximum_sum_circular_subarray/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0901_1000.s0918_maximum_sum_circular_subarray
// #Medium #Array #Dynamic_Programming #Divide_and_Conquer #Queue #Monotonic_Queue
// #Dynamic_Programming_I_Day_5 #2023_04_16_Time_339_ms_(86.96%)_Space_46.4_MB_(56.52%)
class Solution {
private fun kadane(nums: IntArray, sign: Int): Int {
var currSu... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,038 | LeetCode-in-Kotlin | MIT License |
src/test/kotlin/com/eugenenosenko/coding/problems/arrays/pair_with_sum_x/FindPairWithSumXSolution.kt | eugenenosenko | 303,183,289 | false | null | package com.eugenenosenko.coding.problems.arrays.pair_with_sum_x
fun findPairSolution(arr: IntArray, sum: Int): IntArray {
// sort array first from smallest to largest
// you'll end up with an array [0,1,2,3,5,6]
arr.sort()
// create two pointers
var left = 0
var right = arr.size - 1
whil... | 0 | Kotlin | 0 | 0 | 673cc3ef6aa3c4f55b9156d14d64d47588610600 | 1,355 | coding-problems | MIT License |
leetcode/src/array/Offer03.kt | zhangweizhe | 387,808,774 | false | null | package array
fun main() {
// 剑指 Offer 03. 数组中重复的数字
// https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/
println(findRepeatNumber2(intArrayOf(2, 3, 1, 0, 2, 5, 3)))
}
fun findRepeatNumber(nums: IntArray): Int {
val list = HashSet<Int>(nums.size)
for (i in nums) {
if ... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 1,377 | kotlin-study | MIT License |
src/main/kotlin/com/github/shmvanhouten/adventofcode/day10/InstructionCentral.kt | SHMvanHouten | 109,886,692 | false | {"Kotlin": 616528} | package com.github.shmvanhouten.adventofcode.day10
import com.github.shmvanhouten.adventofcode.day10.DestinationType.OUTPUT
class InstructionCentral(private val botDispatch: BotDispatch = BotDispatch()) {
private val VALUE = "value"
fun findBotThatComparesValues(instructions: String, firstValue: Int, secon... | 0 | Kotlin | 0 | 0 | a8abc74816edf7cd63aae81cb856feb776452786 | 3,048 | adventOfCode2016 | MIT License |
src/main/kotlin/_0018_4Sum.kt | ryandyoon | 664,493,186 | false | null | // https://leetcode.com/problems/4sum
fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
val targetLong = target.toLong()
val quardruplets = mutableSetOf<Quardruplet>()
nums.sort()
for (first in 0..nums.lastIndex - 3) {
for (second in first + 1..nums.lastIndex - 2) {
var thi... | 0 | Kotlin | 0 | 0 | 7f75078ddeb22983b2521d8ac80f5973f58fd123 | 1,061 | leetcode-kotlin | MIT License |
src/main/kotlin/days/Day22.kt | mstar95 | 317,305,289 | false | null | package days
class Day22 : Day(22) {
override fun partOne(): Any {
val (deck1, deck2) = prepareInput(inputString)
val winner = play(deck1.toMutableList(), deck2.toMutableList())
return winner.foldIndexed(0) { idx, acc, elem -> acc + elem * (winner.size - idx) }
}
override fun part... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 2,674 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/Day01.kt | Cryosleeper | 572,977,188 | false | {"Kotlin": 43613} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
var max = 0
var current = 0
for (value in input) {
if (value.isEmpty()) {
max = max(max, current)
current = 0
} else {
current += value.toInt()
... | 0 | Kotlin | 0 | 0 | a638356cda864b9e1799d72fa07d3482a5f2128e | 1,054 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/advent/of/code/day04/Solution.kt | brunorene | 160,263,437 | false | null | package advent.of.code.day04
import advent.of.code.day04.State.*
import java.io.File
enum class State(val match: Regex) {
SHIFT(Regex(".+Guard #([0-9]+) begins shift")),
SLEEP(Regex(".+:([0-9]{2})\\] falls asleep")),
AWAKE(Regex(".+:([0-9]{2})\\] wakes up"))
}
fun commonPart(selector: (Map.Entry<Int, Arr... | 0 | Kotlin | 0 | 0 | 0cb6814b91038a1ab99c276a33bf248157a88939 | 1,477 | advent_of_code_2018 | The Unlicense |
year2018/src/main/kotlin/net/olegg/aoc/year2018/day17/Day17.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2018.day17
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions.D
import net.olegg.aoc.utils.Directions.L
import net.olegg.aoc.utils.Directions.R
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.utils.get
import net.olegg.aoc.utils.set
import net.olegg.aoc.year20... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 3,082 | adventofcode | MIT License |
src/questions/RotateImage.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.assertIterableSame
/**
* You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
*
* [Source](https://leetcode.com/problems/rotate-image-/)
*/
@UseCommentAsDocumentation
fun rotate(matrix: Array<IntA... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 2,259 | algorithms | MIT License |
src/questions/IteratorForCombination.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.shouldBe
import java.lang.StringBuilder
/**
* Design the CombinationIterator class:
*
* * CombinationIterator(string characters, int combinationLength) Initializes the object with a string characters of sorted distinct lowercase English letters... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 4,373 | algorithms | MIT License |
src/Day01.kt | arnoutvw | 572,860,930 | false | {"Kotlin": 33036} | fun main() {
fun part1(input: List<String>): Int {
var maxCals = 0;
var cals = 0;
input.forEach {
if(it.isBlank()) {
if(cals > maxCals) {
maxCals = cals;
}
cals = 0;
} else {
cals += I... | 0 | Kotlin | 0 | 0 | 0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4 | 1,035 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Problem33.kt | jimmymorales | 496,703,114 | false | {"Kotlin": 67323} | @file:Suppress("MagicNumber")
/**
* Digit cancelling fractions
*
* The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may
* incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
*
* We shall consider fractions like, 30/50 =... | 0 | Kotlin | 0 | 0 | e881cadf85377374e544af0a75cb073c6b496998 | 2,102 | project-euler | MIT License |
src/main/kotlin/sschr15/aocsolutions/Day6.kt | sschr15 | 317,887,086 | false | {"Kotlin": 184127, "TeX": 2614, "Python": 446} | package sschr15.aocsolutions
import sschr15.aocsolutions.util.*
import kotlin.math.sqrt
/**
* AOC 2023 [Day 6](https://adventofcode.com/2023/day/6)
* Challenge: How many ways can you get a boat down a river if you press a button for random amounts of time?
*/
object Day6 : Challenge {
@ReflectivelyUsed
ove... | 0 | Kotlin | 0 | 0 | e483b02037ae5f025fc34367cb477fabe54a6578 | 2,172 | advent-of-code | MIT License |
advent-of-code-2023/src/main/kotlin/Day24.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | // Day 24: Never Tell Me The Odds
// https://adventofcode.com/2023/day/24
import java.io.File
data class Hailstone(
val initialPosition: Triple<Long, Long, Long>,
val velocity: Triple<Long, Long, Long>,
) {
private fun getSlope(): Double {
return velocity.second / velocity.first.toDouble()
}
... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 2,767 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day18.kt | p88h | 317,362,882 | false | null | internal data class Token(val op: Char, var v: Long)
internal fun Parse(input: String): List<Token> {
return input.split(' ').chunked(2).map { Token(it[0].first(), it[1].toLong()) }
}
internal fun Evaluate(input: String, pri: Char? = null): Long {
var tokens = Parse(input)
if (pri != null) {
var t... | 0 | Kotlin | 0 | 5 | 846ad4a978823563b2910c743056d44552a4b172 | 1,302 | aoc2020 | The Unlicense |
src/main/kotlin/com/github/dangerground/aoc2020/Day6.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
class Day6(batches: List<List<String>>) {
val groups = mutableListOf<Group>()
init {
batches.forEach {
groups.add(Group(it))
}
}
fun part1(): Int {
return groups.sumOf { ... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 1,625 | adventofcode-2020 | MIT License |
app/src/main/java/com/themobilecoder/adventofcode/day4/DayFour.kt | themobilecoder | 726,690,255 | false | {"Kotlin": 323477} | package com.themobilecoder.adventofcode.day4
import com.themobilecoder.adventofcode.splitByNewLine
class DayFour {
fun solveDayFourPartOne(input: String) : Int {
val cards = input.splitByNewLine()
var sumOfPoints = 0
cards.forEach { card ->
val winningNumbers = card.getWinning... | 0 | Kotlin | 0 | 0 | b7770e1f912f52d7a6b0d13871f934096cf8e1aa | 1,949 | Advent-of-Code-2023 | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions40.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
fun test40() {
printlnResult(arrayOf(
booleanArrayOf(true, false, true, false, false),
booleanArrayOf(false, false, true, true, true),
booleanArrayOf(true, true, true, true, true),
booleanArrayOf(true, false, false, true, false)
))
}
/**
... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,013 | Algorithm | Apache License 2.0 |
src/test/kotlin/be/brammeerten/y2023/Day12Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2023
import be.brammeerten.readFileAndSplitLines
import be.brammeerten.toCharList
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
class Day12Test {
@Test
fun `part 1`() {
val num1 = readFileAndSplitLines("2023/day12/exampleInput.txt", " ")
... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 3,407 | Advent-of-Code | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day12.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.dij.Dijkstra
import io.github.clechasseur.adventofcode.dij.Graph
import io.github.clechasseur.adventofcode.util.Direction
import io.github.clechasseur.adventofcode.util.Pt
import io.github.clechasseur.adventofcode.y2022.data.Day... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 1,810 | adventofcode2022 | MIT License |
bitmanipulation/src/main/kotlin/com/kotlinground/bitmanipulation/countbits/countBits.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.bitmanipulation.countbits
/**
* To understand the solution, we remember the following two points from math:
*
* All whole numbers can be represented by 2N (even) and 2N+1 (odd).
* For a given binary number, multiplying by 2 is the same as adding a zero at the end (just as we just add a zer... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 2,025 | KotlinGround | MIT License |
android/scripts/src/main/kotlin/com/github/pgreze/versions/CandidateResolver.kt | pgreze | 535,231,537 | false | {"Kotlin": 23102} | package com.github.pgreze.versions
import java.io.File
import kotlin.math.roundToInt
fun main(args: Array<String>) {
val versions = File(args.first()).parseVersions()
val artifactToAvailableVersion: CandidateResolution = versions.groupByCandidateAvailable()
println(
">> Up-to-date artifacts:\n" +... | 0 | Kotlin | 2 | 4 | 32a03204fc65c3a2dc5cc5781383225314afa253 | 1,953 | kotlin-ci | Apache License 2.0 |
app/src/main/kotlin/advent_of_code/year_2022/day2/RockPaperScissors.kt | mavomo | 574,441,138 | false | {"Kotlin": 56468} | package advent_of_code.year_2022.day2
import advent_of_code.year_2022.day2.RPS.*
import advent_of_code.year_2022.day2.RPS.Companion.myScoreByRoundResult
import advent_of_code.year_2022.day2.RPS.Companion.myShapesCombination
import advent_of_code.year_2022.day2.RPS.Companion.scoresByShape
import advent_of_code.year_202... | 0 | Kotlin | 0 | 0 | b7fec100ea3ac63f48046852617f7f65e9136112 | 4,028 | advent-of-code | MIT License |
src/Day21second.kt | Oktosha | 573,139,677 | false | {"Kotlin": 110908} | enum class Operation(val symbol: String) {
CONSTANT("C"),
ADD("+"),
SUBSTRACT("-"),
MULTIPLY("*"),
DIVIDE("/"),
COMPARE("="),
HUMAN("H");
companion object {
private val mapping = values().associateBy(Operation::symbol)
fun fromSymbol(symbol: String): Operation {
... | 0 | Kotlin | 0 | 0 | e53eea61440f7de4f2284eb811d355f2f4a25f8c | 5,283 | aoc-2022 | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[107]二叉树的层序遍历 II.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import java.util.*
import kotlin.collections.ArrayList
//给定一个二叉树,返回其节点值自底向上的层序遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)
//
// 例如:
//给定二叉树 [3,9,20,null,null,15,7],
//
//
// 3
// / \
// 9 20
// / \
// 15 7
//
//
// 返回其自底向上的层序遍历为:
//
//
//[
// [15,7],
// [9,20],
// [3]
//]
//
// Related Topics 树 广度优先搜索
... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,805 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/day14.kt | gautemo | 433,582,833 | false | {"Kotlin": 91784} | import shared.getText
fun polymerTemplate(input: String, times: Int = 10): Long{
val (template, insertionsString) = input.split("\n\n")
val insertions = insertionsString.lines().map {
val (first, second) = it.split("->")
Pair(first.trim(), second.trim())
}
var countMap = mutableMapOf<St... | 0 | Kotlin | 0 | 0 | c50d872601ba52474fcf9451a78e3e1bcfa476f7 | 1,762 | AdventOfCode2021 | MIT License |
src/main/kotlin/days/Day13.kt | andilau | 433,504,283 | false | {"Kotlin": 137815} | package days
@AdventOfCodePuzzle(
name = "<NAME>",
url = "https://adventofcode.com/2021/day/13",
date = Date(day = 13, year = 2021)
)
class Day13(val input: List<String>) : Puzzle {
private val points = input.parsePoints()
private val instructions = input.parseInstructions()
override fun partO... | 0 | Kotlin | 0 | 0 | b3f06a73e7d9d207ee3051879b83e92b049a0304 | 2,397 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
classroom/src/main/kotlin/com/radix2/algorithms/week3/NutsAndBolts.kt | rupeshsasne | 190,130,318 | false | {"Java": 66279, "Kotlin": 50290} | package com.radix2.algorithms.week3
import java.util.*
class NutsAndBolts {
fun solve(nuts: IntArray, bolts: IntArray) {
shuffle(nuts)
shuffle(bolts)
solve(nuts, bolts, 0, nuts.size - 1)
}
private fun solve(nuts: IntArray, bolts: IntArray, lo: Int, hi: Int) {
if (lo >= h... | 0 | Java | 0 | 1 | 341634c0da22e578d36f6b5c5f87443ba6e6b7bc | 1,986 | coursera-algorithms-part1 | Apache License 2.0 |
src/problems/187-findRepeatedDnaSequences.kt | w1374720640 | 352,006,409 | false | null | package problems
/**
* 187. 重复的DNA序列 https://leetcode-cn.com/problems/repeated-dna-sequences/
*
* 解:创建两个HashSet,
* 从起点开始遍历原始字符,每次截取10个字符,如果第一个Set中不存在,则存放到第一个Set中,否则存放到第二个Set中
* 最后将第二个Set转换为List即可,
* 时间复杂度O(N),空间复杂度O(N)
*/
fun findRepeatedDnaSequences(s: String): List<String> {
val firstSet = HashSet<String>... | 0 | Kotlin | 0 | 0 | 21c96a75d13030009943474e2495f1fc5a7716ad | 4,409 | LeetCode | MIT License |
src/main/kotlin/com/psmay/exp/advent/y2021/Day09.kt | psmay | 434,705,473 | false | {"Kotlin": 242220} | package com.psmay.exp.advent.y2021
import com.psmay.exp.advent.y2021.util.Grid
import com.psmay.exp.advent.y2021.util.laterallyAdjacentCells
object Day09 {
// This top part was for part 1. It's written to process a stream of lines and produce a stream of results; it is
// meant to be suitable for maps with a... | 0 | Kotlin | 0 | 0 | c7ca54612ec117d42ba6cf733c4c8fe60689d3a8 | 3,136 | advent-2021-kotlin | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day13.kt | hughjdavey | 317,575,435 | false | null | package days
class Day13 : Day(13) {
// 3606
override fun partOne(): Any {
val timestamp = inputList.first().toInt()
val buses = inputList.last().split(",").mapNotNull { it.toIntOrNull() }.map { Bus(it) }
val bus = generateSequence(buses) { bs -> bs.map { it.loop() } }
.fi... | 0 | Kotlin | 0 | 1 | 63c677854083fcce2d7cb30ed012d6acf38f3169 | 1,476 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/g2101_2200/s2163_minimum_difference_in_sums_after_removal_of_elements/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2101_2200.s2163_minimum_difference_in_sums_after_removal_of_elements
// #Hard #Array #Dynamic_Programming #Heap_Priority_Queue
// #2023_06_26_Time_854_ms_(100.00%)_Space_79.2_MB_(100.00%)
import java.util.PriorityQueue
class Solution {
fun minimumDifference(nums: IntArray): Long {
val n = nums.s... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,480 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/github/michaelbull/advent2023/math/Distance.kt | michaelbull | 726,012,340 | false | {"Kotlin": 195941} | package com.github.michaelbull.advent2023.math
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.pow
import kotlin.math.sqrt
/**
* Calculates the two-dimensional [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance#Two_dimensions)
* between [positions][Vector2] [p] and [q] in the [x]... | 0 | Kotlin | 0 | 1 | ea0b10a9c6528d82ddb481b9cf627841f44184dd | 1,698 | advent-2023 | ISC License |
src/shreckye/coursera/algorithms/Course 3 Programming Assignment #2 Question 2.kts | ShreckYe | 205,871,625 | false | {"Kotlin": 72136} | package shreckye.coursera.algorithms
// number of bits shouldn't exceed 32
val filename = args[0]
val (numNodes, numBits, nodes) = java.io.File(filename).bufferedReader().use {
val (numNodes, numBits) = it.readLine().splitToInts()
val nodes = it.lineSequence().map {
it.splitWithWhiteSpaceAndFilterEmpt... | 0 | Kotlin | 1 | 2 | 1746af789d016a26f3442f9bf47dc5ab10f49611 | 1,577 | coursera-stanford-algorithms-solutions-kotlin | MIT License |
src/main/kotlin/com/frankandrobot/rapier/nlp/generalize.patterns.cases.kt | frankandrobot | 62,833,944 | false | null | /*
* Copyright 2016 <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 ... | 1 | Kotlin | 1 | 1 | ddbc0dab60ca595e63a701e2f8cd6694ff009adc | 8,005 | rapier | Apache License 2.0 |
src/main/kotlin/unam/ciencias/heuristicas/algorithm/Metrologist.kt | angelgladin | 203,038,278 | false | {"TSQL": 7853771, "Kotlin": 28077, "TeX": 21759} | package unam.ciencias.heuristicas.algorithm
import unam.ciencias.heuristicas.Constants.Companion.EARTH_RADIUS_IN_METERS
import unam.ciencias.heuristicas.heuristic.Solution
import unam.ciencias.heuristicas.model.City
import kotlin.math.*
/**
* TODO
*
* @property graph Pondered graph representing a the cities as ver... | 0 | TSQL | 0 | 0 | b8f3288ebc17f1a1468da4631cbf8af58f4fd28b | 6,194 | TSP-Threshold-Accepting | MIT License |
src/Day06.kt | akleemans | 574,937,934 | false | {"Kotlin": 5797} | fun main() {
fun duplicateCount(text: String): Int {
val invalid = ArrayList<Char>()
for (i in text.indices) {
val c = text[i].lowercaseChar()
if (invalid.contains(c))
continue
for (j in i + 1 until text.length) {
if (c == text[j... | 0 | Kotlin | 0 | 0 | fa4281772d89a6d1cda071db4b6fb92fff5b42f5 | 1,203 | aoc-2022-kotlin | Apache License 2.0 |
leetcode/src/sort/Q268.kt | zhangweizhe | 387,808,774 | false | null | package sort
fun main() {
// 268. 丢失的数字
// https://leetcode-cn.com/problems/missing-number/
println(missingNumber1(intArrayOf(9,6,4,2,3,5,7,0,1)))
}
private fun missingNumber(nums: IntArray): Int {
val n = nums.size
nums.sort()
var i = 0
while (i < n-1) {
if (nums[i+1] - nums[i]... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 724 | kotlin-study | MIT License |
src/Day01.kt | marciprete | 574,547,125 | false | {"Kotlin": 13734} | fun main() {
fun getCalories(input: List<String>): List<Int> {
return input.foldIndexed(ArrayList<ArrayList<Int>>(1)) { index, acc, item ->
if(index==0 || item.isEmpty()) {
acc.add(ArrayList())
} else {
acc.last().add(item.toInt())
}
... | 0 | Kotlin | 0 | 0 | 6345abc8f2c90d9bd1f5f82072af678e3f80e486 | 813 | Kotlin-AoC-2022 | Apache License 2.0 |
src/day13.kt | miiila | 725,271,087 | false | {"Kotlin": 77215} | import java.io.File
import kotlin.system.exitProcess
private const val DAY = 13
val results = mutableMapOf<List<String>, MutableList<Int>>()
fun main() {
if (!File("./day${DAY}_input").exists()) {
downloadInput(DAY)
println("Input downloaded")
exitProcess(0)
}
val transformer = { ... | 0 | Kotlin | 0 | 1 | 1cd45c2ce0822e60982c2c71cb4d8c75e37364a1 | 3,719 | aoc2023 | MIT License |
src/Day01.kt | jdappel | 575,879,747 | false | {"Kotlin": 10062} | fun main() {
fun logic(input: List<String>): Map<Int,Int> {
var elves = mutableMapOf<Int,Int>()
var tmp = 0
var cnt = 0
input.forEach { line ->
if (line.isNotEmpty()) {
tmp += line.toInt()
}
else {
elves[++cnt] = tm... | 0 | Kotlin | 0 | 0 | ddcf4f0be47ccbe4409605b37f43534125ee859d | 917 | AdventOfCodeKotlin | Apache License 2.0 |
src/main/kotlin/com/github/brpeterman/advent2022/CampSections.kt | brpeterman | 573,059,778 | false | {"Kotlin": 53108} | package com.github.brpeterman.advent2022
class CampSections {
fun countOverlaps(assignments: List<Pair<IntRange, IntRange>>): Int {
return assignments.fold(0, { total, assignment ->
if ((assignment.second.contains(assignment.first.first)) ||
(assignment.second.contains(assignmen... | 0 | Kotlin | 0 | 0 | 1407ca85490366645ae3ec86cfeeab25cbb4c585 | 1,428 | advent2022 | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day25.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.y2022.data.Day25Data
import kotlin.math.pow
object Day25 {
private val input = Day25Data.input
fun part1(): String = input.lines().map { SnafuNumber(it) }.sum().asSnafu
private val snafuValues = mapOf('2' to 2L, '... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 1,556 | adventofcode2022 | MIT License |
leetcode2/src/leetcode/CountAndSay.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* 38. 报数
* https://leetcode-cn.com/problems/count-and-say/
* Created by test
* Date 2019/5/23 1:18
* Description
* 报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 被读作 "one 1" ("一个一") , 即 11。
11 被读作 "two 1s" ("两个一"), 即 21。
21 被读作 "one 2", ... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 2,069 | leetcode | MIT License |
2018/kotlin/day16p1/src/main.kt | sgravrock | 47,810,570 | false | {"Rust": 1263100, "Swift": 1167766, "Ruby": 641843, "C++": 529504, "Kotlin": 466600, "Haskell": 339813, "Racket": 264679, "HTML": 200276, "OpenEdge ABL": 165979, "C": 89974, "Objective-C": 50086, "JavaScript": 40960, "Shell": 33315, "Python": 29781, "Elm": 22980, "Perl": 10662, "BASIC": 9264, "Io": 8122, "Awk": 5701, "... | import java.util.*
fun main(args: Array<String>) {
val start = Date()
val classLoader = Opcode::class.java.classLoader
val input = classLoader.getResource("input.txt").readText()
val instructions = Instruction.parse(input)
val matches = instructions.filter { it.behavesLike().size >= 3 }
println... | 0 | Rust | 0 | 0 | ea44adeb128cf1e3b29a2f0c8a12f37bb6d19bf3 | 2,596 | adventofcode | MIT License |
advent2022/src/main/kotlin/year2022/Day20.kt | bulldog98 | 572,838,866 | false | {"Kotlin": 132847} | package year2022
import AdventDay
import kotlin.math.absoluteValue
/**
* this swaps beforeFirst -> first -> second -> afterSecond,
* to beforeFirst -> second -> first -> afterSecond
*/
private fun swap(first: Day20.Node, second: Day20.Node) {
val beforeFirst = first.previous
val afterSecond = second.next
... | 0 | Kotlin | 0 | 0 | 02ce17f15aa78e953a480f1de7aa4821b55b8977 | 3,407 | advent-of-code | Apache License 2.0 |
src/main/kotlin/solutions/day03/Day3.kt | Dr-Horv | 112,381,975 | false | null | package solutions.day03
import solutions.Solver
import utils.Coordinate
import utils.Direction
import utils.step
data class Cursor(var x: Int, var y:Int)
fun Cursor.manhattanDistance() : Int = Math.abs(x) + Math.abs(y)
data class CircleInfo(val circle: Int, val numbers: Int)
class Day3: Solver {
override fun... | 0 | Kotlin | 0 | 2 | 975695cc49f19a42c0407f41355abbfe0cb3cc59 | 4,840 | Advent-of-Code-2017 | MIT License |
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/graphs/prim/Prim.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.datastructuresandalgorithms.graphs.prim
import dev.funkymuse.datastructuresandalgorithms.graphs.Edge
import dev.funkymuse.datastructuresandalgorithms.graphs.EdgeType
import dev.funkymuse.datastructuresandalgorithms.graphs.Graph
import dev.funkymuse.datastructuresandalgorithms.graphs.Vertex
import... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 2,185 | KAHelpers | MIT License |
src/main/kotlin/com/colinodell/advent2021/Day03.kt | colinodell | 433,864,377 | true | {"Kotlin": 111114} | package com.colinodell.advent2021
class Day03 (private val input: List<String>) {
private val bitSize = input.first().length
fun solvePart1(): Int {
// For each column / bit-index, figure out the most common bit value, and then concatenate those together
var gammaRateAsString = (0 until bitSiz... | 0 | Kotlin | 0 | 1 | a1e04207c53adfcc194c85894765195bf147be7a | 2,510 | advent-2021 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ReconstructItinerary.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,329 | kotlab | Apache License 2.0 |
src/main/kotlin/adventofcode2018/Day11ChronalCharge.kt | n81ur3 | 484,801,748 | false | {"Kotlin": 476844, "Java": 275} | package adventofcode2018
class Day11ChronalCharge
data class FuelCell(val x: Int, val y: Int, val powerLevel: Int) {
companion object {
fun forSerialNumber(x: Int, y: Int, serialNumber: Int): FuelCell =
FuelCell(x, y, computePowerLevel(x, y, serialNumber))
private fun computePowerLev... | 0 | Kotlin | 0 | 0 | fdc59410c717ac4876d53d8688d03b9b044c1b7e | 2,197 | kotlin-coding-challenges | MIT License |
src/test/kotlin/year2015/Day13.kt | abelkov | 47,995,527 | false | {"Kotlin": 48425} | package year2015
import kotlin.math.max
import kotlin.test.*
class Day13 {
@Test
fun part1() {
val map = mutableMapOf<String, MutableMap<String, Int>>()
// Alice would gain 54 happiness units by sitting next to Bob.
val regex = """(\w+) would (\w+) (\d+) happiness units by sitting next... | 0 | Kotlin | 0 | 0 | 0e4b827a742322f42c2015ae49ebc976e2ef0aa8 | 2,864 | advent-of-code | MIT License |
src/main/kotlin/io/github/sdkei/kotlin_jvm_utils/PermutationAndCombination.kt | sdkei | 150,868,041 | false | {"Kotlin": 28918} | package io.github.sdkei.kotlin_jvm_utils
/**
* Returns permutation of elements of the receiver.
*
* ```
* listOf("A", "B", "C").permutation(2) // -> [[A, B], [A, C], [B, A], [B, C], [C, A], [C, B]]
* ```
*
* @param count number of elements of permutation.
*/
fun <T> Iterable<T>.permutation(count: Int): List<Li... | 0 | Kotlin | 0 | 0 | db6280c9442bdb317db5717860f105d3371edf77 | 1,632 | KotlinJvmUtils | Apache License 2.0 |
src/main/kotlin/g2401_2500/s2416_sum_of_prefix_scores_of_strings/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2416_sum_of_prefix_scores_of_strings
// #Hard #Array #String #Counting #Trie #2023_07_04_Time_2062_ms_(50.00%)_Space_191.8_MB_(100.00%)
class Solution {
private val child: Array<Solution?> = arrayOfNulls(26)
private var ct: Int = 0
fun sumPrefixScores(words: Array<String>): IntArray {... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,290 | LeetCode-in-Kotlin | MIT License |
src/Day25.kt | wgolyakov | 572,463,468 | false | null | import kotlin.math.max
fun main() {
val toDecimalDigit = mapOf(
'2' to 2,
'1' to 1,
'0' to 0,
'-' to -1,
'=' to -2,
)
val toSnafuDigit = mapOf(
0 to "0",
1 to "1",
2 to "2",
3 to "1=",
4 to "1-",
5 to "10",
6 to "11",
7 to "12",
8 to "2=",
9 to "2-",
)
fun toDecimal(snafu: String):... | 0 | Kotlin | 0 | 0 | 789a2a027ea57954301d7267a14e26e39bfbc3c7 | 2,375 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day2.kt | dlew | 75,886,947 | false | null | class Day2 {
enum class Move {
UP,
DOWN,
LEFT,
RIGHT
}
data class Location(val x: Int, val y: Int)
companion object {
val INV = 'Z' // Invalid character
val NUMBER_GRID = arrayOf(
arrayOf('1', '2', '3'),
arrayOf('4', '5', '6'),
arrayOf('7', '8', '9')
)
... | 0 | Kotlin | 2 | 12 | 527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd | 2,256 | aoc-2016 | MIT License |
src/main/kotlin/days/Day3.kt | andilau | 573,139,461 | false | {"Kotlin": 65955} | package days
@AdventOfCodePuzzle(
name = "<NAME>",
url = "https://adventofcode.com/2022/day/3",
date = Date(day = 3, year = 2022)
)
class Day3(input: List<String>) : Puzzle {
private val rucksacks = input.asSequence().map { line -> Rucksack.from(line) }
override fun partOne(): Int = rucksacks.sum... | 0 | Kotlin | 0 | 0 | da824f8c562d72387940844aff306b22f605db40 | 1,062 | advent-of-code-2022 | Creative Commons Zero v1.0 Universal |
src/day03/Day03.kt | ubuntudroid | 571,771,936 | false | {"Kotlin": 7845} | package day03
import readInput
fun main() {
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
fun part1(input: List<String>): Int = input
.map { it.subSequence(0, it.length / 2) to it.subSequence(it.length / 2, it.length) }
.map { (firstCompartment, secondCompartment) -... | 0 | Kotlin | 0 | 0 | fde55dcf7583aac6571c0f6fc2d323d235337c27 | 1,480 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxFrequency.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,418 | kotlab | Apache License 2.0 |
kotlin/2021/round-1b/broken-clock/src/main/kotlin/Solution.kt | ShreckYe | 345,946,821 | false | null | import java.math.BigInteger
fun main() {
val t = readLine()!!.toInt()
repeat(t, ::testCase)
}
fun testCase(ti: Int) {
val (a, b, c) = readLine()!!.splitToSequence(' ').map { it.toLong() }.toList()
val ans = ans(a, b, c)
with(ans) {
println("Case #${ti + 1}: $h $m $s $n")
}
}
data cl... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 4,470 | google-code-jam | MIT License |
src/main/kotlin/g0401_0500/s0488_zuma_game/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0401_0500.s0488_zuma_game
// #Hard #String #Dynamic_Programming #Breadth_First_Search #Memoization
// #2023_01_03_Time_1727_ms_(100.00%)_Space_131.5_MB_(100.00%)
class Solution {
fun findMinStep(board: String, hand: String): Int {
return dfs(board, hand)
}
private fun dfs(board: String, ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,585 | LeetCode-in-Kotlin | MIT License |
kotlin/src/main/kotlin/com/tolchev/algo/array/435NonOverlappingIntervals.kt | VTolchev | 692,559,009 | false | {"Kotlin": 53858, "C#": 47939, "Java": 1802} | package com.tolchev.algo.array
class NonOverlappingIntervals {
fun eraseOverlapIntervals(intervals: Array<IntArray>): Int {
intervals.sortWith { a, b -> a[1].compareTo(b[1]) }
var maxFinishTime = intervals[0][1]
var removeCount = 0
for (i in 1 ..< intervals.size)
if (i... | 0 | Kotlin | 0 | 0 | c3129f23e4e7ba42b44f9fb4af39a95f4a762550 | 2,012 | algo | MIT License |
year2021/day09/basin/src/main/kotlin/com/curtislb/adventofcode/year2021/day09/basin/HeightMap.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | package com.curtislb.adventofcode.year2021.day09.basin
import com.curtislb.adventofcode.common.grid.Grid
import com.curtislb.adventofcode.common.geometry.Point
import com.curtislb.adventofcode.common.grid.forEachPointValue
import com.curtislb.adventofcode.common.grid.mutableGridOf
/**
* A map of heights at various p... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 3,757 | AdventOfCode | MIT License |
16.kts | pin2t | 725,922,444 | false | {"Kotlin": 48856, "Go": 48364, "Shell": 54} | import kotlin.math.max
val grid = System.`in`.bufferedReader().lines().toList()
val up = Pair(0, -1); val right = Pair(1, 0); val down = Pair(0, 1); val left = Pair(-1, 0)
data class Beam(val pos: Pair<Int, Int>, val dir: Pair<Int, Int>) {
private fun inside() = pos.first >= 0 && pos.second >= 0 && pos.first < gri... | 0 | Kotlin | 1 | 0 | 7575ab03cdadcd581acabd0b603a6f999119bbb6 | 2,803 | aoc2023 | MIT License |
src/Day01.kt | ivancordonm | 572,816,777 | false | {"Kotlin": 36235} | fun main() {
fun part1(input: List<String>) = input.sumarize().first()
fun part2(input: List<String>) = input.sumarize().take(3).sum()
val testInput = readInput("Day01_test")
val input = readInput("Day01")
check(part1(testInput) == 24000)
println(part1(input))
check(part2(testInput) == ... | 0 | Kotlin | 0 | 2 | dc9522fd509cb582d46d2d1021e9f0f291b2e6ce | 712 | AoC-2022 | Apache License 2.0 |
Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/kotlin/PavDev3.kt | mouredev | 581,049,695 | false | {"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ... | fun main() {
println("Introduce un número:")
val input = readLine()
try {
val n = input!!.toInt()
val result = isPrimeAndFibonacciAndParity(n)
println(result)
} catch (e: NumberFormatException) {
println("La entrada no es un número válido.")
}
}
fun isPrimeAndFibonac... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 1,144 | retos-programacion-2023 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestWordDistance.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,926 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/StampingSequence.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,479 | kotlab | Apache License 2.0 |
src/main/kotlin/be/tabs_spaces/advent2021/days/Day13.kt | janvryck | 433,393,768 | false | {"Kotlin": 58803} | package be.tabs_spaces.advent2021.days
import be.tabs_spaces.advent2021.days.Day13.Axis.X
import be.tabs_spaces.advent2021.days.Day13.Axis.Y
class Day13 : Day(13) {
private val transparentPaper = TransparentPaper.parse(inputList)
override fun partOne() = transparentPaper.fold(1).size
override fun partT... | 0 | Kotlin | 0 | 0 | f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9 | 3,005 | advent-2021 | Creative Commons Zero v1.0 Universal |
src/Day25.kt | shepard8 | 573,449,602 | false | {"Kotlin": 73637} | fun main() {
fun snafu2dec(input: String): Long {
var ret = 0L
input.forEach {
ret = 5 * ret + when (it) {
'2' -> 2L
'1' -> 1L
'0' -> 0L
'-' -> -1L
'=' -> -2L
else -> throw IllegalArgumentExce... | 0 | Kotlin | 0 | 1 | 81382d722718efcffdda9b76df1a4ea4e1491b3c | 1,142 | aoc2022-kotlin | Apache License 2.0 |
src/main/kotlin/day08/DayEight.kt | Neonader | 572,678,494 | false | {"Kotlin": 19255} | package day08
import java.io.File
val fileList = File("puzzle_input/day08.txt").useLines { it.toList() }
val forest = fileList.map { row -> row.toList().map { col -> col.code } }
val width = forest[0].size
val height = forest.size
fun visible(row: Int, col: Int): Boolean {
val tree = forest[row][col]
if (
r... | 0 | Kotlin | 0 | 3 | 4d0cb6fd285c8f5f439cb86cb881b4cd80e248bc | 2,226 | Advent-of-Code-2022 | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem673/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem673
/**
* LeetCode page: [673. Number of Longest Increasing Subsequence](https://leetcode.com/problems/number-of-longest-increasing-subsequence/);
*/
class Solution {
/* Complexity:
* Time O(N^2) and Space O(N) where N is the size of nums;
*/
fun findNumberOfLI... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,351 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2022/Day24.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2022
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import com.s13g.aoc.XY
import com.s13g.aoc.resultFrom
import java.lang.RuntimeException
/**
* --- Day 24: <NAME> ---
* https://adventofcode.com/2022/day/24
*/
class Day24 : Solver {
enum class Type { UP, DOWN, LEFT, RIGHT, WALL }
... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 3,738 | euler | Apache License 2.0 |
src/main/kotlin/days/Day7.kt | shymmq | 318,337,339 | false | null | package days
class Day7 : Day(7) {
override fun partOne(): Any {
val parents = input
// parse into a list of edges
.flatMap { ruleStr ->
val parent = "^\\w+ \\w+".toRegex().find(ruleStr)!!.value
val children = "(?<=\\d )\\w+ \\w+".toRegex().findAll(... | 0 | Kotlin | 0 | 0 | 8292e8f30eaf7a58c5dc0074f85b7339b6999e18 | 1,551 | aoc20-kotlin | Creative Commons Zero v1.0 Universal |
src/_2015/Day03.kt | albertogarrido | 572,874,945 | false | {"Kotlin": 36434} | package _2015
import _2015.CardinalDirection.*
import readInput
import java.lang.IllegalArgumentException
fun main() {
part1Tests(readInput("2015", "day03_test"))
part2Tests(readInput("2015", "day03_test_2"))
runScenario(readInput("2015", "day03"))
}
private fun runScenario(input: List<String>) {
pri... | 0 | Kotlin | 0 | 0 | ef310c5375f67d66f4709b5ac410d3a6a4889ca6 | 4,397 | AdventOfCode.kt | Apache License 2.0 |
Final Project/src/main/java/Bees.kt | edjacob25 | 166,317,485 | false | {"TeX": 77616, "Java": 42668, "Kotlin": 13806, "Rust": 7029, "C++": 3268, "C#": 3139, "MATLAB": 1783} | import BinPacking.Solver.BinPackingSolver
import BinPacking.Solver.Feature
import BinPacking.Solver.Heuristic
import BinPacking.Solver.HyperHeuristic
import BinPacking.Utils.BinPackingProblemSet
import java.util.*
import kotlin.random.Random
class Bees(
features: Array<out Feature>?,
heuristics: Array<... | 0 | TeX | 0 | 0 | 6945f257eb7ed22a97350a0f3af9153ff9caf0ec | 5,048 | ComputationalFundaments | MIT License |
src/main/kotlin/aoc2022/Day03.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
import util.illegalInput
// https://adventofcode.com/2022/day/3
object Day03 : AoCDay<Int>(
title = "Rucksack Reorganization",
part1ExampleAnswer = 157,
part1Answer = 8139,
part2ExampleAnswer = 70,
part2Answer = 2668,
) {
private class Rucksack(val items: String) ... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 1,239 | advent-of-code-kotlin | MIT License |
src/Day05.kt | hijst | 572,885,261 | false | {"Kotlin": 26466} | data class CraneMove(
val amount: Int,
val from: Int,
val to: Int
)
class Cargo(
private val stacks: MutableList<String>,
private val moves: List<CraneMove>
) {
fun stackTops(): String = stacks.map { it.last() }.joinToString("")
fun executeAllMoves9000() = moves.forEach { move ->
st... | 0 | Kotlin | 0 | 0 | 2258fd315b8933642964c3ca4848c0658174a0a5 | 1,210 | AoC-2022 | Apache License 2.0 |
src/day04/Day04.kt | Sardorbekcyber | 573,890,266 | false | {"Kotlin": 6613} | package day04
import java.io.File
fun main() {
fun part1(input: String) : Long {
val data = input.split("\n").sumOf { line ->
val parts = line.split(",")
val firstPart = parts[0].split("-")
val secondPart = parts[1].split("-")
val firstStart = firstPart.fir... | 0 | Kotlin | 0 | 2 | 56f29c8322663720bc83e7b1c6b0a362de292b12 | 1,674 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day09.kt | fonglh | 573,269,990 | false | {"Kotlin": 48950, "Ruby": 1701} | fun main() {
fun isAdjacent(head: Pair<Int, Int>, tail: Pair<Int, Int>): Boolean {
for (row in head.first-1..head.first+1) {
for (col in head.second-1..head.second+1) {
if (tail.first == row && tail.second == col)
return true
}
}
re... | 0 | Kotlin | 0 | 0 | ef41300d53c604fcd0f4d4c1783cc16916ef879b | 5,496 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/leetcode/top100LikedQuestions/medium/add_two_numbers/Main.kt | frikit | 254,842,734 | false | null | package com.leetcode.top100LikedQuestions.medium.add_two_numbers
fun main() {
println("Test case 1:")
val ll1 = ListNode(2, ListNode(4, ListNode(3, null)))
val ll2 = ListNode(5, ListNode(6, ListNode(4, null)))
println(Solution().addTwoNumbers(ll1, ll2)) //[7,0,8]
println()
println("Test case 2... | 0 | Kotlin | 0 | 0 | dda68313ba468163386239ab07f4d993f80783c7 | 2,496 | leet-code-problems | Apache License 2.0 |
app/src/main/java/com/mouredev/weeklychallenge2022/Challenge39.kt | mouredev | 440,606,306 | false | {"Kotlin": 111136} | package com.mouredev.weeklychallenge2022
/*
* Reto #39
* TOP ALGORITMOS: QUICK SORT
* Fecha publicación enunciado: 27/09/22
* Fecha publicación resolución: 03/10/22
* Dificultad: MEDIA
*
* Enunciado: Implementa uno de los algoritmos de ordenación más famosos: el "Quick Sort",
* creado por <NAME>.
* - Entender... | 796 | Kotlin | 1,060 | 1,912 | 211814959bd8e98566b2440e3e4237dd210a74f2 | 1,996 | Weekly-Challenge-2022-Kotlin | Apache License 2.0 |
src/main/java/challenges/educative_grokking_coding_interview/sliding_window/_4/LongestSubstringKDistinct.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.sliding_window._4
/**
* Given a string, find the length of the longest substring in it with no more than K distinct characters.
*
* https://www.educative.io/courses/grokking-the-coding-interview/YQQwQMWLx80
*/
object LongestSubstringKDistinct {
private fun... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 1,842 | CodingChallenges | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[714]买卖股票的最佳时机含手续费.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个整数数组 prices,其中第 i 个元素代表了第 i 天的股票价格 ;非负整数 fee 代表了交易股票的手续费用。
//
// 你可以无限次地完成交易,但是你每笔交易都需要付手续费。如果你已经购买了一个股票,在卖出它之前你就不能再继续购买股票了。
//
// 返回获得利润的最大值。
//
// 注意:这里的一笔交易指买入持有并卖出股票的整个过程,每笔交易你只需要为支付一次手续费。
//
// 示例 1:
//
// 输入: prices = [1, 3, 2, 8, 4, 9], fee = 2
//输出: 8
//解释: 能够达到的最大利润:
//在此处买入 prices[0] = 1
//在此处卖出 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,632 | MyLeetCode | Apache License 2.0 |
src/com/leecode/array/Code1.kt | zys0909 | 305,335,860 | false | null | package com.leecode.array
/**
* 一个长度为n-1的递增排序数组中的所有数字都是唯一的,并且每个数字都在范围0~n-1之内。在范围0~n-1内的n个数字中有且只有一个数字不在该数组中,请找出这个数字。
如何在一个1到100的整数数组中找到丢失的数字? google, Amazon,tencent
示例 1:
输入: [0,1,3]
输出: 2
示例 2:
输入: [0,1,2]
输出: 3
示例 3:
输入: [0,1,2,3,4,5,6,7,9]
输出: 8
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/pro... | 0 | Kotlin | 0 | 0 | 869c7c2f6686a773b2ec7d2aaa5bea2de46f1e0b | 1,176 | CodeLabs | Apache License 2.0 |
leetcode/990-SatisfiabilityOfEqualityEquations/Solution.kt | everyevery | 17,393,217 | false | null | class Solution {
class Some () {
val parent = IntArray(26) {it}
val rank = IntArray(26) {it}
fun union(a: Int, b: Int): Unit {
val pa = find(a)
val pb = find(b)
if (rank[a] > rank[b]) {
parent[pb] = pa
rank[pa] += rank[pb]
... | 0 | Roff | 3 | 1 | e9a93f228692a3f82d1d60932e7871833f9e0931 | 2,247 | algorithm_code | MIT License |
src/test/kotlin/Day2Test.kt | corentinnormand | 725,992,109 | false | {"Kotlin": 40576} | import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
class Day2Test {
@Test
fun test() {
val input = """
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6... | 0 | Kotlin | 0 | 0 | 2b177a98ab112850b0f985c5926d15493a9a1373 | 1,474 | aoc_2023 | Apache License 2.0 |
src/Day10.kt | gojoel | 573,543,233 | false | {"Kotlin": 28426} | fun main() {
val input = readInput("10")
// val input = readInput("10_test")
fun valuesAtCycle(input: List<String>, cycle: Int) : HashMap<Int, Int> {
val values: HashMap<Int, Int> = hashMapOf()
var currentCycle = 1
var value = 1
values[1] = value
for (i in 1 .. cycl... | 0 | Kotlin | 0 | 0 | 0690030de456dad6dcfdcd9d6d2bd9300cc23d4a | 1,927 | aoc-kotlin-22 | Apache License 2.0 |
app/src/main/kotlin/advent_of_code/year_2022/day1/CounterOfCalories.kt | mavomo | 574,441,138 | false | {"Kotlin": 56468} | package advent_of_code.year_2022.day1
class CounterOfCalories {
fun computeCaloriesCarriedByEachElf(caloriesMeasurements: List<String>): Map<Int, Int> {
val allMeasurements = mutableMapOf<Int, Int>()
var currentElfIndex = caloriesMeasurements.indexOfFirst { it.isEmpty() }.plus(1)
var accum... | 0 | Kotlin | 0 | 0 | b7fec100ea3ac63f48046852617f7f65e9136112 | 1,581 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NonOverlappingIntervals.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,243 | kotlab | Apache License 2.0 |
src/aoc2022/Day16_.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2022
import utils.checkEquals
import utils.sendAnswer
fun main() {
data class Valve(val name :String,val rate:Int, val que : Set<String>, var isOpen :Boolean = false)
fun part1(input: List<String>): Int {
var score = 0
var minutes = 31
val valves = mutableSetOf<Valve>()
... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 1,587 | Kotlin-AOC-2023 | Apache License 2.0 |
AdventOfCodeDay16/src/nativeMain/kotlin/Packet.kt | bdlepla | 451,510,571 | false | {"Kotlin": 165771} | sealed class BITSPacket(val version: Int) {
abstract val value: Long
companion object {
fun of(input: Iterator<Char>): BITSPacket {
val version = input.nextInt(3)
return when (val packetType = input.nextInt(3)) {
4 -> BITSLiteral.of(version, input)
... | 0 | Kotlin | 0 | 0 | 1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871 | 2,487 | AdventOfCode2021 | The Unlicense |
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day03.kt | triozer | 573,964,813 | false | {"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716} | package fr.triozer.aoc.y2022
import fr.triozer.aoc.utils.readInput
// #region part1
private fun part1(input: List<String>): Int = input.sumOf {
val (first, second) = it.chunked(it.length / 2)
val item = first.filter { c -> second.contains(c) }[0]
if (item.isUpperCase()) {
item.code - 'A'.code + 2... | 0 | Kotlin | 0 | 1 | a9f47fa0f749a40e9667295ea8a4023045793ac1 | 1,014 | advent-of-code | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.