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/MinMovesToSeat.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,816
kotlab
Apache License 2.0
src/Day03.kt
morris-j
573,197,835
false
{"Kotlin": 7085}
fun main() { fun getRank(value: Char): Int { if(value.isUpperCase()) { return value.code - 64 + 26 } return value.code - 96 } fun findCommon(first: String, second: String): Char { first.forEach { if(second.contains(it)) { return it ...
0
Kotlin
0
0
e3f2d02dad432dbc1b15c9e0eefa7b35ace0e316
1,633
kotlin-advent-of-code-2022
Apache License 2.0
lib/src/main/kotlin/aoc/day05/Day05.kt
Denaun
636,769,784
false
null
package aoc.day05 data class Crate(val name: Char) data class Step(val quantity: Int, val from: Int, val to: Int) abstract class CrateMover { fun execute(steps: List<Step>, initialStacks: List<List<Crate>>): List<List<Crate>> = steps.fold(initialStacks) { stacks, step -> execute(step, stacks) } abstr...
0
Kotlin
0
0
560f6e33f8ca46e631879297fadc0bc884ac5620
1,638
aoc-2022
Apache License 2.0
src/year2022/16/Day16.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`16` import java.util.PriorityQueue import readInput /** * With help of solution from * https://github.com/LiquidFun/adventofcode * * (This task was really hard and I've couldn't manage to solve it by myself) */ data class State( var remainingTime: RemainingTime, var currentValve: Valve,...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
8,758
KotlinAdventOfCode
Apache License 2.0
year2020/day06/part1/src/main/kotlin/com/curtislb/adventofcode/year2020/day06/part1/Year2020Day06Part1.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Day 6: Custom Customs --- As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers. The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone in...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
2,463
AdventOfCode
MIT License
src/main/kotlin/day11/Day11.kt
vitalir2
572,865,549
false
{"Kotlin": 89962}
package day11 import Challenge import product private typealias MonkeyId = Int object Day11 : Challenge(11) { override fun part1(input: List<String>): Any { return solveDay(input, 20) { level -> level / 3 } } override fun part2(input: List<String>): Any { return solveDay(input, 10000) ...
0
Kotlin
0
0
ceffb6d4488d3a0e82a45cab3cbc559a2060d8e6
6,436
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2016/Day20.kt
tginsberg
74,924,040
false
null
/* * Copyright (c) 2016 by <NAME> */ package com.ginsberg.advent2016 /** * Advent of Code - Day 20: December 20, 2016 * * From http://adventofcode.com/2016/day/20 * */ class Day20(val input: List<String>) { val ipRanges = parseInput() fun solvePart1(): Long = ipRanges.first().last.inc() ...
0
Kotlin
0
3
a486b60e1c0f76242b95dd37b51dfa1d50e6b321
1,233
advent-2016-kotlin
MIT License
2022/src/main/kotlin/day3_fast.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.split object Day3Fast : Solution<List<String>>() { override val name = "day3" override val parser = Parser.lines override fun part1(input: List<String>): Int { var sum = 0 input.forEach { line -> val (l, r) = line.split() var lmask = 0...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,242
aoc_kotlin
MIT License
src/main/kotlin/days/Day04.kt
julia-kim
569,976,303
false
null
package days import readInput fun main() { fun part1(input: List<String>): Int { var assignmentPairs = 0 input.forEach { // 2-4,6-8 val (first, second) = it.split(",").map { range -> val (start, end) = range.split("-", limit = 2).map(String::toInt) ...
0
Kotlin
0
0
65188040b3b37c7cb73ef5f2c7422587528d61a4
1,123
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/jaspervanmerle/aoc2021/day/Day05.kt
jmerle
434,010,865
false
{"Kotlin": 60581}
package com.jaspervanmerle.aoc2021.day import kotlin.math.max import kotlin.math.min class Day05 : Day("4993", "21101") { private data class Point(val x: Int, val y: Int) private data class Line(val from: Point, val to: Point) { val coordinates = if (from.x == to.x) { val yFrom = min(from...
0
Kotlin
0
0
dcac2ac9121f9bfacf07b160e8bd03a7c6732e4e
1,544
advent-of-code-2021
MIT License
kotlin/src/main/kotlin/com/github/jntakpe/aoc2022/days/Day5.kt
jntakpe
572,853,785
false
{"Kotlin": 72329, "Rust": 15876}
package com.github.jntakpe.aoc2022.days import com.github.jntakpe.aoc2022.shared.Day import com.github.jntakpe.aoc2022.shared.readInput object Day5 : Day { override val input = Supplies.create() override fun part1() = input.moveAll(false).print() override fun part2() = input.moveAll(true).print() ...
1
Kotlin
0
0
63f48d4790f17104311b3873f321368934060e06
2,674
aoc2022
MIT License
src/Day09.kt
Kanialdo
573,165,497
false
{"Kotlin": 15615}
fun main() { data class Pos(val x: Int, val y: Int) fun part1(input: List<String>): Int { var h = Pos(0, 0) var t = Pos(0, 0) val tail = mutableSetOf(t) input.forEach { val direction = it.split(" ").first() val moves = it.split(" ").last().toInt() ...
0
Kotlin
0
0
10a8550a0a85bd0a928970f8c7c5aafca2321a4b
1,330
advent-of-code-2022
Apache License 2.0
src/Day04.kt
Daan-Gunnink
572,614,830
false
{"Kotlin": 8595}
class Day04 : AdventOfCode(2,4) { private fun getSectors(data: String): List<List<Int>>{ return data.split(",").map {sectors -> val splitSectors = sectors.split("-") val range = IntRange(splitSectors[0].toInt(), splitSectors[1].toInt()) range.toList() } } ...
0
Kotlin
0
0
15a89224f332faaed34fc2d000c00fbefe1a3c08
1,003
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2022/Day14.kt
tginsberg
568,158,721
false
{"Kotlin": 113322}
/* * Copyright (c) 2022 by <NAME> */ /** * Advent of Code 2022, Day 14 - Regolith Reservoir * Problem Description: http://adventofcode.com/2022/day/14 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2022/day14/ */ package com.ginsberg.advent2022 class Day14(input: List<String>) { priv...
0
Kotlin
2
26
2cd87bdb95b431e2c358ffaac65b472ab756515e
1,916
advent-2022-kotlin
Apache License 2.0
src/Day09.kt
Venkat-juju
572,834,602
false
{"Kotlin": 27944}
import java.lang.Math.abs fun main() { fun isAdjacentPoint(firstPoint: Pair<Int, Int>, secondPoint: Pair<Int, Int>): Boolean { val distanceRowWise = abs(secondPoint.first - firstPoint.first) val distanceColumnWise = abs(secondPoint.second - firstPoint.second) return (distanceRowWise == 1 ...
0
Kotlin
0
0
785a737b3dd0d2259ccdcc7de1bb705e302b298f
5,569
aoc-2022
Apache License 2.0
src/Day21.kt
frungl
573,598,286
false
{"Kotlin": 86423}
data class Monkey(val left: String?, val operation: String?, val right: String?, var number: Long) { init { if (left == null || right == null || operation == null) { require(left == null && right == null && operation == null) } } val hasNumber: Boolean get() = left == nu...
0
Kotlin
0
0
d4cecfd5ee13de95f143407735e00c02baac7d5c
5,075
aoc2022
Apache License 2.0
src/aoc2021/Day10.kt
dayanruben
433,250,590
false
{"Kotlin": 79134}
package aoc2021 import readInput import java.util.* fun main() { val (year, day) = "2021" to "Day10" fun List<String>.toScores(corrupted: Boolean) = map { line -> val stack = LinkedList<Char>() line.forEach { c -> when (c) { ')' -> { val match =...
1
Kotlin
2
30
df1f04b90e81fbb9078a30f528d52295689f7de7
1,986
aoc-kotlin
Apache License 2.0
src/Day04.kt
sms-system
572,903,655
false
{"Kotlin": 4632}
fun main() { fun prepareData (input: List<String>): List<String> = input .map { it.split(",").map { it.split("-").map { it.toInt() } } } fun part1(input: List<String>): Int = prepareData(input).filter { it[0][0]...
0
Kotlin
0
0
266dd4e52f3b01912fbe2aa23d1ee70d1292827d
774
adventofcode-2022-kotlin
Apache License 2.0
15/src/main/kotlin/Cokies.kt
kopernic-pl
109,750,709
false
null
import Ingredient.IngredientProperty import com.google.common.io.Resources const val TEASPOONS_CAPACITY = 100 @Suppress("UnstableApiUsage") fun main() { val allIngredients: List<Ingredient> = Resources.getResource("input.txt") .readText().lines() .map(Ingredient.Companion::fromString) val all...
0
Kotlin
0
0
06367f7e16c0db340c7bda8bc2ff991756e80e5b
3,506
aoc-2015-kotlin
The Unlicense
src/main/kotlin/biz/koziolek/adventofcode/year2021/day22/day22.kt
pkoziol
434,913,366
false
{"Kotlin": 715025, "Shell": 1892}
package biz.koziolek.adventofcode.year2021.day22 import biz.koziolek.adventofcode.* import kotlin.math.max import kotlin.math.min fun main() { val inputFile = findInput(object {}) val lines = inputFile.bufferedReader().readLines() val rebootSteps = parseReactorRebootSteps(lines) val onCubes = execut...
0
Kotlin
0
0
1b1c6971bf45b89fd76bbcc503444d0d86617e95
7,501
advent-of-code
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinTaps.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
3,673
kotlab
Apache License 2.0
src/main/kotlin/wtf/log/xmas2021/day/day10/Day10.kt
damianw
434,043,459
false
{"Kotlin": 62890}
package wtf.log.xmas2021.day.day10 import wtf.log.xmas2021.Day import java.io.BufferedReader import java.util.* object Day10 : Day<List<List<Token>>, Long, Long> { override fun parseInput(reader: BufferedReader): List<List<Token>> = reader .lineSequence() .map { line -> line.map(Token...
0
Kotlin
0
0
1c4c12546ea3de0e7298c2771dc93e578f11a9c6
3,107
AdventOfKotlin2021
BSD Source Code Attribution
src/Day08.kt
OskarWalczak
573,349,185
false
{"Kotlin": 22486}
fun main() { val treeMatrix: Array<IntArray> = Array(99){IntArray(99)} val testMatrix: Array<IntArray> = Array(5){IntArray(5)} fun readLinesToMatrix(lines: List<String>, matrix: Array<IntArray>){ lines.forEachIndexed { lineIndex, s -> s.forEachIndexed { stringIndex, c -> ...
0
Kotlin
0
0
d34138860184b616771159984eb741dc37461705
3,820
AoC2022
Apache License 2.0
src/Day03.kt
hadiamin
572,509,248
false
null
fun main() { fun part1(input: List<String>): Int { return input.map { rucksack -> rucksack.substring(0, rucksack.length / 2) to rucksack.substring(rucksack.length / 2) } // .also { println(it) } .flatMap { (first, second) -> first.toSet() intersect second.toSet() ...
0
Kotlin
0
0
e63aea2a55b629b9ac3202cdab2a59b334fb7041
1,006
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/g1401_1500/s1473_paint_house_iii/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1401_1500.s1473_paint_house_iii // #Hard #Array #Dynamic_Programming #2023_06_13_Time_235_ms_(100.00%)_Space_38.5_MB_(63.64%) class Solution { private lateinit var prev: Array<IntArray> private lateinit var curr: Array<IntArray> private lateinit var mins: Array<IntArray> fun minCost(houses: ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
3,015
LeetCode-in-Kotlin
MIT License
src/main/kotlin/days/Day17.kt
sicruse
315,469,617
false
null
package days class Day17 : Day(17) { // 4D Array!! // 3D Array? // 2D Array? class Matrix(private val space: List<List<List<List<Boolean>>>>, private val dimensions: Dimensions) { enum class Dimensions {THREE, FOUR} fun active(x: Int, y: Int, z: Int, w: Int): Boolean { re...
0
Kotlin
0
0
9a07af4879a6eca534c5dd7eb9fc60b71bfa2f0f
4,521
aoc-kotlin-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/sk/mkiss/algorithms/dynamic/BuyAndSellStock.kt
marek-kiss
430,858,906
false
{"Kotlin": 85343}
package sk.mkiss.algorithms.dynamic; import kotlin.math.max object BuyAndSellStock { // https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ fun maxProfitFromOneDeal(prices: IntArray): Int { require(prices.isNotEmpty()) require(prices.all { it >= 0 }) var maxProfit = 0 ...
0
Kotlin
0
0
296cbd2e04a397597db223a5721b6c5722eb0c60
1,574
algo-in-kotlin
MIT License
src/main/kotlin/days/day22/Day22.kt
Stenz123
725,707,248
false
{"Kotlin": 123279, "Shell": 862}
package days.day22 import days.Day import java.util.* class Day22: Day() { override fun partOne(): Any { val bricks = parseInput() val brickCoordinateMap = mutableListOf<Coordinate>() val queue: PriorityQueue<Brick> = PriorityQueue() queue.addAll(bricks) while (queue.isNot...
0
Kotlin
1
0
3de47ec31c5241947d38400d0a4d40c681c197be
5,175
advent-of-code_2023
The Unlicense
src/main/kotlin/Day04.kt
arosenf
726,114,493
false
{"Kotlin": 40487}
import java.math.BigDecimal import kotlin.system.exitProcess fun main(args: Array<String>) { if (args.isEmpty() or (args.size < 2)) { println("Scratchcard not specified") exitProcess(1) } val fileName = args.first() println("Reading $fileName") val lines = readLines(fileName) v...
0
Kotlin
0
0
d9ce83ee89db7081cf7c14bcad09e1348d9059cb
2,503
adventofcode2023
MIT License
src/Day03.kt
sjgoebel
573,578,579
false
{"Kotlin": 21782}
fun main() { fun part1(input: List<String>): Int { var priorities = 0 for (line in input) { val first = line.substring(0 until line.length/2) //println(first) val second = line.substring(line.length/2 until line.length) //println(second) f...
0
Kotlin
0
0
ae1588dbbb923dbcd4d19fd1495ec4ebe8f2593e
1,779
advent-of-code-2022-kotlin
Apache License 2.0
src/day7/Code.kt
fcolasuonno
221,697,249
false
null
package day7 import java.io.File fun main() { val name = if (false) "test.txt" else "input.txt" val dir = ::main::class.java.`package`.name val input = File("src/$dir/$name").readLines() val parsed = parse(input) println("Part 1 = ${part1(parsed)}") println("Part 2 = ${part2(parsed)}") } fun ...
0
Kotlin
0
0
73110eb4b40f474e91e53a1569b9a24455984900
1,152
AOC2016
MIT License
leetcode2/src/leetcode/ValidPalindrome.kt
hewking
68,515,222
false
null
package leetcode /** * 125. 验证回文串 * https://leetcode-cn.com/problems/valid-palindrome/ * Created by test * Date 2019/6/7 0:45 * Description * 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 说明:本题中,我们将空字符串定义为有效的回文串。 示例 1: 输入: "A man, a plan, a canal: Panama" 输出: true 示例 2: 输入: "race a car" 输出: false 来源:力扣(LeetCode)...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
1,653
leetcode
MIT License
advent_of_code/2018/solutions/day_10_b.kt
migafgarcia
63,630,233
false
{"C++": 121354, "Kotlin": 38202, "C": 34840, "Java": 23043, "C#": 10596, "Python": 8343}
import java.io.File import java.lang.Math.abs data class Point(var position: Pair<Int, Int>, val velocity: Pair<Int, Int>) fun main(args: Array<String>) { val regex = Regex("position=<([- \\d]+),([- \\d]+)> velocity=<([- \\d]+),([- \\d]+)>") val points = ArrayList<Point>(400) File(args[0]).forEachLine...
0
C++
3
9
82f5e482c0c3c03fd39e46aa70cab79391ed2dc5
2,099
programming-challenges
MIT License
src/Day01.kt
kerchen
573,125,453
false
{"Kotlin": 137233}
fun main() { fun part1(input: List<String>): Int { var max_calories = 0 var sum_calories = 0 var elf = 0 for (calories in input) { val c: Int = try { calories.toInt() } catch (e:NumberFormatException) { 0 } if (c != 0) { sum_calories += c ...
0
Kotlin
0
0
dc15640ff29ec5f9dceb4046adaf860af892c1a9
1,411
AdventOfCode2022
Apache License 2.0
src/main/kotlin/net/voldrich/aoc2022/Day08.kt
MavoCz
434,703,997
false
{"Kotlin": 119158}
package net.voldrich.aoc2022 import net.voldrich.BaseDay // https://adventofcode.com/2022/day/7 fun main() { Day08().run() } class Day08 : BaseDay() { override fun task1() : Int { return countVisibleTrees(input.lines().filter { it.isNotBlank() }) } override fun task2() : Int { retur...
0
Kotlin
0
0
0cedad1d393d9040c4cc9b50b120647884ea99d9
3,385
advent-of-code
Apache License 2.0
problems/2020adventofcode17b/submissions/accepted/Stefan.kt
stoman
47,287,900
false
{"C": 169266, "C++": 142801, "Kotlin": 115106, "Python": 76047, "Java": 68331, "Go": 46428, "TeX": 27545, "Shell": 3428, "Starlark": 2165, "Makefile": 1582, "SWIG": 722}
import java.util.* const val cycles = 6 fun main() { val s = Scanner(System.`in`) val input = mutableListOf<List<Boolean>>() while (s.hasNext()) { input.add(s.next().map { it == '#' }) } var map = List(1 + 2 * cycles) { List(1 + 2 * cycles) { List(input.size + 2 * cycles) { MutableLi...
0
C
1
3
ee214c95c1dc1d5e9510052ae425d2b19bf8e2d9
1,658
CompetitiveProgramming
MIT License
src/day2/Day2.kt
pocmo
433,766,909
false
{"Kotlin": 134886}
package day2 import java.io.File sealed interface Command { data class Forward( val steps: Int ): Command data class Down( val steps: Int ) : Command data class Up( val steps: Int ) : Command } fun readCourse(): List<Command> { val lines = File("day2.txt").readLi...
0
Kotlin
1
2
73bbb6a41229e5863e52388a19108041339a864e
2,408
AdventOfCode2021
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MajorityElement.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
3,219
kotlab
Apache License 2.0
src/year2023/13/Day13.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2023.`13` import readInput import utils.printDebug import utils.printlnDebug private const val CURRENT_DAY = "13" private data class Point( val x: Int, val y: Int, ) private fun parseIntoListsOfLists(input: List<String>): List<List<String>> { val mutableRes = mutableListOf<List<String>>() ...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
8,840
KotlinAdventOfCode
Apache License 2.0
kotlin/src/com/daily/algothrim/leetcode/MinimumDifference.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode import com.daily.algothrim.tree.TreeNode import kotlin.math.min /** * 二叉树的最小绝对差(leetcode 530) * * 给你一棵所有节点为非负值的二叉搜索树,请你计算树中任意两节点的差的绝对值的最小值。 * 示例: * * 输入: * * 1 * \ * 3 * / * 2 * * 输出: * 1 * * 解释: * 最小绝对差为 1,其中 2 和 1 的差的绝对值为 1(或者 2 和 3)。 * * 提示: * 树中至少有 2 个节点...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
1,452
daily_algorithm
Apache License 2.0
src/kotlin2023/Day01.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2023 import readInput val spelledNumbers = mapOf( "one" to 1, "two" to 2, "three" to 3, "four" to 4, "five" to 5, "six" to 6, "seven" to 7, "eight" to 8, "nine" to 9 ) fun main() { val lines = readInput("kotlin2023/Day01_test") ...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
1,084
advent-of-code-kotlin
Apache License 2.0
src/Day18.kt
jvmusin
572,685,421
false
{"Kotlin": 86453}
import java.util.* import kotlin.collections.ArrayDeque import kotlin.math.abs fun main() { data class Cube(val x: Int, val y: Int, val z: Int) fun part1(input: List<String>): Int { val cubes = HashSet<Cube>() for (s in input) { val (x, y, z) = s.split(',').map { it.toInt() } ...
1
Kotlin
0
0
4dd83724103617aa0e77eb145744bc3e8c988959
3,535
advent-of-code-2022
Apache License 2.0
2023/src/main/kotlin/day20.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import utils.cut import utils.lcm import utils.mapItems import java.util.LinkedList fun main() { Day20.run(skipTest = true) } object Day20 : Solution<Map<String, Day20.Module>>() { override val name = "day20" override val parser = Parser.lines .mapItems { Module.par...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
4,676
aoc_kotlin
MIT License
src/Day22.kt
syncd010
324,790,559
false
null
import java.math.BigInteger class Day22: Day { enum class Oper {CUT, DEAL, REVERSE} data class Instruction(val op: Oper, val arg: Long) fun convert(input: List<String>, sz: Long) : List<Instruction> { return input.mapNotNull { inst -> when { inst.startsWith("cut") -> ...
0
Kotlin
0
0
11c7c7d6ccd2488186dfc7841078d9db66beb01a
3,343
AoC2019
Apache License 2.0
Algorithms/Search/SherlockandArray/Solution.kt
ahmed-mahmoud-abo-elnaga
449,443,709
false
{"Kotlin": 14218}
/* Problem: https://www.hackerrank.com/challenges/sherlock-and-array/problem Kotlin Language Version Tool Version : Android Studio Thoughts (Key points in algorithm): This is quite a straight forward problem. All elements of the input array is set to the sum of all the el...
0
Kotlin
1
1
a65ee26d47b470b1cb2c1681e9d49fe48b7cb7fc
2,002
HackerRank
MIT License
src/main/kotlin/com/github/freekdb/aoc2019/old/Day3Version1.kt
FreekDB
228,241,398
false
null
package com.github.freekdb.aoc2019.old import java.io.File import kotlin.experimental.or import kotlin.math.abs import kotlin.math.max import kotlin.math.min private const val NUMBER_PATH_1 = 0 private const val NUMBER_PATH_2 = 1 private const val DIRECTION_UP = 'U' private const val DIRECTION_DOWN = 'D' private con...
0
Kotlin
0
1
fd67b87608bcbb5299d6549b3eb5fb665d66e6b5
6,146
advent-of-code-2019
Apache License 2.0
src/main/kotlin/com/github/michaelbull/advent2023/day11/Image.kt
michaelbull
726,012,340
false
{"Kotlin": 195941}
package com.github.michaelbull.advent2023.day11 import com.github.michaelbull.advent2023.iteration.combinationPairs import com.github.michaelbull.advent2023.math.Vector2 import com.github.michaelbull.advent2023.math.manhattanDistance private typealias Dimension = (Vector2) -> Int private typealias Axis = (Int) -> Vec...
0
Kotlin
0
1
ea0b10a9c6528d82ddb481b9cf627841f44184dd
2,529
advent-2023
ISC License
src/main/kotlin/solutions/Day21MonkeyMath.kt
aormsby
571,002,889
false
{"Kotlin": 80084}
package solutions import utils.Input import utils.Solution // run only this day fun main() { Day21MonkeyMath() } class Day21MonkeyMath : Solution() { init { begin("Day 21 - Monkey Math") val input = Input.parseLines(filename = "/d21_monkey_shouts.txt") val numYellers = mutableMapOf<S...
0
Kotlin
0
0
1bef4812a65396c5768f12c442d73160c9cfa189
6,689
advent-of-code-2022
MIT License
src/main/kotlin/com/hopkins/aoc/day14/main.kt
edenrox
726,934,488
false
{"Kotlin": 88215}
package com.hopkins.aoc.day14 import java.io.File const val debug = true const val part = 2 val cache = mutableMapOf<String, Int>() val loadFactorLookup = mutableMapOf<Int, Int>() /** Advent of Code 2023: Day 14 */ fun main() { // Read the file input val lines: List<String> = File("input/input14.txt").readL...
0
Kotlin
0
0
45dce3d76bf3bf140d7336c4767e74971e827c35
4,033
aoc2023
MIT License
Kotlin/days/src/day10.kt
dukemarty
224,307,841
false
null
import java.io.BufferedReader import java.io.FileReader import java.lang.StringBuilder import kotlin.math.* data class Coordinate(val x: Int, val y: Int) data class Asteroid(val Coord: Coordinate, var WatchCount: Int = 0, var Angle: Double = -1.0, var VaporIndex: Int = -1) { fun distance(other: Asteroid): Double...
0
Kotlin
0
0
6af89b0440cc1d0cc3f07d5a62559aeb68e4511a
5,636
dukesaoc2019
MIT License
src/main/kotlin/com/hj/leetcode/kotlin/problem221/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem221 /** * LeetCode page: [221. Maximal Square](https://leetcode.com/problems/maximal-square/); */ class Solution { /* Complexity: * Time O(MN) and Space O(N) where M and N are the number of rows and columns of matrix; */ fun maximalSquare(matrix: Array<CharArra...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,403
hj-leetcode-kotlin
Apache License 2.0
kotlin/1288-remove-covered-intervals.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 complexity O(nlogn) and space complexity O(n) // Find solution with optimized space complexity below class Solution { fun removeCoveredIntervals(intervals: Array<IntArray>): Int { intervals.sortWith(compareBy({ it[0] }, { -it[1] })) val res = LinkedList<IntArray>().apply { add(intervals[0])...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,051
leetcode
MIT License
src/year2022/day03/Day03.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day03 import readInputFileByYearAndDay import readTestFileByYearAndDay fun main() { fun Char.toPriority(): Int { if (this.code >= 'A'.code && this.code < 'a'.code) return this.code - 'A'.code + 27 else if (this.code >= 'a'.code && this.code <= 'z'.code) re...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
1,184
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/AppealSum.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
1,606
kotlab
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem79/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem79 /** * LeetCode page: [79. Word Search](https://leetcode.com/problems/word-search/); */ class Solution { /* Complexity: * Time O(|board| * |word|) and Space O(|board|); */ fun exist(board: Array<CharArray>, word: String): Boolean { val visited = List(...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,683
hj-leetcode-kotlin
Apache License 2.0
2023/src/main/kotlin/Day11.kt
dlew
498,498,097
false
{"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262}
object Day11 { private data class Pos(val x: Int, val y: Int) fun sumPairwisePaths(input: String, expansionSize: Long): Long { val image = input.splitNewlines() val emptyRows = image.indices.filter { y -> image[y].all { it == '.' } } val emptyCols = image[0].indices.filter { x -> image.all { it[x] == ...
0
Kotlin
0
0
6972f6e3addae03ec1090b64fa1dcecac3bc275c
1,046
advent-of-code
MIT License
src/main/kotlin/Day9.kt
pavittr
317,532,861
false
null
import java.io.File import java.math.BigInteger import java.nio.charset.Charset fun main() { val testDocs = File("test/day9").readLines(Charset.defaultCharset()).map{it.toBigInteger()} val puzzles = File("puzzles/day9").readLines(Charset.defaultCharset()).map{it.toBigInteger()} fun lastNumIsValid(input: L...
0
Kotlin
0
0
3d8c83a7fa8f5a8d0f129c20038e80a829ed7d04
1,561
aoc2020
Apache License 2.0
src/main/kotlin/com/sk/set5/581. Shortest Unsorted Continuous Subarray.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.set5 import java.util.Stack private fun findUnsortedSubarray2(nums: IntArray): Int { var l = nums.size var r = 0 for (i in 0 until nums.size - 1) { for (j in i + 1 until nums.size) { if (nums[j] < nums[i]) { r = maxOf(r, j) l = minOf(l, i)...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,952
leetcode-kotlin
Apache License 2.0
src/main/kotlin/de/nosswald/aoc/days/Day10.kt
7rebux
722,943,964
false
{"Kotlin": 34890}
package de.nosswald.aoc.days import de.nosswald.aoc.Day import kotlin.math.ceil // https://adventofcode.com/2023/day/10 object Day10 : Day<Int>(10, "Pipe Maze") { data class Point(val x: Int, val y: Int) override fun partOne(input: List<String>): Int { val start = Point( x = input.first {...
0
Kotlin
0
1
398fb9873cceecb2496c79c7adf792bb41ea85d7
2,109
advent-of-code-2023
MIT License
src/Day12.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { data class Input( val grid: List<List<Int>>, val start: Pair<Int, Int>, val end: Pair<Int, Int> ) fun parseInput(input: List<String>): Input { val grid = mutableListOf<List<Int>>() var start = Pair(0, 0) var end = Pair(0, 0) for ((i, v) i...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
5,372
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/advent/of/code/hjk/Day23.kt
h-j-k
427,964,167
false
{"Java": 46088, "Kotlin": 26804}
package com.advent.of.code.hjk object Day23 { private fun process(input: List<String>, initial: Map<String, Int>): Int { val copy = input.toMutableList() val registers = initial.toMutableMap() var i = 0 while (i < copy.size) { val values = copy[i].split(" ") ...
0
Java
0
0
5ffa381e97cbcfe234c49b5a5f8373641166db6c
4,021
advent16
Apache License 2.0
src/main/kotlin/at/mpichler/aoc/solutions/year2022/Day03.kt
mpichler94
656,873,940
false
{"Kotlin": 196457}
package at.mpichler.aoc.solutions.year2022 import at.mpichler.aoc.lib.Day import at.mpichler.aoc.lib.PartSolution open class Part3A : PartSolution() { internal lateinit var rucksacks: List<String> override fun parseInput(text: String) { rucksacks = text.trim().split("\n") } override fun comp...
0
Kotlin
0
0
69a0748ed640cf80301d8d93f25fb23cc367819c
1,656
advent-of-code-kotlin
MIT License
2022/Day02/problems.kt
moozzyk
317,429,068
false
{"Rust": 102403, "C++": 88189, "Python": 75787, "Kotlin": 72672, "OCaml": 60373, "Haskell": 53307, "JavaScript": 51984, "Go": 49768, "Scala": 46794}
import java.io.File fun main(args: Array<String>) { val lines = File(args[0]).readLines() problem1(lines) problem2(lines) } fun problem1(lines: List<String>) { println(calculateScore(lines)) } fun problem2(lines: List<String>) { println( calculateScore( lines.map {...
0
Rust
0
0
c265f4c0bddb0357fe90b6a9e6abdc3bee59f585
1,658
AdventOfCode
MIT License
src/Day08.kt
KliminV
573,758,839
false
{"Kotlin": 19586}
fun main() { fun part1(input: Array<Array<Int>>): Int { val topView = Array(input.size) { Array(input[0].size) { 0 } } val leftView = Array(input.size) { Array(input[0].size) { 0 } } val bottomView = Array(input.size) { Array(input[0].size) { 0 } } val rightView = Array(input.size) {...
0
Kotlin
0
0
542991741cf37481515900894480304d52a989ae
3,662
AOC-2022-in-kotlin
Apache License 2.0
src/me/bytebeats/algo/kt/Solution13.kt
bytebeats
251,234,289
false
null
package me.bytebeats.algo.kt import me.bytebeats.algs.ds.TreeNode import kotlin.math.absoluteValue import kotlin.math.min /** * @Author bytebeats * @Email <<EMAIL>> * @Github https://github.com/bytebeats * @Created on 2021/9/7 19:30 * @Version 1.0 * @Description TO-DO */ class Solution13 { fun minimumSwit...
0
Kotlin
0
1
7cf372d9acb3274003bb782c51d608e5db6fa743
8,338
Algorithms
MIT License
src/Day02.kt
KorneliuszBarwinski
572,677,168
false
{"Kotlin": 6042}
fun main() { fun calculatePointsFirstStrategy(values: List<String>) : Int { val me = values[1] val opponent = values[0] var pointsForRound = 0 when (me) { "X" -> { pointsForRound += 1 if (opponent == "A") pointsForRound += 3 ...
0
Kotlin
0
0
d90175134e0c6482986fcf3c144282f189abc875
3,120
AoC_2022
Apache License 2.0
aoc2022/day22.kt
davidfpc
726,214,677
false
{"Kotlin": 127212}
package aoc2022 import utils.InputRetrieval fun main() { Day22.execute() } object Day22 { fun execute() { val input = readInput() println("Part 1: ${part1(input)}") println("Part 2: ${part2(input)}") } private fun part1(input: Pair<List<String>, List<Any>>): Int { va...
0
Kotlin
0
0
8dacf809ab3f6d06ed73117fde96c81b6d81464b
5,768
Advent-Of-Code
MIT License
src/main/kotlin/g2501_2600/s2597_the_number_of_beautiful_subsets/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2501_2600.s2597_the_number_of_beautiful_subsets // #Medium #Array #Dynamic_Programming #Backtracking // #2023_07_12_Time_194_ms_(100.00%)_Space_36.7_MB_(100.00%) class Solution { fun beautifulSubsets(nums: IntArray, k: Int): Int { val map: MutableMap<Int, Int> = HashMap() for (n in nums) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,529
LeetCode-in-Kotlin
MIT License
src/main/kotlin/g1001_1100/s1027_longest_arithmetic_subsequence/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g1001_1100.s1027_longest_arithmetic_subsequence // #Medium #Array #Hash_Table #Dynamic_Programming #Binary_Search // #2023_05_23_Time_330_ms_(100.00%)_Space_101.4_MB_(16.67%) import java.util.Arrays class Solution { fun longestArithSeqLength(nums: IntArray): Int { val max = maxElement(nums) ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,364
LeetCode-in-Kotlin
MIT License
src/Day11.kt
Cryosleeper
572,977,188
false
{"Kotlin": 43613}
fun main() { fun part1(input: List<String>): Int { val monkeys: Map<String, Monkey> = input.chunked(7) { val monkey = Monkey(it) monkey.id to monkey }.toMap() repeat(20) { println("### ROUND $it BEGINS! ###\n") monkeys.forEach { it.value.inspec...
0
Kotlin
0
0
a638356cda864b9e1799d72fa07d3482a5f2128e
5,349
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/IsGraphBipartite.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,728
kotlab
Apache License 2.0
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/kotlin/robepe.kt
mouredev
581,049,695
false
{"Python": 3866914, "JavaScript": 1514237, "Java": 1272062, "C#": 770734, "Kotlin": 533094, "TypeScript": 457043, "Rust": 356917, "PHP": 281430, "Go": 243918, "Jupyter Notebook": 221090, "Swift": 216751, "C": 210761, "C++": 164758, "Dart": 159755, "Ruby": 70259, "Perl": 52923, "VBScript": 49663, "HTML": 45912, "Raku": ...
import java.lang.StringBuilder import java.util.Scanner /* * Escribe un programa que reciba un texto y transforme lenguaje natural a * "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje * se caracteriza por sustituir caracteres alfanuméricos. * - Utiliza esta tabla (https://www.gamehouse.c...
4
Python
2,929
4,661
adcec568ef7944fae3dcbb40c79dbfb8ef1f633c
2,424
retos-programacion-2023
Apache License 2.0
src/main/kotlin/aoc2022/Day09.kt
davidsheldon
565,946,579
false
{"Kotlin": 161960}
package aoc2022 import utils.InputUtils import utils.Coordinates class Day09(val size: Int) { var positions = Array(size) { Coordinates(0,0) } val visited = mutableSetOf(tail) private var head: Coordinates get() = positions.first() set(c) { positions[0] = c } private val tail: Coordina...
0
Kotlin
0
0
5abc9e479bed21ae58c093c8efbe4d343eee7714
1,810
aoc-2022-kotlin
Apache License 2.0
src/nativeMain/kotlin/xyz/justinhorton/aoc2022/Day03.kt
justinhorton
573,614,839
false
{"Kotlin": 39759, "Shell": 611}
package xyz.justinhorton.aoc2022 /** * https://adventofcode.com/2022/day/3 */ class Day03(override val input: String) : Day() { override fun part1(): String { return input.trim() .split("\n") .asSequence() .map { it.chunked(it.length / 2) } .map { (half1, h...
0
Kotlin
0
1
bf5dd4b7df78d7357291c7ed8b90d1721de89e59
1,394
adventofcode2022
MIT License
advent-of-code-2021/src/code/day4/Main.kt
Conor-Moran
288,265,415
false
{"Kotlin": 53347, "Java": 14161, "JavaScript": 10111, "Python": 6625, "HTML": 733}
package code.day4 import code.common.getOrPut import java.io.File fun main() { doIt("Day 4 Part 1: Test Input", "src/code/day4/test.input", part1); doIt("Day 4 Part 1: Real Input", "src/code/day4/part1.input", part1); doIt("Day 4 Part 2: Test Input", "src/code/day4/test.input", part2); doIt("Day 4 Par...
0
Kotlin
0
0
ec8bcc6257a171afb2ff3a732704b3e7768483be
4,903
misc-dev
MIT License
src/Day17.kt
MarkTheHopeful
572,552,660
false
{"Kotlin": 75535}
import kotlin.math.max private const val EMPTY = 0 private const val BLOCKED = 1 private val DOWN = 0 to -1 private val SHIFT = mapOf('>' to (1 to 0), '<' to (-1 to 0)) private val MINUS = listOf(0 to 0, 1 to 0, 2 to 0, 3 to 0) private val PLUS = listOf(0 to 1, 1 to 1, 1 to 0, 1 to 2, 2 to 1) private val CORNER = lis...
0
Kotlin
0
0
8218c60c141ea2d39984792fddd1e98d5775b418
4,861
advent-of-kotlin-2022
Apache License 2.0
src/Day07.kt
jamOne-
573,851,509
false
{"Kotlin": 20355}
import java.util.ArrayDeque sealed class Entity { class File(val name: String, val size: Int): Entity() class Folder(val name: String, val parent: Folder?): Entity() { val children = mutableMapOf<String, Entity>() var size = 0 } } fun main() { fun buildFileSystem(terminal: List<String>...
0
Kotlin
0
0
77795045bc8e800190f00cd2051fe93eebad2aec
2,840
adventofcode2022
Apache License 2.0
src/Day16.kt
dakr0013
572,861,855
false
{"Kotlin": 105418}
import kotlin.test.assertEquals fun main() { fun part1(input: List<String>): Int { val releaseRates = parseReleaseRates(input) val directNeighbors = parseDirectNeighbors(input) val travelTimes = getTravelTimesBetweenValves(releaseRates.keys, directNeighbors) val openableValves = releaseRates.filterV...
0
Kotlin
0
0
6b3adb09f10f10baae36284ac19c29896d9993d9
6,005
aoc2022
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12912.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12912 * * 두 정수 a, b가 주어졌을 때 a와 b 사이에 속한 모든 정수의 합을 리턴하는 함수, solution을 완성하세요. * 예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다. * * 제한 조건 * a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요. * a와 b는 -10,000,000 이상 10,000,000 ...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,130
HoOne
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem241/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem241 /** * LeetCode page: [241. Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses/); * * TODO : Analyze the complexity of solution and may relate to the Catalan Numbers ([See Ref](https://people.math.sc.edu/howard/Classes/554b/cat...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,644
hj-leetcode-kotlin
Apache License 2.0
src/Day03.kt
vitind
578,020,578
false
{"Kotlin": 60987}
fun main() { val ARRAY_SIZE = 52 val ARRAY_OFFSET = 26 fun getIndexedCharArray(s: String) : Array<Int> { val indexedCharArray = Array<Int>(ARRAY_SIZE){0} s.forEach { val index = if (it.isLowerCase()) { it.minus('a') } else { // is upper case ...
0
Kotlin
0
0
2698c65af0acd1fce51525737ab50f225d6502d1
1,888
aoc2022
Apache License 2.0
2021/src/main/kotlin/day10.kt
madisp
434,510,913
false
{"Kotlin": 388138}
import utils.Parser import utils.Solution import java.math.BigDecimal fun main() { Day10.run() } object Day10 : Solution<List<String>>() { override val name = "day10" override val parser = Parser.lines fun validate(str: String): Char? { val stack = ArrayDeque<Char>() for (char in str) { when (c...
0
Kotlin
0
1
3f106415eeded3abd0fb60bed64fb77b4ab87d76
1,833
aoc_kotlin
MIT License
src/Day03.kt
JaydenPease
574,590,496
false
{"Kotlin": 11645}
fun main() { // fun part1(input: List<String>): Int { // return input.size // } // // fun part2(input: List<String>): Int { // return input.size // } // test if implementation meets criteria from the description, like: val testInput = readInput("Day03_test") //println(Day03_part1(...
0
Kotlin
0
0
0a5fa22b3653c4b44a716927e2293fc4b2ed9eb7
1,777
AdventOfCode-2022
Apache License 2.0
src/main/kotlin/days/Day04.kt
irmakcelebi
573,174,392
false
{"Kotlin": 6258}
package days import Day fun main() { val day = Day04() day.test1(2) day.test2(4) day.run() } class Day04 : Day() { override fun solve1(lines: List<String>) = lines .map { it.split(',') } .count { (elf1, elf2) -> val section1 = Section.from(elf1) val sec...
0
Kotlin
0
0
fe20c7fd574c505423a9d9be449a42427775ec76
1,251
AdventOfCode2022
Apache License 2.0
src/main/kotlin/days/Day2.kt
teunw
573,164,590
false
{"Kotlin": 20073}
package days class Day2 : Day(2) { private val wins = mapOf( 0 to 1, 1 to 2, 2 to 0 ) private fun getMatchResultPartOne(opponent: Int, me: Int): Int { if (opponent == me) { return 3 } val didIWin = wins[opponent] == me return if (didIWin...
0
Kotlin
0
0
149219285efdb1a4d2edc306cc449cce19250e85
1,265
advent-of-code-22
Creative Commons Zero v1.0 Universal
src/Day05.kt
A55enz10
573,364,112
false
{"Kotlin": 15119}
fun main() { fun part1(input: List<String>): String { val supplies = getInitialStacks(input) val instructions = getInstructions(input) instructions.forEach { val quantity = it[0] val fromStack = it[1]-1 val toStack = it[2]-1 ...
0
Kotlin
0
1
8627efc194d281a0e9c328eb6e0b5f401b759c6c
2,292
advent-of-code-2022
Apache License 2.0
src/main/java/io/github/lunarwatcher/aoc/day8/Day8.kt
LunarWatcher
160,042,659
false
null
package io.github.lunarwatcher.aoc.day8 import io.github.lunarwatcher.aoc.commons.readFile import java.util.* data class Node(val children: List<Node>, val metadata: List<Int>){ val childCount: Int get() = children.size val hasChildren: Boolean get() = children.size > 0 val hasMetadata: B...
0
Kotlin
0
1
99f9b05521b270366c2f5ace2e28aa4d263594e4
2,790
AoC-2018
MIT License
src/com/github/crunchynomnom/aoc2022/puzzles/Day03.kt
CrunchyNomNom
573,394,553
false
{"Kotlin": 14290, "Shell": 518}
package com.github.crunchynomnom.aoc2022.puzzles import Puzzle import java.io.File class Day03 : Puzzle() { override fun part1(input: File) { println(input.readLines().sumOf { getPrio(findMatch(it)) }) } override fun part2(input: File) { println(input.readLines().chunked(3).sumOf { getPri...
0
Kotlin
0
0
88bae9c0ce7f66a78f672b419e247cdd7374cdc1
1,500
advent-of-code-2022
Apache License 2.0
2021/src/test/kotlin/Day21.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import kotlin.math.max import kotlin.math.min import kotlin.test.Test import kotlin.test.assertEquals class Day21 { class DeterministicDie { var rolls: Int = 0 private set private var outcome: Int = 0 fun roll(): Int { outcome = if (outcome == 100) 1 else outcome.i...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
4,367
adventofcode
MIT License
src/Day02/Day02.kt
hectdel
573,376,349
false
{"Kotlin": 5426}
package Day02 import java.io.File fun main() { fun playResult(play: String): Int { val splitPlay = play.split(" ") val play = Play(splitPlay[0], splitPlay[1]); return play.selScore() + play.resScore() } fun playResultPart2(play: String): Int { val splitPlay = play.split("...
0
Kotlin
0
0
cff5677a654a18ceb199cc52fdd1c865dea46e1e
2,474
aco-kotlin-2022
Apache License 2.0
src/test/kotlin/ch/ranil/aoc/aoc2022/Day16.kt
stravag
572,872,641
false
{"Kotlin": 234222}
package ch.ranil.aoc.aoc2022 import ch.ranil.aoc.AbstractDay import org.junit.jupiter.api.Test import kotlin.test.Ignore import kotlin.test.assertEquals object Day16 : AbstractDay() { @Test fun part1Test() { assertEquals(1651, compute1(testInput)) } @Test fun part1Puzzle() { asse...
0
Kotlin
1
0
dbd25877071cbb015f8da161afb30cf1968249a8
4,700
aoc
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec07.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec07 : PuzzleDayTester(7, 2020) { override fun part1(): Int { val tree = Node("shiny gold") val bags = parse() var oldTreeSize: Int // TODO filter the bags or something shit man have some pride ...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
3,650
advent-of-code
MIT License
src/Lesson6Sorting/Distinct.kt
slobodanantonijevic
557,942,075
false
{"Kotlin": 50634}
import java.util.Arrays import java.util.HashSet /** * Scores 100/100 * @param A * @return */ fun solution(A: IntArray?): Int { return Arrays.stream(A).distinct().toArray().size } /** * Manual solution */ fun solution2(A: IntArray): Int { val unique: HashSet<Int> = HashSet<Int>() for (i in A.indic...
0
Kotlin
0
0
155cf983b1f06550e99c8e13c5e6015a7e7ffb0f
1,033
Codility-Kotlin
Apache License 2.0
src/main/kotlin/aoc2023/Day25.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2023 import readInput import java.util.* object Day25 { @JvmInline private value class GroupId(val value: Int) private data class Component(val name: String) { var groupId: GroupId? = null val connections = mutableSetOf<Component>() } private fun parseComponents(input...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
5,251
adventOfCode
Apache License 2.0
src/main/kotlin/algorithm/base.kt
Tiofx
175,697,373
false
null
package algorithm interface IOperator { val C: Set<String> val R: Set<String> } val IOperator.V get() = C union R interface IGroupOperator : IOperator { val operators: List<IOperator> override val C get() = operators.flatMap(IOperator::C).toSet() override val R get() = operators.flatMap(IOperat...
0
Kotlin
0
0
32c1cc3e95940e377ed9a99293eccc871ce13864
2,163
CPF
The Unlicense
src/main/kotlin/day5/solver.kt
derekaspaulding
317,756,568
false
null
package day5 import java.io.File import kotlin.math.pow fun getSeatId(seat: Pair<Int, Int>) = seat.first * 8 + seat.second fun getSeatLocation(seatDescription: String): Pair<Int, Int> { var row = 0 var column = 0 for ((index, char) in seatDescription.substring(0, 7).reversed().withIndex()) { if ...
0
Kotlin
0
0
0e26fdbb3415fac413ea833bc7579c09561b49e5
1,383
advent-of-code-2020
MIT License
AdventOfCodeDay20/src/nativeMain/kotlin/Day20.kt
bdlepla
451,523,596
false
{"Kotlin": 153773}
import kotlin.math.sqrt class Day20(lines: List<String>) { val tiles = mutableListOf<Tile>() init { var currentTile = 0 val tileLines = mutableListOf<String>() lines.forEach { if (it.trim().isNotEmpty()) { if (it.startsWith("Tile")) { if (...
0
Kotlin
0
0
043d0cfe3971c83921a489ded3bd45048f02ce83
3,808
AdventOfCode2020
The Unlicense
src/Day01.kt
henryjcee
573,492,716
false
{"Kotlin": 2217}
fun main() { fun part1(input: List<String>): Int { return input.joinToString("\n") .split("\n\n") .map { it.split("\n") } .map { it.fold(0) { acc, i -> acc + i.toInt() } } .max() } fun part2(input: List<String>): Int { return input.joinToStrin...
0
Kotlin
0
0
2fde9f3db7454583ac9c47cfca524cfa6a16eb61
770
aoc-2022
Apache License 2.0
src/main/kotlin/cc/stevenyin/leetcode/_0027_RemoveElement.kt
StevenYinKop
269,945,740
false
{"Kotlin": 107894, "Java": 9565}
package cc.stevenyin.leetcode /** * https://leetcode.com/problems/remove-element/ * Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you ...
0
Kotlin
0
1
748812d291e5c2df64c8620c96189403b19e12dd
3,194
kotlin-demo-code
MIT License
src/Day12.kt
diego09310
576,378,549
false
{"Kotlin": 28768}
fun main() { data class Coor(var x: Int, var y: Int, var steps: Int) fun isReachable(coor1: Coor, coor2: Coor, map: MutableList<MutableList<Char>>, stepMap: Array<Array<Int>>): Boolean { return ((map[coor2.x][coor2.y].code <= map[coor1.x][coor1.y].code + 1 && map[coor2.x][coor2.y] != 'E') || (map[coor1...
0
Kotlin
0
0
644fee9237c01754fc1a04fef949a76b057a03fc
5,232
aoc-2022-kotlin
Apache License 2.0