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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aoc-2022/src/commonMain/kotlin/fr/outadoc/aoc/twentytwentytwo/Day02.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwentytwo
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.readDayInput
class Day02 : Day<Int> {
private val input: Sequence<Pair<String, String>> =
readDayInput()
.lineSequence()
.map { line ->
val (a, b) = line.split(... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 3,013 | adventofcode | Apache License 2.0 |
src/main/kotlin/aoc/year2020/Day04.kt | SackCastellon | 573,157,155 | false | {"Kotlin": 62581} | package aoc.year2020
import aoc.Puzzle
/**
* [Day 4 - Advent of Code 2020](https://adventofcode.com/2020/day/4)
*/
object Day04 : Puzzle<Int, Int> {
override fun solvePartOne(input: String): Int {
val reqFields = setOf(
"byr",
"iyr",
"eyr",
"hgt",
... | 0 | Kotlin | 0 | 0 | 75b0430f14d62bb99c7251a642db61f3c6874a9e | 2,806 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/hj/leetcode/kotlin/problem2466/Solution.kt | hj-core | 534,054,064 | false | {"Kotlin": 619841} | package com.hj.leetcode.kotlin.problem2466
/**
* LeetCode page: [2466. Count Ways To Build Good Strings](https://leetcode.com/problems/count-ways-to-build-good-strings/);
*/
class Solution {
private val mod = 1_000_000_007 // modulo required by the problem
/* Complexity:
* Time O(high) and Space O(hig... | 1 | Kotlin | 0 | 1 | 14c033f2bf43d1c4148633a222c133d76986029c | 2,311 | hj-leetcode-kotlin | Apache License 2.0 |
src/main/java/challenges/cracking_coding_interview/bit_manipulation/flip_bit_to_win/QuestionB.kt | ShabanKamell | 342,007,920 | false | null | package challenges.cracking_coding_interview.bit_manipulation.flip_bit_to_win
import kotlin.math.max
/**
* You have an integer, and you can flip exactly one bit from a 0 to a 1.
* Write code to find the length of the longest sequence of ls you could create.
* EXAMPLE
* Input: 1775 (or: 11011101111) Output: 8
*... | 0 | Kotlin | 0 | 0 | ee06bebe0d3a7cd411d9ec7b7e317b48fe8c6d70 | 2,281 | CodingChallenges | Apache License 2.0 |
src/Day08.kt | brunojensen | 572,665,994 | false | {"Kotlin": 13161} | fun main() {
fun part1(input: List<String>): Int {
val matrix = input.map { it.map { v -> v.digitToInt() } }
val visible = Array(matrix.size) { BooleanArray(matrix[0].size) }
val edgesCount = (matrix.size * 2 + matrix[0].size * 2) - 4
for (x in 1..matrix.size - 2) {
for (y in 1..matrix[0].si... | 0 | Kotlin | 0 | 0 | 2707e76f5abd96c9d59c782e7122427fc6fdaad1 | 798 | advent-of-code-kotlin-1 | Apache License 2.0 |
y2022/src/main/kotlin/adventofcode/y2022/Day25.kt | Ruud-Wiegers | 434,225,587 | false | {"Kotlin": 503769} | package adventofcode.y2022
import adventofcode.io.AdventSolution
object Day25 : AdventSolution(2022, 25, "Full of Hot Air") {
override fun solvePartOne(input: String) =
input.lineSequence().map { fromBalancedQuinary(it) }.sum().toBalancedQuinary()
private fun fromBalancedQuinary(it: String): Long ... | 0 | Kotlin | 0 | 3 | fc35e6d5feeabdc18c86aba428abcf23d880c450 | 1,244 | advent-of-code | MIT License |
src/main/kotlin/day3/solver.kt | derekaspaulding | 317,756,568 | false | null | package day3
import java.io.File
fun solveProblemOne(rawGrid: List<String>, slope: Pair<Int, Int> = Pair(1, 3)): Int {
val grid = Grid(rawGrid)
var x = 0
var y = 0
var trees = 0
while (y < grid.height) {
if (grid.isTree(x, y)) {
trees += 1
}
x += slope.second
... | 0 | Kotlin | 0 | 0 | 0e26fdbb3415fac413ea833bc7579c09561b49e5 | 1,030 | advent-of-code-2020 | MIT License |
src/main/kotlin/_2022/Day21.kt | novikmisha | 572,840,526 | false | {"Kotlin": 145780} | package _2022
import readInput
fun main() {
fun dfs(
monkeyName: String,
monkeyMap: Map<String, MathMonkey>
): Long {
val currentMonkey = monkeyMap[monkeyName]!!
if (currentMonkey.simpleNumber > -1L) {
return currentMonkey.simpleNumber
}
val first... | 0 | Kotlin | 0 | 0 | 0c78596d46f3a8bf977bf356019ea9940ee04c88 | 4,658 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/nibado/projects/advent/y2020/Day09.kt | nielsutrecht | 47,550,570 | false | null | package com.nibado.projects.advent.y2020
import com.nibado.projects.advent.*
object Day09 : Day {
private val numbers = resourceLines(2020, 9).map { it.toLong() }
private const val preAmbleSize = 25
private val part1Number : Long by lazy { numbers.asSequence().drop(preAmbleSize).mapIndexedNotNull { index... | 1 | Kotlin | 0 | 15 | b4221cdd75e07b2860abf6cdc27c165b979aa1c7 | 1,298 | adventofcode | MIT License |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions5.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
fun test5() {
printlnResult(arrayOf("abcw", "foo", "bar", "fxyz", "abcdef"))
}
/**
* Questions 5: We have a String array, find the maximum product
* of the two strings that don't have any same alphabet, the all
* stings are composed by lowercase alphabets
*/
private fun... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,064 | Algorithm | Apache License 2.0 |
src/Day21.kt | kpilyugin | 572,573,503 | false | {"Kotlin": 60569} | class Monkeys(val input: List<String>) {
val monkeys = mutableMapOf<String, Monkey>()
var ownId: String = ""
init {
input.forEach { line ->
val (id, info) = line.split(": ")
val monkey = when {
" " in info -> {
val (m1, op, m2) = info.spli... | 0 | Kotlin | 0 | 1 | 7f0cfc410c76b834a15275a7f6a164d887b2c316 | 3,822 | Advent-of-Code-2022 | Apache License 2.0 |
src/main/kotlin/com/leetcode/P311.kt | antop-dev | 229,558,170 | false | {"Kotlin": 695315, "Java": 213000} | package com.leetcode
import java.util.*
// https://github.com/antop-dev/algorithm/issues/311
class P311 {
private val dy = intArrayOf(-1, +0, +1, +0)
private val dx = intArrayOf(+0, +1, +0, -1)
fun shortestPath(grid: Array<IntArray>, k: Int): Int {
val m = grid.size
val n = grid[0].size
... | 1 | Kotlin | 0 | 0 | 9a3e762af93b078a2abd0d97543123a06e327164 | 1,712 | algorithm | MIT License |
src/Day03.kt | ChenJiaJian96 | 576,533,624 | false | {"Kotlin": 11529} | fun main() {
fun findSameChar(first: String, second: String): Set<Char> {
return first.toCharArray().toSet() intersect second.toCharArray().toSet()
}
fun findSameChar(first: String, second: String, third: String): Set<Char> {
return first.toCharArray().toSet() intersect second.toCharArray()... | 0 | Kotlin | 0 | 0 | b1a88f437aee756548ac5ba422e2adf2a43dce9f | 1,220 | Advent-Code-2022 | Apache License 2.0 |
src/main/kotlin/com/ab/advent/day04/Puzzle.kt | battagliandrea | 574,137,910 | false | {"Kotlin": 27923} | package com.ab.advent.day04
import com.ab.advent.utils.readLines
/*
PART 01
Space needs to be cleared before the last supplies can be unloaded from the ships,
and so several Elves have been assigned the job of cleaning up sections of the camp.
Every section has a unique ID number, and each Elf is assigned a range of... | 0 | Kotlin | 0 | 0 | cb66735eea19a5f37dcd4a31ae64f5b450975005 | 3,144 | Advent-of-Kotlin | Apache License 2.0 |
aoc-2020/src/commonMain/kotlin/fr/outadoc/aoc/twentytwenty/Day18.kt | outadoc | 317,517,472 | false | {"Kotlin": 183714} | package fr.outadoc.aoc.twentytwenty
import fr.outadoc.aoc.scaffold.Day
import fr.outadoc.aoc.scaffold.readDayInput
class Day18 : Day<Long> {
private sealed class Expression {
data class Addition(val a: Expression, val b: Expression) : Expression() {
override fun toString() = "($a + $b)"
... | 0 | Kotlin | 0 | 0 | 54410a19b36056a976d48dc3392a4f099def5544 | 4,108 | adventofcode | Apache License 2.0 |
src/commonMain/kotlin/io/github/kkarnauk/parsek/token/tokenizer/Tokenizer.kt | kkarnauk | 440,554,625 | false | {"Kotlin": 111337} | package io.github.kkarnauk.parsek.token.tokenizer
import io.github.kkarnauk.parsek.exception.TokenizeException
import io.github.kkarnauk.parsek.info.Location
import io.github.kkarnauk.parsek.token.Token
import io.github.kkarnauk.parsek.token.TokenProducer
import io.github.kkarnauk.parsek.token.type.TokenType
/**
* R... | 0 | Kotlin | 0 | 17 | 7479f94b28d4fdb611f4fabf83acece597a0203c | 3,155 | parsek | Apache License 2.0 |
src/day17/Day17.kt | davidcurrie | 579,636,994 | false | {"Kotlin": 52697} | package day17
import java.io.File
fun main() {
val jetPattern = File("src/day17/input.txt").readLines().first()
val rockShapes = listOf(
listOf(Pair(0,0), Pair(1,0), Pair(2,0), Pair(3,0)),
listOf(Pair(0,1), Pair(1,0), Pair(1,1), Pair(1,2), Pair(2,1)),
listOf(Pair(0,0), Pair(1,0), Pair... | 0 | Kotlin | 0 | 0 | 0e0cae3b9a97c6019c219563621b43b0eb0fc9db | 3,129 | advent-of-code-2022 | MIT License |
src/Day05.kt | RickShaa | 572,623,247 | false | {"Kotlin": 34294} | import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.math.sign
fun main() {
val fileName = "day05.txt"
val testFileName = "day05_test.txt"
val input = FileUtil.getText(fileName);
val cratesAndInstructions = input.split("\n\n")
fun String.patchLastValue(): List<Char> {
var c... | 0 | Kotlin | 0 | 1 | 76257b971649e656c1be6436f8cb70b80d5c992b | 2,989 | aoc | Apache License 2.0 |
src/Day02.kt | matusekma | 572,617,724 | false | {"Kotlin": 119912, "JavaScript": 2024} | class Day02 {
private val scoreMap1 = mapOf<String, Int>(
"A X" to 1 + 3,
"A Y" to 2 + 6,
"A Z" to 3 + 0,
"B X" to 1 + 0,
"B Y" to 2 + 3,
"B Z" to 3 + 6,
"C X" to 1 + 6,
"C Y" to 2 + 0,
"C Z" to 3 + 3,
)
private val scoreMap2 = mapOf(
... | 0 | Kotlin | 0 | 0 | 744392a4d262112fe2d7819ffb6d5bde70b6d16a | 912 | advent-of-code | Apache License 2.0 |
advent2022/src/main/kotlin/year2022/Day24.kt | bulldog98 | 572,838,866 | false | {"Kotlin": 132847} | package year2022
import AdventDay
import Point2D
import lcm
class Day24 : AdventDay(2022, 24) {
private data class Blizzard(val location: Point2D, val movement: Point2D) {
fun next(boundary: Point2D): Blizzard {
val nextLocation = location + movement
val correctedNextLocation = whe... | 0 | Kotlin | 0 | 0 | 02ce17f15aa78e953a480f1de7aa4821b55b8977 | 4,748 | advent-of-code | Apache License 2.0 |
aoc2022/day11.kt | davidfpc | 726,214,677 | false | {"Kotlin": 127212} | package aoc2022
import utils.InputRetrieval
fun main() {
Day11.execute()
}
object Day11 {
fun execute() {
val input = readInput()
println("Part 1: ${part1(input)}")
input.forEach { it.reset() }
println("Part 2: ${part2(input)}")
}
private fun part1(input: List<Monkey... | 0 | Kotlin | 0 | 0 | 8dacf809ab3f6d06ed73117fde96c81b6d81464b | 3,720 | Advent-Of-Code | MIT License |
src/main/kotlin/day03.kt | mgellert | 572,594,052 | false | {"Kotlin": 19842} | object RucksackReorganization : Solution {
fun findSumOfMatching(rucksacks: List<Rucksack>, priorities: Map<Char, Int> = priorities()): Int = rucksacks.map {
val first = it.substring(0, it.length / 2).toSet()
val second = it.substring(it.length / 2).toSet()
first.intersect(second)
}
... | 0 | Kotlin | 0 | 0 | 4224c762ad4961b28e47cd3db35e5bc73587a118 | 1,052 | advent-of-code-2022-kotlin | The Unlicense |
src/main/kotlin/g2801_2900/s2867_count_valid_paths_in_a_tree/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g2801_2900.s2867_count_valid_paths_in_a_tree
// #Hard #Dynamic_Programming #Math #Depth_First_Search #Tree #Number_Theory
// #2023_12_21_Time_793_ms_(100.00%)_Space_111.6_MB_(100.00%)
class Solution {
private lateinit var isPrime: BooleanArray
private lateinit var treeEdges: Array<MutableList<Int>?>
... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 2,167 | LeetCode-in-Kotlin | MIT License |
leetcode-75-kotlin/src/main/kotlin/ReverseWordsInAString.kt | Codextor | 751,507,040 | false | {"Kotlin": 49566} | /**
* Given an input string s, reverse the order of the words.
*
* A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.
*
* Return a string of the words in reverse order concatenated by a single space.
*
* Note that s may contain leading or trailing spa... | 0 | Kotlin | 0 | 0 | 0511a831aeee96e1bed3b18550be87a9110c36cb | 2,530 | leetcode-75 | Apache License 2.0 |
src/Day01.kt | vi-quang | 573,647,667 | false | {"Kotlin": 49703} | import java.util.PriorityQueue
fun main() {
data class Elf(val calorieList: MutableList<Int> = mutableListOf()) {
fun totalCalories() : Int {
return calorieList.sumOf { it }
}
}
fun createElfList(input : List<String>) : MutableList<Elf> {
val elves = mutableListOf<Elf>(... | 0 | Kotlin | 0 | 2 | ae153c99b58ba3749f16b3fe53f06a4b557105d3 | 1,574 | aoc-2022 | Apache License 2.0 |
src/Day14.kt | wbars | 576,906,839 | false | {"Kotlin": 32565} | import java.lang.Integer.max
import java.lang.Integer.min
fun main() {
fun part1(input: List<String>): Int {
val a: Array<CharArray> = Array(1000) { CharArray(1000) { '.' } }
input.asSequence().filter { it.isNotEmpty() }
.map { it.split(" -> ") }
.map {
it.m... | 0 | Kotlin | 0 | 0 | 344961d40f7fc1bb4e57f472c1f6c23dd29cb23f | 3,902 | advent-of-code-2022 | Apache License 2.0 |
app/src/main/java/com/betulnecanli/kotlindatastructuresalgorithms/CodingPatterns/TwoPointers.kt | betulnecanli | 568,477,911 | false | {"Kotlin": 167849} | /*
The two-pointer technique is often used for problems that involve searching for a pair of elements, sorting,
or finding a subarray with a specific property. Let's tackle three problems:
"Squaring a Sorted Array," "Dutch National Flag Problem," and "Minimum Window Sort in a Matrix."
I'll provide Kotlin implementat... | 2 | Kotlin | 2 | 40 | 70a4a311f0c57928a32d7b4d795f98db3bdbeb02 | 2,965 | Kotlin-Data-Structures-Algorithms | Apache License 2.0 |
plugins/evaluation-plugin/core/src/com/intellij/cce/metric/SimilarityMetrics.kt | JetBrains | 2,489,216 | false | null | // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.cce.metric
import com.intellij.cce.core.Lookup
import com.intellij.cce.core.Session
import com.intellij.cce.metric.util.Bootstrap
import org.apache.commons.lang3.StringUtils
imp... | 251 | null | 5,079 | 16,158 | 831d1a4524048aebf64173c1f0b26e04b61c6880 | 4,076 | intellij-community | Apache License 2.0 |
src/main/kotlin/solutions/CHK/CheckoutSolution.kt | DPNT-Sourcecode | 683,058,972 | false | null | package solutions.CHK
/**
* +------+-------+------------------------+
* | Item | Price | Special offers |
* +------+-------+------------------------+
* | A | 50 | 3A for 130, 5A for 200 |
* | B | 30 | 2B for 45 |
* | C | 20 | |
* | D | 15 | ... | 0 | Kotlin | 0 | 0 | 08a55cb40cb8bed10ab5a0397b70cedc80ad3d5f | 2,629 | CHK-fncv01 | Apache License 2.0 |
src/main/kotlin/com/github/davio/aoc/y2016/Day1.kt | Davio | 317,510,947 | false | {"Kotlin": 405939} | package com.github.davio.aoc.y2016
import com.github.davio.aoc.general.Day
import com.github.davio.aoc.general.getInputAsList
import com.github.davio.aoc.y2016.Day1.Orientation.*
import kotlin.math.abs
fun main() {
Day1.getResultPart1()
}
object Day1 : Day() {
/*
* --- Day 1: No Time for a Taxicab ---
... | 1 | Kotlin | 0 | 0 | 4fafd2b0a88f2f54aa478570301ed55f9649d8f3 | 3,676 | advent-of-code | MIT License |
src/main/kotlin/Day05.kt | dliszewski | 573,836,961 | false | {"Kotlin": 57757} | import kotlin.collections.HashMap
class Day05 {
fun part1(input: String): String {
return getTopCrates(input, CrateMoverModel.CrateMover9000)
}
fun part2(input: String): String {
return getTopCrates(input, CrateMoverModel.CrateMover9001)
}
private fun getTopCrates(input: String, ... | 0 | Kotlin | 0 | 0 | 76d5eea8ff0c96392f49f450660220c07a264671 | 3,004 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/wtf/log/xmas2021/day/day03/Day03.kt | damianw | 434,043,459 | false | {"Kotlin": 62890} | package wtf.log.xmas2021.day.day03
import wtf.log.xmas2021.Day
import wtf.log.xmas2021.util.math.toInt
import java.io.BufferedReader
object Day03 : Day<BitTable, Int, Int> {
override fun parseInput(reader: BufferedReader): BitTable = BitTable.parse(reader)
override fun part1(input: BitTable): Int {
... | 0 | Kotlin | 0 | 0 | 1c4c12546ea3de0e7298c2771dc93e578f11a9c6 | 3,238 | AdventOfKotlin2021 | BSD Source Code Attribution |
src/main/kotlin/endredeak/aoc2023/Day14.kt | edeak | 725,919,562 | false | {"Kotlin": 26575} | package endredeak.aoc2023
fun main() {
solve("Parabolic Reflector Dish") {
val input = lines.map { it.toCharArray() }
fun List<CharArray>.copy() = this.map { it.toMutableList().toCharArray() }
fun List<CharArray>.tilt(dir: String): List<CharArray> {
val c = this.copy()
... | 0 | Kotlin | 0 | 0 | 92c684c42c8934e83ded7881da340222ff11e338 | 3,998 | AdventOfCode2023 | Do What The F*ck You Want To Public License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/SumOfUnique.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 | 2,085 | kotlab | Apache License 2.0 |
src/main/kotlin/year2022/Day07.kt | simpor | 572,200,851 | false | {"Kotlin": 80923} | import AoCUtils
import AoCUtils.test
fun main() {
data class File(val name: String, val size: Long)
data class Folder(
val name: String,
val parent: Folder?,
val files: MutableList<File> = mutableListOf(),
val folders: MutableList<Folder> = mutableListOf(),
var totalSize... | 0 | Kotlin | 0 | 0 | 631cbd22ca7bdfc8a5218c306402c19efd65330b | 4,722 | aoc-2022-kotlin | Apache License 2.0 |
src/Day09.kt | Allagash | 572,736,443 | false | {"Kotlin": 101198} | import java.io.File
import kotlin.math.abs
import kotlin.math.sign
// Advent of Code 2022, Day 09, Rope Bridge
fun main() {
fun readInput(name: String) = File("src", "$name.txt").readLines()
data class Pos(val x: Int, val y: Int)
fun getHeadMoves(input: List<String>): List<Pos> {
val headMoves ... | 0 | Kotlin | 0 | 0 | 8d5fc0b93f6d600878ac0d47128140e70d7fc5d9 | 2,958 | AdventOfCode2022 | Apache License 2.0 |
codeforces/src/main/kotlin/contest1911/G.kt | austin226 | 729,634,548 | false | {"Kotlin": 23837} | import java.math.BigInteger
private fun String.splitWhitespace() = split("\\s+".toRegex())
// s1 and s2 both have the same length
fun averageString(s1: String, s2: String, len: Int): String {
// // Work backwards from the end
// val avgStrChars = MutableList<Char>(len) { '?' }
// var remainder = 0
// for ... | 0 | Kotlin | 0 | 0 | 4377021827ffcf8e920343adf61a93c88c56d8aa | 2,134 | codeforces-kt | MIT License |
src/main/aoc2019/Day14.kt | nibarius | 154,152,607 | false | {"Kotlin": 963896} | package aoc2019
import kotlin.math.ceil
import kotlin.math.min
class Day14(input: List<String>) {
data class Reaction(val req: List<Pair<Int, String>>, val res: Pair<Int, String>)
// Material name to reaction to create the material
private val reactions = input.map { parseLine(it) }.associateBy { it.res... | 0 | Kotlin | 0 | 6 | f2ca41fba7f7ccf4e37a7a9f2283b74e67db9f22 | 2,962 | aoc | MIT License |
src/Day05.kt | LauwiMeara | 572,498,129 | false | {"Kotlin": 109923} | import kotlin.collections.ArrayDeque
const val FIRST_STACK_NUMBER = '1'
fun main() {
data class Procedure(val unit: Int, val startStack: Int, val destinationStack: Int)
fun getCrates(input: List<String>): Map<Int, ArrayDeque<Char>> {
val crates = mutableMapOf<Int, ArrayDeque<Char>>()
// Get ... | 0 | Kotlin | 0 | 1 | 34b4d4fa7e562551cb892c272fe7ad406a28fb69 | 3,196 | AoC2022 | Apache License 2.0 |
plugins/evaluation-plugin/core/src/com/intellij/cce/metric/CompletionGolfMetrics.kt | trinhanhngoc | 205,765,945 | true | null | package com.intellij.cce.metric
import com.intellij.cce.core.Session
import com.intellij.cce.metric.util.Sample
abstract class CompletionGolfMetric<T : Number> : Metric {
protected var sample = Sample()
private fun T.alsoAddToSample(): T = also { sample.add(it.toDouble()) }
protected fun computeMoves(session:... | 0 | null | 0 | 0 | 1d4a962cfda308a73e0a7ef75186aaa4b15d1e17 | 3,147 | intellij-community | Apache License 2.0 |
src/aoc2022/Day08.kt | anitakar | 576,901,981 | false | {"Kotlin": 124382} | package aoc2022
import println
import readInput
fun main() {
data class Tree(val x: Int, val y: Int, val h: Int)
fun part1(input: List<String>): Int {
// i top to bottom, j left to right == LEFT
val unique = mutableSetOf<Tree>()
for (i in input.indices) {
var tallest = 0... | 0 | Kotlin | 0 | 1 | 50998a75d9582d4f5a77b829a9e5d4b88f4f2fcf | 4,134 | advent-of-code-kotlin | Apache License 2.0 |
src/main/kotlin/com/kishor/kotlin/algo/algorithms/graph/KruskalsMST.kt | kishorsutar | 276,212,164 | false | null | package com.kishor.kotlin.algo.algorithms.graph
import java.util.*
fun main() {
val unionFind = KruskalsMST(9)
val sc = Scanner(System.`in`)
unionFind.accept(sc)
unionFind.display()
// println(unionFind.containsCycle())
var sum = 0
val mst: Array<Edge?> = unionFind.kruskal()
for (e in... | 0 | Kotlin | 0 | 0 | 6672d7738b035202ece6f148fde05867f6d4d94c | 3,215 | DS_Algo_Kotlin | MIT License |
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2022/2022-25.kt | ferinagy | 432,170,488 | false | {"Kotlin": 787586} | package com.github.ferinagy.adventOfCode.aoc2022
import com.github.ferinagy.adventOfCode.println
import com.github.ferinagy.adventOfCode.readInputLines
fun main() {
val input = readInputLines(2022, "25-input")
val testInput1 = readInputLines(2022, "25-test1")
println("Part1:")
part1(testInput1).print... | 0 | Kotlin | 0 | 1 | f4890c25841c78784b308db0c814d88cf2de384b | 1,179 | advent-of-code | MIT License |
src/Day10.kt | GreyWolf2020 | 573,580,087 | false | {"Kotlin": 32400} | fun main() {
fun part1(input: List<String>): Int {
val cycleForSignalStrength = mutableListOf<Int>(20, 60, 100, 140, 180, 220)
val register = Register()
val clock = Clock().apply { addProcessors(register) }
val signalStrength = buildList {
input
.forEach... | 0 | Kotlin | 0 | 0 | 498da8861d88f588bfef0831c26c458467564c59 | 3,852 | aoc-2022-in-kotlin | Apache License 2.0 |
src/kotlin/_2023/Task01.kt | MuhammadSaadSiddique | 567,431,330 | false | {"Kotlin": 20410} | package _2022
import Task
import readInput
object Task01: Task {
override fun partA() = part1(parseInput())
override fun partB() = part2(parseInput())
private fun parseInput() = readInput("_2022/01")
.split("\n\n")
.map { it.split("\n").sumOf { it.toInt() } }
fun part1(input: Lis... | 0 | Kotlin | 0 | 0 | 3893ae1ac096c56e224e798d08d7fee60e299a84 | 1,041 | AdventCode-Kotlin | Apache License 2.0 |
src/Day13.kt | cornz | 572,867,092 | false | {"Kotlin": 35639} | import kotlin.math.min
fun main() {
data class Index(var index: Int = 0)
fun processList(input: String, index: Index): List<Any> {
val list = mutableListOf<Any>()
while (index.index < input.count()) {
val char = input[index.index]
index.index++
when (char)... | 0 | Kotlin | 0 | 0 | 2800416ddccabc45ba8940fbff998ec777168551 | 3,927 | aoc2022 | Apache License 2.0 |
src/main/kotlin/day18/Day18.kt | alxgarcia | 435,549,527 | false | {"Kotlin": 91398} | package day18
import java.io.File
sealed interface SnailFishNumber {
val magnitude: Int
}
class SnailNumber(override var magnitude: Int) : SnailFishNumber {
val isSplittable: Boolean
get() = magnitude > 9
override fun toString(): String = magnitude.toString()
fun split(parent: SnailPair): SnailPair =
... | 0 | Kotlin | 0 | 0 | d6b10093dc6f4a5fc21254f42146af04709f6e30 | 4,309 | advent-of-code-2021 | MIT License |
src/Day04.kt | l8nite | 573,298,097 | false | {"Kotlin": 105683} | fun main() {
fun part1(input: List<String>): Int {
var overlapped = 0
input.forEach { line ->
val (a1, a2, b1, b2) = line.split("-",",").map { it.toInt() }
if ((a1 <= b1 && a2 >= b2) || (a1 >= b1 && a2 <= b2) ) {
overlapped += 1
}
}
... | 0 | Kotlin | 0 | 0 | f74331778fdd5a563ee43cf7fff042e69de72272 | 938 | advent-of-code-2022 | Apache License 2.0 |
app/src/y2021/day15/Day15Chiton.kt | henningBunk | 432,858,990 | false | {"Kotlin": 124495} | package y2021.day15
import common.*
import common.annotations.AoCPuzzle
import kotlin.math.min
fun main(args: Array<String>) {
Day15Chiton().solveThem(ignorePart1 = true)
}
@AoCPuzzle(2021, 15)
class Day15Chiton : AocSolution {
override val answers = Answers(samplePart1 = 40, samplePart2 = 315, part1 = 398)
... | 0 | Kotlin | 0 | 0 | 94235f97c436f434561a09272642911c5588560d | 4,806 | advent-of-code-2021 | Apache License 2.0 |
src/day07/Day07.kt | jimsaidov | 572,881,855 | false | {"Kotlin": 10629} | package day07
class Day07(private val input: List<String>) {
private data class File(val name: String, val size: Double)
private data class Directory(
val name: String,
val parent: Directory?,
val dirs: MutableList<Directory> = mutableListOf(),
val files: MutableList<File> = m... | 0 | Kotlin | 0 | 0 | d4eb926b57460d4ba4acced14658f211e1ccc12c | 2,439 | aoc2022 | Apache License 2.0 |
src/Day03.kt | MisterTeatime | 561,848,263 | false | {"Kotlin": 20300} | fun main() {
val movements = mapOf(
'>' to Point2D(1,0),
'<' to Point2D(-1,0),
'^' to Point2D(0,1),
'v' to Point2D(0,-1)
)
fun part1(input: List<String>): Int {
var position = Point2D(0,0)
val visitedHouses = mutableSetOf<Point2D>(position)
input[0]... | 0 | Kotlin | 0 | 0 | d684bd252a9c6e93106bdd8b6f95a45c9924aed6 | 1,376 | AoC2015 | Apache License 2.0 |
src/nativeMain/kotlin/com.qiaoyuang.algorithm/special/Questions57.kt | qiaoyuang | 100,944,213 | false | {"Kotlin": 338134} | package com.qiaoyuang.algorithm.special
fun test57() {
printlnResult(intArrayOf(1, 2, 3, 1), 3, 0)
printlnResult(intArrayOf(1, 5, 9, 1, 5, 9), 2, 3)
}
/**
* Questions 57: Given an IntArray nums, and two positive integer t and k,
* find the two indexes i and j that abs(i - j) <= k, and abs(nums[i] - nums[j])... | 0 | Kotlin | 3 | 6 | 66d94b4a8fa307020d515d4d5d54a77c0bab6c4f | 1,200 | Algorithm | Apache License 2.0 |
src/main/kotlin/cc/stevenyin/leetcode/_0941_ValidMountainArray.kt | StevenYinKop | 269,945,740 | false | {"Kotlin": 107894, "Java": 9565} | package cc.stevenyin.leetcode
/**
* https://leetcode.com/problems/valid-mountain-array
* Given an array of integers arr, return true if and only if it is a valid mountain array.
*
* Recall that arr is a mountain array if and only if:
*
* arr.length >= 3
* There exists some i with 0 < i < arr.length - 1 such tha... | 0 | Kotlin | 0 | 1 | 748812d291e5c2df64c8620c96189403b19e12dd | 1,512 | kotlin-demo-code | MIT License |
2021/Day2.kt | vypxl | 159,938,890 | false | {"Python": 216454, "Haskell": 97987, "Scala": 79708, "Go": 17521, "C++": 15658, "Kotlin": 6914, "Shell": 6661, "Elixir": 6363, "F#": 5977, "C#": 5571, "D": 5098, "C": 4467, "JavaScript": 3386, "Pascal": 3004, "OCaml": 2736, "Idris": 2434, "Perl": 1627, "Assembly": 1614, "Just": 1549, "Ruby": 1457, "Lua": 1117, "Groovy"... | import java.io.File
data class Command(val kind: String, val x: Int)
typealias TInput2 = List<Command>
typealias TOutput2 = Int
private fun part1(input: TInput2): TOutput2 =
input.fold(Pair(0, 0)) { (d, p), (kind, x) -> when(kind) {
"forward" -> Pair(d, p + x)
"up" -> Pair(d - x, p)
"down... | 0 | Python | 0 | 2 | d15e2052e6cff0f817080e815eb05543a7781982 | 1,091 | aoc | Do What The F*ck You Want To Public License |
src/Day14.kt | AlaricLightin | 572,897,551 | false | {"Kotlin": 87366} | private const val SAND_START_X = 500
fun main() {
fun part1(input: List<String>): Int {
val pathList: List<List<Coords>> = readPathList(input)
val fieldData = getFieldDataForPart1(pathList)
val field = Field(fieldData)
return field.getSandUnitCount()
}
fun part2(input: List... | 0 | Kotlin | 0 | 0 | ee991f6932b038ce5e96739855df7807c6e06258 | 4,776 | AdventOfCode2022 | Apache License 2.0 |
src/Day07NoSpaceLeftOnDevice.kt | zizoh | 573,932,084 | false | {"Kotlin": 13370} | fun main() {
val input: List<String> = readInput("input/day07")
val totalSizeOnDisk = calculateSumOfDirectories(getRootNode(input))
val totalDiskSpace = 70_000_000
val minimumSpaceRequired = 30_000_000
println(
sizesOfDirectories.filter { size ->
size >= minimumSpaceRequired + to... | 0 | Kotlin | 0 | 0 | 817017369d257cca648974234f1e4137cdcd3138 | 2,474 | aoc-2022 | Apache License 2.0 |
src/main/kotlin/mkuhn/aoc/Day14.kt | mtkuhn | 572,236,871 | false | {"Kotlin": 53161} | package mkuhn.aoc
import mkuhn.aoc.util.Point
import mkuhn.aoc.util.progressBetween
import mkuhn.aoc.util.readInput
fun main() {
val input = readInput("Day14")
println(day14part1(input))
println(day14part2(input))
}
fun day14part1(input: List<String>): Int {
val sandOrigin = Point(500, 0)
val roc... | 0 | Kotlin | 0 | 1 | 89138e33bb269f8e0ef99a4be2c029065b69bc5c | 2,624 | advent-of-code-2022 | Apache License 2.0 |
src/main/kotlin/solutions/Day22MonkeyMap.kt | aormsby | 571,002,889 | false | {"Kotlin": 80084} | package solutions
import models.Coord2d
import utils.Input
import utils.Solution
// run only this day
fun main() {
Day22MonkeyMap()
}
class Day22MonkeyMap : Solution() {
init {
begin("Day 22 - Monkey Map")
val input = Input.parseLines("/d22_monkey_notes.txt")
// map coord -> isOpenS... | 0 | Kotlin | 0 | 0 | 1bef4812a65396c5768f12c442d73160c9cfa189 | 3,954 | advent-of-code-2022 | MIT License |
src/Day14.kt | MerickBao | 572,842,983 | false | {"Kotlin": 28200} | import kotlin.math.max
import kotlin.math.min
fun main() {
var MAX = 0
fun build(input: List<String>): HashSet<Int> {
val res = HashSet<Int>()
for (s in input) {
val coords = s.split(" -> ")
for (i in coords.indices) {
if (i == 0) continue
... | 0 | Kotlin | 0 | 0 | 70a4a52aa5164f541a8dd544c2e3231436410f4b | 2,174 | aoc-2022-in-kotlin | Apache License 2.0 |
src/aoc_2022/Day04.kt | jakob-lj | 573,335,157 | false | {"Kotlin": 38689} | package aoc_2022
import readInput
fun main() {
val input = readInput("day4_test")
part1(input)
part2(input)
}
fun part1(input: List<String>) {
val data = input.map {
val compartments = it.split(",")
val first = compartments[0].split("-")
val second = compartments[1].split("... | 0 | Kotlin | 0 | 0 | 3a7212dff9ef0644d9dce178e7cc9c3b4992c1ab | 1,195 | advent_of_code | Apache License 2.0 |
src/main/kotlin/year2021/day-21.kt | ppichler94 | 653,105,004 | false | {"Kotlin": 182859} | package year2021
import lib.aoc.Day
import lib.aoc.Part
import lib.memoize
import lib.splitLines
import kotlin.math.max
fun main() {
Day(21, 2021, PartA21(), PartB21()).run()
}
open class PartA21 : Part() {
protected class DeterministicDice {
var counter = 0
fun roll(): Int {
val... | 0 | Kotlin | 0 | 0 | 49dc6eb7aa2a68c45c716587427353567d7ea313 | 2,739 | Advent-Of-Code-Kotlin | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/MaximizeScoreAfterNOperations.kt | ashtanko | 203,993,092 | false | {"Kotlin": 5856223, "Shell": 1168, "Makefile": 917} | /*
* Copyright 2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in w... | 4 | Kotlin | 0 | 19 | 776159de0b80f0bdc92a9d057c852b8b80147c11 | 4,922 | kotlab | Apache License 2.0 |
src/Day04.kt | roxanapirlea | 572,665,040 | false | {"Kotlin": 27613} | fun main() {
fun String.getAssignment(): Pair<Int, Int> =
substringBefore("-").toInt() to substringAfter("-").toInt()
fun isAssignmentContainingOther(assignment1: Pair<Int, Int>, assignment2: Pair<Int, Int>): Boolean {
if (assignment1.first <= assignment2.first && assignment1.second >= assignme... | 0 | Kotlin | 0 | 0 | 6c4ae6a70678ca361404edabd1e7d1ed11accf32 | 1,494 | aoc-2022 | Apache License 2.0 |
src/Day04.kt | bin-wang | 572,801,360 | false | {"Kotlin": 19395} | fun main() {
infix fun IntRange.fullyContains(other: IntRange) = first <= other.first && last >= other.last
infix fun IntRange.overlaps(other: IntRange) = !(last < other.first || first > other.last)
fun parseLine(line: String): List<IntRange> {
return line.split(",").map {
val (first, ... | 0 | Kotlin | 0 | 0 | dca2c4915594a4b4ca2791843b53b71fd068fe28 | 915 | aoc22-kt | Apache License 2.0 |
archive/src/main/kotlin/com/grappenmaker/aoc/year18/Day24.kt | 770grappenmaker | 434,645,245 | false | {"Kotlin": 409647, "Python": 647} | package com.grappenmaker.aoc.year18
import com.grappenmaker.aoc.PuzzleSet
import com.grappenmaker.aoc.doubleLines
import com.grappenmaker.aoc.splitInts
import com.grappenmaker.aoc.takeUntil
fun PuzzleSet.day24() = puzzle {
data class Group(
val units: Int,
val hp: Int,
val immunities: Set<... | 0 | Kotlin | 0 | 7 | 92ef1b5ecc3cbe76d2ccd0303a73fddda82ba585 | 4,899 | advent-of-code | The Unlicense |
2015/18/kotlin/b.kt | shrivatsas | 583,681,989 | false | {"Kotlin": 17998, "Python": 9402, "Racket": 4669, "Clojure": 2953} | import java.io.File
fun updateStuckLights(d: List<CharArray>): List<CharArray> {
d[0][0] = '#'
d[0][d[0].size - 1] = '#'
d[d.size - 1][0] = '#'
d[d.size - 1][d[0].size - 1] = '#'
return d
}
fun isOn(d: List<CharArray>, i: Int, j: Int): Boolean {
if (i < 0 || i > d.size - 1) {
return false
}
if (j ... | 0 | Kotlin | 0 | 1 | 529a72ff55f1d90af97f8e83b6c93a05afccb44c | 2,002 | AoC | MIT License |
src/main/kotlin/dev/shtanko/algorithms/leetcode/KClosestPoints.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 | 1,888 | kotlab | Apache License 2.0 |
2022/src/main/kotlin/day16.kt | madisp | 434,510,913 | false | {"Kotlin": 388138} | import utils.Parse
import utils.Parser
import utils.Solution
import utils.mapItems
fun main() {
Day16.run()
}
object Day16 : Solution<List<Day16.Valve>>() {
override val name = "day16"
override val parser = Parser.lines
.mapItems { it.replace("tunnel leads to valve", "tunnels lead to valves") }
.mapItem... | 0 | Kotlin | 0 | 1 | 3f106415eeded3abd0fb60bed64fb77b4ab87d76 | 5,488 | aoc_kotlin | MIT License |
src/main/kotlin/g0701_0800/s0764_largest_plus_sign/Solution.kt | javadev | 190,711,550 | false | {"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994} | package g0701_0800.s0764_largest_plus_sign
// #Medium #Array #Dynamic_Programming #2023_03_08_Time_415_ms_(100.00%)_Space_49.9_MB_(100.00%)
class Solution {
fun orderOfLargestPlusSign(n: Int, mines: Array<IntArray>): Int {
val mat = Array(n) { BooleanArray(n) }
for (pos in mines) {
mat... | 0 | Kotlin | 14 | 24 | fc95a0f4e1d629b71574909754ca216e7e1110d2 | 1,523 | LeetCode-in-Kotlin | MIT License |
aoc/src/ColorGame.kt | aragos | 726,211,893 | false | {"Kotlin": 16232} | import java.io.File
fun main() {
// problem1()
problem2()
}
private fun problem2() {
var powerSum = 0
val colors = listOf("red", "green", "blue")
File("inputs/colorGame.txt").forEachLine { line ->
val split = line.split(":")
val maxes = colors.associateWith { 0 }.toMutableMap()
split[1].split(";"... | 0 | Kotlin | 0 | 0 | 7bca0a857ea42d89435adc658c0ff55207ca374a | 1,334 | aoc2023 | Apache License 2.0 |
src/main/kotlin/dp/EditDist.kt | yx-z | 106,589,674 | false | null | import util.get
import util.min
import util.set
import util.toCharOneArray
// Edit Distance between 2 Strings
// min # of add/remove/replace modifications to match 2 Strings
fun main(args: Array<String>) {
// test strings
val s1 = "algorithm"
val s2 = "altruistic"
// println(editDistRecursion(s1, s2))
println(edi... | 0 | Kotlin | 0 | 1 | 15494d3dba5e5aa825ffa760107d60c297fb5206 | 2,961 | AlgoKt | MIT License |
src/main/kotlin/day18/Code.kt | fcolasuonno | 317,324,330 | false | null | package day18
import isDebug
import java.io.File
fun main() {
val name = if (isDebug()) "test.txt" else "input.txt"
System.err.println(name)
val dir = ::main::class.java.`package`.name
val input = File("src/main/kotlin/$dir/$name").readLines()
val parsed = parse(input)
part1(parsed)
part2(... | 0 | Kotlin | 0 | 0 | e7408e9d513315ea3b48dbcd31209d3dc068462d | 1,827 | AOC2020 | MIT License |
src/main/kotlin/days/Day4Data.kt | yigitozgumus | 572,855,908 | false | {"Kotlin": 26037} | package days
import utils.SolutionData
fun main() = with(Day4Data()) {
solvePart1()
solvePart2()
}
class Day4Data : SolutionData(inputFile = "inputs/day4.txt") {
val part1Data = rawData.map { it.split(",").map { it.split("-").map { it.toInt() } } }
fun doesListsContainEachOther(first: List<Int>, second: List<I... | 0 | Kotlin | 0 | 0 | 9a3654b6d1d455aed49d018d9aa02d37c57c8946 | 1,077 | AdventOfCode2022 | MIT License |
src/main/kotlin/Day001.kt | ruffCode | 398,923,968 | false | null | object Day001 {
private val input = PuzzleInput("day001.txt").readLines().map { it.toInt() }
internal fun partOne(input: List<Int>): Int {
var result = 0
outer@ for (i in input) {
for (ii in input) {
if (i + ii == 2020) {
result = i * ii
... | 0 | Kotlin | 0 | 0 | 477510cd67dac9653fc61d6b3cb294ac424d2244 | 1,857 | advent-of-code-2020-kt | MIT License |
src/Day07.kt | undermark5 | 574,819,802 | false | {"Kotlin": 67472} | import java.math.BigInteger
sealed interface TerminalLine {
sealed class Command : TerminalLine {
class CdCommand(val arg: String) : Command()
object LsCommand : Command()
}
sealed class Listing(val name: String) : TerminalLine {
abstract val size: BigInteger
class FileLis... | 0 | Kotlin | 0 | 0 | e9cf715b922db05e1929f781dc29cf0c7fb62170 | 5,755 | AoC_2022_Kotlin | Apache License 2.0 |
src/Day02.kt | HenryCadogan | 574,509,648 | false | {"Kotlin": 12228} | fun main() {
val input = readInput("Day02")
/*
A | X -> Rock
B | Y -> Paper
C | Z -> Scissors
*/
fun part1(input: List<String>): Int {
return input.sumOf {
val myMove = it.takeLast(1)[0]
val theirMove = it.take(1)[0]
val shapePoints ... | 0 | Kotlin | 0 | 0 | 0a0999007cf16c11355fcf32fc8bc1c66828bbd8 | 2,658 | AOC2022 | Apache License 2.0 |
src/Day23.kt | jvmusin | 572,685,421 | false | {"Kotlin": 86453} | import java.util.*
fun main() {
val dirs = HashMap<Char, Pair<Int, Int>>().apply {
this['N'] = -1 to 0
this['S'] = 1 to 0
this['W'] = 0 to -1
this['E'] = 0 to 1
}
val neighbors = mapOf(
'N' to "EW",
'S' to "EW",
'W' to "NS",
'E' to "NS"
)... | 1 | Kotlin | 0 | 0 | 4dd83724103617aa0e77eb145744bc3e8c988959 | 3,192 | advent-of-code-2022 | Apache License 2.0 |
cz.wrent.advent/Day13.kt | Wrent | 572,992,605 | false | {"Kotlin": 206165} | package cz.wrent.advent
import java.util.Deque
import java.util.LinkedList
fun main() {
println(partOne(test))
val result = partOne(input)
println("13a: $result")
println(partTwo(test))
println("13b: ${partTwo(input)}")
}
private fun partOne(input: String): Int {
val pairs = input.split("\n\n")
val packetPair... | 0 | Kotlin | 0 | 0 | 8230fce9a907343f11a2c042ebe0bf204775be3f | 25,069 | advent-of-code-2022 | MIT License |
src/Day12.kt | iownthegame | 573,926,504 | false | {"Kotlin": 68002} | import java.util.Queue
import kotlin.Pair
class Point(val x: Int, val y: Int, val value: Char) {
fun sameAs(anotherPoint: Point): Boolean {
return anotherPoint.x == x && anotherPoint.y == y
}
// fun inRange(rows: Int, cols: Int): Boolean {
// return (x in 0 until rows) && (y in 0 until cols)
... | 0 | Kotlin | 0 | 0 | 4e3d0d698669b598c639ca504d43cf8a62e30b5c | 5,389 | advent-of-code-2022 | Apache License 2.0 |
kotlin-practice/src/main/kotlin/algorithms/new/SumOfCalibrationValues.kt | nicolegeorgieva | 590,020,790 | false | {"Kotlin": 120359} | package algorithms.new
import java.io.File
fun main() {
val input = File("day1.txt").readText()
val input2 = File("new.txt").readText()
println(finalSum("www3two"))
println(finalSum(input))
println(finalSum(input2))
}
val numbers = mapOf(
Pair("one", 1),
Pair("two", 2),
Pair("three",... | 0 | Kotlin | 0 | 1 | c96a0234cc467dfaee258bdea8ddc743627e2e20 | 1,685 | kotlin-practice | MIT License |
src/main/kotlin/com/advent/of/code/hjk/Day22.kt | h-j-k | 427,964,167 | false | {"Java": 46088, "Kotlin": 26804} | package com.advent.of.code.hjk
import kotlin.math.abs
object Day22 {
private fun parse(line: String): Node? =
"/dev/grid/node-x(?<x>\\d+)-y(?<y>\\d+)\\s+(?<size>\\d+)T\\s+(?<used>\\d+)T.+".toRegex()
.matchEntire(line)?.destructured
?.let { (x, y, size, used) -> Node(x.toInt(), y.t... | 0 | Java | 0 | 0 | 5ffa381e97cbcfe234c49b5a5f8373641166db6c | 1,277 | advent16 | Apache License 2.0 |
src/Day03.kt | MisterTeatime | 560,956,854 | false | {"Kotlin": 37980} | fun main() {
val priorities = ('a'..'z') + ('A'..'Z')
fun part1(input: List<String>): Int {
return input.map {
it.chunked(it.length / 2)
}
.flatMap { (front, back) ->
front.toSet().intersect(back.toSet())
}
.sumOf { priorities.inde... | 0 | Kotlin | 0 | 0 | 8ba0c36992921e1623d9b2ed3585c8eb8d88718e | 934 | AoC2022 | Apache License 2.0 |
src/main/kotlin/io/nozemi/aoc/solutions/year2021/day09/SmokeBasin.kt | Nozemi | 433,882,587 | false | {"Kotlin": 92614, "Shell": 421} | package io.nozemi.aoc.solutions.year2021.day09
import io.nozemi.aoc.puzzle.Puzzle
import io.nozemi.aoc.utils.addIfNotExists
import kotlin.reflect.KFunction0
class SmokeBasin(input: String) : Puzzle<Array<IntArray>>(input) {
override fun Sequence<String>.parse(): Array<IntArray> = this.map { line ->
line.... | 0 | Kotlin | 0 | 0 | fc7994829e4329e9a726154ffc19e5c0135f5442 | 5,428 | advent-of-code | MIT License |
src/main/kotlin/dev/bogwalk/batch9/Problem97.kt | bog-walk | 381,459,475 | false | null | package dev.bogwalk.batch9
import java.math.BigInteger
/**
* Problem 97: Large Non-Mersenne Prime
*
* https://projecteuler.net/problem=97
*
* Goal: Return the last 12 digits of a very large number of the form A * (B^C) + D. If this
* amount is less than 1e12, return the output padded with leading zeroes.
*
* ... | 0 | Kotlin | 0 | 0 | 62b33367e3d1e15f7ea872d151c3512f8c606ce7 | 3,387 | project-euler-kotlin | MIT License |
src/Day08/Day08.kt | emillourens | 572,599,575 | false | {"Kotlin": 32933} | fun main() {
fun part1(input: List<String>): Int {
var forest: MutableList<MutableList<Int>> = ArrayList()//Array(input.size) { IntArray(input.size) }
var counter = 0
for (line in input)
{
var tempList: MutableList<Int> = ArrayList()
for ( j in line.indices... | 0 | Kotlin | 0 | 0 | 1f9739b73ef080b012e505e0a4dfe88f928e893d | 3,846 | AoC2022 | Apache License 2.0 |
src/aoc22/Day13.kt | mihassan | 575,356,150 | false | {"Kotlin": 123343} | @file:Suppress("PackageDirectoryMismatch")
package aoc2022.day13
import lib.Collections.headTail
import lib.Solution
sealed interface Value : Comparable<Value> {
override operator fun compareTo(other: Value): Int =
when (this) {
is IntegerValue -> when (other) {
is IntegerValue -> value.compareTo... | 0 | Kotlin | 0 | 0 | 698316da8c38311366ee6990dd5b3e68b486b62d | 3,022 | aoc-kotlin | Apache License 2.0 |
src/Day03.kt | derivz | 575,340,267 | false | {"Kotlin": 6141} | // create map of all lowercase letters and uppercase letters to numbers from 1 to 52
val letterValues = ('a'..'z').zip(1..26).toMap() + ('A'..'Z').zip(27..52).toMap()
fun main() {
fun part1(lines: List<String>): Int {
return lines.map { line ->
val left = line.substring(0, line.length / 2).toSe... | 0 | Kotlin | 0 | 0 | 24da2ff43dc3878c4e025f5b737dca31913f40a5 | 890 | AoC2022.kt | Apache License 2.0 |
src/main/kotlin/adventofcode2022/solution/day_10.kt | dangerground | 579,293,233 | false | {"Kotlin": 51472} | package adventofcode2022.solution
import adventofcode2022.util.readDay
import java.lang.Long.min
fun main() {
Day10("10").solve()
}
class Day10(private val num: String) {
private val inputText = readDay(num)
fun solve() {
println("Day $num Solution")
println("* Part 1: ${solution1()}")
... | 0 | Kotlin | 0 | 0 | f1094ba3ead165adaadce6cffd5f3e78d6505724 | 2,686 | adventofcode-2022 | MIT License |
src/Day11.kt | ChAoSUnItY | 572,814,842 | false | {"Kotlin": 19036} | import java.util.*
fun main() {
val perMonkeyPattern =
Regex("""Monkey \d*:\n {2}Starting items: ([\w, ]+)\n {2}Operation: (new = [ (old)+*\d]+)\n {2}Test: divisible by (\d+)\n {4}If true: throw to monkey (\d+)\n {4}If false: throw to monkey (\d+)""")
val operationPattern =
Regex("""new = old (... | 0 | Kotlin | 0 | 3 | 4fae89104aba1428820821dbf050822750a736bb | 3,113 | advent-of-code-2022-kt | Apache License 2.0 |
leetcode2/src/leetcode/sqrtx.kt | hewking | 68,515,222 | false | null | package leetcode
/**
* 69. x 的平方根
* https://leetcode-cn.com/problems/sqrtx/
* Created by test
* Date 2019/7/18 0:50
* Description
* 实现 int sqrt(int x) 函数。
计算并返回 x 的平方根,其中 x 是非负整数。
由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。
示例 1:
输入: 4
输出: 2
示例 2:
输入: 8
输出: 2
说明: 8 的平方根是 2.82842...,
由于返回类型是整数,小数部分将被舍去。
来源:力扣(LeetC... | 0 | Kotlin | 0 | 0 | a00a7aeff74e6beb67483d9a8ece9c1deae0267d | 1,951 | leetcode | MIT License |
src/main/kotlin/recursion/WordSearchII.kt | e-freiman | 471,473,372 | false | {"Kotlin": 78010} | package recursion
class WordSearchII {
class TrieNode {
val children = HashMap<Char, TrieNode>()
var isLeaf = false
}
private val ret = mutableSetOf<String>()
private var board: Array<CharArray> = arrayOf<CharArray>()
private var m: Int = -1
private var n: Int = -1
private... | 0 | Kotlin | 0 | 0 | fab7f275fbbafeeb79c520622995216f6c7d8642 | 2,105 | LeetcodeGoogleInterview | Apache License 2.0 |
solutions/aockt/y2016/Y2016D03.kt | Jadarma | 624,153,848 | false | {"Kotlin": 435090} | package aockt.y2016
import io.github.jadarma.aockt.core.Solution
object Y2016D03 : Solution {
/** Parses the input, returning the number rows as triples of integers. */
private fun parseInput(input: String): Sequence<Triple<Int, Int, Int>> =
input
.lineSequence()
.map {
... | 0 | Kotlin | 0 | 3 | 19773317d665dcb29c84e44fa1b35a6f6122a5fa | 1,455 | advent-of-code-kotlin-solutions | The Unlicense |
src/com/ncorti/aoc2023/Day16.kt | cortinico | 723,409,155 | false | {"Kotlin": 76642} | package com.ncorti.aoc2023
import com.ncorti.aoc2023.Direction.*
enum class Direction {
UP, DOWN, LEFT, RIGHT;
fun opposite(): Direction = when (this) {
UP -> DOWN
DOWN -> UP
LEFT -> RIGHT
RIGHT -> LEFT
}
}
fun main() {
fun parseInput() = getInputAsText("16") {
... | 1 | Kotlin | 0 | 1 | 84e06f0cb0350a1eed17317a762359e9c9543ae5 | 3,740 | adventofcode-2023 | MIT License |
src/main/kotlin/com/github/michaelbull/advent2023/day21/GardenMap.kt | michaelbull | 726,012,340 | false | {"Kotlin": 195941} | package com.github.michaelbull.advent2023.day21
import com.github.michaelbull.advent2023.math.Vector2
import com.github.michaelbull.advent2023.math.Vector2.Companion.CARDINAL_DIRECTIONS
import com.github.michaelbull.advent2023.math.Vector2CharMap
import com.github.michaelbull.advent2023.math.Vector3
import com.github.... | 0 | Kotlin | 0 | 1 | ea0b10a9c6528d82ddb481b9cf627841f44184dd | 3,539 | advent-2023 | ISC License |
Day24/src/Bugs.kt | gautemo | 225,219,298 | false | null | import java.io.File
import kotlin.math.pow
fun main(){
val input = File(Thread.currentThread().contextClassLoader.getResource("input.txt")!!.toURI()).readText()
val result = findRepeatedBiodiversity(input)
println(result)
val spaceResult = findBugsSpaceFold(input, 200)
println(spaceResult)
}
fun ... | 0 | Kotlin | 0 | 0 | f8ac96e7b8af13202f9233bb5a736d72261c3a3b | 3,919 | AdventOfCode2019 | MIT License |
src/Day03.kt | lmoustak | 573,003,221 | false | {"Kotlin": 25890} | fun main() {
val items = mutableSetOf<Char>()
for (c in 'a'..'z') items.add(c)
for (c in 'A'..'Z') items.add(c)
fun part1(input: List<String>): Int {
var score = 0
for (line in input) {
val partition = line.length / 2
val firstHalf = line.substring(0, partition)... | 0 | Kotlin | 0 | 0 | bd259af405b557ab7e6c27e55d3c419c54d9d867 | 1,175 | aoc-2022-kotlin | Apache License 2.0 |
aoc/src/main/kotlin/com/bloidonia/aoc2023/day10/Main.kt | timyates | 725,647,758 | false | {"Kotlin": 45518, "Groovy": 202} | package com.bloidonia.aoc2023.day10
import com.bloidonia.aoc2023.text
private const val example = """-L|F7
7S-7|
L|7||
-L-J|
L|-JF"""
private const val example2 = """7-F7-
.FJ|7
SJLL7
|F--J
LJ.LJ"""
private const val example3 = """...........
.S-------7.
.|F-----7|.
.||.....||.
.||.....||.
.|L-7.F-J|.
.|..|.|..|.
.... | 0 | Kotlin | 0 | 0 | 158162b1034e3998445a4f5e3f476f3ebf1dc952 | 2,510 | aoc-2023 | MIT License |
src/Day03.kt | pejema | 576,456,995 | false | {"Kotlin": 7994} | import kotlin.streams.toList
fun main() {
val items = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
fun getPriorities(compartment1: String, compartment2: String) : Int {
return compartment1.toList().stream()
.filter { item -> compartment2.contains(item) }
.find... | 0 | Kotlin | 0 | 0 | b2a06318f0fcf5c6067058755a44e5567e345e0c | 1,432 | advent-of-code | Apache License 2.0 |
src/main/kotlin/com/colinodell/advent2016/Day22.kt | colinodell | 495,627,767 | false | {"Kotlin": 80872} | package com.colinodell.advent2016
class Day22(input: List<String>) {
private val nodes = input.drop(2).map { Node.parse(it) }
fun solvePart1() = nodes.permutationPairs().includingReversePairs().filter { it.first.used > 0 && it.first.used < it.second.avail }.count()
fun solvePart2(): Int {
val xMax... | 0 | Kotlin | 0 | 0 | 8a387ddc60025a74ace8d4bc874310f4fbee1b65 | 1,225 | advent-2016 | Apache License 2.0 |
src/Day01.kt | phamobic | 572,925,492 | false | {"Kotlin": 12697} | fun main() {
fun insertCaloriesToSortedMax(topMaxCalories: MutableList<Long>, calories: Long) {
val index = topMaxCalories.indexOfFirst { calories > it }
if (index < 0) return
topMaxCalories.add(index, calories)
topMaxCalories.removeLast()
}
fun getMaxCaloriesSum(numberOfE... | 1 | Kotlin | 0 | 0 | 34b2603470c8325d7cdf80cd5182378a4e822616 | 1,137 | aoc-2022 | Apache License 2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.