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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
app/src/main/java/com/example/SecretService/KylesMathPack.kt | PartlyFluked | 126,126,943 | false | {"C++": 129610, "C": 98209, "Kotlin": 10802, "CMake": 2384} | package com.example.SecretService
/**
* Created by menta on 29/03/2018.
*/
import java.lang.Math.pow
fun List<Int>.innerProduct(B:List<Int>): Int {
return zip(B)
.map { it.first * it.second }
.sum()
}
fun List<Int>.vandermond(): List<List<Int>> {
return map { xval -> List<Int>(size,... | 0 | C++ | 0 | 0 | d2540dcd1e362b2224b65fc63f1adca4689516ec | 2,308 | PASS-android | Apache License 2.0 |
src/main/kotlin/Puzzle13.kt | namyxc | 317,466,668 | false | null | import java.math.BigInteger
object Puzzle13 {
@JvmStatic
fun main(args: Array<String>) {
val input = Puzzle13::class.java.getResource("puzzle13.txt").readText()
val earliestBusNumberMultipledByWaitTime = earliestBusNumberMultipledByWaitTime(input)
println(earliestBusNumberMultipledByWa... | 0 | Kotlin | 0 | 0 | 60fa6991ac204de6a756456406e1f87c3784f0af | 2,296 | adventOfCode2020 | MIT License |
src/main/kotlin/io/dmitrijs/aoc2022/Day08.kt | lakiboy | 578,268,213 | false | {"Kotlin": 76651} | package io.dmitrijs.aoc2022
class Day08(input: List<String>) {
private val size = input.size
private val grid = input.map { row ->
row.map { it.digitToInt() }
}
fun puzzle1() = (size * 4 - 4) + (1 until (size - 1)).sumOf { y ->
(1 until (size - 1)).count { x -> Point(x, y).visible }
... | 0 | Kotlin | 0 | 1 | bfce0f4cb924834d44b3aae14686d1c834621456 | 1,547 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/Day07.kt | acunap | 573,116,784 | false | {"Kotlin": 23918} | import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
@OptIn(ExperimentalTime::class)
fun main() {
fun parseDirectories(input: List<String>) = buildMap {
put("", 0)
var cwd = ""
for(line in input) {
val match = """[$] cd (.*)|(\d*).*""".toRegex().matchEntire(line)... | 0 | Kotlin | 0 | 0 | f06f9b409885dd0df78f16dcc1e9a3e90151abe1 | 1,667 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/Day22.kt | Yeah69 | 317,335,309 | false | {"Kotlin": 73241} | class Day22 : Day() {
override val label: String get() = "22"
private val initialDecks by lazy {
fun String.toDeck(): List<Int> = this.lineSequence().drop(1).mapNotNull { it.toIntOrNull() }.toList()
val split = input.split("\r\n\r\n")
split[0].toDeck() to split[1].toDeck()
}
pr... | 0 | Kotlin | 0 | 0 | 23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec | 3,958 | AdventOfCodeKotlin | The Unlicense |
src/main/kotlin/aoc2015/Matchsticks.kt | komu | 113,825,414 | false | {"Kotlin": 395919} | package komu.adventofcode.aoc2015
import komu.adventofcode.utils.nonEmptyLines
fun matchsticks(input: String): Int {
val lines = input.nonEmptyLines()
return lines.sumBy { it.length } - lines.sumBy { it.decodedLength() }
}
fun matchsticks2(input: String): Int {
val lines = input.nonEmptyLines()
ret... | 0 | Kotlin | 0 | 0 | 8e135f80d65d15dbbee5d2749cccbe098a1bc5d8 | 968 | advent-of-code | MIT License |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem009.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
/**
* Problem 9
*
* A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
*
* a^2 + b^2 = c^2
*
* For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
*
* There exists exactly one Pythagorean triplet for which a + b + c = 1000.
* Find the product abc.
*... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 846 | project-euler | MIT License |
src/main/kotlin/se/saidaspen/aoc/aoc2018/Day12.kt | saidaspen | 354,930,478 | false | {"Kotlin": 301372, "CSS": 530} | package se.saidaspen.aoc.aoc2018
import se.saidaspen.aoc.util.Day
import se.saidaspen.aoc.util.e
import java.lang.RuntimeException
fun main() = Day12.run()
object Day12 : Day(2018, 12) {
private val rules: Set<String> = parseRules(input.lines())
private val initialState: String = input.lines().first().subs... | 0 | Kotlin | 0 | 1 | be120257fbce5eda9b51d3d7b63b121824c6e877 | 2,612 | adventofkotlin | MIT License |
src/Day04.kt | cgeesink | 573,018,348 | false | {"Kotlin": 10745} | fun main() {
fun part1(input: List<String>): Int {
val data = input.map { it.asRanges() }
return data.count { it.first fullyOverlaps it.second || it.second fullyOverlaps it.first }
}
fun part2(input: List<String>): Int {
val data = input.map { it.asRanges() }
return data.cou... | 0 | Kotlin | 0 | 0 | 137fb9a9561f5cbc358b7cfbdaf5562c20d6b10d | 1,053 | aoc-2022-in-kotlin | Apache License 2.0 |
src/main/kotlin/days/Day5.kt | andilau | 573,139,461 | false | {"Kotlin": 65955} | package days
@AdventOfCodePuzzle(
name = "Supply Stacks",
url = "https://adventofcode.com/2022/day/5",
date = Date(day = 5, year = 2022)
)
class Day5(input: List<String>) : Puzzle {
private val stacks = input
.takeWhile { it.isNotBlank() }
.reversed().drop(1)
.map { line -> lin... | 0 | Kotlin | 0 | 0 | da824f8c562d72387940844aff306b22f605db40 | 1,948 | advent-of-code-2022 | Creative Commons Zero v1.0 Universal |
rakeKotlin/src/main/java/tech/ippon/rakekotlin/KeywordsExtractor.kt | JulianClemot | 550,972,261 | false | {"Kotlin": 61528} | package tech.ippon.rakekotlin
import java.util.*
import kotlin.math.max
class KeywordsExtractor(stopWords: List<String> = stopWordsFr) {
private val stopWordsRegex: Regex by lazy {
stopWords.joinToString(separator = STOP_WORDS_DELIMITER) { "\\b$it(?![\\w-])" }.toRegex()
}
fun extract(content: St... | 0 | Kotlin | 1 | 2 | e1ff792d2a2cff1be0074e7806507e9cdd530824 | 3,214 | Ocear | MIT License |
src/Day01.kt | treegem | 572,875,670 | false | {"Kotlin": 38876} | import common.readInput
fun main() {
val day = "01"
fun part1(input: List<String>): Int {
val caloriesGrouped = groupCaloriesByElf(input)
return caloriesGrouped.maxOf { it.sum() }
}
fun part2(input: List<String>): Int {
val caloriesGrouped = groupCaloriesByElf(input)
... | 0 | Kotlin | 0 | 0 | 97f5b63f7e01a64a3b14f27a9071b8237ed0a4e8 | 1,159 | advent_of_code_2022 | Apache License 2.0 |
src/day03/Day03.kt | Volifter | 572,720,551 | false | {"Kotlin": 65483} | package day03
import utils.*
fun findDuplicate(lines: List<Set<Char>>): Char = lines.reduce { acc, chars ->
acc.intersect(chars)
}.single()
fun getPriority(c: Char): Int =
1 + (c.lowercaseChar() - 'a') + c.isUpperCase().compareTo(false) * 26
fun part1(input: List<String>): Int = input.sumOf { line ->
ge... | 0 | Kotlin | 0 | 0 | c2c386844c09087c3eac4b66ee675d0a95bc8ccc | 744 | AOC-2022-Kotlin | Apache License 2.0 |
src/main/kotlin/com/adventofcode/year2021/day3/part1/App.kt | demidko | 433,889,383 | false | {"Kotlin": 7692, "Dockerfile": 264} | package com.adventofcode.year2021.day3.part1
import com.adventofcode.year2021.day
import java.math.BigInteger
/**
* Calculates bits in one column
*/
class BitColumn {
private var trueCounter = 0L
private var falseCounter = 0L
fun collectBit(bit: Char) {
when (bit) {
'0' -> ++falseCounter
'1' ... | 0 | Kotlin | 0 | 0 | 2f42bede3ed0c4b17cb2575f6b61a1917a465bda | 1,488 | adventofcode | MIT License |
src/leetcodeProblem/leetcode/editor/en/WordSearch.kt | faniabdullah | 382,893,751 | false | null | //Given an m x n grid of characters board and a string word, return true if
//word exists in the grid.
//
// The word can be constructed from letters of sequentially adjacent cells,
//where adjacent cells are horizontally or vertically neighboring. The same letter
//cell may not be used more than once.
//
//
// Ex... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 2,635 | dsa-kotlin | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2023/day13/day13.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2023.day13
import biz.koziolek.adventofcode.*
import kotlin.math.min
fun main() {
val inputFile = findInput(object {})
val notes = parseNotes202313(inputFile.bufferedReader().readLines())
println("Summarized notes: ${notes.summarize()}")
println("Summarized notes ... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 6,781 | advent-of-code | MIT License |
advent-of-code/src/main/kotlin/com/akikanellis/adventofcode/year2022/Day14.kt | akikanellis | 600,872,090 | false | {"Kotlin": 142932, "Just": 977} | package com.akikanellis.adventofcode.year2022
import com.akikanellis.adventofcode.year2022.utils.Point
object Day14 {
private val SAND_STARTING_POINT = Point(500, 0)
fun unitsOfSandRestingBeforeFreefall(input: String) =
unitsOfSandResting(input, sandFreeFalls = true)
fun unitsOfSandRestingWhenFu... | 8 | Kotlin | 0 | 0 | 036cbcb79d4dac96df2e478938de862a20549dce | 3,141 | advent-of-code | MIT License |
calendar/day15/Day15.kt | starkwan | 573,066,100 | false | {"Kotlin": 43097} | package day15
import Day
import Lines
import kotlin.math.abs
class Day15 : Day() {
override fun part1(input: Lines): Any {
val targetY = 2000000
val sensorsAtTargetY = mutableSetOf<Int>()
val beaconsAtTargetY = mutableSetOf<Int>()
val infeasibleAtTargetY = mutableSetOf<Int>()
... | 0 | Kotlin | 0 | 0 | 13fb66c6b98d452e0ebfc5440b0cd283f8b7c352 | 3,198 | advent-of-kotlin-2022 | Apache License 2.0 |
src/Day04.kt | arisaksen | 573,116,584 | false | {"Kotlin": 42887} | import org.assertj.core.api.Assertions.assertThat
// https://adventofcode.com/2022/day/4
fun main() {
fun part1(items: List<String>): Int =
items
.map { it.split(",") }
.map { it.map { range -> (range.substringBefore("-").toInt()..range.substringAfter("-").toInt()) } }
... | 0 | Kotlin | 0 | 0 | 85da7e06b3355f2aa92847280c6cb334578c2463 | 1,300 | aoc-2022-kotlin | Apache License 2.0 |
src/Day02.kt | papichulo | 572,669,466 | false | {"Kotlin": 16864} | import kotlin.IllegalArgumentException
fun main() {
fun part2(input: List<String>): Int {
return input.sumOf { when(it) {
"A X" -> 3
"A Y" -> 4
"A Z" -> 8
"B X" -> 1
"B Y" -> 5
"B Z" -> 9
"C X" -> 2
"C Y" -> 6
... | 0 | Kotlin | 0 | 0 | e277ee5bca823ce3693e88df0700c021e9081948 | 1,083 | aoc-2022-in-kotlin | Apache License 2.0 |
2016/src/main/kotlin/com/koenv/adventofcode/Day3.kt | koesie10 | 47,333,954 | false | null | package com.koenv.adventofcode
object Day3 {
fun isTrianglePossible(input: String) = isTrianglePossible(getSides(input))
private fun isTrianglePossible(sides: List<Int>) = isTrianglePossible(sides[0], sides[1], sides[2])
private fun isTrianglePossible(a: Int, b: Int, c: Int): Boolean {
if (a + b ... | 0 | Kotlin | 0 | 0 | 29f3d426cfceaa131371df09785fa6598405a55f | 1,608 | AdventOfCode-Solutions-Kotlin | MIT License |
src/array/LeetCode88.kt | Alex-Linrk | 180,918,573 | false | null | package array
/**
* 合并两个有序数组
给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。
说明:
初始化 nums1 和 nums2 的元素数量分别为 m 和 n。
你可以假设 nums1 有足够的空间(空间大小大于或等于 m + n)来保存 nums2 中的元素。
示例:
输入:
nums1 = [1,2,3,0,0,0], m = 3
nums2 = [2,5,6], n = 3
输出: [1,2,2,3,5,6]
思路:
因为是两个有序数组,为了避免移动数组的麻烦,从后往前比较,
将有效的最大值放在最后面,并向... | 0 | Kotlin | 0 | 0 | 59f4ab02819b7782a6af19bc73307b93fdc5bf37 | 1,316 | LeetCode | Apache License 2.0 |
kotlin/src/katas/kotlin/leetcode/container_with_most_water/ContainerWithMostWater.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.container_with_most_water
import nonstdlib.listOfInts
import datsok.shouldEqual
import org.junit.Test
import kotlin.random.Random
/**
* https://leetcode.com/problems/container-with-most-water
*/
class ContainerWithMostWaterTests {
@Test fun `some examples`() {
listOf(1, 1).... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 2,141 | katas | The Unlicense |
kotlin/src/main/kotlin/dev/mikeburgess/euler/problems/Problem035.kt | mddburgess | 261,028,925 | false | null | package dev.mikeburgess.euler.problems
import dev.mikeburgess.euler.common.isEven
import dev.mikeburgess.euler.sequences.PrimeSequence
import kotlin.math.floor
import kotlin.math.log10
import kotlin.math.pow
/**
* The number 197 is called a circular prime because all rotations of the digits: 197, 971, and 719,
* ar... | 0 | Kotlin | 0 | 0 | 86518be1ac8bde25afcaf82ba5984b81589b7bc9 | 1,418 | project-euler | MIT License |
kotlin/src/katas/kotlin/leetcode/knapsack/Knapsack.kt | dkandalov | 2,517,870 | false | {"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C... | package katas.kotlin.leetcode.knapsack
import nonstdlib.*
import datsok.*
import org.junit.*
/**
* Guided by Priyo based on
* https://medium.com/@fabianterh/how-to-solve-the-knapsack-problem-with-dynamic-programming-eb88c706d3cf
*/
class KnapsackTests {
@Test fun `find maximum amount of meetings fitting hours... | 7 | Roff | 3 | 5 | 0f169804fae2984b1a78fc25da2d7157a8c7a7be | 4,737 | katas | The Unlicense |
src/main/kotlin/_2022/Day03.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2022
import readInput
fun main() {
fun findCommonChar(strings: List<String>): Collection<Char> {
return strings.map { it.toSet() }
.reduce(Set<Char>::intersect)
}
fun getCharPriority(it: Char): Int {
var result = (it - 'a') + 1
if (result < 0) {
r... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 1,064 | advent-of-code | Apache License 2.0 |
src/main/kotlin/dp/SOS.kt | yx-z | 106,589,674 | false | null | package dp
import java.util.*
// shortest oscillating supersequence
// find the definition of an oscillating sequence in 'LOS'
// find the definition of a supersequence in 'SCS'
// find sos of A[1..n] here
fun main(args: Array<String>) {
val A = intArrayOf(3, 10, 15, 9, 29)
println(sos(A))
}
fun sos(A: IntArray... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 1,135 | AlgoKt | MIT License |
src/main/kotlin/solutions/Day17PyroclasticFlow.kt | aormsby | 571,002,889 | false | {"Kotlin": 80084} | package solutions
import models.Coord2d
import models.Grid
import utils.Input
import utils.Solution
import kotlin.math.max
// run only this day
fun main() {
Day17PyroclasticFlow()
}
class Day17PyroclasticFlow : Solution() {
init {
begin("Day 17 - Pyroclastic Flow")
val input = Input.parseAll... | 0 | Kotlin | 0 | 0 | 1bef4812a65396c5768f12c442d73160c9cfa189 | 4,647 | advent-of-code-2022 | MIT License |
src/main/kotlin/treesandgraphs/EvaluateDivision.kt | e-freiman | 471,473,372 | false | {"Kotlin": 78010} | package treesandgraphs
private data class Vertex(val name: String, val edges: MutableList<Pair<Vertex, Double>>) {
var visited = false
}
class EvaluateDivision {
private val vertexes = mutableMapOf<String, Vertex>()
private fun dfs(v: Vertex, target: Vertex, value: Double): Pair<Boolean, Double> {
... | 0 | Kotlin | 0 | 0 | fab7f275fbbafeeb79c520622995216f6c7d8642 | 1,618 | LeetcodeGoogleInterview | Apache License 2.0 |
src/leetcodeProblem/leetcode/editor/en/FindTheWinnerOfTheCircularGame.kt | faniabdullah | 382,893,751 | false | null | //There are n friends that are playing a game. The friends are sitting in a
//circle and are numbered from 1 to n in clockwise order. More formally, moving
//clockwise from the iᵗʰ friend brings you to the (i+1)ᵗʰ friend for 1 <= i < n, and
//moving clockwise from the nᵗʰ friend brings you to the 1ˢᵗ friend.
//
// T... | 0 | Kotlin | 0 | 6 | ecf14fe132824e944818fda1123f1c7796c30532 | 3,339 | dsa-kotlin | MIT License |
src/Day07.kt | vitind | 578,020,578 | false | {"Kotlin": 60987} |
fun main() {
class Directory(directoryName: String, parentDirectory: Directory?) {
private val directoryName: String = directoryName
private val parentDirectory: Directory? = parentDirectory
private val innerDirectories = arrayListOf<Directory>()
private val files = arrayListOf<Pair... | 0 | Kotlin | 0 | 0 | 2698c65af0acd1fce51525737ab50f225d6502d1 | 5,604 | aoc2022 | Apache License 2.0 |
src/commonMain/kotlin/avl/AvlUtils.kt | EdwarDDay | 174,175,328 | false | null | /*
* Copyright 2019 <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 wr... | 0 | Kotlin | 0 | 0 | 219a58640619c74f60c02742baaeb9346524215b | 10,604 | SortedList | Apache License 2.0 |
src/year2022/day20/Day20.kt | lukaslebo | 573,423,392 | false | {"Kotlin": 222221} | package year2022.day20
import check
import readInput
fun main() {
// test if implementation meets criteria from the description, like:
val testInput = readInput("2022", "Day20_test")
check(part1(testInput), 3)
check(part2(testInput), 1623178306)
val input = readInput("2022", "Day20")
println(... | 0 | Kotlin | 0 | 1 | f3cc3e935bfb49b6e121713dd558e11824b9465b | 1,645 | AdventOfCode | Apache License 2.0 |
src/test/kotlin/Day11Test.kt | FredrikFolkesson | 320,692,155 | false | null | import Day11Test.Direction.*
import Day11Test.SeatStatus.*
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class Day11Test {
enum class SeatStatus {
Empty, Taken, Floor, Outside
}
enum class Direction {
UpLeft, Up, UpRight,
Left, Ri... | 0 | Kotlin | 0 | 0 | 79a67f88e1fcf950e77459a4f3343353cfc1d48a | 7,513 | advent-of-code | MIT License |
solutions/aockt/y2021/Y2021D08.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2021
import aockt.y2021.Y2021D08.Segment.*
import aockt.y2021.Y2021D08.SevenSegmentDigit.*
import io.github.jadarma.aockt.core.Solution
object Y2021D08 : Solution {
/** The individual segment indicators of a seven segment display. */
private enum class Segment { A, B, C, D, E, F, G }
/** ... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 5,689 | advent-of-code-kotlin-solutions | The Unlicense |
src/main/kotlin/day04/Day04.kt | Malo-T | 575,370,082 | false | null | package day04
private typealias Assignments = Pair<IntRange, IntRange>
private fun String.toIntRange(): IntRange = split("-").map { it.toInt() }.let { it[0]..it[1] }
// anonymous function
private val hasCompleteOverlap = fun(assignments: Assignments): Boolean {
with(assignments) {
return first.subtract(s... | 0 | Kotlin | 0 | 0 | f4edefa30c568716e71a5379d0a02b0275199963 | 1,016 | AoC-2022 | Apache License 2.0 |
src/test/kotlin/ch/ranil/aoc/aoc2023/Day18.kt | stravag | 572,872,641 | false | {"Kotlin": 234222} | package ch.ranil.aoc.aoc2023
import ch.ranil.aoc.AbstractDay
import ch.ranil.aoc.aoc2023.Direction.*
import org.junit.jupiter.api.Test
import kotlin.math.abs
import kotlin.test.assertEquals
class Day18 : AbstractDay() {
@Test
fun part1Test() {
assertEquals(62, compute1(testInput))
}
@Test
... | 0 | Kotlin | 1 | 0 | dbd25877071cbb015f8da161afb30cf1968249a8 | 2,957 | aoc | Apache License 2.0 |
src/d07/Main.kt | cweckerl | 572,838,803 | false | {"Kotlin": 12921} | package d07
import java.io.File
fun main() {
data class Trie(
val dir: String,
val children: MutableMap<String, Trie> = mutableMapOf(),
val parent: Trie? = null,
var dirSize: Long = 0L
)
// combining parts for this day
val input = File("src/d07/input").readLines()
... | 0 | Kotlin | 0 | 0 | 612badffbc42c3b4524f5d539c5cbbfe5abc15d3 | 1,248 | aoc | Apache License 2.0 |
app/src/main/java/com/exponential_groth/calculator/result/Util.kt | exponentialGroth | 680,748,973 | false | {"Kotlin": 144165, "CSS": 140} | package com.exponential_groth.calculator.result
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sign
import kotlin.math.sqrt
private val Double.mantissa get() = toBits() and 0x000fffffffffffffL/* or 0x0010000000000000L*/
private val Double.exponent get() = (toBits() and 0x7ff0000000000000 ushr 52) -... | 0 | Kotlin | 0 | 0 | 49a34a8dd7ff50c670db0ffdf255df135bda332e | 7,637 | Calculator | Apache License 2.0 |
Problem Solving/Algorithms/Basic - Counting Valleys.kt | MechaArms | 525,331,223 | false | {"Kotlin": 30017} | /*
An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly steps, for every step it was noted if it was an uphill, U, or a downhill, D step. Hikes always start and end at sea level, and each step up or down represents a 1 unit change in altitude. We define the following terms:
A m... | 0 | Kotlin | 0 | 1 | eda7f92fca21518f6ee57413138a0dadf023f596 | 2,629 | My-HackerRank-Solutions | MIT License |
src/main/kotlin/y2023/Day01.kt | jforatier | 432,712,749 | false | {"Kotlin": 44692} | package y2023
import common.Resources.splitOnEmpty
class Day01(private val data: List<String>) {
val VALID_DIGITS: Map<String, Int> = mapOf(
Pair("1", 1),
Pair("2", 2),
Pair("3", 3),
Pair("4", 4),
Pair("5", 5),
Pair("6", 6),
Pair("7", 7),
Pair("8", ... | 0 | Kotlin | 0 | 0 | 2a8c0b4ccb38c40034c6aefae2b0f7d4c486ffae | 1,922 | advent-of-code-kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/WordAbbreviation.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 | 6,631 | kotlab | Apache License 2.0 |
src/main/aoc2016/Day10.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2016
class Day10(input: List<String>) {
interface Instruction
private data class GetInstruction(val value: Int, val to: Int) : Instruction
private data class GiveInstruction(val who: Int,
val lowTo: Int, val lowIsBot: Boolean,
... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 3,560 | aoc | MIT License |
kotlin/src/com/daily/algothrim/leetcode/CommonChars.kt | idisfkj | 291,855,545 | false | null | package com.daily.algothrim.leetcode
/**
* 查找常用字符(leetcode 1002)
*
* 给定仅有小写字母组成的字符串数组 A,返回列表中的每个字符串中都显示的全部字符(包括重复字符)组成的列表。例如,如果一个字符在每个字符串中出现 3 次,但不是 4 次,则需要在最终答案中包含该字符 3 次。
* 你可以按任意顺序返回答案。
*
* 示例 1:
*
* 输入:["bella","label","roller"]
* 输出:["e","l","l"]
* 示例 2:
*
* 输入:["cool","lock","cook"]
* 输出:["c","o"]
... | 0 | Kotlin | 9 | 59 | 9de2b21d3bcd41cd03f0f7dd19136db93824a0fa | 3,022 | daily_algorithm | Apache License 2.0 |
src/main/kotlin/days/Day4.kt | wmichaelshirk | 315,495,224 | false | null | package days
typealias Passport = Map<String, String>
class Day4 : Day(4) {
private val fields = mapOf<String, (String) -> Boolean>(
"byr" to { p -> p.toIntOrNull() in 1920..2002 },
"iyr" to { p -> p.toIntOrNull() in 2010..2020 },
"eyr" to { p -> p.toIntOrNull() in 2020..2030 },
... | 0 | Kotlin | 0 | 0 | b36e5236f81e5368f9f6dbed09a9e4a8d3da8e30 | 1,776 | 2020-Advent-of-Code | Creative Commons Zero v1.0 Universal |
day04/part2.kts | bmatcuk | 726,103,418 | false | {"Kotlin": 214659} | // --- Part Two ---
// Just as you're about to report your findings to the Elf, one of you realizes
// that the rules have actually been printed on the back of every card this
// whole time.
//
// There's no such thing as "points". Instead, scratchcards only cause you to
// win more scratchcards equal to the number of ... | 0 | Kotlin | 0 | 0 | a01c9000fb4da1a0cd2ea1a225be28ab11849ee7 | 3,178 | adventofcode2023 | MIT License |
src/Day01/Day01.kt | Trisiss | 573,815,785 | false | {"Kotlin": 16486} | fun main() {
fun initListCalories(input: List<String>): List<Int> {
val listCalories = mutableListOf<Int>()
var sum = 0
input.forEachIndexed { index, element ->
element.toIntOrNull()?.let { num ->
sum += num
if (index == input.lastIndex) listCalor... | 0 | Kotlin | 0 | 0 | cb81a0b8d3aa81a3f47b62962812f25ba34b57db | 955 | AOC-2022 | Apache License 2.0 |
2022/src/main/kotlin/Day14.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import kotlin.math.sign
object Day14 {
fun part1(input: String): Int {
val grid = parseInput(input)
var count = 0
while (true) {
val settledSand = dropSand(grid)
if (settledSand.y > grid.maxY) {
break
}
grid.putSand(settledSand.x, settledSand.y)
count++
}
r... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 1,988 | advent-of-code | MIT License |
src/Day05.kt | vivekpanchal | 572,801,707 | false | {"Kotlin": 11850} | import java.util.Stack
fun main() {
val input = readInput("Day05")
val emptyLine = input.indexOfFirst { it.isEmpty() }
data class CrateMove(val items: Int, val from: Int, val to: Int)
val regex = Regex("\\d+")
fun parseCrateMove(command: String): CrateMove {
val (num, from, to) = regex.... | 0 | Kotlin | 0 | 0 | f21a2dd08be66520e9c9de14611e50c14ea017f0 | 1,980 | Aoc-kotlin | Apache License 2.0 |
aoc-2015/src/main/kotlin/aoc/AocDay15.kt | triathematician | 576,590,518 | false | {"Kotlin": 615974} | package aoc
import aoc.util.chunk
import aoc.util.chunkint
class AocDay15: AocDay(15) {
companion object { @JvmStatic fun main(args: Array<String>) { AocDay15().run() } }
override val testinput = """
Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8
Cinnamon: capacity ... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 1,830 | advent-of-code | Apache License 2.0 |
Algorithms/src/main/kotlin/AllWaysToMakeChange.kt | ILIYANGERMANOV | 557,496,216 | false | {"Kotlin": 74485} | fun numberOfWaysToMakeChange(n: Int, denoms: List<Int>): Int {
// Write your code here.
println("----------- CASE: n = $n, denoms = $denoms ----------------")
val allWays = ways(
n = n,
ds = denoms,
)
println("All ways: $allWays")
val uniqueWays = allWays.map { it.sorted() }.toSe... | 0 | Kotlin | 0 | 1 | 4abe4b50b61c9d5fed252c40d361238de74e6f48 | 862 | algorithms | MIT License |
src/main/kotlin/se/radicalcode/aoc/2.kt | gwendo | 162,547,004 | false | null | package se.radicalcode.aoc
fun hasNumberOfUniqueLetter(word: String, count: Int): Boolean {
return word.asSequence().groupingBy { it }.eachCount().filter {it.value == count}.count() > 0
}
fun calculateChecksum(wordList: List<String>): Int {
var hasTwoLetters = wordList.filter{ hasNumberOfUniqueLetter(it, 2) }... | 0 | Kotlin | 0 | 0 | 12d0c841c91695e215f06efaf62d06a5480ba7a2 | 1,148 | advent-of-code-2018 | MIT License |
src/main/kotlin/adventofcode/year2021/Day03BinaryDiagnostic.kt | pfolta | 573,956,675 | false | {"Kotlin": 199554, "Dockerfile": 227} | package adventofcode.year2021
import adventofcode.Puzzle
import adventofcode.PuzzleInput
class Day03BinaryDiagnostic(customInput: PuzzleInput? = null) : Puzzle(customInput) {
private val numbers by lazy { input.lines() }
override fun partOne(): Int {
val gammaRate = numbers.first().indices.map { inde... | 0 | Kotlin | 0 | 0 | 72492c6a7d0c939b2388e13ffdcbf12b5a1cb838 | 1,618 | AdventOfCode | MIT License |
src/Day04.kt | meletios | 573,316,028 | false | {"Kotlin": 4032} | fun main() {
var leftA = 0
var leftB = 0
var rightA = 0
var rightB = 0
fun rearrangeParts(parts: List<String>) {
if (parts[0].toInt() <= parts[2].toInt()) {
leftA = parts[0].toInt()
leftB = parts[1].toInt()
rightA = parts[2].toInt()
rightB = p... | 0 | Kotlin | 0 | 0 | 25549bde439b949f6dd091ccd69beb590d078787 | 1,383 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem63/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem63
/**
* LeetCode page: [63. Unique Paths II](https://leetcode.com/problems/unique-paths-ii/);
*/
class Solution {
/* Complexity:
* Time O(MN) and Space O(MN) where M and N are the number of rows and columns in obstacleGrid;
*/
fun uniquePathsWithObstacles(obst... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 1,292 | hj-leetcode-kotlin | Apache License 2.0 |
kotlin/2018/src/main/kotlin/2018/Lib03.kt | nathanjent | 48,783,324 | false | {"Rust": 147170, "Go": 52936, "Kotlin": 49570, "Shell": 966} | package aoc.kt.y2018;
/**
* Day 3.
*/
data class Point(
val x: Int,
val y: Int)
/** Part 1 */
fun processClaims1(input: String): String {
val claimMap = getClaimMap(input)
val overlapCount = claimMap.filter { it.value.count() > 1 } .count()
return overlapCount.toString()
}
/** Part 2... | 0 | Rust | 0 | 0 | 7e1d66d2176beeecaac5c3dde94dccdb6cfeddcf | 2,005 | adventofcode | MIT License |
src/main/kotlin/days/aoc2020/Day22.kt | bjdupuis | 435,570,912 | false | {"Kotlin": 537037} | package days.aoc2020
import days.Day
class Day22: Day(2020, 22) {
override fun partOne(): Any {
val players = parsePlayers(inputList)
while (players.none { it.hasLost() }) {
val drawn = players.mapIndexed { index, player ->
Pair(index,player.drawCard()!!)
}
... | 0 | Kotlin | 0 | 1 | c692fb71811055c79d53f9b510fe58a6153a1397 | 3,658 | Advent-Of-Code | Creative Commons Zero v1.0 Universal |
src/Day01.kt | f1qwase | 572,888,869 | false | {"Kotlin": 33268} | fun main() {
fun part1(input: List<String>): Int {
var currentCount = 0
var maxCount = 0
input.forEach {
if (it.isEmpty()) {
if (currentCount > maxCount) {
maxCount = currentCount
}
currentCount = 0
}... | 0 | Kotlin | 0 | 0 | 3fc7b74df8b6595d7cd48915c717905c4d124729 | 1,266 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/com/nibado/projects/advent/y2021/Day14.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2021
import com.nibado.projects.advent.*
object Day14 : Day {
private val values = resourceStrings(2021, 14).let { (template, rules) ->
template to
rules.split("\n").map { it.split(" -> ").let { (from, to) -> from to to } }.toMap()
}
private fun ... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,524 | adventofcode | MIT License |
src/main/kotlin/dev/siller/aoc2022/Day02.kt | chearius | 575,352,798 | false | {"Kotlin": 41999} | package dev.siller.aoc2022
private val example = """
A Y
B X
C Z
""".trimIndent()
private const val WIN = 6
private const val DRAW = 3
private const val LOSS = 0
private fun part1(input: List<String>): Int = input
.map {
val opponent = it[0] - 'A' + 1
val me = it[2] - 'X' + 1
... | 0 | Kotlin | 0 | 0 | e070c0254a658e36566cc9389831b60d9e811cc5 | 1,058 | advent-of-code-2022 | MIT License |
src/Day14.kt | a-glapinski | 572,880,091 | false | {"Kotlin": 26602} | import Day14.move
import utils.Coordinate2D
import utils.readInputAsLines
fun main() {
val input = readInputAsLines("day14_input")
val caveMap = input.flatMap { path ->
path.splitToSequence(" -> ")
.map { Coordinate2D(x = it.substringBefore(',').toInt(), y = it.substringAfter(',').toInt())... | 0 | Kotlin | 0 | 0 | c830d23ffc2ab8e9a422d015ecd413b5b01fb1a8 | 1,622 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/aoc2021/day6/Lanternfish.kt | arnab | 75,525,311 | false | null | package aoc2021.day6
object Lanternfish {
data class Fish(val counter: Int = 8) {
fun nextDay(): List<Fish> {
return if (counter == 0) {
listOf(Fish(6), Fish())
} else {
listOf(Fish(counter - 1))
}
}
}
fun parse(data: S... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 1,318 | adventofcode | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/round0/Questions57.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.round0
fun test57() {
val array = intArrayOf(1, 2, 4, 7, 11, 15)
print("和为15的两个数为:")
findNumbersWithSum(array, 15).forEach { print("$it ") }
println()
println()
val list1 = findContinuousSequence(15)
while (!list1.isEmpty) {
val value = list1.pop()
print("和为15的序列为:")
value.... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,549 | Algorithm | Apache License 2.0 |
src/Day15.kt | MartinsCode | 572,817,581 | false | {"Kotlin": 77324} | import kotlin.math.abs
class BeaconMap {
/**
* Value map is map of sensors and beacons.
*
* key stores coords of sensor, value is coord of beacon.
*/
private val map = mutableMapOf<Pair<Int, Int>, Pair<Int, Int>>()
private var minX = Int.MAX_VALUE
private var minY = Int.MAX_VALUE
... | 0 | Kotlin | 0 | 0 | 1aedb69d80ae13553b913635fbf1df49c5ad58bd | 7,531 | AoC-2022-12-01 | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem863/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem863
import com.hj.leetcode.kotlin.common.model.TreeNode
/**
* LeetCode page: [863. All Nodes Distance K in Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/);
*/
class Solution {
/* Complexity:
* Time O(N) and Space O(N) where N is the num... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,257 | hj-leetcode-kotlin | Apache License 2.0 |
capitulo5/src/main/kotlin/5.21BeaultifulStrings.kt | Cursos-Livros | 667,537,024 | false | {"Kotlin": 104564} | //5.21 (Embelezando Strings) Escreva métodos que realizam cada uma das seguintes tarefas:
//a) Verifique se a string termina com um ponto final e, caso contrário, adicione um ponto final.
//b) Verifique se a string começa com letra maiúscula, caso contrário, coloque a primeira letra em maiúscula.
//c) Use os métodos de... | 0 | Kotlin | 0 | 0 | f2e005135a62b15360c2a26fb6bc2cbad18812dd | 1,638 | Kotlin-Como-Programar | MIT License |
src/main/kotlin/g1501_1600/s1595_minimum_cost_to_connect_two_groups_of_points/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1595_minimum_cost_to_connect_two_groups_of_points
// #Hard #Array #Dynamic_Programming #Matrix #Bit_Manipulation #Bitmask
// #2023_06_14_Time_278_ms_(100.00%)_Space_38.4_MB_(100.00%)
class Solution {
fun connectTwoGroups(cost: List<List<Int>>): Int {
// size of set 1
val m = co... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,141 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/game/CountPoints.kt | jangalinski | 154,946,573 | false | null | package com.github.jangalinski.tidesoftime.game
import com.github.jangalinski.tidesoftime.Card
import com.github.jangalinski.tidesoftime.CardFeature
fun countPoints(k1: Kingdom, k2: Kingdom): Pair<Result, Result> {
// assert(k1.size == k2.size)
val r1 = Result(k1)
val r2 = Result(k2)
arrayOf(r1,r2).forEach... | 0 | Kotlin | 0 | 0 | 945109d12c3b089935f9fb1ea91633194cce8820 | 2,579 | tidesoftime | Apache License 2.0 |
aoc21/day_24/main.kt | viktormalik | 436,281,279 | false | {"Rust": 227300, "Go": 86273, "OCaml": 82410, "Kotlin": 78968, "Makefile": 13967, "Roff": 9981, "Shell": 2796} | import java.io.File
import kotlin.math.min
fun getVal(v: String, regs: Map<Char, Long>): Long =
if (v[0].isLetter()) regs.get(v[0])!! else v.toLong()
fun execSegment(input: Char, initZ: Long, code: List<String>): Long {
val regs = ('x'..'z').map { it to 0.toLong() }.toMap().toMutableMap()
regs.put('z', in... | 0 | Rust | 1 | 0 | f47ef85393d395710ce113708117fd33082bab30 | 2,202 | advent-of-code | MIT License |
src/main/kotlin/biz/koziolek/adventofcode/year2022/day13/day13.kt | pkoziol | 434,913,366 | false | {"Kotlin": 715025, "Shell": 1892} | package biz.koziolek.adventofcode.year2022.day13
import biz.koziolek.adventofcode.findInput
import java.util.ArrayDeque
import java.util.Deque
fun main() {
val inputFile = findInput(object {})
val packetPairs = parsePacketPairs(inputFile.bufferedReader().readLines())
println("Sum of packet pairs in right ... | 0 | Kotlin | 0 | 0 | 1b1c6971bf45b89fd76bbcc503444d0d86617e95 | 3,791 | advent-of-code | MIT License |
src/main/kotlin/com/github/davio/aoc/y2021/Day9.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2021
import com.github.davio.aoc.general.Day
import com.github.davio.aoc.general.call
import com.github.davio.aoc.general.getInputAsList
import kotlin.system.measureTimeMillis
fun main() {
Day9.getResultPart1()
measureTimeMillis {
Day9.getResultPart2()
}.call { printl... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 6,414 | advent-of-code | MIT License |
src/Day09.kt | er453r | 572,440,270 | false | {"Kotlin": 69456} | fun main() {
fun ropeTailTravel(input: List<String>, ropeLength: Int): Int {
val knots = Array(ropeLength) { Vector2d(0, 0) }
val visited = mutableSetOf(knots.last())
for (command in input) {
val (direction, steps) = command.split(" ")
repeat(steps.toInt()) {
... | 0 | Kotlin | 0 | 0 | 9f98e24485cd7afda383c273ff2479ec4fa9c6dd | 1,221 | aoc2022 | Apache License 2.0 |
src/Day10.kt | amelentev | 573,120,350 | false | {"Kotlin": 87839} | import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.atan2
fun main() {
val input = readInput("Day10")
val n = input.size
val m = input[0].length
val south = setOf('|', '7', 'F')
val north = setOf('|', 'L', 'J')
val west = setOf('-', 'J', '7')
val east = setOf('-', 'L', 'F')
... | 0 | Kotlin | 0 | 0 | a137d895472379f0f8cdea136f62c106e28747d5 | 3,017 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/dev/shtanko/algorithms/leetcode/AddBinary.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,107 | kotlab | Apache License 2.0 |
src/Day03.kt | rk012 | 574,169,156 | false | {"Kotlin": 9389} | private const val ITEM_TYPES = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun main() {
fun part1(input: List<String>) = input.map { items ->
items.length.let {
items.slice(0 until it / 2) to items.slice(it / 2 until it)
}
}.map { (item1, item2) ->
item1.find { it... | 0 | Kotlin | 0 | 0 | bfb4c56c4d4c8153241fa6aa6ae0e829012e6679 | 861 | advent-of-code-2022 | Apache License 2.0 |
src/exercises/Day14.kt | Njko | 572,917,534 | false | {"Kotlin": 53729} | // ktlint-disable filename
package exercises
import readInput
data class Coord(val x: Int, val y: Int)
fun main() {
fun extractPaths(input: List<String>) = input.map { line ->
val points = line.split(" -> ")
points.map {
val coord = it.split(",")
Coord(coord[0].toInt(), co... | 0 | Kotlin | 0 | 2 | 68d0c8d0bcfb81c183786dfd7e02e6745024e396 | 5,949 | advent-of-code-2022 | Apache License 2.0 |
leetcode-75-kotlin/src/main/kotlin/IsSubsequence.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
*
* A subsequence of a string is a new string that is formed from the original string by deleting some
* (can be none) of the characters without disturbing the relative positions of the remaining characters.
* (i.e., "ace"... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 1,206 | leetcode-75 | Apache License 2.0 |
src/main/kotlin/com/lucaszeta/adventofcode2020/day06/day06.kt | LucasZeta | 317,600,635 | false | null | package com.lucaszeta.adventofcode2020.day06
import com.lucaszeta.adventofcode2020.ext.getResourceAsText
fun main() {
val input = parseData(getResourceAsText("/day06/customs-form-answers.txt"))
val sumQuestionsAnyoneAnswered = input
.map(::countQuestionsAnyoneAnswered)
.reduce(Int::plus)
... | 0 | Kotlin | 0 | 1 | 9c19513814da34e623f2bec63024af8324388025 | 1,061 | advent-of-code-2020 | MIT License |
src/Day02.kt | maewCP | 579,203,172 | false | {"Kotlin": 59412} | fun main() {
fun calcScore(a: Int, b: Int): Int {
// draw
if (a == b) return 3 + b
// win
if ((a == 1 && b == 2) || (a == 2 && b == 3) || (a == 3 && b == 1)) return 6 + b
// lose
return b
}
fun followCmd(a: Int, command: String): Int {
return when (c... | 0 | Kotlin | 0 | 0 | 8924a6d913e2c15876c52acd2e1dc986cd162693 | 2,188 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/aoc2020/day9/XmasEncryption.kt | arnab | 75,525,311 | false | null | package aoc2020.day9
object XmasEncryption {
fun parse(data: String) = data.split("\n").map { it.toLong() }
fun findFirstInvalid(numbers: List<Long>, preamble: Int = 25) =
numbers.withIndex().find { (i, n) ->
if (i < preamble) {
false
} else {
va... | 0 | Kotlin | 0 | 0 | 1d9f6bc569f361e37ccb461bd564efa3e1fccdbd | 1,468 | adventofcode | MIT License |
advent/src/test/kotlin/org/elwaxoro/advent/y2022/Dec02.kt | elwaxoro | 328,044,882 | false | {"Kotlin": 376774} | package org.elwaxoro.advent.y2022
import org.elwaxoro.advent.PuzzleDayTester
import java.lang.IllegalStateException
/**
* Day 2: Rock Paper Scissors
*/
class Dec02 : PuzzleDayTester(2, 2022) {
/**
* Parse to RPS on both sides, then play as last against first
*/
override fun part1(): Any = load().... | 0 | Kotlin | 4 | 0 | 1718f2d675f637b97c54631cb869165167bc713c | 2,015 | advent-of-code | MIT License |
leetcode/src/queue/Q1700.kt | zhangweizhe | 387,808,774 | false | null | package queue
import java.util.*
fun main() {
// 1700. 无法吃午餐的学生数量
// https://leetcode-cn.com/problems/number-of-students-unable-to-eat-lunch/
println(countStudents1(intArrayOf(1,1,1,0,0,1), intArrayOf(1,0,0,0,1,1)))
}
fun countStudents(students: IntArray, sandwiches: IntArray): Int {
val stuQueue = ... | 0 | Kotlin | 0 | 0 | 1d213b6162dd8b065d6ca06ac961c7873c65bcdc | 1,486 | kotlin-study | MIT License |
AdventOfCodeDay10/src/nativeMain/kotlin/Day10.kt | bdlepla | 451,510,571 | false | {"Kotlin": 165771} | class Day10(private val lines:List<String>) {
fun solvePart1() = lines.map { it.decode() }.sumOf { it.score() }
fun solvePart2() = lines.filter { it.decode().score() == 0}
.map {it.fixLine()}.sorted().middle()
private fun <T> Iterable<T>.middle() = this.drop(this.count()/2).first()
private f... | 0 | Kotlin | 0 | 0 | 1d60a1b3d0d60e0b3565263ca8d3bd5c229e2871 | 1,762 | AdventOfCode2021 | The Unlicense |
src/Day01.kt | RaspiKonk | 572,875,045 | false | {"Kotlin": 17390} | /**
* Day 1: Count the calories in the elves' backpacks
*
* Part 1: Who has the most calories?
* Part 2: What are the top 3 calories combined?
*/
fun main()
{
val start = System.currentTimeMillis()
val DAY: String = "01"
println("Advent of Code 2022 - Day $DAY")
var calorieList: List<Int> = listOf()
fun pa... | 0 | Kotlin | 0 | 1 | 7d47bea3a5e8be91abfe5a1f750838f2205a5e18 | 1,267 | AoC_Kotlin_2022 | Apache License 2.0 |
Kotlin/src/main/kotlin/org/algorithm/problems/0055_spiral_matrix_i.kt | raulhsant | 213,479,201 | true | {"C++": 1035543, "Kotlin": 114509, "Java": 27177, "Python": 16568, "Shell": 999, "Makefile": 187} | // Problem Statement
// Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
// Input:
// [
// [ 1, 2, 3 ],
// [ 4, 5, 6 ],
// [ 7, 8, 9 ]
// ]
// Output: [1,2,3,6,9,8,7,4,5]
package org.algorithm.problems
class `0055_spiral_matrix_i` {
fun canWalk(row: Int, ... | 0 | C++ | 0 | 0 | 1578a0dc0a34d63c74c28dd87b0873e0b725a0bd | 1,572 | algorithms | MIT License |
src/main/kotlin/main.kt | stury | 390,913,839 | false | null | package main.kotlin
fun distances(maze:DistanceGrid, startCell:Cell? = null ) {
var start = maze.grid[0][0]
if ( startCell != null ) {
start = startCell
}
if (start != null ) {
var distances = start.distances()
maze.distances = distances
print("\nDistances from (${start.... | 0 | Kotlin | 0 | 1 | d85d9ab02b70a3d7d599ed93e91c65d3f7e7bd10 | 1,943 | MazesUsingKotlin | MIT License |
2022/src/main/kotlin/de/skyrising/aoc2022/day23/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2022.day23
import de.skyrising.aoc.*
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
private fun parseInput(input: PuzzleInput): MutableSet<Vec2i> {
val width = input.lines.maxOf { it.length }
val height = input.lines.size
val grid = CharGrid(width, height, CharArray(wid... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 2,647 | aoc | MIT License |
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Fenwick_Tree/Fenwick_Tree.kt | rajatenzyme | 325,100,742 | false | {"C++": 709855, "Java": 559443, "Python": 397216, "C": 381274, "Jupyter Notebook": 127469, "Go": 123745, "Dart": 118962, "JavaScript": 109884, "C#": 109817, "Ruby": 86344, "PHP": 63402, "Kotlin": 52237, "TypeScript": 21623, "Rust": 20123, "CoffeeScript": 13585, "Julia": 2385, "Shell": 506, "Erlang": 385, "Scala": 310, ... | /*Fenwick Tree is used when there is a problem of range sum query with update
i.e. RMQ. Suppose you have an array and you have been asked to find sum in
range. It can be done in linear time with static array method. If will be
difficult for one to do it in linear time when you have point updates. In this
update operati... | 0 | C++ | 0 | 0 | 65a0570153b7e3393d78352e78fb2111223049f3 | 3,219 | Coding-Journey | MIT License |
src/main/kotlin/aoc2018/day02_inventory_management/InventoryManagement.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package aoc2018.day02_inventory_management
import util.hasCharWithExactOccurrences
fun main() {
util.solve(7776, ::partOne)
util.solve("wlkigsqyfecjqqmnxaktdrhbz", ::partTwo)
}
fun partOne(input: String): Int {
val (doubles, triples) = input
.lines()
.fold(Pair(0, 0)) { (doubles, triples)... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 1,175 | aoc-2021 | MIT License |
src/main/kotlin/QuadTree.kt | hannomalie | 465,694,597 | false | {"Kotlin": 30338} | fun isInside(position: Vector2, min: Vector2, max: Vector2): Boolean {
return (position.x >= min.x && position.y >= min.y)
&& (position.x <= max.x && position.y <= max.y)
}
data class Vector2(val x: Float, val y: Float)
sealed class QuadTree(val min: Vector2, val max: Vector2) {
abstract fun insert... | 0 | Kotlin | 0 | 0 | 4349e8f881fda9ec29e2c9124d7dc0520f577a03 | 3,273 | artemis-playground | MIT License |
AoC2022/src/main/kotlin/xyz/danielstefani/Day2.kt | OpenSrcerer | 572,873,135 | false | {"Kotlin": 14185} | package xyz.danielstefani
import kotlin.math.abs
val shapeToScore = mapOf(
Pair("A", 1), // Rock
Pair("B", 2), // Paper
Pair("C", 3), // Scissors
Pair("X", 1), // Rock
Pair("Y", 2), // Paper
Pair("Z", 3) // Scissors
)
fun main(args: Array<String>) {
// Prep
val rounds = object {}.jav... | 0 | Kotlin | 0 | 3 | 84b9b62e15c70a4a17f8b2379dc29f9daa9f4be3 | 1,719 | aoc-2022 | The Unlicense |
advent-of-code-2021/src/main/kotlin/Day12.kt | jomartigcal | 433,713,130 | false | {"Kotlin": 72459} | //Day 12: Passage Pathing
//https://adventofcode.com/2021/day/12
import java.io.File
private const val START = "start"
val connections = mutableMapOf<String, MutableList<String>>()
fun main() {
File("src/main/resources/Day12.txt").readLines().sorted().map { connection ->
val (cave1, cave2) = connection.... | 0 | Kotlin | 0 | 0 | 6b0c4e61dc9df388383a894f5942c0b1fe41813f | 1,439 | advent-of-code | Apache License 2.0 |
src/Day01.kt | mcrispim | 573,449,109 | false | {"Kotlin": 46488} | fun main() {
var elvesCalories: List<Int>
fun calculateElvesCalories(input: List<String>): List<Int> {
val calories = mutableListOf<Int>()
var item = 0
var sum = 0
while(item < input.size) {
if (input[item] == "") {
calories.add(sum)
s... | 0 | Kotlin | 0 | 0 | 5fcacc6316e1576a172a46ba5fc9f70bcb41f532 | 1,076 | AoC2022 | Apache License 2.0 |
src/main/kotlin/NQueens.kt | embuc | 735,933,359 | false | {"Kotlin": 110920, "Java": 60263} | package se.embuc
fun placeQueens(boardSize: Int): List<List<String>> {
val results = mutableListOf<List<String>>()
val board = Array(boardSize) { CharArray(boardSize) { '.' } }
solveNQueens(board, 0, results)
return results
}
fun solveNQueens(board: Array<CharArray>, row: Int, results: MutableList<List<String>>) ... | 0 | Kotlin | 0 | 1 | 79c87068303f862037d27c1b33ea037ab43e500c | 1,104 | projecteuler | MIT License |
src/Day25.kt | matusekma | 572,617,724 | false | {"Kotlin": 119912, "JavaScript": 2024} | import kotlin.math.max
import kotlin.math.pow
class Day25 {
private val powerCountsMap = mutableMapOf<Int, Int>()
// fun part1_(input: List<String>): Long {
//
// while (currentCount !=) {
// if (currentCount % 10000000L == 0L) println(currentCount)
// var indexToIncrement: Int? = n... | 0 | Kotlin | 0 | 0 | 744392a4d262112fe2d7819ffb6d5bde70b6d16a | 4,771 | advent-of-code | Apache License 2.0 |
src/main/kotlin/Day17.kt | SimonMarquis | 570,868,366 | false | {"Kotlin": 50263} | import java.lang.System.lineSeparator
class Day17(private val input: String, rocks: String) {
fun part1(target: Long = 2022L) = Simulation(input.toList(), rocks).apply {
while (totalRocks != target) simulate()
}.top().inc()
fun part2(target: Long = 1_000_000_000_000L): Long = Simulation(input.toL... | 0 | Kotlin | 0 | 0 | a2129cc558c610dfe338594d9f05df6501dff5e6 | 2,838 | advent-of-code-2022 | Apache License 2.0 |
src/Day20.kt | timhillgit | 572,354,733 | false | {"Kotlin": 69577} | fun elfMix(numbers: MutableList<Long>, rounds: Int) {
val positions = MutableList(numbers.size) { it }
repeat(rounds) {
for (originalIndex in numbers.indices) {
val index = positions.indexOf(originalIndex)
positions.removeAt(index)
val value = numbers.removeAt(index)
... | 0 | Kotlin | 0 | 1 | 76c6e8dc7b206fb8bc07d8b85ff18606f5232039 | 1,005 | advent-of-code-2022 | Apache License 2.0 |
src/Day03.kt | Lonexera | 573,177,106 | false | null | fun main() {
fun String.splitInHalf(): Pair<String, String> {
return windowed(
size = length / 2,
step = length / 2
)
.zipWithNext()
.first()
}
fun Char.toElfErrorCode(): Int {
val alphabetString = "abcdefghijklmnopqrs... | 0 | Kotlin | 0 | 0 | c06d394cd98818ec66ba9c0311c815f620fafccb | 1,238 | kotlin-advent-of-code-2022 | Apache License 2.0 |
src/kotlin/_2022/Task08.kt | MuhammadSaadSiddique | 567,431,330 | false | {"Kotlin": 20410} | package _2022
import Task
import readInput
import utils.Matrix.adjacentRowsAndCols
import java.lang.Integer.max
typealias Grid = List<List<Int>>
object Task08 : Task {
override fun partA(): Int = traverseFold(parseInput()) { totalVisibleTrees, neighbours, treeHeight ->
neighbours
.map { neig... | 0 | Kotlin | 0 | 0 | 3893ae1ac096c56e224e798d08d7fee60e299a84 | 1,701 | AdventCode-Kotlin | Apache License 2.0 |
src/main/kotlin/com/github/michaelbull/advent2021/day24/ModelNumberAutomaticDetector.kt | michaelbull | 433,565,311 | false | {"Kotlin": 162839} | package com.github.michaelbull.advent2021.day24
import com.github.michaelbull.advent2021.day24.Instruction.Literal.Div
import com.github.michaelbull.advent2021.day24.VariableName.W
import com.github.michaelbull.advent2021.day24.VariableName.Z
import kotlin.math.max
import kotlin.math.pow
class ModelNumberAutomaticDet... | 0 | Kotlin | 0 | 4 | 7cec2ac03705da007f227306ceb0e87f302e2e54 | 3,459 | advent-2021 | ISC License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.