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/main/kotlin/se/brainleech/adventofcode/aoc2021/Aoc2021Day02.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2021 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readLines import se.brainleech.adventofcode.verify class Aoc2021Day02 { companion object { private const val COMMAND_DATA_SEPARATOR = " " } data class Command(val direction: Str...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
2,004
adventofcode
MIT License
src/main/kotlin/cz/tomasbublik/Day04.kt
tomasbublik
572,856,220
false
{"Kotlin": 21908}
package cz.tomasbublik fun main() { fun createPairsStructure(input: List<String>): ArrayList<Pair<IntRange, IntRange>> { val duals = ArrayList<Pair<IntRange, IntRange>>() for (line in input) { val firstRange = line.split(",")[0].split("-")[0].toInt()..line.split(",")[0].split("-")[1].to...
0
Kotlin
0
0
8c26a93e8f6f7ab0f260c75a287608dd7218d0f0
2,266
advent-of-code-kotlin-2022
Apache License 2.0
src/jvmMain/kotlin/day05/initial/Day05.kt
liusbl
726,218,737
false
{"Kotlin": 109684}
package day05.initial import util.add import util.updateLast import java.io.File fun main() { // Overslept and started at 07:43 // solvePart1() // Solution: 340994526, at 08:49 solvePart2() // Solution: } /** * seed-to-soil map: 52 50 48 50 98 2 0 -> 0 <-- key point (unmarked) 1 -> 1 .. 49 -> 49 50 -> 5...
0
Kotlin
0
0
1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1
16,986
advent-of-code
MIT License
src/day08/Day08.kt
TheRishka
573,352,778
false
{"Kotlin": 29720}
package day08 import readInput fun main() { val input = readInput("day08/Day08") val matrixInput = arrayListOf<Int>() input.forEach { it.forEach { treeAsChar -> matrixInput.add(treeAsChar.digitToInt()) } } val matrixCols = input[0].length val matrixRows = input.si...
0
Kotlin
0
1
54c6abe68c4867207b37e9798e1fdcf264e38658
5,079
AOC2022-Kotlin
Apache License 2.0
src/Day19.kt
greg-burgoon
573,074,283
false
{"Kotlin": 120556}
import kotlin.collections.HashMap fun main() { var priorityValues = HashMap<Char, Int>() var count = 1 for(c in 'a'..'z') { priorityValues.put(c, count) count++ } for(c in 'A'..'Z') { priorityValues.put(c, count) count++ } fun part1(input: String): Int {...
0
Kotlin
0
1
74f10b93d3bad72fa0fc276b503bfa9f01ac0e35
1,329
aoc-kotlin
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem87/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem87 /** * LeetCode page: [87. Scramble String](https://leetcode.com/problems/scramble-string/); */ class Solution { /* Complexity: * Time O(N^4) and Space O(N^3) where N is the length of s1 and s2; */ fun isScramble(s1: String, s2: String): Boolean { val...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
3,173
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/Day16.kt
Yeah69
317,335,309
false
{"Kotlin": 73241}
class Day16 : Day() { override val label: String get() = "16" private val ruleRegex: Regex = """^(.+): ([0-9]+)-([0-9]+) or ([0-9]+)-([0-9]+)$""".toRegex() data class Rule(val fieldName: String, val firstRange: IntRange, val secondRange: IntRange){ fun valid(fieldValue: Int): Boolean = ...
0
Kotlin
0
0
23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec
2,509
AdventOfCodeKotlin
The Unlicense
solutions/aockt/y2015/Y2015D24.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import io.github.jadarma.aockt.core.Solution object Y2015D24 : Solution { /** * Returns a sequence of all combinations of size [take] from the initial list. * This is a refactor of a Rosetta Code snippet, available at [https://rosettacode.org/wiki/Combinations#Kotlin]. * TODO: ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,234
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/Day10.kt
brigham
573,127,412
false
{"Kotlin": 59675}
sealed class Ins object NoopIns: Ins() data class AddxIns(val add: Int): Ins() fun main() { fun parse(input: List<String>): List<Ins> = input.map { it.split(" ") } .map { when (it[0]) { "noop" -> NoopIns "addx" -> AddxIns(it[1].toInt()) else -> ...
0
Kotlin
0
0
b87ffc772e5bd9fd721d552913cf79c575062f19
2,931
advent-of-code-2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions14.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test14() { printlnResult("ac", "dgcaf") printlnResult("tops", "tuacstopszpxm") printlnResult("ac", "dgccaaf") printlnResult("tops", "tuacstotpzpxm") printlnResult("tops", "pots") printlnResult("tops", "potp") } /** * Questions 14: Judge whether a st...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,310
Algorithm
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2020/Day21.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver /** * --- Day 21: Allergen Assessment --- * https://adventofcode.com/2020/day/21 */ class Day21 : Solver { override fun solve(lines: List<String>): Result { val foods = lines.map { parseLine(it) } // Allergen --> the ingr...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,556
euler
Apache License 2.0
src/Day05.kt
AlexeyVD
575,495,640
false
{"Kotlin": 11056}
fun main() { fun part1(input: List<String>): String { return process(input, CrateMover9000(input.getBucketsNumber())) } fun part2(input: List<String>): String { return process(input, CrateMover9001(input.getBucketsNumber())) } val testInput = readInput("Day05_test") check(part1...
0
Kotlin
0
0
ec217d9771baaef76fa75c4ce7cbb67c728014c0
3,387
advent-kotlin
Apache License 2.0
src/main/kotlin/day05/Day05.kt
mdenburger
433,731,891
false
{"Kotlin": 8573}
package day05 import java.io.File fun main() { val lines: List<Line> = File("src/main/kotlin/day05/day05-input.txt") .readLines() .map { it.split(" -> ") } .map { Line(it.first().asPoint(), it.last().asPoint()) } println("Part 1: " + countOverlappingPoints(lines.filter { it.isHorizont...
0
Kotlin
0
0
e890eec2acc2eea9c0432d092679aeb9de3f51b4
1,456
aoc-2021
MIT License
src/Day11.kt
iownthegame
573,926,504
false
{"Kotlin": 68002}
import kotlin.math.floor class Inspection(val monkeyIndex: Int, private val operation: String, val divisibleByValue: Int, private val throwToMonkeys: Array<Int>) { var inspectedItemTimes = 0 fun operateItem(worryLevel: Long): Long { // do operation, for example: old * 19, old + 3, old * old va...
0
Kotlin
0
0
4e3d0d698669b598c639ca504d43cf8a62e30b5c
6,507
advent-of-code-2022
Apache License 2.0
src/Day02.kt
KarinaCher
572,657,240
false
{"Kotlin": 21749}
val LOST = 0 val DRAW = 3 val WON = 6 val ROCK = "Rock" val PAPER = "Paper" val SCISSORS = "Scissors" val STRATEGY_LOST = "Lost" val STRATEGY_DRAW = "Draw" val STRATEGY_WON = "Won" fun main() { fun part1(input: List<String>): Int { var round = 1 var reward = 0; for (line in input) { ...
0
Kotlin
0
0
17d5fc87e1bcb2a65764067610778141110284b6
2,824
KotlinAdvent
Apache License 2.0
untitled/src/main/kotlin/Day11-alt.kt
jlacar
572,845,298
false
{"Kotlin": 41161}
import java.math.BigInteger val sample = InputReader("Day11-sample.txt").lines val input = InputReader("Day11-alt.txt").lines val monkeys = parse(input) val bigModulo: BigInteger = monkeys.map { it.modulo }.fold(BigInteger.ONE) { acc, prime -> acc.multiply(prime) } //.also { println("bigModulo $it") } fun parse(...
0
Kotlin
0
2
dbdefda9a354589de31bc27e0690f7c61c1dc7c9
2,587
adventofcode2022-kotlin
The Unlicense
Advent-of-Code-2023/src/Day03.kt
Radnar9
726,180,837
false
{"Kotlin": 93593}
private const val AOC_DAY = "Day03" private const val PART1_TEST_FILE = "${AOC_DAY}_test_part1" private const val PART2_TEST_FILE = "${AOC_DAY}_test_part2" private const val INPUT_FILE = AOC_DAY /** * Find and sum up the numbers adjacent, including diagonal ones, to any symbol different from '.'. * Starts by findin...
0
Kotlin
0
0
e6b1caa25bcab4cb5eded12c35231c7c795c5506
6,023
Advent-of-Code-2023
Apache License 2.0
tasks-2/lib/src/main/kotlin/trees/utils/DisjointSet.kt
AzimMuradov
472,473,231
false
{"Kotlin": 127576}
package trees.utils /** * Disjoint Set * * In computer science, a disjoint-set data structure, also called a [union]–[find] data structure or merge–find set, is a data structure that stores a collection of disjoint (non-overlapping) sets. * Equivalently, it stores a partition of a set into disjoint subsets. */ in...
0
Kotlin
0
0
01c0c46df9dc32c2cc6d3efc48b3a9ee880ce799
1,509
discrete-math-spbu
Apache License 2.0
src/Day03.kt
cgeesink
573,018,348
false
{"Kotlin": 10745}
fun main() { fun part1(input: List<String>): Int = input.map { rucksack -> rucksack.substring(0 until rucksack.length / 2).toCharArray() to rucksack.substring(rucksack.length / 2).toCharArray() }.flatMap { (first, second) -> first intersect second.toSet() }.map { item -> item.toScore() }...
0
Kotlin
0
0
137fb9a9561f5cbc358b7cfbdaf5562c20d6b10d
1,079
aoc-2022-in-kotlin
Apache License 2.0
src/Day14.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
fun markRocks(input: List<String>): MutableSet<Pair<Int, Int>> { val result = mutableSetOf<Pair<Int, Int>>() for (line in input) { val corners = line.split("->").map { it.trim() } for (i in 1 until corners.size) { val (ax, ay) = corners[i - 1].split(",").map { it.toInt() } ...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
2,224
Advent-Of-Code-2022
Apache License 2.0
kotlin/kotlin-by-example/std-lib/collections.kts
JafarSadik
117,316,387
false
{"Scala": 647948, "Java": 100704, "JavaScript": 43562, "Kotlin": 28712, "Groovy": 21124, "HTML": 16067, "Ruby": 4083, "CSS": 2531, "Shell": 2174, "SuperCollider": 961, "Dockerfile": 258}
import kotlin.math.max // Higher Order Functions that are frequently used with collections. // map can be used to transform collection into another collection val numbers = listOf(-2, -1, 0, 1, 2) check(numbers.map { it * 2 } == listOf(-4, -2, 0, 2, 4)) // flatmap maps each element into a list and flattens the resul...
2
Scala
1
0
e6e02a214f973494004e1ab3d80254455c936918
3,651
code-lab
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day18.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 class Day18(private val input: List<String>) { fun solvePart1(): Long { return solve(listOf(setOf(Token.Plus, Token.Multiply))) } fun solvePart2(): Long { return solve(listOf(setOf(Token.Plus), setOf(Token.Multiply))) } private fun solve(oper...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
3,063
advent-of-code
Apache License 2.0
leetcode2/src/leetcode/IntersectionOfTwoArraysII.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 两个数组的交集 II * https://leetcode-cn.com/problems/intersection-of-two-arrays-ii/ * Created by test * Date 2019/5/23 0:51 * Description * 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2,2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [4,9] 说...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,913
leetcode
MIT License
src/main/kotlin/aoc2020/day10/Joltage.kt
arnab
75,525,311
false
null
package aoc2020.day10 object Joltage { fun parse(data: String): List<Int> = data.split("\n").map { it.toInt() } fun arrange(adapters: List<Int>): List<Int> { val sorted = adapters.sorted() return sorted + listOf(sorted.maxOrNull()!! + 3) } fun calculateDiffs(chain: List<Int>): List<In...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
1,904
adventofcode
MIT License
src/main/kotlin/day02/Day02.kt
dustinconrad
572,737,903
false
{"Kotlin": 100547}
package day02 import readResourceAsBufferedReader fun main() { println("part 1: ${part1(readResourceAsBufferedReader("2_1.txt").readLines())}") println("part 2: ${part2(readResourceAsBufferedReader("2_1.txt").readLines())}") } fun part1(input: List<String>): Int { return input.map { parseRoundPart1(it) }...
0
Kotlin
0
0
1dae6d2790d7605ac3643356b207b36a34ad38be
2,197
aoc-2022
Apache License 2.0
src/main/kotlin/com/sk/topicWise/slidingwindow/hard/76. Minimum Window Substring.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.slidingwindow.hard class Solution76 { fun minWindow(s: String, t: String): String { if (s.length < t.length) return "" val dict = t.toCharArray().groupBy { it }.mapValues { it.value.size }.toMutableMap() val required = dict.size var l = 0 var r = 0 ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,238
leetcode-kotlin
Apache License 2.0
src/main/kotlin/tw/gasol/aoc/aoc2022/Day12.kt
Gasol
574,784,477
false
{"Kotlin": 70912, "Shell": 1291, "Makefile": 59}
package tw.gasol.aoc.aoc2022 import java.lang.Exception import java.util.* import kotlin.Comparator import kotlin.math.abs enum class NodeType { Unspecific, Start, Goal } data class Node(val x: Int, val y: Int, val z: Int, val type: NodeType) { fun distanceTo(other: Node): Int { return abs(x - other.x) + ...
0
Kotlin
0
0
a14582ea15f1554803e63e5ba12e303be2879b8a
6,150
aoc2022
MIT License
src/main/kotlin/Day15.kt
clechasseur
267,632,210
false
null
object Day15 { private val input = Sculpture(listOf( Disc(17, 1), Disc(7, 0), Disc(19, 2), Disc(5, 0), Disc(3, 0), Disc(13, 5) ), -1, 0) fun part1(): Int = generateSequence(input) { it.moveWithNewBall() }.first { ballPassesThrough(it) }.t fun part2(): In...
0
Kotlin
0
0
120795d90c47e80bfa2346bd6ab19ab6b7054167
1,445
adventofcode2016
MIT License
kotlin/src/katas/kotlin/palindromes/Palindromes.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.palindromes import datsok.shouldEqual import org.junit.Test class Palindromes { @Test fun `palindrome example from the task`() { findLongestPalindromes("sqrrqabccbatudefggfedvwhijkllkjihxymnnmzpop") shouldEqual listOf( Palindrome("hijkllkjih", IntRange(23, 32)), ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,558
katas
The Unlicense
src/main/kotlin/Day17.kt
andrewrlee
434,584,657
false
{"Kotlin": 29493, "Clojure": 14117, "Shell": 398}
object Day17 { // val targetArea = 20..30 to -10..-5 val targetArea = 248..285 to -85..-56 data class Coord(val x: Int, val y: Int) { constructor(coord: Pair<Int, Int>) : this(coord.first, coord.second) } private fun Pair<IntRange, IntRange>.toCoords(): List<Coord> { val (xs, ys) =...
0
Kotlin
0
0
aace0fccf9bb739d57f781b0b79f2f3a5d9d038e
2,974
adventOfCode2021
MIT License
src/Day05.kt
Sghazzawi
574,678,250
false
{"Kotlin": 10945}
import java.util.* data class CraneCommand(val quantity: Int, val from: Int, val to: Int) fun MutableMap<Int, Stack<Char>>.processCraneCommand(command: CraneCommand): MutableMap<Int, Stack<Char>> { val fromStack = get(command.from) val toStack = get(command.to) for (i in 0 until command.quantity) { ...
0
Kotlin
0
0
a26111fa1bcfec28cc43a2f48877455b783acc0d
3,330
advent-of-code-kotlin
Apache License 2.0
src/Day15.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
data class Sensor( val x: Int, val y: Int, val beaconX: Int, val beaconY: Int ) { internal val dX = Math.abs(x - beaconX) internal val dY = Math.abs(y - beaconY) fun isInRange(posX: Int, posY: Int): Boolean { return posX in (x - dX)..(x + dX) && posY in (y - dY)..(y + dY...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
3,195
KotlinAdventOfCode2022
Apache License 2.0
kotlin/1048-longest-string-chain.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
//dfs class Solution { fun longestStrChain(words: Array<String>): Int { val wordList = words.toHashSet() val dp = HashMap<String, Int>() fun dfs(word: String, len: Int): Int { if (word !in wordList) return 0 if ("$word:$len" in dp) return dp["$word:$len"]!! ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,397
leetcode
MIT License
algorithms/src/main/kotlin/io/nullables/api/playground/algorithms/QuadNode.kt
AlexRogalskiy
331,076,596
false
null
/* * Copyright (C) 2021. <NAME>. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applic...
13
Kotlin
2
2
d7173ec1d9ef227308d926e71335b530c43c92a8
3,158
gradle-kotlin-sample
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2021/Day24.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2021 import me.grison.aoc.* /** * Solved it manually exactly like Day 23, with some more luck involved. * Solution is based on the brilliant explanation you'll find here: * https://github.com/dphilipson/advent-of-code-2021/blob/master/src/days/day24.rs */ class Day24 : Day(24, 2021) { o...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
2,201
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/bogwalk/batch5/Problem52.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import kotlin.math.pow /** * Problem 52: Permuted Multiples * * https://projecteuler.net/problem=52 * * Goal: Find all positive integers, x <= N, such that all requested multiples (x, 2x, ..., Kx) * are a permutation of x. * * Constraints: 125_875 <= N <= 2e6, 2 <= K <= 6 * * e.g....
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,212
project-euler-kotlin
MIT License
src/Day17.kt
fercarcedo
573,142,185
false
{"Kotlin": 60181}
private const val CHAMBER_WIDTH = 7 private const val MAX_ROCKS_PART_ONE = 2022L private const val MAX_ROCKS_PART_TWO = 1000000000000L enum class RockType { HORIZONTAL_LINE { override fun getPoints(bottomLeftPosition: Pair<Long, Long>): List<Pair<Long, Long>> { return (bottomLeftPosition.first ...
0
Kotlin
0
0
e34bc66389cd8f261ef4f1e2b7f7b664fa13f778
6,820
Advent-of-Code-2022-Kotlin
Apache License 2.0
jvm/src/main/kotlin/io/prfxn/aoc2021/day04.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// Giant Squid (https://adventofcode.com/2021/day/4) package io.prfxn.aoc2021 fun main() { val maxRows = 5 val maxCols = 5 val (numbersToDraw, boards) = textResourceReader("input/04.txt").useLines { lineSeq -> val lineIter = lineSeq.iterator() val numbersToDraw = lineIte...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
3,328
aoc2021
MIT License
src/cn/leetcode/codes/simple16/Simple16.kt
shishoufengwise1234
258,793,407
false
{"Java": 771296, "Kotlin": 68641}
package cn.leetcode.codes.simple16 import cn.leetcode.codes.out import java.util.* import kotlin.math.abs fun main() { val nums = intArrayOf(-1,2,1,-4) val re = threeSumClosest(nums,2) out("re = $re") } /* 16. 最接近的三数之和 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定...
0
Java
0
0
f917a262bcfae8cd973be83c427944deb5352575
1,465
LeetCodeSimple
Apache License 2.0
src/Day09.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
import kotlin.math.absoluteValue import kotlin.math.sign data class RopeKnot(var x: Int = 0, var y: Int = 0) fun main() { fun updatePlaces(head: RopeKnot, tail: RopeKnot) { val horizontalDistance = tail.x - head.x val verticalDistance = tail.y - head.y if (horizontalDistance.absoluteValue...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
1,947
aoc-2022-kotlin
Apache License 2.0
03-problems-lab1/src/main/kotlin/Main.kt
iproduct
277,474,020
false
{"JavaScript": 3237497, "Kotlin": 545267, "Java": 110766, "HTML": 83688, "CSS": 44893, "SCSS": 32196, "Dockerfile": 58}
import java.io.File data class LongNumberProblem( var n: Int, var a: String, var fm: List<Int>, ) fun main(args: Array<String>) { // read input // val n = readLine()!!.toInt() // val a = readLine()!! // val fm = readLine()!!.split(" ").map { it.toInt() } // read input from file // Us...
0
JavaScript
1
4
89884f8c29fffe6c6f0384a49ae8768c8e7ab509
1,805
course-kotlin
Apache License 2.0
src/questions/ReorderList.kt
realpacific
234,499,820
false
null
package questions import questions.common.LeetNode import utils.assertIterableSame import java.util.* /** * You are given the head of a singly linked-list. The list can be represented as `L0 → L1 → … → Ln - 1 → Ln` * * Reorder the list to be on the following form: `L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …` * You m...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
4,898
algorithms
MIT License
src/main/kotlin/Day1.kt
ummen-sherry
726,250,829
false
{"Kotlin": 4811}
import java.io.File private val numberRegex = Regex("""(\d|one|two|three|four|five|six|seven|eight|nine)""") private val numberReverseRegex = Regex("""(\d|enin|thgie|neves|xis|evif|ruof|eerht|owt|eno)""") private val validNumbers = mapOf( "1" to 1, "2" to 2, "3" to 3, "4" to 4, "5" to 5, "6" t...
0
Kotlin
0
0
c91c1b606a17a00e9efa5f2139d0efd0c1270634
1,771
adventofcode2023
MIT License
src/main/kotlin/days/Day13.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import util.Utils class Day13 : Day(13) { private val dots = inputList.takeWhile { it != "" }.map { it.split(",").map { it.toInt() } }.map { Utils.Coord(it[0], it[1]) } private val folds = inputList.takeLastWhile { it != "" }.map { it.dropWhile { it != 'x' && it != 'y' }.split("=") }.map { it[0...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
1,773
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day14.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.Day fun main() = Day14.run() object Day14 : Day(2021, 14) { private val template = input.lines()[0] private val inserts = input.lines().drop(2).map { it.split("->") }.associate { it[0].trim() to it[1].trim() } override fun part1(): Any { ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,650
adventofkotlin
MIT License
src/day16/b/day16b.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day16.b import day16.a.Valve import day16.a.read import day16.a.simplifyGraph import shouldBe import kotlin.math.max fun main() { val graph = simplifyGraph(read()) val start = graph["AA"]!!.value var best = 0 // The sum of the rates of unused valves is tracked to estimate the best case of th...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,094
advent-of-code-2022
Apache License 2.0
src/Day05.kt
kecolk
572,819,860
false
{"Kotlin": 22071}
fun main() { data class Move(val count: Int, val from: Int, val to: Int) fun extractStacks(input: List<String>): List<ArrayDeque<Char>> { val result = MutableList<ArrayDeque<Char>>(9) { ArrayDeque() } input.forEach { line -> if (line.isEmpty() || !line.contains("[")) return result ...
0
Kotlin
0
0
72b3680a146d9d05be4ee209d5ba93ae46a5cb13
2,332
kotlin_aoc_22
Apache License 2.0
src/main/kotlin/adventofcode/year2022/Day11MonkeyInTheMiddle.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2022 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.product class Day11MonkeyInTheMiddle(customInput: PuzzleInput? = null) : Puzzle(customInput) { override val name = "Monkey in the Middle" override fun partOne() = input .parseMonkeys() ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,889
AdventOfCode
MIT License
src/main/kotlin/y2023/day01/Day01.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2023.day01 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } fun input(): List<String> { return AoCGenerics.getInputLines("/y2023/day01/input.txt") } fun part1(): Int { return input().sumOf { val first = it.first { char -> ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,233
AdventOfCode
MIT License
src/Day14.kt
kmes055
577,555,032
false
{"Kotlin": 35314}
class Move( val type: String, val point: Int, val range: IntRange ) { private val isHorizon = type == "HORIZON" val points: List<Pair<Int, Int>> get() { return if (this.isHorizon) range.map { Pair(it, point) } else range.map { Pair(point, it) } } companio...
0
Kotlin
0
0
84c2107fd70305353d953e9d8ba86a1a3d12fe49
4,498
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/github/dangerground/aoc2020/Day7.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput class Day7(input: List<String>) { private val bagrules = input.map { BagRule(it) }.map { it.color to it.innerBags }.toMap() fun getInnerBagCount(color: BagColor): Int { var total = bagrules[color]!!.entries....
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
1,877
adventofcode-2020
MIT License
2021/src/test/kotlin/Day15.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import java.lang.IllegalStateException import java.util.PriorityQueue import kotlin.test.Test import kotlin.test.assertEquals class Day15 { data class Coord(val x: Int, val y: Int) private val directions = listOf(Coord(1, 0), Coord(0, 1), Coord(-1, 0), Coord(0, -1)) @Test fun `run part 01`() { ...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
3,141
adventofcode
MIT License
src/Day04.kt
becsegal
573,649,289
false
{"Kotlin": 9779}
import java.io.File fun main() { // assumes sorted fun List<Int>.fullyContains(innerList: List<Int>): Boolean { return this.first() <= innerList.first() && this.last() >= innerList.last() } // assumes sorted fun List<Int>.overlaps(otherList: List<Int>): Boolean { return (this.firs...
0
Kotlin
0
0
a4b744a3e3c940c382aaa1d5f5c93ae0df124179
1,365
advent-of-code-2022
Apache License 2.0
Factorization.kt
kokic
563,806,758
false
{"Kotlin": 3604}
import java.math.BigInteger fun main(args: Array<String>) { val m = (1003917294).toBigInteger() println(Factorization.factor(m)) } fun Integer.isPrime(): Boolean { if (this < BigInteger.TWO) return false var i = BigInteger.TWO while (i.multiply(i) <= this) if (mod(i++) == BigInteger.ZERO)...
0
Kotlin
0
0
6b69f097a86eb488baf70537c52862f6391d30a4
1,832
potos-flavus
MIT License
src/main/kotlin/com/scavi/brainsqueeze/adventofcode/Day18OperationOrder.kt
Scavi
68,294,098
false
{"Java": 1449516, "Kotlin": 59149}
package com.scavi.brainsqueeze.adventofcode class Day18OperationOrder { private val formulaPattern = """(\d+\s+)([*+])(\s+\d+)""".toRegex() private val parenthesesPattern = """\(\d+\s+[*+]\s+[\d+|\d+\s+\[*\]\s+\d+]+\)""".toRegex() private val arithmeticPatternA = """^(\d+\s+[*+]\s+\d+)""".toRegex() pri...
0
Java
0
1
79550cb8ce504295f762e9439e806b1acfa057c9
2,441
BrainSqueeze
Apache License 2.0
src/Day25.kt
adrianforsius
573,044,406
false
{"Kotlin": 68131}
import org.assertj.core.api.Assertions.assertThat fun main() { fun part1(input: List<String>): Int { val lines = input var splitAt = lines .withIndex() .filter { it.value == "" } .map { it.index } splitAt = listOf(0) + splitAt splitAt = splitAt +...
0
Kotlin
0
0
f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb
1,860
kotlin-2022
Apache License 2.0
src/Day02.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
fun main() { fun part1(games: List<Pair<Int, Int>>) = games.sumOf { (opponent, me) -> val shapeScore = me + 1 val gameScore = if (me - opponent == 1 || me - opponent == -2) 6 else if (me == opponent) 3 else 0 shapeScore + gameScore } fun part2(games: List<Pai...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
841
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day11/Day11Puzzle.kt
Any1s
433,954,562
false
{"Kotlin": 96683}
package de.mbdevelopment.adventofcode.year2021.solvers.day11 import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver abstract class Day11Puzzle : PuzzleSolver { final override fun solve(inputLines: Sequence<String>) = simulate( inputLines.map { row -> row.map { it.digitToInt() } } ...
0
Kotlin
0
0
21d3a0e69d39a643ca1fe22771099144e580f30e
2,150
AdventOfCode2021
Apache License 2.0
2022/src/test/kotlin/Day07.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe class Day07 : StringSpec({ "puzzle part 01" { val sumOfAtMost10K = getDirectorySizes() .filterValues { it <= 100000 } .values.sum() sumOfAtMost10K shouldBe 1778099 } "puzzle part 02" { ...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,619
adventofcode
MIT License
src/main/kotlin/dev/bogwalk/batch2/Problem27.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import dev.bogwalk.util.maths.isPrime import dev.bogwalk.util.maths.primeNumbers /** * Problem 27: Quadratic Primes * * https://projecteuler.net/problem=27 * * Goal: Find coefficients a & b for the quadratic expression that produces the maximum number of * primes for consecutive value...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,015
project-euler-kotlin
MIT License
Collections/FlatMap/src/Task.kt
diskostu
554,658,487
false
{"Kotlin": 36179}
// Return all products the given customer has ordered fun Customer.getOrderedProducts(): List<Product> = orders.flatMap { it.products } // Return all products that were ordered by at least one customer fun Shop.getOrderedProducts(): Set<Product> = customers.flatMap { it.orders }.flatMap { it.products }.toSet()...
0
Kotlin
0
0
3cad6559e1add8d202e15501165e2aca0ee82168
1,689
Kotlin_Koans
MIT License
2017/src/main/kotlin/Day21.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import utils.splitNewlines import utils.splitWhitespace import kotlin.math.sqrt object Day21 { /* * Note to self: I setup pattern matching as a single row, where each cell is represented thus: * * 2x2 * 01 * 23 * * 3x3 * 012 * 345 * 678 */ private val START = listOf( f...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
3,356
advent-of-code
MIT License
leetcode/src/offer/Q001.kt
zhangweizhe
387,808,774
false
null
package offer fun main() { // 剑指 Offer II 001. 整数除法 // https://leetcode-cn.com/problems/xoh6Oh/ println(divide(Int.MAX_VALUE, Int.MIN_VALUE)) println(divide1(Int.MAX_VALUE, Int.MIN_VALUE)) } private fun divide(a: Int, b: Int): Int { if (a == Int.MIN_VALUE && b == -1) { // MIN_VALUE = -214...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,636
kotlin-study
MIT License
2021/src/main/kotlin/de/skyrising/aoc2021/day5/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day5 import de.skyrising.aoc.* fun coord(s: String): Pair<Int, Int> { val (x, y) = s.split(',') return x.toInt() to y.toInt() } val test = TestInput(""" 0,9 -> 5,9 8,0 -> 0,8 9,4 -> 3,4 2,2 -> 2,1 7,0 -> 7,4 6,4 -> 2,0 0,9 -> 2,9 3,4 -> 1,4 0,0...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,233
aoc
MIT License
src/leetcodeProblem/leetcode/editor/en/MinimumValueToGetPositiveStepByStepSum.kt
faniabdullah
382,893,751
false
null
//Given an array of integers nums, you start with an initial positive value //startValue. // // In each iteration, you calculate the step by step sum of startValue plus //elements in nums (from left to right). // // Return the minimum positive value of startValue such that the step by step //sum is never less than ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
3,053
dsa-kotlin
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2018/Day13.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2018 import se.saidaspen.aoc.util.* fun main() = Day13.run() object Day13 : Day(2018, 13) { private val map = toMap(input) private var carts = mutableListOf<Cart>() init { map.entries.filter { it.value in mutableListOf('v', '^', '<', '>') } .map { Cart(i...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
3,523
adventofkotlin
MIT License
src/y2015/Day05.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput object Day05 { fun part1(input: List<String>): Int { val nice = input.filter { hasVowels(it) }.filter { hasDouble(it) }.filter { !hasNaughty(it) } return nice.size } private fun hasVowels(strin...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,664
advent-of-code
Apache License 2.0
year2022/src/main/kotlin/net/olegg/aoc/year2022/day14/Day14.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day14 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.D import net.olegg.aoc.utils.Directions.DL import net.olegg.aoc.utils.Directions.DR import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.get import net.olegg.aoc.utils.parseInts import net.olegg.ao...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,596
adventofcode
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem934/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem934 /** * LeetCode page: [934. Shortest Bridge](https://leetcode.com/problems/shortest-bridge/); */ class Solution { /* Complexity: * Time O(N) and Space O(N) where N is the number of cells in grid; */ fun shortestBridge(grid: Array<IntArray>): Int { va...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
4,042
hj-leetcode-kotlin
Apache License 2.0
src/Day02.kt
bendh
573,833,833
false
{"Kotlin": 11618}
fun main() { val scoreMap = mapOf( "A X" to 4, "B Y" to 5, "C Z" to 6, "C X" to 7, "A Y" to 8, "B Z" to 9, "A Z" to 3, "B X" to 1, "C Y" to 2) fun part1(input: List<String>): Int { return input.sumOf { scoreMap.getOrDefault(it, 0)...
0
Kotlin
0
0
e3ef574441b63a99a99a095086a0bf025b8fc475
893
advent-of-code-2022-kotlin
Apache License 2.0
advent-of-code-2022/src/Day20.kt
osipxd
572,825,805
false
{"Kotlin": 141640, "Shell": 4083, "Scala": 693}
fun main() { val testInput = readInput("Day20_test") val input = readInput("Day20") "Part 1" { part1(testInput) shouldBe 3 measureAnswer { part1(input) } } "Part 2" { part2(testInput) shouldBe 1623178306 measureAnswer { part2(input) } } } private fun part1(inpu...
0
Kotlin
0
5
6a67946122abb759fddf33dae408db662213a072
1,243
advent-of-code
Apache License 2.0
src/aoc2022/day20/aoC20.kt
Saxintosh
576,065,000
false
{"Kotlin": 30013}
package aoc2022.day20 import readLines data class Node(val value: Long) { var prev = this var next = this fun addAfter(n1: Node) { this.next = n1.next this.prev = n1 n1.next.prev = this n1.next = this } fun remove() { this.prev.next = this.next this.next.prev = this.prev } fun next(times: Int): ...
0
Kotlin
0
0
877d58367018372502f03dcc97a26a6f831fc8d8
2,218
aoc2022
Apache License 2.0
src/main/kotlin/day2.kt
gautemo
572,204,209
false
{"Kotlin": 78294}
import shared.getText fun main() { val input = getText("day2.txt") println(day2A(input)) println(day2B(input)) } fun day2A(input: String): Int{ val rounds = input.lines().map { val pair = it.split(" ") val opponent = when(pair[0]) { "A" -> Rock() "B" -> Paper() ...
0
Kotlin
0
0
bce9feec3923a1bac1843a6e34598c7b81679726
2,664
AdventOfCode2022
MIT License
src/main/kotlin/dev/bogwalk/batch0/Problem5.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch0 import dev.bogwalk.util.maths.gcd import dev.bogwalk.util.maths.lcm import dev.bogwalk.util.maths.primeNumbers import kotlin.math.abs import kotlin.math.log2 import kotlin.math.pow /** * Problem 5: Smallest Multiple * * https://projecteuler.net/problem=5 * * Goal: Find the smallest pos...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,558
project-euler-kotlin
MIT License
src/Day25.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
import java.math.BigInteger fun main() { fun parseNum(line: String): Long { var num = 0L var multiplier = 1L for (ch in line.reversed()) { num += when (ch) { '2' -> 2L * multiplier '1' -> 1L * multiplier '0' -> 0L ...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
1,910
aoc22
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/StickersToSpellWord.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,407
kotlab
Apache License 2.0
app/src/main/kotlin/aoc2022/day07/Day07.kt
dbubenheim
574,231,602
false
{"Kotlin": 18742}
package aoc2022.day07 import aoc2022.day07.Day07.ResourceType.DIRECTORY import aoc2022.day07.Day07.ResourceType.FILE import aoc2022.day07.Day07.part1 import aoc2022.day07.Day07.part2 import aoc2022.toFile import java.util.UUID object Day07 { fun part1(): Long { val root = Directory(id = newId(), name = "/...
8
Kotlin
0
0
ee381bb9820b493d5e210accbe6d24383ae5b4dc
3,600
advent-of-code-2022
MIT License
src/main/kotlin/days/aoc2021/Day20.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2021 import days.Day class Day20 : Day(2021, 20) { override fun partOne(): Any { val (algorithm, image) = parseInput(inputList) return countLightPixels(image.enhance(algorithm, 2)) } override fun partTwo(): Any { val (algorithm, image) = parseInput(inputList) ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,668
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day12.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 import kotlin.math.min /** * https://adventofcode.com/2022/day/12 */ class Day12(override val input: String) : Day() { override fun part1(): String { val grid = Grid.fromChars(input) { it } val start = grid.enumeratePoints().first { grid[it] == 'S' } val ...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
2,476
adventofcode2022
MIT License
day13/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File fun main() { val input = readInputFile() println("Part I: the solution is ${runPartI(input)}.") println("Part II: the solution is ${runPartII(input)}.") } fun readInputFile(): List<String> { return File(ClassLoader.getSystemResource("input.txt").file).readLines() } fun runPartI(i...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
6,728
AdventOfCode2018
MIT License
src/main/kotlin/ru/timakden/aoc/year2023/Day08.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2023 import ru.timakden.aoc.util.lcm import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 8: <NAME>](https://adventofcode.com/2023/day/8). */ object Day08 { @JvmStatic fun main(args: Array<String>) { measure { val input = readIn...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,278
advent-of-code
MIT License
src/Day04.kt
ChenJiaJian96
576,533,624
false
{"Kotlin": 11529}
fun main() { fun List<String>.checkIfFullyOverlap(): Boolean { val firstPair = get(0).split('-').run { get(0).toInt() to get(1).toInt() } val secondPair = get(1).split('-').run { get(0).toInt() to get(1).toInt() } return firstPair.first <= secondPair.f...
0
Kotlin
0
0
b1a88f437aee756548ac5ba422e2adf2a43dce9f
1,347
Advent-Code-2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day14.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part14A : PartSolution() { private lateinit var template: String private lateinit var rules: Map<String, String> open val numSteps = 10 override fun parseInput(text: String) { ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,421
advent-of-code-kotlin
MIT License
src/Day11.kt
illarionov
572,508,428
false
{"Kotlin": 108577}
import java.io.File data class Monkey( val number: Int, val startingItems: List<Int>, val opp: Op, val test: Int, val testTrueMonkey: Int, val testFalseMonkey: Int ) { fun runTest(level: Long): Int = if (level % test.toLong() == 0L) testTrueMonkey else testFalseMonkey } data class Op( v...
0
Kotlin
0
0
3c6bffd9ac60729f7e26c50f504fb4e08a395a97
5,368
aoc22-kotlin
Apache License 2.0
src/com/mrxyx/algorithm/BFS.kt
Mrxyx
366,778,189
false
null
package com.mrxyx.algorithm import java.util.* import kotlin.collections.HashSet class BFS { /** * 二叉树的最小深度 * https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ */ fun minDepth(root: TreeNode?): Int { if (root == null) return 0 val queue = LinkedList<TreeNode?>() ...
0
Kotlin
0
0
b81b357440e3458bd065017d17d6f69320b025bf
2,644
algorithm-test
The Unlicense
src/2021/Day17_2.kts
Ozsie
318,802,874
false
{"Kotlin": 99344, "Python": 1723, "Shell": 975}
import java.io.File import kotlin.math.absoluteValue import kotlin.math.max class Result(val initVel: Pair<Int,Int>, val maxY: Int, val hit: Boolean) fun shoot(x: Int, y: Int, xRange: IntRange, yRange: IntRange): Result { var maxYPos = Int.MIN_VALUE var localYMax = Int.MIN_VALUE var position = Pair(0,0) ...
0
Kotlin
0
0
d938da57785d35fdaba62269cffc7487de67ac0a
2,099
adventofcode
MIT License
src/Day03.kt
saphcarter
573,329,337
false
null
fun main() { fun priorityCalc(alpha: Char): Int{ return if (alpha.isLowerCase()) { alpha.code - 96 } else alpha.code - 38; } fun part1(input: List<String>): Int { var priority = 0 input.forEach { val inputList = it.toList() val size = inpu...
0
Kotlin
0
0
2037106e961dc58e75df2fbf6c31af6e0f44777f
1,744
aoc-2022
Apache License 2.0
src/Day08/Day08.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day08 import readInput fun findVisibleTrees(treeMatrix: List<List<Int>>): Int { var visibleTrees = HashSet<Pair<Int, Int>>() for (rowIndex in treeMatrix.indices) { processRow(rowIndex, treeMatrix, visibleTrees) } val columnCount = treeMatrix[0].size for(columnIndex in 0..columnC...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
4,862
advent-of-code-2022
Apache License 2.0
src/Day21.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
fun main() { open class Node(val name: String) class ValueNode(name: String, val value: Long) : Node(name) class ExpressionNode( name: String, val left: Node, val right: Node, val operation: (Long, Long) -> Long, val moveRightOperand: (Long, Long) -> Long, val...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
4,565
aoc-2022
Apache License 2.0
src/Day16.kt
thorny-thorny
573,065,588
false
{"Kotlin": 57129}
import kotlin.math.pow data class Valve(val id: String, val rate: Int, val connectedTo: List<String>) { override fun equals(other: Any?): Boolean { return when (other) { is Valve -> id == other.id else -> false } } override fun hashCode(): Int { return id.ha...
0
Kotlin
0
0
843869d19d5457dc972c98a9a4d48b690fa094a6
5,332
aoc-2022
Apache License 2.0
src/Day09.kt
ajmfulcher
573,611,837
false
{"Kotlin": 24722}
data class Instruction( val direction: String, val moves: Int ) fun main() { fun instructions(input: List<String>): ArrayDeque<Instruction> { return ArrayDeque<Instruction>(input.map { val i = it.split(" ") Instruction(i[0], i[1].toInt()) }) } fun Pair<Int...
0
Kotlin
0
0
981f6014b09e347241e64ba85e0c2c96de78ef8a
3,402
advent-of-code-2022-kotlin
Apache License 2.0
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day17/Day17.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2021.day17 import eu.janvdb.aocutil.kotlin.point2d.Point2D import kotlin.math.max import kotlin.math.min //val TARGET = Target(20, 30, -10, -5) val TARGET = Target(155, 182, -117, -67) fun main() { part1() part2() } private fun part1() { var startX = 1 while (true) { val reachedX = startX...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
2,377
advent-of-code
Apache License 2.0
src/main/kotlin/net/hiddevb/advent/advent2019/day08/main.kt
hidde-vb
224,606,393
false
null
package net.hiddevb.advent.advent2019.day08 import net.hiddevb.advent.common.initialize /** * --- Day 8: Space Image Format --- */ private const val WIDTH = 25 private const val HEIGHT = 6 fun main() { val fileStrings = initialize("Day 8: Space Image Format", arrayOf("day8.txt")) println("Part 1: Basic")...
0
Kotlin
0
0
d2005b1bc8c536fe6800f0cbd05ac53c178db9d8
1,653
advent-of-code-2019
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem2492/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem2492 /** * LeetCode page: [2492. Minimum Score of a Path Between Two Cities](https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities/); */ class Solution { /* Complexity: * Time O(E) and Space O(E) where E is the size of roads; */ fun minScore(...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,627
hj-leetcode-kotlin
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day13/Day13.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day13 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 13](https://adventofcode.com/2021/day/13) */ object Day13 : DayOf2021(13) { override fun first(): Any...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,959
adventofcode
MIT License
src/main/kotlin/aoc2022/Day12.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* import java.lang.IllegalArgumentException typealias Grid<T> = Array<Array<T>> class Day12 { companion object { fun <T> Grid<T>.fromCoord(coord:Coord) = this.getOrNull(coord.y)?.getOrNull(coord.x) } sealed class Elevation(val level: Int)...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
3,309
aoc-kotlin
Apache License 2.0
src/main/kotlin/day18.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day18 import aoc.utils.Point import aoc.utils.readInput import kotlin.math.abs fun main() { // (0..5).forEach {x -> // (0..5).forEach { y -> // (0..5).forEach {z -> // // println() // } // } // } val rocks = points().toSet() val emptySurface...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
6,902
adventOfCode2022
Apache License 2.0
src/main/kotlin/be/swsb/aoc2021/day11/Day11.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day11 import be.swsb.aoc2021.common.Point object Day11 { fun solve1(input: List<String>) : AmountOfFlashes { return DumboOctopusConsortium(input).step(100).amountOfFlashedOctopi } fun solve2(input: List<String>) : AmountOfSteps { var dumboOctopusConsortium = Dumbo...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
4,210
Advent-of-Code-2021
MIT License
src/Day03.kt
wmichaelshirk
573,031,182
false
{"Kotlin": 19037}
fun main() { fun findPriority (c: Char): Int { return if (c.isUpperCase()) { c.code - 64 + 26 } else { c.code - 96 } } fun part1(input: List<String>): Int { return input .map { it.chunked(it.length / 2) } .map { it.first().t...
0
Kotlin
0
2
b748c43e9af05b9afc902d0005d3ba219be7ade2
928
2022-Advent-of-Code
Apache License 2.0
src/main/kotlin/solutions/day12/Day12.kt
Dr-Horv
570,666,285
false
{"Kotlin": 115643}
package solutions.day12 import solutions.Solver import utils.Coordinate import utils.Direction import utils.step class Node( val id: Int, val char: Char, val start: Boolean, val goal: Boolean, val elevation: Int, val neighbours: MutableMap<Direction, Node> ) { override fun equals(other: An...
0
Kotlin
0
2
6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e
3,418
Advent-of-Code-2022
MIT License