path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/Day11.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.nio.charset.Charset
import kotlin.streams.toList
fun main() {
val testDocs = File("test/day11").readLines(Charset.defaultCharset())
val puzzles = File("puzzles/day11").readLines(Charset.defaultCharset())
fun process(text: List<String>, tolerance: Int) : Int {
val i... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 4,492 | aoc2020 | Apache License 2.0 |
src/main/kotlin/problems/Day11.kt | PedroDiogo | 432,836,814 | false | {"Kotlin": 128203} | package problems
class Day11(override val input: String) : Problem {
override val number: Int = 11
override fun runPartOne(): String {
val currentBoard = Board.fromStr(input)
var flashes = 0
repeat(100) {
flashes += currentBoard.runStep()
}
return flashes.to... | 0 | Kotlin | 0 | 0 | 93363faee195d5ef90344a4fb74646d2d26176de | 2,789 | AdventOfCode2021 | MIT License |
leetcode/src/main/kotlin/AtoiSolution.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | /**
* This was in 2020...
*
* [LeetCode](https://leetcode.com/problems/string-to-integer-atoi/)
*/
class AtoiSolution {
fun myAtoi(str: String): Int {
val numberStr =
str.trim().dropWhile { !it.isDigit() }.takeWhile { it.isDigit() }.dropWhile { it == '0' }
if (numberStr.isEmpty()) return 0
val... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 1,182 | advent-of-code | MIT License |
src/main/kotlin/Utils.kt | hughjdavey | 317,575,435 | false | null | import java.util.Stack
import kotlin.math.abs
fun <T> List<T>.allPairs(): List<Pair<T, T>> = this.flatMap { i -> this.map { j -> Pair(i, j) } }
fun <T> List<T>.allTriples(): List<Triple<T, T, T>> = this.flatMap { i -> this.flatMap { j -> this.map { k -> Triple(i, j, k) } } }
fun Pair<Int, Int>.add() = this.first + ... | 0 | Kotlin | 0 | 1 | 63c677854083fcce2d7cb30ed012d6acf38f3169 | 3,489 | aoc-2020 | Creative Commons Zero v1.0 Universal |
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day12.kt | loehnertz | 573,145,141 | false | {"Kotlin": 53239} | package codes.jakob.aoc
import codes.jakob.aoc.shared.Grid
import codes.jakob.aoc.shared.parseGrid
import java.util.*
import java.util.Comparator.comparing
class Day12 : Solution() {
override fun solvePart1(input: String): Any {
val grid: Grid<Elevation> = input.parseGrid { Elevation(it) }
val sta... | 0 | Kotlin | 0 | 0 | ddad8456dc697c0ca67255a26c34c1a004ac5039 | 1,881 | advent-of-code-2022 | MIT License |
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day20.kt | mpichler94 | 656,873,940 | false | {"Kotlin": 196457} | package at.mpichler.aoc.solutions.year2022
import at.mpichler.aoc.lib.Day
import at.mpichler.aoc.lib.PartSolution
import java.util.*
import kotlin.collections.ArrayDeque
open class Part20A : PartSolution() {
lateinit var numbers: ArrayDeque<Pair<Long, Int>>
var zeroIdx = 0
override fun parseInput(text: S... | 0 | Kotlin | 0 | 0 | 69a0748ed640cf80301d8d93f25fb23cc367819c | 3,079 | advent-of-code-kotlin | MIT License |
src/main/kotlin/days/Day5.kt | butnotstupid | 433,717,137 | false | {"Kotlin": 55124} | package days
class Day5 : Day(5) {
override fun partOne(): Any {
val regex = """(\d+),(\d+) -> (\d+),(\d+)""".toRegex()
val lines = inputList.map {
regex.find(it)!!.groupValues.drop(1).map { it.toInt() }
.let { (x1, y1, x2, y2) -> Line(x1, y1, x2, y2) }
}
... | 0 | Kotlin | 0 | 0 | a06eaaff7e7c33df58157d8f29236675f9aa7b64 | 2,245 | aoc-2021 | Creative Commons Zero v1.0 Universal |
src/day22/day.kt | LostMekka | 574,697,945 | false | {"Kotlin": 92218} | package day22
import day22.Tile.*
import util.Direction2NonDiagonal
import util.Grid
import util.Point
import util.minus
import util.mutate
import util.pathSequence
import util.plus
import util.readInput
import util.shouldBe
import util.toGrid
import java.util.LinkedList
fun main() {
val testInput = readInput(Inp... | 0 | Kotlin | 0 | 0 | 58d92387825cf6b3d6b7567a9e6578684963b578 | 5,788 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2016/Day02.kt | tginsberg | 74,924,040 | false | null | /*
* Copyright (c) 2016 by <NAME>
*/
package com.ginsberg.advent2016
import com.ginsberg.advent2016.utils.toHex
/**
* Advent of Code - Day 2: December 2, 2016
*
* From http://adventofcode.com/2016/day/2
*
*/
class Day02(val instructions: List<String>, val startingPoint: Int = 5) {
/**
* Keypad like ... | 0 | Kotlin | 0 | 3 | a486b60e1c0f76242b95dd37b51dfa1d50e6b321 | 2,397 | advent-2016-kotlin | MIT License |
src/main/kotlin/solutions/day02/Day2.kt | Dr-Horv | 570,666,285 | false | {"Kotlin": 115643} | package solutions.day02
import solutions.Solver
enum class Moves {
ROCK,
PAPER,
SCISSORS
}
enum class Outcome {
DRAW,
LOST,
WON
}
class Day2 : Solver {
private fun roundScore(input: String, partTwo: Boolean): Int {
val moves = input.split(" ")
val opponentMove = when (mo... | 0 | Kotlin | 0 | 2 | 6c9b24de2fe2a36346cb4c311c7a5e80bf505f9e | 2,762 | Advent-of-Code-2022 | MIT License |
src/main/kotlin/com/nibado/projects/advent/y2021/Day04.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2021
import com.nibado.projects.advent.*
object Day04 : Day {
private val values = resourceLines(2021, 4)
private val numbers = values.first().split(',').map { it.toInt() }
private val boards = values.asSequence().drop(1).filterNot { it.trim().isBlank() }.chunked(5) {
... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,504 | adventofcode | MIT License |
advent-of-code-2021/src/main/kotlin/Day13.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | //Day 13: Transparent Origami
//https://adventofcode.com/2021/day/13
import java.io.File
fun main() {
val dots = mutableListOf<Pair<Int, Int>>()
val folds = mutableListOf<Fold>()
val lines = File("src/main/resources/Day13.txt").readLines()
lines.forEach {
if (it.startsWith("fold")) {
... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 2,443 | advent-of-code | Apache License 2.0 |
src/aoc2023/Day17.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
import java.util.PriorityQueue
fun main() {
fun somePathHeatLoss(map: Array<Array<Int>>): Int {
return (1 until map.size).sumOf { map[it - 1][it] + map[it][it] }
}
data class Point(val x: Int, val y: Int)
data class Move(val direction: Char, val point: Point,... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 6,451 | advent-of-code-kotlin | Apache License 2.0 |
src/Day11.kt | mr-cell | 575,589,839 | false | {"Kotlin": 17585} | import kotlin.math.floor
fun main() {
fun part1(input: List<String>): Long {
val monkeys = input.toMonkeys()
repeat(20) {
monkeys.forEach { monkey ->
val transfers = monkey.inspectItems()
transfers.forEach { transfer -> monkeys[transfer.first].addItem(tr... | 0 | Kotlin | 0 | 0 | 2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9 | 3,030 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | GunnarBernsteinHH | 737,845,880 | false | {"Kotlin": 10952} | /*
* --- Day 3: Gear Ratios ---
* Source: https://adventofcode.com/2023/day/3
*/
/** main function containing sub-functions like a class */
fun main() {
data class NumberData(
val value: Int,
val start: Int,
val endExclusive: Int,
var isAdjacent: Boolean = false
)
class L... | 0 | Kotlin | 0 | 0 | bc66eef73bca2e64dfa5d83670266c8aaeae5b24 | 5,198 | aoc-2023-in-kotlin | MIT License |
src/main/kotlin/dev/sirch/aoc/y2022/days/Day02.kt | kristofferchr | 573,549,785 | false | {"Kotlin": 28399, "Mustache": 1231} | package dev.sirch.aoc.y2022.days
import dev.sirch.aoc.Day
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
class Day02(testing: Boolean = false): Day(2022, 2, testing) {
override fun part1(): Int {
return inputLines.sumOf {
val foe = Shape.from(it.first())
v... | 0 | Kotlin | 0 | 0 | 867e19b0876a901228803215bed8e146d67dba3f | 2,663 | advent-of-code-kotlin | Apache License 2.0 |
src/com/ncorti/aoc2022/Day05.kt | cortinico | 571,724,497 | false | {"Kotlin": 5773} | package com.ncorti.aoc2022
import java.util.*
private fun String.processInput(): Pair<List<Stack<Char>>, List<List<Int>>> {
val (stackDefs, moveDefs) = split("\n\n")
val stacks = mutableListOf<Stack<Char>>()
val stackLines = stackDefs.split("\n")
stackLines.last().split(" ").filter(String::isNotBlank).forEach... | 4 | Kotlin | 0 | 1 | cd9ad108a1ed1ea08f9313c4cad5e52a200a5951 | 1,609 | adventofcode-2022 | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[674]最长连续递增序列.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个未经排序的整数数组,找到最长且 连续递增的子序列,并返回该序列的长度。
//
// 连续递增的子序列 可以由两个下标 l 和 r(l < r)确定,如果对于每个 l <= i < r,都有 nums[i] < nums[i + 1] ,那
//么子序列 [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] 就是连续递增子序列。
//
//
//
// 示例 1:
//
//
//输入:nums = [1,3,5,4,7]
//输出:3
//解释:最长连续递增序列是 [1,3,5], 长度为3。
//尽管 [1,3,5,7] 也是升序的子序列, 但它不是连续的,因为 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,590 | MyLeetCode | Apache License 2.0 |
src/main/kotlin/wtf/log/xmas2021/day/day02/Day02.kt | damianw | 434,043,459 | false | {"Kotlin": 62890} | package wtf.log.xmas2021.day.day02
import wtf.log.xmas2021.Day
import java.io.BufferedReader
object Day02 : Day<List<Instruction>, Int, Int> {
override fun parseInput(reader: BufferedReader): List<Instruction> = reader
.lineSequence()
.map(Instruction::parse)
.toList()
override fun p... | 0 | Kotlin | 0 | 0 | 1c4c12546ea3de0e7298c2771dc93e578f11a9c6 | 2,292 | AdventOfKotlin2021 | BSD Source Code Attribution |
scripts/profiling/CompareCSVs.kts | TIBHannover | 197,416,205 | false | {"Kotlin": 3096016, "Cypher": 217169, "Python": 4881, "Groovy": 1936, "Shell": 1803, "HTML": 240} | #!/usr/bin/env kscript
import java.io.File
val fileA = args.getOrElse(0) { "before.csv" }
val fileB = args.getOrElse(1) { "after.csv" }
val mapA = readCSV(fileA)
val mapB = readCSV(fileB)
var totalTimeA: Long = 0
var totalTimeB: Long = 0
var totalMethodCount = 0
println("Comparing $fileA (A) to $fileB (B)")
(mapA... | 0 | Kotlin | 1 | 4 | bcc5b31678df9610bb2128dd14fd5fe34461eea8 | 2,916 | orkg-backend | MIT License |
src/day02/Day02.kt | maxmil | 578,287,889 | false | {"Kotlin": 32792} | package day02
import println
import readInput
data class Position(val aim: Int = 0, val depth: Int = 0, val position: Int = 0)
fun main() {
fun part1(input: List<String>): Int = input.map { line -> line.split(" ") }
.fold(Position()) { acc, next ->
when (next[0]) {
"forward" ... | 0 | Kotlin | 0 | 0 | 246353788b1259ba11321d2b8079c044af2e211a | 1,490 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/endredeak/aoc2022/Day15.kt | edeak | 571,891,076 | false | {"Kotlin": 44975} | package endredeak.aoc2022
import kotlin.math.abs
fun main() {
solve("Beacon Exclusion Zone") {
fun Pair<Int, Int>.manhattanRange(m: Int): Pair<IntRange, IntRange> =
(this.first - m..this.first + m) to (this.second - m..this.second + m)
infix fun Pair<Int, Int>.manhattan(other: Pair<I... | 0 | Kotlin | 0 | 0 | e0b95e35c98b15d2b479b28f8548d8c8ac457e3a | 1,842 | AdventOfCode2022 | Do What The F*ck You Want To Public License |
src/main/kotlin/com/ginsberg/advent2022/Day05.kt | tginsberg | 568,158,721 | false | {"Kotlin": 113322} | /*
* Copyright (c) 2022 by <NAME>
*/
/**
* Advent of Code 2022, Day 5 - Supply Stacks
* Problem Description: http://adventofcode.com/2022/day/5
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day5/
*/
package com.ginsberg.advent2022
class Day05(input: List<String>) {
private val ... | 0 | Kotlin | 2 | 26 | 2cd87bdb95b431e2c358ffaac65b472ab756515e | 1,909 | advent-2022-kotlin | Apache License 2.0 |
src/main/kotlin/graph/variation/NumShortestPaths.kt | yx-z | 106,589,674 | false | null | package graph.variation
import graph.core.*
import util.OneArray
import java.util.*
import kotlin.collections.HashMap
// given # of shortest paths (that should have equal length) in a graph G = (V, E)
// starting with vertex v in V
fun <V> WeightedGraph<V, Int>.numShortestPaths(s: Vertex<V>,
... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,399 | AlgoKt | MIT License |
src/day09/solution.kt | bohdandan | 729,357,703 | false | {"Kotlin": 80367} | package day09
import println
import readInput
fun main() {
fun diffList(numbers: List<Long>): List<Long> {
return (0..<(numbers.size-1)).map {
numbers[it + 1] - numbers[it]
}.toList()
}
fun extrapolateLine(numbers: List<Long>): Long {
var diffs = diffList(numbers)
... | 0 | Kotlin | 0 | 0 | 92735c19035b87af79aba57ce5fae5d96dde3788 | 1,050 | advent-of-code-2023 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimizeMax.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,978 | kotlab | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2021/Day8.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2021
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.report
import java.util.BitSet
class Day8 : AdventDay(2021, 8) {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val day = Day8()
report {
day.part1... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 5,481 | adventofcode | MIT License |
src/main/kotlin/com/ginsberg/advent2020/Day22.kt | tginsberg | 315,060,137 | false | null | /*
* Copyright (c) 2020 by <NAME>
*/
/**
* Advent of Code 2020, Day 22 - Crab Combat
* Problem Description: http://adventofcode.com/2020/day/22
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day22/
*/
package com.ginsberg.advent2020
import java.util.Objects
typealias Deck = MutableL... | 0 | Kotlin | 2 | 38 | 75766e961f3c18c5e392b4c32bc9a935c3e6862b | 2,098 | advent-2020-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/NamingCompany.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,764 | kotlab | Apache License 2.0 |
04/04.kt | Steve2608 | 433,779,296 | false | {"Python": 34592, "Julia": 13999, "Kotlin": 11412, "Shell": 349, "Cython": 211} | import java.io.File
private class Bingo(board: List<String>) {
val numbers: Array<IntArray>
val marked: Array<BooleanArray>
val calledNumbers: MutableList<Int> = mutableListOf(-1)
init {
fun getLine(board: List<String>, line: Int) =
board[line].split("\\s+".toRegex()).filter { it.isNotBlank() }.map { it.toIn... | 0 | Python | 0 | 1 | 2dcad5ecdce5e166eb053593d40b40d3e8e3f9b6 | 2,591 | AoC-2021 | MIT License |
src/main/kotlin/ru/timakden/aoc/year2022/Day14.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2022
import ru.timakden.aoc.util.Point
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
import kotlin.math.max
import kotlin.math.min
/**
* [Day 14: Regolith Reservoir](https://adventofcode.com/2022/day/14).
*/
object Day14 {
@JvmStatic
fun main(args: Arr... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 3,502 | advent-of-code | MIT License |
java/app/src/main/kotlin/com/github/ggalmazor/aoc2021/day22/Cuboid.kt | ggalmazor | 434,148,320 | false | {"JavaScript": 80092, "Java": 33594, "Kotlin": 14508, "C++": 3077, "CMake": 119} | package com.github.ggalmazor.aoc2021.day22
data class Cuboid(val xx: IntRange, val yy: IntRange, val zz: IntRange) {
fun within(other: Cuboid): Boolean = other.xx.contains(xx.first) && other.xx.contains(xx.last)
&& other.yy.contains(yy.first) && other.yy.contains(yy.last)
&& other.zz.contai... | 0 | JavaScript | 0 | 0 | 7a7ec831ca89de3f19d78f006fe95590cc533836 | 2,005 | aoc2021 | Apache License 2.0 |
src/main/kotlin/com/github/freekdb/aoc2019/Day08.kt | FreekDB | 228,241,398 | false | null | package com.github.freekdb.aoc2019
import java.io.File
// https://adventofcode.com/2019/day/8
fun main() {
val input = File("input/day-08--input.txt").readLines()[0]
println("Input length: ${input.length}.")
println("15000 == 9925 + 2524 + 2551 = ${9925 + 2524 + 2551}")
val width = 25
val height... | 0 | Kotlin | 0 | 1 | fd67b87608bcbb5299d6549b3eb5fb665d66e6b5 | 2,103 | advent-of-code-2019 | Apache License 2.0 |
src/main/day3/Day03.kt | Derek52 | 572,850,008 | false | {"Kotlin": 22102} | package main.day3
import main.readInput
val priorityMap = HashMap<Char, Int>()
fun main() {
val input = readInput("day3/day3")
var count = 1
val alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (letter in alphabet) {
priorityMap[letter] = count
count++
}
... | 0 | Kotlin | 0 | 0 | c11d16f34589117f290e2b9e85f307665952ea76 | 1,976 | 2022AdventOfCodeKotlin | Apache License 2.0 |
src/main/kotlin/eu/qiou/aaf4k/util/algorithm/Algorithm.kt | 6234456 | 191,817,083 | false | null | package eu.qiou.aaf4k.util.algorithm
import eu.qiou.aaf4k.util.mkString
import java.math.BigInteger
import kotlin.math.roundToInt
import kotlin.random.Random
object Algorithm {
val PRIMES = mutableListOf(2L, 3L, 5L, 7L, 11L, 13L, 17L, 19L, 23L)
private val CHECK_IF_GT = 100_000L
fun sequentialIsPrime(n... | 2 | Kotlin | 0 | 0 | dcd0ef0bad007e37a08ce5a05af52990c9d904e0 | 10,506 | aaf4k-base | MIT License |
src/main/day11/Part1.kt | ollehagner | 572,141,655 | false | {"Kotlin": 80353} | package day11
import infiniteInts
import readInput
import java.lang.IllegalArgumentException
import java.util.*
import kotlin.math.floor
fun main() {
val monkeys = parseInput(readInput("day11/testinput.txt"))
infiniteInts(1)
.take(20)
.forEach { round ->
monkeys.forEach { monkey ->... | 0 | Kotlin | 0 | 0 | 6e12af1ff2609f6ef5b1bfb2a970d0e1aec578a1 | 2,679 | aoc2022 | Apache License 2.0 |
src/Day08.kt | AxelUser | 572,845,434 | false | {"Kotlin": 29744} | data class Input(
val rows: Array<Array<MutableList<Int>>>,
val cols: Array<Array<MutableList<Int>>>,
val map: Array<IntArray>
)
fun main() {
fun List<String>.parse(): Input {
val rows = Array(size) { Array(10) { mutableListOf<Int>() } }
val cols = Array(this[0].length) { Array(10) { m... | 0 | Kotlin | 0 | 1 | 042e559f80b33694afba08b8de320a7072e18c4e | 3,234 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/learn/sudoku/Sudoku.kt | asher-stern | 193,098,718 | false | null | package com.learn.sudoku
import java.io.File
typealias Board = Array<Array<Int?>> // Row first. For example, b[1][3] means second row forth column.
fun main(args: Array<String>)
{
val board = Sudoku.read(args[0])
println(Sudoku.print(board))
println((1..11).joinToString("") { "=" } )
if(!Sudoku.solv... | 0 | Kotlin | 0 | 0 | 73ee63a2dcb749a72e3f6e01a21b62974b2dd24e | 3,647 | sudoku | MIT License |
src/day17/Code.kt | fcolasuonno | 225,219,560 | false | null | package day17
import IntCode
import IntCodeComputer
import isDebug
import java.io.File
private fun Pair<Int, Int>.neighbours() = listOf(
copy(first = first - 1),
copy(first = first + 1),
copy(second = second - 1),
copy(second = second + 1)
)
fun main() {
val name = if (isDebug()) "test.txt" else ... | 0 | Kotlin | 0 | 0 | d1a5bfbbc85716d0a331792b59cdd75389cf379f | 4,673 | AOC2019 | MIT License |
src/main/kotlin/tr/emreone/adventofcode/days/Day09.kt | EmRe-One | 433,772,813 | false | {"Kotlin": 118159} | package tr.emreone.adventofcode.days
import tr.emreone.kotlin_utils.automation.Day
import tr.emreone.kotlin_utils.math.Coords
class Day09 : Day(9, 2021, "Smoke Basin") {
class Grid(var input: List<String>) {
private val grid = mutableMapOf<Coords, Int>()
private val width = input.first().length
... | 0 | Kotlin | 0 | 0 | 516718bd31fbf00693752c1eabdfcf3fe2ce903c | 3,715 | advent-of-code-2021 | Apache License 2.0 |
src/day11/Day11.kt | ZsemberiDaniel | 159,921,870 | false | null | package day11
import RunnablePuzzleSolver
import java.lang.Integer.min
class Day11 : RunnablePuzzleSolver {
val gridSerialNumber = 7347
val cells = Array(301) { Array(301) { 0 } }
val cellSums = Array(301) { Array(301) { 0 } }
override fun readInput1(lines: Array<String>) { }
override fun readI... | 0 | Kotlin | 0 | 0 | bf34b93aff7f2561f25fa6bd60b7c2c2356b16ed | 2,660 | adventOfCode2018 | MIT License |
src/main/kotlin/07/07.kt | Wrent | 225,133,563 | false | null | import java.lang.IllegalStateException
import java.math.BigInteger
import java.util.*
fun main() {
var permutations = getPermutations(listOf(0L, 1L, 2L, 3L, 4L).map { it.toBigInteger() }.toTypedArray())
var max = BigInteger.ZERO
permutations.forEach {
val res = evaluateAmplifier(it[0], evaluateAmp... | 0 | Kotlin | 0 | 0 | 0a783ed8b137c31cd0ce2e56e451c6777465af5d | 5,279 | advent-of-code-2019 | MIT License |
src/Day04.kt | sd2000usr | 573,123,353 | false | {"Kotlin": 21846} |
fun main()
{
fun part1(input: List<String>)
{
var overlappingCount = 0
input.forEach ()
{ line ->
println("line: $line")
val split = line.split(',')
val (elfWithRange0Raw, elfWithRange1Raw) = split
val elfRangeSplit0 = elfWithRange0... | 0 | Kotlin | 0 | 0 | fe5307af5dd8620ae8dee0ad5244466b5332e535 | 3,223 | cfgtvsizedxr8jubhy | Apache License 2.0 |
kotlin/2021/round-1c/roaring-years/src/main/kotlin/Solution.kt | ShreckYe | 345,946,821 | false | null | /*
import kotlin.math.floor
import kotlin.math.log10
fun main() {
val t = readLine()!!.toInt()
repeat(t, ::testCase)
}
fun testCase(ti: Int) {
val y = readLine()!!
val ansY = ans(y)
println("Case #${ti + 1}: $ansY")
}
fun ans(y: String): Long {
val yLong = y.toLong()
return (1..y.length... | 0 | Kotlin | 1 | 1 | 743540a46ec157a6f2ddb4de806a69e5126f10ad | 1,645 | google-code-jam | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ThreeSum.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,735 | kotlab | Apache License 2.0 |
src/Day03.kt | D000L | 575,350,411 | false | {"Kotlin": 23716} | fun main() {
fun part1(input: List<String>): Int {
return input.map {
val halfSize = it.length / 2
val wordA = it.subSequence(0,halfSize)
val wordB = it.subSequence(halfSize,it.length)
wordA.toSet().intersect(wordB.toSet()).first()
}.sumOf {
... | 0 | Kotlin | 0 | 0 | b733a4f16ebc7b71af5b08b947ae46afb62df05e | 745 | adventOfCode | Apache License 2.0 |
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec03.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2020
import org.elwaxoro.advent.PuzzleDayTester
class Dec03 : PuzzleDayTester(3, 2020) {
override fun part1(): Any = countTrees(parseInput(), 3, 1)
override fun part2(): Any = DOTHEDEW(parseInput())
private fun DOTHEDEW(rows: List<List<Int>>) =
listOf(
1... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 1,422 | advent-of-code | MIT License |
src/Day04.kt | A55enz10 | 573,364,112 | false | {"Kotlin": 15119} | fun main() {
fun part1(input: List<String>): Int {
return input.map {it.split(",","-")}
.map{elem -> elem.map{it.toInt()}}
.filter {elvesRange -> (elvesRange[0] >= elvesRange[2] && elvesRange[1] <= elvesRange[3])
|| (elvesRange[0] <= elvesRange[2] && elvesRange[1... | 0 | Kotlin | 0 | 1 | 8627efc194d281a0e9c328eb6e0b5f401b759c6c | 1,001 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2021/Day2.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2021
import com.chriswk.aoc.AdventDay
import com.chriswk.aoc.util.report
class Day2: AdventDay(2021, 2) {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val day = Day2()
report {
day.part1()
}
... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 2,749 | adventofcode | MIT License |
src/Day15.kt | fmborghino | 573,233,162 | false | {"Kotlin": 60805} | import kotlin.math.abs
fun main() {
fun log(message: Any?) {
println(message)
}
data class Vec2(val x: Int, val y: Int)
data class Node(val c: Char, val beacon: Vec2? = null, val manhattan: Int? = null)
class Grid(val grid: MutableMap<Vec2, Node>, val rangeX: Pair<Int, Int>, val rangeY: Pa... | 0 | Kotlin | 0 | 0 | 893cab0651ca0bb3bc8108ec31974654600d2bf1 | 5,452 | aoc2022 | Apache License 2.0 |
src/test/kotlin/nl/dirkgroot/adventofcode/year2022/Day19Test.kt | dirkgroot | 317,968,017 | false | {"Kotlin": 187862} | package nl.dirkgroot.adventofcode.year2022
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import nl.dirkgroot.adventofcode.util.input
import nl.dirkgroot.adventofcode.util.invokedWith
import kotlin.math.ceil
import kotlin.math.max
private fun solution1(input: String) = parseBlueprints(... | 1 | Kotlin | 1 | 1 | ffdffedc8659aa3deea3216d6a9a1fd4e02ec128 | 6,152 | adventofcode-kotlin | MIT License |
src/main/kotlin/recur/QuickSelect.kt | yx-z | 106,589,674 | false | null | package recur
import util.OneArray
import util.get
import util.swap
// given an unsorted array, A[1..n], find the k-th smallest element
fun main(args: Array<String>) {
val arr = OneArray(100) { it * 10 }
println(arr.quickSelect(30))
println(arr.momSelect(30))
}
// here we partition based on pivot index 1
// find ... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,896 | AlgoKt | MIT License |
src/Day20.kt | kenyee | 573,186,108 | false | {"Kotlin": 57550} | fun Array<Int>.indexPos(signedPos: Int): Int {
return if (signedPos < 0) (this.size - 1 + (signedPos).rem(this.lastIndex)) else signedPos.rem(this.size)
}
fun main() { // ktlint-disable filename
fun part1(input: List<String>): Int {
val moves = input.map { it.toInt() }
val numbers = moves.toTyp... | 0 | Kotlin | 0 | 0 | 814f08b314ae0cbf8e5ae842a8ba82ca2171809d | 1,502 | KotlinAdventOfCode2022 | Apache License 2.0 |
src/Day15.kt | spaikmos | 573,196,976 | false | {"Kotlin": 83036} | fun main() {
fun parseInput(input: List<String>): MutableSet<Pair<Pair<Int, Int>, Pair<Int, Int>>> {
val s = mutableSetOf<Pair<Pair<Int, Int>, Pair<Int, Int>>>()
for (i in input) {
val regex = """Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at x=(-?\d+), y=(-?\d+)""".toRegex()
... | 0 | Kotlin | 0 | 0 | 6fee01bbab667f004c86024164c2acbb11566460 | 3,663 | aoc-2022 | Apache License 2.0 |
src/Day10.kt | Cryosleeper | 572,977,188 | false | {"Kotlin": 43613} | import kotlin.math.abs
private const val SCREEN_WIDTH = 40
fun main() {
fun part1(input: List<String>): Int {
var registerX = 1
var currentCycle = 1
val valuesToSave = mutableMapOf<Int, Int?>(
20 to null,
60 to null,
100 to null,
140 to null,... | 0 | Kotlin | 0 | 0 | a638356cda864b9e1799d72fa07d3482a5f2128e | 2,605 | aoc-2022 | Apache License 2.0 |
advent-of-code2016/src/main/kotlin/day10/Advent10.kt | REDNBLACK | 128,669,137 | false | null | package day10
import array2d
import day08.Operation.Type.*
import day10.Operation.Direction
import day10.Operation.Direction.BOT
import day10.Operation.Direction.OUTPUT
import day10.Operation.Target
import day10.Operation.Type.HIGH
import day10.Operation.Type.LOW
import mul
import parseInput
import splitToLines
import... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 5,985 | courses | MIT License |
src/aoc2017/kot/Day22.kt | Tandrial | 47,354,790 | false | null | package aoc2017.kot
import java.io.File
object Day22 {
fun solve(input: List<String>, cnt: Int, partTwo: Boolean = false): Int {
val grid = genGrid(input)
var count = 0
var pos = Pair(grid.size / 2, grid.size / 2)
var dir = Pair(-1, 0)
repeat(cnt) {
val (posX, posY) = pos
when (grid... | 0 | Kotlin | 1 | 1 | 9294b2cbbb13944d586449f6a20d49f03391991e | 1,617 | Advent_of_Code | MIT License |
src/day05/Day05.kt | easchner | 572,762,654 | false | {"Kotlin": 104604} | package day05
import readInputSpaceDelimited
import java.util.Stack
fun main() {
fun getStacks(input: List<String>): List<Stack<Char>> {
val stacks = mutableListOf<Stack<Char>>()
for (line in input) {
val containers = line.chunked(4).map {
it.substring(1, 2)[0]
... | 0 | Kotlin | 0 | 0 | 5966e1a1f385c77958de383f61209ff67ffaf6bf | 2,221 | Advent-Of-Code-2022 | Apache License 2.0 |
src/day04/Day04.kt | robin-schoch | 572,718,550 | false | {"Kotlin": 26220} | package day04
import AdventOfCodeSolution
fun main() {
Day04.run()
}
fun createRange(input: String) = with(input.split('-')) {
this[0].toInt()..this[1].toInt()
}
infix fun IntRange.overlaps(range: IntRange) = !(last < range.first || range.last < first)
infix fun IntRange.contains(range: IntRange) = first <=... | 0 | Kotlin | 0 | 0 | fa993787cbeee21ab103d2ce7a02033561e3fac3 | 941 | aoc-2022 | Apache License 2.0 |
src/test/kotlin/be/brammeerten/y2023/Day10Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2023
import be.brammeerten.C
import be.brammeerten.readFile
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import kotlin.math.min
class Day10Test {
@Test
fun `part 1`() {
// val map = PipeMap(readFile("2023/day10/exampleInput.txt"))
// ... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 6,629 | Advent-of-Code | MIT License |
code/numeric/ModLinEqSolver.kt | hakiobo | 397,069,173 | false | null | private class ModLinEqSolver(val matrix: Array<IntArray>, val p: Int) {
val inv = IntArray(p) { num ->
modPow(num.toLong(), (p - 2).toLong(), p.toLong()).toInt()
}
var status: Status? = null
private set
private fun swap(r1: Int, r2: Int) {
val tmp = matrix[r1]
matrix[r1]... | 0 | Kotlin | 1 | 2 | f862cc5e7fb6a81715d6ea8ccf7fb08833a58173 | 2,693 | Kotlinaughts | MIT License |
src/main/kotlin/days/day11/Day11.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day11
import days.Day
import kotlin.math.abs
class Day11 : Day(false) {
override fun partOne(): Any {
return solve(1)
}
override fun partTwo(): Any {
return solve(999_999)
}
private fun solve(increas: Int):Long {
val input = readInput()
val galaxy = r... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 2,442 | advent-of-code_2023 | The Unlicense |
kotlin/2147-number-of-ways-to-divide-a-long-corridor.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | // Use combinatorics, time O(n) and space O(n)
class Solution {
fun numberOfWays(corridor: String): Int {
val mod = 1_000_000_007
val seats = mutableListOf<Int>()
for ((i, c) in corridor.withIndex()) {
if (c == 'S')
seats.add(i)
}
if (seats.size ... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 2,195 | leetcode | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/GraphSearch.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode
import java.util.*
fun <T : Any> searchGraph(
startingSet: Set<T>,
isDone: (T) -> Boolean,
nextSteps: (T) -> Set<Pair<T, Int>>,
computePath: Boolean = false,
heuristic: (T) -> Int = { 0 },
allowDuplicatesInQueue: Boolean = true
): Int {
val dists = ... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,110 | advent-of-code | MIT License |
src/Day05.kt | kedvinas | 572,850,757 | false | {"Kotlin": 15366} | fun main() {
fun part1(input: List<String>): String {
val stacks = mutableListOf<MutableList<String>>()
var i = 0
val line = input[i].chunked(4)
line.forEach {
stacks.add(mutableListOf(it))
}
while (true) {
if (input[++i].isEmpty()) {
... | 0 | Kotlin | 0 | 0 | 04437e66eef8cf9388fd1aaea3c442dcb02ddb9e | 2,355 | adventofcode2022 | Apache License 2.0 |
src/main/aoc2015/Day24.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2015
import kotlin.math.min
class Day24(input: List<String>) {
private val parsedInput = input.map { it.toInt() }.sortedBy { -it } // Largest first
private fun List<Int>.weight(): Int = sum()
private fun List<Int>.qe(): Long = fold(1L) { acc, i -> i * acc }
private var smallestFound = inpu... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,895 | aoc | MIT License |
kotlin/src/com/daily/algothrim/leetcode/medium/Search.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.medium
/**
* 33. 搜索旋转排序数组
*
* 整数数组 nums 按升序排列,数组中的值 互不相同 。
* 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]](下标 从 0 开始 计数)。例如, [0,1,2,4,5,6,7] 在下标 3 处经旋转后可能变为 [4,5,6,7,0,1,2] 。
* 给你 旋转后 的数组 nu... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,719 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/days/Day5.kt | jgrgt | 433,952,606 | false | {"Kotlin": 113705} | package days
import kotlin.math.abs
class Day5 : Day(5) {
override fun partOne(): Any {
return p1(inputList)
}
fun p1(ls: List<String>): Any {
val lines = parseLines(ls).filter { it.isVerticalSameX() || it.isHorizontalSameY() }
val maxPoint = findMaxPoint(lines)
val ground... | 0 | Kotlin | 0 | 0 | 6231e2092314ece3f993d5acf862965ba67db44f | 4,107 | aoc2021 | Creative Commons Zero v1.0 Universal |
src/day4/Day4.kt | ZsemberiDaniel | 159,921,870 | false | null | package day4
import RunnablePuzzleSolver
import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern
class Day4 : RunnablePuzzleSolver {
val guards: HashMap<Int, Guard> = hashMapOf()
override fun readInput1(lines: Array<String>) {
// patterns for matching the input string
... | 0 | Kotlin | 0 | 0 | bf34b93aff7f2561f25fa6bd60b7c2c2356b16ed | 4,302 | adventOfCode2018 | MIT License |
src/Day16.kt | rosyish | 573,297,490 | false | {"Kotlin": 51693} | import kotlin.math.max
import kotlin.system.measureTimeMillis
fun main() {
val valves = readInput("Day16_input").mapIndexed { index, str ->
val parts = str.split(" ")
val name = parts[1]
val flowRate = parts[4].split("=")[1].dropLast(1).toInt()
val neighbors = parts.takeLast(parts.s... | 0 | Kotlin | 0 | 2 | 43560f3e6a814bfd52ebadb939594290cd43549f | 5,125 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/adrielm/aoc2020/common/Algorithms.kt | Adriel-M | 318,860,784 | false | null | package com.adrielm.aoc2020.common
object Algorithms {
private fun <T> twoSum(
input: List<T>,
target: T,
startingIndex: Int,
subtractFun: (T, T) -> T
): Pair<T, T>? {
val visited = mutableSetOf<T>()
for (i in startingIndex until input.size) {
val cur... | 0 | Kotlin | 0 | 0 | 8984378d0297f7bc75c5e41a80424d091ac08ad0 | 3,778 | advent-of-code-2020 | MIT License |
src/main/kotlin/advent/day10/SyntaxScoring.kt | hofiisek | 434,171,205 | false | {"Kotlin": 51627} | package advent.day10
import advent.loadInput
import java.io.File
/**
* @author <NAME>
*/
typealias Stack = ArrayDeque<Char>
fun Char.isOpeningBracket() = listOf('(', '[', '{', '<').contains(this)
infix fun Char.doesNotClose(openingChar: Char) = !(this closes openingChar)
infix fun Char.closes(openingBracket: Cha... | 0 | Kotlin | 0 | 2 | 3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb | 2,713 | Advent-of-code-2021 | MIT License |
src/main/kotlin/co/csadev/advent2021/Day21.kt | gtcompscientist | 577,439,489 | false | {"Kotlin": 252918} | /**
* Copyright (c) 2021 by <NAME>
* Advent of Code 2021, Day 21
* Problem Description: http://adventofcode.com/2021/day/21
*/
package co.csadev.advent2021
import co.csadev.adventOfCode.BaseDay
import co.csadev.adventOfCode.Resources.resourceAsList
class Day21(override val input: List<String> = resourceAsList("21... | 0 | Kotlin | 0 | 1 | 43cbaac4e8b0a53e8aaae0f67dfc4395080e1383 | 2,535 | advent-of-kotlin | Apache License 2.0 |
src/year2022/day25/Day25.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day25
import readInputFileByYearAndDay
import readTestFileByYearAndDay
import kotlin.math.pow
val snafuToDec = mapOf('=' to -2, '-' to -1, '0' to 0, '1' to 1, '2' to 2)
fun main() {
fun decimalToSnafu(decimal: String): String {
val dec = decimal.toLong()
var digits = ""
... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 1,153 | advent-of-code-kotlin | Apache License 2.0 |
AOC-2017/src/main/kotlin/Day16.kt | sagar-viradiya | 117,343,471 | false | {"Kotlin": 72737} | import utils.splitAtComma
object Day16 {
fun part1(danceMoves: String, input: String = "abcdefghijklmnop"): String {
val programs = StringBuffer(input)
var danceMoveType: DanceMoveType
for (danceMove in danceMoves.splitAtComma()) {
danceMoveType = getDanceMoveType(danceMove)... | 0 | Kotlin | 0 | 0 | 7f88418f4eb5bb59a69333595dffa19bee270064 | 3,872 | advent-of-code | MIT License |
src/main/kotlin/utils/Primes.kt | embuc | 735,933,359 | false | {"Kotlin": 110920, "Java": 60263} | package se.embuc.utils
import kotlin.math.sqrt
fun isPrime(n: Long): Boolean {
if (n < 2) return false
if (n == 2L) return true
if (n % 2L == 0L) return false
val sqrtN = Math.sqrt(n.toDouble()).toLong()
for (i in 3..sqrtN step 2) {
if (n % i == 0L) return false
}
return true
}
fun isPrime(n: Int): Boolean {... | 0 | Kotlin | 0 | 1 | 79c87068303f862037d27c1b33ea037ab43e500c | 4,317 | projecteuler | MIT License |
src/day01/Day01.kt | jpveilleux | 573,221,738 | false | {"Kotlin": 42252} | package day01
import readInput
fun main() {
val testInputFileName = "Day01_test";
val inputFileName = "Day01";
val testInput = readInput(testInputFileName)
val input = readInput(inputFileName)
fun part1(input: List<String>, nameOfFile: String) {
getHighestCalCount(input, "$nameOfFile.txt"... | 0 | Kotlin | 0 | 0 | 5ece22f84f2373272b26d77f92c92cf9c9e5f4df | 1,569 | jpadventofcode2022 | Apache License 2.0 |
src/Day03.kt | nGoldi | 573,158,084 | false | {"Kotlin": 6839} | fun main() {
val input = readInput("Day03")
println(part1(input))
println(part2(input))
}
private fun calculatePriority(char: Char): Int {
return if (char.code >= 92) {
char.code - 96
} else {
char.code - 38
}
}
private fun calculatePriority(backpacks: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | bc587f433aa38c4d745c09d82b7d231462f777c8 | 712 | advent-of-code | Apache License 2.0 |
src/main/kotlin/io/math/SumOf4Numbers.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.math
import io.utils.runTests
class SumOf4Numbers {
fun execute(input: IntArray, target: Int): List<List<Int>> {
val triples = (input.indices).flatMap { i -> (i + 1 until input.size).map { Triple(i, it, input[i] + input[it]) } }
val map = mutableMapOf<Int, MutableList<Pair<Int, Int>>>()
trip... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 1,547 | coding | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem1675/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem1675
import java.util.*
/**
* LeetCode page: [1675. Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array/);
*/
class Solution {
/* Complexity:
* Time O(NLogN) and Space O(N);
*/
fun minimumDeviation(nums: IntArray): Int {
... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,827 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/kotlin/g2401_2500/s2493_divide_nodes_into_the_maximum_number_of_groups/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2493_divide_nodes_into_the_maximum_number_of_groups
// #Hard #Breadth_First_Search #Graph #Union_Find
// #2023_07_05_Time_862_ms_(100.00%)_Space_58.1_MB_(100.00%)
import java.util.LinkedList
import java.util.Queue
class Solution {
fun magnificentSets(n: Int, edges: Array<IntArray>): Int {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,948 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/de/dikodam/calendar/Day05.kt | dikodam | 573,126,346 | false | {"Kotlin": 26584} | package de.dikodam.calendar
import de.dikodam.AbstractDay
import de.dikodam.executeTasks
import kotlin.time.ExperimentalTime
@ExperimentalTime
fun main() {
Day05().executeTasks()
}
class Day05 : AbstractDay() {
private val inputLines = readInputLines()
private val stackDefinition = inputLines.takeWhile ... | 0 | Kotlin | 0 | 1 | 3eb9fc6f1b125565d6d999ebd0e0b1043539d192 | 2,920 | aoc2022 | MIT License |
src/Day11.kt | mpythonite | 572,671,910 | false | {"Kotlin": 29542} | fun main() {
class Monkey(var items: ArrayDeque<Long>, val operation: (Long) -> Long, val test: Long, val success: Int, val fail: Int) {
var inspects: Long = 0
}
fun part1(monkeys: List<Monkey>): Long {
for (i in 0 until 20) {
for (currMonkey in monkeys) {
while ... | 0 | Kotlin | 0 | 0 | cac94823f41f3db4b71deb1413239f6c8878c6e4 | 2,353 | advent-of-code-2022 | Apache License 2.0 |
src/Day05.kt | MwBoesgaard | 572,857,083 | false | {"Kotlin": 40623} | fun main() {
fun extractCargoLines(input: List<String>): Pair<List<String>, Pair<Int, Int>> {
val cargoLines: MutableList<String> = mutableListOf()
var numOfCargoCols = 0
var numOfRowsProcessed = 0
for ((i, row) in input.withIndex()) {
if (row[1] == '1') {
... | 0 | Kotlin | 0 | 0 | 3bfa51af6e5e2095600bdea74b4b7eba68dc5f83 | 3,439 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/sk/mkiss/algorithms/dynamic/LongestCommonSubsequence.kt | marek-kiss | 430,858,906 | false | {"Kotlin": 85343} | package sk.mkiss.algorithms.dynamic
import kotlin.math.max
object LongestCommonSubsequence {
fun getSizeOfLongestCommonSubsequence(a: List<Int>, b: List<Int>): Int {
val lcsMemory = mutableMapOf<Pair<Int, Int>, Int>()
lcs(a, b, a.size, b.size, lcsMemory)
return lcsMemory[a.size, b.size]!!... | 0 | Kotlin | 0 | 0 | 296cbd2e04a397597db223a5721b6c5722eb0c60 | 1,720 | algo-in-kotlin | MIT License |
src/main/kotlin/recursion/WordSquares.kt | e-freiman | 471,473,372 | false | {"Kotlin": 78010} | package recursion
val squares: MutableList<MutableList<String>> = mutableListOf()
data class TrieNode(val children: MutableMap<Char, TrieNode>)
val root = TrieNode(mutableMapOf())
fun traverse(square: MutableList<String>, cur: TrieNode, word: StringBuilder, words: Array<String>) {
if (word.length == words[0].len... | 0 | Kotlin | 0 | 0 | fab7f275fbbafeeb79c520622995216f6c7d8642 | 1,733 | LeetcodeGoogleInterview | Apache License 2.0 |
2022/src/main/kotlin/day10_imp.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Parser
import utils.Solution
import utils.Vec2i
import utils.cut
import kotlin.math.absoluteValue
fun main() {
Day10Imp.run()
}
object Day10Imp : Solution<List<Day10Imp.Insn>>() {
sealed class Insn {
data class Add(val a: Int) : Insn()
object Nop : Insn()
}
override ... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,340 | aoc_kotlin | MIT License |
day22/kotlin/corneil/src/main/kotlin/solution.kt | jensnerche | 317,661,818 | true | {"HTML": 2739009, "Java": 348790, "Kotlin": 271053, "TypeScript": 262310, "Python": 198318, "Groovy": 125347, "Jupyter Notebook": 116902, "C++": 101742, "Dart": 47762, "Haskell": 43633, "CSS": 35030, "Ruby": 27091, "JavaScript": 13242, "Scala": 11409, "Dockerfile": 10370, "PHP": 4152, "Go": 2838, "Shell": 2651, "Rust":... | package com.github.corneil.aoc2019.day22
import com.github.corneil.aoc2019.day22.Instruction.Cut
import com.github.corneil.aoc2019.day22.Instruction.Increment
import com.github.corneil.aoc2019.day22.Instruction.Reverse
import java.io.File
import java.math.BigInteger
infix fun BigInteger.`%%`(b: BigInteger): BigIntege... | 0 | HTML | 0 | 0 | a84c00ddbeb7f9114291125e93871d54699da887 | 7,864 | aoc-2019 | MIT License |
src/Day09.kt | HaydenMeloche | 572,788,925 | false | {"Kotlin": 25699} | fun main() {
val input = readInput("Day09")
val partOnePositions = mutableSetOf<Location>()
val partTwoPositions = mutableSetOf<Location>()
var headLocation = Location(0, 0)
val tails = (0 until 9).map {
Location(0, 0)
}.toMutableList()
input.forEach {
val (direction, amou... | 0 | Kotlin | 0 | 1 | 1a7e13cb525bb19cc9ff4eba40d03669dc301fb9 | 4,230 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxTwinSum.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 | 3,003 | kotlab | Apache License 2.0 |
ImageSegmentation/app/src/main/java/com/example/imagesegmentation/camera/CameraSizes.kt | bbueno5000 | 478,454,063 | false | {"Kotlin": 67304} | package com.example.imagesegmentation.camera
/*
* Copyright 2019 Google LLC
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* U... | 0 | Kotlin | 0 | 0 | 9e7dde119f345ed939c1ece4161bfd4d4ddc8b46 | 3,250 | Image-Segment-App | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem2353/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2353
import java.util.*
/**
* LeetCode page: [2353. Design a Food Rating System](https://leetcode.com/problems/design-a-food-rating-system/);
*/
class FoodRatings(foods: Array<String>, cuisines: Array<String>, ratings: IntArray) {
// entry=(food, (cuisine, rating))
pri... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,698 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/SubarraysWithKDistinct.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
/**
* 992. K 个不同整数的子数组
* 给定一个正整数数组 A,如果 A 的某个子数组中不同整数的个数恰好为 K,则称 A 的这个连续、不一定独立的子数组为好子数组。
*
* (例如,[1,2,3,1,2] 中有 3 个不同的整数:1,2,以及 3。)
*
* 返回 A 中好子数组的数目。
*/
class SubarraysWithKDistinct {
companion object {
@JvmStatic
fun main(args: Array<String>) {
... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,537 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/de/mbdevelopment/adventofcode/year2021/solvers/day14/Day14Puzzle1.kt | Any1s | 433,954,562 | false | {"Kotlin": 96683} | package de.mbdevelopment.adventofcode.year2021.solvers.day14
import de.mbdevelopment.adventofcode.year2021.solvers.PuzzleSolver
class Day14Puzzle1 : PuzzleSolver {
override fun solve(inputLines: Sequence<String>) = highestMinusLowestQuantity(inputLines.toList()).toString()
private fun highestMinusLowestQuan... | 0 | Kotlin | 0 | 0 | 21d3a0e69d39a643ca1fe22771099144e580f30e | 1,430 | AdventOfCode2021 | Apache License 2.0 |
src/Day01.kt | vitind | 578,020,578 | false | {"Kotlin": 60987} | fun main() {
fun part1(input: List<String>): Int {
var highestCalories = 0
input.fold(0) { totalCalories, value ->
if (value.isNotEmpty()) {
totalCalories + value.toInt()
} else { // value is empty -> check if it is the highest calories
if (... | 0 | Kotlin | 0 | 0 | 2698c65af0acd1fce51525737ab50f225d6502d1 | 1,007 | aoc2022 | Apache License 2.0 |
src/Day07.kt | meierjan | 572,860,548 | false | {"Kotlin": 20066} | import kotlin.math.min
sealed class Command {
data class CD(val path: String) : Command() {
companion object {
const val DISCRIMINATOR = "cd"
fun parse(input: List<String>): CD {
val (_, _, path) = input.first().split(" ")
return CD(path)
... | 0 | Kotlin | 0 | 0 | a7e52209da6427bce8770cc7f458e8ee9548cc14 | 5,467 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/g2001_2100/s2003_smallest_missing_genetic_value_in_each_subtree/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2001_2100.s2003_smallest_missing_genetic_value_in_each_subtree
// #Hard #Dynamic_Programming #Depth_First_Search #Tree #Union_Find
// #2023_06_23_Time_984_ms_(100.00%)_Space_78.9_MB_(100.00%)
@Suppress("NAME_SHADOWING")
class Solution {
fun smallestMissingValueSubtree(parents: IntArray, nums: IntArray): ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,219 | LeetCode-in-Kotlin | MIT License |
Chapter06/RabinKarp.kt | PacktPublishing | 125,371,513 | false | null | fun search(text: String, pattern: String): Int {
val patternLen = pattern.length
val textLen = text.length - patternLen
val patternHash = hash(pattern)
var subText = text.substring(0, patternLen)
var subTextHash = hash(subText)
var isFound = false
if ((patternHash == subTextHash) and subText... | 0 | Kotlin | 62 | 162 | f125372a286a3bf4f0248db109a7427f6bc643a7 | 1,742 | Hands-On-Data-Structures-and-Algorithms-with-Kotlin | MIT License |
src/main/kotlin/days/Day2.kt | andilau | 726,429,411 | false | {"Kotlin": 37060} | package days
@AdventOfCodePuzzle(
name = "<NAME>",
url = "https://adventofcode.com/2023/day/2",
date = Date(day = 2, year = 2023)
)
class Day2(input: List<String>) : Puzzle {
private val games = input.map { Game.from(it) }
override fun partOne(): Int = games.filter { it.possible() }.sumOf { it.id... | 3 | Kotlin | 0 | 0 | 9a1f13a9815ab42d7fd1d9e6048085038d26da90 | 1,401 | advent-of-code-2023 | Creative Commons Zero v1.0 Universal |
Retos/Reto #38 - LAS SUMAS [Media]/kotlin/pisanowp.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": ... | fun main() {
/*
* Reto #38 25/09/2023 LAS SUMAS
*
* Crea una función que encuentre todas las combinaciones de los números
* de una lista que suman el valor objetivo.
* - La función recibirá una lista de números enteros positivos
* y un valor objetivo.
* - Para obtener las combinacion... | 4 | Python | 2,929 | 4,661 | adcec568ef7944fae3dcbb40c79dbfb8ef1f633c | 2,821 | retos-programacion-2023 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.