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
google/2019/round1_a/1/main.kt
seirion
17,619,607
false
{"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294}
import java.util.* fun main(args: Array<String>) { repeat(readLine()!!.toInt()) { print("Case #${it + 1}: ") solve() } } val impossible = arrayListOf(Pair(2, 2), Pair(2, 3), Pair(2, 4), Pair(3, 2), Pair(3, 3), Pair(4, 2)) const val RIGHT = 2 const val DOWN = 1 fun solve() { var (row, col...
0
C++
4
4
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
1,570
code
Apache License 2.0
src/MatrixUtils.kt
freszu
573,122,040
false
{"Kotlin": 32507}
import kotlin.math.max import kotlin.math.min typealias Matrix<T> = List<List<T>> inline fun <T, R> Matrix<T>.map2d(transform: (T) -> R) = this.map { it.map(transform) } inline fun <T, R> Matrix<T>.map2dIndexed(transform: (x: Int, y: Int, T) -> R) = mapIndexed { y, rows -> rows.mapIndexed { x, t -> transform(x, ...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
1,876
aoc2022
Apache License 2.0
2021/src/Day10.kt
Bajena
433,856,664
false
{"Kotlin": 65121, "Ruby": 14942, "Rust": 1698, "Makefile": 454}
import java.util.* // https://adventofcode.com/2021/day/10 fun main() { fun checkLine(line: String) : Int { val stack = Stack<Char>() for (c in line) { when (c) { '(', '[', '{', '<' -> stack.push(c) ')' -> if (stack.peek() == '(') stack.pop() else return 3 ']' -> if (stack.pee...
0
Kotlin
0
0
a5ca56b7ac8d9d48f82dc079c8ea0cf06d17109a
2,693
advent-of-code
Apache License 2.0
src/Day10.kt
roxanapirlea
572,665,040
false
{"Kotlin": 27613}
import kotlin.math.abs fun main() { fun List<String>.toInstr(): List<Pair<Int, Int>> = map { val instrCount = when { it.startsWith("noop") -> 1 it.startsWith("addx") -> 2 else -> throw IllegalArgumentException() } val instr...
0
Kotlin
0
0
6c4ae6a70678ca361404edabd1e7d1ed11accf32
1,871
aoc-2022
Apache License 2.0
jvm_sandbox/projects/advent_of_code/src/main/kotlin/year2021/Day5.kt
jduan
166,515,850
false
{"Rust": 876461, "Kotlin": 257167, "Java": 139101, "Python": 114308, "Vim Script": 100117, "Shell": 96665, "C": 67784, "Starlark": 23497, "JavaScript": 20939, "HTML": 12920, "Ruby": 5087, "Thrift": 4518, "Nix": 2919, "HCL": 1069, "Lua": 926, "CSS": 826, "Assembly": 761, "Makefile": 591, "Haskell": 585, "Dockerfile": 50...
package year2021 import java.io.File import java.lang.Integer.max import java.lang.Integer.min import kotlin.math.abs fun countPoints(inputFile: String): Int { var dict = mutableMapOf<Pair<Int, Int>, Int>() File(inputFile).forEachLine { line -> val (from, to) = line.split(" -> ") val (x1, y1)...
58
Rust
1
0
d5143e89ce25d761eac67e9c357620231cab303e
2,981
cosmos
MIT License
src/main/kotlin/adventofcode2020/Day21AllergenAssessment.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2020 class Day21AllergenAssessment data class Food(val ingredients: Set<String>, val allergens: Set<String>) { companion object { fun fromString(input: String): Food { val parts = input.split(" (contains ") val ing = parts[0].split(" ").toHashSet() v...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
1,783
kotlin-coding-challenges
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestSuperstring.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,675
kotlab
Apache License 2.0
src/Day05.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day05 : Runner<String, String>(5, "CMZ", "MCD") { override fun part1(input: List<String>): String { val (stacks, instructions) = parseInput(input) // run each instruction instructions.forEach() { with(it) { repeat(count) { stacks[target].addFirst(stacks[so...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
2,133
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/days/Day16.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day16 : Day(16) { private val valves: Map<String, Valve> = parseValves() override fun partOne(): Any { return maxPressure(listOf(valves.getValue("AA")), 30) } override fun partTwo(): Any { return maxPressure(listOf(valves.getValue("AA"), valves.getValue("AA")), 26) ...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
5,320
aoc-2022
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/chriswk/aoc/advent2018/Day8.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2018 object Day8 { fun parseInputToInts(input: List<String>): Sequence<Int> { return input.asSequence().flatMap { it.split(" ").asSequence() }.map { it.toInt() } } fun part1(input: List<String>): Int { val ints = parseInputToInts(input).toMutableList() ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
1,270
adventofcode
MIT License
src/year2022/Day03.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 fun main() { fun part1(input: List<String>): Int { var sum = 0 for (line in input) { val p1 = line.take(line.length / 2) val p2 = line.takeLast(line.length / 2) for (c in p1) { if (p2.contains(c)) { sum += if (...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
1,580
adventofcode-kotlin
Apache License 2.0
kotlin/main.kt
wxmbugu
557,324,684
false
{"Kotlin": 3349, "Rust": 1406, "Makefile": 368}
// Calculating the rsa alglorithm class Rsa(primep: Int, primeq: Int) { var p: Int var q: Int val pq: Int get() = this.p * this.q var n: Int init { p = primep q = primeq n = (p - 1) * (q - 1) } // input should be where there user wants range of prime number to be sel...
0
Kotlin
0
4
7961d1f94356fb115ec1d19005f8e73e2f1027ef
3,099
kotlinrust
MIT License
src/main/kotlin/g1401_1500/s1444_number_of_ways_of_cutting_a_pizza/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1444_number_of_ways_of_cutting_a_pizza // #Hard #Array #Dynamic_Programming #Matrix #Memoization // #2023_06_07_Time_175_ms_(75.00%)_Space_34.7_MB_(100.00%) class Solution { fun ways(pizza: Array<String>, k: Int): Int { if (pizza.isEmpty()) { return 0 } val ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,564
LeetCode-in-Kotlin
MIT License
src/main/kotlin/se/brainleech/adventofcode/aoc2015/Aoc2015Day03.kt
fwangel
435,571,075
false
{"Kotlin": 150622}
package se.brainleech.adventofcode.aoc2015 import se.brainleech.adventofcode.compute import se.brainleech.adventofcode.readText import se.brainleech.adventofcode.verify class Aoc2015Day03 { data class Position(val x: Int, val y: Int) { fun move(direction: Char): Position { return when (directi...
0
Kotlin
0
0
0bba96129354c124aa15e9041f7b5ad68adc662b
1,867
adventofcode
MIT License
src/Day19.kt
p357k4
573,068,508
false
{"Kotlin": 59696}
fun main() { data class Cost(val ore: Int, val clay: Int, val obsidian: Int) data class Blueprint(val ore: Cost, val clay: Cost, val obsidian: Cost, val geode: Cost) fun decode(input: List<String>) = input.map { line -> val segments = line.substringAfter(":").split(".") val oreOre = segment...
0
Kotlin
0
0
b9047b77d37de53be4243478749e9ee3af5b0fac
4,567
aoc-2022-in-kotlin
Apache License 2.0
src/Day05.kt
monsterbrain
572,819,542
false
{"Kotlin": 42040}
import java.util.* import kotlin.collections.ArrayList fun main() { val stackIndexStep = 4 val stackList = ArrayList<Stack<String>>() data class Command(val num:Int, val from:Int, val to:Int) val commands = ArrayList<Command>() fun addCrateToList(s: String) { var stackPosIndex = 1 ...
0
Kotlin
0
0
3a1e8615453dd54ca7c4312417afaa45379ecf6b
3,528
advent-of-code-kotlin-2022-Solutions
Apache License 2.0
src/Day01.kt
ostersc
570,327,086
false
{"Kotlin": 9017}
fun main(){ //1791 fun part1(input: List<String>): Int { var last=0 var countOfIncreases=0 var initialized=false for (i in input) { if(!initialized){ initialized=true }else { if (i.toInt() > last) countOfIncreases++ ...
0
Kotlin
0
0
836ff780252317ee28b289742396c74559dd2b6e
1,582
advent-of-code-2021
Apache License 2.0
leetcode2/src/leetcode/perfect-squares.kt
hewking
68,515,222
false
null
package leetcode /** * 279. 完全平方数 * https://leetcode-cn.com/problems/perfect-squares/ * Created by test * Date 2020/1/29 20:58 * Description * 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n。你需要让组成和的完全平方数的个数最少。 示例 1: 输入: n = 12 输出: 3 解释: 12 = 4 + 4 + 4. 示例 2: 输入: n = 13 输出: 2 解释: 13 = 4 + 9. 来源:力扣(LeetCode...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,376
leetcode
MIT License
src/main/kotlin/com/github/solairerove/algs4/leprosorium/linked_list/MergeKSortedLists.kt
solairerove
282,922,172
false
{"Kotlin": 251919}
package com.github.solairerove.algs4.leprosorium.linked_list /** * You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. * * Merge all the linked-lists into one sorted linked-list and return it. * * Input: lists = [[1 -> 4 -> 5], [1 -> 3 -> 4], [2 -> 6]] * Output: [1 -> 1...
1
Kotlin
0
3
64c1acb0c0d54b031e4b2e539b3bc70710137578
1,325
algs4-leprosorium
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestPathInBinaryMatrix.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,090
kotlab
Apache License 2.0
src/main/kotlin/gal/usc/citius/processmining/dfgfiltering/filtering/Greedy.kt
david-chapela
322,881,845
false
null
package gal.usc.citius.processmining.dfgfiltering.filtering import gal.usc.citius.processmining.dfgfiltering.graph.DirectedGraph /** * Given a connected digraph with one source and one sink vertices, and where all vertices are in, at least, a path from * root to sink (i.e., a Directly Follows Graph), obtains an app...
0
Kotlin
0
0
d73d1f3f3462f9ef3d699d8fafb1435084b472ef
2,293
dfg-edge-filtering
MIT License
src/main/kotlin/com/dambra/adventofcode2018/day7/InstructionStep.kt
pauldambra
159,939,178
false
null
package com.dambra.adventofcode2018.day7 class InstructionStep(val step: String) { val previousSteps: MutableSet<InstructionStep> = mutableSetOf() val nextSteps: MutableSet<InstructionStep> = mutableSetOf() var completed: Boolean = false fun canBeCompleted(completedSteps: MutableSet<InstructionStep>)...
0
Kotlin
0
1
7d11bb8a07fb156dc92322e06e76e4ecf8402d1d
2,612
adventofcode2018
The Unlicense
src/main/kotlin/com/github/davio/aoc/y2022/Day9.kt
Davio
317,510,947
false
{"Kotlin": 405939}
package com.github.davio.aoc.y2022 import com.github.davio.aoc.general.* import kotlin.math.abs import kotlin.math.sign import kotlin.system.measureTimeMillis fun main() { measureTimeMillis { println(Day9.getResultPart1()) }.call { println("Took $it ms") } measureTimeMillis { println(Day9....
1
Kotlin
0
0
4fafd2b0a88f2f54aa478570301ed55f9649d8f3
2,678
advent-of-code
MIT License
src/main/kotlin/io/kixi/Range.kt
kixi-io
271,463,422
false
{"Kotlin": 116609}
package io.kixi /** * A Ki Range can be inclusive or exclusive on both ends, may be reversed (e.g. 5..1), * and can be open on the left or right. Note: Ranges that are open should set the same * value for left and right. This is necessary because Comparable types don't require * a max and min value. * * Reversed...
1
Kotlin
0
1
2db59071c688610e65374201ce922e28ce6cd0f9
2,631
Ki.Core-JVM
MIT License
src/main/kotlin/dev/paulshields/aoc/day9/EncodingError.kt
Pkshields
318,658,287
false
null
package dev.paulshields.aoc.day9 import dev.paulshields.aoc.common.firstIndexed import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 9: Encoding Error ** \n") val xmasData = readFileAsStringList("/day9/XmasData.txt") .map { it.toLong() } val notXmasEncodedNumber =...
0
Kotlin
0
0
a7bd42ee17fed44766cfdeb04d41459becd95803
1,654
AdventOfCode2020
MIT License
src/main/kotlin/day02/Day02.kt
vitalir2
572,865,549
false
{"Kotlin": 89962}
package day02 import Challenge object Day02 : Challenge(2) { /** * my: * X - Rock * Y - Paper * Z - Scissors * opponent: * A - Rock * B - Paper * C - Scissors */ private val myTurnToScores = mapOf( "X" to 1, "Y" to 2, "Z" to 3, ) /...
0
Kotlin
0
0
ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6
2,286
AdventOfCode2022
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/day14/Main.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.day14 import com.bloidonia.aoc2023.text import java.time.LocalTime private const val example = """O....#.... O.OO#....# .....##... OO.#O....O .O.....O#. O.#..O.#.# ..O..#O..O .......O.. #....###.. #OO..#....""" private data class Position(var x: Int, var y: Int) private data class Block...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
4,311
aoc-2023
MIT License
src/Day08_part2.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
class Tree2 { val list = mutableListOf<MutableList<String>>() private var highestScore: Int= 0 private var currentScore: Int = 0 private fun checkAll(i: Int, j: Int): Int = checkLeft(i, j) * checkRight(i, j) * checkTop(i, j) * checkBottom(i, j) private fun checkLeft(i: Int, j: Int): Int { v...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
2,204
aoc2022
Apache License 2.0
src/main/kotlin/misc/Trie.kt
yx-z
106,589,674
false
null
package misc const val EMPTY_CHAR = 0.toChar() const val START_CHAR = 'a' const val END_CHAR = 'z' const val NUM_CHARS = END_CHAR - START_CHAR + 1 const val EMPTY_STRING = "" class Trie { private val root = Node() class Node(private val c: Char = EMPTY_CHAR, var address: String = EMPTY_STRING) { val children =...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,974
AlgoKt
MIT License
src/Day05.kt
andyludeveloper
573,249,939
false
{"Kotlin": 7818}
fun main() { val testInput = readInput("Day05_test") println(part1(testInput, 1)) println(part1(testInput, 2)) check(part1(testInput, 1) == "CMZ") check(part1(testInput, 2) == "MCD") val input = readInput("Day05") val part1 = part1(input, 1) val part2 = part1(input, 2) println(part...
0
Kotlin
0
1
684cf9ff315f15bf29914ca25b44cca87ceeeedf
1,722
Kotlin-in-Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/Day08.kt
bent-lorentzen
727,619,283
false
{"Kotlin": 68153}
import java.time.LocalDateTime import java.time.ZoneOffset fun main() { fun buildMap(input: List<String>) = input.subList(2, input.size) .map { it.split(Regex("\\W")).filterNot { item -> item.isEmpty() } }.associate { it.first() to (it[1] to it[2]) } fun countSteps(instructions: ...
0
Kotlin
0
0
41f376bd71a8449e05bbd5b9dd03b3019bde040b
1,732
aoc-2023-in-kotlin
Apache License 2.0
src/Day10.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import kotlin.math.abs fun interface RegisterCmd { fun apply(x: Int): Int } class Add(private val value: Int): RegisterCmd { override fun apply(x: Int): Int = x + value } val Noop = RegisterCmd {it} class CommandIterator(private val commands: List<String>): Iterator<RegisterCmd> { private var index = 0 ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
1,866
advent-of-code-2022
Apache License 2.0
src/main/kotlin/advent/of/code/day10/Solution.kt
brunorene
160,263,437
false
null
package advent.of.code.day10 import java.io.File private val lineRegex = Regex("position=<([- ]?[0-9]+), ([- ]?[0-9]+)> velocity=<([- ]?[0-9]+), ([- ]?[0-9]+)>") private var input = File("day10.txt").readLines().map { val res = lineRegex.find(it.trim()) listOf( res?.groupValues?.get(1)?.trim()?.toInt...
0
Kotlin
0
0
0cb6814b91038a1ab99c276a33bf248157a88939
1,501
advent_of_code_2018
The Unlicense
src/main/kotlin/dev/shtanko/algorithms/leetcode/ParallelCourses2.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,098
kotlab
Apache License 2.0
src/Day08.kt
MT-Jacobs
574,577,538
false
{"Kotlin": 19905}
fun main() { fun part1(input: List<String>): Int { return (0 until input.first().length).sumOf { x -> (input.indices).count { y -> input.isVisible(x, y) } } } fun part2(input: List<String>): Int { input.scoreViewSouth(1,1) return (0 un...
0
Kotlin
0
0
2f41a665760efc56d531e56eaa08c9afb185277c
3,149
advent-of-code-2022
Apache License 2.0
src/main/kotlin/aoc2015/Day16.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2015 import AoCDay // https://adventofcode.com/2015/day/16 object Day16 : AoCDay<Int>( title = "Aunt Sue", part1Answer = 40, part2Answer = 241, ) { private class Sue(val number: Int, val things: Map<String, Int>) private fun parseSues(input: String) = input .lineSequence() ...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,051
advent-of-code-kotlin
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2021/Dec14.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2021 import org.elwaxoro.advent.PuzzleDayTester import org.elwaxoro.advent.merge import org.elwaxoro.advent.plusNull /** * Extended Polymerization */ class Dec14 : PuzzleDayTester(14, 2021) { /** * HELL YEA LETS MAKE A GIANT STRING WOO! */ override fun part1(): Any = ...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,447
advent-of-code
MIT License
src/Day04.kt
erwinw
572,913,172
false
{"Kotlin": 87621}
@file:Suppress("MagicNumber") private const val DAY = "04" private const val PART1_CHECK = 2 private const val PART2_CHECK = 4 private operator fun IntRange.contains(other: IntRange): Boolean { return (first >= other.first && last <= other.last) || (other.first >= first && other.last <= last) } private ...
0
Kotlin
0
0
57cba37265a3c63dea741c187095eff24d0b5381
1,604
adventofcode2022
Apache License 2.0
P2529.kt
daily-boj
253,815,781
false
null
enum class InequationType { LT, // < GT, // > KT, // Nothing } data class Minmax(val min: Long, val max: Long) fun solve(previous: Int, choice: Long, seq: List<InequationType>, available: Set<Int>): Minmax { var min = 9999999999L var max = 0L if (seq.isEmpty()) { return Minmax(choice, ...
0
Rust
0
12
74294a4628e96a64def885fdcdd9c1444224802c
1,226
RanolP
The Unlicense
src/main/kotlin/net/mguenther/adventofcode/day3/Day3Second.kt
mguenther
115,937,032
false
null
package net.mguenther.adventofcode.day3 import net.mguenther.adventofcode.array2dOfInt /** * @author <NAME> (<EMAIL>) */ class SquareFiller(fillUntilLargerThan: Int) { private val fillUntilLargerThan = fillUntilLargerThan private val internalArray = array2dOfInt(11, 11) private val neighbourVectors: L...
0
Kotlin
0
0
c2f80c7edc81a4927b0537ca6b6a156cabb905ba
2,354
advent-of-code-2017
MIT License
2022/Day22.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
private enum class Dir { RIGHT, DOWN, LEFT, UP } fun main() { val input = readInput("Day22") var map = input.takeWhile { it != "" } val maxx = map.maxOf { it.length } map = map.map { it.padEnd(maxx, ' ') } val path = input.dropWhile { it != "" }.drop(1).single().let { s -> var i0 = 0 ...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
4,288
advent-of-code-kotlin
Apache License 2.0
baparker/07/main.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File import kotlin.math.abs import kotlin.math.ceil import kotlin.math.floor fun getDist(p1: Int, p2: Int): Int { return abs(p1 - p2) } fun getTriangularNum(num: Int): Int { return num * (num + 1) / 2 } fun getSmallestSumOfFuelCost(list: List<Int>, center: Double): Int { var floorSum = 0 ...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
1,041
advent-of-code-2021
MIT License
aoc-2016/src/main/kotlin/nl/jstege/adventofcode/aoc2016/days/Day24.kt
JStege1206
92,714,900
false
null
package nl.jstege.adventofcode.aoc2016.days import nl.jstege.adventofcode.aoccommon.days.Day import nl.jstege.adventofcode.aoccommon.utils.extensions.head import nl.jstege.adventofcode.aoccommon.utils.extensions.permutations import nl.jstege.adventofcode.aoccommon.utils.extensions.transformTo import java.util.* /** ...
0
Kotlin
0
0
d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025
3,900
AdventOfCode
MIT License
src/main/kotlin/Day03.kt
SimonMarquis
434,879,922
false
{"Kotlin": 17423}
class Day03(raw: List<String>) { private val forest: Forest = Forest.parse(raw) fun part1(): Long = forest.trees(Slope(right = 3, down = 1)) fun part2(): Long = listOf( Slope(right = 1, down = 1), Slope(right = 3, down = 1), Slope(right = 5, down = 1), Slope(right = 7, dow...
0
Kotlin
0
0
560e3224e006ad4b6093d89079bbe361a2c0794e
1,514
advent-of-code-2020
Apache License 2.0
src/day02/Day02.kt
veronicamengyan
573,063,888
false
{"Kotlin": 14976}
package day02 import readInput /** * Potential improvement * * Use a formula with mod 3 */ fun main() { fun mapRPCToPoint(input: String): Int { when (input) { "X" -> return 1 "Y" -> return 2 "Z" -> return 3 else -> print("input is invalid") } ...
0
Kotlin
0
0
d443cfa49e9d8c9f76fdb6303ecf104498effb88
3,513
aoc-2022-in-kotlin
Apache License 2.0
2022/11/11.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
class Monkey(monkey: String) { var counter = 0L var items: MutableList<Long> var op: (Long) -> Long val divisibleBy: Long val idIfTrue: Int val idIfFalse: Int companion object { var modulo: Long = 1 var monkeys: MutableList<Monkey> = mutableListOf() } init { ...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
1,826
adventofcode
Apache License 2.0
advent-of-code-2023/src/main/kotlin/Day13.kt
jomartigcal
433,713,130
false
{"Kotlin": 72459}
// Day 13: Point of Incidence // https://adventofcode.com/2023/day/13 import java.io.File import kotlin.math.min fun main() { val lines = File("src/main/resources/Day13.txt").readLines() val listOfList = mutableListOf(mutableListOf<String>()) lines.forEach { if (it.isEmpty()) { listOfL...
0
Kotlin
0
0
6b0c4e61dc9df388383a894f5942c0b1fe41813f
1,634
advent-of-code
Apache License 2.0
src/year2022/day02/Day02.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day02 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { // just do a hard lookup, since we have 9 values only // 1 / 2 / 3 + 0 / 3 / 6 val scores = mapOf( "A X" to 4, // 1 + 3 "A Y" to 8, // 2 + 6 "A Z" to 3, // 3 + 0 "B X" to 1...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,378
advent-of-code-kotlin
Apache License 2.0
aoc-2015/src/main/kotlin/aoc/AocDay21.kt
triathematician
576,590,518
false
{"Kotlin": 615974}
package aoc import aoc.util.chunk import aoc.util.chunkint class AocDay21: AocDay(21) { companion object { @JvmStatic fun main(args: Array<String>) { AocDay21().run() } } val PRINT_ALL_LOADOUTS = false val shopinput = """ Weapons: Cost Damage Armor Dagger 8 4 0 ...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
5,673
advent-of-code
Apache License 2.0
src/main/kotlin/arrayandlist/easy/BestTimeToBuyAndSellStock.kt
jiahaoliuliu
747,189,993
false
{"Kotlin": 97631}
package arrayandlist.easy import org.junit.Assert.assertEquals import org.junit.Test import java.lang.Integer.max /** * You are given an array prices where prices[i] is the price of a given stock on the ith day. * You want to maximize your profit by choosing a single day to buy one stock and choosing a different da...
0
Kotlin
0
0
c5ed998111b2a44d082fc6e6470d197554c0e7c9
5,480
CodingExercises
Apache License 2.0
src/main/kotlin/co/csadev/advent2021/Day04.kt
gtcompscientist
577,439,489
false
{"Kotlin": 252918}
/** * Copyright (c) 2021 by <NAME> * Advent of Code 2021, Day 4 * Problem Description: http://adventofcode.com/2021/day/4 */ package co.csadev.advent2021 import co.csadev.adventOfCode.BaseDay import co.csadev.adventOfCode.Resources.resourceAsText class Day04(override val input: String = resourceAsText("21day04.tx...
0
Kotlin
0
1
43cbaac4e8b0a53e8aaae0f67dfc4395080e1383
1,870
advent-of-kotlin
Apache License 2.0
advent-of-code-2022/src/main/kotlin/eu/janvdb/aoc2022/day7/Day7.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2022.day7 import eu.janvdb.aocutil.kotlin.readLines //const val FILENAME = "input07-test.txt" const val FILENAME = "input07.txt" fun main() { val rootDirectory = readStructure() part1(rootDirectory) part2(rootDirectory) } private fun readStructure(): Directory { val rootDirectory = Director...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,844
advent-of-code
Apache License 2.0
day10/src/main/kotlin/Day10.kt
bzabor
160,240,195
false
null
class Day10(input: List<String>) { val regex = Regex("""[^-0-9]+""") val points = input.map { it -> val (a, b, c, d) = it.split(regex).drop(1).dropLast(1).map { it.toInt() } Point(a, b, c, d) } fun part1(): Int { for (seconds in 0..15000) { val minMax = getGridDime...
0
Kotlin
0
0
14382957d43a250886e264a01dd199c5b3e60edb
1,610
AdventOfCode2018
Apache License 2.0
src/Day14.kt
dmstocking
575,012,721
false
{"Kotlin": 40350}
fun main() { fun part1(input: List<String>): Int { val data = List(700) { List(200) { 0 }.toMutableList() }.toMutableList() input.forEach { line -> val points = line .split(" -> ") .map { it .split(",") ...
0
Kotlin
0
0
e49d9247340037e4e70f55b0c201b3a39edd0a0f
3,508
advent-of-code-kotlin-2022
Apache License 2.0
src/main/java/com/github/mmauro94/irws/Cluster.kt
MMauro94
202,988,256
false
{"HTML": 765422, "Kotlin": 20314}
package com.github.mmauro94.irws import org.jgrapht.alg.tour.ChristofidesThreeHalvesApproxMetricTSP import org.jgrapht.graph.DefaultUndirectedWeightedGraph import org.jgrapht.graph.DefaultWeightedEdge /** * Class that represents a cluster of [Document]s. Each cluster has a [medoid] that is the leader of the cluster,...
0
HTML
0
0
7582bd3e3fbca9dc8ed254c37cd36c8fb8f22105
3,592
irws-project
The Unlicense
src/main/kotlin/challenges/Day02.kt
mledl
725,995,129
false
{"Kotlin": 66471}
package challenges class Day02(private val input: List<String>) { private val checkMap = mapOf("red" to 12, "green" to 13, "blue" to 14) fun getPart1(): Int = input.mapIndexed { index, s -> if (checkGame(s.split(";"))) index + 1 else 0 }.sum() fun getPart2(): Int = calcPowers(input) // Part 1 helper...
0
Kotlin
0
0
7949d61d82d2b1a9b46cea386ae54d88b052606d
970
aoc23
Apache License 2.0
src/Day01.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { fun part1(input: List<String>): Int { var maxCalories = 0 var sum = 0 input.forEach { if (it == "") { if (sum > maxCalories) maxCalories = sum sum = 0 } else { sum += it.toInt() } } ...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
997
advent_of_code_2022
Apache License 2.0
src/Day16.kt
spaikmos
573,196,976
false
{"Kotlin": 83036}
fun main() { fun parseInput(input: List<String>) { for (i in input) { val regexNum = """rate=(\d+)""".toRegex() val regexNames = """([A-Z]{2})""".toRegex() val (flowRate) = regexNum.find(i)!!.destructured val names = regexNames.findAll(i) val it = ...
0
Kotlin
0
0
6fee01bbab667f004c86024164c2acbb11566460
7,581
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/EscapeLargeMaze.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,476
kotlab
Apache License 2.0
src/main/kotlin/g1701_1800/s1751_maximum_number_of_events_that_can_be_attended_ii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1701_1800.s1751_maximum_number_of_events_that_can_be_attended_ii // #Hard #Array #Dynamic_Programming #Binary_Search // #2023_06_18_Time_608_ms_(100.00%)_Space_104.6_MB_(100.00%) import java.util.Arrays @Suppress("NAME_SHADOWING") class Solution { fun maxValue(events: Array<IntArray>, k: Int): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,777
LeetCode-in-Kotlin
MIT License
src/Day05.kt
Jintin
573,640,224
false
{"Kotlin": 30591}
import java.util.* fun main() { fun init(input: List<String>): List<Stack<Char>> { val list = mutableListOf<Stack<Char>>() val emptyIndex = input.indexOf("") repeat(input[emptyIndex - 1].split(" ").last().toInt()) { list.add(Stack()) } for (index in emptyIndex - ...
0
Kotlin
0
2
4aa00f0d258d55600a623f0118979a25d76b3ecb
1,840
AdventCode2022
Apache License 2.0
project/src/tptl/Test.kt
informramiz
173,284,942
false
null
import kotlin.random.Random private fun test() { print("Hello World") } // -------------- 1. Test Scores Problem ------------- // fun solution(T: Array<String>, R: Array<String>): Int { if (T.isEmpty()) return 0 val groups = mutableMapOf<Int, Boolean>() for (i in T.indices) { val groupNumber ...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
2,116
codility-challenges-practice
Apache License 2.0
src/day01/Day01.kt
armanaaquib
572,849,507
false
{"Kotlin": 34114}
package day01 import readInput fun main() { fun part1(input: List<String>): Int { var mostCalories = Int.MIN_VALUE var currentCalories = 0 for (calories in input) { if (calories == "") { if (currentCalories > mostCalories) { mostCalories = c...
0
Kotlin
0
0
47c41ceddacb17e28bdbb9449bfde5881fa851b7
1,472
aoc-2022
Apache License 2.0
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[435]无重叠区间.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
import java.util.* //给定一个区间的集合,找到需要移除区间的最小数量,使剩余区间互不重叠。 // // 注意: // // // 可以认为区间的终点总是大于它的起点。 // 区间 [1,2] 和 [2,3] 的边界相互“接触”,但没有相互重叠。 // // // 示例 1: // // //输入: [ [1,2], [2,3], [3,4], [1,3] ] // //输出: 1 // //解释: 移除 [1,3] 后,剩下的区间没有重叠。 // // // 示例 2: // // //输入: [ [1,2], [1,2], [1,2] ] // //输出: 2 // //解释: 你需要移...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,506
MyLeetCode
Apache License 2.0
puzzles/src/main/kotlin/com/kotlinground/puzzles/search/binarysearch/singlenonduplicate/singleNonDuplicate.kt
BrianLusina
113,182,832
false
{"Kotlin": 483489, "Shell": 7283, "Python": 1725}
package com.kotlinground.puzzles.search.binarysearch.singlenonduplicate /** * Finds the non-duplicate number in the list of numbers where there is at least one non-duplicate. Each other number * has a duplicate element. Which is at most 1. Therefore, duplicates come in pairs * * Observe that the parity (even or od...
1
Kotlin
1
0
5e3e45b84176ea2d9eb36f4f625de89d8685e000
2,531
KotlinGround
MIT License
src/Day10.kt
rbraeunlich
573,282,138
false
{"Kotlin": 63724}
import java.util.Arrays fun main() { fun part1(input: MutableList<String>): Int { var currSignalStrength = 1 var upcomingToAdd = 0 var totalSignalStrength = 0 for (cycle in 1..220) { if (cycle in listOf(20, 60, 100, 140, 180, 220)) { totalSignalStrength +...
0
Kotlin
0
1
3c7e46ddfb933281be34e58933b84870c6607acd
2,208
advent-of-code-2022
Apache License 2.0
src/test/kotlin/org/sjoblomj/adventofcode/day8/Day8Tests.kt
sjoblomj
161,537,410
false
null
package org.sjoblomj.adventofcode.day8 import org.junit.Test import kotlin.test.assertEquals class Day8Tests { @Test fun `Can parse license file`() { val input = "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2" val tree = parseLicense(input) val result = visualise(input, tree) val expected = "" + " 2...
0
Kotlin
0
0
80db7e7029dace244a05f7e6327accb212d369cc
2,302
adventofcode2018
MIT License
app/src/main/kotlin/com/resurtm/aoc2023/day22/Common.kt
resurtm
726,078,755
false
{"Kotlin": 119665}
package com.resurtm.aoc2023.day22 import kotlin.math.max import kotlin.math.min internal data class Pos(val x: Long, val y: Long, val z: Long) internal data class Brick(val a: Pos, val b: Pos) { internal fun intersectsZ(some: Brick) = (this.a.x <= some.b.x && this.b.x >= some.a.x) && (this.a.y <= some.b....
0
Kotlin
0
0
fb8da6c246b0e2ffadb046401502f945a82cfed9
2,259
advent-of-code-2023
MIT License
src/Day02.kt
Svikleren
572,637,234
false
{"Kotlin": 11180}
fun main() { val valuesForPart1 = mapOf( Pair("AX", 4), Pair("AY", 8), Pair("AZ", 3), Pair("BX", 1), Pair("BY", 5), Pair("BZ", 9), Pair("CX", 7), Pair("CY", 2), Pair("CZ", 6), ) val valuesForPart2 = mapOf( Pair("AX", 3), ...
0
Kotlin
0
0
e63be3f83b96a73543bf9bc00c22dc71b6aa0f57
1,455
advent-of-code-2022
Apache License 2.0
src/day5.kts
AfzalivE
317,962,201
false
null
println("Start") val input = readInput("day5.txt").readLines() val allRows = 0..127 val allCols = 0..7 var allSeats = listOf<Int>() for (i in allRows) { for (j in allCols) { allSeats = allSeats + (i * 8 + j) } } val seats = input.map { var rows = IntRange(0, 127) var columns = IntRange(0, 7) ...
0
Kotlin
0
0
cc5998bfcaadc99e933fb80961be9a20541e105d
1,268
AdventOfCode2020
Apache License 2.0
src/day04/day04.kt
mahmoud-abdallah863
572,935,594
false
{"Kotlin": 16377}
package day04 import assertEquals import readInput import readTestInput fun main() { fun toListOfSets(input: List<String>): List<Pair<Set<Int>, Set<Int>>> = input .map { line -> val (set1, set2) = line .split(",") .map { val (first, second) ...
0
Kotlin
0
0
f6d1a1583267e9813e2846f0ab826a60d2d1b1c9
1,137
advent-of-code-2022
Apache License 2.0
2021/src/main/kotlin/de/skyrising/aoc2021/day18/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2021.day18 import de.skyrising.aoc.* val test = TestInput(""" [[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]] [[[5,[2,8]],4],[5,[[9,9],0]]] [6,[[[6,2],[5,6]],[[7,6],[4,7]]]] [[[6,[0,7]],[0,9]],[4,[9,[9,0]]]] [[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]] [[6,[[7,3],[3,2]]],[[[...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
4,891
aoc
MIT License
src/main/kotlin/com/oocode/OasisReport.kt
ivanmoore
725,978,325
false
{"Kotlin": 42155}
package com.oocode fun oasisReportFrom(input: String): OasisReport = OasisReport(input .split("\n") .map { line -> OasisHistory(line.split(" ").map { it.toInt() }) }) data class OasisReport(private val histories: List<OasisHistory>) { fun extrapolatedValuesSum(): Int { return histories...
0
Kotlin
0
0
36ab66daf1241a607682e7f7a736411d7faa6277
1,027
advent-of-code-2023
MIT License
src/main/year_2016/day18/day18.kt
rolf-rosenbaum
572,864,107
false
{"Kotlin": 80772}
package year_2016.day18 const val input: Row = ".^^.^^^..^.^..^.^^.^^^^.^^.^^...^..^...^^^..^^...^..^^^^^^..^.^^^..^.^^^^.^^^.^...^^^.^^.^^^.^.^^.^." typealias Row = String fun main() { println(part1()) println(part2()) } fun part1(): Int = generateSequence(input) { s -> s.nextRow() }.take(40).sumOf { it.c...
0
Kotlin
0
2
59cd4265646e1a011d2a1b744c7b8b2afe482265
1,082
aoc-2022
Apache License 2.0
src/day12/Day12.kt
henrikrtfm
570,719,195
false
{"Kotlin": 31473}
package day12 import utils.Resources.resourceAsListOfString fun main(){ val neighbors = sequenceOf(-1 to 0, 0 to -1, 0 to 1, 1 to 0) val input = resourceAsListOfString("src/day12/Day12.txt") val heightmap = parseInput(input) fun returnNeighbors(point: Point): List<Point>{ return neighbors.map...
0
Kotlin
0
0
20c5112594141788c9839061cb0de259f242fb1c
2,302
aoc2022
Apache License 2.0
2015/kt/src/test/kotlin/org/adventofcode/Day07.kt
windmaomao
225,344,109
false
{"JavaScript": 538717, "Ruby": 89779, "Kotlin": 58408, "Rust": 21350, "Go": 19106, "TypeScript": 9930, "Haskell": 8908, "Dhall": 3201, "PureScript": 1488, "HTML": 1307, "CSS": 1092}
package org.adventofcode data class Equation( val op: String, val inputs: List<String>, val output: String ) { fun eval(values: HashMap<String, Int>): Int { val _v = { i: Int -> values.getOrDefault(inputs[i], 0) } return when (op) { "AND" -> _v(0) and _v(1) "OR" -> _v(0) or _v(1) ...
5
JavaScript
0
0
1d64d7fffa6fcfc6825e6aa9322eda76e790700f
1,822
adventofcode
MIT License
src/main/kotlin/kt/kotlinalgs/app/graph/HamiltonianCycle.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph Solution().test() data class DirectedWeightedGraphWithAdjMatrix(val matrix: Array<IntArray>) class Solution { fun test() { println("Test") val graph = DirectedWeightedGraphWithAdjMatrix( arrayOf( intArrayOf(0, 1, 0, 1, 0), ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,210
KotlinAlgs
MIT License
src/twentytwentytwo/day5/Day05.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day5 import readInput fun main() { fun part1(input: List<String>): String { val stacks = listOf( ArrayDeque(listOf('W', 'B', 'G', 'Z', 'R', 'D', 'C', 'V')), ArrayDeque(listOf('V', 'T', 'S', 'B', 'C', 'F', 'W', 'G')), ArrayDeque(listOf('W', 'N', '...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
2,691
advent-of-code
Apache License 2.0
src/year2022/day03/Solution.kt
LewsTherinTelescope
573,240,975
false
{"Kotlin": 33565}
package year2022.day03 import utils.runIt fun main() = runIt( testInput = """ vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT CrZsJsPPZsGzwwsLwLmpwMDw """.trimIndent(), ::part1, testAnswerPart1 = 157, ::part2, testAnswerPar...
0
Kotlin
0
0
ee18157a24765cb129f9fe3f2644994f61bb1365
968
advent-of-code-kotlin
Do What The F*ck You Want To Public License
src/Day08.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
fun solveDay08() { val input = readInput("Day08_test") solvePart1(input) } private var trees: List<List<Int>> = emptyList() private val visibleTrees: MutableList<MutableList<Boolean>> = mutableListOf() private fun solvePart1(input: List<String>) { trees = input.map { line -> line.map { it.digitToInt() } } ...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
3,685
AoC-2022
Apache License 2.0
src/Day23.kt
astrofyz
572,802,282
false
{"Kotlin": 124466}
import kotlin.math.min fun main() { class Elf(var pos: Pair<Int, Int>, var direction: String){} fun Elf.print(){ println("pos = ${this.pos}; direction = ${this.direction}") } fun List<Elf>.printFull(){ val minRow = this.map { it.pos.first }.min() val maxRow = this.map { it.po...
0
Kotlin
0
0
a0bc190b391585ce3bb6fe2ba092fa1f437491a6
4,615
aoc22
Apache License 2.0
src/chapter2/problem5/solution2.kts
neelkamath
395,940,983
false
null
/* Question: Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list. EXAMPLE Input: (7 -> 1 -> 6) + ...
0
Kotlin
0
0
4421a061e5bf032368b3f7a4cee924e65b43f690
3,456
ctci-practice
MIT License
kotlin/src/com/daily/algothrim/leetcode/medium/MinPathSum.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 64. 最小路径和 * * 给定一个包含非负整数的 m x n 网格 grid ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 * 说明:每次只能向下或者向右移动一步。 */ class MinPathSum { companion object { @JvmStatic fun main(args: Array<String>) { println( MinPathSum().minPathSum( ...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,670
daily_algorithm
Apache License 2.0
2023/src/main/kotlin/Day09.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day09 { fun part1(input: String): Int { return parseInput(input) .map { sequences(it) } .sumOf { extrapolate(it) } } fun part2(input: String): Int { return parseInput(input) .map { sequences(it) } .sumOf { extrapolateBackwards(it) } } private fun sequences(history: Li...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
868
advent-of-code
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2019/Dec03.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2019 import org.elwaxoro.advent.* /** * Day 3: Crossed Wires */ class Dec03: PuzzleDayTester(3, 2019) { private val start = Coord(0,0,'o') override fun part1(): Any = load().map { it.split(",") }.let { wires -> val wire1 = wires.first().toSegments() val wire2 =...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
1,805
advent-of-code
MIT License
project/src/problems/BinarySearch.kt
informramiz
173,284,942
false
null
package problems /** * https://codility.com/media/train/12-BinarySearch.pdf */ object BinarySearch { fun findNumber(A: Array<Int>, key: Int): Int { var start = 0 var end = A.lastIndex while (start <= end) { val mid = (start + end) / 2 if (A[mid] == key) { ...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
13,156
codility-challenges-practice
Apache License 2.0
src/Day01.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { fun part1(input: List<String>): Int { var elfNum = 0 return input.groupBy { if (it.isBlank()) elfNum++; elfNum } .map { elf -> elf.value.filterNot { calories -> calories.isBlank() } } .maxOf { it.sumOf { n -> n.toInt() } } } fun part2(inp...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
743
aoc-2022
Apache License 2.0
src/PatternFinder.kt
romangraef
124,646,322
false
null
import java.lang.Math.floor import java.lang.Math.max import javax.script.ScriptEngine import javax.script.ScriptEngineManager data class Expression(val expression: String) fun main(args:Array<String>) { while (true) { println("---------------------------") println("Separate numbers by comma.") ...
0
Kotlin
0
0
e140a49107337a9169628067cebfca79afc009d5
3,594
PatternToFormula
MIT License
solutions/src/MinCostForTickets.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
//https://leetcode.com/problems/minimum-cost-for-tickets/ class MinCostForTickets { fun mincostTickets(days: IntArray, costs: IntArray) : Int { val oneDayCost = costs[0] val sevenDayCost = costs[1] val thirtyDayCost = costs[2] val costOnDay = arrayOfNulls<Int>(days.size) ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
1,410
leetcode-solutions
MIT License
src/main/kotlin/day08/Day08.kt
daniilsjb
572,664,294
false
{"Kotlin": 69004}
package day08 import java.io.File fun main() { val data = parse("src/main/kotlin/day08/Day08.txt") val answer1 = part1(data) val answer2 = part2(data) println("🎄 Day 08 🎄") println() println("[Part 1]") println("Answer: $answer1") println() println("[Part 2]") println("...
0
Kotlin
0
0
6f0d373bdbbcf6536608464a17a34363ea343036
2,371
advent-of-code-2022
MIT License
src/main/kotlin/g0301_0400/s0336_palindrome_pairs/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0336_palindrome_pairs // #Hard #Array #String #Hash_Table #Trie #2022_11_17_Time_2451_ms_(67.33%)_Space_303.4_MB_(41.58%) @Suppress("kotlin:S6218", "NAME_SHADOWING") class Solution { fun palindromePairs(words: Array<String>): List<List<Int>> { val ans = mutableListOf<List<Int>>() ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,228
LeetCode-in-Kotlin
MIT License
src/test/kotlin/ch/ranil/aoc/aoc2022/Day13.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.math.min import kotlin.test.assertEquals object Day13 : AbstractDay() { @Test fun part1() { assertEquals(13, compute1(testInput)) assertEquals(5806, compute1(puzzleInput)) } @...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
3,757
aoc
Apache License 2.0
src/Day04.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
fun main() { fun listToRange(s: String): List<Int> { val (lr, rr) = s.split("-") return (lr.toInt()..rr.toInt()).toList() } fun parse(input: List<String>) = input.map { it.split(",") } .map { (l, r) -> Pair(listToRange(l), listToRange(r)) } fun part1(input: List<S...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
855
aoc22
Apache License 2.0
codeforces/kotlinheroes8/g.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.kotlinheroes8 fun main() { val (n, m) = readInts() data class Attack(val warrior: Int, val barricade: Int, val damage: Int) val attacks = List(n) { warrior -> val (_, damages, barricadesLeft) = List(3) { readInts() } List(damages.size) { Attack(warrior, m - barricadesLeft[it], damages[it]) } ...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,489
competitions
The Unlicense
kotlin/src/x2023/Day03.kt
freeformz
573,924,591
false
{"Kotlin": 43093, "Go": 7781}
package x2023 data class Entry(val num: Int, val line: Int, val start: Int, val end: Int) { fun isPart(symbols: List<Symbol>): Boolean = symbols.any { symbol -> symbol.adjacent(this) } } data class Symbol(val char: Char, val x: Int, val y: Int) { fun adjacent(num: Entry): Boolean = y >= num.line ...
0
Kotlin
0
0
5110fe86387d9323eeb40abd6798ae98e65ab240
4,542
adventOfCode
Apache License 2.0
src/Day11.kt
jinie
572,223,871
false
{"Kotlin": 76283}
private typealias MonkeyId = Int private typealias ItemWorryLevel = Long private typealias ItemInspection = (ItemWorryLevel) -> ItemWorryLevel private typealias ItemRelief = (ItemWorryLevel) -> ItemWorryLevel class Day11 { fun part1(input: String) = input .parse() .getMonkeyBusinessLevel(20) { it ...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
4,052
aoc-22-kotlin
Apache License 2.0
ceria/14/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Long { var memory = mutableMapOf<Int, Long>() var mask = StringBuilder() ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
3,126
advent-of-code-2020
MIT License
src/day25/day25.kt
kacperhreniak
572,835,614
false
{"Kotlin": 85244}
package day25 import readInput import kotlin.math.pow private fun symbolToDigit(input: Char): Int = when (input) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else -> throw IllegalArgumentException() } private const val SNAFU_SYMBOLS = "012=-" private fun convertToDecimal(line: Strin...
0
Kotlin
1
0
03368ffeffa7690677c3099ec84f1c512e2f96eb
1,261
aoc-2022
Apache License 2.0
src/questions/MergeIntervals.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.assertIterableSame import kotlin.math.exp import kotlin.math.max /** * Given an array of intervals where `intervals[i] = [starti, endi]`, merge all overlapping intervals, * and return an array of the non-overlapping intervals that cover all the ...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,475
algorithms
MIT License
src/Day01.kt
jamesrobert
573,249,440
false
{"Kotlin": 13069}
fun main() { fun mapCalories(input: List<String>): Map<Int, Int> { val calorieMap = mutableMapOf<Int, Int>() var elfIndex = 0 for (line in input) { if (line.isBlank()) elfIndex++ else calorieMap[elfIndex] = (calorieMap[elfIndex] ?: 0) + line.toInt() } ...
0
Kotlin
0
0
d0b49770fc313ae42d802489ec757717033a8fda
869
advent-of-code-2022
Apache License 2.0