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/Day10.kt
lmoustak
573,003,221
false
{"Kotlin": 25890}
fun main() { val addPattern = Regex("""addx (-?\d+)""") fun part1(input: List<String>): Int { val targetCycles = mutableListOf(20, 60, 100, 140, 180, 220) var registerTotal = 0 var register = 1 var cycle = 1 for (line in input) { if (cycle > targetCycles[0])...
0
Kotlin
0
0
bd259af405b557ab7e6c27e55d3c419c54d9d867
1,729
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/dayfour/DayFour.kt
pauliancu97
619,525,509
false
null
package dayfour import getLines private val REGEX = """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() private data class Interval( val start: Int, val end: Int ) { fun isContaining(other: Interval): Boolean = this.start <= other.start && this.end >= other.end fun isOverlapping(other: Interval): Boolea...
0
Kotlin
0
0
78af929252f094a34fe7989984a30724fdb81498
1,990
advent-of-code-2022
MIT License
2021/kotlin/src/main/kotlin/aoc/days/Day5.kt
tupini07
76,610,908
false
{"Haskell": 35857, "Elixir": 22701, "Clojure": 20266, "Kotlin": 12288, "F#": 4426, "HTML": 4256, "CSS": 4163, "Dockerfile": 1374, "Shell": 963, "C#": 489, "TypeScript": 320, "Emacs Lisp": 299, "Makefile": 182}
package aoc.days import aoc.entities.Vector2d typealias Day5Input = List<Pair<Vector2d, Vector2d>> class Day5 : BaseDay<Day5Input>(5) { override fun prepareData(data: String): Day5Input = data.split("\n").filter { it.isNotEmpty() }.map { instruction -> val (pos1, pos2) = instr...
0
Haskell
0
0
4aee7ef03880e3cec9467347dc817b1db8a5fc0f
2,159
advent-of-code
MIT License
src/day11/Day11.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
package day11 import streamInput private val file = "Day11" //private val file = "Day11Example" sealed interface ItemOperationInput { fun getValue(oldValue: Long): Long object Old : ItemOperationInput { override fun getValue(oldValue: Long): Long { return oldValue } } d...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
4,911
aoc-2022
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2020/Day3.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2020 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.mul /** * --- Day 3: Toboggan Trajectory --- * https://adventofcode.com/2020/day/3 */ class Day3 : Solver { override fun solve(lines: List<String>): Result { val slopesB = listOf(Slope(1, 1), Slope(3, 1), ...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
976
euler
Apache License 2.0
src/main/kotlin/com/colinodell/advent2016/Day04.kt
colinodell
495,627,767
false
{"Kotlin": 80872}
package com.colinodell.advent2016 class Day04(val input: List<String>) { fun solvePart1(): Int { return input.map { Room.fromString(it) } .filter { it.isReal } .sumOf { it.sectorId } } fun solvePart2(): Int { return input.map { Room.fromString(it) } .fil...
0
Kotlin
0
0
8a387ddc60025a74ace8d4bc874310f4fbee1b65
1,979
advent-2016
Apache License 2.0
src/day14/Day14.kt
EndzeitBegins
573,569,126
false
{"Kotlin": 111428}
package day14 import readInput import readTestInput private data class Coordinate(val x: Int, val y: Int) private val Set<Coordinate>.minX get() = minOf { coordinate -> coordinate.x } private val Set<Coordinate>.minY get() = minOf { coordinate -> coordinate.y } private val Set<Coordinate>.maxX get() = maxOf { coordi...
0
Kotlin
0
0
ebebdf13cfe58ae3e01c52686f2a715ace069dab
6,117
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/g0301_0400/s0312_burst_balloons/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0312_burst_balloons // #Hard #Array #Dynamic_Programming #2022_11_09_Time_210_ms_(100.00%)_Space_35.2_MB_(100.00%) class Solution { fun maxCoins(nums: IntArray): Int { if (nums.size == 0) { return 0 } val dp = Array(nums.size) { IntArray(nums.size) } ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,200
LeetCode-in-Kotlin
MIT License
2019/06 - Universal Orbit Map/kotlin/src/app.kt
Adriel-M
225,250,242
false
null
import java.io.File import java.util.* fun main() { val edges = generateEdges("../input") println("===== Part 1 =====") println(runPart1(edges)) println("===== Part 2 =====") println(runPart2(edges)) } fun runPart1(edges: Map<String, Set<String>>): Int { val queue: Deque<Pair<String, Int>> = ...
0
Kotlin
0
0
ceb1f27013835f13d99dd44b1cd8d073eade8d67
2,327
advent-of-code
MIT License
src/main/kotlin/g0701_0800/s0778_swim_in_rising_water/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0778_swim_in_rising_water // #Hard #Array #Depth_First_Search #Breadth_First_Search #Binary_Search #Matrix // #Heap_Priority_Queue #Union_Find #2023_03_11_Time_190_ms_(100.00%)_Space_37_MB_(89.47%) import java.util.LinkedList import java.util.Queue class Solution { private val dir = intArrayO...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,812
LeetCode-in-Kotlin
MIT License
aoc-2021/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentyone/Day06.kt
outadoc
317,517,472
false
{"Kotlin": 183714}
package fr.outadoc.aoc.twentytwentyone import fr.outadoc.aoc.scaffold.Day import fr.outadoc.aoc.scaffold.readDayInput class Day06 : Day<Long> { companion object { private const val MIN_DAY = 0L private const val MAX_DAY = 8L private const val RESET_DAY = 6L } private data class S...
0
Kotlin
0
0
54410a19b36056a976d48dc3392a4f099def5544
1,523
adventofcode
Apache License 2.0
src/main/kotlin/Day08.kt
nmx
572,850,616
false
{"Kotlin": 18806}
fun main(args: Array<String>) { class Tree(val height: Int) { var visited = false var viewScore = 0 override fun toString(): String { return "$height${if (visited) '*' else ' '} " } } fun countRows(input: List<String>): Int { return input.size } ...
0
Kotlin
0
0
33da2136649d08c32728fa7583ecb82cb1a39049
4,898
aoc2022
MIT License
2015/src/main/kotlin/de/skyrising/aoc2015/day7/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2015.day7 import de.skyrising.aoc.* private fun parse(input: PuzzleInput): MutableMap<String, List<String>> { val map = mutableMapOf<String, List<String>>() for (line in input.lines) { val parts = line.split(' ') val name = parts[parts.lastIndex] map[name] = par...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,814
aoc
MIT License
src/main/java/org/billthefarmer/solver/Solver.kt
billthefarmer
453,687,125
false
{"Java": 29517, "Kotlin": 3366, "HTML": 1565}
package org.billthefarmer.solver class Solver(private var g: List<String>, var y1: List<String>, var y2: List<String>, var y3: List<String>, private var gray: String) { // g green: is correct and in the correct position // y yellow: is in answer but not in the right position // ...
0
Java
3
12
6e2b9a3a138e835516c283e14161ff2a37f3ad2c
3,366
wordlesolver
Apache License 2.0
src/main/kotlin/day19/part1/Part1.kt
bagguley
329,976,670
false
null
package day19.part1 import day19.data val ruleMap: MutableMap<Int, Rule> = mutableMapOf() fun main() { val rules = parseRules(data[0].split("\n")) val input = parseInput(data[1].split("\n")) for (rule in rules) { ruleMap[rule.index] = rule } val valid = rules[0].validStrings(ruleMap) ...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
1,242
adventofcode2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/New21Game.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,718
kotlab
Apache License 2.0
solver/src/commonMain/kotlin/org/hildan/sudoku/solver/techniques/NFish.kt
joffrey-bion
9,559,943
false
{"Kotlin": 51198, "HTML": 187}
package org.hildan.sudoku.solver.techniques import org.hildan.sudoku.model.* object XWing : NFish("X-Wing", dimension = 2) object Swordfish : NFish("Swordfish", dimension = 3) object Jellyfish : NFish("Jellyfish", dimension = 4) object Squirmbag : NFish("Squirmbag", dimension = 5) open class NFish( private va...
0
Kotlin
0
0
441fbb345afe89b28df9fe589944f40dbaccaec5
3,697
sudoku-solver
MIT License
src/shreckye/coursera/algorithms/Course 3 Programming Assignment #1 Question 3.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.util.* val filename = args[0] val INDEX_LABEL_OFFSET = 1 val (numVertices, _, verticesEdges) = readUndirectedGraphVerticesArrayListSimplifiedEdgesFromEdges( filename, INDEX_LABEL_OFFSET ) data class VertexCost(val vertex: Int, val cost: Int) fun mstOverallCos...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
2,419
coursera-stanford-algorithms-solutions-kotlin
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem207/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem207 /** * LeetCode page: [207. Course Schedule](https://leetcode.com/problems/course-schedule/); */ class Solution { /* Complexity: * Time O(V+E) and Space O(V+E) where V equals numCourses and E is the size of prerequisites; */ fun canFinish(numCourses: Int, pr...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,525
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/days/Day10.kt
MisterJack49
574,081,723
false
{"Kotlin": 35586}
package days class Day10 : Day(10) { override fun partOne(): Any { val cpu = CPU() inputList.map { it.split(" ") } .map { Command.valueOf(it.first()) to if (it.first() == "addx") it.last().toInt() else 0 } .forEach { cpu.runCommand(it.first, it.second) } println("CP...
0
Kotlin
0
0
e82699a06156e560bded5465dc39596de67ea007
2,331
AoC-2022
Creative Commons Zero v1.0 Universal
archive/src/main/kotlin/com/grappenmaker/aoc/year15/Day19.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year15 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.asPair import com.grappenmaker.aoc.splitAt fun PuzzleSet.day19() = puzzle(day = 19) { val (rulesPart, molecule) = input.split("\n\n") val rules = rulesPart.lines().map { it.split(" => ").asPair() } fun P...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
2,184
advent-of-code
The Unlicense
src/main/kotlin/g0301_0400/s0399_evaluate_division/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0399_evaluate_division // #Medium #Array #Depth_First_Search #Breadth_First_Search #Graph #Union_Find #Shortest_Path // #2022_11_29_Time_183_ms_(91.49%)_Space_34.6_MB_(95.74%) @Suppress("kotlin:S6518") class Solution { private var root: MutableMap<String?, String?>? = null private var rate...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,300
LeetCode-in-Kotlin
MIT License
src/main/kotlin/de/tek/adventofcode/y2022/day08/TreeTopTreeHouse.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.day08 import de.tek.adventofcode.y2022.util.math.Direction import de.tek.adventofcode.y2022.util.math.Grid import de.tek.adventofcode.y2022.util.math.Point import de.tek.adventofcode.y2022.util.math.isIn import de.tek.adventofcode.y2022.util.readInputLines class TreeGrid(treeSizes: A...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
5,955
advent-of-code-2022
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/InsertionSortList.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 147. 对链表进行插入排序 * * 插入排序算法: * * 插入排序是迭代的,每次只移动一个元素,直到所有元素可以形成一个有序的输出列表。 * 每次迭代中,插入排序只从输入数据中移除一个待排序的元素,找到它在序列中适当的位置,并将其插入。 * 重复直到所有输入数据插入完为止。 * * 示例 1: * * 输入: 4->2->1->3 * 输出: 1->2->3->4 * 示例 2: * * 输入: -1->5->3->4->0 * 输出: -1->0->3->4->5 * */ class InsertionS...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,931
daily_algorithm
Apache License 2.0
src/main/kotlin/org/example/adventofcode/puzzle/Day02.kt
nikos-ds
573,046,617
false
null
package org.example.adventofcode.puzzle import org.apache.commons.lang3.StringUtils.isBlank import org.example.adventofcode.puzzle.RockPaperScissors.PAPER import org.example.adventofcode.puzzle.RockPaperScissors.ROCK import org.example.adventofcode.puzzle.RockPaperScissors.SCISSORS import org.example.adventofcode.util...
0
Kotlin
0
0
3f97096ebcd19f971653762fe29ddec1e379d09a
3,046
advent-of-code-2022-kotlin
MIT License
src/Day01.kt
inssein
573,116,957
false
{"Kotlin": 47333}
import java.util.PriorityQueue fun main() { fun part1(input: List<String>): Int { var max = 0 var current = 0 input.forEach { if (it.isEmpty()) { if (current > max) { max = current } current = 0 } ...
0
Kotlin
0
0
095d8f8e06230ab713d9ffba4cd13b87469f5cd5
1,113
advent-of-code-2022
Apache License 2.0
src/main/kotlin/adventofcode/year2020/Day08HandheldHalting.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2020 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.year2020.Day08HandheldHalting.Companion.Operation.ACC import adventofcode.year2020.Day08HandheldHalting.Companion.Operation.JMP import adventofcode.year2020.Day08HandheldHalting.Companion.Operation.NOP class D...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,437
AdventOfCode
MIT License
src/main/kotlin/com/github/dangerground/aoc2020/Day12.kt
dangerground
317,439,198
false
null
package com.github.dangerground.aoc2020 import com.github.dangerground.aoc2020.util.DayInput import kotlin.math.absoluteValue fun main() { val process = Day12(DayInput.asStringList(12)) println("result part 1: ${process.part1()}") println("result part 2: ${process.part2()}") } class Day12(val input: Lis...
0
Kotlin
0
0
c3667a2a8126d903d09176848b0e1d511d90fa79
3,188
adventofcode-2020
MIT License
algorithms/src/main/kotlin/com/kotlinground/algorithms/backtracking/permutations/generatePermutations.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.algorithms.backtracking.permutations import java.util.stream.Collectors /** * Generates permutations of the given letters and returns a list of all permutations. * Time Complexity * We have n letters to choose in the first level, n - 1 choices in the second level and so on therefore th...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
1,896
KotlinGround
MIT License
src/main/kotlin/PassagePathing_12.kt
Flame239
433,046,232
false
{"Kotlin": 64209}
val caveGraph: HashMap<String, MutableList<String>> by lazy { val paths = readFile("PassagePathing").split("\n").map { it.split("-").zipWithNext()[0] } val graph: HashMap<String, MutableList<String>> = HashMap() paths.forEach { graph.getOrPut(it.first) { mutableListOf() }.add(it.second) grap...
0
Kotlin
0
0
ef4b05d39d70a204be2433d203e11c7ebed04cec
2,131
advent-of-code-2021
Apache License 2.0
Maximal_Rectangle.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 /** * height[i] record the current number of countinous '1' in column i; * left[i] record the left most index j which satisfies that for any index k from j to i, height[k] >= height[i]; * right[i] record the right most index j which satifies that for any index k from i...
0
C++
0
0
eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134
2,957
leetcode
MIT License
src/Day06/Day06.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day06 import readInput import java.util.* fun firstUniqueIndex(input: String, sizeOfmarker: Int): Int { var elementsQueue = LinkedList<Char>() var elementsDictionary = mutableMapOf<Char, Int>() var duplicateElementsCount = 0 var index = 0 for (char in input) { elementsQueue.add(ch...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
1,573
advent-of-code-2022
Apache License 2.0
src/Day01.kt
hubikz
573,170,763
false
{"Kotlin": 8506}
fun main() { fun carriedCaloriesByTopElves(input: List<String>, elvesNbr: Int): Int { var elves = mutableListOf<MutableList<Int>>() var tmp = mutableListOf<Int>() for (caloric in input) { if (caloric.isNotEmpty()) { tmp.add(caloric.toInt()) } else { ...
0
Kotlin
0
0
902c6c3e664ad947c38c8edcb7ffd612b10e58fe
1,045
AoC2022
Apache License 2.0
aoc21/day_17/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File import kotlin.math.max data class Pos(val x: Int, val y: Int) data class Range(val min: Int, val max: Int) { fun contains(v: Int): Boolean = v >= min && v <= max } fun hit(x: Int, y: Int, xTarget: Range, yTarget: Range): Boolean { var pos = Pos(0, 0) var vel = Pos(x, y) while (true...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,163
advent-of-code
MIT License
src/main/kotlin/com/colinodell/advent2022/Day21.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 class Day21(input: List<String>) { private val monkeys = input .map { line -> val parts = line.split(":? ".toRegex()) if (parts.size == 2) { NumberMonkey(parts[0], parts[1].toLong()) } else { JobMonkey(par...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
3,799
advent-2022
MIT License
year2021/day14/part1/src/main/kotlin/com/curtislb/adventofcode/year2021/day14/part1/Year2021Day14Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 14: Extended Polymerization --- The incredible pressures at this depth are starting to put a strain on your submarine. The submarine has polymerization equipment that would produce suitable materials to reinforce the submarine, and the nearby volcanically-active caves should even have the necessary input el...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,450
AdventOfCode
MIT License
src/main/kotlin/g0701_0800/s0712_minimum_ascii_delete_sum_for_two_strings/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0712_minimum_ascii_delete_sum_for_two_strings // #Medium #String #Dynamic_Programming #2023_02_25_Time_176_ms_(100.00%)_Space_36.9_MB_(58.33%) class Solution { fun minimumDeleteSum(s1: String, s2: String): Int { val len1 = s1.length val len2 = s2.length val dp = Array(l...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,012
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/chriswk/aoc/advent2022/Day2.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2022 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report class Day2 : AdventDay(2022, 2) { companion object { @JvmStatic fun main(args: Array<String>): Unit { val day = Day2() report { day.part1() } ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
3,064
adventofcode
MIT License
src/test/kotlin/solutions/TaxCalculatorValidator.kt
daniel-rusu
669,564,782
false
{"Kotlin": 70755}
package solutions import dataModel.base.Money import dataModel.base.Money.Companion.dollars import dataModel.base.TaxBracket import dataModel.base.TaxCalculator import solutions.linear.LinearTaxCalculator import strikt.api.Assertion import strikt.api.expectThat import kotlin.random.Random private const val NUM_SAMPLE...
0
Kotlin
0
1
166d8bc05c355929ffc5b216755702a77bb05c54
2,559
tax-calculator
MIT License
src/main/kotlin/com.gjosquin.partyoptimizer/definitions/Constraints.kt
Oduig
197,274,049
true
{"Kotlin": 9737}
package com.gjosquin.partyoptimizer.definitions object Constraints { val groupHasATank: Constraint = { specs -> specs.any { it.canTank } } val groupHasAHealer: Constraint = { specs -> specs.any { it.canHeal } } val groupHasAHealerWhoIsNotTheOnlyTank: Constraint = { specs -> specs.any { ...
0
Kotlin
0
0
7be0ebefc97994b1420a22f674d364e378122965
1,567
party-optimizer
Apache License 2.0
Kotlin/problems/0023_redundant_connection.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
//Problem Statement // // In this problem, a tree is an undirected graph that is connected and has no cycles. // The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), // with one additional edge added. The added edge has two different vertices chosen // from 1 to N, and was...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,901
algorithms
MIT License
src/main/kotlin/d3/D3_2.kt
MTender
734,007,442
false
{"Kotlin": 108628}
package d3 import input.Input fun findGears(lines: List<String>): List<Pair<Int, Int>> { val gears = mutableListOf<Pair<Int, Int>>() for (i in lines.indices) { for (j in lines[i].indices) { val c = lines[i][j] if (c != '*') continue gears.add(Pair(i, j)) }...
0
Kotlin
0
0
a6eec4168b4a98b73d4496c9d610854a0165dbeb
2,343
aoc2023-kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountKDifference.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
1,882
kotlab
Apache License 2.0
src/aoc2022/Day05.kt
nguyen-anthony
572,781,123
false
null
package aoc2022 import utils.readInputAsList fun main() { fun part1(input: List<String>) : String { val split = input.indexOf("") val stacks = input.slice(0 until split) val instructionsList = input.slice(split+1 until input.size) val allStacks = mutableListOf<ArrayDeque<String>>(...
0
Kotlin
0
0
9336088f904e92d801d95abeb53396a2ff01166f
2,468
AOC-2022-Kotlin
Apache License 2.0
packages/solutions/src/Day02.kt
ffluk3
576,832,574
false
{"Kotlin": 21246, "Shell": 85}
import java.lang.Error enum class OpponentMove(val str: String) { A("rock"), B("paper"), C("scissors") } enum class PlayerMove(val str: String) { X("rock"), Y("paper"), Z("scissors") } enum class EndResult(val str: String) { X("lose"), Y("draw"), Z("win") } fun main() { fun...
0
Kotlin
0
0
f9b68a8953a7452d804990e01175665dffc5ab6e
3,449
advent-of-code-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day11.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.e fun main() = Day11.run() object Day11 : Day(2015, 11) { override fun part1() = nextValid(input) override fun part2() = nextValid(nextValid(input)) private fun nextValid(current: String): String { va...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,709
adventofkotlin
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[109]有序链表转换二叉搜索树.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树。 // // 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。 // // 示例: // // 给定的有序链表: [-10, -3, 0, 5, 9], // //一个可能的答案是:[0, -3, 9, -10, null, 5], 它可以表示下面这个高度平衡二叉搜索树: // // 0 // / \ // -3 9 // / / // -10 5 // // Related Topics 树 二叉搜索树 链表 分治 二叉树 // 👍 612 👎 0 //leetc...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,120
MyLeetCode
Apache License 2.0
src/Day03/Day03.kt
thmsbdr
574,632,643
false
{"Kotlin": 6603}
package Day03 import readInput fun main() { fun part1(input: List<String>): Int { var total = 0 input.forEach { s -> val compOne = s.substring(0, s.length / 2).toSet() run findFirst@{ s.substring(s.length / 2).toCharArray().forEach { if ...
0
Kotlin
0
0
b9ac3ed8b52a95dcc542f4de79fb24163f3929a4
1,390
AoC-2022
Apache License 2.0
hashcode/y2018/qual/Main.kt
winger
151,886,986
true
{"Java": 19887, "Python": 17946, "C++": 10397, "JavaScript": 2402, "Kotlin": 2355, "Lua": 711}
import java.io.File import java.io.PrintWriter import java.util.* //val filename = "a_example" //val filename = "b_should_be_easy" //val filename = "c_no_hurry" val filename = "d_metropolis" //val filename = "e_high_bonus" fun main(args: Array<String>) { val sc = Scanner(File("data/$filename.in")) val (_, _,...
0
Java
2
1
df24b920181ddcee443764e956191ffc097f581f
2,355
team-competitions
The Unlicense
kotlin/src/Day10.kt
ekureina
433,709,362
false
{"Kotlin": 65477, "C": 12591, "Rust": 7560, "Makefile": 386}
import java.lang.IllegalStateException import java.lang.Integer.parseInt import java.util.* fun main() { val illegalCharMap = mapOf( ')' to 3, ']' to 57, '}' to 1197, '>' to 25137 ) fun part1(input: List<String>): Int { return input.sumOf { line -> val s...
0
Kotlin
0
1
391d0017ba9c2494092d27d22d5fd9f73d0c8ded
4,135
aoc-2021
MIT License
src/main/kotlin/com/chriswk/aoc/advent2021/Day18.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import java.lang.Math.round import kotlin.math.roundToInt class Day18 : AdventDay(2021, 18) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day18() ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
5,852
adventofcode
MIT License
aoc-day12/src/Day12.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.nio.file.Files import java.nio.file.Path fun main() { val vertices = Files.readAllLines(Path.of("input")) .filter { it.isNotBlank() } .map { Vertex.parse(it) } val graph = Graph.build(vertices) val paths = part2(graph.start, setOf(graph.start), null) paths.forEach { path -> ...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
1,812
adventofcode2021
MIT License
src/com/hlq/leetcode/array/Question26.kt
HLQ-Struggle
310,978,308
false
null
package com.hlq.leetcode.array /** * @author HLQ_Struggle * @date 2020/11/30 * @desc LeetCode 26. 删除排序数组中的重复项 https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/ */ fun main() { val nums = intArrayOf(0,0,1,1,1,2,2,3,3,4) println("----> ${removeDuplicates(nums)}") } /** * 双指针解法 */ fun...
0
Kotlin
0
2
76922f46432783218ddd34e74dbbf3b9f3c68f25
1,242
LeetCodePro
Apache License 2.0
app/src/main/kotlin/day10/Day10.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day10 import common.InputRepo import common.readSessionCookie import common.solve import java.util.* val openToClosed = mapOf( '(' to ')', '[' to ']', '{' to '}', '<' to '>', ) fun main(args: Array<String>) { val day = 10 val input = InputRepo(args.readSessionCookie()).get(day = day) ...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
1,852
AdventOfCode2021
Apache License 2.0
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day13/Day13.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2015.day13 import nl.sanderp.aoc.common.permutations val preferences = mapOf( "Alice" to mapOf( "Bob" to 54, "Carol" to -81, "David" to -42, "Eric" to 89, "Frank" to -89, "George" to 97, "Mallory" to -94, ), "Bob" to mapOf( ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
2,292
advent-of-code
MIT License
src/main/java/hes/nonogram/RecursiveSolver.kt
Hes-Siemelink
689,215,071
false
{"Kotlin": 32733}
package hes.nonogram import hes.nonogram.State.EMPTY import hes.nonogram.State.FILLED class RecursiveSolver : PuzzleSolver { override fun solve(puzzle: Puzzle): Puzzle? { if (puzzle.isSolved()) { return puzzle } for (r in puzzle.rows.indices) { for (c in puzzle.r...
0
Kotlin
0
0
7b96e50eb2973e4e2a906cf20af743909f0ebc8d
4,897
Nonogram
MIT License
src/main/kotlin/me/peckb/aoc/_2018/calendar/day18/Day18.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2018.calendar.day18 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory class Day18 @Inject constructor(private val generatorFactory: InputGeneratorFactory) { fun partOne(filename: String) = generatorFactory.forFile(filename).read { input -> var ...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
2,922
advent-of-code
MIT License
kotlin/src/main/kotlin/dev/egonr/leetcode/02_AddTwoNumbers.kt
egon-r
575,970,173
false
null
package dev.egonr.leetcode /* Medium You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any lead...
0
Kotlin
0
0
b9c59e54ca2d1399d34d1ee844e03c16a580cbcb
3,834
leetcode
The Unlicense
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-10.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.CharGrid import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.contains import com.github.ferinagy.adventOfCode.get import com.github.ferinagy.adventOfCode.positionOfFirst import com.github.ferina...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,158
advent-of-code
MIT License
kotlin/src/katas/kotlin/leetcode/clone_graph/CloneGraph.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.clone_graph import datsok.shouldEqual import org.junit.Test class CloneGraphTests { @Test fun `clone single node`() { GraphNode(1).cloneGraph() shouldEqual GraphNode(1) } @Test fun `clone two nodes`() { UndirectedGraph.parse("1-2").nodes.first().cloneGraph()....
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,718
katas
The Unlicense
Kotlin/structures/seg_tree.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
class SegTree(val array: IntArray){ private var treeArray:MutableList<Int> private var arrSize: Int init{ treeArray = MutableList<Int>(4*array.size){0} initSegTree(array,0,0,array.size-1) arrSize = array.size println(treeArray) } private fun initSegTree(array: I...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
2,322
algorithms
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinReplacement.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,713
kotlab
Apache License 2.0
src/Lesson8Leader/EquiLeader.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
/** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { val N = A.size var count = 1 var candidate = A[0] // 1. Find a candidate, note: if there is a leader it will for sure be candidate for (i in 1 until N) { if (count == 0) candidate = A[i] if (A[i] == candidate...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
2,368
Codility-Kotlin
Apache License 2.0
src/main/kotlin/aoc22/Day12.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc22 import datastructures.Coordinate import getEntryAboveOrNull import getEntryBelowOrNull import getEntryLeftOrNull import getEntryRightOrNull import readInput import toAocCode import java.util.PriorityQueue import kotlin.math.abs data class Vertex( val position: Coordinate, val fScore: Int, ) dat...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
4,361
advent-of-code
Apache License 2.0
src/main/kotlin/adventofcode/day13.kt
Kvest
163,103,813
false
null
package adventofcode import java.io.File fun main(args: Array<String>) { first13(File("./data/day13_1.txt").readLines()) second13(File("./data/day13_2.txt").readLines()) } fun first13(data: List<String>) { val carts = mutableListOf<Cart>() data.forEachIndexed { i, row -> row.forEachIndexed { ...
0
Kotlin
0
0
d94b725575a8a5784b53e0f7eee6b7519ac59deb
6,868
aoc2018
Apache License 2.0
solutions/aockt/y2015/Y2015D22.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2015 import aockt.y2015.Y2015D22.Spell.* import io.github.jadarma.aockt.core.Solution object Y2015D22 : Solution { /** Parses the input and returns the initial [GameState] to simulate. */ private fun parseInput(input: List<String>) = GameState( playerHealth = 50, playerMana = 5...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
5,444
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/com/digitalreasoning/langpredict/util/NGramGenerator.kt
MJMalone
118,636,650
true
{"Kotlin": 44995, "Groovy": 29696}
package com.digitalreasoning.langpredict.util const val NGRAM_SIZE = 3 class NGramGenerator { fun generate(text: String): List<String> = text .map { CharacterNormalizer.normalize(it) } .joinToString("") .split(' ') .filter { it.length < 3 || it.any { !it.isUpperCase...
0
Kotlin
0
0
be5badebb71586a770cbda52cb223b1278537406
3,079
lang-predict
Apache License 2.0
Desafios/Kotlin/Primeiros passos em Kotlin/Carrefour Android Developer/Figurinhas/figurinhas.kt
shyoutarou
394,972,098
false
null
/* Ricardo e Vicente são aficionados por figurinhas. Nas horas vagas, eles arrumam um jeito de jogar um “bafo” ou algum outro jogo que envolva tais figurinhas. Ambos também têm o hábito de trocarem as figuras repetidas com seus amigos e certo dia pensaram em uma brincadeira diferente. Chamaram todos os amigos e propuse...
0
Java
50
184
b312f8f5e860802d558ad3a78c53850066c880f0
1,934
desafios-DIO
MIT License
src/Day01.kt
LtTempletonPeck
572,896,842
false
{"Kotlin": 1817}
fun main() { fun part1(input: List<String>): Int { return input .splitListByBlank() .maxOf { it.sum() } } fun part2(input: List<String>): Int { val sum = input .splitListByBlank() .map { it.sum() } .sortedDescending() ....
0
Kotlin
0
0
72ce7365f5543e6a45c76a5db46009a43510c398
1,169
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day12/Day12.kt
vitalir2
572,865,549
false
{"Kotlin": 89962}
package day12 import Challenge import java.util.PriorityQueue import utils.Coordinates private data class Heightmap( val startPoint: Point, val endPoint: Point, val points: List<Point>, ) { fun printPath(path: List<Point>) { val maxX = points.maxOf { it.coordinates.x } val maxY = poin...
0
Kotlin
0
0
ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6
5,476
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day17/part1/Part1.kt
bagguley
329,976,670
false
null
package day17.part1 import day17.data const val active = '#' var worldMap:MutableMap<String, Boolean> = mutableMapOf() fun main() { val input = data initWorld(input) advanceWorld() advanceWorld() advanceWorld() advanceWorld() advanceWorld() advanceWorld() println(worldMap.valu...
0
Kotlin
0
0
6afa1b890924e9459f37c604b4b67a8f2e95c6f2
2,552
adventofcode2020
MIT License
src/nativeMain/kotlin/Day8.kt
rubengees
576,436,006
false
{"Kotlin": 67428}
class Day8 : Day { private class Matrix(size: Int) { private val data: Array<Array<Int>> = (0 until size).map { arrayOfZeros(size) }.toTypedArray() operator fun set(x: Int, y: Int, value: Int) { this.data[x][y] = value } operator fun get(x: Int, y: Int): Int { ...
0
Kotlin
0
0
21f03a1c70d4273739d001dd5434f68e2cc2e6e6
2,677
advent-of-code-2022
MIT License
src/main/kotlin/com/groundsfam/advent/y2022/d24/Day24.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2022.d24 import com.groundsfam.advent.* import com.groundsfam.advent.points.Point import kotlin.io.path.div import kotlin.io.path.useLines class Solver(grid: List<String>) { private val width = grid[0].length private val height = grid.size var time = 0 private set ...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
3,107
advent-of-code
MIT License
src/adventofcode/blueschu/y2017/day03/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day03 import kotlin.test.assertEquals fun input(): Int = 289326 fun main(args: Array<String>) { assertEquals(0, part1(1)) assertEquals(3, part1(12)) assertEquals(2, part1(23)) assertEquals(31, part1(1024)) println("Part 1: ${part1(input())}") assertEquals(...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
4,004
Advent-Of-Code
MIT License
src/day10/Day10.kt
MaxBeauchemin
573,094,480
false
{"Kotlin": 60619}
package day10 import readInput import java.lang.Math.abs enum class CMDType { NOOP, ADDX } data class CMD(val type: CMDType, val arg: Int? = null) fun List<Boolean>.render() { this.chunked(40).forEach { row -> row.map { bool -> if (bool) "#" else "." }.also { prin...
0
Kotlin
0
0
38018d252183bd6b64095a8c9f2920e900863a79
2,794
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CanPartitionKSubsets.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,168
kotlab
Apache License 2.0
day08/main.kt
LOZORD
441,007,912
false
{"Kotlin": 29367, "Python": 963}
import java.util.Scanner fun main(args: Array<String>) { val digitsToWires: Array<Set<Char>> = arrayOf( // 0 setOf('a', 'b', 'c', 'e', 'f', 'g'), // 1 setOf('c', 'f'), // 2 setOf('a', 'c', 'd', 'e', 'g'), // 3 setOf('a', 'c', 'd', 'f', 'g'), /...
0
Kotlin
0
0
17dd266787acd492d92b5ed0d178ac2840fe4d57
5,626
aoc2021
MIT License
src/twentytwentythree/day05/Day05.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day05 import readInput fun main() { fun findMatchKey(map: Map<Pair<Long, Long>, Pair<Long, Long>>, seed: Long): Long { val entryMatch = map.entries.firstOrNull { it.key.first <= seed && it.key.second >= seed } return if (entryMatch != null) { val diff = seed - entryMatch.key....
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
5,373
advent-of-code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindSpecialInt.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,836
kotlab
Apache License 2.0
src/Day04.kt
Sasikuttan2163
647,296,570
false
null
fun main() { val input = readInput("Day04") val part1 = input.count { l -> val list = splitInTwo(l) (list[0][0] <= list[1][0] && list[0][1] >= list[1][1]) || (list[0][0] >= list[1][0] && list[0][1] <= list[1][1]) } val part2 = input.count { l -> val list = splitInTwo(l) (...
0
Kotlin
0
0
fb2ade48707c2df7b0ace27250d5ee240b01a4d6
708
AoC-2022-Solutions-In-Kotlin
MIT License
2022/Day08/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 data class Position(val row: Int, val col: Int) {} fun main(args: Array<String>) { val lines = File(args[0]).readLines() val forest = lines.map { it.toCharArray().map { it.code - '0'.code } } println(problem1(forest)) println(problem2(forest)) // println...
0
Rust
0
0
c265f4c0bddb0357fe90b6a9e6abdc3bee59f585
3,604
AdventOfCode
MIT License
2020/day3/day3.kt
Deph0
225,142,801
false
null
// data class Position(var x: Int = 1, var y: Int = 1) class day3 { fun part1(input: List<String>): Int { // first fumbeling attempt on grasping the task.. /*var treeMap: MutableList<String> = input.map { it.repeat(input.size+1) }.toMutableList() var pos = Position() for (y in 0..input.size-1) { ...
0
Kotlin
0
0
42a4fce4526182737d9661fae66c011f0948e481
16,395
adventofcode
MIT License
src/chapter3/section3/ex5&6.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter3.section3 import chapter1.section4.factorial import chapter2.sleep import chapter3.section2.fullArray import edu.princeton.cs.algs4.StdDraw import extensions.formatDouble /** * 3.3.5: 右图显示了N=1到6之间大小为N的所有不同的2-3树(无先后次序) * 请画出N=7、8、9和10的大小为N的所有不同的2-3树 * 3.3.6: 计算用N个随机键构造练习3.3.5中每棵2-3树的概率 * * 解:参考练习3...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
2,498
Algorithms-4th-Edition-in-Kotlin
MIT License
aoc_2023/src/main/kotlin/problems/day3/Gondola.kt
Cavitedev
725,682,393
false
{"Kotlin": 228779}
package problems.day3 class Gondola(val symbolNumbers: List<SymbolNumbers>) { companion object { val symbolRegex = Regex("""[^\d.]""") fun fromLines(lines: List<String>): Gondola { val symbolNumbers = mutableListOf<SymbolNumbers>() for (i in lines.indices) { ...
0
Kotlin
0
1
aa7af2d5aa0eb30df4563c513956ed41f18791d5
2,826
advent-of-code-2023
MIT License
src/main/kotlin/leetcode/kotlin/Important Code Snippets.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin import java.util.concurrent.TimeUnit // using comparator private fun sortArray(twoDArray: Array<IntArray>) { // 1 twoDArray.sortWith(kotlin.Comparator { t1, t2 -> t1[1] - t2[1] }) // 2 twoDArray.sortWith(object : Comparator<IntArray> { override fun compare(p0: IntArra...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
2,953
kotlinmaster
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/remove_duplicates_from_array/RemoveDuplicatesFromSortedArray.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.remove_duplicates_from_array import datsok.shouldEqual import org.junit.Test /** * https://leetcode.com/problems/remove-duplicates-from-sorted-array/ */ class RemoveDuplicatesFromSortedArrayTests { @Test fun `remove the duplicates in-place such that each element appear only once`()...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,863
katas
The Unlicense
src/day21/Day21.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
package day21 import readInput import java.util.regex.Pattern enum class Operation { ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPARE } fun translateOp(op: String): Operation = when(op) { "+" -> Operation.ADD "-" -> Operation.SUBTRACT "/" -> Operation.DIVIDE "*" -> Operation.MULTIPLY ...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
7,210
AdventOfCode2022
Apache License 2.0
repository/src/main/kotlin/org/goodmath/polytope/repository/agents/text/lcs.kt
MarkChuCarroll
608,827,232
false
null
/* * 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 wr...
0
Kotlin
0
0
e33a10b8bb604355e724d724ac27499d4cef826e
3,083
k-polytope
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2021/days/day17/Day17.kt
jntakpe
433,584,164
false
{"Kotlin": 64657, "Rust": 51491}
package com.github.jntakpe.aoc2021.days.day17 import com.github.jntakpe.aoc2021.shared.Day import com.github.jntakpe.aoc2021.shared.readInput object Day17 : Day { override val input = readInput(17) override fun part1() = Launcher(TargetArea.from(input)).calibrate().maxOrNull()!! override fun part2() = ...
0
Kotlin
1
5
230b957cd18e44719fd581c7e380b5bcd46ea615
2,257
aoc2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxConcatenationOfSubsequence.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2024 <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,731
kotlab
Apache License 2.0
src/Day08.kt
kkaptur
573,511,972
false
{"Kotlin": 14524}
import java.io.File import java.util.Collections.max class Position( val topElements: MutableList<Int>, val bottomElements: MutableList<Int>, val leftElements: MutableList<Int>, val rightElements: MutableList<Int> ) { companion object { fun of( currentColumnElements: MutableList...
0
Kotlin
0
0
055073b7c073c8c1daabbfd293139fecf412632a
5,169
AdventOfCode2022Kotlin
Apache License 2.0
src/main/kotlin/leetcode/Problem2115.kt
fredyw
28,460,187
false
{"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604}
package leetcode /** * https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/ */ class Problem2115 { fun findAllRecipes(recipes: Array<String>, ingredients: List<List<String>>, supplies: Array<String>): List<String> { val recipeToIngredients = mutableMapOf<String, List<String>>() ...
0
Java
1
4
a59d77c4fd00674426a5f4f7b9b009d9b8321d6d
1,738
leetcode
MIT License
src/main/kotlin/days/Day21.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day21 : Day(21) { private val circleSize = 10 override fun partOne(): Any { val maxScore = 1000 val (startFirst, startSecond) = inputList.map { Regex("""Player \d+ starting position: (\d+)""").find(it)!!.groupValues[1].toInt() } val players = generateSequence(0) { 1...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
1,417
aoc-2021
Creative Commons Zero v1.0 Universal
calendar/day03/Day3.kt
divgup92
726,169,029
false
{"Kotlin": 16931}
package day03 import Day import Lines import kotlin.math.max import kotlin.math.min class Day3 : Day() { private var numberList = mutableListOf<Map<Int, MutableList<Pair<Int, Int>>>>() private var specialCharList = mutableListOf<List<Int>>() private var starCharList = mutableListOf<List<Int>>() overr...
0
Kotlin
0
0
38dbf3b6eceea8d5b0eeab82b384acdd0c205852
3,859
advent-of-code-2023
Apache License 2.0
src/main/java/com/barneyb/aoc/aoc2022/day02/RockPaperScissors.kt
barneyb
553,291,150
false
{"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020}
package com.barneyb.aoc.aoc2022.day02 import com.barneyb.aoc.util.Solver fun main() { Solver.execute( ::parse, partOne, partTwo, ) } internal fun parse(input: String) = input.trim() .lines() private val tableOne: Map<String, Int> = mapOf( "A X" to 4, "B X" to 1, ...
0
Kotlin
0
0
8b5956164ff0be79a27f68ef09a9e7171cc91995
822
aoc-2022
MIT License
src/main/kotlin/adventofcode/year2022/Day02RockPaperScissors.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2022 import adventofcode.Puzzle import adventofcode.PuzzleInput class Day02RockPaperScissors(customInput: PuzzleInput? = null) : Puzzle(customInput) { private val strategies by lazy { input.lines().map { it.split(" ") }.map { it.first() to it.last() } } override fun partOne() = strat...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
1,774
AdventOfCode
MIT License
src/aoc2022/Day16.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* import java.util.* import kotlin.math.max private const val STARTING_ROOM = "AA" private class Day16(val lines: List<String>) { var roomMap: Map<String, Room> val sparseEdges: Map<String, List<Edge>> val cache = mutableMapOf<State, Long>() init { val denseEdges = mutableM...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
5,461
aoc2022
Apache License 2.0
archive/2022/Day16_submission.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
/** * Pretty terrible code hacked together during submission. * I missed that lots of valves are not useful to open (flow = 0) and tried a walking-time solution * optimized to limit to the 500K top states at every minute */ private const val EXPECTED_1 = 1651 private const val EXPECTED_2 = 1707 private val edges ...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
5,399
advent-of-code-2022
Apache License 2.0
src/Day01.kt
raigol
573,133,877
false
{"Kotlin": 1657}
fun main() { fun getElfCalories(input: List<String>): List<Int> { var sum = 0 val elfTotals = mutableListOf<Int>() for (i in input) { if(i.isNotBlank()) { sum += i.toInt() } else { elfTotals.add(sum) ...
0
Kotlin
0
0
bfc7d520693456fa3a2f539c4a611b6fb74aa53d
1,010
aoc-in-kotlin-2022
Apache License 2.0
src/main/kotlin/g1401_1500/s1489_find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1489_find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree // #Hard #Sorting #Graph #Union_Find #Minimum_Spanning_Tree #Strongly_Connected_Component // #2023_06_13_Time_342_ms_(100.00%)_Space_39.1_MB_(100.00%) import java.util.Arrays import java.util.LinkedList class Solution { fun...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,787
LeetCode-in-Kotlin
MIT License