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/dev/claudio/adventofcode2021/Day9Part2.kt | ClaudioConsolmagno | 434,559,159 | false | {"Kotlin": 78336} | package dev.claudio.adventofcode2021
fun main() {
Day9Part2().main()
}
private class Day9Part2 {
fun main() {
val input: List<String> = Support.readFileAsListString("day9-input.txt")
val xSize = input[0].length
val input2: MutableList<String> = mutableListOf()
input2.add("9".re... | 0 | Kotlin | 0 | 0 | 5f1aff1887ad0a7e5a3af9aca7793f1c719e7f1c | 2,444 | adventofcode-2021 | Apache License 2.0 |
Day22/src/Shuffle.kt | gautemo | 225,219,298 | false | null | import java.io.File
import java.math.BigInteger
import kotlin.math.absoluteValue
fun main(){
val commands = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText().trim()
val deck = Deck(10007)
deck.shuffle(commands)
println(deck.cards.indexOf(2019))
solvePar... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 3,001 | AdventOfCode2019 | MIT License |
src/day02/Day02.kt | Sardorbekcyber | 573,890,266 | false | {"Kotlin": 6613} | package day02
import java.io.File
fun main() {
fun part1(input: String) : Long {
val lostSet = setOf("A Z", "B X", "C Y")
val winSet = setOf("A Y", "B Z", "C X")
val drawSet = setOf("A X", "B Y", "C Z")
val scoreMap = mapOf('X' to 1, 'Y' to 2, 'Z' to 3)
val data = input.... | 0 | Kotlin | 0 | 2 | 56f29c8322663720bc83e7b1c6b0a362de292b12 | 1,699 | aoc-2022-in-kotlin | Apache License 2.0 |
y2017/src/main/kotlin/adventofcode/y2017/Day11.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2017
import adventofcode.io.AdventSolution
import kotlin.math.abs
object Day11 : AdventSolution(2017, 11, "Hex Ed") {
override fun solvePartOne(input: String) = input.split(",")
.mapNotNull { coordinatesForDirection[it] }
.reduce { a, b -> a + b }
.distance
.t... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,420 | advent-of-code | MIT License |
src/Day04.kt | yalematta | 572,668,122 | false | {"Kotlin": 8442} | fun main() {
fun parseInput(input: List<String>): List<List<Set<Int>>> {
return input.map { line ->
line.split(",")
.map { section ->
section.split("-")
.map {
it.toInt()
}.let { (a, ... | 0 | Kotlin | 0 | 0 | 2b43681cc2bd02e4838b7ad1ba04ff73c0422a73 | 1,009 | advent-of-code-2022 | Apache License 2.0 |
year2021/day10/part2/src/main/kotlin/com/curtislb/adventofcode/year2021/day10/part2/Year2021Day10Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
Now, discard the corrupted lines. The remaining lines are incomplete.
Incomplete lines don't have any incorrect characters - instead, they're missing some closing
characters at the end of the line. To repair the navigation subsystem, you just need to figure out
the sequence of closing characters t... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 3,179 | AdventOfCode | MIT License |
2023/src/main/kotlin/day21.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Grid
import utils.MutableGrid
import utils.Parser
import utils.Solution
import utils.Vec2i
import utils.toMutable
fun main() {
Day21.run(skipTest = true)
}
object Day21 : Solution<Grid<Char>>() {
override val name = "day21"
override val parser = Parser.charGrid
override fun part1() = solve(64)
... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 3,482 | aoc_kotlin | MIT License |
src/Day03_part1.kt | yashpalrawat | 573,264,560 | false | {"Kotlin": 12474} | fun main() {
val input = readInput("Day03")
// split string into two halves
// add all elements of first string to a map
// iterate through second string and see if record existing in first map
// if exists then add that character to result list ( or just get the priority )
val priorities = g... | 0 | Kotlin | 0 | 0 | 78a3a817709da6689b810a244b128a46a539511a | 1,305 | code-advent-2022 | Apache License 2.0 |
src/Day20.kt | inssein | 573,116,957 | false | {"Kotlin": 47333} | fun main() {
fun List<String>.parse(decryptionKey: Long = 1L) = map { it.toLong() * decryptionKey }
fun List<Long>.mix(times: Int = 1): List<Long> {
// using `IndexedValue<T>` to keep track of the original index (because the data can contain duplicates)
val data = this.withIndex().toMutableList... | 0 | Kotlin | 0 | 0 | 095d8f8e06230ab713d9ffba4cd13b87469f5cd5 | 1,523 | advent-of-code-2022 | Apache License 2.0 |
src/Day08.kt | chrisjwirth | 573,098,264 | false | {"Kotlin": 28380} | import kotlin.math.max
fun main() {
class VisibleTreeCounter(input: List<String>) {
val rowLength = input.size
val colLength = input[0].length
val lastRow = rowLength - 1
val lastCol = colLength - 1
val grid = List(rowLength) { List(colLength) { Tree() } }
inner cla... | 0 | Kotlin | 0 | 0 | d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d | 6,123 | AdventOfCode2022 | Apache License 2.0 |
6_six/MovieFan.kt | thalees | 250,902,664 | false | null | import java.util.*
fun main() {
repeat(readLine()!!.toInt()) {
// readLine() // skip empty line
solveCase()
}
}
private data class Mv(val i: Int, val a: Int, val b: Int, var t: Int = 0) : Comparable<Mv> {
override fun compareTo(other: Mv): Int = if (b != other.b) b.compareTo(other.b) else i... | 0 | Kotlin | 0 | 0 | 3b499d207d366450c7b2facbd99a345c86b6eff8 | 1,073 | kotlin-code-challenges | MIT License |
src/main/kotlin/analysis/SatelliteCalculator.kt | TheKoren | 708,303,908 | false | {"Kotlin": 22459} | package analysis
import analysis.data.ConstellationInfo
import analysis.data.SatelliteInfo
import model.SatelliteData
import java.time.LocalDate
import kotlin.math.PI
import kotlin.math.cbrt
import kotlin.math.pow
/**
* A utility object for calculating and analyzing satellite-related information.
*/
object Satellit... | 0 | Kotlin | 0 | 0 | 98570983ed3354b5e3c1e99fecf37d2f168bb510 | 5,218 | satellite-data-analysis | MIT License |
advent-of-code2016/src/main/kotlin/day03/Advent3.kt | REDNBLACK | 128,669,137 | false | null | package day03
import parseInput
import splitToLines
/**
--- Day 3: Squares With Three Sides ---
Now that you can think clearly, you move deeper into the labyrinth of hallways and office furniture that makes up this part of Easter Bunny HQ. This must be a graphic design department; the walls are covered in specificat... | 0 | Kotlin | 0 | 0 | e282d1f0fd0b973e4b701c8c2af1dbf4f4a149c7 | 1,357 | courses | MIT License |
aoc-2016/src/main/kotlin/nl/jstege/adventofcode/aoc2016/days/Day20.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2016.days
import nl.jstege.adventofcode.aoccommon.days.Day
import nl.jstege.adventofcode.aoccommon.utils.extensions.sumBy
/**
*
* @author <NAME>
*/
class Day20 : Day(title = "Firewall Rules") {
private companion object Configuration {
private const val MAX_ADDRESS = (1... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 1,710 | AdventOfCode | MIT License |
leetcode-75-kotlin/src/main/kotlin/MaxConsecutiveOnesIII.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given a binary array nums and an integer k,
* return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
*
*
*
* Example 1:
*
* Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2
* Output: 6
* Explanation: [1,1,1,0,0,1,1,1,1,1,1]
* Bolded numbers were flipped from 0 to 1. The lo... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,304 | leetcode-75 | Apache License 2.0 |
src/main/kotlin/tools/graph/ShortPath.kt | wrabot | 739,807,905 | false | {"Kotlin": 19706} | package tools.graph
fun <Node : Any> shortPath(
start: Node,
end: Node,
cost: (origin: Node, destination: Node) -> Double = { _, _ -> 1.0 },
estimatedEndCost: (Node) -> Double = { 0.0 }, // A*
neighbors: (Node) -> List<Node>
) = shortPath(start, isEnd = { this == end }, cost, estimatedEndCost, neig... | 0 | Kotlin | 0 | 0 | fd2da26c0259349fbc9719e694d58549e7f040a0 | 2,955 | competitive-tools | Apache License 2.0 |
src/main/kotlin/ca/kiaira/advent2023/day9/Day9.kt | kiairatech | 728,913,965 | false | {"Kotlin": 78110} | package ca.kiaira.advent2023.day9
import ca.kiaira.advent2023.Puzzle
import ca.kiaira.advent2023.day9.Day9.number
/**
* Object representing the solution for Day 9 of the Advent of Code.
*
* This class extends the Puzzle class and provides specific implementations for parsing and solving
* the puzzle for Day 9, wh... | 0 | Kotlin | 0 | 1 | 27ec8fe5ddef65934ae5577bbc86353d3a52bf89 | 3,974 | kAdvent-2023 | Apache License 2.0 |
src/org/aoc2021/Day8.kt | jsgroth | 439,763,933 | false | {"Kotlin": 86732} | package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day8 {
private fun solvePart1(lines: List<String>): Int {
return lines.sumOf { line ->
val outputDigits = line.split(" | ")[1].split(" ")
outputDigits.count { setOf(2, 3, 4, 7).contains(it.length) }
... | 0 | Kotlin | 0 | 0 | ba81fadf2a8106fae3e16ed825cc25bbb7a95409 | 2,643 | advent-of-code-2021 | The Unlicense |
src/AoC11.kt | Pi143 | 317,631,443 | false | null | import java.io.File
val floor = 0
val emptySeat = 1
val occupiedSeat = 2
fun main() {
println("Starting Day 11 A Test 1")
calculateDay11PartA("Input/2020_Day11_A_Test1")
println("Starting Day 11 A Real")
calculateDay11PartA("Input/2020_Day11_A")
println("Starting Day 11 B Test 1")
calculateDa... | 0 | Kotlin | 0 | 1 | fa21b7f0bd284319e60f964a48a60e1611ccd2c3 | 7,012 | AdventOfCode2020 | MIT License |
src/main/kotlin/advent2019/day3/day3.kt | davidpricedev | 225,621,794 | false | null | package advent2019.day3
import java.lang.Exception
import java.util.*
import kotlin.math.absoluteValue
fun main() {
calculateClosestIntersection(InputData().input1, InputData().input2)
calculateShortestWire(InputData().input1, InputData().input2)
}
fun calculateShortestWire(inputWire1: List<String>, inputWir... | 0 | Kotlin | 0 | 0 | 2283647e5b4ed15ced27dcf2a5cf552c7bd49ae9 | 7,991 | adventOfCode2019 | Apache License 2.0 |
src/main/kotlin/com/anahoret/aoc2022/day23/main.kt | mikhalchenko-alexander | 584,735,440 | false | null | package com.anahoret.aoc2022.day23
import java.io.File
import kotlin.system.measureTimeMillis
data class Elf(var row: Int, var col: Int) {
operator fun plus(point: Point): Point {
return Point(row + point.row, col + point.col)
}
}
data class Point(val row: Int, val col: Int)
fun parseElves(input: S... | 0 | Kotlin | 0 | 0 | b8f30b055f8ca9360faf0baf854e4a3f31615081 | 3,482 | advent-of-code-2022 | Apache License 2.0 |
kotlin/app/src/main/kotlin/coverick/aoc/day1/calorieCounting.kt | RyTheTurtle | 574,328,652 | false | {"Kotlin": 82616} | package coverick.aoc.day1;
import readResourceFile
private val INPUT_FILE = "calorieCounting-input.txt"
/*
The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of ... | 0 | Kotlin | 0 | 0 | 35a8021fdfb700ce926fcf7958bea45ee530e359 | 3,586 | adventofcode2022 | Apache License 2.0 |
src/main/kotlin/year2022/day13/Problem.kt | Ddxcv98 | 573,823,241 | false | {"Kotlin": 154634} | package year2022.day13
import IProblem
class Problem : IProblem {
private val lines = javaClass
.getResource("/2022/13.txt")!!
.readText()
.lines()
.filter(String::isNotEmpty)
.map { parseList(it.toCharArray()) }
private fun getClosingBracket(chars: CharArray, i: Int):... | 0 | Kotlin | 0 | 0 | 455bc8a69527c6c2f20362945b73bdee496ace41 | 2,339 | advent-of-code | The Unlicense |
src/Day20.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | import kotlin.math.abs
fun main() {
fun printList(startingNode: EncryptionNode) {
print(" ${startingNode.number}")
var current = startingNode.next
while(current != startingNode) {
print(", ${current!!.number}")
current = current.next
}
println()
... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 4,153 | aoc2022 | Apache License 2.0 |
src/Day04.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | fun main() {
fun part1(input: List<String>): Int {
var count = 0
for (line in input) {
val (range1, range2) = line.split(",")
val (start1, end1) = range1.split("-").map { it.toInt() }
val (start2, end2) = range2.split("-").map { it.toInt() }
if ((start... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 923 | Advent-Of-Code-2022 | Apache License 2.0 |
2022/src/day05/day05.kt | Bridouille | 433,940,923 | false | {"Kotlin": 171124, "Go": 37047} | package day05
import GREEN
import RESET
import printTimeMillis
import readInput
const val letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun buildStacks(input: List<String>): MutableList<MutableList<Char>> {
val stacks = mutableListOf<MutableList<Char>>()
input.forEach { s ->
for (i in 1..s.lastIndex step 4)... | 0 | Kotlin | 0 | 2 | 8ccdcce24cecca6e1d90c500423607d411c9fee2 | 2,331 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day19/part2/Part2.kt | bagguley | 329,976,670 | false | null | package day19.part2
import java.util.*
val ruleMap: MutableMap<Int, Rule> = mutableMapOf()
fun main() {
val rules = parseRules(data2[0].split("\n"))
val input = parseInput(data2[1].split("\n"))
for (rule in rules) {
ruleMap[rule.index] = rule
}
val valid = ruleMap[0]!!.validStrings(rule... | 0 | Kotlin | 0 | 0 | 6afa1b890924e9459f37c604b4b67a8f2e95c6f2 | 2,125 | adventofcode2020 | MIT License |
src/day02/day02.kt | tmikulsk1 | 573,165,106 | false | {"Kotlin": 25281} | package day02
import day02.Constants.CommandSymbols
import day02.Constants.DEFAULT_VALUE
import day02.Constants.DRAW_EARNING_POINT
import day02.Constants.InterpretedSymbols
import day02.Constants.PAPER_POINT_VALUE
import day02.Constants.PAPER_SYMBOL
import day02.Constants.ROCK_POINT_VALUE
import day02.Constants.ROCK_S... | 0 | Kotlin | 0 | 1 | f5ad4e601776de24f9a118a0549ac38c63876dbe | 5,846 | AoC-22 | Apache License 2.0 |
src/Day14.kt | shepard8 | 573,449,602 | false | {"Kotlin": 73637} | open class Point(val x: Int, val y: Int): Comparable<Point> {
open val char = '~'
override fun toString(): String {
return "($x, $y)"
}
override fun compareTo(other: Point): Int {
return if (x < other.x || x == other.x && y < other.y) {
-1
} else if (x == other.x &&... | 0 | Kotlin | 0 | 1 | 81382d722718efcffdda9b76df1a4ea4e1491b3c | 4,216 | aoc2022-kotlin | Apache License 2.0 |
src/shmulik/klein/day04/Day04.kt | shmulik-klein | 573,426,488 | false | {"Kotlin": 9136} | package shmulik.klein.day04
import readInput
fun main() {
val input = readInput("shmulik/klein/day04/Day04_test")
val result1 = part1(input)
println(result1)
val result2 = part2(input)
println(result2)
}
fun part2(input: List<String>): Int {
var count = 0
for (line in input) {
v... | 0 | Kotlin | 0 | 0 | 4d7b945e966dad8514ec784a4837b63a942882e9 | 1,228 | advent-of-code-2022 | Apache License 2.0 |
advent-of-code-2023/src/main/kotlin/Day12.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | // Day 12: Hot Springs
// https://adventofcode.com/2023/day/12
import java.io.File
private const val WORKING = "."
private const val BROKEN = "#"
private const val UNKNOWN = "?"
fun main() {
val rows = File("src/main/resources/Day12.txt").readLines()
val sumOfPossileArrangements = rows.sumOf { row ->
... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 1,414 | advent-of-code | Apache License 2.0 |
kotlin/src/2022/Day20_2022.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | fun main() {
val input = readInput(20).trim().lines()
.map {it.toInt()}
val N = input.size
val idxes = listOf(1000, 2000, 3000)
fun solve(x: MutableList<Pair<Long, Int>>, rep: Int = 1): Long {
repeat(rep) {
for (i in 0 until N) {
// find where's the item orig... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 1,455 | adventofcode | Apache License 2.0 |
src/Day01.kt | othimar | 573,607,284 | false | {"Kotlin": 14557} | fun main() {
fun part1(input: List<String>): Int {
val data: ArrayList<ArrayList<Int>> = ArrayList()
data.add(ArrayList())
for (str in input) {
if (str.isBlank()) {
data.add(ArrayList())
} else {
data.last().add(str.toInt())
... | 0 | Kotlin | 0 | 0 | ff62a00123fe817773ff6248d34f606947ffad6d | 1,166 | advent-of-code-2022 | Apache License 2.0 |
src/day22/Day22.kt | martin3398 | 572,166,179 | false | {"Kotlin": 76153} | package day22
import readInput
typealias InputType = Triple<Map<Pair<Int, Int>, Node>, List<Instruction>, Pair<Int, Int>>
enum class Direction(val score: Int) {
N(3), S(1), W(2), E(0);
fun rotate(direction: RotationDirection): Direction = when (direction) {
RotationDirection.R -> rotateRight()
... | 0 | Kotlin | 0 | 0 | 4277dfc11212a997877329ac6df387c64be9529e | 6,675 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2022/Day07.kt | colinodell | 572,710,708 | false | {"Kotlin": 105421} | package com.colinodell.advent2022
class Day07(input: List<String>) {
private val root = Directory()
init {
var currentDir = root
// Assume the first line is the root, so skip it
for (line in input.drop(1)) {
val parts = line.split(" ")
when (true) {
... | 0 | Kotlin | 0 | 1 | 32da24a888ddb8e8da122fa3e3a08fc2d4829180 | 1,802 | advent-2022 | MIT License |
src/Day03.kt | novotnyradekcz | 579,767,169 | false | {"Kotlin": 11517} | fun main() {
fun part1(input: List<String>): Int {
var total = 0
val lower = "abcdefghijklmnopqrstuvwxyz"
val upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (line in input) {
var temp = ' '
for (i in 0 until line.length / 2) {
for (j in line.length /... | 0 | Kotlin | 0 | 0 | 2f1907dc63344cf536f5031bc7e1c61db03fc570 | 1,753 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | const val START_ASCII_UPPERCASE = 'A'.code
const val START_ASCII_LOWERCASE = 'a'.code
const val START_ITEM_UPPERCASE = 27
const val START_ITEM_LOWERCASE = 1
const val GROUP_SIZE = 3
fun main() {
fun calculatePriority(item: Char) : Int{
return if (item.isUpperCase()) {
item.code - START_ASCII_UP... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 1,199 | AoC2022 | Apache License 2.0 |
src/Day16b2.kt | jrmacgill | 573,065,109 | false | {"Kotlin": 76362} | import java.lang.Integer.max
import java.lang.Integer.min
class Day16b2 {
val inputLineRegex = """Valve ([A-Z]*) has flow rate=(\d+); tunnel[s]? lead[s]? to valve[s]? (.*)""".toRegex()
val data = mutableMapOf<String, Room>()
val compactData = mutableMapOf<String, CompactRoom>()
val maxTicks = 26
... | 0 | Kotlin | 0 | 1 | 3dcd590f971b6e9c064b444139d6442df034355b | 4,359 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/days/Day4.kt | andilau | 544,512,578 | false | {"Kotlin": 29165} | package days
import java.lang.IllegalArgumentException
@AdventOfCodePuzzle(
name = "Security Through Obscurity",
url = "https://adventofcode.com/2016/day/4",
date = Date(day = 4, year = 2016)
)
class Day4(private val input: List<String>) : Puzzle {
override fun partOne(): Int =
... | 3 | Kotlin | 0 | 0 | b2a836bd3f1c5eaec32b89a6ab5fcccc91b665dc | 2,147 | advent-of-code-2016 | Creative Commons Zero v1.0 Universal |
kotlin-java/src/main/kotlin/func/prog/java/recursion/ListExtn.kt | kogupta | 150,227,783 | false | {"Java": 533747, "Scala": 120497, "Kotlin": 23555} | package func.prog.java.recursion
fun main(args: Array<String>) {
println("abc".toList().head())
println(List(1) { 'a' }.mkString())
println(('a'..'z').asSequence().toList().mkString())
println("-- fold left --")
println("Sum of [1..10] : " + sum2((1..10).toList()))
println(List(1) { 'a' }.mkS... | 16 | Java | 0 | 0 | aabace38199e695027969143e5955f8399d20dbf | 2,108 | misc-projects | The Unlicense |
src/commonMain/kotlin/sequences/Last.kt | tomuvak | 511,086,330 | false | {"Kotlin": 92304, "Shell": 619} | package com.tomuvak.util.sequences
/**
* Returns a sequence containing all elements of the receiver sequence [this] except for the last [n] (which is not
* allowed to be negative) ones (resulting in an empty sequence in case there are only [n] elements or less to begin
* with).
*
* The resulting sequence has the ... | 0 | Kotlin | 0 | 0 | e20cfae9535fd9968542b901c698fdae1a24abc1 | 8,133 | util | MIT License |
src/Day11.kt | hoppjan | 433,705,171 | false | {"Kotlin": 29015, "Shell": 338} | typealias Octopuses = MutableMap<Point, Int>
fun main() {
fun part1(input: Octopuses) =
input.flashingSequence()
.take(100)
.sum()
fun part2(input: Octopuses) =
input.flashingSequence()
.takeWhile { it < input.size }
.count()
.plus(1... | 0 | Kotlin | 0 | 0 | 04f10e8add373884083af2a6de91e9776f9f17b8 | 2,260 | advent-of-code-2021 | Apache License 2.0 |
year2022/src/cz/veleto/aoc/year2022/Day12.kt | haluzpav | 573,073,312 | false | {"Kotlin": 164348} | package cz.veleto.aoc.year2022
import cz.veleto.aoc.core.AocDay
import cz.veleto.aoc.core.Pos
class Day12(config: Config) : AocDay(config) {
override fun part1(): String {
val (nodes, start, end) = parseNodes()
start.currentShortestPath = 0
val nodesToHandle = mutableListOf(start)
... | 0 | Kotlin | 0 | 1 | 32003edb726f7736f881edc263a85a404be6a5f0 | 3,157 | advent-of-pavel | Apache License 2.0 |
src/main/kotlin/Excercise09.kt | underwindfall | 433,989,850 | false | {"Kotlin": 55774} | private fun part1() {
var ans = 0
val input = getInputAsTest("09") { split("\n") }
val n = input.size
val m = input[0].length
for (i in 0 until n) {
for (j in 0 until m) {
val b =
listOfNotNull(
input[i].getOrNull(j + 1),
input[i].getOrNull(j - 1),
input.getOrNu... | 0 | Kotlin | 0 | 0 | 4fbee48352577f3356e9b9b57d215298cdfca1ed | 1,178 | advent-of-code-2021 | MIT License |
day10/src/main/kotlin/com/lillicoder/adventofcode2023/day10/Day10.kt | lillicoder | 731,776,788 | false | {"Kotlin": 98872} | package com.lillicoder.adventofcode2023.day10
import com.lillicoder.adventofcode2023.grids.Direction
import com.lillicoder.adventofcode2023.grids.Grid
import com.lillicoder.adventofcode2023.grids.GridParser
import com.lillicoder.adventofcode2023.grids.Node
import kotlin.math.abs
fun main() {
val day10 = Day10()
... | 0 | Kotlin | 0 | 0 | 390f804a3da7e9d2e5747ef29299a6ad42c8d877 | 6,348 | advent-of-code-2023 | Apache License 2.0 |
leetcode2/src/leetcode/first-unique-character-in-a-string.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* 387. 字符串中的第一个唯一字符
* https://leetcode-cn.com/problems/first-unique-character-in-a-string/
* 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。
案例:
s = "leetcode"
返回 0.
s = "loveleetcode",
返回 2.
注意事项:您可以假定该字符串只包含小写字母。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/first-unique-character-in-... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 1,668 | leetcode | MIT License |
src/main/kotlin/algorithms/MedianString.kt | jimandreas | 377,843,697 | false | null | @file:Suppress("LiftReturnOrAssignment", "GrazieInspection")
package algorithms
import java.lang.Integer.min
/**
2.4 From Motif Finding to Finding a Median String
8 out of 11 steps passed
0 out of 5 points received
Code Challenge: Implement MedianString.
Input: An integer k, followed by a collection of strings Dn... | 0 | Kotlin | 0 | 0 | fa92b10ceca125dbe47e8961fa50242d33b2bb34 | 2,907 | stepikBioinformaticsCourse | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RestoreArrayFromAdjacentPairs.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,946 | kotlab | Apache License 2.0 |
leetcode2/src/leetcode/validate-binary-search-tree.kt | hewking | 68,515,222 | false | null | package leetcode
import leetcode.structure.TreeNode
/**
* 98. 验证二叉搜索树
* https://leetcode-cn.com/problems/validate-binary-search-tree/
* Created by test
* Date 2019/10/5 23:30
* Description
* 给定一个二叉树,判断其是否是一个有效的二叉搜索树。
假设一个二叉搜索树具有如下特征:
节点的左子树只包含小于当前节点的数。
节点的右子树只包含大于当前节点的数。
所有左子树和右子树自身必须也是二叉搜索树。
示例 1:
输入:
2
/ \... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 1,885 | leetcode | MIT License |
y2019/src/main/kotlin/adventofcode/y2019/Day06.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2019
import adventofcode.io.AdventSolution
fun main() = Day06.solve()
object Day06 : AdventSolution(2019, 6, "Universal Orbit Map") {
override fun solvePartOne(input: String): Int {
val satellites: Map<String, List<String>> = input
.lineSequence()
.m... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,040 | advent-of-code | MIT License |
src/main/kotlin/fr/chezbazar/aoc23/day5/AlmanacMapper.kt | chezbazar | 728,404,822 | false | {"Kotlin": 54427} | package fr.chezbazar.aoc23.day5
class AlmanacMapper(private val instructions: List<Instruction>) {
fun map(input: Long): Long {
instructions.forEach { (range, diff) ->
if (range.contains(input)) {
return input + diff
}
}
return input
}
fun mi... | 0 | Kotlin | 0 | 0 | 223f19d3345ed7283f4e2671bda8ac094341061a | 2,790 | adventofcode | MIT License |
src/Day03.kt | robinpokorny | 572,434,148 | false | {"Kotlin": 38009} | typealias Rucksack = List<Char>
private fun parse(input: List<String>): List<Rucksack> = input
.map { it.toCharArray().toList() }
private fun itemToPriority(char: Char): Int =
if (char in 'a'..'z')
char - 'a' + 1
else
char - 'A' + 27
private fun findDuplicate(rucksack: Rucksack): Char = r... | 0 | Kotlin | 0 | 2 | 56a108aaf90b98030a7d7165d55d74d2aff22ecc | 1,299 | advent-of-code-2022 | MIT License |
src/main/kotlin/io/dmitrijs/aoc2022/Day18.kt | lakiboy | 578,268,213 | false | {"Kotlin": 76651} | package io.dmitrijs.aoc2022
class Day18(input: List<String>) {
private val points =
input.map { line ->
val (x, y, z) = line.split(",").map(String::toInt)
Point(x, y, z)
}.toSet()
fun puzzle1() = points.surfaceSize
fun puzzle2() = points.surfaceSize - points.gaps()... | 0 | Kotlin | 0 | 1 | bfce0f4cb924834d44b3aae14686d1c834621456 | 1,993 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/trees_graphs/build_order/dfs/Question.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.trees_graphs.build_order.dfs
import java.util.*
/**
* You are given a list of projects and a list of dependencies (which is a list of pairs of projects,
* where the second project is dependent on the first project).
* All of a project's dependencies must be built before... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 3,765 | CodingChallenges | Apache License 2.0 |
Meeting Scheduler for Two/Main.kt | JChoPop | 429,859,326 | false | {"Kotlin": 20296} | // By HJC 2021-11-18
// Meeting Scheduler for two calendars
//
// example input:
val calOne = listOf(Pair("9:00", "10:30"), Pair("12:00", "13:00"), Pair("16:00", "18:00"))
val bounds1 = Pair("9:00", "20:00")
val calTwo = listOf(Pair("10:00", "11:30"), Pair("12:30", "14:30"), Pair("14:30", "15:00"), Pair("16:00", "17:00... | 0 | Kotlin | 0 | 0 | 3fb587f2af747acc29886cdc2a02653196326dbf | 2,664 | kotlin_projects | MIT License |
src/main/kotlin/com/ginsberg/advent2022/Day07.kt | tginsberg | 568,158,721 | false | {"Kotlin": 113322} | /*
* Copyright (c) 2022 by <NAME>
*/
/**
* Advent of Code 2022, Day 7 - No Space Left On Device
* Problem Description: http://adventofcode.com/2022/day/7
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day7/
*/
package com.ginsberg.advent2022
class Day07(input: List<String>) {
pr... | 0 | Kotlin | 2 | 26 | 2cd87bdb95b431e2c358ffaac65b472ab756515e | 2,155 | advent-2022-kotlin | Apache License 2.0 |
src/main/kotlin/io/github/ajoz/puzzles/Day04.kt | ajoz | 574,043,593 | false | {"Kotlin": 21275} | package io.github.ajoz.puzzles
import io.github.ajoz.utils.containsAll
import io.github.ajoz.utils.containsAny
import io.github.ajoz.utils.readInput
/**
* --- Day 4: Camp Cleanup ---
*
* Space needs to be cleared before the last supplies can be unloaded from the ships, and so several Elves have been
* assigned th... | 0 | Kotlin | 0 | 0 | 6ccc37a4078325edbc4ac1faed81fab4427845b8 | 3,929 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/Day09.kt | brigham | 573,127,412 | false | {"Kotlin": 59675} | import kotlin.math.abs
import kotlin.math.sign
data class Movement(val dir: Char, val count: Int)
data class Position(val x: Int, val y: Int)
fun main() {
fun parse(input: List<String>): List<Movement> {
return input.map { it.split(' ') }
.map { it[0] to it[1].toInt() }
.map { Mov... | 0 | Kotlin | 0 | 0 | b87ffc772e5bd9fd721d552913cf79c575062f19 | 4,457 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | treegem | 572,875,670 | false | {"Kotlin": 38876} | import common.Position
import common.readInput
import kotlin.math.min
// i am sorry for the mess, but i fell behind in schedule and will not refactor or optimize this code
// still hoping to catch up
fun main() {
fun part1(input: List<String>): Long {
val charCodeArray = input.to2dArray()
val sta... | 0 | Kotlin | 0 | 0 | 97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8 | 4,787 | advent_of_code_2022 | Apache License 2.0 |
src/algorithmdesignmanualbook/sorting/KSortedListMerge.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.sorting
import algorithmdesignmanualbook.print
import utils.assertArraysSame
/**
* Give an O(n log k)-time algorithm that merges k sorted lists with a total of n
* elements into one sorted list. (Hint: use a heap to speed up the elementary O(kn)-time algorithm).
*/
private fun kSo... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 1,550 | algorithms | MIT License |
src/main/kotlin/Day03.kt | attilaTorok | 573,174,988 | false | {"Kotlin": 26454} | fun main() {
fun getItemValue(item: Char) = if (item.isUpperCase()) {
item.code - 38
} else {
item.code - 96
}
fun sumOfThePriorities(fileName: String): Int {
var result = 0
readInputWithStream(fileName).useLines {
val iterator = it.iterator()
w... | 0 | Kotlin | 0 | 0 | 1799cf8c470d7f47f2fdd4b61a874adcc0de1e73 | 2,636 | AOC2022 | Apache License 2.0 |
src/main/kotlin/g1801_1900/s1851_minimum_interval_to_include_each_query/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1801_1900.s1851_minimum_interval_to_include_each_query
// #Hard #Array #Sorting #Binary_Search #Heap_Priority_Queue #Line_Sweep
// #2023_06_22_Time_1612_ms_(87.50%)_Space_129.5_MB_(75.00%)
import java.util.Arrays
import java.util.PriorityQueue
class Solution {
fun minInterval(intervals: Array<IntArray>,... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,455 | LeetCode-in-Kotlin | MIT License |
src/jvmMain/kotlin/day14/initial/Day14.kt | liusbl | 726,218,737 | false | {"Kotlin": 109684} | package day14.initial
import day11.initial.Grid
import day11.initial.Location
import day11.initial.rotate
import day11.initial.toPrintableString
import java.io.File
fun main() {
solvePart1() // Solution: 112046, Time: 2023-12-15 23:41
}
fun solvePart1() {
// val input = File("src/jvmMain/kotlin/day14/input/in... | 0 | Kotlin | 0 | 0 | 1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1 | 2,102 | advent-of-code | MIT License |
src/DaySeven.kt | jrmacgill | 573,065,109 | false | {"Kotlin": 76362} | data class Folder(val name: String, val parent: String, var size : Int, var children: MutableList<String>)
data class File(val name: String, val size: Int, val dir: String)
fun main() {
DaySeven().run()
}
class DaySeven( val dirMap: HashMap<String, Folder> = HashMap<String, Folder>()) {
var current: Folder? ... | 0 | Kotlin | 0 | 1 | 3dcd590f971b6e9c064b444139d6442df034355b | 2,428 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/io/github/trustedshops_public/spring_boot_starter_keycloak_path_based_resolver/configuration/holder.kt | trustedshops-public | 524,078,409 | false | {"Kotlin": 22803} | package io.github.trustedshops_public.spring_boot_starter_keycloak_path_based_resolver.configuration
import org.keycloak.adapters.KeycloakDeployment
import java.lang.IllegalArgumentException
class MatcherConfiguration(
private val parent: KeycloakPathContextConfigurationHolder,
private val antPatterns: Array<... | 2 | Kotlin | 0 | 0 | 451885d836f596ae1423b78d9a7a873552b42e18 | 1,752 | spring-boot-starter-keycloak-path-based-resolver | MIT License |
kotlin/graphs/flows/MinCostFlowBF.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package graphs.flows
import java.util.stream.Stream
// https://en.wikipedia.org/wiki/Minimum-cost_flow_problem in O(E * V * FLOW)
// negative-cost edges are allowed
// negative-cost cycles are not allowed
class MinCostFlowBF(nodes: Int) {
var graph: Array<List<Edge>>
inner class Edge(var to: Int, var rev: In... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 3,002 | codelibrary | The Unlicense |
kotlin/src/katas/kotlin/leetcode/subarray_sum_equals_k/Tests.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.subarray_sum_equals_k
import java.util.*
//
// https://leetcode.com/problems/subarray-sum-equals-k
//
// Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
// Constraints:
// - The length of the array is in ran... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 1,365 | katas | The Unlicense |
src/Day02.kt | RogozhinRoman | 572,915,906 | false | {"Kotlin": 28985} | fun main() {
fun part1(input: List<String>): Int {
var result = 0
for (pair in input.map { it.split(' ') }) {
when (pair.first()) {
"A" -> when (pair.last()) {
"X" -> result += 1 + 3
"Y" -> result += 2 + 6
"Z" ->... | 0 | Kotlin | 0 | 1 | 6375cf6275f6d78661e9d4baed84d1db8c1025de | 2,109 | AoC2022 | Apache License 2.0 |
src/year2022/day14/Solution.kt | TheSunshinator | 572,121,335 | false | {"Kotlin": 144661} | package year2022.day14
import io.kotest.matchers.shouldBe
import utils.Point
import utils.not
import utils.readInput
import utils.sequenceTo
fun main() {
val testInput = readInput("14", "test_input")
val realInput = readInput("14", "input")
val testWalls = parseRockWalls(testInput)
val testInitialSta... | 0 | Kotlin | 0 | 0 | d050e86fa5591447f4dd38816877b475fba512d0 | 4,116 | Advent-of-Code | Apache License 2.0 |
src/Day22.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | fun main() {
fun parseInstructions(input: List<String>): List<String> {
val rawInstructions = input[input.size - 1]
val distances = rawInstructions.split('L', 'R').filter { it.isNotEmpty() }
val turns = rawInstructions.split('0', '1', '2', '3', '4', '5', '6', '7', '8', '9').filter { it.isNot... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 11,441 | aoc2022 | Apache License 2.0 |
src/Day04.kt | eo | 574,058,285 | false | {"Kotlin": 45178} | // https://adventofcode.com/2022/day/4
fun main() {
infix fun IntRange.isEitherFullyContainedInTheOther(other: IntRange): Boolean =
(first in other && last in other) || (other.first in this && other.last in this)
infix fun IntRange.overlaps(other: IntRange): Boolean =
!(first > other.last || la... | 0 | Kotlin | 0 | 0 | 8661e4c380b45c19e6ecd590d657c9c396f72a05 | 1,199 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2020/ex5.kt | noamfree | 433,962,392 | false | {"Kotlin": 93533} | fun main() {
val input = readInputFile("aoc2020/input5")
val rowsAndColums = input.lines().map { row(it.take(7)) to column(it.takeLast(3)) }.sortedBy { (a, b) ->
seatId(a, b)
}
val firstRow = rowsAndColums.first().first
val lastRow = rowsAndColums.last().first
var index = 0
print(row... | 0 | Kotlin | 0 | 0 | 566cbb2ef2caaf77c349822f42153badc36565b7 | 1,396 | AOC-2021 | MIT License |
src/leetcode_study_badge/dynamic_programming/Day3.kt | faniabdullah | 382,893,751 | false | null | package leetcode_study_badge.dynamic_programming
class Day3 {
// https://leetcode.com/problems/house-robber/
fun rob(nums: IntArray): Int {
val dp = nums.clone()
for (i in nums.indices) {
for (j in i + 2 until nums.size) {
dp[j] = maxOf(dp[j], nums[j] + dp[i])
... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 3,881 | dsa-kotlin | MIT License |
src/main/kotlin/ru/timakden/aoc/year2015/Day21.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2015
import ru.timakden.aoc.util.PowerSet
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
import ru.timakden.aoc.year2015.Day21.Item.*
/**
* [Day 21: RPG Simulator 20XX](https://adventofcode.com/2015/day/21).
*/
object Day21 {
@JvmStatic
fun main(args: A... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 4,669 | advent-of-code | MIT License |
src/main/kotlin/Day11.kt | bent-lorentzen | 727,619,283 | false | {"Kotlin": 68153} | import java.time.LocalDateTime
import java.time.ZoneOffset
import kotlin.math.abs
fun main() {
fun calculateDistances(input: List<String>, driftAdder: Long): Long {
var emptyLines = 0L
val galaxies = input.mapIndexedNotNull { lineNumber, s ->
val galaxyCoordinates = s.mapIndexedNotNull... | 0 | Kotlin | 0 | 0 | 41f376bd71a8449e05bbd5b9dd03b3019bde040b | 1,979 | aoc-2023-in-kotlin | Apache License 2.0 |
src/main/kotlin/eu/michalchomo/adventofcode/year2023/Day04.kt | MichalChomo | 572,214,942 | false | {"Kotlin": 56758} | package eu.michalchomo.adventofcode.year2023
import eu.michalchomo.adventofcode.Day
import eu.michalchomo.adventofcode.main
import java.math.BigInteger
typealias CountMatchingToOccurrences = Pair<Int, Int>
object Day04 : Day {
override val number: Int = 4
override fun part1(input: List<String>): String = i... | 0 | Kotlin | 0 | 0 | a95d478aee72034321fdf37930722c23b246dd6b | 1,572 | advent-of-code | Apache License 2.0 |
src/me/bytebeats/algo/kt/Solution2.kt | bytebeats | 251,234,289 | false | null | package me.bytebeats.algo.kt
import me.bytebeats.algs.ds.ListNode
import me.bytebeats.algs.ds.TreeNode
class Solution2 {
fun removeDuplicates(s: String, k: Int): String {
if (k < 2 || s.isEmpty() || s.length < k) {
return s
}
var start = -1
var str = s
start = s... | 0 | Kotlin | 0 | 1 | 7cf372d9acb3274003bb782c51d608e5db6fa743 | 48,765 | Algorithms | MIT License |
src/main/kotlin/days/Day5.kt | butnotstupid | 571,247,661 | false | {"Kotlin": 90768} | package days
class Day5 : Day(5) {
override fun partOne(): Any {
val mapState = parseMap().map { it.toMutableList() }
parseCommands().forEach { (number, from, to) ->
repeat(number) {
mapState[to - 1].add(0, mapState[from - 1].first())
mapState[from - 1]... | 0 | Kotlin | 0 | 0 | 4760289e11d322b341141c1cde34cfbc7d0ed59b | 1,788 | aoc-2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/leetcode/P1314.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package com.leetcode
// https://github.com/antop-dev/algorithm/issues/277
class P1314 {
fun matrixBlockSum(mat: Array<IntArray>, k: Int): Array<IntArray> {
val dp = Array(mat.size) { i -> IntArray(mat[i].size) }.apply {
this[0][0] = mat[0][0]
for (i in 1 until mat.size) this[i][0] =... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,271 | algorithm | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[16]最接近的三数之和.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import java.util.*
import kotlin.math.abs
//给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和
//。假定每组输入只存在唯一答案。
//
//
//
// 示例:
//
// 输入:nums = [-1,2,1,-4], target = 1
//输出:2
//解释:与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。
//
//
//
//
// 提示:
//
//
// 3 <= nums.length <= 10^3
// -10^3 <= ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,760 | MyLeetCode | Apache License 2.0 |
src/year2022/day10/Day10.kt | kingdongus | 573,014,376 | false | {"Kotlin": 100767} | package year2022.day10
import readInputFileByYearAndDay
import readTestFileByYearAndDay
fun main() {
fun calculateXOverTime(input: List<String>): Array<Int> {
val history = Array(input.size * 3) { 1 }
var cycle = 1
var x = 1
input
.map { if (it == "noop") "noop 0" els... | 0 | Kotlin | 0 | 0 | aa8da2591310beb4a0d2eef81ad2417ff0341384 | 2,103 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/KWeakestRows.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,464 | kotlab | Apache License 2.0 |
src/main/java/com/ncorti/aoc2021/Exercise13.kt | cortinico | 433,486,684 | false | {"Kotlin": 36975} | package com.ncorti.aoc2021
object Exercise13 {
private fun getInput(): Pair<List<String>, Array<IntArray>> {
val input = getInputAsTest("13") { split("\n") }
val size =
input.filter { "," in it }.flatMap { it.trim().split(",") }.maxOf(String::toInt) + 1
val world = Array(size)... | 0 | Kotlin | 0 | 4 | af3df72d31b74857201c85f923a96f563c450996 | 2,325 | adventofcode-2021 | MIT License |
src/main/kotlin/days/Day07.kt | TheMrMilchmann | 725,205,189 | false | {"Kotlin": 61669} | /*
* Copyright (c) 2023 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, dis... | 0 | Kotlin | 0 | 1 | f94ff8a4c9fefb71e3ea183dbc3a1d41e6503152 | 3,277 | AdventOfCode2023 | MIT License |
src/y2022/Day19.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2022
import util.readInput
import util.transpose
import kotlin.math.ceil
object Day19 {
class Resources(
ore: Int = 0,
clay: Int = 0,
obsidian: Int = 0,
geode: Int = 0,
) {
constructor(list: List<Int>) : this(list[0], list[1], list[2], list[3])
val amo... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 7,732 | advent-of-code | Apache License 2.0 |
src/Day02.kt | mikrise2 | 573,939,318 | false | {"Kotlin": 62406} | fun getPointsForWin(enemyMove: String, yourMove: String) = when (enemyMove) {
"A" -> {
when (yourMove) {
"X" -> 3
"Z" -> 0
else -> 6
}
}
"B" -> {
when (yourMove) {
"Y" -> 3
"X" -> 0
else -> 6
}
}
... | 0 | Kotlin | 0 | 0 | d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8 | 1,502 | Advent-of-code | Apache License 2.0 |
src/Day10.kt | jwklomp | 572,195,432 | false | {"Kotlin": 65103} | import kotlin.math.abs
data class SignalAcc(var registerX: Long, var sumSignal: Long)
data class PixelAcc(var registerX: Long, var pixels: MutableList<String>)
fun main() {
fun toCycles(input: List<String>) = input.map { it.split(" ") }
.flatMap { if (it.first() == "addx") listOf(0, it.last().toInt()) els... | 0 | Kotlin | 0 | 0 | 1b1121cfc57bbb73ac84a2f58927ab59bf158888 | 1,508 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day03.kt | arnoutvw | 572,860,930 | false | {"Kotlin": 33036} | fun main() {
val charslist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun part1(input: List<String>): Int {
return input.sumOf {
val middle = it.length / 2
val first = it.substring(0 until middle)
val second = it.substring(middle)
val interse... | 0 | Kotlin | 0 | 0 | 0cee3a9249fcfbe358bffdf86756bf9b5c16bfe4 | 1,132 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07_part2.kt | lowielow | 578,058,273 | false | {"Kotlin": 29322} | // calculate total size of outermost directory
fun calcOuterDir(list: MutableList<MutableList<String>>): Int {
var outerTotal = 0
for (i in list.indices) {
for (j in list[i].indices) {
if (list[i][j].toIntOrNull() != null) {
outerTotal += list[i][j].toInt()
}
... | 0 | Kotlin | 0 | 0 | acc270cd70a8b7f55dba07bf83d3a7e72256a63f | 3,533 | aoc2022 | Apache License 2.0 |
src/main/kotlin/dev/bogwalk/batch3/Problem31.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch3
import java.math.BigInteger
/**
* Problem 31: Coin Sums
*
* https://projecteuler.net/problem=31
*
* Goal: Count the number of ways (mod 1e9 + 7) that N pence can be made using any combination of
* English coins.
*
* Constraints: 1 <= N <= 1e5
*
* English currency: There are 8 type... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,044 | project-euler-kotlin | MIT License |
src/2022/Day10.kt | ttypic | 572,859,357 | false | {"Kotlin": 94821} | package `2022`
import readInput
fun main() {
fun part1(input: List<String>): Int {
var cycle = 0
var x = 1
val interestingCycles = setOf(20, 60, 100, 140, 180, 220)
return input.sumOf {
var result = 0
val commands = it.split(" ")
when(commands[0... | 0 | Kotlin | 0 | 0 | b3e718d122e04a7322ed160b4c02029c33fbad78 | 1,882 | aoc-2022-in-kotlin | Apache License 2.0 |
src/chapter5/section2/ex23_DuplicatesRevisitedAgain.kt | w1374720640 | 265,536,015 | false | {"Kotlin": 1373556} | package chapter5.section2
import chapter3.section5.LinearProbingHashSET
import chapter5.section1.Alphabet
import extensions.formatInt
import extensions.random
import extensions.spendTimeMillis
/**
* 重复元素(再续)
* 使用StringSET(请见练习5.2.6)代替HashSET重新完成练习3.5.30,比较两种方法的运行时间。
* 然后使用dedup为N=10⁷、10⁸和10⁹运行实验,用随机long型字符串重复实验并讨论... | 0 | Kotlin | 1 | 6 | 879885b82ef51d58efe578c9391f04bc54c2531d | 2,061 | Algorithms-4th-Edition-in-Kotlin | MIT License |
2019/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2019/day03/day03.kt | sanderploegsma | 224,286,922 | false | {"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171} | package nl.sanderp.aoc.aoc2019.day03
import nl.sanderp.aoc.aoc2019.IO
import kotlin.math.abs
enum class Direction { Up, Down, Left, Right }
data class Instruction(val direction: Direction, val steps: Int)
fun parse(instruction: String): Instruction {
val direction = when (instruction.first()) {
'U' -> Di... | 0 | C# | 0 | 6 | 8e96dff21c23f08dcf665c68e9f3e60db821c1e5 | 1,582 | advent-of-code | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDifficulty.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 | 5,833 | kotlab | Apache License 2.0 |
app/src/main/kotlin/com/jamjaws/adventofcode/xxiii/day/Day01.kt | JamJaws | 725,792,497 | false | {"Kotlin": 30656} | package com.jamjaws.adventofcode.xxiii.day
import com.jamjaws.adventofcode.xxiii.readInput
class Day01 {
private val spelledDigits = mapOf(
"one" to '1',
"two" to '2',
"three" to '3',
"four" to '4',
"five" to '5',
"six" to '6',
"seven" to '7',
"eigh... | 0 | Kotlin | 0 | 0 | e2683305d762e3d96500d7268e617891fa397e9b | 1,164 | advent-of-code-2023 | MIT License |
src/Day11.kt | vjgarciag96 | 572,719,091 | false | {"Kotlin": 44399} | private val INT_NUMBER = Regex("[0-9]+")
private val OPERATION = Regex("[*+] ([0-9]+|old)")
private sealed interface Operation {
data class Add(val arg1: Arg) : Operation
data class Multiply(val arg1: Arg) : Operation
sealed class Arg {
object Input : Arg()
data class Other(val value: Int)... | 0 | Kotlin | 0 | 0 | ee53877877b21166b8f7dc63c15cc929c8c20430 | 6,277 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestCommonSubPath.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 5,428 | kotlab | Apache License 2.0 |
src/day06/Solution.kt | abhabongse | 576,594,038 | false | {"Kotlin": 63915} | /* Solution to Day 6: Tuning Trouble
* https://adventofcode.com/2022/day/6
*/
package day06
import java.io.File
fun main() {
val fileName =
// "day06_sample_a.txt"
// "day06_sample_b.txt"
// "day06_sample_c.txt"
// "day06_sample_d.txt"
// "day06_sample_e.txt"
"day06_in... | 0 | Kotlin | 0 | 0 | 8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb | 2,137 | aoc2022-kotlin | Apache License 2.0 |
src/Day18.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | fun main() {
data class Cube(val x: Int, val y: Int, val z: Int)
fun part1(input: List<String>): Int {
val cubes = input.map {
val split = it.split(',').map { it.toInt() }
Cube(split[0], split[1], split[2])
}
var walls = 0
for (cube in cubes) {
... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 2,912 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day09.kt | allwise | 574,465,192 | false | null | import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
val rope = Rope(input)
return rope.process()
}
fun part2(input: List<String>): Int {
val rope = Rope(input)
return rope.process2()
}
// test if implementation meets criteria from the descri... | 0 | Kotlin | 0 | 0 | 400fe1b693bc186d6f510236f121167f7cc1ab76 | 3,627 | advent-of-code-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.