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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
leetcode-75-kotlin/src/main/kotlin/LongestSubarrayOf1sAfterDeletingOneElement.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given a binary array nums, you should delete one element from it.
*
* Return the size of the longest non-empty subarray containing only 1's in the resulting array.
* Return 0 if there is no such subarray.
*
*
*
* Example 1:
*
* Input: nums = [1,1,0,1]
* Output: 3
* Explanation: After deleting the numb... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,395 | leetcode-75 | Apache License 2.0 |
src/main/kotlin/g1501_1600/s1515_best_position_for_a_service_centre/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1515_best_position_for_a_service_centre
// #Hard #Math #Geometry #Randomized #2023_06_12_Time_183_ms_(100.00%)_Space_34.5_MB_(100.00%)
class Solution {
fun getMinDistSum(positions: Array<IntArray>): Double {
var minX = Int.MAX_VALUE.toDouble()
var minY = Int.MAX_VALUE.toDouble(... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,209 | LeetCode-in-Kotlin | MIT License |
src/Day05.kt | cerberus97 | 579,910,396 | false | {"Kotlin": 11722} | fun main() {
fun parseInputStacks(input: List<String>): List<MutableList<Char>> {
val numStacks = (input[0].length + 1) / 4
val stacks = List(numStacks) { mutableListOf<Char>() }
input.forEach { row ->
if (row.contains('[')) {
row.forEachIndexed { idx, crate ->
if (crate.isUpperCas... | 0 | Kotlin | 0 | 0 | ed7b5bd7ad90bfa85e868fa2a2cdefead087d710 | 1,585 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/TwoSumLessThanK.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,013 | kotlab | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2022/Day23.kt | colinodell | 572,710,708 | false | {"Kotlin": 105421} | package com.colinodell.advent2022
class Day23(input: List<String>) {
private val elves = input.toGrid().filter { it.value == '#' }.keys
fun solvePart1() = simulate()
.take(10)
.last()
.let { elves ->
(elves.width() * elves.height()) - elves.count()
}
fun solveP... | 0 | Kotlin | 0 | 1 | 32da24a888ddb8e8da122fa3e3a08fc2d4829180 | 2,624 | advent-2022 | MIT License |
src/main/kotlin/day03/Main.kt | jhreid | 739,775,732 | false | {"Kotlin": 13073} | package day03
import java.io.File
fun main() {
val input = File("./day03.txt").readLines(Charsets.UTF_8)
val valid = input.filter { line ->
val sides = line.trim().split("\\s+".toRegex()).map { it.toInt() }
val (one, two, three) = Triple(sides[0], sides[1], sides[2])
one + two > thre... | 0 | Kotlin | 0 | 0 | 8eeb2bc6b13e76d83a5403ae087729e2c3bbadb1 | 1,409 | AdventOfCode2016 | Apache License 2.0 |
src/main/kotlin/com/resnik/intel/similarity/Extensions.kt | mtresnik | 389,683,705 | false | null | package com.resnik.intel.similarity
import java.util.*
fun String.lcs(other: String): String {
val numArray = Array(this.length + 1) { IntArray(other.length + 1) { 0 } }
for (i in 1 until this.length + 1) {
val c1 = this[i - 1]
for (j in 1 until other.length + 1) {
val c2 = other[j... | 0 | Kotlin | 0 | 0 | 46f23b3033a385e29c043712c0edf9b7023de316 | 2,773 | intel | Apache License 2.0 |
src/Day08.kt | ostersc | 572,991,552 | false | {"Kotlin": 46059} | fun main() {
data class Tree(val x: Int, val y: Int)
fun parseTrees(
input: List<String>,
treeMap: MutableList<MutableList<Int>>,
visibleTrees: MutableSet<Tree>
) {
//LOOK FROM LEFT
//parsing populates the treemap, and also does the look from left
for (yIndex... | 0 | Kotlin | 0 | 1 | 3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9 | 5,210 | advent-of-code-2022 | Apache License 2.0 |
src/2021/Day4_1.kts | Ozsie | 318,802,874 | false | {"Kotlin": 99344, "Python": 1723, "Shell": 975} | import java.io.File
import kotlin.collections.HashMap
import kotlin.collections.ArrayList
class Box(val value: Int, val x: Int, val y: Int, var selected: Boolean = false)
class Board(val boxes: ArrayList<Box>) {
fun selectIf(number: Int) = boxes.filter { it.value == number }.forEach { it.selected = true }
fun... | 0 | Kotlin | 0 | 0 | d938da57785d35fdaba62269cffc7487de67ac0a | 1,581 | adventofcode | MIT License |
2022/src/main/kotlin/de/skyrising/aoc2022/day20/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2022.day20
import de.skyrising.aoc.*
class CircularLongListItem(val value: Long) {
var next = this
var prev = this
fun connect(next: CircularLongListItem) {
next.prev = this
this.next = next
}
fun move(steps: Int) {
if (steps == 0) return
v... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 1,945 | aoc | MIT License |
src/Day21.kt | jvmusin | 572,685,421 | false | {"Kotlin": 86453} | import java.math.BigInteger
import java.util.*
fun main() {
fun part1(input: List<String>): Long {
val monkeys = HashMap<String, () -> Long>()
val cache = HashMap<String, Long>()
fun get(name: String): Long = cache.getOrPut(name) { return monkeys[name]!!() }
for (m in input) {
... | 1 | Kotlin | 0 | 0 | 4dd83724103617aa0e77eb145744bc3e8c988959 | 5,023 | advent-of-code-2022 | Apache License 2.0 |
src/array/TwoSums.kt | develNerd | 456,702,818 | false | {"Kotlin": 37635, "Java": 5892} | /*
*
*
*
*
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,... | 0 | Kotlin | 0 | 0 | 4e6cc8b4bee83361057c8e1bbeb427a43622b511 | 2,351 | Blind75InKotlin | MIT License |
src/Day05.kt | a-glapinski | 572,880,091 | false | {"Kotlin": 26602} | import utils.component6
import utils.readInputAsLines
fun main() {
val (stacksInput, proceduresInput) = readInputAsLines("day05_input").asSequence()
.filter { it.isNotBlank() }
.partition { !it.startsWith("move") }
val stackIndices = stacksInput.last().withIndex()
.filter { (_, c) -> c... | 0 | Kotlin | 0 | 0 | c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8 | 1,586 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | lmoustak | 573,003,221 | false | {"Kotlin": 25890} | fun main() {
fun stringToRange(s: String): IntRange {
val endpoints = s.split('-')
val start = endpoints[0].toInt()
val end = endpoints[1].toInt()
return start..end
}
fun part1(input: List<String>): Int {
var overlaps = 0
for (line in input) {
va... | 0 | Kotlin | 0 | 0 | bd259af405b557ab7e6c27e55d3c419c54d9d867 | 1,014 | aoc-2022-kotlin | Apache License 2.0 |
14/kotlin/src/main/kotlin/se/nyquist/Day14.kt | erinyq712 | 437,223,266 | false | {"Kotlin": 91638, "C#": 10293, "Emacs Lisp": 4331, "Java": 3068, "JavaScript": 2766, "Perl": 1098} | package se.nyquist
class Day14(input: List<String>) {
private val lastChar = input.first().last()
private val template: Map<String, Long> = parseTemplate(input.first())
private val rules: Map<String, Char> = parseRules(input)
private fun parseTemplate(input: String): Map<String, Long> =
input... | 0 | Kotlin | 0 | 0 | b463e53f5cd503fe291df692618ef5a30673ac6f | 1,676 | adventofcode2021 | Apache License 2.0 |
src/main/kotlin/com/manalili/advent/Day07.kt | maines-pet | 162,116,190 | false | null | package com.manalili.advent
import java.util.*
class Day07(input: List<String>) {
private val instructions: MutableMap<Char, MutableList<Char>> = mutableMapOf()
private val regex = Regex("""Step ([A-z]) must be finished before step ([A-z]) can begin.""")
init {
input.forEach {
val (s... | 0 | Kotlin | 0 | 0 | 25a01e13b0e3374c4abb6d00cd9b8d7873ea6c25 | 3,194 | adventOfCode2018 | MIT License |
untitled/src/main/kotlin/Day4.kt | jlacar | 572,845,298 | false | {"Kotlin": 41161} | class Day4(private val fileName: String) : AocSolution {
override val description: String get() = "Day 4 - Camp Cleanup ($fileName)"
private val input = InputReader(fileName).lines
override fun part1() = input.count { hasFullContainment(it) }
override fun part2() = input.count { hasOverlap(it) }
}
fu... | 0 | Kotlin | 0 | 2 | dbdefda9a354589de31bc27e0690f7c61c1dc7c9 | 1,511 | adventofcode2022-kotlin | The Unlicense |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[108]将有序数组转换为二叉搜索树.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给你一个整数数组 nums ,其中元素已经按 升序 排列,请你将其转换为一棵 高度平衡 二叉搜索树。
//
// 高度平衡 二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过 1 」的二叉树。
//
//
//
// 示例 1:
//
//
//输入:nums = [-10,-3,0,5,9]
//输出:[0,-3,9,-10,null,5]
//解释:[0,-10,5,null,-3,null,9] 也将被视为正确答案:
//
//
//
// 示例 2:
//
//
//输入:nums = [1,3]
//输出:[3,1]
//解释:[1,3] 和 [3,1] 都是高度平衡二叉搜索树。
//
/... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,766 | MyLeetCode | Apache License 2.0 |
src/Day03.kt | Advice-Dog | 436,116,275 | true | {"Kotlin": 25836} | fun main() {
fun part1(input: List<String>): Int {
val counts = Array(input.first().length) { 0 }
for (binary in input) {
for ((index, c) in binary.withIndex()) {
counts[index] += c.digitToInt()
}
}
val gammaRate = Integer.parseInt(counts.jo... | 0 | Kotlin | 0 | 0 | 2a2a4767e7f0976dba548d039be148074dce85ce | 1,890 | advent-of-code-kotlin-template | Apache License 2.0 |
src/Day01.kt | malteesch | 573,138,358 | false | {"Kotlin": 1690} | fun main() {
fun part1(input: String): Int = input
.splitToSequence("\n{2}".toRegex())
.map { it.split("\n".toRegex()) }
.maxOf { list ->
list
.filter { string -> string.isNotEmpty() }
.map(String::toInt)
.sum()
}
fun p... | 0 | Kotlin | 0 | 0 | 2c26cdf0134742628e06782f1fd930a4b257105b | 876 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/adventofcode/day05/Mapping.kt | jwcarman | 731,408,177 | false | {"Kotlin": 137289} | /*
* Copyright (c) 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in ... | 0 | Kotlin | 0 | 0 | dfb226e92a03323ad48c50d7e970d2a745b479bb | 2,905 | adventofcode2023 | Apache License 2.0 |
src/main/kotlin/aoc2016/Day04.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2016
import AoCDay
import util.illegalInput
// https://adventofcode.com/2016/day/4
object Day04 : AoCDay<Int>(
title = "Security Through Obscurity",
part1ExampleAnswer = 1514,
part1Answer = 409147,
part2Answer = 991,
) {
private class Room(val encryptedName: String, val sectorId: Int, v... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 1,961 | advent-of-code-kotlin | MIT License |
day10/kotlin/bit-jkraushaar/solution.kts | mehalter | 317,661,818 | true | {"HTML": 2739009, "Java": 348790, "Kotlin": 271602, "TypeScript": 262310, "Python": 198318, "JetBrains MPS": 191916, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 283... | #!/usr/bin/env -S kotlinc-jvm -script
import java.io.File
import kotlin.math.atan2
// tag::asteroids[]
typealias Asteroid = Pair<Int, Int>
fun convertToAsteroidSet(map: List<CharArray>): Set<Asteroid> {
val asteroidSet = mutableSetOf<Asteroid>()
for (row in map.withIndex()) {
for (column in row.value... | 0 | HTML | 0 | 0 | afcaede5326b69fedb7588b1fe771fd0c0b3f6e6 | 3,584 | docToolchain-aoc-2019 | MIT License |
app/src/main/kotlin/me/mataha/misaki/solutions/adventofcode/aoc2015/d16/Day.kt | mataha | 302,513,601 | false | {"Kotlin": 92734, "Gosu": 702, "Batchfile": 104, "Shell": 90} | package me.mataha.misaki.solutions.adventofcode.aoc2015.d16
import com.github.h0tk3y.betterParse.grammar.parseToEnd
import me.mataha.misaki.domain.adventofcode.AdventOfCode
import me.mataha.misaki.domain.adventofcode.AdventOfCodeDay
/** See the puzzle's full description [here](https://adventofcode.com/2015/day/16). *... | 0 | Kotlin | 0 | 0 | 748a5b25a39d01b2ffdcc94f1a99a6fbc8a02685 | 1,343 | misaki | MIT License |
src/Day02.kt | Jintin | 573,640,224 | false | {"Kotlin": 30591} | fun main() {
fun part1(input: List<String>): Int {
var score = 0
input.forEach {
score += it[2] - 'X' + 1
if (it[2] - 'X' == it[0] - 'A') {
score += 3
} else if (it[2] - 'X' == (it[0] - 'A' + 1) % 3) {
score += 6
}
... | 0 | Kotlin | 0 | 2 | 4aa00f0d258d55600a623f0118979a25d76b3ecb | 812 | AdventCode2022 | Apache License 2.0 |
src/main/aoc2019/Day10.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2019
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.atan2
import Pos
class Day10(input: List<String>) {
data class Angle(val value: Double) {
var pos = Pos(0, 0)
var distance: Int = 0
companion object {
fun calculate(self: Pos, other: Pos): Angle {... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,615 | aoc | MIT License |
src/main/kotlin/g2701_2800/s2741_special_permutations/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2701_2800.s2741_special_permutations
// #Medium #Array #Dynamic_Programming #Bit_Manipulation #Bitmask
// #2023_08_07_Time_623_ms_(82.35%)_Space_60.8_MB_(52.94%)
class Solution {
private var dp = HashMap<Pair<Int, Int>, Long>()
private var adj = HashMap<Int, HashSet<Int>>()
private var mod = 1000... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,579 | LeetCode-in-Kotlin | MIT License |
2023/src/main/kotlin/net/daams/solutions/5b.kt | Michiel-Daams | 573,040,288 | false | {"Kotlin": 39925, "Nim": 34690} | package net.daams.solutions
import net.daams.Solution
class `5b`(input: String): Solution(input) {
override fun run() {
val splitInput = input.split("\n\n")
val seeds = splitInput[0].removePrefix("seeds: ").split(" ").map{ it.toLong() }
val seedRanges = mutableListOf<LongRange>()
... | 0 | Kotlin | 0 | 0 | f7b2e020f23ec0e5ecaeb97885f6521f7a903238 | 4,461 | advent-of-code | MIT License |
2020/day/21/allergens.kt | mboos | 318,232,614 | false | {"Python": 45197, "Swift": 25305, "Kotlin": 3701} | /**
* Solution to https://adventofcode.com/2020/day/21
*/
import java.io.File
fun main(args: Array<String>) {
var input: String = args[0]
var potentialAllergens = mutableMapOf<String, MutableSet<String>>()
var allIngredients = mutableListOf<String>()
var pattern: Regex = Regex("((\\w+ )+)\\(contains (\\w+(,... | 0 | Python | 0 | 0 | 4477bb32c50b951b0a1be4850ed28a2c6f78e65d | 1,949 | advent-of-code | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/SearchA2dMatrix.kt | faniabdullah | 382,893,751 | false | null | //Write an efficient algorithm that searches for a value in an m x n matrix.
//This matrix has the following properties:
//
//
// Integers in each row are sorted from left to right.
// The first integer of each row is greater than the last integer of the
//previous row.
//
//
//
// Example 1:
//
//
//Input: ma... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,111 | dsa-kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ShortestPath.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 | 4,469 | kotlab | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2021/day4/Day4.kt | michaelbull | 433,565,311 | false | {"Kotlin": 162839} | package com.github.michaelbull.advent2021.day4
import com.github.michaelbull.advent2021.Puzzle
object Day4 : Puzzle<Day4.Input, Int>(day = 4) {
data class Input(
val draws: List<List<Int>>,
val boards: List<BingoBoard>
)
private fun List<Int>.toDraws(): List<List<Int>> {
return m... | 0 | Kotlin | 0 | 4 | 7cec2ac03705da007f227306ceb0e87f302e2e54 | 1,765 | advent-2021 | ISC License |
2022/21/21.kt | LiquidFun | 435,683,748 | false | {"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191} | fun main() {
val input = generateSequence(::readlnOrNull).map { it.split(": ") }.toList()
val known = input
.filter { (_, value) -> value[0].isDigit() }
.associate { (name, value) -> name to value.toDouble() }
.toMutableMap()
val inputsWithOps = input.filter { " " in it[1] }.map { (n... | 0 | Kotlin | 7 | 43 | 7cd5a97d142780b8b33b93ef2bc0d9e54536c99f | 1,582 | adventofcode | Apache License 2.0 |
src/SeqRanking.kt | nkkarpov | 302,503,568 | false | null | import java.lang.Math.*
fun SeqRanking(env: Environment, initM: List<Int>, budget: Int): List<List<Int>> {
env.reset()
val n = env.n
val m = initM.toIntArray()
val C = List<MutableList<Int>>(m.size - 1) { mutableListOf() }
fun ilog(n: Int) = 0.5 + (2..n).map { 1.0 / it }.sum()
fun t(r: Int, a... | 0 | Kotlin | 0 | 0 | 0d0db3fe0c6e465eb7c7d49b6f284473138d9117 | 3,031 | batched-sorting | MIT License |
103_-_Stacking_Boxes/src/Main.kt | JeanCarlosSC | 274,552,136 | false | null | import java.lang.NumberFormatException
import javax.swing.JOptionPane
import kotlin.system.exitProcess
fun main(){
val numBox = nextInt(1, 30, "enter the number of boxes", "Input", JOptionPane.QUESTION_MESSAGE)
val numDimensions = nextInt(1, 15, "Enter the dimension of the boxes", "Input", JOptionPane.QUESTION... | 0 | Kotlin | 0 | 0 | 82f43d45aa5c5bf570691f9c811a286e27b39a0e | 4,527 | problem-set-volume1 | Apache License 2.0 |
src/Day06.kt | rifkinni | 573,123,064 | false | {"Kotlin": 33155, "Shell": 125} | fun main() {
fun traverseWindows(input: MutableList<Char>, size: Int): Int {
val windows = input.windowed(size)
for (i in windows.indices) {
if (windows[i].distinct().size == size) {
return i + size
}
}
return 0
}
fun part1(input: Muta... | 0 | Kotlin | 0 | 0 | c2f8ca8447c9663c0ce3efbec8e57070d90a8996 | 1,077 | 2022-advent | Apache License 2.0 |
src/Day04.kt | ricardorlg-yml | 573,098,872 | false | {"Kotlin": 38331} | fun main() {
data class Section(val x: Int, val y: Int) {
infix fun fullyContains(other: Section): Boolean {
return x <= other.x && y >= other.y
}
infix fun overlaps(other: Section): Boolean {
return !(other.x > y || other.y < x)
}
}
fun String.toSec... | 0 | Kotlin | 0 | 0 | d7cd903485f41fe8c7023c015e4e606af9e10315 | 1,021 | advent_code_2022 | Apache License 2.0 |
src/Day03.kt | lassebe | 573,423,378 | false | {"Kotlin": 33148} | import kotlin.streams.toList
fun main() {
fun itemPriority(c: Int): Int =
if (c >= 97) (c - 97 + 1)
else (c - 65 + 27)
fun part1Alt(input: List<String>) =
input.sumOf { bag ->
val wholeBag = bag.chars().toList()
val (firstBagItems, secondBagItems) = wholeBag.ch... | 0 | Kotlin | 0 | 0 | c3157c2d66a098598a6b19fd3a2b18a6bae95f0c | 1,357 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/solutions/day21/Day21.kt | Dr-Horv | 112,381,975 | false | null |
package solutions.day21
import solutions.Solver
import utils.Coordinate
import utils.plus
fun printMap(map: Map<Coordinate, Boolean>) {
val size = determineSize(map)
for (y in 0 until size) {
for(x in 0 until size) {
val value = map.getOrDefault(Coordinate(x, y), false)
if(va... | 0 | Kotlin | 0 | 2 | 975695cc49f19a42c0407f41355abbfe0cb3cc59 | 6,303 | Advent-of-Code-2017 | MIT License |
src/year2020/day5/Solution.kt | Niallfitzy1 | 319,123,397 | false | null | package year2020.day5
import java.io.File
fun main() {
val totalRows = 127
val totalColumns = 7
val passes = File("src/year2020/day5/input").readLines().map { BoardingPass(it.take(7), it.takeLast(3)) }
var largestId = 0
val seatIds = passes.map {
var rowRange = 0..totalRows
var col... | 0 | Kotlin | 0 | 0 | 67a69b89f22b7198995d5abc19c4840ab2099e96 | 1,563 | AdventOfCode | The Unlicense |
aoc-2023/src/main/kotlin/aoc/aoc18.kts | triathematician | 576,590,518 | false | {"Kotlin": 615974} | import aoc.AocParser.Companion.parselines
import aoc.*
import aoc.util.*
val testInput = """
R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713f0)
D 2 (#d2c081)
R 2 (#59c680)
D 2 (#411b91)
L 5 (#8ceee2)
U 2 (#caa173)
L 1 (#1b58a2)
U 2 (#caa171)
R 2 (#7807d2)
U 3 (#a77fa3)
L 2 (#015232)
U 2 (#7a21e3)
""".parselines
class Directio... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 8,345 | advent-of-code | Apache License 2.0 |
src/exercises/Day19.kt | Njko | 572,917,534 | false | {"Kotlin": 53729} | // ktlint-disable filename
package exercises
import readInput
data class Blueprint(
val index: Int,
val oreRobotCost: Int,
val clayRobotCost: Int,
val obsidianRobotCost: Pair<Int, Int>,
val geodeRobotConst: Pair<Int, Int>
)
fun extractBlueprints(input: List<String>): List<Blueprint> {
val pat... | 0 | Kotlin | 0 | 2 | 68d0c8d0bcfb81c183786dfd7e02e6745024e396 | 2,125 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} | fun main() {
fun Char.toPriority() = if (this.isUpperCase())
this.code - 65 + 27
else
this.code - 96
fun part1(input: List<String>): Int {
return input.map { it.chunked(it.length / 2).map {it.toSet()} }
.map { (it[0] intersect it[1]).first() }
.sumOf { it.to... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 787 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/sorts/InsertionSorts.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,009 | kotlab | Apache License 2.0 |
src/day09/Day09.kt | taer | 573,051,280 | false | {"Kotlin": 26121} | package day09
import readInput
import java.io.File
import kotlin.math.abs
fun main() {
data class Location(var x: Int = 0, var y: Int = 0)
fun Location.move(direction: String) {
when (direction) {
"U" -> y++
"D" -> y--
"L" -> x--
"R" -> x++
}
... | 0 | Kotlin | 0 | 0 | 1bd19df8949d4a56b881af28af21a2b35d800b22 | 1,847 | aoc2022 | Apache License 2.0 |
2022/src/main/kotlin/org/suggs/adventofcode/Day08TreetopTreeHouse.kt | suggitpe | 321,028,552 | false | {"Kotlin": 156836} | package org.suggs.adventofcode
object Day08TreetopTreeHouse {
fun countAllVisibleTreesFrom(listOfRows: List<List<Int>>): Int {
val listOfColumns = createListOfColumnsFrom(listOfRows)
var count = 0
listOfRows.forEachIndexed { y, ints ->
ints.forEachIndexed { x, data ->
... | 0 | Kotlin | 0 | 0 | 9485010cc0ca6e9dff447006d3414cf1709e279e | 2,729 | advent-of-code | Apache License 2.0 |
KameleBeladen.kt | UlrichBerntien | 156,849,364 | false | null | /**
* Programmieraufgabe:
*
* Kamele beladen
* https://www.programmieraufgaben.ch/aufgabe/kamele-beladen/6gddr4zm
*
* Ein Kamel soll optimal beladen werden. Das Kamel kann maximal 270 kg tragen.
* Aktuell sind Waren mit den folgenden Gewichten zu transportieren: 5, 18, 32,
* 34, 45, 57, 63, 69, 94, 98 und... | 0 | Kotlin | 1 | 0 | 0b4c6085584c972ab3e8dd8b9f49ab77c751df7f | 2,721 | Uebungen-Kotlin | Apache License 2.0 |
archive/2022/Day24.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 18
private const val EXPECTED_2 = 54
private class Day24(isTest: Boolean) : Solver(isTest) {
// 4 moves + stay in place
val dirs = listOf(1 to 0, 0 to 1, -1 to 0, 0 to -1, 0 to 0)
val dirMap = mapOf('>' to 0, 'v' to 1, '<' to 2, '^' to 3)
val map = readAsLines()
var ... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 4,002 | advent-of-code-2022 | Apache License 2.0 |
solutions/src/main/kotlin/de/thermondo/solutions/advent2022/day01/Part2Solution.kt | thermondo | 552,876,124 | false | {"Kotlin": 23756, "Makefile": 274} | package de.thermondo.solutions.advent2022.day01
import de.thermondo.utils.Exclude
import de.thermondo.utils.stringFromFile
/**
* By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most
* Calories of food might eventually run out of snacks.
*
* To avoid ... | 6 | Kotlin | 1 | 0 | ef413904ce4bbe82861776f2efe5efd43dd5dc99 | 1,441 | lets-learn-kotlin | MIT License |
src/Day05.kt | maciekbartczak | 573,160,363 | false | {"Kotlin": 41932} | import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.text.StringBuilder
fun main() {
fun part1(input: String): String {
return getTopCratesAfterRearrangement(input, false)
}
fun part2(input: String): String {
return getTopCratesAfterRearrangement(input, true)
}
va... | 0 | Kotlin | 0 | 0 | 53c83d9eb49d126e91f3768140476a52ba4cd4f8 | 2,481 | advent-of-code-2022 | Apache License 2.0 |
src/Day06.kt | ds411 | 573,543,582 | false | {"Kotlin": 16415} | fun main() {
fun part1(input: List<String>): Int {
val str = input.joinToString("")
val len = 4
val pos = distinctStringEndPos(str, len)
return pos
}
fun part2(input: List<String>): Int {
val str = input.joinToString("")
val len = 14
val pos = distin... | 0 | Kotlin | 0 | 0 | 6f60b8e23ee80b46e7e1262723960af14670d482 | 884 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem1615/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1615
/**
* LeetCode page: [1615. Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank/);
*/
class Solution {
/* Complexity:
* Time O(n^2) and Space O(n+E) where E is the size of roads;
*/
fun maximalNetworkRank(n: Int, roads: Array<IntArray>... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,477 | hj-leetcode-kotlin | Apache License 2.0 |
src/dynamicprogramming/LongestValidParenthesis.kt | faniabdullah | 382,893,751 | false | null | package dynamicprogramming
class LongestValidParenthesis {
fun longestValidParentheses(s: String): Int {
var maxans = 0
val dp = IntArray(s.length)
for (i in 1 until s.length) {
// ( ) ) ( ( ( ) )
// 0 0 0 0 0 0 0 0
// 0 2 0 0 0 0 2
if (s[i] ... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 1,078 | dsa-kotlin | MIT License |
kotlinP/src/main/java/com/jadyn/kotlinp/leetcode/thought/DoublePointer.kt | JadynAi | 136,196,478 | false | null | package com.jadyn.kotlinp.leetcode.thought
import org.w3c.dom.Node
import java.util.*
import kotlin.math.max
/**
*JadynAi since 3/21/21
*
* 双指针
*/
fun main() {
// print("find two sub ${findTwoNumSub(arrayOf(1, 2, 4, 6, 9), 14)}")
print("judgeSquareSum ${judgeSquareSum(1000)}")
}
// 在有序数组中找出两个数,使它们的和为 targ... | 0 | Kotlin | 6 | 17 | 9c5efa0da4346d9f3712333ca02356fa4616a904 | 2,938 | Kotlin-D | Apache License 2.0 |
src/AoC14.kt | Pi143 | 317,631,443 | false | null | import java.io.File
import kotlin.math.pow
fun main() {
println("Starting Day 14 A Test 1")
calculateDay14PartA("Input/2020_Day14_A_Test1")
println("Starting Day 14 A Real")
calculateDay14PartA("Input/2020_Day14_A")
println("Starting Day 14 B Test 1")
calculateDay14PartB("Input/2020_Day14_B_T... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 4,510 | AdventOfCode2020 | MIT License |
src/main/Day04.kt | lifeofchrome | 574,709,665 | false | {"Kotlin": 19233} | package main
import readInput
fun main() {
val input = readInput("Day04")
val day4 = Day04(input)
print("Part 1: ${day4.part1()}\n")
print("Part 2: ${day4.part2()}")
}
class Day04(input: List<String>) {
private val ranges : List<Pair<IntRange, IntRange>>
init {
ranges = input.map { lin... | 0 | Kotlin | 0 | 0 | 6c50ea2ed47ec6e4ff8f6f65690b261a37c00f1e | 1,032 | aoc2022 | Apache License 2.0 |
src/Day01.kt | izyaboi | 572,898,317 | false | {"Kotlin": 4047} | fun main() {
fun part1(input: List<String>): Int {
return input
.split { line -> line.isBlank() }
.map { listOfCalories -> listOfCalories.map { calorie -> calorie.toInt() }.sumOf { it } }
.maxOf { it }
}
fun part2(input: List<String>): Int {
return input.... | 0 | Kotlin | 0 | 1 | b0c8cafc5fe610b088d7ca4d10e2deef8d418f96 | 786 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/org/jetbrains/bio/genome/query/LocusQuery.kt | JetBrains-Research | 173,494,429 | false | {"Kotlin": 1220056} | package org.jetbrains.bio.genome.query
import org.jetbrains.bio.genome.*
import org.jetbrains.bio.genome.containers.locationList
import org.jetbrains.bio.genome.containers.minus
import org.jetbrains.bio.util.Lexeme
import org.jetbrains.bio.util.RegexLexeme
import org.jetbrains.bio.util.Tokenizer
import org.jetbrains.b... | 2 | Kotlin | 3 | 30 | 3f806c069e127430b91712a003e552490bff0820 | 7,626 | bioinf-commons | MIT License |
src/main/kotlin/codes/hanno/adventofcode/day3/Day3Runner.kt | hannotify | 572,944,980 | false | {"Kotlin": 7464} | import java.io.File
import java.nio.file.Path
fun main(args: Array<String>) {
Day3Runner().run(Path.of("src/main/resources/day3/input.txt"))
}
class Day3Runner {
fun run(input: Path) {
File(input.toString()).useLines { lines ->
val groups = mutableListOf<Group>()
val rucksacks... | 0 | Kotlin | 0 | 0 | ccde130e52f5637f140b331416634b8ce86bc401 | 2,211 | advent-of-code | Apache License 2.0 |
year2020/src/main/kotlin/net/olegg/aoc/year2020/day22/Day22.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2020.day22
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.toPair
import net.olegg.aoc.year2020.DayOf2020
/**
* See [Year 2020, Day 22](https://adventofcode.com/2020/day/22)
*/
object Day22 : DayOf2020(22) {
override fun first(): Any? {
val (p1, p2) = data
.spli... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 2,333 | adventofcode | MIT License |
version-utils/src/commonMain/kotlin/org/jetbrains/packagesearch/packageversionutils/normalization/VeryLenientDateTimeExtractor.kt | JetBrains | 498,634,410 | false | {"Kotlin": 129001} | package org.jetbrains.packagesearch.packageversionutils.normalization
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
public object VeryLenientDateTimeExtractor {
/**
* This list of patterns is sorted from longest t... | 0 | Kotlin | 4 | 5 | aa00d67522436bf4ae38707b0d3fdcc04698ab7e | 3,197 | package-search-api-models | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2022/Day18.kt | tginsberg | 568,158,721 | false | {"Kotlin": 113322} | /*
* Copyright (c) 2022 by <NAME>
*/
/**
* Advent of Code 2022, Day 18 - Boiling Boulders
* Problem Description: http://adventofcode.com/2022/day/18
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day18/
*/
package com.ginsberg.advent2022
class Day18(input: List<String>) {
privat... | 0 | Kotlin | 2 | 26 | 2cd87bdb95b431e2c358ffaac65b472ab756515e | 1,501 | advent-2022-kotlin | Apache License 2.0 |
src/Day19.kt | phoenixli | 574,035,552 | false | {"Kotlin": 29419} | fun main() {
fun part1(input: List<String>): Int {
val blueprints = mutableListOf<RobotFactory>()
input.forEach {
val robotFactory = RobotFactory()
robotFactory.addBlueprint(it)
blueprints.add(robotFactory)
}
val results = mutableListOf<Result>()
... | 0 | Kotlin | 0 | 0 | 5f993c7b3c3f518d4ea926a792767a1381349d75 | 4,367 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/io/github/aarjavp/aoc/day11/Day11.kt | AarjavP | 433,672,017 | false | {"Kotlin": 73104} | package io.github.aarjavp.aoc.day11
import io.github.aarjavp.aoc.readFromClasspath
class Day11 {
enum class Direction(val rowOffset: Int, val colOffset: Int) {
UP(rowOffset = -1, colOffset = 0),
UP_RIGHT(rowOffset = -1, colOffset = 1),
RIGHT(rowOffset = 0, colOffset = 1),
DOWN_RIG... | 0 | Kotlin | 0 | 0 | 3f5908fa4991f9b21bb7e3428a359b218fad2a35 | 3,970 | advent-of-code-2021 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/BalanceBST.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,577 | kotlab | Apache License 2.0 |
app/src/main/java/online/vapcom/codewars/algorithms/NodesLoop.kt | vapcomm | 503,057,535 | false | {"Kotlin": 142486} | package online.vapcom.codewars.algorithms
class Node(val id: Int, var next: Node?) {
companion object {
fun createChain(chainSize: Int, loopSize: Int): Node {
val loop: Array<Node> = if (loopSize == 1) {
val n = Node(1, null)
n.next = n
val a = Ar... | 0 | Kotlin | 0 | 0 | 97b50e8e25211f43ccd49bcee2395c4bc942a37a | 1,716 | codewars | MIT License |
2021/src/main/kotlin/day16_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | @file:OptIn(ExperimentalUnsignedTypes::class)
import utils.Parser
import utils.Solution
fun main() {
Day16Func.run()
}
object Day16Func : Solution<UByteArray>() {
override val name = "day16"
override val parser = Parser { input ->
input.chunked(2).map { it.toUByte(16) }.toUByteArray()
}
sealed interfa... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 4,436 | aoc_kotlin | MIT License |
src/main/kotlin/org/jetbrains/bio/statistics/hypothesis/Testing.kt | karl-crl | 208,228,814 | true | {"Kotlin": 1021604} | package org.jetbrains.bio.statistics.hypothesis
import org.jetbrains.bio.statistics.MoreMath
import org.jetbrains.bio.viktor.F64Array
import org.jetbrains.bio.viktor.argSort
enum class Alternative {
LESS, GREATER, TWO_SIDED
}
/**
* Hypergeometric distribution describes the number of successes k
* in n draws fr... | 0 | Kotlin | 0 | 0 | 469bed933860cc34960a61ced4599862acbea9bd | 3,953 | bioinf-commons | MIT License |
src/Day14.kt | tbilou | 572,829,933 | false | {"Kotlin": 40925} | fun main() {
val day = "Day14"
fun expand(p1: Pair<Int, Int>, p2: Pair<Int, Int>): MutableList<Pair<Int, Int>> {
var result = mutableListOf<Pair<Int, Int>>()
if (p1.first == p2.first) {
// iterate over Y
val l = listOf(p1.second, p2.second).sortedDescending()
... | 0 | Kotlin | 0 | 0 | de480bb94785492a27f020a9e56f9ccf89f648b7 | 5,346 | advent-of-code-2022 | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/IncreasingTripletSubsequence.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given an integer array nums,
* return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k].
* If no such indices exists, return false.
*
*
*
* Example 1:
*
* Input: nums = [1,2,3,4,5]
* Output: true
* Explanation: Any triplet where i < j < k is valid.
... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,178 | leetcode-75 | Apache License 2.0 |
src/AoC2.kt | Pi143 | 317,631,443 | false | null | import java.io.File
fun main() {
println("Starting Day 2 A Test 1")
calculateDay2PartA("Input/2020_Day2_A_Test1")
println("Starting Day 2 A Real")
calculateDay2PartA("Input/2020_Day2_A")
println("Starting Day 2 B Test 1")
calculateDay2PartB("Input/2020_Day2_A_Test1")
println("Starting Day... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 2,185 | AdventOfCode2020 | MIT License |
src/com/github/frozengenis/day1/Puzzle.kt | FrozenSync | 159,988,833 | false | null | package com.github.frozengenis.day1
import java.io.File
import java.util.*
fun main() {
val inputFile = File("""src\com\github\frozengenis\day1\input.txt""")
val resultingFrequency = calculateResultingFrequency(inputFile)
val duplicateResultingFrequency = findDuplicateResultingFrequency(inputFile)
S... | 0 | Kotlin | 0 | 0 | ec1e3472990a36b4d2a2270705253c679bee7618 | 2,000 | advent-of-code-2018 | The Unlicense |
src/Day14.kt | weberchu | 573,107,187 | false | {"Kotlin": 91366} | private fun parseRocks(input: List<String>): Set<Pair<Int, Int>> {
val rocks = mutableSetOf<Pair<Int, Int>>()
for (line in input) {
val rockCorners = line.split(" -> ")
for (i in 0..rockCorners.size - 2) {
val corner1 = rockCorners[i].split(",").map { it.toInt() }
val co... | 0 | Kotlin | 0 | 0 | 903ff33037e8dd6dd5504638a281cb4813763873 | 3,674 | advent-of-code-2022 | Apache License 2.0 |
2021/03/main.kt | chylex | 433,239,393 | false | null | import java.io.File
fun main() {
val lines = File("input.txt").readLines().filter(String::isNotEmpty)
val input = Input(lines)
part1(input)
part2(input)
}
class Input(val lines: List<String>) {
val totalRows = lines.size
val totalColumns = lines[0].length
}
private fun part1(input: Input) = with(input) {
val ... | 0 | Rust | 0 | 0 | 04e2c35138f59bee0a3edcb7acb31f66e8aa350f | 1,534 | Advent-of-Code | The Unlicense |
src/Day03.kt | dominiquejb | 572,656,769 | false | {"Kotlin": 10603} | fun main() {
fun Char.itemPriority(): Int {
return when (val c = this.code) {
in 97..122 -> c - 96
in 65..90 -> c - 38
else -> throw Error("Invalid item")
}
}
fun getCommonItem(first: String, second: String): Char {
for (c in first.toCharArray())... | 0 | Kotlin | 0 | 0 | f4f75f9fc0b5c6c81759357e9dcccb8759486f3a | 1,701 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/days/Solution17.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.*
import java.util.*
typealias IntGrid = List<List<Int>>
typealias CrucibleState = Pair<Point2D, Point2D>
object Solution17 : Solution<IntGrid>(AOC_YEAR, 17) {
override fun getInput(handler: InputHandler) = handle... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 1,942 | Advent-of-Code-2023 | MIT License |
src/main/kotlin/g2901_3000/s2902_count_of_sub_multisets_with_bounded_sum/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2901_3000.s2902_count_of_sub_multisets_with_bounded_sum
// #Hard #Array #Hash_Table #Dynamic_Programming #Sliding_Window
// #2024_01_03_Time_263_ms_(87.50%)_Space_41.5_MB_(37.50%)
import kotlin.math.min
@Suppress("NAME_SHADOWING")
class Solution {
private val mod = 1000000007
private val intMap = In... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,012 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumWays.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,898 | kotlab | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2020/Day20.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2020
import com.dvdmunckhof.aoc.rotate
import kotlin.math.sqrt
class Day20(input: String) {
private val tiles = input.split("\n\n").map { tile ->
val id = tile.substring(5, 9).toLong()
val grid = tile.split("\n").drop(1)
val edgeLeft = grid.joinToString("")... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 5,586 | advent-of-code | Apache License 2.0 |
src/Day12.kt | SergeiMikhailovskii | 573,781,461 | false | {"Kotlin": 32574} | val queue = ArrayDeque<Point>()
val matrixElementsWithDistanceToEnd = mutableMapOf<Point, Int>()
var width: Int = 0
var height: Int = 0
var input: List<String> = listOf()
fun main() {
input = readInput("Day12_test")
var end = Point(0, 0)
input.forEachIndexed { i, line ->
line.forEachIndexed { j, it... | 0 | Kotlin | 0 | 0 | c7e16d65242d3be6d7e2c7eaf84f90f3f87c3f2d | 1,930 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/year_2023/Day03.kt | krllus | 572,617,904 | false | {"Kotlin": 97314} | package year_2023
import Day
import solve
import utils.isStar
class Day03 : Day(day = 3, year = 2023, "Gear Ratios") {
override fun part1(): Int {
val matrix = input.map { "$it.".toList() }
var sum = 0
for (i in matrix.indices) {
var numberStr = ""
var numberStrAdja... | 0 | Kotlin | 0 | 0 | b5280f3592ba3a0fbe04da72d4b77fcc9754597e | 4,595 | advent-of-code | Apache License 2.0 |
src/main/kotlin/thesis/preprocess/types/extensions.kt | danilkolikov | 123,672,959 | false | null | package thesis.preprocess.types
import thesis.preprocess.expressions.TypeName
import thesis.preprocess.expressions.algebraic.term.AlgebraicEquation
import thesis.preprocess.expressions.algebraic.term.AlgebraicTerm
import thesis.preprocess.expressions.type.raw.RawType
import thesis.utils.Edge
import thesis.utils.Undire... | 0 | Kotlin | 0 | 2 | 0f5ad2d9fdd1f03d3bf62255da14b05e4e0289e1 | 4,312 | fnn | MIT License |
src/day10/Day10.kt | jorgensta | 573,824,365 | false | {"Kotlin": 31676} | class CPU() {
val sprite = Sprite()
var shift = 0
var cycles = 0
var X = 1
val values = mutableListOf<Int>()
fun doTick() {
cycles++
checkForMod20()
sprite.draw(cycles, X+shift)
}
private fun checkForMod20() {
if(cycles.mod(40) == 20) {
value... | 0 | Kotlin | 0 | 0 | 7243e32351a926c3a269f1e37c1689dfaf9484de | 2,179 | AoC2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem433/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem433
/**
* LeetCode page: [433. Minimum Genetic Mutation](https://leetcode.com/problems/minimum-genetic-mutation/);
*/
class Solution {
/* Complexity:
* Time O(N^2) and Space O(N) where N is the size of bank;
*/
fun minMutation(start: String, end: String, bank: ... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,976 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2015/AntSue.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2015
import komu.adventofcode.utils.nonEmptyLines
fun antSue1(input: String): Int =
Sue.parseAll(input).find { it.matchesKnown() }?.number ?: error("no match")
fun antSue2(input: String): Int =
Sue.parseAll(input).find { it.matchesKnown2() }?.number ?: error("no match")
private ... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,026 | advent-of-code | MIT License |
src/main/kotlin/g1501_1600/s1569_number_of_ways_to_reorder_array_to_get_same_bst/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1569_number_of_ways_to_reorder_array_to_get_same_bst
// #Hard #Array #Dynamic_Programming #Math #Tree #Binary_Tree #Union_Find #Binary_Search_Tree
// #Divide_and_Conquer #Memoization #Combinatorics
// #2023_06_14_Time_256_ms_(100.00%)_Space_38.1_MB_(100.00%)
class Solution {
fun numOfWays(nums... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,907 | LeetCode-in-Kotlin | MIT License |
src/Day20.kt | jvmusin | 572,685,421 | false | {"Kotlin": 86453} | import java.util.*
import kotlin.math.abs
import kotlin.math.sign
import kotlin.random.Random
import kotlin.random.nextInt
fun main() {
fun part1(input: List<String>): Int {
val list = input.mapIndexed { index, s -> s.toInt() to index }.toMutableList()
for (i in list.indices) {
var pos ... | 1 | Kotlin | 0 | 0 | 4dd83724103617aa0e77eb145744bc3e8c988959 | 3,941 | advent-of-code-2022 | Apache License 2.0 |
src/Day05_1.kt | ozzush | 579,610,908 | false | {"Kotlin": 5111} |
// [P] [Q] [T]
// [F] [N] [P] [L] [M]
// [H] [T] [H] [M] [H] [Z]
// [M] [C] [P] [Q] [R] [C] [J]
// [T] [J] [M] [F] [L] [G] [R] [Q]
// [V] [G] [D] [V] [G] [D] [N] [W] [L]
// [L] [Q] [S] [B] [H] [B] [M] [L] [D]
// [D] [H] [R] [L] [N] [W] [G] [C] [R]
// 1 ... | 0 | Kotlin | 0 | 0 | 9b29a13833659f86d3791b5c07f9decb0dcee475 | 1,218 | AdventOfCode2022 | Apache License 2.0 |
Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/kotlin/masdos.kt | mouredev | 581,049,695 | false | {"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ... | import kotlin.math.abs
fun main() {
/*
* Escribe un programa que muestre cómo transcurre un juego de tenis y quién lo ha ganado.
* El programa recibirá una secuencia formada por "P1" (Player 1) o "P2" (Player 2), según quien
* gane cada punto del juego.
*
* - Las puntuaciones de un juego son "Love" (c... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 2,097 | retos-programacion-2023 | Apache License 2.0 |
foreach/src/main0.kt | XinyueZ | 96,028,554 | false | null | import java.util.stream.Collectors
import java.util.stream.IntStream
import java.util.stream.Stream
fun main(args: Array<String>) {
println("Examples foreach, list, array, collection ....")
println()
val list1 = listOf("one", "two", "three")
foreachList(list1)
val list2 = list1 + listOf("four", "f... | 0 | Kotlin | 0 | 0 | 3ec03f258621f32a5d134f04075e00ec95151576 | 3,384 | lambda-world | MIT License |
src/Day04.kt | holukent | 573,489,120 | false | {"Kotlin": 5111} | import java.io.File
fun main() {
fun part1(input: String): Int {
val data = input.split("\r\n")
var result = 0
for (d in data) {
val temp = d.split(",").map { it.split("-") }
val first = temp[0]
val second = temp[1]
if (
(firs... | 0 | Kotlin | 0 | 0 | 6993a6f0f20c226772a16f3b60217f1f0f025ddf | 1,411 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/advent2019/day6/day6.kt | davidpricedev | 225,621,794 | false | null | package advent2019.day6
import advent2019.util.memoize
fun main() {
val inputAsMap = inputToMap(getInput())
runPart1(inputAsMap)
runPart2(inputAsMap)
}
fun runPart1(inputAsMap: Map<String, String>) {
println(countAllAncestors(inputAsMap))
}
fun runPart2(inputAsMap: Map<String, String>) {
println... | 0 | Kotlin | 0 | 0 | 2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9 | 14,665 | adventOfCode2019 | Apache License 2.0 |
src/main/kotlin/com/github/davio/aoc/y2023/Day1.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2023
import com.github.davio.aoc.general.Day
import com.github.davio.aoc.general.getInputAsList
/**
* See [Advent of Code 2023 Day 1](https://adventofcode.com/2023/day/1#part2])
*/
class Day1(exampleNumber: Int? = null) : Day(exampleNumber) {
override fun part1() =
getInpu... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 1,604 | advent-of-code | MIT License |
src/test/kotlin/com/igorwojda/list/medianoftwosorted/Solution.kt | igorwojda | 159,511,104 | false | {"Kotlin": 254856} | package com.igorwojda.list.medianoftwosorted
// Time complexity: O(log (m+n))
private object Solution1 {
fun medianOfSortedLists(list1: List<Int>, list2: List<Int>): Double {
val totalSize = list1.size + list2.size
val lastIndex = (totalSize / 2)
var prevValue: Int? = null
var poi... | 9 | Kotlin | 225 | 895 | b09b738846e9f30ad2e9716e4e1401e2724aeaec | 2,170 | kotlin-coding-challenges | MIT License |
src/day10/Day10.kt | idle-code | 572,642,410 | false | {"Kotlin": 79612} | package day10
import logEnabled
import logln
import readInput
private const val DAY_NUMBER = 10
private const val SCREEN_WIDTH = 40
data class Operation(val opcode: String, val cost: Int, val arg: Int? = null)
class Simulator {
private var registerX = 1
private var currentCycle = 0
val watchValues = ... | 0 | Kotlin | 0 | 0 | 1b261c399a0a84c333cf16f1031b4b1f18b651c7 | 3,717 | advent-of-code-2022 | Apache License 2.0 |
solutions/src/FourSum.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | class FourSum {
fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
return NSum(nums,target,4).map { it.sorted() }.distinct()
}
private fun NSum(nums: IntArray, target: Int, N: Int): List<List<Int>> {
if (N == 2) {
return twoSum(nums, target)
}
else {
... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,310 | leetcode-solutions | MIT License |
advent/src/test/kotlin/org/elwaxoro/advent/y2021/Dec24.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2021
import org.elwaxoro.advent.PuzzleDayTester
/**
* Arithmetic Logic Unit
*/
class Dec24 : PuzzleDayTester(24, 2021) {
override fun part1(): Any = monaderator(isMax = true)
override fun part2(): Any = monaderator(isMax = false)
/**
* Can treat this whole program as ... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 3,052 | advent-of-code | MIT License |
05.kts | pin2t | 725,922,444 | false | {"Kotlin": 48856, "Go": 48364, "Shell": 54} | import java.util.*
val scanner = Scanner(System.`in`)
val mappings = ArrayList<List<Pair<LongRange, Long>>>()
val seeds = ArrayList<Long>()
val number = Regex("\\d+")
while (scanner.hasNext()) {
val line = scanner.nextLine()
if (line.startsWith("seeds:")) {
seeds.addAll(number.findAll(line).map { it.va... | 0 | Kotlin | 1 | 0 | 7575ab03cdadcd581acabd0b603a6f999119bbb6 | 2,428 | aoc2023 | MIT License |
2021/src/test/kotlin/Day17.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import kotlin.math.abs
import kotlin.test.Test
import kotlin.test.assertEquals
class Day17 {
data class Coord(val x: Int, val y: Int)
data class Step(val position: Coord, val velocity: Coord)
@Test
fun `run part 01`() {
val area = getArea()
val maxY = (area.getMinInitialVelocityX()..a... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 2,736 | adventofcode | MIT License |
src/Day03.kt | casslabath | 573,177,204 | false | {"Kotlin": 27085} | import java.util.*
fun main() {
fun initPriorityMap(): Map<Char, Int> {
val lower = "abcdefghijklmnopqrstuvwxyz"
val upper = lower.uppercase(Locale.getDefault())
val map: MutableMap<Char, Int> = mutableMapOf()
var count = 1
for(letter in lower.toCharArray()) {
m... | 0 | Kotlin | 0 | 0 | 5f7305e45f41a6893b6e12c8d92db7607723425e | 1,746 | KotlinAdvent2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.