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/org/example/e3fxgaming/adventOfCode/aoc2023/day01/Day01.kt
E3FxGaming
726,041,587
false
{"Kotlin": 38290}
package org.example.e3fxgaming.adventOfCode.aoc2023.day01 import org.example.e3fxgaming.adventOfCode.utility.Day import org.example.e3fxgaming.adventOfCode.utility.IndividualLineInputParser import org.example.e3fxgaming.adventOfCode.utility.InputParser import org.example.e3fxgaming.adventOfCode.utility.StringAndIntTri...
0
Kotlin
0
0
3ae9e8b60788733d8bc3f6446d7a9ae4b3dabbc0
2,729
adventOfCode
MIT License
src/main/kotlin/symbolik/expressions/extensions.kt
Andlon
55,359,009
false
null
package symbolik.expressions import symbolik.parser.Token import symbolik.util.isDivisible import symbolik.util.reduceOrNull import symbolik.util.repeat import kotlin.comparisons.compareBy import kotlin.comparisons.thenByDescending operator fun Expression.plus(other: Expression): Expression = sum(this, other) operato...
0
Kotlin
0
0
9711157eda9a56ba622475bf994cef8ff9d16946
14,667
symbolik
MIT License
src/main/java/challenges/educative_grokking_coding_interview/merge_intervals/_4/EmployeeFreeTime.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.merge_intervals._4 import challenges.educative_grokking_coding_interview.merge_intervals.Interval import java.util.* object EmployeeFreeTime { private fun employeeFreeTime(schedule: ArrayList<ArrayList<Interval>>): List<Interval> { val heap = Priorit...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
6,189
CodingChallenges
Apache License 2.0
src/Day05_part2.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part2(input: List<String>): String { fun convertInput(input: List<String>): MutableList<MutableList<Char>> { val containers = mutableListOf<MutableList<Char>>() for (i in 0 until input.last().length / 4 + 1) { containers.add(mutableListOf()) ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
1,838
advent-of-code-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day22.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import java.util.* import kotlin.math.max import kotlin.math.min /** * [Day 22: Wizard Simulator 20XX](https://adventofcode.com/2015/day/22). */ object Day22 { @JvmStatic fun main(args: Array<String>) ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
3,976
advent-of-code
MIT License
src/main/kotlin/io/queue/NumberOfIslands.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.queue import java.util.* import kotlin.collections.HashSet // https://leetcode.com/explore/learn/card/queue-stack/231/practical-application-queue/1374/ class NumberOfIslands { fun execute(grid: Array<CharArray>): Int { val visited = HashSet<Coordinates>() var numberOfIslands = 0 grid.mapInde...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,262
coding
MIT License
src/net/sheltem/aoc/y2022/Day13.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 suspend fun main() { Day13().run() } class Day13 : Day<Int>(13, 140) { private val firstDivider = "[[2]]".toSignal() private val secondDivider = "[[6]]".toSignal() override suspend fun part1(input: List<String>): Int = input.toPairsOfSignals().map { it.compare() }.ma...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
3,364
aoc
Apache License 2.0
year2019/day03/part2/src/main/kotlin/com/curtislb/adventofcode/year2019/day03/part2/Year2019Day03Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- It turns out that this circuit is very timing-sensitive; you actually need to minimize the signal delay. To do this, calculate the number of steps each wire takes to reach each intersection; choose the intersection where the sum of both wires' steps is lowest. If a wire visits a position on the gr...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,191
AdventOfCode
MIT License
src/year2022/day08/Day08.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day08 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { fun part1(input: List<String>): Int { val dimension = input[0].length val visibility = Array(dimension) { Array(dimension) { false } } // edges always visible visibility.indices...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
3,471
advent-of-code-kotlin
Apache License 2.0
src/day04/Day04.kt
Ciel-MC
572,868,010
false
{"Kotlin": 55885}
package day04 import readInput fun main() { fun String.toRange(): IntRange { val (min, max) = this.split("-") return min.toInt() .. max.toInt() } fun String.toIntRanges(): Pair<IntRange, IntRange> { return this.split(",").let { (a, b) -> a.toRange() to b.toRange() } } op...
0
Kotlin
0
0
7eb57c9bced945dcad4750a7cc4835e56d20cbc8
979
Advent-Of-Code
Apache License 2.0
src/main/kotlin/com/dambra/adventofcode2018/day5/Polymer.kt
pauldambra
159,939,178
false
null
package com.dambra.adventofcode2018.day5 fun String.triggerPolymer(): String { val removedIndices = mutableSetOf<Int>() var triggeredPolymerCollapse: Boolean do { triggeredPolymerCollapse = false for (i in 0 until this.length) { val left = this[i] if (removedIndic...
0
Kotlin
0
1
7d11bb8a07fb156dc92322e06e76e4ecf8402d1d
3,493
adventofcode2018
The Unlicense
dcp_kotlin/src/main/kotlin/dcp/day310/day310.kt
sraaphorst
182,330,159
false
{"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315}
package dcp.day310 // day310.kt // By <NAME>, 2020. import kotlin.math.floor import kotlin.math.log2 import kotlin.math.pow /** * This is sequence A000788 in the Online Encyclopedia of Integer Sequences: * http://oeis.org/A000788 * It has a number of closed forms. We implement two below. */ /** * Brute force: c...
0
C++
1
0
5981e97106376186241f0fad81ee0e3a9b0270b5
1,460
daily-coding-problem
MIT License
src/day09/Day09.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day09 import readInputString data class Position(var x: Int, var y: Int) fun main() { fun moveHead(head: Position, direction: String) { when (direction) { "U" -> head.y++ "D" -> head.y-- "L" -> head.x-- "R" -> head.x++ } } fun moveK...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
3,032
Advent-Of-Code-2022
Apache License 2.0
2021/src/day11/day11.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day11 import java.io.File import java.lang.Integer.max import java.lang.Integer.min fun main() { val octoBoard = parseData(File("src/day11", "day11input.txt").readLines()) println(getAllFlashStep(octoBoard)) } fun getFlashCount(octoBoard: OctoBoard, stepCount: Int): Int { var sumFlashes = 0 ...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
3,569
adventofcode
Apache License 2.0
src/main/kotlin/github/walkmansit/aoc2020/Day10.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day10(val input: List<String>) : DayAoc<Int, Long> { private class AdaptersChain(val adapters: List<Int>) { fun findDiffMult(): Int { val set = adapters.toMutableSet() var oneDiff = 0 var threeDiff = 1 var current = ...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
1,733
AdventOfCode2020
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions52.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import com.qiaoyuang.algorithm.round0.BinaryTreeNode fun test52() { printlnResult(testCase()) } /** * Questions 52: Flat binary-search tree */ private fun <T : Comparable<T>> BinaryTreeNode<T>.flat(): BinaryTreeNode<T> = flatInternal().first private fun <T : Comparable<...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,386
Algorithm
Apache License 2.0
src/Day02.kt
maximilianproell
574,109,359
false
{"Kotlin": 17586}
fun main() { fun part1(input: List<String>): Int { val allPoints = input.sumOf { val (first, second) = it.split(" ") val opponent = Shape.decryptShape(first) val me = Shape.decryptShape(second) // my points for this move me.play(opponent) ...
0
Kotlin
0
0
371cbfc18808b494ed41152256d667c54601d94d
3,322
kotlin-advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day9.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days import kotlin.math.sign @AdventOfCodePuzzle( name = "Rope Bridge", url = "https://adventofcode.com/2022/day/9", date = Date(day = 9, year = 2022) ) class Day9(val input: List<String>) : Puzzle { private val instructions = input .map { line -> line.first() to line.substringAfter('...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,464
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/days/Day2.kt
jgrgt
575,475,683
false
{"Kotlin": 94368}
package days enum class Hand { ROCK, PAPER, SCISSORS; companion object { fun from(l: String): Hand { return when (l) { "A" -> ROCK "B" -> PAPER "C" -> SCISSORS "X" -> ROCK "Y" -> PAPER "Z" -> SC...
0
Kotlin
0
0
5174262b5a9fc0ee4c1da9f8fca6fb86860188f4
3,591
aoc2022
Creative Commons Zero v1.0 Universal
src/Day07.kt
spaikmos
573,196,976
false
{"Kotlin": 83036}
import java.util.LinkedList fun main() { // Ingest the list of input commands to generate file structure tree fun buildTree(input: List<String>): TreeNode { val rootDir = TreeNode("root", 0, FileType.DIR) var curDir = rootDir val it = input.iterator() while (it.hasNext()) { ...
0
Kotlin
0
0
6fee01bbab667f004c86024164c2acbb11566460
3,805
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day5.kt
broersma
574,686,709
false
{"Kotlin": 20754}
package days import kotlin.collections.ArrayDeque class Day5 : Day(5) { override fun partOne(): String { val input = inputString.split("\n\n") val stacks = input[0].split("\n") .reversed() .drop(1) .map { it...
0
Kotlin
0
0
cd3f87e89f7518eac07dafaaeb0f6adf3ecb44f5
2,317
advent-of-code-2022-kotlin
Creative Commons Zero v1.0 Universal
src/shreckye/coursera/algorithms/Course 1 Programming Assignment #4.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.util.* import kotlin.collections.ArrayList val filename = args[0] class Vertex(val label: Int, val edges: MutableList<Edge>) class Edge(var vertex1: Vertex, var vertex2: Vertex) /*@Suppress("NOTHING_TO_INLINE") inline fun <T> Array<T>.getVertex(vertexLabel: Int) = ge...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
2,949
coursera-stanford-algorithms-solutions-kotlin
MIT License
src/main/kotlin/day5B.kt
zlataovce
726,171,765
false
{"Kotlin": 10762}
import kotlin.math.max import kotlin.math.min fun main() = println( generateSequence(::readLine) .joinToString("\n") .split("\n\n") .let { p -> Pair( p[0].substringAfter(": ") .split(' ') .map(String::toLong), ...
0
Kotlin
0
2
0f5317f87615ad646e390eca33973f527dc8b72b
2,320
aoc23
The Unlicense
20/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : Image { val input = File("input.txt") .readText() .split("""\r\n\r\n""".toRegex()) val enhancementAlgo = input[0] val pixels = input[1].split("\r\n").filter { it.isNotEmpty() } return Image(enhancementAlgo, pixels) } const val ALGO_STEPS = 2 cla...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
2,980
advent-of-code-2021
MIT License
src/Day05.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") private const val DAY = "05" private const val PART1_CHECK = "CMZ" private const val PART2_CHECK = "MCD" private typealias Stacks = MutableList<MutableList<Char>> private fun splitInput(input: List<String>): Pair<List<String>, List<String>> { val partA = mutableListOf<String>() ...
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
3,014
adventofcode2022
Apache License 2.0
src/Day09.kt
Vlisie
572,110,977
false
{"Kotlin": 31465}
import java.io.File import kotlin.math.absoluteValue import kotlin.math.sign class Day09(file: File) { val tailList = mutableListOf<Coordinate>() val motionList = file.readLines() .map { Motion(Direction.withFirstLetter(it[0]), it.substring(2).toInt()) } fun part1(): Int { return moveHead(...
0
Kotlin
0
0
b5de21ed7ab063067703e4adebac9c98920dd51e
3,638
AoC2022
Apache License 2.0
src/main/kotlin/year2015/Day06.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2015 import utils.Point2D import kotlin.math.max class Day06 { fun part1(input: String) = solution( input, mapOf( "turn on " to { _: Int -> 1 }, "turn off " to { _: Int -> 0 }, "toggle " to { i: Int -> 1 - i }, ) ) fun part2(input: String) ...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
1,200
aoc-2022
Apache License 2.0
src/leetcodeProblem/leetcode/editor/en/BestTimeToBuyAndSellStockIi.kt
faniabdullah
382,893,751
false
null
//You are given an integer array prices where prices[i] is the price of a given //stock on the iᵗʰ day. // // On each day, you may decide to buy and/or sell the stock. You can only hold //at most one share of the stock at any time. However, you can buy it then //immediately sell it on the same day. // // Find and r...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,832
dsa-kotlin
MIT License
src/main/kotlin/com/gitTraining/Fibbonaci.kt
samjdixon
278,647,267
true
{"Kotlin": 4663}
package com.gitTraining fun computeFibbonaciNumber(position: Int, recursion: Boolean = false): Int { if (recursion) return recursiveFibbonachi(position) if (position == 0) return 0 if (position < 0) { val positionIsOdd = position % 2 == -1 return if (positionIsOdd) computeFibbonaciNumber(-...
0
Kotlin
0
0
c5ab05f71d7015a825144b428c73aa035fe47e88
1,706
git-training
MIT License
src/main/kotlin/io/queue/PerfectSquares.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.queue import java.util.* import kotlin.math.pow // https://leetcode.com/explore/learn/card/queue-stack/231/practical-application-queue/1371/ class PerfectSquares { fun execute(input: Int): Int { val stack = Stack<List<Int>>() var steps = 1 stack.add(listOf(input)) val perfectNumbers = g...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,258
coding
MIT License
src/commonMain/kotlin/com/dogeweb/fuzzymatcher/function/ScoringFunction.kt
dogeweb
558,010,459
false
{"Kotlin": 106948}
package com.dogeweb.fuzzymatcher.function import com.dogeweb.fuzzymatcher.domain.Match import com.dogeweb.fuzzymatcher.domain.Score import kotlin.math.pow /** * A functional interface to get a score between 2 Match objects */ typealias ScoringFunction = (Match<*>, List<Score>) -> Score object ScoringFunctions { ...
0
Kotlin
0
0
1d636b9b941441d92881ad36b149b3f14b2df9bd
5,515
fuzzy-matcher-kt
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2023/Day3.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2023 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.XY import com.s13g.aoc.resultFrom /** * --- Day 3: Gear Ratios --- * https://adventofcode.com/2023/day/3 */ class Day3 : Solver { override fun solve(lines: List<String>): Result { val schematic = Schematic(...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,295
euler
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BinaryTreePruning.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,095
kotlab
Apache License 2.0
src/Day10.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
fun main() { @Suppress("unused") fun log(message: Any?) { println(message) } fun scanAndDoStuff(input: List<String>, doStuff: (Int, Int) -> Unit) { var cycle = 1 var x = 1 // shove an extra noop before every addx to make the cycle counts simpler input.flatMap { ...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
1,892
aoc2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day08.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.zeros import org.jetbrains.kotlinx.multik.ndarray.data.* import org.jetbrains.kotlinx.multik.ndarray.operations.any import...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
3,681
advent-of-code-kotlin
MIT License
src/main/kotlin/roundC2021/rockpaperscissors-analysis.kt
kristofersokk
422,727,227
false
null
package roundC2021 import kotlin.random.Random.Default.nextDouble fun main() { // prod() // test(40, 40) // test(40, 20) // test(40, 4) // test(40, 0) // val seq1 = RPS.getListFromString("RSP".repeat(20)) // testSequence(seq1, 40, 40) // testSequence(seq1, 40, 20) // testSequence(seq1, 40, ...
0
Kotlin
0
0
3ebd59df60ee425b7af86a147f49361dc56ee38d
5,058
Google-coding-competitions
MIT License
src/main/kotlin/g0101_0200/s0120_triangle/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0101_0200.s0120_triangle // #Medium #Array #Dynamic_Programming #Algorithm_I_Day_12_Dynamic_Programming // #Dynamic_Programming_I_Day_13 #Udemy_Dynamic_Programming // #2022_10_08_Time_194_ms_(97.87%)_Space_40_MB_(71.28%) class Solution { fun minimumTotal(triangle: List<List<Int>>): Int { if (tria...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,083
LeetCode-in-Kotlin
MIT License
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day23.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwenty import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.max import fr.outadoc.aoc.scaffold.readDayInput class Day23 : Day<Long> { /** * @param cups map of cup value to next cup value in the cyclic list */ private data class State(val cups: MutableMap<In...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
3,069
adventofcode
Apache License 2.0
src/test/kotlin/Day21.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe /* --- Day 21: Allergen Assessment --- See https://adventofcode.com/2020/day/21 */ fun List<FoodInformation>.findIngredientsWithoutAllergens(): List<String> { val allergensUniqueInIngredients = findAllergensUniqueInIngredients() ...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
7,100
advent_of_code_2020
Apache License 2.0
src/main/kotlin/year2022/Day08.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils.test fun main() { data class Tree(val x: Int, val y: Int, val height: Int, var visible: Boolean = false, var scenic: Int = 0) fun part1(input: String, debug: Boolean = false): Long { val treeMap = input.lines().mapIndexed { y, row -> row.mapIndexed { x, c -> ...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
4,974
aoc-2022-kotlin
Apache License 2.0
src/day14.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import kotlin.system.exitProcess private const val DAY = 14 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: String -> x.toList() } val input = loadInput(DAY, false...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
4,315
aoc2023
MIT License
Day_09/Solution_Part2.kts
0800LTT
317,590,451
false
null
import java.io.File import java.io.BufferedReader import java.math.BigInteger fun File.readData(): Array<BigInteger> = readLines().map { it.toBigInteger() }.toTypedArray() fun isValid(array: Array<BigInteger>, start: Int, end: Int, target: BigInteger) : Boolean { val complementMap = mutableMapOf<BigInteger, B...
0
Kotlin
0
0
191c8c307676fb0e7352f7a5444689fc79cc5b54
1,894
advent-of-code-2020
The Unlicense
src/Day22.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
import java.util.* fun main() { val dr = intArrayOf(0, 1, 0, -1) val dc = intArrayOf(1, 0, -1, 0) val R = 0 val D = 1 val L = 2 val U = 3 fun solve(input: List<String>, wrap: (List<Int>) -> List<Int>): Any { val next = HashMap<List<Int>, List<Int>>() fun go(r: Int, c: Int, ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
5,682
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day8.kt
EmRe-One
434,793,519
false
{"Kotlin": 44202}
package tr.emreone.adventofcode.days object Day8 { fun part1(input: List<String>): Int { val regexHex = """(\\x[0-9a-fA-F]{2})""".toRegex() val regexEscaped = """(\\\\|\\")""".toRegex() return input.sumOf { val trimmed = it.substring(1, it.length - 1) val numberOfH...
0
Kotlin
0
0
57f6dea222f4f3e97b697b3b0c7af58f01fc4f53
1,652
advent-of-code-2015
Apache License 2.0
src/Day03.kt
ExpiredMinotaur
572,572,449
false
{"Kotlin": 11216}
fun main() { fun priority(input: Char): Int { return input.code - if (input.code < 97) 38 else 96 } fun part1(input: List<String>): Int { return input.map { it.chunked(it.length / 2).map { s -> s.toSet() } } .map { it[0] intersect it[1] } .sumOf { it.sumOf { item ->...
0
Kotlin
0
0
7ded818577737b0d6aa93cccf28f07bcf60a9e8f
857
AOC2022
Apache License 2.0
Algorithm/HackerRank/src/BigNumberMultiplication.kt
chaking
180,269,329
false
{"JavaScript": 118156, "HTML": 97206, "Jupyter Notebook": 93471, "C++": 19666, "Kotlin": 14457, "Java": 8536, "Python": 4928, "Swift": 3893, "Makefile": 2257, "Scala": 890, "Elm": 191, "CSS": 56}
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
JavaScript
0
0
a394f100155fa4eb1032c09cdc85816b7104804b
1,652
study
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ConstructBinaryTree.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,822
kotlab
Apache License 2.0
src/main/kotlin/g1801_1900/s1838_frequency_of_the_most_frequent_element/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1801_1900.s1838_frequency_of_the_most_frequent_element // #Medium #Array #Sorting #Greedy #Binary_Search #Prefix_Sum #Sliding_Window // #Binary_Search_II_Day_9 #2023_06_22_Time_564_ms_(88.89%)_Space_50.8_MB_(100.00%) class Solution { fun maxFrequency(nums: IntArray, k: Int): Int { countingSort(nu...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,241
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g0801_0900/s0823_binary_trees_with_factors/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0823_binary_trees_with_factors // #Medium #Array #Hash_Table #Dynamic_Programming // #2023_03_25_Time_298_ms_(100.00%)_Space_45.1_MB_(100.00%)dsecx class Solution { private val dp: MutableMap<Int, Long> = HashMap() private val nums: MutableMap<Int, Int> = HashMap() fun numFactoredBinar...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,395
LeetCode-in-Kotlin
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[110]平衡二叉树.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个二叉树,判断它是否是高度平衡的二叉树。 // // 本题中,一棵高度平衡二叉树定义为: // // // 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1 。 // // // // // 示例 1: // // //输入:root = [3,9,20,null,null,15,7] //输出:true // // // 示例 2: // // //输入:root = [1,2,2,3,3,null,null,4,4] //输出:false // // // 示例 3: // // //输入:root = [] //输出:true // // // // // 提示: // ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,710
MyLeetCode
Apache License 2.0
src/Day01.kt
MixusMinimax
572,717,459
false
{"Kotlin": 2016}
data class Elf(val snacks: List<Int>) { val totalCalories: Int = snacks.sum() } fun main() { // Groups of snacks are separated by a blank line. fun parseElves(lines: List<String>): List<Elf> { val elves = mutableListOf<Elf>() var snacks = mutableListOf<Int>() for (line in lines) { ...
0
Kotlin
0
0
b7066def6aab4d248aa411ea335fab9ce94ba929
1,353
advent-of-code-2022
Apache License 2.0
src/net/sheltem/aoc/y2023/Day13.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 import net.sheltem.common.rotateCockwise suspend fun main() { Day13().run() } class Day13 : Day<Long>(405, 400) { override suspend fun part1(input: List<String>): Long = input.joinToString("\n").split("\n\n").sumOf { it.mirrorSum() } override suspend fun part2(input: List<...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,598
aoc
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem605/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem605 /** * LeetCode page: [605. Can Place Flowers](https://leetcode.com/problems/can-place-flowers/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) where N is the size of flowerbed; */ fun canPlaceFlowers(flowerbed: IntArray, n: Int): Boolean { ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,955
hj-leetcode-kotlin
Apache License 2.0
src/main/day04/day04.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package day04 import fullyContains import overlapsWith import readInput fun part1(input: List<String>): Int = input.solve(IntRange::fullyContains) fun part2(input: List<String>): Int = input.solve(IntRange::overlapsWith) val regex by lazy { """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() } fun main() { val input = rea...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
756
aoc-2022
Apache License 2.0
src/main/kotlin/biz/koziolek/adventofcode/year2023/day24/day24.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day24 import biz.koziolek.adventofcode.* import java.time.LocalDateTime fun main() { val inputFile = findInput(object {}) val hails = parseHails(inputFile.bufferedReader().readLines()) println("Hails intersect ${countFutureIntersections(hails, testArea)} times in...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
6,494
advent-of-code
MIT License
src/day3/Day3.kt
ZsemberiDaniel
159,921,870
false
null
package day3 import RunnablePuzzleSolver class Day3 : RunnablePuzzleSolver { private val fabricSize = 1000 private lateinit var claims: List<Claim> override fun readInput1(lines: Array<String>) { // splitting by all the delimiters and mapping to Claim objects claims = lines.map { ...
0
Kotlin
0
0
bf34b93aff7f2561f25fa6bd60b7c2c2356b16ed
2,532
adventOfCode2018
MIT License
src/main/kotlin/g2701_2800/s2711_difference_of_number_of_distinct_values_on_diagonals/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2701_2800.s2711_difference_of_number_of_distinct_values_on_diagonals // #Medium #Array #Hash_Table #Matrix #2023_07_31_Time_281_ms_(100.00%)_Space_44.5_MB_(70.00%) class Solution { fun differenceOfDistinctValues(grid: Array<IntArray>): Array<IntArray> { val m = grid.size val n = grid[0].s...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,927
LeetCode-in-Kotlin
MIT License
src/Day20.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day20 import patriker.utils.* import java.util.LinkedList fun main(){ val testInput = readInput("Day20_test") val input = readInput("Day20_input") solvePart1(testInput) println(solvePart1(input)) } fun solvePart1(input: List<String>): Int{ val encodedCoords = input.mapIndexe...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
1,472
aoc2022
Apache License 2.0
Kotlin for Java Developers. Week 3/Taxi Park/Task/src/taxipark/TaxiParkTask.kt
obarcelonap
374,972,699
false
null
package taxipark /* * Task #1. Find all the drivers who performed no trips. */ fun TaxiPark.findFakeDrivers(): Set<Driver> = allDrivers.filter { findTrips(it).isEmpty() } .toSet() /* * Task #2. Find all the clients who completed at least the given number of trips. */ fun TaxiPark.findFaithfulPassenger...
0
Kotlin
0
0
d79103eeebcb4f1a7b345d29c0883b1eebe1d241
2,579
coursera-kotlin-for-java-developers
MIT License
src/Day05SupplyStacks.kt
zizoh
573,932,084
false
{"Kotlin": 13370}
fun main() { val input: List<String> = readInput("input/day05") val stacks = getStacks(input) rearrangeCrates(getRearrangementProcedure(input), stacks) println(getCratesOnTopOfStack(stacks)) } private fun getStacks(input: List<String>): Map<String, MutableList<String>> { val stacks = mutableMapOf<S...
0
Kotlin
0
0
817017369d257cca648974234f1e4137cdcd3138
2,157
aoc-2022
Apache License 2.0
src/Day08.kt
YunxiangHuang
572,333,905
false
{"Kotlin": 20157}
import kotlin.math.max fun main() { class Node(h: Char) { var up = -1; var down = -1; var left = -1; var right = -1; val height = h.toString().toInt(); fun isVisiable(): Boolean { return height > up || height > down || height > left || height > right ...
0
Kotlin
0
0
f62cc39dd4881f4fcf3d7493f23d4d65a7eb6d66
3,285
AoC_2022
Apache License 2.0
src/main/kotlin/day17/Day17ReservoirResearch.kt
Zordid
160,908,640
false
null
package day17 import shared.extractAllPositiveInts import shared.measureRuntime import shared.readPuzzle abstract class Clay { abstract val minY: Int abstract val maxY: Int abstract val minX: Int abstract val maxX: Int abstract fun isClay(tX: Int, tY: Int): Boolean } data class HClay(val x: Int, ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
4,417
adventofcode-kotlin-2018
Apache License 2.0
src/main/kotlin/dev/phiber/aoc2022/day3/Solution.kt
rsttst
572,967,557
false
{"Kotlin": 7688}
package dev.phiber.aoc2022.day3 import dev.phiber.aoc2022.readAllLinesUntilEmpty fun itemPriority(item: Char) : Int = if (item < 'a') { (item - 'A') + 27 } else { (item - 'a') + 1 } fun main() { val lines: List<String> = readAllLinesUntilEmpty() val doubleCompartmentItems: List<Char> = lines ...
0
Kotlin
0
0
2155029ebcee4727cd0af75543d9f6f6ab2b8995
1,169
advent-of-code-2022
Apache License 2.0
corneil/common/src/main/kotlin/permute.kt
jensnerche
317,661,818
true
{"HTML": 2739009, "Java": 348790, "Kotlin": 271053, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust":...
package com.github.corneil.aoc2019.common import java.math.BigInteger // found on https://rosettacode.org/wiki/Permutations#Kotlin fun <T> permute(input: List<T>): List<List<T>> { if (input.isEmpty()) return emptyList() if (input.size == 1) return listOf(input) val perms = mutableListOf<List<T>>() val...
0
HTML
0
0
a84c00ddbeb7f9114291125e93871d54699da887
1,732
aoc-2019
MIT License
src/Day05.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import java.util.Stack val MOVE_REGEX = Regex("move\\s(\\d+)\\sfrom\\s(\\d+)\\sto\\s(\\d+)") fun main() { fun createStackList(input: List<String>, blankLineNumber: Int): List<Stack<Char>> { val stackList = mutableListOf<Stack<Char>>() for (i in (0..blankLineNumber - 2).reversed()) { va...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
2,804
AdventOfCode2022
Apache License 2.0
Round 1C - A. Ample Syrup/src/app.kt
amirkhanyana
110,548,909
false
{"Kotlin": 20514}
import java.util.* fun main(args: Array<String>) { val input = Scanner(System.`in`) val T = input.nextInt() var Ti = 1 while (Ti <= T) { val N = input.nextInt() val K = input.nextInt() val pancakes = Array(N, { Pair(input.nextInt(), input.nextInt()) }) val pancakesByCyli...
0
Kotlin
0
0
25a8e6dbd5843e9d4a054d316acc9d726995fffe
2,118
Google-Code-Jam-2017-Problem-Kotlin-Solutions
The Unlicense
src/main/kotlin/days/Day23.kt
sicruse
315,469,617
false
null
package days class Day23 : Day(23) { val initalCupLabels = inputString.map { c -> c.toString().toInt() } private class CupGame(sample: List<Int>, size: Int = sample.size): Items(size) { init { currentItem = items[sample.first()] val itemsInOrder = sample + (sample.size + 1 .. ...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
2,561
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
2017/src/main/kotlin/Day08.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
import utils.splitNewlines import utils.splitWhitespace object Day08 { fun part1(input: String): Int { val registers = mutableMapOf<String, Int>().withDefault { 0 } val instructions = input.splitNewlines().map(this::parseInstruction) for (instruction in instructions) { execute(registers, instructi...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
2,442
advent-of-code
MIT License
solutions/src/ValidPathOnGrid.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
/** * https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid/ */ class ValidPathOnGrid { fun hasValidPath(grid: Array<IntArray>) : Boolean { val queue = mutableListOf(Pair(0,0)) val visited = mutableSetOf<Pair<Int,Int>>() while (queue.isNotEmpty()) { val curren...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
2,739
leetcode-solutions
MIT License
year2022/src/main/kotlin/net/olegg/aoc/year2022/day5/Day5.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day5 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2022.DayOf2022 /** * See [Year 2022, Day 5](https://adventofcode.com/2022/day/5) */ object Day5 : DayOf2022(5) { private val NUM_PATTERN = "(\\d)".toRegex() private val COMMAND_PATTERN = "move (\\d+) from (\\d+) to...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,947
adventofcode
MIT License
src/main/kotlin/com/kishor/kotlin/algo/algorithms/divideandconquer/MergeSort.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.algorithms.divideandconquer val inputArray = arrayOf(9, 1, -4, 5, 8, -2, 10) val sorted = Array<Int>(inputArray.size) { 0 } fun main() { MergeSort().mergeSort(0, inputArray.size - 1) inputArray.forEach { println("$it") } } class MergeSort { fun mergeSort(low: I...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,187
DS_Algo_Kotlin
MIT License
advent2022/src/main/kotlin/year2022/Day25.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay import kotlin.math.pow private fun Char.parseSnafuDigit() = when (this) { '2' -> 2L '1' -> 1L '0' -> 0L '-' -> -1L '=' -> -2L else -> error("unexpected Snafu digit") } fun String.parseSnafuNumber(): Long = map { it.parseSnafuDigit() }.reversed().reduceInd...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
1,129
advent-of-code
Apache License 2.0
src/Day05.kt
jordan-thirus
573,476,470
false
{"Kotlin": 41711}
fun main() { fun buildCrateStacks( input: List<String>, instructionSplitIndex: Int ): MutableList<MutableList<Char>> { val crateStacks: MutableList<MutableList<Char>> = mutableListOf() for (line in input.subList(0, instructionSplitIndex - 1)) { //println(line) ...
0
Kotlin
0
0
59b0054fe4d3a9aecb1c9ccebd7d5daa7a98362e
2,800
advent-of-code-2022
Apache License 2.0
src/Day08.kt
WilsonSunBritten
572,338,927
false
{"Kotlin": 40606}
fun main() { fun part1(input: List<String>): Int { val rows = input.size val columns = input.first().toList().size val map: List<List<Int>> = input.map { row -> row.toList().map { it.digitToInt() }} val visibleMap = mutableMapOf<Pair<Int, Int>, Boolean>() // visible from ...
0
Kotlin
0
0
363252ffd64c6dbdbef7fd847518b642ec47afb8
4,596
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/days/aoc2022/Day19.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day import kotlin.math.max class Day19 : Day(2022, 19) { override fun partOne(): Any { return determineSumOfBlueprintQualityLevels(inputList, 24) } override fun partTwo(): Any { return 0 } fun determineSumOfBlueprintQualityLevels(input: List<Strin...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
6,570
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day21.kt
wgolyakov
572,463,468
false
null
import kotlin.math.absoluteValue fun main() { fun parse(input: List<String>): Pair<MutableMap<String, Long>, MutableMap<String, List<String>>> { val values = mutableMapOf<String, Long>() val actions = mutableMapOf<String, List<String>>() for (line in input) { val (name, expr) = line.split(": ") if (expr[0...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
2,914
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxProductDifference.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,889
kotlab
Apache License 2.0
src/main/kotlin/Day11.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.* fun main() { val input = readFileAsList("Day11") println(Day11.part1(input)) println(Day11.part2(input)) } object Day11 { fun part1(input: List<String>): Long { val monkeys = parseMonkeys(input) repeat(20) { for (monkey in monkeys) { for ...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
5,072
advent-of-code-2022
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day21/MonkeyMath.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day21 import com.barneyb.aoc.util.Solver import com.barneyb.aoc.util.toLong import com.barneyb.aoc.util.toSlice import com.barneyb.util.HashSet fun main() { Solver.execute( ::parse, ::rootYellsWhat, // 82,225,382,988,628 ::whatToYell, // 3,429,411,069,028 ...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
3,896
aoc-2022
MIT License
src/test/kotlin/com/igorwojda/list/sort/quicksort/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.list.sort.quicksort // Time complexity (Best): Ω(n log(n)) // Time complexity (Average): Θ(l log(n)) // Time complexity (Worst): O(n^2) // Space complexity: O(log(n)) private object Solution1 { private fun quickSort(list: MutableList<Int>, left: Int = 0, right: Int = list.lastIndex): List<Num...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
3,030
kotlin-coding-challenges
MIT License
kotlin/src/main/kotlin/AoC_Day22.kt
sviams
115,921,582
false
null
import kotlin.collections.HashMap object AoC_Day22 { // So...in Kotlin, Map<K,V> is actually a LinkedHashMap behind the scenes // because JetBrains want to preserve order, which might be useful when doing // transformations from List -> Map -> List or whatever. // It is however most harmful to inserti...
0
Kotlin
0
0
19a665bb469279b1e7138032a183937993021e36
4,068
aoc17
MIT License
src/Day10.kt
mihansweatpants
573,733,975
false
{"Kotlin": 31704}
import java.lang.IllegalStateException import kotlin.math.abs fun main() { fun part1(instructions: List<CPUInstruction>): Int { val interestingCycles = setOf(20, 60, 100, 140, 180, 220) var sumOfInterestingSignalStrengths = 0 var register = 1 var currentCycle = 0 for (inst...
0
Kotlin
0
0
0de332053f6c8f44e94f857ba7fe2d7c5d0aae91
2,521
aoc-2022
Apache License 2.0
src/Day08.kt
maciekbartczak
573,160,363
false
{"Kotlin": 41932}
fun main() { fun part1(input: List<String>): Int { val grid = makeGrid(input) return getVisibleTrees(grid) } fun part2(input: List<String>): Int { val grid = makeGrid(input) return grid .flatMapIndexed { y, row -> List(row.size) { x -> ...
0
Kotlin
0
0
53c83d9eb49d126e91f3768140476a52ba4cd4f8
3,334
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/freekdb/aoc2019/Day06.kt
FreekDB
228,241,398
false
null
package com.github.freekdb.aoc2019 import java.io.File private const val CENTER_OF_MASS = "COM" private const val SANTA = "SAN" private const val YOU = "YOU" // https://adventofcode.com/2019/day/6 fun main() { val orbitMap = mutableMapOf<String, MutableList<String>>() val reverseOrbitMap = mutableMapOf<Strin...
0
Kotlin
0
1
fd67b87608bcbb5299d6549b3eb5fb665d66e6b5
2,055
advent-of-code-2019
Apache License 2.0
src/main/kotlin/days/Day14.kt
hughjdavey
159,955,618
false
null
package days class Day14 : Day(14) { override fun partOne(): Any { return recipeScoresAfter(inputString.trim().toInt()) } override fun partTwo(): Any { println("// Day 14 Part 2 takes about 9 seconds...") return recipeScoresBefore(inputString.trim()) } data class Elf(var ...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
2,705
aoc-2018
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/PossiblyEquals.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,762
kotlab
Apache License 2.0
src/me/anno/knoq/KNoqSolver.kt
AntonioNoack
504,659,355
false
null
package me.anno.knoq import me.anno.Engine import me.anno.utils.strings.StringHelper.levenshtein import java.util.* fun findIsEqual(rules: List<Rule>, input: String, output: String, maxTries: Int) = findIsEqual(rules, KNoqLang.parse(input), KNoqLang.parse(output), maxTries) fun findIsEqual(rules: List<Rule>, inp...
0
Kotlin
0
0
e163430c52f92fa71a32052c72581076e3f1ae71
3,097
KNoq
Apache License 2.0
src/main/kotlin/codes/jakob/aoc/solution/Day06.kt
The-Self-Taught-Software-Engineer
433,875,929
false
{"Kotlin": 56277}
package codes.jakob.aoc.solution object Day06 : Solution() { override fun solvePart1(input: String): Any { return simulateDays(parseInput(input), 80) } override fun solvePart2(input: String): Any { return simulateDays(parseInput(input), 256) } private fun simulateDays(initialTimer...
0
Kotlin
0
6
d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c
1,336
advent-of-code-2021
MIT License
solution/kotlin/day20/src/main/kotlin/domain/yahtzee/original/YahtzeeCalculator.kt
advent-of-craft
721,598,788
false
{"Java": 240720, "C#": 208054, "Kotlin": 162843, "TypeScript": 162359, "Shell": 16244, "JavaScript": 10227}
package domain.yahtzee.original object YahtzeeCalculator { private const val ROLL_LENGTH = 5 private const val MINIMUM_DIE = 1 private const val MAXIMUM_DIE = 6 fun number(dice: IntArray, number: Int): Int = calculate( { d -> d.filter { die -> die == number }.sum() }, dice ) fun three...
0
Java
60
71
3cc9e8b2c59963db97919b808a8285fbe3157c34
2,872
advent-of-craft
MIT License
06/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File const val LAST_DAY = 80 fun readInput() : List<Int> { return File("input.txt") .readLines() .flatMap { it.split(",") } .map { it.toInt() } } class LanternFishPopulation(timers : List<Int>) { companion object { const val MAX_TIMER = 8 co...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
1,231
advent-of-code-2021
MIT License
src/main/kotlin/dev/bogwalk/batch4/Problem46.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch4 import dev.bogwalk.util.maths.isPrime import dev.bogwalk.util.maths.primeNumbers import kotlin.math.floor import kotlin.math.sqrt /** * Problem 46: Goldbach's Other Conjecture * * https://projecteuler.net/problem=46 * * Goal: Return the number of ways an odd composite number, N, can be...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,587
project-euler-kotlin
MIT License
src/Day03.kt
tristanrothman
572,898,348
false
null
fun main() { fun Char.priority(): Int { return if (this.isLowerCase()) { this - 'a' + 1 } else { this - 'A' + 27 } } fun part1(input: List<String>): Int { return input.map { rucksack -> val compartmentSize = rucksack.length / 2 ...
0
Kotlin
0
0
e794ab7e0d50f22d250c65b20e13d9b5aeba23e2
986
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/supermarket/model/offers/BundleDiscountOffer.kt
vinaysshenoy
197,952,789
true
{"Kotlin": 92616, "C++": 16827, "Java": 13115, "C#": 12980, "TypeScript": 12246, "Ruby": 7985, "CMake": 1669}
package supermarket.model.offers import supermarket.ProductQuantities import supermarket.model.Discount import supermarket.model.Product import supermarket.model.ProductQuantity import supermarket.model.SupermarketCatalog data class BundleDiscountOffer( val bundle: Set<ProductQuantity>, val discountPercent: D...
1
Kotlin
0
0
015533297f1a84f3cd5e0f48d5fa37d09cf5b977
3,526
SupermarketReceipt-Refactoring-Kata
MIT License
src/main/kotlin/com/ginsberg/advent2023/Day03.kt
tginsberg
723,688,654
false
{"Kotlin": 112398}
/* * Copyright (c) 2023 by <NAME> */ /** * Advent of Code 2023, Day 3 - Gear Ratios * Problem Description: http://adventofcode.com/2023/day/3 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2023/day3/ */ package com.ginsberg.advent2023 class Day03(private val input: List<String>) { fu...
0
Kotlin
0
12
0d5732508025a7e340366594c879b99fe6e7cbf0
2,699
advent-2023-kotlin
Apache License 2.0
src/array/CodeSignam1.kt
develNerd
456,702,818
false
{"Kotlin": 37635, "Java": 5892}
package array import hackerankhone.solutionR import kotlin.math.absoluteValue fun main(){ //println(solution3(mutableListOf(2,4,7,5,3,5,8,5,1,7),4,10)) val m = "WhereIsJohn" val regex = Regex("[A-Z]") var finalString = "" m.forEachIndexed { index, char -> if(regex.matches(char.toString())...
0
Kotlin
0
0
4e6cc8b4bee83361057c8e1bbeb427a43622b511
2,498
Blind75InKotlin
MIT License
hacker-rank/strings/SpecialPalindromeAgain.kt
piazentin
62,427,919
false
{"Python": 34824, "Jupyter Notebook": 29307, "Kotlin": 19570, "C++": 2465, "R": 2425, "C": 158}
fun main() { readLine() // ignore first input val str = readLine().orEmpty() var count = 0L val freqTable = buildFreqTable(str) // all singles for (freq in freqTable) count += triangleNumber(freq.second) // all "middle" cases for (i in 0 until freqTable.size - 2) { if (freq...
0
Python
0
0
db490b1b2d41ed6913b4cacee1b4bb40e15186b7
1,048
programming-challenges
MIT License
2019/src/main/kotlin/y2019/D6.kt
ununhexium
113,359,669
false
null
package y2019 object D6 { fun parse(input: String): Map<String, String> { val parents = mutableMapOf<String, String>() input.split("\n").forEach { line -> // B orbits A val (A, B) = line.split(')') parents[B] = A } return parents } } object D6A { fun solve(parents: Map<String...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
1,484
adventofcode
The Unlicense
src/Day01.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currentCalories = 0 input.forEach { line -> if(line.isBlank()) { if(currentCalories > maxCalories) { println("$currentCalories is more than $maxCalories") ...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
1,222
advent-of-code-2022
Apache License 2.0
src/main/kotlin/io/math/DivideTwoIntegers.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.math import io.utils.runTests import kotlin.math.absoluteValue // https://leetcode.com/problems/divide-two-integers/ class DivideTwoIntegers { // Time O(logN) // Space O(logN) fun executeWithExtraSpace(dividendInput: Int, divisor: Int): Int { // Special case: overflow. if (dividendInput == ...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
3,237
coding
MIT License
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day13.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.shared.map import codes.jakob.aoc.shared.splitMultiline import codes.jakob.aoc.shared.toPair import com.google.gson.Gson class Day13 : Solution() { private val gson = Gson() override fun solvePart1(input: String): Any { val pairs = input .sp...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
1,823
advent-of-code-2022
MIT License