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/me/anno/docs/stats/FunctionLength.kt | AntonioNoack | 686,716,019 | false | {"Kotlin": 41609, "JavaScript": 19397, "HTML": 4377, "CSS": 3451} | package me.anno.docs.stats
import me.anno.docs.Method
import me.anno.docs.Scope
import me.anno.docs.collectAll
import me.anno.utils.structures.lists.Lists.largestKElements
import me.anno.utils.types.Floats.f3
import kotlin.math.log2
fun main() {
// done set start and end length to each function
// collect all... | 0 | Kotlin | 0 | 1 | 7e7b3635cb4dd63105bf9503957108407308729f | 1,832 | RemsDocsGenerator | Apache License 2.0 |
src/iii_conventions/MyDate.kt | agbragin | 108,394,108 | false | null | package iii_conventions
import java.time.LocalDate
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
override fun compareTo(other: MyDate): Int {
return LocalDate.of(year, month + 1, dayOfMonth).compareTo(
LocalDate.of(other.year, other.month + 1... | 0 | Kotlin | 1 | 0 | 34caea48743312ed30272842b61b3d148fc6b00d | 2,568 | kotlin-koans | MIT License |
src/Day13.kt | inssein | 573,116,957 | false | {"Kotlin": 47333} | import kotlinx.serialization.json.*
import kotlinx.serialization.json.Json.Default.parseToJsonElement
sealed class Packet : Comparable<Packet> {
data class Value(val value: Int) : Packet() {
fun toList() = Container(listOf(this))
override fun compareTo(other: Packet): Int = when (other) {
... | 0 | Kotlin | 0 | 0 | 095d8f8e06230ab713d9ffba4cd13b87469f5cd5 | 2,264 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day03/Puzzle.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2023.day03
import eu.janvdb.aocutil.kotlin.point2d.Point2D
val NUMBER_REGEX = Regex("\\d+")
class Puzzle(input: List<String>) {
private val numbers: List<Number>
private val symbols: List<Symbol>
init {
this.numbers = input.flatMapIndexed { y, line ->
NUMBER_REGEX.findAll(line)
.ma... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,537 | advent-of-code | Apache License 2.0 |
src/main/java/challenges/coderbyte/SeatingStudents.kt | ShabanKamell | 342,007,920 | false | null | package challenges.coderbyte
/*
Have the function SeatingStudents(arr) read the array of integers stored in arr which will be in the
following format: [K, r1, r2, r3, ...] where K represents the number of desks in a classroom,
and the rest of the integers in the array will be in sorted order and will represent the des... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,965 | CodingChallenges | Apache License 2.0 |
src/day09/Day09.kt | kerchen | 573,125,453 | false | {"Kotlin": 137233} | package day09
import readInput
import java.lang.Math.abs
data class Position(var x: Int, var y: Int) {
fun move(deltaX: Int, deltaY: Int) {
x += deltaX
y += deltaY
}
fun follow(position: Position): Boolean {
var moved = false
val dx = position.x - x
val dy = positi... | 0 | Kotlin | 0 | 0 | dc15640ff29ec5f9dceb4046adaf860af892c1a9 | 3,209 | AdventOfCode2022 | Apache License 2.0 |
src/Day20.kt | MickyOR | 578,726,798 | false | {"Kotlin": 98785} | fun main() {
fun part1(input: List<String>): Int {
var v = mutableListOf<Pair<Int, Int>>()
for (i in input.indices) {
var line = input[i]
v.add(Pair(line.toInt(), i))
}
var n = v.size
for (ite in 0 until v.size) {
var ini = 0
fo... | 0 | Kotlin | 0 | 0 | c24e763a1adaf0a35ed2fad8ccc4c315259827f0 | 2,618 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day22.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.math.max
import kotlin.math.min
import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Int {
val pathDescription = parsePathDescription(input.last())
val board = Board.parse(input.dropLast(2))
return board.getPassword(pathDescription)
}
fun part2(input: List<Strin... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 21,612 | aoc2022 | Apache License 2.0 |
src/main/kotlin/day10/Day10.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day10
import Day
fun main() {
Day10("Day10").solve()
}
class Day10(input: String) : Day<List<Int>>(input) {
override fun parseInput(): List<Int> {
return inputByLines.map {
val (a, b) = (it.split(" ") + " ")
a to b.toIntOrNull()
}.flatMap { (action, num) ->
... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 1,381 | aoc-2022 | Apache License 2.0 |
kotlin/src/Wardrobe/sal/SalWardrobe.kt | intresrl | 457,786,766 | false | {"Kotlin": 23396, "Java": 13383, "Python": 8693, "JavaScript": 7499, "Common Lisp": 1566, "TypeScript": 861} | package wardrobe.sal
typealias Width = Int
typealias Price = Int
fun combinations(
goal: Width = 250,
availableSizes: List<Width> = listOf(50, 75, 100, 120)
): Set<List<Width>> =
if (goal == 0)
setOf(emptyList())
else
availableSizes
.filter { it <= goal }
.flatM... | 0 | Kotlin | 0 | 1 | 05310869bbc37ae3b2edab3d62c9a9e49a785592 | 1,333 | kata-pulta | MIT License |
src/main/kotlin/Day10.kt | maldoinc | 726,264,110 | false | {"Kotlin": 14472} | import java.util.*
import kotlin.io.path.Path
import kotlin.io.path.readLines
data class Coordinate(val y: Int, val x: Int)
typealias Maze = List<String>
fun Maze.isValidCoordinate(coordinate: Coordinate): Boolean =
coordinate.y in this.indices && coordinate.x in this[coordinate.y].indices
fun getStartingCoordin... | 0 | Kotlin | 0 | 1 | 47a1ab8185eb6cf16bc012f20af28a4a3fef2f47 | 2,268 | advent-2023 | MIT License |
src/main/kotlin/day3.kt | gautemo | 725,273,259 | false | {"Kotlin": 79259} | import shared.Input
import shared.Point
import shared.XYMap
fun main() {
val input = Input.day(3)
println(day3A(input))
println(day3B(input))
}
fun day3A(input: Input): Int {
val map = XYMap(input) { if (it == '.') null else it }
val partNumbers = findPartNumbers(input)
return partNumbers
... | 0 | Kotlin | 0 | 0 | 6862b6d7429b09f2a1d29aaf3c0cd544b779ed25 | 1,224 | AdventOfCode2023 | MIT License |
src/day04/Day04.kt | emartynov | 572,129,354 | false | {"Kotlin": 11347} | package day04
import readInput
fun main() {
fun List<String>.toRangeSets() = map { pair ->
pair.split(",")
.map { pairString ->
pairString.split("-")
.map { it.toUInt() }
}
}.map { pairRangeString ->
pairRangeString.map { indexValues... | 0 | Kotlin | 0 | 1 | 8f3598cf29948fbf55feda585f613591c1ea4b42 | 1,183 | advent-of-code-2022 | Apache License 2.0 |
aoc-day4/src/Day4.kt | rnicoll | 438,043,402 | false | {"Kotlin": 90620, "Rust": 1313} | import java.io.File
import java.text.NumberFormat
object Day4 {
const val BOARD_SIZE = 5
val NUMBER_PARSER: NumberFormat = NumberFormat.getIntegerInstance()
}
fun main() {
val file = File("input")
val input = file.readLines()
val numbers: List<Int>
val boards: List<Board>
input.iterator().... | 0 | Kotlin | 0 | 0 | 8c3aa2a97cb7b71d76542f5aa7f81eedd4015661 | 1,920 | adventofcode2021 | MIT License |
src/main/kotlin/day25/Day25.kt | daniilsjb | 434,765,082 | false | {"Kotlin": 77544} | package day25
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day25/Day25.txt")
val answer = solve(data)
println("🎄 Day 25 🎄")
println("Answer: $answer")
}
private data class Area(
val width: Int,
val height: Int,
val cells: List<Char>,
)
private fun Area.getIndex(... | 0 | Kotlin | 0 | 1 | bcdd709899fd04ec09f5c96c4b9b197364758aea | 1,776 | advent-of-code-2021 | MIT License |
src/main/kotlin/days/Day4.kt | jgrgt | 433,952,606 | false | {"Kotlin": 113705} | package days
class Day4 : Day(4) {
override fun partOne(): Any {
return p1(inputList)
}
fun p1(lines: List<String>): Any {
val numbers = lines[0].split(",").map { it.toInt() }
val boards = lines.drop(1).windowed(6, 6).map {
Board.fromLines(it.drop(1))
}.toMutabl... | 0 | Kotlin | 0 | 0 | 6231e2092314ece3f993d5acf862965ba67db44f | 3,722 | aoc2021 | Creative Commons Zero v1.0 Universal |
ceria/07/src/main/kotlin/Solution.kt | VisionistInc | 317,503,410 | false | null | import java.io.File;
val yourBag = "shiny gold"
val stopBag = "no other"
val outterBag = "contain"
var total = 0
fun main(args : Array<String>) {
val input = File(args.first()).readLines()
println("Solution 1: ${solution1(input)}")
println("Solution 2: ${solution2(input)}")
}
private fun solution1(bagRul... | 0 | Rust | 0 | 0 | 002734670384aa02ca122086035f45dfb2ea9949 | 1,869 | advent-of-code-2020 | MIT License |
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/mathematics/Prime.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.datastructuresandalgorithms.mathematics
import kotlin.math.sqrt
import kotlin.random.Random
/**
* Two numbers are co-prime when the GCD of the numbers is 1.
* This method uses an algorithm called the Euclidean algorithm to compute GCD.
*/
fun areCoprime(first: Long, second: Long): Boolean {
... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 4,487 | KAHelpers | MIT License |
src/Day13.kt | greg-burgoon | 573,074,283 | false | {"Kotlin": 120556} | fun main() {
fun constructList(listString: String): MutableList<Any> {
var stack = ArrayDeque<MutableList<Any>>()
var currentInteger = ""
listString.toCharArray().forEach {
if (it == '[') {
stack.add(mutableListOf<Any>())
} else if (it == ']') {
... | 0 | Kotlin | 0 | 1 | 74f10b93d3bad72fa0fc276b503bfa9f01ac0e35 | 4,125 | aoc-kotlin | Apache License 2.0 |
src/Day01.kt | SpencerDamon | 573,244,838 | false | {"Kotlin": 6482} | import kotlin.math.max
fun main() {
/* Return highest sum dilineated by "" */
fun part1(input: List<String>): Int {
var highestSum = 0
var currentSum = 0
for (s in input) {
if (s.isEmpty()) { // if (see an empty line)
highestSum = max(highestSum, currentSum)
... | 0 | Kotlin | 0 | 0 | 659a9e9ae4687bd633bddfb924416c80a8a2db2e | 1,459 | aoc-2022-in-Kotlin | Apache License 2.0 |
src/Day05.kt | OskarWalczak | 573,349,185 | false | {"Kotlin": 22486} | import java.util.*
import kotlin.collections.ArrayList
fun main() {
fun readStacks(input: List<String>): MutableList<Stack<Char>> {
val stacks: MutableList<Stack<Char>> = ArrayList()
var stackNumsLineIndex: Int = 0
for(line in input.withIndex()){
if(line.value.matches(Regex("[0... | 0 | Kotlin | 0 | 0 | d34138860184b616771159984eb741dc37461705 | 3,180 | AoC2022 | Apache License 2.0 |
src/day3/Day03.kt | Johnett | 572,834,907 | false | {"Kotlin": 9781} | package day3
import readInput
fun main() {
fun Char.getPriorityValue(): Int = when (this) {
in 'a'..'z' -> (this - 'a') + 1
in 'A'..'Z' -> (this - 'A') + 27
else -> error("Item not found")
}
fun part1(input: List<String>): Int = input.map { content ->
val (firstCompartment... | 0 | Kotlin | 0 | 1 | c8b0ac2184bdad65db7d2f185806b9bb2071f159 | 1,143 | AOC-2022-in-Kotlin | Apache License 2.0 |
src/Day23.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | import java.util.Collections
suspend fun main() {
val testInput = readInput("Day23_test")
check(part1(testInput) == 110)
check(part2(testInput) == 20)
val input = readInput("Day23")
measureAndPrintResult {
part1(input)
}
measureAndPrintResult {
part2(input)
}
}
private... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 2,297 | aoc-22 | Apache License 2.0 |
src/main/kotlin/bk69/Problem3.kt | yvelianyk | 405,919,452 | false | {"Kotlin": 147854, "Java": 610} | package bk69
// ["dd","aa","bb","dd","aa","dd","bb","dd","aa","cc","bb","cc","dd","cc"]
fun main() {
val res = Problem3().longestPalindrome(
arrayOf(
"xx", "zz"
)
)
println(res)
}
class Problem3 {
fun longestPalindrome(words: Array<String>): Int {
val countMap = wor... | 0 | Kotlin | 0 | 0 | 780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd | 1,312 | leetcode-kotlin | MIT License |
2021/src/main/kotlin/com/trikzon/aoc2021/Day13.kt | Trikzon | 317,622,840 | false | {"Kotlin": 43720, "Rust": 21648, "C#": 12576, "C++": 4114, "CMake": 397} | package com.trikzon.aoc2021
import kotlin.math.absoluteValue
fun main() {
val input = getInputStringFromFile("/day13.txt")
benchmark(Part.One, ::day13Part1, input, 682, 50)
benchmark(Part.Two, ::day13Part2, input, 682, 50)
}
fun day13Part1(input: String): Int {
var points = ArrayList<Pair<Int, Int>>(... | 0 | Kotlin | 1 | 0 | d4dea9f0c1b56dc698b716bb03fc2ad62619ca08 | 3,051 | advent-of-code | MIT License |
src/main/kotlin/dev/paulshields/aoc/Day17.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 17: Trick Shot
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.Point
import dev.paulshields.aoc.common.extractGroups
import dev.paulshields.aoc.common.readFileAsString
import kotlin.math.abs
fun main() {
println(" ** Day 17: Trick Shot ** \n")
val oceanTrenchArea = readFileAsStr... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 3,473 | AdventOfCode2021 | MIT License |
src/main/kotlin/28-aug.kt | aladine | 276,334,792 | false | {"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511} | class Solution28Aug {
fun findRightInterval(intervals: Array<IntArray>): IntArray {
val ans: MutableList<Int> = MutableList<Int>(intervals.size) {-1}
val newIntervals = intervals.withIndex().map { c ->
intArrayOf(c.index, c.value[0])
}.sortedBy { it[1] }
for(i in newInter... | 0 | C++ | 1 | 1 | 54b7f625f6c4828a72629068d78204514937b2a9 | 2,003 | awesome-leetcode | Apache License 2.0 |
src/year2022/day23/Day23.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day23
import Point2D
import readInputFileByYearAndDay
import readTestFileByYearAndDay
enum class Direction(val offset: Point2D) {
N(Point2D(0, -1)),
NE(Point2D(1, -1)),
E(Point2D(1, 0)),
SE(Point2D(1, 1)),
S(Point2D(0, 1)),
SW(Point2D(-1, 1)),
W(Point2D(-1, 0)),
NW(Poi... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 5,816 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/day05/SupplyStacks.kt | iamwent | 572,947,468 | false | {"Kotlin": 18217} | package day05
import readText
import java.util.*
class SupplyStacks(
private val name: String
) {
private fun read(): Pair<List<Stack<Char>>, List<Step>> {
val (stacks, steps) = readText(name).split("\n\n")
return readStacks(stacks) to readSteps(steps)
}
private fun readStacks(input:... | 0 | Kotlin | 0 | 0 | 77ce9ea5b227b29bc6424d9a3bc486d7e08f7f58 | 2,340 | advent-of-code-kotlin | Apache License 2.0 |
src/y2016/Day10.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2016
import util.readInput
interface NumberGiver {
fun getNumberFor(target: Int): Int
}
data class Input(val n: Int) : NumberGiver {
override fun getNumberFor(target: Int): Int {
return n
}
}
data class Bot(
val id: Int,
val inputMap: Map<Int, List<NumberGiver>>,
val lowTarg... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 4,471 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2020/Day23.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 23 - Crab Cups
* Problem Description: http://adventofcode.com/2020/day/23
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day23/
*/
package com.ginsberg.advent2020
class Day23(private val input: String) {
fun so... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 2,682 | advent-2020-kotlin | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day22.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 22: Reactor Reboot
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.extractGroups
import dev.paulshields.aoc.common.readFileAsStringList
import kotlin.math.max
import kotlin.math.min
fun main() {
println(" ** Day 22: Reactor Reboot ** \n")
val rebootInstructions = readFileAsStrin... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 4,490 | AdventOfCode2021 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/DesignFoodRatingSystem.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 | 6,598 | kotlab | Apache License 2.0 |
src/Day04.kt | cak | 573,455,947 | false | {"Kotlin": 8236} | fun main() {
fun part1(input: List<String>): Int {
val data = input.map { j ->
j.split(",")
.map { k ->
k.split("-")
.map { it.toInt() }
}
.map { (it.first()..it.last()).toList() }
}.filter { it.f... | 0 | Kotlin | 0 | 1 | cab2dffae8c1b78405ec7d85e328c514a71b21f1 | 1,024 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | rdbatch02 | 575,174,840 | false | {"Kotlin": 18925} | import java.util.EmptyStackException
import java.util.Stack
import kotlin.Error
data class CrateMove(val quantity: Int, val source: Int, val dest: Int)
fun main() {
fun parseCurrentStacks(input: List<String>): List<Stack<String>> {
val endLineIdx = input.indexOfFirst { it.isEmpty() }
val endLine = ... | 0 | Kotlin | 0 | 1 | 330a112806536910bafe6b7083aa5de50165f017 | 2,844 | advent-of-code-kt-22 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/HighFive.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 | 3,279 | kotlab | Apache License 2.0 |
src/Day11.kt | aneroid | 572,802,061 | false | {"Kotlin": 27313} | class Day11(input: List<String>) {
private var worryReducer = { it: Long -> it / 3 }
private val monkeys: List<Monkey> = parseInput(input)
private fun printMonkeyItems(round: Int = 0) {
if (round != 0) {
println("After round $round:")
}
monkeys.forEachIndexed { index... | 0 | Kotlin | 0 | 0 | cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd | 3,664 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/day02/Day02.kt | violabs | 576,367,139 | false | {"Kotlin": 10620} | package day02
import readInput
fun main() {
test1("day-02-test-input-01", 15)
test2("day-02-test-input-01", 12)
}
private fun test1(filename: String, expected: Int) {
val input = readInput("day02/$filename")
val actual: Int = runGuessingGame(input)
println("EXPECT: $expected")
println("ACT... | 0 | Kotlin | 0 | 0 | be3d6bb2aef1ebd44bbd8e62d3194c608a5b3cc1 | 3,932 | AOC-2022 | Apache License 2.0 |
RomanToInteger.kt | ncschroeder | 604,822,497 | false | {"Kotlin": 19399} | /*
https://leetcode.com/problems/roman-to-integer/
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
For example, 2 is written as II in Roman nu... | 0 | Kotlin | 0 | 0 | c77d0c8bb0595e61960193fc9b0c7a31952e8e48 | 2,098 | Coding-Challenges | MIT License |
src/main/kotlin/com/github/shmvanhouten/adventofcode/day11/ChipAndGeneratorDistributor.kt | SHMvanHouten | 109,886,692 | false | {"Kotlin": 616528} | package com.github.shmvanhouten.adventofcode.day11
class ChipAndGeneratorDistributor (var elevatorLvl: Int = 1){
private val AMOUNT_OF_STEPS_IT_TAKES_TO_MOVE_FIRST_TWO_SETS_OF_COMPONENTS_UP_ONE_FLOOR = 5
private val STEPS_PER_SET_OF_COMPONENTS = 4
fun findQuickestWayToTop(floorsInput: Map<Int, Pair<List<... | 0 | Kotlin | 0 | 0 | a8abc74816edf7cd63aae81cb856feb776452786 | 3,168 | adventOfCode2016 | MIT License |
src/main/kotlin/day20.kt | p88h | 317,362,882 | false | null | internal fun bswap(code: Int): Int {
return (0 until 10).fold(0) { r, i -> r * 2 + if (code and (1 shl i) != 0) 1 else 0 }
}
internal val monster = arrayListOf(
" @ ".toCharArray(),
"* __ __ ()>".toCharArray(),
" \\ / \\ / \\ / ".toCharArray()
)
internal data class Til... | 0 | Kotlin | 0 | 5 | 846ad4a978823563b2910c743056d44552a4b172 | 5,014 | aoc2020 | The Unlicense |
src/main/kotlin/daythree/DayThree.kt | pauliancu97 | 619,525,509 | false | null | package daythree
import getLines
private fun getItemPriority(char: Char): Int =
if (char.isLowerCase()) {
char.code - 'a'.code + 1
} else {
char.code - 'A'.code + 27
}
private fun getMissplacedPackagePriority(rucksack: String): Int {
val firstCompartmentItems = rucksack.substring(0 un... | 0 | Kotlin | 0 | 0 | 78af929252f094a34fe7989984a30724fdb81498 | 1,709 | advent-of-code-2022 | MIT License |
src/day04/Day04.kt | marcBrochu | 573,884,748 | false | {"Kotlin": 12896} | package day04
import readInput
data class Range(val min:Int, val max: Int) {
fun fullyContains(otherRange: Range): Boolean =
this.min <= otherRange.min && this.max >= otherRange.max
fun overlap(otherRange: Range): Boolean =
(this.min >= otherRange.min && this.min <= otherRange.max)
... | 0 | Kotlin | 0 | 2 | 8d4796227dace8b012622c071a25385a9c7909d2 | 1,384 | advent-of-code-kotlin | Apache License 2.0 |
src/main/java/com/ncorti/aoc2021/Exercise04.kt | cortinico | 433,486,684 | false | {"Kotlin": 36975} | package com.ncorti.aoc2021
object Exercise04 {
private fun getInput(): Pair<List<Int>, List<Array<IntArray>>> =
getInputAsTest("04") { split("\n") }.let { lines ->
val calls = lines[0].split(",").map(String::toInt)
val boards =
lines
.asSequence(... | 0 | Kotlin | 0 | 4 | af3df72d31b74857201c85f923a96f563c450996 | 2,775 | adventofcode-2021 | MIT License |
src/Day02.kt | Iamlooker | 573,103,288 | false | {"Kotlin": 5744} | fun main() {
/**
*
* Part 1:
* A or X -> Rock -> 1
* B or Y -> Paper -> 2
* C or Z -> Scissor -> 3
*
* Part 2:
* X -> Lose -> 0
* Y -> Draw -> 3
* Z -> Win -> 6
*/
val pointsTable = mapOf(
'A' to 1, 'B' to 2, 'C' to 3
)
val part1YourPoint... | 0 | Kotlin | 0 | 0 | 91a335428a99db2f2b1fd5c5f51a6b1e55ae2245 | 2,232 | aoc-2022-kotlin | Apache License 2.0 |
src/Day04.kt | yeung66 | 574,904,673 | false | {"Kotlin": 8143} | fun main() {
fun parse(input: String): List<List<List<Int>>> {
return input.lines().map { line -> line.split(",").map { range -> range.split("-").map {it.toInt()}} }.toList()
}
fun part1(input: List<List<List<Int>>>): Int {
return input.map {
val (a, b) = it
if (a[0]... | 0 | Kotlin | 0 | 0 | 554217f83e81021229759bccc8b616a6b270902c | 684 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day08.kt | andydenk | 573,909,669 | false | {"Kotlin": 24096} | fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day08_test")
check(part1(testInput) == 21)
check(part2(testInput) == 8)
val input = readInput("Day08")
println("Part 1: ${part1(input)}")
println("Part 2: ${part2(input)}")
}
privat... | 0 | Kotlin | 0 | 0 | 1b547d59b1dc55d515fe8ca8e88df05ea4c4ded1 | 4,007 | advent-of-code-2022 | Apache License 2.0 |
src/main/java/kr/co/programmers/P81302.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/363
class P81302 {
fun solution(places: Array<Array<String>>): IntArray {
val answer = IntArray(places.size)
for (i in places.indices) answer[i] = place(places[i])
return answer
}
private fun place(place: A... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,791 | algorithm | MIT License |
year2022/src/main/kotlin/net/olegg/aoc/year2022/day15/Day15.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2022.day15
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.year2022.DayOf2022
import kotlin.math.abs
/**
* See [Year 2022, Day 15](https://adventofcode.com/2022/day/15)
*/
object Day15 : DayOf2022(15) {
private val PATTERN = "^Sensor at x=(-?... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,757 | adventofcode | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2101/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2101
/**
* LeetCode page: [2101. Detonate the Maximum Bombs](https://leetcode.com/problems/detonate-the-maximum-bombs/);
*/
class Solution {
/* Complexity:
* Time O(N^3) and Space O(N^2) where N is the size of bombs;
*/
fun maximumDetonation(bombs: Array<IntArr... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,231 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day08.kt | acrab | 573,191,416 | false | {"Kotlin": 52968} | import com.google.common.truth.Truth.assertThat
fun main() {
fun isVisible(height: Int, x: Int, y: Int, map: List<List<Int>>): Boolean {
//edge trees are always visible
if (x == 0 || x == map.size - 1 || y == 0 || y == map[x].size - 1) {
return true
}
//check up
... | 0 | Kotlin | 0 | 0 | 0be1409ceea72963f596e702327c5a875aca305c | 2,752 | aoc-2022 | Apache License 2.0 |
kotlin-practice/src/main/kotlin/exercise/collection/CollectionOperators2.kt | nicolegeorgieva | 590,020,790 | false | {"Kotlin": 120359} | package exercise.collection
fun main() {
val salesData = listOf<Sale>(
Sale("Meat", 7.0, 10),
Sale("Fish", 5.0, 5),
Sale("Snack", 3.0, 2),
Sale("Bread", 1.0, 5),
Sale("Nuts", 2.0, 9),
Sale("Chocolate", 3.0, 5)
)
println(calculateTotalProfit(salesData, 1.0))
... | 0 | Kotlin | 0 | 1 | c96a0234cc467dfaee258bdea8ddc743627e2e20 | 2,324 | kotlin-practice | MIT License |
src/Day02.kt | LesleySommerville-Ki | 577,718,331 | false | {"Kotlin": 9590} | fun main() {
val part1Scoring: Map<String, Int> =
mapOf(
"A X" to 1 + 3, // rock = 1
"A Y" to 2 + 6, // paper = 2
"A Z" to 3 + 0, // scissors = 3
"B X" to 1 + 0,
"B Y" to 2 + 3,
"B Z" to 3 + 6,
"C X" to 1 + 6,
"C... | 0 | Kotlin | 0 | 0 | ea657777d8f084077df9a324093af9892c962200 | 1,138 | AoC | Apache License 2.0 |
src/2021/Day15_1.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
val grid = ArrayList<ArrayList<Int>>()
File("input/2021/day15").forEachLine { line ->
grid.add(ArrayList<Int>().apply { addAll(line.toList().map { it.digitToInt() }) })
}
fun ArrayList<Pair<Int, Pair<Int, Int>>>.addFor(y: Int, x: Int, from: ArrayList<ArrayList<Int>>) = add(Pair(from[y][x], Pai... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 3,142 | adventofcode | MIT License |
src/main/kotlin/day2.kt | noamfree | 433,962,392 | false | {"Kotlin": 93533} | private val testInput1 = """
forward 5
down 5
forward 8
up 3
down 8
forward 2
""".trimIndent()
private fun tests() {
assertEquals(part1(parseInput(testInput1)), 150)
assertEquals(part2(parseInput(testInput1)), 900)
}
private fun main() {
tests()
val input = readInputFile("inpu... | 0 | Kotlin | 0 | 0 | 566cbb2ef2caaf77c349822f42153badc36565b7 | 2,271 | AOC-2021 | MIT License |
src/main/kotlin/Day2.kt | Ostkontentitan | 434,500,914 | false | {"Kotlin": 73563} | import kotlin.math.abs
fun puzzleDayTwoPartOne() {
val inputs = readInput(2)
val position = inputs.fold(Position()) { acc, item ->
val number = getNumber(item)
when (getDirection(item)) {
Direction.UP -> acc.copy(height = acc.height + number)
Direction.DOWN -> acc.copy(h... | 0 | Kotlin | 0 | 0 | e0e5022238747e4b934cac0f6235b92831ca8ac7 | 1,644 | advent-of-kotlin-2021 | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2023/Day06.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2023
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 6: Wait For It](https://adventofcode.com/2023/day/6).
*/
object Day06 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val input = readInput("year2023/Day06")
... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 1,713 | advent-of-code | MIT License |
src/Day01.kt | dizney | 572,581,781 | false | {"Kotlin": 105380} | const val PART1_EXPECTED_HIGHEST_CALORIES = 24000
const val PART2_EXPECTED_HIGHEST_3_CALORIES_SUM = 45000
const val PART2_TOP_ELF_COUNT = 3
fun main() {
fun elfTotals(input: List<String>, idx: Int = 0, elfAmount: Int = 0, totals: List<Int> = emptyList()): List<Int> {
if (idx >= input.size) return totals +... | 0 | Kotlin | 0 | 0 | f684a4e78adf77514717d64b2a0e22e9bea56b98 | 1,593 | aoc-2022-in-kotlin | Apache License 2.0 |
day12/src/main/kotlin/App.kt | ascheja | 317,918,055 | false | null | package net.sinceat.aoc2020.day12
import kotlin.math.abs
fun main() {
println(readInstructions("testinput.txt").calculateManhattanDistancePart1())
println(readInstructions("input.txt").calculateManhattanDistancePart1())
println(readInstructions("testinput.txt").calculateManhattanDistancePart2())
prin... | 0 | Kotlin | 0 | 0 | f115063875d4d79da32cbdd44ff688f9b418d25e | 4,114 | aoc2020 | MIT License |
src/Day02.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | fun main() {
val moveScoreMap1 = 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
)
val moveScoreMap2 = mapOf(
"A X" to 3+0, "A Y" to 1+3, "A Z" to 2+6,
"B X" to 1+0, "B Y" to 2+3, "B ... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 783 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day21/a/day21a.kt | pghj | 577,868,985 | false | {"Kotlin": 94937} | package day21.a
import readInputLines
import shouldBe
fun main() {
val r = read()
val answer = (evaluate(r) as Num).value
shouldBe(63119856257960, answer)
}
fun evaluate(e: Expr): Expr {
if (e is Op) {
val a = evaluate(e.a)
val b = evaluate(e.b)
if (a is Num && b is Num) {
... | 0 | Kotlin | 0 | 0 | 4b6911ee7dfc7c731610a0514d664143525b0954 | 2,065 | advent-of-code-2022 | Apache License 2.0 |
src/Day19.kt | astrofyz | 572,802,282 | false | {"Kotlin": 124466} | import kotlin.math.max
fun main() {
class State(var oreRobot: Int, var clayRobot: Int, var obsidianRobot: Int, var geodeRobot: Int,
var ore: Int, var clay: Int, var obsidian: Int, var geode: Int, var t: Int)
fun parseBlueprint(input: String): MutableMap<String, MutableMap<String, Int>> {
val ... | 0 | Kotlin | 0 | 0 | a0bc190b391585ce3bb6fe2ba092fa1f437491a6 | 9,457 | aoc22 | Apache License 2.0 |
src/DayTwo.kt | P-ter | 572,781,029 | false | {"Kotlin": 18422} | fun main() {
fun partOne(input: List<String>): Int {
val resultMap = buildMap {
put(Pair("A", "X"), 3)
put(Pair("A", "Y"), 6)
put(Pair("A", "Z"), 0)
put(Pair("B", "X"), 0)
put(Pair("B", "Y"), 3)
put(Pair("B", "Z"), 6)
put(... | 0 | Kotlin | 0 | 1 | e28851ee38d6de5600b54fb884ad7199b44e8373 | 1,685 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/day02/Day02.kt | RegBl | 573,086,350 | false | {"Kotlin": 11359} | package day02
import readInput
fun main() {
val input = readInput("\\day02\\Day02")
val testInput = readInput("\\day02\\Day02_test")
val contestantChoices = inputListToContestantChoicesList(input)
val contestantScores = contestantChoicesToContestantScores(contestantChoices)
// Part 1
println... | 0 | Kotlin | 0 | 0 | bd45eb4378d057267823dcc72ad958492f7056ff | 4,336 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Droplets.kt | alebedev | 573,733,821 | false | {"Kotlin": 82424} | fun main() = Droplets.solve()
private object Droplets {
fun solve() {
val input = readInput()
val droplet = Droplet(input)
println("total surface area ${droplet.surfaceArea1()}")
println("outside surface area ${droplet.surfaceArea2()}")
}
private fun readInput(): List<Pos> ... | 0 | Kotlin | 0 | 0 | d6ba46bc414c6a55a1093f46a6f97510df399cd1 | 2,276 | aoc2022 | MIT License |
src/main/kotlin/org/sjoblomj/adventofcode/GeneticAlgorithm.kt | sjoblomj | 161,537,410 | false | null | package org.sjoblomj.adventofcode
/**
* A Genetic Algorithm is inspired by natural selection and evolution to find solutions to a problem. A list of possible
* solutions are evaluated, and the ones giving the best result are selected as the basis for creating new solutions,
* which are hopefully even better. In eac... | 0 | Kotlin | 0 | 0 | 80db7e7029dace244a05f7e6327accb212d369cc | 3,273 | adventofcode2018 | MIT License |
src/Day03.kt | dmarcato | 576,511,169 | false | {"Kotlin": 36664} | fun main() {
fun Char.priority(): Int = when {
isUpperCase() -> code - 'A'.code + 27
else -> code - 'a'.code + 1
}
fun part1(input: List<String>): Int {
return input.sumOf { row ->
val (a, b) = row.chunked(row.length / 2)
a.asSequence().first { b.contains(it)... | 0 | Kotlin | 0 | 0 | 6abd8ca89a1acce49ecc0ca8a51acd3969979464 | 900 | aoc2022 | Apache License 2.0 |
src/Day07.kt | cypressious | 572,898,685 | false | {"Kotlin": 77610} | import kotlin.LazyThreadSafetyMode.NONE
fun main() {
class File(
val name: String,
val size: Int
) {
override fun toString() = name
}
class Directory(
val name: String,
val parent: Directory?,
val dirs: MutableList<Directory> = mutableListOf(),
v... | 0 | Kotlin | 0 | 1 | 7b4c3ee33efdb5850cca24f1baa7e7df887b019a | 2,800 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/aoc22/Day02.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import aoc22.Day02Common.summed
import aoc22.Day02Common.toRoundsUsing
import aoc22.DomainRPS.Outcome
import aoc22.DomainRPS.Outcome.*
import aoc22.DomainRPS.Play
import aoc22.DomainRPS.Play.*
import aoc22.DomainRPS.Round
import aoc22.DomainRPS.points
import aoc22.DomainRPS.toOutcome
import common.Year22... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 2,732 | aoc | Apache License 2.0 |
grind-75-kotlin/src/main/kotlin/FirstBadVersion.kt | Codextor | 484,602,390 | false | {"Kotlin": 27206} | /**
* You are a product manager and currently leading a team to develop a new product.
* Unfortunately, the latest version of your product fails the quality check.
* Since each version is developed based on the previous version, all the versions after a bad version are also bad.
*
* Suppose you have n versions [1,... | 0 | Kotlin | 0 | 0 | 87aa60c2bf5f6a672de5a9e6800452321172b289 | 1,829 | grind-75 | Apache License 2.0 |
src/main/kotlin/Day02.kt | N-Silbernagel | 573,145,327 | false | {"Kotlin": 118156} | fun main() {
val ROCK_ENEMY = 'A'
val PAPER_ENEMY = 'B'
val SCISSORS_ENEMY = 'C'
val enemyChoiceMap = mapOf(
Pair(ROCK_ENEMY, Choice.ROCK),
Pair(PAPER_ENEMY, Choice.PAPER),
Pair(SCISSORS_ENEMY, Choice.SCISSORS)
)
val choiceScores = mapOf(
Pair(Choice.ROCK, 1),
... | 0 | Kotlin | 0 | 0 | b0d61ba950a4278a69ac1751d33bdc1263233d81 | 3,279 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/leetcode/monthly_challenges/2021/april/alien_dictionary/Main.kt | frikit | 254,842,734 | false | null | package com.leetcode.monthly_challenges.`2021`.april.alien_dictionary
fun main() {
println("Test case 1:")
println(Solution().isAlienSorted(arrayOf("hello", "leetcode"), "hlabcdefgijkmnopqrstuvwxyz"))//true
println()
println("Test case 2:")
println(Solution().isAlienSorted(arrayOf("word", "world", ... | 0 | Kotlin | 0 | 0 | dda68313ba468163386239ab07f4d993f80783c7 | 1,720 | leet-code-problems | Apache License 2.0 |
src/Day24.kt | Jintin | 573,640,224 | false | {"Kotlin": 30591} | import java.util.LinkedList
fun main() {
var width = 0
var height = 0
fun checkBlockPosition(x: Int, y: Int, value: Char, map: List<List<Char>>): Boolean {
val w = width - 2
val h = height - 2
return map[1 + ((x - 1 + w) % w)][1 + ((y - 1 + h) % h)] == value
}
fun check(ma... | 0 | Kotlin | 0 | 2 | 4aa00f0d258d55600a623f0118979a25d76b3ecb | 3,077 | AdventCode2022 | Apache License 2.0 |
src/main/kotlin/days/Solution23.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
import adventOfCode.util.Point2D
import adventOfCode.util.plus
import kotlin.math.max
typealias TrailMap = Map<Point2D, Map<Point2D, Int>>
private val directions = listOf(1 to 0, 0 to 1, -1 to 0, 0 to -1)
priva... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 3,817 | Advent-of-Code-2023 | MIT License |
kotlin/src/com/leetcode/64_MinimumPathSum.kt | programmerr47 | 248,502,040 | false | null | package com.leetcode
import kotlin.math.min
//Partial sum vector. Time: O(n*m). Space: O(m)
private class Solution64 {
fun minPathSum(grid: Array<IntArray>): Int {
val waveGrid = IntArray(grid[0].size)
for (i in grid.indices) {
for (j in grid[i].indices) {
waveGrid[j] ... | 0 | Kotlin | 0 | 0 | 0b5fbb3143ece02bb60d7c61fea56021fcc0f069 | 1,351 | problemsolving | Apache License 2.0 |
src/Day16.kt | jvmusin | 572,685,421 | false | {"Kotlin": 86453} | import java.time.Duration
import java.time.Instant
import java.util.*
import kotlin.time.toKotlinDuration
private typealias Mask = Long
private typealias Position = Int
private typealias Score = Int
fun main() {
fun Long.get(i: Int) = (this shr i) and 1 == 1L
fun Long.set(i: Int) = this or (1L shl i)
fun... | 1 | Kotlin | 0 | 0 | 4dd83724103617aa0e77eb145744bc3e8c988959 | 10,773 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/schlaubi/aoc/days/Day7.kt | DRSchlaubi | 573,014,474 | false | {"Kotlin": 21541} | package dev.schlaubi.aoc.days
import dev.schlaubi.aoc.Day
import kotlin.io.path.readLines
private val cdPattern = """\$ cd (.*)""".toRegex()
private val lsPattern = """\$ ls""".toRegex()
private val filePattern = """(\d+) ((.*)(?:\.(.*))?)""".toRegex()
private data class SizedDirectory(val size: Int, val directory: ... | 1 | Kotlin | 0 | 4 | 4514e4ac86dd3ed480afa907d907e3ae26457bba | 4,373 | aoc-2022 | MIT License |
src/main/kotlin/dev/paulshields/aoc/Day13.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 13: Transparent Origami
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.Point
import dev.paulshields.aoc.common.extractGroups
import dev.paulshields.aoc.common.readFileAsString
fun main() {
println(" ** Day 13: Transparent Origami ** \n")
val pageOne = readFileAsString("/Day13Ma... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 2,559 | AdventOfCode2021 | MIT License |
src/day10/Code.kt | fcolasuonno | 221,697,249 | false | null | package day10
import java.io.File
fun main() {
val name = if (false) "test.txt" else "input.txt"
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part 1 = ${part1(parsed)}")
println("Part 2 = ${part2()}")
}
private v... | 0 | Kotlin | 0 | 0 | 73110eb4b40f474e91e53a1569b9a24455984900 | 2,320 | AOC2016 | MIT License |
src/Day4/Day04.kt | lukeqwas | 573,403,156 | false | null | package Day5
import readInput
//data class Range(val lowerBound: Int, val upperBound: Int)
fun main() {
val testInput = readInput("Day4/Day04")
var numPairs = 0
for(input in testInput) {
// find the smallest lower bound and see if the other range falls in the smalles lower bound range
... | 0 | Kotlin | 0 | 0 | 6174a8215f8d4dc6d33fce6f8300a4a8999d5431 | 1,202 | aoc-kotlin-2022 | Apache License 2.0 |
2023/src/main/kotlin/day1.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parser
import utils.Solution
fun main() {
Day1.run()
}
object Day1 : Solution<List<String>>() {
override val name = "day1"
override val parser: Parser<List<String>> = Parser.lines
private val digits = (0..9).associateBy { it.toString() }
private val words = mapOf(
"one" to 1,
"two" to ... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,135 | aoc_kotlin | MIT License |
src/main/kotlin/Main.kt | nikdim03 | 620,591,512 | false | null | import kotlin.random.Random
data class Cell(val row: Int, val col: Int)
fun main() {
val gridSize = 100
val fillPercentage = listOf(50, 75)
fillPercentage.forEach { percentage ->
val grid = generateGrid(gridSize, percentage)
val path = findPathWithLeastWhiteSquares(grid)
println("... | 0 | Kotlin | 0 | 0 | 3b12afbb67f96978b4c0f451e9911389364c4f6e | 3,778 | Percolation | MIT License |
src/main/kotlin/wtf/log/xmas2021/day/day04/Day04.kt | damianw | 434,043,459 | false | {"Kotlin": 62890} | package wtf.log.xmas2021.day.day04
import wtf.log.xmas2021.Day
import wtf.log.xmas2021.util.collect.Grid
import wtf.log.xmas2021.util.collect.mapCells
import wtf.log.xmas2021.util.collect.toGrid
import java.io.BufferedReader
object Day04 : Day<Day04.Input, Int, Int> {
override fun parseInput(reader: BufferedRead... | 0 | Kotlin | 0 | 0 | 1c4c12546ea3de0e7298c2771dc93e578f11a9c6 | 3,552 | AdventOfKotlin2021 | BSD Source Code Attribution |
src/main/kotlin/graph/variation/BestShortestPath.kt | yx-z | 106,589,674 | false | null | package graph.variation
import graph.core.Vertex
import graph.core.WeightedEdge
import graph.core.WeightedGraph
import util.INF
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.set
// given a directed, positively weighted graph G = (V, E), two vertices s, t in V,
// find the shortest pat... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,014 | AlgoKt | MIT License |
src/main/kotlin/dev/bogwalk/batch4/Problem42.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch4
import dev.bogwalk.util.maths.isTriangularNumber
import dev.bogwalk.util.maths.lcm
import kotlin.math.sqrt
/**
* Problem 42: Coded Triangle Numbers
*
* https://projecteuler.net/problem=42
*
* Goal: Given an integer, if it is a triangle number tN, return its corresponding term n;
* oth... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 2,287 | project-euler-kotlin | MIT License |
src/Day13.kt | fouksf | 572,530,146 | false | {"Kotlin": 43124} | import java.io.File
import java.lang.Exception
import kotlin.math.abs
import kotlin.math.min
import kotlin.reflect.typeOf
fun main() {
fun parseArray(iterator: ListIterator<String>): List<Any> {
val result = mutableListOf<Any>()
while (iterator.hasNext()) {
val token = iterator.next()
... | 0 | Kotlin | 0 | 0 | 701bae4d350353e2c49845adcd5087f8f5409307 | 4,073 | advent-of-code-2022 | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/valid_number/ValidNumber.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.valid_number
import datsok.shouldEqual
import org.junit.jupiter.api.Test
//
// https://leetcode.com/problems/valid-number ✅
//
// A valid number can be split up into these components (in order):
// A decimal number or an integer.
// (Optional) An 'e' or 'E', followed by an integer.... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 3,700 | katas | The Unlicense |
src/Day02.kt | revseev | 573,354,544 | false | {"Kotlin": 9868} | import GameResult.*
fun main() {
println(day2task1())
println(day2task2())
}
fun day2task1(): Int {
var userScore = 0
readInputAsSequence("Day02") {
userScore = sumOf { getScore(RPS.of(it[0]), RPS.of(it[2])) }
}
return userScore
}
fun day2task2(): Int {
var userScore = 0
readI... | 0 | Kotlin | 0 | 0 | df2e12287a30a3a7bd5a026a963bcac41a730232 | 2,396 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Lesson5PrefixSums/CountDiv.kt | slobodanantonijevic | 557,942,075 | false | {"Kotlin": 50634} | /**
* 100/100
* @param A
* @param B
* @param K
* @return
*/
fun solution(A: Int, B: Int, K: Int): Int {
var firstDivisible = -1
if (K == 1) { // if K is 1, all of the ints are divisible by it in range
return B - A + 1 // return ALL of them, no need to process anything
}
// In case K is gr... | 0 | Kotlin | 0 | 0 | 155cf983b1f06550e99c8e13c5e6015a7e7ffb0f | 1,409 | Codility-Kotlin | Apache License 2.0 |
src/questions/UniquePathsII.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.shouldBe
/**
* A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
* The robot can only move either down or right at any point in time.
* The robot is trying to reach the bottom-right corner of the g... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 5,023 | algorithms | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day18.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.util.Pt3D
import io.github.clechasseur.adventofcode.y2022.data.Day18Data
object Day18 {
private val input = Day18Data.input
private val displacements = listOf(
Pt3D(-1, 0, 0),
Pt3D(1, 0, 0),
Pt3... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 2,675 | adventofcode2022 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SparseVector.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 | 2,912 | kotlab | Apache License 2.0 |
src/Day05.kt | ManueruEd | 573,678,383 | false | {"Kotlin": 10647} | fun main() {
val day = "05"
fun part1(input: List<String>): String {
val lengthStack = 9
val stacks = List(lengthStack) { mutableListOf<Char?>() }
val a = input.takeWhile { !it.startsWith("1") }.reversed()
for (i in 0 until a[0].length) {
for (j in a){
... | 0 | Kotlin | 0 | 0 | 09f3357e059e31fda3dd2dfda5ce603c31614d77 | 2,398 | AdventOfCode2022 | Apache License 2.0 |
src/Day02.kt | RandomUserIK | 572,624,698 | false | {"Kotlin": 21278} | fun main() {
fun part1(input: List<Pair<Char, Char>>): Int {
val roundPoints = mapOf(
Pair('B', 'X') to 0,
Pair('C', 'Y') to 0,
Pair('A', 'Z') to 0,
Pair('A', 'X') to 3,
Pair('B', 'Y') to 3,
Pair('C', 'Z') to 3,
Pair('C', 'X') to 6,
Pair('A', 'Y') to 6,
Pair('B', 'Z') to 6,
)
// In t... | 0 | Kotlin | 0 | 0 | f22f10da922832d78dd444b5c9cc08fadc566b4b | 1,416 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day10.kt | Gitvert | 433,947,508 | false | {"Kotlin": 82286} | fun day10() {
val lines: List<String> = readFile("day10.txt")
day10part1(lines)
day10part2(lines)
}
fun day10part1(lines: List<String>) {
val answer = lines.map { getCorruptedPoints(it) }.sumOf{ it }
println("10a: $answer")
}
fun day10part2(lines: List<String>) {
val incompleteLines = lines.... | 0 | Kotlin | 0 | 0 | 02484bd3bcb921094bc83368843773f7912fe757 | 1,720 | advent_of_code_2021 | MIT License |
src/Day02.kt | mpythonite | 572,671,910 | false | {"Kotlin": 29542} | fun main() {
fun part1(input: List<String>): Int {
var score = 0
for (i in input.indices) {
val them = input[i].first() - 'A' + 1
val me = input[i].last() - 'X' + 1
score += me
if (me == them) score += 3
if (me == them % 3 + 1) score += 6
... | 0 | Kotlin | 0 | 0 | cac94823f41f3db4b71deb1413239f6c8878c6e4 | 1,125 | advent-of-code-2022 | Apache License 2.0 |
string-similarity/src/commonMain/kotlin/com/aallam/similarity/DamerauLevenshtein.kt | aallam | 597,692,521 | false | null | package com.aallam.similarity
/**
* Damerau-Levenshtein distance with transposition (*unrestricted Damerau-Levenshtein* distance).
*
* The distance is the minimum number of operations needed to transform one string into the other, where an operation
* is defined as an insertion, deletion, or substitution of a sing... | 0 | Kotlin | 0 | 1 | 40cd4eb7543b776c283147e05d12bb840202b6f7 | 2,958 | string-similarity-kotlin | MIT License |
src/day07/Day07.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package template
import readInput
import java.util.*
class Day07 {
fun part1(): Int {
val readInput = readInput("day07/input")
return part1(readInput)
}
fun part2(): Int {
val readInput = readInput("day07/input")
return part2(readInput)
}
fun part1(input: List<Str... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 2,507 | adventofcode-2022 | Apache License 2.0 |
algorithms/src/main/kotlin/com/kotlinground/algorithms/stack/dailytemperatures/dailyTemperatures.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.algorithms.stack.dailytemperatures
import java.util.Stack
/**
* To solve this problem, we will use a Monotonic Decreasing Stack. That is a stack, where all the values inside the
* stack, are ordered from largest, to smallest. Meaning, we only add to the stack when the stack is either:
*
*... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 3,149 | KotlinGround | MIT License |
src/Day10.kt | zdenekobornik | 572,882,216 | false | null | fun main() {
fun generateValues(testInput: List<String>): List<Int> {
return testInput.flatMap { line ->
when (line) {
"noop" -> listOf(0)
else -> listOf(0, line.substring(5).toInt())
}
}.runningFold(1) { x, op -> x + op }
}
fun part1(... | 0 | Kotlin | 0 | 0 | f73e4a32802fa43b90c9d687d3c3247bf089e0e5 | 1,095 | advent-of-code-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.