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/days/Day19.kt
nuudles
316,314,995
false
null
package days class Day19 : Day(19) { sealed class Rule { data class Letter(val char: String) : Rule() data class RuleSet(val rules: List<List<Int>>) : Rule() } private val rules: Map<Int, Rule> by lazy { val rules = mutableMapOf<Int, Rule>() inputString .split("...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
3,149
advent-of-code-2020
Creative Commons Zero v1.0 Universal
advanced-algorithms/kotlin/src/fP1PrecFMax.kt
nothingelsematters
135,926,684
false
{"Jupyter Notebook": 7400788, "Java": 512017, "C++": 378834, "Haskell": 261217, "Kotlin": 251383, "CSS": 45551, "Vue": 37772, "Rust": 34636, "HTML": 22859, "Yacc": 14912, "PLpgSQL": 10573, "JavaScript": 9741, "Makefile": 8222, "TeX": 7166, "FreeMarker": 6855, "Python": 6708, "OCaml": 5977, "Nix": 5059, "ANTLR": 4802, "...
import java.io.File import java.math.BigInteger import java.util.Scanner private fun scheduleP1PrecFMax( times: List<Int>, functions: List<(Int) -> BigInteger>, prec: Map<Int, List<Int>>, ): Pair<BigInteger, List<Int>> { val n = times.size val children = MutableList(n) { 0 } prec.forEach { (_, ...
0
Jupyter Notebook
3
5
d442a3d25b579b96c6abda13ed3f7e60d1747b53
2,092
university
Do What The F*ck You Want To Public License
src/Day04.kt
josepatinob
571,756,490
false
{"Kotlin": 17374}
fun main() { fun IntRange.containsAll(valueList: List<Int>) = valueList.all { value -> this.contains(value) } fun IntRange.containsAny(valueList: List<Int>) = valueList.any { value -> this.contains(value) } fun part1(input: List<String>): Int { var overlapCount = 0 ...
0
Kotlin
0
0
d429a5fff7ddc3f533d0854e515c2ba4b0d461b0
1,988
aoc-kotlin-2022
Apache License 2.0
src/twentytwentythree/day01/Day01.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day01 import readInput fun main() { fun part1(input: List<String>): Int { return input.sumOf { line -> val filtered = line.filter { it.isDigit() } filtered.first().digitToInt() * 10 + filtered.last().digitToInt() } } fun part2(input: List<String>): Int { val di...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,467
advent-of-code
Apache License 2.0
Day10/src/MonitoringStation.kt
gautemo
225,219,298
false
null
import java.io.File import java.lang.Math.pow import kotlin.math.abs import kotlin.math.atan2 import kotlin.math.sqrt fun main(){ val map = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText() val astroids = getAstroids(map) val best = findBestCount(astroids) pr...
0
Kotlin
0
0
f8ac96e7b8af13202f9233bb5a736d72261c3a3b
2,132
AdventOfCode2019
MIT License
src/day10/Day10.kt
ivanovmeya
573,150,306
false
{"Kotlin": 43768}
package day10 import readInput fun main() { data class Instruction(val cycles: Int, val registryValue: Int? = null) fun parseInstructions(input: List<String>): List<Instruction> { return input.map { if (it.contains(' ')) { val (_, registry) = it.split(' ') ...
0
Kotlin
0
0
7530367fb453f012249f1dc37869f950bda018e0
2,594
advent-of-code-2022
Apache License 2.0
src/main/kotlin/days/Day5.kt
hughjdavey
159,955,618
false
null
package days import util.parallelMap import util.sameLetterDifferentCase class Day5 : Day(5) { override fun partOne(): Int { val reactedPolymer = scanAndReact("", inputString) return reactedPolymer.length - 1 } override fun partTwo(): Int { println("// Day 5 Part 2 takes about 11...
0
Kotlin
0
0
4f163752c67333aa6c42cdc27abe07be094961a7
2,081
aoc-2018
Creative Commons Zero v1.0 Universal
src/Day03.kt
hottendo
572,708,982
false
{"Kotlin": 41152}
fun main() { fun getItemPriority(character: Char): Int { val lowerCaseAsciiOffset = 96 // ascii code of a is 97 val upperCaseAsciiOffset = 64 // ascii code of A is 65 val priority: Int // println("Char: $character - Code: ${character.code}") if (character.code < 97) { // u...
0
Kotlin
0
0
a166014be8bf379dcb4012e1904e25610617c550
2,531
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountAllPossibleRoutes.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,981
kotlab
Apache License 2.0
src/main/kotlin/be/seppevolkaerts/day4/Day4.kt
Cybermaxke
727,453,020
false
{"Kotlin": 35118}
package be.seppevolkaerts.day4 import be.seppevolkaerts.splitInts import kotlin.math.pow fun matches(card: String): Int { val winningAndOurNumbers = card.substringAfter(':', "").split('|') if (winningAndOurNumbers.size < 2) { return 0 } val winningNumbers = winningAndOurNumbers[0].splitInts().toSet() re...
0
Kotlin
0
1
56ed086f8493b9f5ff1b688e2f128c69e3e1962c
1,059
advent-2023
MIT License
src/year_2022/day_04/Day04.kt
scottschmitz
572,656,097
false
{"Kotlin": 240069}
package year_2022.day_04 import readInput data class Assignment( val elfOneSectionIds: List<Int>, val elfTwoSectionIds: List<Int> ) { val assignmentFullyContained: Boolean get() { return elfOneSectionIds.all { it in elfTwoSectionIds } || elfTwoSectionIds.all { it in elfOneSecti...
0
Kotlin
0
0
70efc56e68771aa98eea6920eb35c8c17d0fc7ac
1,737
advent_of_code
Apache License 2.0
app/src/main/kotlin/day05/Day05.kt
W3D3
572,447,546
false
{"Kotlin": 159335}
package day05 import common.InputRepo import common.readSessionCookie import common.solve import util.split fun main(args: Array<String>) { val day = 5 val input = InputRepo(args.readSessionCookie()).get(day = day) solve(day, input, ::solveDay05Part1, ::solveDay05Part2) } fun solveDay05Part1(input: List...
0
Kotlin
0
0
34437876bf5c391aa064e42f5c984c7014a9f46d
2,848
AdventOfCode2022
Apache License 2.0
leetcode2/src/leetcode/evaluate-reverse-polish-notation.kt
hewking
68,515,222
false
null
package leetcode import java.util.* /** * 150. 逆波兰表达式求值 * https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/ * Created by test * Date 2019/9/29 12:55 * Description * 根据逆波兰表示法,求表达式的值。 有效的运算符包括 +, -, *, / 。每个运算对象可以是整数,也可以是另一个逆波兰表达式。 说明: 整数除法只保留整数部分。 给定逆波兰表达式总是有效的。换句话说,表达式总会得出有效数值且不存在除数为 0 的情况。 ...
0
Kotlin
0
0
a00a7aeff74e6beb67483d9a8ece9c1deae0267d
2,697
leetcode
MIT License
src/day19/Parser.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day19 import readInput import java.lang.IllegalArgumentException import java.util.regex.Pattern class Resources { private val data = mutableMapOf<Material, Int> () fun get (material: Material): Int = data[material] ?: 0 fun set (material: Material, count: Int) { data[material] = count ...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
7,050
advent_of_code_2022
Apache License 2.0
src/Day13.kt
ked4ma
573,017,240
false
{"Kotlin": 51348}
import kotlin.math.min /** * [Day13](https://adventofcode.com/2022/day/13) */ private class Day13 { sealed class Packet { abstract fun toData(): Data companion object { fun parse(input: String): Packet { val packet = innerParse(input).second!! // chec...
1
Kotlin
0
0
6d4794d75b33c4ca7e83e45a85823e828c833c62
5,297
aoc-in-kotlin-2022
Apache License 2.0
src/main/kotlin/aoc2022/Day11.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2022 import AoCDay import util.illegalInput private typealias Operation = (Long) -> Long // https://adventofcode.com/2022/day/11 object Day11 : AoCDay<Long>( title = "Monkey in the Middle", part1ExampleAnswer = 10605, part1Answer = 99852, part2ExampleAnswer = 2713310158, part2Answer = ...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
3,525
advent-of-code-kotlin
MIT License
src/main/kotlin/dev/tasso/adventofcode/_2021/day05/Day05.kt
AndrewTasso
433,656,563
false
{"Kotlin": 75030}
package dev.tasso.adventofcode._2021.day05 import dev.tasso.adventofcode.Solution import java.lang.Integer.max class Day05 : Solution<Int> { override fun part1(input: List<String>): Int { val ventLines = input.map { it.split(" -> ").map{it.split(",").map { it.toInt() }}} .map { Line(Coordina...
0
Kotlin
0
0
daee918ba3df94dc2a3d6dd55a69366363b4d46c
1,451
advent-of-code
MIT License
src/Day07.kt
georgiizorabov
573,050,504
false
{"Kotlin": 10501}
import java.lang.Double.min import kotlin.math.min fun main() { class Node( val parent: Node?, val files: MutableList<Pair<String, Int>> = ArrayList(), val dirs: MutableMap<String, Node> = mutableMapOf(), var size: Int = 0 ) var root: Node? = null root = Node(root) ...
0
Kotlin
0
0
bf84e55fe052c9c5f3121c245a7ae7c18a70c699
2,635
aoc2022
Apache License 2.0
src/Day04.kt
wellithy
571,903,945
false
null
package day04 import util.* @JvmInline value class Elf(private val assignment: IntRange) { infix fun contained(other: Elf): Boolean = assignment.first in other.assignment && assignment.last in other.assignment infix fun overlaps(other: Elf): Boolean = assignment.first in other.assignment || a...
0
Kotlin
0
0
6d5fd4f0d361e4d483f7ddd2c6ef10224f6a9dec
1,325
aoc2022
Apache License 2.0
src/main/kotlin/days/Day23.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days @AdventOfCodePuzzle( name = "Unstable Diffusion", url = "https://adventofcode.com/2022/day/23", date = Date(day = 23, year = 2022) ) class Day23(input: List<String>) : Puzzle { private val elfs = input.extract('#') private val dirs = listOf("N", "S", "W", "E") override fun partOn...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,726
advent-of-code-2022
Creative Commons Zero v1.0 Universal
src/Day03.kt
samframpton
572,917,565
false
{"Kotlin": 6980}
fun main() { fun part1(input: List<String>): Int { var sum = 0 for (contents in input) { val first = contents.subSequence(0, contents.length / 2) val second = contents.subSequence(contents.length / 2, contents.length) for (item in first) { if (seco...
0
Kotlin
0
0
e7f5220b6bd6f3c5a54396fa95f199ff3a8a24be
1,124
advent-of-code-2022
Apache License 2.0
src/main/kotlin/fp/kotlin/example/chapter05/Main.kt
funfunStory
101,662,895
false
null
package fp.kotlin.example.chapter05 import fp.kotlin.example.chapter05.FunList.Nil import fp.kotlin.example.chapter05.solution.filter fun main() { val intList = funListOf(1, 2, 3) val doubleList = funListOf(1.0, 2.0, 3.0) printFunList(add3(intList)) // [4, 5, 6] printFunList(product3(doubleLi...
1
Kotlin
23
39
bb10ea01d9f0e1b02b412305940c1bd270093cb6
2,474
fp-kotlin-example
MIT License
src/day04/Day04.kt
iulianpopescu
572,832,973
false
{"Kotlin": 30777}
package day04 import readInput private const val DAY = "04" private const val DAY_TEST = "day${DAY}/Day${DAY}_test" private const val DAY_INPUT = "day${DAY}/Day${DAY}" fun main() { fun intervalMapping(input: List<String>) = input.map { val sections = it.split(',') sections[0].toInterval() to sect...
0
Kotlin
0
0
4ff5afb730d8bc074eb57650521a03961f86bc95
1,327
AOC2022
Apache License 2.0
src/day7/d7_1.kt
svorcmar
720,683,913
false
{"Kotlin": 49110}
fun main() { val input = "" val byTarget = input.lines().map { parseConnection(it) }.associate { it.target to it } val cache = mutableMapOf<String, UShort>() println(eval("a", byTarget, cache)) } enum class Gate { WIRE, NOT, AND, OR, LSHIFT, RSHIFT } data class Connection(val gate: Gate, val leftOp: String, va...
0
Kotlin
0
0
cb097b59295b2ec76cc0845ee6674f1683c3c91f
2,031
aoc2015
MIT License
src/Day10.kt
Flame239
570,094,570
false
{"Kotlin": 60685}
import kotlin.math.abs private fun instructions(): List<Instruction> { return readInput("Day10").map { if (it == "noop") Instruction(0, 1) else Instruction(it.split(" ")[1].toInt(), 2) } } private fun part1(instructions: List<Instruction>): Int { val cyclesToCount = ArrayDeque(listOf(20, 60, 100, 140, 180, 22...
0
Kotlin
0
0
27f3133e4cd24b33767e18777187f09e1ed3c214
1,585
advent-of-code-2022
Apache License 2.0
src/Day05.kt
stevennoto
573,247,572
false
{"Kotlin": 18058}
import java.util.Deque fun main() { fun part1(input: List<String>, numStacks: Int, moveBoxesOneAtATime: Boolean = true): String { // Parse input diagram into 9 dequeues, 1 for each stack of crates, top of stack at ennd of dequeue val stacks = List(numStacks) {ArrayDeque<Char>()} val data = ...
0
Kotlin
0
0
42941fc84d50b75f9e3952bb40d17d4145a3036b
1,673
adventofcode2022
Apache License 2.0
src/main/kotlin/day6/Day6ChronalCoordinates.kt
Zordid
160,908,640
false
null
package day6 import shared.enclosingArea import shared.extractCoordinate import shared.minByIfUnique import shared.readPuzzle fun part1(puzzle: List<String>): Int { val coordinates = puzzle.map { it.extractCoordinate() } val area = coordinates.enclosingArea() val infinite = mutableSetOf<Int>() val ow...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
1,723
adventofcode-kotlin-2018
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions67.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import kotlin.math.pow import kotlin.math.max fun test67() { printlnResult(1, 3, 4, 7) } /** * Questions 67: Find the two numbers in an IntArray(all integers equal or greater than 0) that their results of exclusive or is maximum */ private fun IntArray.maxXor(): Int { ...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,590
Algorithm
Apache License 2.0
src/Day09.kt
arksap2002
576,679,233
false
{"Kotlin": 31030}
import kotlin.math.abs class Point(a: Int, b: Int) { private var x = a private var y = b fun isNear(other: Point): Boolean = abs(x - other.x) <= 1 && abs(y - other.y) <= 1 fun goUp() = y++ fun goDown() = y-- fun goLeft() = x-- fun goRight() = x++ fun goToHead(head: Point) { ...
0
Kotlin
0
0
a24a20be5bda37003ef52c84deb8246cdcdb3d07
2,147
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/io/array/MaxNumberProductThreeNumbers.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
package io.array // https://leetcode.com/problems/maximum-product-of-three-numbers/ class MaxNumberProductThreeNumbers { fun execute(input: IntArray): Int = maxOf( findBiggest(input, 3).reduce { acc, value -> acc * value }, findSmallest(input, 2).reduce { acc, value -> acc * value } * fin...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
1,559
coding
MIT License
src/day16/Day16.kt
Oktosha
573,139,677
false
{"Kotlin": 110908}
package day16 import java.lang.Integer.max import readInput class Valve(val rate: Int, val tunnels: List<String>) fun parseValve(input: String): Pair<String, Valve> { val regex = Regex("""Valve (\p{Upper}{2}) has flow rate=(\d+); tunnels? leads? to valves? (((\p{Upper}{2})(, )?)+)""") val match = rege...
0
Kotlin
0
0
e53eea61440f7de4f2284eb811d355f2f4a25f8c
5,188
aoc-2022
Apache License 2.0
src/Day10.kt
max-zhilin
573,066,300
false
{"Kotlin": 114003}
var cycle = 0 var x = 1 fun process(ticks: Int, operand: Int): Int { var result = 0 repeat(ticks) { cycle++ if ((cycle - 20) % 40 == 0) { result += x * cycle } draw() } x += operand return result } fun processDraw(ticks: Int, operand: Int) { repeat(t...
0
Kotlin
0
0
d9dd7a33b404dc0d43576dfddbc9d066036f7326
1,592
AoC-2022
Apache License 2.0
src/main/kotlin/com/keithwedinger/Day7.kt
jkwuc89
112,970,285
false
null
package com.keithwedinger import java.io.InputStream import kotlin.math.absoluteValue /** * Day 7 Puzzle * http://adventofcode.com/2017/day/7 * * @author <NAME> <br> * Created On: 12/14/17 */ class Day7 { private val utils = Utils() /** * Part 1 */ fun findBottomProgram(programTowerInputS...
0
Kotlin
0
0
3b88f64a498e4640b021cc91160a5adfcb01d0ec
4,372
adventofcode
Apache License 2.0
src/Day11.kt
EdoFanuel
575,561,680
false
{"Kotlin": 80963}
class Monkey(private val items: MutableList<Long>, private val operation: Char, private val value: Int, val divisor: Int, private val passTarget: Int, private val failTarget: Int) { var itemsProcessed = 0L fun addItem(item: Long) { items ...
0
Kotlin
0
0
46a776181e5c9ade0b5e88aa3c918f29b1659b4c
3,601
Advent-Of-Code-2022
Apache License 2.0
2021/src/main/kotlin/Day11.kt
eduellery
433,983,584
false
{"Kotlin": 97092}
class Day11(input: List<String>) { private val grid = OctopusGrid.parse(input) fun solve1(): Int { return (1..100).sumOf { grid.increase() grid.flash().also { grid.reset() } } } fun solve2(): Int { return 1 + generateSequence { grid.increase...
0
Kotlin
0
1
3e279dd04bbcaa9fd4b3c226d39700ef70b031fc
2,545
adventofcode-2021-2025
MIT License
kotlin/src/katas/kotlin/leetcode/add_two_numbers/AddTwoNumbers.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.leetcode.add_two_numbers import nonstdlib.printed import datsok.shouldEqual import org.junit.Test import kotlin.random.Random /** * You are given two non-empty linked lists representing two non-negative integers. * The digits are stored in reverse order and each of their nodes contain a single ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
2,946
katas
The Unlicense
src/main/kotlin/aoc2021/day11.kt
sodaplayer
434,841,315
false
{"Kotlin": 31068}
package aoc2021 import aoc2021.utils.head import aoc2021.utils.loadInput import aoc2021.utils.tail fun main() { val grid = loadInput("/2021/day11") .bufferedReader() .readLines() .flatMap { it.asSequence() } .mapIndexed { i, c -> i to (c.code - 48) } .to...
0
Kotlin
0
0
2d72897e1202ee816aa0e4834690a13f5ce19747
4,029
aoc-kotlin
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch2/Problem28.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch2 import java.math.BigInteger import kotlin.math.ceil /** * Problem 28: Number Spiral Diagonals * * https://projecteuler.net/problem=28 * * Goal: Return the sum (mod 1e9 + 7) of the diagonal numbers in an NxN grid that is generated * using a spiral pattern. * * Constraints: 1 <= N <= ...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,144
project-euler-kotlin
MIT License
src/Day02.kt
copperwall
572,339,673
false
{"Kotlin": 7027}
import kotlin.Exception const val TIE = 3 const val LOSE = 0 const val WIN = 6 enum class Move { ROCK, PAPER, SCISSORS } enum class Outcome { LOSS, TIE, WIN } fun stringToOutcome(s: String): Outcome { return when (s) { "X" -> Outcome.LOSS "Y" -> Outcome.TIE "Z" -> Outcome.WIN ...
0
Kotlin
0
1
f7b856952920ebd651bf78b0e15e9460524c39bb
2,854
advent-of-code-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day15.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.* fun main() = Day15.run() object Day15: Day(2022, 15) { private val dirs = mutableListOf(Point(1, 1), Point(-1, 1), Point(-1, -1), Point(1, -1)) private val beacons = input.lines().map { ints(it) }.map { (_, _, x2, y2) -> P(x2, y2) }.toSet() ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,800
adventofkotlin
MIT License
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12954_x_n.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/12954 * * 문제 설명 * 함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. * 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요. * * 제한 조건 * x는 -10000000 이상, 10000000 이하인 정수입니다. * n은 1000 이하인 자연...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,115
HoOne
Apache License 2.0
src/main/kotlin/day21/day21.kt
corneil
572,437,852
false
{"Kotlin": 93311, "Shell": 595}
package day21 import day21.Day21.eval import main.utils.measureAndPrint import space.kscience.kmath.functions.ListRationalFunction import space.kscience.kmath.functions.ListRationalFunctionSpace import space.kscience.kmath.functions.listRationalFunctionSpace import space.kscience.kmath.operations.JBigIntegerField impo...
0
Kotlin
0
0
dd79aed1ecc65654cdaa9bc419d44043aee244b2
5,694
aoc-2022-in-kotlin
Apache License 2.0
AdventOfCodeDay20/src/nativeMain/kotlin/Day20a.kt
bdlepla
451,510,571
false
{"Kotlin": 165771}
data class Point2d(val x:Int, val y:Int) class Day20a(lines:List<String>) { val input = lines.takeWhile{it.isNotEmpty()}.joinToString("") private val algorithmString: String = input.map { if (it == '#') '1' else '0' }.joinToString("") private val startingImage: List<String> = parseInput(lines) fun sol...
0
Kotlin
0
0
1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871
2,014
AdventOfCode2021
The Unlicense
src/Day02.kt
BionicCa
574,904,899
false
{"Kotlin": 20039}
import kotlin.random.Random enum class RockPaperScissors(val shapeScore: Int) { ROCK(1), PAPER(2), SCISSORS(3) } enum class GameState(val roundScore: Int) { LOSS(0), DRAW(3), WIN(6) } fun main() { fun part1(input: List<String>): Int { val operations = input.map { it.split(' ')} var score ...
0
Kotlin
0
0
ed8bda8067386b6cd86ad9704bda5eac81bf0163
3,114
AdventOfCode2022
Apache License 2.0
src/main/kotlin2023/Day001.kt
teodor-vasile
573,434,400
false
{"Kotlin": 41204}
package main.kotlin2023 class Day001 { fun part1(input: String): Int { val data = parseInput(input) return data.map { row -> row.find { it.isDigit() }.toString() + row.findLast { it.isDigit() }.toString() } .sumOf { it.toInt() } } fun part2(input: String): Int { val dat...
0
Kotlin
0
0
2fcfe95a05de1d67eca62f34a1b456d88e8eb172
1,161
aoc-2022-kotlin
Apache License 2.0
kotlin/1160-find-words-that-can-be-formed-by-characters.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}
class Solution { fun countCharacters(words: Array<String>, chars: String): Int { val charMap = chars.groupingBy { it }.eachCount() var res = 0 outer@for (word in words) { val wordMap = word.groupingBy { it }.eachCount() for ((ch, cnt) in wordMap) { if ...
337
JavaScript
2,004
4,367
0cf38f0d05cd76f9e96f08da22e063353af86224
1,470
leetcode
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/KSmallestPairs.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,118
kotlab
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions91.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.special import kotlin.math.min fun test91() { printlnResult(arrayOf( intArrayOf(17, 2, 16), intArrayOf(15, 14, 5), intArrayOf(13, 3, 1), )) } /** * Questions 91: Paint houses to red, green or blue. The houses that nearby can't be painted with same colo...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,915
Algorithm
Apache License 2.0
src/y2015/Day08.kt
gaetjen
572,857,330
false
{"Kotlin": 325874, "Mermaid": 571}
package y2015 import util.readInput object Day08 { fun part1(input: List<String>): Int { val quotes = input.sumOf { str -> str.count { it == '"' } } val backs = input.sumOf { it.split(Regex("\\\\\\\\")).count() - 1 } val hex = input.sumOf { ...
0
Kotlin
0
0
d0b9b5e16cf50025bd9c1ea1df02a308ac1cb66a
1,231
advent-of-code
Apache License 2.0
src/day19/Day19.kt
ayukatawago
572,742,437
false
{"Kotlin": 58880}
package day19 import readInput fun main() { val testInput = readInput("day19/test") val blueprints = testInput.mapNotNull { val regex = """Blueprint (\d+): Each ore robot costs (\d+) ore. Each clay robot costs (\d+) ore. Each obsidian robot costs (\d+) ore and (\d+) clay. Each geode robot...
0
Kotlin
0
0
923f08f3de3cdd7baae3cb19b5e9cf3e46745b51
5,877
advent-of-code-2022
Apache License 2.0
y2016/src/main/kotlin/adventofcode/y2016/Day01.kt
Ruud-Wiegers
434,225,587
false
{"Kotlin": 503769}
package adventofcode.y2016 import adventofcode.io.AdventSolution import adventofcode.util.collections.firstDuplicate import adventofcode.util.collections.onlyChanges import adventofcode.util.vector.Direction import adventofcode.util.vector.Vec2 object Day01 : AdventSolution(2016, 1, "No Time for a Taxicab") { ov...
0
Kotlin
0
3
fc35e6d5feeabdc18c86aba428abcf23d880c450
1,986
advent-of-code
MIT License
src/main/kotlin/y2015/day02/Day02.kt
TimWestmark
571,510,211
false
{"Kotlin": 97942, "Shell": 1067}
package y2015.day02 fun main() { AoCGenerics.printAndMeasureResults( part1 = { part1() }, part2 = { part2() } ) } data class Present( val length: Int, val width: Int, val height: Int, ) fun Present.calculatePaperNeeded(): Int { return 2 * length * width + 2 * width * height + ...
0
Kotlin
0
0
23b3edf887e31bef5eed3f00c1826261b9a4bd30
1,174
AdventOfCode
MIT License
src/Day04.kt
cypressious
572,898,685
false
{"Kotlin": 77610}
fun main() { fun parse(line: String) = line .split(',') .map { val (start, end) = it.split('-').map(String::toInt) start..end } fun IntRange.includes(range: IntRange) = range.first in this && range.last in this fun IntRange.overlaps(range: IntRange) = range.f...
0
Kotlin
0
1
7b4c3ee33efdb5850cca24f1baa7e7df887b019a
1,000
AdventOfCode2022
Apache License 2.0
src/questions/NextGreaterElement.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe import java.util.* /** * The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. * * You are given two distinct 0-indexed integer arrays nums1 and nums2, where n...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
4,912
algorithms
MIT License
src/main/kotlin/days/Day7.kt
butnotstupid
571,247,661
false
{"Kotlin": 90768}
package days class Day7 : Day(7) { override fun partOne(): Any { val root = Directory("/", null) readInput(root) return getAllSizesThat(root) { it < 100000 }.sum() } override fun partTwo(): Any { val root = Directory("/", null) readInput(root) val (totalSiz...
0
Kotlin
0
0
4760289e11d322b341141c1cde34cfbc7d0ed59b
3,408
aoc-2022
Creative Commons Zero v1.0 Universal
src/Day10.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { abstract class Triable { abstract fun tryObservation(cycle: Int, reg: Int): Triable abstract fun value(): Any } data class State(val cycle: Int, val reg: Int, val triable: Triable) data class SumSignalStrengths(val value: Int) : Triable() { override fun tryObservat...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
2,493
advent_of_code_2022
Apache License 2.0
src/main/kotlin/days/Day11.kt
butnotstupid
433,717,137
false
{"Kotlin": 55124}
package days class Day11 : Day(11) { override fun partOne(): Any { val grid = inputList.map { it.map { Character.getNumericValue(it) }.toTypedArray() }.toTypedArray() return generateSequence { step(grid) }.take(100).sum() } override fun partTwo(): Any { val grid = inputList.map { ...
0
Kotlin
0
0
a06eaaff7e7c33df58157d8f29236675f9aa7b64
1,835
aoc-2021
Creative Commons Zero v1.0 Universal
day3/day3/src/main/kotlin/Day4.kt
teemu-rossi
437,894,529
false
{"Kotlin": 28815, "Rust": 4678}
val CARD_WIDTH = 5 val CARD_HEIGHT = 5 fun List<Int>.isBingo(inputs: List<Int>) = this.all { inputs.contains(it) } data class BingoCard( val numbers: List<Int> ) { fun get(row: Int, column: Int): Int = numbers[row * CARD_WIDTH + column] fun getRow(row: Int) = (0 until CARD_WIDTH).map { get(row, it) } ...
0
Kotlin
0
0
16fe605f26632ac2e134ad4bcf42f4ed13b9cf03
2,246
AdventOfCode
MIT License
src/main/kotlin/de/dikodam/day07/Day07.kt
dikodam
317,290,436
false
null
package de.dikodam.day07 import de.dikodam.AbstractDay fun main() { Day07()() } private typealias DirectedAcyclWeightedGraph = List<Node> private typealias Node = Pair<String, NodeChildren> private typealias NodeChildren = List<Pair<String, Int>> class Day07 : AbstractDay() { override fun task1(): String { ...
0
Kotlin
0
0
dc70d185cb9f6fd7d69bd1fe74c6dfc8f4aac097
49,340
adventofcode2020
MIT License
src/main/kotlin/g2001_2100/s2035_partition_array_into_two_arrays_to_minimize_sum_difference/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2035_partition_array_into_two_arrays_to_minimize_sum_difference // #Hard #Array #Dynamic_Programming #Binary_Search #Two_Pointers #Bit_Manipulation #Ordered_Set // #Bitmask #2023_06_23_Time_1318_ms_(100.00%)_Space_53.2_MB_(100.00%) class Solution { fun minimumDifference(nums: IntArray): Int { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,247
LeetCode-in-Kotlin
MIT License
src/main/kotlin/com/staricka/adventofcode2023/days/Day12.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day class Day12: Day { enum class Condition { OPERATIONAL, BROKEN, UNKNOWN; companion object { fun fromChar(c: Char): Condition { return when (c) { '.' -> OPER...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
4,082
adventOfCode2023
MIT License
solutions/src/LongestPalindrome.kt
JustAnotherSoftwareDeveloper
139,743,481
false
{"Kotlin": 305071, "Java": 14982}
import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet class LongestPalindrome { //https://leetcode.com/problems/longest-palindromic-substring/description/ fun longestPalindrome(s: String): String { if (s == null || s.length <= 1) { return s } ...
0
Kotlin
0
0
fa4a9089be4af420a4ad51938a276657b2e4301f
2,195
leetcode-solutions
MIT License
src/Day02.kt
zoidfirz
572,839,149
false
{"Kotlin": 15878}
fun main() { partOneSolution(readInput("main/resources/Day02_Input")) partTwoSolution(readInput("main/resources/Day02_Input")) } private fun partOneSolution(records: List<String>) { var sum = 0 val newRecords = records.map { it.split(" ") } for (record in newRecords) { val p1Record = reco...
0
Kotlin
0
0
e955c1c08696f15929aaf53731f2ae926c585ff3
4,088
kotlin-advent-2022
Apache License 2.0
kotlin/structures/MetricTree.kt
polydisc
281,633,906
true
{"Java": 540473, "Kotlin": 515759, "C++": 265630, "CMake": 571}
package structures import java.util.Random // https://en.wikipedia.org/wiki/Metric_tree class MetricTree(var x: IntArray, var y: IntArray) { fun build(low: Int, high: Int) { if (high - low <= 2) return swap(low + rnd.nextInt(high - low), low) val mid = low + 1 + high ushr 1 nth_ele...
1
Java
0
0
4566f3145be72827d72cb93abca8bfd93f1c58df
3,906
codelibrary
The Unlicense
src/Day16.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import java.lang.IllegalArgumentException data class Valve(val name: String, val flowRate: Int, val connectionNames: List<String>) fun buildSystem(valves: List<Valve>): ValveSystem { val valvesByName = valves.associateByTo(mutableMapOf()) { it.name } val toOpen = valves.filter { it.flowRate > 0 }.toMutableSet...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
4,830
advent-of-code-2022
Apache License 2.0
src/Day16.kt
armandmgt
573,595,523
false
{"Kotlin": 47774}
fun main() { data class Valve(val key: String, val rate: Int, val tunnels: List<String>) val valvePattern = Regex("Valve (\\w+) has flow rate=(\\d+);") val tunnelsPattern = Regex("tunnels? leads? to valves? ([\\w, ]+)") fun parseGraph(input: List<String>): Map<String, Valve> { val graph = mutab...
0
Kotlin
0
1
0d63a5974dd65a88e99a70e04243512a8f286145
3,388
advent_of_code_2022
Apache License 2.0
src/main/kotlin/day09/Day09.kt
TheSench
572,930,570
false
{"Kotlin": 128505}
package day09 import runDay import toUnit import utils.Point import kotlin.math.abs fun main() { fun part1(input: List<String>) = input.toMoves() .fold(Rope(2)) { path, next -> // TODO: Condense repeat(next.distance) { path.moveHead(next.dire...
0
Kotlin
0
0
c3e421d75bc2cd7a4f55979fdfd317f08f6be4eb
2,391
advent-of-code-2022
Apache License 2.0
src/main/kotlin/g2901_3000/s2976_minimum_cost_to_convert_string_i/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2976_minimum_cost_to_convert_string_i // #Medium #Array #String #Graph #Shortest_Path // #2024_01_19_Time_421_ms_(85.29%)_Space_46_MB_(61.76%) import kotlin.math.min class Solution { fun minimumCost( inputText: String, desiredText: String, fromLetters: CharArray, ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,321
LeetCode-in-Kotlin
MIT License
aoc-day15/src/Day15.kt
rnicoll
438,043,402
false
{"Kotlin": 90620, "Rust": 1313}
import java.nio.file.Files import java.nio.file.Path import java.util.* fun main() { val map = Files.readAllLines(Path.of("input")).map { line -> line.toCharArray().map { it.toString().toInt() }.toIntArray() }.toTypedArray() println(part1(map)) println(part2(map)) } private...
0
Kotlin
0
0
8c3aa2a97cb7b71d76542f5aa7f81eedd4015661
2,537
adventofcode2021
MIT License
src/main/kotlin/com/sk/topicWise/dp/hard/1335. Minimum Difficulty of a Job Schedule.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.dp.hard class Solution1335 { fun minDifficulty(jobDifficulty: IntArray, days: Int): Int { val SIZE = jobDifficulty.size if (SIZE < days) return -1 fun minAt(startIndex: Int, d: Int): Int { if (d == 0 && startIndex == SIZE) return 0 if (d =...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
2,410
leetcode-kotlin
Apache License 2.0
src/Day18.kt
GarrettShorr
571,769,671
false
{"Kotlin": 82669}
import kotlin.math.abs fun main() { data class Cube(val x: Int, val y: Int, val z: Int) { fun isAdjacent(other: Cube): Boolean { if (x == other.x && y == other.y) { return abs(z - other.z) == 1 } else if (y == other.y && z == other.z) { return abs(x - other.x) == 1 } else if (z...
0
Kotlin
0
0
391336623968f210a19797b44d027b05f31484b5
4,915
AdventOfCode2022
Apache License 2.0
src/main/aoc2018/Day23.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2018 import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.math.min class Day23(input: List<String>) { data class Pos(val x: Int, val y: Int, val z: Int) data class Nanobot(val pos: Pos, val range: Int) { fun inRange(other: Nanobot): Boolean { return ab...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
9,102
aoc
MIT License
src/Day04.kt
ka1eka
574,248,838
false
{"Kotlin": 36739}
fun main() { fun expand(assigment: String): Set<Int> = assigment .split('-') .map { it.toInt() } .let { Pair(it[0], it[1]) } .let { (it.first..it.second).toSet() } fun part1(input: List<String>): Int = input .map { it.split(',') } .map { Pair( ...
0
Kotlin
0
0
4f7893448db92a313c48693b64b3b2998c744f3b
898
advent-of-code-2022
Apache License 2.0
src/Day04.kt
maewCP
579,203,172
false
{"Kotlin": 59412}
fun main() { val regex = "(\\d+)-(\\d+),(\\d+)-(\\d+)".toRegex() fun part1(input: List<String>): Int { var containCount = 0 input.forEach { line -> val g = regex.find(line)!!.destructured.toList().map { it.toInt() } if ((g[0] <= g[2] && g[1] >= g[3]) || (g[2] <= g[0] && ...
0
Kotlin
0
0
8924a6d913e2c15876c52acd2e1dc986cd162693
960
advent-of-code-2022-kotlin
Apache License 2.0
src/year2022/day24/Day24.kt
kingdongus
573,014,376
false
{"Kotlin": 100767}
package year2022.day24 import Point2D import readInputFileByYearAndDay import readTestFileByYearAndDay enum class Action(val offset: Point2D) { UP(Point2D(0, -1)), DOWN(Point2D(0, 1)), RIGHT(Point2D(1, 0)), LEFT(Point2D(-1, 0)), WAIT(Point2D(0, 0)); companion object { infix fun from(s...
0
Kotlin
0
0
aa8da2591310beb4a0d2eef81ad2417ff0341384
3,986
advent-of-code-kotlin
Apache License 2.0
src/main/kotlin/aoc23/Day02.kt
asmundh
573,096,020
false
{"Kotlin": 56155}
package aoc23 import runTask import toOnlyInteger import utils.InputReader import java.lang.IllegalStateException import kotlin.math.max fun day2part1(input: List<String>): Int { val games = input.map { parseGame(it) } val legalGames = games.filter { game -> game.sets.all { it.red <= 12 &&...
0
Kotlin
0
0
7d0803d9b1d6b92212ee4cecb7b824514f597d09
1,807
advent-of-code
Apache License 2.0
src/main/kotlin/year2022/day-07.kt
ppichler94
653,105,004
false
{"Kotlin": 182859}
package year2022 import lib.aoc.Day import lib.aoc.Part fun main() { Day(7, 2022, PartA7(), PartB7()).run() } open class PartA7 : Part() { data class File(val name: String, val size: Int) data class Directory(val name: String, val parent: Directory?) { val directories = mutableListOf<Directory>...
0
Kotlin
0
0
49dc6eb7aa2a68c45c716587427353567d7ea313
3,644
Advent-Of-Code-Kotlin
MIT License
src/twentytwentythree/day06/Day06.kt
colinmarsch
571,723,956
false
{"Kotlin": 65403, "Python": 6148}
package twentytwentythree.day06 import readInput fun main() { fun part1(input: List<String>): Int { val times = input[0].split(" ").mapNotNull { it.toIntOrNull() } val distances = input[1].split(" ").mapNotNull { it.toIntOrNull() } var sum = 1 for (i in times.indices) { var ways = 0 val...
0
Kotlin
0
0
bcd7a08494e6db8140478b5f0a5f26ac1585ad76
1,150
advent-of-code
Apache License 2.0
solution/kotlin/aoc/src/main/kotlin/codes/jakob/aoc/Day10_fucked.kt
loehnertz
573,145,141
false
{"Kotlin": 53239}
package codes.jakob.aoc import codes.jakob.aoc.ClockCircuit.Instruction.Type.ADD_X import codes.jakob.aoc.ClockCircuit.Instruction.Type.NOOP import codes.jakob.aoc.ClockCircuit.Register import codes.jakob.aoc.shared.splitMultiline import java.util.* class Day10_fucked : Solution() { override fun solvePart1(input:...
0
Kotlin
0
0
ddad8456dc697c0ca67255a26c34c1a004ac5039
4,388
advent-of-code-2022
MIT License
src/Day09.kt
laricchia
434,141,174
false
{"Kotlin": 38143}
import org.jetbrains.kotlinx.multik.api.toNDArray import org.jetbrains.kotlinx.multik.ndarray.data.D2Array import org.jetbrains.kotlinx.multik.ndarray.data.get fun firstPart09(list : List<List<Int>>) { val caveHeatMap = list.toNDArray() val rows = caveHeatMap.shape[0] val cols = caveHeatMap.shape[1] ...
0
Kotlin
0
0
7041d15fafa7256628df5c52fea2a137bdc60727
3,397
Advent_of_Code_2021_Kotlin
Apache License 2.0
src/day01/Puzzle1.kt
tmikulsk1
573,165,106
false
{"Kotlin": 25281}
package day01 import readInput /** * Advent of Code 2022 * Day 1 / Puzzle 1 * @author tmikulsk1 * * 1st read input values * 2nd separate calories carried per elf * 3rd separate and convert calories per elf * p1: sum total amount of calories per elf * p2: show top three calories sum * final: print answers *...
0
Kotlin
0
1
f5ad4e601776de24f9a118a0549ac38c63876dbe
1,531
AoC-22
Apache License 2.0
2021/kotlin/src/main/kotlin/com/codelicia/advent2021/Day09.kt
codelicia
627,407,402
false
{"Kotlin": 49578, "PHP": 554, "Makefile": 293}
package com.codelicia.advent2021 import java.util.Stack class Day09(private val input: List<String>) { private fun parseHeightmap(xs: List<String>): List<List<Int>> = xs.map { it.toCharArray().map(Char::digitToInt) } private fun <T> List<List<T>>.getLocation(p: Pair<Int, Int>): T? = this.get...
2
Kotlin
0
0
df0cfd5c559d9726663412c0dec52dbfd5fa54b0
2,865
adventofcode
MIT License
src/main/kotlin/com/rtarita/days/Day7.kt
RaphaelTarita
570,100,357
false
{"Kotlin": 79822}
package com.rtarita.days import com.rtarita.structure.AoCDay import com.rtarita.util.day import kotlinx.datetime.LocalDate object Day7 : AoCDay { private sealed class TreeNode { abstract val parent: IntermediateNode? abstract val size: Int fun root(): IntermediateNode { var cu...
0
Kotlin
0
9
491923041fc7051f289775ac62ceadf50e2f0fbe
3,845
AoC-2022
Apache License 2.0
src/Day13/Day13.kt
Nathan-Molby
572,771,729
false
{"Kotlin": 95872, "Python": 13537, "Java": 3671}
package Day13 import readInput import java.util.PriorityQueue import kotlin.math.* class Index(var index: Int = 0) fun main() { fun processInput(input: List<String>): List<List<String>> { return input .withIndex() .groupBy { it.index / 3 } .map { it.value.map { it.val...
0
Kotlin
0
0
750bde9b51b425cda232d99d11ce3d6a9dd8f801
4,045
advent-of-code-2022
Apache License 2.0
src/Day10.kt
kenyee
573,186,108
false
{"Kotlin": 57550}
fun main() { // ktlint-disable filename fun part1(input: List<String>): Long { var registerX = 1 val signalStrengths = mutableListOf<Long>() var cycle = 1 fun checkCycleStrengths(startCheckCycle: Int = 20, cycleCheckPoint: Int = 40) { if ((cycle - startCheckCycle).rem(c...
0
Kotlin
0
0
814f08b314ae0cbf8e5ae842a8ba82ca2171809d
2,572
KotlinAdventOfCode2022
Apache License 2.0
LeetCode/0416. Partition Equal Subset Sum/Soution.kt
InnoFang
86,413,001
false
{"C++": 501928, "Kotlin": 291271, "Python": 280936, "Java": 78746, "Go": 43858, "JavaScript": 27490, "Rust": 6410}
/** * Created by <NAME> on 2017/12/9. */ class Solution { private val memo = MutableList<MutableList<Int>>(0) { MutableList<Int>(0) { 0 } } fun canPartition(nums: IntArray): Boolean { if (nums.isEmpty() || nums.sum() and 1 == 1) return false val par = nums.sum() shr 1 memo.addAll(M...
0
C++
8
20
2419a7d720bea1fd6ff3b75c38342a0ace18b205
3,266
algo-set
Apache License 2.0
codeforces/polynomial2022/d.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.polynomial2022 import java.lang.StringBuilder private fun solve() { val (hei, wid) = readInts() val a = List(hei) { readInts() } val aSum = a.map { it.sum() }.toIntArray() val totalOnes = aSum.sum() if (totalOnes % hei != 0) return println(-1) val needOnes = totalOnes / hei val ans = StringB...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
1,112
competitions
The Unlicense
src/main/kotlin/day13/Day13.kt
Avataw
572,709,044
false
{"Kotlin": 99761}
package day13 fun solveA(input: List<String>): Int { val pairs = input.chunked(3).map { signal -> Pair(Packet(signal[0]).also { it.initialize() }, Packet(signal[1]).also { it.initialize() }) } val result = pairs.mapIndexedNotNull { index, it -> if (it.first...
0
Kotlin
2
0
769c4bf06ee5b9ad3220e92067d617f07519d2b7
3,565
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumGap.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2021 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
3,889
kotlab
Apache License 2.0
src/day05/Code.kt
ldickmanns
572,675,185
false
{"Kotlin": 48227}
package day05 import readInput fun main() { val input = readInput("day05/input") // val input = readInput("day05/input_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): String { val separatorLine = input.indexOfFirst { it.isEmpty() } val startConfiguration ...
0
Kotlin
0
0
2654ca36ee6e5442a4235868db8174a2b0ac2523
2,516
aoc-kotlin-2022
Apache License 2.0
src/day6/puzzle06.kt
brendencapps
572,821,792
false
{"Kotlin": 70597}
package day6 import Puzzle import PuzzleInput import java.io.File class Day6PuzzleInput(private val input: String, val numMarkers: Int, expectedResult: Int? = null) : PuzzleInput<Int>(expectedResult) { fun getPuzzleInput(): String { val puzzleInput = File(input).readText() check(puzzleInput.length...
0
Kotlin
0
0
00e9bd960f8bcf6d4ca1c87cb6e8807707fa28f3
2,919
aoc_2022
Apache License 2.0
src/main/kotlin/day13/Day13.kt
limelier
725,979,709
false
{"Kotlin": 48112}
package day13 import common.InputReader import common.split private fun List<String>.checkMirroredHorizontal(rowsBefore: Int): Boolean { for (row in rowsBefore..<this.size) { val rowMir = rowsBefore * 2 - row - 1 if (rowMir !in indices) break if (this[row] != this[rowMir]) return false ...
0
Kotlin
0
0
0edcde7c96440b0a59e23ec25677f44ae2cfd20c
1,895
advent-of-code-2023-kotlin
MIT License
src/Day23.kt
sabercon
648,989,596
false
null
fun main() { fun move(current: Int, linkMap: MutableMap<Int, Int>): Int { val picked = generateSequence(current) { linkMap[it]!! } .drop(1).take(3).toList() val destination = generateSequence(current - 1) { it - 1 } .map { if (it < 1) linkMap.size + it else it } ....
0
Kotlin
0
0
81b51f3779940dde46f3811b4d8a32a5bb4534c8
1,177
advent-of-code-2020
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaxRunTime.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,776
kotlab
Apache License 2.0
src/Day03.kt
Soykaa
576,055,206
false
{"Kotlin": 14045}
private fun getPriority(itemType: Char): Int = if (itemType in 'a'..'z') itemType - 'a' + 1 else itemType - 'A' + 27 private fun findIntersection(items: String): List<Int> { val (fstPart, sndPart) = items.chunked(items.length / 2) return fstPart.toSet().intersect(sndPart.toSet()).map { getPriority(it) ...
0
Kotlin
0
0
1e30571c475da4db99e5643933c5341aa6c72c59
823
advent-of-kotlin-2022
Apache License 2.0
src/Day03.kt
emersonf
572,870,317
false
{"Kotlin": 17689}
typealias Item = Char val Item.priority: Int get() = when (this) { in 'a'..'z' -> this - 'a' + 1 in 'A'..'Z' -> this - 'A' + 27 else -> throw IllegalStateException() } fun main() { fun part1(input: List<String>): Int = input.sumOf { val (sack1, sack2) = it.chunk...
0
Kotlin
0
0
0e97351ec1954364648ec74c557e18ccce058ae6
1,361
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/advent/day3/BinaryDiagnostic.kt
hofiisek
434,171,205
false
{"Kotlin": 51627}
package advent.day3 import advent.loadInput import java.io.File /** * @author <NAME> */ fun part1(input: File) { val lines = input.readLines() val numBits = lines.firstOrNull()?.length ?: throw IllegalArgumentException("Empty input") lines .map { bits -> bits.map { it.digitToInt() } } // strin...
0
Kotlin
0
2
3bd543ea98646ddb689dcd52ec5ffd8ed926cbbb
2,518
Advent-of-code-2021
MIT License
src/main/kotlin/aoc2023/Day14.kt
lukellmann
574,273,843
false
{"Kotlin": 175166}
package aoc2023 import AoCDay // https://adventofcode.com/2023/day/14 object Day14 : AoCDay<Int>( title = "Parabolic Reflector Dish", part1ExampleAnswer = 136, part1Answer = 106378, part2ExampleAnswer = 64, part2Answer = 90795, ) { private fun List<String>.tiltNorth(): List<String> { v...
0
Kotlin
0
1
344c3d97896575393022c17e216afe86685a9344
2,624
advent-of-code-kotlin
MIT License
src/main/kotlin/Day13.kt
andrewrlee
434,584,657
false
{"Kotlin": 29493, "Clojure": 14117, "Shell": 398}
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 object Day13 { data class Coord(val x: Int, val y: Int) { constructor(coord: Pair<Int, Int>) : this(coord.first, coord.second) } enum class Direction { x { override fun extract(c: Coord) = c.x overr...
0
Kotlin
0
0
aace0fccf9bb739d57f781b0b79f2f3a5d9d038e
2,894
adventOfCode2021
MIT License
src/Day03.kt
iam-afk
572,941,009
false
{"Kotlin": 33272}
fun main() { fun priority(type: Char): Int = when (type) { in 'a'..'z' -> type - 'a' + 1 in 'A'..'Z' -> type - 'A' + 27 else -> error("unknown type '$type'") } fun part1(input: List<String>): Int = input.sumOf { val first = it.substring(0, it.length / 2).toSet() val...
0
Kotlin
0
0
b30c48f7941eedd4a820d8e1ee5f83598789667b
910
aockt
Apache License 2.0