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/commonMain/kotlin/advent2020/day01/Day01Puzzle.kt
jakubgwozdz
312,526,719
false
null
package advent2020.day01 import advent2020.ProgressLogger var comparisons = 0 // comparisons counter for reporting internal fun findIndex( sortedEntries: List<Int>, expectedSum: Int, indexOfExcluded: Int = -1, ): Int { var startIndex = indexOfExcluded + 1 var endIndex = sortedEntries.lastIndex ...
0
Kotlin
0
2
e233824109515fc4a667ad03e32de630d936838e
1,879
advent-of-code-2020
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[50]Pow(x, n).kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//实现 pow(x, n) ,即计算 x 的 n 次幂函数(即,xn)。 // // // // 示例 1: // // //输入:x = 2.00000, n = 10 //输出:1024.00000 // // // 示例 2: // // //输入:x = 2.10000, n = 3 //输出:9.26100 // // // 示例 3: // // //输入:x = 2.00000, n = -2 //输出:0.25000 //解释:2-2 = 1/22 = 1/4 = 0.25 // // // // // 提示: // // // -100.0 < x < 100.0 // -231 <...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
1,426
MyLeetCode
Apache License 2.0
src/main/kotlin/tree/bintree/LargestBST.kt
yx-z
106,589,674
false
null
package tree.bintree fun main(args: Array<String>) { // sample tree // 3 // / \ // 2 5 // \ / \ // 1 3 6 val root = BinTreeNode(3) root.left = BinTreeNode(2) root.right = BinTreeNode(5) root.left!!.right = BinTreeNode(1) root.right!!.left = BinTreeNode(3) root.right!!.rig...
0
Kotlin
0
1
15494d3dba5e5aa825ffa760107d60c297fb5206
1,170
AlgoKt
MIT License
advent/src/test/kotlin/org/elwaxoro/advent/y2020/Dec23.kt
elwaxoro
328,044,882
false
{"Kotlin": 376774}
package org.elwaxoro.advent.y2020 import org.elwaxoro.advent.PuzzleDayTester class Dec23 : PuzzleDayTester(23, 2020) { override fun part1(): Any = playCupGameWithCrabbo(parse(), 100).let { cups -> cups.listify(1, cups[1]!!, listOf()).joinToString("") } override fun part2(): Any = playCupGameWith...
0
Kotlin
4
0
1718f2d675f637b97c54631cb869165167bc713c
3,057
advent-of-code
MIT License
src/Day03.kt
maquirag
576,698,073
false
{"Kotlin": 3883}
fun main() { val day = "03" fun priority(c: Char): Int = when(c) { in 'a'..'z' -> (c - 'a') + 1 else -> (c - 'A') + 27 } fun part1(input: List<String>): Int = input.map { val misplaced = (it.take(it.length/2).toSet() intersect it.drop(it.length/2).toSet()).first() ...
0
Kotlin
0
0
23403172e909f8fb0c87e953d06fc0921c75fc32
894
aoc2022-kotlin
Apache License 2.0
src/day07/day07.kt
tmikulsk1
573,165,106
false
{"Kotlin": 25281}
package day07 import readInput data class Node( val key: String, val level: Int, val size: Int = 0, var totalSize: Int = 0, var children: List<Node>? = null, val parent: String? = null ) var globalCurrentDir = "" var globalParentDir = "" var globalLevel = 1 var globalRootNode = Node(key = "di...
0
Kotlin
0
1
f5ad4e601776de24f9a118a0549ac38c63876dbe
7,398
AoC-22
Apache License 2.0
src/net/mlin/GLnext/data/BedRanges.kt
mlin
421,269,634
false
{"Kotlin": 129211, "Shell": 12192, "Python": 8907, "Makefile": 186}
package net.mlin.GLnext.data import net.mlin.iitj.IntegerIntervalTree /** * Minimal in-memory data structure of a BED file indexed for overlap/containment queries. Can be * broadcasted efficiently. */ class BedRanges : java.io.Serializable { private val iit: Array<IntegerIntervalTree> private val totalCount...
0
Kotlin
0
3
08a13b1993eded11c4ca826c3644ac919c762a23
3,278
GLnext
Apache License 2.0
Kotlin/Solucionando problemas em Kotlin/Figurinhas.kt
Pleiterson
328,727,089
false
null
// Figurinhas /* Ricardo e Vicente são aficionados por figurinhas. Nas horas vagas, eles arrumam um jeito de jogar um “bafo” ou algum outro jogo que envolva tais figurinhas. Ambos também têm o hábito de trocarem as figuras repetidas com seus amigos e certo dia pensaram em uma brincadeira diferente. Chamaram todos os a...
3
Java
73
274
003eda61f88702e68670262d6c656f47a3f318b6
2,094
desafios-bootcamps-dio
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/FlipGame2.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,100
kotlab
Apache License 2.0
src/day04/Day04.kt
chskela
574,228,146
false
{"Kotlin": 9406}
package day04 import java.io.File fun main() { fun parseInput(input: String) = input .lines() .map { it.split(",") .map { s -> s.split("-") } .map { (a, b) -> (a.toInt()..b.toInt()).toSet() } } fun part1(...
0
Kotlin
0
0
951d38a894dcf0109fd0847eef9ff3ed3293fca0
981
adventofcode-2022-kotlin
Apache License 2.0
src/Day10.kt
RandomUserIK
572,624,698
false
{"Kotlin": 21278}
fun main() { fun part1(input: List<String>): Int { var signalStrength = 0 var cycle = 1 var register = 1 fun calculateSignalStrength(currentCycle: Int, register: Int): Int = currentCycle * register fun increaseSignalStrength(currentCycle: Int, register: Int) { if (currentCycle % 40 == 20) signalS...
0
Kotlin
0
0
f22f10da922832d78dd444b5c9cc08fadc566b4b
1,358
advent-of-code-2022
Apache License 2.0
src/main/kotlin/Day02.kt
SimonMarquis
724,825,757
false
{"Kotlin": 30983}
import Day02.Color.blue import Day02.Color.green import Day02.Color.red class Day02(private val input: List<String>) { @Suppress("EnumEntryName") enum class Color { red, green, blue } private val regex = """(\d+) (${Color.entries.joinToString("|")})""".toRegex() fun part1( target: Map<Color,...
0
Kotlin
0
1
043fbdb271603c84b7e5eddcd0e8f323c6ebdf1e
1,204
advent-of-code-2023
MIT License
src/Day06.kt
pmellaaho
573,136,030
false
{"Kotlin": 22024}
fun main() { fun String.allDifferent(): Boolean { forEachIndexed { index, c -> for (i in index + 1..lastIndex) { if (this[i] == c) return false } } return true } fun part1(input: List<String>): Int { val windowSize = 4 val cou...
0
Kotlin
0
0
cd13824d9bbae3b9debee1a59d05a3ab66565727
997
AoC_22
Apache License 2.0
src/main/kotlin/kt/kotlinalgs/app/graph/BellmanFord.ws.kts
sjaindl
384,471,324
false
null
package kt.kotlinalgs.app.graph println("Test") data class Vertice(val value: String) data class Edge( val from: Vertice, val to: Vertice, val weight: Int ) data class WeightedDirectedGraph(val vertices: List<Vertice>) { var edges: MutableList<Edge> = mutableListOf() fun addEdge(from: Vertice, ...
0
Java
0
0
e7ae2fcd1ce8dffabecfedb893cb04ccd9bf8ba0
2,502
KotlinAlgs
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/TwoSum.kt
ashtanko
515,874,521
false
{"Kotlin": 235302, "Shell": 755, "Makefile": 591}
/* * MIT License * Copyright (c) 2022 <NAME> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge...
2
Kotlin
1
9
6a2d7ed76e2d88a3446f6558109809c318780e2c
3,503
the-algorithms
MIT License
src/main/kotlin/dev/bogwalk/util/custom/SuDokuGame.kt
bog-walk
381,459,475
false
null
package dev.bogwalk.util.custom /** * A class representing a Su Doku puzzle grid, with each cell value stored as a Set, so that * options can be iterated over until a final value remains. */ class SuDokuGame(input: List<String>) { private var puzzleCells: Array<Array<Set<Int>>> private val hasUnfilledCells:...
0
Kotlin
0
0
62b33367e3d1e15f7ea872d151c3512f8c606ce7
10,499
project-euler-kotlin
MIT License
src/main/kotlin/ru/timakden/aoc/year2022/Day24.kt
timakden
76,895,831
false
{"Kotlin": 321649}
package ru.timakden.aoc.year2022 import ru.timakden.aoc.util.measure import ru.timakden.aoc.util.readInput import kotlin.math.abs /** * [Day 24: <NAME>](https://adventofcode.com/2022/day/24). */ object Day24 { @JvmStatic fun main(args: Array<String>) { measure { val input = readInput("ye...
0
Kotlin
0
3
acc4dceb69350c04f6ae42fc50315745f728cce1
4,825
advent-of-code
MIT License
Problem Solving/Algorithms/Basic - Day of the Programmer.kt
MechaArms
525,331,223
false
{"Kotlin": 30017}
/* Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the 256th day of the year) during a year in the inclusive range from 1700 to 2700. From 1700 to 1917, Russia's official calendar was the Julian calendar; since 1919 they used the Gregorian calendar sys...
0
Kotlin
0
1
eda7f92fca21518f6ee57413138a0dadf023f596
4,079
My-HackerRank-Solutions
MIT License
src/main/kotlin/com/askrepps/advent2021/day10/Day10.kt
askrepps
726,566,200
false
{"Kotlin": 302802}
/* * MIT License * * Copyright (c) 2021-2023 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modi...
0
Kotlin
0
0
89de848ddc43c5106dc6b3be290fef5bbaed2e5a
3,256
advent-of-code-kotlin
MIT License
src/main/euler/solved/Task_536.kt
dzmitry-paulenka
24,504,894
false
{"Java": 805518, "Kotlin": 23071, "C#": 21356, "Ruby": 17045, "Scala": 6559, "Python": 4465, "Mathematica": 3529, "JavaScript": 1215, "Lua": 1075}
package solved import tasks.AbstractTask import tasks.Tester import utils.MyMath import utils.log.Logger //Answer : 3557005261906288 class Task_536 : AbstractTask() { val LIM = 1000000L; // val LIM = 1000000000000L; var sum = 11L; var maxprime = 0L; var primes: LongArray = LongArray(0); var fa...
0
Java
0
0
1af096219a86d173ebcb23265885ab309802987d
3,598
project-euler
MIT License
aoc-kotlin/src/main/kotlin/day08/Day08.kt
mahpgnaohhnim
573,579,334
false
{"Kotlin": 29246, "TypeScript": 1975, "Go": 1693, "Rust": 1520, "JavaScript": 123}
package day08 import java.io.File class Day08 { companion object { val inputFile = File(this::class.java.getResource("input.txt")?.path.orEmpty()) fun countVisibleTrees(inputText: String): Int { val data = createTreeList(inputText) val visibleTrees = data.filter { it.visib...
0
Kotlin
0
0
c514152e9e2f0047514383fe536f7610a66aff70
5,224
aoc-2022
MIT License
src/main/kotlin/days/Day10.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days @AdventOfCodePuzzle( name = "<NAME>", url = "https://adventofcode.com/2022/day/10", date = Date(day = 10, year = 2022) ) class Day10(val input: List<String>) : Puzzle { private val instructions = input .map { line -> line.substringBefore(' ') to (line.substringAfter(' ').toIntOrNu...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
1,691
advent-of-code-2022
Creative Commons Zero v1.0 Universal
2021/src/test/kotlin/Day05.kt
jp7677
318,523,414
false
{"Kotlin": 171284, "C++": 87930, "Rust": 59366, "C#": 1731, "Shell": 354, "CMake": 338}
import Util.towards import kotlin.math.abs import kotlin.test.Test import kotlin.test.assertEquals class Day05 { data class Coord(val x: Int, val y: Int) @Test fun `run part 01`() { val overlaps = getCoords().calcOverlaps() assertEquals(8111, overlaps) } @Test fun `run part 0...
0
Kotlin
1
2
8bc5e92ce961440e011688319e07ca9a4a86d9c9
1,457
adventofcode
MIT License
kotest-assertions/kotest-assertions-core/src/commonMain/kotlin/io/kotest/matchers/ranges/Range.kt
kotest
47,071,082
false
{"Kotlin": 4460715, "CSS": 352, "Java": 145}
package io.kotest.matchers.ranges data class Range<T: Comparable<T>>( val start: RangeEdge<T>, val end: RangeEdge<T> ) { init { require(start.value <= end.value) { "${start.value} cannot be after ${end.value}" } } override fun toString(): String { return "${if(start.edgeTyp...
102
Kotlin
615
4,198
7fee2503fbbdc24df3c594ac6b240c11b265d03e
2,535
kotest
Apache License 2.0
src/main/java/kt/day1/LargestTimeForGivenDigits.kt
surya-uppuluri
292,050,828
false
{"Java": 9862, "Kotlin": 5746}
package kt.day1 import jv.day1.prerequisites.PermutationGenerator import lombok.extern.slf4j.Slf4j import java.util.* @Slf4j class LargestTimeForGivenDigits { /** * 949. Largest Time for Given Digits * Easy * * * 271 * * * 565 * * * Add to List * * ...
0
Java
0
0
5cddbecb5502294537137b6864aaf54eb001be5d
2,432
september-leetcode-challenge
Apache License 2.0
app/src/main/kotlin/aoc2021/day10/NavigationLine.kt
dbubenheim
435,284,482
false
{"Kotlin": 31242}
package aoc2021.day10 import kotlin.streams.asSequence data class NavigationLine(val value: String) { val syntaxCheck: SyntaxCheck = value.checkSyntax() override fun toString(): String = "$value: $syntaxCheck" } private fun String.checkSyntax(): SyntaxCheck { val errorScores: Map<Char, Int> = mapOf( ...
9
Kotlin
0
0
83a93845ebbc1a6405f858214bfa79b3448b932c
1,752
advent-of-code-2021
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinPairSum.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
1,197
kotlab
Apache License 2.0
src/main/kotlin/g2001_2100/s2096_step_by_step_directions_from_a_binary_tree_node_to_another/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g2001_2100.s2096_step_by_step_directions_from_a_binary_tree_node_to_another // #Medium #String #Depth_First_Search #Tree #Binary_Tree // #2023_06_28_Time_690_ms_(93.33%)_Space_95.9_MB_(66.67%) import com_github_leetcode.TreeNode /* * Example: * var ti = TreeNode(5) * var v = ti.`val` * Definition for a b...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,428
LeetCode-in-Kotlin
MIT License
src/main/kotlin/info/jukov/adventofcode/y2022/Day16.kt
jukov
572,271,165
false
{"Kotlin": 78755}
package info.jukov.adventofcode.y2022 import info.jukov.adventofcode.Day import info.jukov.adventofcode.util.fixHashCode import java.io.BufferedReader import kotlin.math.max class Day16 : Day() { override val year: Int = 2022 override val day: Int = 16 private val cache1 = HashMap<CacheKey1, Int>() ...
0
Kotlin
1
0
5fbdaf39a508dec80e0aa0b87035984cfd8af1bb
8,302
AdventOfCode
The Unlicense
src/main/kotlin/com/sk/topicWise/tree/easy/437. Path Sum III.kt
sandeep549
262,513,267
false
{"Kotlin": 530613}
package com.sk.topicWise.tree.easy import com.sk.topicWise.tree.TreeNode private fun pathSum(root: TreeNode?, sum: Int): Int { var ans = 0 fun dfs(root: TreeNode?): MutableList<ArrayList<Int>> { root?.let { var l = dfs(it.left) var r = dfs(it.right) var lret = mutab...
1
Kotlin
0
0
cf357cdaaab2609de64a0e8ee9d9b5168c69ac12
1,796
leetcode-kotlin
Apache License 2.0
src/main/kotlin/com/jacobhyphenated/advent2023/day21/Day21.kt
jacobhyphenated
725,928,124
false
{"Kotlin": 121644}
package com.jacobhyphenated.advent2023.day21 import com.jacobhyphenated.advent2023.Day class Day21: Day<List<List<Char>>> { override fun getInput(): List<List<Char>> { return readInputFile("21").lines().map { it.toCharArray().toList() } } override fun part1(input: List<List<Char>>): Any { return countP...
0
Kotlin
0
0
90d8a95bf35cae5a88e8daf2cfc062a104fe08c1
1,427
advent2023
The Unlicense
src/Day10.kt
kipwoker
572,884,607
false
null
class Operation(val cycles: Int, val add: Int) fun main() { fun parse(input: List<String>): List<Operation> { return input.map { line -> if (line == "noop") { Operation(1, 0) } else { val modifier = line.split(' ')[1].toInt() Operation...
0
Kotlin
0
0
d8aeea88d1ab3dc4a07b2ff5b071df0715202af2
2,229
aoc2022
Apache License 2.0
src/main/kotlin/days/Day14.kt
TheMrMilchmann
433,608,462
false
{"Kotlin": 94737}
/* * Copyright (c) 2021 <NAME> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, dis...
0
Kotlin
0
1
dfc91afab12d6dad01de552a77fc22a83237c21d
2,790
AdventOfCode2021
MIT License
src/Day10.kt
mlidal
572,869,919
false
{"Kotlin": 20582}
import kotlin.math.abs import kotlin.text.StringBuilder fun main() { fun part1(input: List<String>): Int { var cycle = 1 var signalStrength = 1 val signalStrengths = mutableListOf<Int>() input.forEach { line -> if (line.startsWith("addx")) { cycle += 1 ...
0
Kotlin
0
0
bea7801ed5398dcf86a82b633a011397a154a53d
4,081
AdventOfCode2022
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2020/Day10.kt
tginsberg
315,060,137
false
null
/* * Copyright (c) 2020 by <NAME> */ /** * Advent of Code 2020, Day 10 - Adapter Array * Problem Description: http://adventofcode.com/2020/day/10 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2020/day10/ */ package com.ginsberg.advent2020 class Day10(input: List<Int>) { private val ...
0
Kotlin
2
38
75766e961f3c18c5e392b4c32bc9a935c3e6862b
1,068
advent-2020-kotlin
Apache License 2.0
src/Day10.kt
frango9000
573,098,370
false
{"Kotlin": 73317}
fun main() { val input = readInput("Day10") printTime { println(Day10.part1(input)) } printTime { println(Day10.part2(input)) } } class Day10 { companion object { fun part1(input: List<String>): Int { var signalStrength = 0 var x = 1 var cycle = 1 ...
0
Kotlin
0
0
62e91dd429554853564484d93575b607a2d137a3
1,451
advent-of-code-22
Apache License 2.0
src/main/kotlin/com/kishor/kotlin/algo/recursion/LowestCommonManager.kt
kishorsutar
276,212,164
false
null
package com.kishor.kotlin.algo.recursion class OrgChart(name: Char) { val name = name val directReports = mutableListOf<OrgChart>() } //fun getLowestCommonManager(topManager: OrgChart, empOne: OrgChart, empTwo: OrgChart): OrgChart? { // val managerStack = Stack<OrgChart>() // // for (report in topManag...
0
Kotlin
0
0
6672d7738b035202ece6f148fde05867f6d4d94c
2,176
DS_Algo_Kotlin
MIT License
year2023/day09/part2/src/main/kotlin/com/curtislb/adventofcode/year2023/day09/part2/Year2023Day09Part2.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
/* --- Part Two --- Of course, it would be nice to have even more history included in your report. Surely it's safe to just extrapolate backwards as well, right? For each history, repeat the process of finding differences until the sequence of differences is entirely zero. Then, rather than adding a zero to the end a...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,854
AdventOfCode
MIT License
kotlin/104.Maximum Depth of Binary Tree(二叉树的最大深度).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>Given a binary tree, find its maximum depth.</p> <p>The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.</p> <p><strong>Note:</strong>&nbsp;A leaf is a node with no children.</p> <p><strong>Example:</strong></p> <p>Given binary tree <code>[3,9,20,...
0
Python
1
3
6731e128be0fd3c0bdfe885c1a409ac54b929597
1,519
leetcode
MIT License
src/main/kotlin/days/Day18.kt
nuudles
316,314,995
false
null
package days class Day18 : Day(18) { enum class Operator { SUM, PRODUCT } sealed class Token { data class Value(val value: Long) : Token() object StartParen : Token() object EndParen : Token() object Plus : Token() object Times : Token() com...
0
Kotlin
0
0
5ac4aac0b6c1e79392701b588b07f57079af4b03
6,956
advent-of-code-2020
Creative Commons Zero v1.0 Universal
src/main/kotlin/Day14.kt
Yeah69
317,335,309
false
{"Kotlin": 73241}
import java.lang.Exception class Day14 : Day() { override val label: String get() = "14" interface Instruction { fun execute(mask: Mask, map: MutableMap<Long, Long>): Mask } abstract class Mask(private val mask: String) : Instruction { override fun execute(mask: Mask, map: MutableMap<...
0
Kotlin
0
0
23121ede8e3e8fc7aa1e8619b9ce425b9b2397ec
3,952
AdventOfCodeKotlin
The Unlicense
src/main/kotlin/g0101_0200/s0115_distinct_subsequences/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0101_0200.s0115_distinct_subsequences // #Hard #String #Dynamic_Programming #2022_09_29_Time_285_ms_(88.89%)_Space_34.2_MB_(100.00%) class Solution { fun numDistinct(s: String, t: String): Int { if (s.length < t.length) { return 0 } if (s.length == t.length) { ...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
1,488
LeetCode-in-Kotlin
MIT License
src/day2/second/Solution.kt
verwoerd
224,986,977
false
null
package day2.second import tools.timeSolution fun main() = timeSolution { val code = readLine()!!.split(",").map { it.toInt() }.toIntArray() val target = 19690720 loop@ for (noun in 0..100) { for (verb in 0..100) { if (executeProgram(code.copyOf(), noun, verb) == target) { println("Solution: $...
0
Kotlin
0
0
554377cc4cf56cdb770ba0b49ddcf2c991d5d0b7
1,275
AoC2019
MIT License
year2020/day13/bus/src/main/kotlin/com/curtislb/adventofcode/year2020/day13/bus/BusSchedule.kt
curtislb
226,797,689
false
{"Kotlin": 2146738}
package com.curtislb.adventofcode.year2020.day13.bus /** * A schedule that lists the IDs of in-service buses at various offsets. * * All in-service buses initially depart at timestamp 0, and the ID of each bus indicates the time * between this and each * subsequent departure. * * @param schedule A string repres...
0
Kotlin
1
1
6b64c9eb181fab97bc518ac78e14cd586d64499e
1,853
AdventOfCode
MIT License
src/main/kotlin/days/Day12.kt
andilau
573,139,461
false
{"Kotlin": 65955}
package days import java.util.PriorityQueue @AdventOfCodePuzzle( name = "Hill Climbing Algorithm", url = "https://adventofcode.com/2022/day/12", date = Date(day = 12, year = 2022) ) class Day12(val input: List<String>) : Puzzle { lateinit var start: Point lateinit var end: Point private val h...
0
Kotlin
0
0
da824f8c562d72387940844aff306b22f605db40
2,060
advent-of-code-2022
Creative Commons Zero v1.0 Universal
kotori/src/main/kotlin/com/github/wanasit/kotori/Dictionary.kt
wanasit
262,215,376
false
null
package com.github.wanasit.kotori import com.github.wanasit.kotori.optimized.DefaultDictionary import com.github.wanasit.kotori.optimized.DefaultTermFeatures open class Dictionary <out TermFeatures> ( open val terms: TermDictionary<TermFeatures>, open val connection: ConnectionCost, open val ...
0
Kotlin
4
41
7ca4f352e6bf4fb314828d36a217953ec5006b20
1,869
kotori
MIT License
src/Day06.kt
emmanueljohn1
572,809,704
false
{"Kotlin": 12720}
fun main() { fun findMarker(chars: String, countUniq: Int = 4): Pair<Int, List<Char>> { val windows = chars.asSequence().windowed(countUniq, 1) val foundMarker = windows.mapIndexed{ idx, value -> Pair(idx+1, value) }.filter { (_, marker) -> marker.toSet().size == countUniq } ...
0
Kotlin
0
0
154db2b1648c9d12f82aa00722209741b1de1e1b
978
advent22
Apache License 2.0
src/day4/Day4.kt
gautemo
317,316,447
false
null
package day4 import shared.getText fun validPassports(input: String, validate: Boolean = false): Int{ val regex = Regex("""^\s*${'$'}""", RegexOption.MULTILINE) val passports = input.split(regex) return passports.count { if(validate) hasValidRequiredFields(it) else hasRequiredFields(it) } } fun hasRequir...
0
Kotlin
0
0
ce25b091366574a130fa3d6abd3e538a414cdc3b
1,491
AdventOfCode2020
MIT License
src/main/kotlin/com/github/ferinagy/adventOfCode/aoc2017/2017-06.kt
ferinagy
432,170,488
false
{"Kotlin": 787586}
package com.github.ferinagy.adventOfCode.aoc2017 fun main() { println("Part1+2:") println(solve(testInput1)) println(solve(input)) } private fun solve(input: String): Pair<Int, Int> { var memory = input.split("""\s+""".toRegex()).map { it.toInt() } val visited = mutableMapOf<List<Int>, Int>() ...
0
Kotlin
0
1
f4890c25841c78784b308db0c814d88cf2de384b
1,001
advent-of-code
MIT License
src/main/kotlin/com/staricka/adventofcode2023/days/Day9.kt
mathstar
719,656,133
false
{"Kotlin": 107115}
package com.staricka.adventofcode2023.days import com.staricka.adventofcode2023.framework.Day class Day9: Day { private fun produceDiffSequence(original: List<Int>): List<List<Int>> { val result = ArrayList<List<Int>>() result.add(original) while (result.last().any { it != 0 }) { ...
0
Kotlin
0
0
8c1e3424bb5d58f6f590bf96335e4d8d89ae9ffa
1,406
adventOfCode2023
MIT License
2021/05/main.kt
chylex
433,239,393
false
null
import java.io.File import kotlin.math.abs import kotlin.math.max import kotlin.math.min import kotlin.system.measureTimeMillis fun main() { val lineRegex = Regex("^(\\d+),(\\d+) -> (\\d+),(\\d+)$") val lines = File("input.txt").readLines() .mapNotNull(lineRegex::matchEntire) .map { it.groupValues.takeLast(4).ma...
0
Rust
0
0
04e2c35138f59bee0a3edcb7acb31f66e8aa350f
2,843
Advent-of-Code
The Unlicense
2017/src/twentyfive/PortBridgeChallenge.kt
Mattias1
116,139,424
false
null
package twentyfive fun portBridgeInput(): List<String> = listOf( "31/13", "34/4", "49/49", "23/37", "47/45", "32/4", "12/35", "37/30", "41/48", "0/47", "32/30", "12/5", "37/31", "7/41", "10/28", "35/4", "28/35", "20/29", "32/20", "31/43", "48/14", "10/11", "27/6", "9/24", "8/28", "45/48", "8/1"...
0
Kotlin
0
0
6bcd889c6652681e243d493363eef1c2e57d35ef
2,398
advent-of-code
MIT License
kotlin/src/katas/kotlin/adventofcode/day7/Part2.kt
dkandalov
2,517,870
false
{"Roff": 9263219, "JavaScript": 1513061, "Kotlin": 836347, "Scala": 475843, "Java": 475579, "Groovy": 414833, "Haskell": 148306, "HTML": 112989, "Ruby": 87169, "Python": 35433, "Rust": 32693, "C": 31069, "Clojure": 23648, "Lua": 19599, "C#": 12576, "q": 11524, "Scheme": 10734, "CSS": 8639, "R": 7235, "Racket": 6875, "C...
package katas.kotlin.adventofcode.day7 import katas.kotlin.adventofcode.day5.* import nonstdlib.* import java.io.* fun main() { val program = File("src/katas/kotlin/adventofcode/day7/input.txt") .readText().split(",").map(String::toInt).toMutableList() val maxOutput = (5..9).permutations() .m...
7
Roff
3
5
0f169804fae2984b1a78fc25da2d7157a8c7a7be
1,404
katas
The Unlicense
src/Day01.kt
dmarcato
576,511,169
false
{"Kotlin": 36664}
fun main() { fun part1(input: List<String>): Int { val output = mutableListOf<Int>() var count = 0 input.forEach { if (it.isEmpty()) { output.add(count) count = 0 } else { count += it.toInt() } } ...
0
Kotlin
0
0
6abd8ca89a1acce49ecc0ca8a51acd3969979464
968
aoc2022
Apache License 2.0
src/main/kotlin/io/binarysearch/FindKClosestElements.kt
jffiorillo
138,075,067
false
{"Kotlin": 434399, "Java": 14529, "Shell": 465}
@file:Suppress("MemberVisibilityCanBePrivate") package io.binarysearch // https://leetcode.com/explore/learn/card/binary-search/135/template-iii/945/ class FindKClosestElements { fun execute(input: IntArray, k: Int, target: Int): List<Int> = when { input.isEmpty() -> emptyList() k == input.size -> input.to...
0
Kotlin
0
0
f093c2c19cd76c85fab87605ae4a3ea157325d43
2,708
coding
MIT License
src/test/kotlin/com/igorwojda/tree/multiway/traversal/breathfirst/Solution.kt
igorwojda
159,511,104
false
{"Kotlin": 254856}
package com.igorwojda.tree.multiway.traversal.breathfirst private object Solution1 { private fun traverseBreathFirst(tree: BinarySearchTree<Char>): List<Char> { val queue = Queue<BinaryNode<Char>>() val result = mutableListOf<Char>() if (tree.isEmpty()) { return result ...
9
Kotlin
225
895
b09b738846e9f30ad2e9716e4e1401e2724aeaec
3,215
kotlin-coding-challenges
MIT License
src/main/kotlin/day23/Code.kt
fcolasuonno
317,324,330
false
null
package day23 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,594
AOC2020
MIT License
src/main/kotlin/game/GameBoard.kt
kevinpbaker
512,335,324
false
{"Kotlin": 44698}
import koma.abs import koma.ceil import koma.extensions.forEachIndexed import koma.extensions.get import koma.fill import koma.floor import koma.matrix.Matrix interface GameBoard { val rows: Int val cols: Int var colors: Array<IntArray> fun isFilled(x: Int, y: Int): Boolean { return when { ...
0
Kotlin
0
2
cf5b5f595b8e25e88b7cd7979230df804173332d
3,740
TetrisAI
MIT License
src/Day22.kt
Allagash
572,736,443
false
{"Kotlin": 101198}
import java.io.File // Advent of Code 2022, Day 22: Monkey Map class Day22(input: String) { private val moveInstructions: String private val maze: Array<CharArray> init { val inputParts = input.split("\n\n") moveInstructions = inputParts[1] val mazeInput = inputParts[0].split("\...
0
Kotlin
0
0
8d5fc0b93f6d600878ac0d47128140e70d7fc5d9
4,279
AdventOfCode2022
Apache License 2.0
hackerrank/abbr/Solution.kts
shengmin
5,972,157
false
null
import java.io.* import java.math.* import java.security.* import java.text.* import java.util.* import java.util.concurrent.* import java.util.function.* import java.util.regex.* import java.util.stream.* import kotlin.collections.* import kotlin.comparisons.* import kotlin.io.* import kotlin.jvm.* import kotlin.jvm.f...
0
Java
18
20
08e65546527436f4bd2a2014350b2f97ac1367e7
1,816
coding-problem
MIT License
src/main/kotlin/dev/shtanko/algorithms/leetcode/MergeStringsAlternately.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
1,941
kotlab
Apache License 2.0
src/day09/Day09.kt
Frank112
572,910,492
false
null
import day08.Direction import day08.MoveCommand import day08.Rope fun main() { val moveCommandRegex = Regex("^([DULR]) (\\d+)$") fun mapDirection(s: String): Direction { return when(s) { "D" -> Direction.DOWN "U" -> Direction.UP "L" -> Direction.LEFT "R...
0
Kotlin
0
0
1e927c95191a154efc0fe91a7b89d8ff526125eb
1,452
advent-of-code-2022
Apache License 2.0
src/main/kotlin/se/saidaspen/aoc/aoc2022/Day05.kt
saidaspen
354,930,478
false
{"Kotlin": 301372, "CSS": 530}
package se.saidaspen.aoc.aoc2022 import se.saidaspen.aoc.util.Day import se.saidaspen.aoc.util.ints import se.saidaspen.aoc.util.removeFirst fun main() = Day05.run() object Day05 : Day(2022, 5) { override fun part1(): Any { val stacks = mutableMapOf<Int, ArrayDeque<Char>>().withDefault { ArrayDeque() } ...
0
Kotlin
0
1
be120257fbce5eda9b51d3d7b63b121824c6e877
1,859
adventofkotlin
MIT License
kotlinLeetCode/src/main/kotlin/leetcode/editor/cn/[17]电话号码的字母组合.kt
maoqitian
175,940,000
false
{"Kotlin": 354268, "Java": 297740, "C++": 634}
//给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 // // 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 // // // // // // 示例 1: // // //输入:digits = "23" //输出:["ad","ae","af","bd","be","bf","cd","ce","cf"] // // // 示例 2: // // //输入:digits = "" //输出:[] // // // 示例 3: // // //输入:digits = "2" //输出:["a","b","c"] // // // ...
0
Kotlin
0
1
8a85996352a88bb9a8a6a2712dce3eac2e1c3463
2,010
MyLeetCode
Apache License 2.0
src/main/kotlin/ru/nsu/lupa/ChainProcessor.kt
lilvadim
576,661,907
false
{"Kotlin": 22514, "Java": 836}
package ru.nsu.lupa class ChainProcessor: ResultProcessor { /** * Convert match graph to list of chains from longest to shortest */ private lateinit var g: Map<Profile, Map<Profile, Set<MatchCriteria>>> private lateinit var rootChainNode: ChainNode<Set<MatchCriteria>, Profile> private var c...
0
Kotlin
0
0
9388aa69457bc625317a3732f2afcd52e02ef1a1
1,844
lupa
Apache License 2.0
src/Day06/Day06.kt
G-lalonde
574,649,075
false
{"Kotlin": 39626}
package Day06 import readInput fun main() { fun part1(input: List<String>): Int { val signal = input[0] val queue = Queue<Char>() for ((i, c) in signal.withIndex()) { if (queue.size() == 4) { return i } if (queue.contains(c)) { ...
0
Kotlin
0
0
3463c3228471e7fc08dbe6f89af33199da1ceac9
1,756
aoc-2022
Apache License 2.0
src/main/kotlin/dev/shtanko/algorithms/leetcode/MinOperationsBinaryString.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,059
kotlab
Apache License 2.0
src/iii_conventions/MyDate.kt
EugenIvanushkin
90,234,259
true
{"Kotlin": 77289, "Java": 4952}
package iii_conventions import java.time.Month data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(date: MyDate): Int { if (this.year.compareTo(date.year) == 0) { if (this.month.compareTo(date.month) == 0) { if (th...
0
Kotlin
0
0
321e41c17ba3dab01ee7f182ec1a1f4494ba232d
1,857
kotlin-koans
MIT License
src/sat.kt
JoelEager
126,541,542
false
null
import kotlin.math.pow class Vector(var x: Double, var y: Double) /** * @param poly1, poly2 The two polygons described as arrays of points as Vectors * Note: The points list must go in sequence around the polygon * @param maxDist The maximum distance between any two points of any two polygons that can be touching...
0
Kotlin
0
0
2c05f92310d25d638cf36d54a82522e7c85eacc6
2,568
Kotlin-Collision-Detector
MIT License
src/main/kotlin/adventofcode2017/Day21FractalArt.kt
n81ur3
484,801,748
false
{"Kotlin": 476844, "Java": 275}
package adventofcode2017 class Day21FractalArt data class FractalRule(val original: String, val transformed: String) class FractalArt(ruleLines: List<String>) { val rules: List<FractalRule> val fractals: MutableList<Fractal> = mutableListOf() val activePixels: Int get() = fractals.sumOf { it.acti...
0
Kotlin
0
0
fdc59410c717ac4876d53d8688d03b9b044c1b7e
6,211
kotlin-coding-challenges
MIT License
src/main/kotlin/year2022/Day01.kt
simpor
572,200,851
false
{"Kotlin": 80923}
import AoCUtils import AoCUtils.test fun main() { fun part1(input: String, debug: Boolean = false): Long { val elves = input.split("\n\n") return elves.map { s -> s.split("\n") .sumOf { it.toInt() } }.max().toLong() } fun part2(input: String, debug: Boo...
0
Kotlin
0
0
631cbd22ca7bdfc8a5218c306402c19efd65330b
1,170
aoc-2022-kotlin
Apache License 2.0
src/main/kotlin/year2022/Day18.kt
forketyfork
572,832,465
false
{"Kotlin": 142196}
package year2022 import utils.Point3D class Day18(input: String) { enum class Plane { XY, YZ, XZ } data class Face(val point: Point3D, val plane: Plane) private val Point3D.faces get() = setOf( Face(this, Plane.XY), Face(this, Plane.XZ), Face(this...
0
Kotlin
0
0
5c5e6304b1758e04a119716b8de50a7525668112
2,005
aoc-2022
Apache License 2.0
src/main/kotlin/ch/uzh/ifi/seal/bencher/prioritization/search/PermutationNeighborhood.kt
chrstphlbr
227,602,878
false
{"Kotlin": 918163, "Java": 29153}
package ch.uzh.ifi.seal.bencher.prioritization.search import org.uma.jmetal.solution.permutationsolution.PermutationSolution import org.uma.jmetal.util.neighborhood.Neighborhood // Implementation of a test suite neighborhood as defined in Li et al. "Search Algorithms for Regression Test Case Prioritization" // The ne...
0
Kotlin
2
4
06601fb4dda3b2996c2ba9b2cd612e667420006f
1,629
bencher
Apache License 2.0
src/main/kotlin/com/ginsberg/advent2017/Day23.kt
tginsberg
112,672,087
false
null
/* * Copyright (c) 2017 by <NAME> */ package com.ginsberg.advent2017 /** * AoC 2017, Day 23 * * Problem Description: http://adventofcode.com/2017/day/23 * Blog Post/Commentary: https://todd.ginsberg.com/post/advent-of-code/2017/day23/ */ class Day23(private val input: List<String>) { fun solvePart1(): Lon...
0
Kotlin
0
15
a57219e75ff9412292319b71827b35023f709036
1,833
advent-2017-kotlin
MIT License
src/main/List.kt
ivan-moto
162,077,405
false
{"Kotlin": 21137}
import java.util.Objects import kotlin.math.max fun <T> all(list: List<T>, predicate: (T) -> Boolean): Boolean = list.all(predicate) fun <T> allEqual(list: List<T>): Boolean = if (list.isEmpty()) false else list.all { it == list[0] } fun <T> any(list: List<T>, predicate: (T) -> Boolean): Boolean = list.a...
0
Kotlin
17
251
772896cb8d835c66a6e543c0c5a3f0aacea492c2
12,974
30-seconds-of-kotlin
MIT License
src/main/kotlin/g0301_0400/s0388_longest_absolute_file_path/Solution.kt
javadev
190,711,550
false
{"Kotlin": 4420233, "TypeScript": 50437, "Python": 3646, "Shell": 994}
package g0301_0400.s0388_longest_absolute_file_path // #Medium #String #Depth_First_Search #Stack // #2022_11_24_Time_150_ms_(100.00%)_Space_33.6_MB_(100.00%) import java.util.ArrayDeque import java.util.Deque class Solution { fun lengthLongestPath(input: String): Int { val stack: Deque<Int> = ArrayDeque...
0
Kotlin
14
24
fc95a0f4e1d629b71574909754ca216e7e1110d2
2,220
LeetCode-in-Kotlin
MIT License
src/com/ncorti/aoc2023/Day06.kt
cortinico
723,409,155
false
{"Kotlin": 76642}
package com.ncorti.aoc2023 fun main() { fun part1(): Int { val (time, distance) = getInputAsText("06") { split("\n").filter(String::isNotBlank).map { it.split(" ").filter(String::isNotBlank).drop(1).map(String::toInt) } } val wins = IntArray(time.size...
1
Kotlin
0
1
84e06f0cb0350a1eed17317a762359e9c9543ae5
1,146
adventofcode-2023
MIT License
tasks-3/lib/src/main/kotlin/flows/algo/NetworkPathFinder.kt
AzimMuradov
472,473,231
false
{"Kotlin": 127576}
package flows.algo import flows.algo.PathFindingMode.BFS import flows.algo.PathFindingMode.DFS import flows.structures.Matrix import flows.structures.Network /** * Find path in the [network][this] that can be valid flow in the [residual network][residualNetworkCapacities] using given [mode]. */ internal fun <V> Net...
0
Kotlin
0
0
01c0c46df9dc32c2cc6d3efc48b3a9ee880ce799
1,668
discrete-math-spbu
Apache License 2.0
aoc2023/src/main/kotlin/de/havox_design/aoc2023/day08/HauntedWasteland.kt
Gentleman1983
737,309,232
false
{"Kotlin": 746488, "Java": 441473, "Scala": 33415, "Groovy": 5725, "Python": 3319}
package de.havox_design.aoc2023.day08 import de.havox_design.aoc.utils.kotlin.model.directions.LeftRightDirection import java.util.regex.Pattern class HauntedWasteland(private var filename: String) { private val PATTERN_GROUP_NODE_NAME = "nodeName" private val PATTERN_GROUP_LEFT_NODE_NAME = "leftNodeName" ...
4
Kotlin
0
1
35ce3f13415f6bb515bd510a1f540ebd0c3afb04
3,941
advent-of-code
Apache License 2.0
src/kotlin2022/Day07.kt
egnbjork
571,981,366
false
{"Kotlin": 18156}
package kotlin2022 import readInput const val CD = "$ cd " const val TOTAL_SPACE = 70000000 const val UPDATE_SPACE = 30000000 fun main() { val gameInput = readInput("Day07_test") val currentDirectoryPath = mutableListOf<String>("") val dirSizes = mutableMapOf<String, Int>() for (line in gameInput) ...
0
Kotlin
0
0
1294afde171a64b1a2dfad2d30ff495d52f227f5
1,385
advent-of-code-kotlin
Apache License 2.0
src/Day01.kt
bin-wang
572,801,360
false
{"Kotlin": 19395}
fun main() { fun getCalories(input: List<String>): List<Int> { return input .split { it.isBlank() } .map { it.sumOf(Integer::parseInt) } } fun part1(input: List<String>): Int { val calories = getCalories(input) return calories.max() } fun part2(input...
0
Kotlin
0
0
dca2c4915594a4b4ca2791843b53b71fd068fe28
730
aoc22-kt
Apache License 2.0
src/aoc23/Day04.kt
mihassan
575,356,150
false
{"Kotlin": 123343}
@file:Suppress("PackageDirectoryMismatch") package aoc23.day04 import kotlin.math.min import lib.Solution import lib.Strings.extractInts import lib.Strings.ints data class Card(val id: Int, val winningNumbers: Set<Int>, val numbersInHand: Set<Int>) { fun matches(): Int = (numbersInHand intersect winningNumbers).si...
0
Kotlin
0
0
698316da8c38311366ee6990dd5b3e68b486b62d
1,405
aoc-kotlin
Apache License 2.0
src/Day01.kt
pmellaaho
573,136,030
false
{"Kotlin": 22024}
fun main() { fun part1(input: List<String>): Int { var max = 0 val value = input.fold(0) { r, t -> try { t.toInt() + r } catch (e: Exception) { if (r > max) max = r 0 } } return if (max > value) max ...
0
Kotlin
0
0
cd13824d9bbae3b9debee1a59d05a3ab66565727
1,015
AoC_22
Apache License 2.0
src/main/kotlin/com/leetcode/P241.kt
antop-dev
229,558,170
false
{"Kotlin": 695315, "Java": 213000}
package com.leetcode // https://leetcode.com/problems/different-ways-to-add-parentheses/ class P241 { private val ops = setOf('+', '-', '*') fun diffWaysToCompute(expression: String): List<Int> { val values = mutableListOf<Int>() // 연산자를 만나면 왼쪽 계산식과 오른쪽 계산식을 나눠서 재귀 expression.forEachIn...
1
Kotlin
0
0
9a3e762af93b078a2abd0d97543123a06e327164
1,161
algorithm
MIT License
src/main/kotlin/aoc2021/Day18.kt
j4velin
572,870,735
false
{"Kotlin": 285016, "Python": 1446}
package aoc2021 import readInput import kotlin.math.ceil import kotlin.math.floor import kotlin.math.max private sealed class SnailfishNumber(var parent: SnailfishPair?) { protected abstract fun explode(currentLevel: Int): Boolean abstract fun split(): Boolean abstract fun getMostRightPrimitive(): Snailf...
0
Kotlin
0
0
f67b4d11ef6a02cba5b206aba340df1e9631b42b
8,378
adventOfCode
Apache License 2.0
src/main/kotlin/P023_NonAbundantSums.kt
perihanmirkelam
291,833,878
false
null
/** * P23-Non-Abundant Sums * * A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. * For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, * which means that 28 is a perfect number. * * A number n is called deficient if the sum of i...
0
Kotlin
1
3
a24ac440871220c87419bfd5938f80dc22a422b2
1,739
ProjectEuler
MIT License
16/src/main/kotlin/AuntGuesser.kt
kopernic-pl
109,750,709
false
null
import com.google.common.io.Resources @Suppress("MagicNumber") val facts = mapOf( "children" to 3, "cats" to 7, "samoyeds" to 2, "pomeranians" to 3, "akitas" to 0, "vizslas" to 0, "goldfish" to 5, "trees" to 3, "cars" to 2, "perfumes" to 1 ) fun isEqualTo(value: Int): (Int) -> ...
0
Kotlin
0
0
06367f7e16c0db340c7bda8bc2ff991756e80e5b
3,082
aoc-2015-kotlin
The Unlicense
NumberOfIslands.kt
ncschroeder
604,822,497
false
{"Kotlin": 19399}
/* https://leetcode.com/problems/number-of-islands/ Given an m x n 2D binary grid `grid` which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the gr...
0
Kotlin
0
0
c77d0c8bb0595e61960193fc9b0c7a31952e8e48
1,733
Coding-Challenges
MIT License
AoC2021day15-Chiton/src/main/kotlin/Main.kt
mcrispim
533,770,397
false
{"Kotlin": 29888}
import java.io.File lateinit var cave: List<List<Int>> data class Position(val x: Int, val y: Int) fun main() { val originalCave = File("data.txt").readLines().map { str -> str.map { c-> c.digitToInt() } } // For the first part, cave = originalCave. // For the second part, cave = growCave(originalCave) cave =...
0
Kotlin
0
0
ac4aa71c9b5955fa4077ae40fc7e3fc3d5242523
2,552
AoC2021
MIT License
workshops/moscow_prefinals2020/day3/e.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package workshops.moscow_prefinals2020.day3 private typealias State = Int private fun solve() { val (hei, wid) = readInts() val field = List(hei) { readLn().toCharArray() } val state = IntArray(hei) { -1 } fun arrayToInt(): Int { var m = 0 for (i in 0 until hei) { val bits = state[i] and 15 m = m or (b...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
3,019
competitions
The Unlicense
src/day01/Day01.kt
martin3398
572,166,179
false
{"Kotlin": 76153}
package day01 import readInput fun main() { fun part1(input: List<String>): Int { var cur = 0 var maxVal = -1 input.forEach { if (it == "") { if (cur > maxVal) { maxVal = cur } cur = 0 } else { ...
0
Kotlin
0
0
4277dfc11212a997877329ac6df387c64be9529e
1,220
advent-of-code-2022
Apache License 2.0
test/leetcode/DetermineColorOfAChessboardSquare.kt
andrej-dyck
340,964,799
false
null
package leetcode import leetcode.SquareColor.* import lib.isEven import lib.require import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource /** * https://leetcode.com/problems/determine-color-of-a-chessboard-square/descr...
0
Kotlin
0
0
3e3baf8454c34793d9771f05f330e2668fda7e9d
2,909
coding-challenges
MIT License
Kotlin/MergeSort.kt
sukritishah15
299,329,204
false
null
/** * Algorithm: Merge Sorting * Language: Kotlin * Input: * a) n: Size of Array * b) arr: Integer Array of size n * Output: * a) Array before applying Merge Sorting * b) Array after applying Merge Sorting * Time Complexity: O(n * log n) * Space Complexity: O(n) * * Sample Input: * Enter th...
164
Java
295
955
1b6040f7d9af5830882b53916e83d53a9c0d67d1
2,223
DS-Algo-Point
MIT License
solutions/src/solutions/y21/day 13.kt
Kroppeb
225,582,260
false
null
@file:Suppress("PackageDirectoryMismatch", "UnusedImport") package solutions.y21.d13 /* import grid.Clock import helpers.* import itertools.* import kotlin.math.* */ import grid.Clock import helpers.* val xxxxx = Clock(6, 3); /* */ private fun part1() { var (paper, folds) = getLines(2021_13).splitOn { it.is...
0
Kotlin
0
1
744b02b4acd5c6799654be998a98c9baeaa25a79
2,567
AdventOfCodeSolutions
MIT License
src/main/kotlin/parts/wisdom/simplednn/Learning.kt
deansher
267,331,452
false
null
package parts.wisdom.simplednn import koma.matrix.Matrix private const val BATCH_SIZE = 20 private const val NUM_EPOCHS = 25 data class Coords(val row: Int, val col: Int) { constructor(idx: IntArray) : this( idx.let { require(it.size == 2) { "Can't construct Coords...
0
Kotlin
0
0
f4fc329b86f2ef231d5b9e1d982d6acafe275418
2,491
simple-dnn-from-scratch-kotlin
The Unlicense
pdg/src/main/kotlin/me/haydencheers/nscpdt/pdg/util/GraphEditDistanceEvaluator.kt
hjc851
247,242,039
false
null
package me.haydencheers.nscpdt.pdg.util import com.automation.graph.HungarianAlgorithm import org.graphstream.graph.Edge import org.graphstream.graph.Graph import org.graphstream.graph.Node import kotlin.math.max object GraphEditDistanceEvaluator { fun evaluate(g1: Graph, g2: Graph) = evaluate(g1, g2, 3.0, 1.0, 1...
0
Kotlin
0
0
b697648f04710a58722dfc1b764a3e43e56b4c4a
6,728
NaiveSCPDTools
MIT License
src/day19/Utils.kt
g0dzill3r
576,012,003
false
{"Kotlin": 172121}
package day19 fun <T> MutableMap<T, Int>.add (t: T, count: Int) { val already = get (t) if (already != null) { put (t, already + count) } else { put (t, count) } } fun permutations (pairs: List<Robots>): List<List<Robots>> { return _permutations (pairs) .map { i...
0
Kotlin
0
0
6ec11a5120e4eb180ab6aff3463a2563400cc0c3
1,150
advent_of_code_2022
Apache License 2.0
hoon/HoonAlgorithm/src/main/kotlin/programmers/lv01/Lv1_12918.kt
boris920308
618,428,844
false
{"Kotlin": 137657, "Swift": 35553, "Java": 1947, "Rich Text Format": 407}
package main.kotlin.programmers.lv01 /** * * https://school.programmers.co.kr/learn/courses/30/lessons/12918 * * 문자열 다루기 기본 * 문제 설명 * 문자열 s의 길이가 4 혹은 6이고, 숫자로만 구성돼있는지 확인해주는 함수, solution을 완성하세요. * 예를 들어 s가 "a234"이면 False를 리턴하고 "1234"라면 True를 리턴하면 됩니다. * * 제한 사항 * s는 길이 1 이상, 길이 8 이하인 문자열입니다. * s는 영문 알파벳 대소문자...
1
Kotlin
1
2
88814681f7ded76e8aa0fa7b85fe472769e760b4
1,043
HoOne
Apache License 2.0
codeforces/polynomial2022/b_slow.kt
mikhail-dvorkin
93,438,157
false
{"Java": 2219540, "Kotlin": 615766, "Haskell": 393104, "Python": 103162, "Shell": 4295, "Batchfile": 408}
package codeforces.polynomial2022 import java.util.TreeSet private fun solve(): String { val (n, _, k) = readInts() val a = readInts() val allow = LongArray(n) { -1 } val allowed = TreeSet<Long>() fun encode(count: Int, index: Int) = (count.toLong() shl 32) + index.toLong() for (i in a.indices) { allowed.add(...
0
Java
1
9
30953122834fcaee817fe21fb108a374946f8c7c
804
competitions
The Unlicense
src/main/kotlin/me/peckb/aoc/_2020/calendar/day07/Day07.kt
peckb1
433,943,215
false
{"Kotlin": 956135}
package me.peckb.aoc._2020.calendar.day07 import javax.inject.Inject import me.peckb.aoc.generators.InputGenerator.InputGeneratorFactory class Day07 @Inject constructor( private val generatorFactory: InputGeneratorFactory, ) { fun partOne(filename: String) = generatorFactory.forFile(filename).readAs(::bagData) {...
0
Kotlin
1
3
2625719b657eb22c83af95abfb25eb275dbfee6a
3,069
advent-of-code
MIT License