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/Day08.kt | tsschmidt | 572,649,729 | false | {"Kotlin": 24089} | fun main() {
fun parseMap(input: List<String>): List<List<Int>> {
val map = mutableListOf<List<Int>>()
input.forEach {row ->
map.add(row.map { it.toString().toInt() })
}
return map
}
fun checkRight(r: Int, c: Int, cur: Int, map: List<List<Int>>): Boolean {
... | 0 | Kotlin | 0 | 0 | 7bb637364667d075509c1759858a4611c6fbb0c2 | 3,554 | aoc-2022 | Apache License 2.0 |
src/Day02/Day02.kt | emillourens | 572,599,575 | false | {"Kotlin": 32933} | fun main() {
fun part1(input: List<String>): Int {
var score = 0
// A - Rock, B - Paper, C - Scissors
// X - Rock, Y - Paper, Z - Scissors
for (item in input) {
val opponent = item[0].toString()
val you = item[2].toString()
when (opponent) {
... | 0 | Kotlin | 0 | 0 | 1f9739b73ef080b012e505e0a4dfe88f928e893d | 2,509 | AoC2022 | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2022/day05/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2022.day05
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
solution(false)
solution(true)
}
fun solution(retainOrder: Boolean) {
readInput(2022, 5).useLines { lineSequence ->
val lines = lineSequence.iterator()
val entries = mutableL... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 1,343 | adventofcode | Apache License 2.0 |
src/main/kotlin/pl/poznan/put/mioib/algorithm/weight/SymmetricSolutionEvaluator.kt | Azbesciak | 213,989,135 | false | null | package pl.poznan.put.mioib.algorithm.weight
class SymmetricSolutionEvaluator(
private val weightMatrix: WeightMatrix
): SolutionEvaluator {
override fun solution(sequence: IntArray): Double {
var result = 0.0
require(sequence.size >= 2) {
"instance size must be at least of siz... | 1 | Kotlin | 0 | 0 | 61e81ccbf8d6054b135f2b18db307cb8bf56f6ba | 1,803 | MetaheuristicsAndOptimization | MIT License |
Problems/Algorithms/407. Trapping Rain Water II/TrapWaterII.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun trapRainWater(heightMap: Array<IntArray>): Int {
val n = heightMap.size
val m = heightMap[0].size
val pq = PriorityQueue<IntArray>({ a, b -> a[2] - b[2] })
val visited = Array(n) { BooleanArray(m) { false } }
val neighbors = arrayOf(intArrayOf(0,... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,423 | leet-code | MIT License |
src/main/kotlin/com/sk/topicWise/dp/139. Word Break.kt | sandeep549 | 262,513,267 | false | {"Kotlin": 530613} | package com.sk.topicWise.dp
class Solution139 {
// dp, bottom-up
fun wordBreak(s: String, wordDict: List<String>): Boolean {
val dp = BooleanArray(s.length)
val dict = wordDict.toSet()
for (i in s.indices) {
for (j in i downTo 0) {
//val part1 = s.substring(... | 1 | Kotlin | 0 | 0 | cf357cdaaab2609de64a0e8ee9d9b5168c69ac12 | 2,294 | leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/year2023/day16/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2023.day16
import IProblem
import kotlin.math.max
class Problem : IProblem {
val map = javaClass
.getResourceAsStream("/2023/16.txt")!!
.bufferedReader()
.lines()
.map(String::toCharArray)
.toList()
.toTypedArray()
private val n = map.size
priv... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 2,796 | advent-of-code | The Unlicense |
src/algorithmdesignmanualbook/sorting/ColorSort.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.sorting
import algorithmdesignmanualbook.print
import utils.assertIterableSame
import java.util.*
private typealias Color = Pair<Int, String>
/**
* Assume that we are given n pairs of items as input, where the first item is a
* number and the second item is one of three colors (re... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,685 | algorithms | MIT License |
yandex/y2020/qual/a.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package yandex.y2020.qual
fun main() {
val s = readLn()
fun solve(s: String): Pair<Int, String>? {
if (s.length == 1) return 0 to s
if (s.length == 2) {
if (s[0] == s[1]) return null
return 0 to s
}
val (even, odd) = List(2) { s.filterIndexed { index, _ -> index % 2 == it } }
if (even.all { it == eve... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 857 | competitions | The Unlicense |
src/main/kotlin/com/groundsfam/advent/y2023/d19/Day19.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d19
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import java.nio.file.Path
import kotlin.io.path.div
import kotlin.io.path.useLines
import kotlin.math.max
import kotlin.math.min
sealed class Rule {
/**
* Checks if the part matches this rule's c... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 6,778 | advent-of-code | MIT License |
advent23-kt/app/src/main/kotlin/dev/rockyj/advent_kt/Day8.kt | rocky-jaiswal | 726,062,069 | false | {"Kotlin": 41834, "Ruby": 2966, "TypeScript": 2848, "JavaScript": 830, "Shell": 455, "Dockerfile": 387} | package dev.rockyj.advent_kt
private fun part2(input: List<String>) {
val mapM = mutableMapOf<String, Pair<String, String>>()
val steps = input.get(0).trim().split("").filter { it != "" }
input.subList(2, input.size).forEach { line ->
val parts = line.split(" = ")
val lr = parts.last().sp... | 0 | Kotlin | 0 | 0 | a7bc1dfad8fb784868150d7cf32f35f606a8dafe | 2,324 | advent-2023 | MIT License |
leetcode/src/linkedlist/Q706.kt | zhangweizhe | 387,808,774 | false | null | package linkedlist
fun main() {
// 706. 设计哈希映射
// https://leetcode-cn.com/problems/design-hashmap/
val myHashMap = MyHashMap()
myHashMap.put(1, 1)
println(myHashMap.get(1))
myHashMap.put(1, 2)
println(myHashMap.get(1))
println(myHashMap.get(2))
myHashMap.put(2, 5)
println(myHa... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 2,391 | kotlin-study | MIT License |
src/main/kotlin/feb_challenge2023/ShortestPathWithAltColors.kt | yvelianyk | 405,919,452 | false | {"Kotlin": 147854, "Java": 610} | package feb_challenge2023
import java.util.*
fun main() {
val result =
ShortestPathWithAltColors()
.shortestAlternatingPaths(
5,
arrayOf(intArrayOf(0, 1), intArrayOf(1, 2), intArrayOf(2, 3), intArrayOf(3, 4)),
arrayOf(intArrayOf(1, 2), intArrayOf... | 0 | Kotlin | 0 | 0 | 780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd | 2,523 | leetcode-kotlin | MIT License |
src/main/kotlin/aoc2022/Day18.kt | davidsheldon | 565,946,579 | false | {"Kotlin": 161960} | package aoc2022
import aoc2022.utils.bfs
import utils.Cube
import utils.InputUtils
import utils.toPoint3d
fun main() {
val testInput = """2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5
3,2,5
2,1,5
2,3,5""".split("\n")
fun part1(input: List<String>): Int {
val points = input.map { it.toP... | 0 | Kotlin | 0 | 0 | 5abc9e479bed21ae58c093c8efbe4d343eee7714 | 1,130 | aoc-2022-kotlin | Apache License 2.0 |
advent-of-code-2020/src/test/java/aoc/Day18OperationOrder.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | package aoc
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import java.util.*
class Day18OperationOrder {
@Test
fun noParantheses() {
assertThat(evaluate("2 * 3 + 4 * 5 ")).isEqualTo(50)
}
@Test
fun silverTest() {
assertThat(evaluate("2 * 3 + (4 * 5) ")).i... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 26,469 | advent-of-code | MIT License |
src/Day04.kt | TinusHeystek | 574,474,118 | false | {"Kotlin": 53071} | class Day04 : Day(4) {
// --- Part 1 ---
private fun getPair(pairString: String): Pair<Set<Int>, Set<Int>> {
val split = pairString.trim().split(',')
val left = split.first().split("-").let { (a, b) -> a.toInt()..b.toInt() }.toSet()
val right = split.last().split("-").let { (a, b) -> a... | 0 | Kotlin | 0 | 0 | 80b9ea6b25869a8267432c3a6f794fcaed2cf28b | 1,322 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/DestinationCity.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,108 | kotlab | Apache License 2.0 |
src/Day01.kt | nic-dgl-204-fall-2022 | 552,818,440 | false | {"Kotlin": 1372} |
fun main() {
fun part1(input: List<String>): Int {
var checkSum = 0
for (values in input) {
val num = values.split(' ')
checkSum += num.maxOf { it.toInt() } - num.minOf { it.toInt() }
}
return checkSum
}
fun part2(input: List<String>): Int {
... | 1 | Kotlin | 0 | 0 | 31188f920c36d1f3b4c80f99665557e039e436a8 | 748 | ShakshyamAdventOfCode | Apache License 2.0 |
two_sum/solution.kts | dvsu | 385,288,512 | false | {"JavaScript": 9418, "Python": 7788, "Kotlin": 4001, "Go": 3794} | import java.util.*
class Solution {
fun twoSum(nums: IntArray, target: Int): IntArray {
var numsSorted: IntArray = nums.copyOf()
numsSorted.sort()
var cursorL: Int = 0
var cursorR: Int = numsSorted.size - 1
while(true) {
if (numsSorted[cursorL] + numsSorted[cur... | 0 | JavaScript | 0 | 1 | 6004ad1402c30f6dd850eb1e72986bcedb835008 | 1,213 | leetcode | MIT License |
src/main/kotlin/days/day8/Day8.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day8
import days.Day
class Day8 : Day() {
override fun partOne(): Any {
val rawInput = readInput()
val input = rawInput[0]
val maps: MutableMap<String, Pair<String, String>> = mutableMapOf()
val newRaw = rawInput.drop(2)
newRaw.forEach {
val key =... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 3,040 | advent-of-code_2023 | The Unlicense |
src/main/kotlin/cloud/dqn/leetcode/TwoSumKt.kt | aviuswen | 112,305,062 | false | null | package cloud.dqn.leetcode
/**
*
* Kotlin implementation
* Problem: https://leetcode.com/problems/two-sum/description/
Given an array of integers, return indices of the two
numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution,
and you ma... | 0 | Kotlin | 0 | 0 | 23458b98104fa5d32efe811c3d2d4c1578b67f4b | 2,938 | cloud-dqn-leetcode | No Limit Public License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2300/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2300
/**
* LeetCode page: [2300. Successful Pairs of Spells and Potions](https://leetcode.com/problems/successful-pairs-of-spells-and-potions/);
*/
class Solution {
/* Complexity:
* Time O(NLogM+MLogM) and Space O(M) where N and M are the size of spells and potions;
... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,208 | hj-leetcode-kotlin | Apache License 2.0 |
EclipseKotlin/Kotlin/src/fun/fizzy/leetcode/easy/LeetCodeEasy.kt | PabloRosas17 | 473,046,141 | false | {"Kotlin": 90579, "Java": 47926, "C++": 19073, "C": 641} | package `fun`.fizzy.leetcode.easy
import java.util.*
/** @desc leet code easy driver is meant for easy questions */
/**
* @suppress all functions in the file will be exposed to the client
* , when a function is used by another function in the implementation
* , the IDE believes that it should be encapsulated
* ,... | 0 | Kotlin | 0 | 0 | 76476151a8788dd01c8d3c667a5a876d3ebd9812 | 25,465 | Algorithms | Apache License 2.0 |
src/Day01.kt | yalematta | 572,668,122 | false | {"Kotlin": 8442} | fun main() {
fun part1(input: List<String>): Int {
val elves = mutableListOf(0)
input.forEach { line ->
if (line.isBlank()) elves.add(0)
else elves[elves.lastIndex] += line.toIntOrNull() ?: 0
}
return elves.max()
}
fun part2(input: List<String>): Int... | 0 | Kotlin | 0 | 0 | 2b43681cc2bd02e4838b7ad1ba04ff73c0422a73 | 825 | advent-of-code-2022 | Apache License 2.0 |
app/src/test/java/com/kotaku/camerax2leetcode/ExampleUnitTest.kt | Espresso521 | 642,651,388 | false | null | package com.kotaku.camerax2leetcode
import org.junit.Assert.*
import org.junit.Test
import java.util.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun leetcode1431... | 0 | Kotlin | 0 | 0 | 1c19b46a79557d356ac28932a0ae0297d60cf2f9 | 72,627 | CameraXAndLeetCode | Apache License 2.0 |
src/main/kotlin/leetcode/Problem2182.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
import java.util.PriorityQueue
/**
* https://leetcode.com/problems/construct-string-with-repeat-limit/
*/
class Problem2182 {
fun repeatLimitedString(s: String, repeatLimit: Int): String {
data class CharCount(val char: Char, val count: Int)
val array = IntArray(26)
for ... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 2,423 | leetcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MakeTheStringGreat.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,327 | kotlab | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2018/Day3.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2018
import com.chriswk.aoc.util.dayInputAsLines
object Day3 {
val lines = dayInputAsLines(2018, 3)
val idPattern = """(\d+)""".toRegex()
fun parseClaim(line: String): Claim {
val (id, actu) = line.split("@")
val (startCoord, size) = actu.trim().split(":")
... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 1,939 | adventofcode | MIT License |
src/main/kotlin/algorithm/cpf.kt | Tiofx | 175,697,373 | false | null | package algorithm
class CPF(val init: Program) {
private val cpfChecker = CPFChecker(init)
private val parallelGroupOperatorFormatter = ParallelGroupOperatorFormatter(init)
private val sequentialGroupOperatorFormatter = SequentialGroupOperatorFormatter(init)
fun form(): List<Iteration> {
val r... | 0 | Kotlin | 0 | 0 | 32c1cc3e95940e377ed9a99293eccc871ce13864 | 9,352 | CPF | The Unlicense |
Kotlin-Knn/src/main/kotlin/dataOOP.kt | JUSTNic3 | 739,087,623 | false | {"Kotlin": 11542} | // Simplified data class
data class Movie(
val crew: String,
val country: String,
val originalLanguage: String
)
val movies: List<Movie> = loadCsvData("database/imdb_movies.csv").mapNotNull { row ->
val crew = row["crew"]
val country = row["country"]
val originalLanguage = row["orig_lang"]
i... | 0 | Kotlin | 0 | 0 | 2c74d4e143d082a61c8a72de9b1c8469fdf82b30 | 1,993 | Kotlin-Knn | MIT License |
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day03.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2021
import se.saidaspen.aoc.util.Day
fun main() = Day03.run()
object Day03 : Day(2021, 3) {
override fun part1(): Any {
val lines = input.lines().size
val gamma = StringBuilder()
for (i in 0 until input.lines()[0].length) {
val ones = input.lines(... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,375 | adventofkotlin | MIT License |
2015/src/main/kotlin/day11.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
fun main() {
Day11.run()
}
object Day11 : Solution<String>() {
override val name = "day11"
override val parser: Parser<String> = Parser { it.trim() }
fun validPwd(pwd: String): Boolean {
if ('i' in pwd || 'o' in pwd || 'l' in pwd) {
return false
}
... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,079 | aoc_kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/HalvesAreAlike.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,993 | kotlab | Apache License 2.0 |
src/main/kotlin/Day13.kt | clechasseur | 258,279,622 | false | null | import org.clechasseur.adventofcode2019.Day13Data
import org.clechasseur.adventofcode2019.IntcodeComputer
import org.clechasseur.adventofcode2019.Pt
import kotlin.math.sign
object Day13 {
private val input = Day13Data.input
private const val empty = 0L
private const val wall = 1L
private const val blo... | 0 | Kotlin | 0 | 0 | 187acc910eccb7dcb97ff534e5f93786f0341818 | 2,597 | adventofcode2019 | MIT License |
2020/day22/day22.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 day22
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
import kotlin.time.measureTimedValue
/* Input: "... | 0 | Julia | 1 | 5 | f2d6dbb67d41f8f2898dbbc6a98477d05473888f | 4,439 | adventofcode | MIT License |
src/main/kotlin/d25/d25.kt | LaurentJeanpierre1 | 573,454,829 | false | {"Kotlin": 118105} | package d25
import readInput
import java.lang.IllegalStateException
import java.util.*
val units = mapOf('0' to 0L, '1' to 1L, '2' to 2L, '-' to -1L, '=' to -2L)
fun snafuToLong(snafu : String) : Long {
var pow = 1L
var sum = 0L
for (unit in snafu.reversed()) {
sum += pow * units[unit]!!
... | 0 | Kotlin | 0 | 0 | 5cf6b2142df6082ddd7d94f2dbde037f1fe0508f | 1,127 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/day12/part1/main.kt | TheMrMilchmann | 225,375,010 | false | null | /*
* Copyright (c) 2019 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, dis... | 0 | Kotlin | 0 | 1 | 9d6e2adbb25a057bffc993dfaedabefcdd52e168 | 2,540 | AdventOfCode2019 | MIT License |
src/main/kotlin/week2/RegolithReservoir.kt | waikontse | 572,850,856 | false | {"Kotlin": 63258} | package week2
import shared.Puzzle
import java.lang.Integer.max
import java.lang.Integer.min
typealias Point = Pair<Int, Int>
typealias Cave = Array<CharArray>
class RegolithReservoir : Puzzle(14) {
companion object {
const val SAND = 'o'
const val ROCK = '#'
const val AIR = '.'
va... | 0 | Kotlin | 0 | 0 | 860792f79b59aedda19fb0360f9ce05a076b61fe | 5,583 | aoc-2022-in-kotllin | Creative Commons Zero v1.0 Universal |
src/Day08.kt | Redstonecrafter0 | 571,787,306 | false | {"Kotlin": 19087} |
fun main() {
fun part1(input: List<String>): Int {
val grid = input.map { it.toCharArray().map { i -> i.toString().toInt() } }
var visible = grid.size * 2 + grid.first().size - 2 + grid.last().size - 2
for (y in 1 until grid.lastIndex) {
for (x in 1 until grid[y].lastIndex) {
... | 0 | Kotlin | 0 | 0 | e5dbabe247457aabd6dd0f0eb2eb56f9e4c68858 | 3,170 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/org/tameter/planguage/requirements.kt | HughG | 226,680,701 | false | null | package org.tameter.planguage
/**
* The __Gist__ of an item is a short single sentence; this system uses the first paragraph of the class or object
* comment in KDoc, the summary.
*
* The __Description__ (Concept 416) of an item consists of words, diagrams, etc. which (inevitably only partly) define
* that item. ... | 0 | Kotlin | 0 | 0 | b6eaaa8392e3df3c721f9c03163bd142b8d4a747 | 3,550 | planguage-autodoc | The Unlicense |
src/main/aoc2019/Day15.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2019
import Direction
import Pos
import AMap
import org.magicwerk.brownies.collections.GapList
import kotlin.math.max
class Day15(input: List<String>) {
val program = Intcode(input.map { it.toLong() })
enum class Status(val ch: Char) {
Wall('#'),
Moved('.'),
Found('o');
... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 3,816 | aoc | MIT License |
src/main/kotlin/days/Day4.kt | felix-ebert | 433,847,657 | false | {"Kotlin": 12718} | package days
class Day4 : Day(4) {
private val scores = getScores()
override fun partOne(): Any {
return scores.first
}
override fun partTwo(): Any {
return scores.second
}
private fun parseDrawnNumbers(str: String): List<Int> {
val regex = Regex("\\d+")
retu... | 0 | Kotlin | 0 | 2 | cf7535d1c4f8a327de19660bb3a9977750894f30 | 2,041 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dayfour/DayFour.kt | Sasikuttan2163 | 434,187,872 | false | {"Kotlin": 7716} | package dayfour
import myutilities.Utils
import java.util.*
import kotlin.collections.ArrayList
fun main(){
val data = Utils.readFile("dayfour.txt")
val order = data[0].split(",").map { it.toInt() }.toList()
val matrix = Array(5) { IntArray(5) }
val matrices = ArrayList<Array<IntArray>>()
var ind... | 0 | Kotlin | 0 | 1 | 2894d4a5753472e5759b8d74d7480a611d0f05e5 | 1,985 | AoC-2021-Solutions-In-Kotlin | MIT License |
solver/src/commonMain/kotlin/org/hildan/sudoku/solver/HumanSolver.kt | joffrey-bion | 9,559,943 | false | {"Kotlin": 51198, "HTML": 187} | package org.hildan.sudoku.solver
import org.hildan.sudoku.model.Grid
import org.hildan.sudoku.model.removeValueFromSistersCandidates
import org.hildan.sudoku.solver.techniques.*
data class SolveResult(
val solved: Boolean,
val steps: List<Step>,
) {
override fun toString(): String = steps.joinToString("\n... | 0 | Kotlin | 0 | 0 | 441fbb345afe89b28df9fe589944f40dbaccaec5 | 2,014 | sudoku-solver | MIT License |
src/Day06.kt | dmarcato | 576,511,169 | false | {"Kotlin": 36664} | fun main() {
fun findPacket(input: List<String>, numOfDistinct: Int): Int {
return input.first().asSequence().windowed(numOfDistinct, 1, true) { chunk ->
chunk.any { c ->
chunk.count { it == c } > 1
}
}.indexOfFirst { !it } + numOfDistinct
}
fun part1... | 0 | Kotlin | 0 | 0 | 6abd8ca89a1acce49ecc0ca8a51acd3969979464 | 804 | aoc2022 | Apache License 2.0 |
src/chapter5/section2/ex8_OrderedOperationsForTries.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter5.section2
import chapter3.section1.OrderedST
import chapter5.section1.Alphabet
import edu.princeton.cs.algs4.Queue
/**
* 单词查找树的有序性操作
* 为TrieST实现floor()、ceiling()、rank()和select()方法(来自第3章标准有序符号表的API)
*/
class OrderedTrieST<V : Any>(alphabet: Alphabet) : TrieST<V>(alphabet), OrderedST<String, V> {
... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 8,427 | Algorithms-4th-Edition-in-Kotlin | MIT License |
src/Day01.kt | irshea846 | 576,767,042 | false | null | fun main() {
fun part1(input: List<String>): Int {
return input.size
}
fun part2(input: List<List<Int>>): Int {
return input.size
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
check(part1(testInput) == 1)
... | 0 | Kotlin | 0 | 0 | b48414d0cf9aedbb68e7423b7a01399b9a709659 | 813 | AoC | Apache License 2.0 |
src/cn/ancono/math/algebra/DecomposedPoly.kt | 140378476 | 105,762,795 | false | {"Java": 1912158, "Kotlin": 1243514} | package cn.ancono.math.algebra
import cn.ancono.math.numberModels.api.RealCalculator
import cn.ancono.math.numberModels.structure.Polynomial
/**
* Describes a polynomial that has the form of
* > (p1)^n1 * (p2)^n2 ... * (p^k)^nk
* where pi is a polynomial.
*
* Created at 2018/12/13 18:51
* @author liyicheng
*... | 0 | Java | 0 | 6 | 02c2984c10a95fcf60adcb510b4bf111c3a773bc | 2,348 | Ancono | MIT License |
src/Day05.kt | hrach | 572,585,537 | false | {"Kotlin": 32838} | @file:Suppress("NAME_SHADOWING")
fun main() {
data class Command(
val amount: Int,
val from: Int,
val to: Int,
)
fun parse(input: List<String>): Pair<List<MutableList<Char>>, List<Command>> {
val input = input.toMutableList()
val state = MutableList(
((in... | 0 | Kotlin | 0 | 1 | 40b341a527060c23ff44ebfe9a7e5443f76eadf3 | 2,214 | aoc-2022 | Apache License 2.0 |
src/pl/shockah/aoc/y2019/Day4.kt | Shockah | 159,919,224 | false | null | package pl.shockah.aoc.y2019
import pl.shockah.aoc.AdventTask
class Day4: AdventTask<IntRange, Int, Int>(2019, 4) {
override fun parseInput(rawInput: String): IntRange {
val split = rawInput.split("-")
return split[0].toInt()..split[1].toInt()
}
private fun <T> Iterable<T>.groupDuplicates(): List<Pair<T, Int>... | 0 | Kotlin | 0 | 0 | 9abb1e3db1cad329cfe1e3d6deae2d6b7456c785 | 1,755 | Advent-of-Code | Apache License 2.0 |
src/main/kotlin/Amphipod_23.kt | Flame239 | 433,046,232 | false | {"Kotlin": 64209} | import AmphipodType.valueOf
import kotlin.math.abs
import kotlin.math.min
private fun getAmphipodsState(filename: String, roomSize: Int): List<Amphipod> {
return readFile(filename).split("\n").drop(2).take(roomSize).flatMapIndexed { roomPos, s ->
s.filter { it != '#' && it != ' ' }.mapIndexed { room, c -> ... | 0 | Kotlin | 0 | 0 | ef4b05d39d70a204be2433d203e11c7ebed04cec | 7,794 | advent-of-code-2021 | Apache License 2.0 |
src/advent/of/code/ThirdPuzzle.kt | 1nco | 725,911,911 | false | {"Kotlin": 112713, "Shell": 103} | package advent.of.code
import java.io.File
class ThirdPuzzle {
companion object {
private val day = "3";
private var input: MutableList<String> = arrayListOf();
private var sum = 0;
private var sumSecond = 0;
private var adjacentList = arrayListOf<Adjacent>();
... | 0 | Kotlin | 0 | 0 | 0dffdeba1ebe0b44d24f94895f16f0f21ac8b7a3 | 5,207 | advent-of-code | Apache License 2.0 |
problems/binary-search-tree-check/binary-search-tree-check.kt | mre | 14,571,395 | false | {"Python": 149850, "JavaScript": 52163, "Rust": 22731, "Java": 18047, "Kotlin": 17919, "C++": 16563, "CoffeeScript": 16079, "PHP": 14313, "C#": 14295, "Shell": 11341, "Go": 8067, "Ruby": 5883, "C": 4745, "F#": 4418, "Swift": 1811, "Haskell": 1585, "TypeScript": 1405, "Scala": 1394, "Dart": 1025, "LOLCODE": 647, "Julia"... | import java.util.Stack
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class TreeStack<T : Comparable<T>>(treeNode: TreeNode<T>) : Stack<Triple<TreeNode<T>, T?, T?>>() {
init {
push(treeNode)
}
inline fun drain(action: TreeStack<T>.(node: TreeNode<T>, min: T?, max: T?) -> Unit) {
... | 8 | Python | 413 | 1,636 | e879e0949a24da5ebc80e9319683baabf8bb0a37 | 2,225 | the-coding-interview | MIT License |
src/main/kotlin/day4/Day4.kt | jakubgwozdz | 571,298,326 | false | {"Kotlin": 85100} | package day4
import execute
import parseRecords
import readAllText
fun main() {
val input = readAllText("local/day2_input.txt")
val test = """
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8
""".trimIndent()
execute(::part1, test, 157)
execute(::part... | 0 | Kotlin | 0 | 0 | 7589942906f9f524018c130b0be8976c824c4c2a | 1,083 | advent-of-code-2022 | MIT License |
src/me/bytebeats/algo/kt/Solution12.kt | bytebeats | 251,234,289 | false | null | package me.bytebeats.algo.kt
import me.bytebeats.algs.ds.TreeNode
/**
* @Author bytebeats
* @Email <<EMAIL>>
* @Github https://github.com/bytebeats
* @Created on 2020/12/14 20:31
* @Version 1.0
* @Description TO-DO
*/
class Solution12 {
fun findSubArray(arr: IntArray, target: Int): Int {
var minL ... | 0 | Kotlin | 0 | 1 | 7cf372d9acb3274003bb782c51d608e5db6fa743 | 27,003 | Algorithms | MIT License |
src/main/kotlin/recursion/AndroidUnlockPatterns.kt | e-freiman | 471,473,372 | false | {"Kotlin": 78010} | package recursion
private val visited = BooleanArray(9) {false}
fun valid(i: Int, j: Int, ni: Int, nj: Int): Boolean {
val di = Math.abs(i - ni)
val dj = Math.abs(j - nj)
return if ((di == 2 && dj == 2) || (di == 0 && dj == 2) || (di == 2 && dj == 0)) {
val mi = (i + ni) / 2
val mj = (j ... | 0 | Kotlin | 0 | 0 | fab7f275fbbafeeb79c520622995216f6c7d8642 | 1,080 | LeetcodeGoogleInterview | Apache License 2.0 |
src/main/kotlin/Day03.kt | gijs-pennings | 573,023,936 | false | {"Kotlin": 20319} | fun main() {
val lines = readInput(3)
println(part1(lines.map { it.chunked(it.length / 2) }))
println(part1(lines.chunked(3).map { listOf(it[0].intersect(it[1]), it[2]) }))
}
private fun part1(rucksacks: List<List<String>>) = rucksacks
.map { it[0].intersect(it[1]).first() }
.sumOf { if (it.isLower... | 0 | Kotlin | 0 | 0 | 8ffbcae744b62e36150af7ea9115e351f10e71c1 | 452 | aoc-2022 | ISC License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2224/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2224
/**
* LeetCode page: [2224. Minimum Number of Operations to Convert Time](https://leetcode.com/problems/minimum-number-of-operations-to-convert-time/);
*/
class Solution {
private val incrementInMinutesDescending = listOf(60, 15, 5, 1)
/* Complexity:
* Time O(... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,484 | hj-leetcode-kotlin | Apache License 2.0 |
modules/graph/src/commonMain/kotlin/com/handtruth/mc/graph/Isomorhism.kt | handtruth | 282,440,433 | false | null | package com.handtruth.mc.graph
private fun <E> swap(list: MutableList<E>, i: Int, j: Int) {
val a = list[i]
val b = list[j]
list[i] = b
list[j] = a
}
private suspend fun <E> SequenceScope<List<E>>.heapPermutation(
list: MutableList<E>,
size: Int
) {
if (size == 1) {
yield(list)
... | 0 | Kotlin | 0 | 0 | fa6d230dc1f7e62cd75b91ad4798a763ca7e78f1 | 3,446 | mc-tools | MIT License |
archive/src/main/kotlin/com/grappenmaker/aoc/year21/Day13.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year21
import com.grappenmaker.aoc.*
fun PuzzleSet.day13() = puzzle(day = 13) {
val (pointsPart, foldsPart) = input.split("\n\n")
val points = pointsPart.lines().mapTo(hashSetOf()) { it.split(",").map(String::toInt).asPair().toPoint() }
val folds = foldsPart.lines().map {
... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 1,065 | advent-of-code | The Unlicense |
src/main/kotlin/g0501_0600/s0592_fraction_addition_and_subtraction/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0501_0600.s0592_fraction_addition_and_subtraction
// #Medium #String #Math #Simulation #2023_01_31_Time_164_ms_(100.00%)_Space_35.9_MB_(66.67%)
class Solution {
private fun gcd(a: Int, b: Int): Int {
return if (a % b == 0) b else gcd(b, a % b)
}
private fun format(a: Int, b: Int): String... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,282 | LeetCode-in-Kotlin | MIT License |
src/day01/day01.kt | PS-MS | 572,890,533 | false | null | package day01
import readInput
import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
var highestElf = 0
var thisElf = 0
input.forEachIndexed { index, value ->
val calories = value.toIntOrNull()
if (calories != null) {
thisElf += c... | 0 | Kotlin | 0 | 0 | 24f280a1d8ad69e83755391121f6107f12ffebc0 | 1,374 | AOC2022 | Apache License 2.0 |
algorithms/src/main/kotlin/io/nullables/api/playground/algorithms/Point.kt | AlexRogalskiy | 331,076,596 | false | null | /*
* Copyright (C) 2021. <NAME>. All Rights Reserved.
*
* 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 applic... | 13 | Kotlin | 2 | 2 | d7173ec1d9ef227308d926e71335b530c43c92a8 | 2,301 | gradle-kotlin-sample | Apache License 2.0 |
LeetCode/Kotlin/MaxAreaOfIsland.kt | vale-c | 177,558,551 | false | null | /*
* 695. Max Area of Island
* https://leetcode.com/problems/max-area-of-island/
*/
class MaxAreaOfIsland {
fun maxAreaOfIsland(grid: Array<IntArray>): Int {
var max = 0
for (i in 0 until grid.size) {
for (j in 0 until grid[i].size) {
if (grid[i][j] != 0) ... | 0 | Java | 5 | 9 | 977e232fa334a3f065b0122f94bd44f18a152078 | 939 | CodingInterviewProblems | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ContainerWithMostWater.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,522 | kotlab | Apache License 2.0 |
src/day05/Day05_Part1.kt | m-jaekel | 570,582,194 | false | {"Kotlin": 13764} | package day05
import readInput
fun main() {
fun part1(input: List<String>): String {
parseMoves(input).forEach { move ->
repeat(move[0]) {
val stack = data04_data[move[1] - 1].first()
data04_data[move[1] - 1].removeFirst()
data04_data[move[2] - 1... | 0 | Kotlin | 0 | 1 | 07e015c2680b5623a16121e5314017ddcb40c06c | 1,843 | AOC-2022 | Apache License 2.0 |
src/Day05.kt | stephenkao | 572,205,897 | false | {"Kotlin": 14623} | import kotlin.reflect.typeOf
fun main() {
val day = "05"
var charsPerCrate = 4 // assumption!
fun part1(input: List<String>): String {
val structureRegex = Regex("\\[([A-Z]+)\\]")
val moveRegex = Regex("\\s*move\\s*(\\d*)\\s*from\\s*(\\d*)\\s*to\\s*(\\d*)")
// initialize stacks ba... | 0 | Kotlin | 0 | 0 | 7a1156f10c1fef475320ca985badb4167f4116f1 | 2,099 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/year2023/day-01.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2023
import lib.aoc.Day
import lib.aoc.Part
import lib.splitLines
fun main() {
Day(1, 2023, PartA1(), PartB1()).run()
}
open class PartA1 : Part() {
private lateinit var lines: List<String>
override fun parse(text: String) {
lines = text.splitLines()
}
override fun compute():... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 1,885 | Advent-Of-Code-Kotlin | MIT License |
Code/3Sum/Solution.kt | Guaidaodl | 26,102,098 | false | {"Java": 20880, "Kotlin": 6663, "C++": 4106, "Python": 1216} | class Solution {
fun threeSum(nums: IntArray): List<List<Int>> {
nums.sort()
val result: ArrayList<List<Int>> = ArrayList()
var lastTwoResult: List<List<Int>>? = null
for (i in 0 until nums.size - 2) {
if (nums[i] > 0) return result
val r = twoSum(nums, i + ... | 0 | Java | 0 | 0 | a5e9c36d34e603906c06df642231bfdeb0887088 | 1,689 | leetcode | Apache License 2.0 |
src/main/kotlin/days/aoc2021/Day21.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2021
import days.Day
class Day21 : Day(2021, 21) {
override fun partOne(): Any {
return calculateScoresForGame(inputList)
}
override fun partTwo(): Any {
return calculateDiracWinners(inputList)
}
fun calculateDiracWinners(inputList: List<String>): Long {
v... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 3,465 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestPalindromicSubstring.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 | 5,179 | kotlab | Apache License 2.0 |
kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/Statistics.kt | JetBrains | 3,432,266 | false | {"Kotlin": 74444760, "Java": 6669398, "Swift": 4261253, "C": 2620837, "C++": 1953730, "Objective-C": 640870, "Objective-C++": 170766, "JavaScript": 135724, "Python": 48402, "Shell": 30960, "TypeScript": 22754, "Lex": 18369, "Groovy": 17273, "Batchfile": 11693, "CSS": 11368, "Ruby": 10470, "EJS": 5241, "Dockerfile": 513... | /*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package org.jetbrains.analyzer
import org.jetbrains.report.BenchmarkResult
import org.jetbrains.report.MeanVariance
import org.jetbrains.report.MeanVarianceBenchmark
i... | 166 | Kotlin | 5,771 | 46,772 | bef0946ab7e5acd5b24b971eca532c43c8eba750 | 6,786 | kotlin | Apache License 2.0 |
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/search/minTime/MinTime.kt | slobanov | 200,526,003 | false | null | package ru.amai.study.hackerrank.practice.interviewPreparationKit.search.minTime
import java.util.*
import kotlin.math.ceil
import kotlin.math.floor
fun minTime(machines: List<Int>, goal: Int): Long {
fun producedByMachinesIn(time: Long): Long =
machines.fold(0L) { total, machine -> total + time / machine... | 0 | Kotlin | 0 | 0 | 2cfdf851e1a635b811af82d599681b316b5bde7c | 1,289 | kotlin-hackerrank | MIT License |
src/Day01.kt | ka1eka | 574,248,838 | false | {"Kotlin": 36739} | fun main() {
fun Sequence<Int?>.chunkedOnNull(): Sequence<List<Int>> = sequence {
val buffer = mutableListOf<Int>()
for (element in this@chunkedOnNull) {
if (element == null) {
yield(buffer)
buffer.clear()
} else {
buffer += ele... | 0 | Kotlin | 0 | 0 | 4f7893448db92a313c48693b64b3b2998c744f3b | 998 | advent-of-code-2022 | Apache License 2.0 |
src/dataStructures/trees/BinaryStructure.kt | tpltn | 119,588,847 | false | null | package dataStructures.trees
import java.util.*
data class BinaryStructure<T>(val value: T, var left: BinaryStructure<T>? = null, var right: BinaryStructure<T>? = null)
fun <T> binaryStructureEnumeration(root: BinaryStructure<T>) {
val stack: Stack<BinaryStructure<T>> = Stack()
stack.push(root)
var node... | 0 | Kotlin | 1 | 0 | 2257a6a968bb8440f8a2a65a5fd31ff0fa5a5e8f | 2,815 | ads | The Unlicense |
src/Day09.kt | JonasDBB | 573,382,821 | false | {"Kotlin": 17550} | import java.lang.Exception
data class Loc(val x: Int, val y: Int)
enum class Direction {
up,
down,
left,
right
}
private fun move(c: Loc, d: Direction) =
when (d) {
Direction.up -> Loc(c.x, c.y -1)
Direction.down -> Loc(c.x, c.y + 1)
Direction.left -> Loc(c.x - 1, c.y)
... | 0 | Kotlin | 0 | 0 | 199303ae86f294bdcb2f50b73e0f33dca3a3ac0a | 2,917 | AoC2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/PredictTheWinner.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,159 | kotlab | Apache License 2.0 |
module-tool/src/main/kotlin/de/twomartens/adventofcode/day9/SequencePredictor.kt | 2martens | 729,312,999 | false | {"Kotlin": 89431} | package de.twomartens.adventofcode.day9
class SequencePredictor {
fun calculateSumOfPredictedNextValues(lines: List<List<Int>>): Int {
return lines.sumOf {
predictNextValue(it)
}
}
fun predictNextValue(sequence: List<Int>): Int {
val differenceLists = mutableListOf(sequ... | 0 | Kotlin | 0 | 0 | 03a9f7a6c4e0bdf73f0c663ff54e01daf12a9762 | 1,514 | advent-of-code | Apache License 2.0 |
src/Day06.kt | i-tatsenko | 575,595,840 | false | {"Kotlin": 90644} | import java.lang.IllegalArgumentException
fun main() {
fun findPacketIndex(line: String, distinctChars: Int): Int {
val inSubstr = mutableMapOf<Char, Int>()
for (index in line.indices) {
if (index > distinctChars - 1) {
inSubstr.compute(line[index - distinctChars]) { _,... | 0 | Kotlin | 0 | 0 | 0a9b360a5fb8052565728e03a665656d1e68c687 | 1,138 | advent-of-code-2022 | Apache License 2.0 |
leetcode/src/offer/middle/Offer20.kt | zhangweizhe | 387,808,774 | false | null | package offer.middle
fun main() {
// 剑指 Offer 20. 表示数值的字符串
// https://leetcode.cn/problems/biao-shi-shu-zhi-de-zi-fu-chuan-lcof/
println(isNumber(" -12.3e1"))
}
fun isNumber(s: String): Boolean {
val transferMap = HashMap<State, MutableMap<CharType, State>>()
val initialMap = HashMap<CharType, ... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 3,608 | kotlin-study | MIT License |
src/day_10/kotlin/Day10.kt | Nxllpointer | 573,051,992 | false | {"Kotlin": 41751} | // AOC Day 10
interface Instruction {
data class AddX(val amount: Int) : Instruction
object Noop : Instruction
}
data class InstructionExecution<T : Instruction>(val instruction: T, var executionCyclesLeft: Int)
fun Iterator<Instruction>.run(maxCycles: Int, duringCycleAction: (cycle: Int, registerX: Int) -> ... | 0 | Kotlin | 0 | 0 | b6d7ef06de41ad01a8d64ef19ca7ca2610754151 | 2,857 | AdventOfCode2022 | MIT License |
2015/Day08/src/main/kotlin/Main.kt | mcrispim | 658,165,735 | false | null | import java.io.File
fun main() {
fun stringInMemoryLength(raw: String): Int {
val string = raw.drop(1).dropLast(1)
var length = 0
var index = 0
val lastIndex = string.length - 1
while (index <= lastIndex) {
if (string[index] == '\\' && index < lastIndex) {
... | 0 | Kotlin | 0 | 0 | 2f4be35e78a8a56fd1e078858f4965886dfcd7fd | 2,094 | AdventOfCode | MIT License |
kotlin/646.Maximum Length of Pair Chain(最长数对链).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>
You are given <code>n</code> pairs of numbers. In every pair, the first number is always smaller than the second number.
</p>
<p>
Now, we define a pair <code>(c, d)</code> can follow another pair <code>(a, b)</code> if and only if <code>b < c</code>. Chain of pairs can be formed in this fashion.
</p>
<p>
Giv... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 2,510 | leetcode | MIT License |
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day05/Almanac.kt | Gentleman1983 | 737,309,232 | false | {"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319} | package de.havox_design.aoc2023.day05
import de.havox_design.aoc.utils.kotlin.model.positions.Position3d
data class Almanac(val seeds: List<Long>, val maps: List<List<Position3d<Long>>>) {
fun seedsToLocation(): List<Long> =
seeds
.map { seed -> computeLocation(seed) }
fun seedRangesToLowestL... | 4 | Kotlin | 0 | 1 | 35ce3f13415f6bb515bd510a1f540ebd0c3afb04 | 2,357 | advent-of-code | Apache License 2.0 |
year2020/day10/joltage/src/main/kotlin/com/curtislb/adventofcode/year2020/day10/joltage/JoltageAdapters.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | package com.curtislb.adventofcode.year2020.day10.joltage
import com.curtislb.adventofcode.common.collection.Counter
import com.curtislb.adventofcode.common.collection.FifoCache
/**
* A collection of distinct joltage adapters that may be chained to connect a compatible device to
* an outlet.
*
* @param ratings A s... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,747 | AdventOfCode | MIT License |
src/main/kotlin/leetcode/kotlin/string/767. Reorganize String.kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.string
import java.lang.StringBuilder
/**
* 1. Make frequency map of chars.
* 2. Take last two char of max frequency and append them, take max frequency one as first one always
* 3. modify used frequencies in list, and sort again according to frequencies
* 4. Repeat 2, 3 until list size is... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 2,957 | kotlinmaster | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordSearch.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,003 | kotlab | Apache License 2.0 |
src/Day10.kt | ked4ma | 573,017,240 | false | {"Kotlin": 51348} | /**
* [Day10](https://adventofcode.com/2022/day/10)
*/
fun main() {
fun toOpFragments(input: List<String>): List<Int> = buildList {
input.forEach {
add(0)
if (it.startsWith("addx")) {
add(it.split(" ")[1].toInt())
}
}
}
fun part1(input: ... | 1 | Kotlin | 0 | 0 | 6d4794d75b33c4ca7e83e45a85823e828c833c62 | 1,854 | aoc-in-kotlin-2022 | Apache License 2.0 |
src/Day08.kt | rmyhal | 573,210,876 | false | {"Kotlin": 17741} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
return visibleTrees(input)
}
fun part2(input: List<String>): Int {
return highestScenic(input)
}
val input = readInput("Day08")
println(part1(input))
println(part2(input))
}
private fun visibleTrees(input: List<String>):... | 0 | Kotlin | 0 | 0 | e08b65e632ace32b494716c7908ad4a0f5c6d7ef | 2,821 | AoC22 | Apache License 2.0 |
2022/kotlin/app/src/main/kotlin/day07/Day07.kt | jghoman | 726,228,039 | false | {"Kotlin": 15309, "Rust": 14555, "Scala": 1804, "Shell": 737} | package day07
import java.lang.Exception
import java.util.Stack
val testInput = "\$ cd /\n" +
"\$ ls\n" +
"dir a\n" +
"14848514 b.txt\n" +
"8504156 c.dat\n" +
"dir d\n" +
"\$ cd a\n" +
"\$ ls\n" +
"dir e\n" +
"29116 f\n" +
"2557 g\n" +
... | 0 | Kotlin | 0 | 0 | 2eb856af5d696505742f7c77e6292bb83a6c126c | 3,910 | aoc | Apache License 2.0 |
src/day10/Day10.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day10
import readInput
import kotlin.math.absoluteValue
const val day = "10"
fun main() {
fun calculatePart1Score(input: List<String>): Int {
val allX = input.executeProgram()
return allX.mapIndexed { index, x -> (1 + index) * x }.slice(19..allX.size step 40).sum()
}
fun calcul... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 2,156 | advent-of-code-22-kotlin | Apache License 2.0 |
Examples.kt | callej | 428,413,375 | false | {"Kotlin": 9131} | // Code examples in Kotlin
// This file contains some very basic Kotlin code constructs.
// It is part of the JetBrains Academy Kotlin Course.
// The code below are some examples of how basic Kotlin code can be written.
// It is a playground with some funny implementations and some experiments on what works and what do... | 0 | Kotlin | 0 | 0 | 59120fc9bbbf8c9ec5af8b363fab26238f7adbb4 | 4,665 | Zoo-Keeper | MIT License |
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day16.kt | jmerle | 434,010,865 | false | {"Kotlin": 60581} | package com.jaspervanmerle.aoc2021.day
class Day16 : Day("1007", "834151779165") {
private class Bits(input: String) {
private var bits = input
.toCharArray()
.joinToString("") { it.digitToInt(16).toString(2).padStart(4, '0') }
fun popBits(bitCount: Int): String {
... | 0 | Kotlin | 0 | 0 | dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e | 4,856 | advent-of-code-2021 | MIT License |
year2023/src/main/kotlin/net/olegg/aoc/year2023/day21/Day21.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2023.day21
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.utils.find
import net.olegg.aoc.utils.get
import net.olegg.aoc.year2023.DayOf2023
/**
* See [Year 2023, Day 21](https://adventofcode.com/2023/day/21... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,346 | adventofcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SumOfLeftLeaves.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,795 | kotlab | Apache License 2.0 |
src/main/kotlin/days/Day20.kt | mstar95 | 317,305,289 | false | null | package days
class Day20 : Day(20) {
val bodyRegex = Regex("#....##....##....###")
val legsRegex = Regex(".#..#..#..#..#..#...")
override fun partOne(): Any {
val tiles = prepareInput(inputString)
findConnected(tiles)
val corners = tiles.filter { it.connections.size == 2 }.map { it... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 7,189 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/twentytwentytwo/Day25.kt | JanGroot | 317,476,637 | false | {"Kotlin": 80906} | package twentytwentytwo
import kotlin.math.pow
fun main() {
val input = {}.javaClass.getResource("input-25.txt")!!.readText().linesFiltered { it.isNotEmpty() };
val day = Day25(input)
println(day.part1())
}
class Day25(private val input: List<String>) {
fun part1(): String {
return getElvesNu... | 0 | Kotlin | 0 | 0 | 04a9531285e22cc81e6478dc89708bcf6407910b | 1,332 | aoc202xkotlin | The Unlicense |
src/Day06.kt | Inn0 | 573,532,249 | false | {"Kotlin": 16938} | fun main() {
fun getMarker(input: String, markerVal: Int): Int {
var counter = 0
while(counter + markerVal <= input.length){
val substr = input.substring(counter, counter + markerVal)
if(substr.toCharArray().distinct().size == substr.length){
break
... | 0 | Kotlin | 0 | 0 | f35b9caba5f0c76e6e32bc30196a2b462a70dbbe | 874 | aoc-2022 | Apache License 2.0 |
src/Day10.kt | davidkna | 572,439,882 | false | {"Kotlin": 79526} | fun main() {
fun part1(input: List<String>): Int {
var x = 1
var signalStrength = 0
var cycle = -19
input.map { it.split(" ") }.forEach { ins ->
val cycleDuration = when (ins[0]) {
"noop" -> 1
"addx" -> 2
else -> throw Exce... | 0 | Kotlin | 0 | 0 | ccd666cc12312537fec6e0c7ca904f5d9ebf75a3 | 2,040 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Main.kt | goetz-markgraf | 754,010,781 | false | {"Kotlin": 4778} | import java.lang.Integer.max
import java.lang.Integer.min
import kotlin.math.abs
enum class Function {
CHECK, PLACE
}
enum class Player {
PLAYER1, PLAYER2
}
data class Position(
val col: Int,
val row: Int
)
data class Ship(
var parts: List<Position>
)
typealias Field = Array<Array<Int>>
data c... | 0 | Kotlin | 0 | 0 | ebd9504a64cb5908c8a0c954a93a5682de1fe550 | 4,778 | battleship_2024 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.