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/Day24.kt
clechasseur
264,758,910
false
null
object Day24 { private val input = """ 31/13 34/4 49/49 23/37 47/45 32/4 12/35 37/30 41/48 0/47 32/30 12/5 37/31 7/41 10/28 35/4 28/35 20/29 32/20 31/43 ...
0
Kotlin
0
0
f3e8840700e4c71e59d34fb22850f152f4e6e739
2,432
adventofcode2017
MIT License
src/day2/Day02.kt
JoeSkedulo
573,328,678
false
{"Kotlin": 69788}
package day2 import day2.Move.* import day2.Part.PartOne import day2.Part.PartTwo import day2.RoundResult.* import readInput fun main() { fun rounds(input: List<String>) : List<Round> { return input.map { line -> Round( opponentInput = Move.values().first { it.v == line.first() }, ...
0
Kotlin
0
0
bd8f4058cef195804c7a057473998bf80b88b781
2,026
advent-of-code
Apache License 2.0
src/Day03.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
fun main() { val priorities = ('a'..'z').zip((1..26)).toMap() + ('A'..'Z').zip((27..52)).toMap() fun part1(input: List<String>): Int { var totalSum = 0 for (line in input) { val halfLen = line.length / 2 val head = line.take(halfLen).asIterable() ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
1,403
aoc2022
Apache License 2.0
kotlin/0128-longest-consecutive-sequence.kt
neetcode-gh
331,360,188
false
{"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750}
import kotlin.math.max class Solution { fun longestConsecutive(nums: IntArray): Int { if (nums.isEmpty()) return 0 if (nums.size == 1) return 1 val hashSet = HashSet<Int>() nums.forEach { hashSet.add(it) } var longestSize = 0 var isNumberStartOfSequence: Boolean ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,956
leetcode
MIT License
src/Day06.kt
akijowski
574,262,746
false
{"Kotlin": 56887, "Shell": 101}
fun main() { // TODO: Clean this up fun part1(input: String): Int { input.windowed(4).indexOfFirst { it.toCharArray().distinct().size == it.length } val seen = mutableSetOf<Char>() for (idx in input.indices) { val c = input[idx] if (c in seen) { seen.c...
0
Kotlin
1
0
84d86a4bbaee40de72243c25b57e8eaf1d88e6d1
2,465
advent-of-code-2022
Apache License 2.0
src/day12/Day12.kt
commanderpepper
574,647,779
false
{"Kotlin": 44999}
package day12 import readInput import kotlin.math.abs /** * My solution was able to find the correct shortest path for the smaller puzzle input (the solution is 31). * My solution fails to make a proper tree for the actual puzzle input. I believe this is caused from the way I add visited positions to the set. * My...
0
Kotlin
0
0
fef291c511408c1a6f34a24ed7070ceabc0894a1
6,393
advent-of-code-kotlin-2022
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year15/Day15.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year15 import com.grappenmaker.aoc.PuzzleSet fun PuzzleSet.day15() = puzzle { val ingredients = inputLines.map { l -> val (_, propertyList) = l.split(": ") val (capacity, durability, flavor, texture, calories) = propertyList.split(", ").map { it.split(" ")[...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,942
advent-of-code
The Unlicense
src/Day04.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 13 private const val EXPECTED_2 = 30L private class Day04(isTest: Boolean) : Solver(isTest) { fun part1(): Any { var sum = 0 for (line in readAsLines()) { val parts = line.split(" | ") val winning = parts[0].substringAfter(": ").splitInts().toS...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,529
advent-of-code-2022
Apache License 2.0
src/main/kotlin/me/circuitrcay/euler/utils/Extensions.kt
adamint
134,989,381
false
null
package me.circuitrcay.euler.utils import org.apache.commons.collections4.iterators.PermutationIterator import org.jsoup.Jsoup import java.math.BigInteger fun <T : Number> bigInt(n: T) = BigInteger(n.toString()) private fun Long.isEven() = (this % 2) == 0L private fun Long.isPrime() = this > 1 && smallestPrimeFactor(...
0
Kotlin
0
0
cebe96422207000718dbee46dce92fb332118665
6,413
project-euler-kotlin
Apache License 2.0
src/Day22.kt
amelentev
573,120,350
false
{"Kotlin": 87839}
fun main() { data class Point3(val x: Int, val y: Int, var z: Int) val input = readInput("Day22").map { brick -> brick.split('~').map { point -> val (x,y,z) = point.split(',').map { it.toInt() } Point3(x,y,z) } }.sortedBy { minOf(it[0].z, it[1].z) } fun getBrickIn...
0
Kotlin
0
0
a137d895472379f0f8cdea136f62c106e28747d5
1,883
advent-of-code-kotlin
Apache License 2.0
src/Day07.kt
ds411
573,543,582
false
{"Kotlin": 16415}
fun main() { fun part1(input: List<String>): Int { val dirByPath = buildFilesystem(input) return dirByPath.values.filter { it.getSize() <= 100000 }.sumOf { it.getSize() } } fun part2(input: List<String>): Int { val dirByPath = buildFilesystem(input) val spaceAvailable = 700...
0
Kotlin
0
0
6f60b8e23ee80b46e7e1262723960af14670d482
3,230
advent-of-code-2022
Apache License 2.0
src/Day05.kt
wellithy
571,903,945
false
null
package day05 import util.* @JvmInline value class Crate(val mark: Char) @JvmInline value class Stack(private val crates: ArrayDeque<Crate> = ArrayDeque()) { fun addLast(crate: Crate) = crates.addLast(crate) fun move(other: Stack, count: Int, order: Boolean) = other.crates.addFirst(crates.removeFirs...
0
Kotlin
0
0
6d5fd4f0d361e4d483f7ddd2c6ef10224f6a9dec
2,278
aoc2022
Apache License 2.0
src/Day25.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 54 private const val EXPECTED_2 = 0 private class Day25(isTest: Boolean) : Solver(isTest) { fun flowCount( conn: MutableMap<String, MutableSet<String>>, src: String, dest: String ): Pair<Int, List<Pair<String, String>>?> { val allEdges = conn.flatM...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
3,120
advent-of-code-2022
Apache License 2.0
src/Day03.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { fun compartments(rucksack: String): Pair<CharArray, CharArray> { return Pair( rucksack.substring(0, rucksack.length / 2).toCharArray(), rucksack.substring(rucksack.length / 2).toCharArray() ) } fun toPriority(char: Char): Int { return if (char <=...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
1,200
advent_of_code_2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/searching/MissingInt.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.searching println("test") val array = IntArray(1000) { if (it == 900) 1001 // missing is 900! else it } println(Solution().missingInt(array)) /* follow up: 1 bil. ints, 10 MB memory 1 billion ints 10MB = ~10.000KB = ~10.000.000 bytes = ~ 80 million bits .. ~ < 2^23 bytes -> 2^23 / ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,492
KotlinAlgs
MIT License
src/y2023/Day03.kt
a3nv
574,208,224
false
{"Kotlin": 34115, "Java": 1914}
package y2023 import utils.readInput fun main() { fun isSymbol(c: Char): Boolean { return !c.isLetterOrDigit() && '.' != c } fun getNeighbours(row: Int, col: Int, size: Int, length: Int): List<Pair<Int, Int>> { val neighbours = mutableListOf<Pair<Int, Int>>(); val directions = li...
0
Kotlin
0
0
ab2206ab5030ace967e08c7051becb4ae44aea39
4,577
advent-of-code-kotlin
Apache License 2.0
src/Day02.kt
JCampbell8
572,669,444
false
{"Kotlin": 10115}
fun main() { val ROCK_SCORE = 1 val PAPER_SCORE = 2 val SCISSORS_SCORE = 3 val ROCK = "AX" val PAPER = "BY" val SCISSORS = "CZ" val LOSS = 0 val DRAW = 3 val WIN = 6 fun didIWin(me: String, them: String): Int { return if (ROCK.contains(me) && PAPER.contains(them) || PA...
0
Kotlin
0
1
0bac6b866e769d0ac6906456aefc58d4dd9688ad
2,796
advent-of-code-2022
Apache License 2.0
src/Day05.kt
WhatDo
572,393,865
false
{"Kotlin": 24776}
fun main() { val input = readInput("Day05") val crates = parseCrates(input) println(crates) val instructions = parseInstructions(input) println(instructions) instructions.forEach { instr -> when (instr) { is Move -> move9001(crates, instr) } } val sortedStac...
0
Kotlin
0
0
94abea885a59d0aa3873645d4c5cefc2d36d27cf
2,039
aoc-kotlin-2022
Apache License 2.0
src/Day04.kt
vladislav-og
573,326,483
false
{"Kotlin": 27072}
fun main() { fun part1(input: List<String>): Int { var fullyContainsPairsCount = 0 for (row in input) { val (x1, x2, y1, y2) = row.split(",").map { pair -> pair.split("-") }.flatten().map { i -> i.toInt() } if ((y1 in x1..x2 && y2 in x1..x2) || (x...
0
Kotlin
0
0
b230ebcb5705786af4c7867ef5f09ab2262297b6
1,247
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/anahoret/aoc2022/day20/main.kt
mikhalchenko-alexander
584,735,440
false
null
package com.anahoret.aoc2022.day20 import com.anahoret.aoc2022.calculateEndIndex import java.io.File import kotlin.system.measureTimeMillis data class NumberContainer(val initialIndex: Int, val value: Long) fun parse(str: String): Array<NumberContainer> { return str.split("\n") .mapIndexed { idx, s -> Nu...
0
Kotlin
0
0
b8f30b055f8ca9360faf0baf854e4a3f31615081
2,000
advent-of-code-2022
Apache License 2.0
app/src/main/kotlin/day15/Day15.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day15 import common.InputRepo import common.readSessionCookie import common.solve import util.Coord import kotlin.math.abs fun main(args: Array<String>) { val day = 15 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay15Part1, ::solveDay15Part2) } fun sol...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
3,008
AdventOfCode2022
Apache License 2.0
src/Day13.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import Signal.Scalar import Signal.Seq import java.lang.IllegalArgumentException sealed class Signal { fun scalar(): Int = if (this is Scalar) this.value else throw IllegalArgumentException("Can't cast Seq to Scalar") fun seq(): Seq = if (this is Seq) this else Seq(listOf(this)) data class Scalar(val valu...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
3,689
advent-of-code-2022
Apache License 2.0
src/Day09.kt
adrianforsius
573,044,406
false
{"Kotlin": 68131}
import org.assertj.core.api.Assertions.assertThat fun main() { fun part1(input: List<String>): Int { data class Point(var x: Int, var y: Int) var visited = listOf(Point(0,0)) fun visit(x: Int, y: Int): Point { val p = Point(x, y) visited += p return ...
0
Kotlin
0
0
f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb
4,095
kotlin-2022
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions60.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 fun test60() { printlnResult(1) printlnResult(2) printlnResult(3) } /** * Questions 60: Find the probabilities of all situations of sums of n dices */ private fun getProbabilityOfDices(n: Int): Map<Int, Double> { val map = getProbabilityOfDicesRecursion(n) ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,897
Algorithm
Apache License 2.0
src/Day20.kt
fedochet
573,033,793
false
{"Kotlin": 77129}
fun main() { fun part1(input: List<String>): Int { val values = input.map { it.toInt() } val indexed = values.mapIndexed { idx, value -> idx to value } val result = indexed.toMutableList() for (toMove in indexed) { val oldIndex = result.indexOf(toMove) val st...
0
Kotlin
0
1
975362ac7b1f1522818fc87cf2505aedc087738d
2,138
aoc2022
Apache License 2.0
src/Day02.kt
xuejingao
573,076,407
false
null
import Outcome.* private val selectedScoreMap = hashMapOf<String, Int>( "X" to 1, // rock "Y" to 2, // paper "Z" to 3, // scissor ) private enum class Outcome { WIN, LOSE, DRAW } private val winScoreMap = hashMapOf<Outcome, Int>( WIN to 6, LOSE to 0, DRAW to 3, ) ...
0
Kotlin
0
0
e438c3527ff7c69c13985dcd7c55145336d4f9ca
2,955
aoc-kotlin-2022
Apache License 2.0
src/Day02.kt
mcrispim
573,449,109
false
{"Kotlin": 46488}
fun main() { // Part 1 // First Column (adversary move) A = Rock, B = Paper, C = Scissor // Second column (your move) X = Rock, Y = Paper, Z = Scissor fun part1(input: List<String>): Int { val handPoints = mapOf( "A X" to 4, "A Y" to 8, "A Z" to 3, "B X" to 1, "B Y" to...
0
Kotlin
0
0
5fcacc6316e1576a172a46ba5fc9f70bcb41f532
1,147
AoC2022
Apache License 2.0
2020/src/year2020/day07/Day07.kt
eburke56
436,742,568
false
{"Kotlin": 61133}
package year2020.day07 import util.readAllLines import java.util.regex.Pattern private fun getRules(filename: String): Map<String, Map<String, Int>> { val input = readAllLines(filename) val contentsPattern = Pattern.compile("([0-9])+ (.*)? bag.*") val map = mutableMapOf<String, MutableMap<String, Int>>() ...
0
Kotlin
0
0
24ae0848d3ede32c9c4d8a4bf643bf67325a718e
1,931
adventofcode
MIT License
src/Day15.kt
zirman
572,627,598
false
{"Kotlin": 89030}
import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis data class Pos(val x: Int, val y: Int) data class Sensor(val x: Int, val y: Int) data class Beacon(val x: Int, val y: Int) sealed interface SensorGrid { object Air : SensorGrid object Sensor :...
0
Kotlin
0
1
2ec1c664f6d6c6e3da2641ff5769faa368fafa0f
8,717
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumDeleteSum.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
7,353
kotlab
Apache License 2.0
kotlin/2020/round-1a/pattern-matching/src/main/kotlin/Solution.kt
ShreckYe
345,946,821
false
null
fun main() { val T = readLine()!!.toInt() repeat(T) { t -> val N = readLine()!!.toInt() val P = (0 until N).map { readLine()!! } println("Case #${t + 1}: ${case(N, P)}") } } fun case(N: Int, P: List<String>): String? = getName(P.map { it.toList() }) fun getName(patterns: List<L...
0
Kotlin
1
1
743540a46ec157a6f2ddb4de806a69e5126f10ad
1,698
google-code-jam
MIT License
melif/src/main/kotlin/ru/ifmo/ctddev/isaev/measure.kt
siviae
53,358,845
false
{"Kotlin": 152748, "Java": 152582}
package ru.ifmo.ctddev.isaev /** * @author iisaev */ abstract class RelevanceMeasure(val minValue: Double, val maxValue: Double) { abstract fun evaluate(feature: Feature, classes: List<Int>): Double fun evaluate(original: FeatureDataSet): DoubleArray { return original.features.map { evaluate(it, ori...
0
Kotlin
0
1
2a3300ea32dda160d400258f2400c03ad84cb713
3,333
parallel-feature-selection
MIT License
src/day05/Day05.kt
TimberBro
572,681,059
false
{"Kotlin": 20536}
package day05 import readInput data class Instruction(val quantity: Int, val source: Int, val destination: Int) fun main() { fun part1(input: List<String>): String { val crates = parseCrates(input) val instructions = parseInstructions(input) for (instruction in instructions) { ...
0
Kotlin
0
0
516a98e5067d11f0e6ff73ae19f256d8c1bfa905
2,771
AoC2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2023/Day11.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2023 import se.saidaspen.aoc.util.* import kotlin.math.abs fun main() = Day11.run() object Day11 : Day(2023, 11) { private val map = toMap(input) private val emptyRows = input.lines().indices.filter { r -> map.filter { it.key.second == r }.all { it.value == '.' } }.toList() ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,107
adventofkotlin
MIT License
src/Day05.kt
dominik003
573,083,805
false
{"Kotlin": 9376}
import java.util.* fun main() { fun part1(input: Pair<Map<Int, ArrayDeque<Char>>, List<Triple<Int, Int, Int>>>): String { val stackMap = input.first val commands = input.second commands.forEach { for (i in 0 until it.first) { val firstEl = stackMap[it.second - 1...
0
Kotlin
0
0
b64d1d4c96c3dd95235f604807030970a3f52bfa
2,542
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2018/Day07.kt
tginsberg
155,878,142
false
null
/* * Copyright (c) 2018 by <NAME> */ /** * Advent of Code 2018, Day 7 - The Sum of Its Parts * * Problem Description: http://adventofcode.com/2018/day/7 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2018/day7/ */ package com.ginsberg.advent2018 class Day07(input: List<String>) { pr...
0
Kotlin
1
18
f33ff59cff3d5895ee8c4de8b9e2f470647af714
3,133
advent-2018-kotlin
MIT License
src/main/kotlin/g2401_2500/s2435_paths_in_matrix_whose_sum_is_divisible_by_k/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2401_2500.s2435_paths_in_matrix_whose_sum_is_divisible_by_k // #Hard #Array #Dynamic_Programming #Matrix // #2023_07_05_Time_752_ms_(100.00%)_Space_76.1_MB_(100.00%) class Solution { private val mod = (1e9 + 7).toInt() private var row = 0 private var col = 0 private lateinit var cache: Array<...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,411
LeetCode-in-Kotlin
MIT License
src/main/kotlin/day13/Day13.kt
alxgarcia
435,549,527
false
{"Kotlin": 91398}
package day13 import java.io.File /* Syntax sugar */ typealias Dot = Pair<Int, Int> typealias PaperFold = Pair<Char, Int> private val Dot.x: Int get() = this.first private val Dot.y: Int get() = this.second /* end */ fun parseInput(lines: List<String>): Pair<List<Dot>, List<PaperFold>> { val dots = lines...
0
Kotlin
0
0
d6b10093dc6f4a5fc21254f42146af04709f6e30
2,272
advent-of-code-2021
MIT License
src/2021-Day03.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
fun main() { fun part1(input: List<String>): Pair<Int,Int> { val size = input[0].trim().length val counts = MutableList(size) { 0 } var total = 0 for (line in input) { ++total var ix = 0 for (digit in line.trim()) { if (digit == '1...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
2,882
2022-aoc-kotlin
Apache License 2.0
leetcode/src/offer/middle/Offer13.kt
zhangweizhe
387,808,774
false
null
package offer.middle fun main() { // 剑指 Offer 13. 机器人的运动范围 // https://leetcode.cn/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ println(movingCount(16,16,2)) } fun movingCount(m: Int, n: Int, k: Int): Int { val visited = ArrayList<RobotPair>() help1(visited, m, n, k, 0, 0) return visited.size ...
0
Kotlin
0
0
1d213b6162dd8b065d6ca06ac961c7873c65bcdc
2,348
kotlin-study
MIT License
src/day4/Day04.kt
kongminghan
573,466,303
false
{"Kotlin": 7118}
package day4 import readInput import java.lang.Integer.max import java.lang.Integer.min fun main() { fun String.toIntRange(): IntRange { val (first, second) = this.split("-") return first.toInt()..second.toInt() } fun ClosedRange<Int>.containedIn(other: ClosedRange<Int>) = other....
0
Kotlin
0
0
f602900209712090778c161d407ded8c013ae581
1,702
advent-of-code-kotlin
Apache License 2.0
archive/2022/Day03.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
package aoc2022 private const val EXPECTED_1 = 157 private const val EXPECTED_2 = 70 private fun Set<Char>.score(): Int { check(size == 1) val value = first() return if (value in 'a'..'z') value - 'a' + 1 else value - 'A' + 27 } private class Day03(isTest: Boolean) : Solver(isTest) { ...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,166
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dp/MaxSum.kt
yx-z
106,589,674
false
null
package dp import util.* // given an array of arbitrary numbers // find the largest sum of elements in a contiguous subarray fun main(args: Array<String>) { val arr = intArrayOf(-6, 12, -7, 0, 14, -7, 5) // println(arr.maxSumN2()) // println(arr.maxSumNLogN()) // println(arr.maxSumN()) // println(arr.maxSumKadane())...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
3,988
AlgoKt
MIT License
kotlin/037.kts
daithiocrualaoich
12,319,597
false
{"Scala": 55137, "CoffeeScript": 17629, "Python": 10689, "Rust": 5395, "Kotlin": 2121, "Shell": 924}
/* * Truncatable Primes * ================== * The number 3797 has an interesting property. Being prime itself, it is * possible to continuously remove digits from left to right, and remain prime * at each stage: 3797, 797, 97, and 7. Similarly we can work from right to * left: 3797, 379, 37, and 3. * * Find th...
0
Scala
0
1
5bb0ab16bf9bc622b94f4c66a18fa6fac070fc48
2,121
euler
Apache License 2.0
src/main/kotlin/aoc23/day03.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc23 import datastructures.Coordinate import datastructures.getAllAdjacentCoordinates import runTask import utils.InputReader import java.util.UUID fun day3part1(input: List<String>): Int = with(getNumbersAndSymbols(input)) { symbols.flatMap { symbol -> symbol.coordinate.getAllAdjacen...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
2,389
advent-of-code
Apache License 2.0
src/Day10.kt
AxelUser
572,845,434
false
{"Kotlin": 29744}
import java.util.* fun main() { fun part1(input: List<String>): Int { var sum = 0 var cmd = 0 var x = 1 val ops: Queue<Triple<Int, String, Int>> = LinkedList() for (cycle in 1..220) { if (ops.isNotEmpty() && ops.peek().first == cycle) { x += ops...
0
Kotlin
0
1
042e559f80b33694afba08b8de320a7072e18c4e
1,825
aoc-2022
Apache License 2.0
src/main/kotlin/Day03.kt
SimonMarquis
724,825,757
false
{"Kotlin": 30983}
import Day03.Object.Part import Day03.Object.Symbol import kotlin.math.max import kotlin.math.min class Day03(private val input: List<String>) { sealed class Object { data class Part(val x: IntRange, val y: Int, val value: Int) : Object() data class Symbol(val x: Int, val y: Int, val value: Char) ...
0
Kotlin
0
1
043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e
2,138
advent-of-code-2023
MIT License
ceria/16/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File import java.util.Collections fun main(args : Array<String>) { val input = File(args.first()).readLines() println("Solution 1: ${solution1(input)}") println("Solution 2: ${solution2(input)}") } private fun solution1(input :List<String>) :Int { val rules = input.subList(0, input.indexO...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
3,909
advent-of-code-2020
MIT License
KotlinAdvent2018/week1/src/main/kotlin/net/twisterrob/challenges/adventOfKotlin2018/week1/MarkingWayOnMap.kt
TWiStErRob
136,539,340
false
{"Kotlin": 104880, "Java": 11319}
package net.twisterrob.challenges.adventOfKotlin2018.week1 import net.twisterrob.challenges.adventOfKotlin2018.week1.AStar.Pos import net.twisterrob.challenges.adventOfKotlin2018.week1.Map.Cell import java.lang.Math.sqrt fun addPath(inputMap: String): String { val map = Map.parse(inputMap) AStar(map).run(::heuristi...
1
Kotlin
1
2
5cf062322ddecd72d29f7682c3a104d687bd5cfc
1,240
TWiStErRob
The Unlicense
kotlin/src/main/kotlin/be/swsb/aoc2023/day7/Day7.kt
Sch3lp
724,797,927
false
{"Kotlin": 44815, "Rust": 14075}
package be.swsb.aoc2023.day7 import be.swsb.aoc2023.day7.Card.* object HandComparator : Comparator<Pair<Hand, Bid>> { override fun compare(hand1: Pair<Hand, Bid>, hand2: Pair<Hand, Bid>): Int { val typeComparison = hand1.first.type.ordinal.compareTo(hand2.first.type.ordinal) return if (typeCompari...
0
Kotlin
0
1
dec9331d3c0976b4de09ce16fb8f3462e6f54f6e
2,933
Advent-of-Code-2023
MIT License
2022/24/24.kt
LiquidFun
435,683,748
false
{"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191}
typealias Point = Pair<Int, Int> val dirs = listOf(0 to 1, 1 to 0, 0 to -1, -1 to 0) val dirsChars: Map<Char, Point> = mapOf('>' to dirs[0], 'v' to dirs[1], '<' to dirs[2], '^' to dirs[3]) fun lcmOf(a: Int, b: Int) = (1..100000).first { it % a == 0 && it % b == 0 } fun main() { val input = generateSequence(::read...
0
Kotlin
7
43
7cd5a97d142780b8b33b93ef2bc0d9e54536c99f
2,282
adventofcode
Apache License 2.0
src/Day04.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
fun main() { fun fullyIn(range1: IntRange, range2: IntRange): Boolean { return (range1.first in range2 && range1.last in range2) } fun overlap(range1: IntRange, range2: IntRange): Boolean { return (range1.first in range2 || range1.last in range2) } fun withRangesParsed(input: List<...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
1,084
advent-of-kotlin-2022
Apache License 2.0
src/main/kotlin/day15.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.Point import shared.XYMap import shared.getLines import kotlin.math.abs class CavernRisk(input: List<String>): XYMap<Int>(input, { c: Char -> c.digitToInt() }) { private val start = Point(0,0) private val goal = Point(width-1, height-1) private fun heuristic(a: Point, b: Point) = (abs(a.x - ...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
2,536
AdventOfCode2021
MIT License
src/Day02.kt
jaldhar
573,188,501
false
{"Kotlin": 14191}
class RockPaperScissors { companion object { val shape = mapOf<String, Int>( "X" to 1, "Y" to 2, "Z" to 3, ) val transform = mapOf<String, String>( "AX" to "Z", "AY" to "X", "AZ" to "Y", "BX" to "X...
0
Kotlin
0
0
b193df75071022cfb5e7172cc044dd6cff0f6fdf
1,727
aoc2022-kotlin
Apache License 2.0
2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day09/Day09.kt
sanderploegsma
224,286,922
false
{"C#": 233770, "Kotlin": 126791, "F#": 110333, "Go": 70654, "Python": 64250, "Scala": 11381, "Swift": 5153, "Elixir": 2770, "Jinja": 1263, "Ruby": 1171}
package nl.sanderp.aoc.aoc2015.day09 import nl.sanderp.aoc.common.readResource data class Distance(val from: String, val to: String, val distance: Int) fun parse(line: String): List<Distance> { val segments = line.split(" to ", " = ") val distance = Distance(from = segments[0], to = segments[1], distance = s...
0
C#
0
6
8e96dff21c23f08dcf665c68e9f3e60db821c1e5
1,283
advent-of-code
MIT License
src/main/kotlin/day21/Day21.kt
dustinconrad
572,737,903
false
{"Kotlin": 100547}
package day21 import readResourceAsBufferedReader fun main() { println("part 1: ${part1(readResourceAsBufferedReader("21_1.txt").readLines())}") println("part 2: ${part2(readResourceAsBufferedReader("21_2.txt").readLines())}") } fun part1(input: List<String>): Long { val nodes = input.map { Node.parse(it...
0
Kotlin
0
0
1dae6d2790d7605ac3643356b207b36a34ad38be
3,445
aoc-2022
Apache License 2.0
src/twentytwentythree/day08/Day08.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day08 import readInput fun main() { fun Set<String>.allZ(): Boolean { return this.all { it.last() == 'Z' } } fun part1(input: List<String>): Int { val directions = input[0].toList() val nodeMap = mutableMapOf<String, Pair<String, String>>() input.subList(2, input.size)...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
2,300
advent-of-code
Apache License 2.0
src/main/kotlin/io/matrix/RangeSumQuery2DMatrix.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.matrix import io.utils.runTests // https://leetcode.com/problems/range-sum-query-2d-immutable/ class RangeSumQuery2DMatrix(private val matrix: Array<IntArray>) { private val dp = Array(matrix.size) { IntArray(matrix.firstOrNull()?.size ?: 0) }.apply { if (matrix.isNotEmpty() && matrix.first().isNotE...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,936
coding
MIT License
src/Day05.kt
haraldsperre
572,671,018
false
{"Kotlin": 17302}
typealias CrateStack = ArrayDeque<Char> fun CrateStack.pop(): Char = removeLast() fun CrateStack.pop(count: Int): CrateStack { val a = CrateStack() repeat(count) { a.addFirst(pop()) } return a } fun CrateStack.push(crate: Char) = addLast(crate) fun CrateStack.push(crates: CrateStack) { while (crates.i...
0
Kotlin
0
0
c4224fd73a52a2c9b218556c169c129cf21ea415
2,414
advent-of-code-2022
Apache License 2.0
src/Day15.kt
AlaricLightin
572,897,551
false
{"Kotlin": 87366}
import kotlin.math.abs fun main() { fun part1(coords: List<Pair<Coords, Coords>>, lineY: Int): Int { val rangePointList = getRangePointListForLine(coords, lineY) var result = 0 var beginCount = 0 var currentBegin: Int? = null rangePointList.forEach { when(it.poi...
0
Kotlin
0
0
ee991f6932b038ce5e96739855df7807c6e06258
4,406
AdventOfCode2022
Apache License 2.0
src/Day15.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
import java.util.regex.Pattern import kotlin.math.abs import kotlin.streams.toList import kotlin.time.ExperimentalTime import kotlin.time.measureTime class Segment(var start: Int, var end: Int) : Comparable<Segment> { fun overlap(other: Segment): Int { if (other.end < other.start) return 0 ...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
2,272
AOC-2022
Apache License 2.0
src/Day03.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
fun main() { fun Char.priority(): Int { return if (isLowerCase()) code - 'a'.code + 1 else code - 'A'.code + 27 } fun part1(input: List<String>): Int = input.sumOf { rucksack -> val (first, second) = rucksack.map { item -> item.pr...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
1,043
AdventOfCode
Apache License 2.0
src/main/kotlin/day24_arithmetic_logic_unit/ArithmeticLogicUnit.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package day24_arithmetic_logic_unit /** * At first blush, this looks like a "build an interpreter/VM" sort of problem * in the style of Intcode. However, 9^14 numbers to check... This is another * "find the optimal path" (like Chiton #15), but the thing you need to find a * path through is expressed by the input p...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
2,860
aoc-2021
MIT License
src/Day07.kt
paul-matthews
433,857,586
false
{"Kotlin": 18652}
import java.lang.Math.abs typealias CrabMultiplier = (Int) -> Int val constantInt: CrabMultiplier = {i -> i} val incrementalInt: CrabMultiplier = {i -> (1..i).toList().sum()} fun List<String>.toCrabs(): Crabs = fold(mutableListOf()) { acc, s -> acc.addAll(s.split(",").toInts()) acc } typealias Crabs = List<In...
0
Kotlin
0
0
2f90856b9b03294bc279db81c00b4801cce08e0e
1,363
advent-of-code-kotlin-template
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch2/Problem23.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import dev.bogwalk.util.maths.sumProperDivisors /** * Problem 23: Non-Abundant Sums * * https://projecteuler.net/problem=23 * * Goal: Return whether N can be expressed as the sum of 2 abundant numbers. * * Constraints: 0 <= N <= 1e5 * * Perfect Number: The sum of its proper divisor...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
2,879
project-euler-kotlin
MIT License
src/Day05.kt
mr-cell
575,589,839
false
{"Kotlin": 17585}
fun main() { fun performInstructions(instructions: List<Instruction>, stacks: Stacks, reverse: Boolean) { instructions.forEach { (howMany, from, to) -> val crates = stacks[from].take(howMany) repeat(howMany) { stacks[from].removeFirst() } stacks[to].addAll(0, if (reverse...
0
Kotlin
0
0
2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9
1,892
advent-of-code-2022
Apache License 2.0
src/Day11/Day11.kt
lukeqwas
573,403,156
false
null
package Day11 import readInput import java.lang.IllegalArgumentException import java.math.BigDecimal import java.math.BigInteger fun main() { val testInput = readInput("Day11/Day11") val monkeyList = mutableListOf<Monkey>() var startingItems = mutableListOf<Item>() var operation = { x:BigDecimal -> B...
0
Kotlin
0
0
6174a8215f8d4dc6d33fce6f8300a4a8999d5431
4,153
aoc-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2020/day02_password_philosophy/PasswordPhilosophy.kt
barneyb
425,532,798
false
{"Kotlin": 238776, "Shell": 3825, "Java": 567}
package aoc2020.day02_password_philosophy fun main() { util.solve(424, ::partOne) util.solve(747, ::partTwo) } data class Policy(val a: Int, val b: Int, val char: Char) data class Record(val policy: Policy, val password: String) object parseRecord { private val RE_RECORD = Regex("""(\d+)-(\d+) ([a-z]):...
0
Kotlin
0
0
a8d52412772750c5e7d2e2e018f3a82354e8b1c3
1,525
aoc-2021
MIT License
2017/src/main/java/p3/Problem3.kt
ununhexium
113,359,669
false
null
package p3 import more.format import more.next import p3.Position.x import p3.Position.y import kotlin.math.ceil import kotlin.math.log10 // https://adventofcode.com/2017/day/3 val inputs = listOf( 1, 1024, 289326 ) fun main(args: Array<String>) { inputs.forEach { println(buildSpiral(it)) } } p...
6
Kotlin
0
0
d5c38e55b9574137ed6b351a64f80d764e7e61a9
2,791
adventofcode
The Unlicense
src/Day05.kt
lukewalker128
573,611,809
false
{"Kotlin": 14077}
fun main() { val testInput = readInput("Day05_test") checkEquals("CMZ", part1(testInput)) checkEquals("MCD", part2(testInput)) val input = readInput("Day05") println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } /** * Execute commands from the given input on the initial stac...
0
Kotlin
0
0
c1aa17de335bd5c2f5f555ecbdf39874c1fb2854
3,234
advent-of-code-2022
Apache License 2.0
src/Day05.kt
romainbsl
572,718,344
false
{"Kotlin": 17019}
fun main() { val testInput = readInput("Day05_test") check(part1(testInput) == "CMZ") check(part2(testInput) == "MCD") val input = readInput("Day05") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): String { val (stacks, moves) = parse(input) moves...
0
Kotlin
0
0
b72036968769fc67c222a66b97a11abfd610f6ce
2,487
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1011/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1011 /** * LeetCode page: [1011. Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/); */ class Solution { /* Complexity: * Time O(N+K(LogM)(LogN)) and Space O(N) where N is the size of weights, K is days, and ...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,125
hj-leetcode-kotlin
Apache License 2.0
src/Day08.kt
MisterTeatime
561,848,263
false
{"Kotlin": 20300}
fun main() { fun part1(input: List<String>): Int { val regexEscapeSequences = """\\x[0-9a-fA-F]{2}|\\\\|\\\"""".toRegex() val codeLength = input.sumOf { it.length } val memoryLength = input .map { it.drop(1)} //Erstes Gänsefüßchen verwerfen .map { it.dropLast(1) } //...
0
Kotlin
0
0
d684bd252a9c6e93106bdd8b6f95a45c9924aed6
1,182
AoC2015
Apache License 2.0
src/Day07.kt
zt64
572,594,597
false
null
fun main() { val input = readInput("Day07") val log = input.lines() val rootDirectory = Dir(null, "/") var currentDirectory = rootDirectory val fs = mutableListOf<FsEntity>() fs.add(rootDirectory) fun flatten(list: List<FsEntity>): List<FsEntity> = buildList { list.forEach { entit...
0
Kotlin
0
0
4e4e7ed23d665b33eb10be59670b38d6a5af485d
3,188
aoc-2022
Apache License 2.0
src/main/kotlin/Day17.kt
dlew
75,886,947
false
null
class Day17 { enum class Direction(val c: Char, val x: Int, val y: Int) { UP('U', 0, -1), DOWN('D', 0, 1), LEFT('L', -1, 0), RIGHT('R', 1, 0) } data class State(val x: Int, val y: Int, val moves: String) companion object { private val INDEX_TO_DIRECTION = arrayOf(Direction.UP, Direction.D...
0
Kotlin
2
12
527e6f509e677520d7a8b8ee99f2ae74fc2e3ecd
2,119
aoc-2016
MIT License
src/main/kotlin/de/consuli/aoc/year2022/days/Day08.kt
ulischulte
572,773,554
false
{"Kotlin": 40404}
package de.consuli.aoc.year2022.days import de.consuli.aoc.common.Day class Day08 : Day(8, 2022) { private val treesTestInput: List<Tree> private val trees: List<Tree> init { trees = readTrees(false) treesTestInput = readTrees(true) } override fun partOne(testInput: Boolean): An...
0
Kotlin
0
2
21e92b96b7912ad35ecb2a5f2890582674a0dd6a
4,086
advent-of-code
Apache License 2.0
aoc/src/main/kotlin/com/bloidonia/aoc2023/graph/Graph.kt
timyates
725,647,758
false
{"Kotlin": 45518, "Groovy": 202}
package com.bloidonia.aoc2023.graph import java.util.PriorityQueue typealias Neighbours<Vertex> = (Vertex) -> List<Vertex> typealias End<Vertex> = (Vertex) -> Boolean typealias Cost<Vertex> = (Vertex, Vertex) -> Long typealias Fudge<Vertex> = (Vertex) -> Long data class Seen<Vertex>(val cost: Long, val prev: Vertex?...
0
Kotlin
0
0
158162b1034e3998445a4f5e3f476f3ebf1dc952
1,828
aoc-2023
MIT License
app/src/main/kotlin/day04/Day04.kt
meli-w
433,710,859
false
{"Kotlin": 52501}
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
1
f3b96c831d6c8e21de1ac866cf9c64aaae2e5ea1
4,041
AoC-2021
Apache License 2.0
src/main/kotlin/Day8_2.kt
vincent-mercier
726,287,758
false
{"Kotlin": 37963}
import java.io.File import java.io.InputStream private fun gcd(x: Long, y: Long): Long { return if ((y == 0L)) x else gcd(y, x % y) } private fun lcm(numbers: Sequence<Long>): Long { return numbers .fold(1) { x: Long, y: Long -> x * (y / gcd(x, y)) } } fun firstZ( directions:...
0
Kotlin
0
0
53b5d0a0bb65a77deb5153c8a912d292c628e048
1,712
advent-of-code-2023
MIT License
src/Day02.kt
m0r0
576,999,741
false
null
fun main() { fun part1(input: List<String>): Int { return solvePart1(input) } fun part2(input: List<String>): Int { return solvePart2(input) } val input = readInput("Day02") part1(input).println() part2(input).println() } fun solvePart1(input: List<String>): Int { ret...
0
Kotlin
0
0
b6f3c5229ad758f61f219040f8db61f654d7fc00
2,699
kotlin-AoC-2022
Apache License 2.0
src/day05/Day05.kt
iliascholl
572,982,464
false
{"Kotlin": 8373}
package day05 import day05.Instruction.Companion.toInstruction import readInput private typealias Stack = MutableMap.MutableEntry<Int, ArrayDeque<Char>> private typealias Stacks = MutableMap<Int, ArrayDeque<Char>> private data class Instruction( val amount: Int, val from: Int, val to: Int, ) { compan...
0
Kotlin
0
1
26db12ddf4731e4ee84f45e1dc4385707f9e1d05
3,159
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/com/colinodell/advent2021/Day19.kt
colinodell
433,864,377
true
{"Kotlin": 111114}
package com.colinodell.advent2021 // I really struggled with this one, so I ended up adapting the solution from the following: // - https://bit.ly/3Ei8rOw // - https://github.com/ThomasBollmeier/advent-of-code-kotlin-2021 class Day19(input: String) { private val scanners = input.split("\n\n").map { s -> ...
0
Kotlin
0
1
a1e04207c53adfcc194c85894765195bf147be7a
3,873
advent-2021
Apache License 2.0
advent2022/src/main/kotlin/year2022/Day07.kt
bulldog98
572,838,866
false
{"Kotlin": 132847}
package year2022 import AdventDay sealed interface Node { val name: String val parent: Node? val fileSize: Int } class File(override val fileSize: Int, override val name: String, override val parent: Node?): Node class Directory( override val name: String, override val parent: Node?, val chil...
0
Kotlin
0
0
02ce17f15aa78e953a480f1de7aa4821b55b8977
2,235
advent-of-code
Apache License 2.0
src/Day12/Day12.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day12 import readInput import java.util.PriorityQueue import kotlin.math.* class Node(val elevation: Int): Comparable<Node> { var distance = Int.MAX_VALUE - 1 var prev: Node? = null var neighbors = mutableListOf<Node>() fun isReachable(other: Node): Boolean { return other.elevation <=...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
4,070
advent-of-code-2022
Apache License 2.0
src/Day15.kt
freszu
573,122,040
false
{"Kotlin": 32507}
import kotlin.math.abs import kotlin.time.ExperimentalTime import kotlin.time.measureTime fun Position.manhattanDistance(other: Position) = abs(this.x - other.x) + abs(this.y - other.y) @OptIn(ExperimentalTime::class) fun main() { val inputLineRegex = Regex("""Sensor at x=(-?\d+), y=(-?\d+): closest beacon is at...
0
Kotlin
0
0
2f50262ce2dc5024c6da5e470c0214c584992ddb
2,696
aoc2022
Apache License 2.0
src/main/kotlin/day9.kt
nerok
572,862,875
false
{"Kotlin": 32118}
import java.io.File fun main(args: Array<String>) { day9part2() } fun day9part1() { var coordinates = mutableListOf<List<Int>>() val input = File("day9input.txt").bufferedReader().readLines() input.mapIndexed { index, line -> line.split("") .filterNot { it == "" } .map ...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
6,650
Advent-of-code-2021
Apache License 2.0
src/main/kotlin/solutions/year2022/Day2.kt
neewrobert
573,028,531
false
{"Kotlin": 7605}
package solutions.year2022 import readInputLines private val lose = mapOf(1 to 0, 2 to 1, 0 to 2) private val won = mapOf(0 to 1, 1 to 2, 2 to 0) fun main() { fun getResultScore(elfCode: Int, villainCode: Int) = 3 * elfCode to when (elfCode) { 0 -> lose[villainCode]!! 1 -> villa...
0
Kotlin
0
0
7ecf680845af9d22ef1b9038c05d72724e3914f1
1,701
aoc-2022-in-kotlin
Apache License 2.0
src/Day02.kt
lassebe
573,423,378
false
{"Kotlin": 33148}
fun main() { val scores = mapOf( "Rock" to 1, "Paper" to 2, "Scissor" to 3, "Win" to 6, "Draw" to 3, "Loss" to 0 ) fun part1(input: List<String>): Int = input.sumOf { val plays = it.split(" ").map { mapOf( "A" to "Rock", ...
0
Kotlin
0
0
c3157c2d66a098598a6b19fd3a2b18a6bae95f0c
2,506
advent_of_code_2022
Apache License 2.0
src/Day03.kt
befrvnk
574,229,637
false
{"Kotlin": 15788}
fun Char.priority() = if (this.code <= 'Z'.code) this.code - 'A'.code + 27 else this.code - 'a'.code + 1 fun main() { fun part1(input: List<String>): Int { var totalPriority = 0 input.forEach { rucksack -> val leftCompartment = rucksack.substring(0 until rucksack.length / 2) ...
0
Kotlin
0
0
68e5dd5656c052d8c8a2ea9e03c62f4cd2438dd7
1,347
aoc-2022-kotlin
Apache License 2.0
src/day04/Day04.kt
scottpeterson
573,109,888
false
{"Kotlin": 15611}
private class CleaningAssignment(start: Int, end: Int) { val range = start..end infix fun containsAll(other: CleaningAssignment) = range.intersect(other.range).size == other.range.count() infix fun containsAny(other: CleaningAssignment) = range.intersect(other.range).isNotEmpty() companion object { ...
0
Kotlin
0
0
0d86213c5e0cd5403349366d0f71e0c09588ca70
1,261
advent-of-code-2022
Apache License 2.0
src/Day04.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
private fun ranges(): List<Pair<IntRange, IntRange>> { return readInput("Day04").map { it.split(",") }.map { it[0].split("-") + it[1].split("-") } .map { Pair(IntRange(it[0].toInt(), it[1].toInt()), IntRange(it[2].toInt(), it[3].toInt())) } } private fun part1(ranges: List<Pair<IntRange, IntRange>>): Int {...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
612
advent-of-code-2022
Apache License 2.0
advent-of-code-2022/src/main/kotlin/year_2022/Day14.kt
rudii1410
575,662,325
false
{"Kotlin": 37749}
package year_2022 import util.Pos2 import util.Runner import util.wrap fun main() { fun drawStone(map: List<MutableList<Char>>, h: Pos2, v: Pos2) { for (i in h.x .. h.y) { for (j in v.x .. v.y) map[i][j] = '#' } } fun scanAndNormalizeMap( input: List<String> ): Tri...
1
Kotlin
0
0
ab63e6cd53746e68713ddfffd65dd25408d5d488
4,073
advent-of-code
Apache License 2.0
src/Year2022Day02.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
enum class HandShape { ROCK, PAPER, SCISSOR; companion object { fun of(char: Char): HandShape = when (char) { 'A', 'X' -> ROCK 'B', 'Y' -> PAPER 'C', 'Z' -> SCISSOR else -> throw IllegalArgumentException() } fun of(myResult: Result, oppon...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
2,621
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/days/Day2.kt
hughjdavey
572,954,098
false
{"Kotlin": 61752}
package days import days.Day2.Outcome.LOSE import days.Day2.Outcome.DRAW import days.Day2.Outcome.WIN import days.Day2.Shape.ROCK import days.Day2.Shape.PAPER import days.Day2.Shape.SCISSORS class Day2 : Day(2) { private val mappings = mapOf("A" to 1, "X" to 1, "B" to 2, "Y" to 2, "C" to 3, "Z" to 3) privat...
0
Kotlin
0
2
65014f2872e5eb84a15df8e80284e43795e4c700
1,749
aoc-2022
Creative Commons Zero v1.0 Universal
kotlin/2018/src/main/kotlin/2018/Lib06.kt
nathanjent
48,783,324
false
{"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966}
package aoc.kt.y2018; import kotlin.math.absoluteValue /** * Day 6. */ /** Part 1 */ fun processAreas1(input: String): String { val coordinateMap = coordinateMap(input) val (width, height) = borderDimensions(coordinateMap) val distanceMap = distanceMap(coordinateMap, width, height) val areaMap =...
0
Rust
0
0
7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf
3,768
adventofcode
MIT License
kotlin/src/katas/kotlin/leetcode/jump_game_ii/JumpGame.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.jump_game_ii import datsok.shouldEqual import org.junit.jupiter.api.Test // // https://leetcode.com/problems/jump-game-ii ✅ // // Given an array of non-negative integers, you are initially positioned at the first index of the array. // Each element in the array represents your maximum ju...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,371
katas
The Unlicense
src/Lesson6Sorting/MaxProductOfThree.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Arrays /** * 100/100 * @param A * @return */ fun solution(A: IntArray): Int { val N = A.size Arrays.sort(A) /** * When we sort an array there are two possible options for the largest product * 1) The largest (the last) three elements * 2) Combination of two smallest an...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
1,786
Codility-Kotlin
Apache License 2.0
src/Day02.kt
azat-ismagilov
573,217,326
false
{"Kotlin": 75114}
fun main() { fun String.toNumber(): Int = when (this) { "X" -> 1 "Y" -> 2 "Z" -> 3 "A" -> 1 "B" -> 2 "C" -> 3 else -> 0 } fun win(players: List<Int>): Int = ((players[1] - players[0] + 4) % 3) * 3 fun calcMyPrice(players: List<Int>): Int = win(pl...
0
Kotlin
0
0
abdd1b8d93b8afb3372cfed23547ec5a8b8298aa
955
advent-of-code-kotlin-2022
Apache License 2.0
2020/src/main/kotlin/sh/weller/adventofcode/twentytwenty/Day18Part2.kt
Guruth
328,467,380
false
{"Kotlin": 188298, "Rust": 13289, "Elixir": 1833}
package sh.weller.adventofcode.twentytwenty fun List<String>.day18Part2(): Long = this.map { it.split(" ").filter { it.isNotBlank() } } .map { it.calculateAdvanced() } .map { it.toLong() } .sum() private fun List<String>.calculateAdvanced(): String { when { this.size == 1 -> {...
0
Kotlin
0
0
69ac07025ce520cdf285b0faa5131ee5962bd69b
2,607
AdventOfCode
MIT License
src/Day25.kt
dizney
572,581,781
false
{"Kotlin": 105380}
import kotlin.math.pow object Day25 { const val EXPECTED_PART1_CHECK_ANSWER = "2=-1=0" const val EXPECTED_PART2_CHECK_ANSWER = 1 } fun main() { fun fivesValueForDigit(char: Char) = when (char) { '2' -> 2 '1' -> 1 '0' -> 0 '-' -> -1 '=' -> -2 else -> error(...
0
Kotlin
0
0
f684a4e78adf77514717d64b2a0e22e9bea56b98
2,022
aoc-2022-in-kotlin
Apache License 2.0