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/Day06.kt
mddanishansari
576,622,315
false
{"Kotlin": 11861}
fun main() { fun String.containsDuplicate(): Boolean { val duplicates = mutableListOf<Char>() forEach { if (duplicates.contains(it)) { return true } duplicates.add(it) } return false } fun String.solution(distinctCharacters...
0
Kotlin
0
0
e032e14b57f5e6c2321e2b02b2e09d256a27b2e2
1,045
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tools/math/Modulo.kt
wrabot
739,807,905
false
{"Kotlin": 19706}
package tools.math fun Long.times(multiplier: Long, modulo: Long): Long { if (this < 0) error("negative multiplicand") if (multiplier < 0) error("negative multiplier") if (modulo < 0) error("negative modulo") var res = 0L var a = this % modulo var b = multiplier % modulo while (true) { ...
0
Kotlin
0
0
fd2da26c0259349fbc9719e694d58549e7f040a0
976
competitive-tools
Apache License 2.0
src/day19/Day19.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
package day19 import readInput import java.util.* import java.util.regex.Pattern import kotlin.time.measureTime import kotlin.time.Duration import kotlin.time.ExperimentalTime enum class Material { ORE, CLAY, OBSIDIAN, GEODE } data class BuildCost(val ore: Int, val clay: Int, val obsidian: Int) clas...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
7,231
AdventOfCode2022
Apache License 2.0
src/main/kotlin/aoc2022/Day17.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.Coordinates import utils.InputUtils import java.lang.Integer.max typealias Rock = List<String> fun Rock.width() = get(0).length class Room(val jets: Iterator<Char>, val rockSupply: Iterator<Rock>) { val rows : MutableList<CharArray> = arrayListOf() var highest = -1 fun isCol...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
3,929
aoc-2022-kotlin
Apache License 2.0
src/year_2022/day_23/Day23.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_23 import readInput import util.* enum class Direction { NORTH, SOUTH, WEST, EAST, ; companion object { fun byOrder(order: Int): Direction { return when(order) { 1 -> NORTH 2 -> SOUTH 3 -> WEST ...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
9,055
advent_of_code
Apache License 2.0
src/Day02.kt
michaelYuenAE
573,094,416
false
{"Kotlin": 74685}
fun main() { fun part1(input: List<String>): Int { return input.size } fun part2(input: List<String>): Int { return input.size } // test if implementation meets criteria from the description, like: // shape you selected (1 for Rock, 2 for Paper, and 3 for Scissors) val input...
0
Kotlin
0
0
ee521263dee60dd3462bea9302476c456bfebdf8
2,684
advent22
Apache License 2.0
src/Day12.kt
felldo
572,233,925
false
{"Kotlin": 76496}
import java.lang.Integer.min fun main() { fun buildMinMountain(mountain: Array<Array<Int>>, ey: Int, ex: Int): Array<Array<Int>> { val minMountain = Array(mountain.size) { Array(mountain[0].size) { Int.MAX_VALUE - 10 } } minMountain[ey][ex] = 0 var changed = true while (changed) {...
0
Kotlin
0
0
0ef7ac4f160f484106b19632cd87ee7594cf3d38
3,529
advent-of-code-kotlin-2022
Apache License 2.0
src/day13/a/day13a.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package day13.a import readInputLines import shouldBe fun main() { val msg = read() var r = 0 var i = 0 for (p in msg) { i++ val (m0, m1) = p if (m0 < m1) r += i } shouldBe(6187, r) } data class Message( val list : List<*> ) : Comparable<Message> { constructor...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,089
advent-of-code-2022
Apache License 2.0
kotlin/src/test/kotlin/be/swsb/aoc2023/day9/Solve.kt
Sch3lp
724,797,927
false
{"Kotlin": 44815, "Rust": 14075}
package be.swsb.aoc2023.day9 import be.swsb.aoc2023.readFile import io.kotest.matchers.equals.shouldBeEqual import org.junit.jupiter.api.Test class Solve { private val exampleInput = "2023/day9/exampleInput.txt" private val actualInput = "2023/day9/input.txt" private fun parse(input: String) = input.line...
0
Kotlin
0
1
dec9331d3c0976b4de09ce16fb8f3462e6f54f6e
2,222
Advent-of-Code-2023
MIT License
src/main/kotlin/_2018/Day7.kt
thebrightspark
227,161,060
false
{"Kotlin": 548420}
package _2018 import aocRun import java.util.regex.Pattern import kotlin.math.min private val pattern = Pattern.compile("Step (?<step1>.) must be finished before step (?<step2>.) can begin") fun main() { aocRun(puzzleInput) { input -> val steps = processSteps(input) //println("Steps:\n$steps") ...
0
Kotlin
0
0
ac62ce8aeaed065f8fbd11e30368bfe5d31b7033
10,139
AdventOfCode
Creative Commons Zero v1.0 Universal
year2022/src/cz/veleto/aoc/year2022/Day23.kt
haluzpav
573,073,312
false
{"Kotlin": 164348}
package cz.veleto.aoc.year2022 import cz.veleto.aoc.core.AocDay import cz.veleto.aoc.core.Pos import cz.veleto.aoc.core.plus import cz.veleto.aoc.core.rotateBy class Day23(config: Config) : AocDay(config) { override fun part1(): String { var elves = parseElves() for (round in 1..10) { ...
0
Kotlin
0
1
32003edb726f7736f881edc263a85a404be6a5f0
3,006
advent-of-pavel
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CarPooling.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,101
kotlab
Apache License 2.0
11/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File const val LAST_DAY = 100 fun readInput() : Octopuses { val inputLines = File("input.txt") .readLines() .map { line -> line.split("") .filter { it.isNotEmpty() } .map{ it.toInt() }} return Octopuses(inputLines.map { it.toMutableList() }.toMutableList...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
3,004
advent-of-code-2021
MIT License
src/Day07.kt
Reivax47
572,984,467
false
{"Kotlin": 32685}
fun main() { fun part1(input: List<String>): Int { var monArbre = directory(arbre = input, parentname = "", "/", -1) directory.index = 1 monArbre.ComputeMyPart(input) var somme = 0 monArbre.getLespetits().forEach { it -> somme += it.totalSize() } ...
0
Kotlin
0
0
0affd02997046d72f15d493a148f99f58f3b2fb9
3,300
AD2022-01
Apache License 2.0
src/leetcode_problems/medium/AddTwoNumbers.kt
MhmoudAlim
451,633,139
false
{"Kotlin": 31257, "Java": 586}
package leetcode_problems.medium /* https://leetcode.com/problems/add-two-numbers/ */ /** * Example: * var li = ListNode(5) * var v = li.`val` * Definition for singly-linked list. * class ListNode(var `val`: Int) { * var next: ListNode? = null * } * Example 1: * Input: l1 = [2,4,3], l2 = [5,6,4] * Outpu...
0
Kotlin
0
0
31f0b84ebb6e3947e971285c8c641173c2a60b68
1,225
Coding-challanges
MIT License
src/Day04.kt
robinpokorny
572,434,148
false
{"Kotlin": 38009}
private typealias Assignment = Pair<IntRange, IntRange> private fun parse(input: List<String>): List<Assignment> = input .map(fun(line): List<IntRange> { return line .split(",") .map { it.split("-").map(String::toInt) } .map { (first, second) -> first..second } }) ...
0
Kotlin
0
2
56a108aaf90b98030a7d7165d55d74d2aff22ecc
1,133
advent-of-code-2022
MIT License
Jump_Game_II_v1.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import kotlin.math.min class Solution { fun jump(nums: IntArray): Int { if (nums.isEmpty() || nums.size == 1) return 0 val minimumNumberOfJumps = IntArray(nums.size) { 0xffffff } minimumNumberOfJumps[0] = 0 var longest = 0 for ((i, j) in nums.withIndex()) { if (i...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
999
leetcode
MIT License
src/main/kotlin/day2/Day2.kt
cyril265
433,772,262
false
{"Kotlin": 39445, "Java": 4273}
package day2 import readToList private val input = readToList("day2") fun main() { println(part1()) println(part2()) } private fun part1(): Int { val (horizontal, vertical) = splitInput() .partition { (direction, _) -> direction == "forward" } return horizontal.sumOf {...
0
Kotlin
0
0
1ceda91b8ef57b45ce4ac61541f7bc9d2eb17f7b
998
aoc2021
Apache License 2.0
src/Day20.kt
frungl
573,598,286
false
{"Kotlin": 86423}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { val list = MutableList (input.size) { i -> input[i].toInt() to i } val orig = list.toList() for ((i, index) in orig) { val pos = list.indexOf(i to index) var next = 0 if (i < 0) { ...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
2,314
aoc2022
Apache License 2.0
src/Day09.kt
hottendo
572,708,982
false
{"Kotlin": 41152}
import kotlin.math.absoluteValue import kotlin.math.max private data class Knot(var x: Int = 0, var y: Int = 0) { fun getXY(): Pair<Int, Int> { return Pair(x, y) } fun step(direction: String) { when (direction) { "R" -> x++ "U" -> y-- "D" -> y++ ...
0
Kotlin
0
0
a166014be8bf379dcb4012e1904e25610617c550
3,935
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/sh/weller/aoc/Day04.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.aoc object Day04 : SomeDay<Pair<List<Int>, List<Int>>, Int> { override fun partOne(input: List<Pair<List<Int>, List<Int>>>): Int = input .map { (winningNumbers, havingNumbers) -> val numberOfWinningNumbers = havingNumbers .filter { it in win...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
1,571
AdventOfCode
MIT License
src/main/java/challenges/cracking_coding_interview/trees_graphs/build_order/edge_removal/Question.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.trees_graphs.build_order.edge_removal object Question { private fun buildOrderWrapper( projects: Array<String>, dependencies: Array<Array<String>> ): Array<String?> { val buildOrder = findBuildOrder(projects, dependencies) ?: return emptyArr...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,690
CodingChallenges
Apache License 2.0
dsalgo/src/commonMain/kotlin/com/nalin/datastructurealgorithm/ds/AVLTree.kt
nalinchhajer1
534,780,196
false
{"Kotlin": 86359, "Ruby": 1605}
package com.nalin.datastructurealgorithm.ds import kotlin.math.abs import kotlin.math.max /** * AVL Tree: * Creates a self balancing Binary tree * Left is smaller than parent and right is greater than or equal to parent */ class AVLTree<T : Comparable<T>> : BSTTree<T> { private var rootNode: BSTNode<T>? = nu...
0
Kotlin
0
0
eca60301dab981d0139788f61149d091c2c557fd
3,644
kotlin-ds-algo
MIT License
src/day10/Day10.kt
pnavais
574,712,395
false
{"Kotlin": 54079}
package day10 import readInput import kotlin.text.StringBuilder class CycleRegister(private val frequency: Int = 20, private val step: Int = 40) { private var registerX: Int = 1 private val signalStrengths = mutableListOf<Int>() private var cycleNum = 0 private val rows = mutableListOf<String>() ...
0
Kotlin
0
0
ed5f521ef2124f84327d3f6c64fdfa0d35872095
2,266
advent-of-code-2k2
Apache License 2.0
src/main/kotlin/adventofcode/year2015/Day13KnightsOfTheDinnerTable.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2015 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.permutations class Day13KnightsOfTheDinnerTable(customInput: PuzzleInput? = null) : Puzzle(customInput) { override val name = "Knights of the Dinner Table" private val happiness by lazy { ...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,678
AdventOfCode
MIT License
src/problemOfTheDay/problemEight/universalTree.kt
cunrein
159,861,371
false
null
package problemOfTheDay.problemEight import problemOfTheDay.problemThree.node // A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. // // Given the root to a binary tree, count the number of unival subtrees. // // For example, the following tree has 5 unival su...
0
Kotlin
0
0
3488ccb200f993a84f1e9302eca3fe3977dbfcd9
2,059
ProblemOfTheDay
Apache License 2.0
src/main/kotlin/pl/mrugacz95/aoc/day15/day15.kt
mrugacz95
317,354,321
false
null
package pl.mrugacz95.aoc.day15 fun findSpokenNumber(turns: List<Int>, toFind: Int): Int { var lastFound: Int? = null for (i in turns.indices.reversed()) { val turn = turns[i] if (turn == toFind) { if (lastFound != null) { return lastFound - i } else { ...
0
Kotlin
0
1
a2f7674a8f81f16cd693854d9f564b52ce6aaaaf
1,385
advent-of-code-2020
Do What The F*ck You Want To Public License
year2019/src/main/kotlin/net/olegg/aoc/year2019/day3/Day3.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2019.day3 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.year2019.DayOf2019 /** * See [Year 2019, Day 3](https://adventofcode.com/2019/day/3) */ object Day3 : DayOf2019(3) { override fun first(): Any? { ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,527
adventofcode
MIT License
csp-scheduling/src/main/kotlin/com/tsovedenski/csp/scheduling/Scheduling.kt
RedShuhart
152,120,429
false
null
package com.tsovedenski.csp.scheduling import com.tsovedenski.csp.* import com.tsovedenski.csp.scheduling.TimeRange.Companion.fromString import java.io.File import kotlin.random.Random class Scheduling(val classesSchedules: Map<String, List<TimeRange>>) : Solvable<String, TimeRange> { private val classes = class...
0
Kotlin
1
4
29d59ec7ff4f0893c0d1ec895118f961dd221c7f
2,756
csp-framework
MIT License
ceria/08/src/main/kotlin/Solution.kt
VisionistInc
572,963,504
false
null
import java.io.File; fun main(args : Array<String>) { var input = mutableListOf<List<Int>>() File(args.first()).readLines().forEach { var row = it.toList().map{ it.digitToInt() } input.add(row) } println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private...
0
Rust
0
0
90b348d9c8060a8e967fe1605516e9c126fc7a56
3,088
advent-of-code-2022
MIT License
src/day19/Day19.kt
idle-code
572,642,410
false
{"Kotlin": 79612}
package day19 import logEnabled import logln import readInput import java.util.PriorityQueue import kotlin.math.ceil import kotlin.math.min import kotlin.math.roundToInt private const val DAY_NUMBER = 19 val blueprintRegex = """Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Eac...
0
Kotlin
0
0
1b261c399a0a84c333cf16f1031b4b1f18b651c7
6,872
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/davio/aoc/y2023/Day8.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2023 import com.github.davio.aoc.general.Day import com.github.davio.aoc.general.getInputAsList import com.github.davio.aoc.general.lcm /** * See [Advent of Code 2023 Day 8](https://adventofcode.com/2023/day/8#part2]) */ class Day8(exampleNumber: Int? = null) : Day(exampleNumber) { ...
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
2,372
advent-of-code
MIT License
src/Day13.kt
underwindfall
573,471,357
false
{"Kotlin": 42718}
fun main() { val dayId = "13" val input = readInput("Day${dayId}") fun parse(s: String): Any { var i = 0 fun next(): Any { if (s[i] == '[') { i++ val res = ArrayList<Any>() while(true) { if (s[i] == ']') { ...
0
Kotlin
0
0
0e7caf00319ce99c6772add017c6dd3c933b96f0
1,728
aoc-2022
Apache License 2.0
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day22.kt
dvdmunckhof
318,829,531
false
{"Kotlin": 195848, "PowerShell": 1266}
package com.dvdmunckhof.aoc.event2020 class Day22(private val input: String) { fun solvePart1(): Int { return playCombat(false) } fun solvePart2(): Int { return playCombat(true) } private fun playCombat(recursive: Boolean): Int { val (deck1, deck2) = input.split("\n\n").m...
0
Kotlin
0
0
025090211886c8520faa44b33460015b96578159
1,683
advent-of-code
Apache License 2.0
src/main/kotlin/day20/main.kt
janneri
572,969,955
false
{"Kotlin": 99028}
package day20 import util.readTestInput // Wrapper class to capture the original index of each number. // The original index can be used to find the current index of number to be shifted private data class ShiftingNumber(val originalIndex: Int, val value: Long) // Decryption key is used in part 2. In part 1 it's 1. ...
0
Kotlin
0
0
1de6781b4d48852f4a6c44943cc25f9c864a4906
2,150
advent-of-code-2022
MIT License
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day18/Cube.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day18 data class Cube(val x: Int, val y: Int, val z: Int) { fun getSides(): Sequence<Side> { return sequenceOf( Side(x + 0, x + 0, y + 0, y + 1, z + 0, z + 1), Side(x + 1, x + 1, y + 0, y + 1, z + 0, z + 1), Side(x + 0, x + 1, y + 0, y + 0, z + 0, z + 1), Side(x + 0, x + 1, y +...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
879
advent-of-code
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions77.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round1.SingleDirectionNode import com.qiaoyuang.algorithm.round1.printlnLinkedList fun test77() { val head = SingleDirectionNode(element = 3, next = SingleDirectionNode(element = 5, next = SingleDirectionNode(element = 1, next = SingleDirectio...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,629
Algorithm
Apache License 2.0
src/commonMain/kotlin/de/voize/semver4k/Requirement.kt
voize-gmbh
369,655,654
true
{"Kotlin": 125030}
package de.voize.semver4k import de.voize.semver4k.Tokenizer.tokenize import de.voize.semver4k.Semver.SemverType import de.voize.semver4k.Range.RangeOperator /** * A requirement will provide an easy way to check if a version is satisfying. * There are 2 types of requirements: * - Strict: checks if a version is equ...
0
Kotlin
1
2
fb9a7623e181b3246ad894b439dff6cb1353dfbc
28,055
semver4k
MIT License
advent2022/src/main/kotlin/year2022/Day09.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import kotlin.math.sign class Day09 : AdventDay(2022, 9) { sealed class RopeMove(val amount: Int) { companion object { fun from(input: String) = input.split(" ").let { (a, b) -> when (a) { "L" -> Left...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,322
advent-of-code
Apache License 2.0
src/main/kotlin/aoc2022/Day07.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* class Day07() { sealed interface Node { val size: Int val subNodes: List<Node> } data class FileNode(override val size: Int, val name: String) : Node { override val subNodes: List<Node> get() = emptyList() } da...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
1,649
aoc-kotlin
Apache License 2.0
src/Day07.kt
SeanDijk
575,314,390
false
{"Kotlin": 29164}
// Not the most efficient code, but it works interface FileSystemObject { fun size(): Int } sealed interface Command { data class Cd(val dir: String) : Command data class Ls(val output: List<String>) : Command } fun main() { fun parseCommands(input: String): List<Command> { return input ...
0
Kotlin
0
0
363747c25efb002fe118e362fb0c7fecb02e3708
5,359
advent-of-code-2022
Apache License 2.0
puzzles/src/main/kotlin/com/kotlinground/puzzles/search/binarysearch/findpeakelement/findPeakElement.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.puzzles.search.binarysearch.findpeakelement /** * Finds a peak element's index in the provided list of integers * * Algorithm: * - Initializes left as the start index of the list and right as the end index of the list (len(nums)- 1). * - Perform binary search until left becomes equal to r...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
1,716
KotlinGround
MIT License
src/main/kotlin/dp/MetaPal.kt
yx-z
106,589,674
false
null
package dp import util.OneArray import util.get import util.toOneArray // a metapalindrome is a decomposition of string into palindromes, // such that the sequence of palindrome lengths itself is a palindrome fun main(args: Array<String>) { val str = "BUBBLESSEESABANANA".toCharArray().toList().toOneArray() println...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,971
AlgoKt
MIT License
src/Day09.kt
marosseleng
573,498,695
false
{"Kotlin": 32754}
fun main() { fun part1(input: List<String>): Int { return countVisitedByTail(input) } fun part2(input: List<String>): Int { return countVisitedByTail2(input) } val testInput = readInput("Day09_test") check(part1(testInput) == 13) val testInput2 = readInput("Day09_test_2") ...
0
Kotlin
0
0
f13773d349b65ae2305029017490405ed5111814
6,300
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2023/Day02.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2023 import se.saidaspen.aoc.util.* fun main() = Day02.run() object Day02 : Day(2023, 2) { override fun part1() : Any { var possible = 0 for (line in input.lines()) { val gameID = words(line)[1].replace(":", "").toInt() val game = line.split(":...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,323
adventofkotlin
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year15/Day22.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year15 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.drain import com.grappenmaker.aoc.hasDuplicateBy import com.grappenmaker.aoc.splitInts import java.util.* fun PuzzleSet.day22() = puzzle(day = 22) { val (initialBossHP, bossDMG) = input.splitInts() // Horrib...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,168
advent-of-code
The Unlicense
kotlin/src/com/s13g/aoc/aoc2023/Day12.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2023 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.resultFrom /** * --- Day 12: Hot Springs --- * https://adventofcode.com/2023/day/12 */ class Day12 : Solver { private val cache = mutableMapOf<String, Long>() override fun solve(lines: List<String>): Result {...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
3,018
euler
Apache License 2.0
src/year_2021/day_11/Day11.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2021.day_11 import readInput import util.neighbors import java.awt.font.ImageGraphicAttribute enum class FlashAttemptResult { IGNORED, INCREASED, FLASHED, ; } data class Octopus( var charge: Int ) { var hasFlashedThisRound: Boolean = false private set fun attemptFlas...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
2,770
advent_of_code
Apache License 2.0
src/main/kotlin/kr/co/programmers/P42861.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package kr.co.programmers // https://github.com/antop-dev/algorithm/issues/530 class P42861 { fun solution(n: Int, costs: Array<IntArray>): Int { // 건설 비용이 낮은 순으로 정렬 costs.sortBy { (_, _, cost) -> cost } // Union-Find val root = IntArray(n) { it } var ans = 0 var co...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
951
algorithm
MIT License
src/main/java/io/github/lunarwatcher/aoc/day6/Day6.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day6 import io.github.lunarwatcher.aoc.commons.readFile import kotlin.math.absoluteValue const val INFINITE_AREA = -1 data class Area (val center: Pair<Int, Int>, val points: MutableList<Pair<Int, Int>> = mutableListOf()){ val area: Int get() = points.size fun won(x...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
2,486
AoC-2018
MIT License
src/aoc2022/Day14.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 import utils.* import kotlin.math.max private const val ROCK = -1 private const val AIR = 0 private const val SAND = 1 //private val SAND_START_POINT = 0 to 500 private val SAND_START_POINT = Vertex(500, 0) fun main() { // parts execution val testInput = readInput("Day14_test") val input...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
4,063
Kotlin-AOC-2023
Apache License 2.0
src/Day21.kt
mrugacz95
572,881,300
false
{"Kotlin": 102751}
import java.math.BigInteger private const val DEBUG = true private sealed class TreeNode(open val name: String?) private data class Terminal( val value: BigInteger, override val name: String? ) : TreeNode(name) { override fun toString(): String { return "$value" } } private data class Product...
0
Kotlin
0
0
29aa4f978f6507b182cb6697a0a2896292c83584
5,504
advent-of-code-2022
Apache License 2.0
Edit_Distance.kt
xiekch
166,329,519
false
{"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349}
import kotlin.math.max import kotlin.math.min class Solution { fun minDistance(word1: String, word2: String): Int { val maxLen = max(word1.length, word2.length) if (word1.isEmpty() || word2.isEmpty()) return maxLen val dp = Array(word1.length + 1) { Array(word2.length + 1) { 0 } } f...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
1,049
leetcode
MIT License
Problems/Algorithms/695. Max Area of Island/MaxArea.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun closedIsland(grid: Array<IntArray>): Int { val n = grid.size val m = grid[0].size val visited = Array(n) { IntArray(m) { 0 } } var ans = 0 for (r in 0..n-1) { for (c in 0..m-1) { val curr = dfs(grid, visited, n, m, r, ...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,166
leet-code
MIT License
src/Day02.kt
JCofman
576,062,635
false
{"Kotlin": 6297}
object PointConstants { const val DRAW_SCORE = 3; const val LOOSE_SCORE = 0; const val WIN_SCORE = 6; } fun main() { fun solvePart1(input: List<String>): Int { var points = 0; input.forEach { when (it) { "A X" -> points += 1 + PointConstants.DRAW_SCORE ...
0
Kotlin
0
1
c25a54b03df77c1be46827642b6adc7644825c8c
1,899
aoc-2022-in-kotlin
Apache License 2.0
leetcode-75-kotlin/src/main/kotlin/AsteroidCollision.kt
Codextor
751,507,040
false
{"Kotlin": 49566}
import kotlin.math.absoluteValue /** * We are given an array asteroids of integers representing asteroids in a row. * * For each asteroid, the absolute value represents its size, * and the sign represents its direction (positive meaning right, negative meaning left). * Each asteroid moves at the same speed. * *...
0
Kotlin
0
0
0511a831aeee96e1bed3b18550be87a9110c36cb
2,202
leetcode-75
Apache License 2.0
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day22Test.kt
dirkgroot
317,968,017
false
{"Kotlin": 187862}
package nl.dirkgroot.adventofcode.year2022 import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import nl.dirkgroot.adventofcode.util.input import nl.dirkgroot.adventofcode.util.invokedWith private fun solution1(input: String) = parse(input).let { (map, path) -> val width = map[0].size ...
0
Kotlin
1
1
ffdffedc8659aa3deea3216d6a9a1fd4e02ec128
3,788
adventofcode-kotlin
MIT License
Chapter10/src/main/kotlin/com/programming/kotlin/chapter10/MapsCollection.kt
PacktPublishing
78,835,440
false
null
package com.programming.kotlin.chapter10 import java.util.* fun maps() { val carsMap: Map<String, String> = mapOf("a" to "<NAME>", "b" to "bmw", "m" to "mercedes", "f" to "ferrari") println("cars[${carsMap.javaClass.canonicalName}:$carsMap]") println("car maker starting with 'f':${carsMap.get("f")}") //...
5
Kotlin
41
75
4502b55d4086795df3f76ef65517679ad6c8cd55
1,988
Programming-Kotlin
MIT License
src/main/kotlin/year_2022/Day01.kt
krllus
572,617,904
false
{"Kotlin": 97314}
package year_2022 import utils.readInput fun main() { fun part1(input: List<String>): Int { val caloriesCountByElf = arrayListOf<Int>() var currentElfCaloriesCount = 0 for(index in input.indices){ val element = input[index] if(element.isEmpty()){ ca...
0
Kotlin
0
0
b5280f3592ba3a0fbe04da72d4b77fcc9754597e
1,655
advent-of-code
Apache License 2.0
src/main/kotlin/days/day25/Day25.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day25 import days.Day class Day25 : Day() { override fun partOne(): Any { val vertices = mutableSetOf<String>() val edges = mutableListOf<Pair<String, String>>() readInput().forEach { val firstComponent = it.substringBefore(": ") vertices.add(firstComp...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
1,772
advent-of-code_2023
The Unlicense
core/src/main/kotlin/moe/sdl/yac/sources/ValueSource.kt
Colerar
481,849,090
false
{"Kotlin": 188073}
package moe.sdl.yac.sources import moe.sdl.yac.core.Context import moe.sdl.yac.parameters.options.Option import moe.sdl.yac.parameters.options.longestName import moe.sdl.yac.parameters.options.splitOptionPrefix interface ValueSource { data class Invocation(val values: List<String>) { companion object { /*...
0
Kotlin
0
2
40194f93904bedb1d25bf325fa7a2ebde33f58f1
2,531
Yac
Apache License 2.0
src/main/kotlin/com/hjk/advent22/Day13.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 import com.fasterxml.jackson.databind.ObjectMapper object Day13 { fun part1(input: List<String>): Int = input.chunkedByEmptyLine().foldIndexed(0) { index, acc, (a, b) -> acc + (if (isRightOrder(a.convert(), b.convert()) == true) index + 1 else 0) } fun part2(input: List<...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
1,515
advent22
Apache License 2.0
src/main/kotlin/adventofcode/day16/Valve.kt
jwcarman
573,183,719
false
{"Kotlin": 183494}
/* * Copyright (c) 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 i...
0
Kotlin
0
0
d6be890aa20c4b9478a23fced3bcbabbc60c32e0
2,890
adventofcode2022
Apache License 2.0
src/main/kotlin/github/walkmansit/aoc2020/Day16.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day16(val input: String) : DayAoc<Int, Long> { private class TicketScanner private constructor( val fieldValidators: LinkedHashMap<String, Array<IntRange>>, val myTicket: Array<Int>, val nearbyTickets: Array<Array<Int>> ) { fun getScanni...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
4,503
AdventOfCode2020
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions88.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import kotlin.math.min fun test88() { printlnResult(1, 100, 1, 1, 100, 1) } /** * Questions 88: Minimum cost for climbing stairs */ private fun minCost(vararg costs: Int): Int { require(costs.size >= 2) { "The size of costs must greater or equal than 2" } return ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,155
Algorithm
Apache License 2.0
app/src/main/java/online/vapcom/codewars/math/ScreenLockingPatterns.kt
vapcomm
503,057,535
false
{"Kotlin": 142486}
package online.vapcom.codewars.math /* * A B C 0 1 2 * D E F -> 3 4 5 * G H I 6 7 8 */ private val DIRECT_POINTS = arrayOf( intArrayOf(1, 5, 4, 7, 3), // 0 intArrayOf(2, 5, 8, 4, 6, 3, 0), // 1 intArrayOf(5, 7, 4, 3, 1), // 2 intArrayOf(0, 1, 2, 4, 8, 7, 6), // 3 i...
0
Kotlin
0
0
97b50e8e25211f43ccd49bcee2395c4bc942a37a
3,957
codewars
MIT License
year2020/day18/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day18/part1/Year2020Day18Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 18: Operation Order --- As you look out the window and notice a heavily-forested continent slowly appear over the horizon, you are interrupted by the child sitting next to you. They're curious if you could help them with their math homework. Unfortunately, it seems like this "math" follows different rules ...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,422
AdventOfCode
MIT License
src/main/kotlin/07.kts
reitzig
318,492,753
false
null
import java.io.File typealias Color = String data class BagRule private constructor(val color: Color, val canContain: Map<Color, Int>) { companion object { val bagAmountPattern = Regex("(\\d+) ([a-z ]+) bags?") val rulePattern = Regex("^([a-z ]+) bags contain ([0-9a-z, ]+)\\.$") operator...
0
Kotlin
0
0
f17184fe55dfe06ac8897c2ecfe329a1efbf6a09
4,016
advent-of-code-2020
The Unlicense
library/src/main/kotlin/io/github/tomplum/libs/algorithm/DijkstrasAlgorithm.kt
TomPlum
317,517,927
false
{"Kotlin": 161096}
package io.github.tomplum.libs.algorithm import java.util.* /** * A single node in a graph traversed by Dijkstra's algorithm. * * @param value The value of the node. Usually contains cartesian positional information. * @param distance The distance to this node from the starting point. */ data class Node<T>(val v...
2
Kotlin
0
0
c026ab7ae982c34db4f5fbebf3f79b0b8c717ee5
4,182
advent-of-code-libs
Apache License 2.0
src/main/kotlin/days/Day1.kt
jgrgt
433,952,606
false
{"Kotlin": 113705}
package days class Day1 : Day(1) { override fun partOne(): Any { val depths = inputList.map { it.toInt() } val increases = DepthIncreaseCounter.count(depths) println("Increases: $increases") return increases } override fun partTwo(): Any { val depths = inputList.ma...
0
Kotlin
0
0
6231e2092314ece3f993d5acf862965ba67db44f
1,264
aoc2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/sortingandsearching/MedianOfTwoSortedArrays.kt
e-freiman
471,473,372
false
{"Kotlin": 78010}
package sortingandsearching // O(log(min(m, n))) fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val a = if (nums1.size < nums2.size) nums1 else nums2 val b = if (nums1.size < nums2.size) nums2 else nums1 var l = 0 var r = a.size var i: Int var j: Int var found: Bool...
0
Kotlin
0
0
fab7f275fbbafeeb79c520622995216f6c7d8642
1,202
LeetcodeGoogleInterview
Apache License 2.0
dcp_kotlin/src/main/kotlin/dcp/day257/day257.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day257 // day257.kt // By <NAME>, 2019. fun <T: Comparable<T>> smallestWindowBruteForce(list: List<T>): Pair<Int, Int>? { if (list.isEmpty()) return null val sorted = list.sorted() val left = list.zip(sorted).indexOfFirst { it.first != it.second } val right = list.zip(sorted).indexOfLast...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,515
daily-coding-problem
MIT License
src/Day04.kt
ChAoSUnItY
572,814,842
false
{"Kotlin": 19036}
fun main() { fun part1(data: List<List<IntRange>>): Int = data.sumOf { val (l, r) = it.take(2) val intersectedSize = l.intersect(r).size if (intersectedSize == l.count() || intersectedSize == r.count()) 1.toInt() else 0 } fun part2(data: List<List<IntRange>>...
0
Kotlin
0
3
4fae89104aba1428820821dbf050822750a736bb
954
advent-of-code-2022-kt
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day03/Day03.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
3,594
AdventOfCode
Apache License 2.0
src/main/kotlin/days/Day12.kt
MaciejLipinski
317,582,924
true
{"Kotlin": 60261}
package days import days.InstructionType.E import days.InstructionType.F import days.InstructionType.L import days.InstructionType.N import days.InstructionType.R import days.InstructionType.S import days.InstructionType.W class Day12 : Day(12) { override fun partOne(): Any = interpretInstructions(Ferry1()) ...
0
Kotlin
0
0
1c3881e602e2f8b11999fa12b82204bc5c7c5b51
3,556
aoc-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/github/solairerove/algs4/leprosorium/binary_search_tree/CountOfSmallerNumbersAfterSelf.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.binary_search_tree import java.util.* fun main() { println(countSmallerNaiveSquared(intArrayOf(5, 2, 6, 1))) // [2, 1, 1, 0] println(countSmallerBST(listOf(5, 2, 6, 1))) // [2, 1, 1, 0] println(countSmaller(intArrayOf(5, 2, 6, 1))) // [2, 1, 1, 0] } privat...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
3,438
algs4-leprosorium
MIT License
src/main/kotlin/_2023/Day18.kt
novikmisha
572,840,526
false
{"Kotlin": 145780}
package _2023 import Coordinate import Day import InputReader import java.math.BigInteger import java.util.* import kotlin.collections.LinkedHashSet import kotlin.math.abs import kotlin.math.absoluteValue import kotlin.time.measureTime class Day18 : Day(2023, 18) { override val firstTestAnswer = 62 override ...
0
Kotlin
0
0
0c78596d46f3a8bf977bf356019ea9940ee04c88
3,619
advent-of-code
Apache License 2.0
src/main/kotlin/g2101_2200/s2151_maximum_good_people_based_on_statements/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2151_maximum_good_people_based_on_statements // #Hard #Array #Bit_Manipulation #Backtracking #Enumeration // #2023_06_26_Time_308_ms_(100.00%)_Space_46.3_MB_(100.00%) class Solution { fun maximumGood(statements: Array<IntArray>): Int { val known = IntArray(statements.size) know...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,791
LeetCode-in-Kotlin
MIT License
Array/zhangjunwei/6.28-7.4/numOfSubarrays.kt
JessonYue
268,215,243
false
null
package com.lanfairy.md.july class Solution628 { /**https://leetcode-cn.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/solution/ci-ti-zui-you-jie-hua-dong-chuang-kou-jia-dong-tai/ * 思路: step1 : 取出前k个数求和,然后减去k*threshold ,如果结果大于0,说明符合要求。 step2 : 指针后移一位,用后移一位的值...
0
C
19
39
3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79
1,283
LeetCodeLearning
MIT License
leetcode2/src/leetcode/generate-parentheses.kt
hewking
68,515,222
false
null
package leetcode /** * 22. 括号生成 * https://leetcode-cn.com/problems/generate-parentheses/ * * 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出 n = 3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/generate-parentheses 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,752
leetcode
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-06.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.BooleanGrid import com.github.ferinagy.adventOfCode.IntGrid import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2015, "06-input") ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,855
advent-of-code
MIT License
src/main/kotlin/com/github/solairerove/algs4/leprosorium/binary_search_tree/SameBSTs.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.binary_search_tree fun main() { println(sameBsts(listOf(1, 2, 3), listOf(1, 2, 3))) // true println(sameBsts(listOf(1, 2, 3), listOf(1, 3, 2))) // false } // O(nˆ2) time | O(d) space // n is number of nodes // d is depth fun sameBsts( arrOne: List<Int>,...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,381
algs4-leprosorium
MIT License
src/main/kotlin/Main.kt
MisterVitoPro
538,020,117
false
{"Kotlin": 17186}
import mu.KotlinLogging import kotlin.math.max import kotlin.math.min import kotlin.math.roundToInt private val logger = KotlinLogging.logger {} fun main() { print("Set Number of Players (2-5): ") val numOfPlayer = Integer.valueOf(readLine()) println("Number of Players set to: $numOfPlayer") print("H...
0
Kotlin
0
0
0ef653d232d6abef8da4c0f39fbf2fbf6d3bd1e4
3,281
Alphabet-crossing-Simulator
Apache License 2.0
y2021/src/main/kotlin/adventofcode/y2021/Day05.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2021 import adventofcode.io.AdventSolution import adventofcode.util.vector.Vec2 import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.sign object Day05 : AdventSolution(2021, 5, "Hydrothermal Venture") { override fun solvePartOne(input: String) = parseInput(input).filter...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,359
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestObstacleCourse.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,096
kotlab
Apache License 2.0
2022/Day14/problems.kt
moozzyk
317,429,068
false
{"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794}
import java.io.File import kotlin.math.max fun main(args: Array<String>) { val lines = File(args[0]).readLines() println(problem1(lines)) println(problem2(lines)) } fun problem1(lines: List<String>): Int { val cave = buildCave(lines, addFloor = false) var numGrains = 0 while (!dropSand(cave)) ...
0
Rust
0
0
c265f4c0bddb0357fe90b6a9e6abdc3bee59f585
2,118
AdventOfCode
MIT License
src/problems/1006-clumsy.kt
w1374720640
352,006,409
false
null
package problems /** * 1006.笨阶乘 https://leetcode-cn.com/problems/clumsy-factorial/ * * 解:以N=10为例,clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1 * = (10 * 9 / 8) + (7) + (-6 * 5 / 4) + (3) + (-2 * 1) * 以每个括号内的值为单位,不停累加即可得出最终值 */ fun clumsy(N: Int): Int { require(N >= 0) va...
0
Kotlin
0
0
21c96a75d13030009943474e2495f1fc5a7716ad
1,222
LeetCode
MIT License
src/main/kotlin/nl/tiemenschut/aoc/y2023/day15.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day typealias Box = LinkedHashMap<String, Int> fun main() { aoc { puzzle { 2023 day 15 } fun String.christmasHash() = this.fold(0) { acc, c -> (17 * (acc + c.code)).and(0b11111111) } ...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
1,236
aoc-2023
The Unlicense
src/main/kotlin/d14_ExtendedPolymerization/ExtendedPolymerization.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d14_ExtendedPolymerization import util.Input import util.Output fun main() { Output.day(14, "Extended Polymerization") val startTime = Output.startTime() // sort input val input = Input.parseLines(filename = "/input/d14_polymer_pairs_insertion_rules.txt") val polymer = input[0].split("")....
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
2,022
advent-of-code-2021
MIT License
src/Day02.kt
KliminV
573,758,839
false
{"Kotlin": 19586}
fun main() { fun part1(input: List<String>): Int { if (input.isEmpty()) return 0; var totalPoints = 0; for (line in input) { val split = line.split(" "); val playerOneChoice = decrypt(split.get(0)[0]) val playerTwoChoice = decrypt(split.get(1)[0]) ...
0
Kotlin
0
0
542991741cf37481515900894480304d52a989ae
2,782
AOC-2022-in-kotlin
Apache License 2.0
src/main/kotlin/g1301_1400/s1395_count_number_of_teams/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1301_1400.s1395_count_number_of_teams // #Medium #Array #Dynamic_Programming #Binary_Indexed_Tree // #2023_06_06_Time_192_ms_(100.00%)_Space_38.4_MB_(33.33%) @Suppress("NAME_SHADOWING") class Solution { fun numTeams(rating: IntArray): Int { val cp = rating.clone() cp.sort() // cou...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,123
LeetCode-in-Kotlin
MIT License
src/Day10.kt
proggler23
573,129,757
false
{"Kotlin": 27990}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Long { val cycles = input.cycles() val checkMarks = listOf(IndexedValue(19, cycles[19])) + cycles.asSequence().withIndex().drop(20).take(200).windowed(size = 40, step = 40).map { it.last() } return checkMark...
0
Kotlin
0
0
584fa4d73f8589bc17ef56c8e1864d64a23483c8
1,178
advent-of-code-2022
Apache License 2.0
kotlin/2018/src/main/kotlin/2018/Lib07.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
package aoc.kt.y2018; /** * Day 7. */ data class Node(val id: Char) data class Edge(val before: Char, val after: Char) /** Part 1 */ fun processSteps1(input: String): String { val stepMatch = " [A-Z] ".toRegex() val nodes = mutableSetOf<Node>() val edges = mutableSetOf<Edge>() input.lines().forEac...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
1,341
adventofcode
MIT License
src/Day01.kt
emanguy
573,113,840
false
{"Kotlin": 17921}
fun main() { fun part1(input: List<String>): Int { var maxSum = 0 var currentSum = 0 for (calorieCount in input) { if (calorieCount.isBlank()) { if (currentSum > maxSum) maxSum = currentSum currentSum = 0 continue } ...
0
Kotlin
0
1
211e213ec306acc0978f5490524e8abafbd739f3
1,477
advent-of-code-2022
Apache License 2.0
src/Day02.kt
wedrychowiczbarbara
573,185,235
false
null
fun main() { data class Rule(val move: String, val reward: Int) val gameRules = mutableListOf<Rule>( Rule("A X", 4), Rule("A Y", 8), Rule("A Z", 3), Rule("B X", 1), Rule("B Y", 5), Rule("B Z", 9), Rule("C X", 7), Rule("C Y", 2), Rule("C Z"...
0
Kotlin
0
0
04abc035c51649dffe1dde8a115d98640552a99d
1,104
AOC_2022_Kotlin
Apache License 2.0
capitulo5/src/main/kotlin/5.30(Adivinhe o número).kt
Cursos-Livros
667,537,024
false
{"Kotlin": 104564}
import kotlin.random.Random //5.30 (Adivinhe o número) Escreva um aplicativo que reproduza “adivinhe o número” da seguinte maneira: //programa escolhe o número a ser adivinhado selecionando um número inteiro aleatório no intervalo de 1 a 1000. //O aplicativo exibe o prompt Adivinhe um número entre 1 e 1000. O jogador ...
0
Kotlin
0
0
f2e005135a62b15360c2a26fb6bc2cbad18812dd
1,866
Kotlin-Como-Programar
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year17/Day10.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year17 import com.grappenmaker.aoc.* fun PuzzleSet.day10() = puzzle(day = 10) { val (a, b) = knotHash(input.split(",").map(String::toInt)).data partOne = (a * b).s() partTwo = totalKnotHash(input.deepen().map { it.code }).display() } private val primeLengths = listOf(17, 31, ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,569
advent-of-code
The Unlicense
day05/kotlin/RJPlog/day2305_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File import kotlin.math.* fun fertilizer(): Long { var locationList = mutableListOf<Long>() var newLocationList = mutableListOf<Long>() File("day2305_puzzle_input.txt").forEachLine { if (it.contains("seeds: ")) { locationList = it.substringAfter("seeds: ").split(" ").map { it.toLong() }.toMutab...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
2,740
aoc-2023
MIT License
src/Day02.kt
gojoel
573,543,233
false
{"Kotlin": 28426}
enum class Option { // *** elf options *** A, // rock B, // paper C, // scissors // *** player options *** X, // rock, lose Y, // paper, draw Z; // scissors, win fun value(): Int { return when (this) { X -> 1 Y -> 2 Z -> 3 else...
0
Kotlin
0
0
0690030de456dad6dcfdcd9d6d2bd9300cc23d4a
2,495
aoc-kotlin-22
Apache License 2.0
src/Day11/Day11.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day11 import readInput import java.math.BigInteger import java.time.LocalDateTime fun main() { fun extractInstructions(input: String): Instruction { val regex = """Monkey (\d+):\s+Starting items: (\d+(?:, \d+)*)\s+Operation: new = old ([+,-,\\,\*]) (old|\d+)\s+Test: divisible by (\d+)\...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
6,009
aoc-2022
Apache License 2.0