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/Day03.kt | dannyrm | 573,100,803 | false | null | fun main() {
fun part1(input: List<String>): Int {
return input.map { findCommonItem(it) }.sumOf { calculatePriority(it) }
}
fun part2(input: List<String>): Int {
return input.chunked(3).map { findBadge(Triple(it[0], it[1], it[2])) }.sumOf { calculatePriority(it) }
}
val input = re... | 0 | Kotlin | 0 | 0 | 9c89b27614acd268d0d620ac62245858b85ba92e | 1,154 | advent-of-code-2022 | Apache License 2.0 |
src/main/java/io/deeplay/qlab/data/Utils.kt | oQaris | 475,961,305 | false | {"Jupyter Notebook": 766904, "Java": 47993, "Kotlin": 23299} | package io.deeplay.qlab.data
import krangl.mean
import kotlin.math.pow
import kotlin.math.sqrt
fun <T> splitData(data: List<T>, testFraq: Double, shuffle: Boolean = false): Pair<List<T>, List<T>> {
require(testFraq in 0.0..1.0) { "Некорректный testFraq" }
val dataCopy = if (shuffle) data.shuffled() else data... | 0 | Jupyter Notebook | 0 | 0 | 5dd497b74a767c740386dc67e6841673b17b96fb | 1,811 | QLab | MIT License |
src/main/kotlin/dev/bogwalk/batch3/Problem38.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch3
import dev.bogwalk.util.strings.isPandigital
/**
* Problem 38: Pandigital Multiples
*
* https://projecteuler.net/problem=38
*
* Goal: Find all multipliers M below N that provide a K-pandigital concatenated product when
* used with a multiplicand starting with 1 onwards.
*
* Constrai... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,321 | project-euler-kotlin | MIT License |
src/main/kotlin/Day18.kt | clechasseur | 318,029,920 | false | null | import org.clechasseur.adventofcode2020.Day18Data
object Day18 {
private val input = Day18Data.input
fun part1(): Long = input.lines().map { line ->
line.withoutWhitespace.compute(advanced = false)
}.sum()
fun part2(): Long = input.lines().map { line ->
line.withoutWhitespace.compute(... | 0 | Kotlin | 0 | 0 | 6173c9da58e3118803ff6ec5b1f1fc1c134516cb | 2,729 | adventofcode2020 | MIT License |
leetcode/kotlin/number-of-islands.kt | PaiZuZe | 629,690,446 | false | null | data class Cell(val row: Int, val col: Int)
class Solution {
fun numIslands(grid: Array<CharArray>): Int {
val visited = Array(grid.size) { BooleanArray(grid[0].size) { false } }
var islands = 0
for (i in grid.indices) {
for (j in grid[i].indices) {
val cell = C... | 0 | Kotlin | 0 | 0 | 175a5cd88959a34bcb4703d8dfe4d895e37463f0 | 1,698 | interprep | MIT License |
src/main/kotlin/net/voldrich/aoc2021/Day13.kt | MavoCz | 434,703,997 | false | {"Kotlin": 119158} | package net.voldrich.aoc2021
import net.voldrich.BaseDay
// link to task
fun main() {
Day13().run()
}
class Day13 : BaseDay() {
override fun task1() : Int {
val paper = PaperInstructions()
return foldPaper(paper.foldInstructions.first(), paper.points.toSet()).size
}
override fun tas... | 0 | Kotlin | 0 | 0 | 0cedad1d393d9040c4cc9b50b120647884ea99d9 | 2,605 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day25.kt | Gitvert | 725,292,325 | false | {"Kotlin": 97000} | import java.util.*
fun day25 (lines: List<String>) {
val components = parseComponentConnections(lines)
val connections = mutableListOf<Pair<String, String>>()
components.forEach { component ->
component.value.forEach {
if (!connections.contains(Pair(component.key, it)) && !connect... | 0 | Kotlin | 0 | 0 | f204f09c94528f5cd83ce0149a254c4b0ca3bc91 | 3,500 | advent_of_code_2023 | MIT License |
src/Day04.kt | jdappel | 575,879,747 | false | {"Kotlin": 10062} | fun main() {
fun part1(input: List<String>): Int {
return input.fold(0) { acc, line ->
val (firstElf, secondElf) = line.split(",")
val (firstElfStart, firstElfEnd) = firstElf.split("-")
val (secondElfStart, secondElfEnd) = secondElf.split("-")
val firstElfRan... | 0 | Kotlin | 0 | 0 | ddcf4f0be47ccbe4409605b37f43534125ee859d | 1,436 | AdventOfCodeKotlin | Apache License 2.0 |
lc003/src/main/kotlin/max_sum_of_rectangle_no_larger_than_k/max_sum_of_rectangle_no_larger_than_k.kt | warmthdawn | 467,419,502 | false | {"Kotlin": 28653, "Java": 8222} | package max_sum_of_rectangle_no_larger_than_k
import kotlin.math.sign
class Solution {
fun maxSumSubmatrix(matrix: Array<IntArray>, k: Int): Int {
val lineSums = matrix.map { line ->
val size = line.size
Array(size) { i ->
var sum = 0
IntArray(siz... | 0 | Kotlin | 0 | 0 | 40dc158a934f0fc4a3c6076bf1b5babf8413e190 | 2,711 | LeetCode | MIT License |
advent-of-code-2018/src/test/java/aoc/Advent4.kt | yuriykulikov | 159,951,728 | false | {"Kotlin": 1666784, "Rust": 33275} | package aoc
import org.assertj.core.api.Assertions.assertThat
import org.junit.Ignore
import org.junit.Test
import java.text.SimpleDateFormat
import java.util.*
import java.util.Locale
private val sdf = SimpleDateFormat("YYYY-MM-dd HH:mm", Locale.ENGLISH)
sealed class Line
data class ShiftStart(val calendar: Calenda... | 0 | Kotlin | 0 | 1 | f5efe2f0b6b09b0e41045dc7fda3a7565cb21db3 | 44,066 | advent-of-code | MIT License |
src/Day11.kt | undermark5 | 574,819,802 | false | {"Kotlin": 67472} | import java.math.BigInteger
data class Monkey(
val id: String,
private var _items: MutableList<Long>,
val operation: (Long, Long) -> Long,
val testValue: Int,
val successPartner: Int,
val failPartner: Int,
) {
var inspectionCount = 0L
private set
val items: List<Long> get() = ... | 0 | Kotlin | 0 | 0 | e9cf715b922db05e1929f781dc29cf0c7fb62170 | 6,090 | AoC_2022_Kotlin | Apache License 2.0 |
src/Day02.kt | thorny-thorny | 573,065,588 | false | {"Kotlin": 57129} | fun main() {
fun decodeLine(line: String) = (line.first() - 'A' + 1) to (line.last() - 'X' + 1)
fun roundScore(opponent: Int, me: Int) = me + ((4 + me - opponent) % 3) * 3
fun part1(input: List<String>): Int {
return input.sumOf {
val (opponent, me) = decodeLine(it)
roundSc... | 0 | Kotlin | 0 | 0 | 843869d19d5457dc972c98a9a4d48b690fa094a6 | 962 | aoc-2022 | Apache License 2.0 |
src/main/java/strassenbahn/ThriftTicket.kt | ununhexium | 125,272,921 | false | null | package strassenbahn
import java.util.LinkedList
import kotlin.math.max
interface Ticket {
fun getPrice(area: Int): Float
val description: String
val adultCapacity: Int
val childrenCapacity: Int
val allowedTrips: Int
}
data class Wanted(
val area: Int,
val adults: Int = 0,
val childre... | 0 | Kotlin | 0 | 0 | 11aca6b37e06fe1e8ad31467703dacf857332825 | 5,626 | samples | The Unlicense |
src/Day02.kt | andrewgadion | 572,927,267 | false | {"Kotlin": 16973} | enum class Shape(val Score: Int) {
Rock(1),
Paper(2),
Scissors(3);
fun Play(other: Shape): Int {
if (other == this)
return 3 + Score
return when(this) {
Rock -> if (other == Scissors) 6 else 0
Paper -> if (other == Rock) 6 else 0
Scissors ... | 0 | Kotlin | 0 | 0 | 4d091e2da5d45a786aee4721624ddcae681664c9 | 1,617 | advent-of-code-2022 | Apache License 2.0 |
src/Day12.kt | adrianforsius | 573,044,406 | false | {"Kotlin": 68131} | import org.assertj.core.api.Assertions.assertThat
fun level(c: Char): Int = when (c) {
'S' -> 0
'E' -> 'z' - 'a' + 1
else -> c - 'a'
}
fun findCoord(input: List<String>, char: Char): Point = input
.withIndex()
.map {(index, it) ->
Point(index, it.indexOf(char))
}.find{
it.x !... | 0 | Kotlin | 0 | 0 | f65a0e4371cf77c2558d37bf2ac42e44eeb4bdbb | 4,026 | kotlin-2022 | Apache License 2.0 |
src/Day15.kt | abeltay | 572,984,420 | false | {"Kotlin": 91982, "Shell": 191} | import kotlin.math.abs
fun main() {
fun manhattanDistance(a: Pair<Int, Int>, b: Pair<Int, Int>): Int {
return abs(a.first - b.first) + abs(a.second - b.second)
}
fun isTouching(a: Pair<Int, Int>, b: Pair<Int, Int>): Boolean {
if (a.first > b.first) {
return isTouching(b, a)
... | 0 | Kotlin | 0 | 0 | a51bda36eaef85a8faa305a0441efaa745f6f399 | 3,739 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/g2301_2400/s2338_count_the_number_of_ideal_arrays/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2301_2400.s2338_count_the_number_of_ideal_arrays
// #Hard #Dynamic_Programming #Math #Number_Theory #Combinatorics
// #2023_07_01_Time_201_ms_(100.00%)_Space_37.8_MB_(100.00%)
import kotlin.math.ln
class Solution {
fun idealArrays(n: Int, maxValue: Int): Int {
val mod = (1e9 + 7).toInt()
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,473 | LeetCode-in-Kotlin | MIT License |
src/Day05.kt | ben-dent | 572,931,260 | false | {"Kotlin": 10265} | fun main() {
fun part1(input: List<String>): String {
val piles = getBoxes(input)
var boxes = piles.first
val i = piles.second
val newData = input.subList(i + 2, input.size)
for (line in newData) {
val s1 = line.split("move ")[1]
val s2 = s1.split("... | 0 | Kotlin | 0 | 0 | 2c3589047945f578b57ceab9b975aef8ddde4878 | 3,624 | AdventOfCode2022Kotlin | Apache License 2.0 |
src/main/kotlin/com/mobiento/aoc/Day02.kt | markburk | 572,970,459 | false | {"Kotlin": 22252} | package com.mobiento.aoc
class Day02 {
fun part1(input: List<String>): Int {
return input.sumOf { line ->
line.split(" ").takeIf { it.size >= 2 }?.let { parts ->
scoreForRoundPart1(parts[0], parts[1])
} ?: 0
}
}
fun scoreForRoundPart1(a: String, b: ... | 0 | Kotlin | 0 | 0 | d28656b4d54c506a01252caf6b493e4f7f97e896 | 3,607 | potential-lamp | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/util/Utils.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.util
import java.math.BigInteger
import java.security.MessageDigest
import java.util.*
import kotlin.io.path.Path
import kotlin.io.path.readLines
import kotlin.time.measureTime
/**
* Generates the MD5 hash of a string.
*
* @return the MD5 hash as a hexadecimal string
*/
fun String.md5() = ... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 3,124 | advent-of-code | MIT License |
jvm/src/main/kotlin/io/prfxn/aoc2021/day14.kt | prfxn | 435,386,161 | false | {"Kotlin": 72820, "Python": 362} | // Extended Polymerization (https://adventofcode.com/2021/day/14)
package io.prfxn.aoc2021
fun main() {
val lines = textResourceReader("input/14.txt").readLines()
val template = lines.first()
val rules = lines.drop(2).map {
with (it.split(" -> ")) { first() to last() }
}
val spc = temp... | 0 | Kotlin | 0 | 0 | 148938cab8656d3fbfdfe6c68256fa5ba3b47b90 | 1,665 | aoc2021 | MIT License |
src/Day04.kt | JaydenPease | 574,590,496 | false | {"Kotlin": 11645} | fun main() {
// fun part1(input: List<String>): Int {
// return input.size
// }
//
// fun part2(input: List<String>): Int {
// return input.size
// }
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day04_test")
//println(Day04_part1(... | 0 | Kotlin | 0 | 0 | 0a5fa22b3653c4b44a716927e2293fc4b2ed9eb7 | 1,353 | AdventOfCode-2022 | Apache License 2.0 |
2022/src/main/kotlin/com/github/akowal/aoc/Day03.kt | akowal | 573,170,341 | false | {"Kotlin": 36572} | package com.github.akowal.aoc
class Day03 {
private val rucksacks = inputFile("day03").readLines()
fun solvePart1(): Int {
return rucksacks.sumOf { rucksack ->
val items1 = rucksack.take(rucksack.length / 2).toCharArray().toSet()
val items2 = rucksack.drop(rucksack.length / 2).... | 0 | Kotlin | 0 | 0 | 02e52625c1c8bd00f8251eb9427828fb5c439fb5 | 1,060 | advent-of-kode | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/onegravity/sudoku/model/Util.kt | 1gravity | 407,597,760 | false | {"Kotlin": 148326} | package com.onegravity.sudoku.model
import java.util.*
/**
* Map region codes to cell indices
*
* Region codes for rows would look like this:
* 0 0 0 0 0 0 0 0 0
* 1 1 1 1 1 1 1 1 1
* 2 2 2 2 2 2 2 2 2
* etc.
*
* Region codes for columns would look like this:
* 0 1 2 3 4 5 6 7 8
* 0 1 2 3 4 5 6 7 8
... | 0 | Kotlin | 0 | 1 | 4e8bfb119a57a101db4d873bf86cd5722105ebb3 | 3,054 | Dancing-Links-Kotlin | Apache License 2.0 |
src/com/wd/algorithm/leetcode/ALGO0003.kt | WalkerDenial | 327,944,547 | false | null | package com.wd.algorithm.leetcode
import com.wd.algorithm.test
import kotlin.math.max
/**
* 3. 无重复字符的最长子串
*
* 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
*
*/
class ALGO0003 {
/**
* 方式一:暴力解法
* 逐个生产子字符串,看看是否含有重复的字符
* 时间复杂度 T(n²)
*/
fun lengthOfLongestSubstring1(s: String): Int {
var endI... | 0 | Kotlin | 0 | 0 | 245ab89bd8bf467625901034dc1139f0a626887b | 1,924 | AlgorithmAnalyze | Apache License 2.0 |
kotlin/36_Valid_Sudoku.kt | giovanniPepi | 607,763,568 | false | null | // Leet Code problem 36, Valid Sudoku
// problem description found on following link:
// https://leetcode.com/problems/valid-sudoku/description/
class Solution {
fun isValidSudoku(board: Array<CharArray>): Boolean {
// my board is an instance of Sudoku class
val myboard = Sudoku(board)
// ... | 0 | Kotlin | 1 | 0 | ccb853bce41206f30cbfb1ff4ca8e8f22feb0ee2 | 3,168 | bastterCode | MIT License |
src/main/kotlin/aoc22/Day10.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import aoc22.Day10Domain.Addx
import aoc22.Day10Domain.Cycle
import aoc22.Day10Domain.Instruction
import aoc22.Day10Domain.Noop
import aoc22.Day10Domain.Register
import aoc22.Day10Parser.toInstructions
import aoc22.Day10Runner.run
import aoc22.Day10SolutionPart1.part1Day10
import aoc22.Day10SolutionPart2... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 2,974 | aoc | Apache License 2.0 |
kotlin/src/com/daily/algothrim/leetcode/medium/CanPartitionKSubsets.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode.medium
/**
* 698. 划分为k个相等的子集
*
* 给定一个整数数组 nums 和一个正整数 k,找出是否有可能把这个数组分成 k 个非空子集,其总和都相等。
*
* 示例 1:
* 输入: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
* 输出: True
* 说明: 有可能将其分成 4 个子集(5),(1,4),(2,3),(2,3)等于总和。
* 示例 2:
* 输入: nums = [1,2,3,4], k = 3
* 输出: false
*
* 1 <= k <= len(nums... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 4,244 | daily_algorithm | Apache License 2.0 |
src/day2/day02.kt | TP1cks | 573,328,994 | false | {"Kotlin": 5377} | package day2
import readInputLines
typealias GameRecord = Pair<String, String>
typealias Game = Pair<Shape, Shape>
fun main () {
part1()
part2()
}
fun part1() {
val games = getGameRecords().map { gameRecord ->
Game(symbolToShape(gameRecord.first), symbolToShape(gameRecord.second))
}
prin... | 0 | Kotlin | 0 | 0 | 52f79a4593384fe651d905ddaea379f49ddfe513 | 1,947 | advent-of-code-2022 | Apache License 2.0 |
src/year2022/25/Day25.kt | Vladuken | 573,128,337 | false | {"Kotlin": 327524, "Python": 16475} | package year2022.`25`
import kotlin.math.pow
import kotlin.math.roundToLong
import readInput
fun String.toDecimal(): Long {
return split("").filter { it.isNotEmpty() }.map {
when (it) {
"2" -> 2
"1" -> 1
"0" -> 0
"-" -> -1
"=" -> -2
e... | 0 | Kotlin | 0 | 5 | c0f36ec0e2ce5d65c35d408dd50ba2ac96363772 | 1,404 | KotlinAdventOfCode | Apache License 2.0 |
src/main/kotlin/Day5.kt | maldoinc | 726,264,110 | false | {"Kotlin": 14472} | import kotlin.io.path.Path
import kotlin.io.path.readLines
data class Mapping(val destinationStart: Long, val sourceStart: Long, val size: Long)
fun getSection(contents: String, sectionName: String) =
Regex("`$sectionName map:`(.+?)(`[a-z]|$)")
.findAll(contents)
.map { it.groupValues[1] }
... | 0 | Kotlin | 0 | 1 | 47a1ab8185eb6cf16bc012f20af28a4a3fef2f47 | 2,484 | advent-2023 | MIT License |
src/main/kotlin/GiantSquid_4.kt | Flame239 | 433,046,232 | false | {"Kotlin": 64209} | val input: Input by lazy {
val lines = readFile("GiantSquid").split("\n")
val numbers = lines[0].split(",").map { Integer.parseInt(it) }
val boards = mutableListOf<Board>()
var curRow = 2
while (curRow < lines.size) {
val curBoard: MutableList<List<Int>> = mutableListOf()
// could u... | 0 | Kotlin | 0 | 0 | ef4b05d39d70a204be2433d203e11c7ebed04cec | 2,656 | advent-of-code-2021 | Apache License 2.0 |
src/aoc2022/day12/AoC12.kt | Saxintosh | 576,065,000 | false | {"Kotlin": 30013} | package aoc2022.day12
import readLines
data class P(val x: Int, val y: Int) {
fun up() = P(x + 1, y)
fun down() = P(x - 1, y)
fun left() = P(x, y - 1)
fun right() = P(x, y + 1)
override fun toString() = "($x,$y)"
}
class XYMap(lines: List<String>) {
private val start: P
private val end: P
private val grid: L... | 0 | Kotlin | 0 | 0 | 877d58367018372502f03dcc97a26a6f831fc8d8 | 2,623 | aoc2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem218/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem218
import java.util.*
/**
* LeetCode page: [218. The Skyline Problem](https://leetcode.com/problems/the-skyline-problem/);
*/
class Solution {
/* Complexity:
* Time O(NLogN) and Space O(N) where N is the size of buildings;
*/
fun getSkyline(buildings: Array<I... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,714 | hj-leetcode-kotlin | Apache License 2.0 |
src/Day20/Day20.kt | Nathan-Molby | 572,771,729 | false | {"Kotlin": 95872, "Python": 13537, "Java": 3671} | package Day20
import readInput
import java.math.BigInteger
import kotlin.math.*
class LinkedListNode(var number: BigInteger) {
var nextNode: LinkedListNode? = null
var prevNode: LinkedListNode? = null
fun move(listSize: BigInteger) {
var smallNumber = number % (listSize - BigInteger.ONE)
i... | 0 | Kotlin | 0 | 0 | 750bde9b51b425cda232d99d11ce3d6a9dd8f801 | 3,666 | advent-of-code-2022 | Apache License 2.0 |
y2021/src/main/kotlin/adventofcode/y2021/Day10.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2021
import adventofcode.io.AdventSolution
object Day10 : AdventSolution(2021, 10, "Syntax Scoring") {
override fun solvePartOne(input: String) = input.lineSequence().sumOf(::firstError)
override fun solvePartTwo(input: String) = input.lineSequence()
.filter { firstError(it) ==... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,168 | advent-of-code | MIT License |
src/Day04.kt | jfiorato | 573,233,200 | false | null | fun main() {
fun getSet(input: String): Set<Int> {
val (start, end) = input.split("-").map { it.toInt() }
return IntRange(start, end).toSet()
}
fun part1(input: List<String>): Int {
var counter = 0
for (line in input) {
val (assignment1, assignment2) = line.split... | 0 | Kotlin | 0 | 0 | 4455a5e9c15cd067d2661438c680b3d7b5879a56 | 1,373 | kotlin-aoc-2022 | Apache License 2.0 |
src/day01/Day01.kt | veronicamengyan | 573,063,888 | false | {"Kotlin": 14976} | package day01
import java.util.Comparator
import java.util.PriorityQueue
import readInput
/**
* Potential improvement:
* * use sorted and takeLast(3) instead of priority queue from java
*/
fun main() {
fun findMaxCalories1(input: List<String>): Long {
var maxCalories = 0L
var currentCaloriesPer... | 0 | Kotlin | 0 | 0 | d443cfa49e9d8c9f76fdb6303ecf104498effb88 | 1,999 | aoc-2022-in-kotlin | Apache License 2.0 |
src/day21/Code.kt | fcolasuonno | 572,734,674 | false | {"Kotlin": 63451, "Dockerfile": 1340} | package day21
import day06.main
import readInput
import java.math.BigInteger
sealed class Monkey
data class Number(val number: BigInteger) : Monkey()
data class Op(val left: String, val right: String, val op: (BigInteger, BigInteger) -> BigInteger) : Monkey()
fun main() {
fun parse(input: List<String>) = input.... | 0 | Kotlin | 0 | 0 | 9cb653bd6a5abb214a9310f7cac3d0a5a478a71a | 2,388 | AOC2022 | Apache License 2.0 |
src/DayFive.kt | P-ter | 573,301,805 | false | {"Kotlin": 9464} | fun main() {
val exclusions = listOf("ab", "cd", "pq", "xy")
val vowels = listOf("a", "e", "i", "o", "u")
fun part1(input: List<String>): Int {
var total = 0
input.forEach {line ->
val pairs = line.windowed(2)
if(pairs.intersect(exclusions).isEmpty() &&
... | 0 | Kotlin | 0 | 0 | fc46b19451145e0c41b1a50f62c77693865f9894 | 1,171 | aoc-2015 | Apache License 2.0 |
src/main/kotlin/days/Day3.kt | andilau | 544,512,578 | false | {"Kotlin": 29165} | package days
@AdventOfCodePuzzle(
name = "Squares With Three Sides",
url = "https://adventofcode.com/2016/day/3",
date = Date(day = 3, year = 2016)
)
class Day3(input: List<String>) : Puzzle {
private val triangles: List<Triangle> = input.mapNotNull { Triangle.from(it) }
override fun p... | 3 | Kotlin | 0 | 0 | b2a836bd3f1c5eaec32b89a6ab5fcccc91b665dc | 1,415 | advent-of-code-2016 | Creative Commons Zero v1.0 Universal |
kotlin/src/com/daily/algothrim/leetcode/MedianSlidingWindow.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
import java.util.*
/**
* 480. 滑动窗口中位数
* 中位数是有序序列最中间的那个数。如果序列的长度是偶数,则没有最中间的数;此时中位数是最中间的两个数的平均数。
*
* 例如:
*
* [2,3,4],中位数是 3
* [2,3],中位数是 (2 + 3) / 2 = 2.5
* 给你一个数组 nums,有一个长度为 k 的窗口从最左端滑动到最右端。窗口中有 k 个数,每次窗口向右移动 1 位。你的任务是找出每次窗口移动后得到的新窗口中元素的中位数,并输出由它们组成的数组。
*/
class MedianSli... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 3,991 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/day14/Day14.kt | Jessevanbekkum | 112,612,571 | false | null | package day14
import day10.hash64
fun hash(input: String): Int {
val toIntArray = (0..127).map { it ->
val s = hash64(input + "-" + it)
s.toCharArray().map { c -> countBits(c) }.sum()
}.toIntArray()
return toIntArray.sum()
}
fun countBits(inp: Char): Int {
return Integer.valueOf(inp.t... | 0 | Kotlin | 0 | 0 | 1340efd354c61cd070c621cdf1eadecfc23a7cc5 | 1,544 | aoc-2017 | Apache License 2.0 |
src/main/kotlin/day7/Day7.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day7
import Day
import kotlin.LazyThreadSafetyMode.NONE
fun main() {
Day7("Day07").apply {
println(part1(parsedInput))
println(part2(parsedInput))
}
}
class Day7(input: String) : Day<List<Day7.Dir>>(input) {
class Dir(
var filesSize: Int = 0,
val dirs: MutableMap<... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 1,483 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/days/Day3.kt | MisterJack49 | 729,926,959 | false | {"Kotlin": 31964} | package days
import common.Coordinates
class Day3 : Day(3) {
override fun partOne() =
inputList.toSchematic()
.identifyParts()
.sumOf { it.value }
override fun partTwo() =
inputList.toSchematic()
.identifyGearParts()
.identifyGearSystems()
... | 0 | Kotlin | 0 | 0 | 807a6b2d3ec487232c58c7e5904138fc4f45f808 | 3,750 | AoC-2023 | Creative Commons Zero v1.0 Universal |
advent-of-code-2023/src/main/kotlin/eu/janvdb/aoc2023/day04/day04.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2023.day04
import eu.janvdb.aocutil.kotlin.readLines
//const val FILENAME = "input04-test.txt"
const val FILENAME = "input04.txt"
val LINE_REGEX = Regex("^Card +(\\d+): ([\\d ]+)\\|([\\d ]+)$")
val SPLIT_REGEX = Regex(" +")
fun main() {
val puzzle = Puzzle.parse(readLines(2023, FILENAME))
pr... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 1,492 | advent-of-code | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/PalindromePairs.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 | 5,339 | kotlab | Apache License 2.0 |
src/main/kotlin/day11/Day11.kt | qnox | 575,581,183 | false | {"Kotlin": 66677} | package day11
import readInput
class Monkey(
items: List<Long>,
val operation: (Long) -> Long,
val test: (Long) -> Boolean,
val ifTrue: Int,
val ifFalse: Int
) {
fun inspectFirst(): Boolean {
_count += 1
val old = _items[0]
val worry = operation(old)
_items[0] ... | 0 | Kotlin | 0 | 0 | 727ca335d32000c3de2b750d23248a1364ba03e4 | 4,107 | aoc2022 | Apache License 2.0 |
src/main/kotlin/g0201_0300/s0218_the_skyline_problem/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0201_0300.s0218_the_skyline_problem
// #Hard #Top_Interview_Questions #Array #Heap_Priority_Queue #Ordered_Set #Divide_and_Conquer
// #Segment_Tree #Binary_Indexed_Tree #Line_Sweep
// #2022_10_25_Time_365_ms_(93.14%)_Space_45.7_MB_(93.71%)
import java.util.TreeMap
class Solution {
fun getSkyline(blds: A... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,294 | LeetCode-in-Kotlin | MIT License |
src/Day23.kt | EdoFanuel | 575,561,680 | false | {"Kotlin": 80963} | import utils.Coord2DInt
import utils.Orientation
class Day23 {
fun parseInput(input: List<String>): Set<Coord2DInt> {
val result = mutableSetOf<Coord2DInt>()
for (i in input.indices) {
for (j in input[i].indices) {
if (input[i][j] == '#') result += Coord2DInt(i, j)
... | 0 | Kotlin | 0 | 0 | 46a776181e5c9ade0b5e88aa3c918f29b1659b4c | 4,076 | Advent-Of-Code-2022 | Apache License 2.0 |
src/Day24.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | import java.util.*
fun main() {
val testInput = readInput("Day24_test")
val testMap = BlizzardMap(testInput)
check(part1(testMap) == 18)
check(part2(testMap) == 54)
val input = readInput("Day24")
val map = BlizzardMap(input)
println(part1(map))
println(part2(map))
}
private fun part1(... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 5,322 | AOC2022 | Apache License 2.0 |
src/day03/Day03.kt | Harvindsokhal | 572,911,840 | false | {"Kotlin": 11823} | package day03
import readInput
fun main() {
val data = readInput("day03/day03_data")
val alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun sortRucksack(list: List<String>): Int {
var sum = 0
list.forEach { item ->
val half = item.length / 2
val p... | 0 | Kotlin | 0 | 0 | 7ebaee4887ea41aca4663390d4eadff9dc604f69 | 1,227 | aoc-2022-kotlin | Apache License 2.0 |
src/com/kingsleyadio/adventofcode/y2023/Day09.kt | kingsleyadio | 435,430,807 | false | {"Kotlin": 134666, "JavaScript": 5423} | package com.kingsleyadio.adventofcode.y2023
import com.kingsleyadio.adventofcode.util.readInput
fun main() {
val input = readInput(2023, 9).readLines().map { line -> line.split(" ").map(String::toInt) }
part1(input)
part2(input)
}
private fun part1(input: List<List<Int>>) = println(input.sumOf(::findNext... | 0 | Kotlin | 0 | 1 | 9abda490a7b4e3d9e6113a0d99d4695fcfb36422 | 987 | adventofcode | Apache License 2.0 |
src/main/kotlin/utils/CharGrid.kt | dkhawk | 573,106,005 | false | {"Kotlin": 574941} | package utils
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.sign
import kotlin.math.sqrt
data class Vector(val x: Int = 0, val y: Int = 0) : Comparable<Vector> {
val sign: Vector
get() = Vector(x.sign, y.sign)
operator fun times(scale: Int): Vector {
return Vector(x * scale, y * scale)... | 0 | Kotlin | 0 | 1 | 4cbe3200832ce8d81333bb5e851ad66dfe390e6e | 16,830 | AoCDesktop | Apache License 2.0 |
src/Day01/Day01.kt | G-lalonde | 574,649,075 | false | {"Kotlin": 39626} | import java.util.*
fun main() {
fun part1(input: List<String>): Int {
var mostCalories = Double.MIN_VALUE
var calories = 0.0
for (line: String in input) {
if (line.isEmpty()) {
if (calories > mostCalories) {
mostCalories = calories
... | 0 | Kotlin | 0 | 0 | 3463c3228471e7fc08dbe6f89af33199da1ceac9 | 1,494 | aoc-2022 | Apache License 2.0 |
src/Day02.kt | kthun | 572,871,866 | false | {"Kotlin": 17958} | fun main() {
fun part1(input: List<String>): Int {
return input.sumOf { line ->
val (opponent, self) = line.split(" ")
val symbolValue = when (self) {
"X" -> 1
"Y" -> 2
"Z" -> 3
else -> throw IllegalArgumentException("Un... | 0 | Kotlin | 0 | 0 | 5452702e4e20ef2db3adc8112427c0229ebd1c29 | 2,860 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/se/saidaspen/aoc/aoc2018/Day09.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2018
import se.saidaspen.aoc.util.*
fun main() = Day09.run()
object Day09 : Day(2018, 9) {
override fun part1() : Any = play(ints(input)[0] * 1L, ints(input)[1] * 1L)
override fun part2(): Any = play(ints(input)[0] * 1L, ints(input)[1] * 100L)
private fun play(numPlayers: Lo... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 2,530 | adventofkotlin | MIT License |
src/test/kotlin/Day09.kt | christof-vollrath | 317,635,262 | false | null | import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
/*
--- Day 9: Encoding Error ---
See https://adventofcode.com/2020/day/9
*/
fun List<Long>.checkProperty(preamble: Int): List<Long> {
fun checkNumber(nr: Long, numbersToCheck: Set<Long>): Boolean {
numbersToCheck.forEach { numb... | 1 | Kotlin | 0 | 0 | 8ad08350aa4bd1a29b7e18765fc7a2d6de8021e8 | 3,189 | advent_of_code_2020 | Apache License 2.0 |
2022/12/12.kt | LiquidFun | 435,683,748 | false | {"Kotlin": 40554, "Python": 35985, "Julia": 29455, "Rust": 20622, "C++": 1965, "Shell": 1268, "APL": 191} | fun bfs(field: List<String>, queue: MutableList<Pair<Int, Int>>, target: Pair<Int, Int>): Int {
val dist = queue.associate { it to 0 }.toMutableMap()
val dirs = listOf(-1 to 0, 1 to 0, 0 to 1, 0 to -1)
while (!queue.isEmpty()) {
val (y, x) = queue.removeFirst()
dirs
.map { (ya, x... | 0 | Kotlin | 7 | 43 | 7cd5a97d142780b8b33b93ef2bc0d9e54536c99f | 1,155 | adventofcode | Apache License 2.0 |
year2023/day02/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day02/part2/Year2023Day02Part2.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | /*
--- Part Two ---
The Elf says they've stopped producing snow because they aren't getting any water! He isn't sure why
the water stopped; however, he can show you how to get to the water source to check it out for
yourself. It's just up ahead!
As you continue your walk, the Elf poses a second question: in each game... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 2,364 | AdventOfCode | MIT License |
src/main/kotlin/14/14.kt | Wrent | 225,133,563 | false | null | import java.math.BigInteger
import java.math.RoundingMode
import kotlin.math.ceil
import kotlin.math.roundToLong
fun main() {
val chemicals = mutableMapOf<String, Chemical>()
chemicals.put("ORE", Chemical("ORE"))
INPUT14.split("\n")
.forEach { reaction ->
val (inputs, output) = reactio... | 0 | Kotlin | 0 | 0 | 0a783ed8b137c31cd0ce2e56e451c6777465af5d | 6,507 | advent-of-code-2019 | MIT License |
src/benchmark/BenchmarkUtils.kt | aaronoe | 186,243,764 | false | null | package de.aaronoe.benchmark
import de.aaronoe.models.Seminar
import de.aaronoe.models.Student
import java.io.StringWriter
private const val PREFIX_META_DATA = 'd'
private const val PREFIX_SEMINAR = 't'
private const val PREFIX_STUDENT = 's'
enum class PopularityResult {
MORE, EQUAL, LESS
}
fun Pair<List<Studen... | 0 | Kotlin | 0 | 1 | 8265e6553aca23c3bf2c5236ba56d46ab7e2b3f3 | 2,295 | matching_server | MIT License |
src/main/kotlin/_2022/Day15.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2022
import readInput
import java.math.BigInteger
import kotlin.math.abs
fun main() {
fun printMap(map: Map<Pair<Int, Int>, _2022.BeaconItem>) {
val minX = map.keys.minBy { it.first }.first - 1
val maxX = map.keys.maxBy { it.first }.first + 1
val minY = 0
val maxY = map.k... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 5,837 | advent-of-code | Apache License 2.0 |
y2023/src/main/kotlin/adventofcode/y2023/Day18.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2023
import adventofcode.io.AdventSolution
import adventofcode.util.vector.Direction
import adventofcode.util.vector.Direction.*
import kotlin.math.absoluteValue
fun main() {
Day18.solve()
}
object Day18 : AdventSolution(2023, 18, "<NAME>") {
override fun solvePartOne(input: String) = ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,530 | advent-of-code | MIT License |
src/main/kotlin/com/manalili/advent/Day04.kt | maines-pet | 162,116,190 | false | null | package com.manalili.advent
class Day04(private val logs: List<String>){
private var guardList: List<Guard> = listOf()
get(){
val guardIdPattern = Regex("""\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})] Guard #(\d+) begins shift""")
val isSleepingPattern = Regex("""\[(\d{4}-\d{2}-\d{2} \d{2... | 0 | Kotlin | 0 | 0 | 25a01e13b0e3374c4abb6d00cd9b8d7873ea6c25 | 3,255 | adventOfCode2018 | MIT License |
src/day02/Task.kt | dniHze | 433,447,720 | false | {"Kotlin": 35403} | package day02
import readInput
fun main() {
val input = readInput("day02")
println(solvePartOne(input))
println(solvePartTwo(input))
}
fun solvePartOne(input: List<String>) = input.solveWithAim(aim = false)
fun solvePartTwo(input: List<String>) = input.solveWithAim(aim = true)
private fun List<String>.... | 0 | Kotlin | 0 | 1 | f81794bd57abf513d129e63787bdf2a7a21fa0d3 | 1,446 | aoc-2021 | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2021/Day24.kt | colinodell | 433,864,377 | true | {"Kotlin": 111114} | package com.colinodell.advent2021
class Day24(input: List<String>) {
private val blockVariables = input
// Every chunk of 18 lines is an almost-identical block, but with three small differences, so let's capture those
.chunked(18)
.map { it.joinToString("") }
.map { Regex("-?\\d+").... | 0 | Kotlin | 0 | 1 | a1e04207c53adfcc194c85894765195bf147be7a | 2,689 | advent-2021 | Apache License 2.0 |
src/Day14.kt | Riari | 574,587,661 | false | {"Kotlin": 83546, "Python": 1054} | fun main() {
data class Tile(val x: Int, val y: Int)
data class Slice(val tiles: Array<CharArray>, var deepestRock: Int = 0) {
fun copyOf(): Slice {
return Slice(tiles.map { it.copyOf() }.toTypedArray(), deepestRock)
}
}
fun processInput(input: List<String>): Slice {
... | 0 | Kotlin | 0 | 0 | 8eecfb5c0c160e26f3ef0e277e48cb7fe86c903d | 2,514 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/CountSubTrees.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,014 | kotlab | Apache License 2.0 |
solutions/src/main/kotlin/de/thermondo/solutions/advent2022/day01/Part1Solution.kt | thermondo | 552,876,124 | false | {"Kotlin": 23756, "Makefile": 274} | package de.thermondo.solutions.advent2022.day01
import de.thermondo.utils.Exclude
import de.thermondo.utils.stringFromFile
/**
* The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition
* traditionally goes on foot. As your boats approach land, the Elves b... | 6 | Kotlin | 1 | 0 | ef413904ce4bbe82861776f2efe5efd43dd5dc99 | 2,307 | lets-learn-kotlin | MIT License |
src/algorithmdesignmanualbook/datastructures/SmallestNumberInRange.kt | realpacific | 234,499,820 | false | null | package algorithmdesignmanualbook.datastructures
import _utils.UseCommentAsDocumentation
import kotlin.test.assertTrue
private typealias Table = Array<Array<Int?>>
private interface SmallestNumberInRange {
fun getSmallest(startIndex: Int, endIndex: Int): Int
}
/**
*
* Suppose that we are given a sequence of n... | 4 | Kotlin | 5 | 93 | 22eef528ef1bea9b9831178b64ff2f5b1f61a51f | 3,771 | algorithms | MIT License |
src/Day02.kt | becsegal | 573,649,289 | false | {"Kotlin": 9779} | import java.io.File
fun main() {
val notationToShape = mapOf(
"A" to "Rock",
"B" to "Paper",
"C" to "Scissors",
"X" to "Rock",
"Y" to "Paper",
"Z" to "Scissors"
)
val shapePoints = mapOf(
"Rock" to 1,
"Paper" to 2,
"Scissors" to 3
)
val winOver ... | 0 | Kotlin | 0 | 0 | a4b744a3e3c940c382aaa1d5f5c93ae0df124179 | 2,243 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/d16/d16.kt | LaurentJeanpierre1 | 573,454,829 | false | {"Kotlin": 118105} | package d16
import readInput
data class Valve(val name: String, val flow: Int, var next: List<String>) {
override fun hashCode(): Int {
return name.hashCode()
}
override fun equals(other: Any?): Boolean {
return other is Valve && name == other.name
}
}
val valves = mutableMapOf<String... | 0 | Kotlin | 0 | 0 | 5cf6b2142df6082ddd7d94f2dbde037f1fe0508f | 6,046 | aoc2022 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/com/github/brpeterman/advent2022/Rucksacks.kt | brpeterman | 573,059,778 | false | {"Kotlin": 53108} | package com.github.brpeterman.advent2022
class Rucksacks {
fun scoreMisfits(rucksacks: List<Pair<Set<String>, Set<String>>>): Int {
return rucksacks.fold(0) { total, sack ->
val misfit = sack.first.intersect(sack.second).first()
total + score(misfit)
}
}
fun scoreBa... | 0 | Kotlin | 0 | 0 | 1407ca85490366645ae3ec86cfeeab25cbb4c585 | 1,603 | advent2022 | MIT License |
src/main/kotlin/de/niemeyer/aoc2022/Day24.kt | stefanniemeyer | 572,897,543 | false | {"Kotlin": 175820, "Shell": 133} | /**
* Advent of Code 2022, Day 24: <NAME>
* Problem Description: https://adventofcode.com/2022/day/27
*/
package de.niemeyer.aoc2022
import de.niemeyer.aoc.direction.DirectionCCS
import de.niemeyer.aoc.direction.arrowToDirectionCCS
import de.niemeyer.aoc.points.Point2D
import de.niemeyer.aoc.utils.Resources.resour... | 0 | Kotlin | 0 | 0 | ed762a391d63d345df5d142aa623bff34b794511 | 3,986 | AoC-2022 | Apache License 2.0 |
src/Day5.kt | CyrilFind | 573,965,299 | false | {"Kotlin": 4160} | import java.util.Stack
fun main() {
val input = readInput("day5")
val stacks = List(9) { Stack<String>() }
val cratesRegex =
"""(?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) ) (?:\[(\w)\]| ( ) )"... | 0 | Kotlin | 0 | 0 | eb673682474d09c8f8b166c9e44ae52d85a777c9 | 2,052 | AoC2022 | Apache License 2.0 |
src/main/kotlin/aoc2023/Day11.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2023
import AoCDay
import kotlin.math.abs
// https://adventofcode.com/2023/day/11
object Day11 : AoCDay<Long>(
title = "Cosmic Expansion",
part1ExampleAnswer = 374,
part1Answer = 9639160,
part2Answer = 752936133304,
) {
private data class Galaxy(val x: Long, val y: Long)
private fu... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 1,581 | advent-of-code-kotlin | MIT License |
04/src/commonMain/kotlin/Main.kt | daphil19 | 725,415,769 | false | {"Kotlin": 131380} | import kotlin.math.pow
expect fun getLines(inputOrPath: String): List<String>
fun main() {
var lines = getLines(INPUT_FILE)
// lines = ("Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53\n" +
// "Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19\n" +
// "Card 3: 1 21 53 59 44 | 69 82 63 72... | 0 | Kotlin | 0 | 0 | 70646b330cc1cea4828a10a6bb825212e2f0fb18 | 1,788 | advent-of-code-2023 | Apache License 2.0 |
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day23/ALongWalk.kt | Gentleman1983 | 737,309,232 | false | {"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319} | package de.havox_design.aoc2023.day23
import de.havox_design.aoc.utils.kotlin.model.coordinates.*
import java.util.*
class ALongWalk(private var filename: String) {
private val ICON_FORREST = '#'
private val ICON_PATH = '.'
private val ICON_SLOPE_DOWN = 'v'
private val ICON_SLOPE_LEFT = '<'
privat... | 4 | Kotlin | 0 | 1 | 35ce3f13415f6bb515bd510a1f540ebd0c3afb04 | 7,456 | advent-of-code | Apache License 2.0 |
src/Day02.kt | mr-cell | 575,589,839 | false | {"Kotlin": 17585} | private val part1Scores =
mapOf(
"A X" to 1 + 3,
"A Y" to 2 + 6,
"A Z" to 3 + 0,
"B X" to 1 + 0,
"B Y" to 2 + 3,
"B Z" to 3 + 6,
"C X" to 1 + 6,
"C Y" to 2 + 0,
"C Z" to 3 + 3,
)
private val part2Scores =
mapOf(
"A X" to 3 + 0,... | 0 | Kotlin | 0 | 0 | 2528bf0f72bcdbe7c13b6a1a71e3d7fe1e81e7c9 | 983 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/dr206/2022/Day03.kt | dr206 | 572,377,838 | false | {"Kotlin": 9200} | fun main() {
fun findValueOfIntersectingLetters(listOfLists: List<List<String>>) = listOfLists.sumOf {
val letter = it.fold(it[0].toSet()) { acc, item ->
acc.intersect(item.toSet())
}.first()
letter.code % 32 + if (letter.isUpperCase()) 26 else 0
}
fun part1(input: List... | 0 | Kotlin | 0 | 0 | 57b2e7227d992de87a51094a971e952b3774fd11 | 946 | advent-of-code-in-kotlin | Apache License 2.0 |
src/main/kotlin/day2/Day2.kt | afTrolle | 572,960,379 | false | {"Kotlin": 33530} | package day2
import Day
import day2.Day2.Hand.*
import day2.Day2.Score.*
import ext.reverse
fun main() {
Day2("Day02").solve()
}
class Day2(input: String) : Day<List<Day2.Round>>(input) {
enum class Hand(val opponent: Char, val player: Char, val score: Int) {
Rock('A', 'X', 1),
Paper('B', 'Y... | 0 | Kotlin | 0 | 0 | 4ddfb8f7427b8037dca78cbf7c6b57e2a9e50545 | 1,801 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/aoc22/Day05.kt | tom-power | 573,330,992 | false | {"Kotlin": 254717, "Shell": 1026} | package aoc22
import common.Collections.transpose
import aoc22.Day05Runner.crane9000
import aoc22.Day05Runner.crane9001
import aoc22.Day05Domain.Movement
import aoc22.Day05Parser.toMovements
import aoc22.Day05Parser.toStacks
import common.Collections.partitionedBy
import common.Year22
object Day05: Year22 {
fun L... | 0 | Kotlin | 0 | 0 | baccc7ff572540fc7d5551eaa59d6a1466a08f56 | 2,441 | aoc | Apache License 2.0 |
src/main/kotlin/g0401_0500/s0407_trapping_rain_water_ii/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0401_0500.s0407_trapping_rain_water_ii
// #Hard #Array #Breadth_First_Search #Matrix #Heap_Priority_Queue
// #2022_12_03_Time_500_ms_(100.00%)_Space_64.7_MB_(100.00%)
import java.util.PriorityQueue
class Solution {
private class Cell(val row: Int, val col: Int, val value: Int) : Comparable<Cell?> {
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,624 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/day9.kt | kevinrobayna | 436,414,545 | false | {"Ruby": 195446, "Kotlin": 42719, "Shell": 1288} | fun day9ProblemReader(string: String): List<Long> {
return string
.split("\n")
.map { line -> line.toLong() }
.toList()
}
// https://adventofcode.com/2020/day/9
class Day9(
private val numbers: List<Long>,
private val preamble: Int,
) {
fun solvePart1(): Long {
for (in... | 0 | Ruby | 0 | 0 | 9e48ecdebdb4c479ef00f0fd3b1a44a211fb6577 | 1,851 | adventofcode_2020 | MIT License |
src/Day10/day10.kt | NST-d | 573,224,214 | false | null | package Day10
import utils.*
class Machine(instructions: List<Instruction>) {
private val instructions: Map<Int, Instruction>
private var registerOverTime: MutableMap<Int, Int>
init {
this.instructions = HashMap()
this.registerOverTime = HashMap()
registerOverTime[1] = 1
... | 0 | Kotlin | 0 | 0 | c4913b488b8a42c4d7dad94733d35711a9c98992 | 2,649 | aoc22 | Apache License 2.0 |
src/day08/Day08_part2.kt | seastco | 574,758,881 | false | {"Kotlin": 72220} | package day08
import readLines
fun traverseLeft(forest: List<List<Int>>, i: Int, j: Int): Int {
var count = 0
for (curr in j-1 downTo 0) {
count += 1
if (forest[i][j] <= forest[i][curr]) {
break
}
}
return count
}
fun traverseRight(forest: List<List<Int>>, i: In... | 0 | Kotlin | 0 | 0 | 2d8f796089cd53afc6b575d4b4279e70d99875f5 | 1,585 | aoc2022 | Apache License 2.0 |
src/Day04.kt | Kvest | 573,621,595 | false | {"Kotlin": 87988} | fun main() {
val testInput = readInput("Day04_test")
check(part1(testInput) == 2)
check(part2(testInput) == 4)
val input = readInput("Day04")
println(part1(input))
println(part2(input))
}
private fun part1(input: List<String>): Int {
return input
.map(String::parseSectionRanges)
... | 0 | Kotlin | 0 | 0 | 6409e65c452edd9dd20145766d1e0ea6f07b569a | 880 | AOC2022 | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximumWidthRamp.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,198 | kotlab | Apache License 2.0 |
src/Day04.kt | ben-dent | 572,931,260 | false | {"Kotlin": 10265} | fun main() {
fun part1(input: List<String>): Int {
return input.count { contains(it, 1) }
}
fun part2(input: List<String>): Int {
return input.count { contains(it, 2) }
}
// test if implementation meets criteria from the description, like:
val testInput = readInput("Day04_test... | 0 | Kotlin | 0 | 0 | 2c3589047945f578b57ceab9b975aef8ddde4878 | 1,266 | AdventOfCode2022Kotlin | Apache License 2.0 |
src/main/kotlin/days/Day11.kt | mstar95 | 317,305,289 | false | null | package days
import days.Cell.EMPTY
import days.Cell.FLOOR
import days.Cell.OCCUPIED
typealias NextCell = (Pair<Int, Int>, Cell, List<List<Cell>>) -> Cell
class Day11 : Day(11) {
override fun partOne(): Any {
val input = prepareInput(inputList)
//printRoad(input)
val board = live(input, ... | 0 | Kotlin | 0 | 0 | ca0bdd7f3c5aba282a7aa55a4f6cc76078253c81 | 3,463 | aoc-2020 | Creative Commons Zero v1.0 Universal |
src/day03/Day03.kt | sanyarajan | 572,663,282 | false | {"Kotlin": 24016} | package day03
import readInput
val priorityValues = mapOf(
'a' to 1,
'b' to 2,
'c' to 3,
'd' to 4,
'e' to 5,
'f' to 6,
'g' to 7,
'h' to 8,
'i' to 9,
'j' to 10,
'k' to 11,
'l' to 12,
'm' to 13,
'n' to 14,
'o' to 15,
'p' to 16,
'q' to 17,
'r' to 18... | 0 | Kotlin | 0 | 0 | e23413357b13b68ed80f903d659961843f2a1973 | 2,493 | Kotlin-AOC-2022 | Apache License 2.0 |
src/main/kotlin/ru/timakden/aoc/year2016/Day04.kt | timakden | 76,895,831 | false | {"Kotlin": 321649} | package ru.timakden.aoc.year2016
import arrow.core.Option
import arrow.core.none
import arrow.core.some
import ru.timakden.aoc.util.measure
import ru.timakden.aoc.util.readInput
/**
* [Day 4: Security Through Obscurity](https://adventofcode.com/2016/day/4).
*/
object Day04 {
@JvmStatic
fun main(args: Array<... | 0 | Kotlin | 0 | 3 | acc4dceb69350c04f6ae42fc50315745f728cce1 | 2,386 | advent-of-code | MIT License |
src/main/kotlin/day5/Day5.kt | stoerti | 726,442,865 | false | {"Kotlin": 19680} | package io.github.stoerti.aoc.day5
import io.github.stoerti.aoc.IOUtils
import io.github.stoerti.aoc.StringExt.longValues
import java.util.ListResourceBundle
import java.util.Locale
fun main(args: Array<String>) {
val lines = IOUtils.readInput("day_5_input").toMutableList().also { it.add("") }
val seeds = lines.... | 0 | Kotlin | 0 | 0 | 05668206293c4c51138bfa61ac64073de174e1b0 | 2,163 | advent-of-code | Apache License 2.0 |
archive/src/main/kotlin/com/grappenmaker/aoc/year20/Day21.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year20
import com.grappenmaker.aoc.PuzzleSet
import com.grappenmaker.aoc.onceSplit
fun PuzzleSet.day21() = puzzle(day = 21) {
data class Food(val ingredients: Set<String>, val allergens: List<String>)
val foods = inputLines.map { l ->
val (ingredientsParts, allergensPart)... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 1,661 | advent-of-code | The Unlicense |
src/Day04.kt | Excape | 572,551,865 | false | {"Kotlin": 36421} | fun main() {
fun parseRanges(input: List<String>) =
input.map { it.split(",").map { it.split("-").map { it.toInt() } } }
.map { Pair((it[0][0]..it[0][1]).toSet(), (it[1][0]..it[1][1]).toSet()) }
fun part1(input: List<String>) = parseRanges(input)
.count { (it.first union it.second... | 0 | Kotlin | 0 | 0 | a9d7fa1e463306ad9ea211f9c037c6637c168e2f | 733 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2022/Day02.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2022
import AoCDay
import aoc2022.Day02.Shape.*
import util.component1
import util.component2
import util.component3
import util.illegalInput
// https://adventofcode.com/2022/day/2
object Day02 : AoCDay<Int>(
title = "Rock Paper Scissors",
part1ExampleAnswer = 15,
part1Answer = 13809,
part2... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 2,287 | advent-of-code-kotlin | MIT License |
src/Day14.kt | undermark5 | 574,819,802 | false | {"Kotlin": 67472} |
sealed interface Direction {
object Down : Direction
object Left : Direction
object Right : Direction
object Unknown : Direction
}
data class Cave(val data: List<MutableList<Char>>)
fun main() {
fun canMove(currentPos: Pair<Int, Int>, cave: List<MutableList<Char>>): Direction {
if (curr... | 0 | Kotlin | 0 | 0 | e9cf715b922db05e1929f781dc29cf0c7fb62170 | 5,119 | AoC_2022_Kotlin | Apache License 2.0 |
src/main/kotlin/biz/koziolek/adventofcode/year2021/day21/day21.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2021.day21
import biz.koziolek.adventofcode.*
fun main() {
val inputFile = findInput(object {})
val lines = inputFile.bufferedReader().readLines()
val (player1, player2) = parseDiracDiceStartingPositions(lines)
val dice = RollCountingDice(DeterministicDice(sides =... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 5,496 | advent-of-code | MIT License |
aoc-2017/src/main/kotlin/nl/jstege/adventofcode/aoc2017/days/Day20.kt | JStege1206 | 92,714,900 | false | null | package nl.jstege.adventofcode.aoc2017.days
import nl.jstege.adventofcode.aoccommon.days.Day
import kotlin.math.abs
import kotlin.math.sqrt
/**
*
* @author <NAME>
*/
class Day20 : Day(title = "Particle Swarm") {
private companion object Configuration {
private const val TIME_LIMIT = 100000L
pri... | 0 | Kotlin | 0 | 0 | d48f7f98c4c5c59e2a2dfff42a68ac2a78b1e025 | 6,922 | AdventOfCode | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.