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/Day03.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | import java.lang.IllegalArgumentException
fun main() {
fun Char.priority(): Int = when (this) {
in 'A'..'Z' -> this - 'A' + 27
in 'a'..'z' -> this - 'a' + 1
else -> throw IllegalArgumentException()
}
fun part1(input: List<String>): Int {
return input.sumOf { bag ->
... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 980 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day10.kt | zhiqiyu | 573,221,845 | false | {"Kotlin": 20644} |
val cyclesToLook = arrayOf(20, 60, 100, 140, 180, 220)
class Machine(var width: Int, var height: Int) {
var spritePos: Int
var cycle: Int
var signalStrength: Int
var screen: Array<Array<Char>>
init {
spritePos = 1
cycle = 0
signalStrength = 0
screen = Array(height) ... | 0 | Kotlin | 0 | 0 | d3aa03b2ba2a8def927b94c2b7731663041ffd1d | 2,183 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/me/astynax/aoc2023kt/Day04.kt | astynax | 726,011,031 | false | {"Kotlin": 9743} | package me.astynax.aoc2023kt
import kotlin.math.pow
import kotlin.math.roundToInt
object Day04 {
data class Game(val id: Int, val points: Int) {
companion object {
private val space = Regex("\\s+")
private val pipe = Regex(" \\| ")
fun fromString(s: String): Game {
val halves = s.spli... | 0 | Kotlin | 0 | 0 | 9771b5ccde4c591c7edb413578c5a8dadf3736e0 | 1,247 | aoc2023kt | MIT License |
Advent-of-Code-2023/src/Day10.kt | Radnar9 | 726,180,837 | false | {"Kotlin": 93593} | private const val AOC_DAY = "Day10"
private const val PART1_TEST_FILE = "${AOC_DAY}_test_part1"
private const val PART2_TEST_FILE = "${AOC_DAY}_test_part2"
private const val INPUT_FILE = AOC_DAY
private data class Point(val x: Int, val y: Int)
private data class Path(val prev: Point, val next: Point)
private val pipes... | 0 | Kotlin | 0 | 0 | e6b1caa25bcab4cb5eded12c35231c7c795c5506 | 8,125 | Advent-of-Code-2023 | Apache License 2.0 |
2021/src/test/kotlin/Day11.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import kotlin.test.Test
import kotlin.test.assertEquals
class Day11 {
data class Coord(val x: Int, val y: Int)
data class Octopus(val coord: Coord, var energy: Int)
private val flashArea =
listOf(
Coord(-1, -1), Coord(0, -1), Coord(1, -1),
Coord(-1, 0), Coord(0, 0), Coord(1,... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 2,083 | adventofcode | MIT License |
src/Day05.kt | stevefranchak | 573,628,312 | false | {"Kotlin": 34220} | class CrateStacks {
companion object {
private val EXTRACT_CRATE_ID_REGEX = Regex("""[A-Z]""")
}
private val stacks: MutableMap<Int, ArrayDeque<Char>> = mutableMapOf()
fun addToStartingStacks(inputLine: String) {
inputLine.chunked(4).asSequence()
.map { crate -> EXTRACT_CRA... | 0 | Kotlin | 0 | 0 | 22a0b0544773a6c84285d381d6c21b4b1efe6b8d | 3,629 | advent-of-code-2022 | Apache License 2.0 |
marathons/icpcchallenge/y2020_huaweiGraphMining/a.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package marathons.icpcchallenge.y2020_huaweiGraphMining
import java.io.BufferedReader
import java.io.FileReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.pow
import kotlin.random.asJavaRandom
fun solve(fileName: String, nei: List<IntArray>) {
val outputFile = "$fileName.out"
val auxFile = "$f... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 6,902 | competitions | The Unlicense |
src/main/kotlin/Day1.kt | maldoinc | 726,264,110 | false | {"Kotlin": 14472} | import java.io.File
fun getFirstAndLastDigitsFromString(input: String): Pair<Int, Int>? {
val digits = input.filter { it.isDigit() }.map { it.digitToInt() }
return if (digits.isNotEmpty()) {
digits.first() to digits.last()
} else {
null
}
}
fun getFirstAndLastDigitsFromStringWithWords... | 0 | Kotlin | 0 | 1 | 47a1ab8185eb6cf16bc012f20af28a4a3fef2f47 | 1,502 | advent-2023 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/UniqueOccurrences.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,787 | kotlab | Apache License 2.0 |
kotest-property/src/commonMain/kotlin/io/kotest/property/exhaustive/strings.kt | kotest | 47,071,082 | false | {"Kotlin": 4460715, "CSS": 352, "Java": 145} | package io.kotest.property.exhaustive
import io.kotest.property.Exhaustive
import io.kotest.property.RandomSource
fun Exhaustive.Companion.azstring(range: IntRange): Exhaustive<String> {
fun az() = ('a'..'z').map { it.toString() }
val values = range.toList().flatMap { size ->
List(size) { az() }.reduce { ... | 102 | Kotlin | 615 | 4,198 | 7fee2503fbbdc24df3c594ac6b240c11b265d03e | 1,781 | kotest | Apache License 2.0 |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day6/OrbitMap.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.day6
import java.util.*
class OrbitMap(items: List<String>) {
private val rootNode = buildNodeTree(items)
fun calculateChecksum(): Int {
var checksum = 0
val stack = Stack<Node>()
stack.push(rootNode)
while (stack.isNotEmpty... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 3,473 | advent-of-code | Apache License 2.0 |
src/main/kotlin/year2022/Day09.kt | forketyfork | 572,832,465 | false | {"Kotlin": 142196} | package year2022
import utils.Direction
import utils.Point2D
import kotlin.math.abs
import kotlin.math.sign
class Day09 {
private fun solution(input: String, len: Int): Int {
val positions = mutableSetOf<Point2D>()
val parts = MutableList(len) { Point2D(0, 0) }
positions.add(parts.last())... | 0 | Kotlin | 0 | 0 | 5c5e6304b1758e04a119716b8de50a7525668112 | 1,432 | aoc-2022 | Apache License 2.0 |
kotlin/ConvexHull.kt | indy256 | 1,493,359 | false | {"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571} | data class Point(val x: Int, val y: Int)
// Convex hull in O(n*log(n))
fun convexHull(points: Array<Point>): Array<Point> {
fun isNotRightTurn(p3: List<Point>): Boolean {
val (a, b, c) = p3
val cross = (a.x - b.x).toLong() * (c.y - b.y) - (a.y - b.y).toLong() * (c.x - b.x)
val dot = (a.x -... | 97 | Java | 561 | 1,806 | 405552617ba1cd4a74010da38470d44f1c2e4ae3 | 1,098 | codelibrary | The Unlicense |
src/main/kotlin/algorithms/ShortestSuperstring.kt | jimandreas | 377,843,697 | false | null | @file:Suppress("MemberVisibilityCanBePrivate")
package algorithms
/**
* See also:
* http://rosalind.info/problems/long/
* Introduction to Genome Sequencing
*
* Problem
Problem
For a collection of strings, a larger string containing every
one of the smaller strings as a substring is called a superstring.
By th... | 0 | Kotlin | 0 | 0 | fa92b10ceca125dbe47e8961fa50242d33b2bb34 | 6,104 | stepikBioinformaticsCourse | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem2130/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2130
import com.hj.leetcode.kotlin.common.model.ListNode
/**
* LeetCode page: [2130. Maximum Twin Sum of a Linked List](https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(N) where N is the size ... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,582 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/13.kt | NeonMika | 433,743,141 | false | {"Kotlin": 68645} | class Day13 : Day<Day13.PaperFolding>("13") {
data class FoldInstruction(val axis: Char, val line: Int)
infix fun Char.foldBy(amount: Int) = FoldInstruction(this, amount)
data class PaperFolding(val dots: TwoDimensionalArray<Boolean>, val folds: List<FoldInstruction>) {
val nextFold
ge... | 0 | Kotlin | 0 | 0 | c625d684147395fc2b347f5bc82476668da98b31 | 2,618 | advent-of-code-2021 | MIT License |
src/main/kotlin/com/chriswk/aoc/advent2020/Day19.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2020
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.report
class Day19 : AdventDay(2020, 19) {
companion object {
@JvmStatic
fun main(args: Array<String>): Unit {
val day = Day19()
report {
day.part1()
... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 2,612 | adventofcode | MIT License |
src/Day03.kt | saikatsgupta | 572,824,837 | false | {"Kotlin": 2709} | fun main() {
fun Char.getPriority(): Int {
return when {
isUpperCase() -> code - 'A'.code + 27
else -> code - 'a'.code + 1
}
}
fun part1(input: List<String>): Int {
return input.sumOf {
val compartment1 = it.take(it.length / 2)
val co... | 0 | Kotlin | 0 | 1 | 2c491a9e5ddc7c08fbeacccce29f574510cd0288 | 736 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day05.kt | Kanialdo | 573,165,497 | false | {"Kotlin": 15615} | fun main() {
val moveRegex = "move (\\d+) from (\\d+) to (\\d+)".toRegex()
fun part1(input: String): String {
val (stack, moves) = input.split("\n\n").map { it.lines() }
val size = stack.last().trim().last().digitToInt()
val data = List<ArrayDeque<Char>>(size) { ArrayDeque() }
... | 0 | Kotlin | 0 | 0 | 10a8550a0a85bd0a928970f8c7c5aafca2321a4b | 1,947 | advent-of-code-2022 | Apache License 2.0 |
src/day_4/kotlin/Day4.kt | Nxllpointer | 573,051,992 | false | {"Kotlin": 41751} | // AOC Day 4
fun part1(pairs: List<Pair<IntRange, IntRange>>) {
val containingCount = pairs.count { it.first.containsAll(it.second) || it.second.containsAll(it.first) }
println("Part 1: In $containingCount assignment pairs one fully contains the others assignment")
}
fun part2(pairs: List<Pair<IntRange, IntR... | 0 | Kotlin | 0 | 0 | b6d7ef06de41ad01a8d64ef19ca7ca2610754151 | 826 | AdventOfCode2022 | MIT License |
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/UnboundedKnapsack.kt | betulnecanli | 568,477,911 | false | {"Kotlin": 167849} | /*
Use this technique to select elements that give maximum profit from a given set with a limitation on capacity
and that each element can be picked multiple times.
*/
//1. Rod Cutting
fun maxRodCuttingProfit(lengths: IntArray, prices: IntArray, rodLength: Int): Int {
val n = lengths.size
// Create a 1D arra... | 2 | Kotlin | 2 | 40 | 70a4a311f0c57928a32d7b4d795f98db3bdbeb02 | 2,353 | Kotlin-Data-Structures-Algorithms | Apache License 2.0 |
shared/src/commonMain/kotlin/com/joetr/sync/sphere/ui/results/AvailabilityCalculator.kt | j-roskopf | 712,951,839 | false | {"Kotlin": 1486933, "Ruby": 3083, "Shell": 1352, "Swift": 588} | package com.joetr.sync.sphere.ui.results
import com.joetr.sync.sphere.data.model.People
import com.joetr.sync.sphere.ui.results.data.ALL_DAY
import com.joetr.sync.sphere.ui.results.data.NONE
import com.joetr.sync.sphere.ui.results.data.Time
import com.joetr.sync.sphere.ui.results.data.TimeRange
import com.joetr.sync.s... | 0 | Kotlin | 0 | 1 | 39a74df18fc0c00515027cd7f52e9539214b0085 | 3,673 | SyncSphere | MIT License |
puzzles/kotlin/src/mayan-calc/mayan-calc.kt | charlesfranciscodev | 179,561,845 | false | {"Python": 141140, "Java": 34848, "Kotlin": 33981, "C++": 27526, "TypeScript": 22844, "C#": 22075, "Go": 12617, "JavaScript": 11282, "Ruby": 6255, "Swift": 3911, "Shell": 3090, "Haskell": 1375, "PHP": 1126, "Perl": 667, "C": 493} | import java.util.Scanner
const val BASE = 20
val input = Scanner(System.`in`)
fun main(args : Array<String>) {
val width = input.nextInt()
val height = input.nextInt()
val numerals = ArrayList<String>() // mayan numerals
val numeralMap = HashMap<String, Long>() // mayan numeral -> base 20 number
for (i in ... | 0 | Python | 19 | 45 | 3ec80602e58572a0b7baf3a2829a97e24ca3460c | 2,376 | codingame | MIT License |
src/y2022/Day04.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.readInput
object Day04 {
fun part1(input: List<String>): Int {
return input.count { fullyContains(it) }
}
private fun inputToRanges(input: String): Pair<IntRange, IntRange> {
val (p1, p2) = input.split(",")
.map {
it.split("-")
... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 1,154 | advent-of-code | Apache License 2.0 |
src/main/kotlin/g0601_0700/s0632_smallest_range_covering_elements_from_k_lists/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0601_0700.s0632_smallest_range_covering_elements_from_k_lists
// #Hard #Array #Hash_Table #Sorting #Greedy #Heap_Priority_Queue #Sliding_Window
// #2023_02_09_Time_399_ms_(83.33%)_Space_59.2_MB_(66.67%)
import java.util.Objects
import java.util.PriorityQueue
class Solution {
internal class Triplet(var v... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,813 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/colinodell/advent2023/Search.kt | colinodell | 726,073,391 | false | {"Kotlin": 114923} | package com.colinodell.advent2023
import java.util.PriorityQueue
data class Seen<State>(val cost: Int, val prev: State?)
private data class Scored<State>(val state: State, val cost: Int, private val heuristic: Int) : Comparable<Scored<State>> {
override fun compareTo(other: Scored<State>): Int = (cost + heuristic... | 0 | Kotlin | 0 | 0 | 97e36330a24b30ef750b16f3887d30c92f3a0e83 | 1,682 | advent-2023 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ContainsDuplicate2.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,169 | kotlab | Apache License 2.0 |
src/main/kotlin/adventofcode/y2021/Day08.kt | Tasaio | 433,879,637 | false | {"Kotlin": 117806} | import adventofcode.allPermutations
fun main() {
val testInput = """
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb c... | 0 | Kotlin | 0 | 0 | cc72684e862a782fad78b8ef0d1929b21300ced8 | 3,390 | adventofcode2021 | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ConstructQuadTree.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,961 | kotlab | Apache License 2.0 |
src/Day01.kt | Inn0 | 573,532,249 | false | {"Kotlin": 16938} | fun main() {
fun getElvesList(input: List<String>): MutableList<MutableList<Int>> {
val elvesList: MutableList<MutableList<Int>> = mutableListOf()
var elf: MutableList<Int> = mutableListOf()
input.forEach {
if (it == ""){
elvesList.add(elf)
elf = m... | 0 | Kotlin | 0 | 0 | f35b9caba5f0c76e6e32bc30196a2b462a70dbbe | 1,710 | aoc-2022 | Apache License 2.0 |
src/day03/Day03.kt | Xlebo | 572,928,568 | false | {"Kotlin": 10125} | package day03
import getOrFetchInputData
import readInput
fun main() {
fun getValueOfItem(item: Char): Int {
return if (item.isLowerCase()) {
item.code - 96
} else {
item.code - 38
}
}
fun part1(input: List<String>): Int {
return input.map { Pair(i... | 0 | Kotlin | 0 | 0 | cd718c2c7cb59528080d2aef599bd93e0919d2d9 | 1,190 | aoc2022 | Apache License 2.0 |
test/leetcode/AssignCookies.kt | andrej-dyck | 340,964,799 | false | null | package leetcode
import lib.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.params.*
import org.junit.jupiter.params.converter.*
import org.junit.jupiter.params.provider.*
/**
* https://leetcode.com/problems/assign-cookies/
*
* 455. Assign Cookies
* [Easy]
*
* Assume you are an awes... | 0 | Kotlin | 0 | 0 | 3e3baf8454c34793d9771f05f330e2668fda7e9d | 3,151 | coding-challenges | MIT License |
src/main/kotlin/days/Day6.kt | MaciejLipinski | 317,582,924 | true | {"Kotlin": 60261} | package days
class Day6 : Day(6) {
override fun partOne(): Any {
return splitIntoGroups(inputString)
.map { FormGroup.from(it) }
.map { it.distinctAnswers() }
.map { it.count() }
.sum()
}
override fun partTwo(): Any {
return s... | 0 | Kotlin | 0 | 0 | 1c3881e602e2f8b11999fa12b82204bc5c7c5b51 | 1,471 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/github/dangerground/aoc2020/Day14.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
import kotlin.math.pow
fun main() {
val process = Day14(DayInput.asStringList(14))
println("result part 1: ${process.part1()}")
println("result part 2: ${process.part2()}")
}
class Day14(val input: List<String>)... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 4,418 | adventofcode-2020 | MIT License |
src/day8/Day08.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day8
import readInput
private var counter: Int = 0
private fun part1(input: List<String>): Int {
val grid: Array<IntArray> = Array(input.size) { IntArray(input[0].length) }
val added: Array<BooleanArray> = Array(input.size) { BooleanArray(input[0].length) }
for (row in input.indices) {
f... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 4,306 | aoc-2022 | Apache License 2.0 |
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Collections.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.common
import java.util.*
/**
* Generates all permutations of a list.
* @see <a href="https://rosettacode.org/wiki/Permutations#Kotlin">Source on RosettaCode</a>
*/
fun <T> List<T>.permutations(): List<List<T>> {
if (this.size == 1) return listOf(this)
val perms = mutableListOf<List<... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 2,111 | advent-of-code | MIT License |
leetcode/kotlin/insert-interval.kt | PaiZuZe | 629,690,446 | false | null | import kotlin.math.max
class Solution {
fun insert(intervals: Array<IntArray>, newInterval: IntArray): Array<IntArray> {
val newIntervals = mutableListOf<IntArray>()
var newIserted = false
if (intervals.size == 0 || intervals[0][0] >= newInterval[0]) {
newIntervals.add(... | 0 | Kotlin | 0 | 0 | 175a5cd88959a34bcb4703d8dfe4d895e37463f0 | 2,957 | interprep | MIT License |
src/main/kotlin/day23/Day23.kt | Arch-vile | 317,641,541 | false | null | package day23
class Cup(val label: Int, var previous: Cup?, var next: Cup?) {
fun joinWith(joinWith: Cup) {
next = joinWith
joinWith.previous = this
}
override fun toString() = label.toString()
}
fun main(args: Array<String>) {
val maxCupLabel = 1000000
val cupSetting = "253149867".windowed(1)
... | 0 | Kotlin | 0 | 0 | 12070ef9156b25f725820fc327c2e768af1167c0 | 2,113 | adventOfCode2020 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindDuplicate.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,103 | kotlab | Apache License 2.0 |
src/Day01.kt | esp-er | 573,196,902 | false | {"Kotlin": 29675} | package patriker.day01
import patriker.utils.*
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInputText("Day01_test")
check(solvePart1(testInput) == 24000)
check(solvePart2(testInput) == listOf(24000, 11000, 10000))
val input = readInputText(... | 0 | Kotlin | 0 | 0 | f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362 | 892 | aoc2022 | Apache License 2.0 |
src/Day11.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | fun main() {
val multiply = 0
val add = 1
data class Data(
val items: ArrayDeque<Long>,
val operation: Int,
val operand: Long,
val divisor: Long,
val passTrue: Int,
val passFalse: Int
)
fun parseInput(input: List<String>): List<Data> {
var i =... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 4,161 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day24.kt | mstar95 | 317,305,289 | false | null | package days
import arrow.core.mapOf
import days.Direction.E
import days.Direction.NE
import days.Direction.NW
import days.Direction.SE
import days.Direction.SW
import days.Direction.W
import days.HexColor.*
class Day24 : Day(24) {
override fun partOne(): Any {
val input = parseInput(inputList)
p... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 3,910 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/Day10.kt | mr-cell | 575,589,839 | false | {"Kotlin": 17585} | import kotlin.math.absoluteValue
fun main() {
fun part1(input: List<String>): Int {
val signals = parseInput(input).runningReduce(Int::plus)
return signals.sampleSignals().sum()
}
fun part2(input: List<String>) {
val signals = parseInput(input).runningReduce(Int::plus)
sig... | 0 | Kotlin | 0 | 0 | 2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9 | 1,366 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem1380/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1380
/**
* LeetCode page: [1380. Lucky Numbers in a Matrix](https://leetcode.com/problems/lucky-numbers-in-a-matrix/);
*/
class Solution {
/* Complexity:
* Time O(MN) and Space O(1) where M and N are mat.length and mat[0].length;
*/
fun luckyNumbers(matrix: Arr... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,511 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day07/day7.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day07
import biz.koziolek.adventofcode.findInput
import kotlin.math.abs
fun main() {
val inputFile = findInput(object {})
val line = inputFile.bufferedReader().readLines().first()
val (position, cost) = findCheapestPosition(line, ::calculateLinearCost)
print... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 1,216 | advent-of-code | MIT License |
src/main/kotlin/com/chriswk/aoc/advent2018/Day2.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2018
object Day2 {
fun partOne(input: List<String>): Int {
val (twos, threes) = input.asSequence().map { line ->
val charCount = line.groupBy { c -> c }.mapValues { it.value.size }
val hasTwoChars = charCount.entries.any { it.value == 2 }
va... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 1,311 | adventofcode | MIT License |
src/Day07.kt | tristanrothman | 572,898,348 | false | null | data class Directory(
val path: String,
) {
fun back(): Directory {
return Directory(path.substringBeforeLast('/'))
}
}
data class FileSystem(
var pwd: Directory,
val sizes: MutableMap<Directory, Int> = mutableMapOf(pwd to 0)
) {
fun cd(dir: String) {
pwd = when (dir) {
... | 0 | Kotlin | 0 | 0 | e794ab7e0d50f22d250c65b20e13d9b5aeba23e2 | 1,624 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinSubsequence.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,339 | kotlab | Apache License 2.0 |
app/src/main/java/com/alqoview/data/source/LeetCode_1-5.kt | alonsd | 581,167,011 | false | {"Kotlin": 64432} | package com.alqoview.data.source
import com.alqoview.model.AlgorithmicProblem
val leetcode1 = AlgorithmicProblem(
problemId = 1,
questionNumber = 1,
title = "Two Sum",
problemDescription = "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up t... | 0 | Kotlin | 0 | 0 | c43f3f20c169fff1511391452b3a7a21f1913276 | 15,633 | AlqoView | Apache License 2.0 |
codeforces/deltix2021summer/f.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.deltix2021summer
fun main() {
readLn()
val strengths = readInts().map { it.toModular() }
val n = strengths.size
val probWin = Array(n) { i -> Array(n) { j -> strengths[i] / (strengths[i] + strengths[j]) } }
val masks = 1 shl n
val pScc = Array(masks) { 1.toModular() }
var ans = 0.toModular()
... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 2,238 | competitions | The Unlicense |
src/Day09.kt | a2xchip | 573,197,744 | false | {"Kotlin": 37206} | import kotlin.math.abs
import kotlin.math.sign
class RopeAction(val direction: Direction, val stepsCount: Int) {
companion object {
fun fromString(s: String): RopeAction {
val (d, c) = s.split(" ")
return RopeAction(Direction.valueOf(d), c.toInt())
}
}
}
enum class Dire... | 0 | Kotlin | 0 | 2 | 19a97260db00f9e0c87cd06af515cb872d92f50b | 3,609 | kotlin-advent-of-code-22 | Apache License 2.0 |
src/main/kotlin/io/array/MinimumWindowSubstring.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.array
import io.utils.runTests
// https://leetcode.com/problems/minimum-window-substring/
class MinimumWindowSubstring {
fun execute(input: String, chars: String): String {
if (chars.isEmpty() || input.isEmpty() || chars.length > input.length) return ""
val charsSet = chars.fold(mutableMapOf<Char... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,943 | coding | MIT License |
src/main/kotlin/Day03.kt | ripla | 573,901,460 | false | {"Kotlin": 19599} | object Day3 {
private val characterRanges = CharRange('a', 'z') + CharRange('A', 'Z')
private fun characterPriority(char: Char): Int = characterRanges.indexOf(char) + 1
fun part1(input: List<String>): Int {
return input.map { Pair(it.take(it.length / 2), it.takeLast(it.length / 2)) }
... | 0 | Kotlin | 0 | 0 | e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8 | 757 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day14.kt | JIghtuse | 572,807,913 | false | {"Kotlin": 46764} | package day14
import readText
data class Position(val x: Int, val y: Int)
val SandSource = Position(500, 0)
fun String.toPosition(): Position {
val parts = this.split(",")
return Position(parts[0].toInt(), parts[1].toInt())
}
fun String.toPositionList() =
this
.split(" -> ")
.map(String::toPosit... | 0 | Kotlin | 0 | 0 | 8f33c74e14f30d476267ab3b046b5788a91c642b | 4,007 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/ru/itmo/ctlab/gmwcs/solver/TreeSolver.kt | ctlab | 290,164,889 | false | {"Java": 250115, "Kotlin": 21543} | package ru.itmo.ctlab.gmwcs.solver
import ru.itmo.ctlab.gmwcs.solver.preprocessing.preprocess
import ru.itmo.ctlab.virgo.gmwcs.graph.Edge
import ru.itmo.ctlab.virgo.gmwcs.graph.Elem
import ru.itmo.ctlab.virgo.gmwcs.graph.Graph
import ru.itmo.ctlab.virgo.gmwcs.graph.Node
import ru.itmo.ctlab.virgo.gmwcs.solver.MSTSolve... | 0 | Java | 0 | 3 | f561bdce02f43b7c58cd5334896c2aec513bda15 | 3,616 | virgo-solver | Apache License 2.0 |
src/main/kotlin/com/hopkins/aoc/day10/main.kt | edenrox | 726,934,488 | false | {"Kotlin": 88215} | package com.hopkins.aoc.day10
import java.io.File
const val debug = false
const val part = 2
/** Advent of Code 2023: Day 10 */
fun main() {
val inputFile = File("input/input10.txt")
val lines: List<String> = inputFile.readLines()
var start = Point(-1, -1)
val pieceTypeLookup = PieceType.values().as... | 0 | Kotlin | 0 | 0 | 45dce3d76bf3bf140d7336c4767e74971e827c35 | 6,509 | aoc2023 | MIT License |
day15/src/main/kotlin/Battle.kt | rstockbridge | 159,586,951 | false | null | class Battle(private val rawMap: List<String>) {
data class Result(val rounds: Int, val remainingHp: Int)
data class ShortestPathResult(val start: GridPoint2d, val distance: Int)
data class ClosestLocationResult(val closestLocation: GridPoint2d, val firstStep: GridPoint2d)
companion object {
... | 0 | Kotlin | 0 | 0 | c404f1c47c9dee266b2330ecae98471e19056549 | 13,027 | AdventOfCode2018 | MIT License |
src/Day01.kt | toninau | 729,811,683 | false | {"Kotlin": 8423} | fun main() {
val spelledToDigit = mapOf(
"one" to '1',
"two" to '2',
"three" to '3',
"four" to '4',
"five" to '5',
"six" to '6',
"seven" to '7',
"eight" to '8',
"nine" to '9',
)
fun String.firstDigit(): Char {
var string = ""
... | 0 | Kotlin | 0 | 0 | b3ce2cf2b4184beb2342dd62233b54351646722b | 1,541 | advent-of-code-2023 | Apache License 2.0 |
src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0101_0200.s0153_find_minimum_in_rotated_sorted_array
// #Medium #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_II_Day_2_Binary_Search
// #Binary_Search_I_Day_12 #Udemy_Binary_Search #Big_O_Time_O(log_N)_Space_O(log_N)
// #2022_09_06_Time_262_ms_(60.96%)_Space_35.4_MB_(86.45%)
class Solution {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,023 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/com/nibado/projects/advent/y2021/Day13.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2021
import com.nibado.projects.advent.*
object Day13 : Day {
private val input = resourceStrings(2021, 13).let { (first, second) ->
first.split("\n").map(Point::parse) to second.split("\n")
}
private val instructions = input.second.map {
it.matchGroups... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,437 | adventofcode | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions61.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
import com.qiaoyuang.algorithm.round0.PriorityQueue
import kotlin.math.min
fun test61() {
printlnResult(intArrayOf(1, 5, 13, 21), intArrayOf(2, 4, 9, 15), 3)
}
/**
* Questions 61: Given two increased IntArrays, find the k integers pair that sum is minimum
*/
private fun ... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,276 | Algorithm | Apache License 2.0 |
src/main/kotlin/Day05.kt | SimonMarquis | 570,868,366 | false | {"Kotlin": 50263} | import java.lang.System.lineSeparator
class Day05(input: String) {
private val stacks: List<ArrayDeque<Char>>
private val moves: List<Move>
init {
val (crates, procedure) = input.split(lineSeparator() * 2)
stacks = crates.lines().asReversed().drop(1).foldInPlace(
initial = Li... | 0 | Kotlin | 0 | 0 | a2129cc558c610dfe338594d9f05df6501dff5e6 | 1,475 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/github/alturkovic/robots/txt/RuleMatchingStrategy.kt | alturkovic | 636,725,117 | false | null | package com.github.alturkovic.robots.txt
interface RuleMatchingStrategy {
fun matches(rule: Rule, path: String): Boolean
}
object WildcardRuleMatchingStrategy : RuleMatchingStrategy {
override fun matches(rule: Rule, path: String): Boolean {
return matches(rule.pattern, path)
}
// taken from ... | 0 | Kotlin | 0 | 1 | a70632010f74029f5e6414aaaa464975ba51b481 | 1,994 | robots-txt | MIT License |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day24/BugPlanet.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.day24
import com.github.jrhenderson1988.adventofcode2019.common.Direction
import com.github.jrhenderson1988.adventofcode2019.common.powerOf
class BugPlanet(private val grid: Map<Pair<Int, Int>, Char>) {
private val maxY = grid.keys.map { it.second }.max()!!
... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 4,677 | advent-of-code | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/ReorderList.kt | faniabdullah | 382,893,751 | false | null | //You are given the head of a singly linked-list. The list can be represented
//as:
//
//
//L0 → L1 → … → Ln - 1 → Ln
//
//
// Reorder the list to be on the following form:
//
//
//L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …
//
//
// You may not modify the values in the list's nodes. Only nodes themselves may
//be c... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,107 | dsa-kotlin | MIT License |
src/Day05.kt | yeung66 | 574,904,673 | false | {"Kotlin": 8143} | fun main() {
fun initStacks() = listOf(ArrayDeque(), ArrayDeque("DBJV".toList()), ArrayDeque("PVBWRDF".toList()), ArrayDeque("RGFLDCWQ".toList()), ArrayDeque("WJPMLNDB".toList()),
ArrayDeque("HNBPCSQ".toList()), ArrayDeque("RDBSNG".toList()), ArrayDeque("ZBPMQFSH".toList()), ArrayDeque("WLF".toList()), Arra... | 0 | Kotlin | 0 | 0 | 554217f83e81021229759bccc8b616a6b270902c | 1,423 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/io/dmitrijs/aoc2022/Day21.kt | lakiboy | 578,268,213 | false | {"Kotlin": 76651} | package io.dmitrijs.aoc2022
import io.dmitrijs.aoc2022.Day21.Operation.DIV
import io.dmitrijs.aoc2022.Day21.Operation.MINUS
import io.dmitrijs.aoc2022.Day21.Operation.PLUS
import io.dmitrijs.aoc2022.Day21.Operation.TIMES
class Day21(input: List<String>) {
private val env = buildEnv(input)
fun puzzle1(): Long... | 0 | Kotlin | 0 | 1 | bfce0f4cb924834d44b3aae14686d1c834621456 | 4,465 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_807_Max_Increase_to_Keep_City_Skyline.kt | v43d3rm4k4r | 515,553,024 | false | {"Kotlin": 40113, "Java": 25728} | package leetcode.solutions.concrete.kotlin
import leetcode.solutions.*
import leetcode.solutions.ProblemDifficulty.*
import leetcode.solutions.validation.SolutionValidator.*
import leetcode.solutions.annotations.ProblemInputData
import leetcode.solutions.annotations.ProblemSolution
/**
* __Problem:__ There is a city... | 0 | Kotlin | 0 | 1 | c5a7e389c943c85a90594315ff99e4aef87bff65 | 3,178 | LeetcodeSolutions | Apache License 2.0 |
src/Day01.kt | monsterbrain | 572,819,542 | false | {"Kotlin": 42040} | fun main() {
fun part1MostCalories(input: List<String>): Int {
var currentElfIndex = 0
var maxElfCalories = 0
var elfCalorieCount = 0
input.forEach {
if (it.isEmpty()) {
if (elfCalorieCount > maxElfCalories) {
// println("elfCalorieCou... | 0 | Kotlin | 0 | 0 | 3a1e8615453dd54ca7c4312417afaa45379ecf6b | 1,273 | advent-of-code-kotlin-2022-Solutions | Apache License 2.0 |
neuro_router_core/src/main/java/com/victor/neuro/router/core/Nucleus.kt | Victor2018 | 538,359,659 | false | {"Kotlin": 69455} | package com.victor.neuro.router.core
import com.victor.neuro.router.core.data.Chosen
import java.util.*
/*
* -----------------------------------------------------------------
* Copyright (C) 2018-2028, by Victor, All rights reserved.
* -----------------------------------------------------------------
* File: Nucl... | 0 | Kotlin | 0 | 0 | 76abc8151196ca7f4ab0665b0a314a6c98007b5c | 4,128 | NRouter | Apache License 2.0 |
day08/Kotlin/day08.kt | Ad0lphus | 353,610,043 | false | {"C++": 195638, "Python": 139359, "Kotlin": 80248} | import java.io.*
fun print_day_8() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 8" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Seven Segment Search -c -f sma... | 0 | C++ | 0 | 0 | 02f219ea278d85c7799d739294c664aa5a47719a | 2,662 | AOC2021 | Apache License 2.0 |
kotlin/problems/src/solution/BitProblems.kt | lunabox | 86,097,633 | false | {"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966} | package solution
import kotlin.math.max
class BitProblems {
/**
* https://leetcode-cn.com/problems/single-number-iii/
*/
fun singleNumber(nums: IntArray): IntArray {
var mask = 0
nums.forEach {
mask = mask.xor(it)
}
val last = mask.and(-mask)
var ... | 0 | Kotlin | 0 | 0 | cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9 | 1,762 | leetcode | Apache License 2.0 |
src/Day11.kt | BurgundyDev | 572,937,542 | false | {"Kotlin": 11050} | fun main() {
val testInput = readInput("../inputs/Day11_test")
val input = readInput("../inputs/Day11")
// println(part1(testInput))
// println(part1(input))
println(part2(testInput))
println(part2(input))
}
enum class OperationType {
ADD, MUL, ADDOLD, MULOLD
}
class Monkey(var items: Mutabl... | 0 | Kotlin | 0 | 0 | dd931604fa35f75599ef778fc3f0f8bc82b2fce0 | 5,845 | aoc2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CloseStrings.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,427 | kotlab | Apache License 2.0 |
src/main/kotlin/day14/main.kt | janneri | 572,969,955 | false | {"Kotlin": 99028} | package day14
import day14.Direction.*
import util.readTestInput
import kotlin.math.max
private enum class Direction(val dx: Int, val dy: Int) {
LEFT( -1, 0), RIGHT( 1, 0), UP( 0, -1), DOWN( 0, 1)
}
private data class Move(val direction: Direction, val amount: Int = 1)
private data class Vector(val start: Coord... | 0 | Kotlin | 0 | 0 | 1de6781b4d48852f4a6c44943cc25f9c864a4906 | 3,929 | advent-of-code-2022 | MIT License |
src/Day06.kt | 3n3a-archive | 573,389,832 | false | {"Kotlin": 41221, "Shell": 534} | fun Day06() {
fun getXUniqueLetters(input: String, uniqueAmount: Int): Int {
val inputAsChars = input.toCharArray()
val processedChars = mutableListOf<Char>()
for ((index, char) in inputAsChars.withIndex()) {
processedChars.add(char)
if (index >= uniqueAmount) {
... | 0 | Kotlin | 0 | 0 | fd25137d2d2df0aa629e56981f18de52b25a2d28 | 1,066 | aoc_kt | Apache License 2.0 |
src/main/kotlin/day8.kt | Gitvert | 725,292,325 | false | {"Kotlin": 97000} | fun day8 (lines: List<String>) {
val map = parseDesertMap(lines)
val steps = countSteps(lines[0], map)
println("Day 8 part 1: $steps")
val ghostSteps = countGhostSteps(lines[0], map)
var lcm = ghostSteps[0]
for (i in ghostSteps.indices) {
if (i == 0) {
continue... | 0 | Kotlin | 0 | 0 | f204f09c94528f5cd83ce0149a254c4b0ca3bc91 | 2,629 | advent_of_code_2023 | MIT License |
src/2021/Day5_2.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
import kotlin.collections.HashMap
import kotlin.collections.ArrayList
class Point(val x: Int, val y: Int)
class Line(val start: Point, val end: Point) {
fun extrapolatePoints(): ArrayList<Point> {
val extrapolated = ArrayList<Point>()
if (start.y == end.y) {
if (star... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 1,344 | adventofcode | MIT License |
src/main/kotlin/days/Day9.kt | vovarova | 726,012,901 | false | {"Kotlin": 48551} | package days
import util.DayInput
class Day9 : Day("9") {
override fun partOne(dayInput: DayInput): Any {
val map = dayInput.inputList().map {
val findDiffs = findDiff(it.split(" ").map {
it.toInt()
})
val reversed = findDiffs.reversed()
v... | 0 | Kotlin | 0 | 0 | 77df1de2a663def33b6f261c87238c17bbf0c1c3 | 1,484 | adventofcode_2023 | Creative Commons Zero v1.0 Universal |
y2017/src/main/kotlin/adventofcode/y2017/Day06.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2017
import adventofcode.io.AdventSolution
import adventofcode.util.collections.takeWhileDistinct
fun main() = Day06.solve()
object Day06 : AdventSolution(2017, 6, "Memory Reallocation") {
override fun solvePartOne(input: String) =
generateSequence(parse(input), ::redistribute)
... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,045 | advent-of-code | MIT License |
src/Day04.kt | adamgaafar | 572,629,287 | false | {"Kotlin": 12429} | import java.util.regex.Pattern
fun main(){
fun part1(input: List<String>): Int {
var score = 0
for (line in input){
val (first,second) = line.split(",")
val (start1,end1) = first.split("-")
val (start2,end2) = second.split("-")
val assign1low = start1... | 0 | Kotlin | 0 | 0 | 5c7c9a2e819618b7f87c5d2c7bb6e6ce415ee41e | 1,881 | AOCK | Apache License 2.0 |
gcj/y2020/qual/e.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package gcj.y2020.qual
private fun solve(possible: String = "POSSIBLE", impossible: String = "IMPOSSIBLE"): String {
// for (n in 2..50) { solveDiagonal(n, 0, 0); solveDiagonal(n, 1, 1); solveDiagonal(n, 1, 2) }
val (n, trace) = readInts()
for (i in 1..n) for (j in 1..n) for (k in 1..n) {
if ((i == j) xor (i == k)... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 3,002 | competitions | The Unlicense |
src/main/kotlin/sschr15/aocsolutions/Day14.kt | sschr15 | 317,887,086 | false | {"Kotlin": 184127, "TeX": 2614, "Python": 446} | package sschr15.aocsolutions
import sschr15.aocsolutions.util.*
import sschr15.aocsolutions.util.watched.sumOf
/**
* AOC 2023 [Day 14](https://adventofcode.com/2023/day/14)
* Challenge: TODO (based on the day's description)
*/
object Day14 : Challenge {
@ReflectivelyUsed
override fun solve() = challenge(20... | 0 | Kotlin | 0 | 0 | e483b02037ae5f025fc34367cb477fabe54a6578 | 4,447 | advent-of-code | MIT License |
src/aoc2022/Day24.kt | NoMoor | 571,730,615 | false | {"Kotlin": 101800} | package aoc2022
import utils.*
private class Day24(val lines: List<String>) {
fun parseInput(): Triple<Coord, Coord, List<Blizz>> {
val start = Coord.xy(lines[0].indexOfFirst { it == '.' }, 0)
val end = Coord.xy(lines.last().indexOfFirst { it == '.' }, lines.size - 1)
val blizzards = mutableListOf<Bli... | 0 | Kotlin | 1 | 2 | d561db73c98d2d82e7e4bc6ef35b599f98b3e333 | 4,511 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/dr206/2022/Day01.kt | dr206 | 572,377,838 | false | {"Kotlin": 9200} | fun main() {
fun getCounts(input: List<String>): List<Int> = input
.split { calorie -> calorie.isBlank() }
.map { elfCalorieList -> elfCalorieList.sumOf { calorie -> calorie.toInt() } }
fun part1(input: List<String>): Int {
return getCounts(input).max()
}
fun part2(input: List... | 0 | Kotlin | 0 | 0 | 57b2e7227d992de87a51094a971e952b3774fd11 | 787 | advent-of-code-in-kotlin | Apache License 2.0 |
src/Day02.kt | jpereyrol | 573,074,843 | false | {"Kotlin": 9016} | fun main() {
fun part1(input: List<String>): Int {
val rounds = input.map { line -> line.filterNot { it.isWhitespace() } }
val scoreResults = rounds.map { it.processRound() }
return scoreResults.sum()
}
fun part2(input: List<String>): Int {
val rounds = input.map { line -> ... | 0 | Kotlin | 0 | 0 | e17165afe973392a0cbbac227eb31d215bc8e07c | 1,980 | advent-of-code | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2023/Day14.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2023
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import com.s13g.aoc.XY
import com.s13g.aoc.resultFrom
/**
* --- Day 14: Parabolic Reflector Dish ---
* https://adventofcode.com/2023/day/14
*/
class Day14 : Solver {
override fun solve(lines: List<String>): Result {
val grid =... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 2,824 | euler | Apache License 2.0 |
src/Day06.kt | fmborghino | 573,233,162 | false | {"Kotlin": 60805} | // four characters that are all different
fun main() {
fun log(message: Any?) {
// println(message)
}
fun part1(input: String): Int {
// whoaa TIL indexOfFirst()
// windowedSequence or not... need to benchmark really, not obvious
return input.windowedSequence(4).indexOfFirst... | 0 | Kotlin | 0 | 0 | 893cab0651ca0bb3bc8108ec31974654600d2bf1 | 1,357 | aoc2022 | Apache License 2.0 |
leetcode/src/daily/Interview1709.kt | zhangweizhe | 387,808,774 | false | null | package daily
import kotlin.math.min
fun main() {
// 面试题 17.09. 第 k 个数
// https://leetcode.cn/problems/get-kth-magic-number-lcci/
// 题解
// https://leetcode.cn/problems/get-kth-magic-number-lcci/solution/di-k-ge-shu-jiu-shi-xiang-bu-tong-wei-he-san-zhi-z/
println(getKthMagicNumber(5))
}
fun getKth... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 1,647 | kotlin-study | MIT License |
src/Day03.kt | kmakma | 574,238,598 | false | null | fun main() {
fun Char.priority(): Int {
return this.code - if (this.isLowerCase()) 96 else 38
}
fun part1(input: List<String>): Int {
var prioSum = 0
input.forEach { line ->
val chunked = line.chunked(line.length / 2)
val duplicate = chunked[0].toSet().inter... | 0 | Kotlin | 0 | 0 | 950ffbce2149df9a7df3aac9289c9a5b38e29135 | 817 | advent-of-kotlin-2022 | Apache License 2.0 |
src/Day10.kt | jordan-thirus | 573,476,470 | false | {"Kotlin": 41711} | fun main() {
fun processCommand(command: String, registerX: Int, processCycle: () -> Unit): Int {
return when (command) {
"noop" -> {
processCycle()
registerX
}
else -> { //addx
val v = command.split(" ")[1].toInt()
... | 0 | Kotlin | 0 | 0 | 59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e | 1,847 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day10.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2021
class Day10(private val input: List<String>) {
fun solvePart1(): Int {
val bracketPoints = mapOf(')' to 3, ']' to 57, '}' to 1197, '>' to 25137)
return solve().filterIsInstance<LineResult.Corrupt>().sumOf { result ->
bracketPoints.getValue(result.b... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,415 | advent-of-code | Apache License 2.0 |
src/main/kotlin/Day13.kt | joostbaas | 573,096,671 | false | {"Kotlin": 45397} | import Packet.Companion.parsePacket
import kotlin.math.max
sealed interface Packet : Comparable<Packet> {
companion object {
fun String.parsePacket(): Packet {
val firstPacketListContent = mutableListOf<Packet>()
val stack: MutableList<PacketList> = mutableListOf(PacketList(firstPac... | 0 | Kotlin | 0 | 0 | 8d4e3c87f6f2e34002b6dbc89c377f5a0860f571 | 4,240 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Day6.kt | hughjdavey | 225,440,374 | false | null | package days
class Day6 : Day(6) {
override fun partOne(): Any {
return numberOfOrbits(inputList)
}
override fun partTwo(): Any {
return numberOfOrbits(inputList, "YOU", "SAN")
}
fun numberOfOrbits(map: List<String>): Int {
val orbits = orbits(map)
return orbits.k... | 0 | Kotlin | 0 | 1 | 84db818b023668c2bf701cebe7c07f30bc08def0 | 1,438 | aoc-2019 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/unam/ciencias/heuristicas/algorithm/Graph.kt | angelgladin | 203,038,278 | false | {"TSQL": 7853771, "Kotlin": 28077, "TeX": 21759} | package unam.ciencias.heuristicas.algorithm
import java.util.*
/**
* Weighted undirected graph.
*
* @param T The identifier of the node.
* @param E The data it's going to store each node in it.
*/
class Graph<T, E> {
private val nodes = hashMapOf<T, Node<T, E>>()
val edges = PriorityQueue<Edge<T>>(Compar... | 0 | TSQL | 0 | 0 | b8f3288ebc17f1a1468da4631cbf8af58f4fd28b | 1,950 | TSP-Threshold-Accepting | MIT License |
DijkstraAlgorithm/src/main/java/com/muramsyah/dijkstraalgorithm/dijkstra/Dijkstra.kt | ramdhanjr11 | 493,106,469 | false | {"Kotlin": 68652} | /*
* Copyright (c) 2022.
* Created By <NAME> on 16-05-2022
* Github : https://github.com/ramdhanjr11
* LinkedIn : https://www.linkedin.com/in/ramdhanjr11
* Instagram : ramdhan.official
*/
fun <T> dijkstra(graph: Graph<T>, start: T): Map<T, T?> {
val S: MutableSet<T> = mutableSetOf() // subset dari simpul yan... | 0 | Kotlin | 0 | 2 | 7f4782354a578030728cb2c64aed768095e38c32 | 1,973 | Sea-Kidul-App | Apache License 2.0 |
src/day07/Day07.kt | Longtainbin | 573,466,419 | false | {"Kotlin": 22711} | package day07
import Reference
import readInput
import kotlin.math.min
fun main() {
val input = readInput("inputDay07")
val root = generateTree(input)
calculateDirectorySize(root)
fun part1(root: Node): Long {
return helperForPart1(root)
}
fun part2(root: Node): Long {
retur... | 0 | Kotlin | 0 | 0 | 48ef88b2e131ba2a5b17ab80a0bf6a641e46891b | 1,543 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2016/Day10.kt | colinodell | 495,627,767 | false | {"Kotlin": 80872} | package com.colinodell.advent2016
class Day10(private val input: List<String>) {
fun solvePart1() = Factory(input).runUntilBotHas(listOf(61, 17))
fun solvePart2(): Int {
val f = Factory(input)
f.runAll()
return f.containers
.filterKeys { listOf("output 0", "output 1", "outp... | 0 | Kotlin | 0 | 0 | 8a387ddc60025a74ace8d4bc874310f4fbee1b65 | 3,189 | advent-2016 | Apache License 2.0 |
src/day21.kt | miiila | 725,271,087 | false | {"Kotlin": 77215} | import java.io.File
import kotlin.system.exitProcess
private const val DAY = 21
fun main() {
if (!File("./day${DAY}_input").exists()) {
downloadInput(DAY)
println("Input downloaded")
exitProcess(0)
}
val transformer = { x: String -> x.toList() }
val input = loadInput(DAY, false... | 0 | Kotlin | 0 | 1 | 1cd45c2ce0822e60982c2c71cb4d8c75e37364a1 | 4,957 | aoc2023 | MIT License |
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day02.kt | MichalChomo | 572,214,942 | false | {"Kotlin": 56758} | package eu.michalchomo.adventofcode.year2022
fun main() {
val letterPairToScore = mapOf(
"A X" to 3 + 1,
"A Y" to 6 + 2,
"A Z" to 0 + 3,
"B X" to 0 + 1,
"B Y" to 3 + 2,
"B Z" to 6 + 3,
"C X" to 6 + 1,
"C Y" to 0 + 2,
"C Z" to 3 + 3,
)
... | 0 | Kotlin | 0 | 0 | a95d478aee72034321fdf37930722c23b246dd6b | 997 | advent-of-code | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.