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/Day01.kt | elliaoster | 573,666,162 | false | {"Kotlin": 14556} | fun main() {
fun part1(input: List<String>): Int {
var max = 0
var elfLine = 0
for (line in input) {
if (line.isEmpty()) {
elfLine = 0
} else {
elfLine = elfLine + line.toInt()
if (elfLine > max) {
m... | 0 | Kotlin | 0 | 0 | 27e774b133f9d5013be9a951d15cefa8cb01a984 | 2,470 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/us/jwf/aoc2021/Day12PassagePathing.kt | jasonwyatt | 318,073,137 | false | null | package us.jwf.aoc2021
import java.io.Reader
import us.jwf.aoc.Day
/**
* AoC 2021 - Day 12
*/
class Day12PassagePathing : Day<Int, Int> {
override suspend fun executePart1(input: Reader): Int {
val graph = Graph()
input.readLines().forEach { graph.addEdge(it) }
return graph.countPathsToEnd(Cave("sta... | 0 | Kotlin | 0 | 0 | 0c92a62ba324aaa1f21d70b0f9f5d1a2c52e6868 | 2,766 | AdventOfCode-Kotlin | Apache License 2.0 |
src/day2.kt | SerggioC | 573,171,085 | false | {"Kotlin": 8824} | fun main() {
// A, X -> rock = 1
// B, Y -> paper = 2
// C, Z -> scissors = 3
val input: List<String> = readInput("day2")
var total = 0
input.forEach {
val game = it.split(" ")
val player2 = game[0]
when (game[1]) {
"X" -> total += getGameScoreForX(player2)
... | 0 | Kotlin | 0 | 0 | d56fb119196e2617868c248ae48dcde315e5a0b3 | 2,216 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2019/Day10.kt | tginsberg | 222,116,116 | false | null | /*
* Copyright (c) 2019 by <NAME>
*/
/**
* Advent of Code 2019, Day 10 - Monitoring Station
* Problem Description: http://adventofcode.com/2019/day/10
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2019/day10/
*/
package com.ginsberg.advent2019
class Day10(input: List<String>) {
priv... | 0 | Kotlin | 2 | 23 | a83e2ecdb6057af509d1704ebd9f86a8e4206a55 | 1,262 | advent-2019-kotlin | Apache License 2.0 |
src/main/kotlin/advent/week1/Dijkstra.kt | reitzig | 159,310,794 | false | null | package advent.week1
import java.util.*
/**
* Implements a simple form of Dijkstra's algorithm.
*/
object Dijkstra : ShortestPathSolver {
override fun shortestPath(maze: Labyrinth, source: Node, target: Node): List<Node> {
require(maze.contains(source) && maze.contains(target))
// Set up auxili... | 0 | Kotlin | 0 | 0 | 38911626f62bce3c59abe893afa8f15dc29dcbda | 2,693 | advent-of-kotlin-2018 | MIT License |
2019/task_13/src/main/kotlin/task_13/App.kt | romanthekat | 52,710,492 | false | {"Go": 90415, "Kotlin": 74230, "Python": 57300, "Nim": 22698, "Ruby": 7404, "Rust": 1516, "Crystal": 967} | package task_13
import java.io.File
import java.lang.RuntimeException
class App {
fun solveFirst(input: String): Int {
val tiles = HashMap<Point, Tile>()
val computer = IntcodeComputer(input)
while (!computer.isHalt) {
val x = computer.run()
val y = computer.run()... | 4 | Go | 0 | 0 | f410f71c3ff3e1323f29898c1ab39ad6858589bb | 11,033 | advent_of_code | MIT License |
src/main/kotlin/day20/Day20.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day20
import readResourceAsBufferedReader
fun main() {
println("part 1: ${part1(readResourceAsBufferedReader("20_1.txt").readLines())}")
//println("part 2: ${part2(readResourceAsBufferedReader("20_1.txt").readLines())}")
}
fun part1(input: List<String>): Int {
val nums = input.map { it.toInt() }
... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 1,828 | aoc-2022 | Apache License 2.0 |
src/day05/Day05.kt | kerchen | 573,125,453 | false | {"Kotlin": 137233} | package day05
import readInput
import java.util.regex.Pattern
class CargoBay(arrangement: List<String>, newerCrane: Boolean = false) {
val stacks = mutableListOf<ArrayDeque<Char>>()
init {
val it = arrangement.iterator()
// Parse initial layout
while (it.hasNext()) {
val ... | 0 | Kotlin | 0 | 0 | dc15640ff29ec5f9dceb4046adaf860af892c1a9 | 2,637 | AdventOfCode2022 | Apache License 2.0 |
intstar-mcalculus/src/main/kotlin/intstar/mcalculus/Prelude.kt | vikaskushwaha9oct | 276,676,290 | false | null | package intstar.mcalculus
import java.nio.ByteBuffer.wrap
import java.util.*
import kotlin.math.abs
typealias InputStream = java.io.InputStream
const val INFINITY = Double.POSITIVE_INFINITY
const val NEG_INFINITY = Double.NEGATIVE_INFINITY
fun <T> Iterable<T>.sumsToOne(valueFn: (T) -> Double): Boolean {
return... | 0 | Kotlin | 0 | 5 | 27ee78077690f2de1712a2b9f2ca6e4738162b56 | 4,518 | intstar | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MostPoints.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,413 | kotlab | Apache License 2.0 |
Day2/src/IntState.kt | gautemo | 225,219,298 | false | null | import java.io.File
fun main(){
val state = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText()
val arr = toArr(state)
part1(arr)
part2(arr)
}
fun part1(start: List<Int>){
val arr = start.toMutableList()
arr[1] = 12
arr[2] = 2
val output = outC... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 1,304 | AdventOfCode2019 | MIT License |
src/Main.kt | Arch-vile | 162,448,942 | false | null | import solutions.AreaSelection
import utils.*
fun main2(args: Array<String>) {
val solution = deserialize()
solution.sortedBy { routeLength(it) }.reversed()
.take(50).takeLast(10)
.forEachIndexed { index, route -> exportForGpsVizualizerTrack(index.toString(), route.stops) }
}
fun mai... | 0 | Kotlin | 0 | 0 | 03160a5ea318082a0995b08ba1f70b8101215ed7 | 1,441 | santasLittleHelper | Apache License 2.0 |
src/Day01.kt | pimts | 573,091,164 | false | {"Kotlin": 8145} | fun main() {
fun part1(input: String): Int {
return input.split("\n\n")
.maxOf { elf ->
elf.lines().sumOf { calories ->
calories.toInt()
}
}
}
fun part2(input: String): Int {
return input.split("\n\n")
.... | 0 | Kotlin | 0 | 0 | dc7abb10538bf6ad9950a079bbea315b4fbd011b | 812 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2016/2016-17.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2016
import com.github.ferinagy.adventOfCode.Coord2D
import com.github.ferinagy.adventOfCode.component1
import com.github.ferinagy.adventOfCode.component2
import com.github.ferinagy.adventOfCode.md5toBytes
import com.github.ferinagy.adventOfCode.searchGraph
import com.github... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 2,090 | advent-of-code | MIT License |
src/main/kotlin/com/polydus/aoc18/Day13.kt | Polydus | 160,193,832 | false | null | package com.polydus.aoc18
class Day13: Day(13){
//https://adventofcode.com/2018/day/13
val height = input.size
val width = input.sortedBy { it.length }.last().length
val map = Array(height) {CharArray(width){ ' '}}
val carts = arrayListOf<Point>()
init {
var i = 0
input.fo... | 0 | Kotlin | 0 | 0 | e510e4a9801c228057cb107e3e7463d4a946bdae | 5,786 | advent-of-code-2018 | MIT License |
src/main/kotlin/days/Solution02.kt | Verulean | 725,878,707 | false | {"Kotlin": 62395} | package days
import adventOfCode.InputHandler
import adventOfCode.Solution
import adventOfCode.util.PairOf
import kotlin.math.max
object Solution02 : Solution<List<String>>(AOC_YEAR, 2) {
enum class Color {
RED, GREEN, BLUE
}
private val colorMap = mapOf("red" to Color.RED, "green" to Color.GREEN... | 0 | Kotlin | 0 | 1 | 99d95ec6810f5a8574afd4df64eee8d6bfe7c78b | 1,258 | Advent-of-Code-2023 | MIT License |
difficultycalculator-app/app/src/main/java/com/stehno/difficulty/CombatantStore.kt | cjstehno | 143,009,387 | false | null | package com.stehno.difficulty
class CombatantStore(private val combatants: MutableList<Combatant> = mutableListOf()) {
// FIXME: should this be stored in DB? - not really something needed beyond app use so prob not
companion object {
private val xpForCr = mapOf(
Pair("0", 10), Pair("1/8",... | 1 | Kotlin | 0 | 1 | 5bfedc56ad901db11ac77a5a1a45a998ba979668 | 3,288 | dmtools | The Unlicense |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions54.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round1
import com.qiaoyuang.algorithm.round0.BinaryTreeNode
fun test54() {
printlnResult(testCase1(), 3)
printlnResult(testCase1(), 1)
printlnResult(testCase1(), 7)
printlnResult(testCase1(), 4)
}
/**
* Questions 54: Find the Kth smallest node in a Binary-search tree
... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,484 | Algorithm | Apache License 2.0 |
src/main/kotlin/days/Day8.kt | MaciejLipinski | 317,582,924 | true | {"Kotlin": 60261} | package days
import days.Operation.ACC
import days.Operation.JMP
import days.Operation.NOP
class Day8 : Day(8) {
override fun partOne(): Any {
val instructions = inputList.map { Instruction.from(it) }
val alreadyVisited = instructions.map { false }.toMutableList()
var i = 0
var acc... | 0 | Kotlin | 0 | 0 | 1c3881e602e2f8b11999fa12b82204bc5c7c5b51 | 3,214 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/ginsberg/advent2018/Day03.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 3 - No Matter How You Slice It
*
* Problem Description: http://adventofcode.com/2018/day/3
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day3/
*/
package com.ginsberg.advent2018
class Day03(rawInput: List<String>) ... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 1,831 | advent-2018-kotlin | MIT License |
packages/solutions/src/Day01.kt | ffluk3 | 576,832,574 | false | {"Kotlin": 21246, "Shell": 85} |
fun main() {
fun getElfCapacities(input: List<String>): List<Int> {
var allElfCapacities = mutableListOf<Int>()
var currentElfCapacity: Int = 0
input.forEach {
if (it.isEmpty()) {
allElfCapacities.add(currentElfCapacity)
currentElfCapacity = 0
... | 0 | Kotlin | 0 | 0 | f9b68a8953a7452d804990e01175665dffc5ab6e | 996 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/org/example/adventofcode/puzzle/Day01.kt | wcchristian | 712,668,434 | false | {"Kotlin": 5484} | package org.example.adventofcode.puzzle
import org.example.adventofcode.util.FileLoader
val numberMap = mapOf(
"one" to "1",
"two" to "2",
"three" to "3",
"four" to "4",
"five" to "5",
"six" to "6",
"seven" to "7",
"eight" to "8",
"nine" to "9"
)
object Day01 {
fun pa... | 0 | Kotlin | 0 | 0 | 8485b440dcd10b0399acbe9d6ae3ee9cf7f4d6ae | 2,123 | advent-of-code-2023 | MIT License |
src/main/kotlin/d21/d21.kt | LaurentJeanpierre1 | 573,454,829 | false | {"Kotlin": 118105} | package d21
import readInput
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import java.lang.NullPointerException
import java.util.Scanner
open class Monkey {
open fun res(): Long = 0
}
val monkeys = mutableMapOf<String, Monkey>()
data class MonkeyNumber(val nb: Long) : Monkey(... | 0 | Kotlin | 0 | 0 | 5cf6b2142df6082ddd7d94f2dbde037f1fe0508f | 3,246 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dev/shtanko/algorithms/leetcode/TrappingRainWater.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,394 | kotlab | Apache License 2.0 |
net.akehurst.language/agl-processor/src/commonMain/kotlin/collections/binaryHeapFifo.kt | dhakehurst | 197,245,665 | false | {"Kotlin": 3541898, "ANTLR": 64742, "Rascal": 17698, "Java": 14313, "PEG.js": 6866, "JavaScript": 5287, "BASIC": 22} | /**
* Copyright (C) 2021 Dr. <NAME> (http://dr.david.h.akehurst.net)
*
* 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... | 3 | Kotlin | 7 | 45 | 177abcb60c51efcfc2432174f5d6620a7db89928 | 8,338 | net.akehurst.language | Apache License 2.0 |
src/shreckye/coursera/algorithms/Course 3 Programming Assignment #4.kts | ShreckYe | 205,871,625 | false | {"Kotlin": 72136} | package shreckye.coursera.algorithms
import java.io.File
import kotlin.math.max
import kotlin.random.Random
import kotlin.system.measureNanoTime
import kotlin.test.assertEquals
data class Item(val value: Int, val weight: Int)
fun File.readKnapsackData() =
bufferedReader().use {
val (knapsackSize, numItem... | 0 | Kotlin | 1 | 2 | 1746af789d016a26f3442f9bf47dc5ab10f49611 | 6,672 | coursera-stanford-algorithms-solutions-kotlin | MIT License |
2022/src/main/kotlin/day17.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Parser
import utils.Solution
import utils.Vec2i
import utils.badInput
fun main() {
Day17.run()
}
object Day17 : Solution<String>() {
override val name = "day17"
override val parser = Parser { it.trim() }
private val rocks = listOf(
// ####
listOf(Vec2i(0, 0), Vec2i(1... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 3,262 | aoc_kotlin | MIT License |
src/main/kotlin/day09/Code.kt | fcolasuonno | 317,324,330 | false | null | package day09
import isDebug
import java.io.File
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
val size = if (isDebug()) 5 else 25
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/main/kotlin/$dir/$name").readLines()
val parsed = p... | 0 | Kotlin | 0 | 0 | e7408e9d513315ea3b48dbcd31209d3dc068462d | 1,276 | AOC2020 | MIT License |
src/aoc2017/kot/Day19.kt | Tandrial | 47,354,790 | false | null | package aoc2017.kot
import java.io.File
object Day19 {
fun solve(input: List<CharArray>): Pair<String, Int> {
var posX = input[0].indexOf('|')
var posY = 0
var dx = 0
var dy = 1
var count = 0
val sb = StringBuilder()
loop@ while (true) {
val currChar = input[posY][posX]
when... | 0 | Kotlin | 1 | 1 | 9294b2cbbb13944d586449f6a20d49f03391991e | 1,518 | Advent_of_Code | MIT License |
src/com/kingsleyadio/adventofcode/y2022/day08/Solution.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2022.day08
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val grid = buildGrid()
part1(grid)
part2(grid)
}
fun part1(grid: List<List<Int>>) {
// We could also use a boolean array as a shadow grid and do the counting explicitly
val visibleCe... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 5,027 | adventofcode | Apache License 2.0 |
src/Day13.kt | Aldas25 | 572,846,570 | false | {"Kotlin": 106964} | fun main() {
open class PacketList() {
val list: MutableList<PacketList> = mutableListOf()
override fun toString(): String {
var res = "["
for (p in list)
res += "$p,"
res += "]"
return res
}
override fun equals(other... | 0 | Kotlin | 0 | 0 | 80785e323369b204c1057f49f5162b8017adb55a | 4,905 | Advent-of-Code-2022 | Apache License 2.0 |
archive/673/solve.kt | daniellionel01 | 435,306,139 | false | null | /*
=== #673 Beds and Desks - Project Euler ===
At Euler University, each of the $n$ students (numbered from 1 to $n$) occupies a bed in the dormitory and uses a desk in the classroom.
Some of the beds are in private rooms which a student occupies alone, while the others are in double rooms occupied by two students as ... | 0 | Kotlin | 0 | 1 | 1ad6a549a0a420ac04906cfa86d99d8c612056f6 | 2,631 | euler | MIT License |
judge/src/main/kotlin/bluejam/hobby/gekitsui/judge/problem/floydalgorithmwarshall/solution.kt | blue-jam | 234,080,324 | false | null | package bluejam.hobby.gekitsui.judge.problem.floydalgorithmwarshall
import bluejam.hobby.gekitsui.judge.tool.JudgeSuite
import bluejam.hobby.gekitsui.judge.tool.validator.InStream
import bluejam.hobby.gekitsui.judge.tool.validator.InvalidFormatException
import org.springframework.stereotype.Component
import java.util.... | 14 | Kotlin | 0 | 0 | 36b446bbe2ea27bace0cb028ba76ede4fd0df00e | 2,886 | gekitsui-online-judge | Apache License 2.0 |
src/main/day6/Day06.kt | Derek52 | 572,850,008 | false | {"Kotlin": 22102} | package main.day6
import main.readInput
fun main() {
val input = readInput("day6/day6")
val firstHalf = false
//testAlg(firstHalf)
if (firstHalf) {
println(part1(input))
} else {
println(part2(input))
}
}
fun part1(input: List<String>) : Int {
val message = input[0]
... | 0 | Kotlin | 0 | 0 | c11d16f34589117f290e2b9e85f307665952ea76 | 1,423 | 2022AdventOfCodeKotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindKPairs.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,967 | kotlab | Apache License 2.0 |
src/main/kotlin/g2401_2500/s2440_create_components_with_same_value/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2401_2500.s2440_create_components_with_same_value
// #Hard #Array #Math #Depth_First_Search #Tree #Enumeration
// #2023_07_05_Time_751_ms_(100.00%)_Space_60.1_MB_(100.00%)
class Solution {
private lateinit var nums: IntArray
fun componentValue(nums: IntArray, edges: Array<IntArray>): Int {
v... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,618 | LeetCode-in-Kotlin | MIT License |
src/Day17.kt | mikrise2 | 573,939,318 | false | {"Kotlin": 62406} | import kotlin.math.absoluteValue
private operator fun Set<Pair<Int, Int>>.times(point: Pair<Int, Int>): Set<Pair<Int, Int>> =
map { Pair(it.first + point.first, it.second + point.second) }.toSet()
abstract class Shape(var x: Long, var y: Long, val map: Set<Pair<Long, Long>>) {
abstract val width: Long
abs... | 0 | Kotlin | 0 | 0 | d5d180eaf367a93bc038abbc4dc3920c8cbbd3b8 | 7,380 | Advent-of-code | Apache License 2.0 |
src/day15/Interval.kt | g0dzill3r | 576,012,003 | false | {"Kotlin": 172121} | package day15
data class Interval (val x0: Int, val x1: Int) {
fun touches (other: Interval): Boolean {
val (y0, y1) = other
if (x0 <= y0 && x1 >= y1) {
return true
}
if (x0 in y0 - 1 .. y1 + 1) {
return true
}
if (x1 in y0 - 1 .. y1 + 1) {
... | 0 | Kotlin | 0 | 0 | 6ec11a5120e4eb180ab6aff3463a2563400cc0c3 | 4,256 | advent_of_code_2022 | Apache License 2.0 |
src/main/kotlin/org/jetbrains/bio/statistics/Constraints.kt | karl-crl | 208,228,814 | true | {"Kotlin": 1021604} | package org.jetbrains.bio.statistics
import com.google.common.primitives.Ints
import java.util.*
/**
* A container for internal parameters used by pairwise comparison models.
*
* @author <NAME>
* @author <NAME>
* @since 16/08/14
*/
class Constraints (
/** Mapping from (dimension, state) pairs to equival... | 0 | Kotlin | 0 | 0 | 469bed933860cc34960a61ced4599862acbea9bd | 1,958 | bioinf-commons | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode/y2022/Day3.kt | clechasseur | 567,968,171 | false | {"Kotlin": 493887} | package io.github.clechasseur.adventofcode.y2022
import io.github.clechasseur.adventofcode.y2022.data.Day3Data
object Day3 {
private val input = Day3Data.input
fun part1(): Int = input.lines().sumOf { it.toRucksack().commonType.priority }
fun part2(): Int = input.lines().map { it.toRucksack() }.chunked(... | 0 | Kotlin | 0 | 0 | 7ead7db6491d6fba2479cd604f684f0f8c1e450f | 1,205 | adventofcode2022 | MIT License |
src/main/kotlin/days/aoc2021/Day18.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2021
import days.Day
import kotlin.math.ceil
class Day18 : Day(2021, 18) {
override fun partOne(): Any {
return calculateMagnitudeOfFinalSum(inputList)
}
override fun partTwo(): Any {
return findLargestMagnitudeOfPairs(inputList)
}
fun findLargestMagnitudeOfPairs(... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 6,713 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/Dec7.kt | karlstjarne | 572,529,215 | false | {"Kotlin": 45095} | import java.util.*
object Dec7 {
private const val DISK_SPACE = 70_000_000
private const val REQUIRED_SPACE = 30_000_000
private val fileStructure = hashMapOf<String, Node>()
fun a(): Int {
setup()
// Go through each node, find <= 100000
var totalSum = 0
fileStructure.... | 0 | Kotlin | 0 | 0 | 9220750bf71f39f693d129d170679f3be4328576 | 2,639 | AoC_2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FrogJump.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,759 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CreateBinaryTree.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,908 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/Subsets.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,005 | kotlab | Apache License 2.0 |
src/P12HighlyDivisibleTriangularNumber.kt | rhavran | 250,959,542 | false | null | fun main(args: Array<String>) {
println("Res: " + findSolution())
}
/**
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors o... | 0 | Kotlin | 0 | 0 | 11156745ef0512ab8aee625ac98cb6b7d74c7e92 | 1,196 | ProjectEuler | MIT License |
src/main/kotlin/Day09.kt | robfletcher | 724,814,488 | false | {"Kotlin": 18682} | class Day09 : Puzzle {
override fun test() {
val input = """
0 3 6 9 12 15
1 3 6 10 15 21
10 13 16 21 30 45""".trimIndent()
assert(part1(input.lineSequence()) == 114)
assert(part2(input.lineSequence()) == 2)
}
override fun part1(input: Sequence<String>) =
input.sumOf { line ->
... | 0 | Kotlin | 0 | 0 | cf10b596c00322ea004712e34e6a0793ba1029ed | 852 | aoc2023 | The Unlicense |
src/main/kotlin/me/circuitrcay/euler/challenges/twentySixToFifty/Problem31.kt | adamint | 134,989,381 | false | null | package me.circuitrcay.euler.challenges.twentySixToFifty
import me.circuitrcay.euler.Problem
class Problem31 : Problem<String>() {
override fun calculate(): Any {
var sum = 0
(0..200).forEach { one ->
(0..100).forEach { two ->
(0..40).forEach { five ->
... | 0 | Kotlin | 0 | 0 | cebe96422207000718dbee46dce92fb332118665 | 1,165 | project-euler-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDeletions.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,431 | kotlab | Apache License 2.0 |
src/main/kotlin/com/chimber/debtislav/util/Graph.kt | chimbersaw | 441,295,823 | false | {"Kotlin": 46382} | package com.chimber.debtislav.util
data class Edge<T>(val a: T, val b: T, var weight: Int)
class Graph<T>(edgesList: List<Edge<T>>) {
val edges: MutableList<Edge<T>>
private var start: T? = null
init {
val edgeMap = HashMap<Pair<T, T>, Int>()
for (edge in edgesList) {
edgeMap.... | 0 | Kotlin | 0 | 0 | be2459710d4fb05a659be8d0a33388f48a4d97fd | 2,512 | debtislav | Apache License 2.0 |
src/Day04.kt | ChristianNavolskyi | 573,154,881 | false | {"Kotlin": 29804} | class Day04 : Challenge<Int> {
override val name: String
get() = "Day 04"
override fun inputName(): String = "Day04"
override fun testInputName(): String = "Day04_test"
override fun testResult1(): Int = 2
override fun testResult2(): Int = 4
override fun part1(input: String): Int = i... | 0 | Kotlin | 0 | 0 | 222e25771039bdc5b447bf90583214bf26ced417 | 1,471 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/14/Day14.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`14`
import readInput
data class Point(
val x: Int,
val y: Int
)
sealed class Cell {
abstract val point: Point
data class Sand(
override val point: Point
) : Cell()
data class SandGenerator(
override val point: Point
) : Cell()
data class Rock(
... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 6,000 | KotlinAdventOfCode | Apache License 2.0 |
codeforces/src/main/kotlin/contest1911/F.kt | austin226 | 729,634,548 | false | {"Kotlin": 23837} | // https://codeforces.com/contest/1911/problem/F
private fun String.splitWhitespace() = split("\\s+".toRegex())
private fun <T> List<T>.counts(): Map<T, Int> = this.groupingBy { it }.eachCount()
fun idealUniqueWeights(weights: List<Int>): Set<Int> {
val uniqueWeights = mutableSetOf<Int>()
for (weight in weig... | 0 | Kotlin | 0 | 0 | 4377021827ffcf8e920343adf61a93c88c56d8aa | 1,138 | codeforces-kt | MIT License |
kotlin/src/com/daily/algothrim/leetcode/medium/SortColors.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.medium
/**
* 75. 颜色分类
*
* 给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。
* 此题中,我们使用整数 0、 1 和 2 分别表示红色、白色和蓝色。
*/
class SortColors {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val nums = intArrayOf(2, 0, 2, 1... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 1,734 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/utils/Collections.kt | Arch-vile | 317,641,541 | false | null | package utils
fun <T> subsets(collection: List<T>): List<List<T>> {
val subsets = mutableListOf<List<T>>()
val n: Int = collection.size
for (i in 0 until (1 shl n)) {
val subset = mutableListOf<T>()
for (j in 0 until n) {
if (i and (1 shl j) > 0) {
subset.add(collection[j])
}
}
... | 0 | Kotlin | 0 | 0 | 12070ef9156b25f725820fc327c2e768af1167c0 | 1,035 | adventOfCode2020 | Apache License 2.0 |
src/Day01.kt | guilherme | 574,434,377 | false | {"Kotlin": 7468} | fun main() {
fun elfScores(input: List<String>): List<Int> = input
.split { it.isBlank() }
.map { it.sumOf { it.toInt() } }
fun part1(input: List<String>): Int {
return elfScores(input).max()
}
fun part2(input: List<String>): Int {
return elfScores(input)
.sorted()
.takeLast(3)
... | 0 | Kotlin | 0 | 3 | dfc0cee1d023be895f265623bec130386ed12f05 | 651 | advent-of-code | Apache License 2.0 |
kotlin/MaxBipartiteMatchingEV.kt | indy256 | 1,493,359 | false | {"Java": 545116, "C++": 266009, "Python": 59511, "Kotlin": 28391, "Rust": 4682, "CMake": 571} | // https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs in O(V * E)
fun maxMatching(graph: Array<out List<Int>>, n2: Int): Int {
val n1 = graph.size
val vis = BooleanArray(n1)
val matching = IntArray(n2) { -1 }
val findPath = DeepRecursiveFunction { u1 ->
vis[u1]... | 97 | Java | 561 | 1,806 | 405552617ba1cd4a74010da38470d44f1c2e4ae3 | 823 | codelibrary | The Unlicense |
src/org/aoc2021/Day20.kt | jsgroth | 439,763,933 | false | {"Kotlin": 86732} | package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day20 {
private const val iterationsPart1 = 2
private const val iterationsPart2 = 50
data class Image(
val lit: Set<Pair<Int, Int>>,
val outOfBoundsLit: Boolean,
)
private fun solve(lines: List<String... | 0 | Kotlin | 0 | 0 | ba81fadf2a8106fae3e16ed825cc25bbb7a95409 | 2,692 | advent-of-code-2021 | The Unlicense |
src/commonMain/kotlin/com/github/d_costa/acacia/BinaryTree.kt | d-costa | 603,519,207 | false | null | package com.github.d_costa.acacia
data class BNode<T>(
val value: T,
val left: BNode<T>? = null,
val right: BNode<T>? = null
)
/**
* A Binary Tree
*
* Supports insertion, deletion, and iteration
*/
class BinaryTree<T : Comparable<T>>: Iterable<T> {
var root: BNode<T>? = null
fun insert(value... | 0 | Kotlin | 0 | 0 | 35aa2f394cfdbbb66e9a5055940a6e672b301b73 | 3,382 | acacia | The Unlicense |
advent-of-code-2023/src/main/kotlin/Point.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | import kotlin.math.abs
data class Point(val x: Int, val y: Int)
fun <T : Any> Map<Point, T>.lines(
invertedY: Boolean = true,
prefixFun: (Int) -> String = { "" },
func: Point.(T?) -> String = { "${it ?: " "}" }
): List<String> {
val maxX = keys.maxOf { it.x }
val minX = keys.minOf { it.x }
val maxY ... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 1,923 | advent-of-code | MIT License |
src/main/kotlin/g1001_1100/s1036_escape_a_large_maze/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1001_1100.s1036_escape_a_large_maze
// #Hard #Array #Hash_Table #Depth_First_Search #Breadth_First_Search
// #2023_05_25_Time_387_ms_(100.00%)_Space_94.1_MB_(100.00%)
class Solution {
fun isEscapePossible(blocked: Array<IntArray>, source: IntArray, target: IntArray): Boolean {
if (blocked.isEmpty... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,602 | LeetCode-in-Kotlin | MIT License |
src/Day01.kt | dmstocking | 575,012,721 | false | {"Kotlin": 40350} | fun main() {
fun part1(input: List<String>): Int {
val grouped = mutableListOf<MutableList<Int>>()
grouped.add(mutableListOf())
input.forEach {
if (it.isBlank()) {
grouped.add(mutableListOf())
} else {
grouped[grouped.size-1].add(it.toI... | 0 | Kotlin | 0 | 0 | e49d9247340037e4e70f55b0c201b3a39edd0a0f | 1,060 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day02.kt | cak | 573,455,947 | false | {"Kotlin": 8236} | enum class RockPaperScissors(val bonus: Int) {
ROCK(1), PAPER(2), SCISSORS(3)
}
enum class End(val score: Int) {
LOSE(0), DRAW(3), WIN(6)
}
fun main() {
fun letterToRPS(item: String): RockPaperScissors? {
return when (item) {
"A", "X" -> RockPaperScissors.ROCK
"B", "Y" -> ... | 0 | Kotlin | 0 | 1 | cab2dffae8c1b78405ec7d85e328c514a71b21f1 | 3,432 | advent-of-code-2022 | Apache License 2.0 |
Problem Solving/Algorithms/Basic - The Hurdle Race.kt | MechaArms | 525,331,223 | false | {"Kotlin": 30017} | /*
A video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by 1 unit for each dose. How many doses of the potion must the chara... | 0 | Kotlin | 0 | 1 | eda7f92fca21518f6ee57413138a0dadf023f596 | 2,017 | My-HackerRank-Solutions | MIT License |
src/main/kotlin/at/doml/anc/lab1/MutableMatrix.kt | domagojlatecki | 124,923,523 | false | null | package at.doml.anc.lab1
import java.io.File
import java.util.Arrays
class MutableMatrix constructor(rows: Int, columns: Int) : Matrix {
init {
if (rows <= 0 || columns <= 0) {
throw IllegalArgumentException("invalid matrix dimensions provided: [$rows, $columns]")
}
}
private... | 0 | Kotlin | 0 | 0 | b483dda88bd9f2a6dc9f4928c7aa4e9a217eac8f | 3,969 | anc-lab | MIT License |
solutions/src/solutions/y20/day 24.kt | Kroppeb | 225,582,260 | false | null | @file:Suppress("PackageDirectoryMismatch")
package solutions.y20.d24
import collections.counter
import grid.Clock
import helpers.Lines
import helpers.getLines
import helpers.toP
val xxxxx = Clock(6, 3);
private fun part1(data: Data) {
val points = data.map { line ->
var i = 0
var p = 0 toP 0
println(line)
... | 0 | Kotlin | 0 | 1 | 744b02b4acd5c6799654be998a98c9baeaa25a79 | 1,949 | AdventOfCodeSolutions | MIT License |
src/main/kotlin/d4_GiantSquid/GiantSquid.kt | aormsby | 425,644,961 | false | {"Kotlin": 68415} | package d4_GiantSquid
import util.CollectionHelper
import util.Input
import util.Output
var boardSize = 0
fun main() {
Output.day(4, "Giant Squid")
val startTime = Output.startTime()
var bingoDrawings: List<Int>
var bingoBoards = mutableListOf<BingoBoard>()
// set up number call and board colle... | 0 | Kotlin | 1 | 1 | 193d7b47085c3e84a1f24b11177206e82110bfad | 3,193 | advent-of-code-2021 | MIT License |
findPositionElementArrayInfiniteLength.kt | prashantsinghpaliwal | 537,191,958 | false | {"Kotlin": 9473} | // Question Link - https://www.geeksforgeeks.org/find-position-element-sorted-array-infinite-numbers/
/* In this problem, since the array is of infinite length, we dont know the length
and hence wont make use of arr.length
- We will reverse the binary search approach to find a window
or range in which the targ... | 0 | Kotlin | 0 | 0 | e66599817508beb4e90de43305939d200a9e3964 | 2,029 | DsAlgo | Apache License 2.0 |
src/main/kotlin/com/thedevadventure/roverkata/RoverKata.kt | EduanPrinsloo | 549,216,876 | false | {"Kotlin": 12299} | package com.thedevadventure.roverkata
import java.util.*
fun main() {
val scanner = Scanner(System.`in`)
// Get and validate the plateau
println("Please enter the dimensions of your plateau starting with the size of X?")
val plateauDimensionsX = scanner.nextInt()
println("And the size of Y?")
v... | 0 | Kotlin | 0 | 0 | 5ee857f548921b79f3184cff5f2f83956d8521b9 | 4,782 | RoverKata | Apache License 2.0 |
day1/src/main/kotlin/com/nohex/aoc/day1/Solution.kt | mnohe | 433,396,563 | false | {"Kotlin": 105740} | package com.nohex.aoc.day1
import com.nohex.aoc.PuzzleInput
fun main() {
println("Day 1, part 1: " + Solution().count(getInput()))
println("Day 1, part 2: " + Solution().countWindows(getInput()))
}
private fun getInput() =
PuzzleInput("input.txt")
.asSequence()
.filter(String::isNotBlank)
... | 0 | Kotlin | 0 | 0 | 4d7363c00252b5668c7e3002bb5d75145af91c23 | 1,993 | advent_of_code_2021 | MIT License |
src/leetcodeProblem/leetcode/editor/en/HammingDistance.kt | faniabdullah | 382,893,751 | false | null | //The Hamming distance between two integers is the number of positions at which
//the corresponding bits are different.
//
// Given two integers x and y, return the Hamming distance between them.
//
//
// Example 1:
//
//
//Input: x = 1, y = 4
//Output: 2
//Explanation:
//1 (0 0 0 1)
//4 (0 1 0 0)
// ↑ ... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 1,406 | dsa-kotlin | MIT License |
leetcode-75-kotlin/src/main/kotlin/DecodeString.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given an encoded string, return its decoded string.
*
* The encoding rule is: k[encoded_string],
* where the encoded_string inside the square brackets is being repeated exactly k times.
* Note that k is guaranteed to be a positive integer.
*
* You may assume that the input string is always valid;
* there ... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 2,034 | leetcode-75 | Apache License 2.0 |
src/2021/Day04.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2021`
import java.io.File
import java.util.*
fun main() {
Day04().solve()
}
data class BingoResult(val turn: Int, val score: Int)
class BingoBoard(s: Scanner) {
data class BingoField(val number: Int, var isDrawn: Boolean = false)
val numbers = List(25){BingoField(s.nextInt())}
val numberMap... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 2,070 | advent-of-code | Apache License 2.0 |
src/main/day05/Day05.kt | rolf-rosenbaum | 543,501,223 | false | {"Kotlin": 17211} | package day05
import readInput
fun part1(input: List<String>): Int {
return input.first().process().length
}
fun part2(input: List<String>): Int {
return ('a'..'z').map { c ->
c to input.first().filterNot {
c.lowercase() == it.lowercase()
}.process().apply { println("'$c' done: $l... | 0 | Kotlin | 0 | 0 | dfd7c57afa91dac42362683291c20e0c2784e38e | 1,096 | aoc-2018 | Apache License 2.0 |
src/commonMain/kotlin/org/petitparser/core/parser/consumer/CharPredicate.kt | petitparser | 541,100,427 | false | {"Kotlin": 114391} | package org.petitparser.core.parser.consumer
import org.petitparser.core.parser.action.map
import org.petitparser.core.parser.combinator.or
import org.petitparser.core.parser.combinator.seqMap
import org.petitparser.core.parser.misc.end
import org.petitparser.core.parser.parse
import org.petitparser.core.parser.repeat... | 1 | Kotlin | 1 | 5 | 349522c37813e7714f66af4ed27db0b5750dd6f0 | 4,089 | kotlin-petitparser | MIT License |
day21/kotlin/RJPlog/day2021_1_2.kts | smarkwart | 317,009,367 | true | {"Python": 528881, "Rust": 179510, "Kotlin": 92549, "Ruby": 59698, "TypeScript": 57721, "Groovy": 56394, "CSS": 38649, "Java": 36866, "JavaScript": 27433, "HTML": 5424, "Dockerfile": 3230, "C++": 2171, "Go": 1733, "Jupyter Notebook": 988, "Shell": 897, "Clojure": 567, "PHP": 68, "Tcl": 46, "Dart": 41, "Haskell": 37} | import java.io.File
// tag::allergen_2[]
fun allergen_2(): String {
// tag::read_puzzle[]
var food_ingredients = mutableMapOf<Int, List<String>>()
var food_allergens = mutableMapOf<Int, List<String>>()
var allergen_list = mutableMapOf<String, String>()
var food: Int = 0
File("day2021_puzzle_input.txt").forEac... | 0 | Python | 0 | 0 | b1f9e04177afaf7e7c15fdc7bf7bc76f27a029f6 | 4,687 | aoc-2020 | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-23.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2015
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2015, "23-input")
val test1 = readInputLines(2015, "23-test1")
println("Part1:")
part1(test1).println()
p... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 3,498 | advent-of-code | MIT License |
src/main/kotlin/tr/emreone/kotlin_utils/extensions/Sequences.kt | EmRe-One | 442,916,831 | false | {"Kotlin": 173543} | import tr.emreone.kotlin_utils.extensions.minMaxOrNull
import tr.emreone.kotlin_utils.extensions.safeTimes
class InfiniteSequence<T>(base: Sequence<T>) : Sequence<T> by base
fun <T> Iterable<T>.asInfiniteSequence() =
InfiniteSequence(sequence { while (true) yieldAll(this@asInfiniteSequence) })
fun <T> Sequence<T... | 0 | Kotlin | 0 | 0 | aee38364ca1827666949557acb15ae3ea21881a1 | 1,841 | kotlin-utils | Apache License 2.0 |
2020/Day12/src/main/kotlin/main.kt | airstandley | 225,475,112 | false | {"Python": 104962, "Kotlin": 59337} | import java.io.File
import kotlin.math.*
fun getInput(filename: String): List<String> {
return File(filename).readLines()
}
const val NORTH = 'N'
const val SOUTH = 'S'
const val EAST = 'E'
const val WEST = 'W'
const val TURN_LEFT = 'L'
const val TURN_RIGHT = 'R'
const val FORWARD = 'F'
fun getManhattanDistance(e... | 0 | Python | 0 | 0 | 86b7e289d67ba3ea31a78f4a4005253098f47254 | 3,068 | AdventofCode | MIT License |
Kotlin/problems/0049_unique_paths_iii.kt | oxone-999 | 243,366,951 | true | {"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187} | //Problem Statement
// On a 2-dimensional grid, there are 4 types of squares:
//
// * 1 represents the starting square. There is exactly one starting square.
// * 2 represents the ending square. There is exactly one ending square.
// * 0 represents empty squares we can walk over.
// * -1 represents obstacles that we ... | 0 | null | 0 | 0 | 52dc527111e7422923a0e25684d8f4837e81a09b | 1,981 | algorithms | MIT License |
src/main/kotlin/machines/FSMMinimizer.kt | Niksen111 | 736,732,938 | false | {"Kotlin": 16917} | package machines
class FSMMinimizer {
companion object {
fun minimize(fsm: FiniteStateMachine): FiniteStateMachine {
val achievableStates = findAchievableStates(fsm)
val classes = extractKEquivalenceClasses(achievableStates, 0, fsm)
val states = classes.map { it.joinToS... | 0 | Kotlin | 0 | 1 | 7cb9dd0072fc2c4cc11b893de4d5f9d4092d9213 | 7,938 | formalki-referat | Apache License 2.0 |
src/main/kotlin/days/Day3.kt | hughjdavey | 317,575,435 | false | null | package days
class Day3 : Day(3) {
private val trees = TreeGrid(inputList.map { it.trim() })
// 237
override fun partOne(): Any {
return trees.path(3, 1).count { it == '#' }
}
// 2106818610
override fun partTwo(): Any {
return listOf(1 to 1, 3 to 1, 5 to 1, 7 to 1, 1 to 2)
... | 0 | Kotlin | 0 | 1 | 63c677854083fcce2d7cb30ed012d6acf38f3169 | 882 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day20.kt | butnotstupid | 433,717,137 | false | {"Kotlin": 55124} | package days
class Day20 : Day(20) {
private val padx = 250
private val pady = 250
override fun partOne(): Any {
return extendImage(inputList, 2)
}
override fun partTwo(): Any {
return extendImage(inputList, 50)
}
private fun extendImage(inputList: List<String>, stepsNum... | 0 | Kotlin | 0 | 0 | a06eaaff7e7c33df58157d8f29236675f9aa7b64 | 1,633 | aoc-2021 | Creative Commons Zero v1.0 Universal |
utility/src/main/java/org/oppia/android/util/math/ComparatorExtensions.kt | oppia | 148,093,817 | false | {"Kotlin": 12174721, "Starlark": 666467, "Java": 33231, "Shell": 12716} | package org.oppia.android.util.math
import com.google.protobuf.MessageLite
/**
* Compares two [Iterable]s based on an item [Comparator] and returns the result.
*
* The two [Iterable]s are iterated in an order determined by [Comparator], and then compared
* element-by-element. If any element is different, the diff... | 508 | Kotlin | 491 | 285 | 4a07d8db69e395c9e076c342c0d1dc3521ff3051 | 3,475 | oppia-android | Apache License 2.0 |
src/main/kotlin/leetcode/kotlin/dp/53. Maximum Subarray.kt | sandeep549 | 251,593,168 | false | null | package leetcode.kotlin.dp
/**
1. Optimal structure
f(n) = MAX(f(n-1), f`(n-1) + arr[n], arr[n])
f`(i) = MAX(f`(i-1), 0) + arr[i]
Legends:
f(n) = max sum including and excluding index n
f`(n) = max sum including index n
arr[n] = element at index n in given array
2. sub-problems calls tree for f(4), depicting overlap... | 0 | Kotlin | 0 | 0 | 9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b | 1,688 | kotlinmaster | Apache License 2.0 |
src/main/aoc2018/Day16.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2018
import aoc2018.Day16.InstructionName.*
class Day16(input: List<String>) {
data class Example(val before: List<Int>, val after: List<Int>, val instruction: Instruction)
data class Instruction(val opcode: Int, val a: Int, val b: Int, val output: Int)
enum class InstructionName {
ADD... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 5,737 | aoc | MIT License |
src/main/kotlin/g1801_1900/s1802_maximum_value_at_a_given_index_in_a_bounded_array/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1801_1900.s1802_maximum_value_at_a_given_index_in_a_bounded_array
// #Medium #Greedy #Binary_Search #Binary_Search_II_Day_17
// #2023_06_19_Time_118_ms_(100.00%)_Space_33.8_MB_(13.82%)
class Solution {
private fun isPossible(n: Int, index: Int, maxSum: Int, value: Int): Boolean {
val leftValue = ... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,039 | LeetCode-in-Kotlin | MIT License |
year2019/src/main/kotlin/net/olegg/aoc/year2019/day6/Day6.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2019.day6
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2019.DayOf2019
/**
* See [Year 2019, Day 6](https://adventofcode.com/2019/day/6)
*/
object Day6 : DayOf2019(6) {
override fun first(): Any? {
val orbits = lines
.mapTo(mutableListOf()) { line -> line.split(... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,394 | adventofcode | MIT License |
src/day17/Day17.kt | spyroid | 433,555,350 | false | null | package day17
import kotlin.math.absoluteValue
import kotlin.system.measureTimeMillis
class Simulation(val x1: Int, val x2: Int, val y1: Int, val y2: Int) {
data class Bullet(var dx: Int, var dy: Int, var x: Int = 0, var y: Int = 0) {
var maxY = y
fun step() {
x += dx
y ... | 0 | Kotlin | 0 | 0 | 939c77c47e6337138a277b5e6e883a7a3a92f5c7 | 1,471 | Advent-of-Code-2021 | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day18/day18.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day18
import biz.koziolek.adventofcode.*
import java.util.*
import kotlin.math.ceil
import kotlin.math.floor
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val numbers = parseSnailfishNumbers(lines)
val s... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 15,188 | advent-of-code | MIT License |
src/main/kotlin/ru/timakden/aoc/year2015/Day03.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2015
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 3: Perfectly Spherical Houses in a Vacuum](https://adventofcode.com/2015/day/3).
*/
object Day03 {
@JvmStatic
fun main(args: Array<String>) {
measure {
val input = readIn... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 1,447 | advent-of-code | MIT License |
foundations/merge-sort-with-insertion/Main.kt | ivan-magda | 102,283,964 | false | null | import java.util.*
fun insertionSort(array: Array<Int>) {
insertionSort(array, 1, array.lastIndex)
}
fun insertionSort(array: Array<Int>, start: Int, end: Int) {
val startIndex: Int = if (start >= 1) {
start
} else {
1
}
for (i in startIndex..end) {
val key = array[i]
... | 0 | Kotlin | 0 | 2 | da06ec75cbd06c8e158aec86ca813e72bd22a2dc | 2,000 | introduction-algorithms | MIT License |
grind-75-kotlin/src/main/kotlin/ValidPalindrome.kt | Codextor | 484,602,390 | false | {"Kotlin": 27206} | /**
* A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters,
* it reads the same forward and backward. Alphanumeric characters include letters and numbers.
*
* Given a string s, return true if it is a palindrome, or false otherwise.
... | 0 | Kotlin | 0 | 0 | 87aa60c2bf5f6a672de5a9e6800452321172b289 | 1,445 | grind-75 | Apache License 2.0 |
src/questions/GenerateParentheses.kt | realpacific | 234,499,820 | false | null | package questions
import _utils.UseCommentAsDocumentation
import utils.assertIterableSameInAnyOrder
/**
* Given `n` pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
*
* [Source](https://leetcode.com/problems/generate-parentheses/)
*/
@UseCommentAsDocumentation
privat... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 2,065 | algorithms | MIT License |
src/main/kotlin/day9/Day9.kt | stoerti | 726,442,865 | false | {"Kotlin": 19680} | package io.github.stoerti.aoc.day9
import io.github.stoerti.aoc.IOUtils
import io.github.stoerti.aoc.MathUtils
import io.github.stoerti.aoc.StringExt.longValues
import kotlin.math.abs
fun main(args: Array<String>) {
val lines = IOUtils.readInput("day_9_input").map { it.longValues() }
val result1 = lines.sumOf { ... | 0 | Kotlin | 0 | 0 | 05668206293c4c51138bfa61ac64073de174e1b0 | 1,212 | advent-of-code | Apache License 2.0 |
src/main/kotlin/days/aoc2021/Day1.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2021
import days.Day
class Day1 : Day(2021, 1) {
override fun partOne(): Any {
return countIncreasingPairs(inputList.map { it.toInt() })
}
fun countIncreasingPairs(list: List<Int>): Int {
return pairs(list)
.filter { pair -> pair.first < pair.second }
... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 1,067 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
leetcode/src/offer/Offer012.kt | zhangweizhe | 387,808,774 | false | null | package offer
fun main() {
// https://leetcode-cn.com/problems/tvdfij/
// 剑指 Offer II 012. 左右两边子数组的和相等
println(pivotIndex1(intArrayOf(1,7,3,6,5,6)))
}
private fun pivotIndex(nums: IntArray): Int {
val leftSums = IntArray(nums.size)
val rightSums = IntArray(nums.size)
leftSums[0] = nums[0]
... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 944 | kotlin-study | MIT License |
src/main/kotlin/day01/Day01.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day01
import byEmptyLines
import readResourceAsBufferedReader
import java.util.PriorityQueue
fun main() {
println("part 1: ${part1(readResourceAsBufferedReader("1_1.txt").readLines())}")
println("part 2: ${part2(readResourceAsBufferedReader("1_1.txt").readLines())}")
}
fun parseElf(elf: String): Elf ... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 1,298 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/day09/Day09.kt | vitalir2 | 572,865,549 | false | {"Kotlin": 89962} | package day09
import Challenge
import utils.Coordinates
import kotlin.math.absoluteValue
import kotlin.math.sign
object Day09 : Challenge(9) {
override fun part1(input: List<String>): Any {
return modelRopeMovement(input, ROPE_LENGTH_PART_1)
}
override fun part2(input: List<String>): Any {
... | 0 | Kotlin | 0 | 0 | ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6 | 2,517 | AdventOfCode2022 | Apache License 2.0 |
src/y2022/Day09.kt | Yg0R2 | 433,731,745 | false | null | package y2022
import DayX
import y2022.Day09.Direction.D
import y2022.Day09.Direction.L
import y2022.Day09.Direction.R
import y2022.Day09.Direction.U
import kotlin.math.abs
class Day09 : DayX<Int>(listOf(13), listOf(1, 36)) {
override fun part1(input: List<String>): Int {
val rope = Rope(2)
inpu... | 0 | Kotlin | 0 | 0 | d88df7529665b65617334d84b87762bd3ead1323 | 2,914 | advent-of-code | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.