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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
day24/src/main/kotlin/ver_b.kt | jabbalaci | 115,397,721 | false | null | package b
import java.io.File
val NOT_FOUND = -1
val LEFT = 0
val RIGHT = 1
data class Component(val id: Int, val line: String) {
var left : Int
var right : Int
init {
val parts = line.split("/")
left = parts[0].toInt()
right = parts[1].toInt()
}
fun swap() {
va... | 0 | Kotlin | 0 | 0 | bce7c57fbedb78d61390366539cd3ba32b7726da | 3,130 | aoc2017 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/TaskScheduler.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,023 | kotlab | Apache License 2.0 |
src/main/kotlin/com/jaspervanmerle/aoc2020/day/Day07.kt | jmerle | 317,518,472 | false | null | package com.jaspervanmerle.aoc2020.day
class Day07 : Day("289", "30055") {
private data class Bag(val color: String, val contents: Map<String, Int>) {
fun contains(targetColor: String, bags: Map<String, Bag>): Boolean {
return contents.keys.any { it == targetColor || bags.getValue(it).contains(... | 0 | Kotlin | 0 | 0 | 81765a46df89533842162f3bfc90f25511b4913e | 1,324 | advent-of-code-2020 | MIT License |
src/Day03.kt | ajesh-n | 573,125,760 | false | {"Kotlin": 8882} | fun main() {
fun Char.toPriority(): Int {
return if (this.isUpperCase()) {
code - 38
} else {
code - 96
}
}
fun part1(input: List<String>): Int {
return input.map { it.chunked(it.count() / 2) }.sumOf {
it.first().first { itemType -> itemTy... | 0 | Kotlin | 0 | 0 | 2545773d7118da20abbc4243c4ccbf9330c4a187 | 836 | kotlin-aoc-2022 | Apache License 2.0 |
src/Day09.kt | brigittb | 572,958,287 | false | {"Kotlin": 46744} | fun main() {
fun getMoves(input: List<String>) = input
.filter { it.isNotEmpty() }
.map {
Movement(
direction = it.substringBefore(" ").first(),
step = it.substringAfter(" ").toInt(),
)
}
fun getSize(moves: List<Movement>, directi... | 0 | Kotlin | 0 | 0 | 470f026f2632d1a5147919c25dbd4eb4c08091d6 | 5,987 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day03.kt | Vampire | 572,990,104 | false | {"Kotlin": 57326} | fun main() {
val priorities = ('a'..'z') + ('A'..'Z')
fun part1(input: List<String>) = input
.flatMap {
it
.chunkedSequence(it.length / 2)
.map(String::toCharArray)
.reduce { a, b -> a.intersect(b.asIterable().toSet()).toCharArray() }
... | 0 | Kotlin | 0 | 0 | 16a31a0b353f4b1ce3c6e9cdccbf8f0cadde1f1f | 995 | aoc-2022 | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/reverse_nodes_in_k_group/ReverseNodesInKGroup.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.reverse_nodes_in_k_group
import katas.kotlin.leetcode.ListNode
import katas.kotlin.leetcode.listNodes
import datsok.shouldEqual
import org.junit.Test
class ReverseNodesInKGroupTests {
@Test fun `reverse the nodes of a linked list k at a time`() {
listNodes(1).reverseGroup(1) ... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 2,224 | katas | The Unlicense |
src/main/kotlin/advent/of/code/day15/Solution.kt | brunorene | 160,263,437 | false | null | package advent.of.code.day15
import java.io.File
import java.util.*
import kotlin.collections.LinkedHashSet
import kotlin.math.abs
data class Position(val x: Int, val y: Int) : Comparable<Position> {
override fun compareTo(other: Position): Int {
return compareBy<Position>({ it.y }, { it.x }).compare(this... | 0 | Kotlin | 0 | 0 | 0cb6814b91038a1ab99c276a33bf248157a88939 | 5,738 | advent_of_code_2018 | The Unlicense |
lab11/src/main/kotlin/cs/put/pmds/lab11/Main.kt | Azbesciak | 153,350,976 | false | null | package cs.put.pmds.lab11
import com.carrotsearch.hppc.IntHashSet
import cs.put.pmds.lab10.MinHash
import cs.put.pmds.lab10.generateMinHashes
import cs.put.pmds.lab9.*
import java.io.File
import java.math.BigDecimal
import java.math.RoundingMode
import java.util.stream.Stream
import kotlin.math.ceil
import kotlin.math... | 0 | Kotlin | 0 | 0 | f1d3cf4d51ad6588e39583f7b958c92b619799f8 | 3,822 | BigDataLabs | MIT License |
src/Day04.kt | olezhabobrov | 572,687,414 | false | {"Kotlin": 27363} | fun main() {
fun part1(input: List<String>): Int {
return input.count { line ->
val (a, b, c, d) = line.split(",", "-").map { it.toInt() }
assert(a <= b && c <= d)
a <= c && b >= d || a >=c && b <= d
}
}
fun part2(input: List<String>): Int {
retur... | 0 | Kotlin | 0 | 0 | 31f2419230c42f72137c6cd2c9a627492313d8fb | 772 | AdventOfCode | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2022/day23/Day23.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day23
import com.jacobhyphenated.advent2022.Day
/**
* Day 23: Unstable Diffusion
*
* The elves need to spread out to plant new trees.
* The puzzle input is all the elves starting locations.
* The elves look in a certain order of directions: (north,south,west,east) to determ... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 5,272 | advent2022 | The Unlicense |
src/Day14.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | import kotlin.math.max
import kotlin.math.min
class Location(var x: Int, var y: Int, var type: Char = Type.AIR) {
override fun toString(): String {
return "($x, $y)"
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Location)
ret... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 4,316 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g1901_2000/s1923_longest_common_subpath/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1901_2000.s1923_longest_common_subpath
// #Hard #Array #Binary_Search #Hash_Function #Rolling_Hash #Suffix_Array
// #2023_06_20_Time_1142_ms_(100.00%)_Space_71.9_MB_(100.00%)
@Suppress("UNUSED_PARAMETER")
class Solution {
private lateinit var pow: LongArray
fun longestCommonSubpath(n: Int, paths: Ar... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,969 | LeetCode-in-Kotlin | MIT License |
src/Day18.kt | dakr0013 | 572,861,855 | false | {"Kotlin": 105418} | import kotlin.test.assertEquals
fun main() {
fun part1(input: List<String>): Int {
val lavaDroplet = LavaDroplet.parse(input)
return lavaDroplet.surfaceArea()
}
fun part2(input: List<String>): Int {
val lavaDroplet = LavaDroplet.parse(input)
return lavaDroplet.surfaceAreaAccountingAirPockets()
... | 0 | Kotlin | 0 | 0 | 6b3adb09f10f10baae36284ac19c29896d9993d9 | 3,271 | aoc2022 | Apache License 2.0 |
src/Utils.kt | akijowski | 574,262,746 | false | {"Kotlin": 56887, "Shell": 101} | import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
/**
* Reads entire input txt file.
*/
fun readInputAsText(name: String) = File("src", "$name.txt").readText... | 0 | Kotlin | 1 | 0 | 84d86a4bbaee40de72243c25b57e8eaf1d88e6d1 | 3,365 | advent-of-code-2022 | Apache License 2.0 |
day13/src/main/kotlin/com/lillicoder/adventofcode2023/day13/Day13.kt | lillicoder | 731,776,788 | false | {"Kotlin": 98872} | package com.lillicoder.adventofcode2023.day13
import com.lillicoder.adventofcode2023.grids.Grid
import com.lillicoder.adventofcode2023.grids.GridParser
import com.lillicoder.adventofcode2023.grids.Node
fun main() {
val day13 = Day13()
val grids = GridParser().parseFile("input.txt")
println("Sum of reflect... | 0 | Kotlin | 0 | 0 | 390f804a3da7e9d2e5747ef29299a6ad42c8d877 | 5,602 | advent-of-code-2023 | Apache License 2.0 |
src/main/kotlin/day16/Day16.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day16
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day16/Day16.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 16 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 3,332 | advent-of-code-2022 | MIT License |
usvm-util/src/main/kotlin/org/usvm/algorithms/RandomizedPriorityCollection.kt | UnitTestBot | 586,907,774 | false | {"Kotlin": 2547205, "Java": 471958} | package org.usvm.algorithms
/**
* [UPriorityCollection] implementation which peeks elements randomly with distribution based on priority.
*
* Implemented with tree set in which each node contains sum of its children weights (priorities).
*
* To peek an element, a random point in interval [[0..sum of all leaf weig... | 39 | Kotlin | 0 | 7 | 94c5a49a0812737024dee5be9d642f22baf991a2 | 2,473 | usvm | Apache License 2.0 |
Kotlin/problem011.kt | emergent | 116,013,843 | false | null | // Problem 11 - Project Euler
// http://projecteuler.net/index.php?section=problems&id=11
fun main(args: Array<String>) {
val d = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52... | 0 | Rust | 0 | 0 | d04f5029385c09a569c071254191c75d582fe340 | 1,991 | ProjectEuler | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinCostClimbingStairs.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2020 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,058 | kotlab | Apache License 2.0 |
original/Kotlin/KtHelloPrime.kt | alexy2008 | 242,878,207 | false | null | import kotlin.math.ceil
import kotlin.math.pow
fun primeByEuler(page: Int, prime: KtPrime) {
val num = BooleanArray(page)
for (i in 2 until page) {
if (!num[i]) prime.add(i.toLong())
for (j in 0 until prime.size() ){
if (i.toLong() * prime.getitem(j) >= page) break
num[(... | 0 | Java | 0 | 1 | dac2f599b5f88df1fe675e5ba21046bdcb9eb127 | 4,622 | HelloPrime | Apache License 2.0 |
src/main/kotlin/day18.kt | Gitvert | 433,947,508 | false | {"Kotlin": 82286} | import kotlin.math.ceil
import kotlin.math.floor
fun day18() {
val lines: List<String> = readFile("day18.txt")
day18part1(lines)
day18part2(lines)
}
fun day18part1(lines: List<String>) {
val sum = sumListOfSnailFishNumbers(lines)
val answer = getMagnitudeOfNumber(sum)
println("18a: $answer... | 0 | Kotlin | 0 | 0 | 02484bd3bcb921094bc83368843773f7912fe757 | 5,887 | advent_of_code_2021 | MIT License |
kotlin/2140-solving-questions-with-brainpower.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | /*
* DFS/Recursion + Memoization
*/
class Solution {
fun mostPoints(questions: Array<IntArray>): Long {
val memo = LongArray(questions.size) { -1L }
fun dfs(i: Int): Long {
if (i >= questions.size)
return 0
if (memo[i] != -1L)
return memo[i]
... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 1,308 | leetcode | MIT License |
src/day17/Day17.kt | ritesh-singh | 572,210,598 | false | {"Kotlin": 99540} | package day17
import readInput
data class Position(val x: Long, val y: Long)
val firstRock = listOf(
Position(0 + 2, 3),
Position(1 + 2, 3),
Position(2 + 2, 3),
Position(3 + 2, 3),
)
val secondRock = listOf(
Position(1 + 2, 5),
Position(0 + 2, 4),
Position(1 + 2, 4),
Position(2 + 2, 4... | 0 | Kotlin | 0 | 0 | 17fd65a8fac7fa0c6f4718d218a91a7b7d535eab | 4,929 | aoc-2022-kotlin | Apache License 2.0 |
src/main/kotlin/me/peckb/aoc/_2015/calendar/day06/Day06.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2015.calendar.day06
import me.peckb.aoc._2015.calendar.day06.Day06.Action.TOGGLE
import me.peckb.aoc._2015.calendar.day06.Day06.Action.TURN_OFF
import me.peckb.aoc._2015.calendar.day06.Day06.Action.TURN_ON
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import javax.inject.Inj... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,402 | advent-of-code | MIT License |
year2015/src/main/kotlin/net/olegg/aoc/year2015/day14/Day14.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2015.day14
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.year2015.DayOf2015
/**
* See [Year 2015, Day 14](https://adventofcode.com/2015/day/14)
*/
object Day14 : DayOf2015(14) {
private const val TIME = 2503
private val PATTERN = ".*\\b(\\d+)\\b.*\\b(\\d+)\\b.*\\b(\\d+)\\b.... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,333 | adventofcode | MIT License |
src/main/kotlin/days/Day8.kt | jgrgt | 575,475,683 | false | {"Kotlin": 94368} | package days
import util.MutableMatrix
import util.Point
class Day8 : Day(8) {
override fun partOne(): Any {
val matrix = MutableMatrix.fromSingleDigits(inputList) { c ->
c.digitToInt()
}
var count = 0
matrix.forEachPoint { p ->
if (matrix.isOnEdge(p)) {
... | 0 | Kotlin | 0 | 0 | 5174262b5a9fc0ee4c1da9f8fca6fb86860188f4 | 2,081 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/aoc2016/MazeOfTwistyLittleCubicles.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2016
import komu.adventofcode.utils.Point
import utils.shortestPathBetween
fun mazeOfTwistyLittleCubicles1() =
shortestPathBetween(Point(1, 1), Point(31, 39)) { it.openNeighbors }?.size ?: error("no path")
fun mazeOfTwistyLittleCubicles2(): Int {
val seen = mutableSetOf<Point>()
... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 1,086 | advent-of-code | MIT License |
src/day03/Solve03.kt | NKorchagin | 572,397,799 | false | {"Kotlin": 9272} | package day03
import utils.*
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
@ExperimentalTime
fun main() {
fun Char.priority(): Int =
if (isUpperCase()) {
this - 'A' + 27 // Uppercase item types 'A' through 'Z' have priorities 27 through 52.
} else {
... | 0 | Kotlin | 0 | 0 | ed401ab4de38b83cecbc4e3ac823e4d22a332885 | 1,651 | AOC-2022-Kotlin | Apache License 2.0 |
src/util/Iterables.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package util
/**
* Splits a list into sublists where the predicate is true, similar to String.split.
*/
fun <T> List<T>.split(matchInPost: Boolean = false, matchInPre: Boolean = false, predicate: (T) -> Boolean): List<List<T>> {
val idx = this.indexOfFirst(predicate)
return if (idx == -1) {
listOf(th... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 1,865 | advent-of-code | Apache License 2.0 |
Day3/src/CrossedWires.kt | gautemo | 225,219,298 | false | null | import java.io.File
import kotlin.math.abs
fun readLines() = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readLines()
fun main(){
val wires = readLines()
val path1 = path(wires[0])
val path2 = path(wires[1])
val closest = closestIntersect(path1, path2)
println... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 1,633 | AdventOfCode2019 | MIT License |
src/Lesson6Sorting/Triangle.kt | slobodanantonijevic | 557,942,075 | false | {"Kotlin": 50634} |
import java.util.Arrays
/**
* 100/100
* @param A
* @return
*/
fun solution(A: IntArray): Int {
val N = A.size
if (N < 3) return 0
Arrays.sort(A)
for (i in 0 until N - 2) {
/**
* Since the array is sorted A[i + 2] is always the greates or equal to previous values
* So A[i... | 0 | Kotlin | 0 | 0 | 155cf983b1f06550e99c8e13c5e6015a7e7ffb0f | 2,613 | Codility-Kotlin | Apache License 2.0 |
2022/Day12/problems.kt | moozzyk | 317,429,068 | false | {"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794} | import java.io.File
import java.util.ArrayDeque
import kotlin.text.toCharArray
data class Position(val row: Int, val col: Int) {}
fun main(args: Array<String>) {
val lines = File(args[0]).readLines()
println(problem1(lines.map { it.toCharArray() }))
println(problem2(lines.map { it.toCharArray() }))
}
fun... | 0 | Rust | 0 | 0 | c265f4c0bddb0357fe90b6a9e6abdc3bee59f585 | 3,021 | AdventOfCode | MIT License |
src/aoc2022/Day09.kt | NoMoor | 571,730,615 | false | {"Kotlin": 101800} | import utils.*
import java.rmi.UnexpectedException
import kotlin.math.sign
internal class Day09(val lines: List<String>) {
init {
lines.forEach { println(it) }
}
fun part1(): Any {
val tailVisitedCoordinates = mutableSetOf<Coord>()
var head = Coord.xy(0, 0)
var tail = Coord.xy(0, 0)
for (l... | 0 | Kotlin | 1 | 2 | d561db73c98d2d82e7e4bc6ef35b599f98b3e333 | 2,170 | aoc2022 | Apache License 2.0 |
src/main/kotlin/g1701_1800/s1738_find_kth_largest_xor_coordinate_value/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1701_1800.s1738_find_kth_largest_xor_coordinate_value
// #Medium #Array #Matrix #Bit_Manipulation #Heap_Priority_Queue #Prefix_Sum #Divide_and_Conquer
// #Quickselect #2023_06_16_Time_936_ms_(100.00%)_Space_146.3_MB_(100.00%)
class Solution {
fun kthLargestValue(matrix: Array<IntArray>, k: Int): Int {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,912 | LeetCode-in-Kotlin | MIT License |
2021/src/main/kotlin/day25_func.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.IntGrid
import utils.Parser
import utils.Solution
import utils.wrap
fun main() {
Day25Func.run()
}
object Day25Func : Solution<IntGrid>() {
override val name = "day25"
private const val EMPTY = 0
private const val EAST = 1
private const val SOUTH = 2
override val parser = Parser { input -> ... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,397 | aoc_kotlin | MIT License |
app-quality-insights/api/src/com/android/tools/idea/insights/IssueStats.kt | JetBrains | 60,701,247 | false | {"Kotlin": 47313864, "Java": 36708134, "HTML": 1217549, "Starlark": 856523, "C++": 321587, "Python": 100400, "C": 71515, "Lex": 66732, "NSIS": 58538, "AIDL": 35209, "Shell": 28591, "CMake": 26717, "JavaScript": 18437, "Batchfile": 7774, "Smali": 7580, "RenderScript": 4411, "Makefile": 2298, "IDL": 269, "QMake": 18} | /*
* Copyright (C) 2022 The Android Open Source Project
*
* 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 app... | 2 | Kotlin | 231 | 892 | ca717ad602b0c2141bd5e7db4a88067a55b71bfe | 5,945 | android | Apache License 2.0 |
src/main/kotlin/day10/Day10.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day10
import readResourceAsBufferedReader
fun main() {
println("part 1: ${part1(readResourceAsBufferedReader("10_1.txt").readLines())}")
println("part 2: \n${part2(readResourceAsBufferedReader("10_1.txt").readLines())}")
}
fun part1(input: List<String>): Int {
val instrs = input.map { Instruction... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 1,948 | aoc-2022 | Apache License 2.0 |
src/net/sheltem/common/NumericUtils.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.common
import kotlin.math.abs
infix fun Int?.nullsafeMax(other: Int?): Int? = when {
other == null -> this
this == null -> other
else -> maxOf(this, other)
}
infix operator fun Pair<Long, Long>.plus(other: Pair<Long, Long>): Pair<Long, Long> = first + other.first to second + other.sec... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 2,954 | aoc | Apache License 2.0 |
src/main/kotlin/day01_sonar_sweep/SonarSweep.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package day01_sonar_sweep
import util.saveTextFile
import java.io.PrintWriter
import java.io.StringWriter
import java.util.*
/**
* Classic day one: prove you can read in a text file, get numeric values out of
* it, and then loop over them.
*
* Part two requires the a windowed loop, instead of treating each item
... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 2,750 | aoc-2021 | MIT License |
src/jvmMain/kotlin/day01/refined/Day01.kt | liusbl | 726,218,737 | false | {"Kotlin": 109684} | package day01.refined
import java.io.File
fun main() {
// solvePart1() // Solution: 55816
solvePart2() // Solution: 54980
}
fun solvePart1() {
// val input = File("src/jvmMain/kotlin/day01/input/input_part1_test.txt")
val input = File("src/jvmMain/kotlin/day01/input/input.txt")
val lines = input.re... | 0 | Kotlin | 0 | 0 | 1a89bcc77ddf9bc503cf2f25fbf9da59494a61e1 | 1,557 | advent-of-code | MIT License |
src/Day10.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | private const val EXPECTED_1 = 8
private const val EXPECTED_2 = 10
// Way too complicated with trying all 4 directions from the start point, but it works
private class Day10(isTest: Boolean) : Solver(isTest) {
val connections = mapOf(
'|' to listOf(0 to -1, 0 to 1),
'-' to listOf(-1 to 0, 1 to 0),
... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 5,552 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day6.kt | Gitvert | 433,947,508 | false | {"Kotlin": 82286} | import java.math.BigInteger
fun day6() {
val lines: List<String> = readFile("day06.txt")
day6part1(lines)
day6part2(lines)
}
fun day6part1(lines: List<String>) {
val answer = solve(lines, 79)
println("6a: $answer")
}
fun day6part2(lines: List<String>) {
val answer = solve(lines, 255)
p... | 0 | Kotlin | 0 | 0 | 02484bd3bcb921094bc83368843773f7912fe757 | 1,540 | advent_of_code_2021 | MIT License |
src/main/kotlin/com/hj/leetcode/kotlin/problem28/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem28
/**
* LeetCode page: [28. Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/);
*/
class Solution {
/* Complexity:
* Time O(N+M) and Space O(M) where N and M are the length of haystack ... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,695 | hj-leetcode-kotlin | Apache License 2.0 |
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day02.kt | triozer | 573,964,813 | false | {"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716} | package fr.triozer.aoc.y2022
import fr.triozer.aoc.utils.readInput
// #region other
private enum class Action(val value: Int) {
ROCK(1), PAPER(2), SCISSORS(3);
companion object {
fun from(value: String) = when (value) {
"A", "X" -> ROCK
"B", "Y" -> PAPER
"C", "Z" -... | 0 | Kotlin | 0 | 1 | a9f47fa0f749a40e9667295ea8a4023045793ac1 | 1,887 | advent-of-code | Apache License 2.0 |
src/day14/Day14.kt | Ciel-MC | 572,868,010 | false | {"Kotlin": 55885} | package day14
import readInput
sealed class Tile {
data object Wall: Tile()
class Sand(private val grid: Grid): Tile(), Iterable<Sand.MoveResult> {
private var x = 500
private var y = 0
init {
grid[x, y] = this
}
enum class MoveResult {
MOVED, STU... | 0 | Kotlin | 0 | 0 | 7eb57c9bced945dcad4750a7cc4835e56d20cbc8 | 5,469 | Advent-Of-Code | Apache License 2.0 |
src/main/kotlin/com/marcdenning/adventofcode/day23/Day23a.kt | marcdenning | 317,730,735 | false | {"Kotlin": 87536} | package com.marcdenning.adventofcode.day23
import java.util.Collections.*
fun main(args: Array<String>) {
var cups = args[0].map { Integer.parseInt(it + "") }
val moves = args[1].toInt()
for (i in 1..moves) {
cups = moveCups(cups)
}
println(getCupsStateString(cups))
}
/**
* Conduct mov... | 0 | Kotlin | 0 | 0 | b227acb3876726e5eed3dcdbf6c73475cc86cbc1 | 2,387 | advent-of-code-2020 | MIT License |
src/net/sheltem/aoc/y2016/Day04.kt | jtheegarten | 572,901,679 | false | {"Kotlin": 178521} | package net.sheltem.aoc.y2016
import net.sheltem.common.ALPHABET
suspend fun main() {
Day04().run(true)
}
class Day04 : Day<Int>(1514, 4) {
override suspend fun part1(input: List<String>): Int {
return input.map { Room.from(it) }.filter { it.isValid() }.sumOf { it.id }
}
override suspend fu... | 0 | Kotlin | 0 | 0 | ac280f156c284c23565fba5810483dd1cd8a931f | 1,573 | aoc | Apache License 2.0 |
src/main/kotlin/21.kts | reitzig | 318,492,753 | false | null | import java.io.File
typealias Ingredient = String
typealias Allergen = String
data class Food(val ingredients: List<Ingredient>, val allergens: List<Allergen>) {
companion object {
val linePattern = Regex("^([^(]*)\\(contains ([^)]*)\\)$")
operator fun invoke(foodLine: String): Food {
... | 0 | Kotlin | 0 | 0 | f17184fe55dfe06ac8897c2ecfe329a1efbf6a09 | 1,972 | advent-of-code-2020 | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FourKeysKeyboard.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 | 1,712 | kotlab | Apache License 2.0 |
src/Day04.kt | proggler23 | 573,129,757 | false | {"Kotlin": 27990} | fun main() {
fun part1(input: List<String>): Int {
return input.parse4().count { (elf1, elf2) ->
(elf1.first in elf2 && elf1.last in elf2) || (elf2.first in elf1 && elf2.last in elf1)
}
}
fun part2(input: List<String>): Int {
return input.parse4().count { (elf1, elf2) ->... | 0 | Kotlin | 0 | 0 | 584fa4d73f8589bc17ef56c8e1864d64a23483c8 | 896 | advent-of-code-2022 | Apache License 2.0 |
src/day15/Day15.kt | kerchen | 573,125,453 | false | {"Kotlin": 137233} |
package day15
import readInput
import java.lang.Math.abs
import java.util.regex.Pattern
data class Point(var x: Int, var y: Int) {
fun manhattanDistance(other: Point): Int {
return abs(x-other.x) + abs(y-other.y)
}
}
enum class FieldReading {
SENSOR,
BEACON,
KNOWN_EMPTY
}
class SensorFi... | 0 | Kotlin | 0 | 0 | dc15640ff29ec5f9dceb4046adaf860af892c1a9 | 4,749 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/Day04.kt | ripla | 573,901,460 | false | {"Kotlin": 19599} | object Day4 {
private fun stringToIntRange(stringRange: String): IntRange =
stringRange
.split("-")
.toPair()
.map { it.toInt() }
.toIntRange()
private fun containsOther(elfPair: Pair<IntRange, IntRange>): Boolean =
elfPair.first.all(elfPair.seco... | 0 | Kotlin | 0 | 0 | e5e6c0bc7a9c6eaee1a69abca051601ccd0257c8 | 939 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2021/Day11.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 11 - Dumbo Octopus
* Problem Description: http://adventofcode.com/2021/day/11
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day11/
*/
package com.ginsberg.advent2021
typealias OctopusCave = Map<Point2d, Int>
class... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 1,490 | advent-2021-kotlin | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2016/Day07.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2016
import se.saidaspen.aoc.util.*
fun main() = Day07.run()
object Day07 : Day(2016, 7) {
override fun part1() = input.lines().count { supportsTls(it) }
override fun part2() = input.lines().count { supportSsl(it) }
private fun supportSsl(s: String): Boolean {
val ca... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 1,201 | adventofkotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/FullBloomFlowers.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,899 | kotlab | Apache License 2.0 |
src/main/kotlin/io/queue/BasicCalculatorII.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.queue
import io.utils.runTests
import java.util.*
// https://leetcode.com/problems/basic-calculator-ii/
class BasicCalculatorII {
// inspired by https://leetcode.com/problems/basic-calculator-ii/discuss/63003/Share-my-java-solution
fun execute(input: String): Int {
var sign = '+'
var num = 0
... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 3,248 | coding | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2022/day16/day16.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2022.day16
import biz.koziolek.adventofcode.*
import java.util.Comparator
import java.util.PriorityQueue
import java.util.Queue
fun main() {
val inputFile = findInput(object {})
val valvesGraph = parseValvesGraph(inputFile.bufferedReader().readLines())
val timeLimit =... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 6,898 | advent-of-code | MIT License |
src/day15.kt | skuhtic | 572,645,300 | false | {"Kotlin": 36109} | import kotlin.math.abs
fun main() {
day15.execute(onlyTests = false, forceBothParts = false)
}
val day15 = object : Day<Long>(15, 26, 56000011) {
override val testInput: InputData
get() = """
Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beac... | 0 | Kotlin | 0 | 0 | 8de2933df90259cf53c9cb190624d1fb18566868 | 3,057 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2018/Day12.kt | tginsberg | 155,878,142 | false | null | /*
* Copyright (c) 2018 by <NAME>
*/
/**
* Advent of Code 2018, Day 12 - Subterranean Sustainability
*
* Problem Description: http://adventofcode.com/2018/day/12
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day12/
*/
package com.ginsberg.advent2018
class Day12(rawInput: List<Strin... | 0 | Kotlin | 1 | 18 | f33ff59cff3d5895ee8c4de8b9e2f470647af714 | 2,905 | advent-2018-kotlin | MIT License |
codeforces/round606/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.round606
import kotlin.math.sqrt
fun main() {
readLn()
val a = readInts()
val groups = a.groupBy { it }.toList().sortedByDescending { it.second.size }
val b = groups.map { it.second.size }
var bSelf = b.size
var bSum = 0
val (h, w) = (1..sqrt(a.size.toDouble()).toInt()).map { h ->
while (b... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 862 | competitions | The Unlicense |
src/day02/Day02.kt | pientaa | 572,927,825 | false | {"Kotlin": 19922} | package day02
import readLines
fun main() {
fun part1(input: List<String>): Int {
fun Char.shapeScore() = this - 'X' + 1
fun outcome(round: String): Int =
when (round) {
"C X", "A Y", "B Z" -> 6
"A X", "B Y", "C Z" -> 3
"B X", "C Y", "A ... | 0 | Kotlin | 0 | 0 | 63094d8d1887d33b78e2dd73f917d46ca1cbaf9c | 1,128 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day02.kt | mattfrsn | 573,195,420 | false | {"Kotlin": 5703} | import java.io.File
fun main() {
val values = mapOf<String, Int>(
"X" to 1, // pt1 Rock / 2 lose
"Y" to 2, // pt1 Paper / 2 draw
"Z" to 3 // pt1 Sissors / 2 win
)
fun determineGameResult(theirs: String, mine: String): Int {
return when(theirs.single() to mine.single()) {
... | 0 | Kotlin | 0 | 0 | f17941024c1a2bac1cea88c3d9f6b7ecb9fd67e4 | 2,078 | kotlinAdvent2022 | Apache License 2.0 |
src/main/kotlin/arrayandlist/medium/4Sum.kt | jiahaoliuliu | 747,189,993 | false | {"Kotlin": 97631} | package arrayandlist.medium
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
/**
* Given an array nums of n integers, return an array of all the unique quadruplets
* [nums[a], nums[b], nums[c], nums[d]] such that:
* 0 <= a, b, c, d < n
* a, b, c, and d are di... | 0 | Kotlin | 0 | 0 | c5ed998111b2a44d082fc6e6470d197554c0e7c9 | 3,009 | CodingExercises | Apache License 2.0 |
src/main/kotlin/day13/Day13.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day13
import Day
import kotlin.math.max
fun main() {
Day13("Day13").solve()
}
class ValueOrList(
val parent: ValueOrList? = null,
val list: MutableList<ValueOrList>? = null,
val value: Int? = null
) {
val isValue = value != null
}
class Day13(input: String) : Day<List<Pair<ValueOrList, V... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 4,245 | aoc-2022 | Apache License 2.0 |
src/vectors.ws.kts | exerro | 191,953,002 | false | null |
sealed class Dimensions {
object Zero: Dimensions()
class Inc<D: Dimensions>(): Dimensions()
}
typealias One = Dimensions.Inc<Dimensions.Zero>
typealias Two = Dimensions.Inc<One>
typealias Three = Dimensions.Inc<Two>
typealias Four = Dimensions.Inc<Three>
sealed class FList<D: Dimensions> {
object Empty:... | 8 | Kotlin | 0 | 0 | 3210f450651e68430d2442dc184253c0b5c40da2 | 1,874 | ktaf | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2022/day18/Day18.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day18
import com.jacobhyphenated.advent2022.Day
import kotlin.math.absoluteValue
/**
* Day 18: Boiling Boulders
*
* We can observe lava being shot into the air by the volcano.
* Each unit of lava is represented by a 1x1x1 cube in 3d space by the puzzle input.
* How the lava... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 4,099 | advent2022 | The Unlicense |
src/day23/Day23.kt | HGilman | 572,891,570 | false | {"Kotlin": 109639, "C++": 5375, "Python": 400} | package day23
import lib.Point2D
import lib.Vector2D
import readInput
fun main() {
val day = 23
val testInput = readInput("day$day/testInput")
// check(part1(testInput) == 110)
// check(part2(testInput) == 20)
val input = readInput("day$day/input")
// println(part1(input))
println(part2(inpu... | 0 | Kotlin | 0 | 1 | d05a53f84cb74bbb6136f9baf3711af16004ed12 | 9,036 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | devLeitner | 572,272,654 | false | {"Kotlin": 6301} | fun main(){
fun part1(){
var input = readInput("resources/day3source")
var pairList = input.map {
Pair(it.subSequence(0, it.length/2),it.subSequence(it.length/2, it.length))
}
println(pairList)
var totalScore = 0
pairList.forEachIndexed{index, pair ->
... | 0 | Kotlin | 0 | 0 | 72b9d184fc58f790b393260fc6b1a0ed24028059 | 1,166 | AOC_2022 | Apache License 2.0 |
mynlp/src/main/java/com/mayabot/nlp/algorithm/TopIntMinK.kt | mayabot | 113,726,044 | false | {"Java": 985672, "Kotlin": 575923, "Shell": 530} | package com.mayabot.nlp.algorithm
/**
* Top K 最小值。
*/
class TopIntMinK(private val k: Int) {
private val heap = FloatArray(k)
private val idIndex = IntArray(k) { -1 }
var size = 0
fun push(id: Int, score: Float) {
if (size < k) {
heap[size] = score
idIndex[size] = i... | 18 | Java | 90 | 658 | b980da3a6f9cdcb83e0800f6cab50656df94a22a | 1,822 | mynlp | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/RotatedDigits.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,526 | kotlab | Apache License 2.0 |
security/src/main/java/dev/funkymuse/security/RSA.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.security
import java.math.BigInteger
import kotlin.random.Random
/**
* Two numbers are co-prime when the GCD of the numbers is 1.
* This method uses an algorithm called the Euclidean algorithm to compute GCD.
*/
private fun areCoprime(first: Long, second: Long): Boolean {
fun greatest... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 6,964 | KAHelpers | MIT License |
src/y2016/Day02.kt | gaetjen | 572,857,330 | false | {"Kotlin": 325874, "Mermaid": 571} | package y2016
import util.Direction
import util.Pos
import util.get
import util.inverse
import util.readInput
object Day02 {
val keyPad = listOf(
listOf(7, 8, 9),
listOf(4, 5, 6),
listOf(1, 2, 3)
)
val keyPad2 = listOf(
"XX1XX".toList(),
"X234X".toList(),
"... | 0 | Kotlin | 0 | 0 | d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a | 2,089 | advent-of-code | Apache License 2.0 |
src/day24/Code.kt | fcolasuonno | 162,470,286 | false | null | package day24
import java.io.File
import java.util.*
fun main(args: Array<String>) {
val name = if (false) "test.txt" else "input.txt"
val dir = ::main::class.java.`package`.name
val input = File("src/$dir/$name").readLines()
val parsed = parse(input)
println("Part 1 = ${part(parsed, parsed.sum() ... | 0 | Kotlin | 0 | 0 | 24f54bf7be4b5d2a91a82a6998f633f353b2afb6 | 1,697 | AOC2015 | MIT License |
src/Day15.kt | rbraeunlich | 573,282,138 | false | {"Kotlin": 63724} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>, lineToCheck: Int): Int {
val sensorsAndClosestBeacons = input.map { line ->
val sensorAndBeaconLine = line.replace("Sensor at ", "").replace(" closest beacon is at ", "")
val sensorLine = sensorAndBeaconLine.split(":... | 0 | Kotlin | 0 | 1 | 3c7e46ddfb933281be34e58933b84870c6607acd | 8,113 | advent-of-code-2022 | Apache License 2.0 |
dcp_kotlin/src/main/kotlin/dcp/day199/day199.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day199
// day199.kt
// By <NAME>.
fun closestString(elems: String): String {
return closestString(elems.toList())
}
fun closestString(elems: List<Char>): String {
/**
* Goal: given a string comprising parentheses, find a string with balanced parentheses to the original string.
* We can a... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 2,120 | daily-coding-problem | MIT License |
src/Day02.kt | kseito | 573,212,303 | false | {"Kotlin": 2701} | fun main() {
fun part1(input: List<String>): Int {
var sum = 0
input.forEach {
when(it) {
"A X" -> sum += 3 + 1
"A Y" -> sum += 6 + 2
"A Z" -> sum += 0 + 3
"B X" -> sum += 0 + 1
"B Y" -> sum += 3 + 2
... | 0 | Kotlin | 0 | 0 | e14f765390630635a2230feda1efb21b443add39 | 1,141 | advent-of-code-kotlin-template | Apache License 2.0 |
src/search/Main.kt | JIghtuse | 590,549,138 | false | null | package search
import java.io.File
import java.lang.IllegalArgumentException
typealias Dataset = List<String>
typealias InvertedIndex = Map<String, List<Int>>
fun toLowercaseWords(s: String) = s.split(" ").map(String::lowercase)
fun ask(prompt: String): String {
println(prompt)
return readln()
}
fun scanIn... | 0 | Kotlin | 0 | 0 | 4634a626ee544ab63fff5b0e08bbfe3bc11e3f65 | 5,165 | simple-search-engine-hyperskill | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2023/day14/Platform.kt | michaelbull | 726,012,340 | false | {"Kotlin": 195941} | package com.github.michaelbull.advent2023.day14
import com.github.michaelbull.advent2023.math.Vector2
import com.github.michaelbull.advent2023.math.Vector2CharMap
import com.github.michaelbull.advent2023.math.toVector2CharMap
fun Sequence<String>.toPlatform(): Platform {
return Platform(this.toVector2CharMap())
}... | 0 | Kotlin | 0 | 1 | ea0b10a9c6528d82ddb481b9cf627841f44184dd | 3,104 | advent-2023 | ISC License |
src/main/kotlin/aoc2018/BeverageBandits.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2018
import komu.adventofcode.aoc2018.Creature.Companion.hitPointComparator
import komu.adventofcode.aoc2018.Creature.Companion.positionComparator
import komu.adventofcode.aoc2018.CreatureType.ELF
import komu.adventofcode.aoc2018.CreatureType.GOBLIN
import komu.adventofcode.utils.Point
imp... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 5,883 | advent-of-code | MIT License |
src/day7/day7.kt | TimCastelijns | 113,205,922 | false | null | package day7
import java.io.File
fun main(args: Array<String>) {
p1(File("src/day7/input"))
p2(File("src/day7/input"))
}
fun p1(file: File) {
val programs = mutableListOf<String>()
val subPrograms = mutableListOf<String>()
file.forEachLine { line ->
val parts = line.split(" ")
v... | 0 | Kotlin | 0 | 0 | 656f2a424b323175cd14d309bc25430ac7f7250f | 2,550 | aoc2017 | MIT License |
src/Day01.kt | i-tatsenko | 575,595,840 | false | {"Kotlin": 90644} | import java.util.PriorityQueue
class Sums(val input: List<String>) : Iterable<Int> {
override fun iterator(): Iterator<Int> {
return object : Iterator<Int> {
var index = 0
override fun hasNext(): Boolean = index < input.size
override fun next(): Int {
va... | 0 | Kotlin | 0 | 0 | 0a9b360a5fb8052565728e03a665656d1e68c687 | 1,265 | advent-of-code-2022 | Apache License 2.0 |
src/Day07.kt | janbina | 112,736,606 | false | null | package day07
import getInput
import kotlin.math.abs
import kotlin.test.assertEquals
data class Program(
val name: String,
val weight: Int,
val supports: MutableList<Program> = mutableListOf(),
var supportedBy: Program? = null
) {
private val totalWeight: Int by lazy {
weig... | 0 | Kotlin | 0 | 0 | 71b34484825e1ec3f1b3174325c16fee33a13a65 | 1,775 | advent-of-code-2017 | MIT License |
app/src/main/kotlin/com/engineerclark/advent2022/Day04.kt | engineerclark | 577,449,596 | false | {"Kotlin": 10394} | package com.engineerclark.advent2022
import com.engineerclark.advent2022.utils.readDayLines
fun main() {
val assignments = readDayLines(4).readPairAssignments()
println("Day 4, challenge 1 -- Count of elf pair assignments where one is a subset of the other: " +
"${assignments.countHavingSubset}")
... | 0 | Kotlin | 0 | 0 | 3d03ab2cc9c83b3691fede465a6e3936e7c091e9 | 1,597 | advent-of-code-2022 | MIT License |
2023/src/main/kotlin/day2.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parse
import utils.Parser
import utils.Solution
import utils.mapItems
private typealias Input = List<Day2.Game>
fun main() {
Day2.run()
}
object Day2 : Solution<Input>() {
override val name = "day2"
override val parser = Parser.lines.mapItems(::parseGame)
@Parse("Game {id}: {r '; ' rounds}")
... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 1,156 | aoc_kotlin | MIT License |
src/main/kotlin/aoc2020/day11/GameOfLife.kt | arnab | 75,525,311 | false | null | package aoc2020.day11
object GameOfLife {
private const val DEBUG_REPORT_MODE = false
fun parse(rawData: String): List<List<Cell>> = rawData
.split("\n")
.mapIndexed { y, row ->
row.toCharArray().mapIndexed { x, char ->
val state = State.values().find { it.sign == ... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 4,019 | adventofcode | MIT License |
src/day03/Day03.kt | apeinte | 574,487,528 | false | {"Kotlin": 47438} | package day03
import readDayInput
const val ITEMS_PATTERN = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
fun main() {
fun getAlphabetParsed(): List<String> {
return ITEMS_PATTERN.split(",")
}
fun checkIfAlphabetIsCorrect(): Boolean {
... | 0 | Kotlin | 0 | 0 | 4bb3df5eb017eda769b29c03c6f090ca5cdef5bb | 3,696 | my-advent-of-code | Apache License 2.0 |
src/main/kotlin/Excercise02.kt | underwindfall | 433,989,850 | false | {"Kotlin": 55774} | private fun part1() {
getInputAsTest("02") { split("\n") }
.map { it.split(" ") }
.map { it[0] to it[1].toInt() }
.fold(0 to 0) { (y, x), (move, unit) ->
when (move) {
"forward" -> y to x + unit
"down" -> y + unit to x
"up" -> y - unit to x
else -> throw IllegalArgume... | 0 | Kotlin | 0 | 0 | 4fbee48352577f3356e9b9b57d215298cdfca1ed | 945 | advent-of-code-2021 | MIT License |
src/day3/day3.kt | bienenjakob | 573,125,960 | false | {"Kotlin": 53763} | package day3
import inputTextOfDay
import testTextOfDay
private val Char.priority: Int
get() = when (this) {
in 'a'..'z' -> this - 'a' + 1
in 'A'..'Z' -> this - 'A' + 27
else -> error("$this is unknown, check your input!")
}
fun part1(text: String): Int =
text.lines()
.map... | 0 | Kotlin | 0 | 0 | 6ff34edab6f7b4b0630fb2760120725bed725daa | 924 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2023/day9/Day9.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day9
import com.jacobhyphenated.advent2023.Day
/**
* Day 9: Mirage Maintenance
*
* Each line of the puzzle input is a series of readings from an instrument.
*/
class Day9: Day<List<List<Int>>> {
override fun getInput(): List<List<Int>> {
return parseInput(readInputFile... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 2,400 | advent2023 | The Unlicense |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[47]全排列 II.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import java.util.*
import kotlin.collections.ArrayList
//给定一个可包含重复数字的序列 nums ,按任意顺序 返回所有不重复的全排列。
//
//
//
// 示例 1:
//
//
//输入:nums = [1,1,2]
//输出:
//[[1,1,2],
// [1,2,1],
// [2,1,1]]
//
//
// 示例 2:
//
//
//输入:nums = [1,2,3]
//输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
//
//
//
//
// 提示:
//
//
// 1 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,892 | MyLeetCode | Apache License 2.0 |
src/Day02_part2.kt | jmorozov | 573,077,620 | false | {"Kotlin": 31919} | import java.util.EnumMap
fun main() {
val inputData = readInput("Day02")
var myTotalScore = 0
for (line in inputData) {
val trimmedLine = line.trim()
val opponent = Shape.from(trimmedLine.take(1))
val roundOutcome = RoundOutcome.from(trimmedLine.takeLast(1))
val roundOutcom... | 0 | Kotlin | 0 | 0 | 480a98838949dbc7b5b7e84acf24f30db644f7b7 | 1,839 | aoc-2022-in-kotlin | Apache License 2.0 |
dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestNQueens.kt | tuProlog | 230,784,338 | false | {"Kotlin": 3879230, "Java": 18690, "ANTLR": 10366, "CSS": 1535, "JavaScript": 894, "Prolog": 818} | package it.unibo.tuprolog.dsl.solve
import it.unibo.tuprolog.core.Integer
import it.unibo.tuprolog.core.Tuple
import it.unibo.tuprolog.solve.Solution
import kotlin.test.Test
import kotlin.test.assertEquals
class TestNQueens {
private val solutions =
listOf(
listOf((1 to 3), (2 to 1), (3 to 4),... | 71 | Kotlin | 13 | 79 | 804e57913f072066a4e66455ccd91d13a5d9299a | 2,184 | 2p-kt | Apache License 2.0 |
dcp_kotlin/src/main/kotlin/dcp/day271/day271.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day271
// day271.kt
// <NAME>, 20202.
import kotlin.math.min
// Use a technique called the Fibonacci search.
// https://en.wikipedia.org/wiki/Fibonacci_search_technique
fun List<Int>.fibContains(x: Int): Boolean {
if (x > last() || x < first())
return false
val n: Int = this.size
// ... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 1,897 | daily-coding-problem | MIT License |
src/main/kotlin/d11/D11_2.kt | MTender | 734,007,442 | false | {"Kotlin": 108628} | package d11
import input.Input
import kotlin.math.abs
fun findEmptyRows(universe: List<String>): List<Int> {
val empty = mutableListOf<Int>()
for (i in universe.indices) {
if (universe[i].all { it == '.' }) {
empty.add(i)
}
}
return empty
}
fun findEmptyCols(universe: List... | 0 | Kotlin | 0 | 0 | a6eec4168b4a98b73d4496c9d610854a0165dbeb | 1,537 | aoc2023-kotlin | MIT License |
src/main/aoc2018/Day15.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2018
import AMap
import Pos
import Search
class Day15(val input: List<String>) {
data class Player(val team: PlayerType, var pos: Pos, var attackPower: Int = 3, var hp: Int = 200) {
fun isAlive() = hp > 0
}
enum class PlayerType(val symbol: Char) {
ELF('E'),
GOBLIN('G')... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 7,676 | aoc | MIT License |
year2020/day07/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day07/part1/Year2020Day07Part1.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Day 7: Handy Haversacks ---
You land at the regional airport in time for your next flight. In fact, it looks like you'll even
have time to grab some food: all flights are currently delayed due to issues in luggage processing.
Due to recent aviation regulations, many rules (your puzzle input) are being enforced... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,816 | AdventOfCode | MIT License |
src/Day11.kt | vlsolodilov | 573,277,339 | false | {"Kotlin": 19518} | fun main() {
val monkeyListTest = listOf<Monkey>(
Monkey(0, mutableListOf(79, 98), { old -> old * 19}, 23, 2, 3),
Monkey(1, mutableListOf(54, 65, 75, 74), {old -> old + 6}, 19, 2, 0),
Monkey(2, mutableListOf(79, 60, 97), {old -> old * old}, 13, 1, 3),
Monkey(3, mutableListOf(74), {o... | 0 | Kotlin | 0 | 0 | b75427b90b64b21fcb72c16452c3683486b48d76 | 2,755 | aoc22 | Apache License 2.0 |
src/main/kotlin/day05/Problem.kt | xfornesa | 572,983,494 | false | {"Kotlin": 18402} | package day05
import java.util.*
fun solveProblem01(input: List<String>): String {
val stackInput = Stack<String>()
val movements = mutableListOf<String>()
var stackHalf = true
for (value in input) {
if (value.isEmpty()) {
stackHalf = false
continue
}
if... | 0 | Kotlin | 0 | 0 | dc142923f8f5bc739564bc93b432616608a8b7cd | 2,733 | aoc2022 | MIT License |
app/src/main/java/com/canerkorkmaz/cicek/jobdistribution/model/Solution.kt | nberktumer | 173,110,988 | false | {"Kotlin": 47340} | package com.canerkorkmaz.cicek.jobdistribution.model
import com.canerkorkmaz.cicek.jobdistribution.util.sum
import com.canerkorkmaz.cicek.jobdistribution.util.sumByDouble
data class Solution(
val store: StoreData,
val jobs: Set<JobData>
) {
val isValid by lazy {
store.min <= jobs.size && jobs.size... | 0 | Kotlin | 0 | 0 | bd3356d1dcd0da1fa4a4ed5967205ea488724d3a | 1,428 | CicekSepeti-Hackathon | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.