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/Day20.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
import kotlin.math.abs fun main() { val multiplier = 811589153L val reps = 10 val input = readInput("Day20_input").map{ it.trim().toLong() * multiplier }.toList() val output = input.mapIndexed{ index, value -> Pair(index, value) }.toMutableList() val originalPosToCurrentPos = input.indices.map { in...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,564
aoc-2022
Apache License 2.0
Sudoku_Solver.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
class Solution { private var found = false fun solveSudoku(board: Array<CharArray>) { found = false val rows = Array(9) { BooleanArray(10) { it == 0 } } val columns = Array(9) { BooleanArray(10) { it == 0 } } val boxes = Array(9) { BooleanArray(10) { it == 0 } } for (i i...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
3,927
leetcode
MIT License
2022/src/main/kotlin/Day04.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day04 { fun part1(input: String): Int { return parse(input).count { (a, b) -> a.containsAll(b) || b.containsAll(a) } } fun part2(input: String): Int { return parse(input).count { (a, b) -> a.containsAny(b) } } private fun IntRange.containsAll(other: IntRange) = this.first <= other.first && t...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
793
advent-of-code
MIT License
src/main/kotlin/days/Day7.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import kotlin.math.abs class Day7 : Day(7) { private val crabs = inputString.split(",").map { it.replace(Regex("\\s+"), "").toInt() } override fun partOne(): Any { // simplification of calculateMinFuel { fuel, distance -> fuel + distance } return calculateMinFuel(Int::plus) ...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
975
aoc-2021
Creative Commons Zero v1.0 Universal
2022/src/main/kotlin/Day17.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import Day17.Direction.LEFT import Day17.Direction.RIGHT object Day17 { fun part1(input: String): Int { val chamber = Chamber(parseInput(input)) repeat(2022) { chamber.dropNext() } return chamber.height() } fun part2(input: String, testSize: Int, startingCycleSize: Int): Long { val chamber = Ch...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
5,275
advent-of-code
MIT License
src/main/kotlin/g2201_2300/s2271_maximum_white_tiles_covered_by_a_carpet/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2201_2300.s2271_maximum_white_tiles_covered_by_a_carpet // #Medium #Array #Sorting #Greedy #Binary_Search #Prefix_Sum // #2023_06_28_Time_692_ms_(100.00%)_Space_66.2_MB_(100.00%) import java.util.Arrays class Solution { fun maximumWhiteTiles(tiles: Array<IntArray>, carpetLength: Int): Int { Arra...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,243
LeetCode-in-Kotlin
MIT License
day08/kotlin/RJPlog/day2108_1_2.kts
razziel89
438,180,535
true
{"Rust": 132841, "Python": 99823, "Go": 86335, "Groovy": 67858, "TypeScript": 43504, "Kotlin": 42281, "CSS": 35030, "Shell": 18611, "C": 5260, "JavaScript": 2624, "Ruby": 2359, "Dockerfile": 2115, "HTML": 227, "C++": 153}
import java.io.File //fun main(args: Array<String>) { // tag::firstpart[] // part 1 var solution1: Int = 0 File("day2108_puzzle_input.txt").forEachLine { var instruction = it.split(" | ") var output = instruction[1].split(" ") output.forEach { if (it.length == 2 || it.length == 4 || it.length == 3 || it...
1
Rust
0
0
91a801b3c812cc3d37d6088a2544227cf158d114
2,857
aoc-2021
MIT License
src/main/kotlin/g2301_2400/s2316_count_unreachable_pairs_of_nodes_in_an_undirected_graph/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2301_2400.s2316_count_unreachable_pairs_of_nodes_in_an_undirected_graph // #Medium #Depth_First_Search #Breadth_First_Search #Graph #Union_Find // #2023_06_30_Time_981_ms_(87.50%)_Space_118.4_MB_(50.00%) class Solution { fun countPairs(n: Int, edges: Array<IntArray>): Long { val d = DSU(n) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,603
LeetCode-in-Kotlin
MIT License
2015/src/main/kotlin/com/koenv/adventofcode/Day3.kt
koesie10
47,333,954
false
null
package com.koenv.adventofcode object Day3 { public fun getTotalVisitedHouses(input: String): Int { var currentPosition = Coordinate(0, 0) val visitedHouses = arrayListOf(currentPosition) input.forEach { currentPosition += getCoordinateDelta(it) visitedHouses.add(cu...
0
Kotlin
0
0
29f3d426cfceaa131371df09785fa6598405a55f
1,719
AdventOfCode-Solutions-Kotlin
MIT License
kotlin/src/katas/kotlin/adventofcode/day5/Part1.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.adventofcode.day5 import katas.kotlin.adventofcode.day5.ParamMode.* import java.io.* fun main() { val text = File("src/katas/kotlin/adventofcode/day5/input.txt").readText() val program = text.split(",").map(String::toInt).toMutableList() val io = object: IO { override fun read...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,562
katas
The Unlicense
src/main/kotlin/ru/glukhov/aoc/Day8.kt
cobaku
576,736,856
false
{"Kotlin": 25268}
package ru.glukhov.aoc import java.io.Reader fun main() { val field = Problem.forDay("day8").use { parseTree(it) } println("Result of the first problem is ${solvePartOne(field)}") println("Result of the second problem is ${solvePartTwo(field)}") } private fun parseTree(reader: Reader): Array<IntArray> { ...
0
Kotlin
0
0
a40975c1852db83a193c173067aba36b6fe11e7b
4,066
aoc2022
MIT License
kt-string-similarity/src/commonMain/kotlin/ca/solostudios/stringsimilarity/LCS.kt
solo-studios
420,274,115
false
{"Kotlin": 201452, "SCSS": 10556, "JavaScript": 3786, "FreeMarker": 2581}
/* * kt-fuzzy - A Kotlin library for fuzzy string matching * Copyright (c) 2015-2023 solonovamax <<EMAIL>> * * The file LCS.kt is part of kotlin-fuzzy * Last modified on 19-10-2023 04:33 p.m. * * MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software an...
2
Kotlin
0
5
b3ae4f9f0e15ee38feb81b0edd88cdad68124b21
3,536
kt-fuzzy
MIT License
src/main/kotlin/year2022/day14/Problem.kt
Ddxcv98
573,823,241
false
{"Kotlin": 154634}
package year2022.day14 import IProblem import java.util.regex.Pattern import kotlin.math.max import kotlin.math.min class Problem : IProblem { private val map = mutableMapOf<Point, Char>() private val topLeft: Point private val botRight: Point init { val pattern = Pattern.compile("(\\d+),(\\d...
0
Kotlin
0
0
455bc8a69527c6c2f20362945b73bdee496ace41
3,311
advent-of-code
The Unlicense
src/main/kotlin/day22.kt
p88h
317,362,882
false
null
import java.util.* internal data class Deck(val name: String, var cards: Deque<Int>) { fun str() = cards.joinToString(",") fun copy(limit: Int = cards.size) = Deck(name, ArrayDeque(cards.take(limit))) } internal fun load(deck: String): Deck { val lines = deck.split('\n') return Deck(lines.first(), Arr...
0
Kotlin
0
5
846ad4a978823563b2910c743056d44552a4b172
1,676
aoc2020
The Unlicense
src/main/kotlin/org/flightofstairs/ctci/recusionAndDynamicProgramming/NQueens.kt
FlightOfStairs
509,587,102
false
{"Kotlin": 38930}
package org.flightofstairs.ctci.recusionAndDynamicProgramming import org.flightofstairs.ctci.treesAndGraphs.Position fun nQueens(count: Int) = (0 until count).toList().permutations().map { it.mapIndexed { row, col -> Position(row, col) } }.filter { solution -> val posIntercepts = solution.map { (it.y - it.x)...
0
Kotlin
0
0
5f4636ac342f0ee5e4f3517f7b5771e5aabe5992
1,124
FlightOfStairs-ctci
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[55]跳跃游戏.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个非负整数数组 nums ,你最初位于数组的 第一个下标 。 // // 数组中的每个元素代表你在该位置可以跳跃的最大长度。 // // 判断你是否能够到达最后一个下标。 // // // // 示例 1: // // //输入:nums = [2,3,1,1,4] //输出:true //解释:可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。 // // // 示例 2: // // //输入:nums = [3,2,1,0,4] //输出:false //解释:无论怎样,总会到达下标为 3 的位置。但该下标的最大跳跃长度是 0 , 所以永远不可能到达最后一个...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,443
MyLeetCode
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[697]数组的度.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //给定一个非空且只包含非负数的整数数组 nums,数组的度的定义是指数组里任一元素出现频数的最大值。 // // 你的任务是在 nums 中找到与 nums 拥有相同大小的度的最短连续子数组,返回其长度。 // // // // 示例 1: // // //输入:[1, 2, 2, 3, 1] //输出:2 //解释: //输入数组的度是2,因为元素1和2的出现频数最大,均为2. //连续子数组里面拥有相同度的有如下所示: //[1, 2, 2, 3, 1], [1, 2, 2, 3], [2, 2, 3, 1], [1, 2, 2], [2, 2, 3], [2, 2] //最...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,973
MyLeetCode
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_68935.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/68935 * * 3진법 뒤집기 * 문제 설명 * 자연수 n이 매개변수로 주어집니다. * n을 3진법 상에서 앞뒤로 뒤집은 후, 이를 다시 10진법으로 표현한 수를 return 하도록 solution 함수를 완성해주세요. * * 제한사항 * n은 1 이상 100,000,000 이하인 자연수입니다. * 입출력 예 * n result * 45 7 * 125 229...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,200
HoOne
Apache License 2.0
2020/10/week4/minhyungPark/algorithm/Leetcode1626.kt
Road-of-CODEr
270,008,701
false
{"Java": 199573, "C++": 42297, "JavaScript": 29489, "Kotlin": 28801, "Python": 20313, "HTML": 7981, "Shell": 7160}
/** * Leetcode 1626. Best Team With No Conflicts * https://leetcode.com/contest/weekly-contest-211/problems/best-team-with-no-conflicts/ */ import kotlin.math.max class Leetcode1626 { fun bestTeamScore(scores: IntArray, ages: IntArray): Int { val players = List(scores.size) { ages[it] to scores[it] }.s...
3
Java
11
36
1c603bc40359aeb674da9956129887e6f7c8c30a
749
stupid-week-2020
MIT License
src/day4/second/Solution.kt
verwoerd
224,986,977
false
null
package day4.second import tools.timeSolution // BLEH, I tried to solve the wrong problem where the grouped digits may be part of a group of larger then 2 fun main() = timeSolution { println("should all be false") println(isValidPassword(123444)) println(isValidPassword(277777)) println(isValidPassword(777778)...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
3,912
AoC2019
MIT License
src/Day02.kt
vitind
578,020,578
false
{"Kotlin": 60987}
// Part 1 Scoring // A = Rock (Get 1 point for choosing) // B = Paper (Get 2 point for choosing) // C = Scissors (Get 3 point for choosing) // X = Rock // Y = Paper // Z = Scissors // Lose = 0 points // Draw = 3 points // Win = 6 points // A X = Rock Rock + Draw = 1 + 3 = 4 // A Y = Rock Paper + W...
0
Kotlin
0
0
2698c65af0acd1fce51525737ab50f225d6502d1
2,366
aoc2022
Apache License 2.0
PacMan/src/main/kotlin/org.neige.codingame.pacman/Pac.kt
CedrickFlocon
106,032,469
false
null
package org.neige.codingame.pacman import org.neige.codingame.geometry.Coordinate import java.util.* data class Pac( val id: Int, val team: Team, val type: Type, val speedTurnsLeft: Int, val abilityCooldown: Int, override val coordinate: Coordinate, override va...
0
Kotlin
0
4
8d3ba5436af69a603127755613612c3540ed23a2
7,239
Codingame
Do What The F*ck You Want To Public License
src/day23/Code.kt
fcolasuonno
162,470,286
false
null
package day23 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
1,970
AOC2015
MIT License
src/main/kotlin/1360. Number of Days Between Two Dates.kts
ShreckYe
206,086,675
false
null
import kotlin.math.abs class Solution { companion object { val NUM_MONTHS = 12 val COMMON_YEAR_MONTH_DAYS = intArrayOf(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) val COMMON_YEAR_MONTH_DAYS_ACC = IntArray(NUM_MONTHS + 1).also { it[0] = 0 for (i in 0 until NUM_MON...
0
Kotlin
0
0
20e8b77049fde293b5b1b3576175eb5703c81ce2
1,623
leetcode-solutions-kotlin
MIT License
src/main/kotlin/com/github/solairerove/algs4/leprosorium/linked_list/ReverseNodesInEvenLengthGroups.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.linked_list /** * You are given the head of a linked list. * * The nodes in the linked list are sequentially assigned to non-empty groups * whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). * The length of a group is the number of nodes assi...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
2,678
algs4-leprosorium
MIT License
src/main/kotlin/com/chriswk/aoc/advent2020/Day13.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 Day13: AdventDay(2020, 13) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day13() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
1,769
adventofcode
MIT License
src/Day05.kt
gojoel
573,543,233
false
{"Kotlin": 28426}
import java.rmi.UnexpectedException import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap fun main() { val input = readInput("05") // val input = readInput("05_test") data class Step(val amount: Int, val sourceIndex: Int, val destIndex: Int) fun buildStack(row: Strin...
0
Kotlin
0
0
0690030de456dad6dcfdcd9d6d2bd9300cc23d4a
3,144
aoc-kotlin-22
Apache License 2.0
leetcode/src/offer/middle/Offer59_2.kt
zhangweizhe
387,808,774
false
null
package offer.middle import java.util.* fun main() { // 剑指 Offer 59 - II. 队列的最大值 // https://leetcode.cn/problems/dui-lie-de-zui-da-zhi-lcof/ val maxQueue = MaxQueue() println(maxQueue.max_value()) println(maxQueue.pop_front()) maxQueue.push_back(4) maxQueue.push_back(3) maxQueue.push_b...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,166
kotlin-study
MIT License
advent-of-code-2018/src/test/java/aoc/Advent10.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
package aoc import org.assertj.core.api.Assertions.assertThat import org.junit.Test import kotlin.math.absoluteValue class Advent10 { @Test fun `stars say hi in 3 seconds`() { val matrix = Array(20) { Array(20) { " " } } parseInput(testInput) .map { it.position(3) } ....
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
19,099
advent-of-code
MIT License
kotlin-leetcode/src/main/kotlin/io/github/dreamylost/Leetcode_164.kt
jxnu-liguobin
123,690,567
false
null
/* Licensed under Apache-2.0 @梦境迷离 */ package io.github.dreamylost import kotlin.math.ceil import kotlin.math.max import kotlin.math.min /** * 164. 最大间距 * * 给定一个无序的数组,找出数组在排序之后,相邻元素之间最大的差值。 * 如果数组元素个数小于 2,则返回 0。 * @author 梦境迷离 * @version 1.0,2020/11/26 */ class Leetcode_164 { companion object { /*...
13
Java
190
526
a97159e99fc6592bec5032d18391d18b84708175
3,480
cs-summary-reflection
Apache License 2.0
src/main/kotlin/day2/Day2InventoryManagementSystem.kt
Zordid
160,908,640
false
null
package day2 import shared.allPairs import shared.readPuzzle fun String.containsOneCharExactly(times: Int) = toCharArray().distinct().any { c -> count { it == c } == times } infix fun String.difference(other: String) = indices.count { this[it] != other.getOrNull(it) } + (other.length - length).coerceAtLeast(...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
847
adventofcode-kotlin-2018
Apache License 2.0
src/main/kotlin/g2001_2100/s2099_find_subsequence_of_length_k_with_the_largest_sum/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2099_find_subsequence_of_length_k_with_the_largest_sum // #Easy #Array #Hash_Table #Sorting #Heap_Priority_Queue // #2023_06_28_Time_203_ms_(100.00%)_Space_37.5_MB_(100.00%) import java.util.PriorityQueue class Solution { fun maxSubsequence(nums: IntArray, k: Int): IntArray { // Creat...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,554
LeetCode-in-Kotlin
MIT License
Algorithm/coding_interviews/Kotlin/Questions28.kt
ck76
314,136,865
false
{"HTML": 1420929, "Java": 723214, "JavaScript": 534260, "Python": 437495, "CSS": 348978, "C++": 348274, "Swift": 325819, "Go": 310456, "Less": 203040, "Rust": 105712, "Ruby": 96050, "Kotlin": 88868, "PHP": 67753, "Lua": 52032, "C": 30808, "TypeScript": 23395, "C#": 4973, "Elixir": 4945, "Pug": 1853, "PowerShell": 471, ...
package com.qiaoyuang.algorithm fun main() { val a = BinaryTreeNode(8) val b = BinaryTreeNode(6) val c = BinaryTreeNode(6) val d = BinaryTreeNode(5) val e = BinaryTreeNode(7) val f = BinaryTreeNode(7) val g = BinaryTreeNode(5) a.mLeft = b a.mRight = c b.mLeft = d b.mRight = e c.mLeft = f c.mRight = g pri...
0
HTML
0
2
2a989fe85941f27b9dd85b3958514371c8ace13b
1,451
awesome-cs
Apache License 2.0
src/main/kotlin/aoc10/Solution10.kt
rainer-gepardec
573,386,353
false
{"Kotlin": 13070}
package aoc10 import java.nio.file.Paths fun main() { val lines = Paths.get("src/main/resources/aoc_10.txt").toFile().useLines { it.toList() } println(solution1(lines)) println(solution2(lines)) } fun solution1(lines: List<String>): Int { return solve(lines) .filter { it.first == 20 || ((it....
0
Kotlin
0
0
c920692d23e8c414a996e8c1f5faeee07d0f18f2
1,329
aoc2022
Apache License 2.0
src/test/kotlin/day13/BusTest.kt
gmpalmer
319,038,590
false
null
package day13 import org.junit.jupiter.api.Test import kotlin.test.assertEquals class BusTest { @Test fun example_a() { val input = AdventUtils.getResourceAsText("/day13/example.txt").lines() val result = solveA(input) assertEquals(295, result) } @Test fun input_a() { ...
0
Kotlin
0
0
ec8eba4c247973ac6f1d1fce2bae76c5a938cda2
3,502
advent2020
Apache License 2.0
LeetCode/0017. Letter Combinations of a Phone Number/Solution.kt
InnoFang
86,413,001
false
{"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410}
/** * Created by <NAME> on 2017/12/31. */ class Solution { private val res = ArrayList<String>() private val map = hashMapOf( '0' to "", '1' to "", '2' to "abc", '3' to "def", '4' to "ghi", '5' to "jkl", '6' to "mno", ...
0
C++
8
20
2419a7d720bea1fd6ff3b75c38342a0ace18b205
1,487
algo-set
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day15.kt
EmRe-One
433,772,813
false
{"Kotlin": 118159}
package tr.emreone.adventofcode.days import tr.emreone.kotlin_utils.Logger.logger import tr.emreone.kotlin_utils.automation.Day import tr.emreone.kotlin_utils.math.Coords import java.util.* import kotlin.math.max import kotlin.math.min class Day15 : Day(15, 2021, "Chiton") { class Traversal(val location: Coords,...
0
Kotlin
0
0
516718bd31fbf00693752c1eabdfcf3fe2ce903c
5,162
advent-of-code-2021
Apache License 2.0
day_13/src/main/kotlin/io/github/zebalu/advent2020/IdealTimeFinder.kt
zebalu
317,448,231
false
null
package io.github.zebalu.advent2020 import java.math.BigInteger object IdealTimeFinder { fun findTime2(buses: List<Pair<Int, Int>>): Long = longBuses(buses) .fold(Pair(0L, 1L)) { acc, next -> applyBus(acc.first, acc.second, next.first, next.second) }.first private fun applyBus(sum: Long, interval: Long, bus: Lo...
0
Kotlin
0
1
ca54c64a07755ba044440832ba4abaa7105cdd6e
1,437
advent2020
Apache License 2.0
2020/day23/day23.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 day23 import kotlin.time.ExperimentalTime import kotlin.time.TimeSource import kotlin.time.measureTimedValue /* Input: A...
0
Julia
1
5
f2d6dbb67d41f8f2898dbbc6a98477d05473888f
4,092
adventofcode
MIT License
src/chapter1/section2/ex18_VarianceForAccumulator.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter1.section2 import edu.princeton.cs.algs4.Accumulator import extensions.inputPrompt import extensions.readAllDoubles import kotlin.math.sqrt /** * 累加器的方差 * 以下代码为Accumulator类添加了var()和stddev()方法,它们计算了addDataValue()方法的参数的方差和标准差,验证这段代码。 * 与直接对所有数据的平方求和的方法相比较,这种实现能够更好的避免四舍五入产生的误差。 * * 解:标准差计算公式简化过程参考 h...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,859
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/puzzle2/SubCommand.kt
tpoujol
436,532,129
false
{"Kotlin": 47470}
package puzzle2 fun main() { println("Hello World!") val subCommand = SubCommand() println("Result is: ${subCommand.pilotSub()}, ${subCommand.pilotSubWithAim()}") } enum class Command { forward, down, up } data class Position (val horizontal: Int, val depth: Int, val aim: Int = 0) class Sub...
0
Kotlin
0
1
6d474b30e5204d3bd9c86b50ed657f756a638b2b
1,761
aoc-2021
Apache License 2.0
src/year2020/day01/Day01.kt
fadi426
433,496,346
false
{"Kotlin": 44622}
package year2020.day01 import util.assertTrue import util.read2020DayInput fun main() { val input = read2020DayInput("Day01").map { it.toInt() } assertTrue(task01(input) == 996075) assertTrue(task02(input) == 51810360) } private fun task01(input: List<Int>): Int { input.forEachIndexed { i, primary -...
0
Kotlin
0
0
acf8b6db03edd5ff72ee8cbde0372113824833b6
1,174
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BitwiseComplement.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,199
kotlab
Apache License 2.0
src/main/kotlin/g0901_1000/s0966_vowel_spellchecker/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0966_vowel_spellchecker // #Medium #Array #String #Hash_Table #2023_05_05_Time_371_ms_(100.00%)_Space_77.8_MB_(50.00%) class Solution { private var matched: HashSet<String>? = null private var capitalizations: HashMap<String, String>? = null private var vowelErrors: HashMap<String, Str...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,696
LeetCode-in-Kotlin
MIT License
src/main/kotlin/me/consuegra/algorithms/KMultiplyIntArray.kt
aconsuegra
91,884,046
false
{"Java": 113554, "Kotlin": 79568}
package me.consuegra.algorithms /** * Given an array of integers, return an array in which each position is the result of multiplying all other entries * in the array * <p> * Examples: * [1,2,3,4] -> [24,12,8,6] * [6,-4,0,5] -> [0,0,-120,0] */ class KMultiplyIntArray { fun multiplyIntArrayOption1(input: In...
0
Java
0
7
7be2cbb64fe52c9990b209cae21859e54f16171b
1,096
algorithms-playground
MIT License
app/src/main/java/com/itscoder/ljuns/practise/algorithm/ShellSort.kt
ljuns
148,606,057
false
{"Java": 26841, "Kotlin": 25458}
package com.itscoder.ljuns.practise.algorithm /** * Created by ljuns at 2019/1/9. * I am just a developer. * 希尔排序 */ fun main(args: Array<String>) { val arr = intArrayOf(3, 1, 1, 6, 2, 4, 19) shellSort(arr) arr.forEach { println(it) } } /** * 3, 1, 1, 6, 2, 4, 19 * 1、gap = arr.size / 2,即分成 gap 组(偶...
0
Java
0
0
365062b38a7ac55468b202ebeff1b760663fc676
1,679
Practise
Apache License 2.0
src/main/kotlin/day04/day04.kt
andrew-suprun
725,670,189
false
{"Kotlin": 18354, "Python": 17857, "Dart": 8224}
package day04 import java.io.File fun main() { Part1("input.data").run() Part2("input.data").run() } data class Card(val matchingNumbers: Int, var copies: Int = 1) abstract class Day04(val fileName: String) { val cards = parseInput() fun run() { var result = 0 for ((idx, card) in c...
0
Kotlin
0
0
dd5f53e74e59ab0cab71ce7c53975695518cdbde
1,402
AoC-2023
The Unlicense
src/main/kotlin/days/Day9.kt
sicruse
315,469,617
false
null
package days class Day9 : Day(9) { private val codes: List<Long> by lazy { inputList.map { code -> code.toLong() } } private val codeAccumulation: List<Long> by lazy { var acc = 0L codes.map { code -> val result = code + acc acc += code result ...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
1,720
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
nebulosa-nova/src/main/kotlin/nebulosa/nova/almanac/Search.kt
tiagohm
568,578,345
false
{"Kotlin": 2031289, "TypeScript": 322187, "HTML": 164617, "SCSS": 10191, "Python": 2817, "JavaScript": 1119}
package nebulosa.nova.almanac import nebulosa.constants.DAYSEC /** * Returns evenly spaced numbers over a specified interval. */ fun evenlySpacedNumbers( start: Double, end: Double, n: Int, endpoint: Boolean = true, ): DoubleArray { val div = if (endpoint) n - 1 else n val res = DoubleArray(n) v...
0
Kotlin
0
1
de96a26e1a79c5b6f604d9af85311223cc28f264
2,543
nebulosa
MIT License
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/TopologicalSort.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* Use this technique to find a linear ordering of elements that have dependencies on each other. */ //1. Tasks Scheduling import java.util.* fun canFinish(numCourses: Int, prerequisites: Array<IntArray>): Boolean { // Create an adjacency list to represent the directed graph val graph = Array(numCourses) { mu...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
3,668
Kotlin-Data-Structures-Algorithms
Apache License 2.0
kotlin/src/Day05.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.Integer.parseInt import kotlin.math.abs enum class LineOrientation { VERTICAL, HORIZONTAL, DIAGONAL; } fun main() { data class Point(val x: Int, val y: Int) data class Line(val start: Point, val end: Point) { fun generateDiagonalPoints(start: Point, end: Point): List<Point...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
9,561
aoc-2021
MIT License
src/main/kotlin/me/peckb/aoc/_2021/calendar/day05/Day05.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2021.calendar.day05 import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory import javax.inject.Inject import kotlin.ranges.IntProgression.Companion.fromClosedRange data class Point(val x : Int, val y: Int) typealias Line = Pair<Point, Point> typealias Map = Array<Array<Int>> class...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,508
advent-of-code
MIT License
src/main/kotlin/net/mguenther/adventofcode/day2/Day2.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day2 import java.io.File /** * See http://adventofcode.com/2017/day/2 * * @author <NAME> (<EMAIL>) */ fun minmax(columns: List<String>): Pair<Int, Int> { val numbers = columns.map { it.toInt() } return Pair(numbers.min() ?: 0, numbers.max() ?: 0) } fun diff(minmax: Pair...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
1,417
advent-of-code-2017
MIT License
src/main/kotlin/aoc2023/Day14.kt
Ceridan
725,711,266
false
{"Kotlin": 110767, "Shell": 1955}
package aoc2023 class Day14 { fun part1(input: String): Int = parseInput(input).tiltNorth() fun part2(input: String, cycles: Int): Int { val platform = parseInput(input) val loopCheckSize = 20 val cycleScores = mutableListOf<Int>() while (cycleScores.size <= cycles) { ...
0
Kotlin
0
0
18b97d650f4a90219bd6a81a8cf4d445d56ea9e8
4,970
advent-of-code-2023
MIT License
src/main/kotlin/Day10_1.kt
vincent-mercier
726,287,758
false
{"Kotlin": 37963}
import java.io.File import java.io.InputStream enum class Direction(val deltaY: Int, val deltaX: Int, val nextDirection: Map<Char, () -> Direction?>) { S( 0, 0, mapOf( 'S' to { S } ) ), UP( -1, 0, mapOf( '|' to { UP }, ...
0
Kotlin
0
0
53b5d0a0bb65a77deb5153c8a912d292c628e048
2,997
advent-of-code-2023
MIT License
src/main/kotlin/ch/uzh/ifi/seal/bencher/analysis/coverage/Coverages.kt
chrstphlbr
227,602,878
false
{"Kotlin": 918163, "Java": 29153}
package ch.uzh.ifi.seal.bencher.analysis.coverage import arrow.core.zip import ch.uzh.ifi.seal.bencher.Method import ch.uzh.ifi.seal.bencher.analysis.change.* import ch.uzh.ifi.seal.bencher.analysis.coverage.computation.* data class Coverages( val coverages: Map<Method, Coverage> ) : CoverageComputation, Cov...
0
Kotlin
2
4
06601fb4dda3b2996c2ba9b2cd612e667420006f
3,235
bencher
Apache License 2.0
src/Day11.kt
WilsonSunBritten
572,338,927
false
{"Kotlin": 40606}
import java.math.BigInteger enum class OPERATION { MULTIPLY, ADD } fun main() { fun part1(input: List<String>): Long { val monkeyList = input.joinToString("\n") { it }.split("\n\n").map { monkeyDefinition: String -> val monkeyDefinitionLines = monkeyDefinition.split("\n") v...
0
Kotlin
0
0
363252ffd64c6dbdbef7fd847518b642ec47afb8
5,788
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2018/Day12.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2018 import com.nibado.projects.advent.Day import com.nibado.projects.advent.resourceLines object Day12 : Day { private val regex = "([#.]{5}) => (#|.)".toRegex() private val input = resourceLines(2018, 12) private val instructions = input.drop(2).map(::parse).toMap() ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,913
adventofcode
MIT License
src/day-4/part-2/solution-day-4-part-2.kts
d3ns0n
572,960,768
false
{"Kotlin": 31665}
import java.io.File fun splitAssignemntGroups(input: String): Pair<String, String> { val split = input.split(",") return Pair(split[0], split[1]) } fun splitAssignemntGroup(assignmentGroup: String): Pair<Int, Int> { val split = assignmentGroup.split("-") return Pair(split[0].toInt(), split[1].toInt())...
0
Kotlin
0
0
8e8851403a44af233d00a53b03cf45c72f252045
1,077
advent-of-code-22
MIT License
src/main/kotlin/com/rtarita/days/Day1.kt
RaphaelTarita
724,581,070
false
{"Kotlin": 64943}
package com.rtarita.days import com.rtarita.structure.AoCDay import com.rtarita.util.day import kotlinx.datetime.LocalDate object Day1 : AoCDay { override val day: LocalDate = day(1) private enum class Digits(val spelling: String, val value: Int) { ONE("one", 1), TWO("two", 2), THREE(...
0
Kotlin
0
0
4691126d970ab0d5034239949bd399c8692f3bb1
1,999
AoC-2023
Apache License 2.0
src/datastructure/heap/Heap.kt
minielectron
332,678,510
false
{"Java": 127791, "Kotlin": 48336}
package datastructure.heap class Heap { private val heap = arrayListOf<Int>() fun getHeap(): List<Int> { return heap.toList() } fun getLeftChild(index: Int): Int { return 2 * index + 1 } fun getRightChild(index: Int): Int { return 2 * index + 2 } private fun...
0
Java
0
0
f2aaff0a995071d6e188ee19f72b78d07688a672
3,907
data-structure-and-coding-problems
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2018/Day17.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2018 import com.nibado.projects.advent.Day import com.nibado.projects.advent.Point import com.nibado.projects.advent.Rectangle import com.nibado.projects.advent.collect.CharMap import com.nibado.projects.advent.resourceRegex import java.util.* import kotlin.math.max object Day17 : ...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
3,878
adventofcode
MIT License
src/main/kotlin/Problem3.kt
jimmymorales
496,703,114
false
{"Kotlin": 67323}
import kotlin.math.sqrt /** * Largest prime factor * * The prime factors of 13195 are 5, 7, 13 and 29. * What is the largest prime factor of the number 600851475143 ? * * https://projecteuler.net/problem=3 */ fun main() { println(solution3(600851475143L)) } private fun solution3(n: Long): Long { var n...
0
Kotlin
0
0
e881cadf85377374e544af0a75cb073c6b496998
919
project-euler
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[45]跳跃游戏 II.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个非负整数数组,你最初位于数组的第一个位置。 // // 数组中的每个元素代表你在该位置可以跳跃的最大长度。 // // 你的目标是使用最少的跳跃次数到达数组的最后一个位置。 // // 假设你总是可以到达数组的最后一个位置。 // // // // 示例 1: // // //输入: [2,3,1,1,4] //输出: 2 //解释: 跳到最后一个位置的最小跳跃数是 2。 //  从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。 // // // 示例 2: // // //输入: [2,3,0,1,4] //输出: 2 // // // // // ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,376
MyLeetCode
Apache License 2.0
src/main/java/challenges/educative_grokking_coding_interview/fast_slow_pointers/_1/HappyNumber.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.fast_slow_pointers._1 import challenges.util.PrintHyphens import kotlin.math.pow /** Write an algorithm to determine if a number nis happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by th...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
1,824
CodingChallenges
Apache License 2.0
plot-base/src/commonMain/kotlin/org/jetbrains/letsPlot/core/plot/base/stat/regression/RegressionUtil.kt
JetBrains
176,771,727
false
{"Kotlin": 6221641, "Python": 1158665, "Shell": 3495, "C": 3039, "JavaScript": 931, "Dockerfile": 94}
/* * Copyright (c) 2023. JetBrains s.r.o. * Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ package org.jetbrains.letsPlot.core.plot.base.stat.regression import org.jetbrains.letsPlot.core.plot.base.stat.math3.Percentile import org.jetbrains.letsPlot.core.commons.da...
128
Kotlin
46
1,373
c61353ece18358ba6c6306a0f634e3b4b036577a
3,238
lets-plot
MIT License
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/linkedList/Extensions.kt
FunkyMuse
168,687,007
false
{"Kotlin": 1728251}
package dev.funkymuse.datastructuresandalgorithms.linkedList import dev.funkymuse.datastructuresandalgorithms.stack.Stack fun <T> LinkedList<T>.printInReverse() { val stack = Stack<T>() for (node in this) { stack.push(node) } var node = stack.pop() while (node != null) { println(no...
0
Kotlin
92
771
e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1
1,961
KAHelpers
MIT License
aoc-2023/src/main/kotlin/nerok/aoc/aoc2023/day05/Day05.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2023.day05 import nerok.aoc.utils.Input import nerok.aoc.utils.append import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: String): Long { var seeds = emptyList<Long>().toMutableList() input.split("\n\n").forEach { block -> w...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
11,574
AOC
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/medium/CombinationSum2.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 40. 组合总和 II */ class CombinationSum2 { companion object { @JvmStatic fun main(args: Array<String>) { CombinationSum2().combinationSum2( intArrayOf(10, 1, 2, 7, 6, 1, 5), 8 ).forEach { it.fo...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,524
daily_algorithm
Apache License 2.0
2021/src/main/kotlin/de/skyrising/aoc2021/day16/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day16 import de.skyrising.aoc.* import java.util.* val test = TestInput("CE00C43D881120") @PuzzleName("Packet Decoder") fun PuzzleInput.part1(): Any { val bytes = HexFormat.of().parseHex(chars.trimEnd()) val data = BitBuf(bytes) val packets = mutableListOf<Packet>() while...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
3,087
aoc
MIT License
src/leetcodeProblem/leetcode/editor/en/BinaryTreeInorderTraversal.kt
faniabdullah
382,893,751
false
null
//Given the root of a binary tree, return the inorder traversal of its nodes' //values. // // // Example 1: // // //Input: root = [1,null,2,3] //Output: [1,3,2] // // // Example 2: // // //Input: root = [] //Output: [] // // // Example 3: // // //Input: root = [1] //Output: [1] // // // Example 4: // // //...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,404
dsa-kotlin
MIT License
src/main/kotlin/day22.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
import kotlin.math.max import kotlin.math.min import kotlin.random.Random val random: Random = Random(1337) fun day22 (lines: List<String>) { val bricks = parseBricks(lines) val settledBricks = settleBricks(bricks.sortedBy { it.start.z }) removeBlocks(settledBricks) } fun removeBlocks(bricks: List<Brick...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
4,061
advent_of_code_2023
MIT License
src/main/kotlin/com/vvv/engine/domain/Metadata.kt
vicol13
530,589,547
false
{"Kotlin": 40611, "Jupyter Notebook": 36031}
package com.vvv.engine.domain import java.util.* /** * This class represent container for data related to file * each file name has an associated LineMap in which * is contained data about occurrences of a word within file * * * as a chain this classes represent next structure of map * * { <word:String>: { ...
0
Kotlin
0
1
534a40c5a4c0b02f1935ba4ea976d47cd8c43485
1,687
search-engine
MIT License
src/main/kotlin/dev/bogwalk/batch5/Problem56.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.maths.powerDigitSum /** * Problem 56: Powerful Digit Sum * * https://projecteuler.net/problem=56 * * Goal: Considering natural numbers of the form a^b, where a, b < N, find the maximum digit sum. * * Constraints: 5 <= N <= 200 * * Googol: A massive number th...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
1,330
project-euler-kotlin
MIT License
advent-of-code-2022/src/main/kotlin/Point.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import kotlin.math.abs data class Point(val x: Int, val y: Int) { override fun hashCode(): Int { return x * 106039 + (y and 0xffff) } override fun equals(other: Any?): Boolean { return other is Point && other.x == x && other.y == y } } fun printMap( tiles: Map<Point, String>, ) { val maxX = tile...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,916
advent-of-code
MIT License
src/main/kotlin/leetcode/Problem2192.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode import java.util.* /** * https://leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/ */ class Problem2192 { fun getAncestors(n: Int, edges: Array<IntArray>): List<List<Int>> { val adjList = reverse(n, edges) val answer = mutableListOf<List<Int>>() ...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,302
leetcode
MIT License
solutions/src/AdjacentPairs.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/restore-the-array-from-adjacent-pairs/ */ class AdjacentPairs { fun restoreArray(adjacentPairs: Array<IntArray>): IntArray { val adjacentList = adjacentPairs.map { it.toList().sorted() }.map { Pair(it[0],it[1]) } val adjacentFreq = mutableMapOf<Int,Int>() ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,662
leetcode-solutions
MIT License
day21/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File import java.lang.IllegalStateException fun main() { val device = parseInput(readInputFile()) println("Part I: the solution is ${solvePartI(device)}.") println("Part II: the solution is ${solvePartII(device)}.") } fun readInputFile(): List<String> { return File(ClassLoader.getSyste...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
3,985
AdventOfCode2018
MIT License
src/Day04.kt
drothmaler
572,899,837
false
{"Kotlin": 15196}
fun main() { fun cleaningRanges(input: Sequence<String>) = input .map { it.split(',').map { elfRange -> val (left, right) = elfRange.split('-').map(String::toInt) left..right } ...
0
Kotlin
0
0
1fa39ebe3e4a43e87f415acaf20a991c930eae1c
1,291
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt
Earthcomputer
240,984,777
true
{"Kotlin": 1282177, "Lex": 12961, "HTML": 10151, "Groovy": 4500, "Java": 948, "Shell": 798}
/* * Minecraft Dev for IntelliJ * * https://minecraftdev.org * * Copyright (c) 2019 minecraft-dev * * MIT License */ package com.demonwav.mcdev.util import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.ReleasePart import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.TextPart /...
3
Kotlin
2
23
ab8aaeb8804c7a8b2e439e063a73cb12d0a9d4b5
5,628
MinecraftDev
MIT License
kotlin/377.Combination Sum IV(组合总和 Ⅳ).kt
learningtheory
141,790,045
false
{"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944}
/** <p> Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.</p> <p><b>Example:</b> <pre> <i><b>nums</b></i> = [1, 2, 3] <i><b>target</b></i> = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3)...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
2,570
leetcode
MIT License
src/main/kotlin/g0901_1000/s0949_largest_time_for_given_digits/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0901_1000.s0949_largest_time_for_given_digits // #Medium #String #Enumeration #2023_05_01_Time_171_ms_(100.00%)_Space_36.6_MB_(100.00%) class Solution { fun largestTimeFromDigits(arr: IntArray): String { val buf = StringBuilder() var maxHour: String? = "" for (i in 0..3) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,574
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem790/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem790 /** * LeetCode page: [790. Domino and Tromino Tiling](https://leetcode.com/problems/domino-and-tromino-tiling/); */ class Solution { /* Complexity: * Time O(n) and Space O(1); */ fun numTilings(n: Int): Int { val module = 1_000_000_007 // from the p...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,618
hj-leetcode-kotlin
Apache License 2.0
2021/src/day07/day7.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day07 import java.io.File import kotlin.math.abs fun main() { var positions = File("src/day07", "day7input.txt").readLines().single().split(",").map{it.toInt()} println(findLowestFuel(positions, ::calculateFuelLinear).first) } fun findLowestFuel(positions: List<Int>, calc : (List<Int>, Int) -> Int = ...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
1,105
adventofcode
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/easy/LongestCommonPrefix.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.easy /** * 14. 最长公共前缀 * * 编写一个函数来查找字符串数组中的最长公共前缀。 * 如果不存在公共前缀,返回空字符串 ""。 * * 示例 1: * * 输入:strs = ["flower","flow","flight"] * 输出:"fl" * 示例 2: * * 输入:strs = ["dog","racecar","car"] * 输出:"" * 解释:输入不存在公共前缀。 */ class LongestCommonPrefix { companion object { ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,439
daily_algorithm
Apache License 2.0
src/main/kotlin/Day3.kt
corentinnormand
725,992,109
false
{"Kotlin": 40576}
class Day3 : Aoc("day3.txt") { override fun one() { val input = readFile("day3.txt").lines() val numbers = mutableListOf<Int>() for (i in 0..<input[0].length) { for (j in input.indices) { val c = input[j][i] if (!c.isDigit() && c != '.') { ...
0
Kotlin
0
0
2b177a98ab112850b0f985c5926d15493a9a1373
3,666
aoc_2023
Apache License 2.0
src/main/kotlin/Day6.kt
lanrete
244,431,253
false
null
data class Star(val name: String) { override fun toString(): String { return name } val orbitedBy: MutableSet<Star> = mutableSetOf() lateinit var parent: Star } object Day6 : Solver() { override val day: Int = 6 override val inputs: List<String> = getInput() private fun processIn...
0
Kotlin
0
1
15125c807abe53230e8d0f0b2ca0e98ea72eb8fd
2,279
AoC2019-Kotlin
MIT License
src/main/kotlin/se/saidaspen/aoc/util/Lists.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.util import java.util.* import kotlin.collections.ArrayDeque fun <E> permutations(list: List<E>, length: Int? = null): Sequence<List<E>> = sequence { val n = list.size val r = length ?: list.size val indices = list.indices.toMutableList() val cycles = (n downTo (n - r)).toMut...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
3,173
adventofkotlin
MIT License
year2017/src/main/kotlin/net/olegg/aoc/year2017/day6/Day6.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2017.day6 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2017.DayOf2017 /** * See [Year 2017, Day 6](https://adventofcode.com/2017/day/6) */ object Day6 : DayOf2017(6) { override fun first(): Any? { val blocks = data.parseInts("\t")...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,725
adventofcode
MIT License
src/main/kotlin/days/Day16.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils.takeWhileInclusive class Day16 : Day(16) { override fun partOne(): Any { return sumVersionNumbers(parse(hex2Bin(inputString.trim()))) } override fun partTwo(): Any { return calculatePacketExpression(parse(hex2Bin(inputString.trim()))) } fun sumVers...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
3,740
aoc-2021
Creative Commons Zero v1.0 Universal
src/test/kotlin/Day21.kt
FredrikFolkesson
320,692,155
false
null
import org.junit.jupiter.api.Test import kotlin.test.assertEquals class Day21 { @Test fun `test demo input`() { val input = "mxmxvkd kfcds sqjhc nhms (contains dairy, fish)\n" + "trh fvjkl sbzzf mxmxvkd (contains dairy)\n" + "sqjhc fvjkl (contains s...
0
Kotlin
0
0
79a67f88e1fcf950e77459a4f3343353cfc1d48a
4,362
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/DegreeOfArray.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
1,519
kotlab
Apache License 2.0
src/questions/BestTimeStock.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * You are given an array prices where `prices[i]` is the price of a given stock on the ith day. * You want to maximize your profit by choosing a single day to buy one stock * and choosing a different day in the f...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
1,466
algorithms
MIT License
src/main/kotlin/com/leetcode/P48.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://github.com/antop-dev/algorithm/issues/280 class P48 { fun rotate(matrix: Array<IntArray>) { var p = 0 var length = matrix.size while (length > 1) { rotate(matrix, p++, length) length -= 2 } } private fun rotate(matrix:...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,143
algorithm
MIT License
src/2021-Day04.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
class Board { fun callNumber(num: Int): Boolean { // println("${num} called") var win = false for (row in rows) { if (row.remove(num)) { win = row.isEmpty() // print("${num} found in row") // if (win) // print("-- wi...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
3,617
2022-aoc-kotlin
Apache License 2.0
src/main/kotlin/Day8.kt
pavittr
317,532,861
false
null
import java.io.File import java.nio.charset.Charset fun main() { fun getAcc(inputDocs: List<String>): Pair<Int, Boolean> { val steps = inputDocs.mapIndexed { index, s -> Triple(index, s.split(" ")[0], s.split(" ")[1].toInt()) } val seen = mutableListOf<Triple<Int, String,Int>>() var st...
0
Kotlin
0
0
3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04
2,082
aoc2020
Apache License 2.0
2017/src/main/java/p6/Problem6.kt
ununhexium
113,359,669
false
null
package p6 val input = """14 0 15 12 11 11 3 5 1 6 8 4 9 1 8 4""" fun main(args: Array<String>) { val ints = input.split(" ").map { it.toInt() } println(cycle(mutableListOf(0, 2, 7, 0))) println(cycle(ints.toMutableList())) } fun cycle(currentList: MutableList<Int>): Pair<Int, Int> { val lookup = HashSet<Li...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
925
adventofcode
The Unlicense
Algorithms/Search/Ice Cream Parlor/Solution.kt
ahmed-mahmoud-abo-elnaga
449,443,709
false
{"Kotlin": 14218}
/* Problem: https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem Kotlin Language Version Tool Version : Android Studio Thoughts (Key points in algorithm): Keep track of the index and the complement value in a hasmap and as we can our input, check if we ...
0
Kotlin
1
1
a65ee26d47b470b1cb2c1681e9d49fe48b7cb7fc
1,345
HackerRank
MIT License
src/Day01.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
fun main() { fun part1(input: List<String>): Int { val elves = readElves(input) return elves.max() } fun part2(input: List<String>): Int { val elves = readElves(input) val sortedElves = elves.sortedDescending() return sortedElves[0] + sortedElves[1] + sortedElves[2]...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
964
adventofcode2022
Apache License 2.0
src/main/kotlin/Day10.kt
Vampire
572,990,104
false
{"Kotlin": 57326}
import kotlin.math.abs fun main() { fun xValues(input: List<String>) = input .map { it.split(" ") } .flatMap { when (it.first()) { "noop" -> listOf(0) "addx" -> listOf(0, it.last().toInt()) else -> error("Unexpected instruction ${it.first(...
0
Kotlin
0
0
16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f
1,688
aoc-2022
Apache License 2.0