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/utils/Graph.kt
TheSunshinator
572,121,335
false
{"Kotlin": 144661}
package utils data class Graph<T : Identifiable>( val nodes: Set<T>, val neighbors: Map<Identifier, Set<Identifier>>, val costs: Map<Pair<Identifier, Identifier>, Long>, ) { val edges: Set<Pair<Identifier, Identifier>> by lazy { neighbors.flatMapTo(mutableSetOf()) { (start, destinations) -> ...
0
Kotlin
0
0
d050e86fa5591447f4dd38816877b475fba512d0
1,814
Advent-of-Code
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxNumEdgesToRemove.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
3,662
kotlab
Apache License 2.0
Kotlin/Dijkstra.kt
lprimeroo
41,106,663
false
null
class Dijkstra { // Dijkstra's algorithm to find shortest path from s to all other nodes fun dijkstra(G: WeightedGraph, s: Int): IntArray { val dist = IntArray(G.size()) // shortest known distance from "s" val pred = IntArray(G.size()) // preceeding node in path val visited = BooleanA...
56
C++
186
99
16367eb9796b6d4681c5ddf45248e2bcda72de80
1,657
DSA
MIT License
kotlin/src/com/daily/algothrim/leetcode/Trie.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode /** * 208. 实现 Trie (前缀树) * * Trie(发音类似 "try")或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。 * * 请你实现 Trie 类: * * Trie() 初始化前缀树对象。 * void insert(String word) 向前缀树中插入字符串 word 。 * boolean search(String word) 如果字符串 word 在前缀树中,返回 true(即,在检索之前已经插入);否则,返回 fals...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,282
daily_algorithm
Apache License 2.0
src/main/kotlin/net/navatwo/adventofcode2023/day7/Day7Solution.kt
Nava2
726,034,626
false
{"Kotlin": 100705, "Python": 2640, "Shell": 28}
package net.navatwo.adventofcode2023.day7 import net.navatwo.adventofcode2023.framework.ComputedResult import net.navatwo.adventofcode2023.framework.Solution sealed class Day7Solution : Solution<Day7Solution.Game> { internal abstract val handComparator: Comparator<Hand> // lazy due to accessing `abstract val` pr...
0
Kotlin
0
0
4b45e663120ad7beabdd1a0f304023cc0b236255
5,667
advent-of-code-2023
MIT License
src/aoc2018/kot/Day04.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import getNumbers import java.io.File object Day04 { data class Guard(val id: Int, val sleeps: MutableList<List<Int>> = mutableListOf()) fun partOne(input: List<String>): Int { val guards = parse(input) val maxSleeper = guards.maxBy { it.sleeps.sumBy { it.last() - it.first() } }!! ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,436
Advent_of_Code
MIT License
2022/Day07.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
sealed class Node(val size: Long) { class Dir(val children: MutableMap<String, Node> = mutableMapOf(), size: Long = 0) : Node(size) class File(size: Long) : Node(size) } fun main() { val input = readInput("Day07") val root = Node.Dir() val stack = ArrayDeque(listOf(root)) for (s in input) { ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,722
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day02.kt
EmRe-One
568,569,073
false
{"Kotlin": 166986}
package tr.emreone.adventofcode.days object Day02 { /* * Score is calculated by adding the score of shape with the score for the round * * 1 for Rock * 2 for Paper, and * 3 for Scissors * * plus * * 0 if you lost * 3 if the round was a draw, and * 6 if you won */ ...
0
Kotlin
0
0
a951d2660145d3bf52db5cd6d6a07998dbfcb316
2,318
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day2.kt
hughjdavey
433,597,582
false
{"Kotlin": 53042}
package days import days.Day2.SubmarineDirection.DOWN import days.Day2.SubmarineDirection.FORWARD import days.Day2.SubmarineDirection.UP class Day2 : Day(2) { private val submarine = Submarine(SubmarinePosition(), inputList) override fun partOne(): Any { return submarine.move( { position...
0
Kotlin
0
0
a3c2fe866f6b1811782d774a4317457f0882f5ef
2,037
aoc-2021
Creative Commons Zero v1.0 Universal
src/main/kotlin/io/github/clechasseur/adventofcode/y2015/Day21.kt
clechasseur
568,233,589
false
{"Kotlin": 242914}
package io.github.clechasseur.adventofcode.y2015 import kotlin.math.max object Day21 { private val input = Protagonist(hp = 100, damage = 8, armor = 2, equipment = emptyList()) fun part1(): Int = playerLayouts().sortedBy { it.totalCost }.filter { `fight!`(it) }.first().totalCost fun part2(): Int = playe...
0
Kotlin
0
0
e5a83093156cd7cd4afa41c93967a5181fd6ab80
3,375
adventofcode2015
MIT License
src/day11/Day11.kt
robin-schoch
572,718,550
false
{"Kotlin": 26220}
package day11 import AdventOfCodeSolution fun main() { Day11.run() } var supermodulo = 1L sealed class Operation { abstract val value: Long? fun execute(item: Long): Long = item.execute(value ?: item) abstract fun Long.execute(change: Long): Long companion object { fun fromString(ops: ...
0
Kotlin
0
0
fa993787cbeee21ab103d2ce7a02033561e3fac3
3,900
aoc-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day07/Day07.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
1,758
AdventOfCode
Apache License 2.0
src/year2022/21/Day21.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`21` import readInput @JvmInline value class NodeTitle(val value: String) enum class OperationType { PLUS, MINUS, MUL, DIV; companion object { fun from(string: String): OperationType { return when (string) { "*" -> MUL "/" -> DIV ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
4,828
KotlinAdventOfCode
Apache License 2.0
grind-75-kotlin/src/main/kotlin/BestTimeToBuyAndSellStock.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
/** * You are given an array prices where prices[i] is the price of a given stock on the ith day. * * You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. * * Return the maximum profit you can achieve from this transaction. If you...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
1,582
grind-75
Apache License 2.0
src/Day23.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
import kotlin.math.max typealias Grid = MutableInput<Char> fun main() { fun Grid.next(curr: RowCol): List<RowCol> { return when (this.get(curr)) { '>' -> listOf(curr.right()) '<' -> listOf(curr.left()) '^' -> listOf(curr.up()) 'v' -> listOf(curr.down()) ...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
3,167
aoc-2023
Apache License 2.0
kotlin/src/com/s13g/aoc/aoc2022/Day11.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.mul import com.s13g.aoc.resultFrom /** * --- Day 11: Monkey in the Middle --- * https://adventofcode.com/2022/day/11 */ class Day11 : Solver { override fun solve(lines: List<String>): Result { return result...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,179
euler
Apache License 2.0
src/Day04.kt
NatoNathan
572,672,396
false
{"Kotlin": 6460}
typealias AssignmentsPair = Pair<IntRange, IntRange> fun getPair(input:String): AssignmentsPair { val (one, two) = input.split(",").map { getAssignments(it) } return Pair(one, two) } fun getAssignments(input:String): IntRange { val (lower, upper) = input.split('-').map { it.toInt() } return lower..u...
0
Kotlin
0
0
c0c9e2a2d0ca2503afe33684a3fbba1f9eefb2b0
1,308
advent-of-code-kt
Apache License 2.0
src/main/kotlin/oct_challenge2021/wordSearchII/WordSearchII.kt
yvelianyk
405,919,452
false
{"Kotlin": 147854, "Java": 610}
package oct_challenge2021.wordSearchII fun main() { val matrix = arrayOf( charArrayOf('o', 'a', 'a', 'n'), charArrayOf('e', 't', 'a', 'e'), charArrayOf('i', 'h', 'k', 'r'), charArrayOf('i', 'f', 'l', 'v'), ) val words = arrayOf("oath", "pea", "eat", "rain") val result = ...
0
Kotlin
0
0
780d6597d0f29154b3c2fb7850a8b1b8c7ee4bcd
2,740
leetcode-kotlin
MIT License
src/Day07.kt
allisonjoycarter
574,207,005
false
{"Kotlin": 22303}
fun main() { class File(val name: String, val size: Int) class Directory(val name: String) { var parent: Directory? = null val directories: MutableList<Directory> = mutableListOf() val files: MutableList<File> = mutableListOf() val size: Int get() = files.sumOf { i...
0
Kotlin
0
0
86306ee6f4e90c1cab7c2743eb437fa86d4238e5
6,325
adventofcode2022
Apache License 2.0
advent-of-code-2023/src/test/kotlin/Day3Test.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
import io.kotest.matchers.shouldBe import org.junit.jupiter.api.Test /** [Day 3: Gear Ratios](https://adventofcode.com/2023/day/3) */ class Day3Test { data class EnginePart( private val start: Point, val value: Char, val strings: List<String>, ) { val numbers: List<Int> get() = strings....
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
2,483
advent-of-code
MIT License
aoc-2023/src/main/kotlin/aoc/aoc13.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.CharGrid import aoc.util.getDayInput val testInput = """ #.##..##. ..#.##.#. ##......# ##......# ..#.##.#. ..##..##. #.#.##.#. #...##..# #....#..# ..##..### #####.##. #####.##. ..##..### #....#..# """.parselines fun List<String>.parse(): List<Cha...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
2,162
advent-of-code
Apache License 2.0
kotlin/1930-unique-length-3-palindromic-subsequences.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
/* * Time complexity 0(N * 26) ~ O(N) * * Space complexity O(26 + 26 + 26*26) or 0(A^2) where A is the alphabet which technically is O(1) */ class Solution { fun countPalindromicSubsequence(s: String): Int { val left = HashSet<Char>() val right = IntArray(26) var res = HashSet<Pair<Char, C...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,732
leetcode
MIT License
src/day23/Day23.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day23 import readInput fun Pair<Int, Int>.surrounding() = listOf( first to second + 1, first to second - 1, first + 1 to second, first + 1 to second + 1, first + 1 to second - 1, first - 1 to second, first - 1 to second + 1, first - 1 to second - 1, ) fun Pair<Int, Int>.north...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
3,649
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day19.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.days.Day19.Resource.* import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines import java.util.* object Day19 : Day { override val input = readInputLines(19).map { Blueprint.from(it) } over...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
5,726
aoc2022
MIT License
src/Day09.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
fun main() { fun parseMoves(input: List<String>): List<HeadMove> { return input.map { val split = it.split(" ") HeadMove(Direction.valueOf(split[0]), split[1].toInt()) } } fun part1(input: List<String>): Int { val moves = parseMoves(input) val head = ...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
5,287
advent-of-code-2022
Apache License 2.0
day16/src/main/kotlin/de/havox_design/aoc2023/day16/Day16.kt
Gentleman1983
715,778,541
false
{"Kotlin": 163912, "Python": 1048}
package de.havox_design.aoc2023.day16 import de.havox_design.aoc2023.day10.Direction class Day16(private var filename: String) { fun solvePart1(): Long = getEnergy(parseTiles(getResourceAsText(filename)), Direction.EAST, Pair(0, 0)) .toLong() fun solvePart2(): Long { val input = g...
1
Kotlin
0
0
eac8ff77420f061f5cef0fd4b8d05e7805c4cc5a
4,396
aoc2023
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem45/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem45 /** * LeetCode page: [45. Jump Game II](https://leetcode.com/problems/jump-game-ii/); */ class Solution2 { /* Algorithm: (By Dynamic Programming) * 1. SubProblem: * let X(i) be the minimum jumps if start at index i. Use array Dp to store the result * ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,913
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day24/HailstoneMap.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day24 import com.github.michaelbull.advent2023.iteration.combinationPairs fun Sequence<String>.toHailstoneMap(): HailstoneMap { return HailstoneMap(map(String::toHailstone).toList()) } data class HailstoneMap( val hailstones: List<Hailstone>, ) { fun intersectio...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
1,327
advent-2023
ISC License
src/main/kotlin/com/dmc/advent2022/Day09.kt
dorienmc
576,916,728
false
{"Kotlin": 86239}
package com.dmc.advent2022 import kotlin.math.absoluteValue import kotlin.math.sign //--- Day 9: Rope Bridge --- class Day09 : Day<Int> { override val index = 9 override fun part1(input: List<String>): Int { var head = Point() var tail = Point() val tailPositions = mutableSetOf(Point(...
0
Kotlin
0
0
207c47b47e743ec7849aea38ac6aab6c4a7d4e79
2,951
aoc-2022-kotlin
Apache License 2.0
src/Day08.kt
li-xin-yi
573,617,763
false
{"Kotlin": 23422}
import java.util.* fun main() { fun parseInput(input: List<String>): List<List<Int>> { return input.map { line -> line.map { it - '0' } } } fun solvePart1(input: List<String>): Int { val grid = parseInput(input) val seen = mutableSetOf<Pair<Int, Int>>() ...
0
Kotlin
0
1
fb18bb7e462b8b415875a82c5c69962d254c8255
3,296
AoC-2022-kotlin
Apache License 2.0
string-similarity/src/commonMain/kotlin/com/aallam/similarity/Levenshtein.kt
aallam
597,692,521
false
null
package com.aallam.similarity import kotlin.math.min /** * The Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or * substitutions) required to change one string into the other. * * This implementation uses dynamic programming (Wagner–Fischer algorithm)...
0
Kotlin
0
1
40cd4eb7543b776c283147e05d12bb840202b6f7
2,605
string-similarity-kotlin
MIT License
src/main/kotlin/com/kishor/kotlin/algo/problems/arrayandstrings/LengthOfLongestSubString.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.problems.arrayandstrings import kotlin.math.max fun main() { // lengthOfLongestSubstring("abcabcbb") println("${findLongestSubstringLength("abcabcbb")}") println("${longestSubstringLength("abcabcbb")}") } fun lengthOfLongestSubstring(s: String): Int { var count = 0 ...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
1,334
DS_Algo_Kotlin
MIT License
src/main/kotlin/day04.kt
mgellert
572,594,052
false
{"Kotlin": 19842}
object CampCleanup : Solution { fun countFullyContainedAssignments(assignments: List<Pair<Assignment, Assignment>>): Int = count(assignments) { it.first.contains(it.second) || it.second.contains(it.first) } fun countOverlappedAssignments(assignments: List<Pair<Assignment, Assignment>>): Int = coun...
0
Kotlin
0
0
4224c762ad4961b28e47cd3db35e5bc73587a118
1,250
advent-of-code-2022-kotlin
The Unlicense
kotlin/src/katas/kotlin/hackerrank/MatrixLayerRotation.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.hackerrank import datsok.shouldEqual import org.junit.Test import java.util.* import kotlin.collections.ArrayList /** * https://www.hackerrank.com/challenges/matrix-rotation-algo */ fun main() { val scanner = Scanner(System.`in`) val i = generateSequence { scanner.nextLine() }.iterator(...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
6,075
katas
The Unlicense
src/main/kotlin/eu/michalchomo/adventofcode/year2022/Day09.kt
MichalChomo
572,214,942
false
{"Kotlin": 56758}
package eu.michalchomo.adventofcode.year2022 import kotlin.math.abs import kotlin.math.max enum class Motion { R, U, L, D } fun main() { fun List<List<Int>>.printMotion() = println( (10 downTo -10).joinToString(separator = "\n") { i -> (-10..10).joinToString(separator = " ") { j -> ...
0
Kotlin
0
0
a95d478aee72034321fdf37930722c23b246dd6b
3,688
advent-of-code
Apache License 2.0
src/Day07.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
fun main() { val input = readInput("Day07") val root = Dir("/", null, emptyList()) var shell = ShellState(FileSystem(root), root) var currentInput = input while (currentInput.isNotEmpty()) { val nextCmdItemCount = (currentInput.subList(1, currentInput.size) .indexOfFirst { it....
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
4,126
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/day14.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day14 import aoc.utils.* import java.lang.Integer.max import java.lang.Integer.min fun main() { part2() } fun part2(): Int { val sandSource = Cursor(500, 0) var rockLinEnds = readInput("day14-input.txt") .map { it.findInts().windowed(2, 2).map { Cursor(it[0], it[1]) } } val large = r...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
5,017
adventOfCode2022
Apache License 2.0
src/main/kotlin/pl/bizarre/day2_1.kt
gosak
572,644,357
false
{"Kotlin": 26456}
package pl.bizarre import pl.bizarre.Day2Move.Companion.findMove import pl.bizarre.common.loadInput import java.util.regex.Pattern fun main() { val input = loadInput(2) println("result ${day2_1(input)}") } fun day2_1(input: List<String>): Int { val whitespace = Pattern.compile("\\s+") return input.su...
0
Kotlin
0
0
aaabc56532c4a5b12a9ce23d54c76a2316b933a6
1,230
adventofcode2022
Apache License 2.0
src/Day03.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
fun main() { fun List<List<Int>>.intersection(): Int { return map { it.toSet() }.reduce { a, b -> a intersect b }.sum() } fun parseInput(input: String): List<Int> { return input.toCharArray().asList().map { if (it.isUpperCase()) it - 'A' + 27 else it - 'a' + 1 } } fun part1(input: List<String>): Int...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
782
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/Day03.kt
KarinaCher
572,657,240
false
{"Kotlin": 21749}
fun main() { fun part1(input: List<String>): Int { var result = 0 for (rucksack in input) { val rp = rucksack.toList() val chunked = rp.chunked(rp.size / 2) val ic = findIncorrect(chunked) result += getPriority(ic) } return result ...
0
Kotlin
0
0
17d5fc87e1bcb2a65764067610778141110284b6
1,239
KotlinAdvent
Apache License 2.0
src/com/ncorti/aoc2023/Day11.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 import kotlin.math.abs import kotlin.math.min fun main() { fun part(factor : Long = 2): Long { val map = getInputAsText("11") { split("\n").filter(String::isNotBlank).map { it.toCharArray().toMutableList() } }.toMutableList() var i = 0 while (...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
2,581
adventofcode-2023
MIT License
day09/Kotlin/day09.kt
Ad0lphus
353,610,043
false
{"C++": 195638, "Python": 139359, "Kotlin": 80248}
import java.io.* fun print_day_9() { val yellow = "\u001B[33m" val reset = "\u001b[0m" val green = "\u001B[32m" println(yellow + "-".repeat(25) + "Advent of Code - Day 9" + "-".repeat(25) + reset) println(green) val process = Runtime.getRuntime().exec("figlet Smoke Basin -c -f small") v...
0
C++
0
0
02f219ea278d85c7799d739294c664aa5a47719a
2,682
AOC2021
Apache License 2.0
LeetCode/0128. Longest Consecutive Sequence/Solution.kt
InnoFang
86,413,001
false
{"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410}
/** * Created by <NAME> on 2018/3/13. */ /** * 68 / 68 test cases passed. * Status: Accepted * Runtime: 328 ms */ class Solution { fun longestConsecutive(nums: IntArray): Int { val uf = UnionFind(nums) val store = HashMap<Int, Int>() nums.forEach { i -> if (!store.contains...
0
C++
8
20
2419a7d720bea1fd6ff3b75c38342a0ace18b205
2,600
algo-set
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec11.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec11 : PuzzleDayTester(11, 2020) { override fun part1(): Int = parse().findStableSeating(maxNeighbors = 4, transformFloor = true).countOccupiedSeats() override fun part2(): Int = parse().findStableSeating(max...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
3,304
advent-of-code
MIT License
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p00/Leet5.kt
artemkaxboy
513,636,701
false
{"Kotlin": 547181, "Java": 13948}
package com.artemkaxboy.leetcode.p00 private class Leet5 { fun longestPalindrome(s: String): String { var longestFound: Pair<Int, Int> = 0 to 0 for (firstLetterOffset in s.indices) { findLongestForSubstring(s, firstLetterOffset, longestFound.second + 1) ?.let { longestF...
0
Kotlin
0
0
516a8a05112e57eb922b9a272f8fd5209b7d0727
1,470
playground
MIT License
src/main/kotlin/aoc23/Day07.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import common.Year23 import aoc23.Day07Domain.CamelCards import aoc23.Day07Domain.Cards import aoc23.Day07Parser.toCamelCards import aoc23.Day07Solution.part1Day07 import aoc23.Day07Solution.part2Day07 import com.github.shiguruikai.combinatoricskt.permutationsWithRepetition import common.Strings.replaceA...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
4,179
aoc
Apache License 2.0
src/Day04.kt
haraldsperre
572,671,018
false
{"Kotlin": 17302}
fun main() { fun getElfRanges(pair: String): Pair<IntRange, IntRange> { return pair .split(",") .map { elf -> val (low, high) = elf.split("-").map { it.toInt() } low..high } .let { it[0] to it[1] } } fun part1(input: L...
0
Kotlin
0
0
c4224fd73a52a2c9b218556c169c129cf21ea415
1,087
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc23/Day11.kt
tahlers
725,424,936
false
{"Kotlin": 65626}
package aoc23 import kotlin.math.abs typealias RowAndColumnIndexes = Pair<Set<Long>, Set<Long>> object Day11 { data class Pos(val x: Long, val y: Long) data class Image(val galaxies: Set<Pos>) fun calculateSumOfShortestPaths(input: String, expansionCount: Int = 2): Long { val originalImage = p...
0
Kotlin
0
0
0cd9676a7d1fec01858ede1ab0adf254d17380b0
2,301
advent-of-code-23
Apache License 2.0
src/Day07.kt
f1qwase
572,888,869
false
{"Kotlin": 33268}
import java.lang.IllegalStateException private const val COMMAND_PREFIX = "$ " private val TOTAL_SPACE = 70000000 private val SPACE_REQUIRED = 30000000 private sealed interface FSNode { val parent: FSNode? val name: String val size: Int class File( override val parent: FSNode?, overr...
0
Kotlin
0
0
3fc7b74df8b6595d7cd48915c717905c4d124729
3,819
aoc-2022
Apache License 2.0
src/day08/Day08.kt
JakubMosakowski
572,993,890
false
{"Kotlin": 66633}
package day08 import readInput /** * The expedition comes across a peculiar patch of tall trees all planted carefully in a grid. * The Elves explain that a previous expedition planted these trees as a reforestation effort. * Now, they're curious if this would be a good location for a tree house. * * First, deter...
0
Kotlin
0
0
f6e9a0b6c2b66c28f052d461c79ad4f427dbdfc8
9,145
advent-of-code-2022
Apache License 2.0
src/main/kotlin/tw/gasol/aoc/aoc2022/Day14.kt
Gasol
574,784,477
false
{"Kotlin": 70912, "Shell": 1291, "Makefile": 59}
package tw.gasol.aoc.aoc2022 import java.util.* class Day14 { private val print: Boolean = false private fun parseRockCoordinates(input: String): List<List<Location>> { return input.lines() .filterNot { it.isBlank() } .map { line -> line.split(" -> ").map { ...
0
Kotlin
0
0
a14582ea15f1554803e63e5ba12e303be2879b8a
7,709
aoc2022
MIT License
src/Day05.kt
jordanfarrer
573,120,618
false
{"Kotlin": 20954}
fun main() { val day = "Day05" fun parseInstructions(input: List<String>): List<Instruction> { val instructionRegex = Regex(".*?(\\d+).*?(\\d+).*?(\\d+)") return input.map { line -> val match = instructionRegex.find(line) val quantity = match?.groups?.get(1)?.value?.toIn...
0
Kotlin
0
1
aea4bb23029f3b48c94aa742958727d71c3532ac
3,486
advent-of-code-2022-kotlin
Apache License 2.0
src/jvmMain/kotlin/day08/initial/Day08.kt
liusbl
726,218,737
false
{"Kotlin": 109684}
package day08.initial import java.io.File fun main() { // solvePart1() ///// Solution: 19637, Time: 20:30 solvePart2() ///// Solution: 19637, Time: 20:30 } fun solvePart1() { // val input = File("src/jvmMain/kotlin/day08/input/input_part1_test.txt") val input = File("src/jvmMain/kotlin/day08/input/inpu...
0
Kotlin
0
0
1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1
4,100
advent-of-code
MIT License
src/Day02.kt
janbina
157,854,025
false
null
import kotlin.test.assertEquals object Day02 { fun part1(input: List<String>): Int { var two = 0 var three = 0 input .map { str -> str.groupingBy { it }.eachCount() } .map { it.values } .forEach { counts -> if (counts.any { it == 2 }) two...
0
Kotlin
0
0
522d93baf9ff4191bc2fc416d95b06208be32325
1,073
advent-of-code-2018
MIT License
src/Day04.kt
iProdigy
572,297,795
false
{"Kotlin": 33616}
fun main() { fun part1(input: List<String>): Int { return parse(input).count { (a, b) -> a containsAll b || b containsAll a } } fun part2(input: List<String>): Int { return parse(input).count { (a, b) -> a containsAny b } } // test if implementation meets criteria from the descript...
0
Kotlin
0
1
784fc926735fc01f4cf18d2ec105956c50a0d663
772
advent-of-code-2022
Apache License 2.0
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day7.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInputLines object Day7 : Day { override val input = buildTree(parseCommands(readInputLines(7))) override fun part1() = input.dirSizes().filter { it <= 100000 }.sum() overrid...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,851
aoc2022
MIT License
src/main/kotlin/twentytwentytwo/Day7.kt
JanGroot
317,476,637
false
{"Kotlin": 80906}
package twentytwentytwo import twentytwentytwo.File.Companion.ROOT import twentytwentytwo.File.Companion.isDir fun main() { val input = {}.javaClass.getResource("input-7.txt")!!.readText().linesFiltered { it.isNotEmpty() && !it.startsWith("$ ls") } val day = Day7(input) println(day.part1()) p...
0
Kotlin
0
0
04a9531285e22cc81e6478dc89708bcf6407910b
1,970
aoc202xkotlin
The Unlicense
src/Day09.kt
wgolyakov
572,463,468
false
null
import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun part1(input: List<String>): Int { var x = 0 var y = 0 var a = 0 var b = 0 val tailPositions = mutableSetOf(a to b) for (line in input) { val direction = line[0] val steps = line.substring(2).toInt() for (s in 0 until steps)...
0
Kotlin
0
0
789a2a027ea57954301d7267a14e26e39bfbc3c7
1,516
advent-of-code-2022
Apache License 2.0
year2022/src/main/kotlin/net/olegg/aoc/year2022/day7/Day7.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2022.day7 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.toPair import net.olegg.aoc.year2022.DayOf2022 import net.olegg.aoc.year2022.day7.Day7.Node.Dir import net.olegg.aoc.year2022.day7.Day7.Node.File /** * See [Year 2022, Day 7](https://adventofcode.com/2022/day/7) */ o...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
3,129
adventofcode
MIT License
src/Day01.kt
ech0matrix
572,692,409
false
{"Kotlin": 116274}
fun main() { fun parseGroups(input: List<String>): List<List<String>> { val splitIndex = input.indexOf("") if (splitIndex == -1) return listOf(input) val first: List<String> = input.subList(0, splitIndex) val remainder: List<List<String>> = parseGroups(input.subList(split...
0
Kotlin
0
0
50885e12813002be09fb6186ecdaa3cc83b6a5ea
1,080
aoc2022
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day8.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay // https://adventofcode.com/2021/day/8 fun main() { Day8().run() } /* 1 = 2 4 = 4 7 = 3 8 = 7 5 = 5 2 = 5 3 = 5 6 = 6 9 = 6 0 = 6 **/ class Day8 : BaseDay() { override fun task1() : Int { val signalEntries = parseEntries() return s...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
3,516
advent-of-code
Apache License 2.0
src/test/kotlin/Day5Test.kt
corentinnormand
725,992,109
false
{"Kotlin": 40576}
import org.junit.jupiter.api.Test import kotlin.math.min class Day5Test { @Test fun test() { val input = Day5().readFile("day5.txt").split("\n\n") val seeds = input[0].split(":")[1].split(" ") .filter { it != "" } .map { it.trim().toLong() } val maps = input.sub...
0
Kotlin
0
0
2b177a98ab112850b0f985c5926d15493a9a1373
2,435
aoc_2023
Apache License 2.0
src/Day03.kt
gomercin
572,911,270
false
{"Kotlin": 25313}
/* * searches I needed to make: * kotlin list intersection * kotlin list split * kotlin string to list of chars * kotlin ch to ascii * */ fun main() { class Rucksack { var compartment1: List<Char> var compartment2: List<Char> var allContents: List<Char> constructor(contents: Stri...
0
Kotlin
0
0
30f75c4103ab9e971c7c668f03f279f96dbd72ab
2,229
adventofcode-2022
Apache License 2.0
src/Day03.kt
ajspadial
573,864,089
false
{"Kotlin": 15457}
fun main() { fun calcPriority (c: Char): Int { return if (c in 'a'..'z') c.code - 'a'.code + 1 else c.code - 'A'.code + 27 } fun part1(input: List<String>): Int { var score = 0 for (line in input) { val firstCompartment = line.substring(0..line...
0
Kotlin
0
0
ed7a2010008be17fec1330b41adc7ee5861b956b
1,415
adventofcode2022
Apache License 2.0
Coding Challenges/Advent of Code/2021/Day 8/part2.kt
Alphabeater
435,048,407
false
{"Kotlin": 69566, "Python": 5974}
import java.io.File import java.util.Scanner import kotlin.math.pow /* dddd x0x0x0x0 e a x6 x1 e a x6 x1 ffff -> x2x2x2x2 g b x5 x3 g b x5 x3 cccc x4x4x4x4 */ var stv = mutableMapOf<String, Int>() //...
0
Kotlin
0
0
05c8d4614e025ed2f26fef2e5b1581630201adf0
2,711
Archive
MIT License
src/Day07/Day07.kt
rooksoto
573,602,435
false
{"Kotlin": 16098}
package Day07 import profile import readInputActual import readInputTest private const val DAY = "Day07" private const val ROOT = "ROOT" private const val PD = "/" private const val TOTAL_SPACE: Int = 70000000 private const val NEEDED_SPACE: Int = 30000000 var fileSystem: MutableMap<String, Directory> = mutableMapOf...
0
Kotlin
0
1
52093dbf0dc2f5f62f44a57aa3064d9b0b458583
3,652
AoC-2022
Apache License 2.0
src/main/kotlin/day19/Day19.kt
jakubgwozdz
571,298,326
false
{"Kotlin": 85100}
package day19 import Stack import execute import parseRecords import readAllText fun part1(input: String) = input.parseRecords(regex, ::parse) .map { it.id to it.score(24) } .sumOf { (id, score) -> id * score } fun part2(input: String) = input.parseRecords(regex, ::parse) .take(3) .map { it.score(32)...
0
Kotlin
0
0
7589942906f9f524018c130b0be8976c824c4c2a
6,236
advent-of-code-2022
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions59.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import com.qiaoyuang.algorithm.round0.Queue import com.qiaoyuang.algorithm.round0.Stack fun test59() { printlnResult1(intArrayOf(2, 3, 4, 2, 6, 2, 5, 1), 3) printlnResult1(intArrayOf(1, 3, 4, 7, 9, 1, 9, 8), 2) printlnResult1(intArrayOf(2, 2, 2, 2, 3, 6, 2, 5, 1), 3)...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
2,600
Algorithm
Apache License 2.0
leetcode2/src/leetcode/HammingDistance.kt
hewking
68,515,222
false
null
package leetcode /** * 461. 汉明距离 * Created by test * Date 2019/5/30 1:26 * Description * https://leetcode-cn.com/problems/hamming-distance/ * 两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目。 给出两个整数 x 和 y,计算它们之间的汉明距离。 注意: 0 ≤ x, y < 231. 示例: 输入: x = 1, y = 4 输出: 2 解释: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ 上面的箭头指出了对应二进制位不同的位...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,237
leetcode
MIT License
src/Day03.kt
wellithy
571,903,945
false
null
package day03 import util.* @JvmInline value class Item(val char: Char) { fun priority(): Int = when (char) { in 'a'..'z' -> (char - 'a') + 1 in 'A'..'Z' -> (char - 'A') + 27 else -> error("") } } fun Set<Item>.priority(): Int = single().priority() @JvmInline ...
0
Kotlin
0
0
6d5fd4f0d361e4d483f7ddd2c6ef10224f6a9dec
1,487
aoc2022
Apache License 2.0
y2020/src/main/kotlin/adventofcode/y2020/Day13.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2020 import adventofcode.io.AdventSolution import java.math.BigInteger fun main() = Day13.solve() object Day13 : AdventSolution(2020, 13, "Shuttle Search") { override fun solvePartOne(input: String): Int { val (ts, bussesStr) = input.lines() val t = ts.toInt() v...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,171
advent-of-code
MIT License
src/main/kotlin/cz/tomasbublik/Day05.kt
tomasbublik
572,856,220
false
{"Kotlin": 21908}
package cz.tomasbublik fun main() { fun createStacks(input: List<String>): ArrayList<ArrayDeque<Char>> { val cratesLines = input.slice(0 until input.indexOf("")) val listOfStacks = ArrayList<ArrayDeque<Char>>() val numberOfStacks = cratesLines.last().split(" ").last().toInt() for ...
0
Kotlin
0
0
8c26a93e8f6f7ab0f260c75a287608dd7218d0f0
2,824
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
zuevmaxim
572,255,617
false
{"Kotlin": 17901}
private fun part1(input: List<String>) = input.count { line -> val (a, b) = line.split(",").map { r -> r.split("-").map(String::toInt).toPair() } a.first <= b.first && b.second <= a.second || b.first <= a.first && a.second <= b.second } private fun part2(input: List<String>) = input.count { line -> ...
0
Kotlin
0
0
34356dd1f6e27cc45c8b4f0d9849f89604af0dfd
830
AOC2022
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2021/Day17.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2021 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution import at.mpichler.aoc.lib.Vector2i import kotlin.math.ceil import kotlin.math.sign import kotlin.math.sqrt open class Part17A : PartSolution() { lateinit var targetArea: Pair<Vector2i, Vector2i> ...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
2,352
advent-of-code-kotlin
MIT License
src/main/kotlin/day18.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
fun day18ProblemReader(text: String): List<String> { return text.split("\n") } // https://adventofcode.com/2020/day/18 class Day18( private val operations: List<String>, ) { fun solvePart1(): Long { return operations .asSequence() .map { "(%s)".format(it) } .map...
0
Kotlin
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
2,877
adventofcode_2020
MIT License
2021/src/day17/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day17 import java.nio.file.Files import java.nio.file.Paths import kotlin.math.absoluteValue import kotlin.math.sign fun main() { fun part1(input: Input): Int { val (xRange, yRange) = input.toList().map { it.first..it.second } require(xRange.first > 0 && xRange.last >= xRange.first) require(yRan...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
3,259
advent-of-code
Apache License 2.0
src/Day08_part1.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun part1(input: List<String>): Int { val grid = mutableListOf<List<Int>>() val seen = mutableListOf<MutableList<Boolean>>() for (it in input) { val intArr = mutableListOf<Int>() for (char in it.toList()) { intArr.add(char.digitToInt()) ...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
1,756
advent-of-code-2022
Apache License 2.0
src/main/kotlin/solutions/year2022/Day5.kt
neewrobert
573,028,531
false
{"Kotlin": 7605}
package solutions.year2022 import readInputLines fun main() { fun moveLines(moveLines: List<String>, onePerMove: Boolean, stacks: Array<ArrayDeque<Char>>) { moveLines.forEach { line -> val parts = line.split(" ") val numCrates = parts[1].toInt() val from = parts[3].to...
0
Kotlin
0
0
7ecf680845af9d22ef1b9038c05d72724e3914f1
1,896
aoc-2022-in-kotlin
Apache License 2.0
src/twentytwentytwo/day12/Day12.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day12 import readInput fun main() { fun part1(input: List<String>): Int { val matrix = mutableListOf<List<Char>>() input.forEach { matrix.add(it.toList()) } val graph = Graph<Square>() lateinit var start: Square lateinit var end: Square for...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
6,592
advent-of-code
Apache License 2.0
src/Day07.kt
zdenekobornik
572,882,216
false
null
import kotlin.math.min sealed class Data { data class Directory( val name: String, val parent: Directory? = null, var children: MutableList<Data> = mutableListOf() ) : Data() data class File(val size: Long, val name: String) : Data() } data class Drive( var currentDirectory: D...
0
Kotlin
0
0
f73e4a32802fa43b90c9d687d3c3247bf089e0e5
3,979
advent-of-code-2022
Apache License 2.0
y2017/src/main/kotlin/adventofcode/y2017/Day08.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2017 import adventofcode.io.AdventSolution object Day08 : AdventSolution(2017, 8, "I Heard You Like Registers") { override fun solvePartOne(input: String): String { val registers = mutableMapOf<String, Int>() for (instruction in parseInput(input)) { instruction.executeOn(registers) }...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,632
advent-of-code
MIT License
2021/src/main/kotlin/day5_func.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Segment import utils.Solution import utils.Vec2i import utils.mapItems fun main() { Day5Func.run() } object Day5Func : Solution<List<Segment>>() { override val name = "day5" override val parser = Parser.lines .mapItems(Segment::parse) .mapItems { if (it.start.x > it.end....
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,212
aoc_kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestPalindromeConcatenating.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,284
kotlab
Apache License 2.0
src/day04/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 4: Camp Cleanup * https://adventofcode.com/2022/day/4 */ package day04 import java.io.File fun main() { val fileName = // "day04_sample.txt" "day04_input.txt" val assignmentPairs = readInput(fileName) // Part 1: count assignment pairs where one fully contains the other...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
1,388
aoc2022-kotlin
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2022/Dec08.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2022 import org.elwaxoro.advent.PuzzleDayTester import org.elwaxoro.advent.padTo import org.elwaxoro.advent.splitToInt /** * Day 8: Treetop Tree House */ class Dec08: PuzzleDayTester(8, 2022) { /** * Can't see the forest for all the trees */ override fun part1(): Any ...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
3,154
advent-of-code
MIT License
src/main/kotlin/day22.kt
Arch-vile
572,557,390
false
{"Kotlin": 132454}
package day22 import aoc.utils.* val UP = Cursor(0, -1) val DOWN = Cursor(0, 1) val LEFT = Cursor(-1, 0) val RIGHT = Cursor(1, 0) val ROTATIONS = listOf(UP, RIGHT, DOWN, LEFT) data class Actor(val location: Block, val direction: Block) { fun turn(direction: Char): Actor { val currentDirectionIndex = loc...
0
Kotlin
0
0
e737bf3112e97b2221403fef6f77e994f331b7e9
4,640
adventOfCode2022
Apache License 2.0
kotlin/src/com/leetcode/120_Triangle.kt
programmerr47
248,502,040
false
null
package com.leetcode import java.lang.Integer.min //DP, but we assume the we have natural numbers. Time: O(n), Space: O(n), where n - is a total amount of numbers private class Solution120 { fun minimumTotal(triangle: List<List<Int>>): Int { val buffer = IntArray(triangle.size) triangle.forEachI...
0
Kotlin
0
0
0b5fbb3143ece02bb60d7c61fea56021fcc0f069
1,413
problemsolving
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-06.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input1 = readInputLines(2023, "06-input") val test1 = readInputLines(2023, "06-test1") println("Part1:") part1(test1).println() ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,146
advent-of-code
MIT License
src/main/kotlin/days/Day14.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days @AdventOfCodePuzzle( name = "Extended Polymerization", url = "https://adventofcode.com/2021/day/14", date = Date(day = 14, year = 2021) ) class Day14(val input: List<String>) : Puzzle { private val polymer: String = input.first() private val rules = input.drop(2) .associate { l...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
2,151
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/Day08.kt
cornz
572,867,092
false
{"Kotlin": 35639}
fun main() { fun scenicScore(input: List<String>): Int { val scenicScores = mutableListOf<Int>() val twoDArray = input.map { x -> x.toCharArray().map { y -> y.digitToInt() } } for ((listcounter, list) in twoDArray.withIndex()) { if (listcounter > 0 && listcounter < twoDArray.si...
0
Kotlin
0
0
2800416ddccabc45ba8940fbff998ec777168551
4,308
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/GreatestCommonDivisorOfArray.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,997
kotlab
Apache License 2.0
src/main/kotlin/Day01.kt
ripla
573,901,460
false
{"Kotlin": 19599}
object Day1 { fun part1(input: List<String>): Int { val elvesGrouped: List<List<Int>> = input.fold(listOf(emptyList())) { acc: List<List<Int>>, element -> (if (element == "") { acc.plusElement(emptyList()) } else { val elfAdded: List<Int> = acc.last()...
0
Kotlin
0
0
e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8
1,097
advent-of-code-2022-kotlin
Apache License 2.0
src/Day03.kt
hanmet
573,490,488
false
{"Kotlin": 9896}
fun main() { fun toPriority(c: Char): Int { return if (c.isUpperCase()) { c.code - 38 } else { c.code - 96 } } fun part1(input: List<String>): Int { var sum = 0 for (rucksack in input) { val (left, right) = rucksack.chunked(rucks...
0
Kotlin
0
0
e4e1722726587639776df86de8d4e325d1defa02
998
advent-of-code-2022
Apache License 2.0
2016/src/main/java/p3/Problem3.kt
ununhexium
113,359,669
false
null
package p3 import com.google.common.collect.Lists import more.Input fun main(args: Array<String>) { val sides = Input .getFor("p3") .split("\n") .map { it.trim().replace(Regex(" +"), " ").split(" ") } .map { it.map { it.toInt() } } readByLine(sides) readByColumn(sides) } fun readByColu...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
876
adventofcode
The Unlicense
year2016/src/main/kotlin/net/olegg/aoc/year2016/day24/Day24.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2016.day24 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.permutations import net.olegg.aoc.year2016.DayOf2016 /** * See [Year 2016, Day 24](https://adventofcode.com/2016/day/24) */ ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,529
adventofcode
MIT License
src/day04/Day04.kt
violabs
576,367,139
false
{"Kotlin": 10620}
package day04 import readInput fun main() { test1("day-04-test-input-01", 2) test2("day-04-test-input-01", 4) test2("day-04-actual-test-input", 4) } private fun test1(filename: String, expected: Int) { val input = readInput("day04/$filename") val actual: Int = findHighPriorityCleaningReassignme...
0
Kotlin
0
0
be3d6bb2aef1ebd44bbd8e62d3194c608a5b3cc1
2,139
AOC-2022
Apache License 2.0
src/main/kotlin/day16.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.* fun main() { val input = Input.day(16) println(day16A(input)) println(day16B(input)) } fun day16A(input: Input): Int { val map = XYMap(input) { it } return tilesEnergized(map, Mover(Point(0, 0), Right)) } fun day16B(input: Input): Int { val map = XYMap(input) { it } val en...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
2,165
AdventOfCode2023
MIT License
src/Day07.kt
jwklomp
572,195,432
false
{"Kotlin": 65103}
data class FileProp(val path: String, val name: String, val size: Long) data class Acc(var currentPath: String, val allDirs: MutableList<String>, val files: MutableList<FileProp>) fun main() { fun foldFn(input: List<String>): Acc = input.fold(Acc("root", mutableListOf("root"), mutableListOf())) { acc: Acc,...
0
Kotlin
0
0
1b1121cfc57bbb73ac84a2f58927ab59bf158888
1,573
aoc-2022-in-kotlin
Apache License 2.0
src/Day04.kt
roxspring
573,123,316
false
{"Kotlin": 9291}
fun main() { fun String.parseRange(): IntRange = substring(0 until indexOf('-')).toInt()..substring(indexOf('-') + 1).toInt() fun String.parsePair(): Pair<IntRange, IntRange> = substring(0 until indexOf(',')).parseRange() to substring(indexOf(',') + 1).parseRange() fun IntRange.containsAl...
0
Kotlin
0
0
535beea93bf84e650d8640f1c635a430b38c169b
1,151
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-10.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2021 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2021, "10-input") val test1 = readInputLines(2021, "10-test1") println("Part1:") part1(test1).println() p...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,954
advent-of-code
MIT License