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/de/jball/aoc2022/day02/Day02.kt | fibsifan | 573,189,295 | false | {"Kotlin": 43681} | package de.jball.aoc2022.day02
import de.jball.aoc2022.Day
class Day02(test: Boolean = false) : Day<Long>(test, 15, 12) {
private val games: List<Pair<Played, ToPlay>> = input.map { parseGame(it) }
private fun parseGame(it: String) =
Pair(Played.valueOf(it.substringBefore(" ")), ToPlay.valueOf(it.sub... | 0 | Kotlin | 0 | 3 | a6d01b73aca9b54add4546664831baf889e064fb | 1,425 | aoc-2022 | Apache License 2.0 |
src/Day01.kt | weberchu | 573,107,187 | false | {"Kotlin": 91366} | fun main() {
fun insertMaxHeap(maxHeap: MutableList<Int>, heapSize: Int, entry: Int) {
var inserted = false;
for (i in maxHeap.indices) {
if (entry > maxHeap[i]) {
maxHeap.add(i, entry)
inserted = true
break
}
}
... | 0 | Kotlin | 0 | 0 | 903ff33037e8dd6dd5504638a281cb4813763873 | 1,734 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/pl/klemba/aoc/day2/Main.kt | aklemba | 726,935,468 | false | {"Kotlin": 16373} | package pl.klemba.aoc.day2
import java.io.File
fun main() {
// ----- PART 1 -----
File(inputPath)
.readLines()
.foldIndexed(0) { index, acc, line -> if (line.meetsRequirements) acc + index + 1 else acc }
.let { println(it) }
// ----- PART 2 -----
File(inputPath)
.readLines()
.map { it.max... | 0 | Kotlin | 0 | 1 | 2432d300d2203ff91c41ffffe266e19a50cca944 | 1,497 | adventOfCode2023 | Apache License 2.0 |
src/main/kotlin/io/github/pshegger/aoc/y2020/Y2020D24.kt | PsHegger | 325,498,299 | false | null | package io.github.pshegger.aoc.y2020
import io.github.pshegger.aoc.common.BaseSolver
import io.github.pshegger.aoc.common.Coordinate
import kotlin.math.absoluteValue
class Y2020D24 : BaseSolver() {
override val year = 2020
override val day = 24
override fun part1(): Int =
calculateStartingState(p... | 0 | Kotlin | 0 | 0 | 346a8994246775023686c10f3bde90642d681474 | 3,499 | advent-of-code | MIT License |
src/Day02.kt | ChenJiaJian96 | 576,533,624 | false | {"Kotlin": 11529} | /**
* https://adventofcode.com/2022/day/2
*/
fun main() {
fun String.calResult(): Int {
val (otherChar, _, myChar) = this
val otherChoice = otherChar.toChoice()
val myChoice = myChar.toChoice()
return myChoice.run {
this.toScore() + this.challengeTo(otherChoice).toSc... | 0 | Kotlin | 0 | 0 | b1a88f437aee756548ac5ba422e2adf2a43dce9f | 2,746 | Advent-Code-2022 | Apache License 2.0 |
src/main/kotlin/me/giacomozama/adventofcode2022/days/Day21.kt | giacomozama | 572,965,253 | false | {"Kotlin": 75671} | package me.giacomozama.adventofcode2022.days
import java.io.File
class Day21 : Day() {
private lateinit var input: List<String>
override fun parseInput(inputFile: File) {
input = inputFile.readLines()
}
// n = number of monkeys
// time: O(n), space: O(n)
override fun solveFirstPuzzl... | 0 | Kotlin | 0 | 0 | c30f4a37dc9911f3e42bbf5088fe246aabbee239 | 6,006 | aoc2022 | MIT License |
src/main/kotlin/io/matrix/MatrixDiagonalTraversal.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.matrix
import io.utils.runTests
import kotlin.math.absoluteValue
// https://leetcode.com/explore/learn/card/array-and-string/202/introduction-to-2d-array/1167/
class MatrixDiagonalTraversal {
fun execute(matrix: Array<IntArray>): IntArray = when {
matrix.isEmpty() -> intArrayOf()
matrix.size == ... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 4,111 | coding | MIT License |
src/main/kotlin/Sudoku/Heuristics.kt | aolkhov | 117,635,100 | false | null | package Sudoku
import kotlin.math.roundToInt
private fun sumOfAllPossibleValues(sm: SudokuMatrix) = sm.possibleValueCount * (sm.possibleValueCount + 1) / 2
/**
* When cell has a known value, no other cells in the same row, column, or quadrant, have that value
*/
class SingleValueInCellHeuristic: CellHeuristic() {... | 0 | Kotlin | 0 | 0 | d58ff1e30854b391c87b8efb73f1089d6512d20e | 14,320 | SudokuSolver | MIT License |
src/main/kotlin/mirecxp/aoc23/day09/Day09.kt | MirecXP | 726,044,224 | false | {"Kotlin": 42343} | package mirecxp.aoc23.day09
import mirecxp.aoc23.day04.toNumList
import mirecxp.aoc23.readInput
//https://adventofcode.com/2023/day/9
class Day09(private val inputPath: String) {
private var lines: List<List<Long>> = readInput(inputPath).map { it.toNumList() }
fun solve(part2: Boolean): String {
pri... | 0 | Kotlin | 0 | 0 | 6518fad9de6fb07f28375e46b50e971d99fce912 | 2,005 | AoC-2023 | MIT License |
src/Day05.kt | p357k4 | 573,068,508 | false | {"Kotlin": 59696} | fun main() {
fun part1(input: String): String {
val (header, instruction) = input.split("\n\n")
val crates = arrayOf(mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>(), mutableListOf<Char>()... | 0 | Kotlin | 0 | 0 | b9047b77d37de53be4243478749e9ee3af5b0fac | 2,810 | aoc-2022-in-kotlin | Apache License 2.0 |
src/Day07.kt | thelmstedt | 572,818,960 | false | {"Kotlin": 30245} | import java.io.File
sealed class Entry(open val name: String) {
data class File(override val name: String, val size: Long) : Entry(name)
data class Dir(
override val name: String,
val prev: Dir? = null,
var size: Long? = null,
val children: MutableList<Entry> = mutableListOf(),
... | 0 | Kotlin | 0 | 0 | e98cd2054c1fe5891494d8a042cf5504014078d3 | 4,456 | advent2022 | Apache License 2.0 |
src/test/kotlin/days/y2022/Day15Test.kt | jewell-lgtm | 569,792,185 | false | {"Kotlin": 161272, "Jupyter Notebook": 103410, "TypeScript": 78635, "JavaScript": 123} | package days.y2022
import days.Day
import org.hamcrest.CoreMatchers.nullValue
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.core.Is.`is`
import org.junit.jupiter.api.Test
import java.lang.Integer.max
import kotlin.math.absoluteValue
class Day15(val bound: Int = 20) : Day(2022, 15) {
override ... | 0 | Kotlin | 0 | 0 | b274e43441b4ddb163c509ed14944902c2b011ab | 4,743 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/Day14.kt | sbaumeister | 572,855,566 | false | {"Kotlin": 38905} | data class Scan(
var map: MutableList<MutableList<Char>>,
var startPos: Pair<Int, Int>,
val paths: List<List<Pair<Int, Int>>>,
val highestX: Int,
val lowestX: Int,
val highestY: Int,
)
fun createScanPart1(input: List<String>): Scan {
var (highestX, lowestX, highestY) = listOf(0, Int.MAX_VAL... | 0 | Kotlin | 0 | 0 | e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84 | 5,031 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/groupnet/algorithm/DescriptionMatcher.kt | AlmasB | 174,802,362 | false | {"Kotlin": 167480, "Java": 91450, "CSS": 110} | package groupnet.algorithm
import groupnet.euler.Description
import java.util.*
import java.util.stream.Stream
import kotlin.collections.ArrayList
/**
*
*
* @author <NAME> (<EMAIL>)
*/
object DescriptionMatcher {
/**
* Matches the actual string (description) with a given pattern.
* Given a pattern ... | 3 | Kotlin | 0 | 0 | 4aaa9de60ecdba5b9402b809e1e6e62489a1d790 | 2,852 | D2020 | Apache License 2.0 |
src/main/kotlin/day16/Day16.kt | dustinconrad | 572,737,903 | false | {"Kotlin": 100547} | package day16
import getCartesianProduct
import readResourceAsBufferedReader
import java.util.UUID
fun main() {
println("part 1: ${part1(readResourceAsBufferedReader("16_1.txt").readLines())}")
println("part 2: ${part2(readResourceAsBufferedReader("16_1.txt").readLines())}")
}
data class Node(val name: Strin... | 0 | Kotlin | 0 | 0 | 1dae6d2790d7605ac3643356b207b36a34ad38be | 6,449 | aoc-2022 | Apache License 2.0 |
src/aoc2023/Day06.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2023
import readInput
import kotlin.text.Typography.times
fun main() {
fun part1(lines: List<String>): Long {
val times =
"(Time:\\s+)(.*)".toRegex().findAll(lines[0]).iterator().next().groupValues[2].split("\\s+".toRegex())
.map { it.toInt() }
val distances ... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 1,922 | advent-of-code-kotlin | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/NumberOfRecentCalls.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* You have a RecentCounter class which counts the number of recent requests within a certain time frame.
*
* Implement the RecentCounter class:
*
* RecentCounter() Initializes the counter with zero recent requests.
* int ping(int t) Adds a new request at time t, where t represents some time in milliseconds,
... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,845 | leetcode-75 | Apache License 2.0 |
kotlin/strings/SuffixTree.kt | polydisc | 281,633,906 | true | {"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571} | package strings
// https://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english/9513423#9513423
object SuffixTree {
const val ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789\u0001\u0002"
fun buildSuffixTree(s: CharSequence): Node {
val n: Int = s.length()
val a =... | 1 | Java | 0 | 0 | 4566f3145be72827d72cb93abca8bfd93f1c58df | 3,719 | codelibrary | The Unlicense |
src/main/kotlin/dev/bogwalk/batch0/Problem10.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch0
/**
* Problem 10: Summation of Primes
*
* https://projecteuler.net/problem=10
*
* Goal: Find the sum of all prime numbers <= N.
*
* Constraints: 1 <= N <= 1e6
*
* e.g. N = 5
* primes = {2, 3, 5}
* sum = 10
*/
class SummationOfPrimes {
/**
* Stores the cumulati... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,040 | project-euler-kotlin | MIT License |
src/Day06.kt | MartinsCode | 572,817,581 | false | {"Kotlin": 77324} | fun main() {
fun allDifferentChars(text: String): Boolean {
val chars = text.toCharArray().distinct()
return text.length == chars.size
}
fun part1(input: List<String>): List<Int> {
val returnList = mutableListOf<Int>()
input.forEach {
var bufferString = it[0].toS... | 0 | Kotlin | 0 | 0 | 1aedb69d80ae13553b913635fbf1df49c5ad58bd | 1,664 | AoC-2022-12-01 | Apache License 2.0 |
src/day7/first/Solution.kt | verwoerd | 224,986,977 | false | null | package day7.first
import tools.executeProgram
import tools.readInput
import tools.timeSolution
import java.util.Collections.swap
fun main() = timeSolution {
val code = readInput()
val permutations = generatePermutations(mutableListOf(0,1,2,3,4))
val result = permutations.map {
// acctuator 1
va... | 0 | Kotlin | 0 | 0 | 554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7 | 1,290 | AoC2019 | MIT License |
src/main/kotlin/Day03.kt | joostbaas | 573,096,671 | false | {"Kotlin": 45397} | fun Char.priorityValue(): Int = when (this) {
in ('a'..'z') -> this - 'a' + 1
in ('A'..'Z') -> this - 'A' + 27
else -> throw IllegalArgumentException()
}
fun charsInCommon(s: List<String>): Set<Char> =
s.fold(s[0].toSet()) { acc, next ->
acc intersect next.toSet()
}
fun <T> Set<T>.onlyElem... | 0 | Kotlin | 0 | 0 | 8d4e3c87f6f2e34002b6dbc89c377f5a0860f571 | 735 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/de/pgebert/aoc/days/Day11.kt | pgebert | 724,032,034 | false | {"Kotlin": 65831} | package de.pgebert.aoc.days
import de.pgebert.aoc.Day
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
private typealias Point = Pair<Int, Int>
class Day11(input: String? = null) : Day(11, "Cosmic Expansion", input) {
private val rowsToDuplicate = inputList.indices.filter { i -> inputList[i]... | 0 | Kotlin | 1 | 0 | a30d3987f1976889b8d143f0843bbf95ff51bad2 | 1,821 | advent-of-code-2023 | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SortedArrayToBST.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,028 | kotlab | Apache License 2.0 |
archive/k/kotlin/JobSequencing.kt | TheRenegadeCoder | 125,427,624 | false | {"BASIC": 97136, "Rust": 61107, "PHP": 58368, "Beef": 51651, "Mathematica": 43477, "C++": 37590, "Java": 33084, "Python": 30222, "JavaScript": 29447, "C": 29061, "Go": 22022, "C#": 18001, "Objective-C": 16797, "Haskell": 16781, "Kotlin": 13185, "Brainfuck": 12179, "Perl": 11260, "TypeScript": 10875, "MATLAB": 9411, "Ma... | fun main(args: Array<String>) {
val jobs = buildJobs(args)
if (jobs.isNullOrEmpty()) {
println("Usage: please provide a list of profits and a list of deadlines")
} else {
println(maxProfit(jobs))
}
}
/**
* Calculates the maximum profit of a list of jobs
*/
private fun maxProfit(jobs: ... | 83 | BASIC | 540 | 527 | bd5f385f6b3f7881c496a4c2884d1a63b8bb5448 | 1,269 | sample-programs | MIT License |
src/Day15.kt | uekemp | 575,483,293 | false | {"Kotlin": 69253} | import kotlin.math.absoluteValue
class SensorMap(val sensors: List<Sensor>) {
val map = mutableMapOf<Coordinate, Char>()
init {
sensors.forEach {sensor ->
this[sensor.position] = SENSOR
this[sensor.beacon] = BEACON
}
}
private val left: Int
get() = ma... | 0 | Kotlin | 0 | 0 | bc32522d49516f561fb8484c8958107c50819f49 | 4,316 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/Day18.kt | max-zhilin | 573,066,300 | false | {"Kotlin": 114003} | import java.util.*
fun parse(s: String): Triple<Int, Int, Int> {
val scanner = Scanner(s)
scanner.useDelimiter(",")
return Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
}
fun main() {
fun part1(input: List<String>): Int {
val (maxX, maxY, maxZ) = listOf(19, 19, 19)
// ... | 0 | Kotlin | 0 | 0 | d9dd7a33b404dc0d43576dfddbc9d066036f7326 | 4,650 | AoC-2022 | Apache License 2.0 |
src/main/kotlin/graph/variation/WrongEdgeWeight.kt | yx-z | 106,589,674 | false | null | package graph.variation
import graph.core.Vertex
import graph.core.WeightedGraph
import graph.core.dijkstra
import util.min
// suppose you have computed the all pairs shortest path (apsp) table
// but later you find out that your edge weight for u -> v is wrong during
// the computation... that is, w(u -> v) is used ... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,727 | AlgoKt | MIT License |
src/main/kotlin/com/kishor/kotlin/ds/MinHeap.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.ds
import java.util.*
data class Item(val test: Int) : Comparable<Item> {
override fun compareTo(other: Item): Int {
return this.test.compareTo(other.test)
}
}
fun main() {
val minHeap = MinHeap()
minHeap.checkPriorityQueue()
println(minHeap.priorityQueue.peek().... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 2,448 | DS_Algo_Kotlin | MIT License |
src/Day07.kt | frango9000 | 573,098,370 | false | {"Kotlin": 73317} | fun main() {
val input = readInput("Day07")
println(Day07.part1(input))
println(Day07.part2(input))
}
class Day07 {
companion object {
fun getFolderSizes(input: List<String>): MutableMap<String, Int> {
val folders: MutableMap<String, Int> = mutableMapOf()
val stack: Ar... | 0 | Kotlin | 0 | 0 | 62e91dd429554853564484d93575b607a2d137a3 | 1,784 | advent-of-code-22 | Apache License 2.0 |
2022/main/day_09/Main.kt | Bluesy1 | 572,214,020 | false | {"Rust": 280861, "Kotlin": 94178, "Shell": 996} | package day_09_2022
import java.io.File
import kotlin.math.abs
fun day9(input: List<String>) {
var headPos = 0 to 0
var tailPos= 0 to 0
val visited = mutableMapOf((0 to 0) to 1)
val tailVisited = mutableMapOf((0 to 0) to 1)
val lastTen = ArrayDeque((0..9).map { 0 to 0 }.toList())
val inputs = ... | 0 | Rust | 0 | 0 | 537497bdb2fc0c75f7281186abe52985b600cbfb | 3,293 | AdventofCode | MIT License |
src/main/kotlin/com/dambra/adventofcode2018/day2/BoxChecksum.kt | pauldambra | 159,939,178 | false | null | package com.dambra.adventofcode2018.day2
fun List<LetterFrequency>.boxChecksum(): Int {
var twos = 0
var threes = 0
this.forEach {
if (it.exactlyTwoTimesLetter.isNotEmpty()) twos++
if (it.exactlyThreeTimesLetter.isNotEmpty()) threes++
}
return twos * threes
}
data class Comparis... | 0 | Kotlin | 0 | 1 | 7d11bb8a07fb156dc92322e06e76e4ecf8402d1d | 1,985 | adventofcode2018 | The Unlicense |
src/main/kotlin/g0801_0900/s0854_k_similar_strings/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0801_0900.s0854_k_similar_strings
// #Hard #String #Breadth_First_Search #2023_03_31_Time_136_ms_(100.00%)_Space_33.6_MB_(100.00%)
class Solution {
fun kSimilarity(a: String, b: String): Int {
var ans = 0
val achars = a.toCharArray()
val bchars = b.toCharArray()
ans += get... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,627 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/day24/Code.kt | fcolasuonno | 317,324,330 | false | null | package day24
import isDebug
import java.io.File
private val Pair<Int, Int>.hexNeighbours: Set<Pair<Int, Int>>
get() = Direction.values().map { Pair(first + it.x, second + it.y) }.toSet()
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::cla... | 0 | Kotlin | 0 | 0 | e7408e9d513315ea3b48dbcd31209d3dc068462d | 2,379 | AOC2020 | MIT License |
src/Day01.kt | polbins | 573,082,325 | false | {"Kotlin": 9981} | fun main() {
fun part1(input: List<String>): Long {
var current: Long = 0
var highest: Long = 0
for (s in input) {
current = s.toLongOrNull()?.let {
current + it
} ?: 0
if (current > highest) {
highest = current
}
}
return highest
}
fun part2(input: ... | 0 | Kotlin | 0 | 0 | fb9438d78fed7509a4a2cf6c9ea9e2eb9d059f14 | 996 | AoC-2022 | Apache License 2.0 |
src/Day07.kt | AxelUser | 572,845,434 | false | {"Kotlin": 29744} | import java.util.Stack
fun main() {
fun List<String>.buildTree(): Map<String, Int> {
val stack = Stack<String>()
val dirs = mutableMapOf<String, Int>()
dirs["/"] = 0
stack.push("/")
for (i in 1..lastIndex) {
val line = this[i].split(' ')
when (line[0... | 0 | Kotlin | 0 | 1 | 042e559f80b33694afba08b8de320a7072e18c4e | 1,499 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2021/2021-04.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2021
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputText
fun main() {
val input = readInputText(2021, "04-input")
val test1 = readInputText(2021, "04-test1")
println("Part1:")
part1(test1).println()
part... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 3,001 | advent-of-code | MIT License |
src/Day02.kt | fouksf | 572,530,146 | false | {"Kotlin": 43124} | enum class PlayedChoice() {
A {
override fun getScore(): Int {
return 1
}
},
B {
override fun getScore(): Int {
return 2
}
},
C {
override fun getScore(): Int {
return 3
}
};
abstract fun getScore(): Int
}
... | 0 | Kotlin | 0 | 0 | 701bae4d350353e2c49845adcd5087f8f5409307 | 3,427 | advent-of-code-2022 | Apache License 2.0 |
src/day7/Day7.kt | jorgensta | 573,824,365 | false | {"Kotlin": 31676} | import day7.Dir
import day7.File
fun String.isTerminalInstruction() = this.contains("$")
fun String.isChangeDirectory() = this.contains("cd") && this.isTerminalInstruction()
fun String.isListDir() = this.contains("ls") && this.isTerminalInstruction()
fun String.goesUpOneDirectory() = this.isChangeDirectory() && this.s... | 0 | Kotlin | 0 | 0 | 7243e32351a926c3a269f1e37c1689dfaf9484de | 3,951 | AoC2022 | Apache License 2.0 |
src/main/kotlin/aoc/day1/Trebuchet.kt | hofiisek | 726,824,585 | false | {"Kotlin": 5136} | package aoc.day1
import aoc.dropFirst
import aoc.loadInput
import java.io.File
/**
* https://adventofcode.com/2023/day/1
*
* @author <NAME>
*/
fun File.part1() = readLines()
.map { line -> listOfNotNull(line.firstOrNull { it.isDigit() }, line.lastOrNull { it.isDigit() })
.joinToString(separator = "")... | 0 | Kotlin | 0 | 0 | 35a93ebd980202ab0d512310ed611a7d96dd330a | 2,392 | Advent-of-code-2023 | MIT License |
src/day04/Day04.kt | iliascholl | 572,982,464 | false | {"Kotlin": 8373} | package day04
import readInput
private fun String.toRangePair(): Pair<IntRange, IntRange> =
split(',', limit = 2)
.map(String::toRange)
.let { (first, second) -> first to second }
private fun String.toRange(): IntRange =
split('-', limit = 2)
.let { (start, end) -> start.toInt()..end.... | 0 | Kotlin | 0 | 1 | 26db12ddf4731e4ee84f45e1dc4385707f9e1d05 | 1,074 | advent-of-code-kotlin | Apache License 2.0 |
src/Day09.kt | seana-zr | 725,858,211 | false | {"Kotlin": 28265} | fun main() {
fun List<Int>.getDifferences(): MutableList<Int> {
val result = mutableListOf<Int>()
for (i in 1..this.lastIndex) {
result.add(this[i] - this[i - 1])
}
return result
}
fun List<Int>.isAllZeros(): Boolean = all { it == 0 }
fun part1(input: List<... | 0 | Kotlin | 0 | 0 | da17a5de6e782e06accd3a3cbeeeeb4f1844e427 | 2,336 | advent-of-code-kotlin-template | Apache License 2.0 |
src/main/kotlin/year2021/day-10.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2021
import lib.aoc.Day
import lib.aoc.Part
fun main() {
Day(10, 2021, PartA10(), PartB10()).run()
}
open class PartA10 : Part() {
protected lateinit var lines: List<String>
override fun parse(text: String) {
lines = text.split("\n")
}
override fun compute(): String {
... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 2,649 | Advent-Of-Code-Kotlin | MIT License |
2022/src/main/kotlin/Day05.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | object Day05 {
fun part1(input: String): String {
val inputs = parseInput(input)
val crates = inputs.crates.toMutableList()
inputs.moves.forEach { (number, from, to) ->
crates[to] = crates[to] + crates[from].takeLast(number).reversed()
crates[from] = crates[from].dropLast(number)
}
... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 1,881 | advent-of-code | MIT License |
src/Day04.kt | epishkin | 572,788,077 | false | {"Kotlin": 6572} | fun main() {
fun parseInput(input: List<String>) = input
.map {
it.split(",")
.map { txt ->
val (start, end) = txt
.split("-")
.map { num -> num.trim().toInt() }
IntRange(start, end).toSet()
... | 0 | Kotlin | 0 | 0 | e5e5755c2d77f75750bde01ec5aad70652ef4dbf | 1,078 | advent-of-code-2022 | Apache License 2.0 |
src/Day04.kt | mhuerster | 572,728,068 | false | {"Kotlin": 24302} | fun main() {
// input: string of format 2-4,6-8
fun parseSectionStrings(pair: String): List<String> {
val (section1, section2) = pair.split(",")
return listOf(section1, section2)
}
// input: string of format 2-4
fun getSectionRange(section: String): Set<Int> {
val (start, end) = section.split("-"... | 0 | Kotlin | 0 | 0 | 5f333beaafb8fe17ff7b9d69bac87d368fe6c7b6 | 1,155 | 2022-advent-of-code | Apache License 2.0 |
src/main/kotlin/days/day24/Day24.kt | Stenz123 | 725,707,248 | false | {"Kotlin": 123279, "Shell": 862} | package days.day24
import Jama.Matrix
import days.Day
import kotlin.math.round
class Day24 : Day() {
override fun partOne(): Any {
val testArea = 200000000000000.0..400000000000000.0
val vectors = readInput().map {
val split = it.split(" @ ").map { it.split(", ").map(String::toDouble) ... | 0 | Kotlin | 1 | 0 | 3de47ec31c5241947d38400d0a4d40c681c197be | 7,142 | advent-of-code_2023 | The Unlicense |
src/Day12.kt | makohn | 571,699,522 | false | {"Kotlin": 35992} | fun main() {
val day = "12"
fun solve(input: List<String>, predicate: (Int) -> Boolean, startWith: Char, vararg endWith: Char): Int {
val inputMatrix = input.toCharMatrix()
val dataPoints = inputMatrix.dataPoints()
val startNode = dataPoints.single { it.data == startWith }
fun... | 0 | Kotlin | 0 | 0 | 2734d9ea429b0099b32c8a4ce3343599b522b321 | 1,193 | aoc-2022 | Apache License 2.0 |
src/Day03.kt | daniyarmukhanov | 572,847,967 | false | {"Kotlin": 9474} | //use this file as template
fun main() {
fun part1(input: List<String>): Int {
var sum = 0
input.forEach {
val left = it.substring(0, it.length / 2).toSet()
val right = it.substring(it.length / 2, it.length).toSet()
left.forEach { leftChar ->
if (r... | 0 | Kotlin | 0 | 0 | ebad16b2809ef0e3c7034d5eed75e6a8ea34c854 | 1,418 | aoc22 | Apache License 2.0 |
src/Day06.kt | thpz2210 | 575,577,457 | false | {"Kotlin": 50995} | private class Solution06(val input: String) {
fun part1() = findMarker(4)
fun part2() = findMarker(14)
private fun findMarker(length: Int) =
(length until input.length).first { input.subSequence(it - length, it).toSet().size == length }
}
fun main() {
val testSolution1 = Solution06("mjqjpqm... | 0 | Kotlin | 0 | 0 | 69ed62889ed90692de2f40b42634b74245398633 | 1,135 | aoc-2022 | Apache License 2.0 |
src/main/aoc2019/Day22.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2019
import kotlin.math.max
class Day22(val input: List<String>) {
sealed class Technique {
abstract fun nextPositionForCard(card: Long, deckSize: Long): Long
data class Cut(val n: Long) : Technique() {
override fun nextPositionForCard(card: Long, deckSize: Long) = Math.fl... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 6,883 | aoc | MIT License |
src/main/kotlin/days/Day12.kt | hughjdavey | 572,954,098 | false | {"Kotlin": 61752} | package days
import xyz.hughjd.aocutils.Coords.Coord
import java.util.LinkedList
import java.util.Queue
class Day12 : Day(12) {
private val pointsInfo = PointsInfo.fromInput(inputList)
override fun partOne(): Any {
return dijkstra(pointsInfo)[pointsInfo.end] ?: 0
}
// todo improve performan... | 0 | Kotlin | 0 | 2 | 65014f2872e5eb84a15df8e80284e43795e4c700 | 2,753 | aoc-2022 | Creative Commons Zero v1.0 Universal |
src/aoc2022/day04/Day04.kt | svilen-ivanov | 572,637,864 | false | {"Kotlin": 53827} | package aoc2022.day04
import readInput
fun String.toRange(): IntRange {
val startEnd = split('-').map { it.toInt() }
return startEnd[0]..startEnd[1]
}
fun IntRange.contains(other: IntRange): Boolean {
return contains(other.first) && contains(other.last)
}
fun IntRange.overlap(other: IntRange): Boolean {... | 0 | Kotlin | 0 | 0 | 456bedb4d1082890d78490d3b730b2bb45913fe9 | 1,257 | aoc-2022 | Apache License 2.0 |
year2021/src/main/kotlin/net/olegg/aoc/year2021/day20/Day20.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2021.day20
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.utils.get
import net.olegg.aoc.year2021.DayOf2021
/**
* See [Year 2021, Day 20](https://adventofcode.com/2021/day/20)
*/
object Day20 : DayOf2021(20) {
override fun first(): Any? {
... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,369 | adventofcode | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountPoints.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 2,274 | kotlab | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumANDSum.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,654 | kotlab | Apache License 2.0 |
src/main/kotlin/com/jacobhyphenated/advent2022/day25/Day25.kt | jacobhyphenated | 573,603,184 | false | {"Kotlin": 144303} | package com.jacobhyphenated.advent2022.day25
import com.jacobhyphenated.advent2022.Day
import kotlin.math.pow
/**
* Day 25: Full of Hot Air
*
* A SNAFU number is a special kind of base 5 number that uses the characters
* = (-2), - (-1), 0, 1, 2
* therefore 3 is 1=
* 9 is 2-
* 2022 is 1=11-2
*/
class Day25: Da... | 0 | Kotlin | 0 | 0 | 9f4527ee2655fedf159d91c3d7ff1fac7e9830f7 | 3,006 | advent2022 | The Unlicense |
src/day02/Day02.kt | Raibaz | 571,997,684 | false | {"Kotlin": 9423} | package day02
import readInput
fun main() {
fun processRound1(theirPlay: Char, myPlay: Char): Int {
return when (theirPlay) {
'A' -> when(myPlay) {
'X' -> 1 + 3
'Y' -> 2 + 6
'Z' -> 3 + 0
else -> -1
}
'B' -... | 0 | Kotlin | 0 | 0 | 99d912f661bd3545ca9ff222ac7d93c12682f42d | 1,810 | aoc-22 | Apache License 2.0 |
src/main/kotlin/io/array/LongestPalindromicSubstring.kt | jffiorillo | 138,075,067 | false | {"Kotlin": 434399, "Java": 14529, "Shell": 465} | package io.array
import io.utils.runTests
class LongestPalindromicSubstring {
fun executeManacher(rawInput: String): String {
if (rawInput.isEmpty()) return ""
val inputManacher = preprocessManacher(rawInput)
val weights = IntArray(inputManacher.length) { 0 }
var center = 0
var rightBoundary =... | 0 | Kotlin | 0 | 0 | f093c2c19cd76c85fab87605ae4a3ea157325d43 | 3,079 | coding | MIT License |
src/Day01.kt | JaydenPease | 574,590,496 | false | {"Kotlin": 11645} | fun main() {
// fun part1(input: List<String>): Int {
// return input.size
// }
//
// fun part2(input: List<String>): Int {
// return input.size
// }
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
//println(Day01(testIn... | 0 | Kotlin | 0 | 0 | 0a5fa22b3653c4b44a716927e2293fc4b2ed9eb7 | 2,096 | AdventOfCode-2022 | Apache License 2.0 |
src/Day16.kt | thomasreader | 573,047,664 | false | {"Kotlin": 59975} | import java.io.Reader
typealias ValveToValveDistance = Map<Valve, Map<Valve, Int>>
typealias MutableValveToValveDistance = MutableMap<Valve, Map<Valve, Int>>
fun main() {
val testInput = """
Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valv... | 0 | Kotlin | 0 | 0 | eff121af4aa65f33e05eb5e65c97d2ee464d18a6 | 7,196 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/com/ginsberg/advent2021/Day18.kt | tginsberg | 432,766,033 | false | {"Kotlin": 92813} | /*
* Copyright (c) 2021 by <NAME>
*/
/**
* Advent of Code 2021, Day 18 - Snailfish
* Problem Description: http://adventofcode.com/2021/day/18
* Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2021/day18/
*/
package com.ginsberg.advent2021
import kotlin.math.ceil
import kotlin.math.floor
cl... | 0 | Kotlin | 2 | 34 | 8e57e75c4d64005c18ecab96cc54a3b397c89723 | 5,558 | advent-2021-kotlin | Apache License 2.0 |
app/src/main/kotlin/day04/Day04.kt | StylianosGakis | 434,004,245 | false | {"Kotlin": 56380} | package day04
import common.InputRepo
import common.readSessionCookie
import common.solve
fun main(args: Array<String>) {
val day = 4
val input = InputRepo(args.readSessionCookie()).get(day = day)
solve(day, input, ::solveDay04Part1, ::solveDay04Part2)
}
fun solveDay04Part1(input: List<String>): Int {
... | 0 | Kotlin | 0 | 0 | a2dad83d8c17a2e75dcd00651c5c6ae6691e881e | 1,944 | advent-of-code-2021 | Apache License 2.0 |
src/main/kotlin/twentytwentytwo/Graph.kt | JanGroot | 317,476,637 | false | {"Kotlin": 80906} | package twentytwentytwo
class Graph<T>(private val weightedPaths: Map<T, Map<T, Int>>) {
//dijkstra
fun findShortestPath(start: T, end: T): Int {
if (start == end) return 0
val paths = recurseFindShortestPath(NodePaths(start, end)).paths
return paths.getValue(end)
}
private ta... | 0 | Kotlin | 0 | 0 | 04a9531285e22cc81e6478dc89708bcf6407910b | 1,936 | aoc202xkotlin | The Unlicense |
src/Day10.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | const val MAX_CYCLE = 220
const val FIRST_IMPORTANT_CYCLE = 20
const val ITERATION_IMPORTANT_CYCLES = 40
const val SCREEN_HEIGHT = 6
const val SCREEN_WIDTH = 40
fun main() {
fun nextCyclePart1(cycle: Int, x: Int, signalStrengthPerCycle: MutableMap<Int, Int>): Int {
val importantCycle = (cycle - FIRST_IMPOR... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 2,541 | AoC2022 | Apache License 2.0 |
src/main/kotlin/me/peckb/aoc/_2018/calendar/day15/Space.kt | peckb1 | 433,943,215 | false | {"Kotlin": 956135} | package me.peckb.aoc._2018.calendar.day15
import me.peckb.aoc._2018.calendar.day15.Day15.Companion.DEFAULT_POWER
sealed class Space(var x: Int, var y: Int) {
class Wall(_x: Int, _y: Int) : Space(_x, _y)
class Empty(_x: Int, _y: Int): Space(_x, _y)
sealed class Player(_x: Int, _y: Int, var attackPower: Int = D... | 0 | Kotlin | 1 | 3 | 2625719b657eb22c83af95abfb25eb275dbfee6a | 2,573 | advent-of-code | MIT License |
test/Main.kt | goodkillerchen | 452,747,451 | false | {"Kotlin": 21502} | val ans = ArrayList<Matrix>()
fun main(args: Array<String>){
while(true) {
val nextLine = readLine().takeUnless {
it.isNullOrEmpty()
} ?: break
val (V, E) = nextLine.split(' ').map(String::toInt)
val graphA = Graph(V, E)
val (V1, E1) = readLine()!!.split(' ').map(... | 0 | Kotlin | 0 | 2 | f310137ed3adf7702c59a3d295f9824b9dc99398 | 2,630 | DS-for-Kotlin | MIT License |
src/Day15.kt | diego09310 | 576,378,549 | false | {"Kotlin": 28768} | import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
fun main() {
data class Point(var x: Int, var y: Int)
lateinit var occupied: HashSet<Int>
lateinit var beaconsInTarget: HashSet<Int>
var targetRow: Int
fun part1(input: List<String>): Int {
occupied = hashSetOf()
... | 0 | Kotlin | 0 | 0 | 644fee9237c01754fc1a04fef949a76b057a03fc | 4,367 | aoc-2022-kotlin | Apache License 2.0 |
src/Day05.kt | touchman | 574,559,057 | false | {"Kotlin": 16512} | import java.util.LinkedList
fun main() {
val input = readInput("Day05")
val listOfIndexes = listOf(1, 5, 9, 13, 17, 21, 25, 29, 33)
fun fillQueues(input: List<String>): MutableList<LinkedList<Char>> {
val queues = mutableListOf<LinkedList<Char>>()
for (i in 0..8) {
queues.add(... | 0 | Kotlin | 0 | 0 | 4f7402063a4a7651884be77bb9e97828a31459a7 | 2,475 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/dvdmunckhof/aoc/event2023/Day02.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2023
import com.dvdmunckhof.aoc.multiply
import com.dvdmunckhof.aoc.splitOnce
import kotlin.math.max
class Day02(private val input: List<String>) {
fun solvePart1(): Int = solve { gameId, cubes ->
val valid = cubes.all { (count, color) ->
when (color) {
... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,337 | advent-of-code | Apache License 2.0 |
src/main/kotlin/me/mattco/days/day04.kt | mattco98 | 160,000,311 | false | null | package me.mattco.days
import me.mattco.utils.ResourceLoader.getTextResource
import java.util.*
object Day4 {
private val input = getTextResource("/day04").split(System.lineSeparator())
enum class Action {
BEGIN_SHIFT,
FALL_ASLEEP,
WAKE_UP
}
data class Instruction(val date: C... | 0 | Kotlin | 0 | 0 | 9ec878de1cd727bb56ba7cb17796c766d4894252 | 2,903 | AdventOfCode2018 | MIT License |
src/Day08_part2.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | fun main() {
fun part2(input: List<String>): Int {
fun scenicScore(grid: List<List<Int>>, coord: Pair<Int, Int>): Int {
val tree = grid[coord.first][coord.second]
var west = 0
for (i in coord.first - 1 downTo 0) {
west++
if (grid[i][coord.s... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 1,832 | advent-of-code-2022 | Apache License 2.0 |
src/day3/day04.kt | kongminghan | 573,466,303 | false | {"Kotlin": 7118} | package day3
import readInput
fun main() {
fun Char.toPriority() = if (this.isUpperCase()) {
this.code - 38
} else {
this.code - 96
}
fun String.toCharSet(): Set<Char> = toCharArray().toSet()
fun List<String>.findIntersection(): Set<Char> {
return foldIndexed(setOf()) { ... | 0 | Kotlin | 0 | 0 | f602900209712090778c161d407ded8c013ae581 | 1,276 | advent-of-code-kotlin | Apache License 2.0 |
src/Day04.kt | arksap2002 | 576,679,233 | false | {"Kotlin": 31030} | fun main() {
fun part1(input: List<String>): Int {
var result = 0
for (pairs in input) {
val firstLeft = pairs.split(",")[0].split("-")[0].toInt()
val firstRight = pairs.split(",")[0].split("-")[1].toInt()
val secondLeft = pairs.split(",")[1].split("-")[0].toInt()... | 0 | Kotlin | 0 | 0 | a24a20be5bda37003ef52c84deb8246cdcdb3d07 | 1,748 | advent-of-code-kotlin | Apache License 2.0 |
src/Day02.kt | Advice-Dog | 436,116,275 | true | {"Kotlin": 25836} | fun main() {
fun part1(input: List<Command>): Int {
val horizontal = input
.filterIsInstance<Command.Forward>()
.sumOf { it.value }
val depth = input
.filterNot { it is Command.Forward }
.sumOf { it.value }
return horizontal * depth
}
... | 0 | Kotlin | 0 | 0 | 2a2a4767e7f0976dba548d039be148074dce85ce | 1,665 | advent-of-code-kotlin-template | Apache License 2.0 |
src/Java/LeetcodeSolutions/src/main/java/leetcode/solutions/concrete/kotlin/Solution_32_Longest_Valid_Parentheses.kt | v43d3rm4k4r | 515,553,024 | false | {"Kotlin": 40113, "Java": 25728} | package leetcode.solutions.concrete.kotlin
import leetcode.solutions.*
import leetcode.solutions.ProblemDifficulty.*
import leetcode.solutions.validation.SolutionValidator.*
import leetcode.solutions.annotations.ProblemInputData
import leetcode.solutions.annotations.ProblemSolution
/**
* __Problem:__ Given a string ... | 0 | Kotlin | 0 | 1 | c5a7e389c943c85a90594315ff99e4aef87bff65 | 2,688 | LeetcodeSolutions | Apache License 2.0 |
year2020/src/main/kotlin/net/olegg/aoc/year2020/day11/Day11.kt | 0legg | 110,665,187 | false | {"Kotlin": 511989} | package net.olegg.aoc.year2020.day11
import net.olegg.aoc.someday.SomeDay
import net.olegg.aoc.utils.Directions.Companion.NEXT_8
import net.olegg.aoc.utils.Vector2D
import net.olegg.aoc.utils.get
import net.olegg.aoc.year2020.DayOf2020
/**
* See [Year 2020, Day 11](https://adventofcode.com/2020/day/11)
*/
object Da... | 0 | Kotlin | 1 | 7 | e4a356079eb3a7f616f4c710fe1dfe781fc78b1a | 1,789 | adventofcode | MIT License |
src/Day05.kt | karloti | 573,006,513 | false | {"Kotlin": 25606} | fun main() {
fun solution(lines: List<String>, part: Int): String {
val initLines = lines
.takeWhile { it.isNotEmpty() }
.dropLast(1)
.map { it.chunked(4).mapIndexedNotNull { i, s -> s.trim(' ', '[', ']').takeIf(String::isNotEmpty)?.let { i + 1 to it[0] } } }
val... | 0 | Kotlin | 1 | 2 | 39ac1df5542d9cb07a2f2d3448066e6e8896fdc1 | 1,307 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/utils/AStarPath.kt | krllus | 572,617,904 | false | {"Kotlin": 97314} | package utils
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt
fun main() {
val rows = 5
val columns = 8
val grid = Array(rows) { row ->
Array(columns) { column ->
Node(row = row, column = column, value = 'S')
}
}
va... | 0 | Kotlin | 0 | 0 | b5280f3592ba3a0fbe04da72d4b77fcc9754597e | 3,854 | advent-of-code | Apache License 2.0 |
src/Day09.kt | catcutecat | 572,816,768 | false | {"Kotlin": 53001} | import kotlin.math.abs
import kotlin.math.sign
import kotlin.system.measureTimeMillis
fun main() {
measureTimeMillis {
Day09.run {
solve1(listOf(13, 88)) // 6090
solve2(listOf(1, 36)) // 2566
}
}.let { println("Total: $it ms") }
}
object Day09 : Day.GroupInput<List<Day0... | 0 | Kotlin | 0 | 2 | fd771ff0fddeb9dcd1f04611559c7f87ac048721 | 1,930 | AdventOfCode2022 | Apache License 2.0 |
src/main/kotlin/dev/siller/aoc2022/Day03.kt | chearius | 575,352,798 | false | {"Kotlin": 41999} | package dev.siller.aoc2022
private val example = """
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw
""".trimIndent()
private fun part1(input: List<String>): Int = input
.map { l -> l.toLi... | 0 | Kotlin | 0 | 0 | e070c0254a658e36566cc9389831b60d9e811cc5 | 1,173 | advent-of-code-2022 | MIT License |
src/Day06.kt | ech0matrix | 572,692,409 | false | {"Kotlin": 116274} | fun main() {
fun findMarker(input: String, numDistinct: Int): Int {
for(index in (numDistinct-1) until input.length) {
val set = (0 until numDistinct).map { i -> input[index - i] }.toSet()
if (set.size == numDistinct) {
return index+1
}
}
t... | 0 | Kotlin | 0 | 0 | 50885e12813002be09fb6186ecdaa3cc83b6a5ea | 1,113 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/chriswk/aoc/advent2018/Day18.kt | chriswk | 317,863,220 | false | {"Kotlin": 481061} | package com.chriswk.aoc.advent2018
object Day18 {
fun part1(input: List<String>, minutes: Int = 10, print: Boolean = false): Int {
val area = parseInput(input)
if (print) {
println("Inital state")
print(area)
}
val endState = (1..minutes).fold(area) { previou... | 116 | Kotlin | 0 | 0 | 69fa3dfed62d5cb7d961fe16924066cb7f9f5985 | 5,414 | adventofcode | MIT License |
src/Day16/Day16.kt | martin3398 | 436,014,815 | false | {"Kotlin": 63436, "Python": 5921} | import java.lang.IllegalArgumentException
fun main() {
val hexToBin = mapOf(
"0" to "0000",
"1" to "0001",
"2" to "0010",
"3" to "0011",
"4" to "0100",
"5" to "0101",
"6" to "0110",
"7" to "0111",
"8" to "1000",
"9" to "1001",
... | 0 | Kotlin | 0 | 0 | 085b1f2995e13233ade9cbde9cd506cafe64e1b5 | 3,372 | advent-of-code-2021 | Apache License 2.0 |
Kotlin/LongestCommonSubSequence.kt | sukritishah15 | 299,329,204 | false | null | /**
* Algorithm: Longest Common Sub-Sequence using Dynamic Programming
* Language: Kotlin
* Input:
* String1 and String2 -> Two Strings
* Output:
* Integer -> The longest common sub-sequence of String1 and String2
* Time Complexity: O(nStr1*nStr2)
* Space Complexity: O(nStr1*nStr2)
*
* Sample... | 164 | Java | 295 | 955 | 1b6040f7d9af5830882b53916e83d53a9c0d67d1 | 1,436 | DS-Algo-Point | MIT License |
kotlin/src/2022/Day02_2022.kt | regob | 575,917,627 | false | {"Kotlin": 50757, "Python": 46520, "Shell": 430} | private fun part1(input: String): Int {
return input.lines().asSequence()
.map { (it[0] - 'A') to (it[2] - 'X') }
// pairs of (player's shape, difference)
.map { it.second to (it.second - it.first).mod(3) }
// score = player's shape + 1 + 3*(difference + 1) % 3
.map {
... | 0 | Kotlin | 0 | 0 | cf49abe24c1242e23e96719cc71ed471e77b3154 | 820 | adventofcode | Apache License 2.0 |
src/main/kotlin/Day14.kt | alex859 | 573,174,372 | false | {"Kotlin": 80552} | import kotlin.math.absoluteValue
fun main() {
val testInput = readInput("Day14_test.txt")
// check(testInput.day14Part1() == 24)
val day14Part1 = testInput.day14Part1()
// check(day14Part1 == 93)
val input = readInput("Day14.txt")
println(input.day14Part1())
// println(input.day13Part2())
}
... | 0 | Kotlin | 0 | 0 | fbbd1543b5c5d57885e620ede296b9103477f61d | 4,115 | advent-of-code-kotlin-2022 | Apache License 2.0 |
src/main/kotlin/tr/emreone/adventofcode/days/Day21.kt | EmRe-One | 568,569,073 | false | {"Kotlin": 166986} | package tr.emreone.adventofcode.days
import org.mariuszgromada.math.mxparser.Expression
import kotlin.math.roundToLong
object Day21 {
val MONKEY_VALUE_PATTERN = """(\w+): (\d+)""".toRegex()
val MONKEY_EQ_PATTERN = """(\w+): (\w+) ([*/+\-]) (\w+)""".toRegex()
class RootCalculator() {
val allMonke... | 0 | Kotlin | 0 | 0 | a951d2660145d3bf52db5cd6d6a07998dbfcb316 | 3,596 | advent-of-code-2022 | Apache License 2.0 |
leetcode/src/main/kotlin/com/artemkaxboy/leetcode/p00/Leet42.kt | artemkaxboy | 513,636,701 | false | {"Kotlin": 547181, "Java": 13948} | package com.artemkaxboy.leetcode.p00
import com.artemkaxboy.leetcode.LeetUtils
import java.util.Collections
import java.util.TreeMap
/**
* Hard
* Runtime 653ms Beats 10.84%
* Memory 45.6MB Beats 15.27%
*/
class Leet42 {
fun trap(height: IntArray): Int {
val firstIndex = 0
val lastIn... | 0 | Kotlin | 0 | 0 | 516a8a05112e57eb922b9a272f8fd5209b7d0727 | 2,295 | playground | MIT License |
src/day02/Day02.kt | jacobprudhomme | 573,057,457 | false | {"Kotlin": 29699} | import java.io.File
import java.lang.IllegalArgumentException
enum class Result(val score: Int) {
LOSE(0),
DRAW(3),
WIN(6),
}
enum class Move(val value: Int) {
ROCK(1),
PAPER(2),
SCISSORS(3);
fun against(other: Move): Result = when (other.value) {
((value + 1) % 3) + 1 -> Result.W... | 0 | Kotlin | 0 | 1 | 9c2b080aea8b069d2796d58bcfc90ce4651c215b | 2,246 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/sschr15/aocsolutions/Day22.kt | sschr15 | 317,887,086 | false | {"Kotlin": 184127, "TeX": 2614, "Python": 446} | package sschr15.aocsolutions
import sschr15.aocsolutions.util.*
private typealias Point3d = Triple<Int, Int, Int>
private typealias Cube = Set<Point3d>
/**
* AOC 2023 [Day 22](https://adventofcode.com/2023/day/22)
* Challenge: how can we have our sand bricks and disintegrate them too?
*/
object Day22 : Challenge ... | 0 | Kotlin | 0 | 0 | e483b02037ae5f025fc34367cb477fabe54a6578 | 2,915 | advent-of-code | MIT License |
src/Day04.kt | Cryosleeper | 572,977,188 | false | {"Kotlin": 43613} | fun main() {
fun List<String>.toRange(): IntRange {
return first().toInt()..last().toInt()
}
fun List<String>.prepareData(): List<List<IntRange>> =
map { line -> line.split(",").map { range -> range.split("-").toRange() } }
fun IntRange.hasFullOverlap(anotherRange: IntRange): Boolean ... | 0 | Kotlin | 0 | 0 | a638356cda864b9e1799d72fa07d3482a5f2128e | 1,625 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/ReplaceWords.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 | 2,700 | kotlab | Apache License 2.0 |
src/Day20.kt | illarionov | 572,508,428 | false | {"Kotlin": 108577} | import kotlin.math.abs
fun main() {
val testInput = readInput("Day20_test").map(String::toLong)
val input = readInput("Day20").map(String::toLong)
part1v2(testInput).also {
println("Part 1, test input: $it")
check(it == 3L)
}
part1v2(input).also {
println("Part 1 1, real i... | 0 | Kotlin | 0 | 0 | 3c6bffd9ac60729f7e26c50f504fb4e08a395a97 | 3,129 | aoc22-kotlin | Apache License 2.0 |
src/main/kotlin/70. Climbing Stairs.kts | ShreckYe | 206,086,675 | false | null | import kotlin.test.assertEquals
class Solution {
fun climbStairs(n: Int): Int =
(FIBONACCI_MATRIX pow n).a22
data class TwoTimesTwoSymmetricMatrix(val a11: Int, val a12AndA21: Int, val a22: Int) {
// The product of two symmetric matrices is a symmetric matrix if and only if they commute.
... | 0 | Kotlin | 0 | 0 | 20e8b77049fde293b5b1b3576175eb5703c81ce2 | 1,509 | leetcode-solutions-kotlin | MIT License |
dcp_kotlin/src/main/kotlin/dcp/day298/day298.kt | sraaphorst | 182,330,159 | false | {"C++": 577416, "Kotlin": 231559, "Python": 132573, "Scala": 50468, "Java": 34742, "CMake": 2332, "C": 315} | package dcp.day298
// day298.kt
// By <NAME>, 2020.
import kotlin.math.max
typealias AppleType = Int
typealias ApplePath = List<AppleType>
/**
* Apple picking: this corresponds to the longest subarray that consists of just two values.
*/
fun applePicking(path: ApplePath): Int {
if (path.size <= 2)
path.... | 0 | C++ | 1 | 0 | 5981e97106376186241f0fad81ee0e3a9b0270b5 | 1,868 | daily-coding-problem | MIT License |
src/Day05.kt | adamgaafar | 572,629,287 | false | {"Kotlin": 12429} | import java.util.*
import kotlin.collections.ArrayDeque
fun main() {
var input = readInput("Day05")
fun part1(input: List<String>) = alterCrate(input,true)
fun part2(input: List<String>) = alterCrate(input,false)
println(part1(input))
println(part2(input))
}
fun alterCrate(input: List<String>, ... | 0 | Kotlin | 0 | 0 | 5c7c9a2e819618b7f87c5d2c7bb6e6ce415ee41e | 1,538 | AOCK | Apache License 2.0 |
src/Day02.kt | esteluk | 572,920,449 | false | {"Kotlin": 29185} | fun main() {
val score = mapOf(
"A X" to 4,
"A Y" to 8,
"A Z" to 3,
"B X" to 1,
"B Y" to 5,
"B Z" to 9,
"C X" to 7,
"C Y" to 2,
"C Z" to 6,
)
fun part1(input: List<String>): Int {
return input.sumOf { score[it] ?: 0 }
}
... | 0 | Kotlin | 0 | 0 | 5d1cf6c32b0c76c928e74e8dd69513bd68b8cb73 | 1,047 | adventofcode-2022 | Apache License 2.0 |
Kotlin/src/CombinationSum.kt | TonnyL | 106,459,115 | false | null | /**
* Given a set of candidate numbers (C) (without duplicates) and a target number (T),
* find all unique combinations in C where the candidate numbers sums to T.
*
* The same repeated number may be chosen from C unlimited number of times.
*
* Note:
* All numbers (including target) will be positive integers.
*... | 1 | Swift | 22 | 189 | 39f85cdedaaf5b85f7ce842ecef975301fc974cf | 1,339 | Windary | MIT License |
src/Day01.kt | KarinaCher | 572,657,240 | false | {"Kotlin": 21749} | import java.util.Comparator
fun main() {
fun mapElvesCalories(input: List<String>): MutableMap<Int, Int> {
var elvesCalories = mutableMapOf<Int, Int>()
var index = 1
for (line in input) {
if (line.isEmpty()) {
index = index.plus(1)
elvesCalories.p... | 0 | Kotlin | 0 | 0 | 17d5fc87e1bcb2a65764067610778141110284b6 | 1,198 | KotlinAdvent | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.