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/Day09.kt
mpythonite
572,671,910
false
{"Kotlin": 29542}
import kotlin.math.abs fun main() { data class Point(var x: Int = 0, var y: Int = 0) fun part1(input: List<String>): Int { var head = Point() var tail = Point() var trail = HashSet<Point>() var visited = 0 input.forEach { val split = it.split(' ') ...
0
Kotlin
0
0
cac94823f41f3db4b71deb1413239f6c8878c6e4
3,491
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/de/skyrising/aoc2023/day22/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2023.day22 import de.skyrising.aoc.* val test = TestInput(""" 1,0,1~1,2,1 0,0,2~2,0,2 0,2,3~2,2,3 0,0,4~0,2,4 2,0,5~2,2,5 0,1,6~2,1,6 1,1,8~1,1,9 """) private fun parse(input: PuzzleInput) = input.lines.map { val (x1,y1,z1, x2, y2, z2) = it.ints() Cube(list...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
1,474
aoc
MIT License
src/main/kotlin/io/github/mikaojk/day3/part1/day3Part1.kt
MikAoJk
573,000,620
false
{"Kotlin": 15562}
package io.github.mikaojk.day3.part1 import io.github.mikaojk.common.getFileAsString import java.util.Locale fun day3Part1(): Int { val rucksacksItems = getFileAsString("src/main/resources/day3/rucksacksItems.txt") val rucksacks = rucksacksItems.split("\\n".toRegex()).map { Rucksack( firs...
0
Kotlin
0
0
eaa90abc6f64fd42291ab42a03478a3758568ecf
1,833
aoc2022
MIT License
src/Day04.kt
mpythonite
572,671,910
false
{"Kotlin": 29542}
import java.awt.PageAttributes.PrintQualityType fun main() { fun part1(input: List<String>): Int { var redundancies = 0 input.forEach{ val splits = it.split(',') val first = splits.first().split('-') val second = splits.last().split('-') val low1 = fi...
0
Kotlin
0
0
cac94823f41f3db4b71deb1413239f6c8878c6e4
1,512
advent-of-code-2022
Apache License 2.0
src/main/kotlin/astminer/featureextraction/TreeFeature.kt
JetBrains-Research
161,813,380
false
{"Kotlin": 339696, "ANTLR": 110038, "C++": 25952, "Java": 22416, "Python": 14294, "JavaScript": 7698, "PHP": 3778, "Dockerfile": 1431, "Shell": 988}
package astminer.featureextraction import astminer.common.model.Node /** * Interface that describes tree feature. * @param T tree feature's type */ interface TreeFeature<out T> { /** * Computes this feature for given tree. * @param tree tree for which this feature is computed * @return computed ...
11
Kotlin
79
269
8e7872fa78983b3b9b4ff4b9f70d24cc4dfed280
3,203
astminer
MIT License
src/year2022/day09/Day09.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2022.day09 import check import readInput import kotlin.math.abs fun main() { // test if implementation meets criteria from the description, like: val testInputA = readInput("2022", "Day09_test_a") val testInputB = readInput("2022", "Day09_test_b") check(part1(testInputA), 13) check(pa...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,848
AdventOfCode
Apache License 2.0
src/week3/TopKFrequent.kt
anesabml
268,056,512
false
null
package week3 import java.util.* import kotlin.system.measureNanoTime class TopKFrequent { fun topKFrequent(nums: IntArray, k: Int): IntArray { if (k == nums.size) return nums val map = hashMapOf<Int, Int>() nums.forEach { n -> map[n] = map.getOrDefault(n, 0) + 1 } ...
0
Kotlin
0
1
a7734672f5fcbdb3321e2993e64227fb49ec73e8
2,529
leetCode
Apache License 2.0
src/year2015/day19/Day19.kt
lukaslebo
573,423,392
false
{"Kotlin": 222221}
package year2015.day19 import readInput fun main() { val input = readInput("2015", "Day19") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val replacements = input.dropLast(2).map { it.split(" => ") }.map { it[0] to it[1] } val molecule = input.last() ...
0
Kotlin
0
1
f3cc3e935bfb49b6e121713dd558e11824b9465b
1,650
AdventOfCode
Apache License 2.0
src/main/kotlin/org/motivesearch/csma/MotiveGenerator.kt
JonasKellerer
754,498,515
false
{"Kotlin": 10127, "Python": 6871}
package org.motivesearch.csma data class MotiveUnit(val name: String) data class MotivePosition(val position: Int, val length: Int) data class Motive(val positions: List<MotivePosition>, val frequency: Int, val sequence: List<MotiveUnit>) { companion object { fun fromPositions(positions: List<MotivePosit...
0
Kotlin
0
0
7d57ab65c379beab24d81a82dad7ee215afb5567
4,763
motivsearch
MIT License
day18/src/main/kotlin/Day18.kt
bzabor
160,240,195
false
null
class Day18(private val input: List<String>) { val gridDim = 50 var grid = Array(gridDim) { Array(gridDim) { Cell() } } var minutes = 0 fun init() { for (row in input.indices) { for (col in input[row].indices) { val c = input[row][col] grid[row][col...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
3,954
AdventOfCode2018
Apache License 2.0
src/year2023/Day14.kt
drademacher
725,945,859
false
{"Kotlin": 76037}
package year2023 import Direction import MutableGrid import readLines fun main() { val input = parseInput(readLines("2023", "day14")) val testInput = parseInput(readLines("2023", "day14_test")) val testResultPart1 = part1(testInput.simpleCopy()) check(testResultPart1 == 136) { "Incorrect result for p...
0
Kotlin
0
0
4c4cbf677d97cfe96264b922af6ae332b9044ba8
3,906
advent_of_code
MIT License
src/Day05.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
import java.util.ArrayDeque data class Day5Command(val count: Int, val from: Int, val to: Int) data class Day5Data(val stacks: List<ArrayDeque<Char>>, val commands: List<Day5Command>) val COMMAND_REGEX = """^move (\d+) from (\d+) to (\d+)$""".toRegex() fun main() { fun part1(input: List<String>): String { ...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
2,196
adventofcode2022
Apache License 2.0
codeforces/round621/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round621 const val M = 1_000_000_007 fun main() { val (n, m) = readInts() val a = readInts().map { it - 1 } val indices = List(n) { mutableListOf<Int>() } for (x in a.indices) { indices[a[x]].add(x) } val eaters = List(n) { mutableSetOf<Int>() } repeat(m) { val (id, hunger) = readInts().map...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,640
competitions
The Unlicense
yandex/y2020/qual/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2020.qual import kotlin.random.Random fun main() { readLn() var treap: PersistentTreap? = null var ans = 0.toBigInteger() val a = readInts() println(a.mapIndexed { index, x -> ans += (PersistentTreap.split(treap, (x + 1L) * a.size)[1]?.sum ?: 0).toBigInteger() treap = PersistentTreap.add(trea...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,097
competitions
The Unlicense
src/Day10.kt
nordberg
573,769,081
false
{"Kotlin": 47470}
fun main() { fun addInterestingSignals(cycleCount: Int, signalStrength: Int): Int { return when (cycleCount) { 20, 60, 100, 140, 180, 220 -> signalStrength * cycleCount else -> 0 } } fun part1(input: List<String>): Int { var signalStrength = 1 var cyc...
0
Kotlin
0
0
3de1e2b0d54dcf34a35279ba47d848319e99ab6b
2,664
aoc-2022
Apache License 2.0
src/medium/_15ThreeSum.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package medium import java.util.* class _15ThreeSum { /** * 直接三重循环的话,会超时 * 优化-> 先对数组进行排序,然后结合双指针减少遍历次数 */ class Solution { fun threeSum(nums: IntArray): List<List<Int>> { if (nums.size < 3) { return emptyList() } Arrays.sort(nums) ...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
3,397
AlgorithmsProject
Apache License 2.0
project-euler/kotlin/src/test/kotlin/dev/mikeburgess/euler/problems/Problems02x.kt
mddburgess
469,258,868
false
{"Kotlin": 47737}
package dev.mikeburgess.euler.problems import dev.mikeburgess.euler.extensions.* import dev.mikeburgess.euler.math.factorial import dev.mikeburgess.euler.getResourceAsLines import org.assertj.core.api.Assertions.assertThat import java.math.BigInteger import kotlin.test.Test class Problems02x { /** * Problem...
0
Kotlin
0
0
9ad8f26583b204e875b07782c8d09d9d8b404b00
6,773
code-kata
MIT License
src/main/kotlin/com/hjk/advent22/Day10.kt
h-j-k
572,485,447
false
{"Kotlin": 26661, "Racket": 3822}
package com.hjk.advent22 import kotlin.math.abs object Day10 { fun part1(input: List<String>): Int = process(input).filter { (_, cycle) -> cycle in setOf(20, 60, 100, 140, 180, 220) } .sumOf { (x, cycle) -> x * cycle } fun part2(input: List<String>): List<String> = process(input).chunked...
0
Kotlin
0
0
20d94964181b15faf56ff743b8646d02142c9961
971
advent22
Apache License 2.0
utility/src/main/kotlin/aoc2015/utility/Lists.kt
sihamark
581,653,112
false
{"Kotlin": 263428, "Shell": 467, "Batchfile": 383}
package aoc2015.utility /** * finds all permutations of the receiver list. * Each permutation has the same length of the receiver list. * * For example, when applying this function in the list (1, 2, 3) = (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1) */ fun <T> List<T>.allPermutations(): List<L...
0
Kotlin
0
0
6d10f4a52b8c7757c40af38d7d814509cf0b9bbb
1,946
aoc2015
Apache License 2.0
src/day01/Day01.kt
Klaus-Anderson
572,740,347
false
{"Kotlin": 13405}
package day01 import readInput fun main() { fun getTotalCaloriesList(input: List<String>): MutableList<Int> { val totalCalorieList = mutableListOf<Int>() val listDelimiter = "" val breakLines = input.mapIndexedNotNull{ index, elem -> index.takeIf{ elem == listDelimiter } } breakLi...
0
Kotlin
0
0
faddc2738011782841ec20475171909e9d4cee84
1,486
harry-advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/solutions/day14/Day14.kt
Dr-Horv
112,381,975
false
null
package solutions.day14 import solutions.Solver import utils.Coordinate import utils.Direction import utils.KnotHasher import utils.step fun Long.toBinaryString(): String { val s = java.lang.Long.toBinaryString(this) return if(s.length < 4) { s.padStart(4, '0') } else { s } } class D...
0
Kotlin
0
2
975695cc49f19a42c0407f41355abbfe0cb3cc59
2,386
Advent-of-Code-2017
MIT License
kotlin/src/com/s13g/aoc/aoc2022/Day14.kt
shaeberling
50,704,971
false
{"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245}
package com.s13g.aoc.aoc2022 import com.s13g.aoc.Result import com.s13g.aoc.Solver import com.s13g.aoc.XY import com.s13g.aoc.resultFrom import kotlin.math.max import kotlin.math.min /** * --- Day 14: Regolith Reservoir --- * https://adventofcode.com/2022/day/14 */ class Day14 : Solver { override fun solve(lines...
0
Kotlin
1
2
7e5806f288e87d26cd22eca44e5c695faf62a0d7
2,865
euler
Apache License 2.0
src/day2.kt
miiila
725,271,087
false
{"Kotlin": 77215}
import java.io.File import kotlin.math.max import kotlin.system.exitProcess private const val DAY = 2 fun main() { if (!File("./day${DAY}_input").exists()) { downloadInput(DAY) println("Input downloaded") exitProcess(0) } val transformer = { x: String -> x } val input = loadInp...
0
Kotlin
0
1
1cd45c2ce0822e60982c2c71cb4d8c75e37364a1
2,218
aoc2023
MIT License
src/Day14.kt
fmborghino
573,233,162
false
{"Kotlin": 60805}
fun main() { fun log(message: Any?) { println(message) } data class Vec2(val x: Int, val y: Int) data class Node(val c: Char) class Grid(val grid: MutableMap<Vec2, Node>, val hasFloor: Boolean, val rangeX: Pair<Int, Int>, val rangeY: Pair<Int, Int>) fun parse(input: List...
0
Kotlin
0
0
893cab0651ca0bb3bc8108ec31974654600d2bf1
4,947
aoc2022
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day23/HikingTrailMap.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day23 import com.github.michaelbull.advent2023.math.Vector2 import com.github.michaelbull.advent2023.math.Vector2.Companion.CARDINAL_DIRECTIONS import com.github.michaelbull.advent2023.math.Vector2.Companion.EAST import com.github.michaelbull.advent2023.math.Vector2.Companion....
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
4,931
advent-2023
ISC License
src/Day09.kt
thomasreader
573,047,664
false
{"Kotlin": 59975}
import java.io.Reader import kotlin.math.abs data class RopeKnot(var x: Int, var y: Int) data class IntPair(val x: Int, val y: Int) infix fun Int.diff(other: Int) = abs((this) - (other)) fun RopeKnot.isAdjacentTo(other: RopeKnot): Boolean { return (this.x diff other.x < 2 && this.y diff other.y < 2) } fun RopeK...
0
Kotlin
0
0
eff121af4aa65f33e05eb5e65c97d2ee464d18a6
2,430
advent-of-code-2022-kotlin
Apache License 2.0
2022/src/main/kotlin/day1_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.parseItems fun main() { Day1Fast.run() } object Day1All { @JvmStatic fun main(args: Array<String>) { mapOf("func" to Day1Func, "imp" to Day1Imp, "fast" to Day1Fast).forEach { (header, solution) -> solution.run( header = header, print...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,282
aoc_kotlin
MIT License
solutions/aockt/y2021/Y2021D16.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import aockt.y2021.Y2021D16.BitsPacket.TypeID.* import io.github.jadarma.aockt.core.Solution object Y2021D16 : Solution { /** A BITS packet type. */ private sealed interface BitsPacket { /** The version of this packet. Seemingly unused, unless you find the manual. */ val v...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
5,459
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/5. Longest Palindromic Substring Manacher's algorithm.kts
ShreckYe
206,086,675
false
null
import kotlin.math.min // Manacher's Algorithm class Solution { fun longestPalindrome(s: String): String { val lastPosition = 2 * s.length val numPositions = lastPosition + 1 val longestPalindromeLengthsCenteredAt = IntArray(numPositions) var rightmostPalindromeCenter = 0 /...
0
Kotlin
0
0
20e8b77049fde293b5b1b3576175eb5703c81ce2
1,743
leetcode-solutions-kotlin
MIT License
src/Day13.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
private data class SpecialList(val children: ArrayDeque<Any>, val parent: SpecialList?) { override fun toString(): String { val s = StringBuilder("") for (i in children.indices) { val c = children[i] if (c is Int) s.append(c) if (c is SpecialList) s.append("[").ap...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
4,123
aoc-2022
Apache License 2.0
solutions/aockt/y2016/Y2016D02.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2016 import io.github.jadarma.aockt.core.Solution object Y2016D02 : Solution { /** Parses the input and returns the list of instructions for obtaining the bathroom passcode. */ private fun parseInput(input: String): List<List<Direction>> = input.lines().map { line -> line.map { Directi...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,712
advent-of-code-kotlin-solutions
The Unlicense
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem026.kt
mddburgess
261,028,925
false
null
package dev.mikeburgess.euler.problems /** * Problem 26 * * A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions * with denominators 2 to 10 are given: * * 1/2 = 0.5 * 1/3 = 0.(3) * 1/4 = 0.25 * 1/5 = 0.2 * 1/6 = 0.1(6) * 1/7 = 0.(142857) * 1/8 = 0.125 * 1/9...
0
Kotlin
0
0
86518be1ac8bde25afcaf82ba5984b81589b7bc9
1,106
project-euler
MIT License
codeforces/kotlinheroes1/f.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes1 fun main() { val (n, m, canIncrease) = readInts() val a = readInts().sorted() val acc = mutableListOf(0L) for (i in 0 until n) { acc.add(acc[i] + a[i]) } var ans = a.fold(0L, Long::plus) for (left in 0..n - m) { var low = a[left] var high = a[lef...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,306
competitions
The Unlicense
src/main/kotlin/Day03.kt
JPQuirmbach
572,636,904
false
{"Kotlin": 11093}
fun main() { fun priority(group: List<String>): Int { val chars = group.flatMap { it.toSet() } val sharedItem = chars.groupingBy { it } .eachCount() .maxBy { it.value }.key return if (sharedItem.isLowerCase()) sharedItem - 'a' + 1 else ...
0
Kotlin
0
0
829e11bd08ff7d613280108126fa6b0b61dcb819
913
advent-of-code-Kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinFallingPathSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,945
kotlab
Apache License 2.0
src/Day04.kt
Soykaa
576,055,206
false
{"Kotlin": 14045}
// https://stackoverflow.com/questions/67712063/kotlin-split-string-into-range private fun IntRange.isSubset(other: IntRange): Boolean = first in other && last in other private fun IntRange.isOverlap(other: IntRange): Boolean = first in other || last in other private fun getRanges(input: List<String>): List<List<IntR...
0
Kotlin
0
0
1e30571c475da4db99e5643933c5341aa6c72c59
889
advent-of-kotlin-2022
Apache License 2.0
src/Day01.kt
ExpiredMinotaur
572,572,449
false
{"Kotlin": 11216}
fun main() { fun part1(input: List<String>): Int { val elves = input.chunkedByBlank() //separate elves .map { cal -> cal.sumOf { it.toInt() } } //count calories return elves.max() //return max amount of calories } fun part2(input: List<String>): Int { return input.chunke...
0
Kotlin
0
0
7ded818577737b0d6aa93cccf28f07bcf60a9e8f
853
AOC2022
Apache License 2.0
src/main/kotlin/github/walkmansit/aoc2020/Day14.kt
walkmansit
317,479,715
false
null
package github.walkmansit.aoc2020 class Day14(val input: List<String>) : DayAoc<Long, Long> { private class MaskMachine(val commands: Collection<String>) { fun applyCommandsAndGetSum(): Long { var zeroMask = Long.MAX_VALUE // for mult var oneMask = Long.MIN_VALUE // for add ...
0
Kotlin
0
0
9c005ac4513119ebb6527c01b8f56ec8fd01c9ae
3,412
AdventOfCode2020
MIT License
src/main/aoc2022/Day11.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 class Day11(input: List<String>) { data class Monkey( val holding: MutableList<Long>, val test: Int, val ifTrue: Int, val ifFalse: Int, val op: (Long) -> Long ) { var numInspections = 0L fun inspectAndThrow(copingStrategy: (Long) -> Long):...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
2,540
aoc
MIT License
src/day10/Day10.kt
TheJosean
573,113,380
false
{"Kotlin": 20611}
package day10 import readInput fun main() { fun part1(input: List<String>): Int { val cycles = listOf(20, 60, 100, 140, 180, 220) var cycle = 0 var x = 1 return input.sumOf { var result = 0 cycle++ when (it) { "noop" -> { ...
0
Kotlin
0
0
798d5e9b1ce446ba3bac86f70b7888335e1a242b
2,158
advent-of-code
Apache License 2.0
kotlin/wordy/src/main/kotlin/Wordy.kt
fredyw
523,079,058
false
null
import kotlin.math.pow object Wordy { fun answer(input: String): Int { val initial = ("What is (-?\\d+)" + "(?: " + "plus -?\\d+" + "| minus -?\\d+" + "| multiplied by -?\\d+" + "| divided by -?\...
0
Kotlin
0
0
101a0c849678ebb7d2e15b896cfd9e5d82c56275
1,747
exercism
MIT License
src/twentytwentytwo/day2/Day02.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
fun main() { fun part1(input: List<String>): Int = input.sumOf { round -> val choices = round.split(" ") val them = choices[0] val me = choices[1] win(them, me) + extraScore(me) } fun part2(input: List<String>): Int = input.sumOf { round -> val choices = round.split(...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,612
advent-of-code
Apache License 2.0
src/main/kotlin/day16/day16.kt
lavong
317,978,236
false
null
/* --- Day 16: Ticket Translation --- As you're walking to yet another connecting flight, you realize that one of the legs of your re-routed trip coming up is on a high-speed train. However, the train ticket you were given is in a language you don't understand. You should probably figure out what it says before you ge...
0
Kotlin
0
1
a4ccec64a614d73edb4b9c4d4a72c55f04a4b77f
5,419
adventofcode-2020
MIT License
src/main/kotlin/com/chriswk/aoc/2020/Day1.kt
chriswk
317,550,327
false
null
package com.chriswk.aoc.`2020` class Day1 { companion object { @JvmStatic fun main(args: Array<String>): Unit { val day = Day1() val numbers = "day1.txt".fileToLines().map { it.toInt() }.sorted() report { day.part1(numbers) } ...
0
Kotlin
0
0
b2ec866e565bcba9ec0287a6d51297e91831a5b2
2,269
aoc2020
MIT License
src/main/kotlin/com/chriswk/aoc/advent2020/Day7.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2020 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import com.chriswk.aoc.util.toInt import org.apache.logging.log4j.LogManager class Day7: AdventDay(2020, 7) { companion object { @JvmStatic fun main(args: Array<String>) { val day = D...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,915
adventofcode
MIT License
src/main/kotlin/org/sjoblomj/adventofcode/day11/Day11.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day11 import org.sjoblomj.adventofcode.readFile import kotlin.system.measureTimeMillis private const val inputFile = "src/main/resources/inputs/day11.txt" private const val defaultSquareSize = 3 private const val gridWidth = 300 private const val gridHeight = 300 private const val m...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
3,195
adventofcode2018
MIT License
src/main/kotlin/leetcode/kotlin/tree/270. Closest Binary Search Tree Value.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package leetcode.kotlin.tree import java.util.* import kotlin.math.abs /** * Traverse the tree in inorder, store result in array, then find closet value searching sorted array */ private fun closestValue(root: TreeNode?, target: Double): Int { var list = mutableListOf<Int>() fun dfs(root: TreeNode?) { ...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,666
leetcode-kotlin
Apache License 2.0
domain/src/main/java/com/example/domain/helper/RestaurantSortingHelper.kt
RomisaaAttiaa
440,273,040
false
{"Kotlin": 73572}
import com.example.domain.model.Restaurant import com.example.domain.model.SortOptions fun sortRestaurants(sortOptions: SortOptions, restaurants: List<Restaurant>): List<Restaurant> { return sortBasedOnFavorite( sortBasedOnOpeningStatus( sortBasedOnSortingOptions( sortOptions, ...
0
Kotlin
0
0
d82d5cc6feafd1e832d959eee3d69b49d5bb3bc9
2,558
RestaurantsSample
Apache License 2.0
src/Day10.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { data class Step(val cycle: Int, val sum: Int) fun run(input: List<String>): MutableList<Step>{ var cycle = 1 var sum = 1 val steps = mutableListOf<Step>() input.forEach { when (it) { "noop" -> steps.add(Step(cycle++, sum)) ...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
1,186
aoc-2022
Apache License 2.0
src/main/kotlin/championofgoats/advent/2019/day10/day10.kt
ChampionOfGoats
225,446,764
false
null
package championofgoats.advent.twentynineteen.day10 import java.io.File import kotlin.sequences.* import championofgoats.advent.Problem import championofgoats.advent.utils.Direction import championofgoats.advent.utils.Point import championofgoats.advent.utils.logging.Logger object Day10 : Problem { override fun s...
0
Kotlin
0
0
4f69de1579f40928c1278c3cea4e23e0c0e3b742
2,534
advent-of-code
MIT License
src/year2022/day09/Day09.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day09 import Point2D import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { infix fun Point2D.moveTowards(other: Point2D): Point2D { if (this == other || this isAdjacentTo other) return this // move by 1 in direction of dx and dy each val newX = th...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,974
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/adventofcode2023/day13/day13.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day13 import adventofcode2023.readInput import java.lang.RuntimeException import kotlin.math.min import kotlin.time.measureTime fun main() { println("Day 13") val input = readInput("day13") val puzzle1Duration = measureTime { println("Puzzle 1 ${puzzle1(input)}") } ...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
2,601
adventofcode2023
MIT License
src/Day03.kt
ekgame
573,100,811
false
{"Kotlin": 20661}
fun main() { fun Char.priorityScore() = when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> error("Invalid for priority") } fun part1(input: List<String>): Int = input .map { it.chunked(it.length/2) } .sumOf { val set1 = it...
0
Kotlin
0
2
0c2a68cedfa5a0579292248aba8c73ad779430cd
984
advent-of-code-2022
Apache License 2.0
kotlin/main-native.kt
frol
133,128,231
false
null
import kotlin.io.* import java.util.Random val random = Random() class Node(var x: Int) { var y = random.nextInt() var left: Node? = null var right: Node? = null } fun merge(lower: Node?, greater: Node?): Node? { if(lower == null) return greater if(greater == null) return lower...
14
C++
73
523
baeadaac61807f0049ad35b9282b0c27eeb6d104
2,388
completely-unscientific-benchmarks
Apache License 2.0
kotlin/combinatorics/CombinatorialEnumerations.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package combinatorics import java.util.Arrays object CombinatorialEnumerations { fun main(args: Array<String?>?) { val permutations = Permutations(3) permutations.enumerate() val combinations = Combinations(4, 3) combinations.enumerate() val arrangements = Arrangements(3, 2...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
6,309
codelibrary
The Unlicense
src/main/kotlin/lib/matrix/MatrixHelpers.kt
ecxyzzy
679,985,671
false
null
package lib.matrix fun isSymmetric(a: Matrix): Boolean { return if (a.m != a.n) false else a == t(a) } fun isSkewSymmetric(a: Matrix): Boolean { return if (a.m != a.n) false else a == -t(a) } fun t(a: Matrix): Matrix { return Matrix(a.n, a.m, Array(a.n) { i -> Array(a.m) { j -> a[j + 1, i + 1] } }) } fun tr(a...
0
Kotlin
0
0
6b2d12797379b47e2a9b23ee234f5d00820398c3
1,230
cs164-kt
MIT License
src/main/kotlin/ca/kiaira/advent2023/day5/Day5.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day5 import ca.kiaira.advent2023.Puzzle /** * Solves the Day 5 puzzle of Advent of Code. * * The puzzle involves processing a list of seed numbers through a series of mappings * to transform each seed number and determine specific results based on these transformations. * * @constru...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
2,859
kAdvent-2023
Apache License 2.0
2023/src/day07/Day07.kt
scrubskip
160,313,272
false
{"Kotlin": 198319, "Python": 114888, "Dart": 86314}
package day07 import java.io.File fun main() { val input = File("src/day07/day07.txt").readLines() println(getWinnings(input, true)) } fun getWinnings(input: List<String>, useJoker: Boolean = false): Int { val handBids = input.map { handBid -> val parts = handBid.split(" ") Pair(Hand(par...
0
Kotlin
0
0
a5b7f69b43ad02b9356d19c15ce478866e6c38a1
4,054
adventofcode
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions34.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import com.qiaoyuang.algorithm.round0.BinaryTreeNode import com.qiaoyuang.algorithm.round0.Stack import com.qiaoyuang.algorithm.round0.toIntArray fun test34() { val (root, target) = testCase() printlnResults(root, target) printlnResults(root, 21) printlnResults(r...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,550
Algorithm
Apache License 2.0
src/day7/d7_2.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val byTarget = input.lines().map { parseConnection(it) }.associate { it.target to it } // take the signal you got on wire a val origA = eval("a", byTarget, mutableMapOf<String, UShort>()) // override wire b to that signal val rewired = byTarget + ("b" to Connection(Gate.WIRE, ori...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
2,263
aoc2015
MIT License
2021/src/day16/Day16.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day16 import readInput import java.lang.IllegalStateException data class ParsingResult(val packet: Packet, val restOfString: String) sealed class Packet { data class LiteralValue(val v: Int, val number: Long) : Packet() { override fun getVersionSum() = v override fun getTotal() = number ...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
3,987
advent-of-code
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day18.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import arrow.core.Either import arrow.core.getOrElse import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 18: Like a GIF For Your Yard](https://adventofcode.com/2015/day/18). */ object Day18 { @JvmStatic fun main(args: Array<String>) { ...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
1,889
advent-of-code
MIT License
src/Day03.kt
Ramo-11
573,610,722
false
{"Kotlin": 21264}
fun main() { fun mainLogicPart1(first: String, second: String): Int { val matchingLetters: MutableList<Char> = ArrayList() for (letter in first) { if (letter in second && letter !in matchingLetters) { matchingLetters.add(letter) if (letter.isUpperCase())...
0
Kotlin
0
0
a122cca3423c9849ceea5a4b69b4d96fdeeadd01
2,071
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestBridge.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
5,019
kotlab
Apache License 2.0
src/Day03.kt
korsik
573,366,257
false
{"Kotlin": 5186}
import kotlin.properties.Delegates fun main() { fun part1(input: List<String>): Int { fun Char.toScore(): Int { return if(this.isLowerCase()) { this.code - 'a'.code + 1 } else { this.code - 'A'.code + 27 } } return input.s...
0
Kotlin
0
0
1a576c51fc8233b1a2d64e44e9301c7f4f2b6b01
1,600
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
Feketerig
571,677,145
false
{"Kotlin": 14818}
enum class Type(val score: Int){ ROCK(1), PAPER(2), SCISSORS(3) } fun main() { fun fight(first: Type, second: Type): Int{ if (first == second){ return 3 + second.score } return when(second){ Type.ROCK -> { if (first == Type.PAPER){ ...
0
Kotlin
0
0
c65e4022120610d930293788d9584d20b81bc4d7
3,027
Advent-of-Code-2022
Apache License 2.0
aoc16/day_07/main.kt
viktormalik
436,281,279
false
{"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796}
import java.io.File data class IPv7(val supernet: List<String>, val hypernet: List<String>) fun parse_ip(line: String): IPv7 { val split = line.split("[\\[\\]]".toRegex()) return IPv7( split.filterIndexed { i, _ -> (i % 2) == 0 }, split.filterIndexed { i, _ -> (i % 2) == 1 }, ) } fun has_...
0
Rust
1
0
f47ef85393d395710ce113708117fd33082bab30
1,127
advent-of-code
MIT License
src/main/kotlin/com/github/h0tk3y/probabilistik/distribution/Multinomial.kt
h0tk3y
124,875,312
false
null
package com.github.h0tk3y.probabilistik.distribution import com.github.h0tk3y.probabilistik.normalize class Multinomial<T>(val probabilities: Map<T, Double>) : FiniteDistribution<T> { init { require(probabilities.isNotEmpty()) { "At least one value is required." } require(probabilities.values.all ...
1
Kotlin
3
20
d5abd5c58b223957afcc91e7c71093e966757643
1,411
probabilistik
Apache License 2.0
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2023/2023-21.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2023 import com.github.ferinagy.adventOfCode.CharGrid import com.github.ferinagy.adventOfCode.Coord2D import com.github.ferinagy.adventOfCode.IntGrid import com.github.ferinagy.adventOfCode.contains import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.a...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
3,816
advent-of-code
MIT License
src/main/java/com/liueq/leetcode/easy/NextGreaterElementI.kt
liueq
129,225,615
false
{"Java": 240910, "Kotlin": 5671}
package com.liueq.leetcode.easy import java.util.* /** * 问题描述:给定两个数组 nums1, nums2。其中 1 是 2的子集。求nums1 每一个element 在 nums2 中的位置,往后最大的数字。如果不存在,用 -1 代替。 * 比如: [4, 1, 2] * [1, 3, 4, 2] * = * [-1, 3, -1] 因为 4 在 nums2 中往后只有一个 2,不比4大,所以不存在;1在 nums2 中,往后第一个比 1 大的是3,所以返回3。同理。 * * 解:先求出 nums2 每一个 element...
0
Java
0
0
dda0178efe6899800b46b8b7527a8f59e429f5e1
1,599
LeetCodePractice
Apache License 2.0
src/Day04.kt
KarinaCher
572,657,240
false
{"Kotlin": 21749}
fun main() { fun part1(input: List<String>): Int { var result = 0 input.forEach { val elves = it.split(",") val firstElves = elves[0].split("-") val secondElves = elves[1].split("-") val firstElvesSections = (firstElves[0].toInt()..firstElves[1].toI...
0
Kotlin
0
0
17d5fc87e1bcb2a65764067610778141110284b6
1,433
KotlinAdvent
Apache License 2.0
src/Day02.kt
cnietoc
572,880,374
false
{"Kotlin": 15990}
fun main() { fun part1(input: List<String>): Long { var sumResult = 0L input.forEach { val (opponentShapeEncrypted, myShapeEncrypted) = it.split(" ") val myShape = myShapeEncrypted.toMyShape() val opponentShape = opponentShapeEncrypted.toOpponentShape() ...
0
Kotlin
0
0
bbd8e81751b96b37d9fe48a54e5f4b3a0bab5da3
3,404
aoc-2022
Apache License 2.0
src/main/kotlin/year2022/Day23.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils import AoCUtils.test enum class MapType { SPACE, ELF } fun main() { data class MovementLogic(val moveDirection: Map2dDirection, val checks: List<Map2dDirection>) { fun checkIfElf(map: Map2d<MapType>, elf: Point): Boolean { val toCheck = map.around(elf, checks).values.any { it ...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
3,323
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/com/github/wtfjoke/day4/Day4Part1.kts
WtfJoke
434,008,687
false
{"Kotlin": 80582}
import java.nio.file.Paths typealias BingoBoard = List<List<Int>> val inputs = Paths.get("inputs.txt").toFile().useLines { it.toList() } val drawnNumbers = inputs.first().split(',').map { it.toInt() } val boards: Set<BingoBoard> = inputs .asSequence() .drop(1) .filter { it.isNotEmpty() } .chunked(5) ...
1
Kotlin
0
0
9185b9ddf3892be24838139fcfc849d3cb6e89b4
1,242
adventofcode-21
MIT License
classroom/src/main/kotlin/com/radix2/algorithms/extras/Scribble.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.extras import java.util.* fun print(array: IntArray, lo: Int, hi: Int) { if (lo == hi) { println(array[lo]) } else { println(array[lo]) print(array, lo + 1, hi) } } fun map(array: IntArray, lo: Int, hi: Int, transform: (Int) -> Int) { array[lo] = ...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,683
coursera-algorithms-part1
Apache License 2.0
src/main/kotlin/me/grison/aoc/y2021/Day23.kt
agrison
315,292,447
false
{"Kotlin": 267552}
package me.grison.aoc.y2021 import me.grison.aoc.* import me.grison.aoc.y2021.Day23.Amphipod.* import java.util.* import kotlin.math.abs class Day23 : Day(23, 2021) { override fun title() = "Amphipod" enum class Amphipod { A, B, C, D } private val roomExits = listOf(2, 4, 6, 8) override fun partOne(...
0
Kotlin
3
18
ea6899817458f7ee76d4ba24d36d33f8b58ce9e8
4,795
advent-of-code
Creative Commons Zero v1.0 Universal
src/main/kotlin/day5.kt
kevinrobayna
436,414,545
false
{"Ruby": 195446, "Kotlin": 42719, "Shell": 1288}
import java.util.stream.Collectors import kotlin.math.roundToLong data class BoardingPass( val row: List<String>, val seat: List<String> ) { companion object { const val LEFT = "L" const val RIGHT = "R" const val BACK = "B" const val FRONT = "F" } } fun day5ProblemReade...
0
Kotlin
0
0
9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577
3,141
adventofcode_2020
MIT License
src/Day04.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
fun main() { fun String.toRange() = split("-").map { it.toInt() }.let { it[0]..it[1] } fun part1(input: List<String>): Int { var cnt = 0 for (s in input) { val p = s.split(",") val r1 = p[0].toRange().toList() val r2 = p[1].toRange().toList() if (r...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
984
advent-of-code-2022
Apache License 2.0
2021/src/day23/Solution.kt
vadimsemenov
437,677,116
false
{"Kotlin": 56211, "Rust": 37295}
package day23 import java.nio.file.Files import java.nio.file.Paths import java.util.TreeSet import kotlin.math.absoluteValue import kotlin.system.measureTimeMillis fun main() { val amphipods = "ABCD" val step = listOf(1, 10, 100, 1000) val rooms = listOf(3, 5, 7, 9) fun Input.isFinal(): Boolean { for (i...
0
Kotlin
0
0
8f31d39d1a94c862f88278f22430e620b424bd68
3,937
advent-of-code
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem229/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem229 /** * LeetCode page: [229. Majority Element II](https://leetcode.com/problems/majority-element-ii/); */ class Solution { private val k = 3 // Divisor of size of nums describing the threshold to be considered as majority; /* Complexity: * Time O(N) and Space O(...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,733
hj-leetcode-kotlin
Apache License 2.0
src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/SeqValiant.kt
breandan
245,074,037
false
{"Kotlin": 1482924, "Haskell": 744, "OCaml": 200}
package ai.hypergraph.kaliningraph.parsing import ai.hypergraph.kaliningraph.* import ai.hypergraph.kaliningraph.repair.* import ai.hypergraph.kaliningraph.sampling.* import ai.hypergraph.kaliningraph.tensor.UTMatrix import ai.hypergraph.kaliningraph.types.* import com.ionspin.kotlin.bignum.integer.* import kotlin.jvm...
0
Kotlin
8
100
c755dc4858ed2c202c71e12b083ab0518d113714
15,764
galoisenne
Apache License 2.0
src/Day16.kt
PascalHonegger
573,052,507
false
{"Kotlin": 66208}
import kotlin.math.max fun main() { val inputPattern = "Valve (.+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)".toRegex() data class Valve(val id: Long, val name: String, val flowRate: Int, val leadsTo: List<String>) { override fun toString() = name } fun String.toValve(id: Long): ...
0
Kotlin
0
0
2215ea22a87912012cf2b3e2da600a65b2ad55fc
7,829
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2021/Day25.kt
tginsberg
432,766,033
false
{"Kotlin": 92813}
/* * Copyright (c) 2021 by <NAME> */ /** * Advent of Code 2021, Day 25 - Sea Cucumber * Problem Description: http://adventofcode.com/2021/day/25 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day25/ */ package com.ginsberg.advent2021 class Day25(input: List<String>) { private v...
0
Kotlin
2
34
8e57e75c4d64005c18ecab96cc54a3b397c89723
1,798
advent-2021-kotlin
Apache License 2.0
src/year2021/07/Day07.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2021.`07` import readInput import kotlin.math.abs fun main() { fun calculateFullAmountOfFuelToPosition( position: Int, map: Map<Int, Int>, modifier: (Int) -> Int ): Int { return map.keys.sumOf { modifier(abs(it - position)) * map[it]!! } } ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
1,190
KotlinAdventOfCode
Apache License 2.0
src/net/sheltem/aoc/y2023/Day15.kt
jtheegarten
572,901,679
false
{"Kotlin": 178521}
package net.sheltem.aoc.y2023 suspend fun main() { Day15().run() } class Day15 : Day<Long>(1320, 145) { override suspend fun part1(input: List<String>): Long = input[0].split(",").sumOf { it.hash() }.toLong() override suspend fun part2(input: List<String>): Long = part2(input[0]) } private fun String....
0
Kotlin
0
0
ac280f156c284c23565fba5810483dd1cd8a931f
1,639
aoc
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem31/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem31 /** * LeetCode page: [31. Next Permutation](https://leetcode.com/problems/next-permutation/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) where N is the size of nums; */ fun nextPermutation(nums: IntArray): Unit { val leftIndex = fi...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,969
hj-leetcode-kotlin
Apache License 2.0
src/main/kotlin/tr/emreone/adventofcode/days/Day2.kt
EmRe-One
434,793,519
false
{"Kotlin": 44202}
package tr.emreone.adventofcode.days object Day2 { fun part1(input: List<String>): Int { val regex = """^(?<length>\d+)x(?<width>\d+)x(?<height>\d+)$""".toRegex() return input.sumOf { line -> val (l, w, h) = regex.find(line)?.destructured!! val side1 = l.toInt() * w.toInt(...
0
Kotlin
0
0
57f6dea222f4f3e97b697b3b0c7af58f01fc4f53
987
advent-of-code-2015
Apache License 2.0
src/main/kotlin/Day2.kt
mikegehard
114,013,792
false
null
import kotlin.math.absoluteValue data class Spreadsheet(private val rows: List<Row>) { companion object { fun from(s: String): Spreadsheet = Spreadsheet( s.split("\n") .filter { it.isNotBlank() } .map { Row.from(it) } ) } fun ...
0
Kotlin
0
1
d58268847a7dba42d5e7a45b9eb59078711ca53d
1,172
AdventOfCode2017Kotlin
MIT License
src/main/kotlin/com/lucaszeta/adventofcode2020/day09/day09.kt
LucasZeta
317,600,635
false
null
package com.lucaszeta.adventofcode2020.day09 import com.lucaszeta.adventofcode2020.ext.getResourceAsText import java.lang.IllegalArgumentException fun main() { val input = getResourceAsText("/day09/xmas-number-series.txt") .split("\n") .filter { it.isNotEmpty() } .map { it.toLong() } ...
0
Kotlin
0
1
9c19513814da34e623f2bec63024af8324388025
1,891
advent-of-code-2020
MIT License
day14/Part2.kt
anthaas
317,622,929
false
null
import java.io.File fun main(args: Array<String>) { val input = File("input.txt").bufferedReader().use { it.readText() }.split("\n") val mem = mapOf<Long, Long>().toMutableMap() var mask = "" input.map { when { it.startsWith("mask") -> mask = it.split(" = ")[1] it.starts...
0
Kotlin
0
0
aba452e0f6dd207e34d17b29e2c91ee21c1f3e41
1,300
Advent-of-Code-2020
MIT License
src/Day12.kt
lassebe
573,423,378
false
{"Kotlin": 33148}
fun main() { fun buildGraph(input: List<String>): Triple<MutableMap<Pair<Int, Int>, List<Pair<Int, Int>>>, MutableMap<Pair<Int, Int>, Int>, Pair<Pair<Int, Int>,Pair<Int,Int>>> { val edges = mutableMapOf<Pair<Int, Int>, List<Pair<Int, Int>>>() val cost = mutableMapOf<Pair<Int, Int>, Int>() v...
0
Kotlin
0
0
c3157c2d66a098598a6b19fd3a2b18a6bae95f0c
5,048
advent_of_code_2022
Apache License 2.0
src/Day03.kt
bigtlb
573,081,626
false
{"Kotlin": 38940}
fun main() { fun itemSum(items: Iterable<Char>): Int = items.map { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(it) + 1 }.sum() fun part1(input: List<String>): Int = itemSum(input.map { it.toCharArray(endIndex = it.length / 2).intersect(it.toCharArray(it.length / 2...
0
Kotlin
0
0
d8f76d3c75a30ae00c563c997ed2fb54827ea94a
886
aoc-2022-demo
Apache License 2.0
src/day16/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day16 import readInput fun main() { fun part1(input: List<String>): Int { return Valves .parse(input) .mostPressure() } fun part2(input: List<String>): Int { return -1 } val input = readInput("test") //val input = readInput("prod") println(...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
1,909
AoC-2022
Apache License 2.0
2021/src/Day04.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
// https://adventofcode.com/2021/day/4 fun main() { class Table(size: Int, tableNumbers : Collection<Int>) { val size = size var won = false val unselectedNumbers : MutableList<Int> = tableNumbers as MutableList<Int> val numberToPosition = mutableMapOf<Int, Pair<Int, Int>>() val selectedPositions...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
3,464
advent-of-code
Apache License 2.0
src/main/kotlin/org/sj/aoc2022/day06/SignalScanner.kt
sadhasivam
573,168,428
false
{"Kotlin": 10910}
package org.sj.aoc2022.day06 import org.sj.aoc2022.util.readInput fun String.hasUniqueChars(): Boolean = this.toCharArray().distinct().count() != length fun scanSignal(input: String, marker: Int): Int { var signal = "" var count = 0 for (char in input.asSequence()) { signal += char count+...
0
Kotlin
0
0
7a1ceaddbe7e72bad0e9dfce268387d333b62143
1,495
advent-of-code-kotlin-2022
Apache License 2.0
src/Day04.kt
hufman
573,586,479
false
{"Kotlin": 29792}
fun main() { fun parseRange(input: String): IntRange { val parts = input.split('-') .mapNotNull { it.toIntOrNull() } return IntRange(parts[0], parts[1]) } fun parse(input: List<String>): List<Pair<IntRange, IntRange>> { return input .map { it.split(',') } .filter { parts -> parts.size == 2} .map ...
0
Kotlin
0
0
1bc08085295bdc410a4a1611ff486773fda7fcce
970
aoc2022-kt
Apache License 2.0
src/main/kotlin/com/txq/graph/graph.kt
flyingyizi
124,735,014
false
null
package com.txq.graph data class Graph (val numVertices: Int, val isDirection:Boolean=true) { val edage = AdjacencyMatrix(numVertices) val vertex = arrayOfNulls<String>( numVertices) val isTrav = arrayOfNulls<Boolean>( numVertices) //https://www.programiz.com/dsa/graph-dfs //Depth First Search ...
0
Kotlin
0
0
f4ace2d018ae8a93becaee85b7db882098074b7a
2,912
helloworldprovider
Apache License 2.0
src/main/kotlin/io/github/pshegger/aoc/y2022/Y2022D2.kt
PsHegger
325,498,299
false
null
package io.github.pshegger.aoc.y2022 import io.github.pshegger.aoc.common.BaseSolver class Y2022D2 : BaseSolver() { override val year = 2022 override val day = 2 override fun part1(): Int { fun EncryptedSymbol.decrypt() = when (this) { EncryptedSymbol.X -> Symbol.Rock Encr...
0
Kotlin
0
0
346a8994246775023686c10f3bde90642d681474
2,949
advent-of-code
MIT License
src/Day02.kt
RichardLiba
572,867,612
false
{"Kotlin": 16347}
fun main() { val values = mapOf( //rock "A" to 1, //paper "B" to 2, //scissors "C" to 3, //rock "X" to 1, //paper "Y" to 2, //scissors "Z" to 3 ) fun evalWin(round: Pair<String, String>): Int { return w...
0
Kotlin
0
0
6a0b6b91b5fb25b8ae9309b8e819320ac70616ed
2,143
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2019/Day18.kt
tginsberg
222,116,116
false
null
/* * Copyright (c) 2019 by <NAME> */ /** * Advent of Code 2019, Day 18 - Many-Worlds Interpretation * Problem Description: http://adventofcode.com/2019/day/18 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day18/ */ package com.ginsberg.advent2019 import java.util.ArrayDeque class D...
0
Kotlin
2
23
a83e2ecdb6057af509d1704ebd9f86a8e4206a55
3,605
advent-2019-kotlin
Apache License 2.0