path stringlengths 5 169 | owner stringlengths 2 34 | repo_id int64 1.49M 755M | is_fork bool 2
classes | languages_distribution stringlengths 16 1.68k ⌀ | content stringlengths 446 72k | issues float64 0 1.84k | main_language stringclasses 37
values | forks int64 0 5.77k | stars int64 0 46.8k | commit_sha stringlengths 40 40 | size int64 446 72.6k | name stringlengths 2 64 | license stringclasses 15
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src/main/kotlin/com/adventofcode/year2021/day9/part1/App.kt | demidko | 433,889,383 | false | {"Kotlin": 7692, "Dockerfile": 264} | package com.adventofcode.year2021.day9.part1
import com.adventofcode.year2021.day
class RiskMap(private val rows: List<String>) {
val horizontalLength = rows.first().length
val verticalLength = rows.size
/**
* @param x horizontal
* @param y vertical
*/
operator fun get(x: Int, y: Int): Point? {
... | 0 | Kotlin | 0 | 0 | 2f42bede3ed0c4b17cb2575f6b61a1917a465bda | 1,220 | adventofcode | MIT License |
src/array/leetcode18.kt | Alex-Linrk | 180,918,573 | false | null | package leecode
/**
* 给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,
* 使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。
注意:
答案中不可以包含重复的四元组。
示例:
给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。
满足要求的四元组集合为:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]
*/
class leetcode18 {
fun fourSum(n... | 0 | Kotlin | 0 | 0 | 59f4ab02819b7782a6af19bc73307b93fdc5bf37 | 2,074 | LeetCode | Apache License 2.0 |
src/Day14.kt | cagriyildirimR | 572,811,424 | false | {"Kotlin": 34697} | fun day14Part1() {
val input = readInput("Day14")
var ymin = 0
var ymax = 0
var xmin = 500
var xmax = 0
fun calculateMinMax() {
input.forEach { y ->
y.split("->").forEach { x ->
val p = x.split(",").map { it.trim().toInt() }
if (ymin > p.last... | 0 | Kotlin | 0 | 0 | 343efa0fb8ee76b7b2530269bd986e6171d8bb68 | 6,795 | AoC | Apache License 2.0 |
src/main/kotlin/year2021/day-16.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2021
import lib.aoc.Day
import lib.aoc.Part
import lib.aoc.TestCase
fun main() {
Day(16, 2021, PartA16(), PartB16()).run()
}
open class PartA16 : Part() {
sealed class Packet(val version: Int, val length: Int, val value: () -> Long)
sealed class OperatorPacket(version: Int, length: Int, val ... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 6,183 | Advent-Of-Code-Kotlin | MIT License |
2022/main/day_19/Main.kt | Bluesy1 | 572,214,020 | false | {"Rust": 280861, "Kotlin": 94178, "Shell": 996} | package day_19_2022
import java.io.File
class Blueprint(val input: String) {
val blueprintNumber: Int
val oreRobotCost: Int
val clayRobotCost: Int
val obsidianRobotCost: Pair<Int, Int>
val geodeRobotCost: Pair<Int, Int>
var value = 0
init {
val ints = input.split(" ").map { it.rem... | 0 | Rust | 0 | 0 | 537497bdb2fc0c75f7281186abe52985b600cbfb | 4,296 | AdventofCode | MIT License |
model/src/test/kotlin/ScopeTest.kt | codeakki | 354,880,826 | true | {"Kotlin": 2934213, "JavaScript": 337630, "HTML": 34185, "CSS": 24865, "Python": 21694, "FreeMarker": 13132, "Shell": 7793, "Dockerfile": 7023, "Scala": 6656, "Ruby": 3515, "ANTLR": 1877, "Go": 1071, "Rust": 280} | /*
* Copyright (C) 2017-2020 HERE Europe B.V.
*
* 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... | 17 | null | 2 | 2 | edbb46cb1dab1529d5ffb81cba18d365b98ef23e | 4,577 | ort | Apache License 2.0 |
src/Day06.kt | befrvnk | 574,229,637 | false | {"Kotlin": 15788} | fun String.isMarker(): Boolean {
return all { char -> this.count(char) == 1 }
}
fun String.count(char: Char): Int {
return count { it == char }
}
fun main() {
fun part1(input: List<String>): Int {
val firstLine = input.first()
(0..firstLine.length - 4).forEach { index ->
val po... | 0 | Kotlin | 0 | 0 | 68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7 | 1,112 | aoc-2022-kotlin | Apache License 2.0 |
day10/src/main/kotlin/App.kt | ascheja | 317,918,055 | false | null | package net.sinceat.aoc2020.day10
fun main() {
println(differences(parseFile("testinput.txt")))
println(differences(parseFile("input.txt")))
println(with(Cached()) { parseFile("testinput.txt").combinations() })
println(
with(Cached()) {
val result = parseFile("input.txt").combinati... | 0 | Kotlin | 0 | 0 | f115063875d4d79da32cbdd44ff688f9b418d25e | 1,593 | aoc2020 | MIT License |
src/main/kotlin/letterboxed/Puzzle.kt | gmarmstrong | 531,249,433 | false | {"Kotlin": 22711} | package letterboxed
const val EDGES_PER_PUZZLE = 4
const val LETTERS_PER_EDGE = 3
/**
* Represents a Letter Boxed puzzle configuration.
*/
data class Puzzle(val edges: Set<Set<Char>>) {
val letters: Set<Char>
get() = edges.flatten().toSet()
/**
* Constructs a puzzle from a set of 4 edges (set... | 2 | Kotlin | 0 | 0 | a0545396ebe135ebd602f1d874bf8c4dd9b037d5 | 2,028 | letter-boxed | MIT License |
src/commonMain/kotlin/io/github/alexandrepiveteau/graphs/algorithms/BreadthFirstTraversal.kt | alexandrepiveteau | 630,931,403 | false | {"Kotlin": 132267} | @file:JvmName("Traversals")
@file:JvmMultifileClass
package io.github.alexandrepiveteau.graphs.algorithms
import io.github.alexandrepiveteau.graphs.*
import io.github.alexandrepiveteau.graphs.internal.collections.IntDequeue
import kotlin.contracts.contract
import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName... | 9 | Kotlin | 0 | 6 | a4fd159f094aed5b6b8920d0ceaa6a9c5fc7679f | 2,481 | kotlin-graphs | MIT License |
src/main/kotlin/com/lucaszeta/adventofcode2020/day18/sumOverMultiplication.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day18
fun evaluateAdvancedMathExpression(expression: String): Long {
var line = "($expression)"
val operatorPrecedence = listOf(
SUM_IN_PARENTHESIS to sum,
SUM to sum,
MULTIPLE_MULTIPLICATION to multiplication,
MULTIPLICATION_IN_PARENTHESI... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 1,863 | advent-of-code-2020 | MIT License |
src/Day01.kt | Oktosha | 573,139,677 | false | {"Kotlin": 110908} | import kotlin.math.max
import java.util.PriorityQueue
fun main() {
fun part1(input: List<String>): Int {
var answer = 0
var current = 0
for (line in input) {
if (line.trim() == "") {
answer = max(current, answer)
current = 0
} else {
... | 0 | Kotlin | 0 | 0 | e53eea61440f7de4f2284eb811d355f2f4a25f8c | 1,164 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/Day09.kt | SimonMarquis | 724,825,757 | false | {"Kotlin": 30983} | class Day09(input: List<String>) {
private val histories = input.asSequence()
.map { it.split(" ").map(String::toLong) }
.map { it.differences() }
private fun List<Long>.differences(): List<List<Long>> = buildList {
add(this@differences)
while (last().any { it != 0L }) add(last... | 0 | Kotlin | 0 | 1 | 043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e | 605 | advent-of-code-2023 | MIT License |
sort/bogo_sort/kotlin/bogo_sort.kt | ZoranPandovski | 93,438,176 | false | {"Jupyter Notebook": 21909905, "C++": 1692994, "Python": 1158220, "Java": 806066, "C": 560110, "JavaScript": 305918, "Go": 145277, "C#": 117882, "PHP": 85458, "Kotlin": 72238, "Rust": 53852, "Ruby": 43243, "MATLAB": 34672, "Swift": 31023, "Processing": 22089, "HTML": 18961, "Haskell": 14298, "Dart": 11842, "CSS": 10509... | /*
Bogo Sort
Bogo Sort is the most inefficient way of sorting an algorithm.
The way Bogo Sort works is like throwing a deck of cards in the air
and picking them back up and checking to see if it's organized.
Array of ints [ 3, 1, 2 ]
Step 1.
Starts at the start of the array and will grab a random index from the array... | 62 | Jupyter Notebook | 1,994 | 1,298 | 62a1a543b8f3e2ca1280bf50fc8a95896ef69d63 | 1,665 | al-go-rithms | Creative Commons Zero v1.0 Universal |
src/Day01.kt | romainbsl | 572,718,344 | false | {"Kotlin": 17019} | fun main() {
fun part1(input: String): Elf {
return input.split("\n\n")
.map { foods ->
Elf(foods.split("\n").map { Food(it.toInt()) })
}
.maxBy { elf -> elf.foods.sumOf { it.calories } }
}
fun part2(input: String): List<Elf> {
return inpu... | 0 | Kotlin | 0 | 0 | b72036968769fc67c222a66b97a11abfd610f6ce | 911 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/days/Day19.kt | poqueque | 430,806,840 | false | {"Kotlin": 101024} | package days
import Coor3
import kotlin.math.abs
class Day19 : Day(19) {
class Scanner {
var position: Coor3? = null
var rotation: Int? = null
val beacons = mutableListOf<Coor3>()
fun add(c: Coor3) {
beacons.add(c)
}
fun rotated(faced: Int): Scanner {
... | 0 | Kotlin | 0 | 0 | 4fa363be46ca5cfcfb271a37564af15233f2a141 | 4,682 | adventofcode2021 | MIT License |
advent-of-code-2022/src/Day10.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
val testInput = readInput("Day10_test")
val input = readInput("Day10")
"Part 1 + 2" {
println()
solve(testInput) shouldBe 13140
println()
answer(solve(input))
}
}
private const val START_OFFSET = 20
private const val WIDTH = 40
private fun solve(commands: ... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 1,053 | advent-of-code | Apache License 2.0 |
src/main/aoc2021/Day9.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2021
import Grid
import Pos
class Day9(input: List<String>) {
private val rangeX = input.first().indices
private val rangeY = input.indices
val grid = Grid.parse(input)
private fun findLowPoints(): List<Pos> {
return grid.keys
.filter { it.y in rangeY } // real input i... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,471 | aoc | MIT License |
2020/src/year2021/day06/code.kt | eburke56 | 436,742,568 | false | {"Kotlin": 61133} | package year2021.day06
import util.readAllLines
fun main() {
part1()
part2()
}
private fun part1() {
run(80, "input.txt")
}
private fun part2() {
run(256, "input.txt")
}
private fun run(times: Int, file: String) {
val size = readAllLines(file).first().split(",")
.map { it.toInt() }
... | 0 | Kotlin | 0 | 0 | 24ae0848d3ede32c9c4d8a4bf643bf67325a718e | 1,079 | adventofcode | MIT License |
src/Day06.kt | erikthered | 572,804,470 | false | {"Kotlin": 36722} | fun main() {
fun markerLocation(input: String, size: Int): Int {
input.windowed(size).forEachIndexed { index, s ->
if(s.toCharArray().toSet().size == size) {
return index + s.length
}
}
throw IllegalArgumentException("Marker not found")
}
fun ... | 0 | Kotlin | 0 | 0 | 3946827754a449cbe2a9e3e249a0db06fdc3995d | 890 | aoc-2022-kotlin | Apache License 2.0 |
src/medium/_29DivideTwoIntegers.kt | ilinqh | 390,190,883 | false | {"Kotlin": 382147, "Java": 32712} | package medium
import kotlin.math.abs
class _29DivideTwoIntegers {
class Solution {
fun divide(a: Int, b: Int): Int {
var dividend = Math.abs(a.toLong())
val divisor = Math.abs(b.toLong())
var quotient = 0L
for (i in 31 downTo 0) {
if ((divid... | 0 | Kotlin | 0 | 0 | 8d2060888123915d2ef2ade293e5b12c66fb3a3f | 2,211 | AlgorithmsProject | Apache License 2.0 |
src/Day1/Day1.kt | tomashavlicek | 571,148,506 | false | {"Kotlin": 3033} | package Day1
import readInputAsInts
fun main() {
fun part1(input: List<Int>): Int {
return input.windowed(size = 2).count { it.first() < it.last() }
}
fun part2(input: List<Int>): Int {
// return input.windowed(size = 3).windowed(2).count {
// (firstWindow, secondWindow) -> firs... | 0 | Kotlin | 0 | 0 | 52f7febaacaab3ee9809899d21077fecac39c13b | 808 | aoc-2021-in-kotlin | Apache License 2.0 |
src/main/kotlin/me/grison/aoc/y2021/Day22.kt | agrison | 315,292,447 | false | {"Kotlin": 267552} | package me.grison.aoc.y2021
import me.grison.aoc.*
import kotlin.collections.component1
import kotlin.collections.component2
import kotlin.collections.component3
import kotlin.collections.component4
import kotlin.collections.component5
import kotlin.collections.set
import kotlin.math.max
import kotlin.math.min
import ... | 0 | Kotlin | 3 | 18 | ea6899817458f7ee76d4ba24d36d33f8b58ce9e8 | 2,407 | advent-of-code | Creative Commons Zero v1.0 Universal |
src/day6/Day6.kt | blundell | 572,916,256 | false | {"Kotlin": 38491} | package day6
import readInput
fun main() {
fun detectStartOfPacket(input: List<String>, startOfMessageMarkerSize: Int): Int {
var lastFour = ""
for ((index, c) in input[0].withIndex()) {
if (lastFour.length < startOfMessageMarkerSize) {
lastFour += c
con... | 0 | Kotlin | 0 | 0 | f41982912e3eb10b270061db1f7fe3dcc1931902 | 1,434 | kotlin-advent-of-code-2022 | Apache License 2.0 |
leetcode/src/Q35.kt | zhangweizhe | 387,808,774 | false | null | fun main() {
// https://leetcode-cn.com/problems/search-insert-position/
//println(searchInsert(intArrayOf(3,5,7,9,10), 8))
println(binSearch1(intArrayOf(1), 1))
}
fun searchInsert(nums: IntArray, target: Int): Int {
return binSearch(nums, target, 0, nums.size - 1)
}
fun binSearch(nums: IntArray, targ... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 1,259 | kotlin-study | MIT License |
2021/src/main/kotlin/Day2.kt | osipxd | 388,214,845 | false | null | /**
* # Day 2: Dive!
*
* Now, you need to figure out how to pilot this thing.
*
* It seems like the submarine can take a series of commands like forward 1,
* down 2, or up 3:
*
* forward X increases the horizontal position by X units.
* down X increases the depth by X units.
* up X decreases the depth by X un... | 0 | Kotlin | 0 | 0 | 66553923d8d221bcd1bd108f701fceb41f4d1cbf | 4,832 | advent-of-code | MIT License |
leetcode2/src/leetcode/kthSmallest.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* @Classname kthSmallest
* @Description TODO
* @Date 2020-05-16 14:00
* @Created by jianhao
* 给你一个 m * n 的矩阵 mat,以及一个整数 k ,矩阵中的每一行都以非递减的顺序排列。
你可以从每一行中选出 1 个元素形成一个数组。返回所有可能数组中的第 k 个 最小 数组和。
示例 1:
输入:mat = [[1,3,11],[2,4,6]], k = 5
输出:7
解释:从每一行中选出一个元素,前 k 个和最小的数组分别是:
[1,2], [1,4], [3,2], [... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 1,679 | leetcode | MIT License |
LeetCode/0215. Kth Largest Element in an Array/Solution.kt | InnoFang | 86,413,001 | false | {"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410} | /**
* Created by <NAME> on 2018/2/28.
*/
/**
* 31 / 31 test cases passed.
* Status: Accepted
* Runtime: 480 ms
*/
class Solution {
fun findKthLargest(nums: IntArray, k: Int): Int {
return partition(nums, k, 0, nums.lastIndex)
}
private fun partition(nums: IntArray, k: Int, start: Int, end: I... | 0 | C++ | 8 | 20 | 2419a7d720bea1fd6ff3b75c38342a0ace18b205 | 1,385 | algo-set | Apache License 2.0 |
src/day01/Day01.kt | tschens95 | 573,743,557 | false | {"Kotlin": 32775} | fun main() {
fun part1(input: String): Int {
val elves = input.split("\r\n\r\n")
val mapElveToCalories = elves.map { it.split("\r\n").sumOf { ele -> Integer.parseInt(ele) } }
return mapElveToCalories.max()
}
fun part2(input: String): Int {
val elves = input.split("\r\n\r\n")... | 0 | Kotlin | 0 | 2 | 9d78a9bcd69abc9f025a6a0bde923f53c2d8b301 | 773 | AdventOfCode2022 | Apache License 2.0 |
src/002.kt | brunopessanha | 269,604,204 | false | null | package bruno.euler
/**
* PROBLEM 2
*
* Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
* 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
* By considering the terms in the Fibonacci sequence whose valu... | 0 | Kotlin | 0 | 0 | f3533b81013f7f0486dbea3e49e158201793c115 | 1,297 | euler-kt | Apache License 2.0 |
kotlin/src/com/s13g/aoc/aoc2019/Day13.kt | shaeberling | 50,704,971 | false | {"Kotlin": 300158, "Go": 140763, "Java": 107355, "Rust": 2314, "Starlark": 245} | package com.s13g.aoc.aoc2019
import com.s13g.aoc.Result
import com.s13g.aoc.Solver
import java.lang.RuntimeException
/** https://adventofcode.com/2019/day/13 */
class Day13 : Solver {
override fun solve(lines: List<String>): Result {
val programA = lines[0].split(",").map { it.toLong() }.toMutableList()
pro... | 0 | Kotlin | 1 | 2 | 7e5806f288e87d26cd22eca44e5c695faf62a0d7 | 2,670 | euler | Apache License 2.0 |
src/Day10.kt | WilsonSunBritten | 572,338,927 | false | {"Kotlin": 40606} | fun main() {
fun part1(input: List<String>): Int {
val xIterator = input.map {
if (it == "noop") {
NOOP()
} else {
ADD(it.split(" ")[1].toInt())
}
}.flatMap { command ->
when(command) {
is NOOP -> { listO... | 0 | Kotlin | 0 | 0 | 363252ffd64c6dbdbef7fd847518b642ec47afb8 | 3,125 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/nl/jackploeg/aoc/_2023/calendar/day12/Day12.kt | jackploeg | 736,755,380 | false | {"Kotlin": 318734} | package nl.jackploeg.aoc._2023.calendar.day12
import nl.jackploeg.aoc.generators.InputGenerator.InputGeneratorFactory
import nl.jackploeg.aoc.utilities.readStringFile
import nl.jackploeg.aoc.utilities.repeatString
import javax.inject.Inject
class Day12 @Inject constructor(
private val generatorFactory: InputGenerat... | 0 | Kotlin | 0 | 0 | f2b873b6cf24bf95a4ba3d0e4f6e007b96423b76 | 2,855 | advent-of-code | MIT License |
src/Day19.kt | syncd010 | 324,790,559 | false | null | class Day19: Day {
private fun convert(input: List<String>) : List<Long> {
return input[0].split(",").map { it.toLong() }
}
override fun solvePartOne(input: List<String>): Int {
val initialMem = convert(input)
val computer = Intcode(initialMem)
val grid = List(50) { MutableL... | 0 | Kotlin | 0 | 0 | 11c7c7d6ccd2488186dfc7841078d9db66beb01a | 1,834 | AoC2019 | Apache License 2.0 |
src/main/kotlin/Solution.kt | ShizoCactus | 666,096,274 | false | null |
import exceptions.NoSuchCourseException
import exceptions.NoSuchStudentException
import java.io.File
class Solution(
listVarientsFileName: String,
averageScoresFileName: String,
studentChoicesFileName: String
) {
private val courses = mutableListOf<Course>()
private val scores = mutableMapOf<Strin... | 0 | Kotlin | 0 | 0 | 41b6b4251998f670bc6054b17741b3419d59d959 | 6,201 | uchebnaya-praktika-leti-compose | Apache License 2.0 |
src/main/kotlin/me/peckb/aoc/_2015/calendar/day24/Day24.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2015.calendar.day24
import javax.inject.Inject
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import kotlin.math.min
class Day24 @Inject constructor(private val generatorFactory: InputGeneratorFactory) {
/**
* There are sums that hit our `evenThreePoint` using only fiv... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,396 | advent-of-code | MIT License |
src/day04/Main.kt | nikwotton | 572,814,041 | false | {"Kotlin": 77320} | package day04
import java.io.File
const val workingDir = "src/day04"
fun main() {
val sample = File("$workingDir/sample.txt")
val input1 = File("$workingDir/input_1.txt")
println("Step 1a: ${runStep1(sample)}")
println("Step 1b: ${runStep1(input1)}")
println("Step 2a: ${runStep2(sample)}")
pr... | 0 | Kotlin | 0 | 0 | dee6a1c34bfe3530ae6a8417db85ac590af16909 | 1,016 | advent-of-code-2022 | Apache License 2.0 |
plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ArtifactVersionKeysReading.kt | Splitties | 150,827,271 | false | {"Kotlin": 808317, "Shell": 2793, "Just": 1182, "Java": 89, "Groovy": 24} | package de.fayard.refreshVersions.core.internal
import de.fayard.refreshVersions.core.ModuleId
@InternalRefreshVersionsApi
abstract class ArtifactVersionKeyReader private constructor(
val getRemovedDependenciesVersionsKeys: () -> Map<ModuleId.Maven, String>
) {
abstract fun readVersionKey(group: String, name... | 113 | Kotlin | 109 | 1,606 | df624c0fb781cb6e0de054a2b9d44808687e4fc8 | 2,195 | refreshVersions | MIT License |
src/medium/_17LetterCombinationsOfAPhoneNumber.kt | ilinqh | 390,190,883 | false | {"Kotlin": 382147, "Java": 32712} | package medium
class _17LetterCombinationsOfAPhoneNumber {
class Solution {
fun letterCombinations(digits: String): List<String> {
if (digits.isEmpty()) {
return emptyList()
}
val sb = StringBuffer()
val resultList: ArrayList<String> = ArrayList()
backtrack(resul... | 0 | Kotlin | 0 | 0 | 8d2060888123915d2ef2ade293e5b12c66fb3a3f | 2,076 | AlgorithmsProject | Apache License 2.0 |
src/test/kotlin/chapter4/solutions/ex6/listing.kt | DavidGomesh | 680,857,367 | false | {"Kotlin": 204685} | package chapter4.solutions.ex6
import chapter4.Either
import chapter4.Left
import chapter4.Right
import chapter4.flatMap
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.WordSpec
//tag::init[]
fun <E, A, B> Either<E, A>.map(f: (A) -> B): Either<E, B> =
when (this) {
is Left -> this
... | 0 | Kotlin | 0 | 0 | 41fd131cd5049cbafce8efff044bc00d8acddebd | 2,623 | fp-kotlin | MIT License |
solution/#3 Longest Substring Without Repeating Characters/Solution.kt | enihsyou | 116,918,868 | false | {"Java": 179666, "Python": 36379, "Kotlin": 32431, "Shell": 367} | package leetcode.q3.kotlin;
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
class Solution {
fun lengthOfLongestSubstring(s: String): Int {
val n = s.length
... | 1 | Java | 0 | 0 | 230325d1dfd666ee53f304edf74c9c0f60f81d75 | 2,136 | LeetCode | MIT License |
src/main/kotlin/com/jackchapman/adventofcode/Day06.kt | crepppy | 317,691,375 | false | null | package com.jackchapman.adventofcode
fun solveDay6(): Pair<Int, Int> {
val groupAnswers = getInput(6).joinToString("\n").split("\n\n")
val answered = groupAnswers.map { questionsAnswered(it) }
val commonAnswers = groupAnswers.map { questionsEveryoneAnswered(it) }
return answered.sum() to commonAnswer... | 0 | Kotlin | 0 | 0 | b49bb8f62b4542791626950846ca07d1eff4f2d1 | 765 | aoc2020 | The Unlicense |
src/main/kotlin/codes/jakob/aoc/solution/Solution.kt | The-Self-Taught-Software-Engineer | 433,875,929 | false | {"Kotlin": 56277} | @file:Suppress("unused")
package codes.jakob.aoc.solution
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
import java.util.*
abstract class Solution {
abstract fun solvePart1(input: String): Any
abstract fun solvePart2(input: String): Any
private val identifier: String = getCla... | 0 | Kotlin | 0 | 6 | d4cfb3479bf47192b6ddb9a76b0fe8aa10c0e46c | 3,541 | advent-of-code-2021 | MIT License |
scripts/profiling/SummarizeCSV.kts | TIBHannover | 197,416,205 | false | {"Kotlin": 3096016, "Cypher": 217169, "Python": 4881, "Groovy": 1936, "Shell": 1803, "HTML": 240} | #!/usr/bin/env kscript
import java.io.File
val file = args.getOrElse(0) { "result.csv" }
val results = readCSV(file)
var totalTimeA: Long = 0
var totalTimeB: Long = 0
var totalMethodCount = 0
results.forEach { (repo, measurements) ->
val methodToResult = computeMethodResults(measurements)
var time: Long = ... | 0 | Kotlin | 1 | 4 | bcc5b31678df9610bb2128dd14fd5fe34461eea8 | 2,126 | orkg-backend | MIT License |
src/day11/Day11.kt | Puju2496 | 576,611,911 | false | {"Kotlin": 46156} | package day11
import println
import readInput
import java.util.*
import kotlin.math.abs
import kotlin.collections.MutableList
fun main() {
// test if implementation meets criteria from the description, like:
val input = readInput("src/day11", "Day11")
println("Part1")
part1(input)
println("Part2")... | 0 | Kotlin | 0 | 0 | e04f89c67f6170441651a1fe2bd1f2448a2cf64e | 10,628 | advent-of-code-2022 | Apache License 2.0 |
program/add-two-matrices/AddTwoMatrices.kt | codinasion | 540,856,406 | false | null | fun main() {
print("Enter the two matrices line separated: \n")
val size = 3
val a = readMatrix(size)
readln()
val b = readMatrix(size)
val c = addMatrices(a, b)
println("Result of adding the matrices: \n")
printMatrix(c)
}
// Takes number of rows and columns and reads the matrix from... | 951 | Java | 550 | 300 | d8880e34c1ff4713c2ff8fbe9cdfbed3f209844a | 1,188 | program | MIT License |
src/main/kotlin/sschr15/aocsolutions/Day15.kt | sschr15 | 317,887,086 | false | {"Kotlin": 184127, "TeX": 2614, "Python": 446} | package sschr15.aocsolutions
import sschr15.aocsolutions.util.Challenge
import sschr15.aocsolutions.util.ReflectivelyUsed
import sschr15.aocsolutions.util.challenge
import sschr15.aocsolutions.util.findLongs
/**
* AOC 2023 [Day 15](https://adventofcode.com/2023/day/15)
* Challenge: Baby's first hashmap
*/
object D... | 0 | Kotlin | 0 | 0 | e483b02037ae5f025fc34367cb477fabe54a6578 | 1,737 | advent-of-code | MIT License |
2023/src/main/kotlin/Advent2306.kt | jkesanen | 737,123,947 | false | {"Kotlin": 22721} | import java.io.File
import kotlin.math.max
class Advent2306 {
private fun chargeToDistance(charge: Long, duration: Long): Long {
val timeLeft = duration - charge
return charge * max(0, timeLeft)
}
private fun getBestResults(filename: String): List<Pair<Long, Long>> {
val times = mu... | 0 | Kotlin | 0 | 0 | e4be0577f8e6654a306c3c9c3cf4f0620db93b8b | 2,452 | adventofcode | MIT License |
year2022/src/cz/veleto/aoc/year2022/Day13.kt | haluzpav | 573,073,312 | false | {"Kotlin": 164348} | package cz.veleto.aoc.year2022
import cz.veleto.aoc.core.AocDay
import kotlin.jvm.JvmInline
import kotlin.math.min
class Day13(config: Config) : AocDay(config) {
override fun part1(): String = input.chunked(3)
.mapIndexed { pairIndex, (leftString, rightString) ->
val left = parseList(leftStri... | 0 | Kotlin | 0 | 1 | 32003edb726f7736f881edc263a85a404be6a5f0 | 4,587 | advent-of-pavel | Apache License 2.0 |
src/main/kotlin/_2023/Day04.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2023
import Day
import InputReader
import inc
import kotlin.math.pow
class Day04 : Day(2023, 4) {
override val firstTestAnswer = 13
override val secondTestAnswer = 30
override fun first(input: InputReader) = input.asLines()
.sumOf { card ->
val (winningNumbers, cardNumbers) ... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 1,499 | advent-of-code | Apache License 2.0 |
2023/01/Solution.kt | AdrianMiozga | 588,519,359 | false | {"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732} | import java.io.File
import kotlin.math.max
import kotlin.math.min
private const val FILENAME = "2023/01/input.txt"
private val digitsRegex = Regex("""\D""")
fun main() {
partOne()
partTwo()
}
private fun partOne() {
val file = File(FILENAME).readLines()
var result = 0
for (line in file) {
... | 0 | Kotlin | 0 | 0 | c9cba875089d8d4fb145932c45c2d487ccc7e8e5 | 2,011 | Advent-of-Code | MIT License |
src/Day17.kt | kipwoker | 572,884,607 | false | null | import kotlin.math.max
class Rock(val cells: List<Point>, var shift: Point) {
fun getCoords(): List<Point> {
return cells.map { x -> x.sum(shift) }
}
fun hasCollision(points: Set<Point>, move: Point): Boolean {
val newPosition = this.getCoords()
.map { it.sum(move) }
v... | 0 | Kotlin | 0 | 0 | d8aeea88d1ab3dc4a07b2ff5b071df0715202af2 | 7,365 | aoc2022 | Apache License 2.0 |
aoc_2023/src/main/kotlin/problems/day23/HikingSol.kt | Cavitedev | 725,682,393 | false | {"Kotlin": 228779} | package problems.day23
import kotlin.math.max
class HikingSol(val hikingMap: HikingMap) {
val startCell = hikingMap.startCell()
val endCell = hikingMap.endCell()
fun solve(): Int {
var longestPath = 0
val startNode = HikingNode(startCell, 0, null, mutableSetOf())
val openedNodes... | 0 | Kotlin | 0 | 1 | aa7af2d5aa0eb30df4563c513956ed41f18791d5 | 1,578 | advent-of-code-2023 | MIT License |
src/Day14.kt | jrmacgill | 573,065,109 | false | {"Kotlin": 76362} | import utils.*
import java.lang.Integer.max
import java.lang.Math.min
class Day14 {
val grid = MutableGrid(100000,1000) { _ -> '.' }
fun Point.down() : Point {
return Point(this.x, this.y+1)
}
fun Point.left() : Point {
return Point(this.x-1, this.y+1)
}
fun Point.right() : Po... | 0 | Kotlin | 0 | 1 | 3dcd590f971b6e9c064b444139d6442df034355b | 1,885 | aoc-2022-kotlin | Apache License 2.0 |
solutions/aockt/y2022/Y2022D11.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2022
import io.github.jadarma.aockt.core.Solution
object Y2022D11 : Solution {
/** Regex that extracts information on monkeys. */
private val inputRegex = Regex(
"""
Monkey (?<id>\d+):
{2}Starting items: (?<startingItems>[0-9, ]+)
{2}Operation: new = old (?<op... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 5,246 | advent-of-code-kotlin-solutions | The Unlicense |
src/main/kotlin/g2901_3000/s2901_longest_unequal_adjacent_groups_subsequence_ii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2901_3000.s2901_longest_unequal_adjacent_groups_subsequence_ii
// #Medium #Array #String #Dynamic_Programming
// #2023_12_27_Time_305_ms_(100.00%)_Space_47.6_MB_(75.00%)
class Solution {
fun getWordsInLongestSubsequence(n: Int, words: Array<String>, groups: IntArray): List<String> {
val check = I... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,476 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/Puzzle3.kt | darwineee | 578,563,140 | false | {"Kotlin": 17166} | import java.io.File
fun puzzle3Part1(args: Array<String>) {
var sum = 0
File(args[0])
.readLines()
.forEach {
val commonItem = it.toCharArray().getCommonItem()
if (commonItem != null) {
sum += commonItem.toPriorityPoint()
}
}
print... | 0 | Kotlin | 0 | 0 | f4354b88b657a6d6f803632bc6b43b5abb6943f1 | 1,948 | adventOfCode2022 | Apache License 2.0 |
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day22/BigDeck.kt | jrhenderson1988 | 289,786,400 | false | {"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37} | package com.github.jrhenderson1988.adventofcode2019.day22
import java.math.BigInteger
/**
* Solution came primarily from this insight:
* https://www.reddit.com/r/adventofcode/comments/ee0rqi/comment/fbnkaju/
*/
class BigDeck(
private val offset: BigInteger,
private val increment: BigInteger,
private va... | 0 | Kotlin | 0 | 0 | 7b56f99deccc3790c6c15a6fe98a57892bff9e51 | 2,351 | advent-of-code | Apache License 2.0 |
src/main/kotlin/leetcode/problem0005/LongestPalindromicSubstring.kt | ayukatawago | 456,312,186 | false | {"Kotlin": 266300, "Python": 1842} | package leetcode.problem0005
import kotlin.math.max
class LongestPalindromicSubstring {
fun longestPalindrome(s: String): String {
if (s.isEmpty()) {
return ""
}
var startIndex = 0
var endIndex = 0
for (index in 0..s.length) {
val temp1 = findPalind... | 0 | Kotlin | 0 | 0 | f9602f2560a6c9102728ccbc5c1ff8fa421341b8 | 1,078 | leetcode-kotlin | MIT License |
src/main/kotlin/aoc2016/FirewallRules.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2016
import komu.adventofcode.utils.nonEmptyLines
fun firewallRules1(input: String): UInt =
FirewallRule.parseRules(input).mergeSuccessive().first().high + 1u
fun firewallRules2(input: String): UInt =
FirewallRule.parseRules(input).mergeSuccessive().zipWithNext().sumOf { (r1, r2)... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 1,381 | advent-of-code | MIT License |
src/main/kotlin/be/tabs_spaces/advent2021/days/Day12.kt | janvryck | 433,393,768 | false | {"Kotlin": 58803} | package be.tabs_spaces.advent2021.days
class Day12 : Day(12) {
private val caveSystem = CaveSystem(inputList)
override fun partOne() = caveSystem.findExitFromStart().size
override fun partTwo() = caveSystem.findExitFromStart(maxDuplicateSmallCaves = 1).size
class CaveSystem(rawInput: List<String>) {... | 0 | Kotlin | 0 | 0 | f6c8dc0cf28abfa7f610ffb69ffe837ba14bafa9 | 1,941 | advent-2021 | Creative Commons Zero v1.0 Universal |
Algorithm/HackerRank/src/BiggerIsGreater.kt | chaking | 180,269,329 | false | {"JavaScript": 118156, "HTML": 97206, "Jupyter Notebook": 93471, "C++": 19666, "Kotlin": 14457, "Java": 8536, "Python": 4928, "Swift": 3893, "Makefile": 2257, "Scala": 890, "Elm": 191, "CSS": 56} | import java.io.*
import java.math.*
import java.security.*
import java.text.*
import java.util.*
import java.util.concurrent.*
import java.util.function.*
import java.util.regex.*
import java.util.stream.*
import kotlin.collections.*
import kotlin.comparisons.*
import kotlin.io.*
import kotlin.jvm.*
import kotlin.jvm.f... | 0 | JavaScript | 0 | 0 | a394f100155fa4eb1032c09cdc85816b7104804b | 1,238 | study | MIT License |
test/leetcode/NumberOfStudentsUnableToEatLunch.kt | andrej-dyck | 340,964,799 | false | null | package leetcode
import lib.IntArrayArg
import org.assertj.core.api.Assertions
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.converter.ConvertWith
import org.junit.jupiter.params.provider.CsvSource
/**
* https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/
*
* 1... | 0 | Kotlin | 0 | 0 | 3e3baf8454c34793d9771f05f330e2668fda7e9d | 3,606 | coding-challenges | MIT License |
src/Day12_2.kt | lsimeonov | 572,929,910 | false | {"Kotlin": 66434} |
import readInput
import java.util.LinkedList
import java.util.Queue
fun main() {
data class RowCol(
val row: Int,
val col: Int
)
var sourceP: RowCol? = null
var destP: RowCol? = null
val sourceDestinations = mutableListOf<RowCol>()
fun List<String>.initMatrix(matrix: Array<... | 0 | Kotlin | 0 | 0 | 9d41342f355b8ed05c56c3d7faf20f54adaa92f1 | 5,703 | advent-of-code-2022 | Apache License 2.0 |
src/test/kotlin/be/brammeerten/y2023/Day2Test.kt | BramMeerten | 572,879,653 | false | {"Kotlin": 170522} | package be.brammeerten.y2023
import be.brammeerten.extractRegexGroups
import be.brammeerten.readFile
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import java.util.regex.Pattern
import kotlin.math.max
class Day2Test {
@Test
fun `part 1`() {
val lines = readFile(... | 0 | Kotlin | 0 | 0 | 1defe58b8cbaaca17e41b87979c3107c3cb76de0 | 2,068 | Advent-of-Code | MIT License |
src/main/kotlin/ru/amai/study/hackerrank/practice/interviewPreparationKit/sorting/merge/CountInversions.kt | slobanov | 200,526,003 | false | null | package ru.amai.study.hackerrank.practice.interviewPreparationKit.sorting.merge
import java.util.*
fun countInversions(arr: IntArray): Long =
mergeSortSupport(arr, IntArray(arr.size), 0, arr.size)
fun mergeSortSupport(arr: IntArray, temp: IntArray, left: Int, right: Int): Long =
if (right - left > 1) {
... | 0 | Kotlin | 0 | 0 | 2cfdf851e1a635b811af82d599681b316b5bde7c | 1,487 | kotlin-hackerrank | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimizeMaximumOfArray.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,215 | kotlab | Apache License 2.0 |
src/day05/Day05.kt | veronicamengyan | 573,063,888 | false | {"Kotlin": 14976} | package day05
import java.lang.StringBuilder
import java.util.ArrayDeque
import readInput
fun main() {
fun findTopCrates(input: List<String>): String {
var top = mutableListOf<String>()
val bottom = mutableListOf<String>()
var isInstruction = false;
for(item in input) {
... | 0 | Kotlin | 0 | 0 | d443cfa49e9d8c9f76fdb6303ecf104498effb88 | 3,350 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day06/Day06.kt | sanyarajan | 572,663,282 | false | {"Kotlin": 24016} | @file:Suppress("SpellCheckingInspection")
package day06
import readInputText
fun main() {
fun findDistinctSequenceOfLength(input: String, sequenceLength:Int): Int {
(0..input.length - sequenceLength).forEach { i ->
val sub = input.subSequence(i, i + sequenceLength)
val set = s... | 0 | Kotlin | 0 | 0 | e23413357b13b68ed80f903d659961843f2a1973 | 1,513 | Kotlin-AOC-2022 | Apache License 2.0 |
src/main/kotlin/me/circuitrcay/euler/challenges/oneToTwentyFive/Problem4.kt | adamint | 134,989,381 | false | null | package me.circuitrcay.euler.challenges.oneToTwentyFive
import me.circuitrcay.euler.Problem
class Problem4 : Problem<String>() {
override fun calculate(): Any {
var largest = PalindromeResult(0, 0, 0)
for (i in 100..999) {
for (j in 100..999) {
if (isPal(i, j) && i * j ... | 0 | Kotlin | 0 | 0 | cebe96422207000718dbee46dce92fb332118665 | 816 | project-euler-kotlin | Apache License 2.0 |
Add_Two_Numbers_II.kt | xiekch | 166,329,519 | false | {"C++": 165148, "Java": 103273, "Kotlin": 97031, "Go": 40017, "Python": 22302, "TypeScript": 17514, "Swift": 6748, "Rust": 6579, "JavaScript": 4244, "Makefile": 349} | import java.util.*
// https://leetcode.com/problems/add-two-numbers-ii/discuss/92623/Easy-O(n)-Java-Solution-using-Stackhttps://leetcode.com/problems/add-two-numbers-ii/discuss/92623/Easy-O(n)-Java-Solution-using-Stack
// Definition for singly-linked list.
// Example:
// var li = ListNode(5)
// var v = li.`val`
// De... | 0 | C++ | 0 | 0 | eb5b6814e8ba0847f0b36aec9ab63bcf1bbbc134 | 1,726 | leetcode | MIT License |
src/Day06.kt | kecolk | 572,819,860 | false | {"Kotlin": 22071} | fun main() {
fun isDistinct(buffer: List<Char>): Boolean =
buffer.all { chr -> buffer.count { it == chr } == 1 }
fun findStart(input: String, size: Int): Int {
val signal = input.toList()
signal.windowed(size = size, step = 1, partialWindows = false)
.forEachIndexed { index... | 0 | Kotlin | 0 | 0 | 72b3680a146d9d05be4ee209d5ba93ae46a5cb13 | 813 | kotlin_aoc_22 | Apache License 2.0 |
dataStructuresAndAlgorithms/src/main/java/dev/funkymuse/datastructuresandalgorithms/trees/avl/AVLTree.kt | FunkyMuse | 168,687,007 | false | {"Kotlin": 1728251} | package dev.funkymuse.datastructuresandalgorithms.trees.avl
import kotlin.math.max
class AVLTree<T : Comparable<T>> {
var root: AVLNode<T>? = null
fun insert(value: T) {
root = insert(root, value)
}
fun remove(value: T) {
root = remove(root, value)
}
private fun remove(node... | 0 | Kotlin | 92 | 771 | e2afb0cc98c92c80ddf2ec1c073d7ae4ecfcb6e1 | 3,924 | KAHelpers | MIT License |
src/Day01.kt | dmdrummond | 573,289,191 | false | {"Kotlin": 9084} | fun main() {
fun buildList(input: List<String>): List<Int> {
val calorieList = mutableListOf<Int>()
var calories = 0
input.forEach {
if (it.isEmpty()) {
calorieList.add(calories)
calories = 0
} else {
calories += (it.toI... | 0 | Kotlin | 0 | 0 | 2493256124c341e9d4a5e3edfb688584e32f95ec | 870 | AoC2022 | Apache License 2.0 |
src/main/kotlin/days/aoc2020/Day21.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2020
import days.Day
class Day21: Day(2020, 21) {
override fun partOne(): Any {
var potentialIngredientsForAllergen = mutableMapOf<String, MutableSet<String>>()
val allIngredients = mutableMapOf<String, Int>()
inputList.forEach {
Regex("(.*) \\(contains (.*)\\)"... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 3,170 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day11.kt | jmerle | 434,010,865 | false | {"Kotlin": 60581} | package com.jaspervanmerle.aoc2021.day
class Day11 : Day("1719", "232") {
private data class Point(val x: Int, val y: Int)
private val width = input.lines()[0].length
private val height = input.lines().size
private val directions = listOf(
-1 to 0,
1 to 0,
0 to -1,
0 t... | 0 | Kotlin | 0 | 0 | dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e | 2,295 | advent-of-code-2021 | MIT License |
adventofcode/1/main.kt | seirion | 17,619,607 | false | {"C++": 801740, "HTML": 42242, "Kotlin": 37689, "Python": 21759, "C": 3798, "JavaScript": 294} | // part 1
fun main() {
val abc = "ABC"
val xyz = "XYZ"
var out = 0
while (true) {
val input = readLine() ?: break
val (a, b) = input.split(" ").map { it.first() }
out += score(abc.indexOf(a), xyz.indexOf(b))
}
println(out)
}
fun score(a: Int, b: Int): Int {
return (1 + b) + if (a == b) 3
else if (b == (... | 0 | C++ | 4 | 4 | a59df98712c7eeceabc98f6535f7814d3a1c2c9f | 787 | code | Apache License 2.0 |
src/Day23.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | fun main() {
fun parseInput(input: List<String>): MutableList<Pair<Int, Int>> {
val elves = mutableListOf<Pair<Int, Int>>()
for (i in input.indices) {
for (j in input[i].indices) {
if (input[i][j] == '#') {
elves.add(Pair(i, j))
}
... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 4,389 | advent-of-code-2022 | Apache License 2.0 |
src/Day21.kt | Aldas25 | 572,846,570 | false | {"Kotlin": 106964} | fun main() {
abstract class Operation() {
abstract fun doOperation(x: Long, y: Long): Long
abstract fun getLeft(req: Long, y: Long): Long
abstract fun getRight(req: Long, x: Long): Long
}
class AddOperation() : Operation() {
override fun doOperation(x: Long, y: Long): Long ... | 0 | Kotlin | 0 | 0 | 80785e323369b204c1057f49f5162b8017adb55a | 5,331 | Advent-of-Code-2022 | Apache License 2.0 |
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt | zeredouni | 537,907,731 | true | {"Kotlin": 2272674, "Shell": 1179} | package eu.kanade.tachiyomi.data.library
import eu.kanade.tachiyomi.data.database.models.Manga
import kotlin.math.abs
/**
* This class will provide various functions to Rank mangaList to efficiently schedule mangaList to update.
*/
object LibraryUpdateRanker {
val rankingScheme = listOf(
(this::lexicog... | 32 | Kotlin | 0 | 0 | f6bb0a0b34ee9ccb761a126b4066193a71815e86 | 2,107 | Neko-master | Apache License 2.0 |
src/lexer/Lexer.kt | q-lang | 128,704,097 | false | null | package lexer
import io.File
import re.Regex
import java.io.StringReader
import kotlin.coroutines.experimental.buildSequence
private fun stringLines(string: String) = buildSequence {
StringReader(string).useLines { yieldAll(it) }
}
data class Lexer(
val vocabulary: Map<String, String>,
val keywords... | 0 | Kotlin | 1 | 0 | 2d8a8b4d32ae8ec5b8ed9cce099bd58f37838833 | 4,050 | q-lang | MIT License |
Day5/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)
transform(arr)
}
fun transform(start: List<Int>): List<Int>{
val arr = start.toMutableList()
var i = 0
loop@ while (i < arr.size){
... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 2,362 | AdventOfCode2019 | MIT License |
src/Day01.kt | aeisele | 572,478,307 | false | {"Kotlin": 4468} | import java.util.*
import kotlin.math.max
fun main() {
fun part1(input: List<String>): Int {
var max = 0;
var cur = 0;
for (line in input) {
if (line.isBlank()) {
max = max(max, cur);
cur = 0;
} else {
cur += line.toI... | 0 | Kotlin | 0 | 0 | 40a867c599fda032660724b81b0c12070ac5ba87 | 1,282 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/aoc2020/ex15.kt | noamfree | 433,962,392 | false | {"Kotlin": 93533} | package aoc2020
import kotlin.math.sign
fun main() {
println(nThNumber("8,11,0,19,1,2", 30_000_000))
error("")
require(nThNumber("1,3,2", 2020) == 1)
require(nThNumber("2,1,3", 2020) == 10)
require(nThNumber("1,2,3", 2020) == 27)
require(nThNumber("2,3,1", 2020) == 78)
require(nThNumber("3... | 0 | Kotlin | 0 | 0 | 566cbb2ef2caaf77c349822f42153badc36565b7 | 2,139 | AOC-2021 | MIT License |
aoc-2022/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentytwo/Day03.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentytwo
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.intersectAll
import fr.outadoc.aoc.scaffold.readDayInput
import kotlin.jvm.JvmInline
class Day03 : Day<Int> {
@JvmInline
private value class Item(val id: Char)
private val allowedItems: List<Char> =
... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 1,733 | adventofcode | Apache License 2.0 |
day22/part2.kts | bmatcuk | 726,103,418 | false | {"Kotlin": 214659} | // --- Part Two ---
// Disintegrating bricks one at a time isn't going to be fast enough. While it
// might sound dangerous, what you really need is a chain reaction.
//
// You'll need to figure out the best brick to disintegrate. For each brick,
// determine how many other bricks would fall if that brick were disinteg... | 0 | Kotlin | 0 | 0 | a01c9000fb4da1a0cd2ea1a225be28ab11849ee7 | 3,338 | adventofcode2023 | MIT License |
app/src/main/kotlin/com/github/ilikeyourhat/kudoku/solving/sat/SatSolver.kt | ILikeYourHat | 139,063,649 | false | {"Kotlin": 166134} | package com.github.ilikeyourhat.kudoku.solving.sat
import com.github.ilikeyourhat.kudoku.solving.SolutionCount
import com.github.ilikeyourhat.kudoku.model.Field
import com.github.ilikeyourhat.kudoku.model.Sudoku
import com.github.ilikeyourhat.kudoku.solving.SudokuSolutionChecker
import com.github.ilikeyourhat.kudoku.s... | 1 | Kotlin | 0 | 0 | b234b2de2edb753844c88ea3cd573444675fc1cf | 2,905 | Kudoku | Apache License 2.0 |
src/day3/second/Solution.kt | verwoerd | 224,986,977 | false | null | package day3.second
import tools.Coordinate
import tools.origin
import tools.timeSolution
import java.util.PriorityQueue
import kotlin.test.fail
fun slowMain() = timeSolution { // Took 32 seconds
val points = mutableListOf<Coordinate>()
var last = origin
readLine()!!.split(",").forEach { current ->
// assum... | 0 | Kotlin | 0 | 0 | 554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7 | 6,178 | AoC2019 | MIT License |
src/main/kotlin/com/jackchapman/adventofcode/Day08.kt | crepppy | 317,691,375 | false | null | package com.jackchapman.adventofcode
fun solveDay8(): Pair<Int, Int> {
val instructions = getInput(8)
return calculateAccBeforeRepeat(instructions) to calculateAccAfterInstructionChange(instructions)
}
// Completed in 4mins 5seconds
fun calculateAccBeforeRepeat(instructions: List<String>): Int {
return r... | 0 | Kotlin | 0 | 0 | b49bb8f62b4542791626950846ca07d1eff4f2d1 | 1,544 | aoc2020 | The Unlicense |
src/main/kotlin/leetcode/Problem2064.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
import kotlin.math.max
/**
* https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/
*/
class Problem2064 {
fun minimizedMaximum(n: Int, quantities: IntArray): Int {
var min = 1
var max = quantities[0]
for (i in 1 until quantities.size) {
... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 1,005 | leetcode | MIT License |
src/main/kotlin/_2023/Day08.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2023
import Day
import InputReader
import lcm
class Day08 : Day(2023, 8) {
override val firstTestAnswer = 6
override val secondTestAnswer = 6L
override fun first(input: InputReader): Int {
val (unparsedSteps, unparsedMap) = input.asGroups()
val steps = unparsedSteps.first()
... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 2,071 | advent-of-code | Apache License 2.0 |
src/main/kotlin/dev/thecoati/adventofcode/days/Day2.kt | TheCoati | 725,922,788 | false | {"Kotlin": 7934} | package dev.thecoati.adventofcode.days
import dev.thecoati.adventofcode.FileInput
class Day2: Day {
override fun day(): Int {
return 2
}
override fun title(): String {
return "Cube Conundrum"
}
override fun input(): FileInput {
return FileInput("day2")
}
override... | 0 | Kotlin | 0 | 0 | 6d08b2f3fc26c8710bf28a907715168cdd12ce7f | 1,749 | Advent-of-Code-2023 | MIT License |
strings/MaximumNumberOfVowelsInASubstringOfGivenLength/kotlin/Solution.kt | YaroslavHavrylovych | 78,222,218 | false | {"Java": 284373, "Kotlin": 35978, "Shell": 2994} | /**
* Given a string s and an integer k.
* Return the maximum number of vowel letters in any
* substring of s with length k.
* Vowel letters in English are (a, e, i, o, u).
* <br>
* https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/
*/
class Solution {
val vows = setOf('a'... | 0 | Java | 0 | 2 | cb8e6f7e30563e7ced7c3a253cb8e8bbe2bf19dd | 834 | codility | MIT License |
ceria/07/src/main/kotlin/Solution.kt | VisionistInc | 433,099,870 | false | {"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104} | import java.io.File;
import kotlin.math.abs;
fun main(args : Array<String>) {
val input = File(args.first()).readLines().first().split(",").map { it.toInt() }
println("Solution 1: ${solution1(input)}")
println("Solution 2: ${solution2(input)}")
}
private fun solution1(input: List<Int>) :Int {
val min ... | 0 | Kotlin | 4 | 1 | e22a1d45c38417868f05e0501bacd1cad717a016 | 1,114 | advent-of-code-2021 | MIT License |
src/2020/Day01.kt | mathijs81 | 572,837,783 | false | {"Kotlin": 167658, "Python": 725, "Shell": 57} | package aoc2020
import Solver
private const val EXPECTED_1 = 514579
private const val EXPECTED_2 = 241861950
private class Day01(isTest: Boolean) : Solver(isTest, "/2020") {
fun part1(): Any {
val seen = mutableSetOf<Int>()
readAsLines().forEach {
val value = it.toInt()
v... | 0 | Kotlin | 0 | 2 | 92f2e803b83c3d9303d853b6c68291ac1568a2ba | 1,342 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/_0039_CombinationSum.kt | ryandyoon | 664,493,186 | false | null | // https://leetcode.com/problems/combination-sum
fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> {
return mutableListOf<List<Int>>().also {
buildCombinations(candidates, startIndex = 0, target = target, combination = mutableListOf(), combinations = it)
}
}
private fun buildCombin... | 0 | Kotlin | 0 | 0 | 7f75078ddeb22983b2521d8ac80f5973f58fd123 | 1,042 | leetcode-kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/TotalSteps.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2022 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 1,371 | kotlab | Apache License 2.0 |
Hyperskill/Unit-Converter/Main.kt | Alphabeater | 435,048,407 | false | {"Kotlin": 69566, "Python": 5974} | package converter
enum class Units(val names: List<String>, val value: Double, val type: Char) {
METER(listOf("meters", "meter", "m"), 1.0, 'd'),
KILOMETER(listOf("kilometers", "kilometer", "km"), 1000.0, 'd'),
CENTIMETER(listOf("centimeters", "centimeter", "cm"), 0.01, 'd'),
MILLIMETER(listOf("millime... | 0 | Kotlin | 0 | 0 | 05c8d4614e025ed2f26fef2e5b1581630201adf0 | 4,660 | Archive | MIT License |
src/Day11.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | fun main() {
fun solve(monkeys: List<Monkey>, numRounds: Int): Long {
for(i in 0 until numRounds) {
for(monkey in monkeys) {
monkey.testItems(monkeys)
}
}
val inspectCounts = monkeys.map { it.numInspected }
println(inspectCounts)
printl... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 3,362 | aoc2022 | Apache License 2.0 |
src/main/aoc2016/Day14.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2016
import md5
class Day14(private val salt: String) {
private fun String.threeInARowChar(): Char? {
if (length < 3) {
return null
}
for (i in 2 until length) {
if (this[i - 2] == this[i - 1] && this[i - 1] == this[i]) {
return this[i]
... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,852 | aoc | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.