kt_path stringlengths 35 167 | kt_source stringlengths 626 28.9k | classes listlengths 1 17 |
|---|---|---|
akshaybhongale__Largest-Sum-Contiguous-Subarray-Kotlin__e2de2c9/MaximumSubArray.kt | /**
* Array Data Structure Problem
* Largest Sum Contiguous Sub-array
* Kotlin solution :
* 1- Simple approach = time complexity O(n*n) where n is size of array
* 2- kadane approach = time complexity O(n) where n is size of array
*/
class MaximumSubArray {
companion object {
@JvmStatic
fun ma... | [
{
"class_path": "akshaybhongale__Largest-Sum-Contiguous-Subarray-Kotlin__e2de2c9/MaximumSubArray.class",
"javap": "Compiled from \"MaximumSubArray.kt\"\npublic final class MaximumSubArray {\n public static final MaximumSubArray$Companion Companion;\n\n public MaximumSubArray();\n Code:\n 0: aload... |
strouilhet__KeepCalmAndCode3__f779bf1/séance 1 et 2 _ classe et objet/correction/Complexe.kt | import kotlin.math.PI
import kotlin.math.atan
import kotlin.math.round
import kotlin.math.sqrt
class Complexe(val reel: Double = 0.0, val im: Double = 0.0) {
constructor(c: Complexe) : this(c.reel, c.im)
fun module(): Double = sqrt(reel * reel + im * im)
fun argument(): Double =
if (reel == 0.0)... | [
{
"class_path": "strouilhet__KeepCalmAndCode3__f779bf1/Complexe.class",
"javap": "Compiled from \"Complexe.kt\"\npublic final class Complexe {\n public static final Complexe$Companion Companion;\n\n private final double reel;\n\n private final double im;\n\n private static final Complexe I;\n\n private... |
benjaminjkraft__aoc2017__e3ac356/day10.kt | fun doHash(lengths: List<Int>, n: Int, rounds: Int): Array<Int> {
var pos = 0
var skip = 0
val list = Array(n, { it })
for (round in 0 until rounds) {
for (i in lengths.indices) {
val listAgain = list.copyOf()
for (j in 0 until lengths[i]) {
list[(pos + j)... | [
{
"class_path": "benjaminjkraft__aoc2017__e3ac356/Day10Kt.class",
"javap": "Compiled from \"day10.kt\"\npublic final class Day10Kt {\n public static final java.lang.Integer[] doHash(java.util.List<java.lang.Integer>, int, int);\n Code:\n 0: aload_0\n 1: ldc #10 // S... |
thuva4__Algorithms__7da835f/algorithms/Kotlin/QuickSort/QuickSort.kt | fun printArray(x: IntArray) {
for (i in x.indices)
print(x[i].toString() + " ")
}
fun IntArray.sort(low: Int = 0, high: Int = this.size - 1) {
if (low >= high) return
val middle = partition(low, high)
sort(low, middle - 1)
sort(middle + 1, high)
}
fun IntArray.partition(low: Int, high: I... | [
{
"class_path": "thuva4__Algorithms__7da835f/QuickSortKt.class",
"javap": "Compiled from \"QuickSort.kt\"\npublic final class QuickSortKt {\n public static final void printArray(int[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String x\n 3: invokestatic #15 ... |
dlfelps__aoc-2022__3ebcc49/src/Day01.kt | import java.io.File
fun main() {
fun parseInput(input: String) : List<Int> {
fun getNext(rest: List<Int?>): Pair<Int,List<Int?>> {
val next = rest.takeWhile {it != null} as List<Int>
val temp = rest.dropWhile {it != null}
val rest = if (temp.isEmpty()) {
... | [
{
"class_path": "dlfelps__aoc-2022__3ebcc49/Day01Kt.class",
"javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // Stri... |
MisterTeatime__AoC2022__d684bd2/src/Utils.kt | import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import kotlin.math.absoluteValue
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = File("src", "$name.txt").readLines()
/**
* Converts string to md5 hash.
*/
fun String.md5(): String = BigInteger(1, ... | [
{
"class_path": "MisterTeatime__AoC2022__d684bd2/UtilsKt.class",
"javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n... |
UlrichBerntien__Codewars-Katas__034d7f2/6_kyu/Playing_with_digits.kt | /** Power function for integers */
fun Int.pow(exp: Int): Long {
return this.toBigInteger().pow(exp).toLong()
}
/**
* Sum decimal digits with power.
*
* @param x Calculate the digit powerd sum of this int.
* @param p The exponent of the most significant digit.
* @return sum of all decimal digits with power p,... | [
{
"class_path": "UlrichBerntien__Codewars-Katas__034d7f2/Playing_with_digitsKt.class",
"javap": "Compiled from \"Playing_with_digits.kt\"\npublic final class Playing_with_digitsKt {\n public static final long pow(int, int);\n Code:\n 0: iload_0\n 1: i2l\n 2: invokestatic #12 ... |
UlrichBerntien__Codewars-Katas__034d7f2/4_kyu/The_observed_PIN.kt | /**
* Generates all possible PINs based on the observed PIN. The true PIN is around the observed PIN.
* Each key could be also the key around the observed key.
*
* @param The observed PIN.
* @return All possible PINs.
*/
fun getPINs(observed: String): List<String> =
when (observed.length) {
0 -> empty... | [
{
"class_path": "UlrichBerntien__Codewars-Katas__034d7f2/The_observed_PINKt.class",
"javap": "Compiled from \"The_observed_PIN.kt\"\npublic final class The_observed_PINKt {\n private static final java.util.Map<java.lang.Character, char[]> keyNeighbours;\n\n public static final java.util.List<java.lang.Str... |
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/LargestPalindromicNumber.kt | /**
* # Largest Palindromic Number
* Problem:
* https://leetcode.com/problems/largest-palindromic-number/
*/
class LargestPalindromicNumber {
fun largestPalindromic(num: String): String {
val digits = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
for (c in num) {
val digit = c.digitToI... | [
{
"class_path": "ILIYANGERMANOV__algorithms__4abe4b5/LargestPalindromicNumber.class",
"javap": "Compiled from \"LargestPalindromicNumber.kt\"\npublic final class LargestPalindromicNumber {\n public LargestPalindromicNumber();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Met... |
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/NextClosestTime.kt | fun main() {
val sut = NextClosestTime()
for (h in 0..23) {
val hour = if (h < 10) "0$h" else h.toString()
for (m in 0..59) {
val minute = if (m < 10) "0$m" else m.toString()
val time = "$hour:$minute"
println("\"$time\" -> \"${sut.nextClosestTime(time)}\"")
... | [
{
"class_path": "ILIYANGERMANOV__algorithms__4abe4b5/NextClosestTimeKt.class",
"javap": "Compiled from \"NextClosestTime.kt\"\npublic final class NextClosestTimeKt {\n public static final void main();\n Code:\n 0: new #8 // class NextClosestTime\n 3: dup\n 4:... |
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/MinimumAreaRectangle.kt | import kotlin.math.pow
import kotlin.math.sqrt
typealias Point = IntArray
/**
* # Minimum Area Rectangle
*
* _Note: Time Limit Exceeded (not optimal)_
*
* Problem:
* https://leetcode.com/problems/minimum-area-rectangle/
*/
class MinimumAreaRectangle {
fun minAreaRect(points: Array<Point>): Int {
v... | [
{
"class_path": "ILIYANGERMANOV__algorithms__4abe4b5/MinimumAreaRectangleKt.class",
"javap": "Compiled from \"MinimumAreaRectangle.kt\"\npublic final class MinimumAreaRectangleKt {\n}\n",
"javap_err": ""
},
{
"class_path": "ILIYANGERMANOV__algorithms__4abe4b5/MinimumAreaRectangle.class",
"ja... |
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/AllWaysToMakeChange.kt | fun numberOfWaysToMakeChange(n: Int, denoms: List<Int>): Int {
// Write your code here.
println("----------- CASE: n = $n, denoms = $denoms ----------------")
val allWays = ways(
n = n,
ds = denoms,
)
println("All ways: $allWays")
val uniqueWays = allWays.map { it.sorted() }.toSe... | [
{
"class_path": "ILIYANGERMANOV__algorithms__4abe4b5/AllWaysToMakeChangeKt.class",
"javap": "Compiled from \"AllWaysToMakeChange.kt\"\npublic final class AllWaysToMakeChangeKt {\n public static final int numberOfWaysToMakeChange(int, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n ... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5