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/Day3.kt | devPalacio | 574,493,024 | false | {"Kotlin": 8009, "Python": 1346} | import java.io.File
import java.lang.Exception
fun main() {
val input = File("src/day3.txt").readLines()
val compartmented = input.map {
it.chunked(it.length / 2).map(String::toSet)
}
val elvesGrouped = input.chunked(3).map{it.map(String::toSet)}
fun findBadge(group: List<Set<Char>>) : C... | 0 | Kotlin | 0 | 0 | 648755244e07887335d05601b5fe78bdcb8b1baa | 995 | AoC-2022 | Apache License 2.0 |
src/chapter2/problem7/solution1.kts | neelkamath | 395,940,983 | false | null | /*
Question:
Intersection: Given two (singly) linked lists, determine if the two lists intersect. Return the intersecting node. Note
that the intersection is defined based on reference, not value. That is, if the kth node of the first linked list is the
exact same node (by reference) as the jth node of the second linke... | 0 | Kotlin | 0 | 0 | 4421a061e5bf032368b3f7a4cee924e65b43f690 | 2,850 | ctci-practice | MIT License |
src/main/kotlin/aoc2020/day03_toboggan_trajectory/TobogganTrajectory.kt | barneyb | 425,532,798 | false | {"Kotlin": 238776, "Shell": 3825, "Java": 567} | package aoc2020.day03_toboggan_trajectory
fun main() {
util.solve(176, ::partOne)
util.solve(5872458240, ::partTwo)
}
fun partOne(input: String) =
input.lines().foldIndexed(0) { row, agg, line ->
if (line[row * 3 % line.length] == '#') agg + 1
else agg
}
fun partTwo(input: String) =
... | 0 | Kotlin | 0 | 0 | a8d52412772750c5e7d2e2e018f3a82354e8b1c3 | 750 | aoc-2021 | MIT License |
src/main/kotlin/aoc2015/Day20.kt | lukellmann | 574,273,843 | false | {"Kotlin": 175166} | package aoc2015
import AoCDay
import kotlin.math.sqrt
// https://adventofcode.com/2015/day/20
object Day20 : AoCDay<Int>(
title = "Infinite Elves and Infinite Houses",
part1Answer = 665280,
part2Answer = 705600,
) {
private fun divisors(n: Int) = buildSet {
for (divisor in 1..sqrt(n.toDouble()... | 0 | Kotlin | 0 | 1 | 344c3d97896575393022c17e216afe86685a9344 | 1,082 | advent-of-code-kotlin | MIT License |
src/Day01.kt | isfaaghyth | 572,864,191 | false | {"Kotlin": 1561} | fun main() {
fun day01(input: List<String>): List<Int> {
val highers = mutableListOf<Int>()
var higher = 0
var temp = 0
for (i in input) {
if (i.isNotBlank()) {
temp += i.toInt()
} else {
if (temp > higher) {
... | 0 | Kotlin | 0 | 1 | ccd5dc526296808cd43f54a9a49c389c383f4c5a | 920 | adventofcode | Apache License 2.0 |
toml/src/main/kotlin/org/rust/toml/crates/local/CrateVersionRequirement.kt | Kobzol | 174,706,351 | true | {"Kotlin": 8149163, "Rust": 119828, "Python": 80380, "Lex": 20075, "HTML": 18030, "Java": 1274, "Shell": 760, "RenderScript": 89} | /*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package org.rust.toml.crates.local
import com.vdurmont.semver4j.Requirement
import com.vdurmont.semver4j.Semver
import com.vdurmont.semver4j.SemverException
class CrateVersionRequirement private constructor(pri... | 1 | Kotlin | 0 | 4 | 7d5f70bcf89dcc9c772efbeecf20fea7b0fb331e | 2,628 | intellij-rust | MIT License |
2023/src/main/kotlin/de/skyrising/aoc2023/day9/solution.kt | skyrising | 317,830,992 | false | {"Kotlin": 411565} | package de.skyrising.aoc2023.day9
import de.skyrising.aoc.*
import it.unimi.dsi.fastutil.ints.IntList
inline fun generate(list: IntList, pick: IntList.()->Int): IntList {
var splitPoint = list.size
while (true) {
list[splitPoint - 1] = pick(list.subList(0, splitPoint))
splitPoint--
var... | 0 | Kotlin | 0 | 0 | 19599c1204f6994226d31bce27d8f01440322f39 | 912 | aoc | MIT License |
src/Day06.kt | shoresea | 576,381,520 | false | {"Kotlin": 29960} | fun main() {
fun part1(inputs: List<String>): Int {
return getMarker(inputs[0], 4)
}
fun part2(inputs: List<String>): Int {
return getMarker(inputs[0], 14)
}
val input = readInput("Day06")
part1(input).println()
part2(input).println()
}
fun getMarker(input: String, distinc... | 0 | Kotlin | 0 | 0 | e5d21eac78fcd4f1c469faa2967a4fd9aa197b0e | 629 | AOC2022InKotlin | Apache License 2.0 |
src/main/kotlin/g1501_1600/s1568_minimum_number_of_days_to_disconnect_island/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1568_minimum_number_of_days_to_disconnect_island
// #Hard #Array #Depth_First_Search #Breadth_First_Search #Matrix #Strongly_Connected_Component
// #2023_06_14_Time_210_ms_(100.00%)_Space_35.9_MB_(100.00%)
@Suppress("kotlin:S107")
class Solution {
private val dirs = arrayOf(intArrayOf(0, 1), i... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 3,135 | LeetCode-in-Kotlin | MIT License |
src/2023/Day24.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2023`
import `2021`.sign
import java.io.File
import java.lang.RuntimeException
import java.math.BigInteger
import java.util.*
import kotlin.math.sign
fun main() {
Day24().solve()
}
class Day24 {
val input1 = """
19, 13, 30 @ -2, 1, -2
18, 19, 22 @ -1, -1, -2
20,... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 5,827 | advent-of-code | Apache License 2.0 |
2021/src/test/kotlin/Day10.kt | jp7677 | 318,523,414 | false | {"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338} | import kotlin.test.Test
import kotlin.test.assertEquals
class Day10 {
private val re = "[(\\[{<][)\\]}>]".toRegex()
@Test
fun `run part 01`() {
val lines = Util.getInputAsListOfString("day10-input.txt")
val errorScore = lines
.mapNotNull { it.getCorruptedClosingChar() }
... | 0 | Kotlin | 1 | 2 | 8bc5e92ce961440e011688319e07ca9a4a86d9c9 | 2,568 | adventofcode | MIT License |
mathevaluator/src/test/kotlin/com/github/vatbub/mathevaluator/FourEqualsTenHelp.kt | vatbub | 137,678,673 | false | {"Kotlin": 78857, "Java": 6074} | /*-
* #%L
* math-evaluator
* %%
* Copyright (C) 2019 - 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
*
* Unl... | 0 | Kotlin | 0 | 0 | 161919fc92e35ea1c4d93baee8ad32a630bb17c3 | 7,137 | mathevaluator | Apache License 2.0 |
src/Day21.kt | MickyOR | 578,726,798 | false | {"Kotlin": 98785} | fun main() {
class Monke {
var leaf = false
var leftChild: Monke? = null
var rightChild: Monke? = null
var op: String = ""
var value: Long = 0
var parent: Monke? = null
var toMove = false
}
fun getValue(node: Monke?) : Long {
if (node == null)... | 0 | Kotlin | 0 | 0 | c24e763a1adaf0a35ed2fad8ccc4c315259827f0 | 9,595 | advent-of-code-2022-kotlin | Apache License 2.0 |
src/main/kotlin/Day04.kt | bacecek | 574,824,698 | false | null | fun main() {
val inputRaw = loadInput("day04_input")
var part1Result = 0
var part2NumberOfOverlaps = 0
for (i in inputRaw.lines().indices) {
val line = inputRaw.lines()[i]
if (line.isBlank()) {
continue
}
val pairsRaw = line.split(",")
require(pairsRa... | 0 | Kotlin | 0 | 0 | c9a99b549d97d1e7a04a1c055492cf41653e78bb | 1,220 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/day21/Day21.kt | daniilsjb | 572,664,294 | false | {"Kotlin": 69004} | package day21
import java.io.File
fun main() {
val data = parse("src/main/kotlin/day21/Day21.txt")
val answer1 = part1(data)
val answer2 = part2(data)
println("🎄 Day 21 🎄")
println()
println("[Part 1]")
println("Answer: $answer1")
println()
println("[Part 2]")
println("... | 0 | Kotlin | 0 | 0 | 6f0d373bdbbcf6536608464a17a34363ea343036 | 3,997 | advent-of-code-2022 | MIT License |
src/main/kotlin/_2020/Day10.kt | thebrightspark | 227,161,060 | false | {"Kotlin": 548420} | package _2020
import aocRun
import splitToInts
import kotlin.math.pow
fun main() {
aocRun(testInput1) { input ->
val adapters = createSortedAdapterList(input)
val differenceMap = (0 until adapters.size - 1)
.map { adapters[it + 1] - adapters[it] }
.groupBy { it }
.mapValues { it.value.size }
println(d... | 0 | Kotlin | 0 | 0 | ac62ce8aeaed065f8fbd11e30368bfe5d31b7033 | 2,310 | AdventOfCode | Creative Commons Zero v1.0 Universal |
src/Day25.kt | flex3r | 572,653,526 | false | {"Kotlin": 63192} | import kotlin.math.pow
suspend fun main() {
val testInput = readInput("Day25_test")
check(part1(testInput) == "2=-1=0")
val input = readInput("Day25")
measureAndPrintResult {
part1(input)
}
}
private fun part1(input: List<String>): String {
return encode(input.sumOf(::decode))
}
priv... | 0 | Kotlin | 0 | 0 | 8604ce3c0c3b56e2e49df641d5bf1e498f445ff9 | 1,137 | aoc-22 | Apache License 2.0 |
src/main/kotlin/year2022/Day06.kt | forketyfork | 572,832,465 | false | {"Kotlin": 142196} | package year2022
class Day06 {
companion object {
fun solution(input: String, length: Int) = input.windowed(length)
.indexOfFirst { it.toSet().size == length } + length
fun linearSolution(input: String, length: Int): Int {
var distinctCount = 0
val charCounts = ... | 0 | Kotlin | 0 | 0 | 5c5e6304b1758e04a119716b8de50a7525668112 | 997 | aoc-2022 | Apache License 2.0 |
aoc2022/day17.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import aoc2022.Day17.RockType.MINUS
import aoc2022.Day17.RockType.MIRROR_L
import aoc2022.Day17.RockType.PLUS
import aoc2022.Day17.RockType.SQUARE
import aoc2022.Day17.RockType.VERTICAL
import utils.InputRetrieval
fun main() {
Day17.execute()
}
object Day17 {
fun execute() {
val inpu... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 5,228 | Advent-Of-Code | MIT License |
src/Utils.kt | dizney | 572,581,781 | false | {"Kotlin": 105380} | import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt")
.readLines()
/**
* Converts string to md5 hash.
*/
fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").dig... | 0 | Kotlin | 0 | 0 | f684a4e78adf77514717d64b2a0e22e9bea56b98 | 3,047 | aoc-2022-in-kotlin | Apache License 2.0 |
Algorithms/src/main/kotlin/net/milosvasic/algorithms/sort/efficient/HeapSort.kt | milos85vasic | 80,288,639 | false | null | package net.milosvasic.algorithms.sort.efficient
import net.milosvasic.algorithms.sort.Sort
class HeapSort<T : Comparable<T>> : Sort<T> {
private var count = 0
override fun sort(elements: MutableList<T>, ascending: Boolean) {
count = elements.size - 1
for (index in count / 2 downTo 0) {
... | 0 | Kotlin | 1 | 5 | a2be55959035654463b4855058d07ccfb68ac4a7 | 1,481 | Fundamental-Algorithms | Apache License 2.0 |
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12901.kt | boris920308 | 618,428,844 | false | {"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407} | package programmers.lv01
/**
* no.12901
* 2016년
* https://school.programmers.co.kr/learn/courses/30/lessons/12901
*
* 2016년 1월 1일은 금요일입니다.
* 2016년 a월 b일은 무슨 요일일까요?
* 두 수 a ,b를 입력받아 2016년 a월 b일이 무슨 요일인지 리턴하는 함수, solution을 완성하세요.
* 요일의 이름은 일요일부터 토요일까지 각각 SUN,MON,TUE,WED,THU,FRI,SAT 입니다.
* 예를 들어 a=5, b=24라면 5월 2... | 1 | Kotlin | 1 | 2 | 88814681f7ded76e8aa0fa7b85fe472769e760b4 | 1,205 | HoOne | Apache License 2.0 |
src/main/kotlin/aoc2021/Day20.kt | j4velin | 572,870,735 | false | {"Kotlin": 285016, "Python": 1446} | package aoc2021
import readInput
private fun Boolean.toInt() = if (this) 1 else 0
/**
* @param input the "image enhancement algorithm"
*/
private class ImageEnhancer(input: String) {
private val enhancement = input.map { it == '#' }.toBooleanArray()
/**
* Enhances the given image
* @param input... | 0 | Kotlin | 0 | 0 | f67b4d11ef6a02cba5b206aba340df1e9631b42b | 3,832 | adventOfCode | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/linked_list/Intersection.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.linked_list
import challenges.data_structure.LinkedListNode
import challenges.util.AssortedMethods
import kotlin.math.abs
/**
* Given two (singly) linked lists, determine if the two lists intersect.
* Return the intersecting node. Note that the intersection is defined ba... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,877 | CodingChallenges | Apache License 2.0 |
src/main/java/challenges/educative_grokking_coding_interview/sliding_window/_10/StringAnagrams.kt | ShabanKamell | 342,007,920 | false | null | package challenges.educative_grokking_coding_interview.sliding_window._10
/**
* Given a string and a pattern, find all anagrams of the pattern in the given string.
* Every anagram is a permutation of a string. As we know, when we are not allowed to repeat characters
* while finding permutations of a string, we get ... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,231 | CodingChallenges | Apache License 2.0 |
src/commonMain/kotlin/com/jeffpdavidson/kotwords/model/Labyrinth.kt | jpd236 | 143,651,464 | false | {"Kotlin": 4390419, "HTML": 41919, "Rouge": 3731, "Perl": 1705, "Shell": 744, "JavaScript": 618} | package com.jeffpdavidson.kotwords.model
import com.jeffpdavidson.kotwords.formats.Puzzleable
import kotlin.math.abs
data class Labyrinth(
val title: String,
val creator: String,
val copyright: String,
val description: String,
val grid: List<List<Char>>,
val gridKey: List<List<Int>>,
val r... | 5 | Kotlin | 5 | 19 | c2dc23bafc7236ba076a63060e08e6dc134c8e24 | 3,598 | kotwords | Apache License 2.0 |
2019/src/main/kotlin/adventofcode/day04/main.kt | analogrelay | 47,284,386 | false | {"Go": 93140, "F#": 42601, "Common Lisp": 36618, "Rust": 35214, "Kotlin": 15705, "Erlang": 15613, "TypeScript": 9933, "Swift": 4317, "HTML": 1721, "Shell": 1388, "PowerShell": 1180, "CSS": 990, "Makefile": 293, "JavaScript": 165} | package adventofcode.day04
fun main(args: Array<String>) {
if (args.size < 2) {
System.err.println("Usage: adventofcode day04 <START> <END>")
System.exit(1)
}
val start = args[0].toInt()
val end = args[1].toInt()
println("Computing passwords in range $start - $end")
val part1... | 0 | Go | 0 | 2 | 006343d0c05d12556605cc4d2c2d47938ce09045 | 2,119 | advent-of-code | Apache License 2.0 |
src/main/kotlin/day-05.kt | warriorzz | 728,357,548 | false | {"Kotlin": 15609, "PowerShell": 237} | package com.github.warriorzz.aoc
class Day5 : Day(5) {
override fun init() {
}
override val partOne: (List<String>, Boolean) -> String = { input, _ ->
val seeds1 = input[0].split(": ")[1].split(" ").map { it.toLong() }
val converterMaps1 = ArrayList<ArrayList<Triple<Long, Long, Long>>>()
... | 0 | Kotlin | 0 | 1 | 502993c1cd414c0ecd97cda41475401e40ebb8c1 | 2,983 | aoc-23 | MIT License |
src/Day05.kt | tristanrothman | 572,898,348 | false | null | import java.io.File
fun main() {
fun solve(input: String, multipleCrates: Boolean): String {
val inputs = input.split("\n\n")
val size = inputs.component1().split("\n").last().trim().last().toString().toInt()
val stacks = Array(size) {
ArrayDeque<Char>()
}
inpu... | 0 | Kotlin | 0 | 0 | e794ab7e0d50f22d250c65b20e13d9b5aeba23e2 | 1,687 | advent-of-code-2022 | Apache License 2.0 |
2017/src/main/kotlin/Day11.kt | dlew | 498,498,097 | false | {"Kotlin": 331659, "TypeScript": 60083, "JavaScript": 262} | import utils.splitCommas
import kotlin.math.abs
object Day11 {
fun part1(input: String): Int {
return input
.splitCommas()
.fold(Hex(0, 0, 0), { hex, direction -> hex.move(direction) })
.distanceFromCenter()
}
fun part2(input: String): Int {
val directions = input.splitCommas()
... | 0 | Kotlin | 0 | 0 | 6972f6e3addae03ec1090b64fa1dcecac3bc275c | 1,082 | advent-of-code | MIT License |
src/Day01.kt | m0r0 | 576,999,741 | false | null | fun main() {
fun part1(input: List<String>): Int {
var maxSum = 0
var curSum = 0
for (value in input) {
value.toIntOrNull()?.let { curSum += it }
?: run {
if (curSum > maxSum) maxSum = curSum
curSum = 0
}
... | 0 | Kotlin | 0 | 0 | b6f3c5229ad758f61f219040f8db61f654d7fc00 | 830 | kotlin-AoC-2022 | Apache License 2.0 |
src/main/kotlin/com/quakbo/euler/Euler6.kt | quincy | 120,237,243 | false | null | package com.quakbo.euler
/*
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of t... | 0 | Kotlin | 0 | 0 | 01d96f61bda6e87f1f58ddf7415d9bca8a4913de | 1,000 | euler-kotlin | The Unlicense |
src/main/kotlin/dev/shtanko/algorithms/sorts/TimSort.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,955 | kotlab | Apache License 2.0 |
Pells_equation/Kotlin/src/Pell.kt | ncoe | 108,064,933 | false | {"D": 425100, "Java": 399306, "Visual Basic .NET": 343987, "C++": 328611, "C#": 289790, "C": 216950, "Kotlin": 162468, "Modula-2": 148295, "Groovy": 146721, "Lua": 139015, "Ruby": 84703, "LLVM": 58530, "Python": 46744, "Scala": 43213, "F#": 21133, "Perl": 13407, "JavaScript": 6729, "CSS": 453, "HTML": 409} | import java.math.BigInteger
import kotlin.math.sqrt
class BIRef(var value: BigInteger) {
operator fun minus(b: BIRef): BIRef {
return BIRef(value - b.value)
}
operator fun times(b: BIRef): BIRef {
return BIRef(value * b.value)
}
override fun equals(other: Any?): Boolean {
... | 0 | D | 0 | 4 | c2a9f154a5ae77eea2b34bbe5e0cc2248333e421 | 1,659 | rosetta | MIT License |
examples/nearestNeighbor/src/main/kotlin/NearestNeighbor.kt | Kotlin | 225,367,588 | false | {"Kotlin": 435270, "C": 152277, "Python": 7577} | import org.jetbrains.numkt.*
import org.jetbrains.numkt.core.KtNDArray
import org.jetbrains.numkt.core.ravel
import org.jetbrains.numkt.math.*
import org.jetbrains.numkt.random.Random
fun generateRandomPoints(size: Int = 10, min: Int = 0, max: Int = 1): KtNDArray<Double> =
(max - min) * Random.randomSample(size, 2... | 11 | Kotlin | 11 | 313 | 2f1421883c201df60c57eaa4db4c3ee74dc40413 | 4,001 | kotlin-numpy | Apache License 2.0 |
shared/src/commonMain/kotlin/io/ktlab/bshelper/model/enums/SortEnum.kt | ktKongTong | 694,984,299 | false | {"Kotlin": 836333, "Shell": 71} | package io.ktlab.bshelper.model.enums
import io.ktlab.bshelper.model.IMap
enum class SortKey(val human: String, val slug: String) {
DEFAULT("默认", "default"),
NPS("NPS", "nps"),
DURATION("时长", "duration"),
NOTES("方块数", "notes"),
;
// BLOCKS,
override fun toString(): String {
ret... | 3 | Kotlin | 0 | 0 | 5e5ea79e31bc6c4a2565c191cddb7769e8007b45 | 1,971 | cm-bs-helper | MIT License |
stripecardscan/src/main/java/com/stripe/android/stripecardscan/framework/ml/NonMaximumSuppression.kt | stripe | 6,926,049 | false | {"Kotlin": 10509333, "Java": 71963, "Ruby": 22569, "Shell": 20387, "Python": 13907, "HTML": 7519} | package com.stripe.android.stripecardscan.framework.ml
import com.stripe.android.stripecardscan.framework.ml.ssd.RectForm
import com.stripe.android.stripecardscan.framework.ml.ssd.areaClamped
import com.stripe.android.stripecardscan.framework.ml.ssd.overlapWith
/**
* In this project we implement HARD NMS and NOT Sof... | 118 | Kotlin | 636 | 1,190 | af9342071f016bcfbb52d6561e311258081cd06a | 3,328 | stripe-android | MIT License |
src/Day01.kt | hanmet | 573,490,488 | false | {"Kotlin": 9896} | import java.util.regex.Pattern
fun main() {
fun part1(input: String): Int {
return input.split(Pattern.compile("\n\n"))
.map { line -> line.split("\n").map { num -> num.toInt() } }
.map { it.sum() }
.max()
}
fun part2(input: String): Int {
return input.s... | 0 | Kotlin | 0 | 0 | e4e1722726587639776df86de8d4e325d1defa02 | 774 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/fr/chezbazar/aoc23/day11/Day11.kt | chezbazar | 728,404,822 | false | {"Kotlin": 54427} | package fr.chezbazar.aoc23.day11
import fr.chezbazar.aoc23.Point
import fr.chezbazar.aoc23.computeFromIndexed
fun main() {
val galaxyMap = mutableListOf<Point>()
computeFromIndexed("day11/input.txt") { y, line ->
line.forEachIndexed { x, c ->
if (c == '#') {
galaxyMap.add(P... | 0 | Kotlin | 0 | 0 | 223f19d3345ed7283f4e2671bda8ac094341061a | 1,131 | adventofcode | MIT License |
src/2021/Day15.kt | nagyjani | 572,361,168 | false | {"Kotlin": 369497} | package `2021`
import common.*
import java.io.File
import java.util.*
fun main() {
Day15().solve()
}
class Day15 {
val input = """
1163751742
1381373672
2136511328
3694931569
7463417111
1319128137
1359912421
3125421639
1293138521
2311944581
""".trimIndent()
fun StringBuilder.toCave(): List<Int> {
... | 0 | Kotlin | 0 | 0 | f0c61c787e4f0b83b69ed0cde3117aed3ae918a5 | 2,603 | advent-of-code | Apache License 2.0 |
src/main/kotlin/days/Day07.kt | Kebaan | 573,069,009 | false | null | package days
import days.Day07.VirtualEntry.VirtualDirectory
import days.Day07.VirtualEntry.VirtualFile
import utils.Day
typealias VirtualPath = String
typealias FileSize = Int
fun main() {
Day07.solve()
}
object Day07 : Day<Int>(2022, 7) {
private val CD_COMMAND_REGEX = """[$] cd (.*)""".toRegex()
priv... | 0 | Kotlin | 0 | 0 | ef8bba36fedbcc93698f3335fbb5a69074b40da2 | 4,663 | Advent-of-Code-2022 | Apache License 2.0 |
advent-of-code-2021/src/main/kotlin/eu/janvdb/aoc2021/day11/Day11.kt | janvdbergh | 318,992,922 | false | {"Java": 1000798, "Kotlin": 284065, "Shell": 452, "C": 335} | package eu.janvdb.aoc2021.day11
import eu.janvdb.aocutil.kotlin.readNonSeparatedDigits
const val FILENAME = "input11.txt"
const val NUMBER_OF_STEPS = 100
fun main() {
part1()
part2()
}
private fun part1() {
val board = Board.create()
var result = 0
for (i in 0 until NUMBER_OF_STEPS) {
result += board.step()... | 0 | Java | 0 | 0 | 78ce266dbc41d1821342edca484768167f261752 | 2,299 | advent-of-code | Apache License 2.0 |
2020/09/Solution.kt | AdrianMiozga | 588,519,359 | false | {"Kotlin": 110785, "Python": 11275, "Assembly": 3369, "C": 2378, "Pawn": 1390, "Dart": 732} | import java.io.File
private const val FILENAME = "2020/09/input.txt"
private const val PREAMBLE = 25
fun main() {
val result = partOne()
partTwo(result)
}
private fun partOne(): Long {
var result = 0L
val lines = File(FILENAME).readLines()
entry@ for (i in PREAMBLE + 1 until lines.size) {
... | 0 | Kotlin | 0 | 0 | c9cba875089d8d4fb145932c45c2d487ccc7e8e5 | 1,454 | Advent-of-Code | MIT License |
aoc2022/day25.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import utils.InputRetrieval
import kotlin.math.pow
fun main() {
Day25.execute()
}
object Day25 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
}
private val DIGIT_MAP = mapOf('=' to -2, '-' to -1, '0' to 0, '1' to 1, '2' to 2)
private ... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 1,132 | Advent-Of-Code | MIT License |
Algorithms/Strings/Strong Password/Solution.kt | ahmed-mahmoud-abo-elnaga | 449,443,709 | false | {"Kotlin": 14218} | /*
Problem: https://www.hackerrank.com/challenges/strong-password/problem
Kotlin Language Version
Tool Version : Android Studio
Thoughts :
Keep iterating the input string untill
- at least one digit is found
- at least one lower case alphabet is found
-... | 0 | Kotlin | 1 | 1 | a65ee26d47b470b1cb2c1681e9d49fe48b7cb7fc | 1,720 | HackerRank | MIT License |
src/main/kotlin/com/staricka/adventofcode2022/Day21.kt | mathstar | 569,952,400 | false | {"Kotlin": 77567} | package com.staricka.adventofcode2022
import com.staricka.adventofcode2022.Day21.Monkey.Companion.parseMonkey
import java.util.Random
class Day21 : Day {
override val id = 21
interface Job {
fun value(monkeys: Map<String, Monkey>): Long
fun includesHuman(monkeys: Map<String, Monkey>): Boolean
}
clas... | 0 | Kotlin | 0 | 0 | 2fd07f21348a708109d06ea97ae8104eb8ee6a02 | 4,916 | adventOfCode2022 | MIT License |
CodeChef/TCTCTOE.kt | thedevelopersanjeev | 112,687,950 | false | null | private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private var states = hashMapOf<String, Int>()
private fun isWonOrDrawn(state: Array<Array<Char>>): Boolean {
var emptyCount = 0
... | 0 | C++ | 58 | 146 | 610520cc396fb13a03c606b5fb6739cfd68cc444 | 2,224 | Competitive-Programming | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/LengthOfLongestSubstring.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 3,322 | kotlab | Apache License 2.0 |
kotlin/minesweeper/src/main/kotlin/Minesweeper.kt | fredyw | 523,079,058 | false | null | data class MinesweeperBoard(val board: List<String>) {
fun withNumbers(): List<String> {
val maxRows = board.size
val maxCols = if (maxRows > 0) board[0].length else 0
return (0 until maxRows).map { row ->
(0 until maxCols).fold("") { acc, col ->
if (board[row][co... | 0 | Kotlin | 0 | 0 | 101a0c849678ebb7d2e15b896cfd9e5d82c56275 | 1,094 | exercism | MIT License |
2017/src/twentyfive/SporificaVirusChallenge.kt | Mattias1 | 116,139,424 | false | null | package twentyfive
import gridList.*
const val CLEAN = 0
const val WEAKENED = 1
const val INFECTED = 2
const val FLAGGED = 3
class SporificaVirusChallenge {
fun infectionBursts(input: List<String>, steps: Int = 10_000): Int {
val grid = buildGrid(input)
val carrier = buildCarrier(grid)
r... | 0 | Kotlin | 0 | 0 | 6bcd889c6652681e243d493363eef1c2e57d35ef | 3,153 | advent-of-code | MIT License |
src/main/kotlin/days/Day7.kt | C06A | 435,034,782 | false | {"Kotlin": 20662} | package days
import kotlin.math.roundToInt
class Day7 : Day(7) {
override fun partOne(): Any {
return inputList[0].split(","
).map {
it.toInt()
}.sorted().let { seq ->
val half = seq.drop(seq.size / 2).reversed()
seq.zip(half).fold(0) { sum, x: Pair<Int... | 0 | Kotlin | 0 | 0 | afbe60427eddd2b6814815bf7937a67c20515642 | 1,234 | Aoc2021 | Creative Commons Zero v1.0 Universal |
src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/MeasurementResults.kt | world-federation-of-advertisers | 349,561,061 | false | {"Kotlin": 8731680, "Starlark": 854205, "C++": 488657, "CUE": 153505, "HCL": 145480, "TypeScript": 103886, "Shell": 20694, "CSS": 8481, "Go": 8063, "JavaScript": 5305, "HTML": 2188} | /*
* Copyright 2023 The Cross-Media Measurement Authors
*
* 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 appl... | 103 | Kotlin | 10 | 32 | a22d079b0c292f3b056e066149f57c0ee2f71067 | 2,430 | cross-media-measurement | Apache License 2.0 |
src/main/kotlin/leetcode/Problem1718.kt | fredyw | 28,460,187 | false | {"Java": 1280840, "Rust": 363472, "Kotlin": 148898, "Shell": 604} | package leetcode
/**
* https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/
*/
class Problem1718 {
fun constructDistancedSequence(n: Int): IntArray {
return constructDistancedSequence(n, 0, HashSet(), IntArray(n * 2 - 1)).array
}
private class Answer(val found: B... | 0 | Java | 1 | 4 | a59d77c4fd00674426a5f4f7b9b009d9b8321d6d | 1,464 | leetcode | MIT License |
src/main/kotlin/g1501_1600/s1563_stone_game_v/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g1501_1600.s1563_stone_game_v
// #Hard #Array #Dynamic_Programming #Math #Game_Theory
// #2023_06_14_Time_371_ms_(100.00%)_Space_40.5_MB_(100.00%)
class Solution {
fun stoneGameV(stoneValue: IntArray): Int {
val n = stoneValue.size
val ps = IntArray(n)
ps[0] = stoneValue[0]
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,195 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/g0801_0900/s0847_shortest_path_visiting_all_nodes/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0801_0900.s0847_shortest_path_visiting_all_nodes
// #Hard #Dynamic_Programming #Breadth_First_Search #Bit_Manipulation #Graph #Bitmask
// #Graph_Theory_I_Day_10_Standard_Traversal
// #2023_03_29_Time_164_ms_(100.00%)_Space_35.8_MB_(88.89%)
import java.util.LinkedList
import java.util.Objects
import java.util... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,452 | LeetCode-in-Kotlin | MIT License |
src/main/kotlin/org/mechdancer/filters/algebra/Calculate.kt | MechDancer | 144,807,668 | false | null | package org.mechdancer.filters.algebra
import kotlin.math.PI
fun List<Complex>.dft(): List<Complex> {
val w0 = Complex.e.pow((-2 * PI / size).asIm())
return List(size) { k ->
mapIndexed { n, x ->
x * w0.pow((n * k).asRe())
}.sum()
}
}
fun List<Complex>.idft(): List<Complex> {
... | 0 | Kotlin | 0 | 1 | d266ccb7b4e704c90ffcba9a5b4a0fce55bd5be0 | 792 | filters | Do What The F*ck You Want To Public License |
src/main/kotlin/dev/forst/katlib/IterableExtensions.kt | LukasForst | 285,036,343 | false | {"Kotlin": 113999, "Makefile": 191} | package dev.forst.katlib
import java.util.NavigableSet
import java.util.TreeSet
import java.util.logging.Logger
import kotlin.collections.component1
import kotlin.collections.component2
import kotlin.random.Random
/**
* Function that will return a random element from the iterable.
*/
fun <E> Iterable<E>.getRandomE... | 9 | Kotlin | 2 | 76 | 3e26a31459a573edf484d7c4174a81cefcde5dc3 | 23,228 | katlib | MIT License |
fuzzyset.kt | manciuszz | 175,858,294 | false | null | class FuzzySet(arr: Array<String> = emptyArray(), val useLevenshtein: Boolean = true, val gramSizeLower: Int = 2, val gramSizeUpper: Int = 3) {
private val _nonWordRe = Regex("/[^a-zA-Z0-9\\u00C0-\\u00FF, ]+/g")
private val exactSet = mutableMapOf<String, String>()
private val matchDict = mutableMapOf<Stri... | 0 | Kotlin | 0 | 1 | c2d6232a8dcedd7667d941a7ce2744dd0a230089 | 7,289 | FuzzySet.kt | CNRI Python License |
src/main/kotlin/com/github/dangerground/aoc2020/Day11.kt | dangerground | 317,439,198 | false | null | package com.github.dangerground.aoc2020
import com.github.dangerground.aoc2020.util.DayInput
import com.github.dangerground.aoc2020.util.Direction
import com.github.dangerground.aoc2020.util.World
fun main() {
val process = Day11(DayInput.asWorld(11))
println("result part 1: ${process.part1()}")
println(... | 0 | Kotlin | 0 | 0 | c3667a2a8126d903d09176848b0e1d511d90fa79 | 3,288 | adventofcode-2020 | MIT License |
day09/kotlin/RJPlog/day2109_1_2.kts | razziel89 | 438,180,535 | true | {"Rust": 368326, "Python": 219109, "Go": 200337, "Kotlin": 80185, "Groovy": 67858, "JavaScript": 45619, "TypeScript": 43504, "CSS": 35030, "Shell": 18611, "C": 5260, "Ruby": 2359, "Dockerfile": 2285, "HTML": 227, "C++": 153} | import java.io.File
// tag::smokeBasin[]
fun smokeBasin(input1: Int, input2: Int, input3: List<Int>, input4: Int, input5: Int): Int {
var xpos = input1
var ypos = input2
var map = mutableListOf<Char>()
var width = input4
var height = input5
var result: Int = 1
input3.forEach {
map.add((it + 48).toChar())
}
... | 1 | Rust | 0 | 0 | 91a801b3c812cc3d37d6088a2544227cf158d114 | 3,534 | aoc-2021 | MIT License |
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[3]无重复字符的最长子串.kt | maoqitian | 175,940,000 | false | {"Kotlin": 354268, "Java": 297740, "C++": 634} | import kotlin.math.max
//给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
//
//
//
// 示例 1:
//
//
//输入: s = "abcabcbb"
//输出: 3
//解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
//
//
// 示例 2:
//
//
//输入: s = "bbbbb"
//输出: 1
//解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
//
//
// 示例 3:
//
//
//输入: s = "pwwkew"
//输出: 3
//解释: 因为无重复字符的最长子串是 "wke",所以其长度为 ... | 0 | Kotlin | 0 | 1 | 8a85996352a88bb9a8a6a2712dce3eac2e1c3463 | 1,718 | MyLeetCode | Apache License 2.0 |
src/lesson8/EquiLeader.kt | P3tran | 213,443,394 | false | null | package lesson8
import java.util.*
/*
* Find leaders in 2 array slices by checking if leader exists
* and using prefix occurrences sums after, on all array slices
* */
class EquiLeader {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val result = solution(intArrayOf(4... | 0 | Kotlin | 0 | 0 | 15c60656161bfab4d585792ad64390aa959fcc5e | 2,361 | CodilityLessonsKotlin | Apache License 2.0 |
src/main/kotlin/zanagram/App.kt | HenriqueRocha | 259,845,874 | false | null | package zanagram
import java.io.File
import kotlin.system.measureTimeMillis
fun permutations(s: String): List<String> {
val result = DynamicArray<String>()
permutations(s.toCharArray(), 0, s.length - 1, result)
return result
}
fun permutations(s: CharArray, lowerBound: Int, upperBound: Int, result: List<... | 1 | Kotlin | 0 | 0 | fbc4f2fc5489306dbc0eddfcd2a527745e297b78 | 1,410 | zanagram | MIT License |
app/icfpc2020/src/main/kotlin/ru/spbstu/SymbolUtil.kt | belyaev-mikhail | 280,179,984 | false | null | package ru.spbstu
fun Symbols.custom(data: String, name: String): Symbol.Custom {
val matrix = parseMatrix(data)
return Symbol.Custom(matrix, matrix.toCode(), name).also(::set)
}
fun Symbols.symbol(data: String): Symbol {
return get(parseMatrix(data))
}
fun Symbols.custom(data: String): Symbol.Custom {
... | 0 | Kotlin | 0 | 0 | 7d000e9b82416e51c4b6a06f19b703af8d5dec2a | 2,975 | icfpc2020-sub | MIT License |
src/main/kotlin/kr/co/programmers/P83201.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package kr.co.programmers
// https://github.com/antop-dev/algorithm/issues/314
class P83201 {
fun solution(scores: Array<IntArray>): String {
val n = scores.size
val answer = StringBuffer()
for (j in 0 until n) {
val arr = Array(n) { i -> scores[i][j] }
var min = In... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,181 | algorithm | MIT License |
src/Day10.kt | rmyhal | 573,210,876 | false | {"Kotlin": 17741} | import kotlin.math.abs
fun main() {
fun part1(input: List<String>): Int {
return first(input)
}
fun part2(input: List<String>): String {
return second(input)
}
val input = readInput("Day10")
println(part1(input))
println(part2(input))
}
private fun first(input: List<String>): Int {
var x = ... | 0 | Kotlin | 0 | 0 | e08b65e632ace32b494716c7908ad4a0f5c6d7ef | 1,098 | AoC22 | Apache License 2.0 |
hacker-rank/strings/SherlockAndTheValidString.kt | piazentin | 62,427,919 | false | {"Python": 34824, "Jupyter Notebook": 29307, "Kotlin": 19570, "C++": 2465, "R": 2425, "C": 158} | // https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem
fun main() {
val string = readLine().orEmpty()
println(if (isValid(string)) "YES" else "NO")
}
fun isValid(string: String): Boolean {
if (string.length <= 3) return true
val charFreq = IntArray('z' - 'a' + 1)
for (char i... | 0 | Python | 0 | 0 | db490b1b2d41ed6913b4cacee1b4bb40e15186b7 | 897 | programming-challenges | MIT License |
src/algorithm/HeapSort.kt | DavidZhong003 | 157,566,685 | false | null | package algorithm
/**
* 堆排序
* @author doive
* on 2019/6/25 20:20
*/
class HeapSort :IArraySort{
override fun sort(array: IntArray): IntArray {
if (array.size <= 1) {
return array
}
//构建最大堆
buildMaxHeap(array, array.size)
for (i in array.lastIndex downTo 1) ... | 0 | Kotlin | 0 | 1 | 7eabe9d651013bf06fa813734d6556d5c05791dc | 1,230 | LeetCode-kt | Apache License 2.0 |
src/Day03.kt | rweekers | 573,305,041 | false | {"Kotlin": 38747} | fun main() {
val alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun part1(input: List<String>): Int {
return input
.map { Pair(it.substring(0, it.length / 2), it.substring(it.length / 2)) }
.map { it.first.commonCharacter(it.second) }
.sumOf { alp... | 0 | Kotlin | 0 | 1 | 276eae0afbc4fd9da596466e06866ae8a66c1807 | 846 | adventofcode-2022 | Apache License 2.0 |
src/main/kotlin/com/github/amolkov/kotlin/algorithms/sorting/HeapSort.kt | amolkov | 122,844,991 | false | null | package com.github.amolkov.kotlin.algorithms.sorting
import com.github.amolkov.kotlin.algorithms.extensions.swap
class HeapSort {
companion object {
/**
* Sorts the specified array into ascending order, according to the natural ordering of its elements,
* using the heap sort algorith... | 0 | Kotlin | 0 | 0 | acb6bc2e397087fec8432b3307d0c0ea0c6ba75b | 1,245 | kotlin-algorithms | Apache License 2.0 |
src/cn/ancono/math/prob/ProbSpace.kt | 140378476 | 105,762,795 | false | {"Java": 1912158, "Kotlin": 1243514} | package cn.ancono.math.prob
import java.util.*
import kotlin.math.exp
import kotlin.math.ln
typealias Event = Map<ProbSpace<*>, Any?>
/**
* Describes the probability space in math, but it only provides method of generating
* random points in the space according to the probability of the space.
*
* Probability s... | 0 | Java | 0 | 6 | 02c2984c10a95fcf60adcb510b4bf111c3a773bc | 5,300 | Ancono | MIT License |
src/main/java/io/github/lunarwatcher/aoc/day4/Day4.kt | LunarWatcher | 160,042,659 | false | null | package io.github.lunarwatcher.aoc.day4
import io.github.lunarwatcher.aoc.commons.readFile
import io.github.lunarwatcher.aoc.day1.day1part2processor
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
enum class LogActio... | 0 | Kotlin | 0 | 1 | 99f9b05521b270366c2f5ace2e28aa4d263594e4 | 5,103 | AoC-2018 | MIT License |
src/test/kotlin/ch/ranil/aoc/aoc2023/Day21.kt | stravag | 572,872,641 | false | {"Kotlin": 234222} | package ch.ranil.aoc.aoc2023
import ch.ranil.aoc.AbstractDay
import ch.ranil.aoc.PrintColor
import ch.ranil.aoc.printColor
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
class Day21 : AbstractDay() {
@Test
fun part1Test() {
assertEquals(16, compute1(testInput, 6))
}
@Test
... | 0 | Kotlin | 1 | 0 | dbd25877071cbb015f8da161afb30cf1968249a8 | 3,848 | aoc | Apache License 2.0 |
Kotlin/problems/0047_group_of_anagrams.kt | oxone-999 | 243,366,951 | true | {"C++": 961697, "Kotlin": 99948, "Java": 17927, "Python": 9476, "Shell": 999, "Makefile": 187} | /* Problem Statement
Given an array of strings, group anagrams together.
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
] */
class Solution constructor() {
fun getStringArray(word : String): String{
var counter:IntArray = IntArray... | 0 | null | 0 | 0 | 52dc527111e7422923a0e25684d8f4837e81a09b | 1,412 | algorithms | MIT License |
src/SRanking.kt | nkkarpov | 302,503,568 | false | null | import java.lang.Math.*
fun SRanking(env: Environment, initM: List<Int>, budget: Int, R: Int): List<List<Int>> {
env.reset()
val n = env.n
val m = initM.toIntArray()
val C = List<MutableList<Int>>(m.size - 1) { mutableListOf() }
fun n(r: Int) = if (r == R) 0 else floor(pow(n.toDouble(), 1.0 - 1.0 ... | 0 | Kotlin | 0 | 0 | 0d0db3fe0c6e465eb7c7d49b6f284473138d9117 | 2,449 | batched-sorting | MIT License |
aoc-2015/src/main/kotlin/aoc/AocDay19.kt | triathematician | 576,590,518 | false | {"Kotlin": 615974} | package aoc
import aoc.util.chunk
class AocDay19: AocDay(19) {
companion object { @JvmStatic fun main(args: Array<String>) { AocDay19().run() } }
override val testinput = """
H => HO
H => OH
O => HH
e => H
e => O
HOHOHO
""".trimIndent().lines()
... | 0 | Kotlin | 0 | 0 | 7b1b1542c4bdcd4329289c06763ce50db7a75a2d | 2,412 | advent-of-code | Apache License 2.0 |
_7Function/src/main/kotlin/practice/62.0 Squirrel Play.kt | Meus-Livros-Lidos | 690,208,771 | false | {"Kotlin": 166470} | package practice
/**
* The squirrels spend most of their time playing. In particular, they play if the temperature is between 60 and 90, inclusive.
* Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean isSummer,
* return true if the squirrels are playing and false ... | 0 | Kotlin | 0 | 1 | 2d05e5528b9dd2cf9ed8799bce47444246be6b42 | 1,406 | LearnCsOnline-Kotlin | MIT License |
common/geometry/src/main/kotlin/com/curtislb/adventofcode/common/geometry/Point.kt | curtislb | 226,797,689 | false | {"Kotlin": 2146738} | package com.curtislb.adventofcode.common.geometry
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.atan2
/**
* A point with integer x- and y-coordinates on a 2D grid.
*
* @property x The x-coordinate of the point.
* @property y The y-coordinate of the point.
*
* @constructor Creates a new instanc... | 0 | Kotlin | 1 | 1 | 6b64c9eb181fab97bc518ac78e14cd586d64499e | 7,243 | AdventOfCode | MIT License |
codeforces/vk2022/qual/c.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package codeforces.vk2022.qual
private fun solve() {
readln()
val a = readInts()
var ans = 1
var nextHigh = a.last() + 1
val seen = mutableSetOf<Pair<Int, Int>>()
for (i in a.indices.reversed()) {
for (t in 1 downTo 0) {
val high = a[i] + t
if (high > nextHigh) continue
nextHigh = nextHigh.coerceAtMos... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 782 | competitions | The Unlicense |
src/main/kotlin/Day4.kt | d1snin | 726,126,205 | false | {"Kotlin": 14602} | /*
* 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 wr... | 0 | Kotlin | 0 | 0 | 8b5b34c4574627bb3c6b1a12664cc6b4c9263e30 | 3,416 | aoc-2023 | Apache License 2.0 |
app/src/main/kotlin/io/github/andrewfitzy/day07/Task02.kt | andrewfitzy | 747,793,365 | false | {"Kotlin": 60159, "Shell": 1211} | package io.github.andrewfitzy.day07
class Task02(puzzleInput: List<String>) {
private val input: List<String> = puzzleInput
fun solve(): Int {
var count = 0
for (line in input) {
val splits = line.split("[")
val hypernetSplits =
splits.filter { value -> ... | 0 | Kotlin | 0 | 0 | 15ac072a14b83666da095b9ed66da2fd912f5e65 | 1,942 | 2016-advent-of-code | Creative Commons Zero v1.0 Universal |
affogato-core-ktx/src/main/java/com/parsuomash/affogato/core/ktx/collections/Map.kt | ghasemdev | 510,960,043 | false | {"Kotlin": 951820, "Shell": 3263} | package com.parsuomash.affogato.core.ktx.collections
/**
* Returns a [HashMap] containing all elements.
*
* Example:
* ```Kotlin
* mapOf(1 to 2, 2 to 3).toHashMap() // {1=2, 2=3}
* ```
* @since 1.1.0
*/
inline fun <reified K, V> Map<K, V>.toHashMap(): HashMap<K, V> = HashMap(this)
/**
* Returns a [LinkedHash... | 1 | Kotlin | 1 | 12 | 36ec37d6b08d089b3ea4e8aad239e00a747d49e5 | 2,246 | affogato | MIT License |
kotlin/complex-numbers/src/main/kotlin/ComplexNumber.kt | fredyw | 523,079,058 | false | null | import kotlin.math.*
data class ComplexNumber(val real: Double = 0.0, val imag: Double = 0.0) {
val abs: Double = sqrt(real.pow(2) + imag.pow(2))
}
operator fun ComplexNumber.plus(other: ComplexNumber): ComplexNumber =
ComplexNumber(
real = this.real + other.real,
imag = this.imag + other.imag... | 0 | Kotlin | 0 | 0 | 101a0c849678ebb7d2e15b896cfd9e5d82c56275 | 1,333 | exercism | MIT License |
src/main/kotlin/com/dvdmunckhof/aoc/event2021/Day03.kt | dvdmunckhof | 318,829,531 | false | {"Kotlin": 195848, "PowerShell": 1266} | package com.dvdmunckhof.aoc.event2021
class Day03(private val input: List<String>) {
private val bitIndices = 0 until input.first().length
fun solvePart1(): Int {
var gamma = 0
var epsilon = 0
for (index in bitIndices) {
val count = input.count { it[it.length - index - 1] ... | 0 | Kotlin | 0 | 0 | 025090211886c8520faa44b33460015b96578159 | 1,280 | advent-of-code | Apache License 2.0 |
src/Day05.kt | chasegn | 573,224,944 | false | {"Kotlin": 29978} | import java.util.*
/**
* Day 05 for Advent of Code 2022
* https://adventofcode.com/2022/day/5
*/
class Day05 : Day {
override val inputFileName: String = "Day05"
override val test1Expected: String = "CMZ"
override val test2Expected: String = "MCD"
/**
* Accepted solution: "CNSZFDVLJ"
*/
... | 0 | Kotlin | 0 | 0 | 2b9a91f083a83aa474fad64f73758b363e8a7ad6 | 3,465 | advent-of-code-2022 | Apache License 2.0 |
LeetCode/Easy/balanced-binary-tree/Solution.kt | GregoryHo | 254,657,102 | false | null | class Solution {
fun isBalanced(root: TreeNode?): Boolean {
return dfs(root).balanced
}
private fun dfs(root: TreeNode?): NodeStatus {
if (root == null) {
return NodeStatus(true, 0)
}
val leftNodeStatus = dfs(root.left)
// just interupt when one subtree is not balanced
if (!leftNo... | 0 | Kotlin | 0 | 0 | 8f126ffdf75aa83a6d60689e0b6fcc966a173c70 | 1,462 | coding-fun | MIT License |
src/main/kotlin/com/booleworks/packagesolver/solver/PackageSolver.kt | booleworks | 497,876,711 | false | {"Kotlin": 30454} | package com.booleworks.packagesolver.solver
import com.booleworks.packagesolver.data.*
import com.booleworks.packagesolver.translation.ProblemTranslator
import org.logicng.datastructures.Assignment
import org.logicng.datastructures.Tristate
import org.logicng.formulas.FormulaFactory
import org.logicng.formulas.Variabl... | 0 | Kotlin | 0 | 0 | e99b2e19599720866a0172b5c30047d37862343c | 6,271 | package-solving-poc | MIT License |
src/Day01.kt | thelmstedt | 572,818,960 | false | {"Kotlin": 30245} | import java.io.File
fun main() {
fun part1(text: String) {
text.split("\n\n")
.filter { it.isNotBlank() }
.map { elf -> elf.lineSequence().filter { it.isNotBlank() }.sumOf { it.toInt() } }
.mapIndexed { index, i -> Pair(index + 1, i) }
.maxBy { it.second }
... | 0 | Kotlin | 0 | 0 | e98cd2054c1fe5891494d8a042cf5504014078d3 | 951 | advent2022 | Apache License 2.0 |
src/main/kotlin/day08/Main.kt | jhreid | 739,775,732 | false | {"Kotlin": 13073} | package day08
import java.io.File
fun main() {
val input = File("./day08.txt").readLines(Charsets.UTF_8)
val screen = Array(6) { Array(50) { '.' } }
val rectDigits = """.* (\d+)x(\d+)""".toRegex()
val rotateDigits = """.*=(\d+) by (\d+)""".toRegex()
input.forEach { instruction ->
when {
... | 0 | Kotlin | 0 | 0 | 8eeb2bc6b13e76d83a5403ae087729e2c3bbadb1 | 2,034 | AdventOfCode2016 | Apache License 2.0 |
src/main/kotlin/g2501_2600/s2580_count_ways_to_group_overlapping_ranges/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2501_2600.s2580_count_ways_to_group_overlapping_ranges
// #Medium #Array #Sorting #2023_07_10_Time_669_ms_(100.00%)_Space_122.8_MB_(50.00%)
import java.util.Arrays
@Suppress("NAME_SHADOWING")
class Solution {
fun countWays(ranges: Array<IntArray>): Int {
var cnt = 1
Arrays.sort(ranges) {... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,148 | LeetCode-in-Kotlin | MIT License |
Kotlin/code/FirstAPP/app/src/main/java/com/example/firstapp/lesson/Caculator.kt | hairyOwl | 416,770,569 | false | {"Kotlin": 109185, "Java": 291} | package com.example.firstapp.lesson
import java.lang.Exception
/**
*@author: hairly owl
*@time:2021/10/13 21:22
*@version: 1.00
*@description: 一次四则运算计算机器
*/
fun main() {
while(true){
println("==========请输入你的表达式==========")
//接受控制台输入数据
val input:String? = readLine() //判空的校验
tr... | 0 | Kotlin | 0 | 0 | 278c8d74a305d1213ce9b8587f6ba2b8fa8aa7b9 | 2,073 | AndroidStudy | Apache License 2.0 |
facebook/y2020/round3/a.kt | mikhail-dvorkin | 93,438,157 | false | {"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408} | package facebook.y2020.round3
import java.lang.StringBuilder
private fun solve(): String {
var k = readInt() / 2
val main = minOf(100, k + 2)
var vertices = main
val edges = mutableListOf<Pair<Int, Int>>()
for (i in 1 until main) {
edges.add(i - 1 to i)
}
k -= main - 2
for (i in 1..main - 2) {
var deg = 2... | 0 | Java | 1 | 9 | 30953122834fcaee817fe21fb108a374946f8c7c | 1,016 | competitions | The Unlicense |
src/main/aoc2018/Day20.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2018
import java.util.*
class Day20(input: String) {
private data class Pos(val x: Int, val y: Int) {
fun move(dir: Char): Pos {
return when (dir) {
'N' -> Pos(x, y - 1)
'S' -> Pos(x, y + 1)
'W' -> Pos(x - 1, y)
'E' ->... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 1,678 | aoc | MIT License |
Algo_Ds_Notes-master/Algo_Ds_Notes-master/Jhonson_Algoritm/Jhonson_Algorithm.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, ... | fun main()
{
var vert = 0
var edge = 0
var i = 0
var j = 0
var k = 0
var c = 0
var inf = 999999;
var cost = Array(10, {IntArray(10)})
var adj = Array(10, {IntArray(10)})
println("Enter no of vertices: ")
vert = readLine() !!.toInt()
println("Enter no of Edges: ");
ed... | 0 | C++ | 0 | 0 | 65a0570153b7e3393d78352e78fb2111223049f3 | 1,558 | Coding-Journey | MIT License |
kotlin/0377-combination-sum-iv.kt | neetcode-gh | 331,360,188 | false | {"JavaScript": 473974, "Kotlin": 418778, "Java": 372274, "C++": 353616, "C": 254169, "Python": 207536, "C#": 188620, "Rust": 155910, "TypeScript": 144641, "Go": 131749, "Swift": 111061, "Ruby": 44099, "Scala": 26287, "Dart": 9750} | //dp solution
class Solution {
fun combinationSum4(nums: IntArray, target: Int): Int {
val dp = IntArray(target + 1)
dp[0] = 1
for (i in 1..target) {
for (n in nums) {
if(i - n >= 0) dp[i] += dp[i - n]
}
}
return dp[target]
... | 337 | JavaScript | 2,004 | 4,367 | 0cf38f0d05cd76f9e96f08da22e063353af86224 | 847 | leetcode | MIT License |
2021/app/src/main/kotlin/net/sympower/aok2021/tonis/Day02.kt | tonisojandu | 573,036,346 | false | {"Rust": 158858, "Kotlin": 15806, "Shell": 1265} | package net.sympower.aok2021.tonis
fun main() {
println("1st: ${day02Part01("/Day02.in")})")
println("2nd: ${day02Part02("/Day02.in")})")
}
fun day02Part01(fileIn: String): EndPosition {
val movements = readMovements(fileIn)
val totalMovements = movements.groupBy({ it.direction }) { it.amount }
.map ... | 0 | Rust | 0 | 0 | 5ee0c3fb2e461dcfd4a3bdd7db3efae9a4d5aabd | 1,198 | to-advent-of-code | MIT License |
src/main/kotlin/io/github/clechasseur/adventofcode2021/Day13.kt | clechasseur | 435,726,930 | false | {"Kotlin": 315943} | package io.github.clechasseur.adventofcode2021
import io.github.clechasseur.adventofcode2021.data.Day13Data
import io.github.clechasseur.adventofcode2021.util.Pt
object Day13 {
private val data = Day13Data.data
private val foldData = Day13Data.foldData
fun part1(): Int = data.toPage().foldLeft(655).dots.... | 0 | Kotlin | 0 | 0 | 4b893c001efec7d11a326888a9a98ec03241d331 | 1,713 | adventofcode2021 | MIT License |
kotlin/759.Set Intersection Size At Least Two( 设置交集大小至少为2).kt | learningtheory | 141,790,045 | false | {"Python": 4025652, "C++": 1999023, "Java": 1995266, "JavaScript": 1990554, "C": 1979022, "Ruby": 1970980, "Scala": 1925110, "Kotlin": 1917691, "Go": 1898079, "Swift": 1827809, "HTML": 124958, "Shell": 7944} | /**
<p>
An integer interval <code>[a, b]</code> (for integers <code>a < b</code>) is a set of all consecutive integers from <code>a</code> to <code>b</code>, including <code>a</code> and <code>b</code>.
</p><p>
Find the minimum size of a set S such that for every integer interval A in <code>intervals</code>, the inters... | 0 | Python | 1 | 3 | 6731e128be0fd3c0bdfe885c1a409ac54b929597 | 4,029 | leetcode | MIT License |
src/main/kotlin/com/ginsberg/advent2016/Day10.kt | tginsberg | 74,924,040 | false | null | /*
* Copyright (c) 2016 by <NAME>
*/
package com.ginsberg.advent2016
/**
* Advent of Code - Day 10: December 10, 2016
*
* From http://adventofcode.com/2016/day/10
*
*/
class Day10(input: List<String>, val find: Set<Int> = setOf(17, 61)) {
companion object {
val giveChip: Regex = Regex("""^value (\... | 0 | Kotlin | 0 | 3 | a486b60e1c0f76242b95dd37b51dfa1d50e6b321 | 3,044 | advent-2016-kotlin | MIT License |
LeetCode/Medium/container-with-most-water/Solution.kt | GregoryHo | 254,657,102 | false | null | class Solution {
fun maxArea(height: IntArray): Int {
// return twoLoop(height)
return twoPointClose(height)
}
// O(N^2)
fun twoLoop(height: IntArray): Int {
val lastIndex = height.size - 1
var maximumArea = 0
height.forEachIndexed { i, valueI ->
height.reversedArray().forEachIndexe... | 0 | Kotlin | 0 | 0 | 8f126ffdf75aa83a6d60689e0b6fcc966a173c70 | 1,124 | coding-fun | MIT License |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.