path
stringlengths
5
169
owner
stringlengths
2
34
repo_id
int64
1.49M
755M
is_fork
bool
2 classes
languages_distribution
stringlengths
16
1.68k
content
stringlengths
446
72k
issues
float64
0
1.84k
main_language
stringclasses
37 values
forks
int64
0
5.77k
stars
int64
0
46.8k
commit_sha
stringlengths
40
40
size
int64
446
72.6k
name
stringlengths
2
64
license
stringclasses
15 values
src/main/kotlin/io/github/kmakma/adventofcode/y2020/Y2020Day16.kt
kmakma
225,714,388
false
null
package io.github.kmakma.adventofcode.y2020 import io.github.kmakma.adventofcode.utils.Day fun main() { Y2020Day16().solveAndPrint() } class Y2020Day16 : Day(2020, 16, "Ticket Translation") { private lateinit var inputLines: List<String> override fun initializeDay() { inputLines = inputInStringL...
0
Kotlin
0
0
7e6241173959b9d838fa00f81fdeb39fdb3ef6fe
4,563
adventofcode-kotlin
MIT License
kotlin/numbertheory/PrimesAndDivisors.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package numbertheory import java.util.Arrays object PrimesAndDivisors { // Generates prime numbers up to n in O(n*log(log(n))) time fun generatePrimes(n: Int): IntArray { val prime = BooleanArray(n + 1) Arrays.fill(prime, 2, n + 1, true) run { var i = 2 while (i...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
4,506
codelibrary
The Unlicense
src/main/kotlin/year2022/Day20.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils.test fun main() { data class LinkedList(val value: Long) { lateinit var prev: LinkedList lateinit var next: LinkedList fun moveBack() { val a = this.prev.prev val b = this.prev val d = this.next a.next = this this...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
3,836
aoc-2022-kotlin
Apache License 2.0
Problems/Algorithms/1235. Maximum Profit in Job Scheduling/MaxProfit.kt
xuedong
189,745,542
false
{"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65}
class Solution { fun jobScheduling(startTime: IntArray, endTime: IntArray, profit: IntArray): Int { val n = startTime.size val jobs = Array(n) { IntArray(3) { 0 } } for (i in 0..n-1) { jobs[i][0] = startTime[i] jobs[i][1] = endTime[i] jobs[i][2] = profit[i...
0
Kotlin
0
1
5e919965b43917eeee15e4bff12a0b6bea4fd0e7
1,070
leet-code
MIT License
aoc-2022/src/main/kotlin/nerok/aoc/aoc2022/day12/Day12.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2022.day12 import nerok.aoc.utils.GenericGrid import nerok.aoc.utils.Input import nerok.aoc.utils.Point import nerok.aoc.utils.removeFirstOrNull import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { val heightMap = GenericGri...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
4,780
AOC
Apache License 2.0
src/Day11.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
import java.math.BigInteger interface Operation { fun exec(input: Long): Long } class Multiply(private val multiplier: Long) : Operation { override fun exec(input: Long): Long { return input * multiplier } } class Add(private val addValue: Long) : Operation { override fun exec(input: Long): Lon...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
4,694
KotlinAdventOfCode2022
Apache License 2.0
LengthOfLongestSubstring.kt
linisme
111,369,586
false
null
class LengthOfLongestSubstringSolution { fun lengthOfLongestSubstring(s: String): Int { var set = hashSetOf<Char>() var maxLength = 0 val size = s.length s.forEachIndexed { index, c -> set.clear() var pos = index + 1 set.add(c) var next : Char? = if (pos < si...
0
Kotlin
1
0
4382afcc782da539ed0d535c0a5b3a257e0c8097
1,331
LeetCodeInKotlin
MIT License
src/Day02.kt
ostersc
570,327,086
false
{"Kotlin": 9017}
fun main(){ fun part1(input: List<String>): Int { val dirMap= input.groupBy ( keySelector = {it.split(" ").get(0)}, valueTransform = { it.split(" ").get(1).toInt()}) return dirMap.get("forward")!!.sum() * (dirMap.get("down")!!.sum() -dirMap.get("up")!!.sum()) } fun part2(input: List<String...
0
Kotlin
0
0
836ff780252317ee28b289742396c74559dd2b6e
1,016
advent-of-code-2021
Apache License 2.0
src/main/kotlin/g0801_0900/s0889_construct_binary_tree_from_preorder_and_postorder_traversal/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0801_0900.s0889_construct_binary_tree_from_preorder_and_postorder_traversal // #Medium #Array #Hash_Table #Tree #Binary_Tree #Divide_and_Conquer // #2023_04_09_Time_168_ms_(100.00%)_Space_35.5_MB_(75.00%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Defin...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,804
LeetCode-in-Kotlin
MIT License
src/main/kotlin/Day01.kt
arosenf
726,114,493
false
{"Kotlin": 40487}
import kotlin.system.exitProcess fun main(args: Array<String>) { if (args.isEmpty() or (args.size < 2)) { println("Calibration document not specified") exitProcess(1) } val calibrationDocument = args.first() println("Recovering $calibrationDocument") val calibrationValue = ...
0
Kotlin
0
0
d9ce83ee89db7081cf7c14bcad09e1348d9059cb
2,886
adventofcode2023
MIT License
src/main/kotlin/days/Day11.kt
TheMrMilchmann
725,205,189
false
{"Kotlin": 61669}
/* * Copyright (c) 2023 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
f94ff8a4c9fefb71e3ea183dbc3a1d41e6503152
2,966
AdventOfCode2023
MIT License
Bootcamp_01/test.kt
Hasuk1
740,111,124
false
{"Kotlin": 120039}
data class Incident( val x: Int, val y: Int, val type: IncidentType, val phoneNumber: String? ) enum class IncidentType(val name: String) { FIRE("Fire"), LEAK("Gas Leak"), CAT("Cat on the tree") } open class Zone( val phoneNumber: String = "800" ) { open fun isIncidentInside(incide...
0
Kotlin
0
1
1dc4de50dd3cd875e3fe76e3da4a58aa04bb87c7
3,504
Kotlin_bootcamp
MIT License
src/day20/Day20.kt
davidcurrie
579,636,994
false
{"Kotlin": 52697}
package day20 import java.io.File fun main() { val input = File("src/day20/input.txt").readLines().map { it.toLong() } println(grove(mix(input.mapIndexed { index, delta -> index to delta }.toMutableList()))) println(grove((1..10).fold(input.mapIndexed { index, delta -> index to delta * 811589153L } ...
0
Kotlin
0
0
0e0cae3b9a97c6019c219563621b43b0eb0fc9db
1,089
advent-of-code-2022
MIT License
src/main/kotlin/nl/tiemenschut/aoc/y2023/day16.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.util.Direction import nl.tiemenschut.aoc.lib.util.Direction.* import nl.tiemenschut.aoc.lib.util.grid.CharGridParser import nl.tiemenschut.aoc.lib.util.grid.Grid import nl.tiemensc...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
2,848
aoc-2023
The Unlicense
kotlin/wordy/src/main/kotlin/Wordy.kt
ErikSchierboom
27,632,754
false
{"C++": 14523188, "C": 1712536, "C#": 843402, "JavaScript": 766003, "Java": 570202, "F#": 559855, "Elixir": 504471, "Haskell": 499200, "Shell": 393291, "TypeScript": 381035, "Kotlin": 326721, "Scala": 321830, "Clojure": 303772, "Nim": 283613, "Ruby": 233410, "Elm": 157678, "Crystal": 155384, "Go": 152557, "Gleam": 1500...
import java.lang.IllegalStateException import kotlin.math.pow object Wordy { const val PREFIX = "What is " const val SUFFIX = "?" fun answer(input: String): Int { require(input.startsWith(PREFIX)) require(input.endsWith(SUFFIX)) val parts = input.drop(PREFIX.length).dropLast(SUFFI...
0
C++
10
29
d84c9d48a2d3adb0c37d7bd93c9a759d172bdd8e
1,399
exercism
Apache License 2.0
src/All_Filters_and_Built_In_Functions/getOrElse_first_last_map_max_min_filter_all_any_associateBy_groupBy.kt
RedwanSharafatKabir
280,724,526
false
null
package All_Filters_and_Built_In_Functions data class Hero( val name: String, val age: Int, val gender: Gender? ) enum class Gender { MALE, FEMALE } fun main (args: Array<String>){ val heroes = listOf( Hero("The Captain", 60, Gender.MALE), Hero("Frenchy", 42, Gender...
0
Kotlin
0
3
f764850ab3a7d0949f3e0401b0fe335d9df30cab
2,920
OOP-Kotlin
MIT License
app/src/test/java/com/terencepeh/leetcodepractice/LowestCommonAncestorBST.kt
tieren1
560,012,707
false
{"Kotlin": 26346}
package com.terencepeh.leetcodepractice /** * Created by <NAME> on 26/10/22. */ /** * Definition for a binary tree node. * class TreeNode(var `val`: Int = 0) { * var left: TreeNode? = null * var right: TreeNode? = null * } */ class TreeNode(var `val`: Int = 0) { var left: TreeNode? = null var ...
0
Kotlin
0
0
427fa2855c01fbc1e85a840d0be381cbb4eec858
1,946
LeetCodePractice
MIT License
src/Day03.kt
petoS6
573,018,212
false
{"Kotlin": 14258}
fun main() { fun part1(input: List<String>): Int { return input.sumOf { it.commonChar().priority() } } fun part2(input: List<String>): Int { return input.chunked(3).sumOf { it.commonChar().priority() } } val testInput = readInput("Day03.txt") println(part1(testInput)) println(part2(testInput)) }...
0
Kotlin
0
0
40bd094155e664a89892400aaf8ba8505fdd1986
720
kotlin-aoc-2022
Apache License 2.0
kotlin/0767-reorganize-string.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}
class Solution { fun reorganizeString(s: String): String { var count = HashMap<Char, Int>().apply { for (c in s) this[c] = getOrDefault(c, 0) + 1 } val maxHeap = PriorityQueue<Pair<Int, Char>>() { a, b -> b.first - a.first } f...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,864
leetcode
MIT License
src/day08/Day08.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day08 import readInput fun main() { fun parseInput(input: List<String>) = input.map { row -> row.split("").filter { it.isNotEmpty() }.map { it.toInt() } } // fun isEdge(data: List<List<Int>>, r: Int, c: Int): Boolean { // return r == 0 || r == data.lastIndex || c == 0 || c == data[r].lastIndex /...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
4,528
aoc-2022
Apache License 2.0
advent-of-code-2020/src/test/java/aoc/Day19MonsterMessages.kt
yuriykulikov
159,951,728
false
{"Kotlin": 1666784, "Rust": 33275}
package aoc import org.assertj.core.api.Assertions.assertThat import org.junit.Test sealed class Rule(open val index: Int) data class Compound( override val index: Int, val or: List<List<Int>>, ) : Rule(index) data class Letter( override val index: Int, val letter: String, ) : Rule(index) data clas...
0
Kotlin
0
1
f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3
27,769
advent-of-code
MIT License
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/FastSlowPointers.kt
betulnecanli
568,477,911
false
{"Kotlin": 167849}
/* The Fast and Slow Pointers technique involves using two pointers to traverse a sequence at different speeds, often leading to efficient solutions for problems involving cycle detection, finding middle elements, or other related tasks. Let's explore three problems: "Middle of the LinkedList," "Happy Number," and...
2
Kotlin
2
40
70a4a311f0c57928a32d7b4d795f98db3bdbeb02
2,447
Kotlin-Data-Structures-Algorithms
Apache License 2.0
2022/src/test/kotlin/Day05.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe private data class Move5(val times: Int, val src: Int, val dest: Int) class Day05 : StringSpec({ "puzzle part 01" { val (stacks, moves) = getStacksAndMoves() moves.forEach { move -> repeat(move.times) { ...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,822
adventofcode
MIT License
src/main/kotlin/g1501_1600/s1514_path_with_maximum_probability/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1501_1600.s1514_path_with_maximum_probability // #Medium #Heap_Priority_Queue #Graph #Shortest_Path // #2023_06_12_Time_681_ms_(100.00%)_Space_67.5_MB_(62.50%) import java.util.ArrayDeque import java.util.Queue class Solution { fun maxProbability(n: Int, edges: Array<IntArray>, succProb: DoubleArray, st...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,794
LeetCode-in-Kotlin
MIT License
code/day_14/src/jvm8Main/kotlin/task2.kt
dhakehurst
725,945,024
false
{"Kotlin": 105846}
package day_14 val List<Char>.join get() = this.joinToString(separator = "") fun String.tilt(): String { val segments = this.split("#") return segments.map { val os = it.count { it == 'O' } "O".repeat(os) + ".".repeat(it.length - os) }.joinToString(separator = "#") } fun GridAsString.tilt...
0
Kotlin
0
0
be416bd89ac375d49649e7fce68c074f8c4e912e
1,369
advent-of-code
Apache License 2.0
src/main/kotlin/dev/patbeagan/days/Day11.kt
patbeagan1
576,401,502
false
{"Kotlin": 57404}
package dev.patbeagan.days import java.lang.IllegalArgumentException /** * [Day 11](https://adventofcode.com/2022/day/11) */ class Day11 : AdventDay<Int> { override fun part1(input: String) = parseInput(input).let { monkeyList -> Main(monkeyList, Person()).let { main -> repeat(20) { ...
0
Kotlin
0
0
4e25b38226bcd0dbd9c2ea18553c876bf2ec1722
6,681
AOC-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestValidParentheses.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,928
kotlab
Apache License 2.0
kotlin/src/katas/kotlin/leetcode/regex_matching/RegexMatching.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.regex_matching import datsok.shouldEqual import org.junit.Test class RegexMatchingTests { @Test fun `it mostly works`() { "".matches("") shouldEqual true "a".matches("a") shouldEqual true "a".matches("b") shouldEqual false "a".matches(".") shouldEqual...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,970
katas
The Unlicense
src/leetcodeProblem/leetcode/editor/en/RansomNote.kt
faniabdullah
382,893,751
false
null
//Given two stings ransomNote and magazine, return true if ransomNote can be //constructed from magazine and false otherwise. // // Each letter in magazine can only be used once in ransomNote. // // // Example 1: // Input: ransomNote = "a", magazine = "b" //Output: false // Example 2: // Input: ransomNote = "aa", ...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
1,704
dsa-kotlin
MIT License
src/Day03.kt
ivancordonm
572,816,777
false
{"Kotlin": 36235}
fun main() { fun part1(input: List<String>) = input.fold(0) { acc, it -> acc + it.take(it.length / 2).toSet().intersect(it.substring(it.length / 2).toSet()).first().getValue() } fun part2(input: List<String>) = input.chunked(3).fold(0) { acc, triple -> acc + tri...
0
Kotlin
0
2
dc9522fd509cb582d46d2d1021e9f0f291b2e6ce
765
AoC-2022
Apache License 2.0
day05/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File import java.lang.Double.POSITIVE_INFINITY fun main() { val input = readInputFile()[0] println("Part I: the solution is ${solvePartI(input)}.") println("Part II: the solution is ${solvePartII(input)}.") } fun readInputFile(): List<String> { return File(ClassLoader.getSystemResource...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
1,727
AdventOfCode2018
MIT License
src/main/kotlin/com/ginsberg/advent2020/Day14.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 14 - Docking Data * Problem Description: http://adventofcode.com/2020/day/14 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day14/ */ package com.ginsberg.advent2020 class Day14(private val input: List<String>) { ...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
2,628
advent-2020-kotlin
Apache License 2.0
src/main/kotlin/g0501_0600/s0564_find_the_closest_palindrome/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0564_find_the_closest_palindrome // #Hard #String #Math #2023_01_21_Time_179_ms_(100.00%)_Space_33.7_MB_(100.00%) @Suppress("NAME_SHADOWING") class Solution { fun nearestPalindromic(n: String): String { if (n.length == 1) { return (n.toInt() - 1).toString() } ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,001
LeetCode-in-Kotlin
MIT License
src/util/Graph.kt
pghj
577,868,985
false
{"Kotlin": 94937}
package util import java.util.Collections class Graph<K, N> { inner class Node( val key: K, val value: N ) { val connected: ArrayList<Vertex> = ArrayList() } inner class Vertex( val a: Node, val b: Node, val aToB: Int, val bToA: Int, ) { ...
0
Kotlin
0
0
4b6911ee7dfc7c731610a0514d664143525b0954
2,297
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day02/Day02.kt
W3D3
433,748,408
false
{"Kotlin": 72893}
package day02 import common.InputRepo import common.readSessionCookie import common.solve fun main(args: Array<String>) { val day = 2 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay02Part1, ::solveDay02Part2) } enum class Command { FORWARD, DOWN, U...
0
Kotlin
0
0
df4f21cd99838150e703bcd0ffa4f8b5532c7b8c
1,310
AdventOfCode2021
Apache License 2.0
src/Day04.kt
dannyrm
573,100,803
false
null
fun main() { fun part1(input: List<String>): Int { return input.map { splitIntoRange(it) }.filter { it.first.subtract(it.second).isEmpty() }.size } fun part2(input: List<String>): Int { return input.map { splitIntoRange(it) }.filter { (it.first.subtract(it.second).size) < it.first.count() }...
0
Kotlin
0
0
9c89b27614acd268d0d620ac62245858b85ba92e
683
advent-of-code-2022
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day14.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.algorithm.md5 object Day14 : AdventSolution(2016, 14, "One-Time Pad") { override fun solvePartOne(input: String) = generateSequence(0,Int::inc) .map { md5("$input$it") } .solve() override fun solvePartTwo(input: String...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
954
advent-of-code
MIT License
src/Day17.kt
jinie
572,223,871
false
{"Kotlin": 76283}
class Day17(input: List<String>) { enum class Rock(val height: Int, val parts: List<Point2d>) { Dash(1, listOf(Point2d(0, 0), Point2d(1, 0), Point2d(2, 0), Point2d(3, 0))), Plus(3, listOf(Point2d(1, 0), Point2d(0, 1), Point2d(1, 1), Point2d(2, 1), Point2d(1, 2))), Angle(3, listOf(Point2d(0,...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
4,171
aoc-22-kotlin
Apache License 2.0
src/Day23.kt
joy32812
573,132,774
false
{"Kotlin": 62766}
import java.lang.Math.abs data class Elf(var x: Int, var y: Int, var d: Int = 0) fun main() { val dirs = listOf( listOf(-1, -1, -1) to listOf(-1, 0, 1), // north listOf(1, 1, 1) to listOf(-1, 0, 1), // south listOf(-1, 0, 1) to listOf(-1, -1, -1), // west listOf(-1, 0, 1) to listOf...
0
Kotlin
0
0
5e87958ebb415083801b4d03ceb6465f7ae56002
3,785
aoc-2022-in-kotlin
Apache License 2.0
2023/src/main/kotlin/day3_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Grid import utils.IntGrid import utils.Solution import utils.Vec2i fun main() { Day3_fast.run(skipTest = false) } object Day3All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day3, "fast" to Day3_fast).forEach { (header, solution) -> solution.run( header = header, ...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
4,560
aoc_kotlin
MIT License
src/main/kotlin/co/csadev/advent2021/Day13.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 13 * Problem Description: http://adventofcode.com/2021/day/13 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Point2D import co.csadev.adventOfCode.Resources.resourceAsList import co.csadev.adventOfCod...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,522
advent-of-kotlin
Apache License 2.0
src/main/java/challenges/educative_grokking_coding_interview/k_way_merge/_4/MergeSortList.kt
ShabanKamell
342,007,920
false
null
package challenges.educative_grokking_coding_interview.k_way_merge._4 import challenges.educative_grokking_coding_interview.LinkedList import challenges.educative_grokking_coding_interview.LinkedListNode import challenges.educative_grokking_coding_interview.PrintList.printListWithForwardArrow import challenges.util.Pr...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,567
CodingChallenges
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NextLargerNodes.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,849
kotlab
Apache License 2.0
datastructures/src/main/kotlin/com/kotlinground/datastructures/trees/trie/Trie.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.datastructures.trees.trie /** * Trie is a trie tree */ class Trie(private var root: TrieNode) { /** * Searches for a word in the trie, returning a collection of words that match it * @param word [String] word to search for * @return [Collection] matching words */ ...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,394
KotlinGround
MIT License
day7.main.kts
goncalossilva
319,515,627
false
{"Kotlin": 5954, "Erlang": 2329}
#!/usr/bin/env kotlinc -script import java.io.File val rules = File("day7.txt").readLines() val bagRegex = "(^[\\w\\s]+) bags contain".toRegex() val ruleRegex = "(\\d+) ([\\w\\s]+) bags?,?".toRegex() data class Rule(val bag: String, val count: Int) val bagRules = mutableMapOf<String, List<Rule>>() rules.forEach { r...
0
Kotlin
0
1
2d63c5760236274418f7ed134da6d8d8ba9838eb
1,063
aoc-2020
The Unlicense
src/me/bytebeats/algo/kt/Solution.kt
bytebeats
251,234,289
false
null
package me.bytebeats.algo.kt import me.bytebeats.algo.designs.Trie import me.bytebeats.algs.ds.ListNode import me.bytebeats.algs.ds.TreeNode import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.collections.HashSet class Solution { fun findDuplicate(nums: IntArray)...
0
Kotlin
0
1
7cf372d9acb3274003bb782c51d608e5db6fa743
57,740
Algorithms
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/PathCrossing.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,645
kotlab
Apache License 2.0
hackerrank/lilys-homework/Solution.kts
shengmin
5,972,157
false
null
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
Java
18
20
08e65546527436f4bd2a2014350b2f97ac1367e7
1,839
coding-problem
MIT License
src/main/kotlin/adventofcode/y2021/Day13.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.* import java.math.BigInteger fun main() { val testInput = """ 6,10 0,14 9,10 0,3 10,4 4,11 6,0 6,12 4,1 0,13 10,12 3,4 3,0 8,4 1,10 2,14 8,10 9,0 ...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
2,414
adventofcode2021
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/UniquePaths3.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,888
kotlab
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2020/Day12.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2020 import me.grison.aoc.* import me.grison.aoc.y2020.Day12.Direction.E class Day12 : Day(12, 2020) { override fun title() = "Rain Risk" override fun partOne(): Int { var (pos, dir) = p(p(0, 0), E) inputList.forEach { l -> val (cmd, amount) = p(l.slice(0.....
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
1,713
advent-of-code
Creative Commons Zero v1.0 Universal
6_kyu/Playing_with_digits.kt
UlrichBerntien
439,630,417
false
{"Go": 293606, "Rust": 191729, "Python": 184557, "Lua": 137612, "Assembly": 89144, "C": 76738, "Julia": 35473, "Kotlin": 33204, "R": 27633, "C#": 20860, "Shell": 14326, "Forth": 3750, "PLpgSQL": 2117, "C++": 122}
/** Power function for integers */ fun Int.pow(exp: Int): Long { return this.toBigInteger().pow(exp).toLong() } /** * Sum decimal digits with power. * * @param x Calculate the digit powerd sum of this int. * @param p The exponent of the most significant digit. * @return sum of all decimal digits with power p,...
0
Go
0
0
034d7f2bdcebc503b02877f2241e4dd143188b43
1,030
Codewars-Katas
MIT License
src/main/kotlin/de/startat/aoc2023/Day3.kt
Arondc
727,396,875
false
{"Kotlin": 194620}
package de.startat.aoc2023 data class Number(val value: Int, val lineNumber : Int, val indices : IntRange) data class Symbol(val value: String,val lineNumber: Int, val index : Int) data class Schematic(val numbers : List<Number>, val symbols: List<Symbol>) fun Symbol.isAdjacentTo(number: Number) : Boolean{ val li...
0
Kotlin
0
0
660d1a5733dd533aff822f0e10166282b8e4bed9
22,322
AOC2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/LetterCasePermutation.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,393
kotlab
Apache License 2.0
src/net/sheltem/aoc/y2022/Day18.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2022 import net.sheltem.aoc.y2022.D3Direction.BACKWARD import net.sheltem.aoc.y2022.D3Direction.DOWN import net.sheltem.aoc.y2022.D3Direction.FORWARD import net.sheltem.aoc.y2022.D3Direction.LEFT import net.sheltem.aoc.y2022.D3Direction.RIGHT import net.sheltem.aoc.y2022.D3Direction.UP suspe...
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
2,135
aoc
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day18/Cubes.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day18 data class Cubes(val cubes: Set<Cube>) { val uniqueSides: Set<Side> by lazy { cubes .flatMap(Cube::getSides) .groupingBy { it } .eachCount() .filterValues { it == 1 } .keys } fun isLinkedTo(other: Cubes) = uniqueSides.intersect(other.uniqueSides).isNotEmpty() fun ...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,587
advent-of-code
Apache License 2.0
AoC2022/src/main/kotlin/xyz/danielstefani/Day3.kt
OpenSrcerer
572,873,135
false
{"Kotlin": 14185}
package xyz.danielstefani import java.util.stream.IntStream import kotlin.streams.asSequence val priorityMap = mutableMapOf<Int, Int>() fun main() { // Prep fillMapWithPriorities(97, 122, 1) fillMapWithPriorities(65, 90, 27) val splitRucksacks = object {}.javaClass .classLoader .getR...
0
Kotlin
0
3
84b9b62e15c70a4a17f8b2379dc29f9daa9f4be3
1,535
aoc-2022
The Unlicense
src/main/kotlin/Puzzle10.kt
namyxc
317,466,668
false
null
import java.math.BigInteger object Puzzle10 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle10::class.java.getResource("puzzle10.txt").readText() val count1and3diffInInput = count1and3diffInInput(input) println(count1and3diffInInput.first * count1and3diffInInput.secon...
0
Kotlin
0
0
60fa6991ac204de6a756456406e1f87c3784f0af
2,102
adventOfCode2020
MIT License
hackerrank/the-grid-search/Solution.kts
shengmin
5,972,157
false
null
import java.util.*; import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.functions.* import kotlin.jvm.internal.* import kotlin.ranges.* import kotlin....
0
Java
18
20
08e65546527436f4bd2a2014350b2f97ac1367e7
3,906
coding-problem
MIT License
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day5.kt
clechasseur
435,726,930
false
{"Kotlin": 315943}
package io.github.clechasseur.adventofcode2021 import io.github.clechasseur.adventofcode2021.data.Day5Data import io.github.clechasseur.adventofcode2021.util.Pt object Day5 { private val data = Day5Data.data private val linesRegex = """^(\d+),(\d+) -> (\d+),(\d+)$""".toRegex() private val lines: List<Pa...
0
Kotlin
0
0
4b893c001efec7d11a326888a9a98ec03241d331
2,060
adventofcode2021
MIT License
numeriko-core/src/main/kotlin/tomasvolker/numeriko/core/primitives/Extensions.kt
TomasVolker
114,266,369
false
null
package tomasvolker.numeriko.core.primitives import tomasvolker.numeriko.core.config.NumerikoConfig import kotlin.math.abs infix fun Int.modulo(other: Int) = ((this % other) + other) % other infix fun Long.modulo(other: Long) = ((this % other) + other) % other infix fun Float.modulo(other: Float) = ((this % other) + ...
8
Kotlin
1
3
1e9d64140ec70b692b1b64ecdcd8b63cf41f97af
2,504
numeriko
Apache License 2.0
src/main/kotlin/aoc22/Day20.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc22 import aoc22.Day20Domain.Mixer import aoc22.Day20Solution.part1Day20 import aoc22.Day20Solution.part2Day20 import aoc22.Day20Parser.toMixer import aoc22.Day20Runner.coordinates import aoc22.Day20Runner.decrypt import common.Year22 object Day20: Year22 { fun List<String>.part1(): Long = part1Day20() ...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
1,806
aoc
Apache License 2.0
src/Day11.kt
buczebar
572,864,830
false
{"Kotlin": 39213}
import java.lang.IllegalArgumentException private fun parseMonkey(monkeyData: String): Monkey { return Monkey.build { monkeyData.lines().forEach { line -> with(line.trim()) { when { startsWith("Monkey") -> { id = getAllInts().first() ...
0
Kotlin
0
0
cdb6fe3996ab8216e7a005e766490a2181cd4101
3,851
advent-of-code
Apache License 2.0
src/main/kotlin/aoc2017/SporificaVirus.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2017 import komu.adventofcode.utils.Direction import komu.adventofcode.utils.Point import komu.adventofcode.utils.nonEmptyLines fun sporificaVirus1(input: String): Int { val infectedPoints = VirusMap(input.nonEmptyLines()) var point = Point.ORIGIN var dir = Direction.UP va...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
2,064
advent-of-code
MIT License
src/questions/TwoSumII.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import algorithmdesignmanualbook.print import utils.assertIterableSame /** * Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, * find two numbers such that they add up to a specific target number. * Return the indic...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
3,942
algorithms
MIT License
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions82.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special fun test82() { printlnResult(intArrayOf(2, 2, 2, 4, 3, 3), 8) } /** * Questions 82: Given an IntArray that contain the same integers possibly. And, given a value, * please find all subsets that the sum of subset equals this value, integers just could appear once in one su...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,350
Algorithm
Apache License 2.0
kotlin/0329-longest-increasing-path-in-a-matrix.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}
class Solution { fun longestIncreasingPath(matrix: Array<IntArray>): Int { val m = matrix.size val n = matrix[0].size val memo = Array<IntArray>(m){IntArray(n)} val dirs = arrayOf(intArrayOf(-1,0),intArrayOf(1,0),intArrayOf(0,1),intArrayOf(0,-1)) var res = 1 for (i i...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,111
leetcode
MIT License
src/Day11.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
class Monke { var items = MutableList(0) { mutableListOf<Pair<Int, Int>>() } var operation: (Int) -> Int = { a -> a } var trueMonke: Int = 0 var falseMonke: Int = 0 var inspectCount: Long = 0 } fun main() { fun part1(input: List<String>): Long { var monkes = mutableListOf<Monke>() ...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
5,911
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day03/Day03.kt
jackploeg
736,755,380
false
{"Kotlin": 318734}
package nl.jackploeg.aoc._2023.calendar.day03 import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory import nl.jackploeg.aoc.utilities.readStringFile import javax.inject.Inject class Day03 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun partOne(fileName: String):...
0
Kotlin
0
0
f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76
3,423
advent-of-code
MIT License
src/com/kingsleyadio/adventofcode/y2022/day03/Solution.kt
kingsleyadio
435,430,807
false
{"Kotlin": 134666, "JavaScript": 5423}
package com.kingsleyadio.adventofcode.y2022.day03 import com.kingsleyadio.adventofcode.util.readInput fun main() { part1() part2() } fun part1() { var result = 0 readInput(2022, 3).forEachLine { line -> val first = line.substring(0, line.length / 2) val second = line.substring(line.le...
0
Kotlin
0
1
9abda490a7b4e3d9e6113a0d99d4695fcfb36422
1,451
adventofcode
Apache License 2.0
leetcode/src/offer/middle/Offer48.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 48. 最长不含重复字符的子字符串 // https://leetcode.cn/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/ println(lengthOfLongestSubstring("abba")) } fun lengthOfLongestSubstring(s: String): Int { // 滑动窗口,左开右闭,所以 left 初始化为 -1 var left = -1 val map ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
1,191
kotlin-study
MIT License
common/src/main/kotlin/combo/math/Cholesky.kt
rasros
148,620,275
false
null
package combo.math import kotlin.math.absoluteValue import kotlin.math.sqrt /** * Perform cholesky decomposition downdate with vector x, such that A = L'*L - x*x' * The matrix is modified inline. * Ported from fortran dchdd. */ fun Matrix.choleskyDowndate(x: VectorView): Float { val L = this val p = x.siz...
0
Kotlin
1
2
2f4aab86e1b274c37d0798081bc5500d77f8cd6f
1,912
combo
Apache License 2.0
jvm/src/main/kotlin/io/prfxn/aoc2021/day25.kt
prfxn
435,386,161
false
{"Kotlin": 72820, "Python": 362}
// <NAME> (https://adventofcode.com/2021/day/25) package io.prfxn.aoc2021 fun main() { val v = 'v' val gt = '>' val lines = textResourceReader("input/25.txt").readLines() val numRows = lines.size val numCols = lines.first().length val (gts, vs) = lines.indices .flatMap {...
0
Kotlin
0
0
148938cab8656d3fbfdfe6c68256fa5ba3b47b90
1,537
aoc2021
MIT License
src/Day11.kt
l8nite
573,298,097
false
{"Kotlin": 105683}
class Monkey( private val items: MutableList<Long>, val operation: ((Long) -> Long), val divisor: Long, private val trueTarget: Int, private val falseTarget: Int, var worry: ((Long) -> (Long))? = null ) { var inspected: Long = 0L fun inspect(monkeys: List<Monkey>) { items.forEa...
0
Kotlin
0
0
f74331778fdd5a563ee43cf7fff042e69de72272
3,798
advent-of-code-2022
Apache License 2.0
year2021/day16/bits/src/main/kotlin/com/curtislb/adventofcode/year2021/day16/bits/BitsPacketType.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2021.day16.bits import com.curtislb.adventofcode.common.number.product /** * A type of packet included as part of a BITS transmission. * * @param id An integer ID that uniquely defines this packet type. */ enum class BitsPacketType(val id: Int) { /** * A packet whose...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
3,164
AdventOfCode
MIT License
kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt
schakalakka
254,950,505
true
{"Kotlin": 217723}
package scientifik.kmath.operations interface SpaceOperations<T> { /** * Addition operation for two context elements */ fun add(a: T, b: T): T /** * Multiplication operation for context element and real number */ fun multiply(a: T, k: Number): T //Operation to be performed in...
0
null
0
0
e52cfcaafe7eb1149170838d9910e54851ba1a92
2,114
kmath
Apache License 2.0
src/main/kotlin/main.kt
zsr2531
354,633,269
false
null
import kotlin.math.max import kotlin.math.min import kotlin.random.Random fun minimax(board: Board): Int { // First, we check if the game is over, and return the score accordingly. if (board.isFinished) { return when (board.winner) { Side.Cross -> 1 Side.Circle -> -1 ...
0
Kotlin
1
0
5260b0996b776d6f6da737b9dbe60eaa1b4a59cf
4,280
ticwactoe
MIT License
src/main/kotlin/com/sk/leetcode/kotlin/121. Best Time to Buy and Sell Stock.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package leetcode.kotlin.array.easy import kotlin.math.max import kotlin.math.min fun main() { check(maxProfit(intArrayOf(7, 1, 5, 3, 6, 4)) == 5) check(maxProfit(intArrayOf(7, 6, 4, 3, 1)) == 0) check(maxProfit3(intArrayOf(7, 1, 5, 3, 6, 4)) == 5) check(maxProfit3(intArrayOf(7, 6, 4, 3, 1)) == 0) ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,816
leetcode-kotlin
Apache License 2.0
src/day16/second/Solution.kt
verwoerd
224,986,977
false
null
package day16.second import tools.timeSolution import kotlin.math.abs import kotlin.math.min fun main() = timeSolution { val input = readLine()!!.toCharArray().map { (it - '0').toLong() } val offset = input.take(7).joinToString("").toInt() val work = generateInput(input).drop(offset).take(10_000 * input.size - ...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,506
AoC2019
MIT License
src/Day08_part2_optimal.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
fun main() { val lines = readInput("Day08_input") val rows = lines.size val cols = lines[0].length val heights = Array(rows) { i -> Array(cols) { j -> lines[i][j] - '0' } } val score = Array(rows) { Array(cols) { 1 } } val outerBounds = listOf(0 until rows, 0 until rows, 0 until cols, 0 until c...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,439
aoc-2022
Apache License 2.0
src/main/kotlin/days/Day17.kt
hughjdavey
225,440,374
false
null
package days import common.IntcodeComputer import common.stackOf class Day17 : Day(17) { private fun program() = inputString.split(",").map { it.trim().toLong() }.toMutableList() override fun partOne(): Any { val image = getImage() return getIntersections(image).map { it.alignment }.sum() ...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
6,762
aoc-2019
Creative Commons Zero v1.0 Universal
src/Day01.kt
kent10000
573,114,356
false
{"Kotlin": 11288}
fun main() { fun getElfCalories(input: List<String>): List<Int> { val elfCalories = mutableListOf(0) for (value in input) { if (value.isBlank()) { elfCalories.add(0) continue } elfCalories[elfCalories.size - 1] += value.toInt() ...
0
Kotlin
0
0
c128d05ab06ecb2cb56206e22988c7ca688886ad
911
advent-of-code-2022
Apache License 2.0
src/Day08.kt
janbina
112,736,606
false
null
package day08 import getInput import kotlin.test.assertEquals data class Instruction( val name: String, val operation: (Int) -> Int, val condName: String, val condition: (Int) -> Boolean ) { companion object { fun fromString(input: String): Instruction { val par...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
2,074
advent-of-code-2017
MIT License
src/main/kotlin/days/impl/Day3.kt
errob37
726,532,024
false
{"Kotlin": 29748, "Shell": 408}
package days.impl import days.model.* class Day3() : AdventOfCodeDayImpl(3, 4361L, 467835L) { override fun partOne(input: List<String>): Long { val engineSchematic = extractEngineSchematic(input) val (numbers, symbols) = extractPosition(engineSchematic) return symbols .map { n...
0
Kotlin
0
0
79db6f0f56d207b68fb89425ad6c91667a84d60f
3,795
adventofcode-2023
Apache License 2.0
src/day3/Code.kt
fcolasuonno
225,219,560
false
null
package day3 import isDebug import java.io.File import kotlin.math.abs fun main() { val name = if (isDebug()) "test.txt" else "input.txt" System.err.println(name) val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part ...
0
Kotlin
0
0
d1a5bfbbc85716d0a331792b59cdd75389cf379f
1,541
AOC2019
MIT License
src/main/kotlin/adventofcode2018/Day04ReposeRecord.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2018 import java.time.LocalDateTime import java.time.format.DateTimeFormatter class Day04ReposeRecord data class Guard(val id: Int) data class SleepPeriod(val start: LocalDateTime, val stop: LocalDateTime) sealed class ShiftEntry( val dateTime: LocalDateTime, val guard: Guard = Guard(-1...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
4,326
kotlin-coding-challenges
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2021/Day17.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2021 import se.saidaspen.aoc.util.* fun main() = Day17.run() object Day17 : Day(2021, 17) { var ints = ints(input) private var xRange = IntRange(ints[0], ints[1]) private var yRange = IntRange(ints[2], ints[3]) override fun part1() = (0..250).flatMap { x -> (-250..500)....
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,095
adventofkotlin
MIT License
src/main/kotlin/days/Day6.kt
mstar95
317,305,289
false
null
package days import util.groupByEmpty class Day6 : Day(6) { override fun partOne(): Any { val groups: List<List<String>> = groupByEmpty(inputList) val forms = flatten(groups) val answers = forms.map { form -> form.distinct().size } return answers.fold(0, {sum, elem -> sum + elem})...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
936
aoc-2020
Creative Commons Zero v1.0 Universal
AdventOfCode/Challenge2023Day11.kt
MartinWie
702,541,017
false
{"Kotlin": 90565}
import org.junit.Test import java.io.File import kotlin.math.abs import kotlin.test.assertEquals class Challenge2023Day11 { private fun solve1(lines: List<String>): Int { val map = mutableListOf<String>() // First lets expand the map for (line in lines) { map.add(line) ...
0
Kotlin
0
0
47cdda484fabd0add83848e6000c16d52ab68cb0
2,793
KotlinCodeJourney
MIT License
src/day13/Day13.kt
GrzegorzBaczek93
572,128,118
false
{"Kotlin": 44027}
package day13 import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.int import readInput import utils.multiply import utils.withStopwatch fun main() { val te...
0
Kotlin
0
0
543e7cf0a2d706d23c3213d3737756b61ccbf94b
1,725
advent-of-code-kotlin-2022
Apache License 2.0
year2020/day18/part2/src/main/kotlin/com/curtislb/adventofcode/year2020/day18/part2/Year2020Day18Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- You manage to answer the child's questions and they finish part 1 of their homework, but get stuck when they reach the next section: advanced math. Now, addition and multiplication have different precedence levels, but they're not the ones you're familiar with. Instead, addition is evaluated befor...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,510
AdventOfCode
MIT License
arrays/RemoveDuplicatesFromSortedArray/kotlin/Solution.kt
YaroslavHavrylovych
78,222,218
false
{"Java": 284373, "Kotlin": 35978, "Shell": 2994}
/** * Given a sorted array nums, remove the duplicates in-place such * that each element appears only once and returns the new length. * Do not allocate extra space for another array, you must * do this by modifying the input array in-place with O(1) extra memory. * Clarification: * Confused why the returned va...
0
Java
0
2
cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd
1,362
codility
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2017/Day10.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2017 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints import kotlin.streams.toList fun main() = Day10.run() object Day10 : Day(2017, 10) { private val ropeLen = 256 override fun part1(): String { val rope = generateSequence(0) { it + 1 }.take(ropeLen).t...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,898
adventofkotlin
MIT License
src/main/kotlin/puzzle7/WhaleBuster.kt
tpoujol
436,532,129
false
{"Kotlin": 47470}
package puzzle7 import kotlin.math.abs import kotlin.math.floor import kotlin.math.roundToInt import kotlin.system.measureTimeMillis fun main() { val whaleBuster = WhaleBuster() val time = measureTimeMillis { println("Minimal fuel consumption is: ${whaleBuster.findCrabAlignment()}") println("T...
0
Kotlin
0
1
6d474b30e5204d3bd9c86b50ed657f756a638b2b
1,815
aoc-2021
Apache License 2.0
src/Day22.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
fun main() { val up = Vec2(-1, 0) val right = Vec2(0, 1) val down = Vec2(1, 0) val left = Vec2(0, -1) val dirs = listOf(right, down, left, up) data class Input(val table: List<String>, val commands: List<String>) fun parseInput(input: String): Input { val (tableStr, cmds) = input.s...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
8,481
Advent-of-Code-2022
Apache License 2.0
src/Day06.kt
winnerwinter
573,917,144
false
{"Kotlin": 20685}
fun main() { fun part1(): Int { val testInput = readInput("Day06_test") val test_ans = testInput.map { naive(it, 4) } check(test_ans == listOf(7,5,6,10,11)) val input = readInput("Day06") val ans = naive(input.single(), 4) return ans } fun part2(): Int { ...
0
Kotlin
0
0
a019e5006998224748bcafc1c07011cc1f02aa50
772
advent-of-code-22
Apache License 2.0
LeetCode/Kotlin/GenerateParentheses.kt
vale-c
177,558,551
false
null
/** * 22. Generate Parentheses * https://leetcode.com/problems/generate-parentheses/ */ class Solution { val combinations = mutableListOf<String>() fun generateParentheses(n: Int): List<String> { generateParentheses(n, n, "") return combinations } private fun generateParentheses(op...
0
Java
5
9
977e232fa334a3f065b0122f94bd44f18a152078
1,333
CodingInterviewProblems
MIT License
src/main/kotlin/aoc2019/UniversalOrbitMap.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2019 import komu.adventofcode.utils.nonEmptyLines private typealias OrbitalObject = String private typealias OrbitMap = Map<OrbitalObject, OrbitalObject> fun universalOrbitMap1(input: String): Int { val map = parseOrbitMap(input) return map.keys.sumBy { map.stepsToCenterOfMass(it...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,266
advent-of-code
MIT License
src/main/kotlin/cloud/dqn/leetcode/NumberOfIslandsKt.kt
aviuswen
112,305,062
false
null
package cloud.dqn.leetcode /** * https://leetcode.com/problems/number-of-islands/description/ * Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all ...
0
Kotlin
0
0
23458b98104fa5d32efe811c3d2d4c1578b67f4b
2,446
cloud-dqn-leetcode
No Limit Public License
app/src/main/java/my/github/dstories/core/model/AbilityScores.kt
horseunnamed
515,286,546
false
{"Kotlin": 116710}
package my.github.dstories.core.model import kotlin.math.max enum class AbilityScore { Str, Dex, Con, Int, Wis, Cha } data class AbilityScoreValue( val base: Int, val raceBonus: Int = 0 ) { val modifier: Int get() = (base - 10).floorDiv(2) val total: Int get() = base + raceBonus ...
6
Kotlin
0
0
e431340467993b839e5db0b6d64972cee6d379c6
3,621
Dungeon-Stories
MIT License