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/dev/shtanko/algorithms/leetcode/RemoveBoxes.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
3,017
kotlab
Apache License 2.0
src/main/java/com/ncorti/aoc2021/Exercise03.kt
cortinico
433,486,684
false
{"Kotlin": 36975}
package com.ncorti.aoc2021 object Exercise03 { fun part1(): Int { val input = getInputAsTest("03") { split("\n") }.map { it.toCharArray().map { digit -> digit.digitToInt() } } return input .reduce { l, r -> l.mapIndexed { index, item -> item + r...
0
Kotlin
0
4
af3df72d31b74857201c85f923a96f563c450996
1,727
adventofcode-2021
MIT License
src/main/kotlin/Day07.kt
dliszewski
573,836,961
false
{"Kotlin": 57757}
class Day07 { fun part1(input: List<String>): Long { val hashMapOf = directoriesMap(input) return hashMapOf.values.filter { it <= 100_000 }.sum() } private fun directoriesMap(input: List<String>): MutableMap<String, Long> { val hashMapOf = mutableMapOf<String, Long>() var p...
0
Kotlin
0
0
76d5eea8ff0c96392f49f450660220c07a264671
2,295
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/dikodam/Utils.kt
dikodam
573,126,346
false
{"Kotlin": 26584}
package de.dikodam data class Coordinates2D(val x: Int, val y: Int) { operator fun plus(other: Coordinates2D) = Coordinates2D(x + other.x, y + other.y) fun all4Neighbors(): List<Coordinates2D> { return Cardinal4Direction.values().map { dir -> this + dir.toCoords2D() } } fun all8neighbors(): L...
0
Kotlin
0
1
3eb9fc6f1b125565d6d999ebd0e0b1043539d192
2,695
aoc2022
MIT License
src/day_13/kotlin/Day13.kt
Nxllpointer
573,051,992
false
{"Kotlin": 41751}
import kotlin.math.max // AOC Day 13 fun Pair<List<*>, List<*>>.isInRightOrder(): Boolean? { val left = first val right = second for (listIndex in 0..max(left.lastIndex, right.lastIndex)) { if (listIndex > left.lastIndex) return true if (listIndex > right.lastIndex) return false ...
0
Kotlin
0
0
b6d7ef06de41ad01a8d64ef19ca7ca2610754151
3,450
AdventOfCode2022
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2015/2015-07.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2015 import com.github.ferinagy.adventOfCode.println import com.github.ferinagy.adventOfCode.readInputLines fun main() { val input = readInputLines(2015, "07-input") val test1 = readInputLines(2015, "07-test1") println("Part1:") part1(test1, "g").println() ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
2,705
advent-of-code
MIT License
advent-of-code-2020/src/main/kotlin/eu/janvdb/aoc2020/day10/Day10.kt
janvdbergh
318,992,922
false
{"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335}
package eu.janvdb.aoc2020.day10 import eu.janvdb.aocutil.kotlin.readLines fun main() { val numbers = readLines(2020, "input10.txt").map(String::toInt) val numbersIncludingStartAndEndValue = listOf(listOf(0, numbers.maxOrNull()!! + 3), numbers).flatten().sorted() part1(numbersIncludingStartAndEndValue) part2(numb...
0
Java
0
0
78ce266dbc41d1821342edca484768167f261752
1,168
advent-of-code
Apache License 2.0
src/day04/Day04.kt
dkoval
572,138,985
false
{"Kotlin": 86889}
package day04 import readInput private const val DAY_ID = "04" fun main() { fun parseInput(input: List<String>): List<Pair<IntRange, IntRange>> = input.map { line -> val (first, second) = line.split(",").map { range -> val (start, end) = range.split("-").map { it.toInt...
0
Kotlin
1
0
791dd54a4e23f937d5fc16d46d85577d91b1507a
1,342
aoc-2022-in-kotlin
Apache License 2.0
src/Day15.kt
ostersc
572,991,552
false
{"Kotlin": 46059}
import kotlin.math.absoluteValue fun log(s: String) { //println(s) } sealed class LocationContent class Beacon : LocationContent() class Sensor(var distanceFromBeacon: Int) : LocationContent() data class Location(var x: Int, var y: Int) { fun distanceFrom(l: Location): Int { return (x - l.x).absolute...
0
Kotlin
0
1
3eb6b7e3400c2097cf0283f18b2dad84b7d5bcf9
4,436
advent-of-code-2022
Apache License 2.0
src/main/kotlin/year2022/day-08.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.aoc.Day import lib.aoc.Part import lib.math.Vector import lib.math.plus import lib.math.plusAssign import lib.math.product fun main() { Day(8, 2022, PartA8(), PartB8()).run() } open class PartA8 : Part() { lateinit var trees: List<List<Int>> lateinit var limits: Iterable<Int>...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
2,685
Advent-Of-Code-Kotlin
MIT License
src/main/kotlin/days/aoc2023/Day12.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2023 import days.Day class Day12 : Day(2023, 12) { override fun partOne(): Any { return calculatePartOne(inputList) } override fun partTwo(): Any { return calculatePartTwo(inputList) } fun calculatePartOne(input: List<String>): Int { // brute force it ...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
4,669
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day03.kt
aneroid
572,802,061
false
{"Kotlin": 27313}
class Day03(private val input: List<String>) { private val data get() = parseInput(input) private val priorities = (('a'..'z') + ('A'..'Z')).zip(1..52).toMap() fun partOne(): Int = data .asSequence() .map { it.first.toSet().intersect(it.second.toSet()).first...
0
Kotlin
0
0
cf4b2d8903e2fd5a4585d7dabbc379776c3b5fbd
1,211
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dp/LIBAFS.kt
yx-z
106,589,674
false
null
package dp // given an array of (int, boolean) pair, find the length of longest increasing // back-and-forth subsequence which is defined as // the subsequence is increasing // when boolean == true, find the next element to the right // o/w, find the next element to the left fun main(args: Array<String>) { // ex. len...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,512
AlgoKt
MIT License
src/main/kotlin/binary/NumberOfOccurrences.kt
Pawlllosss
526,668,214
false
{"Kotlin": 61939}
package binary import sorting.QuickSort fun main() { val list = listOf(6, 2, 8, 1, 4, 1, 7, 5, 1, 8, 4, 1, 6, 1) // 5 ones val sortedList = QuickSort().sort(list) val leftBoundary = boundaryBinarySearch(sortedList, 1, true) val rightBoundary = boundaryBinarySearch(sortedList, 1, false) print(rig...
0
Kotlin
0
0
94ad00ca3e3e8ab7a2cb46f8846196ae7c55c8b4
1,358
Kotlin-algorithms
MIT License
src/aoc2017/kot/Day15.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import getWords import java.io.File object Day15 { fun partOne(seedA: Long, seedB: Long): Int { val genA = gen(seedA, 16807) val genB = gen(seedB, 48271) return getCount(genA, genB, 40_000_000) } fun partTwo(seedA: Long, seedB: Long): Int { val genA = gen(seedA, 16807, 4) ...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,472
Advent_of_Code
MIT License
src/main/kotlin/days/y23/Day02.kt
kezz
572,635,766
false
{"Kotlin": 20772}
package days.y23 import util.Day public fun main() { Day02().run() } public class Day02 : Day(23, 2) { private val limits = mapOf( "red" to 12, "green" to 13, "blue" to 14, ) private fun parseInput(input: List<String>) = input .map { string -> string.split(": ") } ...
0
Kotlin
0
0
1cef7fe0f72f77a3a409915baac3c674cc058228
1,686
aoc
Apache License 2.0
src/Day09.kt
MwBoesgaard
572,857,083
false
{"Kotlin": 40623}
import kotlin.math.max import kotlin.math.abs fun main() { class Knot(var posX: Int, var posY: Int, var attachedTo: Knot?) { val setOfPlacesVisited = mutableSetOf(Pair(0, 0)) fun moveInDirection(direction: String) { when (direction) { "U" -> posY += 1 "R...
0
Kotlin
0
0
3bfa51af6e5e2095600bdea74b4b7eba68dc5f83
2,516
advent_of_code_2022
Apache License 2.0
src/test/kotlin/Day19.kt
christof-vollrath
317,635,262
false
null
import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe import java.lang.IllegalArgumentException /* --- Day 19: Monster Messages --- See https://adventofcode.com/2020/day/19 */ fun List<String>.filterMatchingRule(rules: Map<Int, MessageRule>): List<String> { val allValidMessages = genera...
1
Kotlin
0
0
8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8
11,063
advent_of_code_2020
Apache License 2.0
2022/src/main/kotlin/Day07.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day07 { fun part1(input: String): Int { val root = parseCommandHistory(input) val sizes = getDirectorySizes(root) return sizes.values.filter { it <= 1e5 }.sum() } fun part2(input: String): Int { val root = parseCommandHistory(input) val sizes = getDirectorySizes(root) val neededSp...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,804
advent-of-code
MIT License
src/day8/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day8 import java.io.File data class Line(val input:Set<Set<Char>>, val output: List<Set<Char>>) { private val from: Map<Set<Char>, Int> init { val to = mutableMapOf( 1 to input.find { it.size == 2 }!!, 4 to input.find { it.size == 4 }!!, 7 to input.find { it...
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,442
advent-of-code-2021
MIT License
src/aoc2023/Day03.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import readInput import checkValue fun main() { val (year, day) = "2023" to "Day03" val directions = listOf(-1, 0, 1) fun resized(board: List<String>): List<String> { val boardLength = board.first().length + 1 val emptyLine = CharArray(boardLength) { '.' }.joinToString(""...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
3,390
aoc-kotlin
Apache License 2.0
year2018/src/main/kotlin/net/olegg/aoc/year2018/day22/Day22.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2018.day22 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions.Companion.NEXT_4 import net.olegg.aoc.utils.Vector2D import net.olegg.aoc.utils.parseInts import net.olegg.aoc.year2018.DayOf2018 import java.util.PriorityQueue /** * See [Year 2018, Day 22](https://advent...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
2,780
adventofcode
MIT License
src/main/kotlin/aoc23/Day11.kt
tom-power
573,330,992
false
{"Kotlin": 254717, "Shell": 1026}
package aoc23 import aoc23.Day11Domain.Observatory import aoc23.Day11Parser.toObservatory import com.github.shiguruikai.combinatoricskt.combinations import common.Space2D import common.Space2D.Parser.toPointToChars import common.Year23 object Day11 : Year23 { fun List<String>.part1(): Long = toObservatory...
0
Kotlin
0
0
baccc7ff572540fc7d5551eaa59d6a1466a08f56
2,641
aoc
Apache License 2.0
src/main/kotlin/adventofcode2023/day9/day9.kt
dzkoirn
725,682,258
false
{"Kotlin": 133478}
package adventofcode2023.day9 import adventofcode2023.readInput import kotlin.time.measureTime fun main() { println("Day 9") val input = readInput("day9") val puzzle1Time = measureTime { println("Puzzle 1 ${puzzle1(input)}") } println("Puzzle 1 took $puzzle1Time") val puzzle2Time = me...
0
Kotlin
0
0
8f248fcdcd84176ab0875969822b3f2b02d8dea6
1,462
adventofcode2023
MIT License
src/Day03/Day03.kt
JamesKing95
574,470,043
false
{"Kotlin": 7225}
package Day03 import readInput private val ALPHABET_INDEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun main() { val testInput = readInput("Day03/Day03_test") check(part1(testInput) == 157) check(part2(testInput) == 70) val input = readInput("Day03/Day03") println("Part 1: ".plu...
0
Kotlin
0
0
cf7b6bd5ae6e13b83d871dfd6f0a75b6ae8f04cf
2,553
aoc-2022-in-kotlin
Apache License 2.0
day25/src/main/kotlin/Main.kt
rstockbridge
159,586,951
false
null
import java.io.File fun main() { val points = parseInput(readInputFile()) println("The solution is ${solveProblem(points)}.") } fun readInputFile(): List<String> { return File(ClassLoader.getSystemResource("input.txt").file).readLines() } fun parseInput(input: List<String>): List<Coordinate4d> { va...
0
Kotlin
0
0
c404f1c47c9dee266b2330ecae98471e19056549
2,067
AdventOfCode2018
MIT License
src/main/kotlin/days/Day16.kt
hughjdavey
317,575,435
false
null
package days import splitOnBlank class Day16 : Day(16) { private val ticketFields: List<TicketField> private val yourTicket: List<Int> private val nearbyTickets: List<List<Int>> init { val (fields, your, nearby) = if (customInput != null) customInput!!.splitOnBlank() else inputList.splitOnBl...
0
Kotlin
0
1
63c677854083fcce2d7cb30ed012d6acf38f3169
2,642
aoc-2020
Creative Commons Zero v1.0 Universal
lib/src/main/kotlin/com/bloidonia/advent/day19/Day19.kt
timyates
433,372,884
false
{"Kotlin": 48604, "Groovy": 33934}
package com.bloidonia.advent.day19 import java.lang.StrictMath.pow import kotlin.math.sqrt data class Vector(val x: Int, val y: Int, val z: Int) { operator fun plus(other: Vector) = Vector(x + other.x, y + other.y, z + other.z) operator fun times(other: Vector) = Vector(x * other.x, y * other.y, z * other.y) ...
0
Kotlin
0
1
9714e5b2c6a57db1b06e5ee6526eb30d587b94b4
1,252
advent-of-kotlin-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/BurstBalloons.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,587
kotlab
Apache License 2.0
src/main/kotlin/days/Day7.kt
mstar95
317,305,289
false
null
package days class Day7 : Day(7) { override fun partOne(): Any { val bags: Map<String, List<String>> = parse(inputList) .map { it.key to it.value.map { p -> p.first } } .toMap() val bag = bags.keys.map { findBag(bags, it, "shiny gold bag") } return bag.filt...
0
Kotlin
0
0
ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81
2,424
aoc-2020
Creative Commons Zero v1.0 Universal
aoc-2021/src/main/kotlin/nerok/aoc/aoc2021/day05/Day05.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2021.day05 import nerok.aoc.utils.Input import kotlin.math.abs import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { val coordinates = mutableListOf<List<Pair<Int, Int>>>() var size = 0 input.forEach { fileLi...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
6,272
AOC
Apache License 2.0
src/Day17.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
import kotlin.math.max /** * [Day17](https://adventofcode.com/2022/day/17) */ private class Day17 { data class Rock(val array: List<List<Char>>) { val height = array.size val width = array[0].size } companion object { val ROCKS = listOf( Rock(listOf("####".toList()))...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
4,074
aoc-in-kotlin-2022
Apache License 2.0
src/Day02.kt
dustinlewis
572,792,391
false
{"Kotlin": 29162}
fun main() { fun part1(input: List<String>): Int { return input.fold(0) { acc, el -> val (opponentLetter, myLetter) = el.split(" ") acc + calculateMatchScore(opponentLetter, myLetter) } } fun part2(input: List<String>): Int { return input....
0
Kotlin
0
0
c8d1c9f374c2013c49b449f41c7ee60c64ef6cff
2,837
aoc-2022-in-kotlin
Apache License 2.0
src/test/kotlin/aoc2016/day7/IPAddresses.kt
arnab
75,525,311
false
null
package aoc2016.day7 data class IpAddress(val address: String) { fun supportsSsl(): Boolean { println("Testing: $address") val (supernets, hypernets) = partitionSequences(address) println("Supernet sequences: $supernets") println("Hypernet sequences: $hypernets") val abaP...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
3,327
adventofcode
MIT License
src/main/kotlin/se/saidaspen/aoc/aoc2015/Day13.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2015 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.P import se.saidaspen.aoc.util.permutations fun main() = Day13.run() object Day13 : Day(2015, 13) { private val inpMap = input.lines().associate { val split = it.split(" ") val points = if (split[2] ==...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,348
adventofkotlin
MIT License
src/main/kotlin/days/Day21.kt
andilau
399,220,768
false
{"Kotlin": 85768}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2020/day/21", date = Date(day = 21, year = 2020) ) class Day21(lines: List<String>) : Puzzle { private val food = readFood(lines) private val allergens = food.values.flatten().toSet() override fun partOne(): Int...
7
Kotlin
0
0
2809e686cac895482c03e9bbce8aa25821eab100
2,339
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/day2/Solution.kt
chipnesh
572,700,723
false
{"Kotlin": 48016}
package day2 import day2.Result.DRAW import day2.Result.LOOSE import day2.Result.WIN import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { round -> val (f, s) = round.split(" ") Figure.of(s).fightClassic(Figure.of(f)).score } } f...
0
Kotlin
0
1
2d0482102ccc3f0d8ec8e191adffcfe7475874f5
1,973
AoC-2022
Apache License 2.0
src/main/kotlin/day07/day07.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package main.day07 import main.utils.Stack import utils.readFile import utils.separator fun main() { val test = readFile("day07_test") val input = readFile("day07") data class FileInfo(val name: String, val size: Int) class Directory(val name: String) { private val files = mutableMapOf<String, FileInfo>(...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
4,493
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindLongestChain.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,228
kotlab
Apache License 2.0
src/aoc2023/Day1.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2023 import utils.alsoPrintln import utils.checkEquals import utils.checkNotEquals import utils.readInput fun main(): Unit = with(Day1) { part1(testInput.take(4)) .checkEquals(142) part1(input) .alsoPrintln() // .sendAnswer(part = 1, day = "1", year = 2023) part2(testIn...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
2,033
Kotlin-AOC-2023
Apache License 2.0
src/day25/day.kt
LostMekka
574,697,945
false
{"Kotlin": 92218}
package day25 import util.readInput import util.shouldBe fun main() { val testInput = readInput(Input::class, testInput = true).parseInput() testInput.part1() shouldBe "2=-1=0" testInput.part2() shouldBe Unit val input = readInput(Input::class).parseInput() println("output for part1: ${input.part...
0
Kotlin
0
0
58d92387825cf6b3d6b7567a9e6578684963b578
1,600
advent-of-code-2022
Apache License 2.0
src/Day11.kt
jstapels
572,982,488
false
{"Kotlin": 74335}
import java.lang.IllegalArgumentException data class Monkey( val id: Int, val startItems: List<Long>, val operation: (Long) -> Long, val divisor: Int, val trueTo: Int, val falseTo: Int ) { val items = startItems.toMutableList() var inspected = 0 fun throwItems(monkeys: Map<Int, Mon...
0
Kotlin
0
0
0d71521039231c996e2c4e2d410960d34270e876
3,462
aoc22
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SearchSuggestionsSystem.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
4,786
kotlab
Apache License 2.0
src/main/java/challenges/coderbyte/Palindrome.kt
ShabanKamell
342,007,920
false
null
package challenges.coderbyte /** * Have the function PalindromeCreator(str) take the str parameter being passed and * determine if it is possible to create a palindromic string of minimum length 3 * characters by removing 1 or 2 characters. For example: if str is "abjchba" * then you can remove the characters jc t...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
3,275
CodingChallenges
Apache License 2.0
src/main/kotlin/days/Day10.kt
hughjdavey
225,440,374
false
null
package days import kotlin.math.abs import kotlin.math.atan2 class Day10 : Day(10) { private val grid = AsteroidGrid(inputList) override fun partOne(): Any { val bestLocation = grid.bestLocationForMonitoring() val numberDetectable = grid.numberCanDetect(bestLocation.first, bestLocation.secon...
0
Kotlin
0
1
84db818b023668c2bf701cebe7c07f30bc08def0
3,623
aoc-2019
Creative Commons Zero v1.0 Universal
p12/src/main/kotlin/SubterraneanSustainability.kt
jcavanagh
159,918,838
false
null
package p12 import common.file.readLines object Transitions { data class Transition(val match: String, val survives: Boolean) val transitions = loadTransitions() val byStrMatch = transitions.groupBy { it.match }.mapValues { it.value.first() } private fun loadTransitions(): List<Transition> { return read...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
2,585
advent2018
MIT License
src/CommonFun.kt
syncd010
324,790,559
false
null
import java.math.BigInteger import kotlin.math.abs import kotlin.math.pow import kotlin.math.sign /** * Position class with helper functions */ data class Position(var x: Int, var y: Int = 0, var z: Int = 0) { operator fun plus(other: Position): Position = Position(x + other.x, y + other.y, z + other.z) ...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
3,676
AoC2019
Apache License 2.0
src/Day03.kt
benwicks
572,726,620
false
{"Kotlin": 29712}
fun main() { fun Char.toPriority(): Int { return if (code > 90) { code - 96 } else { code - 38 } } fun part1(input: List<String>): Int { var repeatedCharSum = 0 for (line in input) { val numChars = line.length val halfw...
0
Kotlin
0
0
fbec04e056bc0933a906fd1383c191051a17c17b
1,269
aoc-2022-kotlin
Apache License 2.0
src/Day05.kt
drothmaler
572,899,837
false
{"Kotlin": 15196}
import Crate.Companion.chars import Crate.Companion.print import kotlin.time.measureTime var debug = false @JvmInline value class Crate(val char:Char) { override fun toString() = if (char == ' ') " " else "[$char]" companion object { val empty = Crate(' ') val List<Crate>.chars get() = Str...
0
Kotlin
0
0
1fa39ebe3e4a43e87f415acaf20a991c930eae1c
4,301
aoc-2022-in-kotlin
Apache License 2.0
2021/kotlin/src/main/kotlin/com/pietromaggi/aoc2021/day09/Day09.kt
pfmaggi
438,378,048
false
{"Kotlin": 113883, "Zig": 18220, "C": 7779, "Go": 4059, "CMake": 386, "Awk": 184}
/* * 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 wr...
0
Kotlin
0
0
7c4946b6a161fb08a02e10e99055a7168a3a795e
2,879
AdventOfCode
Apache License 2.0
src/test/kotlin/de/tek/adventofcode/y2022/util/math/GraphTest.kt
Thumas
576,671,911
false
{"Kotlin": 192328}
package de.tek.adventofcode.y2022.util.math import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe class GraphTest : StringSpec({ "Given linear graph and its ends as start and end, the shortest path is the whole line." { val graph = Graph(setOf(1 to 2, 2 to 3, 3 to 4, 4 to 5)) ...
0
Kotlin
0
0
551069a21a45690c80c8d96bce3bb095b5982bf0
2,931
advent-of-code-2022
Apache License 2.0
10/part_two.kt
ivanilos
433,620,308
false
{"Kotlin": 97993}
import java.io.File fun readInput() : List<String> { return File("input.txt") .readLines() } class SyntaxChecker { companion object { val OPEN_CHARS = listOf('(', '[', '{', '<') val MATCH = mapOf('(' to ')', '[' to ']', '{' to '}', '<' to '>') ...
0
Kotlin
0
3
a24b6f7e8968e513767dfd7e21b935f9fdfb6d72
1,778
advent-of-code-2021
MIT License
src/main/kotlin/com/groundsfam/advent/y2015/d13/Day13.kt
agrounds
573,140,808
false
{"Kotlin": 281620, "Shell": 742}
package com.groundsfam.advent.y2015.d13 import com.groundsfam.advent.DATAPATH import kotlin.io.path.div import kotlin.io.path.useLines fun maxHappiness(opinions: Array<IntArray>): Int { // happiness - total happiness from seatings so far // prevPerson - most recent seated person // needToSeat - set of pe...
0
Kotlin
0
1
c20e339e887b20ae6c209ab8360f24fb8d38bd2c
1,874
advent-of-code
MIT License
src/Year2022Day04.kt
zhangt2333
575,260,256
false
{"Kotlin": 34993}
fun main() { operator fun IntRange.contains(other: IntRange): Boolean = first <= other.first && other.last <= last fun IntRange.overlap(other: IntRange): Boolean = !(other.last < first || last < other.first) fun part1(input: List<String>): Int { return input.map { val (...
0
Kotlin
0
0
cdba887c4df3a63c224d5a80073bcad12786ac71
872
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2021/Day5.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2021 import net.voldrich.BaseDay import kotlin.math.abs import kotlin.math.max import kotlin.math.min // https://adventofcode.com/2021/day/5 // result 5632 // result 22213 fun main() { Day5().run() } private class Day5 : BaseDay() { override fun task1() : Int { return calcula...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
3,081
advent-of-code
Apache License 2.0
src/Day07.kt
rosyish
573,297,490
false
{"Kotlin": 51693}
class Node(val name: String, val parent: Node?, val isDir: Boolean = false, var size: Int = 0, val children: HashMap<String, Node> = hashMapOf()) val part1MaxVal = 100000 var part1answer = 0 var minDirSize = Int.MAX_VALUE fun fillSizes(current: Node) { if (!current.isDir) return; if (current.children.isEmpty(...
0
Kotlin
0
2
43560f3e6a814bfd52ebadb939594290cd43549f
1,919
aoc-2022
Apache License 2.0
src/main/kotlin/dp/MaxPlusMult.kt
yx-z
106,589,674
false
null
package dp import util.get import util.max import util.min import util.set // similar to MaxPlusMinus // but this time, the input array contains only numbers, +, and * // find the maximum value of expression by adding parenthesis // also with different constraints as the following // 1. all numbers are positive fun ...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
4,089
AlgoKt
MIT License
2022/src/main/kotlin/de/skyrising/aoc2022/day15/solution.kt
skyrising
317,830,992
false
{"Kotlin": 411565}
package de.skyrising.aoc2022.day15 import de.skyrising.aoc.* import kotlin.math.abs private fun parseInput(input: PuzzleInput) = input.lines.map { val (a, b, c, d) = it.ints() Vec2i(a, b) to Vec2i(c, d) } private fun rangesForRow(pairs: List<Pair<Vec2i, Vec2i>>, row: Int) = joinRanges(pairs.mapNotNull { (s, ...
0
Kotlin
0
0
19599c1204f6994226d31bce27d8f01440322f39
2,315
aoc
MIT License
app/src/main/kotlin/kotlinadventofcode/util/Relations.kt
pragmaticpandy
356,481,847
false
{"Kotlin": 1003522, "Shell": 219}
package kotlinadventofcode.util import kotlin.math.pow fun isQuadratic(x: List<Int>, y: List<Int>): Boolean { if (!x.map { it.toDouble() }.isLinear()) error("x values must be linear") if (x.size != y.size) error("x and y must be the same size") if (x.size < 4) error("x and y must have at least 4 values") ...
0
Kotlin
0
3
26ef6b194f3e22783cbbaf1489fc125d9aff9566
1,383
kotlinadventofcode
MIT License
src/y2016/Day11.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2016 import util.readInput object Day11 { fun part1(input: List<String>): Int { val itemsPerFloor = input.map { it.split(" a ").size - 1 } val cumulative = itemsPerFloor.scan(0) { acc, i -> acc + i }.drop(1).dropLast(1) /** * bringing n items up one floor taken 2*n - 3 s...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,495
advent-of-code
Apache License 2.0
src/main/kotlin/adventofcode/year2022/Day08TreetopTreeHouse.kt
pfolta
573,956,675
false
{"Kotlin": 199554, "Dockerfile": 227}
package adventofcode.year2022 import adventofcode.Puzzle import adventofcode.PuzzleInput import adventofcode.common.product import adventofcode.year2022.Day08TreetopTreeHouse.Companion.Direction.DOWN import adventofcode.year2022.Day08TreetopTreeHouse.Companion.Direction.LEFT import adventofcode.year2022.Day08TreetopTr...
0
Kotlin
0
0
72492c6a7d0c939b2388e13ffdcbf12b5a1cb838
2,015
AdventOfCode
MIT License
src/main/kotlin/g0501_0600/s0587_erect_the_fence/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0501_0600.s0587_erect_the_fence // #Hard #Array #Math #Geometry #2023_01_30_Time_470_ms_(100.00%)_Space_54.7_MB_(100.00%) import kotlin.math.abs import kotlin.math.atan2 import kotlin.math.pow import kotlin.math.sqrt class Solution { private fun dist(p1: Pair<Int, Int>, p2: Pair<Int, Int>): Double { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,737
LeetCode-in-Kotlin
MIT License
src/main/kotlin/be/swsb/aoc2021/day6/Day6.kt
Sch3lp
433,542,959
false
{"Kotlin": 90751}
package be.swsb.aoc2021.day6 object Day6 { fun solve1(input: List<Int>, days: Int): Int { return dayCycle(input, days).size } fun solve2(input: List<Int>, days: Int): Long { return dayCyclePart2(input, days) } } fun dayCycle(school: List<Int>, days: Int): List<Int> { return (1..da...
0
Kotlin
0
0
7662b3861ca53214e3e3a77c1af7b7c049f81f44
1,229
Advent-of-Code-2021
MIT License
src/Day16.kt
janbina
112,736,606
false
null
package day16 import getInput import java.util.* import kotlin.test.assertEquals fun main(args: Array<String>) { val input = getInput(16).readLines().first().split(',').map { Instruction.fromString(it) } val programs = CharArray(16) { (it + 'a'.toInt()).toChar() } assertEquals("ociedpjbmfnkhlga", part1(p...
0
Kotlin
0
0
71b34484825e1ec3f1b3174325c16fee33a13a65
2,904
advent-of-code-2017
MIT License
src/Day21.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
import kotlin.math.sign const val MY_MONKEY_NAME = "humn" const val ROOT = "root" enum class Operation(val perform: (Double, Double) -> Double) { DIV(Double::div), MUL(Double::times), MINUS(Double::minus), PLUS(Double::plus); override fun toString(): String { return when (this) { DIV -> " / " MU...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
3,756
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/main/kotlin/d20_TrenchMap/TrenchMap.kt
aormsby
425,644,961
false
{"Kotlin": 68415}
package d20_TrenchMap import util.Coord import util.Input import util.Output fun main() { Output.day(20, "Trench Map") val startTime = Output.startTime() val input = Input.parseLines(filename = "/input/d20_trench_map_input.txt") val algorithm = input[0].map { if (it == '#') '1' else '0' }.joinToStrin...
0
Kotlin
1
1
193d7b47085c3e84a1f24b11177206e82110bfad
2,091
advent-of-code-2021
MIT License
src/Day09.kt
dyomin-ea
572,996,238
false
{"Kotlin": 21309}
import kotlin.math.abs import kotlin.math.sign import kotlin.math.truncate typealias Dot = Pair<Int, Int> fun main() { fun way(input: String): List<Direction> = buildList { val pair = input.splitBy(" ") repeat(pair.second.toInt()) { add(Direction(pair.first)) ...
0
Kotlin
0
0
8aaf3f063ce432207dee5f4ad4e597030cfded6d
3,375
advent-of-code-2022
Apache License 2.0
src/day06/Day06.kt
spyroid
433,555,350
false
null
package day06 import readInput fun main() { fun liveOneDay(map: Map<Int, Long>): Map<Int, Long> { return map .mapKeys { it.key - 1 } .toMutableMap() .also { val m1 = it.getOrDefault(-1, 0) it.merge(6, m1) { a, b -> a + b } ...
0
Kotlin
0
0
939c77c47e6337138a277b5e6e883a7a3a92f5c7
1,163
Advent-of-Code-2021
Apache License 2.0
yandex/y2023/qual/d_wrong.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package yandex.y2023.qual private fun solve() { val (n, m) = readInts() val nei = List(2) { List(n + 1) { mutableListOf<Pair<Int, Int>>() } } repeat(m) { val tokens = readStrings() val a = tokens[0].toInt() - 1 val b = tokens[1].toInt() val greater = (tokens[2][0] == '>').toInt() val value = tokens[3].toI...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,229
competitions
The Unlicense
src/Day01.kt
buongarzoni
572,991,996
false
{"Kotlin": 26251}
fun solveDay01() { val testInput = readInput("Day01_test") val carriedCaloriesPerElve: List<List<String>> = testInput.toCarriedCaloriesPerElve() val caloriesIntakePerElve = carriedCaloriesPerElve.toCaloriesIntakePerElve() val maxCalorieIntake = caloriesIntakePerElve.max() println("Max calorie intak...
0
Kotlin
0
0
96aadef37d79bcd9880dbc540e36984fb0f83ce0
917
AoC-2022
Apache License 2.0
aoc-2023/src/main/kotlin/nerok/aoc/aoc2023/day03/Day03.kt
nerok
572,862,875
false
{"Kotlin": 113337}
package nerok.aoc.aoc2023.day03 import nerok.aoc.utils.Input import nerok.aoc.utils.Point import nerok.aoc.utils.append import nerok.aoc.utils.createCharGrid import kotlin.time.DurationUnit import kotlin.time.measureTime fun main() { fun part1(input: List<String>): Long { val engineSchematic = createCharG...
0
Kotlin
0
0
7553c28ac9053a70706c6af98b954fbdda6fb5d2
3,216
AOC
Apache License 2.0
src/Day21.kt
rod41732
572,917,438
false
{"Kotlin": 85344}
fun main() { fun part1(input: List<String>): Long { val ctx = ExpressionContext() input.forEach { val parts = it.split(" ") val name = parts[0].substring(0, 4) val cur = ctx.get(name) when (parts.size) { 2 -> cur.num = parts[1].toLong(...
0
Kotlin
0
0
1d2d3d00e90b222085e0989d2b19e6164dfdb1ce
4,213
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/com/cbrew/chart/Chart.kt
cbrew
248,690,438
false
{"Kotlin": 147469, "ANTLR": 8870, "Vue": 8502, "HTML": 303, "Dockerfile": 123}
package com.cbrew.chart import com.cbrew.unify.FeatureMap import com.cbrew.unify.FeatureStructure import com.cbrew.unify.subst import com.cbrew.unify.unify import java.util.* import kotlin.Comparator import kotlin.collections.set /** * A chart is a container for edges. It contains two arrays: one for complete edge...
1
Kotlin
0
0
16c4e42911782595e419f38c23796ce34b65f384
8,892
quadruplet
Apache License 2.0
src/Day03.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
private val file = "Day03" private data class RucksackContents(val contents: String) { val firstCompartment: String get() = contents.substring(0, contents.length / 2) val secondCompartment: String get() = contents.substring(contents.length / 2) fun getCommonItemType(): Char { return firstCompartm...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
1,232
aoc-2022
Apache License 2.0
src/Day03.kt
chbirmes
572,675,727
false
{"Kotlin": 32114}
fun main() { fun part1(input: List<String>): Int = input.map { it.charInBothHalves() } .sumOf { it.priority() } fun part2(input: List<String>): Int = input.chunked(3) .map { it.charInEach() } .sumOf { it.priority() } val testInput = readInput("Day03_te...
0
Kotlin
0
0
db82954ee965238e19c9c917d5c278a274975f26
915
aoc-2022
Apache License 2.0
solutions/aockt/y2021/Y2021D11.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import io.github.jadarma.aockt.core.Solution object Y2021D11 : Solution { /** Represents a 10x10 2D map of octopus energy levels, as scanned by the submarine. */ private class OctopusMap(initial: List<Int>) { /** Represents a discrete point in 2D space. */ private data cl...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
2,935
advent-of-code-kotlin-solutions
The Unlicense
src/y2022/day02.kt
sapuglha
573,238,440
false
{"Kotlin": 33695}
package y2022 import readFileAsLines import java.lang.IllegalArgumentException fun main() { fun part1(input: List<String>): Int = input.sumOf { line -> val round = line.split(" ") val theirMove = round.first().toHand() val myMove = round.last().toHand() when (theirMove) { ...
0
Kotlin
0
0
82a96ccc8dcf38ae4974e6726e27ddcc164e4b54
2,810
adventOfCode2022
Apache License 2.0
src/y2015/Day19.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput import util.split import y2015.Day19.analysis import kotlin.math.max typealias Replacements = Map<String, List<String>> typealias Molecule = List<String> object Day19 { private fun parse(input: List<String>): Pair<Replacements, String> { val replacements = input.dropLa...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
7,339
advent-of-code
Apache License 2.0
Kotlin/problems/0008_array_nesting.kt
oxone-999
243,366,951
true
{"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187}
// Proble Statement // // A zero-indexed array A of length N contains all integers from 0 to N-1. // Find and return the longest length of set S, // where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below. // // Suppose the first element in S starts with the selection of element A[i] // of index = i,...
0
null
0
0
52dc527111e7422923a0e25684d8f4837e81a09b
1,664
algorithms
MIT License
src/main/kotlin/Day04.kt
robert-iits
573,124,643
false
{"Kotlin": 21047}
class Day04 { fun part1(input: List<String>): Int { return input.sumOf { sectionPair -> stringToRanges(sectionPair.split(',')) .let { ranges -> countFullOverlap(ranges.first(), ranges.last()) } } } private fun stringToRanges(listOfStrings: List<String>): List<In...
0
Kotlin
0
0
223017895e483a762d8aa2cdde6d597ab9256b2d
1,173
aoc2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinDays.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,351
kotlab
Apache License 2.0
src/day8/Day08.kt
jorgensta
573,824,365
false
{"Kotlin": 31676}
fun asGrid(input: List<String>) = input.map { it .split("") .mapNotNull { s -> s.toIntOrNull() } } fun countPerimeter(grid: List<List<Int>>): Int { val height = grid.size val width = grid.first().size return (height + width) * 2 - 4 // counts the corners four times ;) } fun visibleFrom...
0
Kotlin
0
0
7243e32351a926c3a269f1e37c1689dfaf9484de
3,708
AoC2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem983/Solution2.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem983 /** * LeetCode page: [983. Minimum Cost For Tickets](https://leetcode.com/problems/minimum-cost-for-tickets/); */ class Solution2 { /* Complexity: * Time O(N) and Space O(N) where N is the size of days; */ fun mincostTickets(days: IntArray, costs: IntArray)...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,361
hj-leetcode-kotlin
Apache License 2.0
src/Day01.kt
sbaumeister
572,855,566
false
{"Kotlin": 38905}
fun main() { fun part1(input: List<String>): Int { var maxSumCalories = 0 var sumCalories = 0 input.forEach { if (it == "") { sumCalories = 0 } else { sumCalories += it.toInt() if (sumCalories > maxSumCalories) { ...
0
Kotlin
0
0
e3afbe3f4c2dc9ece1da7cf176ae0f8dce872a84
1,211
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/paulshields/aoc/Day21.kt
Pkshields
433,609,825
false
{"Kotlin": 133840}
/** * Day 21: Dirac Dice */ package dev.paulshields.aoc import dev.paulshields.aoc.common.readFileAsStringList fun main() { println(" ** Day 21: Dirac Dice ** \n") val diracDiceStaringPositionsText = readFileAsStringList("/Day21StartingPositions.txt") val playerOnePosition = diracDiceStaringPositionsT...
0
Kotlin
0
0
e3533f62e164ad72ec18248487fe9e44ab3cbfc2
5,128
AdventOfCode2021
MIT License
src/main/kotlin/dec18/Main.kt
dladukedev
318,188,745
false
null
package dec18 fun <T> List<T>.tail(): List<T> = this.drop(1) const val NESTED_PARENTHESIS_REGEX = "\\(([^()]*|\\([^()]*\\))*\\)" fun solveParenthesis(input: String, sum: (String) -> String): String { val parensRegex = Regex(NESTED_PARENTHESIS_REGEX) val paren = parensRegex.find(input) ?: return sum(input) ...
0
Kotlin
0
0
d4591312ddd1586dec6acecd285ac311db176f45
1,902
advent-of-code-2020
MIT License
src/Day01.kt
tbilou
572,829,933
false
{"Kotlin": 40925}
fun List<String>.split(): List<List<Int>> { val listOfLists = arrayListOf<List<Int>>() var tmp = arrayListOf<Int>() this.forEach { // if we find an empty line, store the current list and create a new one if (it.isBlank()) { listOfLists.add(tmp) tmp = arrayListOf() ...
0
Kotlin
0
0
de480bb94785492a27f020a9e56f9ccf89f648b7
2,045
advent-of-code-2022
Apache License 2.0
src/Day03.kt
Akhunzaada
573,119,655
false
{"Kotlin": 23755}
fun main() { fun Char.getPriority() = code - if (isLowerCase()) 96 else 38 fun part1(input: List<String>): Int { var sum = 0 input.forEach skip@ { val firstCompartment = it.subSequence(0, it.length / 2).toSet() for (i in it.length / 2 until it.length) { i...
0
Kotlin
0
0
b2754454080989d9579ab39782fd1d18552394f0
1,093
advent-of-code-2022
Apache License 2.0
src/Day03.kt
MarkRunWu
573,656,261
false
{"Kotlin": 25971}
import java.lang.Math.abs fun main() { fun getPriority(char: Char): Int { return if (char.code >= 'a'.code) { char.code - 'a'.code } else { char.code - 'A'.code + 26 } + 1 } fun part1(input: List<String>): Int { return input.map { it -> v...
0
Kotlin
0
0
ced885dcd6b32e8d3c89a646dbdcf50b5665ba65
1,127
AOC-2022
Apache License 2.0
src/Day07.kt
kedvinas
572,850,757
false
{"Kotlin": 15366}
fun main() { fun part1(input: List<String>): Int { val files = mutableListOf<File>() var workingDirectory = "" for (i in input) { val split = i.split(" ") if (split[0] == "$") { if (split[1] == "cd") { if (split[2] == "/") { ...
0
Kotlin
0
0
04437e66eef8cf9388fd1aaea3c442dcb02ddb9e
3,085
adventofcode2022
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2020/Day11.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2020 import com.nibado.projects.advent.* import com.nibado.projects.advent.collect.CharMap object Day11 : Day { private val map = resourceString(2020, 11) override fun part1(): Int = solve({ map, p -> map.count(p) == 0 }, { map, p -> map.count(p) >= 4 }) override fun p...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
1,777
adventofcode
MIT License
src/twentytwentytwo/day7/Day07.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentytwo.day7 import readInput class TreeNode(var value: Int, private var name: String) { var parent: TreeNode? = null var children: MutableMap<String, TreeNode> = mutableMapOf() fun addChild(node: TreeNode): TreeNode? { if (!children.containsKey(node.name)) { children...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
4,025
advent-of-code
Apache License 2.0
src/DayFive.kt
P-ter
572,781,029
false
{"Kotlin": 18422}
import java.util.* fun main() { fun partOne(input: List<String>): Int { var total = 0 val stacks = (0 .. 9).map { Stack<String>() } input.take(8).forEach { line -> line.windowed(3, 4).forEachIndexed { index, crate -> if(crate.isNotBlank()) { ...
0
Kotlin
0
1
e28851ee38d6de5600b54fb884ad7199b44e8373
1,945
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/ca/kiaira/advent2023/day3/Day3.kt
kiairatech
728,913,965
false
{"Kotlin": 78110}
package ca.kiaira.advent2023.day3 import ca.kiaira.advent2023.Puzzle /** * Day3 is an implementation of the Puzzle class for Advent of Code 2023, Day 3. * It solves two parts of the puzzle: * - Part 1: Calculate the sum of all part numbers adjacent to certain symbols in an engine schematic. * - Part 2: Calculate ...
0
Kotlin
0
1
27ec8fe5ddef65934ae5577bbc86353d3a52bf89
3,009
kAdvent-2023
Apache License 2.0
src/main/kotlin/day05.kt
tobiasae
434,034,540
false
{"Kotlin": 72901}
class Day05 : Solvable("05") { override fun solveA(input: List<String>): String { val lineCount = HashMap<Pair<Int, Int>, Int>() getLines(input).forEach { it.getVertHorPoints().forEach { lineCount[it] = 1 + (lineCount[it] ?: 0) } } return lineCount.filterValues { it >=...
0
Kotlin
0
0
16233aa7c4820db072f35e7b08213d0bd3a5be69
2,065
AdventOfCode
Creative Commons Zero v1.0 Universal
src/leetcodeProblem/leetcode/editor/en/LargestDivisibleSubset.kt
faniabdullah
382,893,751
false
null
//Given a set of distinct positive integers nums, return the largest subset //answer such that every pair (answer[i], answer[j]) of elements in this subset //satisfies: // // // answer[i] % answer[j] == 0, or // answer[j] % answer[i] == 0 // // // If there are multiple solutions, return any of them. // // // Ex...
0
Kotlin
0
6
ecf14fe132824e944818fda1123f1c7796c30532
2,194
dsa-kotlin
MIT License
codeforces/round621/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round621 fun main() { val (n, m, _) = readInts() val special = readInts().map { it - 1 } val nei = List(n) { mutableListOf<Int>() } repeat(m) { val (u, v) = readInts().map { it - 1 } nei[u].add(v); nei[v].add(u) } val (s, t) = listOf(0, n - 1).map { bfs(nei, it) } val best = special.sorte...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
965
competitions
The Unlicense
src/Day02/Day02.kt
thmsbdr
574,632,643
false
{"Kotlin": 6603}
package Day02 import readInput fun main() { fun part1(input: List<String>): Int { var total = 0 val valueOfMove = mapOf('X' to 1, 'Y' to 2, 'Z' to 3) val whoDoIBeat = mapOf('X' to 'C', 'Y' to 'A', 'Z' to 'B') input.forEach { if (it[0] == it[2] -23) { to...
0
Kotlin
0
0
b9ac3ed8b52a95dcc542f4de79fb24163f3929a4
1,528
AoC-2022
Apache License 2.0
src/day07/Day07.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day07 import readInput fun main() { data class File(val name: String, val ext: String?, val size: Long) data class Dir( val name: String, val files: MutableList<File>, val dirs: MutableList<Dir>, val parentDir: Dir?, var calculatedSize: Long = -1 ) fu...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
5,257
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/NumberOfCombinations.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,840
kotlab
Apache License 2.0