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/y2021/Day08.kt
Yg0R2
433,731,745
false
null
package y2021 private val SEGMENT_BITS = arrayOf("1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011") fun main() { fun part1(input: List<String>): Int { return input .map { line -> line.split("|").map { it.trim() } } .map { i...
0
Kotlin
0
0
d88df7529665b65617334d84b87762bd3ead1323
4,800
advent-of-code
Apache License 2.0
src/main/java/leetcode/a350_intersectTwoArrays/Solution.kt
Laomedeia
122,696,571
true
{"Java": 801075, "Kotlin": 38473, "JavaScript": 8268}
package leetcode.a350_intersectTwoArrays import java.util.* import kotlin.math.min /** * 给定两个数组,编写一个函数来计算它们的交集。 * * 示例 1: * 输入:nums1 = [1,2,2,1], nums2 = [2,2] * 输出:[2,2] * * 示例 2: * 输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4] * 输出:[4,9] *   * * 说明: * 输出结果中每个元素出现的次数,应与元素在两个数组中出现次数的最小值一致。 * 我们可以不考虑输出结果的顺序。 ...
0
Java
0
0
0dcd8438e0846493ced9c1294ce686bac34c8614
2,068
Java8InAction
MIT License
solutions/src/Day12.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
import java.util.* fun main() { fun part1(input: List<String>): Int { val grid = parseGrid(input, destinationChar = 'E') return search( grid = grid, destinationChar = 'E', fromCharGetter = { char -> if (char == 'S') { 'a' ...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
4,217
advent-of-code-22
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2018/Day4.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2018 import com.chriswk.aoc.util.dayInputAsLines import com.chriswk.aoc.util.fileToLines import com.chriswk.aoc.util.rangeTo import com.chriswk.aoc.util.toLocalDateTime import java.time.Duration import java.time.LocalDateTime object Day4 { val lines = dayInputAsLines(2018, 4) val...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,743
adventofcode
MIT License
src/main/kotlin/days/Day15.kt
poqueque
430,806,840
false
{"Kotlin": 101024}
package days import util.Coor // Using Dijkstra's algorithm // https://es.wikipedia.org/wiki/Algoritmo_de_Dijkstra class Day15 : Day(15) { val size = 100 override fun partOne(): Any { val map = mutableMapOf<Coor, Int>() val shortest = mutableMapOf<Coor, Int>() val pending = mutableL...
0
Kotlin
0
0
4fa363be46ca5cfcfb271a37564af15233f2a141
4,350
adventofcode2021
MIT License
src/com/weiliange/algorithm/AddTwoNumbers.kt
WeiLianYang
467,326,442
false
{"Kotlin": 3867}
package com.weiliange.algorithm import kotlin.math.pow /** * @author : WilliamYang * @date : 2022/3/8 11:36 * @description : <a href="https://leetcode-cn.com/problems/add-two-numbers">两数相加</a> * * 给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。 * 请你将两个数相加,并以相同形式返回一个表示和的链表。 * 你可以假设除了数字 0 之外,这两个数都不会...
0
Kotlin
0
3
0b2defc34a14af396fe2d08fe3ef30b3f734f8a4
3,741
AlgorithmAnalysis
Apache License 2.0
src/Day05.kt
realpacific
573,561,400
false
{"Kotlin": 59236}
import java.util.* fun main() { val commandRegex = Regex("move (\\d+) from (\\d+) to (\\d+)") class CrateHolder { private val stack = Stack<String>() fun push(item: String) { stack.push(item) } fun pop(): String { return stack.pop()!! } ...
0
Kotlin
0
0
f365d78d381ac3d864cc402c6eb9c0017ce76b8d
3,486
advent-of-code-2022
Apache License 2.0
src/Day07.kt
valerakostin
574,165,845
false
{"Kotlin": 21086}
import java.util.* data class FileElement(val name: String, val length: Long) data class Dir( val name: String, val parent: Dir? = null, val children: MutableList<Dir> = mutableListOf(), val files: MutableList<FileElement> = mutableListOf(), var size: Long = 0 ) { override fun toString(): Stri...
0
Kotlin
0
0
e5f13dae0d2fa1aef14dc71c7ba7c898c1d1a5d1
3,636
AdventOfCode-2022
Apache License 2.0
src/main/kotlin/divine/brothers/qual/Setup.kt
AarjavP
450,892,849
false
{"Kotlin": 28300}
package divine.brothers.qual import com.google.common.collect.BiMap import com.google.common.collect.HashBiMap @JvmInline value class Skill(val id: Int) { override fun toString(): String = id.toString() } @JvmInline value class ContributorId(val id: Int) @JvmInline value class ProjectId(val id: Int) data clas...
0
Kotlin
0
0
3aaaefc04d55b1e286dde0895fa32f9c34f5c945
3,270
google-hash-code-2022
MIT License
src/main/kotlin/jks/Day2.kt
jksolbakken
572,966,811
false
{"Kotlin": 6326}
package jks import java.io.File import java.lang.RuntimeException import jks.Item.PAPER import jks.Item.ROCK import jks.Item.SCISSORS import jks.Result.DRAW import jks.Result.LOSER import jks.Result.WINNER fun main() { val uri = object {}::class.java.getResource("/day2_input")?.toURI() ?: throw RuntimeExc...
0
Kotlin
0
0
afc771f8a2843d92347929dab471aa491a40a675
2,423
aoc2022
MIT License
kotlin/problems/src/solution/WeeklyContest.kt
lunabox
86,097,633
false
{"Kotlin": 146671, "Python": 38767, "JavaScript": 19188, "Java": 13966}
package solution import java.util.* import kotlin.Comparator import kotlin.collections.HashMap import kotlin.math.abs import kotlin.math.max class WeeklyContest { /** * https://leetcode-cn.com/contest/weekly-contest-187/problems/destination-city/ */ fun destCity(paths: List<List<String>>): String {...
0
Kotlin
0
0
cbb2e3ad8f2d05d7cc54a865265561a0e391a9b9
22,281
leetcode
Apache License 2.0
src/main/kotlin/g2101_2200/s2101_detonate_the_maximum_bombs/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2101_2200.s2101_detonate_the_maximum_bombs // #Medium #Array #Math #Depth_First_Search #Breadth_First_Search #Graph #Geometry // #2023_06_25_Time_262_ms_(98.96%)_Space_40.7_MB_(78.76%) class Solution { fun maximumDetonation(bombs: Array<IntArray>): Int { val n = bombs.size val graph: Arra...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,578
LeetCode-in-Kotlin
MIT License
src/main/kotlin/days/Day9.kt
andilau
433,504,283
false
{"Kotlin": 137815}
package days typealias Basin = MutableList<List<IntRange>> typealias Basins = Set<Basin> @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2021/day/9", date = Date(day = 9, year = 2021) ) class Day9(private val seafloor: List<String>) : Puzzle { override fun partOne() = se...
0
Kotlin
0
0
b3f06a73e7d9d207ee3051879b83e92b049a0304
3,411
advent-of-code-2021
Creative Commons Zero v1.0 Universal
src/aoc2022/Day04.kt
NoMoor
571,730,615
false
{"Kotlin": 101800}
package aoc2022 import utils.* internal class Day04(lines: List<String>) { init { lines.forEach { println(it) } } private val lines = lines .map { val (a, b, c, d) = it.split('-', ',').map { it.toInt() } (a .. b) to (c .. d) } fun IntRange.contains(b: IntRange): Boolean { return this.f...
0
Kotlin
1
2
d561db73c98d2d82e7e4bc6ef35b599f98b3e333
1,389
aoc2022
Apache License 2.0
advent-of-code2015/src/main/kotlin/day10/Advent10.kt
REDNBLACK
128,669,137
false
null
package day10 /** --- Day 10: Elves Look, Elves Say --- Today, the Elves are playing a game called look-and-say. They take turns making sequences by reading aloud the previous sequence and using that reading as the next sequence. For example, 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s). Look-a...
0
Kotlin
0
0
e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7
2,039
courses
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem72/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem72 /** * LeetCode page: [72. Edit Distance](https://leetcode.com/problems/edit-distance/); */ class Solution { /* Complexity: * Time O(MN) and Space O(MN) where M and N are the length of word1 and word2; */ fun minDistance(word1: String, word2: String): Int { ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,107
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/aoc2019/SlamShuffle.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.multiplicativeInverse import komu.adventofcode.utils.nonEmptyLines fun slamShuffle(input: String): Long { val shuffle = Shuffle.parse(input.nonEmptyLines(), size = 10007) return shuffle(2019) } fun slamShuffle2(input: String): Long { val on...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
3,197
advent-of-code
MIT License
src/day09/Day09.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day09 import readInput import kotlin.math.abs import kotlin.math.sign enum class Direction { LEFT, UP, RIGHT, DOWN; companion object { fun from(letter: Char) = when (letter) { 'L' -> LEFT 'U' -> UP 'R' -> RIGHT 'D' -> DOWN ...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
3,474
advent-of-code-2022
Apache License 2.0
src/Day03.kt
acunap
573,116,784
false
{"Kotlin": 23918}
import kotlin.time.ExperimentalTime import kotlin.time.measureTime @OptIn(ExperimentalTime::class) fun main() { fun Char.itemCodeToPoints(): Int = if (isLowerCase()) code - 96 else code - 38 fun String.mapCharsToIndexes(): MutableMap<Char, MutableList<Int>> { val charsToIndexes = mutableMapOf<Char, Mu...
0
Kotlin
0
0
f06f9b409885dd0df78f16dcc1e9a3e90151abe1
1,731
advent-of-code-2022
Apache License 2.0
src/aoc2018/kot/Day16.kt
Tandrial
47,354,790
false
null
package aoc2018.kot import getNumbers import java.io.File object Day16 { fun partOne(input: List<String>) = input.chunked(4).takeWhile { it[0] != it[1] }.count { (before, op, after) -> check(before.getNumbers(), op.getNumbers(), after.getNumbers()).size >= 3 } fun partTwo(input: List<String>): Int { va...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
2,711
Advent_of_Code
MIT License
src/day14/Code.kt
fcolasuonno
162,470,286
false
null
package day14 import java.io.File import java.lang.Integer.min fun main(args: Array<String>) { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed, 25...
0
Kotlin
0
0
24f54bf7be4b5d2a91a82a6998f633f353b2afb6
1,471
AOC2015
MIT License
src/main/kotlin/days/Day18.kt
andilau
399,220,768
false
{"Kotlin": 85768}
package days @AdventOfCodePuzzle( name = "Operation Order", url = "https://adventofcode.com/2020/day/18", date = Date(day = 18, year = 2020) ) class Day18(val lines: List<String>) : Puzzle { override fun partOne() = lines.sumOf { equation -> solve(equation, Day18::solveFromLeft) } over...
7
Kotlin
0
0
2809e686cac895482c03e9bbce8aa25821eab100
2,422
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/aoc2022/Day02.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2022 import readInput fun main() { fun points(me: Char): Int { return me.minus('X') + 1 } fun draw(op: Char, me: Char): Boolean { return (op == 'A' && me == 'X') || (op == 'B' && me == 'Y') || (op == 'C' && me == 'Z') } fun won(op: Char, me: Char): Boolean { r...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
2,081
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day8/DesertMap.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day8 import com.github.michaelbull.advent2023.math.leastCommonMultiple private val NODE_REGEX = "[A-Z0-9]{3}".toRegex() private val NETWORK_REGEX = "($NODE_REGEX) = \\(($NODE_REGEX), ($NODE_REGEX)\\)".toRegex() fun Sequence<String>.toDesertMap(): DesertMap { var instruct...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
2,249
advent-2023
ISC License
kotlin/src/katas/kotlin/leetcode/add_two_numbers/AddTwoNumbers_2.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.add_two_numbers import datsok.shouldEqual import katas.kotlin.leetcode.ListNode import nonstdlib.with import org.junit.jupiter.api.Test class AddTwoNumbers_2_Tests { @Test fun `convert number to ListNode`() { 1.toListNode() shouldEqual ListNode(1) 10.toListNode() shou...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,340
katas
The Unlicense
src/main/kotlin/Day8.kt
maldoinc
726,264,110
false
{"Kotlin": 14472}
import java.util.function.Predicate import kotlin.io.path.Path import kotlin.io.path.readLines fun getSteps( instructions: String, navigation: Map<String, Pair<String, String>>, start: String, endPredicate: Predicate<String> ): Int { var location = start var locationIndex = 0 var steps = 0 ...
0
Kotlin
0
1
47a1ab8185eb6cf16bc012f20af28a4a3fef2f47
1,488
advent-2023
MIT License
src/main/kotlin/biz/koziolek/adventofcode/year2023/day25/day25.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2023.day25 import biz.koziolek.adventofcode.* fun main() { val inputFile = findInput(object {}) val graph = parseWiring(inputFile.bufferedReader().readLines()) val wiresToCut = findWiresToCut(graph) val newGraphs = graph.removeEdges(wiresToCut) println(wiresT...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
1,940
advent-of-code
MIT License
src/aoc2022/Day02.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2022 import readInput fun main() { val (year, day) = "2022" to "Day02" fun calculateScore(input: List<String>, withPlay: Boolean): Int { val lose = mapOf(1 to 0, 2 to 1, 0 to 2) val won = mapOf(0 to 1, 1 to 2, 2 to 0) return input.sumOf { round -> val (op, resu...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,361
aoc-kotlin
Apache License 2.0
lib/src/main/kotlin/com/bloidonia/advent/day06/Day06Optimized.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day06 import com.bloidonia.advent.readText import kotlin.collections.ArrayDeque class ArrayPopulation(private val population: LongArray) { fun generation() = (population.copyOfRange(1, 9) + population[0]).let { it[6] += it[8] ArrayPopulation(it) } fun size() =...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,529
advent-of-kotlin-2021
MIT License
src/2023/Day02.kt
nagyjani
572,361,168
false
{"Kotlin": 369497}
package `2023` import java.io.File import java.util.* import kotlin.math.max fun main() { Day02().solve() } class Day02 { val input1 = """ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red,...
0
Kotlin
0
0
f0c61c787e4f0b83b69ed0cde3117aed3ae918a5
2,439
advent-of-code
Apache License 2.0
src/Day08.kt
hufman
573,586,479
false
{"Kotlin": 29792}
open class ColumnView<E>(open val rows: List<List<E>>, val columnIndex: Int): AbstractMutableList<E>() { override fun add(index: Int, element: E) { TODO("Not yet implemented") } override fun removeAt(index: Int): E { TODO("Not yet implemented") } override fun set(index: Int, element: E): E { TODO("Not yet implemen...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
3,266
aoc2022-kt
Apache License 2.0
src/main/day7/Day07.kt
Derek52
572,850,008
false
{"Kotlin": 22102}
package main.day7 import main.readInput import java.util.* import kotlin.collections.HashSet fun main() { val input = readInput("day7/day7") val firstHalf = false testAlg(firstHalf) if (firstHalf) { println(part1(input)) } else { println(part2(input)) } } data class Director...
0
Kotlin
0
0
c11d16f34589117f290e2b9e85f307665952ea76
4,359
2022AdventOfCodeKotlin
Apache License 2.0
kotlin/2021/round-1a/hacked-exam/src/main/kotlin/testset1and2/TestSet1And2Solution.kt
ShreckYe
345,946,821
false
null
package testset1and2 import testset1and2.Fraction.Companion.one import java.math.BigInteger fun main() { val t = readLine()!!.toInt() repeat(t, ::testCase) } fun testCase(ti: Int) { val (n, q) = readLine()!!.splitToSequence(' ').map { it.toInt() }.toList() val ass = List(n) { val lineInputs =...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
4,454
google-code-jam
MIT License
src/main/java/challenges/cracking_coding_interview/sorting_and_searching/sorted_matrix_search/QuestionB.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.sorting_and_searching.sorted_matrix_search import challenges.util.AssortedMethods.printMatrix object QuestionB { private fun partitionAndSearch( matrix: Array<IntArray>, origin: Coordinate, dest: Coordinate, pivot: Coordinate, x:...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,444
CodingChallenges
Apache License 2.0
src/main/kotlin/be/swsb/aoc2021/day1/Day1.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day1 object Day1 { fun solve1(depthMeasurementInput: List<String>): Int { return depthMeasurementInput .map { it.toDepthMeasurement() } .zipWithNext() .count { (prev, cur) -> prev < cur } } fun solve2(depthMeasurementInput: List<String>): ...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
1,408
Advent-of-Code-2021
MIT License
src/Day09.kt
thelmstedt
572,818,960
false
{"Kotlin": 30245}
import java.io.File import kotlin.math.abs enum class Cardinal { N, NE, E, SE, S, SW, W, NW } typealias Point = Pair<Int, Int> fun move(p: Point, dir: Cardinal): Pair<Int, Int> { return when (dir) { Cardinal.N -> p.first to p.second - 1 Cardinal.NE -> p.first + 1 to p.second - 1 Cardi...
0
Kotlin
0
0
e98cd2054c1fe5891494d8a042cf5504014078d3
5,462
advent2022
Apache License 2.0
grind-75-kotlin/src/main/kotlin/ImplementQueueUsingStacks.kt
Codextor
484,602,390
false
{"Kotlin": 27206}
/** * Implement a first in first out (FIFO) queue using only two stacks. * The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). * * Implement the .MyQueue class: * * void push(int x) Pushes element x to the back of the queue. * int pop() Removes the element from ...
0
Kotlin
0
0
87aa60c2bf5f6a672de5a9e6800452321172b289
2,627
grind-75
Apache License 2.0
src/aoc2023/Day12.kt
anitakar
576,901,981
false
{"Kotlin": 124382}
package aoc2023 import readInput fun main() { fun arrangementForSequence(sequence: String): String { var result = "" var count = 0 for (i in sequence.indices) { if (sequence[i] == '#') { count += 1 } else { if (count > 0) { ...
0
Kotlin
0
1
50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf
2,722
advent-of-code-kotlin
Apache License 2.0
src/Day01.kt
camina-apps
572,935,546
false
{"Kotlin": 7782}
fun main() { fun caloriesPerElve(rucksack: String) = rucksack.replace(",", "") .trim() .split(" ") .sumOf { it.toInt() } fun getElvesList(input: List<String>): List<String> = input.toString() .removePrefix("[") .removeSuffix("]") ...
0
Kotlin
0
0
fb6c6176f8c127e9d36aa0b7ae1f0e32b5c31171
921
aoc_2022
Apache License 2.0
advent23-kt/app/src/main/kotlin/dev/rockyj/advent_kt/Day3.kt
rocky-jaiswal
726,062,069
false
{"Kotlin": 41834, "Ruby": 2966, "TypeScript": 2848, "JavaScript": 830, "Shell": 455, "Dockerfile": 387}
package dev.rockyj.advent_kt private fun part1(input: List<String>) { val symbols = mutableMapOf<Pair<Int, Int>, String>() var lenX = 0 input.forEachIndexed { idx, line -> val sls = line.trim().split("") lenX = sls.subList(1, sls.size - 1).size sls.subList(1, sls.size - 1).forEachI...
0
Kotlin
0
0
a7bc1dfad8fb784868150d7cf32f35f606a8dafe
4,795
advent-2023
MIT License
src/day2/day02.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
private fun itemPoint(item: Char): Int = when { item == 'X' || item == 'A' -> 0 // rock item == 'Y' || item == 'B' -> 1 // paper item == 'Z' || item == 'C' -> 2 // scisorr else -> 0 } private fun part1(input: List<String>): Int { fun winning(first: Char, second: Char): Int { ...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
1,812
aoc-2022
Apache License 2.0
src/main/kotlin/com/github/solairerove/algs4/leprosorium/strings/LongestPalindrome.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.strings fun main() { print(longestPalindrome("arpkqqkpfkpdp")) // pkqqkp } // O(n^2) time | O(n) space private fun longestPalindrome(s: String): String { var longest = listOf(0, 1) for (i in 1 until s.length) { val odd = getLongestPalindrome(s, i -...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
877
algs4-leprosorium
MIT License
src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0001_0100.s0005_longest_palindromic_substring // #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming // #Data_Structure_II_Day_9_String #Algorithm_II_Day_14_Dynamic_Programming // #Dynamic_Programming_I_Day_17 #Udemy_Strings #Big_O_Time_O(n)_Space_O(n) // #2023_07_03_Time_16...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,485
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/aoc2023/day6/Day6.kt
brookseakate
729,329,997
false
{"Kotlin": 8231}
package main.kotlin.com.aoc2023.day6 import kotlin.math.pow import kotlin.math.sqrt class Day6 { companion object { fun main() { println("hello Day 6") val (timesList, distancesList) = getInput() println(getProductOfWinningStrategies(timesList, distancesList)) } fun parseInput() { ...
0
Kotlin
0
0
885663f27a8d5f6e6c5eaf046df4234b49bc53b9
2,731
advent-of-code-2023
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day22.kt
clechasseur
435,726,930
false
{"Kotlin": 315943}
package io.github.clechasseur.adventofcode2021 import io.github.clechasseur.adventofcode2021.data.Day22Data import io.github.clechasseur.adventofcode2021.util.Pt3D import kotlin.math.max import kotlin.math.min object Day22 { private val data = Day22Data.data fun part1(): Int = data.lineSequence().take(20).ma...
0
Kotlin
0
0
4b893c001efec7d11a326888a9a98ec03241d331
2,845
adventofcode2021
MIT License
src/com/hlq/leetcode/array/Question14.kt
HLQ-Struggle
310,978,308
false
null
package com.hlq.leetcode.array import java.util.* /** * @author HLQ_Struggle * @date 2020/11/09 * @desc LeetCode 14. 最长公共前缀 https://leetcode-cn.com/problems/longest-common-prefix/ */ fun main() { val strs = arrayOf("flower", "flow", "flight") val strs1 = arrayOf("flower", "flower", "flower", "flower") ...
0
Kotlin
0
2
76922f46432783218ddd34e74dbbf3b9f3c68f25
3,182
LeetCodePro
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day1/Day1.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day1 import com.jacobhyphenated.advent2023.Day /** * Day 1: Trebuchet?! * * The puzzle input is a list of strings. The calibration score for each line is the first digit in the line * combined with the last digit in the line. Example: a1b2c3d4e5f is 15 */ class Day1: Day<Li...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
3,849
advent2023
The Unlicense
src/Day01.kt
iownthegame
573,926,504
false
{"Kotlin": 68002}
fun main() { fun getCaloriesOfElves(input: List<String>): Array<Int> { var caloriesOfElves = arrayOf<Int>() var currentCalories = 0 for (line: String in input) { if (line.isEmpty()) { caloriesOfElves += currentCalories currentCalories = 0 ...
0
Kotlin
0
0
4e3d0d698669b598c639ca504d43cf8a62e30b5c
1,186
advent-of-code-2022
Apache License 2.0
src/Day10.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
import kotlin.math.* fun main() { fun List<String>.toRegisterPoints(): List<Int> { var currentValue = 1 val result = mutableListOf(currentValue) for (line in this) { val commands = line.split(' ') when (commands[0]) { "noop" -> result.add(currentValu...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
1,487
advent-of-code-kotlin-2022
Apache License 2.0
kotlin/app/src/main/kotlin/coverick/aoc/day7/NoSpaceLeftOnDrive.kt
RyTheTurtle
574,328,652
false
{"Kotlin": 82616}
package coverick.aoc.day7 import readResourceFile val INPUT_FILE = "noSpaceLeftOnDevice-input.txt" class Dir(val path:String, val parent: Dir?){ val files = ArrayList<Long>() val subDirs = ArrayList<Dir>() fun nav(nextPath: String) :Dir { return when(nextPath){ ".."-> when(this.parent)...
0
Kotlin
0
0
35a8021fdfb700ce926fcf7958bea45ee530e359
3,632
adventofcode2022
Apache License 2.0
src/Day04.kt
ChrisCrisis
575,611,028
false
{"Kotlin": 31591}
fun main() { fun String.getSectionRange(): IntRange { return this.split("-").let { it.first().toInt() .. it.last().toInt() } } fun List<String>.processInput(): List<ElvenPair>{ return this.map { val elves = it.split(",") ElvenPair( ...
1
Kotlin
0
0
732b29551d987f246e12b0fa7b26692666bf0e24
1,374
aoc2022-kotlin
Apache License 2.0
src/Day06.kt
schoi80
726,076,340
false
{"Kotlin": 83778}
fun main() { val input = readInput("Day06") fun numWaysToWin(time: Long, distance: Long): Long { return (1..time).count { speed -> (time - speed) * speed > distance }.toLong() } fun part1(input: List<String>): Long { val time = input[0].split(":")[1].trim().split("...
0
Kotlin
0
0
ee9fb20d0ed2471496185b6f5f2ee665803b7393
941
aoc-2023
Apache License 2.0
src/Day03_2021.kt
Scholar17
579,871,947
false
{"Kotlin": 24751}
import java.io.File fun main() { fun parseInput(input: String): List<List<Int>> { return input.split("\n").map { bit -> bit.map { it.digitToIntOrNull() ?: 0 } } } val filename = "src/Day03_sample_2021.txt" // "src/Day03_quiz_2021.txt"...
0
Kotlin
0
2
d3d79fbeeb640a990dbeccf2404612b4f7922b38
2,076
aoc-2022-in-kotlin
Apache License 2.0
src/Day03.kt
andrikeev
574,393,673
false
{"Kotlin": 70541, "Python": 18310, "HTML": 5558}
fun main() { val chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun priority(char: Char) = chars.indexOf(char) + 1 fun part1(input: List<String>): Int { return input .map { line -> val first = line.take(line.length / 2).toSet() val second ...
0
Kotlin
0
1
1aedc6c61407a28e0abcad86e2fdfe0b41add139
1,058
aoc-2022
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2021/Dec08.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2021 import org.elwaxoro.advent.PuzzleDayTester /** * Seven Segment Search */ class Dec08 : PuzzleDayTester(8, 2021) { /** * Only care about the right side of the pipe * Only care about unique length digits */ override fun part1(): Any = load().map { it.split(" |...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,382
advent-of-code
MIT License
src/main/aoc2016/Day8.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2016 class Day8(input: List<String>) { private data class Instruction(val action: Action, val a: Int, val b: Int) { fun execute(display: Array<IntArray>) { when (action) { Action.Rect -> createRect(display, a, b) Action.RotateRow -> rotateRow(display, ...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,862
aoc
MIT License
src/main/kotlin/com/mckernant1/leetcode/RegexMatching.kt
mckernant1
494,952,749
false
{"Kotlin": 33093}
package com.mckernant1.leetcode /** * ab*cd* * ab | cd | [] * abbbbbbbbbcdddddd * * * a.|c|cc * ab.cccbbbcc * */ fun main() { println(isMatch("aaa", "ab*a*c*a")) // println(isMatch("aab", "c*a*b")) } private fun isMatch(input: String, pattern: String): Boolean { if (pattern == ".*") return true ...
0
Kotlin
0
0
5aaa96588925b1b8d77d7dd98dd54738deeab7f1
1,089
kotlin-random
Apache License 2.0
src/day08/Day08.kt
palpfiction
572,688,778
false
{"Kotlin": 38770}
package day08 import readInput typealias Matrix<T> = MutableList<MutableList<T>> fun emptyMatrix(x: Int, y: Int) = MutableList(x) { MutableList(y) { 0 } } fun <T> Matrix<T>.dimensions() = this.size to this[0].size fun <T> Matrix<T>.print() { val (rows, columns) = this.dimensions() for (j in 0 until columns...
0
Kotlin
0
0
5b79ec5fa4116e496cd07f0c7cea7dabc8a371e7
5,087
advent-of-code
Apache License 2.0
src/Day21.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
enum class Operator { Plus, Minus, Times, Divide } fun main() { abstract class Monkey(val name: String) class Number(name: String, val number: Long): Monkey(name) // After solving part 2 I realize monkey1 and monkey2 should be of type Monkey instead of String. // That would have allowed more object-o...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
4,541
aoc2022-kotlin
Apache License 2.0
p11/src/main/kotlin/ChronalCharge.kt
jcavanagh
159,918,838
false
null
package p11 class FuelCell(val x: Int, val y: Int, gridSN: Int) { val rackID = x + 10 val power = getPower(gridSN) private fun getPower(gridSN: Int): Int { var pwr = rackID * y pwr += gridSN pwr *= rackID pwr /= 100 if(pwr < 100) { pwr = 0 } else { pwr -= pwr / 10 * 10 } ...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
2,241
advent2018
MIT License
src/main/kotlin/main.kt
gavq
291,229,489
false
null
fun pad2(n: Int): String { val s = "$n" return if (s.length < 2) " $s" else s } interface ICell { fun draw(): String } interface IDown { val down: Int } interface IAcross { val across: Int } // singleton object EmptyCell : ICell { override fun toString() = "EmptyCell" override fun draw(...
0
Kotlin
0
0
413f26dcca9b5041eef3bf6187ed08c68c69d507
5,047
kakuro-kotlin
MIT License
src/Day04.kt
ManueruEd
573,678,383
false
{"Kotlin": 10647}
fun main() { val day = "04" fun part1(input: List<String>): Int { val ans = input.mapNotNull { val s = it.split(",") .map { it.split("-") .map { it.toInt() } } val p1: List<Int> = s[0] val ...
0
Kotlin
0
0
09f3357e059e31fda3dd2dfda5ce603c31614d77
1,337
AdventOfCode2022
Apache License 2.0
src/day15/day15.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
package day15 import com.google.common.collect.Range import com.google.common.collect.RangeSet import com.google.common.collect.TreeRangeSet import streamInput import java.util.BitSet import kotlin.math.abs import kotlin.math.max import kotlin.math.min //val file = "Day15Example" val file = "Day15" data class Point(...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
3,069
aoc-2022
Apache License 2.0
src/main/kotlin/day10.kt
gautemo
725,273,259
false
{"Kotlin": 79259}
import shared.Input import shared.Point import shared.XYMap fun main() { val input = Input.day(10) println(day10A(input)) println(day10B(input)) } fun day10A(input: Input): Int { val map = XYMap(input) { if (it == '.') null else it } val trail = getTrail(map) return trail.size / 2 } /* next t...
0
Kotlin
0
0
6862b6d7429b09f2a1d29aaf3c0cd544b779ed25
4,609
AdventOfCode2023
MIT License
src/main/kotlin/day2.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.util.stream.Collectors data class PolicyAndPassword( val min: Int, val max: Int, val str: String, val password: String, ) // https://adventofcode.com/2020/day/2 class Day2( private val values: List<PolicyAndPassword> ) { fun solve(): Long { return values .stream...
0
Ruby
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
2,156
adventofcode_2020
MIT License
src/Day13.kt
brigittb
572,958,287
false
{"Kotlin": 46744}
fun main() { fun convertToList( remaining: String, sb: StringBuilder = StringBuilder(), level: Level, ): Level { val currentChar = if (remaining.isEmpty()) { if (sb.isNotEmpty()) { val itemToAdd = sb.toString().toInt() level.current.ad...
0
Kotlin
0
0
470f026f2632d1a5147919c25dbd4eb4c08091d6
5,882
aoc-2022
Apache License 2.0
2021/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2021/day18/Day18.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.aoc2021.day18 import nl.sanderp.aoc.common.* fun main() { val input = readResource("Day18.txt").lines().map { parse(it) } val (answer1, duration1) = measureDuration<Int> { input.reduce { a, b -> a + b }.magnitude } println("Part one: $answer1 (took ${duration1.prettyPrint()})") ...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
3,856
advent-of-code
MIT License
src/Day24.kt
Riari
574,587,661
false
{"Kotlin": 83546, "Python": 1054}
import kotlin.math.abs fun main() { data class Vector2(var x: Int, var y: Int) { operator fun plus(other: Vector2): Vector2 = Vector2(x + other.x, y + other.y) operator fun minus(other: Vector2): Vector2 = Vector2(x - other.x, y - other.y) override operator fun equals(other: Any?): Boolean ...
0
Kotlin
0
0
8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d
5,021
aoc-2022
Apache License 2.0
src/Day10.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
class Cpu(var clock: Int = 1, var x: Int = 1) { var sum = 0 fun tick(increment: Int = 0) { clock++ x += increment if ((clock - 20) % 40 == 0) { sum += clock * x } } } class Crt(val cpu: Cpu) { private val screen = Array(6) { CharArray(40) } fun drawP...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
2,031
advent-of-code-kotlin-2022
Apache License 2.0
2022/Day15.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
import kotlin.math.abs fun main() { val input = readInput("Day15") val maxxy = 4000000L val coords = input.map { s -> s.split("Sensor at x=", ", y=", ": closest beacon is at x=").drop(1).map { it.toLong() } } val minx = coords.minOf { minOf(it[0], it[2]) } val maxx = coords.maxOf { maxO...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,304
advent-of-code-kotlin
Apache License 2.0
2023/13/Solution.kt
AdrianMiozga
588,519,359
false
{"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732}
import java.io.File import kotlin.math.min private const val FILENAME = "2023/13/input.txt" fun main() { partOne() partTwo() } private fun partOne() { val file = File(FILENAME).readText().split("\r\n\r\n").map { it.split("\r\n") } var result = 0 for (pattern in file) { val transp...
0
Kotlin
0
0
c9cba875089d8d4fb145932c45c2d487ccc7e8e5
3,500
Advent-of-Code
MIT License
src/main/kotlin/solutions/day22/Day22.kt
Dr-Horv
112,381,975
false
null
package solutions.day22 import solutions.Solver import utils.Coordinate import utils.Direction import utils.step fun Direction.left() = when (this) { Direction.UP -> Direction.LEFT Direction.LEFT -> Direction.DOWN Direction.RIGHT -> Direction.UP Direction.DOWN -> Direction.RIGHT } fun Direction.right...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
2,871
Advent-of-Code-2017
MIT License
src/main/kotlin/day09.kt
mgellert
572,594,052
false
{"Kotlin": 19842}
import kotlin.math.abs import kotlin.math.sign object RopeBridge : Solution { fun moveRope(motions: List<Direction>, parts: Int): Int { val rope = List(parts) { Rope() } val tailPositions = mutableSetOf(rope.last().toPair()) motions.forEach { direction -> rope[0].move(directio...
0
Kotlin
0
0
4224c762ad4961b28e47cd3db35e5bc73587a118
1,774
advent-of-code-2022-kotlin
The Unlicense
src/main/kotlin/be/swsb/aoc2021/day3/Day3.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day3 object Day3 { fun getPowerConsumption(input: List<String>): Pair<String, String> { var result = (1..input[0].length).map { 0 } input.forEach { bitNumber -> val bitAsCalculcations = bitNumber.map { if (it == '1') 1 else -1 } result = bitAsCalculca...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
1,484
Advent-of-Code-2021
MIT License
src/main/kotlin/nl/meine/aoc/_2023/Day3.kt
mtoonen
158,697,380
false
{"Kotlin": 201978, "Java": 138385}
package nl.meine.aoc._2023 import kotlin.math.max import kotlin.math.min class Day3 { fun one(input: String): Int { val lines = input.split("\n") val matrix = lines.map { it.toCharArray() }.toTypedArray() val numbers: MutableList<Int> = mutableListOf() matrix.onEachI...
0
Kotlin
0
0
a36addef07f61072cbf4c7c71adf2236a53959a5
26,476
advent-code
MIT License
2022/src/day17/day17.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day17 import GREEN import RESET import printTimeMillis import readInput import java.math.BigInteger data class Point(val x: Int, val y: Int) val ROCKS = listOf( setOf(Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0)), setOf(Point(1, 0), Point(0, 1), Point(1, 1), Point(2, 1), Point(1, 2)), setOf(...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,697
advent-of-code
Apache License 2.0
src/main/kotlin/ca/voidstarzero/isbd/titlestatement/grammar/SeriesTitle.kt
hzafar
262,218,140
false
null
package ca.voidstarzero.isbd.titlestatement.grammar import ca.voidstarzero.isbd.titlestatement.ast.* import ca.voidstarzero.marc.MARCField import norswap.autumn.DSL.rule val TitleStatementGrammar.seriesTitle: rule get() = seq(data, seriesTitleOtherInfo.maybe(), period.maybe()) .push { items -> ...
2
Kotlin
0
2
16bb26858722ca818c0a9f659be1cc9d3e4e7213
3,808
isbd-parser
MIT License
src/main/kotlin/com/github/alturkovic/robots/txt/RobotsTxt.kt
alturkovic
636,725,117
false
null
package com.github.alturkovic.robots.txt import com.github.alturkovic.robots.txt.StringUtils.greatestCommonPrefix data class RobotsTxt( val ruleGroups: List<RuleGroup>, private val ruleMatchingStrategy: RuleMatchingStrategy = WildcardRuleMatchingStrategy, private val ruleSelectionStrategy: RuleSelectionSt...
0
Kotlin
0
1
a70632010f74029f5e6414aaaa464975ba51b481
2,204
robots-txt
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinOperations.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,304
kotlab
Apache License 2.0
src/chapter2/problem5/solution1.kts
neelkamath
395,940,983
false
null
/* Question: Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list. EXAMPLE Input: (7 -> 1 -> 6) + ...
0
Kotlin
0
0
4421a061e5bf032368b3f7a4cee924e65b43f690
2,728
ctci-practice
MIT License
kotlin/hackerrank/algorithms.kt
jmfayard
82,162,118
false
null
package hackerrank import org.junit.Test fun stdin(): List<String> { if (System.`in`.available() == 0) { System.err.println("nothing in stdin"); System.exit(1) } return generateSequence { readLine() }.toList() } inline fun <T> Iterable<T>.sumLong(selector: (T) -> Long): Long { var sum = 0L ...
0
Kotlin
2
6
b0c51334749a632b6413ae08f131612460abd432
2,180
skripts
Apache License 2.0
src/Day10.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
enum class OpType(val ticks: Int) { ADDX(2), NOOP(1), } class Computer { private val ops: MutableList<Pair<OpType, Int>> = mutableListOf() private var ip = 0 private var tick = 0 private var nextInc = 0 var reg = 1 private fun doOp(op: OpType, arg: Int) { when (op) { ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
2,856
aoc2022
Apache License 2.0
src/Day01.kt
bogdanbeczkowski
572,679,090
false
{"Kotlin": 8398}
import java.lang.Integer.max fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var currentElf = 0 for (line in input) { if (line.isNotEmpty()) { currentElf += line.toInt() } else { maxCalories = max(currentElf, max...
0
Kotlin
0
0
03c29c7571e0d98ab00ee5c4c625954c0a46ab00
1,416
AoC-2022-Kotlin
Apache License 2.0
src/adventofcode/blueschu/y2017/day04/solution.kt
blueschu
112,979,855
false
null
package adventofcode.blueschu.y2017.day04 import java.io.File import kotlin.test.assertFalse import kotlin.test.assertTrue fun input(): List<String> = File("resources/y2017/day04.txt") .readLines() fun main(args: Array<String>) { assertTrue { wordsDistinct("aa bb cc dd ee") } assertFalse { wordsDistinct(...
0
Kotlin
0
0
9f2031b91cce4fe290d86d557ebef5a6efe109ed
1,231
Advent-Of-Code
MIT License
src/day12/puzzle12.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day12 import Puzzle import PuzzleInput import kotlinx.coroutines.* import kotlinx.coroutines.sync.Semaphore import java.io.File import kotlin.coroutines.coroutineContext import kotlin.math.abs fun day12Puzzle() { //Day12PuzzleSolution().solve(Day12PuzzleInput("inputs/day12/example.txt", 31)) //Day12Pu...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
4,860
aoc_2022
Apache License 2.0
src/main/kotlin/day11.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day11 : Solvable("11") { override fun solveA(input: List<String>): String { val grid = getGrid(input) var flashes = 0 repeat(100) { flashes += simulateStep(grid) } return flashes.toString() } override fun solveB(input: List<String>): String { val grid = get...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
2,071
AdventOfCode
Creative Commons Zero v1.0 Universal
2017-kotlin/src/main/kotlin/com/morninghacks/aoc2017/Day08.kt
whaley
116,508,747
false
null
package com.morninghacks.aoc2017 import java.lang.invoke.MethodHandles /* You receive a signal directly from the CPU. Because of your recent assistance with jump instructions, it would like you to compute the result of a series of unusual register instructions. Each instruction consists of several parts: the registe...
0
Kotlin
0
0
16ce3c9d6310b5faec06ff580bccabc7270c53a8
4,575
advent-of-code
MIT License
src/Day02.kt
6234456
572,616,769
false
{"Kotlin": 39979}
fun main() { val judge: (Char, Char)->Int = { a, x -> val t1 = a - 'A' val t2 = x - 'X' (t2 + 1) + ( if (t1 == t2) 3 else{ if((t1 + 2).mod(3) == t2) 0 else 6 }) } val judge2: (Char, Ch...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
1,148
advent-of-code-kotlin-2022
Apache License 2.0
src/Day02.kt
carotkut94
572,816,808
false
{"Kotlin": 7508}
fun main() { fun prepare(input: String): List<String> { return input.split("\n") } fun part1(input: List<String>): Int { var total = 0 input.forEach { val (move1, move2) = it.split(" ") val v1 = getValue(move1) val v2 = getValue(move2) ...
0
Kotlin
0
0
ef3dee8be98abbe7e305e62bfe8c7d2eeff808ad
1,223
aoc-2022
Apache License 2.0
src/Day04.kt
matusekma
572,617,724
false
{"Kotlin": 119912, "JavaScript": 2024}
class Day04 { fun part1(input: List<String>): Int { var sum = 0 for (row in input) { val (first, second) = row.split(',') .map { interval -> interval.split('-').map { it.toInt() } } if((first[0] <= second[0] && first[1] >= second[1]) || (first[...
0
Kotlin
0
0
744392a4d262112fe2d7819ffb6d5bde70b6d16a
1,072
advent-of-code
Apache License 2.0
src/main/kotlin/io/github/mikaojk/day1/part2/Day1Part2.kt
MikAoJk
724,057,348
false
{"Kotlin": 6448}
package io.github.mikaojk.day1.part2 import io.github.mikaojk.day1.part1.CalibrationDigit import io.github.mikaojk.day1.part1.CalibrationDigits import io.github.mikaojk.day1.part1.getFileAsString import io.github.mikaojk.day1.part1.sumAllDigtits fun day1Part2(): String { val calibrationDocument = getFileAsString(...
0
Kotlin
0
0
0147f91c722225ae12382a82d131695b2ec5a766
2,248
advent-of-code-2023
MIT License
src/main/kotlin/de/dikodam/calendar/Day06.kt
dikodam
433,719,746
false
{"Kotlin": 51383}
package de.dikodam.calendar import de.dikodam.AbstractDay import de.dikodam.executeTasks import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { Day06().executeTasks() } val memoizationMap = mutableMapOf<Pair<Int, Int>, Long>() fun computeRes(startState: Int, rounds: Int): Long { if (startState > ...
0
Kotlin
0
1
4934242280cebe5f56ca8d7dcf46a43f5f75a2a2
2,580
aoc-2021
MIT License
src/Day01.kt
jordanfarrer
573,120,618
false
{"Kotlin": 20954}
fun main() { fun getElves(input: List<String>): List<Elf> { var elfIndex = 0 val elves = mutableListOf<Elf>() for (line in input) { if (line == "") { elfIndex++ } else { var elf = elves.find { it.index == elfIndex } if (...
0
Kotlin
0
1
aea4bb23029f3b48c94aa742958727d71c3532ac
1,412
advent-of-code-2022-kotlin
Apache License 2.0
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day09.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 import kotlin.math.abs /** * https://adventofcode.com/2022/day/9 */ class Day09(override val input: String) : Day() { override fun part1(): String { var headPos = Point(0, 0) var tailPos = Point(0, 0) val seenTailPos = mutableSetOf<Point>().apply { add(ta...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
2,876
adventofcode2022
MIT License
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day19.kt
akikanellis
600,872,090
false
{"Kotlin": 142932, "Just": 977}
package com.akikanellis.adventofcode.year2022 import java.util.* import kotlin.math.ceil import kotlin.math.max object Day19 { private val BLUEPRINT_REGEX = """\d+""".toRegex() fun qualityLevelsOfBlueprints(input: String) = blueprints(input) .map { blueprint -> Pair(blueprint.id, blueprint.maxGeodeTh...
8
Kotlin
0
0
036cbcb79d4dac96df2e478938de862a20549dce
7,485
advent-of-code
MIT License
Core/src/main/kotlin/com/github/ezauton/core/utils/math/AlgebraUtils.kt
ezAuton
140,008,964
false
null
package com.github.ezauton.core.utils.math /** * @param map * @return If is odd function */ fun hasOddSymmetry(map: Map<out Double, Double>): Boolean { return map.entries.stream().allMatch { entry -> val key = entry.key val value = entry.value val symmetricEntry = map[-key]?.toDouble() symmetricEn...
26
Kotlin
3
25
b08c52233b0c492e1b5fa0a4d638b436b5d06605
1,622
ezAuton
MIT License
src/Day01.kt
pedroldk
573,424,273
false
{"Kotlin": 4625}
fun main() { fun getCarriersValues(input: List<String>): MutableList<Int> { val biggestCarriers = mutableListOf<Int>() var sum = 0 for (line in input) { if (line == "") { biggestCarriers.add(sum) sum = 0 } else { sum += ...
0
Kotlin
0
0
68348bbfc308d257b2d02fa87dd241f8f584b444
1,091
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/adventofcode/day05/AlmanacSection.kt
jwcarman
731,408,177
false
{"Kotlin": 137289}
/* * Copyright (c) 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 ...
0
Kotlin
0
0
dfb226e92a03323ad48c50d7e970d2a745b479bb
2,962
adventofcode2023
Apache License 2.0
src/main/kotlin/day3/Day3NoMatterHowYouSliceIt.kt
Zordid
160,908,640
false
null
package day3 import shared.readPuzzle data class Claim(val id: String, val left: Int, val top: Int, val width: Int, val height: Int) { private val right = left + width - 1 private val bottom = top + height - 1 fun cut(fabric: List<ByteArray>) { for (line in top until (top + height)) { ...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
1,360
adventofcode-kotlin-2018
Apache License 2.0
src/day15/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day15 import java.io.File import java.util.* val deltas = listOf(Coord(-1, 0), Coord(1, 0), Coord(0, -1), Coord(0, 1)) data class Coord(val x: Int, val y: Int) data class CoordRisk(val coord: Coord, val risk: Int) fun Map<Coord, Int>.explore(): Int { val end = Coord(keys.maxOf { it.x }, keys.maxOf { it....
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,546
advent-of-code-2021
MIT License