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/day13/day14.kt
HGilman
572,891,570
false
{"Kotlin": 109639, "C++": 5375, "Python": 400}
package day13 import readInput import readTextGroups import java.util.Stack import kotlin.math.min fun main() { val day = 13 val testInput = readTextGroups("day$day/testInput") // check(part1(testInput) == 1) getSubLists("[1,[2,[3,[4,[5,6,7]]]],8,9]") println() getSubLists("[[1],[2,3,4]]") ...
0
Kotlin
0
1
d05a53f84cb74bbb6136f9baf3711af16004ed12
2,429
advent-of-code-2022
Apache License 2.0
src/main/kotlin/14-jun.kt
aladine
276,334,792
false
{"C++": 70308, "Kotlin": 53152, "Java": 10020, "Makefile": 511}
class Solution14Jun { fun findCheapestPrice(n: Int, flights: Array<IntArray>, src: Int, dst: Int, K: Int): Int { val adjList: HashMap<Int, HashSet<Pair<Int, Int>>> = HashMap() for (f in flights) { adjList .computeIfAbsent(f[0]) { HashSet() } .add(Pair<Int...
0
C++
1
1
54b7f625f6c4828a72629068d78204514937b2a9
2,584
awesome-leetcode
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/TopKFrequentElements.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
4,651
kotlab
Apache License 2.0
src/aoc2022/Day03.kt
RobertMaged
573,140,924
false
{"Kotlin": 225650}
package aoc2022 fun main() { fun Set<Char>.calculatePriority(): Int = sumOf { duplicatedItemChar -> if (duplicatedItemChar.isLowerCase()) (duplicatedItemChar.code % 'a'.code) + 1 else (duplicatedItemChar.code % 'A'.code) + 27 } fun part1(input: List<String>): Int...
0
Kotlin
0
0
e2e012d6760a37cb90d2435e8059789941e038a5
1,059
Kotlin-AOC-2023
Apache License 2.0
src/Day03.kt
jorgecastrejon
573,097,701
false
{"Kotlin": 33669}
fun main() { fun part1(input: List<String>): Int = input.sumOf { rucksack -> findMisplacedItem(rucksack).priority } fun part2(input: List<String>): Int = input.chunked(3).sumOf { group -> findBadge(group).priority } val input = readInput("Day03") println(part1(input)) println(pa...
0
Kotlin
0
0
d83b6cea997bd18956141fa10e9188a82c138035
806
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/LongestCommonSubsequence.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,048
kotlab
Apache License 2.0
src/Day09.kt
uekemp
575,483,293
false
{"Kotlin": 69253}
import kotlin.math.absoluteValue import kotlin.math.sign data class Motion(var dx: Int, var dy: Int) { fun isDone(): Boolean { return dx == 0 && dy == 0 } fun move(knot: Knot) { if (isDone()) { error("Motion is exhausted") } val sx = dx.sign val sy = dy...
0
Kotlin
0
0
bc32522d49516f561fb8484c8958107c50819f49
3,496
advent-of-code-kotlin-2022
Apache License 2.0
src/Day05.kt
diesieben07
572,879,498
false
{"Kotlin": 44432}
private val file = "Day05" private class CrateStack { private val stack: ArrayDeque<Char> = ArrayDeque() fun takeTop(): Char { return stack.removeFirst() } fun takeTop(n: Int): List<Char> { val subList = stack.subList(0, n) val result = subList.toList() subList.clear...
0
Kotlin
0
0
0b9993ef2f96166b3d3e8a6653b1cbf9ef8e82e6
2,883
aoc-2022
Apache License 2.0
src/aoc2022/Day06.kt
Playacem
573,606,418
false
{"Kotlin": 44779}
package aoc2022 import utils.readInput object Day06 { override fun toString(): String { return this.javaClass.simpleName } } fun main() { fun findIndexWithPrecedingNUniqueValues(input: String, n: Int): Int { val res = input.windowed(size = n + 1, step = 1).find { it.toCharArra...
0
Kotlin
0
0
4ec3831b3d4f576e905076ff80aca035307ed522
1,835
advent-of-code-2022
Apache License 2.0
src/Day10.kt
StephenVinouze
572,377,941
false
{"Kotlin": 55719}
import java.lang.IllegalArgumentException data class Instruction( val cyclesCount: Int, val value: Int, ) fun main() { fun List<String>.toInstructions(): List<Instruction> = map { when { it.startsWith("noop") -> Instruction(1, 0) it.startsWith("addx") -...
0
Kotlin
0
0
11b9c8816ded366aed1a5282a0eb30af20fff0c5
2,022
AdventOfCode2022
Apache License 2.0
src/main/kotlin/day3/Day3.kt
stoerti
726,442,865
false
{"Kotlin": 19680}
package io.github.stoerti.aoc.day3 import io.github.stoerti.aoc.IOUtils fun main(args: Array<String>) { val schematics = Schematics(IOUtils.readInput("day_3_input")) val result1 = schematics.lines.mapIndexed { index, _ -> schematics.scanForPartNumbers(index) } .onEach { println(it) } .map { it.sumOf { it...
0
Kotlin
0
0
05668206293c4c51138bfa61ac64073de174e1b0
2,480
advent-of-code
Apache License 2.0
src/Day10.kt
hrach
572,585,537
false
{"Kotlin": 32838}
sealed interface Command { data class Addx(val n: Int) : Command object Noop : Command } fun main() { fun parse(input: List<String>): List<Command> = input .filter { it.isNotBlank() } .map { when (it.substring(0, 4)) { "addx" -> Command.Ad...
0
Kotlin
0
1
40b341a527060c23ff44ebfe9a7e5443f76eadf3
2,710
aoc-2022
Apache License 2.0
src/lib/Grid.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
package lib import kotlin.math.abs enum class Direction { RIGHT, DOWN, LEFT, UP; fun turnRight(): Direction = rotate(1) fun turnLeft(): Direction = rotate(3) fun turnAround(): Direction = rotate(2) private fun rotate(turn: Int): Direction = Direction.values()[(ordinal + turn) % 4] } enum class Adjacenc...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
5,627
aoc-kotlin
Apache License 2.0
src/main/kotlin/days/aoc2022/Day7.kt
bjdupuis
435,570,912
false
{"Kotlin": 537037}
package days.aoc2022 import days.Day class Day7 : Day(2022, 7) { override fun partOne(): Any { return calculateSumOfDirectoriesUnder100000(inputList) } override fun partTwo(): Any { return calculateSmallestDirectoryThatCanBeDeleted(inputList) } fun calculateSmallestDirectoryThatC...
0
Kotlin
0
1
c692fb71811055c79d53f9b510fe58a6153a1397
2,524
Advent-Of-Code
Creative Commons Zero v1.0 Universal
src/main/kotlin/com/hj/leetcode/kotlin/problem912/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem912 /** * LeetCode page: [912. Sort an Array](https://leetcode.com/problems/sort-an-array/); * * TODO : Add Heap Sort solution; */ class Solution { /* Complexity: * Time O(NLogN) and Space O(N) where N is the size of nums; */ fun sortArray(nums: IntArray): In...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
2,389
hj-leetcode-kotlin
Apache License 2.0
src/Day05.kt
jinie
572,223,871
false
{"Kotlin": 76283}
import java.util.Stack class Day05(input: String) { private val stacks = prepareStacks(input.substringBefore("\n\n").lines()) private val pattern = """move (\d+) from (\d+) to (\d+)""".toRegex() private val commands = input.substringAfter("\n\n").lines() .map { pattern.matchEntire(it)!!.destructure...
0
Kotlin
0
0
4b994515004705505ac63152835249b4bc7b601a
1,727
aoc-22-kotlin
Apache License 2.0
src/com/ncorti/aoc2023/Day03.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 import kotlin.math.pow fun main() { fun part1(): Long { val matrix = getInputAsText("03") { split("\n").filter(String::isNotBlank).map { it.toCharArray() } }.toTypedArray() var result = 0L var foundNumberList = mutableListOf<Pair<Int, Int>>()...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
3,977
adventofcode-2023
MIT License
packages/solutions/src/Day03.kt
ffluk3
576,832,574
false
{"Kotlin": 21246, "Shell": 85}
fun main() { fun getScore(char: Char): Int { if (char.isUpperCase()) { return char.code + 26 - 64 } else { return char.code - 96 } } fun getCommonLetters(str1: String, str: String): List<Char> { val res = mutableSetOf<Char>() str1.toList().for...
0
Kotlin
0
0
f9b68a8953a7452d804990e01175665dffc5ab6e
1,768
advent-of-code-2022
Apache License 2.0
src/main/kotlin/day05/Solution.kt
TestaDiRapa
573,066,811
false
{"Kotlin": 50405}
package day05 import java.io.File import java.util.* data class Move( val qty: Int, val source: String, val dest: String ) fun parseStack(rawInput: List<String>): Map<String, Stack<Char>> = (1 .. 9).fold(emptyMap()) { acc, it -> acc + (it.toString() to rawInput .last() ...
0
Kotlin
0
0
b5b7ebff71cf55fcc26192628738862b6918c879
2,959
advent-of-code-2022
MIT License
advent-of-code/src/main/kotlin/DayThree.kt
pauliancu97
518,083,754
false
{"Kotlin": 36950}
class DayThree { enum class Direction(val id: Char) { North('^'), South('v'), East('>'), West('<'); companion object { fun getDirection(char: Char) = Direction.values().firstOrNull { it.id == char } } } fun String.toDirections() =...
0
Kotlin
0
0
3ba05bc0d3e27d9cbfd99ca37ca0db0775bb72d6
3,099
advent-of-code-2015
MIT License
2017/13-packet_scanners/src/main/kotlin/de/qwhon/aoc/PacketScanner.kt
frankschmitt
227,218,372
false
{"Elm": 170193, "Python": 143983, "Rust": 116065, "Haskell": 33760, "Clojure": 16809, "Java": 16591, "Crystal": 15064, "R": 12840, "JavaScript": 9484, "Elixir": 5192, "Lua": 5085, "C++": 4720, "Go": 4052, "Raku": 3667, "Kotlin": 3478, "Ruby": 2983, "OCaml": 2957, "F#": 2554, "Shell": 1647, "Julia": 1437, "HTML": 767, "...
package de.qwhon.aoc import java.io.File /** A simple helper class for keeping track of scanners. * */ data class ScannerRecord(val depth: Int, val range: Int) /** parse the input file, and return a List of scanner records. * */ fun parseInputFile(fileName: String): List<ScannerRecord> { val file = File(fil...
0
Elm
0
0
69f2dad6ae39a316b13a0d7fb77669d4a66c4da8
1,938
advent_of_code
MIT License
part-1.kt
shyzus
733,207,050
false
{"Kotlin": 3146}
import java.io.File fun main() { val lines = File("input.txt").readLines() val partNumbers = ArrayList<Int>() lines.forEachIndexed { idx, line -> val top: String val mid: String val bot: String when (idx) { 0 -> { top = "" mid ...
0
Kotlin
0
0
80f003dbf169168251f2e05639298d4aaa33c02c
3,146
AoC2023-Day-3
MIT License
src/day12/Day12.kt
pnavais
574,712,395
false
{"Kotlin": 54079}
package day12 import readInput import java.util.* typealias NodeGrid = MutableList<MutableList<Node>> data class Id(val x: Int, val y: Int) data class Path(val cost: Int = 1, val targetNode: Node) class Node(private val id: Id, private val c: Char) { var pathValue: Int = -1 var visited: Boolean = false ...
0
Kotlin
0
0
ed5f521ef2124f84327d3f6c64fdfa0d35872095
6,248
advent-of-code-2k2
Apache License 2.0
src/main/kotlin/de/niemeyer/aoc2022/Day13.kt
stefanniemeyer
572,897,543
false
{"Kotlin": 175820, "Shell": 133}
/** * Advent of Code 2022, Day 13: Distress Signal * Problem Description: https://adventofcode.com/2022/day/13 */ package de.niemeyer.aoc2022 import kotlinx.serialization.* import kotlinx.serialization.json.* import de.niemeyer.aoc.utils.Resources.resourceAsText import de.niemeyer.aoc.utils.getClassName @Serializ...
0
Kotlin
0
0
ed762a391d63d345df5d142aa623bff34b794511
2,622
AoC-2022
Apache License 2.0
src/main/kotlin/adventofcode/y2021/Day14.kt
Tasaio
433,879,637
false
{"Kotlin": 117806}
import adventofcode.BigIntegerMap import adventofcode.countOfEachCharacter import adventofcode.runDay fun main() { val testInput = """ NNCB CH -> B HH -> N CB -> H NH -> C HB -> C HC -> B HN -> C NN -> C BH -> H NC -> B ...
0
Kotlin
0
0
cc72684e862a782fad78b8ef0d1929b21300ced8
2,422
adventofcode2021
The Unlicense
src/main/kotlin/aoc2022/Day25.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import readInput typealias SNAFU = String object Day25 { private fun Char.digitFromSNAFU(): Int { return when (this) { '=' -> -2 '-' -> -1 else -> this.digitToInt() } } private fun SNAFU.toDecimal(): Long { val array = this.toC...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
1,637
adventOfCode
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/BinaryTreeCameras.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,214
kotlab
Apache License 2.0
src/Day03.kt
ambrosil
572,667,754
false
{"Kotlin": 70967}
fun main() { fun Set<Char>.score(): Int { val c = single() return if (c.isLowerCase()) { 1 + (c - 'a') } else { 27 + (c - 'A') } } fun String.halve(): List<String> { val half = length / 2 return listOf(substring(0, half), substring(ha...
0
Kotlin
0
0
ebaacfc65877bb5387ba6b43e748898c15b1b80a
976
aoc-2022
Apache License 2.0
src/Day20.kt
Fedannie
572,872,414
false
{"Kotlin": 64631}
const val DECRYPTION_KEY = 811589153L fun main() { fun List<Long>.grove(): Long { return listOf(1000, 2000, 3000).sumOf { this[(indexOf(0) + it) % size] } } fun parseInput(input: List<String>, key: Long = 1): List<Long> { return input.map { it.toLong() * key } } fun mix(order: List<Long>, values: L...
0
Kotlin
0
0
1d5ac01d3d2f4be58c3d199bf15b1637fd6bcd6f
1,348
Advent-of-Code-2022-in-Kotlin
Apache License 2.0
src/questions/SearchRange.kt
realpacific
234,499,820
false
null
package questions import _utils.UseCommentAsDocumentation import utils.shouldBe /** * Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of * a given target value. If target is not found in the array, return [-1, -1]. * * [Source](https://leetcode.com/problems/fi...
4
Kotlin
5
93
22eef528ef1bea9b9831178b64ff2f5b1f61a51f
2,241
algorithms
MIT License
app/src/test/java/com/zwq65/unity/algorithm/unionfind/LeetCode959.kt
Izzamuzzic
95,655,850
false
{"Kotlin": 449365, "Java": 17918}
package com.zwq65.unity.algorithm.unionfind import org.junit.Test /** * ================================================ * <p> * <a href="https://leetcode-cn.com/problems/regions-cut-by-slashes">959. 由斜杠划分区域</a>. * Created by NIRVANA on 2019/7/15. * Contact with <<EMAIL>> * =====================================...
0
Kotlin
0
0
98a9ad7bb298d0b0cfd314825918a683d89bb9e8
2,233
Unity
Apache License 2.0
solutions/src/Day05.kt
khouari1
573,893,634
false
{"Kotlin": 132605, "HTML": 175}
fun main() { fun part1(input: List<String>): String = getTopCrates(input) { from, to, numberToMove -> for (i in 1..numberToMove) { val poppedChar = from.removeLast() to.addLast(poppedChar) } } fun part2(input: List<String>): String = getTopCrates(input) { from, to, n...
0
Kotlin
0
1
b00ece4a569561eb7c3ca55edee2496505c0e465
2,690
advent-of-code-22
Apache License 2.0
src/main/kotlin/com/nibado/projects/advent/y2020/Day14.kt
nielsutrecht
47,550,570
false
null
package com.nibado.projects.advent.y2020 import com.nibado.projects.advent.Day import com.nibado.projects.advent.resourceLines object Day14 : Day { private interface Day14Input private data class Mask(val mask: String) : Day14Input private data class Mem(val index: Int, val value: Int) : Day14Input p...
1
Kotlin
0
15
b4221cdd75e07b2860abf6cdc27c165b979aa1c7
2,372
adventofcode
MIT License
src/main/kotlin/day4/Day4ReposeRecord.kt
Zordid
160,908,640
false
null
package day4 import shared.extractAllInts import shared.readPuzzle data class Guard(val id: Int) { private val minuteStatistics = IntArray(60) val totalMinutesAsleep get() = minuteStatistics.sum() val maxMinuteAsleepCount get() = minuteStatistics.max() val maxMinuteAsleep get() = minuteStatistics.ind...
0
Kotlin
0
0
f246234df868eabecb25387d75e9df7040fab4f7
1,569
adventofcode-kotlin-2018
Apache License 2.0
year2023/src/main/kotlin/net/olegg/aoc/year2023/day18/Day18.kt
0legg
110,665,187
false
{"Kotlin": 511989}
package net.olegg.aoc.year2023.day18 import net.olegg.aoc.someday.SomeDay import net.olegg.aoc.utils.Directions import net.olegg.aoc.utils.Directions.D import net.olegg.aoc.utils.Directions.L import net.olegg.aoc.utils.Directions.R import net.olegg.aoc.utils.Directions.U import net.olegg.aoc.utils.Vector2D import net....
0
Kotlin
1
7
e4a356079eb3a7f616f4c710fe1dfe781fc78b1a
1,417
adventofcode
MIT License
src/Day03.kt
yeung66
574,904,673
false
{"Kotlin": 8143}
fun main() { fun getPriority(c: Char): Int = when(c) { in ('a'..'z') -> c - 'a' + 1 else -> c - 'A' + 27 } fun part1(input: List<String>): Int { return input.sumOf { it.subSequence(0, it.length / 2).toSet().intersect(it.subSequence(it.length / 2, it.length).toSet()).map(::getPriorit...
0
Kotlin
0
0
554217f83e81021229759bccc8b616a6b270902c
682
advent-of-code-2022-kotlin
Apache License 2.0
src/main/kotlin/nl/tiemenschut/aoc/y2023/day13.kt
tschut
723,391,380
false
{"Kotlin": 61206}
package nl.tiemenschut.aoc.y2023 import nl.tiemenschut.aoc.lib.dsl.aoc import nl.tiemenschut.aoc.lib.dsl.day import nl.tiemenschut.aoc.lib.dsl.parser.InputParser import nl.tiemenschut.aoc.lib.util.grid.CharGridParser import nl.tiemenschut.aoc.lib.util.grid.Grid import nl.tiemenschut.aoc.lib.util.points.by import nl.ti...
0
Kotlin
0
1
a1ade43c29c7bbdbbf21ba7ddf163e9c4c9191b3
2,635
aoc-2023
The Unlicense
src/Day14.kt
zfz7
573,100,794
false
{"Kotlin": 53499}
import kotlin.math.abs fun main() { println(day14A(readFile("Day14"))) println(day14B(readFile("Day14"))) } fun generateGrid(input: String, addFloor: Boolean = false ): MutableList<MutableList<Char>> { val rocks = input.trim().split("\n").flatMap { line -> line.split(" -> ").windowed(2).flatMap { ...
0
Kotlin
0
0
c50a12b52127eba3f5706de775a350b1568127ae
3,890
AdventOfCode22
Apache License 2.0
src/main/kotlin/com/github/brpeterman/advent2022/CrateCrane.kt
brpeterman
573,059,778
false
{"Kotlin": 53108}
package com.github.brpeterman.advent2022 import java.util.* class CrateCrane { data class CrateState(val stacks: MutableMap<Int, LinkedList<Char>>, val moves: List<CrateMove>) data class CrateMove(val count: Int, val from: Int, val to: Int) fun reportStacks(stacks: List<LinkedList<Char>>): String { ...
0
Kotlin
0
0
1407ca85490366645ae3ec86cfeeab25cbb4c585
2,613
advent2022
MIT License
src/Day05.kt
Feketerig
571,677,145
false
{"Kotlin": 14818}
import java.util.InputMismatchException fun main(){ data class Move(val count: Int, val from: Int, val to: Int) fun parse(input: List<String>): Pair<List<MutableList<Char>>, List<Move>>{ val emptyLineIndex = input.indexOfFirst { line -> line.isBlank() } val numberOfStacks = input[emptyLineIn...
0
Kotlin
0
0
c65e4022120610d930293788d9584d20b81bc4d7
1,921
Advent-of-Code-2022
Apache License 2.0
src/main/kotlin/com/simiacryptus/util/index/FindCompressionPrefixes.kt
SimiaCryptus
737,271,270
false
{"Kotlin": 55470}
package com.simiacryptus.util.index import com.simiacryptus.util.files.XElements import com.simiacryptus.util.files.elements import com.simiacryptus.util.files.until import java.util.* fun FileIndexer.findCompressionPrefixes(threshold: Int, count: Int): Array<Pair<String, Int>> { val returnMap = TreeMap<String, Int...
0
Kotlin
0
0
685824833817ea5aadd5ba21ccba91b71597adf5
2,652
DataGnome
Apache License 2.0
src/Day22.kt
shepard8
573,449,602
false
{"Kotlin": 73637}
enum class Direction { Right, Down, Left, Up } enum class CellType { OutsideMap, Ground, Wall } fun main() { class Position(val row: Int, val column: Int, val direction: Direction): Comparable<Position> { fun next(): Position { return when (direction) { Direction.Right -> Positi...
0
Kotlin
0
1
81382d722718efcffdda9b76df1a4ea4e1491b3c
7,410
aoc2022-kotlin
Apache License 2.0
src/Day23.kt
i-tatsenko
575,595,840
false
{"Kotlin": 90644}
import Direction23.* private enum class Direction23 { NORTH { override fun safeZone(p: Point): List<Point> = safeRange(p.y) { y -> Point(p.x - 1, y) } override fun move(p: Point): Point = Point(p.x - 1, p.y) }, EAST { override fun safeZone(p: Point): List<Point> = safeRange(p.x) { ...
0
Kotlin
0
0
0a9b360a5fb8052565728e03a665656d1e68c687
4,433
advent-of-code-2022
Apache License 2.0
EvoMaster/core/src/main/kotlin/org/evomaster/core/problem/util/StringSimilarityComparator.kt
mitchellolsthoorn
364,836,402
false
{"Java": 3999651, "JavaScript": 2621912, "Kotlin": 2157071, "TypeScript": 137702, "CSS": 94780, "HTML": 35418, "Less": 29035, "Python": 25019, "R": 20339, "ANTLR": 12520, "XSLT": 6892, "Shell": 5833, "TeX": 4838, "Dockerfile": 493}
package org.evomaster.core.problem.util import java.util.ArrayList /** * created by manzh on 2019-08-31 */ object StringSimilarityComparator { const val SimilarityThreshold = 0.6 fun isSimilar(str1: String, str2: String, algorithm: SimilarityAlgorithm = SimilarityAlgorithm.Trigrams, threshold : Double = S...
0
Java
1
0
50e9fb327fe918cc64c6b5e30d0daa2d9d5d923f
1,816
ASE-Technical-2021-api-linkage-replication
MIT License
archive/2022/Day07.kt
mathijs81
572,837,783
false
{"Kotlin": 167658, "Python": 725, "Shell": 57}
private const val EXPECTED_1 = 95437L private const val EXPECTED_2 = 24933642L private class Day07(isTest: Boolean) : Solver(isTest) { fun constructDirSizes(): Map<String, Long> { val currentDir = mutableListOf<String>() val sizeMap = mutableMapOf<String, Long>() readAsLines().forEach { lin...
0
Kotlin
0
2
92f2e803b83c3d9303d853b6c68291ac1568a2ba
1,887
advent-of-code-2022
Apache License 2.0
src/main/kotlin/dev/bogwalk/batch5/Problem53.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.batch5 import dev.bogwalk.util.combinatorics.binomialCoefficient import java.math.BigInteger /** * Problem 53: Combinatoric Selections * * https://projecteuler.net/problem=53 * * Goal: Count the values of C(n, r), for 1 <= n <= N, that are greater than K. Values do not * have to be distinct....
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
3,892
project-euler-kotlin
MIT License
src/commonMain/kotlin/org/jetbrains/packagesearch/packageversionutils/normalization/VeryLenientDateTimeExtractor.kt
JetBrains
498,634,573
false
{"Kotlin": 44145}
package org.jetbrains.packagesearch.packageversionutils.normalization import kotlinx.datetime.* object VeryLenientDateTimeExtractor { /** * This list of patterns is sorted from longest to shortest. It's generated * by combining these base patterns: * * `yyyy/MM/dd_HH:mm:ss` * * `yyyy/MM/dd_...
0
Kotlin
2
4
4a9cf732526a0cd177dbaadb786bd2e41903a33e
2,881
package-search-version-utils
Apache License 2.0
src/Day20.kt
kpilyugin
572,573,503
false
{"Kotlin": 60569}
fun main() { class PLong(val value: Long) { override fun toString() = value.toString() } fun solve(input: List<String>, key: Long, repeatMix: Int): Long { val initial = input.map { PLong(it.toLong() * key) } val n = initial.size val mixed = initial.toMutableList() r...
0
Kotlin
0
1
7f0cfc410c76b834a15275a7f6a164d887b2c316
1,184
Advent-of-Code-2022
Apache License 2.0
src/Day10.kt
punx120
573,421,386
false
{"Kotlin": 30825}
import java.lang.StringBuilder fun main() { class Node(val length: Int, val arg: Int) { var startCycle: Int = -1 } fun parseInstructions(input: List<String>): ArrayDeque<Node> { val instructions = ArrayDeque<Node>() input.map { it.split(" ") } .map { instructions.add(N...
0
Kotlin
0
0
eda0e2d6455dd8daa58ffc7292fc41d7411e1693
1,653
aoc-2022
Apache License 2.0
src/main/kotlin/Main.kt
NicLeenknegt
342,582,751
false
null
import java.io.File data class Matrix( val matrix:Array<ArrayList<String>>, var row:Int = 0, var column:Int = 0 ) fun main(args: Array<String>) { var words:Array<String> = splitStringByDelimiter(readFile("./input.txt"), "\n") printStringArray(words) var maxWordLength = words.map{ it:String -...
0
Kotlin
0
0
11081ceafa98be1453f31249b88268a47de2b6e8
2,559
kenze_exercise
Creative Commons Zero v1.0 Universal
src/main/kotlin/dev/shtanko/algorithms/leetcode/RangeSumOfBinarySearchTreeIterative.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,207
kotlab
Apache License 2.0
src/Day06.kt
GreyWolf2020
573,580,087
false
{"Kotlin": 32400}
fun main() { fun part1(signal: String, n: Int = 4): Int = firstNUniqueCharacters(signal = signal, n = n) fun part2(signal: String, n: Int = 14): Int = firstNUniqueCharacters(signal = signal, n = n) // test if implementation meets criteria from the description, like: // table test of part1 // val te...
0
Kotlin
0
0
498da8861d88f588bfef0831c26c458467564c59
1,325
aoc-2022-in-kotlin
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/DistantBarcodes.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,441
kotlab
Apache License 2.0
src/main/kotlin/day9.kt
p88h
317,362,882
false
null
fun part1(nums: List<Long>): Long { var sums = HashMap<Long, Long>() for (a in nums.indices) { val b = a - 25 if (b >= 0 && nums[a] !in sums) { println(nums[a]) return nums[a] } for (c in b + 1 until a) { if (b >= 0) { // remove...
0
Kotlin
0
5
846ad4a978823563b2910c743056d44552a4b172
1,273
aoc2020
The Unlicense
classroom/src/main/kotlin/com/radix2/algorithms/week3/CountingInversionsV1.kt
rupeshsasne
190,130,318
false
{"Java": 66279, "Kotlin": 50290}
package com.radix2.algorithms.week3 fun sort(array: Array<Int>): Long { return sort(array, Array(array.size) { 0 }, 0, array.size - 1) } fun sort(array: Array<Int>, aux: Array<Int>, lo: Int, hi: Int): Long { if (lo >= hi) return 0 val mid = lo + (hi - lo) / 2 var inversions: Long inversions = s...
0
Java
0
1
341634c0da22e578d36f6b5c5f87443ba6e6b7bc
1,190
coursera-algorithms-part1
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/GraphConnectivityWithThreshold.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2022 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in w...
4
Kotlin
0
19
776159de0b80f0bdc92a9d057c852b8b80147c11
2,478
kotlab
Apache License 2.0
src/main/aoc2022/Day13.kt
nibarius
154,152,607
false
{"Kotlin": 963896}
package aoc2022 import java.util.* class Day13(input: List<String>) { sealed class Entry { data class Value(val value: Int) : Entry() data class AList(val list: MutableList<Entry> = mutableListOf()) : Entry() } private val packetPairs = input .map { rawPairs -> rawPai...
0
Kotlin
0
6
f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22
3,537
aoc
MIT License
src/Day02.kt
mrwhoknows55
573,993,349
false
{"Kotlin": 4863}
import java.io.File fun main() { val input = File("src/day02_input.txt").readText().split("\n") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { var score = 0 input.forEach { val oppMove = Move.getMoveObj(it[0]) ?: return@part1 (score) val myMove ...
0
Kotlin
0
1
f307e524412a3ed27acb93b7b9aa6aa7269a6d03
1,770
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/hj/leetcode/kotlin/problem1913/Solution.kt
hj-core
534,054,064
false
{"Kotlin": 619841}
package com.hj.leetcode.kotlin.problem1913 import kotlin.math.max import kotlin.math.min /** * LeetCode page: [1913. Maximum Product Difference Between Two Pairs](https://leetcode.com/problems/maximum-product-difference-between-two-pairs/); */ class Solution { /* Complexity: * Time O(N) and Space O(1) wher...
1
Kotlin
0
1
14c033f2bf43d1c4148633a222c133d76986029c
1,715
hj-leetcode-kotlin
Apache License 2.0
src/easy/_14LongestCommonPrefix.kt
ilinqh
390,190,883
false
{"Kotlin": 382147, "Java": 32712}
package easy import kotlin.math.min /** * 数据量不大的前提下,用双层 for 循环更加高效 */ class _14LongestCommonPrefix { class Solution { private lateinit var strList: Array<String> fun longestCommonPrefix(strs: Array<String>): String { if (strs.isEmpty()) { return "" } ...
0
Kotlin
0
0
8d2060888123915d2ef2ade293e5b12c66fb3a3f
1,892
AlgorithmsProject
Apache License 2.0
src/Day07.kt
anilkishore
573,688,256
false
{"Kotlin": 27023}
class Dir(val par: Dir? = null, var size: Int = 0, val subDirs: HashMap<String, Dir> = hashMapOf()) fun main() { var part2ans: Int = 7e7.toInt() fun foldSizes(cur: Dir) { for (subDir in cur.subDirs.values) { foldSizes(subDir) cur.size += subDir.size } } fun fi...
0
Kotlin
0
0
f8f989fa400c2fac42a5eb3b0aa99d0c01bc08a9
1,435
AOC-2022
Apache License 2.0
kotlin/src/katas/kotlin/sort/mergesort/MergeSort4.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.sort.mergesort import nonstdlib.listOfInts import nonstdlib.permutations import nonstdlib.printed import datsok.shouldEqual import org.junit.Test import java.util.* import kotlin.collections.ArrayList import kotlin.random.Random class MergeSort4Tests { @Test fun `trivial examples`() { ...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
3,009
katas
The Unlicense
p03/src/main/kotlin/NoMatterHowYouSliceIt.kt
jcavanagh
159,918,838
false
null
package p03 import common.file.readLines inline fun <reified T> aggregateClaims(claims: List<Claim>, init: () -> T, delegate: (T, Claim) -> T): Array<Array<T>> { val maxX = claims.maxBy { it.maxX }!!.maxX val maxY = claims.maxBy { it.maxY }!!.maxY val claimMap = Array(maxX) { Array(maxY) { init() } } for(cl...
0
Kotlin
0
0
289511d067492de1ad0ceb7aa91d0ef7b07163c0
1,380
advent2018
MIT License
src/Day11.kt
risboo6909
572,912,116
false
{"Kotlin": 66075}
var M = 1.toULong() data class Monkey(var items: ArrayDeque<ULong>, var op: ((ULong) -> ULong)?, var test: ((ULong) -> Int)?, var inspect: ULong, private val useModulo: Boolean) { constructor(useModulo: Boolean) : this(ArrayDeque<ULong>(), null, null, 0.toULong(), useModulo) } fun main() { ...
0
Kotlin
0
0
bd6f9b46d109a34978e92ab56287e94cc3e1c945
4,062
aoc2022
Apache License 2.0
2022/src/day10/day10.kt
Bridouille
433,940,923
false
{"Kotlin": 171124, "Go": 37047}
package day10 import GREEN import RESET import printTimeMillis import readInput // Hey fab // returns a map of {cycle -> X register} fun computeInstructions(input: List<String>): Map<Int, Int> { var xRegister = 1 var cycle = 1 val memory = mutableMapOf(1 to 1) input.forEach { if (it == "noop"...
0
Kotlin
0
2
8ccdcce24cecca6e1d90c500423607d411c9fee2
1,635
advent-of-code
Apache License 2.0
src/main/kotlin/g2901_3000/s2920_maximum_points_after_collecting_coins_from_all_nodes/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2901_3000.s2920_maximum_points_after_collecting_coins_from_all_nodes // #Hard #Array #Dynamic_Programming #Depth_First_Search #Tree #Bit_Manipulation // #2023_12_31_Time_2255_ms_(25.00%)_Space_112.1_MB_(100.00%) import kotlin.math.max class Solution { private lateinit var adjList: Array<MutableList<Int>...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,749
LeetCode-in-Kotlin
MIT License
kotlin/src/com/daily/algothrim/leetcode/medium/ThreeSum.kt
idisfkj
291,855,545
false
null
package com.daily.algothrim.leetcode.medium /** * 15. 三数之和 * 给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重复的三元组。 * 注意:答案中不可以包含重复的三元组。 */ class ThreeSum { companion object { @JvmStatic fun main(args: Array<String>) { println(ThreeSum().threeSum(intAr...
0
Kotlin
9
59
9de2b21d3bcd41cd03f0f7dd19136db93824a0fa
2,049
daily_algorithm
Apache License 2.0
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round1/Questions46.kt
qiaoyuang
100,944,213
false
{"Kotlin": 338134}
package com.qiaoyuang.algorithm.round1 import kotlin.math.abs fun test46() { printlnResult(12258) printlnResult(-12258) printlnResult(1225825) printlnResult(0) printlnResult(-25262526) } /** * Questions 46: Translate integer to string, 0-a, 1-b, 2-c...24-y, 25-z. Find the amount of kinds of tra...
0
Kotlin
3
6
66d94b4a8fa307020d515d4d5d54a77c0bab6c4f
1,536
Algorithm
Apache License 2.0
src/day04/Day04.kt
TimberBro
572,681,059
false
{"Kotlin": 20536}
package day04 import readInput import toInt fun main() { fun stringToPairs(it: String): Pair<IntRange, IntRange> { val assignments = it.split(",") val firstSplit = assignments[0].split("-") val secondSplit = assignments[1].split("-") return firstSplit[0].toInt()..firstSplit[1].toIn...
0
Kotlin
0
0
516a98e5067d11f0e6ff73ae19f256d8c1bfa905
1,488
AoC2022
Apache License 2.0
src/Day10.kt
JanTie
573,131,468
false
{"Kotlin": 31854}
import kotlin.math.absoluteValue fun main() { fun parseInput(input: List<String>): List<Int> { return input.map { it.split(" ") } .flatMap { when (it.first()) { "noop" -> listOf(0) "addx" -> listOf(0, it[1].toInt()) els...
0
Kotlin
0
0
3452e167f7afe291960d41b6fe86d79fd821a545
1,601
advent-of-code-2022
Apache License 2.0
src/main/kotlin/com/colinodell/advent2022/Extensions.kt
colinodell
572,710,708
false
{"Kotlin": 105421}
package com.colinodell.advent2022 import kotlin.math.max fun <T> Iterable<T>.chunkedBy(separator: (T) -> Boolean): List<List<T>> = fold(mutableListOf(mutableListOf<T>())) { acc, t -> if (separator(t)) { acc.add(mutableListOf()) } else { acc.last().add(t) } a...
0
Kotlin
0
1
32da24a888ddb8e8da122fa3e3a08fc2d4829180
1,986
advent-2022
MIT License
codeforces/round680/a.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.round680 private fun solve(): Long { val (p, q) = readLongs() if (p % q != 0L) return p val xs = primeFactorization(q) var ans = 1L for (i in xs) { var pp = p while (pp % q == 0L && pp % i == 0L) pp /= i if (pp % q != 0L) ans = maxOf(ans, pp) } return ans } fun primeFactorization(n: Lo...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
903
competitions
The Unlicense
solutions/src/main/kotlin/fr/triozer/aoc/y2022/Day09.kt
triozer
573,964,813
false
{"Kotlin": 16632, "Shell": 3355, "JavaScript": 1716}
package fr.triozer.aoc.y2022 import fr.triozer.aoc.utils.readInput import kotlin.math.absoluteValue import kotlin.math.sign // #region other-type private typealias IntPair = Pair<Int, Int> // #endregion other-type // #region other-parse-input private fun parse(input: List<String>) = sequence { var x = 0 var ...
0
Kotlin
0
1
a9f47fa0f749a40e9667295ea8a4023045793ac1
2,266
advent-of-code
Apache License 2.0
src/Day04.kt
MT-Jacobs
574,577,538
false
{"Kotlin": 19905}
fun main() { fun part1(input: List<String>): Int { return input.count { val (elf1, elf2) = it.toSectionAssignmentPairs() elf2.within(elf1) || elf1.within(elf2) } } fun part2(input: List<String>): Int { return input.count { val (elf1, elf2) = it.t...
0
Kotlin
0
0
2f41a665760efc56d531e56eaa08c9afb185277c
1,181
advent-of-code-2022
Apache License 2.0
core/src/main/kotlin/in/specmatic/core/pattern/CombinationSpec.kt
znsio
247,710,440
false
{"Kotlin": 2742865, "Shell": 3975, "Python": 2412, "Nix": 391, "Dockerfile": 367}
package `in`.specmatic.core.pattern import kotlin.math.min /** * Provides utility access to all combinations of multiple sets of candidate values. Represented as the cartesian * product of all sets where each combination is represented as a numerical index from 0 to (MAX_COMBOS - 1). * * Supports sequential itera...
36
Kotlin
44
175
6b8e2defe4fcafb6f522f5d271fbfb46dc1089d1
4,147
specmatic
MIT License
src/Day09.kt
askeron
572,955,924
false
{"Kotlin": 24616}
import Point.Companion.DOWN import Point.Companion.LEFT import Point.Companion.RIGHT import Point.Companion.UP class Day09 : Day<Int>(13, 1, 6236, 2449) { private fun parseInput(input: List<String>): List<Point> { return input.map { it.split(" ").toPair() } .map { (a,b) -> mapOf...
0
Kotlin
0
1
6c7cf9cf12404b8451745c1e5b2f1827264dc3b8
1,427
advent-of-code-kotlin-2022
Apache License 2.0
solutions/aockt/y2021/Y2021D20.kt
Jadarma
624,153,848
false
{"Kotlin": 435090}
package aockt.y2021 import io.github.jadarma.aockt.core.Solution object Y2021D20 : Solution { /** * Represents a finite slice of an infinite image, with a maximum size of 2^15 * 2^15 pixels. * @property width The finite width of this slice. * @property height The finite height of this slice. ...
0
Kotlin
0
3
19773317d665dcb29c84e44fa1b35a6f6122a5fa
3,974
advent-of-code-kotlin-solutions
The Unlicense
src/main/kotlin/day4.kt
Gitvert
725,292,325
false
{"Kotlin": 97000}
fun day4 (lines: List<String>) { day4part1(lines) day4part2(lines) println() } fun day4part2(lines: List<String>) { val winsPerCard = mutableMapOf<Int, Int>() val noOfCards = mutableListOf<Int>() lines.forEachIndexed { index, line -> winsPerCard[index] = findMatches(line) ...
0
Kotlin
0
0
f204f09c94528f5cd83ce0149a254c4b0ca3bc91
1,418
advent_of_code_2023
MIT License
src/Day11.kt
lassebe
573,423,378
false
{"Kotlin": 33148}
fun main() { data class Monkey( val id: Int, val items: MutableList<Long>, val operation: (Long) -> Long, val divisor: Long, val test: (Long) -> Boolean, val testTrueId: Int, val testFalseId: Int ) fun monkeys(input: List<String>): MutableList<Monkey>...
0
Kotlin
0
0
c3157c2d66a098598a6b19fd3a2b18a6bae95f0c
4,065
advent_of_code_2022
Apache License 2.0
src/main/kotlin/de/soniro/nonogramsolver/Nonogram.kt
soniro
228,921,836
false
{"Kotlin": 7386}
package de.soniro.nonogramsolver import de.soniro.nonogramsolver.Cell.* enum class Cell(val char: Char) { FILL('\u2588'), EMPTY(' '), NOT_FILLED('X'), UNKNOWN('?'); override fun toString(): String = "$char" } class Nonogram(val rows: Array<IntArray>, val columns: Array<IntArray>) { val grid...
0
Kotlin
0
0
6cc0f04715a3e0c2dc87db6ecd5dee1925704ff9
3,246
nonogram-solver
Apache License 2.0
src/main/kotlin/day04/Day04.kt
qnox
575,581,183
false
{"Kotlin": 66677}
package day04 import readInput typealias Range = List<Int> fun Range.includes(range: Range): Boolean = this[0] <= range[0] && this[1] >= range[1] fun Range.overlap(range: Range): Boolean = this[1] >= range[0] && this[0] <= range[1] fun main() { fun part1(input: List<String>): Int { return input.count {l...
0
Kotlin
0
0
727ca335d32000c3de2b750d23248a1364ba03e4
921
aoc2022
Apache License 2.0
src/main/kotlin/aoc2018/day6/Manhattan.kt
arnab
75,525,311
false
null
package aoc2018.day6 import kotlin.math.abs data class Point(val id: Int?, val x: Int, val y: Int) { fun distanceTo(other: Point): Int { return abs(x - other.x) + abs(y - other.y) } } object Manhattan { fun largestArea(points: List<Point>): Int { val closestPoint: MutableMap<Point, Point...
0
Kotlin
0
0
1d9f6bc569f361e37ccb461bd564efa3e1fccdbd
2,752
adventofcode
MIT License
src/Day02.kt
rromanowski-figure
573,003,468
false
{"Kotlin": 35951}
object Day02 : Runner<Int, Int>(2, 15, 12) { override fun part1(input: List<String>): Int { val results = input.map { val values = it.split(" ") val them = Shape.them(values[0]) val me = Shape.me(values[1]) me.vs(them) } return results.sum() ...
0
Kotlin
0
0
6ca5f70872f1185429c04dcb8bc3f3651e3c2a84
2,617
advent-of-code-2022-kotlin
Apache License 2.0
java/app/src/main/kotlin/com/github/ggalmazor/aoc2021/day21/Day21Kt.kt
ggalmazor
434,148,320
false
{"JavaScript": 80092, "Java": 33594, "Kotlin": 14508, "C++": 3077, "CMake": 119}
package com.github.ggalmazor.aoc2021.day21 class Day21Kt { enum class Turn { PLAYER1, PLAYER2; fun next(): Turn { return when (this) { PLAYER1 -> PLAYER2 PLAYER2 -> PLAYER1 } } } private val rollFrequencies = mapOf(3 to 1, 4 ...
0
JavaScript
0
0
7a7ec831ca89de3f19d78f006fe95590cc533836
2,045
aoc2021
Apache License 2.0
src/Day25.kt
abeltay
572,984,420
false
{"Kotlin": 91982, "Shell": 191}
fun main() { fun convertToNum(snafu: Char): Int { return when (snafu) { '-' -> -1 '=' -> -2 else -> snafu.digitToInt() } } fun convertToSNAFU(num: Int): Char { return when (num) { -1 -> '-' -2 -> '=' else -> Cha...
0
Kotlin
0
0
a51bda36eaef85a8faa305a0441efaa745f6f399
1,900
advent-of-code-2022
Apache License 2.0
src/Day05_part2.kt
lowielow
578,058,273
false
{"Kotlin": 29322}
class Stack2 { val input = readInput("Day05") private val rawList = mutableListOf<MutableList<Char>>() private val newList = mutableListOf<MutableList<Char>>() fun addStack(str: String) { var raw = "" for (i in 1 until str.length step 4) { raw += str[i].toString() }...
0
Kotlin
0
0
acc270cd70a8b7f55dba07bf83d3a7e72256a63f
2,024
aoc2022
Apache License 2.0
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec19.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec19 : PuzzleDayTester(19, 2020) { override fun part1(): Any = parse().let { rulesToMessages -> // first arg is the rule map, second is the list of messages rulesToMessages.second.filter { val maxIdxMa...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
4,149
advent-of-code
MIT License
gcj/y2022/round1b/c_easy.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package gcj.y2022.round1b private fun solve(m: Int = 8) { fun ask(asked: Int): Int { println(asked.toString(2).padStart(m, '0')) return readInt() } val masks = 1 shl m fun rotate(mask: Int, shift: Int): Int { return (((mask shl m) or mask) shr shift) and (masks - 1) } val initOnes = ask(0) var ones = init...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
2,054
competitions
The Unlicense
src/main/kotlin/com/tonnoz/adventofcode23/day9/Nine.kt
tonnoz
725,970,505
false
{"Kotlin": 78395}
package com.tonnoz.adventofcode23.day9 import com.tonnoz.adventofcode23.utils.readInput import kotlin.system.measureTimeMillis object Nine { @JvmStatic fun main(args: Array<String>) { val input = "inputNine.txt".readInput() problemOne(input) problemTwo(input) } private fun problemTwo(input: List...
0
Kotlin
0
0
d573dfd010e2ffefcdcecc07d94c8225ad3bb38f
1,914
adventofcode23
MIT License
src/day22/Board3D.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day22 import java.lang.IllegalStateException class Board3D (board: Board) : Board (board.grid, board.steps) { val cubeMap = CubeMap (board) /** * */ override val nextPoint: Point get () { val newPoint = pos.move (facing) if (grid.containsKey (newPoint))...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
8,684
advent_of_code_2022
Apache License 2.0
src/main/kotlin/aoc/day2/RockPaperScissors.kt
hofiisek
573,543,194
false
{"Kotlin": 17421}
package aoc.day2 import aoc.loadInput import java.io.File /** * https://adventofcode.com/2022/day/2 * * @author <NAME> */ sealed class Outcome(val score: Int) object Lose : Outcome(0) object Draw : Outcome(3) object Win : Outcome(6) sealed class Shape(val score: Int) object Rock : Shape(1) object Paper : Shape(...
0
Kotlin
0
2
5908a665db4ac9fc562c44d6907f81cd3cd8d647
1,978
Advent-of-code-2022
MIT License
src/aoc2017/kot/Day25.kt
Tandrial
47,354,790
false
null
package aoc2017.kot import getNumbers import getWords import java.io.File object Day25 { data class Rule(val write: Int, val move: Int, val nextState: String) fun solve(input: List<String>): Int { val rules = mutableMapOf<Pair<String, Int>, Rule>() val rulesText = input.drop(3) for ((idx, line) in r...
0
Kotlin
1
1
9294b2cbbb13944d586449f6a20d49f03391991e
1,476
Advent_of_Code
MIT License
src/Day18.kt
frozbiz
573,457,870
false
{"Kotlin": 124645}
import java.util.BitSet class Point3D(val x: Int, val y: Int, val z: Int) { fun adjacentPoints() = sequence { yield(Point3D(x - 1, y, z)) yield(Point3D(x + 1 , y, z)) yield(Point3D(x, y - 1, z)) yield(Point3D(x, y + 1, z)) yield(Point3D(x, y, z - 1)) yield(Point3D(x,...
0
Kotlin
0
0
4feef3fa7cd5f3cea1957bed1d1ab5d1eb2bc388
3,964
2022-aoc-kotlin
Apache License 2.0
src/year2022/19/Day19.kt
Vladuken
573,128,337
false
{"Kotlin": 327524, "Python": 16475}
package year2022.`19` import java.util.LinkedList import java.util.PriorityQueue import readInput import utils.doWithPrintedTime data class Resources( val ore: Int, val clay: Int, val obsidian: Int, val geode: Int ) { infix operator fun minus(resources: Resources): Resources { return Resou...
0
Kotlin
0
5
c0f36ec0e2ce5d65c35d408dd50ba2ac96363772
9,733
KotlinAdventOfCode
Apache License 2.0
src/day18/Day18.kt
easchner
572,762,654
false
{"Kotlin": 104604}
package day18 import readInputString import java.lang.Integer.max import java.lang.Math.abs import kotlin.system.measureNanoTime data class Point(val x: Int, val y: Int, val z: Int, var visited: Boolean = false) fun main() { fun part1(input: List<String>): Int { val cubes = mutableListOf<Point>() ...
0
Kotlin
0
0
5966e1a1f385c77958de383f61209ff67ffaf6bf
5,523
Advent-Of-Code-2022
Apache License 2.0
src/day10/Day10.kt
henrikrtfm
570,719,195
false
{"Kotlin": 31473}
package day10 import utils.Resources.resourceAsListOfString private const val ROWLENGTH = 40 private val INTERVALS = listOf(20,60,100,140,180,220) fun main(){ val input = resourceAsListOfString("src/day10/Day10.txt") val commands = ArrayDeque<Command>().apply { addAll(input.map{parseInput(it)})} var regi...
0
Kotlin
0
0
20c5112594141788c9839061cb0de259f242fb1c
2,201
aoc2022
Apache License 2.0
src/chapter5/section2/ex22_TypingMonkeys.kt
w1374720640
265,536,015
false
{"Kotlin": 1373556}
package chapter5.section2 import chapter5.section1.Alphabet import edu.princeton.cs.algs4.StdRandom import extensions.formatDouble import extensions.formatInt /** * 打字的猴子 * 假设有一只会打字的猴子,它打出每个字母的概率为p,结束一个单词的概率为1-26p。 * 编写一个程序,计算产生各种长度的单词的概率分布。 * 其中如果"abc"出现了多次,只计算一次。 * * 解:p的大小应该小于1/26,才会有概率结束单词 * 根据给定概率生成索引可以可以...
0
Kotlin
1
6
879885b82ef51d58efe578c9391f04bc54c2531d
1,967
Algorithms-4th-Edition-in-Kotlin
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/ReduceArraySizeToTheHalf.kt
ashtanko
203,993,092
false
{"Kotlin": 5856223, "Shell": 1168, "Makefile": 917}
/* * Copyright 2020 <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,643
kotlab
Apache License 2.0
src/main/kotlin/aoc2022/Day22.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2022 import Point import readInput object Day22 { private enum class Rotation { COUNTERCLOCKWISE, CLOCKWISE, NONE; companion object { fun fromChar(c: Char) = when (c) { 'R' -> CLOCKWISE 'L' -> COUNTERCLOCKWISE else -> NONE ...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
4,458
adventOfCode
Apache License 2.0
src/Day09.kt
rmyhal
573,210,876
false
{"Kotlin": 17741}
import java.lang.IllegalArgumentException import kotlin.math.absoluteValue fun main() { fun part1(input: List<String>): Int { return first(input) } fun part2(input: List<String>): Int { return second(input) } val input = readInput("Day09") println(part1(input)) println(part2(input)) } private...
0
Kotlin
0
0
e08b65e632ace32b494716c7908ad4a0f5c6d7ef
3,062
AoC22
Apache License 2.0