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/2023/Day3_1.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
val grid = mutableListOf<String>()
val symbols = Regex("[^\\.\\d\\s]")
val partNumbers = mutableListOf<Int>()
fun String.isPrevDigit(pos: Int) = pos > 0 && this[pos-1].isDigit()
File("input/2023/day3").apply {
forEachLine { grid.add(it) }
grid.forEachIndexed { y, row ->
val number... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 2,151 | adventofcode | MIT License |
src/main/kotlin/aoc22/Day25.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import aoc22.Day25Domain.BaseConvertor.toBalancedQuinary
import aoc22.Day25Domain.BaseConvertor.toDecimal
import aoc22.Day25Domain.SnafuConvertor.toBalancedQuinary
import aoc22.Day25Domain.SnafuConvertor.toSnafu
import aoc22.Day25Solution.part1Day25
import common.Year22
import kotlin.math.pow
object Day... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 1,937 | aoc | Apache License 2.0 |
src/main/kotlin/graph/variation/EvenLenWalk.kt | yx-z | 106,589,674 | false | null | package graph.variation
import graph.core.Edge
import graph.core.Graph
import graph.core.Vertex
import graph.core.bfs
import util.Tuple2
import util.tu
// given an undirected graph G, find a shortest even length walk from s to e
// or report that such walk does not exist
fun main(args: Array<String>) {
val vertices ... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,901 | AlgoKt | MIT License |
core/src/main/kotlin/net/olegg/aoc/utils/Collections.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.utils
/**
* Generates the sequence of all permutations of items in current list.
*/
fun <T : Any> List<T>.permutations(): Sequence<List<T>> = if (size == 1) {
sequenceOf(this)
} else {
val iterator = iterator()
var head = iterator.next()
var permutations = (this - head).permutations().i... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,307 | adventofcode | MIT License |
src/main/kotlin/aoc/Day01.kt | fluxxion82 | 573,716,300 | false | {"Kotlin": 39632} | package aoc
import aoc.utils.readInput
fun main() {
fun part1(input: List<String>): Int {
val data = input.filterNot { it == "" } .map { elf ->
elf.lines().map { it.toInt() }
}
return data.maxOf { it.sum() }
}
fun part2(input: List<String>): Int {
return input... | 0 | Kotlin | 0 | 0 | 3920d2c3adfa83c1549a9137ffea477a9734a467 | 1,238 | advent-of-code-kotlin-22 | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch1/Problem12.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch1
import dev.bogwalk.util.maths.gaussSum
import dev.bogwalk.util.maths.primeFactors
import dev.bogwalk.util.maths.primeNumbers
/**
* Problem 12: Highly Divisible Triangular Number
*
* https://projecteuler.net/problem=12
*
* Goal: Find the value of the first triangle number to have more t... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 7,725 | project-euler-kotlin | MIT License |
src/Day06.kt | vladislav-og | 573,326,483 | false | {"Kotlin": 27072} | fun main() {
fun checkIfUniqueMarker(currentMarker: ArrayDeque<Char>): Boolean {
val distinctMarker = currentMarker.distinct()
return distinctMarker.size == currentMarker.size
}
fun solvePuzzle(input: List<String>, markerLength: Int): Int {
for (datastream in input) {
va... | 0 | Kotlin | 0 | 0 | b230ebcb5705786af4c7867ef5f09ab2262297b6 | 1,328 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day03.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2022
import findCommon
import readInput
private fun findCommonItem(vararg compartments: String): Char =
findCommon(*compartments.map { it.toCharArray().toSet() }.toTypedArray())
private val Char.priority: Int
get() = if (isLowerCase()) {
this - 'a' + 1
} else {
this - 'A' + 27
... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 1,172 | adventOfCode | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/IteratorForCombination.kt | faniabdullah | 382,893,751 | false | null | //Design the CombinationIterator class:
//
//
// CombinationIterator(string characters, int combinationLength) Initializes
//the object with a string characters of sorted distinct lowercase English letters
//and a number combinationLength as arguments.
// next() Returns the next combination of length combinationLen... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,911 | dsa-kotlin | MIT License |
src/shmulik/klein/day03/Day03.kt | shmulik-klein | 573,426,488 | false | {"Kotlin": 9136} | package shmulik.klein.day03
import readInput
fun main() {
fun getPriorityMap(): MutableMap<Char, Int> {
val lowerIntRange = 1..26
val upperIntRange = 27..52
val lowerRange = 'a'..'z'
val upperRange = 'A'..'Z'
val mutableMapOf = mutableMapOf<Char, Int>()
for ((j, i) ... | 0 | Kotlin | 0 | 0 | 4d7b945e966dad8514ec784a4837b63a942882e9 | 1,724 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | simonbirt | 574,137,905 | false | {"Kotlin": 45762} |
fun main() {
Day7.printSolutionIfTest(95437,24933642)
}
object Day7: Day<Int, Int>(7) {
override fun part1(lines: List<String>):Int =
totals(lines).values.filter { it <= 100000 }.sum()
override fun part2(lines: List<String>):Int =
totals(lines).let{ totals ->
val requiredSpace... | 0 | Kotlin | 0 | 0 | 962eccac0ab5fc11c86396fc5427e9a30c7cd5fd | 1,079 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/16_Permutation.kt | barta3 | 112,792,199 | false | null | import java.util.*
fun main(args: Array<String>) {
example()
part1()
part2()
}
private fun part1() {
val input = "abcdefghijklmnop".toMutableList()
val moves = Permutation::class.java
.getResource("16_input.txt")
.readText()
val res = Permutation(input).run(moves)
... | 0 | Kotlin | 0 | 0 | 51ba74dc7b922ac11f202cece8802d23011f34f1 | 2,021 | AdventOfCode2017 | MIT License |
src/Day10.kt | jamOne- | 573,851,509 | false | {"Kotlin": 20355} | sealed class Day10Command {
object Noop : Day10Command()
class AddX(val v: Int): Day10Command()
companion object {
fun fromString(string: String): Day10Command {
return when {
string == "noop" -> Noop
string.startsWith("addx") -> AddX(string.split(" ")[1]... | 0 | Kotlin | 0 | 0 | 77795045bc8e800190f00cd2051fe93eebad2aec | 2,142 | adventofcode2022 | Apache License 2.0 |
algorithms/src/main/kotlin/com/kotlinground/algorithms/sorting/quicksort/quicksort.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.algorithms.sorting.quicksort
// partitions a slice into 2 and returns the pivot index. Assumes the pivot is at the end of the slice
fun <T> partition(collection: Array<T>, startIndex: Int, endIndex: Int): Int {
val pivot = collection[endIndex]
var leftIndex = startIndex
var right... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 2,597 | KotlinGround | MIT License |
src/main/kotlin/com/anahoret/aoc2022/day14/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day14
import java.io.File
data class Point(val x: Int, val y: Int) {
fun moveDown(): Point {
return Point(x, y + 1)
}
fun moveDownLeft(): Point {
return Point(x - 1, y + 1)
}
fun moveDownRight(): Point {
return Point(x + 1, y + 1)
}
c... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 3,603 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/easy/longest-common-prefix.kt | shevtsiv | 286,838,200 | false | null | package easy
class LongestCommonPrefixSolution {
/**
* Time Complexity: O(n^2)
* Space Complexity: O(k^2), where k - length of the first string
*/
fun longestCommonPrefixBruteforce(strs: Array<String>): String {
if (strs.isEmpty()) {
return ""
}
var prefix = ... | 0 | Kotlin | 0 | 0 | 95d5f74069098beddf2aee14465f069302a51b77 | 2,847 | leet | MIT License |
src/Day11.kt | allwise | 574,465,192 | false | null |
fun main() {
fun part1(input: List<String>): Int {
val monkeys = Monkeys(input)
val res = monkeys.process()
println("res1: $res")
return res
}
fun part2(input: List<String>): Long {
val monkeys = Monkeys(input)
val res = monkeys.process2()
println... | 0 | Kotlin | 0 | 0 | 400fe1b693bc186d6f510236f121167f7cc1ab76 | 4,858 | advent-of-code-2022 | Apache License 2.0 |
app/src/main/java/ru/igla/duocamera/utils/CameraSizes.kt | iglaweb | 414,899,591 | false | {"Kotlin": 85927, "Java": 2752} | package ru.igla.duocamera.utils
import android.graphics.Point
import android.hardware.camera2.CameraCharacteristics
import android.hardware.camera2.params.StreamConfigurationMap
import android.util.Size
import android.view.Display
import kotlin.math.max
import kotlin.math.min
/** Helper class used to pre-compute shor... | 1 | Kotlin | 0 | 6 | 5743d5c22fdc96d2d2f0f0e2b00e17ee4c75147e | 2,974 | DuoCamera | Apache License 2.0 |
kotlin/graphs/shortestpaths/DijkstraHeap.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package graphs.shortestpaths
import java.util.stream.Stream
// https://en.wikipedia.org/wiki/Dijkstra's_algorithm
object DijkstraHeap {
// calculate shortest paths in O(E*log(V)) time and O(E) memory
fun shortestPaths(edges: Array<List<Edge>>, s: Int, prio: IntArray, pred: IntArray) {
Arrays.fill(pred... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 1,847 | codelibrary | The Unlicense |
src/main/kotlin/com/rtarita/days/Day3.kt | RaphaelTarita | 724,581,070 | false | {"Kotlin": 64943} | package com.rtarita.days
import com.rtarita.structure.AoCDay
import com.rtarita.util.day
import com.rtarita.util.exactlyOrNull
import com.rtarita.util.indexOfFirst
import kotlinx.datetime.LocalDate
import kotlin.math.max
import kotlin.math.min
object Day3 : AoCDay {
override val day: LocalDate = day(3)
priva... | 0 | Kotlin | 0 | 0 | 4691126d970ab0d5034239949bd399c8692f3bb1 | 2,749 | AoC-2023 | Apache License 2.0 |
2022/src/main/kotlin/day7_imp.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
import utils.badInput
fun main() {
Day7Imp.run()
}
sealed class Cmd {
data class ChangeDir(val relative: String): Cmd()
data class ListFiles(val output: List<FsNode>): Cmd()
}
sealed class FsNode {
abstract val name: String
data class DirNode(
override val nam... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 3,933 | aoc_kotlin | MIT License |
src/main/kotlin/aoc2023/Day07.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2023
import AoCDay
import aoc2023.Day07.Hand.Type.*
import util.illegalInput
import util.pow
import kotlin.math.max
// https://adventofcode.com/2023/day/7
object Day07 : AoCDay<Int>(
title = "Camel Cards",
part1ExampleAnswer = 6440,
part1Answer = 250951660,
part2ExampleAnswer = 5905,
pa... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 3,062 | advent-of-code-kotlin | MIT License |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/common/Utils.kt | jrhenderson1988 | 289,786,400 | false | {"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37} | package com.github.jrhenderson1988.adventofcode2019.common
import java.util.*
fun <T>dijkstra(points: Iterable<T>, source: T, target: T, neighbours: (T) -> Iterable<T>): List<T>? {
val q = points.toMutableSet()
val dist = q.map { it to Int.MAX_VALUE }.toMap().toMutableMap()
val prev: MutableMap<T, T?> = q... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 2,474 | advent-of-code | Apache License 2.0 |
src/main/day05/day05.kt | rolf-rosenbaum | 572,864,107 | false | {"Kotlin": 80772} | package day05
import java.util.*
import readInput
val stackIndices = listOf(1, 5, 9, 13, 17, 21, 25, 29, 33)
var stacks: List<Stack<Char>> = emptyList()
var moves: List<Move> = emptyList()
val regex by lazy { """move (\d+) from (\d) to (\d)""".toRegex() }
fun main() {
val input = readInput("main/day05/Day05")
... | 0 | Kotlin | 0 | 2 | 59cd4265646e1a011d2a1b744c7b8b2afe482265 | 2,126 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/days_2020/Day11.kt | BasKiers | 434,124,805 | false | {"Kotlin": 40804} | package days_2020
import util.Day
import kotlin.math.floor
import kotlin.math.max
import kotlin.math.min
class Day11 : Day(11, 2020) {
val input = inputList.map { row ->
row.toCharArray().map {
when (it) {
'#' -> Tile.OCCUPIED_SEAT
'L' -> Tile.EMPTY_SEAT
... | 0 | Kotlin | 0 | 0 | 870715c172f595b731ee6de275687c2d77caf2f3 | 4,089 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/2021/Day13_1.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
var switched = false
val points = ArrayList<Pair<Int, Int>>()
val instructions = ArrayList<Pair<String, Int>>()
File("input/2021/day13").forEachLine { line ->
if (line.isEmpty()) {
switched = true
} else {
if (!switched) {
val (x,y) = line.split(",").map { it.toI... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 1,753 | adventofcode | MIT License |
src/main/aoc2023/Day02.kt | Clausr | 575,584,811 | false | {"Kotlin": 65961} | package aoc2023
class Day02(input: List<String>) {
private val parsedInput = input.map {
val gameId = it.substringBefore(":").split(" ").last().toInt()
println("GameID: $gameId")
val rawThrows = it.substringAfter(": ")
val reveals = rawThrows.split("; ")
val cubesInReveals ... | 1 | Kotlin | 0 | 0 | dd33c886c4a9b93a00b5724f7ce126901c5fb3ea | 1,703 | advent_of_code | Apache License 2.0 |
src/day16/solution.kt | bohdandan | 729,357,703 | false | {"Kotlin": 80367} | package day16
import assert
import println
import readInput
enum class Direction(val row: Int, val column: Int) {
UP(-1, 0),
DOWN(1, 0),
LEFT(0, -1),
RIGHT(0, 1)
}
fun main() {
val OPPOSITES = mapOf(
Direction.UP to Direction.DOWN,
Direction.DOWN to Direction.UP,
Direction... | 0 | Kotlin | 0 | 0 | 92735c19035b87af79aba57ce5fae5d96dde3788 | 5,175 | advent-of-code-2023 | Apache License 2.0 |
src/main/kotlin/Day25.kt | todynskyi | 573,152,718 | false | {"Kotlin": 47697} | import kotlin.math.pow
fun main() {
fun snafuToInt(snafu: String): Long = snafu.reversed()
.withIndex()
.fold(0L) { acc, indexedValue ->
val weight = 5.0.pow(indexedValue.index.toDouble()).toLong()
acc + when (indexedValue.value) {
'-' -> -weight
... | 0 | Kotlin | 0 | 0 | 5f9d9037544e0ac4d5f900f57458cc4155488f2a | 1,102 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/aoc2023/Day18.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2023
import utils.*
import kotlin.math.abs
fun main(): Unit = with(Day18) {
part1(testInput).checkEquals(62)
part1(input)
.checkEquals(35244)
// .sendAnswer(part = 1, day = "18", year = 2023)
part2(testInput).checkEquals(952408144115)
.alsoPrintln()
part2(input)
... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 3,548 | Kotlin-AOC-2023 | Apache License 2.0 |
src/Day05.kt | Riari | 574,587,661 | false | {"Kotlin": 83546, "Python": 1054} | import kotlin.collections.ArrayDeque
fun main() {
data class Procedure(val move: Int, val from: Int, val to: Int)
fun parseInitialState(input: List<String>): List<ArrayDeque<Char>> {
val state = mutableListOf<ArrayDeque<Char>>()
val regex = Regex("[A-Z]")
for (line in input) {
... | 0 | Kotlin | 0 | 0 | 8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d | 2,643 | aoc-2022 | Apache License 2.0 |
LeetCode/LongestConsecutiveSequence.kt | MartinWie | 702,541,017 | false | {"Kotlin": 90565} | import org.junit.Test
import kotlin.test.assertEquals
class LongestConsecutiveSequence {
private fun longestConsecutive(nums: IntArray): Int {
val numsSorted = nums.toSortedSet()
var overallHighestCons = 0
var currentHighestCons = if (nums.isEmpty()) 0 else 1
var lastNum: Int? = nul... | 0 | Kotlin | 0 | 0 | 47cdda484fabd0add83848e6000c16d52ab68cb0 | 1,694 | KotlinCodeJourney | MIT License |
src/main/kotlin/days/Day2.kt | vovarova | 726,012,901 | false | {"Kotlin": 48551} | package days
import util.DayInput
class Day2 : Day("2") {
class Line {
var game: Int = 0
var sets: List<BallSet> = mutableListOf()
}
class BallSet {
var red: Int = 0
var blue: Int = 0
var green: Int = 0
}
fun lines(input: List<String>): List<Line> {
... | 0 | Kotlin | 0 | 0 | 77df1de2a663def33b6f261c87238c17bbf0c1c3 | 1,859 | adventofcode_2023 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-24.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2023
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
import java.math.BigInteger
fun main() {
val input = readInputLines(2023, "24-input")
val test1 = readInputLines(2023, "24-test1")
println("Part1:")
... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 6,471 | advent-of-code | MIT License |
src/Day07.kt | roxanapirlea | 572,665,040 | false | {"Kotlin": 27613} | private data class File(
val name: String,
var fileSize: Long = 0,
val children: MutableList<File> = mutableListOf()
)
private sealed class Instruction {
data class MoveIn(val name: String) : Instruction()
object MoveOut : Instruction()
object MoveToRoot : Instruction()
object List : Instru... | 0 | Kotlin | 0 | 0 | 6c4ae6a70678ca361404edabd1e7d1ed11accf32 | 4,221 | aoc-2022 | Apache License 2.0 |
src/year2021/Day7.kt | drademacher | 725,945,859 | false | {"Kotlin": 76037} | package year2021
import readLines
import kotlin.math.abs
fun main() {
val input = readLines("2021", "day7").map { it.toInt() }
val testInput = readLines("2021", "day7_test").map { it.toInt() }
check(part1(testInput) == 37)
println("Part 1:" + part1(input))
check(part2(testInput) == 168)
prin... | 0 | Kotlin | 0 | 0 | 4c4cbf677d97cfe96264b922af6ae332b9044ba8 | 819 | advent_of_code | MIT License |
src/main/kotlin/Monkeys.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | import java.math.BigInteger
fun main() = Monkeys.solve()
object Monkeys {
private var inspectedBy = mutableListOf<Int>()
fun solve() {
val input = readInput()
for (monkey in input) {
inspectedBy.add(monkey.id, 0)
}
for (turn in 1..10000) {
runTurn(input... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 4,863 | aoc2022 | MIT License |
src/main/kotlin/q1_50/q21_30/Solution23.kt | korilin | 348,462,546 | false | null | package q1_50.q21_30
import java.util.*
/**
* https://leetcode-cn.com/problems/merge-k-sorted-lists
*/
class Solution23 {
/**
* 优先队列
* 时间复杂度:与分治合并算法一样都是 O(kn×log(k))
*/
fun mergeKLists(lists: Array<ListNode?>): ListNode? {
val nodePriorityQueue = PriorityQueue<ListNode> { a, b -> a.`... | 0 | Kotlin | 0 | 1 | 1ce05efeaf34536fff5fa6226bdcfd28247b2660 | 2,153 | leetcode_kt_solution | MIT License |
src/Day04.kt | pydaoc | 573,843,750 | false | {"Kotlin": 8484} | fun main() {
fun checkMinusLists(list1: IntRange, list2: IntRange): Boolean {
return !list1.minus(list2).any() || !list2.minus(list1).any()
}
fun checkIntersectLists(list1: IntRange, list2: IntRange): Boolean {
return list1.intersect(list2).any() || list2.intersect(list1).any()
}
... | 0 | Kotlin | 0 | 0 | 970dedbfaf09d12a29315c6b8631fa66eb394054 | 1,661 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt | robertizotov-zz | 101,105,621 | false | {"Kotlin": 979869, "Lex": 10506, "HTML": 7115, "Groovy": 4245, "Java": 1290} | /*
* Minecraft Dev for IntelliJ
*
* https://minecraftdev.org
*
* Copyright (c) 2017 minecraft-dev
*
* MIT License
*/
package com.demonwav.mcdev.util
import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.PreReleasePart
import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.ReleaseP... | 0 | Kotlin | 0 | 1 | 9b91deed668fce98cd21474b9135ec9b92212c2b | 4,044 | Minecraft-dev_JetBrains-plugin | MIT License |
src/main/kotlin/com/nibado/projects/advent/y2017/Day22.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2017
import com.nibado.projects.advent.Day
import com.nibado.projects.advent.Direction
import com.nibado.projects.advent.Point
import com.nibado.projects.advent.resourceLines
object Day22 : Day {
private val input = resourceLines(2017, 22).mapIndexed { y, s -> s.trim().toCharAr... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 2,325 | adventofcode | MIT License |
difficultycalc/src/main/kotlin/com/stehno/dmt/difficulty/DifficultyCalculation.kt | cjstehno | 143,009,387 | false | null | package com.stehno.dmt.difficulty
import com.stehno.dmt.difficulty.model.Challenger
object DifficultyCalculation {
private val xpForCr = mapOf(
Pair("0", 10), Pair("1/8", 25), Pair("1/4", 50), Pair("1/2", 100),
Pair("1", 200), Pair("2", 450), Pair("3", 700), Pair("4", 1100),
Pair("5", 180... | 1 | Kotlin | 0 | 1 | 5bfedc56ad901db11ac77a5a1a45a998ba979668 | 2,520 | dmtools | The Unlicense |
src/day01/Day01.kt | scottpeterson | 573,109,888 | false | {"Kotlin": 15611} | fun main() {
fun part1(input: List<String>): Int {
val testInput = readInput("/day01/Day01_test")
var map: MutableMap<Int, Int> = mutableMapOf()
var key = 1
testInput.forEach {
if (it == "") {
++key
return@forEach
}
... | 0 | Kotlin | 0 | 0 | 0d86213c5e0cd5403349366d0f71e0c09588ca70 | 1,274 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day18/Day18.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day18
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day18/Day18.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 18 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 2,062 | advent-of-code-2022 | MIT License |
src/main/kotlin/y2021/Day04.kt | jforatier | 432,712,749 | false | {"Kotlin": 44692} | package y2021
// Considering a grid as full-line of Int
typealias Grid = List<Int>
class Day04(private val data: List<String>) {
private fun getDrew(input: List<String>): List<Int> {
return input[0] // <= Get the first line
.split(",") // <= Split values with "," separator
... | 0 | Kotlin | 0 | 0 | 2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae | 3,171 | advent-of-code-kotlin | MIT License |
src/day03/Day03.kt | henrikrtfm | 570,719,195 | false | {"Kotlin": 31473} | package day03
import utils.Resources.resourceAsListOfString
fun main() {
fun parseInput(line: String): Rucksack{
val firstCompartment = mutableSetOf<Char>()
val secondCompartment = mutableSetOf<Char>()
line.chunked(line.length/2)
.first()
.forEach {
... | 0 | Kotlin | 0 | 0 | 20c5112594141788c9839061cb0de259f242fb1c | 1,657 | aoc2022 | Apache License 2.0 |
day-13/src/main/kotlin/TransparentOrigami.kt | diogomr | 433,940,168 | false | {"Kotlin": 92651} | fun main() {
println("Part One Solution: ${partOne()}")
println("Part Two Solution: ${partTwo()}")
}
private fun partOne(): Int {
val folds = mutableListOf<String>()
val map = Array(1400) { Array(1400) { "." } }
var readingFolds = false
readInputLines().forEach {
if (it.isBlank()) {
... | 0 | Kotlin | 0 | 0 | 17af21b269739e04480cc2595f706254bc455008 | 2,346 | aoc-2021 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountUnreachablePairs.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,877 | kotlab | Apache License 2.0 |
2021/app/src/main/kotlin/net/sympower/aok2021/tonis/Day07.kt | tonisojandu | 573,036,346 | false | {"Rust": 158858, "Kotlin": 15806, "Shell": 1265} | package net.sympower.aok2021.tonis
import kotlin.math.abs
fun main() {
println("1st: ${day07Part01("/Day07.in")}")
println("2nd: ${day07Part02("/Day07.in")}")
}
fun day07Part01(fileIn: String): Int {
return calculateOptimalFuel(fileIn)
}
fun day07Part02(fileIn: String): Int {
return calculateOptimalFuel(fil... | 0 | Rust | 0 | 0 | 5ee0c3fb2e461dcfd4a3bdd7db3efae9a4d5aabd | 1,819 | to-advent-of-code | MIT License |
src/main/kotlin/days/Day16.kt | andilau | 429,557,457 | false | {"Kotlin": 103829} | package days
@AdventOfCodePuzzle(
name = "<NAME>",
url = "https://adventofcode.com/2015/day/16",
date = Date(day = 16, year = 2015)
)
class Day16(input: List<String>) : Puzzle {
private val aunts = input.map(AuntSueDescription::from).toSet()
private val signature = AuntSueSignature
override fu... | 0 | Kotlin | 0 | 0 | 55932fb63d6a13a1aa8c8df127593d38b760a34c | 2,416 | advent-of-code-2015 | Creative Commons Zero v1.0 Universal |
src/Day04.kt | eps90 | 574,098,235 | false | {"Kotlin": 9738} | fun <T> List<T>.destructed() = Pair(first(), last())
fun main() {
fun prepareSections(input: List<String>): List<Pair<IntRange, IntRange>> {
return input.map { line ->
line.split(",")
.map { s -> s.split("-").let { IntRange(it[0].toInt(), it[1].toInt()) } }
.destr... | 0 | Kotlin | 0 | 0 | bbf58c512fddc0ef1112c3bee5e5c6d43f5aabc0 | 981 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/io/riko/Calculator.kt | laguiar | 278,205,629 | false | null | package io.riko
import io.riko.Strategy.*
import java.math.RoundingMode
private val DEFAULT_WEIGHT_FACTOR = 0.65 to 0.35
private const val MINIMAL_WEIGHT = 0.50
fun calculatePie(input: CalculationInput): List<Slice> =
when (input.strategy) {
YIELD -> calculateByDividendYield(input.stocks)
RATING ... | 4 | Kotlin | 0 | 3 | 185c277fa39f1fcfd7bcab5a535a88986676395a | 2,055 | riko | MIT License |
src/Day25.kt | Tomcat88 | 572,566,485 | false | {"Kotlin": 52372} | import kotlin.math.pow
object Day25 {
fun part1(input: List<String>) {
val number = input.sumOf { snafu ->
snafu.fromSNAFU()
}.log("from")
number.toSNAFU().log("part1")
// Not so elegant first solution below
// var snafu = "20=022=200=========-"
// var i... | 0 | Kotlin | 0 | 0 | 6d95882887128c322d46cbf975b283e4a985f74f | 1,929 | advent-of-code-2022 | Apache License 2.0 |
leetcode2/src/leetcode/letter-case-permutation.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* 784. 字母大小写全排列
* https://leetcode-cn.com/problems/letter-case-permutation/
* Created by test
* Date 2019/10/7 22:08
* Description
* 给定一个字符串S,通过将字符串S中的每个字母转变大小写,我们可以获得一个新的字符串。返回所有可能得到的字符串集合。
示例:
输入: S = "a1b2"
输出: ["a1b2", "a1B2", "A1b2", "A1B2"]
输入: S = "3z4"
输出: ["3z4", "3Z4"]
输入: S = "... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 2,986 | leetcode | MIT License |
src/main/kotlin/com/briarshore/aoc2022/day04/CampCleanupPuzzle.kt | steveswing | 579,243,154 | false | {"Kotlin": 47151} | package com.briarshore.aoc2022.day04
import println
import readInput
fun main() {
fun asRange(rangeParts: List<String>): IntRange {
return IntRange(rangeParts.first().toInt(), rangeParts.last().toInt())
}
fun prepareInput(input: List<String>) = input
.map { it.split(",") }
.map { ... | 0 | Kotlin | 0 | 0 | a0d19d38dae3e0a24bb163f5f98a6a31caae6c05 | 1,331 | 2022-AoC-Kotlin | Apache License 2.0 |
src/Year2022Day09.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | import kotlin.math.abs
import kotlin.math.sign
internal fun Point.move(char: Char) {
when (char) {
'U' -> y++
'D' -> y--
'L' -> x--
'R' -> x++
}
}
internal fun Point.follow(head: Point) {
val dx = head.x - x
val dy = head.y - y
if (abs(dx) > 1) {
x += dx - d... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 1,473 | aoc-2022-in-kotlin | Apache License 2.0 |
src/me/bytebeats/algo/kt/Solution4.kt | bytebeats | 251,234,289 | false | null | package me.bytebeats.algo.kt
import me.bytebeats.algo.kt.design.BinaryMatrix
import me.bytebeats.algo.kt.design.MountainArray
import me.bytebeats.algs.ds.ListNode
import me.bytebeats.algs.ds.TreeNode
class Solution4 {
fun minPathSum(grid: Array<IntArray>): Int {
if (grid.isEmpty() || grid[0].isEmpty()) {
... | 0 | Kotlin | 0 | 1 | 7cf372d9acb3274003bb782c51d608e5db6fa743 | 40,003 | Algorithms | MIT License |
src/day02/Day02.kt | Dr4kn | 575,092,295 | false | {"Kotlin": 12652} | package day02
import readInput
import java.lang.Exception
fun main() {
fun convertToValue(letter: String): Int {
return when (letter) {
"A", "X" -> 1 // Rock
"B", "Y" -> 2 // Paper
"C", "Z" -> 3 // Scissors
else -> throw Exception("Not a valid Symbol")
... | 0 | Kotlin | 0 | 0 | 6de396cb4eeb27ff0dd9a98b56e68a13c2c90cd5 | 2,376 | advent-of-code-2022 | Apache License 2.0 |
src/aoc2022/Day07.kt | Playacem | 573,606,418 | false | {"Kotlin": 44779} | package aoc2022
import utils.createDebug
import utils.readInput
import java.util.*
object Day07 {
sealed class ElfPath(val name: String, val size: Long, val children: MutableMap<String, ElfPath>) {
abstract fun recursiveSize(): Long
abstract fun recursiveDirectories(): List<ElfDirectory>
}
... | 0 | Kotlin | 0 | 0 | 4ec3831b3d4f576e905076ff80aca035307ed522 | 4,078 | advent-of-code-2022 | Apache License 2.0 |
src/Day10.kt | davedupplaw | 573,042,501 | false | {"Kotlin": 29190} | fun main() {
fun executeOperation(it: List<String>, value: Int): Int {
val (operation, argument) = it
return if (operation == "addx") value + argument.toInt() else value
}
fun runProgram(input: List<String>, hook: (Int, Int) -> Unit) {
var value = 1
val allInstructions = inp... | 0 | Kotlin | 0 | 0 | 3b3efb1fb45bd7311565bcb284614e2604b75794 | 3,109 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/tw/gasol/aoc/aoc2022/Day11.kt | Gasol | 574,784,477 | false | {"Kotlin": 70912, "Shell": 1291, "Makefile": 59} | package tw.gasol.aoc.aoc2022
import java.math.BigInteger
import java.util.*
typealias WorryLevel = BigInteger
data class MonkeySpec(
val id: Int,
val items: MutableList<WorryLevel>,
val operation: (WorryLevel) -> WorryLevel,
val testDivider: Int,
val ifTrue: Int,
val ifFalse: Int
) {
ove... | 0 | Kotlin | 0 | 0 | a14582ea15f1554803e63e5ba12e303be2879b8a | 6,468 | aoc2022 | MIT License |
src/Day05.kt | jamie23 | 573,156,415 | false | {"Kotlin": 19195} | import java.lang.Integer.*
import java.util.Stack
fun main() {
data class Instruction(
val num: Int,
val from: Int,
val to: Int
)
fun processInitialState(rawState: String): List<Stack<Char>> {
val stackNum = rawState[rawState.lastIndex - 1].digitToInt()
val state = ... | 0 | Kotlin | 0 | 0 | cfd08064654baabea03f8bf31c3133214827289c | 2,426 | Aoc22 | Apache License 2.0 |
src/Day01.kt | mr-kaffee | 575,129,713 | false | {"Kotlin": 1828} | import java.io.File
fun main() {
fun part1(elves: List<Int>): Int {
return elves.fold(0) { mx, calories -> maxOf(mx, calories) }
}
fun part2(elves: List<Int>): Int {
return elves.fold(mutableListOf(0, 0, 0)) { mx, calories ->
if (calories > mx[0]) {
mx[2] = mx[1... | 0 | Kotlin | 0 | 0 | 313432b49b73da22c55efb6e2b5b8177599c0921 | 1,565 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/minhiew/translation/Analyzer.kt | mhiew | 431,932,268 | false | {"Kotlin": 41977} | package com.minhiew.translation
object Analyzer {
fun compare(androidStrings: Map<String, String>, iosStrings: Map<String, String>): LocalizationReport {
return LocalizationReport(
uniqueAndroidStrings = androidStrings.filterForKeysNotPresentIn(iosStrings),
uniqueIosStrings = iosStr... | 0 | Kotlin | 0 | 1 | 8261d9e94cd0a69bb04d5e5cb018bf5d16f95e89 | 3,238 | translation-tool | MIT License |
year2017/src/main/kotlin/net/olegg/aoc/year2017/day14/Day14.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2017.day14
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions.Companion.NEXT_4
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.utils.get
import net.olegg.aoc.utils.set
import net.olegg.aoc.year2017.DayOf2017
/**
* See [Year 2017, Day 14](https://adventofcode... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 3,166 | adventofcode | MIT License |
src/main/kotlin/com/leetcode/P167.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package com.leetcode
// https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/
class P167 {
fun twoSum(numbers: IntArray, target: Int): IntArray {
// target 보다 작은 수의 조합만 찾으면 된다.
var endOfSearch = numbers.lastIndex - 1
for (i in numbers.indices) {
if (numbers[i] > target... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,200 | algorithm | MIT License |
src/main/kotlin/hu/advent/of/code/year2022/day12/Puzzle12A.kt | sztojkatamas | 568,512,275 | false | {"Kotlin": 157914} | package hu.advent.of.code.year2022.day12
import hu.advent.of.code.AdventOfCodePuzzle
import hu.advent.of.code.BaseChallenge
import java.util.PriorityQueue
@AdventOfCodePuzzle
class Puzzle12A: BaseChallenge(2022) {
override fun run() {
printPuzzleName()
loadDataFromFile("data12.txt")
val w... | 0 | Kotlin | 0 | 0 | 6aa9e53d06f8cd01d9bb2fcfb2dc14b7418368c9 | 3,291 | advent-of-code-universe | MIT License |
src/Day08.kt | CrazyBene | 573,111,401 | false | {"Kotlin": 50149} | fun main() {
fun List<Int>.toVisibilityList(): List<Boolean> {
return this.mapIndexed { index, numberToCheck ->
for (i in index + 1 until this.size) {
if (this[i] >= numberToCheck)
return@mapIndexed false
}
true
}
}
inf... | 0 | Kotlin | 0 | 0 | dfcc5ba09ca3e33b3ec75fe7d6bc3b9d5d0d7d26 | 5,367 | AdventOfCode2022 | Apache License 2.0 |
kotlin/0474-ones-and-zeroes.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /*
* Recursion with memoization solution
*/
class Solution {
fun findMaxForm(strs: Array<String>, m: Int, n: Int): Int {
val dp = Array(m + 1){ Array(n + 1){ IntArray(strs.size){ -1 } } }
fun dfs(i: Int, m: Int, n: Int): Int {
if(i == strs.size) return 0
if(dp[m][n][i] != -... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,348 | leetcode | MIT License |
src/day20/Day20.kt | JoeSkedulo | 573,328,678 | false | {"Kotlin": 69788} | package day20
import Runner
fun main() {
Day20Runner().solve()
}
class Day20Runner : Runner<Long>(
day = 20,
expectedPartOneTestAnswer = 3,
expectedPartTwoTestAnswer = 1623178306
) {
override fun partOne(input: List<String>, test: Boolean): Long {
val mutable = mix(input = input, key = 1... | 0 | Kotlin | 0 | 0 | bd8f4058cef195804c7a057473998bf80b88b781 | 1,945 | advent-of-code | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/odd_even_jump/OddEvenJump.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.odd_even_jump
import datsok.shouldEqual
import org.junit.Test
/**
* ✅ https://leetcode.com/problems/odd-even-jump/
*/
class OddEvenJumpTests {
@Test fun `find number of starting indices that can reach the end of array`() {
oddEvenJumps(intArrayOf()) shouldEqual 0
od... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 1,795 | katas | The Unlicense |
src/Day02.kt | weberchu | 573,107,187 | false | {"Kotlin": 91366} | private enum class Shape(val score: Int) {
Rock(1), Paper(2), Scissors(3)
}
private enum class Result(val score: Int) {
Win(6), Draw(3), Lose(0)
}
private fun toOpponentShape(shape: String): Shape {
return when (shape) {
"A" -> Shape.Rock
"B" -> Shape.Paper
"C" -> Shape.Scissors
... | 0 | Kotlin | 0 | 0 | 903ff33037e8dd6dd5504638a281cb4813763873 | 2,853 | advent-of-code-2022 | Apache License 2.0 |
aoc-2023/src/main/kotlin/aoc/aoc14.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocParser.Companion.parselines
import aoc.*
import aoc.util.getDayInput
val testInput = """
O....#....
O.OO#....#
.....##...
OO.#O....O
.O.....O#.
O.#..O.#.#
..O..#O..O
.......O..
#....###..
#OO..#....
""".parselines
class Rocks(val initLines: List<String>) {
var curLines: MutableList<MutableList<Char>... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 3,203 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/hopkins/aoc/day1/main.kt | edenrox | 726,934,488 | false | {"Kotlin": 88215} | package com.hopkins.aoc.day1
import java.io.File
const val debug = true
const val part = 2
val digits = listOf("1", "2", "3", "4", "5", "6" ,"7", "8", "9")
val digitNames = listOf("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
val valueMap: Map<String, Int> = buildMap {
digits.mapIndexed ... | 0 | Kotlin | 0 | 0 | 45dce3d76bf3bf140d7336c4767e74971e827c35 | 1,784 | aoc2023 | MIT License |
classroom/src/main/kotlin/com/radix2/algorithms/extras/RunningMedian.kt | rupeshsasne | 190,130,318 | false | {"Java": 66279, "Kotlin": 50290} | package com.radix2.algorithms.extras
import java.util.PriorityQueue
fun runningMedian(a: Array<Int>): Array<Double> {
val minPQ = PriorityQueue<Int> { o1, o2 -> o2.compareTo(o1) }
val maxPQ = PriorityQueue<Int>()
val medians = Array(a.size) { 0.0 }
for (i in 0..a.lastIndex) {
add(a[i], minPQ... | 0 | Java | 0 | 1 | 341634c0da22e578d36f6b5c5f87443ba6e6b7bc | 1,681 | coursera-algorithms-part1 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SearchInRotatedSortedArray2.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,777 | kotlab | Apache License 2.0 |
src/Day04.kt | bromhagen | 572,988,081 | false | {"Kotlin": 3615} | import kotlin.math.min
fun main() {
fun splitToIntRanges(pair: String): Pair<IntRange, IntRange> {
val ranges = pair.split(",").map {
val start = it.split("-")[0]
val end = it.split("-")[1]
IntRange(start.toInt(), end.toInt())
}
val first = ranges[0]
... | 0 | Kotlin | 0 | 0 | 0ee6d96e790d9ebfab882351b3949c9ba372cb3e | 1,064 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day08_seven_segment/SevenSegment.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day08_seven_segment
import kotlin.experimental.and
import kotlin.experimental.or
import kotlin.experimental.xor
/**
* Well this is easy, just grab the stuff after the pipe and count how many
* strings have length 1, 4, 7, or 8. Done! Smells like a trap...
*
* Part two is about picking structures based on ... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 3,885 | aoc-2021 | MIT License |
src/Day08.kt | uekemp | 575,483,293 | false | {"Kotlin": 69253} |
fun parseInput(input: List<String>): Array<IntArray> {
val cols = input[0].length
val rows = input.size
val grid = Array(rows) { IntArray(cols) }
input.forEachIndexed { y, line ->
val row = grid[y]
line.toCharArray().forEachIndexed { x, char ->
row[x] = char.digitToInt()
... | 0 | Kotlin | 0 | 0 | bc32522d49516f561fb8484c8958107c50819f49 | 2,231 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day20/Day20.kt | ritesh-singh | 572,210,598 | false | {"Kotlin": 99540} | package day20
import readInput
import java.util.UUID
data class Node(
var uuid: UUID,
var value: Long,
var next: Node? = null,
var prev: Node? = null
) {
override fun toString(): String {
return value.toString()
}
}
class CircularLinkedList {
private val listOfPointers = mutableL... | 0 | Kotlin | 0 | 0 | 17fd65a8fac7fa0c6f4718d218a91a7b7d535eab | 2,848 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/patbeagan/days/Day09.kt | patbeagan1 | 576,401,502 | false | {"Kotlin": 57404} | package dev.patbeagan.days
import dev.patbeagan.days.Day09.Point.Companion.coord
import java.lang.IllegalArgumentException
import kotlin.math.atan2
import kotlin.math.hypot
import kotlin.math.sqrt
/**
* [Day 9](https://adventofcode.com/2022/day/9)
*/
class Day09 : AdventDay<Int> {
override fun part1(input: Stri... | 0 | Kotlin | 0 | 0 | 4e25b38226bcd0dbd9c2ea18553c876bf2ec1722 | 4,021 | AOC-2022-in-Kotlin | Apache License 2.0 |
src/Day05.kt | gillyobeast | 574,413,213 | false | {"Kotlin": 27372} | import utils.appliedTo
import utils.readInput
import java.util.*
fun main() {
val whitespace = "\\s".toRegex()
fun List<String>.extractIndices(): List<String> {
return last().chunked(4).filter(String::isNotBlank)
}
fun parse(input: List<String>): Pair<List<String>, List<String>> = input
... | 0 | Kotlin | 0 | 0 | 8cdbb20c1a544039b0e91101ec3ebd529c2b9062 | 3,021 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/org/deep/quined/main.kt | RedDocMD | 347,395,585 | false | null | package org.deep.quined
import org.deep.quined.algo.Cube
import org.deep.quined.algo.findMinCovers
import org.deep.quined.algo.partitionCubesByOneCount
import org.deep.quined.algo.reduceOneStep
import java.io.BufferedReader
import java.io.InputStreamReader
fun main(args: Array<String>) {
val reader = BufferedRead... | 0 | Kotlin | 1 | 3 | 22e0783bcc257ffad15cbf3008ab59b623787920 | 3,145 | QuinedAgain | MIT License |
kotlin/0983-minimum-cost-for-tickets.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /*
* DFS solution
*/
class Solution {
fun mincostTicketsRecursive(days: IntArray, costs: IntArray): Int {
val dp = mutableMapOf<Int, Int>()
fun dfs(dayIndex: Int): Int {
if (dayIndex == days.size) return 0
if (dayIndex in dp) return dp[dayIndex]!!
dp[dayIndex] ... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,397 | leetcode | MIT License |
src/Day03.kt | manuel-martos | 574,260,226 | false | {"Kotlin": 7235} | fun main() {
println("part01 -> ${solveDay03Part01()}")
println("part02 -> ${solveDay03Part02()}")
}
private fun solveDay03Part01() =
readInput("day03")
.sumOf { line ->
val half1 = line.substring(0 until line.length / 2).toSet()
val half2 = line.substring(line.length / 2 un... | 0 | Kotlin | 0 | 0 | 5836682fe0cd88b4feb9091d416af183f7f70317 | 777 | advent-of-code-2022 | Apache License 2.0 |
solutions/src/Day06.kt | khouari1 | 573,893,634 | false | {"Kotlin": 132605, "HTML": 175} | fun main() {
fun part1(input: String): Int = count(input, 4)
fun part2(input: String): Int = count(input, 14)
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day06_test").first()
check(part1(testInput) == 7)
check(part2(testInput) == 19)
val... | 0 | Kotlin | 0 | 1 | b00ece4a569561eb7c3ca55edee2496505c0e465 | 1,154 | advent-of-code-22 | Apache License 2.0 |
src/main/day10/Day10.kt | rolf-rosenbaum | 543,501,223 | false | {"Kotlin": 17211} | package day10
import day06.Point
import readInput
fun part1(input: List<String>) {
var stars = input.map { it.toStar() }
var seconds = 0
do {
stars = stars.move()
seconds++
} while(!stars.prettyPrint())
println(seconds)
}
fun main() {
val input = readInput("main/day10/Da... | 0 | Kotlin | 0 | 0 | dfd7c57afa91dac42362683291c20e0c2784e38e | 1,395 | aoc-2018 | Apache License 2.0 |
src/week-day-1/ContainsDuplicate.kt | luix | 573,258,926 | false | {"Kotlin": 7897, "Java": 232} | package week1
/**
* Contains Duplicate (easy)
* Problem Statement
* Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
*
* Example 1:
*
* Input: nums= [1, 2, 3, 4]
* Output: false
* Explanation: There are no duplicates in t... | 0 | Kotlin | 0 | 0 | 8e9b605950049cc9a0dced9c7ba99e1e2458e53e | 1,087 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2023/day08/day8.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2023.day08
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val map = parseWastelandMap(inputFile.bufferedReader().readLines())
println("It takes ${map.followInstructions().size - 1} moves to move from $START_ID to $END_ID")
pri... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 4,264 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/TreeAncestor.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,276 | kotlab | Apache License 2.0 |
src/Day03.kt | jamie23 | 573,156,415 | false | {"Kotlin": 19195} | fun main() {
fun part1(input: List<String>) = input
.map { s ->
listOf(
s.substring(0, s.length / 2),
s.substring(
s.length / 2, s.length
)
)
}
.map { it.commonChar() }
.sumOf { it.calculatePr... | 0 | Kotlin | 0 | 0 | cfd08064654baabea03f8bf31c3133214827289c | 994 | Aoc22 | Apache License 2.0 |
src/day01/Day01.kt | banshay | 572,450,866 | false | {"Kotlin": 33644} | fun main() {
fun part1(input: Elves): Int {
return input.maxOf { it.value.sum() }
}
fun part2(input: Elves): Int {
val maxList = input.map { it.value.sum() }.sortedDescending()
return maxList[0] + maxList[1] + maxList[2]
}
fun sanitizeInput(input: String): Elves {
... | 0 | Kotlin | 0 | 0 | c3de3641c20c8c2598359e7aae3051d6d7582e7e | 1,331 | advent-of-code-22 | Apache License 2.0 |
src/main/kotlin/com/dmc/advent2022/Day11.kt | dorienmc | 576,916,728 | false | {"Kotlin": 86239} | package com.dmc.advent2022
//--- Day 11: Monkey in the Middle ---
class Day11 : Day<Long> {
override val index = 11
override fun part1(input: List<String>): Long {
val monkeys: List<Monkey> = input.chunked(7).map { Monkey.of(it) }
repeat(20) {
monkeys.play{ it / 3 }
}
... | 0 | Kotlin | 0 | 0 | 207c47b47e743ec7849aea38ac6aab6c4a7d4e79 | 3,703 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/day1.kt | kevinrobayna | 317,548,264 | false | null | import java.util.stream.Collectors
// https://adventofcode.com/2020/day/1
class Day1(
private val values: List<Int>
) {
fun solve(): Pair<Int, Int> {
val pairs: MutableList<Pair<Int, Int>> = mutableListOf()
for (outLoop in values.indices) {
for (innerLoop in values.indices) {
... | 0 | Kotlin | 0 | 0 | 8b1a84dc1fbace0d87866ae57791db3a67bcba70 | 1,857 | adventofcode_2020 | MIT License |
src/Day03/Day03.kt | hectdel | 573,376,349 | false | {"Kotlin": 5426} | package Day03
import java.io.File
fun main() {
val chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun Char.toValue(): Int = chars.indexOf(this) + 1
check('p'.toValue() == 16)
check('L'.toValue() == 38)
fun part1(input: String): Int {
var commonChars = mutableListOf<Char... | 0 | Kotlin | 0 | 0 | cff5677a654a18ceb199cc52fdd1c865dea46e1e | 1,569 | aco-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxProbability.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 | 4,699 | kotlab | Apache License 2.0 |
codeforces/src/main/kotlin/contest1911/e.kt | austin226 | 729,634,548 | false | {"Kotlin": 23837} | import java.util.*
private fun String.splitWhitespace() = split("\\s+".toRegex())
fun greatestPowerUpTo(n: Int): Int? {
if (n < 1) {
return null
}
var p = 1
while (p < n) {
if (p * 2 > n) {
return p
}
p *= 2
}
return p
}
fun asPower2Sum(n: Int, k: I... | 0 | Kotlin | 0 | 0 | 4377021827ffcf8e920343adf61a93c88c56d8aa | 1,569 | codeforces-kt | MIT License |
src/main/kotlin/de/dikodam/calendar/Day04.kt | dikodam | 433,719,746 | false | {"Kotlin": 51383} | package de.dikodam.calendar
import de.dikodam.AbstractDay
import de.dikodam.executeTasks
import kotlin.time.ExperimentalTime
@ExperimentalTime
fun main() {
Day04().executeTasks()
}
private const val lineBreak = "\r\n"
class Day04 : AbstractDay() {
val rawInput = readInputRaw()
override fun task1(): S... | 0 | Kotlin | 0 | 1 | 4934242280cebe5f56ca8d7dcf46a43f5f75a2a2 | 3,107 | aoc-2021 | MIT License |
src/main/kotlin/se/brainleech/adventofcode/aoc2020/Aoc2020Day02.kt | fwangel | 435,571,075 | false | {"Kotlin": 150622} | package se.brainleech.adventofcode.aoc2020
import se.brainleech.adventofcode.compute
import se.brainleech.adventofcode.readLines
import se.brainleech.adventofcode.verify
class Aoc2020Day02 {
open class PasswordPolicy(
val limitRule: String,
val character: Char,
val password: String
) ... | 0 | Kotlin | 0 | 0 | 0bba96129354c124aa15e9041f7b5ad68adc662b | 2,192 | adventofcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinPenaltyForShop.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,456 | kotlab | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.