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/aoc2017/PermutationPromenade.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2017
import komu.adventofcode.utils.rotate
import komu.adventofcode.utils.swap
private val regexSpin = Regex("""s(\d+)""")
private val regexExchange = Regex("""x(\d+)/(\d+)""")
private val regexPartner = Regex("""p(\w)/(\w)""")
private const val DEFAULT_PROGRAMS = "abcdefghijklmnop"
fun ... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 2,176 | advent-of-code | MIT License |
src/Day05.kt | Oli2861 | 572,895,182 | false | {"Kotlin": 16729} | fun prepareInput(input: List<String>): Pair<List<Triple<Int, Int, Int>>, MutableList<ArrayDeque<Char>>> {
val splitIndex = input.indexOfFirst { it.isEmpty() } - 1
val instructionString = input.subList(splitIndex + 2, input.size)
val instructions: List<Triple<Int, Int, Int>> = toInstructions(instructionStri... | 0 | Kotlin | 0 | 0 | 138b79001245ec221d8df2a6db0aaeb131725af2 | 2,462 | Advent-of-Code-2022 | Apache License 2.0 |
src/Day05/Day05.kt | G-lalonde | 574,649,075 | false | {"Kotlin": 39626} | package Day05
import readInput
import java.util.regex.Pattern
fun main() {
fun stackCrates(string: String, piles: List<Stack<Char>>) {
val regex = """\[(.*?)\]"""
val pattern = Pattern.compile(regex)
val matcher = pattern.matcher(string)
while (matcher.find()) {
val g... | 0 | Kotlin | 0 | 0 | 3463c3228471e7fc08dbe6f89af33199da1ceac9 | 3,425 | aoc-2022 | Apache License 2.0 |
src/com/aaron/helloalgorithm/algorithm/数组/_1_两数之和.kt | aaronzzx | 431,740,908 | false | null | package com.aaron.helloalgorithm.algorithm.数组
import com.aaron.helloalgorithm.algorithm.LeetCode
import com.aaron.helloalgorithm.algorithm.Printer
/**
* # 1. 两数之和
*
* 给定一个整数数组 nums和一个整数目标值 target,请你在该数组中找出 和为目标值 target
* 的那两个整数,并返回它们的数组下标。
*
* 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。
*
* 你可以按任意顺序返回答案。
*
* 示... | 0 | Kotlin | 0 | 0 | 2d3d823b794fd0712990cbfef804ac2e138a9db3 | 3,778 | HelloAlgorithm | Apache License 2.0 |
src/day06/Day06.kt | molundb | 573,623,136 | false | {"Kotlin": 26868} | package day06
import readInput
fun main() {
val input = readInput(parent = "src/day06", name = "Day06_input")
println(solvePartOne(input))
println(solvePartTwo(input))
}
private fun solvePartOne(input: List<String>)= solve(input, 4)
private fun solvePartTwo(input: List<String>) = solve(input, 14)
priva... | 0 | Kotlin | 0 | 0 | a4b279bf4190f028fe6bea395caadfbd571288d5 | 1,251 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/bhsoft/decisiontree/SampleApp.kt | bholota | 103,860,306 | false | null | package com.bhsoft.decisiontree
/**
* Kotlin implementation of classification decision tree learning based on
* https://github.com/random-forests/tutorials/blob/master/decision_tree.py
*/
class DecisionTree(val headers: Array<String>) {
private var trainedTree: GraphNode? = null
/**
* Counts how many... | 0 | Kotlin | 0 | 0 | 8578d44459e4f28285df8dc1c087995b20593bff | 6,657 | KotlinDecisionTree | MIT License |
src/Day10.kt | freszu | 573,122,040 | false | {"Kotlin": 32507} | fun main() {
fun xOverCycles(lines: List<String>) = lines.map {
val split = it.split(" ")
split.first() to split.getOrNull(1)?.toInt()
}
.fold(listOf(1)) { acc, (op, arg) ->
when (op) {
"noop" -> acc + (acc.last())
"addx" -> acc + acc.last() +... | 0 | Kotlin | 0 | 0 | 2f50262ce2dc5024c6da5e470c0214c584992ddb | 1,747 | aoc2022 | Apache License 2.0 |
src/Day11.kt | uekemp | 575,483,293 | false | {"Kotlin": 69253} | import kotlin.math.floor
data class Monkey(
val id: Int,
val items: ArrayDeque<Long>,
val operation: (Long) -> Long,
val divideByThree: Boolean,
val divisor: Int,
val nextIdTrue: Int,
val nextIdFalse: Int
) {
var inspections = 0L
var correctionMod = 0L
fun accept(throwItem: T... | 0 | Kotlin | 0 | 0 | bc32522d49516f561fb8484c8958107c50819f49 | 4,759 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/com/kishor/kotlin/algo/sorting/QuickSelectProblem.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.sorting
fun main() {
println(quickselect(mutableListOf(7, 2, 5, 1, 9, 3), 3))
}
fun quickselect(array: MutableList<Int>, k: Int): Int {
// solve using quick sort method
// do the partition logic until partition/pivot + 1 == k
// return partition
var pivot = 0
re... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 1,320 | DS_Algo_Kotlin | MIT License |
src/Day05.kt | andrewgadion | 572,927,267 | false | {"Kotlin": 16973} | import java.util.*
import kotlin.io.path.createTempDirectory
fun main() {
fun parseCrates(input: List<String>): List<MutableList<Char>> {
val crates = input.reversed().drop(1)
val cratesStr = input.last()
val cratesCount = cratesStr.trim().split(" ").last().toInt()
return (1..crates... | 0 | Kotlin | 0 | 0 | 4d091e2da5d45a786aee4721624ddcae681664c9 | 1,478 | advent-of-code-2022 | Apache License 2.0 |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[1004]最大连续1的个数 III.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个由若干 0 和 1 组成的数组 A,我们最多可以将 K 个值从 0 变成 1 。
//
// 返回仅包含 1 的最长(连续)子数组的长度。
//
//
//
// 示例 1:
//
// 输入:A = [1,1,1,0,0,0,1,1,1,1,0], K = 2
//输出:6
//解释:
//[1,1,1,0,0,1,1,1,1,1,1]
//粗体数字从 0 翻转到 1,最长的子数组长度为 6。
//
// 示例 2:
//
// 输入:A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], K = 3
//输出:10
//解释:
//[0,0,1,1,1,1,1,1,1,... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,673 | MyLeetCode | Apache License 2.0 |
src/day05/day05.kt | PS-MS | 572,890,533 | false | null | package day05
import java.io.File
fun main() {
fun part1(input: String): String {
val (boxes, commandLines) = input.split("\r\n\r\n")
val columns = boxes.lines().map { it.chunked(4) }.map { it.map { box -> box.trim() } }
val columnLists: MutableList<MutableList<String>> = mutableListOf()
... | 0 | Kotlin | 0 | 0 | 24f280a1d8ad69e83755391121f6107f12ffebc0 | 2,751 | AOC2022 | Apache License 2.0 |
app/src/main/java/com/droidhats/mapprocessor/PathAlgorithm.kt | RobertBeaudenon | 232,313,026 | false | null | package com.droidhats.mapprocessor
import kotlin.math.pow
import kotlin.math.sqrt
/**
* Function that returns a string of path elements that would display the shortest path between 2 elements
* in a graph of path Nodes.
* @param start starting element
* @param end ending element
* @param pathElements graph of co... | 4 | Kotlin | 4 | 7 | ea136a60a71f5d393f4a5688e86b9c56c6bea7b6 | 8,394 | SOEN390-CampusGuideMap | MIT License |
src/main/kotlin/days/aoc2020/Day23.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2020
import days.Day
class Day23: Day(2020, 23) {
override fun partOne(): Any {
val solution = solve(inputString, 100, 9)
return solution.joinToString("").toInt()
}
override fun partTwo(): Any {
return solve(inputString, 10000000, 1000000).subList(0,2).let {
... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 1,793 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
2015/Day12/src/main/kotlin/Main.kt | mcrispim | 658,165,735 | false | null | import java.io.File
fun main() {
fun part1(input: List<String>): Int {
val jason = input[0]
var sum = 0
var index = 0
while (index < jason.length) {
val c = jason[index]
when (c) {
in setOf('-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9... | 0 | Kotlin | 0 | 0 | 2f4be35e78a8a56fd1e078858f4965886dfcd7fd | 2,965 | AdventOfCode | MIT License |
src/main/kotlin/Day6.kt | i-redbyte | 433,743,675 | false | {"Kotlin": 49932} | fun main() {
val data = readInputFile("day6")
val lines = data.joinToString("")
.split(",")
fun part1(): Long {
val initialData = LongArray(9) { 0 }
lines.map { it.toInt() }
.forEach { initialData[it]++ }
return calculateLanternfish(80, initialData)
}
fu... | 0 | Kotlin | 0 | 0 | 6d4f19df3b7cb1906052b80a4058fa394a12740f | 1,099 | AOC2021 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day18.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2023
import PointL
import areaWithin
import readInput
@OptIn(ExperimentalStdlibApi::class)
object Day18 {
/**
* @param input the puzzle input
* @param getDelta a function to transform a given input line into a [PointL]-Delta (to get to the next point)
*/
private fun solve(input: Lis... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 2,172 | adventOfCode | Apache License 2.0 |
src/day25/Day25.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package day25
import readInput
class Day25 {
fun part1(): String {
val readInput = readInput("day25/input")
return part1(readInput)
}
fun part2(): String {
val readInput = readInput("day25/input")
return part2(readInput)
}
fun part1(input: List<String>): String {
... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 1,787 | adventofcode-2022 | Apache License 2.0 |
src/algorithms/sorting/merge_sort/MergeSort.kt | abdurakhmonoff | 353,686,707 | false | null | package algorithms.sorting.merge_sort
/**
* Implementation of the merge sort algorithm for sorting a list of integers in ascending order.
*/
class MergeSort {
/**
* Recursively sorts the given list by dividing it into halves and merging them.
*
* @param array the list to sort
* @return the s... | 0 | Kotlin | 40 | 107 | cd9746d02b34b54dd0cf8c8dacc2fb91d2a3cc07 | 2,031 | data-structures-and-algorithms-kotlin | MIT License |
src/Day10.kt | juliantoledo | 570,579,626 | false | {"Kotlin": 34375} | fun main() {
fun solve(input: List<String>): Int {
var cycle = 0
var register = 1
var strengthSum = 0
var matrix = MutableList<String>(240) { "." }
fun addCycle() {
if (cycle <=240) {
if (cycle % 40 in (register - 1..register + 1)) {
... | 0 | Kotlin | 0 | 0 | 0b9af1c79b4ef14c64e9a949508af53358335f43 | 1,274 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/java/challenges/coderbyte/FindIntersection.kt | ShabanKamell | 342,007,920 | false | null | package challenges.coderbyte
/*
Have the function FindIntersection(strArr) read the array of strings stored in strArr which will contain 2
elements: the first element will represent a list of comma-separated numbers sorted in ascending order,
the second element will represent a second list of comma-separated numbers ... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,071 | CodingChallenges | Apache License 2.0 |
src/main/java/com/luckystar/advent2020/Advent7.kt | alexeymatveevp | 48,393,486 | false | {"Java": 199293, "Kotlin": 8971} | package com.luckystar.advent2020
fun main() {
val file = object {}.javaClass.getResource("/2020/input_7.txt").readText()
var rules = file.split("\r\n")
rules = rules.filter { rule -> !rule.contains("no other bags") }
val regex = """^(\w+ \w+) bags contain (.*)\.$""".toRegex()
val rightRegex = """... | 0 | Java | 0 | 1 | d140ee8328003e79fbd2e0997cc7a8adf0e59ab2 | 1,953 | adventofcode | Apache License 2.0 |
src/main/kotlin/com/staricka/adventofcode2023/days/Day14.kt | mathstar | 719,656,133 | false | {"Kotlin": 107115} | package com.staricka.adventofcode2023.days
import com.staricka.adventofcode2023.framework.Day
import com.staricka.adventofcode2023.util.Grid
import com.staricka.adventofcode2023.util.GridCell
import com.staricka.adventofcode2023.util.StandardGrid
enum class Rock(override val symbol: Char): GridCell {
ROUND('O'), ... | 0 | Kotlin | 0 | 0 | 8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa | 3,624 | adventOfCode2023 | MIT License |
demo-plural-sight-gradle/src/main/kotlin/demo/objects/teste2.kt | antoniolazaro | 257,624,848 | false | null | package demo.objects
import java.io.File
import java.util.Scanner
import kotlin.math.pow
import java.util.*
import kotlin.math.sqrt
fun main(args: Array<String>) {
createAEuphoniousWord()
}
fun sum(a: Int, b: Int): Int = a + b
val mul2 = { a: Int, b: Int -> a * b }
private fun lambdasDemo() {
println(sum(1... | 0 | Kotlin | 0 | 0 | 9e673057c3255be66fd67479b8198fa129463d95 | 21,225 | kotlin-lab | Apache License 2.0 |
src/main/kotlin/org/kotrix/discrete/automata/GrammarToNFA.kt | JarnaChao09 | 285,169,397 | false | {"Kotlin": 446442, "Jupyter Notebook": 26378} | package org.kotrix.discrete.automata
/**
* Helper function to wrap output in visual line breaks
*
* @param title title of the specific section
* @param separator string to use as the line break string
* @param n length of the line break
* @param block block of code to run in between the line breaks
*/
fun wrap(... | 0 | Kotlin | 1 | 5 | c5bb19457142ce1f3260e8fed5041a4d0c77fb14 | 21,383 | Kotrix | MIT License |
2022/src/main/kotlin/Day21.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import Day21.Operation.*
object Day21 {
fun part1(input: String): Long {
val monkeys = parseMonkeys(input).associateBy { it.name }
return getYell("root", monkeys)
}
fun part2(input: String): Long {
val monkeyMap = parseMonkeys(input).filter { it.name != "humn" }.associateBy { it.name }
val yel... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 4,465 | advent-of-code | MIT License |
src/day23/day23.kt | kacperhreniak | 572,835,614 | false | {"Kotlin": 85244} | package day23
import readInput
private fun parse(input: List<String>): HashMap<Int, HashSet<Int>> {
fun HashMap<Int, HashSet<Int>>.addItem(row: Int, col: Int) {
val values = getOrDefault(row, hashSetOf())
values.add(col)
put(row, values)
}
val result = HashMap<Int, HashSet<Int>>()... | 0 | Kotlin | 1 | 0 | 03368ffeffa7690677c3099ec84f1c512e2f96eb | 4,716 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/github/freekdb/aoc2019/Day03.kt | FreekDB | 228,241,398 | false | null | package com.github.freekdb.aoc2019
import java.io.File
private const val DIRECTION_UP = 'U'
private const val DIRECTION_DOWN = 'D'
private const val DIRECTION_LEFT = 'L'
private const val DIRECTION_RIGHT = 'R'
// Heavily inspired by <NAME>:
// https://github.com/tginsberg/advent-2019-kotlin/blob/master/src/main/kotl... | 0 | Kotlin | 0 | 1 | fd67b87608bcbb5299d6549b3eb5fb665d66e6b5 | 2,107 | advent-of-code-2019 | Apache License 2.0 |
src/main/kotlin/com/kishor/kotlin/algo/algorithms/dynamicprogramming/KnapSackProblem.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.algorithms.dynamicprogramming
import kotlin.math.max
fun main() {
val items = mutableListOf<List<Int>>()
items.add(listOf(2, 2))
items.add(listOf(3, 3))
items.add(listOf(4, 10))
items.add(listOf(5, 7))
items.add(listOf(2, 4))
println(knapsackProblem(items, 7... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 1,559 | DS_Algo_Kotlin | MIT License |
src/main/kotlin/dev/tasso/adventofcode/_2021/day02/Day02.kt | AndrewTasso | 433,656,563 | false | {"Kotlin": 75030} | package dev.tasso.adventofcode._2021.day02
import dev.tasso.adventofcode.Solution
import kotlin.math.absoluteValue
class Day02 : Solution<Int> {
override fun part1(input: List<String>): Int {
// Split the input into lists of horizontal and vertical movements
val (horizontalMovements, verticalMov... | 0 | Kotlin | 0 | 0 | daee918ba3df94dc2a3d6dd55a69366363b4d46c | 1,739 | advent-of-code | MIT License |
year2023/day07/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day07/part2/Year2023Day07Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
To make things a little more interesting, the Elf introduces one additional rule. Now, `J` cards are
jokers - wildcards that can act like whatever card would make the hand the strongest type possible.
To balance this, `J` cards are now the weakest individual cards, weaker even than 2. The other ca... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 1,998 | AdventOfCode | MIT License |
aoc21/day_14/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
class Polymer(var pairs: Map<String, Long>, val last: Char) {
var chars = mutableMapOf<Char, Long>()
constructor (str: String) : this(
str.windowed(2).groupingBy { it }.eachCount().mapValues { it.value.toLong() }.toMap(),
str.last(),
)
fun step(rules: Map<String, S... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 1,334 | advent-of-code | MIT License |
src/main/kotlin/days/Day9.kt | mir47 | 433,536,325 | false | {"Kotlin": 31075} | package days
class Day9 : Day(9) {
override fun partOne(): Int {
var result = 0
inputList.forEachIndexed { i, s ->
(s.indices).forEach { j ->
var passH = when (j) {
0 -> s[j].digitToInt() < s[j+1].digitToInt()
s.length-1 -> s[j].d... | 0 | Kotlin | 0 | 0 | 686fa5388d712bfdf3c2cc9dd4bab063bac632ce | 3,164 | aoc-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day22.kt | hughjdavey | 317,575,435 | false | null | package days
import splitOnBlank
class Day22 : Day(22) {
// 34566
override fun partOne(): Any {
return getGame(false).playUntilOver().score
}
// 31854
override fun partTwo(): Any {
return getGame(true).playUntilOver().score
}
private fun getGame(recursive: Boolean): Comb... | 0 | Kotlin | 0 | 1 | 63c677854083fcce2d7cb30ed012d6acf38f3169 | 2,533 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/days/Day18.kt | andilau | 433,504,283 | false | {"Kotlin": 137815} | package days
@AdventOfCodePuzzle(
name = "Snailfish",
url = "https://adventofcode.com/2021/day/18",
date = Date(day = 18, year = 2021)
)
class Day18(val input: List<String>) : Puzzle {
private val snailfishNumbers = input.map(SnailfishNumber::from)
override fun partOne() =
snailfishNumbers... | 0 | Kotlin | 0 | 0 | b3f06a73e7d9d207ee3051879b83e92b049a0304 | 5,116 | advent-of-code-2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistinctSubsequences.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,596 | kotlab | Apache License 2.0 |
src/main/kotlin/shortestpath/전보.kt | CokeLee777 | 614,704,937 | false | null | package shortestpath
import java.util.*
import kotlin.math.*
private const val INF = 1e9.toInt()
fun main(){
val sc = Scanner(System.`in`)
val n = sc.nextInt()
val m = sc.nextInt()
val start = sc.nextInt()
//최단거리 테이블 초기화
val distances = IntArray(n + 1) { INF }
//그래프 초기화
val graph = m... | 0 | Kotlin | 0 | 0 | 919d6231c87fe4ee7fda6c700099e212e8da833f | 1,882 | algorithm | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[34]在排序数组中查找元素的第一个和最后一个位置.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | //给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。
//
// 如果数组中不存在目标值 target,返回 [-1, -1]。
//
// 进阶:
//
//
// 你可以设计并实现时间复杂度为 O(log n) 的算法解决此问题吗?
//
//
//
//
// 示例 1:
//
//
//输入:nums = [5,7,7,8,8,10], target = 8
//输出:[3,4]
//
// 示例 2:
//
//
//输入:nums = [5,7,7,8,8,10], target = 6
//输出:[-1,-1]
//
// 示例... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,696 | MyLeetCode | Apache License 2.0 |
src/Year2022Day11.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | private class Monkey(text: String) {
val itemWorryLevels: MutableList<Long>
val operation: (Long) -> Long
val testDivisor: Int
val trueTarget: Int
val falseTarget: Int
var inspectTimes: Long = 0
init {
val lines = text.split("\n")
itemWorryLevels = lines[1].substringAfter(":... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 2,518 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/Day17.kt | pavittr | 317,532,861 | false | null | import java.io.File
import java.nio.charset.Charset
fun main() {
fun part1(inputFile: String) {
val input = File(inputFile).readLines(Charset.defaultCharset())
var elements = input.flatMapIndexed { y, line ->
line.mapIndexed { x, c ->
if (c == '#') {
... | 0 | Kotlin | 0 | 0 | 3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04 | 5,926 | aoc2020 | Apache License 2.0 |
src/Day20.kt | tigerxy | 575,114,927 | false | {"Kotlin": 21255} | fun main() {
fun part1(input: List<String>): Int {
val result = input
.parse()
.scramble()
return (1000..3000 step 1000)
.map { it + result.indexOf(0) }
.sumOf { result.getMod(it) }
}
fun part2(input: List<String>): Int = 0
val day = "20... | 0 | Kotlin | 0 | 1 | d516a3b8516a37fbb261a551cffe44b939f81146 | 1,384 | aoc-2022-in-kotlin | Apache License 2.0 |
aoc-2018/src/main/kotlin/nl/jstege/adventofcode/aoc2018/days/Day07.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2018.days
import nl.jstege.adventofcode.aoccommon.days.Day
class Day07 : Day(title = "The Sum of Its Parts") {
private companion object {
private val PARSE_INDICES = listOf(5, 36)
private const val WORKER_AMOUNT = 5
}
override fun first(input: Sequence<St... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 2,381 | AdventOfCode | MIT License |
src/main/kotlin/day13/Day13.kt | TheSench | 572,930,570 | false | {"Kotlin": 128505} | package day13
import groupByBlanks
import mapGroups
import runDay
fun main() {
fun part1(input: List<String>) = input.groupByBlanks()
.mapGroups { it.toPacket() }
.mapIndexed { index, packets ->
(index + 1) to packets.first().compareTo(packets.last())
}.filter { (_, comparison)... | 0 | Kotlin | 0 | 0 | c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb | 3,192 | advent-of-code-2022 | Apache License 2.0 |
src/day01/Day01.kt | Frank112 | 572,910,492 | false | null | package day01
import readInput
fun main() {
fun computeCarriedFoodByElf(input: List<String>): List<Int> {
val carriedFoodByElfs = mutableListOf<Int>()
var carriedFoodByElf = 0
for (s in input) {
if(s.isBlank()) {
carriedFoodByElfs.add(carriedFoodByElf)
... | 0 | Kotlin | 0 | 0 | 1e927c95191a154efc0fe91a7b89d8ff526125eb | 1,254 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinReorder.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,634 | kotlab | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2022/day22/Day22.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day22
import com.jacobhyphenated.advent2022.Day
typealias Board = Map<Pair<Int,Int>, Tile>
/**
* Day 22: Monkey Map
*
* You are given an irregularly shaped map in a 2d grid
* The map contains '.' for empty space, and '#' for walls.
* empty space means the map should wrap a... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 9,753 | advent2022 | The Unlicense |
src/Day04.kt | sabercon | 648,989,596 | false | null | fun main() {
fun hasRequiredKeys(passport: Map<String, String>): Boolean {
return passport.keys.containsAll(listOf("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"))
}
fun hasValidValues(passport: Map<String, String>): Boolean {
return passport.all { (k, v) ->
when (k) {
... | 0 | Kotlin | 0 | 0 | 81b51f3779940dde46f3811b4d8a32a5bb4534c8 | 1,285 | advent-of-code-2020 | MIT License |
src/Day25.kt | frozbiz | 573,457,870 | false | {"Kotlin": 124645} | import kotlin.math.ceil
import kotlin.math.pow
import kotlin.math.floor
import kotlin.math.log
fun main() {
fun snafuToDecimal(num: String): Long {
var power = 1L
var answer = 0L
for (digit in num.trim().reversed()) {
answer += when (digit) {
'=' -> power * -2
... | 0 | Kotlin | 0 | 0 | 4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388 | 1,686 | 2022-aoc-kotlin | Apache License 2.0 |
2023/src/main/kotlin/Day17.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import java.util.PriorityQueue
object Day17 {
fun part1(input: String) = solve(input, 0, 3)
fun part2(input: String) = solve(input, 4, 10)
private enum class Direction { NORTH, EAST, SOUTH, WEST }
private data class Pos(val x: Int, val y: Int)
private data class Crucible(val direction: Direction, val po... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 3,413 | advent-of-code | MIT License |
src/day02/Day02.kt | S-Flavius | 573,063,719 | false | {"Kotlin": 6843} | package day02
import readInput
fun main() {
fun part1(input: List<String>): Int {
var curScore = 0
for (line in input) {
val values = line.split(" ")
when {
values[1] == "X" -> {
curScore += 1
when {
... | 0 | Kotlin | 0 | 0 | 47ce29125ff6071edbb07ae725ac0b9d672c5356 | 2,398 | AoC-Kotlin-2022 | Apache License 2.0 |
day05/Kotlin/day05.kt | Ad0lphus | 353,610,043 | false | {"C++": 195638, "Python": 139359, "Kotlin": 80248} | import java.io.*
import kotlin.math.abs
fun print_day_5() {
val yellow = "\u001B[33m"
val reset = "\u001b[0m"
val green = "\u001B[32m"
println(yellow + "-".repeat(25) + "Advent of Code - Day 5" + "-".repeat(25) + reset)
println(green)
val process = Runtime.getRuntime().exec("figlet Hydroth... | 0 | C++ | 0 | 0 | 02f219ea278d85c7799d739294c664aa5a47719a | 3,049 | AOC2021 | Apache License 2.0 |
src/main/kotlin/aoc2017/day02_corruption_checksum/CorruptionChecksum.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package aoc2017.day02_corruption_checksum
fun main() {
util.solve(53978, ::partOne)
util.solve(314, ::partTwo)
}
private val RE_RUN_OF_SPACES = Regex("\\s+")
private fun checksum(spreadsheet: String, rowChecksum: (List<Int>) -> Int) =
spreadsheet
.lines()
.sumOf {
rowChecksum(... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 1,121 | aoc-2021 | MIT License |
src/day02/Day02.kt | mherda64 | 512,106,270 | false | {"Kotlin": 10058} | package day02
import readInput
fun main() {
data class Operation(val direction: String, val amount: Int)
fun part1(input: List<String>): Int {
var position = 0;
var depth = 0;
input.map { it.split(" ") }
.map { Operation(it[0], it[1].toInt()) }
.forEach { (dire... | 0 | Kotlin | 0 | 0 | d04e179f30ad6468b489d2f094d6973b3556de1d | 1,337 | AoC2021_kotlin | Apache License 2.0 |
src/Day13.kt | felldo | 572,233,925 | false | {"Kotlin": 76496} | fun main() {
fun addToList(a: String, elements: MutableList<String>) {
var str = a
while (str != "") {
if (str[0] != '[') {
elements.add(str.substringBefore(","))
str = if (!str.contains(',')) "" else str.substringAfter(",")
} else {
... | 0 | Kotlin | 0 | 0 | 0ef7ac4f160f484106b19632cd87ee7594cf3d38 | 2,986 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day03.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | fun main() {
val lowercase = 'a'..'z'
val uppercase = 'A'..'Z'
fun part1(input: List<String>): Int {
var score = 0
for (line in input) {
val left = line.substring(0 until line.length / 2).toCharArray().toSet()
val right = line.substring(line.length / 2 until line.len... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 1,312 | Advent-Of-Code-2022 | Apache License 2.0 |
LeetCode/Kotlin/MaxIncreaseKeepingSkyline.kt | vale-c | 177,558,551 | false | null | /**
* 807. Max Increase to Keep City Skyline
* https://leetcode.com/problems/max-increase-to-keep-city-skyline/
*/
class MaxIncreaseKeepingSkyline {
fun maxIncreaseKeepingSkyline(grid: Array<IntArray>): Int {
val maxPerLineAndColumn: Pair<List<Int>, List<Int>> = getMaxPerLineAndColumn(grid)
val ... | 0 | Java | 5 | 9 | 977e232fa334a3f065b0122f94bd44f18a152078 | 1,314 | CodingInterviewProblems | MIT License |
src/main/kotlin/com/londogard/fuzzymatch/FuzzyMatcher.kt | londogard | 225,202,364 | false | null | package com.londogard.fuzzymatch
import kotlin.math.min
class FuzzyMatcher(private val scoreConfig: ScoreConfig = ScoreConfig()) {
data class Result(val indices: List<Int>, val score: Int, val text: String? = null)
private data class DataHolder(val textLeft: String, val matches: List<Int>, val recursiveResult... | 1 | Kotlin | 0 | 2 | f6df4d4ef699e3af5d857bba100fecce2c7fd879 | 6,159 | fuzzy-match-kt | Apache License 2.0 |
algorithms/src/main/kotlin/com/kotlinground/algorithms/sorting/mergesort/mergesort.kt | BrianLusina | 113,182,832 | false | {"Kotlin": 483489, "Shell": 7283, "Python": 1725} | package com.kotlinground.algorithms.sorting.mergesort
private fun combineSortedArrays(arrayOne: IntArray, arrayTwo: IntArray): IntArray {
var arrayOneIndex = 0
var arrayTwoIndex = 0
var mergedArrayIndex = 0
val mergedArray = IntArray(arrayOne.size + arrayTwo.size)
// both arrays have some items l... | 1 | Kotlin | 1 | 0 | 5e3e45b84176ea2d9eb36f4f625de89d8685e000 | 1,936 | KotlinGround | MIT License |
src/main/kotlin/de/soerenhenning/mimwidth/ExactMimCalculator.kt | SoerenHenning | 107,282,322 | false | {"Kotlin": 47246} | package de.soerenhenning.mimwidth
import com.google.common.graph.Graph
import de.soerenhenning.mimwidth.graphs.createCut
class ExactMimCalculator<T>(private val graph: Graph<T>, private val treeDecomposition: TreeDecomposition<T>) {
fun compute(): TreeDecomposition<T> {
val tree = treeDecomposition.tree
... | 0 | Kotlin | 0 | 0 | 5b49df3716acd6762341453d50bc573b890c87cc | 3,056 | MIM-Width | Apache License 2.0 |
advent-of-code-2020/src/test/java/aoc/Day3TobogganTrajectory.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | package aoc
import org.assertj.core.api.KotlinAssertions.assertThat
import org.junit.Test
class Day3TobogganTrajectory {
private fun rideToboggan(map: Map<Point, Char>, pathFunction: (Point) -> Point): Map<Point, Char> {
val maxX = map.keys.map { it.x }.max() ?: 0
val maxY = map.keys.map { it.y }.... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 16,561 | advent-of-code | MIT License |
src/cn/leetcode/codes/simple50/Simple50.kt | shishoufengwise1234 | 258,793,407 | false | {"Java": 771296, "Kotlin": 68641} | package cn.leetcode.codes.simple50
import cn.leetcode.codes.out
fun main() {
// val x = 2.0000
// val n = 10
val x = 2.0000
val n = -2
val re = myPow(x, n)
out("re = $re")
}
/*
50. Pow(x, n)
实现 pow(x, n) ,即计算 x 的 n 次幂函数(即,xn)。
示例 1:
输入:x = 2.00000, n = 10
输出:1024.00000
示例 2:
输入:x = 2.1... | 0 | Java | 0 | 0 | f917a262bcfae8cd973be83c427944deb5352575 | 972 | LeetCodeSimple | Apache License 2.0 |
src/aoc2023/Day6.kt | RobertMaged | 573,140,924 | false | {"Kotlin": 225650} | package aoc2023
import utils.checkEquals
import utils.readInputAsText
fun main(): Unit = with(Day6) {
part1(testInput).checkEquals(288)
part1(input)
.checkEquals(219849)
// .sendAnswer(part = 1, day = "6", year = 2023)
part2(testInput).checkEquals(71503)
part2(input)
.checkEqu... | 0 | Kotlin | 0 | 0 | e2e012d6760a37cb90d2435e8059789941e038a5 | 1,675 | Kotlin-AOC-2023 | Apache License 2.0 |
src/main/kotlin/g2101_2200/s2146_k_highest_ranked_items_within_a_price_range/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2101_2200.s2146_k_highest_ranked_items_within_a_price_range
// #Medium #Array #Sorting #Breadth_First_Search #Matrix #Heap_Priority_Queue
// #2023_06_25_Time_1373_ms_(100.00%)_Space_78_MB_(100.00%)
import java.util.ArrayDeque
import java.util.Collections
import java.util.Deque
class Solution {
fun highe... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,983 | LeetCode-in-Kotlin | MIT License |
src/Day03.kt | Inn0 | 573,532,249 | false | {"Kotlin": 16938} | class Backpack constructor(
val compartment1: String,
val compartment2: String,
val str: String = compartment1 + compartment2
) {
fun getDupeVal(): Char {
for (c1 in compartment1) {
for (c2 in compartment2) {
if (c1 == c2){
return c1
... | 0 | Kotlin | 0 | 0 | f35b9caba5f0c76e6e32bc30196a2b462a70dbbe | 2,882 | aoc-2022 | Apache License 2.0 |
advent-of-code-2022/src/Day19.kt | osipxd | 572,825,805 | false | {"Kotlin": 141640, "Shell": 4083, "Scala": 693} | fun main() {
val testInput = readInput("Day19_test")
val input = readInput("Day19")
"Part 1" {
part1(testInput) shouldBe 33
measureAnswer { part1(input) }
}
"Part 2" {
part2(testInput) shouldBe (56 * 62)
measureAnswer { part2(input) }
}
}
private fun readInput(... | 0 | Kotlin | 0 | 5 | 6a67946122abb759fddf33dae408db662213a072 | 5,541 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day03/day03.kt | andrew-suprun | 725,670,189 | false | {"Kotlin": 18354, "Python": 17857, "Dart": 8224} | package day03
import java.io.File
fun main() {
run(::part1)
run(::part2)
}
data class Number(val value: Int, val row: Int, val colStart: Int, var colEnd: Int)
fun run(part: (numbers: List<Number>, char: Char, row: Int, col: Int) -> Int) {
val lines = File("input.data").readLines()
val numbers = pars... | 0 | Kotlin | 0 | 0 | dd5f53e74e59ab0cab71ce7c53975695518cdbde | 2,361 | AoC-2023 | The Unlicense |
advent-of-code/src/main/kotlin/solution/Day07.kt | kressnick25 | 573,285,946 | false | null | package solution
import java.lang.Exception
import java.lang.Integer.parseInt
import java.lang.NullPointerException
data class File (
val size: Int,
val name: String
)
class Dir constructor(val name: String, val parent: Dir?, var files: ArrayDeque<File> = ArrayDeque(), val subDirs: ArrayDeque<Dir> = ArrayDeq... | 0 | Rust | 0 | 0 | 203284a1941e018c7ad3c5d719a6e366013ffb82 | 3,270 | advent-of-code-2022 | MIT License |
src/Day07.kt | thiyagu06 | 572,818,472 | false | {"Kotlin": 17748} | import aoc22.printIt
import java.io.File
fun main() {
fun parseInput(file: String): List<String> {
return File(file).readLines()
}
fun part1(): Long {
val input = parseInput("input.txt/day07.txt")
val dirs = mutableListOf(Dir(null))
var current: Dir = dirs.first()
... | 0 | Kotlin | 0 | 0 | 55a7acdd25f1a101be5547e15e6c1512481c4e21 | 1,852 | aoc-2022 | Apache License 2.0 |
src/Day15.kt | Tomcat88 | 572,566,485 | false | {"Kotlin": 52372} | import kotlin.math.abs
object Day15 {
fun part1(input: List<Pair<Pair<Int, Int>, Pair<Int, Int>>>) {
val grid = mutableMapOf<Pair<Int, Int>, Char>()
val rowToInspect = 2000000
input.forEach { (sensor, beacon) ->
sensor.log("s")
beacon.log("b")
val (sX, s... | 0 | Kotlin | 0 | 0 | 6d95882887128c322d46cbf975b283e4a985f74f | 4,144 | advent-of-code-2022 | Apache License 2.0 |
src/Day09/Solution.kt | cweinberger | 572,873,688 | false | {"Kotlin": 42814} | package Day09
import readInput
import kotlin.math.abs
/**
* Initial state:
......
......
......
......
H.....
*/
fun main() {
fun Boolean.toInt() = if (this) 1 else 0
fun parseInstructions(input: List<String>) : List<Pair<Char, Int>> {
return input.map { line ->
lin... | 0 | Kotlin | 0 | 0 | 883785d661d4886d8c9e43b7706e6a70935fb4f1 | 4,335 | aoc-2022 | Apache License 2.0 |
src/ThreeSum2.kt | max-f | 221,919,191 | false | {"Python": 13459, "Kotlin": 8011} | import java.io.File
fun main() {
val s = ThreeSumSolution()
val inputStrRaw = File("/home/keks/input_long").readText(Charsets.UTF_8)
val inputStr = inputStrRaw.slice(1 until inputStrRaw.length - 1)
val inputIntArr = inputStr.trim().split(",").toList().map { it.toInt() }.toIntArray()
// Thread.sleep(... | 0 | Python | 0 | 0 | 3fc1888484531a1a23b880f9875614e56f846564 | 2,634 | leetcode | MIT License |
src/main/kotlin/me/peckb/aoc/_2018/calendar/day11/Day11.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2018.calendar.day11
import javax.inject.Inject
import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory
import kotlin.Int.Companion.MIN_VALUE
class Day11 @Inject constructor(private val generatorFactory: InputGeneratorFactory) {
fun partOne(filename: String) = generatorFactory.forF... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,639 | advent-of-code | MIT License |
src/main/kotlin/de/tek/adventofcode/y2022/day04/CampCleanup.kt | Thumas | 576,671,911 | false | {"Kotlin": 192328} | package de.tek.adventofcode.y2022.day04
import de.tek.adventofcode.y2022.util.readInputLines
class AssignmentPair(code: String) {
private val sections = code.split(',').map { parseLimits(it) }.map { IntRange(it[0], it[1]) }
private fun parseLimits(it: String) = it.split('-').map { limit -> limit.toInt() }.ta... | 0 | Kotlin | 0 | 0 | 551069a21a45690c80c8d96bce3bb095b5982bf0 | 1,245 | advent-of-code-2022 | Apache License 2.0 |
src/Day18.kt | MickyOR | 578,726,798 | false | {"Kotlin": 98785} | fun main() {
var dx: MutableList<Int> = mutableListOf(0, 1, 0, -1, 0, 0)
var dy: MutableList<Int> = mutableListOf(-1, 0, 1, 0, 0, 0)
var dz: MutableList<Int> = mutableListOf(0, 0, 0, 0, -1, 1)
fun part1(input: List<String>): Int {
val tam = 20
var grid = Array(tam) { Array(tam) { Boolea... | 0 | Kotlin | 0 | 0 | c24e763a1adaf0a35ed2fad8ccc4c315259827f0 | 3,314 | advent-of-code-2022-kotlin | Apache License 2.0 |
solutions/src/MaxDiffYouCanGetFromChangingInteger.kt | JustAnotherSoftwareDeveloper | 139,743,481 | false | {"Kotlin": 305071, "Java": 14982} | /**
* https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer/
*/
class MaxDiffYouCanGetFromChangingInteger {
fun maxDiff(num: Int) : Int {
val numMap = buildNumMap(num)
var min = Int.MAX_VALUE
var max = Int.MIN_VALUE
for(x in 0 until 10) {
fo... | 0 | Kotlin | 0 | 0 | fa4a9089be4af420a4ad51938a276657b2e4301f | 1,769 | leetcode-solutions | MIT License |
src/main/kotlin/Problem26.kt | jimmymorales | 496,703,114 | false | {"Kotlin": 67323} | import java.util.Comparator
/**
* Reciprocal cycles
*
* A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to
* 10 are given:
*
* 1/2 = 0.5
* 1/3 = 0.(3)
* 1/4 = 0.25
* 1/5 = 0.2
* 1/6 = 0.1(6)
* 1/7 = 0.(142857)
* 1/8 = 0.125
* 1/9 = ... | 0 | Kotlin | 0 | 0 | e881cadf85377374e544af0a75cb073c6b496998 | 1,815 | project-euler | MIT License |
src/main/kotlin/aoc2015/Day14.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2015
import AoCDay
import util.match
// https://adventofcode.com/2015/day/14
object Day14 : AoCDay<Int>(
title = "Reindeer Olympics",
part1Answer = 2696,
part2Answer = 1084,
) {
private class Reindeer(val speed: Int, val goSeconds: Int, val restSeconds: Int) {
fun travelFor(seconds:... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 2,110 | advent-of-code-kotlin | MIT License |
src/main/kotlin/com/jacobhyphenated/advent2023/day10/Day10.kt | jacobhyphenated | 725,928,124 | false | {"Kotlin": 121644} | package com.jacobhyphenated.advent2023.day10
import com.jacobhyphenated.advent2023.Day
import java.util.*
/**
* Day 10: Pipe Maze
*
* The puzzle input describes a maze of pipes. Each character represents the shape of a pipe
* with the '.' character meaning an empty spaces.
*
* Start at the S symbol, which conne... | 0 | Kotlin | 0 | 0 | 90d8a95bf35cae5a88e8daf2cfc062a104fe08c1 | 8,786 | advent2023 | The Unlicense |
src/Day11.kt | rbraeunlich | 573,282,138 | false | {"Kotlin": 63724} | fun main() {
fun parseOperation(operationLine: String): (Long) -> Long {
val operationString = operationLine.trim().replace("Operation: new = old ", "")
val operand = operationString.split(" ")[0]
val numberString = operationString.split(" ")[1]
if (numberString == "old") {
... | 0 | Kotlin | 0 | 1 | 3c7e46ddfb933281be34e58933b84870c6607acd | 5,281 | advent-of-code-2022 | Apache License 2.0 |
src/Utils.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import kotlin.math.abs
typealias Matrix = Array<IntArray>
typealias BooleanMatrix = Array<BooleanArray>
typealias Int3DMatrix = Array<Array<IntArray>>
typealias Boolean3DMatrix = Array<Array<BooleanArray>>
/**
* Reads lines from the g... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 2,798 | AOC2022 | Apache License 2.0 |
src/day5/Day05.kt | omarshaarawi | 573,867,009 | false | {"Kotlin": 9725} | package day5
import java.io.File
data class Operation(val move: Int, val from: Int, val to: Int)
fun main() {
val charMatch = """\[(\w)\]""".toRegex()
val moveMatch = """move (\w+) from (\w) to (\w)""".toRegex()
fun parseStack(stacks: String) = stacks.split("\n")
.reversed()
.asSequence(... | 0 | Kotlin | 0 | 0 | 4347548045f12793a8693c4d31fe3d3dade5100a | 2,277 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Year2022Day05.kt | zhangt2333 | 575,260,256 | false | {"Kotlin": 34993} | import java.util.Stack
fun main() {
fun handle(input: List<String>, handler: (Array<Stack<Char>>, Int, Int, Int) -> Unit): String {
val borderLine = input.indexOf("")
val stacks = Array<Stack<Char>>(input[borderLine - 1].count { it.isDigit() } + 1) { Stack() }
for ((colIndex, value) in inp... | 0 | Kotlin | 0 | 0 | cdba887c4df3a63c224d5a80073bcad12786ac71 | 1,812 | aoc-2022-in-kotlin | Apache License 2.0 |
day14/src/main/kotlin/Day14.kt | bzabor | 160,240,195 | false | null | class Day14(private val input: List<String>) {
val recipeMin = 607331
val recipies = mutableListOf(3, 7)
var elf1Index = 0
var elf2Index = 1
var tryCount = 1
fun part1(): Int {
while (recipies.size <= recipeMin + 10) {
tryCount++
recipies.addAll(nextRecipes())... | 0 | Kotlin | 0 | 0 | 14382957d43a250886e264a01dd199c5b3e60edb | 3,166 | AdventOfCode2018 | Apache License 2.0 |
src/main/kotlin/com/github/dangerground/aoc2020/Day20.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
import com.github.dangerground.aoc2020.util.World
fun main() {
val process = Day20(DayInput.batchesOfStringList(20))
println("result part 1: ${process.part1()}")
println("result part 2: ${process.part2()}")
}
cl... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 8,133 | adventofcode-2020 | MIT License |
LeetCode/0789. Escape The Ghosts/Solution.kt | InnoFang | 86,413,001 | false | {"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410} | /**
* 40 / 40 test cases passed.
* Status: Accepted
* Runtime: 256 ms
*/
class Solution {
fun escapeGhosts(ghosts: Array<IntArray>, target: IntArray): Boolean {
val distance = fun(x: Int, y: Int) = Math.abs(x - target[0]) + Math.abs(y - target[1])
val d = distance(0, 0)
ghosts.forEach { ... | 0 | C++ | 8 | 20 | 2419a7d720bea1fd6ff3b75c38342a0ace18b205 | 1,055 | algo-set | Apache License 2.0 |
Problems/Algorithms/1162. As Far from Land as Possible/FarLand.kt | xuedong | 189,745,542 | false | {"Kotlin": 332182, "Java": 294218, "Python": 237866, "C++": 97190, "Rust": 82753, "Go": 37320, "JavaScript": 12030, "Ruby": 3367, "C": 3121, "C#": 3117, "Swift": 2876, "Scala": 2868, "TypeScript": 2134, "Shell": 149, "Elixir": 130, "Racket": 107, "Erlang": 96, "Dart": 65} | class Solution {
fun maxDistance(grid: Array<IntArray>): Int {
val n = grid.size
val m = grid[0].size
val neighbors = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0))
val visited = Array(n) { BooleanArray(m) { false } }
val q... | 0 | Kotlin | 0 | 1 | 5e919965b43917eeee15e4bff12a0b6bea4fd0e7 | 1,386 | leet-code | MIT License |
src/com/ncorti/aoc2023/Day15.kt | cortinico | 723,409,155 | false | {"Kotlin": 76642} | package com.ncorti.aoc2023
fun main() {
fun String.computeHash(): Int {
var current = 0
toCharArray().forEach {
current += it.toInt()
current *= 17
current %= 256
}
return current
}
fun parseInput() = getInputAsText("15") {
split... | 1 | Kotlin | 0 | 1 | 84e06f0cb0350a1eed17317a762359e9c9543ae5 | 1,834 | adventofcode-2023 | MIT License |
src/Day02a.kt | palex65 | 572,937,600 | false | {"Kotlin": 68582} | fun calc(o: Int, r: Int): Int = r + 1 + when(r - o) {
-2,1 -> 6 // Win
2,-1 -> 0 // Lose
else /*0*/ -> 3 // Draw
}
fun part1a(lines: List<String>): Int = lines.sumOf { calc(it[0] - 'A', it[2] - 'X') }
fun part2a(lines: List<String>): Int = lines.sumOf {
val o = it[0] - 'A'
... | 0 | Kotlin | 0 | 2 | 35771fa36a8be9862f050496dba9ae89bea427c5 | 673 | aoc2022 | Apache License 2.0 |
solutions/aockt/y2022/Y2022D14.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2022
import aockt.y2022.Y2022D14.FallingSandSimulation.*
import io.github.jadarma.aockt.core.Solution
object Y2022D14 : Solution {
/** Represents a discrete point in 2D space. */
private data class Point(val x: Int, val y: Int)
/** Simulates a potentially infinite grid of [Cell]s. If [max... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 4,156 | advent-of-code-kotlin-solutions | The Unlicense |
src/Day04.kt | oleksandrbalan | 572,863,834 | false | {"Kotlin": 27338} | fun main() {
val input = readInput("Day04")
.filterNot { it.isEmpty() }
.map {
val (elf1, elf2) = it.split(",")
elf1.range to elf2.range
}
val part1 = input.count { (range1, range2) ->
range1.contains(range2) || range2.contains(range1)
}
println... | 0 | Kotlin | 0 | 2 | 1493b9752ea4e3db8164edc2dc899f73146eeb50 | 709 | advent-of-code-2022 | Apache License 2.0 |
src/day08/Day08.kt | schrami8 | 572,631,109 | false | {"Kotlin": 18696} | package day08
import readInput
fun visibleFromLeft(line: ArrayList<Int>, index: Int): Boolean {
for (i in 0 until index) {
if (line[i] >= line[index])
return false
}
return true
}
fun visibleFromRight(line: ArrayList<Int>, index: Int): Boolean {
for (i in index + 1 until line.size... | 0 | Kotlin | 0 | 0 | 215f89d7cd894ce58244f27e8f756af28420fc94 | 3,896 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2023/day18/day18Solver.kt | Advent-of-Code-Netcompany-Unions | 726,531,711 | false | {"Kotlin": 94973} | package aoc2023.day18
import lib.*
import lib.twoDimensional.*
suspend fun main() {
setupChallenge().solveChallenge()
}
fun setupChallenge(): Challenge<List<Instruction>> {
return setup {
day(18)
year(2023)
//input("example.txt")
parser {
it.readLines()
... | 0 | Kotlin | 0 | 0 | a77584ee012d5b1b0d28501ae42d7b10d28bf070 | 4,236 | AoC-2023-DDJ | MIT License |
src/Day04.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | fun main() {
val testInput = readInput("Day04_test")
check(part1(testInput) == 2)
check(part2(testInput) == 4)
val input = readInput("Day04")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
return input.map(::parseLine)
.count { (first, s... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 999 | aoc-22 | Apache License 2.0 |
src/main/java/com/barneyb/aoc/aoc2016/day17/TwoStepsForward.kt | barneyb | 553,291,150 | false | {"Kotlin": 184395, "Java": 104225, "HTML": 6307, "JavaScript": 5601, "Shell": 3219, "CSS": 1020} | package com.barneyb.aoc.aoc2016.day17
import com.barneyb.aoc.util.Solver
import java.security.MessageDigest
import java.util.*
import kotlin.experimental.and
const val WIDTH = 4
const val HEIGHT = 4
fun main() {
Solver.execute(
{ it.trim() },
::shortestPath,
{ longestPath(it).length })
}
... | 0 | Kotlin | 0 | 0 | 8b5956164ff0be79a27f68ef09a9e7171cc91995 | 2,787 | aoc-2022 | MIT License |
src/day08/Day08.kt | tobihein | 569,448,315 | false | {"Kotlin": 58721} | package day08
import readInput
class Day08 {
fun part1(): Int {
val readInput = readInput("day08/input")
return part1(readInput)
}
fun part2(): Int {
val readInput = readInput("day08/input")
return part2(readInput)
}
fun part1(input: List<String>): Int {
v... | 0 | Kotlin | 0 | 0 | af8d851702e633eb8ff4020011f762156bfc136b | 5,369 | adventofcode-2022 | Apache License 2.0 |
2022/src/Day25.kt | Saydemr | 573,086,273 | false | {"Kotlin": 35583, "Python": 3913} | package src
val snafu = mapOf("=" to -2, "-" to -1, "1" to 1, "2" to 2, "0" to 0)
val snafuBack = mapOf(-2 to "=", -1 to "-", 1 to "1", 2 to "2", 0 to "0")
fun main() {
fun encoder(number: String): Long {
// powers of five in reverse order
val powersOf5 =
generateSequence { 5 }
... | 0 | Kotlin | 0 | 1 | 25b287d90d70951093391e7dcd148ab5174a6fbc | 1,174 | AoC | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MeetingRooms.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,698 | kotlab | Apache License 2.0 |
src/main/kotlin/apoy2k/aoc2023/problem1/Problem1.kt | ApoY2k | 725,965,251 | false | {"Kotlin": 2769} | package apoy2k.aoc2023.problem1
import apoy2k.aoc2023.readInput
fun main() {
println("Part 1: ${part1()}")
println("Part 2: ${part2()}")
}
private fun part1() = solve(map.values.toSet())
private fun part2() = solve(map.keys + map.values)
private fun solve(numbers: Set<String>) = readInput("problem1.txt")
... | 0 | Kotlin | 0 | 0 | 4d428feac36813acb8541b69d6fb821669714882 | 880 | aoc2023 | The Unlicense |
src/main/kotlin/adventofcode/year2022/Day05SupplyStacks.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2022
import adventofcode.Puzzle
import adventofcode.PuzzleInput
import adventofcode.common.transpose
class Day05SupplyStacks(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val stacks by lazy {
val stackRows = input
.split("\n\n")
.first()... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 1,880 | AdventOfCode | MIT License |
src/main/kotlin/org/tinygears/tinydiff/algorithm/MyersDiffAlgorithm.kt | TinyGearsOrg | 561,403,042 | false | {"Kotlin": 76143} | /*
* Copyright (c) 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 ... | 0 | Kotlin | 0 | 0 | 6556f2868fcb879cc22cd5ae1557862377e1ef27 | 12,050 | tinydiff | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.