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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
algorithms/src/main/kotlin/com/kotlinground/algorithms/numssameconsecdiff/numssameconsecdiff.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.algorithms.numssameconsecdiff
/**
* Each level contains the numbers that are of the same amount of digits. Also, each level corresponds to the solutions
with a specific number of digits.
level 1: [1, 2, 3, 4, 5, 6, 7, 8, 9]
level 2: [18, 29, 70, 81, 92]
level 3: [181, 292, 707, 818, 929]
Fo... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 2,761 | KotlinGround | MIT License |
codeforces/kotlinheroes8/f.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.kotlinheroes8
fun main() {
val (n, m) = readInts()
val groups = List(2) { mutableListOf<IndexedValue<Int>>() }
repeat(n) {
val (k, t) = readInts()
groups[t - 1].add(IndexedValue(it, k))
}
val groupSum = groups.map { group -> group.sumOf { it.value } }
val can = BooleanArray(m + 1)
val how... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,268 | competitions | The Unlicense |
src/jvmMain/kotlin/day06/initial/Day06.kt | liusbl | 726,218,737 | false | {"Kotlin": 109684} | package day06.initial
import java.io.File
import kotlin.math.*
/**
Time: 7 15 30
Record: 9 40 200
0 -> 0
1 -> (7-1)*1=6
2 -> (7-2)*2=10
3 -> (7-3)*3=12
4 -> (7-4)*4=12
5 -> (7-5)*5=10
6 -> (7-6)*6=6
7 -> 0
formula:
h = hold
f = result time
t = time
d = distance
f = (t - h) * h
f = h*t - h*h
-h^2 + ht -... | 0 | Kotlin | 0 | 0 | 1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1 | 2,849 | advent-of-code | MIT License |
kotlin/templates-and-commons/src/main/kotlin/NumberTheory.kt | ShreckYe | 345,946,821 | false | null | import kotlin.math.ln
import kotlin.math.sqrt
fun simplePrimesTo(n: Int): List<Int> =
(2..n).filter { i -> (2 until i).all { i % it != 0 } }
val xLnXConst = 30 * ln(113.toDouble()) / 113
fun piXUpperBound(x: Int): Int = run {
require(x >= 2)
// see: https://en.wikipedia.org/wiki/Prime-counting_function#In... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 3,308 | google-code-jam | MIT License |
src/main/kotlin/com/groundsfam/advent/y2023/d15/Day15.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2023.d15
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.readLines
private data class Lens(val label: String, val focalLength: Int)
private fun hash(s: String): Int =
s.fold(0) { curr, c ->
(curr + c.... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 1,246 | advent-of-code | MIT License |
src/day08/Day08Answer2.kt | IThinkIGottaGo | 572,833,474 | false | {"Kotlin": 72162} | package day08
import readInput
/**
* Answers from [Advent of Code with <NAME> | Day 8](https://youtu.be/6d6FXFh-UdA)
*/
val input = readInput("day08")
fun main() {
val myGameField = GameField.fromLines(input)
println(myGameField.countVisible()) // 1803
println(myGameField.maxScenicScore()) // 268... | 0 | Kotlin | 0 | 0 | 967812138a7ee110a63e1950cae9a799166a6ba8 | 3,207 | advent-of-code-2022 | Apache License 2.0 |
src/algorithmsinanutshell/DijkstraAlgorithm.kt | realpacific | 234,499,820 | false | null | package algorithmsinanutshell
import algorithmdesignmanualbook.padLeft
import java.util.*
import kotlin.test.assertEquals
class DijkstraAlgorithm(val graph: Graph, private val startVertex: Vertex, private val endVertex: Vertex) {
/**
* List containing path:length
*/
private val connections = mutabl... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 3,865 | algorithms | MIT License |
src/main/kotlin/prefixSum/MinSubArrayLen.kt | ghonix | 88,671,637 | false | null | package prefixSum
import kotlin.math.min
/*
https://leetcode.com/problems/minimum-size-subarray-sum/
*/
class MinSubArrayLen {
fun minSubArrayLen(target: Int, nums: IntArray): Int {
if (nums.isEmpty()) {
return 0
}
var minSize = Int.MAX_VALUE
val prefixSums = IntArray(n... | 0 | Kotlin | 0 | 2 | 25d4ba029e4223ad88a2c353a56c966316dd577e | 2,120 | Problems | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FrogPosition.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,793 | kotlab | Apache License 2.0 |
src/com/mrxyx/algorithm/Coin.kt | Mrxyx | 366,778,189 | false | null | package com.mrxyx.algorithm
import kotlin.math.min
/**
* 零钱兑换
* https://leetcode-cn.com/problems/coin-change/
*/
class Coin {
private var res: Int = Int.MAX_VALUE
/**
* 暴力递归 自顶向下
*/
fun coinChangeV1(coins: Array<Int>, amount: Int): Int {
if (coins.isEmpty()) return 0
coinChan... | 0 | Kotlin | 0 | 0 | b81b357440e3458bd065017d17d6f69320b025bf | 2,318 | algorithm-test | The Unlicense |
2023/src/main/kotlin/Day24.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import kotlin.math.abs
object Day24 {
fun part1(input: String, testRange: LongRange): Int {
val hailstones = parse(input)
return hailstones
.mapIndexed { a, h1 ->
hailstones.subList(a + 1, hailstones.size).count { h2 ->
willCollideXy(h1, h2, testRange)
}
}
.sum()
... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 4,774 | advent-of-code | MIT License |
src/main/kotlin/day7/day7KtTest.kt | Jessevanbekkum | 112,612,571 | false | null | package day7
fun day7_1(filename: String):String {
val lines = util.readLines(filename);
val regex = Regex("([a-z]*) \\((\\d*)\\) -> ([a-z, ]*)").toPattern()
val first = ArrayList<String>()
val rest = ArrayList<String>()
lines.forEach {
val result = regex.matcher(it)
if (result.mat... | 0 | Kotlin | 0 | 0 | 1340efd354c61cd070c621cdf1eadecfc23a7cc5 | 1,891 | aoc-2017 | Apache License 2.0 |
src/Day02.kt | wujingwe | 574,096,169 | false | null | fun main() {
fun String.toShape(): Shape = when(this) {
"A", "X" -> Shape.Rock
"B", "Y" -> Shape.Paper
else -> Shape.Scissor
}
fun shapeScore(shape: Shape): Int {
return shape.score
}
fun outcomeScore(opponent: Shape, me: Shape): Int {
return if (me > oppone... | 0 | Kotlin | 0 | 0 | a5777a67d234e33dde43589602dc248bc6411aee | 2,368 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/Day06.kt | bent-lorentzen | 727,619,283 | false | {"Kotlin": 68153} | import java.time.LocalDateTime
import java.time.ZoneOffset
import kotlin.math.floor
import kotlin.math.sqrt
fun main() {
fun getValues(input: List<String>, label: String) =
input.first { it.startsWith(label) }.substringAfter(label).split(Regex(" +")).filterNot { it.isEmpty() }.map { it.toInt() }
fun ... | 0 | Kotlin | 0 | 0 | 41f376bd71a8449e05bbd5b9dd03b3019bde040b | 1,711 | aoc-2023-in-kotlin | Apache License 2.0 |
src/Day03.kt | mddanishansari | 576,622,315 | false | {"Kotlin": 11861} | fun main() {
val lowerCaseRange = 'a'..'z'
fun Char.priority(): Int {
if (this in lowerCaseRange)
return code - 96
return code - 38
}
fun part1(input: List<String>): Int {
var priorities = 0
input.forEach {
val (firstHalf, secondHalf) = it.chunked... | 0 | Kotlin | 0 | 0 | e032e14b57f5e6c2321e2b02b2e09d256a27b2e2 | 1,163 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/groundsfam/advent/y2022/d11/Day11.kt | agrounds | 573,140,808 | false | {"Kotlin": 281620, "Shell": 742} | package com.groundsfam.advent.y2022.d11
import com.groundsfam.advent.DATAPATH
import com.groundsfam.advent.timed
import kotlin.io.path.div
import kotlin.io.path.useLines
class Monkey(startingItems: List<Long>, val operation: (Long) -> Long, val test: (Long) -> Int) {
private val items = ArrayDeque(startingItems)
... | 0 | Kotlin | 0 | 1 | c20e339e887b20ae6c209ab8360f24fb8d38bd2c | 2,899 | advent-of-code | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem990/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem990
/**
* LeetCode page: [990. Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(1) where N is the size of equations;
*/
fun equationsPossible(e... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,967 | hj-leetcode-kotlin | Apache License 2.0 |
aoc-day9/src/Day9.kt | rnicoll | 438,043,402 | false | {"Kotlin": 90620, "Rust": 1313} | import java.nio.file.Files
import java.nio.file.Path
import java.util.*
fun main() {
val map: Array<IntArray> = Files.readAllLines(Path.of("input")).mapNotNull { line ->
if (line.isBlank()) {
null
} else {
line.toCharArray().map { it.toString().toInt() }.toIntArray()
... | 0 | Kotlin | 0 | 0 | 8c3aa2a97cb7b71d76542f5aa7f81eedd4015661 | 2,388 | adventofcode2021 | MIT License |
project/src/problems/PrimeAndCompositeNumbers.kt | informramiz | 173,284,942 | false | null | package problems
object PrimeAndCompositeNumbers {
/**
* https://codility.com/media/train/8-PrimeNumbers.pdf
* if number a is a divisor of n, then n/a is also a divisor.
* One of these two divisors is less than or equal to √n.
* (If that were not the case, n would be
* a product of two... | 0 | Kotlin | 0 | 0 | a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4 | 12,737 | codility-challenges-practice | Apache License 2.0 |
src/y2016/Day17.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2016
import util.Direction
import util.Pos
import util.md5
object Day17 {
val viablePositions = List(4) { x -> List(4) { y -> x to y } }.flatten().toSet()
fun part1(input: String): String {
var states = listOf((0 to 3) to "")
while (true) {
states = states.flatMap {
... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,158 | advent-of-code | Apache License 2.0 |
src/main/kotlin/Day15.kt | i-redbyte | 433,743,675 | false | {"Kotlin": 49932} | import java.util.*
fun main() {
val data = readInputFile("day15").map { it.toCharArray().map { it.digitToInt() } }
fun part1(): Int {
val n = data.size
val m = data.first().size
val matrix = Array(n) { IntArray(m) { Int.MAX_VALUE } }
val v = Array(n) { BooleanArray(m) }
... | 0 | Kotlin | 0 | 0 | 6d4f19df3b7cb1906052b80a4058fa394a12740f | 2,307 | AOC2021 | Apache License 2.0 |
src/Day01/Day01.kt | ctlevi | 578,257,705 | false | {"Kotlin": 10889} | fun main() {
fun part1(input: List<String>): Int {
var currentElfCalorieCount: Int = 0
var highestCalorieCount: Int = 0
for (row in input) {
if (row == "") {
if (currentElfCalorieCount > highestCalorieCount) {
highestCalorieCount = currentElfCa... | 0 | Kotlin | 0 | 0 | 0fad8816e22ec0df9b2928983713cd5c1ac2d813 | 1,613 | advent_of_code_2022 | Apache License 2.0 |
src/Day12.kt | acrab | 573,191,416 | false | {"Kotlin": 52968} | import com.google.common.truth.Truth.assertThat
import kotlin.math.min
data class HillPoint(val elevation: Char, val x: Int, val y: Int, val isEnd: Boolean = false) {
var steps: Int = Int.MAX_VALUE
var visited: Boolean = false
}
fun main() {
fun parseMap(
input: List<String>
): Pair<List<List... | 0 | Kotlin | 0 | 0 | 0be1409ceea72963f596e702327c5a875aca305c | 3,689 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | vitind | 578,020,578 | false | {"Kotlin": 60987} |
fun main() {
fun getSectionCount(sectionStart: Int, sectionEnd: Int) : Int {
val range = sectionEnd - sectionStart
return if (range == 1) { range } else { range + 1 }
}
fun getSectionBounds(sectionString: String) : List<Int> = sectionString.split("-").map { it.toInt() }
fun part1(inpu... | 0 | Kotlin | 0 | 0 | 2698c65af0acd1fce51525737ab50f225d6502d1 | 2,054 | aoc2022 | Apache License 2.0 |
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/sort/MergeInsertionSort.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.datastructuresandalgorithms.sort
/**
* Merge-Insertion sort is a sorting algorithm using the principle that for
* smaller sets of data, insertion sort is more efficient than merge sort.
* It uses a threshold. If the list's size is below the threshold, insertion sort will be used.
*
* Prin... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 2,073 | KAHelpers | MIT License |
src/Coordinate.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | import java.lang.Integer.max
import java.lang.Integer.min
import kotlin.math.absoluteValue
import kotlin.math.sign
data class Coordinate(val x: Int, val y: Int) {
constructor(x: String, y: String) : this(x.toInt(), y.toInt())
fun manhattanDistanceTo(coordinate: Coordinate): Int = manhattanDistanceTo(coordinat... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 1,972 | advent-of-code-22-kotlin | Apache License 2.0 |
contest1907/src/main/kotlin/D.kt | austin226 | 729,634,548 | false | {"Kotlin": 23837} | import kotlin.math.max
import kotlin.math.min
// https://codeforces.com/contest/1907/problem/D
private fun String.splitWhitespace() = split("\\s+".toRegex())
private fun readInt(): Int = readln().toInt()
private fun readInts(): List<Int> = readln().splitWhitespace().map { it.toInt() }
private fun testK(segments: Lis... | 0 | Kotlin | 0 | 0 | 4377021827ffcf8e920343adf61a93c88c56d8aa | 1,765 | codeforces-kt | MIT License |
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day12.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentyone
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.readDayInput
class Day12 : Day<Int> {
private enum class NodeType {
Start,
End,
SmallCave,
BigCave
}
private data class Node(
val id: String,
val conne... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 3,823 | adventofcode | Apache License 2.0 |
day02/part2.kts | bmatcuk | 726,103,418 | false | {"Kotlin": 214659} | // --- Part Two ---
// The Elf says they've stopped producing snow because they aren't getting any
// water! He isn't sure why the water stopped; however, he can show you how to
// get to the water source to check it out for yourself. It's just up ahead!
//
// As you continue your walk, the Elf poses a second question:... | 0 | Kotlin | 0 | 0 | a01c9000fb4da1a0cd2ea1a225be28ab11849ee7 | 2,399 | adventofcode2023 | MIT License |
src/main/kotlin/net/wrony/aoc2023/a7/Main.kt | kopernic-pl | 727,133,267 | false | {"Kotlin": 52043} | package net.wrony.aoc2023.a7
import net.wrony.aoc2023.a7.Hand.Companion.fromTextLine
import kotlin.io.path.Path
import kotlin.io.path.readLines
//Five of a kind, where all five cards have the same label: AAAAA
//Four of a kind, where four cards have the same label and one card has a different label: AA8AA
//Full hou... | 0 | Kotlin | 0 | 0 | 1719de979ac3e8862264ac105eb038a51aa0ddfb | 4,343 | aoc-2023-kotlin | MIT License |
src/test/kotlin/be/brammeerten/y2022/Day19Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2022
import be.brammeerten.extractRegexGroups
import be.brammeerten.extractRegexGroupsI
import be.brammeerten.readFile
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import kotlin.math.max
val POTENTIAL_EXTRA_GEODES_PER_MINUTE_LEFT = createSequence(listOf(0... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 7,647 | Advent-of-Code | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem399/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem399
/**
* LeetCode page: [399. Evaluate Division](https://leetcode.com/problems/evaluate-division/);
*/
class Solution {
/* Complexity:
* Time O(NE) and Space O(E) where E is the size of equations and N is the size of queries;
*/
fun calcEquation(equations: Lis... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,066 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/io/binarysearch/AllElementsInTwoBinarySearchTree.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.binarysearch
import io.models.TreeNode
// https://leetcode.com/problems/all-elements-in-two-binary-search-trees/
class AllElementsInTwoBinarySearchTree {
fun getAllElements(root1: TreeNode?, root2: TreeNode?): List<Int> = execute(root1, root2)
fun execute(root0: TreeNode?, root1: TreeNode?): List<In... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,741 | coding | MIT License |
src/day07/Day07.kt | andreas-eberle | 573,039,929 | false | {"Kotlin": 90908} | package day07
import readInput
import java.util.*
const val day = "07"
fun main() {
fun calculateDirectories(input: List<String>): MutableMap<String, Int> {
val currentDirectory = Stack<String>()
val directories = mutableMapOf<String, Int>()
input.forEach {
when {
... | 0 | Kotlin | 0 | 0 | e42802d7721ad25d60c4f73d438b5b0d0176f120 | 2,509 | advent-of-code-22-kotlin | Apache License 2.0 |
src/day04/Day04.kt | Xlebo | 572,928,568 | false | {"Kotlin": 10125} | package day04
import getOrFetchInputData
import readInput
fun main() {
fun List<String>.asSections(): List<Pair<Pair<Int, Int>, Pair<Int, Int>>> =
this.map { row ->
row.split(",")
.map { section -> section.split("-").map { it.toInt() } }
.map { Pair(it[0], it[1... | 0 | Kotlin | 0 | 0 | cd718c2c7cb59528080d2aef599bd93e0919d2d9 | 1,376 | aoc2022 | Apache License 2.0 |
src/Day07.kt | buongarzoni | 572,991,996 | false | {"Kotlin": 26251} | private const val TOTAL_MEMORY = 70_000_000L
private const val NEEDED_MEMORY = 30_000_000L
fun solveDay07() {
val input = readInput("Day07_test")
execute(input)
}
private val currentPath = ArrayDeque<String>()
private val sizesByPath = mutableMapOf<String, Long>()
private var usedMemory = 0L
private fun exec... | 0 | Kotlin | 0 | 0 | 96aadef37d79bcd9880dbc540e36984fb0f83ce0 | 1,553 | AoC-2022 | Apache License 2.0 |
src/day05/Day05.kt | daniilsjb | 726,047,752 | false | {"Kotlin": 66638, "Python": 1161} | package day05
import java.io.File
import kotlin.math.max
import kotlin.math.min
fun main() {
val data = parse("src/day05/Day05.txt")
println("🎄 Day 05 🎄")
println()
println("[Part 1]")
println("Answer: ${part1(data)}")
println()
println("[Part 2]")
println("Answer: ${part2(data)... | 0 | Kotlin | 0 | 0 | 46a837603e739b8646a1f2e7966543e552eb0e20 | 3,882 | advent-of-code-2023 | MIT License |
year2020/src/main/kotlin/net/olegg/aoc/year2020/day16/Day16.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2020.day16
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.parseInts
import net.olegg.aoc.utils.parseLongs
import net.olegg.aoc.utils.toPair
import net.olegg.aoc.year2020.DayOf2020
/**
* See [Year 2020, Day 16](https://adventofcode.com/2020/day/16)
*/
object Day16 : DayOf20... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,890 | adventofcode | MIT License |
src/Day24.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import utils.BBox2D
import utils.Coord2DInt
import utils.Orientation
import utils.aStar
import kotlin.math.abs
import kotlin.math.max
class Day24 {
data class Wind(val location: Coord2DInt, val orientation: Orientation) {
fun move(boundary: BBox2D): Coord2DInt {
val newLoc = location + orientat... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 5,978 | Advent-Of-Code-2022 | Apache License 2.0 |
src/main/kotlin/day4/Day4.kt | mortenberg80 | 574,042,993 | false | {"Kotlin": 50107} | package day4
class Day4 {
fun getOrganizer(filename: String): SupplyOrganizer {
val readLines = this::class.java.getResourceAsStream(filename).bufferedReader().readLines()
return SupplyOrganizer(readLines)
}
}
class SupplyOrganizer(input: List<String>) {
val elfPairs = input.map { ElfPair... | 0 | Kotlin | 0 | 0 | b21978e145dae120621e54403b14b81663f93cd8 | 1,886 | adventofcode2022 | Apache License 2.0 |
kotlin/src/katas/kotlin/sort/mergesort/MergeSort5.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.sort.mergesort
import nonstdlib.listOfInts
import nonstdlib.permutations
import nonstdlib.printed
import datsok.shouldEqual
import org.junit.Test
import java.util.*
import kotlin.random.Random
class MergeSort5Tests {
@Test fun `trivial examples`() {
emptyList<Int>().mergeSort() should... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 2,705 | katas | The Unlicense |
src/main/kotlin/g1201_1300/s1202_smallest_string_with_swaps/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1201_1300.s1202_smallest_string_with_swaps
// #Medium #String #Hash_Table #Depth_First_Search #Breadth_First_Search #Union_Find
// #2023_06_09_Time_562_ms_(100.00%)_Space_84.3_MB_(100.00%)
class Solution {
fun smallestStringWithSwaps(s: String, pairs: List<List<Int>>): String {
val uf = UF(s.leng... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,884 | LeetCode-in-Kotlin | MIT License |
project/src/problems/Sorting.kt | informramiz | 173,284,942 | false | null | package problems
import extensions.swap
//https://codility.com/media/train/4-Sorting.pdf
object Sorting {
fun selectionSort(A: Array<Int>): Array<Int> {
for (i in 0 until A.size-1) {
val minimumElementIndex = findIndexOfMinimum(A, i+1)
A.swap(i, minimumElementIndex)
}
... | 0 | Kotlin | 0 | 0 | a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4 | 8,805 | codility-challenges-practice | Apache License 2.0 |
src/Day11.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | const val RELIEF = 3
const val ROUNDS_PART_1 = 20
const val ROUNDS_PART_2 = 10000
data class Monkey (val items: MutableList<Long>, val operation: List<String>, val testDivisibleBy: Int, val indexIfTestTrue: Int, val indexIfTestFalse: Int, var totalNumOfInspectedItems: Int)
fun main() {
fun getMonkeys(input: List<... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 3,952 | AoC2022 | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/NumberOfValidWordsForEachPuzzle.kt | faniabdullah | 382,893,751 | false | null | //With respect to a given puzzle string, a word is valid if both the following
//conditions are satisfied:
//
// word contains the first letter of puzzle.
// For each letter in word, that letter is in puzzle.
//
// For example, if the puzzle is "abcdefg", then valid words are "faced",
//"cabbage", and "baggage", wh... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,232 | dsa-kotlin | MIT License |
src/Day24.kt | illarionov | 572,508,428 | false | {"Kotlin": 108577} | import Day24.Blizzard
import Day24.Direction.*
import Day24.Valley
import Day24.XY
fun main() {
val testInput = readInput("Day24_test")
.parseValley()
val input = readInput("Day24")
.parseValley()
part1(testInput).also {
println("Part 1, test input: $it")
check(it == 18)
... | 0 | Kotlin | 0 | 0 | 3c6bffd9ac60729f7e26c50f504fb4e08a395a97 | 6,436 | aoc22-kotlin | Apache License 2.0 |
src/Day04.kt | erikthered | 572,804,470 | false | {"Kotlin": 36722} | fun main() {
fun part1(input: List<String>): Int {
var contained = 0
for(line in input) {
val (a, b) = line.split(",").map { getSections(it) }
if(a.containsAll(b) || b.containsAll(a))
contained += 1
}
return contained
}
fun part2(inpu... | 0 | Kotlin | 0 | 0 | 3946827754a449cbe2a9e3e249a0db06fdc3995d | 996 | aoc-2022-kotlin | Apache License 2.0 |
src/main/aoc2021/Day12.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2021
class Day12(input: List<String>) {
private val graph = parseInput(input)
private fun String.isEnd() = equals("end")
private fun String.isStart() = equals("start")
private fun String.isSmall() = first().isLowerCase() // It's all lowercase or all uppercase
private fun parseInput(in... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,025 | aoc | MIT License |
src/main/kotlin/day7/Day7.kt | alxgarcia | 435,549,527 | false | {"Kotlin": 91398} | package day7
import java.io.File
import kotlin.math.abs
fun parseInput(input: String) = input.split(",").groupingBy(String::toInt).eachCount()
private fun minFuelSpentToAlignedPosition(data: Map<Int, Int>, costFn: (Int, Int) -> Int): Int {
val min = data.keys.minOf { it }
val max = data.keys.maxOf { it }
retu... | 0 | Kotlin | 0 | 0 | d6b10093dc6f4a5fc21254f42146af04709f6e30 | 1,139 | advent-of-code-2021 | MIT License |
src/Day03.kt | zhiqiyu | 573,221,845 | false | {"Kotlin": 20644} | import kotlin.math.max
import kotlin.math.abs
fun main() {
fun getPriority(item: Char): Int {
if (item.isLowerCase()) {
return item.minus('a') + 1
} else {
return item.minus('A') + 27
}
}
fun part1(input: List<String>): Int {
var result = 0
... | 0 | Kotlin | 0 | 0 | d3aa03b2ba2a8def927b94c2b7731663041ffd1d | 1,608 | aoc-2022 | Apache License 2.0 |
src/Day07.kt | cisimon7 | 573,872,773 | false | {"Kotlin": 41406} | fun main() {
fun getNestedDirectories(folder: FileSystem.Storage): List<FileSystem.Storage> {
val directories = mutableListOf<FileSystem.Storage>()
val stack = mutableListOf(folder to false)
while (stack.isNotEmpty()) {
val (storage, checked) = stack.last()
if (checke... | 0 | Kotlin | 0 | 0 | 29f9cb46955c0f371908996cc729742dc0387017 | 3,974 | aoc-2022 | Apache License 2.0 |
src/Day09.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
val DIM = 1000
val START = DIM/2
fun part1(input: List<String>): Int {
val head = intArrayOf(START, START)
var tail = intArrayOf(START, START)
val seen = mutableSetOf(Pair(START, START))
for (i in input) {
val parts = i.split(" ")
val di... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 3,059 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/dev/paulshields/aoc/Day5.kt | Pkshields | 433,609,825 | false | {"Kotlin": 133840} | /**
* Day 5: Hydrothermal Venture
*/
package dev.paulshields.aoc
import dev.paulshields.aoc.common.Point
import dev.paulshields.aoc.common.readFileAsStringList
fun main() {
println(" ** Day 5: Hydrothermal Venture ** \n")
val rawHydrothermalVents = readFileAsStringList("/Day5HydrothermalVentsLineSegments.... | 0 | Kotlin | 0 | 0 | e3533f62e164ad72ec18248487fe9e44ab3cbfc2 | 1,969 | AdventOfCode2021 | MIT License |
src/main/kotlin/aoc2020/day05_binary_boarding/BinaryBoarding.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package aoc2020.day05_binary_boarding
fun main() {
util.solve(842, ::partOne)
util.solve(617, ::partTwo)
}
private val IntRange.size
get() = last - start + 1
private fun IntRange.partition(c: Char) = when (c) {
'F', 'L' -> start..(last - size / 2)
'B', 'R' -> (start + size / 2)..last
else -> ... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 1,051 | aoc-2021 | MIT License |
src/main/kotlin/day8.kt | gautemo | 725,273,259 | false | {"Kotlin": 79259} | import shared.*
fun main() {
val input = Input.day(8)
println(day8A(input))
println(day8B(input))
}
fun day8A(input: Input): Long {
val (instructions, network) = input.chunks
val nodes = network.lines().toNetwork()
val ghost = Ghost(nodes.first { it.name == "AAA" })
while (ghost.on.name !=... | 0 | Kotlin | 0 | 0 | 6862b6d7429b09f2a1d29aaf3c0cd544b779ed25 | 1,745 | AdventOfCode2023 | MIT License |
src/main/kotlin/year2022/day-16.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2022
import lib.TraversalBreadthFirstSearch
import lib.aoc.Day
import lib.aoc.Part
fun main() {
Day(16, 2022, PartA16(), PartB16()).run()
}
open class PartA16 : Part() {
internal data class State(val current: String, val minutes: Int, val opened: Set<Valve>)
internal data class Valve(val nam... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 3,048 | Advent-Of-Code-Kotlin | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2022/day3/Day3.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day3
import com.jacobhyphenated.advent2022.Day
/**
* Day 3: Rucksack Reorganization
*
* There are a bunch of rucksacks with different items (characters a-z and A-Z)
* Each item has a priority: a-z is 1-26 and A-Z is 27-52
*/
class Day3: Day<List<String>> {
// create a ... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 1,912 | advent2022 | The Unlicense |
2023/src/main/kotlin/de/skyrising/aoc2023/day7/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2023.day7
import de.skyrising.aoc.*
import it.unimi.dsi.fastutil.bytes.Byte2IntMap
import java.nio.ByteBuffer
enum class HandType {
HIGH_CARD,
ONE_PAIR,
TWO_PAIR,
THREE_OF_A_KIND,
FULL_HOUSE,
FOUR_OF_A_KIND,
FIVE_OF_A_KIND,
}
const val MIRROR_CHAR_CODE = 'Z'.code +... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 2,495 | aoc | MIT License |
src/Day04.kt | peterphmikkelsen | 573,069,935 | false | {"Kotlin": 7834} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0
for (intervals in input) {
val (first, second) = intervals.splitToIntervals()
val intersection = first.intersect(second)
if (intersection == first.toSet() || intersection == second.toSet()) sum++
... | 0 | Kotlin | 0 | 0 | 374c421ff8d867a0bdb7e8da2980217c3455ecfd | 1,112 | aoc-2022 | Apache License 2.0 |
src/Day13.kt | HylkeB | 573,815,567 | false | {"Kotlin": 83982} | private sealed class Value {
class List : Value() {
var values = emptyList<Value>()
}
class Primitive(val value: Int) : Value()
}
private sealed class ValidationResult
private object Valid : ValidationResult()
private object Invalid : ValidationResult()
private object Unknown : ValidationResult()
... | 0 | Kotlin | 0 | 0 | 8649209f4b1264f51b07212ef08fa8ca5c7d465b | 4,768 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day03.kt | Narmo | 573,031,777 | false | {"Kotlin": 34749} | fun main() {
fun Char.getPriority(): Int = when {
isUpperCase() -> this - 'A' + 27
else -> this - 'a' + 1
}
fun part1(input: List<String>): Int = input.sumOf { line ->
val compartmentSize = line.length / 2
val firstCompartment = line.substring(0, compartmentSize).toSet()
val secondCompartment = line.subst... | 0 | Kotlin | 0 | 0 | 335641aa0a964692c31b15a0bedeb1cc5b2318e0 | 844 | advent-of-code-2022 | Apache License 2.0 |
src/aoc2023/Day11.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
import kotlin.math.abs
fun main() {
fun convertToMaze(lines: List<String>): Array<Array<Char>> {
val maze = Array(lines.size) { Array(lines[0].length) { '.' } }
for (i in lines.indices) {
maze[i] = lines[i].toCharArray().toTypedArray()
}
... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 4,207 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/io/github/pshegger/aoc/y2022/Y2022D7.kt | PsHegger | 325,498,299 | false | null | package io.github.pshegger.aoc.y2022
import io.github.pshegger.aoc.common.BaseSolver
class Y2022D7 : BaseSolver() {
override val year = 2022
override val day = 7
private val fileSystem by lazy { parseInput() }
private val minimumToDelete by lazy { REQUIRED_DISK_SPACE - (DISK_SPACE - fileSystem.size) ... | 0 | Kotlin | 0 | 0 | 346a8994246775023686c10f3bde90642d681474 | 3,434 | advent-of-code | MIT License |
src/Day07.kt | nordberg | 573,769,081 | false | {"Kotlin": 47470} | enum class FileTypes {
DIRECTORY,
FILE
}
fun main() {
data class AocFile(val name: String, val filePath: String, val size: Int?, val fileType: FileTypes)
fun part1(input: List<String>): Set<AocFile> {
val fileConts = mutableMapOf<String, MutableSet<AocFile>>()
val dirsWithoutSize = mu... | 0 | Kotlin | 0 | 0 | 3de1e2b0d54dcf34a35279ba47d848319e99ab6b | 3,655 | aoc-2022 | Apache License 2.0 |
src/day02/Day02.kt | ritesh-singh | 572,210,598 | false | {"Kotlin": 99540} | package day02
import readInput
fun main() {
// Y defeats A
// Z defeats B
// X defeats C
val defeatMap = mapOf(
"A" to "Y",
"B" to "Z",
"C" to "X"
)
// X loses to B
// Y loses to C
// Z loses to A
val loseMap = mapOf(
"B" to "X",
"C" to "Y"... | 0 | Kotlin | 0 | 0 | 17fd65a8fac7fa0c6f4718d218a91a7b7d535eab | 2,091 | aoc-2022-kotlin | Apache License 2.0 |
solutions/aockt/y2021/Y2021D14.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2021
import io.github.jadarma.aockt.core.Solution
object Y2021D14 : Solution {
/**
* Holds metadata about a polymer after repeated polymerization via some rules.
* The submarine does not have enough memory to store exponentially growing polymers, unfortunately.
*/
private class ... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 4,299 | advent-of-code-kotlin-solutions | The Unlicense |
src/Day11/Day11.kt | AllePilli | 572,859,920 | false | {"Kotlin": 47397} | package Day11
import checkAndPrint
import divides
import measureAndPrintTimeMillis
import readInput
import java.math.BigDecimal
import java.math.BigInteger
import java.math.RoundingMode
import java.util.*
fun main() {
val itemsRgx = """\s+Starting items:\s+(.*)""".toRegex()
val operationRgx = """\s+Operation:... | 0 | Kotlin | 0 | 0 | 614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643 | 5,133 | AdventOfCode2022 | Apache License 2.0 |
src/Day01.kt | stcastle | 573,145,217 | false | {"Kotlin": 24899} | import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
var sum = 0
var max = 0
input.forEach {
if (it == "") {
max = max(sum, max)
sum = 0
} else {
sum += it.toInt()
}
}
// one more time on the end
return max(sum, max)
}
fun pa... | 0 | Kotlin | 0 | 0 | 746809a72ea9262c6347f7bc8942924f179438d5 | 1,142 | aoc2022 | Apache License 2.0 |
Algorithms/Array/twoSum.kt | ahampriyanshu | 278,614,006 | false | {"C++": 583777, "Java": 277289, "Python": 254940, "C": 223686, "C#": 127046, "JavaScript": 96050, "Ruby": 37909, "PHP": 37167, "Go": 34857, "TypeScript": 34282, "Swift": 16690, "Jupyter Notebook": 13334, "Kotlin": 9718, "Rust": 9569, "Shell": 7923, "Scala": 6275, "Haskell": 5456, "HTML": 2270, "Clojure": 348, "Makefile... | import java.util.*
/*Naive Approach: Check for all pairs if they adds up to the target or not
TC: O(n*n) SC: O(1)
*/
fun findTwoSumNaive(nums: List<Int>, target: Int): IntArray{
val n = nums.size
for(i in 0 until n){
for(j in (i+1) until n){
if(nums[i] + nums[j] == target)
r... | 0 | C++ | 760 | 156 | ea880b13c09df58922065ab408d23fa4d264fb7c | 2,482 | algo-ds-101 | MIT License |
src/main/kotlin/g1201_1300/s1268_search_suggestions_system/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1201_1300.s1268_search_suggestions_system
// #Medium #Array #String #2023_06_08_Time_331_ms_(100.00%)_Space_50.2_MB_(88.89%)
class Solution {
private var result: MutableList<List<String>> = ArrayList()
fun suggestedProducts(products: Array<String>, searchWord: String): List<List<String>> {
/... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 3,468 | LeetCode-in-Kotlin | MIT License |
src/net/sheltem/common/GraphUtils.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.common
import net.sheltem.common.SearchGraph.Edge
import net.sheltem.common.SearchGraph.Route
import kotlin.random.Random
class SearchGraph<N>(val nodes: Set<Node<N>>, edges: Set<Edge<N>>, val bidirectional: Boolean, val circular: Boolean = false) {
val edges: Set<Edge<N>> = if (bidirectional... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 7,078 | aoc | Apache License 2.0 |
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/dynamic/candies/Candies.kt | slobanov | 200,526,003 | false | null | package ru.amai.study.hackerrank.practice.interviewPreparationKit.dynamic.candies
import java.util.*
import kotlin.math.max
import kotlin.math.min
fun candies(grades: Array<Int>): Long {
val size = grades.size
val gradeByIndex = saveGrading(grades)
val startIndicesWithDirections = buildStartIndicesWithD... | 0 | Kotlin | 0 | 0 | 2cfdf851e1a635b811af82d599681b316b5bde7c | 2,653 | kotlin-hackerrank | MIT License |
src/main/kotlin/solutions/Day11.kt | chutchinson | 573,586,343 | false | {"Kotlin": 21958} | class Day11 : Solver {
data class Monkey(
val startingItems: ArrayDeque<Long>,
val worry: (Long) -> Long,
val divisor: Long,
val throwTrue: Int,
val throwFalse: Int)
override fun solve (input: Sequence<String>) {
val monkies = input
.split { it.i... | 0 | Kotlin | 0 | 0 | 5076dcb5aab4adced40adbc64ab26b9b5fdd2a67 | 2,922 | advent-of-code-2022 | MIT License |
src/Day02.kt | adrianforsius | 573,044,406 | false | {"Kotlin": 68131} | import org.assertj.core.api.Assertions.assertThat
val opponent = mapOf(
"A" to 1,
"B" to 2,
"C" to 3,
)
val player = mapOf(
"X" to 1,
"Y" to 2,
"Z" to 3,
)
fun getWinner(opp: Int): Int = when(opp) {
1 -> 2
2 -> 3
3 -> 1
else -> error("nope")
}
fun getLoser(opp: Int): Int = wh... | 0 | Kotlin | 0 | 0 | f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb | 2,154 | kotlin-2022 | Apache License 2.0 |
kotlin/2022/round-1b/2/src/main/kotlin/alllongs/AllLongsSolution.kt | ShreckYe | 345,946,821 | false | null | import kotlin.math.abs
import kotlin.math.min
fun main() {
val t = readLine()!!.toInt()
repeat(t, ::testCase)
}
fun testCase(ti: Int) {
val (nn, pp) = readLine()!!.splitToSequence(' ').map { it.toInt() }.toList()
val xx = List(nn) { readLine()!!.splitToSequence(' ').map { it.toInt() }.toList() }
... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 1,230 | google-code-jam | MIT License |
src/Day10.kt | szymon-kaczorowski | 572,839,642 | false | {"Kotlin": 45324} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
val signal = mutableListOf<Int>()
signal.add(1)
input.forEach {
signal.add(signal.last())
if (it != "noop") {
val toInt = it.split(" ")[1].toInt()
signal.add(si... | 0 | Kotlin | 0 | 0 | 1d7ab334f38a9e260c72725d3f583228acb6aa0e | 1,619 | advent-2022 | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-23.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2022
import com.github.ferinagy.adventOfCode.Coord2D
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2022, "23-input")
val testInput1 = readInputLines(2022, "23-test1")
... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,241 | advent-of-code | MIT License |
kotlin/src/katas/kotlin/adventofcode/day9/Part1.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.adventofcode.day9
import katas.kotlin.adventofcode.day9.ParamMode.*
import java.io.*
import java.util.*
fun main() {
val text = File("src/katas/kotlin/adventofcode/day9/input.txt").readText()
val program = text.split(",").map(String::toLong)
execute(program, read = { 1 }).forEach { pr... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 3,399 | katas | The Unlicense |
src/Day04.kt | SebastianHelzer | 573,026,636 | false | {"Kotlin": 27111} |
fun main() {
fun getRangePairsFromInput(input: List<String>): List<Pair<IntRange, IntRange>> {
return input.map {
val (first, second) = it.split(',').map {
val (start, end) = it.split('-').map { it.toInt() }
start..end
}
first to second
... | 0 | Kotlin | 0 | 0 | e48757626eb2fb5286fa1c59960acd4582432700 | 1,182 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | timj11dude | 572,900,585 | false | {"Kotlin": 15953} | fun main() {
val extractionRegex = "^(\\d+)-(\\d+),(\\d+)-(\\d+)$".toRegex()
fun IntRange.fullyContains(other: IntRange): Boolean = this.first <= other.first && this.last >= other.last
fun IntRange.partiallycontains(other: IntRange): Boolean = this.first in other || this.last in other || other.first in th... | 0 | Kotlin | 0 | 0 | 28aa4518ea861bd1b60463b23def22e70b1ed481 | 1,274 | advent-of-code-2022 | Apache License 2.0 |
src/main/aoc2023/Day13.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2023
class Day13(input: List<String>) {
private val patterns2 = input.map { rawPattern ->
val rows = rawPattern.split("\n")
val cols = rows.first().indices.map { i ->
rows.map { it[i] }.joinToString("")
}
Pattern(rows, cols)
}
// Keeps rows and cols a... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,804 | aoc | MIT License |
src/main/kotlin/day2/day2.kt | lavong | 317,978,236 | false | null | /*
--- Day 2: Password Philosophy ---
Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via toboggan.
The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with our computers; we can't log in!" You ask if you can take a l... | 0 | Kotlin | 0 | 1 | a4ccec64a614d73edb4b9c4d4a72c55f04a4b77f | 3,526 | adventofcode-2020 | MIT License |
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day17.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2020
class Day17(private val input: List<String>) {
fun solvePart1(): Int {
return runCycles(3)
}
fun solvePart2(): Int {
return runCycles(4)
}
private fun runCycles(dimensions: Int): Int {
val neighbours = (0..80).map { i -> Coordinate(i ... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,920 | advent-of-code | Apache License 2.0 |
src/main/kotlin/days/Day5.kt | VictorWinberg | 433,748,855 | false | {"Kotlin": 26228} | package days
import kotlin.math.abs
import kotlin.math.max
class Day5 : Day(5) {
private fun parseInput() = inputList.map { it.split(" -> ").map { it.split(",").map { it.toInt() } } }
override fun partOne(): Any {
val input = parseInput()
val xyInput = input.filter { (a, b) -> a[0] == b[0] |... | 0 | Kotlin | 0 | 0 | d61c76eb431fa7b7b66be5b8549d4685a8dd86da | 1,308 | advent-of-code-kotlin | Creative Commons Zero v1.0 Universal |
src/Day04.kt | Ajimi | 572,961,710 | false | {"Kotlin": 11228} | fun main() {
fun part1(ranges: List<List<IntRange>>): Int = ranges.count { (first, second) ->
first.all { it in second } || second.all { it in first }
}
fun part2(ranges: List<List<IntRange>>): Int = ranges.count { (first, second) ->
first.any { it in second }
}
// test if implemen... | 0 | Kotlin | 0 | 0 | 8c2211694111ee622ebb48f52f36547fe247be42 | 829 | adventofcode-2022 | Apache License 2.0 |
solutions/aockt/y2015/Y2015D18.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2015
import io.github.jadarma.aockt.core.Solution
object Y2015D18 : Solution {
private class GameOfLife(val width: Int, val height: Int, val santaVariation: Boolean = false) {
private val state = Array(width + 2) { BooleanArray(height + 2) { false } }
init {
stuckLigh... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 3,300 | advent-of-code-kotlin-solutions | The Unlicense |
kotlin/src/com/s13g/aoc/aoc2021/Day14.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2021
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
/**
* --- Day 14: Extended Polymerization ---
* https://adventofcode.com/2021/day/14
*/
private typealias PairCounts = MutableMap<String, Long>
class Day14 : Solver {
override fun solve(lines: List<String>): Result {
val po... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 1,934 | euler | Apache License 2.0 |
src/main/kotlin/de/nilsdruyen/aoc/Day03.kt | nilsjr | 571,758,796 | false | {"Kotlin": 15971} | package de.nilsdruyen.aoc
fun main() {
fun part1(input: List<String>): Int = input.sumUpPrio()
fun part2(input: List<String>): Int {
return input.windowed(3, 3)
.map { group ->
group.first().first { group[1].contains(it) && group[2].contains(it) }
}
... | 0 | Kotlin | 0 | 0 | 1b71664d18076210e54b60bab1afda92e975d9ff | 896 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2017/Day08.kt | tginsberg | 112,672,087 | false | null | /*
* Copyright (c) 2017 by <NAME>
*/
package com.ginsberg.advent2017
/**
* AoC 2017, Day 8
*
* Problem Description: http://adventofcode.com/2017/day/8
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day8/
*/
class Day08(input: List<String>) {
private val instructionRegex = """(\S... | 0 | Kotlin | 0 | 15 | a57219e75ff9412292319b71827b35023f709036 | 2,411 | advent-2017-kotlin | MIT License |
src/Day12.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | fun main() {
fun part1(input: List<String>): Int {
fun map(col: Int, row: Int): Char = input[row][col]
fun height(col: Int, row: Int): Char {
val c = input[row][col]
if (c == 'S') return 'a'
if (c == 'E') return 'z'
return c
}
val (row... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 3,515 | AoC-2022 | Apache License 2.0 |
app/src/main/java/com/achawki/sequencetrainer/math/Operator.kt | achawki | 382,692,328 | false | null | package com.achawki.sequencetrainer.math
import kotlin.math.min
import kotlin.random.Random
interface Operator<T> {
fun apply(t: T): Int
}
enum class BinaryOperator : Operator<Pair<Int, Int>> {
PLUS {
override fun apply(t: Pair<Int, Int>): Int {
return t.first + t.second
}
},
... | 0 | Kotlin | 0 | 0 | fa47830638c8cbe40ba78a4cfaf61d45e12502c6 | 2,281 | number-sequence-trainer-android | Apache License 2.0 |
src/main/kotlin/days/day14/Day14.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day14
import days.Day
import java.util.*
class Day14 : Day() {
override fun partOne(): Any {
val input = readInput()
val maxSize = input.size
var inputMap = mutableMapOf<Coordinate, Char>()
input.forEachIndexed { i, l ->
l.forEachIndexed { j, c ->
... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 5,251 | advent-of-code_2023 | The Unlicense |
src/day14/day14.kt | bienenjakob | 573,125,960 | false | {"Kotlin": 53763} | package day14
import inputTextOfDay
import testTextOfDay
import kotlin.math.max
import kotlin.math.min
const val day = 14
val test = testTextOfDay(day)
val input = inputTextOfDay(day)
typealias Pos = Pair<Int, Int>
val Pos.x get() = first
val Pos.y get() = second
typealias Cave = MutableMap<Pos, Char>
fun scanCav... | 0 | Kotlin | 0 | 0 | 6ff34edab6f7b4b0630fb2760120725bed725daa | 2,502 | aoc-2022-in-kotlin | Apache License 2.0 |
plugins/evaluation-plugin/core/src/com/intellij/cce/metric/CodeGolfMetrics.kt | dunno99 | 221,283,848 | true | null | package com.intellij.cce.metric
import com.intellij.cce.core.Session
import com.intellij.cce.metric.util.Sample
abstract class CodeGolfMetric<T : Number> : Metric {
protected var sample = Sample()
private fun T.alsoAddToSample(): T = also { sample.add(it.toDouble()) }
protected fun computeMoves(session: Sessi... | 0 | null | 0 | 0 | f37a7bcddf4f66018f9cc8dbc109e0d49c3832a9 | 3,121 | intellij-community | Apache License 2.0 |
src/aoc23/Day07.kt | mihassan | 575,356,150 | false | {"Kotlin": 123343} | @file:Suppress("PackageDirectoryMismatch")
package aoc23.day07
import lib.Collections.histogram
import lib.Solution
enum class Card(val symbol: Char) {
JOKER('X'),
TWO('2'),
THREE('3'),
FOUR('4'),
FIVE('5'),
SIX('6'),
SEVEN('7'),
EIGHT('8'),
NINE('9'),
TEN('T'),
JACK('J'),
QUEEN('Q'),
KING(... | 0 | Kotlin | 0 | 0 | 698316da8c38311366ee6990dd5b3e68b486b62d | 3,125 | aoc-kotlin | Apache License 2.0 |
src/day2/Day02.kt | AhmedAshour | 574,898,033 | false | {"Kotlin": 4639} | package day2
import readInput
fun main() {
val input = readInput("src/day2", "input").toString()
val formattedInput = input.trim { it == '[' || it == ']' }.split(",").map { it.trim() }
println(partOne(formattedInput))
println(partTwo(formattedInput))
}
fun partOne(input: List<String>): Int {
//... | 0 | Kotlin | 0 | 0 | 59b9e895649858de0b95fa2e6eef779bc0d8b45c | 2,229 | adventofcode-2022 | Apache License 2.0 |
src/Day03.kt | coolcut69 | 572,865,721 | false | {"Kotlin": 36853} | fun main() {
val scores = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun part1(inputs: List<String>): Int {
var score = 0
for (rucksack in inputs) {
val chunked = rucksack.chunked(rucksack.length / 2)
val firstCompartment = chunked.first()
val sec... | 0 | Kotlin | 0 | 0 | 031301607c2e1c21a6d4658b1e96685c4135fd44 | 1,243 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day21/Day21.kt | davidcurrie | 579,636,994 | false | {"Kotlin": 52697} | package day21
import java.io.File
import kotlin.math.roundToLong
fun main() {
val input = File("src/day21/input.txt").readLines()
.map { it.split(": ") }
.associate { it[0] to it[1] }
println(part1(input, "root"))
input["root"]!!.split(" ").let {
val lhs = part2(input, it[0])
... | 0 | Kotlin | 0 | 0 | 0e0cae3b9a97c6019c219563621b43b0eb0fc9db | 2,391 | advent-of-code-2022 | MIT License |
src/Day03/Day03.kt | rooksoto | 573,602,435 | false | {"Kotlin": 16098} | package Day03
import profile
import readInputActual
import readInputTest
private const val DAY = "Day03"
private const val UPPERCASE_BASELINE = 38
private const val LOWERCASE_BASELINE = 96
fun main() {
fun part1(
input: List<String>
): Int = input.map(::toCharArrayPair)
.map(::toIntersectedCh... | 0 | Kotlin | 0 | 1 | 52093dbf0dc2f5f62f44a57aa3064d9b0b458583 | 1,697 | AoC-2022 | Apache License 2.0 |
src/main/kotlin/problems/Day5.kt | PedroDiogo | 432,836,814 | false | {"Kotlin": 128203} | package problems
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
class Day5(override val input: String) : Problem {
override val number: Int = 5
private val lines = input.lines().map { line -> Line.fromStr(line) }
override fun runPartOne(): String {
val straightLines = lines.... | 0 | Kotlin | 0 | 0 | 93363faee195d5ef90344a4fb74646d2d26176de | 2,073 | AdventOfCode2021 | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.