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/bogwalk/batch5/Problem57.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.maths.lcm import dev.bogwalk.util.strings.digitCount import java.math.BigInteger /** * Problem 57: Square Root Convergents * * https://projecteuler.net/problem=57 * * Goal: Given N, in the 1st N expansions of the square root of 2's infinite continued fraction, ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
4,916
project-euler-kotlin
MIT License
src/Day06.kts
Cicirifu
225,414,163
false
null
import java.io.File val input by lazy { File("Day06.txt").readLines(Charsets.UTF_8) } val edges = input.map { line -> val nodes = line.split(")") nodes[1] to nodes[0] }.toMap() fun pathToRoot(node: String) = generateSequence(node) { edges[it] } val orbits = edges.keys.map { pathToRoot(it).count() - 1 }.s...
0
Kotlin
0
0
bbeb2ee39fd13bd57cd6384d0a82f91227e4541f
1,820
AdventOfCode2019
Apache License 2.0
src/Day06.kt
Kvest
573,621,595
false
{"Kotlin": 87988}
fun main() { val testInput = readInput("Day06_test") check(part1(testInput[0]) == 5) check(part1(testInput[1]) == 6) check(part1(testInput[2]) == 10) check(part1(testInput[3]) == 11) check(part2(testInput[0]) == 23) check(part2(testInput[1]) == 23) check(part2(testInput[2]) == 29) c...
0
Kotlin
0
0
6409e65c452edd9dd20145766d1e0ea6f07b569a
1,268
AOC2022
Apache License 2.0
src/day25/Day25.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day25 import readInput import kotlin.math.pow fun main() { val day = 25 val testInput = readInput("day$day/testInput") check(part1(testInput) == "2=-1=0") val input = readInput("day$day/input") println(part1(input)) } fun part1(input: List<String>): String { return convertDigitToSna...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
1,659
advent-of-code-2022
Apache License 2.0
src/main/kotlin/ru/timakden/aoc/year2015/Day14.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2015 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput /** * [Day 14: Reindeer Olympics](https://adventofcode.com/2015/day/14). */ object Day14 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("year2015/Day14...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
2,371
advent-of-code
MIT License
src/questions/BestTimeStockII.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * You are given an integer array prices where `prices[i]` is the price of a given stock on the ith day. * On each day, you may decide to buy and/or sell the stock. * You can only hold at most one share of the sto...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,516
algorithms
MIT License
src/Day04_CampCleanup.kt
raipc
574,467,742
false
{"Kotlin": 9511}
fun main() { checkAndSolve("Day04", 2) { it.count { line -> lineHasIncludingRanges(line) } } checkAndSolve("Day04", 4) { it.count { line -> lineHasOverlappingRanges(line) } } } private fun parseRange(value: String) = value.split('-').let { IntRange(it[0].toInt(), it[1].toInt()) } private fun lineHasIncludingR...
0
Kotlin
0
0
9068c21dc0acb5e1009652b4a074432000540d71
1,025
adventofcode22
Apache License 2.0
src/year2022/Day04.kt
Maetthu24
572,844,320
false
{"Kotlin": 41016}
package year2022 fun main() { fun part1(input: List<String>): Int { return input.count { val parts = it.split(",") val range1 = parts.first().split("-").first().toInt()..parts.first().split("-").last().toInt() val range2 = parts.last().spl...
0
Kotlin
0
1
3b3b2984ab718899fbba591c14c991d76c34f28c
1,516
adventofcode-kotlin
Apache License 2.0
src/Day12.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
import java.util.LinkedList import java.util.Queue fun main() { fun part1(grid: List<String>): Int { data class Cell(val r: Int, val c: Int) { fun neighbors(): List<Cell> = listOf(Cell(r-1, c), Cell(r, c-1), Cell(r+1, c), Cell(r, c+1)) fun elev(): Char { val c = g...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
1,845
AOC-2022
Apache License 2.0
src/Day01.kt
jottinger
573,151,634
false
{"Kotlin": 2022}
data class Elf(val calories: List<Int>) { fun totalCalories(): Int { return calories.sum() } override fun toString(): String { return calories.toString()+" (total: "+totalCalories()+")" } } fun main() { val mode = "actual" fun convertToElves(input: List<String>): List<Elf> { ...
0
Kotlin
0
0
910ec8f0b6f64e4fa27c53189babe12e2e1f030b
1,381
advent202201
Apache License 2.0
src/aoc2017/kot/Day07.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import getWords import java.io.File object Day07 { data class Program(val name: String, val oWeight: Int, val supports: List<String> = listOf(), var weight: Int = oWeight) private fun parse(input: List<String>): List<Program> = input.map { val line = it.getWords() Program(line[0], lin...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,837
Advent_of_Code
MIT License
src/day9/result.kt
davidcurrie
437,645,413
false
{"Kotlin": 37294}
package day9 import java.io.File data class Coord(val x: Int, val y: Int) fun Map<Coord, Int>.neighbours(coord: Coord) = listOf(Pair(-1, 0), Pair(0, -1), Pair(1, 0), Pair(0, 1)) .map { Coord(coord.x + it.first, coord.y + it.second) } .filter { contains(it) } .toSet() fun Map<Coord, Int>....
0
Kotlin
0
0
dd37372420dc4b80066efd7250dd3711bc677f4c
1,210
advent-of-code-2021
MIT License
project/src/problems/SieveOfErotasthenese.kt
informramiz
173,284,942
false
null
package problems /** * https://codility.com/media/train/9-Sieve.pdf * The Sieve of Eratosthenes is a very simple and popular technique for finding all the prime * numbers in the range from 2 to a given number n. The algorithm takes its name from the * process of sieving—in a simple way we remove multiples of conse...
0
Kotlin
0
0
a38862f3c36c17b8cb62ccbdb2e1b0973ae75da4
9,642
codility-challenges-practice
Apache License 2.0
src/Day01.kt
makobernal
573,037,099
false
{"Kotlin": 16467}
fun main() { fun asListOfListOfInts(input: List<String>): List<List<Int>> { val accumlatorList = mutableListOf<MutableList<String>>() accumlatorList.add(mutableListOf()) var currentIndex = 0 input.forEach { if (it == "") { currentIndex++ ac...
0
Kotlin
0
0
63841809f7932901e97465b2dcceb7cec10773b9
1,260
kotlin-advent-of-code-2022
Apache License 2.0
src/Day05.kt
Tiebe
579,377,778
false
{"Kotlin": 17146}
fun main() { fun List<String>.mapToCrateList(): List<MutableList<Char>> { val crates = mutableListOf<MutableList<Char>>() repeat((this[0].length+1) / 4) { crates.add(mutableListOf()) } this.subList(0, this.indexOf("")-1).forEach { it.forEachIndexed { index, ...
1
Kotlin
0
0
afe9ac46b38e45bd400e66d6afd4314f435793b3
2,408
advent-of-code
Apache License 2.0
src/day11/Day11.kt
jacobprudhomme
573,057,457
false
{"Kotlin": 29699}
import java.io.File import java.lang.IllegalArgumentException import java.math.BigInteger import java.util.PriorityQueue class Monkey( val heldItems: MutableList<Int>, val applyOperation: (Int) -> BigInteger, val decide: (Int) -> Int ) { var inspectedItems: BigInteger = BigInteger.ZERO fun inspect...
0
Kotlin
0
1
9c2b080aea8b069d2796d58bcfc90ce4651c215b
4,479
advent-of-code-2022
Apache License 2.0
src/Day04.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
fun main() { fun String.toSectionRanges(): Pair<IntRange, IntRange> { val ranges = this.split(",") val firstRangeArray = ranges.first().split("-") val lastRangeArray = ranges.last().split("-") val firstRange = IntRange(firstRangeArray.first().toInt(), firstRangeArray.last().toInt())...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
1,399
AdventOfCode2022
Apache License 2.0
day01/kotlin/RJPlog/day2301_1_2.kt
mr-kaffee
720,687,812
false
{"Rust": 223627, "Kotlin": 46100, "Python": 39390, "Shell": 3369, "Haskell": 3122, "Dockerfile": 2236, "Gnuplot": 1678, "C++": 980, "HTML": 592, "CMake": 314}
import java.io.File fun trebuchet(in1: Int): Int { var conMap = mutableMapOf("0" to 1, "1" to 1, "2" to 2, "3" to 3, "4" to 4, "5" to 5, "6" to 6, "7" to 7, "8" to 8, "9" to 9) var pattern = """\d""".toRegex() if (in1 == 2) { var conMap2 =...
0
Rust
2
0
5cbd13d6bdcb2c8439879818a33867a99d58b02f
2,144
aoc-2023
MIT License
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day08.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.shared.* class Day08 : Solution() { override fun solvePart1(input: String): Any { val grid: Grid<Tree> = input.parseGrid { Tree(it.parseInt()) } val visibleTrees: Set<Grid.Cell<Tree>> = SimpleDirection.values() .flatMap { d...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
2,024
advent-of-code-2022
MIT License
src/main/kotlin/aoc2022/Day09.kt
w8mr
572,700,604
false
{"Kotlin": 140954}
package aoc2022 import aoc.* import aoc.parser.* import kotlin.math.absoluteValue import kotlin.math.sign class Day09 { enum class Dir(val text: String) { UP("U"), DOWN("D"), LEFT("L"), RIGHT("R") } data class Move(val dir: Dir, val count: Int) val dir = byEnum(Dir::c...
0
Kotlin
0
0
e9bd07770ccf8949f718a02db8d09daf5804273d
1,886
aoc-kotlin
Apache License 2.0
src/Day03.kt
chrisjwirth
573,098,264
false
{"Kotlin": 28380}
fun main() { fun sharedItem(firstCompartment: CharSequence, secondComponent: CharSequence): Char { return firstCompartment.first { it in secondComponent } } fun sharedItem(first: CharSequence, second: CharSequence, third: CharSequence): Char { return first.first { it in second && it in thir...
0
Kotlin
0
0
d8b1f2a0d0f579dd23fa1dc1f7b156f728152c2d
1,501
AdventOfCode2022
Apache License 2.0
src/Day04.kt
esp-er
573,196,902
false
{"Kotlin": 29675}
package patriker.day04 import patriker.utils.* fun main() { val testInput = readInput("Day04_test") val input = readInput("Day04_input") check(solvePart1(testInput) == 2) println(solvePart1(input)) println(solvePart2(input)) } fun solvePart1(input: List<String>): Int{ return input.count{ el...
0
Kotlin
0
0
f46d09934c33d6e5bbbe27faaf2cdf14c2ba0362
1,072
aoc2022
Apache License 2.0
src/main/kotlin/Day23.kt
N-Silbernagel
573,145,327
false
{"Kotlin": 118156}
import java.util.* import kotlin.collections.ArrayList fun main() { val input = readFileAsList("Day23") println(Day23.part1(input)) println(Day23.part2(input)) } object Day23 { private val directions: List<Direction> = listOf(Direction.N, Direction.S, Direction.W, Direction.E) fun part1(input: Li...
0
Kotlin
0
0
b0d61ba950a4278a69ac1751d33bdc1263233d81
3,995
advent-of-code-2022
Apache License 2.0
src/aoc2023/Day15.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2023 import checkValue import readInputText fun main() { val (year, day) = "2023" to "Day15" fun String.toSequence() = replace("\n", "").split(",") fun String.hash() = fold(0) { hash, ch -> ((hash + ch.code) * 17) % 256 } fun part1(input: String) = input.toSequence().sumOf { ...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,873
aoc-kotlin
Apache License 2.0
y2023/src/main/kotlin/adventofcode/y2023/Day04.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2023 import adventofcode.io.AdventSolution fun main() { Day04.solve() } object Day04 : AdventSolution(2023, 4, "Scratch Cards") { override fun solvePartOne(input: String) = parse(input).sumOf(Scratchcard::score) override fun solvePartTwo(input: String): Int { val cards = ...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,178
advent-of-code
MIT License
src/Day03.kt
zdenekobornik
572,882,216
false
null
fun main() { fun part1(input: List<String>): Int { return input.sumOf { val (left, right) = it.chunked(it.length / 2) val char = left.first { right.contains(it) } if (char in 'a' .. 'z') { char.code - 96 } else { char.code - 3...
0
Kotlin
0
0
f73e4a32802fa43b90c9d687d3c3247bf089e0e5
1,135
advent-of-code-2022
Apache License 2.0
src/main/kotlin/de/nosswald/aoc/days/Day15.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day // https://adventofcode.com/2023/day/15 object Day15 : Day<Int>(15, "Lens Library") { private fun appendix1A(str: String): Int { return str .map(Char::code) .fold(0) { acc, next -> (acc + next) * 17 % 256 } } override...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
1,747
advent-of-code-2023
MIT License
2021/08/main.kt
chylex
433,239,393
false
null
import Position.BOTTOM import Position.BOTTOM_LEFT import Position.BOTTOM_RIGHT import Position.MIDDLE import Position.TOP import Position.TOP_LEFT import Position.TOP_RIGHT import java.io.File import java.util.EnumSet fun main() { val records = File("input.txt").readLines().map { line -> line.split(" | ", limit = ...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
4,801
Advent-of-Code
The Unlicense
src/Day04.kt
touchman
574,559,057
false
{"Kotlin": 16512}
fun main() { val input = readInput("Day04") fun part1(input: List<String>) = input.map { it.split(",").let { it[0] to it[1] }.let { val firstSplit = it.first.split("-").map(String::toInt) val secondSplit = it.second.split("-").map...
0
Kotlin
0
0
4f7402063a4a7651884be77bb9e97828a31459a7
1,580
advent-of-code-2022
Apache License 2.0
src/Day13.kt
Tomcat88
572,566,485
false
{"Kotlin": 52372}
import java.util.Stack object Day13 { fun part1(input: List<List<Item>>) { input.mapIndexed { i, l -> val (first, second) = l first.compareTo(second).takeIf { it == -1 }?.let { i + 1 } }.filterNotNull().sum().log("part1") } fun part2(input: List<List<Item>>) { ...
0
Kotlin
0
0
6d95882887128c322d46cbf975b283e4a985f74f
3,796
advent-of-code-2022
Apache License 2.0
src/main/kotlin/executeNameCmds.kt
sam-hoodie
534,831,633
false
{"Kotlin": 43732}
fun main() { val data = parseCongressFile(true) interpretNameCommand("-get congress.serving.names.shortest.frist", data) } fun interpretNameCommand(command: String, data: List<Person>) { // -get congress.names.shortest.first // -get congress.names.shortest.last // -get congress.names.longest.first ...
0
Kotlin
0
0
9efea9f9eec55c1e61ac1cb11d3e3460f825994b
2,452
congress-challenge
Apache License 2.0
kotlin/1466-reorder-routes-to-make-all-paths-lead-to-the-city-zero.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}
/* * DFS Solution */ class Solution { fun minReorder(n: Int, connections: Array<IntArray>): Int { val neighbors = ArrayList<ArrayList<Int>>().apply { for (i in 0 until n) this.add(ArrayList<Int>()) for ((u,v) in connections) { this.get(u).apply { this...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
2,058
leetcode
MIT License
src/main/kotlin/days/Day4.kt
hughjdavey
725,972,063
false
{"Kotlin": 76988}
package days class Day4 : Day(4) { private val cards = inputList.map(this::parseCard) override fun partOne(): Any { return cards.sumOf { it.getPoints() } } override fun partTwo(): Any { var cardCount = 0 val cachedWins = cards.associate { it.id to it.getCardWins() } v...
0
Kotlin
0
0
330f13d57ef8108f5c605f54b23d04621ed2b3de
1,513
aoc-2023
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day3.kt
maldoinc
726,264,110
false
{"Kotlin": 14472}
import kotlin.io.path.Path import kotlin.io.path.readLines /** * For part 1, find numbers and for every digit added to the number * check if there was an adjacent symbol, * when done keep or discard depending on if a symbol was found. */ fun getPart1Nums(input: List<String>): List<Int> { val res: List<Int> = m...
0
Kotlin
0
1
47a1ab8185eb6cf16bc012f20af28a4a3fef2f47
3,264
advent-2023
MIT License
src/main/kotlin/pl/bizarre/day5_2.kt
gosak
572,644,357
false
{"Kotlin": 26456}
package pl.bizarre import pl.bizarre.common.loadInput fun main() { val input = loadInput(5) println("result ${day5_2(input)}") } fun day5_2(input: List<String>): String { val piles = input.numberOfPiles() val storage = input.take(piles).map { line -> line.findCrates(piles) }.fold((0 until...
0
Kotlin
0
0
aaabc56532c4a5b12a9ce23d54c76a2316b933a6
2,148
adventofcode2022
Apache License 2.0
src/Day12.kt
syncd010
324,790,559
false
null
import kotlin.math.abs class Day12: Day { private fun convert(input: List<String>) : List<Position> { val regexp = """<x=([+-]?\d+), y=([+-]?\d+), z=([+-]?\d+)>""".toRegex() return input.map { val m = regexp.find(it)!! return@map Position(m.groupValues[1].toInt(), m.groupVa...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
3,786
AoC2019
Apache License 2.0
src/Day08.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
fun main() { fun part1(input: List<String>): Int { var n = input.size; var m = input[0].length; var set = mutableSetOf<Pair<Int, Int>>(); for (i in 0 until n) { var lst = -1; for (j in 0 until m) { var h = input[i][j].code - '0'.code; ...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
2,399
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/SuccessfulPairs.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,276
kotlab
Apache License 2.0
src/Day02.kt
MisterTeatime
561,848,263
false
{"Kotlin": 20300}
fun main() { fun part1(input: List<String>): Int { return input.fold(0) { total, gift -> val (length, width, height) = gift.split("x").map { it.toInt() } val side1 = length * width val side2 = width * height val side3 = height * length total + 2 ...
0
Kotlin
0
0
d684bd252a9c6e93106bdd8b6f95a45c9924aed6
912
AoC2015
Apache License 2.0
src/day03/Solution.kt
abhabongse
576,594,038
false
{"Kotlin": 63915}
/* Solution to Day 3: Rucksack Reorganization * https://adventofcode.com/2022/day/3 */ package day03 import java.io.File fun main() { val fileName = // "day03_sample.txt" "day03_input.txt" val rucksacks = readInput(fileName) // Part 1: sum of priorities for item types // that appear ...
0
Kotlin
0
0
8a0aaa3b3c8974f7dab1e0ad4874cd3c38fe12eb
1,276
aoc2022-kotlin
Apache License 2.0
src/main/kotlin/aoc2018/FourDimensionalAdventure.kt
komu
113,825,414
false
{"Kotlin": 395919}
package komu.adventofcode.aoc2018 import komu.adventofcode.utils.nonEmptyLines import kotlin.math.abs fun fourDimensionalAdventure1(input: String): Int { val stars = input.nonEmptyLines().map { Point4.parse(it) } val constellations = stars.map { Constellation(listOf(it)) }.toMutableList() do { va...
0
Kotlin
0
0
8e135f80d65d15dbbee5d2749cccbe098a1bc5d8
1,761
advent-of-code
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2015/Dec15.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2015 import org.elwaxoro.advent.PuzzleDayTester import org.elwaxoro.advent.merge import org.elwaxoro.advent.plusNull class Dec15 : PuzzleDayTester(15, 2015) { override fun part1(): Any = expandScoops(100L, mapOf(), parse(), null) ?: -1 override fun part2(): Any = expandScoops(10...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
2,068
advent-of-code
MIT License
src/Day02.kt
uberbinge
572,972,800
false
{"Kotlin": 7404}
fun main() { firstProblem() secondProblem() } fun firstProblem() { val input = readLines("Day02") var sum = 0 val newInput = input.asSequence().map { it.replace("A", "rock") }.map { it.replace("B", "paper") }.map { it -> it.replace("C", "scissors") }.map { it.replace("X", "rock") }.map ...
0
Kotlin
0
0
ef57861156ac4c1a097fabe03322edcfa4d2d714
3,495
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/adventofcode/util/graph/Graphs.kt
jwcarman
731,408,177
false
{"Kotlin": 183494}
/* * Copyright (c) 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
0
Kotlin
0
0
dfb226e92a03323ad48c50d7e970d2a745b479bb
3,703
adventofcode2023
Apache License 2.0
src/main/kotlin/currentLegislatorsCmds.kt
sam-hoodie
534,831,633
false
{"Kotlin": 43732}
import kotlin.collections.HashMap fun interpretCurrentCommands(command: String, data: List<Person>) { val cmdParts = command.split(' ')[1].split('.') val stateToFind = stateToAbbreviation(cmdParts[3].lowercase()) var legislators = getLegislators(data, stateToFind, command) if (legislators.isNotEmpty()) ...
0
Kotlin
0
0
9efea9f9eec55c1e61ac1cb11d3e3460f825994b
5,148
congress-challenge
Apache License 2.0
src/shreckye/coursera/algorithms/Course 1 Programming Assignment #2.kts
ShreckYe
205,871,625
false
{"Kotlin": 72136}
package shreckye.coursera.algorithms import java.io.File import kotlin.test.assertEquals val filename = args[0] val integers = File(filename).useLines { it.map(String::toInt).toIntArray(100_000) } fun mergeSortAndCountNumInversions( integers: IntArray, left: Int = 0, right: Int = integers.size ): Pair<IntArr...
0
Kotlin
1
2
1746af789d016a26f3442f9bf47dc5ab10f49611
1,965
coursera-stanford-algorithms-solutions-kotlin
MIT License
src/Day03.kt
6234456
572,616,769
false
{"Kotlin": 39979}
fun main() { val judge: (Char)->Int = { if (it in 'a'..'z') { it - 'a' + 1 } else{ it - 'A' + 27 } } fun part1(input: List<String>): Int { return input.map { val a = it.trim().toCharArray() val l = a.size / 2 val m = m...
0
Kotlin
0
0
b6d683e0900ab2136537089e2392b96905652c4e
1,530
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/kickstart/nov22/Electricity.ws.kts
sjaindl
384,471,324
false
null
var line = 0 var args: Array<String> = arrayOf() fun readLine(): String? { val result = args[line] line++ return result } // https://codingcompetitions.withgoogle.com/kickstart/round/00000000008cb1b6/0000000000c47c8e#problem // O(E + V) time, O(E + V) space (graph) fun main(mainArgs: Array<String>) { ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,938
KotlinAlgs
MIT License
aoc-2023/src/main/kotlin/aoc/aoc17.kts
triathematician
576,590,518
false
{"Kotlin": 615974}
import aoc.AocParser.Companion.parselines import aoc.* import aoc.util.* val testInput = """ 2413432311323 3215453535623 3255245654254 3446585845452 4546657867536 1438598798454 4457876987766 3637877979653 4654967986887 4564679986453 1224686865563 2546548887735 4322674655533 """.parselines fun List<String>.parse() = m...
0
Kotlin
0
0
7b1b1542c4bdcd4329289c06763ce50db7a75a2d
11,073
advent-of-code
Apache License 2.0
solutions/qualifications/moons-and-umbrellas/src/main/kotlin/solutions.moons.and.umbrellas/MoonsAndUmbrellasSolution.kt
Lysoun
351,224,145
false
null
import kotlin.math.min fun main(args: Array<String>) { val casesNumber = readLine()!!.toInt() for (i in 1..casesNumber) { // Ignore first line of case val inputLine = readLine()!!.split(" ") println("Case #$i: ${computeMuralCost(ProblemInput( inputLine[0].toInt(), ...
0
Kotlin
0
0
98d39fcab3c8898bfdc2c6875006edcf759feddd
1,571
google-code-jam-2021
MIT License
src/Day09.kt
Fenfax
573,898,130
false
{"Kotlin": 30582}
import java.awt.Point import kotlin.math.sign fun main() { fun solve(input: List<Pair<Direction, Int>>, pointCount: Int): Int { val points = (0 until pointCount).map { Point() } val tailPointsVisited = mutableSetOf(Point()) for (command in input) { for (unused in (1..command.s...
0
Kotlin
0
0
28af8fc212c802c35264021ff25005c704c45699
1,468
AdventOfCode2022
Apache License 2.0
2022/src/day09/day09.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day09 import GREEN import RESET import printTimeMillis import readInput import kotlin.math.abs data class Point(var x: Int, var y: Int) { private fun right() { x += 1 } private fun left() { x-= 1 } private fun up() { y -= 1 } private fun down() { y += 1 } fun executeInstruction(inst: Strin...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
2,302
advent-of-code
Apache License 2.0
kotlin/2359-find-closest-node-to-given-two-nodes.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}
// bfs class Solution { fun closestMeetingNode(edges: IntArray, node1: Int, node2: Int): Int { val adj = HashMap<Int, MutableList<Int>>().apply { for ((u, v) in edges.withIndex()) { this[u] = getOrDefault(u, mutableListOf<Int>()).apply { add(v) } } } ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
3,681
leetcode
MIT License
ceria/12/src/main/kotlin/Solution.kt
VisionistInc
317,503,410
false
null
import java.io.File import kotlin.math.roundToInt 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 { var currPos = Pair<Int, Int>(0, 0) ...
0
Rust
0
0
002734670384aa02ca122086035f45dfb2ea9949
3,929
advent-of-code-2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FindAnagrams.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,623
kotlab
Apache License 2.0
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day12.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year18 import com.grappenmaker.aoc.PuzzleSet import com.grappenmaker.aoc.nth fun PuzzleSet.day12() = puzzle(day = 12) { fun String.parse() = map { it == '#' }.withIndex().filter { it.value }.map { it.index } val (initPart, rulesPart) = input.split("\n\n") val initial = initPa...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
1,455
advent-of-code
The Unlicense
src/main/java/challenges/cracking_coding_interview/bit_manipulation/flip_bit_to_win/QuestionC.kt
ShabanKamell
342,007,920
false
null
package challenges.cracking_coding_interview.bit_manipulation.flip_bit_to_win import kotlin.math.max /** * You have an integer, and you can flip exactly one bit from a 0 to a 1. * Write code to find the length of the longest sequence of ls you could create. * EXAMPLE * Input: 1775 (or: 11011101111) Output: 8 *...
0
Kotlin
0
0
ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70
2,203
CodingChallenges
Apache License 2.0
src/main/kotlin/day21.kt
gautemo
433,582,833
false
{"Kotlin": 91784}
import shared.getText class Dirac(private val startPlayer1: Int, private val startPlayer2: Int, private val dice: Dice){ private val cache = mutableMapOf<DiracState, Wins>() private fun playerTurn(state: DiracState, steps: Int){ val currentPlayer = if(state.player1Turn) state.player1 else state.player...
0
Kotlin
0
0
c50d872601ba52474fcf9451a78e3e1bcfa476f7
3,870
AdventOfCode2021
MIT License
src/Day03.kt
Kietyo
573,293,671
false
{"Kotlin": 147083}
fun Char.toPriority(): Int { if (this in 'a'..'z') { return this.code - 96 } else if (this in 'A'..'Z') { return this.code - 65 + 27 } TODO() } fun main() { fun part1(input: List<String>): Unit { var sum = 0 input.forEach {line -> val halfSize = line.len...
0
Kotlin
0
0
dd5deef8fa48011aeb3834efec9a0a1826328f2e
1,396
advent-of-code-2022-kietyo
Apache License 2.0
src/main/day1/Day01.kt
Derek52
572,850,008
false
{"Kotlin": 22102}
package main.day1 import main.readInput fun main() { val input = readInput("day1/day1_part1") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { var highestCalorieCount = 0 var currentCalorieCount = 0 for (line in input) { if (line == "") { ...
0
Kotlin
0
0
c11d16f34589117f290e2b9e85f307665952ea76
1,671
2022AdventOfCodeKotlin
Apache License 2.0
src/main/kotlin/sschr15/aocsolutions/Day21.kt
sschr15
317,887,086
false
{"Kotlin": 184127, "TeX": 2614, "Python": 446}
package sschr15.aocsolutions import sschr15.aocsolutions.util.* /** * AOC 2023 [Day 21](https://adventofcode.com/2023/day/21) * Challenge: The farmer elf needs to figure out where is traversable in their infinitely large field... */ object Day21 : Challenge { @ReflectivelyUsed override fun solve() = challe...
0
Kotlin
0
0
e483b02037ae5f025fc34367cb477fabe54a6578
3,686
advent-of-code
MIT License
src/Day11.kt
SnyderConsulting
573,040,913
false
{"Kotlin": 46459}
fun main() { fun part1(input: List<String>): Int { val monkeyConfigs = mutableListOf<MutableList<String>>() input.forEach { line -> if (line.startsWith("Monkey")) { monkeyConfigs.add(mutableListOf()) } else if (line.isNotBlank()) { monkeyConfi...
0
Kotlin
0
0
ee8806b1b4916fe0b3d576b37269c7e76712a921
3,579
Advent-Of-Code-2022
Apache License 2.0
calendar/day11/Day11.kt
maartenh
572,433,648
false
{"Kotlin": 50914}
package day11 import Day import Lines class Day11 : Day() { override fun part1(input: Lines): Any { val monkeys = createMonkeys() val worryMod = monkeys.values.map { it.testDivisibleBy }.fold(1L) { acc, b -> acc * b } (1..20).forEach { round -> monkeys.keys.sorted().forEach {...
0
Kotlin
0
0
4297aa0d7addcdc9077f86ad572f72d8e1f90fe8
3,831
advent-of-code-2022
Apache License 2.0
src/Day05.kt
revseev
573,354,544
false
{"Kotlin": 9868}
fun main() { day05task1() day05task2() } fun day05task1() { var first = true var stacks: List<ArrayDeque<Char>>? = null readInputAsSequenceGrouped("Day05") { forEach { lines -> if (first) { stacks = parseStacks(lines.toList()) first = false ...
0
Kotlin
0
0
df2e12287a30a3a7bd5a026a963bcac41a730232
2,721
advent-of-code-kotlin-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinimumFallingPathSum3.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,124
kotlab
Apache License 2.0
src/Day15.kt
MickyOR
578,726,798
false
{"Kotlin": 98785}
import kotlin.math.abs fun main() { fun part1(input: List<String>): Int { var sensors = mutableListOf<Pair<Pair<Int,Int>,Int>>() var beacons = mutableSetOf<Pair<Int,Int>>() for (line in input) { if (line.isEmpty()) continue var vs = line.split(" ").map { if (it.last(...
0
Kotlin
0
0
c24e763a1adaf0a35ed2fad8ccc4c315259827f0
4,927
advent-of-code-2022-kotlin
Apache License 2.0
src/Day05.kt
carloxavier
574,841,315
false
{"Kotlin": 14082}
fun main() { // test if implementation meets criteria from the description sample: val testInput = readInput("Day05_test") check(day5(testInput) == "CMZ") val input = readInput("Day05") // Part 1 check(day5(input) == "LJSVLTWQM") // Part 2 check(day5(input, shouldReverse = false) == "...
0
Kotlin
0
0
4e84433fe866ce1a8c073a7a1e352595f3ea8372
2,336
adventOfCode2022
Apache License 2.0
2019/src/main/kotlin/com/github/jrhenderson1988/adventofcode2019/day24/BugUniverse.kt
jrhenderson1988
289,786,400
false
{"Kotlin": 216891, "Java": 166355, "Go": 158613, "Rust": 124111, "Scala": 113820, "Elixir": 112109, "Python": 91752, "Shell": 37}
package com.github.jrhenderson1988.adventofcode2019.day24 import com.github.jrhenderson1988.adventofcode2019.common.Direction class BugUniverse(grid: Map<Pair<Int, Int>, Char>) { private val universe = mapOf(0 to grid) private val maxY = grid.keys.map { it.second }.max()!! private val maxX = grid.keys.map...
0
Kotlin
0
0
7b56f99deccc3790c6c15a6fe98a57892bff9e51
4,098
advent-of-code
Apache License 2.0
src/day24/Day24.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day24 import readInput enum class Direction(private val offset: Pair<Int, Int>) { UP(-1 to 0), DOWN(1 to 0), LEFT(0 to -1), RIGHT(0 to 1); fun transform(pos: Pair<Int, Int>) = Pair(pos.first + offset.first, pos.second + offset.second) companion object { fun fromChar(c: Char) = when (c) {...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
3,990
advent-of-code-2022
Apache License 2.0
src/aoc23/Day05.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day05 import kotlin.math.max import kotlin.math.min import lib.Collections.headTail import lib.Solution import lib.Strings.extractLongs import lib.Strings.longs enum class Category { SEED, SOIL, FERTILIZER, WATER, LIGHT, TEMPERATURE, HUMIDITY, LOCATION; c...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
4,535
aoc-kotlin
Apache License 2.0
year2021/src/main/kotlin/net/olegg/aoc/year2021/day3/Day3.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2021.day3 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.year2021.DayOf2021 /** * See [Year 2021, Day 3](https://adventofcode.com/2021/day/3) */ object Day3 : DayOf2021(3) { override fun first(): Any? { val length = lines.first().length val counts = lines .map { ...
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,482
adventofcode
MIT License
src/main/kotlin/leetcode/kotlin/binarysearch/33. Search in Rotated Sorted Array.kt
sandeep549
251,593,168
false
null
package leetcode.kotlin.binarysearch private fun search(nums: IntArray, target: Int): Int { if (nums.isEmpty()) return -1 // find smallest element, use it's index as rotation count var l = 0 var r = nums.lastIndex var mid = 0 while (l < r) { mid = l + (r - l) / 2 if (nums[mid] ...
0
Kotlin
0
0
9cf6b013e21d0874ec9a6ffed4ae47d71b0b6c7b
1,314
kotlinmaster
Apache License 2.0
src/main/arrays/SpecialNumbers.kt
dremme
162,006,465
false
{"Kotlin": 24254}
package arrays /** * Finds the minimum and maximum values. Elements can be any integer. * * @return a tuple of `(min, max)` or `null` if the array is empty. */ fun IntArray.findMinMaxNumbers(): Pair<Int, Int>? { if (isEmpty()) return null var min = Int.MAX_VALUE var max = Int.MIN_VALUE forEach { ...
0
Kotlin
0
0
1bdd6639502e3a5317a76bb5c0c116f04123f047
1,357
coding-kotlin
MIT License
src/Day05.kt
Lonexera
573,177,106
false
null
fun main() { fun String.getAllNumbers(): List<Int> { val decimals = "1234567890" return map { if (it in decimals) it else " " } .joinToString("") .split(" ") .filter { it.isNotBlank() } .map { it.toInt() } } ...
0
Kotlin
0
0
c06d394cd98818ec66ba9c0311c815f620fafccb
2,289
kotlin-advent-of-code-2022
Apache License 2.0
src/Day07.kt
Misano9699
572,108,457
false
null
const val TOTAL_DISKSPACE = 70000000 const val FREE_DISKSPACE_NEEDED = 30000000 fun main() { var root = Dir("/") var currentDirectory: Dir = root var directoriesWithSizes = mutableListOf<Pair<String, Int>>() fun reset() { root = Dir("/") currentDirectory = root directoriesW...
0
Kotlin
0
0
adb8c5e5098fde01a4438eb2a437840922fb8ae6
4,328
advent-of-code-2022
Apache License 2.0
ceria/14/src/main/kotlin/Solution.kt
VisionistInc
433,099,870
false
{"Kotlin": 91599, "Go": 87605, "Ruby": 65600, "Python": 21104}
import java.io.File; import java.util.Stack; fun main(args : Array<String>) { val input = File(args.first()).readLines() var startPoly = input.first() var polymers = mutableMapOf<String, String>() for ( p in 2..input.size - 1) { val poly = input.get(p).split(" -> ") polymers.put(pol...
0
Kotlin
4
1
e22a1d45c38417868f05e0501bacd1cad717a016
5,346
advent-of-code-2021
MIT License
src/main/kotlin/com/jacobhyphenated/advent2023/day3/Day3.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day3 import com.jacobhyphenated.advent2023.Day import com.jacobhyphenated.advent2023.product /** * Day 3: Gear Ratios * * A 2d array contains numbers, periods, and symbols. * Continuous numbers for a single integer, periods are empty spaces. * * A Part number is any number...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
5,301
advent2023
The Unlicense
src/main/kotlin/days/aoc2020/Day19.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2020 import days.Day class Day19 : Day(2020, 19) { override fun partOne(): Any { val ruleMap = createRuleMap(inputList) val regexString = generateRegex(ruleMap["0"] ?: error("no rule 0"), ruleMap) val regex = Regex(regexString) return inputList.subList(inputList.in...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,783
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/Day03.kt
wlghdu97
573,333,153
false
{"Kotlin": 50633}
fun main() { fun priority(compartment: Char): Int { return when (compartment) { in ('a'..'z') -> compartment.code - 96 in ('A'..'Z') -> compartment.code - 38 else -> throw IllegalArgumentException() } } fun part1(input: List<String>): Int { return...
0
Kotlin
0
0
2b95aaaa9075986fa5023d1bf0331db23cf2822b
953
aoc-2022
Apache License 2.0
2016/main/day_20/Main.kt
Bluesy1
572,214,020
false
{"Rust": 280861, "Kotlin": 94178, "Shell": 996}
package day_20_2016 import java.io.File fun part1(input: List<UIntRange>) { var inputs = input.sortedBy { it.first } var index: UInt = 0u while (index < inputs.maxBy { it.last }.last) { index = inputs[0].last + 1u inputs = inputs.filter { it.last > index } if (index < inputs[0].fir...
0
Rust
0
0
537497bdb2fc0c75f7281186abe52985b600cbfb
1,556
AdventofCode
MIT License
src/year2021/day02/Day02.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2021.day02 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { fun part1(input: List<String>): Int { fun sumNumbersByPrefix(input: List<String>, prefix: String): Int = input.filter { it.startsWith(prefix) } .map { it.split(" ")[1] } .map { it....
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,304
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/g0701_0800/s0741_cherry_pickup/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0701_0800.s0741_cherry_pickup // #Hard #Array #Dynamic_Programming #Matrix // #2023_03_03_Time_196_ms_(100.00%)_Space_37.3_MB_(100.00%) class Solution { fun cherryPickup(grid: Array<IntArray>): Int { val dp = Array(grid.size) { Array(grid.size) { IntArray( ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,474
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/github/aoc/AOCD4P2.kt
frikit
317,914,710
false
null
package com.github.aoc import com.github.aoc.utils.InputDay4Problem2 import com.github.aoc.utils.InputParser import com.github.aoc.utils.Result fun main() { // TC // byr valid: 2002 // byr invalid: 2003 // // hgt valid: 60in // hgt valid: 190cm // hgt invalid: 190in // hgt invalid: 190 // ...
0
Kotlin
0
0
2fca82225a19144bbbca39247ba57c42a30ef459
4,512
aoc2020
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/WaysToBuildRooms.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,786
kotlab
Apache License 2.0
src/Day05.kt
olezhabobrov
572,687,414
false
{"Kotlin": 27363}
fun main() { fun initialForTest(): List<MutableList<Char>> { val size = 3 val crates = arrayListOf( mutableListOf('Z', 'N'), mutableListOf('M', 'C', 'D'), mutableListOf('P') ) return crates } fun initial(): List<MutableList<Char>> { ...
0
Kotlin
0
0
31f2419230c42f72137c6cd2c9a627492313d8fb
2,689
AdventOfCode
Apache License 2.0
src/main/kotlin/com/chriswk/aoc/advent2021/Day5.kt
chriswk
317,863,220
false
{"Kotlin": 481061}
package com.chriswk.aoc.advent2021 import com.chriswk.aoc.AdventDay import com.chriswk.aoc.util.report import kotlin.math.abs import kotlin.math.sign class Day5 : AdventDay(2021, 5) { companion object { @JvmStatic fun main(args: Array<String>) { val day = Day5() report { ...
116
Kotlin
0
0
69fa3dfed62d5cb7d961fe16924066cb7f9f5985
2,492
adventofcode
MIT License
src/main/kotlin/day23/Day23.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day23 import runDay import utils.Point import utils.Ring fun main() { fun part1(input: List<String>) = input.toElves() .let { allElves -> var positions = allElves var movesToTry = possibleMoves repeat(10) { i -> posit...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
4,667
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/EvaluateDivision.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,136
kotlab
Apache License 2.0
day17/src/main/kotlin/App.kt
ascheja
317,918,055
false
null
package net.sinceat.aoc2020.day17 fun main() { run { var grid = Grid(readInput("testinput.txt") { x, y -> GridPoint3d(x, y, 0) }, ::drawGrid3d) (1 .. 6).forEach { grid = grid.evolve() } println(grid.countActive()) println() } run { var grid = Grid...
0
Kotlin
0
0
f115063875d4d79da32cbdd44ff688f9b418d25e
5,784
aoc2020
MIT License
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day15.kt
770grappenmaker
434,645,245
false
{"Kotlin": 409647, "Python": 647}
package com.grappenmaker.aoc.year18 import com.grappenmaker.aoc.* import java.util.* fun PuzzleSet.day15() = puzzle(day = 15) { val initialGrid = inputLines.asCharGrid().mapIndexedElements { p, v -> when (v) { '.' -> EmptySquare '#' -> Wall else -> Battler(v == 'E', p) ...
0
Kotlin
0
7
92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585
3,684
advent-of-code
The Unlicense
src/day05/Day05.kt
gagandeep-io
573,585,563
false
{"Kotlin": 9775}
package day05 import readInput import java.util.Stack fun main() { fun part1(input: List<String>): String { val index = input.indexOfFirst { it.isBlank() || it.isEmpty() } val cratesDiagram:List<String> = input.subList(0, index) val lastLine = cratesDiagram.last() val numberOfCrate...
0
Kotlin
0
0
952887dd94ccc81c6a8763abade862e2d73ef924
2,123
aoc-2022-kotlin
Apache License 2.0
src/year2022/03/Day03.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`03` import readInput const val ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun main() { val ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" fun part1(input: List<String>): Int { return input .map { s1 -> val mid: I...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
1,277
KotlinAdventOfCode
Apache License 2.0
src/Day03.kt
palex65
572,937,600
false
{"Kotlin": 68582}
fun Char.toPriority() = when (this) { in 'a'..'z' -> this-'a'+1 in 'A'..'Z' -> this-'A'+27 else -> error("Invalid item $this") } private fun part1(lines: List<String>) = lines.sumOf { l -> val a = l.substring(0, l.length / 2) val b = l.substring(l.length / 2) a.first { it in b }.toPriority() }...
0
Kotlin
0
2
35771fa36a8be9862f050496dba9ae89bea427c5
686
aoc2022
Apache License 2.0
solutions/src/Day10.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): Int { val cycleValues = mutableListOf<Int>() var cycle = 0 var x = 1 input.forEach { line -> val instruction = line.substring(0, 4) when (instruction) { "addx" -> { val (_, number...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
2,255
advent-of-code-22
Apache License 2.0
ShortestPalindrome.kt
ncschroeder
604,822,497
false
{"Kotlin": 19399}
/* https://leetcode.com/problems/shortest-palindrome/ You are given a string `s`. You can convert `s` to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation. Examples: Input: s = "aacecaaa" Output: "aaacecaaa" Input: s = "abcd" Output: "dcb...
0
Kotlin
0
0
c77d0c8bb0595e61960193fc9b0c7a31952e8e48
1,476
Coding-Challenges
MIT License
src/main/kotlin/Day03.kt
michaeljwood
572,560,528
false
{"Kotlin": 5391}
fun main() { fun part1(input: List<String>) = input.filter { it.isNotBlank() } .map { Pair( it.substring(0, it.length / 2).toCharArray().toSet(), it.substring(it.length / 2).toCharArray().toSet() ) } .map { it.first.intersect(it.second)...
0
Kotlin
0
0
8df2121f12a5a967b25ce34bce6678ab9afe4aa7
979
advent-of-code-2022
Apache License 2.0
kotlin/1425-constrained-subsequence-sum.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}
// Time O(nlogn) and space O(n) using max heap class Solution { fun constrainedSubsetSum(nums: IntArray, k: Int): Int { var res = nums[0] val maxHeap = PriorityQueue<IntArray>() { a, b -> b[0] - a[0] } maxHeap.add(intArrayOf(nums[0], 0)) for (i in 1 until nums.size) { wh...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,219
leetcode
MIT License
src/test/kotlin/chapter6/solutions/ex7/listing.kt
DavidGomesh
680,857,367
false
{"Kotlin": 204685}
package chapter6.solutions.ex7 import chapter3.Cons import chapter3.List import chapter3.Nil import chapter3.foldRight import chapter6.RNG import chapter6.Rand import chapter6.rng1 import chapter6.solutions.ex6.map2 import chapter6.unit import io.kotest.matchers.shouldBe import io.kotest.core.spec.style.WordSpec //ta...
0
Kotlin
0
0
41fd131cd5049cbafce8efff044bc00d8acddebd
2,212
fp-kotlin
MIT License
src/Day10/Day10.kt
AllePilli
572,859,920
false
{"Kotlin": 47397}
package Day10 import checkAndPrint import measureAndPrintTimeMillis import readInput import kotlin.math.abs fun main() { fun List<String>.prepareInput(): List<Operation> { val addxRgx = """addx (-?\d+)""".toRegex() val noopRgx = "noop".toRegex() return map { line -> addxRgx.mat...
0
Kotlin
0
0
614d0ca9cc925cf1f6cfba21bf7dc80ba24e6643
1,942
AdventOfCode2022
Apache License 2.0
src/Day10.kt
zhtk
579,137,192
false
{"Kotlin": 9893}
fun main() { fun part1(operations: List<Int>): Int { var x = 1 return operations.mapIndexed { index, i -> val cycle = index + 1 val signal = if (cycle <= 220 && (cycle - 20) % 40 == 0) x * cycle else 0 x += i signal }.sum() } fun part2(...
0
Kotlin
0
0
bb498e93f9c1dd2cdd5699faa2736c2b359cc9f1
854
aoc2022
Apache License 2.0